LCOV - code coverage report
Current view: top level - src/frontend/SageIII/astFileIO - SourcesOfIRNodesAstFileIOSupport.C (source / functions) Hit Total Coverage
Test: ROSE Lines: 29202 80653 36.2 %
Date: 2022-12-08 13:48:47 Functions: 3359 6800 49.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // MACHINE GENERATED SOURCE FILE WITH ROSE (Grammar.h)--- DO NOT MODIFY!
       2             : 
       3             : #include "sage3basic.h"
       4             : 
       5             : #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
       6             :    #include "AST_FILE_IO.h"
       7             : #endif 
       8             : // The header file ("rose_config.h") should only be included by source files that require it.
       9             : #include "rose_config.h"
      10             : 
      11             : #if _MSC_VER
      12             : #define USE_CPP_NEW_DELETE_OPERATORS 0
      13             : #endif
      14             : 
      15             : #define ROSE_ALLOC_TRACE 0
      16             : #undef mprintf
      17             : #define mprintf Rose::Diagnostics::mfprintf(Rose::ir_node_mlog[Rose::Diagnostics::DEBUG])
      18             : 
      19             : 
      20             : using namespace std;
      21             : #include "Cxx_GrammarMemoryPoolSupport.h"
      22             : 
      23             : 
      24             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
      25             : 
      26             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
      27             : 
      28             : //############################################################################
      29             : /* JH (02/02/2006) Constructor of the IR node SgNode that takes its 
      30             :  * corresponding StorageClass as parameter
      31             :  */
      32     1599690 : SgNode :: SgNode ( const SgNodeStorageClass& storageSource )   
      33             :    {
      34             : 
      35             : 
      36             : /* #line 37 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
      37             : 
      38     1599690 :      p_freepointer = AST_FileIO::IS_VALID_POINTER() ; 
      39     1599690 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
      40     1599690 :      p_parent =  (SgNode*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parent) );
      41     1599690 :      p_isModified = storageSource.storageOf_isModified ;
      42     1599690 :      p_containsTransformation = storageSource.storageOf_containsTransformation ;
      43             : 
      44             : 
      45             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
      46             : 
      47             : 
      48     1599690 :    }
      49             : 
      50             : //############################################################################
      51             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
      52             :  * within the working AST. 
      53             :  */
      54           0 : SgNode * SgNode::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
      55           0 :      SgNode* returnPointer = NULL;
      56           0 :      if ( globalIndex != 0 )
      57             :         {
      58             : 
      59             : #if FILE_IO_EXTRA_CHECK
      60           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNode ) ) <= globalIndex ) ;
      61           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNode + 1 ) ) );
      62             : #endif
      63           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNode )  
      64           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNode );
      65           0 :           unsigned long positionInPool = localIndex % SgNode::pool_size;
      66           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNode::pool_size;
      67             : 
      68             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
      69             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
      70             : 
      71           0 :           returnPointer = &( ( (SgNode*)(SgNode::pools[memoryBlock]) ) [positionInPool]) ;
      72             : 
      73           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
      74             :         }
      75           0 :      return returnPointer ;
      76             :    }
      77             : 
      78             : //############################################################################
      79             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
      80             :   for the AST with the index astIndex
      81             : */
      82           0 : SgNode * SgNode::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
      83           0 :      SgNode* returnPointer = NULL;
      84           0 :      if ( globalIndex != 0 )
      85             :         {
      86             : 
      87             : #if FILE_IO_EXTRA_CHECK
      88           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNode ) ) <= globalIndex ) ;
      89           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNode + 1 ) ) );
      90             : #endif
      91           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNode )
      92           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNode );
      93           0 :           unsigned long positionInPool = localIndex % SgNode::pool_size ;
      94           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNode::pool_size ;
      95             : 
      96             : #if FILE_IO_EXTRA_CHECK
      97             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
      98             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
      99             : #endif
     100             : 
     101           0 :           returnPointer = &( ( (SgNode*)(SgNode::pools[memoryBlock]) ) [positionInPool]) ;
     102             : 
     103             : #if FILE_IO_EXTRA_CHECK
     104           0 :           assert ( returnPointer != NULL ) ;
     105             : #endif
     106             :         }
     107           0 :      return returnPointer ;
     108             :    }
     109             : 
     110             : //############################################################################
     111             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
     112             :  * pool size! We set for every valid object in the memory pool the freepointer
     113             :  * to the global index and increase the global index afterwards. For all the 
     114             :  * invalid objects (means address ranges within the memory pool that were not
     115             :  * returned by the new operator) the freepointer is set to NULL, in order to 
     116             :  * distinguish valid from invalid objects! 
     117             :  */
     118             : unsigned long
     119           5 : SgNode::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
     120             :    {
     121           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
     122           5 :      SgNode* pointer = NULL;
     123           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
     124           5 :      std::vector < unsigned char* > :: const_iterator block;
     125           5 :      for ( block = SgNode::pools.begin(); block != SgNode::pools.end() ; ++block )
     126             :         {
     127           0 :           pointer = (SgNode*)(*block);
     128           0 :           for (unsigned i = 0; i < SgNode::pool_size; ++i )
     129             :              {
     130             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
     131             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
     132             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
     133             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
     134             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
     135             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
     136             :             // properly; so this will have to be checked next.
     137             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
     138             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
     139           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
     140             :                   {
     141           0 :                     pointer[i].set_freepointer((SgNode*)(globalIndex));
     142           0 :                     globalIndex++;
     143             :                   }
     144             :                else
     145             :                   {
     146           0 :                     pointer[i].set_freepointer(NULL);
     147             :                   }
     148             :               }
     149             :         }
     150           5 :      return globalIndex;
     151             :    }
     152             : 
     153             : //############################################################################
     154             : // JH (01/14/2006)
     155             : void
     156           5 : SgNode::resetValidFreepointers( )
     157             :    {
     158           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
     159           5 :      SgNode* pointer = NULL;
     160           5 :      std::vector < unsigned char* > :: const_iterator block;
     161           5 :      SgNode* pointerOfLinkedList = NULL;
     162           5 :      for ( block = SgNode::pools.begin(); block != SgNode::pools.end() ; ++block )
     163             :         {
     164           0 :           pointer = (SgNode*)(*block);
     165           0 :           for (unsigned i = 0; i < SgNode::pool_size; ++i )
     166             :              {
     167             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
     168             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
     169             :             // memory blocks!.
     170           0 :                if ( pointer[i].get_freepointer() != NULL )
     171             :                   {
     172           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
     173             :                   }
     174             :                else
     175             :                   {
     176           0 :                     if ( pointerOfLinkedList == NULL )
     177             :                        {
     178           0 :                          SgNode::next_node = &(pointer[i]);
     179             :                        }
     180             :                     else
     181             :                        {
     182             :                       // printf ("In SgNode::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
     183           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
     184             :                        }
     185             :                     pointerOfLinkedList = &(pointer[i]);
     186             :                   }
     187             :               }
     188             :         }
     189             : 
     190           5 :      if ( pointerOfLinkedList != NULL )
     191             :         {
     192             :        // printf ("In SgNode::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
     193           0 :           pointerOfLinkedList->set_freepointer(NULL);
     194             :        // DQ (6/6/2010): Temporary debugging...
     195             :        //   ROSE_ASSERT(false);
     196             :         }
     197             : 
     198           5 :      return ;
     199             :    }
     200             : 
     201             : //############################################################################
     202             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
     203             :  * within the memory pool and resets the freepointers, in order to achieve a 
     204             :  * linked list, that has no jumps and starts at the beginning! This function 
     205             :  * does not extend the memory pool, since we do not delete any memory blocks,
     206             :  * but delete the valid objects.  
     207             :  */
     208             : void
     209           0 : SgNode::clearMemoryPool( )
     210             :    {
     211             :   // printf ("Inside of SgNode::clearMemoryPool() \n");
     212             : 
     213           0 :      SgNode* pointer = NULL, *tempPointer = NULL;
     214           0 :      std::vector < unsigned char* > :: const_iterator block;
     215           0 :      if ( SgNode::pools.empty() == false )
     216             :         {
     217           0 :           block = SgNode::pools.begin() ;
     218           0 :           SgNode::next_node = (SgNode*) (*block);
     219             : 
     220           0 :           while ( block != SgNode::pools.end() )
     221             :              {
     222           0 :                pointer = (SgNode*) (*block);
     223           0 :                if ( tempPointer != NULL )
     224             :                   {
     225           0 :                     tempPointer->set_freepointer(pointer);
     226             :                   }
     227           0 :                for (unsigned i = 0; i < SgNode::pool_size - 1; ++i)
     228             :                   {
     229           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
     230             :                   }
     231           0 :                 pointer[SgNode::pool_size-1].set_freepointer(NULL);
     232           0 :                 tempPointer = &(pointer[SgNode::pool_size-1]);
     233           0 :                 ++block;
     234             :              }
     235             :         }
     236           0 :    }
     237             : 
     238           5 : void SgNode::deleteMemoryPool() {
     239           5 :   for (auto p: SgNode::pools) {
     240           0 :     ROSE_FREE(p);
     241             :   }
     242           5 :   SgNode::next_node = nullptr;
     243           5 :   SgNode::pools.clear();
     244           5 : }
     245             : 
     246             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
     247             : //                 reading multiple binary files to for a single AST.
     248             : /////////// new version ////////////////////////////////
     249             : //############################################################################
     250             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
     251             : void
     252           2 : SgNode::extendMemoryPoolForFileIO( )
     253             :   {
     254           2 :     size_t blockIndex = SgNode::pools.size();
     255           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNode) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNode);
     256             : 
     257           2 :     while ( (blockIndex * SgNode::pool_size) < newPoolSize)
     258             :       {
     259             : #if ROSE_ALLOC_TRACE
     260             :         if (blockIndex > 0) {
     261             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNode) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNode) = %" PRIuPTR " SgNode::pool_size = %d \n",
     262             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNode),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNode),SgNode::pool_size);
     263             :         }
     264             : #endif
     265             : 
     266           0 :         SgNode * pointer = (SgNode*) ROSE_MALLOC ( SgNode::pool_size * sizeof(SgNode) );
     267           0 :         assert( pointer != NULL );
     268             : #if ROSE_ALLOC_MEMSET == 1
     269             :         memset(pointer, 0x00, SgNode::pool_size * sizeof(SgNode));
     270             : #elif ROSE_ALLOC_MEMSET == 2
     271             :         memset(pointer, 0xCC, SgNode::pool_size * sizeof(SgNode));
     272             : #endif
     273           0 :         SgNode::pools.push_back( (unsigned char*)(pointer) );
     274           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNode::pool_size * sizeof(SgNode), V_SgNode ) );
     275             : 
     276           0 :         if ( SgNode::next_node != NULL ) {
     277           0 :           if ( blockIndex > 0 ) {
     278           0 :             SgNode * blkptr = (SgNode*)(SgNode::pools[blockIndex-1]);
     279           0 :             blkptr[ SgNode::pool_size - 1 ].set_freepointer(pointer);
     280             :           }
     281             :         } else {
     282           0 :           SgNode::next_node = pointer;
     283             :         }
     284             : 
     285           0 :         for (unsigned i = 0; i < SgNode::pool_size-1; ++i)
     286             :            {
     287           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
     288             :            }
     289           0 :         pointer[ SgNode::pool_size -1 ].set_freepointer(NULL);
     290             : 
     291           0 :         blockIndex++;
     292             :       }
     293           2 :   }
     294             : 
     295             : //############################################################################
     296             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
     297             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
     298             :  * not compressed. However, that stuff is not yet implemented! 
     299             :  */
     300             : unsigned long
     301           0 : SgNode::getNumberOfLastValidPointer()
     302             :    {
     303           0 :       SgNode* testPointer = (SgNode*)(SgNode::pools.back());
     304           0 :       unsigned long localIndex = SgNode::pool_size - 1;
     305           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
     306             :          {
     307           0 :            localIndex--;
     308             :          }
     309           0 :       return (localIndex + SgNode::pool_size * (SgNode::pools.size()-1));
     310             :    }
     311             : 
     312             : //############################################################################
     313             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
     314             :  * memory pool and initializes the data member in class SgNodeStroageClass
     315             :  * from its counterpart of SgNode. The return value is just for checking, 
     316             :  * that the whole StorageClassArray is initialized!
     317             :  */
     318             : unsigned long
     319           0 : SgNode::initializeStorageClassArray( SgNodeStorageClass *storageArray )
     320             :    {
     321           0 :      unsigned long storageCounter = 0;
     322           0 :      std::vector < unsigned char* > :: const_iterator block = SgNode::pools.begin();
     323           0 :      SgNode* pointer = NULL;
     324           0 :      while ( block != SgNode::pools.end() ) {
     325           0 :           pointer = (SgNode*) (*block);
     326           0 :           for ( unsigned i = 0; i < SgNode::pool_size; ++i ) {
     327           0 :                if ( pointer->get_freepointer() != NULL ) {
     328           0 :                  storageArray->pickOutIRNodeData (pointer) ;
     329           0 :                  storageArray++;
     330           0 :                  storageCounter++;
     331             :                }
     332           0 :                pointer++;
     333             :              }
     334           0 :            block++;
     335             :         }
     336           0 :      return storageCounter;
     337             :    }
     338             : 
     339             : /* #line 340 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
     340             : 
     341             : 
     342             : 
     343             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
     344             : 
     345             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
     346             : 
     347             : //############################################################################
     348             : /* JH (02/02/2006) Constructor of the IR node SgSupport that takes its 
     349             :  * corresponding StorageClass as parameter
     350             :  */
     351     1381490 : SgSupport :: SgSupport ( const SgSupportStorageClass& storageSource )   : SgNode (storageSource)
     352             :    {
     353             : 
     354             : 
     355             : /* #line 356 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
     356             : 
     357     1381490 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
     358             : 
     359             : 
     360             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
     361             : 
     362             : 
     363     1381490 :    }
     364             : 
     365             : //############################################################################
     366             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
     367             :  * within the working AST. 
     368             :  */
     369           0 : SgSupport * SgSupport::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
     370           0 :      SgSupport* returnPointer = NULL;
     371           0 :      if ( globalIndex != 0 )
     372             :         {
     373             : 
     374             : #if FILE_IO_EXTRA_CHECK
     375           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSupport ) ) <= globalIndex ) ;
     376           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSupport + 1 ) ) );
     377             : #endif
     378           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSupport )  
     379           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSupport );
     380           0 :           unsigned long positionInPool = localIndex % SgSupport::pool_size;
     381           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSupport::pool_size;
     382             : 
     383             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
     384             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
     385             : 
     386           0 :           returnPointer = &( ( (SgSupport*)(SgSupport::pools[memoryBlock]) ) [positionInPool]) ;
     387             : 
     388           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
     389             :         }
     390           0 :      return returnPointer ;
     391             :    }
     392             : 
     393             : //############################################################################
     394             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
     395             :   for the AST with the index astIndex
     396             : */
     397           0 : SgSupport * SgSupport::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
     398           0 :      SgSupport* returnPointer = NULL;
     399           0 :      if ( globalIndex != 0 )
     400             :         {
     401             : 
     402             : #if FILE_IO_EXTRA_CHECK
     403           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSupport ) ) <= globalIndex ) ;
     404           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSupport + 1 ) ) );
     405             : #endif
     406           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSupport )
     407           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSupport );
     408           0 :           unsigned long positionInPool = localIndex % SgSupport::pool_size ;
     409           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSupport::pool_size ;
     410             : 
     411             : #if FILE_IO_EXTRA_CHECK
     412             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
     413             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
     414             : #endif
     415             : 
     416           0 :           returnPointer = &( ( (SgSupport*)(SgSupport::pools[memoryBlock]) ) [positionInPool]) ;
     417             : 
     418             : #if FILE_IO_EXTRA_CHECK
     419           0 :           assert ( returnPointer != NULL ) ;
     420             : #endif
     421             :         }
     422           0 :      return returnPointer ;
     423             :    }
     424             : 
     425             : //############################################################################
     426             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
     427             :  * pool size! We set for every valid object in the memory pool the freepointer
     428             :  * to the global index and increase the global index afterwards. For all the 
     429             :  * invalid objects (means address ranges within the memory pool that were not
     430             :  * returned by the new operator) the freepointer is set to NULL, in order to 
     431             :  * distinguish valid from invalid objects! 
     432             :  */
     433             : unsigned long
     434           5 : SgSupport::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
     435             :    {
     436           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
     437           5 :      SgSupport* pointer = NULL;
     438           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
     439           5 :      std::vector < unsigned char* > :: const_iterator block;
     440           5 :      for ( block = SgSupport::pools.begin(); block != SgSupport::pools.end() ; ++block )
     441             :         {
     442           0 :           pointer = (SgSupport*)(*block);
     443           0 :           for (unsigned i = 0; i < SgSupport::pool_size; ++i )
     444             :              {
     445             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
     446             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
     447             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
     448             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
     449             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
     450             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
     451             :             // properly; so this will have to be checked next.
     452             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
     453             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
     454           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
     455             :                   {
     456           0 :                     pointer[i].set_freepointer((SgSupport*)(globalIndex));
     457           0 :                     globalIndex++;
     458             :                   }
     459             :                else
     460             :                   {
     461           0 :                     pointer[i].set_freepointer(NULL);
     462             :                   }
     463             :               }
     464             :         }
     465           5 :      return globalIndex;
     466             :    }
     467             : 
     468             : //############################################################################
     469             : // JH (01/14/2006)
     470             : void
     471           5 : SgSupport::resetValidFreepointers( )
     472             :    {
     473           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
     474           5 :      SgSupport* pointer = NULL;
     475           5 :      std::vector < unsigned char* > :: const_iterator block;
     476           5 :      SgSupport* pointerOfLinkedList = NULL;
     477           5 :      for ( block = SgSupport::pools.begin(); block != SgSupport::pools.end() ; ++block )
     478             :         {
     479           0 :           pointer = (SgSupport*)(*block);
     480           0 :           for (unsigned i = 0; i < SgSupport::pool_size; ++i )
     481             :              {
     482             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
     483             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
     484             :             // memory blocks!.
     485           0 :                if ( pointer[i].get_freepointer() != NULL )
     486             :                   {
     487           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
     488             :                   }
     489             :                else
     490             :                   {
     491           0 :                     if ( pointerOfLinkedList == NULL )
     492             :                        {
     493           0 :                          SgSupport::next_node = &(pointer[i]);
     494             :                        }
     495             :                     else
     496             :                        {
     497             :                       // printf ("In SgSupport::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
     498           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
     499             :                        }
     500             :                     pointerOfLinkedList = &(pointer[i]);
     501             :                   }
     502             :               }
     503             :         }
     504             : 
     505           5 :      if ( pointerOfLinkedList != NULL )
     506             :         {
     507             :        // printf ("In SgSupport::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
     508           0 :           pointerOfLinkedList->set_freepointer(NULL);
     509             :        // DQ (6/6/2010): Temporary debugging...
     510             :        //   ROSE_ASSERT(false);
     511             :         }
     512             : 
     513           5 :      return ;
     514             :    }
     515             : 
     516             : //############################################################################
     517             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
     518             :  * within the memory pool and resets the freepointers, in order to achieve a 
     519             :  * linked list, that has no jumps and starts at the beginning! This function 
     520             :  * does not extend the memory pool, since we do not delete any memory blocks,
     521             :  * but delete the valid objects.  
     522             :  */
     523             : void
     524           0 : SgSupport::clearMemoryPool( )
     525             :    {
     526             :   // printf ("Inside of SgSupport::clearMemoryPool() \n");
     527             : 
     528           0 :      SgSupport* pointer = NULL, *tempPointer = NULL;
     529           0 :      std::vector < unsigned char* > :: const_iterator block;
     530           0 :      if ( SgSupport::pools.empty() == false )
     531             :         {
     532           0 :           block = SgSupport::pools.begin() ;
     533           0 :           SgSupport::next_node = (SgSupport*) (*block);
     534             : 
     535           0 :           while ( block != SgSupport::pools.end() )
     536             :              {
     537           0 :                pointer = (SgSupport*) (*block);
     538           0 :                if ( tempPointer != NULL )
     539             :                   {
     540           0 :                     tempPointer->set_freepointer(pointer);
     541             :                   }
     542           0 :                for (unsigned i = 0; i < SgSupport::pool_size - 1; ++i)
     543             :                   {
     544           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
     545             :                   }
     546           0 :                 pointer[SgSupport::pool_size-1].set_freepointer(NULL);
     547           0 :                 tempPointer = &(pointer[SgSupport::pool_size-1]);
     548           0 :                 ++block;
     549             :              }
     550             :         }
     551           0 :    }
     552             : 
     553           5 : void SgSupport::deleteMemoryPool() {
     554           5 :   for (auto p: SgSupport::pools) {
     555           0 :     ROSE_FREE(p);
     556             :   }
     557           5 :   SgSupport::next_node = nullptr;
     558           5 :   SgSupport::pools.clear();
     559           5 : }
     560             : 
     561             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
     562             : //                 reading multiple binary files to for a single AST.
     563             : /////////// new version ////////////////////////////////
     564             : //############################################################################
     565             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
     566             : void
     567           2 : SgSupport::extendMemoryPoolForFileIO( )
     568             :   {
     569           2 :     size_t blockIndex = SgSupport::pools.size();
     570           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSupport) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSupport);
     571             : 
     572           2 :     while ( (blockIndex * SgSupport::pool_size) < newPoolSize)
     573             :       {
     574             : #if ROSE_ALLOC_TRACE
     575             :         if (blockIndex > 0) {
     576             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSupport) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSupport) = %" PRIuPTR " SgSupport::pool_size = %d \n",
     577             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSupport),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSupport),SgSupport::pool_size);
     578             :         }
     579             : #endif
     580             : 
     581           0 :         SgSupport * pointer = (SgSupport*) ROSE_MALLOC ( SgSupport::pool_size * sizeof(SgSupport) );
     582           0 :         assert( pointer != NULL );
     583             : #if ROSE_ALLOC_MEMSET == 1
     584             :         memset(pointer, 0x00, SgSupport::pool_size * sizeof(SgSupport));
     585             : #elif ROSE_ALLOC_MEMSET == 2
     586             :         memset(pointer, 0xCC, SgSupport::pool_size * sizeof(SgSupport));
     587             : #endif
     588           0 :         SgSupport::pools.push_back( (unsigned char*)(pointer) );
     589           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSupport::pool_size * sizeof(SgSupport), V_SgSupport ) );
     590             : 
     591           0 :         if ( SgSupport::next_node != NULL ) {
     592           0 :           if ( blockIndex > 0 ) {
     593           0 :             SgSupport * blkptr = (SgSupport*)(SgSupport::pools[blockIndex-1]);
     594           0 :             blkptr[ SgSupport::pool_size - 1 ].set_freepointer(pointer);
     595             :           }
     596             :         } else {
     597           0 :           SgSupport::next_node = pointer;
     598             :         }
     599             : 
     600           0 :         for (unsigned i = 0; i < SgSupport::pool_size-1; ++i)
     601             :            {
     602           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
     603             :            }
     604           0 :         pointer[ SgSupport::pool_size -1 ].set_freepointer(NULL);
     605             : 
     606           0 :         blockIndex++;
     607             :       }
     608           2 :   }
     609             : 
     610             : //############################################################################
     611             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
     612             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
     613             :  * not compressed. However, that stuff is not yet implemented! 
     614             :  */
     615             : unsigned long
     616           0 : SgSupport::getNumberOfLastValidPointer()
     617             :    {
     618           0 :       SgSupport* testPointer = (SgSupport*)(SgSupport::pools.back());
     619           0 :       unsigned long localIndex = SgSupport::pool_size - 1;
     620           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
     621             :          {
     622           0 :            localIndex--;
     623             :          }
     624           0 :       return (localIndex + SgSupport::pool_size * (SgSupport::pools.size()-1));
     625             :    }
     626             : 
     627             : //############################################################################
     628             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
     629             :  * memory pool and initializes the data member in class SgSupportStroageClass
     630             :  * from its counterpart of SgSupport. The return value is just for checking, 
     631             :  * that the whole StorageClassArray is initialized!
     632             :  */
     633             : unsigned long
     634           0 : SgSupport::initializeStorageClassArray( SgSupportStorageClass *storageArray )
     635             :    {
     636           0 :      unsigned long storageCounter = 0;
     637           0 :      std::vector < unsigned char* > :: const_iterator block = SgSupport::pools.begin();
     638           0 :      SgSupport* pointer = NULL;
     639           0 :      while ( block != SgSupport::pools.end() ) {
     640           0 :           pointer = (SgSupport*) (*block);
     641           0 :           for ( unsigned i = 0; i < SgSupport::pool_size; ++i ) {
     642           0 :                if ( pointer->get_freepointer() != NULL ) {
     643           0 :                  storageArray->pickOutIRNodeData (pointer) ;
     644           0 :                  storageArray++;
     645           0 :                  storageCounter++;
     646             :                }
     647           0 :                pointer++;
     648             :              }
     649           0 :            block++;
     650             :         }
     651           0 :      return storageCounter;
     652             :    }
     653             : 
     654             : /* #line 655 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
     655             : 
     656             : 
     657             : 
     658             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
     659             : 
     660             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
     661             : 
     662             : //############################################################################
     663             : /* JH (02/02/2006) Constructor of the IR node SgModifier that takes its 
     664             :  * corresponding StorageClass as parameter
     665             :  */
     666      518147 : SgModifier :: SgModifier ( const SgModifierStorageClass& storageSource )   : SgSupport (storageSource)
     667             :    {
     668             : 
     669             : 
     670             : /* #line 671 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
     671             : 
     672      518147 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
     673             : 
     674             : 
     675             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
     676             : 
     677             : 
     678      518147 :    }
     679             : 
     680             : //############################################################################
     681             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
     682             :  * within the working AST. 
     683             :  */
     684           0 : SgModifier * SgModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
     685           0 :      SgModifier* returnPointer = NULL;
     686           0 :      if ( globalIndex != 0 )
     687             :         {
     688             : 
     689             : #if FILE_IO_EXTRA_CHECK
     690           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgModifier ) ) <= globalIndex ) ;
     691           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModifier + 1 ) ) );
     692             : #endif
     693           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModifier )  
     694           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgModifier );
     695           0 :           unsigned long positionInPool = localIndex % SgModifier::pool_size;
     696           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModifier::pool_size;
     697             : 
     698             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
     699             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
     700             : 
     701           0 :           returnPointer = &( ( (SgModifier*)(SgModifier::pools[memoryBlock]) ) [positionInPool]) ;
     702             : 
     703           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
     704             :         }
     705           0 :      return returnPointer ;
     706             :    }
     707             : 
     708             : //############################################################################
     709             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
     710             :   for the AST with the index astIndex
     711             : */
     712           0 : SgModifier * SgModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
     713           0 :      SgModifier* returnPointer = NULL;
     714           0 :      if ( globalIndex != 0 )
     715             :         {
     716             : 
     717             : #if FILE_IO_EXTRA_CHECK
     718           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgModifier ) ) <= globalIndex ) ;
     719           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModifier + 1 ) ) );
     720             : #endif
     721           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModifier )
     722           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgModifier );
     723           0 :           unsigned long positionInPool = localIndex % SgModifier::pool_size ;
     724           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModifier::pool_size ;
     725             : 
     726             : #if FILE_IO_EXTRA_CHECK
     727             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
     728             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
     729             : #endif
     730             : 
     731           0 :           returnPointer = &( ( (SgModifier*)(SgModifier::pools[memoryBlock]) ) [positionInPool]) ;
     732             : 
     733             : #if FILE_IO_EXTRA_CHECK
     734           0 :           assert ( returnPointer != NULL ) ;
     735             : #endif
     736             :         }
     737           0 :      return returnPointer ;
     738             :    }
     739             : 
     740             : //############################################################################
     741             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
     742             :  * pool size! We set for every valid object in the memory pool the freepointer
     743             :  * to the global index and increase the global index afterwards. For all the 
     744             :  * invalid objects (means address ranges within the memory pool that were not
     745             :  * returned by the new operator) the freepointer is set to NULL, in order to 
     746             :  * distinguish valid from invalid objects! 
     747             :  */
     748             : unsigned long
     749           5 : SgModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
     750             :    {
     751           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
     752           5 :      SgModifier* pointer = NULL;
     753           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
     754           5 :      std::vector < unsigned char* > :: const_iterator block;
     755           5 :      for ( block = SgModifier::pools.begin(); block != SgModifier::pools.end() ; ++block )
     756             :         {
     757           0 :           pointer = (SgModifier*)(*block);
     758           0 :           for (unsigned i = 0; i < SgModifier::pool_size; ++i )
     759             :              {
     760             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
     761             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
     762             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
     763             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
     764             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
     765             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
     766             :             // properly; so this will have to be checked next.
     767             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
     768             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
     769           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
     770             :                   {
     771           0 :                     pointer[i].set_freepointer((SgModifier*)(globalIndex));
     772           0 :                     globalIndex++;
     773             :                   }
     774             :                else
     775             :                   {
     776           0 :                     pointer[i].set_freepointer(NULL);
     777             :                   }
     778             :               }
     779             :         }
     780           5 :      return globalIndex;
     781             :    }
     782             : 
     783             : //############################################################################
     784             : // JH (01/14/2006)
     785             : void
     786           5 : SgModifier::resetValidFreepointers( )
     787             :    {
     788           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
     789           5 :      SgModifier* pointer = NULL;
     790           5 :      std::vector < unsigned char* > :: const_iterator block;
     791           5 :      SgModifier* pointerOfLinkedList = NULL;
     792           5 :      for ( block = SgModifier::pools.begin(); block != SgModifier::pools.end() ; ++block )
     793             :         {
     794           0 :           pointer = (SgModifier*)(*block);
     795           0 :           for (unsigned i = 0; i < SgModifier::pool_size; ++i )
     796             :              {
     797             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
     798             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
     799             :             // memory blocks!.
     800           0 :                if ( pointer[i].get_freepointer() != NULL )
     801             :                   {
     802           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
     803             :                   }
     804             :                else
     805             :                   {
     806           0 :                     if ( pointerOfLinkedList == NULL )
     807             :                        {
     808           0 :                          SgModifier::next_node = &(pointer[i]);
     809             :                        }
     810             :                     else
     811             :                        {
     812             :                       // printf ("In SgModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
     813           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
     814             :                        }
     815             :                     pointerOfLinkedList = &(pointer[i]);
     816             :                   }
     817             :               }
     818             :         }
     819             : 
     820           5 :      if ( pointerOfLinkedList != NULL )
     821             :         {
     822             :        // printf ("In SgModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
     823           0 :           pointerOfLinkedList->set_freepointer(NULL);
     824             :        // DQ (6/6/2010): Temporary debugging...
     825             :        //   ROSE_ASSERT(false);
     826             :         }
     827             : 
     828           5 :      return ;
     829             :    }
     830             : 
     831             : //############################################################################
     832             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
     833             :  * within the memory pool and resets the freepointers, in order to achieve a 
     834             :  * linked list, that has no jumps and starts at the beginning! This function 
     835             :  * does not extend the memory pool, since we do not delete any memory blocks,
     836             :  * but delete the valid objects.  
     837             :  */
     838             : void
     839           0 : SgModifier::clearMemoryPool( )
     840             :    {
     841             :   // printf ("Inside of SgModifier::clearMemoryPool() \n");
     842             : 
     843           0 :      SgModifier* pointer = NULL, *tempPointer = NULL;
     844           0 :      std::vector < unsigned char* > :: const_iterator block;
     845           0 :      if ( SgModifier::pools.empty() == false )
     846             :         {
     847           0 :           block = SgModifier::pools.begin() ;
     848           0 :           SgModifier::next_node = (SgModifier*) (*block);
     849             : 
     850           0 :           while ( block != SgModifier::pools.end() )
     851             :              {
     852           0 :                pointer = (SgModifier*) (*block);
     853           0 :                if ( tempPointer != NULL )
     854             :                   {
     855           0 :                     tempPointer->set_freepointer(pointer);
     856             :                   }
     857           0 :                for (unsigned i = 0; i < SgModifier::pool_size - 1; ++i)
     858             :                   {
     859           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
     860             :                   }
     861           0 :                 pointer[SgModifier::pool_size-1].set_freepointer(NULL);
     862           0 :                 tempPointer = &(pointer[SgModifier::pool_size-1]);
     863           0 :                 ++block;
     864             :              }
     865             :         }
     866           0 :    }
     867             : 
     868           5 : void SgModifier::deleteMemoryPool() {
     869           5 :   for (auto p: SgModifier::pools) {
     870           0 :     ROSE_FREE(p);
     871             :   }
     872           5 :   SgModifier::next_node = nullptr;
     873           5 :   SgModifier::pools.clear();
     874           5 : }
     875             : 
     876             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
     877             : //                 reading multiple binary files to for a single AST.
     878             : /////////// new version ////////////////////////////////
     879             : //############################################################################
     880             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
     881             : void
     882           2 : SgModifier::extendMemoryPoolForFileIO( )
     883             :   {
     884           2 :     size_t blockIndex = SgModifier::pools.size();
     885           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifier);
     886             : 
     887           2 :     while ( (blockIndex * SgModifier::pool_size) < newPoolSize)
     888             :       {
     889             : #if ROSE_ALLOC_TRACE
     890             :         if (blockIndex > 0) {
     891             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifier) = %" PRIuPTR " SgModifier::pool_size = %d \n",
     892             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifier),SgModifier::pool_size);
     893             :         }
     894             : #endif
     895             : 
     896           0 :         SgModifier * pointer = (SgModifier*) ROSE_MALLOC ( SgModifier::pool_size * sizeof(SgModifier) );
     897           0 :         assert( pointer != NULL );
     898             : #if ROSE_ALLOC_MEMSET == 1
     899             :         memset(pointer, 0x00, SgModifier::pool_size * sizeof(SgModifier));
     900             : #elif ROSE_ALLOC_MEMSET == 2
     901             :         memset(pointer, 0xCC, SgModifier::pool_size * sizeof(SgModifier));
     902             : #endif
     903           0 :         SgModifier::pools.push_back( (unsigned char*)(pointer) );
     904           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgModifier::pool_size * sizeof(SgModifier), V_SgModifier ) );
     905             : 
     906           0 :         if ( SgModifier::next_node != NULL ) {
     907           0 :           if ( blockIndex > 0 ) {
     908           0 :             SgModifier * blkptr = (SgModifier*)(SgModifier::pools[blockIndex-1]);
     909           0 :             blkptr[ SgModifier::pool_size - 1 ].set_freepointer(pointer);
     910             :           }
     911             :         } else {
     912           0 :           SgModifier::next_node = pointer;
     913             :         }
     914             : 
     915           0 :         for (unsigned i = 0; i < SgModifier::pool_size-1; ++i)
     916             :            {
     917           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
     918             :            }
     919           0 :         pointer[ SgModifier::pool_size -1 ].set_freepointer(NULL);
     920             : 
     921           0 :         blockIndex++;
     922             :       }
     923           2 :   }
     924             : 
     925             : //############################################################################
     926             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
     927             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
     928             :  * not compressed. However, that stuff is not yet implemented! 
     929             :  */
     930             : unsigned long
     931           0 : SgModifier::getNumberOfLastValidPointer()
     932             :    {
     933           0 :       SgModifier* testPointer = (SgModifier*)(SgModifier::pools.back());
     934           0 :       unsigned long localIndex = SgModifier::pool_size - 1;
     935           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
     936             :          {
     937           0 :            localIndex--;
     938             :          }
     939           0 :       return (localIndex + SgModifier::pool_size * (SgModifier::pools.size()-1));
     940             :    }
     941             : 
     942             : //############################################################################
     943             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
     944             :  * memory pool and initializes the data member in class SgModifierStroageClass
     945             :  * from its counterpart of SgModifier. The return value is just for checking, 
     946             :  * that the whole StorageClassArray is initialized!
     947             :  */
     948             : unsigned long
     949           0 : SgModifier::initializeStorageClassArray( SgModifierStorageClass *storageArray )
     950             :    {
     951           0 :      unsigned long storageCounter = 0;
     952           0 :      std::vector < unsigned char* > :: const_iterator block = SgModifier::pools.begin();
     953           0 :      SgModifier* pointer = NULL;
     954           0 :      while ( block != SgModifier::pools.end() ) {
     955           0 :           pointer = (SgModifier*) (*block);
     956           0 :           for ( unsigned i = 0; i < SgModifier::pool_size; ++i ) {
     957           0 :                if ( pointer->get_freepointer() != NULL ) {
     958           0 :                  storageArray->pickOutIRNodeData (pointer) ;
     959           0 :                  storageArray++;
     960           0 :                  storageCounter++;
     961             :                }
     962           0 :                pointer++;
     963             :              }
     964           0 :            block++;
     965             :         }
     966           0 :      return storageCounter;
     967             :    }
     968             : 
     969             : /* #line 970 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
     970             : 
     971             : 
     972             : 
     973             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
     974             : 
     975             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
     976             : 
     977             : //############################################################################
     978             : /* JH (02/02/2006) Constructor of the IR node SgModifierNodes that takes its 
     979             :  * corresponding StorageClass as parameter
     980             :  */
     981           0 : SgModifierNodes :: SgModifierNodes ( const SgModifierNodesStorageClass& storageSource )   : SgModifier (storageSource)
     982             :    {
     983             : 
     984             : 
     985             : /* #line 986 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
     986             : 
     987           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
     988           0 :      p_nodes = storageSource.storageOf_nodes.rebuildDataStoredInEasyStorageClass() ;
     989           0 :      SgModifierTypePtrVector::iterator i_nodes = p_nodes.begin() ; 
     990           0 :      for ( ; i_nodes != p_nodes.end(); ++i_nodes ) 
     991             :         {
     992           0 :           (*i_nodes) = (SgModifierTypePtrVector::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_nodes) ) );
     993             :         }
     994           0 :      p_next =  (SgModifierNodes*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_next) );
     995             : 
     996             : 
     997             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
     998             : 
     999             : 
    1000           0 :    }
    1001             : 
    1002             : //############################################################################
    1003             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    1004             :  * within the working AST. 
    1005             :  */
    1006           0 : SgModifierNodes * SgModifierNodes::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    1007           0 :      SgModifierNodes* returnPointer = NULL;
    1008           0 :      if ( globalIndex != 0 )
    1009             :         {
    1010             : 
    1011             : #if FILE_IO_EXTRA_CHECK
    1012           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgModifierNodes ) ) <= globalIndex ) ;
    1013           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModifierNodes + 1 ) ) );
    1014             : #endif
    1015           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModifierNodes )  
    1016           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgModifierNodes );
    1017           0 :           unsigned long positionInPool = localIndex % SgModifierNodes::pool_size;
    1018           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModifierNodes::pool_size;
    1019             : 
    1020             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    1021             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    1022             : 
    1023           0 :           returnPointer = &( ( (SgModifierNodes*)(SgModifierNodes::pools[memoryBlock]) ) [positionInPool]) ;
    1024             : 
    1025           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    1026             :         }
    1027           0 :      return returnPointer ;
    1028             :    }
    1029             : 
    1030             : //############################################################################
    1031             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    1032             :   for the AST with the index astIndex
    1033             : */
    1034           0 : SgModifierNodes * SgModifierNodes::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    1035           0 :      SgModifierNodes* returnPointer = NULL;
    1036           0 :      if ( globalIndex != 0 )
    1037             :         {
    1038             : 
    1039             : #if FILE_IO_EXTRA_CHECK
    1040           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgModifierNodes ) ) <= globalIndex ) ;
    1041           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModifierNodes + 1 ) ) );
    1042             : #endif
    1043           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModifierNodes )
    1044           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgModifierNodes );
    1045           0 :           unsigned long positionInPool = localIndex % SgModifierNodes::pool_size ;
    1046           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModifierNodes::pool_size ;
    1047             : 
    1048             : #if FILE_IO_EXTRA_CHECK
    1049             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    1050             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    1051             : #endif
    1052             : 
    1053           0 :           returnPointer = &( ( (SgModifierNodes*)(SgModifierNodes::pools[memoryBlock]) ) [positionInPool]) ;
    1054             : 
    1055             : #if FILE_IO_EXTRA_CHECK
    1056           0 :           assert ( returnPointer != NULL ) ;
    1057             : #endif
    1058             :         }
    1059           0 :      return returnPointer ;
    1060             :    }
    1061             : 
    1062             : //############################################################################
    1063             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    1064             :  * pool size! We set for every valid object in the memory pool the freepointer
    1065             :  * to the global index and increase the global index afterwards. For all the 
    1066             :  * invalid objects (means address ranges within the memory pool that were not
    1067             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    1068             :  * distinguish valid from invalid objects! 
    1069             :  */
    1070             : unsigned long
    1071           5 : SgModifierNodes::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    1072             :    {
    1073           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    1074           5 :      SgModifierNodes* pointer = NULL;
    1075           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    1076           5 :      std::vector < unsigned char* > :: const_iterator block;
    1077           5 :      for ( block = SgModifierNodes::pools.begin(); block != SgModifierNodes::pools.end() ; ++block )
    1078             :         {
    1079           0 :           pointer = (SgModifierNodes*)(*block);
    1080           0 :           for (unsigned i = 0; i < SgModifierNodes::pool_size; ++i )
    1081             :              {
    1082             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    1083             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    1084             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    1085             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    1086             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    1087             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    1088             :             // properly; so this will have to be checked next.
    1089             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    1090             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    1091           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    1092             :                   {
    1093           0 :                     pointer[i].set_freepointer((SgModifierNodes*)(globalIndex));
    1094           0 :                     globalIndex++;
    1095             :                   }
    1096             :                else
    1097             :                   {
    1098           0 :                     pointer[i].set_freepointer(NULL);
    1099             :                   }
    1100             :               }
    1101             :         }
    1102           5 :      return globalIndex;
    1103             :    }
    1104             : 
    1105             : //############################################################################
    1106             : // JH (01/14/2006)
    1107             : void
    1108           5 : SgModifierNodes::resetValidFreepointers( )
    1109             :    {
    1110           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    1111           5 :      SgModifierNodes* pointer = NULL;
    1112           5 :      std::vector < unsigned char* > :: const_iterator block;
    1113           5 :      SgModifierNodes* pointerOfLinkedList = NULL;
    1114           5 :      for ( block = SgModifierNodes::pools.begin(); block != SgModifierNodes::pools.end() ; ++block )
    1115             :         {
    1116           0 :           pointer = (SgModifierNodes*)(*block);
    1117           0 :           for (unsigned i = 0; i < SgModifierNodes::pool_size; ++i )
    1118             :              {
    1119             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    1120             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    1121             :             // memory blocks!.
    1122           0 :                if ( pointer[i].get_freepointer() != NULL )
    1123             :                   {
    1124           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    1125             :                   }
    1126             :                else
    1127             :                   {
    1128           0 :                     if ( pointerOfLinkedList == NULL )
    1129             :                        {
    1130           0 :                          SgModifierNodes::next_node = &(pointer[i]);
    1131             :                        }
    1132             :                     else
    1133             :                        {
    1134             :                       // printf ("In SgModifierNodes::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    1135           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    1136             :                        }
    1137             :                     pointerOfLinkedList = &(pointer[i]);
    1138             :                   }
    1139             :               }
    1140             :         }
    1141             : 
    1142           5 :      if ( pointerOfLinkedList != NULL )
    1143             :         {
    1144             :        // printf ("In SgModifierNodes::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    1145           0 :           pointerOfLinkedList->set_freepointer(NULL);
    1146             :        // DQ (6/6/2010): Temporary debugging...
    1147             :        //   ROSE_ASSERT(false);
    1148             :         }
    1149             : 
    1150           5 :      return ;
    1151             :    }
    1152             : 
    1153             : //############################################################################
    1154             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    1155             :  * within the memory pool and resets the freepointers, in order to achieve a 
    1156             :  * linked list, that has no jumps and starts at the beginning! This function 
    1157             :  * does not extend the memory pool, since we do not delete any memory blocks,
    1158             :  * but delete the valid objects.  
    1159             :  */
    1160             : void
    1161           0 : SgModifierNodes::clearMemoryPool( )
    1162             :    {
    1163             :   // printf ("Inside of SgModifierNodes::clearMemoryPool() \n");
    1164             : 
    1165           0 :      SgModifierNodes* pointer = NULL, *tempPointer = NULL;
    1166           0 :      std::vector < unsigned char* > :: const_iterator block;
    1167           0 :      if ( SgModifierNodes::pools.empty() == false )
    1168             :         {
    1169           0 :           block = SgModifierNodes::pools.begin() ;
    1170           0 :           SgModifierNodes::next_node = (SgModifierNodes*) (*block);
    1171             : 
    1172           0 :           while ( block != SgModifierNodes::pools.end() )
    1173             :              {
    1174           0 :                pointer = (SgModifierNodes*) (*block);
    1175           0 :                if ( tempPointer != NULL )
    1176             :                   {
    1177           0 :                     tempPointer->set_freepointer(pointer);
    1178             :                   }
    1179           0 :                for (unsigned i = 0; i < SgModifierNodes::pool_size - 1; ++i)
    1180             :                   {
    1181           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    1182             :                   }
    1183           0 :                 pointer[SgModifierNodes::pool_size-1].set_freepointer(NULL);
    1184           0 :                 tempPointer = &(pointer[SgModifierNodes::pool_size-1]);
    1185           0 :                 ++block;
    1186             :              }
    1187             :         }
    1188           0 :    }
    1189             : 
    1190           5 : void SgModifierNodes::deleteMemoryPool() {
    1191           5 :   for (auto p: SgModifierNodes::pools) {
    1192           0 :     ROSE_FREE(p);
    1193             :   }
    1194           5 :   SgModifierNodes::next_node = nullptr;
    1195           5 :   SgModifierNodes::pools.clear();
    1196           5 : }
    1197             : 
    1198             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    1199             : //                 reading multiple binary files to for a single AST.
    1200             : /////////// new version ////////////////////////////////
    1201             : //############################################################################
    1202             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    1203             : void
    1204           2 : SgModifierNodes::extendMemoryPoolForFileIO( )
    1205             :   {
    1206           2 :     size_t blockIndex = SgModifierNodes::pools.size();
    1207           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgModifierNodes) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifierNodes);
    1208             : 
    1209           2 :     while ( (blockIndex * SgModifierNodes::pool_size) < newPoolSize)
    1210             :       {
    1211             : #if ROSE_ALLOC_TRACE
    1212             :         if (blockIndex > 0) {
    1213             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgModifierNodes) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifierNodes) = %" PRIuPTR " SgModifierNodes::pool_size = %d \n",
    1214             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgModifierNodes),AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifierNodes),SgModifierNodes::pool_size);
    1215             :         }
    1216             : #endif
    1217             : 
    1218           0 :         SgModifierNodes * pointer = (SgModifierNodes*) ROSE_MALLOC ( SgModifierNodes::pool_size * sizeof(SgModifierNodes) );
    1219           0 :         assert( pointer != NULL );
    1220             : #if ROSE_ALLOC_MEMSET == 1
    1221             :         memset(pointer, 0x00, SgModifierNodes::pool_size * sizeof(SgModifierNodes));
    1222             : #elif ROSE_ALLOC_MEMSET == 2
    1223             :         memset(pointer, 0xCC, SgModifierNodes::pool_size * sizeof(SgModifierNodes));
    1224             : #endif
    1225           0 :         SgModifierNodes::pools.push_back( (unsigned char*)(pointer) );
    1226           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgModifierNodes::pool_size * sizeof(SgModifierNodes), V_SgModifierNodes ) );
    1227             : 
    1228           0 :         if ( SgModifierNodes::next_node != NULL ) {
    1229           0 :           if ( blockIndex > 0 ) {
    1230           0 :             SgModifierNodes * blkptr = (SgModifierNodes*)(SgModifierNodes::pools[blockIndex-1]);
    1231           0 :             blkptr[ SgModifierNodes::pool_size - 1 ].set_freepointer(pointer);
    1232             :           }
    1233             :         } else {
    1234           0 :           SgModifierNodes::next_node = pointer;
    1235             :         }
    1236             : 
    1237           0 :         for (unsigned i = 0; i < SgModifierNodes::pool_size-1; ++i)
    1238             :            {
    1239           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    1240             :            }
    1241           0 :         pointer[ SgModifierNodes::pool_size -1 ].set_freepointer(NULL);
    1242             : 
    1243           0 :         blockIndex++;
    1244             :       }
    1245           2 :   }
    1246             : 
    1247             : //############################################################################
    1248             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    1249             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    1250             :  * not compressed. However, that stuff is not yet implemented! 
    1251             :  */
    1252             : unsigned long
    1253           0 : SgModifierNodes::getNumberOfLastValidPointer()
    1254             :    {
    1255           0 :       SgModifierNodes* testPointer = (SgModifierNodes*)(SgModifierNodes::pools.back());
    1256           0 :       unsigned long localIndex = SgModifierNodes::pool_size - 1;
    1257           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    1258             :          {
    1259           0 :            localIndex--;
    1260             :          }
    1261           0 :       return (localIndex + SgModifierNodes::pool_size * (SgModifierNodes::pools.size()-1));
    1262             :    }
    1263             : 
    1264             : //############################################################################
    1265             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    1266             :  * memory pool and initializes the data member in class SgModifierNodesStroageClass
    1267             :  * from its counterpart of SgModifierNodes. The return value is just for checking, 
    1268             :  * that the whole StorageClassArray is initialized!
    1269             :  */
    1270             : unsigned long
    1271           0 : SgModifierNodes::initializeStorageClassArray( SgModifierNodesStorageClass *storageArray )
    1272             :    {
    1273           0 :      unsigned long storageCounter = 0;
    1274           0 :      std::vector < unsigned char* > :: const_iterator block = SgModifierNodes::pools.begin();
    1275           0 :      SgModifierNodes* pointer = NULL;
    1276           0 :      while ( block != SgModifierNodes::pools.end() ) {
    1277           0 :           pointer = (SgModifierNodes*) (*block);
    1278           0 :           for ( unsigned i = 0; i < SgModifierNodes::pool_size; ++i ) {
    1279           0 :                if ( pointer->get_freepointer() != NULL ) {
    1280           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    1281           0 :                  storageArray++;
    1282           0 :                  storageCounter++;
    1283             :                }
    1284           0 :                pointer++;
    1285             :              }
    1286           0 :            block++;
    1287             :         }
    1288           0 :      return storageCounter;
    1289             :    }
    1290             : 
    1291             : /* #line 1292 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    1292             : 
    1293             : 
    1294             : 
    1295             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    1296             : 
    1297             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    1298             : 
    1299             : //############################################################################
    1300             : /* JH (02/02/2006) Constructor of the IR node SgConstVolatileModifier that takes its 
    1301             :  * corresponding StorageClass as parameter
    1302             :  */
    1303       54713 : SgConstVolatileModifier :: SgConstVolatileModifier ( const SgConstVolatileModifierStorageClass& storageSource )   : SgModifier (storageSource)
    1304             :    {
    1305             : 
    1306             : 
    1307             : /* #line 1308 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    1308             : 
    1309       54713 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    1310       54713 :      p_modifier = storageSource.storageOf_modifier ;
    1311             : 
    1312             : 
    1313             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    1314             : 
    1315             : 
    1316       54713 :    }
    1317             : 
    1318             : //############################################################################
    1319             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    1320             :  * within the working AST. 
    1321             :  */
    1322           0 : SgConstVolatileModifier * SgConstVolatileModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    1323           0 :      SgConstVolatileModifier* returnPointer = NULL;
    1324           0 :      if ( globalIndex != 0 )
    1325             :         {
    1326             : 
    1327             : #if FILE_IO_EXTRA_CHECK
    1328           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgConstVolatileModifier ) ) <= globalIndex ) ;
    1329           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConstVolatileModifier + 1 ) ) );
    1330             : #endif
    1331           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConstVolatileModifier )  
    1332           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgConstVolatileModifier );
    1333           0 :           unsigned long positionInPool = localIndex % SgConstVolatileModifier::pool_size;
    1334           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConstVolatileModifier::pool_size;
    1335             : 
    1336             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    1337             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    1338             : 
    1339           0 :           returnPointer = &( ( (SgConstVolatileModifier*)(SgConstVolatileModifier::pools[memoryBlock]) ) [positionInPool]) ;
    1340             : 
    1341           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    1342             :         }
    1343           0 :      return returnPointer ;
    1344             :    }
    1345             : 
    1346             : //############################################################################
    1347             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    1348             :   for the AST with the index astIndex
    1349             : */
    1350           0 : SgConstVolatileModifier * SgConstVolatileModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    1351           0 :      SgConstVolatileModifier* returnPointer = NULL;
    1352           0 :      if ( globalIndex != 0 )
    1353             :         {
    1354             : 
    1355             : #if FILE_IO_EXTRA_CHECK
    1356           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgConstVolatileModifier ) ) <= globalIndex ) ;
    1357           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConstVolatileModifier + 1 ) ) );
    1358             : #endif
    1359           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConstVolatileModifier )
    1360           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgConstVolatileModifier );
    1361           0 :           unsigned long positionInPool = localIndex % SgConstVolatileModifier::pool_size ;
    1362           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConstVolatileModifier::pool_size ;
    1363             : 
    1364             : #if FILE_IO_EXTRA_CHECK
    1365             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    1366             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    1367             : #endif
    1368             : 
    1369           0 :           returnPointer = &( ( (SgConstVolatileModifier*)(SgConstVolatileModifier::pools[memoryBlock]) ) [positionInPool]) ;
    1370             : 
    1371             : #if FILE_IO_EXTRA_CHECK
    1372           0 :           assert ( returnPointer != NULL ) ;
    1373             : #endif
    1374             :         }
    1375           0 :      return returnPointer ;
    1376             :    }
    1377             : 
    1378             : //############################################################################
    1379             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    1380             :  * pool size! We set for every valid object in the memory pool the freepointer
    1381             :  * to the global index and increase the global index afterwards. For all the 
    1382             :  * invalid objects (means address ranges within the memory pool that were not
    1383             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    1384             :  * distinguish valid from invalid objects! 
    1385             :  */
    1386             : unsigned long
    1387           5 : SgConstVolatileModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    1388             :    {
    1389           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    1390           5 :      SgConstVolatileModifier* pointer = NULL;
    1391           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    1392           5 :      std::vector < unsigned char* > :: const_iterator block;
    1393           5 :      for ( block = SgConstVolatileModifier::pools.begin(); block != SgConstVolatileModifier::pools.end() ; ++block )
    1394             :         {
    1395           0 :           pointer = (SgConstVolatileModifier*)(*block);
    1396           0 :           for (unsigned i = 0; i < SgConstVolatileModifier::pool_size; ++i )
    1397             :              {
    1398             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    1399             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    1400             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    1401             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    1402             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    1403             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    1404             :             // properly; so this will have to be checked next.
    1405             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    1406             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    1407           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    1408             :                   {
    1409           0 :                     pointer[i].set_freepointer((SgConstVolatileModifier*)(globalIndex));
    1410           0 :                     globalIndex++;
    1411             :                   }
    1412             :                else
    1413             :                   {
    1414           0 :                     pointer[i].set_freepointer(NULL);
    1415             :                   }
    1416             :               }
    1417             :         }
    1418           5 :      return globalIndex;
    1419             :    }
    1420             : 
    1421             : //############################################################################
    1422             : // JH (01/14/2006)
    1423             : void
    1424           5 : SgConstVolatileModifier::resetValidFreepointers( )
    1425             :    {
    1426           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    1427           5 :      SgConstVolatileModifier* pointer = NULL;
    1428           5 :      std::vector < unsigned char* > :: const_iterator block;
    1429           5 :      SgConstVolatileModifier* pointerOfLinkedList = NULL;
    1430           5 :      for ( block = SgConstVolatileModifier::pools.begin(); block != SgConstVolatileModifier::pools.end() ; ++block )
    1431             :         {
    1432           0 :           pointer = (SgConstVolatileModifier*)(*block);
    1433           0 :           for (unsigned i = 0; i < SgConstVolatileModifier::pool_size; ++i )
    1434             :              {
    1435             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    1436             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    1437             :             // memory blocks!.
    1438           0 :                if ( pointer[i].get_freepointer() != NULL )
    1439             :                   {
    1440           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    1441             :                   }
    1442             :                else
    1443             :                   {
    1444           0 :                     if ( pointerOfLinkedList == NULL )
    1445             :                        {
    1446           0 :                          SgConstVolatileModifier::next_node = &(pointer[i]);
    1447             :                        }
    1448             :                     else
    1449             :                        {
    1450             :                       // printf ("In SgConstVolatileModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    1451           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    1452             :                        }
    1453             :                     pointerOfLinkedList = &(pointer[i]);
    1454             :                   }
    1455             :               }
    1456             :         }
    1457             : 
    1458           5 :      if ( pointerOfLinkedList != NULL )
    1459             :         {
    1460             :        // printf ("In SgConstVolatileModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    1461           0 :           pointerOfLinkedList->set_freepointer(NULL);
    1462             :        // DQ (6/6/2010): Temporary debugging...
    1463             :        //   ROSE_ASSERT(false);
    1464             :         }
    1465             : 
    1466           5 :      return ;
    1467             :    }
    1468             : 
    1469             : //############################################################################
    1470             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    1471             :  * within the memory pool and resets the freepointers, in order to achieve a 
    1472             :  * linked list, that has no jumps and starts at the beginning! This function 
    1473             :  * does not extend the memory pool, since we do not delete any memory blocks,
    1474             :  * but delete the valid objects.  
    1475             :  */
    1476             : void
    1477           0 : SgConstVolatileModifier::clearMemoryPool( )
    1478             :    {
    1479             :   // printf ("Inside of SgConstVolatileModifier::clearMemoryPool() \n");
    1480             : 
    1481           0 :      SgConstVolatileModifier* pointer = NULL, *tempPointer = NULL;
    1482           0 :      std::vector < unsigned char* > :: const_iterator block;
    1483           0 :      if ( SgConstVolatileModifier::pools.empty() == false )
    1484             :         {
    1485           0 :           block = SgConstVolatileModifier::pools.begin() ;
    1486           0 :           SgConstVolatileModifier::next_node = (SgConstVolatileModifier*) (*block);
    1487             : 
    1488           0 :           while ( block != SgConstVolatileModifier::pools.end() )
    1489             :              {
    1490           0 :                pointer = (SgConstVolatileModifier*) (*block);
    1491           0 :                if ( tempPointer != NULL )
    1492             :                   {
    1493           0 :                     tempPointer->set_freepointer(pointer);
    1494             :                   }
    1495           0 :                for (unsigned i = 0; i < SgConstVolatileModifier::pool_size - 1; ++i)
    1496             :                   {
    1497           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    1498             :                   }
    1499           0 :                 pointer[SgConstVolatileModifier::pool_size-1].set_freepointer(NULL);
    1500           0 :                 tempPointer = &(pointer[SgConstVolatileModifier::pool_size-1]);
    1501           0 :                 ++block;
    1502             :              }
    1503             :         }
    1504           0 :    }
    1505             : 
    1506           5 : void SgConstVolatileModifier::deleteMemoryPool() {
    1507           5 :   for (auto p: SgConstVolatileModifier::pools) {
    1508           0 :     ROSE_FREE(p);
    1509             :   }
    1510           5 :   SgConstVolatileModifier::next_node = nullptr;
    1511           5 :   SgConstVolatileModifier::pools.clear();
    1512           5 : }
    1513             : 
    1514             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    1515             : //                 reading multiple binary files to for a single AST.
    1516             : /////////// new version ////////////////////////////////
    1517             : //############################################################################
    1518             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    1519             : void
    1520           2 : SgConstVolatileModifier::extendMemoryPoolForFileIO( )
    1521             :   {
    1522           2 :     size_t blockIndex = SgConstVolatileModifier::pools.size();
    1523           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgConstVolatileModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgConstVolatileModifier);
    1524             : 
    1525           2 :     while ( (blockIndex * SgConstVolatileModifier::pool_size) < newPoolSize)
    1526             :       {
    1527             : #if ROSE_ALLOC_TRACE
    1528             :         if (blockIndex > 0) {
    1529             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgConstVolatileModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgConstVolatileModifier) = %" PRIuPTR " SgConstVolatileModifier::pool_size = %d \n",
    1530             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgConstVolatileModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgConstVolatileModifier),SgConstVolatileModifier::pool_size);
    1531             :         }
    1532             : #endif
    1533             : 
    1534           0 :         SgConstVolatileModifier * pointer = (SgConstVolatileModifier*) ROSE_MALLOC ( SgConstVolatileModifier::pool_size * sizeof(SgConstVolatileModifier) );
    1535           0 :         assert( pointer != NULL );
    1536             : #if ROSE_ALLOC_MEMSET == 1
    1537             :         memset(pointer, 0x00, SgConstVolatileModifier::pool_size * sizeof(SgConstVolatileModifier));
    1538             : #elif ROSE_ALLOC_MEMSET == 2
    1539             :         memset(pointer, 0xCC, SgConstVolatileModifier::pool_size * sizeof(SgConstVolatileModifier));
    1540             : #endif
    1541           0 :         SgConstVolatileModifier::pools.push_back( (unsigned char*)(pointer) );
    1542           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgConstVolatileModifier::pool_size * sizeof(SgConstVolatileModifier), V_SgConstVolatileModifier ) );
    1543             : 
    1544           0 :         if ( SgConstVolatileModifier::next_node != NULL ) {
    1545           0 :           if ( blockIndex > 0 ) {
    1546           0 :             SgConstVolatileModifier * blkptr = (SgConstVolatileModifier*)(SgConstVolatileModifier::pools[blockIndex-1]);
    1547           0 :             blkptr[ SgConstVolatileModifier::pool_size - 1 ].set_freepointer(pointer);
    1548             :           }
    1549             :         } else {
    1550           0 :           SgConstVolatileModifier::next_node = pointer;
    1551             :         }
    1552             : 
    1553           0 :         for (unsigned i = 0; i < SgConstVolatileModifier::pool_size-1; ++i)
    1554             :            {
    1555           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    1556             :            }
    1557           0 :         pointer[ SgConstVolatileModifier::pool_size -1 ].set_freepointer(NULL);
    1558             : 
    1559           0 :         blockIndex++;
    1560             :       }
    1561           2 :   }
    1562             : 
    1563             : //############################################################################
    1564             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    1565             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    1566             :  * not compressed. However, that stuff is not yet implemented! 
    1567             :  */
    1568             : unsigned long
    1569           0 : SgConstVolatileModifier::getNumberOfLastValidPointer()
    1570             :    {
    1571           0 :       SgConstVolatileModifier* testPointer = (SgConstVolatileModifier*)(SgConstVolatileModifier::pools.back());
    1572           0 :       unsigned long localIndex = SgConstVolatileModifier::pool_size - 1;
    1573           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    1574             :          {
    1575           0 :            localIndex--;
    1576             :          }
    1577           0 :       return (localIndex + SgConstVolatileModifier::pool_size * (SgConstVolatileModifier::pools.size()-1));
    1578             :    }
    1579             : 
    1580             : //############################################################################
    1581             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    1582             :  * memory pool and initializes the data member in class SgConstVolatileModifierStroageClass
    1583             :  * from its counterpart of SgConstVolatileModifier. The return value is just for checking, 
    1584             :  * that the whole StorageClassArray is initialized!
    1585             :  */
    1586             : unsigned long
    1587           0 : SgConstVolatileModifier::initializeStorageClassArray( SgConstVolatileModifierStorageClass *storageArray )
    1588             :    {
    1589           0 :      unsigned long storageCounter = 0;
    1590           0 :      std::vector < unsigned char* > :: const_iterator block = SgConstVolatileModifier::pools.begin();
    1591           0 :      SgConstVolatileModifier* pointer = NULL;
    1592           0 :      while ( block != SgConstVolatileModifier::pools.end() ) {
    1593           0 :           pointer = (SgConstVolatileModifier*) (*block);
    1594           0 :           for ( unsigned i = 0; i < SgConstVolatileModifier::pool_size; ++i ) {
    1595           0 :                if ( pointer->get_freepointer() != NULL ) {
    1596           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    1597           0 :                  storageArray++;
    1598           0 :                  storageCounter++;
    1599             :                }
    1600           0 :                pointer++;
    1601             :              }
    1602           0 :            block++;
    1603             :         }
    1604           0 :      return storageCounter;
    1605             :    }
    1606             : 
    1607             : /* #line 1608 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    1608             : 
    1609             : 
    1610             : 
    1611             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    1612             : 
    1613             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    1614             : 
    1615             : //############################################################################
    1616             : /* JH (02/02/2006) Constructor of the IR node SgStorageModifier that takes its 
    1617             :  * corresponding StorageClass as parameter
    1618             :  */
    1619      109062 : SgStorageModifier :: SgStorageModifier ( const SgStorageModifierStorageClass& storageSource )   : SgModifier (storageSource)
    1620             :    {
    1621             : 
    1622             : 
    1623             : /* #line 1624 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    1624             : 
    1625      109062 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    1626      109062 :      p_modifier = storageSource.storageOf_modifier ;
    1627      109062 :      p_thread_local_storage = storageSource.storageOf_thread_local_storage ;
    1628             : 
    1629             : 
    1630             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    1631             : 
    1632             : 
    1633      109062 :    }
    1634             : 
    1635             : //############################################################################
    1636             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    1637             :  * within the working AST. 
    1638             :  */
    1639       55225 : SgStorageModifier * SgStorageModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    1640       55225 :      SgStorageModifier* returnPointer = NULL;
    1641       55225 :      if ( globalIndex != 0 )
    1642             :         {
    1643             : 
    1644             : #if FILE_IO_EXTRA_CHECK
    1645       55225 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStorageModifier ) ) <= globalIndex ) ;
    1646       55225 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStorageModifier + 1 ) ) );
    1647             : #endif
    1648       55225 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStorageModifier )  
    1649       55225 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStorageModifier );
    1650       55225 :           unsigned long positionInPool = localIndex % SgStorageModifier::pool_size;
    1651       55225 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStorageModifier::pool_size;
    1652             : 
    1653             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    1654             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    1655             : 
    1656       55225 :           returnPointer = &( ( (SgStorageModifier*)(SgStorageModifier::pools[memoryBlock]) ) [positionInPool]) ;
    1657             : 
    1658       55225 :           ROSE_ASSERT( returnPointer != NULL ) ;
    1659             :         }
    1660       55225 :      return returnPointer ;
    1661             :    }
    1662             : 
    1663             : //############################################################################
    1664             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    1665             :   for the AST with the index astIndex
    1666             : */
    1667           0 : SgStorageModifier * SgStorageModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    1668           0 :      SgStorageModifier* returnPointer = NULL;
    1669           0 :      if ( globalIndex != 0 )
    1670             :         {
    1671             : 
    1672             : #if FILE_IO_EXTRA_CHECK
    1673           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStorageModifier ) ) <= globalIndex ) ;
    1674           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStorageModifier + 1 ) ) );
    1675             : #endif
    1676           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStorageModifier )
    1677           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStorageModifier );
    1678           0 :           unsigned long positionInPool = localIndex % SgStorageModifier::pool_size ;
    1679           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStorageModifier::pool_size ;
    1680             : 
    1681             : #if FILE_IO_EXTRA_CHECK
    1682             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    1683             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    1684             : #endif
    1685             : 
    1686           0 :           returnPointer = &( ( (SgStorageModifier*)(SgStorageModifier::pools[memoryBlock]) ) [positionInPool]) ;
    1687             : 
    1688             : #if FILE_IO_EXTRA_CHECK
    1689           0 :           assert ( returnPointer != NULL ) ;
    1690             : #endif
    1691             :         }
    1692           0 :      return returnPointer ;
    1693             :    }
    1694             : 
    1695             : //############################################################################
    1696             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    1697             :  * pool size! We set for every valid object in the memory pool the freepointer
    1698             :  * to the global index and increase the global index afterwards. For all the 
    1699             :  * invalid objects (means address ranges within the memory pool that were not
    1700             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    1701             :  * distinguish valid from invalid objects! 
    1702             :  */
    1703             : unsigned long
    1704           5 : SgStorageModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    1705             :    {
    1706           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    1707           5 :      SgStorageModifier* pointer = NULL;
    1708           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    1709           5 :      std::vector < unsigned char* > :: const_iterator block;
    1710          34 :      for ( block = SgStorageModifier::pools.begin(); block != SgStorageModifier::pools.end() ; ++block )
    1711             :         {
    1712          29 :           pointer = (SgStorageModifier*)(*block);
    1713       58029 :           for (unsigned i = 0; i < SgStorageModifier::pool_size; ++i )
    1714             :              {
    1715             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    1716             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    1717             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    1718             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    1719             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    1720             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    1721             :             // properly; so this will have to be checked next.
    1722             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    1723             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    1724       58000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    1725             :                   {
    1726       55225 :                     pointer[i].set_freepointer((SgStorageModifier*)(globalIndex));
    1727       55225 :                     globalIndex++;
    1728             :                   }
    1729             :                else
    1730             :                   {
    1731        2775 :                     pointer[i].set_freepointer(NULL);
    1732             :                   }
    1733             :               }
    1734             :         }
    1735           5 :      return globalIndex;
    1736             :    }
    1737             : 
    1738             : //############################################################################
    1739             : // JH (01/14/2006)
    1740             : void
    1741           5 : SgStorageModifier::resetValidFreepointers( )
    1742             :    {
    1743           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    1744           5 :      SgStorageModifier* pointer = NULL;
    1745           5 :      std::vector < unsigned char* > :: const_iterator block;
    1746           5 :      SgStorageModifier* pointerOfLinkedList = NULL;
    1747          34 :      for ( block = SgStorageModifier::pools.begin(); block != SgStorageModifier::pools.end() ; ++block )
    1748             :         {
    1749          29 :           pointer = (SgStorageModifier*)(*block);
    1750       58029 :           for (unsigned i = 0; i < SgStorageModifier::pool_size; ++i )
    1751             :              {
    1752             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    1753             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    1754             :             // memory blocks!.
    1755       58000 :                if ( pointer[i].get_freepointer() != NULL )
    1756             :                   {
    1757       55225 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    1758             :                   }
    1759             :                else
    1760             :                   {
    1761        2775 :                     if ( pointerOfLinkedList == NULL )
    1762             :                        {
    1763           2 :                          SgStorageModifier::next_node = &(pointer[i]);
    1764             :                        }
    1765             :                     else
    1766             :                        {
    1767             :                       // printf ("In SgStorageModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    1768        2773 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    1769             :                        }
    1770             :                     pointerOfLinkedList = &(pointer[i]);
    1771             :                   }
    1772             :               }
    1773             :         }
    1774             : 
    1775           5 :      if ( pointerOfLinkedList != NULL )
    1776             :         {
    1777             :        // printf ("In SgStorageModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    1778           2 :           pointerOfLinkedList->set_freepointer(NULL);
    1779             :        // DQ (6/6/2010): Temporary debugging...
    1780             :        //   ROSE_ASSERT(false);
    1781             :         }
    1782             : 
    1783           5 :      return ;
    1784             :    }
    1785             : 
    1786             : //############################################################################
    1787             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    1788             :  * within the memory pool and resets the freepointers, in order to achieve a 
    1789             :  * linked list, that has no jumps and starts at the beginning! This function 
    1790             :  * does not extend the memory pool, since we do not delete any memory blocks,
    1791             :  * but delete the valid objects.  
    1792             :  */
    1793             : void
    1794           0 : SgStorageModifier::clearMemoryPool( )
    1795             :    {
    1796             :   // printf ("Inside of SgStorageModifier::clearMemoryPool() \n");
    1797             : 
    1798           0 :      SgStorageModifier* pointer = NULL, *tempPointer = NULL;
    1799           0 :      std::vector < unsigned char* > :: const_iterator block;
    1800           0 :      if ( SgStorageModifier::pools.empty() == false )
    1801             :         {
    1802           0 :           block = SgStorageModifier::pools.begin() ;
    1803           0 :           SgStorageModifier::next_node = (SgStorageModifier*) (*block);
    1804             : 
    1805           0 :           while ( block != SgStorageModifier::pools.end() )
    1806             :              {
    1807           0 :                pointer = (SgStorageModifier*) (*block);
    1808           0 :                if ( tempPointer != NULL )
    1809             :                   {
    1810           0 :                     tempPointer->set_freepointer(pointer);
    1811             :                   }
    1812           0 :                for (unsigned i = 0; i < SgStorageModifier::pool_size - 1; ++i)
    1813             :                   {
    1814           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    1815             :                   }
    1816           0 :                 pointer[SgStorageModifier::pool_size-1].set_freepointer(NULL);
    1817           0 :                 tempPointer = &(pointer[SgStorageModifier::pool_size-1]);
    1818           0 :                 ++block;
    1819             :              }
    1820             :         }
    1821           0 :    }
    1822             : 
    1823           5 : void SgStorageModifier::deleteMemoryPool() {
    1824          63 :   for (auto p: SgStorageModifier::pools) {
    1825          58 :     ROSE_FREE(p);
    1826             :   }
    1827           5 :   SgStorageModifier::next_node = nullptr;
    1828           5 :   SgStorageModifier::pools.clear();
    1829           5 : }
    1830             : 
    1831             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    1832             : //                 reading multiple binary files to for a single AST.
    1833             : /////////// new version ////////////////////////////////
    1834             : //############################################################################
    1835             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    1836             : void
    1837           2 : SgStorageModifier::extendMemoryPoolForFileIO( )
    1838             :   {
    1839           2 :     size_t blockIndex = SgStorageModifier::pools.size();
    1840           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStorageModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStorageModifier);
    1841             : 
    1842          31 :     while ( (blockIndex * SgStorageModifier::pool_size) < newPoolSize)
    1843             :       {
    1844             : #if ROSE_ALLOC_TRACE
    1845             :         if (blockIndex > 0) {
    1846             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStorageModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStorageModifier) = %" PRIuPTR " SgStorageModifier::pool_size = %d \n",
    1847             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStorageModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStorageModifier),SgStorageModifier::pool_size);
    1848             :         }
    1849             : #endif
    1850             : 
    1851          29 :         SgStorageModifier * pointer = (SgStorageModifier*) ROSE_MALLOC ( SgStorageModifier::pool_size * sizeof(SgStorageModifier) );
    1852          29 :         assert( pointer != NULL );
    1853             : #if ROSE_ALLOC_MEMSET == 1
    1854             :         memset(pointer, 0x00, SgStorageModifier::pool_size * sizeof(SgStorageModifier));
    1855             : #elif ROSE_ALLOC_MEMSET == 2
    1856             :         memset(pointer, 0xCC, SgStorageModifier::pool_size * sizeof(SgStorageModifier));
    1857             : #endif
    1858          29 :         SgStorageModifier::pools.push_back( (unsigned char*)(pointer) );
    1859          29 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStorageModifier::pool_size * sizeof(SgStorageModifier), V_SgStorageModifier ) );
    1860             : 
    1861          29 :         if ( SgStorageModifier::next_node != NULL ) {
    1862          27 :           if ( blockIndex > 0 ) {
    1863          27 :             SgStorageModifier * blkptr = (SgStorageModifier*)(SgStorageModifier::pools[blockIndex-1]);
    1864          27 :             blkptr[ SgStorageModifier::pool_size - 1 ].set_freepointer(pointer);
    1865             :           }
    1866             :         } else {
    1867           2 :           SgStorageModifier::next_node = pointer;
    1868             :         }
    1869             : 
    1870       58000 :         for (unsigned i = 0; i < SgStorageModifier::pool_size-1; ++i)
    1871             :            {
    1872       57971 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    1873             :            }
    1874          29 :         pointer[ SgStorageModifier::pool_size -1 ].set_freepointer(NULL);
    1875             : 
    1876          29 :         blockIndex++;
    1877             :       }
    1878           2 :   }
    1879             : 
    1880             : //############################################################################
    1881             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    1882             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    1883             :  * not compressed. However, that stuff is not yet implemented! 
    1884             :  */
    1885             : unsigned long
    1886           0 : SgStorageModifier::getNumberOfLastValidPointer()
    1887             :    {
    1888           0 :       SgStorageModifier* testPointer = (SgStorageModifier*)(SgStorageModifier::pools.back());
    1889           0 :       unsigned long localIndex = SgStorageModifier::pool_size - 1;
    1890           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    1891             :          {
    1892           0 :            localIndex--;
    1893             :          }
    1894           0 :       return (localIndex + SgStorageModifier::pool_size * (SgStorageModifier::pools.size()-1));
    1895             :    }
    1896             : 
    1897             : //############################################################################
    1898             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    1899             :  * memory pool and initializes the data member in class SgStorageModifierStroageClass
    1900             :  * from its counterpart of SgStorageModifier. The return value is just for checking, 
    1901             :  * that the whole StorageClassArray is initialized!
    1902             :  */
    1903             : unsigned long
    1904           2 : SgStorageModifier::initializeStorageClassArray( SgStorageModifierStorageClass *storageArray )
    1905             :    {
    1906           2 :      unsigned long storageCounter = 0;
    1907           2 :      std::vector < unsigned char* > :: const_iterator block = SgStorageModifier::pools.begin();
    1908           2 :      SgStorageModifier* pointer = NULL;
    1909          31 :      while ( block != SgStorageModifier::pools.end() ) {
    1910          29 :           pointer = (SgStorageModifier*) (*block);
    1911       58029 :           for ( unsigned i = 0; i < SgStorageModifier::pool_size; ++i ) {
    1912       58000 :                if ( pointer->get_freepointer() != NULL ) {
    1913       55225 :                  storageArray->pickOutIRNodeData (pointer) ;
    1914       55225 :                  storageArray++;
    1915       55225 :                  storageCounter++;
    1916             :                }
    1917       58000 :                pointer++;
    1918             :              }
    1919          29 :            block++;
    1920             :         }
    1921           2 :      return storageCounter;
    1922             :    }
    1923             : 
    1924             : /* #line 1925 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    1925             : 
    1926             : 
    1927             : 
    1928             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    1929             : 
    1930             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    1931             : 
    1932             : //############################################################################
    1933             : /* JH (02/02/2006) Constructor of the IR node SgAccessModifier that takes its 
    1934             :  * corresponding StorageClass as parameter
    1935             :  */
    1936       54457 : SgAccessModifier :: SgAccessModifier ( const SgAccessModifierStorageClass& storageSource )   : SgModifier (storageSource)
    1937             :    {
    1938             : 
    1939             : 
    1940             : /* #line 1941 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    1941             : 
    1942       54457 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    1943       54457 :      p_modifier = storageSource.storageOf_modifier ;
    1944             : 
    1945             : 
    1946             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    1947             : 
    1948             : 
    1949       54457 :    }
    1950             : 
    1951             : //############################################################################
    1952             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    1953             :  * within the working AST. 
    1954             :  */
    1955           0 : SgAccessModifier * SgAccessModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    1956           0 :      SgAccessModifier* returnPointer = NULL;
    1957           0 :      if ( globalIndex != 0 )
    1958             :         {
    1959             : 
    1960             : #if FILE_IO_EXTRA_CHECK
    1961           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAccessModifier ) ) <= globalIndex ) ;
    1962           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAccessModifier + 1 ) ) );
    1963             : #endif
    1964           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAccessModifier )  
    1965           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAccessModifier );
    1966           0 :           unsigned long positionInPool = localIndex % SgAccessModifier::pool_size;
    1967           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAccessModifier::pool_size;
    1968             : 
    1969             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    1970             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    1971             : 
    1972           0 :           returnPointer = &( ( (SgAccessModifier*)(SgAccessModifier::pools[memoryBlock]) ) [positionInPool]) ;
    1973             : 
    1974           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    1975             :         }
    1976           0 :      return returnPointer ;
    1977             :    }
    1978             : 
    1979             : //############################################################################
    1980             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    1981             :   for the AST with the index astIndex
    1982             : */
    1983           0 : SgAccessModifier * SgAccessModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    1984           0 :      SgAccessModifier* returnPointer = NULL;
    1985           0 :      if ( globalIndex != 0 )
    1986             :         {
    1987             : 
    1988             : #if FILE_IO_EXTRA_CHECK
    1989           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAccessModifier ) ) <= globalIndex ) ;
    1990           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAccessModifier + 1 ) ) );
    1991             : #endif
    1992           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAccessModifier )
    1993           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAccessModifier );
    1994           0 :           unsigned long positionInPool = localIndex % SgAccessModifier::pool_size ;
    1995           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAccessModifier::pool_size ;
    1996             : 
    1997             : #if FILE_IO_EXTRA_CHECK
    1998             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    1999             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    2000             : #endif
    2001             : 
    2002           0 :           returnPointer = &( ( (SgAccessModifier*)(SgAccessModifier::pools[memoryBlock]) ) [positionInPool]) ;
    2003             : 
    2004             : #if FILE_IO_EXTRA_CHECK
    2005           0 :           assert ( returnPointer != NULL ) ;
    2006             : #endif
    2007             :         }
    2008           0 :      return returnPointer ;
    2009             :    }
    2010             : 
    2011             : //############################################################################
    2012             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    2013             :  * pool size! We set for every valid object in the memory pool the freepointer
    2014             :  * to the global index and increase the global index afterwards. For all the 
    2015             :  * invalid objects (means address ranges within the memory pool that were not
    2016             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    2017             :  * distinguish valid from invalid objects! 
    2018             :  */
    2019             : unsigned long
    2020           5 : SgAccessModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    2021             :    {
    2022           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    2023           5 :      SgAccessModifier* pointer = NULL;
    2024           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    2025           5 :      std::vector < unsigned char* > :: const_iterator block;
    2026           5 :      for ( block = SgAccessModifier::pools.begin(); block != SgAccessModifier::pools.end() ; ++block )
    2027             :         {
    2028           0 :           pointer = (SgAccessModifier*)(*block);
    2029           0 :           for (unsigned i = 0; i < SgAccessModifier::pool_size; ++i )
    2030             :              {
    2031             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    2032             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    2033             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    2034             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    2035             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    2036             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    2037             :             // properly; so this will have to be checked next.
    2038             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    2039             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    2040           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    2041             :                   {
    2042           0 :                     pointer[i].set_freepointer((SgAccessModifier*)(globalIndex));
    2043           0 :                     globalIndex++;
    2044             :                   }
    2045             :                else
    2046             :                   {
    2047           0 :                     pointer[i].set_freepointer(NULL);
    2048             :                   }
    2049             :               }
    2050             :         }
    2051           5 :      return globalIndex;
    2052             :    }
    2053             : 
    2054             : //############################################################################
    2055             : // JH (01/14/2006)
    2056             : void
    2057           5 : SgAccessModifier::resetValidFreepointers( )
    2058             :    {
    2059           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    2060           5 :      SgAccessModifier* pointer = NULL;
    2061           5 :      std::vector < unsigned char* > :: const_iterator block;
    2062           5 :      SgAccessModifier* pointerOfLinkedList = NULL;
    2063           5 :      for ( block = SgAccessModifier::pools.begin(); block != SgAccessModifier::pools.end() ; ++block )
    2064             :         {
    2065           0 :           pointer = (SgAccessModifier*)(*block);
    2066           0 :           for (unsigned i = 0; i < SgAccessModifier::pool_size; ++i )
    2067             :              {
    2068             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    2069             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    2070             :             // memory blocks!.
    2071           0 :                if ( pointer[i].get_freepointer() != NULL )
    2072             :                   {
    2073           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    2074             :                   }
    2075             :                else
    2076             :                   {
    2077           0 :                     if ( pointerOfLinkedList == NULL )
    2078             :                        {
    2079           0 :                          SgAccessModifier::next_node = &(pointer[i]);
    2080             :                        }
    2081             :                     else
    2082             :                        {
    2083             :                       // printf ("In SgAccessModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    2084           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    2085             :                        }
    2086             :                     pointerOfLinkedList = &(pointer[i]);
    2087             :                   }
    2088             :               }
    2089             :         }
    2090             : 
    2091           5 :      if ( pointerOfLinkedList != NULL )
    2092             :         {
    2093             :        // printf ("In SgAccessModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    2094           0 :           pointerOfLinkedList->set_freepointer(NULL);
    2095             :        // DQ (6/6/2010): Temporary debugging...
    2096             :        //   ROSE_ASSERT(false);
    2097             :         }
    2098             : 
    2099           5 :      return ;
    2100             :    }
    2101             : 
    2102             : //############################################################################
    2103             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    2104             :  * within the memory pool and resets the freepointers, in order to achieve a 
    2105             :  * linked list, that has no jumps and starts at the beginning! This function 
    2106             :  * does not extend the memory pool, since we do not delete any memory blocks,
    2107             :  * but delete the valid objects.  
    2108             :  */
    2109             : void
    2110           0 : SgAccessModifier::clearMemoryPool( )
    2111             :    {
    2112             :   // printf ("Inside of SgAccessModifier::clearMemoryPool() \n");
    2113             : 
    2114           0 :      SgAccessModifier* pointer = NULL, *tempPointer = NULL;
    2115           0 :      std::vector < unsigned char* > :: const_iterator block;
    2116           0 :      if ( SgAccessModifier::pools.empty() == false )
    2117             :         {
    2118           0 :           block = SgAccessModifier::pools.begin() ;
    2119           0 :           SgAccessModifier::next_node = (SgAccessModifier*) (*block);
    2120             : 
    2121           0 :           while ( block != SgAccessModifier::pools.end() )
    2122             :              {
    2123           0 :                pointer = (SgAccessModifier*) (*block);
    2124           0 :                if ( tempPointer != NULL )
    2125             :                   {
    2126           0 :                     tempPointer->set_freepointer(pointer);
    2127             :                   }
    2128           0 :                for (unsigned i = 0; i < SgAccessModifier::pool_size - 1; ++i)
    2129             :                   {
    2130           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    2131             :                   }
    2132           0 :                 pointer[SgAccessModifier::pool_size-1].set_freepointer(NULL);
    2133           0 :                 tempPointer = &(pointer[SgAccessModifier::pool_size-1]);
    2134           0 :                 ++block;
    2135             :              }
    2136             :         }
    2137           0 :    }
    2138             : 
    2139           5 : void SgAccessModifier::deleteMemoryPool() {
    2140           5 :   for (auto p: SgAccessModifier::pools) {
    2141           0 :     ROSE_FREE(p);
    2142             :   }
    2143           5 :   SgAccessModifier::next_node = nullptr;
    2144           5 :   SgAccessModifier::pools.clear();
    2145           5 : }
    2146             : 
    2147             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    2148             : //                 reading multiple binary files to for a single AST.
    2149             : /////////// new version ////////////////////////////////
    2150             : //############################################################################
    2151             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    2152             : void
    2153           2 : SgAccessModifier::extendMemoryPoolForFileIO( )
    2154             :   {
    2155           2 :     size_t blockIndex = SgAccessModifier::pools.size();
    2156           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAccessModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAccessModifier);
    2157             : 
    2158           2 :     while ( (blockIndex * SgAccessModifier::pool_size) < newPoolSize)
    2159             :       {
    2160             : #if ROSE_ALLOC_TRACE
    2161             :         if (blockIndex > 0) {
    2162             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAccessModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAccessModifier) = %" PRIuPTR " SgAccessModifier::pool_size = %d \n",
    2163             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAccessModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAccessModifier),SgAccessModifier::pool_size);
    2164             :         }
    2165             : #endif
    2166             : 
    2167           0 :         SgAccessModifier * pointer = (SgAccessModifier*) ROSE_MALLOC ( SgAccessModifier::pool_size * sizeof(SgAccessModifier) );
    2168           0 :         assert( pointer != NULL );
    2169             : #if ROSE_ALLOC_MEMSET == 1
    2170             :         memset(pointer, 0x00, SgAccessModifier::pool_size * sizeof(SgAccessModifier));
    2171             : #elif ROSE_ALLOC_MEMSET == 2
    2172             :         memset(pointer, 0xCC, SgAccessModifier::pool_size * sizeof(SgAccessModifier));
    2173             : #endif
    2174           0 :         SgAccessModifier::pools.push_back( (unsigned char*)(pointer) );
    2175           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAccessModifier::pool_size * sizeof(SgAccessModifier), V_SgAccessModifier ) );
    2176             : 
    2177           0 :         if ( SgAccessModifier::next_node != NULL ) {
    2178           0 :           if ( blockIndex > 0 ) {
    2179           0 :             SgAccessModifier * blkptr = (SgAccessModifier*)(SgAccessModifier::pools[blockIndex-1]);
    2180           0 :             blkptr[ SgAccessModifier::pool_size - 1 ].set_freepointer(pointer);
    2181             :           }
    2182             :         } else {
    2183           0 :           SgAccessModifier::next_node = pointer;
    2184             :         }
    2185             : 
    2186           0 :         for (unsigned i = 0; i < SgAccessModifier::pool_size-1; ++i)
    2187             :            {
    2188           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    2189             :            }
    2190           0 :         pointer[ SgAccessModifier::pool_size -1 ].set_freepointer(NULL);
    2191             : 
    2192           0 :         blockIndex++;
    2193             :       }
    2194           2 :   }
    2195             : 
    2196             : //############################################################################
    2197             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    2198             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    2199             :  * not compressed. However, that stuff is not yet implemented! 
    2200             :  */
    2201             : unsigned long
    2202           0 : SgAccessModifier::getNumberOfLastValidPointer()
    2203             :    {
    2204           0 :       SgAccessModifier* testPointer = (SgAccessModifier*)(SgAccessModifier::pools.back());
    2205           0 :       unsigned long localIndex = SgAccessModifier::pool_size - 1;
    2206           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    2207             :          {
    2208           0 :            localIndex--;
    2209             :          }
    2210           0 :       return (localIndex + SgAccessModifier::pool_size * (SgAccessModifier::pools.size()-1));
    2211             :    }
    2212             : 
    2213             : //############################################################################
    2214             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    2215             :  * memory pool and initializes the data member in class SgAccessModifierStroageClass
    2216             :  * from its counterpart of SgAccessModifier. The return value is just for checking, 
    2217             :  * that the whole StorageClassArray is initialized!
    2218             :  */
    2219             : unsigned long
    2220           0 : SgAccessModifier::initializeStorageClassArray( SgAccessModifierStorageClass *storageArray )
    2221             :    {
    2222           0 :      unsigned long storageCounter = 0;
    2223           0 :      std::vector < unsigned char* > :: const_iterator block = SgAccessModifier::pools.begin();
    2224           0 :      SgAccessModifier* pointer = NULL;
    2225           0 :      while ( block != SgAccessModifier::pools.end() ) {
    2226           0 :           pointer = (SgAccessModifier*) (*block);
    2227           0 :           for ( unsigned i = 0; i < SgAccessModifier::pool_size; ++i ) {
    2228           0 :                if ( pointer->get_freepointer() != NULL ) {
    2229           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    2230           0 :                  storageArray++;
    2231           0 :                  storageCounter++;
    2232             :                }
    2233           0 :                pointer++;
    2234             :              }
    2235           0 :            block++;
    2236             :         }
    2237           0 :      return storageCounter;
    2238             :    }
    2239             : 
    2240             : /* #line 2241 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    2241             : 
    2242             : 
    2243             : 
    2244             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    2245             : 
    2246             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    2247             : 
    2248             : //############################################################################
    2249             : /* JH (02/02/2006) Constructor of the IR node SgFunctionModifier that takes its 
    2250             :  * corresponding StorageClass as parameter
    2251             :  */
    2252       13303 : SgFunctionModifier :: SgFunctionModifier ( const SgFunctionModifierStorageClass& storageSource )   : SgModifier (storageSource)
    2253             :    {
    2254             : 
    2255             : 
    2256             : /* #line 2257 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    2257             : 
    2258       13303 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    2259       13303 :      p_modifierVector = storageSource.storageOf_modifierVector.rebuildDataStoredInEasyStorageClass() ;
    2260       13303 :      p_gnu_attribute_constructor_destructor_priority = storageSource.storageOf_gnu_attribute_constructor_destructor_priority ;
    2261       13303 :      p_gnu_attribute_named_weak_reference = storageSource.storageOf_gnu_attribute_named_weak_reference.rebuildDataStoredInEasyStorageClass() ;
    2262       13303 :      p_gnu_attribute_named_alias = storageSource.storageOf_gnu_attribute_named_alias.rebuildDataStoredInEasyStorageClass() ;
    2263       13303 :      p_opencl_vec_type =  (SgType *)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_opencl_vec_type) );
    2264       13303 :      p_opencl_work_group_size = storageSource.storageOf_opencl_work_group_size ;
    2265             : 
    2266             : 
    2267             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    2268             : 
    2269             : 
    2270       13303 :    }
    2271             : 
    2272             : //############################################################################
    2273             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    2274             :  * within the working AST. 
    2275             :  */
    2276           0 : SgFunctionModifier * SgFunctionModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    2277           0 :      SgFunctionModifier* returnPointer = NULL;
    2278           0 :      if ( globalIndex != 0 )
    2279             :         {
    2280             : 
    2281             : #if FILE_IO_EXTRA_CHECK
    2282           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionModifier ) ) <= globalIndex ) ;
    2283           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionModifier + 1 ) ) );
    2284             : #endif
    2285           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionModifier )  
    2286           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionModifier );
    2287           0 :           unsigned long positionInPool = localIndex % SgFunctionModifier::pool_size;
    2288           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionModifier::pool_size;
    2289             : 
    2290             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    2291             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    2292             : 
    2293           0 :           returnPointer = &( ( (SgFunctionModifier*)(SgFunctionModifier::pools[memoryBlock]) ) [positionInPool]) ;
    2294             : 
    2295           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    2296             :         }
    2297           0 :      return returnPointer ;
    2298             :    }
    2299             : 
    2300             : //############################################################################
    2301             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    2302             :   for the AST with the index astIndex
    2303             : */
    2304           0 : SgFunctionModifier * SgFunctionModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    2305           0 :      SgFunctionModifier* returnPointer = NULL;
    2306           0 :      if ( globalIndex != 0 )
    2307             :         {
    2308             : 
    2309             : #if FILE_IO_EXTRA_CHECK
    2310           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionModifier ) ) <= globalIndex ) ;
    2311           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionModifier + 1 ) ) );
    2312             : #endif
    2313           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionModifier )
    2314           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionModifier );
    2315           0 :           unsigned long positionInPool = localIndex % SgFunctionModifier::pool_size ;
    2316           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionModifier::pool_size ;
    2317             : 
    2318             : #if FILE_IO_EXTRA_CHECK
    2319             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    2320             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    2321             : #endif
    2322             : 
    2323           0 :           returnPointer = &( ( (SgFunctionModifier*)(SgFunctionModifier::pools[memoryBlock]) ) [positionInPool]) ;
    2324             : 
    2325             : #if FILE_IO_EXTRA_CHECK
    2326           0 :           assert ( returnPointer != NULL ) ;
    2327             : #endif
    2328             :         }
    2329           0 :      return returnPointer ;
    2330             :    }
    2331             : 
    2332             : //############################################################################
    2333             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    2334             :  * pool size! We set for every valid object in the memory pool the freepointer
    2335             :  * to the global index and increase the global index afterwards. For all the 
    2336             :  * invalid objects (means address ranges within the memory pool that were not
    2337             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    2338             :  * distinguish valid from invalid objects! 
    2339             :  */
    2340             : unsigned long
    2341           5 : SgFunctionModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    2342             :    {
    2343           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    2344           5 :      SgFunctionModifier* pointer = NULL;
    2345           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    2346           5 :      std::vector < unsigned char* > :: const_iterator block;
    2347           5 :      for ( block = SgFunctionModifier::pools.begin(); block != SgFunctionModifier::pools.end() ; ++block )
    2348             :         {
    2349           0 :           pointer = (SgFunctionModifier*)(*block);
    2350           0 :           for (unsigned i = 0; i < SgFunctionModifier::pool_size; ++i )
    2351             :              {
    2352             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    2353             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    2354             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    2355             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    2356             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    2357             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    2358             :             // properly; so this will have to be checked next.
    2359             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    2360             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    2361           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    2362             :                   {
    2363           0 :                     pointer[i].set_freepointer((SgFunctionModifier*)(globalIndex));
    2364           0 :                     globalIndex++;
    2365             :                   }
    2366             :                else
    2367             :                   {
    2368           0 :                     pointer[i].set_freepointer(NULL);
    2369             :                   }
    2370             :               }
    2371             :         }
    2372           5 :      return globalIndex;
    2373             :    }
    2374             : 
    2375             : //############################################################################
    2376             : // JH (01/14/2006)
    2377             : void
    2378           5 : SgFunctionModifier::resetValidFreepointers( )
    2379             :    {
    2380           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    2381           5 :      SgFunctionModifier* pointer = NULL;
    2382           5 :      std::vector < unsigned char* > :: const_iterator block;
    2383           5 :      SgFunctionModifier* pointerOfLinkedList = NULL;
    2384           5 :      for ( block = SgFunctionModifier::pools.begin(); block != SgFunctionModifier::pools.end() ; ++block )
    2385             :         {
    2386           0 :           pointer = (SgFunctionModifier*)(*block);
    2387           0 :           for (unsigned i = 0; i < SgFunctionModifier::pool_size; ++i )
    2388             :              {
    2389             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    2390             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    2391             :             // memory blocks!.
    2392           0 :                if ( pointer[i].get_freepointer() != NULL )
    2393             :                   {
    2394           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    2395             :                   }
    2396             :                else
    2397             :                   {
    2398           0 :                     if ( pointerOfLinkedList == NULL )
    2399             :                        {
    2400           0 :                          SgFunctionModifier::next_node = &(pointer[i]);
    2401             :                        }
    2402             :                     else
    2403             :                        {
    2404             :                       // printf ("In SgFunctionModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    2405           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    2406             :                        }
    2407             :                     pointerOfLinkedList = &(pointer[i]);
    2408             :                   }
    2409             :               }
    2410             :         }
    2411             : 
    2412           5 :      if ( pointerOfLinkedList != NULL )
    2413             :         {
    2414             :        // printf ("In SgFunctionModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    2415           0 :           pointerOfLinkedList->set_freepointer(NULL);
    2416             :        // DQ (6/6/2010): Temporary debugging...
    2417             :        //   ROSE_ASSERT(false);
    2418             :         }
    2419             : 
    2420           5 :      return ;
    2421             :    }
    2422             : 
    2423             : //############################################################################
    2424             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    2425             :  * within the memory pool and resets the freepointers, in order to achieve a 
    2426             :  * linked list, that has no jumps and starts at the beginning! This function 
    2427             :  * does not extend the memory pool, since we do not delete any memory blocks,
    2428             :  * but delete the valid objects.  
    2429             :  */
    2430             : void
    2431           0 : SgFunctionModifier::clearMemoryPool( )
    2432             :    {
    2433             :   // printf ("Inside of SgFunctionModifier::clearMemoryPool() \n");
    2434             : 
    2435           0 :      SgFunctionModifier* pointer = NULL, *tempPointer = NULL;
    2436           0 :      std::vector < unsigned char* > :: const_iterator block;
    2437           0 :      if ( SgFunctionModifier::pools.empty() == false )
    2438             :         {
    2439           0 :           block = SgFunctionModifier::pools.begin() ;
    2440           0 :           SgFunctionModifier::next_node = (SgFunctionModifier*) (*block);
    2441             : 
    2442           0 :           while ( block != SgFunctionModifier::pools.end() )
    2443             :              {
    2444           0 :                pointer = (SgFunctionModifier*) (*block);
    2445           0 :                if ( tempPointer != NULL )
    2446             :                   {
    2447           0 :                     tempPointer->set_freepointer(pointer);
    2448             :                   }
    2449           0 :                for (unsigned i = 0; i < SgFunctionModifier::pool_size - 1; ++i)
    2450             :                   {
    2451           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    2452             :                   }
    2453           0 :                 pointer[SgFunctionModifier::pool_size-1].set_freepointer(NULL);
    2454           0 :                 tempPointer = &(pointer[SgFunctionModifier::pool_size-1]);
    2455           0 :                 ++block;
    2456             :              }
    2457             :         }
    2458           0 :    }
    2459             : 
    2460           5 : void SgFunctionModifier::deleteMemoryPool() {
    2461           5 :   for (auto p: SgFunctionModifier::pools) {
    2462           0 :     ROSE_FREE(p);
    2463             :   }
    2464           5 :   SgFunctionModifier::next_node = nullptr;
    2465           5 :   SgFunctionModifier::pools.clear();
    2466           5 : }
    2467             : 
    2468             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    2469             : //                 reading multiple binary files to for a single AST.
    2470             : /////////// new version ////////////////////////////////
    2471             : //############################################################################
    2472             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    2473             : void
    2474           2 : SgFunctionModifier::extendMemoryPoolForFileIO( )
    2475             :   {
    2476           2 :     size_t blockIndex = SgFunctionModifier::pools.size();
    2477           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionModifier);
    2478             : 
    2479           2 :     while ( (blockIndex * SgFunctionModifier::pool_size) < newPoolSize)
    2480             :       {
    2481             : #if ROSE_ALLOC_TRACE
    2482             :         if (blockIndex > 0) {
    2483             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionModifier) = %" PRIuPTR " SgFunctionModifier::pool_size = %d \n",
    2484             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionModifier),SgFunctionModifier::pool_size);
    2485             :         }
    2486             : #endif
    2487             : 
    2488           0 :         SgFunctionModifier * pointer = (SgFunctionModifier*) ROSE_MALLOC ( SgFunctionModifier::pool_size * sizeof(SgFunctionModifier) );
    2489           0 :         assert( pointer != NULL );
    2490             : #if ROSE_ALLOC_MEMSET == 1
    2491             :         memset(pointer, 0x00, SgFunctionModifier::pool_size * sizeof(SgFunctionModifier));
    2492             : #elif ROSE_ALLOC_MEMSET == 2
    2493             :         memset(pointer, 0xCC, SgFunctionModifier::pool_size * sizeof(SgFunctionModifier));
    2494             : #endif
    2495           0 :         SgFunctionModifier::pools.push_back( (unsigned char*)(pointer) );
    2496           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionModifier::pool_size * sizeof(SgFunctionModifier), V_SgFunctionModifier ) );
    2497             : 
    2498           0 :         if ( SgFunctionModifier::next_node != NULL ) {
    2499           0 :           if ( blockIndex > 0 ) {
    2500           0 :             SgFunctionModifier * blkptr = (SgFunctionModifier*)(SgFunctionModifier::pools[blockIndex-1]);
    2501           0 :             blkptr[ SgFunctionModifier::pool_size - 1 ].set_freepointer(pointer);
    2502             :           }
    2503             :         } else {
    2504           0 :           SgFunctionModifier::next_node = pointer;
    2505             :         }
    2506             : 
    2507           0 :         for (unsigned i = 0; i < SgFunctionModifier::pool_size-1; ++i)
    2508             :            {
    2509           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    2510             :            }
    2511           0 :         pointer[ SgFunctionModifier::pool_size -1 ].set_freepointer(NULL);
    2512             : 
    2513           0 :         blockIndex++;
    2514             :       }
    2515           2 :   }
    2516             : 
    2517             : //############################################################################
    2518             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    2519             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    2520             :  * not compressed. However, that stuff is not yet implemented! 
    2521             :  */
    2522             : unsigned long
    2523           0 : SgFunctionModifier::getNumberOfLastValidPointer()
    2524             :    {
    2525           0 :       SgFunctionModifier* testPointer = (SgFunctionModifier*)(SgFunctionModifier::pools.back());
    2526           0 :       unsigned long localIndex = SgFunctionModifier::pool_size - 1;
    2527           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    2528             :          {
    2529           0 :            localIndex--;
    2530             :          }
    2531           0 :       return (localIndex + SgFunctionModifier::pool_size * (SgFunctionModifier::pools.size()-1));
    2532             :    }
    2533             : 
    2534             : //############################################################################
    2535             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    2536             :  * memory pool and initializes the data member in class SgFunctionModifierStroageClass
    2537             :  * from its counterpart of SgFunctionModifier. The return value is just for checking, 
    2538             :  * that the whole StorageClassArray is initialized!
    2539             :  */
    2540             : unsigned long
    2541           0 : SgFunctionModifier::initializeStorageClassArray( SgFunctionModifierStorageClass *storageArray )
    2542             :    {
    2543           0 :      unsigned long storageCounter = 0;
    2544           0 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionModifier::pools.begin();
    2545           0 :      SgFunctionModifier* pointer = NULL;
    2546           0 :      while ( block != SgFunctionModifier::pools.end() ) {
    2547           0 :           pointer = (SgFunctionModifier*) (*block);
    2548           0 :           for ( unsigned i = 0; i < SgFunctionModifier::pool_size; ++i ) {
    2549           0 :                if ( pointer->get_freepointer() != NULL ) {
    2550           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    2551           0 :                  storageArray++;
    2552           0 :                  storageCounter++;
    2553             :                }
    2554           0 :                pointer++;
    2555             :              }
    2556           0 :            block++;
    2557             :         }
    2558           0 :      return storageCounter;
    2559             :    }
    2560             : 
    2561             : /* #line 2562 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    2562             : 
    2563             : 
    2564             : 
    2565             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    2566             : 
    2567             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    2568             : 
    2569             : //############################################################################
    2570             : /* JH (02/02/2006) Constructor of the IR node SgUPC_AccessModifier that takes its 
    2571             :  * corresponding StorageClass as parameter
    2572             :  */
    2573       54713 : SgUPC_AccessModifier :: SgUPC_AccessModifier ( const SgUPC_AccessModifierStorageClass& storageSource )   : SgModifier (storageSource)
    2574             :    {
    2575             : 
    2576             : 
    2577             : /* #line 2578 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    2578             : 
    2579       54713 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    2580       54713 :      p_modifier = storageSource.storageOf_modifier ;
    2581       54713 :      p_isShared = storageSource.storageOf_isShared ;
    2582       54713 :      p_layout = storageSource.storageOf_layout ;
    2583             : 
    2584             : 
    2585             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    2586             : 
    2587             : 
    2588       54713 :    }
    2589             : 
    2590             : //############################################################################
    2591             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    2592             :  * within the working AST. 
    2593             :  */
    2594           0 : SgUPC_AccessModifier * SgUPC_AccessModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    2595           0 :      SgUPC_AccessModifier* returnPointer = NULL;
    2596           0 :      if ( globalIndex != 0 )
    2597             :         {
    2598             : 
    2599             : #if FILE_IO_EXTRA_CHECK
    2600           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUPC_AccessModifier ) ) <= globalIndex ) ;
    2601           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUPC_AccessModifier + 1 ) ) );
    2602             : #endif
    2603           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUPC_AccessModifier )  
    2604           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUPC_AccessModifier );
    2605           0 :           unsigned long positionInPool = localIndex % SgUPC_AccessModifier::pool_size;
    2606           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUPC_AccessModifier::pool_size;
    2607             : 
    2608             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    2609             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    2610             : 
    2611           0 :           returnPointer = &( ( (SgUPC_AccessModifier*)(SgUPC_AccessModifier::pools[memoryBlock]) ) [positionInPool]) ;
    2612             : 
    2613           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    2614             :         }
    2615           0 :      return returnPointer ;
    2616             :    }
    2617             : 
    2618             : //############################################################################
    2619             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    2620             :   for the AST with the index astIndex
    2621             : */
    2622           0 : SgUPC_AccessModifier * SgUPC_AccessModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    2623           0 :      SgUPC_AccessModifier* returnPointer = NULL;
    2624           0 :      if ( globalIndex != 0 )
    2625             :         {
    2626             : 
    2627             : #if FILE_IO_EXTRA_CHECK
    2628           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUPC_AccessModifier ) ) <= globalIndex ) ;
    2629           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUPC_AccessModifier + 1 ) ) );
    2630             : #endif
    2631           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUPC_AccessModifier )
    2632           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUPC_AccessModifier );
    2633           0 :           unsigned long positionInPool = localIndex % SgUPC_AccessModifier::pool_size ;
    2634           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUPC_AccessModifier::pool_size ;
    2635             : 
    2636             : #if FILE_IO_EXTRA_CHECK
    2637             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    2638             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    2639             : #endif
    2640             : 
    2641           0 :           returnPointer = &( ( (SgUPC_AccessModifier*)(SgUPC_AccessModifier::pools[memoryBlock]) ) [positionInPool]) ;
    2642             : 
    2643             : #if FILE_IO_EXTRA_CHECK
    2644           0 :           assert ( returnPointer != NULL ) ;
    2645             : #endif
    2646             :         }
    2647           0 :      return returnPointer ;
    2648             :    }
    2649             : 
    2650             : //############################################################################
    2651             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    2652             :  * pool size! We set for every valid object in the memory pool the freepointer
    2653             :  * to the global index and increase the global index afterwards. For all the 
    2654             :  * invalid objects (means address ranges within the memory pool that were not
    2655             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    2656             :  * distinguish valid from invalid objects! 
    2657             :  */
    2658             : unsigned long
    2659           5 : SgUPC_AccessModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    2660             :    {
    2661           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    2662           5 :      SgUPC_AccessModifier* pointer = NULL;
    2663           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    2664           5 :      std::vector < unsigned char* > :: const_iterator block;
    2665           5 :      for ( block = SgUPC_AccessModifier::pools.begin(); block != SgUPC_AccessModifier::pools.end() ; ++block )
    2666             :         {
    2667           0 :           pointer = (SgUPC_AccessModifier*)(*block);
    2668           0 :           for (unsigned i = 0; i < SgUPC_AccessModifier::pool_size; ++i )
    2669             :              {
    2670             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    2671             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    2672             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    2673             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    2674             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    2675             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    2676             :             // properly; so this will have to be checked next.
    2677             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    2678             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    2679           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    2680             :                   {
    2681           0 :                     pointer[i].set_freepointer((SgUPC_AccessModifier*)(globalIndex));
    2682           0 :                     globalIndex++;
    2683             :                   }
    2684             :                else
    2685             :                   {
    2686           0 :                     pointer[i].set_freepointer(NULL);
    2687             :                   }
    2688             :               }
    2689             :         }
    2690           5 :      return globalIndex;
    2691             :    }
    2692             : 
    2693             : //############################################################################
    2694             : // JH (01/14/2006)
    2695             : void
    2696           5 : SgUPC_AccessModifier::resetValidFreepointers( )
    2697             :    {
    2698           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    2699           5 :      SgUPC_AccessModifier* pointer = NULL;
    2700           5 :      std::vector < unsigned char* > :: const_iterator block;
    2701           5 :      SgUPC_AccessModifier* pointerOfLinkedList = NULL;
    2702           5 :      for ( block = SgUPC_AccessModifier::pools.begin(); block != SgUPC_AccessModifier::pools.end() ; ++block )
    2703             :         {
    2704           0 :           pointer = (SgUPC_AccessModifier*)(*block);
    2705           0 :           for (unsigned i = 0; i < SgUPC_AccessModifier::pool_size; ++i )
    2706             :              {
    2707             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    2708             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    2709             :             // memory blocks!.
    2710           0 :                if ( pointer[i].get_freepointer() != NULL )
    2711             :                   {
    2712           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    2713             :                   }
    2714             :                else
    2715             :                   {
    2716           0 :                     if ( pointerOfLinkedList == NULL )
    2717             :                        {
    2718           0 :                          SgUPC_AccessModifier::next_node = &(pointer[i]);
    2719             :                        }
    2720             :                     else
    2721             :                        {
    2722             :                       // printf ("In SgUPC_AccessModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    2723           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    2724             :                        }
    2725             :                     pointerOfLinkedList = &(pointer[i]);
    2726             :                   }
    2727             :               }
    2728             :         }
    2729             : 
    2730           5 :      if ( pointerOfLinkedList != NULL )
    2731             :         {
    2732             :        // printf ("In SgUPC_AccessModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    2733           0 :           pointerOfLinkedList->set_freepointer(NULL);
    2734             :        // DQ (6/6/2010): Temporary debugging...
    2735             :        //   ROSE_ASSERT(false);
    2736             :         }
    2737             : 
    2738           5 :      return ;
    2739             :    }
    2740             : 
    2741             : //############################################################################
    2742             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    2743             :  * within the memory pool and resets the freepointers, in order to achieve a 
    2744             :  * linked list, that has no jumps and starts at the beginning! This function 
    2745             :  * does not extend the memory pool, since we do not delete any memory blocks,
    2746             :  * but delete the valid objects.  
    2747             :  */
    2748             : void
    2749           0 : SgUPC_AccessModifier::clearMemoryPool( )
    2750             :    {
    2751             :   // printf ("Inside of SgUPC_AccessModifier::clearMemoryPool() \n");
    2752             : 
    2753           0 :      SgUPC_AccessModifier* pointer = NULL, *tempPointer = NULL;
    2754           0 :      std::vector < unsigned char* > :: const_iterator block;
    2755           0 :      if ( SgUPC_AccessModifier::pools.empty() == false )
    2756             :         {
    2757           0 :           block = SgUPC_AccessModifier::pools.begin() ;
    2758           0 :           SgUPC_AccessModifier::next_node = (SgUPC_AccessModifier*) (*block);
    2759             : 
    2760           0 :           while ( block != SgUPC_AccessModifier::pools.end() )
    2761             :              {
    2762           0 :                pointer = (SgUPC_AccessModifier*) (*block);
    2763           0 :                if ( tempPointer != NULL )
    2764             :                   {
    2765           0 :                     tempPointer->set_freepointer(pointer);
    2766             :                   }
    2767           0 :                for (unsigned i = 0; i < SgUPC_AccessModifier::pool_size - 1; ++i)
    2768             :                   {
    2769           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    2770             :                   }
    2771           0 :                 pointer[SgUPC_AccessModifier::pool_size-1].set_freepointer(NULL);
    2772           0 :                 tempPointer = &(pointer[SgUPC_AccessModifier::pool_size-1]);
    2773           0 :                 ++block;
    2774             :              }
    2775             :         }
    2776           0 :    }
    2777             : 
    2778           5 : void SgUPC_AccessModifier::deleteMemoryPool() {
    2779           5 :   for (auto p: SgUPC_AccessModifier::pools) {
    2780           0 :     ROSE_FREE(p);
    2781             :   }
    2782           5 :   SgUPC_AccessModifier::next_node = nullptr;
    2783           5 :   SgUPC_AccessModifier::pools.clear();
    2784           5 : }
    2785             : 
    2786             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    2787             : //                 reading multiple binary files to for a single AST.
    2788             : /////////// new version ////////////////////////////////
    2789             : //############################################################################
    2790             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    2791             : void
    2792           2 : SgUPC_AccessModifier::extendMemoryPoolForFileIO( )
    2793             :   {
    2794           2 :     size_t blockIndex = SgUPC_AccessModifier::pools.size();
    2795           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUPC_AccessModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUPC_AccessModifier);
    2796             : 
    2797           2 :     while ( (blockIndex * SgUPC_AccessModifier::pool_size) < newPoolSize)
    2798             :       {
    2799             : #if ROSE_ALLOC_TRACE
    2800             :         if (blockIndex > 0) {
    2801             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUPC_AccessModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUPC_AccessModifier) = %" PRIuPTR " SgUPC_AccessModifier::pool_size = %d \n",
    2802             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUPC_AccessModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUPC_AccessModifier),SgUPC_AccessModifier::pool_size);
    2803             :         }
    2804             : #endif
    2805             : 
    2806           0 :         SgUPC_AccessModifier * pointer = (SgUPC_AccessModifier*) ROSE_MALLOC ( SgUPC_AccessModifier::pool_size * sizeof(SgUPC_AccessModifier) );
    2807           0 :         assert( pointer != NULL );
    2808             : #if ROSE_ALLOC_MEMSET == 1
    2809             :         memset(pointer, 0x00, SgUPC_AccessModifier::pool_size * sizeof(SgUPC_AccessModifier));
    2810             : #elif ROSE_ALLOC_MEMSET == 2
    2811             :         memset(pointer, 0xCC, SgUPC_AccessModifier::pool_size * sizeof(SgUPC_AccessModifier));
    2812             : #endif
    2813           0 :         SgUPC_AccessModifier::pools.push_back( (unsigned char*)(pointer) );
    2814           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUPC_AccessModifier::pool_size * sizeof(SgUPC_AccessModifier), V_SgUPC_AccessModifier ) );
    2815             : 
    2816           0 :         if ( SgUPC_AccessModifier::next_node != NULL ) {
    2817           0 :           if ( blockIndex > 0 ) {
    2818           0 :             SgUPC_AccessModifier * blkptr = (SgUPC_AccessModifier*)(SgUPC_AccessModifier::pools[blockIndex-1]);
    2819           0 :             blkptr[ SgUPC_AccessModifier::pool_size - 1 ].set_freepointer(pointer);
    2820             :           }
    2821             :         } else {
    2822           0 :           SgUPC_AccessModifier::next_node = pointer;
    2823             :         }
    2824             : 
    2825           0 :         for (unsigned i = 0; i < SgUPC_AccessModifier::pool_size-1; ++i)
    2826             :            {
    2827           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    2828             :            }
    2829           0 :         pointer[ SgUPC_AccessModifier::pool_size -1 ].set_freepointer(NULL);
    2830             : 
    2831           0 :         blockIndex++;
    2832             :       }
    2833           2 :   }
    2834             : 
    2835             : //############################################################################
    2836             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    2837             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    2838             :  * not compressed. However, that stuff is not yet implemented! 
    2839             :  */
    2840             : unsigned long
    2841           0 : SgUPC_AccessModifier::getNumberOfLastValidPointer()
    2842             :    {
    2843           0 :       SgUPC_AccessModifier* testPointer = (SgUPC_AccessModifier*)(SgUPC_AccessModifier::pools.back());
    2844           0 :       unsigned long localIndex = SgUPC_AccessModifier::pool_size - 1;
    2845           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    2846             :          {
    2847           0 :            localIndex--;
    2848             :          }
    2849           0 :       return (localIndex + SgUPC_AccessModifier::pool_size * (SgUPC_AccessModifier::pools.size()-1));
    2850             :    }
    2851             : 
    2852             : //############################################################################
    2853             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    2854             :  * memory pool and initializes the data member in class SgUPC_AccessModifierStroageClass
    2855             :  * from its counterpart of SgUPC_AccessModifier. The return value is just for checking, 
    2856             :  * that the whole StorageClassArray is initialized!
    2857             :  */
    2858             : unsigned long
    2859           0 : SgUPC_AccessModifier::initializeStorageClassArray( SgUPC_AccessModifierStorageClass *storageArray )
    2860             :    {
    2861           0 :      unsigned long storageCounter = 0;
    2862           0 :      std::vector < unsigned char* > :: const_iterator block = SgUPC_AccessModifier::pools.begin();
    2863           0 :      SgUPC_AccessModifier* pointer = NULL;
    2864           0 :      while ( block != SgUPC_AccessModifier::pools.end() ) {
    2865           0 :           pointer = (SgUPC_AccessModifier*) (*block);
    2866           0 :           for ( unsigned i = 0; i < SgUPC_AccessModifier::pool_size; ++i ) {
    2867           0 :                if ( pointer->get_freepointer() != NULL ) {
    2868           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    2869           0 :                  storageArray++;
    2870           0 :                  storageCounter++;
    2871             :                }
    2872           0 :                pointer++;
    2873             :              }
    2874           0 :            block++;
    2875             :         }
    2876           0 :      return storageCounter;
    2877             :    }
    2878             : 
    2879             : /* #line 2880 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    2880             : 
    2881             : 
    2882             : 
    2883             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    2884             : 
    2885             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    2886             : 
    2887             : //############################################################################
    2888             : /* JH (02/02/2006) Constructor of the IR node SgSpecialFunctionModifier that takes its 
    2889             :  * corresponding StorageClass as parameter
    2890             :  */
    2891       13303 : SgSpecialFunctionModifier :: SgSpecialFunctionModifier ( const SgSpecialFunctionModifierStorageClass& storageSource )   : SgModifier (storageSource)
    2892             :    {
    2893             : 
    2894             : 
    2895             : /* #line 2896 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    2896             : 
    2897       13303 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    2898       13303 :      p_modifierVector = storageSource.storageOf_modifierVector.rebuildDataStoredInEasyStorageClass() ;
    2899             : 
    2900             : 
    2901             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    2902             : 
    2903             : 
    2904       13303 :    }
    2905             : 
    2906             : //############################################################################
    2907             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    2908             :  * within the working AST. 
    2909             :  */
    2910           0 : SgSpecialFunctionModifier * SgSpecialFunctionModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    2911           0 :      SgSpecialFunctionModifier* returnPointer = NULL;
    2912           0 :      if ( globalIndex != 0 )
    2913             :         {
    2914             : 
    2915             : #if FILE_IO_EXTRA_CHECK
    2916           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSpecialFunctionModifier ) ) <= globalIndex ) ;
    2917           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSpecialFunctionModifier + 1 ) ) );
    2918             : #endif
    2919           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSpecialFunctionModifier )  
    2920           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSpecialFunctionModifier );
    2921           0 :           unsigned long positionInPool = localIndex % SgSpecialFunctionModifier::pool_size;
    2922           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSpecialFunctionModifier::pool_size;
    2923             : 
    2924             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    2925             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    2926             : 
    2927           0 :           returnPointer = &( ( (SgSpecialFunctionModifier*)(SgSpecialFunctionModifier::pools[memoryBlock]) ) [positionInPool]) ;
    2928             : 
    2929           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    2930             :         }
    2931           0 :      return returnPointer ;
    2932             :    }
    2933             : 
    2934             : //############################################################################
    2935             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    2936             :   for the AST with the index astIndex
    2937             : */
    2938           0 : SgSpecialFunctionModifier * SgSpecialFunctionModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    2939           0 :      SgSpecialFunctionModifier* returnPointer = NULL;
    2940           0 :      if ( globalIndex != 0 )
    2941             :         {
    2942             : 
    2943             : #if FILE_IO_EXTRA_CHECK
    2944           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSpecialFunctionModifier ) ) <= globalIndex ) ;
    2945           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSpecialFunctionModifier + 1 ) ) );
    2946             : #endif
    2947           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSpecialFunctionModifier )
    2948           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSpecialFunctionModifier );
    2949           0 :           unsigned long positionInPool = localIndex % SgSpecialFunctionModifier::pool_size ;
    2950           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSpecialFunctionModifier::pool_size ;
    2951             : 
    2952             : #if FILE_IO_EXTRA_CHECK
    2953             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    2954             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    2955             : #endif
    2956             : 
    2957           0 :           returnPointer = &( ( (SgSpecialFunctionModifier*)(SgSpecialFunctionModifier::pools[memoryBlock]) ) [positionInPool]) ;
    2958             : 
    2959             : #if FILE_IO_EXTRA_CHECK
    2960           0 :           assert ( returnPointer != NULL ) ;
    2961             : #endif
    2962             :         }
    2963           0 :      return returnPointer ;
    2964             :    }
    2965             : 
    2966             : //############################################################################
    2967             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    2968             :  * pool size! We set for every valid object in the memory pool the freepointer
    2969             :  * to the global index and increase the global index afterwards. For all the 
    2970             :  * invalid objects (means address ranges within the memory pool that were not
    2971             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    2972             :  * distinguish valid from invalid objects! 
    2973             :  */
    2974             : unsigned long
    2975           5 : SgSpecialFunctionModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    2976             :    {
    2977           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    2978           5 :      SgSpecialFunctionModifier* pointer = NULL;
    2979           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    2980           5 :      std::vector < unsigned char* > :: const_iterator block;
    2981           5 :      for ( block = SgSpecialFunctionModifier::pools.begin(); block != SgSpecialFunctionModifier::pools.end() ; ++block )
    2982             :         {
    2983           0 :           pointer = (SgSpecialFunctionModifier*)(*block);
    2984           0 :           for (unsigned i = 0; i < SgSpecialFunctionModifier::pool_size; ++i )
    2985             :              {
    2986             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    2987             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    2988             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    2989             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    2990             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    2991             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    2992             :             // properly; so this will have to be checked next.
    2993             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    2994             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    2995           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    2996             :                   {
    2997           0 :                     pointer[i].set_freepointer((SgSpecialFunctionModifier*)(globalIndex));
    2998           0 :                     globalIndex++;
    2999             :                   }
    3000             :                else
    3001             :                   {
    3002           0 :                     pointer[i].set_freepointer(NULL);
    3003             :                   }
    3004             :               }
    3005             :         }
    3006           5 :      return globalIndex;
    3007             :    }
    3008             : 
    3009             : //############################################################################
    3010             : // JH (01/14/2006)
    3011             : void
    3012           5 : SgSpecialFunctionModifier::resetValidFreepointers( )
    3013             :    {
    3014           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    3015           5 :      SgSpecialFunctionModifier* pointer = NULL;
    3016           5 :      std::vector < unsigned char* > :: const_iterator block;
    3017           5 :      SgSpecialFunctionModifier* pointerOfLinkedList = NULL;
    3018           5 :      for ( block = SgSpecialFunctionModifier::pools.begin(); block != SgSpecialFunctionModifier::pools.end() ; ++block )
    3019             :         {
    3020           0 :           pointer = (SgSpecialFunctionModifier*)(*block);
    3021           0 :           for (unsigned i = 0; i < SgSpecialFunctionModifier::pool_size; ++i )
    3022             :              {
    3023             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    3024             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    3025             :             // memory blocks!.
    3026           0 :                if ( pointer[i].get_freepointer() != NULL )
    3027             :                   {
    3028           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    3029             :                   }
    3030             :                else
    3031             :                   {
    3032           0 :                     if ( pointerOfLinkedList == NULL )
    3033             :                        {
    3034           0 :                          SgSpecialFunctionModifier::next_node = &(pointer[i]);
    3035             :                        }
    3036             :                     else
    3037             :                        {
    3038             :                       // printf ("In SgSpecialFunctionModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    3039           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    3040             :                        }
    3041             :                     pointerOfLinkedList = &(pointer[i]);
    3042             :                   }
    3043             :               }
    3044             :         }
    3045             : 
    3046           5 :      if ( pointerOfLinkedList != NULL )
    3047             :         {
    3048             :        // printf ("In SgSpecialFunctionModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    3049           0 :           pointerOfLinkedList->set_freepointer(NULL);
    3050             :        // DQ (6/6/2010): Temporary debugging...
    3051             :        //   ROSE_ASSERT(false);
    3052             :         }
    3053             : 
    3054           5 :      return ;
    3055             :    }
    3056             : 
    3057             : //############################################################################
    3058             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    3059             :  * within the memory pool and resets the freepointers, in order to achieve a 
    3060             :  * linked list, that has no jumps and starts at the beginning! This function 
    3061             :  * does not extend the memory pool, since we do not delete any memory blocks,
    3062             :  * but delete the valid objects.  
    3063             :  */
    3064             : void
    3065           0 : SgSpecialFunctionModifier::clearMemoryPool( )
    3066             :    {
    3067             :   // printf ("Inside of SgSpecialFunctionModifier::clearMemoryPool() \n");
    3068             : 
    3069           0 :      SgSpecialFunctionModifier* pointer = NULL, *tempPointer = NULL;
    3070           0 :      std::vector < unsigned char* > :: const_iterator block;
    3071           0 :      if ( SgSpecialFunctionModifier::pools.empty() == false )
    3072             :         {
    3073           0 :           block = SgSpecialFunctionModifier::pools.begin() ;
    3074           0 :           SgSpecialFunctionModifier::next_node = (SgSpecialFunctionModifier*) (*block);
    3075             : 
    3076           0 :           while ( block != SgSpecialFunctionModifier::pools.end() )
    3077             :              {
    3078           0 :                pointer = (SgSpecialFunctionModifier*) (*block);
    3079           0 :                if ( tempPointer != NULL )
    3080             :                   {
    3081           0 :                     tempPointer->set_freepointer(pointer);
    3082             :                   }
    3083           0 :                for (unsigned i = 0; i < SgSpecialFunctionModifier::pool_size - 1; ++i)
    3084             :                   {
    3085           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    3086             :                   }
    3087           0 :                 pointer[SgSpecialFunctionModifier::pool_size-1].set_freepointer(NULL);
    3088           0 :                 tempPointer = &(pointer[SgSpecialFunctionModifier::pool_size-1]);
    3089           0 :                 ++block;
    3090             :              }
    3091             :         }
    3092           0 :    }
    3093             : 
    3094           5 : void SgSpecialFunctionModifier::deleteMemoryPool() {
    3095           5 :   for (auto p: SgSpecialFunctionModifier::pools) {
    3096           0 :     ROSE_FREE(p);
    3097             :   }
    3098           5 :   SgSpecialFunctionModifier::next_node = nullptr;
    3099           5 :   SgSpecialFunctionModifier::pools.clear();
    3100           5 : }
    3101             : 
    3102             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    3103             : //                 reading multiple binary files to for a single AST.
    3104             : /////////// new version ////////////////////////////////
    3105             : //############################################################################
    3106             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    3107             : void
    3108           2 : SgSpecialFunctionModifier::extendMemoryPoolForFileIO( )
    3109             :   {
    3110           2 :     size_t blockIndex = SgSpecialFunctionModifier::pools.size();
    3111           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSpecialFunctionModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpecialFunctionModifier);
    3112             : 
    3113           2 :     while ( (blockIndex * SgSpecialFunctionModifier::pool_size) < newPoolSize)
    3114             :       {
    3115             : #if ROSE_ALLOC_TRACE
    3116             :         if (blockIndex > 0) {
    3117             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSpecialFunctionModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpecialFunctionModifier) = %" PRIuPTR " SgSpecialFunctionModifier::pool_size = %d \n",
    3118             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSpecialFunctionModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpecialFunctionModifier),SgSpecialFunctionModifier::pool_size);
    3119             :         }
    3120             : #endif
    3121             : 
    3122           0 :         SgSpecialFunctionModifier * pointer = (SgSpecialFunctionModifier*) ROSE_MALLOC ( SgSpecialFunctionModifier::pool_size * sizeof(SgSpecialFunctionModifier) );
    3123           0 :         assert( pointer != NULL );
    3124             : #if ROSE_ALLOC_MEMSET == 1
    3125             :         memset(pointer, 0x00, SgSpecialFunctionModifier::pool_size * sizeof(SgSpecialFunctionModifier));
    3126             : #elif ROSE_ALLOC_MEMSET == 2
    3127             :         memset(pointer, 0xCC, SgSpecialFunctionModifier::pool_size * sizeof(SgSpecialFunctionModifier));
    3128             : #endif
    3129           0 :         SgSpecialFunctionModifier::pools.push_back( (unsigned char*)(pointer) );
    3130           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSpecialFunctionModifier::pool_size * sizeof(SgSpecialFunctionModifier), V_SgSpecialFunctionModifier ) );
    3131             : 
    3132           0 :         if ( SgSpecialFunctionModifier::next_node != NULL ) {
    3133           0 :           if ( blockIndex > 0 ) {
    3134           0 :             SgSpecialFunctionModifier * blkptr = (SgSpecialFunctionModifier*)(SgSpecialFunctionModifier::pools[blockIndex-1]);
    3135           0 :             blkptr[ SgSpecialFunctionModifier::pool_size - 1 ].set_freepointer(pointer);
    3136             :           }
    3137             :         } else {
    3138           0 :           SgSpecialFunctionModifier::next_node = pointer;
    3139             :         }
    3140             : 
    3141           0 :         for (unsigned i = 0; i < SgSpecialFunctionModifier::pool_size-1; ++i)
    3142             :            {
    3143           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    3144             :            }
    3145           0 :         pointer[ SgSpecialFunctionModifier::pool_size -1 ].set_freepointer(NULL);
    3146             : 
    3147           0 :         blockIndex++;
    3148             :       }
    3149           2 :   }
    3150             : 
    3151             : //############################################################################
    3152             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    3153             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    3154             :  * not compressed. However, that stuff is not yet implemented! 
    3155             :  */
    3156             : unsigned long
    3157           0 : SgSpecialFunctionModifier::getNumberOfLastValidPointer()
    3158             :    {
    3159           0 :       SgSpecialFunctionModifier* testPointer = (SgSpecialFunctionModifier*)(SgSpecialFunctionModifier::pools.back());
    3160           0 :       unsigned long localIndex = SgSpecialFunctionModifier::pool_size - 1;
    3161           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    3162             :          {
    3163           0 :            localIndex--;
    3164             :          }
    3165           0 :       return (localIndex + SgSpecialFunctionModifier::pool_size * (SgSpecialFunctionModifier::pools.size()-1));
    3166             :    }
    3167             : 
    3168             : //############################################################################
    3169             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    3170             :  * memory pool and initializes the data member in class SgSpecialFunctionModifierStroageClass
    3171             :  * from its counterpart of SgSpecialFunctionModifier. The return value is just for checking, 
    3172             :  * that the whole StorageClassArray is initialized!
    3173             :  */
    3174             : unsigned long
    3175           0 : SgSpecialFunctionModifier::initializeStorageClassArray( SgSpecialFunctionModifierStorageClass *storageArray )
    3176             :    {
    3177           0 :      unsigned long storageCounter = 0;
    3178           0 :      std::vector < unsigned char* > :: const_iterator block = SgSpecialFunctionModifier::pools.begin();
    3179           0 :      SgSpecialFunctionModifier* pointer = NULL;
    3180           0 :      while ( block != SgSpecialFunctionModifier::pools.end() ) {
    3181           0 :           pointer = (SgSpecialFunctionModifier*) (*block);
    3182           0 :           for ( unsigned i = 0; i < SgSpecialFunctionModifier::pool_size; ++i ) {
    3183           0 :                if ( pointer->get_freepointer() != NULL ) {
    3184           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    3185           0 :                  storageArray++;
    3186           0 :                  storageCounter++;
    3187             :                }
    3188           0 :                pointer++;
    3189             :              }
    3190           0 :            block++;
    3191             :         }
    3192           0 :      return storageCounter;
    3193             :    }
    3194             : 
    3195             : /* #line 3196 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    3196             : 
    3197             : 
    3198             : 
    3199             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    3200             : 
    3201             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    3202             : 
    3203             : //############################################################################
    3204             : /* JH (02/02/2006) Constructor of the IR node SgElaboratedTypeModifier that takes its 
    3205             :  * corresponding StorageClass as parameter
    3206             :  */
    3207       54713 : SgElaboratedTypeModifier :: SgElaboratedTypeModifier ( const SgElaboratedTypeModifierStorageClass& storageSource )   : SgModifier (storageSource)
    3208             :    {
    3209             : 
    3210             : 
    3211             : /* #line 3212 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    3212             : 
    3213       54713 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    3214       54713 :      p_modifier = storageSource.storageOf_modifier ;
    3215             : 
    3216             : 
    3217             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    3218             : 
    3219             : 
    3220       54713 :    }
    3221             : 
    3222             : //############################################################################
    3223             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    3224             :  * within the working AST. 
    3225             :  */
    3226           0 : SgElaboratedTypeModifier * SgElaboratedTypeModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    3227           0 :      SgElaboratedTypeModifier* returnPointer = NULL;
    3228           0 :      if ( globalIndex != 0 )
    3229             :         {
    3230             : 
    3231             : #if FILE_IO_EXTRA_CHECK
    3232           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElaboratedTypeModifier ) ) <= globalIndex ) ;
    3233           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElaboratedTypeModifier + 1 ) ) );
    3234             : #endif
    3235           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElaboratedTypeModifier )  
    3236           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElaboratedTypeModifier );
    3237           0 :           unsigned long positionInPool = localIndex % SgElaboratedTypeModifier::pool_size;
    3238           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElaboratedTypeModifier::pool_size;
    3239             : 
    3240             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    3241             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    3242             : 
    3243           0 :           returnPointer = &( ( (SgElaboratedTypeModifier*)(SgElaboratedTypeModifier::pools[memoryBlock]) ) [positionInPool]) ;
    3244             : 
    3245           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    3246             :         }
    3247           0 :      return returnPointer ;
    3248             :    }
    3249             : 
    3250             : //############################################################################
    3251             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    3252             :   for the AST with the index astIndex
    3253             : */
    3254           0 : SgElaboratedTypeModifier * SgElaboratedTypeModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    3255           0 :      SgElaboratedTypeModifier* returnPointer = NULL;
    3256           0 :      if ( globalIndex != 0 )
    3257             :         {
    3258             : 
    3259             : #if FILE_IO_EXTRA_CHECK
    3260           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElaboratedTypeModifier ) ) <= globalIndex ) ;
    3261           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElaboratedTypeModifier + 1 ) ) );
    3262             : #endif
    3263           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElaboratedTypeModifier )
    3264           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElaboratedTypeModifier );
    3265           0 :           unsigned long positionInPool = localIndex % SgElaboratedTypeModifier::pool_size ;
    3266           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElaboratedTypeModifier::pool_size ;
    3267             : 
    3268             : #if FILE_IO_EXTRA_CHECK
    3269             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    3270             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    3271             : #endif
    3272             : 
    3273           0 :           returnPointer = &( ( (SgElaboratedTypeModifier*)(SgElaboratedTypeModifier::pools[memoryBlock]) ) [positionInPool]) ;
    3274             : 
    3275             : #if FILE_IO_EXTRA_CHECK
    3276           0 :           assert ( returnPointer != NULL ) ;
    3277             : #endif
    3278             :         }
    3279           0 :      return returnPointer ;
    3280             :    }
    3281             : 
    3282             : //############################################################################
    3283             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    3284             :  * pool size! We set for every valid object in the memory pool the freepointer
    3285             :  * to the global index and increase the global index afterwards. For all the 
    3286             :  * invalid objects (means address ranges within the memory pool that were not
    3287             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    3288             :  * distinguish valid from invalid objects! 
    3289             :  */
    3290             : unsigned long
    3291           5 : SgElaboratedTypeModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    3292             :    {
    3293           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    3294           5 :      SgElaboratedTypeModifier* pointer = NULL;
    3295           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    3296           5 :      std::vector < unsigned char* > :: const_iterator block;
    3297           5 :      for ( block = SgElaboratedTypeModifier::pools.begin(); block != SgElaboratedTypeModifier::pools.end() ; ++block )
    3298             :         {
    3299           0 :           pointer = (SgElaboratedTypeModifier*)(*block);
    3300           0 :           for (unsigned i = 0; i < SgElaboratedTypeModifier::pool_size; ++i )
    3301             :              {
    3302             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    3303             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    3304             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    3305             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    3306             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    3307             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    3308             :             // properly; so this will have to be checked next.
    3309             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    3310             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    3311           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    3312             :                   {
    3313           0 :                     pointer[i].set_freepointer((SgElaboratedTypeModifier*)(globalIndex));
    3314           0 :                     globalIndex++;
    3315             :                   }
    3316             :                else
    3317             :                   {
    3318           0 :                     pointer[i].set_freepointer(NULL);
    3319             :                   }
    3320             :               }
    3321             :         }
    3322           5 :      return globalIndex;
    3323             :    }
    3324             : 
    3325             : //############################################################################
    3326             : // JH (01/14/2006)
    3327             : void
    3328           5 : SgElaboratedTypeModifier::resetValidFreepointers( )
    3329             :    {
    3330           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    3331           5 :      SgElaboratedTypeModifier* pointer = NULL;
    3332           5 :      std::vector < unsigned char* > :: const_iterator block;
    3333           5 :      SgElaboratedTypeModifier* pointerOfLinkedList = NULL;
    3334           5 :      for ( block = SgElaboratedTypeModifier::pools.begin(); block != SgElaboratedTypeModifier::pools.end() ; ++block )
    3335             :         {
    3336           0 :           pointer = (SgElaboratedTypeModifier*)(*block);
    3337           0 :           for (unsigned i = 0; i < SgElaboratedTypeModifier::pool_size; ++i )
    3338             :              {
    3339             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    3340             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    3341             :             // memory blocks!.
    3342           0 :                if ( pointer[i].get_freepointer() != NULL )
    3343             :                   {
    3344           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    3345             :                   }
    3346             :                else
    3347             :                   {
    3348           0 :                     if ( pointerOfLinkedList == NULL )
    3349             :                        {
    3350           0 :                          SgElaboratedTypeModifier::next_node = &(pointer[i]);
    3351             :                        }
    3352             :                     else
    3353             :                        {
    3354             :                       // printf ("In SgElaboratedTypeModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    3355           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    3356             :                        }
    3357             :                     pointerOfLinkedList = &(pointer[i]);
    3358             :                   }
    3359             :               }
    3360             :         }
    3361             : 
    3362           5 :      if ( pointerOfLinkedList != NULL )
    3363             :         {
    3364             :        // printf ("In SgElaboratedTypeModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    3365           0 :           pointerOfLinkedList->set_freepointer(NULL);
    3366             :        // DQ (6/6/2010): Temporary debugging...
    3367             :        //   ROSE_ASSERT(false);
    3368             :         }
    3369             : 
    3370           5 :      return ;
    3371             :    }
    3372             : 
    3373             : //############################################################################
    3374             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    3375             :  * within the memory pool and resets the freepointers, in order to achieve a 
    3376             :  * linked list, that has no jumps and starts at the beginning! This function 
    3377             :  * does not extend the memory pool, since we do not delete any memory blocks,
    3378             :  * but delete the valid objects.  
    3379             :  */
    3380             : void
    3381           0 : SgElaboratedTypeModifier::clearMemoryPool( )
    3382             :    {
    3383             :   // printf ("Inside of SgElaboratedTypeModifier::clearMemoryPool() \n");
    3384             : 
    3385           0 :      SgElaboratedTypeModifier* pointer = NULL, *tempPointer = NULL;
    3386           0 :      std::vector < unsigned char* > :: const_iterator block;
    3387           0 :      if ( SgElaboratedTypeModifier::pools.empty() == false )
    3388             :         {
    3389           0 :           block = SgElaboratedTypeModifier::pools.begin() ;
    3390           0 :           SgElaboratedTypeModifier::next_node = (SgElaboratedTypeModifier*) (*block);
    3391             : 
    3392           0 :           while ( block != SgElaboratedTypeModifier::pools.end() )
    3393             :              {
    3394           0 :                pointer = (SgElaboratedTypeModifier*) (*block);
    3395           0 :                if ( tempPointer != NULL )
    3396             :                   {
    3397           0 :                     tempPointer->set_freepointer(pointer);
    3398             :                   }
    3399           0 :                for (unsigned i = 0; i < SgElaboratedTypeModifier::pool_size - 1; ++i)
    3400             :                   {
    3401           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    3402             :                   }
    3403           0 :                 pointer[SgElaboratedTypeModifier::pool_size-1].set_freepointer(NULL);
    3404           0 :                 tempPointer = &(pointer[SgElaboratedTypeModifier::pool_size-1]);
    3405           0 :                 ++block;
    3406             :              }
    3407             :         }
    3408           0 :    }
    3409             : 
    3410           5 : void SgElaboratedTypeModifier::deleteMemoryPool() {
    3411           5 :   for (auto p: SgElaboratedTypeModifier::pools) {
    3412           0 :     ROSE_FREE(p);
    3413             :   }
    3414           5 :   SgElaboratedTypeModifier::next_node = nullptr;
    3415           5 :   SgElaboratedTypeModifier::pools.clear();
    3416           5 : }
    3417             : 
    3418             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    3419             : //                 reading multiple binary files to for a single AST.
    3420             : /////////// new version ////////////////////////////////
    3421             : //############################################################################
    3422             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    3423             : void
    3424           2 : SgElaboratedTypeModifier::extendMemoryPoolForFileIO( )
    3425             :   {
    3426           2 :     size_t blockIndex = SgElaboratedTypeModifier::pools.size();
    3427           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElaboratedTypeModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElaboratedTypeModifier);
    3428             : 
    3429           2 :     while ( (blockIndex * SgElaboratedTypeModifier::pool_size) < newPoolSize)
    3430             :       {
    3431             : #if ROSE_ALLOC_TRACE
    3432             :         if (blockIndex > 0) {
    3433             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElaboratedTypeModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElaboratedTypeModifier) = %" PRIuPTR " SgElaboratedTypeModifier::pool_size = %d \n",
    3434             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElaboratedTypeModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElaboratedTypeModifier),SgElaboratedTypeModifier::pool_size);
    3435             :         }
    3436             : #endif
    3437             : 
    3438           0 :         SgElaboratedTypeModifier * pointer = (SgElaboratedTypeModifier*) ROSE_MALLOC ( SgElaboratedTypeModifier::pool_size * sizeof(SgElaboratedTypeModifier) );
    3439           0 :         assert( pointer != NULL );
    3440             : #if ROSE_ALLOC_MEMSET == 1
    3441             :         memset(pointer, 0x00, SgElaboratedTypeModifier::pool_size * sizeof(SgElaboratedTypeModifier));
    3442             : #elif ROSE_ALLOC_MEMSET == 2
    3443             :         memset(pointer, 0xCC, SgElaboratedTypeModifier::pool_size * sizeof(SgElaboratedTypeModifier));
    3444             : #endif
    3445           0 :         SgElaboratedTypeModifier::pools.push_back( (unsigned char*)(pointer) );
    3446           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElaboratedTypeModifier::pool_size * sizeof(SgElaboratedTypeModifier), V_SgElaboratedTypeModifier ) );
    3447             : 
    3448           0 :         if ( SgElaboratedTypeModifier::next_node != NULL ) {
    3449           0 :           if ( blockIndex > 0 ) {
    3450           0 :             SgElaboratedTypeModifier * blkptr = (SgElaboratedTypeModifier*)(SgElaboratedTypeModifier::pools[blockIndex-1]);
    3451           0 :             blkptr[ SgElaboratedTypeModifier::pool_size - 1 ].set_freepointer(pointer);
    3452             :           }
    3453             :         } else {
    3454           0 :           SgElaboratedTypeModifier::next_node = pointer;
    3455             :         }
    3456             : 
    3457           0 :         for (unsigned i = 0; i < SgElaboratedTypeModifier::pool_size-1; ++i)
    3458             :            {
    3459           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    3460             :            }
    3461           0 :         pointer[ SgElaboratedTypeModifier::pool_size -1 ].set_freepointer(NULL);
    3462             : 
    3463           0 :         blockIndex++;
    3464             :       }
    3465           2 :   }
    3466             : 
    3467             : //############################################################################
    3468             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    3469             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    3470             :  * not compressed. However, that stuff is not yet implemented! 
    3471             :  */
    3472             : unsigned long
    3473           0 : SgElaboratedTypeModifier::getNumberOfLastValidPointer()
    3474             :    {
    3475           0 :       SgElaboratedTypeModifier* testPointer = (SgElaboratedTypeModifier*)(SgElaboratedTypeModifier::pools.back());
    3476           0 :       unsigned long localIndex = SgElaboratedTypeModifier::pool_size - 1;
    3477           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    3478             :          {
    3479           0 :            localIndex--;
    3480             :          }
    3481           0 :       return (localIndex + SgElaboratedTypeModifier::pool_size * (SgElaboratedTypeModifier::pools.size()-1));
    3482             :    }
    3483             : 
    3484             : //############################################################################
    3485             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    3486             :  * memory pool and initializes the data member in class SgElaboratedTypeModifierStroageClass
    3487             :  * from its counterpart of SgElaboratedTypeModifier. The return value is just for checking, 
    3488             :  * that the whole StorageClassArray is initialized!
    3489             :  */
    3490             : unsigned long
    3491           0 : SgElaboratedTypeModifier::initializeStorageClassArray( SgElaboratedTypeModifierStorageClass *storageArray )
    3492             :    {
    3493           0 :      unsigned long storageCounter = 0;
    3494           0 :      std::vector < unsigned char* > :: const_iterator block = SgElaboratedTypeModifier::pools.begin();
    3495           0 :      SgElaboratedTypeModifier* pointer = NULL;
    3496           0 :      while ( block != SgElaboratedTypeModifier::pools.end() ) {
    3497           0 :           pointer = (SgElaboratedTypeModifier*) (*block);
    3498           0 :           for ( unsigned i = 0; i < SgElaboratedTypeModifier::pool_size; ++i ) {
    3499           0 :                if ( pointer->get_freepointer() != NULL ) {
    3500           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    3501           0 :                  storageArray++;
    3502           0 :                  storageCounter++;
    3503             :                }
    3504           0 :                pointer++;
    3505             :              }
    3506           0 :            block++;
    3507             :         }
    3508           0 :      return storageCounter;
    3509             :    }
    3510             : 
    3511             : /* #line 3512 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    3512             : 
    3513             : 
    3514             : 
    3515             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    3516             : 
    3517             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    3518             : 
    3519             : //############################################################################
    3520             : /* JH (02/02/2006) Constructor of the IR node SgLinkageModifier that takes its 
    3521             :  * corresponding StorageClass as parameter
    3522             :  */
    3523           0 : SgLinkageModifier :: SgLinkageModifier ( const SgLinkageModifierStorageClass& storageSource )   : SgModifier (storageSource)
    3524             :    {
    3525             : 
    3526             : 
    3527             : /* #line 3528 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    3528             : 
    3529           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    3530           0 :      p_modifier = storageSource.storageOf_modifier ;
    3531             : 
    3532             : 
    3533             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    3534             : 
    3535             : 
    3536           0 :    }
    3537             : 
    3538             : //############################################################################
    3539             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    3540             :  * within the working AST. 
    3541             :  */
    3542           0 : SgLinkageModifier * SgLinkageModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    3543           0 :      SgLinkageModifier* returnPointer = NULL;
    3544           0 :      if ( globalIndex != 0 )
    3545             :         {
    3546             : 
    3547             : #if FILE_IO_EXTRA_CHECK
    3548           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLinkageModifier ) ) <= globalIndex ) ;
    3549           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLinkageModifier + 1 ) ) );
    3550             : #endif
    3551           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLinkageModifier )  
    3552           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLinkageModifier );
    3553           0 :           unsigned long positionInPool = localIndex % SgLinkageModifier::pool_size;
    3554           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLinkageModifier::pool_size;
    3555             : 
    3556             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    3557             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    3558             : 
    3559           0 :           returnPointer = &( ( (SgLinkageModifier*)(SgLinkageModifier::pools[memoryBlock]) ) [positionInPool]) ;
    3560             : 
    3561           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    3562             :         }
    3563           0 :      return returnPointer ;
    3564             :    }
    3565             : 
    3566             : //############################################################################
    3567             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    3568             :   for the AST with the index astIndex
    3569             : */
    3570           0 : SgLinkageModifier * SgLinkageModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    3571           0 :      SgLinkageModifier* returnPointer = NULL;
    3572           0 :      if ( globalIndex != 0 )
    3573             :         {
    3574             : 
    3575             : #if FILE_IO_EXTRA_CHECK
    3576           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLinkageModifier ) ) <= globalIndex ) ;
    3577           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLinkageModifier + 1 ) ) );
    3578             : #endif
    3579           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLinkageModifier )
    3580           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLinkageModifier );
    3581           0 :           unsigned long positionInPool = localIndex % SgLinkageModifier::pool_size ;
    3582           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLinkageModifier::pool_size ;
    3583             : 
    3584             : #if FILE_IO_EXTRA_CHECK
    3585             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    3586             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    3587             : #endif
    3588             : 
    3589           0 :           returnPointer = &( ( (SgLinkageModifier*)(SgLinkageModifier::pools[memoryBlock]) ) [positionInPool]) ;
    3590             : 
    3591             : #if FILE_IO_EXTRA_CHECK
    3592           0 :           assert ( returnPointer != NULL ) ;
    3593             : #endif
    3594             :         }
    3595           0 :      return returnPointer ;
    3596             :    }
    3597             : 
    3598             : //############################################################################
    3599             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    3600             :  * pool size! We set for every valid object in the memory pool the freepointer
    3601             :  * to the global index and increase the global index afterwards. For all the 
    3602             :  * invalid objects (means address ranges within the memory pool that were not
    3603             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    3604             :  * distinguish valid from invalid objects! 
    3605             :  */
    3606             : unsigned long
    3607           5 : SgLinkageModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    3608             :    {
    3609           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    3610           5 :      SgLinkageModifier* pointer = NULL;
    3611           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    3612           5 :      std::vector < unsigned char* > :: const_iterator block;
    3613           5 :      for ( block = SgLinkageModifier::pools.begin(); block != SgLinkageModifier::pools.end() ; ++block )
    3614             :         {
    3615           0 :           pointer = (SgLinkageModifier*)(*block);
    3616           0 :           for (unsigned i = 0; i < SgLinkageModifier::pool_size; ++i )
    3617             :              {
    3618             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    3619             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    3620             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    3621             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    3622             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    3623             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    3624             :             // properly; so this will have to be checked next.
    3625             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    3626             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    3627           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    3628             :                   {
    3629           0 :                     pointer[i].set_freepointer((SgLinkageModifier*)(globalIndex));
    3630           0 :                     globalIndex++;
    3631             :                   }
    3632             :                else
    3633             :                   {
    3634           0 :                     pointer[i].set_freepointer(NULL);
    3635             :                   }
    3636             :               }
    3637             :         }
    3638           5 :      return globalIndex;
    3639             :    }
    3640             : 
    3641             : //############################################################################
    3642             : // JH (01/14/2006)
    3643             : void
    3644           5 : SgLinkageModifier::resetValidFreepointers( )
    3645             :    {
    3646           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    3647           5 :      SgLinkageModifier* pointer = NULL;
    3648           5 :      std::vector < unsigned char* > :: const_iterator block;
    3649           5 :      SgLinkageModifier* pointerOfLinkedList = NULL;
    3650           5 :      for ( block = SgLinkageModifier::pools.begin(); block != SgLinkageModifier::pools.end() ; ++block )
    3651             :         {
    3652           0 :           pointer = (SgLinkageModifier*)(*block);
    3653           0 :           for (unsigned i = 0; i < SgLinkageModifier::pool_size; ++i )
    3654             :              {
    3655             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    3656             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    3657             :             // memory blocks!.
    3658           0 :                if ( pointer[i].get_freepointer() != NULL )
    3659             :                   {
    3660           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    3661             :                   }
    3662             :                else
    3663             :                   {
    3664           0 :                     if ( pointerOfLinkedList == NULL )
    3665             :                        {
    3666           0 :                          SgLinkageModifier::next_node = &(pointer[i]);
    3667             :                        }
    3668             :                     else
    3669             :                        {
    3670             :                       // printf ("In SgLinkageModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    3671           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    3672             :                        }
    3673             :                     pointerOfLinkedList = &(pointer[i]);
    3674             :                   }
    3675             :               }
    3676             :         }
    3677             : 
    3678           5 :      if ( pointerOfLinkedList != NULL )
    3679             :         {
    3680             :        // printf ("In SgLinkageModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    3681           0 :           pointerOfLinkedList->set_freepointer(NULL);
    3682             :        // DQ (6/6/2010): Temporary debugging...
    3683             :        //   ROSE_ASSERT(false);
    3684             :         }
    3685             : 
    3686           5 :      return ;
    3687             :    }
    3688             : 
    3689             : //############################################################################
    3690             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    3691             :  * within the memory pool and resets the freepointers, in order to achieve a 
    3692             :  * linked list, that has no jumps and starts at the beginning! This function 
    3693             :  * does not extend the memory pool, since we do not delete any memory blocks,
    3694             :  * but delete the valid objects.  
    3695             :  */
    3696             : void
    3697           0 : SgLinkageModifier::clearMemoryPool( )
    3698             :    {
    3699             :   // printf ("Inside of SgLinkageModifier::clearMemoryPool() \n");
    3700             : 
    3701           0 :      SgLinkageModifier* pointer = NULL, *tempPointer = NULL;
    3702           0 :      std::vector < unsigned char* > :: const_iterator block;
    3703           0 :      if ( SgLinkageModifier::pools.empty() == false )
    3704             :         {
    3705           0 :           block = SgLinkageModifier::pools.begin() ;
    3706           0 :           SgLinkageModifier::next_node = (SgLinkageModifier*) (*block);
    3707             : 
    3708           0 :           while ( block != SgLinkageModifier::pools.end() )
    3709             :              {
    3710           0 :                pointer = (SgLinkageModifier*) (*block);
    3711           0 :                if ( tempPointer != NULL )
    3712             :                   {
    3713           0 :                     tempPointer->set_freepointer(pointer);
    3714             :                   }
    3715           0 :                for (unsigned i = 0; i < SgLinkageModifier::pool_size - 1; ++i)
    3716             :                   {
    3717           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    3718             :                   }
    3719           0 :                 pointer[SgLinkageModifier::pool_size-1].set_freepointer(NULL);
    3720           0 :                 tempPointer = &(pointer[SgLinkageModifier::pool_size-1]);
    3721           0 :                 ++block;
    3722             :              }
    3723             :         }
    3724           0 :    }
    3725             : 
    3726           5 : void SgLinkageModifier::deleteMemoryPool() {
    3727           5 :   for (auto p: SgLinkageModifier::pools) {
    3728           0 :     ROSE_FREE(p);
    3729             :   }
    3730           5 :   SgLinkageModifier::next_node = nullptr;
    3731           5 :   SgLinkageModifier::pools.clear();
    3732           5 : }
    3733             : 
    3734             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    3735             : //                 reading multiple binary files to for a single AST.
    3736             : /////////// new version ////////////////////////////////
    3737             : //############################################################################
    3738             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    3739             : void
    3740           2 : SgLinkageModifier::extendMemoryPoolForFileIO( )
    3741             :   {
    3742           2 :     size_t blockIndex = SgLinkageModifier::pools.size();
    3743           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLinkageModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLinkageModifier);
    3744             : 
    3745           2 :     while ( (blockIndex * SgLinkageModifier::pool_size) < newPoolSize)
    3746             :       {
    3747             : #if ROSE_ALLOC_TRACE
    3748             :         if (blockIndex > 0) {
    3749             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLinkageModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLinkageModifier) = %" PRIuPTR " SgLinkageModifier::pool_size = %d \n",
    3750             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLinkageModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLinkageModifier),SgLinkageModifier::pool_size);
    3751             :         }
    3752             : #endif
    3753             : 
    3754           0 :         SgLinkageModifier * pointer = (SgLinkageModifier*) ROSE_MALLOC ( SgLinkageModifier::pool_size * sizeof(SgLinkageModifier) );
    3755           0 :         assert( pointer != NULL );
    3756             : #if ROSE_ALLOC_MEMSET == 1
    3757             :         memset(pointer, 0x00, SgLinkageModifier::pool_size * sizeof(SgLinkageModifier));
    3758             : #elif ROSE_ALLOC_MEMSET == 2
    3759             :         memset(pointer, 0xCC, SgLinkageModifier::pool_size * sizeof(SgLinkageModifier));
    3760             : #endif
    3761           0 :         SgLinkageModifier::pools.push_back( (unsigned char*)(pointer) );
    3762           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLinkageModifier::pool_size * sizeof(SgLinkageModifier), V_SgLinkageModifier ) );
    3763             : 
    3764           0 :         if ( SgLinkageModifier::next_node != NULL ) {
    3765           0 :           if ( blockIndex > 0 ) {
    3766           0 :             SgLinkageModifier * blkptr = (SgLinkageModifier*)(SgLinkageModifier::pools[blockIndex-1]);
    3767           0 :             blkptr[ SgLinkageModifier::pool_size - 1 ].set_freepointer(pointer);
    3768             :           }
    3769             :         } else {
    3770           0 :           SgLinkageModifier::next_node = pointer;
    3771             :         }
    3772             : 
    3773           0 :         for (unsigned i = 0; i < SgLinkageModifier::pool_size-1; ++i)
    3774             :            {
    3775           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    3776             :            }
    3777           0 :         pointer[ SgLinkageModifier::pool_size -1 ].set_freepointer(NULL);
    3778             : 
    3779           0 :         blockIndex++;
    3780             :       }
    3781           2 :   }
    3782             : 
    3783             : //############################################################################
    3784             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    3785             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    3786             :  * not compressed. However, that stuff is not yet implemented! 
    3787             :  */
    3788             : unsigned long
    3789           0 : SgLinkageModifier::getNumberOfLastValidPointer()
    3790             :    {
    3791           0 :       SgLinkageModifier* testPointer = (SgLinkageModifier*)(SgLinkageModifier::pools.back());
    3792           0 :       unsigned long localIndex = SgLinkageModifier::pool_size - 1;
    3793           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    3794             :          {
    3795           0 :            localIndex--;
    3796             :          }
    3797           0 :       return (localIndex + SgLinkageModifier::pool_size * (SgLinkageModifier::pools.size()-1));
    3798             :    }
    3799             : 
    3800             : //############################################################################
    3801             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    3802             :  * memory pool and initializes the data member in class SgLinkageModifierStroageClass
    3803             :  * from its counterpart of SgLinkageModifier. The return value is just for checking, 
    3804             :  * that the whole StorageClassArray is initialized!
    3805             :  */
    3806             : unsigned long
    3807           0 : SgLinkageModifier::initializeStorageClassArray( SgLinkageModifierStorageClass *storageArray )
    3808             :    {
    3809           0 :      unsigned long storageCounter = 0;
    3810           0 :      std::vector < unsigned char* > :: const_iterator block = SgLinkageModifier::pools.begin();
    3811           0 :      SgLinkageModifier* pointer = NULL;
    3812           0 :      while ( block != SgLinkageModifier::pools.end() ) {
    3813           0 :           pointer = (SgLinkageModifier*) (*block);
    3814           0 :           for ( unsigned i = 0; i < SgLinkageModifier::pool_size; ++i ) {
    3815           0 :                if ( pointer->get_freepointer() != NULL ) {
    3816           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    3817           0 :                  storageArray++;
    3818           0 :                  storageCounter++;
    3819             :                }
    3820           0 :                pointer++;
    3821             :              }
    3822           0 :            block++;
    3823             :         }
    3824           0 :      return storageCounter;
    3825             :    }
    3826             : 
    3827             : /* #line 3828 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    3828             : 
    3829             : 
    3830             : 
    3831             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    3832             : 
    3833             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    3834             : 
    3835             : //############################################################################
    3836             : /* JH (02/02/2006) Constructor of the IR node SgBaseClassModifier that takes its 
    3837             :  * corresponding StorageClass as parameter
    3838             :  */
    3839         620 : SgBaseClassModifier :: SgBaseClassModifier ( const SgBaseClassModifierStorageClass& storageSource )   : SgModifier (storageSource)
    3840             :    {
    3841             : 
    3842             : 
    3843             : /* #line 3844 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    3844             : 
    3845         620 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    3846         620 :      p_modifier = storageSource.storageOf_modifier ;
    3847         620 :      p_accessModifier = SgAccessModifier ( storageSource.storageOf_accessModifier ) ;
    3848             : 
    3849             : 
    3850             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    3851             : 
    3852             : 
    3853         620 :    }
    3854             : 
    3855             : //############################################################################
    3856             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    3857             :  * within the working AST. 
    3858             :  */
    3859         620 : SgBaseClassModifier * SgBaseClassModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    3860         620 :      SgBaseClassModifier* returnPointer = NULL;
    3861         620 :      if ( globalIndex != 0 )
    3862             :         {
    3863             : 
    3864             : #if FILE_IO_EXTRA_CHECK
    3865         620 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBaseClassModifier ) ) <= globalIndex ) ;
    3866         620 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBaseClassModifier + 1 ) ) );
    3867             : #endif
    3868         620 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBaseClassModifier )  
    3869         620 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBaseClassModifier );
    3870         620 :           unsigned long positionInPool = localIndex % SgBaseClassModifier::pool_size;
    3871         620 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBaseClassModifier::pool_size;
    3872             : 
    3873             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    3874             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    3875             : 
    3876         620 :           returnPointer = &( ( (SgBaseClassModifier*)(SgBaseClassModifier::pools[memoryBlock]) ) [positionInPool]) ;
    3877             : 
    3878         620 :           ROSE_ASSERT( returnPointer != NULL ) ;
    3879             :         }
    3880         620 :      return returnPointer ;
    3881             :    }
    3882             : 
    3883             : //############################################################################
    3884             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    3885             :   for the AST with the index astIndex
    3886             : */
    3887           0 : SgBaseClassModifier * SgBaseClassModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    3888           0 :      SgBaseClassModifier* returnPointer = NULL;
    3889           0 :      if ( globalIndex != 0 )
    3890             :         {
    3891             : 
    3892             : #if FILE_IO_EXTRA_CHECK
    3893           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBaseClassModifier ) ) <= globalIndex ) ;
    3894           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBaseClassModifier + 1 ) ) );
    3895             : #endif
    3896           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBaseClassModifier )
    3897           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBaseClassModifier );
    3898           0 :           unsigned long positionInPool = localIndex % SgBaseClassModifier::pool_size ;
    3899           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBaseClassModifier::pool_size ;
    3900             : 
    3901             : #if FILE_IO_EXTRA_CHECK
    3902             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    3903             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    3904             : #endif
    3905             : 
    3906           0 :           returnPointer = &( ( (SgBaseClassModifier*)(SgBaseClassModifier::pools[memoryBlock]) ) [positionInPool]) ;
    3907             : 
    3908             : #if FILE_IO_EXTRA_CHECK
    3909           0 :           assert ( returnPointer != NULL ) ;
    3910             : #endif
    3911             :         }
    3912           0 :      return returnPointer ;
    3913             :    }
    3914             : 
    3915             : //############################################################################
    3916             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    3917             :  * pool size! We set for every valid object in the memory pool the freepointer
    3918             :  * to the global index and increase the global index afterwards. For all the 
    3919             :  * invalid objects (means address ranges within the memory pool that were not
    3920             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    3921             :  * distinguish valid from invalid objects! 
    3922             :  */
    3923             : unsigned long
    3924           5 : SgBaseClassModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    3925             :    {
    3926           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    3927           5 :      SgBaseClassModifier* pointer = NULL;
    3928           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    3929           5 :      std::vector < unsigned char* > :: const_iterator block;
    3930           6 :      for ( block = SgBaseClassModifier::pools.begin(); block != SgBaseClassModifier::pools.end() ; ++block )
    3931             :         {
    3932           1 :           pointer = (SgBaseClassModifier*)(*block);
    3933        2001 :           for (unsigned i = 0; i < SgBaseClassModifier::pool_size; ++i )
    3934             :              {
    3935             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    3936             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    3937             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    3938             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    3939             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    3940             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    3941             :             // properly; so this will have to be checked next.
    3942             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    3943             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    3944        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    3945             :                   {
    3946         620 :                     pointer[i].set_freepointer((SgBaseClassModifier*)(globalIndex));
    3947         620 :                     globalIndex++;
    3948             :                   }
    3949             :                else
    3950             :                   {
    3951        1380 :                     pointer[i].set_freepointer(NULL);
    3952             :                   }
    3953             :               }
    3954             :         }
    3955           5 :      return globalIndex;
    3956             :    }
    3957             : 
    3958             : //############################################################################
    3959             : // JH (01/14/2006)
    3960             : void
    3961           5 : SgBaseClassModifier::resetValidFreepointers( )
    3962             :    {
    3963           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    3964           5 :      SgBaseClassModifier* pointer = NULL;
    3965           5 :      std::vector < unsigned char* > :: const_iterator block;
    3966           5 :      SgBaseClassModifier* pointerOfLinkedList = NULL;
    3967           6 :      for ( block = SgBaseClassModifier::pools.begin(); block != SgBaseClassModifier::pools.end() ; ++block )
    3968             :         {
    3969           1 :           pointer = (SgBaseClassModifier*)(*block);
    3970        2001 :           for (unsigned i = 0; i < SgBaseClassModifier::pool_size; ++i )
    3971             :              {
    3972             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    3973             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    3974             :             // memory blocks!.
    3975        2000 :                if ( pointer[i].get_freepointer() != NULL )
    3976             :                   {
    3977         620 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    3978             :                   }
    3979             :                else
    3980             :                   {
    3981        1380 :                     if ( pointerOfLinkedList == NULL )
    3982             :                        {
    3983           1 :                          SgBaseClassModifier::next_node = &(pointer[i]);
    3984             :                        }
    3985             :                     else
    3986             :                        {
    3987             :                       // printf ("In SgBaseClassModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    3988        1379 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    3989             :                        }
    3990             :                     pointerOfLinkedList = &(pointer[i]);
    3991             :                   }
    3992             :               }
    3993             :         }
    3994             : 
    3995           5 :      if ( pointerOfLinkedList != NULL )
    3996             :         {
    3997             :        // printf ("In SgBaseClassModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    3998           1 :           pointerOfLinkedList->set_freepointer(NULL);
    3999             :        // DQ (6/6/2010): Temporary debugging...
    4000             :        //   ROSE_ASSERT(false);
    4001             :         }
    4002             : 
    4003           5 :      return ;
    4004             :    }
    4005             : 
    4006             : //############################################################################
    4007             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    4008             :  * within the memory pool and resets the freepointers, in order to achieve a 
    4009             :  * linked list, that has no jumps and starts at the beginning! This function 
    4010             :  * does not extend the memory pool, since we do not delete any memory blocks,
    4011             :  * but delete the valid objects.  
    4012             :  */
    4013             : void
    4014           0 : SgBaseClassModifier::clearMemoryPool( )
    4015             :    {
    4016             :   // printf ("Inside of SgBaseClassModifier::clearMemoryPool() \n");
    4017             : 
    4018           0 :      SgBaseClassModifier* pointer = NULL, *tempPointer = NULL;
    4019           0 :      std::vector < unsigned char* > :: const_iterator block;
    4020           0 :      if ( SgBaseClassModifier::pools.empty() == false )
    4021             :         {
    4022           0 :           block = SgBaseClassModifier::pools.begin() ;
    4023           0 :           SgBaseClassModifier::next_node = (SgBaseClassModifier*) (*block);
    4024             : 
    4025           0 :           while ( block != SgBaseClassModifier::pools.end() )
    4026             :              {
    4027           0 :                pointer = (SgBaseClassModifier*) (*block);
    4028           0 :                if ( tempPointer != NULL )
    4029             :                   {
    4030           0 :                     tempPointer->set_freepointer(pointer);
    4031             :                   }
    4032           0 :                for (unsigned i = 0; i < SgBaseClassModifier::pool_size - 1; ++i)
    4033             :                   {
    4034           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    4035             :                   }
    4036           0 :                 pointer[SgBaseClassModifier::pool_size-1].set_freepointer(NULL);
    4037           0 :                 tempPointer = &(pointer[SgBaseClassModifier::pool_size-1]);
    4038           0 :                 ++block;
    4039             :              }
    4040             :         }
    4041           0 :    }
    4042             : 
    4043           5 : void SgBaseClassModifier::deleteMemoryPool() {
    4044           7 :   for (auto p: SgBaseClassModifier::pools) {
    4045           2 :     ROSE_FREE(p);
    4046             :   }
    4047           5 :   SgBaseClassModifier::next_node = nullptr;
    4048           5 :   SgBaseClassModifier::pools.clear();
    4049           5 : }
    4050             : 
    4051             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    4052             : //                 reading multiple binary files to for a single AST.
    4053             : /////////// new version ////////////////////////////////
    4054             : //############################################################################
    4055             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    4056             : void
    4057           2 : SgBaseClassModifier::extendMemoryPoolForFileIO( )
    4058             :   {
    4059           2 :     size_t blockIndex = SgBaseClassModifier::pools.size();
    4060           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBaseClassModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBaseClassModifier);
    4061             : 
    4062           3 :     while ( (blockIndex * SgBaseClassModifier::pool_size) < newPoolSize)
    4063             :       {
    4064             : #if ROSE_ALLOC_TRACE
    4065             :         if (blockIndex > 0) {
    4066             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBaseClassModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBaseClassModifier) = %" PRIuPTR " SgBaseClassModifier::pool_size = %d \n",
    4067             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBaseClassModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBaseClassModifier),SgBaseClassModifier::pool_size);
    4068             :         }
    4069             : #endif
    4070             : 
    4071           1 :         SgBaseClassModifier * pointer = (SgBaseClassModifier*) ROSE_MALLOC ( SgBaseClassModifier::pool_size * sizeof(SgBaseClassModifier) );
    4072           1 :         assert( pointer != NULL );
    4073             : #if ROSE_ALLOC_MEMSET == 1
    4074             :         memset(pointer, 0x00, SgBaseClassModifier::pool_size * sizeof(SgBaseClassModifier));
    4075             : #elif ROSE_ALLOC_MEMSET == 2
    4076             :         memset(pointer, 0xCC, SgBaseClassModifier::pool_size * sizeof(SgBaseClassModifier));
    4077             : #endif
    4078           1 :         SgBaseClassModifier::pools.push_back( (unsigned char*)(pointer) );
    4079           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBaseClassModifier::pool_size * sizeof(SgBaseClassModifier), V_SgBaseClassModifier ) );
    4080             : 
    4081           1 :         if ( SgBaseClassModifier::next_node != NULL ) {
    4082           0 :           if ( blockIndex > 0 ) {
    4083           0 :             SgBaseClassModifier * blkptr = (SgBaseClassModifier*)(SgBaseClassModifier::pools[blockIndex-1]);
    4084           0 :             blkptr[ SgBaseClassModifier::pool_size - 1 ].set_freepointer(pointer);
    4085             :           }
    4086             :         } else {
    4087           1 :           SgBaseClassModifier::next_node = pointer;
    4088             :         }
    4089             : 
    4090        2000 :         for (unsigned i = 0; i < SgBaseClassModifier::pool_size-1; ++i)
    4091             :            {
    4092        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    4093             :            }
    4094           1 :         pointer[ SgBaseClassModifier::pool_size -1 ].set_freepointer(NULL);
    4095             : 
    4096           1 :         blockIndex++;
    4097             :       }
    4098           2 :   }
    4099             : 
    4100             : //############################################################################
    4101             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    4102             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    4103             :  * not compressed. However, that stuff is not yet implemented! 
    4104             :  */
    4105             : unsigned long
    4106           0 : SgBaseClassModifier::getNumberOfLastValidPointer()
    4107             :    {
    4108           0 :       SgBaseClassModifier* testPointer = (SgBaseClassModifier*)(SgBaseClassModifier::pools.back());
    4109           0 :       unsigned long localIndex = SgBaseClassModifier::pool_size - 1;
    4110           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    4111             :          {
    4112           0 :            localIndex--;
    4113             :          }
    4114           0 :       return (localIndex + SgBaseClassModifier::pool_size * (SgBaseClassModifier::pools.size()-1));
    4115             :    }
    4116             : 
    4117             : //############################################################################
    4118             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    4119             :  * memory pool and initializes the data member in class SgBaseClassModifierStroageClass
    4120             :  * from its counterpart of SgBaseClassModifier. The return value is just for checking, 
    4121             :  * that the whole StorageClassArray is initialized!
    4122             :  */
    4123             : unsigned long
    4124           1 : SgBaseClassModifier::initializeStorageClassArray( SgBaseClassModifierStorageClass *storageArray )
    4125             :    {
    4126           1 :      unsigned long storageCounter = 0;
    4127           1 :      std::vector < unsigned char* > :: const_iterator block = SgBaseClassModifier::pools.begin();
    4128           1 :      SgBaseClassModifier* pointer = NULL;
    4129           2 :      while ( block != SgBaseClassModifier::pools.end() ) {
    4130           1 :           pointer = (SgBaseClassModifier*) (*block);
    4131        2001 :           for ( unsigned i = 0; i < SgBaseClassModifier::pool_size; ++i ) {
    4132        2000 :                if ( pointer->get_freepointer() != NULL ) {
    4133         620 :                  storageArray->pickOutIRNodeData (pointer) ;
    4134         620 :                  storageArray++;
    4135         620 :                  storageCounter++;
    4136             :                }
    4137        2000 :                pointer++;
    4138             :              }
    4139           1 :            block++;
    4140             :         }
    4141           1 :      return storageCounter;
    4142             :    }
    4143             : 
    4144             : /* #line 4145 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    4145             : 
    4146             : 
    4147             : 
    4148             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    4149             : 
    4150             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    4151             : 
    4152             : //############################################################################
    4153             : /* JH (02/02/2006) Constructor of the IR node SgStructureModifier that takes its 
    4154             :  * corresponding StorageClass as parameter
    4155             :  */
    4156       54713 : SgStructureModifier :: SgStructureModifier ( const SgStructureModifierStorageClass& storageSource )   : SgModifier (storageSource)
    4157             :    {
    4158             : 
    4159             : 
    4160             : /* #line 4161 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    4161             : 
    4162       54713 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    4163       54713 :      p_modifier = storageSource.storageOf_modifier ;
    4164       54713 :      p_bits_per_entry = storageSource.storageOf_bits_per_entry ;
    4165             : 
    4166             : 
    4167             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    4168             : 
    4169             : 
    4170       54713 :    }
    4171             : 
    4172             : //############################################################################
    4173             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    4174             :  * within the working AST. 
    4175             :  */
    4176           0 : SgStructureModifier * SgStructureModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    4177           0 :      SgStructureModifier* returnPointer = NULL;
    4178           0 :      if ( globalIndex != 0 )
    4179             :         {
    4180             : 
    4181             : #if FILE_IO_EXTRA_CHECK
    4182           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStructureModifier ) ) <= globalIndex ) ;
    4183           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStructureModifier + 1 ) ) );
    4184             : #endif
    4185           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStructureModifier )  
    4186           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStructureModifier );
    4187           0 :           unsigned long positionInPool = localIndex % SgStructureModifier::pool_size;
    4188           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStructureModifier::pool_size;
    4189             : 
    4190             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    4191             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    4192             : 
    4193           0 :           returnPointer = &( ( (SgStructureModifier*)(SgStructureModifier::pools[memoryBlock]) ) [positionInPool]) ;
    4194             : 
    4195           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    4196             :         }
    4197           0 :      return returnPointer ;
    4198             :    }
    4199             : 
    4200             : //############################################################################
    4201             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    4202             :   for the AST with the index astIndex
    4203             : */
    4204           0 : SgStructureModifier * SgStructureModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    4205           0 :      SgStructureModifier* returnPointer = NULL;
    4206           0 :      if ( globalIndex != 0 )
    4207             :         {
    4208             : 
    4209             : #if FILE_IO_EXTRA_CHECK
    4210           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStructureModifier ) ) <= globalIndex ) ;
    4211           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStructureModifier + 1 ) ) );
    4212             : #endif
    4213           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStructureModifier )
    4214           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStructureModifier );
    4215           0 :           unsigned long positionInPool = localIndex % SgStructureModifier::pool_size ;
    4216           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStructureModifier::pool_size ;
    4217             : 
    4218             : #if FILE_IO_EXTRA_CHECK
    4219             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    4220             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    4221             : #endif
    4222             : 
    4223           0 :           returnPointer = &( ( (SgStructureModifier*)(SgStructureModifier::pools[memoryBlock]) ) [positionInPool]) ;
    4224             : 
    4225             : #if FILE_IO_EXTRA_CHECK
    4226           0 :           assert ( returnPointer != NULL ) ;
    4227             : #endif
    4228             :         }
    4229           0 :      return returnPointer ;
    4230             :    }
    4231             : 
    4232             : //############################################################################
    4233             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    4234             :  * pool size! We set for every valid object in the memory pool the freepointer
    4235             :  * to the global index and increase the global index afterwards. For all the 
    4236             :  * invalid objects (means address ranges within the memory pool that were not
    4237             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    4238             :  * distinguish valid from invalid objects! 
    4239             :  */
    4240             : unsigned long
    4241           5 : SgStructureModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    4242             :    {
    4243           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    4244           5 :      SgStructureModifier* pointer = NULL;
    4245           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    4246           5 :      std::vector < unsigned char* > :: const_iterator block;
    4247           5 :      for ( block = SgStructureModifier::pools.begin(); block != SgStructureModifier::pools.end() ; ++block )
    4248             :         {
    4249           0 :           pointer = (SgStructureModifier*)(*block);
    4250           0 :           for (unsigned i = 0; i < SgStructureModifier::pool_size; ++i )
    4251             :              {
    4252             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    4253             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    4254             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    4255             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    4256             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    4257             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    4258             :             // properly; so this will have to be checked next.
    4259             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    4260             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    4261           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    4262             :                   {
    4263           0 :                     pointer[i].set_freepointer((SgStructureModifier*)(globalIndex));
    4264           0 :                     globalIndex++;
    4265             :                   }
    4266             :                else
    4267             :                   {
    4268           0 :                     pointer[i].set_freepointer(NULL);
    4269             :                   }
    4270             :               }
    4271             :         }
    4272           5 :      return globalIndex;
    4273             :    }
    4274             : 
    4275             : //############################################################################
    4276             : // JH (01/14/2006)
    4277             : void
    4278           5 : SgStructureModifier::resetValidFreepointers( )
    4279             :    {
    4280           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    4281           5 :      SgStructureModifier* pointer = NULL;
    4282           5 :      std::vector < unsigned char* > :: const_iterator block;
    4283           5 :      SgStructureModifier* pointerOfLinkedList = NULL;
    4284           5 :      for ( block = SgStructureModifier::pools.begin(); block != SgStructureModifier::pools.end() ; ++block )
    4285             :         {
    4286           0 :           pointer = (SgStructureModifier*)(*block);
    4287           0 :           for (unsigned i = 0; i < SgStructureModifier::pool_size; ++i )
    4288             :              {
    4289             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    4290             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    4291             :             // memory blocks!.
    4292           0 :                if ( pointer[i].get_freepointer() != NULL )
    4293             :                   {
    4294           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    4295             :                   }
    4296             :                else
    4297             :                   {
    4298           0 :                     if ( pointerOfLinkedList == NULL )
    4299             :                        {
    4300           0 :                          SgStructureModifier::next_node = &(pointer[i]);
    4301             :                        }
    4302             :                     else
    4303             :                        {
    4304             :                       // printf ("In SgStructureModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    4305           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    4306             :                        }
    4307             :                     pointerOfLinkedList = &(pointer[i]);
    4308             :                   }
    4309             :               }
    4310             :         }
    4311             : 
    4312           5 :      if ( pointerOfLinkedList != NULL )
    4313             :         {
    4314             :        // printf ("In SgStructureModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    4315           0 :           pointerOfLinkedList->set_freepointer(NULL);
    4316             :        // DQ (6/6/2010): Temporary debugging...
    4317             :        //   ROSE_ASSERT(false);
    4318             :         }
    4319             : 
    4320           5 :      return ;
    4321             :    }
    4322             : 
    4323             : //############################################################################
    4324             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    4325             :  * within the memory pool and resets the freepointers, in order to achieve a 
    4326             :  * linked list, that has no jumps and starts at the beginning! This function 
    4327             :  * does not extend the memory pool, since we do not delete any memory blocks,
    4328             :  * but delete the valid objects.  
    4329             :  */
    4330             : void
    4331           0 : SgStructureModifier::clearMemoryPool( )
    4332             :    {
    4333             :   // printf ("Inside of SgStructureModifier::clearMemoryPool() \n");
    4334             : 
    4335           0 :      SgStructureModifier* pointer = NULL, *tempPointer = NULL;
    4336           0 :      std::vector < unsigned char* > :: const_iterator block;
    4337           0 :      if ( SgStructureModifier::pools.empty() == false )
    4338             :         {
    4339           0 :           block = SgStructureModifier::pools.begin() ;
    4340           0 :           SgStructureModifier::next_node = (SgStructureModifier*) (*block);
    4341             : 
    4342           0 :           while ( block != SgStructureModifier::pools.end() )
    4343             :              {
    4344           0 :                pointer = (SgStructureModifier*) (*block);
    4345           0 :                if ( tempPointer != NULL )
    4346             :                   {
    4347           0 :                     tempPointer->set_freepointer(pointer);
    4348             :                   }
    4349           0 :                for (unsigned i = 0; i < SgStructureModifier::pool_size - 1; ++i)
    4350             :                   {
    4351           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    4352             :                   }
    4353           0 :                 pointer[SgStructureModifier::pool_size-1].set_freepointer(NULL);
    4354           0 :                 tempPointer = &(pointer[SgStructureModifier::pool_size-1]);
    4355           0 :                 ++block;
    4356             :              }
    4357             :         }
    4358           0 :    }
    4359             : 
    4360           5 : void SgStructureModifier::deleteMemoryPool() {
    4361           5 :   for (auto p: SgStructureModifier::pools) {
    4362           0 :     ROSE_FREE(p);
    4363             :   }
    4364           5 :   SgStructureModifier::next_node = nullptr;
    4365           5 :   SgStructureModifier::pools.clear();
    4366           5 : }
    4367             : 
    4368             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    4369             : //                 reading multiple binary files to for a single AST.
    4370             : /////////// new version ////////////////////////////////
    4371             : //############################################################################
    4372             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    4373             : void
    4374           2 : SgStructureModifier::extendMemoryPoolForFileIO( )
    4375             :   {
    4376           2 :     size_t blockIndex = SgStructureModifier::pools.size();
    4377           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStructureModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStructureModifier);
    4378             : 
    4379           2 :     while ( (blockIndex * SgStructureModifier::pool_size) < newPoolSize)
    4380             :       {
    4381             : #if ROSE_ALLOC_TRACE
    4382             :         if (blockIndex > 0) {
    4383             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStructureModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStructureModifier) = %" PRIuPTR " SgStructureModifier::pool_size = %d \n",
    4384             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStructureModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStructureModifier),SgStructureModifier::pool_size);
    4385             :         }
    4386             : #endif
    4387             : 
    4388           0 :         SgStructureModifier * pointer = (SgStructureModifier*) ROSE_MALLOC ( SgStructureModifier::pool_size * sizeof(SgStructureModifier) );
    4389           0 :         assert( pointer != NULL );
    4390             : #if ROSE_ALLOC_MEMSET == 1
    4391             :         memset(pointer, 0x00, SgStructureModifier::pool_size * sizeof(SgStructureModifier));
    4392             : #elif ROSE_ALLOC_MEMSET == 2
    4393             :         memset(pointer, 0xCC, SgStructureModifier::pool_size * sizeof(SgStructureModifier));
    4394             : #endif
    4395           0 :         SgStructureModifier::pools.push_back( (unsigned char*)(pointer) );
    4396           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStructureModifier::pool_size * sizeof(SgStructureModifier), V_SgStructureModifier ) );
    4397             : 
    4398           0 :         if ( SgStructureModifier::next_node != NULL ) {
    4399           0 :           if ( blockIndex > 0 ) {
    4400           0 :             SgStructureModifier * blkptr = (SgStructureModifier*)(SgStructureModifier::pools[blockIndex-1]);
    4401           0 :             blkptr[ SgStructureModifier::pool_size - 1 ].set_freepointer(pointer);
    4402             :           }
    4403             :         } else {
    4404           0 :           SgStructureModifier::next_node = pointer;
    4405             :         }
    4406             : 
    4407           0 :         for (unsigned i = 0; i < SgStructureModifier::pool_size-1; ++i)
    4408             :            {
    4409           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    4410             :            }
    4411           0 :         pointer[ SgStructureModifier::pool_size -1 ].set_freepointer(NULL);
    4412             : 
    4413           0 :         blockIndex++;
    4414             :       }
    4415           2 :   }
    4416             : 
    4417             : //############################################################################
    4418             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    4419             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    4420             :  * not compressed. However, that stuff is not yet implemented! 
    4421             :  */
    4422             : unsigned long
    4423           0 : SgStructureModifier::getNumberOfLastValidPointer()
    4424             :    {
    4425           0 :       SgStructureModifier* testPointer = (SgStructureModifier*)(SgStructureModifier::pools.back());
    4426           0 :       unsigned long localIndex = SgStructureModifier::pool_size - 1;
    4427           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    4428             :          {
    4429           0 :            localIndex--;
    4430             :          }
    4431           0 :       return (localIndex + SgStructureModifier::pool_size * (SgStructureModifier::pools.size()-1));
    4432             :    }
    4433             : 
    4434             : //############################################################################
    4435             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    4436             :  * memory pool and initializes the data member in class SgStructureModifierStroageClass
    4437             :  * from its counterpart of SgStructureModifier. The return value is just for checking, 
    4438             :  * that the whole StorageClassArray is initialized!
    4439             :  */
    4440             : unsigned long
    4441           0 : SgStructureModifier::initializeStorageClassArray( SgStructureModifierStorageClass *storageArray )
    4442             :    {
    4443           0 :      unsigned long storageCounter = 0;
    4444           0 :      std::vector < unsigned char* > :: const_iterator block = SgStructureModifier::pools.begin();
    4445           0 :      SgStructureModifier* pointer = NULL;
    4446           0 :      while ( block != SgStructureModifier::pools.end() ) {
    4447           0 :           pointer = (SgStructureModifier*) (*block);
    4448           0 :           for ( unsigned i = 0; i < SgStructureModifier::pool_size; ++i ) {
    4449           0 :                if ( pointer->get_freepointer() != NULL ) {
    4450           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    4451           0 :                  storageArray++;
    4452           0 :                  storageCounter++;
    4453             :                }
    4454           0 :                pointer++;
    4455             :              }
    4456           0 :            block++;
    4457             :         }
    4458           0 :      return storageCounter;
    4459             :    }
    4460             : 
    4461             : /* #line 4462 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    4462             : 
    4463             : 
    4464             : 
    4465             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    4466             : 
    4467             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    4468             : 
    4469             : //############################################################################
    4470             : /* JH (02/02/2006) Constructor of the IR node SgTypeModifier that takes its 
    4471             :  * corresponding StorageClass as parameter
    4472             :  */
    4473       54713 : SgTypeModifier :: SgTypeModifier ( const SgTypeModifierStorageClass& storageSource )   : SgModifier (storageSource)
    4474             :    {
    4475             : 
    4476             : 
    4477             : /* #line 4478 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    4478             : 
    4479       54713 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    4480       54713 :      p_modifierVector = storageSource.storageOf_modifierVector.rebuildDataStoredInEasyStorageClass() ;
    4481       54713 :      p_upcModifier = SgUPC_AccessModifier ( storageSource.storageOf_upcModifier ) ;
    4482       54713 :      p_structureModifier = SgStructureModifier ( storageSource.storageOf_structureModifier ) ;
    4483       54713 :      p_constVolatileModifier = SgConstVolatileModifier ( storageSource.storageOf_constVolatileModifier ) ;
    4484       54713 :      p_elaboratedTypeModifier = SgElaboratedTypeModifier ( storageSource.storageOf_elaboratedTypeModifier ) ;
    4485       54713 :      p_gnu_extension_machine_mode = storageSource.storageOf_gnu_extension_machine_mode ;
    4486       54713 :      p_gnu_attribute_alignment = storageSource.storageOf_gnu_attribute_alignment ;
    4487       54713 :      p_gnu_attribute_sentinel = storageSource.storageOf_gnu_attribute_sentinel ;
    4488       54713 :      p_address_space_value = storageSource.storageOf_address_space_value ;
    4489       54713 :      p_vector_size = storageSource.storageOf_vector_size ;
    4490             : 
    4491             : 
    4492             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    4493             : 
    4494             : 
    4495       54713 :    }
    4496             : 
    4497             : //############################################################################
    4498             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    4499             :  * within the working AST. 
    4500             :  */
    4501           0 : SgTypeModifier * SgTypeModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    4502           0 :      SgTypeModifier* returnPointer = NULL;
    4503           0 :      if ( globalIndex != 0 )
    4504             :         {
    4505             : 
    4506             : #if FILE_IO_EXTRA_CHECK
    4507           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeModifier ) ) <= globalIndex ) ;
    4508           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeModifier + 1 ) ) );
    4509             : #endif
    4510           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeModifier )  
    4511           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeModifier );
    4512           0 :           unsigned long positionInPool = localIndex % SgTypeModifier::pool_size;
    4513           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeModifier::pool_size;
    4514             : 
    4515             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    4516             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    4517             : 
    4518           0 :           returnPointer = &( ( (SgTypeModifier*)(SgTypeModifier::pools[memoryBlock]) ) [positionInPool]) ;
    4519             : 
    4520           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    4521             :         }
    4522           0 :      return returnPointer ;
    4523             :    }
    4524             : 
    4525             : //############################################################################
    4526             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    4527             :   for the AST with the index astIndex
    4528             : */
    4529           0 : SgTypeModifier * SgTypeModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    4530           0 :      SgTypeModifier* returnPointer = NULL;
    4531           0 :      if ( globalIndex != 0 )
    4532             :         {
    4533             : 
    4534             : #if FILE_IO_EXTRA_CHECK
    4535           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeModifier ) ) <= globalIndex ) ;
    4536           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeModifier + 1 ) ) );
    4537             : #endif
    4538           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeModifier )
    4539           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeModifier );
    4540           0 :           unsigned long positionInPool = localIndex % SgTypeModifier::pool_size ;
    4541           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeModifier::pool_size ;
    4542             : 
    4543             : #if FILE_IO_EXTRA_CHECK
    4544             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    4545             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    4546             : #endif
    4547             : 
    4548           0 :           returnPointer = &( ( (SgTypeModifier*)(SgTypeModifier::pools[memoryBlock]) ) [positionInPool]) ;
    4549             : 
    4550             : #if FILE_IO_EXTRA_CHECK
    4551           0 :           assert ( returnPointer != NULL ) ;
    4552             : #endif
    4553             :         }
    4554           0 :      return returnPointer ;
    4555             :    }
    4556             : 
    4557             : //############################################################################
    4558             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    4559             :  * pool size! We set for every valid object in the memory pool the freepointer
    4560             :  * to the global index and increase the global index afterwards. For all the 
    4561             :  * invalid objects (means address ranges within the memory pool that were not
    4562             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    4563             :  * distinguish valid from invalid objects! 
    4564             :  */
    4565             : unsigned long
    4566           5 : SgTypeModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    4567             :    {
    4568           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    4569           5 :      SgTypeModifier* pointer = NULL;
    4570           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    4571           5 :      std::vector < unsigned char* > :: const_iterator block;
    4572           5 :      for ( block = SgTypeModifier::pools.begin(); block != SgTypeModifier::pools.end() ; ++block )
    4573             :         {
    4574           0 :           pointer = (SgTypeModifier*)(*block);
    4575           0 :           for (unsigned i = 0; i < SgTypeModifier::pool_size; ++i )
    4576             :              {
    4577             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    4578             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    4579             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    4580             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    4581             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    4582             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    4583             :             // properly; so this will have to be checked next.
    4584             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    4585             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    4586           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    4587             :                   {
    4588           0 :                     pointer[i].set_freepointer((SgTypeModifier*)(globalIndex));
    4589           0 :                     globalIndex++;
    4590             :                   }
    4591             :                else
    4592             :                   {
    4593           0 :                     pointer[i].set_freepointer(NULL);
    4594             :                   }
    4595             :               }
    4596             :         }
    4597           5 :      return globalIndex;
    4598             :    }
    4599             : 
    4600             : //############################################################################
    4601             : // JH (01/14/2006)
    4602             : void
    4603           5 : SgTypeModifier::resetValidFreepointers( )
    4604             :    {
    4605           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    4606           5 :      SgTypeModifier* pointer = NULL;
    4607           5 :      std::vector < unsigned char* > :: const_iterator block;
    4608           5 :      SgTypeModifier* pointerOfLinkedList = NULL;
    4609           5 :      for ( block = SgTypeModifier::pools.begin(); block != SgTypeModifier::pools.end() ; ++block )
    4610             :         {
    4611           0 :           pointer = (SgTypeModifier*)(*block);
    4612           0 :           for (unsigned i = 0; i < SgTypeModifier::pool_size; ++i )
    4613             :              {
    4614             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    4615             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    4616             :             // memory blocks!.
    4617           0 :                if ( pointer[i].get_freepointer() != NULL )
    4618             :                   {
    4619           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    4620             :                   }
    4621             :                else
    4622             :                   {
    4623           0 :                     if ( pointerOfLinkedList == NULL )
    4624             :                        {
    4625           0 :                          SgTypeModifier::next_node = &(pointer[i]);
    4626             :                        }
    4627             :                     else
    4628             :                        {
    4629             :                       // printf ("In SgTypeModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    4630           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    4631             :                        }
    4632             :                     pointerOfLinkedList = &(pointer[i]);
    4633             :                   }
    4634             :               }
    4635             :         }
    4636             : 
    4637           5 :      if ( pointerOfLinkedList != NULL )
    4638             :         {
    4639             :        // printf ("In SgTypeModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    4640           0 :           pointerOfLinkedList->set_freepointer(NULL);
    4641             :        // DQ (6/6/2010): Temporary debugging...
    4642             :        //   ROSE_ASSERT(false);
    4643             :         }
    4644             : 
    4645           5 :      return ;
    4646             :    }
    4647             : 
    4648             : //############################################################################
    4649             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    4650             :  * within the memory pool and resets the freepointers, in order to achieve a 
    4651             :  * linked list, that has no jumps and starts at the beginning! This function 
    4652             :  * does not extend the memory pool, since we do not delete any memory blocks,
    4653             :  * but delete the valid objects.  
    4654             :  */
    4655             : void
    4656           0 : SgTypeModifier::clearMemoryPool( )
    4657             :    {
    4658             :   // printf ("Inside of SgTypeModifier::clearMemoryPool() \n");
    4659             : 
    4660           0 :      SgTypeModifier* pointer = NULL, *tempPointer = NULL;
    4661           0 :      std::vector < unsigned char* > :: const_iterator block;
    4662           0 :      if ( SgTypeModifier::pools.empty() == false )
    4663             :         {
    4664           0 :           block = SgTypeModifier::pools.begin() ;
    4665           0 :           SgTypeModifier::next_node = (SgTypeModifier*) (*block);
    4666             : 
    4667           0 :           while ( block != SgTypeModifier::pools.end() )
    4668             :              {
    4669           0 :                pointer = (SgTypeModifier*) (*block);
    4670           0 :                if ( tempPointer != NULL )
    4671             :                   {
    4672           0 :                     tempPointer->set_freepointer(pointer);
    4673             :                   }
    4674           0 :                for (unsigned i = 0; i < SgTypeModifier::pool_size - 1; ++i)
    4675             :                   {
    4676           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    4677             :                   }
    4678           0 :                 pointer[SgTypeModifier::pool_size-1].set_freepointer(NULL);
    4679           0 :                 tempPointer = &(pointer[SgTypeModifier::pool_size-1]);
    4680           0 :                 ++block;
    4681             :              }
    4682             :         }
    4683           0 :    }
    4684             : 
    4685           5 : void SgTypeModifier::deleteMemoryPool() {
    4686           5 :   for (auto p: SgTypeModifier::pools) {
    4687           0 :     ROSE_FREE(p);
    4688             :   }
    4689           5 :   SgTypeModifier::next_node = nullptr;
    4690           5 :   SgTypeModifier::pools.clear();
    4691           5 : }
    4692             : 
    4693             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    4694             : //                 reading multiple binary files to for a single AST.
    4695             : /////////// new version ////////////////////////////////
    4696             : //############################################################################
    4697             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    4698             : void
    4699           2 : SgTypeModifier::extendMemoryPoolForFileIO( )
    4700             :   {
    4701           2 :     size_t blockIndex = SgTypeModifier::pools.size();
    4702           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeModifier);
    4703             : 
    4704           2 :     while ( (blockIndex * SgTypeModifier::pool_size) < newPoolSize)
    4705             :       {
    4706             : #if ROSE_ALLOC_TRACE
    4707             :         if (blockIndex > 0) {
    4708             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeModifier) = %" PRIuPTR " SgTypeModifier::pool_size = %d \n",
    4709             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeModifier),SgTypeModifier::pool_size);
    4710             :         }
    4711             : #endif
    4712             : 
    4713           0 :         SgTypeModifier * pointer = (SgTypeModifier*) ROSE_MALLOC ( SgTypeModifier::pool_size * sizeof(SgTypeModifier) );
    4714           0 :         assert( pointer != NULL );
    4715             : #if ROSE_ALLOC_MEMSET == 1
    4716             :         memset(pointer, 0x00, SgTypeModifier::pool_size * sizeof(SgTypeModifier));
    4717             : #elif ROSE_ALLOC_MEMSET == 2
    4718             :         memset(pointer, 0xCC, SgTypeModifier::pool_size * sizeof(SgTypeModifier));
    4719             : #endif
    4720           0 :         SgTypeModifier::pools.push_back( (unsigned char*)(pointer) );
    4721           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeModifier::pool_size * sizeof(SgTypeModifier), V_SgTypeModifier ) );
    4722             : 
    4723           0 :         if ( SgTypeModifier::next_node != NULL ) {
    4724           0 :           if ( blockIndex > 0 ) {
    4725           0 :             SgTypeModifier * blkptr = (SgTypeModifier*)(SgTypeModifier::pools[blockIndex-1]);
    4726           0 :             blkptr[ SgTypeModifier::pool_size - 1 ].set_freepointer(pointer);
    4727             :           }
    4728             :         } else {
    4729           0 :           SgTypeModifier::next_node = pointer;
    4730             :         }
    4731             : 
    4732           0 :         for (unsigned i = 0; i < SgTypeModifier::pool_size-1; ++i)
    4733             :            {
    4734           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    4735             :            }
    4736           0 :         pointer[ SgTypeModifier::pool_size -1 ].set_freepointer(NULL);
    4737             : 
    4738           0 :         blockIndex++;
    4739             :       }
    4740           2 :   }
    4741             : 
    4742             : //############################################################################
    4743             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    4744             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    4745             :  * not compressed. However, that stuff is not yet implemented! 
    4746             :  */
    4747             : unsigned long
    4748           0 : SgTypeModifier::getNumberOfLastValidPointer()
    4749             :    {
    4750           0 :       SgTypeModifier* testPointer = (SgTypeModifier*)(SgTypeModifier::pools.back());
    4751           0 :       unsigned long localIndex = SgTypeModifier::pool_size - 1;
    4752           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    4753             :          {
    4754           0 :            localIndex--;
    4755             :          }
    4756           0 :       return (localIndex + SgTypeModifier::pool_size * (SgTypeModifier::pools.size()-1));
    4757             :    }
    4758             : 
    4759             : //############################################################################
    4760             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    4761             :  * memory pool and initializes the data member in class SgTypeModifierStroageClass
    4762             :  * from its counterpart of SgTypeModifier. The return value is just for checking, 
    4763             :  * that the whole StorageClassArray is initialized!
    4764             :  */
    4765             : unsigned long
    4766           0 : SgTypeModifier::initializeStorageClassArray( SgTypeModifierStorageClass *storageArray )
    4767             :    {
    4768           0 :      unsigned long storageCounter = 0;
    4769           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeModifier::pools.begin();
    4770           0 :      SgTypeModifier* pointer = NULL;
    4771           0 :      while ( block != SgTypeModifier::pools.end() ) {
    4772           0 :           pointer = (SgTypeModifier*) (*block);
    4773           0 :           for ( unsigned i = 0; i < SgTypeModifier::pool_size; ++i ) {
    4774           0 :                if ( pointer->get_freepointer() != NULL ) {
    4775           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    4776           0 :                  storageArray++;
    4777           0 :                  storageCounter++;
    4778             :                }
    4779           0 :                pointer++;
    4780             :              }
    4781           0 :            block++;
    4782             :         }
    4783           0 :      return storageCounter;
    4784             :    }
    4785             : 
    4786             : /* #line 4787 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    4787             : 
    4788             : 
    4789             : 
    4790             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    4791             : 
    4792             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    4793             : 
    4794             : //############################################################################
    4795             : /* JH (02/02/2006) Constructor of the IR node SgDeclarationModifier that takes its 
    4796             :  * corresponding StorageClass as parameter
    4797             :  */
    4798       53837 : SgDeclarationModifier :: SgDeclarationModifier ( const SgDeclarationModifierStorageClass& storageSource )   : SgModifier (storageSource)
    4799             :    {
    4800             : 
    4801             : 
    4802             : /* #line 4803 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    4803             : 
    4804       53837 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    4805       53837 :      p_modifierVector = storageSource.storageOf_modifierVector.rebuildDataStoredInEasyStorageClass() ;
    4806       53837 :      p_typeModifier = SgTypeModifier ( storageSource.storageOf_typeModifier ) ;
    4807       53837 :      p_accessModifier = SgAccessModifier ( storageSource.storageOf_accessModifier ) ;
    4808       53837 :      p_storageModifier = SgStorageModifier ( storageSource.storageOf_storageModifier ) ;
    4809       53837 :      p_gnu_attribute_section_name = storageSource.storageOf_gnu_attribute_section_name.rebuildDataStoredInEasyStorageClass() ;
    4810       53837 :      p_gnu_attribute_visability = storageSource.storageOf_gnu_attribute_visability ;
    4811       53837 :      p_microsoft_uuid_string = storageSource.storageOf_microsoft_uuid_string.rebuildDataStoredInEasyStorageClass() ;
    4812       53837 :      p_microsoft_property_get_function_name = storageSource.storageOf_microsoft_property_get_function_name.rebuildDataStoredInEasyStorageClass() ;
    4813       53837 :      p_microsoft_property_put_function_name = storageSource.storageOf_microsoft_property_put_function_name.rebuildDataStoredInEasyStorageClass() ;
    4814             : 
    4815             : 
    4816             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    4817             : 
    4818             : 
    4819       53837 :    }
    4820             : 
    4821             : //############################################################################
    4822             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    4823             :  * within the working AST. 
    4824             :  */
    4825           0 : SgDeclarationModifier * SgDeclarationModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    4826           0 :      SgDeclarationModifier* returnPointer = NULL;
    4827           0 :      if ( globalIndex != 0 )
    4828             :         {
    4829             : 
    4830             : #if FILE_IO_EXTRA_CHECK
    4831           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDeclarationModifier ) ) <= globalIndex ) ;
    4832           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeclarationModifier + 1 ) ) );
    4833             : #endif
    4834           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeclarationModifier )  
    4835           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDeclarationModifier );
    4836           0 :           unsigned long positionInPool = localIndex % SgDeclarationModifier::pool_size;
    4837           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeclarationModifier::pool_size;
    4838             : 
    4839             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    4840             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    4841             : 
    4842           0 :           returnPointer = &( ( (SgDeclarationModifier*)(SgDeclarationModifier::pools[memoryBlock]) ) [positionInPool]) ;
    4843             : 
    4844           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    4845             :         }
    4846           0 :      return returnPointer ;
    4847             :    }
    4848             : 
    4849             : //############################################################################
    4850             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    4851             :   for the AST with the index astIndex
    4852             : */
    4853           0 : SgDeclarationModifier * SgDeclarationModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    4854           0 :      SgDeclarationModifier* returnPointer = NULL;
    4855           0 :      if ( globalIndex != 0 )
    4856             :         {
    4857             : 
    4858             : #if FILE_IO_EXTRA_CHECK
    4859           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDeclarationModifier ) ) <= globalIndex ) ;
    4860           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeclarationModifier + 1 ) ) );
    4861             : #endif
    4862           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeclarationModifier )
    4863           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDeclarationModifier );
    4864           0 :           unsigned long positionInPool = localIndex % SgDeclarationModifier::pool_size ;
    4865           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeclarationModifier::pool_size ;
    4866             : 
    4867             : #if FILE_IO_EXTRA_CHECK
    4868             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    4869             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    4870             : #endif
    4871             : 
    4872           0 :           returnPointer = &( ( (SgDeclarationModifier*)(SgDeclarationModifier::pools[memoryBlock]) ) [positionInPool]) ;
    4873             : 
    4874             : #if FILE_IO_EXTRA_CHECK
    4875           0 :           assert ( returnPointer != NULL ) ;
    4876             : #endif
    4877             :         }
    4878           0 :      return returnPointer ;
    4879             :    }
    4880             : 
    4881             : //############################################################################
    4882             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    4883             :  * pool size! We set for every valid object in the memory pool the freepointer
    4884             :  * to the global index and increase the global index afterwards. For all the 
    4885             :  * invalid objects (means address ranges within the memory pool that were not
    4886             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    4887             :  * distinguish valid from invalid objects! 
    4888             :  */
    4889             : unsigned long
    4890           5 : SgDeclarationModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    4891             :    {
    4892           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    4893           5 :      SgDeclarationModifier* pointer = NULL;
    4894           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    4895           5 :      std::vector < unsigned char* > :: const_iterator block;
    4896           5 :      for ( block = SgDeclarationModifier::pools.begin(); block != SgDeclarationModifier::pools.end() ; ++block )
    4897             :         {
    4898           0 :           pointer = (SgDeclarationModifier*)(*block);
    4899           0 :           for (unsigned i = 0; i < SgDeclarationModifier::pool_size; ++i )
    4900             :              {
    4901             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    4902             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    4903             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    4904             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    4905             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    4906             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    4907             :             // properly; so this will have to be checked next.
    4908             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    4909             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    4910           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    4911             :                   {
    4912           0 :                     pointer[i].set_freepointer((SgDeclarationModifier*)(globalIndex));
    4913           0 :                     globalIndex++;
    4914             :                   }
    4915             :                else
    4916             :                   {
    4917           0 :                     pointer[i].set_freepointer(NULL);
    4918             :                   }
    4919             :               }
    4920             :         }
    4921           5 :      return globalIndex;
    4922             :    }
    4923             : 
    4924             : //############################################################################
    4925             : // JH (01/14/2006)
    4926             : void
    4927           5 : SgDeclarationModifier::resetValidFreepointers( )
    4928             :    {
    4929           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    4930           5 :      SgDeclarationModifier* pointer = NULL;
    4931           5 :      std::vector < unsigned char* > :: const_iterator block;
    4932           5 :      SgDeclarationModifier* pointerOfLinkedList = NULL;
    4933           5 :      for ( block = SgDeclarationModifier::pools.begin(); block != SgDeclarationModifier::pools.end() ; ++block )
    4934             :         {
    4935           0 :           pointer = (SgDeclarationModifier*)(*block);
    4936           0 :           for (unsigned i = 0; i < SgDeclarationModifier::pool_size; ++i )
    4937             :              {
    4938             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    4939             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    4940             :             // memory blocks!.
    4941           0 :                if ( pointer[i].get_freepointer() != NULL )
    4942             :                   {
    4943           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    4944             :                   }
    4945             :                else
    4946             :                   {
    4947           0 :                     if ( pointerOfLinkedList == NULL )
    4948             :                        {
    4949           0 :                          SgDeclarationModifier::next_node = &(pointer[i]);
    4950             :                        }
    4951             :                     else
    4952             :                        {
    4953             :                       // printf ("In SgDeclarationModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    4954           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    4955             :                        }
    4956             :                     pointerOfLinkedList = &(pointer[i]);
    4957             :                   }
    4958             :               }
    4959             :         }
    4960             : 
    4961           5 :      if ( pointerOfLinkedList != NULL )
    4962             :         {
    4963             :        // printf ("In SgDeclarationModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    4964           0 :           pointerOfLinkedList->set_freepointer(NULL);
    4965             :        // DQ (6/6/2010): Temporary debugging...
    4966             :        //   ROSE_ASSERT(false);
    4967             :         }
    4968             : 
    4969           5 :      return ;
    4970             :    }
    4971             : 
    4972             : //############################################################################
    4973             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    4974             :  * within the memory pool and resets the freepointers, in order to achieve a 
    4975             :  * linked list, that has no jumps and starts at the beginning! This function 
    4976             :  * does not extend the memory pool, since we do not delete any memory blocks,
    4977             :  * but delete the valid objects.  
    4978             :  */
    4979             : void
    4980           0 : SgDeclarationModifier::clearMemoryPool( )
    4981             :    {
    4982             :   // printf ("Inside of SgDeclarationModifier::clearMemoryPool() \n");
    4983             : 
    4984           0 :      SgDeclarationModifier* pointer = NULL, *tempPointer = NULL;
    4985           0 :      std::vector < unsigned char* > :: const_iterator block;
    4986           0 :      if ( SgDeclarationModifier::pools.empty() == false )
    4987             :         {
    4988           0 :           block = SgDeclarationModifier::pools.begin() ;
    4989           0 :           SgDeclarationModifier::next_node = (SgDeclarationModifier*) (*block);
    4990             : 
    4991           0 :           while ( block != SgDeclarationModifier::pools.end() )
    4992             :              {
    4993           0 :                pointer = (SgDeclarationModifier*) (*block);
    4994           0 :                if ( tempPointer != NULL )
    4995             :                   {
    4996           0 :                     tempPointer->set_freepointer(pointer);
    4997             :                   }
    4998           0 :                for (unsigned i = 0; i < SgDeclarationModifier::pool_size - 1; ++i)
    4999             :                   {
    5000           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    5001             :                   }
    5002           0 :                 pointer[SgDeclarationModifier::pool_size-1].set_freepointer(NULL);
    5003           0 :                 tempPointer = &(pointer[SgDeclarationModifier::pool_size-1]);
    5004           0 :                 ++block;
    5005             :              }
    5006             :         }
    5007           0 :    }
    5008             : 
    5009           5 : void SgDeclarationModifier::deleteMemoryPool() {
    5010           5 :   for (auto p: SgDeclarationModifier::pools) {
    5011           0 :     ROSE_FREE(p);
    5012             :   }
    5013           5 :   SgDeclarationModifier::next_node = nullptr;
    5014           5 :   SgDeclarationModifier::pools.clear();
    5015           5 : }
    5016             : 
    5017             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    5018             : //                 reading multiple binary files to for a single AST.
    5019             : /////////// new version ////////////////////////////////
    5020             : //############################################################################
    5021             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    5022             : void
    5023           2 : SgDeclarationModifier::extendMemoryPoolForFileIO( )
    5024             :   {
    5025           2 :     size_t blockIndex = SgDeclarationModifier::pools.size();
    5026           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationModifier);
    5027             : 
    5028           2 :     while ( (blockIndex * SgDeclarationModifier::pool_size) < newPoolSize)
    5029             :       {
    5030             : #if ROSE_ALLOC_TRACE
    5031             :         if (blockIndex > 0) {
    5032             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationModifier) = %" PRIuPTR " SgDeclarationModifier::pool_size = %d \n",
    5033             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationModifier),SgDeclarationModifier::pool_size);
    5034             :         }
    5035             : #endif
    5036             : 
    5037           0 :         SgDeclarationModifier * pointer = (SgDeclarationModifier*) ROSE_MALLOC ( SgDeclarationModifier::pool_size * sizeof(SgDeclarationModifier) );
    5038           0 :         assert( pointer != NULL );
    5039             : #if ROSE_ALLOC_MEMSET == 1
    5040             :         memset(pointer, 0x00, SgDeclarationModifier::pool_size * sizeof(SgDeclarationModifier));
    5041             : #elif ROSE_ALLOC_MEMSET == 2
    5042             :         memset(pointer, 0xCC, SgDeclarationModifier::pool_size * sizeof(SgDeclarationModifier));
    5043             : #endif
    5044           0 :         SgDeclarationModifier::pools.push_back( (unsigned char*)(pointer) );
    5045           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDeclarationModifier::pool_size * sizeof(SgDeclarationModifier), V_SgDeclarationModifier ) );
    5046             : 
    5047           0 :         if ( SgDeclarationModifier::next_node != NULL ) {
    5048           0 :           if ( blockIndex > 0 ) {
    5049           0 :             SgDeclarationModifier * blkptr = (SgDeclarationModifier*)(SgDeclarationModifier::pools[blockIndex-1]);
    5050           0 :             blkptr[ SgDeclarationModifier::pool_size - 1 ].set_freepointer(pointer);
    5051             :           }
    5052             :         } else {
    5053           0 :           SgDeclarationModifier::next_node = pointer;
    5054             :         }
    5055             : 
    5056           0 :         for (unsigned i = 0; i < SgDeclarationModifier::pool_size-1; ++i)
    5057             :            {
    5058           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    5059             :            }
    5060           0 :         pointer[ SgDeclarationModifier::pool_size -1 ].set_freepointer(NULL);
    5061             : 
    5062           0 :         blockIndex++;
    5063             :       }
    5064           2 :   }
    5065             : 
    5066             : //############################################################################
    5067             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    5068             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    5069             :  * not compressed. However, that stuff is not yet implemented! 
    5070             :  */
    5071             : unsigned long
    5072           0 : SgDeclarationModifier::getNumberOfLastValidPointer()
    5073             :    {
    5074           0 :       SgDeclarationModifier* testPointer = (SgDeclarationModifier*)(SgDeclarationModifier::pools.back());
    5075           0 :       unsigned long localIndex = SgDeclarationModifier::pool_size - 1;
    5076           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    5077             :          {
    5078           0 :            localIndex--;
    5079             :          }
    5080           0 :       return (localIndex + SgDeclarationModifier::pool_size * (SgDeclarationModifier::pools.size()-1));
    5081             :    }
    5082             : 
    5083             : //############################################################################
    5084             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    5085             :  * memory pool and initializes the data member in class SgDeclarationModifierStroageClass
    5086             :  * from its counterpart of SgDeclarationModifier. The return value is just for checking, 
    5087             :  * that the whole StorageClassArray is initialized!
    5088             :  */
    5089             : unsigned long
    5090           0 : SgDeclarationModifier::initializeStorageClassArray( SgDeclarationModifierStorageClass *storageArray )
    5091             :    {
    5092           0 :      unsigned long storageCounter = 0;
    5093           0 :      std::vector < unsigned char* > :: const_iterator block = SgDeclarationModifier::pools.begin();
    5094           0 :      SgDeclarationModifier* pointer = NULL;
    5095           0 :      while ( block != SgDeclarationModifier::pools.end() ) {
    5096           0 :           pointer = (SgDeclarationModifier*) (*block);
    5097           0 :           for ( unsigned i = 0; i < SgDeclarationModifier::pool_size; ++i ) {
    5098           0 :                if ( pointer->get_freepointer() != NULL ) {
    5099           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    5100           0 :                  storageArray++;
    5101           0 :                  storageCounter++;
    5102             :                }
    5103           0 :                pointer++;
    5104             :              }
    5105           0 :            block++;
    5106             :         }
    5107           0 :      return storageCounter;
    5108             :    }
    5109             : 
    5110             : /* #line 5111 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    5111             : 
    5112             : 
    5113             : 
    5114             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    5115             : 
    5116             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    5117             : 
    5118             : //############################################################################
    5119             : /* JH (02/02/2006) Constructor of the IR node SgOpenclAccessModeModifier that takes its 
    5120             :  * corresponding StorageClass as parameter
    5121             :  */
    5122           0 : SgOpenclAccessModeModifier :: SgOpenclAccessModeModifier ( const SgOpenclAccessModeModifierStorageClass& storageSource )   : SgModifier (storageSource)
    5123             :    {
    5124             : 
    5125             : 
    5126             : /* #line 5127 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    5127             : 
    5128           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    5129           0 :      p_modifier = storageSource.storageOf_modifier ;
    5130             : 
    5131             : 
    5132             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    5133             : 
    5134             : 
    5135           0 :    }
    5136             : 
    5137             : //############################################################################
    5138             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    5139             :  * within the working AST. 
    5140             :  */
    5141           0 : SgOpenclAccessModeModifier * SgOpenclAccessModeModifier::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    5142           0 :      SgOpenclAccessModeModifier* returnPointer = NULL;
    5143           0 :      if ( globalIndex != 0 )
    5144             :         {
    5145             : 
    5146             : #if FILE_IO_EXTRA_CHECK
    5147           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOpenclAccessModeModifier ) ) <= globalIndex ) ;
    5148           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOpenclAccessModeModifier + 1 ) ) );
    5149             : #endif
    5150           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOpenclAccessModeModifier )  
    5151           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOpenclAccessModeModifier );
    5152           0 :           unsigned long positionInPool = localIndex % SgOpenclAccessModeModifier::pool_size;
    5153           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOpenclAccessModeModifier::pool_size;
    5154             : 
    5155             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    5156             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    5157             : 
    5158           0 :           returnPointer = &( ( (SgOpenclAccessModeModifier*)(SgOpenclAccessModeModifier::pools[memoryBlock]) ) [positionInPool]) ;
    5159             : 
    5160           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    5161             :         }
    5162           0 :      return returnPointer ;
    5163             :    }
    5164             : 
    5165             : //############################################################################
    5166             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    5167             :   for the AST with the index astIndex
    5168             : */
    5169           0 : SgOpenclAccessModeModifier * SgOpenclAccessModeModifier::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    5170           0 :      SgOpenclAccessModeModifier* returnPointer = NULL;
    5171           0 :      if ( globalIndex != 0 )
    5172             :         {
    5173             : 
    5174             : #if FILE_IO_EXTRA_CHECK
    5175           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOpenclAccessModeModifier ) ) <= globalIndex ) ;
    5176           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOpenclAccessModeModifier + 1 ) ) );
    5177             : #endif
    5178           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOpenclAccessModeModifier )
    5179           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOpenclAccessModeModifier );
    5180           0 :           unsigned long positionInPool = localIndex % SgOpenclAccessModeModifier::pool_size ;
    5181           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOpenclAccessModeModifier::pool_size ;
    5182             : 
    5183             : #if FILE_IO_EXTRA_CHECK
    5184             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    5185             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    5186             : #endif
    5187             : 
    5188           0 :           returnPointer = &( ( (SgOpenclAccessModeModifier*)(SgOpenclAccessModeModifier::pools[memoryBlock]) ) [positionInPool]) ;
    5189             : 
    5190             : #if FILE_IO_EXTRA_CHECK
    5191           0 :           assert ( returnPointer != NULL ) ;
    5192             : #endif
    5193             :         }
    5194           0 :      return returnPointer ;
    5195             :    }
    5196             : 
    5197             : //############################################################################
    5198             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    5199             :  * pool size! We set for every valid object in the memory pool the freepointer
    5200             :  * to the global index and increase the global index afterwards. For all the 
    5201             :  * invalid objects (means address ranges within the memory pool that were not
    5202             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    5203             :  * distinguish valid from invalid objects! 
    5204             :  */
    5205             : unsigned long
    5206           5 : SgOpenclAccessModeModifier::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    5207             :    {
    5208           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    5209           5 :      SgOpenclAccessModeModifier* pointer = NULL;
    5210           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    5211           5 :      std::vector < unsigned char* > :: const_iterator block;
    5212           5 :      for ( block = SgOpenclAccessModeModifier::pools.begin(); block != SgOpenclAccessModeModifier::pools.end() ; ++block )
    5213             :         {
    5214           0 :           pointer = (SgOpenclAccessModeModifier*)(*block);
    5215           0 :           for (unsigned i = 0; i < SgOpenclAccessModeModifier::pool_size; ++i )
    5216             :              {
    5217             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    5218             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    5219             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    5220             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    5221             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    5222             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    5223             :             // properly; so this will have to be checked next.
    5224             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    5225             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    5226           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    5227             :                   {
    5228           0 :                     pointer[i].set_freepointer((SgOpenclAccessModeModifier*)(globalIndex));
    5229           0 :                     globalIndex++;
    5230             :                   }
    5231             :                else
    5232             :                   {
    5233           0 :                     pointer[i].set_freepointer(NULL);
    5234             :                   }
    5235             :               }
    5236             :         }
    5237           5 :      return globalIndex;
    5238             :    }
    5239             : 
    5240             : //############################################################################
    5241             : // JH (01/14/2006)
    5242             : void
    5243           5 : SgOpenclAccessModeModifier::resetValidFreepointers( )
    5244             :    {
    5245           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    5246           5 :      SgOpenclAccessModeModifier* pointer = NULL;
    5247           5 :      std::vector < unsigned char* > :: const_iterator block;
    5248           5 :      SgOpenclAccessModeModifier* pointerOfLinkedList = NULL;
    5249           5 :      for ( block = SgOpenclAccessModeModifier::pools.begin(); block != SgOpenclAccessModeModifier::pools.end() ; ++block )
    5250             :         {
    5251           0 :           pointer = (SgOpenclAccessModeModifier*)(*block);
    5252           0 :           for (unsigned i = 0; i < SgOpenclAccessModeModifier::pool_size; ++i )
    5253             :              {
    5254             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    5255             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    5256             :             // memory blocks!.
    5257           0 :                if ( pointer[i].get_freepointer() != NULL )
    5258             :                   {
    5259           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    5260             :                   }
    5261             :                else
    5262             :                   {
    5263           0 :                     if ( pointerOfLinkedList == NULL )
    5264             :                        {
    5265           0 :                          SgOpenclAccessModeModifier::next_node = &(pointer[i]);
    5266             :                        }
    5267             :                     else
    5268             :                        {
    5269             :                       // printf ("In SgOpenclAccessModeModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    5270           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    5271             :                        }
    5272             :                     pointerOfLinkedList = &(pointer[i]);
    5273             :                   }
    5274             :               }
    5275             :         }
    5276             : 
    5277           5 :      if ( pointerOfLinkedList != NULL )
    5278             :         {
    5279             :        // printf ("In SgOpenclAccessModeModifier::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    5280           0 :           pointerOfLinkedList->set_freepointer(NULL);
    5281             :        // DQ (6/6/2010): Temporary debugging...
    5282             :        //   ROSE_ASSERT(false);
    5283             :         }
    5284             : 
    5285           5 :      return ;
    5286             :    }
    5287             : 
    5288             : //############################################################################
    5289             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    5290             :  * within the memory pool and resets the freepointers, in order to achieve a 
    5291             :  * linked list, that has no jumps and starts at the beginning! This function 
    5292             :  * does not extend the memory pool, since we do not delete any memory blocks,
    5293             :  * but delete the valid objects.  
    5294             :  */
    5295             : void
    5296           0 : SgOpenclAccessModeModifier::clearMemoryPool( )
    5297             :    {
    5298             :   // printf ("Inside of SgOpenclAccessModeModifier::clearMemoryPool() \n");
    5299             : 
    5300           0 :      SgOpenclAccessModeModifier* pointer = NULL, *tempPointer = NULL;
    5301           0 :      std::vector < unsigned char* > :: const_iterator block;
    5302           0 :      if ( SgOpenclAccessModeModifier::pools.empty() == false )
    5303             :         {
    5304           0 :           block = SgOpenclAccessModeModifier::pools.begin() ;
    5305           0 :           SgOpenclAccessModeModifier::next_node = (SgOpenclAccessModeModifier*) (*block);
    5306             : 
    5307           0 :           while ( block != SgOpenclAccessModeModifier::pools.end() )
    5308             :              {
    5309           0 :                pointer = (SgOpenclAccessModeModifier*) (*block);
    5310           0 :                if ( tempPointer != NULL )
    5311             :                   {
    5312           0 :                     tempPointer->set_freepointer(pointer);
    5313             :                   }
    5314           0 :                for (unsigned i = 0; i < SgOpenclAccessModeModifier::pool_size - 1; ++i)
    5315             :                   {
    5316           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    5317             :                   }
    5318           0 :                 pointer[SgOpenclAccessModeModifier::pool_size-1].set_freepointer(NULL);
    5319           0 :                 tempPointer = &(pointer[SgOpenclAccessModeModifier::pool_size-1]);
    5320           0 :                 ++block;
    5321             :              }
    5322             :         }
    5323           0 :    }
    5324             : 
    5325           5 : void SgOpenclAccessModeModifier::deleteMemoryPool() {
    5326           5 :   for (auto p: SgOpenclAccessModeModifier::pools) {
    5327           0 :     ROSE_FREE(p);
    5328             :   }
    5329           5 :   SgOpenclAccessModeModifier::next_node = nullptr;
    5330           5 :   SgOpenclAccessModeModifier::pools.clear();
    5331           5 : }
    5332             : 
    5333             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    5334             : //                 reading multiple binary files to for a single AST.
    5335             : /////////// new version ////////////////////////////////
    5336             : //############################################################################
    5337             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    5338             : void
    5339           2 : SgOpenclAccessModeModifier::extendMemoryPoolForFileIO( )
    5340             :   {
    5341           2 :     size_t blockIndex = SgOpenclAccessModeModifier::pools.size();
    5342           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOpenclAccessModeModifier) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOpenclAccessModeModifier);
    5343             : 
    5344           2 :     while ( (blockIndex * SgOpenclAccessModeModifier::pool_size) < newPoolSize)
    5345             :       {
    5346             : #if ROSE_ALLOC_TRACE
    5347             :         if (blockIndex > 0) {
    5348             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOpenclAccessModeModifier) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOpenclAccessModeModifier) = %" PRIuPTR " SgOpenclAccessModeModifier::pool_size = %d \n",
    5349             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOpenclAccessModeModifier),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOpenclAccessModeModifier),SgOpenclAccessModeModifier::pool_size);
    5350             :         }
    5351             : #endif
    5352             : 
    5353           0 :         SgOpenclAccessModeModifier * pointer = (SgOpenclAccessModeModifier*) ROSE_MALLOC ( SgOpenclAccessModeModifier::pool_size * sizeof(SgOpenclAccessModeModifier) );
    5354           0 :         assert( pointer != NULL );
    5355             : #if ROSE_ALLOC_MEMSET == 1
    5356             :         memset(pointer, 0x00, SgOpenclAccessModeModifier::pool_size * sizeof(SgOpenclAccessModeModifier));
    5357             : #elif ROSE_ALLOC_MEMSET == 2
    5358             :         memset(pointer, 0xCC, SgOpenclAccessModeModifier::pool_size * sizeof(SgOpenclAccessModeModifier));
    5359             : #endif
    5360           0 :         SgOpenclAccessModeModifier::pools.push_back( (unsigned char*)(pointer) );
    5361           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOpenclAccessModeModifier::pool_size * sizeof(SgOpenclAccessModeModifier), V_SgOpenclAccessModeModifier ) );
    5362             : 
    5363           0 :         if ( SgOpenclAccessModeModifier::next_node != NULL ) {
    5364           0 :           if ( blockIndex > 0 ) {
    5365           0 :             SgOpenclAccessModeModifier * blkptr = (SgOpenclAccessModeModifier*)(SgOpenclAccessModeModifier::pools[blockIndex-1]);
    5366           0 :             blkptr[ SgOpenclAccessModeModifier::pool_size - 1 ].set_freepointer(pointer);
    5367             :           }
    5368             :         } else {
    5369           0 :           SgOpenclAccessModeModifier::next_node = pointer;
    5370             :         }
    5371             : 
    5372           0 :         for (unsigned i = 0; i < SgOpenclAccessModeModifier::pool_size-1; ++i)
    5373             :            {
    5374           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    5375             :            }
    5376           0 :         pointer[ SgOpenclAccessModeModifier::pool_size -1 ].set_freepointer(NULL);
    5377             : 
    5378           0 :         blockIndex++;
    5379             :       }
    5380           2 :   }
    5381             : 
    5382             : //############################################################################
    5383             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    5384             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    5385             :  * not compressed. However, that stuff is not yet implemented! 
    5386             :  */
    5387             : unsigned long
    5388           0 : SgOpenclAccessModeModifier::getNumberOfLastValidPointer()
    5389             :    {
    5390           0 :       SgOpenclAccessModeModifier* testPointer = (SgOpenclAccessModeModifier*)(SgOpenclAccessModeModifier::pools.back());
    5391           0 :       unsigned long localIndex = SgOpenclAccessModeModifier::pool_size - 1;
    5392           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    5393             :          {
    5394           0 :            localIndex--;
    5395             :          }
    5396           0 :       return (localIndex + SgOpenclAccessModeModifier::pool_size * (SgOpenclAccessModeModifier::pools.size()-1));
    5397             :    }
    5398             : 
    5399             : //############################################################################
    5400             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    5401             :  * memory pool and initializes the data member in class SgOpenclAccessModeModifierStroageClass
    5402             :  * from its counterpart of SgOpenclAccessModeModifier. The return value is just for checking, 
    5403             :  * that the whole StorageClassArray is initialized!
    5404             :  */
    5405             : unsigned long
    5406           0 : SgOpenclAccessModeModifier::initializeStorageClassArray( SgOpenclAccessModeModifierStorageClass *storageArray )
    5407             :    {
    5408           0 :      unsigned long storageCounter = 0;
    5409           0 :      std::vector < unsigned char* > :: const_iterator block = SgOpenclAccessModeModifier::pools.begin();
    5410           0 :      SgOpenclAccessModeModifier* pointer = NULL;
    5411           0 :      while ( block != SgOpenclAccessModeModifier::pools.end() ) {
    5412           0 :           pointer = (SgOpenclAccessModeModifier*) (*block);
    5413           0 :           for ( unsigned i = 0; i < SgOpenclAccessModeModifier::pool_size; ++i ) {
    5414           0 :                if ( pointer->get_freepointer() != NULL ) {
    5415           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    5416           0 :                  storageArray++;
    5417           0 :                  storageCounter++;
    5418             :                }
    5419           0 :                pointer++;
    5420             :              }
    5421           0 :            block++;
    5422             :         }
    5423           0 :      return storageCounter;
    5424             :    }
    5425             : 
    5426             : /* #line 5427 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    5427             : 
    5428             : 
    5429             : 
    5430             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    5431             : 
    5432             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    5433             : 
    5434             : //############################################################################
    5435             : /* JH (02/02/2006) Constructor of the IR node SgName that takes its 
    5436             :  * corresponding StorageClass as parameter
    5437             :  */
    5438      140121 : SgName :: SgName ( const SgNameStorageClass& storageSource )   : SgSupport (storageSource)
    5439             :    {
    5440             : 
    5441             : 
    5442             : /* #line 5443 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    5443             : 
    5444      140121 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    5445      140121 :      p_char = storageSource.storageOf_char.rebuildDataStoredInEasyStorageClass() ;
    5446             : 
    5447             : 
    5448             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    5449             : 
    5450             : 
    5451      140121 :    }
    5452             : 
    5453             : //############################################################################
    5454             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    5455             :  * within the working AST. 
    5456             :  */
    5457           0 : SgName * SgName::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    5458           0 :      SgName* returnPointer = NULL;
    5459           0 :      if ( globalIndex != 0 )
    5460             :         {
    5461             : 
    5462             : #if FILE_IO_EXTRA_CHECK
    5463           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgName ) ) <= globalIndex ) ;
    5464           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgName + 1 ) ) );
    5465             : #endif
    5466           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgName )  
    5467           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgName );
    5468           0 :           unsigned long positionInPool = localIndex % SgName::pool_size;
    5469           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgName::pool_size;
    5470             : 
    5471             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    5472             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    5473             : 
    5474           0 :           returnPointer = &( ( (SgName*)(SgName::pools[memoryBlock]) ) [positionInPool]) ;
    5475             : 
    5476           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    5477             :         }
    5478           0 :      return returnPointer ;
    5479             :    }
    5480             : 
    5481             : //############################################################################
    5482             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    5483             :   for the AST with the index astIndex
    5484             : */
    5485           0 : SgName * SgName::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    5486           0 :      SgName* returnPointer = NULL;
    5487           0 :      if ( globalIndex != 0 )
    5488             :         {
    5489             : 
    5490             : #if FILE_IO_EXTRA_CHECK
    5491           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgName ) ) <= globalIndex ) ;
    5492           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgName + 1 ) ) );
    5493             : #endif
    5494           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgName )
    5495           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgName );
    5496           0 :           unsigned long positionInPool = localIndex % SgName::pool_size ;
    5497           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgName::pool_size ;
    5498             : 
    5499             : #if FILE_IO_EXTRA_CHECK
    5500             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    5501             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    5502             : #endif
    5503             : 
    5504           0 :           returnPointer = &( ( (SgName*)(SgName::pools[memoryBlock]) ) [positionInPool]) ;
    5505             : 
    5506             : #if FILE_IO_EXTRA_CHECK
    5507           0 :           assert ( returnPointer != NULL ) ;
    5508             : #endif
    5509             :         }
    5510           0 :      return returnPointer ;
    5511             :    }
    5512             : 
    5513             : //############################################################################
    5514             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    5515             :  * pool size! We set for every valid object in the memory pool the freepointer
    5516             :  * to the global index and increase the global index afterwards. For all the 
    5517             :  * invalid objects (means address ranges within the memory pool that were not
    5518             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    5519             :  * distinguish valid from invalid objects! 
    5520             :  */
    5521             : unsigned long
    5522           5 : SgName::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    5523             :    {
    5524           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    5525           5 :      SgName* pointer = NULL;
    5526           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    5527           5 :      std::vector < unsigned char* > :: const_iterator block;
    5528           5 :      for ( block = SgName::pools.begin(); block != SgName::pools.end() ; ++block )
    5529             :         {
    5530           0 :           pointer = (SgName*)(*block);
    5531           0 :           for (unsigned i = 0; i < SgName::pool_size; ++i )
    5532             :              {
    5533             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    5534             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    5535             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    5536             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    5537             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    5538             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    5539             :             // properly; so this will have to be checked next.
    5540             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    5541             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    5542           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    5543             :                   {
    5544           0 :                     pointer[i].set_freepointer((SgName*)(globalIndex));
    5545           0 :                     globalIndex++;
    5546             :                   }
    5547             :                else
    5548             :                   {
    5549           0 :                     pointer[i].set_freepointer(NULL);
    5550             :                   }
    5551             :               }
    5552             :         }
    5553           5 :      return globalIndex;
    5554             :    }
    5555             : 
    5556             : //############################################################################
    5557             : // JH (01/14/2006)
    5558             : void
    5559           5 : SgName::resetValidFreepointers( )
    5560             :    {
    5561           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    5562           5 :      SgName* pointer = NULL;
    5563           5 :      std::vector < unsigned char* > :: const_iterator block;
    5564           5 :      SgName* pointerOfLinkedList = NULL;
    5565           5 :      for ( block = SgName::pools.begin(); block != SgName::pools.end() ; ++block )
    5566             :         {
    5567           0 :           pointer = (SgName*)(*block);
    5568           0 :           for (unsigned i = 0; i < SgName::pool_size; ++i )
    5569             :              {
    5570             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    5571             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    5572             :             // memory blocks!.
    5573           0 :                if ( pointer[i].get_freepointer() != NULL )
    5574             :                   {
    5575           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    5576             :                   }
    5577             :                else
    5578             :                   {
    5579           0 :                     if ( pointerOfLinkedList == NULL )
    5580             :                        {
    5581           0 :                          SgName::next_node = &(pointer[i]);
    5582             :                        }
    5583             :                     else
    5584             :                        {
    5585             :                       // printf ("In SgName::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    5586           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    5587             :                        }
    5588             :                     pointerOfLinkedList = &(pointer[i]);
    5589             :                   }
    5590             :               }
    5591             :         }
    5592             : 
    5593           5 :      if ( pointerOfLinkedList != NULL )
    5594             :         {
    5595             :        // printf ("In SgName::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    5596           0 :           pointerOfLinkedList->set_freepointer(NULL);
    5597             :        // DQ (6/6/2010): Temporary debugging...
    5598             :        //   ROSE_ASSERT(false);
    5599             :         }
    5600             : 
    5601           5 :      return ;
    5602             :    }
    5603             : 
    5604             : //############################################################################
    5605             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    5606             :  * within the memory pool and resets the freepointers, in order to achieve a 
    5607             :  * linked list, that has no jumps and starts at the beginning! This function 
    5608             :  * does not extend the memory pool, since we do not delete any memory blocks,
    5609             :  * but delete the valid objects.  
    5610             :  */
    5611             : void
    5612           0 : SgName::clearMemoryPool( )
    5613             :    {
    5614             :   // printf ("Inside of SgName::clearMemoryPool() \n");
    5615             : 
    5616           0 :      SgName* pointer = NULL, *tempPointer = NULL;
    5617           0 :      std::vector < unsigned char* > :: const_iterator block;
    5618           0 :      if ( SgName::pools.empty() == false )
    5619             :         {
    5620           0 :           block = SgName::pools.begin() ;
    5621           0 :           SgName::next_node = (SgName*) (*block);
    5622             : 
    5623           0 :           while ( block != SgName::pools.end() )
    5624             :              {
    5625           0 :                pointer = (SgName*) (*block);
    5626           0 :                if ( tempPointer != NULL )
    5627             :                   {
    5628           0 :                     tempPointer->set_freepointer(pointer);
    5629             :                   }
    5630           0 :                for (unsigned i = 0; i < SgName::pool_size - 1; ++i)
    5631             :                   {
    5632           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    5633             :                   }
    5634           0 :                 pointer[SgName::pool_size-1].set_freepointer(NULL);
    5635           0 :                 tempPointer = &(pointer[SgName::pool_size-1]);
    5636           0 :                 ++block;
    5637             :              }
    5638             :         }
    5639           0 :    }
    5640             : 
    5641           5 : void SgName::deleteMemoryPool() {
    5642           5 :   for (auto p: SgName::pools) {
    5643           0 :     ROSE_FREE(p);
    5644             :   }
    5645           5 :   SgName::next_node = nullptr;
    5646           5 :   SgName::pools.clear();
    5647           5 : }
    5648             : 
    5649             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    5650             : //                 reading multiple binary files to for a single AST.
    5651             : /////////// new version ////////////////////////////////
    5652             : //############################################################################
    5653             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    5654             : void
    5655           2 : SgName::extendMemoryPoolForFileIO( )
    5656             :   {
    5657           2 :     size_t blockIndex = SgName::pools.size();
    5658           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgName) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgName);
    5659             : 
    5660           2 :     while ( (blockIndex * SgName::pool_size) < newPoolSize)
    5661             :       {
    5662             : #if ROSE_ALLOC_TRACE
    5663             :         if (blockIndex > 0) {
    5664             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgName) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgName) = %" PRIuPTR " SgName::pool_size = %d \n",
    5665             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgName),AST_FILE_IO::getPoolSizeOfNewAst(V_SgName),SgName::pool_size);
    5666             :         }
    5667             : #endif
    5668             : 
    5669           0 :         SgName * pointer = (SgName*) ROSE_MALLOC ( SgName::pool_size * sizeof(SgName) );
    5670           0 :         assert( pointer != NULL );
    5671             : #if ROSE_ALLOC_MEMSET == 1
    5672             :         memset(pointer, 0x00, SgName::pool_size * sizeof(SgName));
    5673             : #elif ROSE_ALLOC_MEMSET == 2
    5674             :         memset(pointer, 0xCC, SgName::pool_size * sizeof(SgName));
    5675             : #endif
    5676           0 :         SgName::pools.push_back( (unsigned char*)(pointer) );
    5677           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgName::pool_size * sizeof(SgName), V_SgName ) );
    5678             : 
    5679           0 :         if ( SgName::next_node != NULL ) {
    5680           0 :           if ( blockIndex > 0 ) {
    5681           0 :             SgName * blkptr = (SgName*)(SgName::pools[blockIndex-1]);
    5682           0 :             blkptr[ SgName::pool_size - 1 ].set_freepointer(pointer);
    5683             :           }
    5684             :         } else {
    5685           0 :           SgName::next_node = pointer;
    5686             :         }
    5687             : 
    5688           0 :         for (unsigned i = 0; i < SgName::pool_size-1; ++i)
    5689             :            {
    5690           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    5691             :            }
    5692           0 :         pointer[ SgName::pool_size -1 ].set_freepointer(NULL);
    5693             : 
    5694           0 :         blockIndex++;
    5695             :       }
    5696           2 :   }
    5697             : 
    5698             : //############################################################################
    5699             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    5700             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    5701             :  * not compressed. However, that stuff is not yet implemented! 
    5702             :  */
    5703             : unsigned long
    5704           0 : SgName::getNumberOfLastValidPointer()
    5705             :    {
    5706           0 :       SgName* testPointer = (SgName*)(SgName::pools.back());
    5707           0 :       unsigned long localIndex = SgName::pool_size - 1;
    5708           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    5709             :          {
    5710           0 :            localIndex--;
    5711             :          }
    5712           0 :       return (localIndex + SgName::pool_size * (SgName::pools.size()-1));
    5713             :    }
    5714             : 
    5715             : //############################################################################
    5716             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    5717             :  * memory pool and initializes the data member in class SgNameStroageClass
    5718             :  * from its counterpart of SgName. The return value is just for checking, 
    5719             :  * that the whole StorageClassArray is initialized!
    5720             :  */
    5721             : unsigned long
    5722           0 : SgName::initializeStorageClassArray( SgNameStorageClass *storageArray )
    5723             :    {
    5724           0 :      unsigned long storageCounter = 0;
    5725           0 :      std::vector < unsigned char* > :: const_iterator block = SgName::pools.begin();
    5726           0 :      SgName* pointer = NULL;
    5727           0 :      while ( block != SgName::pools.end() ) {
    5728           0 :           pointer = (SgName*) (*block);
    5729           0 :           for ( unsigned i = 0; i < SgName::pool_size; ++i ) {
    5730           0 :                if ( pointer->get_freepointer() != NULL ) {
    5731           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    5732           0 :                  storageArray++;
    5733           0 :                  storageCounter++;
    5734             :                }
    5735           0 :                pointer++;
    5736             :              }
    5737           0 :            block++;
    5738             :         }
    5739           0 :      return storageCounter;
    5740             :    }
    5741             : 
    5742             : /* #line 5743 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    5743             : 
    5744             : 
    5745             : 
    5746             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    5747             : 
    5748             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    5749             : 
    5750             : //############################################################################
    5751             : /* JH (02/02/2006) Constructor of the IR node SgSymbolTable that takes its 
    5752             :  * corresponding StorageClass as parameter
    5753             :  */
    5754       26900 : SgSymbolTable :: SgSymbolTable ( const SgSymbolTableStorageClass& storageSource )   : SgSupport (storageSource)
    5755             :    {
    5756             : 
    5757             : 
    5758             : /* #line 5759 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    5759             : 
    5760       26900 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    5761       26900 :      p_name = SgName ( storageSource.storageOf_name ) ;
    5762       26900 :      p_no_name = storageSource.storageOf_no_name ;
    5763       26900 :      p_table = storageSource.storageOf_table.rebuildDataStoredInEasyStorageClass() ;
    5764       26900 :      rose_hash_multimap::iterator it; 
    5765       71650 :       for (it = p_table->begin(); it != p_table->end(); ++it)
    5766             :          {
    5767       44750 :           it->second = (SgSymbol*)(AST_FILE_IO::getSgClassPointerFromGlobalIndex( (unsigned long)(it->second) ) ); 
    5768             :         }
    5769       26900 :      p_symbolSet = storageSource.storageOf_symbolSet.rebuildDataStoredInEasyStorageClass() ;
    5770       26900 :      p_case_insensitive = storageSource.storageOf_case_insensitive ;
    5771             : 
    5772             : 
    5773             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    5774             : 
    5775             : 
    5776       26900 :    }
    5777             : 
    5778             : //############################################################################
    5779             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    5780             :  * within the working AST. 
    5781             :  */
    5782       72436 : SgSymbolTable * SgSymbolTable::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    5783       72436 :      SgSymbolTable* returnPointer = NULL;
    5784       72436 :      if ( globalIndex != 0 )
    5785             :         {
    5786             : 
    5787             : #if FILE_IO_EXTRA_CHECK
    5788       72436 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSymbolTable ) ) <= globalIndex ) ;
    5789       72436 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSymbolTable + 1 ) ) );
    5790             : #endif
    5791       72436 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSymbolTable )  
    5792       72436 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSymbolTable );
    5793       72436 :           unsigned long positionInPool = localIndex % SgSymbolTable::pool_size;
    5794       72436 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSymbolTable::pool_size;
    5795             : 
    5796             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    5797             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    5798             : 
    5799       72436 :           returnPointer = &( ( (SgSymbolTable*)(SgSymbolTable::pools[memoryBlock]) ) [positionInPool]) ;
    5800             : 
    5801       72436 :           ROSE_ASSERT( returnPointer != NULL ) ;
    5802             :         }
    5803       72436 :      return returnPointer ;
    5804             :    }
    5805             : 
    5806             : //############################################################################
    5807             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    5808             :   for the AST with the index astIndex
    5809             : */
    5810           0 : SgSymbolTable * SgSymbolTable::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    5811           0 :      SgSymbolTable* returnPointer = NULL;
    5812           0 :      if ( globalIndex != 0 )
    5813             :         {
    5814             : 
    5815             : #if FILE_IO_EXTRA_CHECK
    5816           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSymbolTable ) ) <= globalIndex ) ;
    5817           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSymbolTable + 1 ) ) );
    5818             : #endif
    5819           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSymbolTable )
    5820           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSymbolTable );
    5821           0 :           unsigned long positionInPool = localIndex % SgSymbolTable::pool_size ;
    5822           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSymbolTable::pool_size ;
    5823             : 
    5824             : #if FILE_IO_EXTRA_CHECK
    5825             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    5826             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    5827             : #endif
    5828             : 
    5829           0 :           returnPointer = &( ( (SgSymbolTable*)(SgSymbolTable::pools[memoryBlock]) ) [positionInPool]) ;
    5830             : 
    5831             : #if FILE_IO_EXTRA_CHECK
    5832           0 :           assert ( returnPointer != NULL ) ;
    5833             : #endif
    5834             :         }
    5835           0 :      return returnPointer ;
    5836             :    }
    5837             : 
    5838             : //############################################################################
    5839             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    5840             :  * pool size! We set for every valid object in the memory pool the freepointer
    5841             :  * to the global index and increase the global index afterwards. For all the 
    5842             :  * invalid objects (means address ranges within the memory pool that were not
    5843             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    5844             :  * distinguish valid from invalid objects! 
    5845             :  */
    5846             : unsigned long
    5847           5 : SgSymbolTable::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    5848             :    {
    5849           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    5850           5 :      SgSymbolTable* pointer = NULL;
    5851           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    5852           5 :      std::vector < unsigned char* > :: const_iterator block;
    5853          23 :      for ( block = SgSymbolTable::pools.begin(); block != SgSymbolTable::pools.end() ; ++block )
    5854             :         {
    5855          18 :           pointer = (SgSymbolTable*)(*block);
    5856       36018 :           for (unsigned i = 0; i < SgSymbolTable::pool_size; ++i )
    5857             :              {
    5858             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    5859             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    5860             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    5861             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    5862             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    5863             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    5864             :             // properly; so this will have to be checked next.
    5865             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    5866             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    5867       36000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    5868             :                   {
    5869       26918 :                     pointer[i].set_freepointer((SgSymbolTable*)(globalIndex));
    5870       26918 :                     globalIndex++;
    5871             :                   }
    5872             :                else
    5873             :                   {
    5874        9082 :                     pointer[i].set_freepointer(NULL);
    5875             :                   }
    5876             :               }
    5877             :         }
    5878           5 :      return globalIndex;
    5879             :    }
    5880             : 
    5881             : //############################################################################
    5882             : // JH (01/14/2006)
    5883             : void
    5884           5 : SgSymbolTable::resetValidFreepointers( )
    5885             :    {
    5886           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    5887           5 :      SgSymbolTable* pointer = NULL;
    5888           5 :      std::vector < unsigned char* > :: const_iterator block;
    5889           5 :      SgSymbolTable* pointerOfLinkedList = NULL;
    5890          23 :      for ( block = SgSymbolTable::pools.begin(); block != SgSymbolTable::pools.end() ; ++block )
    5891             :         {
    5892          18 :           pointer = (SgSymbolTable*)(*block);
    5893       36018 :           for (unsigned i = 0; i < SgSymbolTable::pool_size; ++i )
    5894             :              {
    5895             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    5896             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    5897             :             // memory blocks!.
    5898       36000 :                if ( pointer[i].get_freepointer() != NULL )
    5899             :                   {
    5900       26918 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    5901             :                   }
    5902             :                else
    5903             :                   {
    5904        9082 :                     if ( pointerOfLinkedList == NULL )
    5905             :                        {
    5906           5 :                          SgSymbolTable::next_node = &(pointer[i]);
    5907             :                        }
    5908             :                     else
    5909             :                        {
    5910             :                       // printf ("In SgSymbolTable::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    5911        9077 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    5912             :                        }
    5913             :                     pointerOfLinkedList = &(pointer[i]);
    5914             :                   }
    5915             :               }
    5916             :         }
    5917             : 
    5918           5 :      if ( pointerOfLinkedList != NULL )
    5919             :         {
    5920             :        // printf ("In SgSymbolTable::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    5921           5 :           pointerOfLinkedList->set_freepointer(NULL);
    5922             :        // DQ (6/6/2010): Temporary debugging...
    5923             :        //   ROSE_ASSERT(false);
    5924             :         }
    5925             : 
    5926           5 :      return ;
    5927             :    }
    5928             : 
    5929             : //############################################################################
    5930             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    5931             :  * within the memory pool and resets the freepointers, in order to achieve a 
    5932             :  * linked list, that has no jumps and starts at the beginning! This function 
    5933             :  * does not extend the memory pool, since we do not delete any memory blocks,
    5934             :  * but delete the valid objects.  
    5935             :  */
    5936             : void
    5937           0 : SgSymbolTable::clearMemoryPool( )
    5938             :    {
    5939             :   // printf ("Inside of SgSymbolTable::clearMemoryPool() \n");
    5940             : 
    5941           0 :      SgSymbolTable* pointer = NULL, *tempPointer = NULL;
    5942           0 :      std::vector < unsigned char* > :: const_iterator block;
    5943           0 :      if ( SgSymbolTable::pools.empty() == false )
    5944             :         {
    5945           0 :           block = SgSymbolTable::pools.begin() ;
    5946           0 :           SgSymbolTable::next_node = (SgSymbolTable*) (*block);
    5947             : 
    5948           0 :           while ( block != SgSymbolTable::pools.end() )
    5949             :              {
    5950           0 :                pointer = (SgSymbolTable*) (*block);
    5951           0 :                if ( tempPointer != NULL )
    5952             :                   {
    5953           0 :                     tempPointer->set_freepointer(pointer);
    5954             :                   }
    5955           0 :                for (unsigned i = 0; i < SgSymbolTable::pool_size - 1; ++i)
    5956             :                   {
    5957           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    5958             :                   }
    5959           0 :                 pointer[SgSymbolTable::pool_size-1].set_freepointer(NULL);
    5960           0 :                 tempPointer = &(pointer[SgSymbolTable::pool_size-1]);
    5961           0 :                 ++block;
    5962             :              }
    5963             :         }
    5964           0 :    }
    5965             : 
    5966           5 : void SgSymbolTable::deleteMemoryPool() {
    5967          36 :   for (auto p: SgSymbolTable::pools) {
    5968          31 :     ROSE_FREE(p);
    5969             :   }
    5970           5 :   SgSymbolTable::next_node = nullptr;
    5971           5 :   SgSymbolTable::pools.clear();
    5972           5 : }
    5973             : 
    5974             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    5975             : //                 reading multiple binary files to for a single AST.
    5976             : /////////// new version ////////////////////////////////
    5977             : //############################################################################
    5978             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    5979             : void
    5980           2 : SgSymbolTable::extendMemoryPoolForFileIO( )
    5981             :   {
    5982           2 :     size_t blockIndex = SgSymbolTable::pools.size();
    5983           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSymbolTable) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSymbolTable);
    5984             : 
    5985          15 :     while ( (blockIndex * SgSymbolTable::pool_size) < newPoolSize)
    5986             :       {
    5987             : #if ROSE_ALLOC_TRACE
    5988             :         if (blockIndex > 0) {
    5989             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSymbolTable) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSymbolTable) = %" PRIuPTR " SgSymbolTable::pool_size = %d \n",
    5990             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSymbolTable),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSymbolTable),SgSymbolTable::pool_size);
    5991             :         }
    5992             : #endif
    5993             : 
    5994          13 :         SgSymbolTable * pointer = (SgSymbolTable*) ROSE_MALLOC ( SgSymbolTable::pool_size * sizeof(SgSymbolTable) );
    5995          13 :         assert( pointer != NULL );
    5996             : #if ROSE_ALLOC_MEMSET == 1
    5997             :         memset(pointer, 0x00, SgSymbolTable::pool_size * sizeof(SgSymbolTable));
    5998             : #elif ROSE_ALLOC_MEMSET == 2
    5999             :         memset(pointer, 0xCC, SgSymbolTable::pool_size * sizeof(SgSymbolTable));
    6000             : #endif
    6001          13 :         SgSymbolTable::pools.push_back( (unsigned char*)(pointer) );
    6002          13 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSymbolTable::pool_size * sizeof(SgSymbolTable), V_SgSymbolTable ) );
    6003             : 
    6004          13 :         if ( SgSymbolTable::next_node != NULL ) {
    6005          13 :           if ( blockIndex > 0 ) {
    6006          13 :             SgSymbolTable * blkptr = (SgSymbolTable*)(SgSymbolTable::pools[blockIndex-1]);
    6007          13 :             blkptr[ SgSymbolTable::pool_size - 1 ].set_freepointer(pointer);
    6008             :           }
    6009             :         } else {
    6010           0 :           SgSymbolTable::next_node = pointer;
    6011             :         }
    6012             : 
    6013       26000 :         for (unsigned i = 0; i < SgSymbolTable::pool_size-1; ++i)
    6014             :            {
    6015       25987 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    6016             :            }
    6017          13 :         pointer[ SgSymbolTable::pool_size -1 ].set_freepointer(NULL);
    6018             : 
    6019          13 :         blockIndex++;
    6020             :       }
    6021           2 :   }
    6022             : 
    6023             : //############################################################################
    6024             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    6025             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    6026             :  * not compressed. However, that stuff is not yet implemented! 
    6027             :  */
    6028             : unsigned long
    6029           0 : SgSymbolTable::getNumberOfLastValidPointer()
    6030             :    {
    6031           0 :       SgSymbolTable* testPointer = (SgSymbolTable*)(SgSymbolTable::pools.back());
    6032           0 :       unsigned long localIndex = SgSymbolTable::pool_size - 1;
    6033           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    6034             :          {
    6035           0 :            localIndex--;
    6036             :          }
    6037           0 :       return (localIndex + SgSymbolTable::pool_size * (SgSymbolTable::pools.size()-1));
    6038             :    }
    6039             : 
    6040             : //############################################################################
    6041             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    6042             :  * memory pool and initializes the data member in class SgSymbolTableStroageClass
    6043             :  * from its counterpart of SgSymbolTable. The return value is just for checking, 
    6044             :  * that the whole StorageClassArray is initialized!
    6045             :  */
    6046             : unsigned long
    6047           3 : SgSymbolTable::initializeStorageClassArray( SgSymbolTableStorageClass *storageArray )
    6048             :    {
    6049           3 :      unsigned long storageCounter = 0;
    6050           3 :      std::vector < unsigned char* > :: const_iterator block = SgSymbolTable::pools.begin();
    6051           3 :      SgSymbolTable* pointer = NULL;
    6052          19 :      while ( block != SgSymbolTable::pools.end() ) {
    6053          16 :           pointer = (SgSymbolTable*) (*block);
    6054       32016 :           for ( unsigned i = 0; i < SgSymbolTable::pool_size; ++i ) {
    6055       32000 :                if ( pointer->get_freepointer() != NULL ) {
    6056       26910 :                  storageArray->pickOutIRNodeData (pointer) ;
    6057       26910 :                  storageArray++;
    6058       26910 :                  storageCounter++;
    6059             :                }
    6060       32000 :                pointer++;
    6061             :              }
    6062          16 :            block++;
    6063             :         }
    6064           3 :      return storageCounter;
    6065             :    }
    6066             : 
    6067             : /* #line 6068 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    6068             : 
    6069             : 
    6070             : 
    6071             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    6072             : 
    6073             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    6074             : 
    6075             : //############################################################################
    6076             : /* JH (02/02/2006) Constructor of the IR node SgAttribute that takes its 
    6077             :  * corresponding StorageClass as parameter
    6078             :  */
    6079          97 : SgAttribute :: SgAttribute ( const SgAttributeStorageClass& storageSource )   : SgSupport (storageSource)
    6080             :    {
    6081             : 
    6082             : 
    6083             : /* #line 6084 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    6084             : 
    6085          97 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    6086          97 :      p_name = storageSource.storageOf_name.rebuildDataStoredInEasyStorageClass() ;
    6087             : 
    6088             : 
    6089             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    6090             : 
    6091             : 
    6092          97 :    }
    6093             : 
    6094             : //############################################################################
    6095             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    6096             :  * within the working AST. 
    6097             :  */
    6098           0 : SgAttribute * SgAttribute::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    6099           0 :      SgAttribute* returnPointer = NULL;
    6100           0 :      if ( globalIndex != 0 )
    6101             :         {
    6102             : 
    6103             : #if FILE_IO_EXTRA_CHECK
    6104           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAttribute ) ) <= globalIndex ) ;
    6105           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAttribute + 1 ) ) );
    6106             : #endif
    6107           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAttribute )  
    6108           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAttribute );
    6109           0 :           unsigned long positionInPool = localIndex % SgAttribute::pool_size;
    6110           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAttribute::pool_size;
    6111             : 
    6112             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    6113             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    6114             : 
    6115           0 :           returnPointer = &( ( (SgAttribute*)(SgAttribute::pools[memoryBlock]) ) [positionInPool]) ;
    6116             : 
    6117           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    6118             :         }
    6119           0 :      return returnPointer ;
    6120             :    }
    6121             : 
    6122             : //############################################################################
    6123             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    6124             :   for the AST with the index astIndex
    6125             : */
    6126           0 : SgAttribute * SgAttribute::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    6127           0 :      SgAttribute* returnPointer = NULL;
    6128           0 :      if ( globalIndex != 0 )
    6129             :         {
    6130             : 
    6131             : #if FILE_IO_EXTRA_CHECK
    6132           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAttribute ) ) <= globalIndex ) ;
    6133           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAttribute + 1 ) ) );
    6134             : #endif
    6135           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAttribute )
    6136           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAttribute );
    6137           0 :           unsigned long positionInPool = localIndex % SgAttribute::pool_size ;
    6138           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAttribute::pool_size ;
    6139             : 
    6140             : #if FILE_IO_EXTRA_CHECK
    6141             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    6142             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    6143             : #endif
    6144             : 
    6145           0 :           returnPointer = &( ( (SgAttribute*)(SgAttribute::pools[memoryBlock]) ) [positionInPool]) ;
    6146             : 
    6147             : #if FILE_IO_EXTRA_CHECK
    6148           0 :           assert ( returnPointer != NULL ) ;
    6149             : #endif
    6150             :         }
    6151           0 :      return returnPointer ;
    6152             :    }
    6153             : 
    6154             : //############################################################################
    6155             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    6156             :  * pool size! We set for every valid object in the memory pool the freepointer
    6157             :  * to the global index and increase the global index afterwards. For all the 
    6158             :  * invalid objects (means address ranges within the memory pool that were not
    6159             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    6160             :  * distinguish valid from invalid objects! 
    6161             :  */
    6162             : unsigned long
    6163           5 : SgAttribute::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    6164             :    {
    6165           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    6166           5 :      SgAttribute* pointer = NULL;
    6167           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    6168           5 :      std::vector < unsigned char* > :: const_iterator block;
    6169           5 :      for ( block = SgAttribute::pools.begin(); block != SgAttribute::pools.end() ; ++block )
    6170             :         {
    6171           0 :           pointer = (SgAttribute*)(*block);
    6172           0 :           for (unsigned i = 0; i < SgAttribute::pool_size; ++i )
    6173             :              {
    6174             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    6175             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    6176             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    6177             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    6178             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    6179             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    6180             :             // properly; so this will have to be checked next.
    6181             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    6182             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    6183           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    6184             :                   {
    6185           0 :                     pointer[i].set_freepointer((SgAttribute*)(globalIndex));
    6186           0 :                     globalIndex++;
    6187             :                   }
    6188             :                else
    6189             :                   {
    6190           0 :                     pointer[i].set_freepointer(NULL);
    6191             :                   }
    6192             :               }
    6193             :         }
    6194           5 :      return globalIndex;
    6195             :    }
    6196             : 
    6197             : //############################################################################
    6198             : // JH (01/14/2006)
    6199             : void
    6200           5 : SgAttribute::resetValidFreepointers( )
    6201             :    {
    6202           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    6203           5 :      SgAttribute* pointer = NULL;
    6204           5 :      std::vector < unsigned char* > :: const_iterator block;
    6205           5 :      SgAttribute* pointerOfLinkedList = NULL;
    6206           5 :      for ( block = SgAttribute::pools.begin(); block != SgAttribute::pools.end() ; ++block )
    6207             :         {
    6208           0 :           pointer = (SgAttribute*)(*block);
    6209           0 :           for (unsigned i = 0; i < SgAttribute::pool_size; ++i )
    6210             :              {
    6211             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    6212             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    6213             :             // memory blocks!.
    6214           0 :                if ( pointer[i].get_freepointer() != NULL )
    6215             :                   {
    6216           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    6217             :                   }
    6218             :                else
    6219             :                   {
    6220           0 :                     if ( pointerOfLinkedList == NULL )
    6221             :                        {
    6222           0 :                          SgAttribute::next_node = &(pointer[i]);
    6223             :                        }
    6224             :                     else
    6225             :                        {
    6226             :                       // printf ("In SgAttribute::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    6227           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    6228             :                        }
    6229             :                     pointerOfLinkedList = &(pointer[i]);
    6230             :                   }
    6231             :               }
    6232             :         }
    6233             : 
    6234           5 :      if ( pointerOfLinkedList != NULL )
    6235             :         {
    6236             :        // printf ("In SgAttribute::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    6237           0 :           pointerOfLinkedList->set_freepointer(NULL);
    6238             :        // DQ (6/6/2010): Temporary debugging...
    6239             :        //   ROSE_ASSERT(false);
    6240             :         }
    6241             : 
    6242           5 :      return ;
    6243             :    }
    6244             : 
    6245             : //############################################################################
    6246             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    6247             :  * within the memory pool and resets the freepointers, in order to achieve a 
    6248             :  * linked list, that has no jumps and starts at the beginning! This function 
    6249             :  * does not extend the memory pool, since we do not delete any memory blocks,
    6250             :  * but delete the valid objects.  
    6251             :  */
    6252             : void
    6253           0 : SgAttribute::clearMemoryPool( )
    6254             :    {
    6255             :   // printf ("Inside of SgAttribute::clearMemoryPool() \n");
    6256             : 
    6257           0 :      SgAttribute* pointer = NULL, *tempPointer = NULL;
    6258           0 :      std::vector < unsigned char* > :: const_iterator block;
    6259           0 :      if ( SgAttribute::pools.empty() == false )
    6260             :         {
    6261           0 :           block = SgAttribute::pools.begin() ;
    6262           0 :           SgAttribute::next_node = (SgAttribute*) (*block);
    6263             : 
    6264           0 :           while ( block != SgAttribute::pools.end() )
    6265             :              {
    6266           0 :                pointer = (SgAttribute*) (*block);
    6267           0 :                if ( tempPointer != NULL )
    6268             :                   {
    6269           0 :                     tempPointer->set_freepointer(pointer);
    6270             :                   }
    6271           0 :                for (unsigned i = 0; i < SgAttribute::pool_size - 1; ++i)
    6272             :                   {
    6273           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    6274             :                   }
    6275           0 :                 pointer[SgAttribute::pool_size-1].set_freepointer(NULL);
    6276           0 :                 tempPointer = &(pointer[SgAttribute::pool_size-1]);
    6277           0 :                 ++block;
    6278             :              }
    6279             :         }
    6280           0 :    }
    6281             : 
    6282           5 : void SgAttribute::deleteMemoryPool() {
    6283           5 :   for (auto p: SgAttribute::pools) {
    6284           0 :     ROSE_FREE(p);
    6285             :   }
    6286           5 :   SgAttribute::next_node = nullptr;
    6287           5 :   SgAttribute::pools.clear();
    6288           5 : }
    6289             : 
    6290             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    6291             : //                 reading multiple binary files to for a single AST.
    6292             : /////////// new version ////////////////////////////////
    6293             : //############################################################################
    6294             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    6295             : void
    6296           2 : SgAttribute::extendMemoryPoolForFileIO( )
    6297             :   {
    6298           2 :     size_t blockIndex = SgAttribute::pools.size();
    6299           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAttribute) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAttribute);
    6300             : 
    6301           2 :     while ( (blockIndex * SgAttribute::pool_size) < newPoolSize)
    6302             :       {
    6303             : #if ROSE_ALLOC_TRACE
    6304             :         if (blockIndex > 0) {
    6305             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAttribute) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAttribute) = %" PRIuPTR " SgAttribute::pool_size = %d \n",
    6306             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAttribute),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAttribute),SgAttribute::pool_size);
    6307             :         }
    6308             : #endif
    6309             : 
    6310           0 :         SgAttribute * pointer = (SgAttribute*) ROSE_MALLOC ( SgAttribute::pool_size * sizeof(SgAttribute) );
    6311           0 :         assert( pointer != NULL );
    6312             : #if ROSE_ALLOC_MEMSET == 1
    6313             :         memset(pointer, 0x00, SgAttribute::pool_size * sizeof(SgAttribute));
    6314             : #elif ROSE_ALLOC_MEMSET == 2
    6315             :         memset(pointer, 0xCC, SgAttribute::pool_size * sizeof(SgAttribute));
    6316             : #endif
    6317           0 :         SgAttribute::pools.push_back( (unsigned char*)(pointer) );
    6318           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAttribute::pool_size * sizeof(SgAttribute), V_SgAttribute ) );
    6319             : 
    6320           0 :         if ( SgAttribute::next_node != NULL ) {
    6321           0 :           if ( blockIndex > 0 ) {
    6322           0 :             SgAttribute * blkptr = (SgAttribute*)(SgAttribute::pools[blockIndex-1]);
    6323           0 :             blkptr[ SgAttribute::pool_size - 1 ].set_freepointer(pointer);
    6324             :           }
    6325             :         } else {
    6326           0 :           SgAttribute::next_node = pointer;
    6327             :         }
    6328             : 
    6329           0 :         for (unsigned i = 0; i < SgAttribute::pool_size-1; ++i)
    6330             :            {
    6331           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    6332             :            }
    6333           0 :         pointer[ SgAttribute::pool_size -1 ].set_freepointer(NULL);
    6334             : 
    6335           0 :         blockIndex++;
    6336             :       }
    6337           2 :   }
    6338             : 
    6339             : //############################################################################
    6340             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    6341             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    6342             :  * not compressed. However, that stuff is not yet implemented! 
    6343             :  */
    6344             : unsigned long
    6345           0 : SgAttribute::getNumberOfLastValidPointer()
    6346             :    {
    6347           0 :       SgAttribute* testPointer = (SgAttribute*)(SgAttribute::pools.back());
    6348           0 :       unsigned long localIndex = SgAttribute::pool_size - 1;
    6349           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    6350             :          {
    6351           0 :            localIndex--;
    6352             :          }
    6353           0 :       return (localIndex + SgAttribute::pool_size * (SgAttribute::pools.size()-1));
    6354             :    }
    6355             : 
    6356             : //############################################################################
    6357             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    6358             :  * memory pool and initializes the data member in class SgAttributeStroageClass
    6359             :  * from its counterpart of SgAttribute. The return value is just for checking, 
    6360             :  * that the whole StorageClassArray is initialized!
    6361             :  */
    6362             : unsigned long
    6363           0 : SgAttribute::initializeStorageClassArray( SgAttributeStorageClass *storageArray )
    6364             :    {
    6365           0 :      unsigned long storageCounter = 0;
    6366           0 :      std::vector < unsigned char* > :: const_iterator block = SgAttribute::pools.begin();
    6367           0 :      SgAttribute* pointer = NULL;
    6368           0 :      while ( block != SgAttribute::pools.end() ) {
    6369           0 :           pointer = (SgAttribute*) (*block);
    6370           0 :           for ( unsigned i = 0; i < SgAttribute::pool_size; ++i ) {
    6371           0 :                if ( pointer->get_freepointer() != NULL ) {
    6372           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    6373           0 :                  storageArray++;
    6374           0 :                  storageCounter++;
    6375             :                }
    6376           0 :                pointer++;
    6377             :              }
    6378           0 :            block++;
    6379             :         }
    6380           0 :      return storageCounter;
    6381             :    }
    6382             : 
    6383             : /* #line 6384 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    6384             : 
    6385             : 
    6386             : 
    6387             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    6388             : 
    6389             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    6390             : 
    6391             : //############################################################################
    6392             : /* JH (02/02/2006) Constructor of the IR node SgPragma that takes its 
    6393             :  * corresponding StorageClass as parameter
    6394             :  */
    6395          97 : SgPragma :: SgPragma ( const SgPragmaStorageClass& storageSource )   : SgAttribute (storageSource)
    6396             :    {
    6397             : 
    6398             : 
    6399             : /* #line 6400 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    6400             : 
    6401          97 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    6402          97 :      p_startOfConstruct =  (Sg_File_Info*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_startOfConstruct) );
    6403          97 :      p_endOfConstruct =  (Sg_File_Info*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_endOfConstruct) );
    6404          97 :      p_printed = storageSource.storageOf_printed ;
    6405          97 :      p_args =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_args) );
    6406          97 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
    6407             : 
    6408             : 
    6409             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    6410             : 
    6411             : 
    6412          97 :    }
    6413             : 
    6414             : //############################################################################
    6415             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    6416             :  * within the working AST. 
    6417             :  */
    6418         291 : SgPragma * SgPragma::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    6419         291 :      SgPragma* returnPointer = NULL;
    6420         291 :      if ( globalIndex != 0 )
    6421             :         {
    6422             : 
    6423             : #if FILE_IO_EXTRA_CHECK
    6424         291 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPragma ) ) <= globalIndex ) ;
    6425         291 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPragma + 1 ) ) );
    6426             : #endif
    6427         291 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPragma )  
    6428         291 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPragma );
    6429         291 :           unsigned long positionInPool = localIndex % SgPragma::pool_size;
    6430         291 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPragma::pool_size;
    6431             : 
    6432             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    6433             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    6434             : 
    6435         291 :           returnPointer = &( ( (SgPragma*)(SgPragma::pools[memoryBlock]) ) [positionInPool]) ;
    6436             : 
    6437         291 :           ROSE_ASSERT( returnPointer != NULL ) ;
    6438             :         }
    6439         291 :      return returnPointer ;
    6440             :    }
    6441             : 
    6442             : //############################################################################
    6443             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    6444             :   for the AST with the index astIndex
    6445             : */
    6446           0 : SgPragma * SgPragma::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    6447           0 :      SgPragma* returnPointer = NULL;
    6448           0 :      if ( globalIndex != 0 )
    6449             :         {
    6450             : 
    6451             : #if FILE_IO_EXTRA_CHECK
    6452           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPragma ) ) <= globalIndex ) ;
    6453           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPragma + 1 ) ) );
    6454             : #endif
    6455           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPragma )
    6456           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPragma );
    6457           0 :           unsigned long positionInPool = localIndex % SgPragma::pool_size ;
    6458           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPragma::pool_size ;
    6459             : 
    6460             : #if FILE_IO_EXTRA_CHECK
    6461             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    6462             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    6463             : #endif
    6464             : 
    6465           0 :           returnPointer = &( ( (SgPragma*)(SgPragma::pools[memoryBlock]) ) [positionInPool]) ;
    6466             : 
    6467             : #if FILE_IO_EXTRA_CHECK
    6468           0 :           assert ( returnPointer != NULL ) ;
    6469             : #endif
    6470             :         }
    6471           0 :      return returnPointer ;
    6472             :    }
    6473             : 
    6474             : //############################################################################
    6475             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    6476             :  * pool size! We set for every valid object in the memory pool the freepointer
    6477             :  * to the global index and increase the global index afterwards. For all the 
    6478             :  * invalid objects (means address ranges within the memory pool that were not
    6479             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    6480             :  * distinguish valid from invalid objects! 
    6481             :  */
    6482             : unsigned long
    6483           5 : SgPragma::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    6484             :    {
    6485           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    6486           5 :      SgPragma* pointer = NULL;
    6487           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    6488           5 :      std::vector < unsigned char* > :: const_iterator block;
    6489           6 :      for ( block = SgPragma::pools.begin(); block != SgPragma::pools.end() ; ++block )
    6490             :         {
    6491           1 :           pointer = (SgPragma*)(*block);
    6492        2001 :           for (unsigned i = 0; i < SgPragma::pool_size; ++i )
    6493             :              {
    6494             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    6495             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    6496             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    6497             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    6498             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    6499             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    6500             :             // properly; so this will have to be checked next.
    6501             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    6502             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    6503        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    6504             :                   {
    6505          97 :                     pointer[i].set_freepointer((SgPragma*)(globalIndex));
    6506          97 :                     globalIndex++;
    6507             :                   }
    6508             :                else
    6509             :                   {
    6510        1903 :                     pointer[i].set_freepointer(NULL);
    6511             :                   }
    6512             :               }
    6513             :         }
    6514           5 :      return globalIndex;
    6515             :    }
    6516             : 
    6517             : //############################################################################
    6518             : // JH (01/14/2006)
    6519             : void
    6520           5 : SgPragma::resetValidFreepointers( )
    6521             :    {
    6522           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    6523           5 :      SgPragma* pointer = NULL;
    6524           5 :      std::vector < unsigned char* > :: const_iterator block;
    6525           5 :      SgPragma* pointerOfLinkedList = NULL;
    6526           6 :      for ( block = SgPragma::pools.begin(); block != SgPragma::pools.end() ; ++block )
    6527             :         {
    6528           1 :           pointer = (SgPragma*)(*block);
    6529        2001 :           for (unsigned i = 0; i < SgPragma::pool_size; ++i )
    6530             :              {
    6531             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    6532             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    6533             :             // memory blocks!.
    6534        2000 :                if ( pointer[i].get_freepointer() != NULL )
    6535             :                   {
    6536          97 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    6537             :                   }
    6538             :                else
    6539             :                   {
    6540        1903 :                     if ( pointerOfLinkedList == NULL )
    6541             :                        {
    6542           1 :                          SgPragma::next_node = &(pointer[i]);
    6543             :                        }
    6544             :                     else
    6545             :                        {
    6546             :                       // printf ("In SgPragma::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    6547        1902 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    6548             :                        }
    6549             :                     pointerOfLinkedList = &(pointer[i]);
    6550             :                   }
    6551             :               }
    6552             :         }
    6553             : 
    6554           5 :      if ( pointerOfLinkedList != NULL )
    6555             :         {
    6556             :        // printf ("In SgPragma::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    6557           1 :           pointerOfLinkedList->set_freepointer(NULL);
    6558             :        // DQ (6/6/2010): Temporary debugging...
    6559             :        //   ROSE_ASSERT(false);
    6560             :         }
    6561             : 
    6562           5 :      return ;
    6563             :    }
    6564             : 
    6565             : //############################################################################
    6566             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    6567             :  * within the memory pool and resets the freepointers, in order to achieve a 
    6568             :  * linked list, that has no jumps and starts at the beginning! This function 
    6569             :  * does not extend the memory pool, since we do not delete any memory blocks,
    6570             :  * but delete the valid objects.  
    6571             :  */
    6572             : void
    6573           0 : SgPragma::clearMemoryPool( )
    6574             :    {
    6575             :   // printf ("Inside of SgPragma::clearMemoryPool() \n");
    6576             : 
    6577           0 :      SgPragma* pointer = NULL, *tempPointer = NULL;
    6578           0 :      std::vector < unsigned char* > :: const_iterator block;
    6579           0 :      if ( SgPragma::pools.empty() == false )
    6580             :         {
    6581           0 :           block = SgPragma::pools.begin() ;
    6582           0 :           SgPragma::next_node = (SgPragma*) (*block);
    6583             : 
    6584           0 :           while ( block != SgPragma::pools.end() )
    6585             :              {
    6586           0 :                pointer = (SgPragma*) (*block);
    6587           0 :                if ( tempPointer != NULL )
    6588             :                   {
    6589           0 :                     tempPointer->set_freepointer(pointer);
    6590             :                   }
    6591           0 :                for (unsigned i = 0; i < SgPragma::pool_size - 1; ++i)
    6592             :                   {
    6593           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    6594             :                   }
    6595           0 :                 pointer[SgPragma::pool_size-1].set_freepointer(NULL);
    6596           0 :                 tempPointer = &(pointer[SgPragma::pool_size-1]);
    6597           0 :                 ++block;
    6598             :              }
    6599             :         }
    6600           0 :    }
    6601             : 
    6602           5 : void SgPragma::deleteMemoryPool() {
    6603           7 :   for (auto p: SgPragma::pools) {
    6604           2 :     ROSE_FREE(p);
    6605             :   }
    6606           5 :   SgPragma::next_node = nullptr;
    6607           5 :   SgPragma::pools.clear();
    6608           5 : }
    6609             : 
    6610             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    6611             : //                 reading multiple binary files to for a single AST.
    6612             : /////////// new version ////////////////////////////////
    6613             : //############################################################################
    6614             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    6615             : void
    6616           2 : SgPragma::extendMemoryPoolForFileIO( )
    6617             :   {
    6618           2 :     size_t blockIndex = SgPragma::pools.size();
    6619           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPragma) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPragma);
    6620             : 
    6621           3 :     while ( (blockIndex * SgPragma::pool_size) < newPoolSize)
    6622             :       {
    6623             : #if ROSE_ALLOC_TRACE
    6624             :         if (blockIndex > 0) {
    6625             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPragma) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPragma) = %" PRIuPTR " SgPragma::pool_size = %d \n",
    6626             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPragma),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPragma),SgPragma::pool_size);
    6627             :         }
    6628             : #endif
    6629             : 
    6630           1 :         SgPragma * pointer = (SgPragma*) ROSE_MALLOC ( SgPragma::pool_size * sizeof(SgPragma) );
    6631           1 :         assert( pointer != NULL );
    6632             : #if ROSE_ALLOC_MEMSET == 1
    6633             :         memset(pointer, 0x00, SgPragma::pool_size * sizeof(SgPragma));
    6634             : #elif ROSE_ALLOC_MEMSET == 2
    6635             :         memset(pointer, 0xCC, SgPragma::pool_size * sizeof(SgPragma));
    6636             : #endif
    6637           1 :         SgPragma::pools.push_back( (unsigned char*)(pointer) );
    6638           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPragma::pool_size * sizeof(SgPragma), V_SgPragma ) );
    6639             : 
    6640           1 :         if ( SgPragma::next_node != NULL ) {
    6641           0 :           if ( blockIndex > 0 ) {
    6642           0 :             SgPragma * blkptr = (SgPragma*)(SgPragma::pools[blockIndex-1]);
    6643           0 :             blkptr[ SgPragma::pool_size - 1 ].set_freepointer(pointer);
    6644             :           }
    6645             :         } else {
    6646           1 :           SgPragma::next_node = pointer;
    6647             :         }
    6648             : 
    6649        2000 :         for (unsigned i = 0; i < SgPragma::pool_size-1; ++i)
    6650             :            {
    6651        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    6652             :            }
    6653           1 :         pointer[ SgPragma::pool_size -1 ].set_freepointer(NULL);
    6654             : 
    6655           1 :         blockIndex++;
    6656             :       }
    6657           2 :   }
    6658             : 
    6659             : //############################################################################
    6660             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    6661             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    6662             :  * not compressed. However, that stuff is not yet implemented! 
    6663             :  */
    6664             : unsigned long
    6665           0 : SgPragma::getNumberOfLastValidPointer()
    6666             :    {
    6667           0 :       SgPragma* testPointer = (SgPragma*)(SgPragma::pools.back());
    6668           0 :       unsigned long localIndex = SgPragma::pool_size - 1;
    6669           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    6670             :          {
    6671           0 :            localIndex--;
    6672             :          }
    6673           0 :       return (localIndex + SgPragma::pool_size * (SgPragma::pools.size()-1));
    6674             :    }
    6675             : 
    6676             : //############################################################################
    6677             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    6678             :  * memory pool and initializes the data member in class SgPragmaStroageClass
    6679             :  * from its counterpart of SgPragma. The return value is just for checking, 
    6680             :  * that the whole StorageClassArray is initialized!
    6681             :  */
    6682             : unsigned long
    6683           1 : SgPragma::initializeStorageClassArray( SgPragmaStorageClass *storageArray )
    6684             :    {
    6685           1 :      unsigned long storageCounter = 0;
    6686           1 :      std::vector < unsigned char* > :: const_iterator block = SgPragma::pools.begin();
    6687           1 :      SgPragma* pointer = NULL;
    6688           2 :      while ( block != SgPragma::pools.end() ) {
    6689           1 :           pointer = (SgPragma*) (*block);
    6690        2001 :           for ( unsigned i = 0; i < SgPragma::pool_size; ++i ) {
    6691        2000 :                if ( pointer->get_freepointer() != NULL ) {
    6692          97 :                  storageArray->pickOutIRNodeData (pointer) ;
    6693          97 :                  storageArray++;
    6694          97 :                  storageCounter++;
    6695             :                }
    6696        2000 :                pointer++;
    6697             :              }
    6698           1 :            block++;
    6699             :         }
    6700           1 :      return storageCounter;
    6701             :    }
    6702             : 
    6703             : /* #line 6704 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    6704             : 
    6705             : 
    6706             : 
    6707             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    6708             : 
    6709             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    6710             : 
    6711             : //############################################################################
    6712             : /* JH (02/02/2006) Constructor of the IR node SgBitAttribute that takes its 
    6713             :  * corresponding StorageClass as parameter
    6714             :  */
    6715           0 : SgBitAttribute :: SgBitAttribute ( const SgBitAttributeStorageClass& storageSource )   : SgAttribute (storageSource)
    6716             :    {
    6717             : 
    6718             : 
    6719             : /* #line 6720 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    6720             : 
    6721           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    6722           0 :      p_bitflag = storageSource.storageOf_bitflag ;
    6723             : 
    6724             : 
    6725             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    6726             : 
    6727             : 
    6728           0 :    }
    6729             : 
    6730             : //############################################################################
    6731             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    6732             :  * within the working AST. 
    6733             :  */
    6734           0 : SgBitAttribute * SgBitAttribute::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    6735           0 :      SgBitAttribute* returnPointer = NULL;
    6736           0 :      if ( globalIndex != 0 )
    6737             :         {
    6738             : 
    6739             : #if FILE_IO_EXTRA_CHECK
    6740           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBitAttribute ) ) <= globalIndex ) ;
    6741           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitAttribute + 1 ) ) );
    6742             : #endif
    6743           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitAttribute )  
    6744           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBitAttribute );
    6745           0 :           unsigned long positionInPool = localIndex % SgBitAttribute::pool_size;
    6746           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitAttribute::pool_size;
    6747             : 
    6748             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    6749             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    6750             : 
    6751           0 :           returnPointer = &( ( (SgBitAttribute*)(SgBitAttribute::pools[memoryBlock]) ) [positionInPool]) ;
    6752             : 
    6753           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    6754             :         }
    6755           0 :      return returnPointer ;
    6756             :    }
    6757             : 
    6758             : //############################################################################
    6759             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    6760             :   for the AST with the index astIndex
    6761             : */
    6762           0 : SgBitAttribute * SgBitAttribute::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    6763           0 :      SgBitAttribute* returnPointer = NULL;
    6764           0 :      if ( globalIndex != 0 )
    6765             :         {
    6766             : 
    6767             : #if FILE_IO_EXTRA_CHECK
    6768           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBitAttribute ) ) <= globalIndex ) ;
    6769           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitAttribute + 1 ) ) );
    6770             : #endif
    6771           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitAttribute )
    6772           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBitAttribute );
    6773           0 :           unsigned long positionInPool = localIndex % SgBitAttribute::pool_size ;
    6774           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitAttribute::pool_size ;
    6775             : 
    6776             : #if FILE_IO_EXTRA_CHECK
    6777             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    6778             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    6779             : #endif
    6780             : 
    6781           0 :           returnPointer = &( ( (SgBitAttribute*)(SgBitAttribute::pools[memoryBlock]) ) [positionInPool]) ;
    6782             : 
    6783             : #if FILE_IO_EXTRA_CHECK
    6784           0 :           assert ( returnPointer != NULL ) ;
    6785             : #endif
    6786             :         }
    6787           0 :      return returnPointer ;
    6788             :    }
    6789             : 
    6790             : //############################################################################
    6791             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    6792             :  * pool size! We set for every valid object in the memory pool the freepointer
    6793             :  * to the global index and increase the global index afterwards. For all the 
    6794             :  * invalid objects (means address ranges within the memory pool that were not
    6795             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    6796             :  * distinguish valid from invalid objects! 
    6797             :  */
    6798             : unsigned long
    6799           5 : SgBitAttribute::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    6800             :    {
    6801           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    6802           5 :      SgBitAttribute* pointer = NULL;
    6803           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    6804           5 :      std::vector < unsigned char* > :: const_iterator block;
    6805           5 :      for ( block = SgBitAttribute::pools.begin(); block != SgBitAttribute::pools.end() ; ++block )
    6806             :         {
    6807           0 :           pointer = (SgBitAttribute*)(*block);
    6808           0 :           for (unsigned i = 0; i < SgBitAttribute::pool_size; ++i )
    6809             :              {
    6810             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    6811             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    6812             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    6813             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    6814             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    6815             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    6816             :             // properly; so this will have to be checked next.
    6817             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    6818             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    6819           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    6820             :                   {
    6821           0 :                     pointer[i].set_freepointer((SgBitAttribute*)(globalIndex));
    6822           0 :                     globalIndex++;
    6823             :                   }
    6824             :                else
    6825             :                   {
    6826           0 :                     pointer[i].set_freepointer(NULL);
    6827             :                   }
    6828             :               }
    6829             :         }
    6830           5 :      return globalIndex;
    6831             :    }
    6832             : 
    6833             : //############################################################################
    6834             : // JH (01/14/2006)
    6835             : void
    6836           5 : SgBitAttribute::resetValidFreepointers( )
    6837             :    {
    6838           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    6839           5 :      SgBitAttribute* pointer = NULL;
    6840           5 :      std::vector < unsigned char* > :: const_iterator block;
    6841           5 :      SgBitAttribute* pointerOfLinkedList = NULL;
    6842           5 :      for ( block = SgBitAttribute::pools.begin(); block != SgBitAttribute::pools.end() ; ++block )
    6843             :         {
    6844           0 :           pointer = (SgBitAttribute*)(*block);
    6845           0 :           for (unsigned i = 0; i < SgBitAttribute::pool_size; ++i )
    6846             :              {
    6847             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    6848             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    6849             :             // memory blocks!.
    6850           0 :                if ( pointer[i].get_freepointer() != NULL )
    6851             :                   {
    6852           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    6853             :                   }
    6854             :                else
    6855             :                   {
    6856           0 :                     if ( pointerOfLinkedList == NULL )
    6857             :                        {
    6858           0 :                          SgBitAttribute::next_node = &(pointer[i]);
    6859             :                        }
    6860             :                     else
    6861             :                        {
    6862             :                       // printf ("In SgBitAttribute::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    6863           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    6864             :                        }
    6865             :                     pointerOfLinkedList = &(pointer[i]);
    6866             :                   }
    6867             :               }
    6868             :         }
    6869             : 
    6870           5 :      if ( pointerOfLinkedList != NULL )
    6871             :         {
    6872             :        // printf ("In SgBitAttribute::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    6873           0 :           pointerOfLinkedList->set_freepointer(NULL);
    6874             :        // DQ (6/6/2010): Temporary debugging...
    6875             :        //   ROSE_ASSERT(false);
    6876             :         }
    6877             : 
    6878           5 :      return ;
    6879             :    }
    6880             : 
    6881             : //############################################################################
    6882             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    6883             :  * within the memory pool and resets the freepointers, in order to achieve a 
    6884             :  * linked list, that has no jumps and starts at the beginning! This function 
    6885             :  * does not extend the memory pool, since we do not delete any memory blocks,
    6886             :  * but delete the valid objects.  
    6887             :  */
    6888             : void
    6889           0 : SgBitAttribute::clearMemoryPool( )
    6890             :    {
    6891             :   // printf ("Inside of SgBitAttribute::clearMemoryPool() \n");
    6892             : 
    6893           0 :      SgBitAttribute* pointer = NULL, *tempPointer = NULL;
    6894           0 :      std::vector < unsigned char* > :: const_iterator block;
    6895           0 :      if ( SgBitAttribute::pools.empty() == false )
    6896             :         {
    6897           0 :           block = SgBitAttribute::pools.begin() ;
    6898           0 :           SgBitAttribute::next_node = (SgBitAttribute*) (*block);
    6899             : 
    6900           0 :           while ( block != SgBitAttribute::pools.end() )
    6901             :              {
    6902           0 :                pointer = (SgBitAttribute*) (*block);
    6903           0 :                if ( tempPointer != NULL )
    6904             :                   {
    6905           0 :                     tempPointer->set_freepointer(pointer);
    6906             :                   }
    6907           0 :                for (unsigned i = 0; i < SgBitAttribute::pool_size - 1; ++i)
    6908             :                   {
    6909           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    6910             :                   }
    6911           0 :                 pointer[SgBitAttribute::pool_size-1].set_freepointer(NULL);
    6912           0 :                 tempPointer = &(pointer[SgBitAttribute::pool_size-1]);
    6913           0 :                 ++block;
    6914             :              }
    6915             :         }
    6916           0 :    }
    6917             : 
    6918           5 : void SgBitAttribute::deleteMemoryPool() {
    6919           5 :   for (auto p: SgBitAttribute::pools) {
    6920           0 :     ROSE_FREE(p);
    6921             :   }
    6922           5 :   SgBitAttribute::next_node = nullptr;
    6923           5 :   SgBitAttribute::pools.clear();
    6924           5 : }
    6925             : 
    6926             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    6927             : //                 reading multiple binary files to for a single AST.
    6928             : /////////// new version ////////////////////////////////
    6929             : //############################################################################
    6930             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    6931             : void
    6932           2 : SgBitAttribute::extendMemoryPoolForFileIO( )
    6933             :   {
    6934           2 :     size_t blockIndex = SgBitAttribute::pools.size();
    6935           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBitAttribute) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitAttribute);
    6936             : 
    6937           2 :     while ( (blockIndex * SgBitAttribute::pool_size) < newPoolSize)
    6938             :       {
    6939             : #if ROSE_ALLOC_TRACE
    6940             :         if (blockIndex > 0) {
    6941             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBitAttribute) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitAttribute) = %" PRIuPTR " SgBitAttribute::pool_size = %d \n",
    6942             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBitAttribute),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitAttribute),SgBitAttribute::pool_size);
    6943             :         }
    6944             : #endif
    6945             : 
    6946           0 :         SgBitAttribute * pointer = (SgBitAttribute*) ROSE_MALLOC ( SgBitAttribute::pool_size * sizeof(SgBitAttribute) );
    6947           0 :         assert( pointer != NULL );
    6948             : #if ROSE_ALLOC_MEMSET == 1
    6949             :         memset(pointer, 0x00, SgBitAttribute::pool_size * sizeof(SgBitAttribute));
    6950             : #elif ROSE_ALLOC_MEMSET == 2
    6951             :         memset(pointer, 0xCC, SgBitAttribute::pool_size * sizeof(SgBitAttribute));
    6952             : #endif
    6953           0 :         SgBitAttribute::pools.push_back( (unsigned char*)(pointer) );
    6954           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBitAttribute::pool_size * sizeof(SgBitAttribute), V_SgBitAttribute ) );
    6955             : 
    6956           0 :         if ( SgBitAttribute::next_node != NULL ) {
    6957           0 :           if ( blockIndex > 0 ) {
    6958           0 :             SgBitAttribute * blkptr = (SgBitAttribute*)(SgBitAttribute::pools[blockIndex-1]);
    6959           0 :             blkptr[ SgBitAttribute::pool_size - 1 ].set_freepointer(pointer);
    6960             :           }
    6961             :         } else {
    6962           0 :           SgBitAttribute::next_node = pointer;
    6963             :         }
    6964             : 
    6965           0 :         for (unsigned i = 0; i < SgBitAttribute::pool_size-1; ++i)
    6966             :            {
    6967           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    6968             :            }
    6969           0 :         pointer[ SgBitAttribute::pool_size -1 ].set_freepointer(NULL);
    6970             : 
    6971           0 :         blockIndex++;
    6972             :       }
    6973           2 :   }
    6974             : 
    6975             : //############################################################################
    6976             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    6977             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    6978             :  * not compressed. However, that stuff is not yet implemented! 
    6979             :  */
    6980             : unsigned long
    6981           0 : SgBitAttribute::getNumberOfLastValidPointer()
    6982             :    {
    6983           0 :       SgBitAttribute* testPointer = (SgBitAttribute*)(SgBitAttribute::pools.back());
    6984           0 :       unsigned long localIndex = SgBitAttribute::pool_size - 1;
    6985           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    6986             :          {
    6987           0 :            localIndex--;
    6988             :          }
    6989           0 :       return (localIndex + SgBitAttribute::pool_size * (SgBitAttribute::pools.size()-1));
    6990             :    }
    6991             : 
    6992             : //############################################################################
    6993             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    6994             :  * memory pool and initializes the data member in class SgBitAttributeStroageClass
    6995             :  * from its counterpart of SgBitAttribute. The return value is just for checking, 
    6996             :  * that the whole StorageClassArray is initialized!
    6997             :  */
    6998             : unsigned long
    6999           0 : SgBitAttribute::initializeStorageClassArray( SgBitAttributeStorageClass *storageArray )
    7000             :    {
    7001           0 :      unsigned long storageCounter = 0;
    7002           0 :      std::vector < unsigned char* > :: const_iterator block = SgBitAttribute::pools.begin();
    7003           0 :      SgBitAttribute* pointer = NULL;
    7004           0 :      while ( block != SgBitAttribute::pools.end() ) {
    7005           0 :           pointer = (SgBitAttribute*) (*block);
    7006           0 :           for ( unsigned i = 0; i < SgBitAttribute::pool_size; ++i ) {
    7007           0 :                if ( pointer->get_freepointer() != NULL ) {
    7008           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    7009           0 :                  storageArray++;
    7010           0 :                  storageCounter++;
    7011             :                }
    7012           0 :                pointer++;
    7013             :              }
    7014           0 :            block++;
    7015             :         }
    7016           0 :      return storageCounter;
    7017             :    }
    7018             : 
    7019             : /* #line 7020 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    7020             : 
    7021             : 
    7022             : 
    7023             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    7024             : 
    7025             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    7026             : 
    7027             : //############################################################################
    7028             : /* JH (02/02/2006) Constructor of the IR node SgFuncDecl_attr that takes its 
    7029             :  * corresponding StorageClass as parameter
    7030             :  */
    7031           0 : SgFuncDecl_attr :: SgFuncDecl_attr ( const SgFuncDecl_attrStorageClass& storageSource )   : SgBitAttribute (storageSource)
    7032             :    {
    7033             : 
    7034             : 
    7035             : /* #line 7036 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    7036             : 
    7037           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    7038             : 
    7039             : 
    7040             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    7041             : 
    7042             : 
    7043           0 :    }
    7044             : 
    7045             : //############################################################################
    7046             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    7047             :  * within the working AST. 
    7048             :  */
    7049           0 : SgFuncDecl_attr * SgFuncDecl_attr::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    7050           0 :      SgFuncDecl_attr* returnPointer = NULL;
    7051           0 :      if ( globalIndex != 0 )
    7052             :         {
    7053             : 
    7054             : #if FILE_IO_EXTRA_CHECK
    7055           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFuncDecl_attr ) ) <= globalIndex ) ;
    7056           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFuncDecl_attr + 1 ) ) );
    7057             : #endif
    7058           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFuncDecl_attr )  
    7059           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFuncDecl_attr );
    7060           0 :           unsigned long positionInPool = localIndex % SgFuncDecl_attr::pool_size;
    7061           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFuncDecl_attr::pool_size;
    7062             : 
    7063             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    7064             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    7065             : 
    7066           0 :           returnPointer = &( ( (SgFuncDecl_attr*)(SgFuncDecl_attr::pools[memoryBlock]) ) [positionInPool]) ;
    7067             : 
    7068           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    7069             :         }
    7070           0 :      return returnPointer ;
    7071             :    }
    7072             : 
    7073             : //############################################################################
    7074             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    7075             :   for the AST with the index astIndex
    7076             : */
    7077           0 : SgFuncDecl_attr * SgFuncDecl_attr::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    7078           0 :      SgFuncDecl_attr* returnPointer = NULL;
    7079           0 :      if ( globalIndex != 0 )
    7080             :         {
    7081             : 
    7082             : #if FILE_IO_EXTRA_CHECK
    7083           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFuncDecl_attr ) ) <= globalIndex ) ;
    7084           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFuncDecl_attr + 1 ) ) );
    7085             : #endif
    7086           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFuncDecl_attr )
    7087           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFuncDecl_attr );
    7088           0 :           unsigned long positionInPool = localIndex % SgFuncDecl_attr::pool_size ;
    7089           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFuncDecl_attr::pool_size ;
    7090             : 
    7091             : #if FILE_IO_EXTRA_CHECK
    7092             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    7093             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    7094             : #endif
    7095             : 
    7096           0 :           returnPointer = &( ( (SgFuncDecl_attr*)(SgFuncDecl_attr::pools[memoryBlock]) ) [positionInPool]) ;
    7097             : 
    7098             : #if FILE_IO_EXTRA_CHECK
    7099           0 :           assert ( returnPointer != NULL ) ;
    7100             : #endif
    7101             :         }
    7102           0 :      return returnPointer ;
    7103             :    }
    7104             : 
    7105             : //############################################################################
    7106             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    7107             :  * pool size! We set for every valid object in the memory pool the freepointer
    7108             :  * to the global index and increase the global index afterwards. For all the 
    7109             :  * invalid objects (means address ranges within the memory pool that were not
    7110             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    7111             :  * distinguish valid from invalid objects! 
    7112             :  */
    7113             : unsigned long
    7114           5 : SgFuncDecl_attr::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    7115             :    {
    7116           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    7117           5 :      SgFuncDecl_attr* pointer = NULL;
    7118           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    7119           5 :      std::vector < unsigned char* > :: const_iterator block;
    7120           5 :      for ( block = SgFuncDecl_attr::pools.begin(); block != SgFuncDecl_attr::pools.end() ; ++block )
    7121             :         {
    7122           0 :           pointer = (SgFuncDecl_attr*)(*block);
    7123           0 :           for (unsigned i = 0; i < SgFuncDecl_attr::pool_size; ++i )
    7124             :              {
    7125             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    7126             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    7127             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    7128             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    7129             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    7130             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    7131             :             // properly; so this will have to be checked next.
    7132             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    7133             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    7134           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    7135             :                   {
    7136           0 :                     pointer[i].set_freepointer((SgFuncDecl_attr*)(globalIndex));
    7137           0 :                     globalIndex++;
    7138             :                   }
    7139             :                else
    7140             :                   {
    7141           0 :                     pointer[i].set_freepointer(NULL);
    7142             :                   }
    7143             :               }
    7144             :         }
    7145           5 :      return globalIndex;
    7146             :    }
    7147             : 
    7148             : //############################################################################
    7149             : // JH (01/14/2006)
    7150             : void
    7151           5 : SgFuncDecl_attr::resetValidFreepointers( )
    7152             :    {
    7153           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    7154           5 :      SgFuncDecl_attr* pointer = NULL;
    7155           5 :      std::vector < unsigned char* > :: const_iterator block;
    7156           5 :      SgFuncDecl_attr* pointerOfLinkedList = NULL;
    7157           5 :      for ( block = SgFuncDecl_attr::pools.begin(); block != SgFuncDecl_attr::pools.end() ; ++block )
    7158             :         {
    7159           0 :           pointer = (SgFuncDecl_attr*)(*block);
    7160           0 :           for (unsigned i = 0; i < SgFuncDecl_attr::pool_size; ++i )
    7161             :              {
    7162             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    7163             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    7164             :             // memory blocks!.
    7165           0 :                if ( pointer[i].get_freepointer() != NULL )
    7166             :                   {
    7167           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    7168             :                   }
    7169             :                else
    7170             :                   {
    7171           0 :                     if ( pointerOfLinkedList == NULL )
    7172             :                        {
    7173           0 :                          SgFuncDecl_attr::next_node = &(pointer[i]);
    7174             :                        }
    7175             :                     else
    7176             :                        {
    7177             :                       // printf ("In SgFuncDecl_attr::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    7178           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    7179             :                        }
    7180             :                     pointerOfLinkedList = &(pointer[i]);
    7181             :                   }
    7182             :               }
    7183             :         }
    7184             : 
    7185           5 :      if ( pointerOfLinkedList != NULL )
    7186             :         {
    7187             :        // printf ("In SgFuncDecl_attr::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    7188           0 :           pointerOfLinkedList->set_freepointer(NULL);
    7189             :        // DQ (6/6/2010): Temporary debugging...
    7190             :        //   ROSE_ASSERT(false);
    7191             :         }
    7192             : 
    7193           5 :      return ;
    7194             :    }
    7195             : 
    7196             : //############################################################################
    7197             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    7198             :  * within the memory pool and resets the freepointers, in order to achieve a 
    7199             :  * linked list, that has no jumps and starts at the beginning! This function 
    7200             :  * does not extend the memory pool, since we do not delete any memory blocks,
    7201             :  * but delete the valid objects.  
    7202             :  */
    7203             : void
    7204           0 : SgFuncDecl_attr::clearMemoryPool( )
    7205             :    {
    7206             :   // printf ("Inside of SgFuncDecl_attr::clearMemoryPool() \n");
    7207             : 
    7208           0 :      SgFuncDecl_attr* pointer = NULL, *tempPointer = NULL;
    7209           0 :      std::vector < unsigned char* > :: const_iterator block;
    7210           0 :      if ( SgFuncDecl_attr::pools.empty() == false )
    7211             :         {
    7212           0 :           block = SgFuncDecl_attr::pools.begin() ;
    7213           0 :           SgFuncDecl_attr::next_node = (SgFuncDecl_attr*) (*block);
    7214             : 
    7215           0 :           while ( block != SgFuncDecl_attr::pools.end() )
    7216             :              {
    7217           0 :                pointer = (SgFuncDecl_attr*) (*block);
    7218           0 :                if ( tempPointer != NULL )
    7219             :                   {
    7220           0 :                     tempPointer->set_freepointer(pointer);
    7221             :                   }
    7222           0 :                for (unsigned i = 0; i < SgFuncDecl_attr::pool_size - 1; ++i)
    7223             :                   {
    7224           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    7225             :                   }
    7226           0 :                 pointer[SgFuncDecl_attr::pool_size-1].set_freepointer(NULL);
    7227           0 :                 tempPointer = &(pointer[SgFuncDecl_attr::pool_size-1]);
    7228           0 :                 ++block;
    7229             :              }
    7230             :         }
    7231           0 :    }
    7232             : 
    7233           5 : void SgFuncDecl_attr::deleteMemoryPool() {
    7234           5 :   for (auto p: SgFuncDecl_attr::pools) {
    7235           0 :     ROSE_FREE(p);
    7236             :   }
    7237           5 :   SgFuncDecl_attr::next_node = nullptr;
    7238           5 :   SgFuncDecl_attr::pools.clear();
    7239           5 : }
    7240             : 
    7241             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    7242             : //                 reading multiple binary files to for a single AST.
    7243             : /////////// new version ////////////////////////////////
    7244             : //############################################################################
    7245             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    7246             : void
    7247           2 : SgFuncDecl_attr::extendMemoryPoolForFileIO( )
    7248             :   {
    7249           2 :     size_t blockIndex = SgFuncDecl_attr::pools.size();
    7250           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFuncDecl_attr) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFuncDecl_attr);
    7251             : 
    7252           2 :     while ( (blockIndex * SgFuncDecl_attr::pool_size) < newPoolSize)
    7253             :       {
    7254             : #if ROSE_ALLOC_TRACE
    7255             :         if (blockIndex > 0) {
    7256             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFuncDecl_attr) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFuncDecl_attr) = %" PRIuPTR " SgFuncDecl_attr::pool_size = %d \n",
    7257             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFuncDecl_attr),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFuncDecl_attr),SgFuncDecl_attr::pool_size);
    7258             :         }
    7259             : #endif
    7260             : 
    7261           0 :         SgFuncDecl_attr * pointer = (SgFuncDecl_attr*) ROSE_MALLOC ( SgFuncDecl_attr::pool_size * sizeof(SgFuncDecl_attr) );
    7262           0 :         assert( pointer != NULL );
    7263             : #if ROSE_ALLOC_MEMSET == 1
    7264             :         memset(pointer, 0x00, SgFuncDecl_attr::pool_size * sizeof(SgFuncDecl_attr));
    7265             : #elif ROSE_ALLOC_MEMSET == 2
    7266             :         memset(pointer, 0xCC, SgFuncDecl_attr::pool_size * sizeof(SgFuncDecl_attr));
    7267             : #endif
    7268           0 :         SgFuncDecl_attr::pools.push_back( (unsigned char*)(pointer) );
    7269           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFuncDecl_attr::pool_size * sizeof(SgFuncDecl_attr), V_SgFuncDecl_attr ) );
    7270             : 
    7271           0 :         if ( SgFuncDecl_attr::next_node != NULL ) {
    7272           0 :           if ( blockIndex > 0 ) {
    7273           0 :             SgFuncDecl_attr * blkptr = (SgFuncDecl_attr*)(SgFuncDecl_attr::pools[blockIndex-1]);
    7274           0 :             blkptr[ SgFuncDecl_attr::pool_size - 1 ].set_freepointer(pointer);
    7275             :           }
    7276             :         } else {
    7277           0 :           SgFuncDecl_attr::next_node = pointer;
    7278             :         }
    7279             : 
    7280           0 :         for (unsigned i = 0; i < SgFuncDecl_attr::pool_size-1; ++i)
    7281             :            {
    7282           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    7283             :            }
    7284           0 :         pointer[ SgFuncDecl_attr::pool_size -1 ].set_freepointer(NULL);
    7285             : 
    7286           0 :         blockIndex++;
    7287             :       }
    7288           2 :   }
    7289             : 
    7290             : //############################################################################
    7291             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    7292             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    7293             :  * not compressed. However, that stuff is not yet implemented! 
    7294             :  */
    7295             : unsigned long
    7296           0 : SgFuncDecl_attr::getNumberOfLastValidPointer()
    7297             :    {
    7298           0 :       SgFuncDecl_attr* testPointer = (SgFuncDecl_attr*)(SgFuncDecl_attr::pools.back());
    7299           0 :       unsigned long localIndex = SgFuncDecl_attr::pool_size - 1;
    7300           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    7301             :          {
    7302           0 :            localIndex--;
    7303             :          }
    7304           0 :       return (localIndex + SgFuncDecl_attr::pool_size * (SgFuncDecl_attr::pools.size()-1));
    7305             :    }
    7306             : 
    7307             : //############################################################################
    7308             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    7309             :  * memory pool and initializes the data member in class SgFuncDecl_attrStroageClass
    7310             :  * from its counterpart of SgFuncDecl_attr. The return value is just for checking, 
    7311             :  * that the whole StorageClassArray is initialized!
    7312             :  */
    7313             : unsigned long
    7314           0 : SgFuncDecl_attr::initializeStorageClassArray( SgFuncDecl_attrStorageClass *storageArray )
    7315             :    {
    7316           0 :      unsigned long storageCounter = 0;
    7317           0 :      std::vector < unsigned char* > :: const_iterator block = SgFuncDecl_attr::pools.begin();
    7318           0 :      SgFuncDecl_attr* pointer = NULL;
    7319           0 :      while ( block != SgFuncDecl_attr::pools.end() ) {
    7320           0 :           pointer = (SgFuncDecl_attr*) (*block);
    7321           0 :           for ( unsigned i = 0; i < SgFuncDecl_attr::pool_size; ++i ) {
    7322           0 :                if ( pointer->get_freepointer() != NULL ) {
    7323           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    7324           0 :                  storageArray++;
    7325           0 :                  storageCounter++;
    7326             :                }
    7327           0 :                pointer++;
    7328             :              }
    7329           0 :            block++;
    7330             :         }
    7331           0 :      return storageCounter;
    7332             :    }
    7333             : 
    7334             : /* #line 7335 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    7335             : 
    7336             : 
    7337             : 
    7338             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    7339             : 
    7340             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    7341             : 
    7342             : //############################################################################
    7343             : /* JH (02/02/2006) Constructor of the IR node SgClassDecl_attr that takes its 
    7344             :  * corresponding StorageClass as parameter
    7345             :  */
    7346           0 : SgClassDecl_attr :: SgClassDecl_attr ( const SgClassDecl_attrStorageClass& storageSource )   : SgBitAttribute (storageSource)
    7347             :    {
    7348             : 
    7349             : 
    7350             : /* #line 7351 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    7351             : 
    7352           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    7353             : 
    7354             : 
    7355             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    7356             : 
    7357             : 
    7358           0 :    }
    7359             : 
    7360             : //############################################################################
    7361             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    7362             :  * within the working AST. 
    7363             :  */
    7364           0 : SgClassDecl_attr * SgClassDecl_attr::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    7365           0 :      SgClassDecl_attr* returnPointer = NULL;
    7366           0 :      if ( globalIndex != 0 )
    7367             :         {
    7368             : 
    7369             : #if FILE_IO_EXTRA_CHECK
    7370           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClassDecl_attr ) ) <= globalIndex ) ;
    7371           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassDecl_attr + 1 ) ) );
    7372             : #endif
    7373           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassDecl_attr )  
    7374           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClassDecl_attr );
    7375           0 :           unsigned long positionInPool = localIndex % SgClassDecl_attr::pool_size;
    7376           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassDecl_attr::pool_size;
    7377             : 
    7378             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    7379             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    7380             : 
    7381           0 :           returnPointer = &( ( (SgClassDecl_attr*)(SgClassDecl_attr::pools[memoryBlock]) ) [positionInPool]) ;
    7382             : 
    7383           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    7384             :         }
    7385           0 :      return returnPointer ;
    7386             :    }
    7387             : 
    7388             : //############################################################################
    7389             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    7390             :   for the AST with the index astIndex
    7391             : */
    7392           0 : SgClassDecl_attr * SgClassDecl_attr::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    7393           0 :      SgClassDecl_attr* returnPointer = NULL;
    7394           0 :      if ( globalIndex != 0 )
    7395             :         {
    7396             : 
    7397             : #if FILE_IO_EXTRA_CHECK
    7398           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClassDecl_attr ) ) <= globalIndex ) ;
    7399           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassDecl_attr + 1 ) ) );
    7400             : #endif
    7401           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassDecl_attr )
    7402           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClassDecl_attr );
    7403           0 :           unsigned long positionInPool = localIndex % SgClassDecl_attr::pool_size ;
    7404           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassDecl_attr::pool_size ;
    7405             : 
    7406             : #if FILE_IO_EXTRA_CHECK
    7407             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    7408             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    7409             : #endif
    7410             : 
    7411           0 :           returnPointer = &( ( (SgClassDecl_attr*)(SgClassDecl_attr::pools[memoryBlock]) ) [positionInPool]) ;
    7412             : 
    7413             : #if FILE_IO_EXTRA_CHECK
    7414           0 :           assert ( returnPointer != NULL ) ;
    7415             : #endif
    7416             :         }
    7417           0 :      return returnPointer ;
    7418             :    }
    7419             : 
    7420             : //############################################################################
    7421             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    7422             :  * pool size! We set for every valid object in the memory pool the freepointer
    7423             :  * to the global index and increase the global index afterwards. For all the 
    7424             :  * invalid objects (means address ranges within the memory pool that were not
    7425             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    7426             :  * distinguish valid from invalid objects! 
    7427             :  */
    7428             : unsigned long
    7429           5 : SgClassDecl_attr::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    7430             :    {
    7431           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    7432           5 :      SgClassDecl_attr* pointer = NULL;
    7433           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    7434           5 :      std::vector < unsigned char* > :: const_iterator block;
    7435           5 :      for ( block = SgClassDecl_attr::pools.begin(); block != SgClassDecl_attr::pools.end() ; ++block )
    7436             :         {
    7437           0 :           pointer = (SgClassDecl_attr*)(*block);
    7438           0 :           for (unsigned i = 0; i < SgClassDecl_attr::pool_size; ++i )
    7439             :              {
    7440             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    7441             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    7442             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    7443             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    7444             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    7445             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    7446             :             // properly; so this will have to be checked next.
    7447             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    7448             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    7449           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    7450             :                   {
    7451           0 :                     pointer[i].set_freepointer((SgClassDecl_attr*)(globalIndex));
    7452           0 :                     globalIndex++;
    7453             :                   }
    7454             :                else
    7455             :                   {
    7456           0 :                     pointer[i].set_freepointer(NULL);
    7457             :                   }
    7458             :               }
    7459             :         }
    7460           5 :      return globalIndex;
    7461             :    }
    7462             : 
    7463             : //############################################################################
    7464             : // JH (01/14/2006)
    7465             : void
    7466           5 : SgClassDecl_attr::resetValidFreepointers( )
    7467             :    {
    7468           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    7469           5 :      SgClassDecl_attr* pointer = NULL;
    7470           5 :      std::vector < unsigned char* > :: const_iterator block;
    7471           5 :      SgClassDecl_attr* pointerOfLinkedList = NULL;
    7472           5 :      for ( block = SgClassDecl_attr::pools.begin(); block != SgClassDecl_attr::pools.end() ; ++block )
    7473             :         {
    7474           0 :           pointer = (SgClassDecl_attr*)(*block);
    7475           0 :           for (unsigned i = 0; i < SgClassDecl_attr::pool_size; ++i )
    7476             :              {
    7477             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    7478             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    7479             :             // memory blocks!.
    7480           0 :                if ( pointer[i].get_freepointer() != NULL )
    7481             :                   {
    7482           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    7483             :                   }
    7484             :                else
    7485             :                   {
    7486           0 :                     if ( pointerOfLinkedList == NULL )
    7487             :                        {
    7488           0 :                          SgClassDecl_attr::next_node = &(pointer[i]);
    7489             :                        }
    7490             :                     else
    7491             :                        {
    7492             :                       // printf ("In SgClassDecl_attr::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    7493           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    7494             :                        }
    7495             :                     pointerOfLinkedList = &(pointer[i]);
    7496             :                   }
    7497             :               }
    7498             :         }
    7499             : 
    7500           5 :      if ( pointerOfLinkedList != NULL )
    7501             :         {
    7502             :        // printf ("In SgClassDecl_attr::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    7503           0 :           pointerOfLinkedList->set_freepointer(NULL);
    7504             :        // DQ (6/6/2010): Temporary debugging...
    7505             :        //   ROSE_ASSERT(false);
    7506             :         }
    7507             : 
    7508           5 :      return ;
    7509             :    }
    7510             : 
    7511             : //############################################################################
    7512             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    7513             :  * within the memory pool and resets the freepointers, in order to achieve a 
    7514             :  * linked list, that has no jumps and starts at the beginning! This function 
    7515             :  * does not extend the memory pool, since we do not delete any memory blocks,
    7516             :  * but delete the valid objects.  
    7517             :  */
    7518             : void
    7519           0 : SgClassDecl_attr::clearMemoryPool( )
    7520             :    {
    7521             :   // printf ("Inside of SgClassDecl_attr::clearMemoryPool() \n");
    7522             : 
    7523           0 :      SgClassDecl_attr* pointer = NULL, *tempPointer = NULL;
    7524           0 :      std::vector < unsigned char* > :: const_iterator block;
    7525           0 :      if ( SgClassDecl_attr::pools.empty() == false )
    7526             :         {
    7527           0 :           block = SgClassDecl_attr::pools.begin() ;
    7528           0 :           SgClassDecl_attr::next_node = (SgClassDecl_attr*) (*block);
    7529             : 
    7530           0 :           while ( block != SgClassDecl_attr::pools.end() )
    7531             :              {
    7532           0 :                pointer = (SgClassDecl_attr*) (*block);
    7533           0 :                if ( tempPointer != NULL )
    7534             :                   {
    7535           0 :                     tempPointer->set_freepointer(pointer);
    7536             :                   }
    7537           0 :                for (unsigned i = 0; i < SgClassDecl_attr::pool_size - 1; ++i)
    7538             :                   {
    7539           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    7540             :                   }
    7541           0 :                 pointer[SgClassDecl_attr::pool_size-1].set_freepointer(NULL);
    7542           0 :                 tempPointer = &(pointer[SgClassDecl_attr::pool_size-1]);
    7543           0 :                 ++block;
    7544             :              }
    7545             :         }
    7546           0 :    }
    7547             : 
    7548           5 : void SgClassDecl_attr::deleteMemoryPool() {
    7549           5 :   for (auto p: SgClassDecl_attr::pools) {
    7550           0 :     ROSE_FREE(p);
    7551             :   }
    7552           5 :   SgClassDecl_attr::next_node = nullptr;
    7553           5 :   SgClassDecl_attr::pools.clear();
    7554           5 : }
    7555             : 
    7556             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    7557             : //                 reading multiple binary files to for a single AST.
    7558             : /////////// new version ////////////////////////////////
    7559             : //############################################################################
    7560             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    7561             : void
    7562           2 : SgClassDecl_attr::extendMemoryPoolForFileIO( )
    7563             :   {
    7564           2 :     size_t blockIndex = SgClassDecl_attr::pools.size();
    7565           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDecl_attr) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDecl_attr);
    7566             : 
    7567           2 :     while ( (blockIndex * SgClassDecl_attr::pool_size) < newPoolSize)
    7568             :       {
    7569             : #if ROSE_ALLOC_TRACE
    7570             :         if (blockIndex > 0) {
    7571             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDecl_attr) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDecl_attr) = %" PRIuPTR " SgClassDecl_attr::pool_size = %d \n",
    7572             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDecl_attr),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDecl_attr),SgClassDecl_attr::pool_size);
    7573             :         }
    7574             : #endif
    7575             : 
    7576           0 :         SgClassDecl_attr * pointer = (SgClassDecl_attr*) ROSE_MALLOC ( SgClassDecl_attr::pool_size * sizeof(SgClassDecl_attr) );
    7577           0 :         assert( pointer != NULL );
    7578             : #if ROSE_ALLOC_MEMSET == 1
    7579             :         memset(pointer, 0x00, SgClassDecl_attr::pool_size * sizeof(SgClassDecl_attr));
    7580             : #elif ROSE_ALLOC_MEMSET == 2
    7581             :         memset(pointer, 0xCC, SgClassDecl_attr::pool_size * sizeof(SgClassDecl_attr));
    7582             : #endif
    7583           0 :         SgClassDecl_attr::pools.push_back( (unsigned char*)(pointer) );
    7584           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClassDecl_attr::pool_size * sizeof(SgClassDecl_attr), V_SgClassDecl_attr ) );
    7585             : 
    7586           0 :         if ( SgClassDecl_attr::next_node != NULL ) {
    7587           0 :           if ( blockIndex > 0 ) {
    7588           0 :             SgClassDecl_attr * blkptr = (SgClassDecl_attr*)(SgClassDecl_attr::pools[blockIndex-1]);
    7589           0 :             blkptr[ SgClassDecl_attr::pool_size - 1 ].set_freepointer(pointer);
    7590             :           }
    7591             :         } else {
    7592           0 :           SgClassDecl_attr::next_node = pointer;
    7593             :         }
    7594             : 
    7595           0 :         for (unsigned i = 0; i < SgClassDecl_attr::pool_size-1; ++i)
    7596             :            {
    7597           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    7598             :            }
    7599           0 :         pointer[ SgClassDecl_attr::pool_size -1 ].set_freepointer(NULL);
    7600             : 
    7601           0 :         blockIndex++;
    7602             :       }
    7603           2 :   }
    7604             : 
    7605             : //############################################################################
    7606             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    7607             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    7608             :  * not compressed. However, that stuff is not yet implemented! 
    7609             :  */
    7610             : unsigned long
    7611           0 : SgClassDecl_attr::getNumberOfLastValidPointer()
    7612             :    {
    7613           0 :       SgClassDecl_attr* testPointer = (SgClassDecl_attr*)(SgClassDecl_attr::pools.back());
    7614           0 :       unsigned long localIndex = SgClassDecl_attr::pool_size - 1;
    7615           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    7616             :          {
    7617           0 :            localIndex--;
    7618             :          }
    7619           0 :       return (localIndex + SgClassDecl_attr::pool_size * (SgClassDecl_attr::pools.size()-1));
    7620             :    }
    7621             : 
    7622             : //############################################################################
    7623             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    7624             :  * memory pool and initializes the data member in class SgClassDecl_attrStroageClass
    7625             :  * from its counterpart of SgClassDecl_attr. The return value is just for checking, 
    7626             :  * that the whole StorageClassArray is initialized!
    7627             :  */
    7628             : unsigned long
    7629           0 : SgClassDecl_attr::initializeStorageClassArray( SgClassDecl_attrStorageClass *storageArray )
    7630             :    {
    7631           0 :      unsigned long storageCounter = 0;
    7632           0 :      std::vector < unsigned char* > :: const_iterator block = SgClassDecl_attr::pools.begin();
    7633           0 :      SgClassDecl_attr* pointer = NULL;
    7634           0 :      while ( block != SgClassDecl_attr::pools.end() ) {
    7635           0 :           pointer = (SgClassDecl_attr*) (*block);
    7636           0 :           for ( unsigned i = 0; i < SgClassDecl_attr::pool_size; ++i ) {
    7637           0 :                if ( pointer->get_freepointer() != NULL ) {
    7638           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    7639           0 :                  storageArray++;
    7640           0 :                  storageCounter++;
    7641             :                }
    7642           0 :                pointer++;
    7643             :              }
    7644           0 :            block++;
    7645             :         }
    7646           0 :      return storageCounter;
    7647             :    }
    7648             : 
    7649             : /* #line 7650 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    7650             : 
    7651             : 
    7652             : 
    7653             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    7654             : 
    7655             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    7656             : 
    7657             : //############################################################################
    7658             : /* JH (02/02/2006) Constructor of the IR node Sg_File_Info that takes its 
    7659             :  * corresponding StorageClass as parameter
    7660             :  */
    7661      647979 : Sg_File_Info :: Sg_File_Info ( const Sg_File_InfoStorageClass& storageSource )   : SgSupport (storageSource)
    7662             :    {
    7663             : 
    7664             : 
    7665             : /* #line 7666 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    7666             : 
    7667      647979 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    7668      647979 :      p_file_id = storageSource.storageOf_file_id ;
    7669      647979 :      p_line = storageSource.storageOf_line ;
    7670      647979 :      p_col = storageSource.storageOf_col ;
    7671      647979 :      p_classificationBitField = storageSource.storageOf_classificationBitField ;
    7672      647979 :      p_physical_file_id = storageSource.storageOf_physical_file_id ;
    7673      647979 :      p_physical_line = storageSource.storageOf_physical_line ;
    7674      647979 :      p_source_sequence_number = storageSource.storageOf_source_sequence_number ;
    7675      647979 :      p_fileIDsToUnparse = storageSource.storageOf_fileIDsToUnparse.rebuildDataStoredInEasyStorageClass() ;
    7676      647979 :      p_fileLineNumbersToUnparse = storageSource.storageOf_fileLineNumbersToUnparse.rebuildDataStoredInEasyStorageClass() ;
    7677             : 
    7678             : 
    7679             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    7680             : 
    7681             : 
    7682      647979 :    }
    7683             : 
    7684             : //############################################################################
    7685             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    7686             :  * within the working AST. 
    7687             :  */
    7688      342726 : Sg_File_Info * Sg_File_Info::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    7689      342726 :      Sg_File_Info* returnPointer = NULL;
    7690      342726 :      if ( globalIndex != 0 )
    7691             :         {
    7692             : 
    7693             : #if FILE_IO_EXTRA_CHECK
    7694      342726 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_Sg_File_Info ) ) <= globalIndex ) ;
    7695      342726 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_Sg_File_Info + 1 ) ) );
    7696             : #endif
    7697      342726 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_Sg_File_Info )  
    7698      342726 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_Sg_File_Info );
    7699      342726 :           unsigned long positionInPool = localIndex % Sg_File_Info::pool_size;
    7700      342726 :           unsigned long memoryBlock = (localIndex - positionInPool) / Sg_File_Info::pool_size;
    7701             : 
    7702             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    7703             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    7704             : 
    7705      342726 :           returnPointer = &( ( (Sg_File_Info*)(Sg_File_Info::pools[memoryBlock]) ) [positionInPool]) ;
    7706             : 
    7707      342726 :           ROSE_ASSERT( returnPointer != NULL ) ;
    7708             :         }
    7709      342726 :      return returnPointer ;
    7710             :    }
    7711             : 
    7712             : //############################################################################
    7713             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    7714             :   for the AST with the index astIndex
    7715             : */
    7716           0 : Sg_File_Info * Sg_File_Info::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    7717           0 :      Sg_File_Info* returnPointer = NULL;
    7718           0 :      if ( globalIndex != 0 )
    7719             :         {
    7720             : 
    7721             : #if FILE_IO_EXTRA_CHECK
    7722           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_Sg_File_Info ) ) <= globalIndex ) ;
    7723           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_Sg_File_Info + 1 ) ) );
    7724             : #endif
    7725           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_Sg_File_Info )
    7726           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_Sg_File_Info );
    7727           0 :           unsigned long positionInPool = localIndex % Sg_File_Info::pool_size ;
    7728           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / Sg_File_Info::pool_size ;
    7729             : 
    7730             : #if FILE_IO_EXTRA_CHECK
    7731             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    7732             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    7733             : #endif
    7734             : 
    7735           0 :           returnPointer = &( ( (Sg_File_Info*)(Sg_File_Info::pools[memoryBlock]) ) [positionInPool]) ;
    7736             : 
    7737             : #if FILE_IO_EXTRA_CHECK
    7738           0 :           assert ( returnPointer != NULL ) ;
    7739             : #endif
    7740             :         }
    7741           0 :      return returnPointer ;
    7742             :    }
    7743             : 
    7744             : //############################################################################
    7745             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    7746             :  * pool size! We set for every valid object in the memory pool the freepointer
    7747             :  * to the global index and increase the global index afterwards. For all the 
    7748             :  * invalid objects (means address ranges within the memory pool that were not
    7749             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    7750             :  * distinguish valid from invalid objects! 
    7751             :  */
    7752             : unsigned long
    7753           5 : Sg_File_Info::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    7754             :    {
    7755           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    7756           5 :      Sg_File_Info* pointer = NULL;
    7757           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    7758           5 :      std::vector < unsigned char* > :: const_iterator block;
    7759         333 :      for ( block = Sg_File_Info::pools.begin(); block != Sg_File_Info::pools.end() ; ++block )
    7760             :         {
    7761         328 :           pointer = (Sg_File_Info*)(*block);
    7762      656328 :           for (unsigned i = 0; i < Sg_File_Info::pool_size; ++i )
    7763             :              {
    7764             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    7765             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    7766             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    7767             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    7768             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    7769             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    7770             :             // properly; so this will have to be checked next.
    7771             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    7772             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    7773      656000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    7774             :                   {
    7775      648019 :                     pointer[i].set_freepointer((Sg_File_Info*)(globalIndex));
    7776      648019 :                     globalIndex++;
    7777             :                   }
    7778             :                else
    7779             :                   {
    7780        7981 :                     pointer[i].set_freepointer(NULL);
    7781             :                   }
    7782             :               }
    7783             :         }
    7784           5 :      return globalIndex;
    7785             :    }
    7786             : 
    7787             : //############################################################################
    7788             : // JH (01/14/2006)
    7789             : void
    7790           5 : Sg_File_Info::resetValidFreepointers( )
    7791             :    {
    7792           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    7793           5 :      Sg_File_Info* pointer = NULL;
    7794           5 :      std::vector < unsigned char* > :: const_iterator block;
    7795           5 :      Sg_File_Info* pointerOfLinkedList = NULL;
    7796         333 :      for ( block = Sg_File_Info::pools.begin(); block != Sg_File_Info::pools.end() ; ++block )
    7797             :         {
    7798         328 :           pointer = (Sg_File_Info*)(*block);
    7799      656328 :           for (unsigned i = 0; i < Sg_File_Info::pool_size; ++i )
    7800             :              {
    7801             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    7802             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    7803             :             // memory blocks!.
    7804      656000 :                if ( pointer[i].get_freepointer() != NULL )
    7805             :                   {
    7806      648019 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    7807             :                   }
    7808             :                else
    7809             :                   {
    7810        7981 :                     if ( pointerOfLinkedList == NULL )
    7811             :                        {
    7812           5 :                          Sg_File_Info::next_node = &(pointer[i]);
    7813             :                        }
    7814             :                     else
    7815             :                        {
    7816             :                       // printf ("In Sg_File_Info::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    7817        7976 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    7818             :                        }
    7819             :                     pointerOfLinkedList = &(pointer[i]);
    7820             :                   }
    7821             :               }
    7822             :         }
    7823             : 
    7824           5 :      if ( pointerOfLinkedList != NULL )
    7825             :         {
    7826             :        // printf ("In Sg_File_Info::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    7827           5 :           pointerOfLinkedList->set_freepointer(NULL);
    7828             :        // DQ (6/6/2010): Temporary debugging...
    7829             :        //   ROSE_ASSERT(false);
    7830             :         }
    7831             : 
    7832           5 :      return ;
    7833             :    }
    7834             : 
    7835             : //############################################################################
    7836             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    7837             :  * within the memory pool and resets the freepointers, in order to achieve a 
    7838             :  * linked list, that has no jumps and starts at the beginning! This function 
    7839             :  * does not extend the memory pool, since we do not delete any memory blocks,
    7840             :  * but delete the valid objects.  
    7841             :  */
    7842             : void
    7843           0 : Sg_File_Info::clearMemoryPool( )
    7844             :    {
    7845             :   // printf ("Inside of Sg_File_Info::clearMemoryPool() \n");
    7846             : 
    7847           0 :      Sg_File_Info* pointer = NULL, *tempPointer = NULL;
    7848           0 :      std::vector < unsigned char* > :: const_iterator block;
    7849           0 :      if ( Sg_File_Info::pools.empty() == false )
    7850             :         {
    7851           0 :           block = Sg_File_Info::pools.begin() ;
    7852           0 :           Sg_File_Info::next_node = (Sg_File_Info*) (*block);
    7853             : 
    7854           0 :           while ( block != Sg_File_Info::pools.end() )
    7855             :              {
    7856           0 :                pointer = (Sg_File_Info*) (*block);
    7857           0 :                if ( tempPointer != NULL )
    7858             :                   {
    7859           0 :                     tempPointer->set_freepointer(pointer);
    7860             :                   }
    7861           0 :                for (unsigned i = 0; i < Sg_File_Info::pool_size - 1; ++i)
    7862             :                   {
    7863           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    7864             :                   }
    7865           0 :                 pointer[Sg_File_Info::pool_size-1].set_freepointer(NULL);
    7866           0 :                 tempPointer = &(pointer[Sg_File_Info::pool_size-1]);
    7867           0 :                 ++block;
    7868             :              }
    7869             :         }
    7870           0 :    }
    7871             : 
    7872           5 : void Sg_File_Info::deleteMemoryPool() {
    7873         656 :   for (auto p: Sg_File_Info::pools) {
    7874         651 :     ROSE_FREE(p);
    7875             :   }
    7876           5 :   Sg_File_Info::next_node = nullptr;
    7877           5 :   Sg_File_Info::pools.clear();
    7878           5 : }
    7879             : 
    7880             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    7881             : //                 reading multiple binary files to for a single AST.
    7882             : /////////// new version ////////////////////////////////
    7883             : //############################################################################
    7884             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    7885             : void
    7886           2 : Sg_File_Info::extendMemoryPoolForFileIO( )
    7887             :   {
    7888           2 :     size_t blockIndex = Sg_File_Info::pools.size();
    7889           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_Sg_File_Info) + AST_FILE_IO::getPoolSizeOfNewAst(V_Sg_File_Info);
    7890             : 
    7891         325 :     while ( (blockIndex * Sg_File_Info::pool_size) < newPoolSize)
    7892             :       {
    7893             : #if ROSE_ALLOC_TRACE
    7894             :         if (blockIndex > 0) {
    7895             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_Sg_File_Info) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_Sg_File_Info) = %" PRIuPTR " Sg_File_Info::pool_size = %d \n",
    7896             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_Sg_File_Info),AST_FILE_IO::getPoolSizeOfNewAst(V_Sg_File_Info),Sg_File_Info::pool_size);
    7897             :         }
    7898             : #endif
    7899             : 
    7900         323 :         Sg_File_Info * pointer = (Sg_File_Info*) ROSE_MALLOC ( Sg_File_Info::pool_size * sizeof(Sg_File_Info) );
    7901         323 :         assert( pointer != NULL );
    7902             : #if ROSE_ALLOC_MEMSET == 1
    7903             :         memset(pointer, 0x00, Sg_File_Info::pool_size * sizeof(Sg_File_Info));
    7904             : #elif ROSE_ALLOC_MEMSET == 2
    7905             :         memset(pointer, 0xCC, Sg_File_Info::pool_size * sizeof(Sg_File_Info));
    7906             : #endif
    7907         323 :         Sg_File_Info::pools.push_back( (unsigned char*)(pointer) );
    7908         323 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, Sg_File_Info::pool_size * sizeof(Sg_File_Info), V_Sg_File_Info ) );
    7909             : 
    7910         323 :         if ( Sg_File_Info::next_node != NULL ) {
    7911         323 :           if ( blockIndex > 0 ) {
    7912         323 :             Sg_File_Info * blkptr = (Sg_File_Info*)(Sg_File_Info::pools[blockIndex-1]);
    7913         323 :             blkptr[ Sg_File_Info::pool_size - 1 ].set_freepointer(pointer);
    7914             :           }
    7915             :         } else {
    7916           0 :           Sg_File_Info::next_node = pointer;
    7917             :         }
    7918             : 
    7919      646000 :         for (unsigned i = 0; i < Sg_File_Info::pool_size-1; ++i)
    7920             :            {
    7921      645677 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    7922             :            }
    7923         323 :         pointer[ Sg_File_Info::pool_size -1 ].set_freepointer(NULL);
    7924             : 
    7925         323 :         blockIndex++;
    7926             :       }
    7927           2 :   }
    7928             : 
    7929             : //############################################################################
    7930             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    7931             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    7932             :  * not compressed. However, that stuff is not yet implemented! 
    7933             :  */
    7934             : unsigned long
    7935           0 : Sg_File_Info::getNumberOfLastValidPointer()
    7936             :    {
    7937           0 :       Sg_File_Info* testPointer = (Sg_File_Info*)(Sg_File_Info::pools.back());
    7938           0 :       unsigned long localIndex = Sg_File_Info::pool_size - 1;
    7939           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    7940             :          {
    7941           0 :            localIndex--;
    7942             :          }
    7943           0 :       return (localIndex + Sg_File_Info::pool_size * (Sg_File_Info::pools.size()-1));
    7944             :    }
    7945             : 
    7946             : //############################################################################
    7947             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    7948             :  * memory pool and initializes the data member in class Sg_File_InfoStroageClass
    7949             :  * from its counterpart of Sg_File_Info. The return value is just for checking, 
    7950             :  * that the whole StorageClassArray is initialized!
    7951             :  */
    7952             : unsigned long
    7953           3 : Sg_File_Info::initializeStorageClassArray( Sg_File_InfoStorageClass *storageArray )
    7954             :    {
    7955           3 :      unsigned long storageCounter = 0;
    7956           3 :      std::vector < unsigned char* > :: const_iterator block = Sg_File_Info::pools.begin();
    7957           3 :      Sg_File_Info* pointer = NULL;
    7958         329 :      while ( block != Sg_File_Info::pools.end() ) {
    7959         326 :           pointer = (Sg_File_Info*) (*block);
    7960      652326 :           for ( unsigned i = 0; i < Sg_File_Info::pool_size; ++i ) {
    7961      652000 :                if ( pointer->get_freepointer() != NULL ) {
    7962      648013 :                  storageArray->pickOutIRNodeData (pointer) ;
    7963      648013 :                  storageArray++;
    7964      648013 :                  storageCounter++;
    7965             :                }
    7966      652000 :                pointer++;
    7967             :              }
    7968         326 :            block++;
    7969             :         }
    7970           3 :      return storageCounter;
    7971             :    }
    7972             : 
    7973             : /* #line 7974 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    7974             : 
    7975             : 
    7976             : 
    7977             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    7978             : 
    7979             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    7980             : 
    7981             : //############################################################################
    7982             : /* JH (02/02/2006) Constructor of the IR node SgFile that takes its 
    7983             :  * corresponding StorageClass as parameter
    7984             :  */
    7985         197 : SgFile :: SgFile ( const SgFileStorageClass& storageSource )   : SgSupport (storageSource)
    7986             :    {
    7987             : 
    7988             : 
    7989             : /* #line 7990 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    7990             : 
    7991         197 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    7992         197 :      p_startOfConstruct =  (Sg_File_Info*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_startOfConstruct) );
    7993         197 :      p_originalCommandLineArgumentList = storageSource.storageOf_originalCommandLineArgumentList.rebuildDataStoredInEasyStorageClass() ;
    7994         197 :      p_verbose = storageSource.storageOf_verbose ;
    7995         197 :      p_output_warnings = storageSource.storageOf_output_warnings ;
    7996         197 :      p_C_only = storageSource.storageOf_C_only ;
    7997         197 :      p_Cxx_only = storageSource.storageOf_Cxx_only ;
    7998         197 :      p_Fortran_only = storageSource.storageOf_Fortran_only ;
    7999         197 :      p_CoArrayFortran_only = storageSource.storageOf_CoArrayFortran_only ;
    8000         197 :      p_upc_threads = storageSource.storageOf_upc_threads ;
    8001         197 :      p_Cuda_only = storageSource.storageOf_Cuda_only ;
    8002         197 :      p_OpenCL_only = storageSource.storageOf_OpenCL_only ;
    8003         197 :      p_requires_C_preprocessor = storageSource.storageOf_requires_C_preprocessor ;
    8004         197 :      p_inputFormat = storageSource.storageOf_inputFormat ;
    8005         197 :      p_outputFormat = storageSource.storageOf_outputFormat ;
    8006         197 :      p_backendCompileFormat = storageSource.storageOf_backendCompileFormat ;
    8007         197 :      p_fortran_implicit_none = storageSource.storageOf_fortran_implicit_none ;
    8008         197 :      p_openmp = storageSource.storageOf_openmp ;
    8009         197 :      p_openmp_parse_only = storageSource.storageOf_openmp_parse_only ;
    8010         197 :      p_openmp_ast_only = storageSource.storageOf_openmp_ast_only ;
    8011         197 :      p_openmp_lowering = storageSource.storageOf_openmp_lowering ;
    8012         197 :      p_openmp_analyzing = storageSource.storageOf_openmp_analyzing ;
    8013         197 :      p_cray_pointer_support = storageSource.storageOf_cray_pointer_support ;
    8014         197 :      p_failsafe = storageSource.storageOf_failsafe ;
    8015         197 :      p_output_parser_actions = storageSource.storageOf_output_parser_actions ;
    8016         197 :      p_exit_after_parser = storageSource.storageOf_exit_after_parser ;
    8017         197 :      p_skip_syntax_check = storageSource.storageOf_skip_syntax_check ;
    8018         197 :      p_skip_parser = storageSource.storageOf_skip_parser ;
    8019         197 :      p_relax_syntax_check = storageSource.storageOf_relax_syntax_check ;
    8020         197 :      p_skip_translation_from_edg_ast_to_rose_ast = storageSource.storageOf_skip_translation_from_edg_ast_to_rose_ast ;
    8021         197 :      p_skip_transformation = storageSource.storageOf_skip_transformation ;
    8022         197 :      p_skip_unparse = storageSource.storageOf_skip_unparse ;
    8023         197 :      p_skipfinalCompileStep = storageSource.storageOf_skipfinalCompileStep ;
    8024         197 :      p_unparse_includes = storageSource.storageOf_unparse_includes ;
    8025         197 :      p_unparse_line_directives = storageSource.storageOf_unparse_line_directives ;
    8026         197 :      p_unparse_function_calls_using_operator_syntax = storageSource.storageOf_unparse_function_calls_using_operator_syntax ;
    8027         197 :      p_unparse_function_calls_using_operator_names = storageSource.storageOf_unparse_function_calls_using_operator_names ;
    8028         197 :      p_unparse_instruction_addresses = storageSource.storageOf_unparse_instruction_addresses ;
    8029         197 :      p_unparse_raw_memory_contents = storageSource.storageOf_unparse_raw_memory_contents ;
    8030         197 :      p_unparse_binary_file_format = storageSource.storageOf_unparse_binary_file_format ;
    8031         197 :      p_outputLanguage = storageSource.storageOf_outputLanguage ;
    8032         197 :      p_inputLanguage = storageSource.storageOf_inputLanguage ;
    8033         197 :      p_sourceFileNameWithPath = storageSource.storageOf_sourceFileNameWithPath.rebuildDataStoredInEasyStorageClass() ;
    8034         197 :      p_sourceFileNameWithoutPath = storageSource.storageOf_sourceFileNameWithoutPath.rebuildDataStoredInEasyStorageClass() ;
    8035         197 :      p_unparse_output_filename = storageSource.storageOf_unparse_output_filename.rebuildDataStoredInEasyStorageClass() ;
    8036         197 :      p_objectFileNameWithPath = storageSource.storageOf_objectFileNameWithPath.rebuildDataStoredInEasyStorageClass() ;
    8037         197 :      p_objectFileNameWithoutPath = storageSource.storageOf_objectFileNameWithoutPath.rebuildDataStoredInEasyStorageClass() ;
    8038         197 :      p_useBackendOnly = storageSource.storageOf_useBackendOnly ;
    8039         197 :      p_compileOnly = storageSource.storageOf_compileOnly ;
    8040         197 :      p_savedFrontendCommandLine = storageSource.storageOf_savedFrontendCommandLine.rebuildDataStoredInEasyStorageClass() ;
    8041         197 :      p_no_implicit_templates = storageSource.storageOf_no_implicit_templates ;
    8042         197 :      p_no_implicit_inline_templates = storageSource.storageOf_no_implicit_inline_templates ;
    8043         197 :      p_skip_commentsAndDirectives = storageSource.storageOf_skip_commentsAndDirectives ;
    8044         197 :      p_collectAllCommentsAndDirectives = storageSource.storageOf_collectAllCommentsAndDirectives ;
    8045         197 :      p_translateCommentsAndDirectivesIntoAST = storageSource.storageOf_translateCommentsAndDirectivesIntoAST ;
    8046         197 :      p_unparseHeaderFiles = storageSource.storageOf_unparseHeaderFiles ;
    8047         197 :      p_preprocessorDirectivesAndCommentsList = storageSource.storageOf_preprocessorDirectivesAndCommentsList.rebuildDataStoredInEasyStorageClass() ;
    8048         197 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
    8049         197 :      p_KCC_frontend = storageSource.storageOf_KCC_frontend ;
    8050         197 :      p_new_frontend = storageSource.storageOf_new_frontend ;
    8051         197 :      p_disable_edg_backend = storageSource.storageOf_disable_edg_backend ;
    8052         197 :      p_disable_sage_backend = storageSource.storageOf_disable_sage_backend ;
    8053         197 :      p_testingLevel = storageSource.storageOf_testingLevel ;
    8054         197 :      p_preinit_il = storageSource.storageOf_preinit_il ;
    8055         197 :      p_enable_cp_backend = storageSource.storageOf_enable_cp_backend ;
    8056         197 :      p_markGeneratedFiles = storageSource.storageOf_markGeneratedFiles ;
    8057         197 :      p_negative_test = storageSource.storageOf_negative_test ;
    8058         197 :      p_strict_language_handling = storageSource.storageOf_strict_language_handling ;
    8059         197 :      p_wave = storageSource.storageOf_wave ;
    8060         197 :      p_embedColorCodesInGeneratedCode = storageSource.storageOf_embedColorCodesInGeneratedCode ;
    8061         197 :      p_generateSourcePositionCodes = storageSource.storageOf_generateSourcePositionCodes ;
    8062         197 :      p_sourceFileUsesCppFileExtension = storageSource.storageOf_sourceFileUsesCppFileExtension ;
    8063         197 :      p_sourceFileUsesFortranFileExtension = storageSource.storageOf_sourceFileUsesFortranFileExtension ;
    8064         197 :      p_sourceFileUsesFortran77FileExtension = storageSource.storageOf_sourceFileUsesFortran77FileExtension ;
    8065         197 :      p_sourceFileUsesFortran90FileExtension = storageSource.storageOf_sourceFileUsesFortran90FileExtension ;
    8066         197 :      p_sourceFileUsesFortran95FileExtension = storageSource.storageOf_sourceFileUsesFortran95FileExtension ;
    8067         197 :      p_sourceFileUsesFortran2003FileExtension = storageSource.storageOf_sourceFileUsesFortran2003FileExtension ;
    8068         197 :      p_sourceFileUsesFortran2008FileExtension = storageSource.storageOf_sourceFileUsesFortran2008FileExtension ;
    8069         197 :      p_sourceFileUsesCoArrayFortranFileExtension = storageSource.storageOf_sourceFileUsesCoArrayFortranFileExtension ;
    8070         197 :      p_sourceFileUsesPHPFileExtension = storageSource.storageOf_sourceFileUsesPHPFileExtension ;
    8071         197 :      p_sourceFileUsesPythonFileExtension = storageSource.storageOf_sourceFileUsesPythonFileExtension ;
    8072         197 :      p_sourceFileTypeIsUnknown = storageSource.storageOf_sourceFileTypeIsUnknown ;
    8073         197 :      p_detect_dangling_pointers = storageSource.storageOf_detect_dangling_pointers ;
    8074         197 :      p_experimental_fortran_frontend = storageSource.storageOf_experimental_fortran_frontend ;
    8075         197 :      p_experimental_flang_frontend = storageSource.storageOf_experimental_flang_frontend ;
    8076         197 :      p_experimental_cuda_fortran_frontend = storageSource.storageOf_experimental_cuda_fortran_frontend ;
    8077         197 :      p_experimental_fortran_frontend_OFP_test = storageSource.storageOf_experimental_fortran_frontend_OFP_test ;
    8078         197 :      p_read_executable_file_format_only = storageSource.storageOf_read_executable_file_format_only ;
    8079         197 :      p_visualize_executable_file_format_skip_symbols = storageSource.storageOf_visualize_executable_file_format_skip_symbols ;
    8080         197 :      p_visualize_dwarf_only = storageSource.storageOf_visualize_dwarf_only ;
    8081         197 :      p_read_instructions_only = storageSource.storageOf_read_instructions_only ;
    8082         197 :      p_libraryArchiveObjectFileNameList = storageSource.storageOf_libraryArchiveObjectFileNameList.rebuildDataStoredInEasyStorageClass() ;
    8083         197 :      p_isLibraryArchive = storageSource.storageOf_isLibraryArchive ;
    8084         197 :      p_isObjectFile = storageSource.storageOf_isObjectFile ;
    8085         197 :      p_unparse_tokens = storageSource.storageOf_unparse_tokens ;
    8086         197 :      p_unparse_tokens_testing = storageSource.storageOf_unparse_tokens_testing ;
    8087         197 :      p_unparse_using_leading_and_trailing_token_mappings = storageSource.storageOf_unparse_using_leading_and_trailing_token_mappings ;
    8088         197 :      p_unparse_template_ast = storageSource.storageOf_unparse_template_ast ;
    8089         197 :      p_skipAstConsistancyTests = storageSource.storageOf_skipAstConsistancyTests ;
    8090         197 :      p_multifile_support = storageSource.storageOf_multifile_support ;
    8091         197 :      p_optimization = storageSource.storageOf_optimization ;
    8092         197 :      p_use_token_stream_to_improve_source_position_info = storageSource.storageOf_use_token_stream_to_improve_source_position_info ;
    8093         197 :      p_suppress_variable_declaration_normalization = storageSource.storageOf_suppress_variable_declaration_normalization ;
    8094         197 :      p_edg_il_to_graphviz = storageSource.storageOf_edg_il_to_graphviz ;
    8095         197 :      p_clang_il_to_graphviz = storageSource.storageOf_clang_il_to_graphviz ;
    8096         197 :      p_no_optimize_flag_for_frontend = storageSource.storageOf_no_optimize_flag_for_frontend ;
    8097         197 :      p_unparse_edg_normalized_method_ROSE_1392 = storageSource.storageOf_unparse_edg_normalized_method_ROSE_1392 ;
    8098         197 :      p_header_file_unparsing_optimization_source_file = storageSource.storageOf_header_file_unparsing_optimization_source_file ;
    8099         197 :      p_header_file_unparsing_optimization_header_file = storageSource.storageOf_header_file_unparsing_optimization_header_file ;
    8100         197 :      p_standard = storageSource.storageOf_standard ;
    8101         197 :      p_gnu_standard = storageSource.storageOf_gnu_standard ;
    8102         197 :      p_frontendErrorCode = storageSource.storageOf_frontendErrorCode ;
    8103         197 :      p_javacErrorCode = storageSource.storageOf_javacErrorCode ;
    8104         197 :      p_ecjErrorCode = storageSource.storageOf_ecjErrorCode ;
    8105         197 :      p_midendErrorCode = storageSource.storageOf_midendErrorCode ;
    8106         197 :      p_unparserErrorCode = storageSource.storageOf_unparserErrorCode ;
    8107         197 :      p_backendCompilerErrorCode = storageSource.storageOf_backendCompilerErrorCode ;
    8108         197 :      p_unparsedFileFailedCompilation = storageSource.storageOf_unparsedFileFailedCompilation ;
    8109             : 
    8110             : 
    8111             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    8112             : 
    8113             : 
    8114         197 :    }
    8115             : 
    8116             : //############################################################################
    8117             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    8118             :  * within the working AST. 
    8119             :  */
    8120           0 : SgFile * SgFile::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    8121           0 :      SgFile* returnPointer = NULL;
    8122           0 :      if ( globalIndex != 0 )
    8123             :         {
    8124             : 
    8125             : #if FILE_IO_EXTRA_CHECK
    8126           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFile ) ) <= globalIndex ) ;
    8127           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFile + 1 ) ) );
    8128             : #endif
    8129           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFile )  
    8130           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFile );
    8131           0 :           unsigned long positionInPool = localIndex % SgFile::pool_size;
    8132           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFile::pool_size;
    8133             : 
    8134             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    8135             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    8136             : 
    8137           0 :           returnPointer = &( ( (SgFile*)(SgFile::pools[memoryBlock]) ) [positionInPool]) ;
    8138             : 
    8139           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    8140             :         }
    8141           0 :      return returnPointer ;
    8142             :    }
    8143             : 
    8144             : //############################################################################
    8145             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    8146             :   for the AST with the index astIndex
    8147             : */
    8148           0 : SgFile * SgFile::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    8149           0 :      SgFile* returnPointer = NULL;
    8150           0 :      if ( globalIndex != 0 )
    8151             :         {
    8152             : 
    8153             : #if FILE_IO_EXTRA_CHECK
    8154           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFile ) ) <= globalIndex ) ;
    8155           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFile + 1 ) ) );
    8156             : #endif
    8157           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFile )
    8158           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFile );
    8159           0 :           unsigned long positionInPool = localIndex % SgFile::pool_size ;
    8160           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFile::pool_size ;
    8161             : 
    8162             : #if FILE_IO_EXTRA_CHECK
    8163             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    8164             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    8165             : #endif
    8166             : 
    8167           0 :           returnPointer = &( ( (SgFile*)(SgFile::pools[memoryBlock]) ) [positionInPool]) ;
    8168             : 
    8169             : #if FILE_IO_EXTRA_CHECK
    8170           0 :           assert ( returnPointer != NULL ) ;
    8171             : #endif
    8172             :         }
    8173           0 :      return returnPointer ;
    8174             :    }
    8175             : 
    8176             : //############################################################################
    8177             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    8178             :  * pool size! We set for every valid object in the memory pool the freepointer
    8179             :  * to the global index and increase the global index afterwards. For all the 
    8180             :  * invalid objects (means address ranges within the memory pool that were not
    8181             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    8182             :  * distinguish valid from invalid objects! 
    8183             :  */
    8184             : unsigned long
    8185           5 : SgFile::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    8186             :    {
    8187           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    8188           5 :      SgFile* pointer = NULL;
    8189           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    8190           5 :      std::vector < unsigned char* > :: const_iterator block;
    8191           5 :      for ( block = SgFile::pools.begin(); block != SgFile::pools.end() ; ++block )
    8192             :         {
    8193           0 :           pointer = (SgFile*)(*block);
    8194           0 :           for (unsigned i = 0; i < SgFile::pool_size; ++i )
    8195             :              {
    8196             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    8197             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    8198             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    8199             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    8200             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    8201             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    8202             :             // properly; so this will have to be checked next.
    8203             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    8204             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    8205           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    8206             :                   {
    8207           0 :                     pointer[i].set_freepointer((SgFile*)(globalIndex));
    8208           0 :                     globalIndex++;
    8209             :                   }
    8210             :                else
    8211             :                   {
    8212           0 :                     pointer[i].set_freepointer(NULL);
    8213             :                   }
    8214             :               }
    8215             :         }
    8216           5 :      return globalIndex;
    8217             :    }
    8218             : 
    8219             : //############################################################################
    8220             : // JH (01/14/2006)
    8221             : void
    8222           5 : SgFile::resetValidFreepointers( )
    8223             :    {
    8224           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    8225           5 :      SgFile* pointer = NULL;
    8226           5 :      std::vector < unsigned char* > :: const_iterator block;
    8227           5 :      SgFile* pointerOfLinkedList = NULL;
    8228           5 :      for ( block = SgFile::pools.begin(); block != SgFile::pools.end() ; ++block )
    8229             :         {
    8230           0 :           pointer = (SgFile*)(*block);
    8231           0 :           for (unsigned i = 0; i < SgFile::pool_size; ++i )
    8232             :              {
    8233             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    8234             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    8235             :             // memory blocks!.
    8236           0 :                if ( pointer[i].get_freepointer() != NULL )
    8237             :                   {
    8238           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    8239             :                   }
    8240             :                else
    8241             :                   {
    8242           0 :                     if ( pointerOfLinkedList == NULL )
    8243             :                        {
    8244           0 :                          SgFile::next_node = &(pointer[i]);
    8245             :                        }
    8246             :                     else
    8247             :                        {
    8248             :                       // printf ("In SgFile::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    8249           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    8250             :                        }
    8251             :                     pointerOfLinkedList = &(pointer[i]);
    8252             :                   }
    8253             :               }
    8254             :         }
    8255             : 
    8256           5 :      if ( pointerOfLinkedList != NULL )
    8257             :         {
    8258             :        // printf ("In SgFile::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    8259           0 :           pointerOfLinkedList->set_freepointer(NULL);
    8260             :        // DQ (6/6/2010): Temporary debugging...
    8261             :        //   ROSE_ASSERT(false);
    8262             :         }
    8263             : 
    8264           5 :      return ;
    8265             :    }
    8266             : 
    8267             : //############################################################################
    8268             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    8269             :  * within the memory pool and resets the freepointers, in order to achieve a 
    8270             :  * linked list, that has no jumps and starts at the beginning! This function 
    8271             :  * does not extend the memory pool, since we do not delete any memory blocks,
    8272             :  * but delete the valid objects.  
    8273             :  */
    8274             : void
    8275           0 : SgFile::clearMemoryPool( )
    8276             :    {
    8277             :   // printf ("Inside of SgFile::clearMemoryPool() \n");
    8278             : 
    8279           0 :      SgFile* pointer = NULL, *tempPointer = NULL;
    8280           0 :      std::vector < unsigned char* > :: const_iterator block;
    8281           0 :      if ( SgFile::pools.empty() == false )
    8282             :         {
    8283           0 :           block = SgFile::pools.begin() ;
    8284           0 :           SgFile::next_node = (SgFile*) (*block);
    8285             : 
    8286           0 :           while ( block != SgFile::pools.end() )
    8287             :              {
    8288           0 :                pointer = (SgFile*) (*block);
    8289           0 :                if ( tempPointer != NULL )
    8290             :                   {
    8291           0 :                     tempPointer->set_freepointer(pointer);
    8292             :                   }
    8293           0 :                for (unsigned i = 0; i < SgFile::pool_size - 1; ++i)
    8294             :                   {
    8295           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    8296             :                   }
    8297           0 :                 pointer[SgFile::pool_size-1].set_freepointer(NULL);
    8298           0 :                 tempPointer = &(pointer[SgFile::pool_size-1]);
    8299           0 :                 ++block;
    8300             :              }
    8301             :         }
    8302           0 :    }
    8303             : 
    8304           5 : void SgFile::deleteMemoryPool() {
    8305           5 :   for (auto p: SgFile::pools) {
    8306           0 :     ROSE_FREE(p);
    8307             :   }
    8308           5 :   SgFile::next_node = nullptr;
    8309           5 :   SgFile::pools.clear();
    8310           5 : }
    8311             : 
    8312             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    8313             : //                 reading multiple binary files to for a single AST.
    8314             : /////////// new version ////////////////////////////////
    8315             : //############################################################################
    8316             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    8317             : void
    8318           2 : SgFile::extendMemoryPoolForFileIO( )
    8319             :   {
    8320           2 :     size_t blockIndex = SgFile::pools.size();
    8321           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFile) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFile);
    8322             : 
    8323           2 :     while ( (blockIndex * SgFile::pool_size) < newPoolSize)
    8324             :       {
    8325             : #if ROSE_ALLOC_TRACE
    8326             :         if (blockIndex > 0) {
    8327             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFile) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFile) = %" PRIuPTR " SgFile::pool_size = %d \n",
    8328             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFile),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFile),SgFile::pool_size);
    8329             :         }
    8330             : #endif
    8331             : 
    8332           0 :         SgFile * pointer = (SgFile*) ROSE_MALLOC ( SgFile::pool_size * sizeof(SgFile) );
    8333           0 :         assert( pointer != NULL );
    8334             : #if ROSE_ALLOC_MEMSET == 1
    8335             :         memset(pointer, 0x00, SgFile::pool_size * sizeof(SgFile));
    8336             : #elif ROSE_ALLOC_MEMSET == 2
    8337             :         memset(pointer, 0xCC, SgFile::pool_size * sizeof(SgFile));
    8338             : #endif
    8339           0 :         SgFile::pools.push_back( (unsigned char*)(pointer) );
    8340           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFile::pool_size * sizeof(SgFile), V_SgFile ) );
    8341             : 
    8342           0 :         if ( SgFile::next_node != NULL ) {
    8343           0 :           if ( blockIndex > 0 ) {
    8344           0 :             SgFile * blkptr = (SgFile*)(SgFile::pools[blockIndex-1]);
    8345           0 :             blkptr[ SgFile::pool_size - 1 ].set_freepointer(pointer);
    8346             :           }
    8347             :         } else {
    8348           0 :           SgFile::next_node = pointer;
    8349             :         }
    8350             : 
    8351           0 :         for (unsigned i = 0; i < SgFile::pool_size-1; ++i)
    8352             :            {
    8353           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    8354             :            }
    8355           0 :         pointer[ SgFile::pool_size -1 ].set_freepointer(NULL);
    8356             : 
    8357           0 :         blockIndex++;
    8358             :       }
    8359           2 :   }
    8360             : 
    8361             : //############################################################################
    8362             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    8363             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    8364             :  * not compressed. However, that stuff is not yet implemented! 
    8365             :  */
    8366             : unsigned long
    8367           0 : SgFile::getNumberOfLastValidPointer()
    8368             :    {
    8369           0 :       SgFile* testPointer = (SgFile*)(SgFile::pools.back());
    8370           0 :       unsigned long localIndex = SgFile::pool_size - 1;
    8371           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    8372             :          {
    8373           0 :            localIndex--;
    8374             :          }
    8375           0 :       return (localIndex + SgFile::pool_size * (SgFile::pools.size()-1));
    8376             :    }
    8377             : 
    8378             : //############################################################################
    8379             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    8380             :  * memory pool and initializes the data member in class SgFileStroageClass
    8381             :  * from its counterpart of SgFile. The return value is just for checking, 
    8382             :  * that the whole StorageClassArray is initialized!
    8383             :  */
    8384             : unsigned long
    8385           0 : SgFile::initializeStorageClassArray( SgFileStorageClass *storageArray )
    8386             :    {
    8387           0 :      unsigned long storageCounter = 0;
    8388           0 :      std::vector < unsigned char* > :: const_iterator block = SgFile::pools.begin();
    8389           0 :      SgFile* pointer = NULL;
    8390           0 :      while ( block != SgFile::pools.end() ) {
    8391           0 :           pointer = (SgFile*) (*block);
    8392           0 :           for ( unsigned i = 0; i < SgFile::pool_size; ++i ) {
    8393           0 :                if ( pointer->get_freepointer() != NULL ) {
    8394           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    8395           0 :                  storageArray++;
    8396           0 :                  storageCounter++;
    8397             :                }
    8398           0 :                pointer++;
    8399             :              }
    8400           0 :            block++;
    8401             :         }
    8402           0 :      return storageCounter;
    8403             :    }
    8404             : 
    8405             : /* #line 8406 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    8406             : 
    8407             : 
    8408             : 
    8409             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    8410             : 
    8411             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    8412             : 
    8413             : //############################################################################
    8414             : /* JH (02/02/2006) Constructor of the IR node SgSourceFile that takes its 
    8415             :  * corresponding StorageClass as parameter
    8416             :  */
    8417         197 : SgSourceFile :: SgSourceFile ( const SgSourceFileStorageClass& storageSource )   : SgFile (storageSource)
    8418             :    {
    8419             : 
    8420             : 
    8421             : /* #line 8422 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    8422             : 
    8423         197 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    8424         197 :      p_globalScope =  (SgGlobal*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_globalScope) );
    8425         197 :      p_module_list = storageSource.storageOf_module_list.rebuildDataStoredInEasyStorageClass() ;
    8426         197 :      SgModuleStatementPtrList::iterator i_module_list = p_module_list.begin() ; 
    8427         197 :      for ( ; i_module_list != p_module_list.end(); ++i_module_list ) 
    8428             :         {
    8429           0 :           (*i_module_list) = (SgModuleStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_module_list) ) );
    8430             :         }
    8431         197 :      p_token_list = storageSource.storageOf_token_list.rebuildDataStoredInEasyStorageClass() ;
    8432         197 :      SgTokenPtrList::iterator i_token_list = p_token_list.begin() ; 
    8433         197 :      for ( ; i_token_list != p_token_list.end(); ++i_token_list ) 
    8434             :         {
    8435           0 :           (*i_token_list) = (SgTokenPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_token_list) ) );
    8436             :         }
    8437         197 :      p_temp_holding_scope =  (SgGlobal*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_temp_holding_scope) );
    8438         197 :      p_isHeaderFile = storageSource.storageOf_isHeaderFile ;
    8439         197 :      p_isHeaderFileIncludedMoreThanOnce = storageSource.storageOf_isHeaderFileIncludedMoreThanOnce ;
    8440         197 :      p_headerFileReport =  (SgHeaderFileReport*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_headerFileReport) );
    8441         197 :      p_extraIncludeDirectorySpecifierBeforeList = storageSource.storageOf_extraIncludeDirectorySpecifierBeforeList.rebuildDataStoredInEasyStorageClass() ;
    8442         197 :      p_extraIncludeDirectorySpecifierAfterList = storageSource.storageOf_extraIncludeDirectorySpecifierAfterList.rebuildDataStoredInEasyStorageClass() ;
    8443         197 :      p_associated_include_file =  (SgIncludeFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_associated_include_file) );
    8444         197 :      p_processedToIncludeCppDirectivesAndComments = storageSource.storageOf_processedToIncludeCppDirectivesAndComments ;
    8445         197 :      p_extra_nodes_for_namequal_init = storageSource.storageOf_extra_nodes_for_namequal_init.rebuildDataStoredInEasyStorageClass() ;
    8446         197 :      SgNodePtrList::iterator i_extra_nodes_for_namequal_init = p_extra_nodes_for_namequal_init.begin() ; 
    8447         197 :      for ( ; i_extra_nodes_for_namequal_init != p_extra_nodes_for_namequal_init.end(); ++i_extra_nodes_for_namequal_init ) 
    8448             :         {
    8449           0 :           (*i_extra_nodes_for_namequal_init) = (SgNodePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_extra_nodes_for_namequal_init) ) );
    8450             :         }
    8451         197 :      p_isDynamicLibrary = storageSource.storageOf_isDynamicLibrary ;
    8452             : 
    8453             : 
    8454             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    8455             : 
    8456             : 
    8457         197 :    }
    8458             : 
    8459             : //############################################################################
    8460             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    8461             :  * within the working AST. 
    8462             :  */
    8463         624 : SgSourceFile * SgSourceFile::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    8464         624 :      SgSourceFile* returnPointer = NULL;
    8465         624 :      if ( globalIndex != 0 )
    8466             :         {
    8467             : 
    8468             : #if FILE_IO_EXTRA_CHECK
    8469         624 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSourceFile ) ) <= globalIndex ) ;
    8470         624 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSourceFile + 1 ) ) );
    8471             : #endif
    8472         624 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSourceFile )  
    8473         624 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSourceFile );
    8474         624 :           unsigned long positionInPool = localIndex % SgSourceFile::pool_size;
    8475         624 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSourceFile::pool_size;
    8476             : 
    8477             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    8478             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    8479             : 
    8480         624 :           returnPointer = &( ( (SgSourceFile*)(SgSourceFile::pools[memoryBlock]) ) [positionInPool]) ;
    8481             : 
    8482         624 :           ROSE_ASSERT( returnPointer != NULL ) ;
    8483             :         }
    8484         624 :      return returnPointer ;
    8485             :    }
    8486             : 
    8487             : //############################################################################
    8488             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    8489             :   for the AST with the index astIndex
    8490             : */
    8491           0 : SgSourceFile * SgSourceFile::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    8492           0 :      SgSourceFile* returnPointer = NULL;
    8493           0 :      if ( globalIndex != 0 )
    8494             :         {
    8495             : 
    8496             : #if FILE_IO_EXTRA_CHECK
    8497           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSourceFile ) ) <= globalIndex ) ;
    8498           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSourceFile + 1 ) ) );
    8499             : #endif
    8500           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSourceFile )
    8501           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSourceFile );
    8502           0 :           unsigned long positionInPool = localIndex % SgSourceFile::pool_size ;
    8503           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSourceFile::pool_size ;
    8504             : 
    8505             : #if FILE_IO_EXTRA_CHECK
    8506             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    8507             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    8508             : #endif
    8509             : 
    8510           0 :           returnPointer = &( ( (SgSourceFile*)(SgSourceFile::pools[memoryBlock]) ) [positionInPool]) ;
    8511             : 
    8512             : #if FILE_IO_EXTRA_CHECK
    8513           0 :           assert ( returnPointer != NULL ) ;
    8514             : #endif
    8515             :         }
    8516           0 :      return returnPointer ;
    8517             :    }
    8518             : 
    8519             : //############################################################################
    8520             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    8521             :  * pool size! We set for every valid object in the memory pool the freepointer
    8522             :  * to the global index and increase the global index afterwards. For all the 
    8523             :  * invalid objects (means address ranges within the memory pool that were not
    8524             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    8525             :  * distinguish valid from invalid objects! 
    8526             :  */
    8527             : unsigned long
    8528           5 : SgSourceFile::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    8529             :    {
    8530           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    8531           5 :      SgSourceFile* pointer = NULL;
    8532           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    8533           5 :      std::vector < unsigned char* > :: const_iterator block;
    8534           8 :      for ( block = SgSourceFile::pools.begin(); block != SgSourceFile::pools.end() ; ++block )
    8535             :         {
    8536           3 :           pointer = (SgSourceFile*)(*block);
    8537        6003 :           for (unsigned i = 0; i < SgSourceFile::pool_size; ++i )
    8538             :              {
    8539             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    8540             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    8541             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    8542             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    8543             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    8544             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    8545             :             // properly; so this will have to be checked next.
    8546             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    8547             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    8548        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    8549             :                   {
    8550         198 :                     pointer[i].set_freepointer((SgSourceFile*)(globalIndex));
    8551         198 :                     globalIndex++;
    8552             :                   }
    8553             :                else
    8554             :                   {
    8555        5802 :                     pointer[i].set_freepointer(NULL);
    8556             :                   }
    8557             :               }
    8558             :         }
    8559           5 :      return globalIndex;
    8560             :    }
    8561             : 
    8562             : //############################################################################
    8563             : // JH (01/14/2006)
    8564             : void
    8565           5 : SgSourceFile::resetValidFreepointers( )
    8566             :    {
    8567           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    8568           5 :      SgSourceFile* pointer = NULL;
    8569           5 :      std::vector < unsigned char* > :: const_iterator block;
    8570           5 :      SgSourceFile* pointerOfLinkedList = NULL;
    8571           8 :      for ( block = SgSourceFile::pools.begin(); block != SgSourceFile::pools.end() ; ++block )
    8572             :         {
    8573           3 :           pointer = (SgSourceFile*)(*block);
    8574        6003 :           for (unsigned i = 0; i < SgSourceFile::pool_size; ++i )
    8575             :              {
    8576             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    8577             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    8578             :             // memory blocks!.
    8579        6000 :                if ( pointer[i].get_freepointer() != NULL )
    8580             :                   {
    8581         198 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    8582             :                   }
    8583             :                else
    8584             :                   {
    8585        5802 :                     if ( pointerOfLinkedList == NULL )
    8586             :                        {
    8587           3 :                          SgSourceFile::next_node = &(pointer[i]);
    8588             :                        }
    8589             :                     else
    8590             :                        {
    8591             :                       // printf ("In SgSourceFile::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    8592        5799 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    8593             :                        }
    8594             :                     pointerOfLinkedList = &(pointer[i]);
    8595             :                   }
    8596             :               }
    8597             :         }
    8598             : 
    8599           5 :      if ( pointerOfLinkedList != NULL )
    8600             :         {
    8601             :        // printf ("In SgSourceFile::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    8602           3 :           pointerOfLinkedList->set_freepointer(NULL);
    8603             :        // DQ (6/6/2010): Temporary debugging...
    8604             :        //   ROSE_ASSERT(false);
    8605             :         }
    8606             : 
    8607           5 :      return ;
    8608             :    }
    8609             : 
    8610             : //############################################################################
    8611             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    8612             :  * within the memory pool and resets the freepointers, in order to achieve a 
    8613             :  * linked list, that has no jumps and starts at the beginning! This function 
    8614             :  * does not extend the memory pool, since we do not delete any memory blocks,
    8615             :  * but delete the valid objects.  
    8616             :  */
    8617             : void
    8618           0 : SgSourceFile::clearMemoryPool( )
    8619             :    {
    8620             :   // printf ("Inside of SgSourceFile::clearMemoryPool() \n");
    8621             : 
    8622           0 :      SgSourceFile* pointer = NULL, *tempPointer = NULL;
    8623           0 :      std::vector < unsigned char* > :: const_iterator block;
    8624           0 :      if ( SgSourceFile::pools.empty() == false )
    8625             :         {
    8626           0 :           block = SgSourceFile::pools.begin() ;
    8627           0 :           SgSourceFile::next_node = (SgSourceFile*) (*block);
    8628             : 
    8629           0 :           while ( block != SgSourceFile::pools.end() )
    8630             :              {
    8631           0 :                pointer = (SgSourceFile*) (*block);
    8632           0 :                if ( tempPointer != NULL )
    8633             :                   {
    8634           0 :                     tempPointer->set_freepointer(pointer);
    8635             :                   }
    8636           0 :                for (unsigned i = 0; i < SgSourceFile::pool_size - 1; ++i)
    8637             :                   {
    8638           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    8639             :                   }
    8640           0 :                 pointer[SgSourceFile::pool_size-1].set_freepointer(NULL);
    8641           0 :                 tempPointer = &(pointer[SgSourceFile::pool_size-1]);
    8642           0 :                 ++block;
    8643             :              }
    8644             :         }
    8645           0 :    }
    8646             : 
    8647           5 : void SgSourceFile::deleteMemoryPool() {
    8648          10 :   for (auto p: SgSourceFile::pools) {
    8649           5 :     ROSE_FREE(p);
    8650             :   }
    8651           5 :   SgSourceFile::next_node = nullptr;
    8652           5 :   SgSourceFile::pools.clear();
    8653           5 : }
    8654             : 
    8655             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    8656             : //                 reading multiple binary files to for a single AST.
    8657             : /////////// new version ////////////////////////////////
    8658             : //############################################################################
    8659             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    8660             : void
    8661           2 : SgSourceFile::extendMemoryPoolForFileIO( )
    8662             :   {
    8663           2 :     size_t blockIndex = SgSourceFile::pools.size();
    8664           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSourceFile) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSourceFile);
    8665             : 
    8666           4 :     while ( (blockIndex * SgSourceFile::pool_size) < newPoolSize)
    8667             :       {
    8668             : #if ROSE_ALLOC_TRACE
    8669             :         if (blockIndex > 0) {
    8670             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSourceFile) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSourceFile) = %" PRIuPTR " SgSourceFile::pool_size = %d \n",
    8671             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSourceFile),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSourceFile),SgSourceFile::pool_size);
    8672             :         }
    8673             : #endif
    8674             : 
    8675           2 :         SgSourceFile * pointer = (SgSourceFile*) ROSE_MALLOC ( SgSourceFile::pool_size * sizeof(SgSourceFile) );
    8676           2 :         assert( pointer != NULL );
    8677             : #if ROSE_ALLOC_MEMSET == 1
    8678             :         memset(pointer, 0x00, SgSourceFile::pool_size * sizeof(SgSourceFile));
    8679             : #elif ROSE_ALLOC_MEMSET == 2
    8680             :         memset(pointer, 0xCC, SgSourceFile::pool_size * sizeof(SgSourceFile));
    8681             : #endif
    8682           2 :         SgSourceFile::pools.push_back( (unsigned char*)(pointer) );
    8683           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSourceFile::pool_size * sizeof(SgSourceFile), V_SgSourceFile ) );
    8684             : 
    8685           2 :         if ( SgSourceFile::next_node != NULL ) {
    8686           0 :           if ( blockIndex > 0 ) {
    8687           0 :             SgSourceFile * blkptr = (SgSourceFile*)(SgSourceFile::pools[blockIndex-1]);
    8688           0 :             blkptr[ SgSourceFile::pool_size - 1 ].set_freepointer(pointer);
    8689             :           }
    8690             :         } else {
    8691           2 :           SgSourceFile::next_node = pointer;
    8692             :         }
    8693             : 
    8694        4000 :         for (unsigned i = 0; i < SgSourceFile::pool_size-1; ++i)
    8695             :            {
    8696        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    8697             :            }
    8698           2 :         pointer[ SgSourceFile::pool_size -1 ].set_freepointer(NULL);
    8699             : 
    8700           2 :         blockIndex++;
    8701             :       }
    8702           2 :   }
    8703             : 
    8704             : //############################################################################
    8705             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    8706             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    8707             :  * not compressed. However, that stuff is not yet implemented! 
    8708             :  */
    8709             : unsigned long
    8710           0 : SgSourceFile::getNumberOfLastValidPointer()
    8711             :    {
    8712           0 :       SgSourceFile* testPointer = (SgSourceFile*)(SgSourceFile::pools.back());
    8713           0 :       unsigned long localIndex = SgSourceFile::pool_size - 1;
    8714           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    8715             :          {
    8716           0 :            localIndex--;
    8717             :          }
    8718           0 :       return (localIndex + SgSourceFile::pool_size * (SgSourceFile::pools.size()-1));
    8719             :    }
    8720             : 
    8721             : //############################################################################
    8722             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    8723             :  * memory pool and initializes the data member in class SgSourceFileStroageClass
    8724             :  * from its counterpart of SgSourceFile. The return value is just for checking, 
    8725             :  * that the whole StorageClassArray is initialized!
    8726             :  */
    8727             : unsigned long
    8728           3 : SgSourceFile::initializeStorageClassArray( SgSourceFileStorageClass *storageArray )
    8729             :    {
    8730           3 :      unsigned long storageCounter = 0;
    8731           3 :      std::vector < unsigned char* > :: const_iterator block = SgSourceFile::pools.begin();
    8732           3 :      SgSourceFile* pointer = NULL;
    8733           6 :      while ( block != SgSourceFile::pools.end() ) {
    8734           3 :           pointer = (SgSourceFile*) (*block);
    8735        6003 :           for ( unsigned i = 0; i < SgSourceFile::pool_size; ++i ) {
    8736        6000 :                if ( pointer->get_freepointer() != NULL ) {
    8737         198 :                  storageArray->pickOutIRNodeData (pointer) ;
    8738         198 :                  storageArray++;
    8739         198 :                  storageCounter++;
    8740             :                }
    8741        6000 :                pointer++;
    8742             :              }
    8743           3 :            block++;
    8744             :         }
    8745           3 :      return storageCounter;
    8746             :    }
    8747             : 
    8748             : /* #line 8749 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    8749             : 
    8750             : 
    8751             : 
    8752             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    8753             : 
    8754             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    8755             : 
    8756             : //############################################################################
    8757             : /* JH (02/02/2006) Constructor of the IR node SgUnknownFile that takes its 
    8758             :  * corresponding StorageClass as parameter
    8759             :  */
    8760           0 : SgUnknownFile :: SgUnknownFile ( const SgUnknownFileStorageClass& storageSource )   : SgFile (storageSource)
    8761             :    {
    8762             : 
    8763             : 
    8764             : /* #line 8765 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    8765             : 
    8766           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    8767           0 :      p_globalScope =  (SgGlobal*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_globalScope) );
    8768             : 
    8769             : 
    8770             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    8771             : 
    8772             : 
    8773           0 :    }
    8774             : 
    8775             : //############################################################################
    8776             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    8777             :  * within the working AST. 
    8778             :  */
    8779           0 : SgUnknownFile * SgUnknownFile::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    8780           0 :      SgUnknownFile* returnPointer = NULL;
    8781           0 :      if ( globalIndex != 0 )
    8782             :         {
    8783             : 
    8784             : #if FILE_IO_EXTRA_CHECK
    8785           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnknownFile ) ) <= globalIndex ) ;
    8786           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnknownFile + 1 ) ) );
    8787             : #endif
    8788           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnknownFile )  
    8789           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnknownFile );
    8790           0 :           unsigned long positionInPool = localIndex % SgUnknownFile::pool_size;
    8791           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnknownFile::pool_size;
    8792             : 
    8793             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    8794             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    8795             : 
    8796           0 :           returnPointer = &( ( (SgUnknownFile*)(SgUnknownFile::pools[memoryBlock]) ) [positionInPool]) ;
    8797             : 
    8798           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    8799             :         }
    8800           0 :      return returnPointer ;
    8801             :    }
    8802             : 
    8803             : //############################################################################
    8804             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    8805             :   for the AST with the index astIndex
    8806             : */
    8807           0 : SgUnknownFile * SgUnknownFile::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    8808           0 :      SgUnknownFile* returnPointer = NULL;
    8809           0 :      if ( globalIndex != 0 )
    8810             :         {
    8811             : 
    8812             : #if FILE_IO_EXTRA_CHECK
    8813           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnknownFile ) ) <= globalIndex ) ;
    8814           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnknownFile + 1 ) ) );
    8815             : #endif
    8816           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnknownFile )
    8817           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnknownFile );
    8818           0 :           unsigned long positionInPool = localIndex % SgUnknownFile::pool_size ;
    8819           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnknownFile::pool_size ;
    8820             : 
    8821             : #if FILE_IO_EXTRA_CHECK
    8822             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    8823             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    8824             : #endif
    8825             : 
    8826           0 :           returnPointer = &( ( (SgUnknownFile*)(SgUnknownFile::pools[memoryBlock]) ) [positionInPool]) ;
    8827             : 
    8828             : #if FILE_IO_EXTRA_CHECK
    8829           0 :           assert ( returnPointer != NULL ) ;
    8830             : #endif
    8831             :         }
    8832           0 :      return returnPointer ;
    8833             :    }
    8834             : 
    8835             : //############################################################################
    8836             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    8837             :  * pool size! We set for every valid object in the memory pool the freepointer
    8838             :  * to the global index and increase the global index afterwards. For all the 
    8839             :  * invalid objects (means address ranges within the memory pool that were not
    8840             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    8841             :  * distinguish valid from invalid objects! 
    8842             :  */
    8843             : unsigned long
    8844           5 : SgUnknownFile::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    8845             :    {
    8846           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    8847           5 :      SgUnknownFile* pointer = NULL;
    8848           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    8849           5 :      std::vector < unsigned char* > :: const_iterator block;
    8850           5 :      for ( block = SgUnknownFile::pools.begin(); block != SgUnknownFile::pools.end() ; ++block )
    8851             :         {
    8852           0 :           pointer = (SgUnknownFile*)(*block);
    8853           0 :           for (unsigned i = 0; i < SgUnknownFile::pool_size; ++i )
    8854             :              {
    8855             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    8856             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    8857             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    8858             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    8859             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    8860             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    8861             :             // properly; so this will have to be checked next.
    8862             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    8863             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    8864           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    8865             :                   {
    8866           0 :                     pointer[i].set_freepointer((SgUnknownFile*)(globalIndex));
    8867           0 :                     globalIndex++;
    8868             :                   }
    8869             :                else
    8870             :                   {
    8871           0 :                     pointer[i].set_freepointer(NULL);
    8872             :                   }
    8873             :               }
    8874             :         }
    8875           5 :      return globalIndex;
    8876             :    }
    8877             : 
    8878             : //############################################################################
    8879             : // JH (01/14/2006)
    8880             : void
    8881           5 : SgUnknownFile::resetValidFreepointers( )
    8882             :    {
    8883           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    8884           5 :      SgUnknownFile* pointer = NULL;
    8885           5 :      std::vector < unsigned char* > :: const_iterator block;
    8886           5 :      SgUnknownFile* pointerOfLinkedList = NULL;
    8887           5 :      for ( block = SgUnknownFile::pools.begin(); block != SgUnknownFile::pools.end() ; ++block )
    8888             :         {
    8889           0 :           pointer = (SgUnknownFile*)(*block);
    8890           0 :           for (unsigned i = 0; i < SgUnknownFile::pool_size; ++i )
    8891             :              {
    8892             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    8893             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    8894             :             // memory blocks!.
    8895           0 :                if ( pointer[i].get_freepointer() != NULL )
    8896             :                   {
    8897           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    8898             :                   }
    8899             :                else
    8900             :                   {
    8901           0 :                     if ( pointerOfLinkedList == NULL )
    8902             :                        {
    8903           0 :                          SgUnknownFile::next_node = &(pointer[i]);
    8904             :                        }
    8905             :                     else
    8906             :                        {
    8907             :                       // printf ("In SgUnknownFile::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    8908           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    8909             :                        }
    8910             :                     pointerOfLinkedList = &(pointer[i]);
    8911             :                   }
    8912             :               }
    8913             :         }
    8914             : 
    8915           5 :      if ( pointerOfLinkedList != NULL )
    8916             :         {
    8917             :        // printf ("In SgUnknownFile::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    8918           0 :           pointerOfLinkedList->set_freepointer(NULL);
    8919             :        // DQ (6/6/2010): Temporary debugging...
    8920             :        //   ROSE_ASSERT(false);
    8921             :         }
    8922             : 
    8923           5 :      return ;
    8924             :    }
    8925             : 
    8926             : //############################################################################
    8927             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    8928             :  * within the memory pool and resets the freepointers, in order to achieve a 
    8929             :  * linked list, that has no jumps and starts at the beginning! This function 
    8930             :  * does not extend the memory pool, since we do not delete any memory blocks,
    8931             :  * but delete the valid objects.  
    8932             :  */
    8933             : void
    8934           0 : SgUnknownFile::clearMemoryPool( )
    8935             :    {
    8936             :   // printf ("Inside of SgUnknownFile::clearMemoryPool() \n");
    8937             : 
    8938           0 :      SgUnknownFile* pointer = NULL, *tempPointer = NULL;
    8939           0 :      std::vector < unsigned char* > :: const_iterator block;
    8940           0 :      if ( SgUnknownFile::pools.empty() == false )
    8941             :         {
    8942           0 :           block = SgUnknownFile::pools.begin() ;
    8943           0 :           SgUnknownFile::next_node = (SgUnknownFile*) (*block);
    8944             : 
    8945           0 :           while ( block != SgUnknownFile::pools.end() )
    8946             :              {
    8947           0 :                pointer = (SgUnknownFile*) (*block);
    8948           0 :                if ( tempPointer != NULL )
    8949             :                   {
    8950           0 :                     tempPointer->set_freepointer(pointer);
    8951             :                   }
    8952           0 :                for (unsigned i = 0; i < SgUnknownFile::pool_size - 1; ++i)
    8953             :                   {
    8954           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    8955             :                   }
    8956           0 :                 pointer[SgUnknownFile::pool_size-1].set_freepointer(NULL);
    8957           0 :                 tempPointer = &(pointer[SgUnknownFile::pool_size-1]);
    8958           0 :                 ++block;
    8959             :              }
    8960             :         }
    8961           0 :    }
    8962             : 
    8963           5 : void SgUnknownFile::deleteMemoryPool() {
    8964           5 :   for (auto p: SgUnknownFile::pools) {
    8965           0 :     ROSE_FREE(p);
    8966             :   }
    8967           5 :   SgUnknownFile::next_node = nullptr;
    8968           5 :   SgUnknownFile::pools.clear();
    8969           5 : }
    8970             : 
    8971             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    8972             : //                 reading multiple binary files to for a single AST.
    8973             : /////////// new version ////////////////////////////////
    8974             : //############################################################################
    8975             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    8976             : void
    8977           2 : SgUnknownFile::extendMemoryPoolForFileIO( )
    8978             :   {
    8979           2 :     size_t blockIndex = SgUnknownFile::pools.size();
    8980           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnknownFile) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnknownFile);
    8981             : 
    8982           2 :     while ( (blockIndex * SgUnknownFile::pool_size) < newPoolSize)
    8983             :       {
    8984             : #if ROSE_ALLOC_TRACE
    8985             :         if (blockIndex > 0) {
    8986             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnknownFile) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnknownFile) = %" PRIuPTR " SgUnknownFile::pool_size = %d \n",
    8987             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnknownFile),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnknownFile),SgUnknownFile::pool_size);
    8988             :         }
    8989             : #endif
    8990             : 
    8991           0 :         SgUnknownFile * pointer = (SgUnknownFile*) ROSE_MALLOC ( SgUnknownFile::pool_size * sizeof(SgUnknownFile) );
    8992           0 :         assert( pointer != NULL );
    8993             : #if ROSE_ALLOC_MEMSET == 1
    8994             :         memset(pointer, 0x00, SgUnknownFile::pool_size * sizeof(SgUnknownFile));
    8995             : #elif ROSE_ALLOC_MEMSET == 2
    8996             :         memset(pointer, 0xCC, SgUnknownFile::pool_size * sizeof(SgUnknownFile));
    8997             : #endif
    8998           0 :         SgUnknownFile::pools.push_back( (unsigned char*)(pointer) );
    8999           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnknownFile::pool_size * sizeof(SgUnknownFile), V_SgUnknownFile ) );
    9000             : 
    9001           0 :         if ( SgUnknownFile::next_node != NULL ) {
    9002           0 :           if ( blockIndex > 0 ) {
    9003           0 :             SgUnknownFile * blkptr = (SgUnknownFile*)(SgUnknownFile::pools[blockIndex-1]);
    9004           0 :             blkptr[ SgUnknownFile::pool_size - 1 ].set_freepointer(pointer);
    9005             :           }
    9006             :         } else {
    9007           0 :           SgUnknownFile::next_node = pointer;
    9008             :         }
    9009             : 
    9010           0 :         for (unsigned i = 0; i < SgUnknownFile::pool_size-1; ++i)
    9011             :            {
    9012           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    9013             :            }
    9014           0 :         pointer[ SgUnknownFile::pool_size -1 ].set_freepointer(NULL);
    9015             : 
    9016           0 :         blockIndex++;
    9017             :       }
    9018           2 :   }
    9019             : 
    9020             : //############################################################################
    9021             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    9022             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    9023             :  * not compressed. However, that stuff is not yet implemented! 
    9024             :  */
    9025             : unsigned long
    9026           0 : SgUnknownFile::getNumberOfLastValidPointer()
    9027             :    {
    9028           0 :       SgUnknownFile* testPointer = (SgUnknownFile*)(SgUnknownFile::pools.back());
    9029           0 :       unsigned long localIndex = SgUnknownFile::pool_size - 1;
    9030           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    9031             :          {
    9032           0 :            localIndex--;
    9033             :          }
    9034           0 :       return (localIndex + SgUnknownFile::pool_size * (SgUnknownFile::pools.size()-1));
    9035             :    }
    9036             : 
    9037             : //############################################################################
    9038             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    9039             :  * memory pool and initializes the data member in class SgUnknownFileStroageClass
    9040             :  * from its counterpart of SgUnknownFile. The return value is just for checking, 
    9041             :  * that the whole StorageClassArray is initialized!
    9042             :  */
    9043             : unsigned long
    9044           0 : SgUnknownFile::initializeStorageClassArray( SgUnknownFileStorageClass *storageArray )
    9045             :    {
    9046           0 :      unsigned long storageCounter = 0;
    9047           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnknownFile::pools.begin();
    9048           0 :      SgUnknownFile* pointer = NULL;
    9049           0 :      while ( block != SgUnknownFile::pools.end() ) {
    9050           0 :           pointer = (SgUnknownFile*) (*block);
    9051           0 :           for ( unsigned i = 0; i < SgUnknownFile::pool_size; ++i ) {
    9052           0 :                if ( pointer->get_freepointer() != NULL ) {
    9053           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    9054           0 :                  storageArray++;
    9055           0 :                  storageCounter++;
    9056             :                }
    9057           0 :                pointer++;
    9058             :              }
    9059           0 :            block++;
    9060             :         }
    9061           0 :      return storageCounter;
    9062             :    }
    9063             : 
    9064             : /* #line 9065 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    9065             : 
    9066             : 
    9067             : 
    9068             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    9069             : 
    9070             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    9071             : 
    9072             : //############################################################################
    9073             : /* JH (02/02/2006) Constructor of the IR node SgProject that takes its 
    9074             :  * corresponding StorageClass as parameter
    9075             :  */
    9076           2 : SgProject :: SgProject ( const SgProjectStorageClass& storageSource )   : SgSupport (storageSource)
    9077             :    {
    9078             : 
    9079             : 
    9080             : /* #line 9081 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    9081             : 
    9082           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    9083           2 :      p_fileList_ptr =  (SgFileList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_fileList_ptr) );
    9084           2 :      p_originalCommandLineArgumentList = storageSource.storageOf_originalCommandLineArgumentList.rebuildDataStoredInEasyStorageClass() ;
    9085           2 :      p_frontendErrorCode = storageSource.storageOf_frontendErrorCode ;
    9086           2 :      p_javacErrorCode = storageSource.storageOf_javacErrorCode ;
    9087           2 :      p_ecjErrorCode = storageSource.storageOf_ecjErrorCode ;
    9088           2 :      p_midendErrorCode = storageSource.storageOf_midendErrorCode ;
    9089           2 :      p_backendErrorCode = storageSource.storageOf_backendErrorCode ;
    9090           2 :      p_keep_going = storageSource.storageOf_keep_going ;
    9091           2 :      p_unparser__clobber_input_file = storageSource.storageOf_unparser__clobber_input_file ;
    9092           2 :      p_outputFileName = storageSource.storageOf_outputFileName.rebuildDataStoredInEasyStorageClass() ;
    9093           2 :      p_sourceFileNameList = storageSource.storageOf_sourceFileNameList.rebuildDataStoredInEasyStorageClass() ;
    9094           2 :      p_objectFileNameList = storageSource.storageOf_objectFileNameList.rebuildDataStoredInEasyStorageClass() ;
    9095           2 :      p_libraryFileList = storageSource.storageOf_libraryFileList.rebuildDataStoredInEasyStorageClass() ;
    9096           2 :      p_librarySpecifierList = storageSource.storageOf_librarySpecifierList.rebuildDataStoredInEasyStorageClass() ;
    9097           2 :      p_libraryDirectorySpecifierList = storageSource.storageOf_libraryDirectorySpecifierList.rebuildDataStoredInEasyStorageClass() ;
    9098           2 :      p_includeDirectorySpecifierList = storageSource.storageOf_includeDirectorySpecifierList.rebuildDataStoredInEasyStorageClass() ;
    9099           2 :      p_macroSpecifierList = storageSource.storageOf_macroSpecifierList.rebuildDataStoredInEasyStorageClass() ;
    9100           2 :      p_preincludeFileList = storageSource.storageOf_preincludeFileList.rebuildDataStoredInEasyStorageClass() ;
    9101           2 :      p_preincludeDirectoryList = storageSource.storageOf_preincludeDirectoryList.rebuildDataStoredInEasyStorageClass() ;
    9102           2 :      p_compileOnly = storageSource.storageOf_compileOnly ;
    9103           2 :      p_wave = storageSource.storageOf_wave ;
    9104           2 :      p_prelink = storageSource.storageOf_prelink ;
    9105           2 :      p_template_instantiation_mode = storageSource.storageOf_template_instantiation_mode ;
    9106           2 :      p_ast_merge = storageSource.storageOf_ast_merge ;
    9107           2 :      p_projectSpecificDatabaseFile = storageSource.storageOf_projectSpecificDatabaseFile.rebuildDataStoredInEasyStorageClass() ;
    9108           2 :      p_C_PreprocessorOnly = storageSource.storageOf_C_PreprocessorOnly ;
    9109           2 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
    9110           2 :      p_compilationPerformanceFile = storageSource.storageOf_compilationPerformanceFile.rebuildDataStoredInEasyStorageClass() ;
    9111           2 :      p_includePathList = storageSource.storageOf_includePathList.rebuildDataStoredInEasyStorageClass() ;
    9112           2 :      p_excludePathList = storageSource.storageOf_excludePathList.rebuildDataStoredInEasyStorageClass() ;
    9113           2 :      p_includeFileList = storageSource.storageOf_includeFileList.rebuildDataStoredInEasyStorageClass() ;
    9114           2 :      p_excludeFileList = storageSource.storageOf_excludeFileList.rebuildDataStoredInEasyStorageClass() ;
    9115           2 :      p_binary_only = storageSource.storageOf_binary_only ;
    9116           2 :      p_directoryList =  (SgDirectoryList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_directoryList) );
    9117           2 :      p_C_only = storageSource.storageOf_C_only ;
    9118           2 :      p_Cxx_only = storageSource.storageOf_Cxx_only ;
    9119           2 :      p_C11_only = storageSource.storageOf_C11_only ;
    9120           2 :      p_Cxx0x_only = storageSource.storageOf_Cxx0x_only ;
    9121           2 :      p_Cxx11_only = storageSource.storageOf_Cxx11_only ;
    9122           2 :      p_C14_only = storageSource.storageOf_C14_only ;
    9123           2 :      p_Cxx14_only = storageSource.storageOf_Cxx14_only ;
    9124           2 :      p_Fortran_only = storageSource.storageOf_Fortran_only ;
    9125           2 :      p_Fortran_ofp_jvm_options = storageSource.storageOf_Fortran_ofp_jvm_options.rebuildDataStoredInEasyStorageClass() ;
    9126           2 :      p_openmp_linking = storageSource.storageOf_openmp_linking ;
    9127           2 :      p_Java_ecj_jvm_options = storageSource.storageOf_Java_ecj_jvm_options.rebuildDataStoredInEasyStorageClass() ;
    9128           2 :      p_Java_batch_mode = storageSource.storageOf_Java_batch_mode ;
    9129           2 :      p_Java_classpath = storageSource.storageOf_Java_classpath.rebuildDataStoredInEasyStorageClass() ;
    9130           2 :      p_Java_sourcepath = storageSource.storageOf_Java_sourcepath.rebuildDataStoredInEasyStorageClass() ;
    9131           2 :      p_Java_destdir = storageSource.storageOf_Java_destdir.rebuildDataStoredInEasyStorageClass() ;
    9132           2 :      p_Java_source_destdir = storageSource.storageOf_Java_source_destdir.rebuildDataStoredInEasyStorageClass() ;
    9133           2 :      p_addCppDirectivesToAST = storageSource.storageOf_addCppDirectivesToAST ;
    9134           2 :      p_includingPreprocessingInfosMap = storageSource.storageOf_includingPreprocessingInfosMap.rebuildDataStoredInEasyStorageClass() ;
    9135           2 :      p_quotedIncludesSearchPaths = storageSource.storageOf_quotedIncludesSearchPaths.rebuildDataStoredInEasyStorageClass() ;
    9136           2 :      p_bracketedIncludesSearchPaths = storageSource.storageOf_bracketedIncludesSearchPaths.rebuildDataStoredInEasyStorageClass() ;
    9137           2 :      p_unparseHeaderFilesRootFolder = storageSource.storageOf_unparseHeaderFilesRootFolder.rebuildDataStoredInEasyStorageClass() ;
    9138           2 :      p_frontendConstantFolding = storageSource.storageOf_frontendConstantFolding ;
    9139           2 :      p_globalScopeAcrossFiles =  (SgGlobal*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_globalScopeAcrossFiles) );
    9140           2 :      p_unparse_in_same_directory_as_input_file = storageSource.storageOf_unparse_in_same_directory_as_input_file ;
    9141           2 :      p_stop_after_compilation_do_not_assemble_file = storageSource.storageOf_stop_after_compilation_do_not_assemble_file ;
    9142           2 :      p_gnuOptionForUndefinedSymbol = storageSource.storageOf_gnuOptionForUndefinedSymbol.rebuildDataStoredInEasyStorageClass() ;
    9143           2 :      p_mode_32_bit = storageSource.storageOf_mode_32_bit ;
    9144           2 :      p_noclobber_output_file = storageSource.storageOf_noclobber_output_file ;
    9145           2 :      p_noclobber_if_different_output_file = storageSource.storageOf_noclobber_if_different_output_file ;
    9146           2 :      p_suppressConstantFoldingPostProcessing = storageSource.storageOf_suppressConstantFoldingPostProcessing ;
    9147           2 :      p_appendPID = storageSource.storageOf_appendPID ;
    9148           2 :      p_reportOnHeaderFileUnparsing = storageSource.storageOf_reportOnHeaderFileUnparsing ;
    9149           2 :      p_applicationRootDirectory = storageSource.storageOf_applicationRootDirectory.rebuildDataStoredInEasyStorageClass() ;
    9150           2 :      p_usingApplicationRootDirectory = storageSource.storageOf_usingApplicationRootDirectory ;
    9151           2 :      p_usingDeferredTransformations = storageSource.storageOf_usingDeferredTransformations ;
    9152           2 :      p_astfile_out = storageSource.storageOf_astfile_out.rebuildDataStoredInEasyStorageClass() ;
    9153           2 :      p_astfiles_in = storageSource.storageOf_astfiles_in.rebuildDataStoredInEasyStorageClass() ;
    9154           2 :      p_extraIncludeDirectorySpecifierBeforeList = storageSource.storageOf_extraIncludeDirectorySpecifierBeforeList.rebuildDataStoredInEasyStorageClass() ;
    9155           2 :      p_extraIncludeDirectorySpecifierAfterList = storageSource.storageOf_extraIncludeDirectorySpecifierAfterList.rebuildDataStoredInEasyStorageClass() ;
    9156             : 
    9157             : 
    9158             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    9159             : 
    9160             : 
    9161           2 :    }
    9162             : 
    9163             : //############################################################################
    9164             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    9165             :  * within the working AST. 
    9166             :  */
    9167          10 : SgProject * SgProject::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    9168          10 :      SgProject* returnPointer = NULL;
    9169          10 :      if ( globalIndex != 0 )
    9170             :         {
    9171             : 
    9172             : #if FILE_IO_EXTRA_CHECK
    9173          10 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgProject ) ) <= globalIndex ) ;
    9174          10 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgProject + 1 ) ) );
    9175             : #endif
    9176          10 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgProject )  
    9177          10 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgProject );
    9178          10 :           unsigned long positionInPool = localIndex % SgProject::pool_size;
    9179          10 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgProject::pool_size;
    9180             : 
    9181             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    9182             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    9183             : 
    9184          10 :           returnPointer = &( ( (SgProject*)(SgProject::pools[memoryBlock]) ) [positionInPool]) ;
    9185             : 
    9186          10 :           ROSE_ASSERT( returnPointer != NULL ) ;
    9187             :         }
    9188          10 :      return returnPointer ;
    9189             :    }
    9190             : 
    9191             : //############################################################################
    9192             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    9193             :   for the AST with the index astIndex
    9194             : */
    9195           0 : SgProject * SgProject::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    9196           0 :      SgProject* returnPointer = NULL;
    9197           0 :      if ( globalIndex != 0 )
    9198             :         {
    9199             : 
    9200             : #if FILE_IO_EXTRA_CHECK
    9201           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgProject ) ) <= globalIndex ) ;
    9202           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgProject + 1 ) ) );
    9203             : #endif
    9204           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgProject )
    9205           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgProject );
    9206           0 :           unsigned long positionInPool = localIndex % SgProject::pool_size ;
    9207           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgProject::pool_size ;
    9208             : 
    9209             : #if FILE_IO_EXTRA_CHECK
    9210             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    9211             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    9212             : #endif
    9213             : 
    9214           0 :           returnPointer = &( ( (SgProject*)(SgProject::pools[memoryBlock]) ) [positionInPool]) ;
    9215             : 
    9216             : #if FILE_IO_EXTRA_CHECK
    9217           0 :           assert ( returnPointer != NULL ) ;
    9218             : #endif
    9219             :         }
    9220           0 :      return returnPointer ;
    9221             :    }
    9222             : 
    9223             : //############################################################################
    9224             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    9225             :  * pool size! We set for every valid object in the memory pool the freepointer
    9226             :  * to the global index and increase the global index afterwards. For all the 
    9227             :  * invalid objects (means address ranges within the memory pool that were not
    9228             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    9229             :  * distinguish valid from invalid objects! 
    9230             :  */
    9231             : unsigned long
    9232           5 : SgProject::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    9233             :    {
    9234           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    9235           5 :      SgProject* pointer = NULL;
    9236           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    9237           5 :      std::vector < unsigned char* > :: const_iterator block;
    9238          10 :      for ( block = SgProject::pools.begin(); block != SgProject::pools.end() ; ++block )
    9239             :         {
    9240           5 :           pointer = (SgProject*)(*block);
    9241       10005 :           for (unsigned i = 0; i < SgProject::pool_size; ++i )
    9242             :              {
    9243             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    9244             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    9245             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    9246             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    9247             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    9248             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    9249             :             // properly; so this will have to be checked next.
    9250             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    9251             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    9252       10000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    9253             :                   {
    9254           5 :                     pointer[i].set_freepointer((SgProject*)(globalIndex));
    9255           5 :                     globalIndex++;
    9256             :                   }
    9257             :                else
    9258             :                   {
    9259        9995 :                     pointer[i].set_freepointer(NULL);
    9260             :                   }
    9261             :               }
    9262             :         }
    9263           5 :      return globalIndex;
    9264             :    }
    9265             : 
    9266             : //############################################################################
    9267             : // JH (01/14/2006)
    9268             : void
    9269           5 : SgProject::resetValidFreepointers( )
    9270             :    {
    9271           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    9272           5 :      SgProject* pointer = NULL;
    9273           5 :      std::vector < unsigned char* > :: const_iterator block;
    9274           5 :      SgProject* pointerOfLinkedList = NULL;
    9275          10 :      for ( block = SgProject::pools.begin(); block != SgProject::pools.end() ; ++block )
    9276             :         {
    9277           5 :           pointer = (SgProject*)(*block);
    9278       10005 :           for (unsigned i = 0; i < SgProject::pool_size; ++i )
    9279             :              {
    9280             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    9281             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    9282             :             // memory blocks!.
    9283       10000 :                if ( pointer[i].get_freepointer() != NULL )
    9284             :                   {
    9285           5 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    9286             :                   }
    9287             :                else
    9288             :                   {
    9289        9995 :                     if ( pointerOfLinkedList == NULL )
    9290             :                        {
    9291           5 :                          SgProject::next_node = &(pointer[i]);
    9292             :                        }
    9293             :                     else
    9294             :                        {
    9295             :                       // printf ("In SgProject::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    9296        9990 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    9297             :                        }
    9298             :                     pointerOfLinkedList = &(pointer[i]);
    9299             :                   }
    9300             :               }
    9301             :         }
    9302             : 
    9303           5 :      if ( pointerOfLinkedList != NULL )
    9304             :         {
    9305             :        // printf ("In SgProject::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    9306           5 :           pointerOfLinkedList->set_freepointer(NULL);
    9307             :        // DQ (6/6/2010): Temporary debugging...
    9308             :        //   ROSE_ASSERT(false);
    9309             :         }
    9310             : 
    9311           5 :      return ;
    9312             :    }
    9313             : 
    9314             : //############################################################################
    9315             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    9316             :  * within the memory pool and resets the freepointers, in order to achieve a 
    9317             :  * linked list, that has no jumps and starts at the beginning! This function 
    9318             :  * does not extend the memory pool, since we do not delete any memory blocks,
    9319             :  * but delete the valid objects.  
    9320             :  */
    9321             : void
    9322           0 : SgProject::clearMemoryPool( )
    9323             :    {
    9324             :   // printf ("Inside of SgProject::clearMemoryPool() \n");
    9325             : 
    9326           0 :      SgProject* pointer = NULL, *tempPointer = NULL;
    9327           0 :      std::vector < unsigned char* > :: const_iterator block;
    9328           0 :      if ( SgProject::pools.empty() == false )
    9329             :         {
    9330           0 :           block = SgProject::pools.begin() ;
    9331           0 :           SgProject::next_node = (SgProject*) (*block);
    9332             : 
    9333           0 :           while ( block != SgProject::pools.end() )
    9334             :              {
    9335           0 :                pointer = (SgProject*) (*block);
    9336           0 :                if ( tempPointer != NULL )
    9337             :                   {
    9338           0 :                     tempPointer->set_freepointer(pointer);
    9339             :                   }
    9340           0 :                for (unsigned i = 0; i < SgProject::pool_size - 1; ++i)
    9341             :                   {
    9342           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    9343             :                   }
    9344           0 :                 pointer[SgProject::pool_size-1].set_freepointer(NULL);
    9345           0 :                 tempPointer = &(pointer[SgProject::pool_size-1]);
    9346           0 :                 ++block;
    9347             :              }
    9348             :         }
    9349           0 :    }
    9350             : 
    9351           5 : void SgProject::deleteMemoryPool() {
    9352          10 :   for (auto p: SgProject::pools) {
    9353           5 :     ROSE_FREE(p);
    9354             :   }
    9355           5 :   SgProject::next_node = nullptr;
    9356           5 :   SgProject::pools.clear();
    9357           5 : }
    9358             : 
    9359             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    9360             : //                 reading multiple binary files to for a single AST.
    9361             : /////////// new version ////////////////////////////////
    9362             : //############################################################################
    9363             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    9364             : void
    9365           2 : SgProject::extendMemoryPoolForFileIO( )
    9366             :   {
    9367           2 :     size_t blockIndex = SgProject::pools.size();
    9368           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgProject) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgProject);
    9369             : 
    9370           2 :     while ( (blockIndex * SgProject::pool_size) < newPoolSize)
    9371             :       {
    9372             : #if ROSE_ALLOC_TRACE
    9373             :         if (blockIndex > 0) {
    9374             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgProject) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgProject) = %" PRIuPTR " SgProject::pool_size = %d \n",
    9375             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgProject),AST_FILE_IO::getPoolSizeOfNewAst(V_SgProject),SgProject::pool_size);
    9376             :         }
    9377             : #endif
    9378             : 
    9379           0 :         SgProject * pointer = (SgProject*) ROSE_MALLOC ( SgProject::pool_size * sizeof(SgProject) );
    9380           0 :         assert( pointer != NULL );
    9381             : #if ROSE_ALLOC_MEMSET == 1
    9382             :         memset(pointer, 0x00, SgProject::pool_size * sizeof(SgProject));
    9383             : #elif ROSE_ALLOC_MEMSET == 2
    9384             :         memset(pointer, 0xCC, SgProject::pool_size * sizeof(SgProject));
    9385             : #endif
    9386           0 :         SgProject::pools.push_back( (unsigned char*)(pointer) );
    9387           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgProject::pool_size * sizeof(SgProject), V_SgProject ) );
    9388             : 
    9389           0 :         if ( SgProject::next_node != NULL ) {
    9390           0 :           if ( blockIndex > 0 ) {
    9391           0 :             SgProject * blkptr = (SgProject*)(SgProject::pools[blockIndex-1]);
    9392           0 :             blkptr[ SgProject::pool_size - 1 ].set_freepointer(pointer);
    9393             :           }
    9394             :         } else {
    9395           0 :           SgProject::next_node = pointer;
    9396             :         }
    9397             : 
    9398           0 :         for (unsigned i = 0; i < SgProject::pool_size-1; ++i)
    9399             :            {
    9400           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    9401             :            }
    9402           0 :         pointer[ SgProject::pool_size -1 ].set_freepointer(NULL);
    9403             : 
    9404           0 :         blockIndex++;
    9405             :       }
    9406           2 :   }
    9407             : 
    9408             : //############################################################################
    9409             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    9410             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    9411             :  * not compressed. However, that stuff is not yet implemented! 
    9412             :  */
    9413             : unsigned long
    9414           0 : SgProject::getNumberOfLastValidPointer()
    9415             :    {
    9416           0 :       SgProject* testPointer = (SgProject*)(SgProject::pools.back());
    9417           0 :       unsigned long localIndex = SgProject::pool_size - 1;
    9418           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    9419             :          {
    9420           0 :            localIndex--;
    9421             :          }
    9422           0 :       return (localIndex + SgProject::pool_size * (SgProject::pools.size()-1));
    9423             :    }
    9424             : 
    9425             : //############################################################################
    9426             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    9427             :  * memory pool and initializes the data member in class SgProjectStroageClass
    9428             :  * from its counterpart of SgProject. The return value is just for checking, 
    9429             :  * that the whole StorageClassArray is initialized!
    9430             :  */
    9431             : unsigned long
    9432           3 : SgProject::initializeStorageClassArray( SgProjectStorageClass *storageArray )
    9433             :    {
    9434           3 :      unsigned long storageCounter = 0;
    9435           3 :      std::vector < unsigned char* > :: const_iterator block = SgProject::pools.begin();
    9436           3 :      SgProject* pointer = NULL;
    9437           6 :      while ( block != SgProject::pools.end() ) {
    9438           3 :           pointer = (SgProject*) (*block);
    9439        6003 :           for ( unsigned i = 0; i < SgProject::pool_size; ++i ) {
    9440        6000 :                if ( pointer->get_freepointer() != NULL ) {
    9441           3 :                  storageArray->pickOutIRNodeData (pointer) ;
    9442           3 :                  storageArray++;
    9443           3 :                  storageCounter++;
    9444             :                }
    9445        6000 :                pointer++;
    9446             :              }
    9447           3 :            block++;
    9448             :         }
    9449           3 :      return storageCounter;
    9450             :    }
    9451             : 
    9452             : /* #line 9453 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    9453             : 
    9454             : 
    9455             : 
    9456             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    9457             : 
    9458             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    9459             : 
    9460             : //############################################################################
    9461             : /* JH (02/02/2006) Constructor of the IR node SgOptions that takes its 
    9462             :  * corresponding StorageClass as parameter
    9463             :  */
    9464           0 : SgOptions :: SgOptions ( const SgOptionsStorageClass& storageSource )   : SgSupport (storageSource)
    9465             :    {
    9466             : 
    9467             : 
    9468             : /* #line 9469 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    9469             : 
    9470           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    9471           0 :      p_debug_level = storageSource.storageOf_debug_level ;
    9472           0 :      p_logging_level = storageSource.storageOf_logging_level ;
    9473             : 
    9474             : 
    9475             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    9476             : 
    9477             : 
    9478           0 :    }
    9479             : 
    9480             : //############################################################################
    9481             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    9482             :  * within the working AST. 
    9483             :  */
    9484           0 : SgOptions * SgOptions::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    9485           0 :      SgOptions* returnPointer = NULL;
    9486           0 :      if ( globalIndex != 0 )
    9487             :         {
    9488             : 
    9489             : #if FILE_IO_EXTRA_CHECK
    9490           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOptions ) ) <= globalIndex ) ;
    9491           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOptions + 1 ) ) );
    9492             : #endif
    9493           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOptions )  
    9494           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOptions );
    9495           0 :           unsigned long positionInPool = localIndex % SgOptions::pool_size;
    9496           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOptions::pool_size;
    9497             : 
    9498             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    9499             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    9500             : 
    9501           0 :           returnPointer = &( ( (SgOptions*)(SgOptions::pools[memoryBlock]) ) [positionInPool]) ;
    9502             : 
    9503           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    9504             :         }
    9505           0 :      return returnPointer ;
    9506             :    }
    9507             : 
    9508             : //############################################################################
    9509             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    9510             :   for the AST with the index astIndex
    9511             : */
    9512           0 : SgOptions * SgOptions::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    9513           0 :      SgOptions* returnPointer = NULL;
    9514           0 :      if ( globalIndex != 0 )
    9515             :         {
    9516             : 
    9517             : #if FILE_IO_EXTRA_CHECK
    9518           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOptions ) ) <= globalIndex ) ;
    9519           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOptions + 1 ) ) );
    9520             : #endif
    9521           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOptions )
    9522           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOptions );
    9523           0 :           unsigned long positionInPool = localIndex % SgOptions::pool_size ;
    9524           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOptions::pool_size ;
    9525             : 
    9526             : #if FILE_IO_EXTRA_CHECK
    9527             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    9528             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    9529             : #endif
    9530             : 
    9531           0 :           returnPointer = &( ( (SgOptions*)(SgOptions::pools[memoryBlock]) ) [positionInPool]) ;
    9532             : 
    9533             : #if FILE_IO_EXTRA_CHECK
    9534           0 :           assert ( returnPointer != NULL ) ;
    9535             : #endif
    9536             :         }
    9537           0 :      return returnPointer ;
    9538             :    }
    9539             : 
    9540             : //############################################################################
    9541             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    9542             :  * pool size! We set for every valid object in the memory pool the freepointer
    9543             :  * to the global index and increase the global index afterwards. For all the 
    9544             :  * invalid objects (means address ranges within the memory pool that were not
    9545             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    9546             :  * distinguish valid from invalid objects! 
    9547             :  */
    9548             : unsigned long
    9549           5 : SgOptions::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    9550             :    {
    9551           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    9552           5 :      SgOptions* pointer = NULL;
    9553           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    9554           5 :      std::vector < unsigned char* > :: const_iterator block;
    9555           5 :      for ( block = SgOptions::pools.begin(); block != SgOptions::pools.end() ; ++block )
    9556             :         {
    9557           0 :           pointer = (SgOptions*)(*block);
    9558           0 :           for (unsigned i = 0; i < SgOptions::pool_size; ++i )
    9559             :              {
    9560             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    9561             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    9562             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    9563             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    9564             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    9565             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    9566             :             // properly; so this will have to be checked next.
    9567             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    9568             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    9569           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    9570             :                   {
    9571           0 :                     pointer[i].set_freepointer((SgOptions*)(globalIndex));
    9572           0 :                     globalIndex++;
    9573             :                   }
    9574             :                else
    9575             :                   {
    9576           0 :                     pointer[i].set_freepointer(NULL);
    9577             :                   }
    9578             :               }
    9579             :         }
    9580           5 :      return globalIndex;
    9581             :    }
    9582             : 
    9583             : //############################################################################
    9584             : // JH (01/14/2006)
    9585             : void
    9586           5 : SgOptions::resetValidFreepointers( )
    9587             :    {
    9588           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    9589           5 :      SgOptions* pointer = NULL;
    9590           5 :      std::vector < unsigned char* > :: const_iterator block;
    9591           5 :      SgOptions* pointerOfLinkedList = NULL;
    9592           5 :      for ( block = SgOptions::pools.begin(); block != SgOptions::pools.end() ; ++block )
    9593             :         {
    9594           0 :           pointer = (SgOptions*)(*block);
    9595           0 :           for (unsigned i = 0; i < SgOptions::pool_size; ++i )
    9596             :              {
    9597             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    9598             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    9599             :             // memory blocks!.
    9600           0 :                if ( pointer[i].get_freepointer() != NULL )
    9601             :                   {
    9602           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    9603             :                   }
    9604             :                else
    9605             :                   {
    9606           0 :                     if ( pointerOfLinkedList == NULL )
    9607             :                        {
    9608           0 :                          SgOptions::next_node = &(pointer[i]);
    9609             :                        }
    9610             :                     else
    9611             :                        {
    9612             :                       // printf ("In SgOptions::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    9613           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    9614             :                        }
    9615             :                     pointerOfLinkedList = &(pointer[i]);
    9616             :                   }
    9617             :               }
    9618             :         }
    9619             : 
    9620           5 :      if ( pointerOfLinkedList != NULL )
    9621             :         {
    9622             :        // printf ("In SgOptions::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    9623           0 :           pointerOfLinkedList->set_freepointer(NULL);
    9624             :        // DQ (6/6/2010): Temporary debugging...
    9625             :        //   ROSE_ASSERT(false);
    9626             :         }
    9627             : 
    9628           5 :      return ;
    9629             :    }
    9630             : 
    9631             : //############################################################################
    9632             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    9633             :  * within the memory pool and resets the freepointers, in order to achieve a 
    9634             :  * linked list, that has no jumps and starts at the beginning! This function 
    9635             :  * does not extend the memory pool, since we do not delete any memory blocks,
    9636             :  * but delete the valid objects.  
    9637             :  */
    9638             : void
    9639           0 : SgOptions::clearMemoryPool( )
    9640             :    {
    9641             :   // printf ("Inside of SgOptions::clearMemoryPool() \n");
    9642             : 
    9643           0 :      SgOptions* pointer = NULL, *tempPointer = NULL;
    9644           0 :      std::vector < unsigned char* > :: const_iterator block;
    9645           0 :      if ( SgOptions::pools.empty() == false )
    9646             :         {
    9647           0 :           block = SgOptions::pools.begin() ;
    9648           0 :           SgOptions::next_node = (SgOptions*) (*block);
    9649             : 
    9650           0 :           while ( block != SgOptions::pools.end() )
    9651             :              {
    9652           0 :                pointer = (SgOptions*) (*block);
    9653           0 :                if ( tempPointer != NULL )
    9654             :                   {
    9655           0 :                     tempPointer->set_freepointer(pointer);
    9656             :                   }
    9657           0 :                for (unsigned i = 0; i < SgOptions::pool_size - 1; ++i)
    9658             :                   {
    9659           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
    9660             :                   }
    9661           0 :                 pointer[SgOptions::pool_size-1].set_freepointer(NULL);
    9662           0 :                 tempPointer = &(pointer[SgOptions::pool_size-1]);
    9663           0 :                 ++block;
    9664             :              }
    9665             :         }
    9666           0 :    }
    9667             : 
    9668           5 : void SgOptions::deleteMemoryPool() {
    9669           5 :   for (auto p: SgOptions::pools) {
    9670           0 :     ROSE_FREE(p);
    9671             :   }
    9672           5 :   SgOptions::next_node = nullptr;
    9673           5 :   SgOptions::pools.clear();
    9674           5 : }
    9675             : 
    9676             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
    9677             : //                 reading multiple binary files to for a single AST.
    9678             : /////////// new version ////////////////////////////////
    9679             : //############################################################################
    9680             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
    9681             : void
    9682           2 : SgOptions::extendMemoryPoolForFileIO( )
    9683             :   {
    9684           2 :     size_t blockIndex = SgOptions::pools.size();
    9685           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOptions) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOptions);
    9686             : 
    9687           2 :     while ( (blockIndex * SgOptions::pool_size) < newPoolSize)
    9688             :       {
    9689             : #if ROSE_ALLOC_TRACE
    9690             :         if (blockIndex > 0) {
    9691             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOptions) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOptions) = %" PRIuPTR " SgOptions::pool_size = %d \n",
    9692             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOptions),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOptions),SgOptions::pool_size);
    9693             :         }
    9694             : #endif
    9695             : 
    9696           0 :         SgOptions * pointer = (SgOptions*) ROSE_MALLOC ( SgOptions::pool_size * sizeof(SgOptions) );
    9697           0 :         assert( pointer != NULL );
    9698             : #if ROSE_ALLOC_MEMSET == 1
    9699             :         memset(pointer, 0x00, SgOptions::pool_size * sizeof(SgOptions));
    9700             : #elif ROSE_ALLOC_MEMSET == 2
    9701             :         memset(pointer, 0xCC, SgOptions::pool_size * sizeof(SgOptions));
    9702             : #endif
    9703           0 :         SgOptions::pools.push_back( (unsigned char*)(pointer) );
    9704           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOptions::pool_size * sizeof(SgOptions), V_SgOptions ) );
    9705             : 
    9706           0 :         if ( SgOptions::next_node != NULL ) {
    9707           0 :           if ( blockIndex > 0 ) {
    9708           0 :             SgOptions * blkptr = (SgOptions*)(SgOptions::pools[blockIndex-1]);
    9709           0 :             blkptr[ SgOptions::pool_size - 1 ].set_freepointer(pointer);
    9710             :           }
    9711             :         } else {
    9712           0 :           SgOptions::next_node = pointer;
    9713             :         }
    9714             : 
    9715           0 :         for (unsigned i = 0; i < SgOptions::pool_size-1; ++i)
    9716             :            {
    9717           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
    9718             :            }
    9719           0 :         pointer[ SgOptions::pool_size -1 ].set_freepointer(NULL);
    9720             : 
    9721           0 :         blockIndex++;
    9722             :       }
    9723           2 :   }
    9724             : 
    9725             : //############################################################################
    9726             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
    9727             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
    9728             :  * not compressed. However, that stuff is not yet implemented! 
    9729             :  */
    9730             : unsigned long
    9731           0 : SgOptions::getNumberOfLastValidPointer()
    9732             :    {
    9733           0 :       SgOptions* testPointer = (SgOptions*)(SgOptions::pools.back());
    9734           0 :       unsigned long localIndex = SgOptions::pool_size - 1;
    9735           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
    9736             :          {
    9737           0 :            localIndex--;
    9738             :          }
    9739           0 :       return (localIndex + SgOptions::pool_size * (SgOptions::pools.size()-1));
    9740             :    }
    9741             : 
    9742             : //############################################################################
    9743             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
    9744             :  * memory pool and initializes the data member in class SgOptionsStroageClass
    9745             :  * from its counterpart of SgOptions. The return value is just for checking, 
    9746             :  * that the whole StorageClassArray is initialized!
    9747             :  */
    9748             : unsigned long
    9749           0 : SgOptions::initializeStorageClassArray( SgOptionsStorageClass *storageArray )
    9750             :    {
    9751           0 :      unsigned long storageCounter = 0;
    9752           0 :      std::vector < unsigned char* > :: const_iterator block = SgOptions::pools.begin();
    9753           0 :      SgOptions* pointer = NULL;
    9754           0 :      while ( block != SgOptions::pools.end() ) {
    9755           0 :           pointer = (SgOptions*) (*block);
    9756           0 :           for ( unsigned i = 0; i < SgOptions::pool_size; ++i ) {
    9757           0 :                if ( pointer->get_freepointer() != NULL ) {
    9758           0 :                  storageArray->pickOutIRNodeData (pointer) ;
    9759           0 :                  storageArray++;
    9760           0 :                  storageCounter++;
    9761             :                }
    9762           0 :                pointer++;
    9763             :              }
    9764           0 :            block++;
    9765             :         }
    9766           0 :      return storageCounter;
    9767             :    }
    9768             : 
    9769             : /* #line 9770 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    9770             : 
    9771             : 
    9772             : 
    9773             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    9774             : 
    9775             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
    9776             : 
    9777             : //############################################################################
    9778             : /* JH (02/02/2006) Constructor of the IR node SgUnparse_Info that takes its 
    9779             :  * corresponding StorageClass as parameter
    9780             :  */
    9781           0 : SgUnparse_Info :: SgUnparse_Info ( const SgUnparse_InfoStorageClass& storageSource )   : SgSupport (storageSource)
    9782             :    {
    9783             : 
    9784             : 
    9785             : /* #line 9786 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
    9786             : 
    9787           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
    9788           0 :      p_unparse_attribute = storageSource.storageOf_unparse_attribute.rebuildDataStoredInEasyStorageClass() ;
    9789           0 :      p_access_attribute = storageSource.storageOf_access_attribute ;
    9790           0 :      p_nested_expression = storageSource.storageOf_nested_expression ;
    9791           0 :      p_operator_name = storageSource.storageOf_operator_name.rebuildDataStoredInEasyStorageClass() ;
    9792           0 :      p_var_name = SgName ( storageSource.storageOf_var_name ) ;
    9793           0 :      p_declstatement_ptr =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declstatement_ptr) );
    9794           0 :      p_declaration_of_context =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration_of_context) );
    9795           0 :      p_current_context =  (SgNamedType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_current_context) );
    9796           0 :      p_array_index_list = SgName ( storageSource.storageOf_array_index_list ) ;
    9797           0 :      p_current_namespace =  (SgNamespaceDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_current_namespace) );
    9798           0 :      p_outputCodeGenerationFormatDelimiters = storageSource.storageOf_outputCodeGenerationFormatDelimiters ;
    9799           0 :      p_qualifiedNameList = storageSource.storageOf_qualifiedNameList.rebuildDataStoredInEasyStorageClass() ;
    9800           0 :      SgQualifiedNamePtrList::iterator i_qualifiedNameList = p_qualifiedNameList.begin() ; 
    9801           0 :      for ( ; i_qualifiedNameList != p_qualifiedNameList.end(); ++i_qualifiedNameList ) 
    9802             :         {
    9803           0 :           (*i_qualifiedNameList) = (SgQualifiedNamePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_qualifiedNameList) ) );
    9804             :         }
    9805           0 :      p_current_function_call =  (SgFunctionCallExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_current_function_call) );
    9806           0 :      p_current_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_current_scope) );
    9807           0 :      p_reference_node_for_qualification =  (SgNode*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_reference_node_for_qualification) );
    9808           0 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
    9809           0 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
    9810           0 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
    9811           0 :      p_nestingLevel = storageSource.storageOf_nestingLevel ;
    9812           0 :      p_language = storageSource.storageOf_language ;
    9813           0 :      p_current_source_file =  (SgSourceFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_current_source_file) );
    9814           0 :      p_use_generated_name_for_template_arguments = storageSource.storageOf_use_generated_name_for_template_arguments ;
    9815           0 :      p_user_defined_literal = storageSource.storageOf_user_defined_literal ;
    9816           0 :      p_declstatement_associated_with_type =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declstatement_associated_with_type) );
    9817           0 :      p_context_for_added_parentheses = storageSource.storageOf_context_for_added_parentheses ;
    9818             : 
    9819             : 
    9820             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
    9821             : 
    9822             : 
    9823           0 :    }
    9824             : 
    9825             : //############################################################################
    9826             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
    9827             :  * within the working AST. 
    9828             :  */
    9829           0 : SgUnparse_Info * SgUnparse_Info::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
    9830           0 :      SgUnparse_Info* returnPointer = NULL;
    9831           0 :      if ( globalIndex != 0 )
    9832             :         {
    9833             : 
    9834             : #if FILE_IO_EXTRA_CHECK
    9835           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnparse_Info ) ) <= globalIndex ) ;
    9836           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnparse_Info + 1 ) ) );
    9837             : #endif
    9838           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnparse_Info )  
    9839           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnparse_Info );
    9840           0 :           unsigned long positionInPool = localIndex % SgUnparse_Info::pool_size;
    9841           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnparse_Info::pool_size;
    9842             : 
    9843             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    9844             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    9845             : 
    9846           0 :           returnPointer = &( ( (SgUnparse_Info*)(SgUnparse_Info::pools[memoryBlock]) ) [positionInPool]) ;
    9847             : 
    9848           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
    9849             :         }
    9850           0 :      return returnPointer ;
    9851             :    }
    9852             : 
    9853             : //############################################################################
    9854             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
    9855             :   for the AST with the index astIndex
    9856             : */
    9857           0 : SgUnparse_Info * SgUnparse_Info::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
    9858           0 :      SgUnparse_Info* returnPointer = NULL;
    9859           0 :      if ( globalIndex != 0 )
    9860             :         {
    9861             : 
    9862             : #if FILE_IO_EXTRA_CHECK
    9863           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnparse_Info ) ) <= globalIndex ) ;
    9864           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnparse_Info + 1 ) ) );
    9865             : #endif
    9866           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnparse_Info )
    9867           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnparse_Info );
    9868           0 :           unsigned long positionInPool = localIndex % SgUnparse_Info::pool_size ;
    9869           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnparse_Info::pool_size ;
    9870             : 
    9871             : #if FILE_IO_EXTRA_CHECK
    9872             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
    9873             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
    9874             : #endif
    9875             : 
    9876           0 :           returnPointer = &( ( (SgUnparse_Info*)(SgUnparse_Info::pools[memoryBlock]) ) [positionInPool]) ;
    9877             : 
    9878             : #if FILE_IO_EXTRA_CHECK
    9879           0 :           assert ( returnPointer != NULL ) ;
    9880             : #endif
    9881             :         }
    9882           0 :      return returnPointer ;
    9883             :    }
    9884             : 
    9885             : //############################################################################
    9886             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
    9887             :  * pool size! We set for every valid object in the memory pool the freepointer
    9888             :  * to the global index and increase the global index afterwards. For all the 
    9889             :  * invalid objects (means address ranges within the memory pool that were not
    9890             :  * returned by the new operator) the freepointer is set to NULL, in order to 
    9891             :  * distinguish valid from invalid objects! 
    9892             :  */
    9893             : unsigned long
    9894           5 : SgUnparse_Info::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
    9895             :    {
    9896           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
    9897           5 :      SgUnparse_Info* pointer = NULL;
    9898           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
    9899           5 :      std::vector < unsigned char* > :: const_iterator block;
    9900           7 :      for ( block = SgUnparse_Info::pools.begin(); block != SgUnparse_Info::pools.end() ; ++block )
    9901             :         {
    9902           2 :           pointer = (SgUnparse_Info*)(*block);
    9903        4002 :           for (unsigned i = 0; i < SgUnparse_Info::pool_size; ++i )
    9904             :              {
    9905             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
    9906             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
    9907             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
    9908             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
    9909             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
    9910             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
    9911             :             // properly; so this will have to be checked next.
    9912             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    9913             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
    9914        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
    9915             :                   {
    9916           0 :                     pointer[i].set_freepointer((SgUnparse_Info*)(globalIndex));
    9917           0 :                     globalIndex++;
    9918             :                   }
    9919             :                else
    9920             :                   {
    9921        4000 :                     pointer[i].set_freepointer(NULL);
    9922             :                   }
    9923             :               }
    9924             :         }
    9925           5 :      return globalIndex;
    9926             :    }
    9927             : 
    9928             : //############################################################################
    9929             : // JH (01/14/2006)
    9930             : void
    9931           5 : SgUnparse_Info::resetValidFreepointers( )
    9932             :    {
    9933           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
    9934           5 :      SgUnparse_Info* pointer = NULL;
    9935           5 :      std::vector < unsigned char* > :: const_iterator block;
    9936           5 :      SgUnparse_Info* pointerOfLinkedList = NULL;
    9937           7 :      for ( block = SgUnparse_Info::pools.begin(); block != SgUnparse_Info::pools.end() ; ++block )
    9938             :         {
    9939           2 :           pointer = (SgUnparse_Info*)(*block);
    9940        4002 :           for (unsigned i = 0; i < SgUnparse_Info::pool_size; ++i )
    9941             :              {
    9942             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
    9943             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
    9944             :             // memory blocks!.
    9945        4000 :                if ( pointer[i].get_freepointer() != NULL )
    9946             :                   {
    9947           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
    9948             :                   }
    9949             :                else
    9950             :                   {
    9951        4000 :                     if ( pointerOfLinkedList == NULL )
    9952             :                        {
    9953           2 :                          SgUnparse_Info::next_node = &(pointer[i]);
    9954             :                        }
    9955             :                     else
    9956             :                        {
    9957             :                       // printf ("In SgUnparse_Info::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
    9958        3998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
    9959             :                        }
    9960             :                     pointerOfLinkedList = &(pointer[i]);
    9961             :                   }
    9962             :               }
    9963             :         }
    9964             : 
    9965           5 :      if ( pointerOfLinkedList != NULL )
    9966             :         {
    9967             :        // printf ("In SgUnparse_Info::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
    9968           2 :           pointerOfLinkedList->set_freepointer(NULL);
    9969             :        // DQ (6/6/2010): Temporary debugging...
    9970             :        //   ROSE_ASSERT(false);
    9971             :         }
    9972             : 
    9973           5 :      return ;
    9974             :    }
    9975             : 
    9976             : //############################################################################
    9977             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
    9978             :  * within the memory pool and resets the freepointers, in order to achieve a 
    9979             :  * linked list, that has no jumps and starts at the beginning! This function 
    9980             :  * does not extend the memory pool, since we do not delete any memory blocks,
    9981             :  * but delete the valid objects.  
    9982             :  */
    9983             : void
    9984           0 : SgUnparse_Info::clearMemoryPool( )
    9985             :    {
    9986             :   // printf ("Inside of SgUnparse_Info::clearMemoryPool() \n");
    9987             : 
    9988           0 :      SgUnparse_Info* pointer = NULL, *tempPointer = NULL;
    9989           0 :      std::vector < unsigned char* > :: const_iterator block;
    9990           0 :      if ( SgUnparse_Info::pools.empty() == false )
    9991             :         {
    9992           0 :           block = SgUnparse_Info::pools.begin() ;
    9993           0 :           SgUnparse_Info::next_node = (SgUnparse_Info*) (*block);
    9994             : 
    9995           0 :           while ( block != SgUnparse_Info::pools.end() )
    9996             :              {
    9997           0 :                pointer = (SgUnparse_Info*) (*block);
    9998           0 :                if ( tempPointer != NULL )
    9999             :                   {
   10000           0 :                     tempPointer->set_freepointer(pointer);
   10001             :                   }
   10002           0 :                for (unsigned i = 0; i < SgUnparse_Info::pool_size - 1; ++i)
   10003             :                   {
   10004           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   10005             :                   }
   10006           0 :                 pointer[SgUnparse_Info::pool_size-1].set_freepointer(NULL);
   10007           0 :                 tempPointer = &(pointer[SgUnparse_Info::pool_size-1]);
   10008           0 :                 ++block;
   10009             :              }
   10010             :         }
   10011           0 :    }
   10012             : 
   10013           5 : void SgUnparse_Info::deleteMemoryPool() {
   10014           9 :   for (auto p: SgUnparse_Info::pools) {
   10015           4 :     ROSE_FREE(p);
   10016             :   }
   10017           5 :   SgUnparse_Info::next_node = nullptr;
   10018           5 :   SgUnparse_Info::pools.clear();
   10019           5 : }
   10020             : 
   10021             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   10022             : //                 reading multiple binary files to for a single AST.
   10023             : /////////// new version ////////////////////////////////
   10024             : //############################################################################
   10025             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   10026             : void
   10027           2 : SgUnparse_Info::extendMemoryPoolForFileIO( )
   10028             :   {
   10029           2 :     size_t blockIndex = SgUnparse_Info::pools.size();
   10030           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnparse_Info) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnparse_Info);
   10031             : 
   10032           2 :     while ( (blockIndex * SgUnparse_Info::pool_size) < newPoolSize)
   10033             :       {
   10034             : #if ROSE_ALLOC_TRACE
   10035             :         if (blockIndex > 0) {
   10036             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnparse_Info) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnparse_Info) = %" PRIuPTR " SgUnparse_Info::pool_size = %d \n",
   10037             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnparse_Info),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnparse_Info),SgUnparse_Info::pool_size);
   10038             :         }
   10039             : #endif
   10040             : 
   10041           0 :         SgUnparse_Info * pointer = (SgUnparse_Info*) ROSE_MALLOC ( SgUnparse_Info::pool_size * sizeof(SgUnparse_Info) );
   10042           0 :         assert( pointer != NULL );
   10043             : #if ROSE_ALLOC_MEMSET == 1
   10044             :         memset(pointer, 0x00, SgUnparse_Info::pool_size * sizeof(SgUnparse_Info));
   10045             : #elif ROSE_ALLOC_MEMSET == 2
   10046             :         memset(pointer, 0xCC, SgUnparse_Info::pool_size * sizeof(SgUnparse_Info));
   10047             : #endif
   10048           0 :         SgUnparse_Info::pools.push_back( (unsigned char*)(pointer) );
   10049           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnparse_Info::pool_size * sizeof(SgUnparse_Info), V_SgUnparse_Info ) );
   10050             : 
   10051           0 :         if ( SgUnparse_Info::next_node != NULL ) {
   10052           0 :           if ( blockIndex > 0 ) {
   10053           0 :             SgUnparse_Info * blkptr = (SgUnparse_Info*)(SgUnparse_Info::pools[blockIndex-1]);
   10054           0 :             blkptr[ SgUnparse_Info::pool_size - 1 ].set_freepointer(pointer);
   10055             :           }
   10056             :         } else {
   10057           0 :           SgUnparse_Info::next_node = pointer;
   10058             :         }
   10059             : 
   10060           0 :         for (unsigned i = 0; i < SgUnparse_Info::pool_size-1; ++i)
   10061             :            {
   10062           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   10063             :            }
   10064           0 :         pointer[ SgUnparse_Info::pool_size -1 ].set_freepointer(NULL);
   10065             : 
   10066           0 :         blockIndex++;
   10067             :       }
   10068           2 :   }
   10069             : 
   10070             : //############################################################################
   10071             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   10072             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   10073             :  * not compressed. However, that stuff is not yet implemented! 
   10074             :  */
   10075             : unsigned long
   10076           0 : SgUnparse_Info::getNumberOfLastValidPointer()
   10077             :    {
   10078           0 :       SgUnparse_Info* testPointer = (SgUnparse_Info*)(SgUnparse_Info::pools.back());
   10079           0 :       unsigned long localIndex = SgUnparse_Info::pool_size - 1;
   10080           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   10081             :          {
   10082           0 :            localIndex--;
   10083             :          }
   10084           0 :       return (localIndex + SgUnparse_Info::pool_size * (SgUnparse_Info::pools.size()-1));
   10085             :    }
   10086             : 
   10087             : //############################################################################
   10088             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   10089             :  * memory pool and initializes the data member in class SgUnparse_InfoStroageClass
   10090             :  * from its counterpart of SgUnparse_Info. The return value is just for checking, 
   10091             :  * that the whole StorageClassArray is initialized!
   10092             :  */
   10093             : unsigned long
   10094           0 : SgUnparse_Info::initializeStorageClassArray( SgUnparse_InfoStorageClass *storageArray )
   10095             :    {
   10096           0 :      unsigned long storageCounter = 0;
   10097           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnparse_Info::pools.begin();
   10098           0 :      SgUnparse_Info* pointer = NULL;
   10099           0 :      while ( block != SgUnparse_Info::pools.end() ) {
   10100           0 :           pointer = (SgUnparse_Info*) (*block);
   10101           0 :           for ( unsigned i = 0; i < SgUnparse_Info::pool_size; ++i ) {
   10102           0 :                if ( pointer->get_freepointer() != NULL ) {
   10103           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   10104           0 :                  storageArray++;
   10105           0 :                  storageCounter++;
   10106             :                }
   10107           0 :                pointer++;
   10108             :              }
   10109           0 :            block++;
   10110             :         }
   10111           0 :      return storageCounter;
   10112             :    }
   10113             : 
   10114             : /* #line 10115 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   10115             : 
   10116             : 
   10117             : 
   10118             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   10119             : 
   10120             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   10121             : 
   10122             : //############################################################################
   10123             : /* JH (02/02/2006) Constructor of the IR node SgBaseClass that takes its 
   10124             :  * corresponding StorageClass as parameter
   10125             :  */
   10126         620 : SgBaseClass :: SgBaseClass ( const SgBaseClassStorageClass& storageSource )   : SgSupport (storageSource)
   10127             :    {
   10128             : 
   10129             : 
   10130             : /* #line 10131 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   10131             : 
   10132         620 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   10133         620 :      p_base_class =  (SgClassDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_class) );
   10134         620 :      p_isDirectBaseClass = storageSource.storageOf_isDirectBaseClass ;
   10135         620 :      p_baseClassModifier =  (SgBaseClassModifier*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_baseClassModifier) );
   10136         620 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   10137         620 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   10138         620 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   10139             : 
   10140             : 
   10141             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   10142             : 
   10143             : 
   10144         620 :    }
   10145             : 
   10146             : //############################################################################
   10147             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   10148             :  * within the working AST. 
   10149             :  */
   10150        4900 : SgBaseClass * SgBaseClass::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   10151        4900 :      SgBaseClass* returnPointer = NULL;
   10152        4900 :      if ( globalIndex != 0 )
   10153             :         {
   10154             : 
   10155             : #if FILE_IO_EXTRA_CHECK
   10156        4900 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBaseClass ) ) <= globalIndex ) ;
   10157        4900 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBaseClass + 1 ) ) );
   10158             : #endif
   10159        4900 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBaseClass )  
   10160        4900 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBaseClass );
   10161        4900 :           unsigned long positionInPool = localIndex % SgBaseClass::pool_size;
   10162        4900 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBaseClass::pool_size;
   10163             : 
   10164             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   10165             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   10166             : 
   10167        4900 :           returnPointer = &( ( (SgBaseClass*)(SgBaseClass::pools[memoryBlock]) ) [positionInPool]) ;
   10168             : 
   10169        4900 :           ROSE_ASSERT( returnPointer != NULL ) ;
   10170             :         }
   10171        4900 :      return returnPointer ;
   10172             :    }
   10173             : 
   10174             : //############################################################################
   10175             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   10176             :   for the AST with the index astIndex
   10177             : */
   10178           0 : SgBaseClass * SgBaseClass::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   10179           0 :      SgBaseClass* returnPointer = NULL;
   10180           0 :      if ( globalIndex != 0 )
   10181             :         {
   10182             : 
   10183             : #if FILE_IO_EXTRA_CHECK
   10184           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBaseClass ) ) <= globalIndex ) ;
   10185           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBaseClass + 1 ) ) );
   10186             : #endif
   10187           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBaseClass )
   10188           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBaseClass );
   10189           0 :           unsigned long positionInPool = localIndex % SgBaseClass::pool_size ;
   10190           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBaseClass::pool_size ;
   10191             : 
   10192             : #if FILE_IO_EXTRA_CHECK
   10193             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   10194             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   10195             : #endif
   10196             : 
   10197           0 :           returnPointer = &( ( (SgBaseClass*)(SgBaseClass::pools[memoryBlock]) ) [positionInPool]) ;
   10198             : 
   10199             : #if FILE_IO_EXTRA_CHECK
   10200           0 :           assert ( returnPointer != NULL ) ;
   10201             : #endif
   10202             :         }
   10203           0 :      return returnPointer ;
   10204             :    }
   10205             : 
   10206             : //############################################################################
   10207             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   10208             :  * pool size! We set for every valid object in the memory pool the freepointer
   10209             :  * to the global index and increase the global index afterwards. For all the 
   10210             :  * invalid objects (means address ranges within the memory pool that were not
   10211             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   10212             :  * distinguish valid from invalid objects! 
   10213             :  */
   10214             : unsigned long
   10215           5 : SgBaseClass::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   10216             :    {
   10217           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   10218           5 :      SgBaseClass* pointer = NULL;
   10219           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   10220           5 :      std::vector < unsigned char* > :: const_iterator block;
   10221           6 :      for ( block = SgBaseClass::pools.begin(); block != SgBaseClass::pools.end() ; ++block )
   10222             :         {
   10223           1 :           pointer = (SgBaseClass*)(*block);
   10224        2001 :           for (unsigned i = 0; i < SgBaseClass::pool_size; ++i )
   10225             :              {
   10226             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   10227             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   10228             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   10229             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   10230             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   10231             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   10232             :             // properly; so this will have to be checked next.
   10233             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   10234             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   10235        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   10236             :                   {
   10237         420 :                     pointer[i].set_freepointer((SgBaseClass*)(globalIndex));
   10238         420 :                     globalIndex++;
   10239             :                   }
   10240             :                else
   10241             :                   {
   10242        1580 :                     pointer[i].set_freepointer(NULL);
   10243             :                   }
   10244             :               }
   10245             :         }
   10246           5 :      return globalIndex;
   10247             :    }
   10248             : 
   10249             : //############################################################################
   10250             : // JH (01/14/2006)
   10251             : void
   10252           5 : SgBaseClass::resetValidFreepointers( )
   10253             :    {
   10254           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   10255           5 :      SgBaseClass* pointer = NULL;
   10256           5 :      std::vector < unsigned char* > :: const_iterator block;
   10257           5 :      SgBaseClass* pointerOfLinkedList = NULL;
   10258           6 :      for ( block = SgBaseClass::pools.begin(); block != SgBaseClass::pools.end() ; ++block )
   10259             :         {
   10260           1 :           pointer = (SgBaseClass*)(*block);
   10261        2001 :           for (unsigned i = 0; i < SgBaseClass::pool_size; ++i )
   10262             :              {
   10263             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   10264             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   10265             :             // memory blocks!.
   10266        2000 :                if ( pointer[i].get_freepointer() != NULL )
   10267             :                   {
   10268         420 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   10269             :                   }
   10270             :                else
   10271             :                   {
   10272        1580 :                     if ( pointerOfLinkedList == NULL )
   10273             :                        {
   10274           1 :                          SgBaseClass::next_node = &(pointer[i]);
   10275             :                        }
   10276             :                     else
   10277             :                        {
   10278             :                       // printf ("In SgBaseClass::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   10279        1579 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   10280             :                        }
   10281             :                     pointerOfLinkedList = &(pointer[i]);
   10282             :                   }
   10283             :               }
   10284             :         }
   10285             : 
   10286           5 :      if ( pointerOfLinkedList != NULL )
   10287             :         {
   10288             :        // printf ("In SgBaseClass::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   10289           1 :           pointerOfLinkedList->set_freepointer(NULL);
   10290             :        // DQ (6/6/2010): Temporary debugging...
   10291             :        //   ROSE_ASSERT(false);
   10292             :         }
   10293             : 
   10294           5 :      return ;
   10295             :    }
   10296             : 
   10297             : //############################################################################
   10298             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   10299             :  * within the memory pool and resets the freepointers, in order to achieve a 
   10300             :  * linked list, that has no jumps and starts at the beginning! This function 
   10301             :  * does not extend the memory pool, since we do not delete any memory blocks,
   10302             :  * but delete the valid objects.  
   10303             :  */
   10304             : void
   10305           0 : SgBaseClass::clearMemoryPool( )
   10306             :    {
   10307             :   // printf ("Inside of SgBaseClass::clearMemoryPool() \n");
   10308             : 
   10309           0 :      SgBaseClass* pointer = NULL, *tempPointer = NULL;
   10310           0 :      std::vector < unsigned char* > :: const_iterator block;
   10311           0 :      if ( SgBaseClass::pools.empty() == false )
   10312             :         {
   10313           0 :           block = SgBaseClass::pools.begin() ;
   10314           0 :           SgBaseClass::next_node = (SgBaseClass*) (*block);
   10315             : 
   10316           0 :           while ( block != SgBaseClass::pools.end() )
   10317             :              {
   10318           0 :                pointer = (SgBaseClass*) (*block);
   10319           0 :                if ( tempPointer != NULL )
   10320             :                   {
   10321           0 :                     tempPointer->set_freepointer(pointer);
   10322             :                   }
   10323           0 :                for (unsigned i = 0; i < SgBaseClass::pool_size - 1; ++i)
   10324             :                   {
   10325           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   10326             :                   }
   10327           0 :                 pointer[SgBaseClass::pool_size-1].set_freepointer(NULL);
   10328           0 :                 tempPointer = &(pointer[SgBaseClass::pool_size-1]);
   10329           0 :                 ++block;
   10330             :              }
   10331             :         }
   10332           0 :    }
   10333             : 
   10334           5 : void SgBaseClass::deleteMemoryPool() {
   10335           7 :   for (auto p: SgBaseClass::pools) {
   10336           2 :     ROSE_FREE(p);
   10337             :   }
   10338           5 :   SgBaseClass::next_node = nullptr;
   10339           5 :   SgBaseClass::pools.clear();
   10340           5 : }
   10341             : 
   10342             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   10343             : //                 reading multiple binary files to for a single AST.
   10344             : /////////// new version ////////////////////////////////
   10345             : //############################################################################
   10346             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   10347             : void
   10348           2 : SgBaseClass::extendMemoryPoolForFileIO( )
   10349             :   {
   10350           2 :     size_t blockIndex = SgBaseClass::pools.size();
   10351           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBaseClass) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBaseClass);
   10352             : 
   10353           3 :     while ( (blockIndex * SgBaseClass::pool_size) < newPoolSize)
   10354             :       {
   10355             : #if ROSE_ALLOC_TRACE
   10356             :         if (blockIndex > 0) {
   10357             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBaseClass) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBaseClass) = %" PRIuPTR " SgBaseClass::pool_size = %d \n",
   10358             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBaseClass),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBaseClass),SgBaseClass::pool_size);
   10359             :         }
   10360             : #endif
   10361             : 
   10362           1 :         SgBaseClass * pointer = (SgBaseClass*) ROSE_MALLOC ( SgBaseClass::pool_size * sizeof(SgBaseClass) );
   10363           1 :         assert( pointer != NULL );
   10364             : #if ROSE_ALLOC_MEMSET == 1
   10365             :         memset(pointer, 0x00, SgBaseClass::pool_size * sizeof(SgBaseClass));
   10366             : #elif ROSE_ALLOC_MEMSET == 2
   10367             :         memset(pointer, 0xCC, SgBaseClass::pool_size * sizeof(SgBaseClass));
   10368             : #endif
   10369           1 :         SgBaseClass::pools.push_back( (unsigned char*)(pointer) );
   10370           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBaseClass::pool_size * sizeof(SgBaseClass), V_SgBaseClass ) );
   10371             : 
   10372           1 :         if ( SgBaseClass::next_node != NULL ) {
   10373           0 :           if ( blockIndex > 0 ) {
   10374           0 :             SgBaseClass * blkptr = (SgBaseClass*)(SgBaseClass::pools[blockIndex-1]);
   10375           0 :             blkptr[ SgBaseClass::pool_size - 1 ].set_freepointer(pointer);
   10376             :           }
   10377             :         } else {
   10378           1 :           SgBaseClass::next_node = pointer;
   10379             :         }
   10380             : 
   10381        2000 :         for (unsigned i = 0; i < SgBaseClass::pool_size-1; ++i)
   10382             :            {
   10383        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   10384             :            }
   10385           1 :         pointer[ SgBaseClass::pool_size -1 ].set_freepointer(NULL);
   10386             : 
   10387           1 :         blockIndex++;
   10388             :       }
   10389           2 :   }
   10390             : 
   10391             : //############################################################################
   10392             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   10393             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   10394             :  * not compressed. However, that stuff is not yet implemented! 
   10395             :  */
   10396             : unsigned long
   10397           0 : SgBaseClass::getNumberOfLastValidPointer()
   10398             :    {
   10399           0 :       SgBaseClass* testPointer = (SgBaseClass*)(SgBaseClass::pools.back());
   10400           0 :       unsigned long localIndex = SgBaseClass::pool_size - 1;
   10401           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   10402             :          {
   10403           0 :            localIndex--;
   10404             :          }
   10405           0 :       return (localIndex + SgBaseClass::pool_size * (SgBaseClass::pools.size()-1));
   10406             :    }
   10407             : 
   10408             : //############################################################################
   10409             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   10410             :  * memory pool and initializes the data member in class SgBaseClassStroageClass
   10411             :  * from its counterpart of SgBaseClass. The return value is just for checking, 
   10412             :  * that the whole StorageClassArray is initialized!
   10413             :  */
   10414             : unsigned long
   10415           1 : SgBaseClass::initializeStorageClassArray( SgBaseClassStorageClass *storageArray )
   10416             :    {
   10417           1 :      unsigned long storageCounter = 0;
   10418           1 :      std::vector < unsigned char* > :: const_iterator block = SgBaseClass::pools.begin();
   10419           1 :      SgBaseClass* pointer = NULL;
   10420           2 :      while ( block != SgBaseClass::pools.end() ) {
   10421           1 :           pointer = (SgBaseClass*) (*block);
   10422        2001 :           for ( unsigned i = 0; i < SgBaseClass::pool_size; ++i ) {
   10423        2000 :                if ( pointer->get_freepointer() != NULL ) {
   10424         420 :                  storageArray->pickOutIRNodeData (pointer) ;
   10425         420 :                  storageArray++;
   10426         420 :                  storageCounter++;
   10427             :                }
   10428        2000 :                pointer++;
   10429             :              }
   10430           1 :            block++;
   10431             :         }
   10432           1 :      return storageCounter;
   10433             :    }
   10434             : 
   10435             : /* #line 10436 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   10436             : 
   10437             : 
   10438             : 
   10439             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   10440             : 
   10441             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   10442             : 
   10443             : //############################################################################
   10444             : /* JH (02/02/2006) Constructor of the IR node SgExpBaseClass that takes its 
   10445             :  * corresponding StorageClass as parameter
   10446             :  */
   10447           0 : SgExpBaseClass :: SgExpBaseClass ( const SgExpBaseClassStorageClass& storageSource )   : SgBaseClass (storageSource)
   10448             :    {
   10449             : 
   10450             : 
   10451             : /* #line 10452 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   10452             : 
   10453           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   10454           0 :      p_base_class_exp =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_class_exp) );
   10455             : 
   10456             : 
   10457             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   10458             : 
   10459             : 
   10460           0 :    }
   10461             : 
   10462             : //############################################################################
   10463             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   10464             :  * within the working AST. 
   10465             :  */
   10466           0 : SgExpBaseClass * SgExpBaseClass::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   10467           0 :      SgExpBaseClass* returnPointer = NULL;
   10468           0 :      if ( globalIndex != 0 )
   10469             :         {
   10470             : 
   10471             : #if FILE_IO_EXTRA_CHECK
   10472           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgExpBaseClass ) ) <= globalIndex ) ;
   10473           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExpBaseClass + 1 ) ) );
   10474             : #endif
   10475           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExpBaseClass )  
   10476           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgExpBaseClass );
   10477           0 :           unsigned long positionInPool = localIndex % SgExpBaseClass::pool_size;
   10478           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExpBaseClass::pool_size;
   10479             : 
   10480             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   10481             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   10482             : 
   10483           0 :           returnPointer = &( ( (SgExpBaseClass*)(SgExpBaseClass::pools[memoryBlock]) ) [positionInPool]) ;
   10484             : 
   10485           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   10486             :         }
   10487           0 :      return returnPointer ;
   10488             :    }
   10489             : 
   10490             : //############################################################################
   10491             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   10492             :   for the AST with the index astIndex
   10493             : */
   10494           0 : SgExpBaseClass * SgExpBaseClass::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   10495           0 :      SgExpBaseClass* returnPointer = NULL;
   10496           0 :      if ( globalIndex != 0 )
   10497             :         {
   10498             : 
   10499             : #if FILE_IO_EXTRA_CHECK
   10500           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgExpBaseClass ) ) <= globalIndex ) ;
   10501           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExpBaseClass + 1 ) ) );
   10502             : #endif
   10503           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExpBaseClass )
   10504           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgExpBaseClass );
   10505           0 :           unsigned long positionInPool = localIndex % SgExpBaseClass::pool_size ;
   10506           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExpBaseClass::pool_size ;
   10507             : 
   10508             : #if FILE_IO_EXTRA_CHECK
   10509             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   10510             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   10511             : #endif
   10512             : 
   10513           0 :           returnPointer = &( ( (SgExpBaseClass*)(SgExpBaseClass::pools[memoryBlock]) ) [positionInPool]) ;
   10514             : 
   10515             : #if FILE_IO_EXTRA_CHECK
   10516           0 :           assert ( returnPointer != NULL ) ;
   10517             : #endif
   10518             :         }
   10519           0 :      return returnPointer ;
   10520             :    }
   10521             : 
   10522             : //############################################################################
   10523             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   10524             :  * pool size! We set for every valid object in the memory pool the freepointer
   10525             :  * to the global index and increase the global index afterwards. For all the 
   10526             :  * invalid objects (means address ranges within the memory pool that were not
   10527             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   10528             :  * distinguish valid from invalid objects! 
   10529             :  */
   10530             : unsigned long
   10531           5 : SgExpBaseClass::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   10532             :    {
   10533           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   10534           5 :      SgExpBaseClass* pointer = NULL;
   10535           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   10536           5 :      std::vector < unsigned char* > :: const_iterator block;
   10537           5 :      for ( block = SgExpBaseClass::pools.begin(); block != SgExpBaseClass::pools.end() ; ++block )
   10538             :         {
   10539           0 :           pointer = (SgExpBaseClass*)(*block);
   10540           0 :           for (unsigned i = 0; i < SgExpBaseClass::pool_size; ++i )
   10541             :              {
   10542             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   10543             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   10544             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   10545             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   10546             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   10547             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   10548             :             // properly; so this will have to be checked next.
   10549             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   10550             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   10551           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   10552             :                   {
   10553           0 :                     pointer[i].set_freepointer((SgExpBaseClass*)(globalIndex));
   10554           0 :                     globalIndex++;
   10555             :                   }
   10556             :                else
   10557             :                   {
   10558           0 :                     pointer[i].set_freepointer(NULL);
   10559             :                   }
   10560             :               }
   10561             :         }
   10562           5 :      return globalIndex;
   10563             :    }
   10564             : 
   10565             : //############################################################################
   10566             : // JH (01/14/2006)
   10567             : void
   10568           5 : SgExpBaseClass::resetValidFreepointers( )
   10569             :    {
   10570           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   10571           5 :      SgExpBaseClass* pointer = NULL;
   10572           5 :      std::vector < unsigned char* > :: const_iterator block;
   10573           5 :      SgExpBaseClass* pointerOfLinkedList = NULL;
   10574           5 :      for ( block = SgExpBaseClass::pools.begin(); block != SgExpBaseClass::pools.end() ; ++block )
   10575             :         {
   10576           0 :           pointer = (SgExpBaseClass*)(*block);
   10577           0 :           for (unsigned i = 0; i < SgExpBaseClass::pool_size; ++i )
   10578             :              {
   10579             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   10580             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   10581             :             // memory blocks!.
   10582           0 :                if ( pointer[i].get_freepointer() != NULL )
   10583             :                   {
   10584           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   10585             :                   }
   10586             :                else
   10587             :                   {
   10588           0 :                     if ( pointerOfLinkedList == NULL )
   10589             :                        {
   10590           0 :                          SgExpBaseClass::next_node = &(pointer[i]);
   10591             :                        }
   10592             :                     else
   10593             :                        {
   10594             :                       // printf ("In SgExpBaseClass::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   10595           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   10596             :                        }
   10597             :                     pointerOfLinkedList = &(pointer[i]);
   10598             :                   }
   10599             :               }
   10600             :         }
   10601             : 
   10602           5 :      if ( pointerOfLinkedList != NULL )
   10603             :         {
   10604             :        // printf ("In SgExpBaseClass::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   10605           0 :           pointerOfLinkedList->set_freepointer(NULL);
   10606             :        // DQ (6/6/2010): Temporary debugging...
   10607             :        //   ROSE_ASSERT(false);
   10608             :         }
   10609             : 
   10610           5 :      return ;
   10611             :    }
   10612             : 
   10613             : //############################################################################
   10614             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   10615             :  * within the memory pool and resets the freepointers, in order to achieve a 
   10616             :  * linked list, that has no jumps and starts at the beginning! This function 
   10617             :  * does not extend the memory pool, since we do not delete any memory blocks,
   10618             :  * but delete the valid objects.  
   10619             :  */
   10620             : void
   10621           0 : SgExpBaseClass::clearMemoryPool( )
   10622             :    {
   10623             :   // printf ("Inside of SgExpBaseClass::clearMemoryPool() \n");
   10624             : 
   10625           0 :      SgExpBaseClass* pointer = NULL, *tempPointer = NULL;
   10626           0 :      std::vector < unsigned char* > :: const_iterator block;
   10627           0 :      if ( SgExpBaseClass::pools.empty() == false )
   10628             :         {
   10629           0 :           block = SgExpBaseClass::pools.begin() ;
   10630           0 :           SgExpBaseClass::next_node = (SgExpBaseClass*) (*block);
   10631             : 
   10632           0 :           while ( block != SgExpBaseClass::pools.end() )
   10633             :              {
   10634           0 :                pointer = (SgExpBaseClass*) (*block);
   10635           0 :                if ( tempPointer != NULL )
   10636             :                   {
   10637           0 :                     tempPointer->set_freepointer(pointer);
   10638             :                   }
   10639           0 :                for (unsigned i = 0; i < SgExpBaseClass::pool_size - 1; ++i)
   10640             :                   {
   10641           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   10642             :                   }
   10643           0 :                 pointer[SgExpBaseClass::pool_size-1].set_freepointer(NULL);
   10644           0 :                 tempPointer = &(pointer[SgExpBaseClass::pool_size-1]);
   10645           0 :                 ++block;
   10646             :              }
   10647             :         }
   10648           0 :    }
   10649             : 
   10650           5 : void SgExpBaseClass::deleteMemoryPool() {
   10651           5 :   for (auto p: SgExpBaseClass::pools) {
   10652           0 :     ROSE_FREE(p);
   10653             :   }
   10654           5 :   SgExpBaseClass::next_node = nullptr;
   10655           5 :   SgExpBaseClass::pools.clear();
   10656           5 : }
   10657             : 
   10658             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   10659             : //                 reading multiple binary files to for a single AST.
   10660             : /////////// new version ////////////////////////////////
   10661             : //############################################################################
   10662             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   10663             : void
   10664           2 : SgExpBaseClass::extendMemoryPoolForFileIO( )
   10665             :   {
   10666           2 :     size_t blockIndex = SgExpBaseClass::pools.size();
   10667           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgExpBaseClass) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpBaseClass);
   10668             : 
   10669           2 :     while ( (blockIndex * SgExpBaseClass::pool_size) < newPoolSize)
   10670             :       {
   10671             : #if ROSE_ALLOC_TRACE
   10672             :         if (blockIndex > 0) {
   10673             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgExpBaseClass) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpBaseClass) = %" PRIuPTR " SgExpBaseClass::pool_size = %d \n",
   10674             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgExpBaseClass),AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpBaseClass),SgExpBaseClass::pool_size);
   10675             :         }
   10676             : #endif
   10677             : 
   10678           0 :         SgExpBaseClass * pointer = (SgExpBaseClass*) ROSE_MALLOC ( SgExpBaseClass::pool_size * sizeof(SgExpBaseClass) );
   10679           0 :         assert( pointer != NULL );
   10680             : #if ROSE_ALLOC_MEMSET == 1
   10681             :         memset(pointer, 0x00, SgExpBaseClass::pool_size * sizeof(SgExpBaseClass));
   10682             : #elif ROSE_ALLOC_MEMSET == 2
   10683             :         memset(pointer, 0xCC, SgExpBaseClass::pool_size * sizeof(SgExpBaseClass));
   10684             : #endif
   10685           0 :         SgExpBaseClass::pools.push_back( (unsigned char*)(pointer) );
   10686           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgExpBaseClass::pool_size * sizeof(SgExpBaseClass), V_SgExpBaseClass ) );
   10687             : 
   10688           0 :         if ( SgExpBaseClass::next_node != NULL ) {
   10689           0 :           if ( blockIndex > 0 ) {
   10690           0 :             SgExpBaseClass * blkptr = (SgExpBaseClass*)(SgExpBaseClass::pools[blockIndex-1]);
   10691           0 :             blkptr[ SgExpBaseClass::pool_size - 1 ].set_freepointer(pointer);
   10692             :           }
   10693             :         } else {
   10694           0 :           SgExpBaseClass::next_node = pointer;
   10695             :         }
   10696             : 
   10697           0 :         for (unsigned i = 0; i < SgExpBaseClass::pool_size-1; ++i)
   10698             :            {
   10699           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   10700             :            }
   10701           0 :         pointer[ SgExpBaseClass::pool_size -1 ].set_freepointer(NULL);
   10702             : 
   10703           0 :         blockIndex++;
   10704             :       }
   10705           2 :   }
   10706             : 
   10707             : //############################################################################
   10708             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   10709             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   10710             :  * not compressed. However, that stuff is not yet implemented! 
   10711             :  */
   10712             : unsigned long
   10713           0 : SgExpBaseClass::getNumberOfLastValidPointer()
   10714             :    {
   10715           0 :       SgExpBaseClass* testPointer = (SgExpBaseClass*)(SgExpBaseClass::pools.back());
   10716           0 :       unsigned long localIndex = SgExpBaseClass::pool_size - 1;
   10717           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   10718             :          {
   10719           0 :            localIndex--;
   10720             :          }
   10721           0 :       return (localIndex + SgExpBaseClass::pool_size * (SgExpBaseClass::pools.size()-1));
   10722             :    }
   10723             : 
   10724             : //############################################################################
   10725             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   10726             :  * memory pool and initializes the data member in class SgExpBaseClassStroageClass
   10727             :  * from its counterpart of SgExpBaseClass. The return value is just for checking, 
   10728             :  * that the whole StorageClassArray is initialized!
   10729             :  */
   10730             : unsigned long
   10731           0 : SgExpBaseClass::initializeStorageClassArray( SgExpBaseClassStorageClass *storageArray )
   10732             :    {
   10733           0 :      unsigned long storageCounter = 0;
   10734           0 :      std::vector < unsigned char* > :: const_iterator block = SgExpBaseClass::pools.begin();
   10735           0 :      SgExpBaseClass* pointer = NULL;
   10736           0 :      while ( block != SgExpBaseClass::pools.end() ) {
   10737           0 :           pointer = (SgExpBaseClass*) (*block);
   10738           0 :           for ( unsigned i = 0; i < SgExpBaseClass::pool_size; ++i ) {
   10739           0 :                if ( pointer->get_freepointer() != NULL ) {
   10740           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   10741           0 :                  storageArray++;
   10742           0 :                  storageCounter++;
   10743             :                }
   10744           0 :                pointer++;
   10745             :              }
   10746           0 :            block++;
   10747             :         }
   10748           0 :      return storageCounter;
   10749             :    }
   10750             : 
   10751             : /* #line 10752 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   10752             : 
   10753             : 
   10754             : 
   10755             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   10756             : 
   10757             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   10758             : 
   10759             : //############################################################################
   10760             : /* JH (02/02/2006) Constructor of the IR node SgNonrealBaseClass that takes its 
   10761             :  * corresponding StorageClass as parameter
   10762             :  */
   10763         200 : SgNonrealBaseClass :: SgNonrealBaseClass ( const SgNonrealBaseClassStorageClass& storageSource )   : SgBaseClass (storageSource)
   10764             :    {
   10765             : 
   10766             : 
   10767             : /* #line 10768 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   10768             : 
   10769         200 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   10770         200 :      p_base_class_nonreal =  (SgNonrealDecl*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_class_nonreal) );
   10771             : 
   10772             : 
   10773             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   10774             : 
   10775             : 
   10776         200 :    }
   10777             : 
   10778             : //############################################################################
   10779             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   10780             :  * within the working AST. 
   10781             :  */
   10782         947 : SgNonrealBaseClass * SgNonrealBaseClass::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   10783         947 :      SgNonrealBaseClass* returnPointer = NULL;
   10784         947 :      if ( globalIndex != 0 )
   10785             :         {
   10786             : 
   10787             : #if FILE_IO_EXTRA_CHECK
   10788         947 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNonrealBaseClass ) ) <= globalIndex ) ;
   10789         947 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealBaseClass + 1 ) ) );
   10790             : #endif
   10791         947 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealBaseClass )  
   10792         947 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNonrealBaseClass );
   10793         947 :           unsigned long positionInPool = localIndex % SgNonrealBaseClass::pool_size;
   10794         947 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealBaseClass::pool_size;
   10795             : 
   10796             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   10797             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   10798             : 
   10799         947 :           returnPointer = &( ( (SgNonrealBaseClass*)(SgNonrealBaseClass::pools[memoryBlock]) ) [positionInPool]) ;
   10800             : 
   10801         947 :           ROSE_ASSERT( returnPointer != NULL ) ;
   10802             :         }
   10803         947 :      return returnPointer ;
   10804             :    }
   10805             : 
   10806             : //############################################################################
   10807             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   10808             :   for the AST with the index astIndex
   10809             : */
   10810           0 : SgNonrealBaseClass * SgNonrealBaseClass::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   10811           0 :      SgNonrealBaseClass* returnPointer = NULL;
   10812           0 :      if ( globalIndex != 0 )
   10813             :         {
   10814             : 
   10815             : #if FILE_IO_EXTRA_CHECK
   10816           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNonrealBaseClass ) ) <= globalIndex ) ;
   10817           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealBaseClass + 1 ) ) );
   10818             : #endif
   10819           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealBaseClass )
   10820           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNonrealBaseClass );
   10821           0 :           unsigned long positionInPool = localIndex % SgNonrealBaseClass::pool_size ;
   10822           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealBaseClass::pool_size ;
   10823             : 
   10824             : #if FILE_IO_EXTRA_CHECK
   10825             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   10826             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   10827             : #endif
   10828             : 
   10829           0 :           returnPointer = &( ( (SgNonrealBaseClass*)(SgNonrealBaseClass::pools[memoryBlock]) ) [positionInPool]) ;
   10830             : 
   10831             : #if FILE_IO_EXTRA_CHECK
   10832           0 :           assert ( returnPointer != NULL ) ;
   10833             : #endif
   10834             :         }
   10835           0 :      return returnPointer ;
   10836             :    }
   10837             : 
   10838             : //############################################################################
   10839             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   10840             :  * pool size! We set for every valid object in the memory pool the freepointer
   10841             :  * to the global index and increase the global index afterwards. For all the 
   10842             :  * invalid objects (means address ranges within the memory pool that were not
   10843             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   10844             :  * distinguish valid from invalid objects! 
   10845             :  */
   10846             : unsigned long
   10847           5 : SgNonrealBaseClass::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   10848             :    {
   10849           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   10850           5 :      SgNonrealBaseClass* pointer = NULL;
   10851           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   10852           5 :      std::vector < unsigned char* > :: const_iterator block;
   10853           6 :      for ( block = SgNonrealBaseClass::pools.begin(); block != SgNonrealBaseClass::pools.end() ; ++block )
   10854             :         {
   10855           1 :           pointer = (SgNonrealBaseClass*)(*block);
   10856        2001 :           for (unsigned i = 0; i < SgNonrealBaseClass::pool_size; ++i )
   10857             :              {
   10858             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   10859             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   10860             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   10861             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   10862             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   10863             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   10864             :             // properly; so this will have to be checked next.
   10865             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   10866             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   10867        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   10868             :                   {
   10869         200 :                     pointer[i].set_freepointer((SgNonrealBaseClass*)(globalIndex));
   10870         200 :                     globalIndex++;
   10871             :                   }
   10872             :                else
   10873             :                   {
   10874        1800 :                     pointer[i].set_freepointer(NULL);
   10875             :                   }
   10876             :               }
   10877             :         }
   10878           5 :      return globalIndex;
   10879             :    }
   10880             : 
   10881             : //############################################################################
   10882             : // JH (01/14/2006)
   10883             : void
   10884           5 : SgNonrealBaseClass::resetValidFreepointers( )
   10885             :    {
   10886           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   10887           5 :      SgNonrealBaseClass* pointer = NULL;
   10888           5 :      std::vector < unsigned char* > :: const_iterator block;
   10889           5 :      SgNonrealBaseClass* pointerOfLinkedList = NULL;
   10890           6 :      for ( block = SgNonrealBaseClass::pools.begin(); block != SgNonrealBaseClass::pools.end() ; ++block )
   10891             :         {
   10892           1 :           pointer = (SgNonrealBaseClass*)(*block);
   10893        2001 :           for (unsigned i = 0; i < SgNonrealBaseClass::pool_size; ++i )
   10894             :              {
   10895             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   10896             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   10897             :             // memory blocks!.
   10898        2000 :                if ( pointer[i].get_freepointer() != NULL )
   10899             :                   {
   10900         200 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   10901             :                   }
   10902             :                else
   10903             :                   {
   10904        1800 :                     if ( pointerOfLinkedList == NULL )
   10905             :                        {
   10906           1 :                          SgNonrealBaseClass::next_node = &(pointer[i]);
   10907             :                        }
   10908             :                     else
   10909             :                        {
   10910             :                       // printf ("In SgNonrealBaseClass::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   10911        1799 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   10912             :                        }
   10913             :                     pointerOfLinkedList = &(pointer[i]);
   10914             :                   }
   10915             :               }
   10916             :         }
   10917             : 
   10918           5 :      if ( pointerOfLinkedList != NULL )
   10919             :         {
   10920             :        // printf ("In SgNonrealBaseClass::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   10921           1 :           pointerOfLinkedList->set_freepointer(NULL);
   10922             :        // DQ (6/6/2010): Temporary debugging...
   10923             :        //   ROSE_ASSERT(false);
   10924             :         }
   10925             : 
   10926           5 :      return ;
   10927             :    }
   10928             : 
   10929             : //############################################################################
   10930             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   10931             :  * within the memory pool and resets the freepointers, in order to achieve a 
   10932             :  * linked list, that has no jumps and starts at the beginning! This function 
   10933             :  * does not extend the memory pool, since we do not delete any memory blocks,
   10934             :  * but delete the valid objects.  
   10935             :  */
   10936             : void
   10937           0 : SgNonrealBaseClass::clearMemoryPool( )
   10938             :    {
   10939             :   // printf ("Inside of SgNonrealBaseClass::clearMemoryPool() \n");
   10940             : 
   10941           0 :      SgNonrealBaseClass* pointer = NULL, *tempPointer = NULL;
   10942           0 :      std::vector < unsigned char* > :: const_iterator block;
   10943           0 :      if ( SgNonrealBaseClass::pools.empty() == false )
   10944             :         {
   10945           0 :           block = SgNonrealBaseClass::pools.begin() ;
   10946           0 :           SgNonrealBaseClass::next_node = (SgNonrealBaseClass*) (*block);
   10947             : 
   10948           0 :           while ( block != SgNonrealBaseClass::pools.end() )
   10949             :              {
   10950           0 :                pointer = (SgNonrealBaseClass*) (*block);
   10951           0 :                if ( tempPointer != NULL )
   10952             :                   {
   10953           0 :                     tempPointer->set_freepointer(pointer);
   10954             :                   }
   10955           0 :                for (unsigned i = 0; i < SgNonrealBaseClass::pool_size - 1; ++i)
   10956             :                   {
   10957           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   10958             :                   }
   10959           0 :                 pointer[SgNonrealBaseClass::pool_size-1].set_freepointer(NULL);
   10960           0 :                 tempPointer = &(pointer[SgNonrealBaseClass::pool_size-1]);
   10961           0 :                 ++block;
   10962             :              }
   10963             :         }
   10964           0 :    }
   10965             : 
   10966           5 : void SgNonrealBaseClass::deleteMemoryPool() {
   10967           7 :   for (auto p: SgNonrealBaseClass::pools) {
   10968           2 :     ROSE_FREE(p);
   10969             :   }
   10970           5 :   SgNonrealBaseClass::next_node = nullptr;
   10971           5 :   SgNonrealBaseClass::pools.clear();
   10972           5 : }
   10973             : 
   10974             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   10975             : //                 reading multiple binary files to for a single AST.
   10976             : /////////// new version ////////////////////////////////
   10977             : //############################################################################
   10978             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   10979             : void
   10980           2 : SgNonrealBaseClass::extendMemoryPoolForFileIO( )
   10981             :   {
   10982           2 :     size_t blockIndex = SgNonrealBaseClass::pools.size();
   10983           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealBaseClass) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealBaseClass);
   10984             : 
   10985           3 :     while ( (blockIndex * SgNonrealBaseClass::pool_size) < newPoolSize)
   10986             :       {
   10987             : #if ROSE_ALLOC_TRACE
   10988             :         if (blockIndex > 0) {
   10989             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealBaseClass) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealBaseClass) = %" PRIuPTR " SgNonrealBaseClass::pool_size = %d \n",
   10990             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealBaseClass),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealBaseClass),SgNonrealBaseClass::pool_size);
   10991             :         }
   10992             : #endif
   10993             : 
   10994           1 :         SgNonrealBaseClass * pointer = (SgNonrealBaseClass*) ROSE_MALLOC ( SgNonrealBaseClass::pool_size * sizeof(SgNonrealBaseClass) );
   10995           1 :         assert( pointer != NULL );
   10996             : #if ROSE_ALLOC_MEMSET == 1
   10997             :         memset(pointer, 0x00, SgNonrealBaseClass::pool_size * sizeof(SgNonrealBaseClass));
   10998             : #elif ROSE_ALLOC_MEMSET == 2
   10999             :         memset(pointer, 0xCC, SgNonrealBaseClass::pool_size * sizeof(SgNonrealBaseClass));
   11000             : #endif
   11001           1 :         SgNonrealBaseClass::pools.push_back( (unsigned char*)(pointer) );
   11002           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNonrealBaseClass::pool_size * sizeof(SgNonrealBaseClass), V_SgNonrealBaseClass ) );
   11003             : 
   11004           1 :         if ( SgNonrealBaseClass::next_node != NULL ) {
   11005           0 :           if ( blockIndex > 0 ) {
   11006           0 :             SgNonrealBaseClass * blkptr = (SgNonrealBaseClass*)(SgNonrealBaseClass::pools[blockIndex-1]);
   11007           0 :             blkptr[ SgNonrealBaseClass::pool_size - 1 ].set_freepointer(pointer);
   11008             :           }
   11009             :         } else {
   11010           1 :           SgNonrealBaseClass::next_node = pointer;
   11011             :         }
   11012             : 
   11013        2000 :         for (unsigned i = 0; i < SgNonrealBaseClass::pool_size-1; ++i)
   11014             :            {
   11015        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   11016             :            }
   11017           1 :         pointer[ SgNonrealBaseClass::pool_size -1 ].set_freepointer(NULL);
   11018             : 
   11019           1 :         blockIndex++;
   11020             :       }
   11021           2 :   }
   11022             : 
   11023             : //############################################################################
   11024             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   11025             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   11026             :  * not compressed. However, that stuff is not yet implemented! 
   11027             :  */
   11028             : unsigned long
   11029           0 : SgNonrealBaseClass::getNumberOfLastValidPointer()
   11030             :    {
   11031           0 :       SgNonrealBaseClass* testPointer = (SgNonrealBaseClass*)(SgNonrealBaseClass::pools.back());
   11032           0 :       unsigned long localIndex = SgNonrealBaseClass::pool_size - 1;
   11033           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   11034             :          {
   11035           0 :            localIndex--;
   11036             :          }
   11037           0 :       return (localIndex + SgNonrealBaseClass::pool_size * (SgNonrealBaseClass::pools.size()-1));
   11038             :    }
   11039             : 
   11040             : //############################################################################
   11041             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   11042             :  * memory pool and initializes the data member in class SgNonrealBaseClassStroageClass
   11043             :  * from its counterpart of SgNonrealBaseClass. The return value is just for checking, 
   11044             :  * that the whole StorageClassArray is initialized!
   11045             :  */
   11046             : unsigned long
   11047           1 : SgNonrealBaseClass::initializeStorageClassArray( SgNonrealBaseClassStorageClass *storageArray )
   11048             :    {
   11049           1 :      unsigned long storageCounter = 0;
   11050           1 :      std::vector < unsigned char* > :: const_iterator block = SgNonrealBaseClass::pools.begin();
   11051           1 :      SgNonrealBaseClass* pointer = NULL;
   11052           2 :      while ( block != SgNonrealBaseClass::pools.end() ) {
   11053           1 :           pointer = (SgNonrealBaseClass*) (*block);
   11054        2001 :           for ( unsigned i = 0; i < SgNonrealBaseClass::pool_size; ++i ) {
   11055        2000 :                if ( pointer->get_freepointer() != NULL ) {
   11056         200 :                  storageArray->pickOutIRNodeData (pointer) ;
   11057         200 :                  storageArray++;
   11058         200 :                  storageCounter++;
   11059             :                }
   11060        2000 :                pointer++;
   11061             :              }
   11062           1 :            block++;
   11063             :         }
   11064           1 :      return storageCounter;
   11065             :    }
   11066             : 
   11067             : /* #line 11068 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   11068             : 
   11069             : 
   11070             : 
   11071             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   11072             : 
   11073             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   11074             : 
   11075             : //############################################################################
   11076             : /* JH (02/02/2006) Constructor of the IR node SgTypedefSeq that takes its 
   11077             :  * corresponding StorageClass as parameter
   11078             :  */
   11079       16445 : SgTypedefSeq :: SgTypedefSeq ( const SgTypedefSeqStorageClass& storageSource )   : SgSupport (storageSource)
   11080             :    {
   11081             : 
   11082             : 
   11083             : /* #line 11084 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   11084             : 
   11085       16445 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   11086       16445 :      p_typedefs = storageSource.storageOf_typedefs.rebuildDataStoredInEasyStorageClass() ;
   11087       16445 :      SgTypePtrList::iterator i_typedefs = p_typedefs.begin() ; 
   11088       18293 :      for ( ; i_typedefs != p_typedefs.end(); ++i_typedefs ) 
   11089             :         {
   11090        1848 :           (*i_typedefs) = (SgTypePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_typedefs) ) );
   11091             :         }
   11092             : 
   11093             : 
   11094             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   11095             : 
   11096             : 
   11097       16445 :    }
   11098             : 
   11099             : //############################################################################
   11100             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   11101             :  * within the working AST. 
   11102             :  */
   11103       16445 : SgTypedefSeq * SgTypedefSeq::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   11104       16445 :      SgTypedefSeq* returnPointer = NULL;
   11105       16445 :      if ( globalIndex != 0 )
   11106             :         {
   11107             : 
   11108             : #if FILE_IO_EXTRA_CHECK
   11109       16445 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypedefSeq ) ) <= globalIndex ) ;
   11110       16445 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypedefSeq + 1 ) ) );
   11111             : #endif
   11112       16445 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypedefSeq )  
   11113       16445 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypedefSeq );
   11114       16445 :           unsigned long positionInPool = localIndex % SgTypedefSeq::pool_size;
   11115       16445 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypedefSeq::pool_size;
   11116             : 
   11117             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   11118             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   11119             : 
   11120       16445 :           returnPointer = &( ( (SgTypedefSeq*)(SgTypedefSeq::pools[memoryBlock]) ) [positionInPool]) ;
   11121             : 
   11122       16445 :           ROSE_ASSERT( returnPointer != NULL ) ;
   11123             :         }
   11124       16445 :      return returnPointer ;
   11125             :    }
   11126             : 
   11127             : //############################################################################
   11128             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   11129             :   for the AST with the index astIndex
   11130             : */
   11131           0 : SgTypedefSeq * SgTypedefSeq::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   11132           0 :      SgTypedefSeq* returnPointer = NULL;
   11133           0 :      if ( globalIndex != 0 )
   11134             :         {
   11135             : 
   11136             : #if FILE_IO_EXTRA_CHECK
   11137           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypedefSeq ) ) <= globalIndex ) ;
   11138           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypedefSeq + 1 ) ) );
   11139             : #endif
   11140           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypedefSeq )
   11141           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypedefSeq );
   11142           0 :           unsigned long positionInPool = localIndex % SgTypedefSeq::pool_size ;
   11143           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypedefSeq::pool_size ;
   11144             : 
   11145             : #if FILE_IO_EXTRA_CHECK
   11146             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   11147             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   11148             : #endif
   11149             : 
   11150           0 :           returnPointer = &( ( (SgTypedefSeq*)(SgTypedefSeq::pools[memoryBlock]) ) [positionInPool]) ;
   11151             : 
   11152             : #if FILE_IO_EXTRA_CHECK
   11153           0 :           assert ( returnPointer != NULL ) ;
   11154             : #endif
   11155             :         }
   11156           0 :      return returnPointer ;
   11157             :    }
   11158             : 
   11159             : //############################################################################
   11160             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   11161             :  * pool size! We set for every valid object in the memory pool the freepointer
   11162             :  * to the global index and increase the global index afterwards. For all the 
   11163             :  * invalid objects (means address ranges within the memory pool that were not
   11164             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   11165             :  * distinguish valid from invalid objects! 
   11166             :  */
   11167             : unsigned long
   11168           5 : SgTypedefSeq::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   11169             :    {
   11170           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   11171           5 :      SgTypedefSeq* pointer = NULL;
   11172           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   11173           5 :      std::vector < unsigned char* > :: const_iterator block;
   11174          15 :      for ( block = SgTypedefSeq::pools.begin(); block != SgTypedefSeq::pools.end() ; ++block )
   11175             :         {
   11176          10 :           pointer = (SgTypedefSeq*)(*block);
   11177       20010 :           for (unsigned i = 0; i < SgTypedefSeq::pool_size; ++i )
   11178             :              {
   11179             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   11180             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   11181             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   11182             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   11183             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   11184             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   11185             :             // properly; so this will have to be checked next.
   11186             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   11187             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   11188       20000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   11189             :                   {
   11190       16447 :                     pointer[i].set_freepointer((SgTypedefSeq*)(globalIndex));
   11191       16447 :                     globalIndex++;
   11192             :                   }
   11193             :                else
   11194             :                   {
   11195        3553 :                     pointer[i].set_freepointer(NULL);
   11196             :                   }
   11197             :               }
   11198             :         }
   11199           5 :      return globalIndex;
   11200             :    }
   11201             : 
   11202             : //############################################################################
   11203             : // JH (01/14/2006)
   11204             : void
   11205           5 : SgTypedefSeq::resetValidFreepointers( )
   11206             :    {
   11207           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   11208           5 :      SgTypedefSeq* pointer = NULL;
   11209           5 :      std::vector < unsigned char* > :: const_iterator block;
   11210           5 :      SgTypedefSeq* pointerOfLinkedList = NULL;
   11211          15 :      for ( block = SgTypedefSeq::pools.begin(); block != SgTypedefSeq::pools.end() ; ++block )
   11212             :         {
   11213          10 :           pointer = (SgTypedefSeq*)(*block);
   11214       20010 :           for (unsigned i = 0; i < SgTypedefSeq::pool_size; ++i )
   11215             :              {
   11216             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   11217             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   11218             :             // memory blocks!.
   11219       20000 :                if ( pointer[i].get_freepointer() != NULL )
   11220             :                   {
   11221       16447 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   11222             :                   }
   11223             :                else
   11224             :                   {
   11225        3553 :                     if ( pointerOfLinkedList == NULL )
   11226             :                        {
   11227           3 :                          SgTypedefSeq::next_node = &(pointer[i]);
   11228             :                        }
   11229             :                     else
   11230             :                        {
   11231             :                       // printf ("In SgTypedefSeq::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   11232        3550 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   11233             :                        }
   11234             :                     pointerOfLinkedList = &(pointer[i]);
   11235             :                   }
   11236             :               }
   11237             :         }
   11238             : 
   11239           5 :      if ( pointerOfLinkedList != NULL )
   11240             :         {
   11241             :        // printf ("In SgTypedefSeq::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   11242           3 :           pointerOfLinkedList->set_freepointer(NULL);
   11243             :        // DQ (6/6/2010): Temporary debugging...
   11244             :        //   ROSE_ASSERT(false);
   11245             :         }
   11246             : 
   11247           5 :      return ;
   11248             :    }
   11249             : 
   11250             : //############################################################################
   11251             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   11252             :  * within the memory pool and resets the freepointers, in order to achieve a 
   11253             :  * linked list, that has no jumps and starts at the beginning! This function 
   11254             :  * does not extend the memory pool, since we do not delete any memory blocks,
   11255             :  * but delete the valid objects.  
   11256             :  */
   11257             : void
   11258           0 : SgTypedefSeq::clearMemoryPool( )
   11259             :    {
   11260             :   // printf ("Inside of SgTypedefSeq::clearMemoryPool() \n");
   11261             : 
   11262           0 :      SgTypedefSeq* pointer = NULL, *tempPointer = NULL;
   11263           0 :      std::vector < unsigned char* > :: const_iterator block;
   11264           0 :      if ( SgTypedefSeq::pools.empty() == false )
   11265             :         {
   11266           0 :           block = SgTypedefSeq::pools.begin() ;
   11267           0 :           SgTypedefSeq::next_node = (SgTypedefSeq*) (*block);
   11268             : 
   11269           0 :           while ( block != SgTypedefSeq::pools.end() )
   11270             :              {
   11271           0 :                pointer = (SgTypedefSeq*) (*block);
   11272           0 :                if ( tempPointer != NULL )
   11273             :                   {
   11274           0 :                     tempPointer->set_freepointer(pointer);
   11275             :                   }
   11276           0 :                for (unsigned i = 0; i < SgTypedefSeq::pool_size - 1; ++i)
   11277             :                   {
   11278           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   11279             :                   }
   11280           0 :                 pointer[SgTypedefSeq::pool_size-1].set_freepointer(NULL);
   11281           0 :                 tempPointer = &(pointer[SgTypedefSeq::pool_size-1]);
   11282           0 :                 ++block;
   11283             :              }
   11284             :         }
   11285           0 :    }
   11286             : 
   11287           5 : void SgTypedefSeq::deleteMemoryPool() {
   11288          24 :   for (auto p: SgTypedefSeq::pools) {
   11289          19 :     ROSE_FREE(p);
   11290             :   }
   11291           5 :   SgTypedefSeq::next_node = nullptr;
   11292           5 :   SgTypedefSeq::pools.clear();
   11293           5 : }
   11294             : 
   11295             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   11296             : //                 reading multiple binary files to for a single AST.
   11297             : /////////// new version ////////////////////////////////
   11298             : //############################################################################
   11299             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   11300             : void
   11301           2 : SgTypedefSeq::extendMemoryPoolForFileIO( )
   11302             :   {
   11303           2 :     size_t blockIndex = SgTypedefSeq::pools.size();
   11304           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefSeq) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefSeq);
   11305             : 
   11306          11 :     while ( (blockIndex * SgTypedefSeq::pool_size) < newPoolSize)
   11307             :       {
   11308             : #if ROSE_ALLOC_TRACE
   11309             :         if (blockIndex > 0) {
   11310             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefSeq) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefSeq) = %" PRIuPTR " SgTypedefSeq::pool_size = %d \n",
   11311             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefSeq),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefSeq),SgTypedefSeq::pool_size);
   11312             :         }
   11313             : #endif
   11314             : 
   11315           9 :         SgTypedefSeq * pointer = (SgTypedefSeq*) ROSE_MALLOC ( SgTypedefSeq::pool_size * sizeof(SgTypedefSeq) );
   11316           9 :         assert( pointer != NULL );
   11317             : #if ROSE_ALLOC_MEMSET == 1
   11318             :         memset(pointer, 0x00, SgTypedefSeq::pool_size * sizeof(SgTypedefSeq));
   11319             : #elif ROSE_ALLOC_MEMSET == 2
   11320             :         memset(pointer, 0xCC, SgTypedefSeq::pool_size * sizeof(SgTypedefSeq));
   11321             : #endif
   11322           9 :         SgTypedefSeq::pools.push_back( (unsigned char*)(pointer) );
   11323           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypedefSeq::pool_size * sizeof(SgTypedefSeq), V_SgTypedefSeq ) );
   11324             : 
   11325           9 :         if ( SgTypedefSeq::next_node != NULL ) {
   11326           7 :           if ( blockIndex > 0 ) {
   11327           7 :             SgTypedefSeq * blkptr = (SgTypedefSeq*)(SgTypedefSeq::pools[blockIndex-1]);
   11328           7 :             blkptr[ SgTypedefSeq::pool_size - 1 ].set_freepointer(pointer);
   11329             :           }
   11330             :         } else {
   11331           2 :           SgTypedefSeq::next_node = pointer;
   11332             :         }
   11333             : 
   11334       18000 :         for (unsigned i = 0; i < SgTypedefSeq::pool_size-1; ++i)
   11335             :            {
   11336       17991 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   11337             :            }
   11338           9 :         pointer[ SgTypedefSeq::pool_size -1 ].set_freepointer(NULL);
   11339             : 
   11340           9 :         blockIndex++;
   11341             :       }
   11342           2 :   }
   11343             : 
   11344             : //############################################################################
   11345             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   11346             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   11347             :  * not compressed. However, that stuff is not yet implemented! 
   11348             :  */
   11349             : unsigned long
   11350           0 : SgTypedefSeq::getNumberOfLastValidPointer()
   11351             :    {
   11352           0 :       SgTypedefSeq* testPointer = (SgTypedefSeq*)(SgTypedefSeq::pools.back());
   11353           0 :       unsigned long localIndex = SgTypedefSeq::pool_size - 1;
   11354           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   11355             :          {
   11356           0 :            localIndex--;
   11357             :          }
   11358           0 :       return (localIndex + SgTypedefSeq::pool_size * (SgTypedefSeq::pools.size()-1));
   11359             :    }
   11360             : 
   11361             : //############################################################################
   11362             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   11363             :  * memory pool and initializes the data member in class SgTypedefSeqStroageClass
   11364             :  * from its counterpart of SgTypedefSeq. The return value is just for checking, 
   11365             :  * that the whole StorageClassArray is initialized!
   11366             :  */
   11367             : unsigned long
   11368           3 : SgTypedefSeq::initializeStorageClassArray( SgTypedefSeqStorageClass *storageArray )
   11369             :    {
   11370           3 :      unsigned long storageCounter = 0;
   11371           3 :      std::vector < unsigned char* > :: const_iterator block = SgTypedefSeq::pools.begin();
   11372           3 :      SgTypedefSeq* pointer = NULL;
   11373          13 :      while ( block != SgTypedefSeq::pools.end() ) {
   11374          10 :           pointer = (SgTypedefSeq*) (*block);
   11375       20010 :           for ( unsigned i = 0; i < SgTypedefSeq::pool_size; ++i ) {
   11376       20000 :                if ( pointer->get_freepointer() != NULL ) {
   11377       16447 :                  storageArray->pickOutIRNodeData (pointer) ;
   11378       16447 :                  storageArray++;
   11379       16447 :                  storageCounter++;
   11380             :                }
   11381       20000 :                pointer++;
   11382             :              }
   11383          10 :            block++;
   11384             :         }
   11385           3 :      return storageCounter;
   11386             :    }
   11387             : 
   11388             : /* #line 11389 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   11389             : 
   11390             : 
   11391             : 
   11392             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   11393             : 
   11394             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   11395             : 
   11396             : //############################################################################
   11397             : /* JH (02/02/2006) Constructor of the IR node SgTemplateParameter that takes its 
   11398             :  * corresponding StorageClass as parameter
   11399             :  */
   11400        2167 : SgTemplateParameter :: SgTemplateParameter ( const SgTemplateParameterStorageClass& storageSource )   : SgSupport (storageSource)
   11401             :    {
   11402             : 
   11403             : 
   11404             : /* #line 11405 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   11405             : 
   11406        2167 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   11407        2167 :      p_parameterType = storageSource.storageOf_parameterType ;
   11408        2167 :      p_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
   11409        2167 :      p_defaultTypeParameter =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_defaultTypeParameter) );
   11410        2167 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
   11411        2167 :      p_defaultExpressionParameter =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_defaultExpressionParameter) );
   11412        2167 :      p_templateDeclaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_templateDeclaration) );
   11413        2167 :      p_defaultTemplateDeclarationParameter =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_defaultTemplateDeclarationParameter) );
   11414        2167 :      p_initializedName =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initializedName) );
   11415             : 
   11416             : 
   11417             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   11418             : 
   11419             : 
   11420        2167 :    }
   11421             : 
   11422             : //############################################################################
   11423             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   11424             :  * within the working AST. 
   11425             :  */
   11426        3892 : SgTemplateParameter * SgTemplateParameter::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   11427        3892 :      SgTemplateParameter* returnPointer = NULL;
   11428        3892 :      if ( globalIndex != 0 )
   11429             :         {
   11430             : 
   11431             : #if FILE_IO_EXTRA_CHECK
   11432        3892 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateParameter ) ) <= globalIndex ) ;
   11433        3892 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateParameter + 1 ) ) );
   11434             : #endif
   11435        3892 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateParameter )  
   11436        3892 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateParameter );
   11437        3892 :           unsigned long positionInPool = localIndex % SgTemplateParameter::pool_size;
   11438        3892 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateParameter::pool_size;
   11439             : 
   11440             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   11441             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   11442             : 
   11443        3892 :           returnPointer = &( ( (SgTemplateParameter*)(SgTemplateParameter::pools[memoryBlock]) ) [positionInPool]) ;
   11444             : 
   11445        3892 :           ROSE_ASSERT( returnPointer != NULL ) ;
   11446             :         }
   11447        3892 :      return returnPointer ;
   11448             :    }
   11449             : 
   11450             : //############################################################################
   11451             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   11452             :   for the AST with the index astIndex
   11453             : */
   11454           0 : SgTemplateParameter * SgTemplateParameter::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   11455           0 :      SgTemplateParameter* returnPointer = NULL;
   11456           0 :      if ( globalIndex != 0 )
   11457             :         {
   11458             : 
   11459             : #if FILE_IO_EXTRA_CHECK
   11460           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateParameter ) ) <= globalIndex ) ;
   11461           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateParameter + 1 ) ) );
   11462             : #endif
   11463           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateParameter )
   11464           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateParameter );
   11465           0 :           unsigned long positionInPool = localIndex % SgTemplateParameter::pool_size ;
   11466           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateParameter::pool_size ;
   11467             : 
   11468             : #if FILE_IO_EXTRA_CHECK
   11469             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   11470             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   11471             : #endif
   11472             : 
   11473           0 :           returnPointer = &( ( (SgTemplateParameter*)(SgTemplateParameter::pools[memoryBlock]) ) [positionInPool]) ;
   11474             : 
   11475             : #if FILE_IO_EXTRA_CHECK
   11476           0 :           assert ( returnPointer != NULL ) ;
   11477             : #endif
   11478             :         }
   11479           0 :      return returnPointer ;
   11480             :    }
   11481             : 
   11482             : //############################################################################
   11483             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   11484             :  * pool size! We set for every valid object in the memory pool the freepointer
   11485             :  * to the global index and increase the global index afterwards. For all the 
   11486             :  * invalid objects (means address ranges within the memory pool that were not
   11487             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   11488             :  * distinguish valid from invalid objects! 
   11489             :  */
   11490             : unsigned long
   11491           5 : SgTemplateParameter::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   11492             :    {
   11493           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   11494           5 :      SgTemplateParameter* pointer = NULL;
   11495           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   11496           5 :      std::vector < unsigned char* > :: const_iterator block;
   11497           7 :      for ( block = SgTemplateParameter::pools.begin(); block != SgTemplateParameter::pools.end() ; ++block )
   11498             :         {
   11499           2 :           pointer = (SgTemplateParameter*)(*block);
   11500        4002 :           for (unsigned i = 0; i < SgTemplateParameter::pool_size; ++i )
   11501             :              {
   11502             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   11503             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   11504             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   11505             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   11506             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   11507             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   11508             :             // properly; so this will have to be checked next.
   11509             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   11510             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   11511        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   11512             :                   {
   11513        2167 :                     pointer[i].set_freepointer((SgTemplateParameter*)(globalIndex));
   11514        2167 :                     globalIndex++;
   11515             :                   }
   11516             :                else
   11517             :                   {
   11518        1833 :                     pointer[i].set_freepointer(NULL);
   11519             :                   }
   11520             :               }
   11521             :         }
   11522           5 :      return globalIndex;
   11523             :    }
   11524             : 
   11525             : //############################################################################
   11526             : // JH (01/14/2006)
   11527             : void
   11528           5 : SgTemplateParameter::resetValidFreepointers( )
   11529             :    {
   11530           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   11531           5 :      SgTemplateParameter* pointer = NULL;
   11532           5 :      std::vector < unsigned char* > :: const_iterator block;
   11533           5 :      SgTemplateParameter* pointerOfLinkedList = NULL;
   11534           7 :      for ( block = SgTemplateParameter::pools.begin(); block != SgTemplateParameter::pools.end() ; ++block )
   11535             :         {
   11536           2 :           pointer = (SgTemplateParameter*)(*block);
   11537        4002 :           for (unsigned i = 0; i < SgTemplateParameter::pool_size; ++i )
   11538             :              {
   11539             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   11540             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   11541             :             // memory blocks!.
   11542        4000 :                if ( pointer[i].get_freepointer() != NULL )
   11543             :                   {
   11544        2167 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   11545             :                   }
   11546             :                else
   11547             :                   {
   11548        1833 :                     if ( pointerOfLinkedList == NULL )
   11549             :                        {
   11550           1 :                          SgTemplateParameter::next_node = &(pointer[i]);
   11551             :                        }
   11552             :                     else
   11553             :                        {
   11554             :                       // printf ("In SgTemplateParameter::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   11555        1832 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   11556             :                        }
   11557             :                     pointerOfLinkedList = &(pointer[i]);
   11558             :                   }
   11559             :               }
   11560             :         }
   11561             : 
   11562           5 :      if ( pointerOfLinkedList != NULL )
   11563             :         {
   11564             :        // printf ("In SgTemplateParameter::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   11565           1 :           pointerOfLinkedList->set_freepointer(NULL);
   11566             :        // DQ (6/6/2010): Temporary debugging...
   11567             :        //   ROSE_ASSERT(false);
   11568             :         }
   11569             : 
   11570           5 :      return ;
   11571             :    }
   11572             : 
   11573             : //############################################################################
   11574             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   11575             :  * within the memory pool and resets the freepointers, in order to achieve a 
   11576             :  * linked list, that has no jumps and starts at the beginning! This function 
   11577             :  * does not extend the memory pool, since we do not delete any memory blocks,
   11578             :  * but delete the valid objects.  
   11579             :  */
   11580             : void
   11581           0 : SgTemplateParameter::clearMemoryPool( )
   11582             :    {
   11583             :   // printf ("Inside of SgTemplateParameter::clearMemoryPool() \n");
   11584             : 
   11585           0 :      SgTemplateParameter* pointer = NULL, *tempPointer = NULL;
   11586           0 :      std::vector < unsigned char* > :: const_iterator block;
   11587           0 :      if ( SgTemplateParameter::pools.empty() == false )
   11588             :         {
   11589           0 :           block = SgTemplateParameter::pools.begin() ;
   11590           0 :           SgTemplateParameter::next_node = (SgTemplateParameter*) (*block);
   11591             : 
   11592           0 :           while ( block != SgTemplateParameter::pools.end() )
   11593             :              {
   11594           0 :                pointer = (SgTemplateParameter*) (*block);
   11595           0 :                if ( tempPointer != NULL )
   11596             :                   {
   11597           0 :                     tempPointer->set_freepointer(pointer);
   11598             :                   }
   11599           0 :                for (unsigned i = 0; i < SgTemplateParameter::pool_size - 1; ++i)
   11600             :                   {
   11601           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   11602             :                   }
   11603           0 :                 pointer[SgTemplateParameter::pool_size-1].set_freepointer(NULL);
   11604           0 :                 tempPointer = &(pointer[SgTemplateParameter::pool_size-1]);
   11605           0 :                 ++block;
   11606             :              }
   11607             :         }
   11608           0 :    }
   11609             : 
   11610           5 : void SgTemplateParameter::deleteMemoryPool() {
   11611           9 :   for (auto p: SgTemplateParameter::pools) {
   11612           4 :     ROSE_FREE(p);
   11613             :   }
   11614           5 :   SgTemplateParameter::next_node = nullptr;
   11615           5 :   SgTemplateParameter::pools.clear();
   11616           5 : }
   11617             : 
   11618             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   11619             : //                 reading multiple binary files to for a single AST.
   11620             : /////////// new version ////////////////////////////////
   11621             : //############################################################################
   11622             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   11623             : void
   11624           2 : SgTemplateParameter::extendMemoryPoolForFileIO( )
   11625             :   {
   11626           2 :     size_t blockIndex = SgTemplateParameter::pools.size();
   11627           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameter) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameter);
   11628             : 
   11629           4 :     while ( (blockIndex * SgTemplateParameter::pool_size) < newPoolSize)
   11630             :       {
   11631             : #if ROSE_ALLOC_TRACE
   11632             :         if (blockIndex > 0) {
   11633             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameter) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameter) = %" PRIuPTR " SgTemplateParameter::pool_size = %d \n",
   11634             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameter),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameter),SgTemplateParameter::pool_size);
   11635             :         }
   11636             : #endif
   11637             : 
   11638           2 :         SgTemplateParameter * pointer = (SgTemplateParameter*) ROSE_MALLOC ( SgTemplateParameter::pool_size * sizeof(SgTemplateParameter) );
   11639           2 :         assert( pointer != NULL );
   11640             : #if ROSE_ALLOC_MEMSET == 1
   11641             :         memset(pointer, 0x00, SgTemplateParameter::pool_size * sizeof(SgTemplateParameter));
   11642             : #elif ROSE_ALLOC_MEMSET == 2
   11643             :         memset(pointer, 0xCC, SgTemplateParameter::pool_size * sizeof(SgTemplateParameter));
   11644             : #endif
   11645           2 :         SgTemplateParameter::pools.push_back( (unsigned char*)(pointer) );
   11646           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateParameter::pool_size * sizeof(SgTemplateParameter), V_SgTemplateParameter ) );
   11647             : 
   11648           2 :         if ( SgTemplateParameter::next_node != NULL ) {
   11649           1 :           if ( blockIndex > 0 ) {
   11650           1 :             SgTemplateParameter * blkptr = (SgTemplateParameter*)(SgTemplateParameter::pools[blockIndex-1]);
   11651           1 :             blkptr[ SgTemplateParameter::pool_size - 1 ].set_freepointer(pointer);
   11652             :           }
   11653             :         } else {
   11654           1 :           SgTemplateParameter::next_node = pointer;
   11655             :         }
   11656             : 
   11657        4000 :         for (unsigned i = 0; i < SgTemplateParameter::pool_size-1; ++i)
   11658             :            {
   11659        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   11660             :            }
   11661           2 :         pointer[ SgTemplateParameter::pool_size -1 ].set_freepointer(NULL);
   11662             : 
   11663           2 :         blockIndex++;
   11664             :       }
   11665           2 :   }
   11666             : 
   11667             : //############################################################################
   11668             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   11669             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   11670             :  * not compressed. However, that stuff is not yet implemented! 
   11671             :  */
   11672             : unsigned long
   11673           0 : SgTemplateParameter::getNumberOfLastValidPointer()
   11674             :    {
   11675           0 :       SgTemplateParameter* testPointer = (SgTemplateParameter*)(SgTemplateParameter::pools.back());
   11676           0 :       unsigned long localIndex = SgTemplateParameter::pool_size - 1;
   11677           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   11678             :          {
   11679           0 :            localIndex--;
   11680             :          }
   11681           0 :       return (localIndex + SgTemplateParameter::pool_size * (SgTemplateParameter::pools.size()-1));
   11682             :    }
   11683             : 
   11684             : //############################################################################
   11685             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   11686             :  * memory pool and initializes the data member in class SgTemplateParameterStroageClass
   11687             :  * from its counterpart of SgTemplateParameter. The return value is just for checking, 
   11688             :  * that the whole StorageClassArray is initialized!
   11689             :  */
   11690             : unsigned long
   11691           1 : SgTemplateParameter::initializeStorageClassArray( SgTemplateParameterStorageClass *storageArray )
   11692             :    {
   11693           1 :      unsigned long storageCounter = 0;
   11694           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateParameter::pools.begin();
   11695           1 :      SgTemplateParameter* pointer = NULL;
   11696           3 :      while ( block != SgTemplateParameter::pools.end() ) {
   11697           2 :           pointer = (SgTemplateParameter*) (*block);
   11698        4002 :           for ( unsigned i = 0; i < SgTemplateParameter::pool_size; ++i ) {
   11699        4000 :                if ( pointer->get_freepointer() != NULL ) {
   11700        2167 :                  storageArray->pickOutIRNodeData (pointer) ;
   11701        2167 :                  storageArray++;
   11702        2167 :                  storageCounter++;
   11703             :                }
   11704        4000 :                pointer++;
   11705             :              }
   11706           2 :            block++;
   11707             :         }
   11708           1 :      return storageCounter;
   11709             :    }
   11710             : 
   11711             : /* #line 11712 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   11712             : 
   11713             : 
   11714             : 
   11715             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   11716             : 
   11717             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   11718             : 
   11719             : //############################################################################
   11720             : /* JH (02/02/2006) Constructor of the IR node SgTemplateArgument that takes its 
   11721             :  * corresponding StorageClass as parameter
   11722             :  */
   11723        6725 : SgTemplateArgument :: SgTemplateArgument ( const SgTemplateArgumentStorageClass& storageSource )   : SgSupport (storageSource)
   11724             :    {
   11725             : 
   11726             : 
   11727             : /* #line 11728 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   11728             : 
   11729        6725 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   11730        6725 :      p_argumentType = storageSource.storageOf_argumentType ;
   11731        6725 :      p_isArrayBoundUnknownType = storageSource.storageOf_isArrayBoundUnknownType ;
   11732        6725 :      p_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
   11733        6725 :      p_unparsable_type_alias =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_unparsable_type_alias) );
   11734        6725 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
   11735        6725 :      p_templateDeclaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_templateDeclaration) );
   11736        6725 :      p_initializedName =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initializedName) );
   11737        6725 :      p_explicitlySpecified = storageSource.storageOf_explicitlySpecified ;
   11738        6725 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   11739        6725 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   11740        6725 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   11741        6725 :      p_requiresGlobalNameQualificationOnType = storageSource.storageOf_requiresGlobalNameQualificationOnType ;
   11742        6725 :      p_name_qualification_length_for_type = storageSource.storageOf_name_qualification_length_for_type ;
   11743        6725 :      p_type_elaboration_required_for_type = storageSource.storageOf_type_elaboration_required_for_type ;
   11744        6725 :      p_global_qualification_required_for_type = storageSource.storageOf_global_qualification_required_for_type ;
   11745        6725 :      p_previous_instance =  (SgTemplateArgument*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_previous_instance) );
   11746        6725 :      p_next_instance =  (SgTemplateArgument*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_next_instance) );
   11747        6725 :      p_is_pack_element = storageSource.storageOf_is_pack_element ;
   11748             : 
   11749             : 
   11750             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   11751             : 
   11752             : 
   11753        6725 :    }
   11754             : 
   11755             : //############################################################################
   11756             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   11757             :  * within the working AST. 
   11758             :  */
   11759        9002 : SgTemplateArgument * SgTemplateArgument::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   11760        9002 :      SgTemplateArgument* returnPointer = NULL;
   11761        9002 :      if ( globalIndex != 0 )
   11762             :         {
   11763             : 
   11764             : #if FILE_IO_EXTRA_CHECK
   11765        9002 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateArgument ) ) <= globalIndex ) ;
   11766        9002 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateArgument + 1 ) ) );
   11767             : #endif
   11768        9002 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateArgument )  
   11769        9002 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateArgument );
   11770        9002 :           unsigned long positionInPool = localIndex % SgTemplateArgument::pool_size;
   11771        9002 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateArgument::pool_size;
   11772             : 
   11773             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   11774             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   11775             : 
   11776        9002 :           returnPointer = &( ( (SgTemplateArgument*)(SgTemplateArgument::pools[memoryBlock]) ) [positionInPool]) ;
   11777             : 
   11778        9002 :           ROSE_ASSERT( returnPointer != NULL ) ;
   11779             :         }
   11780        9002 :      return returnPointer ;
   11781             :    }
   11782             : 
   11783             : //############################################################################
   11784             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   11785             :   for the AST with the index astIndex
   11786             : */
   11787           0 : SgTemplateArgument * SgTemplateArgument::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   11788           0 :      SgTemplateArgument* returnPointer = NULL;
   11789           0 :      if ( globalIndex != 0 )
   11790             :         {
   11791             : 
   11792             : #if FILE_IO_EXTRA_CHECK
   11793           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateArgument ) ) <= globalIndex ) ;
   11794           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateArgument + 1 ) ) );
   11795             : #endif
   11796           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateArgument )
   11797           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateArgument );
   11798           0 :           unsigned long positionInPool = localIndex % SgTemplateArgument::pool_size ;
   11799           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateArgument::pool_size ;
   11800             : 
   11801             : #if FILE_IO_EXTRA_CHECK
   11802             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   11803             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   11804             : #endif
   11805             : 
   11806           0 :           returnPointer = &( ( (SgTemplateArgument*)(SgTemplateArgument::pools[memoryBlock]) ) [positionInPool]) ;
   11807             : 
   11808             : #if FILE_IO_EXTRA_CHECK
   11809           0 :           assert ( returnPointer != NULL ) ;
   11810             : #endif
   11811             :         }
   11812           0 :      return returnPointer ;
   11813             :    }
   11814             : 
   11815             : //############################################################################
   11816             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   11817             :  * pool size! We set for every valid object in the memory pool the freepointer
   11818             :  * to the global index and increase the global index afterwards. For all the 
   11819             :  * invalid objects (means address ranges within the memory pool that were not
   11820             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   11821             :  * distinguish valid from invalid objects! 
   11822             :  */
   11823             : unsigned long
   11824           5 : SgTemplateArgument::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   11825             :    {
   11826           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   11827           5 :      SgTemplateArgument* pointer = NULL;
   11828           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   11829           5 :      std::vector < unsigned char* > :: const_iterator block;
   11830           9 :      for ( block = SgTemplateArgument::pools.begin(); block != SgTemplateArgument::pools.end() ; ++block )
   11831             :         {
   11832           4 :           pointer = (SgTemplateArgument*)(*block);
   11833        8004 :           for (unsigned i = 0; i < SgTemplateArgument::pool_size; ++i )
   11834             :              {
   11835             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   11836             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   11837             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   11838             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   11839             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   11840             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   11841             :             // properly; so this will have to be checked next.
   11842             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   11843             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   11844        8000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   11845             :                   {
   11846        6725 :                     pointer[i].set_freepointer((SgTemplateArgument*)(globalIndex));
   11847        6725 :                     globalIndex++;
   11848             :                   }
   11849             :                else
   11850             :                   {
   11851        1275 :                     pointer[i].set_freepointer(NULL);
   11852             :                   }
   11853             :               }
   11854             :         }
   11855           5 :      return globalIndex;
   11856             :    }
   11857             : 
   11858             : //############################################################################
   11859             : // JH (01/14/2006)
   11860             : void
   11861           5 : SgTemplateArgument::resetValidFreepointers( )
   11862             :    {
   11863           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   11864           5 :      SgTemplateArgument* pointer = NULL;
   11865           5 :      std::vector < unsigned char* > :: const_iterator block;
   11866           5 :      SgTemplateArgument* pointerOfLinkedList = NULL;
   11867           9 :      for ( block = SgTemplateArgument::pools.begin(); block != SgTemplateArgument::pools.end() ; ++block )
   11868             :         {
   11869           4 :           pointer = (SgTemplateArgument*)(*block);
   11870        8004 :           for (unsigned i = 0; i < SgTemplateArgument::pool_size; ++i )
   11871             :              {
   11872             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   11873             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   11874             :             // memory blocks!.
   11875        8000 :                if ( pointer[i].get_freepointer() != NULL )
   11876             :                   {
   11877        6725 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   11878             :                   }
   11879             :                else
   11880             :                   {
   11881        1275 :                     if ( pointerOfLinkedList == NULL )
   11882             :                        {
   11883           1 :                          SgTemplateArgument::next_node = &(pointer[i]);
   11884             :                        }
   11885             :                     else
   11886             :                        {
   11887             :                       // printf ("In SgTemplateArgument::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   11888        1274 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   11889             :                        }
   11890             :                     pointerOfLinkedList = &(pointer[i]);
   11891             :                   }
   11892             :               }
   11893             :         }
   11894             : 
   11895           5 :      if ( pointerOfLinkedList != NULL )
   11896             :         {
   11897             :        // printf ("In SgTemplateArgument::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   11898           1 :           pointerOfLinkedList->set_freepointer(NULL);
   11899             :        // DQ (6/6/2010): Temporary debugging...
   11900             :        //   ROSE_ASSERT(false);
   11901             :         }
   11902             : 
   11903           5 :      return ;
   11904             :    }
   11905             : 
   11906             : //############################################################################
   11907             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   11908             :  * within the memory pool and resets the freepointers, in order to achieve a 
   11909             :  * linked list, that has no jumps and starts at the beginning! This function 
   11910             :  * does not extend the memory pool, since we do not delete any memory blocks,
   11911             :  * but delete the valid objects.  
   11912             :  */
   11913             : void
   11914           0 : SgTemplateArgument::clearMemoryPool( )
   11915             :    {
   11916             :   // printf ("Inside of SgTemplateArgument::clearMemoryPool() \n");
   11917             : 
   11918           0 :      SgTemplateArgument* pointer = NULL, *tempPointer = NULL;
   11919           0 :      std::vector < unsigned char* > :: const_iterator block;
   11920           0 :      if ( SgTemplateArgument::pools.empty() == false )
   11921             :         {
   11922           0 :           block = SgTemplateArgument::pools.begin() ;
   11923           0 :           SgTemplateArgument::next_node = (SgTemplateArgument*) (*block);
   11924             : 
   11925           0 :           while ( block != SgTemplateArgument::pools.end() )
   11926             :              {
   11927           0 :                pointer = (SgTemplateArgument*) (*block);
   11928           0 :                if ( tempPointer != NULL )
   11929             :                   {
   11930           0 :                     tempPointer->set_freepointer(pointer);
   11931             :                   }
   11932           0 :                for (unsigned i = 0; i < SgTemplateArgument::pool_size - 1; ++i)
   11933             :                   {
   11934           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   11935             :                   }
   11936           0 :                 pointer[SgTemplateArgument::pool_size-1].set_freepointer(NULL);
   11937           0 :                 tempPointer = &(pointer[SgTemplateArgument::pool_size-1]);
   11938           0 :                 ++block;
   11939             :              }
   11940             :         }
   11941           0 :    }
   11942             : 
   11943           5 : void SgTemplateArgument::deleteMemoryPool() {
   11944          13 :   for (auto p: SgTemplateArgument::pools) {
   11945           8 :     ROSE_FREE(p);
   11946             :   }
   11947           5 :   SgTemplateArgument::next_node = nullptr;
   11948           5 :   SgTemplateArgument::pools.clear();
   11949           5 : }
   11950             : 
   11951             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   11952             : //                 reading multiple binary files to for a single AST.
   11953             : /////////// new version ////////////////////////////////
   11954             : //############################################################################
   11955             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   11956             : void
   11957           2 : SgTemplateArgument::extendMemoryPoolForFileIO( )
   11958             :   {
   11959           2 :     size_t blockIndex = SgTemplateArgument::pools.size();
   11960           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateArgument) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateArgument);
   11961             : 
   11962           6 :     while ( (blockIndex * SgTemplateArgument::pool_size) < newPoolSize)
   11963             :       {
   11964             : #if ROSE_ALLOC_TRACE
   11965             :         if (blockIndex > 0) {
   11966             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateArgument) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateArgument) = %" PRIuPTR " SgTemplateArgument::pool_size = %d \n",
   11967             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateArgument),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateArgument),SgTemplateArgument::pool_size);
   11968             :         }
   11969             : #endif
   11970             : 
   11971           4 :         SgTemplateArgument * pointer = (SgTemplateArgument*) ROSE_MALLOC ( SgTemplateArgument::pool_size * sizeof(SgTemplateArgument) );
   11972           4 :         assert( pointer != NULL );
   11973             : #if ROSE_ALLOC_MEMSET == 1
   11974             :         memset(pointer, 0x00, SgTemplateArgument::pool_size * sizeof(SgTemplateArgument));
   11975             : #elif ROSE_ALLOC_MEMSET == 2
   11976             :         memset(pointer, 0xCC, SgTemplateArgument::pool_size * sizeof(SgTemplateArgument));
   11977             : #endif
   11978           4 :         SgTemplateArgument::pools.push_back( (unsigned char*)(pointer) );
   11979           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateArgument::pool_size * sizeof(SgTemplateArgument), V_SgTemplateArgument ) );
   11980             : 
   11981           4 :         if ( SgTemplateArgument::next_node != NULL ) {
   11982           3 :           if ( blockIndex > 0 ) {
   11983           3 :             SgTemplateArgument * blkptr = (SgTemplateArgument*)(SgTemplateArgument::pools[blockIndex-1]);
   11984           3 :             blkptr[ SgTemplateArgument::pool_size - 1 ].set_freepointer(pointer);
   11985             :           }
   11986             :         } else {
   11987           1 :           SgTemplateArgument::next_node = pointer;
   11988             :         }
   11989             : 
   11990        8000 :         for (unsigned i = 0; i < SgTemplateArgument::pool_size-1; ++i)
   11991             :            {
   11992        7996 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   11993             :            }
   11994           4 :         pointer[ SgTemplateArgument::pool_size -1 ].set_freepointer(NULL);
   11995             : 
   11996           4 :         blockIndex++;
   11997             :       }
   11998           2 :   }
   11999             : 
   12000             : //############################################################################
   12001             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   12002             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   12003             :  * not compressed. However, that stuff is not yet implemented! 
   12004             :  */
   12005             : unsigned long
   12006           0 : SgTemplateArgument::getNumberOfLastValidPointer()
   12007             :    {
   12008           0 :       SgTemplateArgument* testPointer = (SgTemplateArgument*)(SgTemplateArgument::pools.back());
   12009           0 :       unsigned long localIndex = SgTemplateArgument::pool_size - 1;
   12010           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   12011             :          {
   12012           0 :            localIndex--;
   12013             :          }
   12014           0 :       return (localIndex + SgTemplateArgument::pool_size * (SgTemplateArgument::pools.size()-1));
   12015             :    }
   12016             : 
   12017             : //############################################################################
   12018             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   12019             :  * memory pool and initializes the data member in class SgTemplateArgumentStroageClass
   12020             :  * from its counterpart of SgTemplateArgument. The return value is just for checking, 
   12021             :  * that the whole StorageClassArray is initialized!
   12022             :  */
   12023             : unsigned long
   12024           1 : SgTemplateArgument::initializeStorageClassArray( SgTemplateArgumentStorageClass *storageArray )
   12025             :    {
   12026           1 :      unsigned long storageCounter = 0;
   12027           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateArgument::pools.begin();
   12028           1 :      SgTemplateArgument* pointer = NULL;
   12029           5 :      while ( block != SgTemplateArgument::pools.end() ) {
   12030           4 :           pointer = (SgTemplateArgument*) (*block);
   12031        8004 :           for ( unsigned i = 0; i < SgTemplateArgument::pool_size; ++i ) {
   12032        8000 :                if ( pointer->get_freepointer() != NULL ) {
   12033        6725 :                  storageArray->pickOutIRNodeData (pointer) ;
   12034        6725 :                  storageArray++;
   12035        6725 :                  storageCounter++;
   12036             :                }
   12037        8000 :                pointer++;
   12038             :              }
   12039           4 :            block++;
   12040             :         }
   12041           1 :      return storageCounter;
   12042             :    }
   12043             : 
   12044             : /* #line 12045 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   12045             : 
   12046             : 
   12047             : 
   12048             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   12049             : 
   12050             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   12051             : 
   12052             : //############################################################################
   12053             : /* JH (02/02/2006) Constructor of the IR node SgDirectory that takes its 
   12054             :  * corresponding StorageClass as parameter
   12055             :  */
   12056           0 : SgDirectory :: SgDirectory ( const SgDirectoryStorageClass& storageSource )   : SgSupport (storageSource)
   12057             :    {
   12058             : 
   12059             : 
   12060             : /* #line 12061 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   12061             : 
   12062           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   12063           0 :      p_name = storageSource.storageOf_name.rebuildDataStoredInEasyStorageClass() ;
   12064           0 :      p_fileList =  (SgFileList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_fileList) );
   12065           0 :      p_directoryList =  (SgDirectoryList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_directoryList) );
   12066           0 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
   12067             : 
   12068             : 
   12069             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   12070             : 
   12071             : 
   12072           0 :    }
   12073             : 
   12074             : //############################################################################
   12075             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   12076             :  * within the working AST. 
   12077             :  */
   12078           0 : SgDirectory * SgDirectory::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   12079           0 :      SgDirectory* returnPointer = NULL;
   12080           0 :      if ( globalIndex != 0 )
   12081             :         {
   12082             : 
   12083             : #if FILE_IO_EXTRA_CHECK
   12084           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDirectory ) ) <= globalIndex ) ;
   12085           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDirectory + 1 ) ) );
   12086             : #endif
   12087           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDirectory )  
   12088           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDirectory );
   12089           0 :           unsigned long positionInPool = localIndex % SgDirectory::pool_size;
   12090           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDirectory::pool_size;
   12091             : 
   12092             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   12093             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   12094             : 
   12095           0 :           returnPointer = &( ( (SgDirectory*)(SgDirectory::pools[memoryBlock]) ) [positionInPool]) ;
   12096             : 
   12097           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   12098             :         }
   12099           0 :      return returnPointer ;
   12100             :    }
   12101             : 
   12102             : //############################################################################
   12103             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   12104             :   for the AST with the index astIndex
   12105             : */
   12106           0 : SgDirectory * SgDirectory::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   12107           0 :      SgDirectory* returnPointer = NULL;
   12108           0 :      if ( globalIndex != 0 )
   12109             :         {
   12110             : 
   12111             : #if FILE_IO_EXTRA_CHECK
   12112           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDirectory ) ) <= globalIndex ) ;
   12113           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDirectory + 1 ) ) );
   12114             : #endif
   12115           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDirectory )
   12116           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDirectory );
   12117           0 :           unsigned long positionInPool = localIndex % SgDirectory::pool_size ;
   12118           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDirectory::pool_size ;
   12119             : 
   12120             : #if FILE_IO_EXTRA_CHECK
   12121             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   12122             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   12123             : #endif
   12124             : 
   12125           0 :           returnPointer = &( ( (SgDirectory*)(SgDirectory::pools[memoryBlock]) ) [positionInPool]) ;
   12126             : 
   12127             : #if FILE_IO_EXTRA_CHECK
   12128           0 :           assert ( returnPointer != NULL ) ;
   12129             : #endif
   12130             :         }
   12131           0 :      return returnPointer ;
   12132             :    }
   12133             : 
   12134             : //############################################################################
   12135             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   12136             :  * pool size! We set for every valid object in the memory pool the freepointer
   12137             :  * to the global index and increase the global index afterwards. For all the 
   12138             :  * invalid objects (means address ranges within the memory pool that were not
   12139             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   12140             :  * distinguish valid from invalid objects! 
   12141             :  */
   12142             : unsigned long
   12143           5 : SgDirectory::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   12144             :    {
   12145           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   12146           5 :      SgDirectory* pointer = NULL;
   12147           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   12148           5 :      std::vector < unsigned char* > :: const_iterator block;
   12149           5 :      for ( block = SgDirectory::pools.begin(); block != SgDirectory::pools.end() ; ++block )
   12150             :         {
   12151           0 :           pointer = (SgDirectory*)(*block);
   12152           0 :           for (unsigned i = 0; i < SgDirectory::pool_size; ++i )
   12153             :              {
   12154             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   12155             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   12156             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   12157             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   12158             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   12159             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   12160             :             // properly; so this will have to be checked next.
   12161             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   12162             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   12163           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   12164             :                   {
   12165           0 :                     pointer[i].set_freepointer((SgDirectory*)(globalIndex));
   12166           0 :                     globalIndex++;
   12167             :                   }
   12168             :                else
   12169             :                   {
   12170           0 :                     pointer[i].set_freepointer(NULL);
   12171             :                   }
   12172             :               }
   12173             :         }
   12174           5 :      return globalIndex;
   12175             :    }
   12176             : 
   12177             : //############################################################################
   12178             : // JH (01/14/2006)
   12179             : void
   12180           5 : SgDirectory::resetValidFreepointers( )
   12181             :    {
   12182           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   12183           5 :      SgDirectory* pointer = NULL;
   12184           5 :      std::vector < unsigned char* > :: const_iterator block;
   12185           5 :      SgDirectory* pointerOfLinkedList = NULL;
   12186           5 :      for ( block = SgDirectory::pools.begin(); block != SgDirectory::pools.end() ; ++block )
   12187             :         {
   12188           0 :           pointer = (SgDirectory*)(*block);
   12189           0 :           for (unsigned i = 0; i < SgDirectory::pool_size; ++i )
   12190             :              {
   12191             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   12192             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   12193             :             // memory blocks!.
   12194           0 :                if ( pointer[i].get_freepointer() != NULL )
   12195             :                   {
   12196           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   12197             :                   }
   12198             :                else
   12199             :                   {
   12200           0 :                     if ( pointerOfLinkedList == NULL )
   12201             :                        {
   12202           0 :                          SgDirectory::next_node = &(pointer[i]);
   12203             :                        }
   12204             :                     else
   12205             :                        {
   12206             :                       // printf ("In SgDirectory::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   12207           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   12208             :                        }
   12209             :                     pointerOfLinkedList = &(pointer[i]);
   12210             :                   }
   12211             :               }
   12212             :         }
   12213             : 
   12214           5 :      if ( pointerOfLinkedList != NULL )
   12215             :         {
   12216             :        // printf ("In SgDirectory::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   12217           0 :           pointerOfLinkedList->set_freepointer(NULL);
   12218             :        // DQ (6/6/2010): Temporary debugging...
   12219             :        //   ROSE_ASSERT(false);
   12220             :         }
   12221             : 
   12222           5 :      return ;
   12223             :    }
   12224             : 
   12225             : //############################################################################
   12226             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   12227             :  * within the memory pool and resets the freepointers, in order to achieve a 
   12228             :  * linked list, that has no jumps and starts at the beginning! This function 
   12229             :  * does not extend the memory pool, since we do not delete any memory blocks,
   12230             :  * but delete the valid objects.  
   12231             :  */
   12232             : void
   12233           0 : SgDirectory::clearMemoryPool( )
   12234             :    {
   12235             :   // printf ("Inside of SgDirectory::clearMemoryPool() \n");
   12236             : 
   12237           0 :      SgDirectory* pointer = NULL, *tempPointer = NULL;
   12238           0 :      std::vector < unsigned char* > :: const_iterator block;
   12239           0 :      if ( SgDirectory::pools.empty() == false )
   12240             :         {
   12241           0 :           block = SgDirectory::pools.begin() ;
   12242           0 :           SgDirectory::next_node = (SgDirectory*) (*block);
   12243             : 
   12244           0 :           while ( block != SgDirectory::pools.end() )
   12245             :              {
   12246           0 :                pointer = (SgDirectory*) (*block);
   12247           0 :                if ( tempPointer != NULL )
   12248             :                   {
   12249           0 :                     tempPointer->set_freepointer(pointer);
   12250             :                   }
   12251           0 :                for (unsigned i = 0; i < SgDirectory::pool_size - 1; ++i)
   12252             :                   {
   12253           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   12254             :                   }
   12255           0 :                 pointer[SgDirectory::pool_size-1].set_freepointer(NULL);
   12256           0 :                 tempPointer = &(pointer[SgDirectory::pool_size-1]);
   12257           0 :                 ++block;
   12258             :              }
   12259             :         }
   12260           0 :    }
   12261             : 
   12262           5 : void SgDirectory::deleteMemoryPool() {
   12263           5 :   for (auto p: SgDirectory::pools) {
   12264           0 :     ROSE_FREE(p);
   12265             :   }
   12266           5 :   SgDirectory::next_node = nullptr;
   12267           5 :   SgDirectory::pools.clear();
   12268           5 : }
   12269             : 
   12270             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   12271             : //                 reading multiple binary files to for a single AST.
   12272             : /////////// new version ////////////////////////////////
   12273             : //############################################################################
   12274             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   12275             : void
   12276           2 : SgDirectory::extendMemoryPoolForFileIO( )
   12277             :   {
   12278           2 :     size_t blockIndex = SgDirectory::pools.size();
   12279           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectory) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectory);
   12280             : 
   12281           2 :     while ( (blockIndex * SgDirectory::pool_size) < newPoolSize)
   12282             :       {
   12283             : #if ROSE_ALLOC_TRACE
   12284             :         if (blockIndex > 0) {
   12285             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectory) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectory) = %" PRIuPTR " SgDirectory::pool_size = %d \n",
   12286             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectory),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectory),SgDirectory::pool_size);
   12287             :         }
   12288             : #endif
   12289             : 
   12290           0 :         SgDirectory * pointer = (SgDirectory*) ROSE_MALLOC ( SgDirectory::pool_size * sizeof(SgDirectory) );
   12291           0 :         assert( pointer != NULL );
   12292             : #if ROSE_ALLOC_MEMSET == 1
   12293             :         memset(pointer, 0x00, SgDirectory::pool_size * sizeof(SgDirectory));
   12294             : #elif ROSE_ALLOC_MEMSET == 2
   12295             :         memset(pointer, 0xCC, SgDirectory::pool_size * sizeof(SgDirectory));
   12296             : #endif
   12297           0 :         SgDirectory::pools.push_back( (unsigned char*)(pointer) );
   12298           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDirectory::pool_size * sizeof(SgDirectory), V_SgDirectory ) );
   12299             : 
   12300           0 :         if ( SgDirectory::next_node != NULL ) {
   12301           0 :           if ( blockIndex > 0 ) {
   12302           0 :             SgDirectory * blkptr = (SgDirectory*)(SgDirectory::pools[blockIndex-1]);
   12303           0 :             blkptr[ SgDirectory::pool_size - 1 ].set_freepointer(pointer);
   12304             :           }
   12305             :         } else {
   12306           0 :           SgDirectory::next_node = pointer;
   12307             :         }
   12308             : 
   12309           0 :         for (unsigned i = 0; i < SgDirectory::pool_size-1; ++i)
   12310             :            {
   12311           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   12312             :            }
   12313           0 :         pointer[ SgDirectory::pool_size -1 ].set_freepointer(NULL);
   12314             : 
   12315           0 :         blockIndex++;
   12316             :       }
   12317           2 :   }
   12318             : 
   12319             : //############################################################################
   12320             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   12321             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   12322             :  * not compressed. However, that stuff is not yet implemented! 
   12323             :  */
   12324             : unsigned long
   12325           0 : SgDirectory::getNumberOfLastValidPointer()
   12326             :    {
   12327           0 :       SgDirectory* testPointer = (SgDirectory*)(SgDirectory::pools.back());
   12328           0 :       unsigned long localIndex = SgDirectory::pool_size - 1;
   12329           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   12330             :          {
   12331           0 :            localIndex--;
   12332             :          }
   12333           0 :       return (localIndex + SgDirectory::pool_size * (SgDirectory::pools.size()-1));
   12334             :    }
   12335             : 
   12336             : //############################################################################
   12337             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   12338             :  * memory pool and initializes the data member in class SgDirectoryStroageClass
   12339             :  * from its counterpart of SgDirectory. The return value is just for checking, 
   12340             :  * that the whole StorageClassArray is initialized!
   12341             :  */
   12342             : unsigned long
   12343           0 : SgDirectory::initializeStorageClassArray( SgDirectoryStorageClass *storageArray )
   12344             :    {
   12345           0 :      unsigned long storageCounter = 0;
   12346           0 :      std::vector < unsigned char* > :: const_iterator block = SgDirectory::pools.begin();
   12347           0 :      SgDirectory* pointer = NULL;
   12348           0 :      while ( block != SgDirectory::pools.end() ) {
   12349           0 :           pointer = (SgDirectory*) (*block);
   12350           0 :           for ( unsigned i = 0; i < SgDirectory::pool_size; ++i ) {
   12351           0 :                if ( pointer->get_freepointer() != NULL ) {
   12352           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   12353           0 :                  storageArray++;
   12354           0 :                  storageCounter++;
   12355             :                }
   12356           0 :                pointer++;
   12357             :              }
   12358           0 :            block++;
   12359             :         }
   12360           0 :      return storageCounter;
   12361             :    }
   12362             : 
   12363             : /* #line 12364 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   12364             : 
   12365             : 
   12366             : 
   12367             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   12368             : 
   12369             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   12370             : 
   12371             : //############################################################################
   12372             : /* JH (02/02/2006) Constructor of the IR node SgFileList that takes its 
   12373             :  * corresponding StorageClass as parameter
   12374             :  */
   12375           2 : SgFileList :: SgFileList ( const SgFileListStorageClass& storageSource )   : SgSupport (storageSource)
   12376             :    {
   12377             : 
   12378             : 
   12379             : /* #line 12380 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   12380             : 
   12381           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   12382           2 :      p_listOfFiles = storageSource.storageOf_listOfFiles.rebuildDataStoredInEasyStorageClass() ;
   12383           2 :      SgFilePtrList::iterator i_listOfFiles = p_listOfFiles.begin() ; 
   12384           4 :      for ( ; i_listOfFiles != p_listOfFiles.end(); ++i_listOfFiles ) 
   12385             :         {
   12386           2 :           (*i_listOfFiles) = (SgFilePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_listOfFiles) ) );
   12387             :         }
   12388           2 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
   12389             : 
   12390             : 
   12391             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   12392             : 
   12393             : 
   12394           2 :    }
   12395             : 
   12396             : //############################################################################
   12397             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   12398             :  * within the working AST. 
   12399             :  */
   12400           4 : SgFileList * SgFileList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   12401           4 :      SgFileList* returnPointer = NULL;
   12402           4 :      if ( globalIndex != 0 )
   12403             :         {
   12404             : 
   12405             : #if FILE_IO_EXTRA_CHECK
   12406           4 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFileList ) ) <= globalIndex ) ;
   12407           4 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFileList + 1 ) ) );
   12408             : #endif
   12409           4 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFileList )  
   12410           4 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFileList );
   12411           4 :           unsigned long positionInPool = localIndex % SgFileList::pool_size;
   12412           4 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFileList::pool_size;
   12413             : 
   12414             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   12415             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   12416             : 
   12417           4 :           returnPointer = &( ( (SgFileList*)(SgFileList::pools[memoryBlock]) ) [positionInPool]) ;
   12418             : 
   12419           4 :           ROSE_ASSERT( returnPointer != NULL ) ;
   12420             :         }
   12421           4 :      return returnPointer ;
   12422             :    }
   12423             : 
   12424             : //############################################################################
   12425             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   12426             :   for the AST with the index astIndex
   12427             : */
   12428           0 : SgFileList * SgFileList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   12429           0 :      SgFileList* returnPointer = NULL;
   12430           0 :      if ( globalIndex != 0 )
   12431             :         {
   12432             : 
   12433             : #if FILE_IO_EXTRA_CHECK
   12434           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFileList ) ) <= globalIndex ) ;
   12435           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFileList + 1 ) ) );
   12436             : #endif
   12437           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFileList )
   12438           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFileList );
   12439           0 :           unsigned long positionInPool = localIndex % SgFileList::pool_size ;
   12440           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFileList::pool_size ;
   12441             : 
   12442             : #if FILE_IO_EXTRA_CHECK
   12443             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   12444             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   12445             : #endif
   12446             : 
   12447           0 :           returnPointer = &( ( (SgFileList*)(SgFileList::pools[memoryBlock]) ) [positionInPool]) ;
   12448             : 
   12449             : #if FILE_IO_EXTRA_CHECK
   12450           0 :           assert ( returnPointer != NULL ) ;
   12451             : #endif
   12452             :         }
   12453           0 :      return returnPointer ;
   12454             :    }
   12455             : 
   12456             : //############################################################################
   12457             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   12458             :  * pool size! We set for every valid object in the memory pool the freepointer
   12459             :  * to the global index and increase the global index afterwards. For all the 
   12460             :  * invalid objects (means address ranges within the memory pool that were not
   12461             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   12462             :  * distinguish valid from invalid objects! 
   12463             :  */
   12464             : unsigned long
   12465           5 : SgFileList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   12466             :    {
   12467           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   12468           5 :      SgFileList* pointer = NULL;
   12469           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   12470           5 :      std::vector < unsigned char* > :: const_iterator block;
   12471          10 :      for ( block = SgFileList::pools.begin(); block != SgFileList::pools.end() ; ++block )
   12472             :         {
   12473           5 :           pointer = (SgFileList*)(*block);
   12474       10005 :           for (unsigned i = 0; i < SgFileList::pool_size; ++i )
   12475             :              {
   12476             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   12477             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   12478             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   12479             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   12480             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   12481             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   12482             :             // properly; so this will have to be checked next.
   12483             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   12484             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   12485       10000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   12486             :                   {
   12487           5 :                     pointer[i].set_freepointer((SgFileList*)(globalIndex));
   12488           5 :                     globalIndex++;
   12489             :                   }
   12490             :                else
   12491             :                   {
   12492        9995 :                     pointer[i].set_freepointer(NULL);
   12493             :                   }
   12494             :               }
   12495             :         }
   12496           5 :      return globalIndex;
   12497             :    }
   12498             : 
   12499             : //############################################################################
   12500             : // JH (01/14/2006)
   12501             : void
   12502           5 : SgFileList::resetValidFreepointers( )
   12503             :    {
   12504           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   12505           5 :      SgFileList* pointer = NULL;
   12506           5 :      std::vector < unsigned char* > :: const_iterator block;
   12507           5 :      SgFileList* pointerOfLinkedList = NULL;
   12508          10 :      for ( block = SgFileList::pools.begin(); block != SgFileList::pools.end() ; ++block )
   12509             :         {
   12510           5 :           pointer = (SgFileList*)(*block);
   12511       10005 :           for (unsigned i = 0; i < SgFileList::pool_size; ++i )
   12512             :              {
   12513             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   12514             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   12515             :             // memory blocks!.
   12516       10000 :                if ( pointer[i].get_freepointer() != NULL )
   12517             :                   {
   12518           5 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   12519             :                   }
   12520             :                else
   12521             :                   {
   12522        9995 :                     if ( pointerOfLinkedList == NULL )
   12523             :                        {
   12524           5 :                          SgFileList::next_node = &(pointer[i]);
   12525             :                        }
   12526             :                     else
   12527             :                        {
   12528             :                       // printf ("In SgFileList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   12529        9990 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   12530             :                        }
   12531             :                     pointerOfLinkedList = &(pointer[i]);
   12532             :                   }
   12533             :               }
   12534             :         }
   12535             : 
   12536           5 :      if ( pointerOfLinkedList != NULL )
   12537             :         {
   12538             :        // printf ("In SgFileList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   12539           5 :           pointerOfLinkedList->set_freepointer(NULL);
   12540             :        // DQ (6/6/2010): Temporary debugging...
   12541             :        //   ROSE_ASSERT(false);
   12542             :         }
   12543             : 
   12544           5 :      return ;
   12545             :    }
   12546             : 
   12547             : //############################################################################
   12548             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   12549             :  * within the memory pool and resets the freepointers, in order to achieve a 
   12550             :  * linked list, that has no jumps and starts at the beginning! This function 
   12551             :  * does not extend the memory pool, since we do not delete any memory blocks,
   12552             :  * but delete the valid objects.  
   12553             :  */
   12554             : void
   12555           0 : SgFileList::clearMemoryPool( )
   12556             :    {
   12557             :   // printf ("Inside of SgFileList::clearMemoryPool() \n");
   12558             : 
   12559           0 :      SgFileList* pointer = NULL, *tempPointer = NULL;
   12560           0 :      std::vector < unsigned char* > :: const_iterator block;
   12561           0 :      if ( SgFileList::pools.empty() == false )
   12562             :         {
   12563           0 :           block = SgFileList::pools.begin() ;
   12564           0 :           SgFileList::next_node = (SgFileList*) (*block);
   12565             : 
   12566           0 :           while ( block != SgFileList::pools.end() )
   12567             :              {
   12568           0 :                pointer = (SgFileList*) (*block);
   12569           0 :                if ( tempPointer != NULL )
   12570             :                   {
   12571           0 :                     tempPointer->set_freepointer(pointer);
   12572             :                   }
   12573           0 :                for (unsigned i = 0; i < SgFileList::pool_size - 1; ++i)
   12574             :                   {
   12575           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   12576             :                   }
   12577           0 :                 pointer[SgFileList::pool_size-1].set_freepointer(NULL);
   12578           0 :                 tempPointer = &(pointer[SgFileList::pool_size-1]);
   12579           0 :                 ++block;
   12580             :              }
   12581             :         }
   12582           0 :    }
   12583             : 
   12584           5 : void SgFileList::deleteMemoryPool() {
   12585          10 :   for (auto p: SgFileList::pools) {
   12586           5 :     ROSE_FREE(p);
   12587             :   }
   12588           5 :   SgFileList::next_node = nullptr;
   12589           5 :   SgFileList::pools.clear();
   12590           5 : }
   12591             : 
   12592             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   12593             : //                 reading multiple binary files to for a single AST.
   12594             : /////////// new version ////////////////////////////////
   12595             : //############################################################################
   12596             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   12597             : void
   12598           2 : SgFileList::extendMemoryPoolForFileIO( )
   12599             :   {
   12600           2 :     size_t blockIndex = SgFileList::pools.size();
   12601           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFileList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFileList);
   12602             : 
   12603           2 :     while ( (blockIndex * SgFileList::pool_size) < newPoolSize)
   12604             :       {
   12605             : #if ROSE_ALLOC_TRACE
   12606             :         if (blockIndex > 0) {
   12607             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFileList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFileList) = %" PRIuPTR " SgFileList::pool_size = %d \n",
   12608             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFileList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFileList),SgFileList::pool_size);
   12609             :         }
   12610             : #endif
   12611             : 
   12612           0 :         SgFileList * pointer = (SgFileList*) ROSE_MALLOC ( SgFileList::pool_size * sizeof(SgFileList) );
   12613           0 :         assert( pointer != NULL );
   12614             : #if ROSE_ALLOC_MEMSET == 1
   12615             :         memset(pointer, 0x00, SgFileList::pool_size * sizeof(SgFileList));
   12616             : #elif ROSE_ALLOC_MEMSET == 2
   12617             :         memset(pointer, 0xCC, SgFileList::pool_size * sizeof(SgFileList));
   12618             : #endif
   12619           0 :         SgFileList::pools.push_back( (unsigned char*)(pointer) );
   12620           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFileList::pool_size * sizeof(SgFileList), V_SgFileList ) );
   12621             : 
   12622           0 :         if ( SgFileList::next_node != NULL ) {
   12623           0 :           if ( blockIndex > 0 ) {
   12624           0 :             SgFileList * blkptr = (SgFileList*)(SgFileList::pools[blockIndex-1]);
   12625           0 :             blkptr[ SgFileList::pool_size - 1 ].set_freepointer(pointer);
   12626             :           }
   12627             :         } else {
   12628           0 :           SgFileList::next_node = pointer;
   12629             :         }
   12630             : 
   12631           0 :         for (unsigned i = 0; i < SgFileList::pool_size-1; ++i)
   12632             :            {
   12633           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   12634             :            }
   12635           0 :         pointer[ SgFileList::pool_size -1 ].set_freepointer(NULL);
   12636             : 
   12637           0 :         blockIndex++;
   12638             :       }
   12639           2 :   }
   12640             : 
   12641             : //############################################################################
   12642             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   12643             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   12644             :  * not compressed. However, that stuff is not yet implemented! 
   12645             :  */
   12646             : unsigned long
   12647           0 : SgFileList::getNumberOfLastValidPointer()
   12648             :    {
   12649           0 :       SgFileList* testPointer = (SgFileList*)(SgFileList::pools.back());
   12650           0 :       unsigned long localIndex = SgFileList::pool_size - 1;
   12651           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   12652             :          {
   12653           0 :            localIndex--;
   12654             :          }
   12655           0 :       return (localIndex + SgFileList::pool_size * (SgFileList::pools.size()-1));
   12656             :    }
   12657             : 
   12658             : //############################################################################
   12659             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   12660             :  * memory pool and initializes the data member in class SgFileListStroageClass
   12661             :  * from its counterpart of SgFileList. The return value is just for checking, 
   12662             :  * that the whole StorageClassArray is initialized!
   12663             :  */
   12664             : unsigned long
   12665           3 : SgFileList::initializeStorageClassArray( SgFileListStorageClass *storageArray )
   12666             :    {
   12667           3 :      unsigned long storageCounter = 0;
   12668           3 :      std::vector < unsigned char* > :: const_iterator block = SgFileList::pools.begin();
   12669           3 :      SgFileList* pointer = NULL;
   12670           6 :      while ( block != SgFileList::pools.end() ) {
   12671           3 :           pointer = (SgFileList*) (*block);
   12672        6003 :           for ( unsigned i = 0; i < SgFileList::pool_size; ++i ) {
   12673        6000 :                if ( pointer->get_freepointer() != NULL ) {
   12674           3 :                  storageArray->pickOutIRNodeData (pointer) ;
   12675           3 :                  storageArray++;
   12676           3 :                  storageCounter++;
   12677             :                }
   12678        6000 :                pointer++;
   12679             :              }
   12680           3 :            block++;
   12681             :         }
   12682           3 :      return storageCounter;
   12683             :    }
   12684             : 
   12685             : /* #line 12686 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   12686             : 
   12687             : 
   12688             : 
   12689             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   12690             : 
   12691             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   12692             : 
   12693             : //############################################################################
   12694             : /* JH (02/02/2006) Constructor of the IR node SgDirectoryList that takes its 
   12695             :  * corresponding StorageClass as parameter
   12696             :  */
   12697           2 : SgDirectoryList :: SgDirectoryList ( const SgDirectoryListStorageClass& storageSource )   : SgSupport (storageSource)
   12698             :    {
   12699             : 
   12700             : 
   12701             : /* #line 12702 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   12702             : 
   12703           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   12704           2 :      p_listOfDirectories = storageSource.storageOf_listOfDirectories.rebuildDataStoredInEasyStorageClass() ;
   12705           2 :      SgDirectoryPtrList::iterator i_listOfDirectories = p_listOfDirectories.begin() ; 
   12706           2 :      for ( ; i_listOfDirectories != p_listOfDirectories.end(); ++i_listOfDirectories ) 
   12707             :         {
   12708           0 :           (*i_listOfDirectories) = (SgDirectoryPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_listOfDirectories) ) );
   12709             :         }
   12710             : 
   12711             : 
   12712             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   12713             : 
   12714             : 
   12715           2 :    }
   12716             : 
   12717             : //############################################################################
   12718             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   12719             :  * within the working AST. 
   12720             :  */
   12721           2 : SgDirectoryList * SgDirectoryList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   12722           2 :      SgDirectoryList* returnPointer = NULL;
   12723           2 :      if ( globalIndex != 0 )
   12724             :         {
   12725             : 
   12726             : #if FILE_IO_EXTRA_CHECK
   12727           2 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDirectoryList ) ) <= globalIndex ) ;
   12728           2 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDirectoryList + 1 ) ) );
   12729             : #endif
   12730           2 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDirectoryList )  
   12731           2 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDirectoryList );
   12732           2 :           unsigned long positionInPool = localIndex % SgDirectoryList::pool_size;
   12733           2 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDirectoryList::pool_size;
   12734             : 
   12735             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   12736             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   12737             : 
   12738           2 :           returnPointer = &( ( (SgDirectoryList*)(SgDirectoryList::pools[memoryBlock]) ) [positionInPool]) ;
   12739             : 
   12740           2 :           ROSE_ASSERT( returnPointer != NULL ) ;
   12741             :         }
   12742           2 :      return returnPointer ;
   12743             :    }
   12744             : 
   12745             : //############################################################################
   12746             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   12747             :   for the AST with the index astIndex
   12748             : */
   12749           0 : SgDirectoryList * SgDirectoryList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   12750           0 :      SgDirectoryList* returnPointer = NULL;
   12751           0 :      if ( globalIndex != 0 )
   12752             :         {
   12753             : 
   12754             : #if FILE_IO_EXTRA_CHECK
   12755           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDirectoryList ) ) <= globalIndex ) ;
   12756           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDirectoryList + 1 ) ) );
   12757             : #endif
   12758           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDirectoryList )
   12759           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDirectoryList );
   12760           0 :           unsigned long positionInPool = localIndex % SgDirectoryList::pool_size ;
   12761           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDirectoryList::pool_size ;
   12762             : 
   12763             : #if FILE_IO_EXTRA_CHECK
   12764             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   12765             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   12766             : #endif
   12767             : 
   12768           0 :           returnPointer = &( ( (SgDirectoryList*)(SgDirectoryList::pools[memoryBlock]) ) [positionInPool]) ;
   12769             : 
   12770             : #if FILE_IO_EXTRA_CHECK
   12771           0 :           assert ( returnPointer != NULL ) ;
   12772             : #endif
   12773             :         }
   12774           0 :      return returnPointer ;
   12775             :    }
   12776             : 
   12777             : //############################################################################
   12778             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   12779             :  * pool size! We set for every valid object in the memory pool the freepointer
   12780             :  * to the global index and increase the global index afterwards. For all the 
   12781             :  * invalid objects (means address ranges within the memory pool that were not
   12782             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   12783             :  * distinguish valid from invalid objects! 
   12784             :  */
   12785             : unsigned long
   12786           5 : SgDirectoryList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   12787             :    {
   12788           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   12789           5 :      SgDirectoryList* pointer = NULL;
   12790           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   12791           5 :      std::vector < unsigned char* > :: const_iterator block;
   12792          10 :      for ( block = SgDirectoryList::pools.begin(); block != SgDirectoryList::pools.end() ; ++block )
   12793             :         {
   12794           5 :           pointer = (SgDirectoryList*)(*block);
   12795       10005 :           for (unsigned i = 0; i < SgDirectoryList::pool_size; ++i )
   12796             :              {
   12797             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   12798             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   12799             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   12800             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   12801             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   12802             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   12803             :             // properly; so this will have to be checked next.
   12804             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   12805             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   12806       10000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   12807             :                   {
   12808           5 :                     pointer[i].set_freepointer((SgDirectoryList*)(globalIndex));
   12809           5 :                     globalIndex++;
   12810             :                   }
   12811             :                else
   12812             :                   {
   12813        9995 :                     pointer[i].set_freepointer(NULL);
   12814             :                   }
   12815             :               }
   12816             :         }
   12817           5 :      return globalIndex;
   12818             :    }
   12819             : 
   12820             : //############################################################################
   12821             : // JH (01/14/2006)
   12822             : void
   12823           5 : SgDirectoryList::resetValidFreepointers( )
   12824             :    {
   12825           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   12826           5 :      SgDirectoryList* pointer = NULL;
   12827           5 :      std::vector < unsigned char* > :: const_iterator block;
   12828           5 :      SgDirectoryList* pointerOfLinkedList = NULL;
   12829          10 :      for ( block = SgDirectoryList::pools.begin(); block != SgDirectoryList::pools.end() ; ++block )
   12830             :         {
   12831           5 :           pointer = (SgDirectoryList*)(*block);
   12832       10005 :           for (unsigned i = 0; i < SgDirectoryList::pool_size; ++i )
   12833             :              {
   12834             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   12835             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   12836             :             // memory blocks!.
   12837       10000 :                if ( pointer[i].get_freepointer() != NULL )
   12838             :                   {
   12839           5 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   12840             :                   }
   12841             :                else
   12842             :                   {
   12843        9995 :                     if ( pointerOfLinkedList == NULL )
   12844             :                        {
   12845           5 :                          SgDirectoryList::next_node = &(pointer[i]);
   12846             :                        }
   12847             :                     else
   12848             :                        {
   12849             :                       // printf ("In SgDirectoryList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   12850        9990 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   12851             :                        }
   12852             :                     pointerOfLinkedList = &(pointer[i]);
   12853             :                   }
   12854             :               }
   12855             :         }
   12856             : 
   12857           5 :      if ( pointerOfLinkedList != NULL )
   12858             :         {
   12859             :        // printf ("In SgDirectoryList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   12860           5 :           pointerOfLinkedList->set_freepointer(NULL);
   12861             :        // DQ (6/6/2010): Temporary debugging...
   12862             :        //   ROSE_ASSERT(false);
   12863             :         }
   12864             : 
   12865           5 :      return ;
   12866             :    }
   12867             : 
   12868             : //############################################################################
   12869             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   12870             :  * within the memory pool and resets the freepointers, in order to achieve a 
   12871             :  * linked list, that has no jumps and starts at the beginning! This function 
   12872             :  * does not extend the memory pool, since we do not delete any memory blocks,
   12873             :  * but delete the valid objects.  
   12874             :  */
   12875             : void
   12876           0 : SgDirectoryList::clearMemoryPool( )
   12877             :    {
   12878             :   // printf ("Inside of SgDirectoryList::clearMemoryPool() \n");
   12879             : 
   12880           0 :      SgDirectoryList* pointer = NULL, *tempPointer = NULL;
   12881           0 :      std::vector < unsigned char* > :: const_iterator block;
   12882           0 :      if ( SgDirectoryList::pools.empty() == false )
   12883             :         {
   12884           0 :           block = SgDirectoryList::pools.begin() ;
   12885           0 :           SgDirectoryList::next_node = (SgDirectoryList*) (*block);
   12886             : 
   12887           0 :           while ( block != SgDirectoryList::pools.end() )
   12888             :              {
   12889           0 :                pointer = (SgDirectoryList*) (*block);
   12890           0 :                if ( tempPointer != NULL )
   12891             :                   {
   12892           0 :                     tempPointer->set_freepointer(pointer);
   12893             :                   }
   12894           0 :                for (unsigned i = 0; i < SgDirectoryList::pool_size - 1; ++i)
   12895             :                   {
   12896           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   12897             :                   }
   12898           0 :                 pointer[SgDirectoryList::pool_size-1].set_freepointer(NULL);
   12899           0 :                 tempPointer = &(pointer[SgDirectoryList::pool_size-1]);
   12900           0 :                 ++block;
   12901             :              }
   12902             :         }
   12903           0 :    }
   12904             : 
   12905           5 : void SgDirectoryList::deleteMemoryPool() {
   12906          10 :   for (auto p: SgDirectoryList::pools) {
   12907           5 :     ROSE_FREE(p);
   12908             :   }
   12909           5 :   SgDirectoryList::next_node = nullptr;
   12910           5 :   SgDirectoryList::pools.clear();
   12911           5 : }
   12912             : 
   12913             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   12914             : //                 reading multiple binary files to for a single AST.
   12915             : /////////// new version ////////////////////////////////
   12916             : //############################################################################
   12917             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   12918             : void
   12919           2 : SgDirectoryList::extendMemoryPoolForFileIO( )
   12920             :   {
   12921           2 :     size_t blockIndex = SgDirectoryList::pools.size();
   12922           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectoryList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectoryList);
   12923             : 
   12924           2 :     while ( (blockIndex * SgDirectoryList::pool_size) < newPoolSize)
   12925             :       {
   12926             : #if ROSE_ALLOC_TRACE
   12927             :         if (blockIndex > 0) {
   12928             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectoryList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectoryList) = %" PRIuPTR " SgDirectoryList::pool_size = %d \n",
   12929             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectoryList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectoryList),SgDirectoryList::pool_size);
   12930             :         }
   12931             : #endif
   12932             : 
   12933           0 :         SgDirectoryList * pointer = (SgDirectoryList*) ROSE_MALLOC ( SgDirectoryList::pool_size * sizeof(SgDirectoryList) );
   12934           0 :         assert( pointer != NULL );
   12935             : #if ROSE_ALLOC_MEMSET == 1
   12936             :         memset(pointer, 0x00, SgDirectoryList::pool_size * sizeof(SgDirectoryList));
   12937             : #elif ROSE_ALLOC_MEMSET == 2
   12938             :         memset(pointer, 0xCC, SgDirectoryList::pool_size * sizeof(SgDirectoryList));
   12939             : #endif
   12940           0 :         SgDirectoryList::pools.push_back( (unsigned char*)(pointer) );
   12941           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDirectoryList::pool_size * sizeof(SgDirectoryList), V_SgDirectoryList ) );
   12942             : 
   12943           0 :         if ( SgDirectoryList::next_node != NULL ) {
   12944           0 :           if ( blockIndex > 0 ) {
   12945           0 :             SgDirectoryList * blkptr = (SgDirectoryList*)(SgDirectoryList::pools[blockIndex-1]);
   12946           0 :             blkptr[ SgDirectoryList::pool_size - 1 ].set_freepointer(pointer);
   12947             :           }
   12948             :         } else {
   12949           0 :           SgDirectoryList::next_node = pointer;
   12950             :         }
   12951             : 
   12952           0 :         for (unsigned i = 0; i < SgDirectoryList::pool_size-1; ++i)
   12953             :            {
   12954           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   12955             :            }
   12956           0 :         pointer[ SgDirectoryList::pool_size -1 ].set_freepointer(NULL);
   12957             : 
   12958           0 :         blockIndex++;
   12959             :       }
   12960           2 :   }
   12961             : 
   12962             : //############################################################################
   12963             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   12964             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   12965             :  * not compressed. However, that stuff is not yet implemented! 
   12966             :  */
   12967             : unsigned long
   12968           0 : SgDirectoryList::getNumberOfLastValidPointer()
   12969             :    {
   12970           0 :       SgDirectoryList* testPointer = (SgDirectoryList*)(SgDirectoryList::pools.back());
   12971           0 :       unsigned long localIndex = SgDirectoryList::pool_size - 1;
   12972           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   12973             :          {
   12974           0 :            localIndex--;
   12975             :          }
   12976           0 :       return (localIndex + SgDirectoryList::pool_size * (SgDirectoryList::pools.size()-1));
   12977             :    }
   12978             : 
   12979             : //############################################################################
   12980             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   12981             :  * memory pool and initializes the data member in class SgDirectoryListStroageClass
   12982             :  * from its counterpart of SgDirectoryList. The return value is just for checking, 
   12983             :  * that the whole StorageClassArray is initialized!
   12984             :  */
   12985             : unsigned long
   12986           3 : SgDirectoryList::initializeStorageClassArray( SgDirectoryListStorageClass *storageArray )
   12987             :    {
   12988           3 :      unsigned long storageCounter = 0;
   12989           3 :      std::vector < unsigned char* > :: const_iterator block = SgDirectoryList::pools.begin();
   12990           3 :      SgDirectoryList* pointer = NULL;
   12991           6 :      while ( block != SgDirectoryList::pools.end() ) {
   12992           3 :           pointer = (SgDirectoryList*) (*block);
   12993        6003 :           for ( unsigned i = 0; i < SgDirectoryList::pool_size; ++i ) {
   12994        6000 :                if ( pointer->get_freepointer() != NULL ) {
   12995           3 :                  storageArray->pickOutIRNodeData (pointer) ;
   12996           3 :                  storageArray++;
   12997           3 :                  storageCounter++;
   12998             :                }
   12999        6000 :                pointer++;
   13000             :              }
   13001           3 :            block++;
   13002             :         }
   13003           3 :      return storageCounter;
   13004             :    }
   13005             : 
   13006             : /* #line 13007 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   13007             : 
   13008             : 
   13009             : 
   13010             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   13011             : 
   13012             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   13013             : 
   13014             : //############################################################################
   13015             : /* JH (02/02/2006) Constructor of the IR node SgFunctionParameterTypeList that takes its 
   13016             :  * corresponding StorageClass as parameter
   13017             :  */
   13018        8410 : SgFunctionParameterTypeList :: SgFunctionParameterTypeList ( const SgFunctionParameterTypeListStorageClass& storageSource )   : SgSupport (storageSource)
   13019             :    {
   13020             : 
   13021             : 
   13022             : /* #line 13023 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   13023             : 
   13024        8410 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   13025        8410 :      p_arguments = storageSource.storageOf_arguments.rebuildDataStoredInEasyStorageClass() ;
   13026        8410 :      SgTypePtrList::iterator i_arguments = p_arguments.begin() ; 
   13027       23187 :      for ( ; i_arguments != p_arguments.end(); ++i_arguments ) 
   13028             :         {
   13029       14777 :           (*i_arguments) = (SgTypePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_arguments) ) );
   13030             :         }
   13031             : 
   13032             : 
   13033             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   13034             : 
   13035             : 
   13036        8410 :    }
   13037             : 
   13038             : //############################################################################
   13039             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   13040             :  * within the working AST. 
   13041             :  */
   13042        5316 : SgFunctionParameterTypeList * SgFunctionParameterTypeList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   13043        5316 :      SgFunctionParameterTypeList* returnPointer = NULL;
   13044        5316 :      if ( globalIndex != 0 )
   13045             :         {
   13046             : 
   13047             : #if FILE_IO_EXTRA_CHECK
   13048        5316 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionParameterTypeList ) ) <= globalIndex ) ;
   13049        5316 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionParameterTypeList + 1 ) ) );
   13050             : #endif
   13051        5316 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionParameterTypeList )  
   13052        5316 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionParameterTypeList );
   13053        5316 :           unsigned long positionInPool = localIndex % SgFunctionParameterTypeList::pool_size;
   13054        5316 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionParameterTypeList::pool_size;
   13055             : 
   13056             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   13057             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   13058             : 
   13059        5316 :           returnPointer = &( ( (SgFunctionParameterTypeList*)(SgFunctionParameterTypeList::pools[memoryBlock]) ) [positionInPool]) ;
   13060             : 
   13061        5316 :           ROSE_ASSERT( returnPointer != NULL ) ;
   13062             :         }
   13063        5316 :      return returnPointer ;
   13064             :    }
   13065             : 
   13066             : //############################################################################
   13067             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   13068             :   for the AST with the index astIndex
   13069             : */
   13070           0 : SgFunctionParameterTypeList * SgFunctionParameterTypeList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   13071           0 :      SgFunctionParameterTypeList* returnPointer = NULL;
   13072           0 :      if ( globalIndex != 0 )
   13073             :         {
   13074             : 
   13075             : #if FILE_IO_EXTRA_CHECK
   13076           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionParameterTypeList ) ) <= globalIndex ) ;
   13077           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionParameterTypeList + 1 ) ) );
   13078             : #endif
   13079           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionParameterTypeList )
   13080           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionParameterTypeList );
   13081           0 :           unsigned long positionInPool = localIndex % SgFunctionParameterTypeList::pool_size ;
   13082           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionParameterTypeList::pool_size ;
   13083             : 
   13084             : #if FILE_IO_EXTRA_CHECK
   13085             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   13086             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   13087             : #endif
   13088             : 
   13089           0 :           returnPointer = &( ( (SgFunctionParameterTypeList*)(SgFunctionParameterTypeList::pools[memoryBlock]) ) [positionInPool]) ;
   13090             : 
   13091             : #if FILE_IO_EXTRA_CHECK
   13092           0 :           assert ( returnPointer != NULL ) ;
   13093             : #endif
   13094             :         }
   13095           0 :      return returnPointer ;
   13096             :    }
   13097             : 
   13098             : //############################################################################
   13099             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   13100             :  * pool size! We set for every valid object in the memory pool the freepointer
   13101             :  * to the global index and increase the global index afterwards. For all the 
   13102             :  * invalid objects (means address ranges within the memory pool that were not
   13103             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   13104             :  * distinguish valid from invalid objects! 
   13105             :  */
   13106             : unsigned long
   13107           5 : SgFunctionParameterTypeList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   13108             :    {
   13109           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   13110           5 :      SgFunctionParameterTypeList* pointer = NULL;
   13111           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   13112           5 :      std::vector < unsigned char* > :: const_iterator block;
   13113          11 :      for ( block = SgFunctionParameterTypeList::pools.begin(); block != SgFunctionParameterTypeList::pools.end() ; ++block )
   13114             :         {
   13115           6 :           pointer = (SgFunctionParameterTypeList*)(*block);
   13116       12006 :           for (unsigned i = 0; i < SgFunctionParameterTypeList::pool_size; ++i )
   13117             :              {
   13118             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   13119             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   13120             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   13121             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   13122             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   13123             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   13124             :             // properly; so this will have to be checked next.
   13125             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   13126             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   13127       12000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   13128             :                   {
   13129        8411 :                     pointer[i].set_freepointer((SgFunctionParameterTypeList*)(globalIndex));
   13130        8411 :                     globalIndex++;
   13131             :                   }
   13132             :                else
   13133             :                   {
   13134        3589 :                     pointer[i].set_freepointer(NULL);
   13135             :                   }
   13136             :               }
   13137             :         }
   13138           5 :      return globalIndex;
   13139             :    }
   13140             : 
   13141             : //############################################################################
   13142             : // JH (01/14/2006)
   13143             : void
   13144           5 : SgFunctionParameterTypeList::resetValidFreepointers( )
   13145             :    {
   13146           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   13147           5 :      SgFunctionParameterTypeList* pointer = NULL;
   13148           5 :      std::vector < unsigned char* > :: const_iterator block;
   13149           5 :      SgFunctionParameterTypeList* pointerOfLinkedList = NULL;
   13150          11 :      for ( block = SgFunctionParameterTypeList::pools.begin(); block != SgFunctionParameterTypeList::pools.end() ; ++block )
   13151             :         {
   13152           6 :           pointer = (SgFunctionParameterTypeList*)(*block);
   13153       12006 :           for (unsigned i = 0; i < SgFunctionParameterTypeList::pool_size; ++i )
   13154             :              {
   13155             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   13156             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   13157             :             // memory blocks!.
   13158       12000 :                if ( pointer[i].get_freepointer() != NULL )
   13159             :                   {
   13160        8411 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   13161             :                   }
   13162             :                else
   13163             :                   {
   13164        3589 :                     if ( pointerOfLinkedList == NULL )
   13165             :                        {
   13166           3 :                          SgFunctionParameterTypeList::next_node = &(pointer[i]);
   13167             :                        }
   13168             :                     else
   13169             :                        {
   13170             :                       // printf ("In SgFunctionParameterTypeList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   13171        3586 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   13172             :                        }
   13173             :                     pointerOfLinkedList = &(pointer[i]);
   13174             :                   }
   13175             :               }
   13176             :         }
   13177             : 
   13178           5 :      if ( pointerOfLinkedList != NULL )
   13179             :         {
   13180             :        // printf ("In SgFunctionParameterTypeList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   13181           3 :           pointerOfLinkedList->set_freepointer(NULL);
   13182             :        // DQ (6/6/2010): Temporary debugging...
   13183             :        //   ROSE_ASSERT(false);
   13184             :         }
   13185             : 
   13186           5 :      return ;
   13187             :    }
   13188             : 
   13189             : //############################################################################
   13190             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   13191             :  * within the memory pool and resets the freepointers, in order to achieve a 
   13192             :  * linked list, that has no jumps and starts at the beginning! This function 
   13193             :  * does not extend the memory pool, since we do not delete any memory blocks,
   13194             :  * but delete the valid objects.  
   13195             :  */
   13196             : void
   13197           0 : SgFunctionParameterTypeList::clearMemoryPool( )
   13198             :    {
   13199             :   // printf ("Inside of SgFunctionParameterTypeList::clearMemoryPool() \n");
   13200             : 
   13201           0 :      SgFunctionParameterTypeList* pointer = NULL, *tempPointer = NULL;
   13202           0 :      std::vector < unsigned char* > :: const_iterator block;
   13203           0 :      if ( SgFunctionParameterTypeList::pools.empty() == false )
   13204             :         {
   13205           0 :           block = SgFunctionParameterTypeList::pools.begin() ;
   13206           0 :           SgFunctionParameterTypeList::next_node = (SgFunctionParameterTypeList*) (*block);
   13207             : 
   13208           0 :           while ( block != SgFunctionParameterTypeList::pools.end() )
   13209             :              {
   13210           0 :                pointer = (SgFunctionParameterTypeList*) (*block);
   13211           0 :                if ( tempPointer != NULL )
   13212             :                   {
   13213           0 :                     tempPointer->set_freepointer(pointer);
   13214             :                   }
   13215           0 :                for (unsigned i = 0; i < SgFunctionParameterTypeList::pool_size - 1; ++i)
   13216             :                   {
   13217           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   13218             :                   }
   13219           0 :                 pointer[SgFunctionParameterTypeList::pool_size-1].set_freepointer(NULL);
   13220           0 :                 tempPointer = &(pointer[SgFunctionParameterTypeList::pool_size-1]);
   13221           0 :                 ++block;
   13222             :              }
   13223             :         }
   13224           0 :    }
   13225             : 
   13226           5 : void SgFunctionParameterTypeList::deleteMemoryPool() {
   13227          16 :   for (auto p: SgFunctionParameterTypeList::pools) {
   13228          11 :     ROSE_FREE(p);
   13229             :   }
   13230           5 :   SgFunctionParameterTypeList::next_node = nullptr;
   13231           5 :   SgFunctionParameterTypeList::pools.clear();
   13232           5 : }
   13233             : 
   13234             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   13235             : //                 reading multiple binary files to for a single AST.
   13236             : /////////// new version ////////////////////////////////
   13237             : //############################################################################
   13238             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   13239             : void
   13240           2 : SgFunctionParameterTypeList::extendMemoryPoolForFileIO( )
   13241             :   {
   13242           2 :     size_t blockIndex = SgFunctionParameterTypeList::pools.size();
   13243           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterTypeList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterTypeList);
   13244             : 
   13245           7 :     while ( (blockIndex * SgFunctionParameterTypeList::pool_size) < newPoolSize)
   13246             :       {
   13247             : #if ROSE_ALLOC_TRACE
   13248             :         if (blockIndex > 0) {
   13249             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterTypeList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterTypeList) = %" PRIuPTR " SgFunctionParameterTypeList::pool_size = %d \n",
   13250             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterTypeList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterTypeList),SgFunctionParameterTypeList::pool_size);
   13251             :         }
   13252             : #endif
   13253             : 
   13254           5 :         SgFunctionParameterTypeList * pointer = (SgFunctionParameterTypeList*) ROSE_MALLOC ( SgFunctionParameterTypeList::pool_size * sizeof(SgFunctionParameterTypeList) );
   13255           5 :         assert( pointer != NULL );
   13256             : #if ROSE_ALLOC_MEMSET == 1
   13257             :         memset(pointer, 0x00, SgFunctionParameterTypeList::pool_size * sizeof(SgFunctionParameterTypeList));
   13258             : #elif ROSE_ALLOC_MEMSET == 2
   13259             :         memset(pointer, 0xCC, SgFunctionParameterTypeList::pool_size * sizeof(SgFunctionParameterTypeList));
   13260             : #endif
   13261           5 :         SgFunctionParameterTypeList::pools.push_back( (unsigned char*)(pointer) );
   13262           5 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionParameterTypeList::pool_size * sizeof(SgFunctionParameterTypeList), V_SgFunctionParameterTypeList ) );
   13263             : 
   13264           5 :         if ( SgFunctionParameterTypeList::next_node != NULL ) {
   13265           3 :           if ( blockIndex > 0 ) {
   13266           3 :             SgFunctionParameterTypeList * blkptr = (SgFunctionParameterTypeList*)(SgFunctionParameterTypeList::pools[blockIndex-1]);
   13267           3 :             blkptr[ SgFunctionParameterTypeList::pool_size - 1 ].set_freepointer(pointer);
   13268             :           }
   13269             :         } else {
   13270           2 :           SgFunctionParameterTypeList::next_node = pointer;
   13271             :         }
   13272             : 
   13273       10000 :         for (unsigned i = 0; i < SgFunctionParameterTypeList::pool_size-1; ++i)
   13274             :            {
   13275        9995 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   13276             :            }
   13277           5 :         pointer[ SgFunctionParameterTypeList::pool_size -1 ].set_freepointer(NULL);
   13278             : 
   13279           5 :         blockIndex++;
   13280             :       }
   13281           2 :   }
   13282             : 
   13283             : //############################################################################
   13284             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   13285             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   13286             :  * not compressed. However, that stuff is not yet implemented! 
   13287             :  */
   13288             : unsigned long
   13289           0 : SgFunctionParameterTypeList::getNumberOfLastValidPointer()
   13290             :    {
   13291           0 :       SgFunctionParameterTypeList* testPointer = (SgFunctionParameterTypeList*)(SgFunctionParameterTypeList::pools.back());
   13292           0 :       unsigned long localIndex = SgFunctionParameterTypeList::pool_size - 1;
   13293           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   13294             :          {
   13295           0 :            localIndex--;
   13296             :          }
   13297           0 :       return (localIndex + SgFunctionParameterTypeList::pool_size * (SgFunctionParameterTypeList::pools.size()-1));
   13298             :    }
   13299             : 
   13300             : //############################################################################
   13301             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   13302             :  * memory pool and initializes the data member in class SgFunctionParameterTypeListStroageClass
   13303             :  * from its counterpart of SgFunctionParameterTypeList. The return value is just for checking, 
   13304             :  * that the whole StorageClassArray is initialized!
   13305             :  */
   13306             : unsigned long
   13307           3 : SgFunctionParameterTypeList::initializeStorageClassArray( SgFunctionParameterTypeListStorageClass *storageArray )
   13308             :    {
   13309           3 :      unsigned long storageCounter = 0;
   13310           3 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionParameterTypeList::pools.begin();
   13311           3 :      SgFunctionParameterTypeList* pointer = NULL;
   13312           9 :      while ( block != SgFunctionParameterTypeList::pools.end() ) {
   13313           6 :           pointer = (SgFunctionParameterTypeList*) (*block);
   13314       12006 :           for ( unsigned i = 0; i < SgFunctionParameterTypeList::pool_size; ++i ) {
   13315       12000 :                if ( pointer->get_freepointer() != NULL ) {
   13316        8411 :                  storageArray->pickOutIRNodeData (pointer) ;
   13317        8411 :                  storageArray++;
   13318        8411 :                  storageCounter++;
   13319             :                }
   13320       12000 :                pointer++;
   13321             :              }
   13322           6 :            block++;
   13323             :         }
   13324           3 :      return storageCounter;
   13325             :    }
   13326             : 
   13327             : /* #line 13328 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   13328             : 
   13329             : 
   13330             : 
   13331             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   13332             : 
   13333             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   13334             : 
   13335             : //############################################################################
   13336             : /* JH (02/02/2006) Constructor of the IR node SgQualifiedName that takes its 
   13337             :  * corresponding StorageClass as parameter
   13338             :  */
   13339           0 : SgQualifiedName :: SgQualifiedName ( const SgQualifiedNameStorageClass& storageSource )   : SgSupport (storageSource)
   13340             :    {
   13341             : 
   13342             : 
   13343             : /* #line 13344 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   13344             : 
   13345           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   13346           0 :      p_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scope) );
   13347             : 
   13348             : 
   13349             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   13350             : 
   13351             : 
   13352           0 :    }
   13353             : 
   13354             : //############################################################################
   13355             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   13356             :  * within the working AST. 
   13357             :  */
   13358           0 : SgQualifiedName * SgQualifiedName::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   13359           0 :      SgQualifiedName* returnPointer = NULL;
   13360           0 :      if ( globalIndex != 0 )
   13361             :         {
   13362             : 
   13363             : #if FILE_IO_EXTRA_CHECK
   13364           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgQualifiedName ) ) <= globalIndex ) ;
   13365           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgQualifiedName + 1 ) ) );
   13366             : #endif
   13367           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgQualifiedName )  
   13368           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgQualifiedName );
   13369           0 :           unsigned long positionInPool = localIndex % SgQualifiedName::pool_size;
   13370           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgQualifiedName::pool_size;
   13371             : 
   13372             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   13373             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   13374             : 
   13375           0 :           returnPointer = &( ( (SgQualifiedName*)(SgQualifiedName::pools[memoryBlock]) ) [positionInPool]) ;
   13376             : 
   13377           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   13378             :         }
   13379           0 :      return returnPointer ;
   13380             :    }
   13381             : 
   13382             : //############################################################################
   13383             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   13384             :   for the AST with the index astIndex
   13385             : */
   13386           0 : SgQualifiedName * SgQualifiedName::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   13387           0 :      SgQualifiedName* returnPointer = NULL;
   13388           0 :      if ( globalIndex != 0 )
   13389             :         {
   13390             : 
   13391             : #if FILE_IO_EXTRA_CHECK
   13392           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgQualifiedName ) ) <= globalIndex ) ;
   13393           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgQualifiedName + 1 ) ) );
   13394             : #endif
   13395           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgQualifiedName )
   13396           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgQualifiedName );
   13397           0 :           unsigned long positionInPool = localIndex % SgQualifiedName::pool_size ;
   13398           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgQualifiedName::pool_size ;
   13399             : 
   13400             : #if FILE_IO_EXTRA_CHECK
   13401             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   13402             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   13403             : #endif
   13404             : 
   13405           0 :           returnPointer = &( ( (SgQualifiedName*)(SgQualifiedName::pools[memoryBlock]) ) [positionInPool]) ;
   13406             : 
   13407             : #if FILE_IO_EXTRA_CHECK
   13408           0 :           assert ( returnPointer != NULL ) ;
   13409             : #endif
   13410             :         }
   13411           0 :      return returnPointer ;
   13412             :    }
   13413             : 
   13414             : //############################################################################
   13415             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   13416             :  * pool size! We set for every valid object in the memory pool the freepointer
   13417             :  * to the global index and increase the global index afterwards. For all the 
   13418             :  * invalid objects (means address ranges within the memory pool that were not
   13419             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   13420             :  * distinguish valid from invalid objects! 
   13421             :  */
   13422             : unsigned long
   13423           5 : SgQualifiedName::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   13424             :    {
   13425           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   13426           5 :      SgQualifiedName* pointer = NULL;
   13427           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   13428           5 :      std::vector < unsigned char* > :: const_iterator block;
   13429           5 :      for ( block = SgQualifiedName::pools.begin(); block != SgQualifiedName::pools.end() ; ++block )
   13430             :         {
   13431           0 :           pointer = (SgQualifiedName*)(*block);
   13432           0 :           for (unsigned i = 0; i < SgQualifiedName::pool_size; ++i )
   13433             :              {
   13434             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   13435             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   13436             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   13437             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   13438             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   13439             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   13440             :             // properly; so this will have to be checked next.
   13441             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   13442             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   13443           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   13444             :                   {
   13445           0 :                     pointer[i].set_freepointer((SgQualifiedName*)(globalIndex));
   13446           0 :                     globalIndex++;
   13447             :                   }
   13448             :                else
   13449             :                   {
   13450           0 :                     pointer[i].set_freepointer(NULL);
   13451             :                   }
   13452             :               }
   13453             :         }
   13454           5 :      return globalIndex;
   13455             :    }
   13456             : 
   13457             : //############################################################################
   13458             : // JH (01/14/2006)
   13459             : void
   13460           5 : SgQualifiedName::resetValidFreepointers( )
   13461             :    {
   13462           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   13463           5 :      SgQualifiedName* pointer = NULL;
   13464           5 :      std::vector < unsigned char* > :: const_iterator block;
   13465           5 :      SgQualifiedName* pointerOfLinkedList = NULL;
   13466           5 :      for ( block = SgQualifiedName::pools.begin(); block != SgQualifiedName::pools.end() ; ++block )
   13467             :         {
   13468           0 :           pointer = (SgQualifiedName*)(*block);
   13469           0 :           for (unsigned i = 0; i < SgQualifiedName::pool_size; ++i )
   13470             :              {
   13471             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   13472             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   13473             :             // memory blocks!.
   13474           0 :                if ( pointer[i].get_freepointer() != NULL )
   13475             :                   {
   13476           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   13477             :                   }
   13478             :                else
   13479             :                   {
   13480           0 :                     if ( pointerOfLinkedList == NULL )
   13481             :                        {
   13482           0 :                          SgQualifiedName::next_node = &(pointer[i]);
   13483             :                        }
   13484             :                     else
   13485             :                        {
   13486             :                       // printf ("In SgQualifiedName::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   13487           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   13488             :                        }
   13489             :                     pointerOfLinkedList = &(pointer[i]);
   13490             :                   }
   13491             :               }
   13492             :         }
   13493             : 
   13494           5 :      if ( pointerOfLinkedList != NULL )
   13495             :         {
   13496             :        // printf ("In SgQualifiedName::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   13497           0 :           pointerOfLinkedList->set_freepointer(NULL);
   13498             :        // DQ (6/6/2010): Temporary debugging...
   13499             :        //   ROSE_ASSERT(false);
   13500             :         }
   13501             : 
   13502           5 :      return ;
   13503             :    }
   13504             : 
   13505             : //############################################################################
   13506             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   13507             :  * within the memory pool and resets the freepointers, in order to achieve a 
   13508             :  * linked list, that has no jumps and starts at the beginning! This function 
   13509             :  * does not extend the memory pool, since we do not delete any memory blocks,
   13510             :  * but delete the valid objects.  
   13511             :  */
   13512             : void
   13513           0 : SgQualifiedName::clearMemoryPool( )
   13514             :    {
   13515             :   // printf ("Inside of SgQualifiedName::clearMemoryPool() \n");
   13516             : 
   13517           0 :      SgQualifiedName* pointer = NULL, *tempPointer = NULL;
   13518           0 :      std::vector < unsigned char* > :: const_iterator block;
   13519           0 :      if ( SgQualifiedName::pools.empty() == false )
   13520             :         {
   13521           0 :           block = SgQualifiedName::pools.begin() ;
   13522           0 :           SgQualifiedName::next_node = (SgQualifiedName*) (*block);
   13523             : 
   13524           0 :           while ( block != SgQualifiedName::pools.end() )
   13525             :              {
   13526           0 :                pointer = (SgQualifiedName*) (*block);
   13527           0 :                if ( tempPointer != NULL )
   13528             :                   {
   13529           0 :                     tempPointer->set_freepointer(pointer);
   13530             :                   }
   13531           0 :                for (unsigned i = 0; i < SgQualifiedName::pool_size - 1; ++i)
   13532             :                   {
   13533           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   13534             :                   }
   13535           0 :                 pointer[SgQualifiedName::pool_size-1].set_freepointer(NULL);
   13536           0 :                 tempPointer = &(pointer[SgQualifiedName::pool_size-1]);
   13537           0 :                 ++block;
   13538             :              }
   13539             :         }
   13540           0 :    }
   13541             : 
   13542           5 : void SgQualifiedName::deleteMemoryPool() {
   13543           5 :   for (auto p: SgQualifiedName::pools) {
   13544           0 :     ROSE_FREE(p);
   13545             :   }
   13546           5 :   SgQualifiedName::next_node = nullptr;
   13547           5 :   SgQualifiedName::pools.clear();
   13548           5 : }
   13549             : 
   13550             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   13551             : //                 reading multiple binary files to for a single AST.
   13552             : /////////// new version ////////////////////////////////
   13553             : //############################################################################
   13554             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   13555             : void
   13556           2 : SgQualifiedName::extendMemoryPoolForFileIO( )
   13557             :   {
   13558           2 :     size_t blockIndex = SgQualifiedName::pools.size();
   13559           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgQualifiedName) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgQualifiedName);
   13560             : 
   13561           2 :     while ( (blockIndex * SgQualifiedName::pool_size) < newPoolSize)
   13562             :       {
   13563             : #if ROSE_ALLOC_TRACE
   13564             :         if (blockIndex > 0) {
   13565             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgQualifiedName) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgQualifiedName) = %" PRIuPTR " SgQualifiedName::pool_size = %d \n",
   13566             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgQualifiedName),AST_FILE_IO::getPoolSizeOfNewAst(V_SgQualifiedName),SgQualifiedName::pool_size);
   13567             :         }
   13568             : #endif
   13569             : 
   13570           0 :         SgQualifiedName * pointer = (SgQualifiedName*) ROSE_MALLOC ( SgQualifiedName::pool_size * sizeof(SgQualifiedName) );
   13571           0 :         assert( pointer != NULL );
   13572             : #if ROSE_ALLOC_MEMSET == 1
   13573             :         memset(pointer, 0x00, SgQualifiedName::pool_size * sizeof(SgQualifiedName));
   13574             : #elif ROSE_ALLOC_MEMSET == 2
   13575             :         memset(pointer, 0xCC, SgQualifiedName::pool_size * sizeof(SgQualifiedName));
   13576             : #endif
   13577           0 :         SgQualifiedName::pools.push_back( (unsigned char*)(pointer) );
   13578           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgQualifiedName::pool_size * sizeof(SgQualifiedName), V_SgQualifiedName ) );
   13579             : 
   13580           0 :         if ( SgQualifiedName::next_node != NULL ) {
   13581           0 :           if ( blockIndex > 0 ) {
   13582           0 :             SgQualifiedName * blkptr = (SgQualifiedName*)(SgQualifiedName::pools[blockIndex-1]);
   13583           0 :             blkptr[ SgQualifiedName::pool_size - 1 ].set_freepointer(pointer);
   13584             :           }
   13585             :         } else {
   13586           0 :           SgQualifiedName::next_node = pointer;
   13587             :         }
   13588             : 
   13589           0 :         for (unsigned i = 0; i < SgQualifiedName::pool_size-1; ++i)
   13590             :            {
   13591           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   13592             :            }
   13593           0 :         pointer[ SgQualifiedName::pool_size -1 ].set_freepointer(NULL);
   13594             : 
   13595           0 :         blockIndex++;
   13596             :       }
   13597           2 :   }
   13598             : 
   13599             : //############################################################################
   13600             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   13601             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   13602             :  * not compressed. However, that stuff is not yet implemented! 
   13603             :  */
   13604             : unsigned long
   13605           0 : SgQualifiedName::getNumberOfLastValidPointer()
   13606             :    {
   13607           0 :       SgQualifiedName* testPointer = (SgQualifiedName*)(SgQualifiedName::pools.back());
   13608           0 :       unsigned long localIndex = SgQualifiedName::pool_size - 1;
   13609           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   13610             :          {
   13611           0 :            localIndex--;
   13612             :          }
   13613           0 :       return (localIndex + SgQualifiedName::pool_size * (SgQualifiedName::pools.size()-1));
   13614             :    }
   13615             : 
   13616             : //############################################################################
   13617             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   13618             :  * memory pool and initializes the data member in class SgQualifiedNameStroageClass
   13619             :  * from its counterpart of SgQualifiedName. The return value is just for checking, 
   13620             :  * that the whole StorageClassArray is initialized!
   13621             :  */
   13622             : unsigned long
   13623           0 : SgQualifiedName::initializeStorageClassArray( SgQualifiedNameStorageClass *storageArray )
   13624             :    {
   13625           0 :      unsigned long storageCounter = 0;
   13626           0 :      std::vector < unsigned char* > :: const_iterator block = SgQualifiedName::pools.begin();
   13627           0 :      SgQualifiedName* pointer = NULL;
   13628           0 :      while ( block != SgQualifiedName::pools.end() ) {
   13629           0 :           pointer = (SgQualifiedName*) (*block);
   13630           0 :           for ( unsigned i = 0; i < SgQualifiedName::pool_size; ++i ) {
   13631           0 :                if ( pointer->get_freepointer() != NULL ) {
   13632           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   13633           0 :                  storageArray++;
   13634           0 :                  storageCounter++;
   13635             :                }
   13636           0 :                pointer++;
   13637             :              }
   13638           0 :            block++;
   13639             :         }
   13640           0 :      return storageCounter;
   13641             :    }
   13642             : 
   13643             : /* #line 13644 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   13644             : 
   13645             : 
   13646             : 
   13647             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   13648             : 
   13649             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   13650             : 
   13651             : //############################################################################
   13652             : /* JH (02/02/2006) Constructor of the IR node SgTemplateArgumentList that takes its 
   13653             :  * corresponding StorageClass as parameter
   13654             :  */
   13655           0 : SgTemplateArgumentList :: SgTemplateArgumentList ( const SgTemplateArgumentListStorageClass& storageSource )   : SgSupport (storageSource)
   13656             :    {
   13657             : 
   13658             : 
   13659             : /* #line 13660 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   13660             : 
   13661           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   13662           0 :      p_args = storageSource.storageOf_args.rebuildDataStoredInEasyStorageClass() ;
   13663           0 :      SgTemplateArgumentPtrList::iterator i_args = p_args.begin() ; 
   13664           0 :      for ( ; i_args != p_args.end(); ++i_args ) 
   13665             :         {
   13666           0 :           (*i_args) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_args) ) );
   13667             :         }
   13668             : 
   13669             : 
   13670             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   13671             : 
   13672             : 
   13673           0 :    }
   13674             : 
   13675             : //############################################################################
   13676             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   13677             :  * within the working AST. 
   13678             :  */
   13679           0 : SgTemplateArgumentList * SgTemplateArgumentList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   13680           0 :      SgTemplateArgumentList* returnPointer = NULL;
   13681           0 :      if ( globalIndex != 0 )
   13682             :         {
   13683             : 
   13684             : #if FILE_IO_EXTRA_CHECK
   13685           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateArgumentList ) ) <= globalIndex ) ;
   13686           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateArgumentList + 1 ) ) );
   13687             : #endif
   13688           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateArgumentList )  
   13689           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateArgumentList );
   13690           0 :           unsigned long positionInPool = localIndex % SgTemplateArgumentList::pool_size;
   13691           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateArgumentList::pool_size;
   13692             : 
   13693             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   13694             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   13695             : 
   13696           0 :           returnPointer = &( ( (SgTemplateArgumentList*)(SgTemplateArgumentList::pools[memoryBlock]) ) [positionInPool]) ;
   13697             : 
   13698           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   13699             :         }
   13700           0 :      return returnPointer ;
   13701             :    }
   13702             : 
   13703             : //############################################################################
   13704             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   13705             :   for the AST with the index astIndex
   13706             : */
   13707           0 : SgTemplateArgumentList * SgTemplateArgumentList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   13708           0 :      SgTemplateArgumentList* returnPointer = NULL;
   13709           0 :      if ( globalIndex != 0 )
   13710             :         {
   13711             : 
   13712             : #if FILE_IO_EXTRA_CHECK
   13713           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateArgumentList ) ) <= globalIndex ) ;
   13714           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateArgumentList + 1 ) ) );
   13715             : #endif
   13716           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateArgumentList )
   13717           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateArgumentList );
   13718           0 :           unsigned long positionInPool = localIndex % SgTemplateArgumentList::pool_size ;
   13719           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateArgumentList::pool_size ;
   13720             : 
   13721             : #if FILE_IO_EXTRA_CHECK
   13722             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   13723             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   13724             : #endif
   13725             : 
   13726           0 :           returnPointer = &( ( (SgTemplateArgumentList*)(SgTemplateArgumentList::pools[memoryBlock]) ) [positionInPool]) ;
   13727             : 
   13728             : #if FILE_IO_EXTRA_CHECK
   13729           0 :           assert ( returnPointer != NULL ) ;
   13730             : #endif
   13731             :         }
   13732           0 :      return returnPointer ;
   13733             :    }
   13734             : 
   13735             : //############################################################################
   13736             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   13737             :  * pool size! We set for every valid object in the memory pool the freepointer
   13738             :  * to the global index and increase the global index afterwards. For all the 
   13739             :  * invalid objects (means address ranges within the memory pool that were not
   13740             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   13741             :  * distinguish valid from invalid objects! 
   13742             :  */
   13743             : unsigned long
   13744           5 : SgTemplateArgumentList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   13745             :    {
   13746           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   13747           5 :      SgTemplateArgumentList* pointer = NULL;
   13748           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   13749           5 :      std::vector < unsigned char* > :: const_iterator block;
   13750           5 :      for ( block = SgTemplateArgumentList::pools.begin(); block != SgTemplateArgumentList::pools.end() ; ++block )
   13751             :         {
   13752           0 :           pointer = (SgTemplateArgumentList*)(*block);
   13753           0 :           for (unsigned i = 0; i < SgTemplateArgumentList::pool_size; ++i )
   13754             :              {
   13755             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   13756             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   13757             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   13758             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   13759             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   13760             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   13761             :             // properly; so this will have to be checked next.
   13762             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   13763             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   13764           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   13765             :                   {
   13766           0 :                     pointer[i].set_freepointer((SgTemplateArgumentList*)(globalIndex));
   13767           0 :                     globalIndex++;
   13768             :                   }
   13769             :                else
   13770             :                   {
   13771           0 :                     pointer[i].set_freepointer(NULL);
   13772             :                   }
   13773             :               }
   13774             :         }
   13775           5 :      return globalIndex;
   13776             :    }
   13777             : 
   13778             : //############################################################################
   13779             : // JH (01/14/2006)
   13780             : void
   13781           5 : SgTemplateArgumentList::resetValidFreepointers( )
   13782             :    {
   13783           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   13784           5 :      SgTemplateArgumentList* pointer = NULL;
   13785           5 :      std::vector < unsigned char* > :: const_iterator block;
   13786           5 :      SgTemplateArgumentList* pointerOfLinkedList = NULL;
   13787           5 :      for ( block = SgTemplateArgumentList::pools.begin(); block != SgTemplateArgumentList::pools.end() ; ++block )
   13788             :         {
   13789           0 :           pointer = (SgTemplateArgumentList*)(*block);
   13790           0 :           for (unsigned i = 0; i < SgTemplateArgumentList::pool_size; ++i )
   13791             :              {
   13792             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   13793             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   13794             :             // memory blocks!.
   13795           0 :                if ( pointer[i].get_freepointer() != NULL )
   13796             :                   {
   13797           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   13798             :                   }
   13799             :                else
   13800             :                   {
   13801           0 :                     if ( pointerOfLinkedList == NULL )
   13802             :                        {
   13803           0 :                          SgTemplateArgumentList::next_node = &(pointer[i]);
   13804             :                        }
   13805             :                     else
   13806             :                        {
   13807             :                       // printf ("In SgTemplateArgumentList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   13808           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   13809             :                        }
   13810             :                     pointerOfLinkedList = &(pointer[i]);
   13811             :                   }
   13812             :               }
   13813             :         }
   13814             : 
   13815           5 :      if ( pointerOfLinkedList != NULL )
   13816             :         {
   13817             :        // printf ("In SgTemplateArgumentList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   13818           0 :           pointerOfLinkedList->set_freepointer(NULL);
   13819             :        // DQ (6/6/2010): Temporary debugging...
   13820             :        //   ROSE_ASSERT(false);
   13821             :         }
   13822             : 
   13823           5 :      return ;
   13824             :    }
   13825             : 
   13826             : //############################################################################
   13827             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   13828             :  * within the memory pool and resets the freepointers, in order to achieve a 
   13829             :  * linked list, that has no jumps and starts at the beginning! This function 
   13830             :  * does not extend the memory pool, since we do not delete any memory blocks,
   13831             :  * but delete the valid objects.  
   13832             :  */
   13833             : void
   13834           0 : SgTemplateArgumentList::clearMemoryPool( )
   13835             :    {
   13836             :   // printf ("Inside of SgTemplateArgumentList::clearMemoryPool() \n");
   13837             : 
   13838           0 :      SgTemplateArgumentList* pointer = NULL, *tempPointer = NULL;
   13839           0 :      std::vector < unsigned char* > :: const_iterator block;
   13840           0 :      if ( SgTemplateArgumentList::pools.empty() == false )
   13841             :         {
   13842           0 :           block = SgTemplateArgumentList::pools.begin() ;
   13843           0 :           SgTemplateArgumentList::next_node = (SgTemplateArgumentList*) (*block);
   13844             : 
   13845           0 :           while ( block != SgTemplateArgumentList::pools.end() )
   13846             :              {
   13847           0 :                pointer = (SgTemplateArgumentList*) (*block);
   13848           0 :                if ( tempPointer != NULL )
   13849             :                   {
   13850           0 :                     tempPointer->set_freepointer(pointer);
   13851             :                   }
   13852           0 :                for (unsigned i = 0; i < SgTemplateArgumentList::pool_size - 1; ++i)
   13853             :                   {
   13854           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   13855             :                   }
   13856           0 :                 pointer[SgTemplateArgumentList::pool_size-1].set_freepointer(NULL);
   13857           0 :                 tempPointer = &(pointer[SgTemplateArgumentList::pool_size-1]);
   13858           0 :                 ++block;
   13859             :              }
   13860             :         }
   13861           0 :    }
   13862             : 
   13863           5 : void SgTemplateArgumentList::deleteMemoryPool() {
   13864           5 :   for (auto p: SgTemplateArgumentList::pools) {
   13865           0 :     ROSE_FREE(p);
   13866             :   }
   13867           5 :   SgTemplateArgumentList::next_node = nullptr;
   13868           5 :   SgTemplateArgumentList::pools.clear();
   13869           5 : }
   13870             : 
   13871             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   13872             : //                 reading multiple binary files to for a single AST.
   13873             : /////////// new version ////////////////////////////////
   13874             : //############################################################################
   13875             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   13876             : void
   13877           2 : SgTemplateArgumentList::extendMemoryPoolForFileIO( )
   13878             :   {
   13879           2 :     size_t blockIndex = SgTemplateArgumentList::pools.size();
   13880           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateArgumentList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateArgumentList);
   13881             : 
   13882           2 :     while ( (blockIndex * SgTemplateArgumentList::pool_size) < newPoolSize)
   13883             :       {
   13884             : #if ROSE_ALLOC_TRACE
   13885             :         if (blockIndex > 0) {
   13886             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateArgumentList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateArgumentList) = %" PRIuPTR " SgTemplateArgumentList::pool_size = %d \n",
   13887             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateArgumentList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateArgumentList),SgTemplateArgumentList::pool_size);
   13888             :         }
   13889             : #endif
   13890             : 
   13891           0 :         SgTemplateArgumentList * pointer = (SgTemplateArgumentList*) ROSE_MALLOC ( SgTemplateArgumentList::pool_size * sizeof(SgTemplateArgumentList) );
   13892           0 :         assert( pointer != NULL );
   13893             : #if ROSE_ALLOC_MEMSET == 1
   13894             :         memset(pointer, 0x00, SgTemplateArgumentList::pool_size * sizeof(SgTemplateArgumentList));
   13895             : #elif ROSE_ALLOC_MEMSET == 2
   13896             :         memset(pointer, 0xCC, SgTemplateArgumentList::pool_size * sizeof(SgTemplateArgumentList));
   13897             : #endif
   13898           0 :         SgTemplateArgumentList::pools.push_back( (unsigned char*)(pointer) );
   13899           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateArgumentList::pool_size * sizeof(SgTemplateArgumentList), V_SgTemplateArgumentList ) );
   13900             : 
   13901           0 :         if ( SgTemplateArgumentList::next_node != NULL ) {
   13902           0 :           if ( blockIndex > 0 ) {
   13903           0 :             SgTemplateArgumentList * blkptr = (SgTemplateArgumentList*)(SgTemplateArgumentList::pools[blockIndex-1]);
   13904           0 :             blkptr[ SgTemplateArgumentList::pool_size - 1 ].set_freepointer(pointer);
   13905             :           }
   13906             :         } else {
   13907           0 :           SgTemplateArgumentList::next_node = pointer;
   13908             :         }
   13909             : 
   13910           0 :         for (unsigned i = 0; i < SgTemplateArgumentList::pool_size-1; ++i)
   13911             :            {
   13912           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   13913             :            }
   13914           0 :         pointer[ SgTemplateArgumentList::pool_size -1 ].set_freepointer(NULL);
   13915             : 
   13916           0 :         blockIndex++;
   13917             :       }
   13918           2 :   }
   13919             : 
   13920             : //############################################################################
   13921             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   13922             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   13923             :  * not compressed. However, that stuff is not yet implemented! 
   13924             :  */
   13925             : unsigned long
   13926           0 : SgTemplateArgumentList::getNumberOfLastValidPointer()
   13927             :    {
   13928           0 :       SgTemplateArgumentList* testPointer = (SgTemplateArgumentList*)(SgTemplateArgumentList::pools.back());
   13929           0 :       unsigned long localIndex = SgTemplateArgumentList::pool_size - 1;
   13930           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   13931             :          {
   13932           0 :            localIndex--;
   13933             :          }
   13934           0 :       return (localIndex + SgTemplateArgumentList::pool_size * (SgTemplateArgumentList::pools.size()-1));
   13935             :    }
   13936             : 
   13937             : //############################################################################
   13938             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   13939             :  * memory pool and initializes the data member in class SgTemplateArgumentListStroageClass
   13940             :  * from its counterpart of SgTemplateArgumentList. The return value is just for checking, 
   13941             :  * that the whole StorageClassArray is initialized!
   13942             :  */
   13943             : unsigned long
   13944           0 : SgTemplateArgumentList::initializeStorageClassArray( SgTemplateArgumentListStorageClass *storageArray )
   13945             :    {
   13946           0 :      unsigned long storageCounter = 0;
   13947           0 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateArgumentList::pools.begin();
   13948           0 :      SgTemplateArgumentList* pointer = NULL;
   13949           0 :      while ( block != SgTemplateArgumentList::pools.end() ) {
   13950           0 :           pointer = (SgTemplateArgumentList*) (*block);
   13951           0 :           for ( unsigned i = 0; i < SgTemplateArgumentList::pool_size; ++i ) {
   13952           0 :                if ( pointer->get_freepointer() != NULL ) {
   13953           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   13954           0 :                  storageArray++;
   13955           0 :                  storageCounter++;
   13956             :                }
   13957           0 :                pointer++;
   13958             :              }
   13959           0 :            block++;
   13960             :         }
   13961           0 :      return storageCounter;
   13962             :    }
   13963             : 
   13964             : /* #line 13965 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   13965             : 
   13966             : 
   13967             : 
   13968             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   13969             : 
   13970             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   13971             : 
   13972             : //############################################################################
   13973             : /* JH (02/02/2006) Constructor of the IR node SgTemplateParameterList that takes its 
   13974             :  * corresponding StorageClass as parameter
   13975             :  */
   13976           0 : SgTemplateParameterList :: SgTemplateParameterList ( const SgTemplateParameterListStorageClass& storageSource )   : SgSupport (storageSource)
   13977             :    {
   13978             : 
   13979             : 
   13980             : /* #line 13981 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   13981             : 
   13982           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   13983           0 :      p_args = storageSource.storageOf_args.rebuildDataStoredInEasyStorageClass() ;
   13984           0 :      SgTemplateParameterPtrList::iterator i_args = p_args.begin() ; 
   13985           0 :      for ( ; i_args != p_args.end(); ++i_args ) 
   13986             :         {
   13987           0 :           (*i_args) = (SgTemplateParameterPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_args) ) );
   13988             :         }
   13989             : 
   13990             : 
   13991             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   13992             : 
   13993             : 
   13994           0 :    }
   13995             : 
   13996             : //############################################################################
   13997             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   13998             :  * within the working AST. 
   13999             :  */
   14000           0 : SgTemplateParameterList * SgTemplateParameterList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   14001           0 :      SgTemplateParameterList* returnPointer = NULL;
   14002           0 :      if ( globalIndex != 0 )
   14003             :         {
   14004             : 
   14005             : #if FILE_IO_EXTRA_CHECK
   14006           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateParameterList ) ) <= globalIndex ) ;
   14007           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateParameterList + 1 ) ) );
   14008             : #endif
   14009           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateParameterList )  
   14010           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateParameterList );
   14011           0 :           unsigned long positionInPool = localIndex % SgTemplateParameterList::pool_size;
   14012           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateParameterList::pool_size;
   14013             : 
   14014             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   14015             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   14016             : 
   14017           0 :           returnPointer = &( ( (SgTemplateParameterList*)(SgTemplateParameterList::pools[memoryBlock]) ) [positionInPool]) ;
   14018             : 
   14019           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   14020             :         }
   14021           0 :      return returnPointer ;
   14022             :    }
   14023             : 
   14024             : //############################################################################
   14025             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   14026             :   for the AST with the index astIndex
   14027             : */
   14028           0 : SgTemplateParameterList * SgTemplateParameterList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   14029           0 :      SgTemplateParameterList* returnPointer = NULL;
   14030           0 :      if ( globalIndex != 0 )
   14031             :         {
   14032             : 
   14033             : #if FILE_IO_EXTRA_CHECK
   14034           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateParameterList ) ) <= globalIndex ) ;
   14035           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateParameterList + 1 ) ) );
   14036             : #endif
   14037           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateParameterList )
   14038           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateParameterList );
   14039           0 :           unsigned long positionInPool = localIndex % SgTemplateParameterList::pool_size ;
   14040           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateParameterList::pool_size ;
   14041             : 
   14042             : #if FILE_IO_EXTRA_CHECK
   14043             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   14044             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   14045             : #endif
   14046             : 
   14047           0 :           returnPointer = &( ( (SgTemplateParameterList*)(SgTemplateParameterList::pools[memoryBlock]) ) [positionInPool]) ;
   14048             : 
   14049             : #if FILE_IO_EXTRA_CHECK
   14050           0 :           assert ( returnPointer != NULL ) ;
   14051             : #endif
   14052             :         }
   14053           0 :      return returnPointer ;
   14054             :    }
   14055             : 
   14056             : //############################################################################
   14057             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   14058             :  * pool size! We set for every valid object in the memory pool the freepointer
   14059             :  * to the global index and increase the global index afterwards. For all the 
   14060             :  * invalid objects (means address ranges within the memory pool that were not
   14061             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   14062             :  * distinguish valid from invalid objects! 
   14063             :  */
   14064             : unsigned long
   14065           5 : SgTemplateParameterList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   14066             :    {
   14067           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   14068           5 :      SgTemplateParameterList* pointer = NULL;
   14069           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   14070           5 :      std::vector < unsigned char* > :: const_iterator block;
   14071           5 :      for ( block = SgTemplateParameterList::pools.begin(); block != SgTemplateParameterList::pools.end() ; ++block )
   14072             :         {
   14073           0 :           pointer = (SgTemplateParameterList*)(*block);
   14074           0 :           for (unsigned i = 0; i < SgTemplateParameterList::pool_size; ++i )
   14075             :              {
   14076             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   14077             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   14078             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   14079             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   14080             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   14081             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   14082             :             // properly; so this will have to be checked next.
   14083             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   14084             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   14085           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   14086             :                   {
   14087           0 :                     pointer[i].set_freepointer((SgTemplateParameterList*)(globalIndex));
   14088           0 :                     globalIndex++;
   14089             :                   }
   14090             :                else
   14091             :                   {
   14092           0 :                     pointer[i].set_freepointer(NULL);
   14093             :                   }
   14094             :               }
   14095             :         }
   14096           5 :      return globalIndex;
   14097             :    }
   14098             : 
   14099             : //############################################################################
   14100             : // JH (01/14/2006)
   14101             : void
   14102           5 : SgTemplateParameterList::resetValidFreepointers( )
   14103             :    {
   14104           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   14105           5 :      SgTemplateParameterList* pointer = NULL;
   14106           5 :      std::vector < unsigned char* > :: const_iterator block;
   14107           5 :      SgTemplateParameterList* pointerOfLinkedList = NULL;
   14108           5 :      for ( block = SgTemplateParameterList::pools.begin(); block != SgTemplateParameterList::pools.end() ; ++block )
   14109             :         {
   14110           0 :           pointer = (SgTemplateParameterList*)(*block);
   14111           0 :           for (unsigned i = 0; i < SgTemplateParameterList::pool_size; ++i )
   14112             :              {
   14113             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   14114             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   14115             :             // memory blocks!.
   14116           0 :                if ( pointer[i].get_freepointer() != NULL )
   14117             :                   {
   14118           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   14119             :                   }
   14120             :                else
   14121             :                   {
   14122           0 :                     if ( pointerOfLinkedList == NULL )
   14123             :                        {
   14124           0 :                          SgTemplateParameterList::next_node = &(pointer[i]);
   14125             :                        }
   14126             :                     else
   14127             :                        {
   14128             :                       // printf ("In SgTemplateParameterList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   14129           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   14130             :                        }
   14131             :                     pointerOfLinkedList = &(pointer[i]);
   14132             :                   }
   14133             :               }
   14134             :         }
   14135             : 
   14136           5 :      if ( pointerOfLinkedList != NULL )
   14137             :         {
   14138             :        // printf ("In SgTemplateParameterList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   14139           0 :           pointerOfLinkedList->set_freepointer(NULL);
   14140             :        // DQ (6/6/2010): Temporary debugging...
   14141             :        //   ROSE_ASSERT(false);
   14142             :         }
   14143             : 
   14144           5 :      return ;
   14145             :    }
   14146             : 
   14147             : //############################################################################
   14148             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   14149             :  * within the memory pool and resets the freepointers, in order to achieve a 
   14150             :  * linked list, that has no jumps and starts at the beginning! This function 
   14151             :  * does not extend the memory pool, since we do not delete any memory blocks,
   14152             :  * but delete the valid objects.  
   14153             :  */
   14154             : void
   14155           0 : SgTemplateParameterList::clearMemoryPool( )
   14156             :    {
   14157             :   // printf ("Inside of SgTemplateParameterList::clearMemoryPool() \n");
   14158             : 
   14159           0 :      SgTemplateParameterList* pointer = NULL, *tempPointer = NULL;
   14160           0 :      std::vector < unsigned char* > :: const_iterator block;
   14161           0 :      if ( SgTemplateParameterList::pools.empty() == false )
   14162             :         {
   14163           0 :           block = SgTemplateParameterList::pools.begin() ;
   14164           0 :           SgTemplateParameterList::next_node = (SgTemplateParameterList*) (*block);
   14165             : 
   14166           0 :           while ( block != SgTemplateParameterList::pools.end() )
   14167             :              {
   14168           0 :                pointer = (SgTemplateParameterList*) (*block);
   14169           0 :                if ( tempPointer != NULL )
   14170             :                   {
   14171           0 :                     tempPointer->set_freepointer(pointer);
   14172             :                   }
   14173           0 :                for (unsigned i = 0; i < SgTemplateParameterList::pool_size - 1; ++i)
   14174             :                   {
   14175           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   14176             :                   }
   14177           0 :                 pointer[SgTemplateParameterList::pool_size-1].set_freepointer(NULL);
   14178           0 :                 tempPointer = &(pointer[SgTemplateParameterList::pool_size-1]);
   14179           0 :                 ++block;
   14180             :              }
   14181             :         }
   14182           0 :    }
   14183             : 
   14184           5 : void SgTemplateParameterList::deleteMemoryPool() {
   14185           5 :   for (auto p: SgTemplateParameterList::pools) {
   14186           0 :     ROSE_FREE(p);
   14187             :   }
   14188           5 :   SgTemplateParameterList::next_node = nullptr;
   14189           5 :   SgTemplateParameterList::pools.clear();
   14190           5 : }
   14191             : 
   14192             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   14193             : //                 reading multiple binary files to for a single AST.
   14194             : /////////// new version ////////////////////////////////
   14195             : //############################################################################
   14196             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   14197             : void
   14198           2 : SgTemplateParameterList::extendMemoryPoolForFileIO( )
   14199             :   {
   14200           2 :     size_t blockIndex = SgTemplateParameterList::pools.size();
   14201           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameterList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameterList);
   14202             : 
   14203           2 :     while ( (blockIndex * SgTemplateParameterList::pool_size) < newPoolSize)
   14204             :       {
   14205             : #if ROSE_ALLOC_TRACE
   14206             :         if (blockIndex > 0) {
   14207             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameterList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameterList) = %" PRIuPTR " SgTemplateParameterList::pool_size = %d \n",
   14208             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameterList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameterList),SgTemplateParameterList::pool_size);
   14209             :         }
   14210             : #endif
   14211             : 
   14212           0 :         SgTemplateParameterList * pointer = (SgTemplateParameterList*) ROSE_MALLOC ( SgTemplateParameterList::pool_size * sizeof(SgTemplateParameterList) );
   14213           0 :         assert( pointer != NULL );
   14214             : #if ROSE_ALLOC_MEMSET == 1
   14215             :         memset(pointer, 0x00, SgTemplateParameterList::pool_size * sizeof(SgTemplateParameterList));
   14216             : #elif ROSE_ALLOC_MEMSET == 2
   14217             :         memset(pointer, 0xCC, SgTemplateParameterList::pool_size * sizeof(SgTemplateParameterList));
   14218             : #endif
   14219           0 :         SgTemplateParameterList::pools.push_back( (unsigned char*)(pointer) );
   14220           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateParameterList::pool_size * sizeof(SgTemplateParameterList), V_SgTemplateParameterList ) );
   14221             : 
   14222           0 :         if ( SgTemplateParameterList::next_node != NULL ) {
   14223           0 :           if ( blockIndex > 0 ) {
   14224           0 :             SgTemplateParameterList * blkptr = (SgTemplateParameterList*)(SgTemplateParameterList::pools[blockIndex-1]);
   14225           0 :             blkptr[ SgTemplateParameterList::pool_size - 1 ].set_freepointer(pointer);
   14226             :           }
   14227             :         } else {
   14228           0 :           SgTemplateParameterList::next_node = pointer;
   14229             :         }
   14230             : 
   14231           0 :         for (unsigned i = 0; i < SgTemplateParameterList::pool_size-1; ++i)
   14232             :            {
   14233           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   14234             :            }
   14235           0 :         pointer[ SgTemplateParameterList::pool_size -1 ].set_freepointer(NULL);
   14236             : 
   14237           0 :         blockIndex++;
   14238             :       }
   14239           2 :   }
   14240             : 
   14241             : //############################################################################
   14242             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   14243             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   14244             :  * not compressed. However, that stuff is not yet implemented! 
   14245             :  */
   14246             : unsigned long
   14247           0 : SgTemplateParameterList::getNumberOfLastValidPointer()
   14248             :    {
   14249           0 :       SgTemplateParameterList* testPointer = (SgTemplateParameterList*)(SgTemplateParameterList::pools.back());
   14250           0 :       unsigned long localIndex = SgTemplateParameterList::pool_size - 1;
   14251           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   14252             :          {
   14253           0 :            localIndex--;
   14254             :          }
   14255           0 :       return (localIndex + SgTemplateParameterList::pool_size * (SgTemplateParameterList::pools.size()-1));
   14256             :    }
   14257             : 
   14258             : //############################################################################
   14259             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   14260             :  * memory pool and initializes the data member in class SgTemplateParameterListStroageClass
   14261             :  * from its counterpart of SgTemplateParameterList. The return value is just for checking, 
   14262             :  * that the whole StorageClassArray is initialized!
   14263             :  */
   14264             : unsigned long
   14265           0 : SgTemplateParameterList::initializeStorageClassArray( SgTemplateParameterListStorageClass *storageArray )
   14266             :    {
   14267           0 :      unsigned long storageCounter = 0;
   14268           0 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateParameterList::pools.begin();
   14269           0 :      SgTemplateParameterList* pointer = NULL;
   14270           0 :      while ( block != SgTemplateParameterList::pools.end() ) {
   14271           0 :           pointer = (SgTemplateParameterList*) (*block);
   14272           0 :           for ( unsigned i = 0; i < SgTemplateParameterList::pool_size; ++i ) {
   14273           0 :                if ( pointer->get_freepointer() != NULL ) {
   14274           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   14275           0 :                  storageArray++;
   14276           0 :                  storageCounter++;
   14277             :                }
   14278           0 :                pointer++;
   14279             :              }
   14280           0 :            block++;
   14281             :         }
   14282           0 :      return storageCounter;
   14283             :    }
   14284             : 
   14285             : /* #line 14286 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   14286             : 
   14287             : 
   14288             : 
   14289             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   14290             : 
   14291             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   14292             : 
   14293             : //############################################################################
   14294             : /* JH (02/02/2006) Constructor of the IR node SgGraph that takes its 
   14295             :  * corresponding StorageClass as parameter
   14296             :  */
   14297           0 : SgGraph :: SgGraph ( const SgGraphStorageClass& storageSource )   : SgSupport (storageSource)
   14298             :    {
   14299             : 
   14300             : 
   14301             : /* #line 14302 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   14302             : 
   14303           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   14304           0 :      p_name = storageSource.storageOf_name.rebuildDataStoredInEasyStorageClass() ;
   14305           0 :      p_node_index_to_node_map = storageSource.storageOf_node_index_to_node_map.rebuildDataStoredInEasyStorageClass() ;
   14306           0 :      rose_graph_integer_node_hash_map::iterator integer_node_it; 
   14307           0 :       for (integer_node_it = p_node_index_to_node_map.begin(); integer_node_it != p_node_index_to_node_map.end(); ++integer_node_it)
   14308             :          {
   14309           0 :           integer_node_it->second = (SgGraphNode*)(AST_FILE_IO::getSgClassPointerFromGlobalIndex( (unsigned long)(integer_node_it->second) ) ); 
   14310             :         }
   14311           0 :      p_edge_index_to_edge_map = storageSource.storageOf_edge_index_to_edge_map.rebuildDataStoredInEasyStorageClass() ;
   14312           0 :      rose_graph_integer_edge_hash_map::iterator integer_edge_it; 
   14313           0 :       for (integer_edge_it = p_edge_index_to_edge_map.begin(); integer_edge_it != p_edge_index_to_edge_map.end(); ++integer_edge_it)
   14314             :          {
   14315           0 :           integer_edge_it->second = (SgGraphEdge*)(AST_FILE_IO::getSgClassPointerFromGlobalIndex( (unsigned long)(integer_edge_it->second) ) ); 
   14316             :         }
   14317           0 :      p_node_index_pair_to_edge_multimap = storageSource.storageOf_node_index_pair_to_edge_multimap.rebuildDataStoredInEasyStorageClass() ;
   14318           0 :      rose_graph_integerpair_edge_hash_multimap::iterator integerpair_edge_it; 
   14319           0 :       for (integerpair_edge_it = p_node_index_pair_to_edge_multimap.begin(); integerpair_edge_it != p_node_index_pair_to_edge_multimap.end(); ++integerpair_edge_it)
   14320             :          {
   14321           0 :           integerpair_edge_it->second = NULL; printf ("Error: not implemented support for rose_graph_integerpair_edge_hash_multimap \n"); ROSE_ASSERT(false); 
   14322             :         }
   14323           0 :    {
   14324           0 :      p_string_to_node_index_multimap = storageSource.storageOf_string_to_node_index_multimap.rebuildDataStoredInEasyStorageClass() ;
   14325           0 :      rose_graph_string_integer_hash_multimap::iterator string_integer_it; 
   14326           0 :       for (string_integer_it = p_string_to_node_index_multimap.begin(); string_integer_it != p_string_to_node_index_multimap.end(); ++string_integer_it)
   14327             :          {
   14328           0 :           string_integer_it->second = 0; printf ("Unimplemented support for rose_graph_string_integer_hash_multimap: Fixme! \n"); ROSE_ASSERT(false); 
   14329             :         }
   14330             :    }
   14331           0 :    {
   14332           0 :      p_string_to_edge_index_multimap = storageSource.storageOf_string_to_edge_index_multimap.rebuildDataStoredInEasyStorageClass() ;
   14333           0 :      rose_graph_string_integer_hash_multimap::iterator string_integer_it; 
   14334           0 :       for (string_integer_it = p_string_to_edge_index_multimap.begin(); string_integer_it != p_string_to_edge_index_multimap.end(); ++string_integer_it)
   14335             :          {
   14336           0 :           string_integer_it->second = 0; printf ("Unimplemented support for rose_graph_string_integer_hash_multimap: Fixme! \n"); ROSE_ASSERT(false); 
   14337             :         }
   14338             :    }
   14339           0 :    {
   14340           0 :      p_node_index_to_edge_multimap = storageSource.storageOf_node_index_to_edge_multimap.rebuildDataStoredInEasyStorageClass() ;
   14341           0 :      rose_graph_integer_edge_hash_multimap::iterator integer_edge_it2; 
   14342           0 :       for (integer_edge_it2 = p_node_index_to_edge_multimap.begin(); integer_edge_it2 != p_node_index_to_edge_multimap.end(); ++integer_edge_it2)
   14343             :          {
   14344           0 :           integer_edge_it2->second = (SgGraphEdge*)(AST_FILE_IO::getSgClassPointerFromGlobalIndex( (unsigned long)(integer_edge_it2->second) ) ); 
   14345             :         }
   14346             :    }
   14347           0 :      p_index = storageSource.storageOf_index ;
   14348           0 :      p_boost_edges = storageSource.storageOf_boost_edges.rebuildDataStoredInEasyStorageClass() ;
   14349           0 :      p_boost_edge_weights = storageSource.storageOf_boost_edge_weights.rebuildDataStoredInEasyStorageClass() ;
   14350           0 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
   14351           0 :      p_properties = storageSource.storageOf_properties.rebuildDataStoredInEasyStorageClass() ;
   14352             : 
   14353             : 
   14354             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   14355             : 
   14356             : 
   14357           0 :    }
   14358             : 
   14359             : //############################################################################
   14360             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   14361             :  * within the working AST. 
   14362             :  */
   14363           0 : SgGraph * SgGraph::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   14364           0 :      SgGraph* returnPointer = NULL;
   14365           0 :      if ( globalIndex != 0 )
   14366             :         {
   14367             : 
   14368             : #if FILE_IO_EXTRA_CHECK
   14369           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGraph ) ) <= globalIndex ) ;
   14370           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraph + 1 ) ) );
   14371             : #endif
   14372           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraph )  
   14373           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGraph );
   14374           0 :           unsigned long positionInPool = localIndex % SgGraph::pool_size;
   14375           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraph::pool_size;
   14376             : 
   14377             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   14378             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   14379             : 
   14380           0 :           returnPointer = &( ( (SgGraph*)(SgGraph::pools[memoryBlock]) ) [positionInPool]) ;
   14381             : 
   14382           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   14383             :         }
   14384           0 :      return returnPointer ;
   14385             :    }
   14386             : 
   14387             : //############################################################################
   14388             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   14389             :   for the AST with the index astIndex
   14390             : */
   14391           0 : SgGraph * SgGraph::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   14392           0 :      SgGraph* returnPointer = NULL;
   14393           0 :      if ( globalIndex != 0 )
   14394             :         {
   14395             : 
   14396             : #if FILE_IO_EXTRA_CHECK
   14397           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGraph ) ) <= globalIndex ) ;
   14398           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraph + 1 ) ) );
   14399             : #endif
   14400           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraph )
   14401           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGraph );
   14402           0 :           unsigned long positionInPool = localIndex % SgGraph::pool_size ;
   14403           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraph::pool_size ;
   14404             : 
   14405             : #if FILE_IO_EXTRA_CHECK
   14406             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   14407             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   14408             : #endif
   14409             : 
   14410           0 :           returnPointer = &( ( (SgGraph*)(SgGraph::pools[memoryBlock]) ) [positionInPool]) ;
   14411             : 
   14412             : #if FILE_IO_EXTRA_CHECK
   14413           0 :           assert ( returnPointer != NULL ) ;
   14414             : #endif
   14415             :         }
   14416           0 :      return returnPointer ;
   14417             :    }
   14418             : 
   14419             : //############################################################################
   14420             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   14421             :  * pool size! We set for every valid object in the memory pool the freepointer
   14422             :  * to the global index and increase the global index afterwards. For all the 
   14423             :  * invalid objects (means address ranges within the memory pool that were not
   14424             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   14425             :  * distinguish valid from invalid objects! 
   14426             :  */
   14427             : unsigned long
   14428           5 : SgGraph::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   14429             :    {
   14430           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   14431           5 :      SgGraph* pointer = NULL;
   14432           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   14433           5 :      std::vector < unsigned char* > :: const_iterator block;
   14434           5 :      for ( block = SgGraph::pools.begin(); block != SgGraph::pools.end() ; ++block )
   14435             :         {
   14436           0 :           pointer = (SgGraph*)(*block);
   14437           0 :           for (unsigned i = 0; i < SgGraph::pool_size; ++i )
   14438             :              {
   14439             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   14440             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   14441             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   14442             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   14443             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   14444             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   14445             :             // properly; so this will have to be checked next.
   14446             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   14447             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   14448           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   14449             :                   {
   14450           0 :                     pointer[i].set_freepointer((SgGraph*)(globalIndex));
   14451           0 :                     globalIndex++;
   14452             :                   }
   14453             :                else
   14454             :                   {
   14455           0 :                     pointer[i].set_freepointer(NULL);
   14456             :                   }
   14457             :               }
   14458             :         }
   14459           5 :      return globalIndex;
   14460             :    }
   14461             : 
   14462             : //############################################################################
   14463             : // JH (01/14/2006)
   14464             : void
   14465           5 : SgGraph::resetValidFreepointers( )
   14466             :    {
   14467           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   14468           5 :      SgGraph* pointer = NULL;
   14469           5 :      std::vector < unsigned char* > :: const_iterator block;
   14470           5 :      SgGraph* pointerOfLinkedList = NULL;
   14471           5 :      for ( block = SgGraph::pools.begin(); block != SgGraph::pools.end() ; ++block )
   14472             :         {
   14473           0 :           pointer = (SgGraph*)(*block);
   14474           0 :           for (unsigned i = 0; i < SgGraph::pool_size; ++i )
   14475             :              {
   14476             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   14477             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   14478             :             // memory blocks!.
   14479           0 :                if ( pointer[i].get_freepointer() != NULL )
   14480             :                   {
   14481           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   14482             :                   }
   14483             :                else
   14484             :                   {
   14485           0 :                     if ( pointerOfLinkedList == NULL )
   14486             :                        {
   14487           0 :                          SgGraph::next_node = &(pointer[i]);
   14488             :                        }
   14489             :                     else
   14490             :                        {
   14491             :                       // printf ("In SgGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   14492           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   14493             :                        }
   14494             :                     pointerOfLinkedList = &(pointer[i]);
   14495             :                   }
   14496             :               }
   14497             :         }
   14498             : 
   14499           5 :      if ( pointerOfLinkedList != NULL )
   14500             :         {
   14501             :        // printf ("In SgGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   14502           0 :           pointerOfLinkedList->set_freepointer(NULL);
   14503             :        // DQ (6/6/2010): Temporary debugging...
   14504             :        //   ROSE_ASSERT(false);
   14505             :         }
   14506             : 
   14507           5 :      return ;
   14508             :    }
   14509             : 
   14510             : //############################################################################
   14511             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   14512             :  * within the memory pool and resets the freepointers, in order to achieve a 
   14513             :  * linked list, that has no jumps and starts at the beginning! This function 
   14514             :  * does not extend the memory pool, since we do not delete any memory blocks,
   14515             :  * but delete the valid objects.  
   14516             :  */
   14517             : void
   14518           0 : SgGraph::clearMemoryPool( )
   14519             :    {
   14520             :   // printf ("Inside of SgGraph::clearMemoryPool() \n");
   14521             : 
   14522           0 :      SgGraph* pointer = NULL, *tempPointer = NULL;
   14523           0 :      std::vector < unsigned char* > :: const_iterator block;
   14524           0 :      if ( SgGraph::pools.empty() == false )
   14525             :         {
   14526           0 :           block = SgGraph::pools.begin() ;
   14527           0 :           SgGraph::next_node = (SgGraph*) (*block);
   14528             : 
   14529           0 :           while ( block != SgGraph::pools.end() )
   14530             :              {
   14531           0 :                pointer = (SgGraph*) (*block);
   14532           0 :                if ( tempPointer != NULL )
   14533             :                   {
   14534           0 :                     tempPointer->set_freepointer(pointer);
   14535             :                   }
   14536           0 :                for (unsigned i = 0; i < SgGraph::pool_size - 1; ++i)
   14537             :                   {
   14538           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   14539             :                   }
   14540           0 :                 pointer[SgGraph::pool_size-1].set_freepointer(NULL);
   14541           0 :                 tempPointer = &(pointer[SgGraph::pool_size-1]);
   14542           0 :                 ++block;
   14543             :              }
   14544             :         }
   14545           0 :    }
   14546             : 
   14547           5 : void SgGraph::deleteMemoryPool() {
   14548           5 :   for (auto p: SgGraph::pools) {
   14549           0 :     ROSE_FREE(p);
   14550             :   }
   14551           5 :   SgGraph::next_node = nullptr;
   14552           5 :   SgGraph::pools.clear();
   14553           5 : }
   14554             : 
   14555             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   14556             : //                 reading multiple binary files to for a single AST.
   14557             : /////////// new version ////////////////////////////////
   14558             : //############################################################################
   14559             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   14560             : void
   14561           2 : SgGraph::extendMemoryPoolForFileIO( )
   14562             :   {
   14563           2 :     size_t blockIndex = SgGraph::pools.size();
   14564           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGraph) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraph);
   14565             : 
   14566           2 :     while ( (blockIndex * SgGraph::pool_size) < newPoolSize)
   14567             :       {
   14568             : #if ROSE_ALLOC_TRACE
   14569             :         if (blockIndex > 0) {
   14570             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGraph) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraph) = %" PRIuPTR " SgGraph::pool_size = %d \n",
   14571             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGraph),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraph),SgGraph::pool_size);
   14572             :         }
   14573             : #endif
   14574             : 
   14575           0 :         SgGraph * pointer = (SgGraph*) ROSE_MALLOC ( SgGraph::pool_size * sizeof(SgGraph) );
   14576           0 :         assert( pointer != NULL );
   14577             : #if ROSE_ALLOC_MEMSET == 1
   14578             :         memset(pointer, 0x00, SgGraph::pool_size * sizeof(SgGraph));
   14579             : #elif ROSE_ALLOC_MEMSET == 2
   14580             :         memset(pointer, 0xCC, SgGraph::pool_size * sizeof(SgGraph));
   14581             : #endif
   14582           0 :         SgGraph::pools.push_back( (unsigned char*)(pointer) );
   14583           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGraph::pool_size * sizeof(SgGraph), V_SgGraph ) );
   14584             : 
   14585           0 :         if ( SgGraph::next_node != NULL ) {
   14586           0 :           if ( blockIndex > 0 ) {
   14587           0 :             SgGraph * blkptr = (SgGraph*)(SgGraph::pools[blockIndex-1]);
   14588           0 :             blkptr[ SgGraph::pool_size - 1 ].set_freepointer(pointer);
   14589             :           }
   14590             :         } else {
   14591           0 :           SgGraph::next_node = pointer;
   14592             :         }
   14593             : 
   14594           0 :         for (unsigned i = 0; i < SgGraph::pool_size-1; ++i)
   14595             :            {
   14596           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   14597             :            }
   14598           0 :         pointer[ SgGraph::pool_size -1 ].set_freepointer(NULL);
   14599             : 
   14600           0 :         blockIndex++;
   14601             :       }
   14602           2 :   }
   14603             : 
   14604             : //############################################################################
   14605             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   14606             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   14607             :  * not compressed. However, that stuff is not yet implemented! 
   14608             :  */
   14609             : unsigned long
   14610           0 : SgGraph::getNumberOfLastValidPointer()
   14611             :    {
   14612           0 :       SgGraph* testPointer = (SgGraph*)(SgGraph::pools.back());
   14613           0 :       unsigned long localIndex = SgGraph::pool_size - 1;
   14614           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   14615             :          {
   14616           0 :            localIndex--;
   14617             :          }
   14618           0 :       return (localIndex + SgGraph::pool_size * (SgGraph::pools.size()-1));
   14619             :    }
   14620             : 
   14621             : //############################################################################
   14622             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   14623             :  * memory pool and initializes the data member in class SgGraphStroageClass
   14624             :  * from its counterpart of SgGraph. The return value is just for checking, 
   14625             :  * that the whole StorageClassArray is initialized!
   14626             :  */
   14627             : unsigned long
   14628           0 : SgGraph::initializeStorageClassArray( SgGraphStorageClass *storageArray )
   14629             :    {
   14630           0 :      unsigned long storageCounter = 0;
   14631           0 :      std::vector < unsigned char* > :: const_iterator block = SgGraph::pools.begin();
   14632           0 :      SgGraph* pointer = NULL;
   14633           0 :      while ( block != SgGraph::pools.end() ) {
   14634           0 :           pointer = (SgGraph*) (*block);
   14635           0 :           for ( unsigned i = 0; i < SgGraph::pool_size; ++i ) {
   14636           0 :                if ( pointer->get_freepointer() != NULL ) {
   14637           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   14638           0 :                  storageArray++;
   14639           0 :                  storageCounter++;
   14640             :                }
   14641           0 :                pointer++;
   14642             :              }
   14643           0 :            block++;
   14644             :         }
   14645           0 :      return storageCounter;
   14646             :    }
   14647             : 
   14648             : /* #line 14649 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   14649             : 
   14650             : 
   14651             : 
   14652             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   14653             : 
   14654             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   14655             : 
   14656             : //############################################################################
   14657             : /* JH (02/02/2006) Constructor of the IR node SgIncidenceDirectedGraph that takes its 
   14658             :  * corresponding StorageClass as parameter
   14659             :  */
   14660           0 : SgIncidenceDirectedGraph :: SgIncidenceDirectedGraph ( const SgIncidenceDirectedGraphStorageClass& storageSource )   : SgGraph (storageSource)
   14661             :    {
   14662             : 
   14663             : 
   14664             : /* #line 14665 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   14665             : 
   14666           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   14667           0 :    {
   14668           0 :      p_node_index_to_edge_multimap_edgesOut = storageSource.storageOf_node_index_to_edge_multimap_edgesOut.rebuildDataStoredInEasyStorageClass() ;
   14669           0 :      rose_graph_integer_edge_hash_multimap::iterator integer_edge_it2; 
   14670           0 :       for (integer_edge_it2 = p_node_index_to_edge_multimap_edgesOut.begin(); integer_edge_it2 != p_node_index_to_edge_multimap_edgesOut.end(); ++integer_edge_it2)
   14671             :          {
   14672           0 :           integer_edge_it2->second = (SgGraphEdge*)(AST_FILE_IO::getSgClassPointerFromGlobalIndex( (unsigned long)(integer_edge_it2->second) ) ); 
   14673             :         }
   14674             :    }
   14675           0 :    {
   14676           0 :      p_node_index_to_edge_multimap_edgesIn = storageSource.storageOf_node_index_to_edge_multimap_edgesIn.rebuildDataStoredInEasyStorageClass() ;
   14677           0 :      rose_graph_integer_edge_hash_multimap::iterator integer_edge_it2; 
   14678           0 :       for (integer_edge_it2 = p_node_index_to_edge_multimap_edgesIn.begin(); integer_edge_it2 != p_node_index_to_edge_multimap_edgesIn.end(); ++integer_edge_it2)
   14679             :          {
   14680           0 :           integer_edge_it2->second = (SgGraphEdge*)(AST_FILE_IO::getSgClassPointerFromGlobalIndex( (unsigned long)(integer_edge_it2->second) ) ); 
   14681             :         }
   14682             :    }
   14683             : 
   14684             : 
   14685             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   14686             : 
   14687             : 
   14688           0 :    }
   14689             : 
   14690             : //############################################################################
   14691             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   14692             :  * within the working AST. 
   14693             :  */
   14694           0 : SgIncidenceDirectedGraph * SgIncidenceDirectedGraph::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   14695           0 :      SgIncidenceDirectedGraph* returnPointer = NULL;
   14696           0 :      if ( globalIndex != 0 )
   14697             :         {
   14698             : 
   14699             : #if FILE_IO_EXTRA_CHECK
   14700           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIncidenceDirectedGraph ) ) <= globalIndex ) ;
   14701           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncidenceDirectedGraph + 1 ) ) );
   14702             : #endif
   14703           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncidenceDirectedGraph )  
   14704           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIncidenceDirectedGraph );
   14705           0 :           unsigned long positionInPool = localIndex % SgIncidenceDirectedGraph::pool_size;
   14706           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncidenceDirectedGraph::pool_size;
   14707             : 
   14708             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   14709             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   14710             : 
   14711           0 :           returnPointer = &( ( (SgIncidenceDirectedGraph*)(SgIncidenceDirectedGraph::pools[memoryBlock]) ) [positionInPool]) ;
   14712             : 
   14713           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   14714             :         }
   14715           0 :      return returnPointer ;
   14716             :    }
   14717             : 
   14718             : //############################################################################
   14719             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   14720             :   for the AST with the index astIndex
   14721             : */
   14722           0 : SgIncidenceDirectedGraph * SgIncidenceDirectedGraph::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   14723           0 :      SgIncidenceDirectedGraph* returnPointer = NULL;
   14724           0 :      if ( globalIndex != 0 )
   14725             :         {
   14726             : 
   14727             : #if FILE_IO_EXTRA_CHECK
   14728           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIncidenceDirectedGraph ) ) <= globalIndex ) ;
   14729           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncidenceDirectedGraph + 1 ) ) );
   14730             : #endif
   14731           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncidenceDirectedGraph )
   14732           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIncidenceDirectedGraph );
   14733           0 :           unsigned long positionInPool = localIndex % SgIncidenceDirectedGraph::pool_size ;
   14734           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncidenceDirectedGraph::pool_size ;
   14735             : 
   14736             : #if FILE_IO_EXTRA_CHECK
   14737             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   14738             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   14739             : #endif
   14740             : 
   14741           0 :           returnPointer = &( ( (SgIncidenceDirectedGraph*)(SgIncidenceDirectedGraph::pools[memoryBlock]) ) [positionInPool]) ;
   14742             : 
   14743             : #if FILE_IO_EXTRA_CHECK
   14744           0 :           assert ( returnPointer != NULL ) ;
   14745             : #endif
   14746             :         }
   14747           0 :      return returnPointer ;
   14748             :    }
   14749             : 
   14750             : //############################################################################
   14751             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   14752             :  * pool size! We set for every valid object in the memory pool the freepointer
   14753             :  * to the global index and increase the global index afterwards. For all the 
   14754             :  * invalid objects (means address ranges within the memory pool that were not
   14755             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   14756             :  * distinguish valid from invalid objects! 
   14757             :  */
   14758             : unsigned long
   14759           5 : SgIncidenceDirectedGraph::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   14760             :    {
   14761           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   14762           5 :      SgIncidenceDirectedGraph* pointer = NULL;
   14763           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   14764           5 :      std::vector < unsigned char* > :: const_iterator block;
   14765           5 :      for ( block = SgIncidenceDirectedGraph::pools.begin(); block != SgIncidenceDirectedGraph::pools.end() ; ++block )
   14766             :         {
   14767           0 :           pointer = (SgIncidenceDirectedGraph*)(*block);
   14768           0 :           for (unsigned i = 0; i < SgIncidenceDirectedGraph::pool_size; ++i )
   14769             :              {
   14770             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   14771             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   14772             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   14773             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   14774             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   14775             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   14776             :             // properly; so this will have to be checked next.
   14777             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   14778             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   14779           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   14780             :                   {
   14781           0 :                     pointer[i].set_freepointer((SgIncidenceDirectedGraph*)(globalIndex));
   14782           0 :                     globalIndex++;
   14783             :                   }
   14784             :                else
   14785             :                   {
   14786           0 :                     pointer[i].set_freepointer(NULL);
   14787             :                   }
   14788             :               }
   14789             :         }
   14790           5 :      return globalIndex;
   14791             :    }
   14792             : 
   14793             : //############################################################################
   14794             : // JH (01/14/2006)
   14795             : void
   14796           5 : SgIncidenceDirectedGraph::resetValidFreepointers( )
   14797             :    {
   14798           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   14799           5 :      SgIncidenceDirectedGraph* pointer = NULL;
   14800           5 :      std::vector < unsigned char* > :: const_iterator block;
   14801           5 :      SgIncidenceDirectedGraph* pointerOfLinkedList = NULL;
   14802           5 :      for ( block = SgIncidenceDirectedGraph::pools.begin(); block != SgIncidenceDirectedGraph::pools.end() ; ++block )
   14803             :         {
   14804           0 :           pointer = (SgIncidenceDirectedGraph*)(*block);
   14805           0 :           for (unsigned i = 0; i < SgIncidenceDirectedGraph::pool_size; ++i )
   14806             :              {
   14807             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   14808             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   14809             :             // memory blocks!.
   14810           0 :                if ( pointer[i].get_freepointer() != NULL )
   14811             :                   {
   14812           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   14813             :                   }
   14814             :                else
   14815             :                   {
   14816           0 :                     if ( pointerOfLinkedList == NULL )
   14817             :                        {
   14818           0 :                          SgIncidenceDirectedGraph::next_node = &(pointer[i]);
   14819             :                        }
   14820             :                     else
   14821             :                        {
   14822             :                       // printf ("In SgIncidenceDirectedGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   14823           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   14824             :                        }
   14825             :                     pointerOfLinkedList = &(pointer[i]);
   14826             :                   }
   14827             :               }
   14828             :         }
   14829             : 
   14830           5 :      if ( pointerOfLinkedList != NULL )
   14831             :         {
   14832             :        // printf ("In SgIncidenceDirectedGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   14833           0 :           pointerOfLinkedList->set_freepointer(NULL);
   14834             :        // DQ (6/6/2010): Temporary debugging...
   14835             :        //   ROSE_ASSERT(false);
   14836             :         }
   14837             : 
   14838           5 :      return ;
   14839             :    }
   14840             : 
   14841             : //############################################################################
   14842             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   14843             :  * within the memory pool and resets the freepointers, in order to achieve a 
   14844             :  * linked list, that has no jumps and starts at the beginning! This function 
   14845             :  * does not extend the memory pool, since we do not delete any memory blocks,
   14846             :  * but delete the valid objects.  
   14847             :  */
   14848             : void
   14849           0 : SgIncidenceDirectedGraph::clearMemoryPool( )
   14850             :    {
   14851             :   // printf ("Inside of SgIncidenceDirectedGraph::clearMemoryPool() \n");
   14852             : 
   14853           0 :      SgIncidenceDirectedGraph* pointer = NULL, *tempPointer = NULL;
   14854           0 :      std::vector < unsigned char* > :: const_iterator block;
   14855           0 :      if ( SgIncidenceDirectedGraph::pools.empty() == false )
   14856             :         {
   14857           0 :           block = SgIncidenceDirectedGraph::pools.begin() ;
   14858           0 :           SgIncidenceDirectedGraph::next_node = (SgIncidenceDirectedGraph*) (*block);
   14859             : 
   14860           0 :           while ( block != SgIncidenceDirectedGraph::pools.end() )
   14861             :              {
   14862           0 :                pointer = (SgIncidenceDirectedGraph*) (*block);
   14863           0 :                if ( tempPointer != NULL )
   14864             :                   {
   14865           0 :                     tempPointer->set_freepointer(pointer);
   14866             :                   }
   14867           0 :                for (unsigned i = 0; i < SgIncidenceDirectedGraph::pool_size - 1; ++i)
   14868             :                   {
   14869           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   14870             :                   }
   14871           0 :                 pointer[SgIncidenceDirectedGraph::pool_size-1].set_freepointer(NULL);
   14872           0 :                 tempPointer = &(pointer[SgIncidenceDirectedGraph::pool_size-1]);
   14873           0 :                 ++block;
   14874             :              }
   14875             :         }
   14876           0 :    }
   14877             : 
   14878           5 : void SgIncidenceDirectedGraph::deleteMemoryPool() {
   14879           5 :   for (auto p: SgIncidenceDirectedGraph::pools) {
   14880           0 :     ROSE_FREE(p);
   14881             :   }
   14882           5 :   SgIncidenceDirectedGraph::next_node = nullptr;
   14883           5 :   SgIncidenceDirectedGraph::pools.clear();
   14884           5 : }
   14885             : 
   14886             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   14887             : //                 reading multiple binary files to for a single AST.
   14888             : /////////// new version ////////////////////////////////
   14889             : //############################################################################
   14890             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   14891             : void
   14892           2 : SgIncidenceDirectedGraph::extendMemoryPoolForFileIO( )
   14893             :   {
   14894           2 :     size_t blockIndex = SgIncidenceDirectedGraph::pools.size();
   14895           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIncidenceDirectedGraph) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncidenceDirectedGraph);
   14896             : 
   14897           2 :     while ( (blockIndex * SgIncidenceDirectedGraph::pool_size) < newPoolSize)
   14898             :       {
   14899             : #if ROSE_ALLOC_TRACE
   14900             :         if (blockIndex > 0) {
   14901             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIncidenceDirectedGraph) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncidenceDirectedGraph) = %" PRIuPTR " SgIncidenceDirectedGraph::pool_size = %d \n",
   14902             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIncidenceDirectedGraph),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncidenceDirectedGraph),SgIncidenceDirectedGraph::pool_size);
   14903             :         }
   14904             : #endif
   14905             : 
   14906           0 :         SgIncidenceDirectedGraph * pointer = (SgIncidenceDirectedGraph*) ROSE_MALLOC ( SgIncidenceDirectedGraph::pool_size * sizeof(SgIncidenceDirectedGraph) );
   14907           0 :         assert( pointer != NULL );
   14908             : #if ROSE_ALLOC_MEMSET == 1
   14909             :         memset(pointer, 0x00, SgIncidenceDirectedGraph::pool_size * sizeof(SgIncidenceDirectedGraph));
   14910             : #elif ROSE_ALLOC_MEMSET == 2
   14911             :         memset(pointer, 0xCC, SgIncidenceDirectedGraph::pool_size * sizeof(SgIncidenceDirectedGraph));
   14912             : #endif
   14913           0 :         SgIncidenceDirectedGraph::pools.push_back( (unsigned char*)(pointer) );
   14914           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIncidenceDirectedGraph::pool_size * sizeof(SgIncidenceDirectedGraph), V_SgIncidenceDirectedGraph ) );
   14915             : 
   14916           0 :         if ( SgIncidenceDirectedGraph::next_node != NULL ) {
   14917           0 :           if ( blockIndex > 0 ) {
   14918           0 :             SgIncidenceDirectedGraph * blkptr = (SgIncidenceDirectedGraph*)(SgIncidenceDirectedGraph::pools[blockIndex-1]);
   14919           0 :             blkptr[ SgIncidenceDirectedGraph::pool_size - 1 ].set_freepointer(pointer);
   14920             :           }
   14921             :         } else {
   14922           0 :           SgIncidenceDirectedGraph::next_node = pointer;
   14923             :         }
   14924             : 
   14925           0 :         for (unsigned i = 0; i < SgIncidenceDirectedGraph::pool_size-1; ++i)
   14926             :            {
   14927           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   14928             :            }
   14929           0 :         pointer[ SgIncidenceDirectedGraph::pool_size -1 ].set_freepointer(NULL);
   14930             : 
   14931           0 :         blockIndex++;
   14932             :       }
   14933           2 :   }
   14934             : 
   14935             : //############################################################################
   14936             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   14937             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   14938             :  * not compressed. However, that stuff is not yet implemented! 
   14939             :  */
   14940             : unsigned long
   14941           0 : SgIncidenceDirectedGraph::getNumberOfLastValidPointer()
   14942             :    {
   14943           0 :       SgIncidenceDirectedGraph* testPointer = (SgIncidenceDirectedGraph*)(SgIncidenceDirectedGraph::pools.back());
   14944           0 :       unsigned long localIndex = SgIncidenceDirectedGraph::pool_size - 1;
   14945           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   14946             :          {
   14947           0 :            localIndex--;
   14948             :          }
   14949           0 :       return (localIndex + SgIncidenceDirectedGraph::pool_size * (SgIncidenceDirectedGraph::pools.size()-1));
   14950             :    }
   14951             : 
   14952             : //############################################################################
   14953             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   14954             :  * memory pool and initializes the data member in class SgIncidenceDirectedGraphStroageClass
   14955             :  * from its counterpart of SgIncidenceDirectedGraph. The return value is just for checking, 
   14956             :  * that the whole StorageClassArray is initialized!
   14957             :  */
   14958             : unsigned long
   14959           0 : SgIncidenceDirectedGraph::initializeStorageClassArray( SgIncidenceDirectedGraphStorageClass *storageArray )
   14960             :    {
   14961           0 :      unsigned long storageCounter = 0;
   14962           0 :      std::vector < unsigned char* > :: const_iterator block = SgIncidenceDirectedGraph::pools.begin();
   14963           0 :      SgIncidenceDirectedGraph* pointer = NULL;
   14964           0 :      while ( block != SgIncidenceDirectedGraph::pools.end() ) {
   14965           0 :           pointer = (SgIncidenceDirectedGraph*) (*block);
   14966           0 :           for ( unsigned i = 0; i < SgIncidenceDirectedGraph::pool_size; ++i ) {
   14967           0 :                if ( pointer->get_freepointer() != NULL ) {
   14968           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   14969           0 :                  storageArray++;
   14970           0 :                  storageCounter++;
   14971             :                }
   14972           0 :                pointer++;
   14973             :              }
   14974           0 :            block++;
   14975             :         }
   14976           0 :      return storageCounter;
   14977             :    }
   14978             : 
   14979             : /* #line 14980 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   14980             : 
   14981             : 
   14982             : 
   14983             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   14984             : 
   14985             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   14986             : 
   14987             : //############################################################################
   14988             : /* JH (02/02/2006) Constructor of the IR node SgBidirectionalGraph that takes its 
   14989             :  * corresponding StorageClass as parameter
   14990             :  */
   14991           0 : SgBidirectionalGraph :: SgBidirectionalGraph ( const SgBidirectionalGraphStorageClass& storageSource )   : SgIncidenceDirectedGraph (storageSource)
   14992             :    {
   14993             : 
   14994             : 
   14995             : /* #line 14996 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   14996             : 
   14997           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   14998             : 
   14999             : 
   15000             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   15001             : 
   15002             : 
   15003           0 :    }
   15004             : 
   15005             : //############################################################################
   15006             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   15007             :  * within the working AST. 
   15008             :  */
   15009           0 : SgBidirectionalGraph * SgBidirectionalGraph::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   15010           0 :      SgBidirectionalGraph* returnPointer = NULL;
   15011           0 :      if ( globalIndex != 0 )
   15012             :         {
   15013             : 
   15014             : #if FILE_IO_EXTRA_CHECK
   15015           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBidirectionalGraph ) ) <= globalIndex ) ;
   15016           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBidirectionalGraph + 1 ) ) );
   15017             : #endif
   15018           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBidirectionalGraph )  
   15019           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBidirectionalGraph );
   15020           0 :           unsigned long positionInPool = localIndex % SgBidirectionalGraph::pool_size;
   15021           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBidirectionalGraph::pool_size;
   15022             : 
   15023             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   15024             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   15025             : 
   15026           0 :           returnPointer = &( ( (SgBidirectionalGraph*)(SgBidirectionalGraph::pools[memoryBlock]) ) [positionInPool]) ;
   15027             : 
   15028           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   15029             :         }
   15030           0 :      return returnPointer ;
   15031             :    }
   15032             : 
   15033             : //############################################################################
   15034             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   15035             :   for the AST with the index astIndex
   15036             : */
   15037           0 : SgBidirectionalGraph * SgBidirectionalGraph::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   15038           0 :      SgBidirectionalGraph* returnPointer = NULL;
   15039           0 :      if ( globalIndex != 0 )
   15040             :         {
   15041             : 
   15042             : #if FILE_IO_EXTRA_CHECK
   15043           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBidirectionalGraph ) ) <= globalIndex ) ;
   15044           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBidirectionalGraph + 1 ) ) );
   15045             : #endif
   15046           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBidirectionalGraph )
   15047           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBidirectionalGraph );
   15048           0 :           unsigned long positionInPool = localIndex % SgBidirectionalGraph::pool_size ;
   15049           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBidirectionalGraph::pool_size ;
   15050             : 
   15051             : #if FILE_IO_EXTRA_CHECK
   15052             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   15053             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   15054             : #endif
   15055             : 
   15056           0 :           returnPointer = &( ( (SgBidirectionalGraph*)(SgBidirectionalGraph::pools[memoryBlock]) ) [positionInPool]) ;
   15057             : 
   15058             : #if FILE_IO_EXTRA_CHECK
   15059           0 :           assert ( returnPointer != NULL ) ;
   15060             : #endif
   15061             :         }
   15062           0 :      return returnPointer ;
   15063             :    }
   15064             : 
   15065             : //############################################################################
   15066             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   15067             :  * pool size! We set for every valid object in the memory pool the freepointer
   15068             :  * to the global index and increase the global index afterwards. For all the 
   15069             :  * invalid objects (means address ranges within the memory pool that were not
   15070             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   15071             :  * distinguish valid from invalid objects! 
   15072             :  */
   15073             : unsigned long
   15074           5 : SgBidirectionalGraph::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   15075             :    {
   15076           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   15077           5 :      SgBidirectionalGraph* pointer = NULL;
   15078           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   15079           5 :      std::vector < unsigned char* > :: const_iterator block;
   15080           5 :      for ( block = SgBidirectionalGraph::pools.begin(); block != SgBidirectionalGraph::pools.end() ; ++block )
   15081             :         {
   15082           0 :           pointer = (SgBidirectionalGraph*)(*block);
   15083           0 :           for (unsigned i = 0; i < SgBidirectionalGraph::pool_size; ++i )
   15084             :              {
   15085             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   15086             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   15087             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   15088             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   15089             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   15090             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   15091             :             // properly; so this will have to be checked next.
   15092             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   15093             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   15094           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   15095             :                   {
   15096           0 :                     pointer[i].set_freepointer((SgBidirectionalGraph*)(globalIndex));
   15097           0 :                     globalIndex++;
   15098             :                   }
   15099             :                else
   15100             :                   {
   15101           0 :                     pointer[i].set_freepointer(NULL);
   15102             :                   }
   15103             :               }
   15104             :         }
   15105           5 :      return globalIndex;
   15106             :    }
   15107             : 
   15108             : //############################################################################
   15109             : // JH (01/14/2006)
   15110             : void
   15111           5 : SgBidirectionalGraph::resetValidFreepointers( )
   15112             :    {
   15113           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   15114           5 :      SgBidirectionalGraph* pointer = NULL;
   15115           5 :      std::vector < unsigned char* > :: const_iterator block;
   15116           5 :      SgBidirectionalGraph* pointerOfLinkedList = NULL;
   15117           5 :      for ( block = SgBidirectionalGraph::pools.begin(); block != SgBidirectionalGraph::pools.end() ; ++block )
   15118             :         {
   15119           0 :           pointer = (SgBidirectionalGraph*)(*block);
   15120           0 :           for (unsigned i = 0; i < SgBidirectionalGraph::pool_size; ++i )
   15121             :              {
   15122             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   15123             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   15124             :             // memory blocks!.
   15125           0 :                if ( pointer[i].get_freepointer() != NULL )
   15126             :                   {
   15127           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   15128             :                   }
   15129             :                else
   15130             :                   {
   15131           0 :                     if ( pointerOfLinkedList == NULL )
   15132             :                        {
   15133           0 :                          SgBidirectionalGraph::next_node = &(pointer[i]);
   15134             :                        }
   15135             :                     else
   15136             :                        {
   15137             :                       // printf ("In SgBidirectionalGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   15138           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   15139             :                        }
   15140             :                     pointerOfLinkedList = &(pointer[i]);
   15141             :                   }
   15142             :               }
   15143             :         }
   15144             : 
   15145           5 :      if ( pointerOfLinkedList != NULL )
   15146             :         {
   15147             :        // printf ("In SgBidirectionalGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   15148           0 :           pointerOfLinkedList->set_freepointer(NULL);
   15149             :        // DQ (6/6/2010): Temporary debugging...
   15150             :        //   ROSE_ASSERT(false);
   15151             :         }
   15152             : 
   15153           5 :      return ;
   15154             :    }
   15155             : 
   15156             : //############################################################################
   15157             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   15158             :  * within the memory pool and resets the freepointers, in order to achieve a 
   15159             :  * linked list, that has no jumps and starts at the beginning! This function 
   15160             :  * does not extend the memory pool, since we do not delete any memory blocks,
   15161             :  * but delete the valid objects.  
   15162             :  */
   15163             : void
   15164           0 : SgBidirectionalGraph::clearMemoryPool( )
   15165             :    {
   15166             :   // printf ("Inside of SgBidirectionalGraph::clearMemoryPool() \n");
   15167             : 
   15168           0 :      SgBidirectionalGraph* pointer = NULL, *tempPointer = NULL;
   15169           0 :      std::vector < unsigned char* > :: const_iterator block;
   15170           0 :      if ( SgBidirectionalGraph::pools.empty() == false )
   15171             :         {
   15172           0 :           block = SgBidirectionalGraph::pools.begin() ;
   15173           0 :           SgBidirectionalGraph::next_node = (SgBidirectionalGraph*) (*block);
   15174             : 
   15175           0 :           while ( block != SgBidirectionalGraph::pools.end() )
   15176             :              {
   15177           0 :                pointer = (SgBidirectionalGraph*) (*block);
   15178           0 :                if ( tempPointer != NULL )
   15179             :                   {
   15180           0 :                     tempPointer->set_freepointer(pointer);
   15181             :                   }
   15182           0 :                for (unsigned i = 0; i < SgBidirectionalGraph::pool_size - 1; ++i)
   15183             :                   {
   15184           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   15185             :                   }
   15186           0 :                 pointer[SgBidirectionalGraph::pool_size-1].set_freepointer(NULL);
   15187           0 :                 tempPointer = &(pointer[SgBidirectionalGraph::pool_size-1]);
   15188           0 :                 ++block;
   15189             :              }
   15190             :         }
   15191           0 :    }
   15192             : 
   15193           5 : void SgBidirectionalGraph::deleteMemoryPool() {
   15194           5 :   for (auto p: SgBidirectionalGraph::pools) {
   15195           0 :     ROSE_FREE(p);
   15196             :   }
   15197           5 :   SgBidirectionalGraph::next_node = nullptr;
   15198           5 :   SgBidirectionalGraph::pools.clear();
   15199           5 : }
   15200             : 
   15201             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   15202             : //                 reading multiple binary files to for a single AST.
   15203             : /////////// new version ////////////////////////////////
   15204             : //############################################################################
   15205             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   15206             : void
   15207           2 : SgBidirectionalGraph::extendMemoryPoolForFileIO( )
   15208             :   {
   15209           2 :     size_t blockIndex = SgBidirectionalGraph::pools.size();
   15210           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBidirectionalGraph) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBidirectionalGraph);
   15211             : 
   15212           2 :     while ( (blockIndex * SgBidirectionalGraph::pool_size) < newPoolSize)
   15213             :       {
   15214             : #if ROSE_ALLOC_TRACE
   15215             :         if (blockIndex > 0) {
   15216             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBidirectionalGraph) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBidirectionalGraph) = %" PRIuPTR " SgBidirectionalGraph::pool_size = %d \n",
   15217             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBidirectionalGraph),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBidirectionalGraph),SgBidirectionalGraph::pool_size);
   15218             :         }
   15219             : #endif
   15220             : 
   15221           0 :         SgBidirectionalGraph * pointer = (SgBidirectionalGraph*) ROSE_MALLOC ( SgBidirectionalGraph::pool_size * sizeof(SgBidirectionalGraph) );
   15222           0 :         assert( pointer != NULL );
   15223             : #if ROSE_ALLOC_MEMSET == 1
   15224             :         memset(pointer, 0x00, SgBidirectionalGraph::pool_size * sizeof(SgBidirectionalGraph));
   15225             : #elif ROSE_ALLOC_MEMSET == 2
   15226             :         memset(pointer, 0xCC, SgBidirectionalGraph::pool_size * sizeof(SgBidirectionalGraph));
   15227             : #endif
   15228           0 :         SgBidirectionalGraph::pools.push_back( (unsigned char*)(pointer) );
   15229           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBidirectionalGraph::pool_size * sizeof(SgBidirectionalGraph), V_SgBidirectionalGraph ) );
   15230             : 
   15231           0 :         if ( SgBidirectionalGraph::next_node != NULL ) {
   15232           0 :           if ( blockIndex > 0 ) {
   15233           0 :             SgBidirectionalGraph * blkptr = (SgBidirectionalGraph*)(SgBidirectionalGraph::pools[blockIndex-1]);
   15234           0 :             blkptr[ SgBidirectionalGraph::pool_size - 1 ].set_freepointer(pointer);
   15235             :           }
   15236             :         } else {
   15237           0 :           SgBidirectionalGraph::next_node = pointer;
   15238             :         }
   15239             : 
   15240           0 :         for (unsigned i = 0; i < SgBidirectionalGraph::pool_size-1; ++i)
   15241             :            {
   15242           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   15243             :            }
   15244           0 :         pointer[ SgBidirectionalGraph::pool_size -1 ].set_freepointer(NULL);
   15245             : 
   15246           0 :         blockIndex++;
   15247             :       }
   15248           2 :   }
   15249             : 
   15250             : //############################################################################
   15251             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   15252             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   15253             :  * not compressed. However, that stuff is not yet implemented! 
   15254             :  */
   15255             : unsigned long
   15256           0 : SgBidirectionalGraph::getNumberOfLastValidPointer()
   15257             :    {
   15258           0 :       SgBidirectionalGraph* testPointer = (SgBidirectionalGraph*)(SgBidirectionalGraph::pools.back());
   15259           0 :       unsigned long localIndex = SgBidirectionalGraph::pool_size - 1;
   15260           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   15261             :          {
   15262           0 :            localIndex--;
   15263             :          }
   15264           0 :       return (localIndex + SgBidirectionalGraph::pool_size * (SgBidirectionalGraph::pools.size()-1));
   15265             :    }
   15266             : 
   15267             : //############################################################################
   15268             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   15269             :  * memory pool and initializes the data member in class SgBidirectionalGraphStroageClass
   15270             :  * from its counterpart of SgBidirectionalGraph. The return value is just for checking, 
   15271             :  * that the whole StorageClassArray is initialized!
   15272             :  */
   15273             : unsigned long
   15274           0 : SgBidirectionalGraph::initializeStorageClassArray( SgBidirectionalGraphStorageClass *storageArray )
   15275             :    {
   15276           0 :      unsigned long storageCounter = 0;
   15277           0 :      std::vector < unsigned char* > :: const_iterator block = SgBidirectionalGraph::pools.begin();
   15278           0 :      SgBidirectionalGraph* pointer = NULL;
   15279           0 :      while ( block != SgBidirectionalGraph::pools.end() ) {
   15280           0 :           pointer = (SgBidirectionalGraph*) (*block);
   15281           0 :           for ( unsigned i = 0; i < SgBidirectionalGraph::pool_size; ++i ) {
   15282           0 :                if ( pointer->get_freepointer() != NULL ) {
   15283           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   15284           0 :                  storageArray++;
   15285           0 :                  storageCounter++;
   15286             :                }
   15287           0 :                pointer++;
   15288             :              }
   15289           0 :            block++;
   15290             :         }
   15291           0 :      return storageCounter;
   15292             :    }
   15293             : 
   15294             : /* #line 15295 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   15295             : 
   15296             : 
   15297             : 
   15298             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   15299             : 
   15300             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   15301             : 
   15302             : //############################################################################
   15303             : /* JH (02/02/2006) Constructor of the IR node SgStringKeyedBidirectionalGraph that takes its 
   15304             :  * corresponding StorageClass as parameter
   15305             :  */
   15306           0 : SgStringKeyedBidirectionalGraph :: SgStringKeyedBidirectionalGraph ( const SgStringKeyedBidirectionalGraphStorageClass& storageSource )   : SgBidirectionalGraph (storageSource)
   15307             :    {
   15308             : 
   15309             : 
   15310             : /* #line 15311 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   15311             : 
   15312           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   15313             : 
   15314             : 
   15315             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   15316             : 
   15317             : 
   15318           0 :    }
   15319             : 
   15320             : //############################################################################
   15321             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   15322             :  * within the working AST. 
   15323             :  */
   15324           0 : SgStringKeyedBidirectionalGraph * SgStringKeyedBidirectionalGraph::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   15325           0 :      SgStringKeyedBidirectionalGraph* returnPointer = NULL;
   15326           0 :      if ( globalIndex != 0 )
   15327             :         {
   15328             : 
   15329             : #if FILE_IO_EXTRA_CHECK
   15330           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStringKeyedBidirectionalGraph ) ) <= globalIndex ) ;
   15331           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStringKeyedBidirectionalGraph + 1 ) ) );
   15332             : #endif
   15333           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStringKeyedBidirectionalGraph )  
   15334           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStringKeyedBidirectionalGraph );
   15335           0 :           unsigned long positionInPool = localIndex % SgStringKeyedBidirectionalGraph::pool_size;
   15336           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStringKeyedBidirectionalGraph::pool_size;
   15337             : 
   15338             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   15339             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   15340             : 
   15341           0 :           returnPointer = &( ( (SgStringKeyedBidirectionalGraph*)(SgStringKeyedBidirectionalGraph::pools[memoryBlock]) ) [positionInPool]) ;
   15342             : 
   15343           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   15344             :         }
   15345           0 :      return returnPointer ;
   15346             :    }
   15347             : 
   15348             : //############################################################################
   15349             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   15350             :   for the AST with the index astIndex
   15351             : */
   15352           0 : SgStringKeyedBidirectionalGraph * SgStringKeyedBidirectionalGraph::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   15353           0 :      SgStringKeyedBidirectionalGraph* returnPointer = NULL;
   15354           0 :      if ( globalIndex != 0 )
   15355             :         {
   15356             : 
   15357             : #if FILE_IO_EXTRA_CHECK
   15358           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStringKeyedBidirectionalGraph ) ) <= globalIndex ) ;
   15359           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStringKeyedBidirectionalGraph + 1 ) ) );
   15360             : #endif
   15361           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStringKeyedBidirectionalGraph )
   15362           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStringKeyedBidirectionalGraph );
   15363           0 :           unsigned long positionInPool = localIndex % SgStringKeyedBidirectionalGraph::pool_size ;
   15364           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStringKeyedBidirectionalGraph::pool_size ;
   15365             : 
   15366             : #if FILE_IO_EXTRA_CHECK
   15367             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   15368             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   15369             : #endif
   15370             : 
   15371           0 :           returnPointer = &( ( (SgStringKeyedBidirectionalGraph*)(SgStringKeyedBidirectionalGraph::pools[memoryBlock]) ) [positionInPool]) ;
   15372             : 
   15373             : #if FILE_IO_EXTRA_CHECK
   15374           0 :           assert ( returnPointer != NULL ) ;
   15375             : #endif
   15376             :         }
   15377           0 :      return returnPointer ;
   15378             :    }
   15379             : 
   15380             : //############################################################################
   15381             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   15382             :  * pool size! We set for every valid object in the memory pool the freepointer
   15383             :  * to the global index and increase the global index afterwards. For all the 
   15384             :  * invalid objects (means address ranges within the memory pool that were not
   15385             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   15386             :  * distinguish valid from invalid objects! 
   15387             :  */
   15388             : unsigned long
   15389           5 : SgStringKeyedBidirectionalGraph::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   15390             :    {
   15391           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   15392           5 :      SgStringKeyedBidirectionalGraph* pointer = NULL;
   15393           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   15394           5 :      std::vector < unsigned char* > :: const_iterator block;
   15395           5 :      for ( block = SgStringKeyedBidirectionalGraph::pools.begin(); block != SgStringKeyedBidirectionalGraph::pools.end() ; ++block )
   15396             :         {
   15397           0 :           pointer = (SgStringKeyedBidirectionalGraph*)(*block);
   15398           0 :           for (unsigned i = 0; i < SgStringKeyedBidirectionalGraph::pool_size; ++i )
   15399             :              {
   15400             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   15401             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   15402             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   15403             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   15404             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   15405             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   15406             :             // properly; so this will have to be checked next.
   15407             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   15408             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   15409           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   15410             :                   {
   15411           0 :                     pointer[i].set_freepointer((SgStringKeyedBidirectionalGraph*)(globalIndex));
   15412           0 :                     globalIndex++;
   15413             :                   }
   15414             :                else
   15415             :                   {
   15416           0 :                     pointer[i].set_freepointer(NULL);
   15417             :                   }
   15418             :               }
   15419             :         }
   15420           5 :      return globalIndex;
   15421             :    }
   15422             : 
   15423             : //############################################################################
   15424             : // JH (01/14/2006)
   15425             : void
   15426           5 : SgStringKeyedBidirectionalGraph::resetValidFreepointers( )
   15427             :    {
   15428           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   15429           5 :      SgStringKeyedBidirectionalGraph* pointer = NULL;
   15430           5 :      std::vector < unsigned char* > :: const_iterator block;
   15431           5 :      SgStringKeyedBidirectionalGraph* pointerOfLinkedList = NULL;
   15432           5 :      for ( block = SgStringKeyedBidirectionalGraph::pools.begin(); block != SgStringKeyedBidirectionalGraph::pools.end() ; ++block )
   15433             :         {
   15434           0 :           pointer = (SgStringKeyedBidirectionalGraph*)(*block);
   15435           0 :           for (unsigned i = 0; i < SgStringKeyedBidirectionalGraph::pool_size; ++i )
   15436             :              {
   15437             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   15438             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   15439             :             // memory blocks!.
   15440           0 :                if ( pointer[i].get_freepointer() != NULL )
   15441             :                   {
   15442           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   15443             :                   }
   15444             :                else
   15445             :                   {
   15446           0 :                     if ( pointerOfLinkedList == NULL )
   15447             :                        {
   15448           0 :                          SgStringKeyedBidirectionalGraph::next_node = &(pointer[i]);
   15449             :                        }
   15450             :                     else
   15451             :                        {
   15452             :                       // printf ("In SgStringKeyedBidirectionalGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   15453           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   15454             :                        }
   15455             :                     pointerOfLinkedList = &(pointer[i]);
   15456             :                   }
   15457             :               }
   15458             :         }
   15459             : 
   15460           5 :      if ( pointerOfLinkedList != NULL )
   15461             :         {
   15462             :        // printf ("In SgStringKeyedBidirectionalGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   15463           0 :           pointerOfLinkedList->set_freepointer(NULL);
   15464             :        // DQ (6/6/2010): Temporary debugging...
   15465             :        //   ROSE_ASSERT(false);
   15466             :         }
   15467             : 
   15468           5 :      return ;
   15469             :    }
   15470             : 
   15471             : //############################################################################
   15472             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   15473             :  * within the memory pool and resets the freepointers, in order to achieve a 
   15474             :  * linked list, that has no jumps and starts at the beginning! This function 
   15475             :  * does not extend the memory pool, since we do not delete any memory blocks,
   15476             :  * but delete the valid objects.  
   15477             :  */
   15478             : void
   15479           0 : SgStringKeyedBidirectionalGraph::clearMemoryPool( )
   15480             :    {
   15481             :   // printf ("Inside of SgStringKeyedBidirectionalGraph::clearMemoryPool() \n");
   15482             : 
   15483           0 :      SgStringKeyedBidirectionalGraph* pointer = NULL, *tempPointer = NULL;
   15484           0 :      std::vector < unsigned char* > :: const_iterator block;
   15485           0 :      if ( SgStringKeyedBidirectionalGraph::pools.empty() == false )
   15486             :         {
   15487           0 :           block = SgStringKeyedBidirectionalGraph::pools.begin() ;
   15488           0 :           SgStringKeyedBidirectionalGraph::next_node = (SgStringKeyedBidirectionalGraph*) (*block);
   15489             : 
   15490           0 :           while ( block != SgStringKeyedBidirectionalGraph::pools.end() )
   15491             :              {
   15492           0 :                pointer = (SgStringKeyedBidirectionalGraph*) (*block);
   15493           0 :                if ( tempPointer != NULL )
   15494             :                   {
   15495           0 :                     tempPointer->set_freepointer(pointer);
   15496             :                   }
   15497           0 :                for (unsigned i = 0; i < SgStringKeyedBidirectionalGraph::pool_size - 1; ++i)
   15498             :                   {
   15499           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   15500             :                   }
   15501           0 :                 pointer[SgStringKeyedBidirectionalGraph::pool_size-1].set_freepointer(NULL);
   15502           0 :                 tempPointer = &(pointer[SgStringKeyedBidirectionalGraph::pool_size-1]);
   15503           0 :                 ++block;
   15504             :              }
   15505             :         }
   15506           0 :    }
   15507             : 
   15508           5 : void SgStringKeyedBidirectionalGraph::deleteMemoryPool() {
   15509           5 :   for (auto p: SgStringKeyedBidirectionalGraph::pools) {
   15510           0 :     ROSE_FREE(p);
   15511             :   }
   15512           5 :   SgStringKeyedBidirectionalGraph::next_node = nullptr;
   15513           5 :   SgStringKeyedBidirectionalGraph::pools.clear();
   15514           5 : }
   15515             : 
   15516             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   15517             : //                 reading multiple binary files to for a single AST.
   15518             : /////////// new version ////////////////////////////////
   15519             : //############################################################################
   15520             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   15521             : void
   15522           2 : SgStringKeyedBidirectionalGraph::extendMemoryPoolForFileIO( )
   15523             :   {
   15524           2 :     size_t blockIndex = SgStringKeyedBidirectionalGraph::pools.size();
   15525           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStringKeyedBidirectionalGraph) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringKeyedBidirectionalGraph);
   15526             : 
   15527           2 :     while ( (blockIndex * SgStringKeyedBidirectionalGraph::pool_size) < newPoolSize)
   15528             :       {
   15529             : #if ROSE_ALLOC_TRACE
   15530             :         if (blockIndex > 0) {
   15531             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStringKeyedBidirectionalGraph) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringKeyedBidirectionalGraph) = %" PRIuPTR " SgStringKeyedBidirectionalGraph::pool_size = %d \n",
   15532             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStringKeyedBidirectionalGraph),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringKeyedBidirectionalGraph),SgStringKeyedBidirectionalGraph::pool_size);
   15533             :         }
   15534             : #endif
   15535             : 
   15536           0 :         SgStringKeyedBidirectionalGraph * pointer = (SgStringKeyedBidirectionalGraph*) ROSE_MALLOC ( SgStringKeyedBidirectionalGraph::pool_size * sizeof(SgStringKeyedBidirectionalGraph) );
   15537           0 :         assert( pointer != NULL );
   15538             : #if ROSE_ALLOC_MEMSET == 1
   15539             :         memset(pointer, 0x00, SgStringKeyedBidirectionalGraph::pool_size * sizeof(SgStringKeyedBidirectionalGraph));
   15540             : #elif ROSE_ALLOC_MEMSET == 2
   15541             :         memset(pointer, 0xCC, SgStringKeyedBidirectionalGraph::pool_size * sizeof(SgStringKeyedBidirectionalGraph));
   15542             : #endif
   15543           0 :         SgStringKeyedBidirectionalGraph::pools.push_back( (unsigned char*)(pointer) );
   15544           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStringKeyedBidirectionalGraph::pool_size * sizeof(SgStringKeyedBidirectionalGraph), V_SgStringKeyedBidirectionalGraph ) );
   15545             : 
   15546           0 :         if ( SgStringKeyedBidirectionalGraph::next_node != NULL ) {
   15547           0 :           if ( blockIndex > 0 ) {
   15548           0 :             SgStringKeyedBidirectionalGraph * blkptr = (SgStringKeyedBidirectionalGraph*)(SgStringKeyedBidirectionalGraph::pools[blockIndex-1]);
   15549           0 :             blkptr[ SgStringKeyedBidirectionalGraph::pool_size - 1 ].set_freepointer(pointer);
   15550             :           }
   15551             :         } else {
   15552           0 :           SgStringKeyedBidirectionalGraph::next_node = pointer;
   15553             :         }
   15554             : 
   15555           0 :         for (unsigned i = 0; i < SgStringKeyedBidirectionalGraph::pool_size-1; ++i)
   15556             :            {
   15557           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   15558             :            }
   15559           0 :         pointer[ SgStringKeyedBidirectionalGraph::pool_size -1 ].set_freepointer(NULL);
   15560             : 
   15561           0 :         blockIndex++;
   15562             :       }
   15563           2 :   }
   15564             : 
   15565             : //############################################################################
   15566             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   15567             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   15568             :  * not compressed. However, that stuff is not yet implemented! 
   15569             :  */
   15570             : unsigned long
   15571           0 : SgStringKeyedBidirectionalGraph::getNumberOfLastValidPointer()
   15572             :    {
   15573           0 :       SgStringKeyedBidirectionalGraph* testPointer = (SgStringKeyedBidirectionalGraph*)(SgStringKeyedBidirectionalGraph::pools.back());
   15574           0 :       unsigned long localIndex = SgStringKeyedBidirectionalGraph::pool_size - 1;
   15575           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   15576             :          {
   15577           0 :            localIndex--;
   15578             :          }
   15579           0 :       return (localIndex + SgStringKeyedBidirectionalGraph::pool_size * (SgStringKeyedBidirectionalGraph::pools.size()-1));
   15580             :    }
   15581             : 
   15582             : //############################################################################
   15583             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   15584             :  * memory pool and initializes the data member in class SgStringKeyedBidirectionalGraphStroageClass
   15585             :  * from its counterpart of SgStringKeyedBidirectionalGraph. The return value is just for checking, 
   15586             :  * that the whole StorageClassArray is initialized!
   15587             :  */
   15588             : unsigned long
   15589           0 : SgStringKeyedBidirectionalGraph::initializeStorageClassArray( SgStringKeyedBidirectionalGraphStorageClass *storageArray )
   15590             :    {
   15591           0 :      unsigned long storageCounter = 0;
   15592           0 :      std::vector < unsigned char* > :: const_iterator block = SgStringKeyedBidirectionalGraph::pools.begin();
   15593           0 :      SgStringKeyedBidirectionalGraph* pointer = NULL;
   15594           0 :      while ( block != SgStringKeyedBidirectionalGraph::pools.end() ) {
   15595           0 :           pointer = (SgStringKeyedBidirectionalGraph*) (*block);
   15596           0 :           for ( unsigned i = 0; i < SgStringKeyedBidirectionalGraph::pool_size; ++i ) {
   15597           0 :                if ( pointer->get_freepointer() != NULL ) {
   15598           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   15599           0 :                  storageArray++;
   15600           0 :                  storageCounter++;
   15601             :                }
   15602           0 :                pointer++;
   15603             :              }
   15604           0 :            block++;
   15605             :         }
   15606           0 :      return storageCounter;
   15607             :    }
   15608             : 
   15609             : /* #line 15610 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   15610             : 
   15611             : 
   15612             : 
   15613             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   15614             : 
   15615             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   15616             : 
   15617             : //############################################################################
   15618             : /* JH (02/02/2006) Constructor of the IR node SgIntKeyedBidirectionalGraph that takes its 
   15619             :  * corresponding StorageClass as parameter
   15620             :  */
   15621           0 : SgIntKeyedBidirectionalGraph :: SgIntKeyedBidirectionalGraph ( const SgIntKeyedBidirectionalGraphStorageClass& storageSource )   : SgBidirectionalGraph (storageSource)
   15622             :    {
   15623             : 
   15624             : 
   15625             : /* #line 15626 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   15626             : 
   15627           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   15628             : 
   15629             : 
   15630             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   15631             : 
   15632             : 
   15633           0 :    }
   15634             : 
   15635             : //############################################################################
   15636             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   15637             :  * within the working AST. 
   15638             :  */
   15639           0 : SgIntKeyedBidirectionalGraph * SgIntKeyedBidirectionalGraph::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   15640           0 :      SgIntKeyedBidirectionalGraph* returnPointer = NULL;
   15641           0 :      if ( globalIndex != 0 )
   15642             :         {
   15643             : 
   15644             : #if FILE_IO_EXTRA_CHECK
   15645           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIntKeyedBidirectionalGraph ) ) <= globalIndex ) ;
   15646           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntKeyedBidirectionalGraph + 1 ) ) );
   15647             : #endif
   15648           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntKeyedBidirectionalGraph )  
   15649           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIntKeyedBidirectionalGraph );
   15650           0 :           unsigned long positionInPool = localIndex % SgIntKeyedBidirectionalGraph::pool_size;
   15651           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntKeyedBidirectionalGraph::pool_size;
   15652             : 
   15653             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   15654             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   15655             : 
   15656           0 :           returnPointer = &( ( (SgIntKeyedBidirectionalGraph*)(SgIntKeyedBidirectionalGraph::pools[memoryBlock]) ) [positionInPool]) ;
   15657             : 
   15658           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   15659             :         }
   15660           0 :      return returnPointer ;
   15661             :    }
   15662             : 
   15663             : //############################################################################
   15664             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   15665             :   for the AST with the index astIndex
   15666             : */
   15667           0 : SgIntKeyedBidirectionalGraph * SgIntKeyedBidirectionalGraph::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   15668           0 :      SgIntKeyedBidirectionalGraph* returnPointer = NULL;
   15669           0 :      if ( globalIndex != 0 )
   15670             :         {
   15671             : 
   15672             : #if FILE_IO_EXTRA_CHECK
   15673           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIntKeyedBidirectionalGraph ) ) <= globalIndex ) ;
   15674           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntKeyedBidirectionalGraph + 1 ) ) );
   15675             : #endif
   15676           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntKeyedBidirectionalGraph )
   15677           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIntKeyedBidirectionalGraph );
   15678           0 :           unsigned long positionInPool = localIndex % SgIntKeyedBidirectionalGraph::pool_size ;
   15679           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntKeyedBidirectionalGraph::pool_size ;
   15680             : 
   15681             : #if FILE_IO_EXTRA_CHECK
   15682             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   15683             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   15684             : #endif
   15685             : 
   15686           0 :           returnPointer = &( ( (SgIntKeyedBidirectionalGraph*)(SgIntKeyedBidirectionalGraph::pools[memoryBlock]) ) [positionInPool]) ;
   15687             : 
   15688             : #if FILE_IO_EXTRA_CHECK
   15689           0 :           assert ( returnPointer != NULL ) ;
   15690             : #endif
   15691             :         }
   15692           0 :      return returnPointer ;
   15693             :    }
   15694             : 
   15695             : //############################################################################
   15696             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   15697             :  * pool size! We set for every valid object in the memory pool the freepointer
   15698             :  * to the global index and increase the global index afterwards. For all the 
   15699             :  * invalid objects (means address ranges within the memory pool that were not
   15700             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   15701             :  * distinguish valid from invalid objects! 
   15702             :  */
   15703             : unsigned long
   15704           5 : SgIntKeyedBidirectionalGraph::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   15705             :    {
   15706           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   15707           5 :      SgIntKeyedBidirectionalGraph* pointer = NULL;
   15708           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   15709           5 :      std::vector < unsigned char* > :: const_iterator block;
   15710           5 :      for ( block = SgIntKeyedBidirectionalGraph::pools.begin(); block != SgIntKeyedBidirectionalGraph::pools.end() ; ++block )
   15711             :         {
   15712           0 :           pointer = (SgIntKeyedBidirectionalGraph*)(*block);
   15713           0 :           for (unsigned i = 0; i < SgIntKeyedBidirectionalGraph::pool_size; ++i )
   15714             :              {
   15715             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   15716             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   15717             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   15718             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   15719             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   15720             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   15721             :             // properly; so this will have to be checked next.
   15722             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   15723             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   15724           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   15725             :                   {
   15726           0 :                     pointer[i].set_freepointer((SgIntKeyedBidirectionalGraph*)(globalIndex));
   15727           0 :                     globalIndex++;
   15728             :                   }
   15729             :                else
   15730             :                   {
   15731           0 :                     pointer[i].set_freepointer(NULL);
   15732             :                   }
   15733             :               }
   15734             :         }
   15735           5 :      return globalIndex;
   15736             :    }
   15737             : 
   15738             : //############################################################################
   15739             : // JH (01/14/2006)
   15740             : void
   15741           5 : SgIntKeyedBidirectionalGraph::resetValidFreepointers( )
   15742             :    {
   15743           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   15744           5 :      SgIntKeyedBidirectionalGraph* pointer = NULL;
   15745           5 :      std::vector < unsigned char* > :: const_iterator block;
   15746           5 :      SgIntKeyedBidirectionalGraph* pointerOfLinkedList = NULL;
   15747           5 :      for ( block = SgIntKeyedBidirectionalGraph::pools.begin(); block != SgIntKeyedBidirectionalGraph::pools.end() ; ++block )
   15748             :         {
   15749           0 :           pointer = (SgIntKeyedBidirectionalGraph*)(*block);
   15750           0 :           for (unsigned i = 0; i < SgIntKeyedBidirectionalGraph::pool_size; ++i )
   15751             :              {
   15752             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   15753             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   15754             :             // memory blocks!.
   15755           0 :                if ( pointer[i].get_freepointer() != NULL )
   15756             :                   {
   15757           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   15758             :                   }
   15759             :                else
   15760             :                   {
   15761           0 :                     if ( pointerOfLinkedList == NULL )
   15762             :                        {
   15763           0 :                          SgIntKeyedBidirectionalGraph::next_node = &(pointer[i]);
   15764             :                        }
   15765             :                     else
   15766             :                        {
   15767             :                       // printf ("In SgIntKeyedBidirectionalGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   15768           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   15769             :                        }
   15770             :                     pointerOfLinkedList = &(pointer[i]);
   15771             :                   }
   15772             :               }
   15773             :         }
   15774             : 
   15775           5 :      if ( pointerOfLinkedList != NULL )
   15776             :         {
   15777             :        // printf ("In SgIntKeyedBidirectionalGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   15778           0 :           pointerOfLinkedList->set_freepointer(NULL);
   15779             :        // DQ (6/6/2010): Temporary debugging...
   15780             :        //   ROSE_ASSERT(false);
   15781             :         }
   15782             : 
   15783           5 :      return ;
   15784             :    }
   15785             : 
   15786             : //############################################################################
   15787             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   15788             :  * within the memory pool and resets the freepointers, in order to achieve a 
   15789             :  * linked list, that has no jumps and starts at the beginning! This function 
   15790             :  * does not extend the memory pool, since we do not delete any memory blocks,
   15791             :  * but delete the valid objects.  
   15792             :  */
   15793             : void
   15794           0 : SgIntKeyedBidirectionalGraph::clearMemoryPool( )
   15795             :    {
   15796             :   // printf ("Inside of SgIntKeyedBidirectionalGraph::clearMemoryPool() \n");
   15797             : 
   15798           0 :      SgIntKeyedBidirectionalGraph* pointer = NULL, *tempPointer = NULL;
   15799           0 :      std::vector < unsigned char* > :: const_iterator block;
   15800           0 :      if ( SgIntKeyedBidirectionalGraph::pools.empty() == false )
   15801             :         {
   15802           0 :           block = SgIntKeyedBidirectionalGraph::pools.begin() ;
   15803           0 :           SgIntKeyedBidirectionalGraph::next_node = (SgIntKeyedBidirectionalGraph*) (*block);
   15804             : 
   15805           0 :           while ( block != SgIntKeyedBidirectionalGraph::pools.end() )
   15806             :              {
   15807           0 :                pointer = (SgIntKeyedBidirectionalGraph*) (*block);
   15808           0 :                if ( tempPointer != NULL )
   15809             :                   {
   15810           0 :                     tempPointer->set_freepointer(pointer);
   15811             :                   }
   15812           0 :                for (unsigned i = 0; i < SgIntKeyedBidirectionalGraph::pool_size - 1; ++i)
   15813             :                   {
   15814           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   15815             :                   }
   15816           0 :                 pointer[SgIntKeyedBidirectionalGraph::pool_size-1].set_freepointer(NULL);
   15817           0 :                 tempPointer = &(pointer[SgIntKeyedBidirectionalGraph::pool_size-1]);
   15818           0 :                 ++block;
   15819             :              }
   15820             :         }
   15821           0 :    }
   15822             : 
   15823           5 : void SgIntKeyedBidirectionalGraph::deleteMemoryPool() {
   15824           5 :   for (auto p: SgIntKeyedBidirectionalGraph::pools) {
   15825           0 :     ROSE_FREE(p);
   15826             :   }
   15827           5 :   SgIntKeyedBidirectionalGraph::next_node = nullptr;
   15828           5 :   SgIntKeyedBidirectionalGraph::pools.clear();
   15829           5 : }
   15830             : 
   15831             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   15832             : //                 reading multiple binary files to for a single AST.
   15833             : /////////// new version ////////////////////////////////
   15834             : //############################################################################
   15835             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   15836             : void
   15837           2 : SgIntKeyedBidirectionalGraph::extendMemoryPoolForFileIO( )
   15838             :   {
   15839           2 :     size_t blockIndex = SgIntKeyedBidirectionalGraph::pools.size();
   15840           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIntKeyedBidirectionalGraph) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntKeyedBidirectionalGraph);
   15841             : 
   15842           2 :     while ( (blockIndex * SgIntKeyedBidirectionalGraph::pool_size) < newPoolSize)
   15843             :       {
   15844             : #if ROSE_ALLOC_TRACE
   15845             :         if (blockIndex > 0) {
   15846             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIntKeyedBidirectionalGraph) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntKeyedBidirectionalGraph) = %" PRIuPTR " SgIntKeyedBidirectionalGraph::pool_size = %d \n",
   15847             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIntKeyedBidirectionalGraph),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntKeyedBidirectionalGraph),SgIntKeyedBidirectionalGraph::pool_size);
   15848             :         }
   15849             : #endif
   15850             : 
   15851           0 :         SgIntKeyedBidirectionalGraph * pointer = (SgIntKeyedBidirectionalGraph*) ROSE_MALLOC ( SgIntKeyedBidirectionalGraph::pool_size * sizeof(SgIntKeyedBidirectionalGraph) );
   15852           0 :         assert( pointer != NULL );
   15853             : #if ROSE_ALLOC_MEMSET == 1
   15854             :         memset(pointer, 0x00, SgIntKeyedBidirectionalGraph::pool_size * sizeof(SgIntKeyedBidirectionalGraph));
   15855             : #elif ROSE_ALLOC_MEMSET == 2
   15856             :         memset(pointer, 0xCC, SgIntKeyedBidirectionalGraph::pool_size * sizeof(SgIntKeyedBidirectionalGraph));
   15857             : #endif
   15858           0 :         SgIntKeyedBidirectionalGraph::pools.push_back( (unsigned char*)(pointer) );
   15859           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIntKeyedBidirectionalGraph::pool_size * sizeof(SgIntKeyedBidirectionalGraph), V_SgIntKeyedBidirectionalGraph ) );
   15860             : 
   15861           0 :         if ( SgIntKeyedBidirectionalGraph::next_node != NULL ) {
   15862           0 :           if ( blockIndex > 0 ) {
   15863           0 :             SgIntKeyedBidirectionalGraph * blkptr = (SgIntKeyedBidirectionalGraph*)(SgIntKeyedBidirectionalGraph::pools[blockIndex-1]);
   15864           0 :             blkptr[ SgIntKeyedBidirectionalGraph::pool_size - 1 ].set_freepointer(pointer);
   15865             :           }
   15866             :         } else {
   15867           0 :           SgIntKeyedBidirectionalGraph::next_node = pointer;
   15868             :         }
   15869             : 
   15870           0 :         for (unsigned i = 0; i < SgIntKeyedBidirectionalGraph::pool_size-1; ++i)
   15871             :            {
   15872           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   15873             :            }
   15874           0 :         pointer[ SgIntKeyedBidirectionalGraph::pool_size -1 ].set_freepointer(NULL);
   15875             : 
   15876           0 :         blockIndex++;
   15877             :       }
   15878           2 :   }
   15879             : 
   15880             : //############################################################################
   15881             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   15882             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   15883             :  * not compressed. However, that stuff is not yet implemented! 
   15884             :  */
   15885             : unsigned long
   15886           0 : SgIntKeyedBidirectionalGraph::getNumberOfLastValidPointer()
   15887             :    {
   15888           0 :       SgIntKeyedBidirectionalGraph* testPointer = (SgIntKeyedBidirectionalGraph*)(SgIntKeyedBidirectionalGraph::pools.back());
   15889           0 :       unsigned long localIndex = SgIntKeyedBidirectionalGraph::pool_size - 1;
   15890           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   15891             :          {
   15892           0 :            localIndex--;
   15893             :          }
   15894           0 :       return (localIndex + SgIntKeyedBidirectionalGraph::pool_size * (SgIntKeyedBidirectionalGraph::pools.size()-1));
   15895             :    }
   15896             : 
   15897             : //############################################################################
   15898             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   15899             :  * memory pool and initializes the data member in class SgIntKeyedBidirectionalGraphStroageClass
   15900             :  * from its counterpart of SgIntKeyedBidirectionalGraph. The return value is just for checking, 
   15901             :  * that the whole StorageClassArray is initialized!
   15902             :  */
   15903             : unsigned long
   15904           0 : SgIntKeyedBidirectionalGraph::initializeStorageClassArray( SgIntKeyedBidirectionalGraphStorageClass *storageArray )
   15905             :    {
   15906           0 :      unsigned long storageCounter = 0;
   15907           0 :      std::vector < unsigned char* > :: const_iterator block = SgIntKeyedBidirectionalGraph::pools.begin();
   15908           0 :      SgIntKeyedBidirectionalGraph* pointer = NULL;
   15909           0 :      while ( block != SgIntKeyedBidirectionalGraph::pools.end() ) {
   15910           0 :           pointer = (SgIntKeyedBidirectionalGraph*) (*block);
   15911           0 :           for ( unsigned i = 0; i < SgIntKeyedBidirectionalGraph::pool_size; ++i ) {
   15912           0 :                if ( pointer->get_freepointer() != NULL ) {
   15913           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   15914           0 :                  storageArray++;
   15915           0 :                  storageCounter++;
   15916             :                }
   15917           0 :                pointer++;
   15918             :              }
   15919           0 :            block++;
   15920             :         }
   15921           0 :      return storageCounter;
   15922             :    }
   15923             : 
   15924             : /* #line 15925 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   15925             : 
   15926             : 
   15927             : 
   15928             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   15929             : 
   15930             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   15931             : 
   15932             : //############################################################################
   15933             : /* JH (02/02/2006) Constructor of the IR node SgIncidenceUndirectedGraph that takes its 
   15934             :  * corresponding StorageClass as parameter
   15935             :  */
   15936           0 : SgIncidenceUndirectedGraph :: SgIncidenceUndirectedGraph ( const SgIncidenceUndirectedGraphStorageClass& storageSource )   : SgGraph (storageSource)
   15937             :    {
   15938             : 
   15939             : 
   15940             : /* #line 15941 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   15941             : 
   15942           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   15943             : 
   15944             : 
   15945             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   15946             : 
   15947             : 
   15948           0 :    }
   15949             : 
   15950             : //############################################################################
   15951             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   15952             :  * within the working AST. 
   15953             :  */
   15954           0 : SgIncidenceUndirectedGraph * SgIncidenceUndirectedGraph::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   15955           0 :      SgIncidenceUndirectedGraph* returnPointer = NULL;
   15956           0 :      if ( globalIndex != 0 )
   15957             :         {
   15958             : 
   15959             : #if FILE_IO_EXTRA_CHECK
   15960           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIncidenceUndirectedGraph ) ) <= globalIndex ) ;
   15961           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncidenceUndirectedGraph + 1 ) ) );
   15962             : #endif
   15963           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncidenceUndirectedGraph )  
   15964           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIncidenceUndirectedGraph );
   15965           0 :           unsigned long positionInPool = localIndex % SgIncidenceUndirectedGraph::pool_size;
   15966           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncidenceUndirectedGraph::pool_size;
   15967             : 
   15968             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   15969             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   15970             : 
   15971           0 :           returnPointer = &( ( (SgIncidenceUndirectedGraph*)(SgIncidenceUndirectedGraph::pools[memoryBlock]) ) [positionInPool]) ;
   15972             : 
   15973           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   15974             :         }
   15975           0 :      return returnPointer ;
   15976             :    }
   15977             : 
   15978             : //############################################################################
   15979             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   15980             :   for the AST with the index astIndex
   15981             : */
   15982           0 : SgIncidenceUndirectedGraph * SgIncidenceUndirectedGraph::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   15983           0 :      SgIncidenceUndirectedGraph* returnPointer = NULL;
   15984           0 :      if ( globalIndex != 0 )
   15985             :         {
   15986             : 
   15987             : #if FILE_IO_EXTRA_CHECK
   15988           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIncidenceUndirectedGraph ) ) <= globalIndex ) ;
   15989           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncidenceUndirectedGraph + 1 ) ) );
   15990             : #endif
   15991           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncidenceUndirectedGraph )
   15992           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIncidenceUndirectedGraph );
   15993           0 :           unsigned long positionInPool = localIndex % SgIncidenceUndirectedGraph::pool_size ;
   15994           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncidenceUndirectedGraph::pool_size ;
   15995             : 
   15996             : #if FILE_IO_EXTRA_CHECK
   15997             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   15998             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   15999             : #endif
   16000             : 
   16001           0 :           returnPointer = &( ( (SgIncidenceUndirectedGraph*)(SgIncidenceUndirectedGraph::pools[memoryBlock]) ) [positionInPool]) ;
   16002             : 
   16003             : #if FILE_IO_EXTRA_CHECK
   16004           0 :           assert ( returnPointer != NULL ) ;
   16005             : #endif
   16006             :         }
   16007           0 :      return returnPointer ;
   16008             :    }
   16009             : 
   16010             : //############################################################################
   16011             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   16012             :  * pool size! We set for every valid object in the memory pool the freepointer
   16013             :  * to the global index and increase the global index afterwards. For all the 
   16014             :  * invalid objects (means address ranges within the memory pool that were not
   16015             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   16016             :  * distinguish valid from invalid objects! 
   16017             :  */
   16018             : unsigned long
   16019           5 : SgIncidenceUndirectedGraph::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   16020             :    {
   16021           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   16022           5 :      SgIncidenceUndirectedGraph* pointer = NULL;
   16023           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   16024           5 :      std::vector < unsigned char* > :: const_iterator block;
   16025           5 :      for ( block = SgIncidenceUndirectedGraph::pools.begin(); block != SgIncidenceUndirectedGraph::pools.end() ; ++block )
   16026             :         {
   16027           0 :           pointer = (SgIncidenceUndirectedGraph*)(*block);
   16028           0 :           for (unsigned i = 0; i < SgIncidenceUndirectedGraph::pool_size; ++i )
   16029             :              {
   16030             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   16031             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   16032             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   16033             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   16034             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   16035             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   16036             :             // properly; so this will have to be checked next.
   16037             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   16038             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   16039           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   16040             :                   {
   16041           0 :                     pointer[i].set_freepointer((SgIncidenceUndirectedGraph*)(globalIndex));
   16042           0 :                     globalIndex++;
   16043             :                   }
   16044             :                else
   16045             :                   {
   16046           0 :                     pointer[i].set_freepointer(NULL);
   16047             :                   }
   16048             :               }
   16049             :         }
   16050           5 :      return globalIndex;
   16051             :    }
   16052             : 
   16053             : //############################################################################
   16054             : // JH (01/14/2006)
   16055             : void
   16056           5 : SgIncidenceUndirectedGraph::resetValidFreepointers( )
   16057             :    {
   16058           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   16059           5 :      SgIncidenceUndirectedGraph* pointer = NULL;
   16060           5 :      std::vector < unsigned char* > :: const_iterator block;
   16061           5 :      SgIncidenceUndirectedGraph* pointerOfLinkedList = NULL;
   16062           5 :      for ( block = SgIncidenceUndirectedGraph::pools.begin(); block != SgIncidenceUndirectedGraph::pools.end() ; ++block )
   16063             :         {
   16064           0 :           pointer = (SgIncidenceUndirectedGraph*)(*block);
   16065           0 :           for (unsigned i = 0; i < SgIncidenceUndirectedGraph::pool_size; ++i )
   16066             :              {
   16067             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   16068             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   16069             :             // memory blocks!.
   16070           0 :                if ( pointer[i].get_freepointer() != NULL )
   16071             :                   {
   16072           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   16073             :                   }
   16074             :                else
   16075             :                   {
   16076           0 :                     if ( pointerOfLinkedList == NULL )
   16077             :                        {
   16078           0 :                          SgIncidenceUndirectedGraph::next_node = &(pointer[i]);
   16079             :                        }
   16080             :                     else
   16081             :                        {
   16082             :                       // printf ("In SgIncidenceUndirectedGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   16083           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   16084             :                        }
   16085             :                     pointerOfLinkedList = &(pointer[i]);
   16086             :                   }
   16087             :               }
   16088             :         }
   16089             : 
   16090           5 :      if ( pointerOfLinkedList != NULL )
   16091             :         {
   16092             :        // printf ("In SgIncidenceUndirectedGraph::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   16093           0 :           pointerOfLinkedList->set_freepointer(NULL);
   16094             :        // DQ (6/6/2010): Temporary debugging...
   16095             :        //   ROSE_ASSERT(false);
   16096             :         }
   16097             : 
   16098           5 :      return ;
   16099             :    }
   16100             : 
   16101             : //############################################################################
   16102             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   16103             :  * within the memory pool and resets the freepointers, in order to achieve a 
   16104             :  * linked list, that has no jumps and starts at the beginning! This function 
   16105             :  * does not extend the memory pool, since we do not delete any memory blocks,
   16106             :  * but delete the valid objects.  
   16107             :  */
   16108             : void
   16109           0 : SgIncidenceUndirectedGraph::clearMemoryPool( )
   16110             :    {
   16111             :   // printf ("Inside of SgIncidenceUndirectedGraph::clearMemoryPool() \n");
   16112             : 
   16113           0 :      SgIncidenceUndirectedGraph* pointer = NULL, *tempPointer = NULL;
   16114           0 :      std::vector < unsigned char* > :: const_iterator block;
   16115           0 :      if ( SgIncidenceUndirectedGraph::pools.empty() == false )
   16116             :         {
   16117           0 :           block = SgIncidenceUndirectedGraph::pools.begin() ;
   16118           0 :           SgIncidenceUndirectedGraph::next_node = (SgIncidenceUndirectedGraph*) (*block);
   16119             : 
   16120           0 :           while ( block != SgIncidenceUndirectedGraph::pools.end() )
   16121             :              {
   16122           0 :                pointer = (SgIncidenceUndirectedGraph*) (*block);
   16123           0 :                if ( tempPointer != NULL )
   16124             :                   {
   16125           0 :                     tempPointer->set_freepointer(pointer);
   16126             :                   }
   16127           0 :                for (unsigned i = 0; i < SgIncidenceUndirectedGraph::pool_size - 1; ++i)
   16128             :                   {
   16129           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   16130             :                   }
   16131           0 :                 pointer[SgIncidenceUndirectedGraph::pool_size-1].set_freepointer(NULL);
   16132           0 :                 tempPointer = &(pointer[SgIncidenceUndirectedGraph::pool_size-1]);
   16133           0 :                 ++block;
   16134             :              }
   16135             :         }
   16136           0 :    }
   16137             : 
   16138           5 : void SgIncidenceUndirectedGraph::deleteMemoryPool() {
   16139           5 :   for (auto p: SgIncidenceUndirectedGraph::pools) {
   16140           0 :     ROSE_FREE(p);
   16141             :   }
   16142           5 :   SgIncidenceUndirectedGraph::next_node = nullptr;
   16143           5 :   SgIncidenceUndirectedGraph::pools.clear();
   16144           5 : }
   16145             : 
   16146             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   16147             : //                 reading multiple binary files to for a single AST.
   16148             : /////////// new version ////////////////////////////////
   16149             : //############################################################################
   16150             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   16151             : void
   16152           2 : SgIncidenceUndirectedGraph::extendMemoryPoolForFileIO( )
   16153             :   {
   16154           2 :     size_t blockIndex = SgIncidenceUndirectedGraph::pools.size();
   16155           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIncidenceUndirectedGraph) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncidenceUndirectedGraph);
   16156             : 
   16157           2 :     while ( (blockIndex * SgIncidenceUndirectedGraph::pool_size) < newPoolSize)
   16158             :       {
   16159             : #if ROSE_ALLOC_TRACE
   16160             :         if (blockIndex > 0) {
   16161             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIncidenceUndirectedGraph) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncidenceUndirectedGraph) = %" PRIuPTR " SgIncidenceUndirectedGraph::pool_size = %d \n",
   16162             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIncidenceUndirectedGraph),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncidenceUndirectedGraph),SgIncidenceUndirectedGraph::pool_size);
   16163             :         }
   16164             : #endif
   16165             : 
   16166           0 :         SgIncidenceUndirectedGraph * pointer = (SgIncidenceUndirectedGraph*) ROSE_MALLOC ( SgIncidenceUndirectedGraph::pool_size * sizeof(SgIncidenceUndirectedGraph) );
   16167           0 :         assert( pointer != NULL );
   16168             : #if ROSE_ALLOC_MEMSET == 1
   16169             :         memset(pointer, 0x00, SgIncidenceUndirectedGraph::pool_size * sizeof(SgIncidenceUndirectedGraph));
   16170             : #elif ROSE_ALLOC_MEMSET == 2
   16171             :         memset(pointer, 0xCC, SgIncidenceUndirectedGraph::pool_size * sizeof(SgIncidenceUndirectedGraph));
   16172             : #endif
   16173           0 :         SgIncidenceUndirectedGraph::pools.push_back( (unsigned char*)(pointer) );
   16174           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIncidenceUndirectedGraph::pool_size * sizeof(SgIncidenceUndirectedGraph), V_SgIncidenceUndirectedGraph ) );
   16175             : 
   16176           0 :         if ( SgIncidenceUndirectedGraph::next_node != NULL ) {
   16177           0 :           if ( blockIndex > 0 ) {
   16178           0 :             SgIncidenceUndirectedGraph * blkptr = (SgIncidenceUndirectedGraph*)(SgIncidenceUndirectedGraph::pools[blockIndex-1]);
   16179           0 :             blkptr[ SgIncidenceUndirectedGraph::pool_size - 1 ].set_freepointer(pointer);
   16180             :           }
   16181             :         } else {
   16182           0 :           SgIncidenceUndirectedGraph::next_node = pointer;
   16183             :         }
   16184             : 
   16185           0 :         for (unsigned i = 0; i < SgIncidenceUndirectedGraph::pool_size-1; ++i)
   16186             :            {
   16187           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   16188             :            }
   16189           0 :         pointer[ SgIncidenceUndirectedGraph::pool_size -1 ].set_freepointer(NULL);
   16190             : 
   16191           0 :         blockIndex++;
   16192             :       }
   16193           2 :   }
   16194             : 
   16195             : //############################################################################
   16196             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   16197             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   16198             :  * not compressed. However, that stuff is not yet implemented! 
   16199             :  */
   16200             : unsigned long
   16201           0 : SgIncidenceUndirectedGraph::getNumberOfLastValidPointer()
   16202             :    {
   16203           0 :       SgIncidenceUndirectedGraph* testPointer = (SgIncidenceUndirectedGraph*)(SgIncidenceUndirectedGraph::pools.back());
   16204           0 :       unsigned long localIndex = SgIncidenceUndirectedGraph::pool_size - 1;
   16205           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   16206             :          {
   16207           0 :            localIndex--;
   16208             :          }
   16209           0 :       return (localIndex + SgIncidenceUndirectedGraph::pool_size * (SgIncidenceUndirectedGraph::pools.size()-1));
   16210             :    }
   16211             : 
   16212             : //############################################################################
   16213             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   16214             :  * memory pool and initializes the data member in class SgIncidenceUndirectedGraphStroageClass
   16215             :  * from its counterpart of SgIncidenceUndirectedGraph. The return value is just for checking, 
   16216             :  * that the whole StorageClassArray is initialized!
   16217             :  */
   16218             : unsigned long
   16219           0 : SgIncidenceUndirectedGraph::initializeStorageClassArray( SgIncidenceUndirectedGraphStorageClass *storageArray )
   16220             :    {
   16221           0 :      unsigned long storageCounter = 0;
   16222           0 :      std::vector < unsigned char* > :: const_iterator block = SgIncidenceUndirectedGraph::pools.begin();
   16223           0 :      SgIncidenceUndirectedGraph* pointer = NULL;
   16224           0 :      while ( block != SgIncidenceUndirectedGraph::pools.end() ) {
   16225           0 :           pointer = (SgIncidenceUndirectedGraph*) (*block);
   16226           0 :           for ( unsigned i = 0; i < SgIncidenceUndirectedGraph::pool_size; ++i ) {
   16227           0 :                if ( pointer->get_freepointer() != NULL ) {
   16228           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   16229           0 :                  storageArray++;
   16230           0 :                  storageCounter++;
   16231             :                }
   16232           0 :                pointer++;
   16233             :              }
   16234           0 :            block++;
   16235             :         }
   16236           0 :      return storageCounter;
   16237             :    }
   16238             : 
   16239             : /* #line 16240 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   16240             : 
   16241             : 
   16242             : 
   16243             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   16244             : 
   16245             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   16246             : 
   16247             : //############################################################################
   16248             : /* JH (02/02/2006) Constructor of the IR node SgGraphNode that takes its 
   16249             :  * corresponding StorageClass as parameter
   16250             :  */
   16251           0 : SgGraphNode :: SgGraphNode ( const SgGraphNodeStorageClass& storageSource )   : SgSupport (storageSource)
   16252             :    {
   16253             : 
   16254             : 
   16255             : /* #line 16256 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   16256             : 
   16257           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   16258           0 :      p_name = storageSource.storageOf_name.rebuildDataStoredInEasyStorageClass() ;
   16259           0 :      p_SgNode =  (SgNode*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_SgNode) );
   16260           0 :      p_index = storageSource.storageOf_index ;
   16261           0 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
   16262           0 :      p_properties = storageSource.storageOf_properties.rebuildDataStoredInEasyStorageClass() ;
   16263             : 
   16264             : 
   16265             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   16266             : 
   16267             : 
   16268           0 :    }
   16269             : 
   16270             : //############################################################################
   16271             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   16272             :  * within the working AST. 
   16273             :  */
   16274           0 : SgGraphNode * SgGraphNode::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   16275           0 :      SgGraphNode* returnPointer = NULL;
   16276           0 :      if ( globalIndex != 0 )
   16277             :         {
   16278             : 
   16279             : #if FILE_IO_EXTRA_CHECK
   16280           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGraphNode ) ) <= globalIndex ) ;
   16281           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraphNode + 1 ) ) );
   16282             : #endif
   16283           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraphNode )  
   16284           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGraphNode );
   16285           0 :           unsigned long positionInPool = localIndex % SgGraphNode::pool_size;
   16286           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraphNode::pool_size;
   16287             : 
   16288             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   16289             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   16290             : 
   16291           0 :           returnPointer = &( ( (SgGraphNode*)(SgGraphNode::pools[memoryBlock]) ) [positionInPool]) ;
   16292             : 
   16293           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   16294             :         }
   16295           0 :      return returnPointer ;
   16296             :    }
   16297             : 
   16298             : //############################################################################
   16299             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   16300             :   for the AST with the index astIndex
   16301             : */
   16302           0 : SgGraphNode * SgGraphNode::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   16303           0 :      SgGraphNode* returnPointer = NULL;
   16304           0 :      if ( globalIndex != 0 )
   16305             :         {
   16306             : 
   16307             : #if FILE_IO_EXTRA_CHECK
   16308           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGraphNode ) ) <= globalIndex ) ;
   16309           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraphNode + 1 ) ) );
   16310             : #endif
   16311           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraphNode )
   16312           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGraphNode );
   16313           0 :           unsigned long positionInPool = localIndex % SgGraphNode::pool_size ;
   16314           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraphNode::pool_size ;
   16315             : 
   16316             : #if FILE_IO_EXTRA_CHECK
   16317             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   16318             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   16319             : #endif
   16320             : 
   16321           0 :           returnPointer = &( ( (SgGraphNode*)(SgGraphNode::pools[memoryBlock]) ) [positionInPool]) ;
   16322             : 
   16323             : #if FILE_IO_EXTRA_CHECK
   16324           0 :           assert ( returnPointer != NULL ) ;
   16325             : #endif
   16326             :         }
   16327           0 :      return returnPointer ;
   16328             :    }
   16329             : 
   16330             : //############################################################################
   16331             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   16332             :  * pool size! We set for every valid object in the memory pool the freepointer
   16333             :  * to the global index and increase the global index afterwards. For all the 
   16334             :  * invalid objects (means address ranges within the memory pool that were not
   16335             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   16336             :  * distinguish valid from invalid objects! 
   16337             :  */
   16338             : unsigned long
   16339           5 : SgGraphNode::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   16340             :    {
   16341           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   16342           5 :      SgGraphNode* pointer = NULL;
   16343           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   16344           5 :      std::vector < unsigned char* > :: const_iterator block;
   16345           5 :      for ( block = SgGraphNode::pools.begin(); block != SgGraphNode::pools.end() ; ++block )
   16346             :         {
   16347           0 :           pointer = (SgGraphNode*)(*block);
   16348           0 :           for (unsigned i = 0; i < SgGraphNode::pool_size; ++i )
   16349             :              {
   16350             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   16351             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   16352             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   16353             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   16354             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   16355             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   16356             :             // properly; so this will have to be checked next.
   16357             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   16358             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   16359           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   16360             :                   {
   16361           0 :                     pointer[i].set_freepointer((SgGraphNode*)(globalIndex));
   16362           0 :                     globalIndex++;
   16363             :                   }
   16364             :                else
   16365             :                   {
   16366           0 :                     pointer[i].set_freepointer(NULL);
   16367             :                   }
   16368             :               }
   16369             :         }
   16370           5 :      return globalIndex;
   16371             :    }
   16372             : 
   16373             : //############################################################################
   16374             : // JH (01/14/2006)
   16375             : void
   16376           5 : SgGraphNode::resetValidFreepointers( )
   16377             :    {
   16378           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   16379           5 :      SgGraphNode* pointer = NULL;
   16380           5 :      std::vector < unsigned char* > :: const_iterator block;
   16381           5 :      SgGraphNode* pointerOfLinkedList = NULL;
   16382           5 :      for ( block = SgGraphNode::pools.begin(); block != SgGraphNode::pools.end() ; ++block )
   16383             :         {
   16384           0 :           pointer = (SgGraphNode*)(*block);
   16385           0 :           for (unsigned i = 0; i < SgGraphNode::pool_size; ++i )
   16386             :              {
   16387             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   16388             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   16389             :             // memory blocks!.
   16390           0 :                if ( pointer[i].get_freepointer() != NULL )
   16391             :                   {
   16392           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   16393             :                   }
   16394             :                else
   16395             :                   {
   16396           0 :                     if ( pointerOfLinkedList == NULL )
   16397             :                        {
   16398           0 :                          SgGraphNode::next_node = &(pointer[i]);
   16399             :                        }
   16400             :                     else
   16401             :                        {
   16402             :                       // printf ("In SgGraphNode::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   16403           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   16404             :                        }
   16405             :                     pointerOfLinkedList = &(pointer[i]);
   16406             :                   }
   16407             :               }
   16408             :         }
   16409             : 
   16410           5 :      if ( pointerOfLinkedList != NULL )
   16411             :         {
   16412             :        // printf ("In SgGraphNode::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   16413           0 :           pointerOfLinkedList->set_freepointer(NULL);
   16414             :        // DQ (6/6/2010): Temporary debugging...
   16415             :        //   ROSE_ASSERT(false);
   16416             :         }
   16417             : 
   16418           5 :      return ;
   16419             :    }
   16420             : 
   16421             : //############################################################################
   16422             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   16423             :  * within the memory pool and resets the freepointers, in order to achieve a 
   16424             :  * linked list, that has no jumps and starts at the beginning! This function 
   16425             :  * does not extend the memory pool, since we do not delete any memory blocks,
   16426             :  * but delete the valid objects.  
   16427             :  */
   16428             : void
   16429           0 : SgGraphNode::clearMemoryPool( )
   16430             :    {
   16431             :   // printf ("Inside of SgGraphNode::clearMemoryPool() \n");
   16432             : 
   16433           0 :      SgGraphNode* pointer = NULL, *tempPointer = NULL;
   16434           0 :      std::vector < unsigned char* > :: const_iterator block;
   16435           0 :      if ( SgGraphNode::pools.empty() == false )
   16436             :         {
   16437           0 :           block = SgGraphNode::pools.begin() ;
   16438           0 :           SgGraphNode::next_node = (SgGraphNode*) (*block);
   16439             : 
   16440           0 :           while ( block != SgGraphNode::pools.end() )
   16441             :              {
   16442           0 :                pointer = (SgGraphNode*) (*block);
   16443           0 :                if ( tempPointer != NULL )
   16444             :                   {
   16445           0 :                     tempPointer->set_freepointer(pointer);
   16446             :                   }
   16447           0 :                for (unsigned i = 0; i < SgGraphNode::pool_size - 1; ++i)
   16448             :                   {
   16449           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   16450             :                   }
   16451           0 :                 pointer[SgGraphNode::pool_size-1].set_freepointer(NULL);
   16452           0 :                 tempPointer = &(pointer[SgGraphNode::pool_size-1]);
   16453           0 :                 ++block;
   16454             :              }
   16455             :         }
   16456           0 :    }
   16457             : 
   16458           5 : void SgGraphNode::deleteMemoryPool() {
   16459           5 :   for (auto p: SgGraphNode::pools) {
   16460           0 :     ROSE_FREE(p);
   16461             :   }
   16462           5 :   SgGraphNode::next_node = nullptr;
   16463           5 :   SgGraphNode::pools.clear();
   16464           5 : }
   16465             : 
   16466             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   16467             : //                 reading multiple binary files to for a single AST.
   16468             : /////////// new version ////////////////////////////////
   16469             : //############################################################################
   16470             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   16471             : void
   16472           2 : SgGraphNode::extendMemoryPoolForFileIO( )
   16473             :   {
   16474           2 :     size_t blockIndex = SgGraphNode::pools.size();
   16475           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphNode) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphNode);
   16476             : 
   16477           2 :     while ( (blockIndex * SgGraphNode::pool_size) < newPoolSize)
   16478             :       {
   16479             : #if ROSE_ALLOC_TRACE
   16480             :         if (blockIndex > 0) {
   16481             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphNode) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphNode) = %" PRIuPTR " SgGraphNode::pool_size = %d \n",
   16482             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphNode),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphNode),SgGraphNode::pool_size);
   16483             :         }
   16484             : #endif
   16485             : 
   16486           0 :         SgGraphNode * pointer = (SgGraphNode*) ROSE_MALLOC ( SgGraphNode::pool_size * sizeof(SgGraphNode) );
   16487           0 :         assert( pointer != NULL );
   16488             : #if ROSE_ALLOC_MEMSET == 1
   16489             :         memset(pointer, 0x00, SgGraphNode::pool_size * sizeof(SgGraphNode));
   16490             : #elif ROSE_ALLOC_MEMSET == 2
   16491             :         memset(pointer, 0xCC, SgGraphNode::pool_size * sizeof(SgGraphNode));
   16492             : #endif
   16493           0 :         SgGraphNode::pools.push_back( (unsigned char*)(pointer) );
   16494           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGraphNode::pool_size * sizeof(SgGraphNode), V_SgGraphNode ) );
   16495             : 
   16496           0 :         if ( SgGraphNode::next_node != NULL ) {
   16497           0 :           if ( blockIndex > 0 ) {
   16498           0 :             SgGraphNode * blkptr = (SgGraphNode*)(SgGraphNode::pools[blockIndex-1]);
   16499           0 :             blkptr[ SgGraphNode::pool_size - 1 ].set_freepointer(pointer);
   16500             :           }
   16501             :         } else {
   16502           0 :           SgGraphNode::next_node = pointer;
   16503             :         }
   16504             : 
   16505           0 :         for (unsigned i = 0; i < SgGraphNode::pool_size-1; ++i)
   16506             :            {
   16507           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   16508             :            }
   16509           0 :         pointer[ SgGraphNode::pool_size -1 ].set_freepointer(NULL);
   16510             : 
   16511           0 :         blockIndex++;
   16512             :       }
   16513           2 :   }
   16514             : 
   16515             : //############################################################################
   16516             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   16517             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   16518             :  * not compressed. However, that stuff is not yet implemented! 
   16519             :  */
   16520             : unsigned long
   16521           0 : SgGraphNode::getNumberOfLastValidPointer()
   16522             :    {
   16523           0 :       SgGraphNode* testPointer = (SgGraphNode*)(SgGraphNode::pools.back());
   16524           0 :       unsigned long localIndex = SgGraphNode::pool_size - 1;
   16525           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   16526             :          {
   16527           0 :            localIndex--;
   16528             :          }
   16529           0 :       return (localIndex + SgGraphNode::pool_size * (SgGraphNode::pools.size()-1));
   16530             :    }
   16531             : 
   16532             : //############################################################################
   16533             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   16534             :  * memory pool and initializes the data member in class SgGraphNodeStroageClass
   16535             :  * from its counterpart of SgGraphNode. The return value is just for checking, 
   16536             :  * that the whole StorageClassArray is initialized!
   16537             :  */
   16538             : unsigned long
   16539           0 : SgGraphNode::initializeStorageClassArray( SgGraphNodeStorageClass *storageArray )
   16540             :    {
   16541           0 :      unsigned long storageCounter = 0;
   16542           0 :      std::vector < unsigned char* > :: const_iterator block = SgGraphNode::pools.begin();
   16543           0 :      SgGraphNode* pointer = NULL;
   16544           0 :      while ( block != SgGraphNode::pools.end() ) {
   16545           0 :           pointer = (SgGraphNode*) (*block);
   16546           0 :           for ( unsigned i = 0; i < SgGraphNode::pool_size; ++i ) {
   16547           0 :                if ( pointer->get_freepointer() != NULL ) {
   16548           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   16549           0 :                  storageArray++;
   16550           0 :                  storageCounter++;
   16551             :                }
   16552           0 :                pointer++;
   16553             :              }
   16554           0 :            block++;
   16555             :         }
   16556           0 :      return storageCounter;
   16557             :    }
   16558             : 
   16559             : /* #line 16560 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   16560             : 
   16561             : 
   16562             : 
   16563             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   16564             : 
   16565             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   16566             : 
   16567             : //############################################################################
   16568             : /* JH (02/02/2006) Constructor of the IR node SgGraphEdge that takes its 
   16569             :  * corresponding StorageClass as parameter
   16570             :  */
   16571           0 : SgGraphEdge :: SgGraphEdge ( const SgGraphEdgeStorageClass& storageSource )   : SgSupport (storageSource)
   16572             :    {
   16573             : 
   16574             : 
   16575             : /* #line 16576 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   16576             : 
   16577           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   16578           0 :      p_node_A =  (SgGraphNode*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_node_A) );
   16579           0 :      p_node_B =  (SgGraphNode*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_node_B) );
   16580           0 :      p_name = storageSource.storageOf_name.rebuildDataStoredInEasyStorageClass() ;
   16581           0 :      p_index = storageSource.storageOf_index ;
   16582           0 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
   16583           0 :      p_properties = storageSource.storageOf_properties.rebuildDataStoredInEasyStorageClass() ;
   16584             : 
   16585             : 
   16586             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   16587             : 
   16588             : 
   16589           0 :    }
   16590             : 
   16591             : //############################################################################
   16592             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   16593             :  * within the working AST. 
   16594             :  */
   16595           0 : SgGraphEdge * SgGraphEdge::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   16596           0 :      SgGraphEdge* returnPointer = NULL;
   16597           0 :      if ( globalIndex != 0 )
   16598             :         {
   16599             : 
   16600             : #if FILE_IO_EXTRA_CHECK
   16601           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGraphEdge ) ) <= globalIndex ) ;
   16602           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraphEdge + 1 ) ) );
   16603             : #endif
   16604           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraphEdge )  
   16605           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGraphEdge );
   16606           0 :           unsigned long positionInPool = localIndex % SgGraphEdge::pool_size;
   16607           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraphEdge::pool_size;
   16608             : 
   16609             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   16610             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   16611             : 
   16612           0 :           returnPointer = &( ( (SgGraphEdge*)(SgGraphEdge::pools[memoryBlock]) ) [positionInPool]) ;
   16613             : 
   16614           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   16615             :         }
   16616           0 :      return returnPointer ;
   16617             :    }
   16618             : 
   16619             : //############################################################################
   16620             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   16621             :   for the AST with the index astIndex
   16622             : */
   16623           0 : SgGraphEdge * SgGraphEdge::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   16624           0 :      SgGraphEdge* returnPointer = NULL;
   16625           0 :      if ( globalIndex != 0 )
   16626             :         {
   16627             : 
   16628             : #if FILE_IO_EXTRA_CHECK
   16629           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGraphEdge ) ) <= globalIndex ) ;
   16630           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraphEdge + 1 ) ) );
   16631             : #endif
   16632           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraphEdge )
   16633           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGraphEdge );
   16634           0 :           unsigned long positionInPool = localIndex % SgGraphEdge::pool_size ;
   16635           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraphEdge::pool_size ;
   16636             : 
   16637             : #if FILE_IO_EXTRA_CHECK
   16638             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   16639             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   16640             : #endif
   16641             : 
   16642           0 :           returnPointer = &( ( (SgGraphEdge*)(SgGraphEdge::pools[memoryBlock]) ) [positionInPool]) ;
   16643             : 
   16644             : #if FILE_IO_EXTRA_CHECK
   16645           0 :           assert ( returnPointer != NULL ) ;
   16646             : #endif
   16647             :         }
   16648           0 :      return returnPointer ;
   16649             :    }
   16650             : 
   16651             : //############################################################################
   16652             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   16653             :  * pool size! We set for every valid object in the memory pool the freepointer
   16654             :  * to the global index and increase the global index afterwards. For all the 
   16655             :  * invalid objects (means address ranges within the memory pool that were not
   16656             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   16657             :  * distinguish valid from invalid objects! 
   16658             :  */
   16659             : unsigned long
   16660           5 : SgGraphEdge::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   16661             :    {
   16662           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   16663           5 :      SgGraphEdge* pointer = NULL;
   16664           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   16665           5 :      std::vector < unsigned char* > :: const_iterator block;
   16666           5 :      for ( block = SgGraphEdge::pools.begin(); block != SgGraphEdge::pools.end() ; ++block )
   16667             :         {
   16668           0 :           pointer = (SgGraphEdge*)(*block);
   16669           0 :           for (unsigned i = 0; i < SgGraphEdge::pool_size; ++i )
   16670             :              {
   16671             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   16672             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   16673             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   16674             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   16675             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   16676             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   16677             :             // properly; so this will have to be checked next.
   16678             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   16679             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   16680           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   16681             :                   {
   16682           0 :                     pointer[i].set_freepointer((SgGraphEdge*)(globalIndex));
   16683           0 :                     globalIndex++;
   16684             :                   }
   16685             :                else
   16686             :                   {
   16687           0 :                     pointer[i].set_freepointer(NULL);
   16688             :                   }
   16689             :               }
   16690             :         }
   16691           5 :      return globalIndex;
   16692             :    }
   16693             : 
   16694             : //############################################################################
   16695             : // JH (01/14/2006)
   16696             : void
   16697           5 : SgGraphEdge::resetValidFreepointers( )
   16698             :    {
   16699           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   16700           5 :      SgGraphEdge* pointer = NULL;
   16701           5 :      std::vector < unsigned char* > :: const_iterator block;
   16702           5 :      SgGraphEdge* pointerOfLinkedList = NULL;
   16703           5 :      for ( block = SgGraphEdge::pools.begin(); block != SgGraphEdge::pools.end() ; ++block )
   16704             :         {
   16705           0 :           pointer = (SgGraphEdge*)(*block);
   16706           0 :           for (unsigned i = 0; i < SgGraphEdge::pool_size; ++i )
   16707             :              {
   16708             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   16709             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   16710             :             // memory blocks!.
   16711           0 :                if ( pointer[i].get_freepointer() != NULL )
   16712             :                   {
   16713           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   16714             :                   }
   16715             :                else
   16716             :                   {
   16717           0 :                     if ( pointerOfLinkedList == NULL )
   16718             :                        {
   16719           0 :                          SgGraphEdge::next_node = &(pointer[i]);
   16720             :                        }
   16721             :                     else
   16722             :                        {
   16723             :                       // printf ("In SgGraphEdge::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   16724           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   16725             :                        }
   16726             :                     pointerOfLinkedList = &(pointer[i]);
   16727             :                   }
   16728             :               }
   16729             :         }
   16730             : 
   16731           5 :      if ( pointerOfLinkedList != NULL )
   16732             :         {
   16733             :        // printf ("In SgGraphEdge::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   16734           0 :           pointerOfLinkedList->set_freepointer(NULL);
   16735             :        // DQ (6/6/2010): Temporary debugging...
   16736             :        //   ROSE_ASSERT(false);
   16737             :         }
   16738             : 
   16739           5 :      return ;
   16740             :    }
   16741             : 
   16742             : //############################################################################
   16743             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   16744             :  * within the memory pool and resets the freepointers, in order to achieve a 
   16745             :  * linked list, that has no jumps and starts at the beginning! This function 
   16746             :  * does not extend the memory pool, since we do not delete any memory blocks,
   16747             :  * but delete the valid objects.  
   16748             :  */
   16749             : void
   16750           0 : SgGraphEdge::clearMemoryPool( )
   16751             :    {
   16752             :   // printf ("Inside of SgGraphEdge::clearMemoryPool() \n");
   16753             : 
   16754           0 :      SgGraphEdge* pointer = NULL, *tempPointer = NULL;
   16755           0 :      std::vector < unsigned char* > :: const_iterator block;
   16756           0 :      if ( SgGraphEdge::pools.empty() == false )
   16757             :         {
   16758           0 :           block = SgGraphEdge::pools.begin() ;
   16759           0 :           SgGraphEdge::next_node = (SgGraphEdge*) (*block);
   16760             : 
   16761           0 :           while ( block != SgGraphEdge::pools.end() )
   16762             :              {
   16763           0 :                pointer = (SgGraphEdge*) (*block);
   16764           0 :                if ( tempPointer != NULL )
   16765             :                   {
   16766           0 :                     tempPointer->set_freepointer(pointer);
   16767             :                   }
   16768           0 :                for (unsigned i = 0; i < SgGraphEdge::pool_size - 1; ++i)
   16769             :                   {
   16770           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   16771             :                   }
   16772           0 :                 pointer[SgGraphEdge::pool_size-1].set_freepointer(NULL);
   16773           0 :                 tempPointer = &(pointer[SgGraphEdge::pool_size-1]);
   16774           0 :                 ++block;
   16775             :              }
   16776             :         }
   16777           0 :    }
   16778             : 
   16779           5 : void SgGraphEdge::deleteMemoryPool() {
   16780           5 :   for (auto p: SgGraphEdge::pools) {
   16781           0 :     ROSE_FREE(p);
   16782             :   }
   16783           5 :   SgGraphEdge::next_node = nullptr;
   16784           5 :   SgGraphEdge::pools.clear();
   16785           5 : }
   16786             : 
   16787             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   16788             : //                 reading multiple binary files to for a single AST.
   16789             : /////////// new version ////////////////////////////////
   16790             : //############################################################################
   16791             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   16792             : void
   16793           2 : SgGraphEdge::extendMemoryPoolForFileIO( )
   16794             :   {
   16795           2 :     size_t blockIndex = SgGraphEdge::pools.size();
   16796           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphEdge) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphEdge);
   16797             : 
   16798           2 :     while ( (blockIndex * SgGraphEdge::pool_size) < newPoolSize)
   16799             :       {
   16800             : #if ROSE_ALLOC_TRACE
   16801             :         if (blockIndex > 0) {
   16802             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphEdge) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphEdge) = %" PRIuPTR " SgGraphEdge::pool_size = %d \n",
   16803             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphEdge),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphEdge),SgGraphEdge::pool_size);
   16804             :         }
   16805             : #endif
   16806             : 
   16807           0 :         SgGraphEdge * pointer = (SgGraphEdge*) ROSE_MALLOC ( SgGraphEdge::pool_size * sizeof(SgGraphEdge) );
   16808           0 :         assert( pointer != NULL );
   16809             : #if ROSE_ALLOC_MEMSET == 1
   16810             :         memset(pointer, 0x00, SgGraphEdge::pool_size * sizeof(SgGraphEdge));
   16811             : #elif ROSE_ALLOC_MEMSET == 2
   16812             :         memset(pointer, 0xCC, SgGraphEdge::pool_size * sizeof(SgGraphEdge));
   16813             : #endif
   16814           0 :         SgGraphEdge::pools.push_back( (unsigned char*)(pointer) );
   16815           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGraphEdge::pool_size * sizeof(SgGraphEdge), V_SgGraphEdge ) );
   16816             : 
   16817           0 :         if ( SgGraphEdge::next_node != NULL ) {
   16818           0 :           if ( blockIndex > 0 ) {
   16819           0 :             SgGraphEdge * blkptr = (SgGraphEdge*)(SgGraphEdge::pools[blockIndex-1]);
   16820           0 :             blkptr[ SgGraphEdge::pool_size - 1 ].set_freepointer(pointer);
   16821             :           }
   16822             :         } else {
   16823           0 :           SgGraphEdge::next_node = pointer;
   16824             :         }
   16825             : 
   16826           0 :         for (unsigned i = 0; i < SgGraphEdge::pool_size-1; ++i)
   16827             :            {
   16828           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   16829             :            }
   16830           0 :         pointer[ SgGraphEdge::pool_size -1 ].set_freepointer(NULL);
   16831             : 
   16832           0 :         blockIndex++;
   16833             :       }
   16834           2 :   }
   16835             : 
   16836             : //############################################################################
   16837             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   16838             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   16839             :  * not compressed. However, that stuff is not yet implemented! 
   16840             :  */
   16841             : unsigned long
   16842           0 : SgGraphEdge::getNumberOfLastValidPointer()
   16843             :    {
   16844           0 :       SgGraphEdge* testPointer = (SgGraphEdge*)(SgGraphEdge::pools.back());
   16845           0 :       unsigned long localIndex = SgGraphEdge::pool_size - 1;
   16846           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   16847             :          {
   16848           0 :            localIndex--;
   16849             :          }
   16850           0 :       return (localIndex + SgGraphEdge::pool_size * (SgGraphEdge::pools.size()-1));
   16851             :    }
   16852             : 
   16853             : //############################################################################
   16854             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   16855             :  * memory pool and initializes the data member in class SgGraphEdgeStroageClass
   16856             :  * from its counterpart of SgGraphEdge. The return value is just for checking, 
   16857             :  * that the whole StorageClassArray is initialized!
   16858             :  */
   16859             : unsigned long
   16860           0 : SgGraphEdge::initializeStorageClassArray( SgGraphEdgeStorageClass *storageArray )
   16861             :    {
   16862           0 :      unsigned long storageCounter = 0;
   16863           0 :      std::vector < unsigned char* > :: const_iterator block = SgGraphEdge::pools.begin();
   16864           0 :      SgGraphEdge* pointer = NULL;
   16865           0 :      while ( block != SgGraphEdge::pools.end() ) {
   16866           0 :           pointer = (SgGraphEdge*) (*block);
   16867           0 :           for ( unsigned i = 0; i < SgGraphEdge::pool_size; ++i ) {
   16868           0 :                if ( pointer->get_freepointer() != NULL ) {
   16869           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   16870           0 :                  storageArray++;
   16871           0 :                  storageCounter++;
   16872             :                }
   16873           0 :                pointer++;
   16874             :              }
   16875           0 :            block++;
   16876             :         }
   16877           0 :      return storageCounter;
   16878             :    }
   16879             : 
   16880             : /* #line 16881 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   16881             : 
   16882             : 
   16883             : 
   16884             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   16885             : 
   16886             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   16887             : 
   16888             : //############################################################################
   16889             : /* JH (02/02/2006) Constructor of the IR node SgDirectedGraphEdge that takes its 
   16890             :  * corresponding StorageClass as parameter
   16891             :  */
   16892           0 : SgDirectedGraphEdge :: SgDirectedGraphEdge ( const SgDirectedGraphEdgeStorageClass& storageSource )   : SgGraphEdge (storageSource)
   16893             :    {
   16894             : 
   16895             : 
   16896             : /* #line 16897 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   16897             : 
   16898           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   16899             : 
   16900             : 
   16901             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   16902             : 
   16903             : 
   16904           0 :    }
   16905             : 
   16906             : //############################################################################
   16907             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   16908             :  * within the working AST. 
   16909             :  */
   16910           0 : SgDirectedGraphEdge * SgDirectedGraphEdge::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   16911           0 :      SgDirectedGraphEdge* returnPointer = NULL;
   16912           0 :      if ( globalIndex != 0 )
   16913             :         {
   16914             : 
   16915             : #if FILE_IO_EXTRA_CHECK
   16916           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDirectedGraphEdge ) ) <= globalIndex ) ;
   16917           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDirectedGraphEdge + 1 ) ) );
   16918             : #endif
   16919           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDirectedGraphEdge )  
   16920           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDirectedGraphEdge );
   16921           0 :           unsigned long positionInPool = localIndex % SgDirectedGraphEdge::pool_size;
   16922           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDirectedGraphEdge::pool_size;
   16923             : 
   16924             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   16925             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   16926             : 
   16927           0 :           returnPointer = &( ( (SgDirectedGraphEdge*)(SgDirectedGraphEdge::pools[memoryBlock]) ) [positionInPool]) ;
   16928             : 
   16929           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   16930             :         }
   16931           0 :      return returnPointer ;
   16932             :    }
   16933             : 
   16934             : //############################################################################
   16935             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   16936             :   for the AST with the index astIndex
   16937             : */
   16938           0 : SgDirectedGraphEdge * SgDirectedGraphEdge::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   16939           0 :      SgDirectedGraphEdge* returnPointer = NULL;
   16940           0 :      if ( globalIndex != 0 )
   16941             :         {
   16942             : 
   16943             : #if FILE_IO_EXTRA_CHECK
   16944           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDirectedGraphEdge ) ) <= globalIndex ) ;
   16945           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDirectedGraphEdge + 1 ) ) );
   16946             : #endif
   16947           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDirectedGraphEdge )
   16948           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDirectedGraphEdge );
   16949           0 :           unsigned long positionInPool = localIndex % SgDirectedGraphEdge::pool_size ;
   16950           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDirectedGraphEdge::pool_size ;
   16951             : 
   16952             : #if FILE_IO_EXTRA_CHECK
   16953             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   16954             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   16955             : #endif
   16956             : 
   16957           0 :           returnPointer = &( ( (SgDirectedGraphEdge*)(SgDirectedGraphEdge::pools[memoryBlock]) ) [positionInPool]) ;
   16958             : 
   16959             : #if FILE_IO_EXTRA_CHECK
   16960           0 :           assert ( returnPointer != NULL ) ;
   16961             : #endif
   16962             :         }
   16963           0 :      return returnPointer ;
   16964             :    }
   16965             : 
   16966             : //############################################################################
   16967             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   16968             :  * pool size! We set for every valid object in the memory pool the freepointer
   16969             :  * to the global index and increase the global index afterwards. For all the 
   16970             :  * invalid objects (means address ranges within the memory pool that were not
   16971             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   16972             :  * distinguish valid from invalid objects! 
   16973             :  */
   16974             : unsigned long
   16975           5 : SgDirectedGraphEdge::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   16976             :    {
   16977           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   16978           5 :      SgDirectedGraphEdge* pointer = NULL;
   16979           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   16980           5 :      std::vector < unsigned char* > :: const_iterator block;
   16981           5 :      for ( block = SgDirectedGraphEdge::pools.begin(); block != SgDirectedGraphEdge::pools.end() ; ++block )
   16982             :         {
   16983           0 :           pointer = (SgDirectedGraphEdge*)(*block);
   16984           0 :           for (unsigned i = 0; i < SgDirectedGraphEdge::pool_size; ++i )
   16985             :              {
   16986             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   16987             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   16988             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   16989             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   16990             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   16991             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   16992             :             // properly; so this will have to be checked next.
   16993             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   16994             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   16995           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   16996             :                   {
   16997           0 :                     pointer[i].set_freepointer((SgDirectedGraphEdge*)(globalIndex));
   16998           0 :                     globalIndex++;
   16999             :                   }
   17000             :                else
   17001             :                   {
   17002           0 :                     pointer[i].set_freepointer(NULL);
   17003             :                   }
   17004             :               }
   17005             :         }
   17006           5 :      return globalIndex;
   17007             :    }
   17008             : 
   17009             : //############################################################################
   17010             : // JH (01/14/2006)
   17011             : void
   17012           5 : SgDirectedGraphEdge::resetValidFreepointers( )
   17013             :    {
   17014           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   17015           5 :      SgDirectedGraphEdge* pointer = NULL;
   17016           5 :      std::vector < unsigned char* > :: const_iterator block;
   17017           5 :      SgDirectedGraphEdge* pointerOfLinkedList = NULL;
   17018           5 :      for ( block = SgDirectedGraphEdge::pools.begin(); block != SgDirectedGraphEdge::pools.end() ; ++block )
   17019             :         {
   17020           0 :           pointer = (SgDirectedGraphEdge*)(*block);
   17021           0 :           for (unsigned i = 0; i < SgDirectedGraphEdge::pool_size; ++i )
   17022             :              {
   17023             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   17024             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   17025             :             // memory blocks!.
   17026           0 :                if ( pointer[i].get_freepointer() != NULL )
   17027             :                   {
   17028           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   17029             :                   }
   17030             :                else
   17031             :                   {
   17032           0 :                     if ( pointerOfLinkedList == NULL )
   17033             :                        {
   17034           0 :                          SgDirectedGraphEdge::next_node = &(pointer[i]);
   17035             :                        }
   17036             :                     else
   17037             :                        {
   17038             :                       // printf ("In SgDirectedGraphEdge::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   17039           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   17040             :                        }
   17041             :                     pointerOfLinkedList = &(pointer[i]);
   17042             :                   }
   17043             :               }
   17044             :         }
   17045             : 
   17046           5 :      if ( pointerOfLinkedList != NULL )
   17047             :         {
   17048             :        // printf ("In SgDirectedGraphEdge::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   17049           0 :           pointerOfLinkedList->set_freepointer(NULL);
   17050             :        // DQ (6/6/2010): Temporary debugging...
   17051             :        //   ROSE_ASSERT(false);
   17052             :         }
   17053             : 
   17054           5 :      return ;
   17055             :    }
   17056             : 
   17057             : //############################################################################
   17058             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   17059             :  * within the memory pool and resets the freepointers, in order to achieve a 
   17060             :  * linked list, that has no jumps and starts at the beginning! This function 
   17061             :  * does not extend the memory pool, since we do not delete any memory blocks,
   17062             :  * but delete the valid objects.  
   17063             :  */
   17064             : void
   17065           0 : SgDirectedGraphEdge::clearMemoryPool( )
   17066             :    {
   17067             :   // printf ("Inside of SgDirectedGraphEdge::clearMemoryPool() \n");
   17068             : 
   17069           0 :      SgDirectedGraphEdge* pointer = NULL, *tempPointer = NULL;
   17070           0 :      std::vector < unsigned char* > :: const_iterator block;
   17071           0 :      if ( SgDirectedGraphEdge::pools.empty() == false )
   17072             :         {
   17073           0 :           block = SgDirectedGraphEdge::pools.begin() ;
   17074           0 :           SgDirectedGraphEdge::next_node = (SgDirectedGraphEdge*) (*block);
   17075             : 
   17076           0 :           while ( block != SgDirectedGraphEdge::pools.end() )
   17077             :              {
   17078           0 :                pointer = (SgDirectedGraphEdge*) (*block);
   17079           0 :                if ( tempPointer != NULL )
   17080             :                   {
   17081           0 :                     tempPointer->set_freepointer(pointer);
   17082             :                   }
   17083           0 :                for (unsigned i = 0; i < SgDirectedGraphEdge::pool_size - 1; ++i)
   17084             :                   {
   17085           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   17086             :                   }
   17087           0 :                 pointer[SgDirectedGraphEdge::pool_size-1].set_freepointer(NULL);
   17088           0 :                 tempPointer = &(pointer[SgDirectedGraphEdge::pool_size-1]);
   17089           0 :                 ++block;
   17090             :              }
   17091             :         }
   17092           0 :    }
   17093             : 
   17094           5 : void SgDirectedGraphEdge::deleteMemoryPool() {
   17095           5 :   for (auto p: SgDirectedGraphEdge::pools) {
   17096           0 :     ROSE_FREE(p);
   17097             :   }
   17098           5 :   SgDirectedGraphEdge::next_node = nullptr;
   17099           5 :   SgDirectedGraphEdge::pools.clear();
   17100           5 : }
   17101             : 
   17102             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   17103             : //                 reading multiple binary files to for a single AST.
   17104             : /////////// new version ////////////////////////////////
   17105             : //############################################################################
   17106             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   17107             : void
   17108           2 : SgDirectedGraphEdge::extendMemoryPoolForFileIO( )
   17109             :   {
   17110           2 :     size_t blockIndex = SgDirectedGraphEdge::pools.size();
   17111           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectedGraphEdge) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectedGraphEdge);
   17112             : 
   17113           2 :     while ( (blockIndex * SgDirectedGraphEdge::pool_size) < newPoolSize)
   17114             :       {
   17115             : #if ROSE_ALLOC_TRACE
   17116             :         if (blockIndex > 0) {
   17117             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectedGraphEdge) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectedGraphEdge) = %" PRIuPTR " SgDirectedGraphEdge::pool_size = %d \n",
   17118             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDirectedGraphEdge),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDirectedGraphEdge),SgDirectedGraphEdge::pool_size);
   17119             :         }
   17120             : #endif
   17121             : 
   17122           0 :         SgDirectedGraphEdge * pointer = (SgDirectedGraphEdge*) ROSE_MALLOC ( SgDirectedGraphEdge::pool_size * sizeof(SgDirectedGraphEdge) );
   17123           0 :         assert( pointer != NULL );
   17124             : #if ROSE_ALLOC_MEMSET == 1
   17125             :         memset(pointer, 0x00, SgDirectedGraphEdge::pool_size * sizeof(SgDirectedGraphEdge));
   17126             : #elif ROSE_ALLOC_MEMSET == 2
   17127             :         memset(pointer, 0xCC, SgDirectedGraphEdge::pool_size * sizeof(SgDirectedGraphEdge));
   17128             : #endif
   17129           0 :         SgDirectedGraphEdge::pools.push_back( (unsigned char*)(pointer) );
   17130           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDirectedGraphEdge::pool_size * sizeof(SgDirectedGraphEdge), V_SgDirectedGraphEdge ) );
   17131             : 
   17132           0 :         if ( SgDirectedGraphEdge::next_node != NULL ) {
   17133           0 :           if ( blockIndex > 0 ) {
   17134           0 :             SgDirectedGraphEdge * blkptr = (SgDirectedGraphEdge*)(SgDirectedGraphEdge::pools[blockIndex-1]);
   17135           0 :             blkptr[ SgDirectedGraphEdge::pool_size - 1 ].set_freepointer(pointer);
   17136             :           }
   17137             :         } else {
   17138           0 :           SgDirectedGraphEdge::next_node = pointer;
   17139             :         }
   17140             : 
   17141           0 :         for (unsigned i = 0; i < SgDirectedGraphEdge::pool_size-1; ++i)
   17142             :            {
   17143           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   17144             :            }
   17145           0 :         pointer[ SgDirectedGraphEdge::pool_size -1 ].set_freepointer(NULL);
   17146             : 
   17147           0 :         blockIndex++;
   17148             :       }
   17149           2 :   }
   17150             : 
   17151             : //############################################################################
   17152             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   17153             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   17154             :  * not compressed. However, that stuff is not yet implemented! 
   17155             :  */
   17156             : unsigned long
   17157           0 : SgDirectedGraphEdge::getNumberOfLastValidPointer()
   17158             :    {
   17159           0 :       SgDirectedGraphEdge* testPointer = (SgDirectedGraphEdge*)(SgDirectedGraphEdge::pools.back());
   17160           0 :       unsigned long localIndex = SgDirectedGraphEdge::pool_size - 1;
   17161           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   17162             :          {
   17163           0 :            localIndex--;
   17164             :          }
   17165           0 :       return (localIndex + SgDirectedGraphEdge::pool_size * (SgDirectedGraphEdge::pools.size()-1));
   17166             :    }
   17167             : 
   17168             : //############################################################################
   17169             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   17170             :  * memory pool and initializes the data member in class SgDirectedGraphEdgeStroageClass
   17171             :  * from its counterpart of SgDirectedGraphEdge. The return value is just for checking, 
   17172             :  * that the whole StorageClassArray is initialized!
   17173             :  */
   17174             : unsigned long
   17175           0 : SgDirectedGraphEdge::initializeStorageClassArray( SgDirectedGraphEdgeStorageClass *storageArray )
   17176             :    {
   17177           0 :      unsigned long storageCounter = 0;
   17178           0 :      std::vector < unsigned char* > :: const_iterator block = SgDirectedGraphEdge::pools.begin();
   17179           0 :      SgDirectedGraphEdge* pointer = NULL;
   17180           0 :      while ( block != SgDirectedGraphEdge::pools.end() ) {
   17181           0 :           pointer = (SgDirectedGraphEdge*) (*block);
   17182           0 :           for ( unsigned i = 0; i < SgDirectedGraphEdge::pool_size; ++i ) {
   17183           0 :                if ( pointer->get_freepointer() != NULL ) {
   17184           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   17185           0 :                  storageArray++;
   17186           0 :                  storageCounter++;
   17187             :                }
   17188           0 :                pointer++;
   17189             :              }
   17190           0 :            block++;
   17191             :         }
   17192           0 :      return storageCounter;
   17193             :    }
   17194             : 
   17195             : /* #line 17196 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   17196             : 
   17197             : 
   17198             : 
   17199             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   17200             : 
   17201             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   17202             : 
   17203             : //############################################################################
   17204             : /* JH (02/02/2006) Constructor of the IR node SgUndirectedGraphEdge that takes its 
   17205             :  * corresponding StorageClass as parameter
   17206             :  */
   17207           0 : SgUndirectedGraphEdge :: SgUndirectedGraphEdge ( const SgUndirectedGraphEdgeStorageClass& storageSource )   : SgGraphEdge (storageSource)
   17208             :    {
   17209             : 
   17210             : 
   17211             : /* #line 17212 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   17212             : 
   17213           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   17214             : 
   17215             : 
   17216             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   17217             : 
   17218             : 
   17219           0 :    }
   17220             : 
   17221             : //############################################################################
   17222             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   17223             :  * within the working AST. 
   17224             :  */
   17225           0 : SgUndirectedGraphEdge * SgUndirectedGraphEdge::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   17226           0 :      SgUndirectedGraphEdge* returnPointer = NULL;
   17227           0 :      if ( globalIndex != 0 )
   17228             :         {
   17229             : 
   17230             : #if FILE_IO_EXTRA_CHECK
   17231           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUndirectedGraphEdge ) ) <= globalIndex ) ;
   17232           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUndirectedGraphEdge + 1 ) ) );
   17233             : #endif
   17234           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUndirectedGraphEdge )  
   17235           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUndirectedGraphEdge );
   17236           0 :           unsigned long positionInPool = localIndex % SgUndirectedGraphEdge::pool_size;
   17237           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUndirectedGraphEdge::pool_size;
   17238             : 
   17239             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   17240             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   17241             : 
   17242           0 :           returnPointer = &( ( (SgUndirectedGraphEdge*)(SgUndirectedGraphEdge::pools[memoryBlock]) ) [positionInPool]) ;
   17243             : 
   17244           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   17245             :         }
   17246           0 :      return returnPointer ;
   17247             :    }
   17248             : 
   17249             : //############################################################################
   17250             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   17251             :   for the AST with the index astIndex
   17252             : */
   17253           0 : SgUndirectedGraphEdge * SgUndirectedGraphEdge::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   17254           0 :      SgUndirectedGraphEdge* returnPointer = NULL;
   17255           0 :      if ( globalIndex != 0 )
   17256             :         {
   17257             : 
   17258             : #if FILE_IO_EXTRA_CHECK
   17259           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUndirectedGraphEdge ) ) <= globalIndex ) ;
   17260           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUndirectedGraphEdge + 1 ) ) );
   17261             : #endif
   17262           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUndirectedGraphEdge )
   17263           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUndirectedGraphEdge );
   17264           0 :           unsigned long positionInPool = localIndex % SgUndirectedGraphEdge::pool_size ;
   17265           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUndirectedGraphEdge::pool_size ;
   17266             : 
   17267             : #if FILE_IO_EXTRA_CHECK
   17268             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   17269             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   17270             : #endif
   17271             : 
   17272           0 :           returnPointer = &( ( (SgUndirectedGraphEdge*)(SgUndirectedGraphEdge::pools[memoryBlock]) ) [positionInPool]) ;
   17273             : 
   17274             : #if FILE_IO_EXTRA_CHECK
   17275           0 :           assert ( returnPointer != NULL ) ;
   17276             : #endif
   17277             :         }
   17278           0 :      return returnPointer ;
   17279             :    }
   17280             : 
   17281             : //############################################################################
   17282             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   17283             :  * pool size! We set for every valid object in the memory pool the freepointer
   17284             :  * to the global index and increase the global index afterwards. For all the 
   17285             :  * invalid objects (means address ranges within the memory pool that were not
   17286             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   17287             :  * distinguish valid from invalid objects! 
   17288             :  */
   17289             : unsigned long
   17290           5 : SgUndirectedGraphEdge::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   17291             :    {
   17292           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   17293           5 :      SgUndirectedGraphEdge* pointer = NULL;
   17294           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   17295           5 :      std::vector < unsigned char* > :: const_iterator block;
   17296           5 :      for ( block = SgUndirectedGraphEdge::pools.begin(); block != SgUndirectedGraphEdge::pools.end() ; ++block )
   17297             :         {
   17298           0 :           pointer = (SgUndirectedGraphEdge*)(*block);
   17299           0 :           for (unsigned i = 0; i < SgUndirectedGraphEdge::pool_size; ++i )
   17300             :              {
   17301             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   17302             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   17303             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   17304             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   17305             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   17306             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   17307             :             // properly; so this will have to be checked next.
   17308             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   17309             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   17310           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   17311             :                   {
   17312           0 :                     pointer[i].set_freepointer((SgUndirectedGraphEdge*)(globalIndex));
   17313           0 :                     globalIndex++;
   17314             :                   }
   17315             :                else
   17316             :                   {
   17317           0 :                     pointer[i].set_freepointer(NULL);
   17318             :                   }
   17319             :               }
   17320             :         }
   17321           5 :      return globalIndex;
   17322             :    }
   17323             : 
   17324             : //############################################################################
   17325             : // JH (01/14/2006)
   17326             : void
   17327           5 : SgUndirectedGraphEdge::resetValidFreepointers( )
   17328             :    {
   17329           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   17330           5 :      SgUndirectedGraphEdge* pointer = NULL;
   17331           5 :      std::vector < unsigned char* > :: const_iterator block;
   17332           5 :      SgUndirectedGraphEdge* pointerOfLinkedList = NULL;
   17333           5 :      for ( block = SgUndirectedGraphEdge::pools.begin(); block != SgUndirectedGraphEdge::pools.end() ; ++block )
   17334             :         {
   17335           0 :           pointer = (SgUndirectedGraphEdge*)(*block);
   17336           0 :           for (unsigned i = 0; i < SgUndirectedGraphEdge::pool_size; ++i )
   17337             :              {
   17338             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   17339             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   17340             :             // memory blocks!.
   17341           0 :                if ( pointer[i].get_freepointer() != NULL )
   17342             :                   {
   17343           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   17344             :                   }
   17345             :                else
   17346             :                   {
   17347           0 :                     if ( pointerOfLinkedList == NULL )
   17348             :                        {
   17349           0 :                          SgUndirectedGraphEdge::next_node = &(pointer[i]);
   17350             :                        }
   17351             :                     else
   17352             :                        {
   17353             :                       // printf ("In SgUndirectedGraphEdge::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   17354           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   17355             :                        }
   17356             :                     pointerOfLinkedList = &(pointer[i]);
   17357             :                   }
   17358             :               }
   17359             :         }
   17360             : 
   17361           5 :      if ( pointerOfLinkedList != NULL )
   17362             :         {
   17363             :        // printf ("In SgUndirectedGraphEdge::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   17364           0 :           pointerOfLinkedList->set_freepointer(NULL);
   17365             :        // DQ (6/6/2010): Temporary debugging...
   17366             :        //   ROSE_ASSERT(false);
   17367             :         }
   17368             : 
   17369           5 :      return ;
   17370             :    }
   17371             : 
   17372             : //############################################################################
   17373             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   17374             :  * within the memory pool and resets the freepointers, in order to achieve a 
   17375             :  * linked list, that has no jumps and starts at the beginning! This function 
   17376             :  * does not extend the memory pool, since we do not delete any memory blocks,
   17377             :  * but delete the valid objects.  
   17378             :  */
   17379             : void
   17380           0 : SgUndirectedGraphEdge::clearMemoryPool( )
   17381             :    {
   17382             :   // printf ("Inside of SgUndirectedGraphEdge::clearMemoryPool() \n");
   17383             : 
   17384           0 :      SgUndirectedGraphEdge* pointer = NULL, *tempPointer = NULL;
   17385           0 :      std::vector < unsigned char* > :: const_iterator block;
   17386           0 :      if ( SgUndirectedGraphEdge::pools.empty() == false )
   17387             :         {
   17388           0 :           block = SgUndirectedGraphEdge::pools.begin() ;
   17389           0 :           SgUndirectedGraphEdge::next_node = (SgUndirectedGraphEdge*) (*block);
   17390             : 
   17391           0 :           while ( block != SgUndirectedGraphEdge::pools.end() )
   17392             :              {
   17393           0 :                pointer = (SgUndirectedGraphEdge*) (*block);
   17394           0 :                if ( tempPointer != NULL )
   17395             :                   {
   17396           0 :                     tempPointer->set_freepointer(pointer);
   17397             :                   }
   17398           0 :                for (unsigned i = 0; i < SgUndirectedGraphEdge::pool_size - 1; ++i)
   17399             :                   {
   17400           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   17401             :                   }
   17402           0 :                 pointer[SgUndirectedGraphEdge::pool_size-1].set_freepointer(NULL);
   17403           0 :                 tempPointer = &(pointer[SgUndirectedGraphEdge::pool_size-1]);
   17404           0 :                 ++block;
   17405             :              }
   17406             :         }
   17407           0 :    }
   17408             : 
   17409           5 : void SgUndirectedGraphEdge::deleteMemoryPool() {
   17410           5 :   for (auto p: SgUndirectedGraphEdge::pools) {
   17411           0 :     ROSE_FREE(p);
   17412             :   }
   17413           5 :   SgUndirectedGraphEdge::next_node = nullptr;
   17414           5 :   SgUndirectedGraphEdge::pools.clear();
   17415           5 : }
   17416             : 
   17417             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   17418             : //                 reading multiple binary files to for a single AST.
   17419             : /////////// new version ////////////////////////////////
   17420             : //############################################################################
   17421             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   17422             : void
   17423           2 : SgUndirectedGraphEdge::extendMemoryPoolForFileIO( )
   17424             :   {
   17425           2 :     size_t blockIndex = SgUndirectedGraphEdge::pools.size();
   17426           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUndirectedGraphEdge) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUndirectedGraphEdge);
   17427             : 
   17428           2 :     while ( (blockIndex * SgUndirectedGraphEdge::pool_size) < newPoolSize)
   17429             :       {
   17430             : #if ROSE_ALLOC_TRACE
   17431             :         if (blockIndex > 0) {
   17432             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUndirectedGraphEdge) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUndirectedGraphEdge) = %" PRIuPTR " SgUndirectedGraphEdge::pool_size = %d \n",
   17433             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUndirectedGraphEdge),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUndirectedGraphEdge),SgUndirectedGraphEdge::pool_size);
   17434             :         }
   17435             : #endif
   17436             : 
   17437           0 :         SgUndirectedGraphEdge * pointer = (SgUndirectedGraphEdge*) ROSE_MALLOC ( SgUndirectedGraphEdge::pool_size * sizeof(SgUndirectedGraphEdge) );
   17438           0 :         assert( pointer != NULL );
   17439             : #if ROSE_ALLOC_MEMSET == 1
   17440             :         memset(pointer, 0x00, SgUndirectedGraphEdge::pool_size * sizeof(SgUndirectedGraphEdge));
   17441             : #elif ROSE_ALLOC_MEMSET == 2
   17442             :         memset(pointer, 0xCC, SgUndirectedGraphEdge::pool_size * sizeof(SgUndirectedGraphEdge));
   17443             : #endif
   17444           0 :         SgUndirectedGraphEdge::pools.push_back( (unsigned char*)(pointer) );
   17445           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUndirectedGraphEdge::pool_size * sizeof(SgUndirectedGraphEdge), V_SgUndirectedGraphEdge ) );
   17446             : 
   17447           0 :         if ( SgUndirectedGraphEdge::next_node != NULL ) {
   17448           0 :           if ( blockIndex > 0 ) {
   17449           0 :             SgUndirectedGraphEdge * blkptr = (SgUndirectedGraphEdge*)(SgUndirectedGraphEdge::pools[blockIndex-1]);
   17450           0 :             blkptr[ SgUndirectedGraphEdge::pool_size - 1 ].set_freepointer(pointer);
   17451             :           }
   17452             :         } else {
   17453           0 :           SgUndirectedGraphEdge::next_node = pointer;
   17454             :         }
   17455             : 
   17456           0 :         for (unsigned i = 0; i < SgUndirectedGraphEdge::pool_size-1; ++i)
   17457             :            {
   17458           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   17459             :            }
   17460           0 :         pointer[ SgUndirectedGraphEdge::pool_size -1 ].set_freepointer(NULL);
   17461             : 
   17462           0 :         blockIndex++;
   17463             :       }
   17464           2 :   }
   17465             : 
   17466             : //############################################################################
   17467             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   17468             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   17469             :  * not compressed. However, that stuff is not yet implemented! 
   17470             :  */
   17471             : unsigned long
   17472           0 : SgUndirectedGraphEdge::getNumberOfLastValidPointer()
   17473             :    {
   17474           0 :       SgUndirectedGraphEdge* testPointer = (SgUndirectedGraphEdge*)(SgUndirectedGraphEdge::pools.back());
   17475           0 :       unsigned long localIndex = SgUndirectedGraphEdge::pool_size - 1;
   17476           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   17477             :          {
   17478           0 :            localIndex--;
   17479             :          }
   17480           0 :       return (localIndex + SgUndirectedGraphEdge::pool_size * (SgUndirectedGraphEdge::pools.size()-1));
   17481             :    }
   17482             : 
   17483             : //############################################################################
   17484             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   17485             :  * memory pool and initializes the data member in class SgUndirectedGraphEdgeStroageClass
   17486             :  * from its counterpart of SgUndirectedGraphEdge. The return value is just for checking, 
   17487             :  * that the whole StorageClassArray is initialized!
   17488             :  */
   17489             : unsigned long
   17490           0 : SgUndirectedGraphEdge::initializeStorageClassArray( SgUndirectedGraphEdgeStorageClass *storageArray )
   17491             :    {
   17492           0 :      unsigned long storageCounter = 0;
   17493           0 :      std::vector < unsigned char* > :: const_iterator block = SgUndirectedGraphEdge::pools.begin();
   17494           0 :      SgUndirectedGraphEdge* pointer = NULL;
   17495           0 :      while ( block != SgUndirectedGraphEdge::pools.end() ) {
   17496           0 :           pointer = (SgUndirectedGraphEdge*) (*block);
   17497           0 :           for ( unsigned i = 0; i < SgUndirectedGraphEdge::pool_size; ++i ) {
   17498           0 :                if ( pointer->get_freepointer() != NULL ) {
   17499           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   17500           0 :                  storageArray++;
   17501           0 :                  storageCounter++;
   17502             :                }
   17503           0 :                pointer++;
   17504             :              }
   17505           0 :            block++;
   17506             :         }
   17507           0 :      return storageCounter;
   17508             :    }
   17509             : 
   17510             : /* #line 17511 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   17511             : 
   17512             : 
   17513             : 
   17514             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   17515             : 
   17516             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   17517             : 
   17518             : //############################################################################
   17519             : /* JH (02/02/2006) Constructor of the IR node SgGraphNodeList that takes its 
   17520             :  * corresponding StorageClass as parameter
   17521             :  */
   17522           0 : SgGraphNodeList :: SgGraphNodeList ( const SgGraphNodeListStorageClass& storageSource )   : SgSupport (storageSource)
   17523             :    {
   17524             : 
   17525             : 
   17526             : /* #line 17527 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   17527             : 
   17528           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   17529             : 
   17530             : 
   17531             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   17532             : 
   17533             : 
   17534           0 :    }
   17535             : 
   17536             : //############################################################################
   17537             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   17538             :  * within the working AST. 
   17539             :  */
   17540           0 : SgGraphNodeList * SgGraphNodeList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   17541           0 :      SgGraphNodeList* returnPointer = NULL;
   17542           0 :      if ( globalIndex != 0 )
   17543             :         {
   17544             : 
   17545             : #if FILE_IO_EXTRA_CHECK
   17546           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGraphNodeList ) ) <= globalIndex ) ;
   17547           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraphNodeList + 1 ) ) );
   17548             : #endif
   17549           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraphNodeList )  
   17550           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGraphNodeList );
   17551           0 :           unsigned long positionInPool = localIndex % SgGraphNodeList::pool_size;
   17552           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraphNodeList::pool_size;
   17553             : 
   17554             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   17555             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   17556             : 
   17557           0 :           returnPointer = &( ( (SgGraphNodeList*)(SgGraphNodeList::pools[memoryBlock]) ) [positionInPool]) ;
   17558             : 
   17559           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   17560             :         }
   17561           0 :      return returnPointer ;
   17562             :    }
   17563             : 
   17564             : //############################################################################
   17565             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   17566             :   for the AST with the index astIndex
   17567             : */
   17568           0 : SgGraphNodeList * SgGraphNodeList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   17569           0 :      SgGraphNodeList* returnPointer = NULL;
   17570           0 :      if ( globalIndex != 0 )
   17571             :         {
   17572             : 
   17573             : #if FILE_IO_EXTRA_CHECK
   17574           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGraphNodeList ) ) <= globalIndex ) ;
   17575           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraphNodeList + 1 ) ) );
   17576             : #endif
   17577           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraphNodeList )
   17578           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGraphNodeList );
   17579           0 :           unsigned long positionInPool = localIndex % SgGraphNodeList::pool_size ;
   17580           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraphNodeList::pool_size ;
   17581             : 
   17582             : #if FILE_IO_EXTRA_CHECK
   17583             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   17584             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   17585             : #endif
   17586             : 
   17587           0 :           returnPointer = &( ( (SgGraphNodeList*)(SgGraphNodeList::pools[memoryBlock]) ) [positionInPool]) ;
   17588             : 
   17589             : #if FILE_IO_EXTRA_CHECK
   17590           0 :           assert ( returnPointer != NULL ) ;
   17591             : #endif
   17592             :         }
   17593           0 :      return returnPointer ;
   17594             :    }
   17595             : 
   17596             : //############################################################################
   17597             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   17598             :  * pool size! We set for every valid object in the memory pool the freepointer
   17599             :  * to the global index and increase the global index afterwards. For all the 
   17600             :  * invalid objects (means address ranges within the memory pool that were not
   17601             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   17602             :  * distinguish valid from invalid objects! 
   17603             :  */
   17604             : unsigned long
   17605           5 : SgGraphNodeList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   17606             :    {
   17607           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   17608           5 :      SgGraphNodeList* pointer = NULL;
   17609           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   17610           5 :      std::vector < unsigned char* > :: const_iterator block;
   17611           5 :      for ( block = SgGraphNodeList::pools.begin(); block != SgGraphNodeList::pools.end() ; ++block )
   17612             :         {
   17613           0 :           pointer = (SgGraphNodeList*)(*block);
   17614           0 :           for (unsigned i = 0; i < SgGraphNodeList::pool_size; ++i )
   17615             :              {
   17616             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   17617             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   17618             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   17619             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   17620             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   17621             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   17622             :             // properly; so this will have to be checked next.
   17623             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   17624             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   17625           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   17626             :                   {
   17627           0 :                     pointer[i].set_freepointer((SgGraphNodeList*)(globalIndex));
   17628           0 :                     globalIndex++;
   17629             :                   }
   17630             :                else
   17631             :                   {
   17632           0 :                     pointer[i].set_freepointer(NULL);
   17633             :                   }
   17634             :               }
   17635             :         }
   17636           5 :      return globalIndex;
   17637             :    }
   17638             : 
   17639             : //############################################################################
   17640             : // JH (01/14/2006)
   17641             : void
   17642           5 : SgGraphNodeList::resetValidFreepointers( )
   17643             :    {
   17644           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   17645           5 :      SgGraphNodeList* pointer = NULL;
   17646           5 :      std::vector < unsigned char* > :: const_iterator block;
   17647           5 :      SgGraphNodeList* pointerOfLinkedList = NULL;
   17648           5 :      for ( block = SgGraphNodeList::pools.begin(); block != SgGraphNodeList::pools.end() ; ++block )
   17649             :         {
   17650           0 :           pointer = (SgGraphNodeList*)(*block);
   17651           0 :           for (unsigned i = 0; i < SgGraphNodeList::pool_size; ++i )
   17652             :              {
   17653             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   17654             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   17655             :             // memory blocks!.
   17656           0 :                if ( pointer[i].get_freepointer() != NULL )
   17657             :                   {
   17658           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   17659             :                   }
   17660             :                else
   17661             :                   {
   17662           0 :                     if ( pointerOfLinkedList == NULL )
   17663             :                        {
   17664           0 :                          SgGraphNodeList::next_node = &(pointer[i]);
   17665             :                        }
   17666             :                     else
   17667             :                        {
   17668             :                       // printf ("In SgGraphNodeList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   17669           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   17670             :                        }
   17671             :                     pointerOfLinkedList = &(pointer[i]);
   17672             :                   }
   17673             :               }
   17674             :         }
   17675             : 
   17676           5 :      if ( pointerOfLinkedList != NULL )
   17677             :         {
   17678             :        // printf ("In SgGraphNodeList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   17679           0 :           pointerOfLinkedList->set_freepointer(NULL);
   17680             :        // DQ (6/6/2010): Temporary debugging...
   17681             :        //   ROSE_ASSERT(false);
   17682             :         }
   17683             : 
   17684           5 :      return ;
   17685             :    }
   17686             : 
   17687             : //############################################################################
   17688             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   17689             :  * within the memory pool and resets the freepointers, in order to achieve a 
   17690             :  * linked list, that has no jumps and starts at the beginning! This function 
   17691             :  * does not extend the memory pool, since we do not delete any memory blocks,
   17692             :  * but delete the valid objects.  
   17693             :  */
   17694             : void
   17695           0 : SgGraphNodeList::clearMemoryPool( )
   17696             :    {
   17697             :   // printf ("Inside of SgGraphNodeList::clearMemoryPool() \n");
   17698             : 
   17699           0 :      SgGraphNodeList* pointer = NULL, *tempPointer = NULL;
   17700           0 :      std::vector < unsigned char* > :: const_iterator block;
   17701           0 :      if ( SgGraphNodeList::pools.empty() == false )
   17702             :         {
   17703           0 :           block = SgGraphNodeList::pools.begin() ;
   17704           0 :           SgGraphNodeList::next_node = (SgGraphNodeList*) (*block);
   17705             : 
   17706           0 :           while ( block != SgGraphNodeList::pools.end() )
   17707             :              {
   17708           0 :                pointer = (SgGraphNodeList*) (*block);
   17709           0 :                if ( tempPointer != NULL )
   17710             :                   {
   17711           0 :                     tempPointer->set_freepointer(pointer);
   17712             :                   }
   17713           0 :                for (unsigned i = 0; i < SgGraphNodeList::pool_size - 1; ++i)
   17714             :                   {
   17715           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   17716             :                   }
   17717           0 :                 pointer[SgGraphNodeList::pool_size-1].set_freepointer(NULL);
   17718           0 :                 tempPointer = &(pointer[SgGraphNodeList::pool_size-1]);
   17719           0 :                 ++block;
   17720             :              }
   17721             :         }
   17722           0 :    }
   17723             : 
   17724           5 : void SgGraphNodeList::deleteMemoryPool() {
   17725           5 :   for (auto p: SgGraphNodeList::pools) {
   17726           0 :     ROSE_FREE(p);
   17727             :   }
   17728           5 :   SgGraphNodeList::next_node = nullptr;
   17729           5 :   SgGraphNodeList::pools.clear();
   17730           5 : }
   17731             : 
   17732             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   17733             : //                 reading multiple binary files to for a single AST.
   17734             : /////////// new version ////////////////////////////////
   17735             : //############################################################################
   17736             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   17737             : void
   17738           2 : SgGraphNodeList::extendMemoryPoolForFileIO( )
   17739             :   {
   17740           2 :     size_t blockIndex = SgGraphNodeList::pools.size();
   17741           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphNodeList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphNodeList);
   17742             : 
   17743           2 :     while ( (blockIndex * SgGraphNodeList::pool_size) < newPoolSize)
   17744             :       {
   17745             : #if ROSE_ALLOC_TRACE
   17746             :         if (blockIndex > 0) {
   17747             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphNodeList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphNodeList) = %" PRIuPTR " SgGraphNodeList::pool_size = %d \n",
   17748             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphNodeList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphNodeList),SgGraphNodeList::pool_size);
   17749             :         }
   17750             : #endif
   17751             : 
   17752           0 :         SgGraphNodeList * pointer = (SgGraphNodeList*) ROSE_MALLOC ( SgGraphNodeList::pool_size * sizeof(SgGraphNodeList) );
   17753           0 :         assert( pointer != NULL );
   17754             : #if ROSE_ALLOC_MEMSET == 1
   17755             :         memset(pointer, 0x00, SgGraphNodeList::pool_size * sizeof(SgGraphNodeList));
   17756             : #elif ROSE_ALLOC_MEMSET == 2
   17757             :         memset(pointer, 0xCC, SgGraphNodeList::pool_size * sizeof(SgGraphNodeList));
   17758             : #endif
   17759           0 :         SgGraphNodeList::pools.push_back( (unsigned char*)(pointer) );
   17760           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGraphNodeList::pool_size * sizeof(SgGraphNodeList), V_SgGraphNodeList ) );
   17761             : 
   17762           0 :         if ( SgGraphNodeList::next_node != NULL ) {
   17763           0 :           if ( blockIndex > 0 ) {
   17764           0 :             SgGraphNodeList * blkptr = (SgGraphNodeList*)(SgGraphNodeList::pools[blockIndex-1]);
   17765           0 :             blkptr[ SgGraphNodeList::pool_size - 1 ].set_freepointer(pointer);
   17766             :           }
   17767             :         } else {
   17768           0 :           SgGraphNodeList::next_node = pointer;
   17769             :         }
   17770             : 
   17771           0 :         for (unsigned i = 0; i < SgGraphNodeList::pool_size-1; ++i)
   17772             :            {
   17773           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   17774             :            }
   17775           0 :         pointer[ SgGraphNodeList::pool_size -1 ].set_freepointer(NULL);
   17776             : 
   17777           0 :         blockIndex++;
   17778             :       }
   17779           2 :   }
   17780             : 
   17781             : //############################################################################
   17782             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   17783             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   17784             :  * not compressed. However, that stuff is not yet implemented! 
   17785             :  */
   17786             : unsigned long
   17787           0 : SgGraphNodeList::getNumberOfLastValidPointer()
   17788             :    {
   17789           0 :       SgGraphNodeList* testPointer = (SgGraphNodeList*)(SgGraphNodeList::pools.back());
   17790           0 :       unsigned long localIndex = SgGraphNodeList::pool_size - 1;
   17791           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   17792             :          {
   17793           0 :            localIndex--;
   17794             :          }
   17795           0 :       return (localIndex + SgGraphNodeList::pool_size * (SgGraphNodeList::pools.size()-1));
   17796             :    }
   17797             : 
   17798             : //############################################################################
   17799             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   17800             :  * memory pool and initializes the data member in class SgGraphNodeListStroageClass
   17801             :  * from its counterpart of SgGraphNodeList. The return value is just for checking, 
   17802             :  * that the whole StorageClassArray is initialized!
   17803             :  */
   17804             : unsigned long
   17805           0 : SgGraphNodeList::initializeStorageClassArray( SgGraphNodeListStorageClass *storageArray )
   17806             :    {
   17807           0 :      unsigned long storageCounter = 0;
   17808           0 :      std::vector < unsigned char* > :: const_iterator block = SgGraphNodeList::pools.begin();
   17809           0 :      SgGraphNodeList* pointer = NULL;
   17810           0 :      while ( block != SgGraphNodeList::pools.end() ) {
   17811           0 :           pointer = (SgGraphNodeList*) (*block);
   17812           0 :           for ( unsigned i = 0; i < SgGraphNodeList::pool_size; ++i ) {
   17813           0 :                if ( pointer->get_freepointer() != NULL ) {
   17814           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   17815           0 :                  storageArray++;
   17816           0 :                  storageCounter++;
   17817             :                }
   17818           0 :                pointer++;
   17819             :              }
   17820           0 :            block++;
   17821             :         }
   17822           0 :      return storageCounter;
   17823             :    }
   17824             : 
   17825             : /* #line 17826 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   17826             : 
   17827             : 
   17828             : 
   17829             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   17830             : 
   17831             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   17832             : 
   17833             : //############################################################################
   17834             : /* JH (02/02/2006) Constructor of the IR node SgGraphEdgeList that takes its 
   17835             :  * corresponding StorageClass as parameter
   17836             :  */
   17837           0 : SgGraphEdgeList :: SgGraphEdgeList ( const SgGraphEdgeListStorageClass& storageSource )   : SgSupport (storageSource)
   17838             :    {
   17839             : 
   17840             : 
   17841             : /* #line 17842 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   17842             : 
   17843           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   17844             : 
   17845             : 
   17846             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   17847             : 
   17848             : 
   17849           0 :    }
   17850             : 
   17851             : //############################################################################
   17852             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   17853             :  * within the working AST. 
   17854             :  */
   17855           0 : SgGraphEdgeList * SgGraphEdgeList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   17856           0 :      SgGraphEdgeList* returnPointer = NULL;
   17857           0 :      if ( globalIndex != 0 )
   17858             :         {
   17859             : 
   17860             : #if FILE_IO_EXTRA_CHECK
   17861           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGraphEdgeList ) ) <= globalIndex ) ;
   17862           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraphEdgeList + 1 ) ) );
   17863             : #endif
   17864           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGraphEdgeList )  
   17865           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGraphEdgeList );
   17866           0 :           unsigned long positionInPool = localIndex % SgGraphEdgeList::pool_size;
   17867           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraphEdgeList::pool_size;
   17868             : 
   17869             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   17870             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   17871             : 
   17872           0 :           returnPointer = &( ( (SgGraphEdgeList*)(SgGraphEdgeList::pools[memoryBlock]) ) [positionInPool]) ;
   17873             : 
   17874           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   17875             :         }
   17876           0 :      return returnPointer ;
   17877             :    }
   17878             : 
   17879             : //############################################################################
   17880             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   17881             :   for the AST with the index astIndex
   17882             : */
   17883           0 : SgGraphEdgeList * SgGraphEdgeList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   17884           0 :      SgGraphEdgeList* returnPointer = NULL;
   17885           0 :      if ( globalIndex != 0 )
   17886             :         {
   17887             : 
   17888             : #if FILE_IO_EXTRA_CHECK
   17889           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGraphEdgeList ) ) <= globalIndex ) ;
   17890           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraphEdgeList + 1 ) ) );
   17891             : #endif
   17892           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGraphEdgeList )
   17893           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGraphEdgeList );
   17894           0 :           unsigned long positionInPool = localIndex % SgGraphEdgeList::pool_size ;
   17895           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGraphEdgeList::pool_size ;
   17896             : 
   17897             : #if FILE_IO_EXTRA_CHECK
   17898             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   17899             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   17900             : #endif
   17901             : 
   17902           0 :           returnPointer = &( ( (SgGraphEdgeList*)(SgGraphEdgeList::pools[memoryBlock]) ) [positionInPool]) ;
   17903             : 
   17904             : #if FILE_IO_EXTRA_CHECK
   17905           0 :           assert ( returnPointer != NULL ) ;
   17906             : #endif
   17907             :         }
   17908           0 :      return returnPointer ;
   17909             :    }
   17910             : 
   17911             : //############################################################################
   17912             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   17913             :  * pool size! We set for every valid object in the memory pool the freepointer
   17914             :  * to the global index and increase the global index afterwards. For all the 
   17915             :  * invalid objects (means address ranges within the memory pool that were not
   17916             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   17917             :  * distinguish valid from invalid objects! 
   17918             :  */
   17919             : unsigned long
   17920           5 : SgGraphEdgeList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   17921             :    {
   17922           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   17923           5 :      SgGraphEdgeList* pointer = NULL;
   17924           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   17925           5 :      std::vector < unsigned char* > :: const_iterator block;
   17926           5 :      for ( block = SgGraphEdgeList::pools.begin(); block != SgGraphEdgeList::pools.end() ; ++block )
   17927             :         {
   17928           0 :           pointer = (SgGraphEdgeList*)(*block);
   17929           0 :           for (unsigned i = 0; i < SgGraphEdgeList::pool_size; ++i )
   17930             :              {
   17931             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   17932             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   17933             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   17934             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   17935             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   17936             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   17937             :             // properly; so this will have to be checked next.
   17938             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   17939             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   17940           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   17941             :                   {
   17942           0 :                     pointer[i].set_freepointer((SgGraphEdgeList*)(globalIndex));
   17943           0 :                     globalIndex++;
   17944             :                   }
   17945             :                else
   17946             :                   {
   17947           0 :                     pointer[i].set_freepointer(NULL);
   17948             :                   }
   17949             :               }
   17950             :         }
   17951           5 :      return globalIndex;
   17952             :    }
   17953             : 
   17954             : //############################################################################
   17955             : // JH (01/14/2006)
   17956             : void
   17957           5 : SgGraphEdgeList::resetValidFreepointers( )
   17958             :    {
   17959           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   17960           5 :      SgGraphEdgeList* pointer = NULL;
   17961           5 :      std::vector < unsigned char* > :: const_iterator block;
   17962           5 :      SgGraphEdgeList* pointerOfLinkedList = NULL;
   17963           5 :      for ( block = SgGraphEdgeList::pools.begin(); block != SgGraphEdgeList::pools.end() ; ++block )
   17964             :         {
   17965           0 :           pointer = (SgGraphEdgeList*)(*block);
   17966           0 :           for (unsigned i = 0; i < SgGraphEdgeList::pool_size; ++i )
   17967             :              {
   17968             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   17969             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   17970             :             // memory blocks!.
   17971           0 :                if ( pointer[i].get_freepointer() != NULL )
   17972             :                   {
   17973           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   17974             :                   }
   17975             :                else
   17976             :                   {
   17977           0 :                     if ( pointerOfLinkedList == NULL )
   17978             :                        {
   17979           0 :                          SgGraphEdgeList::next_node = &(pointer[i]);
   17980             :                        }
   17981             :                     else
   17982             :                        {
   17983             :                       // printf ("In SgGraphEdgeList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   17984           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   17985             :                        }
   17986             :                     pointerOfLinkedList = &(pointer[i]);
   17987             :                   }
   17988             :               }
   17989             :         }
   17990             : 
   17991           5 :      if ( pointerOfLinkedList != NULL )
   17992             :         {
   17993             :        // printf ("In SgGraphEdgeList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   17994           0 :           pointerOfLinkedList->set_freepointer(NULL);
   17995             :        // DQ (6/6/2010): Temporary debugging...
   17996             :        //   ROSE_ASSERT(false);
   17997             :         }
   17998             : 
   17999           5 :      return ;
   18000             :    }
   18001             : 
   18002             : //############################################################################
   18003             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   18004             :  * within the memory pool and resets the freepointers, in order to achieve a 
   18005             :  * linked list, that has no jumps and starts at the beginning! This function 
   18006             :  * does not extend the memory pool, since we do not delete any memory blocks,
   18007             :  * but delete the valid objects.  
   18008             :  */
   18009             : void
   18010           0 : SgGraphEdgeList::clearMemoryPool( )
   18011             :    {
   18012             :   // printf ("Inside of SgGraphEdgeList::clearMemoryPool() \n");
   18013             : 
   18014           0 :      SgGraphEdgeList* pointer = NULL, *tempPointer = NULL;
   18015           0 :      std::vector < unsigned char* > :: const_iterator block;
   18016           0 :      if ( SgGraphEdgeList::pools.empty() == false )
   18017             :         {
   18018           0 :           block = SgGraphEdgeList::pools.begin() ;
   18019           0 :           SgGraphEdgeList::next_node = (SgGraphEdgeList*) (*block);
   18020             : 
   18021           0 :           while ( block != SgGraphEdgeList::pools.end() )
   18022             :              {
   18023           0 :                pointer = (SgGraphEdgeList*) (*block);
   18024           0 :                if ( tempPointer != NULL )
   18025             :                   {
   18026           0 :                     tempPointer->set_freepointer(pointer);
   18027             :                   }
   18028           0 :                for (unsigned i = 0; i < SgGraphEdgeList::pool_size - 1; ++i)
   18029             :                   {
   18030           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   18031             :                   }
   18032           0 :                 pointer[SgGraphEdgeList::pool_size-1].set_freepointer(NULL);
   18033           0 :                 tempPointer = &(pointer[SgGraphEdgeList::pool_size-1]);
   18034           0 :                 ++block;
   18035             :              }
   18036             :         }
   18037           0 :    }
   18038             : 
   18039           5 : void SgGraphEdgeList::deleteMemoryPool() {
   18040           5 :   for (auto p: SgGraphEdgeList::pools) {
   18041           0 :     ROSE_FREE(p);
   18042             :   }
   18043           5 :   SgGraphEdgeList::next_node = nullptr;
   18044           5 :   SgGraphEdgeList::pools.clear();
   18045           5 : }
   18046             : 
   18047             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   18048             : //                 reading multiple binary files to for a single AST.
   18049             : /////////// new version ////////////////////////////////
   18050             : //############################################################################
   18051             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   18052             : void
   18053           2 : SgGraphEdgeList::extendMemoryPoolForFileIO( )
   18054             :   {
   18055           2 :     size_t blockIndex = SgGraphEdgeList::pools.size();
   18056           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphEdgeList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphEdgeList);
   18057             : 
   18058           2 :     while ( (blockIndex * SgGraphEdgeList::pool_size) < newPoolSize)
   18059             :       {
   18060             : #if ROSE_ALLOC_TRACE
   18061             :         if (blockIndex > 0) {
   18062             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphEdgeList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphEdgeList) = %" PRIuPTR " SgGraphEdgeList::pool_size = %d \n",
   18063             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGraphEdgeList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGraphEdgeList),SgGraphEdgeList::pool_size);
   18064             :         }
   18065             : #endif
   18066             : 
   18067           0 :         SgGraphEdgeList * pointer = (SgGraphEdgeList*) ROSE_MALLOC ( SgGraphEdgeList::pool_size * sizeof(SgGraphEdgeList) );
   18068           0 :         assert( pointer != NULL );
   18069             : #if ROSE_ALLOC_MEMSET == 1
   18070             :         memset(pointer, 0x00, SgGraphEdgeList::pool_size * sizeof(SgGraphEdgeList));
   18071             : #elif ROSE_ALLOC_MEMSET == 2
   18072             :         memset(pointer, 0xCC, SgGraphEdgeList::pool_size * sizeof(SgGraphEdgeList));
   18073             : #endif
   18074           0 :         SgGraphEdgeList::pools.push_back( (unsigned char*)(pointer) );
   18075           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGraphEdgeList::pool_size * sizeof(SgGraphEdgeList), V_SgGraphEdgeList ) );
   18076             : 
   18077           0 :         if ( SgGraphEdgeList::next_node != NULL ) {
   18078           0 :           if ( blockIndex > 0 ) {
   18079           0 :             SgGraphEdgeList * blkptr = (SgGraphEdgeList*)(SgGraphEdgeList::pools[blockIndex-1]);
   18080           0 :             blkptr[ SgGraphEdgeList::pool_size - 1 ].set_freepointer(pointer);
   18081             :           }
   18082             :         } else {
   18083           0 :           SgGraphEdgeList::next_node = pointer;
   18084             :         }
   18085             : 
   18086           0 :         for (unsigned i = 0; i < SgGraphEdgeList::pool_size-1; ++i)
   18087             :            {
   18088           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   18089             :            }
   18090           0 :         pointer[ SgGraphEdgeList::pool_size -1 ].set_freepointer(NULL);
   18091             : 
   18092           0 :         blockIndex++;
   18093             :       }
   18094           2 :   }
   18095             : 
   18096             : //############################################################################
   18097             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   18098             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   18099             :  * not compressed. However, that stuff is not yet implemented! 
   18100             :  */
   18101             : unsigned long
   18102           0 : SgGraphEdgeList::getNumberOfLastValidPointer()
   18103             :    {
   18104           0 :       SgGraphEdgeList* testPointer = (SgGraphEdgeList*)(SgGraphEdgeList::pools.back());
   18105           0 :       unsigned long localIndex = SgGraphEdgeList::pool_size - 1;
   18106           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   18107             :          {
   18108           0 :            localIndex--;
   18109             :          }
   18110           0 :       return (localIndex + SgGraphEdgeList::pool_size * (SgGraphEdgeList::pools.size()-1));
   18111             :    }
   18112             : 
   18113             : //############################################################################
   18114             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   18115             :  * memory pool and initializes the data member in class SgGraphEdgeListStroageClass
   18116             :  * from its counterpart of SgGraphEdgeList. The return value is just for checking, 
   18117             :  * that the whole StorageClassArray is initialized!
   18118             :  */
   18119             : unsigned long
   18120           0 : SgGraphEdgeList::initializeStorageClassArray( SgGraphEdgeListStorageClass *storageArray )
   18121             :    {
   18122           0 :      unsigned long storageCounter = 0;
   18123           0 :      std::vector < unsigned char* > :: const_iterator block = SgGraphEdgeList::pools.begin();
   18124           0 :      SgGraphEdgeList* pointer = NULL;
   18125           0 :      while ( block != SgGraphEdgeList::pools.end() ) {
   18126           0 :           pointer = (SgGraphEdgeList*) (*block);
   18127           0 :           for ( unsigned i = 0; i < SgGraphEdgeList::pool_size; ++i ) {
   18128           0 :                if ( pointer->get_freepointer() != NULL ) {
   18129           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   18130           0 :                  storageArray++;
   18131           0 :                  storageCounter++;
   18132             :                }
   18133           0 :                pointer++;
   18134             :              }
   18135           0 :            block++;
   18136             :         }
   18137           0 :      return storageCounter;
   18138             :    }
   18139             : 
   18140             : /* #line 18141 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   18141             : 
   18142             : 
   18143             : 
   18144             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   18145             : 
   18146             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   18147             : 
   18148             : //############################################################################
   18149             : /* JH (02/02/2006) Constructor of the IR node SgTypeTable that takes its 
   18150             :  * corresponding StorageClass as parameter
   18151             :  */
   18152       13450 : SgTypeTable :: SgTypeTable ( const SgTypeTableStorageClass& storageSource )   : SgSupport (storageSource)
   18153             :    {
   18154             : 
   18155             : 
   18156             : /* #line 18157 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   18157             : 
   18158       13450 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   18159       13450 :      p_type_table =  (SgSymbolTable*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type_table) );
   18160             : 
   18161             : 
   18162             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   18163             : 
   18164             : 
   18165       13450 :    }
   18166             : 
   18167             : //############################################################################
   18168             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   18169             :  * within the working AST. 
   18170             :  */
   18171       26900 : SgTypeTable * SgTypeTable::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   18172       26900 :      SgTypeTable* returnPointer = NULL;
   18173       26900 :      if ( globalIndex != 0 )
   18174             :         {
   18175             : 
   18176             : #if FILE_IO_EXTRA_CHECK
   18177       26900 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeTable ) ) <= globalIndex ) ;
   18178       26900 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeTable + 1 ) ) );
   18179             : #endif
   18180       26900 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeTable )  
   18181       26900 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeTable );
   18182       26900 :           unsigned long positionInPool = localIndex % SgTypeTable::pool_size;
   18183       26900 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeTable::pool_size;
   18184             : 
   18185             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   18186             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   18187             : 
   18188       26900 :           returnPointer = &( ( (SgTypeTable*)(SgTypeTable::pools[memoryBlock]) ) [positionInPool]) ;
   18189             : 
   18190       26900 :           ROSE_ASSERT( returnPointer != NULL ) ;
   18191             :         }
   18192       26900 :      return returnPointer ;
   18193             :    }
   18194             : 
   18195             : //############################################################################
   18196             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   18197             :   for the AST with the index astIndex
   18198             : */
   18199           0 : SgTypeTable * SgTypeTable::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   18200           0 :      SgTypeTable* returnPointer = NULL;
   18201           0 :      if ( globalIndex != 0 )
   18202             :         {
   18203             : 
   18204             : #if FILE_IO_EXTRA_CHECK
   18205           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeTable ) ) <= globalIndex ) ;
   18206           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeTable + 1 ) ) );
   18207             : #endif
   18208           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeTable )
   18209           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeTable );
   18210           0 :           unsigned long positionInPool = localIndex % SgTypeTable::pool_size ;
   18211           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeTable::pool_size ;
   18212             : 
   18213             : #if FILE_IO_EXTRA_CHECK
   18214             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   18215             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   18216             : #endif
   18217             : 
   18218           0 :           returnPointer = &( ( (SgTypeTable*)(SgTypeTable::pools[memoryBlock]) ) [positionInPool]) ;
   18219             : 
   18220             : #if FILE_IO_EXTRA_CHECK
   18221           0 :           assert ( returnPointer != NULL ) ;
   18222             : #endif
   18223             :         }
   18224           0 :      return returnPointer ;
   18225             :    }
   18226             : 
   18227             : //############################################################################
   18228             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   18229             :  * pool size! We set for every valid object in the memory pool the freepointer
   18230             :  * to the global index and increase the global index afterwards. For all the 
   18231             :  * invalid objects (means address ranges within the memory pool that were not
   18232             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   18233             :  * distinguish valid from invalid objects! 
   18234             :  */
   18235             : unsigned long
   18236           5 : SgTypeTable::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   18237             :    {
   18238           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   18239           5 :      SgTypeTable* pointer = NULL;
   18240           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   18241           5 :      std::vector < unsigned char* > :: const_iterator block;
   18242          16 :      for ( block = SgTypeTable::pools.begin(); block != SgTypeTable::pools.end() ; ++block )
   18243             :         {
   18244          11 :           pointer = (SgTypeTable*)(*block);
   18245       22011 :           for (unsigned i = 0; i < SgTypeTable::pool_size; ++i )
   18246             :              {
   18247             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   18248             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   18249             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   18250             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   18251             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   18252             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   18253             :             // properly; so this will have to be checked next.
   18254             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   18255             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   18256       22000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   18257             :                   {
   18258       13459 :                     pointer[i].set_freepointer((SgTypeTable*)(globalIndex));
   18259       13459 :                     globalIndex++;
   18260             :                   }
   18261             :                else
   18262             :                   {
   18263        8541 :                     pointer[i].set_freepointer(NULL);
   18264             :                   }
   18265             :               }
   18266             :         }
   18267           5 :      return globalIndex;
   18268             :    }
   18269             : 
   18270             : //############################################################################
   18271             : // JH (01/14/2006)
   18272             : void
   18273           5 : SgTypeTable::resetValidFreepointers( )
   18274             :    {
   18275           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   18276           5 :      SgTypeTable* pointer = NULL;
   18277           5 :      std::vector < unsigned char* > :: const_iterator block;
   18278           5 :      SgTypeTable* pointerOfLinkedList = NULL;
   18279          16 :      for ( block = SgTypeTable::pools.begin(); block != SgTypeTable::pools.end() ; ++block )
   18280             :         {
   18281          11 :           pointer = (SgTypeTable*)(*block);
   18282       22011 :           for (unsigned i = 0; i < SgTypeTable::pool_size; ++i )
   18283             :              {
   18284             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   18285             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   18286             :             // memory blocks!.
   18287       22000 :                if ( pointer[i].get_freepointer() != NULL )
   18288             :                   {
   18289       13459 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   18290             :                   }
   18291             :                else
   18292             :                   {
   18293        8541 :                     if ( pointerOfLinkedList == NULL )
   18294             :                        {
   18295           5 :                          SgTypeTable::next_node = &(pointer[i]);
   18296             :                        }
   18297             :                     else
   18298             :                        {
   18299             :                       // printf ("In SgTypeTable::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   18300        8536 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   18301             :                        }
   18302             :                     pointerOfLinkedList = &(pointer[i]);
   18303             :                   }
   18304             :               }
   18305             :         }
   18306             : 
   18307           5 :      if ( pointerOfLinkedList != NULL )
   18308             :         {
   18309             :        // printf ("In SgTypeTable::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   18310           5 :           pointerOfLinkedList->set_freepointer(NULL);
   18311             :        // DQ (6/6/2010): Temporary debugging...
   18312             :        //   ROSE_ASSERT(false);
   18313             :         }
   18314             : 
   18315           5 :      return ;
   18316             :    }
   18317             : 
   18318             : //############################################################################
   18319             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   18320             :  * within the memory pool and resets the freepointers, in order to achieve a 
   18321             :  * linked list, that has no jumps and starts at the beginning! This function 
   18322             :  * does not extend the memory pool, since we do not delete any memory blocks,
   18323             :  * but delete the valid objects.  
   18324             :  */
   18325             : void
   18326           0 : SgTypeTable::clearMemoryPool( )
   18327             :    {
   18328             :   // printf ("Inside of SgTypeTable::clearMemoryPool() \n");
   18329             : 
   18330           0 :      SgTypeTable* pointer = NULL, *tempPointer = NULL;
   18331           0 :      std::vector < unsigned char* > :: const_iterator block;
   18332           0 :      if ( SgTypeTable::pools.empty() == false )
   18333             :         {
   18334           0 :           block = SgTypeTable::pools.begin() ;
   18335           0 :           SgTypeTable::next_node = (SgTypeTable*) (*block);
   18336             : 
   18337           0 :           while ( block != SgTypeTable::pools.end() )
   18338             :              {
   18339           0 :                pointer = (SgTypeTable*) (*block);
   18340           0 :                if ( tempPointer != NULL )
   18341             :                   {
   18342           0 :                     tempPointer->set_freepointer(pointer);
   18343             :                   }
   18344           0 :                for (unsigned i = 0; i < SgTypeTable::pool_size - 1; ++i)
   18345             :                   {
   18346           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   18347             :                   }
   18348           0 :                 pointer[SgTypeTable::pool_size-1].set_freepointer(NULL);
   18349           0 :                 tempPointer = &(pointer[SgTypeTable::pool_size-1]);
   18350           0 :                 ++block;
   18351             :              }
   18352             :         }
   18353           0 :    }
   18354             : 
   18355           5 : void SgTypeTable::deleteMemoryPool() {
   18356          22 :   for (auto p: SgTypeTable::pools) {
   18357          17 :     ROSE_FREE(p);
   18358             :   }
   18359           5 :   SgTypeTable::next_node = nullptr;
   18360           5 :   SgTypeTable::pools.clear();
   18361           5 : }
   18362             : 
   18363             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   18364             : //                 reading multiple binary files to for a single AST.
   18365             : /////////// new version ////////////////////////////////
   18366             : //############################################################################
   18367             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   18368             : void
   18369           2 : SgTypeTable::extendMemoryPoolForFileIO( )
   18370             :   {
   18371           2 :     size_t blockIndex = SgTypeTable::pools.size();
   18372           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTable) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTable);
   18373             : 
   18374           8 :     while ( (blockIndex * SgTypeTable::pool_size) < newPoolSize)
   18375             :       {
   18376             : #if ROSE_ALLOC_TRACE
   18377             :         if (blockIndex > 0) {
   18378             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTable) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTable) = %" PRIuPTR " SgTypeTable::pool_size = %d \n",
   18379             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTable),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTable),SgTypeTable::pool_size);
   18380             :         }
   18381             : #endif
   18382             : 
   18383           6 :         SgTypeTable * pointer = (SgTypeTable*) ROSE_MALLOC ( SgTypeTable::pool_size * sizeof(SgTypeTable) );
   18384           6 :         assert( pointer != NULL );
   18385             : #if ROSE_ALLOC_MEMSET == 1
   18386             :         memset(pointer, 0x00, SgTypeTable::pool_size * sizeof(SgTypeTable));
   18387             : #elif ROSE_ALLOC_MEMSET == 2
   18388             :         memset(pointer, 0xCC, SgTypeTable::pool_size * sizeof(SgTypeTable));
   18389             : #endif
   18390           6 :         SgTypeTable::pools.push_back( (unsigned char*)(pointer) );
   18391           6 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeTable::pool_size * sizeof(SgTypeTable), V_SgTypeTable ) );
   18392             : 
   18393           6 :         if ( SgTypeTable::next_node != NULL ) {
   18394           6 :           if ( blockIndex > 0 ) {
   18395           6 :             SgTypeTable * blkptr = (SgTypeTable*)(SgTypeTable::pools[blockIndex-1]);
   18396           6 :             blkptr[ SgTypeTable::pool_size - 1 ].set_freepointer(pointer);
   18397             :           }
   18398             :         } else {
   18399           0 :           SgTypeTable::next_node = pointer;
   18400             :         }
   18401             : 
   18402       12000 :         for (unsigned i = 0; i < SgTypeTable::pool_size-1; ++i)
   18403             :            {
   18404       11994 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   18405             :            }
   18406           6 :         pointer[ SgTypeTable::pool_size -1 ].set_freepointer(NULL);
   18407             : 
   18408           6 :         blockIndex++;
   18409             :       }
   18410           2 :   }
   18411             : 
   18412             : //############################################################################
   18413             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   18414             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   18415             :  * not compressed. However, that stuff is not yet implemented! 
   18416             :  */
   18417             : unsigned long
   18418           0 : SgTypeTable::getNumberOfLastValidPointer()
   18419             :    {
   18420           0 :       SgTypeTable* testPointer = (SgTypeTable*)(SgTypeTable::pools.back());
   18421           0 :       unsigned long localIndex = SgTypeTable::pool_size - 1;
   18422           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   18423             :          {
   18424           0 :            localIndex--;
   18425             :          }
   18426           0 :       return (localIndex + SgTypeTable::pool_size * (SgTypeTable::pools.size()-1));
   18427             :    }
   18428             : 
   18429             : //############################################################################
   18430             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   18431             :  * memory pool and initializes the data member in class SgTypeTableStroageClass
   18432             :  * from its counterpart of SgTypeTable. The return value is just for checking, 
   18433             :  * that the whole StorageClassArray is initialized!
   18434             :  */
   18435             : unsigned long
   18436           3 : SgTypeTable::initializeStorageClassArray( SgTypeTableStorageClass *storageArray )
   18437             :    {
   18438           3 :      unsigned long storageCounter = 0;
   18439           3 :      std::vector < unsigned char* > :: const_iterator block = SgTypeTable::pools.begin();
   18440           3 :      SgTypeTable* pointer = NULL;
   18441          12 :      while ( block != SgTypeTable::pools.end() ) {
   18442           9 :           pointer = (SgTypeTable*) (*block);
   18443       18009 :           for ( unsigned i = 0; i < SgTypeTable::pool_size; ++i ) {
   18444       18000 :                if ( pointer->get_freepointer() != NULL ) {
   18445       13455 :                  storageArray->pickOutIRNodeData (pointer) ;
   18446       13455 :                  storageArray++;
   18447       13455 :                  storageCounter++;
   18448             :                }
   18449       18000 :                pointer++;
   18450             :              }
   18451           9 :            block++;
   18452             :         }
   18453           3 :      return storageCounter;
   18454             :    }
   18455             : 
   18456             : /* #line 18457 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   18457             : 
   18458             : 
   18459             : 
   18460             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   18461             : 
   18462             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   18463             : 
   18464             : //############################################################################
   18465             : /* JH (02/02/2006) Constructor of the IR node SgNameGroup that takes its 
   18466             :  * corresponding StorageClass as parameter
   18467             :  */
   18468           0 : SgNameGroup :: SgNameGroup ( const SgNameGroupStorageClass& storageSource )   : SgSupport (storageSource)
   18469             :    {
   18470             : 
   18471             : 
   18472             : /* #line 18473 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   18473             : 
   18474           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   18475           0 :      p_group_name = storageSource.storageOf_group_name.rebuildDataStoredInEasyStorageClass() ;
   18476           0 :      p_name_list = storageSource.storageOf_name_list.rebuildDataStoredInEasyStorageClass() ;
   18477             : 
   18478             : 
   18479             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   18480             : 
   18481             : 
   18482           0 :    }
   18483             : 
   18484             : //############################################################################
   18485             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   18486             :  * within the working AST. 
   18487             :  */
   18488           0 : SgNameGroup * SgNameGroup::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   18489           0 :      SgNameGroup* returnPointer = NULL;
   18490           0 :      if ( globalIndex != 0 )
   18491             :         {
   18492             : 
   18493             : #if FILE_IO_EXTRA_CHECK
   18494           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNameGroup ) ) <= globalIndex ) ;
   18495           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNameGroup + 1 ) ) );
   18496             : #endif
   18497           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNameGroup )  
   18498           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNameGroup );
   18499           0 :           unsigned long positionInPool = localIndex % SgNameGroup::pool_size;
   18500           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNameGroup::pool_size;
   18501             : 
   18502             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   18503             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   18504             : 
   18505           0 :           returnPointer = &( ( (SgNameGroup*)(SgNameGroup::pools[memoryBlock]) ) [positionInPool]) ;
   18506             : 
   18507           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   18508             :         }
   18509           0 :      return returnPointer ;
   18510             :    }
   18511             : 
   18512             : //############################################################################
   18513             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   18514             :   for the AST with the index astIndex
   18515             : */
   18516           0 : SgNameGroup * SgNameGroup::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   18517           0 :      SgNameGroup* returnPointer = NULL;
   18518           0 :      if ( globalIndex != 0 )
   18519             :         {
   18520             : 
   18521             : #if FILE_IO_EXTRA_CHECK
   18522           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNameGroup ) ) <= globalIndex ) ;
   18523           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNameGroup + 1 ) ) );
   18524             : #endif
   18525           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNameGroup )
   18526           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNameGroup );
   18527           0 :           unsigned long positionInPool = localIndex % SgNameGroup::pool_size ;
   18528           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNameGroup::pool_size ;
   18529             : 
   18530             : #if FILE_IO_EXTRA_CHECK
   18531             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   18532             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   18533             : #endif
   18534             : 
   18535           0 :           returnPointer = &( ( (SgNameGroup*)(SgNameGroup::pools[memoryBlock]) ) [positionInPool]) ;
   18536             : 
   18537             : #if FILE_IO_EXTRA_CHECK
   18538           0 :           assert ( returnPointer != NULL ) ;
   18539             : #endif
   18540             :         }
   18541           0 :      return returnPointer ;
   18542             :    }
   18543             : 
   18544             : //############################################################################
   18545             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   18546             :  * pool size! We set for every valid object in the memory pool the freepointer
   18547             :  * to the global index and increase the global index afterwards. For all the 
   18548             :  * invalid objects (means address ranges within the memory pool that were not
   18549             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   18550             :  * distinguish valid from invalid objects! 
   18551             :  */
   18552             : unsigned long
   18553           5 : SgNameGroup::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   18554             :    {
   18555           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   18556           5 :      SgNameGroup* pointer = NULL;
   18557           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   18558           5 :      std::vector < unsigned char* > :: const_iterator block;
   18559           5 :      for ( block = SgNameGroup::pools.begin(); block != SgNameGroup::pools.end() ; ++block )
   18560             :         {
   18561           0 :           pointer = (SgNameGroup*)(*block);
   18562           0 :           for (unsigned i = 0; i < SgNameGroup::pool_size; ++i )
   18563             :              {
   18564             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   18565             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   18566             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   18567             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   18568             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   18569             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   18570             :             // properly; so this will have to be checked next.
   18571             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   18572             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   18573           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   18574             :                   {
   18575           0 :                     pointer[i].set_freepointer((SgNameGroup*)(globalIndex));
   18576           0 :                     globalIndex++;
   18577             :                   }
   18578             :                else
   18579             :                   {
   18580           0 :                     pointer[i].set_freepointer(NULL);
   18581             :                   }
   18582             :               }
   18583             :         }
   18584           5 :      return globalIndex;
   18585             :    }
   18586             : 
   18587             : //############################################################################
   18588             : // JH (01/14/2006)
   18589             : void
   18590           5 : SgNameGroup::resetValidFreepointers( )
   18591             :    {
   18592           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   18593           5 :      SgNameGroup* pointer = NULL;
   18594           5 :      std::vector < unsigned char* > :: const_iterator block;
   18595           5 :      SgNameGroup* pointerOfLinkedList = NULL;
   18596           5 :      for ( block = SgNameGroup::pools.begin(); block != SgNameGroup::pools.end() ; ++block )
   18597             :         {
   18598           0 :           pointer = (SgNameGroup*)(*block);
   18599           0 :           for (unsigned i = 0; i < SgNameGroup::pool_size; ++i )
   18600             :              {
   18601             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   18602             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   18603             :             // memory blocks!.
   18604           0 :                if ( pointer[i].get_freepointer() != NULL )
   18605             :                   {
   18606           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   18607             :                   }
   18608             :                else
   18609             :                   {
   18610           0 :                     if ( pointerOfLinkedList == NULL )
   18611             :                        {
   18612           0 :                          SgNameGroup::next_node = &(pointer[i]);
   18613             :                        }
   18614             :                     else
   18615             :                        {
   18616             :                       // printf ("In SgNameGroup::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   18617           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   18618             :                        }
   18619             :                     pointerOfLinkedList = &(pointer[i]);
   18620             :                   }
   18621             :               }
   18622             :         }
   18623             : 
   18624           5 :      if ( pointerOfLinkedList != NULL )
   18625             :         {
   18626             :        // printf ("In SgNameGroup::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   18627           0 :           pointerOfLinkedList->set_freepointer(NULL);
   18628             :        // DQ (6/6/2010): Temporary debugging...
   18629             :        //   ROSE_ASSERT(false);
   18630             :         }
   18631             : 
   18632           5 :      return ;
   18633             :    }
   18634             : 
   18635             : //############################################################################
   18636             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   18637             :  * within the memory pool and resets the freepointers, in order to achieve a 
   18638             :  * linked list, that has no jumps and starts at the beginning! This function 
   18639             :  * does not extend the memory pool, since we do not delete any memory blocks,
   18640             :  * but delete the valid objects.  
   18641             :  */
   18642             : void
   18643           0 : SgNameGroup::clearMemoryPool( )
   18644             :    {
   18645             :   // printf ("Inside of SgNameGroup::clearMemoryPool() \n");
   18646             : 
   18647           0 :      SgNameGroup* pointer = NULL, *tempPointer = NULL;
   18648           0 :      std::vector < unsigned char* > :: const_iterator block;
   18649           0 :      if ( SgNameGroup::pools.empty() == false )
   18650             :         {
   18651           0 :           block = SgNameGroup::pools.begin() ;
   18652           0 :           SgNameGroup::next_node = (SgNameGroup*) (*block);
   18653             : 
   18654           0 :           while ( block != SgNameGroup::pools.end() )
   18655             :              {
   18656           0 :                pointer = (SgNameGroup*) (*block);
   18657           0 :                if ( tempPointer != NULL )
   18658             :                   {
   18659           0 :                     tempPointer->set_freepointer(pointer);
   18660             :                   }
   18661           0 :                for (unsigned i = 0; i < SgNameGroup::pool_size - 1; ++i)
   18662             :                   {
   18663           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   18664             :                   }
   18665           0 :                 pointer[SgNameGroup::pool_size-1].set_freepointer(NULL);
   18666           0 :                 tempPointer = &(pointer[SgNameGroup::pool_size-1]);
   18667           0 :                 ++block;
   18668             :              }
   18669             :         }
   18670           0 :    }
   18671             : 
   18672           5 : void SgNameGroup::deleteMemoryPool() {
   18673           5 :   for (auto p: SgNameGroup::pools) {
   18674           0 :     ROSE_FREE(p);
   18675             :   }
   18676           5 :   SgNameGroup::next_node = nullptr;
   18677           5 :   SgNameGroup::pools.clear();
   18678           5 : }
   18679             : 
   18680             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   18681             : //                 reading multiple binary files to for a single AST.
   18682             : /////////// new version ////////////////////////////////
   18683             : //############################################################################
   18684             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   18685             : void
   18686           2 : SgNameGroup::extendMemoryPoolForFileIO( )
   18687             :   {
   18688           2 :     size_t blockIndex = SgNameGroup::pools.size();
   18689           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNameGroup) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNameGroup);
   18690             : 
   18691           2 :     while ( (blockIndex * SgNameGroup::pool_size) < newPoolSize)
   18692             :       {
   18693             : #if ROSE_ALLOC_TRACE
   18694             :         if (blockIndex > 0) {
   18695             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNameGroup) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNameGroup) = %" PRIuPTR " SgNameGroup::pool_size = %d \n",
   18696             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNameGroup),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNameGroup),SgNameGroup::pool_size);
   18697             :         }
   18698             : #endif
   18699             : 
   18700           0 :         SgNameGroup * pointer = (SgNameGroup*) ROSE_MALLOC ( SgNameGroup::pool_size * sizeof(SgNameGroup) );
   18701           0 :         assert( pointer != NULL );
   18702             : #if ROSE_ALLOC_MEMSET == 1
   18703             :         memset(pointer, 0x00, SgNameGroup::pool_size * sizeof(SgNameGroup));
   18704             : #elif ROSE_ALLOC_MEMSET == 2
   18705             :         memset(pointer, 0xCC, SgNameGroup::pool_size * sizeof(SgNameGroup));
   18706             : #endif
   18707           0 :         SgNameGroup::pools.push_back( (unsigned char*)(pointer) );
   18708           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNameGroup::pool_size * sizeof(SgNameGroup), V_SgNameGroup ) );
   18709             : 
   18710           0 :         if ( SgNameGroup::next_node != NULL ) {
   18711           0 :           if ( blockIndex > 0 ) {
   18712           0 :             SgNameGroup * blkptr = (SgNameGroup*)(SgNameGroup::pools[blockIndex-1]);
   18713           0 :             blkptr[ SgNameGroup::pool_size - 1 ].set_freepointer(pointer);
   18714             :           }
   18715             :         } else {
   18716           0 :           SgNameGroup::next_node = pointer;
   18717             :         }
   18718             : 
   18719           0 :         for (unsigned i = 0; i < SgNameGroup::pool_size-1; ++i)
   18720             :            {
   18721           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   18722             :            }
   18723           0 :         pointer[ SgNameGroup::pool_size -1 ].set_freepointer(NULL);
   18724             : 
   18725           0 :         blockIndex++;
   18726             :       }
   18727           2 :   }
   18728             : 
   18729             : //############################################################################
   18730             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   18731             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   18732             :  * not compressed. However, that stuff is not yet implemented! 
   18733             :  */
   18734             : unsigned long
   18735           0 : SgNameGroup::getNumberOfLastValidPointer()
   18736             :    {
   18737           0 :       SgNameGroup* testPointer = (SgNameGroup*)(SgNameGroup::pools.back());
   18738           0 :       unsigned long localIndex = SgNameGroup::pool_size - 1;
   18739           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   18740             :          {
   18741           0 :            localIndex--;
   18742             :          }
   18743           0 :       return (localIndex + SgNameGroup::pool_size * (SgNameGroup::pools.size()-1));
   18744             :    }
   18745             : 
   18746             : //############################################################################
   18747             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   18748             :  * memory pool and initializes the data member in class SgNameGroupStroageClass
   18749             :  * from its counterpart of SgNameGroup. The return value is just for checking, 
   18750             :  * that the whole StorageClassArray is initialized!
   18751             :  */
   18752             : unsigned long
   18753           0 : SgNameGroup::initializeStorageClassArray( SgNameGroupStorageClass *storageArray )
   18754             :    {
   18755           0 :      unsigned long storageCounter = 0;
   18756           0 :      std::vector < unsigned char* > :: const_iterator block = SgNameGroup::pools.begin();
   18757           0 :      SgNameGroup* pointer = NULL;
   18758           0 :      while ( block != SgNameGroup::pools.end() ) {
   18759           0 :           pointer = (SgNameGroup*) (*block);
   18760           0 :           for ( unsigned i = 0; i < SgNameGroup::pool_size; ++i ) {
   18761           0 :                if ( pointer->get_freepointer() != NULL ) {
   18762           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   18763           0 :                  storageArray++;
   18764           0 :                  storageCounter++;
   18765             :                }
   18766           0 :                pointer++;
   18767             :              }
   18768           0 :            block++;
   18769             :         }
   18770           0 :      return storageCounter;
   18771             :    }
   18772             : 
   18773             : /* #line 18774 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   18774             : 
   18775             : 
   18776             : 
   18777             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   18778             : 
   18779             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   18780             : 
   18781             : //############################################################################
   18782             : /* JH (02/02/2006) Constructor of the IR node SgDimensionObject that takes its 
   18783             :  * corresponding StorageClass as parameter
   18784             :  */
   18785           0 : SgDimensionObject :: SgDimensionObject ( const SgDimensionObjectStorageClass& storageSource )   : SgSupport (storageSource)
   18786             :    {
   18787             : 
   18788             : 
   18789             : /* #line 18790 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   18790             : 
   18791           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   18792           0 :      p_array =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_array) );
   18793           0 :      p_shape =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_shape) );
   18794             : 
   18795             : 
   18796             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   18797             : 
   18798             : 
   18799           0 :    }
   18800             : 
   18801             : //############################################################################
   18802             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   18803             :  * within the working AST. 
   18804             :  */
   18805           0 : SgDimensionObject * SgDimensionObject::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   18806           0 :      SgDimensionObject* returnPointer = NULL;
   18807           0 :      if ( globalIndex != 0 )
   18808             :         {
   18809             : 
   18810             : #if FILE_IO_EXTRA_CHECK
   18811           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDimensionObject ) ) <= globalIndex ) ;
   18812           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDimensionObject + 1 ) ) );
   18813             : #endif
   18814           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDimensionObject )  
   18815           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDimensionObject );
   18816           0 :           unsigned long positionInPool = localIndex % SgDimensionObject::pool_size;
   18817           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDimensionObject::pool_size;
   18818             : 
   18819             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   18820             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   18821             : 
   18822           0 :           returnPointer = &( ( (SgDimensionObject*)(SgDimensionObject::pools[memoryBlock]) ) [positionInPool]) ;
   18823             : 
   18824           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   18825             :         }
   18826           0 :      return returnPointer ;
   18827             :    }
   18828             : 
   18829             : //############################################################################
   18830             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   18831             :   for the AST with the index astIndex
   18832             : */
   18833           0 : SgDimensionObject * SgDimensionObject::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   18834           0 :      SgDimensionObject* returnPointer = NULL;
   18835           0 :      if ( globalIndex != 0 )
   18836             :         {
   18837             : 
   18838             : #if FILE_IO_EXTRA_CHECK
   18839           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDimensionObject ) ) <= globalIndex ) ;
   18840           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDimensionObject + 1 ) ) );
   18841             : #endif
   18842           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDimensionObject )
   18843           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDimensionObject );
   18844           0 :           unsigned long positionInPool = localIndex % SgDimensionObject::pool_size ;
   18845           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDimensionObject::pool_size ;
   18846             : 
   18847             : #if FILE_IO_EXTRA_CHECK
   18848             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   18849             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   18850             : #endif
   18851             : 
   18852           0 :           returnPointer = &( ( (SgDimensionObject*)(SgDimensionObject::pools[memoryBlock]) ) [positionInPool]) ;
   18853             : 
   18854             : #if FILE_IO_EXTRA_CHECK
   18855           0 :           assert ( returnPointer != NULL ) ;
   18856             : #endif
   18857             :         }
   18858           0 :      return returnPointer ;
   18859             :    }
   18860             : 
   18861             : //############################################################################
   18862             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   18863             :  * pool size! We set for every valid object in the memory pool the freepointer
   18864             :  * to the global index and increase the global index afterwards. For all the 
   18865             :  * invalid objects (means address ranges within the memory pool that were not
   18866             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   18867             :  * distinguish valid from invalid objects! 
   18868             :  */
   18869             : unsigned long
   18870           5 : SgDimensionObject::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   18871             :    {
   18872           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   18873           5 :      SgDimensionObject* pointer = NULL;
   18874           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   18875           5 :      std::vector < unsigned char* > :: const_iterator block;
   18876           5 :      for ( block = SgDimensionObject::pools.begin(); block != SgDimensionObject::pools.end() ; ++block )
   18877             :         {
   18878           0 :           pointer = (SgDimensionObject*)(*block);
   18879           0 :           for (unsigned i = 0; i < SgDimensionObject::pool_size; ++i )
   18880             :              {
   18881             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   18882             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   18883             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   18884             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   18885             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   18886             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   18887             :             // properly; so this will have to be checked next.
   18888             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   18889             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   18890           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   18891             :                   {
   18892           0 :                     pointer[i].set_freepointer((SgDimensionObject*)(globalIndex));
   18893           0 :                     globalIndex++;
   18894             :                   }
   18895             :                else
   18896             :                   {
   18897           0 :                     pointer[i].set_freepointer(NULL);
   18898             :                   }
   18899             :               }
   18900             :         }
   18901           5 :      return globalIndex;
   18902             :    }
   18903             : 
   18904             : //############################################################################
   18905             : // JH (01/14/2006)
   18906             : void
   18907           5 : SgDimensionObject::resetValidFreepointers( )
   18908             :    {
   18909           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   18910           5 :      SgDimensionObject* pointer = NULL;
   18911           5 :      std::vector < unsigned char* > :: const_iterator block;
   18912           5 :      SgDimensionObject* pointerOfLinkedList = NULL;
   18913           5 :      for ( block = SgDimensionObject::pools.begin(); block != SgDimensionObject::pools.end() ; ++block )
   18914             :         {
   18915           0 :           pointer = (SgDimensionObject*)(*block);
   18916           0 :           for (unsigned i = 0; i < SgDimensionObject::pool_size; ++i )
   18917             :              {
   18918             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   18919             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   18920             :             // memory blocks!.
   18921           0 :                if ( pointer[i].get_freepointer() != NULL )
   18922             :                   {
   18923           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   18924             :                   }
   18925             :                else
   18926             :                   {
   18927           0 :                     if ( pointerOfLinkedList == NULL )
   18928             :                        {
   18929           0 :                          SgDimensionObject::next_node = &(pointer[i]);
   18930             :                        }
   18931             :                     else
   18932             :                        {
   18933             :                       // printf ("In SgDimensionObject::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   18934           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   18935             :                        }
   18936             :                     pointerOfLinkedList = &(pointer[i]);
   18937             :                   }
   18938             :               }
   18939             :         }
   18940             : 
   18941           5 :      if ( pointerOfLinkedList != NULL )
   18942             :         {
   18943             :        // printf ("In SgDimensionObject::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   18944           0 :           pointerOfLinkedList->set_freepointer(NULL);
   18945             :        // DQ (6/6/2010): Temporary debugging...
   18946             :        //   ROSE_ASSERT(false);
   18947             :         }
   18948             : 
   18949           5 :      return ;
   18950             :    }
   18951             : 
   18952             : //############################################################################
   18953             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   18954             :  * within the memory pool and resets the freepointers, in order to achieve a 
   18955             :  * linked list, that has no jumps and starts at the beginning! This function 
   18956             :  * does not extend the memory pool, since we do not delete any memory blocks,
   18957             :  * but delete the valid objects.  
   18958             :  */
   18959             : void
   18960           0 : SgDimensionObject::clearMemoryPool( )
   18961             :    {
   18962             :   // printf ("Inside of SgDimensionObject::clearMemoryPool() \n");
   18963             : 
   18964           0 :      SgDimensionObject* pointer = NULL, *tempPointer = NULL;
   18965           0 :      std::vector < unsigned char* > :: const_iterator block;
   18966           0 :      if ( SgDimensionObject::pools.empty() == false )
   18967             :         {
   18968           0 :           block = SgDimensionObject::pools.begin() ;
   18969           0 :           SgDimensionObject::next_node = (SgDimensionObject*) (*block);
   18970             : 
   18971           0 :           while ( block != SgDimensionObject::pools.end() )
   18972             :              {
   18973           0 :                pointer = (SgDimensionObject*) (*block);
   18974           0 :                if ( tempPointer != NULL )
   18975             :                   {
   18976           0 :                     tempPointer->set_freepointer(pointer);
   18977             :                   }
   18978           0 :                for (unsigned i = 0; i < SgDimensionObject::pool_size - 1; ++i)
   18979             :                   {
   18980           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   18981             :                   }
   18982           0 :                 pointer[SgDimensionObject::pool_size-1].set_freepointer(NULL);
   18983           0 :                 tempPointer = &(pointer[SgDimensionObject::pool_size-1]);
   18984           0 :                 ++block;
   18985             :              }
   18986             :         }
   18987           0 :    }
   18988             : 
   18989           5 : void SgDimensionObject::deleteMemoryPool() {
   18990           5 :   for (auto p: SgDimensionObject::pools) {
   18991           0 :     ROSE_FREE(p);
   18992             :   }
   18993           5 :   SgDimensionObject::next_node = nullptr;
   18994           5 :   SgDimensionObject::pools.clear();
   18995           5 : }
   18996             : 
   18997             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   18998             : //                 reading multiple binary files to for a single AST.
   18999             : /////////// new version ////////////////////////////////
   19000             : //############################################################################
   19001             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   19002             : void
   19003           2 : SgDimensionObject::extendMemoryPoolForFileIO( )
   19004             :   {
   19005           2 :     size_t blockIndex = SgDimensionObject::pools.size();
   19006           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDimensionObject) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDimensionObject);
   19007             : 
   19008           2 :     while ( (blockIndex * SgDimensionObject::pool_size) < newPoolSize)
   19009             :       {
   19010             : #if ROSE_ALLOC_TRACE
   19011             :         if (blockIndex > 0) {
   19012             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDimensionObject) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDimensionObject) = %" PRIuPTR " SgDimensionObject::pool_size = %d \n",
   19013             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDimensionObject),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDimensionObject),SgDimensionObject::pool_size);
   19014             :         }
   19015             : #endif
   19016             : 
   19017           0 :         SgDimensionObject * pointer = (SgDimensionObject*) ROSE_MALLOC ( SgDimensionObject::pool_size * sizeof(SgDimensionObject) );
   19018           0 :         assert( pointer != NULL );
   19019             : #if ROSE_ALLOC_MEMSET == 1
   19020             :         memset(pointer, 0x00, SgDimensionObject::pool_size * sizeof(SgDimensionObject));
   19021             : #elif ROSE_ALLOC_MEMSET == 2
   19022             :         memset(pointer, 0xCC, SgDimensionObject::pool_size * sizeof(SgDimensionObject));
   19023             : #endif
   19024           0 :         SgDimensionObject::pools.push_back( (unsigned char*)(pointer) );
   19025           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDimensionObject::pool_size * sizeof(SgDimensionObject), V_SgDimensionObject ) );
   19026             : 
   19027           0 :         if ( SgDimensionObject::next_node != NULL ) {
   19028           0 :           if ( blockIndex > 0 ) {
   19029           0 :             SgDimensionObject * blkptr = (SgDimensionObject*)(SgDimensionObject::pools[blockIndex-1]);
   19030           0 :             blkptr[ SgDimensionObject::pool_size - 1 ].set_freepointer(pointer);
   19031             :           }
   19032             :         } else {
   19033           0 :           SgDimensionObject::next_node = pointer;
   19034             :         }
   19035             : 
   19036           0 :         for (unsigned i = 0; i < SgDimensionObject::pool_size-1; ++i)
   19037             :            {
   19038           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   19039             :            }
   19040           0 :         pointer[ SgDimensionObject::pool_size -1 ].set_freepointer(NULL);
   19041             : 
   19042           0 :         blockIndex++;
   19043             :       }
   19044           2 :   }
   19045             : 
   19046             : //############################################################################
   19047             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   19048             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   19049             :  * not compressed. However, that stuff is not yet implemented! 
   19050             :  */
   19051             : unsigned long
   19052           0 : SgDimensionObject::getNumberOfLastValidPointer()
   19053             :    {
   19054           0 :       SgDimensionObject* testPointer = (SgDimensionObject*)(SgDimensionObject::pools.back());
   19055           0 :       unsigned long localIndex = SgDimensionObject::pool_size - 1;
   19056           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   19057             :          {
   19058           0 :            localIndex--;
   19059             :          }
   19060           0 :       return (localIndex + SgDimensionObject::pool_size * (SgDimensionObject::pools.size()-1));
   19061             :    }
   19062             : 
   19063             : //############################################################################
   19064             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   19065             :  * memory pool and initializes the data member in class SgDimensionObjectStroageClass
   19066             :  * from its counterpart of SgDimensionObject. The return value is just for checking, 
   19067             :  * that the whole StorageClassArray is initialized!
   19068             :  */
   19069             : unsigned long
   19070           0 : SgDimensionObject::initializeStorageClassArray( SgDimensionObjectStorageClass *storageArray )
   19071             :    {
   19072           0 :      unsigned long storageCounter = 0;
   19073           0 :      std::vector < unsigned char* > :: const_iterator block = SgDimensionObject::pools.begin();
   19074           0 :      SgDimensionObject* pointer = NULL;
   19075           0 :      while ( block != SgDimensionObject::pools.end() ) {
   19076           0 :           pointer = (SgDimensionObject*) (*block);
   19077           0 :           for ( unsigned i = 0; i < SgDimensionObject::pool_size; ++i ) {
   19078           0 :                if ( pointer->get_freepointer() != NULL ) {
   19079           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   19080           0 :                  storageArray++;
   19081           0 :                  storageCounter++;
   19082             :                }
   19083           0 :                pointer++;
   19084             :              }
   19085           0 :            block++;
   19086             :         }
   19087           0 :      return storageCounter;
   19088             :    }
   19089             : 
   19090             : /* #line 19091 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   19091             : 
   19092             : 
   19093             : 
   19094             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   19095             : 
   19096             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   19097             : 
   19098             : //############################################################################
   19099             : /* JH (02/02/2006) Constructor of the IR node SgFormatItem that takes its 
   19100             :  * corresponding StorageClass as parameter
   19101             :  */
   19102           0 : SgFormatItem :: SgFormatItem ( const SgFormatItemStorageClass& storageSource )   : SgSupport (storageSource)
   19103             :    {
   19104             : 
   19105             : 
   19106             : /* #line 19107 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   19107             : 
   19108           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   19109           0 :      p_repeat_specification = storageSource.storageOf_repeat_specification ;
   19110           0 :      p_data =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_data) );
   19111           0 :      p_format_item_list =  (SgFormatItemList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_format_item_list) );
   19112             : 
   19113             : 
   19114             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   19115             : 
   19116             : 
   19117           0 :    }
   19118             : 
   19119             : //############################################################################
   19120             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   19121             :  * within the working AST. 
   19122             :  */
   19123           0 : SgFormatItem * SgFormatItem::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   19124           0 :      SgFormatItem* returnPointer = NULL;
   19125           0 :      if ( globalIndex != 0 )
   19126             :         {
   19127             : 
   19128             : #if FILE_IO_EXTRA_CHECK
   19129           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFormatItem ) ) <= globalIndex ) ;
   19130           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFormatItem + 1 ) ) );
   19131             : #endif
   19132           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFormatItem )  
   19133           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFormatItem );
   19134           0 :           unsigned long positionInPool = localIndex % SgFormatItem::pool_size;
   19135           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFormatItem::pool_size;
   19136             : 
   19137             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   19138             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   19139             : 
   19140           0 :           returnPointer = &( ( (SgFormatItem*)(SgFormatItem::pools[memoryBlock]) ) [positionInPool]) ;
   19141             : 
   19142           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   19143             :         }
   19144           0 :      return returnPointer ;
   19145             :    }
   19146             : 
   19147             : //############################################################################
   19148             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   19149             :   for the AST with the index astIndex
   19150             : */
   19151           0 : SgFormatItem * SgFormatItem::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   19152           0 :      SgFormatItem* returnPointer = NULL;
   19153           0 :      if ( globalIndex != 0 )
   19154             :         {
   19155             : 
   19156             : #if FILE_IO_EXTRA_CHECK
   19157           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFormatItem ) ) <= globalIndex ) ;
   19158           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFormatItem + 1 ) ) );
   19159             : #endif
   19160           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFormatItem )
   19161           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFormatItem );
   19162           0 :           unsigned long positionInPool = localIndex % SgFormatItem::pool_size ;
   19163           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFormatItem::pool_size ;
   19164             : 
   19165             : #if FILE_IO_EXTRA_CHECK
   19166             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   19167             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   19168             : #endif
   19169             : 
   19170           0 :           returnPointer = &( ( (SgFormatItem*)(SgFormatItem::pools[memoryBlock]) ) [positionInPool]) ;
   19171             : 
   19172             : #if FILE_IO_EXTRA_CHECK
   19173           0 :           assert ( returnPointer != NULL ) ;
   19174             : #endif
   19175             :         }
   19176           0 :      return returnPointer ;
   19177             :    }
   19178             : 
   19179             : //############################################################################
   19180             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   19181             :  * pool size! We set for every valid object in the memory pool the freepointer
   19182             :  * to the global index and increase the global index afterwards. For all the 
   19183             :  * invalid objects (means address ranges within the memory pool that were not
   19184             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   19185             :  * distinguish valid from invalid objects! 
   19186             :  */
   19187             : unsigned long
   19188           5 : SgFormatItem::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   19189             :    {
   19190           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   19191           5 :      SgFormatItem* pointer = NULL;
   19192           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   19193           5 :      std::vector < unsigned char* > :: const_iterator block;
   19194           5 :      for ( block = SgFormatItem::pools.begin(); block != SgFormatItem::pools.end() ; ++block )
   19195             :         {
   19196           0 :           pointer = (SgFormatItem*)(*block);
   19197           0 :           for (unsigned i = 0; i < SgFormatItem::pool_size; ++i )
   19198             :              {
   19199             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   19200             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   19201             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   19202             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   19203             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   19204             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   19205             :             // properly; so this will have to be checked next.
   19206             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   19207             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   19208           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   19209             :                   {
   19210           0 :                     pointer[i].set_freepointer((SgFormatItem*)(globalIndex));
   19211           0 :                     globalIndex++;
   19212             :                   }
   19213             :                else
   19214             :                   {
   19215           0 :                     pointer[i].set_freepointer(NULL);
   19216             :                   }
   19217             :               }
   19218             :         }
   19219           5 :      return globalIndex;
   19220             :    }
   19221             : 
   19222             : //############################################################################
   19223             : // JH (01/14/2006)
   19224             : void
   19225           5 : SgFormatItem::resetValidFreepointers( )
   19226             :    {
   19227           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   19228           5 :      SgFormatItem* pointer = NULL;
   19229           5 :      std::vector < unsigned char* > :: const_iterator block;
   19230           5 :      SgFormatItem* pointerOfLinkedList = NULL;
   19231           5 :      for ( block = SgFormatItem::pools.begin(); block != SgFormatItem::pools.end() ; ++block )
   19232             :         {
   19233           0 :           pointer = (SgFormatItem*)(*block);
   19234           0 :           for (unsigned i = 0; i < SgFormatItem::pool_size; ++i )
   19235             :              {
   19236             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   19237             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   19238             :             // memory blocks!.
   19239           0 :                if ( pointer[i].get_freepointer() != NULL )
   19240             :                   {
   19241           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   19242             :                   }
   19243             :                else
   19244             :                   {
   19245           0 :                     if ( pointerOfLinkedList == NULL )
   19246             :                        {
   19247           0 :                          SgFormatItem::next_node = &(pointer[i]);
   19248             :                        }
   19249             :                     else
   19250             :                        {
   19251             :                       // printf ("In SgFormatItem::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   19252           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   19253             :                        }
   19254             :                     pointerOfLinkedList = &(pointer[i]);
   19255             :                   }
   19256             :               }
   19257             :         }
   19258             : 
   19259           5 :      if ( pointerOfLinkedList != NULL )
   19260             :         {
   19261             :        // printf ("In SgFormatItem::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   19262           0 :           pointerOfLinkedList->set_freepointer(NULL);
   19263             :        // DQ (6/6/2010): Temporary debugging...
   19264             :        //   ROSE_ASSERT(false);
   19265             :         }
   19266             : 
   19267           5 :      return ;
   19268             :    }
   19269             : 
   19270             : //############################################################################
   19271             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   19272             :  * within the memory pool and resets the freepointers, in order to achieve a 
   19273             :  * linked list, that has no jumps and starts at the beginning! This function 
   19274             :  * does not extend the memory pool, since we do not delete any memory blocks,
   19275             :  * but delete the valid objects.  
   19276             :  */
   19277             : void
   19278           0 : SgFormatItem::clearMemoryPool( )
   19279             :    {
   19280             :   // printf ("Inside of SgFormatItem::clearMemoryPool() \n");
   19281             : 
   19282           0 :      SgFormatItem* pointer = NULL, *tempPointer = NULL;
   19283           0 :      std::vector < unsigned char* > :: const_iterator block;
   19284           0 :      if ( SgFormatItem::pools.empty() == false )
   19285             :         {
   19286           0 :           block = SgFormatItem::pools.begin() ;
   19287           0 :           SgFormatItem::next_node = (SgFormatItem*) (*block);
   19288             : 
   19289           0 :           while ( block != SgFormatItem::pools.end() )
   19290             :              {
   19291           0 :                pointer = (SgFormatItem*) (*block);
   19292           0 :                if ( tempPointer != NULL )
   19293             :                   {
   19294           0 :                     tempPointer->set_freepointer(pointer);
   19295             :                   }
   19296           0 :                for (unsigned i = 0; i < SgFormatItem::pool_size - 1; ++i)
   19297             :                   {
   19298           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   19299             :                   }
   19300           0 :                 pointer[SgFormatItem::pool_size-1].set_freepointer(NULL);
   19301           0 :                 tempPointer = &(pointer[SgFormatItem::pool_size-1]);
   19302           0 :                 ++block;
   19303             :              }
   19304             :         }
   19305           0 :    }
   19306             : 
   19307           5 : void SgFormatItem::deleteMemoryPool() {
   19308           5 :   for (auto p: SgFormatItem::pools) {
   19309           0 :     ROSE_FREE(p);
   19310             :   }
   19311           5 :   SgFormatItem::next_node = nullptr;
   19312           5 :   SgFormatItem::pools.clear();
   19313           5 : }
   19314             : 
   19315             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   19316             : //                 reading multiple binary files to for a single AST.
   19317             : /////////// new version ////////////////////////////////
   19318             : //############################################################################
   19319             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   19320             : void
   19321           2 : SgFormatItem::extendMemoryPoolForFileIO( )
   19322             :   {
   19323           2 :     size_t blockIndex = SgFormatItem::pools.size();
   19324           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatItem) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatItem);
   19325             : 
   19326           2 :     while ( (blockIndex * SgFormatItem::pool_size) < newPoolSize)
   19327             :       {
   19328             : #if ROSE_ALLOC_TRACE
   19329             :         if (blockIndex > 0) {
   19330             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatItem) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatItem) = %" PRIuPTR " SgFormatItem::pool_size = %d \n",
   19331             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatItem),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatItem),SgFormatItem::pool_size);
   19332             :         }
   19333             : #endif
   19334             : 
   19335           0 :         SgFormatItem * pointer = (SgFormatItem*) ROSE_MALLOC ( SgFormatItem::pool_size * sizeof(SgFormatItem) );
   19336           0 :         assert( pointer != NULL );
   19337             : #if ROSE_ALLOC_MEMSET == 1
   19338             :         memset(pointer, 0x00, SgFormatItem::pool_size * sizeof(SgFormatItem));
   19339             : #elif ROSE_ALLOC_MEMSET == 2
   19340             :         memset(pointer, 0xCC, SgFormatItem::pool_size * sizeof(SgFormatItem));
   19341             : #endif
   19342           0 :         SgFormatItem::pools.push_back( (unsigned char*)(pointer) );
   19343           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFormatItem::pool_size * sizeof(SgFormatItem), V_SgFormatItem ) );
   19344             : 
   19345           0 :         if ( SgFormatItem::next_node != NULL ) {
   19346           0 :           if ( blockIndex > 0 ) {
   19347           0 :             SgFormatItem * blkptr = (SgFormatItem*)(SgFormatItem::pools[blockIndex-1]);
   19348           0 :             blkptr[ SgFormatItem::pool_size - 1 ].set_freepointer(pointer);
   19349             :           }
   19350             :         } else {
   19351           0 :           SgFormatItem::next_node = pointer;
   19352             :         }
   19353             : 
   19354           0 :         for (unsigned i = 0; i < SgFormatItem::pool_size-1; ++i)
   19355             :            {
   19356           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   19357             :            }
   19358           0 :         pointer[ SgFormatItem::pool_size -1 ].set_freepointer(NULL);
   19359             : 
   19360           0 :         blockIndex++;
   19361             :       }
   19362           2 :   }
   19363             : 
   19364             : //############################################################################
   19365             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   19366             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   19367             :  * not compressed. However, that stuff is not yet implemented! 
   19368             :  */
   19369             : unsigned long
   19370           0 : SgFormatItem::getNumberOfLastValidPointer()
   19371             :    {
   19372           0 :       SgFormatItem* testPointer = (SgFormatItem*)(SgFormatItem::pools.back());
   19373           0 :       unsigned long localIndex = SgFormatItem::pool_size - 1;
   19374           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   19375             :          {
   19376           0 :            localIndex--;
   19377             :          }
   19378           0 :       return (localIndex + SgFormatItem::pool_size * (SgFormatItem::pools.size()-1));
   19379             :    }
   19380             : 
   19381             : //############################################################################
   19382             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   19383             :  * memory pool and initializes the data member in class SgFormatItemStroageClass
   19384             :  * from its counterpart of SgFormatItem. The return value is just for checking, 
   19385             :  * that the whole StorageClassArray is initialized!
   19386             :  */
   19387             : unsigned long
   19388           0 : SgFormatItem::initializeStorageClassArray( SgFormatItemStorageClass *storageArray )
   19389             :    {
   19390           0 :      unsigned long storageCounter = 0;
   19391           0 :      std::vector < unsigned char* > :: const_iterator block = SgFormatItem::pools.begin();
   19392           0 :      SgFormatItem* pointer = NULL;
   19393           0 :      while ( block != SgFormatItem::pools.end() ) {
   19394           0 :           pointer = (SgFormatItem*) (*block);
   19395           0 :           for ( unsigned i = 0; i < SgFormatItem::pool_size; ++i ) {
   19396           0 :                if ( pointer->get_freepointer() != NULL ) {
   19397           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   19398           0 :                  storageArray++;
   19399           0 :                  storageCounter++;
   19400             :                }
   19401           0 :                pointer++;
   19402             :              }
   19403           0 :            block++;
   19404             :         }
   19405           0 :      return storageCounter;
   19406             :    }
   19407             : 
   19408             : /* #line 19409 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   19409             : 
   19410             : 
   19411             : 
   19412             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   19413             : 
   19414             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   19415             : 
   19416             : //############################################################################
   19417             : /* JH (02/02/2006) Constructor of the IR node SgFormatItemList that takes its 
   19418             :  * corresponding StorageClass as parameter
   19419             :  */
   19420           0 : SgFormatItemList :: SgFormatItemList ( const SgFormatItemListStorageClass& storageSource )   : SgSupport (storageSource)
   19421             :    {
   19422             : 
   19423             : 
   19424             : /* #line 19425 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   19425             : 
   19426           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   19427           0 :      p_format_item_list = storageSource.storageOf_format_item_list.rebuildDataStoredInEasyStorageClass() ;
   19428           0 :      SgFormatItemPtrList::iterator i_format_item_list = p_format_item_list.begin() ; 
   19429           0 :      for ( ; i_format_item_list != p_format_item_list.end(); ++i_format_item_list ) 
   19430             :         {
   19431           0 :           (*i_format_item_list) = (SgFormatItemPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_format_item_list) ) );
   19432             :         }
   19433             : 
   19434             : 
   19435             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   19436             : 
   19437             : 
   19438           0 :    }
   19439             : 
   19440             : //############################################################################
   19441             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   19442             :  * within the working AST. 
   19443             :  */
   19444           0 : SgFormatItemList * SgFormatItemList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   19445           0 :      SgFormatItemList* returnPointer = NULL;
   19446           0 :      if ( globalIndex != 0 )
   19447             :         {
   19448             : 
   19449             : #if FILE_IO_EXTRA_CHECK
   19450           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFormatItemList ) ) <= globalIndex ) ;
   19451           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFormatItemList + 1 ) ) );
   19452             : #endif
   19453           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFormatItemList )  
   19454           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFormatItemList );
   19455           0 :           unsigned long positionInPool = localIndex % SgFormatItemList::pool_size;
   19456           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFormatItemList::pool_size;
   19457             : 
   19458             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   19459             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   19460             : 
   19461           0 :           returnPointer = &( ( (SgFormatItemList*)(SgFormatItemList::pools[memoryBlock]) ) [positionInPool]) ;
   19462             : 
   19463           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   19464             :         }
   19465           0 :      return returnPointer ;
   19466             :    }
   19467             : 
   19468             : //############################################################################
   19469             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   19470             :   for the AST with the index astIndex
   19471             : */
   19472           0 : SgFormatItemList * SgFormatItemList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   19473           0 :      SgFormatItemList* returnPointer = NULL;
   19474           0 :      if ( globalIndex != 0 )
   19475             :         {
   19476             : 
   19477             : #if FILE_IO_EXTRA_CHECK
   19478           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFormatItemList ) ) <= globalIndex ) ;
   19479           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFormatItemList + 1 ) ) );
   19480             : #endif
   19481           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFormatItemList )
   19482           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFormatItemList );
   19483           0 :           unsigned long positionInPool = localIndex % SgFormatItemList::pool_size ;
   19484           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFormatItemList::pool_size ;
   19485             : 
   19486             : #if FILE_IO_EXTRA_CHECK
   19487             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   19488             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   19489             : #endif
   19490             : 
   19491           0 :           returnPointer = &( ( (SgFormatItemList*)(SgFormatItemList::pools[memoryBlock]) ) [positionInPool]) ;
   19492             : 
   19493             : #if FILE_IO_EXTRA_CHECK
   19494           0 :           assert ( returnPointer != NULL ) ;
   19495             : #endif
   19496             :         }
   19497           0 :      return returnPointer ;
   19498             :    }
   19499             : 
   19500             : //############################################################################
   19501             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   19502             :  * pool size! We set for every valid object in the memory pool the freepointer
   19503             :  * to the global index and increase the global index afterwards. For all the 
   19504             :  * invalid objects (means address ranges within the memory pool that were not
   19505             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   19506             :  * distinguish valid from invalid objects! 
   19507             :  */
   19508             : unsigned long
   19509           5 : SgFormatItemList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   19510             :    {
   19511           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   19512           5 :      SgFormatItemList* pointer = NULL;
   19513           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   19514           5 :      std::vector < unsigned char* > :: const_iterator block;
   19515           5 :      for ( block = SgFormatItemList::pools.begin(); block != SgFormatItemList::pools.end() ; ++block )
   19516             :         {
   19517           0 :           pointer = (SgFormatItemList*)(*block);
   19518           0 :           for (unsigned i = 0; i < SgFormatItemList::pool_size; ++i )
   19519             :              {
   19520             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   19521             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   19522             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   19523             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   19524             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   19525             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   19526             :             // properly; so this will have to be checked next.
   19527             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   19528             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   19529           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   19530             :                   {
   19531           0 :                     pointer[i].set_freepointer((SgFormatItemList*)(globalIndex));
   19532           0 :                     globalIndex++;
   19533             :                   }
   19534             :                else
   19535             :                   {
   19536           0 :                     pointer[i].set_freepointer(NULL);
   19537             :                   }
   19538             :               }
   19539             :         }
   19540           5 :      return globalIndex;
   19541             :    }
   19542             : 
   19543             : //############################################################################
   19544             : // JH (01/14/2006)
   19545             : void
   19546           5 : SgFormatItemList::resetValidFreepointers( )
   19547             :    {
   19548           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   19549           5 :      SgFormatItemList* pointer = NULL;
   19550           5 :      std::vector < unsigned char* > :: const_iterator block;
   19551           5 :      SgFormatItemList* pointerOfLinkedList = NULL;
   19552           5 :      for ( block = SgFormatItemList::pools.begin(); block != SgFormatItemList::pools.end() ; ++block )
   19553             :         {
   19554           0 :           pointer = (SgFormatItemList*)(*block);
   19555           0 :           for (unsigned i = 0; i < SgFormatItemList::pool_size; ++i )
   19556             :              {
   19557             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   19558             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   19559             :             // memory blocks!.
   19560           0 :                if ( pointer[i].get_freepointer() != NULL )
   19561             :                   {
   19562           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   19563             :                   }
   19564             :                else
   19565             :                   {
   19566           0 :                     if ( pointerOfLinkedList == NULL )
   19567             :                        {
   19568           0 :                          SgFormatItemList::next_node = &(pointer[i]);
   19569             :                        }
   19570             :                     else
   19571             :                        {
   19572             :                       // printf ("In SgFormatItemList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   19573           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   19574             :                        }
   19575             :                     pointerOfLinkedList = &(pointer[i]);
   19576             :                   }
   19577             :               }
   19578             :         }
   19579             : 
   19580           5 :      if ( pointerOfLinkedList != NULL )
   19581             :         {
   19582             :        // printf ("In SgFormatItemList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   19583           0 :           pointerOfLinkedList->set_freepointer(NULL);
   19584             :        // DQ (6/6/2010): Temporary debugging...
   19585             :        //   ROSE_ASSERT(false);
   19586             :         }
   19587             : 
   19588           5 :      return ;
   19589             :    }
   19590             : 
   19591             : //############################################################################
   19592             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   19593             :  * within the memory pool and resets the freepointers, in order to achieve a 
   19594             :  * linked list, that has no jumps and starts at the beginning! This function 
   19595             :  * does not extend the memory pool, since we do not delete any memory blocks,
   19596             :  * but delete the valid objects.  
   19597             :  */
   19598             : void
   19599           0 : SgFormatItemList::clearMemoryPool( )
   19600             :    {
   19601             :   // printf ("Inside of SgFormatItemList::clearMemoryPool() \n");
   19602             : 
   19603           0 :      SgFormatItemList* pointer = NULL, *tempPointer = NULL;
   19604           0 :      std::vector < unsigned char* > :: const_iterator block;
   19605           0 :      if ( SgFormatItemList::pools.empty() == false )
   19606             :         {
   19607           0 :           block = SgFormatItemList::pools.begin() ;
   19608           0 :           SgFormatItemList::next_node = (SgFormatItemList*) (*block);
   19609             : 
   19610           0 :           while ( block != SgFormatItemList::pools.end() )
   19611             :              {
   19612           0 :                pointer = (SgFormatItemList*) (*block);
   19613           0 :                if ( tempPointer != NULL )
   19614             :                   {
   19615           0 :                     tempPointer->set_freepointer(pointer);
   19616             :                   }
   19617           0 :                for (unsigned i = 0; i < SgFormatItemList::pool_size - 1; ++i)
   19618             :                   {
   19619           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   19620             :                   }
   19621           0 :                 pointer[SgFormatItemList::pool_size-1].set_freepointer(NULL);
   19622           0 :                 tempPointer = &(pointer[SgFormatItemList::pool_size-1]);
   19623           0 :                 ++block;
   19624             :              }
   19625             :         }
   19626           0 :    }
   19627             : 
   19628           5 : void SgFormatItemList::deleteMemoryPool() {
   19629           5 :   for (auto p: SgFormatItemList::pools) {
   19630           0 :     ROSE_FREE(p);
   19631             :   }
   19632           5 :   SgFormatItemList::next_node = nullptr;
   19633           5 :   SgFormatItemList::pools.clear();
   19634           5 : }
   19635             : 
   19636             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   19637             : //                 reading multiple binary files to for a single AST.
   19638             : /////////// new version ////////////////////////////////
   19639             : //############################################################################
   19640             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   19641             : void
   19642           2 : SgFormatItemList::extendMemoryPoolForFileIO( )
   19643             :   {
   19644           2 :     size_t blockIndex = SgFormatItemList::pools.size();
   19645           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatItemList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatItemList);
   19646             : 
   19647           2 :     while ( (blockIndex * SgFormatItemList::pool_size) < newPoolSize)
   19648             :       {
   19649             : #if ROSE_ALLOC_TRACE
   19650             :         if (blockIndex > 0) {
   19651             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatItemList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatItemList) = %" PRIuPTR " SgFormatItemList::pool_size = %d \n",
   19652             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatItemList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatItemList),SgFormatItemList::pool_size);
   19653             :         }
   19654             : #endif
   19655             : 
   19656           0 :         SgFormatItemList * pointer = (SgFormatItemList*) ROSE_MALLOC ( SgFormatItemList::pool_size * sizeof(SgFormatItemList) );
   19657           0 :         assert( pointer != NULL );
   19658             : #if ROSE_ALLOC_MEMSET == 1
   19659             :         memset(pointer, 0x00, SgFormatItemList::pool_size * sizeof(SgFormatItemList));
   19660             : #elif ROSE_ALLOC_MEMSET == 2
   19661             :         memset(pointer, 0xCC, SgFormatItemList::pool_size * sizeof(SgFormatItemList));
   19662             : #endif
   19663           0 :         SgFormatItemList::pools.push_back( (unsigned char*)(pointer) );
   19664           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFormatItemList::pool_size * sizeof(SgFormatItemList), V_SgFormatItemList ) );
   19665             : 
   19666           0 :         if ( SgFormatItemList::next_node != NULL ) {
   19667           0 :           if ( blockIndex > 0 ) {
   19668           0 :             SgFormatItemList * blkptr = (SgFormatItemList*)(SgFormatItemList::pools[blockIndex-1]);
   19669           0 :             blkptr[ SgFormatItemList::pool_size - 1 ].set_freepointer(pointer);
   19670             :           }
   19671             :         } else {
   19672           0 :           SgFormatItemList::next_node = pointer;
   19673             :         }
   19674             : 
   19675           0 :         for (unsigned i = 0; i < SgFormatItemList::pool_size-1; ++i)
   19676             :            {
   19677           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   19678             :            }
   19679           0 :         pointer[ SgFormatItemList::pool_size -1 ].set_freepointer(NULL);
   19680             : 
   19681           0 :         blockIndex++;
   19682             :       }
   19683           2 :   }
   19684             : 
   19685             : //############################################################################
   19686             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   19687             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   19688             :  * not compressed. However, that stuff is not yet implemented! 
   19689             :  */
   19690             : unsigned long
   19691           0 : SgFormatItemList::getNumberOfLastValidPointer()
   19692             :    {
   19693           0 :       SgFormatItemList* testPointer = (SgFormatItemList*)(SgFormatItemList::pools.back());
   19694           0 :       unsigned long localIndex = SgFormatItemList::pool_size - 1;
   19695           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   19696             :          {
   19697           0 :            localIndex--;
   19698             :          }
   19699           0 :       return (localIndex + SgFormatItemList::pool_size * (SgFormatItemList::pools.size()-1));
   19700             :    }
   19701             : 
   19702             : //############################################################################
   19703             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   19704             :  * memory pool and initializes the data member in class SgFormatItemListStroageClass
   19705             :  * from its counterpart of SgFormatItemList. The return value is just for checking, 
   19706             :  * that the whole StorageClassArray is initialized!
   19707             :  */
   19708             : unsigned long
   19709           0 : SgFormatItemList::initializeStorageClassArray( SgFormatItemListStorageClass *storageArray )
   19710             :    {
   19711           0 :      unsigned long storageCounter = 0;
   19712           0 :      std::vector < unsigned char* > :: const_iterator block = SgFormatItemList::pools.begin();
   19713           0 :      SgFormatItemList* pointer = NULL;
   19714           0 :      while ( block != SgFormatItemList::pools.end() ) {
   19715           0 :           pointer = (SgFormatItemList*) (*block);
   19716           0 :           for ( unsigned i = 0; i < SgFormatItemList::pool_size; ++i ) {
   19717           0 :                if ( pointer->get_freepointer() != NULL ) {
   19718           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   19719           0 :                  storageArray++;
   19720           0 :                  storageCounter++;
   19721             :                }
   19722           0 :                pointer++;
   19723             :              }
   19724           0 :            block++;
   19725             :         }
   19726           0 :      return storageCounter;
   19727             :    }
   19728             : 
   19729             : /* #line 19730 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   19730             : 
   19731             : 
   19732             : 
   19733             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   19734             : 
   19735             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   19736             : 
   19737             : //############################################################################
   19738             : /* JH (02/02/2006) Constructor of the IR node SgDataStatementGroup that takes its 
   19739             :  * corresponding StorageClass as parameter
   19740             :  */
   19741           0 : SgDataStatementGroup :: SgDataStatementGroup ( const SgDataStatementGroupStorageClass& storageSource )   : SgSupport (storageSource)
   19742             :    {
   19743             : 
   19744             : 
   19745             : /* #line 19746 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   19746             : 
   19747           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   19748           0 :      p_object_list = storageSource.storageOf_object_list.rebuildDataStoredInEasyStorageClass() ;
   19749           0 :      SgDataStatementObjectPtrList::iterator i_object_list = p_object_list.begin() ; 
   19750           0 :      for ( ; i_object_list != p_object_list.end(); ++i_object_list ) 
   19751             :         {
   19752           0 :           (*i_object_list) = (SgDataStatementObjectPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_object_list) ) );
   19753             :         }
   19754           0 :      p_value_list = storageSource.storageOf_value_list.rebuildDataStoredInEasyStorageClass() ;
   19755           0 :      SgDataStatementValuePtrList::iterator i_value_list = p_value_list.begin() ; 
   19756           0 :      for ( ; i_value_list != p_value_list.end(); ++i_value_list ) 
   19757             :         {
   19758           0 :           (*i_value_list) = (SgDataStatementValuePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_value_list) ) );
   19759             :         }
   19760             : 
   19761             : 
   19762             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   19763             : 
   19764             : 
   19765           0 :    }
   19766             : 
   19767             : //############################################################################
   19768             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   19769             :  * within the working AST. 
   19770             :  */
   19771           0 : SgDataStatementGroup * SgDataStatementGroup::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   19772           0 :      SgDataStatementGroup* returnPointer = NULL;
   19773           0 :      if ( globalIndex != 0 )
   19774             :         {
   19775             : 
   19776             : #if FILE_IO_EXTRA_CHECK
   19777           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDataStatementGroup ) ) <= globalIndex ) ;
   19778           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDataStatementGroup + 1 ) ) );
   19779             : #endif
   19780           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDataStatementGroup )  
   19781           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDataStatementGroup );
   19782           0 :           unsigned long positionInPool = localIndex % SgDataStatementGroup::pool_size;
   19783           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDataStatementGroup::pool_size;
   19784             : 
   19785             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   19786             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   19787             : 
   19788           0 :           returnPointer = &( ( (SgDataStatementGroup*)(SgDataStatementGroup::pools[memoryBlock]) ) [positionInPool]) ;
   19789             : 
   19790           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   19791             :         }
   19792           0 :      return returnPointer ;
   19793             :    }
   19794             : 
   19795             : //############################################################################
   19796             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   19797             :   for the AST with the index astIndex
   19798             : */
   19799           0 : SgDataStatementGroup * SgDataStatementGroup::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   19800           0 :      SgDataStatementGroup* returnPointer = NULL;
   19801           0 :      if ( globalIndex != 0 )
   19802             :         {
   19803             : 
   19804             : #if FILE_IO_EXTRA_CHECK
   19805           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDataStatementGroup ) ) <= globalIndex ) ;
   19806           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDataStatementGroup + 1 ) ) );
   19807             : #endif
   19808           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDataStatementGroup )
   19809           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDataStatementGroup );
   19810           0 :           unsigned long positionInPool = localIndex % SgDataStatementGroup::pool_size ;
   19811           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDataStatementGroup::pool_size ;
   19812             : 
   19813             : #if FILE_IO_EXTRA_CHECK
   19814             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   19815             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   19816             : #endif
   19817             : 
   19818           0 :           returnPointer = &( ( (SgDataStatementGroup*)(SgDataStatementGroup::pools[memoryBlock]) ) [positionInPool]) ;
   19819             : 
   19820             : #if FILE_IO_EXTRA_CHECK
   19821           0 :           assert ( returnPointer != NULL ) ;
   19822             : #endif
   19823             :         }
   19824           0 :      return returnPointer ;
   19825             :    }
   19826             : 
   19827             : //############################################################################
   19828             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   19829             :  * pool size! We set for every valid object in the memory pool the freepointer
   19830             :  * to the global index and increase the global index afterwards. For all the 
   19831             :  * invalid objects (means address ranges within the memory pool that were not
   19832             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   19833             :  * distinguish valid from invalid objects! 
   19834             :  */
   19835             : unsigned long
   19836           5 : SgDataStatementGroup::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   19837             :    {
   19838           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   19839           5 :      SgDataStatementGroup* pointer = NULL;
   19840           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   19841           5 :      std::vector < unsigned char* > :: const_iterator block;
   19842           5 :      for ( block = SgDataStatementGroup::pools.begin(); block != SgDataStatementGroup::pools.end() ; ++block )
   19843             :         {
   19844           0 :           pointer = (SgDataStatementGroup*)(*block);
   19845           0 :           for (unsigned i = 0; i < SgDataStatementGroup::pool_size; ++i )
   19846             :              {
   19847             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   19848             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   19849             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   19850             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   19851             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   19852             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   19853             :             // properly; so this will have to be checked next.
   19854             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   19855             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   19856           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   19857             :                   {
   19858           0 :                     pointer[i].set_freepointer((SgDataStatementGroup*)(globalIndex));
   19859           0 :                     globalIndex++;
   19860             :                   }
   19861             :                else
   19862             :                   {
   19863           0 :                     pointer[i].set_freepointer(NULL);
   19864             :                   }
   19865             :               }
   19866             :         }
   19867           5 :      return globalIndex;
   19868             :    }
   19869             : 
   19870             : //############################################################################
   19871             : // JH (01/14/2006)
   19872             : void
   19873           5 : SgDataStatementGroup::resetValidFreepointers( )
   19874             :    {
   19875           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   19876           5 :      SgDataStatementGroup* pointer = NULL;
   19877           5 :      std::vector < unsigned char* > :: const_iterator block;
   19878           5 :      SgDataStatementGroup* pointerOfLinkedList = NULL;
   19879           5 :      for ( block = SgDataStatementGroup::pools.begin(); block != SgDataStatementGroup::pools.end() ; ++block )
   19880             :         {
   19881           0 :           pointer = (SgDataStatementGroup*)(*block);
   19882           0 :           for (unsigned i = 0; i < SgDataStatementGroup::pool_size; ++i )
   19883             :              {
   19884             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   19885             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   19886             :             // memory blocks!.
   19887           0 :                if ( pointer[i].get_freepointer() != NULL )
   19888             :                   {
   19889           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   19890             :                   }
   19891             :                else
   19892             :                   {
   19893           0 :                     if ( pointerOfLinkedList == NULL )
   19894             :                        {
   19895           0 :                          SgDataStatementGroup::next_node = &(pointer[i]);
   19896             :                        }
   19897             :                     else
   19898             :                        {
   19899             :                       // printf ("In SgDataStatementGroup::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   19900           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   19901             :                        }
   19902             :                     pointerOfLinkedList = &(pointer[i]);
   19903             :                   }
   19904             :               }
   19905             :         }
   19906             : 
   19907           5 :      if ( pointerOfLinkedList != NULL )
   19908             :         {
   19909             :        // printf ("In SgDataStatementGroup::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   19910           0 :           pointerOfLinkedList->set_freepointer(NULL);
   19911             :        // DQ (6/6/2010): Temporary debugging...
   19912             :        //   ROSE_ASSERT(false);
   19913             :         }
   19914             : 
   19915           5 :      return ;
   19916             :    }
   19917             : 
   19918             : //############################################################################
   19919             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   19920             :  * within the memory pool and resets the freepointers, in order to achieve a 
   19921             :  * linked list, that has no jumps and starts at the beginning! This function 
   19922             :  * does not extend the memory pool, since we do not delete any memory blocks,
   19923             :  * but delete the valid objects.  
   19924             :  */
   19925             : void
   19926           0 : SgDataStatementGroup::clearMemoryPool( )
   19927             :    {
   19928             :   // printf ("Inside of SgDataStatementGroup::clearMemoryPool() \n");
   19929             : 
   19930           0 :      SgDataStatementGroup* pointer = NULL, *tempPointer = NULL;
   19931           0 :      std::vector < unsigned char* > :: const_iterator block;
   19932           0 :      if ( SgDataStatementGroup::pools.empty() == false )
   19933             :         {
   19934           0 :           block = SgDataStatementGroup::pools.begin() ;
   19935           0 :           SgDataStatementGroup::next_node = (SgDataStatementGroup*) (*block);
   19936             : 
   19937           0 :           while ( block != SgDataStatementGroup::pools.end() )
   19938             :              {
   19939           0 :                pointer = (SgDataStatementGroup*) (*block);
   19940           0 :                if ( tempPointer != NULL )
   19941             :                   {
   19942           0 :                     tempPointer->set_freepointer(pointer);
   19943             :                   }
   19944           0 :                for (unsigned i = 0; i < SgDataStatementGroup::pool_size - 1; ++i)
   19945             :                   {
   19946           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   19947             :                   }
   19948           0 :                 pointer[SgDataStatementGroup::pool_size-1].set_freepointer(NULL);
   19949           0 :                 tempPointer = &(pointer[SgDataStatementGroup::pool_size-1]);
   19950           0 :                 ++block;
   19951             :              }
   19952             :         }
   19953           0 :    }
   19954             : 
   19955           5 : void SgDataStatementGroup::deleteMemoryPool() {
   19956           5 :   for (auto p: SgDataStatementGroup::pools) {
   19957           0 :     ROSE_FREE(p);
   19958             :   }
   19959           5 :   SgDataStatementGroup::next_node = nullptr;
   19960           5 :   SgDataStatementGroup::pools.clear();
   19961           5 : }
   19962             : 
   19963             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   19964             : //                 reading multiple binary files to for a single AST.
   19965             : /////////// new version ////////////////////////////////
   19966             : //############################################################################
   19967             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   19968             : void
   19969           2 : SgDataStatementGroup::extendMemoryPoolForFileIO( )
   19970             :   {
   19971           2 :     size_t blockIndex = SgDataStatementGroup::pools.size();
   19972           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementGroup) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementGroup);
   19973             : 
   19974           2 :     while ( (blockIndex * SgDataStatementGroup::pool_size) < newPoolSize)
   19975             :       {
   19976             : #if ROSE_ALLOC_TRACE
   19977             :         if (blockIndex > 0) {
   19978             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementGroup) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementGroup) = %" PRIuPTR " SgDataStatementGroup::pool_size = %d \n",
   19979             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementGroup),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementGroup),SgDataStatementGroup::pool_size);
   19980             :         }
   19981             : #endif
   19982             : 
   19983           0 :         SgDataStatementGroup * pointer = (SgDataStatementGroup*) ROSE_MALLOC ( SgDataStatementGroup::pool_size * sizeof(SgDataStatementGroup) );
   19984           0 :         assert( pointer != NULL );
   19985             : #if ROSE_ALLOC_MEMSET == 1
   19986             :         memset(pointer, 0x00, SgDataStatementGroup::pool_size * sizeof(SgDataStatementGroup));
   19987             : #elif ROSE_ALLOC_MEMSET == 2
   19988             :         memset(pointer, 0xCC, SgDataStatementGroup::pool_size * sizeof(SgDataStatementGroup));
   19989             : #endif
   19990           0 :         SgDataStatementGroup::pools.push_back( (unsigned char*)(pointer) );
   19991           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDataStatementGroup::pool_size * sizeof(SgDataStatementGroup), V_SgDataStatementGroup ) );
   19992             : 
   19993           0 :         if ( SgDataStatementGroup::next_node != NULL ) {
   19994           0 :           if ( blockIndex > 0 ) {
   19995           0 :             SgDataStatementGroup * blkptr = (SgDataStatementGroup*)(SgDataStatementGroup::pools[blockIndex-1]);
   19996           0 :             blkptr[ SgDataStatementGroup::pool_size - 1 ].set_freepointer(pointer);
   19997             :           }
   19998             :         } else {
   19999           0 :           SgDataStatementGroup::next_node = pointer;
   20000             :         }
   20001             : 
   20002           0 :         for (unsigned i = 0; i < SgDataStatementGroup::pool_size-1; ++i)
   20003             :            {
   20004           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   20005             :            }
   20006           0 :         pointer[ SgDataStatementGroup::pool_size -1 ].set_freepointer(NULL);
   20007             : 
   20008           0 :         blockIndex++;
   20009             :       }
   20010           2 :   }
   20011             : 
   20012             : //############################################################################
   20013             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   20014             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   20015             :  * not compressed. However, that stuff is not yet implemented! 
   20016             :  */
   20017             : unsigned long
   20018           0 : SgDataStatementGroup::getNumberOfLastValidPointer()
   20019             :    {
   20020           0 :       SgDataStatementGroup* testPointer = (SgDataStatementGroup*)(SgDataStatementGroup::pools.back());
   20021           0 :       unsigned long localIndex = SgDataStatementGroup::pool_size - 1;
   20022           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   20023             :          {
   20024           0 :            localIndex--;
   20025             :          }
   20026           0 :       return (localIndex + SgDataStatementGroup::pool_size * (SgDataStatementGroup::pools.size()-1));
   20027             :    }
   20028             : 
   20029             : //############################################################################
   20030             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   20031             :  * memory pool and initializes the data member in class SgDataStatementGroupStroageClass
   20032             :  * from its counterpart of SgDataStatementGroup. The return value is just for checking, 
   20033             :  * that the whole StorageClassArray is initialized!
   20034             :  */
   20035             : unsigned long
   20036           0 : SgDataStatementGroup::initializeStorageClassArray( SgDataStatementGroupStorageClass *storageArray )
   20037             :    {
   20038           0 :      unsigned long storageCounter = 0;
   20039           0 :      std::vector < unsigned char* > :: const_iterator block = SgDataStatementGroup::pools.begin();
   20040           0 :      SgDataStatementGroup* pointer = NULL;
   20041           0 :      while ( block != SgDataStatementGroup::pools.end() ) {
   20042           0 :           pointer = (SgDataStatementGroup*) (*block);
   20043           0 :           for ( unsigned i = 0; i < SgDataStatementGroup::pool_size; ++i ) {
   20044           0 :                if ( pointer->get_freepointer() != NULL ) {
   20045           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   20046           0 :                  storageArray++;
   20047           0 :                  storageCounter++;
   20048             :                }
   20049           0 :                pointer++;
   20050             :              }
   20051           0 :            block++;
   20052             :         }
   20053           0 :      return storageCounter;
   20054             :    }
   20055             : 
   20056             : /* #line 20057 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   20057             : 
   20058             : 
   20059             : 
   20060             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   20061             : 
   20062             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   20063             : 
   20064             : //############################################################################
   20065             : /* JH (02/02/2006) Constructor of the IR node SgDataStatementObject that takes its 
   20066             :  * corresponding StorageClass as parameter
   20067             :  */
   20068           0 : SgDataStatementObject :: SgDataStatementObject ( const SgDataStatementObjectStorageClass& storageSource )   : SgSupport (storageSource)
   20069             :    {
   20070             : 
   20071             : 
   20072             : /* #line 20073 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   20073             : 
   20074           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   20075           0 :      p_variableReference_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_variableReference_list) );
   20076             : 
   20077             : 
   20078             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   20079             : 
   20080             : 
   20081           0 :    }
   20082             : 
   20083             : //############################################################################
   20084             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   20085             :  * within the working AST. 
   20086             :  */
   20087           0 : SgDataStatementObject * SgDataStatementObject::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   20088           0 :      SgDataStatementObject* returnPointer = NULL;
   20089           0 :      if ( globalIndex != 0 )
   20090             :         {
   20091             : 
   20092             : #if FILE_IO_EXTRA_CHECK
   20093           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDataStatementObject ) ) <= globalIndex ) ;
   20094           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDataStatementObject + 1 ) ) );
   20095             : #endif
   20096           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDataStatementObject )  
   20097           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDataStatementObject );
   20098           0 :           unsigned long positionInPool = localIndex % SgDataStatementObject::pool_size;
   20099           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDataStatementObject::pool_size;
   20100             : 
   20101             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   20102             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   20103             : 
   20104           0 :           returnPointer = &( ( (SgDataStatementObject*)(SgDataStatementObject::pools[memoryBlock]) ) [positionInPool]) ;
   20105             : 
   20106           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   20107             :         }
   20108           0 :      return returnPointer ;
   20109             :    }
   20110             : 
   20111             : //############################################################################
   20112             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   20113             :   for the AST with the index astIndex
   20114             : */
   20115           0 : SgDataStatementObject * SgDataStatementObject::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   20116           0 :      SgDataStatementObject* returnPointer = NULL;
   20117           0 :      if ( globalIndex != 0 )
   20118             :         {
   20119             : 
   20120             : #if FILE_IO_EXTRA_CHECK
   20121           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDataStatementObject ) ) <= globalIndex ) ;
   20122           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDataStatementObject + 1 ) ) );
   20123             : #endif
   20124           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDataStatementObject )
   20125           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDataStatementObject );
   20126           0 :           unsigned long positionInPool = localIndex % SgDataStatementObject::pool_size ;
   20127           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDataStatementObject::pool_size ;
   20128             : 
   20129             : #if FILE_IO_EXTRA_CHECK
   20130             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   20131             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   20132             : #endif
   20133             : 
   20134           0 :           returnPointer = &( ( (SgDataStatementObject*)(SgDataStatementObject::pools[memoryBlock]) ) [positionInPool]) ;
   20135             : 
   20136             : #if FILE_IO_EXTRA_CHECK
   20137           0 :           assert ( returnPointer != NULL ) ;
   20138             : #endif
   20139             :         }
   20140           0 :      return returnPointer ;
   20141             :    }
   20142             : 
   20143             : //############################################################################
   20144             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   20145             :  * pool size! We set for every valid object in the memory pool the freepointer
   20146             :  * to the global index and increase the global index afterwards. For all the 
   20147             :  * invalid objects (means address ranges within the memory pool that were not
   20148             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   20149             :  * distinguish valid from invalid objects! 
   20150             :  */
   20151             : unsigned long
   20152           5 : SgDataStatementObject::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   20153             :    {
   20154           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   20155           5 :      SgDataStatementObject* pointer = NULL;
   20156           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   20157           5 :      std::vector < unsigned char* > :: const_iterator block;
   20158           5 :      for ( block = SgDataStatementObject::pools.begin(); block != SgDataStatementObject::pools.end() ; ++block )
   20159             :         {
   20160           0 :           pointer = (SgDataStatementObject*)(*block);
   20161           0 :           for (unsigned i = 0; i < SgDataStatementObject::pool_size; ++i )
   20162             :              {
   20163             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   20164             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   20165             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   20166             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   20167             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   20168             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   20169             :             // properly; so this will have to be checked next.
   20170             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   20171             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   20172           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   20173             :                   {
   20174           0 :                     pointer[i].set_freepointer((SgDataStatementObject*)(globalIndex));
   20175           0 :                     globalIndex++;
   20176             :                   }
   20177             :                else
   20178             :                   {
   20179           0 :                     pointer[i].set_freepointer(NULL);
   20180             :                   }
   20181             :               }
   20182             :         }
   20183           5 :      return globalIndex;
   20184             :    }
   20185             : 
   20186             : //############################################################################
   20187             : // JH (01/14/2006)
   20188             : void
   20189           5 : SgDataStatementObject::resetValidFreepointers( )
   20190             :    {
   20191           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   20192           5 :      SgDataStatementObject* pointer = NULL;
   20193           5 :      std::vector < unsigned char* > :: const_iterator block;
   20194           5 :      SgDataStatementObject* pointerOfLinkedList = NULL;
   20195           5 :      for ( block = SgDataStatementObject::pools.begin(); block != SgDataStatementObject::pools.end() ; ++block )
   20196             :         {
   20197           0 :           pointer = (SgDataStatementObject*)(*block);
   20198           0 :           for (unsigned i = 0; i < SgDataStatementObject::pool_size; ++i )
   20199             :              {
   20200             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   20201             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   20202             :             // memory blocks!.
   20203           0 :                if ( pointer[i].get_freepointer() != NULL )
   20204             :                   {
   20205           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   20206             :                   }
   20207             :                else
   20208             :                   {
   20209           0 :                     if ( pointerOfLinkedList == NULL )
   20210             :                        {
   20211           0 :                          SgDataStatementObject::next_node = &(pointer[i]);
   20212             :                        }
   20213             :                     else
   20214             :                        {
   20215             :                       // printf ("In SgDataStatementObject::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   20216           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   20217             :                        }
   20218             :                     pointerOfLinkedList = &(pointer[i]);
   20219             :                   }
   20220             :               }
   20221             :         }
   20222             : 
   20223           5 :      if ( pointerOfLinkedList != NULL )
   20224             :         {
   20225             :        // printf ("In SgDataStatementObject::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   20226           0 :           pointerOfLinkedList->set_freepointer(NULL);
   20227             :        // DQ (6/6/2010): Temporary debugging...
   20228             :        //   ROSE_ASSERT(false);
   20229             :         }
   20230             : 
   20231           5 :      return ;
   20232             :    }
   20233             : 
   20234             : //############################################################################
   20235             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   20236             :  * within the memory pool and resets the freepointers, in order to achieve a 
   20237             :  * linked list, that has no jumps and starts at the beginning! This function 
   20238             :  * does not extend the memory pool, since we do not delete any memory blocks,
   20239             :  * but delete the valid objects.  
   20240             :  */
   20241             : void
   20242           0 : SgDataStatementObject::clearMemoryPool( )
   20243             :    {
   20244             :   // printf ("Inside of SgDataStatementObject::clearMemoryPool() \n");
   20245             : 
   20246           0 :      SgDataStatementObject* pointer = NULL, *tempPointer = NULL;
   20247           0 :      std::vector < unsigned char* > :: const_iterator block;
   20248           0 :      if ( SgDataStatementObject::pools.empty() == false )
   20249             :         {
   20250           0 :           block = SgDataStatementObject::pools.begin() ;
   20251           0 :           SgDataStatementObject::next_node = (SgDataStatementObject*) (*block);
   20252             : 
   20253           0 :           while ( block != SgDataStatementObject::pools.end() )
   20254             :              {
   20255           0 :                pointer = (SgDataStatementObject*) (*block);
   20256           0 :                if ( tempPointer != NULL )
   20257             :                   {
   20258           0 :                     tempPointer->set_freepointer(pointer);
   20259             :                   }
   20260           0 :                for (unsigned i = 0; i < SgDataStatementObject::pool_size - 1; ++i)
   20261             :                   {
   20262           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   20263             :                   }
   20264           0 :                 pointer[SgDataStatementObject::pool_size-1].set_freepointer(NULL);
   20265           0 :                 tempPointer = &(pointer[SgDataStatementObject::pool_size-1]);
   20266           0 :                 ++block;
   20267             :              }
   20268             :         }
   20269           0 :    }
   20270             : 
   20271           5 : void SgDataStatementObject::deleteMemoryPool() {
   20272           5 :   for (auto p: SgDataStatementObject::pools) {
   20273           0 :     ROSE_FREE(p);
   20274             :   }
   20275           5 :   SgDataStatementObject::next_node = nullptr;
   20276           5 :   SgDataStatementObject::pools.clear();
   20277           5 : }
   20278             : 
   20279             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   20280             : //                 reading multiple binary files to for a single AST.
   20281             : /////////// new version ////////////////////////////////
   20282             : //############################################################################
   20283             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   20284             : void
   20285           2 : SgDataStatementObject::extendMemoryPoolForFileIO( )
   20286             :   {
   20287           2 :     size_t blockIndex = SgDataStatementObject::pools.size();
   20288           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementObject) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementObject);
   20289             : 
   20290           2 :     while ( (blockIndex * SgDataStatementObject::pool_size) < newPoolSize)
   20291             :       {
   20292             : #if ROSE_ALLOC_TRACE
   20293             :         if (blockIndex > 0) {
   20294             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementObject) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementObject) = %" PRIuPTR " SgDataStatementObject::pool_size = %d \n",
   20295             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementObject),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementObject),SgDataStatementObject::pool_size);
   20296             :         }
   20297             : #endif
   20298             : 
   20299           0 :         SgDataStatementObject * pointer = (SgDataStatementObject*) ROSE_MALLOC ( SgDataStatementObject::pool_size * sizeof(SgDataStatementObject) );
   20300           0 :         assert( pointer != NULL );
   20301             : #if ROSE_ALLOC_MEMSET == 1
   20302             :         memset(pointer, 0x00, SgDataStatementObject::pool_size * sizeof(SgDataStatementObject));
   20303             : #elif ROSE_ALLOC_MEMSET == 2
   20304             :         memset(pointer, 0xCC, SgDataStatementObject::pool_size * sizeof(SgDataStatementObject));
   20305             : #endif
   20306           0 :         SgDataStatementObject::pools.push_back( (unsigned char*)(pointer) );
   20307           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDataStatementObject::pool_size * sizeof(SgDataStatementObject), V_SgDataStatementObject ) );
   20308             : 
   20309           0 :         if ( SgDataStatementObject::next_node != NULL ) {
   20310           0 :           if ( blockIndex > 0 ) {
   20311           0 :             SgDataStatementObject * blkptr = (SgDataStatementObject*)(SgDataStatementObject::pools[blockIndex-1]);
   20312           0 :             blkptr[ SgDataStatementObject::pool_size - 1 ].set_freepointer(pointer);
   20313             :           }
   20314             :         } else {
   20315           0 :           SgDataStatementObject::next_node = pointer;
   20316             :         }
   20317             : 
   20318           0 :         for (unsigned i = 0; i < SgDataStatementObject::pool_size-1; ++i)
   20319             :            {
   20320           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   20321             :            }
   20322           0 :         pointer[ SgDataStatementObject::pool_size -1 ].set_freepointer(NULL);
   20323             : 
   20324           0 :         blockIndex++;
   20325             :       }
   20326           2 :   }
   20327             : 
   20328             : //############################################################################
   20329             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   20330             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   20331             :  * not compressed. However, that stuff is not yet implemented! 
   20332             :  */
   20333             : unsigned long
   20334           0 : SgDataStatementObject::getNumberOfLastValidPointer()
   20335             :    {
   20336           0 :       SgDataStatementObject* testPointer = (SgDataStatementObject*)(SgDataStatementObject::pools.back());
   20337           0 :       unsigned long localIndex = SgDataStatementObject::pool_size - 1;
   20338           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   20339             :          {
   20340           0 :            localIndex--;
   20341             :          }
   20342           0 :       return (localIndex + SgDataStatementObject::pool_size * (SgDataStatementObject::pools.size()-1));
   20343             :    }
   20344             : 
   20345             : //############################################################################
   20346             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   20347             :  * memory pool and initializes the data member in class SgDataStatementObjectStroageClass
   20348             :  * from its counterpart of SgDataStatementObject. The return value is just for checking, 
   20349             :  * that the whole StorageClassArray is initialized!
   20350             :  */
   20351             : unsigned long
   20352           0 : SgDataStatementObject::initializeStorageClassArray( SgDataStatementObjectStorageClass *storageArray )
   20353             :    {
   20354           0 :      unsigned long storageCounter = 0;
   20355           0 :      std::vector < unsigned char* > :: const_iterator block = SgDataStatementObject::pools.begin();
   20356           0 :      SgDataStatementObject* pointer = NULL;
   20357           0 :      while ( block != SgDataStatementObject::pools.end() ) {
   20358           0 :           pointer = (SgDataStatementObject*) (*block);
   20359           0 :           for ( unsigned i = 0; i < SgDataStatementObject::pool_size; ++i ) {
   20360           0 :                if ( pointer->get_freepointer() != NULL ) {
   20361           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   20362           0 :                  storageArray++;
   20363           0 :                  storageCounter++;
   20364             :                }
   20365           0 :                pointer++;
   20366             :              }
   20367           0 :            block++;
   20368             :         }
   20369           0 :      return storageCounter;
   20370             :    }
   20371             : 
   20372             : /* #line 20373 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   20373             : 
   20374             : 
   20375             : 
   20376             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   20377             : 
   20378             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   20379             : 
   20380             : //############################################################################
   20381             : /* JH (02/02/2006) Constructor of the IR node SgIncludeFile that takes its 
   20382             :  * corresponding StorageClass as parameter
   20383             :  */
   20384         224 : SgIncludeFile :: SgIncludeFile ( const SgIncludeFileStorageClass& storageSource )   : SgSupport (storageSource)
   20385             :    {
   20386             : 
   20387             : 
   20388             : /* #line 20389 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   20389             : 
   20390         224 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   20391         224 :      p_filename = SgName ( storageSource.storageOf_filename ) ;
   20392         224 :      p_source_file =  (SgSourceFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_source_file) );
   20393         224 :      p_include_file_list = storageSource.storageOf_include_file_list.rebuildDataStoredInEasyStorageClass() ;
   20394         224 :      SgIncludeFilePtrList::iterator i_include_file_list = p_include_file_list.begin() ; 
   20395         421 :      for ( ; i_include_file_list != p_include_file_list.end(); ++i_include_file_list ) 
   20396             :         {
   20397         197 :           (*i_include_file_list) = (SgIncludeFilePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_include_file_list) ) );
   20398             :         }
   20399         224 :      p_first_source_sequence_number = storageSource.storageOf_first_source_sequence_number ;
   20400         224 :      p_last_source_sequence_number = storageSource.storageOf_last_source_sequence_number ;
   20401         224 :      p_isIncludedMoreThanOnce = storageSource.storageOf_isIncludedMoreThanOnce ;
   20402         224 :      p_isPrimaryUse = storageSource.storageOf_isPrimaryUse ;
   20403         224 :      p_file_hash = storageSource.storageOf_file_hash.rebuildDataStoredInEasyStorageClass() ;
   20404         224 :      p_name_used_in_include_directive = SgName ( storageSource.storageOf_name_used_in_include_directive ) ;
   20405         224 :      p_source_file_of_translation_unit =  (SgSourceFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_source_file_of_translation_unit) );
   20406         224 :      p_including_source_file =  (SgSourceFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_including_source_file) );
   20407         224 :      p_parent_include_file =  (SgIncludeFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parent_include_file) );
   20408         224 :      p_isSystemInclude = storageSource.storageOf_isSystemInclude ;
   20409         224 :      p_isPreinclude = storageSource.storageOf_isPreinclude ;
   20410         224 :      p_requires_explict_path_for_unparsed_headers = storageSource.storageOf_requires_explict_path_for_unparsed_headers ;
   20411         224 :      p_can_be_supported_using_token_based_unparsing = storageSource.storageOf_can_be_supported_using_token_based_unparsing ;
   20412         224 :      p_directory_prefix = SgName ( storageSource.storageOf_directory_prefix ) ;
   20413         224 :      p_name_without_path = SgName ( storageSource.storageOf_name_without_path ) ;
   20414         224 :      p_applicationRootDirectory = SgName ( storageSource.storageOf_applicationRootDirectory ) ;
   20415         224 :      p_will_be_unparsed = storageSource.storageOf_will_be_unparsed ;
   20416         224 :      p_isRoseSystemInclude = storageSource.storageOf_isRoseSystemInclude ;
   20417         224 :      p_from_system_include_dir = storageSource.storageOf_from_system_include_dir ;
   20418         224 :      p_preinclude_macros_only = storageSource.storageOf_preinclude_macros_only ;
   20419         224 :      p_isApplicationFile = storageSource.storageOf_isApplicationFile ;
   20420         224 :      p_isRootSourceFile = storageSource.storageOf_isRootSourceFile ;
   20421         224 :      p_firstStatement =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_firstStatement) );
   20422         224 :      p_lastStatement =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lastStatement) );
   20423             : 
   20424             : 
   20425             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   20426             : 
   20427             : 
   20428         224 :    }
   20429             : 
   20430             : //############################################################################
   20431             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   20432             :  * within the working AST. 
   20433             :  */
   20434        1033 : SgIncludeFile * SgIncludeFile::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   20435        1033 :      SgIncludeFile* returnPointer = NULL;
   20436        1033 :      if ( globalIndex != 0 )
   20437             :         {
   20438             : 
   20439             : #if FILE_IO_EXTRA_CHECK
   20440        1033 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIncludeFile ) ) <= globalIndex ) ;
   20441        1033 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncludeFile + 1 ) ) );
   20442             : #endif
   20443        1033 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncludeFile )  
   20444        1033 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIncludeFile );
   20445        1033 :           unsigned long positionInPool = localIndex % SgIncludeFile::pool_size;
   20446        1033 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncludeFile::pool_size;
   20447             : 
   20448             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   20449             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   20450             : 
   20451        1033 :           returnPointer = &( ( (SgIncludeFile*)(SgIncludeFile::pools[memoryBlock]) ) [positionInPool]) ;
   20452             : 
   20453        1033 :           ROSE_ASSERT( returnPointer != NULL ) ;
   20454             :         }
   20455        1033 :      return returnPointer ;
   20456             :    }
   20457             : 
   20458             : //############################################################################
   20459             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   20460             :   for the AST with the index astIndex
   20461             : */
   20462           0 : SgIncludeFile * SgIncludeFile::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   20463           0 :      SgIncludeFile* returnPointer = NULL;
   20464           0 :      if ( globalIndex != 0 )
   20465             :         {
   20466             : 
   20467             : #if FILE_IO_EXTRA_CHECK
   20468           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIncludeFile ) ) <= globalIndex ) ;
   20469           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncludeFile + 1 ) ) );
   20470             : #endif
   20471           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncludeFile )
   20472           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIncludeFile );
   20473           0 :           unsigned long positionInPool = localIndex % SgIncludeFile::pool_size ;
   20474           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncludeFile::pool_size ;
   20475             : 
   20476             : #if FILE_IO_EXTRA_CHECK
   20477             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   20478             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   20479             : #endif
   20480             : 
   20481           0 :           returnPointer = &( ( (SgIncludeFile*)(SgIncludeFile::pools[memoryBlock]) ) [positionInPool]) ;
   20482             : 
   20483             : #if FILE_IO_EXTRA_CHECK
   20484           0 :           assert ( returnPointer != NULL ) ;
   20485             : #endif
   20486             :         }
   20487           0 :      return returnPointer ;
   20488             :    }
   20489             : 
   20490             : //############################################################################
   20491             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   20492             :  * pool size! We set for every valid object in the memory pool the freepointer
   20493             :  * to the global index and increase the global index afterwards. For all the 
   20494             :  * invalid objects (means address ranges within the memory pool that were not
   20495             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   20496             :  * distinguish valid from invalid objects! 
   20497             :  */
   20498             : unsigned long
   20499           5 : SgIncludeFile::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   20500             :    {
   20501           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   20502           5 :      SgIncludeFile* pointer = NULL;
   20503           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   20504           5 :      std::vector < unsigned char* > :: const_iterator block;
   20505           7 :      for ( block = SgIncludeFile::pools.begin(); block != SgIncludeFile::pools.end() ; ++block )
   20506             :         {
   20507           2 :           pointer = (SgIncludeFile*)(*block);
   20508        4002 :           for (unsigned i = 0; i < SgIncludeFile::pool_size; ++i )
   20509             :              {
   20510             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   20511             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   20512             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   20513             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   20514             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   20515             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   20516             :             // properly; so this will have to be checked next.
   20517             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   20518             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   20519        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   20520             :                   {
   20521         224 :                     pointer[i].set_freepointer((SgIncludeFile*)(globalIndex));
   20522         224 :                     globalIndex++;
   20523             :                   }
   20524             :                else
   20525             :                   {
   20526        3776 :                     pointer[i].set_freepointer(NULL);
   20527             :                   }
   20528             :               }
   20529             :         }
   20530           5 :      return globalIndex;
   20531             :    }
   20532             : 
   20533             : //############################################################################
   20534             : // JH (01/14/2006)
   20535             : void
   20536           5 : SgIncludeFile::resetValidFreepointers( )
   20537             :    {
   20538           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   20539           5 :      SgIncludeFile* pointer = NULL;
   20540           5 :      std::vector < unsigned char* > :: const_iterator block;
   20541           5 :      SgIncludeFile* pointerOfLinkedList = NULL;
   20542           7 :      for ( block = SgIncludeFile::pools.begin(); block != SgIncludeFile::pools.end() ; ++block )
   20543             :         {
   20544           2 :           pointer = (SgIncludeFile*)(*block);
   20545        4002 :           for (unsigned i = 0; i < SgIncludeFile::pool_size; ++i )
   20546             :              {
   20547             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   20548             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   20549             :             // memory blocks!.
   20550        4000 :                if ( pointer[i].get_freepointer() != NULL )
   20551             :                   {
   20552         224 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   20553             :                   }
   20554             :                else
   20555             :                   {
   20556        3776 :                     if ( pointerOfLinkedList == NULL )
   20557             :                        {
   20558           2 :                          SgIncludeFile::next_node = &(pointer[i]);
   20559             :                        }
   20560             :                     else
   20561             :                        {
   20562             :                       // printf ("In SgIncludeFile::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   20563        3774 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   20564             :                        }
   20565             :                     pointerOfLinkedList = &(pointer[i]);
   20566             :                   }
   20567             :               }
   20568             :         }
   20569             : 
   20570           5 :      if ( pointerOfLinkedList != NULL )
   20571             :         {
   20572             :        // printf ("In SgIncludeFile::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   20573           2 :           pointerOfLinkedList->set_freepointer(NULL);
   20574             :        // DQ (6/6/2010): Temporary debugging...
   20575             :        //   ROSE_ASSERT(false);
   20576             :         }
   20577             : 
   20578           5 :      return ;
   20579             :    }
   20580             : 
   20581             : //############################################################################
   20582             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   20583             :  * within the memory pool and resets the freepointers, in order to achieve a 
   20584             :  * linked list, that has no jumps and starts at the beginning! This function 
   20585             :  * does not extend the memory pool, since we do not delete any memory blocks,
   20586             :  * but delete the valid objects.  
   20587             :  */
   20588             : void
   20589           0 : SgIncludeFile::clearMemoryPool( )
   20590             :    {
   20591             :   // printf ("Inside of SgIncludeFile::clearMemoryPool() \n");
   20592             : 
   20593           0 :      SgIncludeFile* pointer = NULL, *tempPointer = NULL;
   20594           0 :      std::vector < unsigned char* > :: const_iterator block;
   20595           0 :      if ( SgIncludeFile::pools.empty() == false )
   20596             :         {
   20597           0 :           block = SgIncludeFile::pools.begin() ;
   20598           0 :           SgIncludeFile::next_node = (SgIncludeFile*) (*block);
   20599             : 
   20600           0 :           while ( block != SgIncludeFile::pools.end() )
   20601             :              {
   20602           0 :                pointer = (SgIncludeFile*) (*block);
   20603           0 :                if ( tempPointer != NULL )
   20604             :                   {
   20605           0 :                     tempPointer->set_freepointer(pointer);
   20606             :                   }
   20607           0 :                for (unsigned i = 0; i < SgIncludeFile::pool_size - 1; ++i)
   20608             :                   {
   20609           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   20610             :                   }
   20611           0 :                 pointer[SgIncludeFile::pool_size-1].set_freepointer(NULL);
   20612           0 :                 tempPointer = &(pointer[SgIncludeFile::pool_size-1]);
   20613           0 :                 ++block;
   20614             :              }
   20615             :         }
   20616           0 :    }
   20617             : 
   20618           5 : void SgIncludeFile::deleteMemoryPool() {
   20619           9 :   for (auto p: SgIncludeFile::pools) {
   20620           4 :     ROSE_FREE(p);
   20621             :   }
   20622           5 :   SgIncludeFile::next_node = nullptr;
   20623           5 :   SgIncludeFile::pools.clear();
   20624           5 : }
   20625             : 
   20626             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   20627             : //                 reading multiple binary files to for a single AST.
   20628             : /////////// new version ////////////////////////////////
   20629             : //############################################################################
   20630             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   20631             : void
   20632           2 : SgIncludeFile::extendMemoryPoolForFileIO( )
   20633             :   {
   20634           2 :     size_t blockIndex = SgIncludeFile::pools.size();
   20635           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeFile) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeFile);
   20636             : 
   20637           4 :     while ( (blockIndex * SgIncludeFile::pool_size) < newPoolSize)
   20638             :       {
   20639             : #if ROSE_ALLOC_TRACE
   20640             :         if (blockIndex > 0) {
   20641             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeFile) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeFile) = %" PRIuPTR " SgIncludeFile::pool_size = %d \n",
   20642             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeFile),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeFile),SgIncludeFile::pool_size);
   20643             :         }
   20644             : #endif
   20645             : 
   20646           2 :         SgIncludeFile * pointer = (SgIncludeFile*) ROSE_MALLOC ( SgIncludeFile::pool_size * sizeof(SgIncludeFile) );
   20647           2 :         assert( pointer != NULL );
   20648             : #if ROSE_ALLOC_MEMSET == 1
   20649             :         memset(pointer, 0x00, SgIncludeFile::pool_size * sizeof(SgIncludeFile));
   20650             : #elif ROSE_ALLOC_MEMSET == 2
   20651             :         memset(pointer, 0xCC, SgIncludeFile::pool_size * sizeof(SgIncludeFile));
   20652             : #endif
   20653           2 :         SgIncludeFile::pools.push_back( (unsigned char*)(pointer) );
   20654           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIncludeFile::pool_size * sizeof(SgIncludeFile), V_SgIncludeFile ) );
   20655             : 
   20656           2 :         if ( SgIncludeFile::next_node != NULL ) {
   20657           0 :           if ( blockIndex > 0 ) {
   20658           0 :             SgIncludeFile * blkptr = (SgIncludeFile*)(SgIncludeFile::pools[blockIndex-1]);
   20659           0 :             blkptr[ SgIncludeFile::pool_size - 1 ].set_freepointer(pointer);
   20660             :           }
   20661             :         } else {
   20662           2 :           SgIncludeFile::next_node = pointer;
   20663             :         }
   20664             : 
   20665        4000 :         for (unsigned i = 0; i < SgIncludeFile::pool_size-1; ++i)
   20666             :            {
   20667        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   20668             :            }
   20669           2 :         pointer[ SgIncludeFile::pool_size -1 ].set_freepointer(NULL);
   20670             : 
   20671           2 :         blockIndex++;
   20672             :       }
   20673           2 :   }
   20674             : 
   20675             : //############################################################################
   20676             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   20677             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   20678             :  * not compressed. However, that stuff is not yet implemented! 
   20679             :  */
   20680             : unsigned long
   20681           0 : SgIncludeFile::getNumberOfLastValidPointer()
   20682             :    {
   20683           0 :       SgIncludeFile* testPointer = (SgIncludeFile*)(SgIncludeFile::pools.back());
   20684           0 :       unsigned long localIndex = SgIncludeFile::pool_size - 1;
   20685           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   20686             :          {
   20687           0 :            localIndex--;
   20688             :          }
   20689           0 :       return (localIndex + SgIncludeFile::pool_size * (SgIncludeFile::pools.size()-1));
   20690             :    }
   20691             : 
   20692             : //############################################################################
   20693             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   20694             :  * memory pool and initializes the data member in class SgIncludeFileStroageClass
   20695             :  * from its counterpart of SgIncludeFile. The return value is just for checking, 
   20696             :  * that the whole StorageClassArray is initialized!
   20697             :  */
   20698             : unsigned long
   20699           2 : SgIncludeFile::initializeStorageClassArray( SgIncludeFileStorageClass *storageArray )
   20700             :    {
   20701           2 :      unsigned long storageCounter = 0;
   20702           2 :      std::vector < unsigned char* > :: const_iterator block = SgIncludeFile::pools.begin();
   20703           2 :      SgIncludeFile* pointer = NULL;
   20704           4 :      while ( block != SgIncludeFile::pools.end() ) {
   20705           2 :           pointer = (SgIncludeFile*) (*block);
   20706        4002 :           for ( unsigned i = 0; i < SgIncludeFile::pool_size; ++i ) {
   20707        4000 :                if ( pointer->get_freepointer() != NULL ) {
   20708         224 :                  storageArray->pickOutIRNodeData (pointer) ;
   20709         224 :                  storageArray++;
   20710         224 :                  storageCounter++;
   20711             :                }
   20712        4000 :                pointer++;
   20713             :              }
   20714           2 :            block++;
   20715             :         }
   20716           2 :      return storageCounter;
   20717             :    }
   20718             : 
   20719             : /* #line 20720 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   20720             : 
   20721             : 
   20722             : 
   20723             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   20724             : 
   20725             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   20726             : 
   20727             : //############################################################################
   20728             : /* JH (02/02/2006) Constructor of the IR node SgDataStatementValue that takes its 
   20729             :  * corresponding StorageClass as parameter
   20730             :  */
   20731           0 : SgDataStatementValue :: SgDataStatementValue ( const SgDataStatementValueStorageClass& storageSource )   : SgSupport (storageSource)
   20732             :    {
   20733             : 
   20734             : 
   20735             : /* #line 20736 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   20736             : 
   20737           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   20738           0 :      p_data_initialization_format = storageSource.storageOf_data_initialization_format ;
   20739           0 :      p_initializer_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initializer_list) );
   20740           0 :      p_repeat_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_repeat_expression) );
   20741           0 :      p_constant_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_constant_expression) );
   20742             : 
   20743             : 
   20744             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   20745             : 
   20746             : 
   20747           0 :    }
   20748             : 
   20749             : //############################################################################
   20750             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   20751             :  * within the working AST. 
   20752             :  */
   20753           0 : SgDataStatementValue * SgDataStatementValue::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   20754           0 :      SgDataStatementValue* returnPointer = NULL;
   20755           0 :      if ( globalIndex != 0 )
   20756             :         {
   20757             : 
   20758             : #if FILE_IO_EXTRA_CHECK
   20759           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDataStatementValue ) ) <= globalIndex ) ;
   20760           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDataStatementValue + 1 ) ) );
   20761             : #endif
   20762           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDataStatementValue )  
   20763           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDataStatementValue );
   20764           0 :           unsigned long positionInPool = localIndex % SgDataStatementValue::pool_size;
   20765           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDataStatementValue::pool_size;
   20766             : 
   20767             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   20768             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   20769             : 
   20770           0 :           returnPointer = &( ( (SgDataStatementValue*)(SgDataStatementValue::pools[memoryBlock]) ) [positionInPool]) ;
   20771             : 
   20772           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   20773             :         }
   20774           0 :      return returnPointer ;
   20775             :    }
   20776             : 
   20777             : //############################################################################
   20778             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   20779             :   for the AST with the index astIndex
   20780             : */
   20781           0 : SgDataStatementValue * SgDataStatementValue::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   20782           0 :      SgDataStatementValue* returnPointer = NULL;
   20783           0 :      if ( globalIndex != 0 )
   20784             :         {
   20785             : 
   20786             : #if FILE_IO_EXTRA_CHECK
   20787           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDataStatementValue ) ) <= globalIndex ) ;
   20788           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDataStatementValue + 1 ) ) );
   20789             : #endif
   20790           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDataStatementValue )
   20791           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDataStatementValue );
   20792           0 :           unsigned long positionInPool = localIndex % SgDataStatementValue::pool_size ;
   20793           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDataStatementValue::pool_size ;
   20794             : 
   20795             : #if FILE_IO_EXTRA_CHECK
   20796             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   20797             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   20798             : #endif
   20799             : 
   20800           0 :           returnPointer = &( ( (SgDataStatementValue*)(SgDataStatementValue::pools[memoryBlock]) ) [positionInPool]) ;
   20801             : 
   20802             : #if FILE_IO_EXTRA_CHECK
   20803           0 :           assert ( returnPointer != NULL ) ;
   20804             : #endif
   20805             :         }
   20806           0 :      return returnPointer ;
   20807             :    }
   20808             : 
   20809             : //############################################################################
   20810             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   20811             :  * pool size! We set for every valid object in the memory pool the freepointer
   20812             :  * to the global index and increase the global index afterwards. For all the 
   20813             :  * invalid objects (means address ranges within the memory pool that were not
   20814             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   20815             :  * distinguish valid from invalid objects! 
   20816             :  */
   20817             : unsigned long
   20818           5 : SgDataStatementValue::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   20819             :    {
   20820           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   20821           5 :      SgDataStatementValue* pointer = NULL;
   20822           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   20823           5 :      std::vector < unsigned char* > :: const_iterator block;
   20824           5 :      for ( block = SgDataStatementValue::pools.begin(); block != SgDataStatementValue::pools.end() ; ++block )
   20825             :         {
   20826           0 :           pointer = (SgDataStatementValue*)(*block);
   20827           0 :           for (unsigned i = 0; i < SgDataStatementValue::pool_size; ++i )
   20828             :              {
   20829             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   20830             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   20831             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   20832             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   20833             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   20834             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   20835             :             // properly; so this will have to be checked next.
   20836             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   20837             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   20838           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   20839             :                   {
   20840           0 :                     pointer[i].set_freepointer((SgDataStatementValue*)(globalIndex));
   20841           0 :                     globalIndex++;
   20842             :                   }
   20843             :                else
   20844             :                   {
   20845           0 :                     pointer[i].set_freepointer(NULL);
   20846             :                   }
   20847             :               }
   20848             :         }
   20849           5 :      return globalIndex;
   20850             :    }
   20851             : 
   20852             : //############################################################################
   20853             : // JH (01/14/2006)
   20854             : void
   20855           5 : SgDataStatementValue::resetValidFreepointers( )
   20856             :    {
   20857           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   20858           5 :      SgDataStatementValue* pointer = NULL;
   20859           5 :      std::vector < unsigned char* > :: const_iterator block;
   20860           5 :      SgDataStatementValue* pointerOfLinkedList = NULL;
   20861           5 :      for ( block = SgDataStatementValue::pools.begin(); block != SgDataStatementValue::pools.end() ; ++block )
   20862             :         {
   20863           0 :           pointer = (SgDataStatementValue*)(*block);
   20864           0 :           for (unsigned i = 0; i < SgDataStatementValue::pool_size; ++i )
   20865             :              {
   20866             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   20867             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   20868             :             // memory blocks!.
   20869           0 :                if ( pointer[i].get_freepointer() != NULL )
   20870             :                   {
   20871           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   20872             :                   }
   20873             :                else
   20874             :                   {
   20875           0 :                     if ( pointerOfLinkedList == NULL )
   20876             :                        {
   20877           0 :                          SgDataStatementValue::next_node = &(pointer[i]);
   20878             :                        }
   20879             :                     else
   20880             :                        {
   20881             :                       // printf ("In SgDataStatementValue::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   20882           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   20883             :                        }
   20884             :                     pointerOfLinkedList = &(pointer[i]);
   20885             :                   }
   20886             :               }
   20887             :         }
   20888             : 
   20889           5 :      if ( pointerOfLinkedList != NULL )
   20890             :         {
   20891             :        // printf ("In SgDataStatementValue::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   20892           0 :           pointerOfLinkedList->set_freepointer(NULL);
   20893             :        // DQ (6/6/2010): Temporary debugging...
   20894             :        //   ROSE_ASSERT(false);
   20895             :         }
   20896             : 
   20897           5 :      return ;
   20898             :    }
   20899             : 
   20900             : //############################################################################
   20901             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   20902             :  * within the memory pool and resets the freepointers, in order to achieve a 
   20903             :  * linked list, that has no jumps and starts at the beginning! This function 
   20904             :  * does not extend the memory pool, since we do not delete any memory blocks,
   20905             :  * but delete the valid objects.  
   20906             :  */
   20907             : void
   20908           0 : SgDataStatementValue::clearMemoryPool( )
   20909             :    {
   20910             :   // printf ("Inside of SgDataStatementValue::clearMemoryPool() \n");
   20911             : 
   20912           0 :      SgDataStatementValue* pointer = NULL, *tempPointer = NULL;
   20913           0 :      std::vector < unsigned char* > :: const_iterator block;
   20914           0 :      if ( SgDataStatementValue::pools.empty() == false )
   20915             :         {
   20916           0 :           block = SgDataStatementValue::pools.begin() ;
   20917           0 :           SgDataStatementValue::next_node = (SgDataStatementValue*) (*block);
   20918             : 
   20919           0 :           while ( block != SgDataStatementValue::pools.end() )
   20920             :              {
   20921           0 :                pointer = (SgDataStatementValue*) (*block);
   20922           0 :                if ( tempPointer != NULL )
   20923             :                   {
   20924           0 :                     tempPointer->set_freepointer(pointer);
   20925             :                   }
   20926           0 :                for (unsigned i = 0; i < SgDataStatementValue::pool_size - 1; ++i)
   20927             :                   {
   20928           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   20929             :                   }
   20930           0 :                 pointer[SgDataStatementValue::pool_size-1].set_freepointer(NULL);
   20931           0 :                 tempPointer = &(pointer[SgDataStatementValue::pool_size-1]);
   20932           0 :                 ++block;
   20933             :              }
   20934             :         }
   20935           0 :    }
   20936             : 
   20937           5 : void SgDataStatementValue::deleteMemoryPool() {
   20938           5 :   for (auto p: SgDataStatementValue::pools) {
   20939           0 :     ROSE_FREE(p);
   20940             :   }
   20941           5 :   SgDataStatementValue::next_node = nullptr;
   20942           5 :   SgDataStatementValue::pools.clear();
   20943           5 : }
   20944             : 
   20945             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   20946             : //                 reading multiple binary files to for a single AST.
   20947             : /////////// new version ////////////////////////////////
   20948             : //############################################################################
   20949             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   20950             : void
   20951           2 : SgDataStatementValue::extendMemoryPoolForFileIO( )
   20952             :   {
   20953           2 :     size_t blockIndex = SgDataStatementValue::pools.size();
   20954           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementValue) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementValue);
   20955             : 
   20956           2 :     while ( (blockIndex * SgDataStatementValue::pool_size) < newPoolSize)
   20957             :       {
   20958             : #if ROSE_ALLOC_TRACE
   20959             :         if (blockIndex > 0) {
   20960             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementValue) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementValue) = %" PRIuPTR " SgDataStatementValue::pool_size = %d \n",
   20961             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDataStatementValue),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDataStatementValue),SgDataStatementValue::pool_size);
   20962             :         }
   20963             : #endif
   20964             : 
   20965           0 :         SgDataStatementValue * pointer = (SgDataStatementValue*) ROSE_MALLOC ( SgDataStatementValue::pool_size * sizeof(SgDataStatementValue) );
   20966           0 :         assert( pointer != NULL );
   20967             : #if ROSE_ALLOC_MEMSET == 1
   20968             :         memset(pointer, 0x00, SgDataStatementValue::pool_size * sizeof(SgDataStatementValue));
   20969             : #elif ROSE_ALLOC_MEMSET == 2
   20970             :         memset(pointer, 0xCC, SgDataStatementValue::pool_size * sizeof(SgDataStatementValue));
   20971             : #endif
   20972           0 :         SgDataStatementValue::pools.push_back( (unsigned char*)(pointer) );
   20973           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDataStatementValue::pool_size * sizeof(SgDataStatementValue), V_SgDataStatementValue ) );
   20974             : 
   20975           0 :         if ( SgDataStatementValue::next_node != NULL ) {
   20976           0 :           if ( blockIndex > 0 ) {
   20977           0 :             SgDataStatementValue * blkptr = (SgDataStatementValue*)(SgDataStatementValue::pools[blockIndex-1]);
   20978           0 :             blkptr[ SgDataStatementValue::pool_size - 1 ].set_freepointer(pointer);
   20979             :           }
   20980             :         } else {
   20981           0 :           SgDataStatementValue::next_node = pointer;
   20982             :         }
   20983             : 
   20984           0 :         for (unsigned i = 0; i < SgDataStatementValue::pool_size-1; ++i)
   20985             :            {
   20986           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   20987             :            }
   20988           0 :         pointer[ SgDataStatementValue::pool_size -1 ].set_freepointer(NULL);
   20989             : 
   20990           0 :         blockIndex++;
   20991             :       }
   20992           2 :   }
   20993             : 
   20994             : //############################################################################
   20995             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   20996             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   20997             :  * not compressed. However, that stuff is not yet implemented! 
   20998             :  */
   20999             : unsigned long
   21000           0 : SgDataStatementValue::getNumberOfLastValidPointer()
   21001             :    {
   21002           0 :       SgDataStatementValue* testPointer = (SgDataStatementValue*)(SgDataStatementValue::pools.back());
   21003           0 :       unsigned long localIndex = SgDataStatementValue::pool_size - 1;
   21004           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   21005             :          {
   21006           0 :            localIndex--;
   21007             :          }
   21008           0 :       return (localIndex + SgDataStatementValue::pool_size * (SgDataStatementValue::pools.size()-1));
   21009             :    }
   21010             : 
   21011             : //############################################################################
   21012             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   21013             :  * memory pool and initializes the data member in class SgDataStatementValueStroageClass
   21014             :  * from its counterpart of SgDataStatementValue. The return value is just for checking, 
   21015             :  * that the whole StorageClassArray is initialized!
   21016             :  */
   21017             : unsigned long
   21018           0 : SgDataStatementValue::initializeStorageClassArray( SgDataStatementValueStorageClass *storageArray )
   21019             :    {
   21020           0 :      unsigned long storageCounter = 0;
   21021           0 :      std::vector < unsigned char* > :: const_iterator block = SgDataStatementValue::pools.begin();
   21022           0 :      SgDataStatementValue* pointer = NULL;
   21023           0 :      while ( block != SgDataStatementValue::pools.end() ) {
   21024           0 :           pointer = (SgDataStatementValue*) (*block);
   21025           0 :           for ( unsigned i = 0; i < SgDataStatementValue::pool_size; ++i ) {
   21026           0 :                if ( pointer->get_freepointer() != NULL ) {
   21027           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   21028           0 :                  storageArray++;
   21029           0 :                  storageCounter++;
   21030             :                }
   21031           0 :                pointer++;
   21032             :              }
   21033           0 :            block++;
   21034             :         }
   21035           0 :      return storageCounter;
   21036             :    }
   21037             : 
   21038             : /* #line 21039 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   21039             : 
   21040             : 
   21041             : 
   21042             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   21043             : 
   21044             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   21045             : 
   21046             : //############################################################################
   21047             : /* JH (02/02/2006) Constructor of the IR node SgHeaderFileReport that takes its 
   21048             :  * corresponding StorageClass as parameter
   21049             :  */
   21050           0 : SgHeaderFileReport :: SgHeaderFileReport ( const SgHeaderFileReportStorageClass& storageSource )   : SgSupport (storageSource)
   21051             :    {
   21052             : 
   21053             : 
   21054             : /* #line 21055 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   21055             : 
   21056           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   21057           0 :      p_source_file =  (SgSourceFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_source_file) );
   21058           0 :      p_include_file_list = storageSource.storageOf_include_file_list.rebuildDataStoredInEasyStorageClass() ;
   21059           0 :      SgSourceFilePtrList::iterator i_include_file_list = p_include_file_list.begin() ; 
   21060           0 :      for ( ; i_include_file_list != p_include_file_list.end(); ++i_include_file_list ) 
   21061             :         {
   21062           0 :           (*i_include_file_list) = (SgSourceFilePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_include_file_list) ) );
   21063             :         }
   21064             : 
   21065             : 
   21066             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   21067             : 
   21068             : 
   21069           0 :    }
   21070             : 
   21071             : //############################################################################
   21072             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   21073             :  * within the working AST. 
   21074             :  */
   21075           0 : SgHeaderFileReport * SgHeaderFileReport::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   21076           0 :      SgHeaderFileReport* returnPointer = NULL;
   21077           0 :      if ( globalIndex != 0 )
   21078             :         {
   21079             : 
   21080             : #if FILE_IO_EXTRA_CHECK
   21081           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgHeaderFileReport ) ) <= globalIndex ) ;
   21082           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgHeaderFileReport + 1 ) ) );
   21083             : #endif
   21084           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgHeaderFileReport )  
   21085           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgHeaderFileReport );
   21086           0 :           unsigned long positionInPool = localIndex % SgHeaderFileReport::pool_size;
   21087           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgHeaderFileReport::pool_size;
   21088             : 
   21089             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   21090             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   21091             : 
   21092           0 :           returnPointer = &( ( (SgHeaderFileReport*)(SgHeaderFileReport::pools[memoryBlock]) ) [positionInPool]) ;
   21093             : 
   21094           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   21095             :         }
   21096           0 :      return returnPointer ;
   21097             :    }
   21098             : 
   21099             : //############################################################################
   21100             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   21101             :   for the AST with the index astIndex
   21102             : */
   21103           0 : SgHeaderFileReport * SgHeaderFileReport::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   21104           0 :      SgHeaderFileReport* returnPointer = NULL;
   21105           0 :      if ( globalIndex != 0 )
   21106             :         {
   21107             : 
   21108             : #if FILE_IO_EXTRA_CHECK
   21109           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgHeaderFileReport ) ) <= globalIndex ) ;
   21110           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgHeaderFileReport + 1 ) ) );
   21111             : #endif
   21112           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgHeaderFileReport )
   21113           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgHeaderFileReport );
   21114           0 :           unsigned long positionInPool = localIndex % SgHeaderFileReport::pool_size ;
   21115           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgHeaderFileReport::pool_size ;
   21116             : 
   21117             : #if FILE_IO_EXTRA_CHECK
   21118             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   21119             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   21120             : #endif
   21121             : 
   21122           0 :           returnPointer = &( ( (SgHeaderFileReport*)(SgHeaderFileReport::pools[memoryBlock]) ) [positionInPool]) ;
   21123             : 
   21124             : #if FILE_IO_EXTRA_CHECK
   21125           0 :           assert ( returnPointer != NULL ) ;
   21126             : #endif
   21127             :         }
   21128           0 :      return returnPointer ;
   21129             :    }
   21130             : 
   21131             : //############################################################################
   21132             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   21133             :  * pool size! We set for every valid object in the memory pool the freepointer
   21134             :  * to the global index and increase the global index afterwards. For all the 
   21135             :  * invalid objects (means address ranges within the memory pool that were not
   21136             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   21137             :  * distinguish valid from invalid objects! 
   21138             :  */
   21139             : unsigned long
   21140           5 : SgHeaderFileReport::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   21141             :    {
   21142           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   21143           5 :      SgHeaderFileReport* pointer = NULL;
   21144           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   21145           5 :      std::vector < unsigned char* > :: const_iterator block;
   21146           5 :      for ( block = SgHeaderFileReport::pools.begin(); block != SgHeaderFileReport::pools.end() ; ++block )
   21147             :         {
   21148           0 :           pointer = (SgHeaderFileReport*)(*block);
   21149           0 :           for (unsigned i = 0; i < SgHeaderFileReport::pool_size; ++i )
   21150             :              {
   21151             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   21152             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   21153             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   21154             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   21155             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   21156             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   21157             :             // properly; so this will have to be checked next.
   21158             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   21159             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   21160           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   21161             :                   {
   21162           0 :                     pointer[i].set_freepointer((SgHeaderFileReport*)(globalIndex));
   21163           0 :                     globalIndex++;
   21164             :                   }
   21165             :                else
   21166             :                   {
   21167           0 :                     pointer[i].set_freepointer(NULL);
   21168             :                   }
   21169             :               }
   21170             :         }
   21171           5 :      return globalIndex;
   21172             :    }
   21173             : 
   21174             : //############################################################################
   21175             : // JH (01/14/2006)
   21176             : void
   21177           5 : SgHeaderFileReport::resetValidFreepointers( )
   21178             :    {
   21179           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   21180           5 :      SgHeaderFileReport* pointer = NULL;
   21181           5 :      std::vector < unsigned char* > :: const_iterator block;
   21182           5 :      SgHeaderFileReport* pointerOfLinkedList = NULL;
   21183           5 :      for ( block = SgHeaderFileReport::pools.begin(); block != SgHeaderFileReport::pools.end() ; ++block )
   21184             :         {
   21185           0 :           pointer = (SgHeaderFileReport*)(*block);
   21186           0 :           for (unsigned i = 0; i < SgHeaderFileReport::pool_size; ++i )
   21187             :              {
   21188             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   21189             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   21190             :             // memory blocks!.
   21191           0 :                if ( pointer[i].get_freepointer() != NULL )
   21192             :                   {
   21193           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   21194             :                   }
   21195             :                else
   21196             :                   {
   21197           0 :                     if ( pointerOfLinkedList == NULL )
   21198             :                        {
   21199           0 :                          SgHeaderFileReport::next_node = &(pointer[i]);
   21200             :                        }
   21201             :                     else
   21202             :                        {
   21203             :                       // printf ("In SgHeaderFileReport::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   21204           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   21205             :                        }
   21206             :                     pointerOfLinkedList = &(pointer[i]);
   21207             :                   }
   21208             :               }
   21209             :         }
   21210             : 
   21211           5 :      if ( pointerOfLinkedList != NULL )
   21212             :         {
   21213             :        // printf ("In SgHeaderFileReport::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   21214           0 :           pointerOfLinkedList->set_freepointer(NULL);
   21215             :        // DQ (6/6/2010): Temporary debugging...
   21216             :        //   ROSE_ASSERT(false);
   21217             :         }
   21218             : 
   21219           5 :      return ;
   21220             :    }
   21221             : 
   21222             : //############################################################################
   21223             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   21224             :  * within the memory pool and resets the freepointers, in order to achieve a 
   21225             :  * linked list, that has no jumps and starts at the beginning! This function 
   21226             :  * does not extend the memory pool, since we do not delete any memory blocks,
   21227             :  * but delete the valid objects.  
   21228             :  */
   21229             : void
   21230           0 : SgHeaderFileReport::clearMemoryPool( )
   21231             :    {
   21232             :   // printf ("Inside of SgHeaderFileReport::clearMemoryPool() \n");
   21233             : 
   21234           0 :      SgHeaderFileReport* pointer = NULL, *tempPointer = NULL;
   21235           0 :      std::vector < unsigned char* > :: const_iterator block;
   21236           0 :      if ( SgHeaderFileReport::pools.empty() == false )
   21237             :         {
   21238           0 :           block = SgHeaderFileReport::pools.begin() ;
   21239           0 :           SgHeaderFileReport::next_node = (SgHeaderFileReport*) (*block);
   21240             : 
   21241           0 :           while ( block != SgHeaderFileReport::pools.end() )
   21242             :              {
   21243           0 :                pointer = (SgHeaderFileReport*) (*block);
   21244           0 :                if ( tempPointer != NULL )
   21245             :                   {
   21246           0 :                     tempPointer->set_freepointer(pointer);
   21247             :                   }
   21248           0 :                for (unsigned i = 0; i < SgHeaderFileReport::pool_size - 1; ++i)
   21249             :                   {
   21250           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   21251             :                   }
   21252           0 :                 pointer[SgHeaderFileReport::pool_size-1].set_freepointer(NULL);
   21253           0 :                 tempPointer = &(pointer[SgHeaderFileReport::pool_size-1]);
   21254           0 :                 ++block;
   21255             :              }
   21256             :         }
   21257           0 :    }
   21258             : 
   21259           5 : void SgHeaderFileReport::deleteMemoryPool() {
   21260           5 :   for (auto p: SgHeaderFileReport::pools) {
   21261           0 :     ROSE_FREE(p);
   21262             :   }
   21263           5 :   SgHeaderFileReport::next_node = nullptr;
   21264           5 :   SgHeaderFileReport::pools.clear();
   21265           5 : }
   21266             : 
   21267             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   21268             : //                 reading multiple binary files to for a single AST.
   21269             : /////////// new version ////////////////////////////////
   21270             : //############################################################################
   21271             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   21272             : void
   21273           2 : SgHeaderFileReport::extendMemoryPoolForFileIO( )
   21274             :   {
   21275           2 :     size_t blockIndex = SgHeaderFileReport::pools.size();
   21276           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgHeaderFileReport) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgHeaderFileReport);
   21277             : 
   21278           2 :     while ( (blockIndex * SgHeaderFileReport::pool_size) < newPoolSize)
   21279             :       {
   21280             : #if ROSE_ALLOC_TRACE
   21281             :         if (blockIndex > 0) {
   21282             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgHeaderFileReport) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgHeaderFileReport) = %" PRIuPTR " SgHeaderFileReport::pool_size = %d \n",
   21283             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgHeaderFileReport),AST_FILE_IO::getPoolSizeOfNewAst(V_SgHeaderFileReport),SgHeaderFileReport::pool_size);
   21284             :         }
   21285             : #endif
   21286             : 
   21287           0 :         SgHeaderFileReport * pointer = (SgHeaderFileReport*) ROSE_MALLOC ( SgHeaderFileReport::pool_size * sizeof(SgHeaderFileReport) );
   21288           0 :         assert( pointer != NULL );
   21289             : #if ROSE_ALLOC_MEMSET == 1
   21290             :         memset(pointer, 0x00, SgHeaderFileReport::pool_size * sizeof(SgHeaderFileReport));
   21291             : #elif ROSE_ALLOC_MEMSET == 2
   21292             :         memset(pointer, 0xCC, SgHeaderFileReport::pool_size * sizeof(SgHeaderFileReport));
   21293             : #endif
   21294           0 :         SgHeaderFileReport::pools.push_back( (unsigned char*)(pointer) );
   21295           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgHeaderFileReport::pool_size * sizeof(SgHeaderFileReport), V_SgHeaderFileReport ) );
   21296             : 
   21297           0 :         if ( SgHeaderFileReport::next_node != NULL ) {
   21298           0 :           if ( blockIndex > 0 ) {
   21299           0 :             SgHeaderFileReport * blkptr = (SgHeaderFileReport*)(SgHeaderFileReport::pools[blockIndex-1]);
   21300           0 :             blkptr[ SgHeaderFileReport::pool_size - 1 ].set_freepointer(pointer);
   21301             :           }
   21302             :         } else {
   21303           0 :           SgHeaderFileReport::next_node = pointer;
   21304             :         }
   21305             : 
   21306           0 :         for (unsigned i = 0; i < SgHeaderFileReport::pool_size-1; ++i)
   21307             :            {
   21308           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   21309             :            }
   21310           0 :         pointer[ SgHeaderFileReport::pool_size -1 ].set_freepointer(NULL);
   21311             : 
   21312           0 :         blockIndex++;
   21313             :       }
   21314           2 :   }
   21315             : 
   21316             : //############################################################################
   21317             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   21318             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   21319             :  * not compressed. However, that stuff is not yet implemented! 
   21320             :  */
   21321             : unsigned long
   21322           0 : SgHeaderFileReport::getNumberOfLastValidPointer()
   21323             :    {
   21324           0 :       SgHeaderFileReport* testPointer = (SgHeaderFileReport*)(SgHeaderFileReport::pools.back());
   21325           0 :       unsigned long localIndex = SgHeaderFileReport::pool_size - 1;
   21326           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   21327             :          {
   21328           0 :            localIndex--;
   21329             :          }
   21330           0 :       return (localIndex + SgHeaderFileReport::pool_size * (SgHeaderFileReport::pools.size()-1));
   21331             :    }
   21332             : 
   21333             : //############################################################################
   21334             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   21335             :  * memory pool and initializes the data member in class SgHeaderFileReportStroageClass
   21336             :  * from its counterpart of SgHeaderFileReport. The return value is just for checking, 
   21337             :  * that the whole StorageClassArray is initialized!
   21338             :  */
   21339             : unsigned long
   21340           0 : SgHeaderFileReport::initializeStorageClassArray( SgHeaderFileReportStorageClass *storageArray )
   21341             :    {
   21342           0 :      unsigned long storageCounter = 0;
   21343           0 :      std::vector < unsigned char* > :: const_iterator block = SgHeaderFileReport::pools.begin();
   21344           0 :      SgHeaderFileReport* pointer = NULL;
   21345           0 :      while ( block != SgHeaderFileReport::pools.end() ) {
   21346           0 :           pointer = (SgHeaderFileReport*) (*block);
   21347           0 :           for ( unsigned i = 0; i < SgHeaderFileReport::pool_size; ++i ) {
   21348           0 :                if ( pointer->get_freepointer() != NULL ) {
   21349           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   21350           0 :                  storageArray++;
   21351           0 :                  storageCounter++;
   21352             :                }
   21353           0 :                pointer++;
   21354             :              }
   21355           0 :            block++;
   21356             :         }
   21357           0 :      return storageCounter;
   21358             :    }
   21359             : 
   21360             : /* #line 21361 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   21361             : 
   21362             : 
   21363             : 
   21364             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   21365             : 
   21366             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   21367             : 
   21368             : //############################################################################
   21369             : /* JH (02/02/2006) Constructor of the IR node SgType that takes its 
   21370             :  * corresponding StorageClass as parameter
   21371             :  */
   21372       16445 : SgType :: SgType ( const SgTypeStorageClass& storageSource )   : SgNode (storageSource)
   21373             :    {
   21374             : 
   21375             : 
   21376             : /* #line 21377 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   21377             : 
   21378       16445 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   21379       16445 :      p_isCoArray = storageSource.storageOf_isCoArray ;
   21380       16445 :      p_substitutedForTemplateParam = storageSource.storageOf_substitutedForTemplateParam ;
   21381       16445 :      p_ref_to =  (SgReferenceType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_ref_to) );
   21382       16445 :      p_ptr_to =  (SgPointerType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_ptr_to) );
   21383       16445 :      p_modifiers =  (SgModifierNodes*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_modifiers) );
   21384       16445 :      p_typedefs =  (SgTypedefSeq*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_typedefs) );
   21385       16445 :      p_rvalue_ref_to =  (SgRvalueReferenceType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_rvalue_ref_to) );
   21386       16445 :      p_decltype_ref_to =  (SgDeclType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_decltype_ref_to) );
   21387       16445 :      p_typeof_ref_to =  (SgTypeOfType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_typeof_ref_to) );
   21388       16445 :      p_type_kind =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type_kind) );
   21389       16445 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
   21390             : 
   21391             : 
   21392             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   21393             : 
   21394             : 
   21395       16445 :    }
   21396             : 
   21397             : //############################################################################
   21398             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   21399             :  * within the working AST. 
   21400             :  */
   21401           0 : SgType * SgType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   21402           0 :      SgType* returnPointer = NULL;
   21403           0 :      if ( globalIndex != 0 )
   21404             :         {
   21405             : 
   21406             : #if FILE_IO_EXTRA_CHECK
   21407           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgType ) ) <= globalIndex ) ;
   21408           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgType + 1 ) ) );
   21409             : #endif
   21410           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgType )  
   21411           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgType );
   21412           0 :           unsigned long positionInPool = localIndex % SgType::pool_size;
   21413           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgType::pool_size;
   21414             : 
   21415             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   21416             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   21417             : 
   21418           0 :           returnPointer = &( ( (SgType*)(SgType::pools[memoryBlock]) ) [positionInPool]) ;
   21419             : 
   21420           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   21421             :         }
   21422           0 :      return returnPointer ;
   21423             :    }
   21424             : 
   21425             : //############################################################################
   21426             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   21427             :   for the AST with the index astIndex
   21428             : */
   21429           0 : SgType * SgType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   21430           0 :      SgType* returnPointer = NULL;
   21431           0 :      if ( globalIndex != 0 )
   21432             :         {
   21433             : 
   21434             : #if FILE_IO_EXTRA_CHECK
   21435           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgType ) ) <= globalIndex ) ;
   21436           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgType + 1 ) ) );
   21437             : #endif
   21438           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgType )
   21439           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgType );
   21440           0 :           unsigned long positionInPool = localIndex % SgType::pool_size ;
   21441           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgType::pool_size ;
   21442             : 
   21443             : #if FILE_IO_EXTRA_CHECK
   21444             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   21445             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   21446             : #endif
   21447             : 
   21448           0 :           returnPointer = &( ( (SgType*)(SgType::pools[memoryBlock]) ) [positionInPool]) ;
   21449             : 
   21450             : #if FILE_IO_EXTRA_CHECK
   21451           0 :           assert ( returnPointer != NULL ) ;
   21452             : #endif
   21453             :         }
   21454           0 :      return returnPointer ;
   21455             :    }
   21456             : 
   21457             : //############################################################################
   21458             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   21459             :  * pool size! We set for every valid object in the memory pool the freepointer
   21460             :  * to the global index and increase the global index afterwards. For all the 
   21461             :  * invalid objects (means address ranges within the memory pool that were not
   21462             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   21463             :  * distinguish valid from invalid objects! 
   21464             :  */
   21465             : unsigned long
   21466           5 : SgType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   21467             :    {
   21468           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   21469           5 :      SgType* pointer = NULL;
   21470           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   21471           5 :      std::vector < unsigned char* > :: const_iterator block;
   21472           5 :      for ( block = SgType::pools.begin(); block != SgType::pools.end() ; ++block )
   21473             :         {
   21474           0 :           pointer = (SgType*)(*block);
   21475           0 :           for (unsigned i = 0; i < SgType::pool_size; ++i )
   21476             :              {
   21477             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   21478             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   21479             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   21480             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   21481             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   21482             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   21483             :             // properly; so this will have to be checked next.
   21484             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   21485             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   21486           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   21487             :                   {
   21488           0 :                     pointer[i].set_freepointer((SgType*)(globalIndex));
   21489           0 :                     globalIndex++;
   21490             :                   }
   21491             :                else
   21492             :                   {
   21493           0 :                     pointer[i].set_freepointer(NULL);
   21494             :                   }
   21495             :               }
   21496             :         }
   21497           5 :      return globalIndex;
   21498             :    }
   21499             : 
   21500             : //############################################################################
   21501             : // JH (01/14/2006)
   21502             : void
   21503           5 : SgType::resetValidFreepointers( )
   21504             :    {
   21505           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   21506           5 :      SgType* pointer = NULL;
   21507           5 :      std::vector < unsigned char* > :: const_iterator block;
   21508           5 :      SgType* pointerOfLinkedList = NULL;
   21509           5 :      for ( block = SgType::pools.begin(); block != SgType::pools.end() ; ++block )
   21510             :         {
   21511           0 :           pointer = (SgType*)(*block);
   21512           0 :           for (unsigned i = 0; i < SgType::pool_size; ++i )
   21513             :              {
   21514             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   21515             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   21516             :             // memory blocks!.
   21517           0 :                if ( pointer[i].get_freepointer() != NULL )
   21518             :                   {
   21519           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   21520             :                   }
   21521             :                else
   21522             :                   {
   21523           0 :                     if ( pointerOfLinkedList == NULL )
   21524             :                        {
   21525           0 :                          SgType::next_node = &(pointer[i]);
   21526             :                        }
   21527             :                     else
   21528             :                        {
   21529             :                       // printf ("In SgType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   21530           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   21531             :                        }
   21532             :                     pointerOfLinkedList = &(pointer[i]);
   21533             :                   }
   21534             :               }
   21535             :         }
   21536             : 
   21537           5 :      if ( pointerOfLinkedList != NULL )
   21538             :         {
   21539             :        // printf ("In SgType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   21540           0 :           pointerOfLinkedList->set_freepointer(NULL);
   21541             :        // DQ (6/6/2010): Temporary debugging...
   21542             :        //   ROSE_ASSERT(false);
   21543             :         }
   21544             : 
   21545           5 :      return ;
   21546             :    }
   21547             : 
   21548             : //############################################################################
   21549             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   21550             :  * within the memory pool and resets the freepointers, in order to achieve a 
   21551             :  * linked list, that has no jumps and starts at the beginning! This function 
   21552             :  * does not extend the memory pool, since we do not delete any memory blocks,
   21553             :  * but delete the valid objects.  
   21554             :  */
   21555             : void
   21556           0 : SgType::clearMemoryPool( )
   21557             :    {
   21558             :   // printf ("Inside of SgType::clearMemoryPool() \n");
   21559             : 
   21560           0 :      SgType* pointer = NULL, *tempPointer = NULL;
   21561           0 :      std::vector < unsigned char* > :: const_iterator block;
   21562           0 :      if ( SgType::pools.empty() == false )
   21563             :         {
   21564           0 :           block = SgType::pools.begin() ;
   21565           0 :           SgType::next_node = (SgType*) (*block);
   21566             : 
   21567           0 :           while ( block != SgType::pools.end() )
   21568             :              {
   21569           0 :                pointer = (SgType*) (*block);
   21570           0 :                if ( tempPointer != NULL )
   21571             :                   {
   21572           0 :                     tempPointer->set_freepointer(pointer);
   21573             :                   }
   21574           0 :                for (unsigned i = 0; i < SgType::pool_size - 1; ++i)
   21575             :                   {
   21576           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   21577             :                   }
   21578           0 :                 pointer[SgType::pool_size-1].set_freepointer(NULL);
   21579           0 :                 tempPointer = &(pointer[SgType::pool_size-1]);
   21580           0 :                 ++block;
   21581             :              }
   21582             :         }
   21583           0 :    }
   21584             : 
   21585           5 : void SgType::deleteMemoryPool() {
   21586           5 :   for (auto p: SgType::pools) {
   21587           0 :     ROSE_FREE(p);
   21588             :   }
   21589           5 :   SgType::next_node = nullptr;
   21590           5 :   SgType::pools.clear();
   21591           5 : }
   21592             : 
   21593             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   21594             : //                 reading multiple binary files to for a single AST.
   21595             : /////////// new version ////////////////////////////////
   21596             : //############################################################################
   21597             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   21598             : void
   21599           2 : SgType::extendMemoryPoolForFileIO( )
   21600             :   {
   21601           2 :     size_t blockIndex = SgType::pools.size();
   21602           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgType);
   21603             : 
   21604           2 :     while ( (blockIndex * SgType::pool_size) < newPoolSize)
   21605             :       {
   21606             : #if ROSE_ALLOC_TRACE
   21607             :         if (blockIndex > 0) {
   21608             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgType) = %" PRIuPTR " SgType::pool_size = %d \n",
   21609             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgType),SgType::pool_size);
   21610             :         }
   21611             : #endif
   21612             : 
   21613           0 :         SgType * pointer = (SgType*) ROSE_MALLOC ( SgType::pool_size * sizeof(SgType) );
   21614           0 :         assert( pointer != NULL );
   21615             : #if ROSE_ALLOC_MEMSET == 1
   21616             :         memset(pointer, 0x00, SgType::pool_size * sizeof(SgType));
   21617             : #elif ROSE_ALLOC_MEMSET == 2
   21618             :         memset(pointer, 0xCC, SgType::pool_size * sizeof(SgType));
   21619             : #endif
   21620           0 :         SgType::pools.push_back( (unsigned char*)(pointer) );
   21621           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgType::pool_size * sizeof(SgType), V_SgType ) );
   21622             : 
   21623           0 :         if ( SgType::next_node != NULL ) {
   21624           0 :           if ( blockIndex > 0 ) {
   21625           0 :             SgType * blkptr = (SgType*)(SgType::pools[blockIndex-1]);
   21626           0 :             blkptr[ SgType::pool_size - 1 ].set_freepointer(pointer);
   21627             :           }
   21628             :         } else {
   21629           0 :           SgType::next_node = pointer;
   21630             :         }
   21631             : 
   21632           0 :         for (unsigned i = 0; i < SgType::pool_size-1; ++i)
   21633             :            {
   21634           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   21635             :            }
   21636           0 :         pointer[ SgType::pool_size -1 ].set_freepointer(NULL);
   21637             : 
   21638           0 :         blockIndex++;
   21639             :       }
   21640           2 :   }
   21641             : 
   21642             : //############################################################################
   21643             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   21644             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   21645             :  * not compressed. However, that stuff is not yet implemented! 
   21646             :  */
   21647             : unsigned long
   21648           0 : SgType::getNumberOfLastValidPointer()
   21649             :    {
   21650           0 :       SgType* testPointer = (SgType*)(SgType::pools.back());
   21651           0 :       unsigned long localIndex = SgType::pool_size - 1;
   21652           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   21653             :          {
   21654           0 :            localIndex--;
   21655             :          }
   21656           0 :       return (localIndex + SgType::pool_size * (SgType::pools.size()-1));
   21657             :    }
   21658             : 
   21659             : //############################################################################
   21660             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   21661             :  * memory pool and initializes the data member in class SgTypeStroageClass
   21662             :  * from its counterpart of SgType. The return value is just for checking, 
   21663             :  * that the whole StorageClassArray is initialized!
   21664             :  */
   21665             : unsigned long
   21666           0 : SgType::initializeStorageClassArray( SgTypeStorageClass *storageArray )
   21667             :    {
   21668           0 :      unsigned long storageCounter = 0;
   21669           0 :      std::vector < unsigned char* > :: const_iterator block = SgType::pools.begin();
   21670           0 :      SgType* pointer = NULL;
   21671           0 :      while ( block != SgType::pools.end() ) {
   21672           0 :           pointer = (SgType*) (*block);
   21673           0 :           for ( unsigned i = 0; i < SgType::pool_size; ++i ) {
   21674           0 :                if ( pointer->get_freepointer() != NULL ) {
   21675           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   21676           0 :                  storageArray++;
   21677           0 :                  storageCounter++;
   21678             :                }
   21679           0 :                pointer++;
   21680             :              }
   21681           0 :            block++;
   21682             :         }
   21683           0 :      return storageCounter;
   21684             :    }
   21685             : 
   21686             : /* #line 21687 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   21687             : 
   21688             : 
   21689             : 
   21690             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   21691             : 
   21692             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   21693             : 
   21694             : //############################################################################
   21695             : /* JH (02/02/2006) Constructor of the IR node SgTypeUnknown that takes its 
   21696             :  * corresponding StorageClass as parameter
   21697             :  */
   21698           1 : SgTypeUnknown :: SgTypeUnknown ( const SgTypeUnknownStorageClass& storageSource )   : SgType (storageSource)
   21699             :    {
   21700             : 
   21701             : 
   21702             : /* #line 21703 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   21703             : 
   21704           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   21705           1 :      p_type_name = storageSource.storageOf_type_name.rebuildDataStoredInEasyStorageClass() ;
   21706           1 :      p_has_type_name = storageSource.storageOf_has_type_name ;
   21707             : 
   21708             : 
   21709             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   21710             : 
   21711             : 
   21712           1 :    }
   21713             : 
   21714             : //############################################################################
   21715             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   21716             :  * within the working AST. 
   21717             :  */
   21718           9 : SgTypeUnknown * SgTypeUnknown::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   21719           9 :      SgTypeUnknown* returnPointer = NULL;
   21720           9 :      if ( globalIndex != 0 )
   21721             :         {
   21722             : 
   21723             : #if FILE_IO_EXTRA_CHECK
   21724           9 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeUnknown ) ) <= globalIndex ) ;
   21725           9 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnknown + 1 ) ) );
   21726             : #endif
   21727           9 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnknown )  
   21728           9 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeUnknown );
   21729           9 :           unsigned long positionInPool = localIndex % SgTypeUnknown::pool_size;
   21730           9 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnknown::pool_size;
   21731             : 
   21732             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   21733             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   21734             : 
   21735           9 :           returnPointer = &( ( (SgTypeUnknown*)(SgTypeUnknown::pools[memoryBlock]) ) [positionInPool]) ;
   21736             : 
   21737           9 :           ROSE_ASSERT( returnPointer != NULL ) ;
   21738             :         }
   21739           9 :      return returnPointer ;
   21740             :    }
   21741             : 
   21742             : //############################################################################
   21743             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   21744             :   for the AST with the index astIndex
   21745             : */
   21746           0 : SgTypeUnknown * SgTypeUnknown::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   21747           0 :      SgTypeUnknown* returnPointer = NULL;
   21748           0 :      if ( globalIndex != 0 )
   21749             :         {
   21750             : 
   21751             : #if FILE_IO_EXTRA_CHECK
   21752           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeUnknown ) ) <= globalIndex ) ;
   21753           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnknown + 1 ) ) );
   21754             : #endif
   21755           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnknown )
   21756           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeUnknown );
   21757           0 :           unsigned long positionInPool = localIndex % SgTypeUnknown::pool_size ;
   21758           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnknown::pool_size ;
   21759             : 
   21760             : #if FILE_IO_EXTRA_CHECK
   21761             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   21762             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   21763             : #endif
   21764             : 
   21765           0 :           returnPointer = &( ( (SgTypeUnknown*)(SgTypeUnknown::pools[memoryBlock]) ) [positionInPool]) ;
   21766             : 
   21767             : #if FILE_IO_EXTRA_CHECK
   21768           0 :           assert ( returnPointer != NULL ) ;
   21769             : #endif
   21770             :         }
   21771           0 :      return returnPointer ;
   21772             :    }
   21773             : 
   21774             : //############################################################################
   21775             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   21776             :  * pool size! We set for every valid object in the memory pool the freepointer
   21777             :  * to the global index and increase the global index afterwards. For all the 
   21778             :  * invalid objects (means address ranges within the memory pool that were not
   21779             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   21780             :  * distinguish valid from invalid objects! 
   21781             :  */
   21782             : unsigned long
   21783           5 : SgTypeUnknown::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   21784             :    {
   21785           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   21786           5 :      SgTypeUnknown* pointer = NULL;
   21787           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   21788           5 :      std::vector < unsigned char* > :: const_iterator block;
   21789           6 :      for ( block = SgTypeUnknown::pools.begin(); block != SgTypeUnknown::pools.end() ; ++block )
   21790             :         {
   21791           1 :           pointer = (SgTypeUnknown*)(*block);
   21792        2001 :           for (unsigned i = 0; i < SgTypeUnknown::pool_size; ++i )
   21793             :              {
   21794             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   21795             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   21796             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   21797             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   21798             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   21799             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   21800             :             // properly; so this will have to be checked next.
   21801             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   21802             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   21803        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   21804             :                   {
   21805           1 :                     pointer[i].set_freepointer((SgTypeUnknown*)(globalIndex));
   21806           1 :                     globalIndex++;
   21807             :                   }
   21808             :                else
   21809             :                   {
   21810        1999 :                     pointer[i].set_freepointer(NULL);
   21811             :                   }
   21812             :               }
   21813             :         }
   21814           5 :      return globalIndex;
   21815             :    }
   21816             : 
   21817             : //############################################################################
   21818             : // JH (01/14/2006)
   21819             : void
   21820           5 : SgTypeUnknown::resetValidFreepointers( )
   21821             :    {
   21822           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   21823           5 :      SgTypeUnknown* pointer = NULL;
   21824           5 :      std::vector < unsigned char* > :: const_iterator block;
   21825           5 :      SgTypeUnknown* pointerOfLinkedList = NULL;
   21826           6 :      for ( block = SgTypeUnknown::pools.begin(); block != SgTypeUnknown::pools.end() ; ++block )
   21827             :         {
   21828           1 :           pointer = (SgTypeUnknown*)(*block);
   21829        2001 :           for (unsigned i = 0; i < SgTypeUnknown::pool_size; ++i )
   21830             :              {
   21831             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   21832             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   21833             :             // memory blocks!.
   21834        2000 :                if ( pointer[i].get_freepointer() != NULL )
   21835             :                   {
   21836           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   21837             :                   }
   21838             :                else
   21839             :                   {
   21840        1999 :                     if ( pointerOfLinkedList == NULL )
   21841             :                        {
   21842           1 :                          SgTypeUnknown::next_node = &(pointer[i]);
   21843             :                        }
   21844             :                     else
   21845             :                        {
   21846             :                       // printf ("In SgTypeUnknown::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   21847        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   21848             :                        }
   21849             :                     pointerOfLinkedList = &(pointer[i]);
   21850             :                   }
   21851             :               }
   21852             :         }
   21853             : 
   21854           5 :      if ( pointerOfLinkedList != NULL )
   21855             :         {
   21856             :        // printf ("In SgTypeUnknown::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   21857           1 :           pointerOfLinkedList->set_freepointer(NULL);
   21858             :        // DQ (6/6/2010): Temporary debugging...
   21859             :        //   ROSE_ASSERT(false);
   21860             :         }
   21861             : 
   21862           5 :      return ;
   21863             :    }
   21864             : 
   21865             : //############################################################################
   21866             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   21867             :  * within the memory pool and resets the freepointers, in order to achieve a 
   21868             :  * linked list, that has no jumps and starts at the beginning! This function 
   21869             :  * does not extend the memory pool, since we do not delete any memory blocks,
   21870             :  * but delete the valid objects.  
   21871             :  */
   21872             : void
   21873           0 : SgTypeUnknown::clearMemoryPool( )
   21874             :    {
   21875             :   // printf ("Inside of SgTypeUnknown::clearMemoryPool() \n");
   21876             : 
   21877           0 :      SgTypeUnknown* pointer = NULL, *tempPointer = NULL;
   21878           0 :      std::vector < unsigned char* > :: const_iterator block;
   21879           0 :      if ( SgTypeUnknown::pools.empty() == false )
   21880             :         {
   21881           0 :           block = SgTypeUnknown::pools.begin() ;
   21882           0 :           SgTypeUnknown::next_node = (SgTypeUnknown*) (*block);
   21883             : 
   21884           0 :           while ( block != SgTypeUnknown::pools.end() )
   21885             :              {
   21886           0 :                pointer = (SgTypeUnknown*) (*block);
   21887           0 :                if ( tempPointer != NULL )
   21888             :                   {
   21889           0 :                     tempPointer->set_freepointer(pointer);
   21890             :                   }
   21891           0 :                for (unsigned i = 0; i < SgTypeUnknown::pool_size - 1; ++i)
   21892             :                   {
   21893           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   21894             :                   }
   21895           0 :                 pointer[SgTypeUnknown::pool_size-1].set_freepointer(NULL);
   21896           0 :                 tempPointer = &(pointer[SgTypeUnknown::pool_size-1]);
   21897           0 :                 ++block;
   21898             :              }
   21899             :         }
   21900           0 :    }
   21901             : 
   21902           5 : void SgTypeUnknown::deleteMemoryPool() {
   21903           7 :   for (auto p: SgTypeUnknown::pools) {
   21904           2 :     ROSE_FREE(p);
   21905             :   }
   21906           5 :   SgTypeUnknown::next_node = nullptr;
   21907           5 :   SgTypeUnknown::pools.clear();
   21908           5 : }
   21909             : 
   21910             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   21911             : //                 reading multiple binary files to for a single AST.
   21912             : /////////// new version ////////////////////////////////
   21913             : //############################################################################
   21914             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   21915             : void
   21916           2 : SgTypeUnknown::extendMemoryPoolForFileIO( )
   21917             :   {
   21918           2 :     size_t blockIndex = SgTypeUnknown::pools.size();
   21919           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnknown) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnknown);
   21920             : 
   21921           3 :     while ( (blockIndex * SgTypeUnknown::pool_size) < newPoolSize)
   21922             :       {
   21923             : #if ROSE_ALLOC_TRACE
   21924             :         if (blockIndex > 0) {
   21925             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnknown) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnknown) = %" PRIuPTR " SgTypeUnknown::pool_size = %d \n",
   21926             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnknown),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnknown),SgTypeUnknown::pool_size);
   21927             :         }
   21928             : #endif
   21929             : 
   21930           1 :         SgTypeUnknown * pointer = (SgTypeUnknown*) ROSE_MALLOC ( SgTypeUnknown::pool_size * sizeof(SgTypeUnknown) );
   21931           1 :         assert( pointer != NULL );
   21932             : #if ROSE_ALLOC_MEMSET == 1
   21933             :         memset(pointer, 0x00, SgTypeUnknown::pool_size * sizeof(SgTypeUnknown));
   21934             : #elif ROSE_ALLOC_MEMSET == 2
   21935             :         memset(pointer, 0xCC, SgTypeUnknown::pool_size * sizeof(SgTypeUnknown));
   21936             : #endif
   21937           1 :         SgTypeUnknown::pools.push_back( (unsigned char*)(pointer) );
   21938           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeUnknown::pool_size * sizeof(SgTypeUnknown), V_SgTypeUnknown ) );
   21939             : 
   21940           1 :         if ( SgTypeUnknown::next_node != NULL ) {
   21941           0 :           if ( blockIndex > 0 ) {
   21942           0 :             SgTypeUnknown * blkptr = (SgTypeUnknown*)(SgTypeUnknown::pools[blockIndex-1]);
   21943           0 :             blkptr[ SgTypeUnknown::pool_size - 1 ].set_freepointer(pointer);
   21944             :           }
   21945             :         } else {
   21946           1 :           SgTypeUnknown::next_node = pointer;
   21947             :         }
   21948             : 
   21949        2000 :         for (unsigned i = 0; i < SgTypeUnknown::pool_size-1; ++i)
   21950             :            {
   21951        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   21952             :            }
   21953           1 :         pointer[ SgTypeUnknown::pool_size -1 ].set_freepointer(NULL);
   21954             : 
   21955           1 :         blockIndex++;
   21956             :       }
   21957           2 :   }
   21958             : 
   21959             : //############################################################################
   21960             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   21961             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   21962             :  * not compressed. However, that stuff is not yet implemented! 
   21963             :  */
   21964             : unsigned long
   21965           0 : SgTypeUnknown::getNumberOfLastValidPointer()
   21966             :    {
   21967           0 :       SgTypeUnknown* testPointer = (SgTypeUnknown*)(SgTypeUnknown::pools.back());
   21968           0 :       unsigned long localIndex = SgTypeUnknown::pool_size - 1;
   21969           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   21970             :          {
   21971           0 :            localIndex--;
   21972             :          }
   21973           0 :       return (localIndex + SgTypeUnknown::pool_size * (SgTypeUnknown::pools.size()-1));
   21974             :    }
   21975             : 
   21976             : //############################################################################
   21977             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   21978             :  * memory pool and initializes the data member in class SgTypeUnknownStroageClass
   21979             :  * from its counterpart of SgTypeUnknown. The return value is just for checking, 
   21980             :  * that the whole StorageClassArray is initialized!
   21981             :  */
   21982             : unsigned long
   21983           1 : SgTypeUnknown::initializeStorageClassArray( SgTypeUnknownStorageClass *storageArray )
   21984             :    {
   21985           1 :      unsigned long storageCounter = 0;
   21986           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeUnknown::pools.begin();
   21987           1 :      SgTypeUnknown* pointer = NULL;
   21988           2 :      while ( block != SgTypeUnknown::pools.end() ) {
   21989           1 :           pointer = (SgTypeUnknown*) (*block);
   21990        2001 :           for ( unsigned i = 0; i < SgTypeUnknown::pool_size; ++i ) {
   21991        2000 :                if ( pointer->get_freepointer() != NULL ) {
   21992           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   21993           1 :                  storageArray++;
   21994           1 :                  storageCounter++;
   21995             :                }
   21996        2000 :                pointer++;
   21997             :              }
   21998           1 :            block++;
   21999             :         }
   22000           1 :      return storageCounter;
   22001             :    }
   22002             : 
   22003             : /* #line 22004 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   22004             : 
   22005             : 
   22006             : 
   22007             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   22008             : 
   22009             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   22010             : 
   22011             : //############################################################################
   22012             : /* JH (02/02/2006) Constructor of the IR node SgTypeChar that takes its 
   22013             :  * corresponding StorageClass as parameter
   22014             :  */
   22015           2 : SgTypeChar :: SgTypeChar ( const SgTypeCharStorageClass& storageSource )   : SgType (storageSource)
   22016             :    {
   22017             : 
   22018             : 
   22019             : /* #line 22020 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   22020             : 
   22021           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   22022             : 
   22023             : 
   22024             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   22025             : 
   22026             : 
   22027           2 :    }
   22028             : 
   22029             : //############################################################################
   22030             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   22031             :  * within the working AST. 
   22032             :  */
   22033         632 : SgTypeChar * SgTypeChar::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   22034         632 :      SgTypeChar* returnPointer = NULL;
   22035         632 :      if ( globalIndex != 0 )
   22036             :         {
   22037             : 
   22038             : #if FILE_IO_EXTRA_CHECK
   22039         632 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeChar ) ) <= globalIndex ) ;
   22040         632 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeChar + 1 ) ) );
   22041             : #endif
   22042         632 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeChar )  
   22043         632 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeChar );
   22044         632 :           unsigned long positionInPool = localIndex % SgTypeChar::pool_size;
   22045         632 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeChar::pool_size;
   22046             : 
   22047             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   22048             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   22049             : 
   22050         632 :           returnPointer = &( ( (SgTypeChar*)(SgTypeChar::pools[memoryBlock]) ) [positionInPool]) ;
   22051             : 
   22052         632 :           ROSE_ASSERT( returnPointer != NULL ) ;
   22053             :         }
   22054         632 :      return returnPointer ;
   22055             :    }
   22056             : 
   22057             : //############################################################################
   22058             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   22059             :   for the AST with the index astIndex
   22060             : */
   22061           0 : SgTypeChar * SgTypeChar::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   22062           0 :      SgTypeChar* returnPointer = NULL;
   22063           0 :      if ( globalIndex != 0 )
   22064             :         {
   22065             : 
   22066             : #if FILE_IO_EXTRA_CHECK
   22067           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeChar ) ) <= globalIndex ) ;
   22068           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeChar + 1 ) ) );
   22069             : #endif
   22070           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeChar )
   22071           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeChar );
   22072           0 :           unsigned long positionInPool = localIndex % SgTypeChar::pool_size ;
   22073           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeChar::pool_size ;
   22074             : 
   22075             : #if FILE_IO_EXTRA_CHECK
   22076             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   22077             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   22078             : #endif
   22079             : 
   22080           0 :           returnPointer = &( ( (SgTypeChar*)(SgTypeChar::pools[memoryBlock]) ) [positionInPool]) ;
   22081             : 
   22082             : #if FILE_IO_EXTRA_CHECK
   22083           0 :           assert ( returnPointer != NULL ) ;
   22084             : #endif
   22085             :         }
   22086           0 :      return returnPointer ;
   22087             :    }
   22088             : 
   22089             : //############################################################################
   22090             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   22091             :  * pool size! We set for every valid object in the memory pool the freepointer
   22092             :  * to the global index and increase the global index afterwards. For all the 
   22093             :  * invalid objects (means address ranges within the memory pool that were not
   22094             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   22095             :  * distinguish valid from invalid objects! 
   22096             :  */
   22097             : unsigned long
   22098           5 : SgTypeChar::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   22099             :    {
   22100           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   22101           5 :      SgTypeChar* pointer = NULL;
   22102           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   22103           5 :      std::vector < unsigned char* > :: const_iterator block;
   22104           7 :      for ( block = SgTypeChar::pools.begin(); block != SgTypeChar::pools.end() ; ++block )
   22105             :         {
   22106           2 :           pointer = (SgTypeChar*)(*block);
   22107        4002 :           for (unsigned i = 0; i < SgTypeChar::pool_size; ++i )
   22108             :              {
   22109             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   22110             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   22111             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   22112             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   22113             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   22114             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   22115             :             // properly; so this will have to be checked next.
   22116             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   22117             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   22118        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   22119             :                   {
   22120           2 :                     pointer[i].set_freepointer((SgTypeChar*)(globalIndex));
   22121           2 :                     globalIndex++;
   22122             :                   }
   22123             :                else
   22124             :                   {
   22125        3998 :                     pointer[i].set_freepointer(NULL);
   22126             :                   }
   22127             :               }
   22128             :         }
   22129           5 :      return globalIndex;
   22130             :    }
   22131             : 
   22132             : //############################################################################
   22133             : // JH (01/14/2006)
   22134             : void
   22135           5 : SgTypeChar::resetValidFreepointers( )
   22136             :    {
   22137           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   22138           5 :      SgTypeChar* pointer = NULL;
   22139           5 :      std::vector < unsigned char* > :: const_iterator block;
   22140           5 :      SgTypeChar* pointerOfLinkedList = NULL;
   22141           7 :      for ( block = SgTypeChar::pools.begin(); block != SgTypeChar::pools.end() ; ++block )
   22142             :         {
   22143           2 :           pointer = (SgTypeChar*)(*block);
   22144        4002 :           for (unsigned i = 0; i < SgTypeChar::pool_size; ++i )
   22145             :              {
   22146             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   22147             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   22148             :             // memory blocks!.
   22149        4000 :                if ( pointer[i].get_freepointer() != NULL )
   22150             :                   {
   22151           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   22152             :                   }
   22153             :                else
   22154             :                   {
   22155        3998 :                     if ( pointerOfLinkedList == NULL )
   22156             :                        {
   22157           2 :                          SgTypeChar::next_node = &(pointer[i]);
   22158             :                        }
   22159             :                     else
   22160             :                        {
   22161             :                       // printf ("In SgTypeChar::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   22162        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   22163             :                        }
   22164             :                     pointerOfLinkedList = &(pointer[i]);
   22165             :                   }
   22166             :               }
   22167             :         }
   22168             : 
   22169           5 :      if ( pointerOfLinkedList != NULL )
   22170             :         {
   22171             :        // printf ("In SgTypeChar::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   22172           2 :           pointerOfLinkedList->set_freepointer(NULL);
   22173             :        // DQ (6/6/2010): Temporary debugging...
   22174             :        //   ROSE_ASSERT(false);
   22175             :         }
   22176             : 
   22177           5 :      return ;
   22178             :    }
   22179             : 
   22180             : //############################################################################
   22181             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   22182             :  * within the memory pool and resets the freepointers, in order to achieve a 
   22183             :  * linked list, that has no jumps and starts at the beginning! This function 
   22184             :  * does not extend the memory pool, since we do not delete any memory blocks,
   22185             :  * but delete the valid objects.  
   22186             :  */
   22187             : void
   22188           0 : SgTypeChar::clearMemoryPool( )
   22189             :    {
   22190             :   // printf ("Inside of SgTypeChar::clearMemoryPool() \n");
   22191             : 
   22192           0 :      SgTypeChar* pointer = NULL, *tempPointer = NULL;
   22193           0 :      std::vector < unsigned char* > :: const_iterator block;
   22194           0 :      if ( SgTypeChar::pools.empty() == false )
   22195             :         {
   22196           0 :           block = SgTypeChar::pools.begin() ;
   22197           0 :           SgTypeChar::next_node = (SgTypeChar*) (*block);
   22198             : 
   22199           0 :           while ( block != SgTypeChar::pools.end() )
   22200             :              {
   22201           0 :                pointer = (SgTypeChar*) (*block);
   22202           0 :                if ( tempPointer != NULL )
   22203             :                   {
   22204           0 :                     tempPointer->set_freepointer(pointer);
   22205             :                   }
   22206           0 :                for (unsigned i = 0; i < SgTypeChar::pool_size - 1; ++i)
   22207             :                   {
   22208           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   22209             :                   }
   22210           0 :                 pointer[SgTypeChar::pool_size-1].set_freepointer(NULL);
   22211           0 :                 tempPointer = &(pointer[SgTypeChar::pool_size-1]);
   22212           0 :                 ++block;
   22213             :              }
   22214             :         }
   22215           0 :    }
   22216             : 
   22217           5 : void SgTypeChar::deleteMemoryPool() {
   22218           9 :   for (auto p: SgTypeChar::pools) {
   22219           4 :     ROSE_FREE(p);
   22220             :   }
   22221           5 :   SgTypeChar::next_node = nullptr;
   22222           5 :   SgTypeChar::pools.clear();
   22223           5 : }
   22224             : 
   22225             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   22226             : //                 reading multiple binary files to for a single AST.
   22227             : /////////// new version ////////////////////////////////
   22228             : //############################################################################
   22229             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   22230             : void
   22231           2 : SgTypeChar::extendMemoryPoolForFileIO( )
   22232             :   {
   22233           2 :     size_t blockIndex = SgTypeChar::pools.size();
   22234           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar);
   22235             : 
   22236           4 :     while ( (blockIndex * SgTypeChar::pool_size) < newPoolSize)
   22237             :       {
   22238             : #if ROSE_ALLOC_TRACE
   22239             :         if (blockIndex > 0) {
   22240             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar) = %" PRIuPTR " SgTypeChar::pool_size = %d \n",
   22241             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar),SgTypeChar::pool_size);
   22242             :         }
   22243             : #endif
   22244             : 
   22245           2 :         SgTypeChar * pointer = (SgTypeChar*) ROSE_MALLOC ( SgTypeChar::pool_size * sizeof(SgTypeChar) );
   22246           2 :         assert( pointer != NULL );
   22247             : #if ROSE_ALLOC_MEMSET == 1
   22248             :         memset(pointer, 0x00, SgTypeChar::pool_size * sizeof(SgTypeChar));
   22249             : #elif ROSE_ALLOC_MEMSET == 2
   22250             :         memset(pointer, 0xCC, SgTypeChar::pool_size * sizeof(SgTypeChar));
   22251             : #endif
   22252           2 :         SgTypeChar::pools.push_back( (unsigned char*)(pointer) );
   22253           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeChar::pool_size * sizeof(SgTypeChar), V_SgTypeChar ) );
   22254             : 
   22255           2 :         if ( SgTypeChar::next_node != NULL ) {
   22256           0 :           if ( blockIndex > 0 ) {
   22257           0 :             SgTypeChar * blkptr = (SgTypeChar*)(SgTypeChar::pools[blockIndex-1]);
   22258           0 :             blkptr[ SgTypeChar::pool_size - 1 ].set_freepointer(pointer);
   22259             :           }
   22260             :         } else {
   22261           2 :           SgTypeChar::next_node = pointer;
   22262             :         }
   22263             : 
   22264        4000 :         for (unsigned i = 0; i < SgTypeChar::pool_size-1; ++i)
   22265             :            {
   22266        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   22267             :            }
   22268           2 :         pointer[ SgTypeChar::pool_size -1 ].set_freepointer(NULL);
   22269             : 
   22270           2 :         blockIndex++;
   22271             :       }
   22272           2 :   }
   22273             : 
   22274             : //############################################################################
   22275             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   22276             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   22277             :  * not compressed. However, that stuff is not yet implemented! 
   22278             :  */
   22279             : unsigned long
   22280           0 : SgTypeChar::getNumberOfLastValidPointer()
   22281             :    {
   22282           0 :       SgTypeChar* testPointer = (SgTypeChar*)(SgTypeChar::pools.back());
   22283           0 :       unsigned long localIndex = SgTypeChar::pool_size - 1;
   22284           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   22285             :          {
   22286           0 :            localIndex--;
   22287             :          }
   22288           0 :       return (localIndex + SgTypeChar::pool_size * (SgTypeChar::pools.size()-1));
   22289             :    }
   22290             : 
   22291             : //############################################################################
   22292             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   22293             :  * memory pool and initializes the data member in class SgTypeCharStroageClass
   22294             :  * from its counterpart of SgTypeChar. The return value is just for checking, 
   22295             :  * that the whole StorageClassArray is initialized!
   22296             :  */
   22297             : unsigned long
   22298           2 : SgTypeChar::initializeStorageClassArray( SgTypeCharStorageClass *storageArray )
   22299             :    {
   22300           2 :      unsigned long storageCounter = 0;
   22301           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeChar::pools.begin();
   22302           2 :      SgTypeChar* pointer = NULL;
   22303           4 :      while ( block != SgTypeChar::pools.end() ) {
   22304           2 :           pointer = (SgTypeChar*) (*block);
   22305        4002 :           for ( unsigned i = 0; i < SgTypeChar::pool_size; ++i ) {
   22306        4000 :                if ( pointer->get_freepointer() != NULL ) {
   22307           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   22308           2 :                  storageArray++;
   22309           2 :                  storageCounter++;
   22310             :                }
   22311        4000 :                pointer++;
   22312             :              }
   22313           2 :            block++;
   22314             :         }
   22315           2 :      return storageCounter;
   22316             :    }
   22317             : 
   22318             : /* #line 22319 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   22319             : 
   22320             : 
   22321             : 
   22322             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   22323             : 
   22324             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   22325             : 
   22326             : //############################################################################
   22327             : /* JH (02/02/2006) Constructor of the IR node SgTypeSignedChar that takes its 
   22328             :  * corresponding StorageClass as parameter
   22329             :  */
   22330           2 : SgTypeSignedChar :: SgTypeSignedChar ( const SgTypeSignedCharStorageClass& storageSource )   : SgType (storageSource)
   22331             :    {
   22332             : 
   22333             : 
   22334             : /* #line 22335 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   22335             : 
   22336           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   22337             : 
   22338             : 
   22339             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   22340             : 
   22341             : 
   22342           2 :    }
   22343             : 
   22344             : //############################################################################
   22345             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   22346             :  * within the working AST. 
   22347             :  */
   22348          39 : SgTypeSignedChar * SgTypeSignedChar::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   22349          39 :      SgTypeSignedChar* returnPointer = NULL;
   22350          39 :      if ( globalIndex != 0 )
   22351             :         {
   22352             : 
   22353             : #if FILE_IO_EXTRA_CHECK
   22354          39 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeSignedChar ) ) <= globalIndex ) ;
   22355          39 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedChar + 1 ) ) );
   22356             : #endif
   22357          39 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedChar )  
   22358          39 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeSignedChar );
   22359          39 :           unsigned long positionInPool = localIndex % SgTypeSignedChar::pool_size;
   22360          39 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedChar::pool_size;
   22361             : 
   22362             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   22363             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   22364             : 
   22365          39 :           returnPointer = &( ( (SgTypeSignedChar*)(SgTypeSignedChar::pools[memoryBlock]) ) [positionInPool]) ;
   22366             : 
   22367          39 :           ROSE_ASSERT( returnPointer != NULL ) ;
   22368             :         }
   22369          39 :      return returnPointer ;
   22370             :    }
   22371             : 
   22372             : //############################################################################
   22373             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   22374             :   for the AST with the index astIndex
   22375             : */
   22376           0 : SgTypeSignedChar * SgTypeSignedChar::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   22377           0 :      SgTypeSignedChar* returnPointer = NULL;
   22378           0 :      if ( globalIndex != 0 )
   22379             :         {
   22380             : 
   22381             : #if FILE_IO_EXTRA_CHECK
   22382           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeSignedChar ) ) <= globalIndex ) ;
   22383           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedChar + 1 ) ) );
   22384             : #endif
   22385           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedChar )
   22386           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeSignedChar );
   22387           0 :           unsigned long positionInPool = localIndex % SgTypeSignedChar::pool_size ;
   22388           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedChar::pool_size ;
   22389             : 
   22390             : #if FILE_IO_EXTRA_CHECK
   22391             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   22392             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   22393             : #endif
   22394             : 
   22395           0 :           returnPointer = &( ( (SgTypeSignedChar*)(SgTypeSignedChar::pools[memoryBlock]) ) [positionInPool]) ;
   22396             : 
   22397             : #if FILE_IO_EXTRA_CHECK
   22398           0 :           assert ( returnPointer != NULL ) ;
   22399             : #endif
   22400             :         }
   22401           0 :      return returnPointer ;
   22402             :    }
   22403             : 
   22404             : //############################################################################
   22405             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   22406             :  * pool size! We set for every valid object in the memory pool the freepointer
   22407             :  * to the global index and increase the global index afterwards. For all the 
   22408             :  * invalid objects (means address ranges within the memory pool that were not
   22409             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   22410             :  * distinguish valid from invalid objects! 
   22411             :  */
   22412             : unsigned long
   22413           5 : SgTypeSignedChar::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   22414             :    {
   22415           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   22416           5 :      SgTypeSignedChar* pointer = NULL;
   22417           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   22418           5 :      std::vector < unsigned char* > :: const_iterator block;
   22419           7 :      for ( block = SgTypeSignedChar::pools.begin(); block != SgTypeSignedChar::pools.end() ; ++block )
   22420             :         {
   22421           2 :           pointer = (SgTypeSignedChar*)(*block);
   22422        4002 :           for (unsigned i = 0; i < SgTypeSignedChar::pool_size; ++i )
   22423             :              {
   22424             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   22425             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   22426             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   22427             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   22428             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   22429             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   22430             :             // properly; so this will have to be checked next.
   22431             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   22432             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   22433        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   22434             :                   {
   22435           2 :                     pointer[i].set_freepointer((SgTypeSignedChar*)(globalIndex));
   22436           2 :                     globalIndex++;
   22437             :                   }
   22438             :                else
   22439             :                   {
   22440        3998 :                     pointer[i].set_freepointer(NULL);
   22441             :                   }
   22442             :               }
   22443             :         }
   22444           5 :      return globalIndex;
   22445             :    }
   22446             : 
   22447             : //############################################################################
   22448             : // JH (01/14/2006)
   22449             : void
   22450           5 : SgTypeSignedChar::resetValidFreepointers( )
   22451             :    {
   22452           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   22453           5 :      SgTypeSignedChar* pointer = NULL;
   22454           5 :      std::vector < unsigned char* > :: const_iterator block;
   22455           5 :      SgTypeSignedChar* pointerOfLinkedList = NULL;
   22456           7 :      for ( block = SgTypeSignedChar::pools.begin(); block != SgTypeSignedChar::pools.end() ; ++block )
   22457             :         {
   22458           2 :           pointer = (SgTypeSignedChar*)(*block);
   22459        4002 :           for (unsigned i = 0; i < SgTypeSignedChar::pool_size; ++i )
   22460             :              {
   22461             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   22462             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   22463             :             // memory blocks!.
   22464        4000 :                if ( pointer[i].get_freepointer() != NULL )
   22465             :                   {
   22466           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   22467             :                   }
   22468             :                else
   22469             :                   {
   22470        3998 :                     if ( pointerOfLinkedList == NULL )
   22471             :                        {
   22472           2 :                          SgTypeSignedChar::next_node = &(pointer[i]);
   22473             :                        }
   22474             :                     else
   22475             :                        {
   22476             :                       // printf ("In SgTypeSignedChar::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   22477        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   22478             :                        }
   22479             :                     pointerOfLinkedList = &(pointer[i]);
   22480             :                   }
   22481             :               }
   22482             :         }
   22483             : 
   22484           5 :      if ( pointerOfLinkedList != NULL )
   22485             :         {
   22486             :        // printf ("In SgTypeSignedChar::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   22487           2 :           pointerOfLinkedList->set_freepointer(NULL);
   22488             :        // DQ (6/6/2010): Temporary debugging...
   22489             :        //   ROSE_ASSERT(false);
   22490             :         }
   22491             : 
   22492           5 :      return ;
   22493             :    }
   22494             : 
   22495             : //############################################################################
   22496             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   22497             :  * within the memory pool and resets the freepointers, in order to achieve a 
   22498             :  * linked list, that has no jumps and starts at the beginning! This function 
   22499             :  * does not extend the memory pool, since we do not delete any memory blocks,
   22500             :  * but delete the valid objects.  
   22501             :  */
   22502             : void
   22503           0 : SgTypeSignedChar::clearMemoryPool( )
   22504             :    {
   22505             :   // printf ("Inside of SgTypeSignedChar::clearMemoryPool() \n");
   22506             : 
   22507           0 :      SgTypeSignedChar* pointer = NULL, *tempPointer = NULL;
   22508           0 :      std::vector < unsigned char* > :: const_iterator block;
   22509           0 :      if ( SgTypeSignedChar::pools.empty() == false )
   22510             :         {
   22511           0 :           block = SgTypeSignedChar::pools.begin() ;
   22512           0 :           SgTypeSignedChar::next_node = (SgTypeSignedChar*) (*block);
   22513             : 
   22514           0 :           while ( block != SgTypeSignedChar::pools.end() )
   22515             :              {
   22516           0 :                pointer = (SgTypeSignedChar*) (*block);
   22517           0 :                if ( tempPointer != NULL )
   22518             :                   {
   22519           0 :                     tempPointer->set_freepointer(pointer);
   22520             :                   }
   22521           0 :                for (unsigned i = 0; i < SgTypeSignedChar::pool_size - 1; ++i)
   22522             :                   {
   22523           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   22524             :                   }
   22525           0 :                 pointer[SgTypeSignedChar::pool_size-1].set_freepointer(NULL);
   22526           0 :                 tempPointer = &(pointer[SgTypeSignedChar::pool_size-1]);
   22527           0 :                 ++block;
   22528             :              }
   22529             :         }
   22530           0 :    }
   22531             : 
   22532           5 : void SgTypeSignedChar::deleteMemoryPool() {
   22533           9 :   for (auto p: SgTypeSignedChar::pools) {
   22534           4 :     ROSE_FREE(p);
   22535             :   }
   22536           5 :   SgTypeSignedChar::next_node = nullptr;
   22537           5 :   SgTypeSignedChar::pools.clear();
   22538           5 : }
   22539             : 
   22540             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   22541             : //                 reading multiple binary files to for a single AST.
   22542             : /////////// new version ////////////////////////////////
   22543             : //############################################################################
   22544             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   22545             : void
   22546           2 : SgTypeSignedChar::extendMemoryPoolForFileIO( )
   22547             :   {
   22548           2 :     size_t blockIndex = SgTypeSignedChar::pools.size();
   22549           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedChar) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedChar);
   22550             : 
   22551           4 :     while ( (blockIndex * SgTypeSignedChar::pool_size) < newPoolSize)
   22552             :       {
   22553             : #if ROSE_ALLOC_TRACE
   22554             :         if (blockIndex > 0) {
   22555             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedChar) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedChar) = %" PRIuPTR " SgTypeSignedChar::pool_size = %d \n",
   22556             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedChar),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedChar),SgTypeSignedChar::pool_size);
   22557             :         }
   22558             : #endif
   22559             : 
   22560           2 :         SgTypeSignedChar * pointer = (SgTypeSignedChar*) ROSE_MALLOC ( SgTypeSignedChar::pool_size * sizeof(SgTypeSignedChar) );
   22561           2 :         assert( pointer != NULL );
   22562             : #if ROSE_ALLOC_MEMSET == 1
   22563             :         memset(pointer, 0x00, SgTypeSignedChar::pool_size * sizeof(SgTypeSignedChar));
   22564             : #elif ROSE_ALLOC_MEMSET == 2
   22565             :         memset(pointer, 0xCC, SgTypeSignedChar::pool_size * sizeof(SgTypeSignedChar));
   22566             : #endif
   22567           2 :         SgTypeSignedChar::pools.push_back( (unsigned char*)(pointer) );
   22568           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeSignedChar::pool_size * sizeof(SgTypeSignedChar), V_SgTypeSignedChar ) );
   22569             : 
   22570           2 :         if ( SgTypeSignedChar::next_node != NULL ) {
   22571           0 :           if ( blockIndex > 0 ) {
   22572           0 :             SgTypeSignedChar * blkptr = (SgTypeSignedChar*)(SgTypeSignedChar::pools[blockIndex-1]);
   22573           0 :             blkptr[ SgTypeSignedChar::pool_size - 1 ].set_freepointer(pointer);
   22574             :           }
   22575             :         } else {
   22576           2 :           SgTypeSignedChar::next_node = pointer;
   22577             :         }
   22578             : 
   22579        4000 :         for (unsigned i = 0; i < SgTypeSignedChar::pool_size-1; ++i)
   22580             :            {
   22581        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   22582             :            }
   22583           2 :         pointer[ SgTypeSignedChar::pool_size -1 ].set_freepointer(NULL);
   22584             : 
   22585           2 :         blockIndex++;
   22586             :       }
   22587           2 :   }
   22588             : 
   22589             : //############################################################################
   22590             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   22591             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   22592             :  * not compressed. However, that stuff is not yet implemented! 
   22593             :  */
   22594             : unsigned long
   22595           0 : SgTypeSignedChar::getNumberOfLastValidPointer()
   22596             :    {
   22597           0 :       SgTypeSignedChar* testPointer = (SgTypeSignedChar*)(SgTypeSignedChar::pools.back());
   22598           0 :       unsigned long localIndex = SgTypeSignedChar::pool_size - 1;
   22599           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   22600             :          {
   22601           0 :            localIndex--;
   22602             :          }
   22603           0 :       return (localIndex + SgTypeSignedChar::pool_size * (SgTypeSignedChar::pools.size()-1));
   22604             :    }
   22605             : 
   22606             : //############################################################################
   22607             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   22608             :  * memory pool and initializes the data member in class SgTypeSignedCharStroageClass
   22609             :  * from its counterpart of SgTypeSignedChar. The return value is just for checking, 
   22610             :  * that the whole StorageClassArray is initialized!
   22611             :  */
   22612             : unsigned long
   22613           2 : SgTypeSignedChar::initializeStorageClassArray( SgTypeSignedCharStorageClass *storageArray )
   22614             :    {
   22615           2 :      unsigned long storageCounter = 0;
   22616           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeSignedChar::pools.begin();
   22617           2 :      SgTypeSignedChar* pointer = NULL;
   22618           4 :      while ( block != SgTypeSignedChar::pools.end() ) {
   22619           2 :           pointer = (SgTypeSignedChar*) (*block);
   22620        4002 :           for ( unsigned i = 0; i < SgTypeSignedChar::pool_size; ++i ) {
   22621        4000 :                if ( pointer->get_freepointer() != NULL ) {
   22622           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   22623           2 :                  storageArray++;
   22624           2 :                  storageCounter++;
   22625             :                }
   22626        4000 :                pointer++;
   22627             :              }
   22628           2 :            block++;
   22629             :         }
   22630           2 :      return storageCounter;
   22631             :    }
   22632             : 
   22633             : /* #line 22634 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   22634             : 
   22635             : 
   22636             : 
   22637             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   22638             : 
   22639             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   22640             : 
   22641             : //############################################################################
   22642             : /* JH (02/02/2006) Constructor of the IR node SgTypeUnsignedChar that takes its 
   22643             :  * corresponding StorageClass as parameter
   22644             :  */
   22645           2 : SgTypeUnsignedChar :: SgTypeUnsignedChar ( const SgTypeUnsignedCharStorageClass& storageSource )   : SgType (storageSource)
   22646             :    {
   22647             : 
   22648             : 
   22649             : /* #line 22650 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   22650             : 
   22651           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   22652             : 
   22653             : 
   22654             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   22655             : 
   22656             : 
   22657           2 :    }
   22658             : 
   22659             : //############################################################################
   22660             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   22661             :  * within the working AST. 
   22662             :  */
   22663         135 : SgTypeUnsignedChar * SgTypeUnsignedChar::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   22664         135 :      SgTypeUnsignedChar* returnPointer = NULL;
   22665         135 :      if ( globalIndex != 0 )
   22666             :         {
   22667             : 
   22668             : #if FILE_IO_EXTRA_CHECK
   22669         135 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeUnsignedChar ) ) <= globalIndex ) ;
   22670         135 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedChar + 1 ) ) );
   22671             : #endif
   22672         135 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedChar )  
   22673         135 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeUnsignedChar );
   22674         135 :           unsigned long positionInPool = localIndex % SgTypeUnsignedChar::pool_size;
   22675         135 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedChar::pool_size;
   22676             : 
   22677             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   22678             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   22679             : 
   22680         135 :           returnPointer = &( ( (SgTypeUnsignedChar*)(SgTypeUnsignedChar::pools[memoryBlock]) ) [positionInPool]) ;
   22681             : 
   22682         135 :           ROSE_ASSERT( returnPointer != NULL ) ;
   22683             :         }
   22684         135 :      return returnPointer ;
   22685             :    }
   22686             : 
   22687             : //############################################################################
   22688             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   22689             :   for the AST with the index astIndex
   22690             : */
   22691           0 : SgTypeUnsignedChar * SgTypeUnsignedChar::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   22692           0 :      SgTypeUnsignedChar* returnPointer = NULL;
   22693           0 :      if ( globalIndex != 0 )
   22694             :         {
   22695             : 
   22696             : #if FILE_IO_EXTRA_CHECK
   22697           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeUnsignedChar ) ) <= globalIndex ) ;
   22698           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedChar + 1 ) ) );
   22699             : #endif
   22700           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedChar )
   22701           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeUnsignedChar );
   22702           0 :           unsigned long positionInPool = localIndex % SgTypeUnsignedChar::pool_size ;
   22703           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedChar::pool_size ;
   22704             : 
   22705             : #if FILE_IO_EXTRA_CHECK
   22706             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   22707             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   22708             : #endif
   22709             : 
   22710           0 :           returnPointer = &( ( (SgTypeUnsignedChar*)(SgTypeUnsignedChar::pools[memoryBlock]) ) [positionInPool]) ;
   22711             : 
   22712             : #if FILE_IO_EXTRA_CHECK
   22713           0 :           assert ( returnPointer != NULL ) ;
   22714             : #endif
   22715             :         }
   22716           0 :      return returnPointer ;
   22717             :    }
   22718             : 
   22719             : //############################################################################
   22720             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   22721             :  * pool size! We set for every valid object in the memory pool the freepointer
   22722             :  * to the global index and increase the global index afterwards. For all the 
   22723             :  * invalid objects (means address ranges within the memory pool that were not
   22724             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   22725             :  * distinguish valid from invalid objects! 
   22726             :  */
   22727             : unsigned long
   22728           5 : SgTypeUnsignedChar::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   22729             :    {
   22730           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   22731           5 :      SgTypeUnsignedChar* pointer = NULL;
   22732           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   22733           5 :      std::vector < unsigned char* > :: const_iterator block;
   22734           7 :      for ( block = SgTypeUnsignedChar::pools.begin(); block != SgTypeUnsignedChar::pools.end() ; ++block )
   22735             :         {
   22736           2 :           pointer = (SgTypeUnsignedChar*)(*block);
   22737        4002 :           for (unsigned i = 0; i < SgTypeUnsignedChar::pool_size; ++i )
   22738             :              {
   22739             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   22740             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   22741             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   22742             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   22743             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   22744             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   22745             :             // properly; so this will have to be checked next.
   22746             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   22747             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   22748        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   22749             :                   {
   22750           2 :                     pointer[i].set_freepointer((SgTypeUnsignedChar*)(globalIndex));
   22751           2 :                     globalIndex++;
   22752             :                   }
   22753             :                else
   22754             :                   {
   22755        3998 :                     pointer[i].set_freepointer(NULL);
   22756             :                   }
   22757             :               }
   22758             :         }
   22759           5 :      return globalIndex;
   22760             :    }
   22761             : 
   22762             : //############################################################################
   22763             : // JH (01/14/2006)
   22764             : void
   22765           5 : SgTypeUnsignedChar::resetValidFreepointers( )
   22766             :    {
   22767           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   22768           5 :      SgTypeUnsignedChar* pointer = NULL;
   22769           5 :      std::vector < unsigned char* > :: const_iterator block;
   22770           5 :      SgTypeUnsignedChar* pointerOfLinkedList = NULL;
   22771           7 :      for ( block = SgTypeUnsignedChar::pools.begin(); block != SgTypeUnsignedChar::pools.end() ; ++block )
   22772             :         {
   22773           2 :           pointer = (SgTypeUnsignedChar*)(*block);
   22774        4002 :           for (unsigned i = 0; i < SgTypeUnsignedChar::pool_size; ++i )
   22775             :              {
   22776             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   22777             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   22778             :             // memory blocks!.
   22779        4000 :                if ( pointer[i].get_freepointer() != NULL )
   22780             :                   {
   22781           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   22782             :                   }
   22783             :                else
   22784             :                   {
   22785        3998 :                     if ( pointerOfLinkedList == NULL )
   22786             :                        {
   22787           2 :                          SgTypeUnsignedChar::next_node = &(pointer[i]);
   22788             :                        }
   22789             :                     else
   22790             :                        {
   22791             :                       // printf ("In SgTypeUnsignedChar::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   22792        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   22793             :                        }
   22794             :                     pointerOfLinkedList = &(pointer[i]);
   22795             :                   }
   22796             :               }
   22797             :         }
   22798             : 
   22799           5 :      if ( pointerOfLinkedList != NULL )
   22800             :         {
   22801             :        // printf ("In SgTypeUnsignedChar::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   22802           2 :           pointerOfLinkedList->set_freepointer(NULL);
   22803             :        // DQ (6/6/2010): Temporary debugging...
   22804             :        //   ROSE_ASSERT(false);
   22805             :         }
   22806             : 
   22807           5 :      return ;
   22808             :    }
   22809             : 
   22810             : //############################################################################
   22811             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   22812             :  * within the memory pool and resets the freepointers, in order to achieve a 
   22813             :  * linked list, that has no jumps and starts at the beginning! This function 
   22814             :  * does not extend the memory pool, since we do not delete any memory blocks,
   22815             :  * but delete the valid objects.  
   22816             :  */
   22817             : void
   22818           0 : SgTypeUnsignedChar::clearMemoryPool( )
   22819             :    {
   22820             :   // printf ("Inside of SgTypeUnsignedChar::clearMemoryPool() \n");
   22821             : 
   22822           0 :      SgTypeUnsignedChar* pointer = NULL, *tempPointer = NULL;
   22823           0 :      std::vector < unsigned char* > :: const_iterator block;
   22824           0 :      if ( SgTypeUnsignedChar::pools.empty() == false )
   22825             :         {
   22826           0 :           block = SgTypeUnsignedChar::pools.begin() ;
   22827           0 :           SgTypeUnsignedChar::next_node = (SgTypeUnsignedChar*) (*block);
   22828             : 
   22829           0 :           while ( block != SgTypeUnsignedChar::pools.end() )
   22830             :              {
   22831           0 :                pointer = (SgTypeUnsignedChar*) (*block);
   22832           0 :                if ( tempPointer != NULL )
   22833             :                   {
   22834           0 :                     tempPointer->set_freepointer(pointer);
   22835             :                   }
   22836           0 :                for (unsigned i = 0; i < SgTypeUnsignedChar::pool_size - 1; ++i)
   22837             :                   {
   22838           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   22839             :                   }
   22840           0 :                 pointer[SgTypeUnsignedChar::pool_size-1].set_freepointer(NULL);
   22841           0 :                 tempPointer = &(pointer[SgTypeUnsignedChar::pool_size-1]);
   22842           0 :                 ++block;
   22843             :              }
   22844             :         }
   22845           0 :    }
   22846             : 
   22847           5 : void SgTypeUnsignedChar::deleteMemoryPool() {
   22848           9 :   for (auto p: SgTypeUnsignedChar::pools) {
   22849           4 :     ROSE_FREE(p);
   22850             :   }
   22851           5 :   SgTypeUnsignedChar::next_node = nullptr;
   22852           5 :   SgTypeUnsignedChar::pools.clear();
   22853           5 : }
   22854             : 
   22855             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   22856             : //                 reading multiple binary files to for a single AST.
   22857             : /////////// new version ////////////////////////////////
   22858             : //############################################################################
   22859             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   22860             : void
   22861           2 : SgTypeUnsignedChar::extendMemoryPoolForFileIO( )
   22862             :   {
   22863           2 :     size_t blockIndex = SgTypeUnsignedChar::pools.size();
   22864           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedChar) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedChar);
   22865             : 
   22866           4 :     while ( (blockIndex * SgTypeUnsignedChar::pool_size) < newPoolSize)
   22867             :       {
   22868             : #if ROSE_ALLOC_TRACE
   22869             :         if (blockIndex > 0) {
   22870             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedChar) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedChar) = %" PRIuPTR " SgTypeUnsignedChar::pool_size = %d \n",
   22871             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedChar),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedChar),SgTypeUnsignedChar::pool_size);
   22872             :         }
   22873             : #endif
   22874             : 
   22875           2 :         SgTypeUnsignedChar * pointer = (SgTypeUnsignedChar*) ROSE_MALLOC ( SgTypeUnsignedChar::pool_size * sizeof(SgTypeUnsignedChar) );
   22876           2 :         assert( pointer != NULL );
   22877             : #if ROSE_ALLOC_MEMSET == 1
   22878             :         memset(pointer, 0x00, SgTypeUnsignedChar::pool_size * sizeof(SgTypeUnsignedChar));
   22879             : #elif ROSE_ALLOC_MEMSET == 2
   22880             :         memset(pointer, 0xCC, SgTypeUnsignedChar::pool_size * sizeof(SgTypeUnsignedChar));
   22881             : #endif
   22882           2 :         SgTypeUnsignedChar::pools.push_back( (unsigned char*)(pointer) );
   22883           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeUnsignedChar::pool_size * sizeof(SgTypeUnsignedChar), V_SgTypeUnsignedChar ) );
   22884             : 
   22885           2 :         if ( SgTypeUnsignedChar::next_node != NULL ) {
   22886           0 :           if ( blockIndex > 0 ) {
   22887           0 :             SgTypeUnsignedChar * blkptr = (SgTypeUnsignedChar*)(SgTypeUnsignedChar::pools[blockIndex-1]);
   22888           0 :             blkptr[ SgTypeUnsignedChar::pool_size - 1 ].set_freepointer(pointer);
   22889             :           }
   22890             :         } else {
   22891           2 :           SgTypeUnsignedChar::next_node = pointer;
   22892             :         }
   22893             : 
   22894        4000 :         for (unsigned i = 0; i < SgTypeUnsignedChar::pool_size-1; ++i)
   22895             :            {
   22896        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   22897             :            }
   22898           2 :         pointer[ SgTypeUnsignedChar::pool_size -1 ].set_freepointer(NULL);
   22899             : 
   22900           2 :         blockIndex++;
   22901             :       }
   22902           2 :   }
   22903             : 
   22904             : //############################################################################
   22905             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   22906             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   22907             :  * not compressed. However, that stuff is not yet implemented! 
   22908             :  */
   22909             : unsigned long
   22910           0 : SgTypeUnsignedChar::getNumberOfLastValidPointer()
   22911             :    {
   22912           0 :       SgTypeUnsignedChar* testPointer = (SgTypeUnsignedChar*)(SgTypeUnsignedChar::pools.back());
   22913           0 :       unsigned long localIndex = SgTypeUnsignedChar::pool_size - 1;
   22914           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   22915             :          {
   22916           0 :            localIndex--;
   22917             :          }
   22918           0 :       return (localIndex + SgTypeUnsignedChar::pool_size * (SgTypeUnsignedChar::pools.size()-1));
   22919             :    }
   22920             : 
   22921             : //############################################################################
   22922             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   22923             :  * memory pool and initializes the data member in class SgTypeUnsignedCharStroageClass
   22924             :  * from its counterpart of SgTypeUnsignedChar. The return value is just for checking, 
   22925             :  * that the whole StorageClassArray is initialized!
   22926             :  */
   22927             : unsigned long
   22928           2 : SgTypeUnsignedChar::initializeStorageClassArray( SgTypeUnsignedCharStorageClass *storageArray )
   22929             :    {
   22930           2 :      unsigned long storageCounter = 0;
   22931           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeUnsignedChar::pools.begin();
   22932           2 :      SgTypeUnsignedChar* pointer = NULL;
   22933           4 :      while ( block != SgTypeUnsignedChar::pools.end() ) {
   22934           2 :           pointer = (SgTypeUnsignedChar*) (*block);
   22935        4002 :           for ( unsigned i = 0; i < SgTypeUnsignedChar::pool_size; ++i ) {
   22936        4000 :                if ( pointer->get_freepointer() != NULL ) {
   22937           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   22938           2 :                  storageArray++;
   22939           2 :                  storageCounter++;
   22940             :                }
   22941        4000 :                pointer++;
   22942             :              }
   22943           2 :            block++;
   22944             :         }
   22945           2 :      return storageCounter;
   22946             :    }
   22947             : 
   22948             : /* #line 22949 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   22949             : 
   22950             : 
   22951             : 
   22952             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   22953             : 
   22954             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   22955             : 
   22956             : //############################################################################
   22957             : /* JH (02/02/2006) Constructor of the IR node SgTypeShort that takes its 
   22958             :  * corresponding StorageClass as parameter
   22959             :  */
   22960           2 : SgTypeShort :: SgTypeShort ( const SgTypeShortStorageClass& storageSource )   : SgType (storageSource)
   22961             :    {
   22962             : 
   22963             : 
   22964             : /* #line 22965 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   22965             : 
   22966           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   22967             : 
   22968             : 
   22969             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   22970             : 
   22971             : 
   22972           2 :    }
   22973             : 
   22974             : //############################################################################
   22975             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   22976             :  * within the working AST. 
   22977             :  */
   22978         140 : SgTypeShort * SgTypeShort::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   22979         140 :      SgTypeShort* returnPointer = NULL;
   22980         140 :      if ( globalIndex != 0 )
   22981             :         {
   22982             : 
   22983             : #if FILE_IO_EXTRA_CHECK
   22984         140 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeShort ) ) <= globalIndex ) ;
   22985         140 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeShort + 1 ) ) );
   22986             : #endif
   22987         140 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeShort )  
   22988         140 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeShort );
   22989         140 :           unsigned long positionInPool = localIndex % SgTypeShort::pool_size;
   22990         140 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeShort::pool_size;
   22991             : 
   22992             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   22993             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   22994             : 
   22995         140 :           returnPointer = &( ( (SgTypeShort*)(SgTypeShort::pools[memoryBlock]) ) [positionInPool]) ;
   22996             : 
   22997         140 :           ROSE_ASSERT( returnPointer != NULL ) ;
   22998             :         }
   22999         140 :      return returnPointer ;
   23000             :    }
   23001             : 
   23002             : //############################################################################
   23003             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   23004             :   for the AST with the index astIndex
   23005             : */
   23006           0 : SgTypeShort * SgTypeShort::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   23007           0 :      SgTypeShort* returnPointer = NULL;
   23008           0 :      if ( globalIndex != 0 )
   23009             :         {
   23010             : 
   23011             : #if FILE_IO_EXTRA_CHECK
   23012           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeShort ) ) <= globalIndex ) ;
   23013           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeShort + 1 ) ) );
   23014             : #endif
   23015           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeShort )
   23016           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeShort );
   23017           0 :           unsigned long positionInPool = localIndex % SgTypeShort::pool_size ;
   23018           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeShort::pool_size ;
   23019             : 
   23020             : #if FILE_IO_EXTRA_CHECK
   23021             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   23022             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   23023             : #endif
   23024             : 
   23025           0 :           returnPointer = &( ( (SgTypeShort*)(SgTypeShort::pools[memoryBlock]) ) [positionInPool]) ;
   23026             : 
   23027             : #if FILE_IO_EXTRA_CHECK
   23028           0 :           assert ( returnPointer != NULL ) ;
   23029             : #endif
   23030             :         }
   23031           0 :      return returnPointer ;
   23032             :    }
   23033             : 
   23034             : //############################################################################
   23035             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   23036             :  * pool size! We set for every valid object in the memory pool the freepointer
   23037             :  * to the global index and increase the global index afterwards. For all the 
   23038             :  * invalid objects (means address ranges within the memory pool that were not
   23039             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   23040             :  * distinguish valid from invalid objects! 
   23041             :  */
   23042             : unsigned long
   23043           5 : SgTypeShort::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   23044             :    {
   23045           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   23046           5 :      SgTypeShort* pointer = NULL;
   23047           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   23048           5 :      std::vector < unsigned char* > :: const_iterator block;
   23049           7 :      for ( block = SgTypeShort::pools.begin(); block != SgTypeShort::pools.end() ; ++block )
   23050             :         {
   23051           2 :           pointer = (SgTypeShort*)(*block);
   23052        4002 :           for (unsigned i = 0; i < SgTypeShort::pool_size; ++i )
   23053             :              {
   23054             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   23055             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   23056             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   23057             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   23058             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   23059             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   23060             :             // properly; so this will have to be checked next.
   23061             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   23062             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   23063        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   23064             :                   {
   23065           2 :                     pointer[i].set_freepointer((SgTypeShort*)(globalIndex));
   23066           2 :                     globalIndex++;
   23067             :                   }
   23068             :                else
   23069             :                   {
   23070        3998 :                     pointer[i].set_freepointer(NULL);
   23071             :                   }
   23072             :               }
   23073             :         }
   23074           5 :      return globalIndex;
   23075             :    }
   23076             : 
   23077             : //############################################################################
   23078             : // JH (01/14/2006)
   23079             : void
   23080           5 : SgTypeShort::resetValidFreepointers( )
   23081             :    {
   23082           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   23083           5 :      SgTypeShort* pointer = NULL;
   23084           5 :      std::vector < unsigned char* > :: const_iterator block;
   23085           5 :      SgTypeShort* pointerOfLinkedList = NULL;
   23086           7 :      for ( block = SgTypeShort::pools.begin(); block != SgTypeShort::pools.end() ; ++block )
   23087             :         {
   23088           2 :           pointer = (SgTypeShort*)(*block);
   23089        4002 :           for (unsigned i = 0; i < SgTypeShort::pool_size; ++i )
   23090             :              {
   23091             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   23092             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   23093             :             // memory blocks!.
   23094        4000 :                if ( pointer[i].get_freepointer() != NULL )
   23095             :                   {
   23096           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   23097             :                   }
   23098             :                else
   23099             :                   {
   23100        3998 :                     if ( pointerOfLinkedList == NULL )
   23101             :                        {
   23102           2 :                          SgTypeShort::next_node = &(pointer[i]);
   23103             :                        }
   23104             :                     else
   23105             :                        {
   23106             :                       // printf ("In SgTypeShort::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   23107        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   23108             :                        }
   23109             :                     pointerOfLinkedList = &(pointer[i]);
   23110             :                   }
   23111             :               }
   23112             :         }
   23113             : 
   23114           5 :      if ( pointerOfLinkedList != NULL )
   23115             :         {
   23116             :        // printf ("In SgTypeShort::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   23117           2 :           pointerOfLinkedList->set_freepointer(NULL);
   23118             :        // DQ (6/6/2010): Temporary debugging...
   23119             :        //   ROSE_ASSERT(false);
   23120             :         }
   23121             : 
   23122           5 :      return ;
   23123             :    }
   23124             : 
   23125             : //############################################################################
   23126             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   23127             :  * within the memory pool and resets the freepointers, in order to achieve a 
   23128             :  * linked list, that has no jumps and starts at the beginning! This function 
   23129             :  * does not extend the memory pool, since we do not delete any memory blocks,
   23130             :  * but delete the valid objects.  
   23131             :  */
   23132             : void
   23133           0 : SgTypeShort::clearMemoryPool( )
   23134             :    {
   23135             :   // printf ("Inside of SgTypeShort::clearMemoryPool() \n");
   23136             : 
   23137           0 :      SgTypeShort* pointer = NULL, *tempPointer = NULL;
   23138           0 :      std::vector < unsigned char* > :: const_iterator block;
   23139           0 :      if ( SgTypeShort::pools.empty() == false )
   23140             :         {
   23141           0 :           block = SgTypeShort::pools.begin() ;
   23142           0 :           SgTypeShort::next_node = (SgTypeShort*) (*block);
   23143             : 
   23144           0 :           while ( block != SgTypeShort::pools.end() )
   23145             :              {
   23146           0 :                pointer = (SgTypeShort*) (*block);
   23147           0 :                if ( tempPointer != NULL )
   23148             :                   {
   23149           0 :                     tempPointer->set_freepointer(pointer);
   23150             :                   }
   23151           0 :                for (unsigned i = 0; i < SgTypeShort::pool_size - 1; ++i)
   23152             :                   {
   23153           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   23154             :                   }
   23155           0 :                 pointer[SgTypeShort::pool_size-1].set_freepointer(NULL);
   23156           0 :                 tempPointer = &(pointer[SgTypeShort::pool_size-1]);
   23157           0 :                 ++block;
   23158             :              }
   23159             :         }
   23160           0 :    }
   23161             : 
   23162           5 : void SgTypeShort::deleteMemoryPool() {
   23163           9 :   for (auto p: SgTypeShort::pools) {
   23164           4 :     ROSE_FREE(p);
   23165             :   }
   23166           5 :   SgTypeShort::next_node = nullptr;
   23167           5 :   SgTypeShort::pools.clear();
   23168           5 : }
   23169             : 
   23170             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   23171             : //                 reading multiple binary files to for a single AST.
   23172             : /////////// new version ////////////////////////////////
   23173             : //############################################################################
   23174             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   23175             : void
   23176           2 : SgTypeShort::extendMemoryPoolForFileIO( )
   23177             :   {
   23178           2 :     size_t blockIndex = SgTypeShort::pools.size();
   23179           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeShort) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeShort);
   23180             : 
   23181           4 :     while ( (blockIndex * SgTypeShort::pool_size) < newPoolSize)
   23182             :       {
   23183             : #if ROSE_ALLOC_TRACE
   23184             :         if (blockIndex > 0) {
   23185             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeShort) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeShort) = %" PRIuPTR " SgTypeShort::pool_size = %d \n",
   23186             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeShort),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeShort),SgTypeShort::pool_size);
   23187             :         }
   23188             : #endif
   23189             : 
   23190           2 :         SgTypeShort * pointer = (SgTypeShort*) ROSE_MALLOC ( SgTypeShort::pool_size * sizeof(SgTypeShort) );
   23191           2 :         assert( pointer != NULL );
   23192             : #if ROSE_ALLOC_MEMSET == 1
   23193             :         memset(pointer, 0x00, SgTypeShort::pool_size * sizeof(SgTypeShort));
   23194             : #elif ROSE_ALLOC_MEMSET == 2
   23195             :         memset(pointer, 0xCC, SgTypeShort::pool_size * sizeof(SgTypeShort));
   23196             : #endif
   23197           2 :         SgTypeShort::pools.push_back( (unsigned char*)(pointer) );
   23198           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeShort::pool_size * sizeof(SgTypeShort), V_SgTypeShort ) );
   23199             : 
   23200           2 :         if ( SgTypeShort::next_node != NULL ) {
   23201           0 :           if ( blockIndex > 0 ) {
   23202           0 :             SgTypeShort * blkptr = (SgTypeShort*)(SgTypeShort::pools[blockIndex-1]);
   23203           0 :             blkptr[ SgTypeShort::pool_size - 1 ].set_freepointer(pointer);
   23204             :           }
   23205             :         } else {
   23206           2 :           SgTypeShort::next_node = pointer;
   23207             :         }
   23208             : 
   23209        4000 :         for (unsigned i = 0; i < SgTypeShort::pool_size-1; ++i)
   23210             :            {
   23211        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   23212             :            }
   23213           2 :         pointer[ SgTypeShort::pool_size -1 ].set_freepointer(NULL);
   23214             : 
   23215           2 :         blockIndex++;
   23216             :       }
   23217           2 :   }
   23218             : 
   23219             : //############################################################################
   23220             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   23221             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   23222             :  * not compressed. However, that stuff is not yet implemented! 
   23223             :  */
   23224             : unsigned long
   23225           0 : SgTypeShort::getNumberOfLastValidPointer()
   23226             :    {
   23227           0 :       SgTypeShort* testPointer = (SgTypeShort*)(SgTypeShort::pools.back());
   23228           0 :       unsigned long localIndex = SgTypeShort::pool_size - 1;
   23229           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   23230             :          {
   23231           0 :            localIndex--;
   23232             :          }
   23233           0 :       return (localIndex + SgTypeShort::pool_size * (SgTypeShort::pools.size()-1));
   23234             :    }
   23235             : 
   23236             : //############################################################################
   23237             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   23238             :  * memory pool and initializes the data member in class SgTypeShortStroageClass
   23239             :  * from its counterpart of SgTypeShort. The return value is just for checking, 
   23240             :  * that the whole StorageClassArray is initialized!
   23241             :  */
   23242             : unsigned long
   23243           2 : SgTypeShort::initializeStorageClassArray( SgTypeShortStorageClass *storageArray )
   23244             :    {
   23245           2 :      unsigned long storageCounter = 0;
   23246           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeShort::pools.begin();
   23247           2 :      SgTypeShort* pointer = NULL;
   23248           4 :      while ( block != SgTypeShort::pools.end() ) {
   23249           2 :           pointer = (SgTypeShort*) (*block);
   23250        4002 :           for ( unsigned i = 0; i < SgTypeShort::pool_size; ++i ) {
   23251        4000 :                if ( pointer->get_freepointer() != NULL ) {
   23252           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   23253           2 :                  storageArray++;
   23254           2 :                  storageCounter++;
   23255             :                }
   23256        4000 :                pointer++;
   23257             :              }
   23258           2 :            block++;
   23259             :         }
   23260           2 :      return storageCounter;
   23261             :    }
   23262             : 
   23263             : /* #line 23264 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   23264             : 
   23265             : 
   23266             : 
   23267             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   23268             : 
   23269             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   23270             : 
   23271             : //############################################################################
   23272             : /* JH (02/02/2006) Constructor of the IR node SgTypeSignedShort that takes its 
   23273             :  * corresponding StorageClass as parameter
   23274             :  */
   23275           2 : SgTypeSignedShort :: SgTypeSignedShort ( const SgTypeSignedShortStorageClass& storageSource )   : SgType (storageSource)
   23276             :    {
   23277             : 
   23278             : 
   23279             : /* #line 23280 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   23280             : 
   23281           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   23282             : 
   23283             : 
   23284             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   23285             : 
   23286             : 
   23287           2 :    }
   23288             : 
   23289             : //############################################################################
   23290             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   23291             :  * within the working AST. 
   23292             :  */
   23293           7 : SgTypeSignedShort * SgTypeSignedShort::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   23294           7 :      SgTypeSignedShort* returnPointer = NULL;
   23295           7 :      if ( globalIndex != 0 )
   23296             :         {
   23297             : 
   23298             : #if FILE_IO_EXTRA_CHECK
   23299           7 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeSignedShort ) ) <= globalIndex ) ;
   23300           7 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedShort + 1 ) ) );
   23301             : #endif
   23302           7 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedShort )  
   23303           7 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeSignedShort );
   23304           7 :           unsigned long positionInPool = localIndex % SgTypeSignedShort::pool_size;
   23305           7 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedShort::pool_size;
   23306             : 
   23307             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   23308             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   23309             : 
   23310           7 :           returnPointer = &( ( (SgTypeSignedShort*)(SgTypeSignedShort::pools[memoryBlock]) ) [positionInPool]) ;
   23311             : 
   23312           7 :           ROSE_ASSERT( returnPointer != NULL ) ;
   23313             :         }
   23314           7 :      return returnPointer ;
   23315             :    }
   23316             : 
   23317             : //############################################################################
   23318             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   23319             :   for the AST with the index astIndex
   23320             : */
   23321           0 : SgTypeSignedShort * SgTypeSignedShort::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   23322           0 :      SgTypeSignedShort* returnPointer = NULL;
   23323           0 :      if ( globalIndex != 0 )
   23324             :         {
   23325             : 
   23326             : #if FILE_IO_EXTRA_CHECK
   23327           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeSignedShort ) ) <= globalIndex ) ;
   23328           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedShort + 1 ) ) );
   23329             : #endif
   23330           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedShort )
   23331           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeSignedShort );
   23332           0 :           unsigned long positionInPool = localIndex % SgTypeSignedShort::pool_size ;
   23333           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedShort::pool_size ;
   23334             : 
   23335             : #if FILE_IO_EXTRA_CHECK
   23336             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   23337             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   23338             : #endif
   23339             : 
   23340           0 :           returnPointer = &( ( (SgTypeSignedShort*)(SgTypeSignedShort::pools[memoryBlock]) ) [positionInPool]) ;
   23341             : 
   23342             : #if FILE_IO_EXTRA_CHECK
   23343           0 :           assert ( returnPointer != NULL ) ;
   23344             : #endif
   23345             :         }
   23346           0 :      return returnPointer ;
   23347             :    }
   23348             : 
   23349             : //############################################################################
   23350             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   23351             :  * pool size! We set for every valid object in the memory pool the freepointer
   23352             :  * to the global index and increase the global index afterwards. For all the 
   23353             :  * invalid objects (means address ranges within the memory pool that were not
   23354             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   23355             :  * distinguish valid from invalid objects! 
   23356             :  */
   23357             : unsigned long
   23358           5 : SgTypeSignedShort::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   23359             :    {
   23360           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   23361           5 :      SgTypeSignedShort* pointer = NULL;
   23362           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   23363           5 :      std::vector < unsigned char* > :: const_iterator block;
   23364           7 :      for ( block = SgTypeSignedShort::pools.begin(); block != SgTypeSignedShort::pools.end() ; ++block )
   23365             :         {
   23366           2 :           pointer = (SgTypeSignedShort*)(*block);
   23367        4002 :           for (unsigned i = 0; i < SgTypeSignedShort::pool_size; ++i )
   23368             :              {
   23369             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   23370             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   23371             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   23372             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   23373             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   23374             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   23375             :             // properly; so this will have to be checked next.
   23376             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   23377             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   23378        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   23379             :                   {
   23380           2 :                     pointer[i].set_freepointer((SgTypeSignedShort*)(globalIndex));
   23381           2 :                     globalIndex++;
   23382             :                   }
   23383             :                else
   23384             :                   {
   23385        3998 :                     pointer[i].set_freepointer(NULL);
   23386             :                   }
   23387             :               }
   23388             :         }
   23389           5 :      return globalIndex;
   23390             :    }
   23391             : 
   23392             : //############################################################################
   23393             : // JH (01/14/2006)
   23394             : void
   23395           5 : SgTypeSignedShort::resetValidFreepointers( )
   23396             :    {
   23397           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   23398           5 :      SgTypeSignedShort* pointer = NULL;
   23399           5 :      std::vector < unsigned char* > :: const_iterator block;
   23400           5 :      SgTypeSignedShort* pointerOfLinkedList = NULL;
   23401           7 :      for ( block = SgTypeSignedShort::pools.begin(); block != SgTypeSignedShort::pools.end() ; ++block )
   23402             :         {
   23403           2 :           pointer = (SgTypeSignedShort*)(*block);
   23404        4002 :           for (unsigned i = 0; i < SgTypeSignedShort::pool_size; ++i )
   23405             :              {
   23406             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   23407             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   23408             :             // memory blocks!.
   23409        4000 :                if ( pointer[i].get_freepointer() != NULL )
   23410             :                   {
   23411           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   23412             :                   }
   23413             :                else
   23414             :                   {
   23415        3998 :                     if ( pointerOfLinkedList == NULL )
   23416             :                        {
   23417           2 :                          SgTypeSignedShort::next_node = &(pointer[i]);
   23418             :                        }
   23419             :                     else
   23420             :                        {
   23421             :                       // printf ("In SgTypeSignedShort::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   23422        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   23423             :                        }
   23424             :                     pointerOfLinkedList = &(pointer[i]);
   23425             :                   }
   23426             :               }
   23427             :         }
   23428             : 
   23429           5 :      if ( pointerOfLinkedList != NULL )
   23430             :         {
   23431             :        // printf ("In SgTypeSignedShort::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   23432           2 :           pointerOfLinkedList->set_freepointer(NULL);
   23433             :        // DQ (6/6/2010): Temporary debugging...
   23434             :        //   ROSE_ASSERT(false);
   23435             :         }
   23436             : 
   23437           5 :      return ;
   23438             :    }
   23439             : 
   23440             : //############################################################################
   23441             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   23442             :  * within the memory pool and resets the freepointers, in order to achieve a 
   23443             :  * linked list, that has no jumps and starts at the beginning! This function 
   23444             :  * does not extend the memory pool, since we do not delete any memory blocks,
   23445             :  * but delete the valid objects.  
   23446             :  */
   23447             : void
   23448           0 : SgTypeSignedShort::clearMemoryPool( )
   23449             :    {
   23450             :   // printf ("Inside of SgTypeSignedShort::clearMemoryPool() \n");
   23451             : 
   23452           0 :      SgTypeSignedShort* pointer = NULL, *tempPointer = NULL;
   23453           0 :      std::vector < unsigned char* > :: const_iterator block;
   23454           0 :      if ( SgTypeSignedShort::pools.empty() == false )
   23455             :         {
   23456           0 :           block = SgTypeSignedShort::pools.begin() ;
   23457           0 :           SgTypeSignedShort::next_node = (SgTypeSignedShort*) (*block);
   23458             : 
   23459           0 :           while ( block != SgTypeSignedShort::pools.end() )
   23460             :              {
   23461           0 :                pointer = (SgTypeSignedShort*) (*block);
   23462           0 :                if ( tempPointer != NULL )
   23463             :                   {
   23464           0 :                     tempPointer->set_freepointer(pointer);
   23465             :                   }
   23466           0 :                for (unsigned i = 0; i < SgTypeSignedShort::pool_size - 1; ++i)
   23467             :                   {
   23468           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   23469             :                   }
   23470           0 :                 pointer[SgTypeSignedShort::pool_size-1].set_freepointer(NULL);
   23471           0 :                 tempPointer = &(pointer[SgTypeSignedShort::pool_size-1]);
   23472           0 :                 ++block;
   23473             :              }
   23474             :         }
   23475           0 :    }
   23476             : 
   23477           5 : void SgTypeSignedShort::deleteMemoryPool() {
   23478           9 :   for (auto p: SgTypeSignedShort::pools) {
   23479           4 :     ROSE_FREE(p);
   23480             :   }
   23481           5 :   SgTypeSignedShort::next_node = nullptr;
   23482           5 :   SgTypeSignedShort::pools.clear();
   23483           5 : }
   23484             : 
   23485             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   23486             : //                 reading multiple binary files to for a single AST.
   23487             : /////////// new version ////////////////////////////////
   23488             : //############################################################################
   23489             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   23490             : void
   23491           2 : SgTypeSignedShort::extendMemoryPoolForFileIO( )
   23492             :   {
   23493           2 :     size_t blockIndex = SgTypeSignedShort::pools.size();
   23494           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedShort) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedShort);
   23495             : 
   23496           4 :     while ( (blockIndex * SgTypeSignedShort::pool_size) < newPoolSize)
   23497             :       {
   23498             : #if ROSE_ALLOC_TRACE
   23499             :         if (blockIndex > 0) {
   23500             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedShort) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedShort) = %" PRIuPTR " SgTypeSignedShort::pool_size = %d \n",
   23501             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedShort),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedShort),SgTypeSignedShort::pool_size);
   23502             :         }
   23503             : #endif
   23504             : 
   23505           2 :         SgTypeSignedShort * pointer = (SgTypeSignedShort*) ROSE_MALLOC ( SgTypeSignedShort::pool_size * sizeof(SgTypeSignedShort) );
   23506           2 :         assert( pointer != NULL );
   23507             : #if ROSE_ALLOC_MEMSET == 1
   23508             :         memset(pointer, 0x00, SgTypeSignedShort::pool_size * sizeof(SgTypeSignedShort));
   23509             : #elif ROSE_ALLOC_MEMSET == 2
   23510             :         memset(pointer, 0xCC, SgTypeSignedShort::pool_size * sizeof(SgTypeSignedShort));
   23511             : #endif
   23512           2 :         SgTypeSignedShort::pools.push_back( (unsigned char*)(pointer) );
   23513           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeSignedShort::pool_size * sizeof(SgTypeSignedShort), V_SgTypeSignedShort ) );
   23514             : 
   23515           2 :         if ( SgTypeSignedShort::next_node != NULL ) {
   23516           0 :           if ( blockIndex > 0 ) {
   23517           0 :             SgTypeSignedShort * blkptr = (SgTypeSignedShort*)(SgTypeSignedShort::pools[blockIndex-1]);
   23518           0 :             blkptr[ SgTypeSignedShort::pool_size - 1 ].set_freepointer(pointer);
   23519             :           }
   23520             :         } else {
   23521           2 :           SgTypeSignedShort::next_node = pointer;
   23522             :         }
   23523             : 
   23524        4000 :         for (unsigned i = 0; i < SgTypeSignedShort::pool_size-1; ++i)
   23525             :            {
   23526        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   23527             :            }
   23528           2 :         pointer[ SgTypeSignedShort::pool_size -1 ].set_freepointer(NULL);
   23529             : 
   23530           2 :         blockIndex++;
   23531             :       }
   23532           2 :   }
   23533             : 
   23534             : //############################################################################
   23535             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   23536             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   23537             :  * not compressed. However, that stuff is not yet implemented! 
   23538             :  */
   23539             : unsigned long
   23540           0 : SgTypeSignedShort::getNumberOfLastValidPointer()
   23541             :    {
   23542           0 :       SgTypeSignedShort* testPointer = (SgTypeSignedShort*)(SgTypeSignedShort::pools.back());
   23543           0 :       unsigned long localIndex = SgTypeSignedShort::pool_size - 1;
   23544           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   23545             :          {
   23546           0 :            localIndex--;
   23547             :          }
   23548           0 :       return (localIndex + SgTypeSignedShort::pool_size * (SgTypeSignedShort::pools.size()-1));
   23549             :    }
   23550             : 
   23551             : //############################################################################
   23552             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   23553             :  * memory pool and initializes the data member in class SgTypeSignedShortStroageClass
   23554             :  * from its counterpart of SgTypeSignedShort. The return value is just for checking, 
   23555             :  * that the whole StorageClassArray is initialized!
   23556             :  */
   23557             : unsigned long
   23558           2 : SgTypeSignedShort::initializeStorageClassArray( SgTypeSignedShortStorageClass *storageArray )
   23559             :    {
   23560           2 :      unsigned long storageCounter = 0;
   23561           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeSignedShort::pools.begin();
   23562           2 :      SgTypeSignedShort* pointer = NULL;
   23563           4 :      while ( block != SgTypeSignedShort::pools.end() ) {
   23564           2 :           pointer = (SgTypeSignedShort*) (*block);
   23565        4002 :           for ( unsigned i = 0; i < SgTypeSignedShort::pool_size; ++i ) {
   23566        4000 :                if ( pointer->get_freepointer() != NULL ) {
   23567           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   23568           2 :                  storageArray++;
   23569           2 :                  storageCounter++;
   23570             :                }
   23571        4000 :                pointer++;
   23572             :              }
   23573           2 :            block++;
   23574             :         }
   23575           2 :      return storageCounter;
   23576             :    }
   23577             : 
   23578             : /* #line 23579 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   23579             : 
   23580             : 
   23581             : 
   23582             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   23583             : 
   23584             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   23585             : 
   23586             : //############################################################################
   23587             : /* JH (02/02/2006) Constructor of the IR node SgTypeUnsignedShort that takes its 
   23588             :  * corresponding StorageClass as parameter
   23589             :  */
   23590           2 : SgTypeUnsignedShort :: SgTypeUnsignedShort ( const SgTypeUnsignedShortStorageClass& storageSource )   : SgType (storageSource)
   23591             :    {
   23592             : 
   23593             : 
   23594             : /* #line 23595 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   23595             : 
   23596           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   23597             : 
   23598             : 
   23599             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   23600             : 
   23601             : 
   23602           2 :    }
   23603             : 
   23604             : //############################################################################
   23605             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   23606             :  * within the working AST. 
   23607             :  */
   23608         116 : SgTypeUnsignedShort * SgTypeUnsignedShort::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   23609         116 :      SgTypeUnsignedShort* returnPointer = NULL;
   23610         116 :      if ( globalIndex != 0 )
   23611             :         {
   23612             : 
   23613             : #if FILE_IO_EXTRA_CHECK
   23614         116 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeUnsignedShort ) ) <= globalIndex ) ;
   23615         116 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedShort + 1 ) ) );
   23616             : #endif
   23617         116 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedShort )  
   23618         116 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeUnsignedShort );
   23619         116 :           unsigned long positionInPool = localIndex % SgTypeUnsignedShort::pool_size;
   23620         116 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedShort::pool_size;
   23621             : 
   23622             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   23623             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   23624             : 
   23625         116 :           returnPointer = &( ( (SgTypeUnsignedShort*)(SgTypeUnsignedShort::pools[memoryBlock]) ) [positionInPool]) ;
   23626             : 
   23627         116 :           ROSE_ASSERT( returnPointer != NULL ) ;
   23628             :         }
   23629         116 :      return returnPointer ;
   23630             :    }
   23631             : 
   23632             : //############################################################################
   23633             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   23634             :   for the AST with the index astIndex
   23635             : */
   23636           0 : SgTypeUnsignedShort * SgTypeUnsignedShort::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   23637           0 :      SgTypeUnsignedShort* returnPointer = NULL;
   23638           0 :      if ( globalIndex != 0 )
   23639             :         {
   23640             : 
   23641             : #if FILE_IO_EXTRA_CHECK
   23642           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeUnsignedShort ) ) <= globalIndex ) ;
   23643           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedShort + 1 ) ) );
   23644             : #endif
   23645           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedShort )
   23646           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeUnsignedShort );
   23647           0 :           unsigned long positionInPool = localIndex % SgTypeUnsignedShort::pool_size ;
   23648           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedShort::pool_size ;
   23649             : 
   23650             : #if FILE_IO_EXTRA_CHECK
   23651             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   23652             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   23653             : #endif
   23654             : 
   23655           0 :           returnPointer = &( ( (SgTypeUnsignedShort*)(SgTypeUnsignedShort::pools[memoryBlock]) ) [positionInPool]) ;
   23656             : 
   23657             : #if FILE_IO_EXTRA_CHECK
   23658           0 :           assert ( returnPointer != NULL ) ;
   23659             : #endif
   23660             :         }
   23661           0 :      return returnPointer ;
   23662             :    }
   23663             : 
   23664             : //############################################################################
   23665             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   23666             :  * pool size! We set for every valid object in the memory pool the freepointer
   23667             :  * to the global index and increase the global index afterwards. For all the 
   23668             :  * invalid objects (means address ranges within the memory pool that were not
   23669             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   23670             :  * distinguish valid from invalid objects! 
   23671             :  */
   23672             : unsigned long
   23673           5 : SgTypeUnsignedShort::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   23674             :    {
   23675           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   23676           5 :      SgTypeUnsignedShort* pointer = NULL;
   23677           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   23678           5 :      std::vector < unsigned char* > :: const_iterator block;
   23679           7 :      for ( block = SgTypeUnsignedShort::pools.begin(); block != SgTypeUnsignedShort::pools.end() ; ++block )
   23680             :         {
   23681           2 :           pointer = (SgTypeUnsignedShort*)(*block);
   23682        4002 :           for (unsigned i = 0; i < SgTypeUnsignedShort::pool_size; ++i )
   23683             :              {
   23684             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   23685             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   23686             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   23687             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   23688             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   23689             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   23690             :             // properly; so this will have to be checked next.
   23691             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   23692             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   23693        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   23694             :                   {
   23695           2 :                     pointer[i].set_freepointer((SgTypeUnsignedShort*)(globalIndex));
   23696           2 :                     globalIndex++;
   23697             :                   }
   23698             :                else
   23699             :                   {
   23700        3998 :                     pointer[i].set_freepointer(NULL);
   23701             :                   }
   23702             :               }
   23703             :         }
   23704           5 :      return globalIndex;
   23705             :    }
   23706             : 
   23707             : //############################################################################
   23708             : // JH (01/14/2006)
   23709             : void
   23710           5 : SgTypeUnsignedShort::resetValidFreepointers( )
   23711             :    {
   23712           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   23713           5 :      SgTypeUnsignedShort* pointer = NULL;
   23714           5 :      std::vector < unsigned char* > :: const_iterator block;
   23715           5 :      SgTypeUnsignedShort* pointerOfLinkedList = NULL;
   23716           7 :      for ( block = SgTypeUnsignedShort::pools.begin(); block != SgTypeUnsignedShort::pools.end() ; ++block )
   23717             :         {
   23718           2 :           pointer = (SgTypeUnsignedShort*)(*block);
   23719        4002 :           for (unsigned i = 0; i < SgTypeUnsignedShort::pool_size; ++i )
   23720             :              {
   23721             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   23722             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   23723             :             // memory blocks!.
   23724        4000 :                if ( pointer[i].get_freepointer() != NULL )
   23725             :                   {
   23726           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   23727             :                   }
   23728             :                else
   23729             :                   {
   23730        3998 :                     if ( pointerOfLinkedList == NULL )
   23731             :                        {
   23732           2 :                          SgTypeUnsignedShort::next_node = &(pointer[i]);
   23733             :                        }
   23734             :                     else
   23735             :                        {
   23736             :                       // printf ("In SgTypeUnsignedShort::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   23737        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   23738             :                        }
   23739             :                     pointerOfLinkedList = &(pointer[i]);
   23740             :                   }
   23741             :               }
   23742             :         }
   23743             : 
   23744           5 :      if ( pointerOfLinkedList != NULL )
   23745             :         {
   23746             :        // printf ("In SgTypeUnsignedShort::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   23747           2 :           pointerOfLinkedList->set_freepointer(NULL);
   23748             :        // DQ (6/6/2010): Temporary debugging...
   23749             :        //   ROSE_ASSERT(false);
   23750             :         }
   23751             : 
   23752           5 :      return ;
   23753             :    }
   23754             : 
   23755             : //############################################################################
   23756             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   23757             :  * within the memory pool and resets the freepointers, in order to achieve a 
   23758             :  * linked list, that has no jumps and starts at the beginning! This function 
   23759             :  * does not extend the memory pool, since we do not delete any memory blocks,
   23760             :  * but delete the valid objects.  
   23761             :  */
   23762             : void
   23763           0 : SgTypeUnsignedShort::clearMemoryPool( )
   23764             :    {
   23765             :   // printf ("Inside of SgTypeUnsignedShort::clearMemoryPool() \n");
   23766             : 
   23767           0 :      SgTypeUnsignedShort* pointer = NULL, *tempPointer = NULL;
   23768           0 :      std::vector < unsigned char* > :: const_iterator block;
   23769           0 :      if ( SgTypeUnsignedShort::pools.empty() == false )
   23770             :         {
   23771           0 :           block = SgTypeUnsignedShort::pools.begin() ;
   23772           0 :           SgTypeUnsignedShort::next_node = (SgTypeUnsignedShort*) (*block);
   23773             : 
   23774           0 :           while ( block != SgTypeUnsignedShort::pools.end() )
   23775             :              {
   23776           0 :                pointer = (SgTypeUnsignedShort*) (*block);
   23777           0 :                if ( tempPointer != NULL )
   23778             :                   {
   23779           0 :                     tempPointer->set_freepointer(pointer);
   23780             :                   }
   23781           0 :                for (unsigned i = 0; i < SgTypeUnsignedShort::pool_size - 1; ++i)
   23782             :                   {
   23783           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   23784             :                   }
   23785           0 :                 pointer[SgTypeUnsignedShort::pool_size-1].set_freepointer(NULL);
   23786           0 :                 tempPointer = &(pointer[SgTypeUnsignedShort::pool_size-1]);
   23787           0 :                 ++block;
   23788             :              }
   23789             :         }
   23790           0 :    }
   23791             : 
   23792           5 : void SgTypeUnsignedShort::deleteMemoryPool() {
   23793           9 :   for (auto p: SgTypeUnsignedShort::pools) {
   23794           4 :     ROSE_FREE(p);
   23795             :   }
   23796           5 :   SgTypeUnsignedShort::next_node = nullptr;
   23797           5 :   SgTypeUnsignedShort::pools.clear();
   23798           5 : }
   23799             : 
   23800             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   23801             : //                 reading multiple binary files to for a single AST.
   23802             : /////////// new version ////////////////////////////////
   23803             : //############################################################################
   23804             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   23805             : void
   23806           2 : SgTypeUnsignedShort::extendMemoryPoolForFileIO( )
   23807             :   {
   23808           2 :     size_t blockIndex = SgTypeUnsignedShort::pools.size();
   23809           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedShort) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedShort);
   23810             : 
   23811           4 :     while ( (blockIndex * SgTypeUnsignedShort::pool_size) < newPoolSize)
   23812             :       {
   23813             : #if ROSE_ALLOC_TRACE
   23814             :         if (blockIndex > 0) {
   23815             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedShort) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedShort) = %" PRIuPTR " SgTypeUnsignedShort::pool_size = %d \n",
   23816             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedShort),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedShort),SgTypeUnsignedShort::pool_size);
   23817             :         }
   23818             : #endif
   23819             : 
   23820           2 :         SgTypeUnsignedShort * pointer = (SgTypeUnsignedShort*) ROSE_MALLOC ( SgTypeUnsignedShort::pool_size * sizeof(SgTypeUnsignedShort) );
   23821           2 :         assert( pointer != NULL );
   23822             : #if ROSE_ALLOC_MEMSET == 1
   23823             :         memset(pointer, 0x00, SgTypeUnsignedShort::pool_size * sizeof(SgTypeUnsignedShort));
   23824             : #elif ROSE_ALLOC_MEMSET == 2
   23825             :         memset(pointer, 0xCC, SgTypeUnsignedShort::pool_size * sizeof(SgTypeUnsignedShort));
   23826             : #endif
   23827           2 :         SgTypeUnsignedShort::pools.push_back( (unsigned char*)(pointer) );
   23828           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeUnsignedShort::pool_size * sizeof(SgTypeUnsignedShort), V_SgTypeUnsignedShort ) );
   23829             : 
   23830           2 :         if ( SgTypeUnsignedShort::next_node != NULL ) {
   23831           0 :           if ( blockIndex > 0 ) {
   23832           0 :             SgTypeUnsignedShort * blkptr = (SgTypeUnsignedShort*)(SgTypeUnsignedShort::pools[blockIndex-1]);
   23833           0 :             blkptr[ SgTypeUnsignedShort::pool_size - 1 ].set_freepointer(pointer);
   23834             :           }
   23835             :         } else {
   23836           2 :           SgTypeUnsignedShort::next_node = pointer;
   23837             :         }
   23838             : 
   23839        4000 :         for (unsigned i = 0; i < SgTypeUnsignedShort::pool_size-1; ++i)
   23840             :            {
   23841        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   23842             :            }
   23843           2 :         pointer[ SgTypeUnsignedShort::pool_size -1 ].set_freepointer(NULL);
   23844             : 
   23845           2 :         blockIndex++;
   23846             :       }
   23847           2 :   }
   23848             : 
   23849             : //############################################################################
   23850             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   23851             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   23852             :  * not compressed. However, that stuff is not yet implemented! 
   23853             :  */
   23854             : unsigned long
   23855           0 : SgTypeUnsignedShort::getNumberOfLastValidPointer()
   23856             :    {
   23857           0 :       SgTypeUnsignedShort* testPointer = (SgTypeUnsignedShort*)(SgTypeUnsignedShort::pools.back());
   23858           0 :       unsigned long localIndex = SgTypeUnsignedShort::pool_size - 1;
   23859           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   23860             :          {
   23861           0 :            localIndex--;
   23862             :          }
   23863           0 :       return (localIndex + SgTypeUnsignedShort::pool_size * (SgTypeUnsignedShort::pools.size()-1));
   23864             :    }
   23865             : 
   23866             : //############################################################################
   23867             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   23868             :  * memory pool and initializes the data member in class SgTypeUnsignedShortStroageClass
   23869             :  * from its counterpart of SgTypeUnsignedShort. The return value is just for checking, 
   23870             :  * that the whole StorageClassArray is initialized!
   23871             :  */
   23872             : unsigned long
   23873           2 : SgTypeUnsignedShort::initializeStorageClassArray( SgTypeUnsignedShortStorageClass *storageArray )
   23874             :    {
   23875           2 :      unsigned long storageCounter = 0;
   23876           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeUnsignedShort::pools.begin();
   23877           2 :      SgTypeUnsignedShort* pointer = NULL;
   23878           4 :      while ( block != SgTypeUnsignedShort::pools.end() ) {
   23879           2 :           pointer = (SgTypeUnsignedShort*) (*block);
   23880        4002 :           for ( unsigned i = 0; i < SgTypeUnsignedShort::pool_size; ++i ) {
   23881        4000 :                if ( pointer->get_freepointer() != NULL ) {
   23882           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   23883           2 :                  storageArray++;
   23884           2 :                  storageCounter++;
   23885             :                }
   23886        4000 :                pointer++;
   23887             :              }
   23888           2 :            block++;
   23889             :         }
   23890           2 :      return storageCounter;
   23891             :    }
   23892             : 
   23893             : /* #line 23894 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   23894             : 
   23895             : 
   23896             : 
   23897             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   23898             : 
   23899             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   23900             : 
   23901             : //############################################################################
   23902             : /* JH (02/02/2006) Constructor of the IR node SgTypeInt that takes its 
   23903             :  * corresponding StorageClass as parameter
   23904             :  */
   23905           2 : SgTypeInt :: SgTypeInt ( const SgTypeIntStorageClass& storageSource )   : SgType (storageSource)
   23906             :    {
   23907             : 
   23908             : 
   23909             : /* #line 23910 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   23910             : 
   23911           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   23912           2 :      p_field_size = storageSource.storageOf_field_size ;
   23913             : 
   23914             : 
   23915             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   23916             : 
   23917             : 
   23918           2 :    }
   23919             : 
   23920             : //############################################################################
   23921             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   23922             :  * within the working AST. 
   23923             :  */
   23924        3155 : SgTypeInt * SgTypeInt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   23925        3155 :      SgTypeInt* returnPointer = NULL;
   23926        3155 :      if ( globalIndex != 0 )
   23927             :         {
   23928             : 
   23929             : #if FILE_IO_EXTRA_CHECK
   23930        3155 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeInt ) ) <= globalIndex ) ;
   23931        3155 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeInt + 1 ) ) );
   23932             : #endif
   23933        3155 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeInt )  
   23934        3155 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeInt );
   23935        3155 :           unsigned long positionInPool = localIndex % SgTypeInt::pool_size;
   23936        3155 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeInt::pool_size;
   23937             : 
   23938             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   23939             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   23940             : 
   23941        3155 :           returnPointer = &( ( (SgTypeInt*)(SgTypeInt::pools[memoryBlock]) ) [positionInPool]) ;
   23942             : 
   23943        3155 :           ROSE_ASSERT( returnPointer != NULL ) ;
   23944             :         }
   23945        3155 :      return returnPointer ;
   23946             :    }
   23947             : 
   23948             : //############################################################################
   23949             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   23950             :   for the AST with the index astIndex
   23951             : */
   23952           0 : SgTypeInt * SgTypeInt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   23953           0 :      SgTypeInt* returnPointer = NULL;
   23954           0 :      if ( globalIndex != 0 )
   23955             :         {
   23956             : 
   23957             : #if FILE_IO_EXTRA_CHECK
   23958           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeInt ) ) <= globalIndex ) ;
   23959           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeInt + 1 ) ) );
   23960             : #endif
   23961           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeInt )
   23962           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeInt );
   23963           0 :           unsigned long positionInPool = localIndex % SgTypeInt::pool_size ;
   23964           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeInt::pool_size ;
   23965             : 
   23966             : #if FILE_IO_EXTRA_CHECK
   23967             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   23968             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   23969             : #endif
   23970             : 
   23971           0 :           returnPointer = &( ( (SgTypeInt*)(SgTypeInt::pools[memoryBlock]) ) [positionInPool]) ;
   23972             : 
   23973             : #if FILE_IO_EXTRA_CHECK
   23974           0 :           assert ( returnPointer != NULL ) ;
   23975             : #endif
   23976             :         }
   23977           0 :      return returnPointer ;
   23978             :    }
   23979             : 
   23980             : //############################################################################
   23981             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   23982             :  * pool size! We set for every valid object in the memory pool the freepointer
   23983             :  * to the global index and increase the global index afterwards. For all the 
   23984             :  * invalid objects (means address ranges within the memory pool that were not
   23985             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   23986             :  * distinguish valid from invalid objects! 
   23987             :  */
   23988             : unsigned long
   23989           5 : SgTypeInt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   23990             :    {
   23991           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   23992           5 :      SgTypeInt* pointer = NULL;
   23993           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   23994           5 :      std::vector < unsigned char* > :: const_iterator block;
   23995           7 :      for ( block = SgTypeInt::pools.begin(); block != SgTypeInt::pools.end() ; ++block )
   23996             :         {
   23997           2 :           pointer = (SgTypeInt*)(*block);
   23998        4002 :           for (unsigned i = 0; i < SgTypeInt::pool_size; ++i )
   23999             :              {
   24000             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   24001             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   24002             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   24003             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   24004             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   24005             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   24006             :             // properly; so this will have to be checked next.
   24007             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   24008             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   24009        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   24010             :                   {
   24011           2 :                     pointer[i].set_freepointer((SgTypeInt*)(globalIndex));
   24012           2 :                     globalIndex++;
   24013             :                   }
   24014             :                else
   24015             :                   {
   24016        3998 :                     pointer[i].set_freepointer(NULL);
   24017             :                   }
   24018             :               }
   24019             :         }
   24020           5 :      return globalIndex;
   24021             :    }
   24022             : 
   24023             : //############################################################################
   24024             : // JH (01/14/2006)
   24025             : void
   24026           5 : SgTypeInt::resetValidFreepointers( )
   24027             :    {
   24028           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   24029           5 :      SgTypeInt* pointer = NULL;
   24030           5 :      std::vector < unsigned char* > :: const_iterator block;
   24031           5 :      SgTypeInt* pointerOfLinkedList = NULL;
   24032           7 :      for ( block = SgTypeInt::pools.begin(); block != SgTypeInt::pools.end() ; ++block )
   24033             :         {
   24034           2 :           pointer = (SgTypeInt*)(*block);
   24035        4002 :           for (unsigned i = 0; i < SgTypeInt::pool_size; ++i )
   24036             :              {
   24037             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   24038             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   24039             :             // memory blocks!.
   24040        4000 :                if ( pointer[i].get_freepointer() != NULL )
   24041             :                   {
   24042           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   24043             :                   }
   24044             :                else
   24045             :                   {
   24046        3998 :                     if ( pointerOfLinkedList == NULL )
   24047             :                        {
   24048           2 :                          SgTypeInt::next_node = &(pointer[i]);
   24049             :                        }
   24050             :                     else
   24051             :                        {
   24052             :                       // printf ("In SgTypeInt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   24053        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   24054             :                        }
   24055             :                     pointerOfLinkedList = &(pointer[i]);
   24056             :                   }
   24057             :               }
   24058             :         }
   24059             : 
   24060           5 :      if ( pointerOfLinkedList != NULL )
   24061             :         {
   24062             :        // printf ("In SgTypeInt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   24063           2 :           pointerOfLinkedList->set_freepointer(NULL);
   24064             :        // DQ (6/6/2010): Temporary debugging...
   24065             :        //   ROSE_ASSERT(false);
   24066             :         }
   24067             : 
   24068           5 :      return ;
   24069             :    }
   24070             : 
   24071             : //############################################################################
   24072             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   24073             :  * within the memory pool and resets the freepointers, in order to achieve a 
   24074             :  * linked list, that has no jumps and starts at the beginning! This function 
   24075             :  * does not extend the memory pool, since we do not delete any memory blocks,
   24076             :  * but delete the valid objects.  
   24077             :  */
   24078             : void
   24079           0 : SgTypeInt::clearMemoryPool( )
   24080             :    {
   24081             :   // printf ("Inside of SgTypeInt::clearMemoryPool() \n");
   24082             : 
   24083           0 :      SgTypeInt* pointer = NULL, *tempPointer = NULL;
   24084           0 :      std::vector < unsigned char* > :: const_iterator block;
   24085           0 :      if ( SgTypeInt::pools.empty() == false )
   24086             :         {
   24087           0 :           block = SgTypeInt::pools.begin() ;
   24088           0 :           SgTypeInt::next_node = (SgTypeInt*) (*block);
   24089             : 
   24090           0 :           while ( block != SgTypeInt::pools.end() )
   24091             :              {
   24092           0 :                pointer = (SgTypeInt*) (*block);
   24093           0 :                if ( tempPointer != NULL )
   24094             :                   {
   24095           0 :                     tempPointer->set_freepointer(pointer);
   24096             :                   }
   24097           0 :                for (unsigned i = 0; i < SgTypeInt::pool_size - 1; ++i)
   24098             :                   {
   24099           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   24100             :                   }
   24101           0 :                 pointer[SgTypeInt::pool_size-1].set_freepointer(NULL);
   24102           0 :                 tempPointer = &(pointer[SgTypeInt::pool_size-1]);
   24103           0 :                 ++block;
   24104             :              }
   24105             :         }
   24106           0 :    }
   24107             : 
   24108           5 : void SgTypeInt::deleteMemoryPool() {
   24109           9 :   for (auto p: SgTypeInt::pools) {
   24110           4 :     ROSE_FREE(p);
   24111             :   }
   24112           5 :   SgTypeInt::next_node = nullptr;
   24113           5 :   SgTypeInt::pools.clear();
   24114           5 : }
   24115             : 
   24116             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   24117             : //                 reading multiple binary files to for a single AST.
   24118             : /////////// new version ////////////////////////////////
   24119             : //############################################################################
   24120             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   24121             : void
   24122           2 : SgTypeInt::extendMemoryPoolForFileIO( )
   24123             :   {
   24124           2 :     size_t blockIndex = SgTypeInt::pools.size();
   24125           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeInt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeInt);
   24126             : 
   24127           4 :     while ( (blockIndex * SgTypeInt::pool_size) < newPoolSize)
   24128             :       {
   24129             : #if ROSE_ALLOC_TRACE
   24130             :         if (blockIndex > 0) {
   24131             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeInt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeInt) = %" PRIuPTR " SgTypeInt::pool_size = %d \n",
   24132             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeInt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeInt),SgTypeInt::pool_size);
   24133             :         }
   24134             : #endif
   24135             : 
   24136           2 :         SgTypeInt * pointer = (SgTypeInt*) ROSE_MALLOC ( SgTypeInt::pool_size * sizeof(SgTypeInt) );
   24137           2 :         assert( pointer != NULL );
   24138             : #if ROSE_ALLOC_MEMSET == 1
   24139             :         memset(pointer, 0x00, SgTypeInt::pool_size * sizeof(SgTypeInt));
   24140             : #elif ROSE_ALLOC_MEMSET == 2
   24141             :         memset(pointer, 0xCC, SgTypeInt::pool_size * sizeof(SgTypeInt));
   24142             : #endif
   24143           2 :         SgTypeInt::pools.push_back( (unsigned char*)(pointer) );
   24144           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeInt::pool_size * sizeof(SgTypeInt), V_SgTypeInt ) );
   24145             : 
   24146           2 :         if ( SgTypeInt::next_node != NULL ) {
   24147           0 :           if ( blockIndex > 0 ) {
   24148           0 :             SgTypeInt * blkptr = (SgTypeInt*)(SgTypeInt::pools[blockIndex-1]);
   24149           0 :             blkptr[ SgTypeInt::pool_size - 1 ].set_freepointer(pointer);
   24150             :           }
   24151             :         } else {
   24152           2 :           SgTypeInt::next_node = pointer;
   24153             :         }
   24154             : 
   24155        4000 :         for (unsigned i = 0; i < SgTypeInt::pool_size-1; ++i)
   24156             :            {
   24157        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   24158             :            }
   24159           2 :         pointer[ SgTypeInt::pool_size -1 ].set_freepointer(NULL);
   24160             : 
   24161           2 :         blockIndex++;
   24162             :       }
   24163           2 :   }
   24164             : 
   24165             : //############################################################################
   24166             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   24167             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   24168             :  * not compressed. However, that stuff is not yet implemented! 
   24169             :  */
   24170             : unsigned long
   24171           0 : SgTypeInt::getNumberOfLastValidPointer()
   24172             :    {
   24173           0 :       SgTypeInt* testPointer = (SgTypeInt*)(SgTypeInt::pools.back());
   24174           0 :       unsigned long localIndex = SgTypeInt::pool_size - 1;
   24175           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   24176             :          {
   24177           0 :            localIndex--;
   24178             :          }
   24179           0 :       return (localIndex + SgTypeInt::pool_size * (SgTypeInt::pools.size()-1));
   24180             :    }
   24181             : 
   24182             : //############################################################################
   24183             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   24184             :  * memory pool and initializes the data member in class SgTypeIntStroageClass
   24185             :  * from its counterpart of SgTypeInt. The return value is just for checking, 
   24186             :  * that the whole StorageClassArray is initialized!
   24187             :  */
   24188             : unsigned long
   24189           2 : SgTypeInt::initializeStorageClassArray( SgTypeIntStorageClass *storageArray )
   24190             :    {
   24191           2 :      unsigned long storageCounter = 0;
   24192           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeInt::pools.begin();
   24193           2 :      SgTypeInt* pointer = NULL;
   24194           4 :      while ( block != SgTypeInt::pools.end() ) {
   24195           2 :           pointer = (SgTypeInt*) (*block);
   24196        4002 :           for ( unsigned i = 0; i < SgTypeInt::pool_size; ++i ) {
   24197        4000 :                if ( pointer->get_freepointer() != NULL ) {
   24198           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   24199           2 :                  storageArray++;
   24200           2 :                  storageCounter++;
   24201             :                }
   24202        4000 :                pointer++;
   24203             :              }
   24204           2 :            block++;
   24205             :         }
   24206           2 :      return storageCounter;
   24207             :    }
   24208             : 
   24209             : /* #line 24210 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   24210             : 
   24211             : 
   24212             : 
   24213             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   24214             : 
   24215             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   24216             : 
   24217             : //############################################################################
   24218             : /* JH (02/02/2006) Constructor of the IR node SgTypeSignedInt that takes its 
   24219             :  * corresponding StorageClass as parameter
   24220             :  */
   24221           2 : SgTypeSignedInt :: SgTypeSignedInt ( const SgTypeSignedIntStorageClass& storageSource )   : SgType (storageSource)
   24222             :    {
   24223             : 
   24224             : 
   24225             : /* #line 24226 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   24226             : 
   24227           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   24228             : 
   24229             : 
   24230             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   24231             : 
   24232             : 
   24233           2 :    }
   24234             : 
   24235             : //############################################################################
   24236             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   24237             :  * within the working AST. 
   24238             :  */
   24239           7 : SgTypeSignedInt * SgTypeSignedInt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   24240           7 :      SgTypeSignedInt* returnPointer = NULL;
   24241           7 :      if ( globalIndex != 0 )
   24242             :         {
   24243             : 
   24244             : #if FILE_IO_EXTRA_CHECK
   24245           7 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeSignedInt ) ) <= globalIndex ) ;
   24246           7 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedInt + 1 ) ) );
   24247             : #endif
   24248           7 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedInt )  
   24249           7 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeSignedInt );
   24250           7 :           unsigned long positionInPool = localIndex % SgTypeSignedInt::pool_size;
   24251           7 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedInt::pool_size;
   24252             : 
   24253             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   24254             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   24255             : 
   24256           7 :           returnPointer = &( ( (SgTypeSignedInt*)(SgTypeSignedInt::pools[memoryBlock]) ) [positionInPool]) ;
   24257             : 
   24258           7 :           ROSE_ASSERT( returnPointer != NULL ) ;
   24259             :         }
   24260           7 :      return returnPointer ;
   24261             :    }
   24262             : 
   24263             : //############################################################################
   24264             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   24265             :   for the AST with the index astIndex
   24266             : */
   24267           0 : SgTypeSignedInt * SgTypeSignedInt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   24268           0 :      SgTypeSignedInt* returnPointer = NULL;
   24269           0 :      if ( globalIndex != 0 )
   24270             :         {
   24271             : 
   24272             : #if FILE_IO_EXTRA_CHECK
   24273           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeSignedInt ) ) <= globalIndex ) ;
   24274           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedInt + 1 ) ) );
   24275             : #endif
   24276           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedInt )
   24277           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeSignedInt );
   24278           0 :           unsigned long positionInPool = localIndex % SgTypeSignedInt::pool_size ;
   24279           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedInt::pool_size ;
   24280             : 
   24281             : #if FILE_IO_EXTRA_CHECK
   24282             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   24283             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   24284             : #endif
   24285             : 
   24286           0 :           returnPointer = &( ( (SgTypeSignedInt*)(SgTypeSignedInt::pools[memoryBlock]) ) [positionInPool]) ;
   24287             : 
   24288             : #if FILE_IO_EXTRA_CHECK
   24289           0 :           assert ( returnPointer != NULL ) ;
   24290             : #endif
   24291             :         }
   24292           0 :      return returnPointer ;
   24293             :    }
   24294             : 
   24295             : //############################################################################
   24296             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   24297             :  * pool size! We set for every valid object in the memory pool the freepointer
   24298             :  * to the global index and increase the global index afterwards. For all the 
   24299             :  * invalid objects (means address ranges within the memory pool that were not
   24300             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   24301             :  * distinguish valid from invalid objects! 
   24302             :  */
   24303             : unsigned long
   24304           5 : SgTypeSignedInt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   24305             :    {
   24306           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   24307           5 :      SgTypeSignedInt* pointer = NULL;
   24308           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   24309           5 :      std::vector < unsigned char* > :: const_iterator block;
   24310           7 :      for ( block = SgTypeSignedInt::pools.begin(); block != SgTypeSignedInt::pools.end() ; ++block )
   24311             :         {
   24312           2 :           pointer = (SgTypeSignedInt*)(*block);
   24313        4002 :           for (unsigned i = 0; i < SgTypeSignedInt::pool_size; ++i )
   24314             :              {
   24315             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   24316             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   24317             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   24318             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   24319             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   24320             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   24321             :             // properly; so this will have to be checked next.
   24322             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   24323             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   24324        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   24325             :                   {
   24326           2 :                     pointer[i].set_freepointer((SgTypeSignedInt*)(globalIndex));
   24327           2 :                     globalIndex++;
   24328             :                   }
   24329             :                else
   24330             :                   {
   24331        3998 :                     pointer[i].set_freepointer(NULL);
   24332             :                   }
   24333             :               }
   24334             :         }
   24335           5 :      return globalIndex;
   24336             :    }
   24337             : 
   24338             : //############################################################################
   24339             : // JH (01/14/2006)
   24340             : void
   24341           5 : SgTypeSignedInt::resetValidFreepointers( )
   24342             :    {
   24343           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   24344           5 :      SgTypeSignedInt* pointer = NULL;
   24345           5 :      std::vector < unsigned char* > :: const_iterator block;
   24346           5 :      SgTypeSignedInt* pointerOfLinkedList = NULL;
   24347           7 :      for ( block = SgTypeSignedInt::pools.begin(); block != SgTypeSignedInt::pools.end() ; ++block )
   24348             :         {
   24349           2 :           pointer = (SgTypeSignedInt*)(*block);
   24350        4002 :           for (unsigned i = 0; i < SgTypeSignedInt::pool_size; ++i )
   24351             :              {
   24352             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   24353             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   24354             :             // memory blocks!.
   24355        4000 :                if ( pointer[i].get_freepointer() != NULL )
   24356             :                   {
   24357           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   24358             :                   }
   24359             :                else
   24360             :                   {
   24361        3998 :                     if ( pointerOfLinkedList == NULL )
   24362             :                        {
   24363           2 :                          SgTypeSignedInt::next_node = &(pointer[i]);
   24364             :                        }
   24365             :                     else
   24366             :                        {
   24367             :                       // printf ("In SgTypeSignedInt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   24368        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   24369             :                        }
   24370             :                     pointerOfLinkedList = &(pointer[i]);
   24371             :                   }
   24372             :               }
   24373             :         }
   24374             : 
   24375           5 :      if ( pointerOfLinkedList != NULL )
   24376             :         {
   24377             :        // printf ("In SgTypeSignedInt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   24378           2 :           pointerOfLinkedList->set_freepointer(NULL);
   24379             :        // DQ (6/6/2010): Temporary debugging...
   24380             :        //   ROSE_ASSERT(false);
   24381             :         }
   24382             : 
   24383           5 :      return ;
   24384             :    }
   24385             : 
   24386             : //############################################################################
   24387             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   24388             :  * within the memory pool and resets the freepointers, in order to achieve a 
   24389             :  * linked list, that has no jumps and starts at the beginning! This function 
   24390             :  * does not extend the memory pool, since we do not delete any memory blocks,
   24391             :  * but delete the valid objects.  
   24392             :  */
   24393             : void
   24394           0 : SgTypeSignedInt::clearMemoryPool( )
   24395             :    {
   24396             :   // printf ("Inside of SgTypeSignedInt::clearMemoryPool() \n");
   24397             : 
   24398           0 :      SgTypeSignedInt* pointer = NULL, *tempPointer = NULL;
   24399           0 :      std::vector < unsigned char* > :: const_iterator block;
   24400           0 :      if ( SgTypeSignedInt::pools.empty() == false )
   24401             :         {
   24402           0 :           block = SgTypeSignedInt::pools.begin() ;
   24403           0 :           SgTypeSignedInt::next_node = (SgTypeSignedInt*) (*block);
   24404             : 
   24405           0 :           while ( block != SgTypeSignedInt::pools.end() )
   24406             :              {
   24407           0 :                pointer = (SgTypeSignedInt*) (*block);
   24408           0 :                if ( tempPointer != NULL )
   24409             :                   {
   24410           0 :                     tempPointer->set_freepointer(pointer);
   24411             :                   }
   24412           0 :                for (unsigned i = 0; i < SgTypeSignedInt::pool_size - 1; ++i)
   24413             :                   {
   24414           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   24415             :                   }
   24416           0 :                 pointer[SgTypeSignedInt::pool_size-1].set_freepointer(NULL);
   24417           0 :                 tempPointer = &(pointer[SgTypeSignedInt::pool_size-1]);
   24418           0 :                 ++block;
   24419             :              }
   24420             :         }
   24421           0 :    }
   24422             : 
   24423           5 : void SgTypeSignedInt::deleteMemoryPool() {
   24424           9 :   for (auto p: SgTypeSignedInt::pools) {
   24425           4 :     ROSE_FREE(p);
   24426             :   }
   24427           5 :   SgTypeSignedInt::next_node = nullptr;
   24428           5 :   SgTypeSignedInt::pools.clear();
   24429           5 : }
   24430             : 
   24431             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   24432             : //                 reading multiple binary files to for a single AST.
   24433             : /////////// new version ////////////////////////////////
   24434             : //############################################################################
   24435             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   24436             : void
   24437           2 : SgTypeSignedInt::extendMemoryPoolForFileIO( )
   24438             :   {
   24439           2 :     size_t blockIndex = SgTypeSignedInt::pools.size();
   24440           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedInt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedInt);
   24441             : 
   24442           4 :     while ( (blockIndex * SgTypeSignedInt::pool_size) < newPoolSize)
   24443             :       {
   24444             : #if ROSE_ALLOC_TRACE
   24445             :         if (blockIndex > 0) {
   24446             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedInt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedInt) = %" PRIuPTR " SgTypeSignedInt::pool_size = %d \n",
   24447             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedInt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedInt),SgTypeSignedInt::pool_size);
   24448             :         }
   24449             : #endif
   24450             : 
   24451           2 :         SgTypeSignedInt * pointer = (SgTypeSignedInt*) ROSE_MALLOC ( SgTypeSignedInt::pool_size * sizeof(SgTypeSignedInt) );
   24452           2 :         assert( pointer != NULL );
   24453             : #if ROSE_ALLOC_MEMSET == 1
   24454             :         memset(pointer, 0x00, SgTypeSignedInt::pool_size * sizeof(SgTypeSignedInt));
   24455             : #elif ROSE_ALLOC_MEMSET == 2
   24456             :         memset(pointer, 0xCC, SgTypeSignedInt::pool_size * sizeof(SgTypeSignedInt));
   24457             : #endif
   24458           2 :         SgTypeSignedInt::pools.push_back( (unsigned char*)(pointer) );
   24459           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeSignedInt::pool_size * sizeof(SgTypeSignedInt), V_SgTypeSignedInt ) );
   24460             : 
   24461           2 :         if ( SgTypeSignedInt::next_node != NULL ) {
   24462           0 :           if ( blockIndex > 0 ) {
   24463           0 :             SgTypeSignedInt * blkptr = (SgTypeSignedInt*)(SgTypeSignedInt::pools[blockIndex-1]);
   24464           0 :             blkptr[ SgTypeSignedInt::pool_size - 1 ].set_freepointer(pointer);
   24465             :           }
   24466             :         } else {
   24467           2 :           SgTypeSignedInt::next_node = pointer;
   24468             :         }
   24469             : 
   24470        4000 :         for (unsigned i = 0; i < SgTypeSignedInt::pool_size-1; ++i)
   24471             :            {
   24472        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   24473             :            }
   24474           2 :         pointer[ SgTypeSignedInt::pool_size -1 ].set_freepointer(NULL);
   24475             : 
   24476           2 :         blockIndex++;
   24477             :       }
   24478           2 :   }
   24479             : 
   24480             : //############################################################################
   24481             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   24482             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   24483             :  * not compressed. However, that stuff is not yet implemented! 
   24484             :  */
   24485             : unsigned long
   24486           0 : SgTypeSignedInt::getNumberOfLastValidPointer()
   24487             :    {
   24488           0 :       SgTypeSignedInt* testPointer = (SgTypeSignedInt*)(SgTypeSignedInt::pools.back());
   24489           0 :       unsigned long localIndex = SgTypeSignedInt::pool_size - 1;
   24490           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   24491             :          {
   24492           0 :            localIndex--;
   24493             :          }
   24494           0 :       return (localIndex + SgTypeSignedInt::pool_size * (SgTypeSignedInt::pools.size()-1));
   24495             :    }
   24496             : 
   24497             : //############################################################################
   24498             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   24499             :  * memory pool and initializes the data member in class SgTypeSignedIntStroageClass
   24500             :  * from its counterpart of SgTypeSignedInt. The return value is just for checking, 
   24501             :  * that the whole StorageClassArray is initialized!
   24502             :  */
   24503             : unsigned long
   24504           2 : SgTypeSignedInt::initializeStorageClassArray( SgTypeSignedIntStorageClass *storageArray )
   24505             :    {
   24506           2 :      unsigned long storageCounter = 0;
   24507           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeSignedInt::pools.begin();
   24508           2 :      SgTypeSignedInt* pointer = NULL;
   24509           4 :      while ( block != SgTypeSignedInt::pools.end() ) {
   24510           2 :           pointer = (SgTypeSignedInt*) (*block);
   24511        4002 :           for ( unsigned i = 0; i < SgTypeSignedInt::pool_size; ++i ) {
   24512        4000 :                if ( pointer->get_freepointer() != NULL ) {
   24513           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   24514           2 :                  storageArray++;
   24515           2 :                  storageCounter++;
   24516             :                }
   24517        4000 :                pointer++;
   24518             :              }
   24519           2 :            block++;
   24520             :         }
   24521           2 :      return storageCounter;
   24522             :    }
   24523             : 
   24524             : /* #line 24525 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   24525             : 
   24526             : 
   24527             : 
   24528             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   24529             : 
   24530             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   24531             : 
   24532             : //############################################################################
   24533             : /* JH (02/02/2006) Constructor of the IR node SgTypeUnsignedInt that takes its 
   24534             :  * corresponding StorageClass as parameter
   24535             :  */
   24536           2 : SgTypeUnsignedInt :: SgTypeUnsignedInt ( const SgTypeUnsignedIntStorageClass& storageSource )   : SgType (storageSource)
   24537             :    {
   24538             : 
   24539             : 
   24540             : /* #line 24541 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   24541             : 
   24542           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   24543             : 
   24544             : 
   24545             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   24546             : 
   24547             : 
   24548           2 :    }
   24549             : 
   24550             : //############################################################################
   24551             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   24552             :  * within the working AST. 
   24553             :  */
   24554        1841 : SgTypeUnsignedInt * SgTypeUnsignedInt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   24555        1841 :      SgTypeUnsignedInt* returnPointer = NULL;
   24556        1841 :      if ( globalIndex != 0 )
   24557             :         {
   24558             : 
   24559             : #if FILE_IO_EXTRA_CHECK
   24560        1841 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeUnsignedInt ) ) <= globalIndex ) ;
   24561        1841 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedInt + 1 ) ) );
   24562             : #endif
   24563        1841 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedInt )  
   24564        1841 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeUnsignedInt );
   24565        1841 :           unsigned long positionInPool = localIndex % SgTypeUnsignedInt::pool_size;
   24566        1841 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedInt::pool_size;
   24567             : 
   24568             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   24569             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   24570             : 
   24571        1841 :           returnPointer = &( ( (SgTypeUnsignedInt*)(SgTypeUnsignedInt::pools[memoryBlock]) ) [positionInPool]) ;
   24572             : 
   24573        1841 :           ROSE_ASSERT( returnPointer != NULL ) ;
   24574             :         }
   24575        1841 :      return returnPointer ;
   24576             :    }
   24577             : 
   24578             : //############################################################################
   24579             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   24580             :   for the AST with the index astIndex
   24581             : */
   24582           0 : SgTypeUnsignedInt * SgTypeUnsignedInt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   24583           0 :      SgTypeUnsignedInt* returnPointer = NULL;
   24584           0 :      if ( globalIndex != 0 )
   24585             :         {
   24586             : 
   24587             : #if FILE_IO_EXTRA_CHECK
   24588           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeUnsignedInt ) ) <= globalIndex ) ;
   24589           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedInt + 1 ) ) );
   24590             : #endif
   24591           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedInt )
   24592           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeUnsignedInt );
   24593           0 :           unsigned long positionInPool = localIndex % SgTypeUnsignedInt::pool_size ;
   24594           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedInt::pool_size ;
   24595             : 
   24596             : #if FILE_IO_EXTRA_CHECK
   24597             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   24598             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   24599             : #endif
   24600             : 
   24601           0 :           returnPointer = &( ( (SgTypeUnsignedInt*)(SgTypeUnsignedInt::pools[memoryBlock]) ) [positionInPool]) ;
   24602             : 
   24603             : #if FILE_IO_EXTRA_CHECK
   24604           0 :           assert ( returnPointer != NULL ) ;
   24605             : #endif
   24606             :         }
   24607           0 :      return returnPointer ;
   24608             :    }
   24609             : 
   24610             : //############################################################################
   24611             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   24612             :  * pool size! We set for every valid object in the memory pool the freepointer
   24613             :  * to the global index and increase the global index afterwards. For all the 
   24614             :  * invalid objects (means address ranges within the memory pool that were not
   24615             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   24616             :  * distinguish valid from invalid objects! 
   24617             :  */
   24618             : unsigned long
   24619           5 : SgTypeUnsignedInt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   24620             :    {
   24621           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   24622           5 :      SgTypeUnsignedInt* pointer = NULL;
   24623           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   24624           5 :      std::vector < unsigned char* > :: const_iterator block;
   24625           7 :      for ( block = SgTypeUnsignedInt::pools.begin(); block != SgTypeUnsignedInt::pools.end() ; ++block )
   24626             :         {
   24627           2 :           pointer = (SgTypeUnsignedInt*)(*block);
   24628        4002 :           for (unsigned i = 0; i < SgTypeUnsignedInt::pool_size; ++i )
   24629             :              {
   24630             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   24631             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   24632             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   24633             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   24634             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   24635             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   24636             :             // properly; so this will have to be checked next.
   24637             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   24638             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   24639        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   24640             :                   {
   24641           2 :                     pointer[i].set_freepointer((SgTypeUnsignedInt*)(globalIndex));
   24642           2 :                     globalIndex++;
   24643             :                   }
   24644             :                else
   24645             :                   {
   24646        3998 :                     pointer[i].set_freepointer(NULL);
   24647             :                   }
   24648             :               }
   24649             :         }
   24650           5 :      return globalIndex;
   24651             :    }
   24652             : 
   24653             : //############################################################################
   24654             : // JH (01/14/2006)
   24655             : void
   24656           5 : SgTypeUnsignedInt::resetValidFreepointers( )
   24657             :    {
   24658           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   24659           5 :      SgTypeUnsignedInt* pointer = NULL;
   24660           5 :      std::vector < unsigned char* > :: const_iterator block;
   24661           5 :      SgTypeUnsignedInt* pointerOfLinkedList = NULL;
   24662           7 :      for ( block = SgTypeUnsignedInt::pools.begin(); block != SgTypeUnsignedInt::pools.end() ; ++block )
   24663             :         {
   24664           2 :           pointer = (SgTypeUnsignedInt*)(*block);
   24665        4002 :           for (unsigned i = 0; i < SgTypeUnsignedInt::pool_size; ++i )
   24666             :              {
   24667             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   24668             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   24669             :             // memory blocks!.
   24670        4000 :                if ( pointer[i].get_freepointer() != NULL )
   24671             :                   {
   24672           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   24673             :                   }
   24674             :                else
   24675             :                   {
   24676        3998 :                     if ( pointerOfLinkedList == NULL )
   24677             :                        {
   24678           2 :                          SgTypeUnsignedInt::next_node = &(pointer[i]);
   24679             :                        }
   24680             :                     else
   24681             :                        {
   24682             :                       // printf ("In SgTypeUnsignedInt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   24683        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   24684             :                        }
   24685             :                     pointerOfLinkedList = &(pointer[i]);
   24686             :                   }
   24687             :               }
   24688             :         }
   24689             : 
   24690           5 :      if ( pointerOfLinkedList != NULL )
   24691             :         {
   24692             :        // printf ("In SgTypeUnsignedInt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   24693           2 :           pointerOfLinkedList->set_freepointer(NULL);
   24694             :        // DQ (6/6/2010): Temporary debugging...
   24695             :        //   ROSE_ASSERT(false);
   24696             :         }
   24697             : 
   24698           5 :      return ;
   24699             :    }
   24700             : 
   24701             : //############################################################################
   24702             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   24703             :  * within the memory pool and resets the freepointers, in order to achieve a 
   24704             :  * linked list, that has no jumps and starts at the beginning! This function 
   24705             :  * does not extend the memory pool, since we do not delete any memory blocks,
   24706             :  * but delete the valid objects.  
   24707             :  */
   24708             : void
   24709           0 : SgTypeUnsignedInt::clearMemoryPool( )
   24710             :    {
   24711             :   // printf ("Inside of SgTypeUnsignedInt::clearMemoryPool() \n");
   24712             : 
   24713           0 :      SgTypeUnsignedInt* pointer = NULL, *tempPointer = NULL;
   24714           0 :      std::vector < unsigned char* > :: const_iterator block;
   24715           0 :      if ( SgTypeUnsignedInt::pools.empty() == false )
   24716             :         {
   24717           0 :           block = SgTypeUnsignedInt::pools.begin() ;
   24718           0 :           SgTypeUnsignedInt::next_node = (SgTypeUnsignedInt*) (*block);
   24719             : 
   24720           0 :           while ( block != SgTypeUnsignedInt::pools.end() )
   24721             :              {
   24722           0 :                pointer = (SgTypeUnsignedInt*) (*block);
   24723           0 :                if ( tempPointer != NULL )
   24724             :                   {
   24725           0 :                     tempPointer->set_freepointer(pointer);
   24726             :                   }
   24727           0 :                for (unsigned i = 0; i < SgTypeUnsignedInt::pool_size - 1; ++i)
   24728             :                   {
   24729           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   24730             :                   }
   24731           0 :                 pointer[SgTypeUnsignedInt::pool_size-1].set_freepointer(NULL);
   24732           0 :                 tempPointer = &(pointer[SgTypeUnsignedInt::pool_size-1]);
   24733           0 :                 ++block;
   24734             :              }
   24735             :         }
   24736           0 :    }
   24737             : 
   24738           5 : void SgTypeUnsignedInt::deleteMemoryPool() {
   24739           9 :   for (auto p: SgTypeUnsignedInt::pools) {
   24740           4 :     ROSE_FREE(p);
   24741             :   }
   24742           5 :   SgTypeUnsignedInt::next_node = nullptr;
   24743           5 :   SgTypeUnsignedInt::pools.clear();
   24744           5 : }
   24745             : 
   24746             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   24747             : //                 reading multiple binary files to for a single AST.
   24748             : /////////// new version ////////////////////////////////
   24749             : //############################################################################
   24750             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   24751             : void
   24752           2 : SgTypeUnsignedInt::extendMemoryPoolForFileIO( )
   24753             :   {
   24754           2 :     size_t blockIndex = SgTypeUnsignedInt::pools.size();
   24755           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedInt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedInt);
   24756             : 
   24757           4 :     while ( (blockIndex * SgTypeUnsignedInt::pool_size) < newPoolSize)
   24758             :       {
   24759             : #if ROSE_ALLOC_TRACE
   24760             :         if (blockIndex > 0) {
   24761             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedInt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedInt) = %" PRIuPTR " SgTypeUnsignedInt::pool_size = %d \n",
   24762             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedInt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedInt),SgTypeUnsignedInt::pool_size);
   24763             :         }
   24764             : #endif
   24765             : 
   24766           2 :         SgTypeUnsignedInt * pointer = (SgTypeUnsignedInt*) ROSE_MALLOC ( SgTypeUnsignedInt::pool_size * sizeof(SgTypeUnsignedInt) );
   24767           2 :         assert( pointer != NULL );
   24768             : #if ROSE_ALLOC_MEMSET == 1
   24769             :         memset(pointer, 0x00, SgTypeUnsignedInt::pool_size * sizeof(SgTypeUnsignedInt));
   24770             : #elif ROSE_ALLOC_MEMSET == 2
   24771             :         memset(pointer, 0xCC, SgTypeUnsignedInt::pool_size * sizeof(SgTypeUnsignedInt));
   24772             : #endif
   24773           2 :         SgTypeUnsignedInt::pools.push_back( (unsigned char*)(pointer) );
   24774           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeUnsignedInt::pool_size * sizeof(SgTypeUnsignedInt), V_SgTypeUnsignedInt ) );
   24775             : 
   24776           2 :         if ( SgTypeUnsignedInt::next_node != NULL ) {
   24777           0 :           if ( blockIndex > 0 ) {
   24778           0 :             SgTypeUnsignedInt * blkptr = (SgTypeUnsignedInt*)(SgTypeUnsignedInt::pools[blockIndex-1]);
   24779           0 :             blkptr[ SgTypeUnsignedInt::pool_size - 1 ].set_freepointer(pointer);
   24780             :           }
   24781             :         } else {
   24782           2 :           SgTypeUnsignedInt::next_node = pointer;
   24783             :         }
   24784             : 
   24785        4000 :         for (unsigned i = 0; i < SgTypeUnsignedInt::pool_size-1; ++i)
   24786             :            {
   24787        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   24788             :            }
   24789           2 :         pointer[ SgTypeUnsignedInt::pool_size -1 ].set_freepointer(NULL);
   24790             : 
   24791           2 :         blockIndex++;
   24792             :       }
   24793           2 :   }
   24794             : 
   24795             : //############################################################################
   24796             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   24797             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   24798             :  * not compressed. However, that stuff is not yet implemented! 
   24799             :  */
   24800             : unsigned long
   24801           0 : SgTypeUnsignedInt::getNumberOfLastValidPointer()
   24802             :    {
   24803           0 :       SgTypeUnsignedInt* testPointer = (SgTypeUnsignedInt*)(SgTypeUnsignedInt::pools.back());
   24804           0 :       unsigned long localIndex = SgTypeUnsignedInt::pool_size - 1;
   24805           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   24806             :          {
   24807           0 :            localIndex--;
   24808             :          }
   24809           0 :       return (localIndex + SgTypeUnsignedInt::pool_size * (SgTypeUnsignedInt::pools.size()-1));
   24810             :    }
   24811             : 
   24812             : //############################################################################
   24813             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   24814             :  * memory pool and initializes the data member in class SgTypeUnsignedIntStroageClass
   24815             :  * from its counterpart of SgTypeUnsignedInt. The return value is just for checking, 
   24816             :  * that the whole StorageClassArray is initialized!
   24817             :  */
   24818             : unsigned long
   24819           2 : SgTypeUnsignedInt::initializeStorageClassArray( SgTypeUnsignedIntStorageClass *storageArray )
   24820             :    {
   24821           2 :      unsigned long storageCounter = 0;
   24822           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeUnsignedInt::pools.begin();
   24823           2 :      SgTypeUnsignedInt* pointer = NULL;
   24824           4 :      while ( block != SgTypeUnsignedInt::pools.end() ) {
   24825           2 :           pointer = (SgTypeUnsignedInt*) (*block);
   24826        4002 :           for ( unsigned i = 0; i < SgTypeUnsignedInt::pool_size; ++i ) {
   24827        4000 :                if ( pointer->get_freepointer() != NULL ) {
   24828           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   24829           2 :                  storageArray++;
   24830           2 :                  storageCounter++;
   24831             :                }
   24832        4000 :                pointer++;
   24833             :              }
   24834           2 :            block++;
   24835             :         }
   24836           2 :      return storageCounter;
   24837             :    }
   24838             : 
   24839             : /* #line 24840 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   24840             : 
   24841             : 
   24842             : 
   24843             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   24844             : 
   24845             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   24846             : 
   24847             : //############################################################################
   24848             : /* JH (02/02/2006) Constructor of the IR node SgTypeLong that takes its 
   24849             :  * corresponding StorageClass as parameter
   24850             :  */
   24851           2 : SgTypeLong :: SgTypeLong ( const SgTypeLongStorageClass& storageSource )   : SgType (storageSource)
   24852             :    {
   24853             : 
   24854             : 
   24855             : /* #line 24856 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   24856             : 
   24857           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   24858             : 
   24859             : 
   24860             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   24861             : 
   24862             : 
   24863           2 :    }
   24864             : 
   24865             : //############################################################################
   24866             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   24867             :  * within the working AST. 
   24868             :  */
   24869         386 : SgTypeLong * SgTypeLong::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   24870         386 :      SgTypeLong* returnPointer = NULL;
   24871         386 :      if ( globalIndex != 0 )
   24872             :         {
   24873             : 
   24874             : #if FILE_IO_EXTRA_CHECK
   24875         386 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeLong ) ) <= globalIndex ) ;
   24876         386 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeLong + 1 ) ) );
   24877             : #endif
   24878         386 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeLong )  
   24879         386 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeLong );
   24880         386 :           unsigned long positionInPool = localIndex % SgTypeLong::pool_size;
   24881         386 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeLong::pool_size;
   24882             : 
   24883             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   24884             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   24885             : 
   24886         386 :           returnPointer = &( ( (SgTypeLong*)(SgTypeLong::pools[memoryBlock]) ) [positionInPool]) ;
   24887             : 
   24888         386 :           ROSE_ASSERT( returnPointer != NULL ) ;
   24889             :         }
   24890         386 :      return returnPointer ;
   24891             :    }
   24892             : 
   24893             : //############################################################################
   24894             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   24895             :   for the AST with the index astIndex
   24896             : */
   24897           0 : SgTypeLong * SgTypeLong::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   24898           0 :      SgTypeLong* returnPointer = NULL;
   24899           0 :      if ( globalIndex != 0 )
   24900             :         {
   24901             : 
   24902             : #if FILE_IO_EXTRA_CHECK
   24903           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeLong ) ) <= globalIndex ) ;
   24904           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeLong + 1 ) ) );
   24905             : #endif
   24906           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeLong )
   24907           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeLong );
   24908           0 :           unsigned long positionInPool = localIndex % SgTypeLong::pool_size ;
   24909           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeLong::pool_size ;
   24910             : 
   24911             : #if FILE_IO_EXTRA_CHECK
   24912             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   24913             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   24914             : #endif
   24915             : 
   24916           0 :           returnPointer = &( ( (SgTypeLong*)(SgTypeLong::pools[memoryBlock]) ) [positionInPool]) ;
   24917             : 
   24918             : #if FILE_IO_EXTRA_CHECK
   24919           0 :           assert ( returnPointer != NULL ) ;
   24920             : #endif
   24921             :         }
   24922           0 :      return returnPointer ;
   24923             :    }
   24924             : 
   24925             : //############################################################################
   24926             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   24927             :  * pool size! We set for every valid object in the memory pool the freepointer
   24928             :  * to the global index and increase the global index afterwards. For all the 
   24929             :  * invalid objects (means address ranges within the memory pool that were not
   24930             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   24931             :  * distinguish valid from invalid objects! 
   24932             :  */
   24933             : unsigned long
   24934           5 : SgTypeLong::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   24935             :    {
   24936           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   24937           5 :      SgTypeLong* pointer = NULL;
   24938           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   24939           5 :      std::vector < unsigned char* > :: const_iterator block;
   24940           7 :      for ( block = SgTypeLong::pools.begin(); block != SgTypeLong::pools.end() ; ++block )
   24941             :         {
   24942           2 :           pointer = (SgTypeLong*)(*block);
   24943        4002 :           for (unsigned i = 0; i < SgTypeLong::pool_size; ++i )
   24944             :              {
   24945             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   24946             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   24947             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   24948             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   24949             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   24950             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   24951             :             // properly; so this will have to be checked next.
   24952             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   24953             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   24954        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   24955             :                   {
   24956           2 :                     pointer[i].set_freepointer((SgTypeLong*)(globalIndex));
   24957           2 :                     globalIndex++;
   24958             :                   }
   24959             :                else
   24960             :                   {
   24961        3998 :                     pointer[i].set_freepointer(NULL);
   24962             :                   }
   24963             :               }
   24964             :         }
   24965           5 :      return globalIndex;
   24966             :    }
   24967             : 
   24968             : //############################################################################
   24969             : // JH (01/14/2006)
   24970             : void
   24971           5 : SgTypeLong::resetValidFreepointers( )
   24972             :    {
   24973           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   24974           5 :      SgTypeLong* pointer = NULL;
   24975           5 :      std::vector < unsigned char* > :: const_iterator block;
   24976           5 :      SgTypeLong* pointerOfLinkedList = NULL;
   24977           7 :      for ( block = SgTypeLong::pools.begin(); block != SgTypeLong::pools.end() ; ++block )
   24978             :         {
   24979           2 :           pointer = (SgTypeLong*)(*block);
   24980        4002 :           for (unsigned i = 0; i < SgTypeLong::pool_size; ++i )
   24981             :              {
   24982             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   24983             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   24984             :             // memory blocks!.
   24985        4000 :                if ( pointer[i].get_freepointer() != NULL )
   24986             :                   {
   24987           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   24988             :                   }
   24989             :                else
   24990             :                   {
   24991        3998 :                     if ( pointerOfLinkedList == NULL )
   24992             :                        {
   24993           2 :                          SgTypeLong::next_node = &(pointer[i]);
   24994             :                        }
   24995             :                     else
   24996             :                        {
   24997             :                       // printf ("In SgTypeLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   24998        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   24999             :                        }
   25000             :                     pointerOfLinkedList = &(pointer[i]);
   25001             :                   }
   25002             :               }
   25003             :         }
   25004             : 
   25005           5 :      if ( pointerOfLinkedList != NULL )
   25006             :         {
   25007             :        // printf ("In SgTypeLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   25008           2 :           pointerOfLinkedList->set_freepointer(NULL);
   25009             :        // DQ (6/6/2010): Temporary debugging...
   25010             :        //   ROSE_ASSERT(false);
   25011             :         }
   25012             : 
   25013           5 :      return ;
   25014             :    }
   25015             : 
   25016             : //############################################################################
   25017             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   25018             :  * within the memory pool and resets the freepointers, in order to achieve a 
   25019             :  * linked list, that has no jumps and starts at the beginning! This function 
   25020             :  * does not extend the memory pool, since we do not delete any memory blocks,
   25021             :  * but delete the valid objects.  
   25022             :  */
   25023             : void
   25024           0 : SgTypeLong::clearMemoryPool( )
   25025             :    {
   25026             :   // printf ("Inside of SgTypeLong::clearMemoryPool() \n");
   25027             : 
   25028           0 :      SgTypeLong* pointer = NULL, *tempPointer = NULL;
   25029           0 :      std::vector < unsigned char* > :: const_iterator block;
   25030           0 :      if ( SgTypeLong::pools.empty() == false )
   25031             :         {
   25032           0 :           block = SgTypeLong::pools.begin() ;
   25033           0 :           SgTypeLong::next_node = (SgTypeLong*) (*block);
   25034             : 
   25035           0 :           while ( block != SgTypeLong::pools.end() )
   25036             :              {
   25037           0 :                pointer = (SgTypeLong*) (*block);
   25038           0 :                if ( tempPointer != NULL )
   25039             :                   {
   25040           0 :                     tempPointer->set_freepointer(pointer);
   25041             :                   }
   25042           0 :                for (unsigned i = 0; i < SgTypeLong::pool_size - 1; ++i)
   25043             :                   {
   25044           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   25045             :                   }
   25046           0 :                 pointer[SgTypeLong::pool_size-1].set_freepointer(NULL);
   25047           0 :                 tempPointer = &(pointer[SgTypeLong::pool_size-1]);
   25048           0 :                 ++block;
   25049             :              }
   25050             :         }
   25051           0 :    }
   25052             : 
   25053           5 : void SgTypeLong::deleteMemoryPool() {
   25054           9 :   for (auto p: SgTypeLong::pools) {
   25055           4 :     ROSE_FREE(p);
   25056             :   }
   25057           5 :   SgTypeLong::next_node = nullptr;
   25058           5 :   SgTypeLong::pools.clear();
   25059           5 : }
   25060             : 
   25061             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   25062             : //                 reading multiple binary files to for a single AST.
   25063             : /////////// new version ////////////////////////////////
   25064             : //############################################################################
   25065             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   25066             : void
   25067           2 : SgTypeLong::extendMemoryPoolForFileIO( )
   25068             :   {
   25069           2 :     size_t blockIndex = SgTypeLong::pools.size();
   25070           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLong) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLong);
   25071             : 
   25072           4 :     while ( (blockIndex * SgTypeLong::pool_size) < newPoolSize)
   25073             :       {
   25074             : #if ROSE_ALLOC_TRACE
   25075             :         if (blockIndex > 0) {
   25076             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLong) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLong) = %" PRIuPTR " SgTypeLong::pool_size = %d \n",
   25077             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLong),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLong),SgTypeLong::pool_size);
   25078             :         }
   25079             : #endif
   25080             : 
   25081           2 :         SgTypeLong * pointer = (SgTypeLong*) ROSE_MALLOC ( SgTypeLong::pool_size * sizeof(SgTypeLong) );
   25082           2 :         assert( pointer != NULL );
   25083             : #if ROSE_ALLOC_MEMSET == 1
   25084             :         memset(pointer, 0x00, SgTypeLong::pool_size * sizeof(SgTypeLong));
   25085             : #elif ROSE_ALLOC_MEMSET == 2
   25086             :         memset(pointer, 0xCC, SgTypeLong::pool_size * sizeof(SgTypeLong));
   25087             : #endif
   25088           2 :         SgTypeLong::pools.push_back( (unsigned char*)(pointer) );
   25089           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeLong::pool_size * sizeof(SgTypeLong), V_SgTypeLong ) );
   25090             : 
   25091           2 :         if ( SgTypeLong::next_node != NULL ) {
   25092           0 :           if ( blockIndex > 0 ) {
   25093           0 :             SgTypeLong * blkptr = (SgTypeLong*)(SgTypeLong::pools[blockIndex-1]);
   25094           0 :             blkptr[ SgTypeLong::pool_size - 1 ].set_freepointer(pointer);
   25095             :           }
   25096             :         } else {
   25097           2 :           SgTypeLong::next_node = pointer;
   25098             :         }
   25099             : 
   25100        4000 :         for (unsigned i = 0; i < SgTypeLong::pool_size-1; ++i)
   25101             :            {
   25102        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   25103             :            }
   25104           2 :         pointer[ SgTypeLong::pool_size -1 ].set_freepointer(NULL);
   25105             : 
   25106           2 :         blockIndex++;
   25107             :       }
   25108           2 :   }
   25109             : 
   25110             : //############################################################################
   25111             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   25112             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   25113             :  * not compressed. However, that stuff is not yet implemented! 
   25114             :  */
   25115             : unsigned long
   25116           0 : SgTypeLong::getNumberOfLastValidPointer()
   25117             :    {
   25118           0 :       SgTypeLong* testPointer = (SgTypeLong*)(SgTypeLong::pools.back());
   25119           0 :       unsigned long localIndex = SgTypeLong::pool_size - 1;
   25120           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   25121             :          {
   25122           0 :            localIndex--;
   25123             :          }
   25124           0 :       return (localIndex + SgTypeLong::pool_size * (SgTypeLong::pools.size()-1));
   25125             :    }
   25126             : 
   25127             : //############################################################################
   25128             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   25129             :  * memory pool and initializes the data member in class SgTypeLongStroageClass
   25130             :  * from its counterpart of SgTypeLong. The return value is just for checking, 
   25131             :  * that the whole StorageClassArray is initialized!
   25132             :  */
   25133             : unsigned long
   25134           2 : SgTypeLong::initializeStorageClassArray( SgTypeLongStorageClass *storageArray )
   25135             :    {
   25136           2 :      unsigned long storageCounter = 0;
   25137           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeLong::pools.begin();
   25138           2 :      SgTypeLong* pointer = NULL;
   25139           4 :      while ( block != SgTypeLong::pools.end() ) {
   25140           2 :           pointer = (SgTypeLong*) (*block);
   25141        4002 :           for ( unsigned i = 0; i < SgTypeLong::pool_size; ++i ) {
   25142        4000 :                if ( pointer->get_freepointer() != NULL ) {
   25143           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   25144           2 :                  storageArray++;
   25145           2 :                  storageCounter++;
   25146             :                }
   25147        4000 :                pointer++;
   25148             :              }
   25149           2 :            block++;
   25150             :         }
   25151           2 :      return storageCounter;
   25152             :    }
   25153             : 
   25154             : /* #line 25155 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   25155             : 
   25156             : 
   25157             : 
   25158             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   25159             : 
   25160             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   25161             : 
   25162             : //############################################################################
   25163             : /* JH (02/02/2006) Constructor of the IR node SgTypeSignedLong that takes its 
   25164             :  * corresponding StorageClass as parameter
   25165             :  */
   25166           2 : SgTypeSignedLong :: SgTypeSignedLong ( const SgTypeSignedLongStorageClass& storageSource )   : SgType (storageSource)
   25167             :    {
   25168             : 
   25169             : 
   25170             : /* #line 25171 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   25171             : 
   25172           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   25173             : 
   25174             : 
   25175             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   25176             : 
   25177             : 
   25178           2 :    }
   25179             : 
   25180             : //############################################################################
   25181             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   25182             :  * within the working AST. 
   25183             :  */
   25184           7 : SgTypeSignedLong * SgTypeSignedLong::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   25185           7 :      SgTypeSignedLong* returnPointer = NULL;
   25186           7 :      if ( globalIndex != 0 )
   25187             :         {
   25188             : 
   25189             : #if FILE_IO_EXTRA_CHECK
   25190           7 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeSignedLong ) ) <= globalIndex ) ;
   25191           7 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedLong + 1 ) ) );
   25192             : #endif
   25193           7 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedLong )  
   25194           7 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeSignedLong );
   25195           7 :           unsigned long positionInPool = localIndex % SgTypeSignedLong::pool_size;
   25196           7 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedLong::pool_size;
   25197             : 
   25198             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   25199             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   25200             : 
   25201           7 :           returnPointer = &( ( (SgTypeSignedLong*)(SgTypeSignedLong::pools[memoryBlock]) ) [positionInPool]) ;
   25202             : 
   25203           7 :           ROSE_ASSERT( returnPointer != NULL ) ;
   25204             :         }
   25205           7 :      return returnPointer ;
   25206             :    }
   25207             : 
   25208             : //############################################################################
   25209             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   25210             :   for the AST with the index astIndex
   25211             : */
   25212           0 : SgTypeSignedLong * SgTypeSignedLong::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   25213           0 :      SgTypeSignedLong* returnPointer = NULL;
   25214           0 :      if ( globalIndex != 0 )
   25215             :         {
   25216             : 
   25217             : #if FILE_IO_EXTRA_CHECK
   25218           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeSignedLong ) ) <= globalIndex ) ;
   25219           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedLong + 1 ) ) );
   25220             : #endif
   25221           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedLong )
   25222           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeSignedLong );
   25223           0 :           unsigned long positionInPool = localIndex % SgTypeSignedLong::pool_size ;
   25224           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedLong::pool_size ;
   25225             : 
   25226             : #if FILE_IO_EXTRA_CHECK
   25227             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   25228             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   25229             : #endif
   25230             : 
   25231           0 :           returnPointer = &( ( (SgTypeSignedLong*)(SgTypeSignedLong::pools[memoryBlock]) ) [positionInPool]) ;
   25232             : 
   25233             : #if FILE_IO_EXTRA_CHECK
   25234           0 :           assert ( returnPointer != NULL ) ;
   25235             : #endif
   25236             :         }
   25237           0 :      return returnPointer ;
   25238             :    }
   25239             : 
   25240             : //############################################################################
   25241             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   25242             :  * pool size! We set for every valid object in the memory pool the freepointer
   25243             :  * to the global index and increase the global index afterwards. For all the 
   25244             :  * invalid objects (means address ranges within the memory pool that were not
   25245             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   25246             :  * distinguish valid from invalid objects! 
   25247             :  */
   25248             : unsigned long
   25249           5 : SgTypeSignedLong::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   25250             :    {
   25251           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   25252           5 :      SgTypeSignedLong* pointer = NULL;
   25253           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   25254           5 :      std::vector < unsigned char* > :: const_iterator block;
   25255           7 :      for ( block = SgTypeSignedLong::pools.begin(); block != SgTypeSignedLong::pools.end() ; ++block )
   25256             :         {
   25257           2 :           pointer = (SgTypeSignedLong*)(*block);
   25258        4002 :           for (unsigned i = 0; i < SgTypeSignedLong::pool_size; ++i )
   25259             :              {
   25260             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   25261             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   25262             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   25263             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   25264             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   25265             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   25266             :             // properly; so this will have to be checked next.
   25267             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   25268             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   25269        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   25270             :                   {
   25271           2 :                     pointer[i].set_freepointer((SgTypeSignedLong*)(globalIndex));
   25272           2 :                     globalIndex++;
   25273             :                   }
   25274             :                else
   25275             :                   {
   25276        3998 :                     pointer[i].set_freepointer(NULL);
   25277             :                   }
   25278             :               }
   25279             :         }
   25280           5 :      return globalIndex;
   25281             :    }
   25282             : 
   25283             : //############################################################################
   25284             : // JH (01/14/2006)
   25285             : void
   25286           5 : SgTypeSignedLong::resetValidFreepointers( )
   25287             :    {
   25288           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   25289           5 :      SgTypeSignedLong* pointer = NULL;
   25290           5 :      std::vector < unsigned char* > :: const_iterator block;
   25291           5 :      SgTypeSignedLong* pointerOfLinkedList = NULL;
   25292           7 :      for ( block = SgTypeSignedLong::pools.begin(); block != SgTypeSignedLong::pools.end() ; ++block )
   25293             :         {
   25294           2 :           pointer = (SgTypeSignedLong*)(*block);
   25295        4002 :           for (unsigned i = 0; i < SgTypeSignedLong::pool_size; ++i )
   25296             :              {
   25297             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   25298             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   25299             :             // memory blocks!.
   25300        4000 :                if ( pointer[i].get_freepointer() != NULL )
   25301             :                   {
   25302           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   25303             :                   }
   25304             :                else
   25305             :                   {
   25306        3998 :                     if ( pointerOfLinkedList == NULL )
   25307             :                        {
   25308           2 :                          SgTypeSignedLong::next_node = &(pointer[i]);
   25309             :                        }
   25310             :                     else
   25311             :                        {
   25312             :                       // printf ("In SgTypeSignedLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   25313        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   25314             :                        }
   25315             :                     pointerOfLinkedList = &(pointer[i]);
   25316             :                   }
   25317             :               }
   25318             :         }
   25319             : 
   25320           5 :      if ( pointerOfLinkedList != NULL )
   25321             :         {
   25322             :        // printf ("In SgTypeSignedLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   25323           2 :           pointerOfLinkedList->set_freepointer(NULL);
   25324             :        // DQ (6/6/2010): Temporary debugging...
   25325             :        //   ROSE_ASSERT(false);
   25326             :         }
   25327             : 
   25328           5 :      return ;
   25329             :    }
   25330             : 
   25331             : //############################################################################
   25332             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   25333             :  * within the memory pool and resets the freepointers, in order to achieve a 
   25334             :  * linked list, that has no jumps and starts at the beginning! This function 
   25335             :  * does not extend the memory pool, since we do not delete any memory blocks,
   25336             :  * but delete the valid objects.  
   25337             :  */
   25338             : void
   25339           0 : SgTypeSignedLong::clearMemoryPool( )
   25340             :    {
   25341             :   // printf ("Inside of SgTypeSignedLong::clearMemoryPool() \n");
   25342             : 
   25343           0 :      SgTypeSignedLong* pointer = NULL, *tempPointer = NULL;
   25344           0 :      std::vector < unsigned char* > :: const_iterator block;
   25345           0 :      if ( SgTypeSignedLong::pools.empty() == false )
   25346             :         {
   25347           0 :           block = SgTypeSignedLong::pools.begin() ;
   25348           0 :           SgTypeSignedLong::next_node = (SgTypeSignedLong*) (*block);
   25349             : 
   25350           0 :           while ( block != SgTypeSignedLong::pools.end() )
   25351             :              {
   25352           0 :                pointer = (SgTypeSignedLong*) (*block);
   25353           0 :                if ( tempPointer != NULL )
   25354             :                   {
   25355           0 :                     tempPointer->set_freepointer(pointer);
   25356             :                   }
   25357           0 :                for (unsigned i = 0; i < SgTypeSignedLong::pool_size - 1; ++i)
   25358             :                   {
   25359           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   25360             :                   }
   25361           0 :                 pointer[SgTypeSignedLong::pool_size-1].set_freepointer(NULL);
   25362           0 :                 tempPointer = &(pointer[SgTypeSignedLong::pool_size-1]);
   25363           0 :                 ++block;
   25364             :              }
   25365             :         }
   25366           0 :    }
   25367             : 
   25368           5 : void SgTypeSignedLong::deleteMemoryPool() {
   25369           9 :   for (auto p: SgTypeSignedLong::pools) {
   25370           4 :     ROSE_FREE(p);
   25371             :   }
   25372           5 :   SgTypeSignedLong::next_node = nullptr;
   25373           5 :   SgTypeSignedLong::pools.clear();
   25374           5 : }
   25375             : 
   25376             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   25377             : //                 reading multiple binary files to for a single AST.
   25378             : /////////// new version ////////////////////////////////
   25379             : //############################################################################
   25380             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   25381             : void
   25382           2 : SgTypeSignedLong::extendMemoryPoolForFileIO( )
   25383             :   {
   25384           2 :     size_t blockIndex = SgTypeSignedLong::pools.size();
   25385           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedLong) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedLong);
   25386             : 
   25387           4 :     while ( (blockIndex * SgTypeSignedLong::pool_size) < newPoolSize)
   25388             :       {
   25389             : #if ROSE_ALLOC_TRACE
   25390             :         if (blockIndex > 0) {
   25391             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedLong) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedLong) = %" PRIuPTR " SgTypeSignedLong::pool_size = %d \n",
   25392             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedLong),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedLong),SgTypeSignedLong::pool_size);
   25393             :         }
   25394             : #endif
   25395             : 
   25396           2 :         SgTypeSignedLong * pointer = (SgTypeSignedLong*) ROSE_MALLOC ( SgTypeSignedLong::pool_size * sizeof(SgTypeSignedLong) );
   25397           2 :         assert( pointer != NULL );
   25398             : #if ROSE_ALLOC_MEMSET == 1
   25399             :         memset(pointer, 0x00, SgTypeSignedLong::pool_size * sizeof(SgTypeSignedLong));
   25400             : #elif ROSE_ALLOC_MEMSET == 2
   25401             :         memset(pointer, 0xCC, SgTypeSignedLong::pool_size * sizeof(SgTypeSignedLong));
   25402             : #endif
   25403           2 :         SgTypeSignedLong::pools.push_back( (unsigned char*)(pointer) );
   25404           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeSignedLong::pool_size * sizeof(SgTypeSignedLong), V_SgTypeSignedLong ) );
   25405             : 
   25406           2 :         if ( SgTypeSignedLong::next_node != NULL ) {
   25407           0 :           if ( blockIndex > 0 ) {
   25408           0 :             SgTypeSignedLong * blkptr = (SgTypeSignedLong*)(SgTypeSignedLong::pools[blockIndex-1]);
   25409           0 :             blkptr[ SgTypeSignedLong::pool_size - 1 ].set_freepointer(pointer);
   25410             :           }
   25411             :         } else {
   25412           2 :           SgTypeSignedLong::next_node = pointer;
   25413             :         }
   25414             : 
   25415        4000 :         for (unsigned i = 0; i < SgTypeSignedLong::pool_size-1; ++i)
   25416             :            {
   25417        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   25418             :            }
   25419           2 :         pointer[ SgTypeSignedLong::pool_size -1 ].set_freepointer(NULL);
   25420             : 
   25421           2 :         blockIndex++;
   25422             :       }
   25423           2 :   }
   25424             : 
   25425             : //############################################################################
   25426             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   25427             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   25428             :  * not compressed. However, that stuff is not yet implemented! 
   25429             :  */
   25430             : unsigned long
   25431           0 : SgTypeSignedLong::getNumberOfLastValidPointer()
   25432             :    {
   25433           0 :       SgTypeSignedLong* testPointer = (SgTypeSignedLong*)(SgTypeSignedLong::pools.back());
   25434           0 :       unsigned long localIndex = SgTypeSignedLong::pool_size - 1;
   25435           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   25436             :          {
   25437           0 :            localIndex--;
   25438             :          }
   25439           0 :       return (localIndex + SgTypeSignedLong::pool_size * (SgTypeSignedLong::pools.size()-1));
   25440             :    }
   25441             : 
   25442             : //############################################################################
   25443             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   25444             :  * memory pool and initializes the data member in class SgTypeSignedLongStroageClass
   25445             :  * from its counterpart of SgTypeSignedLong. The return value is just for checking, 
   25446             :  * that the whole StorageClassArray is initialized!
   25447             :  */
   25448             : unsigned long
   25449           2 : SgTypeSignedLong::initializeStorageClassArray( SgTypeSignedLongStorageClass *storageArray )
   25450             :    {
   25451           2 :      unsigned long storageCounter = 0;
   25452           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeSignedLong::pools.begin();
   25453           2 :      SgTypeSignedLong* pointer = NULL;
   25454           4 :      while ( block != SgTypeSignedLong::pools.end() ) {
   25455           2 :           pointer = (SgTypeSignedLong*) (*block);
   25456        4002 :           for ( unsigned i = 0; i < SgTypeSignedLong::pool_size; ++i ) {
   25457        4000 :                if ( pointer->get_freepointer() != NULL ) {
   25458           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   25459           2 :                  storageArray++;
   25460           2 :                  storageCounter++;
   25461             :                }
   25462        4000 :                pointer++;
   25463             :              }
   25464           2 :            block++;
   25465             :         }
   25466           2 :      return storageCounter;
   25467             :    }
   25468             : 
   25469             : /* #line 25470 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   25470             : 
   25471             : 
   25472             : 
   25473             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   25474             : 
   25475             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   25476             : 
   25477             : //############################################################################
   25478             : /* JH (02/02/2006) Constructor of the IR node SgTypeUnsignedLong that takes its 
   25479             :  * corresponding StorageClass as parameter
   25480             :  */
   25481           2 : SgTypeUnsignedLong :: SgTypeUnsignedLong ( const SgTypeUnsignedLongStorageClass& storageSource )   : SgType (storageSource)
   25482             :    {
   25483             : 
   25484             : 
   25485             : /* #line 25486 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   25486             : 
   25487           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   25488             : 
   25489             : 
   25490             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   25491             : 
   25492             : 
   25493           2 :    }
   25494             : 
   25495             : //############################################################################
   25496             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   25497             :  * within the working AST. 
   25498             :  */
   25499         737 : SgTypeUnsignedLong * SgTypeUnsignedLong::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   25500         737 :      SgTypeUnsignedLong* returnPointer = NULL;
   25501         737 :      if ( globalIndex != 0 )
   25502             :         {
   25503             : 
   25504             : #if FILE_IO_EXTRA_CHECK
   25505         737 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeUnsignedLong ) ) <= globalIndex ) ;
   25506         737 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedLong + 1 ) ) );
   25507             : #endif
   25508         737 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedLong )  
   25509         737 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeUnsignedLong );
   25510         737 :           unsigned long positionInPool = localIndex % SgTypeUnsignedLong::pool_size;
   25511         737 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedLong::pool_size;
   25512             : 
   25513             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   25514             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   25515             : 
   25516         737 :           returnPointer = &( ( (SgTypeUnsignedLong*)(SgTypeUnsignedLong::pools[memoryBlock]) ) [positionInPool]) ;
   25517             : 
   25518         737 :           ROSE_ASSERT( returnPointer != NULL ) ;
   25519             :         }
   25520         737 :      return returnPointer ;
   25521             :    }
   25522             : 
   25523             : //############################################################################
   25524             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   25525             :   for the AST with the index astIndex
   25526             : */
   25527           0 : SgTypeUnsignedLong * SgTypeUnsignedLong::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   25528           0 :      SgTypeUnsignedLong* returnPointer = NULL;
   25529           0 :      if ( globalIndex != 0 )
   25530             :         {
   25531             : 
   25532             : #if FILE_IO_EXTRA_CHECK
   25533           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeUnsignedLong ) ) <= globalIndex ) ;
   25534           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedLong + 1 ) ) );
   25535             : #endif
   25536           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedLong )
   25537           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeUnsignedLong );
   25538           0 :           unsigned long positionInPool = localIndex % SgTypeUnsignedLong::pool_size ;
   25539           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedLong::pool_size ;
   25540             : 
   25541             : #if FILE_IO_EXTRA_CHECK
   25542             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   25543             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   25544             : #endif
   25545             : 
   25546           0 :           returnPointer = &( ( (SgTypeUnsignedLong*)(SgTypeUnsignedLong::pools[memoryBlock]) ) [positionInPool]) ;
   25547             : 
   25548             : #if FILE_IO_EXTRA_CHECK
   25549           0 :           assert ( returnPointer != NULL ) ;
   25550             : #endif
   25551             :         }
   25552           0 :      return returnPointer ;
   25553             :    }
   25554             : 
   25555             : //############################################################################
   25556             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   25557             :  * pool size! We set for every valid object in the memory pool the freepointer
   25558             :  * to the global index and increase the global index afterwards. For all the 
   25559             :  * invalid objects (means address ranges within the memory pool that were not
   25560             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   25561             :  * distinguish valid from invalid objects! 
   25562             :  */
   25563             : unsigned long
   25564           5 : SgTypeUnsignedLong::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   25565             :    {
   25566           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   25567           5 :      SgTypeUnsignedLong* pointer = NULL;
   25568           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   25569           5 :      std::vector < unsigned char* > :: const_iterator block;
   25570           7 :      for ( block = SgTypeUnsignedLong::pools.begin(); block != SgTypeUnsignedLong::pools.end() ; ++block )
   25571             :         {
   25572           2 :           pointer = (SgTypeUnsignedLong*)(*block);
   25573        4002 :           for (unsigned i = 0; i < SgTypeUnsignedLong::pool_size; ++i )
   25574             :              {
   25575             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   25576             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   25577             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   25578             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   25579             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   25580             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   25581             :             // properly; so this will have to be checked next.
   25582             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   25583             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   25584        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   25585             :                   {
   25586           2 :                     pointer[i].set_freepointer((SgTypeUnsignedLong*)(globalIndex));
   25587           2 :                     globalIndex++;
   25588             :                   }
   25589             :                else
   25590             :                   {
   25591        3998 :                     pointer[i].set_freepointer(NULL);
   25592             :                   }
   25593             :               }
   25594             :         }
   25595           5 :      return globalIndex;
   25596             :    }
   25597             : 
   25598             : //############################################################################
   25599             : // JH (01/14/2006)
   25600             : void
   25601           5 : SgTypeUnsignedLong::resetValidFreepointers( )
   25602             :    {
   25603           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   25604           5 :      SgTypeUnsignedLong* pointer = NULL;
   25605           5 :      std::vector < unsigned char* > :: const_iterator block;
   25606           5 :      SgTypeUnsignedLong* pointerOfLinkedList = NULL;
   25607           7 :      for ( block = SgTypeUnsignedLong::pools.begin(); block != SgTypeUnsignedLong::pools.end() ; ++block )
   25608             :         {
   25609           2 :           pointer = (SgTypeUnsignedLong*)(*block);
   25610        4002 :           for (unsigned i = 0; i < SgTypeUnsignedLong::pool_size; ++i )
   25611             :              {
   25612             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   25613             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   25614             :             // memory blocks!.
   25615        4000 :                if ( pointer[i].get_freepointer() != NULL )
   25616             :                   {
   25617           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   25618             :                   }
   25619             :                else
   25620             :                   {
   25621        3998 :                     if ( pointerOfLinkedList == NULL )
   25622             :                        {
   25623           2 :                          SgTypeUnsignedLong::next_node = &(pointer[i]);
   25624             :                        }
   25625             :                     else
   25626             :                        {
   25627             :                       // printf ("In SgTypeUnsignedLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   25628        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   25629             :                        }
   25630             :                     pointerOfLinkedList = &(pointer[i]);
   25631             :                   }
   25632             :               }
   25633             :         }
   25634             : 
   25635           5 :      if ( pointerOfLinkedList != NULL )
   25636             :         {
   25637             :        // printf ("In SgTypeUnsignedLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   25638           2 :           pointerOfLinkedList->set_freepointer(NULL);
   25639             :        // DQ (6/6/2010): Temporary debugging...
   25640             :        //   ROSE_ASSERT(false);
   25641             :         }
   25642             : 
   25643           5 :      return ;
   25644             :    }
   25645             : 
   25646             : //############################################################################
   25647             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   25648             :  * within the memory pool and resets the freepointers, in order to achieve a 
   25649             :  * linked list, that has no jumps and starts at the beginning! This function 
   25650             :  * does not extend the memory pool, since we do not delete any memory blocks,
   25651             :  * but delete the valid objects.  
   25652             :  */
   25653             : void
   25654           0 : SgTypeUnsignedLong::clearMemoryPool( )
   25655             :    {
   25656             :   // printf ("Inside of SgTypeUnsignedLong::clearMemoryPool() \n");
   25657             : 
   25658           0 :      SgTypeUnsignedLong* pointer = NULL, *tempPointer = NULL;
   25659           0 :      std::vector < unsigned char* > :: const_iterator block;
   25660           0 :      if ( SgTypeUnsignedLong::pools.empty() == false )
   25661             :         {
   25662           0 :           block = SgTypeUnsignedLong::pools.begin() ;
   25663           0 :           SgTypeUnsignedLong::next_node = (SgTypeUnsignedLong*) (*block);
   25664             : 
   25665           0 :           while ( block != SgTypeUnsignedLong::pools.end() )
   25666             :              {
   25667           0 :                pointer = (SgTypeUnsignedLong*) (*block);
   25668           0 :                if ( tempPointer != NULL )
   25669             :                   {
   25670           0 :                     tempPointer->set_freepointer(pointer);
   25671             :                   }
   25672           0 :                for (unsigned i = 0; i < SgTypeUnsignedLong::pool_size - 1; ++i)
   25673             :                   {
   25674           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   25675             :                   }
   25676           0 :                 pointer[SgTypeUnsignedLong::pool_size-1].set_freepointer(NULL);
   25677           0 :                 tempPointer = &(pointer[SgTypeUnsignedLong::pool_size-1]);
   25678           0 :                 ++block;
   25679             :              }
   25680             :         }
   25681           0 :    }
   25682             : 
   25683           5 : void SgTypeUnsignedLong::deleteMemoryPool() {
   25684           9 :   for (auto p: SgTypeUnsignedLong::pools) {
   25685           4 :     ROSE_FREE(p);
   25686             :   }
   25687           5 :   SgTypeUnsignedLong::next_node = nullptr;
   25688           5 :   SgTypeUnsignedLong::pools.clear();
   25689           5 : }
   25690             : 
   25691             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   25692             : //                 reading multiple binary files to for a single AST.
   25693             : /////////// new version ////////////////////////////////
   25694             : //############################################################################
   25695             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   25696             : void
   25697           2 : SgTypeUnsignedLong::extendMemoryPoolForFileIO( )
   25698             :   {
   25699           2 :     size_t blockIndex = SgTypeUnsignedLong::pools.size();
   25700           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedLong) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedLong);
   25701             : 
   25702           4 :     while ( (blockIndex * SgTypeUnsignedLong::pool_size) < newPoolSize)
   25703             :       {
   25704             : #if ROSE_ALLOC_TRACE
   25705             :         if (blockIndex > 0) {
   25706             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedLong) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedLong) = %" PRIuPTR " SgTypeUnsignedLong::pool_size = %d \n",
   25707             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedLong),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedLong),SgTypeUnsignedLong::pool_size);
   25708             :         }
   25709             : #endif
   25710             : 
   25711           2 :         SgTypeUnsignedLong * pointer = (SgTypeUnsignedLong*) ROSE_MALLOC ( SgTypeUnsignedLong::pool_size * sizeof(SgTypeUnsignedLong) );
   25712           2 :         assert( pointer != NULL );
   25713             : #if ROSE_ALLOC_MEMSET == 1
   25714             :         memset(pointer, 0x00, SgTypeUnsignedLong::pool_size * sizeof(SgTypeUnsignedLong));
   25715             : #elif ROSE_ALLOC_MEMSET == 2
   25716             :         memset(pointer, 0xCC, SgTypeUnsignedLong::pool_size * sizeof(SgTypeUnsignedLong));
   25717             : #endif
   25718           2 :         SgTypeUnsignedLong::pools.push_back( (unsigned char*)(pointer) );
   25719           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeUnsignedLong::pool_size * sizeof(SgTypeUnsignedLong), V_SgTypeUnsignedLong ) );
   25720             : 
   25721           2 :         if ( SgTypeUnsignedLong::next_node != NULL ) {
   25722           0 :           if ( blockIndex > 0 ) {
   25723           0 :             SgTypeUnsignedLong * blkptr = (SgTypeUnsignedLong*)(SgTypeUnsignedLong::pools[blockIndex-1]);
   25724           0 :             blkptr[ SgTypeUnsignedLong::pool_size - 1 ].set_freepointer(pointer);
   25725             :           }
   25726             :         } else {
   25727           2 :           SgTypeUnsignedLong::next_node = pointer;
   25728             :         }
   25729             : 
   25730        4000 :         for (unsigned i = 0; i < SgTypeUnsignedLong::pool_size-1; ++i)
   25731             :            {
   25732        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   25733             :            }
   25734           2 :         pointer[ SgTypeUnsignedLong::pool_size -1 ].set_freepointer(NULL);
   25735             : 
   25736           2 :         blockIndex++;
   25737             :       }
   25738           2 :   }
   25739             : 
   25740             : //############################################################################
   25741             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   25742             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   25743             :  * not compressed. However, that stuff is not yet implemented! 
   25744             :  */
   25745             : unsigned long
   25746           0 : SgTypeUnsignedLong::getNumberOfLastValidPointer()
   25747             :    {
   25748           0 :       SgTypeUnsignedLong* testPointer = (SgTypeUnsignedLong*)(SgTypeUnsignedLong::pools.back());
   25749           0 :       unsigned long localIndex = SgTypeUnsignedLong::pool_size - 1;
   25750           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   25751             :          {
   25752           0 :            localIndex--;
   25753             :          }
   25754           0 :       return (localIndex + SgTypeUnsignedLong::pool_size * (SgTypeUnsignedLong::pools.size()-1));
   25755             :    }
   25756             : 
   25757             : //############################################################################
   25758             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   25759             :  * memory pool and initializes the data member in class SgTypeUnsignedLongStroageClass
   25760             :  * from its counterpart of SgTypeUnsignedLong. The return value is just for checking, 
   25761             :  * that the whole StorageClassArray is initialized!
   25762             :  */
   25763             : unsigned long
   25764           2 : SgTypeUnsignedLong::initializeStorageClassArray( SgTypeUnsignedLongStorageClass *storageArray )
   25765             :    {
   25766           2 :      unsigned long storageCounter = 0;
   25767           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeUnsignedLong::pools.begin();
   25768           2 :      SgTypeUnsignedLong* pointer = NULL;
   25769           4 :      while ( block != SgTypeUnsignedLong::pools.end() ) {
   25770           2 :           pointer = (SgTypeUnsignedLong*) (*block);
   25771        4002 :           for ( unsigned i = 0; i < SgTypeUnsignedLong::pool_size; ++i ) {
   25772        4000 :                if ( pointer->get_freepointer() != NULL ) {
   25773           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   25774           2 :                  storageArray++;
   25775           2 :                  storageCounter++;
   25776             :                }
   25777        4000 :                pointer++;
   25778             :              }
   25779           2 :            block++;
   25780             :         }
   25781           2 :      return storageCounter;
   25782             :    }
   25783             : 
   25784             : /* #line 25785 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   25785             : 
   25786             : 
   25787             : 
   25788             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   25789             : 
   25790             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   25791             : 
   25792             : //############################################################################
   25793             : /* JH (02/02/2006) Constructor of the IR node SgTypeVoid that takes its 
   25794             :  * corresponding StorageClass as parameter
   25795             :  */
   25796           2 : SgTypeVoid :: SgTypeVoid ( const SgTypeVoidStorageClass& storageSource )   : SgType (storageSource)
   25797             :    {
   25798             : 
   25799             : 
   25800             : /* #line 25801 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   25801             : 
   25802           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   25803             : 
   25804             : 
   25805             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   25806             : 
   25807             : 
   25808           2 :    }
   25809             : 
   25810             : //############################################################################
   25811             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   25812             :  * within the working AST. 
   25813             :  */
   25814        2684 : SgTypeVoid * SgTypeVoid::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   25815        2684 :      SgTypeVoid* returnPointer = NULL;
   25816        2684 :      if ( globalIndex != 0 )
   25817             :         {
   25818             : 
   25819             : #if FILE_IO_EXTRA_CHECK
   25820        2684 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeVoid ) ) <= globalIndex ) ;
   25821        2684 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeVoid + 1 ) ) );
   25822             : #endif
   25823        2684 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeVoid )  
   25824        2684 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeVoid );
   25825        2684 :           unsigned long positionInPool = localIndex % SgTypeVoid::pool_size;
   25826        2684 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeVoid::pool_size;
   25827             : 
   25828             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   25829             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   25830             : 
   25831        2684 :           returnPointer = &( ( (SgTypeVoid*)(SgTypeVoid::pools[memoryBlock]) ) [positionInPool]) ;
   25832             : 
   25833        2684 :           ROSE_ASSERT( returnPointer != NULL ) ;
   25834             :         }
   25835        2684 :      return returnPointer ;
   25836             :    }
   25837             : 
   25838             : //############################################################################
   25839             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   25840             :   for the AST with the index astIndex
   25841             : */
   25842           0 : SgTypeVoid * SgTypeVoid::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   25843           0 :      SgTypeVoid* returnPointer = NULL;
   25844           0 :      if ( globalIndex != 0 )
   25845             :         {
   25846             : 
   25847             : #if FILE_IO_EXTRA_CHECK
   25848           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeVoid ) ) <= globalIndex ) ;
   25849           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeVoid + 1 ) ) );
   25850             : #endif
   25851           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeVoid )
   25852           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeVoid );
   25853           0 :           unsigned long positionInPool = localIndex % SgTypeVoid::pool_size ;
   25854           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeVoid::pool_size ;
   25855             : 
   25856             : #if FILE_IO_EXTRA_CHECK
   25857             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   25858             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   25859             : #endif
   25860             : 
   25861           0 :           returnPointer = &( ( (SgTypeVoid*)(SgTypeVoid::pools[memoryBlock]) ) [positionInPool]) ;
   25862             : 
   25863             : #if FILE_IO_EXTRA_CHECK
   25864           0 :           assert ( returnPointer != NULL ) ;
   25865             : #endif
   25866             :         }
   25867           0 :      return returnPointer ;
   25868             :    }
   25869             : 
   25870             : //############################################################################
   25871             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   25872             :  * pool size! We set for every valid object in the memory pool the freepointer
   25873             :  * to the global index and increase the global index afterwards. For all the 
   25874             :  * invalid objects (means address ranges within the memory pool that were not
   25875             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   25876             :  * distinguish valid from invalid objects! 
   25877             :  */
   25878             : unsigned long
   25879           5 : SgTypeVoid::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   25880             :    {
   25881           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   25882           5 :      SgTypeVoid* pointer = NULL;
   25883           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   25884           5 :      std::vector < unsigned char* > :: const_iterator block;
   25885           8 :      for ( block = SgTypeVoid::pools.begin(); block != SgTypeVoid::pools.end() ; ++block )
   25886             :         {
   25887           3 :           pointer = (SgTypeVoid*)(*block);
   25888        6003 :           for (unsigned i = 0; i < SgTypeVoid::pool_size; ++i )
   25889             :              {
   25890             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   25891             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   25892             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   25893             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   25894             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   25895             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   25896             :             // properly; so this will have to be checked next.
   25897             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   25898             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   25899        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   25900             :                   {
   25901           3 :                     pointer[i].set_freepointer((SgTypeVoid*)(globalIndex));
   25902           3 :                     globalIndex++;
   25903             :                   }
   25904             :                else
   25905             :                   {
   25906        5997 :                     pointer[i].set_freepointer(NULL);
   25907             :                   }
   25908             :               }
   25909             :         }
   25910           5 :      return globalIndex;
   25911             :    }
   25912             : 
   25913             : //############################################################################
   25914             : // JH (01/14/2006)
   25915             : void
   25916           5 : SgTypeVoid::resetValidFreepointers( )
   25917             :    {
   25918           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   25919           5 :      SgTypeVoid* pointer = NULL;
   25920           5 :      std::vector < unsigned char* > :: const_iterator block;
   25921           5 :      SgTypeVoid* pointerOfLinkedList = NULL;
   25922           8 :      for ( block = SgTypeVoid::pools.begin(); block != SgTypeVoid::pools.end() ; ++block )
   25923             :         {
   25924           3 :           pointer = (SgTypeVoid*)(*block);
   25925        6003 :           for (unsigned i = 0; i < SgTypeVoid::pool_size; ++i )
   25926             :              {
   25927             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   25928             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   25929             :             // memory blocks!.
   25930        6000 :                if ( pointer[i].get_freepointer() != NULL )
   25931             :                   {
   25932           3 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   25933             :                   }
   25934             :                else
   25935             :                   {
   25936        5997 :                     if ( pointerOfLinkedList == NULL )
   25937             :                        {
   25938           3 :                          SgTypeVoid::next_node = &(pointer[i]);
   25939             :                        }
   25940             :                     else
   25941             :                        {
   25942             :                       // printf ("In SgTypeVoid::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   25943        5994 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   25944             :                        }
   25945             :                     pointerOfLinkedList = &(pointer[i]);
   25946             :                   }
   25947             :               }
   25948             :         }
   25949             : 
   25950           5 :      if ( pointerOfLinkedList != NULL )
   25951             :         {
   25952             :        // printf ("In SgTypeVoid::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   25953           3 :           pointerOfLinkedList->set_freepointer(NULL);
   25954             :        // DQ (6/6/2010): Temporary debugging...
   25955             :        //   ROSE_ASSERT(false);
   25956             :         }
   25957             : 
   25958           5 :      return ;
   25959             :    }
   25960             : 
   25961             : //############################################################################
   25962             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   25963             :  * within the memory pool and resets the freepointers, in order to achieve a 
   25964             :  * linked list, that has no jumps and starts at the beginning! This function 
   25965             :  * does not extend the memory pool, since we do not delete any memory blocks,
   25966             :  * but delete the valid objects.  
   25967             :  */
   25968             : void
   25969           0 : SgTypeVoid::clearMemoryPool( )
   25970             :    {
   25971             :   // printf ("Inside of SgTypeVoid::clearMemoryPool() \n");
   25972             : 
   25973           0 :      SgTypeVoid* pointer = NULL, *tempPointer = NULL;
   25974           0 :      std::vector < unsigned char* > :: const_iterator block;
   25975           0 :      if ( SgTypeVoid::pools.empty() == false )
   25976             :         {
   25977           0 :           block = SgTypeVoid::pools.begin() ;
   25978           0 :           SgTypeVoid::next_node = (SgTypeVoid*) (*block);
   25979             : 
   25980           0 :           while ( block != SgTypeVoid::pools.end() )
   25981             :              {
   25982           0 :                pointer = (SgTypeVoid*) (*block);
   25983           0 :                if ( tempPointer != NULL )
   25984             :                   {
   25985           0 :                     tempPointer->set_freepointer(pointer);
   25986             :                   }
   25987           0 :                for (unsigned i = 0; i < SgTypeVoid::pool_size - 1; ++i)
   25988             :                   {
   25989           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   25990             :                   }
   25991           0 :                 pointer[SgTypeVoid::pool_size-1].set_freepointer(NULL);
   25992           0 :                 tempPointer = &(pointer[SgTypeVoid::pool_size-1]);
   25993           0 :                 ++block;
   25994             :              }
   25995             :         }
   25996           0 :    }
   25997             : 
   25998           5 : void SgTypeVoid::deleteMemoryPool() {
   25999          10 :   for (auto p: SgTypeVoid::pools) {
   26000           5 :     ROSE_FREE(p);
   26001             :   }
   26002           5 :   SgTypeVoid::next_node = nullptr;
   26003           5 :   SgTypeVoid::pools.clear();
   26004           5 : }
   26005             : 
   26006             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   26007             : //                 reading multiple binary files to for a single AST.
   26008             : /////////// new version ////////////////////////////////
   26009             : //############################################################################
   26010             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   26011             : void
   26012           2 : SgTypeVoid::extendMemoryPoolForFileIO( )
   26013             :   {
   26014           2 :     size_t blockIndex = SgTypeVoid::pools.size();
   26015           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeVoid) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeVoid);
   26016             : 
   26017           4 :     while ( (blockIndex * SgTypeVoid::pool_size) < newPoolSize)
   26018             :       {
   26019             : #if ROSE_ALLOC_TRACE
   26020             :         if (blockIndex > 0) {
   26021             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeVoid) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeVoid) = %" PRIuPTR " SgTypeVoid::pool_size = %d \n",
   26022             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeVoid),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeVoid),SgTypeVoid::pool_size);
   26023             :         }
   26024             : #endif
   26025             : 
   26026           2 :         SgTypeVoid * pointer = (SgTypeVoid*) ROSE_MALLOC ( SgTypeVoid::pool_size * sizeof(SgTypeVoid) );
   26027           2 :         assert( pointer != NULL );
   26028             : #if ROSE_ALLOC_MEMSET == 1
   26029             :         memset(pointer, 0x00, SgTypeVoid::pool_size * sizeof(SgTypeVoid));
   26030             : #elif ROSE_ALLOC_MEMSET == 2
   26031             :         memset(pointer, 0xCC, SgTypeVoid::pool_size * sizeof(SgTypeVoid));
   26032             : #endif
   26033           2 :         SgTypeVoid::pools.push_back( (unsigned char*)(pointer) );
   26034           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeVoid::pool_size * sizeof(SgTypeVoid), V_SgTypeVoid ) );
   26035             : 
   26036           2 :         if ( SgTypeVoid::next_node != NULL ) {
   26037           0 :           if ( blockIndex > 0 ) {
   26038           0 :             SgTypeVoid * blkptr = (SgTypeVoid*)(SgTypeVoid::pools[blockIndex-1]);
   26039           0 :             blkptr[ SgTypeVoid::pool_size - 1 ].set_freepointer(pointer);
   26040             :           }
   26041             :         } else {
   26042           2 :           SgTypeVoid::next_node = pointer;
   26043             :         }
   26044             : 
   26045        4000 :         for (unsigned i = 0; i < SgTypeVoid::pool_size-1; ++i)
   26046             :            {
   26047        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   26048             :            }
   26049           2 :         pointer[ SgTypeVoid::pool_size -1 ].set_freepointer(NULL);
   26050             : 
   26051           2 :         blockIndex++;
   26052             :       }
   26053           2 :   }
   26054             : 
   26055             : //############################################################################
   26056             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   26057             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   26058             :  * not compressed. However, that stuff is not yet implemented! 
   26059             :  */
   26060             : unsigned long
   26061           0 : SgTypeVoid::getNumberOfLastValidPointer()
   26062             :    {
   26063           0 :       SgTypeVoid* testPointer = (SgTypeVoid*)(SgTypeVoid::pools.back());
   26064           0 :       unsigned long localIndex = SgTypeVoid::pool_size - 1;
   26065           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   26066             :          {
   26067           0 :            localIndex--;
   26068             :          }
   26069           0 :       return (localIndex + SgTypeVoid::pool_size * (SgTypeVoid::pools.size()-1));
   26070             :    }
   26071             : 
   26072             : //############################################################################
   26073             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   26074             :  * memory pool and initializes the data member in class SgTypeVoidStroageClass
   26075             :  * from its counterpart of SgTypeVoid. The return value is just for checking, 
   26076             :  * that the whole StorageClassArray is initialized!
   26077             :  */
   26078             : unsigned long
   26079           3 : SgTypeVoid::initializeStorageClassArray( SgTypeVoidStorageClass *storageArray )
   26080             :    {
   26081           3 :      unsigned long storageCounter = 0;
   26082           3 :      std::vector < unsigned char* > :: const_iterator block = SgTypeVoid::pools.begin();
   26083           3 :      SgTypeVoid* pointer = NULL;
   26084           6 :      while ( block != SgTypeVoid::pools.end() ) {
   26085           3 :           pointer = (SgTypeVoid*) (*block);
   26086        6003 :           for ( unsigned i = 0; i < SgTypeVoid::pool_size; ++i ) {
   26087        6000 :                if ( pointer->get_freepointer() != NULL ) {
   26088           3 :                  storageArray->pickOutIRNodeData (pointer) ;
   26089           3 :                  storageArray++;
   26090           3 :                  storageCounter++;
   26091             :                }
   26092        6000 :                pointer++;
   26093             :              }
   26094           3 :            block++;
   26095             :         }
   26096           3 :      return storageCounter;
   26097             :    }
   26098             : 
   26099             : /* #line 26100 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   26100             : 
   26101             : 
   26102             : 
   26103             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   26104             : 
   26105             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   26106             : 
   26107             : //############################################################################
   26108             : /* JH (02/02/2006) Constructor of the IR node SgTypeGlobalVoid that takes its 
   26109             :  * corresponding StorageClass as parameter
   26110             :  */
   26111           0 : SgTypeGlobalVoid :: SgTypeGlobalVoid ( const SgTypeGlobalVoidStorageClass& storageSource )   : SgType (storageSource)
   26112             :    {
   26113             : 
   26114             : 
   26115             : /* #line 26116 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   26116             : 
   26117           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   26118             : 
   26119             : 
   26120             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   26121             : 
   26122             : 
   26123           0 :    }
   26124             : 
   26125             : //############################################################################
   26126             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   26127             :  * within the working AST. 
   26128             :  */
   26129           0 : SgTypeGlobalVoid * SgTypeGlobalVoid::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   26130           0 :      SgTypeGlobalVoid* returnPointer = NULL;
   26131           0 :      if ( globalIndex != 0 )
   26132             :         {
   26133             : 
   26134             : #if FILE_IO_EXTRA_CHECK
   26135           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeGlobalVoid ) ) <= globalIndex ) ;
   26136           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeGlobalVoid + 1 ) ) );
   26137             : #endif
   26138           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeGlobalVoid )  
   26139           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeGlobalVoid );
   26140           0 :           unsigned long positionInPool = localIndex % SgTypeGlobalVoid::pool_size;
   26141           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeGlobalVoid::pool_size;
   26142             : 
   26143             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   26144             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   26145             : 
   26146           0 :           returnPointer = &( ( (SgTypeGlobalVoid*)(SgTypeGlobalVoid::pools[memoryBlock]) ) [positionInPool]) ;
   26147             : 
   26148           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   26149             :         }
   26150           0 :      return returnPointer ;
   26151             :    }
   26152             : 
   26153             : //############################################################################
   26154             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   26155             :   for the AST with the index astIndex
   26156             : */
   26157           0 : SgTypeGlobalVoid * SgTypeGlobalVoid::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   26158           0 :      SgTypeGlobalVoid* returnPointer = NULL;
   26159           0 :      if ( globalIndex != 0 )
   26160             :         {
   26161             : 
   26162             : #if FILE_IO_EXTRA_CHECK
   26163           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeGlobalVoid ) ) <= globalIndex ) ;
   26164           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeGlobalVoid + 1 ) ) );
   26165             : #endif
   26166           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeGlobalVoid )
   26167           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeGlobalVoid );
   26168           0 :           unsigned long positionInPool = localIndex % SgTypeGlobalVoid::pool_size ;
   26169           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeGlobalVoid::pool_size ;
   26170             : 
   26171             : #if FILE_IO_EXTRA_CHECK
   26172             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   26173             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   26174             : #endif
   26175             : 
   26176           0 :           returnPointer = &( ( (SgTypeGlobalVoid*)(SgTypeGlobalVoid::pools[memoryBlock]) ) [positionInPool]) ;
   26177             : 
   26178             : #if FILE_IO_EXTRA_CHECK
   26179           0 :           assert ( returnPointer != NULL ) ;
   26180             : #endif
   26181             :         }
   26182           0 :      return returnPointer ;
   26183             :    }
   26184             : 
   26185             : //############################################################################
   26186             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   26187             :  * pool size! We set for every valid object in the memory pool the freepointer
   26188             :  * to the global index and increase the global index afterwards. For all the 
   26189             :  * invalid objects (means address ranges within the memory pool that were not
   26190             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   26191             :  * distinguish valid from invalid objects! 
   26192             :  */
   26193             : unsigned long
   26194           5 : SgTypeGlobalVoid::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   26195             :    {
   26196           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   26197           5 :      SgTypeGlobalVoid* pointer = NULL;
   26198           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   26199           5 :      std::vector < unsigned char* > :: const_iterator block;
   26200           5 :      for ( block = SgTypeGlobalVoid::pools.begin(); block != SgTypeGlobalVoid::pools.end() ; ++block )
   26201             :         {
   26202           0 :           pointer = (SgTypeGlobalVoid*)(*block);
   26203           0 :           for (unsigned i = 0; i < SgTypeGlobalVoid::pool_size; ++i )
   26204             :              {
   26205             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   26206             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   26207             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   26208             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   26209             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   26210             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   26211             :             // properly; so this will have to be checked next.
   26212             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   26213             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   26214           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   26215             :                   {
   26216           0 :                     pointer[i].set_freepointer((SgTypeGlobalVoid*)(globalIndex));
   26217           0 :                     globalIndex++;
   26218             :                   }
   26219             :                else
   26220             :                   {
   26221           0 :                     pointer[i].set_freepointer(NULL);
   26222             :                   }
   26223             :               }
   26224             :         }
   26225           5 :      return globalIndex;
   26226             :    }
   26227             : 
   26228             : //############################################################################
   26229             : // JH (01/14/2006)
   26230             : void
   26231           5 : SgTypeGlobalVoid::resetValidFreepointers( )
   26232             :    {
   26233           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   26234           5 :      SgTypeGlobalVoid* pointer = NULL;
   26235           5 :      std::vector < unsigned char* > :: const_iterator block;
   26236           5 :      SgTypeGlobalVoid* pointerOfLinkedList = NULL;
   26237           5 :      for ( block = SgTypeGlobalVoid::pools.begin(); block != SgTypeGlobalVoid::pools.end() ; ++block )
   26238             :         {
   26239           0 :           pointer = (SgTypeGlobalVoid*)(*block);
   26240           0 :           for (unsigned i = 0; i < SgTypeGlobalVoid::pool_size; ++i )
   26241             :              {
   26242             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   26243             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   26244             :             // memory blocks!.
   26245           0 :                if ( pointer[i].get_freepointer() != NULL )
   26246             :                   {
   26247           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   26248             :                   }
   26249             :                else
   26250             :                   {
   26251           0 :                     if ( pointerOfLinkedList == NULL )
   26252             :                        {
   26253           0 :                          SgTypeGlobalVoid::next_node = &(pointer[i]);
   26254             :                        }
   26255             :                     else
   26256             :                        {
   26257             :                       // printf ("In SgTypeGlobalVoid::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   26258           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   26259             :                        }
   26260             :                     pointerOfLinkedList = &(pointer[i]);
   26261             :                   }
   26262             :               }
   26263             :         }
   26264             : 
   26265           5 :      if ( pointerOfLinkedList != NULL )
   26266             :         {
   26267             :        // printf ("In SgTypeGlobalVoid::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   26268           0 :           pointerOfLinkedList->set_freepointer(NULL);
   26269             :        // DQ (6/6/2010): Temporary debugging...
   26270             :        //   ROSE_ASSERT(false);
   26271             :         }
   26272             : 
   26273           5 :      return ;
   26274             :    }
   26275             : 
   26276             : //############################################################################
   26277             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   26278             :  * within the memory pool and resets the freepointers, in order to achieve a 
   26279             :  * linked list, that has no jumps and starts at the beginning! This function 
   26280             :  * does not extend the memory pool, since we do not delete any memory blocks,
   26281             :  * but delete the valid objects.  
   26282             :  */
   26283             : void
   26284           0 : SgTypeGlobalVoid::clearMemoryPool( )
   26285             :    {
   26286             :   // printf ("Inside of SgTypeGlobalVoid::clearMemoryPool() \n");
   26287             : 
   26288           0 :      SgTypeGlobalVoid* pointer = NULL, *tempPointer = NULL;
   26289           0 :      std::vector < unsigned char* > :: const_iterator block;
   26290           0 :      if ( SgTypeGlobalVoid::pools.empty() == false )
   26291             :         {
   26292           0 :           block = SgTypeGlobalVoid::pools.begin() ;
   26293           0 :           SgTypeGlobalVoid::next_node = (SgTypeGlobalVoid*) (*block);
   26294             : 
   26295           0 :           while ( block != SgTypeGlobalVoid::pools.end() )
   26296             :              {
   26297           0 :                pointer = (SgTypeGlobalVoid*) (*block);
   26298           0 :                if ( tempPointer != NULL )
   26299             :                   {
   26300           0 :                     tempPointer->set_freepointer(pointer);
   26301             :                   }
   26302           0 :                for (unsigned i = 0; i < SgTypeGlobalVoid::pool_size - 1; ++i)
   26303             :                   {
   26304           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   26305             :                   }
   26306           0 :                 pointer[SgTypeGlobalVoid::pool_size-1].set_freepointer(NULL);
   26307           0 :                 tempPointer = &(pointer[SgTypeGlobalVoid::pool_size-1]);
   26308           0 :                 ++block;
   26309             :              }
   26310             :         }
   26311           0 :    }
   26312             : 
   26313           5 : void SgTypeGlobalVoid::deleteMemoryPool() {
   26314           5 :   for (auto p: SgTypeGlobalVoid::pools) {
   26315           0 :     ROSE_FREE(p);
   26316             :   }
   26317           5 :   SgTypeGlobalVoid::next_node = nullptr;
   26318           5 :   SgTypeGlobalVoid::pools.clear();
   26319           5 : }
   26320             : 
   26321             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   26322             : //                 reading multiple binary files to for a single AST.
   26323             : /////////// new version ////////////////////////////////
   26324             : //############################################################################
   26325             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   26326             : void
   26327           2 : SgTypeGlobalVoid::extendMemoryPoolForFileIO( )
   26328             :   {
   26329           2 :     size_t blockIndex = SgTypeGlobalVoid::pools.size();
   26330           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeGlobalVoid) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeGlobalVoid);
   26331             : 
   26332           2 :     while ( (blockIndex * SgTypeGlobalVoid::pool_size) < newPoolSize)
   26333             :       {
   26334             : #if ROSE_ALLOC_TRACE
   26335             :         if (blockIndex > 0) {
   26336             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeGlobalVoid) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeGlobalVoid) = %" PRIuPTR " SgTypeGlobalVoid::pool_size = %d \n",
   26337             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeGlobalVoid),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeGlobalVoid),SgTypeGlobalVoid::pool_size);
   26338             :         }
   26339             : #endif
   26340             : 
   26341           0 :         SgTypeGlobalVoid * pointer = (SgTypeGlobalVoid*) ROSE_MALLOC ( SgTypeGlobalVoid::pool_size * sizeof(SgTypeGlobalVoid) );
   26342           0 :         assert( pointer != NULL );
   26343             : #if ROSE_ALLOC_MEMSET == 1
   26344             :         memset(pointer, 0x00, SgTypeGlobalVoid::pool_size * sizeof(SgTypeGlobalVoid));
   26345             : #elif ROSE_ALLOC_MEMSET == 2
   26346             :         memset(pointer, 0xCC, SgTypeGlobalVoid::pool_size * sizeof(SgTypeGlobalVoid));
   26347             : #endif
   26348           0 :         SgTypeGlobalVoid::pools.push_back( (unsigned char*)(pointer) );
   26349           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeGlobalVoid::pool_size * sizeof(SgTypeGlobalVoid), V_SgTypeGlobalVoid ) );
   26350             : 
   26351           0 :         if ( SgTypeGlobalVoid::next_node != NULL ) {
   26352           0 :           if ( blockIndex > 0 ) {
   26353           0 :             SgTypeGlobalVoid * blkptr = (SgTypeGlobalVoid*)(SgTypeGlobalVoid::pools[blockIndex-1]);
   26354           0 :             blkptr[ SgTypeGlobalVoid::pool_size - 1 ].set_freepointer(pointer);
   26355             :           }
   26356             :         } else {
   26357           0 :           SgTypeGlobalVoid::next_node = pointer;
   26358             :         }
   26359             : 
   26360           0 :         for (unsigned i = 0; i < SgTypeGlobalVoid::pool_size-1; ++i)
   26361             :            {
   26362           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   26363             :            }
   26364           0 :         pointer[ SgTypeGlobalVoid::pool_size -1 ].set_freepointer(NULL);
   26365             : 
   26366           0 :         blockIndex++;
   26367             :       }
   26368           2 :   }
   26369             : 
   26370             : //############################################################################
   26371             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   26372             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   26373             :  * not compressed. However, that stuff is not yet implemented! 
   26374             :  */
   26375             : unsigned long
   26376           0 : SgTypeGlobalVoid::getNumberOfLastValidPointer()
   26377             :    {
   26378           0 :       SgTypeGlobalVoid* testPointer = (SgTypeGlobalVoid*)(SgTypeGlobalVoid::pools.back());
   26379           0 :       unsigned long localIndex = SgTypeGlobalVoid::pool_size - 1;
   26380           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   26381             :          {
   26382           0 :            localIndex--;
   26383             :          }
   26384           0 :       return (localIndex + SgTypeGlobalVoid::pool_size * (SgTypeGlobalVoid::pools.size()-1));
   26385             :    }
   26386             : 
   26387             : //############################################################################
   26388             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   26389             :  * memory pool and initializes the data member in class SgTypeGlobalVoidStroageClass
   26390             :  * from its counterpart of SgTypeGlobalVoid. The return value is just for checking, 
   26391             :  * that the whole StorageClassArray is initialized!
   26392             :  */
   26393             : unsigned long
   26394           0 : SgTypeGlobalVoid::initializeStorageClassArray( SgTypeGlobalVoidStorageClass *storageArray )
   26395             :    {
   26396           0 :      unsigned long storageCounter = 0;
   26397           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeGlobalVoid::pools.begin();
   26398           0 :      SgTypeGlobalVoid* pointer = NULL;
   26399           0 :      while ( block != SgTypeGlobalVoid::pools.end() ) {
   26400           0 :           pointer = (SgTypeGlobalVoid*) (*block);
   26401           0 :           for ( unsigned i = 0; i < SgTypeGlobalVoid::pool_size; ++i ) {
   26402           0 :                if ( pointer->get_freepointer() != NULL ) {
   26403           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   26404           0 :                  storageArray++;
   26405           0 :                  storageCounter++;
   26406             :                }
   26407           0 :                pointer++;
   26408             :              }
   26409           0 :            block++;
   26410             :         }
   26411           0 :      return storageCounter;
   26412             :    }
   26413             : 
   26414             : /* #line 26415 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   26415             : 
   26416             : 
   26417             : 
   26418             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   26419             : 
   26420             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   26421             : 
   26422             : //############################################################################
   26423             : /* JH (02/02/2006) Constructor of the IR node SgTypeWchar that takes its 
   26424             :  * corresponding StorageClass as parameter
   26425             :  */
   26426           1 : SgTypeWchar :: SgTypeWchar ( const SgTypeWcharStorageClass& storageSource )   : SgType (storageSource)
   26427             :    {
   26428             : 
   26429             : 
   26430             : /* #line 26431 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   26431             : 
   26432           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   26433             : 
   26434             : 
   26435             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   26436             : 
   26437             : 
   26438           1 :    }
   26439             : 
   26440             : //############################################################################
   26441             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   26442             :  * within the working AST. 
   26443             :  */
   26444         312 : SgTypeWchar * SgTypeWchar::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   26445         312 :      SgTypeWchar* returnPointer = NULL;
   26446         312 :      if ( globalIndex != 0 )
   26447             :         {
   26448             : 
   26449             : #if FILE_IO_EXTRA_CHECK
   26450         312 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeWchar ) ) <= globalIndex ) ;
   26451         312 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeWchar + 1 ) ) );
   26452             : #endif
   26453         312 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeWchar )  
   26454         312 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeWchar );
   26455         312 :           unsigned long positionInPool = localIndex % SgTypeWchar::pool_size;
   26456         312 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeWchar::pool_size;
   26457             : 
   26458             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   26459             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   26460             : 
   26461         312 :           returnPointer = &( ( (SgTypeWchar*)(SgTypeWchar::pools[memoryBlock]) ) [positionInPool]) ;
   26462             : 
   26463         312 :           ROSE_ASSERT( returnPointer != NULL ) ;
   26464             :         }
   26465         312 :      return returnPointer ;
   26466             :    }
   26467             : 
   26468             : //############################################################################
   26469             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   26470             :   for the AST with the index astIndex
   26471             : */
   26472           0 : SgTypeWchar * SgTypeWchar::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   26473           0 :      SgTypeWchar* returnPointer = NULL;
   26474           0 :      if ( globalIndex != 0 )
   26475             :         {
   26476             : 
   26477             : #if FILE_IO_EXTRA_CHECK
   26478           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeWchar ) ) <= globalIndex ) ;
   26479           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeWchar + 1 ) ) );
   26480             : #endif
   26481           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeWchar )
   26482           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeWchar );
   26483           0 :           unsigned long positionInPool = localIndex % SgTypeWchar::pool_size ;
   26484           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeWchar::pool_size ;
   26485             : 
   26486             : #if FILE_IO_EXTRA_CHECK
   26487             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   26488             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   26489             : #endif
   26490             : 
   26491           0 :           returnPointer = &( ( (SgTypeWchar*)(SgTypeWchar::pools[memoryBlock]) ) [positionInPool]) ;
   26492             : 
   26493             : #if FILE_IO_EXTRA_CHECK
   26494           0 :           assert ( returnPointer != NULL ) ;
   26495             : #endif
   26496             :         }
   26497           0 :      return returnPointer ;
   26498             :    }
   26499             : 
   26500             : //############################################################################
   26501             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   26502             :  * pool size! We set for every valid object in the memory pool the freepointer
   26503             :  * to the global index and increase the global index afterwards. For all the 
   26504             :  * invalid objects (means address ranges within the memory pool that were not
   26505             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   26506             :  * distinguish valid from invalid objects! 
   26507             :  */
   26508             : unsigned long
   26509           5 : SgTypeWchar::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   26510             :    {
   26511           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   26512           5 :      SgTypeWchar* pointer = NULL;
   26513           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   26514           5 :      std::vector < unsigned char* > :: const_iterator block;
   26515           6 :      for ( block = SgTypeWchar::pools.begin(); block != SgTypeWchar::pools.end() ; ++block )
   26516             :         {
   26517           1 :           pointer = (SgTypeWchar*)(*block);
   26518        2001 :           for (unsigned i = 0; i < SgTypeWchar::pool_size; ++i )
   26519             :              {
   26520             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   26521             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   26522             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   26523             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   26524             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   26525             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   26526             :             // properly; so this will have to be checked next.
   26527             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   26528             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   26529        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   26530             :                   {
   26531           1 :                     pointer[i].set_freepointer((SgTypeWchar*)(globalIndex));
   26532           1 :                     globalIndex++;
   26533             :                   }
   26534             :                else
   26535             :                   {
   26536        1999 :                     pointer[i].set_freepointer(NULL);
   26537             :                   }
   26538             :               }
   26539             :         }
   26540           5 :      return globalIndex;
   26541             :    }
   26542             : 
   26543             : //############################################################################
   26544             : // JH (01/14/2006)
   26545             : void
   26546           5 : SgTypeWchar::resetValidFreepointers( )
   26547             :    {
   26548           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   26549           5 :      SgTypeWchar* pointer = NULL;
   26550           5 :      std::vector < unsigned char* > :: const_iterator block;
   26551           5 :      SgTypeWchar* pointerOfLinkedList = NULL;
   26552           6 :      for ( block = SgTypeWchar::pools.begin(); block != SgTypeWchar::pools.end() ; ++block )
   26553             :         {
   26554           1 :           pointer = (SgTypeWchar*)(*block);
   26555        2001 :           for (unsigned i = 0; i < SgTypeWchar::pool_size; ++i )
   26556             :              {
   26557             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   26558             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   26559             :             // memory blocks!.
   26560        2000 :                if ( pointer[i].get_freepointer() != NULL )
   26561             :                   {
   26562           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   26563             :                   }
   26564             :                else
   26565             :                   {
   26566        1999 :                     if ( pointerOfLinkedList == NULL )
   26567             :                        {
   26568           1 :                          SgTypeWchar::next_node = &(pointer[i]);
   26569             :                        }
   26570             :                     else
   26571             :                        {
   26572             :                       // printf ("In SgTypeWchar::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   26573        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   26574             :                        }
   26575             :                     pointerOfLinkedList = &(pointer[i]);
   26576             :                   }
   26577             :               }
   26578             :         }
   26579             : 
   26580           5 :      if ( pointerOfLinkedList != NULL )
   26581             :         {
   26582             :        // printf ("In SgTypeWchar::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   26583           1 :           pointerOfLinkedList->set_freepointer(NULL);
   26584             :        // DQ (6/6/2010): Temporary debugging...
   26585             :        //   ROSE_ASSERT(false);
   26586             :         }
   26587             : 
   26588           5 :      return ;
   26589             :    }
   26590             : 
   26591             : //############################################################################
   26592             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   26593             :  * within the memory pool and resets the freepointers, in order to achieve a 
   26594             :  * linked list, that has no jumps and starts at the beginning! This function 
   26595             :  * does not extend the memory pool, since we do not delete any memory blocks,
   26596             :  * but delete the valid objects.  
   26597             :  */
   26598             : void
   26599           0 : SgTypeWchar::clearMemoryPool( )
   26600             :    {
   26601             :   // printf ("Inside of SgTypeWchar::clearMemoryPool() \n");
   26602             : 
   26603           0 :      SgTypeWchar* pointer = NULL, *tempPointer = NULL;
   26604           0 :      std::vector < unsigned char* > :: const_iterator block;
   26605           0 :      if ( SgTypeWchar::pools.empty() == false )
   26606             :         {
   26607           0 :           block = SgTypeWchar::pools.begin() ;
   26608           0 :           SgTypeWchar::next_node = (SgTypeWchar*) (*block);
   26609             : 
   26610           0 :           while ( block != SgTypeWchar::pools.end() )
   26611             :              {
   26612           0 :                pointer = (SgTypeWchar*) (*block);
   26613           0 :                if ( tempPointer != NULL )
   26614             :                   {
   26615           0 :                     tempPointer->set_freepointer(pointer);
   26616             :                   }
   26617           0 :                for (unsigned i = 0; i < SgTypeWchar::pool_size - 1; ++i)
   26618             :                   {
   26619           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   26620             :                   }
   26621           0 :                 pointer[SgTypeWchar::pool_size-1].set_freepointer(NULL);
   26622           0 :                 tempPointer = &(pointer[SgTypeWchar::pool_size-1]);
   26623           0 :                 ++block;
   26624             :              }
   26625             :         }
   26626           0 :    }
   26627             : 
   26628           5 : void SgTypeWchar::deleteMemoryPool() {
   26629           7 :   for (auto p: SgTypeWchar::pools) {
   26630           2 :     ROSE_FREE(p);
   26631             :   }
   26632           5 :   SgTypeWchar::next_node = nullptr;
   26633           5 :   SgTypeWchar::pools.clear();
   26634           5 : }
   26635             : 
   26636             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   26637             : //                 reading multiple binary files to for a single AST.
   26638             : /////////// new version ////////////////////////////////
   26639             : //############################################################################
   26640             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   26641             : void
   26642           2 : SgTypeWchar::extendMemoryPoolForFileIO( )
   26643             :   {
   26644           2 :     size_t blockIndex = SgTypeWchar::pools.size();
   26645           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeWchar) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeWchar);
   26646             : 
   26647           3 :     while ( (blockIndex * SgTypeWchar::pool_size) < newPoolSize)
   26648             :       {
   26649             : #if ROSE_ALLOC_TRACE
   26650             :         if (blockIndex > 0) {
   26651             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeWchar) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeWchar) = %" PRIuPTR " SgTypeWchar::pool_size = %d \n",
   26652             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeWchar),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeWchar),SgTypeWchar::pool_size);
   26653             :         }
   26654             : #endif
   26655             : 
   26656           1 :         SgTypeWchar * pointer = (SgTypeWchar*) ROSE_MALLOC ( SgTypeWchar::pool_size * sizeof(SgTypeWchar) );
   26657           1 :         assert( pointer != NULL );
   26658             : #if ROSE_ALLOC_MEMSET == 1
   26659             :         memset(pointer, 0x00, SgTypeWchar::pool_size * sizeof(SgTypeWchar));
   26660             : #elif ROSE_ALLOC_MEMSET == 2
   26661             :         memset(pointer, 0xCC, SgTypeWchar::pool_size * sizeof(SgTypeWchar));
   26662             : #endif
   26663           1 :         SgTypeWchar::pools.push_back( (unsigned char*)(pointer) );
   26664           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeWchar::pool_size * sizeof(SgTypeWchar), V_SgTypeWchar ) );
   26665             : 
   26666           1 :         if ( SgTypeWchar::next_node != NULL ) {
   26667           0 :           if ( blockIndex > 0 ) {
   26668           0 :             SgTypeWchar * blkptr = (SgTypeWchar*)(SgTypeWchar::pools[blockIndex-1]);
   26669           0 :             blkptr[ SgTypeWchar::pool_size - 1 ].set_freepointer(pointer);
   26670             :           }
   26671             :         } else {
   26672           1 :           SgTypeWchar::next_node = pointer;
   26673             :         }
   26674             : 
   26675        2000 :         for (unsigned i = 0; i < SgTypeWchar::pool_size-1; ++i)
   26676             :            {
   26677        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   26678             :            }
   26679           1 :         pointer[ SgTypeWchar::pool_size -1 ].set_freepointer(NULL);
   26680             : 
   26681           1 :         blockIndex++;
   26682             :       }
   26683           2 :   }
   26684             : 
   26685             : //############################################################################
   26686             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   26687             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   26688             :  * not compressed. However, that stuff is not yet implemented! 
   26689             :  */
   26690             : unsigned long
   26691           0 : SgTypeWchar::getNumberOfLastValidPointer()
   26692             :    {
   26693           0 :       SgTypeWchar* testPointer = (SgTypeWchar*)(SgTypeWchar::pools.back());
   26694           0 :       unsigned long localIndex = SgTypeWchar::pool_size - 1;
   26695           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   26696             :          {
   26697           0 :            localIndex--;
   26698             :          }
   26699           0 :       return (localIndex + SgTypeWchar::pool_size * (SgTypeWchar::pools.size()-1));
   26700             :    }
   26701             : 
   26702             : //############################################################################
   26703             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   26704             :  * memory pool and initializes the data member in class SgTypeWcharStroageClass
   26705             :  * from its counterpart of SgTypeWchar. The return value is just for checking, 
   26706             :  * that the whole StorageClassArray is initialized!
   26707             :  */
   26708             : unsigned long
   26709           1 : SgTypeWchar::initializeStorageClassArray( SgTypeWcharStorageClass *storageArray )
   26710             :    {
   26711           1 :      unsigned long storageCounter = 0;
   26712           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeWchar::pools.begin();
   26713           1 :      SgTypeWchar* pointer = NULL;
   26714           2 :      while ( block != SgTypeWchar::pools.end() ) {
   26715           1 :           pointer = (SgTypeWchar*) (*block);
   26716        2001 :           for ( unsigned i = 0; i < SgTypeWchar::pool_size; ++i ) {
   26717        2000 :                if ( pointer->get_freepointer() != NULL ) {
   26718           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   26719           1 :                  storageArray++;
   26720           1 :                  storageCounter++;
   26721             :                }
   26722        2000 :                pointer++;
   26723             :              }
   26724           1 :            block++;
   26725             :         }
   26726           1 :      return storageCounter;
   26727             :    }
   26728             : 
   26729             : /* #line 26730 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   26730             : 
   26731             : 
   26732             : 
   26733             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   26734             : 
   26735             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   26736             : 
   26737             : //############################################################################
   26738             : /* JH (02/02/2006) Constructor of the IR node SgTypeFloat that takes its 
   26739             :  * corresponding StorageClass as parameter
   26740             :  */
   26741           2 : SgTypeFloat :: SgTypeFloat ( const SgTypeFloatStorageClass& storageSource )   : SgType (storageSource)
   26742             :    {
   26743             : 
   26744             : 
   26745             : /* #line 26746 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   26746             : 
   26747           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   26748             : 
   26749             : 
   26750             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   26751             : 
   26752             : 
   26753           2 :    }
   26754             : 
   26755             : //############################################################################
   26756             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   26757             :  * within the working AST. 
   26758             :  */
   26759         486 : SgTypeFloat * SgTypeFloat::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   26760         486 :      SgTypeFloat* returnPointer = NULL;
   26761         486 :      if ( globalIndex != 0 )
   26762             :         {
   26763             : 
   26764             : #if FILE_IO_EXTRA_CHECK
   26765         486 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeFloat ) ) <= globalIndex ) ;
   26766         486 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeFloat + 1 ) ) );
   26767             : #endif
   26768         486 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeFloat )  
   26769         486 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeFloat );
   26770         486 :           unsigned long positionInPool = localIndex % SgTypeFloat::pool_size;
   26771         486 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeFloat::pool_size;
   26772             : 
   26773             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   26774             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   26775             : 
   26776         486 :           returnPointer = &( ( (SgTypeFloat*)(SgTypeFloat::pools[memoryBlock]) ) [positionInPool]) ;
   26777             : 
   26778         486 :           ROSE_ASSERT( returnPointer != NULL ) ;
   26779             :         }
   26780         486 :      return returnPointer ;
   26781             :    }
   26782             : 
   26783             : //############################################################################
   26784             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   26785             :   for the AST with the index astIndex
   26786             : */
   26787           0 : SgTypeFloat * SgTypeFloat::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   26788           0 :      SgTypeFloat* returnPointer = NULL;
   26789           0 :      if ( globalIndex != 0 )
   26790             :         {
   26791             : 
   26792             : #if FILE_IO_EXTRA_CHECK
   26793           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeFloat ) ) <= globalIndex ) ;
   26794           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeFloat + 1 ) ) );
   26795             : #endif
   26796           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeFloat )
   26797           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeFloat );
   26798           0 :           unsigned long positionInPool = localIndex % SgTypeFloat::pool_size ;
   26799           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeFloat::pool_size ;
   26800             : 
   26801             : #if FILE_IO_EXTRA_CHECK
   26802             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   26803             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   26804             : #endif
   26805             : 
   26806           0 :           returnPointer = &( ( (SgTypeFloat*)(SgTypeFloat::pools[memoryBlock]) ) [positionInPool]) ;
   26807             : 
   26808             : #if FILE_IO_EXTRA_CHECK
   26809           0 :           assert ( returnPointer != NULL ) ;
   26810             : #endif
   26811             :         }
   26812           0 :      return returnPointer ;
   26813             :    }
   26814             : 
   26815             : //############################################################################
   26816             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   26817             :  * pool size! We set for every valid object in the memory pool the freepointer
   26818             :  * to the global index and increase the global index afterwards. For all the 
   26819             :  * invalid objects (means address ranges within the memory pool that were not
   26820             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   26821             :  * distinguish valid from invalid objects! 
   26822             :  */
   26823             : unsigned long
   26824           5 : SgTypeFloat::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   26825             :    {
   26826           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   26827           5 :      SgTypeFloat* pointer = NULL;
   26828           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   26829           5 :      std::vector < unsigned char* > :: const_iterator block;
   26830           7 :      for ( block = SgTypeFloat::pools.begin(); block != SgTypeFloat::pools.end() ; ++block )
   26831             :         {
   26832           2 :           pointer = (SgTypeFloat*)(*block);
   26833        4002 :           for (unsigned i = 0; i < SgTypeFloat::pool_size; ++i )
   26834             :              {
   26835             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   26836             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   26837             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   26838             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   26839             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   26840             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   26841             :             // properly; so this will have to be checked next.
   26842             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   26843             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   26844        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   26845             :                   {
   26846           2 :                     pointer[i].set_freepointer((SgTypeFloat*)(globalIndex));
   26847           2 :                     globalIndex++;
   26848             :                   }
   26849             :                else
   26850             :                   {
   26851        3998 :                     pointer[i].set_freepointer(NULL);
   26852             :                   }
   26853             :               }
   26854             :         }
   26855           5 :      return globalIndex;
   26856             :    }
   26857             : 
   26858             : //############################################################################
   26859             : // JH (01/14/2006)
   26860             : void
   26861           5 : SgTypeFloat::resetValidFreepointers( )
   26862             :    {
   26863           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   26864           5 :      SgTypeFloat* pointer = NULL;
   26865           5 :      std::vector < unsigned char* > :: const_iterator block;
   26866           5 :      SgTypeFloat* pointerOfLinkedList = NULL;
   26867           7 :      for ( block = SgTypeFloat::pools.begin(); block != SgTypeFloat::pools.end() ; ++block )
   26868             :         {
   26869           2 :           pointer = (SgTypeFloat*)(*block);
   26870        4002 :           for (unsigned i = 0; i < SgTypeFloat::pool_size; ++i )
   26871             :              {
   26872             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   26873             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   26874             :             // memory blocks!.
   26875        4000 :                if ( pointer[i].get_freepointer() != NULL )
   26876             :                   {
   26877           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   26878             :                   }
   26879             :                else
   26880             :                   {
   26881        3998 :                     if ( pointerOfLinkedList == NULL )
   26882             :                        {
   26883           2 :                          SgTypeFloat::next_node = &(pointer[i]);
   26884             :                        }
   26885             :                     else
   26886             :                        {
   26887             :                       // printf ("In SgTypeFloat::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   26888        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   26889             :                        }
   26890             :                     pointerOfLinkedList = &(pointer[i]);
   26891             :                   }
   26892             :               }
   26893             :         }
   26894             : 
   26895           5 :      if ( pointerOfLinkedList != NULL )
   26896             :         {
   26897             :        // printf ("In SgTypeFloat::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   26898           2 :           pointerOfLinkedList->set_freepointer(NULL);
   26899             :        // DQ (6/6/2010): Temporary debugging...
   26900             :        //   ROSE_ASSERT(false);
   26901             :         }
   26902             : 
   26903           5 :      return ;
   26904             :    }
   26905             : 
   26906             : //############################################################################
   26907             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   26908             :  * within the memory pool and resets the freepointers, in order to achieve a 
   26909             :  * linked list, that has no jumps and starts at the beginning! This function 
   26910             :  * does not extend the memory pool, since we do not delete any memory blocks,
   26911             :  * but delete the valid objects.  
   26912             :  */
   26913             : void
   26914           0 : SgTypeFloat::clearMemoryPool( )
   26915             :    {
   26916             :   // printf ("Inside of SgTypeFloat::clearMemoryPool() \n");
   26917             : 
   26918           0 :      SgTypeFloat* pointer = NULL, *tempPointer = NULL;
   26919           0 :      std::vector < unsigned char* > :: const_iterator block;
   26920           0 :      if ( SgTypeFloat::pools.empty() == false )
   26921             :         {
   26922           0 :           block = SgTypeFloat::pools.begin() ;
   26923           0 :           SgTypeFloat::next_node = (SgTypeFloat*) (*block);
   26924             : 
   26925           0 :           while ( block != SgTypeFloat::pools.end() )
   26926             :              {
   26927           0 :                pointer = (SgTypeFloat*) (*block);
   26928           0 :                if ( tempPointer != NULL )
   26929             :                   {
   26930           0 :                     tempPointer->set_freepointer(pointer);
   26931             :                   }
   26932           0 :                for (unsigned i = 0; i < SgTypeFloat::pool_size - 1; ++i)
   26933             :                   {
   26934           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   26935             :                   }
   26936           0 :                 pointer[SgTypeFloat::pool_size-1].set_freepointer(NULL);
   26937           0 :                 tempPointer = &(pointer[SgTypeFloat::pool_size-1]);
   26938           0 :                 ++block;
   26939             :              }
   26940             :         }
   26941           0 :    }
   26942             : 
   26943           5 : void SgTypeFloat::deleteMemoryPool() {
   26944           9 :   for (auto p: SgTypeFloat::pools) {
   26945           4 :     ROSE_FREE(p);
   26946             :   }
   26947           5 :   SgTypeFloat::next_node = nullptr;
   26948           5 :   SgTypeFloat::pools.clear();
   26949           5 : }
   26950             : 
   26951             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   26952             : //                 reading multiple binary files to for a single AST.
   26953             : /////////// new version ////////////////////////////////
   26954             : //############################################################################
   26955             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   26956             : void
   26957           2 : SgTypeFloat::extendMemoryPoolForFileIO( )
   26958             :   {
   26959           2 :     size_t blockIndex = SgTypeFloat::pools.size();
   26960           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat);
   26961             : 
   26962           4 :     while ( (blockIndex * SgTypeFloat::pool_size) < newPoolSize)
   26963             :       {
   26964             : #if ROSE_ALLOC_TRACE
   26965             :         if (blockIndex > 0) {
   26966             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat) = %" PRIuPTR " SgTypeFloat::pool_size = %d \n",
   26967             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat),SgTypeFloat::pool_size);
   26968             :         }
   26969             : #endif
   26970             : 
   26971           2 :         SgTypeFloat * pointer = (SgTypeFloat*) ROSE_MALLOC ( SgTypeFloat::pool_size * sizeof(SgTypeFloat) );
   26972           2 :         assert( pointer != NULL );
   26973             : #if ROSE_ALLOC_MEMSET == 1
   26974             :         memset(pointer, 0x00, SgTypeFloat::pool_size * sizeof(SgTypeFloat));
   26975             : #elif ROSE_ALLOC_MEMSET == 2
   26976             :         memset(pointer, 0xCC, SgTypeFloat::pool_size * sizeof(SgTypeFloat));
   26977             : #endif
   26978           2 :         SgTypeFloat::pools.push_back( (unsigned char*)(pointer) );
   26979           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeFloat::pool_size * sizeof(SgTypeFloat), V_SgTypeFloat ) );
   26980             : 
   26981           2 :         if ( SgTypeFloat::next_node != NULL ) {
   26982           0 :           if ( blockIndex > 0 ) {
   26983           0 :             SgTypeFloat * blkptr = (SgTypeFloat*)(SgTypeFloat::pools[blockIndex-1]);
   26984           0 :             blkptr[ SgTypeFloat::pool_size - 1 ].set_freepointer(pointer);
   26985             :           }
   26986             :         } else {
   26987           2 :           SgTypeFloat::next_node = pointer;
   26988             :         }
   26989             : 
   26990        4000 :         for (unsigned i = 0; i < SgTypeFloat::pool_size-1; ++i)
   26991             :            {
   26992        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   26993             :            }
   26994           2 :         pointer[ SgTypeFloat::pool_size -1 ].set_freepointer(NULL);
   26995             : 
   26996           2 :         blockIndex++;
   26997             :       }
   26998           2 :   }
   26999             : 
   27000             : //############################################################################
   27001             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   27002             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   27003             :  * not compressed. However, that stuff is not yet implemented! 
   27004             :  */
   27005             : unsigned long
   27006           0 : SgTypeFloat::getNumberOfLastValidPointer()
   27007             :    {
   27008           0 :       SgTypeFloat* testPointer = (SgTypeFloat*)(SgTypeFloat::pools.back());
   27009           0 :       unsigned long localIndex = SgTypeFloat::pool_size - 1;
   27010           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   27011             :          {
   27012           0 :            localIndex--;
   27013             :          }
   27014           0 :       return (localIndex + SgTypeFloat::pool_size * (SgTypeFloat::pools.size()-1));
   27015             :    }
   27016             : 
   27017             : //############################################################################
   27018             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   27019             :  * memory pool and initializes the data member in class SgTypeFloatStroageClass
   27020             :  * from its counterpart of SgTypeFloat. The return value is just for checking, 
   27021             :  * that the whole StorageClassArray is initialized!
   27022             :  */
   27023             : unsigned long
   27024           2 : SgTypeFloat::initializeStorageClassArray( SgTypeFloatStorageClass *storageArray )
   27025             :    {
   27026           2 :      unsigned long storageCounter = 0;
   27027           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeFloat::pools.begin();
   27028           2 :      SgTypeFloat* pointer = NULL;
   27029           4 :      while ( block != SgTypeFloat::pools.end() ) {
   27030           2 :           pointer = (SgTypeFloat*) (*block);
   27031        4002 :           for ( unsigned i = 0; i < SgTypeFloat::pool_size; ++i ) {
   27032        4000 :                if ( pointer->get_freepointer() != NULL ) {
   27033           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   27034           2 :                  storageArray++;
   27035           2 :                  storageCounter++;
   27036             :                }
   27037        4000 :                pointer++;
   27038             :              }
   27039           2 :            block++;
   27040             :         }
   27041           2 :      return storageCounter;
   27042             :    }
   27043             : 
   27044             : /* #line 27045 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   27045             : 
   27046             : 
   27047             : 
   27048             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   27049             : 
   27050             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   27051             : 
   27052             : //############################################################################
   27053             : /* JH (02/02/2006) Constructor of the IR node SgTypeDouble that takes its 
   27054             :  * corresponding StorageClass as parameter
   27055             :  */
   27056           2 : SgTypeDouble :: SgTypeDouble ( const SgTypeDoubleStorageClass& storageSource )   : SgType (storageSource)
   27057             :    {
   27058             : 
   27059             : 
   27060             : /* #line 27061 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   27061             : 
   27062           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   27063             : 
   27064             : 
   27065             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   27066             : 
   27067             : 
   27068           2 :    }
   27069             : 
   27070             : //############################################################################
   27071             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   27072             :  * within the working AST. 
   27073             :  */
   27074         660 : SgTypeDouble * SgTypeDouble::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   27075         660 :      SgTypeDouble* returnPointer = NULL;
   27076         660 :      if ( globalIndex != 0 )
   27077             :         {
   27078             : 
   27079             : #if FILE_IO_EXTRA_CHECK
   27080         660 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeDouble ) ) <= globalIndex ) ;
   27081         660 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeDouble + 1 ) ) );
   27082             : #endif
   27083         660 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeDouble )  
   27084         660 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeDouble );
   27085         660 :           unsigned long positionInPool = localIndex % SgTypeDouble::pool_size;
   27086         660 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeDouble::pool_size;
   27087             : 
   27088             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   27089             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   27090             : 
   27091         660 :           returnPointer = &( ( (SgTypeDouble*)(SgTypeDouble::pools[memoryBlock]) ) [positionInPool]) ;
   27092             : 
   27093         660 :           ROSE_ASSERT( returnPointer != NULL ) ;
   27094             :         }
   27095         660 :      return returnPointer ;
   27096             :    }
   27097             : 
   27098             : //############################################################################
   27099             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   27100             :   for the AST with the index astIndex
   27101             : */
   27102           0 : SgTypeDouble * SgTypeDouble::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   27103           0 :      SgTypeDouble* returnPointer = NULL;
   27104           0 :      if ( globalIndex != 0 )
   27105             :         {
   27106             : 
   27107             : #if FILE_IO_EXTRA_CHECK
   27108           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeDouble ) ) <= globalIndex ) ;
   27109           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeDouble + 1 ) ) );
   27110             : #endif
   27111           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeDouble )
   27112           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeDouble );
   27113           0 :           unsigned long positionInPool = localIndex % SgTypeDouble::pool_size ;
   27114           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeDouble::pool_size ;
   27115             : 
   27116             : #if FILE_IO_EXTRA_CHECK
   27117             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   27118             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   27119             : #endif
   27120             : 
   27121           0 :           returnPointer = &( ( (SgTypeDouble*)(SgTypeDouble::pools[memoryBlock]) ) [positionInPool]) ;
   27122             : 
   27123             : #if FILE_IO_EXTRA_CHECK
   27124           0 :           assert ( returnPointer != NULL ) ;
   27125             : #endif
   27126             :         }
   27127           0 :      return returnPointer ;
   27128             :    }
   27129             : 
   27130             : //############################################################################
   27131             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   27132             :  * pool size! We set for every valid object in the memory pool the freepointer
   27133             :  * to the global index and increase the global index afterwards. For all the 
   27134             :  * invalid objects (means address ranges within the memory pool that were not
   27135             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   27136             :  * distinguish valid from invalid objects! 
   27137             :  */
   27138             : unsigned long
   27139           5 : SgTypeDouble::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   27140             :    {
   27141           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   27142           5 :      SgTypeDouble* pointer = NULL;
   27143           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   27144           5 :      std::vector < unsigned char* > :: const_iterator block;
   27145           7 :      for ( block = SgTypeDouble::pools.begin(); block != SgTypeDouble::pools.end() ; ++block )
   27146             :         {
   27147           2 :           pointer = (SgTypeDouble*)(*block);
   27148        4002 :           for (unsigned i = 0; i < SgTypeDouble::pool_size; ++i )
   27149             :              {
   27150             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   27151             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   27152             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   27153             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   27154             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   27155             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   27156             :             // properly; so this will have to be checked next.
   27157             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   27158             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   27159        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   27160             :                   {
   27161           2 :                     pointer[i].set_freepointer((SgTypeDouble*)(globalIndex));
   27162           2 :                     globalIndex++;
   27163             :                   }
   27164             :                else
   27165             :                   {
   27166        3998 :                     pointer[i].set_freepointer(NULL);
   27167             :                   }
   27168             :               }
   27169             :         }
   27170           5 :      return globalIndex;
   27171             :    }
   27172             : 
   27173             : //############################################################################
   27174             : // JH (01/14/2006)
   27175             : void
   27176           5 : SgTypeDouble::resetValidFreepointers( )
   27177             :    {
   27178           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   27179           5 :      SgTypeDouble* pointer = NULL;
   27180           5 :      std::vector < unsigned char* > :: const_iterator block;
   27181           5 :      SgTypeDouble* pointerOfLinkedList = NULL;
   27182           7 :      for ( block = SgTypeDouble::pools.begin(); block != SgTypeDouble::pools.end() ; ++block )
   27183             :         {
   27184           2 :           pointer = (SgTypeDouble*)(*block);
   27185        4002 :           for (unsigned i = 0; i < SgTypeDouble::pool_size; ++i )
   27186             :              {
   27187             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   27188             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   27189             :             // memory blocks!.
   27190        4000 :                if ( pointer[i].get_freepointer() != NULL )
   27191             :                   {
   27192           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   27193             :                   }
   27194             :                else
   27195             :                   {
   27196        3998 :                     if ( pointerOfLinkedList == NULL )
   27197             :                        {
   27198           2 :                          SgTypeDouble::next_node = &(pointer[i]);
   27199             :                        }
   27200             :                     else
   27201             :                        {
   27202             :                       // printf ("In SgTypeDouble::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   27203        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   27204             :                        }
   27205             :                     pointerOfLinkedList = &(pointer[i]);
   27206             :                   }
   27207             :               }
   27208             :         }
   27209             : 
   27210           5 :      if ( pointerOfLinkedList != NULL )
   27211             :         {
   27212             :        // printf ("In SgTypeDouble::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   27213           2 :           pointerOfLinkedList->set_freepointer(NULL);
   27214             :        // DQ (6/6/2010): Temporary debugging...
   27215             :        //   ROSE_ASSERT(false);
   27216             :         }
   27217             : 
   27218           5 :      return ;
   27219             :    }
   27220             : 
   27221             : //############################################################################
   27222             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   27223             :  * within the memory pool and resets the freepointers, in order to achieve a 
   27224             :  * linked list, that has no jumps and starts at the beginning! This function 
   27225             :  * does not extend the memory pool, since we do not delete any memory blocks,
   27226             :  * but delete the valid objects.  
   27227             :  */
   27228             : void
   27229           0 : SgTypeDouble::clearMemoryPool( )
   27230             :    {
   27231             :   // printf ("Inside of SgTypeDouble::clearMemoryPool() \n");
   27232             : 
   27233           0 :      SgTypeDouble* pointer = NULL, *tempPointer = NULL;
   27234           0 :      std::vector < unsigned char* > :: const_iterator block;
   27235           0 :      if ( SgTypeDouble::pools.empty() == false )
   27236             :         {
   27237           0 :           block = SgTypeDouble::pools.begin() ;
   27238           0 :           SgTypeDouble::next_node = (SgTypeDouble*) (*block);
   27239             : 
   27240           0 :           while ( block != SgTypeDouble::pools.end() )
   27241             :              {
   27242           0 :                pointer = (SgTypeDouble*) (*block);
   27243           0 :                if ( tempPointer != NULL )
   27244             :                   {
   27245           0 :                     tempPointer->set_freepointer(pointer);
   27246             :                   }
   27247           0 :                for (unsigned i = 0; i < SgTypeDouble::pool_size - 1; ++i)
   27248             :                   {
   27249           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   27250             :                   }
   27251           0 :                 pointer[SgTypeDouble::pool_size-1].set_freepointer(NULL);
   27252           0 :                 tempPointer = &(pointer[SgTypeDouble::pool_size-1]);
   27253           0 :                 ++block;
   27254             :              }
   27255             :         }
   27256           0 :    }
   27257             : 
   27258           5 : void SgTypeDouble::deleteMemoryPool() {
   27259           9 :   for (auto p: SgTypeDouble::pools) {
   27260           4 :     ROSE_FREE(p);
   27261             :   }
   27262           5 :   SgTypeDouble::next_node = nullptr;
   27263           5 :   SgTypeDouble::pools.clear();
   27264           5 : }
   27265             : 
   27266             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   27267             : //                 reading multiple binary files to for a single AST.
   27268             : /////////// new version ////////////////////////////////
   27269             : //############################################################################
   27270             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   27271             : void
   27272           2 : SgTypeDouble::extendMemoryPoolForFileIO( )
   27273             :   {
   27274           2 :     size_t blockIndex = SgTypeDouble::pools.size();
   27275           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeDouble) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeDouble);
   27276             : 
   27277           4 :     while ( (blockIndex * SgTypeDouble::pool_size) < newPoolSize)
   27278             :       {
   27279             : #if ROSE_ALLOC_TRACE
   27280             :         if (blockIndex > 0) {
   27281             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeDouble) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeDouble) = %" PRIuPTR " SgTypeDouble::pool_size = %d \n",
   27282             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeDouble),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeDouble),SgTypeDouble::pool_size);
   27283             :         }
   27284             : #endif
   27285             : 
   27286           2 :         SgTypeDouble * pointer = (SgTypeDouble*) ROSE_MALLOC ( SgTypeDouble::pool_size * sizeof(SgTypeDouble) );
   27287           2 :         assert( pointer != NULL );
   27288             : #if ROSE_ALLOC_MEMSET == 1
   27289             :         memset(pointer, 0x00, SgTypeDouble::pool_size * sizeof(SgTypeDouble));
   27290             : #elif ROSE_ALLOC_MEMSET == 2
   27291             :         memset(pointer, 0xCC, SgTypeDouble::pool_size * sizeof(SgTypeDouble));
   27292             : #endif
   27293           2 :         SgTypeDouble::pools.push_back( (unsigned char*)(pointer) );
   27294           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeDouble::pool_size * sizeof(SgTypeDouble), V_SgTypeDouble ) );
   27295             : 
   27296           2 :         if ( SgTypeDouble::next_node != NULL ) {
   27297           0 :           if ( blockIndex > 0 ) {
   27298           0 :             SgTypeDouble * blkptr = (SgTypeDouble*)(SgTypeDouble::pools[blockIndex-1]);
   27299           0 :             blkptr[ SgTypeDouble::pool_size - 1 ].set_freepointer(pointer);
   27300             :           }
   27301             :         } else {
   27302           2 :           SgTypeDouble::next_node = pointer;
   27303             :         }
   27304             : 
   27305        4000 :         for (unsigned i = 0; i < SgTypeDouble::pool_size-1; ++i)
   27306             :            {
   27307        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   27308             :            }
   27309           2 :         pointer[ SgTypeDouble::pool_size -1 ].set_freepointer(NULL);
   27310             : 
   27311           2 :         blockIndex++;
   27312             :       }
   27313           2 :   }
   27314             : 
   27315             : //############################################################################
   27316             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   27317             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   27318             :  * not compressed. However, that stuff is not yet implemented! 
   27319             :  */
   27320             : unsigned long
   27321           0 : SgTypeDouble::getNumberOfLastValidPointer()
   27322             :    {
   27323           0 :       SgTypeDouble* testPointer = (SgTypeDouble*)(SgTypeDouble::pools.back());
   27324           0 :       unsigned long localIndex = SgTypeDouble::pool_size - 1;
   27325           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   27326             :          {
   27327           0 :            localIndex--;
   27328             :          }
   27329           0 :       return (localIndex + SgTypeDouble::pool_size * (SgTypeDouble::pools.size()-1));
   27330             :    }
   27331             : 
   27332             : //############################################################################
   27333             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   27334             :  * memory pool and initializes the data member in class SgTypeDoubleStroageClass
   27335             :  * from its counterpart of SgTypeDouble. The return value is just for checking, 
   27336             :  * that the whole StorageClassArray is initialized!
   27337             :  */
   27338             : unsigned long
   27339           2 : SgTypeDouble::initializeStorageClassArray( SgTypeDoubleStorageClass *storageArray )
   27340             :    {
   27341           2 :      unsigned long storageCounter = 0;
   27342           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeDouble::pools.begin();
   27343           2 :      SgTypeDouble* pointer = NULL;
   27344           4 :      while ( block != SgTypeDouble::pools.end() ) {
   27345           2 :           pointer = (SgTypeDouble*) (*block);
   27346        4002 :           for ( unsigned i = 0; i < SgTypeDouble::pool_size; ++i ) {
   27347        4000 :                if ( pointer->get_freepointer() != NULL ) {
   27348           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   27349           2 :                  storageArray++;
   27350           2 :                  storageCounter++;
   27351             :                }
   27352        4000 :                pointer++;
   27353             :              }
   27354           2 :            block++;
   27355             :         }
   27356           2 :      return storageCounter;
   27357             :    }
   27358             : 
   27359             : /* #line 27360 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   27360             : 
   27361             : 
   27362             : 
   27363             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   27364             : 
   27365             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   27366             : 
   27367             : //############################################################################
   27368             : /* JH (02/02/2006) Constructor of the IR node SgTypeLongLong that takes its 
   27369             :  * corresponding StorageClass as parameter
   27370             :  */
   27371           2 : SgTypeLongLong :: SgTypeLongLong ( const SgTypeLongLongStorageClass& storageSource )   : SgType (storageSource)
   27372             :    {
   27373             : 
   27374             : 
   27375             : /* #line 27376 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   27376             : 
   27377           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   27378             : 
   27379             : 
   27380             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   27381             : 
   27382             : 
   27383           2 :    }
   27384             : 
   27385             : //############################################################################
   27386             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   27387             :  * within the working AST. 
   27388             :  */
   27389         376 : SgTypeLongLong * SgTypeLongLong::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   27390         376 :      SgTypeLongLong* returnPointer = NULL;
   27391         376 :      if ( globalIndex != 0 )
   27392             :         {
   27393             : 
   27394             : #if FILE_IO_EXTRA_CHECK
   27395         376 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeLongLong ) ) <= globalIndex ) ;
   27396         376 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeLongLong + 1 ) ) );
   27397             : #endif
   27398         376 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeLongLong )  
   27399         376 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeLongLong );
   27400         376 :           unsigned long positionInPool = localIndex % SgTypeLongLong::pool_size;
   27401         376 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeLongLong::pool_size;
   27402             : 
   27403             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   27404             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   27405             : 
   27406         376 :           returnPointer = &( ( (SgTypeLongLong*)(SgTypeLongLong::pools[memoryBlock]) ) [positionInPool]) ;
   27407             : 
   27408         376 :           ROSE_ASSERT( returnPointer != NULL ) ;
   27409             :         }
   27410         376 :      return returnPointer ;
   27411             :    }
   27412             : 
   27413             : //############################################################################
   27414             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   27415             :   for the AST with the index astIndex
   27416             : */
   27417           0 : SgTypeLongLong * SgTypeLongLong::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   27418           0 :      SgTypeLongLong* returnPointer = NULL;
   27419           0 :      if ( globalIndex != 0 )
   27420             :         {
   27421             : 
   27422             : #if FILE_IO_EXTRA_CHECK
   27423           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeLongLong ) ) <= globalIndex ) ;
   27424           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeLongLong + 1 ) ) );
   27425             : #endif
   27426           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeLongLong )
   27427           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeLongLong );
   27428           0 :           unsigned long positionInPool = localIndex % SgTypeLongLong::pool_size ;
   27429           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeLongLong::pool_size ;
   27430             : 
   27431             : #if FILE_IO_EXTRA_CHECK
   27432             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   27433             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   27434             : #endif
   27435             : 
   27436           0 :           returnPointer = &( ( (SgTypeLongLong*)(SgTypeLongLong::pools[memoryBlock]) ) [positionInPool]) ;
   27437             : 
   27438             : #if FILE_IO_EXTRA_CHECK
   27439           0 :           assert ( returnPointer != NULL ) ;
   27440             : #endif
   27441             :         }
   27442           0 :      return returnPointer ;
   27443             :    }
   27444             : 
   27445             : //############################################################################
   27446             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   27447             :  * pool size! We set for every valid object in the memory pool the freepointer
   27448             :  * to the global index and increase the global index afterwards. For all the 
   27449             :  * invalid objects (means address ranges within the memory pool that were not
   27450             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   27451             :  * distinguish valid from invalid objects! 
   27452             :  */
   27453             : unsigned long
   27454           5 : SgTypeLongLong::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   27455             :    {
   27456           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   27457           5 :      SgTypeLongLong* pointer = NULL;
   27458           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   27459           5 :      std::vector < unsigned char* > :: const_iterator block;
   27460           7 :      for ( block = SgTypeLongLong::pools.begin(); block != SgTypeLongLong::pools.end() ; ++block )
   27461             :         {
   27462           2 :           pointer = (SgTypeLongLong*)(*block);
   27463        4002 :           for (unsigned i = 0; i < SgTypeLongLong::pool_size; ++i )
   27464             :              {
   27465             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   27466             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   27467             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   27468             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   27469             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   27470             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   27471             :             // properly; so this will have to be checked next.
   27472             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   27473             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   27474        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   27475             :                   {
   27476           2 :                     pointer[i].set_freepointer((SgTypeLongLong*)(globalIndex));
   27477           2 :                     globalIndex++;
   27478             :                   }
   27479             :                else
   27480             :                   {
   27481        3998 :                     pointer[i].set_freepointer(NULL);
   27482             :                   }
   27483             :               }
   27484             :         }
   27485           5 :      return globalIndex;
   27486             :    }
   27487             : 
   27488             : //############################################################################
   27489             : // JH (01/14/2006)
   27490             : void
   27491           5 : SgTypeLongLong::resetValidFreepointers( )
   27492             :    {
   27493           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   27494           5 :      SgTypeLongLong* pointer = NULL;
   27495           5 :      std::vector < unsigned char* > :: const_iterator block;
   27496           5 :      SgTypeLongLong* pointerOfLinkedList = NULL;
   27497           7 :      for ( block = SgTypeLongLong::pools.begin(); block != SgTypeLongLong::pools.end() ; ++block )
   27498             :         {
   27499           2 :           pointer = (SgTypeLongLong*)(*block);
   27500        4002 :           for (unsigned i = 0; i < SgTypeLongLong::pool_size; ++i )
   27501             :              {
   27502             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   27503             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   27504             :             // memory blocks!.
   27505        4000 :                if ( pointer[i].get_freepointer() != NULL )
   27506             :                   {
   27507           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   27508             :                   }
   27509             :                else
   27510             :                   {
   27511        3998 :                     if ( pointerOfLinkedList == NULL )
   27512             :                        {
   27513           2 :                          SgTypeLongLong::next_node = &(pointer[i]);
   27514             :                        }
   27515             :                     else
   27516             :                        {
   27517             :                       // printf ("In SgTypeLongLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   27518        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   27519             :                        }
   27520             :                     pointerOfLinkedList = &(pointer[i]);
   27521             :                   }
   27522             :               }
   27523             :         }
   27524             : 
   27525           5 :      if ( pointerOfLinkedList != NULL )
   27526             :         {
   27527             :        // printf ("In SgTypeLongLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   27528           2 :           pointerOfLinkedList->set_freepointer(NULL);
   27529             :        // DQ (6/6/2010): Temporary debugging...
   27530             :        //   ROSE_ASSERT(false);
   27531             :         }
   27532             : 
   27533           5 :      return ;
   27534             :    }
   27535             : 
   27536             : //############################################################################
   27537             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   27538             :  * within the memory pool and resets the freepointers, in order to achieve a 
   27539             :  * linked list, that has no jumps and starts at the beginning! This function 
   27540             :  * does not extend the memory pool, since we do not delete any memory blocks,
   27541             :  * but delete the valid objects.  
   27542             :  */
   27543             : void
   27544           0 : SgTypeLongLong::clearMemoryPool( )
   27545             :    {
   27546             :   // printf ("Inside of SgTypeLongLong::clearMemoryPool() \n");
   27547             : 
   27548           0 :      SgTypeLongLong* pointer = NULL, *tempPointer = NULL;
   27549           0 :      std::vector < unsigned char* > :: const_iterator block;
   27550           0 :      if ( SgTypeLongLong::pools.empty() == false )
   27551             :         {
   27552           0 :           block = SgTypeLongLong::pools.begin() ;
   27553           0 :           SgTypeLongLong::next_node = (SgTypeLongLong*) (*block);
   27554             : 
   27555           0 :           while ( block != SgTypeLongLong::pools.end() )
   27556             :              {
   27557           0 :                pointer = (SgTypeLongLong*) (*block);
   27558           0 :                if ( tempPointer != NULL )
   27559             :                   {
   27560           0 :                     tempPointer->set_freepointer(pointer);
   27561             :                   }
   27562           0 :                for (unsigned i = 0; i < SgTypeLongLong::pool_size - 1; ++i)
   27563             :                   {
   27564           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   27565             :                   }
   27566           0 :                 pointer[SgTypeLongLong::pool_size-1].set_freepointer(NULL);
   27567           0 :                 tempPointer = &(pointer[SgTypeLongLong::pool_size-1]);
   27568           0 :                 ++block;
   27569             :              }
   27570             :         }
   27571           0 :    }
   27572             : 
   27573           5 : void SgTypeLongLong::deleteMemoryPool() {
   27574           9 :   for (auto p: SgTypeLongLong::pools) {
   27575           4 :     ROSE_FREE(p);
   27576             :   }
   27577           5 :   SgTypeLongLong::next_node = nullptr;
   27578           5 :   SgTypeLongLong::pools.clear();
   27579           5 : }
   27580             : 
   27581             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   27582             : //                 reading multiple binary files to for a single AST.
   27583             : /////////// new version ////////////////////////////////
   27584             : //############################################################################
   27585             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   27586             : void
   27587           2 : SgTypeLongLong::extendMemoryPoolForFileIO( )
   27588             :   {
   27589           2 :     size_t blockIndex = SgTypeLongLong::pools.size();
   27590           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLongLong) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLongLong);
   27591             : 
   27592           4 :     while ( (blockIndex * SgTypeLongLong::pool_size) < newPoolSize)
   27593             :       {
   27594             : #if ROSE_ALLOC_TRACE
   27595             :         if (blockIndex > 0) {
   27596             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLongLong) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLongLong) = %" PRIuPTR " SgTypeLongLong::pool_size = %d \n",
   27597             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLongLong),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLongLong),SgTypeLongLong::pool_size);
   27598             :         }
   27599             : #endif
   27600             : 
   27601           2 :         SgTypeLongLong * pointer = (SgTypeLongLong*) ROSE_MALLOC ( SgTypeLongLong::pool_size * sizeof(SgTypeLongLong) );
   27602           2 :         assert( pointer != NULL );
   27603             : #if ROSE_ALLOC_MEMSET == 1
   27604             :         memset(pointer, 0x00, SgTypeLongLong::pool_size * sizeof(SgTypeLongLong));
   27605             : #elif ROSE_ALLOC_MEMSET == 2
   27606             :         memset(pointer, 0xCC, SgTypeLongLong::pool_size * sizeof(SgTypeLongLong));
   27607             : #endif
   27608           2 :         SgTypeLongLong::pools.push_back( (unsigned char*)(pointer) );
   27609           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeLongLong::pool_size * sizeof(SgTypeLongLong), V_SgTypeLongLong ) );
   27610             : 
   27611           2 :         if ( SgTypeLongLong::next_node != NULL ) {
   27612           0 :           if ( blockIndex > 0 ) {
   27613           0 :             SgTypeLongLong * blkptr = (SgTypeLongLong*)(SgTypeLongLong::pools[blockIndex-1]);
   27614           0 :             blkptr[ SgTypeLongLong::pool_size - 1 ].set_freepointer(pointer);
   27615             :           }
   27616             :         } else {
   27617           2 :           SgTypeLongLong::next_node = pointer;
   27618             :         }
   27619             : 
   27620        4000 :         for (unsigned i = 0; i < SgTypeLongLong::pool_size-1; ++i)
   27621             :            {
   27622        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   27623             :            }
   27624           2 :         pointer[ SgTypeLongLong::pool_size -1 ].set_freepointer(NULL);
   27625             : 
   27626           2 :         blockIndex++;
   27627             :       }
   27628           2 :   }
   27629             : 
   27630             : //############################################################################
   27631             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   27632             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   27633             :  * not compressed. However, that stuff is not yet implemented! 
   27634             :  */
   27635             : unsigned long
   27636           0 : SgTypeLongLong::getNumberOfLastValidPointer()
   27637             :    {
   27638           0 :       SgTypeLongLong* testPointer = (SgTypeLongLong*)(SgTypeLongLong::pools.back());
   27639           0 :       unsigned long localIndex = SgTypeLongLong::pool_size - 1;
   27640           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   27641             :          {
   27642           0 :            localIndex--;
   27643             :          }
   27644           0 :       return (localIndex + SgTypeLongLong::pool_size * (SgTypeLongLong::pools.size()-1));
   27645             :    }
   27646             : 
   27647             : //############################################################################
   27648             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   27649             :  * memory pool and initializes the data member in class SgTypeLongLongStroageClass
   27650             :  * from its counterpart of SgTypeLongLong. The return value is just for checking, 
   27651             :  * that the whole StorageClassArray is initialized!
   27652             :  */
   27653             : unsigned long
   27654           2 : SgTypeLongLong::initializeStorageClassArray( SgTypeLongLongStorageClass *storageArray )
   27655             :    {
   27656           2 :      unsigned long storageCounter = 0;
   27657           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeLongLong::pools.begin();
   27658           2 :      SgTypeLongLong* pointer = NULL;
   27659           4 :      while ( block != SgTypeLongLong::pools.end() ) {
   27660           2 :           pointer = (SgTypeLongLong*) (*block);
   27661        4002 :           for ( unsigned i = 0; i < SgTypeLongLong::pool_size; ++i ) {
   27662        4000 :                if ( pointer->get_freepointer() != NULL ) {
   27663           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   27664           2 :                  storageArray++;
   27665           2 :                  storageCounter++;
   27666             :                }
   27667        4000 :                pointer++;
   27668             :              }
   27669           2 :            block++;
   27670             :         }
   27671           2 :      return storageCounter;
   27672             :    }
   27673             : 
   27674             : /* #line 27675 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   27675             : 
   27676             : 
   27677             : 
   27678             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   27679             : 
   27680             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   27681             : 
   27682             : //############################################################################
   27683             : /* JH (02/02/2006) Constructor of the IR node SgTypeSignedLongLong that takes its 
   27684             :  * corresponding StorageClass as parameter
   27685             :  */
   27686           1 : SgTypeSignedLongLong :: SgTypeSignedLongLong ( const SgTypeSignedLongLongStorageClass& storageSource )   : SgType (storageSource)
   27687             :    {
   27688             : 
   27689             : 
   27690             : /* #line 27691 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   27691             : 
   27692           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   27693             : 
   27694             : 
   27695             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   27696             : 
   27697             : 
   27698           1 :    }
   27699             : 
   27700             : //############################################################################
   27701             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   27702             :  * within the working AST. 
   27703             :  */
   27704           3 : SgTypeSignedLongLong * SgTypeSignedLongLong::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   27705           3 :      SgTypeSignedLongLong* returnPointer = NULL;
   27706           3 :      if ( globalIndex != 0 )
   27707             :         {
   27708             : 
   27709             : #if FILE_IO_EXTRA_CHECK
   27710           3 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeSignedLongLong ) ) <= globalIndex ) ;
   27711           3 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedLongLong + 1 ) ) );
   27712             : #endif
   27713           3 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSignedLongLong )  
   27714           3 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeSignedLongLong );
   27715           3 :           unsigned long positionInPool = localIndex % SgTypeSignedLongLong::pool_size;
   27716           3 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedLongLong::pool_size;
   27717             : 
   27718             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   27719             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   27720             : 
   27721           3 :           returnPointer = &( ( (SgTypeSignedLongLong*)(SgTypeSignedLongLong::pools[memoryBlock]) ) [positionInPool]) ;
   27722             : 
   27723           3 :           ROSE_ASSERT( returnPointer != NULL ) ;
   27724             :         }
   27725           3 :      return returnPointer ;
   27726             :    }
   27727             : 
   27728             : //############################################################################
   27729             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   27730             :   for the AST with the index astIndex
   27731             : */
   27732           0 : SgTypeSignedLongLong * SgTypeSignedLongLong::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   27733           0 :      SgTypeSignedLongLong* returnPointer = NULL;
   27734           0 :      if ( globalIndex != 0 )
   27735             :         {
   27736             : 
   27737             : #if FILE_IO_EXTRA_CHECK
   27738           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeSignedLongLong ) ) <= globalIndex ) ;
   27739           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedLongLong + 1 ) ) );
   27740             : #endif
   27741           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSignedLongLong )
   27742           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeSignedLongLong );
   27743           0 :           unsigned long positionInPool = localIndex % SgTypeSignedLongLong::pool_size ;
   27744           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSignedLongLong::pool_size ;
   27745             : 
   27746             : #if FILE_IO_EXTRA_CHECK
   27747             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   27748             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   27749             : #endif
   27750             : 
   27751           0 :           returnPointer = &( ( (SgTypeSignedLongLong*)(SgTypeSignedLongLong::pools[memoryBlock]) ) [positionInPool]) ;
   27752             : 
   27753             : #if FILE_IO_EXTRA_CHECK
   27754           0 :           assert ( returnPointer != NULL ) ;
   27755             : #endif
   27756             :         }
   27757           0 :      return returnPointer ;
   27758             :    }
   27759             : 
   27760             : //############################################################################
   27761             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   27762             :  * pool size! We set for every valid object in the memory pool the freepointer
   27763             :  * to the global index and increase the global index afterwards. For all the 
   27764             :  * invalid objects (means address ranges within the memory pool that were not
   27765             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   27766             :  * distinguish valid from invalid objects! 
   27767             :  */
   27768             : unsigned long
   27769           5 : SgTypeSignedLongLong::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   27770             :    {
   27771           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   27772           5 :      SgTypeSignedLongLong* pointer = NULL;
   27773           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   27774           5 :      std::vector < unsigned char* > :: const_iterator block;
   27775           6 :      for ( block = SgTypeSignedLongLong::pools.begin(); block != SgTypeSignedLongLong::pools.end() ; ++block )
   27776             :         {
   27777           1 :           pointer = (SgTypeSignedLongLong*)(*block);
   27778        2001 :           for (unsigned i = 0; i < SgTypeSignedLongLong::pool_size; ++i )
   27779             :              {
   27780             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   27781             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   27782             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   27783             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   27784             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   27785             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   27786             :             // properly; so this will have to be checked next.
   27787             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   27788             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   27789        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   27790             :                   {
   27791           1 :                     pointer[i].set_freepointer((SgTypeSignedLongLong*)(globalIndex));
   27792           1 :                     globalIndex++;
   27793             :                   }
   27794             :                else
   27795             :                   {
   27796        1999 :                     pointer[i].set_freepointer(NULL);
   27797             :                   }
   27798             :               }
   27799             :         }
   27800           5 :      return globalIndex;
   27801             :    }
   27802             : 
   27803             : //############################################################################
   27804             : // JH (01/14/2006)
   27805             : void
   27806           5 : SgTypeSignedLongLong::resetValidFreepointers( )
   27807             :    {
   27808           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   27809           5 :      SgTypeSignedLongLong* pointer = NULL;
   27810           5 :      std::vector < unsigned char* > :: const_iterator block;
   27811           5 :      SgTypeSignedLongLong* pointerOfLinkedList = NULL;
   27812           6 :      for ( block = SgTypeSignedLongLong::pools.begin(); block != SgTypeSignedLongLong::pools.end() ; ++block )
   27813             :         {
   27814           1 :           pointer = (SgTypeSignedLongLong*)(*block);
   27815        2001 :           for (unsigned i = 0; i < SgTypeSignedLongLong::pool_size; ++i )
   27816             :              {
   27817             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   27818             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   27819             :             // memory blocks!.
   27820        2000 :                if ( pointer[i].get_freepointer() != NULL )
   27821             :                   {
   27822           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   27823             :                   }
   27824             :                else
   27825             :                   {
   27826        1999 :                     if ( pointerOfLinkedList == NULL )
   27827             :                        {
   27828           1 :                          SgTypeSignedLongLong::next_node = &(pointer[i]);
   27829             :                        }
   27830             :                     else
   27831             :                        {
   27832             :                       // printf ("In SgTypeSignedLongLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   27833        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   27834             :                        }
   27835             :                     pointerOfLinkedList = &(pointer[i]);
   27836             :                   }
   27837             :               }
   27838             :         }
   27839             : 
   27840           5 :      if ( pointerOfLinkedList != NULL )
   27841             :         {
   27842             :        // printf ("In SgTypeSignedLongLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   27843           1 :           pointerOfLinkedList->set_freepointer(NULL);
   27844             :        // DQ (6/6/2010): Temporary debugging...
   27845             :        //   ROSE_ASSERT(false);
   27846             :         }
   27847             : 
   27848           5 :      return ;
   27849             :    }
   27850             : 
   27851             : //############################################################################
   27852             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   27853             :  * within the memory pool and resets the freepointers, in order to achieve a 
   27854             :  * linked list, that has no jumps and starts at the beginning! This function 
   27855             :  * does not extend the memory pool, since we do not delete any memory blocks,
   27856             :  * but delete the valid objects.  
   27857             :  */
   27858             : void
   27859           0 : SgTypeSignedLongLong::clearMemoryPool( )
   27860             :    {
   27861             :   // printf ("Inside of SgTypeSignedLongLong::clearMemoryPool() \n");
   27862             : 
   27863           0 :      SgTypeSignedLongLong* pointer = NULL, *tempPointer = NULL;
   27864           0 :      std::vector < unsigned char* > :: const_iterator block;
   27865           0 :      if ( SgTypeSignedLongLong::pools.empty() == false )
   27866             :         {
   27867           0 :           block = SgTypeSignedLongLong::pools.begin() ;
   27868           0 :           SgTypeSignedLongLong::next_node = (SgTypeSignedLongLong*) (*block);
   27869             : 
   27870           0 :           while ( block != SgTypeSignedLongLong::pools.end() )
   27871             :              {
   27872           0 :                pointer = (SgTypeSignedLongLong*) (*block);
   27873           0 :                if ( tempPointer != NULL )
   27874             :                   {
   27875           0 :                     tempPointer->set_freepointer(pointer);
   27876             :                   }
   27877           0 :                for (unsigned i = 0; i < SgTypeSignedLongLong::pool_size - 1; ++i)
   27878             :                   {
   27879           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   27880             :                   }
   27881           0 :                 pointer[SgTypeSignedLongLong::pool_size-1].set_freepointer(NULL);
   27882           0 :                 tempPointer = &(pointer[SgTypeSignedLongLong::pool_size-1]);
   27883           0 :                 ++block;
   27884             :              }
   27885             :         }
   27886           0 :    }
   27887             : 
   27888           5 : void SgTypeSignedLongLong::deleteMemoryPool() {
   27889           7 :   for (auto p: SgTypeSignedLongLong::pools) {
   27890           2 :     ROSE_FREE(p);
   27891             :   }
   27892           5 :   SgTypeSignedLongLong::next_node = nullptr;
   27893           5 :   SgTypeSignedLongLong::pools.clear();
   27894           5 : }
   27895             : 
   27896             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   27897             : //                 reading multiple binary files to for a single AST.
   27898             : /////////// new version ////////////////////////////////
   27899             : //############################################################################
   27900             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   27901             : void
   27902           2 : SgTypeSignedLongLong::extendMemoryPoolForFileIO( )
   27903             :   {
   27904           2 :     size_t blockIndex = SgTypeSignedLongLong::pools.size();
   27905           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedLongLong) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedLongLong);
   27906             : 
   27907           3 :     while ( (blockIndex * SgTypeSignedLongLong::pool_size) < newPoolSize)
   27908             :       {
   27909             : #if ROSE_ALLOC_TRACE
   27910             :         if (blockIndex > 0) {
   27911             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedLongLong) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedLongLong) = %" PRIuPTR " SgTypeSignedLongLong::pool_size = %d \n",
   27912             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSignedLongLong),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSignedLongLong),SgTypeSignedLongLong::pool_size);
   27913             :         }
   27914             : #endif
   27915             : 
   27916           1 :         SgTypeSignedLongLong * pointer = (SgTypeSignedLongLong*) ROSE_MALLOC ( SgTypeSignedLongLong::pool_size * sizeof(SgTypeSignedLongLong) );
   27917           1 :         assert( pointer != NULL );
   27918             : #if ROSE_ALLOC_MEMSET == 1
   27919             :         memset(pointer, 0x00, SgTypeSignedLongLong::pool_size * sizeof(SgTypeSignedLongLong));
   27920             : #elif ROSE_ALLOC_MEMSET == 2
   27921             :         memset(pointer, 0xCC, SgTypeSignedLongLong::pool_size * sizeof(SgTypeSignedLongLong));
   27922             : #endif
   27923           1 :         SgTypeSignedLongLong::pools.push_back( (unsigned char*)(pointer) );
   27924           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeSignedLongLong::pool_size * sizeof(SgTypeSignedLongLong), V_SgTypeSignedLongLong ) );
   27925             : 
   27926           1 :         if ( SgTypeSignedLongLong::next_node != NULL ) {
   27927           0 :           if ( blockIndex > 0 ) {
   27928           0 :             SgTypeSignedLongLong * blkptr = (SgTypeSignedLongLong*)(SgTypeSignedLongLong::pools[blockIndex-1]);
   27929           0 :             blkptr[ SgTypeSignedLongLong::pool_size - 1 ].set_freepointer(pointer);
   27930             :           }
   27931             :         } else {
   27932           1 :           SgTypeSignedLongLong::next_node = pointer;
   27933             :         }
   27934             : 
   27935        2000 :         for (unsigned i = 0; i < SgTypeSignedLongLong::pool_size-1; ++i)
   27936             :            {
   27937        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   27938             :            }
   27939           1 :         pointer[ SgTypeSignedLongLong::pool_size -1 ].set_freepointer(NULL);
   27940             : 
   27941           1 :         blockIndex++;
   27942             :       }
   27943           2 :   }
   27944             : 
   27945             : //############################################################################
   27946             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   27947             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   27948             :  * not compressed. However, that stuff is not yet implemented! 
   27949             :  */
   27950             : unsigned long
   27951           0 : SgTypeSignedLongLong::getNumberOfLastValidPointer()
   27952             :    {
   27953           0 :       SgTypeSignedLongLong* testPointer = (SgTypeSignedLongLong*)(SgTypeSignedLongLong::pools.back());
   27954           0 :       unsigned long localIndex = SgTypeSignedLongLong::pool_size - 1;
   27955           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   27956             :          {
   27957           0 :            localIndex--;
   27958             :          }
   27959           0 :       return (localIndex + SgTypeSignedLongLong::pool_size * (SgTypeSignedLongLong::pools.size()-1));
   27960             :    }
   27961             : 
   27962             : //############################################################################
   27963             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   27964             :  * memory pool and initializes the data member in class SgTypeSignedLongLongStroageClass
   27965             :  * from its counterpart of SgTypeSignedLongLong. The return value is just for checking, 
   27966             :  * that the whole StorageClassArray is initialized!
   27967             :  */
   27968             : unsigned long
   27969           1 : SgTypeSignedLongLong::initializeStorageClassArray( SgTypeSignedLongLongStorageClass *storageArray )
   27970             :    {
   27971           1 :      unsigned long storageCounter = 0;
   27972           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeSignedLongLong::pools.begin();
   27973           1 :      SgTypeSignedLongLong* pointer = NULL;
   27974           2 :      while ( block != SgTypeSignedLongLong::pools.end() ) {
   27975           1 :           pointer = (SgTypeSignedLongLong*) (*block);
   27976        2001 :           for ( unsigned i = 0; i < SgTypeSignedLongLong::pool_size; ++i ) {
   27977        2000 :                if ( pointer->get_freepointer() != NULL ) {
   27978           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   27979           1 :                  storageArray++;
   27980           1 :                  storageCounter++;
   27981             :                }
   27982        2000 :                pointer++;
   27983             :              }
   27984           1 :            block++;
   27985             :         }
   27986           1 :      return storageCounter;
   27987             :    }
   27988             : 
   27989             : /* #line 27990 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   27990             : 
   27991             : 
   27992             : 
   27993             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   27994             : 
   27995             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   27996             : 
   27997             : //############################################################################
   27998             : /* JH (02/02/2006) Constructor of the IR node SgTypeUnsignedLongLong that takes its 
   27999             :  * corresponding StorageClass as parameter
   28000             :  */
   28001           2 : SgTypeUnsignedLongLong :: SgTypeUnsignedLongLong ( const SgTypeUnsignedLongLongStorageClass& storageSource )   : SgType (storageSource)
   28002             :    {
   28003             : 
   28004             : 
   28005             : /* #line 28006 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   28006             : 
   28007           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   28008             : 
   28009             : 
   28010             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   28011             : 
   28012             : 
   28013           2 :    }
   28014             : 
   28015             : //############################################################################
   28016             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   28017             :  * within the working AST. 
   28018             :  */
   28019         293 : SgTypeUnsignedLongLong * SgTypeUnsignedLongLong::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   28020         293 :      SgTypeUnsignedLongLong* returnPointer = NULL;
   28021         293 :      if ( globalIndex != 0 )
   28022             :         {
   28023             : 
   28024             : #if FILE_IO_EXTRA_CHECK
   28025         293 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeUnsignedLongLong ) ) <= globalIndex ) ;
   28026         293 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedLongLong + 1 ) ) );
   28027             : #endif
   28028         293 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsignedLongLong )  
   28029         293 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeUnsignedLongLong );
   28030         293 :           unsigned long positionInPool = localIndex % SgTypeUnsignedLongLong::pool_size;
   28031         293 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedLongLong::pool_size;
   28032             : 
   28033             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   28034             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   28035             : 
   28036         293 :           returnPointer = &( ( (SgTypeUnsignedLongLong*)(SgTypeUnsignedLongLong::pools[memoryBlock]) ) [positionInPool]) ;
   28037             : 
   28038         293 :           ROSE_ASSERT( returnPointer != NULL ) ;
   28039             :         }
   28040         293 :      return returnPointer ;
   28041             :    }
   28042             : 
   28043             : //############################################################################
   28044             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   28045             :   for the AST with the index astIndex
   28046             : */
   28047           0 : SgTypeUnsignedLongLong * SgTypeUnsignedLongLong::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   28048           0 :      SgTypeUnsignedLongLong* returnPointer = NULL;
   28049           0 :      if ( globalIndex != 0 )
   28050             :         {
   28051             : 
   28052             : #if FILE_IO_EXTRA_CHECK
   28053           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeUnsignedLongLong ) ) <= globalIndex ) ;
   28054           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedLongLong + 1 ) ) );
   28055             : #endif
   28056           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsignedLongLong )
   28057           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeUnsignedLongLong );
   28058           0 :           unsigned long positionInPool = localIndex % SgTypeUnsignedLongLong::pool_size ;
   28059           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsignedLongLong::pool_size ;
   28060             : 
   28061             : #if FILE_IO_EXTRA_CHECK
   28062             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   28063             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   28064             : #endif
   28065             : 
   28066           0 :           returnPointer = &( ( (SgTypeUnsignedLongLong*)(SgTypeUnsignedLongLong::pools[memoryBlock]) ) [positionInPool]) ;
   28067             : 
   28068             : #if FILE_IO_EXTRA_CHECK
   28069           0 :           assert ( returnPointer != NULL ) ;
   28070             : #endif
   28071             :         }
   28072           0 :      return returnPointer ;
   28073             :    }
   28074             : 
   28075             : //############################################################################
   28076             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   28077             :  * pool size! We set for every valid object in the memory pool the freepointer
   28078             :  * to the global index and increase the global index afterwards. For all the 
   28079             :  * invalid objects (means address ranges within the memory pool that were not
   28080             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   28081             :  * distinguish valid from invalid objects! 
   28082             :  */
   28083             : unsigned long
   28084           5 : SgTypeUnsignedLongLong::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   28085             :    {
   28086           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   28087           5 :      SgTypeUnsignedLongLong* pointer = NULL;
   28088           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   28089           5 :      std::vector < unsigned char* > :: const_iterator block;
   28090           7 :      for ( block = SgTypeUnsignedLongLong::pools.begin(); block != SgTypeUnsignedLongLong::pools.end() ; ++block )
   28091             :         {
   28092           2 :           pointer = (SgTypeUnsignedLongLong*)(*block);
   28093        4002 :           for (unsigned i = 0; i < SgTypeUnsignedLongLong::pool_size; ++i )
   28094             :              {
   28095             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   28096             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   28097             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   28098             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   28099             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   28100             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   28101             :             // properly; so this will have to be checked next.
   28102             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   28103             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   28104        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   28105             :                   {
   28106           2 :                     pointer[i].set_freepointer((SgTypeUnsignedLongLong*)(globalIndex));
   28107           2 :                     globalIndex++;
   28108             :                   }
   28109             :                else
   28110             :                   {
   28111        3998 :                     pointer[i].set_freepointer(NULL);
   28112             :                   }
   28113             :               }
   28114             :         }
   28115           5 :      return globalIndex;
   28116             :    }
   28117             : 
   28118             : //############################################################################
   28119             : // JH (01/14/2006)
   28120             : void
   28121           5 : SgTypeUnsignedLongLong::resetValidFreepointers( )
   28122             :    {
   28123           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   28124           5 :      SgTypeUnsignedLongLong* pointer = NULL;
   28125           5 :      std::vector < unsigned char* > :: const_iterator block;
   28126           5 :      SgTypeUnsignedLongLong* pointerOfLinkedList = NULL;
   28127           7 :      for ( block = SgTypeUnsignedLongLong::pools.begin(); block != SgTypeUnsignedLongLong::pools.end() ; ++block )
   28128             :         {
   28129           2 :           pointer = (SgTypeUnsignedLongLong*)(*block);
   28130        4002 :           for (unsigned i = 0; i < SgTypeUnsignedLongLong::pool_size; ++i )
   28131             :              {
   28132             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   28133             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   28134             :             // memory blocks!.
   28135        4000 :                if ( pointer[i].get_freepointer() != NULL )
   28136             :                   {
   28137           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   28138             :                   }
   28139             :                else
   28140             :                   {
   28141        3998 :                     if ( pointerOfLinkedList == NULL )
   28142             :                        {
   28143           2 :                          SgTypeUnsignedLongLong::next_node = &(pointer[i]);
   28144             :                        }
   28145             :                     else
   28146             :                        {
   28147             :                       // printf ("In SgTypeUnsignedLongLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   28148        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   28149             :                        }
   28150             :                     pointerOfLinkedList = &(pointer[i]);
   28151             :                   }
   28152             :               }
   28153             :         }
   28154             : 
   28155           5 :      if ( pointerOfLinkedList != NULL )
   28156             :         {
   28157             :        // printf ("In SgTypeUnsignedLongLong::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   28158           2 :           pointerOfLinkedList->set_freepointer(NULL);
   28159             :        // DQ (6/6/2010): Temporary debugging...
   28160             :        //   ROSE_ASSERT(false);
   28161             :         }
   28162             : 
   28163           5 :      return ;
   28164             :    }
   28165             : 
   28166             : //############################################################################
   28167             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   28168             :  * within the memory pool and resets the freepointers, in order to achieve a 
   28169             :  * linked list, that has no jumps and starts at the beginning! This function 
   28170             :  * does not extend the memory pool, since we do not delete any memory blocks,
   28171             :  * but delete the valid objects.  
   28172             :  */
   28173             : void
   28174           0 : SgTypeUnsignedLongLong::clearMemoryPool( )
   28175             :    {
   28176             :   // printf ("Inside of SgTypeUnsignedLongLong::clearMemoryPool() \n");
   28177             : 
   28178           0 :      SgTypeUnsignedLongLong* pointer = NULL, *tempPointer = NULL;
   28179           0 :      std::vector < unsigned char* > :: const_iterator block;
   28180           0 :      if ( SgTypeUnsignedLongLong::pools.empty() == false )
   28181             :         {
   28182           0 :           block = SgTypeUnsignedLongLong::pools.begin() ;
   28183           0 :           SgTypeUnsignedLongLong::next_node = (SgTypeUnsignedLongLong*) (*block);
   28184             : 
   28185           0 :           while ( block != SgTypeUnsignedLongLong::pools.end() )
   28186             :              {
   28187           0 :                pointer = (SgTypeUnsignedLongLong*) (*block);
   28188           0 :                if ( tempPointer != NULL )
   28189             :                   {
   28190           0 :                     tempPointer->set_freepointer(pointer);
   28191             :                   }
   28192           0 :                for (unsigned i = 0; i < SgTypeUnsignedLongLong::pool_size - 1; ++i)
   28193             :                   {
   28194           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   28195             :                   }
   28196           0 :                 pointer[SgTypeUnsignedLongLong::pool_size-1].set_freepointer(NULL);
   28197           0 :                 tempPointer = &(pointer[SgTypeUnsignedLongLong::pool_size-1]);
   28198           0 :                 ++block;
   28199             :              }
   28200             :         }
   28201           0 :    }
   28202             : 
   28203           5 : void SgTypeUnsignedLongLong::deleteMemoryPool() {
   28204           9 :   for (auto p: SgTypeUnsignedLongLong::pools) {
   28205           4 :     ROSE_FREE(p);
   28206             :   }
   28207           5 :   SgTypeUnsignedLongLong::next_node = nullptr;
   28208           5 :   SgTypeUnsignedLongLong::pools.clear();
   28209           5 : }
   28210             : 
   28211             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   28212             : //                 reading multiple binary files to for a single AST.
   28213             : /////////// new version ////////////////////////////////
   28214             : //############################################################################
   28215             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   28216             : void
   28217           2 : SgTypeUnsignedLongLong::extendMemoryPoolForFileIO( )
   28218             :   {
   28219           2 :     size_t blockIndex = SgTypeUnsignedLongLong::pools.size();
   28220           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedLongLong) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedLongLong);
   28221             : 
   28222           4 :     while ( (blockIndex * SgTypeUnsignedLongLong::pool_size) < newPoolSize)
   28223             :       {
   28224             : #if ROSE_ALLOC_TRACE
   28225             :         if (blockIndex > 0) {
   28226             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedLongLong) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedLongLong) = %" PRIuPTR " SgTypeUnsignedLongLong::pool_size = %d \n",
   28227             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsignedLongLong),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsignedLongLong),SgTypeUnsignedLongLong::pool_size);
   28228             :         }
   28229             : #endif
   28230             : 
   28231           2 :         SgTypeUnsignedLongLong * pointer = (SgTypeUnsignedLongLong*) ROSE_MALLOC ( SgTypeUnsignedLongLong::pool_size * sizeof(SgTypeUnsignedLongLong) );
   28232           2 :         assert( pointer != NULL );
   28233             : #if ROSE_ALLOC_MEMSET == 1
   28234             :         memset(pointer, 0x00, SgTypeUnsignedLongLong::pool_size * sizeof(SgTypeUnsignedLongLong));
   28235             : #elif ROSE_ALLOC_MEMSET == 2
   28236             :         memset(pointer, 0xCC, SgTypeUnsignedLongLong::pool_size * sizeof(SgTypeUnsignedLongLong));
   28237             : #endif
   28238           2 :         SgTypeUnsignedLongLong::pools.push_back( (unsigned char*)(pointer) );
   28239           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeUnsignedLongLong::pool_size * sizeof(SgTypeUnsignedLongLong), V_SgTypeUnsignedLongLong ) );
   28240             : 
   28241           2 :         if ( SgTypeUnsignedLongLong::next_node != NULL ) {
   28242           0 :           if ( blockIndex > 0 ) {
   28243           0 :             SgTypeUnsignedLongLong * blkptr = (SgTypeUnsignedLongLong*)(SgTypeUnsignedLongLong::pools[blockIndex-1]);
   28244           0 :             blkptr[ SgTypeUnsignedLongLong::pool_size - 1 ].set_freepointer(pointer);
   28245             :           }
   28246             :         } else {
   28247           2 :           SgTypeUnsignedLongLong::next_node = pointer;
   28248             :         }
   28249             : 
   28250        4000 :         for (unsigned i = 0; i < SgTypeUnsignedLongLong::pool_size-1; ++i)
   28251             :            {
   28252        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   28253             :            }
   28254           2 :         pointer[ SgTypeUnsignedLongLong::pool_size -1 ].set_freepointer(NULL);
   28255             : 
   28256           2 :         blockIndex++;
   28257             :       }
   28258           2 :   }
   28259             : 
   28260             : //############################################################################
   28261             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   28262             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   28263             :  * not compressed. However, that stuff is not yet implemented! 
   28264             :  */
   28265             : unsigned long
   28266           0 : SgTypeUnsignedLongLong::getNumberOfLastValidPointer()
   28267             :    {
   28268           0 :       SgTypeUnsignedLongLong* testPointer = (SgTypeUnsignedLongLong*)(SgTypeUnsignedLongLong::pools.back());
   28269           0 :       unsigned long localIndex = SgTypeUnsignedLongLong::pool_size - 1;
   28270           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   28271             :          {
   28272           0 :            localIndex--;
   28273             :          }
   28274           0 :       return (localIndex + SgTypeUnsignedLongLong::pool_size * (SgTypeUnsignedLongLong::pools.size()-1));
   28275             :    }
   28276             : 
   28277             : //############################################################################
   28278             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   28279             :  * memory pool and initializes the data member in class SgTypeUnsignedLongLongStroageClass
   28280             :  * from its counterpart of SgTypeUnsignedLongLong. The return value is just for checking, 
   28281             :  * that the whole StorageClassArray is initialized!
   28282             :  */
   28283             : unsigned long
   28284           2 : SgTypeUnsignedLongLong::initializeStorageClassArray( SgTypeUnsignedLongLongStorageClass *storageArray )
   28285             :    {
   28286           2 :      unsigned long storageCounter = 0;
   28287           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeUnsignedLongLong::pools.begin();
   28288           2 :      SgTypeUnsignedLongLong* pointer = NULL;
   28289           4 :      while ( block != SgTypeUnsignedLongLong::pools.end() ) {
   28290           2 :           pointer = (SgTypeUnsignedLongLong*) (*block);
   28291        4002 :           for ( unsigned i = 0; i < SgTypeUnsignedLongLong::pool_size; ++i ) {
   28292        4000 :                if ( pointer->get_freepointer() != NULL ) {
   28293           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   28294           2 :                  storageArray++;
   28295           2 :                  storageCounter++;
   28296             :                }
   28297        4000 :                pointer++;
   28298             :              }
   28299           2 :            block++;
   28300             :         }
   28301           2 :      return storageCounter;
   28302             :    }
   28303             : 
   28304             : /* #line 28305 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   28305             : 
   28306             : 
   28307             : 
   28308             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   28309             : 
   28310             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   28311             : 
   28312             : //############################################################################
   28313             : /* JH (02/02/2006) Constructor of the IR node SgTypeSigned128bitInteger that takes its 
   28314             :  * corresponding StorageClass as parameter
   28315             :  */
   28316           1 : SgTypeSigned128bitInteger :: SgTypeSigned128bitInteger ( const SgTypeSigned128bitIntegerStorageClass& storageSource )   : SgType (storageSource)
   28317             :    {
   28318             : 
   28319             : 
   28320             : /* #line 28321 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   28321             : 
   28322           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   28323             : 
   28324             : 
   28325             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   28326             : 
   28327             : 
   28328           1 :    }
   28329             : 
   28330             : //############################################################################
   28331             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   28332             :  * within the working AST. 
   28333             :  */
   28334          22 : SgTypeSigned128bitInteger * SgTypeSigned128bitInteger::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   28335          22 :      SgTypeSigned128bitInteger* returnPointer = NULL;
   28336          22 :      if ( globalIndex != 0 )
   28337             :         {
   28338             : 
   28339             : #if FILE_IO_EXTRA_CHECK
   28340          22 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeSigned128bitInteger ) ) <= globalIndex ) ;
   28341          22 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSigned128bitInteger + 1 ) ) );
   28342             : #endif
   28343          22 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeSigned128bitInteger )  
   28344          22 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeSigned128bitInteger );
   28345          22 :           unsigned long positionInPool = localIndex % SgTypeSigned128bitInteger::pool_size;
   28346          22 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSigned128bitInteger::pool_size;
   28347             : 
   28348             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   28349             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   28350             : 
   28351          22 :           returnPointer = &( ( (SgTypeSigned128bitInteger*)(SgTypeSigned128bitInteger::pools[memoryBlock]) ) [positionInPool]) ;
   28352             : 
   28353          22 :           ROSE_ASSERT( returnPointer != NULL ) ;
   28354             :         }
   28355          22 :      return returnPointer ;
   28356             :    }
   28357             : 
   28358             : //############################################################################
   28359             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   28360             :   for the AST with the index astIndex
   28361             : */
   28362           0 : SgTypeSigned128bitInteger * SgTypeSigned128bitInteger::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   28363           0 :      SgTypeSigned128bitInteger* returnPointer = NULL;
   28364           0 :      if ( globalIndex != 0 )
   28365             :         {
   28366             : 
   28367             : #if FILE_IO_EXTRA_CHECK
   28368           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeSigned128bitInteger ) ) <= globalIndex ) ;
   28369           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSigned128bitInteger + 1 ) ) );
   28370             : #endif
   28371           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeSigned128bitInteger )
   28372           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeSigned128bitInteger );
   28373           0 :           unsigned long positionInPool = localIndex % SgTypeSigned128bitInteger::pool_size ;
   28374           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeSigned128bitInteger::pool_size ;
   28375             : 
   28376             : #if FILE_IO_EXTRA_CHECK
   28377             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   28378             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   28379             : #endif
   28380             : 
   28381           0 :           returnPointer = &( ( (SgTypeSigned128bitInteger*)(SgTypeSigned128bitInteger::pools[memoryBlock]) ) [positionInPool]) ;
   28382             : 
   28383             : #if FILE_IO_EXTRA_CHECK
   28384           0 :           assert ( returnPointer != NULL ) ;
   28385             : #endif
   28386             :         }
   28387           0 :      return returnPointer ;
   28388             :    }
   28389             : 
   28390             : //############################################################################
   28391             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   28392             :  * pool size! We set for every valid object in the memory pool the freepointer
   28393             :  * to the global index and increase the global index afterwards. For all the 
   28394             :  * invalid objects (means address ranges within the memory pool that were not
   28395             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   28396             :  * distinguish valid from invalid objects! 
   28397             :  */
   28398             : unsigned long
   28399           5 : SgTypeSigned128bitInteger::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   28400             :    {
   28401           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   28402           5 :      SgTypeSigned128bitInteger* pointer = NULL;
   28403           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   28404           5 :      std::vector < unsigned char* > :: const_iterator block;
   28405           6 :      for ( block = SgTypeSigned128bitInteger::pools.begin(); block != SgTypeSigned128bitInteger::pools.end() ; ++block )
   28406             :         {
   28407           1 :           pointer = (SgTypeSigned128bitInteger*)(*block);
   28408        2001 :           for (unsigned i = 0; i < SgTypeSigned128bitInteger::pool_size; ++i )
   28409             :              {
   28410             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   28411             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   28412             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   28413             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   28414             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   28415             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   28416             :             // properly; so this will have to be checked next.
   28417             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   28418             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   28419        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   28420             :                   {
   28421           1 :                     pointer[i].set_freepointer((SgTypeSigned128bitInteger*)(globalIndex));
   28422           1 :                     globalIndex++;
   28423             :                   }
   28424             :                else
   28425             :                   {
   28426        1999 :                     pointer[i].set_freepointer(NULL);
   28427             :                   }
   28428             :               }
   28429             :         }
   28430           5 :      return globalIndex;
   28431             :    }
   28432             : 
   28433             : //############################################################################
   28434             : // JH (01/14/2006)
   28435             : void
   28436           5 : SgTypeSigned128bitInteger::resetValidFreepointers( )
   28437             :    {
   28438           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   28439           5 :      SgTypeSigned128bitInteger* pointer = NULL;
   28440           5 :      std::vector < unsigned char* > :: const_iterator block;
   28441           5 :      SgTypeSigned128bitInteger* pointerOfLinkedList = NULL;
   28442           6 :      for ( block = SgTypeSigned128bitInteger::pools.begin(); block != SgTypeSigned128bitInteger::pools.end() ; ++block )
   28443             :         {
   28444           1 :           pointer = (SgTypeSigned128bitInteger*)(*block);
   28445        2001 :           for (unsigned i = 0; i < SgTypeSigned128bitInteger::pool_size; ++i )
   28446             :              {
   28447             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   28448             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   28449             :             // memory blocks!.
   28450        2000 :                if ( pointer[i].get_freepointer() != NULL )
   28451             :                   {
   28452           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   28453             :                   }
   28454             :                else
   28455             :                   {
   28456        1999 :                     if ( pointerOfLinkedList == NULL )
   28457             :                        {
   28458           1 :                          SgTypeSigned128bitInteger::next_node = &(pointer[i]);
   28459             :                        }
   28460             :                     else
   28461             :                        {
   28462             :                       // printf ("In SgTypeSigned128bitInteger::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   28463        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   28464             :                        }
   28465             :                     pointerOfLinkedList = &(pointer[i]);
   28466             :                   }
   28467             :               }
   28468             :         }
   28469             : 
   28470           5 :      if ( pointerOfLinkedList != NULL )
   28471             :         {
   28472             :        // printf ("In SgTypeSigned128bitInteger::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   28473           1 :           pointerOfLinkedList->set_freepointer(NULL);
   28474             :        // DQ (6/6/2010): Temporary debugging...
   28475             :        //   ROSE_ASSERT(false);
   28476             :         }
   28477             : 
   28478           5 :      return ;
   28479             :    }
   28480             : 
   28481             : //############################################################################
   28482             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   28483             :  * within the memory pool and resets the freepointers, in order to achieve a 
   28484             :  * linked list, that has no jumps and starts at the beginning! This function 
   28485             :  * does not extend the memory pool, since we do not delete any memory blocks,
   28486             :  * but delete the valid objects.  
   28487             :  */
   28488             : void
   28489           0 : SgTypeSigned128bitInteger::clearMemoryPool( )
   28490             :    {
   28491             :   // printf ("Inside of SgTypeSigned128bitInteger::clearMemoryPool() \n");
   28492             : 
   28493           0 :      SgTypeSigned128bitInteger* pointer = NULL, *tempPointer = NULL;
   28494           0 :      std::vector < unsigned char* > :: const_iterator block;
   28495           0 :      if ( SgTypeSigned128bitInteger::pools.empty() == false )
   28496             :         {
   28497           0 :           block = SgTypeSigned128bitInteger::pools.begin() ;
   28498           0 :           SgTypeSigned128bitInteger::next_node = (SgTypeSigned128bitInteger*) (*block);
   28499             : 
   28500           0 :           while ( block != SgTypeSigned128bitInteger::pools.end() )
   28501             :              {
   28502           0 :                pointer = (SgTypeSigned128bitInteger*) (*block);
   28503           0 :                if ( tempPointer != NULL )
   28504             :                   {
   28505           0 :                     tempPointer->set_freepointer(pointer);
   28506             :                   }
   28507           0 :                for (unsigned i = 0; i < SgTypeSigned128bitInteger::pool_size - 1; ++i)
   28508             :                   {
   28509           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   28510             :                   }
   28511           0 :                 pointer[SgTypeSigned128bitInteger::pool_size-1].set_freepointer(NULL);
   28512           0 :                 tempPointer = &(pointer[SgTypeSigned128bitInteger::pool_size-1]);
   28513           0 :                 ++block;
   28514             :              }
   28515             :         }
   28516           0 :    }
   28517             : 
   28518           5 : void SgTypeSigned128bitInteger::deleteMemoryPool() {
   28519           7 :   for (auto p: SgTypeSigned128bitInteger::pools) {
   28520           2 :     ROSE_FREE(p);
   28521             :   }
   28522           5 :   SgTypeSigned128bitInteger::next_node = nullptr;
   28523           5 :   SgTypeSigned128bitInteger::pools.clear();
   28524           5 : }
   28525             : 
   28526             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   28527             : //                 reading multiple binary files to for a single AST.
   28528             : /////////// new version ////////////////////////////////
   28529             : //############################################################################
   28530             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   28531             : void
   28532           2 : SgTypeSigned128bitInteger::extendMemoryPoolForFileIO( )
   28533             :   {
   28534           2 :     size_t blockIndex = SgTypeSigned128bitInteger::pools.size();
   28535           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSigned128bitInteger) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSigned128bitInteger);
   28536             : 
   28537           3 :     while ( (blockIndex * SgTypeSigned128bitInteger::pool_size) < newPoolSize)
   28538             :       {
   28539             : #if ROSE_ALLOC_TRACE
   28540             :         if (blockIndex > 0) {
   28541             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSigned128bitInteger) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSigned128bitInteger) = %" PRIuPTR " SgTypeSigned128bitInteger::pool_size = %d \n",
   28542             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeSigned128bitInteger),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeSigned128bitInteger),SgTypeSigned128bitInteger::pool_size);
   28543             :         }
   28544             : #endif
   28545             : 
   28546           1 :         SgTypeSigned128bitInteger * pointer = (SgTypeSigned128bitInteger*) ROSE_MALLOC ( SgTypeSigned128bitInteger::pool_size * sizeof(SgTypeSigned128bitInteger) );
   28547           1 :         assert( pointer != NULL );
   28548             : #if ROSE_ALLOC_MEMSET == 1
   28549             :         memset(pointer, 0x00, SgTypeSigned128bitInteger::pool_size * sizeof(SgTypeSigned128bitInteger));
   28550             : #elif ROSE_ALLOC_MEMSET == 2
   28551             :         memset(pointer, 0xCC, SgTypeSigned128bitInteger::pool_size * sizeof(SgTypeSigned128bitInteger));
   28552             : #endif
   28553           1 :         SgTypeSigned128bitInteger::pools.push_back( (unsigned char*)(pointer) );
   28554           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeSigned128bitInteger::pool_size * sizeof(SgTypeSigned128bitInteger), V_SgTypeSigned128bitInteger ) );
   28555             : 
   28556           1 :         if ( SgTypeSigned128bitInteger::next_node != NULL ) {
   28557           0 :           if ( blockIndex > 0 ) {
   28558           0 :             SgTypeSigned128bitInteger * blkptr = (SgTypeSigned128bitInteger*)(SgTypeSigned128bitInteger::pools[blockIndex-1]);
   28559           0 :             blkptr[ SgTypeSigned128bitInteger::pool_size - 1 ].set_freepointer(pointer);
   28560             :           }
   28561             :         } else {
   28562           1 :           SgTypeSigned128bitInteger::next_node = pointer;
   28563             :         }
   28564             : 
   28565        2000 :         for (unsigned i = 0; i < SgTypeSigned128bitInteger::pool_size-1; ++i)
   28566             :            {
   28567        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   28568             :            }
   28569           1 :         pointer[ SgTypeSigned128bitInteger::pool_size -1 ].set_freepointer(NULL);
   28570             : 
   28571           1 :         blockIndex++;
   28572             :       }
   28573           2 :   }
   28574             : 
   28575             : //############################################################################
   28576             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   28577             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   28578             :  * not compressed. However, that stuff is not yet implemented! 
   28579             :  */
   28580             : unsigned long
   28581           0 : SgTypeSigned128bitInteger::getNumberOfLastValidPointer()
   28582             :    {
   28583           0 :       SgTypeSigned128bitInteger* testPointer = (SgTypeSigned128bitInteger*)(SgTypeSigned128bitInteger::pools.back());
   28584           0 :       unsigned long localIndex = SgTypeSigned128bitInteger::pool_size - 1;
   28585           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   28586             :          {
   28587           0 :            localIndex--;
   28588             :          }
   28589           0 :       return (localIndex + SgTypeSigned128bitInteger::pool_size * (SgTypeSigned128bitInteger::pools.size()-1));
   28590             :    }
   28591             : 
   28592             : //############################################################################
   28593             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   28594             :  * memory pool and initializes the data member in class SgTypeSigned128bitIntegerStroageClass
   28595             :  * from its counterpart of SgTypeSigned128bitInteger. The return value is just for checking, 
   28596             :  * that the whole StorageClassArray is initialized!
   28597             :  */
   28598             : unsigned long
   28599           1 : SgTypeSigned128bitInteger::initializeStorageClassArray( SgTypeSigned128bitIntegerStorageClass *storageArray )
   28600             :    {
   28601           1 :      unsigned long storageCounter = 0;
   28602           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeSigned128bitInteger::pools.begin();
   28603           1 :      SgTypeSigned128bitInteger* pointer = NULL;
   28604           2 :      while ( block != SgTypeSigned128bitInteger::pools.end() ) {
   28605           1 :           pointer = (SgTypeSigned128bitInteger*) (*block);
   28606        2001 :           for ( unsigned i = 0; i < SgTypeSigned128bitInteger::pool_size; ++i ) {
   28607        2000 :                if ( pointer->get_freepointer() != NULL ) {
   28608           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   28609           1 :                  storageArray++;
   28610           1 :                  storageCounter++;
   28611             :                }
   28612        2000 :                pointer++;
   28613             :              }
   28614           1 :            block++;
   28615             :         }
   28616           1 :      return storageCounter;
   28617             :    }
   28618             : 
   28619             : /* #line 28620 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   28620             : 
   28621             : 
   28622             : 
   28623             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   28624             : 
   28625             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   28626             : 
   28627             : //############################################################################
   28628             : /* JH (02/02/2006) Constructor of the IR node SgTypeUnsigned128bitInteger that takes its 
   28629             :  * corresponding StorageClass as parameter
   28630             :  */
   28631           1 : SgTypeUnsigned128bitInteger :: SgTypeUnsigned128bitInteger ( const SgTypeUnsigned128bitIntegerStorageClass& storageSource )   : SgType (storageSource)
   28632             :    {
   28633             : 
   28634             : 
   28635             : /* #line 28636 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   28636             : 
   28637           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   28638             : 
   28639             : 
   28640             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   28641             : 
   28642             : 
   28643           1 :    }
   28644             : 
   28645             : //############################################################################
   28646             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   28647             :  * within the working AST. 
   28648             :  */
   28649          14 : SgTypeUnsigned128bitInteger * SgTypeUnsigned128bitInteger::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   28650          14 :      SgTypeUnsigned128bitInteger* returnPointer = NULL;
   28651          14 :      if ( globalIndex != 0 )
   28652             :         {
   28653             : 
   28654             : #if FILE_IO_EXTRA_CHECK
   28655          14 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeUnsigned128bitInteger ) ) <= globalIndex ) ;
   28656          14 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsigned128bitInteger + 1 ) ) );
   28657             : #endif
   28658          14 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeUnsigned128bitInteger )  
   28659          14 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeUnsigned128bitInteger );
   28660          14 :           unsigned long positionInPool = localIndex % SgTypeUnsigned128bitInteger::pool_size;
   28661          14 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsigned128bitInteger::pool_size;
   28662             : 
   28663             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   28664             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   28665             : 
   28666          14 :           returnPointer = &( ( (SgTypeUnsigned128bitInteger*)(SgTypeUnsigned128bitInteger::pools[memoryBlock]) ) [positionInPool]) ;
   28667             : 
   28668          14 :           ROSE_ASSERT( returnPointer != NULL ) ;
   28669             :         }
   28670          14 :      return returnPointer ;
   28671             :    }
   28672             : 
   28673             : //############################################################################
   28674             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   28675             :   for the AST with the index astIndex
   28676             : */
   28677           0 : SgTypeUnsigned128bitInteger * SgTypeUnsigned128bitInteger::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   28678           0 :      SgTypeUnsigned128bitInteger* returnPointer = NULL;
   28679           0 :      if ( globalIndex != 0 )
   28680             :         {
   28681             : 
   28682             : #if FILE_IO_EXTRA_CHECK
   28683           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeUnsigned128bitInteger ) ) <= globalIndex ) ;
   28684           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsigned128bitInteger + 1 ) ) );
   28685             : #endif
   28686           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeUnsigned128bitInteger )
   28687           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeUnsigned128bitInteger );
   28688           0 :           unsigned long positionInPool = localIndex % SgTypeUnsigned128bitInteger::pool_size ;
   28689           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeUnsigned128bitInteger::pool_size ;
   28690             : 
   28691             : #if FILE_IO_EXTRA_CHECK
   28692             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   28693             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   28694             : #endif
   28695             : 
   28696           0 :           returnPointer = &( ( (SgTypeUnsigned128bitInteger*)(SgTypeUnsigned128bitInteger::pools[memoryBlock]) ) [positionInPool]) ;
   28697             : 
   28698             : #if FILE_IO_EXTRA_CHECK
   28699           0 :           assert ( returnPointer != NULL ) ;
   28700             : #endif
   28701             :         }
   28702           0 :      return returnPointer ;
   28703             :    }
   28704             : 
   28705             : //############################################################################
   28706             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   28707             :  * pool size! We set for every valid object in the memory pool the freepointer
   28708             :  * to the global index and increase the global index afterwards. For all the 
   28709             :  * invalid objects (means address ranges within the memory pool that were not
   28710             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   28711             :  * distinguish valid from invalid objects! 
   28712             :  */
   28713             : unsigned long
   28714           5 : SgTypeUnsigned128bitInteger::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   28715             :    {
   28716           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   28717           5 :      SgTypeUnsigned128bitInteger* pointer = NULL;
   28718           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   28719           5 :      std::vector < unsigned char* > :: const_iterator block;
   28720           6 :      for ( block = SgTypeUnsigned128bitInteger::pools.begin(); block != SgTypeUnsigned128bitInteger::pools.end() ; ++block )
   28721             :         {
   28722           1 :           pointer = (SgTypeUnsigned128bitInteger*)(*block);
   28723        2001 :           for (unsigned i = 0; i < SgTypeUnsigned128bitInteger::pool_size; ++i )
   28724             :              {
   28725             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   28726             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   28727             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   28728             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   28729             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   28730             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   28731             :             // properly; so this will have to be checked next.
   28732             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   28733             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   28734        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   28735             :                   {
   28736           1 :                     pointer[i].set_freepointer((SgTypeUnsigned128bitInteger*)(globalIndex));
   28737           1 :                     globalIndex++;
   28738             :                   }
   28739             :                else
   28740             :                   {
   28741        1999 :                     pointer[i].set_freepointer(NULL);
   28742             :                   }
   28743             :               }
   28744             :         }
   28745           5 :      return globalIndex;
   28746             :    }
   28747             : 
   28748             : //############################################################################
   28749             : // JH (01/14/2006)
   28750             : void
   28751           5 : SgTypeUnsigned128bitInteger::resetValidFreepointers( )
   28752             :    {
   28753           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   28754           5 :      SgTypeUnsigned128bitInteger* pointer = NULL;
   28755           5 :      std::vector < unsigned char* > :: const_iterator block;
   28756           5 :      SgTypeUnsigned128bitInteger* pointerOfLinkedList = NULL;
   28757           6 :      for ( block = SgTypeUnsigned128bitInteger::pools.begin(); block != SgTypeUnsigned128bitInteger::pools.end() ; ++block )
   28758             :         {
   28759           1 :           pointer = (SgTypeUnsigned128bitInteger*)(*block);
   28760        2001 :           for (unsigned i = 0; i < SgTypeUnsigned128bitInteger::pool_size; ++i )
   28761             :              {
   28762             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   28763             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   28764             :             // memory blocks!.
   28765        2000 :                if ( pointer[i].get_freepointer() != NULL )
   28766             :                   {
   28767           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   28768             :                   }
   28769             :                else
   28770             :                   {
   28771        1999 :                     if ( pointerOfLinkedList == NULL )
   28772             :                        {
   28773           1 :                          SgTypeUnsigned128bitInteger::next_node = &(pointer[i]);
   28774             :                        }
   28775             :                     else
   28776             :                        {
   28777             :                       // printf ("In SgTypeUnsigned128bitInteger::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   28778        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   28779             :                        }
   28780             :                     pointerOfLinkedList = &(pointer[i]);
   28781             :                   }
   28782             :               }
   28783             :         }
   28784             : 
   28785           5 :      if ( pointerOfLinkedList != NULL )
   28786             :         {
   28787             :        // printf ("In SgTypeUnsigned128bitInteger::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   28788           1 :           pointerOfLinkedList->set_freepointer(NULL);
   28789             :        // DQ (6/6/2010): Temporary debugging...
   28790             :        //   ROSE_ASSERT(false);
   28791             :         }
   28792             : 
   28793           5 :      return ;
   28794             :    }
   28795             : 
   28796             : //############################################################################
   28797             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   28798             :  * within the memory pool and resets the freepointers, in order to achieve a 
   28799             :  * linked list, that has no jumps and starts at the beginning! This function 
   28800             :  * does not extend the memory pool, since we do not delete any memory blocks,
   28801             :  * but delete the valid objects.  
   28802             :  */
   28803             : void
   28804           0 : SgTypeUnsigned128bitInteger::clearMemoryPool( )
   28805             :    {
   28806             :   // printf ("Inside of SgTypeUnsigned128bitInteger::clearMemoryPool() \n");
   28807             : 
   28808           0 :      SgTypeUnsigned128bitInteger* pointer = NULL, *tempPointer = NULL;
   28809           0 :      std::vector < unsigned char* > :: const_iterator block;
   28810           0 :      if ( SgTypeUnsigned128bitInteger::pools.empty() == false )
   28811             :         {
   28812           0 :           block = SgTypeUnsigned128bitInteger::pools.begin() ;
   28813           0 :           SgTypeUnsigned128bitInteger::next_node = (SgTypeUnsigned128bitInteger*) (*block);
   28814             : 
   28815           0 :           while ( block != SgTypeUnsigned128bitInteger::pools.end() )
   28816             :              {
   28817           0 :                pointer = (SgTypeUnsigned128bitInteger*) (*block);
   28818           0 :                if ( tempPointer != NULL )
   28819             :                   {
   28820           0 :                     tempPointer->set_freepointer(pointer);
   28821             :                   }
   28822           0 :                for (unsigned i = 0; i < SgTypeUnsigned128bitInteger::pool_size - 1; ++i)
   28823             :                   {
   28824           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   28825             :                   }
   28826           0 :                 pointer[SgTypeUnsigned128bitInteger::pool_size-1].set_freepointer(NULL);
   28827           0 :                 tempPointer = &(pointer[SgTypeUnsigned128bitInteger::pool_size-1]);
   28828           0 :                 ++block;
   28829             :              }
   28830             :         }
   28831           0 :    }
   28832             : 
   28833           5 : void SgTypeUnsigned128bitInteger::deleteMemoryPool() {
   28834           7 :   for (auto p: SgTypeUnsigned128bitInteger::pools) {
   28835           2 :     ROSE_FREE(p);
   28836             :   }
   28837           5 :   SgTypeUnsigned128bitInteger::next_node = nullptr;
   28838           5 :   SgTypeUnsigned128bitInteger::pools.clear();
   28839           5 : }
   28840             : 
   28841             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   28842             : //                 reading multiple binary files to for a single AST.
   28843             : /////////// new version ////////////////////////////////
   28844             : //############################################################################
   28845             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   28846             : void
   28847           2 : SgTypeUnsigned128bitInteger::extendMemoryPoolForFileIO( )
   28848             :   {
   28849           2 :     size_t blockIndex = SgTypeUnsigned128bitInteger::pools.size();
   28850           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsigned128bitInteger) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsigned128bitInteger);
   28851             : 
   28852           3 :     while ( (blockIndex * SgTypeUnsigned128bitInteger::pool_size) < newPoolSize)
   28853             :       {
   28854             : #if ROSE_ALLOC_TRACE
   28855             :         if (blockIndex > 0) {
   28856             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsigned128bitInteger) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsigned128bitInteger) = %" PRIuPTR " SgTypeUnsigned128bitInteger::pool_size = %d \n",
   28857             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeUnsigned128bitInteger),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeUnsigned128bitInteger),SgTypeUnsigned128bitInteger::pool_size);
   28858             :         }
   28859             : #endif
   28860             : 
   28861           1 :         SgTypeUnsigned128bitInteger * pointer = (SgTypeUnsigned128bitInteger*) ROSE_MALLOC ( SgTypeUnsigned128bitInteger::pool_size * sizeof(SgTypeUnsigned128bitInteger) );
   28862           1 :         assert( pointer != NULL );
   28863             : #if ROSE_ALLOC_MEMSET == 1
   28864             :         memset(pointer, 0x00, SgTypeUnsigned128bitInteger::pool_size * sizeof(SgTypeUnsigned128bitInteger));
   28865             : #elif ROSE_ALLOC_MEMSET == 2
   28866             :         memset(pointer, 0xCC, SgTypeUnsigned128bitInteger::pool_size * sizeof(SgTypeUnsigned128bitInteger));
   28867             : #endif
   28868           1 :         SgTypeUnsigned128bitInteger::pools.push_back( (unsigned char*)(pointer) );
   28869           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeUnsigned128bitInteger::pool_size * sizeof(SgTypeUnsigned128bitInteger), V_SgTypeUnsigned128bitInteger ) );
   28870             : 
   28871           1 :         if ( SgTypeUnsigned128bitInteger::next_node != NULL ) {
   28872           0 :           if ( blockIndex > 0 ) {
   28873           0 :             SgTypeUnsigned128bitInteger * blkptr = (SgTypeUnsigned128bitInteger*)(SgTypeUnsigned128bitInteger::pools[blockIndex-1]);
   28874           0 :             blkptr[ SgTypeUnsigned128bitInteger::pool_size - 1 ].set_freepointer(pointer);
   28875             :           }
   28876             :         } else {
   28877           1 :           SgTypeUnsigned128bitInteger::next_node = pointer;
   28878             :         }
   28879             : 
   28880        2000 :         for (unsigned i = 0; i < SgTypeUnsigned128bitInteger::pool_size-1; ++i)
   28881             :            {
   28882        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   28883             :            }
   28884           1 :         pointer[ SgTypeUnsigned128bitInteger::pool_size -1 ].set_freepointer(NULL);
   28885             : 
   28886           1 :         blockIndex++;
   28887             :       }
   28888           2 :   }
   28889             : 
   28890             : //############################################################################
   28891             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   28892             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   28893             :  * not compressed. However, that stuff is not yet implemented! 
   28894             :  */
   28895             : unsigned long
   28896           0 : SgTypeUnsigned128bitInteger::getNumberOfLastValidPointer()
   28897             :    {
   28898           0 :       SgTypeUnsigned128bitInteger* testPointer = (SgTypeUnsigned128bitInteger*)(SgTypeUnsigned128bitInteger::pools.back());
   28899           0 :       unsigned long localIndex = SgTypeUnsigned128bitInteger::pool_size - 1;
   28900           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   28901             :          {
   28902           0 :            localIndex--;
   28903             :          }
   28904           0 :       return (localIndex + SgTypeUnsigned128bitInteger::pool_size * (SgTypeUnsigned128bitInteger::pools.size()-1));
   28905             :    }
   28906             : 
   28907             : //############################################################################
   28908             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   28909             :  * memory pool and initializes the data member in class SgTypeUnsigned128bitIntegerStroageClass
   28910             :  * from its counterpart of SgTypeUnsigned128bitInteger. The return value is just for checking, 
   28911             :  * that the whole StorageClassArray is initialized!
   28912             :  */
   28913             : unsigned long
   28914           1 : SgTypeUnsigned128bitInteger::initializeStorageClassArray( SgTypeUnsigned128bitIntegerStorageClass *storageArray )
   28915             :    {
   28916           1 :      unsigned long storageCounter = 0;
   28917           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeUnsigned128bitInteger::pools.begin();
   28918           1 :      SgTypeUnsigned128bitInteger* pointer = NULL;
   28919           2 :      while ( block != SgTypeUnsigned128bitInteger::pools.end() ) {
   28920           1 :           pointer = (SgTypeUnsigned128bitInteger*) (*block);
   28921        2001 :           for ( unsigned i = 0; i < SgTypeUnsigned128bitInteger::pool_size; ++i ) {
   28922        2000 :                if ( pointer->get_freepointer() != NULL ) {
   28923           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   28924           1 :                  storageArray++;
   28925           1 :                  storageCounter++;
   28926             :                }
   28927        2000 :                pointer++;
   28928             :              }
   28929           1 :            block++;
   28930             :         }
   28931           1 :      return storageCounter;
   28932             :    }
   28933             : 
   28934             : /* #line 28935 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   28935             : 
   28936             : 
   28937             : 
   28938             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   28939             : 
   28940             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   28941             : 
   28942             : //############################################################################
   28943             : /* JH (02/02/2006) Constructor of the IR node SgTypeFloat80 that takes its 
   28944             :  * corresponding StorageClass as parameter
   28945             :  */
   28946           0 : SgTypeFloat80 :: SgTypeFloat80 ( const SgTypeFloat80StorageClass& storageSource )   : SgType (storageSource)
   28947             :    {
   28948             : 
   28949             : 
   28950             : /* #line 28951 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   28951             : 
   28952           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   28953             : 
   28954             : 
   28955             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   28956             : 
   28957             : 
   28958           0 :    }
   28959             : 
   28960             : //############################################################################
   28961             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   28962             :  * within the working AST. 
   28963             :  */
   28964           0 : SgTypeFloat80 * SgTypeFloat80::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   28965           0 :      SgTypeFloat80* returnPointer = NULL;
   28966           0 :      if ( globalIndex != 0 )
   28967             :         {
   28968             : 
   28969             : #if FILE_IO_EXTRA_CHECK
   28970           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeFloat80 ) ) <= globalIndex ) ;
   28971           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeFloat80 + 1 ) ) );
   28972             : #endif
   28973           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeFloat80 )  
   28974           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeFloat80 );
   28975           0 :           unsigned long positionInPool = localIndex % SgTypeFloat80::pool_size;
   28976           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeFloat80::pool_size;
   28977             : 
   28978             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   28979             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   28980             : 
   28981           0 :           returnPointer = &( ( (SgTypeFloat80*)(SgTypeFloat80::pools[memoryBlock]) ) [positionInPool]) ;
   28982             : 
   28983           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   28984             :         }
   28985           0 :      return returnPointer ;
   28986             :    }
   28987             : 
   28988             : //############################################################################
   28989             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   28990             :   for the AST with the index astIndex
   28991             : */
   28992           0 : SgTypeFloat80 * SgTypeFloat80::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   28993           0 :      SgTypeFloat80* returnPointer = NULL;
   28994           0 :      if ( globalIndex != 0 )
   28995             :         {
   28996             : 
   28997             : #if FILE_IO_EXTRA_CHECK
   28998           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeFloat80 ) ) <= globalIndex ) ;
   28999           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeFloat80 + 1 ) ) );
   29000             : #endif
   29001           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeFloat80 )
   29002           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeFloat80 );
   29003           0 :           unsigned long positionInPool = localIndex % SgTypeFloat80::pool_size ;
   29004           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeFloat80::pool_size ;
   29005             : 
   29006             : #if FILE_IO_EXTRA_CHECK
   29007             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   29008             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   29009             : #endif
   29010             : 
   29011           0 :           returnPointer = &( ( (SgTypeFloat80*)(SgTypeFloat80::pools[memoryBlock]) ) [positionInPool]) ;
   29012             : 
   29013             : #if FILE_IO_EXTRA_CHECK
   29014           0 :           assert ( returnPointer != NULL ) ;
   29015             : #endif
   29016             :         }
   29017           0 :      return returnPointer ;
   29018             :    }
   29019             : 
   29020             : //############################################################################
   29021             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   29022             :  * pool size! We set for every valid object in the memory pool the freepointer
   29023             :  * to the global index and increase the global index afterwards. For all the 
   29024             :  * invalid objects (means address ranges within the memory pool that were not
   29025             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   29026             :  * distinguish valid from invalid objects! 
   29027             :  */
   29028             : unsigned long
   29029           5 : SgTypeFloat80::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   29030             :    {
   29031           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   29032           5 :      SgTypeFloat80* pointer = NULL;
   29033           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   29034           5 :      std::vector < unsigned char* > :: const_iterator block;
   29035           5 :      for ( block = SgTypeFloat80::pools.begin(); block != SgTypeFloat80::pools.end() ; ++block )
   29036             :         {
   29037           0 :           pointer = (SgTypeFloat80*)(*block);
   29038           0 :           for (unsigned i = 0; i < SgTypeFloat80::pool_size; ++i )
   29039             :              {
   29040             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   29041             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   29042             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   29043             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   29044             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   29045             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   29046             :             // properly; so this will have to be checked next.
   29047             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   29048             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   29049           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   29050             :                   {
   29051           0 :                     pointer[i].set_freepointer((SgTypeFloat80*)(globalIndex));
   29052           0 :                     globalIndex++;
   29053             :                   }
   29054             :                else
   29055             :                   {
   29056           0 :                     pointer[i].set_freepointer(NULL);
   29057             :                   }
   29058             :               }
   29059             :         }
   29060           5 :      return globalIndex;
   29061             :    }
   29062             : 
   29063             : //############################################################################
   29064             : // JH (01/14/2006)
   29065             : void
   29066           5 : SgTypeFloat80::resetValidFreepointers( )
   29067             :    {
   29068           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   29069           5 :      SgTypeFloat80* pointer = NULL;
   29070           5 :      std::vector < unsigned char* > :: const_iterator block;
   29071           5 :      SgTypeFloat80* pointerOfLinkedList = NULL;
   29072           5 :      for ( block = SgTypeFloat80::pools.begin(); block != SgTypeFloat80::pools.end() ; ++block )
   29073             :         {
   29074           0 :           pointer = (SgTypeFloat80*)(*block);
   29075           0 :           for (unsigned i = 0; i < SgTypeFloat80::pool_size; ++i )
   29076             :              {
   29077             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   29078             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   29079             :             // memory blocks!.
   29080           0 :                if ( pointer[i].get_freepointer() != NULL )
   29081             :                   {
   29082           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   29083             :                   }
   29084             :                else
   29085             :                   {
   29086           0 :                     if ( pointerOfLinkedList == NULL )
   29087             :                        {
   29088           0 :                          SgTypeFloat80::next_node = &(pointer[i]);
   29089             :                        }
   29090             :                     else
   29091             :                        {
   29092             :                       // printf ("In SgTypeFloat80::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   29093           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   29094             :                        }
   29095             :                     pointerOfLinkedList = &(pointer[i]);
   29096             :                   }
   29097             :               }
   29098             :         }
   29099             : 
   29100           5 :      if ( pointerOfLinkedList != NULL )
   29101             :         {
   29102             :        // printf ("In SgTypeFloat80::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   29103           0 :           pointerOfLinkedList->set_freepointer(NULL);
   29104             :        // DQ (6/6/2010): Temporary debugging...
   29105             :        //   ROSE_ASSERT(false);
   29106             :         }
   29107             : 
   29108           5 :      return ;
   29109             :    }
   29110             : 
   29111             : //############################################################################
   29112             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   29113             :  * within the memory pool and resets the freepointers, in order to achieve a 
   29114             :  * linked list, that has no jumps and starts at the beginning! This function 
   29115             :  * does not extend the memory pool, since we do not delete any memory blocks,
   29116             :  * but delete the valid objects.  
   29117             :  */
   29118             : void
   29119           0 : SgTypeFloat80::clearMemoryPool( )
   29120             :    {
   29121             :   // printf ("Inside of SgTypeFloat80::clearMemoryPool() \n");
   29122             : 
   29123           0 :      SgTypeFloat80* pointer = NULL, *tempPointer = NULL;
   29124           0 :      std::vector < unsigned char* > :: const_iterator block;
   29125           0 :      if ( SgTypeFloat80::pools.empty() == false )
   29126             :         {
   29127           0 :           block = SgTypeFloat80::pools.begin() ;
   29128           0 :           SgTypeFloat80::next_node = (SgTypeFloat80*) (*block);
   29129             : 
   29130           0 :           while ( block != SgTypeFloat80::pools.end() )
   29131             :              {
   29132           0 :                pointer = (SgTypeFloat80*) (*block);
   29133           0 :                if ( tempPointer != NULL )
   29134             :                   {
   29135           0 :                     tempPointer->set_freepointer(pointer);
   29136             :                   }
   29137           0 :                for (unsigned i = 0; i < SgTypeFloat80::pool_size - 1; ++i)
   29138             :                   {
   29139           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   29140             :                   }
   29141           0 :                 pointer[SgTypeFloat80::pool_size-1].set_freepointer(NULL);
   29142           0 :                 tempPointer = &(pointer[SgTypeFloat80::pool_size-1]);
   29143           0 :                 ++block;
   29144             :              }
   29145             :         }
   29146           0 :    }
   29147             : 
   29148           5 : void SgTypeFloat80::deleteMemoryPool() {
   29149           5 :   for (auto p: SgTypeFloat80::pools) {
   29150           0 :     ROSE_FREE(p);
   29151             :   }
   29152           5 :   SgTypeFloat80::next_node = nullptr;
   29153           5 :   SgTypeFloat80::pools.clear();
   29154           5 : }
   29155             : 
   29156             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   29157             : //                 reading multiple binary files to for a single AST.
   29158             : /////////// new version ////////////////////////////////
   29159             : //############################################################################
   29160             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   29161             : void
   29162           2 : SgTypeFloat80::extendMemoryPoolForFileIO( )
   29163             :   {
   29164           2 :     size_t blockIndex = SgTypeFloat80::pools.size();
   29165           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat80) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat80);
   29166             : 
   29167           2 :     while ( (blockIndex * SgTypeFloat80::pool_size) < newPoolSize)
   29168             :       {
   29169             : #if ROSE_ALLOC_TRACE
   29170             :         if (blockIndex > 0) {
   29171             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat80) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat80) = %" PRIuPTR " SgTypeFloat80::pool_size = %d \n",
   29172             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat80),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat80),SgTypeFloat80::pool_size);
   29173             :         }
   29174             : #endif
   29175             : 
   29176           0 :         SgTypeFloat80 * pointer = (SgTypeFloat80*) ROSE_MALLOC ( SgTypeFloat80::pool_size * sizeof(SgTypeFloat80) );
   29177           0 :         assert( pointer != NULL );
   29178             : #if ROSE_ALLOC_MEMSET == 1
   29179             :         memset(pointer, 0x00, SgTypeFloat80::pool_size * sizeof(SgTypeFloat80));
   29180             : #elif ROSE_ALLOC_MEMSET == 2
   29181             :         memset(pointer, 0xCC, SgTypeFloat80::pool_size * sizeof(SgTypeFloat80));
   29182             : #endif
   29183           0 :         SgTypeFloat80::pools.push_back( (unsigned char*)(pointer) );
   29184           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeFloat80::pool_size * sizeof(SgTypeFloat80), V_SgTypeFloat80 ) );
   29185             : 
   29186           0 :         if ( SgTypeFloat80::next_node != NULL ) {
   29187           0 :           if ( blockIndex > 0 ) {
   29188           0 :             SgTypeFloat80 * blkptr = (SgTypeFloat80*)(SgTypeFloat80::pools[blockIndex-1]);
   29189           0 :             blkptr[ SgTypeFloat80::pool_size - 1 ].set_freepointer(pointer);
   29190             :           }
   29191             :         } else {
   29192           0 :           SgTypeFloat80::next_node = pointer;
   29193             :         }
   29194             : 
   29195           0 :         for (unsigned i = 0; i < SgTypeFloat80::pool_size-1; ++i)
   29196             :            {
   29197           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   29198             :            }
   29199           0 :         pointer[ SgTypeFloat80::pool_size -1 ].set_freepointer(NULL);
   29200             : 
   29201           0 :         blockIndex++;
   29202             :       }
   29203           2 :   }
   29204             : 
   29205             : //############################################################################
   29206             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   29207             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   29208             :  * not compressed. However, that stuff is not yet implemented! 
   29209             :  */
   29210             : unsigned long
   29211           0 : SgTypeFloat80::getNumberOfLastValidPointer()
   29212             :    {
   29213           0 :       SgTypeFloat80* testPointer = (SgTypeFloat80*)(SgTypeFloat80::pools.back());
   29214           0 :       unsigned long localIndex = SgTypeFloat80::pool_size - 1;
   29215           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   29216             :          {
   29217           0 :            localIndex--;
   29218             :          }
   29219           0 :       return (localIndex + SgTypeFloat80::pool_size * (SgTypeFloat80::pools.size()-1));
   29220             :    }
   29221             : 
   29222             : //############################################################################
   29223             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   29224             :  * memory pool and initializes the data member in class SgTypeFloat80StroageClass
   29225             :  * from its counterpart of SgTypeFloat80. The return value is just for checking, 
   29226             :  * that the whole StorageClassArray is initialized!
   29227             :  */
   29228             : unsigned long
   29229           0 : SgTypeFloat80::initializeStorageClassArray( SgTypeFloat80StorageClass *storageArray )
   29230             :    {
   29231           0 :      unsigned long storageCounter = 0;
   29232           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeFloat80::pools.begin();
   29233           0 :      SgTypeFloat80* pointer = NULL;
   29234           0 :      while ( block != SgTypeFloat80::pools.end() ) {
   29235           0 :           pointer = (SgTypeFloat80*) (*block);
   29236           0 :           for ( unsigned i = 0; i < SgTypeFloat80::pool_size; ++i ) {
   29237           0 :                if ( pointer->get_freepointer() != NULL ) {
   29238           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   29239           0 :                  storageArray++;
   29240           0 :                  storageCounter++;
   29241             :                }
   29242           0 :                pointer++;
   29243             :              }
   29244           0 :            block++;
   29245             :         }
   29246           0 :      return storageCounter;
   29247             :    }
   29248             : 
   29249             : /* #line 29250 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   29250             : 
   29251             : 
   29252             : 
   29253             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   29254             : 
   29255             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   29256             : 
   29257             : //############################################################################
   29258             : /* JH (02/02/2006) Constructor of the IR node SgTypeLongDouble that takes its 
   29259             :  * corresponding StorageClass as parameter
   29260             :  */
   29261           2 : SgTypeLongDouble :: SgTypeLongDouble ( const SgTypeLongDoubleStorageClass& storageSource )   : SgType (storageSource)
   29262             :    {
   29263             : 
   29264             : 
   29265             : /* #line 29266 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   29266             : 
   29267           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   29268             : 
   29269             : 
   29270             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   29271             : 
   29272             : 
   29273           2 :    }
   29274             : 
   29275             : //############################################################################
   29276             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   29277             :  * within the working AST. 
   29278             :  */
   29279         522 : SgTypeLongDouble * SgTypeLongDouble::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   29280         522 :      SgTypeLongDouble* returnPointer = NULL;
   29281         522 :      if ( globalIndex != 0 )
   29282             :         {
   29283             : 
   29284             : #if FILE_IO_EXTRA_CHECK
   29285         522 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeLongDouble ) ) <= globalIndex ) ;
   29286         522 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeLongDouble + 1 ) ) );
   29287             : #endif
   29288         522 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeLongDouble )  
   29289         522 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeLongDouble );
   29290         522 :           unsigned long positionInPool = localIndex % SgTypeLongDouble::pool_size;
   29291         522 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeLongDouble::pool_size;
   29292             : 
   29293             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   29294             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   29295             : 
   29296         522 :           returnPointer = &( ( (SgTypeLongDouble*)(SgTypeLongDouble::pools[memoryBlock]) ) [positionInPool]) ;
   29297             : 
   29298         522 :           ROSE_ASSERT( returnPointer != NULL ) ;
   29299             :         }
   29300         522 :      return returnPointer ;
   29301             :    }
   29302             : 
   29303             : //############################################################################
   29304             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   29305             :   for the AST with the index astIndex
   29306             : */
   29307           0 : SgTypeLongDouble * SgTypeLongDouble::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   29308           0 :      SgTypeLongDouble* returnPointer = NULL;
   29309           0 :      if ( globalIndex != 0 )
   29310             :         {
   29311             : 
   29312             : #if FILE_IO_EXTRA_CHECK
   29313           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeLongDouble ) ) <= globalIndex ) ;
   29314           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeLongDouble + 1 ) ) );
   29315             : #endif
   29316           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeLongDouble )
   29317           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeLongDouble );
   29318           0 :           unsigned long positionInPool = localIndex % SgTypeLongDouble::pool_size ;
   29319           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeLongDouble::pool_size ;
   29320             : 
   29321             : #if FILE_IO_EXTRA_CHECK
   29322             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   29323             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   29324             : #endif
   29325             : 
   29326           0 :           returnPointer = &( ( (SgTypeLongDouble*)(SgTypeLongDouble::pools[memoryBlock]) ) [positionInPool]) ;
   29327             : 
   29328             : #if FILE_IO_EXTRA_CHECK
   29329           0 :           assert ( returnPointer != NULL ) ;
   29330             : #endif
   29331             :         }
   29332           0 :      return returnPointer ;
   29333             :    }
   29334             : 
   29335             : //############################################################################
   29336             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   29337             :  * pool size! We set for every valid object in the memory pool the freepointer
   29338             :  * to the global index and increase the global index afterwards. For all the 
   29339             :  * invalid objects (means address ranges within the memory pool that were not
   29340             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   29341             :  * distinguish valid from invalid objects! 
   29342             :  */
   29343             : unsigned long
   29344           5 : SgTypeLongDouble::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   29345             :    {
   29346           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   29347           5 :      SgTypeLongDouble* pointer = NULL;
   29348           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   29349           5 :      std::vector < unsigned char* > :: const_iterator block;
   29350           7 :      for ( block = SgTypeLongDouble::pools.begin(); block != SgTypeLongDouble::pools.end() ; ++block )
   29351             :         {
   29352           2 :           pointer = (SgTypeLongDouble*)(*block);
   29353        4002 :           for (unsigned i = 0; i < SgTypeLongDouble::pool_size; ++i )
   29354             :              {
   29355             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   29356             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   29357             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   29358             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   29359             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   29360             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   29361             :             // properly; so this will have to be checked next.
   29362             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   29363             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   29364        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   29365             :                   {
   29366           2 :                     pointer[i].set_freepointer((SgTypeLongDouble*)(globalIndex));
   29367           2 :                     globalIndex++;
   29368             :                   }
   29369             :                else
   29370             :                   {
   29371        3998 :                     pointer[i].set_freepointer(NULL);
   29372             :                   }
   29373             :               }
   29374             :         }
   29375           5 :      return globalIndex;
   29376             :    }
   29377             : 
   29378             : //############################################################################
   29379             : // JH (01/14/2006)
   29380             : void
   29381           5 : SgTypeLongDouble::resetValidFreepointers( )
   29382             :    {
   29383           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   29384           5 :      SgTypeLongDouble* pointer = NULL;
   29385           5 :      std::vector < unsigned char* > :: const_iterator block;
   29386           5 :      SgTypeLongDouble* pointerOfLinkedList = NULL;
   29387           7 :      for ( block = SgTypeLongDouble::pools.begin(); block != SgTypeLongDouble::pools.end() ; ++block )
   29388             :         {
   29389           2 :           pointer = (SgTypeLongDouble*)(*block);
   29390        4002 :           for (unsigned i = 0; i < SgTypeLongDouble::pool_size; ++i )
   29391             :              {
   29392             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   29393             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   29394             :             // memory blocks!.
   29395        4000 :                if ( pointer[i].get_freepointer() != NULL )
   29396             :                   {
   29397           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   29398             :                   }
   29399             :                else
   29400             :                   {
   29401        3998 :                     if ( pointerOfLinkedList == NULL )
   29402             :                        {
   29403           2 :                          SgTypeLongDouble::next_node = &(pointer[i]);
   29404             :                        }
   29405             :                     else
   29406             :                        {
   29407             :                       // printf ("In SgTypeLongDouble::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   29408        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   29409             :                        }
   29410             :                     pointerOfLinkedList = &(pointer[i]);
   29411             :                   }
   29412             :               }
   29413             :         }
   29414             : 
   29415           5 :      if ( pointerOfLinkedList != NULL )
   29416             :         {
   29417             :        // printf ("In SgTypeLongDouble::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   29418           2 :           pointerOfLinkedList->set_freepointer(NULL);
   29419             :        // DQ (6/6/2010): Temporary debugging...
   29420             :        //   ROSE_ASSERT(false);
   29421             :         }
   29422             : 
   29423           5 :      return ;
   29424             :    }
   29425             : 
   29426             : //############################################################################
   29427             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   29428             :  * within the memory pool and resets the freepointers, in order to achieve a 
   29429             :  * linked list, that has no jumps and starts at the beginning! This function 
   29430             :  * does not extend the memory pool, since we do not delete any memory blocks,
   29431             :  * but delete the valid objects.  
   29432             :  */
   29433             : void
   29434           0 : SgTypeLongDouble::clearMemoryPool( )
   29435             :    {
   29436             :   // printf ("Inside of SgTypeLongDouble::clearMemoryPool() \n");
   29437             : 
   29438           0 :      SgTypeLongDouble* pointer = NULL, *tempPointer = NULL;
   29439           0 :      std::vector < unsigned char* > :: const_iterator block;
   29440           0 :      if ( SgTypeLongDouble::pools.empty() == false )
   29441             :         {
   29442           0 :           block = SgTypeLongDouble::pools.begin() ;
   29443           0 :           SgTypeLongDouble::next_node = (SgTypeLongDouble*) (*block);
   29444             : 
   29445           0 :           while ( block != SgTypeLongDouble::pools.end() )
   29446             :              {
   29447           0 :                pointer = (SgTypeLongDouble*) (*block);
   29448           0 :                if ( tempPointer != NULL )
   29449             :                   {
   29450           0 :                     tempPointer->set_freepointer(pointer);
   29451             :                   }
   29452           0 :                for (unsigned i = 0; i < SgTypeLongDouble::pool_size - 1; ++i)
   29453             :                   {
   29454           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   29455             :                   }
   29456           0 :                 pointer[SgTypeLongDouble::pool_size-1].set_freepointer(NULL);
   29457           0 :                 tempPointer = &(pointer[SgTypeLongDouble::pool_size-1]);
   29458           0 :                 ++block;
   29459             :              }
   29460             :         }
   29461           0 :    }
   29462             : 
   29463           5 : void SgTypeLongDouble::deleteMemoryPool() {
   29464           9 :   for (auto p: SgTypeLongDouble::pools) {
   29465           4 :     ROSE_FREE(p);
   29466             :   }
   29467           5 :   SgTypeLongDouble::next_node = nullptr;
   29468           5 :   SgTypeLongDouble::pools.clear();
   29469           5 : }
   29470             : 
   29471             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   29472             : //                 reading multiple binary files to for a single AST.
   29473             : /////////// new version ////////////////////////////////
   29474             : //############################################################################
   29475             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   29476             : void
   29477           2 : SgTypeLongDouble::extendMemoryPoolForFileIO( )
   29478             :   {
   29479           2 :     size_t blockIndex = SgTypeLongDouble::pools.size();
   29480           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLongDouble) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLongDouble);
   29481             : 
   29482           4 :     while ( (blockIndex * SgTypeLongDouble::pool_size) < newPoolSize)
   29483             :       {
   29484             : #if ROSE_ALLOC_TRACE
   29485             :         if (blockIndex > 0) {
   29486             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLongDouble) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLongDouble) = %" PRIuPTR " SgTypeLongDouble::pool_size = %d \n",
   29487             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLongDouble),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLongDouble),SgTypeLongDouble::pool_size);
   29488             :         }
   29489             : #endif
   29490             : 
   29491           2 :         SgTypeLongDouble * pointer = (SgTypeLongDouble*) ROSE_MALLOC ( SgTypeLongDouble::pool_size * sizeof(SgTypeLongDouble) );
   29492           2 :         assert( pointer != NULL );
   29493             : #if ROSE_ALLOC_MEMSET == 1
   29494             :         memset(pointer, 0x00, SgTypeLongDouble::pool_size * sizeof(SgTypeLongDouble));
   29495             : #elif ROSE_ALLOC_MEMSET == 2
   29496             :         memset(pointer, 0xCC, SgTypeLongDouble::pool_size * sizeof(SgTypeLongDouble));
   29497             : #endif
   29498           2 :         SgTypeLongDouble::pools.push_back( (unsigned char*)(pointer) );
   29499           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeLongDouble::pool_size * sizeof(SgTypeLongDouble), V_SgTypeLongDouble ) );
   29500             : 
   29501           2 :         if ( SgTypeLongDouble::next_node != NULL ) {
   29502           0 :           if ( blockIndex > 0 ) {
   29503           0 :             SgTypeLongDouble * blkptr = (SgTypeLongDouble*)(SgTypeLongDouble::pools[blockIndex-1]);
   29504           0 :             blkptr[ SgTypeLongDouble::pool_size - 1 ].set_freepointer(pointer);
   29505             :           }
   29506             :         } else {
   29507           2 :           SgTypeLongDouble::next_node = pointer;
   29508             :         }
   29509             : 
   29510        4000 :         for (unsigned i = 0; i < SgTypeLongDouble::pool_size-1; ++i)
   29511             :            {
   29512        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   29513             :            }
   29514           2 :         pointer[ SgTypeLongDouble::pool_size -1 ].set_freepointer(NULL);
   29515             : 
   29516           2 :         blockIndex++;
   29517             :       }
   29518           2 :   }
   29519             : 
   29520             : //############################################################################
   29521             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   29522             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   29523             :  * not compressed. However, that stuff is not yet implemented! 
   29524             :  */
   29525             : unsigned long
   29526           0 : SgTypeLongDouble::getNumberOfLastValidPointer()
   29527             :    {
   29528           0 :       SgTypeLongDouble* testPointer = (SgTypeLongDouble*)(SgTypeLongDouble::pools.back());
   29529           0 :       unsigned long localIndex = SgTypeLongDouble::pool_size - 1;
   29530           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   29531             :          {
   29532           0 :            localIndex--;
   29533             :          }
   29534           0 :       return (localIndex + SgTypeLongDouble::pool_size * (SgTypeLongDouble::pools.size()-1));
   29535             :    }
   29536             : 
   29537             : //############################################################################
   29538             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   29539             :  * memory pool and initializes the data member in class SgTypeLongDoubleStroageClass
   29540             :  * from its counterpart of SgTypeLongDouble. The return value is just for checking, 
   29541             :  * that the whole StorageClassArray is initialized!
   29542             :  */
   29543             : unsigned long
   29544           2 : SgTypeLongDouble::initializeStorageClassArray( SgTypeLongDoubleStorageClass *storageArray )
   29545             :    {
   29546           2 :      unsigned long storageCounter = 0;
   29547           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeLongDouble::pools.begin();
   29548           2 :      SgTypeLongDouble* pointer = NULL;
   29549           4 :      while ( block != SgTypeLongDouble::pools.end() ) {
   29550           2 :           pointer = (SgTypeLongDouble*) (*block);
   29551        4002 :           for ( unsigned i = 0; i < SgTypeLongDouble::pool_size; ++i ) {
   29552        4000 :                if ( pointer->get_freepointer() != NULL ) {
   29553           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   29554           2 :                  storageArray++;
   29555           2 :                  storageCounter++;
   29556             :                }
   29557        4000 :                pointer++;
   29558             :              }
   29559           2 :            block++;
   29560             :         }
   29561           2 :      return storageCounter;
   29562             :    }
   29563             : 
   29564             : /* #line 29565 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   29565             : 
   29566             : 
   29567             : 
   29568             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   29569             : 
   29570             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   29571             : 
   29572             : //############################################################################
   29573             : /* JH (02/02/2006) Constructor of the IR node SgTypeString that takes its 
   29574             :  * corresponding StorageClass as parameter
   29575             :  */
   29576           0 : SgTypeString :: SgTypeString ( const SgTypeStringStorageClass& storageSource )   : SgType (storageSource)
   29577             :    {
   29578             : 
   29579             : 
   29580             : /* #line 29581 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   29581             : 
   29582           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   29583           0 :      p_lengthExpression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lengthExpression) );
   29584             : 
   29585             : 
   29586             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   29587             : 
   29588             : 
   29589           0 :    }
   29590             : 
   29591             : //############################################################################
   29592             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   29593             :  * within the working AST. 
   29594             :  */
   29595           0 : SgTypeString * SgTypeString::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   29596           0 :      SgTypeString* returnPointer = NULL;
   29597           0 :      if ( globalIndex != 0 )
   29598             :         {
   29599             : 
   29600             : #if FILE_IO_EXTRA_CHECK
   29601           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeString ) ) <= globalIndex ) ;
   29602           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeString + 1 ) ) );
   29603             : #endif
   29604           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeString )  
   29605           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeString );
   29606           0 :           unsigned long positionInPool = localIndex % SgTypeString::pool_size;
   29607           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeString::pool_size;
   29608             : 
   29609             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   29610             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   29611             : 
   29612           0 :           returnPointer = &( ( (SgTypeString*)(SgTypeString::pools[memoryBlock]) ) [positionInPool]) ;
   29613             : 
   29614           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   29615             :         }
   29616           0 :      return returnPointer ;
   29617             :    }
   29618             : 
   29619             : //############################################################################
   29620             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   29621             :   for the AST with the index astIndex
   29622             : */
   29623           0 : SgTypeString * SgTypeString::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   29624           0 :      SgTypeString* returnPointer = NULL;
   29625           0 :      if ( globalIndex != 0 )
   29626             :         {
   29627             : 
   29628             : #if FILE_IO_EXTRA_CHECK
   29629           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeString ) ) <= globalIndex ) ;
   29630           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeString + 1 ) ) );
   29631             : #endif
   29632           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeString )
   29633           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeString );
   29634           0 :           unsigned long positionInPool = localIndex % SgTypeString::pool_size ;
   29635           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeString::pool_size ;
   29636             : 
   29637             : #if FILE_IO_EXTRA_CHECK
   29638             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   29639             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   29640             : #endif
   29641             : 
   29642           0 :           returnPointer = &( ( (SgTypeString*)(SgTypeString::pools[memoryBlock]) ) [positionInPool]) ;
   29643             : 
   29644             : #if FILE_IO_EXTRA_CHECK
   29645           0 :           assert ( returnPointer != NULL ) ;
   29646             : #endif
   29647             :         }
   29648           0 :      return returnPointer ;
   29649             :    }
   29650             : 
   29651             : //############################################################################
   29652             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   29653             :  * pool size! We set for every valid object in the memory pool the freepointer
   29654             :  * to the global index and increase the global index afterwards. For all the 
   29655             :  * invalid objects (means address ranges within the memory pool that were not
   29656             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   29657             :  * distinguish valid from invalid objects! 
   29658             :  */
   29659             : unsigned long
   29660           5 : SgTypeString::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   29661             :    {
   29662           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   29663           5 :      SgTypeString* pointer = NULL;
   29664           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   29665           5 :      std::vector < unsigned char* > :: const_iterator block;
   29666           5 :      for ( block = SgTypeString::pools.begin(); block != SgTypeString::pools.end() ; ++block )
   29667             :         {
   29668           0 :           pointer = (SgTypeString*)(*block);
   29669           0 :           for (unsigned i = 0; i < SgTypeString::pool_size; ++i )
   29670             :              {
   29671             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   29672             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   29673             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   29674             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   29675             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   29676             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   29677             :             // properly; so this will have to be checked next.
   29678             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   29679             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   29680           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   29681             :                   {
   29682           0 :                     pointer[i].set_freepointer((SgTypeString*)(globalIndex));
   29683           0 :                     globalIndex++;
   29684             :                   }
   29685             :                else
   29686             :                   {
   29687           0 :                     pointer[i].set_freepointer(NULL);
   29688             :                   }
   29689             :               }
   29690             :         }
   29691           5 :      return globalIndex;
   29692             :    }
   29693             : 
   29694             : //############################################################################
   29695             : // JH (01/14/2006)
   29696             : void
   29697           5 : SgTypeString::resetValidFreepointers( )
   29698             :    {
   29699           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   29700           5 :      SgTypeString* pointer = NULL;
   29701           5 :      std::vector < unsigned char* > :: const_iterator block;
   29702           5 :      SgTypeString* pointerOfLinkedList = NULL;
   29703           5 :      for ( block = SgTypeString::pools.begin(); block != SgTypeString::pools.end() ; ++block )
   29704             :         {
   29705           0 :           pointer = (SgTypeString*)(*block);
   29706           0 :           for (unsigned i = 0; i < SgTypeString::pool_size; ++i )
   29707             :              {
   29708             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   29709             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   29710             :             // memory blocks!.
   29711           0 :                if ( pointer[i].get_freepointer() != NULL )
   29712             :                   {
   29713           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   29714             :                   }
   29715             :                else
   29716             :                   {
   29717           0 :                     if ( pointerOfLinkedList == NULL )
   29718             :                        {
   29719           0 :                          SgTypeString::next_node = &(pointer[i]);
   29720             :                        }
   29721             :                     else
   29722             :                        {
   29723             :                       // printf ("In SgTypeString::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   29724           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   29725             :                        }
   29726             :                     pointerOfLinkedList = &(pointer[i]);
   29727             :                   }
   29728             :               }
   29729             :         }
   29730             : 
   29731           5 :      if ( pointerOfLinkedList != NULL )
   29732             :         {
   29733             :        // printf ("In SgTypeString::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   29734           0 :           pointerOfLinkedList->set_freepointer(NULL);
   29735             :        // DQ (6/6/2010): Temporary debugging...
   29736             :        //   ROSE_ASSERT(false);
   29737             :         }
   29738             : 
   29739           5 :      return ;
   29740             :    }
   29741             : 
   29742             : //############################################################################
   29743             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   29744             :  * within the memory pool and resets the freepointers, in order to achieve a 
   29745             :  * linked list, that has no jumps and starts at the beginning! This function 
   29746             :  * does not extend the memory pool, since we do not delete any memory blocks,
   29747             :  * but delete the valid objects.  
   29748             :  */
   29749             : void
   29750           0 : SgTypeString::clearMemoryPool( )
   29751             :    {
   29752             :   // printf ("Inside of SgTypeString::clearMemoryPool() \n");
   29753             : 
   29754           0 :      SgTypeString* pointer = NULL, *tempPointer = NULL;
   29755           0 :      std::vector < unsigned char* > :: const_iterator block;
   29756           0 :      if ( SgTypeString::pools.empty() == false )
   29757             :         {
   29758           0 :           block = SgTypeString::pools.begin() ;
   29759           0 :           SgTypeString::next_node = (SgTypeString*) (*block);
   29760             : 
   29761           0 :           while ( block != SgTypeString::pools.end() )
   29762             :              {
   29763           0 :                pointer = (SgTypeString*) (*block);
   29764           0 :                if ( tempPointer != NULL )
   29765             :                   {
   29766           0 :                     tempPointer->set_freepointer(pointer);
   29767             :                   }
   29768           0 :                for (unsigned i = 0; i < SgTypeString::pool_size - 1; ++i)
   29769             :                   {
   29770           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   29771             :                   }
   29772           0 :                 pointer[SgTypeString::pool_size-1].set_freepointer(NULL);
   29773           0 :                 tempPointer = &(pointer[SgTypeString::pool_size-1]);
   29774           0 :                 ++block;
   29775             :              }
   29776             :         }
   29777           0 :    }
   29778             : 
   29779           5 : void SgTypeString::deleteMemoryPool() {
   29780           5 :   for (auto p: SgTypeString::pools) {
   29781           0 :     ROSE_FREE(p);
   29782             :   }
   29783           5 :   SgTypeString::next_node = nullptr;
   29784           5 :   SgTypeString::pools.clear();
   29785           5 : }
   29786             : 
   29787             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   29788             : //                 reading multiple binary files to for a single AST.
   29789             : /////////// new version ////////////////////////////////
   29790             : //############################################################################
   29791             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   29792             : void
   29793           2 : SgTypeString::extendMemoryPoolForFileIO( )
   29794             :   {
   29795           2 :     size_t blockIndex = SgTypeString::pools.size();
   29796           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeString) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeString);
   29797             : 
   29798           2 :     while ( (blockIndex * SgTypeString::pool_size) < newPoolSize)
   29799             :       {
   29800             : #if ROSE_ALLOC_TRACE
   29801             :         if (blockIndex > 0) {
   29802             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeString) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeString) = %" PRIuPTR " SgTypeString::pool_size = %d \n",
   29803             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeString),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeString),SgTypeString::pool_size);
   29804             :         }
   29805             : #endif
   29806             : 
   29807           0 :         SgTypeString * pointer = (SgTypeString*) ROSE_MALLOC ( SgTypeString::pool_size * sizeof(SgTypeString) );
   29808           0 :         assert( pointer != NULL );
   29809             : #if ROSE_ALLOC_MEMSET == 1
   29810             :         memset(pointer, 0x00, SgTypeString::pool_size * sizeof(SgTypeString));
   29811             : #elif ROSE_ALLOC_MEMSET == 2
   29812             :         memset(pointer, 0xCC, SgTypeString::pool_size * sizeof(SgTypeString));
   29813             : #endif
   29814           0 :         SgTypeString::pools.push_back( (unsigned char*)(pointer) );
   29815           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeString::pool_size * sizeof(SgTypeString), V_SgTypeString ) );
   29816             : 
   29817           0 :         if ( SgTypeString::next_node != NULL ) {
   29818           0 :           if ( blockIndex > 0 ) {
   29819           0 :             SgTypeString * blkptr = (SgTypeString*)(SgTypeString::pools[blockIndex-1]);
   29820           0 :             blkptr[ SgTypeString::pool_size - 1 ].set_freepointer(pointer);
   29821             :           }
   29822             :         } else {
   29823           0 :           SgTypeString::next_node = pointer;
   29824             :         }
   29825             : 
   29826           0 :         for (unsigned i = 0; i < SgTypeString::pool_size-1; ++i)
   29827             :            {
   29828           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   29829             :            }
   29830           0 :         pointer[ SgTypeString::pool_size -1 ].set_freepointer(NULL);
   29831             : 
   29832           0 :         blockIndex++;
   29833             :       }
   29834           2 :   }
   29835             : 
   29836             : //############################################################################
   29837             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   29838             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   29839             :  * not compressed. However, that stuff is not yet implemented! 
   29840             :  */
   29841             : unsigned long
   29842           0 : SgTypeString::getNumberOfLastValidPointer()
   29843             :    {
   29844           0 :       SgTypeString* testPointer = (SgTypeString*)(SgTypeString::pools.back());
   29845           0 :       unsigned long localIndex = SgTypeString::pool_size - 1;
   29846           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   29847             :          {
   29848           0 :            localIndex--;
   29849             :          }
   29850           0 :       return (localIndex + SgTypeString::pool_size * (SgTypeString::pools.size()-1));
   29851             :    }
   29852             : 
   29853             : //############################################################################
   29854             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   29855             :  * memory pool and initializes the data member in class SgTypeStringStroageClass
   29856             :  * from its counterpart of SgTypeString. The return value is just for checking, 
   29857             :  * that the whole StorageClassArray is initialized!
   29858             :  */
   29859             : unsigned long
   29860           0 : SgTypeString::initializeStorageClassArray( SgTypeStringStorageClass *storageArray )
   29861             :    {
   29862           0 :      unsigned long storageCounter = 0;
   29863           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeString::pools.begin();
   29864           0 :      SgTypeString* pointer = NULL;
   29865           0 :      while ( block != SgTypeString::pools.end() ) {
   29866           0 :           pointer = (SgTypeString*) (*block);
   29867           0 :           for ( unsigned i = 0; i < SgTypeString::pool_size; ++i ) {
   29868           0 :                if ( pointer->get_freepointer() != NULL ) {
   29869           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   29870           0 :                  storageArray++;
   29871           0 :                  storageCounter++;
   29872             :                }
   29873           0 :                pointer++;
   29874             :              }
   29875           0 :            block++;
   29876             :         }
   29877           0 :      return storageCounter;
   29878             :    }
   29879             : 
   29880             : /* #line 29881 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   29881             : 
   29882             : 
   29883             : 
   29884             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   29885             : 
   29886             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   29887             : 
   29888             : //############################################################################
   29889             : /* JH (02/02/2006) Constructor of the IR node SgTypeBool that takes its 
   29890             :  * corresponding StorageClass as parameter
   29891             :  */
   29892           1 : SgTypeBool :: SgTypeBool ( const SgTypeBoolStorageClass& storageSource )   : SgType (storageSource)
   29893             :    {
   29894             : 
   29895             : 
   29896             : /* #line 29897 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   29897             : 
   29898           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   29899             : 
   29900             : 
   29901             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   29902             : 
   29903             : 
   29904           1 :    }
   29905             : 
   29906             : //############################################################################
   29907             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   29908             :  * within the working AST. 
   29909             :  */
   29910        1465 : SgTypeBool * SgTypeBool::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   29911        1465 :      SgTypeBool* returnPointer = NULL;
   29912        1465 :      if ( globalIndex != 0 )
   29913             :         {
   29914             : 
   29915             : #if FILE_IO_EXTRA_CHECK
   29916        1465 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeBool ) ) <= globalIndex ) ;
   29917        1465 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeBool + 1 ) ) );
   29918             : #endif
   29919        1465 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeBool )  
   29920        1465 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeBool );
   29921        1465 :           unsigned long positionInPool = localIndex % SgTypeBool::pool_size;
   29922        1465 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeBool::pool_size;
   29923             : 
   29924             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   29925             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   29926             : 
   29927        1465 :           returnPointer = &( ( (SgTypeBool*)(SgTypeBool::pools[memoryBlock]) ) [positionInPool]) ;
   29928             : 
   29929        1465 :           ROSE_ASSERT( returnPointer != NULL ) ;
   29930             :         }
   29931        1465 :      return returnPointer ;
   29932             :    }
   29933             : 
   29934             : //############################################################################
   29935             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   29936             :   for the AST with the index astIndex
   29937             : */
   29938           0 : SgTypeBool * SgTypeBool::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   29939           0 :      SgTypeBool* returnPointer = NULL;
   29940           0 :      if ( globalIndex != 0 )
   29941             :         {
   29942             : 
   29943             : #if FILE_IO_EXTRA_CHECK
   29944           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeBool ) ) <= globalIndex ) ;
   29945           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeBool + 1 ) ) );
   29946             : #endif
   29947           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeBool )
   29948           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeBool );
   29949           0 :           unsigned long positionInPool = localIndex % SgTypeBool::pool_size ;
   29950           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeBool::pool_size ;
   29951             : 
   29952             : #if FILE_IO_EXTRA_CHECK
   29953             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   29954             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   29955             : #endif
   29956             : 
   29957           0 :           returnPointer = &( ( (SgTypeBool*)(SgTypeBool::pools[memoryBlock]) ) [positionInPool]) ;
   29958             : 
   29959             : #if FILE_IO_EXTRA_CHECK
   29960           0 :           assert ( returnPointer != NULL ) ;
   29961             : #endif
   29962             :         }
   29963           0 :      return returnPointer ;
   29964             :    }
   29965             : 
   29966             : //############################################################################
   29967             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   29968             :  * pool size! We set for every valid object in the memory pool the freepointer
   29969             :  * to the global index and increase the global index afterwards. For all the 
   29970             :  * invalid objects (means address ranges within the memory pool that were not
   29971             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   29972             :  * distinguish valid from invalid objects! 
   29973             :  */
   29974             : unsigned long
   29975           5 : SgTypeBool::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   29976             :    {
   29977           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   29978           5 :      SgTypeBool* pointer = NULL;
   29979           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   29980           5 :      std::vector < unsigned char* > :: const_iterator block;
   29981           6 :      for ( block = SgTypeBool::pools.begin(); block != SgTypeBool::pools.end() ; ++block )
   29982             :         {
   29983           1 :           pointer = (SgTypeBool*)(*block);
   29984        2001 :           for (unsigned i = 0; i < SgTypeBool::pool_size; ++i )
   29985             :              {
   29986             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   29987             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   29988             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   29989             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   29990             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   29991             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   29992             :             // properly; so this will have to be checked next.
   29993             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   29994             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   29995        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   29996             :                   {
   29997           1 :                     pointer[i].set_freepointer((SgTypeBool*)(globalIndex));
   29998           1 :                     globalIndex++;
   29999             :                   }
   30000             :                else
   30001             :                   {
   30002        1999 :                     pointer[i].set_freepointer(NULL);
   30003             :                   }
   30004             :               }
   30005             :         }
   30006           5 :      return globalIndex;
   30007             :    }
   30008             : 
   30009             : //############################################################################
   30010             : // JH (01/14/2006)
   30011             : void
   30012           5 : SgTypeBool::resetValidFreepointers( )
   30013             :    {
   30014           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   30015           5 :      SgTypeBool* pointer = NULL;
   30016           5 :      std::vector < unsigned char* > :: const_iterator block;
   30017           5 :      SgTypeBool* pointerOfLinkedList = NULL;
   30018           6 :      for ( block = SgTypeBool::pools.begin(); block != SgTypeBool::pools.end() ; ++block )
   30019             :         {
   30020           1 :           pointer = (SgTypeBool*)(*block);
   30021        2001 :           for (unsigned i = 0; i < SgTypeBool::pool_size; ++i )
   30022             :              {
   30023             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   30024             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   30025             :             // memory blocks!.
   30026        2000 :                if ( pointer[i].get_freepointer() != NULL )
   30027             :                   {
   30028           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   30029             :                   }
   30030             :                else
   30031             :                   {
   30032        1999 :                     if ( pointerOfLinkedList == NULL )
   30033             :                        {
   30034           1 :                          SgTypeBool::next_node = &(pointer[i]);
   30035             :                        }
   30036             :                     else
   30037             :                        {
   30038             :                       // printf ("In SgTypeBool::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   30039        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   30040             :                        }
   30041             :                     pointerOfLinkedList = &(pointer[i]);
   30042             :                   }
   30043             :               }
   30044             :         }
   30045             : 
   30046           5 :      if ( pointerOfLinkedList != NULL )
   30047             :         {
   30048             :        // printf ("In SgTypeBool::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   30049           1 :           pointerOfLinkedList->set_freepointer(NULL);
   30050             :        // DQ (6/6/2010): Temporary debugging...
   30051             :        //   ROSE_ASSERT(false);
   30052             :         }
   30053             : 
   30054           5 :      return ;
   30055             :    }
   30056             : 
   30057             : //############################################################################
   30058             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   30059             :  * within the memory pool and resets the freepointers, in order to achieve a 
   30060             :  * linked list, that has no jumps and starts at the beginning! This function 
   30061             :  * does not extend the memory pool, since we do not delete any memory blocks,
   30062             :  * but delete the valid objects.  
   30063             :  */
   30064             : void
   30065           0 : SgTypeBool::clearMemoryPool( )
   30066             :    {
   30067             :   // printf ("Inside of SgTypeBool::clearMemoryPool() \n");
   30068             : 
   30069           0 :      SgTypeBool* pointer = NULL, *tempPointer = NULL;
   30070           0 :      std::vector < unsigned char* > :: const_iterator block;
   30071           0 :      if ( SgTypeBool::pools.empty() == false )
   30072             :         {
   30073           0 :           block = SgTypeBool::pools.begin() ;
   30074           0 :           SgTypeBool::next_node = (SgTypeBool*) (*block);
   30075             : 
   30076           0 :           while ( block != SgTypeBool::pools.end() )
   30077             :              {
   30078           0 :                pointer = (SgTypeBool*) (*block);
   30079           0 :                if ( tempPointer != NULL )
   30080             :                   {
   30081           0 :                     tempPointer->set_freepointer(pointer);
   30082             :                   }
   30083           0 :                for (unsigned i = 0; i < SgTypeBool::pool_size - 1; ++i)
   30084             :                   {
   30085           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   30086             :                   }
   30087           0 :                 pointer[SgTypeBool::pool_size-1].set_freepointer(NULL);
   30088           0 :                 tempPointer = &(pointer[SgTypeBool::pool_size-1]);
   30089           0 :                 ++block;
   30090             :              }
   30091             :         }
   30092           0 :    }
   30093             : 
   30094           5 : void SgTypeBool::deleteMemoryPool() {
   30095           7 :   for (auto p: SgTypeBool::pools) {
   30096           2 :     ROSE_FREE(p);
   30097             :   }
   30098           5 :   SgTypeBool::next_node = nullptr;
   30099           5 :   SgTypeBool::pools.clear();
   30100           5 : }
   30101             : 
   30102             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   30103             : //                 reading multiple binary files to for a single AST.
   30104             : /////////// new version ////////////////////////////////
   30105             : //############################################################################
   30106             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   30107             : void
   30108           2 : SgTypeBool::extendMemoryPoolForFileIO( )
   30109             :   {
   30110           2 :     size_t blockIndex = SgTypeBool::pools.size();
   30111           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeBool) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeBool);
   30112             : 
   30113           3 :     while ( (blockIndex * SgTypeBool::pool_size) < newPoolSize)
   30114             :       {
   30115             : #if ROSE_ALLOC_TRACE
   30116             :         if (blockIndex > 0) {
   30117             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeBool) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeBool) = %" PRIuPTR " SgTypeBool::pool_size = %d \n",
   30118             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeBool),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeBool),SgTypeBool::pool_size);
   30119             :         }
   30120             : #endif
   30121             : 
   30122           1 :         SgTypeBool * pointer = (SgTypeBool*) ROSE_MALLOC ( SgTypeBool::pool_size * sizeof(SgTypeBool) );
   30123           1 :         assert( pointer != NULL );
   30124             : #if ROSE_ALLOC_MEMSET == 1
   30125             :         memset(pointer, 0x00, SgTypeBool::pool_size * sizeof(SgTypeBool));
   30126             : #elif ROSE_ALLOC_MEMSET == 2
   30127             :         memset(pointer, 0xCC, SgTypeBool::pool_size * sizeof(SgTypeBool));
   30128             : #endif
   30129           1 :         SgTypeBool::pools.push_back( (unsigned char*)(pointer) );
   30130           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeBool::pool_size * sizeof(SgTypeBool), V_SgTypeBool ) );
   30131             : 
   30132           1 :         if ( SgTypeBool::next_node != NULL ) {
   30133           0 :           if ( blockIndex > 0 ) {
   30134           0 :             SgTypeBool * blkptr = (SgTypeBool*)(SgTypeBool::pools[blockIndex-1]);
   30135           0 :             blkptr[ SgTypeBool::pool_size - 1 ].set_freepointer(pointer);
   30136             :           }
   30137             :         } else {
   30138           1 :           SgTypeBool::next_node = pointer;
   30139             :         }
   30140             : 
   30141        2000 :         for (unsigned i = 0; i < SgTypeBool::pool_size-1; ++i)
   30142             :            {
   30143        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   30144             :            }
   30145           1 :         pointer[ SgTypeBool::pool_size -1 ].set_freepointer(NULL);
   30146             : 
   30147           1 :         blockIndex++;
   30148             :       }
   30149           2 :   }
   30150             : 
   30151             : //############################################################################
   30152             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   30153             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   30154             :  * not compressed. However, that stuff is not yet implemented! 
   30155             :  */
   30156             : unsigned long
   30157           0 : SgTypeBool::getNumberOfLastValidPointer()
   30158             :    {
   30159           0 :       SgTypeBool* testPointer = (SgTypeBool*)(SgTypeBool::pools.back());
   30160           0 :       unsigned long localIndex = SgTypeBool::pool_size - 1;
   30161           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   30162             :          {
   30163           0 :            localIndex--;
   30164             :          }
   30165           0 :       return (localIndex + SgTypeBool::pool_size * (SgTypeBool::pools.size()-1));
   30166             :    }
   30167             : 
   30168             : //############################################################################
   30169             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   30170             :  * memory pool and initializes the data member in class SgTypeBoolStroageClass
   30171             :  * from its counterpart of SgTypeBool. The return value is just for checking, 
   30172             :  * that the whole StorageClassArray is initialized!
   30173             :  */
   30174             : unsigned long
   30175           1 : SgTypeBool::initializeStorageClassArray( SgTypeBoolStorageClass *storageArray )
   30176             :    {
   30177           1 :      unsigned long storageCounter = 0;
   30178           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeBool::pools.begin();
   30179           1 :      SgTypeBool* pointer = NULL;
   30180           2 :      while ( block != SgTypeBool::pools.end() ) {
   30181           1 :           pointer = (SgTypeBool*) (*block);
   30182        2001 :           for ( unsigned i = 0; i < SgTypeBool::pool_size; ++i ) {
   30183        2000 :                if ( pointer->get_freepointer() != NULL ) {
   30184           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   30185           1 :                  storageArray++;
   30186           1 :                  storageCounter++;
   30187             :                }
   30188        2000 :                pointer++;
   30189             :              }
   30190           1 :            block++;
   30191             :         }
   30192           1 :      return storageCounter;
   30193             :    }
   30194             : 
   30195             : /* #line 30196 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   30196             : 
   30197             : 
   30198             : 
   30199             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   30200             : 
   30201             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   30202             : 
   30203             : //############################################################################
   30204             : /* JH (02/02/2006) Constructor of the IR node SgPointerType that takes its 
   30205             :  * corresponding StorageClass as parameter
   30206             :  */
   30207         655 : SgPointerType :: SgPointerType ( const SgPointerTypeStorageClass& storageSource )   : SgType (storageSource)
   30208             :    {
   30209             : 
   30210             : 
   30211             : /* #line 30212 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   30212             : 
   30213         655 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   30214         655 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   30215             : 
   30216             : 
   30217             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   30218             : 
   30219             : 
   30220         655 :    }
   30221             : 
   30222             : //############################################################################
   30223             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   30224             :  * within the working AST. 
   30225             :  */
   30226       12173 : SgPointerType * SgPointerType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   30227       12173 :      SgPointerType* returnPointer = NULL;
   30228       12173 :      if ( globalIndex != 0 )
   30229             :         {
   30230             : 
   30231             : #if FILE_IO_EXTRA_CHECK
   30232       12173 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPointerType ) ) <= globalIndex ) ;
   30233       12173 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPointerType + 1 ) ) );
   30234             : #endif
   30235       12173 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPointerType )  
   30236       12173 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPointerType );
   30237       12173 :           unsigned long positionInPool = localIndex % SgPointerType::pool_size;
   30238       12173 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPointerType::pool_size;
   30239             : 
   30240             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   30241             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   30242             : 
   30243       12173 :           returnPointer = &( ( (SgPointerType*)(SgPointerType::pools[memoryBlock]) ) [positionInPool]) ;
   30244             : 
   30245       12173 :           ROSE_ASSERT( returnPointer != NULL ) ;
   30246             :         }
   30247       12173 :      return returnPointer ;
   30248             :    }
   30249             : 
   30250             : //############################################################################
   30251             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   30252             :   for the AST with the index astIndex
   30253             : */
   30254           0 : SgPointerType * SgPointerType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   30255           0 :      SgPointerType* returnPointer = NULL;
   30256           0 :      if ( globalIndex != 0 )
   30257             :         {
   30258             : 
   30259             : #if FILE_IO_EXTRA_CHECK
   30260           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPointerType ) ) <= globalIndex ) ;
   30261           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPointerType + 1 ) ) );
   30262             : #endif
   30263           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPointerType )
   30264           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPointerType );
   30265           0 :           unsigned long positionInPool = localIndex % SgPointerType::pool_size ;
   30266           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPointerType::pool_size ;
   30267             : 
   30268             : #if FILE_IO_EXTRA_CHECK
   30269             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   30270             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   30271             : #endif
   30272             : 
   30273           0 :           returnPointer = &( ( (SgPointerType*)(SgPointerType::pools[memoryBlock]) ) [positionInPool]) ;
   30274             : 
   30275             : #if FILE_IO_EXTRA_CHECK
   30276           0 :           assert ( returnPointer != NULL ) ;
   30277             : #endif
   30278             :         }
   30279           0 :      return returnPointer ;
   30280             :    }
   30281             : 
   30282             : //############################################################################
   30283             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   30284             :  * pool size! We set for every valid object in the memory pool the freepointer
   30285             :  * to the global index and increase the global index afterwards. For all the 
   30286             :  * invalid objects (means address ranges within the memory pool that were not
   30287             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   30288             :  * distinguish valid from invalid objects! 
   30289             :  */
   30290             : unsigned long
   30291           5 : SgPointerType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   30292             :    {
   30293           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   30294           5 :      SgPointerType* pointer = NULL;
   30295           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   30296           5 :      std::vector < unsigned char* > :: const_iterator block;
   30297           7 :      for ( block = SgPointerType::pools.begin(); block != SgPointerType::pools.end() ; ++block )
   30298             :         {
   30299           2 :           pointer = (SgPointerType*)(*block);
   30300        4002 :           for (unsigned i = 0; i < SgPointerType::pool_size; ++i )
   30301             :              {
   30302             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   30303             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   30304             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   30305             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   30306             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   30307             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   30308             :             // properly; so this will have to be checked next.
   30309             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   30310             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   30311        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   30312             :                   {
   30313         626 :                     pointer[i].set_freepointer((SgPointerType*)(globalIndex));
   30314         626 :                     globalIndex++;
   30315             :                   }
   30316             :                else
   30317             :                   {
   30318        3374 :                     pointer[i].set_freepointer(NULL);
   30319             :                   }
   30320             :               }
   30321             :         }
   30322           5 :      return globalIndex;
   30323             :    }
   30324             : 
   30325             : //############################################################################
   30326             : // JH (01/14/2006)
   30327             : void
   30328           5 : SgPointerType::resetValidFreepointers( )
   30329             :    {
   30330           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   30331           5 :      SgPointerType* pointer = NULL;
   30332           5 :      std::vector < unsigned char* > :: const_iterator block;
   30333           5 :      SgPointerType* pointerOfLinkedList = NULL;
   30334           7 :      for ( block = SgPointerType::pools.begin(); block != SgPointerType::pools.end() ; ++block )
   30335             :         {
   30336           2 :           pointer = (SgPointerType*)(*block);
   30337        4002 :           for (unsigned i = 0; i < SgPointerType::pool_size; ++i )
   30338             :              {
   30339             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   30340             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   30341             :             // memory blocks!.
   30342        4000 :                if ( pointer[i].get_freepointer() != NULL )
   30343             :                   {
   30344         626 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   30345             :                   }
   30346             :                else
   30347             :                   {
   30348        3374 :                     if ( pointerOfLinkedList == NULL )
   30349             :                        {
   30350           2 :                          SgPointerType::next_node = &(pointer[i]);
   30351             :                        }
   30352             :                     else
   30353             :                        {
   30354             :                       // printf ("In SgPointerType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   30355        3372 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   30356             :                        }
   30357             :                     pointerOfLinkedList = &(pointer[i]);
   30358             :                   }
   30359             :               }
   30360             :         }
   30361             : 
   30362           5 :      if ( pointerOfLinkedList != NULL )
   30363             :         {
   30364             :        // printf ("In SgPointerType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   30365           2 :           pointerOfLinkedList->set_freepointer(NULL);
   30366             :        // DQ (6/6/2010): Temporary debugging...
   30367             :        //   ROSE_ASSERT(false);
   30368             :         }
   30369             : 
   30370           5 :      return ;
   30371             :    }
   30372             : 
   30373             : //############################################################################
   30374             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   30375             :  * within the memory pool and resets the freepointers, in order to achieve a 
   30376             :  * linked list, that has no jumps and starts at the beginning! This function 
   30377             :  * does not extend the memory pool, since we do not delete any memory blocks,
   30378             :  * but delete the valid objects.  
   30379             :  */
   30380             : void
   30381           0 : SgPointerType::clearMemoryPool( )
   30382             :    {
   30383             :   // printf ("Inside of SgPointerType::clearMemoryPool() \n");
   30384             : 
   30385           0 :      SgPointerType* pointer = NULL, *tempPointer = NULL;
   30386           0 :      std::vector < unsigned char* > :: const_iterator block;
   30387           0 :      if ( SgPointerType::pools.empty() == false )
   30388             :         {
   30389           0 :           block = SgPointerType::pools.begin() ;
   30390           0 :           SgPointerType::next_node = (SgPointerType*) (*block);
   30391             : 
   30392           0 :           while ( block != SgPointerType::pools.end() )
   30393             :              {
   30394           0 :                pointer = (SgPointerType*) (*block);
   30395           0 :                if ( tempPointer != NULL )
   30396             :                   {
   30397           0 :                     tempPointer->set_freepointer(pointer);
   30398             :                   }
   30399           0 :                for (unsigned i = 0; i < SgPointerType::pool_size - 1; ++i)
   30400             :                   {
   30401           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   30402             :                   }
   30403           0 :                 pointer[SgPointerType::pool_size-1].set_freepointer(NULL);
   30404           0 :                 tempPointer = &(pointer[SgPointerType::pool_size-1]);
   30405           0 :                 ++block;
   30406             :              }
   30407             :         }
   30408           0 :    }
   30409             : 
   30410           5 : void SgPointerType::deleteMemoryPool() {
   30411           9 :   for (auto p: SgPointerType::pools) {
   30412           4 :     ROSE_FREE(p);
   30413             :   }
   30414           5 :   SgPointerType::next_node = nullptr;
   30415           5 :   SgPointerType::pools.clear();
   30416           5 : }
   30417             : 
   30418             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   30419             : //                 reading multiple binary files to for a single AST.
   30420             : /////////// new version ////////////////////////////////
   30421             : //############################################################################
   30422             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   30423             : void
   30424           2 : SgPointerType::extendMemoryPoolForFileIO( )
   30425             :   {
   30426           2 :     size_t blockIndex = SgPointerType::pools.size();
   30427           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerType);
   30428             : 
   30429           4 :     while ( (blockIndex * SgPointerType::pool_size) < newPoolSize)
   30430             :       {
   30431             : #if ROSE_ALLOC_TRACE
   30432             :         if (blockIndex > 0) {
   30433             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerType) = %" PRIuPTR " SgPointerType::pool_size = %d \n",
   30434             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerType),SgPointerType::pool_size);
   30435             :         }
   30436             : #endif
   30437             : 
   30438           2 :         SgPointerType * pointer = (SgPointerType*) ROSE_MALLOC ( SgPointerType::pool_size * sizeof(SgPointerType) );
   30439           2 :         assert( pointer != NULL );
   30440             : #if ROSE_ALLOC_MEMSET == 1
   30441             :         memset(pointer, 0x00, SgPointerType::pool_size * sizeof(SgPointerType));
   30442             : #elif ROSE_ALLOC_MEMSET == 2
   30443             :         memset(pointer, 0xCC, SgPointerType::pool_size * sizeof(SgPointerType));
   30444             : #endif
   30445           2 :         SgPointerType::pools.push_back( (unsigned char*)(pointer) );
   30446           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPointerType::pool_size * sizeof(SgPointerType), V_SgPointerType ) );
   30447             : 
   30448           2 :         if ( SgPointerType::next_node != NULL ) {
   30449           0 :           if ( blockIndex > 0 ) {
   30450           0 :             SgPointerType * blkptr = (SgPointerType*)(SgPointerType::pools[blockIndex-1]);
   30451           0 :             blkptr[ SgPointerType::pool_size - 1 ].set_freepointer(pointer);
   30452             :           }
   30453             :         } else {
   30454           2 :           SgPointerType::next_node = pointer;
   30455             :         }
   30456             : 
   30457        4000 :         for (unsigned i = 0; i < SgPointerType::pool_size-1; ++i)
   30458             :            {
   30459        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   30460             :            }
   30461           2 :         pointer[ SgPointerType::pool_size -1 ].set_freepointer(NULL);
   30462             : 
   30463           2 :         blockIndex++;
   30464             :       }
   30465           2 :   }
   30466             : 
   30467             : //############################################################################
   30468             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   30469             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   30470             :  * not compressed. However, that stuff is not yet implemented! 
   30471             :  */
   30472             : unsigned long
   30473           0 : SgPointerType::getNumberOfLastValidPointer()
   30474             :    {
   30475           0 :       SgPointerType* testPointer = (SgPointerType*)(SgPointerType::pools.back());
   30476           0 :       unsigned long localIndex = SgPointerType::pool_size - 1;
   30477           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   30478             :          {
   30479           0 :            localIndex--;
   30480             :          }
   30481           0 :       return (localIndex + SgPointerType::pool_size * (SgPointerType::pools.size()-1));
   30482             :    }
   30483             : 
   30484             : //############################################################################
   30485             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   30486             :  * memory pool and initializes the data member in class SgPointerTypeStroageClass
   30487             :  * from its counterpart of SgPointerType. The return value is just for checking, 
   30488             :  * that the whole StorageClassArray is initialized!
   30489             :  */
   30490             : unsigned long
   30491           2 : SgPointerType::initializeStorageClassArray( SgPointerTypeStorageClass *storageArray )
   30492             :    {
   30493           2 :      unsigned long storageCounter = 0;
   30494           2 :      std::vector < unsigned char* > :: const_iterator block = SgPointerType::pools.begin();
   30495           2 :      SgPointerType* pointer = NULL;
   30496           4 :      while ( block != SgPointerType::pools.end() ) {
   30497           2 :           pointer = (SgPointerType*) (*block);
   30498        4002 :           for ( unsigned i = 0; i < SgPointerType::pool_size; ++i ) {
   30499        4000 :                if ( pointer->get_freepointer() != NULL ) {
   30500         626 :                  storageArray->pickOutIRNodeData (pointer) ;
   30501         626 :                  storageArray++;
   30502         626 :                  storageCounter++;
   30503             :                }
   30504        4000 :                pointer++;
   30505             :              }
   30506           2 :            block++;
   30507             :         }
   30508           2 :      return storageCounter;
   30509             :    }
   30510             : 
   30511             : /* #line 30512 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   30512             : 
   30513             : 
   30514             : 
   30515             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   30516             : 
   30517             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   30518             : 
   30519             : //############################################################################
   30520             : /* JH (02/02/2006) Constructor of the IR node SgPointerMemberType that takes its 
   30521             :  * corresponding StorageClass as parameter
   30522             :  */
   30523          29 : SgPointerMemberType :: SgPointerMemberType ( const SgPointerMemberTypeStorageClass& storageSource )   : SgPointerType (storageSource)
   30524             :    {
   30525             : 
   30526             : 
   30527             : /* #line 30528 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   30528             : 
   30529          29 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   30530          29 :      p_class_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_class_type) );
   30531             : 
   30532             : 
   30533             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   30534             : 
   30535             : 
   30536          29 :    }
   30537             : 
   30538             : //############################################################################
   30539             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   30540             :  * within the working AST. 
   30541             :  */
   30542         108 : SgPointerMemberType * SgPointerMemberType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   30543         108 :      SgPointerMemberType* returnPointer = NULL;
   30544         108 :      if ( globalIndex != 0 )
   30545             :         {
   30546             : 
   30547             : #if FILE_IO_EXTRA_CHECK
   30548         108 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPointerMemberType ) ) <= globalIndex ) ;
   30549         108 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPointerMemberType + 1 ) ) );
   30550             : #endif
   30551         108 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPointerMemberType )  
   30552         108 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPointerMemberType );
   30553         108 :           unsigned long positionInPool = localIndex % SgPointerMemberType::pool_size;
   30554         108 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPointerMemberType::pool_size;
   30555             : 
   30556             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   30557             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   30558             : 
   30559         108 :           returnPointer = &( ( (SgPointerMemberType*)(SgPointerMemberType::pools[memoryBlock]) ) [positionInPool]) ;
   30560             : 
   30561         108 :           ROSE_ASSERT( returnPointer != NULL ) ;
   30562             :         }
   30563         108 :      return returnPointer ;
   30564             :    }
   30565             : 
   30566             : //############################################################################
   30567             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   30568             :   for the AST with the index astIndex
   30569             : */
   30570           0 : SgPointerMemberType * SgPointerMemberType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   30571           0 :      SgPointerMemberType* returnPointer = NULL;
   30572           0 :      if ( globalIndex != 0 )
   30573             :         {
   30574             : 
   30575             : #if FILE_IO_EXTRA_CHECK
   30576           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPointerMemberType ) ) <= globalIndex ) ;
   30577           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPointerMemberType + 1 ) ) );
   30578             : #endif
   30579           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPointerMemberType )
   30580           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPointerMemberType );
   30581           0 :           unsigned long positionInPool = localIndex % SgPointerMemberType::pool_size ;
   30582           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPointerMemberType::pool_size ;
   30583             : 
   30584             : #if FILE_IO_EXTRA_CHECK
   30585             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   30586             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   30587             : #endif
   30588             : 
   30589           0 :           returnPointer = &( ( (SgPointerMemberType*)(SgPointerMemberType::pools[memoryBlock]) ) [positionInPool]) ;
   30590             : 
   30591             : #if FILE_IO_EXTRA_CHECK
   30592           0 :           assert ( returnPointer != NULL ) ;
   30593             : #endif
   30594             :         }
   30595           0 :      return returnPointer ;
   30596             :    }
   30597             : 
   30598             : //############################################################################
   30599             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   30600             :  * pool size! We set for every valid object in the memory pool the freepointer
   30601             :  * to the global index and increase the global index afterwards. For all the 
   30602             :  * invalid objects (means address ranges within the memory pool that were not
   30603             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   30604             :  * distinguish valid from invalid objects! 
   30605             :  */
   30606             : unsigned long
   30607           5 : SgPointerMemberType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   30608             :    {
   30609           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   30610           5 :      SgPointerMemberType* pointer = NULL;
   30611           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   30612           5 :      std::vector < unsigned char* > :: const_iterator block;
   30613           6 :      for ( block = SgPointerMemberType::pools.begin(); block != SgPointerMemberType::pools.end() ; ++block )
   30614             :         {
   30615           1 :           pointer = (SgPointerMemberType*)(*block);
   30616        2001 :           for (unsigned i = 0; i < SgPointerMemberType::pool_size; ++i )
   30617             :              {
   30618             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   30619             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   30620             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   30621             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   30622             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   30623             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   30624             :             // properly; so this will have to be checked next.
   30625             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   30626             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   30627        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   30628             :                   {
   30629          29 :                     pointer[i].set_freepointer((SgPointerMemberType*)(globalIndex));
   30630          29 :                     globalIndex++;
   30631             :                   }
   30632             :                else
   30633             :                   {
   30634        1971 :                     pointer[i].set_freepointer(NULL);
   30635             :                   }
   30636             :               }
   30637             :         }
   30638           5 :      return globalIndex;
   30639             :    }
   30640             : 
   30641             : //############################################################################
   30642             : // JH (01/14/2006)
   30643             : void
   30644           5 : SgPointerMemberType::resetValidFreepointers( )
   30645             :    {
   30646           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   30647           5 :      SgPointerMemberType* pointer = NULL;
   30648           5 :      std::vector < unsigned char* > :: const_iterator block;
   30649           5 :      SgPointerMemberType* pointerOfLinkedList = NULL;
   30650           6 :      for ( block = SgPointerMemberType::pools.begin(); block != SgPointerMemberType::pools.end() ; ++block )
   30651             :         {
   30652           1 :           pointer = (SgPointerMemberType*)(*block);
   30653        2001 :           for (unsigned i = 0; i < SgPointerMemberType::pool_size; ++i )
   30654             :              {
   30655             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   30656             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   30657             :             // memory blocks!.
   30658        2000 :                if ( pointer[i].get_freepointer() != NULL )
   30659             :                   {
   30660          29 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   30661             :                   }
   30662             :                else
   30663             :                   {
   30664        1971 :                     if ( pointerOfLinkedList == NULL )
   30665             :                        {
   30666           1 :                          SgPointerMemberType::next_node = &(pointer[i]);
   30667             :                        }
   30668             :                     else
   30669             :                        {
   30670             :                       // printf ("In SgPointerMemberType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   30671        1970 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   30672             :                        }
   30673             :                     pointerOfLinkedList = &(pointer[i]);
   30674             :                   }
   30675             :               }
   30676             :         }
   30677             : 
   30678           5 :      if ( pointerOfLinkedList != NULL )
   30679             :         {
   30680             :        // printf ("In SgPointerMemberType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   30681           1 :           pointerOfLinkedList->set_freepointer(NULL);
   30682             :        // DQ (6/6/2010): Temporary debugging...
   30683             :        //   ROSE_ASSERT(false);
   30684             :         }
   30685             : 
   30686           5 :      return ;
   30687             :    }
   30688             : 
   30689             : //############################################################################
   30690             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   30691             :  * within the memory pool and resets the freepointers, in order to achieve a 
   30692             :  * linked list, that has no jumps and starts at the beginning! This function 
   30693             :  * does not extend the memory pool, since we do not delete any memory blocks,
   30694             :  * but delete the valid objects.  
   30695             :  */
   30696             : void
   30697           0 : SgPointerMemberType::clearMemoryPool( )
   30698             :    {
   30699             :   // printf ("Inside of SgPointerMemberType::clearMemoryPool() \n");
   30700             : 
   30701           0 :      SgPointerMemberType* pointer = NULL, *tempPointer = NULL;
   30702           0 :      std::vector < unsigned char* > :: const_iterator block;
   30703           0 :      if ( SgPointerMemberType::pools.empty() == false )
   30704             :         {
   30705           0 :           block = SgPointerMemberType::pools.begin() ;
   30706           0 :           SgPointerMemberType::next_node = (SgPointerMemberType*) (*block);
   30707             : 
   30708           0 :           while ( block != SgPointerMemberType::pools.end() )
   30709             :              {
   30710           0 :                pointer = (SgPointerMemberType*) (*block);
   30711           0 :                if ( tempPointer != NULL )
   30712             :                   {
   30713           0 :                     tempPointer->set_freepointer(pointer);
   30714             :                   }
   30715           0 :                for (unsigned i = 0; i < SgPointerMemberType::pool_size - 1; ++i)
   30716             :                   {
   30717           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   30718             :                   }
   30719           0 :                 pointer[SgPointerMemberType::pool_size-1].set_freepointer(NULL);
   30720           0 :                 tempPointer = &(pointer[SgPointerMemberType::pool_size-1]);
   30721           0 :                 ++block;
   30722             :              }
   30723             :         }
   30724           0 :    }
   30725             : 
   30726           5 : void SgPointerMemberType::deleteMemoryPool() {
   30727           7 :   for (auto p: SgPointerMemberType::pools) {
   30728           2 :     ROSE_FREE(p);
   30729             :   }
   30730           5 :   SgPointerMemberType::next_node = nullptr;
   30731           5 :   SgPointerMemberType::pools.clear();
   30732           5 : }
   30733             : 
   30734             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   30735             : //                 reading multiple binary files to for a single AST.
   30736             : /////////// new version ////////////////////////////////
   30737             : //############################################################################
   30738             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   30739             : void
   30740           2 : SgPointerMemberType::extendMemoryPoolForFileIO( )
   30741             :   {
   30742           2 :     size_t blockIndex = SgPointerMemberType::pools.size();
   30743           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerMemberType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerMemberType);
   30744             : 
   30745           3 :     while ( (blockIndex * SgPointerMemberType::pool_size) < newPoolSize)
   30746             :       {
   30747             : #if ROSE_ALLOC_TRACE
   30748             :         if (blockIndex > 0) {
   30749             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerMemberType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerMemberType) = %" PRIuPTR " SgPointerMemberType::pool_size = %d \n",
   30750             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerMemberType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerMemberType),SgPointerMemberType::pool_size);
   30751             :         }
   30752             : #endif
   30753             : 
   30754           1 :         SgPointerMemberType * pointer = (SgPointerMemberType*) ROSE_MALLOC ( SgPointerMemberType::pool_size * sizeof(SgPointerMemberType) );
   30755           1 :         assert( pointer != NULL );
   30756             : #if ROSE_ALLOC_MEMSET == 1
   30757             :         memset(pointer, 0x00, SgPointerMemberType::pool_size * sizeof(SgPointerMemberType));
   30758             : #elif ROSE_ALLOC_MEMSET == 2
   30759             :         memset(pointer, 0xCC, SgPointerMemberType::pool_size * sizeof(SgPointerMemberType));
   30760             : #endif
   30761           1 :         SgPointerMemberType::pools.push_back( (unsigned char*)(pointer) );
   30762           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPointerMemberType::pool_size * sizeof(SgPointerMemberType), V_SgPointerMemberType ) );
   30763             : 
   30764           1 :         if ( SgPointerMemberType::next_node != NULL ) {
   30765           0 :           if ( blockIndex > 0 ) {
   30766           0 :             SgPointerMemberType * blkptr = (SgPointerMemberType*)(SgPointerMemberType::pools[blockIndex-1]);
   30767           0 :             blkptr[ SgPointerMemberType::pool_size - 1 ].set_freepointer(pointer);
   30768             :           }
   30769             :         } else {
   30770           1 :           SgPointerMemberType::next_node = pointer;
   30771             :         }
   30772             : 
   30773        2000 :         for (unsigned i = 0; i < SgPointerMemberType::pool_size-1; ++i)
   30774             :            {
   30775        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   30776             :            }
   30777           1 :         pointer[ SgPointerMemberType::pool_size -1 ].set_freepointer(NULL);
   30778             : 
   30779           1 :         blockIndex++;
   30780             :       }
   30781           2 :   }
   30782             : 
   30783             : //############################################################################
   30784             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   30785             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   30786             :  * not compressed. However, that stuff is not yet implemented! 
   30787             :  */
   30788             : unsigned long
   30789           0 : SgPointerMemberType::getNumberOfLastValidPointer()
   30790             :    {
   30791           0 :       SgPointerMemberType* testPointer = (SgPointerMemberType*)(SgPointerMemberType::pools.back());
   30792           0 :       unsigned long localIndex = SgPointerMemberType::pool_size - 1;
   30793           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   30794             :          {
   30795           0 :            localIndex--;
   30796             :          }
   30797           0 :       return (localIndex + SgPointerMemberType::pool_size * (SgPointerMemberType::pools.size()-1));
   30798             :    }
   30799             : 
   30800             : //############################################################################
   30801             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   30802             :  * memory pool and initializes the data member in class SgPointerMemberTypeStroageClass
   30803             :  * from its counterpart of SgPointerMemberType. The return value is just for checking, 
   30804             :  * that the whole StorageClassArray is initialized!
   30805             :  */
   30806             : unsigned long
   30807           1 : SgPointerMemberType::initializeStorageClassArray( SgPointerMemberTypeStorageClass *storageArray )
   30808             :    {
   30809           1 :      unsigned long storageCounter = 0;
   30810           1 :      std::vector < unsigned char* > :: const_iterator block = SgPointerMemberType::pools.begin();
   30811           1 :      SgPointerMemberType* pointer = NULL;
   30812           2 :      while ( block != SgPointerMemberType::pools.end() ) {
   30813           1 :           pointer = (SgPointerMemberType*) (*block);
   30814        2001 :           for ( unsigned i = 0; i < SgPointerMemberType::pool_size; ++i ) {
   30815        2000 :                if ( pointer->get_freepointer() != NULL ) {
   30816          29 :                  storageArray->pickOutIRNodeData (pointer) ;
   30817          29 :                  storageArray++;
   30818          29 :                  storageCounter++;
   30819             :                }
   30820        2000 :                pointer++;
   30821             :              }
   30822           1 :            block++;
   30823             :         }
   30824           1 :      return storageCounter;
   30825             :    }
   30826             : 
   30827             : /* #line 30828 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   30828             : 
   30829             : 
   30830             : 
   30831             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   30832             : 
   30833             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   30834             : 
   30835             : //############################################################################
   30836             : /* JH (02/02/2006) Constructor of the IR node SgReferenceType that takes its 
   30837             :  * corresponding StorageClass as parameter
   30838             :  */
   30839         724 : SgReferenceType :: SgReferenceType ( const SgReferenceTypeStorageClass& storageSource )   : SgType (storageSource)
   30840             :    {
   30841             : 
   30842             : 
   30843             : /* #line 30844 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   30844             : 
   30845         724 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   30846         724 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   30847             : 
   30848             : 
   30849             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   30850             : 
   30851             : 
   30852         724 :    }
   30853             : 
   30854             : //############################################################################
   30855             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   30856             :  * within the working AST. 
   30857             :  */
   30858        9624 : SgReferenceType * SgReferenceType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   30859        9624 :      SgReferenceType* returnPointer = NULL;
   30860        9624 :      if ( globalIndex != 0 )
   30861             :         {
   30862             : 
   30863             : #if FILE_IO_EXTRA_CHECK
   30864        9624 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgReferenceType ) ) <= globalIndex ) ;
   30865        9624 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgReferenceType + 1 ) ) );
   30866             : #endif
   30867        9624 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgReferenceType )  
   30868        9624 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgReferenceType );
   30869        9624 :           unsigned long positionInPool = localIndex % SgReferenceType::pool_size;
   30870        9624 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgReferenceType::pool_size;
   30871             : 
   30872             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   30873             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   30874             : 
   30875        9624 :           returnPointer = &( ( (SgReferenceType*)(SgReferenceType::pools[memoryBlock]) ) [positionInPool]) ;
   30876             : 
   30877        9624 :           ROSE_ASSERT( returnPointer != NULL ) ;
   30878             :         }
   30879        9624 :      return returnPointer ;
   30880             :    }
   30881             : 
   30882             : //############################################################################
   30883             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   30884             :   for the AST with the index astIndex
   30885             : */
   30886           0 : SgReferenceType * SgReferenceType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   30887           0 :      SgReferenceType* returnPointer = NULL;
   30888           0 :      if ( globalIndex != 0 )
   30889             :         {
   30890             : 
   30891             : #if FILE_IO_EXTRA_CHECK
   30892           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgReferenceType ) ) <= globalIndex ) ;
   30893           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgReferenceType + 1 ) ) );
   30894             : #endif
   30895           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgReferenceType )
   30896           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgReferenceType );
   30897           0 :           unsigned long positionInPool = localIndex % SgReferenceType::pool_size ;
   30898           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgReferenceType::pool_size ;
   30899             : 
   30900             : #if FILE_IO_EXTRA_CHECK
   30901             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   30902             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   30903             : #endif
   30904             : 
   30905           0 :           returnPointer = &( ( (SgReferenceType*)(SgReferenceType::pools[memoryBlock]) ) [positionInPool]) ;
   30906             : 
   30907             : #if FILE_IO_EXTRA_CHECK
   30908           0 :           assert ( returnPointer != NULL ) ;
   30909             : #endif
   30910             :         }
   30911           0 :      return returnPointer ;
   30912             :    }
   30913             : 
   30914             : //############################################################################
   30915             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   30916             :  * pool size! We set for every valid object in the memory pool the freepointer
   30917             :  * to the global index and increase the global index afterwards. For all the 
   30918             :  * invalid objects (means address ranges within the memory pool that were not
   30919             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   30920             :  * distinguish valid from invalid objects! 
   30921             :  */
   30922             : unsigned long
   30923           5 : SgReferenceType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   30924             :    {
   30925           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   30926           5 :      SgReferenceType* pointer = NULL;
   30927           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   30928           5 :      std::vector < unsigned char* > :: const_iterator block;
   30929           6 :      for ( block = SgReferenceType::pools.begin(); block != SgReferenceType::pools.end() ; ++block )
   30930             :         {
   30931           1 :           pointer = (SgReferenceType*)(*block);
   30932        2001 :           for (unsigned i = 0; i < SgReferenceType::pool_size; ++i )
   30933             :              {
   30934             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   30935             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   30936             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   30937             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   30938             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   30939             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   30940             :             // properly; so this will have to be checked next.
   30941             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   30942             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   30943        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   30944             :                   {
   30945         724 :                     pointer[i].set_freepointer((SgReferenceType*)(globalIndex));
   30946         724 :                     globalIndex++;
   30947             :                   }
   30948             :                else
   30949             :                   {
   30950        1276 :                     pointer[i].set_freepointer(NULL);
   30951             :                   }
   30952             :               }
   30953             :         }
   30954           5 :      return globalIndex;
   30955             :    }
   30956             : 
   30957             : //############################################################################
   30958             : // JH (01/14/2006)
   30959             : void
   30960           5 : SgReferenceType::resetValidFreepointers( )
   30961             :    {
   30962           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   30963           5 :      SgReferenceType* pointer = NULL;
   30964           5 :      std::vector < unsigned char* > :: const_iterator block;
   30965           5 :      SgReferenceType* pointerOfLinkedList = NULL;
   30966           6 :      for ( block = SgReferenceType::pools.begin(); block != SgReferenceType::pools.end() ; ++block )
   30967             :         {
   30968           1 :           pointer = (SgReferenceType*)(*block);
   30969        2001 :           for (unsigned i = 0; i < SgReferenceType::pool_size; ++i )
   30970             :              {
   30971             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   30972             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   30973             :             // memory blocks!.
   30974        2000 :                if ( pointer[i].get_freepointer() != NULL )
   30975             :                   {
   30976         724 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   30977             :                   }
   30978             :                else
   30979             :                   {
   30980        1276 :                     if ( pointerOfLinkedList == NULL )
   30981             :                        {
   30982           1 :                          SgReferenceType::next_node = &(pointer[i]);
   30983             :                        }
   30984             :                     else
   30985             :                        {
   30986             :                       // printf ("In SgReferenceType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   30987        1275 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   30988             :                        }
   30989             :                     pointerOfLinkedList = &(pointer[i]);
   30990             :                   }
   30991             :               }
   30992             :         }
   30993             : 
   30994           5 :      if ( pointerOfLinkedList != NULL )
   30995             :         {
   30996             :        // printf ("In SgReferenceType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   30997           1 :           pointerOfLinkedList->set_freepointer(NULL);
   30998             :        // DQ (6/6/2010): Temporary debugging...
   30999             :        //   ROSE_ASSERT(false);
   31000             :         }
   31001             : 
   31002           5 :      return ;
   31003             :    }
   31004             : 
   31005             : //############################################################################
   31006             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   31007             :  * within the memory pool and resets the freepointers, in order to achieve a 
   31008             :  * linked list, that has no jumps and starts at the beginning! This function 
   31009             :  * does not extend the memory pool, since we do not delete any memory blocks,
   31010             :  * but delete the valid objects.  
   31011             :  */
   31012             : void
   31013           0 : SgReferenceType::clearMemoryPool( )
   31014             :    {
   31015             :   // printf ("Inside of SgReferenceType::clearMemoryPool() \n");
   31016             : 
   31017           0 :      SgReferenceType* pointer = NULL, *tempPointer = NULL;
   31018           0 :      std::vector < unsigned char* > :: const_iterator block;
   31019           0 :      if ( SgReferenceType::pools.empty() == false )
   31020             :         {
   31021           0 :           block = SgReferenceType::pools.begin() ;
   31022           0 :           SgReferenceType::next_node = (SgReferenceType*) (*block);
   31023             : 
   31024           0 :           while ( block != SgReferenceType::pools.end() )
   31025             :              {
   31026           0 :                pointer = (SgReferenceType*) (*block);
   31027           0 :                if ( tempPointer != NULL )
   31028             :                   {
   31029           0 :                     tempPointer->set_freepointer(pointer);
   31030             :                   }
   31031           0 :                for (unsigned i = 0; i < SgReferenceType::pool_size - 1; ++i)
   31032             :                   {
   31033           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   31034             :                   }
   31035           0 :                 pointer[SgReferenceType::pool_size-1].set_freepointer(NULL);
   31036           0 :                 tempPointer = &(pointer[SgReferenceType::pool_size-1]);
   31037           0 :                 ++block;
   31038             :              }
   31039             :         }
   31040           0 :    }
   31041             : 
   31042           5 : void SgReferenceType::deleteMemoryPool() {
   31043           7 :   for (auto p: SgReferenceType::pools) {
   31044           2 :     ROSE_FREE(p);
   31045             :   }
   31046           5 :   SgReferenceType::next_node = nullptr;
   31047           5 :   SgReferenceType::pools.clear();
   31048           5 : }
   31049             : 
   31050             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   31051             : //                 reading multiple binary files to for a single AST.
   31052             : /////////// new version ////////////////////////////////
   31053             : //############################################################################
   31054             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   31055             : void
   31056           2 : SgReferenceType::extendMemoryPoolForFileIO( )
   31057             :   {
   31058           2 :     size_t blockIndex = SgReferenceType::pools.size();
   31059           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgReferenceType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgReferenceType);
   31060             : 
   31061           3 :     while ( (blockIndex * SgReferenceType::pool_size) < newPoolSize)
   31062             :       {
   31063             : #if ROSE_ALLOC_TRACE
   31064             :         if (blockIndex > 0) {
   31065             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgReferenceType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgReferenceType) = %" PRIuPTR " SgReferenceType::pool_size = %d \n",
   31066             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgReferenceType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgReferenceType),SgReferenceType::pool_size);
   31067             :         }
   31068             : #endif
   31069             : 
   31070           1 :         SgReferenceType * pointer = (SgReferenceType*) ROSE_MALLOC ( SgReferenceType::pool_size * sizeof(SgReferenceType) );
   31071           1 :         assert( pointer != NULL );
   31072             : #if ROSE_ALLOC_MEMSET == 1
   31073             :         memset(pointer, 0x00, SgReferenceType::pool_size * sizeof(SgReferenceType));
   31074             : #elif ROSE_ALLOC_MEMSET == 2
   31075             :         memset(pointer, 0xCC, SgReferenceType::pool_size * sizeof(SgReferenceType));
   31076             : #endif
   31077           1 :         SgReferenceType::pools.push_back( (unsigned char*)(pointer) );
   31078           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgReferenceType::pool_size * sizeof(SgReferenceType), V_SgReferenceType ) );
   31079             : 
   31080           1 :         if ( SgReferenceType::next_node != NULL ) {
   31081           0 :           if ( blockIndex > 0 ) {
   31082           0 :             SgReferenceType * blkptr = (SgReferenceType*)(SgReferenceType::pools[blockIndex-1]);
   31083           0 :             blkptr[ SgReferenceType::pool_size - 1 ].set_freepointer(pointer);
   31084             :           }
   31085             :         } else {
   31086           1 :           SgReferenceType::next_node = pointer;
   31087             :         }
   31088             : 
   31089        2000 :         for (unsigned i = 0; i < SgReferenceType::pool_size-1; ++i)
   31090             :            {
   31091        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   31092             :            }
   31093           1 :         pointer[ SgReferenceType::pool_size -1 ].set_freepointer(NULL);
   31094             : 
   31095           1 :         blockIndex++;
   31096             :       }
   31097           2 :   }
   31098             : 
   31099             : //############################################################################
   31100             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   31101             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   31102             :  * not compressed. However, that stuff is not yet implemented! 
   31103             :  */
   31104             : unsigned long
   31105           0 : SgReferenceType::getNumberOfLastValidPointer()
   31106             :    {
   31107           0 :       SgReferenceType* testPointer = (SgReferenceType*)(SgReferenceType::pools.back());
   31108           0 :       unsigned long localIndex = SgReferenceType::pool_size - 1;
   31109           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   31110             :          {
   31111           0 :            localIndex--;
   31112             :          }
   31113           0 :       return (localIndex + SgReferenceType::pool_size * (SgReferenceType::pools.size()-1));
   31114             :    }
   31115             : 
   31116             : //############################################################################
   31117             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   31118             :  * memory pool and initializes the data member in class SgReferenceTypeStroageClass
   31119             :  * from its counterpart of SgReferenceType. The return value is just for checking, 
   31120             :  * that the whole StorageClassArray is initialized!
   31121             :  */
   31122             : unsigned long
   31123           1 : SgReferenceType::initializeStorageClassArray( SgReferenceTypeStorageClass *storageArray )
   31124             :    {
   31125           1 :      unsigned long storageCounter = 0;
   31126           1 :      std::vector < unsigned char* > :: const_iterator block = SgReferenceType::pools.begin();
   31127           1 :      SgReferenceType* pointer = NULL;
   31128           2 :      while ( block != SgReferenceType::pools.end() ) {
   31129           1 :           pointer = (SgReferenceType*) (*block);
   31130        2001 :           for ( unsigned i = 0; i < SgReferenceType::pool_size; ++i ) {
   31131        2000 :                if ( pointer->get_freepointer() != NULL ) {
   31132         724 :                  storageArray->pickOutIRNodeData (pointer) ;
   31133         724 :                  storageArray++;
   31134         724 :                  storageCounter++;
   31135             :                }
   31136        2000 :                pointer++;
   31137             :              }
   31138           1 :            block++;
   31139             :         }
   31140           1 :      return storageCounter;
   31141             :    }
   31142             : 
   31143             : /* #line 31144 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   31144             : 
   31145             : 
   31146             : 
   31147             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   31148             : 
   31149             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   31150             : 
   31151             : //############################################################################
   31152             : /* JH (02/02/2006) Constructor of the IR node SgNamedType that takes its 
   31153             :  * corresponding StorageClass as parameter
   31154             :  */
   31155        8416 : SgNamedType :: SgNamedType ( const SgNamedTypeStorageClass& storageSource )   : SgType (storageSource)
   31156             :    {
   31157             : 
   31158             : 
   31159             : /* #line 31160 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   31160             : 
   31161        8416 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   31162        8416 :      p_declaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
   31163        8416 :      p_autonomous_declaration = storageSource.storageOf_autonomous_declaration ;
   31164        8416 :      p_is_from_template_parameter = storageSource.storageOf_is_from_template_parameter ;
   31165             : 
   31166             : 
   31167             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   31168             : 
   31169             : 
   31170        8416 :    }
   31171             : 
   31172             : //############################################################################
   31173             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   31174             :  * within the working AST. 
   31175             :  */
   31176           0 : SgNamedType * SgNamedType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   31177           0 :      SgNamedType* returnPointer = NULL;
   31178           0 :      if ( globalIndex != 0 )
   31179             :         {
   31180             : 
   31181             : #if FILE_IO_EXTRA_CHECK
   31182           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNamedType ) ) <= globalIndex ) ;
   31183           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamedType + 1 ) ) );
   31184             : #endif
   31185           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamedType )  
   31186           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNamedType );
   31187           0 :           unsigned long positionInPool = localIndex % SgNamedType::pool_size;
   31188           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamedType::pool_size;
   31189             : 
   31190             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   31191             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   31192             : 
   31193           0 :           returnPointer = &( ( (SgNamedType*)(SgNamedType::pools[memoryBlock]) ) [positionInPool]) ;
   31194             : 
   31195           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   31196             :         }
   31197           0 :      return returnPointer ;
   31198             :    }
   31199             : 
   31200             : //############################################################################
   31201             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   31202             :   for the AST with the index astIndex
   31203             : */
   31204           0 : SgNamedType * SgNamedType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   31205           0 :      SgNamedType* returnPointer = NULL;
   31206           0 :      if ( globalIndex != 0 )
   31207             :         {
   31208             : 
   31209             : #if FILE_IO_EXTRA_CHECK
   31210           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNamedType ) ) <= globalIndex ) ;
   31211           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamedType + 1 ) ) );
   31212             : #endif
   31213           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamedType )
   31214           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNamedType );
   31215           0 :           unsigned long positionInPool = localIndex % SgNamedType::pool_size ;
   31216           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamedType::pool_size ;
   31217             : 
   31218             : #if FILE_IO_EXTRA_CHECK
   31219             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   31220             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   31221             : #endif
   31222             : 
   31223           0 :           returnPointer = &( ( (SgNamedType*)(SgNamedType::pools[memoryBlock]) ) [positionInPool]) ;
   31224             : 
   31225             : #if FILE_IO_EXTRA_CHECK
   31226           0 :           assert ( returnPointer != NULL ) ;
   31227             : #endif
   31228             :         }
   31229           0 :      return returnPointer ;
   31230             :    }
   31231             : 
   31232             : //############################################################################
   31233             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   31234             :  * pool size! We set for every valid object in the memory pool the freepointer
   31235             :  * to the global index and increase the global index afterwards. For all the 
   31236             :  * invalid objects (means address ranges within the memory pool that were not
   31237             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   31238             :  * distinguish valid from invalid objects! 
   31239             :  */
   31240             : unsigned long
   31241           5 : SgNamedType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   31242             :    {
   31243           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   31244           5 :      SgNamedType* pointer = NULL;
   31245           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   31246           5 :      std::vector < unsigned char* > :: const_iterator block;
   31247           5 :      for ( block = SgNamedType::pools.begin(); block != SgNamedType::pools.end() ; ++block )
   31248             :         {
   31249           0 :           pointer = (SgNamedType*)(*block);
   31250           0 :           for (unsigned i = 0; i < SgNamedType::pool_size; ++i )
   31251             :              {
   31252             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   31253             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   31254             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   31255             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   31256             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   31257             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   31258             :             // properly; so this will have to be checked next.
   31259             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   31260             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   31261           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   31262             :                   {
   31263           0 :                     pointer[i].set_freepointer((SgNamedType*)(globalIndex));
   31264           0 :                     globalIndex++;
   31265             :                   }
   31266             :                else
   31267             :                   {
   31268           0 :                     pointer[i].set_freepointer(NULL);
   31269             :                   }
   31270             :               }
   31271             :         }
   31272           5 :      return globalIndex;
   31273             :    }
   31274             : 
   31275             : //############################################################################
   31276             : // JH (01/14/2006)
   31277             : void
   31278           5 : SgNamedType::resetValidFreepointers( )
   31279             :    {
   31280           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   31281           5 :      SgNamedType* pointer = NULL;
   31282           5 :      std::vector < unsigned char* > :: const_iterator block;
   31283           5 :      SgNamedType* pointerOfLinkedList = NULL;
   31284           5 :      for ( block = SgNamedType::pools.begin(); block != SgNamedType::pools.end() ; ++block )
   31285             :         {
   31286           0 :           pointer = (SgNamedType*)(*block);
   31287           0 :           for (unsigned i = 0; i < SgNamedType::pool_size; ++i )
   31288             :              {
   31289             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   31290             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   31291             :             // memory blocks!.
   31292           0 :                if ( pointer[i].get_freepointer() != NULL )
   31293             :                   {
   31294           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   31295             :                   }
   31296             :                else
   31297             :                   {
   31298           0 :                     if ( pointerOfLinkedList == NULL )
   31299             :                        {
   31300           0 :                          SgNamedType::next_node = &(pointer[i]);
   31301             :                        }
   31302             :                     else
   31303             :                        {
   31304             :                       // printf ("In SgNamedType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   31305           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   31306             :                        }
   31307             :                     pointerOfLinkedList = &(pointer[i]);
   31308             :                   }
   31309             :               }
   31310             :         }
   31311             : 
   31312           5 :      if ( pointerOfLinkedList != NULL )
   31313             :         {
   31314             :        // printf ("In SgNamedType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   31315           0 :           pointerOfLinkedList->set_freepointer(NULL);
   31316             :        // DQ (6/6/2010): Temporary debugging...
   31317             :        //   ROSE_ASSERT(false);
   31318             :         }
   31319             : 
   31320           5 :      return ;
   31321             :    }
   31322             : 
   31323             : //############################################################################
   31324             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   31325             :  * within the memory pool and resets the freepointers, in order to achieve a 
   31326             :  * linked list, that has no jumps and starts at the beginning! This function 
   31327             :  * does not extend the memory pool, since we do not delete any memory blocks,
   31328             :  * but delete the valid objects.  
   31329             :  */
   31330             : void
   31331           0 : SgNamedType::clearMemoryPool( )
   31332             :    {
   31333             :   // printf ("Inside of SgNamedType::clearMemoryPool() \n");
   31334             : 
   31335           0 :      SgNamedType* pointer = NULL, *tempPointer = NULL;
   31336           0 :      std::vector < unsigned char* > :: const_iterator block;
   31337           0 :      if ( SgNamedType::pools.empty() == false )
   31338             :         {
   31339           0 :           block = SgNamedType::pools.begin() ;
   31340           0 :           SgNamedType::next_node = (SgNamedType*) (*block);
   31341             : 
   31342           0 :           while ( block != SgNamedType::pools.end() )
   31343             :              {
   31344           0 :                pointer = (SgNamedType*) (*block);
   31345           0 :                if ( tempPointer != NULL )
   31346             :                   {
   31347           0 :                     tempPointer->set_freepointer(pointer);
   31348             :                   }
   31349           0 :                for (unsigned i = 0; i < SgNamedType::pool_size - 1; ++i)
   31350             :                   {
   31351           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   31352             :                   }
   31353           0 :                 pointer[SgNamedType::pool_size-1].set_freepointer(NULL);
   31354           0 :                 tempPointer = &(pointer[SgNamedType::pool_size-1]);
   31355           0 :                 ++block;
   31356             :              }
   31357             :         }
   31358           0 :    }
   31359             : 
   31360           5 : void SgNamedType::deleteMemoryPool() {
   31361           5 :   for (auto p: SgNamedType::pools) {
   31362           0 :     ROSE_FREE(p);
   31363             :   }
   31364           5 :   SgNamedType::next_node = nullptr;
   31365           5 :   SgNamedType::pools.clear();
   31366           5 : }
   31367             : 
   31368             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   31369             : //                 reading multiple binary files to for a single AST.
   31370             : /////////// new version ////////////////////////////////
   31371             : //############################################################################
   31372             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   31373             : void
   31374           2 : SgNamedType::extendMemoryPoolForFileIO( )
   31375             :   {
   31376           2 :     size_t blockIndex = SgNamedType::pools.size();
   31377           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNamedType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamedType);
   31378             : 
   31379           2 :     while ( (blockIndex * SgNamedType::pool_size) < newPoolSize)
   31380             :       {
   31381             : #if ROSE_ALLOC_TRACE
   31382             :         if (blockIndex > 0) {
   31383             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNamedType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamedType) = %" PRIuPTR " SgNamedType::pool_size = %d \n",
   31384             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNamedType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamedType),SgNamedType::pool_size);
   31385             :         }
   31386             : #endif
   31387             : 
   31388           0 :         SgNamedType * pointer = (SgNamedType*) ROSE_MALLOC ( SgNamedType::pool_size * sizeof(SgNamedType) );
   31389           0 :         assert( pointer != NULL );
   31390             : #if ROSE_ALLOC_MEMSET == 1
   31391             :         memset(pointer, 0x00, SgNamedType::pool_size * sizeof(SgNamedType));
   31392             : #elif ROSE_ALLOC_MEMSET == 2
   31393             :         memset(pointer, 0xCC, SgNamedType::pool_size * sizeof(SgNamedType));
   31394             : #endif
   31395           0 :         SgNamedType::pools.push_back( (unsigned char*)(pointer) );
   31396           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNamedType::pool_size * sizeof(SgNamedType), V_SgNamedType ) );
   31397             : 
   31398           0 :         if ( SgNamedType::next_node != NULL ) {
   31399           0 :           if ( blockIndex > 0 ) {
   31400           0 :             SgNamedType * blkptr = (SgNamedType*)(SgNamedType::pools[blockIndex-1]);
   31401           0 :             blkptr[ SgNamedType::pool_size - 1 ].set_freepointer(pointer);
   31402             :           }
   31403             :         } else {
   31404           0 :           SgNamedType::next_node = pointer;
   31405             :         }
   31406             : 
   31407           0 :         for (unsigned i = 0; i < SgNamedType::pool_size-1; ++i)
   31408             :            {
   31409           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   31410             :            }
   31411           0 :         pointer[ SgNamedType::pool_size -1 ].set_freepointer(NULL);
   31412             : 
   31413           0 :         blockIndex++;
   31414             :       }
   31415           2 :   }
   31416             : 
   31417             : //############################################################################
   31418             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   31419             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   31420             :  * not compressed. However, that stuff is not yet implemented! 
   31421             :  */
   31422             : unsigned long
   31423           0 : SgNamedType::getNumberOfLastValidPointer()
   31424             :    {
   31425           0 :       SgNamedType* testPointer = (SgNamedType*)(SgNamedType::pools.back());
   31426           0 :       unsigned long localIndex = SgNamedType::pool_size - 1;
   31427           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   31428             :          {
   31429           0 :            localIndex--;
   31430             :          }
   31431           0 :       return (localIndex + SgNamedType::pool_size * (SgNamedType::pools.size()-1));
   31432             :    }
   31433             : 
   31434             : //############################################################################
   31435             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   31436             :  * memory pool and initializes the data member in class SgNamedTypeStroageClass
   31437             :  * from its counterpart of SgNamedType. The return value is just for checking, 
   31438             :  * that the whole StorageClassArray is initialized!
   31439             :  */
   31440             : unsigned long
   31441           0 : SgNamedType::initializeStorageClassArray( SgNamedTypeStorageClass *storageArray )
   31442             :    {
   31443           0 :      unsigned long storageCounter = 0;
   31444           0 :      std::vector < unsigned char* > :: const_iterator block = SgNamedType::pools.begin();
   31445           0 :      SgNamedType* pointer = NULL;
   31446           0 :      while ( block != SgNamedType::pools.end() ) {
   31447           0 :           pointer = (SgNamedType*) (*block);
   31448           0 :           for ( unsigned i = 0; i < SgNamedType::pool_size; ++i ) {
   31449           0 :                if ( pointer->get_freepointer() != NULL ) {
   31450           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   31451           0 :                  storageArray++;
   31452           0 :                  storageCounter++;
   31453             :                }
   31454           0 :                pointer++;
   31455             :              }
   31456           0 :            block++;
   31457             :         }
   31458           0 :      return storageCounter;
   31459             :    }
   31460             : 
   31461             : /* #line 31462 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   31462             : 
   31463             : 
   31464             : 
   31465             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   31466             : 
   31467             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   31468             : 
   31469             : //############################################################################
   31470             : /* JH (02/02/2006) Constructor of the IR node SgClassType that takes its 
   31471             :  * corresponding StorageClass as parameter
   31472             :  */
   31473        1401 : SgClassType :: SgClassType ( const SgClassTypeStorageClass& storageSource )   : SgNamedType (storageSource)
   31474             :    {
   31475             : 
   31476             : 
   31477             : /* #line 31478 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   31478             : 
   31479        1401 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   31480        1401 :      p_packed = storageSource.storageOf_packed ;
   31481             : 
   31482             : 
   31483             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   31484             : 
   31485             : 
   31486        1401 :    }
   31487             : 
   31488             : //############################################################################
   31489             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   31490             :  * within the working AST. 
   31491             :  */
   31492       10121 : SgClassType * SgClassType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   31493       10121 :      SgClassType* returnPointer = NULL;
   31494       10121 :      if ( globalIndex != 0 )
   31495             :         {
   31496             : 
   31497             : #if FILE_IO_EXTRA_CHECK
   31498       10121 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClassType ) ) <= globalIndex ) ;
   31499       10121 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassType + 1 ) ) );
   31500             : #endif
   31501       10121 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassType )  
   31502       10121 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClassType );
   31503       10121 :           unsigned long positionInPool = localIndex % SgClassType::pool_size;
   31504       10121 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassType::pool_size;
   31505             : 
   31506             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   31507             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   31508             : 
   31509       10121 :           returnPointer = &( ( (SgClassType*)(SgClassType::pools[memoryBlock]) ) [positionInPool]) ;
   31510             : 
   31511       10121 :           ROSE_ASSERT( returnPointer != NULL ) ;
   31512             :         }
   31513       10121 :      return returnPointer ;
   31514             :    }
   31515             : 
   31516             : //############################################################################
   31517             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   31518             :   for the AST with the index astIndex
   31519             : */
   31520           0 : SgClassType * SgClassType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   31521           0 :      SgClassType* returnPointer = NULL;
   31522           0 :      if ( globalIndex != 0 )
   31523             :         {
   31524             : 
   31525             : #if FILE_IO_EXTRA_CHECK
   31526           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClassType ) ) <= globalIndex ) ;
   31527           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassType + 1 ) ) );
   31528             : #endif
   31529           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassType )
   31530           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClassType );
   31531           0 :           unsigned long positionInPool = localIndex % SgClassType::pool_size ;
   31532           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassType::pool_size ;
   31533             : 
   31534             : #if FILE_IO_EXTRA_CHECK
   31535             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   31536             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   31537             : #endif
   31538             : 
   31539           0 :           returnPointer = &( ( (SgClassType*)(SgClassType::pools[memoryBlock]) ) [positionInPool]) ;
   31540             : 
   31541             : #if FILE_IO_EXTRA_CHECK
   31542           0 :           assert ( returnPointer != NULL ) ;
   31543             : #endif
   31544             :         }
   31545           0 :      return returnPointer ;
   31546             :    }
   31547             : 
   31548             : //############################################################################
   31549             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   31550             :  * pool size! We set for every valid object in the memory pool the freepointer
   31551             :  * to the global index and increase the global index afterwards. For all the 
   31552             :  * invalid objects (means address ranges within the memory pool that were not
   31553             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   31554             :  * distinguish valid from invalid objects! 
   31555             :  */
   31556             : unsigned long
   31557           5 : SgClassType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   31558             :    {
   31559           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   31560           5 :      SgClassType* pointer = NULL;
   31561           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   31562           5 :      std::vector < unsigned char* > :: const_iterator block;
   31563           7 :      for ( block = SgClassType::pools.begin(); block != SgClassType::pools.end() ; ++block )
   31564             :         {
   31565           2 :           pointer = (SgClassType*)(*block);
   31566        4002 :           for (unsigned i = 0; i < SgClassType::pool_size; ++i )
   31567             :              {
   31568             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   31569             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   31570             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   31571             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   31572             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   31573             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   31574             :             // properly; so this will have to be checked next.
   31575             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   31576             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   31577        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   31578             :                   {
   31579        1401 :                     pointer[i].set_freepointer((SgClassType*)(globalIndex));
   31580        1401 :                     globalIndex++;
   31581             :                   }
   31582             :                else
   31583             :                   {
   31584        2599 :                     pointer[i].set_freepointer(NULL);
   31585             :                   }
   31586             :               }
   31587             :         }
   31588           5 :      return globalIndex;
   31589             :    }
   31590             : 
   31591             : //############################################################################
   31592             : // JH (01/14/2006)
   31593             : void
   31594           5 : SgClassType::resetValidFreepointers( )
   31595             :    {
   31596           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   31597           5 :      SgClassType* pointer = NULL;
   31598           5 :      std::vector < unsigned char* > :: const_iterator block;
   31599           5 :      SgClassType* pointerOfLinkedList = NULL;
   31600           7 :      for ( block = SgClassType::pools.begin(); block != SgClassType::pools.end() ; ++block )
   31601             :         {
   31602           2 :           pointer = (SgClassType*)(*block);
   31603        4002 :           for (unsigned i = 0; i < SgClassType::pool_size; ++i )
   31604             :              {
   31605             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   31606             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   31607             :             // memory blocks!.
   31608        4000 :                if ( pointer[i].get_freepointer() != NULL )
   31609             :                   {
   31610        1401 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   31611             :                   }
   31612             :                else
   31613             :                   {
   31614        2599 :                     if ( pointerOfLinkedList == NULL )
   31615             :                        {
   31616           2 :                          SgClassType::next_node = &(pointer[i]);
   31617             :                        }
   31618             :                     else
   31619             :                        {
   31620             :                       // printf ("In SgClassType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   31621        2597 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   31622             :                        }
   31623             :                     pointerOfLinkedList = &(pointer[i]);
   31624             :                   }
   31625             :               }
   31626             :         }
   31627             : 
   31628           5 :      if ( pointerOfLinkedList != NULL )
   31629             :         {
   31630             :        // printf ("In SgClassType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   31631           2 :           pointerOfLinkedList->set_freepointer(NULL);
   31632             :        // DQ (6/6/2010): Temporary debugging...
   31633             :        //   ROSE_ASSERT(false);
   31634             :         }
   31635             : 
   31636           5 :      return ;
   31637             :    }
   31638             : 
   31639             : //############################################################################
   31640             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   31641             :  * within the memory pool and resets the freepointers, in order to achieve a 
   31642             :  * linked list, that has no jumps and starts at the beginning! This function 
   31643             :  * does not extend the memory pool, since we do not delete any memory blocks,
   31644             :  * but delete the valid objects.  
   31645             :  */
   31646             : void
   31647           0 : SgClassType::clearMemoryPool( )
   31648             :    {
   31649             :   // printf ("Inside of SgClassType::clearMemoryPool() \n");
   31650             : 
   31651           0 :      SgClassType* pointer = NULL, *tempPointer = NULL;
   31652           0 :      std::vector < unsigned char* > :: const_iterator block;
   31653           0 :      if ( SgClassType::pools.empty() == false )
   31654             :         {
   31655           0 :           block = SgClassType::pools.begin() ;
   31656           0 :           SgClassType::next_node = (SgClassType*) (*block);
   31657             : 
   31658           0 :           while ( block != SgClassType::pools.end() )
   31659             :              {
   31660           0 :                pointer = (SgClassType*) (*block);
   31661           0 :                if ( tempPointer != NULL )
   31662             :                   {
   31663           0 :                     tempPointer->set_freepointer(pointer);
   31664             :                   }
   31665           0 :                for (unsigned i = 0; i < SgClassType::pool_size - 1; ++i)
   31666             :                   {
   31667           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   31668             :                   }
   31669           0 :                 pointer[SgClassType::pool_size-1].set_freepointer(NULL);
   31670           0 :                 tempPointer = &(pointer[SgClassType::pool_size-1]);
   31671           0 :                 ++block;
   31672             :              }
   31673             :         }
   31674           0 :    }
   31675             : 
   31676           5 : void SgClassType::deleteMemoryPool() {
   31677           9 :   for (auto p: SgClassType::pools) {
   31678           4 :     ROSE_FREE(p);
   31679             :   }
   31680           5 :   SgClassType::next_node = nullptr;
   31681           5 :   SgClassType::pools.clear();
   31682           5 : }
   31683             : 
   31684             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   31685             : //                 reading multiple binary files to for a single AST.
   31686             : /////////// new version ////////////////////////////////
   31687             : //############################################################################
   31688             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   31689             : void
   31690           2 : SgClassType::extendMemoryPoolForFileIO( )
   31691             :   {
   31692           2 :     size_t blockIndex = SgClassType::pools.size();
   31693           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClassType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassType);
   31694             : 
   31695           4 :     while ( (blockIndex * SgClassType::pool_size) < newPoolSize)
   31696             :       {
   31697             : #if ROSE_ALLOC_TRACE
   31698             :         if (blockIndex > 0) {
   31699             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClassType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassType) = %" PRIuPTR " SgClassType::pool_size = %d \n",
   31700             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClassType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassType),SgClassType::pool_size);
   31701             :         }
   31702             : #endif
   31703             : 
   31704           2 :         SgClassType * pointer = (SgClassType*) ROSE_MALLOC ( SgClassType::pool_size * sizeof(SgClassType) );
   31705           2 :         assert( pointer != NULL );
   31706             : #if ROSE_ALLOC_MEMSET == 1
   31707             :         memset(pointer, 0x00, SgClassType::pool_size * sizeof(SgClassType));
   31708             : #elif ROSE_ALLOC_MEMSET == 2
   31709             :         memset(pointer, 0xCC, SgClassType::pool_size * sizeof(SgClassType));
   31710             : #endif
   31711           2 :         SgClassType::pools.push_back( (unsigned char*)(pointer) );
   31712           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClassType::pool_size * sizeof(SgClassType), V_SgClassType ) );
   31713             : 
   31714           2 :         if ( SgClassType::next_node != NULL ) {
   31715           0 :           if ( blockIndex > 0 ) {
   31716           0 :             SgClassType * blkptr = (SgClassType*)(SgClassType::pools[blockIndex-1]);
   31717           0 :             blkptr[ SgClassType::pool_size - 1 ].set_freepointer(pointer);
   31718             :           }
   31719             :         } else {
   31720           2 :           SgClassType::next_node = pointer;
   31721             :         }
   31722             : 
   31723        4000 :         for (unsigned i = 0; i < SgClassType::pool_size-1; ++i)
   31724             :            {
   31725        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   31726             :            }
   31727           2 :         pointer[ SgClassType::pool_size -1 ].set_freepointer(NULL);
   31728             : 
   31729           2 :         blockIndex++;
   31730             :       }
   31731           2 :   }
   31732             : 
   31733             : //############################################################################
   31734             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   31735             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   31736             :  * not compressed. However, that stuff is not yet implemented! 
   31737             :  */
   31738             : unsigned long
   31739           0 : SgClassType::getNumberOfLastValidPointer()
   31740             :    {
   31741           0 :       SgClassType* testPointer = (SgClassType*)(SgClassType::pools.back());
   31742           0 :       unsigned long localIndex = SgClassType::pool_size - 1;
   31743           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   31744             :          {
   31745           0 :            localIndex--;
   31746             :          }
   31747           0 :       return (localIndex + SgClassType::pool_size * (SgClassType::pools.size()-1));
   31748             :    }
   31749             : 
   31750             : //############################################################################
   31751             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   31752             :  * memory pool and initializes the data member in class SgClassTypeStroageClass
   31753             :  * from its counterpart of SgClassType. The return value is just for checking, 
   31754             :  * that the whole StorageClassArray is initialized!
   31755             :  */
   31756             : unsigned long
   31757           2 : SgClassType::initializeStorageClassArray( SgClassTypeStorageClass *storageArray )
   31758             :    {
   31759           2 :      unsigned long storageCounter = 0;
   31760           2 :      std::vector < unsigned char* > :: const_iterator block = SgClassType::pools.begin();
   31761           2 :      SgClassType* pointer = NULL;
   31762           4 :      while ( block != SgClassType::pools.end() ) {
   31763           2 :           pointer = (SgClassType*) (*block);
   31764        4002 :           for ( unsigned i = 0; i < SgClassType::pool_size; ++i ) {
   31765        4000 :                if ( pointer->get_freepointer() != NULL ) {
   31766        1401 :                  storageArray->pickOutIRNodeData (pointer) ;
   31767        1401 :                  storageArray++;
   31768        1401 :                  storageCounter++;
   31769             :                }
   31770        4000 :                pointer++;
   31771             :              }
   31772           2 :            block++;
   31773             :         }
   31774           2 :      return storageCounter;
   31775             :    }
   31776             : 
   31777             : /* #line 31778 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   31778             : 
   31779             : 
   31780             : 
   31781             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   31782             : 
   31783             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   31784             : 
   31785             : //############################################################################
   31786             : /* JH (02/02/2006) Constructor of the IR node SgEnumType that takes its 
   31787             :  * corresponding StorageClass as parameter
   31788             :  */
   31789          87 : SgEnumType :: SgEnumType ( const SgEnumTypeStorageClass& storageSource )   : SgNamedType (storageSource)
   31790             :    {
   31791             : 
   31792             : 
   31793             : /* #line 31794 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   31794             : 
   31795          87 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   31796             : 
   31797             : 
   31798             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   31799             : 
   31800             : 
   31801          87 :    }
   31802             : 
   31803             : //############################################################################
   31804             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   31805             :  * within the working AST. 
   31806             :  */
   31807         757 : SgEnumType * SgEnumType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   31808         757 :      SgEnumType* returnPointer = NULL;
   31809         757 :      if ( globalIndex != 0 )
   31810             :         {
   31811             : 
   31812             : #if FILE_IO_EXTRA_CHECK
   31813         757 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEnumType ) ) <= globalIndex ) ;
   31814         757 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumType + 1 ) ) );
   31815             : #endif
   31816         757 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumType )  
   31817         757 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEnumType );
   31818         757 :           unsigned long positionInPool = localIndex % SgEnumType::pool_size;
   31819         757 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumType::pool_size;
   31820             : 
   31821             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   31822             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   31823             : 
   31824         757 :           returnPointer = &( ( (SgEnumType*)(SgEnumType::pools[memoryBlock]) ) [positionInPool]) ;
   31825             : 
   31826         757 :           ROSE_ASSERT( returnPointer != NULL ) ;
   31827             :         }
   31828         757 :      return returnPointer ;
   31829             :    }
   31830             : 
   31831             : //############################################################################
   31832             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   31833             :   for the AST with the index astIndex
   31834             : */
   31835           0 : SgEnumType * SgEnumType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   31836           0 :      SgEnumType* returnPointer = NULL;
   31837           0 :      if ( globalIndex != 0 )
   31838             :         {
   31839             : 
   31840             : #if FILE_IO_EXTRA_CHECK
   31841           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEnumType ) ) <= globalIndex ) ;
   31842           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumType + 1 ) ) );
   31843             : #endif
   31844           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumType )
   31845           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEnumType );
   31846           0 :           unsigned long positionInPool = localIndex % SgEnumType::pool_size ;
   31847           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumType::pool_size ;
   31848             : 
   31849             : #if FILE_IO_EXTRA_CHECK
   31850             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   31851             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   31852             : #endif
   31853             : 
   31854           0 :           returnPointer = &( ( (SgEnumType*)(SgEnumType::pools[memoryBlock]) ) [positionInPool]) ;
   31855             : 
   31856             : #if FILE_IO_EXTRA_CHECK
   31857           0 :           assert ( returnPointer != NULL ) ;
   31858             : #endif
   31859             :         }
   31860           0 :      return returnPointer ;
   31861             :    }
   31862             : 
   31863             : //############################################################################
   31864             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   31865             :  * pool size! We set for every valid object in the memory pool the freepointer
   31866             :  * to the global index and increase the global index afterwards. For all the 
   31867             :  * invalid objects (means address ranges within the memory pool that were not
   31868             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   31869             :  * distinguish valid from invalid objects! 
   31870             :  */
   31871             : unsigned long
   31872           5 : SgEnumType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   31873             :    {
   31874           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   31875           5 :      SgEnumType* pointer = NULL;
   31876           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   31877           5 :      std::vector < unsigned char* > :: const_iterator block;
   31878           6 :      for ( block = SgEnumType::pools.begin(); block != SgEnumType::pools.end() ; ++block )
   31879             :         {
   31880           1 :           pointer = (SgEnumType*)(*block);
   31881        2001 :           for (unsigned i = 0; i < SgEnumType::pool_size; ++i )
   31882             :              {
   31883             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   31884             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   31885             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   31886             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   31887             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   31888             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   31889             :             // properly; so this will have to be checked next.
   31890             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   31891             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   31892        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   31893             :                   {
   31894          87 :                     pointer[i].set_freepointer((SgEnumType*)(globalIndex));
   31895          87 :                     globalIndex++;
   31896             :                   }
   31897             :                else
   31898             :                   {
   31899        1913 :                     pointer[i].set_freepointer(NULL);
   31900             :                   }
   31901             :               }
   31902             :         }
   31903           5 :      return globalIndex;
   31904             :    }
   31905             : 
   31906             : //############################################################################
   31907             : // JH (01/14/2006)
   31908             : void
   31909           5 : SgEnumType::resetValidFreepointers( )
   31910             :    {
   31911           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   31912           5 :      SgEnumType* pointer = NULL;
   31913           5 :      std::vector < unsigned char* > :: const_iterator block;
   31914           5 :      SgEnumType* pointerOfLinkedList = NULL;
   31915           6 :      for ( block = SgEnumType::pools.begin(); block != SgEnumType::pools.end() ; ++block )
   31916             :         {
   31917           1 :           pointer = (SgEnumType*)(*block);
   31918        2001 :           for (unsigned i = 0; i < SgEnumType::pool_size; ++i )
   31919             :              {
   31920             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   31921             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   31922             :             // memory blocks!.
   31923        2000 :                if ( pointer[i].get_freepointer() != NULL )
   31924             :                   {
   31925          87 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   31926             :                   }
   31927             :                else
   31928             :                   {
   31929        1913 :                     if ( pointerOfLinkedList == NULL )
   31930             :                        {
   31931           1 :                          SgEnumType::next_node = &(pointer[i]);
   31932             :                        }
   31933             :                     else
   31934             :                        {
   31935             :                       // printf ("In SgEnumType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   31936        1912 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   31937             :                        }
   31938             :                     pointerOfLinkedList = &(pointer[i]);
   31939             :                   }
   31940             :               }
   31941             :         }
   31942             : 
   31943           5 :      if ( pointerOfLinkedList != NULL )
   31944             :         {
   31945             :        // printf ("In SgEnumType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   31946           1 :           pointerOfLinkedList->set_freepointer(NULL);
   31947             :        // DQ (6/6/2010): Temporary debugging...
   31948             :        //   ROSE_ASSERT(false);
   31949             :         }
   31950             : 
   31951           5 :      return ;
   31952             :    }
   31953             : 
   31954             : //############################################################################
   31955             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   31956             :  * within the memory pool and resets the freepointers, in order to achieve a 
   31957             :  * linked list, that has no jumps and starts at the beginning! This function 
   31958             :  * does not extend the memory pool, since we do not delete any memory blocks,
   31959             :  * but delete the valid objects.  
   31960             :  */
   31961             : void
   31962           0 : SgEnumType::clearMemoryPool( )
   31963             :    {
   31964             :   // printf ("Inside of SgEnumType::clearMemoryPool() \n");
   31965             : 
   31966           0 :      SgEnumType* pointer = NULL, *tempPointer = NULL;
   31967           0 :      std::vector < unsigned char* > :: const_iterator block;
   31968           0 :      if ( SgEnumType::pools.empty() == false )
   31969             :         {
   31970           0 :           block = SgEnumType::pools.begin() ;
   31971           0 :           SgEnumType::next_node = (SgEnumType*) (*block);
   31972             : 
   31973           0 :           while ( block != SgEnumType::pools.end() )
   31974             :              {
   31975           0 :                pointer = (SgEnumType*) (*block);
   31976           0 :                if ( tempPointer != NULL )
   31977             :                   {
   31978           0 :                     tempPointer->set_freepointer(pointer);
   31979             :                   }
   31980           0 :                for (unsigned i = 0; i < SgEnumType::pool_size - 1; ++i)
   31981             :                   {
   31982           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   31983             :                   }
   31984           0 :                 pointer[SgEnumType::pool_size-1].set_freepointer(NULL);
   31985           0 :                 tempPointer = &(pointer[SgEnumType::pool_size-1]);
   31986           0 :                 ++block;
   31987             :              }
   31988             :         }
   31989           0 :    }
   31990             : 
   31991           5 : void SgEnumType::deleteMemoryPool() {
   31992           7 :   for (auto p: SgEnumType::pools) {
   31993           2 :     ROSE_FREE(p);
   31994             :   }
   31995           5 :   SgEnumType::next_node = nullptr;
   31996           5 :   SgEnumType::pools.clear();
   31997           5 : }
   31998             : 
   31999             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   32000             : //                 reading multiple binary files to for a single AST.
   32001             : /////////// new version ////////////////////////////////
   32002             : //############################################################################
   32003             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   32004             : void
   32005           2 : SgEnumType::extendMemoryPoolForFileIO( )
   32006             :   {
   32007           2 :     size_t blockIndex = SgEnumType::pools.size();
   32008           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumType);
   32009             : 
   32010           3 :     while ( (blockIndex * SgEnumType::pool_size) < newPoolSize)
   32011             :       {
   32012             : #if ROSE_ALLOC_TRACE
   32013             :         if (blockIndex > 0) {
   32014             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumType) = %" PRIuPTR " SgEnumType::pool_size = %d \n",
   32015             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumType),SgEnumType::pool_size);
   32016             :         }
   32017             : #endif
   32018             : 
   32019           1 :         SgEnumType * pointer = (SgEnumType*) ROSE_MALLOC ( SgEnumType::pool_size * sizeof(SgEnumType) );
   32020           1 :         assert( pointer != NULL );
   32021             : #if ROSE_ALLOC_MEMSET == 1
   32022             :         memset(pointer, 0x00, SgEnumType::pool_size * sizeof(SgEnumType));
   32023             : #elif ROSE_ALLOC_MEMSET == 2
   32024             :         memset(pointer, 0xCC, SgEnumType::pool_size * sizeof(SgEnumType));
   32025             : #endif
   32026           1 :         SgEnumType::pools.push_back( (unsigned char*)(pointer) );
   32027           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEnumType::pool_size * sizeof(SgEnumType), V_SgEnumType ) );
   32028             : 
   32029           1 :         if ( SgEnumType::next_node != NULL ) {
   32030           0 :           if ( blockIndex > 0 ) {
   32031           0 :             SgEnumType * blkptr = (SgEnumType*)(SgEnumType::pools[blockIndex-1]);
   32032           0 :             blkptr[ SgEnumType::pool_size - 1 ].set_freepointer(pointer);
   32033             :           }
   32034             :         } else {
   32035           1 :           SgEnumType::next_node = pointer;
   32036             :         }
   32037             : 
   32038        2000 :         for (unsigned i = 0; i < SgEnumType::pool_size-1; ++i)
   32039             :            {
   32040        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   32041             :            }
   32042           1 :         pointer[ SgEnumType::pool_size -1 ].set_freepointer(NULL);
   32043             : 
   32044           1 :         blockIndex++;
   32045             :       }
   32046           2 :   }
   32047             : 
   32048             : //############################################################################
   32049             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   32050             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   32051             :  * not compressed. However, that stuff is not yet implemented! 
   32052             :  */
   32053             : unsigned long
   32054           0 : SgEnumType::getNumberOfLastValidPointer()
   32055             :    {
   32056           0 :       SgEnumType* testPointer = (SgEnumType*)(SgEnumType::pools.back());
   32057           0 :       unsigned long localIndex = SgEnumType::pool_size - 1;
   32058           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   32059             :          {
   32060           0 :            localIndex--;
   32061             :          }
   32062           0 :       return (localIndex + SgEnumType::pool_size * (SgEnumType::pools.size()-1));
   32063             :    }
   32064             : 
   32065             : //############################################################################
   32066             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   32067             :  * memory pool and initializes the data member in class SgEnumTypeStroageClass
   32068             :  * from its counterpart of SgEnumType. The return value is just for checking, 
   32069             :  * that the whole StorageClassArray is initialized!
   32070             :  */
   32071             : unsigned long
   32072           1 : SgEnumType::initializeStorageClassArray( SgEnumTypeStorageClass *storageArray )
   32073             :    {
   32074           1 :      unsigned long storageCounter = 0;
   32075           1 :      std::vector < unsigned char* > :: const_iterator block = SgEnumType::pools.begin();
   32076           1 :      SgEnumType* pointer = NULL;
   32077           2 :      while ( block != SgEnumType::pools.end() ) {
   32078           1 :           pointer = (SgEnumType*) (*block);
   32079        2001 :           for ( unsigned i = 0; i < SgEnumType::pool_size; ++i ) {
   32080        2000 :                if ( pointer->get_freepointer() != NULL ) {
   32081          87 :                  storageArray->pickOutIRNodeData (pointer) ;
   32082          87 :                  storageArray++;
   32083          87 :                  storageCounter++;
   32084             :                }
   32085        2000 :                pointer++;
   32086             :              }
   32087           1 :            block++;
   32088             :         }
   32089           1 :      return storageCounter;
   32090             :    }
   32091             : 
   32092             : /* #line 32093 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   32093             : 
   32094             : 
   32095             : 
   32096             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   32097             : 
   32098             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   32099             : 
   32100             : //############################################################################
   32101             : /* JH (02/02/2006) Constructor of the IR node SgTypedefType that takes its 
   32102             :  * corresponding StorageClass as parameter
   32103             :  */
   32104        1848 : SgTypedefType :: SgTypedefType ( const SgTypedefTypeStorageClass& storageSource )   : SgNamedType (storageSource)
   32105             :    {
   32106             : 
   32107             : 
   32108             : /* #line 32109 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   32109             : 
   32110        1848 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   32111        1848 :      p_parent_scope =  (SgSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parent_scope) );
   32112             : 
   32113             : 
   32114             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   32115             : 
   32116             : 
   32117        1848 :    }
   32118             : 
   32119             : //############################################################################
   32120             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   32121             :  * within the working AST. 
   32122             :  */
   32123       55148 : SgTypedefType * SgTypedefType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   32124       55148 :      SgTypedefType* returnPointer = NULL;
   32125       55148 :      if ( globalIndex != 0 )
   32126             :         {
   32127             : 
   32128             : #if FILE_IO_EXTRA_CHECK
   32129       55148 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypedefType ) ) <= globalIndex ) ;
   32130       55148 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypedefType + 1 ) ) );
   32131             : #endif
   32132       55148 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypedefType )  
   32133       55148 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypedefType );
   32134       55148 :           unsigned long positionInPool = localIndex % SgTypedefType::pool_size;
   32135       55148 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypedefType::pool_size;
   32136             : 
   32137             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   32138             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   32139             : 
   32140       55148 :           returnPointer = &( ( (SgTypedefType*)(SgTypedefType::pools[memoryBlock]) ) [positionInPool]) ;
   32141             : 
   32142       55148 :           ROSE_ASSERT( returnPointer != NULL ) ;
   32143             :         }
   32144       55148 :      return returnPointer ;
   32145             :    }
   32146             : 
   32147             : //############################################################################
   32148             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   32149             :   for the AST with the index astIndex
   32150             : */
   32151           0 : SgTypedefType * SgTypedefType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   32152           0 :      SgTypedefType* returnPointer = NULL;
   32153           0 :      if ( globalIndex != 0 )
   32154             :         {
   32155             : 
   32156             : #if FILE_IO_EXTRA_CHECK
   32157           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypedefType ) ) <= globalIndex ) ;
   32158           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypedefType + 1 ) ) );
   32159             : #endif
   32160           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypedefType )
   32161           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypedefType );
   32162           0 :           unsigned long positionInPool = localIndex % SgTypedefType::pool_size ;
   32163           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypedefType::pool_size ;
   32164             : 
   32165             : #if FILE_IO_EXTRA_CHECK
   32166             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   32167             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   32168             : #endif
   32169             : 
   32170           0 :           returnPointer = &( ( (SgTypedefType*)(SgTypedefType::pools[memoryBlock]) ) [positionInPool]) ;
   32171             : 
   32172             : #if FILE_IO_EXTRA_CHECK
   32173           0 :           assert ( returnPointer != NULL ) ;
   32174             : #endif
   32175             :         }
   32176           0 :      return returnPointer ;
   32177             :    }
   32178             : 
   32179             : //############################################################################
   32180             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   32181             :  * pool size! We set for every valid object in the memory pool the freepointer
   32182             :  * to the global index and increase the global index afterwards. For all the 
   32183             :  * invalid objects (means address ranges within the memory pool that were not
   32184             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   32185             :  * distinguish valid from invalid objects! 
   32186             :  */
   32187             : unsigned long
   32188           5 : SgTypedefType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   32189             :    {
   32190           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   32191           5 :      SgTypedefType* pointer = NULL;
   32192           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   32193           5 :      std::vector < unsigned char* > :: const_iterator block;
   32194           7 :      for ( block = SgTypedefType::pools.begin(); block != SgTypedefType::pools.end() ; ++block )
   32195             :         {
   32196           2 :           pointer = (SgTypedefType*)(*block);
   32197        4002 :           for (unsigned i = 0; i < SgTypedefType::pool_size; ++i )
   32198             :              {
   32199             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   32200             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   32201             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   32202             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   32203             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   32204             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   32205             :             // properly; so this will have to be checked next.
   32206             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   32207             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   32208        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   32209             :                   {
   32210        1848 :                     pointer[i].set_freepointer((SgTypedefType*)(globalIndex));
   32211        1848 :                     globalIndex++;
   32212             :                   }
   32213             :                else
   32214             :                   {
   32215        2152 :                     pointer[i].set_freepointer(NULL);
   32216             :                   }
   32217             :               }
   32218             :         }
   32219           5 :      return globalIndex;
   32220             :    }
   32221             : 
   32222             : //############################################################################
   32223             : // JH (01/14/2006)
   32224             : void
   32225           5 : SgTypedefType::resetValidFreepointers( )
   32226             :    {
   32227           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   32228           5 :      SgTypedefType* pointer = NULL;
   32229           5 :      std::vector < unsigned char* > :: const_iterator block;
   32230           5 :      SgTypedefType* pointerOfLinkedList = NULL;
   32231           7 :      for ( block = SgTypedefType::pools.begin(); block != SgTypedefType::pools.end() ; ++block )
   32232             :         {
   32233           2 :           pointer = (SgTypedefType*)(*block);
   32234        4002 :           for (unsigned i = 0; i < SgTypedefType::pool_size; ++i )
   32235             :              {
   32236             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   32237             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   32238             :             // memory blocks!.
   32239        4000 :                if ( pointer[i].get_freepointer() != NULL )
   32240             :                   {
   32241        1848 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   32242             :                   }
   32243             :                else
   32244             :                   {
   32245        2152 :                     if ( pointerOfLinkedList == NULL )
   32246             :                        {
   32247           2 :                          SgTypedefType::next_node = &(pointer[i]);
   32248             :                        }
   32249             :                     else
   32250             :                        {
   32251             :                       // printf ("In SgTypedefType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   32252        2150 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   32253             :                        }
   32254             :                     pointerOfLinkedList = &(pointer[i]);
   32255             :                   }
   32256             :               }
   32257             :         }
   32258             : 
   32259           5 :      if ( pointerOfLinkedList != NULL )
   32260             :         {
   32261             :        // printf ("In SgTypedefType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   32262           2 :           pointerOfLinkedList->set_freepointer(NULL);
   32263             :        // DQ (6/6/2010): Temporary debugging...
   32264             :        //   ROSE_ASSERT(false);
   32265             :         }
   32266             : 
   32267           5 :      return ;
   32268             :    }
   32269             : 
   32270             : //############################################################################
   32271             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   32272             :  * within the memory pool and resets the freepointers, in order to achieve a 
   32273             :  * linked list, that has no jumps and starts at the beginning! This function 
   32274             :  * does not extend the memory pool, since we do not delete any memory blocks,
   32275             :  * but delete the valid objects.  
   32276             :  */
   32277             : void
   32278           0 : SgTypedefType::clearMemoryPool( )
   32279             :    {
   32280             :   // printf ("Inside of SgTypedefType::clearMemoryPool() \n");
   32281             : 
   32282           0 :      SgTypedefType* pointer = NULL, *tempPointer = NULL;
   32283           0 :      std::vector < unsigned char* > :: const_iterator block;
   32284           0 :      if ( SgTypedefType::pools.empty() == false )
   32285             :         {
   32286           0 :           block = SgTypedefType::pools.begin() ;
   32287           0 :           SgTypedefType::next_node = (SgTypedefType*) (*block);
   32288             : 
   32289           0 :           while ( block != SgTypedefType::pools.end() )
   32290             :              {
   32291           0 :                pointer = (SgTypedefType*) (*block);
   32292           0 :                if ( tempPointer != NULL )
   32293             :                   {
   32294           0 :                     tempPointer->set_freepointer(pointer);
   32295             :                   }
   32296           0 :                for (unsigned i = 0; i < SgTypedefType::pool_size - 1; ++i)
   32297             :                   {
   32298           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   32299             :                   }
   32300           0 :                 pointer[SgTypedefType::pool_size-1].set_freepointer(NULL);
   32301           0 :                 tempPointer = &(pointer[SgTypedefType::pool_size-1]);
   32302           0 :                 ++block;
   32303             :              }
   32304             :         }
   32305           0 :    }
   32306             : 
   32307           5 : void SgTypedefType::deleteMemoryPool() {
   32308           9 :   for (auto p: SgTypedefType::pools) {
   32309           4 :     ROSE_FREE(p);
   32310             :   }
   32311           5 :   SgTypedefType::next_node = nullptr;
   32312           5 :   SgTypedefType::pools.clear();
   32313           5 : }
   32314             : 
   32315             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   32316             : //                 reading multiple binary files to for a single AST.
   32317             : /////////// new version ////////////////////////////////
   32318             : //############################################################################
   32319             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   32320             : void
   32321           2 : SgTypedefType::extendMemoryPoolForFileIO( )
   32322             :   {
   32323           2 :     size_t blockIndex = SgTypedefType::pools.size();
   32324           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefType);
   32325             : 
   32326           4 :     while ( (blockIndex * SgTypedefType::pool_size) < newPoolSize)
   32327             :       {
   32328             : #if ROSE_ALLOC_TRACE
   32329             :         if (blockIndex > 0) {
   32330             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefType) = %" PRIuPTR " SgTypedefType::pool_size = %d \n",
   32331             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefType),SgTypedefType::pool_size);
   32332             :         }
   32333             : #endif
   32334             : 
   32335           2 :         SgTypedefType * pointer = (SgTypedefType*) ROSE_MALLOC ( SgTypedefType::pool_size * sizeof(SgTypedefType) );
   32336           2 :         assert( pointer != NULL );
   32337             : #if ROSE_ALLOC_MEMSET == 1
   32338             :         memset(pointer, 0x00, SgTypedefType::pool_size * sizeof(SgTypedefType));
   32339             : #elif ROSE_ALLOC_MEMSET == 2
   32340             :         memset(pointer, 0xCC, SgTypedefType::pool_size * sizeof(SgTypedefType));
   32341             : #endif
   32342           2 :         SgTypedefType::pools.push_back( (unsigned char*)(pointer) );
   32343           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypedefType::pool_size * sizeof(SgTypedefType), V_SgTypedefType ) );
   32344             : 
   32345           2 :         if ( SgTypedefType::next_node != NULL ) {
   32346           0 :           if ( blockIndex > 0 ) {
   32347           0 :             SgTypedefType * blkptr = (SgTypedefType*)(SgTypedefType::pools[blockIndex-1]);
   32348           0 :             blkptr[ SgTypedefType::pool_size - 1 ].set_freepointer(pointer);
   32349             :           }
   32350             :         } else {
   32351           2 :           SgTypedefType::next_node = pointer;
   32352             :         }
   32353             : 
   32354        4000 :         for (unsigned i = 0; i < SgTypedefType::pool_size-1; ++i)
   32355             :            {
   32356        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   32357             :            }
   32358           2 :         pointer[ SgTypedefType::pool_size -1 ].set_freepointer(NULL);
   32359             : 
   32360           2 :         blockIndex++;
   32361             :       }
   32362           2 :   }
   32363             : 
   32364             : //############################################################################
   32365             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   32366             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   32367             :  * not compressed. However, that stuff is not yet implemented! 
   32368             :  */
   32369             : unsigned long
   32370           0 : SgTypedefType::getNumberOfLastValidPointer()
   32371             :    {
   32372           0 :       SgTypedefType* testPointer = (SgTypedefType*)(SgTypedefType::pools.back());
   32373           0 :       unsigned long localIndex = SgTypedefType::pool_size - 1;
   32374           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   32375             :          {
   32376           0 :            localIndex--;
   32377             :          }
   32378           0 :       return (localIndex + SgTypedefType::pool_size * (SgTypedefType::pools.size()-1));
   32379             :    }
   32380             : 
   32381             : //############################################################################
   32382             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   32383             :  * memory pool and initializes the data member in class SgTypedefTypeStroageClass
   32384             :  * from its counterpart of SgTypedefType. The return value is just for checking, 
   32385             :  * that the whole StorageClassArray is initialized!
   32386             :  */
   32387             : unsigned long
   32388           2 : SgTypedefType::initializeStorageClassArray( SgTypedefTypeStorageClass *storageArray )
   32389             :    {
   32390           2 :      unsigned long storageCounter = 0;
   32391           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypedefType::pools.begin();
   32392           2 :      SgTypedefType* pointer = NULL;
   32393           4 :      while ( block != SgTypedefType::pools.end() ) {
   32394           2 :           pointer = (SgTypedefType*) (*block);
   32395        4002 :           for ( unsigned i = 0; i < SgTypedefType::pool_size; ++i ) {
   32396        4000 :                if ( pointer->get_freepointer() != NULL ) {
   32397        1848 :                  storageArray->pickOutIRNodeData (pointer) ;
   32398        1848 :                  storageArray++;
   32399        1848 :                  storageCounter++;
   32400             :                }
   32401        4000 :                pointer++;
   32402             :              }
   32403           2 :            block++;
   32404             :         }
   32405           2 :      return storageCounter;
   32406             :    }
   32407             : 
   32408             : /* #line 32409 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   32409             : 
   32410             : 
   32411             : 
   32412             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   32413             : 
   32414             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   32415             : 
   32416             : //############################################################################
   32417             : /* JH (02/02/2006) Constructor of the IR node SgNonrealType that takes its 
   32418             :  * corresponding StorageClass as parameter
   32419             :  */
   32420        5080 : SgNonrealType :: SgNonrealType ( const SgNonrealTypeStorageClass& storageSource )   : SgNamedType (storageSource)
   32421             :    {
   32422             : 
   32423             : 
   32424             : /* #line 32425 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   32425             : 
   32426        5080 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   32427             : 
   32428             : 
   32429             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   32430             : 
   32431             : 
   32432        5080 :    }
   32433             : 
   32434             : //############################################################################
   32435             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   32436             :  * within the working AST. 
   32437             :  */
   32438       20197 : SgNonrealType * SgNonrealType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   32439       20197 :      SgNonrealType* returnPointer = NULL;
   32440       20197 :      if ( globalIndex != 0 )
   32441             :         {
   32442             : 
   32443             : #if FILE_IO_EXTRA_CHECK
   32444       20197 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNonrealType ) ) <= globalIndex ) ;
   32445       20197 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealType + 1 ) ) );
   32446             : #endif
   32447       20197 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealType )  
   32448       20197 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNonrealType );
   32449       20197 :           unsigned long positionInPool = localIndex % SgNonrealType::pool_size;
   32450       20197 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealType::pool_size;
   32451             : 
   32452             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   32453             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   32454             : 
   32455       20197 :           returnPointer = &( ( (SgNonrealType*)(SgNonrealType::pools[memoryBlock]) ) [positionInPool]) ;
   32456             : 
   32457       20197 :           ROSE_ASSERT( returnPointer != NULL ) ;
   32458             :         }
   32459       20197 :      return returnPointer ;
   32460             :    }
   32461             : 
   32462             : //############################################################################
   32463             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   32464             :   for the AST with the index astIndex
   32465             : */
   32466           0 : SgNonrealType * SgNonrealType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   32467           0 :      SgNonrealType* returnPointer = NULL;
   32468           0 :      if ( globalIndex != 0 )
   32469             :         {
   32470             : 
   32471             : #if FILE_IO_EXTRA_CHECK
   32472           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNonrealType ) ) <= globalIndex ) ;
   32473           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealType + 1 ) ) );
   32474             : #endif
   32475           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealType )
   32476           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNonrealType );
   32477           0 :           unsigned long positionInPool = localIndex % SgNonrealType::pool_size ;
   32478           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealType::pool_size ;
   32479             : 
   32480             : #if FILE_IO_EXTRA_CHECK
   32481             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   32482             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   32483             : #endif
   32484             : 
   32485           0 :           returnPointer = &( ( (SgNonrealType*)(SgNonrealType::pools[memoryBlock]) ) [positionInPool]) ;
   32486             : 
   32487             : #if FILE_IO_EXTRA_CHECK
   32488           0 :           assert ( returnPointer != NULL ) ;
   32489             : #endif
   32490             :         }
   32491           0 :      return returnPointer ;
   32492             :    }
   32493             : 
   32494             : //############################################################################
   32495             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   32496             :  * pool size! We set for every valid object in the memory pool the freepointer
   32497             :  * to the global index and increase the global index afterwards. For all the 
   32498             :  * invalid objects (means address ranges within the memory pool that were not
   32499             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   32500             :  * distinguish valid from invalid objects! 
   32501             :  */
   32502             : unsigned long
   32503           5 : SgNonrealType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   32504             :    {
   32505           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   32506           5 :      SgNonrealType* pointer = NULL;
   32507           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   32508           5 :      std::vector < unsigned char* > :: const_iterator block;
   32509           8 :      for ( block = SgNonrealType::pools.begin(); block != SgNonrealType::pools.end() ; ++block )
   32510             :         {
   32511           3 :           pointer = (SgNonrealType*)(*block);
   32512        6003 :           for (unsigned i = 0; i < SgNonrealType::pool_size; ++i )
   32513             :              {
   32514             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   32515             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   32516             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   32517             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   32518             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   32519             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   32520             :             // properly; so this will have to be checked next.
   32521             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   32522             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   32523        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   32524             :                   {
   32525        5080 :                     pointer[i].set_freepointer((SgNonrealType*)(globalIndex));
   32526        5080 :                     globalIndex++;
   32527             :                   }
   32528             :                else
   32529             :                   {
   32530         920 :                     pointer[i].set_freepointer(NULL);
   32531             :                   }
   32532             :               }
   32533             :         }
   32534           5 :      return globalIndex;
   32535             :    }
   32536             : 
   32537             : //############################################################################
   32538             : // JH (01/14/2006)
   32539             : void
   32540           5 : SgNonrealType::resetValidFreepointers( )
   32541             :    {
   32542           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   32543           5 :      SgNonrealType* pointer = NULL;
   32544           5 :      std::vector < unsigned char* > :: const_iterator block;
   32545           5 :      SgNonrealType* pointerOfLinkedList = NULL;
   32546           8 :      for ( block = SgNonrealType::pools.begin(); block != SgNonrealType::pools.end() ; ++block )
   32547             :         {
   32548           3 :           pointer = (SgNonrealType*)(*block);
   32549        6003 :           for (unsigned i = 0; i < SgNonrealType::pool_size; ++i )
   32550             :              {
   32551             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   32552             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   32553             :             // memory blocks!.
   32554        6000 :                if ( pointer[i].get_freepointer() != NULL )
   32555             :                   {
   32556        5080 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   32557             :                   }
   32558             :                else
   32559             :                   {
   32560         920 :                     if ( pointerOfLinkedList == NULL )
   32561             :                        {
   32562           1 :                          SgNonrealType::next_node = &(pointer[i]);
   32563             :                        }
   32564             :                     else
   32565             :                        {
   32566             :                       // printf ("In SgNonrealType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   32567         919 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   32568             :                        }
   32569             :                     pointerOfLinkedList = &(pointer[i]);
   32570             :                   }
   32571             :               }
   32572             :         }
   32573             : 
   32574           5 :      if ( pointerOfLinkedList != NULL )
   32575             :         {
   32576             :        // printf ("In SgNonrealType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   32577           1 :           pointerOfLinkedList->set_freepointer(NULL);
   32578             :        // DQ (6/6/2010): Temporary debugging...
   32579             :        //   ROSE_ASSERT(false);
   32580             :         }
   32581             : 
   32582           5 :      return ;
   32583             :    }
   32584             : 
   32585             : //############################################################################
   32586             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   32587             :  * within the memory pool and resets the freepointers, in order to achieve a 
   32588             :  * linked list, that has no jumps and starts at the beginning! This function 
   32589             :  * does not extend the memory pool, since we do not delete any memory blocks,
   32590             :  * but delete the valid objects.  
   32591             :  */
   32592             : void
   32593           0 : SgNonrealType::clearMemoryPool( )
   32594             :    {
   32595             :   // printf ("Inside of SgNonrealType::clearMemoryPool() \n");
   32596             : 
   32597           0 :      SgNonrealType* pointer = NULL, *tempPointer = NULL;
   32598           0 :      std::vector < unsigned char* > :: const_iterator block;
   32599           0 :      if ( SgNonrealType::pools.empty() == false )
   32600             :         {
   32601           0 :           block = SgNonrealType::pools.begin() ;
   32602           0 :           SgNonrealType::next_node = (SgNonrealType*) (*block);
   32603             : 
   32604           0 :           while ( block != SgNonrealType::pools.end() )
   32605             :              {
   32606           0 :                pointer = (SgNonrealType*) (*block);
   32607           0 :                if ( tempPointer != NULL )
   32608             :                   {
   32609           0 :                     tempPointer->set_freepointer(pointer);
   32610             :                   }
   32611           0 :                for (unsigned i = 0; i < SgNonrealType::pool_size - 1; ++i)
   32612             :                   {
   32613           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   32614             :                   }
   32615           0 :                 pointer[SgNonrealType::pool_size-1].set_freepointer(NULL);
   32616           0 :                 tempPointer = &(pointer[SgNonrealType::pool_size-1]);
   32617           0 :                 ++block;
   32618             :              }
   32619             :         }
   32620           0 :    }
   32621             : 
   32622           5 : void SgNonrealType::deleteMemoryPool() {
   32623          11 :   for (auto p: SgNonrealType::pools) {
   32624           6 :     ROSE_FREE(p);
   32625             :   }
   32626           5 :   SgNonrealType::next_node = nullptr;
   32627           5 :   SgNonrealType::pools.clear();
   32628           5 : }
   32629             : 
   32630             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   32631             : //                 reading multiple binary files to for a single AST.
   32632             : /////////// new version ////////////////////////////////
   32633             : //############################################################################
   32634             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   32635             : void
   32636           2 : SgNonrealType::extendMemoryPoolForFileIO( )
   32637             :   {
   32638           2 :     size_t blockIndex = SgNonrealType::pools.size();
   32639           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealType);
   32640             : 
   32641           5 :     while ( (blockIndex * SgNonrealType::pool_size) < newPoolSize)
   32642             :       {
   32643             : #if ROSE_ALLOC_TRACE
   32644             :         if (blockIndex > 0) {
   32645             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealType) = %" PRIuPTR " SgNonrealType::pool_size = %d \n",
   32646             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealType),SgNonrealType::pool_size);
   32647             :         }
   32648             : #endif
   32649             : 
   32650           3 :         SgNonrealType * pointer = (SgNonrealType*) ROSE_MALLOC ( SgNonrealType::pool_size * sizeof(SgNonrealType) );
   32651           3 :         assert( pointer != NULL );
   32652             : #if ROSE_ALLOC_MEMSET == 1
   32653             :         memset(pointer, 0x00, SgNonrealType::pool_size * sizeof(SgNonrealType));
   32654             : #elif ROSE_ALLOC_MEMSET == 2
   32655             :         memset(pointer, 0xCC, SgNonrealType::pool_size * sizeof(SgNonrealType));
   32656             : #endif
   32657           3 :         SgNonrealType::pools.push_back( (unsigned char*)(pointer) );
   32658           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNonrealType::pool_size * sizeof(SgNonrealType), V_SgNonrealType ) );
   32659             : 
   32660           3 :         if ( SgNonrealType::next_node != NULL ) {
   32661           2 :           if ( blockIndex > 0 ) {
   32662           2 :             SgNonrealType * blkptr = (SgNonrealType*)(SgNonrealType::pools[blockIndex-1]);
   32663           2 :             blkptr[ SgNonrealType::pool_size - 1 ].set_freepointer(pointer);
   32664             :           }
   32665             :         } else {
   32666           1 :           SgNonrealType::next_node = pointer;
   32667             :         }
   32668             : 
   32669        6000 :         for (unsigned i = 0; i < SgNonrealType::pool_size-1; ++i)
   32670             :            {
   32671        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   32672             :            }
   32673           3 :         pointer[ SgNonrealType::pool_size -1 ].set_freepointer(NULL);
   32674             : 
   32675           3 :         blockIndex++;
   32676             :       }
   32677           2 :   }
   32678             : 
   32679             : //############################################################################
   32680             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   32681             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   32682             :  * not compressed. However, that stuff is not yet implemented! 
   32683             :  */
   32684             : unsigned long
   32685           0 : SgNonrealType::getNumberOfLastValidPointer()
   32686             :    {
   32687           0 :       SgNonrealType* testPointer = (SgNonrealType*)(SgNonrealType::pools.back());
   32688           0 :       unsigned long localIndex = SgNonrealType::pool_size - 1;
   32689           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   32690             :          {
   32691           0 :            localIndex--;
   32692             :          }
   32693           0 :       return (localIndex + SgNonrealType::pool_size * (SgNonrealType::pools.size()-1));
   32694             :    }
   32695             : 
   32696             : //############################################################################
   32697             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   32698             :  * memory pool and initializes the data member in class SgNonrealTypeStroageClass
   32699             :  * from its counterpart of SgNonrealType. The return value is just for checking, 
   32700             :  * that the whole StorageClassArray is initialized!
   32701             :  */
   32702             : unsigned long
   32703           1 : SgNonrealType::initializeStorageClassArray( SgNonrealTypeStorageClass *storageArray )
   32704             :    {
   32705           1 :      unsigned long storageCounter = 0;
   32706           1 :      std::vector < unsigned char* > :: const_iterator block = SgNonrealType::pools.begin();
   32707           1 :      SgNonrealType* pointer = NULL;
   32708           4 :      while ( block != SgNonrealType::pools.end() ) {
   32709           3 :           pointer = (SgNonrealType*) (*block);
   32710        6003 :           for ( unsigned i = 0; i < SgNonrealType::pool_size; ++i ) {
   32711        6000 :                if ( pointer->get_freepointer() != NULL ) {
   32712        5080 :                  storageArray->pickOutIRNodeData (pointer) ;
   32713        5080 :                  storageArray++;
   32714        5080 :                  storageCounter++;
   32715             :                }
   32716        6000 :                pointer++;
   32717             :              }
   32718           3 :            block++;
   32719             :         }
   32720           1 :      return storageCounter;
   32721             :    }
   32722             : 
   32723             : /* #line 32724 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   32724             : 
   32725             : 
   32726             : 
   32727             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   32728             : 
   32729             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   32730             : 
   32731             : //############################################################################
   32732             : /* JH (02/02/2006) Constructor of the IR node SgModifierType that takes its 
   32733             :  * corresponding StorageClass as parameter
   32734             :  */
   32735         876 : SgModifierType :: SgModifierType ( const SgModifierTypeStorageClass& storageSource )   : SgType (storageSource)
   32736             :    {
   32737             : 
   32738             : 
   32739             : /* #line 32740 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   32740             : 
   32741         876 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   32742         876 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   32743         876 :      p_typeModifier = SgTypeModifier ( storageSource.storageOf_typeModifier ) ;
   32744         876 :      p_frontend_type_reference = const_cast<char* >( storageSource.storageOf_frontend_type_reference.rebuildDataStoredInEasyStorageClass() ) ;
   32745             : 
   32746             : 
   32747             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   32748             : 
   32749             : 
   32750         876 :    }
   32751             : 
   32752             : //############################################################################
   32753             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   32754             :  * within the working AST. 
   32755             :  */
   32756        2398 : SgModifierType * SgModifierType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   32757        2398 :      SgModifierType* returnPointer = NULL;
   32758        2398 :      if ( globalIndex != 0 )
   32759             :         {
   32760             : 
   32761             : #if FILE_IO_EXTRA_CHECK
   32762        2398 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgModifierType ) ) <= globalIndex ) ;
   32763        2398 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModifierType + 1 ) ) );
   32764             : #endif
   32765        2398 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModifierType )  
   32766        2398 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgModifierType );
   32767        2398 :           unsigned long positionInPool = localIndex % SgModifierType::pool_size;
   32768        2398 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModifierType::pool_size;
   32769             : 
   32770             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   32771             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   32772             : 
   32773        2398 :           returnPointer = &( ( (SgModifierType*)(SgModifierType::pools[memoryBlock]) ) [positionInPool]) ;
   32774             : 
   32775        2398 :           ROSE_ASSERT( returnPointer != NULL ) ;
   32776             :         }
   32777        2398 :      return returnPointer ;
   32778             :    }
   32779             : 
   32780             : //############################################################################
   32781             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   32782             :   for the AST with the index astIndex
   32783             : */
   32784           0 : SgModifierType * SgModifierType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   32785           0 :      SgModifierType* returnPointer = NULL;
   32786           0 :      if ( globalIndex != 0 )
   32787             :         {
   32788             : 
   32789             : #if FILE_IO_EXTRA_CHECK
   32790           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgModifierType ) ) <= globalIndex ) ;
   32791           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModifierType + 1 ) ) );
   32792             : #endif
   32793           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModifierType )
   32794           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgModifierType );
   32795           0 :           unsigned long positionInPool = localIndex % SgModifierType::pool_size ;
   32796           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModifierType::pool_size ;
   32797             : 
   32798             : #if FILE_IO_EXTRA_CHECK
   32799             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   32800             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   32801             : #endif
   32802             : 
   32803           0 :           returnPointer = &( ( (SgModifierType*)(SgModifierType::pools[memoryBlock]) ) [positionInPool]) ;
   32804             : 
   32805             : #if FILE_IO_EXTRA_CHECK
   32806           0 :           assert ( returnPointer != NULL ) ;
   32807             : #endif
   32808             :         }
   32809           0 :      return returnPointer ;
   32810             :    }
   32811             : 
   32812             : //############################################################################
   32813             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   32814             :  * pool size! We set for every valid object in the memory pool the freepointer
   32815             :  * to the global index and increase the global index afterwards. For all the 
   32816             :  * invalid objects (means address ranges within the memory pool that were not
   32817             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   32818             :  * distinguish valid from invalid objects! 
   32819             :  */
   32820             : unsigned long
   32821           5 : SgModifierType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   32822             :    {
   32823           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   32824           5 :      SgModifierType* pointer = NULL;
   32825           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   32826           5 :      std::vector < unsigned char* > :: const_iterator block;
   32827           7 :      for ( block = SgModifierType::pools.begin(); block != SgModifierType::pools.end() ; ++block )
   32828             :         {
   32829           2 :           pointer = (SgModifierType*)(*block);
   32830        4002 :           for (unsigned i = 0; i < SgModifierType::pool_size; ++i )
   32831             :              {
   32832             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   32833             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   32834             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   32835             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   32836             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   32837             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   32838             :             // properly; so this will have to be checked next.
   32839             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   32840             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   32841        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   32842             :                   {
   32843         876 :                     pointer[i].set_freepointer((SgModifierType*)(globalIndex));
   32844         876 :                     globalIndex++;
   32845             :                   }
   32846             :                else
   32847             :                   {
   32848        3124 :                     pointer[i].set_freepointer(NULL);
   32849             :                   }
   32850             :               }
   32851             :         }
   32852           5 :      return globalIndex;
   32853             :    }
   32854             : 
   32855             : //############################################################################
   32856             : // JH (01/14/2006)
   32857             : void
   32858           5 : SgModifierType::resetValidFreepointers( )
   32859             :    {
   32860           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   32861           5 :      SgModifierType* pointer = NULL;
   32862           5 :      std::vector < unsigned char* > :: const_iterator block;
   32863           5 :      SgModifierType* pointerOfLinkedList = NULL;
   32864           7 :      for ( block = SgModifierType::pools.begin(); block != SgModifierType::pools.end() ; ++block )
   32865             :         {
   32866           2 :           pointer = (SgModifierType*)(*block);
   32867        4002 :           for (unsigned i = 0; i < SgModifierType::pool_size; ++i )
   32868             :              {
   32869             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   32870             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   32871             :             // memory blocks!.
   32872        4000 :                if ( pointer[i].get_freepointer() != NULL )
   32873             :                   {
   32874         876 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   32875             :                   }
   32876             :                else
   32877             :                   {
   32878        3124 :                     if ( pointerOfLinkedList == NULL )
   32879             :                        {
   32880           2 :                          SgModifierType::next_node = &(pointer[i]);
   32881             :                        }
   32882             :                     else
   32883             :                        {
   32884             :                       // printf ("In SgModifierType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   32885        3122 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   32886             :                        }
   32887             :                     pointerOfLinkedList = &(pointer[i]);
   32888             :                   }
   32889             :               }
   32890             :         }
   32891             : 
   32892           5 :      if ( pointerOfLinkedList != NULL )
   32893             :         {
   32894             :        // printf ("In SgModifierType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   32895           2 :           pointerOfLinkedList->set_freepointer(NULL);
   32896             :        // DQ (6/6/2010): Temporary debugging...
   32897             :        //   ROSE_ASSERT(false);
   32898             :         }
   32899             : 
   32900           5 :      return ;
   32901             :    }
   32902             : 
   32903             : //############################################################################
   32904             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   32905             :  * within the memory pool and resets the freepointers, in order to achieve a 
   32906             :  * linked list, that has no jumps and starts at the beginning! This function 
   32907             :  * does not extend the memory pool, since we do not delete any memory blocks,
   32908             :  * but delete the valid objects.  
   32909             :  */
   32910             : void
   32911           0 : SgModifierType::clearMemoryPool( )
   32912             :    {
   32913             :   // printf ("Inside of SgModifierType::clearMemoryPool() \n");
   32914             : 
   32915           0 :      SgModifierType* pointer = NULL, *tempPointer = NULL;
   32916           0 :      std::vector < unsigned char* > :: const_iterator block;
   32917           0 :      if ( SgModifierType::pools.empty() == false )
   32918             :         {
   32919           0 :           block = SgModifierType::pools.begin() ;
   32920           0 :           SgModifierType::next_node = (SgModifierType*) (*block);
   32921             : 
   32922           0 :           while ( block != SgModifierType::pools.end() )
   32923             :              {
   32924           0 :                pointer = (SgModifierType*) (*block);
   32925           0 :                if ( tempPointer != NULL )
   32926             :                   {
   32927           0 :                     tempPointer->set_freepointer(pointer);
   32928             :                   }
   32929           0 :                for (unsigned i = 0; i < SgModifierType::pool_size - 1; ++i)
   32930             :                   {
   32931           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   32932             :                   }
   32933           0 :                 pointer[SgModifierType::pool_size-1].set_freepointer(NULL);
   32934           0 :                 tempPointer = &(pointer[SgModifierType::pool_size-1]);
   32935           0 :                 ++block;
   32936             :              }
   32937             :         }
   32938           0 :    }
   32939             : 
   32940           5 : void SgModifierType::deleteMemoryPool() {
   32941           9 :   for (auto p: SgModifierType::pools) {
   32942           4 :     ROSE_FREE(p);
   32943             :   }
   32944           5 :   SgModifierType::next_node = nullptr;
   32945           5 :   SgModifierType::pools.clear();
   32946           5 : }
   32947             : 
   32948             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   32949             : //                 reading multiple binary files to for a single AST.
   32950             : /////////// new version ////////////////////////////////
   32951             : //############################################################################
   32952             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   32953             : void
   32954           2 : SgModifierType::extendMemoryPoolForFileIO( )
   32955             :   {
   32956           2 :     size_t blockIndex = SgModifierType::pools.size();
   32957           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgModifierType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifierType);
   32958             : 
   32959           4 :     while ( (blockIndex * SgModifierType::pool_size) < newPoolSize)
   32960             :       {
   32961             : #if ROSE_ALLOC_TRACE
   32962             :         if (blockIndex > 0) {
   32963             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgModifierType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifierType) = %" PRIuPTR " SgModifierType::pool_size = %d \n",
   32964             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgModifierType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgModifierType),SgModifierType::pool_size);
   32965             :         }
   32966             : #endif
   32967             : 
   32968           2 :         SgModifierType * pointer = (SgModifierType*) ROSE_MALLOC ( SgModifierType::pool_size * sizeof(SgModifierType) );
   32969           2 :         assert( pointer != NULL );
   32970             : #if ROSE_ALLOC_MEMSET == 1
   32971             :         memset(pointer, 0x00, SgModifierType::pool_size * sizeof(SgModifierType));
   32972             : #elif ROSE_ALLOC_MEMSET == 2
   32973             :         memset(pointer, 0xCC, SgModifierType::pool_size * sizeof(SgModifierType));
   32974             : #endif
   32975           2 :         SgModifierType::pools.push_back( (unsigned char*)(pointer) );
   32976           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgModifierType::pool_size * sizeof(SgModifierType), V_SgModifierType ) );
   32977             : 
   32978           2 :         if ( SgModifierType::next_node != NULL ) {
   32979           0 :           if ( blockIndex > 0 ) {
   32980           0 :             SgModifierType * blkptr = (SgModifierType*)(SgModifierType::pools[blockIndex-1]);
   32981           0 :             blkptr[ SgModifierType::pool_size - 1 ].set_freepointer(pointer);
   32982             :           }
   32983             :         } else {
   32984           2 :           SgModifierType::next_node = pointer;
   32985             :         }
   32986             : 
   32987        4000 :         for (unsigned i = 0; i < SgModifierType::pool_size-1; ++i)
   32988             :            {
   32989        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   32990             :            }
   32991           2 :         pointer[ SgModifierType::pool_size -1 ].set_freepointer(NULL);
   32992             : 
   32993           2 :         blockIndex++;
   32994             :       }
   32995           2 :   }
   32996             : 
   32997             : //############################################################################
   32998             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   32999             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   33000             :  * not compressed. However, that stuff is not yet implemented! 
   33001             :  */
   33002             : unsigned long
   33003           0 : SgModifierType::getNumberOfLastValidPointer()
   33004             :    {
   33005           0 :       SgModifierType* testPointer = (SgModifierType*)(SgModifierType::pools.back());
   33006           0 :       unsigned long localIndex = SgModifierType::pool_size - 1;
   33007           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   33008             :          {
   33009           0 :            localIndex--;
   33010             :          }
   33011           0 :       return (localIndex + SgModifierType::pool_size * (SgModifierType::pools.size()-1));
   33012             :    }
   33013             : 
   33014             : //############################################################################
   33015             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   33016             :  * memory pool and initializes the data member in class SgModifierTypeStroageClass
   33017             :  * from its counterpart of SgModifierType. The return value is just for checking, 
   33018             :  * that the whole StorageClassArray is initialized!
   33019             :  */
   33020             : unsigned long
   33021           2 : SgModifierType::initializeStorageClassArray( SgModifierTypeStorageClass *storageArray )
   33022             :    {
   33023           2 :      unsigned long storageCounter = 0;
   33024           2 :      std::vector < unsigned char* > :: const_iterator block = SgModifierType::pools.begin();
   33025           2 :      SgModifierType* pointer = NULL;
   33026           4 :      while ( block != SgModifierType::pools.end() ) {
   33027           2 :           pointer = (SgModifierType*) (*block);
   33028        4002 :           for ( unsigned i = 0; i < SgModifierType::pool_size; ++i ) {
   33029        4000 :                if ( pointer->get_freepointer() != NULL ) {
   33030         876 :                  storageArray->pickOutIRNodeData (pointer) ;
   33031         876 :                  storageArray++;
   33032         876 :                  storageCounter++;
   33033             :                }
   33034        4000 :                pointer++;
   33035             :              }
   33036           2 :            block++;
   33037             :         }
   33038           2 :      return storageCounter;
   33039             :    }
   33040             : 
   33041             : /* #line 33042 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   33042             : 
   33043             : 
   33044             : 
   33045             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   33046             : 
   33047             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   33048             : 
   33049             : //############################################################################
   33050             : /* JH (02/02/2006) Constructor of the IR node SgFunctionType that takes its 
   33051             :  * corresponding StorageClass as parameter
   33052             :  */
   33053        5316 : SgFunctionType :: SgFunctionType ( const SgFunctionTypeStorageClass& storageSource )   : SgType (storageSource)
   33054             :    {
   33055             : 
   33056             : 
   33057             : /* #line 33058 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   33058             : 
   33059        5316 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   33060        5316 :      p_return_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_return_type) );
   33061        5316 :      p_has_ellipses = storageSource.storageOf_has_ellipses ;
   33062        5316 :      p_orig_return_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_orig_return_type) );
   33063        5316 :      p_argument_list =  (SgFunctionParameterTypeList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_argument_list) );
   33064             : 
   33065             : 
   33066             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   33067             : 
   33068             : 
   33069        5316 :    }
   33070             : 
   33071             : //############################################################################
   33072             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   33073             :  * within the working AST. 
   33074             :  */
   33075       28713 : SgFunctionType * SgFunctionType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   33076       28713 :      SgFunctionType* returnPointer = NULL;
   33077       28713 :      if ( globalIndex != 0 )
   33078             :         {
   33079             : 
   33080             : #if FILE_IO_EXTRA_CHECK
   33081       28713 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionType ) ) <= globalIndex ) ;
   33082       28713 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionType + 1 ) ) );
   33083             : #endif
   33084       28713 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionType )  
   33085       28713 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionType );
   33086       28713 :           unsigned long positionInPool = localIndex % SgFunctionType::pool_size;
   33087       28713 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionType::pool_size;
   33088             : 
   33089             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   33090             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   33091             : 
   33092       28713 :           returnPointer = &( ( (SgFunctionType*)(SgFunctionType::pools[memoryBlock]) ) [positionInPool]) ;
   33093             : 
   33094       28713 :           ROSE_ASSERT( returnPointer != NULL ) ;
   33095             :         }
   33096       28713 :      return returnPointer ;
   33097             :    }
   33098             : 
   33099             : //############################################################################
   33100             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   33101             :   for the AST with the index astIndex
   33102             : */
   33103           0 : SgFunctionType * SgFunctionType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   33104           0 :      SgFunctionType* returnPointer = NULL;
   33105           0 :      if ( globalIndex != 0 )
   33106             :         {
   33107             : 
   33108             : #if FILE_IO_EXTRA_CHECK
   33109           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionType ) ) <= globalIndex ) ;
   33110           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionType + 1 ) ) );
   33111             : #endif
   33112           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionType )
   33113           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionType );
   33114           0 :           unsigned long positionInPool = localIndex % SgFunctionType::pool_size ;
   33115           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionType::pool_size ;
   33116             : 
   33117             : #if FILE_IO_EXTRA_CHECK
   33118             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   33119             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   33120             : #endif
   33121             : 
   33122           0 :           returnPointer = &( ( (SgFunctionType*)(SgFunctionType::pools[memoryBlock]) ) [positionInPool]) ;
   33123             : 
   33124             : #if FILE_IO_EXTRA_CHECK
   33125           0 :           assert ( returnPointer != NULL ) ;
   33126             : #endif
   33127             :         }
   33128           0 :      return returnPointer ;
   33129             :    }
   33130             : 
   33131             : //############################################################################
   33132             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   33133             :  * pool size! We set for every valid object in the memory pool the freepointer
   33134             :  * to the global index and increase the global index afterwards. For all the 
   33135             :  * invalid objects (means address ranges within the memory pool that were not
   33136             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   33137             :  * distinguish valid from invalid objects! 
   33138             :  */
   33139             : unsigned long
   33140           5 : SgFunctionType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   33141             :    {
   33142           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   33143           5 :      SgFunctionType* pointer = NULL;
   33144           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   33145           5 :      std::vector < unsigned char* > :: const_iterator block;
   33146           9 :      for ( block = SgFunctionType::pools.begin(); block != SgFunctionType::pools.end() ; ++block )
   33147             :         {
   33148           4 :           pointer = (SgFunctionType*)(*block);
   33149        8004 :           for (unsigned i = 0; i < SgFunctionType::pool_size; ++i )
   33150             :              {
   33151             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   33152             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   33153             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   33154             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   33155             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   33156             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   33157             :             // properly; so this will have to be checked next.
   33158             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   33159             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   33160        8000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   33161             :                   {
   33162        3150 :                     pointer[i].set_freepointer((SgFunctionType*)(globalIndex));
   33163        3150 :                     globalIndex++;
   33164             :                   }
   33165             :                else
   33166             :                   {
   33167        4850 :                     pointer[i].set_freepointer(NULL);
   33168             :                   }
   33169             :               }
   33170             :         }
   33171           5 :      return globalIndex;
   33172             :    }
   33173             : 
   33174             : //############################################################################
   33175             : // JH (01/14/2006)
   33176             : void
   33177           5 : SgFunctionType::resetValidFreepointers( )
   33178             :    {
   33179           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   33180           5 :      SgFunctionType* pointer = NULL;
   33181           5 :      std::vector < unsigned char* > :: const_iterator block;
   33182           5 :      SgFunctionType* pointerOfLinkedList = NULL;
   33183           9 :      for ( block = SgFunctionType::pools.begin(); block != SgFunctionType::pools.end() ; ++block )
   33184             :         {
   33185           4 :           pointer = (SgFunctionType*)(*block);
   33186        8004 :           for (unsigned i = 0; i < SgFunctionType::pool_size; ++i )
   33187             :              {
   33188             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   33189             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   33190             :             // memory blocks!.
   33191        8000 :                if ( pointer[i].get_freepointer() != NULL )
   33192             :                   {
   33193        3150 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   33194             :                   }
   33195             :                else
   33196             :                   {
   33197        4850 :                     if ( pointerOfLinkedList == NULL )
   33198             :                        {
   33199           3 :                          SgFunctionType::next_node = &(pointer[i]);
   33200             :                        }
   33201             :                     else
   33202             :                        {
   33203             :                       // printf ("In SgFunctionType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   33204        4847 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   33205             :                        }
   33206             :                     pointerOfLinkedList = &(pointer[i]);
   33207             :                   }
   33208             :               }
   33209             :         }
   33210             : 
   33211           5 :      if ( pointerOfLinkedList != NULL )
   33212             :         {
   33213             :        // printf ("In SgFunctionType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   33214           3 :           pointerOfLinkedList->set_freepointer(NULL);
   33215             :        // DQ (6/6/2010): Temporary debugging...
   33216             :        //   ROSE_ASSERT(false);
   33217             :         }
   33218             : 
   33219           5 :      return ;
   33220             :    }
   33221             : 
   33222             : //############################################################################
   33223             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   33224             :  * within the memory pool and resets the freepointers, in order to achieve a 
   33225             :  * linked list, that has no jumps and starts at the beginning! This function 
   33226             :  * does not extend the memory pool, since we do not delete any memory blocks,
   33227             :  * but delete the valid objects.  
   33228             :  */
   33229             : void
   33230           0 : SgFunctionType::clearMemoryPool( )
   33231             :    {
   33232             :   // printf ("Inside of SgFunctionType::clearMemoryPool() \n");
   33233             : 
   33234           0 :      SgFunctionType* pointer = NULL, *tempPointer = NULL;
   33235           0 :      std::vector < unsigned char* > :: const_iterator block;
   33236           0 :      if ( SgFunctionType::pools.empty() == false )
   33237             :         {
   33238           0 :           block = SgFunctionType::pools.begin() ;
   33239           0 :           SgFunctionType::next_node = (SgFunctionType*) (*block);
   33240             : 
   33241           0 :           while ( block != SgFunctionType::pools.end() )
   33242             :              {
   33243           0 :                pointer = (SgFunctionType*) (*block);
   33244           0 :                if ( tempPointer != NULL )
   33245             :                   {
   33246           0 :                     tempPointer->set_freepointer(pointer);
   33247             :                   }
   33248           0 :                for (unsigned i = 0; i < SgFunctionType::pool_size - 1; ++i)
   33249             :                   {
   33250           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   33251             :                   }
   33252           0 :                 pointer[SgFunctionType::pool_size-1].set_freepointer(NULL);
   33253           0 :                 tempPointer = &(pointer[SgFunctionType::pool_size-1]);
   33254           0 :                 ++block;
   33255             :              }
   33256             :         }
   33257           0 :    }
   33258             : 
   33259           5 : void SgFunctionType::deleteMemoryPool() {
   33260          12 :   for (auto p: SgFunctionType::pools) {
   33261           7 :     ROSE_FREE(p);
   33262             :   }
   33263           5 :   SgFunctionType::next_node = nullptr;
   33264           5 :   SgFunctionType::pools.clear();
   33265           5 : }
   33266             : 
   33267             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   33268             : //                 reading multiple binary files to for a single AST.
   33269             : /////////// new version ////////////////////////////////
   33270             : //############################################################################
   33271             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   33272             : void
   33273           2 : SgFunctionType::extendMemoryPoolForFileIO( )
   33274             :   {
   33275           2 :     size_t blockIndex = SgFunctionType::pools.size();
   33276           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionType);
   33277             : 
   33278           5 :     while ( (blockIndex * SgFunctionType::pool_size) < newPoolSize)
   33279             :       {
   33280             : #if ROSE_ALLOC_TRACE
   33281             :         if (blockIndex > 0) {
   33282             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionType) = %" PRIuPTR " SgFunctionType::pool_size = %d \n",
   33283             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionType),SgFunctionType::pool_size);
   33284             :         }
   33285             : #endif
   33286             : 
   33287           3 :         SgFunctionType * pointer = (SgFunctionType*) ROSE_MALLOC ( SgFunctionType::pool_size * sizeof(SgFunctionType) );
   33288           3 :         assert( pointer != NULL );
   33289             : #if ROSE_ALLOC_MEMSET == 1
   33290             :         memset(pointer, 0x00, SgFunctionType::pool_size * sizeof(SgFunctionType));
   33291             : #elif ROSE_ALLOC_MEMSET == 2
   33292             :         memset(pointer, 0xCC, SgFunctionType::pool_size * sizeof(SgFunctionType));
   33293             : #endif
   33294           3 :         SgFunctionType::pools.push_back( (unsigned char*)(pointer) );
   33295           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionType::pool_size * sizeof(SgFunctionType), V_SgFunctionType ) );
   33296             : 
   33297           3 :         if ( SgFunctionType::next_node != NULL ) {
   33298           1 :           if ( blockIndex > 0 ) {
   33299           1 :             SgFunctionType * blkptr = (SgFunctionType*)(SgFunctionType::pools[blockIndex-1]);
   33300           1 :             blkptr[ SgFunctionType::pool_size - 1 ].set_freepointer(pointer);
   33301             :           }
   33302             :         } else {
   33303           2 :           SgFunctionType::next_node = pointer;
   33304             :         }
   33305             : 
   33306        6000 :         for (unsigned i = 0; i < SgFunctionType::pool_size-1; ++i)
   33307             :            {
   33308        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   33309             :            }
   33310           3 :         pointer[ SgFunctionType::pool_size -1 ].set_freepointer(NULL);
   33311             : 
   33312           3 :         blockIndex++;
   33313             :       }
   33314           2 :   }
   33315             : 
   33316             : //############################################################################
   33317             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   33318             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   33319             :  * not compressed. However, that stuff is not yet implemented! 
   33320             :  */
   33321             : unsigned long
   33322           0 : SgFunctionType::getNumberOfLastValidPointer()
   33323             :    {
   33324           0 :       SgFunctionType* testPointer = (SgFunctionType*)(SgFunctionType::pools.back());
   33325           0 :       unsigned long localIndex = SgFunctionType::pool_size - 1;
   33326           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   33327             :          {
   33328           0 :            localIndex--;
   33329             :          }
   33330           0 :       return (localIndex + SgFunctionType::pool_size * (SgFunctionType::pools.size()-1));
   33331             :    }
   33332             : 
   33333             : //############################################################################
   33334             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   33335             :  * memory pool and initializes the data member in class SgFunctionTypeStroageClass
   33336             :  * from its counterpart of SgFunctionType. The return value is just for checking, 
   33337             :  * that the whole StorageClassArray is initialized!
   33338             :  */
   33339             : unsigned long
   33340           3 : SgFunctionType::initializeStorageClassArray( SgFunctionTypeStorageClass *storageArray )
   33341             :    {
   33342           3 :      unsigned long storageCounter = 0;
   33343           3 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionType::pools.begin();
   33344           3 :      SgFunctionType* pointer = NULL;
   33345           7 :      while ( block != SgFunctionType::pools.end() ) {
   33346           4 :           pointer = (SgFunctionType*) (*block);
   33347        8004 :           for ( unsigned i = 0; i < SgFunctionType::pool_size; ++i ) {
   33348        8000 :                if ( pointer->get_freepointer() != NULL ) {
   33349        3150 :                  storageArray->pickOutIRNodeData (pointer) ;
   33350        3150 :                  storageArray++;
   33351        3150 :                  storageCounter++;
   33352             :                }
   33353        8000 :                pointer++;
   33354             :              }
   33355           4 :            block++;
   33356             :         }
   33357           3 :      return storageCounter;
   33358             :    }
   33359             : 
   33360             : /* #line 33361 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   33361             : 
   33362             : 
   33363             : 
   33364             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   33365             : 
   33366             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   33367             : 
   33368             : //############################################################################
   33369             : /* JH (02/02/2006) Constructor of the IR node SgMemberFunctionType that takes its 
   33370             :  * corresponding StorageClass as parameter
   33371             :  */
   33372        2167 : SgMemberFunctionType :: SgMemberFunctionType ( const SgMemberFunctionTypeStorageClass& storageSource )   : SgFunctionType (storageSource)
   33373             :    {
   33374             : 
   33375             : 
   33376             : /* #line 33377 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   33377             : 
   33378        2167 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   33379        2167 :      p_class_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_class_type) );
   33380        2167 :      p_mfunc_specifier = storageSource.storageOf_mfunc_specifier ;
   33381        2167 :      p_ref_qualifiers = storageSource.storageOf_ref_qualifiers ;
   33382             : 
   33383             : 
   33384             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   33385             : 
   33386             : 
   33387        2167 :    }
   33388             : 
   33389             : //############################################################################
   33390             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   33391             :  * within the working AST. 
   33392             :  */
   33393       13599 : SgMemberFunctionType * SgMemberFunctionType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   33394       13599 :      SgMemberFunctionType* returnPointer = NULL;
   33395       13599 :      if ( globalIndex != 0 )
   33396             :         {
   33397             : 
   33398             : #if FILE_IO_EXTRA_CHECK
   33399       13599 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMemberFunctionType ) ) <= globalIndex ) ;
   33400       13599 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMemberFunctionType + 1 ) ) );
   33401             : #endif
   33402       13599 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMemberFunctionType )  
   33403       13599 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMemberFunctionType );
   33404       13599 :           unsigned long positionInPool = localIndex % SgMemberFunctionType::pool_size;
   33405       13599 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMemberFunctionType::pool_size;
   33406             : 
   33407             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   33408             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   33409             : 
   33410       13599 :           returnPointer = &( ( (SgMemberFunctionType*)(SgMemberFunctionType::pools[memoryBlock]) ) [positionInPool]) ;
   33411             : 
   33412       13599 :           ROSE_ASSERT( returnPointer != NULL ) ;
   33413             :         }
   33414       13599 :      return returnPointer ;
   33415             :    }
   33416             : 
   33417             : //############################################################################
   33418             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   33419             :   for the AST with the index astIndex
   33420             : */
   33421           0 : SgMemberFunctionType * SgMemberFunctionType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   33422           0 :      SgMemberFunctionType* returnPointer = NULL;
   33423           0 :      if ( globalIndex != 0 )
   33424             :         {
   33425             : 
   33426             : #if FILE_IO_EXTRA_CHECK
   33427           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMemberFunctionType ) ) <= globalIndex ) ;
   33428           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMemberFunctionType + 1 ) ) );
   33429             : #endif
   33430           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMemberFunctionType )
   33431           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMemberFunctionType );
   33432           0 :           unsigned long positionInPool = localIndex % SgMemberFunctionType::pool_size ;
   33433           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMemberFunctionType::pool_size ;
   33434             : 
   33435             : #if FILE_IO_EXTRA_CHECK
   33436             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   33437             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   33438             : #endif
   33439             : 
   33440           0 :           returnPointer = &( ( (SgMemberFunctionType*)(SgMemberFunctionType::pools[memoryBlock]) ) [positionInPool]) ;
   33441             : 
   33442             : #if FILE_IO_EXTRA_CHECK
   33443           0 :           assert ( returnPointer != NULL ) ;
   33444             : #endif
   33445             :         }
   33446           0 :      return returnPointer ;
   33447             :    }
   33448             : 
   33449             : //############################################################################
   33450             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   33451             :  * pool size! We set for every valid object in the memory pool the freepointer
   33452             :  * to the global index and increase the global index afterwards. For all the 
   33453             :  * invalid objects (means address ranges within the memory pool that were not
   33454             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   33455             :  * distinguish valid from invalid objects! 
   33456             :  */
   33457             : unsigned long
   33458           5 : SgMemberFunctionType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   33459             :    {
   33460           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   33461           5 :      SgMemberFunctionType* pointer = NULL;
   33462           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   33463           5 :      std::vector < unsigned char* > :: const_iterator block;
   33464           7 :      for ( block = SgMemberFunctionType::pools.begin(); block != SgMemberFunctionType::pools.end() ; ++block )
   33465             :         {
   33466           2 :           pointer = (SgMemberFunctionType*)(*block);
   33467        4002 :           for (unsigned i = 0; i < SgMemberFunctionType::pool_size; ++i )
   33468             :              {
   33469             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   33470             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   33471             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   33472             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   33473             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   33474             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   33475             :             // properly; so this will have to be checked next.
   33476             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   33477             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   33478        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   33479             :                   {
   33480        2167 :                     pointer[i].set_freepointer((SgMemberFunctionType*)(globalIndex));
   33481        2167 :                     globalIndex++;
   33482             :                   }
   33483             :                else
   33484             :                   {
   33485        1833 :                     pointer[i].set_freepointer(NULL);
   33486             :                   }
   33487             :               }
   33488             :         }
   33489           5 :      return globalIndex;
   33490             :    }
   33491             : 
   33492             : //############################################################################
   33493             : // JH (01/14/2006)
   33494             : void
   33495           5 : SgMemberFunctionType::resetValidFreepointers( )
   33496             :    {
   33497           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   33498           5 :      SgMemberFunctionType* pointer = NULL;
   33499           5 :      std::vector < unsigned char* > :: const_iterator block;
   33500           5 :      SgMemberFunctionType* pointerOfLinkedList = NULL;
   33501           7 :      for ( block = SgMemberFunctionType::pools.begin(); block != SgMemberFunctionType::pools.end() ; ++block )
   33502             :         {
   33503           2 :           pointer = (SgMemberFunctionType*)(*block);
   33504        4002 :           for (unsigned i = 0; i < SgMemberFunctionType::pool_size; ++i )
   33505             :              {
   33506             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   33507             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   33508             :             // memory blocks!.
   33509        4000 :                if ( pointer[i].get_freepointer() != NULL )
   33510             :                   {
   33511        2167 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   33512             :                   }
   33513             :                else
   33514             :                   {
   33515        1833 :                     if ( pointerOfLinkedList == NULL )
   33516             :                        {
   33517           1 :                          SgMemberFunctionType::next_node = &(pointer[i]);
   33518             :                        }
   33519             :                     else
   33520             :                        {
   33521             :                       // printf ("In SgMemberFunctionType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   33522        1832 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   33523             :                        }
   33524             :                     pointerOfLinkedList = &(pointer[i]);
   33525             :                   }
   33526             :               }
   33527             :         }
   33528             : 
   33529           5 :      if ( pointerOfLinkedList != NULL )
   33530             :         {
   33531             :        // printf ("In SgMemberFunctionType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   33532           1 :           pointerOfLinkedList->set_freepointer(NULL);
   33533             :        // DQ (6/6/2010): Temporary debugging...
   33534             :        //   ROSE_ASSERT(false);
   33535             :         }
   33536             : 
   33537           5 :      return ;
   33538             :    }
   33539             : 
   33540             : //############################################################################
   33541             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   33542             :  * within the memory pool and resets the freepointers, in order to achieve a 
   33543             :  * linked list, that has no jumps and starts at the beginning! This function 
   33544             :  * does not extend the memory pool, since we do not delete any memory blocks,
   33545             :  * but delete the valid objects.  
   33546             :  */
   33547             : void
   33548           0 : SgMemberFunctionType::clearMemoryPool( )
   33549             :    {
   33550             :   // printf ("Inside of SgMemberFunctionType::clearMemoryPool() \n");
   33551             : 
   33552           0 :      SgMemberFunctionType* pointer = NULL, *tempPointer = NULL;
   33553           0 :      std::vector < unsigned char* > :: const_iterator block;
   33554           0 :      if ( SgMemberFunctionType::pools.empty() == false )
   33555             :         {
   33556           0 :           block = SgMemberFunctionType::pools.begin() ;
   33557           0 :           SgMemberFunctionType::next_node = (SgMemberFunctionType*) (*block);
   33558             : 
   33559           0 :           while ( block != SgMemberFunctionType::pools.end() )
   33560             :              {
   33561           0 :                pointer = (SgMemberFunctionType*) (*block);
   33562           0 :                if ( tempPointer != NULL )
   33563             :                   {
   33564           0 :                     tempPointer->set_freepointer(pointer);
   33565             :                   }
   33566           0 :                for (unsigned i = 0; i < SgMemberFunctionType::pool_size - 1; ++i)
   33567             :                   {
   33568           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   33569             :                   }
   33570           0 :                 pointer[SgMemberFunctionType::pool_size-1].set_freepointer(NULL);
   33571           0 :                 tempPointer = &(pointer[SgMemberFunctionType::pool_size-1]);
   33572           0 :                 ++block;
   33573             :              }
   33574             :         }
   33575           0 :    }
   33576             : 
   33577           5 : void SgMemberFunctionType::deleteMemoryPool() {
   33578           9 :   for (auto p: SgMemberFunctionType::pools) {
   33579           4 :     ROSE_FREE(p);
   33580             :   }
   33581           5 :   SgMemberFunctionType::next_node = nullptr;
   33582           5 :   SgMemberFunctionType::pools.clear();
   33583           5 : }
   33584             : 
   33585             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   33586             : //                 reading multiple binary files to for a single AST.
   33587             : /////////// new version ////////////////////////////////
   33588             : //############################################################################
   33589             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   33590             : void
   33591           2 : SgMemberFunctionType::extendMemoryPoolForFileIO( )
   33592             :   {
   33593           2 :     size_t blockIndex = SgMemberFunctionType::pools.size();
   33594           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionType);
   33595             : 
   33596           4 :     while ( (blockIndex * SgMemberFunctionType::pool_size) < newPoolSize)
   33597             :       {
   33598             : #if ROSE_ALLOC_TRACE
   33599             :         if (blockIndex > 0) {
   33600             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionType) = %" PRIuPTR " SgMemberFunctionType::pool_size = %d \n",
   33601             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionType),SgMemberFunctionType::pool_size);
   33602             :         }
   33603             : #endif
   33604             : 
   33605           2 :         SgMemberFunctionType * pointer = (SgMemberFunctionType*) ROSE_MALLOC ( SgMemberFunctionType::pool_size * sizeof(SgMemberFunctionType) );
   33606           2 :         assert( pointer != NULL );
   33607             : #if ROSE_ALLOC_MEMSET == 1
   33608             :         memset(pointer, 0x00, SgMemberFunctionType::pool_size * sizeof(SgMemberFunctionType));
   33609             : #elif ROSE_ALLOC_MEMSET == 2
   33610             :         memset(pointer, 0xCC, SgMemberFunctionType::pool_size * sizeof(SgMemberFunctionType));
   33611             : #endif
   33612           2 :         SgMemberFunctionType::pools.push_back( (unsigned char*)(pointer) );
   33613           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMemberFunctionType::pool_size * sizeof(SgMemberFunctionType), V_SgMemberFunctionType ) );
   33614             : 
   33615           2 :         if ( SgMemberFunctionType::next_node != NULL ) {
   33616           1 :           if ( blockIndex > 0 ) {
   33617           1 :             SgMemberFunctionType * blkptr = (SgMemberFunctionType*)(SgMemberFunctionType::pools[blockIndex-1]);
   33618           1 :             blkptr[ SgMemberFunctionType::pool_size - 1 ].set_freepointer(pointer);
   33619             :           }
   33620             :         } else {
   33621           1 :           SgMemberFunctionType::next_node = pointer;
   33622             :         }
   33623             : 
   33624        4000 :         for (unsigned i = 0; i < SgMemberFunctionType::pool_size-1; ++i)
   33625             :            {
   33626        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   33627             :            }
   33628           2 :         pointer[ SgMemberFunctionType::pool_size -1 ].set_freepointer(NULL);
   33629             : 
   33630           2 :         blockIndex++;
   33631             :       }
   33632           2 :   }
   33633             : 
   33634             : //############################################################################
   33635             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   33636             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   33637             :  * not compressed. However, that stuff is not yet implemented! 
   33638             :  */
   33639             : unsigned long
   33640           0 : SgMemberFunctionType::getNumberOfLastValidPointer()
   33641             :    {
   33642           0 :       SgMemberFunctionType* testPointer = (SgMemberFunctionType*)(SgMemberFunctionType::pools.back());
   33643           0 :       unsigned long localIndex = SgMemberFunctionType::pool_size - 1;
   33644           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   33645             :          {
   33646           0 :            localIndex--;
   33647             :          }
   33648           0 :       return (localIndex + SgMemberFunctionType::pool_size * (SgMemberFunctionType::pools.size()-1));
   33649             :    }
   33650             : 
   33651             : //############################################################################
   33652             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   33653             :  * memory pool and initializes the data member in class SgMemberFunctionTypeStroageClass
   33654             :  * from its counterpart of SgMemberFunctionType. The return value is just for checking, 
   33655             :  * that the whole StorageClassArray is initialized!
   33656             :  */
   33657             : unsigned long
   33658           1 : SgMemberFunctionType::initializeStorageClassArray( SgMemberFunctionTypeStorageClass *storageArray )
   33659             :    {
   33660           1 :      unsigned long storageCounter = 0;
   33661           1 :      std::vector < unsigned char* > :: const_iterator block = SgMemberFunctionType::pools.begin();
   33662           1 :      SgMemberFunctionType* pointer = NULL;
   33663           3 :      while ( block != SgMemberFunctionType::pools.end() ) {
   33664           2 :           pointer = (SgMemberFunctionType*) (*block);
   33665        4002 :           for ( unsigned i = 0; i < SgMemberFunctionType::pool_size; ++i ) {
   33666        4000 :                if ( pointer->get_freepointer() != NULL ) {
   33667        2167 :                  storageArray->pickOutIRNodeData (pointer) ;
   33668        2167 :                  storageArray++;
   33669        2167 :                  storageCounter++;
   33670             :                }
   33671        4000 :                pointer++;
   33672             :              }
   33673           2 :            block++;
   33674             :         }
   33675           1 :      return storageCounter;
   33676             :    }
   33677             : 
   33678             : /* #line 33679 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   33679             : 
   33680             : 
   33681             : 
   33682             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   33683             : 
   33684             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   33685             : 
   33686             : //############################################################################
   33687             : /* JH (02/02/2006) Constructor of the IR node SgPartialFunctionType that takes its 
   33688             :  * corresponding StorageClass as parameter
   33689             :  */
   33690           0 : SgPartialFunctionType :: SgPartialFunctionType ( const SgPartialFunctionTypeStorageClass& storageSource )   : SgMemberFunctionType (storageSource)
   33691             :    {
   33692             : 
   33693             : 
   33694             : /* #line 33695 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   33695             : 
   33696           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   33697             : 
   33698             : 
   33699             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   33700             : 
   33701             : 
   33702           0 :    }
   33703             : 
   33704             : //############################################################################
   33705             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   33706             :  * within the working AST. 
   33707             :  */
   33708           0 : SgPartialFunctionType * SgPartialFunctionType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   33709           0 :      SgPartialFunctionType* returnPointer = NULL;
   33710           0 :      if ( globalIndex != 0 )
   33711             :         {
   33712             : 
   33713             : #if FILE_IO_EXTRA_CHECK
   33714           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPartialFunctionType ) ) <= globalIndex ) ;
   33715           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPartialFunctionType + 1 ) ) );
   33716             : #endif
   33717           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPartialFunctionType )  
   33718           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPartialFunctionType );
   33719           0 :           unsigned long positionInPool = localIndex % SgPartialFunctionType::pool_size;
   33720           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPartialFunctionType::pool_size;
   33721             : 
   33722             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   33723             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   33724             : 
   33725           0 :           returnPointer = &( ( (SgPartialFunctionType*)(SgPartialFunctionType::pools[memoryBlock]) ) [positionInPool]) ;
   33726             : 
   33727           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   33728             :         }
   33729           0 :      return returnPointer ;
   33730             :    }
   33731             : 
   33732             : //############################################################################
   33733             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   33734             :   for the AST with the index astIndex
   33735             : */
   33736           0 : SgPartialFunctionType * SgPartialFunctionType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   33737           0 :      SgPartialFunctionType* returnPointer = NULL;
   33738           0 :      if ( globalIndex != 0 )
   33739             :         {
   33740             : 
   33741             : #if FILE_IO_EXTRA_CHECK
   33742           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPartialFunctionType ) ) <= globalIndex ) ;
   33743           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPartialFunctionType + 1 ) ) );
   33744             : #endif
   33745           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPartialFunctionType )
   33746           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPartialFunctionType );
   33747           0 :           unsigned long positionInPool = localIndex % SgPartialFunctionType::pool_size ;
   33748           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPartialFunctionType::pool_size ;
   33749             : 
   33750             : #if FILE_IO_EXTRA_CHECK
   33751             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   33752             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   33753             : #endif
   33754             : 
   33755           0 :           returnPointer = &( ( (SgPartialFunctionType*)(SgPartialFunctionType::pools[memoryBlock]) ) [positionInPool]) ;
   33756             : 
   33757             : #if FILE_IO_EXTRA_CHECK
   33758           0 :           assert ( returnPointer != NULL ) ;
   33759             : #endif
   33760             :         }
   33761           0 :      return returnPointer ;
   33762             :    }
   33763             : 
   33764             : //############################################################################
   33765             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   33766             :  * pool size! We set for every valid object in the memory pool the freepointer
   33767             :  * to the global index and increase the global index afterwards. For all the 
   33768             :  * invalid objects (means address ranges within the memory pool that were not
   33769             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   33770             :  * distinguish valid from invalid objects! 
   33771             :  */
   33772             : unsigned long
   33773           5 : SgPartialFunctionType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   33774             :    {
   33775           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   33776           5 :      SgPartialFunctionType* pointer = NULL;
   33777           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   33778           5 :      std::vector < unsigned char* > :: const_iterator block;
   33779           6 :      for ( block = SgPartialFunctionType::pools.begin(); block != SgPartialFunctionType::pools.end() ; ++block )
   33780             :         {
   33781           1 :           pointer = (SgPartialFunctionType*)(*block);
   33782        2001 :           for (unsigned i = 0; i < SgPartialFunctionType::pool_size; ++i )
   33783             :              {
   33784             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   33785             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   33786             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   33787             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   33788             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   33789             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   33790             :             // properly; so this will have to be checked next.
   33791             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   33792             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   33793        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   33794             :                   {
   33795           0 :                     pointer[i].set_freepointer((SgPartialFunctionType*)(globalIndex));
   33796           0 :                     globalIndex++;
   33797             :                   }
   33798             :                else
   33799             :                   {
   33800        2000 :                     pointer[i].set_freepointer(NULL);
   33801             :                   }
   33802             :               }
   33803             :         }
   33804           5 :      return globalIndex;
   33805             :    }
   33806             : 
   33807             : //############################################################################
   33808             : // JH (01/14/2006)
   33809             : void
   33810           5 : SgPartialFunctionType::resetValidFreepointers( )
   33811             :    {
   33812           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   33813           5 :      SgPartialFunctionType* pointer = NULL;
   33814           5 :      std::vector < unsigned char* > :: const_iterator block;
   33815           5 :      SgPartialFunctionType* pointerOfLinkedList = NULL;
   33816           6 :      for ( block = SgPartialFunctionType::pools.begin(); block != SgPartialFunctionType::pools.end() ; ++block )
   33817             :         {
   33818           1 :           pointer = (SgPartialFunctionType*)(*block);
   33819        2001 :           for (unsigned i = 0; i < SgPartialFunctionType::pool_size; ++i )
   33820             :              {
   33821             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   33822             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   33823             :             // memory blocks!.
   33824        2000 :                if ( pointer[i].get_freepointer() != NULL )
   33825             :                   {
   33826           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   33827             :                   }
   33828             :                else
   33829             :                   {
   33830        2000 :                     if ( pointerOfLinkedList == NULL )
   33831             :                        {
   33832           1 :                          SgPartialFunctionType::next_node = &(pointer[i]);
   33833             :                        }
   33834             :                     else
   33835             :                        {
   33836             :                       // printf ("In SgPartialFunctionType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   33837        1999 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   33838             :                        }
   33839             :                     pointerOfLinkedList = &(pointer[i]);
   33840             :                   }
   33841             :               }
   33842             :         }
   33843             : 
   33844           5 :      if ( pointerOfLinkedList != NULL )
   33845             :         {
   33846             :        // printf ("In SgPartialFunctionType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   33847           1 :           pointerOfLinkedList->set_freepointer(NULL);
   33848             :        // DQ (6/6/2010): Temporary debugging...
   33849             :        //   ROSE_ASSERT(false);
   33850             :         }
   33851             : 
   33852           5 :      return ;
   33853             :    }
   33854             : 
   33855             : //############################################################################
   33856             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   33857             :  * within the memory pool and resets the freepointers, in order to achieve a 
   33858             :  * linked list, that has no jumps and starts at the beginning! This function 
   33859             :  * does not extend the memory pool, since we do not delete any memory blocks,
   33860             :  * but delete the valid objects.  
   33861             :  */
   33862             : void
   33863           0 : SgPartialFunctionType::clearMemoryPool( )
   33864             :    {
   33865             :   // printf ("Inside of SgPartialFunctionType::clearMemoryPool() \n");
   33866             : 
   33867           0 :      SgPartialFunctionType* pointer = NULL, *tempPointer = NULL;
   33868           0 :      std::vector < unsigned char* > :: const_iterator block;
   33869           0 :      if ( SgPartialFunctionType::pools.empty() == false )
   33870             :         {
   33871           0 :           block = SgPartialFunctionType::pools.begin() ;
   33872           0 :           SgPartialFunctionType::next_node = (SgPartialFunctionType*) (*block);
   33873             : 
   33874           0 :           while ( block != SgPartialFunctionType::pools.end() )
   33875             :              {
   33876           0 :                pointer = (SgPartialFunctionType*) (*block);
   33877           0 :                if ( tempPointer != NULL )
   33878             :                   {
   33879           0 :                     tempPointer->set_freepointer(pointer);
   33880             :                   }
   33881           0 :                for (unsigned i = 0; i < SgPartialFunctionType::pool_size - 1; ++i)
   33882             :                   {
   33883           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   33884             :                   }
   33885           0 :                 pointer[SgPartialFunctionType::pool_size-1].set_freepointer(NULL);
   33886           0 :                 tempPointer = &(pointer[SgPartialFunctionType::pool_size-1]);
   33887           0 :                 ++block;
   33888             :              }
   33889             :         }
   33890           0 :    }
   33891             : 
   33892           5 : void SgPartialFunctionType::deleteMemoryPool() {
   33893           6 :   for (auto p: SgPartialFunctionType::pools) {
   33894           1 :     ROSE_FREE(p);
   33895             :   }
   33896           5 :   SgPartialFunctionType::next_node = nullptr;
   33897           5 :   SgPartialFunctionType::pools.clear();
   33898           5 : }
   33899             : 
   33900             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   33901             : //                 reading multiple binary files to for a single AST.
   33902             : /////////// new version ////////////////////////////////
   33903             : //############################################################################
   33904             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   33905             : void
   33906           2 : SgPartialFunctionType::extendMemoryPoolForFileIO( )
   33907             :   {
   33908           2 :     size_t blockIndex = SgPartialFunctionType::pools.size();
   33909           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPartialFunctionType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPartialFunctionType);
   33910             : 
   33911           2 :     while ( (blockIndex * SgPartialFunctionType::pool_size) < newPoolSize)
   33912             :       {
   33913             : #if ROSE_ALLOC_TRACE
   33914             :         if (blockIndex > 0) {
   33915             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPartialFunctionType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPartialFunctionType) = %" PRIuPTR " SgPartialFunctionType::pool_size = %d \n",
   33916             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPartialFunctionType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPartialFunctionType),SgPartialFunctionType::pool_size);
   33917             :         }
   33918             : #endif
   33919             : 
   33920           0 :         SgPartialFunctionType * pointer = (SgPartialFunctionType*) ROSE_MALLOC ( SgPartialFunctionType::pool_size * sizeof(SgPartialFunctionType) );
   33921           0 :         assert( pointer != NULL );
   33922             : #if ROSE_ALLOC_MEMSET == 1
   33923             :         memset(pointer, 0x00, SgPartialFunctionType::pool_size * sizeof(SgPartialFunctionType));
   33924             : #elif ROSE_ALLOC_MEMSET == 2
   33925             :         memset(pointer, 0xCC, SgPartialFunctionType::pool_size * sizeof(SgPartialFunctionType));
   33926             : #endif
   33927           0 :         SgPartialFunctionType::pools.push_back( (unsigned char*)(pointer) );
   33928           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPartialFunctionType::pool_size * sizeof(SgPartialFunctionType), V_SgPartialFunctionType ) );
   33929             : 
   33930           0 :         if ( SgPartialFunctionType::next_node != NULL ) {
   33931           0 :           if ( blockIndex > 0 ) {
   33932           0 :             SgPartialFunctionType * blkptr = (SgPartialFunctionType*)(SgPartialFunctionType::pools[blockIndex-1]);
   33933           0 :             blkptr[ SgPartialFunctionType::pool_size - 1 ].set_freepointer(pointer);
   33934             :           }
   33935             :         } else {
   33936           0 :           SgPartialFunctionType::next_node = pointer;
   33937             :         }
   33938             : 
   33939           0 :         for (unsigned i = 0; i < SgPartialFunctionType::pool_size-1; ++i)
   33940             :            {
   33941           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   33942             :            }
   33943           0 :         pointer[ SgPartialFunctionType::pool_size -1 ].set_freepointer(NULL);
   33944             : 
   33945           0 :         blockIndex++;
   33946             :       }
   33947           2 :   }
   33948             : 
   33949             : //############################################################################
   33950             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   33951             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   33952             :  * not compressed. However, that stuff is not yet implemented! 
   33953             :  */
   33954             : unsigned long
   33955           0 : SgPartialFunctionType::getNumberOfLastValidPointer()
   33956             :    {
   33957           0 :       SgPartialFunctionType* testPointer = (SgPartialFunctionType*)(SgPartialFunctionType::pools.back());
   33958           0 :       unsigned long localIndex = SgPartialFunctionType::pool_size - 1;
   33959           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   33960             :          {
   33961           0 :            localIndex--;
   33962             :          }
   33963           0 :       return (localIndex + SgPartialFunctionType::pool_size * (SgPartialFunctionType::pools.size()-1));
   33964             :    }
   33965             : 
   33966             : //############################################################################
   33967             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   33968             :  * memory pool and initializes the data member in class SgPartialFunctionTypeStroageClass
   33969             :  * from its counterpart of SgPartialFunctionType. The return value is just for checking, 
   33970             :  * that the whole StorageClassArray is initialized!
   33971             :  */
   33972             : unsigned long
   33973           0 : SgPartialFunctionType::initializeStorageClassArray( SgPartialFunctionTypeStorageClass *storageArray )
   33974             :    {
   33975           0 :      unsigned long storageCounter = 0;
   33976           0 :      std::vector < unsigned char* > :: const_iterator block = SgPartialFunctionType::pools.begin();
   33977           0 :      SgPartialFunctionType* pointer = NULL;
   33978           0 :      while ( block != SgPartialFunctionType::pools.end() ) {
   33979           0 :           pointer = (SgPartialFunctionType*) (*block);
   33980           0 :           for ( unsigned i = 0; i < SgPartialFunctionType::pool_size; ++i ) {
   33981           0 :                if ( pointer->get_freepointer() != NULL ) {
   33982           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   33983           0 :                  storageArray++;
   33984           0 :                  storageCounter++;
   33985             :                }
   33986           0 :                pointer++;
   33987             :              }
   33988           0 :            block++;
   33989             :         }
   33990           0 :      return storageCounter;
   33991             :    }
   33992             : 
   33993             : /* #line 33994 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   33994             : 
   33995             : 
   33996             : 
   33997             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   33998             : 
   33999             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   34000             : 
   34001             : //############################################################################
   34002             : /* JH (02/02/2006) Constructor of the IR node SgPartialFunctionModifierType that takes its 
   34003             :  * corresponding StorageClass as parameter
   34004             :  */
   34005           0 : SgPartialFunctionModifierType :: SgPartialFunctionModifierType ( const SgPartialFunctionModifierTypeStorageClass& storageSource )   : SgPartialFunctionType (storageSource)
   34006             :    {
   34007             : 
   34008             : 
   34009             : /* #line 34010 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   34010             : 
   34011           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   34012             : 
   34013             : 
   34014             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   34015             : 
   34016             : 
   34017           0 :    }
   34018             : 
   34019             : //############################################################################
   34020             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   34021             :  * within the working AST. 
   34022             :  */
   34023           0 : SgPartialFunctionModifierType * SgPartialFunctionModifierType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   34024           0 :      SgPartialFunctionModifierType* returnPointer = NULL;
   34025           0 :      if ( globalIndex != 0 )
   34026             :         {
   34027             : 
   34028             : #if FILE_IO_EXTRA_CHECK
   34029           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPartialFunctionModifierType ) ) <= globalIndex ) ;
   34030           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPartialFunctionModifierType + 1 ) ) );
   34031             : #endif
   34032           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPartialFunctionModifierType )  
   34033           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPartialFunctionModifierType );
   34034           0 :           unsigned long positionInPool = localIndex % SgPartialFunctionModifierType::pool_size;
   34035           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPartialFunctionModifierType::pool_size;
   34036             : 
   34037             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   34038             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   34039             : 
   34040           0 :           returnPointer = &( ( (SgPartialFunctionModifierType*)(SgPartialFunctionModifierType::pools[memoryBlock]) ) [positionInPool]) ;
   34041             : 
   34042           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   34043             :         }
   34044           0 :      return returnPointer ;
   34045             :    }
   34046             : 
   34047             : //############################################################################
   34048             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   34049             :   for the AST with the index astIndex
   34050             : */
   34051           0 : SgPartialFunctionModifierType * SgPartialFunctionModifierType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   34052           0 :      SgPartialFunctionModifierType* returnPointer = NULL;
   34053           0 :      if ( globalIndex != 0 )
   34054             :         {
   34055             : 
   34056             : #if FILE_IO_EXTRA_CHECK
   34057           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPartialFunctionModifierType ) ) <= globalIndex ) ;
   34058           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPartialFunctionModifierType + 1 ) ) );
   34059             : #endif
   34060           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPartialFunctionModifierType )
   34061           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPartialFunctionModifierType );
   34062           0 :           unsigned long positionInPool = localIndex % SgPartialFunctionModifierType::pool_size ;
   34063           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPartialFunctionModifierType::pool_size ;
   34064             : 
   34065             : #if FILE_IO_EXTRA_CHECK
   34066             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   34067             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   34068             : #endif
   34069             : 
   34070           0 :           returnPointer = &( ( (SgPartialFunctionModifierType*)(SgPartialFunctionModifierType::pools[memoryBlock]) ) [positionInPool]) ;
   34071             : 
   34072             : #if FILE_IO_EXTRA_CHECK
   34073           0 :           assert ( returnPointer != NULL ) ;
   34074             : #endif
   34075             :         }
   34076           0 :      return returnPointer ;
   34077             :    }
   34078             : 
   34079             : //############################################################################
   34080             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   34081             :  * pool size! We set for every valid object in the memory pool the freepointer
   34082             :  * to the global index and increase the global index afterwards. For all the 
   34083             :  * invalid objects (means address ranges within the memory pool that were not
   34084             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   34085             :  * distinguish valid from invalid objects! 
   34086             :  */
   34087             : unsigned long
   34088           5 : SgPartialFunctionModifierType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   34089             :    {
   34090           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   34091           5 :      SgPartialFunctionModifierType* pointer = NULL;
   34092           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   34093           5 :      std::vector < unsigned char* > :: const_iterator block;
   34094           5 :      for ( block = SgPartialFunctionModifierType::pools.begin(); block != SgPartialFunctionModifierType::pools.end() ; ++block )
   34095             :         {
   34096           0 :           pointer = (SgPartialFunctionModifierType*)(*block);
   34097           0 :           for (unsigned i = 0; i < SgPartialFunctionModifierType::pool_size; ++i )
   34098             :              {
   34099             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   34100             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   34101             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   34102             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   34103             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   34104             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   34105             :             // properly; so this will have to be checked next.
   34106             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   34107             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   34108           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   34109             :                   {
   34110           0 :                     pointer[i].set_freepointer((SgPartialFunctionModifierType*)(globalIndex));
   34111           0 :                     globalIndex++;
   34112             :                   }
   34113             :                else
   34114             :                   {
   34115           0 :                     pointer[i].set_freepointer(NULL);
   34116             :                   }
   34117             :               }
   34118             :         }
   34119           5 :      return globalIndex;
   34120             :    }
   34121             : 
   34122             : //############################################################################
   34123             : // JH (01/14/2006)
   34124             : void
   34125           5 : SgPartialFunctionModifierType::resetValidFreepointers( )
   34126             :    {
   34127           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   34128           5 :      SgPartialFunctionModifierType* pointer = NULL;
   34129           5 :      std::vector < unsigned char* > :: const_iterator block;
   34130           5 :      SgPartialFunctionModifierType* pointerOfLinkedList = NULL;
   34131           5 :      for ( block = SgPartialFunctionModifierType::pools.begin(); block != SgPartialFunctionModifierType::pools.end() ; ++block )
   34132             :         {
   34133           0 :           pointer = (SgPartialFunctionModifierType*)(*block);
   34134           0 :           for (unsigned i = 0; i < SgPartialFunctionModifierType::pool_size; ++i )
   34135             :              {
   34136             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   34137             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   34138             :             // memory blocks!.
   34139           0 :                if ( pointer[i].get_freepointer() != NULL )
   34140             :                   {
   34141           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   34142             :                   }
   34143             :                else
   34144             :                   {
   34145           0 :                     if ( pointerOfLinkedList == NULL )
   34146             :                        {
   34147           0 :                          SgPartialFunctionModifierType::next_node = &(pointer[i]);
   34148             :                        }
   34149             :                     else
   34150             :                        {
   34151             :                       // printf ("In SgPartialFunctionModifierType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   34152           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   34153             :                        }
   34154             :                     pointerOfLinkedList = &(pointer[i]);
   34155             :                   }
   34156             :               }
   34157             :         }
   34158             : 
   34159           5 :      if ( pointerOfLinkedList != NULL )
   34160             :         {
   34161             :        // printf ("In SgPartialFunctionModifierType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   34162           0 :           pointerOfLinkedList->set_freepointer(NULL);
   34163             :        // DQ (6/6/2010): Temporary debugging...
   34164             :        //   ROSE_ASSERT(false);
   34165             :         }
   34166             : 
   34167           5 :      return ;
   34168             :    }
   34169             : 
   34170             : //############################################################################
   34171             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   34172             :  * within the memory pool and resets the freepointers, in order to achieve a 
   34173             :  * linked list, that has no jumps and starts at the beginning! This function 
   34174             :  * does not extend the memory pool, since we do not delete any memory blocks,
   34175             :  * but delete the valid objects.  
   34176             :  */
   34177             : void
   34178           0 : SgPartialFunctionModifierType::clearMemoryPool( )
   34179             :    {
   34180             :   // printf ("Inside of SgPartialFunctionModifierType::clearMemoryPool() \n");
   34181             : 
   34182           0 :      SgPartialFunctionModifierType* pointer = NULL, *tempPointer = NULL;
   34183           0 :      std::vector < unsigned char* > :: const_iterator block;
   34184           0 :      if ( SgPartialFunctionModifierType::pools.empty() == false )
   34185             :         {
   34186           0 :           block = SgPartialFunctionModifierType::pools.begin() ;
   34187           0 :           SgPartialFunctionModifierType::next_node = (SgPartialFunctionModifierType*) (*block);
   34188             : 
   34189           0 :           while ( block != SgPartialFunctionModifierType::pools.end() )
   34190             :              {
   34191           0 :                pointer = (SgPartialFunctionModifierType*) (*block);
   34192           0 :                if ( tempPointer != NULL )
   34193             :                   {
   34194           0 :                     tempPointer->set_freepointer(pointer);
   34195             :                   }
   34196           0 :                for (unsigned i = 0; i < SgPartialFunctionModifierType::pool_size - 1; ++i)
   34197             :                   {
   34198           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   34199             :                   }
   34200           0 :                 pointer[SgPartialFunctionModifierType::pool_size-1].set_freepointer(NULL);
   34201           0 :                 tempPointer = &(pointer[SgPartialFunctionModifierType::pool_size-1]);
   34202           0 :                 ++block;
   34203             :              }
   34204             :         }
   34205           0 :    }
   34206             : 
   34207           5 : void SgPartialFunctionModifierType::deleteMemoryPool() {
   34208           5 :   for (auto p: SgPartialFunctionModifierType::pools) {
   34209           0 :     ROSE_FREE(p);
   34210             :   }
   34211           5 :   SgPartialFunctionModifierType::next_node = nullptr;
   34212           5 :   SgPartialFunctionModifierType::pools.clear();
   34213           5 : }
   34214             : 
   34215             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   34216             : //                 reading multiple binary files to for a single AST.
   34217             : /////////// new version ////////////////////////////////
   34218             : //############################################################################
   34219             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   34220             : void
   34221           2 : SgPartialFunctionModifierType::extendMemoryPoolForFileIO( )
   34222             :   {
   34223           2 :     size_t blockIndex = SgPartialFunctionModifierType::pools.size();
   34224           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPartialFunctionModifierType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPartialFunctionModifierType);
   34225             : 
   34226           2 :     while ( (blockIndex * SgPartialFunctionModifierType::pool_size) < newPoolSize)
   34227             :       {
   34228             : #if ROSE_ALLOC_TRACE
   34229             :         if (blockIndex > 0) {
   34230             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPartialFunctionModifierType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPartialFunctionModifierType) = %" PRIuPTR " SgPartialFunctionModifierType::pool_size = %d \n",
   34231             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPartialFunctionModifierType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPartialFunctionModifierType),SgPartialFunctionModifierType::pool_size);
   34232             :         }
   34233             : #endif
   34234             : 
   34235           0 :         SgPartialFunctionModifierType * pointer = (SgPartialFunctionModifierType*) ROSE_MALLOC ( SgPartialFunctionModifierType::pool_size * sizeof(SgPartialFunctionModifierType) );
   34236           0 :         assert( pointer != NULL );
   34237             : #if ROSE_ALLOC_MEMSET == 1
   34238             :         memset(pointer, 0x00, SgPartialFunctionModifierType::pool_size * sizeof(SgPartialFunctionModifierType));
   34239             : #elif ROSE_ALLOC_MEMSET == 2
   34240             :         memset(pointer, 0xCC, SgPartialFunctionModifierType::pool_size * sizeof(SgPartialFunctionModifierType));
   34241             : #endif
   34242           0 :         SgPartialFunctionModifierType::pools.push_back( (unsigned char*)(pointer) );
   34243           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPartialFunctionModifierType::pool_size * sizeof(SgPartialFunctionModifierType), V_SgPartialFunctionModifierType ) );
   34244             : 
   34245           0 :         if ( SgPartialFunctionModifierType::next_node != NULL ) {
   34246           0 :           if ( blockIndex > 0 ) {
   34247           0 :             SgPartialFunctionModifierType * blkptr = (SgPartialFunctionModifierType*)(SgPartialFunctionModifierType::pools[blockIndex-1]);
   34248           0 :             blkptr[ SgPartialFunctionModifierType::pool_size - 1 ].set_freepointer(pointer);
   34249             :           }
   34250             :         } else {
   34251           0 :           SgPartialFunctionModifierType::next_node = pointer;
   34252             :         }
   34253             : 
   34254           0 :         for (unsigned i = 0; i < SgPartialFunctionModifierType::pool_size-1; ++i)
   34255             :            {
   34256           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   34257             :            }
   34258           0 :         pointer[ SgPartialFunctionModifierType::pool_size -1 ].set_freepointer(NULL);
   34259             : 
   34260           0 :         blockIndex++;
   34261             :       }
   34262           2 :   }
   34263             : 
   34264             : //############################################################################
   34265             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   34266             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   34267             :  * not compressed. However, that stuff is not yet implemented! 
   34268             :  */
   34269             : unsigned long
   34270           0 : SgPartialFunctionModifierType::getNumberOfLastValidPointer()
   34271             :    {
   34272           0 :       SgPartialFunctionModifierType* testPointer = (SgPartialFunctionModifierType*)(SgPartialFunctionModifierType::pools.back());
   34273           0 :       unsigned long localIndex = SgPartialFunctionModifierType::pool_size - 1;
   34274           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   34275             :          {
   34276           0 :            localIndex--;
   34277             :          }
   34278           0 :       return (localIndex + SgPartialFunctionModifierType::pool_size * (SgPartialFunctionModifierType::pools.size()-1));
   34279             :    }
   34280             : 
   34281             : //############################################################################
   34282             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   34283             :  * memory pool and initializes the data member in class SgPartialFunctionModifierTypeStroageClass
   34284             :  * from its counterpart of SgPartialFunctionModifierType. The return value is just for checking, 
   34285             :  * that the whole StorageClassArray is initialized!
   34286             :  */
   34287             : unsigned long
   34288           0 : SgPartialFunctionModifierType::initializeStorageClassArray( SgPartialFunctionModifierTypeStorageClass *storageArray )
   34289             :    {
   34290           0 :      unsigned long storageCounter = 0;
   34291           0 :      std::vector < unsigned char* > :: const_iterator block = SgPartialFunctionModifierType::pools.begin();
   34292           0 :      SgPartialFunctionModifierType* pointer = NULL;
   34293           0 :      while ( block != SgPartialFunctionModifierType::pools.end() ) {
   34294           0 :           pointer = (SgPartialFunctionModifierType*) (*block);
   34295           0 :           for ( unsigned i = 0; i < SgPartialFunctionModifierType::pool_size; ++i ) {
   34296           0 :                if ( pointer->get_freepointer() != NULL ) {
   34297           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   34298           0 :                  storageArray++;
   34299           0 :                  storageCounter++;
   34300             :                }
   34301           0 :                pointer++;
   34302             :              }
   34303           0 :            block++;
   34304             :         }
   34305           0 :      return storageCounter;
   34306             :    }
   34307             : 
   34308             : /* #line 34309 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   34309             : 
   34310             : 
   34311             : 
   34312             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   34313             : 
   34314             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   34315             : 
   34316             : //############################################################################
   34317             : /* JH (02/02/2006) Constructor of the IR node SgArrayType that takes its 
   34318             :  * corresponding StorageClass as parameter
   34319             :  */
   34320         108 : SgArrayType :: SgArrayType ( const SgArrayTypeStorageClass& storageSource )   : SgType (storageSource)
   34321             :    {
   34322             : 
   34323             : 
   34324             : /* #line 34325 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   34325             : 
   34326         108 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   34327         108 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   34328         108 :      p_index =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_index) );
   34329         108 :      p_dim_info =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_dim_info) );
   34330         108 :      p_rank = storageSource.storageOf_rank ;
   34331         108 :      p_number_of_elements = storageSource.storageOf_number_of_elements ;
   34332         108 :      p_is_variable_length_array = storageSource.storageOf_is_variable_length_array ;
   34333             : 
   34334             : 
   34335             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   34336             : 
   34337             : 
   34338         108 :    }
   34339             : 
   34340             : //############################################################################
   34341             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   34342             :  * within the working AST. 
   34343             :  */
   34344         347 : SgArrayType * SgArrayType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   34345         347 :      SgArrayType* returnPointer = NULL;
   34346         347 :      if ( globalIndex != 0 )
   34347             :         {
   34348             : 
   34349             : #if FILE_IO_EXTRA_CHECK
   34350         347 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgArrayType ) ) <= globalIndex ) ;
   34351         347 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgArrayType + 1 ) ) );
   34352             : #endif
   34353         347 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgArrayType )  
   34354         347 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgArrayType );
   34355         347 :           unsigned long positionInPool = localIndex % SgArrayType::pool_size;
   34356         347 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgArrayType::pool_size;
   34357             : 
   34358             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   34359             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   34360             : 
   34361         347 :           returnPointer = &( ( (SgArrayType*)(SgArrayType::pools[memoryBlock]) ) [positionInPool]) ;
   34362             : 
   34363         347 :           ROSE_ASSERT( returnPointer != NULL ) ;
   34364             :         }
   34365         347 :      return returnPointer ;
   34366             :    }
   34367             : 
   34368             : //############################################################################
   34369             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   34370             :   for the AST with the index astIndex
   34371             : */
   34372           0 : SgArrayType * SgArrayType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   34373           0 :      SgArrayType* returnPointer = NULL;
   34374           0 :      if ( globalIndex != 0 )
   34375             :         {
   34376             : 
   34377             : #if FILE_IO_EXTRA_CHECK
   34378           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgArrayType ) ) <= globalIndex ) ;
   34379           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgArrayType + 1 ) ) );
   34380             : #endif
   34381           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgArrayType )
   34382           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgArrayType );
   34383           0 :           unsigned long positionInPool = localIndex % SgArrayType::pool_size ;
   34384           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgArrayType::pool_size ;
   34385             : 
   34386             : #if FILE_IO_EXTRA_CHECK
   34387             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   34388             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   34389             : #endif
   34390             : 
   34391           0 :           returnPointer = &( ( (SgArrayType*)(SgArrayType::pools[memoryBlock]) ) [positionInPool]) ;
   34392             : 
   34393             : #if FILE_IO_EXTRA_CHECK
   34394           0 :           assert ( returnPointer != NULL ) ;
   34395             : #endif
   34396             :         }
   34397           0 :      return returnPointer ;
   34398             :    }
   34399             : 
   34400             : //############################################################################
   34401             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   34402             :  * pool size! We set for every valid object in the memory pool the freepointer
   34403             :  * to the global index and increase the global index afterwards. For all the 
   34404             :  * invalid objects (means address ranges within the memory pool that were not
   34405             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   34406             :  * distinguish valid from invalid objects! 
   34407             :  */
   34408             : unsigned long
   34409           5 : SgArrayType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   34410             :    {
   34411           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   34412           5 :      SgArrayType* pointer = NULL;
   34413           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   34414           5 :      std::vector < unsigned char* > :: const_iterator block;
   34415           7 :      for ( block = SgArrayType::pools.begin(); block != SgArrayType::pools.end() ; ++block )
   34416             :         {
   34417           2 :           pointer = (SgArrayType*)(*block);
   34418        4002 :           for (unsigned i = 0; i < SgArrayType::pool_size; ++i )
   34419             :              {
   34420             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   34421             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   34422             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   34423             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   34424             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   34425             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   34426             :             // properly; so this will have to be checked next.
   34427             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   34428             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   34429        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   34430             :                   {
   34431         108 :                     pointer[i].set_freepointer((SgArrayType*)(globalIndex));
   34432         108 :                     globalIndex++;
   34433             :                   }
   34434             :                else
   34435             :                   {
   34436        3892 :                     pointer[i].set_freepointer(NULL);
   34437             :                   }
   34438             :               }
   34439             :         }
   34440           5 :      return globalIndex;
   34441             :    }
   34442             : 
   34443             : //############################################################################
   34444             : // JH (01/14/2006)
   34445             : void
   34446           5 : SgArrayType::resetValidFreepointers( )
   34447             :    {
   34448           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   34449           5 :      SgArrayType* pointer = NULL;
   34450           5 :      std::vector < unsigned char* > :: const_iterator block;
   34451           5 :      SgArrayType* pointerOfLinkedList = NULL;
   34452           7 :      for ( block = SgArrayType::pools.begin(); block != SgArrayType::pools.end() ; ++block )
   34453             :         {
   34454           2 :           pointer = (SgArrayType*)(*block);
   34455        4002 :           for (unsigned i = 0; i < SgArrayType::pool_size; ++i )
   34456             :              {
   34457             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   34458             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   34459             :             // memory blocks!.
   34460        4000 :                if ( pointer[i].get_freepointer() != NULL )
   34461             :                   {
   34462         108 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   34463             :                   }
   34464             :                else
   34465             :                   {
   34466        3892 :                     if ( pointerOfLinkedList == NULL )
   34467             :                        {
   34468           2 :                          SgArrayType::next_node = &(pointer[i]);
   34469             :                        }
   34470             :                     else
   34471             :                        {
   34472             :                       // printf ("In SgArrayType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   34473        3890 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   34474             :                        }
   34475             :                     pointerOfLinkedList = &(pointer[i]);
   34476             :                   }
   34477             :               }
   34478             :         }
   34479             : 
   34480           5 :      if ( pointerOfLinkedList != NULL )
   34481             :         {
   34482             :        // printf ("In SgArrayType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   34483           2 :           pointerOfLinkedList->set_freepointer(NULL);
   34484             :        // DQ (6/6/2010): Temporary debugging...
   34485             :        //   ROSE_ASSERT(false);
   34486             :         }
   34487             : 
   34488           5 :      return ;
   34489             :    }
   34490             : 
   34491             : //############################################################################
   34492             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   34493             :  * within the memory pool and resets the freepointers, in order to achieve a 
   34494             :  * linked list, that has no jumps and starts at the beginning! This function 
   34495             :  * does not extend the memory pool, since we do not delete any memory blocks,
   34496             :  * but delete the valid objects.  
   34497             :  */
   34498             : void
   34499           0 : SgArrayType::clearMemoryPool( )
   34500             :    {
   34501             :   // printf ("Inside of SgArrayType::clearMemoryPool() \n");
   34502             : 
   34503           0 :      SgArrayType* pointer = NULL, *tempPointer = NULL;
   34504           0 :      std::vector < unsigned char* > :: const_iterator block;
   34505           0 :      if ( SgArrayType::pools.empty() == false )
   34506             :         {
   34507           0 :           block = SgArrayType::pools.begin() ;
   34508           0 :           SgArrayType::next_node = (SgArrayType*) (*block);
   34509             : 
   34510           0 :           while ( block != SgArrayType::pools.end() )
   34511             :              {
   34512           0 :                pointer = (SgArrayType*) (*block);
   34513           0 :                if ( tempPointer != NULL )
   34514             :                   {
   34515           0 :                     tempPointer->set_freepointer(pointer);
   34516             :                   }
   34517           0 :                for (unsigned i = 0; i < SgArrayType::pool_size - 1; ++i)
   34518             :                   {
   34519           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   34520             :                   }
   34521           0 :                 pointer[SgArrayType::pool_size-1].set_freepointer(NULL);
   34522           0 :                 tempPointer = &(pointer[SgArrayType::pool_size-1]);
   34523           0 :                 ++block;
   34524             :              }
   34525             :         }
   34526           0 :    }
   34527             : 
   34528           5 : void SgArrayType::deleteMemoryPool() {
   34529           9 :   for (auto p: SgArrayType::pools) {
   34530           4 :     ROSE_FREE(p);
   34531             :   }
   34532           5 :   SgArrayType::next_node = nullptr;
   34533           5 :   SgArrayType::pools.clear();
   34534           5 : }
   34535             : 
   34536             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   34537             : //                 reading multiple binary files to for a single AST.
   34538             : /////////// new version ////////////////////////////////
   34539             : //############################################################################
   34540             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   34541             : void
   34542           2 : SgArrayType::extendMemoryPoolForFileIO( )
   34543             :   {
   34544           2 :     size_t blockIndex = SgArrayType::pools.size();
   34545           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgArrayType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrayType);
   34546             : 
   34547           4 :     while ( (blockIndex * SgArrayType::pool_size) < newPoolSize)
   34548             :       {
   34549             : #if ROSE_ALLOC_TRACE
   34550             :         if (blockIndex > 0) {
   34551             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgArrayType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrayType) = %" PRIuPTR " SgArrayType::pool_size = %d \n",
   34552             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgArrayType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrayType),SgArrayType::pool_size);
   34553             :         }
   34554             : #endif
   34555             : 
   34556           2 :         SgArrayType * pointer = (SgArrayType*) ROSE_MALLOC ( SgArrayType::pool_size * sizeof(SgArrayType) );
   34557           2 :         assert( pointer != NULL );
   34558             : #if ROSE_ALLOC_MEMSET == 1
   34559             :         memset(pointer, 0x00, SgArrayType::pool_size * sizeof(SgArrayType));
   34560             : #elif ROSE_ALLOC_MEMSET == 2
   34561             :         memset(pointer, 0xCC, SgArrayType::pool_size * sizeof(SgArrayType));
   34562             : #endif
   34563           2 :         SgArrayType::pools.push_back( (unsigned char*)(pointer) );
   34564           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgArrayType::pool_size * sizeof(SgArrayType), V_SgArrayType ) );
   34565             : 
   34566           2 :         if ( SgArrayType::next_node != NULL ) {
   34567           0 :           if ( blockIndex > 0 ) {
   34568           0 :             SgArrayType * blkptr = (SgArrayType*)(SgArrayType::pools[blockIndex-1]);
   34569           0 :             blkptr[ SgArrayType::pool_size - 1 ].set_freepointer(pointer);
   34570             :           }
   34571             :         } else {
   34572           2 :           SgArrayType::next_node = pointer;
   34573             :         }
   34574             : 
   34575        4000 :         for (unsigned i = 0; i < SgArrayType::pool_size-1; ++i)
   34576             :            {
   34577        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   34578             :            }
   34579           2 :         pointer[ SgArrayType::pool_size -1 ].set_freepointer(NULL);
   34580             : 
   34581           2 :         blockIndex++;
   34582             :       }
   34583           2 :   }
   34584             : 
   34585             : //############################################################################
   34586             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   34587             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   34588             :  * not compressed. However, that stuff is not yet implemented! 
   34589             :  */
   34590             : unsigned long
   34591           0 : SgArrayType::getNumberOfLastValidPointer()
   34592             :    {
   34593           0 :       SgArrayType* testPointer = (SgArrayType*)(SgArrayType::pools.back());
   34594           0 :       unsigned long localIndex = SgArrayType::pool_size - 1;
   34595           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   34596             :          {
   34597           0 :            localIndex--;
   34598             :          }
   34599           0 :       return (localIndex + SgArrayType::pool_size * (SgArrayType::pools.size()-1));
   34600             :    }
   34601             : 
   34602             : //############################################################################
   34603             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   34604             :  * memory pool and initializes the data member in class SgArrayTypeStroageClass
   34605             :  * from its counterpart of SgArrayType. The return value is just for checking, 
   34606             :  * that the whole StorageClassArray is initialized!
   34607             :  */
   34608             : unsigned long
   34609           2 : SgArrayType::initializeStorageClassArray( SgArrayTypeStorageClass *storageArray )
   34610             :    {
   34611           2 :      unsigned long storageCounter = 0;
   34612           2 :      std::vector < unsigned char* > :: const_iterator block = SgArrayType::pools.begin();
   34613           2 :      SgArrayType* pointer = NULL;
   34614           4 :      while ( block != SgArrayType::pools.end() ) {
   34615           2 :           pointer = (SgArrayType*) (*block);
   34616        4002 :           for ( unsigned i = 0; i < SgArrayType::pool_size; ++i ) {
   34617        4000 :                if ( pointer->get_freepointer() != NULL ) {
   34618         108 :                  storageArray->pickOutIRNodeData (pointer) ;
   34619         108 :                  storageArray++;
   34620         108 :                  storageCounter++;
   34621             :                }
   34622        4000 :                pointer++;
   34623             :              }
   34624           2 :            block++;
   34625             :         }
   34626           2 :      return storageCounter;
   34627             :    }
   34628             : 
   34629             : /* #line 34630 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   34630             : 
   34631             : 
   34632             : 
   34633             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   34634             : 
   34635             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   34636             : 
   34637             : //############################################################################
   34638             : /* JH (02/02/2006) Constructor of the IR node SgTypeEllipse that takes its 
   34639             :  * corresponding StorageClass as parameter
   34640             :  */
   34641           2 : SgTypeEllipse :: SgTypeEllipse ( const SgTypeEllipseStorageClass& storageSource )   : SgType (storageSource)
   34642             :    {
   34643             : 
   34644             : 
   34645             : /* #line 34646 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   34646             : 
   34647           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   34648             : 
   34649             : 
   34650             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   34651             : 
   34652             : 
   34653           2 :    }
   34654             : 
   34655             : //############################################################################
   34656             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   34657             :  * within the working AST. 
   34658             :  */
   34659         476 : SgTypeEllipse * SgTypeEllipse::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   34660         476 :      SgTypeEllipse* returnPointer = NULL;
   34661         476 :      if ( globalIndex != 0 )
   34662             :         {
   34663             : 
   34664             : #if FILE_IO_EXTRA_CHECK
   34665         476 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeEllipse ) ) <= globalIndex ) ;
   34666         476 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeEllipse + 1 ) ) );
   34667             : #endif
   34668         476 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeEllipse )  
   34669         476 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeEllipse );
   34670         476 :           unsigned long positionInPool = localIndex % SgTypeEllipse::pool_size;
   34671         476 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeEllipse::pool_size;
   34672             : 
   34673             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   34674             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   34675             : 
   34676         476 :           returnPointer = &( ( (SgTypeEllipse*)(SgTypeEllipse::pools[memoryBlock]) ) [positionInPool]) ;
   34677             : 
   34678         476 :           ROSE_ASSERT( returnPointer != NULL ) ;
   34679             :         }
   34680         476 :      return returnPointer ;
   34681             :    }
   34682             : 
   34683             : //############################################################################
   34684             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   34685             :   for the AST with the index astIndex
   34686             : */
   34687           0 : SgTypeEllipse * SgTypeEllipse::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   34688           0 :      SgTypeEllipse* returnPointer = NULL;
   34689           0 :      if ( globalIndex != 0 )
   34690             :         {
   34691             : 
   34692             : #if FILE_IO_EXTRA_CHECK
   34693           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeEllipse ) ) <= globalIndex ) ;
   34694           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeEllipse + 1 ) ) );
   34695             : #endif
   34696           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeEllipse )
   34697           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeEllipse );
   34698           0 :           unsigned long positionInPool = localIndex % SgTypeEllipse::pool_size ;
   34699           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeEllipse::pool_size ;
   34700             : 
   34701             : #if FILE_IO_EXTRA_CHECK
   34702             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   34703             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   34704             : #endif
   34705             : 
   34706           0 :           returnPointer = &( ( (SgTypeEllipse*)(SgTypeEllipse::pools[memoryBlock]) ) [positionInPool]) ;
   34707             : 
   34708             : #if FILE_IO_EXTRA_CHECK
   34709           0 :           assert ( returnPointer != NULL ) ;
   34710             : #endif
   34711             :         }
   34712           0 :      return returnPointer ;
   34713             :    }
   34714             : 
   34715             : //############################################################################
   34716             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   34717             :  * pool size! We set for every valid object in the memory pool the freepointer
   34718             :  * to the global index and increase the global index afterwards. For all the 
   34719             :  * invalid objects (means address ranges within the memory pool that were not
   34720             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   34721             :  * distinguish valid from invalid objects! 
   34722             :  */
   34723             : unsigned long
   34724           5 : SgTypeEllipse::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   34725             :    {
   34726           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   34727           5 :      SgTypeEllipse* pointer = NULL;
   34728           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   34729           5 :      std::vector < unsigned char* > :: const_iterator block;
   34730           7 :      for ( block = SgTypeEllipse::pools.begin(); block != SgTypeEllipse::pools.end() ; ++block )
   34731             :         {
   34732           2 :           pointer = (SgTypeEllipse*)(*block);
   34733        4002 :           for (unsigned i = 0; i < SgTypeEllipse::pool_size; ++i )
   34734             :              {
   34735             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   34736             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   34737             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   34738             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   34739             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   34740             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   34741             :             // properly; so this will have to be checked next.
   34742             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   34743             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   34744        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   34745             :                   {
   34746           2 :                     pointer[i].set_freepointer((SgTypeEllipse*)(globalIndex));
   34747           2 :                     globalIndex++;
   34748             :                   }
   34749             :                else
   34750             :                   {
   34751        3998 :                     pointer[i].set_freepointer(NULL);
   34752             :                   }
   34753             :               }
   34754             :         }
   34755           5 :      return globalIndex;
   34756             :    }
   34757             : 
   34758             : //############################################################################
   34759             : // JH (01/14/2006)
   34760             : void
   34761           5 : SgTypeEllipse::resetValidFreepointers( )
   34762             :    {
   34763           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   34764           5 :      SgTypeEllipse* pointer = NULL;
   34765           5 :      std::vector < unsigned char* > :: const_iterator block;
   34766           5 :      SgTypeEllipse* pointerOfLinkedList = NULL;
   34767           7 :      for ( block = SgTypeEllipse::pools.begin(); block != SgTypeEllipse::pools.end() ; ++block )
   34768             :         {
   34769           2 :           pointer = (SgTypeEllipse*)(*block);
   34770        4002 :           for (unsigned i = 0; i < SgTypeEllipse::pool_size; ++i )
   34771             :              {
   34772             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   34773             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   34774             :             // memory blocks!.
   34775        4000 :                if ( pointer[i].get_freepointer() != NULL )
   34776             :                   {
   34777           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   34778             :                   }
   34779             :                else
   34780             :                   {
   34781        3998 :                     if ( pointerOfLinkedList == NULL )
   34782             :                        {
   34783           2 :                          SgTypeEllipse::next_node = &(pointer[i]);
   34784             :                        }
   34785             :                     else
   34786             :                        {
   34787             :                       // printf ("In SgTypeEllipse::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   34788        3996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   34789             :                        }
   34790             :                     pointerOfLinkedList = &(pointer[i]);
   34791             :                   }
   34792             :               }
   34793             :         }
   34794             : 
   34795           5 :      if ( pointerOfLinkedList != NULL )
   34796             :         {
   34797             :        // printf ("In SgTypeEllipse::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   34798           2 :           pointerOfLinkedList->set_freepointer(NULL);
   34799             :        // DQ (6/6/2010): Temporary debugging...
   34800             :        //   ROSE_ASSERT(false);
   34801             :         }
   34802             : 
   34803           5 :      return ;
   34804             :    }
   34805             : 
   34806             : //############################################################################
   34807             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   34808             :  * within the memory pool and resets the freepointers, in order to achieve a 
   34809             :  * linked list, that has no jumps and starts at the beginning! This function 
   34810             :  * does not extend the memory pool, since we do not delete any memory blocks,
   34811             :  * but delete the valid objects.  
   34812             :  */
   34813             : void
   34814           0 : SgTypeEllipse::clearMemoryPool( )
   34815             :    {
   34816             :   // printf ("Inside of SgTypeEllipse::clearMemoryPool() \n");
   34817             : 
   34818           0 :      SgTypeEllipse* pointer = NULL, *tempPointer = NULL;
   34819           0 :      std::vector < unsigned char* > :: const_iterator block;
   34820           0 :      if ( SgTypeEllipse::pools.empty() == false )
   34821             :         {
   34822           0 :           block = SgTypeEllipse::pools.begin() ;
   34823           0 :           SgTypeEllipse::next_node = (SgTypeEllipse*) (*block);
   34824             : 
   34825           0 :           while ( block != SgTypeEllipse::pools.end() )
   34826             :              {
   34827           0 :                pointer = (SgTypeEllipse*) (*block);
   34828           0 :                if ( tempPointer != NULL )
   34829             :                   {
   34830           0 :                     tempPointer->set_freepointer(pointer);
   34831             :                   }
   34832           0 :                for (unsigned i = 0; i < SgTypeEllipse::pool_size - 1; ++i)
   34833             :                   {
   34834           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   34835             :                   }
   34836           0 :                 pointer[SgTypeEllipse::pool_size-1].set_freepointer(NULL);
   34837           0 :                 tempPointer = &(pointer[SgTypeEllipse::pool_size-1]);
   34838           0 :                 ++block;
   34839             :              }
   34840             :         }
   34841           0 :    }
   34842             : 
   34843           5 : void SgTypeEllipse::deleteMemoryPool() {
   34844           9 :   for (auto p: SgTypeEllipse::pools) {
   34845           4 :     ROSE_FREE(p);
   34846             :   }
   34847           5 :   SgTypeEllipse::next_node = nullptr;
   34848           5 :   SgTypeEllipse::pools.clear();
   34849           5 : }
   34850             : 
   34851             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   34852             : //                 reading multiple binary files to for a single AST.
   34853             : /////////// new version ////////////////////////////////
   34854             : //############################################################################
   34855             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   34856             : void
   34857           2 : SgTypeEllipse::extendMemoryPoolForFileIO( )
   34858             :   {
   34859           2 :     size_t blockIndex = SgTypeEllipse::pools.size();
   34860           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeEllipse) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeEllipse);
   34861             : 
   34862           4 :     while ( (blockIndex * SgTypeEllipse::pool_size) < newPoolSize)
   34863             :       {
   34864             : #if ROSE_ALLOC_TRACE
   34865             :         if (blockIndex > 0) {
   34866             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeEllipse) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeEllipse) = %" PRIuPTR " SgTypeEllipse::pool_size = %d \n",
   34867             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeEllipse),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeEllipse),SgTypeEllipse::pool_size);
   34868             :         }
   34869             : #endif
   34870             : 
   34871           2 :         SgTypeEllipse * pointer = (SgTypeEllipse*) ROSE_MALLOC ( SgTypeEllipse::pool_size * sizeof(SgTypeEllipse) );
   34872           2 :         assert( pointer != NULL );
   34873             : #if ROSE_ALLOC_MEMSET == 1
   34874             :         memset(pointer, 0x00, SgTypeEllipse::pool_size * sizeof(SgTypeEllipse));
   34875             : #elif ROSE_ALLOC_MEMSET == 2
   34876             :         memset(pointer, 0xCC, SgTypeEllipse::pool_size * sizeof(SgTypeEllipse));
   34877             : #endif
   34878           2 :         SgTypeEllipse::pools.push_back( (unsigned char*)(pointer) );
   34879           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeEllipse::pool_size * sizeof(SgTypeEllipse), V_SgTypeEllipse ) );
   34880             : 
   34881           2 :         if ( SgTypeEllipse::next_node != NULL ) {
   34882           0 :           if ( blockIndex > 0 ) {
   34883           0 :             SgTypeEllipse * blkptr = (SgTypeEllipse*)(SgTypeEllipse::pools[blockIndex-1]);
   34884           0 :             blkptr[ SgTypeEllipse::pool_size - 1 ].set_freepointer(pointer);
   34885             :           }
   34886             :         } else {
   34887           2 :           SgTypeEllipse::next_node = pointer;
   34888             :         }
   34889             : 
   34890        4000 :         for (unsigned i = 0; i < SgTypeEllipse::pool_size-1; ++i)
   34891             :            {
   34892        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   34893             :            }
   34894           2 :         pointer[ SgTypeEllipse::pool_size -1 ].set_freepointer(NULL);
   34895             : 
   34896           2 :         blockIndex++;
   34897             :       }
   34898           2 :   }
   34899             : 
   34900             : //############################################################################
   34901             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   34902             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   34903             :  * not compressed. However, that stuff is not yet implemented! 
   34904             :  */
   34905             : unsigned long
   34906           0 : SgTypeEllipse::getNumberOfLastValidPointer()
   34907             :    {
   34908           0 :       SgTypeEllipse* testPointer = (SgTypeEllipse*)(SgTypeEllipse::pools.back());
   34909           0 :       unsigned long localIndex = SgTypeEllipse::pool_size - 1;
   34910           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   34911             :          {
   34912           0 :            localIndex--;
   34913             :          }
   34914           0 :       return (localIndex + SgTypeEllipse::pool_size * (SgTypeEllipse::pools.size()-1));
   34915             :    }
   34916             : 
   34917             : //############################################################################
   34918             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   34919             :  * memory pool and initializes the data member in class SgTypeEllipseStroageClass
   34920             :  * from its counterpart of SgTypeEllipse. The return value is just for checking, 
   34921             :  * that the whole StorageClassArray is initialized!
   34922             :  */
   34923             : unsigned long
   34924           2 : SgTypeEllipse::initializeStorageClassArray( SgTypeEllipseStorageClass *storageArray )
   34925             :    {
   34926           2 :      unsigned long storageCounter = 0;
   34927           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeEllipse::pools.begin();
   34928           2 :      SgTypeEllipse* pointer = NULL;
   34929           4 :      while ( block != SgTypeEllipse::pools.end() ) {
   34930           2 :           pointer = (SgTypeEllipse*) (*block);
   34931        4002 :           for ( unsigned i = 0; i < SgTypeEllipse::pool_size; ++i ) {
   34932        4000 :                if ( pointer->get_freepointer() != NULL ) {
   34933           2 :                  storageArray->pickOutIRNodeData (pointer) ;
   34934           2 :                  storageArray++;
   34935           2 :                  storageCounter++;
   34936             :                }
   34937        4000 :                pointer++;
   34938             :              }
   34939           2 :            block++;
   34940             :         }
   34941           2 :      return storageCounter;
   34942             :    }
   34943             : 
   34944             : /* #line 34945 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   34945             : 
   34946             : 
   34947             : 
   34948             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   34949             : 
   34950             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   34951             : 
   34952             : //############################################################################
   34953             : /* JH (02/02/2006) Constructor of the IR node SgTemplateType that takes its 
   34954             :  * corresponding StorageClass as parameter
   34955             :  */
   34956           0 : SgTemplateType :: SgTemplateType ( const SgTemplateTypeStorageClass& storageSource )   : SgType (storageSource)
   34957             :    {
   34958             : 
   34959             : 
   34960             : /* #line 34961 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   34961             : 
   34962           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   34963           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
   34964           0 :      p_template_parameter_position = storageSource.storageOf_template_parameter_position ;
   34965           0 :      p_template_parameter_depth = storageSource.storageOf_template_parameter_depth ;
   34966           0 :      p_class_type =  (SgType *)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_class_type) );
   34967           0 :      p_parent_class_type =  (SgType *)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parent_class_type) );
   34968           0 :      p_template_parameter =  (SgTemplateParameter *)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_template_parameter) );
   34969           0 :      p_tpl_args = storageSource.storageOf_tpl_args.rebuildDataStoredInEasyStorageClass() ;
   34970           0 :      SgTemplateArgumentPtrList::iterator i_tpl_args = p_tpl_args.begin() ; 
   34971           0 :      for ( ; i_tpl_args != p_tpl_args.end(); ++i_tpl_args ) 
   34972             :         {
   34973           0 :           (*i_tpl_args) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_tpl_args) ) );
   34974             :         }
   34975           0 :      p_part_spec_tpl_args = storageSource.storageOf_part_spec_tpl_args.rebuildDataStoredInEasyStorageClass() ;
   34976           0 :      SgTemplateArgumentPtrList::iterator i_part_spec_tpl_args = p_part_spec_tpl_args.begin() ; 
   34977           0 :      for ( ; i_part_spec_tpl_args != p_part_spec_tpl_args.end(); ++i_part_spec_tpl_args ) 
   34978             :         {
   34979           0 :           (*i_part_spec_tpl_args) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_part_spec_tpl_args) ) );
   34980             :         }
   34981           0 :      p_packed = storageSource.storageOf_packed ;
   34982             : 
   34983             : 
   34984             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   34985             : 
   34986             : 
   34987           0 :    }
   34988             : 
   34989             : //############################################################################
   34990             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   34991             :  * within the working AST. 
   34992             :  */
   34993           0 : SgTemplateType * SgTemplateType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   34994           0 :      SgTemplateType* returnPointer = NULL;
   34995           0 :      if ( globalIndex != 0 )
   34996             :         {
   34997             : 
   34998             : #if FILE_IO_EXTRA_CHECK
   34999           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateType ) ) <= globalIndex ) ;
   35000           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateType + 1 ) ) );
   35001             : #endif
   35002           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateType )  
   35003           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateType );
   35004           0 :           unsigned long positionInPool = localIndex % SgTemplateType::pool_size;
   35005           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateType::pool_size;
   35006             : 
   35007             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   35008             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   35009             : 
   35010           0 :           returnPointer = &( ( (SgTemplateType*)(SgTemplateType::pools[memoryBlock]) ) [positionInPool]) ;
   35011             : 
   35012           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   35013             :         }
   35014           0 :      return returnPointer ;
   35015             :    }
   35016             : 
   35017             : //############################################################################
   35018             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   35019             :   for the AST with the index astIndex
   35020             : */
   35021           0 : SgTemplateType * SgTemplateType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   35022           0 :      SgTemplateType* returnPointer = NULL;
   35023           0 :      if ( globalIndex != 0 )
   35024             :         {
   35025             : 
   35026             : #if FILE_IO_EXTRA_CHECK
   35027           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateType ) ) <= globalIndex ) ;
   35028           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateType + 1 ) ) );
   35029             : #endif
   35030           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateType )
   35031           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateType );
   35032           0 :           unsigned long positionInPool = localIndex % SgTemplateType::pool_size ;
   35033           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateType::pool_size ;
   35034             : 
   35035             : #if FILE_IO_EXTRA_CHECK
   35036             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   35037             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   35038             : #endif
   35039             : 
   35040           0 :           returnPointer = &( ( (SgTemplateType*)(SgTemplateType::pools[memoryBlock]) ) [positionInPool]) ;
   35041             : 
   35042             : #if FILE_IO_EXTRA_CHECK
   35043           0 :           assert ( returnPointer != NULL ) ;
   35044             : #endif
   35045             :         }
   35046           0 :      return returnPointer ;
   35047             :    }
   35048             : 
   35049             : //############################################################################
   35050             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   35051             :  * pool size! We set for every valid object in the memory pool the freepointer
   35052             :  * to the global index and increase the global index afterwards. For all the 
   35053             :  * invalid objects (means address ranges within the memory pool that were not
   35054             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   35055             :  * distinguish valid from invalid objects! 
   35056             :  */
   35057             : unsigned long
   35058           5 : SgTemplateType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   35059             :    {
   35060           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   35061           5 :      SgTemplateType* pointer = NULL;
   35062           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   35063           5 :      std::vector < unsigned char* > :: const_iterator block;
   35064           5 :      for ( block = SgTemplateType::pools.begin(); block != SgTemplateType::pools.end() ; ++block )
   35065             :         {
   35066           0 :           pointer = (SgTemplateType*)(*block);
   35067           0 :           for (unsigned i = 0; i < SgTemplateType::pool_size; ++i )
   35068             :              {
   35069             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   35070             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   35071             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   35072             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   35073             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   35074             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   35075             :             // properly; so this will have to be checked next.
   35076             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   35077             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   35078           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   35079             :                   {
   35080           0 :                     pointer[i].set_freepointer((SgTemplateType*)(globalIndex));
   35081           0 :                     globalIndex++;
   35082             :                   }
   35083             :                else
   35084             :                   {
   35085           0 :                     pointer[i].set_freepointer(NULL);
   35086             :                   }
   35087             :               }
   35088             :         }
   35089           5 :      return globalIndex;
   35090             :    }
   35091             : 
   35092             : //############################################################################
   35093             : // JH (01/14/2006)
   35094             : void
   35095           5 : SgTemplateType::resetValidFreepointers( )
   35096             :    {
   35097           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   35098           5 :      SgTemplateType* pointer = NULL;
   35099           5 :      std::vector < unsigned char* > :: const_iterator block;
   35100           5 :      SgTemplateType* pointerOfLinkedList = NULL;
   35101           5 :      for ( block = SgTemplateType::pools.begin(); block != SgTemplateType::pools.end() ; ++block )
   35102             :         {
   35103           0 :           pointer = (SgTemplateType*)(*block);
   35104           0 :           for (unsigned i = 0; i < SgTemplateType::pool_size; ++i )
   35105             :              {
   35106             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   35107             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   35108             :             // memory blocks!.
   35109           0 :                if ( pointer[i].get_freepointer() != NULL )
   35110             :                   {
   35111           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   35112             :                   }
   35113             :                else
   35114             :                   {
   35115           0 :                     if ( pointerOfLinkedList == NULL )
   35116             :                        {
   35117           0 :                          SgTemplateType::next_node = &(pointer[i]);
   35118             :                        }
   35119             :                     else
   35120             :                        {
   35121             :                       // printf ("In SgTemplateType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   35122           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   35123             :                        }
   35124             :                     pointerOfLinkedList = &(pointer[i]);
   35125             :                   }
   35126             :               }
   35127             :         }
   35128             : 
   35129           5 :      if ( pointerOfLinkedList != NULL )
   35130             :         {
   35131             :        // printf ("In SgTemplateType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   35132           0 :           pointerOfLinkedList->set_freepointer(NULL);
   35133             :        // DQ (6/6/2010): Temporary debugging...
   35134             :        //   ROSE_ASSERT(false);
   35135             :         }
   35136             : 
   35137           5 :      return ;
   35138             :    }
   35139             : 
   35140             : //############################################################################
   35141             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   35142             :  * within the memory pool and resets the freepointers, in order to achieve a 
   35143             :  * linked list, that has no jumps and starts at the beginning! This function 
   35144             :  * does not extend the memory pool, since we do not delete any memory blocks,
   35145             :  * but delete the valid objects.  
   35146             :  */
   35147             : void
   35148           0 : SgTemplateType::clearMemoryPool( )
   35149             :    {
   35150             :   // printf ("Inside of SgTemplateType::clearMemoryPool() \n");
   35151             : 
   35152           0 :      SgTemplateType* pointer = NULL, *tempPointer = NULL;
   35153           0 :      std::vector < unsigned char* > :: const_iterator block;
   35154           0 :      if ( SgTemplateType::pools.empty() == false )
   35155             :         {
   35156           0 :           block = SgTemplateType::pools.begin() ;
   35157           0 :           SgTemplateType::next_node = (SgTemplateType*) (*block);
   35158             : 
   35159           0 :           while ( block != SgTemplateType::pools.end() )
   35160             :              {
   35161           0 :                pointer = (SgTemplateType*) (*block);
   35162           0 :                if ( tempPointer != NULL )
   35163             :                   {
   35164           0 :                     tempPointer->set_freepointer(pointer);
   35165             :                   }
   35166           0 :                for (unsigned i = 0; i < SgTemplateType::pool_size - 1; ++i)
   35167             :                   {
   35168           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   35169             :                   }
   35170           0 :                 pointer[SgTemplateType::pool_size-1].set_freepointer(NULL);
   35171           0 :                 tempPointer = &(pointer[SgTemplateType::pool_size-1]);
   35172           0 :                 ++block;
   35173             :              }
   35174             :         }
   35175           0 :    }
   35176             : 
   35177           5 : void SgTemplateType::deleteMemoryPool() {
   35178           5 :   for (auto p: SgTemplateType::pools) {
   35179           0 :     ROSE_FREE(p);
   35180             :   }
   35181           5 :   SgTemplateType::next_node = nullptr;
   35182           5 :   SgTemplateType::pools.clear();
   35183           5 : }
   35184             : 
   35185             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   35186             : //                 reading multiple binary files to for a single AST.
   35187             : /////////// new version ////////////////////////////////
   35188             : //############################################################################
   35189             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   35190             : void
   35191           2 : SgTemplateType::extendMemoryPoolForFileIO( )
   35192             :   {
   35193           2 :     size_t blockIndex = SgTemplateType::pools.size();
   35194           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateType);
   35195             : 
   35196           2 :     while ( (blockIndex * SgTemplateType::pool_size) < newPoolSize)
   35197             :       {
   35198             : #if ROSE_ALLOC_TRACE
   35199             :         if (blockIndex > 0) {
   35200             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateType) = %" PRIuPTR " SgTemplateType::pool_size = %d \n",
   35201             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateType),SgTemplateType::pool_size);
   35202             :         }
   35203             : #endif
   35204             : 
   35205           0 :         SgTemplateType * pointer = (SgTemplateType*) ROSE_MALLOC ( SgTemplateType::pool_size * sizeof(SgTemplateType) );
   35206           0 :         assert( pointer != NULL );
   35207             : #if ROSE_ALLOC_MEMSET == 1
   35208             :         memset(pointer, 0x00, SgTemplateType::pool_size * sizeof(SgTemplateType));
   35209             : #elif ROSE_ALLOC_MEMSET == 2
   35210             :         memset(pointer, 0xCC, SgTemplateType::pool_size * sizeof(SgTemplateType));
   35211             : #endif
   35212           0 :         SgTemplateType::pools.push_back( (unsigned char*)(pointer) );
   35213           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateType::pool_size * sizeof(SgTemplateType), V_SgTemplateType ) );
   35214             : 
   35215           0 :         if ( SgTemplateType::next_node != NULL ) {
   35216           0 :           if ( blockIndex > 0 ) {
   35217           0 :             SgTemplateType * blkptr = (SgTemplateType*)(SgTemplateType::pools[blockIndex-1]);
   35218           0 :             blkptr[ SgTemplateType::pool_size - 1 ].set_freepointer(pointer);
   35219             :           }
   35220             :         } else {
   35221           0 :           SgTemplateType::next_node = pointer;
   35222             :         }
   35223             : 
   35224           0 :         for (unsigned i = 0; i < SgTemplateType::pool_size-1; ++i)
   35225             :            {
   35226           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   35227             :            }
   35228           0 :         pointer[ SgTemplateType::pool_size -1 ].set_freepointer(NULL);
   35229             : 
   35230           0 :         blockIndex++;
   35231             :       }
   35232           2 :   }
   35233             : 
   35234             : //############################################################################
   35235             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   35236             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   35237             :  * not compressed. However, that stuff is not yet implemented! 
   35238             :  */
   35239             : unsigned long
   35240           0 : SgTemplateType::getNumberOfLastValidPointer()
   35241             :    {
   35242           0 :       SgTemplateType* testPointer = (SgTemplateType*)(SgTemplateType::pools.back());
   35243           0 :       unsigned long localIndex = SgTemplateType::pool_size - 1;
   35244           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   35245             :          {
   35246           0 :            localIndex--;
   35247             :          }
   35248           0 :       return (localIndex + SgTemplateType::pool_size * (SgTemplateType::pools.size()-1));
   35249             :    }
   35250             : 
   35251             : //############################################################################
   35252             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   35253             :  * memory pool and initializes the data member in class SgTemplateTypeStroageClass
   35254             :  * from its counterpart of SgTemplateType. The return value is just for checking, 
   35255             :  * that the whole StorageClassArray is initialized!
   35256             :  */
   35257             : unsigned long
   35258           0 : SgTemplateType::initializeStorageClassArray( SgTemplateTypeStorageClass *storageArray )
   35259             :    {
   35260           0 :      unsigned long storageCounter = 0;
   35261           0 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateType::pools.begin();
   35262           0 :      SgTemplateType* pointer = NULL;
   35263           0 :      while ( block != SgTemplateType::pools.end() ) {
   35264           0 :           pointer = (SgTemplateType*) (*block);
   35265           0 :           for ( unsigned i = 0; i < SgTemplateType::pool_size; ++i ) {
   35266           0 :                if ( pointer->get_freepointer() != NULL ) {
   35267           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   35268           0 :                  storageArray++;
   35269           0 :                  storageCounter++;
   35270             :                }
   35271           0 :                pointer++;
   35272             :              }
   35273           0 :            block++;
   35274             :         }
   35275           0 :      return storageCounter;
   35276             :    }
   35277             : 
   35278             : /* #line 35279 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   35279             : 
   35280             : 
   35281             : 
   35282             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   35283             : 
   35284             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   35285             : 
   35286             : //############################################################################
   35287             : /* JH (02/02/2006) Constructor of the IR node SgQualifiedNameType that takes its 
   35288             :  * corresponding StorageClass as parameter
   35289             :  */
   35290           0 : SgQualifiedNameType :: SgQualifiedNameType ( const SgQualifiedNameTypeStorageClass& storageSource )   : SgType (storageSource)
   35291             :    {
   35292             : 
   35293             : 
   35294             : /* #line 35295 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   35295             : 
   35296           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   35297           0 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   35298           0 :      p_qualifiedNameList = storageSource.storageOf_qualifiedNameList.rebuildDataStoredInEasyStorageClass() ;
   35299           0 :      SgQualifiedNamePtrList::iterator i_qualifiedNameList = p_qualifiedNameList.begin() ; 
   35300           0 :      for ( ; i_qualifiedNameList != p_qualifiedNameList.end(); ++i_qualifiedNameList ) 
   35301             :         {
   35302           0 :           (*i_qualifiedNameList) = (SgQualifiedNamePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_qualifiedNameList) ) );
   35303             :         }
   35304             : 
   35305             : 
   35306             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   35307             : 
   35308             : 
   35309           0 :    }
   35310             : 
   35311             : //############################################################################
   35312             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   35313             :  * within the working AST. 
   35314             :  */
   35315           0 : SgQualifiedNameType * SgQualifiedNameType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   35316           0 :      SgQualifiedNameType* returnPointer = NULL;
   35317           0 :      if ( globalIndex != 0 )
   35318             :         {
   35319             : 
   35320             : #if FILE_IO_EXTRA_CHECK
   35321           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgQualifiedNameType ) ) <= globalIndex ) ;
   35322           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgQualifiedNameType + 1 ) ) );
   35323             : #endif
   35324           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgQualifiedNameType )  
   35325           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgQualifiedNameType );
   35326           0 :           unsigned long positionInPool = localIndex % SgQualifiedNameType::pool_size;
   35327           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgQualifiedNameType::pool_size;
   35328             : 
   35329             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   35330             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   35331             : 
   35332           0 :           returnPointer = &( ( (SgQualifiedNameType*)(SgQualifiedNameType::pools[memoryBlock]) ) [positionInPool]) ;
   35333             : 
   35334           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   35335             :         }
   35336           0 :      return returnPointer ;
   35337             :    }
   35338             : 
   35339             : //############################################################################
   35340             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   35341             :   for the AST with the index astIndex
   35342             : */
   35343           0 : SgQualifiedNameType * SgQualifiedNameType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   35344           0 :      SgQualifiedNameType* returnPointer = NULL;
   35345           0 :      if ( globalIndex != 0 )
   35346             :         {
   35347             : 
   35348             : #if FILE_IO_EXTRA_CHECK
   35349           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgQualifiedNameType ) ) <= globalIndex ) ;
   35350           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgQualifiedNameType + 1 ) ) );
   35351             : #endif
   35352           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgQualifiedNameType )
   35353           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgQualifiedNameType );
   35354           0 :           unsigned long positionInPool = localIndex % SgQualifiedNameType::pool_size ;
   35355           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgQualifiedNameType::pool_size ;
   35356             : 
   35357             : #if FILE_IO_EXTRA_CHECK
   35358             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   35359             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   35360             : #endif
   35361             : 
   35362           0 :           returnPointer = &( ( (SgQualifiedNameType*)(SgQualifiedNameType::pools[memoryBlock]) ) [positionInPool]) ;
   35363             : 
   35364             : #if FILE_IO_EXTRA_CHECK
   35365           0 :           assert ( returnPointer != NULL ) ;
   35366             : #endif
   35367             :         }
   35368           0 :      return returnPointer ;
   35369             :    }
   35370             : 
   35371             : //############################################################################
   35372             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   35373             :  * pool size! We set for every valid object in the memory pool the freepointer
   35374             :  * to the global index and increase the global index afterwards. For all the 
   35375             :  * invalid objects (means address ranges within the memory pool that were not
   35376             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   35377             :  * distinguish valid from invalid objects! 
   35378             :  */
   35379             : unsigned long
   35380           5 : SgQualifiedNameType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   35381             :    {
   35382           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   35383           5 :      SgQualifiedNameType* pointer = NULL;
   35384           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   35385           5 :      std::vector < unsigned char* > :: const_iterator block;
   35386           5 :      for ( block = SgQualifiedNameType::pools.begin(); block != SgQualifiedNameType::pools.end() ; ++block )
   35387             :         {
   35388           0 :           pointer = (SgQualifiedNameType*)(*block);
   35389           0 :           for (unsigned i = 0; i < SgQualifiedNameType::pool_size; ++i )
   35390             :              {
   35391             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   35392             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   35393             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   35394             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   35395             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   35396             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   35397             :             // properly; so this will have to be checked next.
   35398             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   35399             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   35400           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   35401             :                   {
   35402           0 :                     pointer[i].set_freepointer((SgQualifiedNameType*)(globalIndex));
   35403           0 :                     globalIndex++;
   35404             :                   }
   35405             :                else
   35406             :                   {
   35407           0 :                     pointer[i].set_freepointer(NULL);
   35408             :                   }
   35409             :               }
   35410             :         }
   35411           5 :      return globalIndex;
   35412             :    }
   35413             : 
   35414             : //############################################################################
   35415             : // JH (01/14/2006)
   35416             : void
   35417           5 : SgQualifiedNameType::resetValidFreepointers( )
   35418             :    {
   35419           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   35420           5 :      SgQualifiedNameType* pointer = NULL;
   35421           5 :      std::vector < unsigned char* > :: const_iterator block;
   35422           5 :      SgQualifiedNameType* pointerOfLinkedList = NULL;
   35423           5 :      for ( block = SgQualifiedNameType::pools.begin(); block != SgQualifiedNameType::pools.end() ; ++block )
   35424             :         {
   35425           0 :           pointer = (SgQualifiedNameType*)(*block);
   35426           0 :           for (unsigned i = 0; i < SgQualifiedNameType::pool_size; ++i )
   35427             :              {
   35428             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   35429             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   35430             :             // memory blocks!.
   35431           0 :                if ( pointer[i].get_freepointer() != NULL )
   35432             :                   {
   35433           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   35434             :                   }
   35435             :                else
   35436             :                   {
   35437           0 :                     if ( pointerOfLinkedList == NULL )
   35438             :                        {
   35439           0 :                          SgQualifiedNameType::next_node = &(pointer[i]);
   35440             :                        }
   35441             :                     else
   35442             :                        {
   35443             :                       // printf ("In SgQualifiedNameType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   35444           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   35445             :                        }
   35446             :                     pointerOfLinkedList = &(pointer[i]);
   35447             :                   }
   35448             :               }
   35449             :         }
   35450             : 
   35451           5 :      if ( pointerOfLinkedList != NULL )
   35452             :         {
   35453             :        // printf ("In SgQualifiedNameType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   35454           0 :           pointerOfLinkedList->set_freepointer(NULL);
   35455             :        // DQ (6/6/2010): Temporary debugging...
   35456             :        //   ROSE_ASSERT(false);
   35457             :         }
   35458             : 
   35459           5 :      return ;
   35460             :    }
   35461             : 
   35462             : //############################################################################
   35463             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   35464             :  * within the memory pool and resets the freepointers, in order to achieve a 
   35465             :  * linked list, that has no jumps and starts at the beginning! This function 
   35466             :  * does not extend the memory pool, since we do not delete any memory blocks,
   35467             :  * but delete the valid objects.  
   35468             :  */
   35469             : void
   35470           0 : SgQualifiedNameType::clearMemoryPool( )
   35471             :    {
   35472             :   // printf ("Inside of SgQualifiedNameType::clearMemoryPool() \n");
   35473             : 
   35474           0 :      SgQualifiedNameType* pointer = NULL, *tempPointer = NULL;
   35475           0 :      std::vector < unsigned char* > :: const_iterator block;
   35476           0 :      if ( SgQualifiedNameType::pools.empty() == false )
   35477             :         {
   35478           0 :           block = SgQualifiedNameType::pools.begin() ;
   35479           0 :           SgQualifiedNameType::next_node = (SgQualifiedNameType*) (*block);
   35480             : 
   35481           0 :           while ( block != SgQualifiedNameType::pools.end() )
   35482             :              {
   35483           0 :                pointer = (SgQualifiedNameType*) (*block);
   35484           0 :                if ( tempPointer != NULL )
   35485             :                   {
   35486           0 :                     tempPointer->set_freepointer(pointer);
   35487             :                   }
   35488           0 :                for (unsigned i = 0; i < SgQualifiedNameType::pool_size - 1; ++i)
   35489             :                   {
   35490           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   35491             :                   }
   35492           0 :                 pointer[SgQualifiedNameType::pool_size-1].set_freepointer(NULL);
   35493           0 :                 tempPointer = &(pointer[SgQualifiedNameType::pool_size-1]);
   35494           0 :                 ++block;
   35495             :              }
   35496             :         }
   35497           0 :    }
   35498             : 
   35499           5 : void SgQualifiedNameType::deleteMemoryPool() {
   35500           5 :   for (auto p: SgQualifiedNameType::pools) {
   35501           0 :     ROSE_FREE(p);
   35502             :   }
   35503           5 :   SgQualifiedNameType::next_node = nullptr;
   35504           5 :   SgQualifiedNameType::pools.clear();
   35505           5 : }
   35506             : 
   35507             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   35508             : //                 reading multiple binary files to for a single AST.
   35509             : /////////// new version ////////////////////////////////
   35510             : //############################################################################
   35511             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   35512             : void
   35513           2 : SgQualifiedNameType::extendMemoryPoolForFileIO( )
   35514             :   {
   35515           2 :     size_t blockIndex = SgQualifiedNameType::pools.size();
   35516           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgQualifiedNameType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgQualifiedNameType);
   35517             : 
   35518           2 :     while ( (blockIndex * SgQualifiedNameType::pool_size) < newPoolSize)
   35519             :       {
   35520             : #if ROSE_ALLOC_TRACE
   35521             :         if (blockIndex > 0) {
   35522             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgQualifiedNameType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgQualifiedNameType) = %" PRIuPTR " SgQualifiedNameType::pool_size = %d \n",
   35523             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgQualifiedNameType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgQualifiedNameType),SgQualifiedNameType::pool_size);
   35524             :         }
   35525             : #endif
   35526             : 
   35527           0 :         SgQualifiedNameType * pointer = (SgQualifiedNameType*) ROSE_MALLOC ( SgQualifiedNameType::pool_size * sizeof(SgQualifiedNameType) );
   35528           0 :         assert( pointer != NULL );
   35529             : #if ROSE_ALLOC_MEMSET == 1
   35530             :         memset(pointer, 0x00, SgQualifiedNameType::pool_size * sizeof(SgQualifiedNameType));
   35531             : #elif ROSE_ALLOC_MEMSET == 2
   35532             :         memset(pointer, 0xCC, SgQualifiedNameType::pool_size * sizeof(SgQualifiedNameType));
   35533             : #endif
   35534           0 :         SgQualifiedNameType::pools.push_back( (unsigned char*)(pointer) );
   35535           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgQualifiedNameType::pool_size * sizeof(SgQualifiedNameType), V_SgQualifiedNameType ) );
   35536             : 
   35537           0 :         if ( SgQualifiedNameType::next_node != NULL ) {
   35538           0 :           if ( blockIndex > 0 ) {
   35539           0 :             SgQualifiedNameType * blkptr = (SgQualifiedNameType*)(SgQualifiedNameType::pools[blockIndex-1]);
   35540           0 :             blkptr[ SgQualifiedNameType::pool_size - 1 ].set_freepointer(pointer);
   35541             :           }
   35542             :         } else {
   35543           0 :           SgQualifiedNameType::next_node = pointer;
   35544             :         }
   35545             : 
   35546           0 :         for (unsigned i = 0; i < SgQualifiedNameType::pool_size-1; ++i)
   35547             :            {
   35548           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   35549             :            }
   35550           0 :         pointer[ SgQualifiedNameType::pool_size -1 ].set_freepointer(NULL);
   35551             : 
   35552           0 :         blockIndex++;
   35553             :       }
   35554           2 :   }
   35555             : 
   35556             : //############################################################################
   35557             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   35558             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   35559             :  * not compressed. However, that stuff is not yet implemented! 
   35560             :  */
   35561             : unsigned long
   35562           0 : SgQualifiedNameType::getNumberOfLastValidPointer()
   35563             :    {
   35564           0 :       SgQualifiedNameType* testPointer = (SgQualifiedNameType*)(SgQualifiedNameType::pools.back());
   35565           0 :       unsigned long localIndex = SgQualifiedNameType::pool_size - 1;
   35566           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   35567             :          {
   35568           0 :            localIndex--;
   35569             :          }
   35570           0 :       return (localIndex + SgQualifiedNameType::pool_size * (SgQualifiedNameType::pools.size()-1));
   35571             :    }
   35572             : 
   35573             : //############################################################################
   35574             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   35575             :  * memory pool and initializes the data member in class SgQualifiedNameTypeStroageClass
   35576             :  * from its counterpart of SgQualifiedNameType. The return value is just for checking, 
   35577             :  * that the whole StorageClassArray is initialized!
   35578             :  */
   35579             : unsigned long
   35580           0 : SgQualifiedNameType::initializeStorageClassArray( SgQualifiedNameTypeStorageClass *storageArray )
   35581             :    {
   35582           0 :      unsigned long storageCounter = 0;
   35583           0 :      std::vector < unsigned char* > :: const_iterator block = SgQualifiedNameType::pools.begin();
   35584           0 :      SgQualifiedNameType* pointer = NULL;
   35585           0 :      while ( block != SgQualifiedNameType::pools.end() ) {
   35586           0 :           pointer = (SgQualifiedNameType*) (*block);
   35587           0 :           for ( unsigned i = 0; i < SgQualifiedNameType::pool_size; ++i ) {
   35588           0 :                if ( pointer->get_freepointer() != NULL ) {
   35589           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   35590           0 :                  storageArray++;
   35591           0 :                  storageCounter++;
   35592             :                }
   35593           0 :                pointer++;
   35594             :              }
   35595           0 :            block++;
   35596             :         }
   35597           0 :      return storageCounter;
   35598             :    }
   35599             : 
   35600             : /* #line 35601 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   35601             : 
   35602             : 
   35603             : 
   35604             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   35605             : 
   35606             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   35607             : 
   35608             : //############################################################################
   35609             : /* JH (02/02/2006) Constructor of the IR node SgTypeComplex that takes its 
   35610             :  * corresponding StorageClass as parameter
   35611             :  */
   35612           7 : SgTypeComplex :: SgTypeComplex ( const SgTypeComplexStorageClass& storageSource )   : SgType (storageSource)
   35613             :    {
   35614             : 
   35615             : 
   35616             : /* #line 35617 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   35617             : 
   35618           7 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   35619           7 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   35620             : 
   35621             : 
   35622             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   35623             : 
   35624             : 
   35625           7 :    }
   35626             : 
   35627             : //############################################################################
   35628             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   35629             :  * within the working AST. 
   35630             :  */
   35631         304 : SgTypeComplex * SgTypeComplex::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   35632         304 :      SgTypeComplex* returnPointer = NULL;
   35633         304 :      if ( globalIndex != 0 )
   35634             :         {
   35635             : 
   35636             : #if FILE_IO_EXTRA_CHECK
   35637         304 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeComplex ) ) <= globalIndex ) ;
   35638         304 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeComplex + 1 ) ) );
   35639             : #endif
   35640         304 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeComplex )  
   35641         304 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeComplex );
   35642         304 :           unsigned long positionInPool = localIndex % SgTypeComplex::pool_size;
   35643         304 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeComplex::pool_size;
   35644             : 
   35645             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   35646             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   35647             : 
   35648         304 :           returnPointer = &( ( (SgTypeComplex*)(SgTypeComplex::pools[memoryBlock]) ) [positionInPool]) ;
   35649             : 
   35650         304 :           ROSE_ASSERT( returnPointer != NULL ) ;
   35651             :         }
   35652         304 :      return returnPointer ;
   35653             :    }
   35654             : 
   35655             : //############################################################################
   35656             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   35657             :   for the AST with the index astIndex
   35658             : */
   35659           0 : SgTypeComplex * SgTypeComplex::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   35660           0 :      SgTypeComplex* returnPointer = NULL;
   35661           0 :      if ( globalIndex != 0 )
   35662             :         {
   35663             : 
   35664             : #if FILE_IO_EXTRA_CHECK
   35665           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeComplex ) ) <= globalIndex ) ;
   35666           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeComplex + 1 ) ) );
   35667             : #endif
   35668           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeComplex )
   35669           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeComplex );
   35670           0 :           unsigned long positionInPool = localIndex % SgTypeComplex::pool_size ;
   35671           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeComplex::pool_size ;
   35672             : 
   35673             : #if FILE_IO_EXTRA_CHECK
   35674             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   35675             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   35676             : #endif
   35677             : 
   35678           0 :           returnPointer = &( ( (SgTypeComplex*)(SgTypeComplex::pools[memoryBlock]) ) [positionInPool]) ;
   35679             : 
   35680             : #if FILE_IO_EXTRA_CHECK
   35681           0 :           assert ( returnPointer != NULL ) ;
   35682             : #endif
   35683             :         }
   35684           0 :      return returnPointer ;
   35685             :    }
   35686             : 
   35687             : //############################################################################
   35688             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   35689             :  * pool size! We set for every valid object in the memory pool the freepointer
   35690             :  * to the global index and increase the global index afterwards. For all the 
   35691             :  * invalid objects (means address ranges within the memory pool that were not
   35692             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   35693             :  * distinguish valid from invalid objects! 
   35694             :  */
   35695             : unsigned long
   35696           5 : SgTypeComplex::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   35697             :    {
   35698           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   35699           5 :      SgTypeComplex* pointer = NULL;
   35700           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   35701           5 :      std::vector < unsigned char* > :: const_iterator block;
   35702           7 :      for ( block = SgTypeComplex::pools.begin(); block != SgTypeComplex::pools.end() ; ++block )
   35703             :         {
   35704           2 :           pointer = (SgTypeComplex*)(*block);
   35705        4002 :           for (unsigned i = 0; i < SgTypeComplex::pool_size; ++i )
   35706             :              {
   35707             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   35708             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   35709             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   35710             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   35711             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   35712             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   35713             :             // properly; so this will have to be checked next.
   35714             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   35715             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   35716        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   35717             :                   {
   35718           7 :                     pointer[i].set_freepointer((SgTypeComplex*)(globalIndex));
   35719           7 :                     globalIndex++;
   35720             :                   }
   35721             :                else
   35722             :                   {
   35723        3993 :                     pointer[i].set_freepointer(NULL);
   35724             :                   }
   35725             :               }
   35726             :         }
   35727           5 :      return globalIndex;
   35728             :    }
   35729             : 
   35730             : //############################################################################
   35731             : // JH (01/14/2006)
   35732             : void
   35733           5 : SgTypeComplex::resetValidFreepointers( )
   35734             :    {
   35735           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   35736           5 :      SgTypeComplex* pointer = NULL;
   35737           5 :      std::vector < unsigned char* > :: const_iterator block;
   35738           5 :      SgTypeComplex* pointerOfLinkedList = NULL;
   35739           7 :      for ( block = SgTypeComplex::pools.begin(); block != SgTypeComplex::pools.end() ; ++block )
   35740             :         {
   35741           2 :           pointer = (SgTypeComplex*)(*block);
   35742        4002 :           for (unsigned i = 0; i < SgTypeComplex::pool_size; ++i )
   35743             :              {
   35744             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   35745             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   35746             :             // memory blocks!.
   35747        4000 :                if ( pointer[i].get_freepointer() != NULL )
   35748             :                   {
   35749           7 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   35750             :                   }
   35751             :                else
   35752             :                   {
   35753        3993 :                     if ( pointerOfLinkedList == NULL )
   35754             :                        {
   35755           2 :                          SgTypeComplex::next_node = &(pointer[i]);
   35756             :                        }
   35757             :                     else
   35758             :                        {
   35759             :                       // printf ("In SgTypeComplex::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   35760        3991 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   35761             :                        }
   35762             :                     pointerOfLinkedList = &(pointer[i]);
   35763             :                   }
   35764             :               }
   35765             :         }
   35766             : 
   35767           5 :      if ( pointerOfLinkedList != NULL )
   35768             :         {
   35769             :        // printf ("In SgTypeComplex::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   35770           2 :           pointerOfLinkedList->set_freepointer(NULL);
   35771             :        // DQ (6/6/2010): Temporary debugging...
   35772             :        //   ROSE_ASSERT(false);
   35773             :         }
   35774             : 
   35775           5 :      return ;
   35776             :    }
   35777             : 
   35778             : //############################################################################
   35779             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   35780             :  * within the memory pool and resets the freepointers, in order to achieve a 
   35781             :  * linked list, that has no jumps and starts at the beginning! This function 
   35782             :  * does not extend the memory pool, since we do not delete any memory blocks,
   35783             :  * but delete the valid objects.  
   35784             :  */
   35785             : void
   35786           0 : SgTypeComplex::clearMemoryPool( )
   35787             :    {
   35788             :   // printf ("Inside of SgTypeComplex::clearMemoryPool() \n");
   35789             : 
   35790           0 :      SgTypeComplex* pointer = NULL, *tempPointer = NULL;
   35791           0 :      std::vector < unsigned char* > :: const_iterator block;
   35792           0 :      if ( SgTypeComplex::pools.empty() == false )
   35793             :         {
   35794           0 :           block = SgTypeComplex::pools.begin() ;
   35795           0 :           SgTypeComplex::next_node = (SgTypeComplex*) (*block);
   35796             : 
   35797           0 :           while ( block != SgTypeComplex::pools.end() )
   35798             :              {
   35799           0 :                pointer = (SgTypeComplex*) (*block);
   35800           0 :                if ( tempPointer != NULL )
   35801             :                   {
   35802           0 :                     tempPointer->set_freepointer(pointer);
   35803             :                   }
   35804           0 :                for (unsigned i = 0; i < SgTypeComplex::pool_size - 1; ++i)
   35805             :                   {
   35806           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   35807             :                   }
   35808           0 :                 pointer[SgTypeComplex::pool_size-1].set_freepointer(NULL);
   35809           0 :                 tempPointer = &(pointer[SgTypeComplex::pool_size-1]);
   35810           0 :                 ++block;
   35811             :              }
   35812             :         }
   35813           0 :    }
   35814             : 
   35815           5 : void SgTypeComplex::deleteMemoryPool() {
   35816           9 :   for (auto p: SgTypeComplex::pools) {
   35817           4 :     ROSE_FREE(p);
   35818             :   }
   35819           5 :   SgTypeComplex::next_node = nullptr;
   35820           5 :   SgTypeComplex::pools.clear();
   35821           5 : }
   35822             : 
   35823             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   35824             : //                 reading multiple binary files to for a single AST.
   35825             : /////////// new version ////////////////////////////////
   35826             : //############################################################################
   35827             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   35828             : void
   35829           2 : SgTypeComplex::extendMemoryPoolForFileIO( )
   35830             :   {
   35831           2 :     size_t blockIndex = SgTypeComplex::pools.size();
   35832           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeComplex) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeComplex);
   35833             : 
   35834           4 :     while ( (blockIndex * SgTypeComplex::pool_size) < newPoolSize)
   35835             :       {
   35836             : #if ROSE_ALLOC_TRACE
   35837             :         if (blockIndex > 0) {
   35838             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeComplex) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeComplex) = %" PRIuPTR " SgTypeComplex::pool_size = %d \n",
   35839             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeComplex),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeComplex),SgTypeComplex::pool_size);
   35840             :         }
   35841             : #endif
   35842             : 
   35843           2 :         SgTypeComplex * pointer = (SgTypeComplex*) ROSE_MALLOC ( SgTypeComplex::pool_size * sizeof(SgTypeComplex) );
   35844           2 :         assert( pointer != NULL );
   35845             : #if ROSE_ALLOC_MEMSET == 1
   35846             :         memset(pointer, 0x00, SgTypeComplex::pool_size * sizeof(SgTypeComplex));
   35847             : #elif ROSE_ALLOC_MEMSET == 2
   35848             :         memset(pointer, 0xCC, SgTypeComplex::pool_size * sizeof(SgTypeComplex));
   35849             : #endif
   35850           2 :         SgTypeComplex::pools.push_back( (unsigned char*)(pointer) );
   35851           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeComplex::pool_size * sizeof(SgTypeComplex), V_SgTypeComplex ) );
   35852             : 
   35853           2 :         if ( SgTypeComplex::next_node != NULL ) {
   35854           0 :           if ( blockIndex > 0 ) {
   35855           0 :             SgTypeComplex * blkptr = (SgTypeComplex*)(SgTypeComplex::pools[blockIndex-1]);
   35856           0 :             blkptr[ SgTypeComplex::pool_size - 1 ].set_freepointer(pointer);
   35857             :           }
   35858             :         } else {
   35859           2 :           SgTypeComplex::next_node = pointer;
   35860             :         }
   35861             : 
   35862        4000 :         for (unsigned i = 0; i < SgTypeComplex::pool_size-1; ++i)
   35863             :            {
   35864        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   35865             :            }
   35866           2 :         pointer[ SgTypeComplex::pool_size -1 ].set_freepointer(NULL);
   35867             : 
   35868           2 :         blockIndex++;
   35869             :       }
   35870           2 :   }
   35871             : 
   35872             : //############################################################################
   35873             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   35874             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   35875             :  * not compressed. However, that stuff is not yet implemented! 
   35876             :  */
   35877             : unsigned long
   35878           0 : SgTypeComplex::getNumberOfLastValidPointer()
   35879             :    {
   35880           0 :       SgTypeComplex* testPointer = (SgTypeComplex*)(SgTypeComplex::pools.back());
   35881           0 :       unsigned long localIndex = SgTypeComplex::pool_size - 1;
   35882           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   35883             :          {
   35884           0 :            localIndex--;
   35885             :          }
   35886           0 :       return (localIndex + SgTypeComplex::pool_size * (SgTypeComplex::pools.size()-1));
   35887             :    }
   35888             : 
   35889             : //############################################################################
   35890             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   35891             :  * memory pool and initializes the data member in class SgTypeComplexStroageClass
   35892             :  * from its counterpart of SgTypeComplex. The return value is just for checking, 
   35893             :  * that the whole StorageClassArray is initialized!
   35894             :  */
   35895             : unsigned long
   35896           2 : SgTypeComplex::initializeStorageClassArray( SgTypeComplexStorageClass *storageArray )
   35897             :    {
   35898           2 :      unsigned long storageCounter = 0;
   35899           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeComplex::pools.begin();
   35900           2 :      SgTypeComplex* pointer = NULL;
   35901           4 :      while ( block != SgTypeComplex::pools.end() ) {
   35902           2 :           pointer = (SgTypeComplex*) (*block);
   35903        4002 :           for ( unsigned i = 0; i < SgTypeComplex::pool_size; ++i ) {
   35904        4000 :                if ( pointer->get_freepointer() != NULL ) {
   35905           7 :                  storageArray->pickOutIRNodeData (pointer) ;
   35906           7 :                  storageArray++;
   35907           7 :                  storageCounter++;
   35908             :                }
   35909        4000 :                pointer++;
   35910             :              }
   35911           2 :            block++;
   35912             :         }
   35913           2 :      return storageCounter;
   35914             :    }
   35915             : 
   35916             : /* #line 35917 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   35917             : 
   35918             : 
   35919             : 
   35920             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   35921             : 
   35922             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   35923             : 
   35924             : //############################################################################
   35925             : /* JH (02/02/2006) Constructor of the IR node SgTypeImaginary that takes its 
   35926             :  * corresponding StorageClass as parameter
   35927             :  */
   35928           0 : SgTypeImaginary :: SgTypeImaginary ( const SgTypeImaginaryStorageClass& storageSource )   : SgType (storageSource)
   35929             :    {
   35930             : 
   35931             : 
   35932             : /* #line 35933 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   35933             : 
   35934           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   35935           0 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   35936             : 
   35937             : 
   35938             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   35939             : 
   35940             : 
   35941           0 :    }
   35942             : 
   35943             : //############################################################################
   35944             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   35945             :  * within the working AST. 
   35946             :  */
   35947           0 : SgTypeImaginary * SgTypeImaginary::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   35948           0 :      SgTypeImaginary* returnPointer = NULL;
   35949           0 :      if ( globalIndex != 0 )
   35950             :         {
   35951             : 
   35952             : #if FILE_IO_EXTRA_CHECK
   35953           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeImaginary ) ) <= globalIndex ) ;
   35954           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeImaginary + 1 ) ) );
   35955             : #endif
   35956           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeImaginary )  
   35957           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeImaginary );
   35958           0 :           unsigned long positionInPool = localIndex % SgTypeImaginary::pool_size;
   35959           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeImaginary::pool_size;
   35960             : 
   35961             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   35962             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   35963             : 
   35964           0 :           returnPointer = &( ( (SgTypeImaginary*)(SgTypeImaginary::pools[memoryBlock]) ) [positionInPool]) ;
   35965             : 
   35966           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   35967             :         }
   35968           0 :      return returnPointer ;
   35969             :    }
   35970             : 
   35971             : //############################################################################
   35972             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   35973             :   for the AST with the index astIndex
   35974             : */
   35975           0 : SgTypeImaginary * SgTypeImaginary::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   35976           0 :      SgTypeImaginary* returnPointer = NULL;
   35977           0 :      if ( globalIndex != 0 )
   35978             :         {
   35979             : 
   35980             : #if FILE_IO_EXTRA_CHECK
   35981           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeImaginary ) ) <= globalIndex ) ;
   35982           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeImaginary + 1 ) ) );
   35983             : #endif
   35984           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeImaginary )
   35985           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeImaginary );
   35986           0 :           unsigned long positionInPool = localIndex % SgTypeImaginary::pool_size ;
   35987           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeImaginary::pool_size ;
   35988             : 
   35989             : #if FILE_IO_EXTRA_CHECK
   35990             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   35991             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   35992             : #endif
   35993             : 
   35994           0 :           returnPointer = &( ( (SgTypeImaginary*)(SgTypeImaginary::pools[memoryBlock]) ) [positionInPool]) ;
   35995             : 
   35996             : #if FILE_IO_EXTRA_CHECK
   35997           0 :           assert ( returnPointer != NULL ) ;
   35998             : #endif
   35999             :         }
   36000           0 :      return returnPointer ;
   36001             :    }
   36002             : 
   36003             : //############################################################################
   36004             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   36005             :  * pool size! We set for every valid object in the memory pool the freepointer
   36006             :  * to the global index and increase the global index afterwards. For all the 
   36007             :  * invalid objects (means address ranges within the memory pool that were not
   36008             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   36009             :  * distinguish valid from invalid objects! 
   36010             :  */
   36011             : unsigned long
   36012           5 : SgTypeImaginary::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   36013             :    {
   36014           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   36015           5 :      SgTypeImaginary* pointer = NULL;
   36016           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   36017           5 :      std::vector < unsigned char* > :: const_iterator block;
   36018           5 :      for ( block = SgTypeImaginary::pools.begin(); block != SgTypeImaginary::pools.end() ; ++block )
   36019             :         {
   36020           0 :           pointer = (SgTypeImaginary*)(*block);
   36021           0 :           for (unsigned i = 0; i < SgTypeImaginary::pool_size; ++i )
   36022             :              {
   36023             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   36024             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   36025             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   36026             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   36027             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   36028             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   36029             :             // properly; so this will have to be checked next.
   36030             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   36031             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   36032           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   36033             :                   {
   36034           0 :                     pointer[i].set_freepointer((SgTypeImaginary*)(globalIndex));
   36035           0 :                     globalIndex++;
   36036             :                   }
   36037             :                else
   36038             :                   {
   36039           0 :                     pointer[i].set_freepointer(NULL);
   36040             :                   }
   36041             :               }
   36042             :         }
   36043           5 :      return globalIndex;
   36044             :    }
   36045             : 
   36046             : //############################################################################
   36047             : // JH (01/14/2006)
   36048             : void
   36049           5 : SgTypeImaginary::resetValidFreepointers( )
   36050             :    {
   36051           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   36052           5 :      SgTypeImaginary* pointer = NULL;
   36053           5 :      std::vector < unsigned char* > :: const_iterator block;
   36054           5 :      SgTypeImaginary* pointerOfLinkedList = NULL;
   36055           5 :      for ( block = SgTypeImaginary::pools.begin(); block != SgTypeImaginary::pools.end() ; ++block )
   36056             :         {
   36057           0 :           pointer = (SgTypeImaginary*)(*block);
   36058           0 :           for (unsigned i = 0; i < SgTypeImaginary::pool_size; ++i )
   36059             :              {
   36060             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   36061             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   36062             :             // memory blocks!.
   36063           0 :                if ( pointer[i].get_freepointer() != NULL )
   36064             :                   {
   36065           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   36066             :                   }
   36067             :                else
   36068             :                   {
   36069           0 :                     if ( pointerOfLinkedList == NULL )
   36070             :                        {
   36071           0 :                          SgTypeImaginary::next_node = &(pointer[i]);
   36072             :                        }
   36073             :                     else
   36074             :                        {
   36075             :                       // printf ("In SgTypeImaginary::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   36076           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   36077             :                        }
   36078             :                     pointerOfLinkedList = &(pointer[i]);
   36079             :                   }
   36080             :               }
   36081             :         }
   36082             : 
   36083           5 :      if ( pointerOfLinkedList != NULL )
   36084             :         {
   36085             :        // printf ("In SgTypeImaginary::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   36086           0 :           pointerOfLinkedList->set_freepointer(NULL);
   36087             :        // DQ (6/6/2010): Temporary debugging...
   36088             :        //   ROSE_ASSERT(false);
   36089             :         }
   36090             : 
   36091           5 :      return ;
   36092             :    }
   36093             : 
   36094             : //############################################################################
   36095             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   36096             :  * within the memory pool and resets the freepointers, in order to achieve a 
   36097             :  * linked list, that has no jumps and starts at the beginning! This function 
   36098             :  * does not extend the memory pool, since we do not delete any memory blocks,
   36099             :  * but delete the valid objects.  
   36100             :  */
   36101             : void
   36102           0 : SgTypeImaginary::clearMemoryPool( )
   36103             :    {
   36104             :   // printf ("Inside of SgTypeImaginary::clearMemoryPool() \n");
   36105             : 
   36106           0 :      SgTypeImaginary* pointer = NULL, *tempPointer = NULL;
   36107           0 :      std::vector < unsigned char* > :: const_iterator block;
   36108           0 :      if ( SgTypeImaginary::pools.empty() == false )
   36109             :         {
   36110           0 :           block = SgTypeImaginary::pools.begin() ;
   36111           0 :           SgTypeImaginary::next_node = (SgTypeImaginary*) (*block);
   36112             : 
   36113           0 :           while ( block != SgTypeImaginary::pools.end() )
   36114             :              {
   36115           0 :                pointer = (SgTypeImaginary*) (*block);
   36116           0 :                if ( tempPointer != NULL )
   36117             :                   {
   36118           0 :                     tempPointer->set_freepointer(pointer);
   36119             :                   }
   36120           0 :                for (unsigned i = 0; i < SgTypeImaginary::pool_size - 1; ++i)
   36121             :                   {
   36122           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   36123             :                   }
   36124           0 :                 pointer[SgTypeImaginary::pool_size-1].set_freepointer(NULL);
   36125           0 :                 tempPointer = &(pointer[SgTypeImaginary::pool_size-1]);
   36126           0 :                 ++block;
   36127             :              }
   36128             :         }
   36129           0 :    }
   36130             : 
   36131           5 : void SgTypeImaginary::deleteMemoryPool() {
   36132           5 :   for (auto p: SgTypeImaginary::pools) {
   36133           0 :     ROSE_FREE(p);
   36134             :   }
   36135           5 :   SgTypeImaginary::next_node = nullptr;
   36136           5 :   SgTypeImaginary::pools.clear();
   36137           5 : }
   36138             : 
   36139             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   36140             : //                 reading multiple binary files to for a single AST.
   36141             : /////////// new version ////////////////////////////////
   36142             : //############################################################################
   36143             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   36144             : void
   36145           2 : SgTypeImaginary::extendMemoryPoolForFileIO( )
   36146             :   {
   36147           2 :     size_t blockIndex = SgTypeImaginary::pools.size();
   36148           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeImaginary) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeImaginary);
   36149             : 
   36150           2 :     while ( (blockIndex * SgTypeImaginary::pool_size) < newPoolSize)
   36151             :       {
   36152             : #if ROSE_ALLOC_TRACE
   36153             :         if (blockIndex > 0) {
   36154             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeImaginary) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeImaginary) = %" PRIuPTR " SgTypeImaginary::pool_size = %d \n",
   36155             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeImaginary),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeImaginary),SgTypeImaginary::pool_size);
   36156             :         }
   36157             : #endif
   36158             : 
   36159           0 :         SgTypeImaginary * pointer = (SgTypeImaginary*) ROSE_MALLOC ( SgTypeImaginary::pool_size * sizeof(SgTypeImaginary) );
   36160           0 :         assert( pointer != NULL );
   36161             : #if ROSE_ALLOC_MEMSET == 1
   36162             :         memset(pointer, 0x00, SgTypeImaginary::pool_size * sizeof(SgTypeImaginary));
   36163             : #elif ROSE_ALLOC_MEMSET == 2
   36164             :         memset(pointer, 0xCC, SgTypeImaginary::pool_size * sizeof(SgTypeImaginary));
   36165             : #endif
   36166           0 :         SgTypeImaginary::pools.push_back( (unsigned char*)(pointer) );
   36167           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeImaginary::pool_size * sizeof(SgTypeImaginary), V_SgTypeImaginary ) );
   36168             : 
   36169           0 :         if ( SgTypeImaginary::next_node != NULL ) {
   36170           0 :           if ( blockIndex > 0 ) {
   36171           0 :             SgTypeImaginary * blkptr = (SgTypeImaginary*)(SgTypeImaginary::pools[blockIndex-1]);
   36172           0 :             blkptr[ SgTypeImaginary::pool_size - 1 ].set_freepointer(pointer);
   36173             :           }
   36174             :         } else {
   36175           0 :           SgTypeImaginary::next_node = pointer;
   36176             :         }
   36177             : 
   36178           0 :         for (unsigned i = 0; i < SgTypeImaginary::pool_size-1; ++i)
   36179             :            {
   36180           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   36181             :            }
   36182           0 :         pointer[ SgTypeImaginary::pool_size -1 ].set_freepointer(NULL);
   36183             : 
   36184           0 :         blockIndex++;
   36185             :       }
   36186           2 :   }
   36187             : 
   36188             : //############################################################################
   36189             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   36190             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   36191             :  * not compressed. However, that stuff is not yet implemented! 
   36192             :  */
   36193             : unsigned long
   36194           0 : SgTypeImaginary::getNumberOfLastValidPointer()
   36195             :    {
   36196           0 :       SgTypeImaginary* testPointer = (SgTypeImaginary*)(SgTypeImaginary::pools.back());
   36197           0 :       unsigned long localIndex = SgTypeImaginary::pool_size - 1;
   36198           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   36199             :          {
   36200           0 :            localIndex--;
   36201             :          }
   36202           0 :       return (localIndex + SgTypeImaginary::pool_size * (SgTypeImaginary::pools.size()-1));
   36203             :    }
   36204             : 
   36205             : //############################################################################
   36206             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   36207             :  * memory pool and initializes the data member in class SgTypeImaginaryStroageClass
   36208             :  * from its counterpart of SgTypeImaginary. The return value is just for checking, 
   36209             :  * that the whole StorageClassArray is initialized!
   36210             :  */
   36211             : unsigned long
   36212           0 : SgTypeImaginary::initializeStorageClassArray( SgTypeImaginaryStorageClass *storageArray )
   36213             :    {
   36214           0 :      unsigned long storageCounter = 0;
   36215           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeImaginary::pools.begin();
   36216           0 :      SgTypeImaginary* pointer = NULL;
   36217           0 :      while ( block != SgTypeImaginary::pools.end() ) {
   36218           0 :           pointer = (SgTypeImaginary*) (*block);
   36219           0 :           for ( unsigned i = 0; i < SgTypeImaginary::pool_size; ++i ) {
   36220           0 :                if ( pointer->get_freepointer() != NULL ) {
   36221           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   36222           0 :                  storageArray++;
   36223           0 :                  storageCounter++;
   36224             :                }
   36225           0 :                pointer++;
   36226             :              }
   36227           0 :            block++;
   36228             :         }
   36229           0 :      return storageCounter;
   36230             :    }
   36231             : 
   36232             : /* #line 36233 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   36233             : 
   36234             : 
   36235             : 
   36236             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   36237             : 
   36238             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   36239             : 
   36240             : //############################################################################
   36241             : /* JH (02/02/2006) Constructor of the IR node SgTypeDefault that takes its 
   36242             :  * corresponding StorageClass as parameter
   36243             :  */
   36244           4 : SgTypeDefault :: SgTypeDefault ( const SgTypeDefaultStorageClass& storageSource )   : SgType (storageSource)
   36245             :    {
   36246             : 
   36247             : 
   36248             : /* #line 36249 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   36249             : 
   36250           4 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   36251           4 :      p_name = SgName ( storageSource.storageOf_name ) ;
   36252             : 
   36253             : 
   36254             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   36255             : 
   36256             : 
   36257           4 :    }
   36258             : 
   36259             : //############################################################################
   36260             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   36261             :  * within the working AST. 
   36262             :  */
   36263          11 : SgTypeDefault * SgTypeDefault::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   36264          11 :      SgTypeDefault* returnPointer = NULL;
   36265          11 :      if ( globalIndex != 0 )
   36266             :         {
   36267             : 
   36268             : #if FILE_IO_EXTRA_CHECK
   36269          11 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeDefault ) ) <= globalIndex ) ;
   36270          11 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeDefault + 1 ) ) );
   36271             : #endif
   36272          11 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeDefault )  
   36273          11 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeDefault );
   36274          11 :           unsigned long positionInPool = localIndex % SgTypeDefault::pool_size;
   36275          11 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeDefault::pool_size;
   36276             : 
   36277             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   36278             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   36279             : 
   36280          11 :           returnPointer = &( ( (SgTypeDefault*)(SgTypeDefault::pools[memoryBlock]) ) [positionInPool]) ;
   36281             : 
   36282          11 :           ROSE_ASSERT( returnPointer != NULL ) ;
   36283             :         }
   36284          11 :      return returnPointer ;
   36285             :    }
   36286             : 
   36287             : //############################################################################
   36288             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   36289             :   for the AST with the index astIndex
   36290             : */
   36291           0 : SgTypeDefault * SgTypeDefault::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   36292           0 :      SgTypeDefault* returnPointer = NULL;
   36293           0 :      if ( globalIndex != 0 )
   36294             :         {
   36295             : 
   36296             : #if FILE_IO_EXTRA_CHECK
   36297           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeDefault ) ) <= globalIndex ) ;
   36298           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeDefault + 1 ) ) );
   36299             : #endif
   36300           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeDefault )
   36301           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeDefault );
   36302           0 :           unsigned long positionInPool = localIndex % SgTypeDefault::pool_size ;
   36303           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeDefault::pool_size ;
   36304             : 
   36305             : #if FILE_IO_EXTRA_CHECK
   36306             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   36307             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   36308             : #endif
   36309             : 
   36310           0 :           returnPointer = &( ( (SgTypeDefault*)(SgTypeDefault::pools[memoryBlock]) ) [positionInPool]) ;
   36311             : 
   36312             : #if FILE_IO_EXTRA_CHECK
   36313           0 :           assert ( returnPointer != NULL ) ;
   36314             : #endif
   36315             :         }
   36316           0 :      return returnPointer ;
   36317             :    }
   36318             : 
   36319             : //############################################################################
   36320             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   36321             :  * pool size! We set for every valid object in the memory pool the freepointer
   36322             :  * to the global index and increase the global index afterwards. For all the 
   36323             :  * invalid objects (means address ranges within the memory pool that were not
   36324             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   36325             :  * distinguish valid from invalid objects! 
   36326             :  */
   36327             : unsigned long
   36328           5 : SgTypeDefault::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   36329             :    {
   36330           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   36331           5 :      SgTypeDefault* pointer = NULL;
   36332           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   36333           5 :      std::vector < unsigned char* > :: const_iterator block;
   36334           7 :      for ( block = SgTypeDefault::pools.begin(); block != SgTypeDefault::pools.end() ; ++block )
   36335             :         {
   36336           2 :           pointer = (SgTypeDefault*)(*block);
   36337        4002 :           for (unsigned i = 0; i < SgTypeDefault::pool_size; ++i )
   36338             :              {
   36339             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   36340             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   36341             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   36342             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   36343             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   36344             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   36345             :             // properly; so this will have to be checked next.
   36346             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   36347             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   36348        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   36349             :                   {
   36350           4 :                     pointer[i].set_freepointer((SgTypeDefault*)(globalIndex));
   36351           4 :                     globalIndex++;
   36352             :                   }
   36353             :                else
   36354             :                   {
   36355        3996 :                     pointer[i].set_freepointer(NULL);
   36356             :                   }
   36357             :               }
   36358             :         }
   36359           5 :      return globalIndex;
   36360             :    }
   36361             : 
   36362             : //############################################################################
   36363             : // JH (01/14/2006)
   36364             : void
   36365           5 : SgTypeDefault::resetValidFreepointers( )
   36366             :    {
   36367           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   36368           5 :      SgTypeDefault* pointer = NULL;
   36369           5 :      std::vector < unsigned char* > :: const_iterator block;
   36370           5 :      SgTypeDefault* pointerOfLinkedList = NULL;
   36371           7 :      for ( block = SgTypeDefault::pools.begin(); block != SgTypeDefault::pools.end() ; ++block )
   36372             :         {
   36373           2 :           pointer = (SgTypeDefault*)(*block);
   36374        4002 :           for (unsigned i = 0; i < SgTypeDefault::pool_size; ++i )
   36375             :              {
   36376             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   36377             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   36378             :             // memory blocks!.
   36379        4000 :                if ( pointer[i].get_freepointer() != NULL )
   36380             :                   {
   36381           4 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   36382             :                   }
   36383             :                else
   36384             :                   {
   36385        3996 :                     if ( pointerOfLinkedList == NULL )
   36386             :                        {
   36387           2 :                          SgTypeDefault::next_node = &(pointer[i]);
   36388             :                        }
   36389             :                     else
   36390             :                        {
   36391             :                       // printf ("In SgTypeDefault::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   36392        3994 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   36393             :                        }
   36394             :                     pointerOfLinkedList = &(pointer[i]);
   36395             :                   }
   36396             :               }
   36397             :         }
   36398             : 
   36399           5 :      if ( pointerOfLinkedList != NULL )
   36400             :         {
   36401             :        // printf ("In SgTypeDefault::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   36402           2 :           pointerOfLinkedList->set_freepointer(NULL);
   36403             :        // DQ (6/6/2010): Temporary debugging...
   36404             :        //   ROSE_ASSERT(false);
   36405             :         }
   36406             : 
   36407           5 :      return ;
   36408             :    }
   36409             : 
   36410             : //############################################################################
   36411             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   36412             :  * within the memory pool and resets the freepointers, in order to achieve a 
   36413             :  * linked list, that has no jumps and starts at the beginning! This function 
   36414             :  * does not extend the memory pool, since we do not delete any memory blocks,
   36415             :  * but delete the valid objects.  
   36416             :  */
   36417             : void
   36418           0 : SgTypeDefault::clearMemoryPool( )
   36419             :    {
   36420             :   // printf ("Inside of SgTypeDefault::clearMemoryPool() \n");
   36421             : 
   36422           0 :      SgTypeDefault* pointer = NULL, *tempPointer = NULL;
   36423           0 :      std::vector < unsigned char* > :: const_iterator block;
   36424           0 :      if ( SgTypeDefault::pools.empty() == false )
   36425             :         {
   36426           0 :           block = SgTypeDefault::pools.begin() ;
   36427           0 :           SgTypeDefault::next_node = (SgTypeDefault*) (*block);
   36428             : 
   36429           0 :           while ( block != SgTypeDefault::pools.end() )
   36430             :              {
   36431           0 :                pointer = (SgTypeDefault*) (*block);
   36432           0 :                if ( tempPointer != NULL )
   36433             :                   {
   36434           0 :                     tempPointer->set_freepointer(pointer);
   36435             :                   }
   36436           0 :                for (unsigned i = 0; i < SgTypeDefault::pool_size - 1; ++i)
   36437             :                   {
   36438           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   36439             :                   }
   36440           0 :                 pointer[SgTypeDefault::pool_size-1].set_freepointer(NULL);
   36441           0 :                 tempPointer = &(pointer[SgTypeDefault::pool_size-1]);
   36442           0 :                 ++block;
   36443             :              }
   36444             :         }
   36445           0 :    }
   36446             : 
   36447           5 : void SgTypeDefault::deleteMemoryPool() {
   36448           9 :   for (auto p: SgTypeDefault::pools) {
   36449           4 :     ROSE_FREE(p);
   36450             :   }
   36451           5 :   SgTypeDefault::next_node = nullptr;
   36452           5 :   SgTypeDefault::pools.clear();
   36453           5 : }
   36454             : 
   36455             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   36456             : //                 reading multiple binary files to for a single AST.
   36457             : /////////// new version ////////////////////////////////
   36458             : //############################################################################
   36459             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   36460             : void
   36461           2 : SgTypeDefault::extendMemoryPoolForFileIO( )
   36462             :   {
   36463           2 :     size_t blockIndex = SgTypeDefault::pools.size();
   36464           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeDefault) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeDefault);
   36465             : 
   36466           4 :     while ( (blockIndex * SgTypeDefault::pool_size) < newPoolSize)
   36467             :       {
   36468             : #if ROSE_ALLOC_TRACE
   36469             :         if (blockIndex > 0) {
   36470             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeDefault) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeDefault) = %" PRIuPTR " SgTypeDefault::pool_size = %d \n",
   36471             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeDefault),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeDefault),SgTypeDefault::pool_size);
   36472             :         }
   36473             : #endif
   36474             : 
   36475           2 :         SgTypeDefault * pointer = (SgTypeDefault*) ROSE_MALLOC ( SgTypeDefault::pool_size * sizeof(SgTypeDefault) );
   36476           2 :         assert( pointer != NULL );
   36477             : #if ROSE_ALLOC_MEMSET == 1
   36478             :         memset(pointer, 0x00, SgTypeDefault::pool_size * sizeof(SgTypeDefault));
   36479             : #elif ROSE_ALLOC_MEMSET == 2
   36480             :         memset(pointer, 0xCC, SgTypeDefault::pool_size * sizeof(SgTypeDefault));
   36481             : #endif
   36482           2 :         SgTypeDefault::pools.push_back( (unsigned char*)(pointer) );
   36483           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeDefault::pool_size * sizeof(SgTypeDefault), V_SgTypeDefault ) );
   36484             : 
   36485           2 :         if ( SgTypeDefault::next_node != NULL ) {
   36486           0 :           if ( blockIndex > 0 ) {
   36487           0 :             SgTypeDefault * blkptr = (SgTypeDefault*)(SgTypeDefault::pools[blockIndex-1]);
   36488           0 :             blkptr[ SgTypeDefault::pool_size - 1 ].set_freepointer(pointer);
   36489             :           }
   36490             :         } else {
   36491           2 :           SgTypeDefault::next_node = pointer;
   36492             :         }
   36493             : 
   36494        4000 :         for (unsigned i = 0; i < SgTypeDefault::pool_size-1; ++i)
   36495             :            {
   36496        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   36497             :            }
   36498           2 :         pointer[ SgTypeDefault::pool_size -1 ].set_freepointer(NULL);
   36499             : 
   36500           2 :         blockIndex++;
   36501             :       }
   36502           2 :   }
   36503             : 
   36504             : //############################################################################
   36505             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   36506             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   36507             :  * not compressed. However, that stuff is not yet implemented! 
   36508             :  */
   36509             : unsigned long
   36510           0 : SgTypeDefault::getNumberOfLastValidPointer()
   36511             :    {
   36512           0 :       SgTypeDefault* testPointer = (SgTypeDefault*)(SgTypeDefault::pools.back());
   36513           0 :       unsigned long localIndex = SgTypeDefault::pool_size - 1;
   36514           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   36515             :          {
   36516           0 :            localIndex--;
   36517             :          }
   36518           0 :       return (localIndex + SgTypeDefault::pool_size * (SgTypeDefault::pools.size()-1));
   36519             :    }
   36520             : 
   36521             : //############################################################################
   36522             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   36523             :  * memory pool and initializes the data member in class SgTypeDefaultStroageClass
   36524             :  * from its counterpart of SgTypeDefault. The return value is just for checking, 
   36525             :  * that the whole StorageClassArray is initialized!
   36526             :  */
   36527             : unsigned long
   36528           2 : SgTypeDefault::initializeStorageClassArray( SgTypeDefaultStorageClass *storageArray )
   36529             :    {
   36530           2 :      unsigned long storageCounter = 0;
   36531           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypeDefault::pools.begin();
   36532           2 :      SgTypeDefault* pointer = NULL;
   36533           4 :      while ( block != SgTypeDefault::pools.end() ) {
   36534           2 :           pointer = (SgTypeDefault*) (*block);
   36535        4002 :           for ( unsigned i = 0; i < SgTypeDefault::pool_size; ++i ) {
   36536        4000 :                if ( pointer->get_freepointer() != NULL ) {
   36537           4 :                  storageArray->pickOutIRNodeData (pointer) ;
   36538           4 :                  storageArray++;
   36539           4 :                  storageCounter++;
   36540             :                }
   36541        4000 :                pointer++;
   36542             :              }
   36543           2 :            block++;
   36544             :         }
   36545           2 :      return storageCounter;
   36546             :    }
   36547             : 
   36548             : /* #line 36549 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   36549             : 
   36550             : 
   36551             : 
   36552             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   36553             : 
   36554             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   36555             : 
   36556             : //############################################################################
   36557             : /* JH (02/02/2006) Constructor of the IR node SgTypeCAFTeam that takes its 
   36558             :  * corresponding StorageClass as parameter
   36559             :  */
   36560           0 : SgTypeCAFTeam :: SgTypeCAFTeam ( const SgTypeCAFTeamStorageClass& storageSource )   : SgType (storageSource)
   36561             :    {
   36562             : 
   36563             : 
   36564             : /* #line 36565 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   36565             : 
   36566           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   36567             : 
   36568             : 
   36569             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   36570             : 
   36571             : 
   36572           0 :    }
   36573             : 
   36574             : //############################################################################
   36575             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   36576             :  * within the working AST. 
   36577             :  */
   36578           0 : SgTypeCAFTeam * SgTypeCAFTeam::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   36579           0 :      SgTypeCAFTeam* returnPointer = NULL;
   36580           0 :      if ( globalIndex != 0 )
   36581             :         {
   36582             : 
   36583             : #if FILE_IO_EXTRA_CHECK
   36584           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeCAFTeam ) ) <= globalIndex ) ;
   36585           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeCAFTeam + 1 ) ) );
   36586             : #endif
   36587           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeCAFTeam )  
   36588           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeCAFTeam );
   36589           0 :           unsigned long positionInPool = localIndex % SgTypeCAFTeam::pool_size;
   36590           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeCAFTeam::pool_size;
   36591             : 
   36592             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   36593             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   36594             : 
   36595           0 :           returnPointer = &( ( (SgTypeCAFTeam*)(SgTypeCAFTeam::pools[memoryBlock]) ) [positionInPool]) ;
   36596             : 
   36597           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   36598             :         }
   36599           0 :      return returnPointer ;
   36600             :    }
   36601             : 
   36602             : //############################################################################
   36603             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   36604             :   for the AST with the index astIndex
   36605             : */
   36606           0 : SgTypeCAFTeam * SgTypeCAFTeam::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   36607           0 :      SgTypeCAFTeam* returnPointer = NULL;
   36608           0 :      if ( globalIndex != 0 )
   36609             :         {
   36610             : 
   36611             : #if FILE_IO_EXTRA_CHECK
   36612           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeCAFTeam ) ) <= globalIndex ) ;
   36613           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeCAFTeam + 1 ) ) );
   36614             : #endif
   36615           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeCAFTeam )
   36616           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeCAFTeam );
   36617           0 :           unsigned long positionInPool = localIndex % SgTypeCAFTeam::pool_size ;
   36618           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeCAFTeam::pool_size ;
   36619             : 
   36620             : #if FILE_IO_EXTRA_CHECK
   36621             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   36622             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   36623             : #endif
   36624             : 
   36625           0 :           returnPointer = &( ( (SgTypeCAFTeam*)(SgTypeCAFTeam::pools[memoryBlock]) ) [positionInPool]) ;
   36626             : 
   36627             : #if FILE_IO_EXTRA_CHECK
   36628           0 :           assert ( returnPointer != NULL ) ;
   36629             : #endif
   36630             :         }
   36631           0 :      return returnPointer ;
   36632             :    }
   36633             : 
   36634             : //############################################################################
   36635             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   36636             :  * pool size! We set for every valid object in the memory pool the freepointer
   36637             :  * to the global index and increase the global index afterwards. For all the 
   36638             :  * invalid objects (means address ranges within the memory pool that were not
   36639             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   36640             :  * distinguish valid from invalid objects! 
   36641             :  */
   36642             : unsigned long
   36643           5 : SgTypeCAFTeam::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   36644             :    {
   36645           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   36646           5 :      SgTypeCAFTeam* pointer = NULL;
   36647           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   36648           5 :      std::vector < unsigned char* > :: const_iterator block;
   36649           5 :      for ( block = SgTypeCAFTeam::pools.begin(); block != SgTypeCAFTeam::pools.end() ; ++block )
   36650             :         {
   36651           0 :           pointer = (SgTypeCAFTeam*)(*block);
   36652           0 :           for (unsigned i = 0; i < SgTypeCAFTeam::pool_size; ++i )
   36653             :              {
   36654             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   36655             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   36656             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   36657             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   36658             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   36659             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   36660             :             // properly; so this will have to be checked next.
   36661             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   36662             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   36663           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   36664             :                   {
   36665           0 :                     pointer[i].set_freepointer((SgTypeCAFTeam*)(globalIndex));
   36666           0 :                     globalIndex++;
   36667             :                   }
   36668             :                else
   36669             :                   {
   36670           0 :                     pointer[i].set_freepointer(NULL);
   36671             :                   }
   36672             :               }
   36673             :         }
   36674           5 :      return globalIndex;
   36675             :    }
   36676             : 
   36677             : //############################################################################
   36678             : // JH (01/14/2006)
   36679             : void
   36680           5 : SgTypeCAFTeam::resetValidFreepointers( )
   36681             :    {
   36682           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   36683           5 :      SgTypeCAFTeam* pointer = NULL;
   36684           5 :      std::vector < unsigned char* > :: const_iterator block;
   36685           5 :      SgTypeCAFTeam* pointerOfLinkedList = NULL;
   36686           5 :      for ( block = SgTypeCAFTeam::pools.begin(); block != SgTypeCAFTeam::pools.end() ; ++block )
   36687             :         {
   36688           0 :           pointer = (SgTypeCAFTeam*)(*block);
   36689           0 :           for (unsigned i = 0; i < SgTypeCAFTeam::pool_size; ++i )
   36690             :              {
   36691             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   36692             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   36693             :             // memory blocks!.
   36694           0 :                if ( pointer[i].get_freepointer() != NULL )
   36695             :                   {
   36696           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   36697             :                   }
   36698             :                else
   36699             :                   {
   36700           0 :                     if ( pointerOfLinkedList == NULL )
   36701             :                        {
   36702           0 :                          SgTypeCAFTeam::next_node = &(pointer[i]);
   36703             :                        }
   36704             :                     else
   36705             :                        {
   36706             :                       // printf ("In SgTypeCAFTeam::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   36707           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   36708             :                        }
   36709             :                     pointerOfLinkedList = &(pointer[i]);
   36710             :                   }
   36711             :               }
   36712             :         }
   36713             : 
   36714           5 :      if ( pointerOfLinkedList != NULL )
   36715             :         {
   36716             :        // printf ("In SgTypeCAFTeam::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   36717           0 :           pointerOfLinkedList->set_freepointer(NULL);
   36718             :        // DQ (6/6/2010): Temporary debugging...
   36719             :        //   ROSE_ASSERT(false);
   36720             :         }
   36721             : 
   36722           5 :      return ;
   36723             :    }
   36724             : 
   36725             : //############################################################################
   36726             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   36727             :  * within the memory pool and resets the freepointers, in order to achieve a 
   36728             :  * linked list, that has no jumps and starts at the beginning! This function 
   36729             :  * does not extend the memory pool, since we do not delete any memory blocks,
   36730             :  * but delete the valid objects.  
   36731             :  */
   36732             : void
   36733           0 : SgTypeCAFTeam::clearMemoryPool( )
   36734             :    {
   36735             :   // printf ("Inside of SgTypeCAFTeam::clearMemoryPool() \n");
   36736             : 
   36737           0 :      SgTypeCAFTeam* pointer = NULL, *tempPointer = NULL;
   36738           0 :      std::vector < unsigned char* > :: const_iterator block;
   36739           0 :      if ( SgTypeCAFTeam::pools.empty() == false )
   36740             :         {
   36741           0 :           block = SgTypeCAFTeam::pools.begin() ;
   36742           0 :           SgTypeCAFTeam::next_node = (SgTypeCAFTeam*) (*block);
   36743             : 
   36744           0 :           while ( block != SgTypeCAFTeam::pools.end() )
   36745             :              {
   36746           0 :                pointer = (SgTypeCAFTeam*) (*block);
   36747           0 :                if ( tempPointer != NULL )
   36748             :                   {
   36749           0 :                     tempPointer->set_freepointer(pointer);
   36750             :                   }
   36751           0 :                for (unsigned i = 0; i < SgTypeCAFTeam::pool_size - 1; ++i)
   36752             :                   {
   36753           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   36754             :                   }
   36755           0 :                 pointer[SgTypeCAFTeam::pool_size-1].set_freepointer(NULL);
   36756           0 :                 tempPointer = &(pointer[SgTypeCAFTeam::pool_size-1]);
   36757           0 :                 ++block;
   36758             :              }
   36759             :         }
   36760           0 :    }
   36761             : 
   36762           5 : void SgTypeCAFTeam::deleteMemoryPool() {
   36763           5 :   for (auto p: SgTypeCAFTeam::pools) {
   36764           0 :     ROSE_FREE(p);
   36765             :   }
   36766           5 :   SgTypeCAFTeam::next_node = nullptr;
   36767           5 :   SgTypeCAFTeam::pools.clear();
   36768           5 : }
   36769             : 
   36770             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   36771             : //                 reading multiple binary files to for a single AST.
   36772             : /////////// new version ////////////////////////////////
   36773             : //############################################################################
   36774             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   36775             : void
   36776           2 : SgTypeCAFTeam::extendMemoryPoolForFileIO( )
   36777             :   {
   36778           2 :     size_t blockIndex = SgTypeCAFTeam::pools.size();
   36779           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeCAFTeam) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeCAFTeam);
   36780             : 
   36781           2 :     while ( (blockIndex * SgTypeCAFTeam::pool_size) < newPoolSize)
   36782             :       {
   36783             : #if ROSE_ALLOC_TRACE
   36784             :         if (blockIndex > 0) {
   36785             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeCAFTeam) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeCAFTeam) = %" PRIuPTR " SgTypeCAFTeam::pool_size = %d \n",
   36786             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeCAFTeam),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeCAFTeam),SgTypeCAFTeam::pool_size);
   36787             :         }
   36788             : #endif
   36789             : 
   36790           0 :         SgTypeCAFTeam * pointer = (SgTypeCAFTeam*) ROSE_MALLOC ( SgTypeCAFTeam::pool_size * sizeof(SgTypeCAFTeam) );
   36791           0 :         assert( pointer != NULL );
   36792             : #if ROSE_ALLOC_MEMSET == 1
   36793             :         memset(pointer, 0x00, SgTypeCAFTeam::pool_size * sizeof(SgTypeCAFTeam));
   36794             : #elif ROSE_ALLOC_MEMSET == 2
   36795             :         memset(pointer, 0xCC, SgTypeCAFTeam::pool_size * sizeof(SgTypeCAFTeam));
   36796             : #endif
   36797           0 :         SgTypeCAFTeam::pools.push_back( (unsigned char*)(pointer) );
   36798           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeCAFTeam::pool_size * sizeof(SgTypeCAFTeam), V_SgTypeCAFTeam ) );
   36799             : 
   36800           0 :         if ( SgTypeCAFTeam::next_node != NULL ) {
   36801           0 :           if ( blockIndex > 0 ) {
   36802           0 :             SgTypeCAFTeam * blkptr = (SgTypeCAFTeam*)(SgTypeCAFTeam::pools[blockIndex-1]);
   36803           0 :             blkptr[ SgTypeCAFTeam::pool_size - 1 ].set_freepointer(pointer);
   36804             :           }
   36805             :         } else {
   36806           0 :           SgTypeCAFTeam::next_node = pointer;
   36807             :         }
   36808             : 
   36809           0 :         for (unsigned i = 0; i < SgTypeCAFTeam::pool_size-1; ++i)
   36810             :            {
   36811           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   36812             :            }
   36813           0 :         pointer[ SgTypeCAFTeam::pool_size -1 ].set_freepointer(NULL);
   36814             : 
   36815           0 :         blockIndex++;
   36816             :       }
   36817           2 :   }
   36818             : 
   36819             : //############################################################################
   36820             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   36821             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   36822             :  * not compressed. However, that stuff is not yet implemented! 
   36823             :  */
   36824             : unsigned long
   36825           0 : SgTypeCAFTeam::getNumberOfLastValidPointer()
   36826             :    {
   36827           0 :       SgTypeCAFTeam* testPointer = (SgTypeCAFTeam*)(SgTypeCAFTeam::pools.back());
   36828           0 :       unsigned long localIndex = SgTypeCAFTeam::pool_size - 1;
   36829           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   36830             :          {
   36831           0 :            localIndex--;
   36832             :          }
   36833           0 :       return (localIndex + SgTypeCAFTeam::pool_size * (SgTypeCAFTeam::pools.size()-1));
   36834             :    }
   36835             : 
   36836             : //############################################################################
   36837             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   36838             :  * memory pool and initializes the data member in class SgTypeCAFTeamStroageClass
   36839             :  * from its counterpart of SgTypeCAFTeam. The return value is just for checking, 
   36840             :  * that the whole StorageClassArray is initialized!
   36841             :  */
   36842             : unsigned long
   36843           0 : SgTypeCAFTeam::initializeStorageClassArray( SgTypeCAFTeamStorageClass *storageArray )
   36844             :    {
   36845           0 :      unsigned long storageCounter = 0;
   36846           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeCAFTeam::pools.begin();
   36847           0 :      SgTypeCAFTeam* pointer = NULL;
   36848           0 :      while ( block != SgTypeCAFTeam::pools.end() ) {
   36849           0 :           pointer = (SgTypeCAFTeam*) (*block);
   36850           0 :           for ( unsigned i = 0; i < SgTypeCAFTeam::pool_size; ++i ) {
   36851           0 :                if ( pointer->get_freepointer() != NULL ) {
   36852           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   36853           0 :                  storageArray++;
   36854           0 :                  storageCounter++;
   36855             :                }
   36856           0 :                pointer++;
   36857             :              }
   36858           0 :            block++;
   36859             :         }
   36860           0 :      return storageCounter;
   36861             :    }
   36862             : 
   36863             : /* #line 36864 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   36864             : 
   36865             : 
   36866             : 
   36867             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   36868             : 
   36869             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   36870             : 
   36871             : //############################################################################
   36872             : /* JH (02/02/2006) Constructor of the IR node SgTypeCrayPointer that takes its 
   36873             :  * corresponding StorageClass as parameter
   36874             :  */
   36875           0 : SgTypeCrayPointer :: SgTypeCrayPointer ( const SgTypeCrayPointerStorageClass& storageSource )   : SgType (storageSource)
   36876             :    {
   36877             : 
   36878             : 
   36879             : /* #line 36880 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   36880             : 
   36881           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   36882             : 
   36883             : 
   36884             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   36885             : 
   36886             : 
   36887           0 :    }
   36888             : 
   36889             : //############################################################################
   36890             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   36891             :  * within the working AST. 
   36892             :  */
   36893           0 : SgTypeCrayPointer * SgTypeCrayPointer::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   36894           0 :      SgTypeCrayPointer* returnPointer = NULL;
   36895           0 :      if ( globalIndex != 0 )
   36896             :         {
   36897             : 
   36898             : #if FILE_IO_EXTRA_CHECK
   36899           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeCrayPointer ) ) <= globalIndex ) ;
   36900           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeCrayPointer + 1 ) ) );
   36901             : #endif
   36902           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeCrayPointer )  
   36903           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeCrayPointer );
   36904           0 :           unsigned long positionInPool = localIndex % SgTypeCrayPointer::pool_size;
   36905           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeCrayPointer::pool_size;
   36906             : 
   36907             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   36908             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   36909             : 
   36910           0 :           returnPointer = &( ( (SgTypeCrayPointer*)(SgTypeCrayPointer::pools[memoryBlock]) ) [positionInPool]) ;
   36911             : 
   36912           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   36913             :         }
   36914           0 :      return returnPointer ;
   36915             :    }
   36916             : 
   36917             : //############################################################################
   36918             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   36919             :   for the AST with the index astIndex
   36920             : */
   36921           0 : SgTypeCrayPointer * SgTypeCrayPointer::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   36922           0 :      SgTypeCrayPointer* returnPointer = NULL;
   36923           0 :      if ( globalIndex != 0 )
   36924             :         {
   36925             : 
   36926             : #if FILE_IO_EXTRA_CHECK
   36927           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeCrayPointer ) ) <= globalIndex ) ;
   36928           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeCrayPointer + 1 ) ) );
   36929             : #endif
   36930           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeCrayPointer )
   36931           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeCrayPointer );
   36932           0 :           unsigned long positionInPool = localIndex % SgTypeCrayPointer::pool_size ;
   36933           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeCrayPointer::pool_size ;
   36934             : 
   36935             : #if FILE_IO_EXTRA_CHECK
   36936             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   36937             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   36938             : #endif
   36939             : 
   36940           0 :           returnPointer = &( ( (SgTypeCrayPointer*)(SgTypeCrayPointer::pools[memoryBlock]) ) [positionInPool]) ;
   36941             : 
   36942             : #if FILE_IO_EXTRA_CHECK
   36943           0 :           assert ( returnPointer != NULL ) ;
   36944             : #endif
   36945             :         }
   36946           0 :      return returnPointer ;
   36947             :    }
   36948             : 
   36949             : //############################################################################
   36950             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   36951             :  * pool size! We set for every valid object in the memory pool the freepointer
   36952             :  * to the global index and increase the global index afterwards. For all the 
   36953             :  * invalid objects (means address ranges within the memory pool that were not
   36954             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   36955             :  * distinguish valid from invalid objects! 
   36956             :  */
   36957             : unsigned long
   36958           5 : SgTypeCrayPointer::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   36959             :    {
   36960           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   36961           5 :      SgTypeCrayPointer* pointer = NULL;
   36962           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   36963           5 :      std::vector < unsigned char* > :: const_iterator block;
   36964           5 :      for ( block = SgTypeCrayPointer::pools.begin(); block != SgTypeCrayPointer::pools.end() ; ++block )
   36965             :         {
   36966           0 :           pointer = (SgTypeCrayPointer*)(*block);
   36967           0 :           for (unsigned i = 0; i < SgTypeCrayPointer::pool_size; ++i )
   36968             :              {
   36969             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   36970             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   36971             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   36972             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   36973             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   36974             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   36975             :             // properly; so this will have to be checked next.
   36976             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   36977             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   36978           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   36979             :                   {
   36980           0 :                     pointer[i].set_freepointer((SgTypeCrayPointer*)(globalIndex));
   36981           0 :                     globalIndex++;
   36982             :                   }
   36983             :                else
   36984             :                   {
   36985           0 :                     pointer[i].set_freepointer(NULL);
   36986             :                   }
   36987             :               }
   36988             :         }
   36989           5 :      return globalIndex;
   36990             :    }
   36991             : 
   36992             : //############################################################################
   36993             : // JH (01/14/2006)
   36994             : void
   36995           5 : SgTypeCrayPointer::resetValidFreepointers( )
   36996             :    {
   36997           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   36998           5 :      SgTypeCrayPointer* pointer = NULL;
   36999           5 :      std::vector < unsigned char* > :: const_iterator block;
   37000           5 :      SgTypeCrayPointer* pointerOfLinkedList = NULL;
   37001           5 :      for ( block = SgTypeCrayPointer::pools.begin(); block != SgTypeCrayPointer::pools.end() ; ++block )
   37002             :         {
   37003           0 :           pointer = (SgTypeCrayPointer*)(*block);
   37004           0 :           for (unsigned i = 0; i < SgTypeCrayPointer::pool_size; ++i )
   37005             :              {
   37006             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   37007             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   37008             :             // memory blocks!.
   37009           0 :                if ( pointer[i].get_freepointer() != NULL )
   37010             :                   {
   37011           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   37012             :                   }
   37013             :                else
   37014             :                   {
   37015           0 :                     if ( pointerOfLinkedList == NULL )
   37016             :                        {
   37017           0 :                          SgTypeCrayPointer::next_node = &(pointer[i]);
   37018             :                        }
   37019             :                     else
   37020             :                        {
   37021             :                       // printf ("In SgTypeCrayPointer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   37022           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   37023             :                        }
   37024             :                     pointerOfLinkedList = &(pointer[i]);
   37025             :                   }
   37026             :               }
   37027             :         }
   37028             : 
   37029           5 :      if ( pointerOfLinkedList != NULL )
   37030             :         {
   37031             :        // printf ("In SgTypeCrayPointer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   37032           0 :           pointerOfLinkedList->set_freepointer(NULL);
   37033             :        // DQ (6/6/2010): Temporary debugging...
   37034             :        //   ROSE_ASSERT(false);
   37035             :         }
   37036             : 
   37037           5 :      return ;
   37038             :    }
   37039             : 
   37040             : //############################################################################
   37041             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   37042             :  * within the memory pool and resets the freepointers, in order to achieve a 
   37043             :  * linked list, that has no jumps and starts at the beginning! This function 
   37044             :  * does not extend the memory pool, since we do not delete any memory blocks,
   37045             :  * but delete the valid objects.  
   37046             :  */
   37047             : void
   37048           0 : SgTypeCrayPointer::clearMemoryPool( )
   37049             :    {
   37050             :   // printf ("Inside of SgTypeCrayPointer::clearMemoryPool() \n");
   37051             : 
   37052           0 :      SgTypeCrayPointer* pointer = NULL, *tempPointer = NULL;
   37053           0 :      std::vector < unsigned char* > :: const_iterator block;
   37054           0 :      if ( SgTypeCrayPointer::pools.empty() == false )
   37055             :         {
   37056           0 :           block = SgTypeCrayPointer::pools.begin() ;
   37057           0 :           SgTypeCrayPointer::next_node = (SgTypeCrayPointer*) (*block);
   37058             : 
   37059           0 :           while ( block != SgTypeCrayPointer::pools.end() )
   37060             :              {
   37061           0 :                pointer = (SgTypeCrayPointer*) (*block);
   37062           0 :                if ( tempPointer != NULL )
   37063             :                   {
   37064           0 :                     tempPointer->set_freepointer(pointer);
   37065             :                   }
   37066           0 :                for (unsigned i = 0; i < SgTypeCrayPointer::pool_size - 1; ++i)
   37067             :                   {
   37068           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   37069             :                   }
   37070           0 :                 pointer[SgTypeCrayPointer::pool_size-1].set_freepointer(NULL);
   37071           0 :                 tempPointer = &(pointer[SgTypeCrayPointer::pool_size-1]);
   37072           0 :                 ++block;
   37073             :              }
   37074             :         }
   37075           0 :    }
   37076             : 
   37077           5 : void SgTypeCrayPointer::deleteMemoryPool() {
   37078           5 :   for (auto p: SgTypeCrayPointer::pools) {
   37079           0 :     ROSE_FREE(p);
   37080             :   }
   37081           5 :   SgTypeCrayPointer::next_node = nullptr;
   37082           5 :   SgTypeCrayPointer::pools.clear();
   37083           5 : }
   37084             : 
   37085             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   37086             : //                 reading multiple binary files to for a single AST.
   37087             : /////////// new version ////////////////////////////////
   37088             : //############################################################################
   37089             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   37090             : void
   37091           2 : SgTypeCrayPointer::extendMemoryPoolForFileIO( )
   37092             :   {
   37093           2 :     size_t blockIndex = SgTypeCrayPointer::pools.size();
   37094           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeCrayPointer) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeCrayPointer);
   37095             : 
   37096           2 :     while ( (blockIndex * SgTypeCrayPointer::pool_size) < newPoolSize)
   37097             :       {
   37098             : #if ROSE_ALLOC_TRACE
   37099             :         if (blockIndex > 0) {
   37100             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeCrayPointer) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeCrayPointer) = %" PRIuPTR " SgTypeCrayPointer::pool_size = %d \n",
   37101             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeCrayPointer),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeCrayPointer),SgTypeCrayPointer::pool_size);
   37102             :         }
   37103             : #endif
   37104             : 
   37105           0 :         SgTypeCrayPointer * pointer = (SgTypeCrayPointer*) ROSE_MALLOC ( SgTypeCrayPointer::pool_size * sizeof(SgTypeCrayPointer) );
   37106           0 :         assert( pointer != NULL );
   37107             : #if ROSE_ALLOC_MEMSET == 1
   37108             :         memset(pointer, 0x00, SgTypeCrayPointer::pool_size * sizeof(SgTypeCrayPointer));
   37109             : #elif ROSE_ALLOC_MEMSET == 2
   37110             :         memset(pointer, 0xCC, SgTypeCrayPointer::pool_size * sizeof(SgTypeCrayPointer));
   37111             : #endif
   37112           0 :         SgTypeCrayPointer::pools.push_back( (unsigned char*)(pointer) );
   37113           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeCrayPointer::pool_size * sizeof(SgTypeCrayPointer), V_SgTypeCrayPointer ) );
   37114             : 
   37115           0 :         if ( SgTypeCrayPointer::next_node != NULL ) {
   37116           0 :           if ( blockIndex > 0 ) {
   37117           0 :             SgTypeCrayPointer * blkptr = (SgTypeCrayPointer*)(SgTypeCrayPointer::pools[blockIndex-1]);
   37118           0 :             blkptr[ SgTypeCrayPointer::pool_size - 1 ].set_freepointer(pointer);
   37119             :           }
   37120             :         } else {
   37121           0 :           SgTypeCrayPointer::next_node = pointer;
   37122             :         }
   37123             : 
   37124           0 :         for (unsigned i = 0; i < SgTypeCrayPointer::pool_size-1; ++i)
   37125             :            {
   37126           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   37127             :            }
   37128           0 :         pointer[ SgTypeCrayPointer::pool_size -1 ].set_freepointer(NULL);
   37129             : 
   37130           0 :         blockIndex++;
   37131             :       }
   37132           2 :   }
   37133             : 
   37134             : //############################################################################
   37135             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   37136             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   37137             :  * not compressed. However, that stuff is not yet implemented! 
   37138             :  */
   37139             : unsigned long
   37140           0 : SgTypeCrayPointer::getNumberOfLastValidPointer()
   37141             :    {
   37142           0 :       SgTypeCrayPointer* testPointer = (SgTypeCrayPointer*)(SgTypeCrayPointer::pools.back());
   37143           0 :       unsigned long localIndex = SgTypeCrayPointer::pool_size - 1;
   37144           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   37145             :          {
   37146           0 :            localIndex--;
   37147             :          }
   37148           0 :       return (localIndex + SgTypeCrayPointer::pool_size * (SgTypeCrayPointer::pools.size()-1));
   37149             :    }
   37150             : 
   37151             : //############################################################################
   37152             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   37153             :  * memory pool and initializes the data member in class SgTypeCrayPointerStroageClass
   37154             :  * from its counterpart of SgTypeCrayPointer. The return value is just for checking, 
   37155             :  * that the whole StorageClassArray is initialized!
   37156             :  */
   37157             : unsigned long
   37158           0 : SgTypeCrayPointer::initializeStorageClassArray( SgTypeCrayPointerStorageClass *storageArray )
   37159             :    {
   37160           0 :      unsigned long storageCounter = 0;
   37161           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeCrayPointer::pools.begin();
   37162           0 :      SgTypeCrayPointer* pointer = NULL;
   37163           0 :      while ( block != SgTypeCrayPointer::pools.end() ) {
   37164           0 :           pointer = (SgTypeCrayPointer*) (*block);
   37165           0 :           for ( unsigned i = 0; i < SgTypeCrayPointer::pool_size; ++i ) {
   37166           0 :                if ( pointer->get_freepointer() != NULL ) {
   37167           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   37168           0 :                  storageArray++;
   37169           0 :                  storageCounter++;
   37170             :                }
   37171           0 :                pointer++;
   37172             :              }
   37173           0 :            block++;
   37174             :         }
   37175           0 :      return storageCounter;
   37176             :    }
   37177             : 
   37178             : /* #line 37179 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   37179             : 
   37180             : 
   37181             : 
   37182             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   37183             : 
   37184             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   37185             : 
   37186             : //############################################################################
   37187             : /* JH (02/02/2006) Constructor of the IR node SgTypeLabel that takes its 
   37188             :  * corresponding StorageClass as parameter
   37189             :  */
   37190           0 : SgTypeLabel :: SgTypeLabel ( const SgTypeLabelStorageClass& storageSource )   : SgType (storageSource)
   37191             :    {
   37192             : 
   37193             : 
   37194             : /* #line 37195 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   37195             : 
   37196           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   37197           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
   37198             : 
   37199             : 
   37200             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   37201             : 
   37202             : 
   37203           0 :    }
   37204             : 
   37205             : //############################################################################
   37206             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   37207             :  * within the working AST. 
   37208             :  */
   37209           0 : SgTypeLabel * SgTypeLabel::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   37210           0 :      SgTypeLabel* returnPointer = NULL;
   37211           0 :      if ( globalIndex != 0 )
   37212             :         {
   37213             : 
   37214             : #if FILE_IO_EXTRA_CHECK
   37215           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeLabel ) ) <= globalIndex ) ;
   37216           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeLabel + 1 ) ) );
   37217             : #endif
   37218           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeLabel )  
   37219           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeLabel );
   37220           0 :           unsigned long positionInPool = localIndex % SgTypeLabel::pool_size;
   37221           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeLabel::pool_size;
   37222             : 
   37223             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   37224             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   37225             : 
   37226           0 :           returnPointer = &( ( (SgTypeLabel*)(SgTypeLabel::pools[memoryBlock]) ) [positionInPool]) ;
   37227             : 
   37228           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   37229             :         }
   37230           0 :      return returnPointer ;
   37231             :    }
   37232             : 
   37233             : //############################################################################
   37234             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   37235             :   for the AST with the index astIndex
   37236             : */
   37237           0 : SgTypeLabel * SgTypeLabel::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   37238           0 :      SgTypeLabel* returnPointer = NULL;
   37239           0 :      if ( globalIndex != 0 )
   37240             :         {
   37241             : 
   37242             : #if FILE_IO_EXTRA_CHECK
   37243           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeLabel ) ) <= globalIndex ) ;
   37244           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeLabel + 1 ) ) );
   37245             : #endif
   37246           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeLabel )
   37247           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeLabel );
   37248           0 :           unsigned long positionInPool = localIndex % SgTypeLabel::pool_size ;
   37249           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeLabel::pool_size ;
   37250             : 
   37251             : #if FILE_IO_EXTRA_CHECK
   37252             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   37253             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   37254             : #endif
   37255             : 
   37256           0 :           returnPointer = &( ( (SgTypeLabel*)(SgTypeLabel::pools[memoryBlock]) ) [positionInPool]) ;
   37257             : 
   37258             : #if FILE_IO_EXTRA_CHECK
   37259           0 :           assert ( returnPointer != NULL ) ;
   37260             : #endif
   37261             :         }
   37262           0 :      return returnPointer ;
   37263             :    }
   37264             : 
   37265             : //############################################################################
   37266             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   37267             :  * pool size! We set for every valid object in the memory pool the freepointer
   37268             :  * to the global index and increase the global index afterwards. For all the 
   37269             :  * invalid objects (means address ranges within the memory pool that were not
   37270             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   37271             :  * distinguish valid from invalid objects! 
   37272             :  */
   37273             : unsigned long
   37274           5 : SgTypeLabel::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   37275             :    {
   37276           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   37277           5 :      SgTypeLabel* pointer = NULL;
   37278           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   37279           5 :      std::vector < unsigned char* > :: const_iterator block;
   37280           5 :      for ( block = SgTypeLabel::pools.begin(); block != SgTypeLabel::pools.end() ; ++block )
   37281             :         {
   37282           0 :           pointer = (SgTypeLabel*)(*block);
   37283           0 :           for (unsigned i = 0; i < SgTypeLabel::pool_size; ++i )
   37284             :              {
   37285             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   37286             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   37287             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   37288             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   37289             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   37290             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   37291             :             // properly; so this will have to be checked next.
   37292             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   37293             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   37294           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   37295             :                   {
   37296           0 :                     pointer[i].set_freepointer((SgTypeLabel*)(globalIndex));
   37297           0 :                     globalIndex++;
   37298             :                   }
   37299             :                else
   37300             :                   {
   37301           0 :                     pointer[i].set_freepointer(NULL);
   37302             :                   }
   37303             :               }
   37304             :         }
   37305           5 :      return globalIndex;
   37306             :    }
   37307             : 
   37308             : //############################################################################
   37309             : // JH (01/14/2006)
   37310             : void
   37311           5 : SgTypeLabel::resetValidFreepointers( )
   37312             :    {
   37313           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   37314           5 :      SgTypeLabel* pointer = NULL;
   37315           5 :      std::vector < unsigned char* > :: const_iterator block;
   37316           5 :      SgTypeLabel* pointerOfLinkedList = NULL;
   37317           5 :      for ( block = SgTypeLabel::pools.begin(); block != SgTypeLabel::pools.end() ; ++block )
   37318             :         {
   37319           0 :           pointer = (SgTypeLabel*)(*block);
   37320           0 :           for (unsigned i = 0; i < SgTypeLabel::pool_size; ++i )
   37321             :              {
   37322             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   37323             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   37324             :             // memory blocks!.
   37325           0 :                if ( pointer[i].get_freepointer() != NULL )
   37326             :                   {
   37327           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   37328             :                   }
   37329             :                else
   37330             :                   {
   37331           0 :                     if ( pointerOfLinkedList == NULL )
   37332             :                        {
   37333           0 :                          SgTypeLabel::next_node = &(pointer[i]);
   37334             :                        }
   37335             :                     else
   37336             :                        {
   37337             :                       // printf ("In SgTypeLabel::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   37338           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   37339             :                        }
   37340             :                     pointerOfLinkedList = &(pointer[i]);
   37341             :                   }
   37342             :               }
   37343             :         }
   37344             : 
   37345           5 :      if ( pointerOfLinkedList != NULL )
   37346             :         {
   37347             :        // printf ("In SgTypeLabel::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   37348           0 :           pointerOfLinkedList->set_freepointer(NULL);
   37349             :        // DQ (6/6/2010): Temporary debugging...
   37350             :        //   ROSE_ASSERT(false);
   37351             :         }
   37352             : 
   37353           5 :      return ;
   37354             :    }
   37355             : 
   37356             : //############################################################################
   37357             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   37358             :  * within the memory pool and resets the freepointers, in order to achieve a 
   37359             :  * linked list, that has no jumps and starts at the beginning! This function 
   37360             :  * does not extend the memory pool, since we do not delete any memory blocks,
   37361             :  * but delete the valid objects.  
   37362             :  */
   37363             : void
   37364           0 : SgTypeLabel::clearMemoryPool( )
   37365             :    {
   37366             :   // printf ("Inside of SgTypeLabel::clearMemoryPool() \n");
   37367             : 
   37368           0 :      SgTypeLabel* pointer = NULL, *tempPointer = NULL;
   37369           0 :      std::vector < unsigned char* > :: const_iterator block;
   37370           0 :      if ( SgTypeLabel::pools.empty() == false )
   37371             :         {
   37372           0 :           block = SgTypeLabel::pools.begin() ;
   37373           0 :           SgTypeLabel::next_node = (SgTypeLabel*) (*block);
   37374             : 
   37375           0 :           while ( block != SgTypeLabel::pools.end() )
   37376             :              {
   37377           0 :                pointer = (SgTypeLabel*) (*block);
   37378           0 :                if ( tempPointer != NULL )
   37379             :                   {
   37380           0 :                     tempPointer->set_freepointer(pointer);
   37381             :                   }
   37382           0 :                for (unsigned i = 0; i < SgTypeLabel::pool_size - 1; ++i)
   37383             :                   {
   37384           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   37385             :                   }
   37386           0 :                 pointer[SgTypeLabel::pool_size-1].set_freepointer(NULL);
   37387           0 :                 tempPointer = &(pointer[SgTypeLabel::pool_size-1]);
   37388           0 :                 ++block;
   37389             :              }
   37390             :         }
   37391           0 :    }
   37392             : 
   37393           5 : void SgTypeLabel::deleteMemoryPool() {
   37394           5 :   for (auto p: SgTypeLabel::pools) {
   37395           0 :     ROSE_FREE(p);
   37396             :   }
   37397           5 :   SgTypeLabel::next_node = nullptr;
   37398           5 :   SgTypeLabel::pools.clear();
   37399           5 : }
   37400             : 
   37401             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   37402             : //                 reading multiple binary files to for a single AST.
   37403             : /////////// new version ////////////////////////////////
   37404             : //############################################################################
   37405             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   37406             : void
   37407           2 : SgTypeLabel::extendMemoryPoolForFileIO( )
   37408             :   {
   37409           2 :     size_t blockIndex = SgTypeLabel::pools.size();
   37410           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLabel) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLabel);
   37411             : 
   37412           2 :     while ( (blockIndex * SgTypeLabel::pool_size) < newPoolSize)
   37413             :       {
   37414             : #if ROSE_ALLOC_TRACE
   37415             :         if (blockIndex > 0) {
   37416             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLabel) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLabel) = %" PRIuPTR " SgTypeLabel::pool_size = %d \n",
   37417             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeLabel),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeLabel),SgTypeLabel::pool_size);
   37418             :         }
   37419             : #endif
   37420             : 
   37421           0 :         SgTypeLabel * pointer = (SgTypeLabel*) ROSE_MALLOC ( SgTypeLabel::pool_size * sizeof(SgTypeLabel) );
   37422           0 :         assert( pointer != NULL );
   37423             : #if ROSE_ALLOC_MEMSET == 1
   37424             :         memset(pointer, 0x00, SgTypeLabel::pool_size * sizeof(SgTypeLabel));
   37425             : #elif ROSE_ALLOC_MEMSET == 2
   37426             :         memset(pointer, 0xCC, SgTypeLabel::pool_size * sizeof(SgTypeLabel));
   37427             : #endif
   37428           0 :         SgTypeLabel::pools.push_back( (unsigned char*)(pointer) );
   37429           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeLabel::pool_size * sizeof(SgTypeLabel), V_SgTypeLabel ) );
   37430             : 
   37431           0 :         if ( SgTypeLabel::next_node != NULL ) {
   37432           0 :           if ( blockIndex > 0 ) {
   37433           0 :             SgTypeLabel * blkptr = (SgTypeLabel*)(SgTypeLabel::pools[blockIndex-1]);
   37434           0 :             blkptr[ SgTypeLabel::pool_size - 1 ].set_freepointer(pointer);
   37435             :           }
   37436             :         } else {
   37437           0 :           SgTypeLabel::next_node = pointer;
   37438             :         }
   37439             : 
   37440           0 :         for (unsigned i = 0; i < SgTypeLabel::pool_size-1; ++i)
   37441             :            {
   37442           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   37443             :            }
   37444           0 :         pointer[ SgTypeLabel::pool_size -1 ].set_freepointer(NULL);
   37445             : 
   37446           0 :         blockIndex++;
   37447             :       }
   37448           2 :   }
   37449             : 
   37450             : //############################################################################
   37451             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   37452             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   37453             :  * not compressed. However, that stuff is not yet implemented! 
   37454             :  */
   37455             : unsigned long
   37456           0 : SgTypeLabel::getNumberOfLastValidPointer()
   37457             :    {
   37458           0 :       SgTypeLabel* testPointer = (SgTypeLabel*)(SgTypeLabel::pools.back());
   37459           0 :       unsigned long localIndex = SgTypeLabel::pool_size - 1;
   37460           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   37461             :          {
   37462           0 :            localIndex--;
   37463             :          }
   37464           0 :       return (localIndex + SgTypeLabel::pool_size * (SgTypeLabel::pools.size()-1));
   37465             :    }
   37466             : 
   37467             : //############################################################################
   37468             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   37469             :  * memory pool and initializes the data member in class SgTypeLabelStroageClass
   37470             :  * from its counterpart of SgTypeLabel. The return value is just for checking, 
   37471             :  * that the whole StorageClassArray is initialized!
   37472             :  */
   37473             : unsigned long
   37474           0 : SgTypeLabel::initializeStorageClassArray( SgTypeLabelStorageClass *storageArray )
   37475             :    {
   37476           0 :      unsigned long storageCounter = 0;
   37477           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeLabel::pools.begin();
   37478           0 :      SgTypeLabel* pointer = NULL;
   37479           0 :      while ( block != SgTypeLabel::pools.end() ) {
   37480           0 :           pointer = (SgTypeLabel*) (*block);
   37481           0 :           for ( unsigned i = 0; i < SgTypeLabel::pool_size; ++i ) {
   37482           0 :                if ( pointer->get_freepointer() != NULL ) {
   37483           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   37484           0 :                  storageArray++;
   37485           0 :                  storageCounter++;
   37486             :                }
   37487           0 :                pointer++;
   37488             :              }
   37489           0 :            block++;
   37490             :         }
   37491           0 :      return storageCounter;
   37492             :    }
   37493             : 
   37494             : /* #line 37495 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   37495             : 
   37496             : 
   37497             : 
   37498             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   37499             : 
   37500             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   37501             : 
   37502             : //############################################################################
   37503             : /* JH (02/02/2006) Constructor of the IR node SgRvalueReferenceType that takes its 
   37504             :  * corresponding StorageClass as parameter
   37505             :  */
   37506         182 : SgRvalueReferenceType :: SgRvalueReferenceType ( const SgRvalueReferenceTypeStorageClass& storageSource )   : SgType (storageSource)
   37507             :    {
   37508             : 
   37509             : 
   37510             : /* #line 37511 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   37511             : 
   37512         182 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   37513         182 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   37514             : 
   37515             : 
   37516             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   37517             : 
   37518             : 
   37519         182 :    }
   37520             : 
   37521             : //############################################################################
   37522             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   37523             :  * within the working AST. 
   37524             :  */
   37525        1232 : SgRvalueReferenceType * SgRvalueReferenceType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   37526        1232 :      SgRvalueReferenceType* returnPointer = NULL;
   37527        1232 :      if ( globalIndex != 0 )
   37528             :         {
   37529             : 
   37530             : #if FILE_IO_EXTRA_CHECK
   37531        1232 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRvalueReferenceType ) ) <= globalIndex ) ;
   37532        1232 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRvalueReferenceType + 1 ) ) );
   37533             : #endif
   37534        1232 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRvalueReferenceType )  
   37535        1232 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRvalueReferenceType );
   37536        1232 :           unsigned long positionInPool = localIndex % SgRvalueReferenceType::pool_size;
   37537        1232 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRvalueReferenceType::pool_size;
   37538             : 
   37539             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   37540             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   37541             : 
   37542        1232 :           returnPointer = &( ( (SgRvalueReferenceType*)(SgRvalueReferenceType::pools[memoryBlock]) ) [positionInPool]) ;
   37543             : 
   37544        1232 :           ROSE_ASSERT( returnPointer != NULL ) ;
   37545             :         }
   37546        1232 :      return returnPointer ;
   37547             :    }
   37548             : 
   37549             : //############################################################################
   37550             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   37551             :   for the AST with the index astIndex
   37552             : */
   37553           0 : SgRvalueReferenceType * SgRvalueReferenceType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   37554           0 :      SgRvalueReferenceType* returnPointer = NULL;
   37555           0 :      if ( globalIndex != 0 )
   37556             :         {
   37557             : 
   37558             : #if FILE_IO_EXTRA_CHECK
   37559           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRvalueReferenceType ) ) <= globalIndex ) ;
   37560           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRvalueReferenceType + 1 ) ) );
   37561             : #endif
   37562           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRvalueReferenceType )
   37563           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRvalueReferenceType );
   37564           0 :           unsigned long positionInPool = localIndex % SgRvalueReferenceType::pool_size ;
   37565           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRvalueReferenceType::pool_size ;
   37566             : 
   37567             : #if FILE_IO_EXTRA_CHECK
   37568             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   37569             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   37570             : #endif
   37571             : 
   37572           0 :           returnPointer = &( ( (SgRvalueReferenceType*)(SgRvalueReferenceType::pools[memoryBlock]) ) [positionInPool]) ;
   37573             : 
   37574             : #if FILE_IO_EXTRA_CHECK
   37575           0 :           assert ( returnPointer != NULL ) ;
   37576             : #endif
   37577             :         }
   37578           0 :      return returnPointer ;
   37579             :    }
   37580             : 
   37581             : //############################################################################
   37582             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   37583             :  * pool size! We set for every valid object in the memory pool the freepointer
   37584             :  * to the global index and increase the global index afterwards. For all the 
   37585             :  * invalid objects (means address ranges within the memory pool that were not
   37586             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   37587             :  * distinguish valid from invalid objects! 
   37588             :  */
   37589             : unsigned long
   37590           5 : SgRvalueReferenceType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   37591             :    {
   37592           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   37593           5 :      SgRvalueReferenceType* pointer = NULL;
   37594           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   37595           5 :      std::vector < unsigned char* > :: const_iterator block;
   37596           6 :      for ( block = SgRvalueReferenceType::pools.begin(); block != SgRvalueReferenceType::pools.end() ; ++block )
   37597             :         {
   37598           1 :           pointer = (SgRvalueReferenceType*)(*block);
   37599        2001 :           for (unsigned i = 0; i < SgRvalueReferenceType::pool_size; ++i )
   37600             :              {
   37601             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   37602             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   37603             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   37604             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   37605             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   37606             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   37607             :             // properly; so this will have to be checked next.
   37608             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   37609             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   37610        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   37611             :                   {
   37612         182 :                     pointer[i].set_freepointer((SgRvalueReferenceType*)(globalIndex));
   37613         182 :                     globalIndex++;
   37614             :                   }
   37615             :                else
   37616             :                   {
   37617        1818 :                     pointer[i].set_freepointer(NULL);
   37618             :                   }
   37619             :               }
   37620             :         }
   37621           5 :      return globalIndex;
   37622             :    }
   37623             : 
   37624             : //############################################################################
   37625             : // JH (01/14/2006)
   37626             : void
   37627           5 : SgRvalueReferenceType::resetValidFreepointers( )
   37628             :    {
   37629           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   37630           5 :      SgRvalueReferenceType* pointer = NULL;
   37631           5 :      std::vector < unsigned char* > :: const_iterator block;
   37632           5 :      SgRvalueReferenceType* pointerOfLinkedList = NULL;
   37633           6 :      for ( block = SgRvalueReferenceType::pools.begin(); block != SgRvalueReferenceType::pools.end() ; ++block )
   37634             :         {
   37635           1 :           pointer = (SgRvalueReferenceType*)(*block);
   37636        2001 :           for (unsigned i = 0; i < SgRvalueReferenceType::pool_size; ++i )
   37637             :              {
   37638             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   37639             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   37640             :             // memory blocks!.
   37641        2000 :                if ( pointer[i].get_freepointer() != NULL )
   37642             :                   {
   37643         182 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   37644             :                   }
   37645             :                else
   37646             :                   {
   37647        1818 :                     if ( pointerOfLinkedList == NULL )
   37648             :                        {
   37649           1 :                          SgRvalueReferenceType::next_node = &(pointer[i]);
   37650             :                        }
   37651             :                     else
   37652             :                        {
   37653             :                       // printf ("In SgRvalueReferenceType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   37654        1817 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   37655             :                        }
   37656             :                     pointerOfLinkedList = &(pointer[i]);
   37657             :                   }
   37658             :               }
   37659             :         }
   37660             : 
   37661           5 :      if ( pointerOfLinkedList != NULL )
   37662             :         {
   37663             :        // printf ("In SgRvalueReferenceType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   37664           1 :           pointerOfLinkedList->set_freepointer(NULL);
   37665             :        // DQ (6/6/2010): Temporary debugging...
   37666             :        //   ROSE_ASSERT(false);
   37667             :         }
   37668             : 
   37669           5 :      return ;
   37670             :    }
   37671             : 
   37672             : //############################################################################
   37673             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   37674             :  * within the memory pool and resets the freepointers, in order to achieve a 
   37675             :  * linked list, that has no jumps and starts at the beginning! This function 
   37676             :  * does not extend the memory pool, since we do not delete any memory blocks,
   37677             :  * but delete the valid objects.  
   37678             :  */
   37679             : void
   37680           0 : SgRvalueReferenceType::clearMemoryPool( )
   37681             :    {
   37682             :   // printf ("Inside of SgRvalueReferenceType::clearMemoryPool() \n");
   37683             : 
   37684           0 :      SgRvalueReferenceType* pointer = NULL, *tempPointer = NULL;
   37685           0 :      std::vector < unsigned char* > :: const_iterator block;
   37686           0 :      if ( SgRvalueReferenceType::pools.empty() == false )
   37687             :         {
   37688           0 :           block = SgRvalueReferenceType::pools.begin() ;
   37689           0 :           SgRvalueReferenceType::next_node = (SgRvalueReferenceType*) (*block);
   37690             : 
   37691           0 :           while ( block != SgRvalueReferenceType::pools.end() )
   37692             :              {
   37693           0 :                pointer = (SgRvalueReferenceType*) (*block);
   37694           0 :                if ( tempPointer != NULL )
   37695             :                   {
   37696           0 :                     tempPointer->set_freepointer(pointer);
   37697             :                   }
   37698           0 :                for (unsigned i = 0; i < SgRvalueReferenceType::pool_size - 1; ++i)
   37699             :                   {
   37700           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   37701             :                   }
   37702           0 :                 pointer[SgRvalueReferenceType::pool_size-1].set_freepointer(NULL);
   37703           0 :                 tempPointer = &(pointer[SgRvalueReferenceType::pool_size-1]);
   37704           0 :                 ++block;
   37705             :              }
   37706             :         }
   37707           0 :    }
   37708             : 
   37709           5 : void SgRvalueReferenceType::deleteMemoryPool() {
   37710           7 :   for (auto p: SgRvalueReferenceType::pools) {
   37711           2 :     ROSE_FREE(p);
   37712             :   }
   37713           5 :   SgRvalueReferenceType::next_node = nullptr;
   37714           5 :   SgRvalueReferenceType::pools.clear();
   37715           5 : }
   37716             : 
   37717             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   37718             : //                 reading multiple binary files to for a single AST.
   37719             : /////////// new version ////////////////////////////////
   37720             : //############################################################################
   37721             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   37722             : void
   37723           2 : SgRvalueReferenceType::extendMemoryPoolForFileIO( )
   37724             :   {
   37725           2 :     size_t blockIndex = SgRvalueReferenceType::pools.size();
   37726           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRvalueReferenceType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRvalueReferenceType);
   37727             : 
   37728           3 :     while ( (blockIndex * SgRvalueReferenceType::pool_size) < newPoolSize)
   37729             :       {
   37730             : #if ROSE_ALLOC_TRACE
   37731             :         if (blockIndex > 0) {
   37732             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRvalueReferenceType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRvalueReferenceType) = %" PRIuPTR " SgRvalueReferenceType::pool_size = %d \n",
   37733             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRvalueReferenceType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRvalueReferenceType),SgRvalueReferenceType::pool_size);
   37734             :         }
   37735             : #endif
   37736             : 
   37737           1 :         SgRvalueReferenceType * pointer = (SgRvalueReferenceType*) ROSE_MALLOC ( SgRvalueReferenceType::pool_size * sizeof(SgRvalueReferenceType) );
   37738           1 :         assert( pointer != NULL );
   37739             : #if ROSE_ALLOC_MEMSET == 1
   37740             :         memset(pointer, 0x00, SgRvalueReferenceType::pool_size * sizeof(SgRvalueReferenceType));
   37741             : #elif ROSE_ALLOC_MEMSET == 2
   37742             :         memset(pointer, 0xCC, SgRvalueReferenceType::pool_size * sizeof(SgRvalueReferenceType));
   37743             : #endif
   37744           1 :         SgRvalueReferenceType::pools.push_back( (unsigned char*)(pointer) );
   37745           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRvalueReferenceType::pool_size * sizeof(SgRvalueReferenceType), V_SgRvalueReferenceType ) );
   37746             : 
   37747           1 :         if ( SgRvalueReferenceType::next_node != NULL ) {
   37748           0 :           if ( blockIndex > 0 ) {
   37749           0 :             SgRvalueReferenceType * blkptr = (SgRvalueReferenceType*)(SgRvalueReferenceType::pools[blockIndex-1]);
   37750           0 :             blkptr[ SgRvalueReferenceType::pool_size - 1 ].set_freepointer(pointer);
   37751             :           }
   37752             :         } else {
   37753           1 :           SgRvalueReferenceType::next_node = pointer;
   37754             :         }
   37755             : 
   37756        2000 :         for (unsigned i = 0; i < SgRvalueReferenceType::pool_size-1; ++i)
   37757             :            {
   37758        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   37759             :            }
   37760           1 :         pointer[ SgRvalueReferenceType::pool_size -1 ].set_freepointer(NULL);
   37761             : 
   37762           1 :         blockIndex++;
   37763             :       }
   37764           2 :   }
   37765             : 
   37766             : //############################################################################
   37767             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   37768             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   37769             :  * not compressed. However, that stuff is not yet implemented! 
   37770             :  */
   37771             : unsigned long
   37772           0 : SgRvalueReferenceType::getNumberOfLastValidPointer()
   37773             :    {
   37774           0 :       SgRvalueReferenceType* testPointer = (SgRvalueReferenceType*)(SgRvalueReferenceType::pools.back());
   37775           0 :       unsigned long localIndex = SgRvalueReferenceType::pool_size - 1;
   37776           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   37777             :          {
   37778           0 :            localIndex--;
   37779             :          }
   37780           0 :       return (localIndex + SgRvalueReferenceType::pool_size * (SgRvalueReferenceType::pools.size()-1));
   37781             :    }
   37782             : 
   37783             : //############################################################################
   37784             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   37785             :  * memory pool and initializes the data member in class SgRvalueReferenceTypeStroageClass
   37786             :  * from its counterpart of SgRvalueReferenceType. The return value is just for checking, 
   37787             :  * that the whole StorageClassArray is initialized!
   37788             :  */
   37789             : unsigned long
   37790           1 : SgRvalueReferenceType::initializeStorageClassArray( SgRvalueReferenceTypeStorageClass *storageArray )
   37791             :    {
   37792           1 :      unsigned long storageCounter = 0;
   37793           1 :      std::vector < unsigned char* > :: const_iterator block = SgRvalueReferenceType::pools.begin();
   37794           1 :      SgRvalueReferenceType* pointer = NULL;
   37795           2 :      while ( block != SgRvalueReferenceType::pools.end() ) {
   37796           1 :           pointer = (SgRvalueReferenceType*) (*block);
   37797        2001 :           for ( unsigned i = 0; i < SgRvalueReferenceType::pool_size; ++i ) {
   37798        2000 :                if ( pointer->get_freepointer() != NULL ) {
   37799         182 :                  storageArray->pickOutIRNodeData (pointer) ;
   37800         182 :                  storageArray++;
   37801         182 :                  storageCounter++;
   37802             :                }
   37803        2000 :                pointer++;
   37804             :              }
   37805           1 :            block++;
   37806             :         }
   37807           1 :      return storageCounter;
   37808             :    }
   37809             : 
   37810             : /* #line 37811 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   37811             : 
   37812             : 
   37813             : 
   37814             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   37815             : 
   37816             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   37817             : 
   37818             : //############################################################################
   37819             : /* JH (02/02/2006) Constructor of the IR node SgTypeNullptr that takes its 
   37820             :  * corresponding StorageClass as parameter
   37821             :  */
   37822           1 : SgTypeNullptr :: SgTypeNullptr ( const SgTypeNullptrStorageClass& storageSource )   : SgType (storageSource)
   37823             :    {
   37824             : 
   37825             : 
   37826             : /* #line 37827 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   37827             : 
   37828           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   37829             : 
   37830             : 
   37831             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   37832             : 
   37833             : 
   37834           1 :    }
   37835             : 
   37836             : //############################################################################
   37837             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   37838             :  * within the working AST. 
   37839             :  */
   37840           2 : SgTypeNullptr * SgTypeNullptr::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   37841           2 :      SgTypeNullptr* returnPointer = NULL;
   37842           2 :      if ( globalIndex != 0 )
   37843             :         {
   37844             : 
   37845             : #if FILE_IO_EXTRA_CHECK
   37846           2 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeNullptr ) ) <= globalIndex ) ;
   37847           2 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeNullptr + 1 ) ) );
   37848             : #endif
   37849           2 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeNullptr )  
   37850           2 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeNullptr );
   37851           2 :           unsigned long positionInPool = localIndex % SgTypeNullptr::pool_size;
   37852           2 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeNullptr::pool_size;
   37853             : 
   37854             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   37855             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   37856             : 
   37857           2 :           returnPointer = &( ( (SgTypeNullptr*)(SgTypeNullptr::pools[memoryBlock]) ) [positionInPool]) ;
   37858             : 
   37859           2 :           ROSE_ASSERT( returnPointer != NULL ) ;
   37860             :         }
   37861           2 :      return returnPointer ;
   37862             :    }
   37863             : 
   37864             : //############################################################################
   37865             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   37866             :   for the AST with the index astIndex
   37867             : */
   37868           0 : SgTypeNullptr * SgTypeNullptr::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   37869           0 :      SgTypeNullptr* returnPointer = NULL;
   37870           0 :      if ( globalIndex != 0 )
   37871             :         {
   37872             : 
   37873             : #if FILE_IO_EXTRA_CHECK
   37874           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeNullptr ) ) <= globalIndex ) ;
   37875           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeNullptr + 1 ) ) );
   37876             : #endif
   37877           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeNullptr )
   37878           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeNullptr );
   37879           0 :           unsigned long positionInPool = localIndex % SgTypeNullptr::pool_size ;
   37880           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeNullptr::pool_size ;
   37881             : 
   37882             : #if FILE_IO_EXTRA_CHECK
   37883             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   37884             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   37885             : #endif
   37886             : 
   37887           0 :           returnPointer = &( ( (SgTypeNullptr*)(SgTypeNullptr::pools[memoryBlock]) ) [positionInPool]) ;
   37888             : 
   37889             : #if FILE_IO_EXTRA_CHECK
   37890           0 :           assert ( returnPointer != NULL ) ;
   37891             : #endif
   37892             :         }
   37893           0 :      return returnPointer ;
   37894             :    }
   37895             : 
   37896             : //############################################################################
   37897             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   37898             :  * pool size! We set for every valid object in the memory pool the freepointer
   37899             :  * to the global index and increase the global index afterwards. For all the 
   37900             :  * invalid objects (means address ranges within the memory pool that were not
   37901             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   37902             :  * distinguish valid from invalid objects! 
   37903             :  */
   37904             : unsigned long
   37905           5 : SgTypeNullptr::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   37906             :    {
   37907           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   37908           5 :      SgTypeNullptr* pointer = NULL;
   37909           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   37910           5 :      std::vector < unsigned char* > :: const_iterator block;
   37911           6 :      for ( block = SgTypeNullptr::pools.begin(); block != SgTypeNullptr::pools.end() ; ++block )
   37912             :         {
   37913           1 :           pointer = (SgTypeNullptr*)(*block);
   37914        2001 :           for (unsigned i = 0; i < SgTypeNullptr::pool_size; ++i )
   37915             :              {
   37916             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   37917             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   37918             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   37919             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   37920             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   37921             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   37922             :             // properly; so this will have to be checked next.
   37923             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   37924             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   37925        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   37926             :                   {
   37927           1 :                     pointer[i].set_freepointer((SgTypeNullptr*)(globalIndex));
   37928           1 :                     globalIndex++;
   37929             :                   }
   37930             :                else
   37931             :                   {
   37932        1999 :                     pointer[i].set_freepointer(NULL);
   37933             :                   }
   37934             :               }
   37935             :         }
   37936           5 :      return globalIndex;
   37937             :    }
   37938             : 
   37939             : //############################################################################
   37940             : // JH (01/14/2006)
   37941             : void
   37942           5 : SgTypeNullptr::resetValidFreepointers( )
   37943             :    {
   37944           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   37945           5 :      SgTypeNullptr* pointer = NULL;
   37946           5 :      std::vector < unsigned char* > :: const_iterator block;
   37947           5 :      SgTypeNullptr* pointerOfLinkedList = NULL;
   37948           6 :      for ( block = SgTypeNullptr::pools.begin(); block != SgTypeNullptr::pools.end() ; ++block )
   37949             :         {
   37950           1 :           pointer = (SgTypeNullptr*)(*block);
   37951        2001 :           for (unsigned i = 0; i < SgTypeNullptr::pool_size; ++i )
   37952             :              {
   37953             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   37954             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   37955             :             // memory blocks!.
   37956        2000 :                if ( pointer[i].get_freepointer() != NULL )
   37957             :                   {
   37958           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   37959             :                   }
   37960             :                else
   37961             :                   {
   37962        1999 :                     if ( pointerOfLinkedList == NULL )
   37963             :                        {
   37964           1 :                          SgTypeNullptr::next_node = &(pointer[i]);
   37965             :                        }
   37966             :                     else
   37967             :                        {
   37968             :                       // printf ("In SgTypeNullptr::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   37969        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   37970             :                        }
   37971             :                     pointerOfLinkedList = &(pointer[i]);
   37972             :                   }
   37973             :               }
   37974             :         }
   37975             : 
   37976           5 :      if ( pointerOfLinkedList != NULL )
   37977             :         {
   37978             :        // printf ("In SgTypeNullptr::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   37979           1 :           pointerOfLinkedList->set_freepointer(NULL);
   37980             :        // DQ (6/6/2010): Temporary debugging...
   37981             :        //   ROSE_ASSERT(false);
   37982             :         }
   37983             : 
   37984           5 :      return ;
   37985             :    }
   37986             : 
   37987             : //############################################################################
   37988             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   37989             :  * within the memory pool and resets the freepointers, in order to achieve a 
   37990             :  * linked list, that has no jumps and starts at the beginning! This function 
   37991             :  * does not extend the memory pool, since we do not delete any memory blocks,
   37992             :  * but delete the valid objects.  
   37993             :  */
   37994             : void
   37995           0 : SgTypeNullptr::clearMemoryPool( )
   37996             :    {
   37997             :   // printf ("Inside of SgTypeNullptr::clearMemoryPool() \n");
   37998             : 
   37999           0 :      SgTypeNullptr* pointer = NULL, *tempPointer = NULL;
   38000           0 :      std::vector < unsigned char* > :: const_iterator block;
   38001           0 :      if ( SgTypeNullptr::pools.empty() == false )
   38002             :         {
   38003           0 :           block = SgTypeNullptr::pools.begin() ;
   38004           0 :           SgTypeNullptr::next_node = (SgTypeNullptr*) (*block);
   38005             : 
   38006           0 :           while ( block != SgTypeNullptr::pools.end() )
   38007             :              {
   38008           0 :                pointer = (SgTypeNullptr*) (*block);
   38009           0 :                if ( tempPointer != NULL )
   38010             :                   {
   38011           0 :                     tempPointer->set_freepointer(pointer);
   38012             :                   }
   38013           0 :                for (unsigned i = 0; i < SgTypeNullptr::pool_size - 1; ++i)
   38014             :                   {
   38015           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   38016             :                   }
   38017           0 :                 pointer[SgTypeNullptr::pool_size-1].set_freepointer(NULL);
   38018           0 :                 tempPointer = &(pointer[SgTypeNullptr::pool_size-1]);
   38019           0 :                 ++block;
   38020             :              }
   38021             :         }
   38022           0 :    }
   38023             : 
   38024           5 : void SgTypeNullptr::deleteMemoryPool() {
   38025           7 :   for (auto p: SgTypeNullptr::pools) {
   38026           2 :     ROSE_FREE(p);
   38027             :   }
   38028           5 :   SgTypeNullptr::next_node = nullptr;
   38029           5 :   SgTypeNullptr::pools.clear();
   38030           5 : }
   38031             : 
   38032             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   38033             : //                 reading multiple binary files to for a single AST.
   38034             : /////////// new version ////////////////////////////////
   38035             : //############################################################################
   38036             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   38037             : void
   38038           2 : SgTypeNullptr::extendMemoryPoolForFileIO( )
   38039             :   {
   38040           2 :     size_t blockIndex = SgTypeNullptr::pools.size();
   38041           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeNullptr) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeNullptr);
   38042             : 
   38043           3 :     while ( (blockIndex * SgTypeNullptr::pool_size) < newPoolSize)
   38044             :       {
   38045             : #if ROSE_ALLOC_TRACE
   38046             :         if (blockIndex > 0) {
   38047             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeNullptr) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeNullptr) = %" PRIuPTR " SgTypeNullptr::pool_size = %d \n",
   38048             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeNullptr),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeNullptr),SgTypeNullptr::pool_size);
   38049             :         }
   38050             : #endif
   38051             : 
   38052           1 :         SgTypeNullptr * pointer = (SgTypeNullptr*) ROSE_MALLOC ( SgTypeNullptr::pool_size * sizeof(SgTypeNullptr) );
   38053           1 :         assert( pointer != NULL );
   38054             : #if ROSE_ALLOC_MEMSET == 1
   38055             :         memset(pointer, 0x00, SgTypeNullptr::pool_size * sizeof(SgTypeNullptr));
   38056             : #elif ROSE_ALLOC_MEMSET == 2
   38057             :         memset(pointer, 0xCC, SgTypeNullptr::pool_size * sizeof(SgTypeNullptr));
   38058             : #endif
   38059           1 :         SgTypeNullptr::pools.push_back( (unsigned char*)(pointer) );
   38060           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeNullptr::pool_size * sizeof(SgTypeNullptr), V_SgTypeNullptr ) );
   38061             : 
   38062           1 :         if ( SgTypeNullptr::next_node != NULL ) {
   38063           0 :           if ( blockIndex > 0 ) {
   38064           0 :             SgTypeNullptr * blkptr = (SgTypeNullptr*)(SgTypeNullptr::pools[blockIndex-1]);
   38065           0 :             blkptr[ SgTypeNullptr::pool_size - 1 ].set_freepointer(pointer);
   38066             :           }
   38067             :         } else {
   38068           1 :           SgTypeNullptr::next_node = pointer;
   38069             :         }
   38070             : 
   38071        2000 :         for (unsigned i = 0; i < SgTypeNullptr::pool_size-1; ++i)
   38072             :            {
   38073        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   38074             :            }
   38075           1 :         pointer[ SgTypeNullptr::pool_size -1 ].set_freepointer(NULL);
   38076             : 
   38077           1 :         blockIndex++;
   38078             :       }
   38079           2 :   }
   38080             : 
   38081             : //############################################################################
   38082             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   38083             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   38084             :  * not compressed. However, that stuff is not yet implemented! 
   38085             :  */
   38086             : unsigned long
   38087           0 : SgTypeNullptr::getNumberOfLastValidPointer()
   38088             :    {
   38089           0 :       SgTypeNullptr* testPointer = (SgTypeNullptr*)(SgTypeNullptr::pools.back());
   38090           0 :       unsigned long localIndex = SgTypeNullptr::pool_size - 1;
   38091           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   38092             :          {
   38093           0 :            localIndex--;
   38094             :          }
   38095           0 :       return (localIndex + SgTypeNullptr::pool_size * (SgTypeNullptr::pools.size()-1));
   38096             :    }
   38097             : 
   38098             : //############################################################################
   38099             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   38100             :  * memory pool and initializes the data member in class SgTypeNullptrStroageClass
   38101             :  * from its counterpart of SgTypeNullptr. The return value is just for checking, 
   38102             :  * that the whole StorageClassArray is initialized!
   38103             :  */
   38104             : unsigned long
   38105           1 : SgTypeNullptr::initializeStorageClassArray( SgTypeNullptrStorageClass *storageArray )
   38106             :    {
   38107           1 :      unsigned long storageCounter = 0;
   38108           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeNullptr::pools.begin();
   38109           1 :      SgTypeNullptr* pointer = NULL;
   38110           2 :      while ( block != SgTypeNullptr::pools.end() ) {
   38111           1 :           pointer = (SgTypeNullptr*) (*block);
   38112        2001 :           for ( unsigned i = 0; i < SgTypeNullptr::pool_size; ++i ) {
   38113        2000 :                if ( pointer->get_freepointer() != NULL ) {
   38114           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   38115           1 :                  storageArray++;
   38116           1 :                  storageCounter++;
   38117             :                }
   38118        2000 :                pointer++;
   38119             :              }
   38120           1 :            block++;
   38121             :         }
   38122           1 :      return storageCounter;
   38123             :    }
   38124             : 
   38125             : /* #line 38126 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   38126             : 
   38127             : 
   38128             : 
   38129             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   38130             : 
   38131             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   38132             : 
   38133             : //############################################################################
   38134             : /* JH (02/02/2006) Constructor of the IR node SgDeclType that takes its 
   38135             :  * corresponding StorageClass as parameter
   38136             :  */
   38137          92 : SgDeclType :: SgDeclType ( const SgDeclTypeStorageClass& storageSource )   : SgType (storageSource)
   38138             :    {
   38139             : 
   38140             : 
   38141             : /* #line 38142 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   38142             : 
   38143          92 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   38144          92 :      p_base_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_expression) );
   38145          92 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   38146             : 
   38147             : 
   38148             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   38149             : 
   38150             : 
   38151          92 :    }
   38152             : 
   38153             : //############################################################################
   38154             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   38155             :  * within the working AST. 
   38156             :  */
   38157         448 : SgDeclType * SgDeclType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   38158         448 :      SgDeclType* returnPointer = NULL;
   38159         448 :      if ( globalIndex != 0 )
   38160             :         {
   38161             : 
   38162             : #if FILE_IO_EXTRA_CHECK
   38163         448 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDeclType ) ) <= globalIndex ) ;
   38164         448 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeclType + 1 ) ) );
   38165             : #endif
   38166         448 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeclType )  
   38167         448 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDeclType );
   38168         448 :           unsigned long positionInPool = localIndex % SgDeclType::pool_size;
   38169         448 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeclType::pool_size;
   38170             : 
   38171             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   38172             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   38173             : 
   38174         448 :           returnPointer = &( ( (SgDeclType*)(SgDeclType::pools[memoryBlock]) ) [positionInPool]) ;
   38175             : 
   38176         448 :           ROSE_ASSERT( returnPointer != NULL ) ;
   38177             :         }
   38178         448 :      return returnPointer ;
   38179             :    }
   38180             : 
   38181             : //############################################################################
   38182             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   38183             :   for the AST with the index astIndex
   38184             : */
   38185           0 : SgDeclType * SgDeclType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   38186           0 :      SgDeclType* returnPointer = NULL;
   38187           0 :      if ( globalIndex != 0 )
   38188             :         {
   38189             : 
   38190             : #if FILE_IO_EXTRA_CHECK
   38191           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDeclType ) ) <= globalIndex ) ;
   38192           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeclType + 1 ) ) );
   38193             : #endif
   38194           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeclType )
   38195           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDeclType );
   38196           0 :           unsigned long positionInPool = localIndex % SgDeclType::pool_size ;
   38197           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeclType::pool_size ;
   38198             : 
   38199             : #if FILE_IO_EXTRA_CHECK
   38200             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   38201             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   38202             : #endif
   38203             : 
   38204           0 :           returnPointer = &( ( (SgDeclType*)(SgDeclType::pools[memoryBlock]) ) [positionInPool]) ;
   38205             : 
   38206             : #if FILE_IO_EXTRA_CHECK
   38207           0 :           assert ( returnPointer != NULL ) ;
   38208             : #endif
   38209             :         }
   38210           0 :      return returnPointer ;
   38211             :    }
   38212             : 
   38213             : //############################################################################
   38214             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   38215             :  * pool size! We set for every valid object in the memory pool the freepointer
   38216             :  * to the global index and increase the global index afterwards. For all the 
   38217             :  * invalid objects (means address ranges within the memory pool that were not
   38218             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   38219             :  * distinguish valid from invalid objects! 
   38220             :  */
   38221             : unsigned long
   38222           5 : SgDeclType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   38223             :    {
   38224           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   38225           5 :      SgDeclType* pointer = NULL;
   38226           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   38227           5 :      std::vector < unsigned char* > :: const_iterator block;
   38228           6 :      for ( block = SgDeclType::pools.begin(); block != SgDeclType::pools.end() ; ++block )
   38229             :         {
   38230           1 :           pointer = (SgDeclType*)(*block);
   38231        2001 :           for (unsigned i = 0; i < SgDeclType::pool_size; ++i )
   38232             :              {
   38233             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   38234             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   38235             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   38236             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   38237             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   38238             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   38239             :             // properly; so this will have to be checked next.
   38240             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   38241             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   38242        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   38243             :                   {
   38244          92 :                     pointer[i].set_freepointer((SgDeclType*)(globalIndex));
   38245          92 :                     globalIndex++;
   38246             :                   }
   38247             :                else
   38248             :                   {
   38249        1908 :                     pointer[i].set_freepointer(NULL);
   38250             :                   }
   38251             :               }
   38252             :         }
   38253           5 :      return globalIndex;
   38254             :    }
   38255             : 
   38256             : //############################################################################
   38257             : // JH (01/14/2006)
   38258             : void
   38259           5 : SgDeclType::resetValidFreepointers( )
   38260             :    {
   38261           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   38262           5 :      SgDeclType* pointer = NULL;
   38263           5 :      std::vector < unsigned char* > :: const_iterator block;
   38264           5 :      SgDeclType* pointerOfLinkedList = NULL;
   38265           6 :      for ( block = SgDeclType::pools.begin(); block != SgDeclType::pools.end() ; ++block )
   38266             :         {
   38267           1 :           pointer = (SgDeclType*)(*block);
   38268        2001 :           for (unsigned i = 0; i < SgDeclType::pool_size; ++i )
   38269             :              {
   38270             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   38271             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   38272             :             // memory blocks!.
   38273        2000 :                if ( pointer[i].get_freepointer() != NULL )
   38274             :                   {
   38275          92 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   38276             :                   }
   38277             :                else
   38278             :                   {
   38279        1908 :                     if ( pointerOfLinkedList == NULL )
   38280             :                        {
   38281           1 :                          SgDeclType::next_node = &(pointer[i]);
   38282             :                        }
   38283             :                     else
   38284             :                        {
   38285             :                       // printf ("In SgDeclType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   38286        1907 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   38287             :                        }
   38288             :                     pointerOfLinkedList = &(pointer[i]);
   38289             :                   }
   38290             :               }
   38291             :         }
   38292             : 
   38293           5 :      if ( pointerOfLinkedList != NULL )
   38294             :         {
   38295             :        // printf ("In SgDeclType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   38296           1 :           pointerOfLinkedList->set_freepointer(NULL);
   38297             :        // DQ (6/6/2010): Temporary debugging...
   38298             :        //   ROSE_ASSERT(false);
   38299             :         }
   38300             : 
   38301           5 :      return ;
   38302             :    }
   38303             : 
   38304             : //############################################################################
   38305             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   38306             :  * within the memory pool and resets the freepointers, in order to achieve a 
   38307             :  * linked list, that has no jumps and starts at the beginning! This function 
   38308             :  * does not extend the memory pool, since we do not delete any memory blocks,
   38309             :  * but delete the valid objects.  
   38310             :  */
   38311             : void
   38312           0 : SgDeclType::clearMemoryPool( )
   38313             :    {
   38314             :   // printf ("Inside of SgDeclType::clearMemoryPool() \n");
   38315             : 
   38316           0 :      SgDeclType* pointer = NULL, *tempPointer = NULL;
   38317           0 :      std::vector < unsigned char* > :: const_iterator block;
   38318           0 :      if ( SgDeclType::pools.empty() == false )
   38319             :         {
   38320           0 :           block = SgDeclType::pools.begin() ;
   38321           0 :           SgDeclType::next_node = (SgDeclType*) (*block);
   38322             : 
   38323           0 :           while ( block != SgDeclType::pools.end() )
   38324             :              {
   38325           0 :                pointer = (SgDeclType*) (*block);
   38326           0 :                if ( tempPointer != NULL )
   38327             :                   {
   38328           0 :                     tempPointer->set_freepointer(pointer);
   38329             :                   }
   38330           0 :                for (unsigned i = 0; i < SgDeclType::pool_size - 1; ++i)
   38331             :                   {
   38332           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   38333             :                   }
   38334           0 :                 pointer[SgDeclType::pool_size-1].set_freepointer(NULL);
   38335           0 :                 tempPointer = &(pointer[SgDeclType::pool_size-1]);
   38336           0 :                 ++block;
   38337             :              }
   38338             :         }
   38339           0 :    }
   38340             : 
   38341           5 : void SgDeclType::deleteMemoryPool() {
   38342           7 :   for (auto p: SgDeclType::pools) {
   38343           2 :     ROSE_FREE(p);
   38344             :   }
   38345           5 :   SgDeclType::next_node = nullptr;
   38346           5 :   SgDeclType::pools.clear();
   38347           5 : }
   38348             : 
   38349             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   38350             : //                 reading multiple binary files to for a single AST.
   38351             : /////////// new version ////////////////////////////////
   38352             : //############################################################################
   38353             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   38354             : void
   38355           2 : SgDeclType::extendMemoryPoolForFileIO( )
   38356             :   {
   38357           2 :     size_t blockIndex = SgDeclType::pools.size();
   38358           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclType);
   38359             : 
   38360           3 :     while ( (blockIndex * SgDeclType::pool_size) < newPoolSize)
   38361             :       {
   38362             : #if ROSE_ALLOC_TRACE
   38363             :         if (blockIndex > 0) {
   38364             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclType) = %" PRIuPTR " SgDeclType::pool_size = %d \n",
   38365             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclType),SgDeclType::pool_size);
   38366             :         }
   38367             : #endif
   38368             : 
   38369           1 :         SgDeclType * pointer = (SgDeclType*) ROSE_MALLOC ( SgDeclType::pool_size * sizeof(SgDeclType) );
   38370           1 :         assert( pointer != NULL );
   38371             : #if ROSE_ALLOC_MEMSET == 1
   38372             :         memset(pointer, 0x00, SgDeclType::pool_size * sizeof(SgDeclType));
   38373             : #elif ROSE_ALLOC_MEMSET == 2
   38374             :         memset(pointer, 0xCC, SgDeclType::pool_size * sizeof(SgDeclType));
   38375             : #endif
   38376           1 :         SgDeclType::pools.push_back( (unsigned char*)(pointer) );
   38377           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDeclType::pool_size * sizeof(SgDeclType), V_SgDeclType ) );
   38378             : 
   38379           1 :         if ( SgDeclType::next_node != NULL ) {
   38380           0 :           if ( blockIndex > 0 ) {
   38381           0 :             SgDeclType * blkptr = (SgDeclType*)(SgDeclType::pools[blockIndex-1]);
   38382           0 :             blkptr[ SgDeclType::pool_size - 1 ].set_freepointer(pointer);
   38383             :           }
   38384             :         } else {
   38385           1 :           SgDeclType::next_node = pointer;
   38386             :         }
   38387             : 
   38388        2000 :         for (unsigned i = 0; i < SgDeclType::pool_size-1; ++i)
   38389             :            {
   38390        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   38391             :            }
   38392           1 :         pointer[ SgDeclType::pool_size -1 ].set_freepointer(NULL);
   38393             : 
   38394           1 :         blockIndex++;
   38395             :       }
   38396           2 :   }
   38397             : 
   38398             : //############################################################################
   38399             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   38400             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   38401             :  * not compressed. However, that stuff is not yet implemented! 
   38402             :  */
   38403             : unsigned long
   38404           0 : SgDeclType::getNumberOfLastValidPointer()
   38405             :    {
   38406           0 :       SgDeclType* testPointer = (SgDeclType*)(SgDeclType::pools.back());
   38407           0 :       unsigned long localIndex = SgDeclType::pool_size - 1;
   38408           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   38409             :          {
   38410           0 :            localIndex--;
   38411             :          }
   38412           0 :       return (localIndex + SgDeclType::pool_size * (SgDeclType::pools.size()-1));
   38413             :    }
   38414             : 
   38415             : //############################################################################
   38416             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   38417             :  * memory pool and initializes the data member in class SgDeclTypeStroageClass
   38418             :  * from its counterpart of SgDeclType. The return value is just for checking, 
   38419             :  * that the whole StorageClassArray is initialized!
   38420             :  */
   38421             : unsigned long
   38422           1 : SgDeclType::initializeStorageClassArray( SgDeclTypeStorageClass *storageArray )
   38423             :    {
   38424           1 :      unsigned long storageCounter = 0;
   38425           1 :      std::vector < unsigned char* > :: const_iterator block = SgDeclType::pools.begin();
   38426           1 :      SgDeclType* pointer = NULL;
   38427           2 :      while ( block != SgDeclType::pools.end() ) {
   38428           1 :           pointer = (SgDeclType*) (*block);
   38429        2001 :           for ( unsigned i = 0; i < SgDeclType::pool_size; ++i ) {
   38430        2000 :                if ( pointer->get_freepointer() != NULL ) {
   38431          92 :                  storageArray->pickOutIRNodeData (pointer) ;
   38432          92 :                  storageArray++;
   38433          92 :                  storageCounter++;
   38434             :                }
   38435        2000 :                pointer++;
   38436             :              }
   38437           1 :            block++;
   38438             :         }
   38439           1 :      return storageCounter;
   38440             :    }
   38441             : 
   38442             : /* #line 38443 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   38443             : 
   38444             : 
   38445             : 
   38446             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   38447             : 
   38448             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   38449             : 
   38450             : //############################################################################
   38451             : /* JH (02/02/2006) Constructor of the IR node SgTypeOfType that takes its 
   38452             :  * corresponding StorageClass as parameter
   38453             :  */
   38454           3 : SgTypeOfType :: SgTypeOfType ( const SgTypeOfTypeStorageClass& storageSource )   : SgType (storageSource)
   38455             :    {
   38456             : 
   38457             : 
   38458             : /* #line 38459 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   38459             : 
   38460           3 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   38461           3 :      p_base_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_expression) );
   38462           3 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   38463             : 
   38464             : 
   38465             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   38466             : 
   38467             : 
   38468           3 :    }
   38469             : 
   38470             : //############################################################################
   38471             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   38472             :  * within the working AST. 
   38473             :  */
   38474           9 : SgTypeOfType * SgTypeOfType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   38475           9 :      SgTypeOfType* returnPointer = NULL;
   38476           9 :      if ( globalIndex != 0 )
   38477             :         {
   38478             : 
   38479             : #if FILE_IO_EXTRA_CHECK
   38480           9 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeOfType ) ) <= globalIndex ) ;
   38481           9 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeOfType + 1 ) ) );
   38482             : #endif
   38483           9 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeOfType )  
   38484           9 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeOfType );
   38485           9 :           unsigned long positionInPool = localIndex % SgTypeOfType::pool_size;
   38486           9 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeOfType::pool_size;
   38487             : 
   38488             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   38489             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   38490             : 
   38491           9 :           returnPointer = &( ( (SgTypeOfType*)(SgTypeOfType::pools[memoryBlock]) ) [positionInPool]) ;
   38492             : 
   38493           9 :           ROSE_ASSERT( returnPointer != NULL ) ;
   38494             :         }
   38495           9 :      return returnPointer ;
   38496             :    }
   38497             : 
   38498             : //############################################################################
   38499             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   38500             :   for the AST with the index astIndex
   38501             : */
   38502           0 : SgTypeOfType * SgTypeOfType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   38503           0 :      SgTypeOfType* returnPointer = NULL;
   38504           0 :      if ( globalIndex != 0 )
   38505             :         {
   38506             : 
   38507             : #if FILE_IO_EXTRA_CHECK
   38508           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeOfType ) ) <= globalIndex ) ;
   38509           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeOfType + 1 ) ) );
   38510             : #endif
   38511           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeOfType )
   38512           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeOfType );
   38513           0 :           unsigned long positionInPool = localIndex % SgTypeOfType::pool_size ;
   38514           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeOfType::pool_size ;
   38515             : 
   38516             : #if FILE_IO_EXTRA_CHECK
   38517             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   38518             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   38519             : #endif
   38520             : 
   38521           0 :           returnPointer = &( ( (SgTypeOfType*)(SgTypeOfType::pools[memoryBlock]) ) [positionInPool]) ;
   38522             : 
   38523             : #if FILE_IO_EXTRA_CHECK
   38524           0 :           assert ( returnPointer != NULL ) ;
   38525             : #endif
   38526             :         }
   38527           0 :      return returnPointer ;
   38528             :    }
   38529             : 
   38530             : //############################################################################
   38531             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   38532             :  * pool size! We set for every valid object in the memory pool the freepointer
   38533             :  * to the global index and increase the global index afterwards. For all the 
   38534             :  * invalid objects (means address ranges within the memory pool that were not
   38535             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   38536             :  * distinguish valid from invalid objects! 
   38537             :  */
   38538             : unsigned long
   38539           5 : SgTypeOfType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   38540             :    {
   38541           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   38542           5 :      SgTypeOfType* pointer = NULL;
   38543           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   38544           5 :      std::vector < unsigned char* > :: const_iterator block;
   38545           6 :      for ( block = SgTypeOfType::pools.begin(); block != SgTypeOfType::pools.end() ; ++block )
   38546             :         {
   38547           1 :           pointer = (SgTypeOfType*)(*block);
   38548        2001 :           for (unsigned i = 0; i < SgTypeOfType::pool_size; ++i )
   38549             :              {
   38550             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   38551             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   38552             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   38553             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   38554             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   38555             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   38556             :             // properly; so this will have to be checked next.
   38557             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   38558             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   38559        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   38560             :                   {
   38561           3 :                     pointer[i].set_freepointer((SgTypeOfType*)(globalIndex));
   38562           3 :                     globalIndex++;
   38563             :                   }
   38564             :                else
   38565             :                   {
   38566        1997 :                     pointer[i].set_freepointer(NULL);
   38567             :                   }
   38568             :               }
   38569             :         }
   38570           5 :      return globalIndex;
   38571             :    }
   38572             : 
   38573             : //############################################################################
   38574             : // JH (01/14/2006)
   38575             : void
   38576           5 : SgTypeOfType::resetValidFreepointers( )
   38577             :    {
   38578           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   38579           5 :      SgTypeOfType* pointer = NULL;
   38580           5 :      std::vector < unsigned char* > :: const_iterator block;
   38581           5 :      SgTypeOfType* pointerOfLinkedList = NULL;
   38582           6 :      for ( block = SgTypeOfType::pools.begin(); block != SgTypeOfType::pools.end() ; ++block )
   38583             :         {
   38584           1 :           pointer = (SgTypeOfType*)(*block);
   38585        2001 :           for (unsigned i = 0; i < SgTypeOfType::pool_size; ++i )
   38586             :              {
   38587             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   38588             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   38589             :             // memory blocks!.
   38590        2000 :                if ( pointer[i].get_freepointer() != NULL )
   38591             :                   {
   38592           3 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   38593             :                   }
   38594             :                else
   38595             :                   {
   38596        1997 :                     if ( pointerOfLinkedList == NULL )
   38597             :                        {
   38598           1 :                          SgTypeOfType::next_node = &(pointer[i]);
   38599             :                        }
   38600             :                     else
   38601             :                        {
   38602             :                       // printf ("In SgTypeOfType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   38603        1996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   38604             :                        }
   38605             :                     pointerOfLinkedList = &(pointer[i]);
   38606             :                   }
   38607             :               }
   38608             :         }
   38609             : 
   38610           5 :      if ( pointerOfLinkedList != NULL )
   38611             :         {
   38612             :        // printf ("In SgTypeOfType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   38613           1 :           pointerOfLinkedList->set_freepointer(NULL);
   38614             :        // DQ (6/6/2010): Temporary debugging...
   38615             :        //   ROSE_ASSERT(false);
   38616             :         }
   38617             : 
   38618           5 :      return ;
   38619             :    }
   38620             : 
   38621             : //############################################################################
   38622             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   38623             :  * within the memory pool and resets the freepointers, in order to achieve a 
   38624             :  * linked list, that has no jumps and starts at the beginning! This function 
   38625             :  * does not extend the memory pool, since we do not delete any memory blocks,
   38626             :  * but delete the valid objects.  
   38627             :  */
   38628             : void
   38629           0 : SgTypeOfType::clearMemoryPool( )
   38630             :    {
   38631             :   // printf ("Inside of SgTypeOfType::clearMemoryPool() \n");
   38632             : 
   38633           0 :      SgTypeOfType* pointer = NULL, *tempPointer = NULL;
   38634           0 :      std::vector < unsigned char* > :: const_iterator block;
   38635           0 :      if ( SgTypeOfType::pools.empty() == false )
   38636             :         {
   38637           0 :           block = SgTypeOfType::pools.begin() ;
   38638           0 :           SgTypeOfType::next_node = (SgTypeOfType*) (*block);
   38639             : 
   38640           0 :           while ( block != SgTypeOfType::pools.end() )
   38641             :              {
   38642           0 :                pointer = (SgTypeOfType*) (*block);
   38643           0 :                if ( tempPointer != NULL )
   38644             :                   {
   38645           0 :                     tempPointer->set_freepointer(pointer);
   38646             :                   }
   38647           0 :                for (unsigned i = 0; i < SgTypeOfType::pool_size - 1; ++i)
   38648             :                   {
   38649           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   38650             :                   }
   38651           0 :                 pointer[SgTypeOfType::pool_size-1].set_freepointer(NULL);
   38652           0 :                 tempPointer = &(pointer[SgTypeOfType::pool_size-1]);
   38653           0 :                 ++block;
   38654             :              }
   38655             :         }
   38656           0 :    }
   38657             : 
   38658           5 : void SgTypeOfType::deleteMemoryPool() {
   38659           7 :   for (auto p: SgTypeOfType::pools) {
   38660           2 :     ROSE_FREE(p);
   38661             :   }
   38662           5 :   SgTypeOfType::next_node = nullptr;
   38663           5 :   SgTypeOfType::pools.clear();
   38664           5 : }
   38665             : 
   38666             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   38667             : //                 reading multiple binary files to for a single AST.
   38668             : /////////// new version ////////////////////////////////
   38669             : //############################################################################
   38670             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   38671             : void
   38672           2 : SgTypeOfType::extendMemoryPoolForFileIO( )
   38673             :   {
   38674           2 :     size_t blockIndex = SgTypeOfType::pools.size();
   38675           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeOfType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeOfType);
   38676             : 
   38677           3 :     while ( (blockIndex * SgTypeOfType::pool_size) < newPoolSize)
   38678             :       {
   38679             : #if ROSE_ALLOC_TRACE
   38680             :         if (blockIndex > 0) {
   38681             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeOfType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeOfType) = %" PRIuPTR " SgTypeOfType::pool_size = %d \n",
   38682             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeOfType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeOfType),SgTypeOfType::pool_size);
   38683             :         }
   38684             : #endif
   38685             : 
   38686           1 :         SgTypeOfType * pointer = (SgTypeOfType*) ROSE_MALLOC ( SgTypeOfType::pool_size * sizeof(SgTypeOfType) );
   38687           1 :         assert( pointer != NULL );
   38688             : #if ROSE_ALLOC_MEMSET == 1
   38689             :         memset(pointer, 0x00, SgTypeOfType::pool_size * sizeof(SgTypeOfType));
   38690             : #elif ROSE_ALLOC_MEMSET == 2
   38691             :         memset(pointer, 0xCC, SgTypeOfType::pool_size * sizeof(SgTypeOfType));
   38692             : #endif
   38693           1 :         SgTypeOfType::pools.push_back( (unsigned char*)(pointer) );
   38694           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeOfType::pool_size * sizeof(SgTypeOfType), V_SgTypeOfType ) );
   38695             : 
   38696           1 :         if ( SgTypeOfType::next_node != NULL ) {
   38697           0 :           if ( blockIndex > 0 ) {
   38698           0 :             SgTypeOfType * blkptr = (SgTypeOfType*)(SgTypeOfType::pools[blockIndex-1]);
   38699           0 :             blkptr[ SgTypeOfType::pool_size - 1 ].set_freepointer(pointer);
   38700             :           }
   38701             :         } else {
   38702           1 :           SgTypeOfType::next_node = pointer;
   38703             :         }
   38704             : 
   38705        2000 :         for (unsigned i = 0; i < SgTypeOfType::pool_size-1; ++i)
   38706             :            {
   38707        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   38708             :            }
   38709           1 :         pointer[ SgTypeOfType::pool_size -1 ].set_freepointer(NULL);
   38710             : 
   38711           1 :         blockIndex++;
   38712             :       }
   38713           2 :   }
   38714             : 
   38715             : //############################################################################
   38716             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   38717             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   38718             :  * not compressed. However, that stuff is not yet implemented! 
   38719             :  */
   38720             : unsigned long
   38721           0 : SgTypeOfType::getNumberOfLastValidPointer()
   38722             :    {
   38723           0 :       SgTypeOfType* testPointer = (SgTypeOfType*)(SgTypeOfType::pools.back());
   38724           0 :       unsigned long localIndex = SgTypeOfType::pool_size - 1;
   38725           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   38726             :          {
   38727           0 :            localIndex--;
   38728             :          }
   38729           0 :       return (localIndex + SgTypeOfType::pool_size * (SgTypeOfType::pools.size()-1));
   38730             :    }
   38731             : 
   38732             : //############################################################################
   38733             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   38734             :  * memory pool and initializes the data member in class SgTypeOfTypeStroageClass
   38735             :  * from its counterpart of SgTypeOfType. The return value is just for checking, 
   38736             :  * that the whole StorageClassArray is initialized!
   38737             :  */
   38738             : unsigned long
   38739           1 : SgTypeOfType::initializeStorageClassArray( SgTypeOfTypeStorageClass *storageArray )
   38740             :    {
   38741           1 :      unsigned long storageCounter = 0;
   38742           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeOfType::pools.begin();
   38743           1 :      SgTypeOfType* pointer = NULL;
   38744           2 :      while ( block != SgTypeOfType::pools.end() ) {
   38745           1 :           pointer = (SgTypeOfType*) (*block);
   38746        2001 :           for ( unsigned i = 0; i < SgTypeOfType::pool_size; ++i ) {
   38747        2000 :                if ( pointer->get_freepointer() != NULL ) {
   38748           3 :                  storageArray->pickOutIRNodeData (pointer) ;
   38749           3 :                  storageArray++;
   38750           3 :                  storageCounter++;
   38751             :                }
   38752        2000 :                pointer++;
   38753             :              }
   38754           1 :            block++;
   38755             :         }
   38756           1 :      return storageCounter;
   38757             :    }
   38758             : 
   38759             : /* #line 38760 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   38760             : 
   38761             : 
   38762             : 
   38763             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   38764             : 
   38765             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   38766             : 
   38767             : //############################################################################
   38768             : /* JH (02/02/2006) Constructor of the IR node SgTypeMatrix that takes its 
   38769             :  * corresponding StorageClass as parameter
   38770             :  */
   38771           0 : SgTypeMatrix :: SgTypeMatrix ( const SgTypeMatrixStorageClass& storageSource )   : SgType (storageSource)
   38772             :    {
   38773             : 
   38774             : 
   38775             : /* #line 38776 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   38776             : 
   38777           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   38778           0 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   38779             : 
   38780             : 
   38781             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   38782             : 
   38783             : 
   38784           0 :    }
   38785             : 
   38786             : //############################################################################
   38787             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   38788             :  * within the working AST. 
   38789             :  */
   38790           0 : SgTypeMatrix * SgTypeMatrix::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   38791           0 :      SgTypeMatrix* returnPointer = NULL;
   38792           0 :      if ( globalIndex != 0 )
   38793             :         {
   38794             : 
   38795             : #if FILE_IO_EXTRA_CHECK
   38796           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeMatrix ) ) <= globalIndex ) ;
   38797           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeMatrix + 1 ) ) );
   38798             : #endif
   38799           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeMatrix )  
   38800           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeMatrix );
   38801           0 :           unsigned long positionInPool = localIndex % SgTypeMatrix::pool_size;
   38802           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeMatrix::pool_size;
   38803             : 
   38804             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   38805             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   38806             : 
   38807           0 :           returnPointer = &( ( (SgTypeMatrix*)(SgTypeMatrix::pools[memoryBlock]) ) [positionInPool]) ;
   38808             : 
   38809           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   38810             :         }
   38811           0 :      return returnPointer ;
   38812             :    }
   38813             : 
   38814             : //############################################################################
   38815             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   38816             :   for the AST with the index astIndex
   38817             : */
   38818           0 : SgTypeMatrix * SgTypeMatrix::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   38819           0 :      SgTypeMatrix* returnPointer = NULL;
   38820           0 :      if ( globalIndex != 0 )
   38821             :         {
   38822             : 
   38823             : #if FILE_IO_EXTRA_CHECK
   38824           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeMatrix ) ) <= globalIndex ) ;
   38825           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeMatrix + 1 ) ) );
   38826             : #endif
   38827           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeMatrix )
   38828           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeMatrix );
   38829           0 :           unsigned long positionInPool = localIndex % SgTypeMatrix::pool_size ;
   38830           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeMatrix::pool_size ;
   38831             : 
   38832             : #if FILE_IO_EXTRA_CHECK
   38833             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   38834             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   38835             : #endif
   38836             : 
   38837           0 :           returnPointer = &( ( (SgTypeMatrix*)(SgTypeMatrix::pools[memoryBlock]) ) [positionInPool]) ;
   38838             : 
   38839             : #if FILE_IO_EXTRA_CHECK
   38840           0 :           assert ( returnPointer != NULL ) ;
   38841             : #endif
   38842             :         }
   38843           0 :      return returnPointer ;
   38844             :    }
   38845             : 
   38846             : //############################################################################
   38847             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   38848             :  * pool size! We set for every valid object in the memory pool the freepointer
   38849             :  * to the global index and increase the global index afterwards. For all the 
   38850             :  * invalid objects (means address ranges within the memory pool that were not
   38851             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   38852             :  * distinguish valid from invalid objects! 
   38853             :  */
   38854             : unsigned long
   38855           5 : SgTypeMatrix::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   38856             :    {
   38857           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   38858           5 :      SgTypeMatrix* pointer = NULL;
   38859           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   38860           5 :      std::vector < unsigned char* > :: const_iterator block;
   38861           5 :      for ( block = SgTypeMatrix::pools.begin(); block != SgTypeMatrix::pools.end() ; ++block )
   38862             :         {
   38863           0 :           pointer = (SgTypeMatrix*)(*block);
   38864           0 :           for (unsigned i = 0; i < SgTypeMatrix::pool_size; ++i )
   38865             :              {
   38866             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   38867             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   38868             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   38869             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   38870             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   38871             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   38872             :             // properly; so this will have to be checked next.
   38873             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   38874             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   38875           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   38876             :                   {
   38877           0 :                     pointer[i].set_freepointer((SgTypeMatrix*)(globalIndex));
   38878           0 :                     globalIndex++;
   38879             :                   }
   38880             :                else
   38881             :                   {
   38882           0 :                     pointer[i].set_freepointer(NULL);
   38883             :                   }
   38884             :               }
   38885             :         }
   38886           5 :      return globalIndex;
   38887             :    }
   38888             : 
   38889             : //############################################################################
   38890             : // JH (01/14/2006)
   38891             : void
   38892           5 : SgTypeMatrix::resetValidFreepointers( )
   38893             :    {
   38894           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   38895           5 :      SgTypeMatrix* pointer = NULL;
   38896           5 :      std::vector < unsigned char* > :: const_iterator block;
   38897           5 :      SgTypeMatrix* pointerOfLinkedList = NULL;
   38898           5 :      for ( block = SgTypeMatrix::pools.begin(); block != SgTypeMatrix::pools.end() ; ++block )
   38899             :         {
   38900           0 :           pointer = (SgTypeMatrix*)(*block);
   38901           0 :           for (unsigned i = 0; i < SgTypeMatrix::pool_size; ++i )
   38902             :              {
   38903             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   38904             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   38905             :             // memory blocks!.
   38906           0 :                if ( pointer[i].get_freepointer() != NULL )
   38907             :                   {
   38908           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   38909             :                   }
   38910             :                else
   38911             :                   {
   38912           0 :                     if ( pointerOfLinkedList == NULL )
   38913             :                        {
   38914           0 :                          SgTypeMatrix::next_node = &(pointer[i]);
   38915             :                        }
   38916             :                     else
   38917             :                        {
   38918             :                       // printf ("In SgTypeMatrix::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   38919           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   38920             :                        }
   38921             :                     pointerOfLinkedList = &(pointer[i]);
   38922             :                   }
   38923             :               }
   38924             :         }
   38925             : 
   38926           5 :      if ( pointerOfLinkedList != NULL )
   38927             :         {
   38928             :        // printf ("In SgTypeMatrix::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   38929           0 :           pointerOfLinkedList->set_freepointer(NULL);
   38930             :        // DQ (6/6/2010): Temporary debugging...
   38931             :        //   ROSE_ASSERT(false);
   38932             :         }
   38933             : 
   38934           5 :      return ;
   38935             :    }
   38936             : 
   38937             : //############################################################################
   38938             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   38939             :  * within the memory pool and resets the freepointers, in order to achieve a 
   38940             :  * linked list, that has no jumps and starts at the beginning! This function 
   38941             :  * does not extend the memory pool, since we do not delete any memory blocks,
   38942             :  * but delete the valid objects.  
   38943             :  */
   38944             : void
   38945           0 : SgTypeMatrix::clearMemoryPool( )
   38946             :    {
   38947             :   // printf ("Inside of SgTypeMatrix::clearMemoryPool() \n");
   38948             : 
   38949           0 :      SgTypeMatrix* pointer = NULL, *tempPointer = NULL;
   38950           0 :      std::vector < unsigned char* > :: const_iterator block;
   38951           0 :      if ( SgTypeMatrix::pools.empty() == false )
   38952             :         {
   38953           0 :           block = SgTypeMatrix::pools.begin() ;
   38954           0 :           SgTypeMatrix::next_node = (SgTypeMatrix*) (*block);
   38955             : 
   38956           0 :           while ( block != SgTypeMatrix::pools.end() )
   38957             :              {
   38958           0 :                pointer = (SgTypeMatrix*) (*block);
   38959           0 :                if ( tempPointer != NULL )
   38960             :                   {
   38961           0 :                     tempPointer->set_freepointer(pointer);
   38962             :                   }
   38963           0 :                for (unsigned i = 0; i < SgTypeMatrix::pool_size - 1; ++i)
   38964             :                   {
   38965           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   38966             :                   }
   38967           0 :                 pointer[SgTypeMatrix::pool_size-1].set_freepointer(NULL);
   38968           0 :                 tempPointer = &(pointer[SgTypeMatrix::pool_size-1]);
   38969           0 :                 ++block;
   38970             :              }
   38971             :         }
   38972           0 :    }
   38973             : 
   38974           5 : void SgTypeMatrix::deleteMemoryPool() {
   38975           5 :   for (auto p: SgTypeMatrix::pools) {
   38976           0 :     ROSE_FREE(p);
   38977             :   }
   38978           5 :   SgTypeMatrix::next_node = nullptr;
   38979           5 :   SgTypeMatrix::pools.clear();
   38980           5 : }
   38981             : 
   38982             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   38983             : //                 reading multiple binary files to for a single AST.
   38984             : /////////// new version ////////////////////////////////
   38985             : //############################################################################
   38986             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   38987             : void
   38988           2 : SgTypeMatrix::extendMemoryPoolForFileIO( )
   38989             :   {
   38990           2 :     size_t blockIndex = SgTypeMatrix::pools.size();
   38991           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeMatrix) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeMatrix);
   38992             : 
   38993           2 :     while ( (blockIndex * SgTypeMatrix::pool_size) < newPoolSize)
   38994             :       {
   38995             : #if ROSE_ALLOC_TRACE
   38996             :         if (blockIndex > 0) {
   38997             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeMatrix) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeMatrix) = %" PRIuPTR " SgTypeMatrix::pool_size = %d \n",
   38998             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeMatrix),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeMatrix),SgTypeMatrix::pool_size);
   38999             :         }
   39000             : #endif
   39001             : 
   39002           0 :         SgTypeMatrix * pointer = (SgTypeMatrix*) ROSE_MALLOC ( SgTypeMatrix::pool_size * sizeof(SgTypeMatrix) );
   39003           0 :         assert( pointer != NULL );
   39004             : #if ROSE_ALLOC_MEMSET == 1
   39005             :         memset(pointer, 0x00, SgTypeMatrix::pool_size * sizeof(SgTypeMatrix));
   39006             : #elif ROSE_ALLOC_MEMSET == 2
   39007             :         memset(pointer, 0xCC, SgTypeMatrix::pool_size * sizeof(SgTypeMatrix));
   39008             : #endif
   39009           0 :         SgTypeMatrix::pools.push_back( (unsigned char*)(pointer) );
   39010           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeMatrix::pool_size * sizeof(SgTypeMatrix), V_SgTypeMatrix ) );
   39011             : 
   39012           0 :         if ( SgTypeMatrix::next_node != NULL ) {
   39013           0 :           if ( blockIndex > 0 ) {
   39014           0 :             SgTypeMatrix * blkptr = (SgTypeMatrix*)(SgTypeMatrix::pools[blockIndex-1]);
   39015           0 :             blkptr[ SgTypeMatrix::pool_size - 1 ].set_freepointer(pointer);
   39016             :           }
   39017             :         } else {
   39018           0 :           SgTypeMatrix::next_node = pointer;
   39019             :         }
   39020             : 
   39021           0 :         for (unsigned i = 0; i < SgTypeMatrix::pool_size-1; ++i)
   39022             :            {
   39023           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   39024             :            }
   39025           0 :         pointer[ SgTypeMatrix::pool_size -1 ].set_freepointer(NULL);
   39026             : 
   39027           0 :         blockIndex++;
   39028             :       }
   39029           2 :   }
   39030             : 
   39031             : //############################################################################
   39032             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   39033             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   39034             :  * not compressed. However, that stuff is not yet implemented! 
   39035             :  */
   39036             : unsigned long
   39037           0 : SgTypeMatrix::getNumberOfLastValidPointer()
   39038             :    {
   39039           0 :       SgTypeMatrix* testPointer = (SgTypeMatrix*)(SgTypeMatrix::pools.back());
   39040           0 :       unsigned long localIndex = SgTypeMatrix::pool_size - 1;
   39041           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   39042             :          {
   39043           0 :            localIndex--;
   39044             :          }
   39045           0 :       return (localIndex + SgTypeMatrix::pool_size * (SgTypeMatrix::pools.size()-1));
   39046             :    }
   39047             : 
   39048             : //############################################################################
   39049             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   39050             :  * memory pool and initializes the data member in class SgTypeMatrixStroageClass
   39051             :  * from its counterpart of SgTypeMatrix. The return value is just for checking, 
   39052             :  * that the whole StorageClassArray is initialized!
   39053             :  */
   39054             : unsigned long
   39055           0 : SgTypeMatrix::initializeStorageClassArray( SgTypeMatrixStorageClass *storageArray )
   39056             :    {
   39057           0 :      unsigned long storageCounter = 0;
   39058           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeMatrix::pools.begin();
   39059           0 :      SgTypeMatrix* pointer = NULL;
   39060           0 :      while ( block != SgTypeMatrix::pools.end() ) {
   39061           0 :           pointer = (SgTypeMatrix*) (*block);
   39062           0 :           for ( unsigned i = 0; i < SgTypeMatrix::pool_size; ++i ) {
   39063           0 :                if ( pointer->get_freepointer() != NULL ) {
   39064           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   39065           0 :                  storageArray++;
   39066           0 :                  storageCounter++;
   39067             :                }
   39068           0 :                pointer++;
   39069             :              }
   39070           0 :            block++;
   39071             :         }
   39072           0 :      return storageCounter;
   39073             :    }
   39074             : 
   39075             : /* #line 39076 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   39076             : 
   39077             : 
   39078             : 
   39079             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   39080             : 
   39081             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   39082             : 
   39083             : //############################################################################
   39084             : /* JH (02/02/2006) Constructor of the IR node SgTypeTuple that takes its 
   39085             :  * corresponding StorageClass as parameter
   39086             :  */
   39087           0 : SgTypeTuple :: SgTypeTuple ( const SgTypeTupleStorageClass& storageSource )   : SgType (storageSource)
   39088             :    {
   39089             : 
   39090             : 
   39091             : /* #line 39092 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   39092             : 
   39093           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   39094           0 :      p_types = storageSource.storageOf_types.rebuildDataStoredInEasyStorageClass() ;
   39095           0 :      SgTypePtrList::iterator i_types = p_types.begin() ; 
   39096           0 :      for ( ; i_types != p_types.end(); ++i_types ) 
   39097             :         {
   39098           0 :           (*i_types) = (SgTypePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_types) ) );
   39099             :         }
   39100             : 
   39101             : 
   39102             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   39103             : 
   39104             : 
   39105           0 :    }
   39106             : 
   39107             : //############################################################################
   39108             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   39109             :  * within the working AST. 
   39110             :  */
   39111           0 : SgTypeTuple * SgTypeTuple::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   39112           0 :      SgTypeTuple* returnPointer = NULL;
   39113           0 :      if ( globalIndex != 0 )
   39114             :         {
   39115             : 
   39116             : #if FILE_IO_EXTRA_CHECK
   39117           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeTuple ) ) <= globalIndex ) ;
   39118           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeTuple + 1 ) ) );
   39119             : #endif
   39120           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeTuple )  
   39121           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeTuple );
   39122           0 :           unsigned long positionInPool = localIndex % SgTypeTuple::pool_size;
   39123           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeTuple::pool_size;
   39124             : 
   39125             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   39126             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   39127             : 
   39128           0 :           returnPointer = &( ( (SgTypeTuple*)(SgTypeTuple::pools[memoryBlock]) ) [positionInPool]) ;
   39129             : 
   39130           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   39131             :         }
   39132           0 :      return returnPointer ;
   39133             :    }
   39134             : 
   39135             : //############################################################################
   39136             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   39137             :   for the AST with the index astIndex
   39138             : */
   39139           0 : SgTypeTuple * SgTypeTuple::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   39140           0 :      SgTypeTuple* returnPointer = NULL;
   39141           0 :      if ( globalIndex != 0 )
   39142             :         {
   39143             : 
   39144             : #if FILE_IO_EXTRA_CHECK
   39145           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeTuple ) ) <= globalIndex ) ;
   39146           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeTuple + 1 ) ) );
   39147             : #endif
   39148           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeTuple )
   39149           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeTuple );
   39150           0 :           unsigned long positionInPool = localIndex % SgTypeTuple::pool_size ;
   39151           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeTuple::pool_size ;
   39152             : 
   39153             : #if FILE_IO_EXTRA_CHECK
   39154             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   39155             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   39156             : #endif
   39157             : 
   39158           0 :           returnPointer = &( ( (SgTypeTuple*)(SgTypeTuple::pools[memoryBlock]) ) [positionInPool]) ;
   39159             : 
   39160             : #if FILE_IO_EXTRA_CHECK
   39161           0 :           assert ( returnPointer != NULL ) ;
   39162             : #endif
   39163             :         }
   39164           0 :      return returnPointer ;
   39165             :    }
   39166             : 
   39167             : //############################################################################
   39168             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   39169             :  * pool size! We set for every valid object in the memory pool the freepointer
   39170             :  * to the global index and increase the global index afterwards. For all the 
   39171             :  * invalid objects (means address ranges within the memory pool that were not
   39172             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   39173             :  * distinguish valid from invalid objects! 
   39174             :  */
   39175             : unsigned long
   39176           5 : SgTypeTuple::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   39177             :    {
   39178           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   39179           5 :      SgTypeTuple* pointer = NULL;
   39180           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   39181           5 :      std::vector < unsigned char* > :: const_iterator block;
   39182           5 :      for ( block = SgTypeTuple::pools.begin(); block != SgTypeTuple::pools.end() ; ++block )
   39183             :         {
   39184           0 :           pointer = (SgTypeTuple*)(*block);
   39185           0 :           for (unsigned i = 0; i < SgTypeTuple::pool_size; ++i )
   39186             :              {
   39187             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   39188             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   39189             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   39190             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   39191             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   39192             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   39193             :             // properly; so this will have to be checked next.
   39194             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   39195             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   39196           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   39197             :                   {
   39198           0 :                     pointer[i].set_freepointer((SgTypeTuple*)(globalIndex));
   39199           0 :                     globalIndex++;
   39200             :                   }
   39201             :                else
   39202             :                   {
   39203           0 :                     pointer[i].set_freepointer(NULL);
   39204             :                   }
   39205             :               }
   39206             :         }
   39207           5 :      return globalIndex;
   39208             :    }
   39209             : 
   39210             : //############################################################################
   39211             : // JH (01/14/2006)
   39212             : void
   39213           5 : SgTypeTuple::resetValidFreepointers( )
   39214             :    {
   39215           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   39216           5 :      SgTypeTuple* pointer = NULL;
   39217           5 :      std::vector < unsigned char* > :: const_iterator block;
   39218           5 :      SgTypeTuple* pointerOfLinkedList = NULL;
   39219           5 :      for ( block = SgTypeTuple::pools.begin(); block != SgTypeTuple::pools.end() ; ++block )
   39220             :         {
   39221           0 :           pointer = (SgTypeTuple*)(*block);
   39222           0 :           for (unsigned i = 0; i < SgTypeTuple::pool_size; ++i )
   39223             :              {
   39224             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   39225             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   39226             :             // memory blocks!.
   39227           0 :                if ( pointer[i].get_freepointer() != NULL )
   39228             :                   {
   39229           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   39230             :                   }
   39231             :                else
   39232             :                   {
   39233           0 :                     if ( pointerOfLinkedList == NULL )
   39234             :                        {
   39235           0 :                          SgTypeTuple::next_node = &(pointer[i]);
   39236             :                        }
   39237             :                     else
   39238             :                        {
   39239             :                       // printf ("In SgTypeTuple::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   39240           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   39241             :                        }
   39242             :                     pointerOfLinkedList = &(pointer[i]);
   39243             :                   }
   39244             :               }
   39245             :         }
   39246             : 
   39247           5 :      if ( pointerOfLinkedList != NULL )
   39248             :         {
   39249             :        // printf ("In SgTypeTuple::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   39250           0 :           pointerOfLinkedList->set_freepointer(NULL);
   39251             :        // DQ (6/6/2010): Temporary debugging...
   39252             :        //   ROSE_ASSERT(false);
   39253             :         }
   39254             : 
   39255           5 :      return ;
   39256             :    }
   39257             : 
   39258             : //############################################################################
   39259             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   39260             :  * within the memory pool and resets the freepointers, in order to achieve a 
   39261             :  * linked list, that has no jumps and starts at the beginning! This function 
   39262             :  * does not extend the memory pool, since we do not delete any memory blocks,
   39263             :  * but delete the valid objects.  
   39264             :  */
   39265             : void
   39266           0 : SgTypeTuple::clearMemoryPool( )
   39267             :    {
   39268             :   // printf ("Inside of SgTypeTuple::clearMemoryPool() \n");
   39269             : 
   39270           0 :      SgTypeTuple* pointer = NULL, *tempPointer = NULL;
   39271           0 :      std::vector < unsigned char* > :: const_iterator block;
   39272           0 :      if ( SgTypeTuple::pools.empty() == false )
   39273             :         {
   39274           0 :           block = SgTypeTuple::pools.begin() ;
   39275           0 :           SgTypeTuple::next_node = (SgTypeTuple*) (*block);
   39276             : 
   39277           0 :           while ( block != SgTypeTuple::pools.end() )
   39278             :              {
   39279           0 :                pointer = (SgTypeTuple*) (*block);
   39280           0 :                if ( tempPointer != NULL )
   39281             :                   {
   39282           0 :                     tempPointer->set_freepointer(pointer);
   39283             :                   }
   39284           0 :                for (unsigned i = 0; i < SgTypeTuple::pool_size - 1; ++i)
   39285             :                   {
   39286           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   39287             :                   }
   39288           0 :                 pointer[SgTypeTuple::pool_size-1].set_freepointer(NULL);
   39289           0 :                 tempPointer = &(pointer[SgTypeTuple::pool_size-1]);
   39290           0 :                 ++block;
   39291             :              }
   39292             :         }
   39293           0 :    }
   39294             : 
   39295           5 : void SgTypeTuple::deleteMemoryPool() {
   39296           5 :   for (auto p: SgTypeTuple::pools) {
   39297           0 :     ROSE_FREE(p);
   39298             :   }
   39299           5 :   SgTypeTuple::next_node = nullptr;
   39300           5 :   SgTypeTuple::pools.clear();
   39301           5 : }
   39302             : 
   39303             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   39304             : //                 reading multiple binary files to for a single AST.
   39305             : /////////// new version ////////////////////////////////
   39306             : //############################################################################
   39307             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   39308             : void
   39309           2 : SgTypeTuple::extendMemoryPoolForFileIO( )
   39310             :   {
   39311           2 :     size_t blockIndex = SgTypeTuple::pools.size();
   39312           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTuple) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTuple);
   39313             : 
   39314           2 :     while ( (blockIndex * SgTypeTuple::pool_size) < newPoolSize)
   39315             :       {
   39316             : #if ROSE_ALLOC_TRACE
   39317             :         if (blockIndex > 0) {
   39318             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTuple) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTuple) = %" PRIuPTR " SgTypeTuple::pool_size = %d \n",
   39319             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTuple),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTuple),SgTypeTuple::pool_size);
   39320             :         }
   39321             : #endif
   39322             : 
   39323           0 :         SgTypeTuple * pointer = (SgTypeTuple*) ROSE_MALLOC ( SgTypeTuple::pool_size * sizeof(SgTypeTuple) );
   39324           0 :         assert( pointer != NULL );
   39325             : #if ROSE_ALLOC_MEMSET == 1
   39326             :         memset(pointer, 0x00, SgTypeTuple::pool_size * sizeof(SgTypeTuple));
   39327             : #elif ROSE_ALLOC_MEMSET == 2
   39328             :         memset(pointer, 0xCC, SgTypeTuple::pool_size * sizeof(SgTypeTuple));
   39329             : #endif
   39330           0 :         SgTypeTuple::pools.push_back( (unsigned char*)(pointer) );
   39331           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeTuple::pool_size * sizeof(SgTypeTuple), V_SgTypeTuple ) );
   39332             : 
   39333           0 :         if ( SgTypeTuple::next_node != NULL ) {
   39334           0 :           if ( blockIndex > 0 ) {
   39335           0 :             SgTypeTuple * blkptr = (SgTypeTuple*)(SgTypeTuple::pools[blockIndex-1]);
   39336           0 :             blkptr[ SgTypeTuple::pool_size - 1 ].set_freepointer(pointer);
   39337             :           }
   39338             :         } else {
   39339           0 :           SgTypeTuple::next_node = pointer;
   39340             :         }
   39341             : 
   39342           0 :         for (unsigned i = 0; i < SgTypeTuple::pool_size-1; ++i)
   39343             :            {
   39344           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   39345             :            }
   39346           0 :         pointer[ SgTypeTuple::pool_size -1 ].set_freepointer(NULL);
   39347             : 
   39348           0 :         blockIndex++;
   39349             :       }
   39350           2 :   }
   39351             : 
   39352             : //############################################################################
   39353             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   39354             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   39355             :  * not compressed. However, that stuff is not yet implemented! 
   39356             :  */
   39357             : unsigned long
   39358           0 : SgTypeTuple::getNumberOfLastValidPointer()
   39359             :    {
   39360           0 :       SgTypeTuple* testPointer = (SgTypeTuple*)(SgTypeTuple::pools.back());
   39361           0 :       unsigned long localIndex = SgTypeTuple::pool_size - 1;
   39362           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   39363             :          {
   39364           0 :            localIndex--;
   39365             :          }
   39366           0 :       return (localIndex + SgTypeTuple::pool_size * (SgTypeTuple::pools.size()-1));
   39367             :    }
   39368             : 
   39369             : //############################################################################
   39370             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   39371             :  * memory pool and initializes the data member in class SgTypeTupleStroageClass
   39372             :  * from its counterpart of SgTypeTuple. The return value is just for checking, 
   39373             :  * that the whole StorageClassArray is initialized!
   39374             :  */
   39375             : unsigned long
   39376           0 : SgTypeTuple::initializeStorageClassArray( SgTypeTupleStorageClass *storageArray )
   39377             :    {
   39378           0 :      unsigned long storageCounter = 0;
   39379           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeTuple::pools.begin();
   39380           0 :      SgTypeTuple* pointer = NULL;
   39381           0 :      while ( block != SgTypeTuple::pools.end() ) {
   39382           0 :           pointer = (SgTypeTuple*) (*block);
   39383           0 :           for ( unsigned i = 0; i < SgTypeTuple::pool_size; ++i ) {
   39384           0 :                if ( pointer->get_freepointer() != NULL ) {
   39385           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   39386           0 :                  storageArray++;
   39387           0 :                  storageCounter++;
   39388             :                }
   39389           0 :                pointer++;
   39390             :              }
   39391           0 :            block++;
   39392             :         }
   39393           0 :      return storageCounter;
   39394             :    }
   39395             : 
   39396             : /* #line 39397 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   39397             : 
   39398             : 
   39399             : 
   39400             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   39401             : 
   39402             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   39403             : 
   39404             : //############################################################################
   39405             : /* JH (02/02/2006) Constructor of the IR node SgTypeChar16 that takes its 
   39406             :  * corresponding StorageClass as parameter
   39407             :  */
   39408           1 : SgTypeChar16 :: SgTypeChar16 ( const SgTypeChar16StorageClass& storageSource )   : SgType (storageSource)
   39409             :    {
   39410             : 
   39411             : 
   39412             : /* #line 39413 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   39413             : 
   39414           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   39415             : 
   39416             : 
   39417             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   39418             : 
   39419             : 
   39420           1 :    }
   39421             : 
   39422             : //############################################################################
   39423             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   39424             :  * within the working AST. 
   39425             :  */
   39426         151 : SgTypeChar16 * SgTypeChar16::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   39427         151 :      SgTypeChar16* returnPointer = NULL;
   39428         151 :      if ( globalIndex != 0 )
   39429             :         {
   39430             : 
   39431             : #if FILE_IO_EXTRA_CHECK
   39432         151 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeChar16 ) ) <= globalIndex ) ;
   39433         151 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeChar16 + 1 ) ) );
   39434             : #endif
   39435         151 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeChar16 )  
   39436         151 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeChar16 );
   39437         151 :           unsigned long positionInPool = localIndex % SgTypeChar16::pool_size;
   39438         151 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeChar16::pool_size;
   39439             : 
   39440             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   39441             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   39442             : 
   39443         151 :           returnPointer = &( ( (SgTypeChar16*)(SgTypeChar16::pools[memoryBlock]) ) [positionInPool]) ;
   39444             : 
   39445         151 :           ROSE_ASSERT( returnPointer != NULL ) ;
   39446             :         }
   39447         151 :      return returnPointer ;
   39448             :    }
   39449             : 
   39450             : //############################################################################
   39451             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   39452             :   for the AST with the index astIndex
   39453             : */
   39454           0 : SgTypeChar16 * SgTypeChar16::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   39455           0 :      SgTypeChar16* returnPointer = NULL;
   39456           0 :      if ( globalIndex != 0 )
   39457             :         {
   39458             : 
   39459             : #if FILE_IO_EXTRA_CHECK
   39460           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeChar16 ) ) <= globalIndex ) ;
   39461           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeChar16 + 1 ) ) );
   39462             : #endif
   39463           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeChar16 )
   39464           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeChar16 );
   39465           0 :           unsigned long positionInPool = localIndex % SgTypeChar16::pool_size ;
   39466           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeChar16::pool_size ;
   39467             : 
   39468             : #if FILE_IO_EXTRA_CHECK
   39469             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   39470             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   39471             : #endif
   39472             : 
   39473           0 :           returnPointer = &( ( (SgTypeChar16*)(SgTypeChar16::pools[memoryBlock]) ) [positionInPool]) ;
   39474             : 
   39475             : #if FILE_IO_EXTRA_CHECK
   39476           0 :           assert ( returnPointer != NULL ) ;
   39477             : #endif
   39478             :         }
   39479           0 :      return returnPointer ;
   39480             :    }
   39481             : 
   39482             : //############################################################################
   39483             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   39484             :  * pool size! We set for every valid object in the memory pool the freepointer
   39485             :  * to the global index and increase the global index afterwards. For all the 
   39486             :  * invalid objects (means address ranges within the memory pool that were not
   39487             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   39488             :  * distinguish valid from invalid objects! 
   39489             :  */
   39490             : unsigned long
   39491           5 : SgTypeChar16::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   39492             :    {
   39493           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   39494           5 :      SgTypeChar16* pointer = NULL;
   39495           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   39496           5 :      std::vector < unsigned char* > :: const_iterator block;
   39497           6 :      for ( block = SgTypeChar16::pools.begin(); block != SgTypeChar16::pools.end() ; ++block )
   39498             :         {
   39499           1 :           pointer = (SgTypeChar16*)(*block);
   39500        2001 :           for (unsigned i = 0; i < SgTypeChar16::pool_size; ++i )
   39501             :              {
   39502             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   39503             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   39504             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   39505             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   39506             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   39507             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   39508             :             // properly; so this will have to be checked next.
   39509             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   39510             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   39511        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   39512             :                   {
   39513           1 :                     pointer[i].set_freepointer((SgTypeChar16*)(globalIndex));
   39514           1 :                     globalIndex++;
   39515             :                   }
   39516             :                else
   39517             :                   {
   39518        1999 :                     pointer[i].set_freepointer(NULL);
   39519             :                   }
   39520             :               }
   39521             :         }
   39522           5 :      return globalIndex;
   39523             :    }
   39524             : 
   39525             : //############################################################################
   39526             : // JH (01/14/2006)
   39527             : void
   39528           5 : SgTypeChar16::resetValidFreepointers( )
   39529             :    {
   39530           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   39531           5 :      SgTypeChar16* pointer = NULL;
   39532           5 :      std::vector < unsigned char* > :: const_iterator block;
   39533           5 :      SgTypeChar16* pointerOfLinkedList = NULL;
   39534           6 :      for ( block = SgTypeChar16::pools.begin(); block != SgTypeChar16::pools.end() ; ++block )
   39535             :         {
   39536           1 :           pointer = (SgTypeChar16*)(*block);
   39537        2001 :           for (unsigned i = 0; i < SgTypeChar16::pool_size; ++i )
   39538             :              {
   39539             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   39540             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   39541             :             // memory blocks!.
   39542        2000 :                if ( pointer[i].get_freepointer() != NULL )
   39543             :                   {
   39544           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   39545             :                   }
   39546             :                else
   39547             :                   {
   39548        1999 :                     if ( pointerOfLinkedList == NULL )
   39549             :                        {
   39550           1 :                          SgTypeChar16::next_node = &(pointer[i]);
   39551             :                        }
   39552             :                     else
   39553             :                        {
   39554             :                       // printf ("In SgTypeChar16::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   39555        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   39556             :                        }
   39557             :                     pointerOfLinkedList = &(pointer[i]);
   39558             :                   }
   39559             :               }
   39560             :         }
   39561             : 
   39562           5 :      if ( pointerOfLinkedList != NULL )
   39563             :         {
   39564             :        // printf ("In SgTypeChar16::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   39565           1 :           pointerOfLinkedList->set_freepointer(NULL);
   39566             :        // DQ (6/6/2010): Temporary debugging...
   39567             :        //   ROSE_ASSERT(false);
   39568             :         }
   39569             : 
   39570           5 :      return ;
   39571             :    }
   39572             : 
   39573             : //############################################################################
   39574             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   39575             :  * within the memory pool and resets the freepointers, in order to achieve a 
   39576             :  * linked list, that has no jumps and starts at the beginning! This function 
   39577             :  * does not extend the memory pool, since we do not delete any memory blocks,
   39578             :  * but delete the valid objects.  
   39579             :  */
   39580             : void
   39581           0 : SgTypeChar16::clearMemoryPool( )
   39582             :    {
   39583             :   // printf ("Inside of SgTypeChar16::clearMemoryPool() \n");
   39584             : 
   39585           0 :      SgTypeChar16* pointer = NULL, *tempPointer = NULL;
   39586           0 :      std::vector < unsigned char* > :: const_iterator block;
   39587           0 :      if ( SgTypeChar16::pools.empty() == false )
   39588             :         {
   39589           0 :           block = SgTypeChar16::pools.begin() ;
   39590           0 :           SgTypeChar16::next_node = (SgTypeChar16*) (*block);
   39591             : 
   39592           0 :           while ( block != SgTypeChar16::pools.end() )
   39593             :              {
   39594           0 :                pointer = (SgTypeChar16*) (*block);
   39595           0 :                if ( tempPointer != NULL )
   39596             :                   {
   39597           0 :                     tempPointer->set_freepointer(pointer);
   39598             :                   }
   39599           0 :                for (unsigned i = 0; i < SgTypeChar16::pool_size - 1; ++i)
   39600             :                   {
   39601           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   39602             :                   }
   39603           0 :                 pointer[SgTypeChar16::pool_size-1].set_freepointer(NULL);
   39604           0 :                 tempPointer = &(pointer[SgTypeChar16::pool_size-1]);
   39605           0 :                 ++block;
   39606             :              }
   39607             :         }
   39608           0 :    }
   39609             : 
   39610           5 : void SgTypeChar16::deleteMemoryPool() {
   39611           7 :   for (auto p: SgTypeChar16::pools) {
   39612           2 :     ROSE_FREE(p);
   39613             :   }
   39614           5 :   SgTypeChar16::next_node = nullptr;
   39615           5 :   SgTypeChar16::pools.clear();
   39616           5 : }
   39617             : 
   39618             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   39619             : //                 reading multiple binary files to for a single AST.
   39620             : /////////// new version ////////////////////////////////
   39621             : //############################################################################
   39622             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   39623             : void
   39624           2 : SgTypeChar16::extendMemoryPoolForFileIO( )
   39625             :   {
   39626           2 :     size_t blockIndex = SgTypeChar16::pools.size();
   39627           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar16) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar16);
   39628             : 
   39629           3 :     while ( (blockIndex * SgTypeChar16::pool_size) < newPoolSize)
   39630             :       {
   39631             : #if ROSE_ALLOC_TRACE
   39632             :         if (blockIndex > 0) {
   39633             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar16) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar16) = %" PRIuPTR " SgTypeChar16::pool_size = %d \n",
   39634             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar16),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar16),SgTypeChar16::pool_size);
   39635             :         }
   39636             : #endif
   39637             : 
   39638           1 :         SgTypeChar16 * pointer = (SgTypeChar16*) ROSE_MALLOC ( SgTypeChar16::pool_size * sizeof(SgTypeChar16) );
   39639           1 :         assert( pointer != NULL );
   39640             : #if ROSE_ALLOC_MEMSET == 1
   39641             :         memset(pointer, 0x00, SgTypeChar16::pool_size * sizeof(SgTypeChar16));
   39642             : #elif ROSE_ALLOC_MEMSET == 2
   39643             :         memset(pointer, 0xCC, SgTypeChar16::pool_size * sizeof(SgTypeChar16));
   39644             : #endif
   39645           1 :         SgTypeChar16::pools.push_back( (unsigned char*)(pointer) );
   39646           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeChar16::pool_size * sizeof(SgTypeChar16), V_SgTypeChar16 ) );
   39647             : 
   39648           1 :         if ( SgTypeChar16::next_node != NULL ) {
   39649           0 :           if ( blockIndex > 0 ) {
   39650           0 :             SgTypeChar16 * blkptr = (SgTypeChar16*)(SgTypeChar16::pools[blockIndex-1]);
   39651           0 :             blkptr[ SgTypeChar16::pool_size - 1 ].set_freepointer(pointer);
   39652             :           }
   39653             :         } else {
   39654           1 :           SgTypeChar16::next_node = pointer;
   39655             :         }
   39656             : 
   39657        2000 :         for (unsigned i = 0; i < SgTypeChar16::pool_size-1; ++i)
   39658             :            {
   39659        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   39660             :            }
   39661           1 :         pointer[ SgTypeChar16::pool_size -1 ].set_freepointer(NULL);
   39662             : 
   39663           1 :         blockIndex++;
   39664             :       }
   39665           2 :   }
   39666             : 
   39667             : //############################################################################
   39668             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   39669             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   39670             :  * not compressed. However, that stuff is not yet implemented! 
   39671             :  */
   39672             : unsigned long
   39673           0 : SgTypeChar16::getNumberOfLastValidPointer()
   39674             :    {
   39675           0 :       SgTypeChar16* testPointer = (SgTypeChar16*)(SgTypeChar16::pools.back());
   39676           0 :       unsigned long localIndex = SgTypeChar16::pool_size - 1;
   39677           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   39678             :          {
   39679           0 :            localIndex--;
   39680             :          }
   39681           0 :       return (localIndex + SgTypeChar16::pool_size * (SgTypeChar16::pools.size()-1));
   39682             :    }
   39683             : 
   39684             : //############################################################################
   39685             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   39686             :  * memory pool and initializes the data member in class SgTypeChar16StroageClass
   39687             :  * from its counterpart of SgTypeChar16. The return value is just for checking, 
   39688             :  * that the whole StorageClassArray is initialized!
   39689             :  */
   39690             : unsigned long
   39691           1 : SgTypeChar16::initializeStorageClassArray( SgTypeChar16StorageClass *storageArray )
   39692             :    {
   39693           1 :      unsigned long storageCounter = 0;
   39694           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeChar16::pools.begin();
   39695           1 :      SgTypeChar16* pointer = NULL;
   39696           2 :      while ( block != SgTypeChar16::pools.end() ) {
   39697           1 :           pointer = (SgTypeChar16*) (*block);
   39698        2001 :           for ( unsigned i = 0; i < SgTypeChar16::pool_size; ++i ) {
   39699        2000 :                if ( pointer->get_freepointer() != NULL ) {
   39700           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   39701           1 :                  storageArray++;
   39702           1 :                  storageCounter++;
   39703             :                }
   39704        2000 :                pointer++;
   39705             :              }
   39706           1 :            block++;
   39707             :         }
   39708           1 :      return storageCounter;
   39709             :    }
   39710             : 
   39711             : /* #line 39712 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   39712             : 
   39713             : 
   39714             : 
   39715             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   39716             : 
   39717             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   39718             : 
   39719             : //############################################################################
   39720             : /* JH (02/02/2006) Constructor of the IR node SgTypeChar32 that takes its 
   39721             :  * corresponding StorageClass as parameter
   39722             :  */
   39723           1 : SgTypeChar32 :: SgTypeChar32 ( const SgTypeChar32StorageClass& storageSource )   : SgType (storageSource)
   39724             :    {
   39725             : 
   39726             : 
   39727             : /* #line 39728 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   39728             : 
   39729           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   39730             : 
   39731             : 
   39732             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   39733             : 
   39734             : 
   39735           1 :    }
   39736             : 
   39737             : //############################################################################
   39738             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   39739             :  * within the working AST. 
   39740             :  */
   39741         151 : SgTypeChar32 * SgTypeChar32::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   39742         151 :      SgTypeChar32* returnPointer = NULL;
   39743         151 :      if ( globalIndex != 0 )
   39744             :         {
   39745             : 
   39746             : #if FILE_IO_EXTRA_CHECK
   39747         151 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeChar32 ) ) <= globalIndex ) ;
   39748         151 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeChar32 + 1 ) ) );
   39749             : #endif
   39750         151 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeChar32 )  
   39751         151 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeChar32 );
   39752         151 :           unsigned long positionInPool = localIndex % SgTypeChar32::pool_size;
   39753         151 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeChar32::pool_size;
   39754             : 
   39755             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   39756             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   39757             : 
   39758         151 :           returnPointer = &( ( (SgTypeChar32*)(SgTypeChar32::pools[memoryBlock]) ) [positionInPool]) ;
   39759             : 
   39760         151 :           ROSE_ASSERT( returnPointer != NULL ) ;
   39761             :         }
   39762         151 :      return returnPointer ;
   39763             :    }
   39764             : 
   39765             : //############################################################################
   39766             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   39767             :   for the AST with the index astIndex
   39768             : */
   39769           0 : SgTypeChar32 * SgTypeChar32::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   39770           0 :      SgTypeChar32* returnPointer = NULL;
   39771           0 :      if ( globalIndex != 0 )
   39772             :         {
   39773             : 
   39774             : #if FILE_IO_EXTRA_CHECK
   39775           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeChar32 ) ) <= globalIndex ) ;
   39776           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeChar32 + 1 ) ) );
   39777             : #endif
   39778           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeChar32 )
   39779           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeChar32 );
   39780           0 :           unsigned long positionInPool = localIndex % SgTypeChar32::pool_size ;
   39781           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeChar32::pool_size ;
   39782             : 
   39783             : #if FILE_IO_EXTRA_CHECK
   39784             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   39785             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   39786             : #endif
   39787             : 
   39788           0 :           returnPointer = &( ( (SgTypeChar32*)(SgTypeChar32::pools[memoryBlock]) ) [positionInPool]) ;
   39789             : 
   39790             : #if FILE_IO_EXTRA_CHECK
   39791           0 :           assert ( returnPointer != NULL ) ;
   39792             : #endif
   39793             :         }
   39794           0 :      return returnPointer ;
   39795             :    }
   39796             : 
   39797             : //############################################################################
   39798             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   39799             :  * pool size! We set for every valid object in the memory pool the freepointer
   39800             :  * to the global index and increase the global index afterwards. For all the 
   39801             :  * invalid objects (means address ranges within the memory pool that were not
   39802             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   39803             :  * distinguish valid from invalid objects! 
   39804             :  */
   39805             : unsigned long
   39806           5 : SgTypeChar32::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   39807             :    {
   39808           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   39809           5 :      SgTypeChar32* pointer = NULL;
   39810           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   39811           5 :      std::vector < unsigned char* > :: const_iterator block;
   39812           6 :      for ( block = SgTypeChar32::pools.begin(); block != SgTypeChar32::pools.end() ; ++block )
   39813             :         {
   39814           1 :           pointer = (SgTypeChar32*)(*block);
   39815        2001 :           for (unsigned i = 0; i < SgTypeChar32::pool_size; ++i )
   39816             :              {
   39817             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   39818             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   39819             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   39820             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   39821             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   39822             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   39823             :             // properly; so this will have to be checked next.
   39824             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   39825             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   39826        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   39827             :                   {
   39828           1 :                     pointer[i].set_freepointer((SgTypeChar32*)(globalIndex));
   39829           1 :                     globalIndex++;
   39830             :                   }
   39831             :                else
   39832             :                   {
   39833        1999 :                     pointer[i].set_freepointer(NULL);
   39834             :                   }
   39835             :               }
   39836             :         }
   39837           5 :      return globalIndex;
   39838             :    }
   39839             : 
   39840             : //############################################################################
   39841             : // JH (01/14/2006)
   39842             : void
   39843           5 : SgTypeChar32::resetValidFreepointers( )
   39844             :    {
   39845           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   39846           5 :      SgTypeChar32* pointer = NULL;
   39847           5 :      std::vector < unsigned char* > :: const_iterator block;
   39848           5 :      SgTypeChar32* pointerOfLinkedList = NULL;
   39849           6 :      for ( block = SgTypeChar32::pools.begin(); block != SgTypeChar32::pools.end() ; ++block )
   39850             :         {
   39851           1 :           pointer = (SgTypeChar32*)(*block);
   39852        2001 :           for (unsigned i = 0; i < SgTypeChar32::pool_size; ++i )
   39853             :              {
   39854             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   39855             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   39856             :             // memory blocks!.
   39857        2000 :                if ( pointer[i].get_freepointer() != NULL )
   39858             :                   {
   39859           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   39860             :                   }
   39861             :                else
   39862             :                   {
   39863        1999 :                     if ( pointerOfLinkedList == NULL )
   39864             :                        {
   39865           1 :                          SgTypeChar32::next_node = &(pointer[i]);
   39866             :                        }
   39867             :                     else
   39868             :                        {
   39869             :                       // printf ("In SgTypeChar32::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   39870        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   39871             :                        }
   39872             :                     pointerOfLinkedList = &(pointer[i]);
   39873             :                   }
   39874             :               }
   39875             :         }
   39876             : 
   39877           5 :      if ( pointerOfLinkedList != NULL )
   39878             :         {
   39879             :        // printf ("In SgTypeChar32::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   39880           1 :           pointerOfLinkedList->set_freepointer(NULL);
   39881             :        // DQ (6/6/2010): Temporary debugging...
   39882             :        //   ROSE_ASSERT(false);
   39883             :         }
   39884             : 
   39885           5 :      return ;
   39886             :    }
   39887             : 
   39888             : //############################################################################
   39889             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   39890             :  * within the memory pool and resets the freepointers, in order to achieve a 
   39891             :  * linked list, that has no jumps and starts at the beginning! This function 
   39892             :  * does not extend the memory pool, since we do not delete any memory blocks,
   39893             :  * but delete the valid objects.  
   39894             :  */
   39895             : void
   39896           0 : SgTypeChar32::clearMemoryPool( )
   39897             :    {
   39898             :   // printf ("Inside of SgTypeChar32::clearMemoryPool() \n");
   39899             : 
   39900           0 :      SgTypeChar32* pointer = NULL, *tempPointer = NULL;
   39901           0 :      std::vector < unsigned char* > :: const_iterator block;
   39902           0 :      if ( SgTypeChar32::pools.empty() == false )
   39903             :         {
   39904           0 :           block = SgTypeChar32::pools.begin() ;
   39905           0 :           SgTypeChar32::next_node = (SgTypeChar32*) (*block);
   39906             : 
   39907           0 :           while ( block != SgTypeChar32::pools.end() )
   39908             :              {
   39909           0 :                pointer = (SgTypeChar32*) (*block);
   39910           0 :                if ( tempPointer != NULL )
   39911             :                   {
   39912           0 :                     tempPointer->set_freepointer(pointer);
   39913             :                   }
   39914           0 :                for (unsigned i = 0; i < SgTypeChar32::pool_size - 1; ++i)
   39915             :                   {
   39916           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   39917             :                   }
   39918           0 :                 pointer[SgTypeChar32::pool_size-1].set_freepointer(NULL);
   39919           0 :                 tempPointer = &(pointer[SgTypeChar32::pool_size-1]);
   39920           0 :                 ++block;
   39921             :              }
   39922             :         }
   39923           0 :    }
   39924             : 
   39925           5 : void SgTypeChar32::deleteMemoryPool() {
   39926           7 :   for (auto p: SgTypeChar32::pools) {
   39927           2 :     ROSE_FREE(p);
   39928             :   }
   39929           5 :   SgTypeChar32::next_node = nullptr;
   39930           5 :   SgTypeChar32::pools.clear();
   39931           5 : }
   39932             : 
   39933             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   39934             : //                 reading multiple binary files to for a single AST.
   39935             : /////////// new version ////////////////////////////////
   39936             : //############################################################################
   39937             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   39938             : void
   39939           2 : SgTypeChar32::extendMemoryPoolForFileIO( )
   39940             :   {
   39941           2 :     size_t blockIndex = SgTypeChar32::pools.size();
   39942           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar32) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar32);
   39943             : 
   39944           3 :     while ( (blockIndex * SgTypeChar32::pool_size) < newPoolSize)
   39945             :       {
   39946             : #if ROSE_ALLOC_TRACE
   39947             :         if (blockIndex > 0) {
   39948             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar32) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar32) = %" PRIuPTR " SgTypeChar32::pool_size = %d \n",
   39949             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeChar32),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeChar32),SgTypeChar32::pool_size);
   39950             :         }
   39951             : #endif
   39952             : 
   39953           1 :         SgTypeChar32 * pointer = (SgTypeChar32*) ROSE_MALLOC ( SgTypeChar32::pool_size * sizeof(SgTypeChar32) );
   39954           1 :         assert( pointer != NULL );
   39955             : #if ROSE_ALLOC_MEMSET == 1
   39956             :         memset(pointer, 0x00, SgTypeChar32::pool_size * sizeof(SgTypeChar32));
   39957             : #elif ROSE_ALLOC_MEMSET == 2
   39958             :         memset(pointer, 0xCC, SgTypeChar32::pool_size * sizeof(SgTypeChar32));
   39959             : #endif
   39960           1 :         SgTypeChar32::pools.push_back( (unsigned char*)(pointer) );
   39961           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeChar32::pool_size * sizeof(SgTypeChar32), V_SgTypeChar32 ) );
   39962             : 
   39963           1 :         if ( SgTypeChar32::next_node != NULL ) {
   39964           0 :           if ( blockIndex > 0 ) {
   39965           0 :             SgTypeChar32 * blkptr = (SgTypeChar32*)(SgTypeChar32::pools[blockIndex-1]);
   39966           0 :             blkptr[ SgTypeChar32::pool_size - 1 ].set_freepointer(pointer);
   39967             :           }
   39968             :         } else {
   39969           1 :           SgTypeChar32::next_node = pointer;
   39970             :         }
   39971             : 
   39972        2000 :         for (unsigned i = 0; i < SgTypeChar32::pool_size-1; ++i)
   39973             :            {
   39974        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   39975             :            }
   39976           1 :         pointer[ SgTypeChar32::pool_size -1 ].set_freepointer(NULL);
   39977             : 
   39978           1 :         blockIndex++;
   39979             :       }
   39980           2 :   }
   39981             : 
   39982             : //############################################################################
   39983             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   39984             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   39985             :  * not compressed. However, that stuff is not yet implemented! 
   39986             :  */
   39987             : unsigned long
   39988           0 : SgTypeChar32::getNumberOfLastValidPointer()
   39989             :    {
   39990           0 :       SgTypeChar32* testPointer = (SgTypeChar32*)(SgTypeChar32::pools.back());
   39991           0 :       unsigned long localIndex = SgTypeChar32::pool_size - 1;
   39992           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   39993             :          {
   39994           0 :            localIndex--;
   39995             :          }
   39996           0 :       return (localIndex + SgTypeChar32::pool_size * (SgTypeChar32::pools.size()-1));
   39997             :    }
   39998             : 
   39999             : //############################################################################
   40000             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   40001             :  * memory pool and initializes the data member in class SgTypeChar32StroageClass
   40002             :  * from its counterpart of SgTypeChar32. The return value is just for checking, 
   40003             :  * that the whole StorageClassArray is initialized!
   40004             :  */
   40005             : unsigned long
   40006           1 : SgTypeChar32::initializeStorageClassArray( SgTypeChar32StorageClass *storageArray )
   40007             :    {
   40008           1 :      unsigned long storageCounter = 0;
   40009           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeChar32::pools.begin();
   40010           1 :      SgTypeChar32* pointer = NULL;
   40011           2 :      while ( block != SgTypeChar32::pools.end() ) {
   40012           1 :           pointer = (SgTypeChar32*) (*block);
   40013        2001 :           for ( unsigned i = 0; i < SgTypeChar32::pool_size; ++i ) {
   40014        2000 :                if ( pointer->get_freepointer() != NULL ) {
   40015           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   40016           1 :                  storageArray++;
   40017           1 :                  storageCounter++;
   40018             :                }
   40019        2000 :                pointer++;
   40020             :              }
   40021           1 :            block++;
   40022             :         }
   40023           1 :      return storageCounter;
   40024             :    }
   40025             : 
   40026             : /* #line 40027 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   40027             : 
   40028             : 
   40029             : 
   40030             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   40031             : 
   40032             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   40033             : 
   40034             : //############################################################################
   40035             : /* JH (02/02/2006) Constructor of the IR node SgTypeFloat128 that takes its 
   40036             :  * corresponding StorageClass as parameter
   40037             :  */
   40038           1 : SgTypeFloat128 :: SgTypeFloat128 ( const SgTypeFloat128StorageClass& storageSource )   : SgType (storageSource)
   40039             :    {
   40040             : 
   40041             : 
   40042             : /* #line 40043 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   40043             : 
   40044           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   40045             : 
   40046             : 
   40047             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   40048             : 
   40049             : 
   40050           1 :    }
   40051             : 
   40052             : //############################################################################
   40053             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   40054             :  * within the working AST. 
   40055             :  */
   40056           4 : SgTypeFloat128 * SgTypeFloat128::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   40057           4 :      SgTypeFloat128* returnPointer = NULL;
   40058           4 :      if ( globalIndex != 0 )
   40059             :         {
   40060             : 
   40061             : #if FILE_IO_EXTRA_CHECK
   40062           4 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeFloat128 ) ) <= globalIndex ) ;
   40063           4 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeFloat128 + 1 ) ) );
   40064             : #endif
   40065           4 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeFloat128 )  
   40066           4 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeFloat128 );
   40067           4 :           unsigned long positionInPool = localIndex % SgTypeFloat128::pool_size;
   40068           4 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeFloat128::pool_size;
   40069             : 
   40070             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   40071             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   40072             : 
   40073           4 :           returnPointer = &( ( (SgTypeFloat128*)(SgTypeFloat128::pools[memoryBlock]) ) [positionInPool]) ;
   40074             : 
   40075           4 :           ROSE_ASSERT( returnPointer != NULL ) ;
   40076             :         }
   40077           4 :      return returnPointer ;
   40078             :    }
   40079             : 
   40080             : //############################################################################
   40081             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   40082             :   for the AST with the index astIndex
   40083             : */
   40084           0 : SgTypeFloat128 * SgTypeFloat128::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   40085           0 :      SgTypeFloat128* returnPointer = NULL;
   40086           0 :      if ( globalIndex != 0 )
   40087             :         {
   40088             : 
   40089             : #if FILE_IO_EXTRA_CHECK
   40090           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeFloat128 ) ) <= globalIndex ) ;
   40091           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeFloat128 + 1 ) ) );
   40092             : #endif
   40093           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeFloat128 )
   40094           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeFloat128 );
   40095           0 :           unsigned long positionInPool = localIndex % SgTypeFloat128::pool_size ;
   40096           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeFloat128::pool_size ;
   40097             : 
   40098             : #if FILE_IO_EXTRA_CHECK
   40099             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   40100             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   40101             : #endif
   40102             : 
   40103           0 :           returnPointer = &( ( (SgTypeFloat128*)(SgTypeFloat128::pools[memoryBlock]) ) [positionInPool]) ;
   40104             : 
   40105             : #if FILE_IO_EXTRA_CHECK
   40106           0 :           assert ( returnPointer != NULL ) ;
   40107             : #endif
   40108             :         }
   40109           0 :      return returnPointer ;
   40110             :    }
   40111             : 
   40112             : //############################################################################
   40113             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   40114             :  * pool size! We set for every valid object in the memory pool the freepointer
   40115             :  * to the global index and increase the global index afterwards. For all the 
   40116             :  * invalid objects (means address ranges within the memory pool that were not
   40117             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   40118             :  * distinguish valid from invalid objects! 
   40119             :  */
   40120             : unsigned long
   40121           5 : SgTypeFloat128::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   40122             :    {
   40123           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   40124           5 :      SgTypeFloat128* pointer = NULL;
   40125           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   40126           5 :      std::vector < unsigned char* > :: const_iterator block;
   40127           6 :      for ( block = SgTypeFloat128::pools.begin(); block != SgTypeFloat128::pools.end() ; ++block )
   40128             :         {
   40129           1 :           pointer = (SgTypeFloat128*)(*block);
   40130        2001 :           for (unsigned i = 0; i < SgTypeFloat128::pool_size; ++i )
   40131             :              {
   40132             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   40133             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   40134             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   40135             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   40136             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   40137             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   40138             :             // properly; so this will have to be checked next.
   40139             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   40140             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   40141        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   40142             :                   {
   40143           1 :                     pointer[i].set_freepointer((SgTypeFloat128*)(globalIndex));
   40144           1 :                     globalIndex++;
   40145             :                   }
   40146             :                else
   40147             :                   {
   40148        1999 :                     pointer[i].set_freepointer(NULL);
   40149             :                   }
   40150             :               }
   40151             :         }
   40152           5 :      return globalIndex;
   40153             :    }
   40154             : 
   40155             : //############################################################################
   40156             : // JH (01/14/2006)
   40157             : void
   40158           5 : SgTypeFloat128::resetValidFreepointers( )
   40159             :    {
   40160           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   40161           5 :      SgTypeFloat128* pointer = NULL;
   40162           5 :      std::vector < unsigned char* > :: const_iterator block;
   40163           5 :      SgTypeFloat128* pointerOfLinkedList = NULL;
   40164           6 :      for ( block = SgTypeFloat128::pools.begin(); block != SgTypeFloat128::pools.end() ; ++block )
   40165             :         {
   40166           1 :           pointer = (SgTypeFloat128*)(*block);
   40167        2001 :           for (unsigned i = 0; i < SgTypeFloat128::pool_size; ++i )
   40168             :              {
   40169             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   40170             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   40171             :             // memory blocks!.
   40172        2000 :                if ( pointer[i].get_freepointer() != NULL )
   40173             :                   {
   40174           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   40175             :                   }
   40176             :                else
   40177             :                   {
   40178        1999 :                     if ( pointerOfLinkedList == NULL )
   40179             :                        {
   40180           1 :                          SgTypeFloat128::next_node = &(pointer[i]);
   40181             :                        }
   40182             :                     else
   40183             :                        {
   40184             :                       // printf ("In SgTypeFloat128::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   40185        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   40186             :                        }
   40187             :                     pointerOfLinkedList = &(pointer[i]);
   40188             :                   }
   40189             :               }
   40190             :         }
   40191             : 
   40192           5 :      if ( pointerOfLinkedList != NULL )
   40193             :         {
   40194             :        // printf ("In SgTypeFloat128::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   40195           1 :           pointerOfLinkedList->set_freepointer(NULL);
   40196             :        // DQ (6/6/2010): Temporary debugging...
   40197             :        //   ROSE_ASSERT(false);
   40198             :         }
   40199             : 
   40200           5 :      return ;
   40201             :    }
   40202             : 
   40203             : //############################################################################
   40204             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   40205             :  * within the memory pool and resets the freepointers, in order to achieve a 
   40206             :  * linked list, that has no jumps and starts at the beginning! This function 
   40207             :  * does not extend the memory pool, since we do not delete any memory blocks,
   40208             :  * but delete the valid objects.  
   40209             :  */
   40210             : void
   40211           0 : SgTypeFloat128::clearMemoryPool( )
   40212             :    {
   40213             :   // printf ("Inside of SgTypeFloat128::clearMemoryPool() \n");
   40214             : 
   40215           0 :      SgTypeFloat128* pointer = NULL, *tempPointer = NULL;
   40216           0 :      std::vector < unsigned char* > :: const_iterator block;
   40217           0 :      if ( SgTypeFloat128::pools.empty() == false )
   40218             :         {
   40219           0 :           block = SgTypeFloat128::pools.begin() ;
   40220           0 :           SgTypeFloat128::next_node = (SgTypeFloat128*) (*block);
   40221             : 
   40222           0 :           while ( block != SgTypeFloat128::pools.end() )
   40223             :              {
   40224           0 :                pointer = (SgTypeFloat128*) (*block);
   40225           0 :                if ( tempPointer != NULL )
   40226             :                   {
   40227           0 :                     tempPointer->set_freepointer(pointer);
   40228             :                   }
   40229           0 :                for (unsigned i = 0; i < SgTypeFloat128::pool_size - 1; ++i)
   40230             :                   {
   40231           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   40232             :                   }
   40233           0 :                 pointer[SgTypeFloat128::pool_size-1].set_freepointer(NULL);
   40234           0 :                 tempPointer = &(pointer[SgTypeFloat128::pool_size-1]);
   40235           0 :                 ++block;
   40236             :              }
   40237             :         }
   40238           0 :    }
   40239             : 
   40240           5 : void SgTypeFloat128::deleteMemoryPool() {
   40241           7 :   for (auto p: SgTypeFloat128::pools) {
   40242           2 :     ROSE_FREE(p);
   40243             :   }
   40244           5 :   SgTypeFloat128::next_node = nullptr;
   40245           5 :   SgTypeFloat128::pools.clear();
   40246           5 : }
   40247             : 
   40248             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   40249             : //                 reading multiple binary files to for a single AST.
   40250             : /////////// new version ////////////////////////////////
   40251             : //############################################################################
   40252             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   40253             : void
   40254           2 : SgTypeFloat128::extendMemoryPoolForFileIO( )
   40255             :   {
   40256           2 :     size_t blockIndex = SgTypeFloat128::pools.size();
   40257           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat128) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat128);
   40258             : 
   40259           3 :     while ( (blockIndex * SgTypeFloat128::pool_size) < newPoolSize)
   40260             :       {
   40261             : #if ROSE_ALLOC_TRACE
   40262             :         if (blockIndex > 0) {
   40263             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat128) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat128) = %" PRIuPTR " SgTypeFloat128::pool_size = %d \n",
   40264             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFloat128),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFloat128),SgTypeFloat128::pool_size);
   40265             :         }
   40266             : #endif
   40267             : 
   40268           1 :         SgTypeFloat128 * pointer = (SgTypeFloat128*) ROSE_MALLOC ( SgTypeFloat128::pool_size * sizeof(SgTypeFloat128) );
   40269           1 :         assert( pointer != NULL );
   40270             : #if ROSE_ALLOC_MEMSET == 1
   40271             :         memset(pointer, 0x00, SgTypeFloat128::pool_size * sizeof(SgTypeFloat128));
   40272             : #elif ROSE_ALLOC_MEMSET == 2
   40273             :         memset(pointer, 0xCC, SgTypeFloat128::pool_size * sizeof(SgTypeFloat128));
   40274             : #endif
   40275           1 :         SgTypeFloat128::pools.push_back( (unsigned char*)(pointer) );
   40276           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeFloat128::pool_size * sizeof(SgTypeFloat128), V_SgTypeFloat128 ) );
   40277             : 
   40278           1 :         if ( SgTypeFloat128::next_node != NULL ) {
   40279           0 :           if ( blockIndex > 0 ) {
   40280           0 :             SgTypeFloat128 * blkptr = (SgTypeFloat128*)(SgTypeFloat128::pools[blockIndex-1]);
   40281           0 :             blkptr[ SgTypeFloat128::pool_size - 1 ].set_freepointer(pointer);
   40282             :           }
   40283             :         } else {
   40284           1 :           SgTypeFloat128::next_node = pointer;
   40285             :         }
   40286             : 
   40287        2000 :         for (unsigned i = 0; i < SgTypeFloat128::pool_size-1; ++i)
   40288             :            {
   40289        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   40290             :            }
   40291           1 :         pointer[ SgTypeFloat128::pool_size -1 ].set_freepointer(NULL);
   40292             : 
   40293           1 :         blockIndex++;
   40294             :       }
   40295           2 :   }
   40296             : 
   40297             : //############################################################################
   40298             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   40299             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   40300             :  * not compressed. However, that stuff is not yet implemented! 
   40301             :  */
   40302             : unsigned long
   40303           0 : SgTypeFloat128::getNumberOfLastValidPointer()
   40304             :    {
   40305           0 :       SgTypeFloat128* testPointer = (SgTypeFloat128*)(SgTypeFloat128::pools.back());
   40306           0 :       unsigned long localIndex = SgTypeFloat128::pool_size - 1;
   40307           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   40308             :          {
   40309           0 :            localIndex--;
   40310             :          }
   40311           0 :       return (localIndex + SgTypeFloat128::pool_size * (SgTypeFloat128::pools.size()-1));
   40312             :    }
   40313             : 
   40314             : //############################################################################
   40315             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   40316             :  * memory pool and initializes the data member in class SgTypeFloat128StroageClass
   40317             :  * from its counterpart of SgTypeFloat128. The return value is just for checking, 
   40318             :  * that the whole StorageClassArray is initialized!
   40319             :  */
   40320             : unsigned long
   40321           1 : SgTypeFloat128::initializeStorageClassArray( SgTypeFloat128StorageClass *storageArray )
   40322             :    {
   40323           1 :      unsigned long storageCounter = 0;
   40324           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeFloat128::pools.begin();
   40325           1 :      SgTypeFloat128* pointer = NULL;
   40326           2 :      while ( block != SgTypeFloat128::pools.end() ) {
   40327           1 :           pointer = (SgTypeFloat128*) (*block);
   40328        2001 :           for ( unsigned i = 0; i < SgTypeFloat128::pool_size; ++i ) {
   40329        2000 :                if ( pointer->get_freepointer() != NULL ) {
   40330           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   40331           1 :                  storageArray++;
   40332           1 :                  storageCounter++;
   40333             :                }
   40334        2000 :                pointer++;
   40335             :              }
   40336           1 :            block++;
   40337             :         }
   40338           1 :      return storageCounter;
   40339             :    }
   40340             : 
   40341             : /* #line 40342 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   40342             : 
   40343             : 
   40344             : 
   40345             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   40346             : 
   40347             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   40348             : 
   40349             : //############################################################################
   40350             : /* JH (02/02/2006) Constructor of the IR node SgTypeFixed that takes its 
   40351             :  * corresponding StorageClass as parameter
   40352             :  */
   40353           0 : SgTypeFixed :: SgTypeFixed ( const SgTypeFixedStorageClass& storageSource )   : SgType (storageSource)
   40354             :    {
   40355             : 
   40356             : 
   40357             : /* #line 40358 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   40358             : 
   40359           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   40360           0 :      p_scale =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scale) );
   40361           0 :      p_fraction =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_fraction) );
   40362             : 
   40363             : 
   40364             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   40365             : 
   40366             : 
   40367           0 :    }
   40368             : 
   40369             : //############################################################################
   40370             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   40371             :  * within the working AST. 
   40372             :  */
   40373           0 : SgTypeFixed * SgTypeFixed::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   40374           0 :      SgTypeFixed* returnPointer = NULL;
   40375           0 :      if ( globalIndex != 0 )
   40376             :         {
   40377             : 
   40378             : #if FILE_IO_EXTRA_CHECK
   40379           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeFixed ) ) <= globalIndex ) ;
   40380           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeFixed + 1 ) ) );
   40381             : #endif
   40382           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeFixed )  
   40383           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeFixed );
   40384           0 :           unsigned long positionInPool = localIndex % SgTypeFixed::pool_size;
   40385           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeFixed::pool_size;
   40386             : 
   40387             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   40388             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   40389             : 
   40390           0 :           returnPointer = &( ( (SgTypeFixed*)(SgTypeFixed::pools[memoryBlock]) ) [positionInPool]) ;
   40391             : 
   40392           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   40393             :         }
   40394           0 :      return returnPointer ;
   40395             :    }
   40396             : 
   40397             : //############################################################################
   40398             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   40399             :   for the AST with the index astIndex
   40400             : */
   40401           0 : SgTypeFixed * SgTypeFixed::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   40402           0 :      SgTypeFixed* returnPointer = NULL;
   40403           0 :      if ( globalIndex != 0 )
   40404             :         {
   40405             : 
   40406             : #if FILE_IO_EXTRA_CHECK
   40407           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeFixed ) ) <= globalIndex ) ;
   40408           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeFixed + 1 ) ) );
   40409             : #endif
   40410           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeFixed )
   40411           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeFixed );
   40412           0 :           unsigned long positionInPool = localIndex % SgTypeFixed::pool_size ;
   40413           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeFixed::pool_size ;
   40414             : 
   40415             : #if FILE_IO_EXTRA_CHECK
   40416             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   40417             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   40418             : #endif
   40419             : 
   40420           0 :           returnPointer = &( ( (SgTypeFixed*)(SgTypeFixed::pools[memoryBlock]) ) [positionInPool]) ;
   40421             : 
   40422             : #if FILE_IO_EXTRA_CHECK
   40423           0 :           assert ( returnPointer != NULL ) ;
   40424             : #endif
   40425             :         }
   40426           0 :      return returnPointer ;
   40427             :    }
   40428             : 
   40429             : //############################################################################
   40430             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   40431             :  * pool size! We set for every valid object in the memory pool the freepointer
   40432             :  * to the global index and increase the global index afterwards. For all the 
   40433             :  * invalid objects (means address ranges within the memory pool that were not
   40434             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   40435             :  * distinguish valid from invalid objects! 
   40436             :  */
   40437             : unsigned long
   40438           5 : SgTypeFixed::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   40439             :    {
   40440           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   40441           5 :      SgTypeFixed* pointer = NULL;
   40442           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   40443           5 :      std::vector < unsigned char* > :: const_iterator block;
   40444           5 :      for ( block = SgTypeFixed::pools.begin(); block != SgTypeFixed::pools.end() ; ++block )
   40445             :         {
   40446           0 :           pointer = (SgTypeFixed*)(*block);
   40447           0 :           for (unsigned i = 0; i < SgTypeFixed::pool_size; ++i )
   40448             :              {
   40449             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   40450             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   40451             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   40452             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   40453             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   40454             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   40455             :             // properly; so this will have to be checked next.
   40456             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   40457             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   40458           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   40459             :                   {
   40460           0 :                     pointer[i].set_freepointer((SgTypeFixed*)(globalIndex));
   40461           0 :                     globalIndex++;
   40462             :                   }
   40463             :                else
   40464             :                   {
   40465           0 :                     pointer[i].set_freepointer(NULL);
   40466             :                   }
   40467             :               }
   40468             :         }
   40469           5 :      return globalIndex;
   40470             :    }
   40471             : 
   40472             : //############################################################################
   40473             : // JH (01/14/2006)
   40474             : void
   40475           5 : SgTypeFixed::resetValidFreepointers( )
   40476             :    {
   40477           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   40478           5 :      SgTypeFixed* pointer = NULL;
   40479           5 :      std::vector < unsigned char* > :: const_iterator block;
   40480           5 :      SgTypeFixed* pointerOfLinkedList = NULL;
   40481           5 :      for ( block = SgTypeFixed::pools.begin(); block != SgTypeFixed::pools.end() ; ++block )
   40482             :         {
   40483           0 :           pointer = (SgTypeFixed*)(*block);
   40484           0 :           for (unsigned i = 0; i < SgTypeFixed::pool_size; ++i )
   40485             :              {
   40486             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   40487             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   40488             :             // memory blocks!.
   40489           0 :                if ( pointer[i].get_freepointer() != NULL )
   40490             :                   {
   40491           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   40492             :                   }
   40493             :                else
   40494             :                   {
   40495           0 :                     if ( pointerOfLinkedList == NULL )
   40496             :                        {
   40497           0 :                          SgTypeFixed::next_node = &(pointer[i]);
   40498             :                        }
   40499             :                     else
   40500             :                        {
   40501             :                       // printf ("In SgTypeFixed::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   40502           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   40503             :                        }
   40504             :                     pointerOfLinkedList = &(pointer[i]);
   40505             :                   }
   40506             :               }
   40507             :         }
   40508             : 
   40509           5 :      if ( pointerOfLinkedList != NULL )
   40510             :         {
   40511             :        // printf ("In SgTypeFixed::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   40512           0 :           pointerOfLinkedList->set_freepointer(NULL);
   40513             :        // DQ (6/6/2010): Temporary debugging...
   40514             :        //   ROSE_ASSERT(false);
   40515             :         }
   40516             : 
   40517           5 :      return ;
   40518             :    }
   40519             : 
   40520             : //############################################################################
   40521             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   40522             :  * within the memory pool and resets the freepointers, in order to achieve a 
   40523             :  * linked list, that has no jumps and starts at the beginning! This function 
   40524             :  * does not extend the memory pool, since we do not delete any memory blocks,
   40525             :  * but delete the valid objects.  
   40526             :  */
   40527             : void
   40528           0 : SgTypeFixed::clearMemoryPool( )
   40529             :    {
   40530             :   // printf ("Inside of SgTypeFixed::clearMemoryPool() \n");
   40531             : 
   40532           0 :      SgTypeFixed* pointer = NULL, *tempPointer = NULL;
   40533           0 :      std::vector < unsigned char* > :: const_iterator block;
   40534           0 :      if ( SgTypeFixed::pools.empty() == false )
   40535             :         {
   40536           0 :           block = SgTypeFixed::pools.begin() ;
   40537           0 :           SgTypeFixed::next_node = (SgTypeFixed*) (*block);
   40538             : 
   40539           0 :           while ( block != SgTypeFixed::pools.end() )
   40540             :              {
   40541           0 :                pointer = (SgTypeFixed*) (*block);
   40542           0 :                if ( tempPointer != NULL )
   40543             :                   {
   40544           0 :                     tempPointer->set_freepointer(pointer);
   40545             :                   }
   40546           0 :                for (unsigned i = 0; i < SgTypeFixed::pool_size - 1; ++i)
   40547             :                   {
   40548           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   40549             :                   }
   40550           0 :                 pointer[SgTypeFixed::pool_size-1].set_freepointer(NULL);
   40551           0 :                 tempPointer = &(pointer[SgTypeFixed::pool_size-1]);
   40552           0 :                 ++block;
   40553             :              }
   40554             :         }
   40555           0 :    }
   40556             : 
   40557           5 : void SgTypeFixed::deleteMemoryPool() {
   40558           5 :   for (auto p: SgTypeFixed::pools) {
   40559           0 :     ROSE_FREE(p);
   40560             :   }
   40561           5 :   SgTypeFixed::next_node = nullptr;
   40562           5 :   SgTypeFixed::pools.clear();
   40563           5 : }
   40564             : 
   40565             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   40566             : //                 reading multiple binary files to for a single AST.
   40567             : /////////// new version ////////////////////////////////
   40568             : //############################################################################
   40569             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   40570             : void
   40571           2 : SgTypeFixed::extendMemoryPoolForFileIO( )
   40572             :   {
   40573           2 :     size_t blockIndex = SgTypeFixed::pools.size();
   40574           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFixed) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFixed);
   40575             : 
   40576           2 :     while ( (blockIndex * SgTypeFixed::pool_size) < newPoolSize)
   40577             :       {
   40578             : #if ROSE_ALLOC_TRACE
   40579             :         if (blockIndex > 0) {
   40580             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFixed) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFixed) = %" PRIuPTR " SgTypeFixed::pool_size = %d \n",
   40581             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeFixed),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeFixed),SgTypeFixed::pool_size);
   40582             :         }
   40583             : #endif
   40584             : 
   40585           0 :         SgTypeFixed * pointer = (SgTypeFixed*) ROSE_MALLOC ( SgTypeFixed::pool_size * sizeof(SgTypeFixed) );
   40586           0 :         assert( pointer != NULL );
   40587             : #if ROSE_ALLOC_MEMSET == 1
   40588             :         memset(pointer, 0x00, SgTypeFixed::pool_size * sizeof(SgTypeFixed));
   40589             : #elif ROSE_ALLOC_MEMSET == 2
   40590             :         memset(pointer, 0xCC, SgTypeFixed::pool_size * sizeof(SgTypeFixed));
   40591             : #endif
   40592           0 :         SgTypeFixed::pools.push_back( (unsigned char*)(pointer) );
   40593           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeFixed::pool_size * sizeof(SgTypeFixed), V_SgTypeFixed ) );
   40594             : 
   40595           0 :         if ( SgTypeFixed::next_node != NULL ) {
   40596           0 :           if ( blockIndex > 0 ) {
   40597           0 :             SgTypeFixed * blkptr = (SgTypeFixed*)(SgTypeFixed::pools[blockIndex-1]);
   40598           0 :             blkptr[ SgTypeFixed::pool_size - 1 ].set_freepointer(pointer);
   40599             :           }
   40600             :         } else {
   40601           0 :           SgTypeFixed::next_node = pointer;
   40602             :         }
   40603             : 
   40604           0 :         for (unsigned i = 0; i < SgTypeFixed::pool_size-1; ++i)
   40605             :            {
   40606           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   40607             :            }
   40608           0 :         pointer[ SgTypeFixed::pool_size -1 ].set_freepointer(NULL);
   40609             : 
   40610           0 :         blockIndex++;
   40611             :       }
   40612           2 :   }
   40613             : 
   40614             : //############################################################################
   40615             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   40616             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   40617             :  * not compressed. However, that stuff is not yet implemented! 
   40618             :  */
   40619             : unsigned long
   40620           0 : SgTypeFixed::getNumberOfLastValidPointer()
   40621             :    {
   40622           0 :       SgTypeFixed* testPointer = (SgTypeFixed*)(SgTypeFixed::pools.back());
   40623           0 :       unsigned long localIndex = SgTypeFixed::pool_size - 1;
   40624           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   40625             :          {
   40626           0 :            localIndex--;
   40627             :          }
   40628           0 :       return (localIndex + SgTypeFixed::pool_size * (SgTypeFixed::pools.size()-1));
   40629             :    }
   40630             : 
   40631             : //############################################################################
   40632             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   40633             :  * memory pool and initializes the data member in class SgTypeFixedStroageClass
   40634             :  * from its counterpart of SgTypeFixed. The return value is just for checking, 
   40635             :  * that the whole StorageClassArray is initialized!
   40636             :  */
   40637             : unsigned long
   40638           0 : SgTypeFixed::initializeStorageClassArray( SgTypeFixedStorageClass *storageArray )
   40639             :    {
   40640           0 :      unsigned long storageCounter = 0;
   40641           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeFixed::pools.begin();
   40642           0 :      SgTypeFixed* pointer = NULL;
   40643           0 :      while ( block != SgTypeFixed::pools.end() ) {
   40644           0 :           pointer = (SgTypeFixed*) (*block);
   40645           0 :           for ( unsigned i = 0; i < SgTypeFixed::pool_size; ++i ) {
   40646           0 :                if ( pointer->get_freepointer() != NULL ) {
   40647           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   40648           0 :                  storageArray++;
   40649           0 :                  storageCounter++;
   40650             :                }
   40651           0 :                pointer++;
   40652             :              }
   40653           0 :            block++;
   40654             :         }
   40655           0 :      return storageCounter;
   40656             :    }
   40657             : 
   40658             : /* #line 40659 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   40659             : 
   40660             : 
   40661             : 
   40662             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   40663             : 
   40664             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   40665             : 
   40666             : //############################################################################
   40667             : /* JH (02/02/2006) Constructor of the IR node SgAutoType that takes its 
   40668             :  * corresponding StorageClass as parameter
   40669             :  */
   40670          14 : SgAutoType :: SgAutoType ( const SgAutoTypeStorageClass& storageSource )   : SgType (storageSource)
   40671             :    {
   40672             : 
   40673             : 
   40674             : /* #line 40675 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   40675             : 
   40676          14 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   40677             : 
   40678             : 
   40679             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   40680             : 
   40681             : 
   40682          14 :    }
   40683             : 
   40684             : //############################################################################
   40685             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   40686             :  * within the working AST. 
   40687             :  */
   40688          38 : SgAutoType * SgAutoType::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   40689          38 :      SgAutoType* returnPointer = NULL;
   40690          38 :      if ( globalIndex != 0 )
   40691             :         {
   40692             : 
   40693             : #if FILE_IO_EXTRA_CHECK
   40694          38 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAutoType ) ) <= globalIndex ) ;
   40695          38 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAutoType + 1 ) ) );
   40696             : #endif
   40697          38 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAutoType )  
   40698          38 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAutoType );
   40699          38 :           unsigned long positionInPool = localIndex % SgAutoType::pool_size;
   40700          38 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAutoType::pool_size;
   40701             : 
   40702             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   40703             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   40704             : 
   40705          38 :           returnPointer = &( ( (SgAutoType*)(SgAutoType::pools[memoryBlock]) ) [positionInPool]) ;
   40706             : 
   40707          38 :           ROSE_ASSERT( returnPointer != NULL ) ;
   40708             :         }
   40709          38 :      return returnPointer ;
   40710             :    }
   40711             : 
   40712             : //############################################################################
   40713             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   40714             :   for the AST with the index astIndex
   40715             : */
   40716           0 : SgAutoType * SgAutoType::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   40717           0 :      SgAutoType* returnPointer = NULL;
   40718           0 :      if ( globalIndex != 0 )
   40719             :         {
   40720             : 
   40721             : #if FILE_IO_EXTRA_CHECK
   40722           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAutoType ) ) <= globalIndex ) ;
   40723           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAutoType + 1 ) ) );
   40724             : #endif
   40725           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAutoType )
   40726           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAutoType );
   40727           0 :           unsigned long positionInPool = localIndex % SgAutoType::pool_size ;
   40728           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAutoType::pool_size ;
   40729             : 
   40730             : #if FILE_IO_EXTRA_CHECK
   40731             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   40732             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   40733             : #endif
   40734             : 
   40735           0 :           returnPointer = &( ( (SgAutoType*)(SgAutoType::pools[memoryBlock]) ) [positionInPool]) ;
   40736             : 
   40737             : #if FILE_IO_EXTRA_CHECK
   40738           0 :           assert ( returnPointer != NULL ) ;
   40739             : #endif
   40740             :         }
   40741           0 :      return returnPointer ;
   40742             :    }
   40743             : 
   40744             : //############################################################################
   40745             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   40746             :  * pool size! We set for every valid object in the memory pool the freepointer
   40747             :  * to the global index and increase the global index afterwards. For all the 
   40748             :  * invalid objects (means address ranges within the memory pool that were not
   40749             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   40750             :  * distinguish valid from invalid objects! 
   40751             :  */
   40752             : unsigned long
   40753           5 : SgAutoType::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   40754             :    {
   40755           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   40756           5 :      SgAutoType* pointer = NULL;
   40757           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   40758           5 :      std::vector < unsigned char* > :: const_iterator block;
   40759           6 :      for ( block = SgAutoType::pools.begin(); block != SgAutoType::pools.end() ; ++block )
   40760             :         {
   40761           1 :           pointer = (SgAutoType*)(*block);
   40762        2001 :           for (unsigned i = 0; i < SgAutoType::pool_size; ++i )
   40763             :              {
   40764             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   40765             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   40766             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   40767             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   40768             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   40769             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   40770             :             // properly; so this will have to be checked next.
   40771             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   40772             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   40773        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   40774             :                   {
   40775          14 :                     pointer[i].set_freepointer((SgAutoType*)(globalIndex));
   40776          14 :                     globalIndex++;
   40777             :                   }
   40778             :                else
   40779             :                   {
   40780        1986 :                     pointer[i].set_freepointer(NULL);
   40781             :                   }
   40782             :               }
   40783             :         }
   40784           5 :      return globalIndex;
   40785             :    }
   40786             : 
   40787             : //############################################################################
   40788             : // JH (01/14/2006)
   40789             : void
   40790           5 : SgAutoType::resetValidFreepointers( )
   40791             :    {
   40792           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   40793           5 :      SgAutoType* pointer = NULL;
   40794           5 :      std::vector < unsigned char* > :: const_iterator block;
   40795           5 :      SgAutoType* pointerOfLinkedList = NULL;
   40796           6 :      for ( block = SgAutoType::pools.begin(); block != SgAutoType::pools.end() ; ++block )
   40797             :         {
   40798           1 :           pointer = (SgAutoType*)(*block);
   40799        2001 :           for (unsigned i = 0; i < SgAutoType::pool_size; ++i )
   40800             :              {
   40801             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   40802             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   40803             :             // memory blocks!.
   40804        2000 :                if ( pointer[i].get_freepointer() != NULL )
   40805             :                   {
   40806          14 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   40807             :                   }
   40808             :                else
   40809             :                   {
   40810        1986 :                     if ( pointerOfLinkedList == NULL )
   40811             :                        {
   40812           1 :                          SgAutoType::next_node = &(pointer[i]);
   40813             :                        }
   40814             :                     else
   40815             :                        {
   40816             :                       // printf ("In SgAutoType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   40817        1985 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   40818             :                        }
   40819             :                     pointerOfLinkedList = &(pointer[i]);
   40820             :                   }
   40821             :               }
   40822             :         }
   40823             : 
   40824           5 :      if ( pointerOfLinkedList != NULL )
   40825             :         {
   40826             :        // printf ("In SgAutoType::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   40827           1 :           pointerOfLinkedList->set_freepointer(NULL);
   40828             :        // DQ (6/6/2010): Temporary debugging...
   40829             :        //   ROSE_ASSERT(false);
   40830             :         }
   40831             : 
   40832           5 :      return ;
   40833             :    }
   40834             : 
   40835             : //############################################################################
   40836             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   40837             :  * within the memory pool and resets the freepointers, in order to achieve a 
   40838             :  * linked list, that has no jumps and starts at the beginning! This function 
   40839             :  * does not extend the memory pool, since we do not delete any memory blocks,
   40840             :  * but delete the valid objects.  
   40841             :  */
   40842             : void
   40843           0 : SgAutoType::clearMemoryPool( )
   40844             :    {
   40845             :   // printf ("Inside of SgAutoType::clearMemoryPool() \n");
   40846             : 
   40847           0 :      SgAutoType* pointer = NULL, *tempPointer = NULL;
   40848           0 :      std::vector < unsigned char* > :: const_iterator block;
   40849           0 :      if ( SgAutoType::pools.empty() == false )
   40850             :         {
   40851           0 :           block = SgAutoType::pools.begin() ;
   40852           0 :           SgAutoType::next_node = (SgAutoType*) (*block);
   40853             : 
   40854           0 :           while ( block != SgAutoType::pools.end() )
   40855             :              {
   40856           0 :                pointer = (SgAutoType*) (*block);
   40857           0 :                if ( tempPointer != NULL )
   40858             :                   {
   40859           0 :                     tempPointer->set_freepointer(pointer);
   40860             :                   }
   40861           0 :                for (unsigned i = 0; i < SgAutoType::pool_size - 1; ++i)
   40862             :                   {
   40863           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   40864             :                   }
   40865           0 :                 pointer[SgAutoType::pool_size-1].set_freepointer(NULL);
   40866           0 :                 tempPointer = &(pointer[SgAutoType::pool_size-1]);
   40867           0 :                 ++block;
   40868             :              }
   40869             :         }
   40870           0 :    }
   40871             : 
   40872           5 : void SgAutoType::deleteMemoryPool() {
   40873           7 :   for (auto p: SgAutoType::pools) {
   40874           2 :     ROSE_FREE(p);
   40875             :   }
   40876           5 :   SgAutoType::next_node = nullptr;
   40877           5 :   SgAutoType::pools.clear();
   40878           5 : }
   40879             : 
   40880             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   40881             : //                 reading multiple binary files to for a single AST.
   40882             : /////////// new version ////////////////////////////////
   40883             : //############################################################################
   40884             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   40885             : void
   40886           2 : SgAutoType::extendMemoryPoolForFileIO( )
   40887             :   {
   40888           2 :     size_t blockIndex = SgAutoType::pools.size();
   40889           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAutoType) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAutoType);
   40890             : 
   40891           3 :     while ( (blockIndex * SgAutoType::pool_size) < newPoolSize)
   40892             :       {
   40893             : #if ROSE_ALLOC_TRACE
   40894             :         if (blockIndex > 0) {
   40895             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAutoType) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAutoType) = %" PRIuPTR " SgAutoType::pool_size = %d \n",
   40896             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAutoType),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAutoType),SgAutoType::pool_size);
   40897             :         }
   40898             : #endif
   40899             : 
   40900           1 :         SgAutoType * pointer = (SgAutoType*) ROSE_MALLOC ( SgAutoType::pool_size * sizeof(SgAutoType) );
   40901           1 :         assert( pointer != NULL );
   40902             : #if ROSE_ALLOC_MEMSET == 1
   40903             :         memset(pointer, 0x00, SgAutoType::pool_size * sizeof(SgAutoType));
   40904             : #elif ROSE_ALLOC_MEMSET == 2
   40905             :         memset(pointer, 0xCC, SgAutoType::pool_size * sizeof(SgAutoType));
   40906             : #endif
   40907           1 :         SgAutoType::pools.push_back( (unsigned char*)(pointer) );
   40908           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAutoType::pool_size * sizeof(SgAutoType), V_SgAutoType ) );
   40909             : 
   40910           1 :         if ( SgAutoType::next_node != NULL ) {
   40911           0 :           if ( blockIndex > 0 ) {
   40912           0 :             SgAutoType * blkptr = (SgAutoType*)(SgAutoType::pools[blockIndex-1]);
   40913           0 :             blkptr[ SgAutoType::pool_size - 1 ].set_freepointer(pointer);
   40914             :           }
   40915             :         } else {
   40916           1 :           SgAutoType::next_node = pointer;
   40917             :         }
   40918             : 
   40919        2000 :         for (unsigned i = 0; i < SgAutoType::pool_size-1; ++i)
   40920             :            {
   40921        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   40922             :            }
   40923           1 :         pointer[ SgAutoType::pool_size -1 ].set_freepointer(NULL);
   40924             : 
   40925           1 :         blockIndex++;
   40926             :       }
   40927           2 :   }
   40928             : 
   40929             : //############################################################################
   40930             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   40931             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   40932             :  * not compressed. However, that stuff is not yet implemented! 
   40933             :  */
   40934             : unsigned long
   40935           0 : SgAutoType::getNumberOfLastValidPointer()
   40936             :    {
   40937           0 :       SgAutoType* testPointer = (SgAutoType*)(SgAutoType::pools.back());
   40938           0 :       unsigned long localIndex = SgAutoType::pool_size - 1;
   40939           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   40940             :          {
   40941           0 :            localIndex--;
   40942             :          }
   40943           0 :       return (localIndex + SgAutoType::pool_size * (SgAutoType::pools.size()-1));
   40944             :    }
   40945             : 
   40946             : //############################################################################
   40947             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   40948             :  * memory pool and initializes the data member in class SgAutoTypeStroageClass
   40949             :  * from its counterpart of SgAutoType. The return value is just for checking, 
   40950             :  * that the whole StorageClassArray is initialized!
   40951             :  */
   40952             : unsigned long
   40953           1 : SgAutoType::initializeStorageClassArray( SgAutoTypeStorageClass *storageArray )
   40954             :    {
   40955           1 :      unsigned long storageCounter = 0;
   40956           1 :      std::vector < unsigned char* > :: const_iterator block = SgAutoType::pools.begin();
   40957           1 :      SgAutoType* pointer = NULL;
   40958           2 :      while ( block != SgAutoType::pools.end() ) {
   40959           1 :           pointer = (SgAutoType*) (*block);
   40960        2001 :           for ( unsigned i = 0; i < SgAutoType::pool_size; ++i ) {
   40961        2000 :                if ( pointer->get_freepointer() != NULL ) {
   40962          14 :                  storageArray->pickOutIRNodeData (pointer) ;
   40963          14 :                  storageArray++;
   40964          14 :                  storageCounter++;
   40965             :                }
   40966        2000 :                pointer++;
   40967             :              }
   40968           1 :            block++;
   40969             :         }
   40970           1 :      return storageCounter;
   40971             :    }
   40972             : 
   40973             : /* #line 40974 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   40974             : 
   40975             : 
   40976             : 
   40977             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   40978             : 
   40979             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   40980             : 
   40981             : //############################################################################
   40982             : /* JH (02/02/2006) Constructor of the IR node SgLocatedNode that takes its 
   40983             :  * corresponding StorageClass as parameter
   40984             :  */
   40985      156220 : SgLocatedNode :: SgLocatedNode ( const SgLocatedNodeStorageClass& storageSource )   : SgNode (storageSource)
   40986             :    {
   40987             : 
   40988             : 
   40989             : /* #line 40990 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   40990             : 
   40991      156220 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   40992      156220 :      p_startOfConstruct =  (Sg_File_Info*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_startOfConstruct) );
   40993      156220 :      p_endOfConstruct =  (Sg_File_Info*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_endOfConstruct) );
   40994      156220 :      p_attachedPreprocessingInfoPtr = storageSource.storageOf_attachedPreprocessingInfoPtr.rebuildDataStoredInEasyStorageClass() ;
   40995      156220 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
   40996      156220 :      p_containsTransformationToSurroundingWhitespace = storageSource.storageOf_containsTransformationToSurroundingWhitespace ;
   40997             : 
   40998             : 
   40999             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   41000             : 
   41001             : 
   41002      156220 :    }
   41003             : 
   41004             : //############################################################################
   41005             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   41006             :  * within the working AST. 
   41007             :  */
   41008           0 : SgLocatedNode * SgLocatedNode::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   41009           0 :      SgLocatedNode* returnPointer = NULL;
   41010           0 :      if ( globalIndex != 0 )
   41011             :         {
   41012             : 
   41013             : #if FILE_IO_EXTRA_CHECK
   41014           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLocatedNode ) ) <= globalIndex ) ;
   41015           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLocatedNode + 1 ) ) );
   41016             : #endif
   41017           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLocatedNode )  
   41018           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLocatedNode );
   41019           0 :           unsigned long positionInPool = localIndex % SgLocatedNode::pool_size;
   41020           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLocatedNode::pool_size;
   41021             : 
   41022             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   41023             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   41024             : 
   41025           0 :           returnPointer = &( ( (SgLocatedNode*)(SgLocatedNode::pools[memoryBlock]) ) [positionInPool]) ;
   41026             : 
   41027           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   41028             :         }
   41029           0 :      return returnPointer ;
   41030             :    }
   41031             : 
   41032             : //############################################################################
   41033             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   41034             :   for the AST with the index astIndex
   41035             : */
   41036           0 : SgLocatedNode * SgLocatedNode::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   41037           0 :      SgLocatedNode* returnPointer = NULL;
   41038           0 :      if ( globalIndex != 0 )
   41039             :         {
   41040             : 
   41041             : #if FILE_IO_EXTRA_CHECK
   41042           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLocatedNode ) ) <= globalIndex ) ;
   41043           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLocatedNode + 1 ) ) );
   41044             : #endif
   41045           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLocatedNode )
   41046           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLocatedNode );
   41047           0 :           unsigned long positionInPool = localIndex % SgLocatedNode::pool_size ;
   41048           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLocatedNode::pool_size ;
   41049             : 
   41050             : #if FILE_IO_EXTRA_CHECK
   41051             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   41052             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   41053             : #endif
   41054             : 
   41055           0 :           returnPointer = &( ( (SgLocatedNode*)(SgLocatedNode::pools[memoryBlock]) ) [positionInPool]) ;
   41056             : 
   41057             : #if FILE_IO_EXTRA_CHECK
   41058           0 :           assert ( returnPointer != NULL ) ;
   41059             : #endif
   41060             :         }
   41061           0 :      return returnPointer ;
   41062             :    }
   41063             : 
   41064             : //############################################################################
   41065             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   41066             :  * pool size! We set for every valid object in the memory pool the freepointer
   41067             :  * to the global index and increase the global index afterwards. For all the 
   41068             :  * invalid objects (means address ranges within the memory pool that were not
   41069             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   41070             :  * distinguish valid from invalid objects! 
   41071             :  */
   41072             : unsigned long
   41073           5 : SgLocatedNode::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   41074             :    {
   41075           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   41076           5 :      SgLocatedNode* pointer = NULL;
   41077           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   41078           5 :      std::vector < unsigned char* > :: const_iterator block;
   41079           5 :      for ( block = SgLocatedNode::pools.begin(); block != SgLocatedNode::pools.end() ; ++block )
   41080             :         {
   41081           0 :           pointer = (SgLocatedNode*)(*block);
   41082           0 :           for (unsigned i = 0; i < SgLocatedNode::pool_size; ++i )
   41083             :              {
   41084             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   41085             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   41086             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   41087             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   41088             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   41089             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   41090             :             // properly; so this will have to be checked next.
   41091             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   41092             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   41093           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   41094             :                   {
   41095           0 :                     pointer[i].set_freepointer((SgLocatedNode*)(globalIndex));
   41096           0 :                     globalIndex++;
   41097             :                   }
   41098             :                else
   41099             :                   {
   41100           0 :                     pointer[i].set_freepointer(NULL);
   41101             :                   }
   41102             :               }
   41103             :         }
   41104           5 :      return globalIndex;
   41105             :    }
   41106             : 
   41107             : //############################################################################
   41108             : // JH (01/14/2006)
   41109             : void
   41110           5 : SgLocatedNode::resetValidFreepointers( )
   41111             :    {
   41112           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   41113           5 :      SgLocatedNode* pointer = NULL;
   41114           5 :      std::vector < unsigned char* > :: const_iterator block;
   41115           5 :      SgLocatedNode* pointerOfLinkedList = NULL;
   41116           5 :      for ( block = SgLocatedNode::pools.begin(); block != SgLocatedNode::pools.end() ; ++block )
   41117             :         {
   41118           0 :           pointer = (SgLocatedNode*)(*block);
   41119           0 :           for (unsigned i = 0; i < SgLocatedNode::pool_size; ++i )
   41120             :              {
   41121             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   41122             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   41123             :             // memory blocks!.
   41124           0 :                if ( pointer[i].get_freepointer() != NULL )
   41125             :                   {
   41126           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   41127             :                   }
   41128             :                else
   41129             :                   {
   41130           0 :                     if ( pointerOfLinkedList == NULL )
   41131             :                        {
   41132           0 :                          SgLocatedNode::next_node = &(pointer[i]);
   41133             :                        }
   41134             :                     else
   41135             :                        {
   41136             :                       // printf ("In SgLocatedNode::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   41137           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   41138             :                        }
   41139             :                     pointerOfLinkedList = &(pointer[i]);
   41140             :                   }
   41141             :               }
   41142             :         }
   41143             : 
   41144           5 :      if ( pointerOfLinkedList != NULL )
   41145             :         {
   41146             :        // printf ("In SgLocatedNode::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   41147           0 :           pointerOfLinkedList->set_freepointer(NULL);
   41148             :        // DQ (6/6/2010): Temporary debugging...
   41149             :        //   ROSE_ASSERT(false);
   41150             :         }
   41151             : 
   41152           5 :      return ;
   41153             :    }
   41154             : 
   41155             : //############################################################################
   41156             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   41157             :  * within the memory pool and resets the freepointers, in order to achieve a 
   41158             :  * linked list, that has no jumps and starts at the beginning! This function 
   41159             :  * does not extend the memory pool, since we do not delete any memory blocks,
   41160             :  * but delete the valid objects.  
   41161             :  */
   41162             : void
   41163           0 : SgLocatedNode::clearMemoryPool( )
   41164             :    {
   41165             :   // printf ("Inside of SgLocatedNode::clearMemoryPool() \n");
   41166             : 
   41167           0 :      SgLocatedNode* pointer = NULL, *tempPointer = NULL;
   41168           0 :      std::vector < unsigned char* > :: const_iterator block;
   41169           0 :      if ( SgLocatedNode::pools.empty() == false )
   41170             :         {
   41171           0 :           block = SgLocatedNode::pools.begin() ;
   41172           0 :           SgLocatedNode::next_node = (SgLocatedNode*) (*block);
   41173             : 
   41174           0 :           while ( block != SgLocatedNode::pools.end() )
   41175             :              {
   41176           0 :                pointer = (SgLocatedNode*) (*block);
   41177           0 :                if ( tempPointer != NULL )
   41178             :                   {
   41179           0 :                     tempPointer->set_freepointer(pointer);
   41180             :                   }
   41181           0 :                for (unsigned i = 0; i < SgLocatedNode::pool_size - 1; ++i)
   41182             :                   {
   41183           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   41184             :                   }
   41185           0 :                 pointer[SgLocatedNode::pool_size-1].set_freepointer(NULL);
   41186           0 :                 tempPointer = &(pointer[SgLocatedNode::pool_size-1]);
   41187           0 :                 ++block;
   41188             :              }
   41189             :         }
   41190           0 :    }
   41191             : 
   41192           5 : void SgLocatedNode::deleteMemoryPool() {
   41193           5 :   for (auto p: SgLocatedNode::pools) {
   41194           0 :     ROSE_FREE(p);
   41195             :   }
   41196           5 :   SgLocatedNode::next_node = nullptr;
   41197           5 :   SgLocatedNode::pools.clear();
   41198           5 : }
   41199             : 
   41200             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   41201             : //                 reading multiple binary files to for a single AST.
   41202             : /////////// new version ////////////////////////////////
   41203             : //############################################################################
   41204             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   41205             : void
   41206           2 : SgLocatedNode::extendMemoryPoolForFileIO( )
   41207             :   {
   41208           2 :     size_t blockIndex = SgLocatedNode::pools.size();
   41209           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLocatedNode) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLocatedNode);
   41210             : 
   41211           2 :     while ( (blockIndex * SgLocatedNode::pool_size) < newPoolSize)
   41212             :       {
   41213             : #if ROSE_ALLOC_TRACE
   41214             :         if (blockIndex > 0) {
   41215             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLocatedNode) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLocatedNode) = %" PRIuPTR " SgLocatedNode::pool_size = %d \n",
   41216             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLocatedNode),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLocatedNode),SgLocatedNode::pool_size);
   41217             :         }
   41218             : #endif
   41219             : 
   41220           0 :         SgLocatedNode * pointer = (SgLocatedNode*) ROSE_MALLOC ( SgLocatedNode::pool_size * sizeof(SgLocatedNode) );
   41221           0 :         assert( pointer != NULL );
   41222             : #if ROSE_ALLOC_MEMSET == 1
   41223             :         memset(pointer, 0x00, SgLocatedNode::pool_size * sizeof(SgLocatedNode));
   41224             : #elif ROSE_ALLOC_MEMSET == 2
   41225             :         memset(pointer, 0xCC, SgLocatedNode::pool_size * sizeof(SgLocatedNode));
   41226             : #endif
   41227           0 :         SgLocatedNode::pools.push_back( (unsigned char*)(pointer) );
   41228           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLocatedNode::pool_size * sizeof(SgLocatedNode), V_SgLocatedNode ) );
   41229             : 
   41230           0 :         if ( SgLocatedNode::next_node != NULL ) {
   41231           0 :           if ( blockIndex > 0 ) {
   41232           0 :             SgLocatedNode * blkptr = (SgLocatedNode*)(SgLocatedNode::pools[blockIndex-1]);
   41233           0 :             blkptr[ SgLocatedNode::pool_size - 1 ].set_freepointer(pointer);
   41234             :           }
   41235             :         } else {
   41236           0 :           SgLocatedNode::next_node = pointer;
   41237             :         }
   41238             : 
   41239           0 :         for (unsigned i = 0; i < SgLocatedNode::pool_size-1; ++i)
   41240             :            {
   41241           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   41242             :            }
   41243           0 :         pointer[ SgLocatedNode::pool_size -1 ].set_freepointer(NULL);
   41244             : 
   41245           0 :         blockIndex++;
   41246             :       }
   41247           2 :   }
   41248             : 
   41249             : //############################################################################
   41250             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   41251             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   41252             :  * not compressed. However, that stuff is not yet implemented! 
   41253             :  */
   41254             : unsigned long
   41255           0 : SgLocatedNode::getNumberOfLastValidPointer()
   41256             :    {
   41257           0 :       SgLocatedNode* testPointer = (SgLocatedNode*)(SgLocatedNode::pools.back());
   41258           0 :       unsigned long localIndex = SgLocatedNode::pool_size - 1;
   41259           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   41260             :          {
   41261           0 :            localIndex--;
   41262             :          }
   41263           0 :       return (localIndex + SgLocatedNode::pool_size * (SgLocatedNode::pools.size()-1));
   41264             :    }
   41265             : 
   41266             : //############################################################################
   41267             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   41268             :  * memory pool and initializes the data member in class SgLocatedNodeStroageClass
   41269             :  * from its counterpart of SgLocatedNode. The return value is just for checking, 
   41270             :  * that the whole StorageClassArray is initialized!
   41271             :  */
   41272             : unsigned long
   41273           0 : SgLocatedNode::initializeStorageClassArray( SgLocatedNodeStorageClass *storageArray )
   41274             :    {
   41275           0 :      unsigned long storageCounter = 0;
   41276           0 :      std::vector < unsigned char* > :: const_iterator block = SgLocatedNode::pools.begin();
   41277           0 :      SgLocatedNode* pointer = NULL;
   41278           0 :      while ( block != SgLocatedNode::pools.end() ) {
   41279           0 :           pointer = (SgLocatedNode*) (*block);
   41280           0 :           for ( unsigned i = 0; i < SgLocatedNode::pool_size; ++i ) {
   41281           0 :                if ( pointer->get_freepointer() != NULL ) {
   41282           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   41283           0 :                  storageArray++;
   41284           0 :                  storageCounter++;
   41285             :                }
   41286           0 :                pointer++;
   41287             :              }
   41288           0 :            block++;
   41289             :         }
   41290           0 :      return storageCounter;
   41291             :    }
   41292             : 
   41293             : /* #line 41294 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   41294             : 
   41295             : 
   41296             : 
   41297             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   41298             : 
   41299             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   41300             : 
   41301             : //############################################################################
   41302             : /* JH (02/02/2006) Constructor of the IR node SgToken that takes its 
   41303             :  * corresponding StorageClass as parameter
   41304             :  */
   41305           0 : SgToken :: SgToken ( const SgTokenStorageClass& storageSource )   : SgLocatedNode (storageSource)
   41306             :    {
   41307             : 
   41308             : 
   41309             : /* #line 41310 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   41310             : 
   41311           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   41312           0 :      p_lexeme_string = storageSource.storageOf_lexeme_string.rebuildDataStoredInEasyStorageClass() ;
   41313           0 :      p_classification_code = storageSource.storageOf_classification_code ;
   41314             : 
   41315             : 
   41316             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   41317             : 
   41318             : 
   41319           0 :    }
   41320             : 
   41321             : //############################################################################
   41322             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   41323             :  * within the working AST. 
   41324             :  */
   41325           0 : SgToken * SgToken::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   41326           0 :      SgToken* returnPointer = NULL;
   41327           0 :      if ( globalIndex != 0 )
   41328             :         {
   41329             : 
   41330             : #if FILE_IO_EXTRA_CHECK
   41331           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgToken ) ) <= globalIndex ) ;
   41332           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgToken + 1 ) ) );
   41333             : #endif
   41334           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgToken )  
   41335           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgToken );
   41336           0 :           unsigned long positionInPool = localIndex % SgToken::pool_size;
   41337           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgToken::pool_size;
   41338             : 
   41339             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   41340             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   41341             : 
   41342           0 :           returnPointer = &( ( (SgToken*)(SgToken::pools[memoryBlock]) ) [positionInPool]) ;
   41343             : 
   41344           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   41345             :         }
   41346           0 :      return returnPointer ;
   41347             :    }
   41348             : 
   41349             : //############################################################################
   41350             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   41351             :   for the AST with the index astIndex
   41352             : */
   41353           0 : SgToken * SgToken::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   41354           0 :      SgToken* returnPointer = NULL;
   41355           0 :      if ( globalIndex != 0 )
   41356             :         {
   41357             : 
   41358             : #if FILE_IO_EXTRA_CHECK
   41359           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgToken ) ) <= globalIndex ) ;
   41360           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgToken + 1 ) ) );
   41361             : #endif
   41362           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgToken )
   41363           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgToken );
   41364           0 :           unsigned long positionInPool = localIndex % SgToken::pool_size ;
   41365           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgToken::pool_size ;
   41366             : 
   41367             : #if FILE_IO_EXTRA_CHECK
   41368             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   41369             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   41370             : #endif
   41371             : 
   41372           0 :           returnPointer = &( ( (SgToken*)(SgToken::pools[memoryBlock]) ) [positionInPool]) ;
   41373             : 
   41374             : #if FILE_IO_EXTRA_CHECK
   41375           0 :           assert ( returnPointer != NULL ) ;
   41376             : #endif
   41377             :         }
   41378           0 :      return returnPointer ;
   41379             :    }
   41380             : 
   41381             : //############################################################################
   41382             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   41383             :  * pool size! We set for every valid object in the memory pool the freepointer
   41384             :  * to the global index and increase the global index afterwards. For all the 
   41385             :  * invalid objects (means address ranges within the memory pool that were not
   41386             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   41387             :  * distinguish valid from invalid objects! 
   41388             :  */
   41389             : unsigned long
   41390           5 : SgToken::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   41391             :    {
   41392           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   41393           5 :      SgToken* pointer = NULL;
   41394           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   41395           5 :      std::vector < unsigned char* > :: const_iterator block;
   41396           5 :      for ( block = SgToken::pools.begin(); block != SgToken::pools.end() ; ++block )
   41397             :         {
   41398           0 :           pointer = (SgToken*)(*block);
   41399           0 :           for (unsigned i = 0; i < SgToken::pool_size; ++i )
   41400             :              {
   41401             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   41402             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   41403             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   41404             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   41405             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   41406             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   41407             :             // properly; so this will have to be checked next.
   41408             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   41409             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   41410           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   41411             :                   {
   41412           0 :                     pointer[i].set_freepointer((SgToken*)(globalIndex));
   41413           0 :                     globalIndex++;
   41414             :                   }
   41415             :                else
   41416             :                   {
   41417           0 :                     pointer[i].set_freepointer(NULL);
   41418             :                   }
   41419             :               }
   41420             :         }
   41421           5 :      return globalIndex;
   41422             :    }
   41423             : 
   41424             : //############################################################################
   41425             : // JH (01/14/2006)
   41426             : void
   41427           5 : SgToken::resetValidFreepointers( )
   41428             :    {
   41429           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   41430           5 :      SgToken* pointer = NULL;
   41431           5 :      std::vector < unsigned char* > :: const_iterator block;
   41432           5 :      SgToken* pointerOfLinkedList = NULL;
   41433           5 :      for ( block = SgToken::pools.begin(); block != SgToken::pools.end() ; ++block )
   41434             :         {
   41435           0 :           pointer = (SgToken*)(*block);
   41436           0 :           for (unsigned i = 0; i < SgToken::pool_size; ++i )
   41437             :              {
   41438             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   41439             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   41440             :             // memory blocks!.
   41441           0 :                if ( pointer[i].get_freepointer() != NULL )
   41442             :                   {
   41443           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   41444             :                   }
   41445             :                else
   41446             :                   {
   41447           0 :                     if ( pointerOfLinkedList == NULL )
   41448             :                        {
   41449           0 :                          SgToken::next_node = &(pointer[i]);
   41450             :                        }
   41451             :                     else
   41452             :                        {
   41453             :                       // printf ("In SgToken::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   41454           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   41455             :                        }
   41456             :                     pointerOfLinkedList = &(pointer[i]);
   41457             :                   }
   41458             :               }
   41459             :         }
   41460             : 
   41461           5 :      if ( pointerOfLinkedList != NULL )
   41462             :         {
   41463             :        // printf ("In SgToken::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   41464           0 :           pointerOfLinkedList->set_freepointer(NULL);
   41465             :        // DQ (6/6/2010): Temporary debugging...
   41466             :        //   ROSE_ASSERT(false);
   41467             :         }
   41468             : 
   41469           5 :      return ;
   41470             :    }
   41471             : 
   41472             : //############################################################################
   41473             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   41474             :  * within the memory pool and resets the freepointers, in order to achieve a 
   41475             :  * linked list, that has no jumps and starts at the beginning! This function 
   41476             :  * does not extend the memory pool, since we do not delete any memory blocks,
   41477             :  * but delete the valid objects.  
   41478             :  */
   41479             : void
   41480           0 : SgToken::clearMemoryPool( )
   41481             :    {
   41482             :   // printf ("Inside of SgToken::clearMemoryPool() \n");
   41483             : 
   41484           0 :      SgToken* pointer = NULL, *tempPointer = NULL;
   41485           0 :      std::vector < unsigned char* > :: const_iterator block;
   41486           0 :      if ( SgToken::pools.empty() == false )
   41487             :         {
   41488           0 :           block = SgToken::pools.begin() ;
   41489           0 :           SgToken::next_node = (SgToken*) (*block);
   41490             : 
   41491           0 :           while ( block != SgToken::pools.end() )
   41492             :              {
   41493           0 :                pointer = (SgToken*) (*block);
   41494           0 :                if ( tempPointer != NULL )
   41495             :                   {
   41496           0 :                     tempPointer->set_freepointer(pointer);
   41497             :                   }
   41498           0 :                for (unsigned i = 0; i < SgToken::pool_size - 1; ++i)
   41499             :                   {
   41500           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   41501             :                   }
   41502           0 :                 pointer[SgToken::pool_size-1].set_freepointer(NULL);
   41503           0 :                 tempPointer = &(pointer[SgToken::pool_size-1]);
   41504           0 :                 ++block;
   41505             :              }
   41506             :         }
   41507           0 :    }
   41508             : 
   41509           5 : void SgToken::deleteMemoryPool() {
   41510           5 :   for (auto p: SgToken::pools) {
   41511           0 :     ROSE_FREE(p);
   41512             :   }
   41513           5 :   SgToken::next_node = nullptr;
   41514           5 :   SgToken::pools.clear();
   41515           5 : }
   41516             : 
   41517             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   41518             : //                 reading multiple binary files to for a single AST.
   41519             : /////////// new version ////////////////////////////////
   41520             : //############################################################################
   41521             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   41522             : void
   41523           2 : SgToken::extendMemoryPoolForFileIO( )
   41524             :   {
   41525           2 :     size_t blockIndex = SgToken::pools.size();
   41526           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgToken) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgToken);
   41527             : 
   41528           2 :     while ( (blockIndex * SgToken::pool_size) < newPoolSize)
   41529             :       {
   41530             : #if ROSE_ALLOC_TRACE
   41531             :         if (blockIndex > 0) {
   41532             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgToken) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgToken) = %" PRIuPTR " SgToken::pool_size = %d \n",
   41533             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgToken),AST_FILE_IO::getPoolSizeOfNewAst(V_SgToken),SgToken::pool_size);
   41534             :         }
   41535             : #endif
   41536             : 
   41537           0 :         SgToken * pointer = (SgToken*) ROSE_MALLOC ( SgToken::pool_size * sizeof(SgToken) );
   41538           0 :         assert( pointer != NULL );
   41539             : #if ROSE_ALLOC_MEMSET == 1
   41540             :         memset(pointer, 0x00, SgToken::pool_size * sizeof(SgToken));
   41541             : #elif ROSE_ALLOC_MEMSET == 2
   41542             :         memset(pointer, 0xCC, SgToken::pool_size * sizeof(SgToken));
   41543             : #endif
   41544           0 :         SgToken::pools.push_back( (unsigned char*)(pointer) );
   41545           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgToken::pool_size * sizeof(SgToken), V_SgToken ) );
   41546             : 
   41547           0 :         if ( SgToken::next_node != NULL ) {
   41548           0 :           if ( blockIndex > 0 ) {
   41549           0 :             SgToken * blkptr = (SgToken*)(SgToken::pools[blockIndex-1]);
   41550           0 :             blkptr[ SgToken::pool_size - 1 ].set_freepointer(pointer);
   41551             :           }
   41552             :         } else {
   41553           0 :           SgToken::next_node = pointer;
   41554             :         }
   41555             : 
   41556           0 :         for (unsigned i = 0; i < SgToken::pool_size-1; ++i)
   41557             :            {
   41558           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   41559             :            }
   41560           0 :         pointer[ SgToken::pool_size -1 ].set_freepointer(NULL);
   41561             : 
   41562           0 :         blockIndex++;
   41563             :       }
   41564           2 :   }
   41565             : 
   41566             : //############################################################################
   41567             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   41568             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   41569             :  * not compressed. However, that stuff is not yet implemented! 
   41570             :  */
   41571             : unsigned long
   41572           0 : SgToken::getNumberOfLastValidPointer()
   41573             :    {
   41574           0 :       SgToken* testPointer = (SgToken*)(SgToken::pools.back());
   41575           0 :       unsigned long localIndex = SgToken::pool_size - 1;
   41576           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   41577             :          {
   41578           0 :            localIndex--;
   41579             :          }
   41580           0 :       return (localIndex + SgToken::pool_size * (SgToken::pools.size()-1));
   41581             :    }
   41582             : 
   41583             : //############################################################################
   41584             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   41585             :  * memory pool and initializes the data member in class SgTokenStroageClass
   41586             :  * from its counterpart of SgToken. The return value is just for checking, 
   41587             :  * that the whole StorageClassArray is initialized!
   41588             :  */
   41589             : unsigned long
   41590           0 : SgToken::initializeStorageClassArray( SgTokenStorageClass *storageArray )
   41591             :    {
   41592           0 :      unsigned long storageCounter = 0;
   41593           0 :      std::vector < unsigned char* > :: const_iterator block = SgToken::pools.begin();
   41594           0 :      SgToken* pointer = NULL;
   41595           0 :      while ( block != SgToken::pools.end() ) {
   41596           0 :           pointer = (SgToken*) (*block);
   41597           0 :           for ( unsigned i = 0; i < SgToken::pool_size; ++i ) {
   41598           0 :                if ( pointer->get_freepointer() != NULL ) {
   41599           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   41600           0 :                  storageArray++;
   41601           0 :                  storageCounter++;
   41602             :                }
   41603           0 :                pointer++;
   41604             :              }
   41605           0 :            block++;
   41606             :         }
   41607           0 :      return storageCounter;
   41608             :    }
   41609             : 
   41610             : /* #line 41611 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   41611             : 
   41612             : 
   41613             : 
   41614             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   41615             : 
   41616             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   41617             : 
   41618             : //############################################################################
   41619             : /* JH (02/02/2006) Constructor of the IR node SgLocatedNodeSupport that takes its 
   41620             :  * corresponding StorageClass as parameter
   41621             :  */
   41622       55225 : SgLocatedNodeSupport :: SgLocatedNodeSupport ( const SgLocatedNodeSupportStorageClass& storageSource )   : SgLocatedNode (storageSource)
   41623             :    {
   41624             : 
   41625             : 
   41626             : /* #line 41627 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   41627             : 
   41628       55225 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   41629             : 
   41630             : 
   41631             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   41632             : 
   41633             : 
   41634       55225 :    }
   41635             : 
   41636             : //############################################################################
   41637             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   41638             :  * within the working AST. 
   41639             :  */
   41640           0 : SgLocatedNodeSupport * SgLocatedNodeSupport::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   41641           0 :      SgLocatedNodeSupport* returnPointer = NULL;
   41642           0 :      if ( globalIndex != 0 )
   41643             :         {
   41644             : 
   41645             : #if FILE_IO_EXTRA_CHECK
   41646           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLocatedNodeSupport ) ) <= globalIndex ) ;
   41647           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLocatedNodeSupport + 1 ) ) );
   41648             : #endif
   41649           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLocatedNodeSupport )  
   41650           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLocatedNodeSupport );
   41651           0 :           unsigned long positionInPool = localIndex % SgLocatedNodeSupport::pool_size;
   41652           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLocatedNodeSupport::pool_size;
   41653             : 
   41654             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   41655             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   41656             : 
   41657           0 :           returnPointer = &( ( (SgLocatedNodeSupport*)(SgLocatedNodeSupport::pools[memoryBlock]) ) [positionInPool]) ;
   41658             : 
   41659           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   41660             :         }
   41661           0 :      return returnPointer ;
   41662             :    }
   41663             : 
   41664             : //############################################################################
   41665             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   41666             :   for the AST with the index astIndex
   41667             : */
   41668           0 : SgLocatedNodeSupport * SgLocatedNodeSupport::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   41669           0 :      SgLocatedNodeSupport* returnPointer = NULL;
   41670           0 :      if ( globalIndex != 0 )
   41671             :         {
   41672             : 
   41673             : #if FILE_IO_EXTRA_CHECK
   41674           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLocatedNodeSupport ) ) <= globalIndex ) ;
   41675           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLocatedNodeSupport + 1 ) ) );
   41676             : #endif
   41677           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLocatedNodeSupport )
   41678           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLocatedNodeSupport );
   41679           0 :           unsigned long positionInPool = localIndex % SgLocatedNodeSupport::pool_size ;
   41680           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLocatedNodeSupport::pool_size ;
   41681             : 
   41682             : #if FILE_IO_EXTRA_CHECK
   41683             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   41684             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   41685             : #endif
   41686             : 
   41687           0 :           returnPointer = &( ( (SgLocatedNodeSupport*)(SgLocatedNodeSupport::pools[memoryBlock]) ) [positionInPool]) ;
   41688             : 
   41689             : #if FILE_IO_EXTRA_CHECK
   41690           0 :           assert ( returnPointer != NULL ) ;
   41691             : #endif
   41692             :         }
   41693           0 :      return returnPointer ;
   41694             :    }
   41695             : 
   41696             : //############################################################################
   41697             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   41698             :  * pool size! We set for every valid object in the memory pool the freepointer
   41699             :  * to the global index and increase the global index afterwards. For all the 
   41700             :  * invalid objects (means address ranges within the memory pool that were not
   41701             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   41702             :  * distinguish valid from invalid objects! 
   41703             :  */
   41704             : unsigned long
   41705           5 : SgLocatedNodeSupport::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   41706             :    {
   41707           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   41708           5 :      SgLocatedNodeSupport* pointer = NULL;
   41709           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   41710           5 :      std::vector < unsigned char* > :: const_iterator block;
   41711           5 :      for ( block = SgLocatedNodeSupport::pools.begin(); block != SgLocatedNodeSupport::pools.end() ; ++block )
   41712             :         {
   41713           0 :           pointer = (SgLocatedNodeSupport*)(*block);
   41714           0 :           for (unsigned i = 0; i < SgLocatedNodeSupport::pool_size; ++i )
   41715             :              {
   41716             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   41717             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   41718             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   41719             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   41720             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   41721             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   41722             :             // properly; so this will have to be checked next.
   41723             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   41724             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   41725           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   41726             :                   {
   41727           0 :                     pointer[i].set_freepointer((SgLocatedNodeSupport*)(globalIndex));
   41728           0 :                     globalIndex++;
   41729             :                   }
   41730             :                else
   41731             :                   {
   41732           0 :                     pointer[i].set_freepointer(NULL);
   41733             :                   }
   41734             :               }
   41735             :         }
   41736           5 :      return globalIndex;
   41737             :    }
   41738             : 
   41739             : //############################################################################
   41740             : // JH (01/14/2006)
   41741             : void
   41742           5 : SgLocatedNodeSupport::resetValidFreepointers( )
   41743             :    {
   41744           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   41745           5 :      SgLocatedNodeSupport* pointer = NULL;
   41746           5 :      std::vector < unsigned char* > :: const_iterator block;
   41747           5 :      SgLocatedNodeSupport* pointerOfLinkedList = NULL;
   41748           5 :      for ( block = SgLocatedNodeSupport::pools.begin(); block != SgLocatedNodeSupport::pools.end() ; ++block )
   41749             :         {
   41750           0 :           pointer = (SgLocatedNodeSupport*)(*block);
   41751           0 :           for (unsigned i = 0; i < SgLocatedNodeSupport::pool_size; ++i )
   41752             :              {
   41753             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   41754             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   41755             :             // memory blocks!.
   41756           0 :                if ( pointer[i].get_freepointer() != NULL )
   41757             :                   {
   41758           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   41759             :                   }
   41760             :                else
   41761             :                   {
   41762           0 :                     if ( pointerOfLinkedList == NULL )
   41763             :                        {
   41764           0 :                          SgLocatedNodeSupport::next_node = &(pointer[i]);
   41765             :                        }
   41766             :                     else
   41767             :                        {
   41768             :                       // printf ("In SgLocatedNodeSupport::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   41769           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   41770             :                        }
   41771             :                     pointerOfLinkedList = &(pointer[i]);
   41772             :                   }
   41773             :               }
   41774             :         }
   41775             : 
   41776           5 :      if ( pointerOfLinkedList != NULL )
   41777             :         {
   41778             :        // printf ("In SgLocatedNodeSupport::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   41779           0 :           pointerOfLinkedList->set_freepointer(NULL);
   41780             :        // DQ (6/6/2010): Temporary debugging...
   41781             :        //   ROSE_ASSERT(false);
   41782             :         }
   41783             : 
   41784           5 :      return ;
   41785             :    }
   41786             : 
   41787             : //############################################################################
   41788             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   41789             :  * within the memory pool and resets the freepointers, in order to achieve a 
   41790             :  * linked list, that has no jumps and starts at the beginning! This function 
   41791             :  * does not extend the memory pool, since we do not delete any memory blocks,
   41792             :  * but delete the valid objects.  
   41793             :  */
   41794             : void
   41795           0 : SgLocatedNodeSupport::clearMemoryPool( )
   41796             :    {
   41797             :   // printf ("Inside of SgLocatedNodeSupport::clearMemoryPool() \n");
   41798             : 
   41799           0 :      SgLocatedNodeSupport* pointer = NULL, *tempPointer = NULL;
   41800           0 :      std::vector < unsigned char* > :: const_iterator block;
   41801           0 :      if ( SgLocatedNodeSupport::pools.empty() == false )
   41802             :         {
   41803           0 :           block = SgLocatedNodeSupport::pools.begin() ;
   41804           0 :           SgLocatedNodeSupport::next_node = (SgLocatedNodeSupport*) (*block);
   41805             : 
   41806           0 :           while ( block != SgLocatedNodeSupport::pools.end() )
   41807             :              {
   41808           0 :                pointer = (SgLocatedNodeSupport*) (*block);
   41809           0 :                if ( tempPointer != NULL )
   41810             :                   {
   41811           0 :                     tempPointer->set_freepointer(pointer);
   41812             :                   }
   41813           0 :                for (unsigned i = 0; i < SgLocatedNodeSupport::pool_size - 1; ++i)
   41814             :                   {
   41815           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   41816             :                   }
   41817           0 :                 pointer[SgLocatedNodeSupport::pool_size-1].set_freepointer(NULL);
   41818           0 :                 tempPointer = &(pointer[SgLocatedNodeSupport::pool_size-1]);
   41819           0 :                 ++block;
   41820             :              }
   41821             :         }
   41822           0 :    }
   41823             : 
   41824           5 : void SgLocatedNodeSupport::deleteMemoryPool() {
   41825           5 :   for (auto p: SgLocatedNodeSupport::pools) {
   41826           0 :     ROSE_FREE(p);
   41827             :   }
   41828           5 :   SgLocatedNodeSupport::next_node = nullptr;
   41829           5 :   SgLocatedNodeSupport::pools.clear();
   41830           5 : }
   41831             : 
   41832             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   41833             : //                 reading multiple binary files to for a single AST.
   41834             : /////////// new version ////////////////////////////////
   41835             : //############################################################################
   41836             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   41837             : void
   41838           2 : SgLocatedNodeSupport::extendMemoryPoolForFileIO( )
   41839             :   {
   41840           2 :     size_t blockIndex = SgLocatedNodeSupport::pools.size();
   41841           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLocatedNodeSupport) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLocatedNodeSupport);
   41842             : 
   41843           2 :     while ( (blockIndex * SgLocatedNodeSupport::pool_size) < newPoolSize)
   41844             :       {
   41845             : #if ROSE_ALLOC_TRACE
   41846             :         if (blockIndex > 0) {
   41847             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLocatedNodeSupport) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLocatedNodeSupport) = %" PRIuPTR " SgLocatedNodeSupport::pool_size = %d \n",
   41848             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLocatedNodeSupport),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLocatedNodeSupport),SgLocatedNodeSupport::pool_size);
   41849             :         }
   41850             : #endif
   41851             : 
   41852           0 :         SgLocatedNodeSupport * pointer = (SgLocatedNodeSupport*) ROSE_MALLOC ( SgLocatedNodeSupport::pool_size * sizeof(SgLocatedNodeSupport) );
   41853           0 :         assert( pointer != NULL );
   41854             : #if ROSE_ALLOC_MEMSET == 1
   41855             :         memset(pointer, 0x00, SgLocatedNodeSupport::pool_size * sizeof(SgLocatedNodeSupport));
   41856             : #elif ROSE_ALLOC_MEMSET == 2
   41857             :         memset(pointer, 0xCC, SgLocatedNodeSupport::pool_size * sizeof(SgLocatedNodeSupport));
   41858             : #endif
   41859           0 :         SgLocatedNodeSupport::pools.push_back( (unsigned char*)(pointer) );
   41860           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLocatedNodeSupport::pool_size * sizeof(SgLocatedNodeSupport), V_SgLocatedNodeSupport ) );
   41861             : 
   41862           0 :         if ( SgLocatedNodeSupport::next_node != NULL ) {
   41863           0 :           if ( blockIndex > 0 ) {
   41864           0 :             SgLocatedNodeSupport * blkptr = (SgLocatedNodeSupport*)(SgLocatedNodeSupport::pools[blockIndex-1]);
   41865           0 :             blkptr[ SgLocatedNodeSupport::pool_size - 1 ].set_freepointer(pointer);
   41866             :           }
   41867             :         } else {
   41868           0 :           SgLocatedNodeSupport::next_node = pointer;
   41869             :         }
   41870             : 
   41871           0 :         for (unsigned i = 0; i < SgLocatedNodeSupport::pool_size-1; ++i)
   41872             :            {
   41873           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   41874             :            }
   41875           0 :         pointer[ SgLocatedNodeSupport::pool_size -1 ].set_freepointer(NULL);
   41876             : 
   41877           0 :         blockIndex++;
   41878             :       }
   41879           2 :   }
   41880             : 
   41881             : //############################################################################
   41882             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   41883             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   41884             :  * not compressed. However, that stuff is not yet implemented! 
   41885             :  */
   41886             : unsigned long
   41887           0 : SgLocatedNodeSupport::getNumberOfLastValidPointer()
   41888             :    {
   41889           0 :       SgLocatedNodeSupport* testPointer = (SgLocatedNodeSupport*)(SgLocatedNodeSupport::pools.back());
   41890           0 :       unsigned long localIndex = SgLocatedNodeSupport::pool_size - 1;
   41891           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   41892             :          {
   41893           0 :            localIndex--;
   41894             :          }
   41895           0 :       return (localIndex + SgLocatedNodeSupport::pool_size * (SgLocatedNodeSupport::pools.size()-1));
   41896             :    }
   41897             : 
   41898             : //############################################################################
   41899             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   41900             :  * memory pool and initializes the data member in class SgLocatedNodeSupportStroageClass
   41901             :  * from its counterpart of SgLocatedNodeSupport. The return value is just for checking, 
   41902             :  * that the whole StorageClassArray is initialized!
   41903             :  */
   41904             : unsigned long
   41905           0 : SgLocatedNodeSupport::initializeStorageClassArray( SgLocatedNodeSupportStorageClass *storageArray )
   41906             :    {
   41907           0 :      unsigned long storageCounter = 0;
   41908           0 :      std::vector < unsigned char* > :: const_iterator block = SgLocatedNodeSupport::pools.begin();
   41909           0 :      SgLocatedNodeSupport* pointer = NULL;
   41910           0 :      while ( block != SgLocatedNodeSupport::pools.end() ) {
   41911           0 :           pointer = (SgLocatedNodeSupport*) (*block);
   41912           0 :           for ( unsigned i = 0; i < SgLocatedNodeSupport::pool_size; ++i ) {
   41913           0 :                if ( pointer->get_freepointer() != NULL ) {
   41914           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   41915           0 :                  storageArray++;
   41916           0 :                  storageCounter++;
   41917             :                }
   41918           0 :                pointer++;
   41919             :              }
   41920           0 :            block++;
   41921             :         }
   41922           0 :      return storageCounter;
   41923             :    }
   41924             : 
   41925             : /* #line 41926 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   41926             : 
   41927             : 
   41928             : 
   41929             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   41930             : 
   41931             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   41932             : 
   41933             : //############################################################################
   41934             : /* JH (02/02/2006) Constructor of the IR node SgCommonBlockObject that takes its 
   41935             :  * corresponding StorageClass as parameter
   41936             :  */
   41937           0 : SgCommonBlockObject :: SgCommonBlockObject ( const SgCommonBlockObjectStorageClass& storageSource )   : SgLocatedNodeSupport (storageSource)
   41938             :    {
   41939             : 
   41940             : 
   41941             : /* #line 41942 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   41942             : 
   41943           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   41944           0 :      p_block_name = storageSource.storageOf_block_name.rebuildDataStoredInEasyStorageClass() ;
   41945           0 :      p_variable_reference_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_variable_reference_list) );
   41946             : 
   41947             : 
   41948             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   41949             : 
   41950             : 
   41951           0 :    }
   41952             : 
   41953             : //############################################################################
   41954             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   41955             :  * within the working AST. 
   41956             :  */
   41957           0 : SgCommonBlockObject * SgCommonBlockObject::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   41958           0 :      SgCommonBlockObject* returnPointer = NULL;
   41959           0 :      if ( globalIndex != 0 )
   41960             :         {
   41961             : 
   41962             : #if FILE_IO_EXTRA_CHECK
   41963           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCommonBlockObject ) ) <= globalIndex ) ;
   41964           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCommonBlockObject + 1 ) ) );
   41965             : #endif
   41966           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCommonBlockObject )  
   41967           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCommonBlockObject );
   41968           0 :           unsigned long positionInPool = localIndex % SgCommonBlockObject::pool_size;
   41969           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCommonBlockObject::pool_size;
   41970             : 
   41971             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   41972             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   41973             : 
   41974           0 :           returnPointer = &( ( (SgCommonBlockObject*)(SgCommonBlockObject::pools[memoryBlock]) ) [positionInPool]) ;
   41975             : 
   41976           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   41977             :         }
   41978           0 :      return returnPointer ;
   41979             :    }
   41980             : 
   41981             : //############################################################################
   41982             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   41983             :   for the AST with the index astIndex
   41984             : */
   41985           0 : SgCommonBlockObject * SgCommonBlockObject::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   41986           0 :      SgCommonBlockObject* returnPointer = NULL;
   41987           0 :      if ( globalIndex != 0 )
   41988             :         {
   41989             : 
   41990             : #if FILE_IO_EXTRA_CHECK
   41991           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCommonBlockObject ) ) <= globalIndex ) ;
   41992           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCommonBlockObject + 1 ) ) );
   41993             : #endif
   41994           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCommonBlockObject )
   41995           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCommonBlockObject );
   41996           0 :           unsigned long positionInPool = localIndex % SgCommonBlockObject::pool_size ;
   41997           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCommonBlockObject::pool_size ;
   41998             : 
   41999             : #if FILE_IO_EXTRA_CHECK
   42000             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   42001             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   42002             : #endif
   42003             : 
   42004           0 :           returnPointer = &( ( (SgCommonBlockObject*)(SgCommonBlockObject::pools[memoryBlock]) ) [positionInPool]) ;
   42005             : 
   42006             : #if FILE_IO_EXTRA_CHECK
   42007           0 :           assert ( returnPointer != NULL ) ;
   42008             : #endif
   42009             :         }
   42010           0 :      return returnPointer ;
   42011             :    }
   42012             : 
   42013             : //############################################################################
   42014             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   42015             :  * pool size! We set for every valid object in the memory pool the freepointer
   42016             :  * to the global index and increase the global index afterwards. For all the 
   42017             :  * invalid objects (means address ranges within the memory pool that were not
   42018             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   42019             :  * distinguish valid from invalid objects! 
   42020             :  */
   42021             : unsigned long
   42022           5 : SgCommonBlockObject::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   42023             :    {
   42024           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   42025           5 :      SgCommonBlockObject* pointer = NULL;
   42026           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   42027           5 :      std::vector < unsigned char* > :: const_iterator block;
   42028           5 :      for ( block = SgCommonBlockObject::pools.begin(); block != SgCommonBlockObject::pools.end() ; ++block )
   42029             :         {
   42030           0 :           pointer = (SgCommonBlockObject*)(*block);
   42031           0 :           for (unsigned i = 0; i < SgCommonBlockObject::pool_size; ++i )
   42032             :              {
   42033             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   42034             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   42035             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   42036             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   42037             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   42038             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   42039             :             // properly; so this will have to be checked next.
   42040             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   42041             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   42042           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   42043             :                   {
   42044           0 :                     pointer[i].set_freepointer((SgCommonBlockObject*)(globalIndex));
   42045           0 :                     globalIndex++;
   42046             :                   }
   42047             :                else
   42048             :                   {
   42049           0 :                     pointer[i].set_freepointer(NULL);
   42050             :                   }
   42051             :               }
   42052             :         }
   42053           5 :      return globalIndex;
   42054             :    }
   42055             : 
   42056             : //############################################################################
   42057             : // JH (01/14/2006)
   42058             : void
   42059           5 : SgCommonBlockObject::resetValidFreepointers( )
   42060             :    {
   42061           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   42062           5 :      SgCommonBlockObject* pointer = NULL;
   42063           5 :      std::vector < unsigned char* > :: const_iterator block;
   42064           5 :      SgCommonBlockObject* pointerOfLinkedList = NULL;
   42065           5 :      for ( block = SgCommonBlockObject::pools.begin(); block != SgCommonBlockObject::pools.end() ; ++block )
   42066             :         {
   42067           0 :           pointer = (SgCommonBlockObject*)(*block);
   42068           0 :           for (unsigned i = 0; i < SgCommonBlockObject::pool_size; ++i )
   42069             :              {
   42070             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   42071             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   42072             :             // memory blocks!.
   42073           0 :                if ( pointer[i].get_freepointer() != NULL )
   42074             :                   {
   42075           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   42076             :                   }
   42077             :                else
   42078             :                   {
   42079           0 :                     if ( pointerOfLinkedList == NULL )
   42080             :                        {
   42081           0 :                          SgCommonBlockObject::next_node = &(pointer[i]);
   42082             :                        }
   42083             :                     else
   42084             :                        {
   42085             :                       // printf ("In SgCommonBlockObject::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   42086           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   42087             :                        }
   42088             :                     pointerOfLinkedList = &(pointer[i]);
   42089             :                   }
   42090             :               }
   42091             :         }
   42092             : 
   42093           5 :      if ( pointerOfLinkedList != NULL )
   42094             :         {
   42095             :        // printf ("In SgCommonBlockObject::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   42096           0 :           pointerOfLinkedList->set_freepointer(NULL);
   42097             :        // DQ (6/6/2010): Temporary debugging...
   42098             :        //   ROSE_ASSERT(false);
   42099             :         }
   42100             : 
   42101           5 :      return ;
   42102             :    }
   42103             : 
   42104             : //############################################################################
   42105             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   42106             :  * within the memory pool and resets the freepointers, in order to achieve a 
   42107             :  * linked list, that has no jumps and starts at the beginning! This function 
   42108             :  * does not extend the memory pool, since we do not delete any memory blocks,
   42109             :  * but delete the valid objects.  
   42110             :  */
   42111             : void
   42112           0 : SgCommonBlockObject::clearMemoryPool( )
   42113             :    {
   42114             :   // printf ("Inside of SgCommonBlockObject::clearMemoryPool() \n");
   42115             : 
   42116           0 :      SgCommonBlockObject* pointer = NULL, *tempPointer = NULL;
   42117           0 :      std::vector < unsigned char* > :: const_iterator block;
   42118           0 :      if ( SgCommonBlockObject::pools.empty() == false )
   42119             :         {
   42120           0 :           block = SgCommonBlockObject::pools.begin() ;
   42121           0 :           SgCommonBlockObject::next_node = (SgCommonBlockObject*) (*block);
   42122             : 
   42123           0 :           while ( block != SgCommonBlockObject::pools.end() )
   42124             :              {
   42125           0 :                pointer = (SgCommonBlockObject*) (*block);
   42126           0 :                if ( tempPointer != NULL )
   42127             :                   {
   42128           0 :                     tempPointer->set_freepointer(pointer);
   42129             :                   }
   42130           0 :                for (unsigned i = 0; i < SgCommonBlockObject::pool_size - 1; ++i)
   42131             :                   {
   42132           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   42133             :                   }
   42134           0 :                 pointer[SgCommonBlockObject::pool_size-1].set_freepointer(NULL);
   42135           0 :                 tempPointer = &(pointer[SgCommonBlockObject::pool_size-1]);
   42136           0 :                 ++block;
   42137             :              }
   42138             :         }
   42139           0 :    }
   42140             : 
   42141           5 : void SgCommonBlockObject::deleteMemoryPool() {
   42142           5 :   for (auto p: SgCommonBlockObject::pools) {
   42143           0 :     ROSE_FREE(p);
   42144             :   }
   42145           5 :   SgCommonBlockObject::next_node = nullptr;
   42146           5 :   SgCommonBlockObject::pools.clear();
   42147           5 : }
   42148             : 
   42149             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   42150             : //                 reading multiple binary files to for a single AST.
   42151             : /////////// new version ////////////////////////////////
   42152             : //############################################################################
   42153             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   42154             : void
   42155           2 : SgCommonBlockObject::extendMemoryPoolForFileIO( )
   42156             :   {
   42157           2 :     size_t blockIndex = SgCommonBlockObject::pools.size();
   42158           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonBlockObject) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonBlockObject);
   42159             : 
   42160           2 :     while ( (blockIndex * SgCommonBlockObject::pool_size) < newPoolSize)
   42161             :       {
   42162             : #if ROSE_ALLOC_TRACE
   42163             :         if (blockIndex > 0) {
   42164             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonBlockObject) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonBlockObject) = %" PRIuPTR " SgCommonBlockObject::pool_size = %d \n",
   42165             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonBlockObject),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonBlockObject),SgCommonBlockObject::pool_size);
   42166             :         }
   42167             : #endif
   42168             : 
   42169           0 :         SgCommonBlockObject * pointer = (SgCommonBlockObject*) ROSE_MALLOC ( SgCommonBlockObject::pool_size * sizeof(SgCommonBlockObject) );
   42170           0 :         assert( pointer != NULL );
   42171             : #if ROSE_ALLOC_MEMSET == 1
   42172             :         memset(pointer, 0x00, SgCommonBlockObject::pool_size * sizeof(SgCommonBlockObject));
   42173             : #elif ROSE_ALLOC_MEMSET == 2
   42174             :         memset(pointer, 0xCC, SgCommonBlockObject::pool_size * sizeof(SgCommonBlockObject));
   42175             : #endif
   42176           0 :         SgCommonBlockObject::pools.push_back( (unsigned char*)(pointer) );
   42177           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCommonBlockObject::pool_size * sizeof(SgCommonBlockObject), V_SgCommonBlockObject ) );
   42178             : 
   42179           0 :         if ( SgCommonBlockObject::next_node != NULL ) {
   42180           0 :           if ( blockIndex > 0 ) {
   42181           0 :             SgCommonBlockObject * blkptr = (SgCommonBlockObject*)(SgCommonBlockObject::pools[blockIndex-1]);
   42182           0 :             blkptr[ SgCommonBlockObject::pool_size - 1 ].set_freepointer(pointer);
   42183             :           }
   42184             :         } else {
   42185           0 :           SgCommonBlockObject::next_node = pointer;
   42186             :         }
   42187             : 
   42188           0 :         for (unsigned i = 0; i < SgCommonBlockObject::pool_size-1; ++i)
   42189             :            {
   42190           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   42191             :            }
   42192           0 :         pointer[ SgCommonBlockObject::pool_size -1 ].set_freepointer(NULL);
   42193             : 
   42194           0 :         blockIndex++;
   42195             :       }
   42196           2 :   }
   42197             : 
   42198             : //############################################################################
   42199             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   42200             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   42201             :  * not compressed. However, that stuff is not yet implemented! 
   42202             :  */
   42203             : unsigned long
   42204           0 : SgCommonBlockObject::getNumberOfLastValidPointer()
   42205             :    {
   42206           0 :       SgCommonBlockObject* testPointer = (SgCommonBlockObject*)(SgCommonBlockObject::pools.back());
   42207           0 :       unsigned long localIndex = SgCommonBlockObject::pool_size - 1;
   42208           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   42209             :          {
   42210           0 :            localIndex--;
   42211             :          }
   42212           0 :       return (localIndex + SgCommonBlockObject::pool_size * (SgCommonBlockObject::pools.size()-1));
   42213             :    }
   42214             : 
   42215             : //############################################################################
   42216             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   42217             :  * memory pool and initializes the data member in class SgCommonBlockObjectStroageClass
   42218             :  * from its counterpart of SgCommonBlockObject. The return value is just for checking, 
   42219             :  * that the whole StorageClassArray is initialized!
   42220             :  */
   42221             : unsigned long
   42222           0 : SgCommonBlockObject::initializeStorageClassArray( SgCommonBlockObjectStorageClass *storageArray )
   42223             :    {
   42224           0 :      unsigned long storageCounter = 0;
   42225           0 :      std::vector < unsigned char* > :: const_iterator block = SgCommonBlockObject::pools.begin();
   42226           0 :      SgCommonBlockObject* pointer = NULL;
   42227           0 :      while ( block != SgCommonBlockObject::pools.end() ) {
   42228           0 :           pointer = (SgCommonBlockObject*) (*block);
   42229           0 :           for ( unsigned i = 0; i < SgCommonBlockObject::pool_size; ++i ) {
   42230           0 :                if ( pointer->get_freepointer() != NULL ) {
   42231           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   42232           0 :                  storageArray++;
   42233           0 :                  storageCounter++;
   42234             :                }
   42235           0 :                pointer++;
   42236             :              }
   42237           0 :            block++;
   42238             :         }
   42239           0 :      return storageCounter;
   42240             :    }
   42241             : 
   42242             : /* #line 42243 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   42243             : 
   42244             : 
   42245             : 
   42246             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   42247             : 
   42248             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   42249             : 
   42250             : //############################################################################
   42251             : /* JH (02/02/2006) Constructor of the IR node SgInitializedName that takes its 
   42252             :  * corresponding StorageClass as parameter
   42253             :  */
   42254       55225 : SgInitializedName :: SgInitializedName ( const SgInitializedNameStorageClass& storageSource )   : SgLocatedNodeSupport (storageSource)
   42255             :    {
   42256             : 
   42257             : 
   42258             : /* #line 42259 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   42259             : 
   42260       55225 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   42261       55225 :      p_name = SgName ( storageSource.storageOf_name ) ;
   42262       55225 :      p_microsoft_uuid_string = storageSource.storageOf_microsoft_uuid_string.rebuildDataStoredInEasyStorageClass() ;
   42263       55225 :      p_typeptr =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_typeptr) );
   42264       55225 :      p_initptr =  (SgInitializer*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initptr) );
   42265       55225 :      p_prev_decl_item =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_prev_decl_item) );
   42266       55225 :      p_is_initializer = storageSource.storageOf_is_initializer ;
   42267       55225 :      p_declptr =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declptr) );
   42268       55225 :      p_storageModifier =  (SgStorageModifier*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_storageModifier) );
   42269       55225 :      p_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scope) );
   42270       55225 :      p_preinitialization = storageSource.storageOf_preinitialization ;
   42271       55225 :      p_isCoArray = storageSource.storageOf_isCoArray ;
   42272       55225 :      p_register_name_code = storageSource.storageOf_register_name_code ;
   42273       55225 :      p_excess_specifier = storageSource.storageOf_excess_specifier ;
   42274       55225 :      p_register_name_string = storageSource.storageOf_register_name_string.rebuildDataStoredInEasyStorageClass() ;
   42275       55225 :      p_requiresGlobalNameQualificationOnType = storageSource.storageOf_requiresGlobalNameQualificationOnType ;
   42276       55225 :      p_shapeDeferred = storageSource.storageOf_shapeDeferred ;
   42277       55225 :      p_initializationDeferred = storageSource.storageOf_initializationDeferred ;
   42278       55225 :      p_gnu_attribute_modifierVector = storageSource.storageOf_gnu_attribute_modifierVector.rebuildDataStoredInEasyStorageClass() ;
   42279       55225 :      p_gnu_attribute_initialization_priority = storageSource.storageOf_gnu_attribute_initialization_priority ;
   42280       55225 :      p_gnu_attribute_named_weak_reference = storageSource.storageOf_gnu_attribute_named_weak_reference.rebuildDataStoredInEasyStorageClass() ;
   42281       55225 :      p_gnu_attribute_named_alias = storageSource.storageOf_gnu_attribute_named_alias.rebuildDataStoredInEasyStorageClass() ;
   42282       55225 :      p_gnu_attribute_cleanup_function = storageSource.storageOf_gnu_attribute_cleanup_function.rebuildDataStoredInEasyStorageClass() ;
   42283       55225 :      p_gnu_attribute_section_name = storageSource.storageOf_gnu_attribute_section_name.rebuildDataStoredInEasyStorageClass() ;
   42284       55225 :      p_gnu_attribute_alignment = storageSource.storageOf_gnu_attribute_alignment ;
   42285       55225 :      p_gnu_attribute_visability = storageSource.storageOf_gnu_attribute_visability ;
   42286       55225 :      p_protected_declaration = storageSource.storageOf_protected_declaration ;
   42287       55225 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   42288       55225 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   42289       55225 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   42290       55225 :      p_name_qualification_length_for_type = storageSource.storageOf_name_qualification_length_for_type ;
   42291       55225 :      p_type_elaboration_required_for_type = storageSource.storageOf_type_elaboration_required_for_type ;
   42292       55225 :      p_global_qualification_required_for_type = storageSource.storageOf_global_qualification_required_for_type ;
   42293       55225 :      p_hasArrayTypeWithEmptyBracketSyntax = storageSource.storageOf_hasArrayTypeWithEmptyBracketSyntax ;
   42294       55225 :      p_using_C11_Alignas_keyword = storageSource.storageOf_using_C11_Alignas_keyword ;
   42295       55225 :      p_constant_or_type_argument_for_Alignas_keyword =  (SgNode*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_constant_or_type_argument_for_Alignas_keyword) );
   42296       55225 :      p_using_auto_keyword = storageSource.storageOf_using_auto_keyword ;
   42297       55225 :      p_auto_decltype =  (SgType *)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_auto_decltype) );
   42298       55225 :      p_using_device_keyword = storageSource.storageOf_using_device_keyword ;
   42299       55225 :      p_is_braced_initialized = storageSource.storageOf_is_braced_initialized ;
   42300       55225 :      p_using_assignment_copy_constructor_syntax = storageSource.storageOf_using_assignment_copy_constructor_syntax ;
   42301       55225 :      p_needs_definitions = storageSource.storageOf_needs_definitions ;
   42302       55225 :      p_is_parameter_pack = storageSource.storageOf_is_parameter_pack ;
   42303       55225 :      p_is_pack_element = storageSource.storageOf_is_pack_element ;
   42304             : 
   42305             : 
   42306             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   42307             : 
   42308             : 
   42309       55225 :    }
   42310             : 
   42311             : //############################################################################
   42312             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   42313             :  * within the working AST. 
   42314             :  */
   42315      229729 : SgInitializedName * SgInitializedName::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   42316      229729 :      SgInitializedName* returnPointer = NULL;
   42317      229729 :      if ( globalIndex != 0 )
   42318             :         {
   42319             : 
   42320             : #if FILE_IO_EXTRA_CHECK
   42321      229729 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgInitializedName ) ) <= globalIndex ) ;
   42322      229729 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInitializedName + 1 ) ) );
   42323             : #endif
   42324      229729 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInitializedName )  
   42325      229729 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgInitializedName );
   42326      229729 :           unsigned long positionInPool = localIndex % SgInitializedName::pool_size;
   42327      229729 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInitializedName::pool_size;
   42328             : 
   42329             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   42330             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   42331             : 
   42332      229729 :           returnPointer = &( ( (SgInitializedName*)(SgInitializedName::pools[memoryBlock]) ) [positionInPool]) ;
   42333             : 
   42334      229729 :           ROSE_ASSERT( returnPointer != NULL ) ;
   42335             :         }
   42336      229729 :      return returnPointer ;
   42337             :    }
   42338             : 
   42339             : //############################################################################
   42340             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   42341             :   for the AST with the index astIndex
   42342             : */
   42343           0 : SgInitializedName * SgInitializedName::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   42344           0 :      SgInitializedName* returnPointer = NULL;
   42345           0 :      if ( globalIndex != 0 )
   42346             :         {
   42347             : 
   42348             : #if FILE_IO_EXTRA_CHECK
   42349           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgInitializedName ) ) <= globalIndex ) ;
   42350           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInitializedName + 1 ) ) );
   42351             : #endif
   42352           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInitializedName )
   42353           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgInitializedName );
   42354           0 :           unsigned long positionInPool = localIndex % SgInitializedName::pool_size ;
   42355           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInitializedName::pool_size ;
   42356             : 
   42357             : #if FILE_IO_EXTRA_CHECK
   42358             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   42359             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   42360             : #endif
   42361             : 
   42362           0 :           returnPointer = &( ( (SgInitializedName*)(SgInitializedName::pools[memoryBlock]) ) [positionInPool]) ;
   42363             : 
   42364             : #if FILE_IO_EXTRA_CHECK
   42365           0 :           assert ( returnPointer != NULL ) ;
   42366             : #endif
   42367             :         }
   42368           0 :      return returnPointer ;
   42369             :    }
   42370             : 
   42371             : //############################################################################
   42372             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   42373             :  * pool size! We set for every valid object in the memory pool the freepointer
   42374             :  * to the global index and increase the global index afterwards. For all the 
   42375             :  * invalid objects (means address ranges within the memory pool that were not
   42376             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   42377             :  * distinguish valid from invalid objects! 
   42378             :  */
   42379             : unsigned long
   42380           5 : SgInitializedName::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   42381             :    {
   42382           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   42383           5 :      SgInitializedName* pointer = NULL;
   42384           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   42385           5 :      std::vector < unsigned char* > :: const_iterator block;
   42386          34 :      for ( block = SgInitializedName::pools.begin(); block != SgInitializedName::pools.end() ; ++block )
   42387             :         {
   42388          29 :           pointer = (SgInitializedName*)(*block);
   42389       58029 :           for (unsigned i = 0; i < SgInitializedName::pool_size; ++i )
   42390             :              {
   42391             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   42392             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   42393             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   42394             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   42395             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   42396             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   42397             :             // properly; so this will have to be checked next.
   42398             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   42399             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   42400       58000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   42401             :                   {
   42402       55225 :                     pointer[i].set_freepointer((SgInitializedName*)(globalIndex));
   42403       55225 :                     globalIndex++;
   42404             :                   }
   42405             :                else
   42406             :                   {
   42407        2775 :                     pointer[i].set_freepointer(NULL);
   42408             :                   }
   42409             :               }
   42410             :         }
   42411           5 :      return globalIndex;
   42412             :    }
   42413             : 
   42414             : //############################################################################
   42415             : // JH (01/14/2006)
   42416             : void
   42417           5 : SgInitializedName::resetValidFreepointers( )
   42418             :    {
   42419           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   42420           5 :      SgInitializedName* pointer = NULL;
   42421           5 :      std::vector < unsigned char* > :: const_iterator block;
   42422           5 :      SgInitializedName* pointerOfLinkedList = NULL;
   42423          34 :      for ( block = SgInitializedName::pools.begin(); block != SgInitializedName::pools.end() ; ++block )
   42424             :         {
   42425          29 :           pointer = (SgInitializedName*)(*block);
   42426       58029 :           for (unsigned i = 0; i < SgInitializedName::pool_size; ++i )
   42427             :              {
   42428             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   42429             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   42430             :             // memory blocks!.
   42431       58000 :                if ( pointer[i].get_freepointer() != NULL )
   42432             :                   {
   42433       55225 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   42434             :                   }
   42435             :                else
   42436             :                   {
   42437        2775 :                     if ( pointerOfLinkedList == NULL )
   42438             :                        {
   42439           2 :                          SgInitializedName::next_node = &(pointer[i]);
   42440             :                        }
   42441             :                     else
   42442             :                        {
   42443             :                       // printf ("In SgInitializedName::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   42444        2773 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   42445             :                        }
   42446             :                     pointerOfLinkedList = &(pointer[i]);
   42447             :                   }
   42448             :               }
   42449             :         }
   42450             : 
   42451           5 :      if ( pointerOfLinkedList != NULL )
   42452             :         {
   42453             :        // printf ("In SgInitializedName::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   42454           2 :           pointerOfLinkedList->set_freepointer(NULL);
   42455             :        // DQ (6/6/2010): Temporary debugging...
   42456             :        //   ROSE_ASSERT(false);
   42457             :         }
   42458             : 
   42459           5 :      return ;
   42460             :    }
   42461             : 
   42462             : //############################################################################
   42463             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   42464             :  * within the memory pool and resets the freepointers, in order to achieve a 
   42465             :  * linked list, that has no jumps and starts at the beginning! This function 
   42466             :  * does not extend the memory pool, since we do not delete any memory blocks,
   42467             :  * but delete the valid objects.  
   42468             :  */
   42469             : void
   42470           0 : SgInitializedName::clearMemoryPool( )
   42471             :    {
   42472             :   // printf ("Inside of SgInitializedName::clearMemoryPool() \n");
   42473             : 
   42474           0 :      SgInitializedName* pointer = NULL, *tempPointer = NULL;
   42475           0 :      std::vector < unsigned char* > :: const_iterator block;
   42476           0 :      if ( SgInitializedName::pools.empty() == false )
   42477             :         {
   42478           0 :           block = SgInitializedName::pools.begin() ;
   42479           0 :           SgInitializedName::next_node = (SgInitializedName*) (*block);
   42480             : 
   42481           0 :           while ( block != SgInitializedName::pools.end() )
   42482             :              {
   42483           0 :                pointer = (SgInitializedName*) (*block);
   42484           0 :                if ( tempPointer != NULL )
   42485             :                   {
   42486           0 :                     tempPointer->set_freepointer(pointer);
   42487             :                   }
   42488           0 :                for (unsigned i = 0; i < SgInitializedName::pool_size - 1; ++i)
   42489             :                   {
   42490           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   42491             :                   }
   42492           0 :                 pointer[SgInitializedName::pool_size-1].set_freepointer(NULL);
   42493           0 :                 tempPointer = &(pointer[SgInitializedName::pool_size-1]);
   42494           0 :                 ++block;
   42495             :              }
   42496             :         }
   42497           0 :    }
   42498             : 
   42499           5 : void SgInitializedName::deleteMemoryPool() {
   42500          63 :   for (auto p: SgInitializedName::pools) {
   42501          58 :     ROSE_FREE(p);
   42502             :   }
   42503           5 :   SgInitializedName::next_node = nullptr;
   42504           5 :   SgInitializedName::pools.clear();
   42505           5 : }
   42506             : 
   42507             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   42508             : //                 reading multiple binary files to for a single AST.
   42509             : /////////// new version ////////////////////////////////
   42510             : //############################################################################
   42511             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   42512             : void
   42513           2 : SgInitializedName::extendMemoryPoolForFileIO( )
   42514             :   {
   42515           2 :     size_t blockIndex = SgInitializedName::pools.size();
   42516           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgInitializedName) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgInitializedName);
   42517             : 
   42518          31 :     while ( (blockIndex * SgInitializedName::pool_size) < newPoolSize)
   42519             :       {
   42520             : #if ROSE_ALLOC_TRACE
   42521             :         if (blockIndex > 0) {
   42522             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgInitializedName) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgInitializedName) = %" PRIuPTR " SgInitializedName::pool_size = %d \n",
   42523             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgInitializedName),AST_FILE_IO::getPoolSizeOfNewAst(V_SgInitializedName),SgInitializedName::pool_size);
   42524             :         }
   42525             : #endif
   42526             : 
   42527          29 :         SgInitializedName * pointer = (SgInitializedName*) ROSE_MALLOC ( SgInitializedName::pool_size * sizeof(SgInitializedName) );
   42528          29 :         assert( pointer != NULL );
   42529             : #if ROSE_ALLOC_MEMSET == 1
   42530             :         memset(pointer, 0x00, SgInitializedName::pool_size * sizeof(SgInitializedName));
   42531             : #elif ROSE_ALLOC_MEMSET == 2
   42532             :         memset(pointer, 0xCC, SgInitializedName::pool_size * sizeof(SgInitializedName));
   42533             : #endif
   42534          29 :         SgInitializedName::pools.push_back( (unsigned char*)(pointer) );
   42535          29 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgInitializedName::pool_size * sizeof(SgInitializedName), V_SgInitializedName ) );
   42536             : 
   42537          29 :         if ( SgInitializedName::next_node != NULL ) {
   42538          27 :           if ( blockIndex > 0 ) {
   42539          27 :             SgInitializedName * blkptr = (SgInitializedName*)(SgInitializedName::pools[blockIndex-1]);
   42540          27 :             blkptr[ SgInitializedName::pool_size - 1 ].set_freepointer(pointer);
   42541             :           }
   42542             :         } else {
   42543           2 :           SgInitializedName::next_node = pointer;
   42544             :         }
   42545             : 
   42546       58000 :         for (unsigned i = 0; i < SgInitializedName::pool_size-1; ++i)
   42547             :            {
   42548       57971 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   42549             :            }
   42550          29 :         pointer[ SgInitializedName::pool_size -1 ].set_freepointer(NULL);
   42551             : 
   42552          29 :         blockIndex++;
   42553             :       }
   42554           2 :   }
   42555             : 
   42556             : //############################################################################
   42557             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   42558             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   42559             :  * not compressed. However, that stuff is not yet implemented! 
   42560             :  */
   42561             : unsigned long
   42562           0 : SgInitializedName::getNumberOfLastValidPointer()
   42563             :    {
   42564           0 :       SgInitializedName* testPointer = (SgInitializedName*)(SgInitializedName::pools.back());
   42565           0 :       unsigned long localIndex = SgInitializedName::pool_size - 1;
   42566           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   42567             :          {
   42568           0 :            localIndex--;
   42569             :          }
   42570           0 :       return (localIndex + SgInitializedName::pool_size * (SgInitializedName::pools.size()-1));
   42571             :    }
   42572             : 
   42573             : //############################################################################
   42574             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   42575             :  * memory pool and initializes the data member in class SgInitializedNameStroageClass
   42576             :  * from its counterpart of SgInitializedName. The return value is just for checking, 
   42577             :  * that the whole StorageClassArray is initialized!
   42578             :  */
   42579             : unsigned long
   42580           2 : SgInitializedName::initializeStorageClassArray( SgInitializedNameStorageClass *storageArray )
   42581             :    {
   42582           2 :      unsigned long storageCounter = 0;
   42583           2 :      std::vector < unsigned char* > :: const_iterator block = SgInitializedName::pools.begin();
   42584           2 :      SgInitializedName* pointer = NULL;
   42585          31 :      while ( block != SgInitializedName::pools.end() ) {
   42586          29 :           pointer = (SgInitializedName*) (*block);
   42587       58029 :           for ( unsigned i = 0; i < SgInitializedName::pool_size; ++i ) {
   42588       58000 :                if ( pointer->get_freepointer() != NULL ) {
   42589       55225 :                  storageArray->pickOutIRNodeData (pointer) ;
   42590       55225 :                  storageArray++;
   42591       55225 :                  storageCounter++;
   42592             :                }
   42593       58000 :                pointer++;
   42594             :              }
   42595          29 :            block++;
   42596             :         }
   42597           2 :      return storageCounter;
   42598             :    }
   42599             : 
   42600             : /* #line 42601 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   42601             : 
   42602             : 
   42603             : 
   42604             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   42605             : 
   42606             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   42607             : 
   42608             : //############################################################################
   42609             : /* JH (02/02/2006) Constructor of the IR node SgInterfaceBody that takes its 
   42610             :  * corresponding StorageClass as parameter
   42611             :  */
   42612           0 : SgInterfaceBody :: SgInterfaceBody ( const SgInterfaceBodyStorageClass& storageSource )   : SgLocatedNodeSupport (storageSource)
   42613             :    {
   42614             : 
   42615             : 
   42616             : /* #line 42617 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   42617             : 
   42618           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   42619           0 :      p_function_name = SgName ( storageSource.storageOf_function_name ) ;
   42620           0 :      p_functionDeclaration =  (SgFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_functionDeclaration) );
   42621           0 :      p_use_function_name = storageSource.storageOf_use_function_name ;
   42622             : 
   42623             : 
   42624             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   42625             : 
   42626             : 
   42627           0 :    }
   42628             : 
   42629             : //############################################################################
   42630             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   42631             :  * within the working AST. 
   42632             :  */
   42633           0 : SgInterfaceBody * SgInterfaceBody::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   42634           0 :      SgInterfaceBody* returnPointer = NULL;
   42635           0 :      if ( globalIndex != 0 )
   42636             :         {
   42637             : 
   42638             : #if FILE_IO_EXTRA_CHECK
   42639           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgInterfaceBody ) ) <= globalIndex ) ;
   42640           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInterfaceBody + 1 ) ) );
   42641             : #endif
   42642           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInterfaceBody )  
   42643           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgInterfaceBody );
   42644           0 :           unsigned long positionInPool = localIndex % SgInterfaceBody::pool_size;
   42645           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInterfaceBody::pool_size;
   42646             : 
   42647             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   42648             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   42649             : 
   42650           0 :           returnPointer = &( ( (SgInterfaceBody*)(SgInterfaceBody::pools[memoryBlock]) ) [positionInPool]) ;
   42651             : 
   42652           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   42653             :         }
   42654           0 :      return returnPointer ;
   42655             :    }
   42656             : 
   42657             : //############################################################################
   42658             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   42659             :   for the AST with the index astIndex
   42660             : */
   42661           0 : SgInterfaceBody * SgInterfaceBody::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   42662           0 :      SgInterfaceBody* returnPointer = NULL;
   42663           0 :      if ( globalIndex != 0 )
   42664             :         {
   42665             : 
   42666             : #if FILE_IO_EXTRA_CHECK
   42667           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgInterfaceBody ) ) <= globalIndex ) ;
   42668           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInterfaceBody + 1 ) ) );
   42669             : #endif
   42670           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInterfaceBody )
   42671           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgInterfaceBody );
   42672           0 :           unsigned long positionInPool = localIndex % SgInterfaceBody::pool_size ;
   42673           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInterfaceBody::pool_size ;
   42674             : 
   42675             : #if FILE_IO_EXTRA_CHECK
   42676             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   42677             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   42678             : #endif
   42679             : 
   42680           0 :           returnPointer = &( ( (SgInterfaceBody*)(SgInterfaceBody::pools[memoryBlock]) ) [positionInPool]) ;
   42681             : 
   42682             : #if FILE_IO_EXTRA_CHECK
   42683           0 :           assert ( returnPointer != NULL ) ;
   42684             : #endif
   42685             :         }
   42686           0 :      return returnPointer ;
   42687             :    }
   42688             : 
   42689             : //############################################################################
   42690             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   42691             :  * pool size! We set for every valid object in the memory pool the freepointer
   42692             :  * to the global index and increase the global index afterwards. For all the 
   42693             :  * invalid objects (means address ranges within the memory pool that were not
   42694             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   42695             :  * distinguish valid from invalid objects! 
   42696             :  */
   42697             : unsigned long
   42698           5 : SgInterfaceBody::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   42699             :    {
   42700           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   42701           5 :      SgInterfaceBody* pointer = NULL;
   42702           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   42703           5 :      std::vector < unsigned char* > :: const_iterator block;
   42704           5 :      for ( block = SgInterfaceBody::pools.begin(); block != SgInterfaceBody::pools.end() ; ++block )
   42705             :         {
   42706           0 :           pointer = (SgInterfaceBody*)(*block);
   42707           0 :           for (unsigned i = 0; i < SgInterfaceBody::pool_size; ++i )
   42708             :              {
   42709             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   42710             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   42711             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   42712             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   42713             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   42714             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   42715             :             // properly; so this will have to be checked next.
   42716             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   42717             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   42718           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   42719             :                   {
   42720           0 :                     pointer[i].set_freepointer((SgInterfaceBody*)(globalIndex));
   42721           0 :                     globalIndex++;
   42722             :                   }
   42723             :                else
   42724             :                   {
   42725           0 :                     pointer[i].set_freepointer(NULL);
   42726             :                   }
   42727             :               }
   42728             :         }
   42729           5 :      return globalIndex;
   42730             :    }
   42731             : 
   42732             : //############################################################################
   42733             : // JH (01/14/2006)
   42734             : void
   42735           5 : SgInterfaceBody::resetValidFreepointers( )
   42736             :    {
   42737           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   42738           5 :      SgInterfaceBody* pointer = NULL;
   42739           5 :      std::vector < unsigned char* > :: const_iterator block;
   42740           5 :      SgInterfaceBody* pointerOfLinkedList = NULL;
   42741           5 :      for ( block = SgInterfaceBody::pools.begin(); block != SgInterfaceBody::pools.end() ; ++block )
   42742             :         {
   42743           0 :           pointer = (SgInterfaceBody*)(*block);
   42744           0 :           for (unsigned i = 0; i < SgInterfaceBody::pool_size; ++i )
   42745             :              {
   42746             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   42747             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   42748             :             // memory blocks!.
   42749           0 :                if ( pointer[i].get_freepointer() != NULL )
   42750             :                   {
   42751           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   42752             :                   }
   42753             :                else
   42754             :                   {
   42755           0 :                     if ( pointerOfLinkedList == NULL )
   42756             :                        {
   42757           0 :                          SgInterfaceBody::next_node = &(pointer[i]);
   42758             :                        }
   42759             :                     else
   42760             :                        {
   42761             :                       // printf ("In SgInterfaceBody::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   42762           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   42763             :                        }
   42764             :                     pointerOfLinkedList = &(pointer[i]);
   42765             :                   }
   42766             :               }
   42767             :         }
   42768             : 
   42769           5 :      if ( pointerOfLinkedList != NULL )
   42770             :         {
   42771             :        // printf ("In SgInterfaceBody::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   42772           0 :           pointerOfLinkedList->set_freepointer(NULL);
   42773             :        // DQ (6/6/2010): Temporary debugging...
   42774             :        //   ROSE_ASSERT(false);
   42775             :         }
   42776             : 
   42777           5 :      return ;
   42778             :    }
   42779             : 
   42780             : //############################################################################
   42781             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   42782             :  * within the memory pool and resets the freepointers, in order to achieve a 
   42783             :  * linked list, that has no jumps and starts at the beginning! This function 
   42784             :  * does not extend the memory pool, since we do not delete any memory blocks,
   42785             :  * but delete the valid objects.  
   42786             :  */
   42787             : void
   42788           0 : SgInterfaceBody::clearMemoryPool( )
   42789             :    {
   42790             :   // printf ("Inside of SgInterfaceBody::clearMemoryPool() \n");
   42791             : 
   42792           0 :      SgInterfaceBody* pointer = NULL, *tempPointer = NULL;
   42793           0 :      std::vector < unsigned char* > :: const_iterator block;
   42794           0 :      if ( SgInterfaceBody::pools.empty() == false )
   42795             :         {
   42796           0 :           block = SgInterfaceBody::pools.begin() ;
   42797           0 :           SgInterfaceBody::next_node = (SgInterfaceBody*) (*block);
   42798             : 
   42799           0 :           while ( block != SgInterfaceBody::pools.end() )
   42800             :              {
   42801           0 :                pointer = (SgInterfaceBody*) (*block);
   42802           0 :                if ( tempPointer != NULL )
   42803             :                   {
   42804           0 :                     tempPointer->set_freepointer(pointer);
   42805             :                   }
   42806           0 :                for (unsigned i = 0; i < SgInterfaceBody::pool_size - 1; ++i)
   42807             :                   {
   42808           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   42809             :                   }
   42810           0 :                 pointer[SgInterfaceBody::pool_size-1].set_freepointer(NULL);
   42811           0 :                 tempPointer = &(pointer[SgInterfaceBody::pool_size-1]);
   42812           0 :                 ++block;
   42813             :              }
   42814             :         }
   42815           0 :    }
   42816             : 
   42817           5 : void SgInterfaceBody::deleteMemoryPool() {
   42818           5 :   for (auto p: SgInterfaceBody::pools) {
   42819           0 :     ROSE_FREE(p);
   42820             :   }
   42821           5 :   SgInterfaceBody::next_node = nullptr;
   42822           5 :   SgInterfaceBody::pools.clear();
   42823           5 : }
   42824             : 
   42825             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   42826             : //                 reading multiple binary files to for a single AST.
   42827             : /////////// new version ////////////////////////////////
   42828             : //############################################################################
   42829             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   42830             : void
   42831           2 : SgInterfaceBody::extendMemoryPoolForFileIO( )
   42832             :   {
   42833           2 :     size_t blockIndex = SgInterfaceBody::pools.size();
   42834           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceBody) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceBody);
   42835             : 
   42836           2 :     while ( (blockIndex * SgInterfaceBody::pool_size) < newPoolSize)
   42837             :       {
   42838             : #if ROSE_ALLOC_TRACE
   42839             :         if (blockIndex > 0) {
   42840             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceBody) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceBody) = %" PRIuPTR " SgInterfaceBody::pool_size = %d \n",
   42841             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceBody),AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceBody),SgInterfaceBody::pool_size);
   42842             :         }
   42843             : #endif
   42844             : 
   42845           0 :         SgInterfaceBody * pointer = (SgInterfaceBody*) ROSE_MALLOC ( SgInterfaceBody::pool_size * sizeof(SgInterfaceBody) );
   42846           0 :         assert( pointer != NULL );
   42847             : #if ROSE_ALLOC_MEMSET == 1
   42848             :         memset(pointer, 0x00, SgInterfaceBody::pool_size * sizeof(SgInterfaceBody));
   42849             : #elif ROSE_ALLOC_MEMSET == 2
   42850             :         memset(pointer, 0xCC, SgInterfaceBody::pool_size * sizeof(SgInterfaceBody));
   42851             : #endif
   42852           0 :         SgInterfaceBody::pools.push_back( (unsigned char*)(pointer) );
   42853           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgInterfaceBody::pool_size * sizeof(SgInterfaceBody), V_SgInterfaceBody ) );
   42854             : 
   42855           0 :         if ( SgInterfaceBody::next_node != NULL ) {
   42856           0 :           if ( blockIndex > 0 ) {
   42857           0 :             SgInterfaceBody * blkptr = (SgInterfaceBody*)(SgInterfaceBody::pools[blockIndex-1]);
   42858           0 :             blkptr[ SgInterfaceBody::pool_size - 1 ].set_freepointer(pointer);
   42859             :           }
   42860             :         } else {
   42861           0 :           SgInterfaceBody::next_node = pointer;
   42862             :         }
   42863             : 
   42864           0 :         for (unsigned i = 0; i < SgInterfaceBody::pool_size-1; ++i)
   42865             :            {
   42866           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   42867             :            }
   42868           0 :         pointer[ SgInterfaceBody::pool_size -1 ].set_freepointer(NULL);
   42869             : 
   42870           0 :         blockIndex++;
   42871             :       }
   42872           2 :   }
   42873             : 
   42874             : //############################################################################
   42875             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   42876             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   42877             :  * not compressed. However, that stuff is not yet implemented! 
   42878             :  */
   42879             : unsigned long
   42880           0 : SgInterfaceBody::getNumberOfLastValidPointer()
   42881             :    {
   42882           0 :       SgInterfaceBody* testPointer = (SgInterfaceBody*)(SgInterfaceBody::pools.back());
   42883           0 :       unsigned long localIndex = SgInterfaceBody::pool_size - 1;
   42884           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   42885             :          {
   42886           0 :            localIndex--;
   42887             :          }
   42888           0 :       return (localIndex + SgInterfaceBody::pool_size * (SgInterfaceBody::pools.size()-1));
   42889             :    }
   42890             : 
   42891             : //############################################################################
   42892             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   42893             :  * memory pool and initializes the data member in class SgInterfaceBodyStroageClass
   42894             :  * from its counterpart of SgInterfaceBody. The return value is just for checking, 
   42895             :  * that the whole StorageClassArray is initialized!
   42896             :  */
   42897             : unsigned long
   42898           0 : SgInterfaceBody::initializeStorageClassArray( SgInterfaceBodyStorageClass *storageArray )
   42899             :    {
   42900           0 :      unsigned long storageCounter = 0;
   42901           0 :      std::vector < unsigned char* > :: const_iterator block = SgInterfaceBody::pools.begin();
   42902           0 :      SgInterfaceBody* pointer = NULL;
   42903           0 :      while ( block != SgInterfaceBody::pools.end() ) {
   42904           0 :           pointer = (SgInterfaceBody*) (*block);
   42905           0 :           for ( unsigned i = 0; i < SgInterfaceBody::pool_size; ++i ) {
   42906           0 :                if ( pointer->get_freepointer() != NULL ) {
   42907           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   42908           0 :                  storageArray++;
   42909           0 :                  storageCounter++;
   42910             :                }
   42911           0 :                pointer++;
   42912             :              }
   42913           0 :            block++;
   42914             :         }
   42915           0 :      return storageCounter;
   42916             :    }
   42917             : 
   42918             : /* #line 42919 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   42919             : 
   42920             : 
   42921             : 
   42922             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   42923             : 
   42924             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   42925             : 
   42926             : //############################################################################
   42927             : /* JH (02/02/2006) Constructor of the IR node SgHeaderFileBody that takes its 
   42928             :  * corresponding StorageClass as parameter
   42929             :  */
   42930           0 : SgHeaderFileBody :: SgHeaderFileBody ( const SgHeaderFileBodyStorageClass& storageSource )   : SgLocatedNodeSupport (storageSource)
   42931             :    {
   42932             : 
   42933             : 
   42934             : /* #line 42935 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   42935             : 
   42936           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   42937           0 :      p_include_file =  (SgSourceFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_include_file) );
   42938             : 
   42939             : 
   42940             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   42941             : 
   42942             : 
   42943           0 :    }
   42944             : 
   42945             : //############################################################################
   42946             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   42947             :  * within the working AST. 
   42948             :  */
   42949           0 : SgHeaderFileBody * SgHeaderFileBody::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   42950           0 :      SgHeaderFileBody* returnPointer = NULL;
   42951           0 :      if ( globalIndex != 0 )
   42952             :         {
   42953             : 
   42954             : #if FILE_IO_EXTRA_CHECK
   42955           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgHeaderFileBody ) ) <= globalIndex ) ;
   42956           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgHeaderFileBody + 1 ) ) );
   42957             : #endif
   42958           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgHeaderFileBody )  
   42959           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgHeaderFileBody );
   42960           0 :           unsigned long positionInPool = localIndex % SgHeaderFileBody::pool_size;
   42961           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgHeaderFileBody::pool_size;
   42962             : 
   42963             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   42964             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   42965             : 
   42966           0 :           returnPointer = &( ( (SgHeaderFileBody*)(SgHeaderFileBody::pools[memoryBlock]) ) [positionInPool]) ;
   42967             : 
   42968           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   42969             :         }
   42970           0 :      return returnPointer ;
   42971             :    }
   42972             : 
   42973             : //############################################################################
   42974             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   42975             :   for the AST with the index astIndex
   42976             : */
   42977           0 : SgHeaderFileBody * SgHeaderFileBody::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   42978           0 :      SgHeaderFileBody* returnPointer = NULL;
   42979           0 :      if ( globalIndex != 0 )
   42980             :         {
   42981             : 
   42982             : #if FILE_IO_EXTRA_CHECK
   42983           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgHeaderFileBody ) ) <= globalIndex ) ;
   42984           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgHeaderFileBody + 1 ) ) );
   42985             : #endif
   42986           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgHeaderFileBody )
   42987           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgHeaderFileBody );
   42988           0 :           unsigned long positionInPool = localIndex % SgHeaderFileBody::pool_size ;
   42989           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgHeaderFileBody::pool_size ;
   42990             : 
   42991             : #if FILE_IO_EXTRA_CHECK
   42992             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   42993             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   42994             : #endif
   42995             : 
   42996           0 :           returnPointer = &( ( (SgHeaderFileBody*)(SgHeaderFileBody::pools[memoryBlock]) ) [positionInPool]) ;
   42997             : 
   42998             : #if FILE_IO_EXTRA_CHECK
   42999           0 :           assert ( returnPointer != NULL ) ;
   43000             : #endif
   43001             :         }
   43002           0 :      return returnPointer ;
   43003             :    }
   43004             : 
   43005             : //############################################################################
   43006             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   43007             :  * pool size! We set for every valid object in the memory pool the freepointer
   43008             :  * to the global index and increase the global index afterwards. For all the 
   43009             :  * invalid objects (means address ranges within the memory pool that were not
   43010             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   43011             :  * distinguish valid from invalid objects! 
   43012             :  */
   43013             : unsigned long
   43014           5 : SgHeaderFileBody::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   43015             :    {
   43016           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   43017           5 :      SgHeaderFileBody* pointer = NULL;
   43018           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   43019           5 :      std::vector < unsigned char* > :: const_iterator block;
   43020           5 :      for ( block = SgHeaderFileBody::pools.begin(); block != SgHeaderFileBody::pools.end() ; ++block )
   43021             :         {
   43022           0 :           pointer = (SgHeaderFileBody*)(*block);
   43023           0 :           for (unsigned i = 0; i < SgHeaderFileBody::pool_size; ++i )
   43024             :              {
   43025             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   43026             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   43027             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   43028             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   43029             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   43030             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   43031             :             // properly; so this will have to be checked next.
   43032             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   43033             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   43034           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   43035             :                   {
   43036           0 :                     pointer[i].set_freepointer((SgHeaderFileBody*)(globalIndex));
   43037           0 :                     globalIndex++;
   43038             :                   }
   43039             :                else
   43040             :                   {
   43041           0 :                     pointer[i].set_freepointer(NULL);
   43042             :                   }
   43043             :               }
   43044             :         }
   43045           5 :      return globalIndex;
   43046             :    }
   43047             : 
   43048             : //############################################################################
   43049             : // JH (01/14/2006)
   43050             : void
   43051           5 : SgHeaderFileBody::resetValidFreepointers( )
   43052             :    {
   43053           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   43054           5 :      SgHeaderFileBody* pointer = NULL;
   43055           5 :      std::vector < unsigned char* > :: const_iterator block;
   43056           5 :      SgHeaderFileBody* pointerOfLinkedList = NULL;
   43057           5 :      for ( block = SgHeaderFileBody::pools.begin(); block != SgHeaderFileBody::pools.end() ; ++block )
   43058             :         {
   43059           0 :           pointer = (SgHeaderFileBody*)(*block);
   43060           0 :           for (unsigned i = 0; i < SgHeaderFileBody::pool_size; ++i )
   43061             :              {
   43062             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   43063             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   43064             :             // memory blocks!.
   43065           0 :                if ( pointer[i].get_freepointer() != NULL )
   43066             :                   {
   43067           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   43068             :                   }
   43069             :                else
   43070             :                   {
   43071           0 :                     if ( pointerOfLinkedList == NULL )
   43072             :                        {
   43073           0 :                          SgHeaderFileBody::next_node = &(pointer[i]);
   43074             :                        }
   43075             :                     else
   43076             :                        {
   43077             :                       // printf ("In SgHeaderFileBody::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   43078           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   43079             :                        }
   43080             :                     pointerOfLinkedList = &(pointer[i]);
   43081             :                   }
   43082             :               }
   43083             :         }
   43084             : 
   43085           5 :      if ( pointerOfLinkedList != NULL )
   43086             :         {
   43087             :        // printf ("In SgHeaderFileBody::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   43088           0 :           pointerOfLinkedList->set_freepointer(NULL);
   43089             :        // DQ (6/6/2010): Temporary debugging...
   43090             :        //   ROSE_ASSERT(false);
   43091             :         }
   43092             : 
   43093           5 :      return ;
   43094             :    }
   43095             : 
   43096             : //############################################################################
   43097             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   43098             :  * within the memory pool and resets the freepointers, in order to achieve a 
   43099             :  * linked list, that has no jumps and starts at the beginning! This function 
   43100             :  * does not extend the memory pool, since we do not delete any memory blocks,
   43101             :  * but delete the valid objects.  
   43102             :  */
   43103             : void
   43104           0 : SgHeaderFileBody::clearMemoryPool( )
   43105             :    {
   43106             :   // printf ("Inside of SgHeaderFileBody::clearMemoryPool() \n");
   43107             : 
   43108           0 :      SgHeaderFileBody* pointer = NULL, *tempPointer = NULL;
   43109           0 :      std::vector < unsigned char* > :: const_iterator block;
   43110           0 :      if ( SgHeaderFileBody::pools.empty() == false )
   43111             :         {
   43112           0 :           block = SgHeaderFileBody::pools.begin() ;
   43113           0 :           SgHeaderFileBody::next_node = (SgHeaderFileBody*) (*block);
   43114             : 
   43115           0 :           while ( block != SgHeaderFileBody::pools.end() )
   43116             :              {
   43117           0 :                pointer = (SgHeaderFileBody*) (*block);
   43118           0 :                if ( tempPointer != NULL )
   43119             :                   {
   43120           0 :                     tempPointer->set_freepointer(pointer);
   43121             :                   }
   43122           0 :                for (unsigned i = 0; i < SgHeaderFileBody::pool_size - 1; ++i)
   43123             :                   {
   43124           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   43125             :                   }
   43126           0 :                 pointer[SgHeaderFileBody::pool_size-1].set_freepointer(NULL);
   43127           0 :                 tempPointer = &(pointer[SgHeaderFileBody::pool_size-1]);
   43128           0 :                 ++block;
   43129             :              }
   43130             :         }
   43131           0 :    }
   43132             : 
   43133           5 : void SgHeaderFileBody::deleteMemoryPool() {
   43134           5 :   for (auto p: SgHeaderFileBody::pools) {
   43135           0 :     ROSE_FREE(p);
   43136             :   }
   43137           5 :   SgHeaderFileBody::next_node = nullptr;
   43138           5 :   SgHeaderFileBody::pools.clear();
   43139           5 : }
   43140             : 
   43141             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   43142             : //                 reading multiple binary files to for a single AST.
   43143             : /////////// new version ////////////////////////////////
   43144             : //############################################################################
   43145             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   43146             : void
   43147           2 : SgHeaderFileBody::extendMemoryPoolForFileIO( )
   43148             :   {
   43149           2 :     size_t blockIndex = SgHeaderFileBody::pools.size();
   43150           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgHeaderFileBody) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgHeaderFileBody);
   43151             : 
   43152           2 :     while ( (blockIndex * SgHeaderFileBody::pool_size) < newPoolSize)
   43153             :       {
   43154             : #if ROSE_ALLOC_TRACE
   43155             :         if (blockIndex > 0) {
   43156             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgHeaderFileBody) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgHeaderFileBody) = %" PRIuPTR " SgHeaderFileBody::pool_size = %d \n",
   43157             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgHeaderFileBody),AST_FILE_IO::getPoolSizeOfNewAst(V_SgHeaderFileBody),SgHeaderFileBody::pool_size);
   43158             :         }
   43159             : #endif
   43160             : 
   43161           0 :         SgHeaderFileBody * pointer = (SgHeaderFileBody*) ROSE_MALLOC ( SgHeaderFileBody::pool_size * sizeof(SgHeaderFileBody) );
   43162           0 :         assert( pointer != NULL );
   43163             : #if ROSE_ALLOC_MEMSET == 1
   43164             :         memset(pointer, 0x00, SgHeaderFileBody::pool_size * sizeof(SgHeaderFileBody));
   43165             : #elif ROSE_ALLOC_MEMSET == 2
   43166             :         memset(pointer, 0xCC, SgHeaderFileBody::pool_size * sizeof(SgHeaderFileBody));
   43167             : #endif
   43168           0 :         SgHeaderFileBody::pools.push_back( (unsigned char*)(pointer) );
   43169           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgHeaderFileBody::pool_size * sizeof(SgHeaderFileBody), V_SgHeaderFileBody ) );
   43170             : 
   43171           0 :         if ( SgHeaderFileBody::next_node != NULL ) {
   43172           0 :           if ( blockIndex > 0 ) {
   43173           0 :             SgHeaderFileBody * blkptr = (SgHeaderFileBody*)(SgHeaderFileBody::pools[blockIndex-1]);
   43174           0 :             blkptr[ SgHeaderFileBody::pool_size - 1 ].set_freepointer(pointer);
   43175             :           }
   43176             :         } else {
   43177           0 :           SgHeaderFileBody::next_node = pointer;
   43178             :         }
   43179             : 
   43180           0 :         for (unsigned i = 0; i < SgHeaderFileBody::pool_size-1; ++i)
   43181             :            {
   43182           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   43183             :            }
   43184           0 :         pointer[ SgHeaderFileBody::pool_size -1 ].set_freepointer(NULL);
   43185             : 
   43186           0 :         blockIndex++;
   43187             :       }
   43188           2 :   }
   43189             : 
   43190             : //############################################################################
   43191             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   43192             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   43193             :  * not compressed. However, that stuff is not yet implemented! 
   43194             :  */
   43195             : unsigned long
   43196           0 : SgHeaderFileBody::getNumberOfLastValidPointer()
   43197             :    {
   43198           0 :       SgHeaderFileBody* testPointer = (SgHeaderFileBody*)(SgHeaderFileBody::pools.back());
   43199           0 :       unsigned long localIndex = SgHeaderFileBody::pool_size - 1;
   43200           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   43201             :          {
   43202           0 :            localIndex--;
   43203             :          }
   43204           0 :       return (localIndex + SgHeaderFileBody::pool_size * (SgHeaderFileBody::pools.size()-1));
   43205             :    }
   43206             : 
   43207             : //############################################################################
   43208             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   43209             :  * memory pool and initializes the data member in class SgHeaderFileBodyStroageClass
   43210             :  * from its counterpart of SgHeaderFileBody. The return value is just for checking, 
   43211             :  * that the whole StorageClassArray is initialized!
   43212             :  */
   43213             : unsigned long
   43214           0 : SgHeaderFileBody::initializeStorageClassArray( SgHeaderFileBodyStorageClass *storageArray )
   43215             :    {
   43216           0 :      unsigned long storageCounter = 0;
   43217           0 :      std::vector < unsigned char* > :: const_iterator block = SgHeaderFileBody::pools.begin();
   43218           0 :      SgHeaderFileBody* pointer = NULL;
   43219           0 :      while ( block != SgHeaderFileBody::pools.end() ) {
   43220           0 :           pointer = (SgHeaderFileBody*) (*block);
   43221           0 :           for ( unsigned i = 0; i < SgHeaderFileBody::pool_size; ++i ) {
   43222           0 :                if ( pointer->get_freepointer() != NULL ) {
   43223           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   43224           0 :                  storageArray++;
   43225           0 :                  storageCounter++;
   43226             :                }
   43227           0 :                pointer++;
   43228             :              }
   43229           0 :            block++;
   43230             :         }
   43231           0 :      return storageCounter;
   43232             :    }
   43233             : 
   43234             : /* #line 43235 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   43235             : 
   43236             : 
   43237             : 
   43238             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   43239             : 
   43240             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   43241             : 
   43242             : //############################################################################
   43243             : /* JH (02/02/2006) Constructor of the IR node SgRenamePair that takes its 
   43244             :  * corresponding StorageClass as parameter
   43245             :  */
   43246           0 : SgRenamePair :: SgRenamePair ( const SgRenamePairStorageClass& storageSource )   : SgLocatedNodeSupport (storageSource)
   43247             :    {
   43248             : 
   43249             : 
   43250             : /* #line 43251 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   43251             : 
   43252           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   43253           0 :      p_local_name = SgName ( storageSource.storageOf_local_name ) ;
   43254           0 :      p_use_name = SgName ( storageSource.storageOf_use_name ) ;
   43255             : 
   43256             : 
   43257             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   43258             : 
   43259             : 
   43260           0 :    }
   43261             : 
   43262             : //############################################################################
   43263             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   43264             :  * within the working AST. 
   43265             :  */
   43266           0 : SgRenamePair * SgRenamePair::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   43267           0 :      SgRenamePair* returnPointer = NULL;
   43268           0 :      if ( globalIndex != 0 )
   43269             :         {
   43270             : 
   43271             : #if FILE_IO_EXTRA_CHECK
   43272           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRenamePair ) ) <= globalIndex ) ;
   43273           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRenamePair + 1 ) ) );
   43274             : #endif
   43275           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRenamePair )  
   43276           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRenamePair );
   43277           0 :           unsigned long positionInPool = localIndex % SgRenamePair::pool_size;
   43278           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRenamePair::pool_size;
   43279             : 
   43280             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   43281             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   43282             : 
   43283           0 :           returnPointer = &( ( (SgRenamePair*)(SgRenamePair::pools[memoryBlock]) ) [positionInPool]) ;
   43284             : 
   43285           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   43286             :         }
   43287           0 :      return returnPointer ;
   43288             :    }
   43289             : 
   43290             : //############################################################################
   43291             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   43292             :   for the AST with the index astIndex
   43293             : */
   43294           0 : SgRenamePair * SgRenamePair::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   43295           0 :      SgRenamePair* returnPointer = NULL;
   43296           0 :      if ( globalIndex != 0 )
   43297             :         {
   43298             : 
   43299             : #if FILE_IO_EXTRA_CHECK
   43300           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRenamePair ) ) <= globalIndex ) ;
   43301           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRenamePair + 1 ) ) );
   43302             : #endif
   43303           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRenamePair )
   43304           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRenamePair );
   43305           0 :           unsigned long positionInPool = localIndex % SgRenamePair::pool_size ;
   43306           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRenamePair::pool_size ;
   43307             : 
   43308             : #if FILE_IO_EXTRA_CHECK
   43309             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   43310             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   43311             : #endif
   43312             : 
   43313           0 :           returnPointer = &( ( (SgRenamePair*)(SgRenamePair::pools[memoryBlock]) ) [positionInPool]) ;
   43314             : 
   43315             : #if FILE_IO_EXTRA_CHECK
   43316           0 :           assert ( returnPointer != NULL ) ;
   43317             : #endif
   43318             :         }
   43319           0 :      return returnPointer ;
   43320             :    }
   43321             : 
   43322             : //############################################################################
   43323             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   43324             :  * pool size! We set for every valid object in the memory pool the freepointer
   43325             :  * to the global index and increase the global index afterwards. For all the 
   43326             :  * invalid objects (means address ranges within the memory pool that were not
   43327             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   43328             :  * distinguish valid from invalid objects! 
   43329             :  */
   43330             : unsigned long
   43331           5 : SgRenamePair::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   43332             :    {
   43333           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   43334           5 :      SgRenamePair* pointer = NULL;
   43335           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   43336           5 :      std::vector < unsigned char* > :: const_iterator block;
   43337           5 :      for ( block = SgRenamePair::pools.begin(); block != SgRenamePair::pools.end() ; ++block )
   43338             :         {
   43339           0 :           pointer = (SgRenamePair*)(*block);
   43340           0 :           for (unsigned i = 0; i < SgRenamePair::pool_size; ++i )
   43341             :              {
   43342             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   43343             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   43344             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   43345             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   43346             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   43347             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   43348             :             // properly; so this will have to be checked next.
   43349             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   43350             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   43351           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   43352             :                   {
   43353           0 :                     pointer[i].set_freepointer((SgRenamePair*)(globalIndex));
   43354           0 :                     globalIndex++;
   43355             :                   }
   43356             :                else
   43357             :                   {
   43358           0 :                     pointer[i].set_freepointer(NULL);
   43359             :                   }
   43360             :               }
   43361             :         }
   43362           5 :      return globalIndex;
   43363             :    }
   43364             : 
   43365             : //############################################################################
   43366             : // JH (01/14/2006)
   43367             : void
   43368           5 : SgRenamePair::resetValidFreepointers( )
   43369             :    {
   43370           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   43371           5 :      SgRenamePair* pointer = NULL;
   43372           5 :      std::vector < unsigned char* > :: const_iterator block;
   43373           5 :      SgRenamePair* pointerOfLinkedList = NULL;
   43374           5 :      for ( block = SgRenamePair::pools.begin(); block != SgRenamePair::pools.end() ; ++block )
   43375             :         {
   43376           0 :           pointer = (SgRenamePair*)(*block);
   43377           0 :           for (unsigned i = 0; i < SgRenamePair::pool_size; ++i )
   43378             :              {
   43379             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   43380             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   43381             :             // memory blocks!.
   43382           0 :                if ( pointer[i].get_freepointer() != NULL )
   43383             :                   {
   43384           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   43385             :                   }
   43386             :                else
   43387             :                   {
   43388           0 :                     if ( pointerOfLinkedList == NULL )
   43389             :                        {
   43390           0 :                          SgRenamePair::next_node = &(pointer[i]);
   43391             :                        }
   43392             :                     else
   43393             :                        {
   43394             :                       // printf ("In SgRenamePair::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   43395           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   43396             :                        }
   43397             :                     pointerOfLinkedList = &(pointer[i]);
   43398             :                   }
   43399             :               }
   43400             :         }
   43401             : 
   43402           5 :      if ( pointerOfLinkedList != NULL )
   43403             :         {
   43404             :        // printf ("In SgRenamePair::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   43405           0 :           pointerOfLinkedList->set_freepointer(NULL);
   43406             :        // DQ (6/6/2010): Temporary debugging...
   43407             :        //   ROSE_ASSERT(false);
   43408             :         }
   43409             : 
   43410           5 :      return ;
   43411             :    }
   43412             : 
   43413             : //############################################################################
   43414             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   43415             :  * within the memory pool and resets the freepointers, in order to achieve a 
   43416             :  * linked list, that has no jumps and starts at the beginning! This function 
   43417             :  * does not extend the memory pool, since we do not delete any memory blocks,
   43418             :  * but delete the valid objects.  
   43419             :  */
   43420             : void
   43421           0 : SgRenamePair::clearMemoryPool( )
   43422             :    {
   43423             :   // printf ("Inside of SgRenamePair::clearMemoryPool() \n");
   43424             : 
   43425           0 :      SgRenamePair* pointer = NULL, *tempPointer = NULL;
   43426           0 :      std::vector < unsigned char* > :: const_iterator block;
   43427           0 :      if ( SgRenamePair::pools.empty() == false )
   43428             :         {
   43429           0 :           block = SgRenamePair::pools.begin() ;
   43430           0 :           SgRenamePair::next_node = (SgRenamePair*) (*block);
   43431             : 
   43432           0 :           while ( block != SgRenamePair::pools.end() )
   43433             :              {
   43434           0 :                pointer = (SgRenamePair*) (*block);
   43435           0 :                if ( tempPointer != NULL )
   43436             :                   {
   43437           0 :                     tempPointer->set_freepointer(pointer);
   43438             :                   }
   43439           0 :                for (unsigned i = 0; i < SgRenamePair::pool_size - 1; ++i)
   43440             :                   {
   43441           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   43442             :                   }
   43443           0 :                 pointer[SgRenamePair::pool_size-1].set_freepointer(NULL);
   43444           0 :                 tempPointer = &(pointer[SgRenamePair::pool_size-1]);
   43445           0 :                 ++block;
   43446             :              }
   43447             :         }
   43448           0 :    }
   43449             : 
   43450           5 : void SgRenamePair::deleteMemoryPool() {
   43451           5 :   for (auto p: SgRenamePair::pools) {
   43452           0 :     ROSE_FREE(p);
   43453             :   }
   43454           5 :   SgRenamePair::next_node = nullptr;
   43455           5 :   SgRenamePair::pools.clear();
   43456           5 : }
   43457             : 
   43458             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   43459             : //                 reading multiple binary files to for a single AST.
   43460             : /////////// new version ////////////////////////////////
   43461             : //############################################################################
   43462             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   43463             : void
   43464           2 : SgRenamePair::extendMemoryPoolForFileIO( )
   43465             :   {
   43466           2 :     size_t blockIndex = SgRenamePair::pools.size();
   43467           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRenamePair) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRenamePair);
   43468             : 
   43469           2 :     while ( (blockIndex * SgRenamePair::pool_size) < newPoolSize)
   43470             :       {
   43471             : #if ROSE_ALLOC_TRACE
   43472             :         if (blockIndex > 0) {
   43473             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRenamePair) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRenamePair) = %" PRIuPTR " SgRenamePair::pool_size = %d \n",
   43474             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRenamePair),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRenamePair),SgRenamePair::pool_size);
   43475             :         }
   43476             : #endif
   43477             : 
   43478           0 :         SgRenamePair * pointer = (SgRenamePair*) ROSE_MALLOC ( SgRenamePair::pool_size * sizeof(SgRenamePair) );
   43479           0 :         assert( pointer != NULL );
   43480             : #if ROSE_ALLOC_MEMSET == 1
   43481             :         memset(pointer, 0x00, SgRenamePair::pool_size * sizeof(SgRenamePair));
   43482             : #elif ROSE_ALLOC_MEMSET == 2
   43483             :         memset(pointer, 0xCC, SgRenamePair::pool_size * sizeof(SgRenamePair));
   43484             : #endif
   43485           0 :         SgRenamePair::pools.push_back( (unsigned char*)(pointer) );
   43486           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRenamePair::pool_size * sizeof(SgRenamePair), V_SgRenamePair ) );
   43487             : 
   43488           0 :         if ( SgRenamePair::next_node != NULL ) {
   43489           0 :           if ( blockIndex > 0 ) {
   43490           0 :             SgRenamePair * blkptr = (SgRenamePair*)(SgRenamePair::pools[blockIndex-1]);
   43491           0 :             blkptr[ SgRenamePair::pool_size - 1 ].set_freepointer(pointer);
   43492             :           }
   43493             :         } else {
   43494           0 :           SgRenamePair::next_node = pointer;
   43495             :         }
   43496             : 
   43497           0 :         for (unsigned i = 0; i < SgRenamePair::pool_size-1; ++i)
   43498             :            {
   43499           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   43500             :            }
   43501           0 :         pointer[ SgRenamePair::pool_size -1 ].set_freepointer(NULL);
   43502             : 
   43503           0 :         blockIndex++;
   43504             :       }
   43505           2 :   }
   43506             : 
   43507             : //############################################################################
   43508             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   43509             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   43510             :  * not compressed. However, that stuff is not yet implemented! 
   43511             :  */
   43512             : unsigned long
   43513           0 : SgRenamePair::getNumberOfLastValidPointer()
   43514             :    {
   43515           0 :       SgRenamePair* testPointer = (SgRenamePair*)(SgRenamePair::pools.back());
   43516           0 :       unsigned long localIndex = SgRenamePair::pool_size - 1;
   43517           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   43518             :          {
   43519           0 :            localIndex--;
   43520             :          }
   43521           0 :       return (localIndex + SgRenamePair::pool_size * (SgRenamePair::pools.size()-1));
   43522             :    }
   43523             : 
   43524             : //############################################################################
   43525             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   43526             :  * memory pool and initializes the data member in class SgRenamePairStroageClass
   43527             :  * from its counterpart of SgRenamePair. The return value is just for checking, 
   43528             :  * that the whole StorageClassArray is initialized!
   43529             :  */
   43530             : unsigned long
   43531           0 : SgRenamePair::initializeStorageClassArray( SgRenamePairStorageClass *storageArray )
   43532             :    {
   43533           0 :      unsigned long storageCounter = 0;
   43534           0 :      std::vector < unsigned char* > :: const_iterator block = SgRenamePair::pools.begin();
   43535           0 :      SgRenamePair* pointer = NULL;
   43536           0 :      while ( block != SgRenamePair::pools.end() ) {
   43537           0 :           pointer = (SgRenamePair*) (*block);
   43538           0 :           for ( unsigned i = 0; i < SgRenamePair::pool_size; ++i ) {
   43539           0 :                if ( pointer->get_freepointer() != NULL ) {
   43540           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   43541           0 :                  storageArray++;
   43542           0 :                  storageCounter++;
   43543             :                }
   43544           0 :                pointer++;
   43545             :              }
   43546           0 :            block++;
   43547             :         }
   43548           0 :      return storageCounter;
   43549             :    }
   43550             : 
   43551             : /* #line 43552 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   43552             : 
   43553             : 
   43554             : 
   43555             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   43556             : 
   43557             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   43558             : 
   43559             : //############################################################################
   43560             : /* JH (02/02/2006) Constructor of the IR node SgOmpClause that takes its 
   43561             :  * corresponding StorageClass as parameter
   43562             :  */
   43563           0 : SgOmpClause :: SgOmpClause ( const SgOmpClauseStorageClass& storageSource )   : SgLocatedNodeSupport (storageSource)
   43564             :    {
   43565             : 
   43566             : 
   43567             : /* #line 43568 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   43568             : 
   43569           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   43570             : 
   43571             : 
   43572             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   43573             : 
   43574             : 
   43575           0 :    }
   43576             : 
   43577             : //############################################################################
   43578             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   43579             :  * within the working AST. 
   43580             :  */
   43581           0 : SgOmpClause * SgOmpClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   43582           0 :      SgOmpClause* returnPointer = NULL;
   43583           0 :      if ( globalIndex != 0 )
   43584             :         {
   43585             : 
   43586             : #if FILE_IO_EXTRA_CHECK
   43587           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpClause ) ) <= globalIndex ) ;
   43588           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpClause + 1 ) ) );
   43589             : #endif
   43590           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpClause )  
   43591           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpClause );
   43592           0 :           unsigned long positionInPool = localIndex % SgOmpClause::pool_size;
   43593           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpClause::pool_size;
   43594             : 
   43595             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   43596             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   43597             : 
   43598           0 :           returnPointer = &( ( (SgOmpClause*)(SgOmpClause::pools[memoryBlock]) ) [positionInPool]) ;
   43599             : 
   43600           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   43601             :         }
   43602           0 :      return returnPointer ;
   43603             :    }
   43604             : 
   43605             : //############################################################################
   43606             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   43607             :   for the AST with the index astIndex
   43608             : */
   43609           0 : SgOmpClause * SgOmpClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   43610           0 :      SgOmpClause* returnPointer = NULL;
   43611           0 :      if ( globalIndex != 0 )
   43612             :         {
   43613             : 
   43614             : #if FILE_IO_EXTRA_CHECK
   43615           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpClause ) ) <= globalIndex ) ;
   43616           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpClause + 1 ) ) );
   43617             : #endif
   43618           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpClause )
   43619           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpClause );
   43620           0 :           unsigned long positionInPool = localIndex % SgOmpClause::pool_size ;
   43621           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpClause::pool_size ;
   43622             : 
   43623             : #if FILE_IO_EXTRA_CHECK
   43624             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   43625             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   43626             : #endif
   43627             : 
   43628           0 :           returnPointer = &( ( (SgOmpClause*)(SgOmpClause::pools[memoryBlock]) ) [positionInPool]) ;
   43629             : 
   43630             : #if FILE_IO_EXTRA_CHECK
   43631           0 :           assert ( returnPointer != NULL ) ;
   43632             : #endif
   43633             :         }
   43634           0 :      return returnPointer ;
   43635             :    }
   43636             : 
   43637             : //############################################################################
   43638             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   43639             :  * pool size! We set for every valid object in the memory pool the freepointer
   43640             :  * to the global index and increase the global index afterwards. For all the 
   43641             :  * invalid objects (means address ranges within the memory pool that were not
   43642             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   43643             :  * distinguish valid from invalid objects! 
   43644             :  */
   43645             : unsigned long
   43646           5 : SgOmpClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   43647             :    {
   43648           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   43649           5 :      SgOmpClause* pointer = NULL;
   43650           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   43651           5 :      std::vector < unsigned char* > :: const_iterator block;
   43652           5 :      for ( block = SgOmpClause::pools.begin(); block != SgOmpClause::pools.end() ; ++block )
   43653             :         {
   43654           0 :           pointer = (SgOmpClause*)(*block);
   43655           0 :           for (unsigned i = 0; i < SgOmpClause::pool_size; ++i )
   43656             :              {
   43657             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   43658             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   43659             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   43660             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   43661             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   43662             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   43663             :             // properly; so this will have to be checked next.
   43664             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   43665             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   43666           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   43667             :                   {
   43668           0 :                     pointer[i].set_freepointer((SgOmpClause*)(globalIndex));
   43669           0 :                     globalIndex++;
   43670             :                   }
   43671             :                else
   43672             :                   {
   43673           0 :                     pointer[i].set_freepointer(NULL);
   43674             :                   }
   43675             :               }
   43676             :         }
   43677           5 :      return globalIndex;
   43678             :    }
   43679             : 
   43680             : //############################################################################
   43681             : // JH (01/14/2006)
   43682             : void
   43683           5 : SgOmpClause::resetValidFreepointers( )
   43684             :    {
   43685           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   43686           5 :      SgOmpClause* pointer = NULL;
   43687           5 :      std::vector < unsigned char* > :: const_iterator block;
   43688           5 :      SgOmpClause* pointerOfLinkedList = NULL;
   43689           5 :      for ( block = SgOmpClause::pools.begin(); block != SgOmpClause::pools.end() ; ++block )
   43690             :         {
   43691           0 :           pointer = (SgOmpClause*)(*block);
   43692           0 :           for (unsigned i = 0; i < SgOmpClause::pool_size; ++i )
   43693             :              {
   43694             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   43695             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   43696             :             // memory blocks!.
   43697           0 :                if ( pointer[i].get_freepointer() != NULL )
   43698             :                   {
   43699           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   43700             :                   }
   43701             :                else
   43702             :                   {
   43703           0 :                     if ( pointerOfLinkedList == NULL )
   43704             :                        {
   43705           0 :                          SgOmpClause::next_node = &(pointer[i]);
   43706             :                        }
   43707             :                     else
   43708             :                        {
   43709             :                       // printf ("In SgOmpClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   43710           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   43711             :                        }
   43712             :                     pointerOfLinkedList = &(pointer[i]);
   43713             :                   }
   43714             :               }
   43715             :         }
   43716             : 
   43717           5 :      if ( pointerOfLinkedList != NULL )
   43718             :         {
   43719             :        // printf ("In SgOmpClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   43720           0 :           pointerOfLinkedList->set_freepointer(NULL);
   43721             :        // DQ (6/6/2010): Temporary debugging...
   43722             :        //   ROSE_ASSERT(false);
   43723             :         }
   43724             : 
   43725           5 :      return ;
   43726             :    }
   43727             : 
   43728             : //############################################################################
   43729             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   43730             :  * within the memory pool and resets the freepointers, in order to achieve a 
   43731             :  * linked list, that has no jumps and starts at the beginning! This function 
   43732             :  * does not extend the memory pool, since we do not delete any memory blocks,
   43733             :  * but delete the valid objects.  
   43734             :  */
   43735             : void
   43736           0 : SgOmpClause::clearMemoryPool( )
   43737             :    {
   43738             :   // printf ("Inside of SgOmpClause::clearMemoryPool() \n");
   43739             : 
   43740           0 :      SgOmpClause* pointer = NULL, *tempPointer = NULL;
   43741           0 :      std::vector < unsigned char* > :: const_iterator block;
   43742           0 :      if ( SgOmpClause::pools.empty() == false )
   43743             :         {
   43744           0 :           block = SgOmpClause::pools.begin() ;
   43745           0 :           SgOmpClause::next_node = (SgOmpClause*) (*block);
   43746             : 
   43747           0 :           while ( block != SgOmpClause::pools.end() )
   43748             :              {
   43749           0 :                pointer = (SgOmpClause*) (*block);
   43750           0 :                if ( tempPointer != NULL )
   43751             :                   {
   43752           0 :                     tempPointer->set_freepointer(pointer);
   43753             :                   }
   43754           0 :                for (unsigned i = 0; i < SgOmpClause::pool_size - 1; ++i)
   43755             :                   {
   43756           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   43757             :                   }
   43758           0 :                 pointer[SgOmpClause::pool_size-1].set_freepointer(NULL);
   43759           0 :                 tempPointer = &(pointer[SgOmpClause::pool_size-1]);
   43760           0 :                 ++block;
   43761             :              }
   43762             :         }
   43763           0 :    }
   43764             : 
   43765           5 : void SgOmpClause::deleteMemoryPool() {
   43766           5 :   for (auto p: SgOmpClause::pools) {
   43767           0 :     ROSE_FREE(p);
   43768             :   }
   43769           5 :   SgOmpClause::next_node = nullptr;
   43770           5 :   SgOmpClause::pools.clear();
   43771           5 : }
   43772             : 
   43773             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   43774             : //                 reading multiple binary files to for a single AST.
   43775             : /////////// new version ////////////////////////////////
   43776             : //############################################################################
   43777             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   43778             : void
   43779           2 : SgOmpClause::extendMemoryPoolForFileIO( )
   43780             :   {
   43781           2 :     size_t blockIndex = SgOmpClause::pools.size();
   43782           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpClause);
   43783             : 
   43784           2 :     while ( (blockIndex * SgOmpClause::pool_size) < newPoolSize)
   43785             :       {
   43786             : #if ROSE_ALLOC_TRACE
   43787             :         if (blockIndex > 0) {
   43788             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpClause) = %" PRIuPTR " SgOmpClause::pool_size = %d \n",
   43789             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpClause),SgOmpClause::pool_size);
   43790             :         }
   43791             : #endif
   43792             : 
   43793           0 :         SgOmpClause * pointer = (SgOmpClause*) ROSE_MALLOC ( SgOmpClause::pool_size * sizeof(SgOmpClause) );
   43794           0 :         assert( pointer != NULL );
   43795             : #if ROSE_ALLOC_MEMSET == 1
   43796             :         memset(pointer, 0x00, SgOmpClause::pool_size * sizeof(SgOmpClause));
   43797             : #elif ROSE_ALLOC_MEMSET == 2
   43798             :         memset(pointer, 0xCC, SgOmpClause::pool_size * sizeof(SgOmpClause));
   43799             : #endif
   43800           0 :         SgOmpClause::pools.push_back( (unsigned char*)(pointer) );
   43801           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpClause::pool_size * sizeof(SgOmpClause), V_SgOmpClause ) );
   43802             : 
   43803           0 :         if ( SgOmpClause::next_node != NULL ) {
   43804           0 :           if ( blockIndex > 0 ) {
   43805           0 :             SgOmpClause * blkptr = (SgOmpClause*)(SgOmpClause::pools[blockIndex-1]);
   43806           0 :             blkptr[ SgOmpClause::pool_size - 1 ].set_freepointer(pointer);
   43807             :           }
   43808             :         } else {
   43809           0 :           SgOmpClause::next_node = pointer;
   43810             :         }
   43811             : 
   43812           0 :         for (unsigned i = 0; i < SgOmpClause::pool_size-1; ++i)
   43813             :            {
   43814           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   43815             :            }
   43816           0 :         pointer[ SgOmpClause::pool_size -1 ].set_freepointer(NULL);
   43817             : 
   43818           0 :         blockIndex++;
   43819             :       }
   43820           2 :   }
   43821             : 
   43822             : //############################################################################
   43823             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   43824             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   43825             :  * not compressed. However, that stuff is not yet implemented! 
   43826             :  */
   43827             : unsigned long
   43828           0 : SgOmpClause::getNumberOfLastValidPointer()
   43829             :    {
   43830           0 :       SgOmpClause* testPointer = (SgOmpClause*)(SgOmpClause::pools.back());
   43831           0 :       unsigned long localIndex = SgOmpClause::pool_size - 1;
   43832           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   43833             :          {
   43834           0 :            localIndex--;
   43835             :          }
   43836           0 :       return (localIndex + SgOmpClause::pool_size * (SgOmpClause::pools.size()-1));
   43837             :    }
   43838             : 
   43839             : //############################################################################
   43840             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   43841             :  * memory pool and initializes the data member in class SgOmpClauseStroageClass
   43842             :  * from its counterpart of SgOmpClause. The return value is just for checking, 
   43843             :  * that the whole StorageClassArray is initialized!
   43844             :  */
   43845             : unsigned long
   43846           0 : SgOmpClause::initializeStorageClassArray( SgOmpClauseStorageClass *storageArray )
   43847             :    {
   43848           0 :      unsigned long storageCounter = 0;
   43849           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpClause::pools.begin();
   43850           0 :      SgOmpClause* pointer = NULL;
   43851           0 :      while ( block != SgOmpClause::pools.end() ) {
   43852           0 :           pointer = (SgOmpClause*) (*block);
   43853           0 :           for ( unsigned i = 0; i < SgOmpClause::pool_size; ++i ) {
   43854           0 :                if ( pointer->get_freepointer() != NULL ) {
   43855           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   43856           0 :                  storageArray++;
   43857           0 :                  storageCounter++;
   43858             :                }
   43859           0 :                pointer++;
   43860             :              }
   43861           0 :            block++;
   43862             :         }
   43863           0 :      return storageCounter;
   43864             :    }
   43865             : 
   43866             : /* #line 43867 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   43867             : 
   43868             : 
   43869             : 
   43870             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   43871             : 
   43872             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   43873             : 
   43874             : //############################################################################
   43875             : /* JH (02/02/2006) Constructor of the IR node SgOmpNowaitClause that takes its 
   43876             :  * corresponding StorageClass as parameter
   43877             :  */
   43878           0 : SgOmpNowaitClause :: SgOmpNowaitClause ( const SgOmpNowaitClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   43879             :    {
   43880             : 
   43881             : 
   43882             : /* #line 43883 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   43883             : 
   43884           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   43885             : 
   43886             : 
   43887             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   43888             : 
   43889             : 
   43890           0 :    }
   43891             : 
   43892             : //############################################################################
   43893             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   43894             :  * within the working AST. 
   43895             :  */
   43896           0 : SgOmpNowaitClause * SgOmpNowaitClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   43897           0 :      SgOmpNowaitClause* returnPointer = NULL;
   43898           0 :      if ( globalIndex != 0 )
   43899             :         {
   43900             : 
   43901             : #if FILE_IO_EXTRA_CHECK
   43902           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpNowaitClause ) ) <= globalIndex ) ;
   43903           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNowaitClause + 1 ) ) );
   43904             : #endif
   43905           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNowaitClause )  
   43906           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpNowaitClause );
   43907           0 :           unsigned long positionInPool = localIndex % SgOmpNowaitClause::pool_size;
   43908           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNowaitClause::pool_size;
   43909             : 
   43910             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   43911             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   43912             : 
   43913           0 :           returnPointer = &( ( (SgOmpNowaitClause*)(SgOmpNowaitClause::pools[memoryBlock]) ) [positionInPool]) ;
   43914             : 
   43915           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   43916             :         }
   43917           0 :      return returnPointer ;
   43918             :    }
   43919             : 
   43920             : //############################################################################
   43921             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   43922             :   for the AST with the index astIndex
   43923             : */
   43924           0 : SgOmpNowaitClause * SgOmpNowaitClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   43925           0 :      SgOmpNowaitClause* returnPointer = NULL;
   43926           0 :      if ( globalIndex != 0 )
   43927             :         {
   43928             : 
   43929             : #if FILE_IO_EXTRA_CHECK
   43930           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpNowaitClause ) ) <= globalIndex ) ;
   43931           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNowaitClause + 1 ) ) );
   43932             : #endif
   43933           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNowaitClause )
   43934           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpNowaitClause );
   43935           0 :           unsigned long positionInPool = localIndex % SgOmpNowaitClause::pool_size ;
   43936           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNowaitClause::pool_size ;
   43937             : 
   43938             : #if FILE_IO_EXTRA_CHECK
   43939             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   43940             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   43941             : #endif
   43942             : 
   43943           0 :           returnPointer = &( ( (SgOmpNowaitClause*)(SgOmpNowaitClause::pools[memoryBlock]) ) [positionInPool]) ;
   43944             : 
   43945             : #if FILE_IO_EXTRA_CHECK
   43946           0 :           assert ( returnPointer != NULL ) ;
   43947             : #endif
   43948             :         }
   43949           0 :      return returnPointer ;
   43950             :    }
   43951             : 
   43952             : //############################################################################
   43953             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   43954             :  * pool size! We set for every valid object in the memory pool the freepointer
   43955             :  * to the global index and increase the global index afterwards. For all the 
   43956             :  * invalid objects (means address ranges within the memory pool that were not
   43957             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   43958             :  * distinguish valid from invalid objects! 
   43959             :  */
   43960             : unsigned long
   43961           5 : SgOmpNowaitClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   43962             :    {
   43963           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   43964           5 :      SgOmpNowaitClause* pointer = NULL;
   43965           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   43966           5 :      std::vector < unsigned char* > :: const_iterator block;
   43967           5 :      for ( block = SgOmpNowaitClause::pools.begin(); block != SgOmpNowaitClause::pools.end() ; ++block )
   43968             :         {
   43969           0 :           pointer = (SgOmpNowaitClause*)(*block);
   43970           0 :           for (unsigned i = 0; i < SgOmpNowaitClause::pool_size; ++i )
   43971             :              {
   43972             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   43973             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   43974             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   43975             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   43976             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   43977             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   43978             :             // properly; so this will have to be checked next.
   43979             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   43980             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   43981           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   43982             :                   {
   43983           0 :                     pointer[i].set_freepointer((SgOmpNowaitClause*)(globalIndex));
   43984           0 :                     globalIndex++;
   43985             :                   }
   43986             :                else
   43987             :                   {
   43988           0 :                     pointer[i].set_freepointer(NULL);
   43989             :                   }
   43990             :               }
   43991             :         }
   43992           5 :      return globalIndex;
   43993             :    }
   43994             : 
   43995             : //############################################################################
   43996             : // JH (01/14/2006)
   43997             : void
   43998           5 : SgOmpNowaitClause::resetValidFreepointers( )
   43999             :    {
   44000           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   44001           5 :      SgOmpNowaitClause* pointer = NULL;
   44002           5 :      std::vector < unsigned char* > :: const_iterator block;
   44003           5 :      SgOmpNowaitClause* pointerOfLinkedList = NULL;
   44004           5 :      for ( block = SgOmpNowaitClause::pools.begin(); block != SgOmpNowaitClause::pools.end() ; ++block )
   44005             :         {
   44006           0 :           pointer = (SgOmpNowaitClause*)(*block);
   44007           0 :           for (unsigned i = 0; i < SgOmpNowaitClause::pool_size; ++i )
   44008             :              {
   44009             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   44010             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   44011             :             // memory blocks!.
   44012           0 :                if ( pointer[i].get_freepointer() != NULL )
   44013             :                   {
   44014           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   44015             :                   }
   44016             :                else
   44017             :                   {
   44018           0 :                     if ( pointerOfLinkedList == NULL )
   44019             :                        {
   44020           0 :                          SgOmpNowaitClause::next_node = &(pointer[i]);
   44021             :                        }
   44022             :                     else
   44023             :                        {
   44024             :                       // printf ("In SgOmpNowaitClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   44025           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   44026             :                        }
   44027             :                     pointerOfLinkedList = &(pointer[i]);
   44028             :                   }
   44029             :               }
   44030             :         }
   44031             : 
   44032           5 :      if ( pointerOfLinkedList != NULL )
   44033             :         {
   44034             :        // printf ("In SgOmpNowaitClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   44035           0 :           pointerOfLinkedList->set_freepointer(NULL);
   44036             :        // DQ (6/6/2010): Temporary debugging...
   44037             :        //   ROSE_ASSERT(false);
   44038             :         }
   44039             : 
   44040           5 :      return ;
   44041             :    }
   44042             : 
   44043             : //############################################################################
   44044             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   44045             :  * within the memory pool and resets the freepointers, in order to achieve a 
   44046             :  * linked list, that has no jumps and starts at the beginning! This function 
   44047             :  * does not extend the memory pool, since we do not delete any memory blocks,
   44048             :  * but delete the valid objects.  
   44049             :  */
   44050             : void
   44051           0 : SgOmpNowaitClause::clearMemoryPool( )
   44052             :    {
   44053             :   // printf ("Inside of SgOmpNowaitClause::clearMemoryPool() \n");
   44054             : 
   44055           0 :      SgOmpNowaitClause* pointer = NULL, *tempPointer = NULL;
   44056           0 :      std::vector < unsigned char* > :: const_iterator block;
   44057           0 :      if ( SgOmpNowaitClause::pools.empty() == false )
   44058             :         {
   44059           0 :           block = SgOmpNowaitClause::pools.begin() ;
   44060           0 :           SgOmpNowaitClause::next_node = (SgOmpNowaitClause*) (*block);
   44061             : 
   44062           0 :           while ( block != SgOmpNowaitClause::pools.end() )
   44063             :              {
   44064           0 :                pointer = (SgOmpNowaitClause*) (*block);
   44065           0 :                if ( tempPointer != NULL )
   44066             :                   {
   44067           0 :                     tempPointer->set_freepointer(pointer);
   44068             :                   }
   44069           0 :                for (unsigned i = 0; i < SgOmpNowaitClause::pool_size - 1; ++i)
   44070             :                   {
   44071           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   44072             :                   }
   44073           0 :                 pointer[SgOmpNowaitClause::pool_size-1].set_freepointer(NULL);
   44074           0 :                 tempPointer = &(pointer[SgOmpNowaitClause::pool_size-1]);
   44075           0 :                 ++block;
   44076             :              }
   44077             :         }
   44078           0 :    }
   44079             : 
   44080           5 : void SgOmpNowaitClause::deleteMemoryPool() {
   44081           5 :   for (auto p: SgOmpNowaitClause::pools) {
   44082           0 :     ROSE_FREE(p);
   44083             :   }
   44084           5 :   SgOmpNowaitClause::next_node = nullptr;
   44085           5 :   SgOmpNowaitClause::pools.clear();
   44086           5 : }
   44087             : 
   44088             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   44089             : //                 reading multiple binary files to for a single AST.
   44090             : /////////// new version ////////////////////////////////
   44091             : //############################################################################
   44092             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   44093             : void
   44094           2 : SgOmpNowaitClause::extendMemoryPoolForFileIO( )
   44095             :   {
   44096           2 :     size_t blockIndex = SgOmpNowaitClause::pools.size();
   44097           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNowaitClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNowaitClause);
   44098             : 
   44099           2 :     while ( (blockIndex * SgOmpNowaitClause::pool_size) < newPoolSize)
   44100             :       {
   44101             : #if ROSE_ALLOC_TRACE
   44102             :         if (blockIndex > 0) {
   44103             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNowaitClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNowaitClause) = %" PRIuPTR " SgOmpNowaitClause::pool_size = %d \n",
   44104             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNowaitClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNowaitClause),SgOmpNowaitClause::pool_size);
   44105             :         }
   44106             : #endif
   44107             : 
   44108           0 :         SgOmpNowaitClause * pointer = (SgOmpNowaitClause*) ROSE_MALLOC ( SgOmpNowaitClause::pool_size * sizeof(SgOmpNowaitClause) );
   44109           0 :         assert( pointer != NULL );
   44110             : #if ROSE_ALLOC_MEMSET == 1
   44111             :         memset(pointer, 0x00, SgOmpNowaitClause::pool_size * sizeof(SgOmpNowaitClause));
   44112             : #elif ROSE_ALLOC_MEMSET == 2
   44113             :         memset(pointer, 0xCC, SgOmpNowaitClause::pool_size * sizeof(SgOmpNowaitClause));
   44114             : #endif
   44115           0 :         SgOmpNowaitClause::pools.push_back( (unsigned char*)(pointer) );
   44116           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpNowaitClause::pool_size * sizeof(SgOmpNowaitClause), V_SgOmpNowaitClause ) );
   44117             : 
   44118           0 :         if ( SgOmpNowaitClause::next_node != NULL ) {
   44119           0 :           if ( blockIndex > 0 ) {
   44120           0 :             SgOmpNowaitClause * blkptr = (SgOmpNowaitClause*)(SgOmpNowaitClause::pools[blockIndex-1]);
   44121           0 :             blkptr[ SgOmpNowaitClause::pool_size - 1 ].set_freepointer(pointer);
   44122             :           }
   44123             :         } else {
   44124           0 :           SgOmpNowaitClause::next_node = pointer;
   44125             :         }
   44126             : 
   44127           0 :         for (unsigned i = 0; i < SgOmpNowaitClause::pool_size-1; ++i)
   44128             :            {
   44129           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   44130             :            }
   44131           0 :         pointer[ SgOmpNowaitClause::pool_size -1 ].set_freepointer(NULL);
   44132             : 
   44133           0 :         blockIndex++;
   44134             :       }
   44135           2 :   }
   44136             : 
   44137             : //############################################################################
   44138             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   44139             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   44140             :  * not compressed. However, that stuff is not yet implemented! 
   44141             :  */
   44142             : unsigned long
   44143           0 : SgOmpNowaitClause::getNumberOfLastValidPointer()
   44144             :    {
   44145           0 :       SgOmpNowaitClause* testPointer = (SgOmpNowaitClause*)(SgOmpNowaitClause::pools.back());
   44146           0 :       unsigned long localIndex = SgOmpNowaitClause::pool_size - 1;
   44147           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   44148             :          {
   44149           0 :            localIndex--;
   44150             :          }
   44151           0 :       return (localIndex + SgOmpNowaitClause::pool_size * (SgOmpNowaitClause::pools.size()-1));
   44152             :    }
   44153             : 
   44154             : //############################################################################
   44155             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   44156             :  * memory pool and initializes the data member in class SgOmpNowaitClauseStroageClass
   44157             :  * from its counterpart of SgOmpNowaitClause. The return value is just for checking, 
   44158             :  * that the whole StorageClassArray is initialized!
   44159             :  */
   44160             : unsigned long
   44161           0 : SgOmpNowaitClause::initializeStorageClassArray( SgOmpNowaitClauseStorageClass *storageArray )
   44162             :    {
   44163           0 :      unsigned long storageCounter = 0;
   44164           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpNowaitClause::pools.begin();
   44165           0 :      SgOmpNowaitClause* pointer = NULL;
   44166           0 :      while ( block != SgOmpNowaitClause::pools.end() ) {
   44167           0 :           pointer = (SgOmpNowaitClause*) (*block);
   44168           0 :           for ( unsigned i = 0; i < SgOmpNowaitClause::pool_size; ++i ) {
   44169           0 :                if ( pointer->get_freepointer() != NULL ) {
   44170           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   44171           0 :                  storageArray++;
   44172           0 :                  storageCounter++;
   44173             :                }
   44174           0 :                pointer++;
   44175             :              }
   44176           0 :            block++;
   44177             :         }
   44178           0 :      return storageCounter;
   44179             :    }
   44180             : 
   44181             : /* #line 44182 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   44182             : 
   44183             : 
   44184             : 
   44185             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   44186             : 
   44187             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   44188             : 
   44189             : //############################################################################
   44190             : /* JH (02/02/2006) Constructor of the IR node SgOmpReadClause that takes its 
   44191             :  * corresponding StorageClass as parameter
   44192             :  */
   44193           0 : SgOmpReadClause :: SgOmpReadClause ( const SgOmpReadClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   44194             :    {
   44195             : 
   44196             : 
   44197             : /* #line 44198 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   44198             : 
   44199           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   44200             : 
   44201             : 
   44202             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   44203             : 
   44204             : 
   44205           0 :    }
   44206             : 
   44207             : //############################################################################
   44208             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   44209             :  * within the working AST. 
   44210             :  */
   44211           0 : SgOmpReadClause * SgOmpReadClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   44212           0 :      SgOmpReadClause* returnPointer = NULL;
   44213           0 :      if ( globalIndex != 0 )
   44214             :         {
   44215             : 
   44216             : #if FILE_IO_EXTRA_CHECK
   44217           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpReadClause ) ) <= globalIndex ) ;
   44218           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpReadClause + 1 ) ) );
   44219             : #endif
   44220           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpReadClause )  
   44221           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpReadClause );
   44222           0 :           unsigned long positionInPool = localIndex % SgOmpReadClause::pool_size;
   44223           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpReadClause::pool_size;
   44224             : 
   44225             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   44226             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   44227             : 
   44228           0 :           returnPointer = &( ( (SgOmpReadClause*)(SgOmpReadClause::pools[memoryBlock]) ) [positionInPool]) ;
   44229             : 
   44230           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   44231             :         }
   44232           0 :      return returnPointer ;
   44233             :    }
   44234             : 
   44235             : //############################################################################
   44236             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   44237             :   for the AST with the index astIndex
   44238             : */
   44239           0 : SgOmpReadClause * SgOmpReadClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   44240           0 :      SgOmpReadClause* returnPointer = NULL;
   44241           0 :      if ( globalIndex != 0 )
   44242             :         {
   44243             : 
   44244             : #if FILE_IO_EXTRA_CHECK
   44245           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpReadClause ) ) <= globalIndex ) ;
   44246           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpReadClause + 1 ) ) );
   44247             : #endif
   44248           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpReadClause )
   44249           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpReadClause );
   44250           0 :           unsigned long positionInPool = localIndex % SgOmpReadClause::pool_size ;
   44251           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpReadClause::pool_size ;
   44252             : 
   44253             : #if FILE_IO_EXTRA_CHECK
   44254             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   44255             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   44256             : #endif
   44257             : 
   44258           0 :           returnPointer = &( ( (SgOmpReadClause*)(SgOmpReadClause::pools[memoryBlock]) ) [positionInPool]) ;
   44259             : 
   44260             : #if FILE_IO_EXTRA_CHECK
   44261           0 :           assert ( returnPointer != NULL ) ;
   44262             : #endif
   44263             :         }
   44264           0 :      return returnPointer ;
   44265             :    }
   44266             : 
   44267             : //############################################################################
   44268             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   44269             :  * pool size! We set for every valid object in the memory pool the freepointer
   44270             :  * to the global index and increase the global index afterwards. For all the 
   44271             :  * invalid objects (means address ranges within the memory pool that were not
   44272             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   44273             :  * distinguish valid from invalid objects! 
   44274             :  */
   44275             : unsigned long
   44276           5 : SgOmpReadClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   44277             :    {
   44278           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   44279           5 :      SgOmpReadClause* pointer = NULL;
   44280           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   44281           5 :      std::vector < unsigned char* > :: const_iterator block;
   44282           5 :      for ( block = SgOmpReadClause::pools.begin(); block != SgOmpReadClause::pools.end() ; ++block )
   44283             :         {
   44284           0 :           pointer = (SgOmpReadClause*)(*block);
   44285           0 :           for (unsigned i = 0; i < SgOmpReadClause::pool_size; ++i )
   44286             :              {
   44287             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   44288             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   44289             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   44290             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   44291             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   44292             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   44293             :             // properly; so this will have to be checked next.
   44294             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   44295             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   44296           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   44297             :                   {
   44298           0 :                     pointer[i].set_freepointer((SgOmpReadClause*)(globalIndex));
   44299           0 :                     globalIndex++;
   44300             :                   }
   44301             :                else
   44302             :                   {
   44303           0 :                     pointer[i].set_freepointer(NULL);
   44304             :                   }
   44305             :               }
   44306             :         }
   44307           5 :      return globalIndex;
   44308             :    }
   44309             : 
   44310             : //############################################################################
   44311             : // JH (01/14/2006)
   44312             : void
   44313           5 : SgOmpReadClause::resetValidFreepointers( )
   44314             :    {
   44315           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   44316           5 :      SgOmpReadClause* pointer = NULL;
   44317           5 :      std::vector < unsigned char* > :: const_iterator block;
   44318           5 :      SgOmpReadClause* pointerOfLinkedList = NULL;
   44319           5 :      for ( block = SgOmpReadClause::pools.begin(); block != SgOmpReadClause::pools.end() ; ++block )
   44320             :         {
   44321           0 :           pointer = (SgOmpReadClause*)(*block);
   44322           0 :           for (unsigned i = 0; i < SgOmpReadClause::pool_size; ++i )
   44323             :              {
   44324             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   44325             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   44326             :             // memory blocks!.
   44327           0 :                if ( pointer[i].get_freepointer() != NULL )
   44328             :                   {
   44329           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   44330             :                   }
   44331             :                else
   44332             :                   {
   44333           0 :                     if ( pointerOfLinkedList == NULL )
   44334             :                        {
   44335           0 :                          SgOmpReadClause::next_node = &(pointer[i]);
   44336             :                        }
   44337             :                     else
   44338             :                        {
   44339             :                       // printf ("In SgOmpReadClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   44340           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   44341             :                        }
   44342             :                     pointerOfLinkedList = &(pointer[i]);
   44343             :                   }
   44344             :               }
   44345             :         }
   44346             : 
   44347           5 :      if ( pointerOfLinkedList != NULL )
   44348             :         {
   44349             :        // printf ("In SgOmpReadClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   44350           0 :           pointerOfLinkedList->set_freepointer(NULL);
   44351             :        // DQ (6/6/2010): Temporary debugging...
   44352             :        //   ROSE_ASSERT(false);
   44353             :         }
   44354             : 
   44355           5 :      return ;
   44356             :    }
   44357             : 
   44358             : //############################################################################
   44359             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   44360             :  * within the memory pool and resets the freepointers, in order to achieve a 
   44361             :  * linked list, that has no jumps and starts at the beginning! This function 
   44362             :  * does not extend the memory pool, since we do not delete any memory blocks,
   44363             :  * but delete the valid objects.  
   44364             :  */
   44365             : void
   44366           0 : SgOmpReadClause::clearMemoryPool( )
   44367             :    {
   44368             :   // printf ("Inside of SgOmpReadClause::clearMemoryPool() \n");
   44369             : 
   44370           0 :      SgOmpReadClause* pointer = NULL, *tempPointer = NULL;
   44371           0 :      std::vector < unsigned char* > :: const_iterator block;
   44372           0 :      if ( SgOmpReadClause::pools.empty() == false )
   44373             :         {
   44374           0 :           block = SgOmpReadClause::pools.begin() ;
   44375           0 :           SgOmpReadClause::next_node = (SgOmpReadClause*) (*block);
   44376             : 
   44377           0 :           while ( block != SgOmpReadClause::pools.end() )
   44378             :              {
   44379           0 :                pointer = (SgOmpReadClause*) (*block);
   44380           0 :                if ( tempPointer != NULL )
   44381             :                   {
   44382           0 :                     tempPointer->set_freepointer(pointer);
   44383             :                   }
   44384           0 :                for (unsigned i = 0; i < SgOmpReadClause::pool_size - 1; ++i)
   44385             :                   {
   44386           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   44387             :                   }
   44388           0 :                 pointer[SgOmpReadClause::pool_size-1].set_freepointer(NULL);
   44389           0 :                 tempPointer = &(pointer[SgOmpReadClause::pool_size-1]);
   44390           0 :                 ++block;
   44391             :              }
   44392             :         }
   44393           0 :    }
   44394             : 
   44395           5 : void SgOmpReadClause::deleteMemoryPool() {
   44396           5 :   for (auto p: SgOmpReadClause::pools) {
   44397           0 :     ROSE_FREE(p);
   44398             :   }
   44399           5 :   SgOmpReadClause::next_node = nullptr;
   44400           5 :   SgOmpReadClause::pools.clear();
   44401           5 : }
   44402             : 
   44403             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   44404             : //                 reading multiple binary files to for a single AST.
   44405             : /////////// new version ////////////////////////////////
   44406             : //############################################################################
   44407             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   44408             : void
   44409           2 : SgOmpReadClause::extendMemoryPoolForFileIO( )
   44410             :   {
   44411           2 :     size_t blockIndex = SgOmpReadClause::pools.size();
   44412           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReadClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReadClause);
   44413             : 
   44414           2 :     while ( (blockIndex * SgOmpReadClause::pool_size) < newPoolSize)
   44415             :       {
   44416             : #if ROSE_ALLOC_TRACE
   44417             :         if (blockIndex > 0) {
   44418             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReadClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReadClause) = %" PRIuPTR " SgOmpReadClause::pool_size = %d \n",
   44419             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReadClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReadClause),SgOmpReadClause::pool_size);
   44420             :         }
   44421             : #endif
   44422             : 
   44423           0 :         SgOmpReadClause * pointer = (SgOmpReadClause*) ROSE_MALLOC ( SgOmpReadClause::pool_size * sizeof(SgOmpReadClause) );
   44424           0 :         assert( pointer != NULL );
   44425             : #if ROSE_ALLOC_MEMSET == 1
   44426             :         memset(pointer, 0x00, SgOmpReadClause::pool_size * sizeof(SgOmpReadClause));
   44427             : #elif ROSE_ALLOC_MEMSET == 2
   44428             :         memset(pointer, 0xCC, SgOmpReadClause::pool_size * sizeof(SgOmpReadClause));
   44429             : #endif
   44430           0 :         SgOmpReadClause::pools.push_back( (unsigned char*)(pointer) );
   44431           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpReadClause::pool_size * sizeof(SgOmpReadClause), V_SgOmpReadClause ) );
   44432             : 
   44433           0 :         if ( SgOmpReadClause::next_node != NULL ) {
   44434           0 :           if ( blockIndex > 0 ) {
   44435           0 :             SgOmpReadClause * blkptr = (SgOmpReadClause*)(SgOmpReadClause::pools[blockIndex-1]);
   44436           0 :             blkptr[ SgOmpReadClause::pool_size - 1 ].set_freepointer(pointer);
   44437             :           }
   44438             :         } else {
   44439           0 :           SgOmpReadClause::next_node = pointer;
   44440             :         }
   44441             : 
   44442           0 :         for (unsigned i = 0; i < SgOmpReadClause::pool_size-1; ++i)
   44443             :            {
   44444           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   44445             :            }
   44446           0 :         pointer[ SgOmpReadClause::pool_size -1 ].set_freepointer(NULL);
   44447             : 
   44448           0 :         blockIndex++;
   44449             :       }
   44450           2 :   }
   44451             : 
   44452             : //############################################################################
   44453             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   44454             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   44455             :  * not compressed. However, that stuff is not yet implemented! 
   44456             :  */
   44457             : unsigned long
   44458           0 : SgOmpReadClause::getNumberOfLastValidPointer()
   44459             :    {
   44460           0 :       SgOmpReadClause* testPointer = (SgOmpReadClause*)(SgOmpReadClause::pools.back());
   44461           0 :       unsigned long localIndex = SgOmpReadClause::pool_size - 1;
   44462           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   44463             :          {
   44464           0 :            localIndex--;
   44465             :          }
   44466           0 :       return (localIndex + SgOmpReadClause::pool_size * (SgOmpReadClause::pools.size()-1));
   44467             :    }
   44468             : 
   44469             : //############################################################################
   44470             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   44471             :  * memory pool and initializes the data member in class SgOmpReadClauseStroageClass
   44472             :  * from its counterpart of SgOmpReadClause. The return value is just for checking, 
   44473             :  * that the whole StorageClassArray is initialized!
   44474             :  */
   44475             : unsigned long
   44476           0 : SgOmpReadClause::initializeStorageClassArray( SgOmpReadClauseStorageClass *storageArray )
   44477             :    {
   44478           0 :      unsigned long storageCounter = 0;
   44479           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpReadClause::pools.begin();
   44480           0 :      SgOmpReadClause* pointer = NULL;
   44481           0 :      while ( block != SgOmpReadClause::pools.end() ) {
   44482           0 :           pointer = (SgOmpReadClause*) (*block);
   44483           0 :           for ( unsigned i = 0; i < SgOmpReadClause::pool_size; ++i ) {
   44484           0 :                if ( pointer->get_freepointer() != NULL ) {
   44485           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   44486           0 :                  storageArray++;
   44487           0 :                  storageCounter++;
   44488             :                }
   44489           0 :                pointer++;
   44490             :              }
   44491           0 :            block++;
   44492             :         }
   44493           0 :      return storageCounter;
   44494             :    }
   44495             : 
   44496             : /* #line 44497 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   44497             : 
   44498             : 
   44499             : 
   44500             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   44501             : 
   44502             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   44503             : 
   44504             : //############################################################################
   44505             : /* JH (02/02/2006) Constructor of the IR node SgOmpThreadsClause that takes its 
   44506             :  * corresponding StorageClass as parameter
   44507             :  */
   44508           0 : SgOmpThreadsClause :: SgOmpThreadsClause ( const SgOmpThreadsClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   44509             :    {
   44510             : 
   44511             : 
   44512             : /* #line 44513 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   44513             : 
   44514           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   44515             : 
   44516             : 
   44517             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   44518             : 
   44519             : 
   44520           0 :    }
   44521             : 
   44522             : //############################################################################
   44523             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   44524             :  * within the working AST. 
   44525             :  */
   44526           0 : SgOmpThreadsClause * SgOmpThreadsClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   44527           0 :      SgOmpThreadsClause* returnPointer = NULL;
   44528           0 :      if ( globalIndex != 0 )
   44529             :         {
   44530             : 
   44531             : #if FILE_IO_EXTRA_CHECK
   44532           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpThreadsClause ) ) <= globalIndex ) ;
   44533           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpThreadsClause + 1 ) ) );
   44534             : #endif
   44535           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpThreadsClause )  
   44536           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpThreadsClause );
   44537           0 :           unsigned long positionInPool = localIndex % SgOmpThreadsClause::pool_size;
   44538           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpThreadsClause::pool_size;
   44539             : 
   44540             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   44541             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   44542             : 
   44543           0 :           returnPointer = &( ( (SgOmpThreadsClause*)(SgOmpThreadsClause::pools[memoryBlock]) ) [positionInPool]) ;
   44544             : 
   44545           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   44546             :         }
   44547           0 :      return returnPointer ;
   44548             :    }
   44549             : 
   44550             : //############################################################################
   44551             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   44552             :   for the AST with the index astIndex
   44553             : */
   44554           0 : SgOmpThreadsClause * SgOmpThreadsClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   44555           0 :      SgOmpThreadsClause* returnPointer = NULL;
   44556           0 :      if ( globalIndex != 0 )
   44557             :         {
   44558             : 
   44559             : #if FILE_IO_EXTRA_CHECK
   44560           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpThreadsClause ) ) <= globalIndex ) ;
   44561           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpThreadsClause + 1 ) ) );
   44562             : #endif
   44563           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpThreadsClause )
   44564           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpThreadsClause );
   44565           0 :           unsigned long positionInPool = localIndex % SgOmpThreadsClause::pool_size ;
   44566           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpThreadsClause::pool_size ;
   44567             : 
   44568             : #if FILE_IO_EXTRA_CHECK
   44569             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   44570             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   44571             : #endif
   44572             : 
   44573           0 :           returnPointer = &( ( (SgOmpThreadsClause*)(SgOmpThreadsClause::pools[memoryBlock]) ) [positionInPool]) ;
   44574             : 
   44575             : #if FILE_IO_EXTRA_CHECK
   44576           0 :           assert ( returnPointer != NULL ) ;
   44577             : #endif
   44578             :         }
   44579           0 :      return returnPointer ;
   44580             :    }
   44581             : 
   44582             : //############################################################################
   44583             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   44584             :  * pool size! We set for every valid object in the memory pool the freepointer
   44585             :  * to the global index and increase the global index afterwards. For all the 
   44586             :  * invalid objects (means address ranges within the memory pool that were not
   44587             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   44588             :  * distinguish valid from invalid objects! 
   44589             :  */
   44590             : unsigned long
   44591           5 : SgOmpThreadsClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   44592             :    {
   44593           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   44594           5 :      SgOmpThreadsClause* pointer = NULL;
   44595           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   44596           5 :      std::vector < unsigned char* > :: const_iterator block;
   44597           5 :      for ( block = SgOmpThreadsClause::pools.begin(); block != SgOmpThreadsClause::pools.end() ; ++block )
   44598             :         {
   44599           0 :           pointer = (SgOmpThreadsClause*)(*block);
   44600           0 :           for (unsigned i = 0; i < SgOmpThreadsClause::pool_size; ++i )
   44601             :              {
   44602             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   44603             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   44604             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   44605             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   44606             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   44607             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   44608             :             // properly; so this will have to be checked next.
   44609             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   44610             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   44611           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   44612             :                   {
   44613           0 :                     pointer[i].set_freepointer((SgOmpThreadsClause*)(globalIndex));
   44614           0 :                     globalIndex++;
   44615             :                   }
   44616             :                else
   44617             :                   {
   44618           0 :                     pointer[i].set_freepointer(NULL);
   44619             :                   }
   44620             :               }
   44621             :         }
   44622           5 :      return globalIndex;
   44623             :    }
   44624             : 
   44625             : //############################################################################
   44626             : // JH (01/14/2006)
   44627             : void
   44628           5 : SgOmpThreadsClause::resetValidFreepointers( )
   44629             :    {
   44630           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   44631           5 :      SgOmpThreadsClause* pointer = NULL;
   44632           5 :      std::vector < unsigned char* > :: const_iterator block;
   44633           5 :      SgOmpThreadsClause* pointerOfLinkedList = NULL;
   44634           5 :      for ( block = SgOmpThreadsClause::pools.begin(); block != SgOmpThreadsClause::pools.end() ; ++block )
   44635             :         {
   44636           0 :           pointer = (SgOmpThreadsClause*)(*block);
   44637           0 :           for (unsigned i = 0; i < SgOmpThreadsClause::pool_size; ++i )
   44638             :              {
   44639             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   44640             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   44641             :             // memory blocks!.
   44642           0 :                if ( pointer[i].get_freepointer() != NULL )
   44643             :                   {
   44644           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   44645             :                   }
   44646             :                else
   44647             :                   {
   44648           0 :                     if ( pointerOfLinkedList == NULL )
   44649             :                        {
   44650           0 :                          SgOmpThreadsClause::next_node = &(pointer[i]);
   44651             :                        }
   44652             :                     else
   44653             :                        {
   44654             :                       // printf ("In SgOmpThreadsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   44655           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   44656             :                        }
   44657             :                     pointerOfLinkedList = &(pointer[i]);
   44658             :                   }
   44659             :               }
   44660             :         }
   44661             : 
   44662           5 :      if ( pointerOfLinkedList != NULL )
   44663             :         {
   44664             :        // printf ("In SgOmpThreadsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   44665           0 :           pointerOfLinkedList->set_freepointer(NULL);
   44666             :        // DQ (6/6/2010): Temporary debugging...
   44667             :        //   ROSE_ASSERT(false);
   44668             :         }
   44669             : 
   44670           5 :      return ;
   44671             :    }
   44672             : 
   44673             : //############################################################################
   44674             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   44675             :  * within the memory pool and resets the freepointers, in order to achieve a 
   44676             :  * linked list, that has no jumps and starts at the beginning! This function 
   44677             :  * does not extend the memory pool, since we do not delete any memory blocks,
   44678             :  * but delete the valid objects.  
   44679             :  */
   44680             : void
   44681           0 : SgOmpThreadsClause::clearMemoryPool( )
   44682             :    {
   44683             :   // printf ("Inside of SgOmpThreadsClause::clearMemoryPool() \n");
   44684             : 
   44685           0 :      SgOmpThreadsClause* pointer = NULL, *tempPointer = NULL;
   44686           0 :      std::vector < unsigned char* > :: const_iterator block;
   44687           0 :      if ( SgOmpThreadsClause::pools.empty() == false )
   44688             :         {
   44689           0 :           block = SgOmpThreadsClause::pools.begin() ;
   44690           0 :           SgOmpThreadsClause::next_node = (SgOmpThreadsClause*) (*block);
   44691             : 
   44692           0 :           while ( block != SgOmpThreadsClause::pools.end() )
   44693             :              {
   44694           0 :                pointer = (SgOmpThreadsClause*) (*block);
   44695           0 :                if ( tempPointer != NULL )
   44696             :                   {
   44697           0 :                     tempPointer->set_freepointer(pointer);
   44698             :                   }
   44699           0 :                for (unsigned i = 0; i < SgOmpThreadsClause::pool_size - 1; ++i)
   44700             :                   {
   44701           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   44702             :                   }
   44703           0 :                 pointer[SgOmpThreadsClause::pool_size-1].set_freepointer(NULL);
   44704           0 :                 tempPointer = &(pointer[SgOmpThreadsClause::pool_size-1]);
   44705           0 :                 ++block;
   44706             :              }
   44707             :         }
   44708           0 :    }
   44709             : 
   44710           5 : void SgOmpThreadsClause::deleteMemoryPool() {
   44711           5 :   for (auto p: SgOmpThreadsClause::pools) {
   44712           0 :     ROSE_FREE(p);
   44713             :   }
   44714           5 :   SgOmpThreadsClause::next_node = nullptr;
   44715           5 :   SgOmpThreadsClause::pools.clear();
   44716           5 : }
   44717             : 
   44718             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   44719             : //                 reading multiple binary files to for a single AST.
   44720             : /////////// new version ////////////////////////////////
   44721             : //############################################################################
   44722             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   44723             : void
   44724           2 : SgOmpThreadsClause::extendMemoryPoolForFileIO( )
   44725             :   {
   44726           2 :     size_t blockIndex = SgOmpThreadsClause::pools.size();
   44727           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadsClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadsClause);
   44728             : 
   44729           2 :     while ( (blockIndex * SgOmpThreadsClause::pool_size) < newPoolSize)
   44730             :       {
   44731             : #if ROSE_ALLOC_TRACE
   44732             :         if (blockIndex > 0) {
   44733             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadsClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadsClause) = %" PRIuPTR " SgOmpThreadsClause::pool_size = %d \n",
   44734             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadsClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadsClause),SgOmpThreadsClause::pool_size);
   44735             :         }
   44736             : #endif
   44737             : 
   44738           0 :         SgOmpThreadsClause * pointer = (SgOmpThreadsClause*) ROSE_MALLOC ( SgOmpThreadsClause::pool_size * sizeof(SgOmpThreadsClause) );
   44739           0 :         assert( pointer != NULL );
   44740             : #if ROSE_ALLOC_MEMSET == 1
   44741             :         memset(pointer, 0x00, SgOmpThreadsClause::pool_size * sizeof(SgOmpThreadsClause));
   44742             : #elif ROSE_ALLOC_MEMSET == 2
   44743             :         memset(pointer, 0xCC, SgOmpThreadsClause::pool_size * sizeof(SgOmpThreadsClause));
   44744             : #endif
   44745           0 :         SgOmpThreadsClause::pools.push_back( (unsigned char*)(pointer) );
   44746           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpThreadsClause::pool_size * sizeof(SgOmpThreadsClause), V_SgOmpThreadsClause ) );
   44747             : 
   44748           0 :         if ( SgOmpThreadsClause::next_node != NULL ) {
   44749           0 :           if ( blockIndex > 0 ) {
   44750           0 :             SgOmpThreadsClause * blkptr = (SgOmpThreadsClause*)(SgOmpThreadsClause::pools[blockIndex-1]);
   44751           0 :             blkptr[ SgOmpThreadsClause::pool_size - 1 ].set_freepointer(pointer);
   44752             :           }
   44753             :         } else {
   44754           0 :           SgOmpThreadsClause::next_node = pointer;
   44755             :         }
   44756             : 
   44757           0 :         for (unsigned i = 0; i < SgOmpThreadsClause::pool_size-1; ++i)
   44758             :            {
   44759           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   44760             :            }
   44761           0 :         pointer[ SgOmpThreadsClause::pool_size -1 ].set_freepointer(NULL);
   44762             : 
   44763           0 :         blockIndex++;
   44764             :       }
   44765           2 :   }
   44766             : 
   44767             : //############################################################################
   44768             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   44769             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   44770             :  * not compressed. However, that stuff is not yet implemented! 
   44771             :  */
   44772             : unsigned long
   44773           0 : SgOmpThreadsClause::getNumberOfLastValidPointer()
   44774             :    {
   44775           0 :       SgOmpThreadsClause* testPointer = (SgOmpThreadsClause*)(SgOmpThreadsClause::pools.back());
   44776           0 :       unsigned long localIndex = SgOmpThreadsClause::pool_size - 1;
   44777           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   44778             :          {
   44779           0 :            localIndex--;
   44780             :          }
   44781           0 :       return (localIndex + SgOmpThreadsClause::pool_size * (SgOmpThreadsClause::pools.size()-1));
   44782             :    }
   44783             : 
   44784             : //############################################################################
   44785             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   44786             :  * memory pool and initializes the data member in class SgOmpThreadsClauseStroageClass
   44787             :  * from its counterpart of SgOmpThreadsClause. The return value is just for checking, 
   44788             :  * that the whole StorageClassArray is initialized!
   44789             :  */
   44790             : unsigned long
   44791           0 : SgOmpThreadsClause::initializeStorageClassArray( SgOmpThreadsClauseStorageClass *storageArray )
   44792             :    {
   44793           0 :      unsigned long storageCounter = 0;
   44794           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpThreadsClause::pools.begin();
   44795           0 :      SgOmpThreadsClause* pointer = NULL;
   44796           0 :      while ( block != SgOmpThreadsClause::pools.end() ) {
   44797           0 :           pointer = (SgOmpThreadsClause*) (*block);
   44798           0 :           for ( unsigned i = 0; i < SgOmpThreadsClause::pool_size; ++i ) {
   44799           0 :                if ( pointer->get_freepointer() != NULL ) {
   44800           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   44801           0 :                  storageArray++;
   44802           0 :                  storageCounter++;
   44803             :                }
   44804           0 :                pointer++;
   44805             :              }
   44806           0 :            block++;
   44807             :         }
   44808           0 :      return storageCounter;
   44809             :    }
   44810             : 
   44811             : /* #line 44812 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   44812             : 
   44813             : 
   44814             : 
   44815             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   44816             : 
   44817             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   44818             : 
   44819             : //############################################################################
   44820             : /* JH (02/02/2006) Constructor of the IR node SgOmpSimdClause that takes its 
   44821             :  * corresponding StorageClass as parameter
   44822             :  */
   44823           0 : SgOmpSimdClause :: SgOmpSimdClause ( const SgOmpSimdClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   44824             :    {
   44825             : 
   44826             : 
   44827             : /* #line 44828 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   44828             : 
   44829           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   44830             : 
   44831             : 
   44832             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   44833             : 
   44834             : 
   44835           0 :    }
   44836             : 
   44837             : //############################################################################
   44838             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   44839             :  * within the working AST. 
   44840             :  */
   44841           0 : SgOmpSimdClause * SgOmpSimdClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   44842           0 :      SgOmpSimdClause* returnPointer = NULL;
   44843           0 :      if ( globalIndex != 0 )
   44844             :         {
   44845             : 
   44846             : #if FILE_IO_EXTRA_CHECK
   44847           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSimdClause ) ) <= globalIndex ) ;
   44848           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSimdClause + 1 ) ) );
   44849             : #endif
   44850           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSimdClause )  
   44851           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSimdClause );
   44852           0 :           unsigned long positionInPool = localIndex % SgOmpSimdClause::pool_size;
   44853           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSimdClause::pool_size;
   44854             : 
   44855             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   44856             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   44857             : 
   44858           0 :           returnPointer = &( ( (SgOmpSimdClause*)(SgOmpSimdClause::pools[memoryBlock]) ) [positionInPool]) ;
   44859             : 
   44860           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   44861             :         }
   44862           0 :      return returnPointer ;
   44863             :    }
   44864             : 
   44865             : //############################################################################
   44866             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   44867             :   for the AST with the index astIndex
   44868             : */
   44869           0 : SgOmpSimdClause * SgOmpSimdClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   44870           0 :      SgOmpSimdClause* returnPointer = NULL;
   44871           0 :      if ( globalIndex != 0 )
   44872             :         {
   44873             : 
   44874             : #if FILE_IO_EXTRA_CHECK
   44875           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSimdClause ) ) <= globalIndex ) ;
   44876           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSimdClause + 1 ) ) );
   44877             : #endif
   44878           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSimdClause )
   44879           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSimdClause );
   44880           0 :           unsigned long positionInPool = localIndex % SgOmpSimdClause::pool_size ;
   44881           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSimdClause::pool_size ;
   44882             : 
   44883             : #if FILE_IO_EXTRA_CHECK
   44884             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   44885             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   44886             : #endif
   44887             : 
   44888           0 :           returnPointer = &( ( (SgOmpSimdClause*)(SgOmpSimdClause::pools[memoryBlock]) ) [positionInPool]) ;
   44889             : 
   44890             : #if FILE_IO_EXTRA_CHECK
   44891           0 :           assert ( returnPointer != NULL ) ;
   44892             : #endif
   44893             :         }
   44894           0 :      return returnPointer ;
   44895             :    }
   44896             : 
   44897             : //############################################################################
   44898             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   44899             :  * pool size! We set for every valid object in the memory pool the freepointer
   44900             :  * to the global index and increase the global index afterwards. For all the 
   44901             :  * invalid objects (means address ranges within the memory pool that were not
   44902             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   44903             :  * distinguish valid from invalid objects! 
   44904             :  */
   44905             : unsigned long
   44906           5 : SgOmpSimdClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   44907             :    {
   44908           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   44909           5 :      SgOmpSimdClause* pointer = NULL;
   44910           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   44911           5 :      std::vector < unsigned char* > :: const_iterator block;
   44912           5 :      for ( block = SgOmpSimdClause::pools.begin(); block != SgOmpSimdClause::pools.end() ; ++block )
   44913             :         {
   44914           0 :           pointer = (SgOmpSimdClause*)(*block);
   44915           0 :           for (unsigned i = 0; i < SgOmpSimdClause::pool_size; ++i )
   44916             :              {
   44917             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   44918             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   44919             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   44920             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   44921             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   44922             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   44923             :             // properly; so this will have to be checked next.
   44924             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   44925             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   44926           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   44927             :                   {
   44928           0 :                     pointer[i].set_freepointer((SgOmpSimdClause*)(globalIndex));
   44929           0 :                     globalIndex++;
   44930             :                   }
   44931             :                else
   44932             :                   {
   44933           0 :                     pointer[i].set_freepointer(NULL);
   44934             :                   }
   44935             :               }
   44936             :         }
   44937           5 :      return globalIndex;
   44938             :    }
   44939             : 
   44940             : //############################################################################
   44941             : // JH (01/14/2006)
   44942             : void
   44943           5 : SgOmpSimdClause::resetValidFreepointers( )
   44944             :    {
   44945           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   44946           5 :      SgOmpSimdClause* pointer = NULL;
   44947           5 :      std::vector < unsigned char* > :: const_iterator block;
   44948           5 :      SgOmpSimdClause* pointerOfLinkedList = NULL;
   44949           5 :      for ( block = SgOmpSimdClause::pools.begin(); block != SgOmpSimdClause::pools.end() ; ++block )
   44950             :         {
   44951           0 :           pointer = (SgOmpSimdClause*)(*block);
   44952           0 :           for (unsigned i = 0; i < SgOmpSimdClause::pool_size; ++i )
   44953             :              {
   44954             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   44955             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   44956             :             // memory blocks!.
   44957           0 :                if ( pointer[i].get_freepointer() != NULL )
   44958             :                   {
   44959           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   44960             :                   }
   44961             :                else
   44962             :                   {
   44963           0 :                     if ( pointerOfLinkedList == NULL )
   44964             :                        {
   44965           0 :                          SgOmpSimdClause::next_node = &(pointer[i]);
   44966             :                        }
   44967             :                     else
   44968             :                        {
   44969             :                       // printf ("In SgOmpSimdClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   44970           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   44971             :                        }
   44972             :                     pointerOfLinkedList = &(pointer[i]);
   44973             :                   }
   44974             :               }
   44975             :         }
   44976             : 
   44977           5 :      if ( pointerOfLinkedList != NULL )
   44978             :         {
   44979             :        // printf ("In SgOmpSimdClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   44980           0 :           pointerOfLinkedList->set_freepointer(NULL);
   44981             :        // DQ (6/6/2010): Temporary debugging...
   44982             :        //   ROSE_ASSERT(false);
   44983             :         }
   44984             : 
   44985           5 :      return ;
   44986             :    }
   44987             : 
   44988             : //############################################################################
   44989             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   44990             :  * within the memory pool and resets the freepointers, in order to achieve a 
   44991             :  * linked list, that has no jumps and starts at the beginning! This function 
   44992             :  * does not extend the memory pool, since we do not delete any memory blocks,
   44993             :  * but delete the valid objects.  
   44994             :  */
   44995             : void
   44996           0 : SgOmpSimdClause::clearMemoryPool( )
   44997             :    {
   44998             :   // printf ("Inside of SgOmpSimdClause::clearMemoryPool() \n");
   44999             : 
   45000           0 :      SgOmpSimdClause* pointer = NULL, *tempPointer = NULL;
   45001           0 :      std::vector < unsigned char* > :: const_iterator block;
   45002           0 :      if ( SgOmpSimdClause::pools.empty() == false )
   45003             :         {
   45004           0 :           block = SgOmpSimdClause::pools.begin() ;
   45005           0 :           SgOmpSimdClause::next_node = (SgOmpSimdClause*) (*block);
   45006             : 
   45007           0 :           while ( block != SgOmpSimdClause::pools.end() )
   45008             :              {
   45009           0 :                pointer = (SgOmpSimdClause*) (*block);
   45010           0 :                if ( tempPointer != NULL )
   45011             :                   {
   45012           0 :                     tempPointer->set_freepointer(pointer);
   45013             :                   }
   45014           0 :                for (unsigned i = 0; i < SgOmpSimdClause::pool_size - 1; ++i)
   45015             :                   {
   45016           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   45017             :                   }
   45018           0 :                 pointer[SgOmpSimdClause::pool_size-1].set_freepointer(NULL);
   45019           0 :                 tempPointer = &(pointer[SgOmpSimdClause::pool_size-1]);
   45020           0 :                 ++block;
   45021             :              }
   45022             :         }
   45023           0 :    }
   45024             : 
   45025           5 : void SgOmpSimdClause::deleteMemoryPool() {
   45026           5 :   for (auto p: SgOmpSimdClause::pools) {
   45027           0 :     ROSE_FREE(p);
   45028             :   }
   45029           5 :   SgOmpSimdClause::next_node = nullptr;
   45030           5 :   SgOmpSimdClause::pools.clear();
   45031           5 : }
   45032             : 
   45033             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   45034             : //                 reading multiple binary files to for a single AST.
   45035             : /////////// new version ////////////////////////////////
   45036             : //############################################################################
   45037             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   45038             : void
   45039           2 : SgOmpSimdClause::extendMemoryPoolForFileIO( )
   45040             :   {
   45041           2 :     size_t blockIndex = SgOmpSimdClause::pools.size();
   45042           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSimdClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSimdClause);
   45043             : 
   45044           2 :     while ( (blockIndex * SgOmpSimdClause::pool_size) < newPoolSize)
   45045             :       {
   45046             : #if ROSE_ALLOC_TRACE
   45047             :         if (blockIndex > 0) {
   45048             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSimdClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSimdClause) = %" PRIuPTR " SgOmpSimdClause::pool_size = %d \n",
   45049             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSimdClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSimdClause),SgOmpSimdClause::pool_size);
   45050             :         }
   45051             : #endif
   45052             : 
   45053           0 :         SgOmpSimdClause * pointer = (SgOmpSimdClause*) ROSE_MALLOC ( SgOmpSimdClause::pool_size * sizeof(SgOmpSimdClause) );
   45054           0 :         assert( pointer != NULL );
   45055             : #if ROSE_ALLOC_MEMSET == 1
   45056             :         memset(pointer, 0x00, SgOmpSimdClause::pool_size * sizeof(SgOmpSimdClause));
   45057             : #elif ROSE_ALLOC_MEMSET == 2
   45058             :         memset(pointer, 0xCC, SgOmpSimdClause::pool_size * sizeof(SgOmpSimdClause));
   45059             : #endif
   45060           0 :         SgOmpSimdClause::pools.push_back( (unsigned char*)(pointer) );
   45061           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSimdClause::pool_size * sizeof(SgOmpSimdClause), V_SgOmpSimdClause ) );
   45062             : 
   45063           0 :         if ( SgOmpSimdClause::next_node != NULL ) {
   45064           0 :           if ( blockIndex > 0 ) {
   45065           0 :             SgOmpSimdClause * blkptr = (SgOmpSimdClause*)(SgOmpSimdClause::pools[blockIndex-1]);
   45066           0 :             blkptr[ SgOmpSimdClause::pool_size - 1 ].set_freepointer(pointer);
   45067             :           }
   45068             :         } else {
   45069           0 :           SgOmpSimdClause::next_node = pointer;
   45070             :         }
   45071             : 
   45072           0 :         for (unsigned i = 0; i < SgOmpSimdClause::pool_size-1; ++i)
   45073             :            {
   45074           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   45075             :            }
   45076           0 :         pointer[ SgOmpSimdClause::pool_size -1 ].set_freepointer(NULL);
   45077             : 
   45078           0 :         blockIndex++;
   45079             :       }
   45080           2 :   }
   45081             : 
   45082             : //############################################################################
   45083             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   45084             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   45085             :  * not compressed. However, that stuff is not yet implemented! 
   45086             :  */
   45087             : unsigned long
   45088           0 : SgOmpSimdClause::getNumberOfLastValidPointer()
   45089             :    {
   45090           0 :       SgOmpSimdClause* testPointer = (SgOmpSimdClause*)(SgOmpSimdClause::pools.back());
   45091           0 :       unsigned long localIndex = SgOmpSimdClause::pool_size - 1;
   45092           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   45093             :          {
   45094           0 :            localIndex--;
   45095             :          }
   45096           0 :       return (localIndex + SgOmpSimdClause::pool_size * (SgOmpSimdClause::pools.size()-1));
   45097             :    }
   45098             : 
   45099             : //############################################################################
   45100             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   45101             :  * memory pool and initializes the data member in class SgOmpSimdClauseStroageClass
   45102             :  * from its counterpart of SgOmpSimdClause. The return value is just for checking, 
   45103             :  * that the whole StorageClassArray is initialized!
   45104             :  */
   45105             : unsigned long
   45106           0 : SgOmpSimdClause::initializeStorageClassArray( SgOmpSimdClauseStorageClass *storageArray )
   45107             :    {
   45108           0 :      unsigned long storageCounter = 0;
   45109           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSimdClause::pools.begin();
   45110           0 :      SgOmpSimdClause* pointer = NULL;
   45111           0 :      while ( block != SgOmpSimdClause::pools.end() ) {
   45112           0 :           pointer = (SgOmpSimdClause*) (*block);
   45113           0 :           for ( unsigned i = 0; i < SgOmpSimdClause::pool_size; ++i ) {
   45114           0 :                if ( pointer->get_freepointer() != NULL ) {
   45115           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   45116           0 :                  storageArray++;
   45117           0 :                  storageCounter++;
   45118             :                }
   45119           0 :                pointer++;
   45120             :              }
   45121           0 :            block++;
   45122             :         }
   45123           0 :      return storageCounter;
   45124             :    }
   45125             : 
   45126             : /* #line 45127 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   45127             : 
   45128             : 
   45129             : 
   45130             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   45131             : 
   45132             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   45133             : 
   45134             : //############################################################################
   45135             : /* JH (02/02/2006) Constructor of the IR node SgOmpWriteClause that takes its 
   45136             :  * corresponding StorageClass as parameter
   45137             :  */
   45138           0 : SgOmpWriteClause :: SgOmpWriteClause ( const SgOmpWriteClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   45139             :    {
   45140             : 
   45141             : 
   45142             : /* #line 45143 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   45143             : 
   45144           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   45145             : 
   45146             : 
   45147             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   45148             : 
   45149             : 
   45150           0 :    }
   45151             : 
   45152             : //############################################################################
   45153             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   45154             :  * within the working AST. 
   45155             :  */
   45156           0 : SgOmpWriteClause * SgOmpWriteClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   45157           0 :      SgOmpWriteClause* returnPointer = NULL;
   45158           0 :      if ( globalIndex != 0 )
   45159             :         {
   45160             : 
   45161             : #if FILE_IO_EXTRA_CHECK
   45162           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpWriteClause ) ) <= globalIndex ) ;
   45163           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpWriteClause + 1 ) ) );
   45164             : #endif
   45165           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpWriteClause )  
   45166           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpWriteClause );
   45167           0 :           unsigned long positionInPool = localIndex % SgOmpWriteClause::pool_size;
   45168           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpWriteClause::pool_size;
   45169             : 
   45170             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   45171             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   45172             : 
   45173           0 :           returnPointer = &( ( (SgOmpWriteClause*)(SgOmpWriteClause::pools[memoryBlock]) ) [positionInPool]) ;
   45174             : 
   45175           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   45176             :         }
   45177           0 :      return returnPointer ;
   45178             :    }
   45179             : 
   45180             : //############################################################################
   45181             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   45182             :   for the AST with the index astIndex
   45183             : */
   45184           0 : SgOmpWriteClause * SgOmpWriteClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   45185           0 :      SgOmpWriteClause* returnPointer = NULL;
   45186           0 :      if ( globalIndex != 0 )
   45187             :         {
   45188             : 
   45189             : #if FILE_IO_EXTRA_CHECK
   45190           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpWriteClause ) ) <= globalIndex ) ;
   45191           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpWriteClause + 1 ) ) );
   45192             : #endif
   45193           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpWriteClause )
   45194           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpWriteClause );
   45195           0 :           unsigned long positionInPool = localIndex % SgOmpWriteClause::pool_size ;
   45196           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpWriteClause::pool_size ;
   45197             : 
   45198             : #if FILE_IO_EXTRA_CHECK
   45199             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   45200             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   45201             : #endif
   45202             : 
   45203           0 :           returnPointer = &( ( (SgOmpWriteClause*)(SgOmpWriteClause::pools[memoryBlock]) ) [positionInPool]) ;
   45204             : 
   45205             : #if FILE_IO_EXTRA_CHECK
   45206           0 :           assert ( returnPointer != NULL ) ;
   45207             : #endif
   45208             :         }
   45209           0 :      return returnPointer ;
   45210             :    }
   45211             : 
   45212             : //############################################################################
   45213             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   45214             :  * pool size! We set for every valid object in the memory pool the freepointer
   45215             :  * to the global index and increase the global index afterwards. For all the 
   45216             :  * invalid objects (means address ranges within the memory pool that were not
   45217             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   45218             :  * distinguish valid from invalid objects! 
   45219             :  */
   45220             : unsigned long
   45221           5 : SgOmpWriteClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   45222             :    {
   45223           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   45224           5 :      SgOmpWriteClause* pointer = NULL;
   45225           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   45226           5 :      std::vector < unsigned char* > :: const_iterator block;
   45227           5 :      for ( block = SgOmpWriteClause::pools.begin(); block != SgOmpWriteClause::pools.end() ; ++block )
   45228             :         {
   45229           0 :           pointer = (SgOmpWriteClause*)(*block);
   45230           0 :           for (unsigned i = 0; i < SgOmpWriteClause::pool_size; ++i )
   45231             :              {
   45232             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   45233             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   45234             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   45235             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   45236             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   45237             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   45238             :             // properly; so this will have to be checked next.
   45239             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   45240             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   45241           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   45242             :                   {
   45243           0 :                     pointer[i].set_freepointer((SgOmpWriteClause*)(globalIndex));
   45244           0 :                     globalIndex++;
   45245             :                   }
   45246             :                else
   45247             :                   {
   45248           0 :                     pointer[i].set_freepointer(NULL);
   45249             :                   }
   45250             :               }
   45251             :         }
   45252           5 :      return globalIndex;
   45253             :    }
   45254             : 
   45255             : //############################################################################
   45256             : // JH (01/14/2006)
   45257             : void
   45258           5 : SgOmpWriteClause::resetValidFreepointers( )
   45259             :    {
   45260           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   45261           5 :      SgOmpWriteClause* pointer = NULL;
   45262           5 :      std::vector < unsigned char* > :: const_iterator block;
   45263           5 :      SgOmpWriteClause* pointerOfLinkedList = NULL;
   45264           5 :      for ( block = SgOmpWriteClause::pools.begin(); block != SgOmpWriteClause::pools.end() ; ++block )
   45265             :         {
   45266           0 :           pointer = (SgOmpWriteClause*)(*block);
   45267           0 :           for (unsigned i = 0; i < SgOmpWriteClause::pool_size; ++i )
   45268             :              {
   45269             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   45270             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   45271             :             // memory blocks!.
   45272           0 :                if ( pointer[i].get_freepointer() != NULL )
   45273             :                   {
   45274           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   45275             :                   }
   45276             :                else
   45277             :                   {
   45278           0 :                     if ( pointerOfLinkedList == NULL )
   45279             :                        {
   45280           0 :                          SgOmpWriteClause::next_node = &(pointer[i]);
   45281             :                        }
   45282             :                     else
   45283             :                        {
   45284             :                       // printf ("In SgOmpWriteClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   45285           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   45286             :                        }
   45287             :                     pointerOfLinkedList = &(pointer[i]);
   45288             :                   }
   45289             :               }
   45290             :         }
   45291             : 
   45292           5 :      if ( pointerOfLinkedList != NULL )
   45293             :         {
   45294             :        // printf ("In SgOmpWriteClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   45295           0 :           pointerOfLinkedList->set_freepointer(NULL);
   45296             :        // DQ (6/6/2010): Temporary debugging...
   45297             :        //   ROSE_ASSERT(false);
   45298             :         }
   45299             : 
   45300           5 :      return ;
   45301             :    }
   45302             : 
   45303             : //############################################################################
   45304             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   45305             :  * within the memory pool and resets the freepointers, in order to achieve a 
   45306             :  * linked list, that has no jumps and starts at the beginning! This function 
   45307             :  * does not extend the memory pool, since we do not delete any memory blocks,
   45308             :  * but delete the valid objects.  
   45309             :  */
   45310             : void
   45311           0 : SgOmpWriteClause::clearMemoryPool( )
   45312             :    {
   45313             :   // printf ("Inside of SgOmpWriteClause::clearMemoryPool() \n");
   45314             : 
   45315           0 :      SgOmpWriteClause* pointer = NULL, *tempPointer = NULL;
   45316           0 :      std::vector < unsigned char* > :: const_iterator block;
   45317           0 :      if ( SgOmpWriteClause::pools.empty() == false )
   45318             :         {
   45319           0 :           block = SgOmpWriteClause::pools.begin() ;
   45320           0 :           SgOmpWriteClause::next_node = (SgOmpWriteClause*) (*block);
   45321             : 
   45322           0 :           while ( block != SgOmpWriteClause::pools.end() )
   45323             :              {
   45324           0 :                pointer = (SgOmpWriteClause*) (*block);
   45325           0 :                if ( tempPointer != NULL )
   45326             :                   {
   45327           0 :                     tempPointer->set_freepointer(pointer);
   45328             :                   }
   45329           0 :                for (unsigned i = 0; i < SgOmpWriteClause::pool_size - 1; ++i)
   45330             :                   {
   45331           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   45332             :                   }
   45333           0 :                 pointer[SgOmpWriteClause::pool_size-1].set_freepointer(NULL);
   45334           0 :                 tempPointer = &(pointer[SgOmpWriteClause::pool_size-1]);
   45335           0 :                 ++block;
   45336             :              }
   45337             :         }
   45338           0 :    }
   45339             : 
   45340           5 : void SgOmpWriteClause::deleteMemoryPool() {
   45341           5 :   for (auto p: SgOmpWriteClause::pools) {
   45342           0 :     ROSE_FREE(p);
   45343             :   }
   45344           5 :   SgOmpWriteClause::next_node = nullptr;
   45345           5 :   SgOmpWriteClause::pools.clear();
   45346           5 : }
   45347             : 
   45348             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   45349             : //                 reading multiple binary files to for a single AST.
   45350             : /////////// new version ////////////////////////////////
   45351             : //############################################################################
   45352             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   45353             : void
   45354           2 : SgOmpWriteClause::extendMemoryPoolForFileIO( )
   45355             :   {
   45356           2 :     size_t blockIndex = SgOmpWriteClause::pools.size();
   45357           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWriteClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWriteClause);
   45358             : 
   45359           2 :     while ( (blockIndex * SgOmpWriteClause::pool_size) < newPoolSize)
   45360             :       {
   45361             : #if ROSE_ALLOC_TRACE
   45362             :         if (blockIndex > 0) {
   45363             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWriteClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWriteClause) = %" PRIuPTR " SgOmpWriteClause::pool_size = %d \n",
   45364             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWriteClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWriteClause),SgOmpWriteClause::pool_size);
   45365             :         }
   45366             : #endif
   45367             : 
   45368           0 :         SgOmpWriteClause * pointer = (SgOmpWriteClause*) ROSE_MALLOC ( SgOmpWriteClause::pool_size * sizeof(SgOmpWriteClause) );
   45369           0 :         assert( pointer != NULL );
   45370             : #if ROSE_ALLOC_MEMSET == 1
   45371             :         memset(pointer, 0x00, SgOmpWriteClause::pool_size * sizeof(SgOmpWriteClause));
   45372             : #elif ROSE_ALLOC_MEMSET == 2
   45373             :         memset(pointer, 0xCC, SgOmpWriteClause::pool_size * sizeof(SgOmpWriteClause));
   45374             : #endif
   45375           0 :         SgOmpWriteClause::pools.push_back( (unsigned char*)(pointer) );
   45376           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpWriteClause::pool_size * sizeof(SgOmpWriteClause), V_SgOmpWriteClause ) );
   45377             : 
   45378           0 :         if ( SgOmpWriteClause::next_node != NULL ) {
   45379           0 :           if ( blockIndex > 0 ) {
   45380           0 :             SgOmpWriteClause * blkptr = (SgOmpWriteClause*)(SgOmpWriteClause::pools[blockIndex-1]);
   45381           0 :             blkptr[ SgOmpWriteClause::pool_size - 1 ].set_freepointer(pointer);
   45382             :           }
   45383             :         } else {
   45384           0 :           SgOmpWriteClause::next_node = pointer;
   45385             :         }
   45386             : 
   45387           0 :         for (unsigned i = 0; i < SgOmpWriteClause::pool_size-1; ++i)
   45388             :            {
   45389           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   45390             :            }
   45391           0 :         pointer[ SgOmpWriteClause::pool_size -1 ].set_freepointer(NULL);
   45392             : 
   45393           0 :         blockIndex++;
   45394             :       }
   45395           2 :   }
   45396             : 
   45397             : //############################################################################
   45398             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   45399             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   45400             :  * not compressed. However, that stuff is not yet implemented! 
   45401             :  */
   45402             : unsigned long
   45403           0 : SgOmpWriteClause::getNumberOfLastValidPointer()
   45404             :    {
   45405           0 :       SgOmpWriteClause* testPointer = (SgOmpWriteClause*)(SgOmpWriteClause::pools.back());
   45406           0 :       unsigned long localIndex = SgOmpWriteClause::pool_size - 1;
   45407           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   45408             :          {
   45409           0 :            localIndex--;
   45410             :          }
   45411           0 :       return (localIndex + SgOmpWriteClause::pool_size * (SgOmpWriteClause::pools.size()-1));
   45412             :    }
   45413             : 
   45414             : //############################################################################
   45415             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   45416             :  * memory pool and initializes the data member in class SgOmpWriteClauseStroageClass
   45417             :  * from its counterpart of SgOmpWriteClause. The return value is just for checking, 
   45418             :  * that the whole StorageClassArray is initialized!
   45419             :  */
   45420             : unsigned long
   45421           0 : SgOmpWriteClause::initializeStorageClassArray( SgOmpWriteClauseStorageClass *storageArray )
   45422             :    {
   45423           0 :      unsigned long storageCounter = 0;
   45424           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpWriteClause::pools.begin();
   45425           0 :      SgOmpWriteClause* pointer = NULL;
   45426           0 :      while ( block != SgOmpWriteClause::pools.end() ) {
   45427           0 :           pointer = (SgOmpWriteClause*) (*block);
   45428           0 :           for ( unsigned i = 0; i < SgOmpWriteClause::pool_size; ++i ) {
   45429           0 :                if ( pointer->get_freepointer() != NULL ) {
   45430           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   45431           0 :                  storageArray++;
   45432           0 :                  storageCounter++;
   45433             :                }
   45434           0 :                pointer++;
   45435             :              }
   45436           0 :            block++;
   45437             :         }
   45438           0 :      return storageCounter;
   45439             :    }
   45440             : 
   45441             : /* #line 45442 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   45442             : 
   45443             : 
   45444             : 
   45445             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   45446             : 
   45447             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   45448             : 
   45449             : //############################################################################
   45450             : /* JH (02/02/2006) Constructor of the IR node SgOmpUpdateClause that takes its 
   45451             :  * corresponding StorageClass as parameter
   45452             :  */
   45453           0 : SgOmpUpdateClause :: SgOmpUpdateClause ( const SgOmpUpdateClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   45454             :    {
   45455             : 
   45456             : 
   45457             : /* #line 45458 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   45458             : 
   45459           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   45460             : 
   45461             : 
   45462             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   45463             : 
   45464             : 
   45465           0 :    }
   45466             : 
   45467             : //############################################################################
   45468             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   45469             :  * within the working AST. 
   45470             :  */
   45471           0 : SgOmpUpdateClause * SgOmpUpdateClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   45472           0 :      SgOmpUpdateClause* returnPointer = NULL;
   45473           0 :      if ( globalIndex != 0 )
   45474             :         {
   45475             : 
   45476             : #if FILE_IO_EXTRA_CHECK
   45477           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUpdateClause ) ) <= globalIndex ) ;
   45478           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUpdateClause + 1 ) ) );
   45479             : #endif
   45480           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUpdateClause )  
   45481           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUpdateClause );
   45482           0 :           unsigned long positionInPool = localIndex % SgOmpUpdateClause::pool_size;
   45483           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUpdateClause::pool_size;
   45484             : 
   45485             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   45486             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   45487             : 
   45488           0 :           returnPointer = &( ( (SgOmpUpdateClause*)(SgOmpUpdateClause::pools[memoryBlock]) ) [positionInPool]) ;
   45489             : 
   45490           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   45491             :         }
   45492           0 :      return returnPointer ;
   45493             :    }
   45494             : 
   45495             : //############################################################################
   45496             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   45497             :   for the AST with the index astIndex
   45498             : */
   45499           0 : SgOmpUpdateClause * SgOmpUpdateClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   45500           0 :      SgOmpUpdateClause* returnPointer = NULL;
   45501           0 :      if ( globalIndex != 0 )
   45502             :         {
   45503             : 
   45504             : #if FILE_IO_EXTRA_CHECK
   45505           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUpdateClause ) ) <= globalIndex ) ;
   45506           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUpdateClause + 1 ) ) );
   45507             : #endif
   45508           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUpdateClause )
   45509           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUpdateClause );
   45510           0 :           unsigned long positionInPool = localIndex % SgOmpUpdateClause::pool_size ;
   45511           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUpdateClause::pool_size ;
   45512             : 
   45513             : #if FILE_IO_EXTRA_CHECK
   45514             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   45515             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   45516             : #endif
   45517             : 
   45518           0 :           returnPointer = &( ( (SgOmpUpdateClause*)(SgOmpUpdateClause::pools[memoryBlock]) ) [positionInPool]) ;
   45519             : 
   45520             : #if FILE_IO_EXTRA_CHECK
   45521           0 :           assert ( returnPointer != NULL ) ;
   45522             : #endif
   45523             :         }
   45524           0 :      return returnPointer ;
   45525             :    }
   45526             : 
   45527             : //############################################################################
   45528             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   45529             :  * pool size! We set for every valid object in the memory pool the freepointer
   45530             :  * to the global index and increase the global index afterwards. For all the 
   45531             :  * invalid objects (means address ranges within the memory pool that were not
   45532             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   45533             :  * distinguish valid from invalid objects! 
   45534             :  */
   45535             : unsigned long
   45536           5 : SgOmpUpdateClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   45537             :    {
   45538           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   45539           5 :      SgOmpUpdateClause* pointer = NULL;
   45540           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   45541           5 :      std::vector < unsigned char* > :: const_iterator block;
   45542           5 :      for ( block = SgOmpUpdateClause::pools.begin(); block != SgOmpUpdateClause::pools.end() ; ++block )
   45543             :         {
   45544           0 :           pointer = (SgOmpUpdateClause*)(*block);
   45545           0 :           for (unsigned i = 0; i < SgOmpUpdateClause::pool_size; ++i )
   45546             :              {
   45547             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   45548             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   45549             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   45550             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   45551             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   45552             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   45553             :             // properly; so this will have to be checked next.
   45554             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   45555             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   45556           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   45557             :                   {
   45558           0 :                     pointer[i].set_freepointer((SgOmpUpdateClause*)(globalIndex));
   45559           0 :                     globalIndex++;
   45560             :                   }
   45561             :                else
   45562             :                   {
   45563           0 :                     pointer[i].set_freepointer(NULL);
   45564             :                   }
   45565             :               }
   45566             :         }
   45567           5 :      return globalIndex;
   45568             :    }
   45569             : 
   45570             : //############################################################################
   45571             : // JH (01/14/2006)
   45572             : void
   45573           5 : SgOmpUpdateClause::resetValidFreepointers( )
   45574             :    {
   45575           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   45576           5 :      SgOmpUpdateClause* pointer = NULL;
   45577           5 :      std::vector < unsigned char* > :: const_iterator block;
   45578           5 :      SgOmpUpdateClause* pointerOfLinkedList = NULL;
   45579           5 :      for ( block = SgOmpUpdateClause::pools.begin(); block != SgOmpUpdateClause::pools.end() ; ++block )
   45580             :         {
   45581           0 :           pointer = (SgOmpUpdateClause*)(*block);
   45582           0 :           for (unsigned i = 0; i < SgOmpUpdateClause::pool_size; ++i )
   45583             :              {
   45584             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   45585             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   45586             :             // memory blocks!.
   45587           0 :                if ( pointer[i].get_freepointer() != NULL )
   45588             :                   {
   45589           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   45590             :                   }
   45591             :                else
   45592             :                   {
   45593           0 :                     if ( pointerOfLinkedList == NULL )
   45594             :                        {
   45595           0 :                          SgOmpUpdateClause::next_node = &(pointer[i]);
   45596             :                        }
   45597             :                     else
   45598             :                        {
   45599             :                       // printf ("In SgOmpUpdateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   45600           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   45601             :                        }
   45602             :                     pointerOfLinkedList = &(pointer[i]);
   45603             :                   }
   45604             :               }
   45605             :         }
   45606             : 
   45607           5 :      if ( pointerOfLinkedList != NULL )
   45608             :         {
   45609             :        // printf ("In SgOmpUpdateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   45610           0 :           pointerOfLinkedList->set_freepointer(NULL);
   45611             :        // DQ (6/6/2010): Temporary debugging...
   45612             :        //   ROSE_ASSERT(false);
   45613             :         }
   45614             : 
   45615           5 :      return ;
   45616             :    }
   45617             : 
   45618             : //############################################################################
   45619             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   45620             :  * within the memory pool and resets the freepointers, in order to achieve a 
   45621             :  * linked list, that has no jumps and starts at the beginning! This function 
   45622             :  * does not extend the memory pool, since we do not delete any memory blocks,
   45623             :  * but delete the valid objects.  
   45624             :  */
   45625             : void
   45626           0 : SgOmpUpdateClause::clearMemoryPool( )
   45627             :    {
   45628             :   // printf ("Inside of SgOmpUpdateClause::clearMemoryPool() \n");
   45629             : 
   45630           0 :      SgOmpUpdateClause* pointer = NULL, *tempPointer = NULL;
   45631           0 :      std::vector < unsigned char* > :: const_iterator block;
   45632           0 :      if ( SgOmpUpdateClause::pools.empty() == false )
   45633             :         {
   45634           0 :           block = SgOmpUpdateClause::pools.begin() ;
   45635           0 :           SgOmpUpdateClause::next_node = (SgOmpUpdateClause*) (*block);
   45636             : 
   45637           0 :           while ( block != SgOmpUpdateClause::pools.end() )
   45638             :              {
   45639           0 :                pointer = (SgOmpUpdateClause*) (*block);
   45640           0 :                if ( tempPointer != NULL )
   45641             :                   {
   45642           0 :                     tempPointer->set_freepointer(pointer);
   45643             :                   }
   45644           0 :                for (unsigned i = 0; i < SgOmpUpdateClause::pool_size - 1; ++i)
   45645             :                   {
   45646           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   45647             :                   }
   45648           0 :                 pointer[SgOmpUpdateClause::pool_size-1].set_freepointer(NULL);
   45649           0 :                 tempPointer = &(pointer[SgOmpUpdateClause::pool_size-1]);
   45650           0 :                 ++block;
   45651             :              }
   45652             :         }
   45653           0 :    }
   45654             : 
   45655           5 : void SgOmpUpdateClause::deleteMemoryPool() {
   45656           5 :   for (auto p: SgOmpUpdateClause::pools) {
   45657           0 :     ROSE_FREE(p);
   45658             :   }
   45659           5 :   SgOmpUpdateClause::next_node = nullptr;
   45660           5 :   SgOmpUpdateClause::pools.clear();
   45661           5 : }
   45662             : 
   45663             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   45664             : //                 reading multiple binary files to for a single AST.
   45665             : /////////// new version ////////////////////////////////
   45666             : //############################################################################
   45667             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   45668             : void
   45669           2 : SgOmpUpdateClause::extendMemoryPoolForFileIO( )
   45670             :   {
   45671           2 :     size_t blockIndex = SgOmpUpdateClause::pools.size();
   45672           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUpdateClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUpdateClause);
   45673             : 
   45674           2 :     while ( (blockIndex * SgOmpUpdateClause::pool_size) < newPoolSize)
   45675             :       {
   45676             : #if ROSE_ALLOC_TRACE
   45677             :         if (blockIndex > 0) {
   45678             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUpdateClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUpdateClause) = %" PRIuPTR " SgOmpUpdateClause::pool_size = %d \n",
   45679             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUpdateClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUpdateClause),SgOmpUpdateClause::pool_size);
   45680             :         }
   45681             : #endif
   45682             : 
   45683           0 :         SgOmpUpdateClause * pointer = (SgOmpUpdateClause*) ROSE_MALLOC ( SgOmpUpdateClause::pool_size * sizeof(SgOmpUpdateClause) );
   45684           0 :         assert( pointer != NULL );
   45685             : #if ROSE_ALLOC_MEMSET == 1
   45686             :         memset(pointer, 0x00, SgOmpUpdateClause::pool_size * sizeof(SgOmpUpdateClause));
   45687             : #elif ROSE_ALLOC_MEMSET == 2
   45688             :         memset(pointer, 0xCC, SgOmpUpdateClause::pool_size * sizeof(SgOmpUpdateClause));
   45689             : #endif
   45690           0 :         SgOmpUpdateClause::pools.push_back( (unsigned char*)(pointer) );
   45691           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUpdateClause::pool_size * sizeof(SgOmpUpdateClause), V_SgOmpUpdateClause ) );
   45692             : 
   45693           0 :         if ( SgOmpUpdateClause::next_node != NULL ) {
   45694           0 :           if ( blockIndex > 0 ) {
   45695           0 :             SgOmpUpdateClause * blkptr = (SgOmpUpdateClause*)(SgOmpUpdateClause::pools[blockIndex-1]);
   45696           0 :             blkptr[ SgOmpUpdateClause::pool_size - 1 ].set_freepointer(pointer);
   45697             :           }
   45698             :         } else {
   45699           0 :           SgOmpUpdateClause::next_node = pointer;
   45700             :         }
   45701             : 
   45702           0 :         for (unsigned i = 0; i < SgOmpUpdateClause::pool_size-1; ++i)
   45703             :            {
   45704           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   45705             :            }
   45706           0 :         pointer[ SgOmpUpdateClause::pool_size -1 ].set_freepointer(NULL);
   45707             : 
   45708           0 :         blockIndex++;
   45709             :       }
   45710           2 :   }
   45711             : 
   45712             : //############################################################################
   45713             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   45714             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   45715             :  * not compressed. However, that stuff is not yet implemented! 
   45716             :  */
   45717             : unsigned long
   45718           0 : SgOmpUpdateClause::getNumberOfLastValidPointer()
   45719             :    {
   45720           0 :       SgOmpUpdateClause* testPointer = (SgOmpUpdateClause*)(SgOmpUpdateClause::pools.back());
   45721           0 :       unsigned long localIndex = SgOmpUpdateClause::pool_size - 1;
   45722           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   45723             :          {
   45724           0 :            localIndex--;
   45725             :          }
   45726           0 :       return (localIndex + SgOmpUpdateClause::pool_size * (SgOmpUpdateClause::pools.size()-1));
   45727             :    }
   45728             : 
   45729             : //############################################################################
   45730             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   45731             :  * memory pool and initializes the data member in class SgOmpUpdateClauseStroageClass
   45732             :  * from its counterpart of SgOmpUpdateClause. The return value is just for checking, 
   45733             :  * that the whole StorageClassArray is initialized!
   45734             :  */
   45735             : unsigned long
   45736           0 : SgOmpUpdateClause::initializeStorageClassArray( SgOmpUpdateClauseStorageClass *storageArray )
   45737             :    {
   45738           0 :      unsigned long storageCounter = 0;
   45739           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUpdateClause::pools.begin();
   45740           0 :      SgOmpUpdateClause* pointer = NULL;
   45741           0 :      while ( block != SgOmpUpdateClause::pools.end() ) {
   45742           0 :           pointer = (SgOmpUpdateClause*) (*block);
   45743           0 :           for ( unsigned i = 0; i < SgOmpUpdateClause::pool_size; ++i ) {
   45744           0 :                if ( pointer->get_freepointer() != NULL ) {
   45745           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   45746           0 :                  storageArray++;
   45747           0 :                  storageCounter++;
   45748             :                }
   45749           0 :                pointer++;
   45750             :              }
   45751           0 :            block++;
   45752             :         }
   45753           0 :      return storageCounter;
   45754             :    }
   45755             : 
   45756             : /* #line 45757 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   45757             : 
   45758             : 
   45759             : 
   45760             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   45761             : 
   45762             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   45763             : 
   45764             : //############################################################################
   45765             : /* JH (02/02/2006) Constructor of the IR node SgOmpDepobjUpdateClause that takes its 
   45766             :  * corresponding StorageClass as parameter
   45767             :  */
   45768           0 : SgOmpDepobjUpdateClause :: SgOmpDepobjUpdateClause ( const SgOmpDepobjUpdateClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   45769             :    {
   45770             : 
   45771             : 
   45772             : /* #line 45773 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   45773             : 
   45774           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   45775           0 :      p_modifier = storageSource.storageOf_modifier ;
   45776             : 
   45777             : 
   45778             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   45779             : 
   45780             : 
   45781           0 :    }
   45782             : 
   45783             : //############################################################################
   45784             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   45785             :  * within the working AST. 
   45786             :  */
   45787           0 : SgOmpDepobjUpdateClause * SgOmpDepobjUpdateClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   45788           0 :      SgOmpDepobjUpdateClause* returnPointer = NULL;
   45789           0 :      if ( globalIndex != 0 )
   45790             :         {
   45791             : 
   45792             : #if FILE_IO_EXTRA_CHECK
   45793           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDepobjUpdateClause ) ) <= globalIndex ) ;
   45794           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDepobjUpdateClause + 1 ) ) );
   45795             : #endif
   45796           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDepobjUpdateClause )  
   45797           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDepobjUpdateClause );
   45798           0 :           unsigned long positionInPool = localIndex % SgOmpDepobjUpdateClause::pool_size;
   45799           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDepobjUpdateClause::pool_size;
   45800             : 
   45801             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   45802             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   45803             : 
   45804           0 :           returnPointer = &( ( (SgOmpDepobjUpdateClause*)(SgOmpDepobjUpdateClause::pools[memoryBlock]) ) [positionInPool]) ;
   45805             : 
   45806           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   45807             :         }
   45808           0 :      return returnPointer ;
   45809             :    }
   45810             : 
   45811             : //############################################################################
   45812             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   45813             :   for the AST with the index astIndex
   45814             : */
   45815           0 : SgOmpDepobjUpdateClause * SgOmpDepobjUpdateClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   45816           0 :      SgOmpDepobjUpdateClause* returnPointer = NULL;
   45817           0 :      if ( globalIndex != 0 )
   45818             :         {
   45819             : 
   45820             : #if FILE_IO_EXTRA_CHECK
   45821           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDepobjUpdateClause ) ) <= globalIndex ) ;
   45822           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDepobjUpdateClause + 1 ) ) );
   45823             : #endif
   45824           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDepobjUpdateClause )
   45825           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDepobjUpdateClause );
   45826           0 :           unsigned long positionInPool = localIndex % SgOmpDepobjUpdateClause::pool_size ;
   45827           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDepobjUpdateClause::pool_size ;
   45828             : 
   45829             : #if FILE_IO_EXTRA_CHECK
   45830             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   45831             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   45832             : #endif
   45833             : 
   45834           0 :           returnPointer = &( ( (SgOmpDepobjUpdateClause*)(SgOmpDepobjUpdateClause::pools[memoryBlock]) ) [positionInPool]) ;
   45835             : 
   45836             : #if FILE_IO_EXTRA_CHECK
   45837           0 :           assert ( returnPointer != NULL ) ;
   45838             : #endif
   45839             :         }
   45840           0 :      return returnPointer ;
   45841             :    }
   45842             : 
   45843             : //############################################################################
   45844             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   45845             :  * pool size! We set for every valid object in the memory pool the freepointer
   45846             :  * to the global index and increase the global index afterwards. For all the 
   45847             :  * invalid objects (means address ranges within the memory pool that were not
   45848             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   45849             :  * distinguish valid from invalid objects! 
   45850             :  */
   45851             : unsigned long
   45852           5 : SgOmpDepobjUpdateClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   45853             :    {
   45854           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   45855           5 :      SgOmpDepobjUpdateClause* pointer = NULL;
   45856           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   45857           5 :      std::vector < unsigned char* > :: const_iterator block;
   45858           5 :      for ( block = SgOmpDepobjUpdateClause::pools.begin(); block != SgOmpDepobjUpdateClause::pools.end() ; ++block )
   45859             :         {
   45860           0 :           pointer = (SgOmpDepobjUpdateClause*)(*block);
   45861           0 :           for (unsigned i = 0; i < SgOmpDepobjUpdateClause::pool_size; ++i )
   45862             :              {
   45863             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   45864             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   45865             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   45866             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   45867             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   45868             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   45869             :             // properly; so this will have to be checked next.
   45870             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   45871             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   45872           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   45873             :                   {
   45874           0 :                     pointer[i].set_freepointer((SgOmpDepobjUpdateClause*)(globalIndex));
   45875           0 :                     globalIndex++;
   45876             :                   }
   45877             :                else
   45878             :                   {
   45879           0 :                     pointer[i].set_freepointer(NULL);
   45880             :                   }
   45881             :               }
   45882             :         }
   45883           5 :      return globalIndex;
   45884             :    }
   45885             : 
   45886             : //############################################################################
   45887             : // JH (01/14/2006)
   45888             : void
   45889           5 : SgOmpDepobjUpdateClause::resetValidFreepointers( )
   45890             :    {
   45891           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   45892           5 :      SgOmpDepobjUpdateClause* pointer = NULL;
   45893           5 :      std::vector < unsigned char* > :: const_iterator block;
   45894           5 :      SgOmpDepobjUpdateClause* pointerOfLinkedList = NULL;
   45895           5 :      for ( block = SgOmpDepobjUpdateClause::pools.begin(); block != SgOmpDepobjUpdateClause::pools.end() ; ++block )
   45896             :         {
   45897           0 :           pointer = (SgOmpDepobjUpdateClause*)(*block);
   45898           0 :           for (unsigned i = 0; i < SgOmpDepobjUpdateClause::pool_size; ++i )
   45899             :              {
   45900             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   45901             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   45902             :             // memory blocks!.
   45903           0 :                if ( pointer[i].get_freepointer() != NULL )
   45904             :                   {
   45905           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   45906             :                   }
   45907             :                else
   45908             :                   {
   45909           0 :                     if ( pointerOfLinkedList == NULL )
   45910             :                        {
   45911           0 :                          SgOmpDepobjUpdateClause::next_node = &(pointer[i]);
   45912             :                        }
   45913             :                     else
   45914             :                        {
   45915             :                       // printf ("In SgOmpDepobjUpdateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   45916           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   45917             :                        }
   45918             :                     pointerOfLinkedList = &(pointer[i]);
   45919             :                   }
   45920             :               }
   45921             :         }
   45922             : 
   45923           5 :      if ( pointerOfLinkedList != NULL )
   45924             :         {
   45925             :        // printf ("In SgOmpDepobjUpdateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   45926           0 :           pointerOfLinkedList->set_freepointer(NULL);
   45927             :        // DQ (6/6/2010): Temporary debugging...
   45928             :        //   ROSE_ASSERT(false);
   45929             :         }
   45930             : 
   45931           5 :      return ;
   45932             :    }
   45933             : 
   45934             : //############################################################################
   45935             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   45936             :  * within the memory pool and resets the freepointers, in order to achieve a 
   45937             :  * linked list, that has no jumps and starts at the beginning! This function 
   45938             :  * does not extend the memory pool, since we do not delete any memory blocks,
   45939             :  * but delete the valid objects.  
   45940             :  */
   45941             : void
   45942           0 : SgOmpDepobjUpdateClause::clearMemoryPool( )
   45943             :    {
   45944             :   // printf ("Inside of SgOmpDepobjUpdateClause::clearMemoryPool() \n");
   45945             : 
   45946           0 :      SgOmpDepobjUpdateClause* pointer = NULL, *tempPointer = NULL;
   45947           0 :      std::vector < unsigned char* > :: const_iterator block;
   45948           0 :      if ( SgOmpDepobjUpdateClause::pools.empty() == false )
   45949             :         {
   45950           0 :           block = SgOmpDepobjUpdateClause::pools.begin() ;
   45951           0 :           SgOmpDepobjUpdateClause::next_node = (SgOmpDepobjUpdateClause*) (*block);
   45952             : 
   45953           0 :           while ( block != SgOmpDepobjUpdateClause::pools.end() )
   45954             :              {
   45955           0 :                pointer = (SgOmpDepobjUpdateClause*) (*block);
   45956           0 :                if ( tempPointer != NULL )
   45957             :                   {
   45958           0 :                     tempPointer->set_freepointer(pointer);
   45959             :                   }
   45960           0 :                for (unsigned i = 0; i < SgOmpDepobjUpdateClause::pool_size - 1; ++i)
   45961             :                   {
   45962           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   45963             :                   }
   45964           0 :                 pointer[SgOmpDepobjUpdateClause::pool_size-1].set_freepointer(NULL);
   45965           0 :                 tempPointer = &(pointer[SgOmpDepobjUpdateClause::pool_size-1]);
   45966           0 :                 ++block;
   45967             :              }
   45968             :         }
   45969           0 :    }
   45970             : 
   45971           5 : void SgOmpDepobjUpdateClause::deleteMemoryPool() {
   45972           5 :   for (auto p: SgOmpDepobjUpdateClause::pools) {
   45973           0 :     ROSE_FREE(p);
   45974             :   }
   45975           5 :   SgOmpDepobjUpdateClause::next_node = nullptr;
   45976           5 :   SgOmpDepobjUpdateClause::pools.clear();
   45977           5 : }
   45978             : 
   45979             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   45980             : //                 reading multiple binary files to for a single AST.
   45981             : /////////// new version ////////////////////////////////
   45982             : //############################################################################
   45983             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   45984             : void
   45985           2 : SgOmpDepobjUpdateClause::extendMemoryPoolForFileIO( )
   45986             :   {
   45987           2 :     size_t blockIndex = SgOmpDepobjUpdateClause::pools.size();
   45988           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDepobjUpdateClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDepobjUpdateClause);
   45989             : 
   45990           2 :     while ( (blockIndex * SgOmpDepobjUpdateClause::pool_size) < newPoolSize)
   45991             :       {
   45992             : #if ROSE_ALLOC_TRACE
   45993             :         if (blockIndex > 0) {
   45994             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDepobjUpdateClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDepobjUpdateClause) = %" PRIuPTR " SgOmpDepobjUpdateClause::pool_size = %d \n",
   45995             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDepobjUpdateClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDepobjUpdateClause),SgOmpDepobjUpdateClause::pool_size);
   45996             :         }
   45997             : #endif
   45998             : 
   45999           0 :         SgOmpDepobjUpdateClause * pointer = (SgOmpDepobjUpdateClause*) ROSE_MALLOC ( SgOmpDepobjUpdateClause::pool_size * sizeof(SgOmpDepobjUpdateClause) );
   46000           0 :         assert( pointer != NULL );
   46001             : #if ROSE_ALLOC_MEMSET == 1
   46002             :         memset(pointer, 0x00, SgOmpDepobjUpdateClause::pool_size * sizeof(SgOmpDepobjUpdateClause));
   46003             : #elif ROSE_ALLOC_MEMSET == 2
   46004             :         memset(pointer, 0xCC, SgOmpDepobjUpdateClause::pool_size * sizeof(SgOmpDepobjUpdateClause));
   46005             : #endif
   46006           0 :         SgOmpDepobjUpdateClause::pools.push_back( (unsigned char*)(pointer) );
   46007           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDepobjUpdateClause::pool_size * sizeof(SgOmpDepobjUpdateClause), V_SgOmpDepobjUpdateClause ) );
   46008             : 
   46009           0 :         if ( SgOmpDepobjUpdateClause::next_node != NULL ) {
   46010           0 :           if ( blockIndex > 0 ) {
   46011           0 :             SgOmpDepobjUpdateClause * blkptr = (SgOmpDepobjUpdateClause*)(SgOmpDepobjUpdateClause::pools[blockIndex-1]);
   46012           0 :             blkptr[ SgOmpDepobjUpdateClause::pool_size - 1 ].set_freepointer(pointer);
   46013             :           }
   46014             :         } else {
   46015           0 :           SgOmpDepobjUpdateClause::next_node = pointer;
   46016             :         }
   46017             : 
   46018           0 :         for (unsigned i = 0; i < SgOmpDepobjUpdateClause::pool_size-1; ++i)
   46019             :            {
   46020           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   46021             :            }
   46022           0 :         pointer[ SgOmpDepobjUpdateClause::pool_size -1 ].set_freepointer(NULL);
   46023             : 
   46024           0 :         blockIndex++;
   46025             :       }
   46026           2 :   }
   46027             : 
   46028             : //############################################################################
   46029             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   46030             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   46031             :  * not compressed. However, that stuff is not yet implemented! 
   46032             :  */
   46033             : unsigned long
   46034           0 : SgOmpDepobjUpdateClause::getNumberOfLastValidPointer()
   46035             :    {
   46036           0 :       SgOmpDepobjUpdateClause* testPointer = (SgOmpDepobjUpdateClause*)(SgOmpDepobjUpdateClause::pools.back());
   46037           0 :       unsigned long localIndex = SgOmpDepobjUpdateClause::pool_size - 1;
   46038           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   46039             :          {
   46040           0 :            localIndex--;
   46041             :          }
   46042           0 :       return (localIndex + SgOmpDepobjUpdateClause::pool_size * (SgOmpDepobjUpdateClause::pools.size()-1));
   46043             :    }
   46044             : 
   46045             : //############################################################################
   46046             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   46047             :  * memory pool and initializes the data member in class SgOmpDepobjUpdateClauseStroageClass
   46048             :  * from its counterpart of SgOmpDepobjUpdateClause. The return value is just for checking, 
   46049             :  * that the whole StorageClassArray is initialized!
   46050             :  */
   46051             : unsigned long
   46052           0 : SgOmpDepobjUpdateClause::initializeStorageClassArray( SgOmpDepobjUpdateClauseStorageClass *storageArray )
   46053             :    {
   46054           0 :      unsigned long storageCounter = 0;
   46055           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDepobjUpdateClause::pools.begin();
   46056           0 :      SgOmpDepobjUpdateClause* pointer = NULL;
   46057           0 :      while ( block != SgOmpDepobjUpdateClause::pools.end() ) {
   46058           0 :           pointer = (SgOmpDepobjUpdateClause*) (*block);
   46059           0 :           for ( unsigned i = 0; i < SgOmpDepobjUpdateClause::pool_size; ++i ) {
   46060           0 :                if ( pointer->get_freepointer() != NULL ) {
   46061           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   46062           0 :                  storageArray++;
   46063           0 :                  storageCounter++;
   46064             :                }
   46065           0 :                pointer++;
   46066             :              }
   46067           0 :            block++;
   46068             :         }
   46069           0 :      return storageCounter;
   46070             :    }
   46071             : 
   46072             : /* #line 46073 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   46073             : 
   46074             : 
   46075             : 
   46076             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   46077             : 
   46078             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   46079             : 
   46080             : //############################################################################
   46081             : /* JH (02/02/2006) Constructor of the IR node SgOmpDestroyClause that takes its 
   46082             :  * corresponding StorageClass as parameter
   46083             :  */
   46084           0 : SgOmpDestroyClause :: SgOmpDestroyClause ( const SgOmpDestroyClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   46085             :    {
   46086             : 
   46087             : 
   46088             : /* #line 46089 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   46089             : 
   46090           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   46091             : 
   46092             : 
   46093             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   46094             : 
   46095             : 
   46096           0 :    }
   46097             : 
   46098             : //############################################################################
   46099             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   46100             :  * within the working AST. 
   46101             :  */
   46102           0 : SgOmpDestroyClause * SgOmpDestroyClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   46103           0 :      SgOmpDestroyClause* returnPointer = NULL;
   46104           0 :      if ( globalIndex != 0 )
   46105             :         {
   46106             : 
   46107             : #if FILE_IO_EXTRA_CHECK
   46108           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDestroyClause ) ) <= globalIndex ) ;
   46109           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDestroyClause + 1 ) ) );
   46110             : #endif
   46111           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDestroyClause )  
   46112           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDestroyClause );
   46113           0 :           unsigned long positionInPool = localIndex % SgOmpDestroyClause::pool_size;
   46114           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDestroyClause::pool_size;
   46115             : 
   46116             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   46117             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   46118             : 
   46119           0 :           returnPointer = &( ( (SgOmpDestroyClause*)(SgOmpDestroyClause::pools[memoryBlock]) ) [positionInPool]) ;
   46120             : 
   46121           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   46122             :         }
   46123           0 :      return returnPointer ;
   46124             :    }
   46125             : 
   46126             : //############################################################################
   46127             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   46128             :   for the AST with the index astIndex
   46129             : */
   46130           0 : SgOmpDestroyClause * SgOmpDestroyClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   46131           0 :      SgOmpDestroyClause* returnPointer = NULL;
   46132           0 :      if ( globalIndex != 0 )
   46133             :         {
   46134             : 
   46135             : #if FILE_IO_EXTRA_CHECK
   46136           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDestroyClause ) ) <= globalIndex ) ;
   46137           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDestroyClause + 1 ) ) );
   46138             : #endif
   46139           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDestroyClause )
   46140           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDestroyClause );
   46141           0 :           unsigned long positionInPool = localIndex % SgOmpDestroyClause::pool_size ;
   46142           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDestroyClause::pool_size ;
   46143             : 
   46144             : #if FILE_IO_EXTRA_CHECK
   46145             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   46146             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   46147             : #endif
   46148             : 
   46149           0 :           returnPointer = &( ( (SgOmpDestroyClause*)(SgOmpDestroyClause::pools[memoryBlock]) ) [positionInPool]) ;
   46150             : 
   46151             : #if FILE_IO_EXTRA_CHECK
   46152           0 :           assert ( returnPointer != NULL ) ;
   46153             : #endif
   46154             :         }
   46155           0 :      return returnPointer ;
   46156             :    }
   46157             : 
   46158             : //############################################################################
   46159             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   46160             :  * pool size! We set for every valid object in the memory pool the freepointer
   46161             :  * to the global index and increase the global index afterwards. For all the 
   46162             :  * invalid objects (means address ranges within the memory pool that were not
   46163             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   46164             :  * distinguish valid from invalid objects! 
   46165             :  */
   46166             : unsigned long
   46167           5 : SgOmpDestroyClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   46168             :    {
   46169           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   46170           5 :      SgOmpDestroyClause* pointer = NULL;
   46171           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   46172           5 :      std::vector < unsigned char* > :: const_iterator block;
   46173           5 :      for ( block = SgOmpDestroyClause::pools.begin(); block != SgOmpDestroyClause::pools.end() ; ++block )
   46174             :         {
   46175           0 :           pointer = (SgOmpDestroyClause*)(*block);
   46176           0 :           for (unsigned i = 0; i < SgOmpDestroyClause::pool_size; ++i )
   46177             :              {
   46178             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   46179             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   46180             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   46181             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   46182             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   46183             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   46184             :             // properly; so this will have to be checked next.
   46185             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   46186             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   46187           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   46188             :                   {
   46189           0 :                     pointer[i].set_freepointer((SgOmpDestroyClause*)(globalIndex));
   46190           0 :                     globalIndex++;
   46191             :                   }
   46192             :                else
   46193             :                   {
   46194           0 :                     pointer[i].set_freepointer(NULL);
   46195             :                   }
   46196             :               }
   46197             :         }
   46198           5 :      return globalIndex;
   46199             :    }
   46200             : 
   46201             : //############################################################################
   46202             : // JH (01/14/2006)
   46203             : void
   46204           5 : SgOmpDestroyClause::resetValidFreepointers( )
   46205             :    {
   46206           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   46207           5 :      SgOmpDestroyClause* pointer = NULL;
   46208           5 :      std::vector < unsigned char* > :: const_iterator block;
   46209           5 :      SgOmpDestroyClause* pointerOfLinkedList = NULL;
   46210           5 :      for ( block = SgOmpDestroyClause::pools.begin(); block != SgOmpDestroyClause::pools.end() ; ++block )
   46211             :         {
   46212           0 :           pointer = (SgOmpDestroyClause*)(*block);
   46213           0 :           for (unsigned i = 0; i < SgOmpDestroyClause::pool_size; ++i )
   46214             :              {
   46215             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   46216             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   46217             :             // memory blocks!.
   46218           0 :                if ( pointer[i].get_freepointer() != NULL )
   46219             :                   {
   46220           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   46221             :                   }
   46222             :                else
   46223             :                   {
   46224           0 :                     if ( pointerOfLinkedList == NULL )
   46225             :                        {
   46226           0 :                          SgOmpDestroyClause::next_node = &(pointer[i]);
   46227             :                        }
   46228             :                     else
   46229             :                        {
   46230             :                       // printf ("In SgOmpDestroyClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   46231           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   46232             :                        }
   46233             :                     pointerOfLinkedList = &(pointer[i]);
   46234             :                   }
   46235             :               }
   46236             :         }
   46237             : 
   46238           5 :      if ( pointerOfLinkedList != NULL )
   46239             :         {
   46240             :        // printf ("In SgOmpDestroyClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   46241           0 :           pointerOfLinkedList->set_freepointer(NULL);
   46242             :        // DQ (6/6/2010): Temporary debugging...
   46243             :        //   ROSE_ASSERT(false);
   46244             :         }
   46245             : 
   46246           5 :      return ;
   46247             :    }
   46248             : 
   46249             : //############################################################################
   46250             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   46251             :  * within the memory pool and resets the freepointers, in order to achieve a 
   46252             :  * linked list, that has no jumps and starts at the beginning! This function 
   46253             :  * does not extend the memory pool, since we do not delete any memory blocks,
   46254             :  * but delete the valid objects.  
   46255             :  */
   46256             : void
   46257           0 : SgOmpDestroyClause::clearMemoryPool( )
   46258             :    {
   46259             :   // printf ("Inside of SgOmpDestroyClause::clearMemoryPool() \n");
   46260             : 
   46261           0 :      SgOmpDestroyClause* pointer = NULL, *tempPointer = NULL;
   46262           0 :      std::vector < unsigned char* > :: const_iterator block;
   46263           0 :      if ( SgOmpDestroyClause::pools.empty() == false )
   46264             :         {
   46265           0 :           block = SgOmpDestroyClause::pools.begin() ;
   46266           0 :           SgOmpDestroyClause::next_node = (SgOmpDestroyClause*) (*block);
   46267             : 
   46268           0 :           while ( block != SgOmpDestroyClause::pools.end() )
   46269             :              {
   46270           0 :                pointer = (SgOmpDestroyClause*) (*block);
   46271           0 :                if ( tempPointer != NULL )
   46272             :                   {
   46273           0 :                     tempPointer->set_freepointer(pointer);
   46274             :                   }
   46275           0 :                for (unsigned i = 0; i < SgOmpDestroyClause::pool_size - 1; ++i)
   46276             :                   {
   46277           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   46278             :                   }
   46279           0 :                 pointer[SgOmpDestroyClause::pool_size-1].set_freepointer(NULL);
   46280           0 :                 tempPointer = &(pointer[SgOmpDestroyClause::pool_size-1]);
   46281           0 :                 ++block;
   46282             :              }
   46283             :         }
   46284           0 :    }
   46285             : 
   46286           5 : void SgOmpDestroyClause::deleteMemoryPool() {
   46287           5 :   for (auto p: SgOmpDestroyClause::pools) {
   46288           0 :     ROSE_FREE(p);
   46289             :   }
   46290           5 :   SgOmpDestroyClause::next_node = nullptr;
   46291           5 :   SgOmpDestroyClause::pools.clear();
   46292           5 : }
   46293             : 
   46294             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   46295             : //                 reading multiple binary files to for a single AST.
   46296             : /////////// new version ////////////////////////////////
   46297             : //############################################################################
   46298             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   46299             : void
   46300           2 : SgOmpDestroyClause::extendMemoryPoolForFileIO( )
   46301             :   {
   46302           2 :     size_t blockIndex = SgOmpDestroyClause::pools.size();
   46303           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDestroyClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDestroyClause);
   46304             : 
   46305           2 :     while ( (blockIndex * SgOmpDestroyClause::pool_size) < newPoolSize)
   46306             :       {
   46307             : #if ROSE_ALLOC_TRACE
   46308             :         if (blockIndex > 0) {
   46309             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDestroyClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDestroyClause) = %" PRIuPTR " SgOmpDestroyClause::pool_size = %d \n",
   46310             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDestroyClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDestroyClause),SgOmpDestroyClause::pool_size);
   46311             :         }
   46312             : #endif
   46313             : 
   46314           0 :         SgOmpDestroyClause * pointer = (SgOmpDestroyClause*) ROSE_MALLOC ( SgOmpDestroyClause::pool_size * sizeof(SgOmpDestroyClause) );
   46315           0 :         assert( pointer != NULL );
   46316             : #if ROSE_ALLOC_MEMSET == 1
   46317             :         memset(pointer, 0x00, SgOmpDestroyClause::pool_size * sizeof(SgOmpDestroyClause));
   46318             : #elif ROSE_ALLOC_MEMSET == 2
   46319             :         memset(pointer, 0xCC, SgOmpDestroyClause::pool_size * sizeof(SgOmpDestroyClause));
   46320             : #endif
   46321           0 :         SgOmpDestroyClause::pools.push_back( (unsigned char*)(pointer) );
   46322           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDestroyClause::pool_size * sizeof(SgOmpDestroyClause), V_SgOmpDestroyClause ) );
   46323             : 
   46324           0 :         if ( SgOmpDestroyClause::next_node != NULL ) {
   46325           0 :           if ( blockIndex > 0 ) {
   46326           0 :             SgOmpDestroyClause * blkptr = (SgOmpDestroyClause*)(SgOmpDestroyClause::pools[blockIndex-1]);
   46327           0 :             blkptr[ SgOmpDestroyClause::pool_size - 1 ].set_freepointer(pointer);
   46328             :           }
   46329             :         } else {
   46330           0 :           SgOmpDestroyClause::next_node = pointer;
   46331             :         }
   46332             : 
   46333           0 :         for (unsigned i = 0; i < SgOmpDestroyClause::pool_size-1; ++i)
   46334             :            {
   46335           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   46336             :            }
   46337           0 :         pointer[ SgOmpDestroyClause::pool_size -1 ].set_freepointer(NULL);
   46338             : 
   46339           0 :         blockIndex++;
   46340             :       }
   46341           2 :   }
   46342             : 
   46343             : //############################################################################
   46344             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   46345             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   46346             :  * not compressed. However, that stuff is not yet implemented! 
   46347             :  */
   46348             : unsigned long
   46349           0 : SgOmpDestroyClause::getNumberOfLastValidPointer()
   46350             :    {
   46351           0 :       SgOmpDestroyClause* testPointer = (SgOmpDestroyClause*)(SgOmpDestroyClause::pools.back());
   46352           0 :       unsigned long localIndex = SgOmpDestroyClause::pool_size - 1;
   46353           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   46354             :          {
   46355           0 :            localIndex--;
   46356             :          }
   46357           0 :       return (localIndex + SgOmpDestroyClause::pool_size * (SgOmpDestroyClause::pools.size()-1));
   46358             :    }
   46359             : 
   46360             : //############################################################################
   46361             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   46362             :  * memory pool and initializes the data member in class SgOmpDestroyClauseStroageClass
   46363             :  * from its counterpart of SgOmpDestroyClause. The return value is just for checking, 
   46364             :  * that the whole StorageClassArray is initialized!
   46365             :  */
   46366             : unsigned long
   46367           0 : SgOmpDestroyClause::initializeStorageClassArray( SgOmpDestroyClauseStorageClass *storageArray )
   46368             :    {
   46369           0 :      unsigned long storageCounter = 0;
   46370           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDestroyClause::pools.begin();
   46371           0 :      SgOmpDestroyClause* pointer = NULL;
   46372           0 :      while ( block != SgOmpDestroyClause::pools.end() ) {
   46373           0 :           pointer = (SgOmpDestroyClause*) (*block);
   46374           0 :           for ( unsigned i = 0; i < SgOmpDestroyClause::pool_size; ++i ) {
   46375           0 :                if ( pointer->get_freepointer() != NULL ) {
   46376           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   46377           0 :                  storageArray++;
   46378           0 :                  storageCounter++;
   46379             :                }
   46380           0 :                pointer++;
   46381             :              }
   46382           0 :            block++;
   46383             :         }
   46384           0 :      return storageCounter;
   46385             :    }
   46386             : 
   46387             : /* #line 46388 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   46388             : 
   46389             : 
   46390             : 
   46391             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   46392             : 
   46393             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   46394             : 
   46395             : //############################################################################
   46396             : /* JH (02/02/2006) Constructor of the IR node SgOmpCaptureClause that takes its 
   46397             :  * corresponding StorageClass as parameter
   46398             :  */
   46399           0 : SgOmpCaptureClause :: SgOmpCaptureClause ( const SgOmpCaptureClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   46400             :    {
   46401             : 
   46402             : 
   46403             : /* #line 46404 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   46404             : 
   46405           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   46406             : 
   46407             : 
   46408             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   46409             : 
   46410             : 
   46411           0 :    }
   46412             : 
   46413             : //############################################################################
   46414             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   46415             :  * within the working AST. 
   46416             :  */
   46417           0 : SgOmpCaptureClause * SgOmpCaptureClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   46418           0 :      SgOmpCaptureClause* returnPointer = NULL;
   46419           0 :      if ( globalIndex != 0 )
   46420             :         {
   46421             : 
   46422             : #if FILE_IO_EXTRA_CHECK
   46423           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpCaptureClause ) ) <= globalIndex ) ;
   46424           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCaptureClause + 1 ) ) );
   46425             : #endif
   46426           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCaptureClause )  
   46427           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpCaptureClause );
   46428           0 :           unsigned long positionInPool = localIndex % SgOmpCaptureClause::pool_size;
   46429           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCaptureClause::pool_size;
   46430             : 
   46431             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   46432             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   46433             : 
   46434           0 :           returnPointer = &( ( (SgOmpCaptureClause*)(SgOmpCaptureClause::pools[memoryBlock]) ) [positionInPool]) ;
   46435             : 
   46436           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   46437             :         }
   46438           0 :      return returnPointer ;
   46439             :    }
   46440             : 
   46441             : //############################################################################
   46442             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   46443             :   for the AST with the index astIndex
   46444             : */
   46445           0 : SgOmpCaptureClause * SgOmpCaptureClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   46446           0 :      SgOmpCaptureClause* returnPointer = NULL;
   46447           0 :      if ( globalIndex != 0 )
   46448             :         {
   46449             : 
   46450             : #if FILE_IO_EXTRA_CHECK
   46451           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpCaptureClause ) ) <= globalIndex ) ;
   46452           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCaptureClause + 1 ) ) );
   46453             : #endif
   46454           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCaptureClause )
   46455           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpCaptureClause );
   46456           0 :           unsigned long positionInPool = localIndex % SgOmpCaptureClause::pool_size ;
   46457           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCaptureClause::pool_size ;
   46458             : 
   46459             : #if FILE_IO_EXTRA_CHECK
   46460             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   46461             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   46462             : #endif
   46463             : 
   46464           0 :           returnPointer = &( ( (SgOmpCaptureClause*)(SgOmpCaptureClause::pools[memoryBlock]) ) [positionInPool]) ;
   46465             : 
   46466             : #if FILE_IO_EXTRA_CHECK
   46467           0 :           assert ( returnPointer != NULL ) ;
   46468             : #endif
   46469             :         }
   46470           0 :      return returnPointer ;
   46471             :    }
   46472             : 
   46473             : //############################################################################
   46474             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   46475             :  * pool size! We set for every valid object in the memory pool the freepointer
   46476             :  * to the global index and increase the global index afterwards. For all the 
   46477             :  * invalid objects (means address ranges within the memory pool that were not
   46478             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   46479             :  * distinguish valid from invalid objects! 
   46480             :  */
   46481             : unsigned long
   46482           5 : SgOmpCaptureClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   46483             :    {
   46484           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   46485           5 :      SgOmpCaptureClause* pointer = NULL;
   46486           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   46487           5 :      std::vector < unsigned char* > :: const_iterator block;
   46488           5 :      for ( block = SgOmpCaptureClause::pools.begin(); block != SgOmpCaptureClause::pools.end() ; ++block )
   46489             :         {
   46490           0 :           pointer = (SgOmpCaptureClause*)(*block);
   46491           0 :           for (unsigned i = 0; i < SgOmpCaptureClause::pool_size; ++i )
   46492             :              {
   46493             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   46494             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   46495             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   46496             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   46497             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   46498             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   46499             :             // properly; so this will have to be checked next.
   46500             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   46501             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   46502           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   46503             :                   {
   46504           0 :                     pointer[i].set_freepointer((SgOmpCaptureClause*)(globalIndex));
   46505           0 :                     globalIndex++;
   46506             :                   }
   46507             :                else
   46508             :                   {
   46509           0 :                     pointer[i].set_freepointer(NULL);
   46510             :                   }
   46511             :               }
   46512             :         }
   46513           5 :      return globalIndex;
   46514             :    }
   46515             : 
   46516             : //############################################################################
   46517             : // JH (01/14/2006)
   46518             : void
   46519           5 : SgOmpCaptureClause::resetValidFreepointers( )
   46520             :    {
   46521           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   46522           5 :      SgOmpCaptureClause* pointer = NULL;
   46523           5 :      std::vector < unsigned char* > :: const_iterator block;
   46524           5 :      SgOmpCaptureClause* pointerOfLinkedList = NULL;
   46525           5 :      for ( block = SgOmpCaptureClause::pools.begin(); block != SgOmpCaptureClause::pools.end() ; ++block )
   46526             :         {
   46527           0 :           pointer = (SgOmpCaptureClause*)(*block);
   46528           0 :           for (unsigned i = 0; i < SgOmpCaptureClause::pool_size; ++i )
   46529             :              {
   46530             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   46531             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   46532             :             // memory blocks!.
   46533           0 :                if ( pointer[i].get_freepointer() != NULL )
   46534             :                   {
   46535           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   46536             :                   }
   46537             :                else
   46538             :                   {
   46539           0 :                     if ( pointerOfLinkedList == NULL )
   46540             :                        {
   46541           0 :                          SgOmpCaptureClause::next_node = &(pointer[i]);
   46542             :                        }
   46543             :                     else
   46544             :                        {
   46545             :                       // printf ("In SgOmpCaptureClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   46546           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   46547             :                        }
   46548             :                     pointerOfLinkedList = &(pointer[i]);
   46549             :                   }
   46550             :               }
   46551             :         }
   46552             : 
   46553           5 :      if ( pointerOfLinkedList != NULL )
   46554             :         {
   46555             :        // printf ("In SgOmpCaptureClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   46556           0 :           pointerOfLinkedList->set_freepointer(NULL);
   46557             :        // DQ (6/6/2010): Temporary debugging...
   46558             :        //   ROSE_ASSERT(false);
   46559             :         }
   46560             : 
   46561           5 :      return ;
   46562             :    }
   46563             : 
   46564             : //############################################################################
   46565             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   46566             :  * within the memory pool and resets the freepointers, in order to achieve a 
   46567             :  * linked list, that has no jumps and starts at the beginning! This function 
   46568             :  * does not extend the memory pool, since we do not delete any memory blocks,
   46569             :  * but delete the valid objects.  
   46570             :  */
   46571             : void
   46572           0 : SgOmpCaptureClause::clearMemoryPool( )
   46573             :    {
   46574             :   // printf ("Inside of SgOmpCaptureClause::clearMemoryPool() \n");
   46575             : 
   46576           0 :      SgOmpCaptureClause* pointer = NULL, *tempPointer = NULL;
   46577           0 :      std::vector < unsigned char* > :: const_iterator block;
   46578           0 :      if ( SgOmpCaptureClause::pools.empty() == false )
   46579             :         {
   46580           0 :           block = SgOmpCaptureClause::pools.begin() ;
   46581           0 :           SgOmpCaptureClause::next_node = (SgOmpCaptureClause*) (*block);
   46582             : 
   46583           0 :           while ( block != SgOmpCaptureClause::pools.end() )
   46584             :              {
   46585           0 :                pointer = (SgOmpCaptureClause*) (*block);
   46586           0 :                if ( tempPointer != NULL )
   46587             :                   {
   46588           0 :                     tempPointer->set_freepointer(pointer);
   46589             :                   }
   46590           0 :                for (unsigned i = 0; i < SgOmpCaptureClause::pool_size - 1; ++i)
   46591             :                   {
   46592           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   46593             :                   }
   46594           0 :                 pointer[SgOmpCaptureClause::pool_size-1].set_freepointer(NULL);
   46595           0 :                 tempPointer = &(pointer[SgOmpCaptureClause::pool_size-1]);
   46596           0 :                 ++block;
   46597             :              }
   46598             :         }
   46599           0 :    }
   46600             : 
   46601           5 : void SgOmpCaptureClause::deleteMemoryPool() {
   46602           5 :   for (auto p: SgOmpCaptureClause::pools) {
   46603           0 :     ROSE_FREE(p);
   46604             :   }
   46605           5 :   SgOmpCaptureClause::next_node = nullptr;
   46606           5 :   SgOmpCaptureClause::pools.clear();
   46607           5 : }
   46608             : 
   46609             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   46610             : //                 reading multiple binary files to for a single AST.
   46611             : /////////// new version ////////////////////////////////
   46612             : //############################################################################
   46613             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   46614             : void
   46615           2 : SgOmpCaptureClause::extendMemoryPoolForFileIO( )
   46616             :   {
   46617           2 :     size_t blockIndex = SgOmpCaptureClause::pools.size();
   46618           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCaptureClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCaptureClause);
   46619             : 
   46620           2 :     while ( (blockIndex * SgOmpCaptureClause::pool_size) < newPoolSize)
   46621             :       {
   46622             : #if ROSE_ALLOC_TRACE
   46623             :         if (blockIndex > 0) {
   46624             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCaptureClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCaptureClause) = %" PRIuPTR " SgOmpCaptureClause::pool_size = %d \n",
   46625             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCaptureClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCaptureClause),SgOmpCaptureClause::pool_size);
   46626             :         }
   46627             : #endif
   46628             : 
   46629           0 :         SgOmpCaptureClause * pointer = (SgOmpCaptureClause*) ROSE_MALLOC ( SgOmpCaptureClause::pool_size * sizeof(SgOmpCaptureClause) );
   46630           0 :         assert( pointer != NULL );
   46631             : #if ROSE_ALLOC_MEMSET == 1
   46632             :         memset(pointer, 0x00, SgOmpCaptureClause::pool_size * sizeof(SgOmpCaptureClause));
   46633             : #elif ROSE_ALLOC_MEMSET == 2
   46634             :         memset(pointer, 0xCC, SgOmpCaptureClause::pool_size * sizeof(SgOmpCaptureClause));
   46635             : #endif
   46636           0 :         SgOmpCaptureClause::pools.push_back( (unsigned char*)(pointer) );
   46637           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpCaptureClause::pool_size * sizeof(SgOmpCaptureClause), V_SgOmpCaptureClause ) );
   46638             : 
   46639           0 :         if ( SgOmpCaptureClause::next_node != NULL ) {
   46640           0 :           if ( blockIndex > 0 ) {
   46641           0 :             SgOmpCaptureClause * blkptr = (SgOmpCaptureClause*)(SgOmpCaptureClause::pools[blockIndex-1]);
   46642           0 :             blkptr[ SgOmpCaptureClause::pool_size - 1 ].set_freepointer(pointer);
   46643             :           }
   46644             :         } else {
   46645           0 :           SgOmpCaptureClause::next_node = pointer;
   46646             :         }
   46647             : 
   46648           0 :         for (unsigned i = 0; i < SgOmpCaptureClause::pool_size-1; ++i)
   46649             :            {
   46650           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   46651             :            }
   46652           0 :         pointer[ SgOmpCaptureClause::pool_size -1 ].set_freepointer(NULL);
   46653             : 
   46654           0 :         blockIndex++;
   46655             :       }
   46656           2 :   }
   46657             : 
   46658             : //############################################################################
   46659             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   46660             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   46661             :  * not compressed. However, that stuff is not yet implemented! 
   46662             :  */
   46663             : unsigned long
   46664           0 : SgOmpCaptureClause::getNumberOfLastValidPointer()
   46665             :    {
   46666           0 :       SgOmpCaptureClause* testPointer = (SgOmpCaptureClause*)(SgOmpCaptureClause::pools.back());
   46667           0 :       unsigned long localIndex = SgOmpCaptureClause::pool_size - 1;
   46668           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   46669             :          {
   46670           0 :            localIndex--;
   46671             :          }
   46672           0 :       return (localIndex + SgOmpCaptureClause::pool_size * (SgOmpCaptureClause::pools.size()-1));
   46673             :    }
   46674             : 
   46675             : //############################################################################
   46676             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   46677             :  * memory pool and initializes the data member in class SgOmpCaptureClauseStroageClass
   46678             :  * from its counterpart of SgOmpCaptureClause. The return value is just for checking, 
   46679             :  * that the whole StorageClassArray is initialized!
   46680             :  */
   46681             : unsigned long
   46682           0 : SgOmpCaptureClause::initializeStorageClassArray( SgOmpCaptureClauseStorageClass *storageArray )
   46683             :    {
   46684           0 :      unsigned long storageCounter = 0;
   46685           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpCaptureClause::pools.begin();
   46686           0 :      SgOmpCaptureClause* pointer = NULL;
   46687           0 :      while ( block != SgOmpCaptureClause::pools.end() ) {
   46688           0 :           pointer = (SgOmpCaptureClause*) (*block);
   46689           0 :           for ( unsigned i = 0; i < SgOmpCaptureClause::pool_size; ++i ) {
   46690           0 :                if ( pointer->get_freepointer() != NULL ) {
   46691           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   46692           0 :                  storageArray++;
   46693           0 :                  storageCounter++;
   46694             :                }
   46695           0 :                pointer++;
   46696             :              }
   46697           0 :            block++;
   46698             :         }
   46699           0 :      return storageCounter;
   46700             :    }
   46701             : 
   46702             : /* #line 46703 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   46703             : 
   46704             : 
   46705             : 
   46706             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   46707             : 
   46708             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   46709             : 
   46710             : //############################################################################
   46711             : /* JH (02/02/2006) Constructor of the IR node SgOmpBeginClause that takes its 
   46712             :  * corresponding StorageClass as parameter
   46713             :  */
   46714           0 : SgOmpBeginClause :: SgOmpBeginClause ( const SgOmpBeginClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   46715             :    {
   46716             : 
   46717             : 
   46718             : /* #line 46719 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   46719             : 
   46720           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   46721             : 
   46722             : 
   46723             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   46724             : 
   46725             : 
   46726           0 :    }
   46727             : 
   46728             : //############################################################################
   46729             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   46730             :  * within the working AST. 
   46731             :  */
   46732           0 : SgOmpBeginClause * SgOmpBeginClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   46733           0 :      SgOmpBeginClause* returnPointer = NULL;
   46734           0 :      if ( globalIndex != 0 )
   46735             :         {
   46736             : 
   46737             : #if FILE_IO_EXTRA_CHECK
   46738           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpBeginClause ) ) <= globalIndex ) ;
   46739           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpBeginClause + 1 ) ) );
   46740             : #endif
   46741           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpBeginClause )  
   46742           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpBeginClause );
   46743           0 :           unsigned long positionInPool = localIndex % SgOmpBeginClause::pool_size;
   46744           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpBeginClause::pool_size;
   46745             : 
   46746             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   46747             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   46748             : 
   46749           0 :           returnPointer = &( ( (SgOmpBeginClause*)(SgOmpBeginClause::pools[memoryBlock]) ) [positionInPool]) ;
   46750             : 
   46751           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   46752             :         }
   46753           0 :      return returnPointer ;
   46754             :    }
   46755             : 
   46756             : //############################################################################
   46757             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   46758             :   for the AST with the index astIndex
   46759             : */
   46760           0 : SgOmpBeginClause * SgOmpBeginClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   46761           0 :      SgOmpBeginClause* returnPointer = NULL;
   46762           0 :      if ( globalIndex != 0 )
   46763             :         {
   46764             : 
   46765             : #if FILE_IO_EXTRA_CHECK
   46766           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpBeginClause ) ) <= globalIndex ) ;
   46767           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpBeginClause + 1 ) ) );
   46768             : #endif
   46769           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpBeginClause )
   46770           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpBeginClause );
   46771           0 :           unsigned long positionInPool = localIndex % SgOmpBeginClause::pool_size ;
   46772           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpBeginClause::pool_size ;
   46773             : 
   46774             : #if FILE_IO_EXTRA_CHECK
   46775             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   46776             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   46777             : #endif
   46778             : 
   46779           0 :           returnPointer = &( ( (SgOmpBeginClause*)(SgOmpBeginClause::pools[memoryBlock]) ) [positionInPool]) ;
   46780             : 
   46781             : #if FILE_IO_EXTRA_CHECK
   46782           0 :           assert ( returnPointer != NULL ) ;
   46783             : #endif
   46784             :         }
   46785           0 :      return returnPointer ;
   46786             :    }
   46787             : 
   46788             : //############################################################################
   46789             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   46790             :  * pool size! We set for every valid object in the memory pool the freepointer
   46791             :  * to the global index and increase the global index afterwards. For all the 
   46792             :  * invalid objects (means address ranges within the memory pool that were not
   46793             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   46794             :  * distinguish valid from invalid objects! 
   46795             :  */
   46796             : unsigned long
   46797           5 : SgOmpBeginClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   46798             :    {
   46799           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   46800           5 :      SgOmpBeginClause* pointer = NULL;
   46801           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   46802           5 :      std::vector < unsigned char* > :: const_iterator block;
   46803           5 :      for ( block = SgOmpBeginClause::pools.begin(); block != SgOmpBeginClause::pools.end() ; ++block )
   46804             :         {
   46805           0 :           pointer = (SgOmpBeginClause*)(*block);
   46806           0 :           for (unsigned i = 0; i < SgOmpBeginClause::pool_size; ++i )
   46807             :              {
   46808             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   46809             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   46810             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   46811             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   46812             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   46813             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   46814             :             // properly; so this will have to be checked next.
   46815             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   46816             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   46817           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   46818             :                   {
   46819           0 :                     pointer[i].set_freepointer((SgOmpBeginClause*)(globalIndex));
   46820           0 :                     globalIndex++;
   46821             :                   }
   46822             :                else
   46823             :                   {
   46824           0 :                     pointer[i].set_freepointer(NULL);
   46825             :                   }
   46826             :               }
   46827             :         }
   46828           5 :      return globalIndex;
   46829             :    }
   46830             : 
   46831             : //############################################################################
   46832             : // JH (01/14/2006)
   46833             : void
   46834           5 : SgOmpBeginClause::resetValidFreepointers( )
   46835             :    {
   46836           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   46837           5 :      SgOmpBeginClause* pointer = NULL;
   46838           5 :      std::vector < unsigned char* > :: const_iterator block;
   46839           5 :      SgOmpBeginClause* pointerOfLinkedList = NULL;
   46840           5 :      for ( block = SgOmpBeginClause::pools.begin(); block != SgOmpBeginClause::pools.end() ; ++block )
   46841             :         {
   46842           0 :           pointer = (SgOmpBeginClause*)(*block);
   46843           0 :           for (unsigned i = 0; i < SgOmpBeginClause::pool_size; ++i )
   46844             :              {
   46845             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   46846             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   46847             :             // memory blocks!.
   46848           0 :                if ( pointer[i].get_freepointer() != NULL )
   46849             :                   {
   46850           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   46851             :                   }
   46852             :                else
   46853             :                   {
   46854           0 :                     if ( pointerOfLinkedList == NULL )
   46855             :                        {
   46856           0 :                          SgOmpBeginClause::next_node = &(pointer[i]);
   46857             :                        }
   46858             :                     else
   46859             :                        {
   46860             :                       // printf ("In SgOmpBeginClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   46861           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   46862             :                        }
   46863             :                     pointerOfLinkedList = &(pointer[i]);
   46864             :                   }
   46865             :               }
   46866             :         }
   46867             : 
   46868           5 :      if ( pointerOfLinkedList != NULL )
   46869             :         {
   46870             :        // printf ("In SgOmpBeginClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   46871           0 :           pointerOfLinkedList->set_freepointer(NULL);
   46872             :        // DQ (6/6/2010): Temporary debugging...
   46873             :        //   ROSE_ASSERT(false);
   46874             :         }
   46875             : 
   46876           5 :      return ;
   46877             :    }
   46878             : 
   46879             : //############################################################################
   46880             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   46881             :  * within the memory pool and resets the freepointers, in order to achieve a 
   46882             :  * linked list, that has no jumps and starts at the beginning! This function 
   46883             :  * does not extend the memory pool, since we do not delete any memory blocks,
   46884             :  * but delete the valid objects.  
   46885             :  */
   46886             : void
   46887           0 : SgOmpBeginClause::clearMemoryPool( )
   46888             :    {
   46889             :   // printf ("Inside of SgOmpBeginClause::clearMemoryPool() \n");
   46890             : 
   46891           0 :      SgOmpBeginClause* pointer = NULL, *tempPointer = NULL;
   46892           0 :      std::vector < unsigned char* > :: const_iterator block;
   46893           0 :      if ( SgOmpBeginClause::pools.empty() == false )
   46894             :         {
   46895           0 :           block = SgOmpBeginClause::pools.begin() ;
   46896           0 :           SgOmpBeginClause::next_node = (SgOmpBeginClause*) (*block);
   46897             : 
   46898           0 :           while ( block != SgOmpBeginClause::pools.end() )
   46899             :              {
   46900           0 :                pointer = (SgOmpBeginClause*) (*block);
   46901           0 :                if ( tempPointer != NULL )
   46902             :                   {
   46903           0 :                     tempPointer->set_freepointer(pointer);
   46904             :                   }
   46905           0 :                for (unsigned i = 0; i < SgOmpBeginClause::pool_size - 1; ++i)
   46906             :                   {
   46907           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   46908             :                   }
   46909           0 :                 pointer[SgOmpBeginClause::pool_size-1].set_freepointer(NULL);
   46910           0 :                 tempPointer = &(pointer[SgOmpBeginClause::pool_size-1]);
   46911           0 :                 ++block;
   46912             :              }
   46913             :         }
   46914           0 :    }
   46915             : 
   46916           5 : void SgOmpBeginClause::deleteMemoryPool() {
   46917           5 :   for (auto p: SgOmpBeginClause::pools) {
   46918           0 :     ROSE_FREE(p);
   46919             :   }
   46920           5 :   SgOmpBeginClause::next_node = nullptr;
   46921           5 :   SgOmpBeginClause::pools.clear();
   46922           5 : }
   46923             : 
   46924             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   46925             : //                 reading multiple binary files to for a single AST.
   46926             : /////////// new version ////////////////////////////////
   46927             : //############################################################################
   46928             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   46929             : void
   46930           2 : SgOmpBeginClause::extendMemoryPoolForFileIO( )
   46931             :   {
   46932           2 :     size_t blockIndex = SgOmpBeginClause::pools.size();
   46933           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBeginClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBeginClause);
   46934             : 
   46935           2 :     while ( (blockIndex * SgOmpBeginClause::pool_size) < newPoolSize)
   46936             :       {
   46937             : #if ROSE_ALLOC_TRACE
   46938             :         if (blockIndex > 0) {
   46939             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBeginClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBeginClause) = %" PRIuPTR " SgOmpBeginClause::pool_size = %d \n",
   46940             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBeginClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBeginClause),SgOmpBeginClause::pool_size);
   46941             :         }
   46942             : #endif
   46943             : 
   46944           0 :         SgOmpBeginClause * pointer = (SgOmpBeginClause*) ROSE_MALLOC ( SgOmpBeginClause::pool_size * sizeof(SgOmpBeginClause) );
   46945           0 :         assert( pointer != NULL );
   46946             : #if ROSE_ALLOC_MEMSET == 1
   46947             :         memset(pointer, 0x00, SgOmpBeginClause::pool_size * sizeof(SgOmpBeginClause));
   46948             : #elif ROSE_ALLOC_MEMSET == 2
   46949             :         memset(pointer, 0xCC, SgOmpBeginClause::pool_size * sizeof(SgOmpBeginClause));
   46950             : #endif
   46951           0 :         SgOmpBeginClause::pools.push_back( (unsigned char*)(pointer) );
   46952           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpBeginClause::pool_size * sizeof(SgOmpBeginClause), V_SgOmpBeginClause ) );
   46953             : 
   46954           0 :         if ( SgOmpBeginClause::next_node != NULL ) {
   46955           0 :           if ( blockIndex > 0 ) {
   46956           0 :             SgOmpBeginClause * blkptr = (SgOmpBeginClause*)(SgOmpBeginClause::pools[blockIndex-1]);
   46957           0 :             blkptr[ SgOmpBeginClause::pool_size - 1 ].set_freepointer(pointer);
   46958             :           }
   46959             :         } else {
   46960           0 :           SgOmpBeginClause::next_node = pointer;
   46961             :         }
   46962             : 
   46963           0 :         for (unsigned i = 0; i < SgOmpBeginClause::pool_size-1; ++i)
   46964             :            {
   46965           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   46966             :            }
   46967           0 :         pointer[ SgOmpBeginClause::pool_size -1 ].set_freepointer(NULL);
   46968             : 
   46969           0 :         blockIndex++;
   46970             :       }
   46971           2 :   }
   46972             : 
   46973             : //############################################################################
   46974             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   46975             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   46976             :  * not compressed. However, that stuff is not yet implemented! 
   46977             :  */
   46978             : unsigned long
   46979           0 : SgOmpBeginClause::getNumberOfLastValidPointer()
   46980             :    {
   46981           0 :       SgOmpBeginClause* testPointer = (SgOmpBeginClause*)(SgOmpBeginClause::pools.back());
   46982           0 :       unsigned long localIndex = SgOmpBeginClause::pool_size - 1;
   46983           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   46984             :          {
   46985           0 :            localIndex--;
   46986             :          }
   46987           0 :       return (localIndex + SgOmpBeginClause::pool_size * (SgOmpBeginClause::pools.size()-1));
   46988             :    }
   46989             : 
   46990             : //############################################################################
   46991             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   46992             :  * memory pool and initializes the data member in class SgOmpBeginClauseStroageClass
   46993             :  * from its counterpart of SgOmpBeginClause. The return value is just for checking, 
   46994             :  * that the whole StorageClassArray is initialized!
   46995             :  */
   46996             : unsigned long
   46997           0 : SgOmpBeginClause::initializeStorageClassArray( SgOmpBeginClauseStorageClass *storageArray )
   46998             :    {
   46999           0 :      unsigned long storageCounter = 0;
   47000           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpBeginClause::pools.begin();
   47001           0 :      SgOmpBeginClause* pointer = NULL;
   47002           0 :      while ( block != SgOmpBeginClause::pools.end() ) {
   47003           0 :           pointer = (SgOmpBeginClause*) (*block);
   47004           0 :           for ( unsigned i = 0; i < SgOmpBeginClause::pool_size; ++i ) {
   47005           0 :                if ( pointer->get_freepointer() != NULL ) {
   47006           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   47007           0 :                  storageArray++;
   47008           0 :                  storageCounter++;
   47009             :                }
   47010           0 :                pointer++;
   47011             :              }
   47012           0 :            block++;
   47013             :         }
   47014           0 :      return storageCounter;
   47015             :    }
   47016             : 
   47017             : /* #line 47018 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   47018             : 
   47019             : 
   47020             : 
   47021             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   47022             : 
   47023             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   47024             : 
   47025             : //############################################################################
   47026             : /* JH (02/02/2006) Constructor of the IR node SgOmpEndClause that takes its 
   47027             :  * corresponding StorageClass as parameter
   47028             :  */
   47029           0 : SgOmpEndClause :: SgOmpEndClause ( const SgOmpEndClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   47030             :    {
   47031             : 
   47032             : 
   47033             : /* #line 47034 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   47034             : 
   47035           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   47036             : 
   47037             : 
   47038             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   47039             : 
   47040             : 
   47041           0 :    }
   47042             : 
   47043             : //############################################################################
   47044             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   47045             :  * within the working AST. 
   47046             :  */
   47047           0 : SgOmpEndClause * SgOmpEndClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   47048           0 :      SgOmpEndClause* returnPointer = NULL;
   47049           0 :      if ( globalIndex != 0 )
   47050             :         {
   47051             : 
   47052             : #if FILE_IO_EXTRA_CHECK
   47053           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpEndClause ) ) <= globalIndex ) ;
   47054           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpEndClause + 1 ) ) );
   47055             : #endif
   47056           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpEndClause )  
   47057           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpEndClause );
   47058           0 :           unsigned long positionInPool = localIndex % SgOmpEndClause::pool_size;
   47059           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpEndClause::pool_size;
   47060             : 
   47061             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   47062             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   47063             : 
   47064           0 :           returnPointer = &( ( (SgOmpEndClause*)(SgOmpEndClause::pools[memoryBlock]) ) [positionInPool]) ;
   47065             : 
   47066           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   47067             :         }
   47068           0 :      return returnPointer ;
   47069             :    }
   47070             : 
   47071             : //############################################################################
   47072             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   47073             :   for the AST with the index astIndex
   47074             : */
   47075           0 : SgOmpEndClause * SgOmpEndClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   47076           0 :      SgOmpEndClause* returnPointer = NULL;
   47077           0 :      if ( globalIndex != 0 )
   47078             :         {
   47079             : 
   47080             : #if FILE_IO_EXTRA_CHECK
   47081           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpEndClause ) ) <= globalIndex ) ;
   47082           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpEndClause + 1 ) ) );
   47083             : #endif
   47084           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpEndClause )
   47085           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpEndClause );
   47086           0 :           unsigned long positionInPool = localIndex % SgOmpEndClause::pool_size ;
   47087           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpEndClause::pool_size ;
   47088             : 
   47089             : #if FILE_IO_EXTRA_CHECK
   47090             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   47091             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   47092             : #endif
   47093             : 
   47094           0 :           returnPointer = &( ( (SgOmpEndClause*)(SgOmpEndClause::pools[memoryBlock]) ) [positionInPool]) ;
   47095             : 
   47096             : #if FILE_IO_EXTRA_CHECK
   47097           0 :           assert ( returnPointer != NULL ) ;
   47098             : #endif
   47099             :         }
   47100           0 :      return returnPointer ;
   47101             :    }
   47102             : 
   47103             : //############################################################################
   47104             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   47105             :  * pool size! We set for every valid object in the memory pool the freepointer
   47106             :  * to the global index and increase the global index afterwards. For all the 
   47107             :  * invalid objects (means address ranges within the memory pool that were not
   47108             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   47109             :  * distinguish valid from invalid objects! 
   47110             :  */
   47111             : unsigned long
   47112           5 : SgOmpEndClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   47113             :    {
   47114           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   47115           5 :      SgOmpEndClause* pointer = NULL;
   47116           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   47117           5 :      std::vector < unsigned char* > :: const_iterator block;
   47118           5 :      for ( block = SgOmpEndClause::pools.begin(); block != SgOmpEndClause::pools.end() ; ++block )
   47119             :         {
   47120           0 :           pointer = (SgOmpEndClause*)(*block);
   47121           0 :           for (unsigned i = 0; i < SgOmpEndClause::pool_size; ++i )
   47122             :              {
   47123             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   47124             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   47125             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   47126             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   47127             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   47128             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   47129             :             // properly; so this will have to be checked next.
   47130             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   47131             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   47132           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   47133             :                   {
   47134           0 :                     pointer[i].set_freepointer((SgOmpEndClause*)(globalIndex));
   47135           0 :                     globalIndex++;
   47136             :                   }
   47137             :                else
   47138             :                   {
   47139           0 :                     pointer[i].set_freepointer(NULL);
   47140             :                   }
   47141             :               }
   47142             :         }
   47143           5 :      return globalIndex;
   47144             :    }
   47145             : 
   47146             : //############################################################################
   47147             : // JH (01/14/2006)
   47148             : void
   47149           5 : SgOmpEndClause::resetValidFreepointers( )
   47150             :    {
   47151           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   47152           5 :      SgOmpEndClause* pointer = NULL;
   47153           5 :      std::vector < unsigned char* > :: const_iterator block;
   47154           5 :      SgOmpEndClause* pointerOfLinkedList = NULL;
   47155           5 :      for ( block = SgOmpEndClause::pools.begin(); block != SgOmpEndClause::pools.end() ; ++block )
   47156             :         {
   47157           0 :           pointer = (SgOmpEndClause*)(*block);
   47158           0 :           for (unsigned i = 0; i < SgOmpEndClause::pool_size; ++i )
   47159             :              {
   47160             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   47161             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   47162             :             // memory blocks!.
   47163           0 :                if ( pointer[i].get_freepointer() != NULL )
   47164             :                   {
   47165           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   47166             :                   }
   47167             :                else
   47168             :                   {
   47169           0 :                     if ( pointerOfLinkedList == NULL )
   47170             :                        {
   47171           0 :                          SgOmpEndClause::next_node = &(pointer[i]);
   47172             :                        }
   47173             :                     else
   47174             :                        {
   47175             :                       // printf ("In SgOmpEndClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   47176           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   47177             :                        }
   47178             :                     pointerOfLinkedList = &(pointer[i]);
   47179             :                   }
   47180             :               }
   47181             :         }
   47182             : 
   47183           5 :      if ( pointerOfLinkedList != NULL )
   47184             :         {
   47185             :        // printf ("In SgOmpEndClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   47186           0 :           pointerOfLinkedList->set_freepointer(NULL);
   47187             :        // DQ (6/6/2010): Temporary debugging...
   47188             :        //   ROSE_ASSERT(false);
   47189             :         }
   47190             : 
   47191           5 :      return ;
   47192             :    }
   47193             : 
   47194             : //############################################################################
   47195             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   47196             :  * within the memory pool and resets the freepointers, in order to achieve a 
   47197             :  * linked list, that has no jumps and starts at the beginning! This function 
   47198             :  * does not extend the memory pool, since we do not delete any memory blocks,
   47199             :  * but delete the valid objects.  
   47200             :  */
   47201             : void
   47202           0 : SgOmpEndClause::clearMemoryPool( )
   47203             :    {
   47204             :   // printf ("Inside of SgOmpEndClause::clearMemoryPool() \n");
   47205             : 
   47206           0 :      SgOmpEndClause* pointer = NULL, *tempPointer = NULL;
   47207           0 :      std::vector < unsigned char* > :: const_iterator block;
   47208           0 :      if ( SgOmpEndClause::pools.empty() == false )
   47209             :         {
   47210           0 :           block = SgOmpEndClause::pools.begin() ;
   47211           0 :           SgOmpEndClause::next_node = (SgOmpEndClause*) (*block);
   47212             : 
   47213           0 :           while ( block != SgOmpEndClause::pools.end() )
   47214             :              {
   47215           0 :                pointer = (SgOmpEndClause*) (*block);
   47216           0 :                if ( tempPointer != NULL )
   47217             :                   {
   47218           0 :                     tempPointer->set_freepointer(pointer);
   47219             :                   }
   47220           0 :                for (unsigned i = 0; i < SgOmpEndClause::pool_size - 1; ++i)
   47221             :                   {
   47222           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   47223             :                   }
   47224           0 :                 pointer[SgOmpEndClause::pool_size-1].set_freepointer(NULL);
   47225           0 :                 tempPointer = &(pointer[SgOmpEndClause::pool_size-1]);
   47226           0 :                 ++block;
   47227             :              }
   47228             :         }
   47229           0 :    }
   47230             : 
   47231           5 : void SgOmpEndClause::deleteMemoryPool() {
   47232           5 :   for (auto p: SgOmpEndClause::pools) {
   47233           0 :     ROSE_FREE(p);
   47234             :   }
   47235           5 :   SgOmpEndClause::next_node = nullptr;
   47236           5 :   SgOmpEndClause::pools.clear();
   47237           5 : }
   47238             : 
   47239             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   47240             : //                 reading multiple binary files to for a single AST.
   47241             : /////////// new version ////////////////////////////////
   47242             : //############################################################################
   47243             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   47244             : void
   47245           2 : SgOmpEndClause::extendMemoryPoolForFileIO( )
   47246             :   {
   47247           2 :     size_t blockIndex = SgOmpEndClause::pools.size();
   47248           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpEndClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpEndClause);
   47249             : 
   47250           2 :     while ( (blockIndex * SgOmpEndClause::pool_size) < newPoolSize)
   47251             :       {
   47252             : #if ROSE_ALLOC_TRACE
   47253             :         if (blockIndex > 0) {
   47254             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpEndClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpEndClause) = %" PRIuPTR " SgOmpEndClause::pool_size = %d \n",
   47255             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpEndClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpEndClause),SgOmpEndClause::pool_size);
   47256             :         }
   47257             : #endif
   47258             : 
   47259           0 :         SgOmpEndClause * pointer = (SgOmpEndClause*) ROSE_MALLOC ( SgOmpEndClause::pool_size * sizeof(SgOmpEndClause) );
   47260           0 :         assert( pointer != NULL );
   47261             : #if ROSE_ALLOC_MEMSET == 1
   47262             :         memset(pointer, 0x00, SgOmpEndClause::pool_size * sizeof(SgOmpEndClause));
   47263             : #elif ROSE_ALLOC_MEMSET == 2
   47264             :         memset(pointer, 0xCC, SgOmpEndClause::pool_size * sizeof(SgOmpEndClause));
   47265             : #endif
   47266           0 :         SgOmpEndClause::pools.push_back( (unsigned char*)(pointer) );
   47267           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpEndClause::pool_size * sizeof(SgOmpEndClause), V_SgOmpEndClause ) );
   47268             : 
   47269           0 :         if ( SgOmpEndClause::next_node != NULL ) {
   47270           0 :           if ( blockIndex > 0 ) {
   47271           0 :             SgOmpEndClause * blkptr = (SgOmpEndClause*)(SgOmpEndClause::pools[blockIndex-1]);
   47272           0 :             blkptr[ SgOmpEndClause::pool_size - 1 ].set_freepointer(pointer);
   47273             :           }
   47274             :         } else {
   47275           0 :           SgOmpEndClause::next_node = pointer;
   47276             :         }
   47277             : 
   47278           0 :         for (unsigned i = 0; i < SgOmpEndClause::pool_size-1; ++i)
   47279             :            {
   47280           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   47281             :            }
   47282           0 :         pointer[ SgOmpEndClause::pool_size -1 ].set_freepointer(NULL);
   47283             : 
   47284           0 :         blockIndex++;
   47285             :       }
   47286           2 :   }
   47287             : 
   47288             : //############################################################################
   47289             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   47290             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   47291             :  * not compressed. However, that stuff is not yet implemented! 
   47292             :  */
   47293             : unsigned long
   47294           0 : SgOmpEndClause::getNumberOfLastValidPointer()
   47295             :    {
   47296           0 :       SgOmpEndClause* testPointer = (SgOmpEndClause*)(SgOmpEndClause::pools.back());
   47297           0 :       unsigned long localIndex = SgOmpEndClause::pool_size - 1;
   47298           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   47299             :          {
   47300           0 :            localIndex--;
   47301             :          }
   47302           0 :       return (localIndex + SgOmpEndClause::pool_size * (SgOmpEndClause::pools.size()-1));
   47303             :    }
   47304             : 
   47305             : //############################################################################
   47306             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   47307             :  * memory pool and initializes the data member in class SgOmpEndClauseStroageClass
   47308             :  * from its counterpart of SgOmpEndClause. The return value is just for checking, 
   47309             :  * that the whole StorageClassArray is initialized!
   47310             :  */
   47311             : unsigned long
   47312           0 : SgOmpEndClause::initializeStorageClassArray( SgOmpEndClauseStorageClass *storageArray )
   47313             :    {
   47314           0 :      unsigned long storageCounter = 0;
   47315           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpEndClause::pools.begin();
   47316           0 :      SgOmpEndClause* pointer = NULL;
   47317           0 :      while ( block != SgOmpEndClause::pools.end() ) {
   47318           0 :           pointer = (SgOmpEndClause*) (*block);
   47319           0 :           for ( unsigned i = 0; i < SgOmpEndClause::pool_size; ++i ) {
   47320           0 :                if ( pointer->get_freepointer() != NULL ) {
   47321           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   47322           0 :                  storageArray++;
   47323           0 :                  storageCounter++;
   47324             :                }
   47325           0 :                pointer++;
   47326             :              }
   47327           0 :            block++;
   47328             :         }
   47329           0 :      return storageCounter;
   47330             :    }
   47331             : 
   47332             : /* #line 47333 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   47333             : 
   47334             : 
   47335             : 
   47336             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   47337             : 
   47338             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   47339             : 
   47340             : //############################################################################
   47341             : /* JH (02/02/2006) Constructor of the IR node SgOmpUntiedClause that takes its 
   47342             :  * corresponding StorageClass as parameter
   47343             :  */
   47344           0 : SgOmpUntiedClause :: SgOmpUntiedClause ( const SgOmpUntiedClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   47345             :    {
   47346             : 
   47347             : 
   47348             : /* #line 47349 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   47349             : 
   47350           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   47351             : 
   47352             : 
   47353             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   47354             : 
   47355             : 
   47356           0 :    }
   47357             : 
   47358             : //############################################################################
   47359             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   47360             :  * within the working AST. 
   47361             :  */
   47362           0 : SgOmpUntiedClause * SgOmpUntiedClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   47363           0 :      SgOmpUntiedClause* returnPointer = NULL;
   47364           0 :      if ( globalIndex != 0 )
   47365             :         {
   47366             : 
   47367             : #if FILE_IO_EXTRA_CHECK
   47368           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUntiedClause ) ) <= globalIndex ) ;
   47369           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUntiedClause + 1 ) ) );
   47370             : #endif
   47371           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUntiedClause )  
   47372           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUntiedClause );
   47373           0 :           unsigned long positionInPool = localIndex % SgOmpUntiedClause::pool_size;
   47374           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUntiedClause::pool_size;
   47375             : 
   47376             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   47377             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   47378             : 
   47379           0 :           returnPointer = &( ( (SgOmpUntiedClause*)(SgOmpUntiedClause::pools[memoryBlock]) ) [positionInPool]) ;
   47380             : 
   47381           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   47382             :         }
   47383           0 :      return returnPointer ;
   47384             :    }
   47385             : 
   47386             : //############################################################################
   47387             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   47388             :   for the AST with the index astIndex
   47389             : */
   47390           0 : SgOmpUntiedClause * SgOmpUntiedClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   47391           0 :      SgOmpUntiedClause* returnPointer = NULL;
   47392           0 :      if ( globalIndex != 0 )
   47393             :         {
   47394             : 
   47395             : #if FILE_IO_EXTRA_CHECK
   47396           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUntiedClause ) ) <= globalIndex ) ;
   47397           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUntiedClause + 1 ) ) );
   47398             : #endif
   47399           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUntiedClause )
   47400           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUntiedClause );
   47401           0 :           unsigned long positionInPool = localIndex % SgOmpUntiedClause::pool_size ;
   47402           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUntiedClause::pool_size ;
   47403             : 
   47404             : #if FILE_IO_EXTRA_CHECK
   47405             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   47406             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   47407             : #endif
   47408             : 
   47409           0 :           returnPointer = &( ( (SgOmpUntiedClause*)(SgOmpUntiedClause::pools[memoryBlock]) ) [positionInPool]) ;
   47410             : 
   47411             : #if FILE_IO_EXTRA_CHECK
   47412           0 :           assert ( returnPointer != NULL ) ;
   47413             : #endif
   47414             :         }
   47415           0 :      return returnPointer ;
   47416             :    }
   47417             : 
   47418             : //############################################################################
   47419             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   47420             :  * pool size! We set for every valid object in the memory pool the freepointer
   47421             :  * to the global index and increase the global index afterwards. For all the 
   47422             :  * invalid objects (means address ranges within the memory pool that were not
   47423             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   47424             :  * distinguish valid from invalid objects! 
   47425             :  */
   47426             : unsigned long
   47427           5 : SgOmpUntiedClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   47428             :    {
   47429           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   47430           5 :      SgOmpUntiedClause* pointer = NULL;
   47431           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   47432           5 :      std::vector < unsigned char* > :: const_iterator block;
   47433           5 :      for ( block = SgOmpUntiedClause::pools.begin(); block != SgOmpUntiedClause::pools.end() ; ++block )
   47434             :         {
   47435           0 :           pointer = (SgOmpUntiedClause*)(*block);
   47436           0 :           for (unsigned i = 0; i < SgOmpUntiedClause::pool_size; ++i )
   47437             :              {
   47438             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   47439             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   47440             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   47441             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   47442             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   47443             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   47444             :             // properly; so this will have to be checked next.
   47445             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   47446             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   47447           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   47448             :                   {
   47449           0 :                     pointer[i].set_freepointer((SgOmpUntiedClause*)(globalIndex));
   47450           0 :                     globalIndex++;
   47451             :                   }
   47452             :                else
   47453             :                   {
   47454           0 :                     pointer[i].set_freepointer(NULL);
   47455             :                   }
   47456             :               }
   47457             :         }
   47458           5 :      return globalIndex;
   47459             :    }
   47460             : 
   47461             : //############################################################################
   47462             : // JH (01/14/2006)
   47463             : void
   47464           5 : SgOmpUntiedClause::resetValidFreepointers( )
   47465             :    {
   47466           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   47467           5 :      SgOmpUntiedClause* pointer = NULL;
   47468           5 :      std::vector < unsigned char* > :: const_iterator block;
   47469           5 :      SgOmpUntiedClause* pointerOfLinkedList = NULL;
   47470           5 :      for ( block = SgOmpUntiedClause::pools.begin(); block != SgOmpUntiedClause::pools.end() ; ++block )
   47471             :         {
   47472           0 :           pointer = (SgOmpUntiedClause*)(*block);
   47473           0 :           for (unsigned i = 0; i < SgOmpUntiedClause::pool_size; ++i )
   47474             :              {
   47475             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   47476             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   47477             :             // memory blocks!.
   47478           0 :                if ( pointer[i].get_freepointer() != NULL )
   47479             :                   {
   47480           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   47481             :                   }
   47482             :                else
   47483             :                   {
   47484           0 :                     if ( pointerOfLinkedList == NULL )
   47485             :                        {
   47486           0 :                          SgOmpUntiedClause::next_node = &(pointer[i]);
   47487             :                        }
   47488             :                     else
   47489             :                        {
   47490             :                       // printf ("In SgOmpUntiedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   47491           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   47492             :                        }
   47493             :                     pointerOfLinkedList = &(pointer[i]);
   47494             :                   }
   47495             :               }
   47496             :         }
   47497             : 
   47498           5 :      if ( pointerOfLinkedList != NULL )
   47499             :         {
   47500             :        // printf ("In SgOmpUntiedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   47501           0 :           pointerOfLinkedList->set_freepointer(NULL);
   47502             :        // DQ (6/6/2010): Temporary debugging...
   47503             :        //   ROSE_ASSERT(false);
   47504             :         }
   47505             : 
   47506           5 :      return ;
   47507             :    }
   47508             : 
   47509             : //############################################################################
   47510             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   47511             :  * within the memory pool and resets the freepointers, in order to achieve a 
   47512             :  * linked list, that has no jumps and starts at the beginning! This function 
   47513             :  * does not extend the memory pool, since we do not delete any memory blocks,
   47514             :  * but delete the valid objects.  
   47515             :  */
   47516             : void
   47517           0 : SgOmpUntiedClause::clearMemoryPool( )
   47518             :    {
   47519             :   // printf ("Inside of SgOmpUntiedClause::clearMemoryPool() \n");
   47520             : 
   47521           0 :      SgOmpUntiedClause* pointer = NULL, *tempPointer = NULL;
   47522           0 :      std::vector < unsigned char* > :: const_iterator block;
   47523           0 :      if ( SgOmpUntiedClause::pools.empty() == false )
   47524             :         {
   47525           0 :           block = SgOmpUntiedClause::pools.begin() ;
   47526           0 :           SgOmpUntiedClause::next_node = (SgOmpUntiedClause*) (*block);
   47527             : 
   47528           0 :           while ( block != SgOmpUntiedClause::pools.end() )
   47529             :              {
   47530           0 :                pointer = (SgOmpUntiedClause*) (*block);
   47531           0 :                if ( tempPointer != NULL )
   47532             :                   {
   47533           0 :                     tempPointer->set_freepointer(pointer);
   47534             :                   }
   47535           0 :                for (unsigned i = 0; i < SgOmpUntiedClause::pool_size - 1; ++i)
   47536             :                   {
   47537           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   47538             :                   }
   47539           0 :                 pointer[SgOmpUntiedClause::pool_size-1].set_freepointer(NULL);
   47540           0 :                 tempPointer = &(pointer[SgOmpUntiedClause::pool_size-1]);
   47541           0 :                 ++block;
   47542             :              }
   47543             :         }
   47544           0 :    }
   47545             : 
   47546           5 : void SgOmpUntiedClause::deleteMemoryPool() {
   47547           5 :   for (auto p: SgOmpUntiedClause::pools) {
   47548           0 :     ROSE_FREE(p);
   47549             :   }
   47550           5 :   SgOmpUntiedClause::next_node = nullptr;
   47551           5 :   SgOmpUntiedClause::pools.clear();
   47552           5 : }
   47553             : 
   47554             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   47555             : //                 reading multiple binary files to for a single AST.
   47556             : /////////// new version ////////////////////////////////
   47557             : //############################################################################
   47558             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   47559             : void
   47560           2 : SgOmpUntiedClause::extendMemoryPoolForFileIO( )
   47561             :   {
   47562           2 :     size_t blockIndex = SgOmpUntiedClause::pools.size();
   47563           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUntiedClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUntiedClause);
   47564             : 
   47565           2 :     while ( (blockIndex * SgOmpUntiedClause::pool_size) < newPoolSize)
   47566             :       {
   47567             : #if ROSE_ALLOC_TRACE
   47568             :         if (blockIndex > 0) {
   47569             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUntiedClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUntiedClause) = %" PRIuPTR " SgOmpUntiedClause::pool_size = %d \n",
   47570             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUntiedClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUntiedClause),SgOmpUntiedClause::pool_size);
   47571             :         }
   47572             : #endif
   47573             : 
   47574           0 :         SgOmpUntiedClause * pointer = (SgOmpUntiedClause*) ROSE_MALLOC ( SgOmpUntiedClause::pool_size * sizeof(SgOmpUntiedClause) );
   47575           0 :         assert( pointer != NULL );
   47576             : #if ROSE_ALLOC_MEMSET == 1
   47577             :         memset(pointer, 0x00, SgOmpUntiedClause::pool_size * sizeof(SgOmpUntiedClause));
   47578             : #elif ROSE_ALLOC_MEMSET == 2
   47579             :         memset(pointer, 0xCC, SgOmpUntiedClause::pool_size * sizeof(SgOmpUntiedClause));
   47580             : #endif
   47581           0 :         SgOmpUntiedClause::pools.push_back( (unsigned char*)(pointer) );
   47582           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUntiedClause::pool_size * sizeof(SgOmpUntiedClause), V_SgOmpUntiedClause ) );
   47583             : 
   47584           0 :         if ( SgOmpUntiedClause::next_node != NULL ) {
   47585           0 :           if ( blockIndex > 0 ) {
   47586           0 :             SgOmpUntiedClause * blkptr = (SgOmpUntiedClause*)(SgOmpUntiedClause::pools[blockIndex-1]);
   47587           0 :             blkptr[ SgOmpUntiedClause::pool_size - 1 ].set_freepointer(pointer);
   47588             :           }
   47589             :         } else {
   47590           0 :           SgOmpUntiedClause::next_node = pointer;
   47591             :         }
   47592             : 
   47593           0 :         for (unsigned i = 0; i < SgOmpUntiedClause::pool_size-1; ++i)
   47594             :            {
   47595           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   47596             :            }
   47597           0 :         pointer[ SgOmpUntiedClause::pool_size -1 ].set_freepointer(NULL);
   47598             : 
   47599           0 :         blockIndex++;
   47600             :       }
   47601           2 :   }
   47602             : 
   47603             : //############################################################################
   47604             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   47605             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   47606             :  * not compressed. However, that stuff is not yet implemented! 
   47607             :  */
   47608             : unsigned long
   47609           0 : SgOmpUntiedClause::getNumberOfLastValidPointer()
   47610             :    {
   47611           0 :       SgOmpUntiedClause* testPointer = (SgOmpUntiedClause*)(SgOmpUntiedClause::pools.back());
   47612           0 :       unsigned long localIndex = SgOmpUntiedClause::pool_size - 1;
   47613           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   47614             :          {
   47615           0 :            localIndex--;
   47616             :          }
   47617           0 :       return (localIndex + SgOmpUntiedClause::pool_size * (SgOmpUntiedClause::pools.size()-1));
   47618             :    }
   47619             : 
   47620             : //############################################################################
   47621             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   47622             :  * memory pool and initializes the data member in class SgOmpUntiedClauseStroageClass
   47623             :  * from its counterpart of SgOmpUntiedClause. The return value is just for checking, 
   47624             :  * that the whole StorageClassArray is initialized!
   47625             :  */
   47626             : unsigned long
   47627           0 : SgOmpUntiedClause::initializeStorageClassArray( SgOmpUntiedClauseStorageClass *storageArray )
   47628             :    {
   47629           0 :      unsigned long storageCounter = 0;
   47630           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUntiedClause::pools.begin();
   47631           0 :      SgOmpUntiedClause* pointer = NULL;
   47632           0 :      while ( block != SgOmpUntiedClause::pools.end() ) {
   47633           0 :           pointer = (SgOmpUntiedClause*) (*block);
   47634           0 :           for ( unsigned i = 0; i < SgOmpUntiedClause::pool_size; ++i ) {
   47635           0 :                if ( pointer->get_freepointer() != NULL ) {
   47636           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   47637           0 :                  storageArray++;
   47638           0 :                  storageCounter++;
   47639             :                }
   47640           0 :                pointer++;
   47641             :              }
   47642           0 :            block++;
   47643             :         }
   47644           0 :      return storageCounter;
   47645             :    }
   47646             : 
   47647             : /* #line 47648 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   47648             : 
   47649             : 
   47650             : 
   47651             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   47652             : 
   47653             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   47654             : 
   47655             : //############################################################################
   47656             : /* JH (02/02/2006) Constructor of the IR node SgOmpSeqCstClause that takes its 
   47657             :  * corresponding StorageClass as parameter
   47658             :  */
   47659           0 : SgOmpSeqCstClause :: SgOmpSeqCstClause ( const SgOmpSeqCstClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   47660             :    {
   47661             : 
   47662             : 
   47663             : /* #line 47664 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   47664             : 
   47665           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   47666             : 
   47667             : 
   47668             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   47669             : 
   47670             : 
   47671           0 :    }
   47672             : 
   47673             : //############################################################################
   47674             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   47675             :  * within the working AST. 
   47676             :  */
   47677           0 : SgOmpSeqCstClause * SgOmpSeqCstClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   47678           0 :      SgOmpSeqCstClause* returnPointer = NULL;
   47679           0 :      if ( globalIndex != 0 )
   47680             :         {
   47681             : 
   47682             : #if FILE_IO_EXTRA_CHECK
   47683           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSeqCstClause ) ) <= globalIndex ) ;
   47684           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSeqCstClause + 1 ) ) );
   47685             : #endif
   47686           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSeqCstClause )  
   47687           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSeqCstClause );
   47688           0 :           unsigned long positionInPool = localIndex % SgOmpSeqCstClause::pool_size;
   47689           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSeqCstClause::pool_size;
   47690             : 
   47691             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   47692             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   47693             : 
   47694           0 :           returnPointer = &( ( (SgOmpSeqCstClause*)(SgOmpSeqCstClause::pools[memoryBlock]) ) [positionInPool]) ;
   47695             : 
   47696           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   47697             :         }
   47698           0 :      return returnPointer ;
   47699             :    }
   47700             : 
   47701             : //############################################################################
   47702             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   47703             :   for the AST with the index astIndex
   47704             : */
   47705           0 : SgOmpSeqCstClause * SgOmpSeqCstClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   47706           0 :      SgOmpSeqCstClause* returnPointer = NULL;
   47707           0 :      if ( globalIndex != 0 )
   47708             :         {
   47709             : 
   47710             : #if FILE_IO_EXTRA_CHECK
   47711           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSeqCstClause ) ) <= globalIndex ) ;
   47712           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSeqCstClause + 1 ) ) );
   47713             : #endif
   47714           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSeqCstClause )
   47715           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSeqCstClause );
   47716           0 :           unsigned long positionInPool = localIndex % SgOmpSeqCstClause::pool_size ;
   47717           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSeqCstClause::pool_size ;
   47718             : 
   47719             : #if FILE_IO_EXTRA_CHECK
   47720             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   47721             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   47722             : #endif
   47723             : 
   47724           0 :           returnPointer = &( ( (SgOmpSeqCstClause*)(SgOmpSeqCstClause::pools[memoryBlock]) ) [positionInPool]) ;
   47725             : 
   47726             : #if FILE_IO_EXTRA_CHECK
   47727           0 :           assert ( returnPointer != NULL ) ;
   47728             : #endif
   47729             :         }
   47730           0 :      return returnPointer ;
   47731             :    }
   47732             : 
   47733             : //############################################################################
   47734             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   47735             :  * pool size! We set for every valid object in the memory pool the freepointer
   47736             :  * to the global index and increase the global index afterwards. For all the 
   47737             :  * invalid objects (means address ranges within the memory pool that were not
   47738             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   47739             :  * distinguish valid from invalid objects! 
   47740             :  */
   47741             : unsigned long
   47742           5 : SgOmpSeqCstClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   47743             :    {
   47744           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   47745           5 :      SgOmpSeqCstClause* pointer = NULL;
   47746           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   47747           5 :      std::vector < unsigned char* > :: const_iterator block;
   47748           5 :      for ( block = SgOmpSeqCstClause::pools.begin(); block != SgOmpSeqCstClause::pools.end() ; ++block )
   47749             :         {
   47750           0 :           pointer = (SgOmpSeqCstClause*)(*block);
   47751           0 :           for (unsigned i = 0; i < SgOmpSeqCstClause::pool_size; ++i )
   47752             :              {
   47753             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   47754             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   47755             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   47756             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   47757             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   47758             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   47759             :             // properly; so this will have to be checked next.
   47760             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   47761             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   47762           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   47763             :                   {
   47764           0 :                     pointer[i].set_freepointer((SgOmpSeqCstClause*)(globalIndex));
   47765           0 :                     globalIndex++;
   47766             :                   }
   47767             :                else
   47768             :                   {
   47769           0 :                     pointer[i].set_freepointer(NULL);
   47770             :                   }
   47771             :               }
   47772             :         }
   47773           5 :      return globalIndex;
   47774             :    }
   47775             : 
   47776             : //############################################################################
   47777             : // JH (01/14/2006)
   47778             : void
   47779           5 : SgOmpSeqCstClause::resetValidFreepointers( )
   47780             :    {
   47781           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   47782           5 :      SgOmpSeqCstClause* pointer = NULL;
   47783           5 :      std::vector < unsigned char* > :: const_iterator block;
   47784           5 :      SgOmpSeqCstClause* pointerOfLinkedList = NULL;
   47785           5 :      for ( block = SgOmpSeqCstClause::pools.begin(); block != SgOmpSeqCstClause::pools.end() ; ++block )
   47786             :         {
   47787           0 :           pointer = (SgOmpSeqCstClause*)(*block);
   47788           0 :           for (unsigned i = 0; i < SgOmpSeqCstClause::pool_size; ++i )
   47789             :              {
   47790             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   47791             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   47792             :             // memory blocks!.
   47793           0 :                if ( pointer[i].get_freepointer() != NULL )
   47794             :                   {
   47795           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   47796             :                   }
   47797             :                else
   47798             :                   {
   47799           0 :                     if ( pointerOfLinkedList == NULL )
   47800             :                        {
   47801           0 :                          SgOmpSeqCstClause::next_node = &(pointer[i]);
   47802             :                        }
   47803             :                     else
   47804             :                        {
   47805             :                       // printf ("In SgOmpSeqCstClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   47806           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   47807             :                        }
   47808             :                     pointerOfLinkedList = &(pointer[i]);
   47809             :                   }
   47810             :               }
   47811             :         }
   47812             : 
   47813           5 :      if ( pointerOfLinkedList != NULL )
   47814             :         {
   47815             :        // printf ("In SgOmpSeqCstClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   47816           0 :           pointerOfLinkedList->set_freepointer(NULL);
   47817             :        // DQ (6/6/2010): Temporary debugging...
   47818             :        //   ROSE_ASSERT(false);
   47819             :         }
   47820             : 
   47821           5 :      return ;
   47822             :    }
   47823             : 
   47824             : //############################################################################
   47825             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   47826             :  * within the memory pool and resets the freepointers, in order to achieve a 
   47827             :  * linked list, that has no jumps and starts at the beginning! This function 
   47828             :  * does not extend the memory pool, since we do not delete any memory blocks,
   47829             :  * but delete the valid objects.  
   47830             :  */
   47831             : void
   47832           0 : SgOmpSeqCstClause::clearMemoryPool( )
   47833             :    {
   47834             :   // printf ("Inside of SgOmpSeqCstClause::clearMemoryPool() \n");
   47835             : 
   47836           0 :      SgOmpSeqCstClause* pointer = NULL, *tempPointer = NULL;
   47837           0 :      std::vector < unsigned char* > :: const_iterator block;
   47838           0 :      if ( SgOmpSeqCstClause::pools.empty() == false )
   47839             :         {
   47840           0 :           block = SgOmpSeqCstClause::pools.begin() ;
   47841           0 :           SgOmpSeqCstClause::next_node = (SgOmpSeqCstClause*) (*block);
   47842             : 
   47843           0 :           while ( block != SgOmpSeqCstClause::pools.end() )
   47844             :              {
   47845           0 :                pointer = (SgOmpSeqCstClause*) (*block);
   47846           0 :                if ( tempPointer != NULL )
   47847             :                   {
   47848           0 :                     tempPointer->set_freepointer(pointer);
   47849             :                   }
   47850           0 :                for (unsigned i = 0; i < SgOmpSeqCstClause::pool_size - 1; ++i)
   47851             :                   {
   47852           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   47853             :                   }
   47854           0 :                 pointer[SgOmpSeqCstClause::pool_size-1].set_freepointer(NULL);
   47855           0 :                 tempPointer = &(pointer[SgOmpSeqCstClause::pool_size-1]);
   47856           0 :                 ++block;
   47857             :              }
   47858             :         }
   47859           0 :    }
   47860             : 
   47861           5 : void SgOmpSeqCstClause::deleteMemoryPool() {
   47862           5 :   for (auto p: SgOmpSeqCstClause::pools) {
   47863           0 :     ROSE_FREE(p);
   47864             :   }
   47865           5 :   SgOmpSeqCstClause::next_node = nullptr;
   47866           5 :   SgOmpSeqCstClause::pools.clear();
   47867           5 : }
   47868             : 
   47869             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   47870             : //                 reading multiple binary files to for a single AST.
   47871             : /////////// new version ////////////////////////////////
   47872             : //############################################################################
   47873             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   47874             : void
   47875           2 : SgOmpSeqCstClause::extendMemoryPoolForFileIO( )
   47876             :   {
   47877           2 :     size_t blockIndex = SgOmpSeqCstClause::pools.size();
   47878           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSeqCstClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSeqCstClause);
   47879             : 
   47880           2 :     while ( (blockIndex * SgOmpSeqCstClause::pool_size) < newPoolSize)
   47881             :       {
   47882             : #if ROSE_ALLOC_TRACE
   47883             :         if (blockIndex > 0) {
   47884             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSeqCstClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSeqCstClause) = %" PRIuPTR " SgOmpSeqCstClause::pool_size = %d \n",
   47885             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSeqCstClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSeqCstClause),SgOmpSeqCstClause::pool_size);
   47886             :         }
   47887             : #endif
   47888             : 
   47889           0 :         SgOmpSeqCstClause * pointer = (SgOmpSeqCstClause*) ROSE_MALLOC ( SgOmpSeqCstClause::pool_size * sizeof(SgOmpSeqCstClause) );
   47890           0 :         assert( pointer != NULL );
   47891             : #if ROSE_ALLOC_MEMSET == 1
   47892             :         memset(pointer, 0x00, SgOmpSeqCstClause::pool_size * sizeof(SgOmpSeqCstClause));
   47893             : #elif ROSE_ALLOC_MEMSET == 2
   47894             :         memset(pointer, 0xCC, SgOmpSeqCstClause::pool_size * sizeof(SgOmpSeqCstClause));
   47895             : #endif
   47896           0 :         SgOmpSeqCstClause::pools.push_back( (unsigned char*)(pointer) );
   47897           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSeqCstClause::pool_size * sizeof(SgOmpSeqCstClause), V_SgOmpSeqCstClause ) );
   47898             : 
   47899           0 :         if ( SgOmpSeqCstClause::next_node != NULL ) {
   47900           0 :           if ( blockIndex > 0 ) {
   47901           0 :             SgOmpSeqCstClause * blkptr = (SgOmpSeqCstClause*)(SgOmpSeqCstClause::pools[blockIndex-1]);
   47902           0 :             blkptr[ SgOmpSeqCstClause::pool_size - 1 ].set_freepointer(pointer);
   47903             :           }
   47904             :         } else {
   47905           0 :           SgOmpSeqCstClause::next_node = pointer;
   47906             :         }
   47907             : 
   47908           0 :         for (unsigned i = 0; i < SgOmpSeqCstClause::pool_size-1; ++i)
   47909             :            {
   47910           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   47911             :            }
   47912           0 :         pointer[ SgOmpSeqCstClause::pool_size -1 ].set_freepointer(NULL);
   47913             : 
   47914           0 :         blockIndex++;
   47915             :       }
   47916           2 :   }
   47917             : 
   47918             : //############################################################################
   47919             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   47920             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   47921             :  * not compressed. However, that stuff is not yet implemented! 
   47922             :  */
   47923             : unsigned long
   47924           0 : SgOmpSeqCstClause::getNumberOfLastValidPointer()
   47925             :    {
   47926           0 :       SgOmpSeqCstClause* testPointer = (SgOmpSeqCstClause*)(SgOmpSeqCstClause::pools.back());
   47927           0 :       unsigned long localIndex = SgOmpSeqCstClause::pool_size - 1;
   47928           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   47929             :          {
   47930           0 :            localIndex--;
   47931             :          }
   47932           0 :       return (localIndex + SgOmpSeqCstClause::pool_size * (SgOmpSeqCstClause::pools.size()-1));
   47933             :    }
   47934             : 
   47935             : //############################################################################
   47936             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   47937             :  * memory pool and initializes the data member in class SgOmpSeqCstClauseStroageClass
   47938             :  * from its counterpart of SgOmpSeqCstClause. The return value is just for checking, 
   47939             :  * that the whole StorageClassArray is initialized!
   47940             :  */
   47941             : unsigned long
   47942           0 : SgOmpSeqCstClause::initializeStorageClassArray( SgOmpSeqCstClauseStorageClass *storageArray )
   47943             :    {
   47944           0 :      unsigned long storageCounter = 0;
   47945           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSeqCstClause::pools.begin();
   47946           0 :      SgOmpSeqCstClause* pointer = NULL;
   47947           0 :      while ( block != SgOmpSeqCstClause::pools.end() ) {
   47948           0 :           pointer = (SgOmpSeqCstClause*) (*block);
   47949           0 :           for ( unsigned i = 0; i < SgOmpSeqCstClause::pool_size; ++i ) {
   47950           0 :                if ( pointer->get_freepointer() != NULL ) {
   47951           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   47952           0 :                  storageArray++;
   47953           0 :                  storageCounter++;
   47954             :                }
   47955           0 :                pointer++;
   47956             :              }
   47957           0 :            block++;
   47958             :         }
   47959           0 :      return storageCounter;
   47960             :    }
   47961             : 
   47962             : /* #line 47963 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   47963             : 
   47964             : 
   47965             : 
   47966             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   47967             : 
   47968             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   47969             : 
   47970             : //############################################################################
   47971             : /* JH (02/02/2006) Constructor of the IR node SgOmpAcqRelClause that takes its 
   47972             :  * corresponding StorageClass as parameter
   47973             :  */
   47974           0 : SgOmpAcqRelClause :: SgOmpAcqRelClause ( const SgOmpAcqRelClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   47975             :    {
   47976             : 
   47977             : 
   47978             : /* #line 47979 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   47979             : 
   47980           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   47981             : 
   47982             : 
   47983             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   47984             : 
   47985             : 
   47986           0 :    }
   47987             : 
   47988             : //############################################################################
   47989             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   47990             :  * within the working AST. 
   47991             :  */
   47992           0 : SgOmpAcqRelClause * SgOmpAcqRelClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   47993           0 :      SgOmpAcqRelClause* returnPointer = NULL;
   47994           0 :      if ( globalIndex != 0 )
   47995             :         {
   47996             : 
   47997             : #if FILE_IO_EXTRA_CHECK
   47998           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAcqRelClause ) ) <= globalIndex ) ;
   47999           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAcqRelClause + 1 ) ) );
   48000             : #endif
   48001           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAcqRelClause )  
   48002           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAcqRelClause );
   48003           0 :           unsigned long positionInPool = localIndex % SgOmpAcqRelClause::pool_size;
   48004           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAcqRelClause::pool_size;
   48005             : 
   48006             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   48007             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   48008             : 
   48009           0 :           returnPointer = &( ( (SgOmpAcqRelClause*)(SgOmpAcqRelClause::pools[memoryBlock]) ) [positionInPool]) ;
   48010             : 
   48011           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   48012             :         }
   48013           0 :      return returnPointer ;
   48014             :    }
   48015             : 
   48016             : //############################################################################
   48017             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   48018             :   for the AST with the index astIndex
   48019             : */
   48020           0 : SgOmpAcqRelClause * SgOmpAcqRelClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   48021           0 :      SgOmpAcqRelClause* returnPointer = NULL;
   48022           0 :      if ( globalIndex != 0 )
   48023             :         {
   48024             : 
   48025             : #if FILE_IO_EXTRA_CHECK
   48026           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAcqRelClause ) ) <= globalIndex ) ;
   48027           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAcqRelClause + 1 ) ) );
   48028             : #endif
   48029           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAcqRelClause )
   48030           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAcqRelClause );
   48031           0 :           unsigned long positionInPool = localIndex % SgOmpAcqRelClause::pool_size ;
   48032           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAcqRelClause::pool_size ;
   48033             : 
   48034             : #if FILE_IO_EXTRA_CHECK
   48035             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   48036             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   48037             : #endif
   48038             : 
   48039           0 :           returnPointer = &( ( (SgOmpAcqRelClause*)(SgOmpAcqRelClause::pools[memoryBlock]) ) [positionInPool]) ;
   48040             : 
   48041             : #if FILE_IO_EXTRA_CHECK
   48042           0 :           assert ( returnPointer != NULL ) ;
   48043             : #endif
   48044             :         }
   48045           0 :      return returnPointer ;
   48046             :    }
   48047             : 
   48048             : //############################################################################
   48049             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   48050             :  * pool size! We set for every valid object in the memory pool the freepointer
   48051             :  * to the global index and increase the global index afterwards. For all the 
   48052             :  * invalid objects (means address ranges within the memory pool that were not
   48053             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   48054             :  * distinguish valid from invalid objects! 
   48055             :  */
   48056             : unsigned long
   48057           5 : SgOmpAcqRelClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   48058             :    {
   48059           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   48060           5 :      SgOmpAcqRelClause* pointer = NULL;
   48061           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   48062           5 :      std::vector < unsigned char* > :: const_iterator block;
   48063           5 :      for ( block = SgOmpAcqRelClause::pools.begin(); block != SgOmpAcqRelClause::pools.end() ; ++block )
   48064             :         {
   48065           0 :           pointer = (SgOmpAcqRelClause*)(*block);
   48066           0 :           for (unsigned i = 0; i < SgOmpAcqRelClause::pool_size; ++i )
   48067             :              {
   48068             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   48069             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   48070             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   48071             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   48072             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   48073             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   48074             :             // properly; so this will have to be checked next.
   48075             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   48076             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   48077           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   48078             :                   {
   48079           0 :                     pointer[i].set_freepointer((SgOmpAcqRelClause*)(globalIndex));
   48080           0 :                     globalIndex++;
   48081             :                   }
   48082             :                else
   48083             :                   {
   48084           0 :                     pointer[i].set_freepointer(NULL);
   48085             :                   }
   48086             :               }
   48087             :         }
   48088           5 :      return globalIndex;
   48089             :    }
   48090             : 
   48091             : //############################################################################
   48092             : // JH (01/14/2006)
   48093             : void
   48094           5 : SgOmpAcqRelClause::resetValidFreepointers( )
   48095             :    {
   48096           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   48097           5 :      SgOmpAcqRelClause* pointer = NULL;
   48098           5 :      std::vector < unsigned char* > :: const_iterator block;
   48099           5 :      SgOmpAcqRelClause* pointerOfLinkedList = NULL;
   48100           5 :      for ( block = SgOmpAcqRelClause::pools.begin(); block != SgOmpAcqRelClause::pools.end() ; ++block )
   48101             :         {
   48102           0 :           pointer = (SgOmpAcqRelClause*)(*block);
   48103           0 :           for (unsigned i = 0; i < SgOmpAcqRelClause::pool_size; ++i )
   48104             :              {
   48105             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   48106             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   48107             :             // memory blocks!.
   48108           0 :                if ( pointer[i].get_freepointer() != NULL )
   48109             :                   {
   48110           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   48111             :                   }
   48112             :                else
   48113             :                   {
   48114           0 :                     if ( pointerOfLinkedList == NULL )
   48115             :                        {
   48116           0 :                          SgOmpAcqRelClause::next_node = &(pointer[i]);
   48117             :                        }
   48118             :                     else
   48119             :                        {
   48120             :                       // printf ("In SgOmpAcqRelClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   48121           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   48122             :                        }
   48123             :                     pointerOfLinkedList = &(pointer[i]);
   48124             :                   }
   48125             :               }
   48126             :         }
   48127             : 
   48128           5 :      if ( pointerOfLinkedList != NULL )
   48129             :         {
   48130             :        // printf ("In SgOmpAcqRelClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   48131           0 :           pointerOfLinkedList->set_freepointer(NULL);
   48132             :        // DQ (6/6/2010): Temporary debugging...
   48133             :        //   ROSE_ASSERT(false);
   48134             :         }
   48135             : 
   48136           5 :      return ;
   48137             :    }
   48138             : 
   48139             : //############################################################################
   48140             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   48141             :  * within the memory pool and resets the freepointers, in order to achieve a 
   48142             :  * linked list, that has no jumps and starts at the beginning! This function 
   48143             :  * does not extend the memory pool, since we do not delete any memory blocks,
   48144             :  * but delete the valid objects.  
   48145             :  */
   48146             : void
   48147           0 : SgOmpAcqRelClause::clearMemoryPool( )
   48148             :    {
   48149             :   // printf ("Inside of SgOmpAcqRelClause::clearMemoryPool() \n");
   48150             : 
   48151           0 :      SgOmpAcqRelClause* pointer = NULL, *tempPointer = NULL;
   48152           0 :      std::vector < unsigned char* > :: const_iterator block;
   48153           0 :      if ( SgOmpAcqRelClause::pools.empty() == false )
   48154             :         {
   48155           0 :           block = SgOmpAcqRelClause::pools.begin() ;
   48156           0 :           SgOmpAcqRelClause::next_node = (SgOmpAcqRelClause*) (*block);
   48157             : 
   48158           0 :           while ( block != SgOmpAcqRelClause::pools.end() )
   48159             :              {
   48160           0 :                pointer = (SgOmpAcqRelClause*) (*block);
   48161           0 :                if ( tempPointer != NULL )
   48162             :                   {
   48163           0 :                     tempPointer->set_freepointer(pointer);
   48164             :                   }
   48165           0 :                for (unsigned i = 0; i < SgOmpAcqRelClause::pool_size - 1; ++i)
   48166             :                   {
   48167           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   48168             :                   }
   48169           0 :                 pointer[SgOmpAcqRelClause::pool_size-1].set_freepointer(NULL);
   48170           0 :                 tempPointer = &(pointer[SgOmpAcqRelClause::pool_size-1]);
   48171           0 :                 ++block;
   48172             :              }
   48173             :         }
   48174           0 :    }
   48175             : 
   48176           5 : void SgOmpAcqRelClause::deleteMemoryPool() {
   48177           5 :   for (auto p: SgOmpAcqRelClause::pools) {
   48178           0 :     ROSE_FREE(p);
   48179             :   }
   48180           5 :   SgOmpAcqRelClause::next_node = nullptr;
   48181           5 :   SgOmpAcqRelClause::pools.clear();
   48182           5 : }
   48183             : 
   48184             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   48185             : //                 reading multiple binary files to for a single AST.
   48186             : /////////// new version ////////////////////////////////
   48187             : //############################################################################
   48188             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   48189             : void
   48190           2 : SgOmpAcqRelClause::extendMemoryPoolForFileIO( )
   48191             :   {
   48192           2 :     size_t blockIndex = SgOmpAcqRelClause::pools.size();
   48193           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAcqRelClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAcqRelClause);
   48194             : 
   48195           2 :     while ( (blockIndex * SgOmpAcqRelClause::pool_size) < newPoolSize)
   48196             :       {
   48197             : #if ROSE_ALLOC_TRACE
   48198             :         if (blockIndex > 0) {
   48199             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAcqRelClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAcqRelClause) = %" PRIuPTR " SgOmpAcqRelClause::pool_size = %d \n",
   48200             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAcqRelClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAcqRelClause),SgOmpAcqRelClause::pool_size);
   48201             :         }
   48202             : #endif
   48203             : 
   48204           0 :         SgOmpAcqRelClause * pointer = (SgOmpAcqRelClause*) ROSE_MALLOC ( SgOmpAcqRelClause::pool_size * sizeof(SgOmpAcqRelClause) );
   48205           0 :         assert( pointer != NULL );
   48206             : #if ROSE_ALLOC_MEMSET == 1
   48207             :         memset(pointer, 0x00, SgOmpAcqRelClause::pool_size * sizeof(SgOmpAcqRelClause));
   48208             : #elif ROSE_ALLOC_MEMSET == 2
   48209             :         memset(pointer, 0xCC, SgOmpAcqRelClause::pool_size * sizeof(SgOmpAcqRelClause));
   48210             : #endif
   48211           0 :         SgOmpAcqRelClause::pools.push_back( (unsigned char*)(pointer) );
   48212           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAcqRelClause::pool_size * sizeof(SgOmpAcqRelClause), V_SgOmpAcqRelClause ) );
   48213             : 
   48214           0 :         if ( SgOmpAcqRelClause::next_node != NULL ) {
   48215           0 :           if ( blockIndex > 0 ) {
   48216           0 :             SgOmpAcqRelClause * blkptr = (SgOmpAcqRelClause*)(SgOmpAcqRelClause::pools[blockIndex-1]);
   48217           0 :             blkptr[ SgOmpAcqRelClause::pool_size - 1 ].set_freepointer(pointer);
   48218             :           }
   48219             :         } else {
   48220           0 :           SgOmpAcqRelClause::next_node = pointer;
   48221             :         }
   48222             : 
   48223           0 :         for (unsigned i = 0; i < SgOmpAcqRelClause::pool_size-1; ++i)
   48224             :            {
   48225           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   48226             :            }
   48227           0 :         pointer[ SgOmpAcqRelClause::pool_size -1 ].set_freepointer(NULL);
   48228             : 
   48229           0 :         blockIndex++;
   48230             :       }
   48231           2 :   }
   48232             : 
   48233             : //############################################################################
   48234             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   48235             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   48236             :  * not compressed. However, that stuff is not yet implemented! 
   48237             :  */
   48238             : unsigned long
   48239           0 : SgOmpAcqRelClause::getNumberOfLastValidPointer()
   48240             :    {
   48241           0 :       SgOmpAcqRelClause* testPointer = (SgOmpAcqRelClause*)(SgOmpAcqRelClause::pools.back());
   48242           0 :       unsigned long localIndex = SgOmpAcqRelClause::pool_size - 1;
   48243           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   48244             :          {
   48245           0 :            localIndex--;
   48246             :          }
   48247           0 :       return (localIndex + SgOmpAcqRelClause::pool_size * (SgOmpAcqRelClause::pools.size()-1));
   48248             :    }
   48249             : 
   48250             : //############################################################################
   48251             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   48252             :  * memory pool and initializes the data member in class SgOmpAcqRelClauseStroageClass
   48253             :  * from its counterpart of SgOmpAcqRelClause. The return value is just for checking, 
   48254             :  * that the whole StorageClassArray is initialized!
   48255             :  */
   48256             : unsigned long
   48257           0 : SgOmpAcqRelClause::initializeStorageClassArray( SgOmpAcqRelClauseStorageClass *storageArray )
   48258             :    {
   48259           0 :      unsigned long storageCounter = 0;
   48260           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAcqRelClause::pools.begin();
   48261           0 :      SgOmpAcqRelClause* pointer = NULL;
   48262           0 :      while ( block != SgOmpAcqRelClause::pools.end() ) {
   48263           0 :           pointer = (SgOmpAcqRelClause*) (*block);
   48264           0 :           for ( unsigned i = 0; i < SgOmpAcqRelClause::pool_size; ++i ) {
   48265           0 :                if ( pointer->get_freepointer() != NULL ) {
   48266           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   48267           0 :                  storageArray++;
   48268           0 :                  storageCounter++;
   48269             :                }
   48270           0 :                pointer++;
   48271             :              }
   48272           0 :            block++;
   48273             :         }
   48274           0 :      return storageCounter;
   48275             :    }
   48276             : 
   48277             : /* #line 48278 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   48278             : 
   48279             : 
   48280             : 
   48281             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   48282             : 
   48283             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   48284             : 
   48285             : //############################################################################
   48286             : /* JH (02/02/2006) Constructor of the IR node SgOmpReleaseClause that takes its 
   48287             :  * corresponding StorageClass as parameter
   48288             :  */
   48289           0 : SgOmpReleaseClause :: SgOmpReleaseClause ( const SgOmpReleaseClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   48290             :    {
   48291             : 
   48292             : 
   48293             : /* #line 48294 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   48294             : 
   48295           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   48296             : 
   48297             : 
   48298             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   48299             : 
   48300             : 
   48301           0 :    }
   48302             : 
   48303             : //############################################################################
   48304             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   48305             :  * within the working AST. 
   48306             :  */
   48307           0 : SgOmpReleaseClause * SgOmpReleaseClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   48308           0 :      SgOmpReleaseClause* returnPointer = NULL;
   48309           0 :      if ( globalIndex != 0 )
   48310             :         {
   48311             : 
   48312             : #if FILE_IO_EXTRA_CHECK
   48313           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpReleaseClause ) ) <= globalIndex ) ;
   48314           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpReleaseClause + 1 ) ) );
   48315             : #endif
   48316           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpReleaseClause )  
   48317           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpReleaseClause );
   48318           0 :           unsigned long positionInPool = localIndex % SgOmpReleaseClause::pool_size;
   48319           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpReleaseClause::pool_size;
   48320             : 
   48321             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   48322             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   48323             : 
   48324           0 :           returnPointer = &( ( (SgOmpReleaseClause*)(SgOmpReleaseClause::pools[memoryBlock]) ) [positionInPool]) ;
   48325             : 
   48326           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   48327             :         }
   48328           0 :      return returnPointer ;
   48329             :    }
   48330             : 
   48331             : //############################################################################
   48332             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   48333             :   for the AST with the index astIndex
   48334             : */
   48335           0 : SgOmpReleaseClause * SgOmpReleaseClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   48336           0 :      SgOmpReleaseClause* returnPointer = NULL;
   48337           0 :      if ( globalIndex != 0 )
   48338             :         {
   48339             : 
   48340             : #if FILE_IO_EXTRA_CHECK
   48341           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpReleaseClause ) ) <= globalIndex ) ;
   48342           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpReleaseClause + 1 ) ) );
   48343             : #endif
   48344           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpReleaseClause )
   48345           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpReleaseClause );
   48346           0 :           unsigned long positionInPool = localIndex % SgOmpReleaseClause::pool_size ;
   48347           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpReleaseClause::pool_size ;
   48348             : 
   48349             : #if FILE_IO_EXTRA_CHECK
   48350             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   48351             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   48352             : #endif
   48353             : 
   48354           0 :           returnPointer = &( ( (SgOmpReleaseClause*)(SgOmpReleaseClause::pools[memoryBlock]) ) [positionInPool]) ;
   48355             : 
   48356             : #if FILE_IO_EXTRA_CHECK
   48357           0 :           assert ( returnPointer != NULL ) ;
   48358             : #endif
   48359             :         }
   48360           0 :      return returnPointer ;
   48361             :    }
   48362             : 
   48363             : //############################################################################
   48364             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   48365             :  * pool size! We set for every valid object in the memory pool the freepointer
   48366             :  * to the global index and increase the global index afterwards. For all the 
   48367             :  * invalid objects (means address ranges within the memory pool that were not
   48368             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   48369             :  * distinguish valid from invalid objects! 
   48370             :  */
   48371             : unsigned long
   48372           5 : SgOmpReleaseClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   48373             :    {
   48374           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   48375           5 :      SgOmpReleaseClause* pointer = NULL;
   48376           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   48377           5 :      std::vector < unsigned char* > :: const_iterator block;
   48378           5 :      for ( block = SgOmpReleaseClause::pools.begin(); block != SgOmpReleaseClause::pools.end() ; ++block )
   48379             :         {
   48380           0 :           pointer = (SgOmpReleaseClause*)(*block);
   48381           0 :           for (unsigned i = 0; i < SgOmpReleaseClause::pool_size; ++i )
   48382             :              {
   48383             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   48384             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   48385             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   48386             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   48387             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   48388             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   48389             :             // properly; so this will have to be checked next.
   48390             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   48391             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   48392           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   48393             :                   {
   48394           0 :                     pointer[i].set_freepointer((SgOmpReleaseClause*)(globalIndex));
   48395           0 :                     globalIndex++;
   48396             :                   }
   48397             :                else
   48398             :                   {
   48399           0 :                     pointer[i].set_freepointer(NULL);
   48400             :                   }
   48401             :               }
   48402             :         }
   48403           5 :      return globalIndex;
   48404             :    }
   48405             : 
   48406             : //############################################################################
   48407             : // JH (01/14/2006)
   48408             : void
   48409           5 : SgOmpReleaseClause::resetValidFreepointers( )
   48410             :    {
   48411           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   48412           5 :      SgOmpReleaseClause* pointer = NULL;
   48413           5 :      std::vector < unsigned char* > :: const_iterator block;
   48414           5 :      SgOmpReleaseClause* pointerOfLinkedList = NULL;
   48415           5 :      for ( block = SgOmpReleaseClause::pools.begin(); block != SgOmpReleaseClause::pools.end() ; ++block )
   48416             :         {
   48417           0 :           pointer = (SgOmpReleaseClause*)(*block);
   48418           0 :           for (unsigned i = 0; i < SgOmpReleaseClause::pool_size; ++i )
   48419             :              {
   48420             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   48421             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   48422             :             // memory blocks!.
   48423           0 :                if ( pointer[i].get_freepointer() != NULL )
   48424             :                   {
   48425           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   48426             :                   }
   48427             :                else
   48428             :                   {
   48429           0 :                     if ( pointerOfLinkedList == NULL )
   48430             :                        {
   48431           0 :                          SgOmpReleaseClause::next_node = &(pointer[i]);
   48432             :                        }
   48433             :                     else
   48434             :                        {
   48435             :                       // printf ("In SgOmpReleaseClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   48436           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   48437             :                        }
   48438             :                     pointerOfLinkedList = &(pointer[i]);
   48439             :                   }
   48440             :               }
   48441             :         }
   48442             : 
   48443           5 :      if ( pointerOfLinkedList != NULL )
   48444             :         {
   48445             :        // printf ("In SgOmpReleaseClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   48446           0 :           pointerOfLinkedList->set_freepointer(NULL);
   48447             :        // DQ (6/6/2010): Temporary debugging...
   48448             :        //   ROSE_ASSERT(false);
   48449             :         }
   48450             : 
   48451           5 :      return ;
   48452             :    }
   48453             : 
   48454             : //############################################################################
   48455             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   48456             :  * within the memory pool and resets the freepointers, in order to achieve a 
   48457             :  * linked list, that has no jumps and starts at the beginning! This function 
   48458             :  * does not extend the memory pool, since we do not delete any memory blocks,
   48459             :  * but delete the valid objects.  
   48460             :  */
   48461             : void
   48462           0 : SgOmpReleaseClause::clearMemoryPool( )
   48463             :    {
   48464             :   // printf ("Inside of SgOmpReleaseClause::clearMemoryPool() \n");
   48465             : 
   48466           0 :      SgOmpReleaseClause* pointer = NULL, *tempPointer = NULL;
   48467           0 :      std::vector < unsigned char* > :: const_iterator block;
   48468           0 :      if ( SgOmpReleaseClause::pools.empty() == false )
   48469             :         {
   48470           0 :           block = SgOmpReleaseClause::pools.begin() ;
   48471           0 :           SgOmpReleaseClause::next_node = (SgOmpReleaseClause*) (*block);
   48472             : 
   48473           0 :           while ( block != SgOmpReleaseClause::pools.end() )
   48474             :              {
   48475           0 :                pointer = (SgOmpReleaseClause*) (*block);
   48476           0 :                if ( tempPointer != NULL )
   48477             :                   {
   48478           0 :                     tempPointer->set_freepointer(pointer);
   48479             :                   }
   48480           0 :                for (unsigned i = 0; i < SgOmpReleaseClause::pool_size - 1; ++i)
   48481             :                   {
   48482           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   48483             :                   }
   48484           0 :                 pointer[SgOmpReleaseClause::pool_size-1].set_freepointer(NULL);
   48485           0 :                 tempPointer = &(pointer[SgOmpReleaseClause::pool_size-1]);
   48486           0 :                 ++block;
   48487             :              }
   48488             :         }
   48489           0 :    }
   48490             : 
   48491           5 : void SgOmpReleaseClause::deleteMemoryPool() {
   48492           5 :   for (auto p: SgOmpReleaseClause::pools) {
   48493           0 :     ROSE_FREE(p);
   48494             :   }
   48495           5 :   SgOmpReleaseClause::next_node = nullptr;
   48496           5 :   SgOmpReleaseClause::pools.clear();
   48497           5 : }
   48498             : 
   48499             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   48500             : //                 reading multiple binary files to for a single AST.
   48501             : /////////// new version ////////////////////////////////
   48502             : //############################################################################
   48503             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   48504             : void
   48505           2 : SgOmpReleaseClause::extendMemoryPoolForFileIO( )
   48506             :   {
   48507           2 :     size_t blockIndex = SgOmpReleaseClause::pools.size();
   48508           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReleaseClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReleaseClause);
   48509             : 
   48510           2 :     while ( (blockIndex * SgOmpReleaseClause::pool_size) < newPoolSize)
   48511             :       {
   48512             : #if ROSE_ALLOC_TRACE
   48513             :         if (blockIndex > 0) {
   48514             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReleaseClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReleaseClause) = %" PRIuPTR " SgOmpReleaseClause::pool_size = %d \n",
   48515             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReleaseClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReleaseClause),SgOmpReleaseClause::pool_size);
   48516             :         }
   48517             : #endif
   48518             : 
   48519           0 :         SgOmpReleaseClause * pointer = (SgOmpReleaseClause*) ROSE_MALLOC ( SgOmpReleaseClause::pool_size * sizeof(SgOmpReleaseClause) );
   48520           0 :         assert( pointer != NULL );
   48521             : #if ROSE_ALLOC_MEMSET == 1
   48522             :         memset(pointer, 0x00, SgOmpReleaseClause::pool_size * sizeof(SgOmpReleaseClause));
   48523             : #elif ROSE_ALLOC_MEMSET == 2
   48524             :         memset(pointer, 0xCC, SgOmpReleaseClause::pool_size * sizeof(SgOmpReleaseClause));
   48525             : #endif
   48526           0 :         SgOmpReleaseClause::pools.push_back( (unsigned char*)(pointer) );
   48527           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpReleaseClause::pool_size * sizeof(SgOmpReleaseClause), V_SgOmpReleaseClause ) );
   48528             : 
   48529           0 :         if ( SgOmpReleaseClause::next_node != NULL ) {
   48530           0 :           if ( blockIndex > 0 ) {
   48531           0 :             SgOmpReleaseClause * blkptr = (SgOmpReleaseClause*)(SgOmpReleaseClause::pools[blockIndex-1]);
   48532           0 :             blkptr[ SgOmpReleaseClause::pool_size - 1 ].set_freepointer(pointer);
   48533             :           }
   48534             :         } else {
   48535           0 :           SgOmpReleaseClause::next_node = pointer;
   48536             :         }
   48537             : 
   48538           0 :         for (unsigned i = 0; i < SgOmpReleaseClause::pool_size-1; ++i)
   48539             :            {
   48540           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   48541             :            }
   48542           0 :         pointer[ SgOmpReleaseClause::pool_size -1 ].set_freepointer(NULL);
   48543             : 
   48544           0 :         blockIndex++;
   48545             :       }
   48546           2 :   }
   48547             : 
   48548             : //############################################################################
   48549             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   48550             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   48551             :  * not compressed. However, that stuff is not yet implemented! 
   48552             :  */
   48553             : unsigned long
   48554           0 : SgOmpReleaseClause::getNumberOfLastValidPointer()
   48555             :    {
   48556           0 :       SgOmpReleaseClause* testPointer = (SgOmpReleaseClause*)(SgOmpReleaseClause::pools.back());
   48557           0 :       unsigned long localIndex = SgOmpReleaseClause::pool_size - 1;
   48558           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   48559             :          {
   48560           0 :            localIndex--;
   48561             :          }
   48562           0 :       return (localIndex + SgOmpReleaseClause::pool_size * (SgOmpReleaseClause::pools.size()-1));
   48563             :    }
   48564             : 
   48565             : //############################################################################
   48566             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   48567             :  * memory pool and initializes the data member in class SgOmpReleaseClauseStroageClass
   48568             :  * from its counterpart of SgOmpReleaseClause. The return value is just for checking, 
   48569             :  * that the whole StorageClassArray is initialized!
   48570             :  */
   48571             : unsigned long
   48572           0 : SgOmpReleaseClause::initializeStorageClassArray( SgOmpReleaseClauseStorageClass *storageArray )
   48573             :    {
   48574           0 :      unsigned long storageCounter = 0;
   48575           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpReleaseClause::pools.begin();
   48576           0 :      SgOmpReleaseClause* pointer = NULL;
   48577           0 :      while ( block != SgOmpReleaseClause::pools.end() ) {
   48578           0 :           pointer = (SgOmpReleaseClause*) (*block);
   48579           0 :           for ( unsigned i = 0; i < SgOmpReleaseClause::pool_size; ++i ) {
   48580           0 :                if ( pointer->get_freepointer() != NULL ) {
   48581           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   48582           0 :                  storageArray++;
   48583           0 :                  storageCounter++;
   48584             :                }
   48585           0 :                pointer++;
   48586             :              }
   48587           0 :            block++;
   48588             :         }
   48589           0 :      return storageCounter;
   48590             :    }
   48591             : 
   48592             : /* #line 48593 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   48593             : 
   48594             : 
   48595             : 
   48596             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   48597             : 
   48598             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   48599             : 
   48600             : //############################################################################
   48601             : /* JH (02/02/2006) Constructor of the IR node SgOmpAcquireClause that takes its 
   48602             :  * corresponding StorageClass as parameter
   48603             :  */
   48604           0 : SgOmpAcquireClause :: SgOmpAcquireClause ( const SgOmpAcquireClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   48605             :    {
   48606             : 
   48607             : 
   48608             : /* #line 48609 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   48609             : 
   48610           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   48611             : 
   48612             : 
   48613             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   48614             : 
   48615             : 
   48616           0 :    }
   48617             : 
   48618             : //############################################################################
   48619             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   48620             :  * within the working AST. 
   48621             :  */
   48622           0 : SgOmpAcquireClause * SgOmpAcquireClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   48623           0 :      SgOmpAcquireClause* returnPointer = NULL;
   48624           0 :      if ( globalIndex != 0 )
   48625             :         {
   48626             : 
   48627             : #if FILE_IO_EXTRA_CHECK
   48628           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAcquireClause ) ) <= globalIndex ) ;
   48629           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAcquireClause + 1 ) ) );
   48630             : #endif
   48631           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAcquireClause )  
   48632           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAcquireClause );
   48633           0 :           unsigned long positionInPool = localIndex % SgOmpAcquireClause::pool_size;
   48634           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAcquireClause::pool_size;
   48635             : 
   48636             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   48637             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   48638             : 
   48639           0 :           returnPointer = &( ( (SgOmpAcquireClause*)(SgOmpAcquireClause::pools[memoryBlock]) ) [positionInPool]) ;
   48640             : 
   48641           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   48642             :         }
   48643           0 :      return returnPointer ;
   48644             :    }
   48645             : 
   48646             : //############################################################################
   48647             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   48648             :   for the AST with the index astIndex
   48649             : */
   48650           0 : SgOmpAcquireClause * SgOmpAcquireClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   48651           0 :      SgOmpAcquireClause* returnPointer = NULL;
   48652           0 :      if ( globalIndex != 0 )
   48653             :         {
   48654             : 
   48655             : #if FILE_IO_EXTRA_CHECK
   48656           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAcquireClause ) ) <= globalIndex ) ;
   48657           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAcquireClause + 1 ) ) );
   48658             : #endif
   48659           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAcquireClause )
   48660           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAcquireClause );
   48661           0 :           unsigned long positionInPool = localIndex % SgOmpAcquireClause::pool_size ;
   48662           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAcquireClause::pool_size ;
   48663             : 
   48664             : #if FILE_IO_EXTRA_CHECK
   48665             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   48666             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   48667             : #endif
   48668             : 
   48669           0 :           returnPointer = &( ( (SgOmpAcquireClause*)(SgOmpAcquireClause::pools[memoryBlock]) ) [positionInPool]) ;
   48670             : 
   48671             : #if FILE_IO_EXTRA_CHECK
   48672           0 :           assert ( returnPointer != NULL ) ;
   48673             : #endif
   48674             :         }
   48675           0 :      return returnPointer ;
   48676             :    }
   48677             : 
   48678             : //############################################################################
   48679             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   48680             :  * pool size! We set for every valid object in the memory pool the freepointer
   48681             :  * to the global index and increase the global index afterwards. For all the 
   48682             :  * invalid objects (means address ranges within the memory pool that were not
   48683             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   48684             :  * distinguish valid from invalid objects! 
   48685             :  */
   48686             : unsigned long
   48687           5 : SgOmpAcquireClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   48688             :    {
   48689           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   48690           5 :      SgOmpAcquireClause* pointer = NULL;
   48691           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   48692           5 :      std::vector < unsigned char* > :: const_iterator block;
   48693           5 :      for ( block = SgOmpAcquireClause::pools.begin(); block != SgOmpAcquireClause::pools.end() ; ++block )
   48694             :         {
   48695           0 :           pointer = (SgOmpAcquireClause*)(*block);
   48696           0 :           for (unsigned i = 0; i < SgOmpAcquireClause::pool_size; ++i )
   48697             :              {
   48698             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   48699             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   48700             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   48701             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   48702             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   48703             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   48704             :             // properly; so this will have to be checked next.
   48705             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   48706             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   48707           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   48708             :                   {
   48709           0 :                     pointer[i].set_freepointer((SgOmpAcquireClause*)(globalIndex));
   48710           0 :                     globalIndex++;
   48711             :                   }
   48712             :                else
   48713             :                   {
   48714           0 :                     pointer[i].set_freepointer(NULL);
   48715             :                   }
   48716             :               }
   48717             :         }
   48718           5 :      return globalIndex;
   48719             :    }
   48720             : 
   48721             : //############################################################################
   48722             : // JH (01/14/2006)
   48723             : void
   48724           5 : SgOmpAcquireClause::resetValidFreepointers( )
   48725             :    {
   48726           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   48727           5 :      SgOmpAcquireClause* pointer = NULL;
   48728           5 :      std::vector < unsigned char* > :: const_iterator block;
   48729           5 :      SgOmpAcquireClause* pointerOfLinkedList = NULL;
   48730           5 :      for ( block = SgOmpAcquireClause::pools.begin(); block != SgOmpAcquireClause::pools.end() ; ++block )
   48731             :         {
   48732           0 :           pointer = (SgOmpAcquireClause*)(*block);
   48733           0 :           for (unsigned i = 0; i < SgOmpAcquireClause::pool_size; ++i )
   48734             :              {
   48735             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   48736             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   48737             :             // memory blocks!.
   48738           0 :                if ( pointer[i].get_freepointer() != NULL )
   48739             :                   {
   48740           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   48741             :                   }
   48742             :                else
   48743             :                   {
   48744           0 :                     if ( pointerOfLinkedList == NULL )
   48745             :                        {
   48746           0 :                          SgOmpAcquireClause::next_node = &(pointer[i]);
   48747             :                        }
   48748             :                     else
   48749             :                        {
   48750             :                       // printf ("In SgOmpAcquireClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   48751           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   48752             :                        }
   48753             :                     pointerOfLinkedList = &(pointer[i]);
   48754             :                   }
   48755             :               }
   48756             :         }
   48757             : 
   48758           5 :      if ( pointerOfLinkedList != NULL )
   48759             :         {
   48760             :        // printf ("In SgOmpAcquireClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   48761           0 :           pointerOfLinkedList->set_freepointer(NULL);
   48762             :        // DQ (6/6/2010): Temporary debugging...
   48763             :        //   ROSE_ASSERT(false);
   48764             :         }
   48765             : 
   48766           5 :      return ;
   48767             :    }
   48768             : 
   48769             : //############################################################################
   48770             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   48771             :  * within the memory pool and resets the freepointers, in order to achieve a 
   48772             :  * linked list, that has no jumps and starts at the beginning! This function 
   48773             :  * does not extend the memory pool, since we do not delete any memory blocks,
   48774             :  * but delete the valid objects.  
   48775             :  */
   48776             : void
   48777           0 : SgOmpAcquireClause::clearMemoryPool( )
   48778             :    {
   48779             :   // printf ("Inside of SgOmpAcquireClause::clearMemoryPool() \n");
   48780             : 
   48781           0 :      SgOmpAcquireClause* pointer = NULL, *tempPointer = NULL;
   48782           0 :      std::vector < unsigned char* > :: const_iterator block;
   48783           0 :      if ( SgOmpAcquireClause::pools.empty() == false )
   48784             :         {
   48785           0 :           block = SgOmpAcquireClause::pools.begin() ;
   48786           0 :           SgOmpAcquireClause::next_node = (SgOmpAcquireClause*) (*block);
   48787             : 
   48788           0 :           while ( block != SgOmpAcquireClause::pools.end() )
   48789             :              {
   48790           0 :                pointer = (SgOmpAcquireClause*) (*block);
   48791           0 :                if ( tempPointer != NULL )
   48792             :                   {
   48793           0 :                     tempPointer->set_freepointer(pointer);
   48794             :                   }
   48795           0 :                for (unsigned i = 0; i < SgOmpAcquireClause::pool_size - 1; ++i)
   48796             :                   {
   48797           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   48798             :                   }
   48799           0 :                 pointer[SgOmpAcquireClause::pool_size-1].set_freepointer(NULL);
   48800           0 :                 tempPointer = &(pointer[SgOmpAcquireClause::pool_size-1]);
   48801           0 :                 ++block;
   48802             :              }
   48803             :         }
   48804           0 :    }
   48805             : 
   48806           5 : void SgOmpAcquireClause::deleteMemoryPool() {
   48807           5 :   for (auto p: SgOmpAcquireClause::pools) {
   48808           0 :     ROSE_FREE(p);
   48809             :   }
   48810           5 :   SgOmpAcquireClause::next_node = nullptr;
   48811           5 :   SgOmpAcquireClause::pools.clear();
   48812           5 : }
   48813             : 
   48814             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   48815             : //                 reading multiple binary files to for a single AST.
   48816             : /////////// new version ////////////////////////////////
   48817             : //############################################################################
   48818             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   48819             : void
   48820           2 : SgOmpAcquireClause::extendMemoryPoolForFileIO( )
   48821             :   {
   48822           2 :     size_t blockIndex = SgOmpAcquireClause::pools.size();
   48823           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAcquireClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAcquireClause);
   48824             : 
   48825           2 :     while ( (blockIndex * SgOmpAcquireClause::pool_size) < newPoolSize)
   48826             :       {
   48827             : #if ROSE_ALLOC_TRACE
   48828             :         if (blockIndex > 0) {
   48829             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAcquireClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAcquireClause) = %" PRIuPTR " SgOmpAcquireClause::pool_size = %d \n",
   48830             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAcquireClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAcquireClause),SgOmpAcquireClause::pool_size);
   48831             :         }
   48832             : #endif
   48833             : 
   48834           0 :         SgOmpAcquireClause * pointer = (SgOmpAcquireClause*) ROSE_MALLOC ( SgOmpAcquireClause::pool_size * sizeof(SgOmpAcquireClause) );
   48835           0 :         assert( pointer != NULL );
   48836             : #if ROSE_ALLOC_MEMSET == 1
   48837             :         memset(pointer, 0x00, SgOmpAcquireClause::pool_size * sizeof(SgOmpAcquireClause));
   48838             : #elif ROSE_ALLOC_MEMSET == 2
   48839             :         memset(pointer, 0xCC, SgOmpAcquireClause::pool_size * sizeof(SgOmpAcquireClause));
   48840             : #endif
   48841           0 :         SgOmpAcquireClause::pools.push_back( (unsigned char*)(pointer) );
   48842           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAcquireClause::pool_size * sizeof(SgOmpAcquireClause), V_SgOmpAcquireClause ) );
   48843             : 
   48844           0 :         if ( SgOmpAcquireClause::next_node != NULL ) {
   48845           0 :           if ( blockIndex > 0 ) {
   48846           0 :             SgOmpAcquireClause * blkptr = (SgOmpAcquireClause*)(SgOmpAcquireClause::pools[blockIndex-1]);
   48847           0 :             blkptr[ SgOmpAcquireClause::pool_size - 1 ].set_freepointer(pointer);
   48848             :           }
   48849             :         } else {
   48850           0 :           SgOmpAcquireClause::next_node = pointer;
   48851             :         }
   48852             : 
   48853           0 :         for (unsigned i = 0; i < SgOmpAcquireClause::pool_size-1; ++i)
   48854             :            {
   48855           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   48856             :            }
   48857           0 :         pointer[ SgOmpAcquireClause::pool_size -1 ].set_freepointer(NULL);
   48858             : 
   48859           0 :         blockIndex++;
   48860             :       }
   48861           2 :   }
   48862             : 
   48863             : //############################################################################
   48864             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   48865             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   48866             :  * not compressed. However, that stuff is not yet implemented! 
   48867             :  */
   48868             : unsigned long
   48869           0 : SgOmpAcquireClause::getNumberOfLastValidPointer()
   48870             :    {
   48871           0 :       SgOmpAcquireClause* testPointer = (SgOmpAcquireClause*)(SgOmpAcquireClause::pools.back());
   48872           0 :       unsigned long localIndex = SgOmpAcquireClause::pool_size - 1;
   48873           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   48874             :          {
   48875           0 :            localIndex--;
   48876             :          }
   48877           0 :       return (localIndex + SgOmpAcquireClause::pool_size * (SgOmpAcquireClause::pools.size()-1));
   48878             :    }
   48879             : 
   48880             : //############################################################################
   48881             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   48882             :  * memory pool and initializes the data member in class SgOmpAcquireClauseStroageClass
   48883             :  * from its counterpart of SgOmpAcquireClause. The return value is just for checking, 
   48884             :  * that the whole StorageClassArray is initialized!
   48885             :  */
   48886             : unsigned long
   48887           0 : SgOmpAcquireClause::initializeStorageClassArray( SgOmpAcquireClauseStorageClass *storageArray )
   48888             :    {
   48889           0 :      unsigned long storageCounter = 0;
   48890           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAcquireClause::pools.begin();
   48891           0 :      SgOmpAcquireClause* pointer = NULL;
   48892           0 :      while ( block != SgOmpAcquireClause::pools.end() ) {
   48893           0 :           pointer = (SgOmpAcquireClause*) (*block);
   48894           0 :           for ( unsigned i = 0; i < SgOmpAcquireClause::pool_size; ++i ) {
   48895           0 :                if ( pointer->get_freepointer() != NULL ) {
   48896           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   48897           0 :                  storageArray++;
   48898           0 :                  storageCounter++;
   48899             :                }
   48900           0 :                pointer++;
   48901             :              }
   48902           0 :            block++;
   48903             :         }
   48904           0 :      return storageCounter;
   48905             :    }
   48906             : 
   48907             : /* #line 48908 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   48908             : 
   48909             : 
   48910             : 
   48911             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   48912             : 
   48913             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   48914             : 
   48915             : //############################################################################
   48916             : /* JH (02/02/2006) Constructor of the IR node SgOmpRelaxedClause that takes its 
   48917             :  * corresponding StorageClass as parameter
   48918             :  */
   48919           0 : SgOmpRelaxedClause :: SgOmpRelaxedClause ( const SgOmpRelaxedClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   48920             :    {
   48921             : 
   48922             : 
   48923             : /* #line 48924 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   48924             : 
   48925           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   48926             : 
   48927             : 
   48928             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   48929             : 
   48930             : 
   48931           0 :    }
   48932             : 
   48933             : //############################################################################
   48934             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   48935             :  * within the working AST. 
   48936             :  */
   48937           0 : SgOmpRelaxedClause * SgOmpRelaxedClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   48938           0 :      SgOmpRelaxedClause* returnPointer = NULL;
   48939           0 :      if ( globalIndex != 0 )
   48940             :         {
   48941             : 
   48942             : #if FILE_IO_EXTRA_CHECK
   48943           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpRelaxedClause ) ) <= globalIndex ) ;
   48944           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpRelaxedClause + 1 ) ) );
   48945             : #endif
   48946           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpRelaxedClause )  
   48947           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpRelaxedClause );
   48948           0 :           unsigned long positionInPool = localIndex % SgOmpRelaxedClause::pool_size;
   48949           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpRelaxedClause::pool_size;
   48950             : 
   48951             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   48952             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   48953             : 
   48954           0 :           returnPointer = &( ( (SgOmpRelaxedClause*)(SgOmpRelaxedClause::pools[memoryBlock]) ) [positionInPool]) ;
   48955             : 
   48956           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   48957             :         }
   48958           0 :      return returnPointer ;
   48959             :    }
   48960             : 
   48961             : //############################################################################
   48962             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   48963             :   for the AST with the index astIndex
   48964             : */
   48965           0 : SgOmpRelaxedClause * SgOmpRelaxedClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   48966           0 :      SgOmpRelaxedClause* returnPointer = NULL;
   48967           0 :      if ( globalIndex != 0 )
   48968             :         {
   48969             : 
   48970             : #if FILE_IO_EXTRA_CHECK
   48971           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpRelaxedClause ) ) <= globalIndex ) ;
   48972           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpRelaxedClause + 1 ) ) );
   48973             : #endif
   48974           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpRelaxedClause )
   48975           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpRelaxedClause );
   48976           0 :           unsigned long positionInPool = localIndex % SgOmpRelaxedClause::pool_size ;
   48977           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpRelaxedClause::pool_size ;
   48978             : 
   48979             : #if FILE_IO_EXTRA_CHECK
   48980             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   48981             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   48982             : #endif
   48983             : 
   48984           0 :           returnPointer = &( ( (SgOmpRelaxedClause*)(SgOmpRelaxedClause::pools[memoryBlock]) ) [positionInPool]) ;
   48985             : 
   48986             : #if FILE_IO_EXTRA_CHECK
   48987           0 :           assert ( returnPointer != NULL ) ;
   48988             : #endif
   48989             :         }
   48990           0 :      return returnPointer ;
   48991             :    }
   48992             : 
   48993             : //############################################################################
   48994             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   48995             :  * pool size! We set for every valid object in the memory pool the freepointer
   48996             :  * to the global index and increase the global index afterwards. For all the 
   48997             :  * invalid objects (means address ranges within the memory pool that were not
   48998             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   48999             :  * distinguish valid from invalid objects! 
   49000             :  */
   49001             : unsigned long
   49002           5 : SgOmpRelaxedClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   49003             :    {
   49004           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   49005           5 :      SgOmpRelaxedClause* pointer = NULL;
   49006           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   49007           5 :      std::vector < unsigned char* > :: const_iterator block;
   49008           5 :      for ( block = SgOmpRelaxedClause::pools.begin(); block != SgOmpRelaxedClause::pools.end() ; ++block )
   49009             :         {
   49010           0 :           pointer = (SgOmpRelaxedClause*)(*block);
   49011           0 :           for (unsigned i = 0; i < SgOmpRelaxedClause::pool_size; ++i )
   49012             :              {
   49013             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   49014             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   49015             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   49016             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   49017             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   49018             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   49019             :             // properly; so this will have to be checked next.
   49020             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   49021             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   49022           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   49023             :                   {
   49024           0 :                     pointer[i].set_freepointer((SgOmpRelaxedClause*)(globalIndex));
   49025           0 :                     globalIndex++;
   49026             :                   }
   49027             :                else
   49028             :                   {
   49029           0 :                     pointer[i].set_freepointer(NULL);
   49030             :                   }
   49031             :               }
   49032             :         }
   49033           5 :      return globalIndex;
   49034             :    }
   49035             : 
   49036             : //############################################################################
   49037             : // JH (01/14/2006)
   49038             : void
   49039           5 : SgOmpRelaxedClause::resetValidFreepointers( )
   49040             :    {
   49041           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   49042           5 :      SgOmpRelaxedClause* pointer = NULL;
   49043           5 :      std::vector < unsigned char* > :: const_iterator block;
   49044           5 :      SgOmpRelaxedClause* pointerOfLinkedList = NULL;
   49045           5 :      for ( block = SgOmpRelaxedClause::pools.begin(); block != SgOmpRelaxedClause::pools.end() ; ++block )
   49046             :         {
   49047           0 :           pointer = (SgOmpRelaxedClause*)(*block);
   49048           0 :           for (unsigned i = 0; i < SgOmpRelaxedClause::pool_size; ++i )
   49049             :              {
   49050             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   49051             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   49052             :             // memory blocks!.
   49053           0 :                if ( pointer[i].get_freepointer() != NULL )
   49054             :                   {
   49055           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   49056             :                   }
   49057             :                else
   49058             :                   {
   49059           0 :                     if ( pointerOfLinkedList == NULL )
   49060             :                        {
   49061           0 :                          SgOmpRelaxedClause::next_node = &(pointer[i]);
   49062             :                        }
   49063             :                     else
   49064             :                        {
   49065             :                       // printf ("In SgOmpRelaxedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   49066           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   49067             :                        }
   49068             :                     pointerOfLinkedList = &(pointer[i]);
   49069             :                   }
   49070             :               }
   49071             :         }
   49072             : 
   49073           5 :      if ( pointerOfLinkedList != NULL )
   49074             :         {
   49075             :        // printf ("In SgOmpRelaxedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   49076           0 :           pointerOfLinkedList->set_freepointer(NULL);
   49077             :        // DQ (6/6/2010): Temporary debugging...
   49078             :        //   ROSE_ASSERT(false);
   49079             :         }
   49080             : 
   49081           5 :      return ;
   49082             :    }
   49083             : 
   49084             : //############################################################################
   49085             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   49086             :  * within the memory pool and resets the freepointers, in order to achieve a 
   49087             :  * linked list, that has no jumps and starts at the beginning! This function 
   49088             :  * does not extend the memory pool, since we do not delete any memory blocks,
   49089             :  * but delete the valid objects.  
   49090             :  */
   49091             : void
   49092           0 : SgOmpRelaxedClause::clearMemoryPool( )
   49093             :    {
   49094             :   // printf ("Inside of SgOmpRelaxedClause::clearMemoryPool() \n");
   49095             : 
   49096           0 :      SgOmpRelaxedClause* pointer = NULL, *tempPointer = NULL;
   49097           0 :      std::vector < unsigned char* > :: const_iterator block;
   49098           0 :      if ( SgOmpRelaxedClause::pools.empty() == false )
   49099             :         {
   49100           0 :           block = SgOmpRelaxedClause::pools.begin() ;
   49101           0 :           SgOmpRelaxedClause::next_node = (SgOmpRelaxedClause*) (*block);
   49102             : 
   49103           0 :           while ( block != SgOmpRelaxedClause::pools.end() )
   49104             :              {
   49105           0 :                pointer = (SgOmpRelaxedClause*) (*block);
   49106           0 :                if ( tempPointer != NULL )
   49107             :                   {
   49108           0 :                     tempPointer->set_freepointer(pointer);
   49109             :                   }
   49110           0 :                for (unsigned i = 0; i < SgOmpRelaxedClause::pool_size - 1; ++i)
   49111             :                   {
   49112           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   49113             :                   }
   49114           0 :                 pointer[SgOmpRelaxedClause::pool_size-1].set_freepointer(NULL);
   49115           0 :                 tempPointer = &(pointer[SgOmpRelaxedClause::pool_size-1]);
   49116           0 :                 ++block;
   49117             :              }
   49118             :         }
   49119           0 :    }
   49120             : 
   49121           5 : void SgOmpRelaxedClause::deleteMemoryPool() {
   49122           5 :   for (auto p: SgOmpRelaxedClause::pools) {
   49123           0 :     ROSE_FREE(p);
   49124             :   }
   49125           5 :   SgOmpRelaxedClause::next_node = nullptr;
   49126           5 :   SgOmpRelaxedClause::pools.clear();
   49127           5 : }
   49128             : 
   49129             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   49130             : //                 reading multiple binary files to for a single AST.
   49131             : /////////// new version ////////////////////////////////
   49132             : //############################################################################
   49133             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   49134             : void
   49135           2 : SgOmpRelaxedClause::extendMemoryPoolForFileIO( )
   49136             :   {
   49137           2 :     size_t blockIndex = SgOmpRelaxedClause::pools.size();
   49138           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpRelaxedClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpRelaxedClause);
   49139             : 
   49140           2 :     while ( (blockIndex * SgOmpRelaxedClause::pool_size) < newPoolSize)
   49141             :       {
   49142             : #if ROSE_ALLOC_TRACE
   49143             :         if (blockIndex > 0) {
   49144             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpRelaxedClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpRelaxedClause) = %" PRIuPTR " SgOmpRelaxedClause::pool_size = %d \n",
   49145             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpRelaxedClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpRelaxedClause),SgOmpRelaxedClause::pool_size);
   49146             :         }
   49147             : #endif
   49148             : 
   49149           0 :         SgOmpRelaxedClause * pointer = (SgOmpRelaxedClause*) ROSE_MALLOC ( SgOmpRelaxedClause::pool_size * sizeof(SgOmpRelaxedClause) );
   49150           0 :         assert( pointer != NULL );
   49151             : #if ROSE_ALLOC_MEMSET == 1
   49152             :         memset(pointer, 0x00, SgOmpRelaxedClause::pool_size * sizeof(SgOmpRelaxedClause));
   49153             : #elif ROSE_ALLOC_MEMSET == 2
   49154             :         memset(pointer, 0xCC, SgOmpRelaxedClause::pool_size * sizeof(SgOmpRelaxedClause));
   49155             : #endif
   49156           0 :         SgOmpRelaxedClause::pools.push_back( (unsigned char*)(pointer) );
   49157           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpRelaxedClause::pool_size * sizeof(SgOmpRelaxedClause), V_SgOmpRelaxedClause ) );
   49158             : 
   49159           0 :         if ( SgOmpRelaxedClause::next_node != NULL ) {
   49160           0 :           if ( blockIndex > 0 ) {
   49161           0 :             SgOmpRelaxedClause * blkptr = (SgOmpRelaxedClause*)(SgOmpRelaxedClause::pools[blockIndex-1]);
   49162           0 :             blkptr[ SgOmpRelaxedClause::pool_size - 1 ].set_freepointer(pointer);
   49163             :           }
   49164             :         } else {
   49165           0 :           SgOmpRelaxedClause::next_node = pointer;
   49166             :         }
   49167             : 
   49168           0 :         for (unsigned i = 0; i < SgOmpRelaxedClause::pool_size-1; ++i)
   49169             :            {
   49170           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   49171             :            }
   49172           0 :         pointer[ SgOmpRelaxedClause::pool_size -1 ].set_freepointer(NULL);
   49173             : 
   49174           0 :         blockIndex++;
   49175             :       }
   49176           2 :   }
   49177             : 
   49178             : //############################################################################
   49179             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   49180             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   49181             :  * not compressed. However, that stuff is not yet implemented! 
   49182             :  */
   49183             : unsigned long
   49184           0 : SgOmpRelaxedClause::getNumberOfLastValidPointer()
   49185             :    {
   49186           0 :       SgOmpRelaxedClause* testPointer = (SgOmpRelaxedClause*)(SgOmpRelaxedClause::pools.back());
   49187           0 :       unsigned long localIndex = SgOmpRelaxedClause::pool_size - 1;
   49188           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   49189             :          {
   49190           0 :            localIndex--;
   49191             :          }
   49192           0 :       return (localIndex + SgOmpRelaxedClause::pool_size * (SgOmpRelaxedClause::pools.size()-1));
   49193             :    }
   49194             : 
   49195             : //############################################################################
   49196             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   49197             :  * memory pool and initializes the data member in class SgOmpRelaxedClauseStroageClass
   49198             :  * from its counterpart of SgOmpRelaxedClause. The return value is just for checking, 
   49199             :  * that the whole StorageClassArray is initialized!
   49200             :  */
   49201             : unsigned long
   49202           0 : SgOmpRelaxedClause::initializeStorageClassArray( SgOmpRelaxedClauseStorageClass *storageArray )
   49203             :    {
   49204           0 :      unsigned long storageCounter = 0;
   49205           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpRelaxedClause::pools.begin();
   49206           0 :      SgOmpRelaxedClause* pointer = NULL;
   49207           0 :      while ( block != SgOmpRelaxedClause::pools.end() ) {
   49208           0 :           pointer = (SgOmpRelaxedClause*) (*block);
   49209           0 :           for ( unsigned i = 0; i < SgOmpRelaxedClause::pool_size; ++i ) {
   49210           0 :                if ( pointer->get_freepointer() != NULL ) {
   49211           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   49212           0 :                  storageArray++;
   49213           0 :                  storageCounter++;
   49214             :                }
   49215           0 :                pointer++;
   49216             :              }
   49217           0 :            block++;
   49218             :         }
   49219           0 :      return storageCounter;
   49220             :    }
   49221             : 
   49222             : /* #line 49223 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   49223             : 
   49224             : 
   49225             : 
   49226             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   49227             : 
   49228             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   49229             : 
   49230             : //############################################################################
   49231             : /* JH (02/02/2006) Constructor of the IR node SgOmpReverseOffloadClause that takes its 
   49232             :  * corresponding StorageClass as parameter
   49233             :  */
   49234           0 : SgOmpReverseOffloadClause :: SgOmpReverseOffloadClause ( const SgOmpReverseOffloadClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   49235             :    {
   49236             : 
   49237             : 
   49238             : /* #line 49239 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   49239             : 
   49240           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   49241             : 
   49242             : 
   49243             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   49244             : 
   49245             : 
   49246           0 :    }
   49247             : 
   49248             : //############################################################################
   49249             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   49250             :  * within the working AST. 
   49251             :  */
   49252           0 : SgOmpReverseOffloadClause * SgOmpReverseOffloadClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   49253           0 :      SgOmpReverseOffloadClause* returnPointer = NULL;
   49254           0 :      if ( globalIndex != 0 )
   49255             :         {
   49256             : 
   49257             : #if FILE_IO_EXTRA_CHECK
   49258           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpReverseOffloadClause ) ) <= globalIndex ) ;
   49259           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpReverseOffloadClause + 1 ) ) );
   49260             : #endif
   49261           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpReverseOffloadClause )  
   49262           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpReverseOffloadClause );
   49263           0 :           unsigned long positionInPool = localIndex % SgOmpReverseOffloadClause::pool_size;
   49264           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpReverseOffloadClause::pool_size;
   49265             : 
   49266             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   49267             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   49268             : 
   49269           0 :           returnPointer = &( ( (SgOmpReverseOffloadClause*)(SgOmpReverseOffloadClause::pools[memoryBlock]) ) [positionInPool]) ;
   49270             : 
   49271           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   49272             :         }
   49273           0 :      return returnPointer ;
   49274             :    }
   49275             : 
   49276             : //############################################################################
   49277             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   49278             :   for the AST with the index astIndex
   49279             : */
   49280           0 : SgOmpReverseOffloadClause * SgOmpReverseOffloadClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   49281           0 :      SgOmpReverseOffloadClause* returnPointer = NULL;
   49282           0 :      if ( globalIndex != 0 )
   49283             :         {
   49284             : 
   49285             : #if FILE_IO_EXTRA_CHECK
   49286           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpReverseOffloadClause ) ) <= globalIndex ) ;
   49287           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpReverseOffloadClause + 1 ) ) );
   49288             : #endif
   49289           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpReverseOffloadClause )
   49290           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpReverseOffloadClause );
   49291           0 :           unsigned long positionInPool = localIndex % SgOmpReverseOffloadClause::pool_size ;
   49292           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpReverseOffloadClause::pool_size ;
   49293             : 
   49294             : #if FILE_IO_EXTRA_CHECK
   49295             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   49296             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   49297             : #endif
   49298             : 
   49299           0 :           returnPointer = &( ( (SgOmpReverseOffloadClause*)(SgOmpReverseOffloadClause::pools[memoryBlock]) ) [positionInPool]) ;
   49300             : 
   49301             : #if FILE_IO_EXTRA_CHECK
   49302           0 :           assert ( returnPointer != NULL ) ;
   49303             : #endif
   49304             :         }
   49305           0 :      return returnPointer ;
   49306             :    }
   49307             : 
   49308             : //############################################################################
   49309             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   49310             :  * pool size! We set for every valid object in the memory pool the freepointer
   49311             :  * to the global index and increase the global index afterwards. For all the 
   49312             :  * invalid objects (means address ranges within the memory pool that were not
   49313             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   49314             :  * distinguish valid from invalid objects! 
   49315             :  */
   49316             : unsigned long
   49317           5 : SgOmpReverseOffloadClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   49318             :    {
   49319           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   49320           5 :      SgOmpReverseOffloadClause* pointer = NULL;
   49321           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   49322           5 :      std::vector < unsigned char* > :: const_iterator block;
   49323           5 :      for ( block = SgOmpReverseOffloadClause::pools.begin(); block != SgOmpReverseOffloadClause::pools.end() ; ++block )
   49324             :         {
   49325           0 :           pointer = (SgOmpReverseOffloadClause*)(*block);
   49326           0 :           for (unsigned i = 0; i < SgOmpReverseOffloadClause::pool_size; ++i )
   49327             :              {
   49328             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   49329             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   49330             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   49331             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   49332             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   49333             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   49334             :             // properly; so this will have to be checked next.
   49335             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   49336             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   49337           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   49338             :                   {
   49339           0 :                     pointer[i].set_freepointer((SgOmpReverseOffloadClause*)(globalIndex));
   49340           0 :                     globalIndex++;
   49341             :                   }
   49342             :                else
   49343             :                   {
   49344           0 :                     pointer[i].set_freepointer(NULL);
   49345             :                   }
   49346             :               }
   49347             :         }
   49348           5 :      return globalIndex;
   49349             :    }
   49350             : 
   49351             : //############################################################################
   49352             : // JH (01/14/2006)
   49353             : void
   49354           5 : SgOmpReverseOffloadClause::resetValidFreepointers( )
   49355             :    {
   49356           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   49357           5 :      SgOmpReverseOffloadClause* pointer = NULL;
   49358           5 :      std::vector < unsigned char* > :: const_iterator block;
   49359           5 :      SgOmpReverseOffloadClause* pointerOfLinkedList = NULL;
   49360           5 :      for ( block = SgOmpReverseOffloadClause::pools.begin(); block != SgOmpReverseOffloadClause::pools.end() ; ++block )
   49361             :         {
   49362           0 :           pointer = (SgOmpReverseOffloadClause*)(*block);
   49363           0 :           for (unsigned i = 0; i < SgOmpReverseOffloadClause::pool_size; ++i )
   49364             :              {
   49365             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   49366             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   49367             :             // memory blocks!.
   49368           0 :                if ( pointer[i].get_freepointer() != NULL )
   49369             :                   {
   49370           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   49371             :                   }
   49372             :                else
   49373             :                   {
   49374           0 :                     if ( pointerOfLinkedList == NULL )
   49375             :                        {
   49376           0 :                          SgOmpReverseOffloadClause::next_node = &(pointer[i]);
   49377             :                        }
   49378             :                     else
   49379             :                        {
   49380             :                       // printf ("In SgOmpReverseOffloadClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   49381           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   49382             :                        }
   49383             :                     pointerOfLinkedList = &(pointer[i]);
   49384             :                   }
   49385             :               }
   49386             :         }
   49387             : 
   49388           5 :      if ( pointerOfLinkedList != NULL )
   49389             :         {
   49390             :        // printf ("In SgOmpReverseOffloadClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   49391           0 :           pointerOfLinkedList->set_freepointer(NULL);
   49392             :        // DQ (6/6/2010): Temporary debugging...
   49393             :        //   ROSE_ASSERT(false);
   49394             :         }
   49395             : 
   49396           5 :      return ;
   49397             :    }
   49398             : 
   49399             : //############################################################################
   49400             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   49401             :  * within the memory pool and resets the freepointers, in order to achieve a 
   49402             :  * linked list, that has no jumps and starts at the beginning! This function 
   49403             :  * does not extend the memory pool, since we do not delete any memory blocks,
   49404             :  * but delete the valid objects.  
   49405             :  */
   49406             : void
   49407           0 : SgOmpReverseOffloadClause::clearMemoryPool( )
   49408             :    {
   49409             :   // printf ("Inside of SgOmpReverseOffloadClause::clearMemoryPool() \n");
   49410             : 
   49411           0 :      SgOmpReverseOffloadClause* pointer = NULL, *tempPointer = NULL;
   49412           0 :      std::vector < unsigned char* > :: const_iterator block;
   49413           0 :      if ( SgOmpReverseOffloadClause::pools.empty() == false )
   49414             :         {
   49415           0 :           block = SgOmpReverseOffloadClause::pools.begin() ;
   49416           0 :           SgOmpReverseOffloadClause::next_node = (SgOmpReverseOffloadClause*) (*block);
   49417             : 
   49418           0 :           while ( block != SgOmpReverseOffloadClause::pools.end() )
   49419             :              {
   49420           0 :                pointer = (SgOmpReverseOffloadClause*) (*block);
   49421           0 :                if ( tempPointer != NULL )
   49422             :                   {
   49423           0 :                     tempPointer->set_freepointer(pointer);
   49424             :                   }
   49425           0 :                for (unsigned i = 0; i < SgOmpReverseOffloadClause::pool_size - 1; ++i)
   49426             :                   {
   49427           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   49428             :                   }
   49429           0 :                 pointer[SgOmpReverseOffloadClause::pool_size-1].set_freepointer(NULL);
   49430           0 :                 tempPointer = &(pointer[SgOmpReverseOffloadClause::pool_size-1]);
   49431           0 :                 ++block;
   49432             :              }
   49433             :         }
   49434           0 :    }
   49435             : 
   49436           5 : void SgOmpReverseOffloadClause::deleteMemoryPool() {
   49437           5 :   for (auto p: SgOmpReverseOffloadClause::pools) {
   49438           0 :     ROSE_FREE(p);
   49439             :   }
   49440           5 :   SgOmpReverseOffloadClause::next_node = nullptr;
   49441           5 :   SgOmpReverseOffloadClause::pools.clear();
   49442           5 : }
   49443             : 
   49444             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   49445             : //                 reading multiple binary files to for a single AST.
   49446             : /////////// new version ////////////////////////////////
   49447             : //############################################################################
   49448             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   49449             : void
   49450           2 : SgOmpReverseOffloadClause::extendMemoryPoolForFileIO( )
   49451             :   {
   49452           2 :     size_t blockIndex = SgOmpReverseOffloadClause::pools.size();
   49453           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReverseOffloadClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReverseOffloadClause);
   49454             : 
   49455           2 :     while ( (blockIndex * SgOmpReverseOffloadClause::pool_size) < newPoolSize)
   49456             :       {
   49457             : #if ROSE_ALLOC_TRACE
   49458             :         if (blockIndex > 0) {
   49459             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReverseOffloadClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReverseOffloadClause) = %" PRIuPTR " SgOmpReverseOffloadClause::pool_size = %d \n",
   49460             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReverseOffloadClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReverseOffloadClause),SgOmpReverseOffloadClause::pool_size);
   49461             :         }
   49462             : #endif
   49463             : 
   49464           0 :         SgOmpReverseOffloadClause * pointer = (SgOmpReverseOffloadClause*) ROSE_MALLOC ( SgOmpReverseOffloadClause::pool_size * sizeof(SgOmpReverseOffloadClause) );
   49465           0 :         assert( pointer != NULL );
   49466             : #if ROSE_ALLOC_MEMSET == 1
   49467             :         memset(pointer, 0x00, SgOmpReverseOffloadClause::pool_size * sizeof(SgOmpReverseOffloadClause));
   49468             : #elif ROSE_ALLOC_MEMSET == 2
   49469             :         memset(pointer, 0xCC, SgOmpReverseOffloadClause::pool_size * sizeof(SgOmpReverseOffloadClause));
   49470             : #endif
   49471           0 :         SgOmpReverseOffloadClause::pools.push_back( (unsigned char*)(pointer) );
   49472           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpReverseOffloadClause::pool_size * sizeof(SgOmpReverseOffloadClause), V_SgOmpReverseOffloadClause ) );
   49473             : 
   49474           0 :         if ( SgOmpReverseOffloadClause::next_node != NULL ) {
   49475           0 :           if ( blockIndex > 0 ) {
   49476           0 :             SgOmpReverseOffloadClause * blkptr = (SgOmpReverseOffloadClause*)(SgOmpReverseOffloadClause::pools[blockIndex-1]);
   49477           0 :             blkptr[ SgOmpReverseOffloadClause::pool_size - 1 ].set_freepointer(pointer);
   49478             :           }
   49479             :         } else {
   49480           0 :           SgOmpReverseOffloadClause::next_node = pointer;
   49481             :         }
   49482             : 
   49483           0 :         for (unsigned i = 0; i < SgOmpReverseOffloadClause::pool_size-1; ++i)
   49484             :            {
   49485           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   49486             :            }
   49487           0 :         pointer[ SgOmpReverseOffloadClause::pool_size -1 ].set_freepointer(NULL);
   49488             : 
   49489           0 :         blockIndex++;
   49490             :       }
   49491           2 :   }
   49492             : 
   49493             : //############################################################################
   49494             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   49495             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   49496             :  * not compressed. However, that stuff is not yet implemented! 
   49497             :  */
   49498             : unsigned long
   49499           0 : SgOmpReverseOffloadClause::getNumberOfLastValidPointer()
   49500             :    {
   49501           0 :       SgOmpReverseOffloadClause* testPointer = (SgOmpReverseOffloadClause*)(SgOmpReverseOffloadClause::pools.back());
   49502           0 :       unsigned long localIndex = SgOmpReverseOffloadClause::pool_size - 1;
   49503           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   49504             :          {
   49505           0 :            localIndex--;
   49506             :          }
   49507           0 :       return (localIndex + SgOmpReverseOffloadClause::pool_size * (SgOmpReverseOffloadClause::pools.size()-1));
   49508             :    }
   49509             : 
   49510             : //############################################################################
   49511             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   49512             :  * memory pool and initializes the data member in class SgOmpReverseOffloadClauseStroageClass
   49513             :  * from its counterpart of SgOmpReverseOffloadClause. The return value is just for checking, 
   49514             :  * that the whole StorageClassArray is initialized!
   49515             :  */
   49516             : unsigned long
   49517           0 : SgOmpReverseOffloadClause::initializeStorageClassArray( SgOmpReverseOffloadClauseStorageClass *storageArray )
   49518             :    {
   49519           0 :      unsigned long storageCounter = 0;
   49520           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpReverseOffloadClause::pools.begin();
   49521           0 :      SgOmpReverseOffloadClause* pointer = NULL;
   49522           0 :      while ( block != SgOmpReverseOffloadClause::pools.end() ) {
   49523           0 :           pointer = (SgOmpReverseOffloadClause*) (*block);
   49524           0 :           for ( unsigned i = 0; i < SgOmpReverseOffloadClause::pool_size; ++i ) {
   49525           0 :                if ( pointer->get_freepointer() != NULL ) {
   49526           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   49527           0 :                  storageArray++;
   49528           0 :                  storageCounter++;
   49529             :                }
   49530           0 :                pointer++;
   49531             :              }
   49532           0 :            block++;
   49533             :         }
   49534           0 :      return storageCounter;
   49535             :    }
   49536             : 
   49537             : /* #line 49538 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   49538             : 
   49539             : 
   49540             : 
   49541             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   49542             : 
   49543             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   49544             : 
   49545             : //############################################################################
   49546             : /* JH (02/02/2006) Constructor of the IR node SgOmpUnifiedAddressClause that takes its 
   49547             :  * corresponding StorageClass as parameter
   49548             :  */
   49549           0 : SgOmpUnifiedAddressClause :: SgOmpUnifiedAddressClause ( const SgOmpUnifiedAddressClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   49550             :    {
   49551             : 
   49552             : 
   49553             : /* #line 49554 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   49554             : 
   49555           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   49556             : 
   49557             : 
   49558             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   49559             : 
   49560             : 
   49561           0 :    }
   49562             : 
   49563             : //############################################################################
   49564             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   49565             :  * within the working AST. 
   49566             :  */
   49567           0 : SgOmpUnifiedAddressClause * SgOmpUnifiedAddressClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   49568           0 :      SgOmpUnifiedAddressClause* returnPointer = NULL;
   49569           0 :      if ( globalIndex != 0 )
   49570             :         {
   49571             : 
   49572             : #if FILE_IO_EXTRA_CHECK
   49573           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUnifiedAddressClause ) ) <= globalIndex ) ;
   49574           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUnifiedAddressClause + 1 ) ) );
   49575             : #endif
   49576           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUnifiedAddressClause )  
   49577           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUnifiedAddressClause );
   49578           0 :           unsigned long positionInPool = localIndex % SgOmpUnifiedAddressClause::pool_size;
   49579           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUnifiedAddressClause::pool_size;
   49580             : 
   49581             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   49582             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   49583             : 
   49584           0 :           returnPointer = &( ( (SgOmpUnifiedAddressClause*)(SgOmpUnifiedAddressClause::pools[memoryBlock]) ) [positionInPool]) ;
   49585             : 
   49586           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   49587             :         }
   49588           0 :      return returnPointer ;
   49589             :    }
   49590             : 
   49591             : //############################################################################
   49592             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   49593             :   for the AST with the index astIndex
   49594             : */
   49595           0 : SgOmpUnifiedAddressClause * SgOmpUnifiedAddressClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   49596           0 :      SgOmpUnifiedAddressClause* returnPointer = NULL;
   49597           0 :      if ( globalIndex != 0 )
   49598             :         {
   49599             : 
   49600             : #if FILE_IO_EXTRA_CHECK
   49601           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUnifiedAddressClause ) ) <= globalIndex ) ;
   49602           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUnifiedAddressClause + 1 ) ) );
   49603             : #endif
   49604           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUnifiedAddressClause )
   49605           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUnifiedAddressClause );
   49606           0 :           unsigned long positionInPool = localIndex % SgOmpUnifiedAddressClause::pool_size ;
   49607           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUnifiedAddressClause::pool_size ;
   49608             : 
   49609             : #if FILE_IO_EXTRA_CHECK
   49610             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   49611             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   49612             : #endif
   49613             : 
   49614           0 :           returnPointer = &( ( (SgOmpUnifiedAddressClause*)(SgOmpUnifiedAddressClause::pools[memoryBlock]) ) [positionInPool]) ;
   49615             : 
   49616             : #if FILE_IO_EXTRA_CHECK
   49617           0 :           assert ( returnPointer != NULL ) ;
   49618             : #endif
   49619             :         }
   49620           0 :      return returnPointer ;
   49621             :    }
   49622             : 
   49623             : //############################################################################
   49624             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   49625             :  * pool size! We set for every valid object in the memory pool the freepointer
   49626             :  * to the global index and increase the global index afterwards. For all the 
   49627             :  * invalid objects (means address ranges within the memory pool that were not
   49628             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   49629             :  * distinguish valid from invalid objects! 
   49630             :  */
   49631             : unsigned long
   49632           5 : SgOmpUnifiedAddressClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   49633             :    {
   49634           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   49635           5 :      SgOmpUnifiedAddressClause* pointer = NULL;
   49636           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   49637           5 :      std::vector < unsigned char* > :: const_iterator block;
   49638           5 :      for ( block = SgOmpUnifiedAddressClause::pools.begin(); block != SgOmpUnifiedAddressClause::pools.end() ; ++block )
   49639             :         {
   49640           0 :           pointer = (SgOmpUnifiedAddressClause*)(*block);
   49641           0 :           for (unsigned i = 0; i < SgOmpUnifiedAddressClause::pool_size; ++i )
   49642             :              {
   49643             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   49644             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   49645             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   49646             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   49647             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   49648             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   49649             :             // properly; so this will have to be checked next.
   49650             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   49651             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   49652           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   49653             :                   {
   49654           0 :                     pointer[i].set_freepointer((SgOmpUnifiedAddressClause*)(globalIndex));
   49655           0 :                     globalIndex++;
   49656             :                   }
   49657             :                else
   49658             :                   {
   49659           0 :                     pointer[i].set_freepointer(NULL);
   49660             :                   }
   49661             :               }
   49662             :         }
   49663           5 :      return globalIndex;
   49664             :    }
   49665             : 
   49666             : //############################################################################
   49667             : // JH (01/14/2006)
   49668             : void
   49669           5 : SgOmpUnifiedAddressClause::resetValidFreepointers( )
   49670             :    {
   49671           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   49672           5 :      SgOmpUnifiedAddressClause* pointer = NULL;
   49673           5 :      std::vector < unsigned char* > :: const_iterator block;
   49674           5 :      SgOmpUnifiedAddressClause* pointerOfLinkedList = NULL;
   49675           5 :      for ( block = SgOmpUnifiedAddressClause::pools.begin(); block != SgOmpUnifiedAddressClause::pools.end() ; ++block )
   49676             :         {
   49677           0 :           pointer = (SgOmpUnifiedAddressClause*)(*block);
   49678           0 :           for (unsigned i = 0; i < SgOmpUnifiedAddressClause::pool_size; ++i )
   49679             :              {
   49680             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   49681             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   49682             :             // memory blocks!.
   49683           0 :                if ( pointer[i].get_freepointer() != NULL )
   49684             :                   {
   49685           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   49686             :                   }
   49687             :                else
   49688             :                   {
   49689           0 :                     if ( pointerOfLinkedList == NULL )
   49690             :                        {
   49691           0 :                          SgOmpUnifiedAddressClause::next_node = &(pointer[i]);
   49692             :                        }
   49693             :                     else
   49694             :                        {
   49695             :                       // printf ("In SgOmpUnifiedAddressClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   49696           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   49697             :                        }
   49698             :                     pointerOfLinkedList = &(pointer[i]);
   49699             :                   }
   49700             :               }
   49701             :         }
   49702             : 
   49703           5 :      if ( pointerOfLinkedList != NULL )
   49704             :         {
   49705             :        // printf ("In SgOmpUnifiedAddressClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   49706           0 :           pointerOfLinkedList->set_freepointer(NULL);
   49707             :        // DQ (6/6/2010): Temporary debugging...
   49708             :        //   ROSE_ASSERT(false);
   49709             :         }
   49710             : 
   49711           5 :      return ;
   49712             :    }
   49713             : 
   49714             : //############################################################################
   49715             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   49716             :  * within the memory pool and resets the freepointers, in order to achieve a 
   49717             :  * linked list, that has no jumps and starts at the beginning! This function 
   49718             :  * does not extend the memory pool, since we do not delete any memory blocks,
   49719             :  * but delete the valid objects.  
   49720             :  */
   49721             : void
   49722           0 : SgOmpUnifiedAddressClause::clearMemoryPool( )
   49723             :    {
   49724             :   // printf ("Inside of SgOmpUnifiedAddressClause::clearMemoryPool() \n");
   49725             : 
   49726           0 :      SgOmpUnifiedAddressClause* pointer = NULL, *tempPointer = NULL;
   49727           0 :      std::vector < unsigned char* > :: const_iterator block;
   49728           0 :      if ( SgOmpUnifiedAddressClause::pools.empty() == false )
   49729             :         {
   49730           0 :           block = SgOmpUnifiedAddressClause::pools.begin() ;
   49731           0 :           SgOmpUnifiedAddressClause::next_node = (SgOmpUnifiedAddressClause*) (*block);
   49732             : 
   49733           0 :           while ( block != SgOmpUnifiedAddressClause::pools.end() )
   49734             :              {
   49735           0 :                pointer = (SgOmpUnifiedAddressClause*) (*block);
   49736           0 :                if ( tempPointer != NULL )
   49737             :                   {
   49738           0 :                     tempPointer->set_freepointer(pointer);
   49739             :                   }
   49740           0 :                for (unsigned i = 0; i < SgOmpUnifiedAddressClause::pool_size - 1; ++i)
   49741             :                   {
   49742           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   49743             :                   }
   49744           0 :                 pointer[SgOmpUnifiedAddressClause::pool_size-1].set_freepointer(NULL);
   49745           0 :                 tempPointer = &(pointer[SgOmpUnifiedAddressClause::pool_size-1]);
   49746           0 :                 ++block;
   49747             :              }
   49748             :         }
   49749           0 :    }
   49750             : 
   49751           5 : void SgOmpUnifiedAddressClause::deleteMemoryPool() {
   49752           5 :   for (auto p: SgOmpUnifiedAddressClause::pools) {
   49753           0 :     ROSE_FREE(p);
   49754             :   }
   49755           5 :   SgOmpUnifiedAddressClause::next_node = nullptr;
   49756           5 :   SgOmpUnifiedAddressClause::pools.clear();
   49757           5 : }
   49758             : 
   49759             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   49760             : //                 reading multiple binary files to for a single AST.
   49761             : /////////// new version ////////////////////////////////
   49762             : //############################################################################
   49763             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   49764             : void
   49765           2 : SgOmpUnifiedAddressClause::extendMemoryPoolForFileIO( )
   49766             :   {
   49767           2 :     size_t blockIndex = SgOmpUnifiedAddressClause::pools.size();
   49768           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnifiedAddressClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnifiedAddressClause);
   49769             : 
   49770           2 :     while ( (blockIndex * SgOmpUnifiedAddressClause::pool_size) < newPoolSize)
   49771             :       {
   49772             : #if ROSE_ALLOC_TRACE
   49773             :         if (blockIndex > 0) {
   49774             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnifiedAddressClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnifiedAddressClause) = %" PRIuPTR " SgOmpUnifiedAddressClause::pool_size = %d \n",
   49775             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnifiedAddressClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnifiedAddressClause),SgOmpUnifiedAddressClause::pool_size);
   49776             :         }
   49777             : #endif
   49778             : 
   49779           0 :         SgOmpUnifiedAddressClause * pointer = (SgOmpUnifiedAddressClause*) ROSE_MALLOC ( SgOmpUnifiedAddressClause::pool_size * sizeof(SgOmpUnifiedAddressClause) );
   49780           0 :         assert( pointer != NULL );
   49781             : #if ROSE_ALLOC_MEMSET == 1
   49782             :         memset(pointer, 0x00, SgOmpUnifiedAddressClause::pool_size * sizeof(SgOmpUnifiedAddressClause));
   49783             : #elif ROSE_ALLOC_MEMSET == 2
   49784             :         memset(pointer, 0xCC, SgOmpUnifiedAddressClause::pool_size * sizeof(SgOmpUnifiedAddressClause));
   49785             : #endif
   49786           0 :         SgOmpUnifiedAddressClause::pools.push_back( (unsigned char*)(pointer) );
   49787           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUnifiedAddressClause::pool_size * sizeof(SgOmpUnifiedAddressClause), V_SgOmpUnifiedAddressClause ) );
   49788             : 
   49789           0 :         if ( SgOmpUnifiedAddressClause::next_node != NULL ) {
   49790           0 :           if ( blockIndex > 0 ) {
   49791           0 :             SgOmpUnifiedAddressClause * blkptr = (SgOmpUnifiedAddressClause*)(SgOmpUnifiedAddressClause::pools[blockIndex-1]);
   49792           0 :             blkptr[ SgOmpUnifiedAddressClause::pool_size - 1 ].set_freepointer(pointer);
   49793             :           }
   49794             :         } else {
   49795           0 :           SgOmpUnifiedAddressClause::next_node = pointer;
   49796             :         }
   49797             : 
   49798           0 :         for (unsigned i = 0; i < SgOmpUnifiedAddressClause::pool_size-1; ++i)
   49799             :            {
   49800           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   49801             :            }
   49802           0 :         pointer[ SgOmpUnifiedAddressClause::pool_size -1 ].set_freepointer(NULL);
   49803             : 
   49804           0 :         blockIndex++;
   49805             :       }
   49806           2 :   }
   49807             : 
   49808             : //############################################################################
   49809             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   49810             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   49811             :  * not compressed. However, that stuff is not yet implemented! 
   49812             :  */
   49813             : unsigned long
   49814           0 : SgOmpUnifiedAddressClause::getNumberOfLastValidPointer()
   49815             :    {
   49816           0 :       SgOmpUnifiedAddressClause* testPointer = (SgOmpUnifiedAddressClause*)(SgOmpUnifiedAddressClause::pools.back());
   49817           0 :       unsigned long localIndex = SgOmpUnifiedAddressClause::pool_size - 1;
   49818           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   49819             :          {
   49820           0 :            localIndex--;
   49821             :          }
   49822           0 :       return (localIndex + SgOmpUnifiedAddressClause::pool_size * (SgOmpUnifiedAddressClause::pools.size()-1));
   49823             :    }
   49824             : 
   49825             : //############################################################################
   49826             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   49827             :  * memory pool and initializes the data member in class SgOmpUnifiedAddressClauseStroageClass
   49828             :  * from its counterpart of SgOmpUnifiedAddressClause. The return value is just for checking, 
   49829             :  * that the whole StorageClassArray is initialized!
   49830             :  */
   49831             : unsigned long
   49832           0 : SgOmpUnifiedAddressClause::initializeStorageClassArray( SgOmpUnifiedAddressClauseStorageClass *storageArray )
   49833             :    {
   49834           0 :      unsigned long storageCounter = 0;
   49835           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUnifiedAddressClause::pools.begin();
   49836           0 :      SgOmpUnifiedAddressClause* pointer = NULL;
   49837           0 :      while ( block != SgOmpUnifiedAddressClause::pools.end() ) {
   49838           0 :           pointer = (SgOmpUnifiedAddressClause*) (*block);
   49839           0 :           for ( unsigned i = 0; i < SgOmpUnifiedAddressClause::pool_size; ++i ) {
   49840           0 :                if ( pointer->get_freepointer() != NULL ) {
   49841           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   49842           0 :                  storageArray++;
   49843           0 :                  storageCounter++;
   49844             :                }
   49845           0 :                pointer++;
   49846             :              }
   49847           0 :            block++;
   49848             :         }
   49849           0 :      return storageCounter;
   49850             :    }
   49851             : 
   49852             : /* #line 49853 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   49853             : 
   49854             : 
   49855             : 
   49856             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   49857             : 
   49858             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   49859             : 
   49860             : //############################################################################
   49861             : /* JH (02/02/2006) Constructor of the IR node SgOmpUnifiedSharedMemoryClause that takes its 
   49862             :  * corresponding StorageClass as parameter
   49863             :  */
   49864           0 : SgOmpUnifiedSharedMemoryClause :: SgOmpUnifiedSharedMemoryClause ( const SgOmpUnifiedSharedMemoryClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   49865             :    {
   49866             : 
   49867             : 
   49868             : /* #line 49869 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   49869             : 
   49870           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   49871             : 
   49872             : 
   49873             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   49874             : 
   49875             : 
   49876           0 :    }
   49877             : 
   49878             : //############################################################################
   49879             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   49880             :  * within the working AST. 
   49881             :  */
   49882           0 : SgOmpUnifiedSharedMemoryClause * SgOmpUnifiedSharedMemoryClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   49883           0 :      SgOmpUnifiedSharedMemoryClause* returnPointer = NULL;
   49884           0 :      if ( globalIndex != 0 )
   49885             :         {
   49886             : 
   49887             : #if FILE_IO_EXTRA_CHECK
   49888           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUnifiedSharedMemoryClause ) ) <= globalIndex ) ;
   49889           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUnifiedSharedMemoryClause + 1 ) ) );
   49890             : #endif
   49891           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUnifiedSharedMemoryClause )  
   49892           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUnifiedSharedMemoryClause );
   49893           0 :           unsigned long positionInPool = localIndex % SgOmpUnifiedSharedMemoryClause::pool_size;
   49894           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUnifiedSharedMemoryClause::pool_size;
   49895             : 
   49896             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   49897             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   49898             : 
   49899           0 :           returnPointer = &( ( (SgOmpUnifiedSharedMemoryClause*)(SgOmpUnifiedSharedMemoryClause::pools[memoryBlock]) ) [positionInPool]) ;
   49900             : 
   49901           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   49902             :         }
   49903           0 :      return returnPointer ;
   49904             :    }
   49905             : 
   49906             : //############################################################################
   49907             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   49908             :   for the AST with the index astIndex
   49909             : */
   49910           0 : SgOmpUnifiedSharedMemoryClause * SgOmpUnifiedSharedMemoryClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   49911           0 :      SgOmpUnifiedSharedMemoryClause* returnPointer = NULL;
   49912           0 :      if ( globalIndex != 0 )
   49913             :         {
   49914             : 
   49915             : #if FILE_IO_EXTRA_CHECK
   49916           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUnifiedSharedMemoryClause ) ) <= globalIndex ) ;
   49917           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUnifiedSharedMemoryClause + 1 ) ) );
   49918             : #endif
   49919           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUnifiedSharedMemoryClause )
   49920           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUnifiedSharedMemoryClause );
   49921           0 :           unsigned long positionInPool = localIndex % SgOmpUnifiedSharedMemoryClause::pool_size ;
   49922           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUnifiedSharedMemoryClause::pool_size ;
   49923             : 
   49924             : #if FILE_IO_EXTRA_CHECK
   49925             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   49926             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   49927             : #endif
   49928             : 
   49929           0 :           returnPointer = &( ( (SgOmpUnifiedSharedMemoryClause*)(SgOmpUnifiedSharedMemoryClause::pools[memoryBlock]) ) [positionInPool]) ;
   49930             : 
   49931             : #if FILE_IO_EXTRA_CHECK
   49932           0 :           assert ( returnPointer != NULL ) ;
   49933             : #endif
   49934             :         }
   49935           0 :      return returnPointer ;
   49936             :    }
   49937             : 
   49938             : //############################################################################
   49939             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   49940             :  * pool size! We set for every valid object in the memory pool the freepointer
   49941             :  * to the global index and increase the global index afterwards. For all the 
   49942             :  * invalid objects (means address ranges within the memory pool that were not
   49943             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   49944             :  * distinguish valid from invalid objects! 
   49945             :  */
   49946             : unsigned long
   49947           5 : SgOmpUnifiedSharedMemoryClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   49948             :    {
   49949           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   49950           5 :      SgOmpUnifiedSharedMemoryClause* pointer = NULL;
   49951           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   49952           5 :      std::vector < unsigned char* > :: const_iterator block;
   49953           5 :      for ( block = SgOmpUnifiedSharedMemoryClause::pools.begin(); block != SgOmpUnifiedSharedMemoryClause::pools.end() ; ++block )
   49954             :         {
   49955           0 :           pointer = (SgOmpUnifiedSharedMemoryClause*)(*block);
   49956           0 :           for (unsigned i = 0; i < SgOmpUnifiedSharedMemoryClause::pool_size; ++i )
   49957             :              {
   49958             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   49959             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   49960             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   49961             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   49962             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   49963             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   49964             :             // properly; so this will have to be checked next.
   49965             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   49966             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   49967           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   49968             :                   {
   49969           0 :                     pointer[i].set_freepointer((SgOmpUnifiedSharedMemoryClause*)(globalIndex));
   49970           0 :                     globalIndex++;
   49971             :                   }
   49972             :                else
   49973             :                   {
   49974           0 :                     pointer[i].set_freepointer(NULL);
   49975             :                   }
   49976             :               }
   49977             :         }
   49978           5 :      return globalIndex;
   49979             :    }
   49980             : 
   49981             : //############################################################################
   49982             : // JH (01/14/2006)
   49983             : void
   49984           5 : SgOmpUnifiedSharedMemoryClause::resetValidFreepointers( )
   49985             :    {
   49986           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   49987           5 :      SgOmpUnifiedSharedMemoryClause* pointer = NULL;
   49988           5 :      std::vector < unsigned char* > :: const_iterator block;
   49989           5 :      SgOmpUnifiedSharedMemoryClause* pointerOfLinkedList = NULL;
   49990           5 :      for ( block = SgOmpUnifiedSharedMemoryClause::pools.begin(); block != SgOmpUnifiedSharedMemoryClause::pools.end() ; ++block )
   49991             :         {
   49992           0 :           pointer = (SgOmpUnifiedSharedMemoryClause*)(*block);
   49993           0 :           for (unsigned i = 0; i < SgOmpUnifiedSharedMemoryClause::pool_size; ++i )
   49994             :              {
   49995             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   49996             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   49997             :             // memory blocks!.
   49998           0 :                if ( pointer[i].get_freepointer() != NULL )
   49999             :                   {
   50000           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   50001             :                   }
   50002             :                else
   50003             :                   {
   50004           0 :                     if ( pointerOfLinkedList == NULL )
   50005             :                        {
   50006           0 :                          SgOmpUnifiedSharedMemoryClause::next_node = &(pointer[i]);
   50007             :                        }
   50008             :                     else
   50009             :                        {
   50010             :                       // printf ("In SgOmpUnifiedSharedMemoryClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   50011           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   50012             :                        }
   50013             :                     pointerOfLinkedList = &(pointer[i]);
   50014             :                   }
   50015             :               }
   50016             :         }
   50017             : 
   50018           5 :      if ( pointerOfLinkedList != NULL )
   50019             :         {
   50020             :        // printf ("In SgOmpUnifiedSharedMemoryClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   50021           0 :           pointerOfLinkedList->set_freepointer(NULL);
   50022             :        // DQ (6/6/2010): Temporary debugging...
   50023             :        //   ROSE_ASSERT(false);
   50024             :         }
   50025             : 
   50026           5 :      return ;
   50027             :    }
   50028             : 
   50029             : //############################################################################
   50030             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   50031             :  * within the memory pool and resets the freepointers, in order to achieve a 
   50032             :  * linked list, that has no jumps and starts at the beginning! This function 
   50033             :  * does not extend the memory pool, since we do not delete any memory blocks,
   50034             :  * but delete the valid objects.  
   50035             :  */
   50036             : void
   50037           0 : SgOmpUnifiedSharedMemoryClause::clearMemoryPool( )
   50038             :    {
   50039             :   // printf ("Inside of SgOmpUnifiedSharedMemoryClause::clearMemoryPool() \n");
   50040             : 
   50041           0 :      SgOmpUnifiedSharedMemoryClause* pointer = NULL, *tempPointer = NULL;
   50042           0 :      std::vector < unsigned char* > :: const_iterator block;
   50043           0 :      if ( SgOmpUnifiedSharedMemoryClause::pools.empty() == false )
   50044             :         {
   50045           0 :           block = SgOmpUnifiedSharedMemoryClause::pools.begin() ;
   50046           0 :           SgOmpUnifiedSharedMemoryClause::next_node = (SgOmpUnifiedSharedMemoryClause*) (*block);
   50047             : 
   50048           0 :           while ( block != SgOmpUnifiedSharedMemoryClause::pools.end() )
   50049             :              {
   50050           0 :                pointer = (SgOmpUnifiedSharedMemoryClause*) (*block);
   50051           0 :                if ( tempPointer != NULL )
   50052             :                   {
   50053           0 :                     tempPointer->set_freepointer(pointer);
   50054             :                   }
   50055           0 :                for (unsigned i = 0; i < SgOmpUnifiedSharedMemoryClause::pool_size - 1; ++i)
   50056             :                   {
   50057           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   50058             :                   }
   50059           0 :                 pointer[SgOmpUnifiedSharedMemoryClause::pool_size-1].set_freepointer(NULL);
   50060           0 :                 tempPointer = &(pointer[SgOmpUnifiedSharedMemoryClause::pool_size-1]);
   50061           0 :                 ++block;
   50062             :              }
   50063             :         }
   50064           0 :    }
   50065             : 
   50066           5 : void SgOmpUnifiedSharedMemoryClause::deleteMemoryPool() {
   50067           5 :   for (auto p: SgOmpUnifiedSharedMemoryClause::pools) {
   50068           0 :     ROSE_FREE(p);
   50069             :   }
   50070           5 :   SgOmpUnifiedSharedMemoryClause::next_node = nullptr;
   50071           5 :   SgOmpUnifiedSharedMemoryClause::pools.clear();
   50072           5 : }
   50073             : 
   50074             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   50075             : //                 reading multiple binary files to for a single AST.
   50076             : /////////// new version ////////////////////////////////
   50077             : //############################################################################
   50078             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   50079             : void
   50080           2 : SgOmpUnifiedSharedMemoryClause::extendMemoryPoolForFileIO( )
   50081             :   {
   50082           2 :     size_t blockIndex = SgOmpUnifiedSharedMemoryClause::pools.size();
   50083           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnifiedSharedMemoryClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnifiedSharedMemoryClause);
   50084             : 
   50085           2 :     while ( (blockIndex * SgOmpUnifiedSharedMemoryClause::pool_size) < newPoolSize)
   50086             :       {
   50087             : #if ROSE_ALLOC_TRACE
   50088             :         if (blockIndex > 0) {
   50089             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnifiedSharedMemoryClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnifiedSharedMemoryClause) = %" PRIuPTR " SgOmpUnifiedSharedMemoryClause::pool_size = %d \n",
   50090             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnifiedSharedMemoryClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnifiedSharedMemoryClause),SgOmpUnifiedSharedMemoryClause::pool_size);
   50091             :         }
   50092             : #endif
   50093             : 
   50094           0 :         SgOmpUnifiedSharedMemoryClause * pointer = (SgOmpUnifiedSharedMemoryClause*) ROSE_MALLOC ( SgOmpUnifiedSharedMemoryClause::pool_size * sizeof(SgOmpUnifiedSharedMemoryClause) );
   50095           0 :         assert( pointer != NULL );
   50096             : #if ROSE_ALLOC_MEMSET == 1
   50097             :         memset(pointer, 0x00, SgOmpUnifiedSharedMemoryClause::pool_size * sizeof(SgOmpUnifiedSharedMemoryClause));
   50098             : #elif ROSE_ALLOC_MEMSET == 2
   50099             :         memset(pointer, 0xCC, SgOmpUnifiedSharedMemoryClause::pool_size * sizeof(SgOmpUnifiedSharedMemoryClause));
   50100             : #endif
   50101           0 :         SgOmpUnifiedSharedMemoryClause::pools.push_back( (unsigned char*)(pointer) );
   50102           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUnifiedSharedMemoryClause::pool_size * sizeof(SgOmpUnifiedSharedMemoryClause), V_SgOmpUnifiedSharedMemoryClause ) );
   50103             : 
   50104           0 :         if ( SgOmpUnifiedSharedMemoryClause::next_node != NULL ) {
   50105           0 :           if ( blockIndex > 0 ) {
   50106           0 :             SgOmpUnifiedSharedMemoryClause * blkptr = (SgOmpUnifiedSharedMemoryClause*)(SgOmpUnifiedSharedMemoryClause::pools[blockIndex-1]);
   50107           0 :             blkptr[ SgOmpUnifiedSharedMemoryClause::pool_size - 1 ].set_freepointer(pointer);
   50108             :           }
   50109             :         } else {
   50110           0 :           SgOmpUnifiedSharedMemoryClause::next_node = pointer;
   50111             :         }
   50112             : 
   50113           0 :         for (unsigned i = 0; i < SgOmpUnifiedSharedMemoryClause::pool_size-1; ++i)
   50114             :            {
   50115           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   50116             :            }
   50117           0 :         pointer[ SgOmpUnifiedSharedMemoryClause::pool_size -1 ].set_freepointer(NULL);
   50118             : 
   50119           0 :         blockIndex++;
   50120             :       }
   50121           2 :   }
   50122             : 
   50123             : //############################################################################
   50124             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   50125             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   50126             :  * not compressed. However, that stuff is not yet implemented! 
   50127             :  */
   50128             : unsigned long
   50129           0 : SgOmpUnifiedSharedMemoryClause::getNumberOfLastValidPointer()
   50130             :    {
   50131           0 :       SgOmpUnifiedSharedMemoryClause* testPointer = (SgOmpUnifiedSharedMemoryClause*)(SgOmpUnifiedSharedMemoryClause::pools.back());
   50132           0 :       unsigned long localIndex = SgOmpUnifiedSharedMemoryClause::pool_size - 1;
   50133           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   50134             :          {
   50135           0 :            localIndex--;
   50136             :          }
   50137           0 :       return (localIndex + SgOmpUnifiedSharedMemoryClause::pool_size * (SgOmpUnifiedSharedMemoryClause::pools.size()-1));
   50138             :    }
   50139             : 
   50140             : //############################################################################
   50141             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   50142             :  * memory pool and initializes the data member in class SgOmpUnifiedSharedMemoryClauseStroageClass
   50143             :  * from its counterpart of SgOmpUnifiedSharedMemoryClause. The return value is just for checking, 
   50144             :  * that the whole StorageClassArray is initialized!
   50145             :  */
   50146             : unsigned long
   50147           0 : SgOmpUnifiedSharedMemoryClause::initializeStorageClassArray( SgOmpUnifiedSharedMemoryClauseStorageClass *storageArray )
   50148             :    {
   50149           0 :      unsigned long storageCounter = 0;
   50150           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUnifiedSharedMemoryClause::pools.begin();
   50151           0 :      SgOmpUnifiedSharedMemoryClause* pointer = NULL;
   50152           0 :      while ( block != SgOmpUnifiedSharedMemoryClause::pools.end() ) {
   50153           0 :           pointer = (SgOmpUnifiedSharedMemoryClause*) (*block);
   50154           0 :           for ( unsigned i = 0; i < SgOmpUnifiedSharedMemoryClause::pool_size; ++i ) {
   50155           0 :                if ( pointer->get_freepointer() != NULL ) {
   50156           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   50157           0 :                  storageArray++;
   50158           0 :                  storageCounter++;
   50159             :                }
   50160           0 :                pointer++;
   50161             :              }
   50162           0 :            block++;
   50163             :         }
   50164           0 :      return storageCounter;
   50165             :    }
   50166             : 
   50167             : /* #line 50168 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   50168             : 
   50169             : 
   50170             : 
   50171             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   50172             : 
   50173             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   50174             : 
   50175             : //############################################################################
   50176             : /* JH (02/02/2006) Constructor of the IR node SgOmpDynamicAllocatorsClause that takes its 
   50177             :  * corresponding StorageClass as parameter
   50178             :  */
   50179           0 : SgOmpDynamicAllocatorsClause :: SgOmpDynamicAllocatorsClause ( const SgOmpDynamicAllocatorsClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   50180             :    {
   50181             : 
   50182             : 
   50183             : /* #line 50184 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   50184             : 
   50185           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   50186             : 
   50187             : 
   50188             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   50189             : 
   50190             : 
   50191           0 :    }
   50192             : 
   50193             : //############################################################################
   50194             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   50195             :  * within the working AST. 
   50196             :  */
   50197           0 : SgOmpDynamicAllocatorsClause * SgOmpDynamicAllocatorsClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   50198           0 :      SgOmpDynamicAllocatorsClause* returnPointer = NULL;
   50199           0 :      if ( globalIndex != 0 )
   50200             :         {
   50201             : 
   50202             : #if FILE_IO_EXTRA_CHECK
   50203           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDynamicAllocatorsClause ) ) <= globalIndex ) ;
   50204           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDynamicAllocatorsClause + 1 ) ) );
   50205             : #endif
   50206           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDynamicAllocatorsClause )  
   50207           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDynamicAllocatorsClause );
   50208           0 :           unsigned long positionInPool = localIndex % SgOmpDynamicAllocatorsClause::pool_size;
   50209           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDynamicAllocatorsClause::pool_size;
   50210             : 
   50211             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   50212             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   50213             : 
   50214           0 :           returnPointer = &( ( (SgOmpDynamicAllocatorsClause*)(SgOmpDynamicAllocatorsClause::pools[memoryBlock]) ) [positionInPool]) ;
   50215             : 
   50216           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   50217             :         }
   50218           0 :      return returnPointer ;
   50219             :    }
   50220             : 
   50221             : //############################################################################
   50222             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   50223             :   for the AST with the index astIndex
   50224             : */
   50225           0 : SgOmpDynamicAllocatorsClause * SgOmpDynamicAllocatorsClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   50226           0 :      SgOmpDynamicAllocatorsClause* returnPointer = NULL;
   50227           0 :      if ( globalIndex != 0 )
   50228             :         {
   50229             : 
   50230             : #if FILE_IO_EXTRA_CHECK
   50231           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDynamicAllocatorsClause ) ) <= globalIndex ) ;
   50232           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDynamicAllocatorsClause + 1 ) ) );
   50233             : #endif
   50234           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDynamicAllocatorsClause )
   50235           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDynamicAllocatorsClause );
   50236           0 :           unsigned long positionInPool = localIndex % SgOmpDynamicAllocatorsClause::pool_size ;
   50237           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDynamicAllocatorsClause::pool_size ;
   50238             : 
   50239             : #if FILE_IO_EXTRA_CHECK
   50240             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   50241             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   50242             : #endif
   50243             : 
   50244           0 :           returnPointer = &( ( (SgOmpDynamicAllocatorsClause*)(SgOmpDynamicAllocatorsClause::pools[memoryBlock]) ) [positionInPool]) ;
   50245             : 
   50246             : #if FILE_IO_EXTRA_CHECK
   50247           0 :           assert ( returnPointer != NULL ) ;
   50248             : #endif
   50249             :         }
   50250           0 :      return returnPointer ;
   50251             :    }
   50252             : 
   50253             : //############################################################################
   50254             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   50255             :  * pool size! We set for every valid object in the memory pool the freepointer
   50256             :  * to the global index and increase the global index afterwards. For all the 
   50257             :  * invalid objects (means address ranges within the memory pool that were not
   50258             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   50259             :  * distinguish valid from invalid objects! 
   50260             :  */
   50261             : unsigned long
   50262           5 : SgOmpDynamicAllocatorsClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   50263             :    {
   50264           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   50265           5 :      SgOmpDynamicAllocatorsClause* pointer = NULL;
   50266           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   50267           5 :      std::vector < unsigned char* > :: const_iterator block;
   50268           5 :      for ( block = SgOmpDynamicAllocatorsClause::pools.begin(); block != SgOmpDynamicAllocatorsClause::pools.end() ; ++block )
   50269             :         {
   50270           0 :           pointer = (SgOmpDynamicAllocatorsClause*)(*block);
   50271           0 :           for (unsigned i = 0; i < SgOmpDynamicAllocatorsClause::pool_size; ++i )
   50272             :              {
   50273             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   50274             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   50275             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   50276             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   50277             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   50278             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   50279             :             // properly; so this will have to be checked next.
   50280             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   50281             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   50282           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   50283             :                   {
   50284           0 :                     pointer[i].set_freepointer((SgOmpDynamicAllocatorsClause*)(globalIndex));
   50285           0 :                     globalIndex++;
   50286             :                   }
   50287             :                else
   50288             :                   {
   50289           0 :                     pointer[i].set_freepointer(NULL);
   50290             :                   }
   50291             :               }
   50292             :         }
   50293           5 :      return globalIndex;
   50294             :    }
   50295             : 
   50296             : //############################################################################
   50297             : // JH (01/14/2006)
   50298             : void
   50299           5 : SgOmpDynamicAllocatorsClause::resetValidFreepointers( )
   50300             :    {
   50301           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   50302           5 :      SgOmpDynamicAllocatorsClause* pointer = NULL;
   50303           5 :      std::vector < unsigned char* > :: const_iterator block;
   50304           5 :      SgOmpDynamicAllocatorsClause* pointerOfLinkedList = NULL;
   50305           5 :      for ( block = SgOmpDynamicAllocatorsClause::pools.begin(); block != SgOmpDynamicAllocatorsClause::pools.end() ; ++block )
   50306             :         {
   50307           0 :           pointer = (SgOmpDynamicAllocatorsClause*)(*block);
   50308           0 :           for (unsigned i = 0; i < SgOmpDynamicAllocatorsClause::pool_size; ++i )
   50309             :              {
   50310             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   50311             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   50312             :             // memory blocks!.
   50313           0 :                if ( pointer[i].get_freepointer() != NULL )
   50314             :                   {
   50315           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   50316             :                   }
   50317             :                else
   50318             :                   {
   50319           0 :                     if ( pointerOfLinkedList == NULL )
   50320             :                        {
   50321           0 :                          SgOmpDynamicAllocatorsClause::next_node = &(pointer[i]);
   50322             :                        }
   50323             :                     else
   50324             :                        {
   50325             :                       // printf ("In SgOmpDynamicAllocatorsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   50326           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   50327             :                        }
   50328             :                     pointerOfLinkedList = &(pointer[i]);
   50329             :                   }
   50330             :               }
   50331             :         }
   50332             : 
   50333           5 :      if ( pointerOfLinkedList != NULL )
   50334             :         {
   50335             :        // printf ("In SgOmpDynamicAllocatorsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   50336           0 :           pointerOfLinkedList->set_freepointer(NULL);
   50337             :        // DQ (6/6/2010): Temporary debugging...
   50338             :        //   ROSE_ASSERT(false);
   50339             :         }
   50340             : 
   50341           5 :      return ;
   50342             :    }
   50343             : 
   50344             : //############################################################################
   50345             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   50346             :  * within the memory pool and resets the freepointers, in order to achieve a 
   50347             :  * linked list, that has no jumps and starts at the beginning! This function 
   50348             :  * does not extend the memory pool, since we do not delete any memory blocks,
   50349             :  * but delete the valid objects.  
   50350             :  */
   50351             : void
   50352           0 : SgOmpDynamicAllocatorsClause::clearMemoryPool( )
   50353             :    {
   50354             :   // printf ("Inside of SgOmpDynamicAllocatorsClause::clearMemoryPool() \n");
   50355             : 
   50356           0 :      SgOmpDynamicAllocatorsClause* pointer = NULL, *tempPointer = NULL;
   50357           0 :      std::vector < unsigned char* > :: const_iterator block;
   50358           0 :      if ( SgOmpDynamicAllocatorsClause::pools.empty() == false )
   50359             :         {
   50360           0 :           block = SgOmpDynamicAllocatorsClause::pools.begin() ;
   50361           0 :           SgOmpDynamicAllocatorsClause::next_node = (SgOmpDynamicAllocatorsClause*) (*block);
   50362             : 
   50363           0 :           while ( block != SgOmpDynamicAllocatorsClause::pools.end() )
   50364             :              {
   50365           0 :                pointer = (SgOmpDynamicAllocatorsClause*) (*block);
   50366           0 :                if ( tempPointer != NULL )
   50367             :                   {
   50368           0 :                     tempPointer->set_freepointer(pointer);
   50369             :                   }
   50370           0 :                for (unsigned i = 0; i < SgOmpDynamicAllocatorsClause::pool_size - 1; ++i)
   50371             :                   {
   50372           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   50373             :                   }
   50374           0 :                 pointer[SgOmpDynamicAllocatorsClause::pool_size-1].set_freepointer(NULL);
   50375           0 :                 tempPointer = &(pointer[SgOmpDynamicAllocatorsClause::pool_size-1]);
   50376           0 :                 ++block;
   50377             :              }
   50378             :         }
   50379           0 :    }
   50380             : 
   50381           5 : void SgOmpDynamicAllocatorsClause::deleteMemoryPool() {
   50382           5 :   for (auto p: SgOmpDynamicAllocatorsClause::pools) {
   50383           0 :     ROSE_FREE(p);
   50384             :   }
   50385           5 :   SgOmpDynamicAllocatorsClause::next_node = nullptr;
   50386           5 :   SgOmpDynamicAllocatorsClause::pools.clear();
   50387           5 : }
   50388             : 
   50389             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   50390             : //                 reading multiple binary files to for a single AST.
   50391             : /////////// new version ////////////////////////////////
   50392             : //############################################################################
   50393             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   50394             : void
   50395           2 : SgOmpDynamicAllocatorsClause::extendMemoryPoolForFileIO( )
   50396             :   {
   50397           2 :     size_t blockIndex = SgOmpDynamicAllocatorsClause::pools.size();
   50398           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDynamicAllocatorsClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDynamicAllocatorsClause);
   50399             : 
   50400           2 :     while ( (blockIndex * SgOmpDynamicAllocatorsClause::pool_size) < newPoolSize)
   50401             :       {
   50402             : #if ROSE_ALLOC_TRACE
   50403             :         if (blockIndex > 0) {
   50404             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDynamicAllocatorsClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDynamicAllocatorsClause) = %" PRIuPTR " SgOmpDynamicAllocatorsClause::pool_size = %d \n",
   50405             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDynamicAllocatorsClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDynamicAllocatorsClause),SgOmpDynamicAllocatorsClause::pool_size);
   50406             :         }
   50407             : #endif
   50408             : 
   50409           0 :         SgOmpDynamicAllocatorsClause * pointer = (SgOmpDynamicAllocatorsClause*) ROSE_MALLOC ( SgOmpDynamicAllocatorsClause::pool_size * sizeof(SgOmpDynamicAllocatorsClause) );
   50410           0 :         assert( pointer != NULL );
   50411             : #if ROSE_ALLOC_MEMSET == 1
   50412             :         memset(pointer, 0x00, SgOmpDynamicAllocatorsClause::pool_size * sizeof(SgOmpDynamicAllocatorsClause));
   50413             : #elif ROSE_ALLOC_MEMSET == 2
   50414             :         memset(pointer, 0xCC, SgOmpDynamicAllocatorsClause::pool_size * sizeof(SgOmpDynamicAllocatorsClause));
   50415             : #endif
   50416           0 :         SgOmpDynamicAllocatorsClause::pools.push_back( (unsigned char*)(pointer) );
   50417           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDynamicAllocatorsClause::pool_size * sizeof(SgOmpDynamicAllocatorsClause), V_SgOmpDynamicAllocatorsClause ) );
   50418             : 
   50419           0 :         if ( SgOmpDynamicAllocatorsClause::next_node != NULL ) {
   50420           0 :           if ( blockIndex > 0 ) {
   50421           0 :             SgOmpDynamicAllocatorsClause * blkptr = (SgOmpDynamicAllocatorsClause*)(SgOmpDynamicAllocatorsClause::pools[blockIndex-1]);
   50422           0 :             blkptr[ SgOmpDynamicAllocatorsClause::pool_size - 1 ].set_freepointer(pointer);
   50423             :           }
   50424             :         } else {
   50425           0 :           SgOmpDynamicAllocatorsClause::next_node = pointer;
   50426             :         }
   50427             : 
   50428           0 :         for (unsigned i = 0; i < SgOmpDynamicAllocatorsClause::pool_size-1; ++i)
   50429             :            {
   50430           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   50431             :            }
   50432           0 :         pointer[ SgOmpDynamicAllocatorsClause::pool_size -1 ].set_freepointer(NULL);
   50433             : 
   50434           0 :         blockIndex++;
   50435             :       }
   50436           2 :   }
   50437             : 
   50438             : //############################################################################
   50439             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   50440             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   50441             :  * not compressed. However, that stuff is not yet implemented! 
   50442             :  */
   50443             : unsigned long
   50444           0 : SgOmpDynamicAllocatorsClause::getNumberOfLastValidPointer()
   50445             :    {
   50446           0 :       SgOmpDynamicAllocatorsClause* testPointer = (SgOmpDynamicAllocatorsClause*)(SgOmpDynamicAllocatorsClause::pools.back());
   50447           0 :       unsigned long localIndex = SgOmpDynamicAllocatorsClause::pool_size - 1;
   50448           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   50449             :          {
   50450           0 :            localIndex--;
   50451             :          }
   50452           0 :       return (localIndex + SgOmpDynamicAllocatorsClause::pool_size * (SgOmpDynamicAllocatorsClause::pools.size()-1));
   50453             :    }
   50454             : 
   50455             : //############################################################################
   50456             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   50457             :  * memory pool and initializes the data member in class SgOmpDynamicAllocatorsClauseStroageClass
   50458             :  * from its counterpart of SgOmpDynamicAllocatorsClause. The return value is just for checking, 
   50459             :  * that the whole StorageClassArray is initialized!
   50460             :  */
   50461             : unsigned long
   50462           0 : SgOmpDynamicAllocatorsClause::initializeStorageClassArray( SgOmpDynamicAllocatorsClauseStorageClass *storageArray )
   50463             :    {
   50464           0 :      unsigned long storageCounter = 0;
   50465           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDynamicAllocatorsClause::pools.begin();
   50466           0 :      SgOmpDynamicAllocatorsClause* pointer = NULL;
   50467           0 :      while ( block != SgOmpDynamicAllocatorsClause::pools.end() ) {
   50468           0 :           pointer = (SgOmpDynamicAllocatorsClause*) (*block);
   50469           0 :           for ( unsigned i = 0; i < SgOmpDynamicAllocatorsClause::pool_size; ++i ) {
   50470           0 :                if ( pointer->get_freepointer() != NULL ) {
   50471           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   50472           0 :                  storageArray++;
   50473           0 :                  storageCounter++;
   50474             :                }
   50475           0 :                pointer++;
   50476             :              }
   50477           0 :            block++;
   50478             :         }
   50479           0 :      return storageCounter;
   50480             :    }
   50481             : 
   50482             : /* #line 50483 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   50483             : 
   50484             : 
   50485             : 
   50486             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   50487             : 
   50488             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   50489             : 
   50490             : //############################################################################
   50491             : /* JH (02/02/2006) Constructor of the IR node SgOmpParallelClause that takes its 
   50492             :  * corresponding StorageClass as parameter
   50493             :  */
   50494           0 : SgOmpParallelClause :: SgOmpParallelClause ( const SgOmpParallelClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   50495             :    {
   50496             : 
   50497             : 
   50498             : /* #line 50499 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   50499             : 
   50500           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   50501             : 
   50502             : 
   50503             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   50504             : 
   50505             : 
   50506           0 :    }
   50507             : 
   50508             : //############################################################################
   50509             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   50510             :  * within the working AST. 
   50511             :  */
   50512           0 : SgOmpParallelClause * SgOmpParallelClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   50513           0 :      SgOmpParallelClause* returnPointer = NULL;
   50514           0 :      if ( globalIndex != 0 )
   50515             :         {
   50516             : 
   50517             : #if FILE_IO_EXTRA_CHECK
   50518           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpParallelClause ) ) <= globalIndex ) ;
   50519           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelClause + 1 ) ) );
   50520             : #endif
   50521           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelClause )  
   50522           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpParallelClause );
   50523           0 :           unsigned long positionInPool = localIndex % SgOmpParallelClause::pool_size;
   50524           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelClause::pool_size;
   50525             : 
   50526             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   50527             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   50528             : 
   50529           0 :           returnPointer = &( ( (SgOmpParallelClause*)(SgOmpParallelClause::pools[memoryBlock]) ) [positionInPool]) ;
   50530             : 
   50531           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   50532             :         }
   50533           0 :      return returnPointer ;
   50534             :    }
   50535             : 
   50536             : //############################################################################
   50537             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   50538             :   for the AST with the index astIndex
   50539             : */
   50540           0 : SgOmpParallelClause * SgOmpParallelClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   50541           0 :      SgOmpParallelClause* returnPointer = NULL;
   50542           0 :      if ( globalIndex != 0 )
   50543             :         {
   50544             : 
   50545             : #if FILE_IO_EXTRA_CHECK
   50546           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpParallelClause ) ) <= globalIndex ) ;
   50547           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelClause + 1 ) ) );
   50548             : #endif
   50549           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelClause )
   50550           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpParallelClause );
   50551           0 :           unsigned long positionInPool = localIndex % SgOmpParallelClause::pool_size ;
   50552           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelClause::pool_size ;
   50553             : 
   50554             : #if FILE_IO_EXTRA_CHECK
   50555             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   50556             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   50557             : #endif
   50558             : 
   50559           0 :           returnPointer = &( ( (SgOmpParallelClause*)(SgOmpParallelClause::pools[memoryBlock]) ) [positionInPool]) ;
   50560             : 
   50561             : #if FILE_IO_EXTRA_CHECK
   50562           0 :           assert ( returnPointer != NULL ) ;
   50563             : #endif
   50564             :         }
   50565           0 :      return returnPointer ;
   50566             :    }
   50567             : 
   50568             : //############################################################################
   50569             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   50570             :  * pool size! We set for every valid object in the memory pool the freepointer
   50571             :  * to the global index and increase the global index afterwards. For all the 
   50572             :  * invalid objects (means address ranges within the memory pool that were not
   50573             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   50574             :  * distinguish valid from invalid objects! 
   50575             :  */
   50576             : unsigned long
   50577           5 : SgOmpParallelClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   50578             :    {
   50579           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   50580           5 :      SgOmpParallelClause* pointer = NULL;
   50581           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   50582           5 :      std::vector < unsigned char* > :: const_iterator block;
   50583           5 :      for ( block = SgOmpParallelClause::pools.begin(); block != SgOmpParallelClause::pools.end() ; ++block )
   50584             :         {
   50585           0 :           pointer = (SgOmpParallelClause*)(*block);
   50586           0 :           for (unsigned i = 0; i < SgOmpParallelClause::pool_size; ++i )
   50587             :              {
   50588             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   50589             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   50590             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   50591             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   50592             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   50593             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   50594             :             // properly; so this will have to be checked next.
   50595             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   50596             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   50597           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   50598             :                   {
   50599           0 :                     pointer[i].set_freepointer((SgOmpParallelClause*)(globalIndex));
   50600           0 :                     globalIndex++;
   50601             :                   }
   50602             :                else
   50603             :                   {
   50604           0 :                     pointer[i].set_freepointer(NULL);
   50605             :                   }
   50606             :               }
   50607             :         }
   50608           5 :      return globalIndex;
   50609             :    }
   50610             : 
   50611             : //############################################################################
   50612             : // JH (01/14/2006)
   50613             : void
   50614           5 : SgOmpParallelClause::resetValidFreepointers( )
   50615             :    {
   50616           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   50617           5 :      SgOmpParallelClause* pointer = NULL;
   50618           5 :      std::vector < unsigned char* > :: const_iterator block;
   50619           5 :      SgOmpParallelClause* pointerOfLinkedList = NULL;
   50620           5 :      for ( block = SgOmpParallelClause::pools.begin(); block != SgOmpParallelClause::pools.end() ; ++block )
   50621             :         {
   50622           0 :           pointer = (SgOmpParallelClause*)(*block);
   50623           0 :           for (unsigned i = 0; i < SgOmpParallelClause::pool_size; ++i )
   50624             :              {
   50625             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   50626             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   50627             :             // memory blocks!.
   50628           0 :                if ( pointer[i].get_freepointer() != NULL )
   50629             :                   {
   50630           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   50631             :                   }
   50632             :                else
   50633             :                   {
   50634           0 :                     if ( pointerOfLinkedList == NULL )
   50635             :                        {
   50636           0 :                          SgOmpParallelClause::next_node = &(pointer[i]);
   50637             :                        }
   50638             :                     else
   50639             :                        {
   50640             :                       // printf ("In SgOmpParallelClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   50641           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   50642             :                        }
   50643             :                     pointerOfLinkedList = &(pointer[i]);
   50644             :                   }
   50645             :               }
   50646             :         }
   50647             : 
   50648           5 :      if ( pointerOfLinkedList != NULL )
   50649             :         {
   50650             :        // printf ("In SgOmpParallelClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   50651           0 :           pointerOfLinkedList->set_freepointer(NULL);
   50652             :        // DQ (6/6/2010): Temporary debugging...
   50653             :        //   ROSE_ASSERT(false);
   50654             :         }
   50655             : 
   50656           5 :      return ;
   50657             :    }
   50658             : 
   50659             : //############################################################################
   50660             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   50661             :  * within the memory pool and resets the freepointers, in order to achieve a 
   50662             :  * linked list, that has no jumps and starts at the beginning! This function 
   50663             :  * does not extend the memory pool, since we do not delete any memory blocks,
   50664             :  * but delete the valid objects.  
   50665             :  */
   50666             : void
   50667           0 : SgOmpParallelClause::clearMemoryPool( )
   50668             :    {
   50669             :   // printf ("Inside of SgOmpParallelClause::clearMemoryPool() \n");
   50670             : 
   50671           0 :      SgOmpParallelClause* pointer = NULL, *tempPointer = NULL;
   50672           0 :      std::vector < unsigned char* > :: const_iterator block;
   50673           0 :      if ( SgOmpParallelClause::pools.empty() == false )
   50674             :         {
   50675           0 :           block = SgOmpParallelClause::pools.begin() ;
   50676           0 :           SgOmpParallelClause::next_node = (SgOmpParallelClause*) (*block);
   50677             : 
   50678           0 :           while ( block != SgOmpParallelClause::pools.end() )
   50679             :              {
   50680           0 :                pointer = (SgOmpParallelClause*) (*block);
   50681           0 :                if ( tempPointer != NULL )
   50682             :                   {
   50683           0 :                     tempPointer->set_freepointer(pointer);
   50684             :                   }
   50685           0 :                for (unsigned i = 0; i < SgOmpParallelClause::pool_size - 1; ++i)
   50686             :                   {
   50687           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   50688             :                   }
   50689           0 :                 pointer[SgOmpParallelClause::pool_size-1].set_freepointer(NULL);
   50690           0 :                 tempPointer = &(pointer[SgOmpParallelClause::pool_size-1]);
   50691           0 :                 ++block;
   50692             :              }
   50693             :         }
   50694           0 :    }
   50695             : 
   50696           5 : void SgOmpParallelClause::deleteMemoryPool() {
   50697           5 :   for (auto p: SgOmpParallelClause::pools) {
   50698           0 :     ROSE_FREE(p);
   50699             :   }
   50700           5 :   SgOmpParallelClause::next_node = nullptr;
   50701           5 :   SgOmpParallelClause::pools.clear();
   50702           5 : }
   50703             : 
   50704             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   50705             : //                 reading multiple binary files to for a single AST.
   50706             : /////////// new version ////////////////////////////////
   50707             : //############################################################################
   50708             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   50709             : void
   50710           2 : SgOmpParallelClause::extendMemoryPoolForFileIO( )
   50711             :   {
   50712           2 :     size_t blockIndex = SgOmpParallelClause::pools.size();
   50713           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelClause);
   50714             : 
   50715           2 :     while ( (blockIndex * SgOmpParallelClause::pool_size) < newPoolSize)
   50716             :       {
   50717             : #if ROSE_ALLOC_TRACE
   50718             :         if (blockIndex > 0) {
   50719             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelClause) = %" PRIuPTR " SgOmpParallelClause::pool_size = %d \n",
   50720             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelClause),SgOmpParallelClause::pool_size);
   50721             :         }
   50722             : #endif
   50723             : 
   50724           0 :         SgOmpParallelClause * pointer = (SgOmpParallelClause*) ROSE_MALLOC ( SgOmpParallelClause::pool_size * sizeof(SgOmpParallelClause) );
   50725           0 :         assert( pointer != NULL );
   50726             : #if ROSE_ALLOC_MEMSET == 1
   50727             :         memset(pointer, 0x00, SgOmpParallelClause::pool_size * sizeof(SgOmpParallelClause));
   50728             : #elif ROSE_ALLOC_MEMSET == 2
   50729             :         memset(pointer, 0xCC, SgOmpParallelClause::pool_size * sizeof(SgOmpParallelClause));
   50730             : #endif
   50731           0 :         SgOmpParallelClause::pools.push_back( (unsigned char*)(pointer) );
   50732           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpParallelClause::pool_size * sizeof(SgOmpParallelClause), V_SgOmpParallelClause ) );
   50733             : 
   50734           0 :         if ( SgOmpParallelClause::next_node != NULL ) {
   50735           0 :           if ( blockIndex > 0 ) {
   50736           0 :             SgOmpParallelClause * blkptr = (SgOmpParallelClause*)(SgOmpParallelClause::pools[blockIndex-1]);
   50737           0 :             blkptr[ SgOmpParallelClause::pool_size - 1 ].set_freepointer(pointer);
   50738             :           }
   50739             :         } else {
   50740           0 :           SgOmpParallelClause::next_node = pointer;
   50741             :         }
   50742             : 
   50743           0 :         for (unsigned i = 0; i < SgOmpParallelClause::pool_size-1; ++i)
   50744             :            {
   50745           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   50746             :            }
   50747           0 :         pointer[ SgOmpParallelClause::pool_size -1 ].set_freepointer(NULL);
   50748             : 
   50749           0 :         blockIndex++;
   50750             :       }
   50751           2 :   }
   50752             : 
   50753             : //############################################################################
   50754             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   50755             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   50756             :  * not compressed. However, that stuff is not yet implemented! 
   50757             :  */
   50758             : unsigned long
   50759           0 : SgOmpParallelClause::getNumberOfLastValidPointer()
   50760             :    {
   50761           0 :       SgOmpParallelClause* testPointer = (SgOmpParallelClause*)(SgOmpParallelClause::pools.back());
   50762           0 :       unsigned long localIndex = SgOmpParallelClause::pool_size - 1;
   50763           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   50764             :          {
   50765           0 :            localIndex--;
   50766             :          }
   50767           0 :       return (localIndex + SgOmpParallelClause::pool_size * (SgOmpParallelClause::pools.size()-1));
   50768             :    }
   50769             : 
   50770             : //############################################################################
   50771             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   50772             :  * memory pool and initializes the data member in class SgOmpParallelClauseStroageClass
   50773             :  * from its counterpart of SgOmpParallelClause. The return value is just for checking, 
   50774             :  * that the whole StorageClassArray is initialized!
   50775             :  */
   50776             : unsigned long
   50777           0 : SgOmpParallelClause::initializeStorageClassArray( SgOmpParallelClauseStorageClass *storageArray )
   50778             :    {
   50779           0 :      unsigned long storageCounter = 0;
   50780           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpParallelClause::pools.begin();
   50781           0 :      SgOmpParallelClause* pointer = NULL;
   50782           0 :      while ( block != SgOmpParallelClause::pools.end() ) {
   50783           0 :           pointer = (SgOmpParallelClause*) (*block);
   50784           0 :           for ( unsigned i = 0; i < SgOmpParallelClause::pool_size; ++i ) {
   50785           0 :                if ( pointer->get_freepointer() != NULL ) {
   50786           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   50787           0 :                  storageArray++;
   50788           0 :                  storageCounter++;
   50789             :                }
   50790           0 :                pointer++;
   50791             :              }
   50792           0 :            block++;
   50793             :         }
   50794           0 :      return storageCounter;
   50795             :    }
   50796             : 
   50797             : /* #line 50798 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   50798             : 
   50799             : 
   50800             : 
   50801             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   50802             : 
   50803             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   50804             : 
   50805             : //############################################################################
   50806             : /* JH (02/02/2006) Constructor of the IR node SgOmpSectionsClause that takes its 
   50807             :  * corresponding StorageClass as parameter
   50808             :  */
   50809           0 : SgOmpSectionsClause :: SgOmpSectionsClause ( const SgOmpSectionsClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   50810             :    {
   50811             : 
   50812             : 
   50813             : /* #line 50814 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   50814             : 
   50815           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   50816             : 
   50817             : 
   50818             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   50819             : 
   50820             : 
   50821           0 :    }
   50822             : 
   50823             : //############################################################################
   50824             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   50825             :  * within the working AST. 
   50826             :  */
   50827           0 : SgOmpSectionsClause * SgOmpSectionsClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   50828           0 :      SgOmpSectionsClause* returnPointer = NULL;
   50829           0 :      if ( globalIndex != 0 )
   50830             :         {
   50831             : 
   50832             : #if FILE_IO_EXTRA_CHECK
   50833           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSectionsClause ) ) <= globalIndex ) ;
   50834           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSectionsClause + 1 ) ) );
   50835             : #endif
   50836           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSectionsClause )  
   50837           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSectionsClause );
   50838           0 :           unsigned long positionInPool = localIndex % SgOmpSectionsClause::pool_size;
   50839           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSectionsClause::pool_size;
   50840             : 
   50841             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   50842             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   50843             : 
   50844           0 :           returnPointer = &( ( (SgOmpSectionsClause*)(SgOmpSectionsClause::pools[memoryBlock]) ) [positionInPool]) ;
   50845             : 
   50846           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   50847             :         }
   50848           0 :      return returnPointer ;
   50849             :    }
   50850             : 
   50851             : //############################################################################
   50852             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   50853             :   for the AST with the index astIndex
   50854             : */
   50855           0 : SgOmpSectionsClause * SgOmpSectionsClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   50856           0 :      SgOmpSectionsClause* returnPointer = NULL;
   50857           0 :      if ( globalIndex != 0 )
   50858             :         {
   50859             : 
   50860             : #if FILE_IO_EXTRA_CHECK
   50861           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSectionsClause ) ) <= globalIndex ) ;
   50862           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSectionsClause + 1 ) ) );
   50863             : #endif
   50864           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSectionsClause )
   50865           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSectionsClause );
   50866           0 :           unsigned long positionInPool = localIndex % SgOmpSectionsClause::pool_size ;
   50867           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSectionsClause::pool_size ;
   50868             : 
   50869             : #if FILE_IO_EXTRA_CHECK
   50870             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   50871             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   50872             : #endif
   50873             : 
   50874           0 :           returnPointer = &( ( (SgOmpSectionsClause*)(SgOmpSectionsClause::pools[memoryBlock]) ) [positionInPool]) ;
   50875             : 
   50876             : #if FILE_IO_EXTRA_CHECK
   50877           0 :           assert ( returnPointer != NULL ) ;
   50878             : #endif
   50879             :         }
   50880           0 :      return returnPointer ;
   50881             :    }
   50882             : 
   50883             : //############################################################################
   50884             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   50885             :  * pool size! We set for every valid object in the memory pool the freepointer
   50886             :  * to the global index and increase the global index afterwards. For all the 
   50887             :  * invalid objects (means address ranges within the memory pool that were not
   50888             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   50889             :  * distinguish valid from invalid objects! 
   50890             :  */
   50891             : unsigned long
   50892           5 : SgOmpSectionsClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   50893             :    {
   50894           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   50895           5 :      SgOmpSectionsClause* pointer = NULL;
   50896           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   50897           5 :      std::vector < unsigned char* > :: const_iterator block;
   50898           5 :      for ( block = SgOmpSectionsClause::pools.begin(); block != SgOmpSectionsClause::pools.end() ; ++block )
   50899             :         {
   50900           0 :           pointer = (SgOmpSectionsClause*)(*block);
   50901           0 :           for (unsigned i = 0; i < SgOmpSectionsClause::pool_size; ++i )
   50902             :              {
   50903             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   50904             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   50905             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   50906             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   50907             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   50908             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   50909             :             // properly; so this will have to be checked next.
   50910             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   50911             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   50912           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   50913             :                   {
   50914           0 :                     pointer[i].set_freepointer((SgOmpSectionsClause*)(globalIndex));
   50915           0 :                     globalIndex++;
   50916             :                   }
   50917             :                else
   50918             :                   {
   50919           0 :                     pointer[i].set_freepointer(NULL);
   50920             :                   }
   50921             :               }
   50922             :         }
   50923           5 :      return globalIndex;
   50924             :    }
   50925             : 
   50926             : //############################################################################
   50927             : // JH (01/14/2006)
   50928             : void
   50929           5 : SgOmpSectionsClause::resetValidFreepointers( )
   50930             :    {
   50931           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   50932           5 :      SgOmpSectionsClause* pointer = NULL;
   50933           5 :      std::vector < unsigned char* > :: const_iterator block;
   50934           5 :      SgOmpSectionsClause* pointerOfLinkedList = NULL;
   50935           5 :      for ( block = SgOmpSectionsClause::pools.begin(); block != SgOmpSectionsClause::pools.end() ; ++block )
   50936             :         {
   50937           0 :           pointer = (SgOmpSectionsClause*)(*block);
   50938           0 :           for (unsigned i = 0; i < SgOmpSectionsClause::pool_size; ++i )
   50939             :              {
   50940             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   50941             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   50942             :             // memory blocks!.
   50943           0 :                if ( pointer[i].get_freepointer() != NULL )
   50944             :                   {
   50945           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   50946             :                   }
   50947             :                else
   50948             :                   {
   50949           0 :                     if ( pointerOfLinkedList == NULL )
   50950             :                        {
   50951           0 :                          SgOmpSectionsClause::next_node = &(pointer[i]);
   50952             :                        }
   50953             :                     else
   50954             :                        {
   50955             :                       // printf ("In SgOmpSectionsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   50956           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   50957             :                        }
   50958             :                     pointerOfLinkedList = &(pointer[i]);
   50959             :                   }
   50960             :               }
   50961             :         }
   50962             : 
   50963           5 :      if ( pointerOfLinkedList != NULL )
   50964             :         {
   50965             :        // printf ("In SgOmpSectionsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   50966           0 :           pointerOfLinkedList->set_freepointer(NULL);
   50967             :        // DQ (6/6/2010): Temporary debugging...
   50968             :        //   ROSE_ASSERT(false);
   50969             :         }
   50970             : 
   50971           5 :      return ;
   50972             :    }
   50973             : 
   50974             : //############################################################################
   50975             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   50976             :  * within the memory pool and resets the freepointers, in order to achieve a 
   50977             :  * linked list, that has no jumps and starts at the beginning! This function 
   50978             :  * does not extend the memory pool, since we do not delete any memory blocks,
   50979             :  * but delete the valid objects.  
   50980             :  */
   50981             : void
   50982           0 : SgOmpSectionsClause::clearMemoryPool( )
   50983             :    {
   50984             :   // printf ("Inside of SgOmpSectionsClause::clearMemoryPool() \n");
   50985             : 
   50986           0 :      SgOmpSectionsClause* pointer = NULL, *tempPointer = NULL;
   50987           0 :      std::vector < unsigned char* > :: const_iterator block;
   50988           0 :      if ( SgOmpSectionsClause::pools.empty() == false )
   50989             :         {
   50990           0 :           block = SgOmpSectionsClause::pools.begin() ;
   50991           0 :           SgOmpSectionsClause::next_node = (SgOmpSectionsClause*) (*block);
   50992             : 
   50993           0 :           while ( block != SgOmpSectionsClause::pools.end() )
   50994             :              {
   50995           0 :                pointer = (SgOmpSectionsClause*) (*block);
   50996           0 :                if ( tempPointer != NULL )
   50997             :                   {
   50998           0 :                     tempPointer->set_freepointer(pointer);
   50999             :                   }
   51000           0 :                for (unsigned i = 0; i < SgOmpSectionsClause::pool_size - 1; ++i)
   51001             :                   {
   51002           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   51003             :                   }
   51004           0 :                 pointer[SgOmpSectionsClause::pool_size-1].set_freepointer(NULL);
   51005           0 :                 tempPointer = &(pointer[SgOmpSectionsClause::pool_size-1]);
   51006           0 :                 ++block;
   51007             :              }
   51008             :         }
   51009           0 :    }
   51010             : 
   51011           5 : void SgOmpSectionsClause::deleteMemoryPool() {
   51012           5 :   for (auto p: SgOmpSectionsClause::pools) {
   51013           0 :     ROSE_FREE(p);
   51014             :   }
   51015           5 :   SgOmpSectionsClause::next_node = nullptr;
   51016           5 :   SgOmpSectionsClause::pools.clear();
   51017           5 : }
   51018             : 
   51019             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   51020             : //                 reading multiple binary files to for a single AST.
   51021             : /////////// new version ////////////////////////////////
   51022             : //############################################################################
   51023             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   51024             : void
   51025           2 : SgOmpSectionsClause::extendMemoryPoolForFileIO( )
   51026             :   {
   51027           2 :     size_t blockIndex = SgOmpSectionsClause::pools.size();
   51028           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionsClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionsClause);
   51029             : 
   51030           2 :     while ( (blockIndex * SgOmpSectionsClause::pool_size) < newPoolSize)
   51031             :       {
   51032             : #if ROSE_ALLOC_TRACE
   51033             :         if (blockIndex > 0) {
   51034             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionsClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionsClause) = %" PRIuPTR " SgOmpSectionsClause::pool_size = %d \n",
   51035             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionsClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionsClause),SgOmpSectionsClause::pool_size);
   51036             :         }
   51037             : #endif
   51038             : 
   51039           0 :         SgOmpSectionsClause * pointer = (SgOmpSectionsClause*) ROSE_MALLOC ( SgOmpSectionsClause::pool_size * sizeof(SgOmpSectionsClause) );
   51040           0 :         assert( pointer != NULL );
   51041             : #if ROSE_ALLOC_MEMSET == 1
   51042             :         memset(pointer, 0x00, SgOmpSectionsClause::pool_size * sizeof(SgOmpSectionsClause));
   51043             : #elif ROSE_ALLOC_MEMSET == 2
   51044             :         memset(pointer, 0xCC, SgOmpSectionsClause::pool_size * sizeof(SgOmpSectionsClause));
   51045             : #endif
   51046           0 :         SgOmpSectionsClause::pools.push_back( (unsigned char*)(pointer) );
   51047           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSectionsClause::pool_size * sizeof(SgOmpSectionsClause), V_SgOmpSectionsClause ) );
   51048             : 
   51049           0 :         if ( SgOmpSectionsClause::next_node != NULL ) {
   51050           0 :           if ( blockIndex > 0 ) {
   51051           0 :             SgOmpSectionsClause * blkptr = (SgOmpSectionsClause*)(SgOmpSectionsClause::pools[blockIndex-1]);
   51052           0 :             blkptr[ SgOmpSectionsClause::pool_size - 1 ].set_freepointer(pointer);
   51053             :           }
   51054             :         } else {
   51055           0 :           SgOmpSectionsClause::next_node = pointer;
   51056             :         }
   51057             : 
   51058           0 :         for (unsigned i = 0; i < SgOmpSectionsClause::pool_size-1; ++i)
   51059             :            {
   51060           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   51061             :            }
   51062           0 :         pointer[ SgOmpSectionsClause::pool_size -1 ].set_freepointer(NULL);
   51063             : 
   51064           0 :         blockIndex++;
   51065             :       }
   51066           2 :   }
   51067             : 
   51068             : //############################################################################
   51069             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   51070             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   51071             :  * not compressed. However, that stuff is not yet implemented! 
   51072             :  */
   51073             : unsigned long
   51074           0 : SgOmpSectionsClause::getNumberOfLastValidPointer()
   51075             :    {
   51076           0 :       SgOmpSectionsClause* testPointer = (SgOmpSectionsClause*)(SgOmpSectionsClause::pools.back());
   51077           0 :       unsigned long localIndex = SgOmpSectionsClause::pool_size - 1;
   51078           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   51079             :          {
   51080           0 :            localIndex--;
   51081             :          }
   51082           0 :       return (localIndex + SgOmpSectionsClause::pool_size * (SgOmpSectionsClause::pools.size()-1));
   51083             :    }
   51084             : 
   51085             : //############################################################################
   51086             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   51087             :  * memory pool and initializes the data member in class SgOmpSectionsClauseStroageClass
   51088             :  * from its counterpart of SgOmpSectionsClause. The return value is just for checking, 
   51089             :  * that the whole StorageClassArray is initialized!
   51090             :  */
   51091             : unsigned long
   51092           0 : SgOmpSectionsClause::initializeStorageClassArray( SgOmpSectionsClauseStorageClass *storageArray )
   51093             :    {
   51094           0 :      unsigned long storageCounter = 0;
   51095           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSectionsClause::pools.begin();
   51096           0 :      SgOmpSectionsClause* pointer = NULL;
   51097           0 :      while ( block != SgOmpSectionsClause::pools.end() ) {
   51098           0 :           pointer = (SgOmpSectionsClause*) (*block);
   51099           0 :           for ( unsigned i = 0; i < SgOmpSectionsClause::pool_size; ++i ) {
   51100           0 :                if ( pointer->get_freepointer() != NULL ) {
   51101           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   51102           0 :                  storageArray++;
   51103           0 :                  storageCounter++;
   51104             :                }
   51105           0 :                pointer++;
   51106             :              }
   51107           0 :            block++;
   51108             :         }
   51109           0 :      return storageCounter;
   51110             :    }
   51111             : 
   51112             : /* #line 51113 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   51113             : 
   51114             : 
   51115             : 
   51116             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   51117             : 
   51118             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   51119             : 
   51120             : //############################################################################
   51121             : /* JH (02/02/2006) Constructor of the IR node SgOmpForClause that takes its 
   51122             :  * corresponding StorageClass as parameter
   51123             :  */
   51124           0 : SgOmpForClause :: SgOmpForClause ( const SgOmpForClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   51125             :    {
   51126             : 
   51127             : 
   51128             : /* #line 51129 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   51129             : 
   51130           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   51131             : 
   51132             : 
   51133             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   51134             : 
   51135             : 
   51136           0 :    }
   51137             : 
   51138             : //############################################################################
   51139             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   51140             :  * within the working AST. 
   51141             :  */
   51142           0 : SgOmpForClause * SgOmpForClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   51143           0 :      SgOmpForClause* returnPointer = NULL;
   51144           0 :      if ( globalIndex != 0 )
   51145             :         {
   51146             : 
   51147             : #if FILE_IO_EXTRA_CHECK
   51148           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpForClause ) ) <= globalIndex ) ;
   51149           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpForClause + 1 ) ) );
   51150             : #endif
   51151           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpForClause )  
   51152           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpForClause );
   51153           0 :           unsigned long positionInPool = localIndex % SgOmpForClause::pool_size;
   51154           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpForClause::pool_size;
   51155             : 
   51156             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   51157             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   51158             : 
   51159           0 :           returnPointer = &( ( (SgOmpForClause*)(SgOmpForClause::pools[memoryBlock]) ) [positionInPool]) ;
   51160             : 
   51161           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   51162             :         }
   51163           0 :      return returnPointer ;
   51164             :    }
   51165             : 
   51166             : //############################################################################
   51167             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   51168             :   for the AST with the index astIndex
   51169             : */
   51170           0 : SgOmpForClause * SgOmpForClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   51171           0 :      SgOmpForClause* returnPointer = NULL;
   51172           0 :      if ( globalIndex != 0 )
   51173             :         {
   51174             : 
   51175             : #if FILE_IO_EXTRA_CHECK
   51176           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpForClause ) ) <= globalIndex ) ;
   51177           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpForClause + 1 ) ) );
   51178             : #endif
   51179           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpForClause )
   51180           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpForClause );
   51181           0 :           unsigned long positionInPool = localIndex % SgOmpForClause::pool_size ;
   51182           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpForClause::pool_size ;
   51183             : 
   51184             : #if FILE_IO_EXTRA_CHECK
   51185             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   51186             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   51187             : #endif
   51188             : 
   51189           0 :           returnPointer = &( ( (SgOmpForClause*)(SgOmpForClause::pools[memoryBlock]) ) [positionInPool]) ;
   51190             : 
   51191             : #if FILE_IO_EXTRA_CHECK
   51192           0 :           assert ( returnPointer != NULL ) ;
   51193             : #endif
   51194             :         }
   51195           0 :      return returnPointer ;
   51196             :    }
   51197             : 
   51198             : //############################################################################
   51199             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   51200             :  * pool size! We set for every valid object in the memory pool the freepointer
   51201             :  * to the global index and increase the global index afterwards. For all the 
   51202             :  * invalid objects (means address ranges within the memory pool that were not
   51203             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   51204             :  * distinguish valid from invalid objects! 
   51205             :  */
   51206             : unsigned long
   51207           5 : SgOmpForClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   51208             :    {
   51209           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   51210           5 :      SgOmpForClause* pointer = NULL;
   51211           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   51212           5 :      std::vector < unsigned char* > :: const_iterator block;
   51213           5 :      for ( block = SgOmpForClause::pools.begin(); block != SgOmpForClause::pools.end() ; ++block )
   51214             :         {
   51215           0 :           pointer = (SgOmpForClause*)(*block);
   51216           0 :           for (unsigned i = 0; i < SgOmpForClause::pool_size; ++i )
   51217             :              {
   51218             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   51219             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   51220             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   51221             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   51222             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   51223             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   51224             :             // properly; so this will have to be checked next.
   51225             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   51226             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   51227           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   51228             :                   {
   51229           0 :                     pointer[i].set_freepointer((SgOmpForClause*)(globalIndex));
   51230           0 :                     globalIndex++;
   51231             :                   }
   51232             :                else
   51233             :                   {
   51234           0 :                     pointer[i].set_freepointer(NULL);
   51235             :                   }
   51236             :               }
   51237             :         }
   51238           5 :      return globalIndex;
   51239             :    }
   51240             : 
   51241             : //############################################################################
   51242             : // JH (01/14/2006)
   51243             : void
   51244           5 : SgOmpForClause::resetValidFreepointers( )
   51245             :    {
   51246           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   51247           5 :      SgOmpForClause* pointer = NULL;
   51248           5 :      std::vector < unsigned char* > :: const_iterator block;
   51249           5 :      SgOmpForClause* pointerOfLinkedList = NULL;
   51250           5 :      for ( block = SgOmpForClause::pools.begin(); block != SgOmpForClause::pools.end() ; ++block )
   51251             :         {
   51252           0 :           pointer = (SgOmpForClause*)(*block);
   51253           0 :           for (unsigned i = 0; i < SgOmpForClause::pool_size; ++i )
   51254             :              {
   51255             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   51256             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   51257             :             // memory blocks!.
   51258           0 :                if ( pointer[i].get_freepointer() != NULL )
   51259             :                   {
   51260           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   51261             :                   }
   51262             :                else
   51263             :                   {
   51264           0 :                     if ( pointerOfLinkedList == NULL )
   51265             :                        {
   51266           0 :                          SgOmpForClause::next_node = &(pointer[i]);
   51267             :                        }
   51268             :                     else
   51269             :                        {
   51270             :                       // printf ("In SgOmpForClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   51271           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   51272             :                        }
   51273             :                     pointerOfLinkedList = &(pointer[i]);
   51274             :                   }
   51275             :               }
   51276             :         }
   51277             : 
   51278           5 :      if ( pointerOfLinkedList != NULL )
   51279             :         {
   51280             :        // printf ("In SgOmpForClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   51281           0 :           pointerOfLinkedList->set_freepointer(NULL);
   51282             :        // DQ (6/6/2010): Temporary debugging...
   51283             :        //   ROSE_ASSERT(false);
   51284             :         }
   51285             : 
   51286           5 :      return ;
   51287             :    }
   51288             : 
   51289             : //############################################################################
   51290             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   51291             :  * within the memory pool and resets the freepointers, in order to achieve a 
   51292             :  * linked list, that has no jumps and starts at the beginning! This function 
   51293             :  * does not extend the memory pool, since we do not delete any memory blocks,
   51294             :  * but delete the valid objects.  
   51295             :  */
   51296             : void
   51297           0 : SgOmpForClause::clearMemoryPool( )
   51298             :    {
   51299             :   // printf ("Inside of SgOmpForClause::clearMemoryPool() \n");
   51300             : 
   51301           0 :      SgOmpForClause* pointer = NULL, *tempPointer = NULL;
   51302           0 :      std::vector < unsigned char* > :: const_iterator block;
   51303           0 :      if ( SgOmpForClause::pools.empty() == false )
   51304             :         {
   51305           0 :           block = SgOmpForClause::pools.begin() ;
   51306           0 :           SgOmpForClause::next_node = (SgOmpForClause*) (*block);
   51307             : 
   51308           0 :           while ( block != SgOmpForClause::pools.end() )
   51309             :              {
   51310           0 :                pointer = (SgOmpForClause*) (*block);
   51311           0 :                if ( tempPointer != NULL )
   51312             :                   {
   51313           0 :                     tempPointer->set_freepointer(pointer);
   51314             :                   }
   51315           0 :                for (unsigned i = 0; i < SgOmpForClause::pool_size - 1; ++i)
   51316             :                   {
   51317           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   51318             :                   }
   51319           0 :                 pointer[SgOmpForClause::pool_size-1].set_freepointer(NULL);
   51320           0 :                 tempPointer = &(pointer[SgOmpForClause::pool_size-1]);
   51321           0 :                 ++block;
   51322             :              }
   51323             :         }
   51324           0 :    }
   51325             : 
   51326           5 : void SgOmpForClause::deleteMemoryPool() {
   51327           5 :   for (auto p: SgOmpForClause::pools) {
   51328           0 :     ROSE_FREE(p);
   51329             :   }
   51330           5 :   SgOmpForClause::next_node = nullptr;
   51331           5 :   SgOmpForClause::pools.clear();
   51332           5 : }
   51333             : 
   51334             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   51335             : //                 reading multiple binary files to for a single AST.
   51336             : /////////// new version ////////////////////////////////
   51337             : //############################################################################
   51338             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   51339             : void
   51340           2 : SgOmpForClause::extendMemoryPoolForFileIO( )
   51341             :   {
   51342           2 :     size_t blockIndex = SgOmpForClause::pools.size();
   51343           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpForClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpForClause);
   51344             : 
   51345           2 :     while ( (blockIndex * SgOmpForClause::pool_size) < newPoolSize)
   51346             :       {
   51347             : #if ROSE_ALLOC_TRACE
   51348             :         if (blockIndex > 0) {
   51349             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpForClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpForClause) = %" PRIuPTR " SgOmpForClause::pool_size = %d \n",
   51350             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpForClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpForClause),SgOmpForClause::pool_size);
   51351             :         }
   51352             : #endif
   51353             : 
   51354           0 :         SgOmpForClause * pointer = (SgOmpForClause*) ROSE_MALLOC ( SgOmpForClause::pool_size * sizeof(SgOmpForClause) );
   51355           0 :         assert( pointer != NULL );
   51356             : #if ROSE_ALLOC_MEMSET == 1
   51357             :         memset(pointer, 0x00, SgOmpForClause::pool_size * sizeof(SgOmpForClause));
   51358             : #elif ROSE_ALLOC_MEMSET == 2
   51359             :         memset(pointer, 0xCC, SgOmpForClause::pool_size * sizeof(SgOmpForClause));
   51360             : #endif
   51361           0 :         SgOmpForClause::pools.push_back( (unsigned char*)(pointer) );
   51362           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpForClause::pool_size * sizeof(SgOmpForClause), V_SgOmpForClause ) );
   51363             : 
   51364           0 :         if ( SgOmpForClause::next_node != NULL ) {
   51365           0 :           if ( blockIndex > 0 ) {
   51366           0 :             SgOmpForClause * blkptr = (SgOmpForClause*)(SgOmpForClause::pools[blockIndex-1]);
   51367           0 :             blkptr[ SgOmpForClause::pool_size - 1 ].set_freepointer(pointer);
   51368             :           }
   51369             :         } else {
   51370           0 :           SgOmpForClause::next_node = pointer;
   51371             :         }
   51372             : 
   51373           0 :         for (unsigned i = 0; i < SgOmpForClause::pool_size-1; ++i)
   51374             :            {
   51375           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   51376             :            }
   51377           0 :         pointer[ SgOmpForClause::pool_size -1 ].set_freepointer(NULL);
   51378             : 
   51379           0 :         blockIndex++;
   51380             :       }
   51381           2 :   }
   51382             : 
   51383             : //############################################################################
   51384             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   51385             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   51386             :  * not compressed. However, that stuff is not yet implemented! 
   51387             :  */
   51388             : unsigned long
   51389           0 : SgOmpForClause::getNumberOfLastValidPointer()
   51390             :    {
   51391           0 :       SgOmpForClause* testPointer = (SgOmpForClause*)(SgOmpForClause::pools.back());
   51392           0 :       unsigned long localIndex = SgOmpForClause::pool_size - 1;
   51393           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   51394             :          {
   51395           0 :            localIndex--;
   51396             :          }
   51397           0 :       return (localIndex + SgOmpForClause::pool_size * (SgOmpForClause::pools.size()-1));
   51398             :    }
   51399             : 
   51400             : //############################################################################
   51401             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   51402             :  * memory pool and initializes the data member in class SgOmpForClauseStroageClass
   51403             :  * from its counterpart of SgOmpForClause. The return value is just for checking, 
   51404             :  * that the whole StorageClassArray is initialized!
   51405             :  */
   51406             : unsigned long
   51407           0 : SgOmpForClause::initializeStorageClassArray( SgOmpForClauseStorageClass *storageArray )
   51408             :    {
   51409           0 :      unsigned long storageCounter = 0;
   51410           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpForClause::pools.begin();
   51411           0 :      SgOmpForClause* pointer = NULL;
   51412           0 :      while ( block != SgOmpForClause::pools.end() ) {
   51413           0 :           pointer = (SgOmpForClause*) (*block);
   51414           0 :           for ( unsigned i = 0; i < SgOmpForClause::pool_size; ++i ) {
   51415           0 :                if ( pointer->get_freepointer() != NULL ) {
   51416           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   51417           0 :                  storageArray++;
   51418           0 :                  storageCounter++;
   51419             :                }
   51420           0 :                pointer++;
   51421             :              }
   51422           0 :            block++;
   51423             :         }
   51424           0 :      return storageCounter;
   51425             :    }
   51426             : 
   51427             : /* #line 51428 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   51428             : 
   51429             : 
   51430             : 
   51431             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   51432             : 
   51433             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   51434             : 
   51435             : //############################################################################
   51436             : /* JH (02/02/2006) Constructor of the IR node SgOmpTaskgroupClause that takes its 
   51437             :  * corresponding StorageClass as parameter
   51438             :  */
   51439           0 : SgOmpTaskgroupClause :: SgOmpTaskgroupClause ( const SgOmpTaskgroupClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   51440             :    {
   51441             : 
   51442             : 
   51443             : /* #line 51444 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   51444             : 
   51445           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   51446             : 
   51447             : 
   51448             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   51449             : 
   51450             : 
   51451           0 :    }
   51452             : 
   51453             : //############################################################################
   51454             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   51455             :  * within the working AST. 
   51456             :  */
   51457           0 : SgOmpTaskgroupClause * SgOmpTaskgroupClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   51458           0 :      SgOmpTaskgroupClause* returnPointer = NULL;
   51459           0 :      if ( globalIndex != 0 )
   51460             :         {
   51461             : 
   51462             : #if FILE_IO_EXTRA_CHECK
   51463           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTaskgroupClause ) ) <= globalIndex ) ;
   51464           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskgroupClause + 1 ) ) );
   51465             : #endif
   51466           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskgroupClause )  
   51467           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTaskgroupClause );
   51468           0 :           unsigned long positionInPool = localIndex % SgOmpTaskgroupClause::pool_size;
   51469           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskgroupClause::pool_size;
   51470             : 
   51471             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   51472             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   51473             : 
   51474           0 :           returnPointer = &( ( (SgOmpTaskgroupClause*)(SgOmpTaskgroupClause::pools[memoryBlock]) ) [positionInPool]) ;
   51475             : 
   51476           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   51477             :         }
   51478           0 :      return returnPointer ;
   51479             :    }
   51480             : 
   51481             : //############################################################################
   51482             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   51483             :   for the AST with the index astIndex
   51484             : */
   51485           0 : SgOmpTaskgroupClause * SgOmpTaskgroupClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   51486           0 :      SgOmpTaskgroupClause* returnPointer = NULL;
   51487           0 :      if ( globalIndex != 0 )
   51488             :         {
   51489             : 
   51490             : #if FILE_IO_EXTRA_CHECK
   51491           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTaskgroupClause ) ) <= globalIndex ) ;
   51492           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskgroupClause + 1 ) ) );
   51493             : #endif
   51494           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskgroupClause )
   51495           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTaskgroupClause );
   51496           0 :           unsigned long positionInPool = localIndex % SgOmpTaskgroupClause::pool_size ;
   51497           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskgroupClause::pool_size ;
   51498             : 
   51499             : #if FILE_IO_EXTRA_CHECK
   51500             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   51501             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   51502             : #endif
   51503             : 
   51504           0 :           returnPointer = &( ( (SgOmpTaskgroupClause*)(SgOmpTaskgroupClause::pools[memoryBlock]) ) [positionInPool]) ;
   51505             : 
   51506             : #if FILE_IO_EXTRA_CHECK
   51507           0 :           assert ( returnPointer != NULL ) ;
   51508             : #endif
   51509             :         }
   51510           0 :      return returnPointer ;
   51511             :    }
   51512             : 
   51513             : //############################################################################
   51514             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   51515             :  * pool size! We set for every valid object in the memory pool the freepointer
   51516             :  * to the global index and increase the global index afterwards. For all the 
   51517             :  * invalid objects (means address ranges within the memory pool that were not
   51518             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   51519             :  * distinguish valid from invalid objects! 
   51520             :  */
   51521             : unsigned long
   51522           5 : SgOmpTaskgroupClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   51523             :    {
   51524           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   51525           5 :      SgOmpTaskgroupClause* pointer = NULL;
   51526           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   51527           5 :      std::vector < unsigned char* > :: const_iterator block;
   51528           5 :      for ( block = SgOmpTaskgroupClause::pools.begin(); block != SgOmpTaskgroupClause::pools.end() ; ++block )
   51529             :         {
   51530           0 :           pointer = (SgOmpTaskgroupClause*)(*block);
   51531           0 :           for (unsigned i = 0; i < SgOmpTaskgroupClause::pool_size; ++i )
   51532             :              {
   51533             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   51534             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   51535             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   51536             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   51537             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   51538             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   51539             :             // properly; so this will have to be checked next.
   51540             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   51541             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   51542           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   51543             :                   {
   51544           0 :                     pointer[i].set_freepointer((SgOmpTaskgroupClause*)(globalIndex));
   51545           0 :                     globalIndex++;
   51546             :                   }
   51547             :                else
   51548             :                   {
   51549           0 :                     pointer[i].set_freepointer(NULL);
   51550             :                   }
   51551             :               }
   51552             :         }
   51553           5 :      return globalIndex;
   51554             :    }
   51555             : 
   51556             : //############################################################################
   51557             : // JH (01/14/2006)
   51558             : void
   51559           5 : SgOmpTaskgroupClause::resetValidFreepointers( )
   51560             :    {
   51561           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   51562           5 :      SgOmpTaskgroupClause* pointer = NULL;
   51563           5 :      std::vector < unsigned char* > :: const_iterator block;
   51564           5 :      SgOmpTaskgroupClause* pointerOfLinkedList = NULL;
   51565           5 :      for ( block = SgOmpTaskgroupClause::pools.begin(); block != SgOmpTaskgroupClause::pools.end() ; ++block )
   51566             :         {
   51567           0 :           pointer = (SgOmpTaskgroupClause*)(*block);
   51568           0 :           for (unsigned i = 0; i < SgOmpTaskgroupClause::pool_size; ++i )
   51569             :              {
   51570             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   51571             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   51572             :             // memory blocks!.
   51573           0 :                if ( pointer[i].get_freepointer() != NULL )
   51574             :                   {
   51575           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   51576             :                   }
   51577             :                else
   51578             :                   {
   51579           0 :                     if ( pointerOfLinkedList == NULL )
   51580             :                        {
   51581           0 :                          SgOmpTaskgroupClause::next_node = &(pointer[i]);
   51582             :                        }
   51583             :                     else
   51584             :                        {
   51585             :                       // printf ("In SgOmpTaskgroupClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   51586           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   51587             :                        }
   51588             :                     pointerOfLinkedList = &(pointer[i]);
   51589             :                   }
   51590             :               }
   51591             :         }
   51592             : 
   51593           5 :      if ( pointerOfLinkedList != NULL )
   51594             :         {
   51595             :        // printf ("In SgOmpTaskgroupClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   51596           0 :           pointerOfLinkedList->set_freepointer(NULL);
   51597             :        // DQ (6/6/2010): Temporary debugging...
   51598             :        //   ROSE_ASSERT(false);
   51599             :         }
   51600             : 
   51601           5 :      return ;
   51602             :    }
   51603             : 
   51604             : //############################################################################
   51605             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   51606             :  * within the memory pool and resets the freepointers, in order to achieve a 
   51607             :  * linked list, that has no jumps and starts at the beginning! This function 
   51608             :  * does not extend the memory pool, since we do not delete any memory blocks,
   51609             :  * but delete the valid objects.  
   51610             :  */
   51611             : void
   51612           0 : SgOmpTaskgroupClause::clearMemoryPool( )
   51613             :    {
   51614             :   // printf ("Inside of SgOmpTaskgroupClause::clearMemoryPool() \n");
   51615             : 
   51616           0 :      SgOmpTaskgroupClause* pointer = NULL, *tempPointer = NULL;
   51617           0 :      std::vector < unsigned char* > :: const_iterator block;
   51618           0 :      if ( SgOmpTaskgroupClause::pools.empty() == false )
   51619             :         {
   51620           0 :           block = SgOmpTaskgroupClause::pools.begin() ;
   51621           0 :           SgOmpTaskgroupClause::next_node = (SgOmpTaskgroupClause*) (*block);
   51622             : 
   51623           0 :           while ( block != SgOmpTaskgroupClause::pools.end() )
   51624             :              {
   51625           0 :                pointer = (SgOmpTaskgroupClause*) (*block);
   51626           0 :                if ( tempPointer != NULL )
   51627             :                   {
   51628           0 :                     tempPointer->set_freepointer(pointer);
   51629             :                   }
   51630           0 :                for (unsigned i = 0; i < SgOmpTaskgroupClause::pool_size - 1; ++i)
   51631             :                   {
   51632           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   51633             :                   }
   51634           0 :                 pointer[SgOmpTaskgroupClause::pool_size-1].set_freepointer(NULL);
   51635           0 :                 tempPointer = &(pointer[SgOmpTaskgroupClause::pool_size-1]);
   51636           0 :                 ++block;
   51637             :              }
   51638             :         }
   51639           0 :    }
   51640             : 
   51641           5 : void SgOmpTaskgroupClause::deleteMemoryPool() {
   51642           5 :   for (auto p: SgOmpTaskgroupClause::pools) {
   51643           0 :     ROSE_FREE(p);
   51644             :   }
   51645           5 :   SgOmpTaskgroupClause::next_node = nullptr;
   51646           5 :   SgOmpTaskgroupClause::pools.clear();
   51647           5 : }
   51648             : 
   51649             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   51650             : //                 reading multiple binary files to for a single AST.
   51651             : /////////// new version ////////////////////////////////
   51652             : //############################################################################
   51653             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   51654             : void
   51655           2 : SgOmpTaskgroupClause::extendMemoryPoolForFileIO( )
   51656             :   {
   51657           2 :     size_t blockIndex = SgOmpTaskgroupClause::pools.size();
   51658           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskgroupClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskgroupClause);
   51659             : 
   51660           2 :     while ( (blockIndex * SgOmpTaskgroupClause::pool_size) < newPoolSize)
   51661             :       {
   51662             : #if ROSE_ALLOC_TRACE
   51663             :         if (blockIndex > 0) {
   51664             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskgroupClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskgroupClause) = %" PRIuPTR " SgOmpTaskgroupClause::pool_size = %d \n",
   51665             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskgroupClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskgroupClause),SgOmpTaskgroupClause::pool_size);
   51666             :         }
   51667             : #endif
   51668             : 
   51669           0 :         SgOmpTaskgroupClause * pointer = (SgOmpTaskgroupClause*) ROSE_MALLOC ( SgOmpTaskgroupClause::pool_size * sizeof(SgOmpTaskgroupClause) );
   51670           0 :         assert( pointer != NULL );
   51671             : #if ROSE_ALLOC_MEMSET == 1
   51672             :         memset(pointer, 0x00, SgOmpTaskgroupClause::pool_size * sizeof(SgOmpTaskgroupClause));
   51673             : #elif ROSE_ALLOC_MEMSET == 2
   51674             :         memset(pointer, 0xCC, SgOmpTaskgroupClause::pool_size * sizeof(SgOmpTaskgroupClause));
   51675             : #endif
   51676           0 :         SgOmpTaskgroupClause::pools.push_back( (unsigned char*)(pointer) );
   51677           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTaskgroupClause::pool_size * sizeof(SgOmpTaskgroupClause), V_SgOmpTaskgroupClause ) );
   51678             : 
   51679           0 :         if ( SgOmpTaskgroupClause::next_node != NULL ) {
   51680           0 :           if ( blockIndex > 0 ) {
   51681           0 :             SgOmpTaskgroupClause * blkptr = (SgOmpTaskgroupClause*)(SgOmpTaskgroupClause::pools[blockIndex-1]);
   51682           0 :             blkptr[ SgOmpTaskgroupClause::pool_size - 1 ].set_freepointer(pointer);
   51683             :           }
   51684             :         } else {
   51685           0 :           SgOmpTaskgroupClause::next_node = pointer;
   51686             :         }
   51687             : 
   51688           0 :         for (unsigned i = 0; i < SgOmpTaskgroupClause::pool_size-1; ++i)
   51689             :            {
   51690           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   51691             :            }
   51692           0 :         pointer[ SgOmpTaskgroupClause::pool_size -1 ].set_freepointer(NULL);
   51693             : 
   51694           0 :         blockIndex++;
   51695             :       }
   51696           2 :   }
   51697             : 
   51698             : //############################################################################
   51699             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   51700             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   51701             :  * not compressed. However, that stuff is not yet implemented! 
   51702             :  */
   51703             : unsigned long
   51704           0 : SgOmpTaskgroupClause::getNumberOfLastValidPointer()
   51705             :    {
   51706           0 :       SgOmpTaskgroupClause* testPointer = (SgOmpTaskgroupClause*)(SgOmpTaskgroupClause::pools.back());
   51707           0 :       unsigned long localIndex = SgOmpTaskgroupClause::pool_size - 1;
   51708           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   51709             :          {
   51710           0 :            localIndex--;
   51711             :          }
   51712           0 :       return (localIndex + SgOmpTaskgroupClause::pool_size * (SgOmpTaskgroupClause::pools.size()-1));
   51713             :    }
   51714             : 
   51715             : //############################################################################
   51716             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   51717             :  * memory pool and initializes the data member in class SgOmpTaskgroupClauseStroageClass
   51718             :  * from its counterpart of SgOmpTaskgroupClause. The return value is just for checking, 
   51719             :  * that the whole StorageClassArray is initialized!
   51720             :  */
   51721             : unsigned long
   51722           0 : SgOmpTaskgroupClause::initializeStorageClassArray( SgOmpTaskgroupClauseStorageClass *storageArray )
   51723             :    {
   51724           0 :      unsigned long storageCounter = 0;
   51725           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTaskgroupClause::pools.begin();
   51726           0 :      SgOmpTaskgroupClause* pointer = NULL;
   51727           0 :      while ( block != SgOmpTaskgroupClause::pools.end() ) {
   51728           0 :           pointer = (SgOmpTaskgroupClause*) (*block);
   51729           0 :           for ( unsigned i = 0; i < SgOmpTaskgroupClause::pool_size; ++i ) {
   51730           0 :                if ( pointer->get_freepointer() != NULL ) {
   51731           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   51732           0 :                  storageArray++;
   51733           0 :                  storageCounter++;
   51734             :                }
   51735           0 :                pointer++;
   51736             :              }
   51737           0 :            block++;
   51738             :         }
   51739           0 :      return storageCounter;
   51740             :    }
   51741             : 
   51742             : /* #line 51743 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   51743             : 
   51744             : 
   51745             : 
   51746             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   51747             : 
   51748             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   51749             : 
   51750             : //############################################################################
   51751             : /* JH (02/02/2006) Constructor of the IR node SgOmpNogroupClause that takes its 
   51752             :  * corresponding StorageClass as parameter
   51753             :  */
   51754           0 : SgOmpNogroupClause :: SgOmpNogroupClause ( const SgOmpNogroupClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   51755             :    {
   51756             : 
   51757             : 
   51758             : /* #line 51759 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   51759             : 
   51760           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   51761             : 
   51762             : 
   51763             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   51764             : 
   51765             : 
   51766           0 :    }
   51767             : 
   51768             : //############################################################################
   51769             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   51770             :  * within the working AST. 
   51771             :  */
   51772           0 : SgOmpNogroupClause * SgOmpNogroupClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   51773           0 :      SgOmpNogroupClause* returnPointer = NULL;
   51774           0 :      if ( globalIndex != 0 )
   51775             :         {
   51776             : 
   51777             : #if FILE_IO_EXTRA_CHECK
   51778           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpNogroupClause ) ) <= globalIndex ) ;
   51779           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNogroupClause + 1 ) ) );
   51780             : #endif
   51781           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNogroupClause )  
   51782           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpNogroupClause );
   51783           0 :           unsigned long positionInPool = localIndex % SgOmpNogroupClause::pool_size;
   51784           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNogroupClause::pool_size;
   51785             : 
   51786             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   51787             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   51788             : 
   51789           0 :           returnPointer = &( ( (SgOmpNogroupClause*)(SgOmpNogroupClause::pools[memoryBlock]) ) [positionInPool]) ;
   51790             : 
   51791           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   51792             :         }
   51793           0 :      return returnPointer ;
   51794             :    }
   51795             : 
   51796             : //############################################################################
   51797             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   51798             :   for the AST with the index astIndex
   51799             : */
   51800           0 : SgOmpNogroupClause * SgOmpNogroupClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   51801           0 :      SgOmpNogroupClause* returnPointer = NULL;
   51802           0 :      if ( globalIndex != 0 )
   51803             :         {
   51804             : 
   51805             : #if FILE_IO_EXTRA_CHECK
   51806           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpNogroupClause ) ) <= globalIndex ) ;
   51807           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNogroupClause + 1 ) ) );
   51808             : #endif
   51809           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNogroupClause )
   51810           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpNogroupClause );
   51811           0 :           unsigned long positionInPool = localIndex % SgOmpNogroupClause::pool_size ;
   51812           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNogroupClause::pool_size ;
   51813             : 
   51814             : #if FILE_IO_EXTRA_CHECK
   51815             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   51816             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   51817             : #endif
   51818             : 
   51819           0 :           returnPointer = &( ( (SgOmpNogroupClause*)(SgOmpNogroupClause::pools[memoryBlock]) ) [positionInPool]) ;
   51820             : 
   51821             : #if FILE_IO_EXTRA_CHECK
   51822           0 :           assert ( returnPointer != NULL ) ;
   51823             : #endif
   51824             :         }
   51825           0 :      return returnPointer ;
   51826             :    }
   51827             : 
   51828             : //############################################################################
   51829             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   51830             :  * pool size! We set for every valid object in the memory pool the freepointer
   51831             :  * to the global index and increase the global index afterwards. For all the 
   51832             :  * invalid objects (means address ranges within the memory pool that were not
   51833             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   51834             :  * distinguish valid from invalid objects! 
   51835             :  */
   51836             : unsigned long
   51837           5 : SgOmpNogroupClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   51838             :    {
   51839           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   51840           5 :      SgOmpNogroupClause* pointer = NULL;
   51841           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   51842           5 :      std::vector < unsigned char* > :: const_iterator block;
   51843           5 :      for ( block = SgOmpNogroupClause::pools.begin(); block != SgOmpNogroupClause::pools.end() ; ++block )
   51844             :         {
   51845           0 :           pointer = (SgOmpNogroupClause*)(*block);
   51846           0 :           for (unsigned i = 0; i < SgOmpNogroupClause::pool_size; ++i )
   51847             :              {
   51848             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   51849             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   51850             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   51851             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   51852             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   51853             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   51854             :             // properly; so this will have to be checked next.
   51855             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   51856             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   51857           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   51858             :                   {
   51859           0 :                     pointer[i].set_freepointer((SgOmpNogroupClause*)(globalIndex));
   51860           0 :                     globalIndex++;
   51861             :                   }
   51862             :                else
   51863             :                   {
   51864           0 :                     pointer[i].set_freepointer(NULL);
   51865             :                   }
   51866             :               }
   51867             :         }
   51868           5 :      return globalIndex;
   51869             :    }
   51870             : 
   51871             : //############################################################################
   51872             : // JH (01/14/2006)
   51873             : void
   51874           5 : SgOmpNogroupClause::resetValidFreepointers( )
   51875             :    {
   51876           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   51877           5 :      SgOmpNogroupClause* pointer = NULL;
   51878           5 :      std::vector < unsigned char* > :: const_iterator block;
   51879           5 :      SgOmpNogroupClause* pointerOfLinkedList = NULL;
   51880           5 :      for ( block = SgOmpNogroupClause::pools.begin(); block != SgOmpNogroupClause::pools.end() ; ++block )
   51881             :         {
   51882           0 :           pointer = (SgOmpNogroupClause*)(*block);
   51883           0 :           for (unsigned i = 0; i < SgOmpNogroupClause::pool_size; ++i )
   51884             :              {
   51885             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   51886             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   51887             :             // memory blocks!.
   51888           0 :                if ( pointer[i].get_freepointer() != NULL )
   51889             :                   {
   51890           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   51891             :                   }
   51892             :                else
   51893             :                   {
   51894           0 :                     if ( pointerOfLinkedList == NULL )
   51895             :                        {
   51896           0 :                          SgOmpNogroupClause::next_node = &(pointer[i]);
   51897             :                        }
   51898             :                     else
   51899             :                        {
   51900             :                       // printf ("In SgOmpNogroupClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   51901           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   51902             :                        }
   51903             :                     pointerOfLinkedList = &(pointer[i]);
   51904             :                   }
   51905             :               }
   51906             :         }
   51907             : 
   51908           5 :      if ( pointerOfLinkedList != NULL )
   51909             :         {
   51910             :        // printf ("In SgOmpNogroupClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   51911           0 :           pointerOfLinkedList->set_freepointer(NULL);
   51912             :        // DQ (6/6/2010): Temporary debugging...
   51913             :        //   ROSE_ASSERT(false);
   51914             :         }
   51915             : 
   51916           5 :      return ;
   51917             :    }
   51918             : 
   51919             : //############################################################################
   51920             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   51921             :  * within the memory pool and resets the freepointers, in order to achieve a 
   51922             :  * linked list, that has no jumps and starts at the beginning! This function 
   51923             :  * does not extend the memory pool, since we do not delete any memory blocks,
   51924             :  * but delete the valid objects.  
   51925             :  */
   51926             : void
   51927           0 : SgOmpNogroupClause::clearMemoryPool( )
   51928             :    {
   51929             :   // printf ("Inside of SgOmpNogroupClause::clearMemoryPool() \n");
   51930             : 
   51931           0 :      SgOmpNogroupClause* pointer = NULL, *tempPointer = NULL;
   51932           0 :      std::vector < unsigned char* > :: const_iterator block;
   51933           0 :      if ( SgOmpNogroupClause::pools.empty() == false )
   51934             :         {
   51935           0 :           block = SgOmpNogroupClause::pools.begin() ;
   51936           0 :           SgOmpNogroupClause::next_node = (SgOmpNogroupClause*) (*block);
   51937             : 
   51938           0 :           while ( block != SgOmpNogroupClause::pools.end() )
   51939             :              {
   51940           0 :                pointer = (SgOmpNogroupClause*) (*block);
   51941           0 :                if ( tempPointer != NULL )
   51942             :                   {
   51943           0 :                     tempPointer->set_freepointer(pointer);
   51944             :                   }
   51945           0 :                for (unsigned i = 0; i < SgOmpNogroupClause::pool_size - 1; ++i)
   51946             :                   {
   51947           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   51948             :                   }
   51949           0 :                 pointer[SgOmpNogroupClause::pool_size-1].set_freepointer(NULL);
   51950           0 :                 tempPointer = &(pointer[SgOmpNogroupClause::pool_size-1]);
   51951           0 :                 ++block;
   51952             :              }
   51953             :         }
   51954           0 :    }
   51955             : 
   51956           5 : void SgOmpNogroupClause::deleteMemoryPool() {
   51957           5 :   for (auto p: SgOmpNogroupClause::pools) {
   51958           0 :     ROSE_FREE(p);
   51959             :   }
   51960           5 :   SgOmpNogroupClause::next_node = nullptr;
   51961           5 :   SgOmpNogroupClause::pools.clear();
   51962           5 : }
   51963             : 
   51964             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   51965             : //                 reading multiple binary files to for a single AST.
   51966             : /////////// new version ////////////////////////////////
   51967             : //############################################################################
   51968             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   51969             : void
   51970           2 : SgOmpNogroupClause::extendMemoryPoolForFileIO( )
   51971             :   {
   51972           2 :     size_t blockIndex = SgOmpNogroupClause::pools.size();
   51973           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNogroupClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNogroupClause);
   51974             : 
   51975           2 :     while ( (blockIndex * SgOmpNogroupClause::pool_size) < newPoolSize)
   51976             :       {
   51977             : #if ROSE_ALLOC_TRACE
   51978             :         if (blockIndex > 0) {
   51979             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNogroupClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNogroupClause) = %" PRIuPTR " SgOmpNogroupClause::pool_size = %d \n",
   51980             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNogroupClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNogroupClause),SgOmpNogroupClause::pool_size);
   51981             :         }
   51982             : #endif
   51983             : 
   51984           0 :         SgOmpNogroupClause * pointer = (SgOmpNogroupClause*) ROSE_MALLOC ( SgOmpNogroupClause::pool_size * sizeof(SgOmpNogroupClause) );
   51985           0 :         assert( pointer != NULL );
   51986             : #if ROSE_ALLOC_MEMSET == 1
   51987             :         memset(pointer, 0x00, SgOmpNogroupClause::pool_size * sizeof(SgOmpNogroupClause));
   51988             : #elif ROSE_ALLOC_MEMSET == 2
   51989             :         memset(pointer, 0xCC, SgOmpNogroupClause::pool_size * sizeof(SgOmpNogroupClause));
   51990             : #endif
   51991           0 :         SgOmpNogroupClause::pools.push_back( (unsigned char*)(pointer) );
   51992           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpNogroupClause::pool_size * sizeof(SgOmpNogroupClause), V_SgOmpNogroupClause ) );
   51993             : 
   51994           0 :         if ( SgOmpNogroupClause::next_node != NULL ) {
   51995           0 :           if ( blockIndex > 0 ) {
   51996           0 :             SgOmpNogroupClause * blkptr = (SgOmpNogroupClause*)(SgOmpNogroupClause::pools[blockIndex-1]);
   51997           0 :             blkptr[ SgOmpNogroupClause::pool_size - 1 ].set_freepointer(pointer);
   51998             :           }
   51999             :         } else {
   52000           0 :           SgOmpNogroupClause::next_node = pointer;
   52001             :         }
   52002             : 
   52003           0 :         for (unsigned i = 0; i < SgOmpNogroupClause::pool_size-1; ++i)
   52004             :            {
   52005           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   52006             :            }
   52007           0 :         pointer[ SgOmpNogroupClause::pool_size -1 ].set_freepointer(NULL);
   52008             : 
   52009           0 :         blockIndex++;
   52010             :       }
   52011           2 :   }
   52012             : 
   52013             : //############################################################################
   52014             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   52015             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   52016             :  * not compressed. However, that stuff is not yet implemented! 
   52017             :  */
   52018             : unsigned long
   52019           0 : SgOmpNogroupClause::getNumberOfLastValidPointer()
   52020             :    {
   52021           0 :       SgOmpNogroupClause* testPointer = (SgOmpNogroupClause*)(SgOmpNogroupClause::pools.back());
   52022           0 :       unsigned long localIndex = SgOmpNogroupClause::pool_size - 1;
   52023           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   52024             :          {
   52025           0 :            localIndex--;
   52026             :          }
   52027           0 :       return (localIndex + SgOmpNogroupClause::pool_size * (SgOmpNogroupClause::pools.size()-1));
   52028             :    }
   52029             : 
   52030             : //############################################################################
   52031             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   52032             :  * memory pool and initializes the data member in class SgOmpNogroupClauseStroageClass
   52033             :  * from its counterpart of SgOmpNogroupClause. The return value is just for checking, 
   52034             :  * that the whole StorageClassArray is initialized!
   52035             :  */
   52036             : unsigned long
   52037           0 : SgOmpNogroupClause::initializeStorageClassArray( SgOmpNogroupClauseStorageClass *storageArray )
   52038             :    {
   52039           0 :      unsigned long storageCounter = 0;
   52040           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpNogroupClause::pools.begin();
   52041           0 :      SgOmpNogroupClause* pointer = NULL;
   52042           0 :      while ( block != SgOmpNogroupClause::pools.end() ) {
   52043           0 :           pointer = (SgOmpNogroupClause*) (*block);
   52044           0 :           for ( unsigned i = 0; i < SgOmpNogroupClause::pool_size; ++i ) {
   52045           0 :                if ( pointer->get_freepointer() != NULL ) {
   52046           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   52047           0 :                  storageArray++;
   52048           0 :                  storageCounter++;
   52049             :                }
   52050           0 :                pointer++;
   52051             :              }
   52052           0 :            block++;
   52053             :         }
   52054           0 :      return storageCounter;
   52055             :    }
   52056             : 
   52057             : /* #line 52058 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   52058             : 
   52059             : 
   52060             : 
   52061             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   52062             : 
   52063             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   52064             : 
   52065             : //############################################################################
   52066             : /* JH (02/02/2006) Constructor of the IR node SgOmpDefaultClause that takes its 
   52067             :  * corresponding StorageClass as parameter
   52068             :  */
   52069           0 : SgOmpDefaultClause :: SgOmpDefaultClause ( const SgOmpDefaultClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   52070             :    {
   52071             : 
   52072             : 
   52073             : /* #line 52074 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   52074             : 
   52075           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   52076           0 :      p_data_sharing = storageSource.storageOf_data_sharing ;
   52077           0 :      p_variant_directive =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_variant_directive) );
   52078             : 
   52079             : 
   52080             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   52081             : 
   52082             : 
   52083           0 :    }
   52084             : 
   52085             : //############################################################################
   52086             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   52087             :  * within the working AST. 
   52088             :  */
   52089           0 : SgOmpDefaultClause * SgOmpDefaultClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   52090           0 :      SgOmpDefaultClause* returnPointer = NULL;
   52091           0 :      if ( globalIndex != 0 )
   52092             :         {
   52093             : 
   52094             : #if FILE_IO_EXTRA_CHECK
   52095           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDefaultClause ) ) <= globalIndex ) ;
   52096           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDefaultClause + 1 ) ) );
   52097             : #endif
   52098           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDefaultClause )  
   52099           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDefaultClause );
   52100           0 :           unsigned long positionInPool = localIndex % SgOmpDefaultClause::pool_size;
   52101           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDefaultClause::pool_size;
   52102             : 
   52103             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   52104             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   52105             : 
   52106           0 :           returnPointer = &( ( (SgOmpDefaultClause*)(SgOmpDefaultClause::pools[memoryBlock]) ) [positionInPool]) ;
   52107             : 
   52108           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   52109             :         }
   52110           0 :      return returnPointer ;
   52111             :    }
   52112             : 
   52113             : //############################################################################
   52114             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   52115             :   for the AST with the index astIndex
   52116             : */
   52117           0 : SgOmpDefaultClause * SgOmpDefaultClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   52118           0 :      SgOmpDefaultClause* returnPointer = NULL;
   52119           0 :      if ( globalIndex != 0 )
   52120             :         {
   52121             : 
   52122             : #if FILE_IO_EXTRA_CHECK
   52123           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDefaultClause ) ) <= globalIndex ) ;
   52124           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDefaultClause + 1 ) ) );
   52125             : #endif
   52126           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDefaultClause )
   52127           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDefaultClause );
   52128           0 :           unsigned long positionInPool = localIndex % SgOmpDefaultClause::pool_size ;
   52129           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDefaultClause::pool_size ;
   52130             : 
   52131             : #if FILE_IO_EXTRA_CHECK
   52132             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   52133             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   52134             : #endif
   52135             : 
   52136           0 :           returnPointer = &( ( (SgOmpDefaultClause*)(SgOmpDefaultClause::pools[memoryBlock]) ) [positionInPool]) ;
   52137             : 
   52138             : #if FILE_IO_EXTRA_CHECK
   52139           0 :           assert ( returnPointer != NULL ) ;
   52140             : #endif
   52141             :         }
   52142           0 :      return returnPointer ;
   52143             :    }
   52144             : 
   52145             : //############################################################################
   52146             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   52147             :  * pool size! We set for every valid object in the memory pool the freepointer
   52148             :  * to the global index and increase the global index afterwards. For all the 
   52149             :  * invalid objects (means address ranges within the memory pool that were not
   52150             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   52151             :  * distinguish valid from invalid objects! 
   52152             :  */
   52153             : unsigned long
   52154           5 : SgOmpDefaultClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   52155             :    {
   52156           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   52157           5 :      SgOmpDefaultClause* pointer = NULL;
   52158           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   52159           5 :      std::vector < unsigned char* > :: const_iterator block;
   52160           5 :      for ( block = SgOmpDefaultClause::pools.begin(); block != SgOmpDefaultClause::pools.end() ; ++block )
   52161             :         {
   52162           0 :           pointer = (SgOmpDefaultClause*)(*block);
   52163           0 :           for (unsigned i = 0; i < SgOmpDefaultClause::pool_size; ++i )
   52164             :              {
   52165             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   52166             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   52167             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   52168             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   52169             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   52170             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   52171             :             // properly; so this will have to be checked next.
   52172             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   52173             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   52174           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   52175             :                   {
   52176           0 :                     pointer[i].set_freepointer((SgOmpDefaultClause*)(globalIndex));
   52177           0 :                     globalIndex++;
   52178             :                   }
   52179             :                else
   52180             :                   {
   52181           0 :                     pointer[i].set_freepointer(NULL);
   52182             :                   }
   52183             :               }
   52184             :         }
   52185           5 :      return globalIndex;
   52186             :    }
   52187             : 
   52188             : //############################################################################
   52189             : // JH (01/14/2006)
   52190             : void
   52191           5 : SgOmpDefaultClause::resetValidFreepointers( )
   52192             :    {
   52193           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   52194           5 :      SgOmpDefaultClause* pointer = NULL;
   52195           5 :      std::vector < unsigned char* > :: const_iterator block;
   52196           5 :      SgOmpDefaultClause* pointerOfLinkedList = NULL;
   52197           5 :      for ( block = SgOmpDefaultClause::pools.begin(); block != SgOmpDefaultClause::pools.end() ; ++block )
   52198             :         {
   52199           0 :           pointer = (SgOmpDefaultClause*)(*block);
   52200           0 :           for (unsigned i = 0; i < SgOmpDefaultClause::pool_size; ++i )
   52201             :              {
   52202             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   52203             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   52204             :             // memory blocks!.
   52205           0 :                if ( pointer[i].get_freepointer() != NULL )
   52206             :                   {
   52207           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   52208             :                   }
   52209             :                else
   52210             :                   {
   52211           0 :                     if ( pointerOfLinkedList == NULL )
   52212             :                        {
   52213           0 :                          SgOmpDefaultClause::next_node = &(pointer[i]);
   52214             :                        }
   52215             :                     else
   52216             :                        {
   52217             :                       // printf ("In SgOmpDefaultClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   52218           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   52219             :                        }
   52220             :                     pointerOfLinkedList = &(pointer[i]);
   52221             :                   }
   52222             :               }
   52223             :         }
   52224             : 
   52225           5 :      if ( pointerOfLinkedList != NULL )
   52226             :         {
   52227             :        // printf ("In SgOmpDefaultClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   52228           0 :           pointerOfLinkedList->set_freepointer(NULL);
   52229             :        // DQ (6/6/2010): Temporary debugging...
   52230             :        //   ROSE_ASSERT(false);
   52231             :         }
   52232             : 
   52233           5 :      return ;
   52234             :    }
   52235             : 
   52236             : //############################################################################
   52237             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   52238             :  * within the memory pool and resets the freepointers, in order to achieve a 
   52239             :  * linked list, that has no jumps and starts at the beginning! This function 
   52240             :  * does not extend the memory pool, since we do not delete any memory blocks,
   52241             :  * but delete the valid objects.  
   52242             :  */
   52243             : void
   52244           0 : SgOmpDefaultClause::clearMemoryPool( )
   52245             :    {
   52246             :   // printf ("Inside of SgOmpDefaultClause::clearMemoryPool() \n");
   52247             : 
   52248           0 :      SgOmpDefaultClause* pointer = NULL, *tempPointer = NULL;
   52249           0 :      std::vector < unsigned char* > :: const_iterator block;
   52250           0 :      if ( SgOmpDefaultClause::pools.empty() == false )
   52251             :         {
   52252           0 :           block = SgOmpDefaultClause::pools.begin() ;
   52253           0 :           SgOmpDefaultClause::next_node = (SgOmpDefaultClause*) (*block);
   52254             : 
   52255           0 :           while ( block != SgOmpDefaultClause::pools.end() )
   52256             :              {
   52257           0 :                pointer = (SgOmpDefaultClause*) (*block);
   52258           0 :                if ( tempPointer != NULL )
   52259             :                   {
   52260           0 :                     tempPointer->set_freepointer(pointer);
   52261             :                   }
   52262           0 :                for (unsigned i = 0; i < SgOmpDefaultClause::pool_size - 1; ++i)
   52263             :                   {
   52264           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   52265             :                   }
   52266           0 :                 pointer[SgOmpDefaultClause::pool_size-1].set_freepointer(NULL);
   52267           0 :                 tempPointer = &(pointer[SgOmpDefaultClause::pool_size-1]);
   52268           0 :                 ++block;
   52269             :              }
   52270             :         }
   52271           0 :    }
   52272             : 
   52273           5 : void SgOmpDefaultClause::deleteMemoryPool() {
   52274           5 :   for (auto p: SgOmpDefaultClause::pools) {
   52275           0 :     ROSE_FREE(p);
   52276             :   }
   52277           5 :   SgOmpDefaultClause::next_node = nullptr;
   52278           5 :   SgOmpDefaultClause::pools.clear();
   52279           5 : }
   52280             : 
   52281             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   52282             : //                 reading multiple binary files to for a single AST.
   52283             : /////////// new version ////////////////////////////////
   52284             : //############################################################################
   52285             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   52286             : void
   52287           2 : SgOmpDefaultClause::extendMemoryPoolForFileIO( )
   52288             :   {
   52289           2 :     size_t blockIndex = SgOmpDefaultClause::pools.size();
   52290           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDefaultClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDefaultClause);
   52291             : 
   52292           2 :     while ( (blockIndex * SgOmpDefaultClause::pool_size) < newPoolSize)
   52293             :       {
   52294             : #if ROSE_ALLOC_TRACE
   52295             :         if (blockIndex > 0) {
   52296             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDefaultClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDefaultClause) = %" PRIuPTR " SgOmpDefaultClause::pool_size = %d \n",
   52297             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDefaultClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDefaultClause),SgOmpDefaultClause::pool_size);
   52298             :         }
   52299             : #endif
   52300             : 
   52301           0 :         SgOmpDefaultClause * pointer = (SgOmpDefaultClause*) ROSE_MALLOC ( SgOmpDefaultClause::pool_size * sizeof(SgOmpDefaultClause) );
   52302           0 :         assert( pointer != NULL );
   52303             : #if ROSE_ALLOC_MEMSET == 1
   52304             :         memset(pointer, 0x00, SgOmpDefaultClause::pool_size * sizeof(SgOmpDefaultClause));
   52305             : #elif ROSE_ALLOC_MEMSET == 2
   52306             :         memset(pointer, 0xCC, SgOmpDefaultClause::pool_size * sizeof(SgOmpDefaultClause));
   52307             : #endif
   52308           0 :         SgOmpDefaultClause::pools.push_back( (unsigned char*)(pointer) );
   52309           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDefaultClause::pool_size * sizeof(SgOmpDefaultClause), V_SgOmpDefaultClause ) );
   52310             : 
   52311           0 :         if ( SgOmpDefaultClause::next_node != NULL ) {
   52312           0 :           if ( blockIndex > 0 ) {
   52313           0 :             SgOmpDefaultClause * blkptr = (SgOmpDefaultClause*)(SgOmpDefaultClause::pools[blockIndex-1]);
   52314           0 :             blkptr[ SgOmpDefaultClause::pool_size - 1 ].set_freepointer(pointer);
   52315             :           }
   52316             :         } else {
   52317           0 :           SgOmpDefaultClause::next_node = pointer;
   52318             :         }
   52319             : 
   52320           0 :         for (unsigned i = 0; i < SgOmpDefaultClause::pool_size-1; ++i)
   52321             :            {
   52322           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   52323             :            }
   52324           0 :         pointer[ SgOmpDefaultClause::pool_size -1 ].set_freepointer(NULL);
   52325             : 
   52326           0 :         blockIndex++;
   52327             :       }
   52328           2 :   }
   52329             : 
   52330             : //############################################################################
   52331             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   52332             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   52333             :  * not compressed. However, that stuff is not yet implemented! 
   52334             :  */
   52335             : unsigned long
   52336           0 : SgOmpDefaultClause::getNumberOfLastValidPointer()
   52337             :    {
   52338           0 :       SgOmpDefaultClause* testPointer = (SgOmpDefaultClause*)(SgOmpDefaultClause::pools.back());
   52339           0 :       unsigned long localIndex = SgOmpDefaultClause::pool_size - 1;
   52340           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   52341             :          {
   52342           0 :            localIndex--;
   52343             :          }
   52344           0 :       return (localIndex + SgOmpDefaultClause::pool_size * (SgOmpDefaultClause::pools.size()-1));
   52345             :    }
   52346             : 
   52347             : //############################################################################
   52348             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   52349             :  * memory pool and initializes the data member in class SgOmpDefaultClauseStroageClass
   52350             :  * from its counterpart of SgOmpDefaultClause. The return value is just for checking, 
   52351             :  * that the whole StorageClassArray is initialized!
   52352             :  */
   52353             : unsigned long
   52354           0 : SgOmpDefaultClause::initializeStorageClassArray( SgOmpDefaultClauseStorageClass *storageArray )
   52355             :    {
   52356           0 :      unsigned long storageCounter = 0;
   52357           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDefaultClause::pools.begin();
   52358           0 :      SgOmpDefaultClause* pointer = NULL;
   52359           0 :      while ( block != SgOmpDefaultClause::pools.end() ) {
   52360           0 :           pointer = (SgOmpDefaultClause*) (*block);
   52361           0 :           for ( unsigned i = 0; i < SgOmpDefaultClause::pool_size; ++i ) {
   52362           0 :                if ( pointer->get_freepointer() != NULL ) {
   52363           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   52364           0 :                  storageArray++;
   52365           0 :                  storageCounter++;
   52366             :                }
   52367           0 :                pointer++;
   52368             :              }
   52369           0 :            block++;
   52370             :         }
   52371           0 :      return storageCounter;
   52372             :    }
   52373             : 
   52374             : /* #line 52375 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   52375             : 
   52376             : 
   52377             : 
   52378             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   52379             : 
   52380             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   52381             : 
   52382             : //############################################################################
   52383             : /* JH (02/02/2006) Constructor of the IR node SgOmpAllocatorClause that takes its 
   52384             :  * corresponding StorageClass as parameter
   52385             :  */
   52386           0 : SgOmpAllocatorClause :: SgOmpAllocatorClause ( const SgOmpAllocatorClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   52387             :    {
   52388             : 
   52389             : 
   52390             : /* #line 52391 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   52391             : 
   52392           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   52393           0 :      p_modifier = storageSource.storageOf_modifier ;
   52394           0 :      p_user_defined_modifier =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_defined_modifier) );
   52395             : 
   52396             : 
   52397             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   52398             : 
   52399             : 
   52400           0 :    }
   52401             : 
   52402             : //############################################################################
   52403             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   52404             :  * within the working AST. 
   52405             :  */
   52406           0 : SgOmpAllocatorClause * SgOmpAllocatorClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   52407           0 :      SgOmpAllocatorClause* returnPointer = NULL;
   52408           0 :      if ( globalIndex != 0 )
   52409             :         {
   52410             : 
   52411             : #if FILE_IO_EXTRA_CHECK
   52412           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAllocatorClause ) ) <= globalIndex ) ;
   52413           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAllocatorClause + 1 ) ) );
   52414             : #endif
   52415           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAllocatorClause )  
   52416           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAllocatorClause );
   52417           0 :           unsigned long positionInPool = localIndex % SgOmpAllocatorClause::pool_size;
   52418           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAllocatorClause::pool_size;
   52419             : 
   52420             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   52421             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   52422             : 
   52423           0 :           returnPointer = &( ( (SgOmpAllocatorClause*)(SgOmpAllocatorClause::pools[memoryBlock]) ) [positionInPool]) ;
   52424             : 
   52425           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   52426             :         }
   52427           0 :      return returnPointer ;
   52428             :    }
   52429             : 
   52430             : //############################################################################
   52431             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   52432             :   for the AST with the index astIndex
   52433             : */
   52434           0 : SgOmpAllocatorClause * SgOmpAllocatorClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   52435           0 :      SgOmpAllocatorClause* returnPointer = NULL;
   52436           0 :      if ( globalIndex != 0 )
   52437             :         {
   52438             : 
   52439             : #if FILE_IO_EXTRA_CHECK
   52440           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAllocatorClause ) ) <= globalIndex ) ;
   52441           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAllocatorClause + 1 ) ) );
   52442             : #endif
   52443           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAllocatorClause )
   52444           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAllocatorClause );
   52445           0 :           unsigned long positionInPool = localIndex % SgOmpAllocatorClause::pool_size ;
   52446           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAllocatorClause::pool_size ;
   52447             : 
   52448             : #if FILE_IO_EXTRA_CHECK
   52449             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   52450             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   52451             : #endif
   52452             : 
   52453           0 :           returnPointer = &( ( (SgOmpAllocatorClause*)(SgOmpAllocatorClause::pools[memoryBlock]) ) [positionInPool]) ;
   52454             : 
   52455             : #if FILE_IO_EXTRA_CHECK
   52456           0 :           assert ( returnPointer != NULL ) ;
   52457             : #endif
   52458             :         }
   52459           0 :      return returnPointer ;
   52460             :    }
   52461             : 
   52462             : //############################################################################
   52463             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   52464             :  * pool size! We set for every valid object in the memory pool the freepointer
   52465             :  * to the global index and increase the global index afterwards. For all the 
   52466             :  * invalid objects (means address ranges within the memory pool that were not
   52467             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   52468             :  * distinguish valid from invalid objects! 
   52469             :  */
   52470             : unsigned long
   52471           5 : SgOmpAllocatorClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   52472             :    {
   52473           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   52474           5 :      SgOmpAllocatorClause* pointer = NULL;
   52475           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   52476           5 :      std::vector < unsigned char* > :: const_iterator block;
   52477           5 :      for ( block = SgOmpAllocatorClause::pools.begin(); block != SgOmpAllocatorClause::pools.end() ; ++block )
   52478             :         {
   52479           0 :           pointer = (SgOmpAllocatorClause*)(*block);
   52480           0 :           for (unsigned i = 0; i < SgOmpAllocatorClause::pool_size; ++i )
   52481             :              {
   52482             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   52483             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   52484             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   52485             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   52486             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   52487             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   52488             :             // properly; so this will have to be checked next.
   52489             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   52490             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   52491           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   52492             :                   {
   52493           0 :                     pointer[i].set_freepointer((SgOmpAllocatorClause*)(globalIndex));
   52494           0 :                     globalIndex++;
   52495             :                   }
   52496             :                else
   52497             :                   {
   52498           0 :                     pointer[i].set_freepointer(NULL);
   52499             :                   }
   52500             :               }
   52501             :         }
   52502           5 :      return globalIndex;
   52503             :    }
   52504             : 
   52505             : //############################################################################
   52506             : // JH (01/14/2006)
   52507             : void
   52508           5 : SgOmpAllocatorClause::resetValidFreepointers( )
   52509             :    {
   52510           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   52511           5 :      SgOmpAllocatorClause* pointer = NULL;
   52512           5 :      std::vector < unsigned char* > :: const_iterator block;
   52513           5 :      SgOmpAllocatorClause* pointerOfLinkedList = NULL;
   52514           5 :      for ( block = SgOmpAllocatorClause::pools.begin(); block != SgOmpAllocatorClause::pools.end() ; ++block )
   52515             :         {
   52516           0 :           pointer = (SgOmpAllocatorClause*)(*block);
   52517           0 :           for (unsigned i = 0; i < SgOmpAllocatorClause::pool_size; ++i )
   52518             :              {
   52519             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   52520             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   52521             :             // memory blocks!.
   52522           0 :                if ( pointer[i].get_freepointer() != NULL )
   52523             :                   {
   52524           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   52525             :                   }
   52526             :                else
   52527             :                   {
   52528           0 :                     if ( pointerOfLinkedList == NULL )
   52529             :                        {
   52530           0 :                          SgOmpAllocatorClause::next_node = &(pointer[i]);
   52531             :                        }
   52532             :                     else
   52533             :                        {
   52534             :                       // printf ("In SgOmpAllocatorClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   52535           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   52536             :                        }
   52537             :                     pointerOfLinkedList = &(pointer[i]);
   52538             :                   }
   52539             :               }
   52540             :         }
   52541             : 
   52542           5 :      if ( pointerOfLinkedList != NULL )
   52543             :         {
   52544             :        // printf ("In SgOmpAllocatorClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   52545           0 :           pointerOfLinkedList->set_freepointer(NULL);
   52546             :        // DQ (6/6/2010): Temporary debugging...
   52547             :        //   ROSE_ASSERT(false);
   52548             :         }
   52549             : 
   52550           5 :      return ;
   52551             :    }
   52552             : 
   52553             : //############################################################################
   52554             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   52555             :  * within the memory pool and resets the freepointers, in order to achieve a 
   52556             :  * linked list, that has no jumps and starts at the beginning! This function 
   52557             :  * does not extend the memory pool, since we do not delete any memory blocks,
   52558             :  * but delete the valid objects.  
   52559             :  */
   52560             : void
   52561           0 : SgOmpAllocatorClause::clearMemoryPool( )
   52562             :    {
   52563             :   // printf ("Inside of SgOmpAllocatorClause::clearMemoryPool() \n");
   52564             : 
   52565           0 :      SgOmpAllocatorClause* pointer = NULL, *tempPointer = NULL;
   52566           0 :      std::vector < unsigned char* > :: const_iterator block;
   52567           0 :      if ( SgOmpAllocatorClause::pools.empty() == false )
   52568             :         {
   52569           0 :           block = SgOmpAllocatorClause::pools.begin() ;
   52570           0 :           SgOmpAllocatorClause::next_node = (SgOmpAllocatorClause*) (*block);
   52571             : 
   52572           0 :           while ( block != SgOmpAllocatorClause::pools.end() )
   52573             :              {
   52574           0 :                pointer = (SgOmpAllocatorClause*) (*block);
   52575           0 :                if ( tempPointer != NULL )
   52576             :                   {
   52577           0 :                     tempPointer->set_freepointer(pointer);
   52578             :                   }
   52579           0 :                for (unsigned i = 0; i < SgOmpAllocatorClause::pool_size - 1; ++i)
   52580             :                   {
   52581           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   52582             :                   }
   52583           0 :                 pointer[SgOmpAllocatorClause::pool_size-1].set_freepointer(NULL);
   52584           0 :                 tempPointer = &(pointer[SgOmpAllocatorClause::pool_size-1]);
   52585           0 :                 ++block;
   52586             :              }
   52587             :         }
   52588           0 :    }
   52589             : 
   52590           5 : void SgOmpAllocatorClause::deleteMemoryPool() {
   52591           5 :   for (auto p: SgOmpAllocatorClause::pools) {
   52592           0 :     ROSE_FREE(p);
   52593             :   }
   52594           5 :   SgOmpAllocatorClause::next_node = nullptr;
   52595           5 :   SgOmpAllocatorClause::pools.clear();
   52596           5 : }
   52597             : 
   52598             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   52599             : //                 reading multiple binary files to for a single AST.
   52600             : /////////// new version ////////////////////////////////
   52601             : //############################################################################
   52602             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   52603             : void
   52604           2 : SgOmpAllocatorClause::extendMemoryPoolForFileIO( )
   52605             :   {
   52606           2 :     size_t blockIndex = SgOmpAllocatorClause::pools.size();
   52607           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocatorClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocatorClause);
   52608             : 
   52609           2 :     while ( (blockIndex * SgOmpAllocatorClause::pool_size) < newPoolSize)
   52610             :       {
   52611             : #if ROSE_ALLOC_TRACE
   52612             :         if (blockIndex > 0) {
   52613             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocatorClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocatorClause) = %" PRIuPTR " SgOmpAllocatorClause::pool_size = %d \n",
   52614             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocatorClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocatorClause),SgOmpAllocatorClause::pool_size);
   52615             :         }
   52616             : #endif
   52617             : 
   52618           0 :         SgOmpAllocatorClause * pointer = (SgOmpAllocatorClause*) ROSE_MALLOC ( SgOmpAllocatorClause::pool_size * sizeof(SgOmpAllocatorClause) );
   52619           0 :         assert( pointer != NULL );
   52620             : #if ROSE_ALLOC_MEMSET == 1
   52621             :         memset(pointer, 0x00, SgOmpAllocatorClause::pool_size * sizeof(SgOmpAllocatorClause));
   52622             : #elif ROSE_ALLOC_MEMSET == 2
   52623             :         memset(pointer, 0xCC, SgOmpAllocatorClause::pool_size * sizeof(SgOmpAllocatorClause));
   52624             : #endif
   52625           0 :         SgOmpAllocatorClause::pools.push_back( (unsigned char*)(pointer) );
   52626           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAllocatorClause::pool_size * sizeof(SgOmpAllocatorClause), V_SgOmpAllocatorClause ) );
   52627             : 
   52628           0 :         if ( SgOmpAllocatorClause::next_node != NULL ) {
   52629           0 :           if ( blockIndex > 0 ) {
   52630           0 :             SgOmpAllocatorClause * blkptr = (SgOmpAllocatorClause*)(SgOmpAllocatorClause::pools[blockIndex-1]);
   52631           0 :             blkptr[ SgOmpAllocatorClause::pool_size - 1 ].set_freepointer(pointer);
   52632             :           }
   52633             :         } else {
   52634           0 :           SgOmpAllocatorClause::next_node = pointer;
   52635             :         }
   52636             : 
   52637           0 :         for (unsigned i = 0; i < SgOmpAllocatorClause::pool_size-1; ++i)
   52638             :            {
   52639           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   52640             :            }
   52641           0 :         pointer[ SgOmpAllocatorClause::pool_size -1 ].set_freepointer(NULL);
   52642             : 
   52643           0 :         blockIndex++;
   52644             :       }
   52645           2 :   }
   52646             : 
   52647             : //############################################################################
   52648             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   52649             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   52650             :  * not compressed. However, that stuff is not yet implemented! 
   52651             :  */
   52652             : unsigned long
   52653           0 : SgOmpAllocatorClause::getNumberOfLastValidPointer()
   52654             :    {
   52655           0 :       SgOmpAllocatorClause* testPointer = (SgOmpAllocatorClause*)(SgOmpAllocatorClause::pools.back());
   52656           0 :       unsigned long localIndex = SgOmpAllocatorClause::pool_size - 1;
   52657           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   52658             :          {
   52659           0 :            localIndex--;
   52660             :          }
   52661           0 :       return (localIndex + SgOmpAllocatorClause::pool_size * (SgOmpAllocatorClause::pools.size()-1));
   52662             :    }
   52663             : 
   52664             : //############################################################################
   52665             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   52666             :  * memory pool and initializes the data member in class SgOmpAllocatorClauseStroageClass
   52667             :  * from its counterpart of SgOmpAllocatorClause. The return value is just for checking, 
   52668             :  * that the whole StorageClassArray is initialized!
   52669             :  */
   52670             : unsigned long
   52671           0 : SgOmpAllocatorClause::initializeStorageClassArray( SgOmpAllocatorClauseStorageClass *storageArray )
   52672             :    {
   52673           0 :      unsigned long storageCounter = 0;
   52674           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAllocatorClause::pools.begin();
   52675           0 :      SgOmpAllocatorClause* pointer = NULL;
   52676           0 :      while ( block != SgOmpAllocatorClause::pools.end() ) {
   52677           0 :           pointer = (SgOmpAllocatorClause*) (*block);
   52678           0 :           for ( unsigned i = 0; i < SgOmpAllocatorClause::pool_size; ++i ) {
   52679           0 :                if ( pointer->get_freepointer() != NULL ) {
   52680           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   52681           0 :                  storageArray++;
   52682           0 :                  storageCounter++;
   52683             :                }
   52684           0 :                pointer++;
   52685             :              }
   52686           0 :            block++;
   52687             :         }
   52688           0 :      return storageCounter;
   52689             :    }
   52690             : 
   52691             : /* #line 52692 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   52692             : 
   52693             : 
   52694             : 
   52695             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   52696             : 
   52697             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   52698             : 
   52699             : //############################################################################
   52700             : /* JH (02/02/2006) Constructor of the IR node SgOmpAtomicClause that takes its 
   52701             :  * corresponding StorageClass as parameter
   52702             :  */
   52703           0 : SgOmpAtomicClause :: SgOmpAtomicClause ( const SgOmpAtomicClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   52704             :    {
   52705             : 
   52706             : 
   52707             : /* #line 52708 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   52708             : 
   52709           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   52710           0 :      p_atomicity = storageSource.storageOf_atomicity ;
   52711             : 
   52712             : 
   52713             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   52714             : 
   52715             : 
   52716           0 :    }
   52717             : 
   52718             : //############################################################################
   52719             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   52720             :  * within the working AST. 
   52721             :  */
   52722           0 : SgOmpAtomicClause * SgOmpAtomicClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   52723           0 :      SgOmpAtomicClause* returnPointer = NULL;
   52724           0 :      if ( globalIndex != 0 )
   52725             :         {
   52726             : 
   52727             : #if FILE_IO_EXTRA_CHECK
   52728           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAtomicClause ) ) <= globalIndex ) ;
   52729           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAtomicClause + 1 ) ) );
   52730             : #endif
   52731           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAtomicClause )  
   52732           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAtomicClause );
   52733           0 :           unsigned long positionInPool = localIndex % SgOmpAtomicClause::pool_size;
   52734           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAtomicClause::pool_size;
   52735             : 
   52736             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   52737             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   52738             : 
   52739           0 :           returnPointer = &( ( (SgOmpAtomicClause*)(SgOmpAtomicClause::pools[memoryBlock]) ) [positionInPool]) ;
   52740             : 
   52741           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   52742             :         }
   52743           0 :      return returnPointer ;
   52744             :    }
   52745             : 
   52746             : //############################################################################
   52747             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   52748             :   for the AST with the index astIndex
   52749             : */
   52750           0 : SgOmpAtomicClause * SgOmpAtomicClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   52751           0 :      SgOmpAtomicClause* returnPointer = NULL;
   52752           0 :      if ( globalIndex != 0 )
   52753             :         {
   52754             : 
   52755             : #if FILE_IO_EXTRA_CHECK
   52756           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAtomicClause ) ) <= globalIndex ) ;
   52757           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAtomicClause + 1 ) ) );
   52758             : #endif
   52759           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAtomicClause )
   52760           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAtomicClause );
   52761           0 :           unsigned long positionInPool = localIndex % SgOmpAtomicClause::pool_size ;
   52762           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAtomicClause::pool_size ;
   52763             : 
   52764             : #if FILE_IO_EXTRA_CHECK
   52765             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   52766             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   52767             : #endif
   52768             : 
   52769           0 :           returnPointer = &( ( (SgOmpAtomicClause*)(SgOmpAtomicClause::pools[memoryBlock]) ) [positionInPool]) ;
   52770             : 
   52771             : #if FILE_IO_EXTRA_CHECK
   52772           0 :           assert ( returnPointer != NULL ) ;
   52773             : #endif
   52774             :         }
   52775           0 :      return returnPointer ;
   52776             :    }
   52777             : 
   52778             : //############################################################################
   52779             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   52780             :  * pool size! We set for every valid object in the memory pool the freepointer
   52781             :  * to the global index and increase the global index afterwards. For all the 
   52782             :  * invalid objects (means address ranges within the memory pool that were not
   52783             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   52784             :  * distinguish valid from invalid objects! 
   52785             :  */
   52786             : unsigned long
   52787           5 : SgOmpAtomicClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   52788             :    {
   52789           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   52790           5 :      SgOmpAtomicClause* pointer = NULL;
   52791           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   52792           5 :      std::vector < unsigned char* > :: const_iterator block;
   52793           5 :      for ( block = SgOmpAtomicClause::pools.begin(); block != SgOmpAtomicClause::pools.end() ; ++block )
   52794             :         {
   52795           0 :           pointer = (SgOmpAtomicClause*)(*block);
   52796           0 :           for (unsigned i = 0; i < SgOmpAtomicClause::pool_size; ++i )
   52797             :              {
   52798             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   52799             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   52800             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   52801             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   52802             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   52803             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   52804             :             // properly; so this will have to be checked next.
   52805             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   52806             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   52807           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   52808             :                   {
   52809           0 :                     pointer[i].set_freepointer((SgOmpAtomicClause*)(globalIndex));
   52810           0 :                     globalIndex++;
   52811             :                   }
   52812             :                else
   52813             :                   {
   52814           0 :                     pointer[i].set_freepointer(NULL);
   52815             :                   }
   52816             :               }
   52817             :         }
   52818           5 :      return globalIndex;
   52819             :    }
   52820             : 
   52821             : //############################################################################
   52822             : // JH (01/14/2006)
   52823             : void
   52824           5 : SgOmpAtomicClause::resetValidFreepointers( )
   52825             :    {
   52826           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   52827           5 :      SgOmpAtomicClause* pointer = NULL;
   52828           5 :      std::vector < unsigned char* > :: const_iterator block;
   52829           5 :      SgOmpAtomicClause* pointerOfLinkedList = NULL;
   52830           5 :      for ( block = SgOmpAtomicClause::pools.begin(); block != SgOmpAtomicClause::pools.end() ; ++block )
   52831             :         {
   52832           0 :           pointer = (SgOmpAtomicClause*)(*block);
   52833           0 :           for (unsigned i = 0; i < SgOmpAtomicClause::pool_size; ++i )
   52834             :              {
   52835             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   52836             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   52837             :             // memory blocks!.
   52838           0 :                if ( pointer[i].get_freepointer() != NULL )
   52839             :                   {
   52840           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   52841             :                   }
   52842             :                else
   52843             :                   {
   52844           0 :                     if ( pointerOfLinkedList == NULL )
   52845             :                        {
   52846           0 :                          SgOmpAtomicClause::next_node = &(pointer[i]);
   52847             :                        }
   52848             :                     else
   52849             :                        {
   52850             :                       // printf ("In SgOmpAtomicClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   52851           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   52852             :                        }
   52853             :                     pointerOfLinkedList = &(pointer[i]);
   52854             :                   }
   52855             :               }
   52856             :         }
   52857             : 
   52858           5 :      if ( pointerOfLinkedList != NULL )
   52859             :         {
   52860             :        // printf ("In SgOmpAtomicClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   52861           0 :           pointerOfLinkedList->set_freepointer(NULL);
   52862             :        // DQ (6/6/2010): Temporary debugging...
   52863             :        //   ROSE_ASSERT(false);
   52864             :         }
   52865             : 
   52866           5 :      return ;
   52867             :    }
   52868             : 
   52869             : //############################################################################
   52870             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   52871             :  * within the memory pool and resets the freepointers, in order to achieve a 
   52872             :  * linked list, that has no jumps and starts at the beginning! This function 
   52873             :  * does not extend the memory pool, since we do not delete any memory blocks,
   52874             :  * but delete the valid objects.  
   52875             :  */
   52876             : void
   52877           0 : SgOmpAtomicClause::clearMemoryPool( )
   52878             :    {
   52879             :   // printf ("Inside of SgOmpAtomicClause::clearMemoryPool() \n");
   52880             : 
   52881           0 :      SgOmpAtomicClause* pointer = NULL, *tempPointer = NULL;
   52882           0 :      std::vector < unsigned char* > :: const_iterator block;
   52883           0 :      if ( SgOmpAtomicClause::pools.empty() == false )
   52884             :         {
   52885           0 :           block = SgOmpAtomicClause::pools.begin() ;
   52886           0 :           SgOmpAtomicClause::next_node = (SgOmpAtomicClause*) (*block);
   52887             : 
   52888           0 :           while ( block != SgOmpAtomicClause::pools.end() )
   52889             :              {
   52890           0 :                pointer = (SgOmpAtomicClause*) (*block);
   52891           0 :                if ( tempPointer != NULL )
   52892             :                   {
   52893           0 :                     tempPointer->set_freepointer(pointer);
   52894             :                   }
   52895           0 :                for (unsigned i = 0; i < SgOmpAtomicClause::pool_size - 1; ++i)
   52896             :                   {
   52897           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   52898             :                   }
   52899           0 :                 pointer[SgOmpAtomicClause::pool_size-1].set_freepointer(NULL);
   52900           0 :                 tempPointer = &(pointer[SgOmpAtomicClause::pool_size-1]);
   52901           0 :                 ++block;
   52902             :              }
   52903             :         }
   52904           0 :    }
   52905             : 
   52906           5 : void SgOmpAtomicClause::deleteMemoryPool() {
   52907           5 :   for (auto p: SgOmpAtomicClause::pools) {
   52908           0 :     ROSE_FREE(p);
   52909             :   }
   52910           5 :   SgOmpAtomicClause::next_node = nullptr;
   52911           5 :   SgOmpAtomicClause::pools.clear();
   52912           5 : }
   52913             : 
   52914             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   52915             : //                 reading multiple binary files to for a single AST.
   52916             : /////////// new version ////////////////////////////////
   52917             : //############################################################################
   52918             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   52919             : void
   52920           2 : SgOmpAtomicClause::extendMemoryPoolForFileIO( )
   52921             :   {
   52922           2 :     size_t blockIndex = SgOmpAtomicClause::pools.size();
   52923           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicClause);
   52924             : 
   52925           2 :     while ( (blockIndex * SgOmpAtomicClause::pool_size) < newPoolSize)
   52926             :       {
   52927             : #if ROSE_ALLOC_TRACE
   52928             :         if (blockIndex > 0) {
   52929             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicClause) = %" PRIuPTR " SgOmpAtomicClause::pool_size = %d \n",
   52930             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicClause),SgOmpAtomicClause::pool_size);
   52931             :         }
   52932             : #endif
   52933             : 
   52934           0 :         SgOmpAtomicClause * pointer = (SgOmpAtomicClause*) ROSE_MALLOC ( SgOmpAtomicClause::pool_size * sizeof(SgOmpAtomicClause) );
   52935           0 :         assert( pointer != NULL );
   52936             : #if ROSE_ALLOC_MEMSET == 1
   52937             :         memset(pointer, 0x00, SgOmpAtomicClause::pool_size * sizeof(SgOmpAtomicClause));
   52938             : #elif ROSE_ALLOC_MEMSET == 2
   52939             :         memset(pointer, 0xCC, SgOmpAtomicClause::pool_size * sizeof(SgOmpAtomicClause));
   52940             : #endif
   52941           0 :         SgOmpAtomicClause::pools.push_back( (unsigned char*)(pointer) );
   52942           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAtomicClause::pool_size * sizeof(SgOmpAtomicClause), V_SgOmpAtomicClause ) );
   52943             : 
   52944           0 :         if ( SgOmpAtomicClause::next_node != NULL ) {
   52945           0 :           if ( blockIndex > 0 ) {
   52946           0 :             SgOmpAtomicClause * blkptr = (SgOmpAtomicClause*)(SgOmpAtomicClause::pools[blockIndex-1]);
   52947           0 :             blkptr[ SgOmpAtomicClause::pool_size - 1 ].set_freepointer(pointer);
   52948             :           }
   52949             :         } else {
   52950           0 :           SgOmpAtomicClause::next_node = pointer;
   52951             :         }
   52952             : 
   52953           0 :         for (unsigned i = 0; i < SgOmpAtomicClause::pool_size-1; ++i)
   52954             :            {
   52955           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   52956             :            }
   52957           0 :         pointer[ SgOmpAtomicClause::pool_size -1 ].set_freepointer(NULL);
   52958             : 
   52959           0 :         blockIndex++;
   52960             :       }
   52961           2 :   }
   52962             : 
   52963             : //############################################################################
   52964             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   52965             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   52966             :  * not compressed. However, that stuff is not yet implemented! 
   52967             :  */
   52968             : unsigned long
   52969           0 : SgOmpAtomicClause::getNumberOfLastValidPointer()
   52970             :    {
   52971           0 :       SgOmpAtomicClause* testPointer = (SgOmpAtomicClause*)(SgOmpAtomicClause::pools.back());
   52972           0 :       unsigned long localIndex = SgOmpAtomicClause::pool_size - 1;
   52973           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   52974             :          {
   52975           0 :            localIndex--;
   52976             :          }
   52977           0 :       return (localIndex + SgOmpAtomicClause::pool_size * (SgOmpAtomicClause::pools.size()-1));
   52978             :    }
   52979             : 
   52980             : //############################################################################
   52981             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   52982             :  * memory pool and initializes the data member in class SgOmpAtomicClauseStroageClass
   52983             :  * from its counterpart of SgOmpAtomicClause. The return value is just for checking, 
   52984             :  * that the whole StorageClassArray is initialized!
   52985             :  */
   52986             : unsigned long
   52987           0 : SgOmpAtomicClause::initializeStorageClassArray( SgOmpAtomicClauseStorageClass *storageArray )
   52988             :    {
   52989           0 :      unsigned long storageCounter = 0;
   52990           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAtomicClause::pools.begin();
   52991           0 :      SgOmpAtomicClause* pointer = NULL;
   52992           0 :      while ( block != SgOmpAtomicClause::pools.end() ) {
   52993           0 :           pointer = (SgOmpAtomicClause*) (*block);
   52994           0 :           for ( unsigned i = 0; i < SgOmpAtomicClause::pool_size; ++i ) {
   52995           0 :                if ( pointer->get_freepointer() != NULL ) {
   52996           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   52997           0 :                  storageArray++;
   52998           0 :                  storageCounter++;
   52999             :                }
   53000           0 :                pointer++;
   53001             :              }
   53002           0 :            block++;
   53003             :         }
   53004           0 :      return storageCounter;
   53005             :    }
   53006             : 
   53007             : /* #line 53008 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   53008             : 
   53009             : 
   53010             : 
   53011             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   53012             : 
   53013             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   53014             : 
   53015             : //############################################################################
   53016             : /* JH (02/02/2006) Constructor of the IR node SgOmpProcBindClause that takes its 
   53017             :  * corresponding StorageClass as parameter
   53018             :  */
   53019           0 : SgOmpProcBindClause :: SgOmpProcBindClause ( const SgOmpProcBindClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   53020             :    {
   53021             : 
   53022             : 
   53023             : /* #line 53024 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   53024             : 
   53025           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   53026           0 :      p_policy = storageSource.storageOf_policy ;
   53027             : 
   53028             : 
   53029             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   53030             : 
   53031             : 
   53032           0 :    }
   53033             : 
   53034             : //############################################################################
   53035             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   53036             :  * within the working AST. 
   53037             :  */
   53038           0 : SgOmpProcBindClause * SgOmpProcBindClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   53039           0 :      SgOmpProcBindClause* returnPointer = NULL;
   53040           0 :      if ( globalIndex != 0 )
   53041             :         {
   53042             : 
   53043             : #if FILE_IO_EXTRA_CHECK
   53044           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpProcBindClause ) ) <= globalIndex ) ;
   53045           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpProcBindClause + 1 ) ) );
   53046             : #endif
   53047           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpProcBindClause )  
   53048           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpProcBindClause );
   53049           0 :           unsigned long positionInPool = localIndex % SgOmpProcBindClause::pool_size;
   53050           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpProcBindClause::pool_size;
   53051             : 
   53052             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   53053             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   53054             : 
   53055           0 :           returnPointer = &( ( (SgOmpProcBindClause*)(SgOmpProcBindClause::pools[memoryBlock]) ) [positionInPool]) ;
   53056             : 
   53057           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   53058             :         }
   53059           0 :      return returnPointer ;
   53060             :    }
   53061             : 
   53062             : //############################################################################
   53063             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   53064             :   for the AST with the index astIndex
   53065             : */
   53066           0 : SgOmpProcBindClause * SgOmpProcBindClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   53067           0 :      SgOmpProcBindClause* returnPointer = NULL;
   53068           0 :      if ( globalIndex != 0 )
   53069             :         {
   53070             : 
   53071             : #if FILE_IO_EXTRA_CHECK
   53072           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpProcBindClause ) ) <= globalIndex ) ;
   53073           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpProcBindClause + 1 ) ) );
   53074             : #endif
   53075           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpProcBindClause )
   53076           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpProcBindClause );
   53077           0 :           unsigned long positionInPool = localIndex % SgOmpProcBindClause::pool_size ;
   53078           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpProcBindClause::pool_size ;
   53079             : 
   53080             : #if FILE_IO_EXTRA_CHECK
   53081             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   53082             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   53083             : #endif
   53084             : 
   53085           0 :           returnPointer = &( ( (SgOmpProcBindClause*)(SgOmpProcBindClause::pools[memoryBlock]) ) [positionInPool]) ;
   53086             : 
   53087             : #if FILE_IO_EXTRA_CHECK
   53088           0 :           assert ( returnPointer != NULL ) ;
   53089             : #endif
   53090             :         }
   53091           0 :      return returnPointer ;
   53092             :    }
   53093             : 
   53094             : //############################################################################
   53095             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   53096             :  * pool size! We set for every valid object in the memory pool the freepointer
   53097             :  * to the global index and increase the global index afterwards. For all the 
   53098             :  * invalid objects (means address ranges within the memory pool that were not
   53099             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   53100             :  * distinguish valid from invalid objects! 
   53101             :  */
   53102             : unsigned long
   53103           5 : SgOmpProcBindClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   53104             :    {
   53105           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   53106           5 :      SgOmpProcBindClause* pointer = NULL;
   53107           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   53108           5 :      std::vector < unsigned char* > :: const_iterator block;
   53109           5 :      for ( block = SgOmpProcBindClause::pools.begin(); block != SgOmpProcBindClause::pools.end() ; ++block )
   53110             :         {
   53111           0 :           pointer = (SgOmpProcBindClause*)(*block);
   53112           0 :           for (unsigned i = 0; i < SgOmpProcBindClause::pool_size; ++i )
   53113             :              {
   53114             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   53115             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   53116             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   53117             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   53118             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   53119             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   53120             :             // properly; so this will have to be checked next.
   53121             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   53122             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   53123           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   53124             :                   {
   53125           0 :                     pointer[i].set_freepointer((SgOmpProcBindClause*)(globalIndex));
   53126           0 :                     globalIndex++;
   53127             :                   }
   53128             :                else
   53129             :                   {
   53130           0 :                     pointer[i].set_freepointer(NULL);
   53131             :                   }
   53132             :               }
   53133             :         }
   53134           5 :      return globalIndex;
   53135             :    }
   53136             : 
   53137             : //############################################################################
   53138             : // JH (01/14/2006)
   53139             : void
   53140           5 : SgOmpProcBindClause::resetValidFreepointers( )
   53141             :    {
   53142           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   53143           5 :      SgOmpProcBindClause* pointer = NULL;
   53144           5 :      std::vector < unsigned char* > :: const_iterator block;
   53145           5 :      SgOmpProcBindClause* pointerOfLinkedList = NULL;
   53146           5 :      for ( block = SgOmpProcBindClause::pools.begin(); block != SgOmpProcBindClause::pools.end() ; ++block )
   53147             :         {
   53148           0 :           pointer = (SgOmpProcBindClause*)(*block);
   53149           0 :           for (unsigned i = 0; i < SgOmpProcBindClause::pool_size; ++i )
   53150             :              {
   53151             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   53152             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   53153             :             // memory blocks!.
   53154           0 :                if ( pointer[i].get_freepointer() != NULL )
   53155             :                   {
   53156           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   53157             :                   }
   53158             :                else
   53159             :                   {
   53160           0 :                     if ( pointerOfLinkedList == NULL )
   53161             :                        {
   53162           0 :                          SgOmpProcBindClause::next_node = &(pointer[i]);
   53163             :                        }
   53164             :                     else
   53165             :                        {
   53166             :                       // printf ("In SgOmpProcBindClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   53167           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   53168             :                        }
   53169             :                     pointerOfLinkedList = &(pointer[i]);
   53170             :                   }
   53171             :               }
   53172             :         }
   53173             : 
   53174           5 :      if ( pointerOfLinkedList != NULL )
   53175             :         {
   53176             :        // printf ("In SgOmpProcBindClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   53177           0 :           pointerOfLinkedList->set_freepointer(NULL);
   53178             :        // DQ (6/6/2010): Temporary debugging...
   53179             :        //   ROSE_ASSERT(false);
   53180             :         }
   53181             : 
   53182           5 :      return ;
   53183             :    }
   53184             : 
   53185             : //############################################################################
   53186             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   53187             :  * within the memory pool and resets the freepointers, in order to achieve a 
   53188             :  * linked list, that has no jumps and starts at the beginning! This function 
   53189             :  * does not extend the memory pool, since we do not delete any memory blocks,
   53190             :  * but delete the valid objects.  
   53191             :  */
   53192             : void
   53193           0 : SgOmpProcBindClause::clearMemoryPool( )
   53194             :    {
   53195             :   // printf ("Inside of SgOmpProcBindClause::clearMemoryPool() \n");
   53196             : 
   53197           0 :      SgOmpProcBindClause* pointer = NULL, *tempPointer = NULL;
   53198           0 :      std::vector < unsigned char* > :: const_iterator block;
   53199           0 :      if ( SgOmpProcBindClause::pools.empty() == false )
   53200             :         {
   53201           0 :           block = SgOmpProcBindClause::pools.begin() ;
   53202           0 :           SgOmpProcBindClause::next_node = (SgOmpProcBindClause*) (*block);
   53203             : 
   53204           0 :           while ( block != SgOmpProcBindClause::pools.end() )
   53205             :              {
   53206           0 :                pointer = (SgOmpProcBindClause*) (*block);
   53207           0 :                if ( tempPointer != NULL )
   53208             :                   {
   53209           0 :                     tempPointer->set_freepointer(pointer);
   53210             :                   }
   53211           0 :                for (unsigned i = 0; i < SgOmpProcBindClause::pool_size - 1; ++i)
   53212             :                   {
   53213           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   53214             :                   }
   53215           0 :                 pointer[SgOmpProcBindClause::pool_size-1].set_freepointer(NULL);
   53216           0 :                 tempPointer = &(pointer[SgOmpProcBindClause::pool_size-1]);
   53217           0 :                 ++block;
   53218             :              }
   53219             :         }
   53220           0 :    }
   53221             : 
   53222           5 : void SgOmpProcBindClause::deleteMemoryPool() {
   53223           5 :   for (auto p: SgOmpProcBindClause::pools) {
   53224           0 :     ROSE_FREE(p);
   53225             :   }
   53226           5 :   SgOmpProcBindClause::next_node = nullptr;
   53227           5 :   SgOmpProcBindClause::pools.clear();
   53228           5 : }
   53229             : 
   53230             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   53231             : //                 reading multiple binary files to for a single AST.
   53232             : /////////// new version ////////////////////////////////
   53233             : //############################################################################
   53234             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   53235             : void
   53236           2 : SgOmpProcBindClause::extendMemoryPoolForFileIO( )
   53237             :   {
   53238           2 :     size_t blockIndex = SgOmpProcBindClause::pools.size();
   53239           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpProcBindClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpProcBindClause);
   53240             : 
   53241           2 :     while ( (blockIndex * SgOmpProcBindClause::pool_size) < newPoolSize)
   53242             :       {
   53243             : #if ROSE_ALLOC_TRACE
   53244             :         if (blockIndex > 0) {
   53245             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpProcBindClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpProcBindClause) = %" PRIuPTR " SgOmpProcBindClause::pool_size = %d \n",
   53246             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpProcBindClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpProcBindClause),SgOmpProcBindClause::pool_size);
   53247             :         }
   53248             : #endif
   53249             : 
   53250           0 :         SgOmpProcBindClause * pointer = (SgOmpProcBindClause*) ROSE_MALLOC ( SgOmpProcBindClause::pool_size * sizeof(SgOmpProcBindClause) );
   53251           0 :         assert( pointer != NULL );
   53252             : #if ROSE_ALLOC_MEMSET == 1
   53253             :         memset(pointer, 0x00, SgOmpProcBindClause::pool_size * sizeof(SgOmpProcBindClause));
   53254             : #elif ROSE_ALLOC_MEMSET == 2
   53255             :         memset(pointer, 0xCC, SgOmpProcBindClause::pool_size * sizeof(SgOmpProcBindClause));
   53256             : #endif
   53257           0 :         SgOmpProcBindClause::pools.push_back( (unsigned char*)(pointer) );
   53258           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpProcBindClause::pool_size * sizeof(SgOmpProcBindClause), V_SgOmpProcBindClause ) );
   53259             : 
   53260           0 :         if ( SgOmpProcBindClause::next_node != NULL ) {
   53261           0 :           if ( blockIndex > 0 ) {
   53262           0 :             SgOmpProcBindClause * blkptr = (SgOmpProcBindClause*)(SgOmpProcBindClause::pools[blockIndex-1]);
   53263           0 :             blkptr[ SgOmpProcBindClause::pool_size - 1 ].set_freepointer(pointer);
   53264             :           }
   53265             :         } else {
   53266           0 :           SgOmpProcBindClause::next_node = pointer;
   53267             :         }
   53268             : 
   53269           0 :         for (unsigned i = 0; i < SgOmpProcBindClause::pool_size-1; ++i)
   53270             :            {
   53271           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   53272             :            }
   53273           0 :         pointer[ SgOmpProcBindClause::pool_size -1 ].set_freepointer(NULL);
   53274             : 
   53275           0 :         blockIndex++;
   53276             :       }
   53277           2 :   }
   53278             : 
   53279             : //############################################################################
   53280             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   53281             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   53282             :  * not compressed. However, that stuff is not yet implemented! 
   53283             :  */
   53284             : unsigned long
   53285           0 : SgOmpProcBindClause::getNumberOfLastValidPointer()
   53286             :    {
   53287           0 :       SgOmpProcBindClause* testPointer = (SgOmpProcBindClause*)(SgOmpProcBindClause::pools.back());
   53288           0 :       unsigned long localIndex = SgOmpProcBindClause::pool_size - 1;
   53289           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   53290             :          {
   53291           0 :            localIndex--;
   53292             :          }
   53293           0 :       return (localIndex + SgOmpProcBindClause::pool_size * (SgOmpProcBindClause::pools.size()-1));
   53294             :    }
   53295             : 
   53296             : //############################################################################
   53297             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   53298             :  * memory pool and initializes the data member in class SgOmpProcBindClauseStroageClass
   53299             :  * from its counterpart of SgOmpProcBindClause. The return value is just for checking, 
   53300             :  * that the whole StorageClassArray is initialized!
   53301             :  */
   53302             : unsigned long
   53303           0 : SgOmpProcBindClause::initializeStorageClassArray( SgOmpProcBindClauseStorageClass *storageArray )
   53304             :    {
   53305           0 :      unsigned long storageCounter = 0;
   53306           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpProcBindClause::pools.begin();
   53307           0 :      SgOmpProcBindClause* pointer = NULL;
   53308           0 :      while ( block != SgOmpProcBindClause::pools.end() ) {
   53309           0 :           pointer = (SgOmpProcBindClause*) (*block);
   53310           0 :           for ( unsigned i = 0; i < SgOmpProcBindClause::pool_size; ++i ) {
   53311           0 :                if ( pointer->get_freepointer() != NULL ) {
   53312           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   53313           0 :                  storageArray++;
   53314           0 :                  storageCounter++;
   53315             :                }
   53316           0 :                pointer++;
   53317             :              }
   53318           0 :            block++;
   53319             :         }
   53320           0 :      return storageCounter;
   53321             :    }
   53322             : 
   53323             : /* #line 53324 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   53324             : 
   53325             : 
   53326             : 
   53327             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   53328             : 
   53329             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   53330             : 
   53331             : //############################################################################
   53332             : /* JH (02/02/2006) Constructor of the IR node SgOmpBindClause that takes its 
   53333             :  * corresponding StorageClass as parameter
   53334             :  */
   53335           0 : SgOmpBindClause :: SgOmpBindClause ( const SgOmpBindClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   53336             :    {
   53337             : 
   53338             : 
   53339             : /* #line 53340 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   53340             : 
   53341           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   53342           0 :      p_binding = storageSource.storageOf_binding ;
   53343             : 
   53344             : 
   53345             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   53346             : 
   53347             : 
   53348           0 :    }
   53349             : 
   53350             : //############################################################################
   53351             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   53352             :  * within the working AST. 
   53353             :  */
   53354           0 : SgOmpBindClause * SgOmpBindClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   53355           0 :      SgOmpBindClause* returnPointer = NULL;
   53356           0 :      if ( globalIndex != 0 )
   53357             :         {
   53358             : 
   53359             : #if FILE_IO_EXTRA_CHECK
   53360           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpBindClause ) ) <= globalIndex ) ;
   53361           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpBindClause + 1 ) ) );
   53362             : #endif
   53363           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpBindClause )  
   53364           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpBindClause );
   53365           0 :           unsigned long positionInPool = localIndex % SgOmpBindClause::pool_size;
   53366           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpBindClause::pool_size;
   53367             : 
   53368             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   53369             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   53370             : 
   53371           0 :           returnPointer = &( ( (SgOmpBindClause*)(SgOmpBindClause::pools[memoryBlock]) ) [positionInPool]) ;
   53372             : 
   53373           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   53374             :         }
   53375           0 :      return returnPointer ;
   53376             :    }
   53377             : 
   53378             : //############################################################################
   53379             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   53380             :   for the AST with the index astIndex
   53381             : */
   53382           0 : SgOmpBindClause * SgOmpBindClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   53383           0 :      SgOmpBindClause* returnPointer = NULL;
   53384           0 :      if ( globalIndex != 0 )
   53385             :         {
   53386             : 
   53387             : #if FILE_IO_EXTRA_CHECK
   53388           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpBindClause ) ) <= globalIndex ) ;
   53389           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpBindClause + 1 ) ) );
   53390             : #endif
   53391           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpBindClause )
   53392           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpBindClause );
   53393           0 :           unsigned long positionInPool = localIndex % SgOmpBindClause::pool_size ;
   53394           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpBindClause::pool_size ;
   53395             : 
   53396             : #if FILE_IO_EXTRA_CHECK
   53397             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   53398             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   53399             : #endif
   53400             : 
   53401           0 :           returnPointer = &( ( (SgOmpBindClause*)(SgOmpBindClause::pools[memoryBlock]) ) [positionInPool]) ;
   53402             : 
   53403             : #if FILE_IO_EXTRA_CHECK
   53404           0 :           assert ( returnPointer != NULL ) ;
   53405             : #endif
   53406             :         }
   53407           0 :      return returnPointer ;
   53408             :    }
   53409             : 
   53410             : //############################################################################
   53411             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   53412             :  * pool size! We set for every valid object in the memory pool the freepointer
   53413             :  * to the global index and increase the global index afterwards. For all the 
   53414             :  * invalid objects (means address ranges within the memory pool that were not
   53415             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   53416             :  * distinguish valid from invalid objects! 
   53417             :  */
   53418             : unsigned long
   53419           5 : SgOmpBindClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   53420             :    {
   53421           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   53422           5 :      SgOmpBindClause* pointer = NULL;
   53423           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   53424           5 :      std::vector < unsigned char* > :: const_iterator block;
   53425           5 :      for ( block = SgOmpBindClause::pools.begin(); block != SgOmpBindClause::pools.end() ; ++block )
   53426             :         {
   53427           0 :           pointer = (SgOmpBindClause*)(*block);
   53428           0 :           for (unsigned i = 0; i < SgOmpBindClause::pool_size; ++i )
   53429             :              {
   53430             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   53431             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   53432             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   53433             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   53434             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   53435             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   53436             :             // properly; so this will have to be checked next.
   53437             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   53438             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   53439           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   53440             :                   {
   53441           0 :                     pointer[i].set_freepointer((SgOmpBindClause*)(globalIndex));
   53442           0 :                     globalIndex++;
   53443             :                   }
   53444             :                else
   53445             :                   {
   53446           0 :                     pointer[i].set_freepointer(NULL);
   53447             :                   }
   53448             :               }
   53449             :         }
   53450           5 :      return globalIndex;
   53451             :    }
   53452             : 
   53453             : //############################################################################
   53454             : // JH (01/14/2006)
   53455             : void
   53456           5 : SgOmpBindClause::resetValidFreepointers( )
   53457             :    {
   53458           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   53459           5 :      SgOmpBindClause* pointer = NULL;
   53460           5 :      std::vector < unsigned char* > :: const_iterator block;
   53461           5 :      SgOmpBindClause* pointerOfLinkedList = NULL;
   53462           5 :      for ( block = SgOmpBindClause::pools.begin(); block != SgOmpBindClause::pools.end() ; ++block )
   53463             :         {
   53464           0 :           pointer = (SgOmpBindClause*)(*block);
   53465           0 :           for (unsigned i = 0; i < SgOmpBindClause::pool_size; ++i )
   53466             :              {
   53467             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   53468             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   53469             :             // memory blocks!.
   53470           0 :                if ( pointer[i].get_freepointer() != NULL )
   53471             :                   {
   53472           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   53473             :                   }
   53474             :                else
   53475             :                   {
   53476           0 :                     if ( pointerOfLinkedList == NULL )
   53477             :                        {
   53478           0 :                          SgOmpBindClause::next_node = &(pointer[i]);
   53479             :                        }
   53480             :                     else
   53481             :                        {
   53482             :                       // printf ("In SgOmpBindClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   53483           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   53484             :                        }
   53485             :                     pointerOfLinkedList = &(pointer[i]);
   53486             :                   }
   53487             :               }
   53488             :         }
   53489             : 
   53490           5 :      if ( pointerOfLinkedList != NULL )
   53491             :         {
   53492             :        // printf ("In SgOmpBindClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   53493           0 :           pointerOfLinkedList->set_freepointer(NULL);
   53494             :        // DQ (6/6/2010): Temporary debugging...
   53495             :        //   ROSE_ASSERT(false);
   53496             :         }
   53497             : 
   53498           5 :      return ;
   53499             :    }
   53500             : 
   53501             : //############################################################################
   53502             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   53503             :  * within the memory pool and resets the freepointers, in order to achieve a 
   53504             :  * linked list, that has no jumps and starts at the beginning! This function 
   53505             :  * does not extend the memory pool, since we do not delete any memory blocks,
   53506             :  * but delete the valid objects.  
   53507             :  */
   53508             : void
   53509           0 : SgOmpBindClause::clearMemoryPool( )
   53510             :    {
   53511             :   // printf ("Inside of SgOmpBindClause::clearMemoryPool() \n");
   53512             : 
   53513           0 :      SgOmpBindClause* pointer = NULL, *tempPointer = NULL;
   53514           0 :      std::vector < unsigned char* > :: const_iterator block;
   53515           0 :      if ( SgOmpBindClause::pools.empty() == false )
   53516             :         {
   53517           0 :           block = SgOmpBindClause::pools.begin() ;
   53518           0 :           SgOmpBindClause::next_node = (SgOmpBindClause*) (*block);
   53519             : 
   53520           0 :           while ( block != SgOmpBindClause::pools.end() )
   53521             :              {
   53522           0 :                pointer = (SgOmpBindClause*) (*block);
   53523           0 :                if ( tempPointer != NULL )
   53524             :                   {
   53525           0 :                     tempPointer->set_freepointer(pointer);
   53526             :                   }
   53527           0 :                for (unsigned i = 0; i < SgOmpBindClause::pool_size - 1; ++i)
   53528             :                   {
   53529           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   53530             :                   }
   53531           0 :                 pointer[SgOmpBindClause::pool_size-1].set_freepointer(NULL);
   53532           0 :                 tempPointer = &(pointer[SgOmpBindClause::pool_size-1]);
   53533           0 :                 ++block;
   53534             :              }
   53535             :         }
   53536           0 :    }
   53537             : 
   53538           5 : void SgOmpBindClause::deleteMemoryPool() {
   53539           5 :   for (auto p: SgOmpBindClause::pools) {
   53540           0 :     ROSE_FREE(p);
   53541             :   }
   53542           5 :   SgOmpBindClause::next_node = nullptr;
   53543           5 :   SgOmpBindClause::pools.clear();
   53544           5 : }
   53545             : 
   53546             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   53547             : //                 reading multiple binary files to for a single AST.
   53548             : /////////// new version ////////////////////////////////
   53549             : //############################################################################
   53550             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   53551             : void
   53552           2 : SgOmpBindClause::extendMemoryPoolForFileIO( )
   53553             :   {
   53554           2 :     size_t blockIndex = SgOmpBindClause::pools.size();
   53555           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBindClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBindClause);
   53556             : 
   53557           2 :     while ( (blockIndex * SgOmpBindClause::pool_size) < newPoolSize)
   53558             :       {
   53559             : #if ROSE_ALLOC_TRACE
   53560             :         if (blockIndex > 0) {
   53561             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBindClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBindClause) = %" PRIuPTR " SgOmpBindClause::pool_size = %d \n",
   53562             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBindClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBindClause),SgOmpBindClause::pool_size);
   53563             :         }
   53564             : #endif
   53565             : 
   53566           0 :         SgOmpBindClause * pointer = (SgOmpBindClause*) ROSE_MALLOC ( SgOmpBindClause::pool_size * sizeof(SgOmpBindClause) );
   53567           0 :         assert( pointer != NULL );
   53568             : #if ROSE_ALLOC_MEMSET == 1
   53569             :         memset(pointer, 0x00, SgOmpBindClause::pool_size * sizeof(SgOmpBindClause));
   53570             : #elif ROSE_ALLOC_MEMSET == 2
   53571             :         memset(pointer, 0xCC, SgOmpBindClause::pool_size * sizeof(SgOmpBindClause));
   53572             : #endif
   53573           0 :         SgOmpBindClause::pools.push_back( (unsigned char*)(pointer) );
   53574           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpBindClause::pool_size * sizeof(SgOmpBindClause), V_SgOmpBindClause ) );
   53575             : 
   53576           0 :         if ( SgOmpBindClause::next_node != NULL ) {
   53577           0 :           if ( blockIndex > 0 ) {
   53578           0 :             SgOmpBindClause * blkptr = (SgOmpBindClause*)(SgOmpBindClause::pools[blockIndex-1]);
   53579           0 :             blkptr[ SgOmpBindClause::pool_size - 1 ].set_freepointer(pointer);
   53580             :           }
   53581             :         } else {
   53582           0 :           SgOmpBindClause::next_node = pointer;
   53583             :         }
   53584             : 
   53585           0 :         for (unsigned i = 0; i < SgOmpBindClause::pool_size-1; ++i)
   53586             :            {
   53587           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   53588             :            }
   53589           0 :         pointer[ SgOmpBindClause::pool_size -1 ].set_freepointer(NULL);
   53590             : 
   53591           0 :         blockIndex++;
   53592             :       }
   53593           2 :   }
   53594             : 
   53595             : //############################################################################
   53596             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   53597             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   53598             :  * not compressed. However, that stuff is not yet implemented! 
   53599             :  */
   53600             : unsigned long
   53601           0 : SgOmpBindClause::getNumberOfLastValidPointer()
   53602             :    {
   53603           0 :       SgOmpBindClause* testPointer = (SgOmpBindClause*)(SgOmpBindClause::pools.back());
   53604           0 :       unsigned long localIndex = SgOmpBindClause::pool_size - 1;
   53605           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   53606             :          {
   53607           0 :            localIndex--;
   53608             :          }
   53609           0 :       return (localIndex + SgOmpBindClause::pool_size * (SgOmpBindClause::pools.size()-1));
   53610             :    }
   53611             : 
   53612             : //############################################################################
   53613             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   53614             :  * memory pool and initializes the data member in class SgOmpBindClauseStroageClass
   53615             :  * from its counterpart of SgOmpBindClause. The return value is just for checking, 
   53616             :  * that the whole StorageClassArray is initialized!
   53617             :  */
   53618             : unsigned long
   53619           0 : SgOmpBindClause::initializeStorageClassArray( SgOmpBindClauseStorageClass *storageArray )
   53620             :    {
   53621           0 :      unsigned long storageCounter = 0;
   53622           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpBindClause::pools.begin();
   53623           0 :      SgOmpBindClause* pointer = NULL;
   53624           0 :      while ( block != SgOmpBindClause::pools.end() ) {
   53625           0 :           pointer = (SgOmpBindClause*) (*block);
   53626           0 :           for ( unsigned i = 0; i < SgOmpBindClause::pool_size; ++i ) {
   53627           0 :                if ( pointer->get_freepointer() != NULL ) {
   53628           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   53629           0 :                  storageArray++;
   53630           0 :                  storageCounter++;
   53631             :                }
   53632           0 :                pointer++;
   53633             :              }
   53634           0 :            block++;
   53635             :         }
   53636           0 :      return storageCounter;
   53637             :    }
   53638             : 
   53639             : /* #line 53640 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   53640             : 
   53641             : 
   53642             : 
   53643             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   53644             : 
   53645             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   53646             : 
   53647             : //############################################################################
   53648             : /* JH (02/02/2006) Constructor of the IR node SgOmpOrderClause that takes its 
   53649             :  * corresponding StorageClass as parameter
   53650             :  */
   53651           0 : SgOmpOrderClause :: SgOmpOrderClause ( const SgOmpOrderClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   53652             :    {
   53653             : 
   53654             : 
   53655             : /* #line 53656 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   53656             : 
   53657           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   53658           0 :      p_kind = storageSource.storageOf_kind ;
   53659             : 
   53660             : 
   53661             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   53662             : 
   53663             : 
   53664           0 :    }
   53665             : 
   53666             : //############################################################################
   53667             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   53668             :  * within the working AST. 
   53669             :  */
   53670           0 : SgOmpOrderClause * SgOmpOrderClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   53671           0 :      SgOmpOrderClause* returnPointer = NULL;
   53672           0 :      if ( globalIndex != 0 )
   53673             :         {
   53674             : 
   53675             : #if FILE_IO_EXTRA_CHECK
   53676           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpOrderClause ) ) <= globalIndex ) ;
   53677           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpOrderClause + 1 ) ) );
   53678             : #endif
   53679           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpOrderClause )  
   53680           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpOrderClause );
   53681           0 :           unsigned long positionInPool = localIndex % SgOmpOrderClause::pool_size;
   53682           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpOrderClause::pool_size;
   53683             : 
   53684             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   53685             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   53686             : 
   53687           0 :           returnPointer = &( ( (SgOmpOrderClause*)(SgOmpOrderClause::pools[memoryBlock]) ) [positionInPool]) ;
   53688             : 
   53689           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   53690             :         }
   53691           0 :      return returnPointer ;
   53692             :    }
   53693             : 
   53694             : //############################################################################
   53695             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   53696             :   for the AST with the index astIndex
   53697             : */
   53698           0 : SgOmpOrderClause * SgOmpOrderClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   53699           0 :      SgOmpOrderClause* returnPointer = NULL;
   53700           0 :      if ( globalIndex != 0 )
   53701             :         {
   53702             : 
   53703             : #if FILE_IO_EXTRA_CHECK
   53704           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpOrderClause ) ) <= globalIndex ) ;
   53705           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpOrderClause + 1 ) ) );
   53706             : #endif
   53707           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpOrderClause )
   53708           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpOrderClause );
   53709           0 :           unsigned long positionInPool = localIndex % SgOmpOrderClause::pool_size ;
   53710           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpOrderClause::pool_size ;
   53711             : 
   53712             : #if FILE_IO_EXTRA_CHECK
   53713             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   53714             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   53715             : #endif
   53716             : 
   53717           0 :           returnPointer = &( ( (SgOmpOrderClause*)(SgOmpOrderClause::pools[memoryBlock]) ) [positionInPool]) ;
   53718             : 
   53719             : #if FILE_IO_EXTRA_CHECK
   53720           0 :           assert ( returnPointer != NULL ) ;
   53721             : #endif
   53722             :         }
   53723           0 :      return returnPointer ;
   53724             :    }
   53725             : 
   53726             : //############################################################################
   53727             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   53728             :  * pool size! We set for every valid object in the memory pool the freepointer
   53729             :  * to the global index and increase the global index afterwards. For all the 
   53730             :  * invalid objects (means address ranges within the memory pool that were not
   53731             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   53732             :  * distinguish valid from invalid objects! 
   53733             :  */
   53734             : unsigned long
   53735           5 : SgOmpOrderClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   53736             :    {
   53737           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   53738           5 :      SgOmpOrderClause* pointer = NULL;
   53739           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   53740           5 :      std::vector < unsigned char* > :: const_iterator block;
   53741           5 :      for ( block = SgOmpOrderClause::pools.begin(); block != SgOmpOrderClause::pools.end() ; ++block )
   53742             :         {
   53743           0 :           pointer = (SgOmpOrderClause*)(*block);
   53744           0 :           for (unsigned i = 0; i < SgOmpOrderClause::pool_size; ++i )
   53745             :              {
   53746             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   53747             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   53748             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   53749             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   53750             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   53751             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   53752             :             // properly; so this will have to be checked next.
   53753             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   53754             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   53755           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   53756             :                   {
   53757           0 :                     pointer[i].set_freepointer((SgOmpOrderClause*)(globalIndex));
   53758           0 :                     globalIndex++;
   53759             :                   }
   53760             :                else
   53761             :                   {
   53762           0 :                     pointer[i].set_freepointer(NULL);
   53763             :                   }
   53764             :               }
   53765             :         }
   53766           5 :      return globalIndex;
   53767             :    }
   53768             : 
   53769             : //############################################################################
   53770             : // JH (01/14/2006)
   53771             : void
   53772           5 : SgOmpOrderClause::resetValidFreepointers( )
   53773             :    {
   53774           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   53775           5 :      SgOmpOrderClause* pointer = NULL;
   53776           5 :      std::vector < unsigned char* > :: const_iterator block;
   53777           5 :      SgOmpOrderClause* pointerOfLinkedList = NULL;
   53778           5 :      for ( block = SgOmpOrderClause::pools.begin(); block != SgOmpOrderClause::pools.end() ; ++block )
   53779             :         {
   53780           0 :           pointer = (SgOmpOrderClause*)(*block);
   53781           0 :           for (unsigned i = 0; i < SgOmpOrderClause::pool_size; ++i )
   53782             :              {
   53783             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   53784             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   53785             :             // memory blocks!.
   53786           0 :                if ( pointer[i].get_freepointer() != NULL )
   53787             :                   {
   53788           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   53789             :                   }
   53790             :                else
   53791             :                   {
   53792           0 :                     if ( pointerOfLinkedList == NULL )
   53793             :                        {
   53794           0 :                          SgOmpOrderClause::next_node = &(pointer[i]);
   53795             :                        }
   53796             :                     else
   53797             :                        {
   53798             :                       // printf ("In SgOmpOrderClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   53799           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   53800             :                        }
   53801             :                     pointerOfLinkedList = &(pointer[i]);
   53802             :                   }
   53803             :               }
   53804             :         }
   53805             : 
   53806           5 :      if ( pointerOfLinkedList != NULL )
   53807             :         {
   53808             :        // printf ("In SgOmpOrderClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   53809           0 :           pointerOfLinkedList->set_freepointer(NULL);
   53810             :        // DQ (6/6/2010): Temporary debugging...
   53811             :        //   ROSE_ASSERT(false);
   53812             :         }
   53813             : 
   53814           5 :      return ;
   53815             :    }
   53816             : 
   53817             : //############################################################################
   53818             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   53819             :  * within the memory pool and resets the freepointers, in order to achieve a 
   53820             :  * linked list, that has no jumps and starts at the beginning! This function 
   53821             :  * does not extend the memory pool, since we do not delete any memory blocks,
   53822             :  * but delete the valid objects.  
   53823             :  */
   53824             : void
   53825           0 : SgOmpOrderClause::clearMemoryPool( )
   53826             :    {
   53827             :   // printf ("Inside of SgOmpOrderClause::clearMemoryPool() \n");
   53828             : 
   53829           0 :      SgOmpOrderClause* pointer = NULL, *tempPointer = NULL;
   53830           0 :      std::vector < unsigned char* > :: const_iterator block;
   53831           0 :      if ( SgOmpOrderClause::pools.empty() == false )
   53832             :         {
   53833           0 :           block = SgOmpOrderClause::pools.begin() ;
   53834           0 :           SgOmpOrderClause::next_node = (SgOmpOrderClause*) (*block);
   53835             : 
   53836           0 :           while ( block != SgOmpOrderClause::pools.end() )
   53837             :              {
   53838           0 :                pointer = (SgOmpOrderClause*) (*block);
   53839           0 :                if ( tempPointer != NULL )
   53840             :                   {
   53841           0 :                     tempPointer->set_freepointer(pointer);
   53842             :                   }
   53843           0 :                for (unsigned i = 0; i < SgOmpOrderClause::pool_size - 1; ++i)
   53844             :                   {
   53845           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   53846             :                   }
   53847           0 :                 pointer[SgOmpOrderClause::pool_size-1].set_freepointer(NULL);
   53848           0 :                 tempPointer = &(pointer[SgOmpOrderClause::pool_size-1]);
   53849           0 :                 ++block;
   53850             :              }
   53851             :         }
   53852           0 :    }
   53853             : 
   53854           5 : void SgOmpOrderClause::deleteMemoryPool() {
   53855           5 :   for (auto p: SgOmpOrderClause::pools) {
   53856           0 :     ROSE_FREE(p);
   53857             :   }
   53858           5 :   SgOmpOrderClause::next_node = nullptr;
   53859           5 :   SgOmpOrderClause::pools.clear();
   53860           5 : }
   53861             : 
   53862             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   53863             : //                 reading multiple binary files to for a single AST.
   53864             : /////////// new version ////////////////////////////////
   53865             : //############################################################################
   53866             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   53867             : void
   53868           2 : SgOmpOrderClause::extendMemoryPoolForFileIO( )
   53869             :   {
   53870           2 :     size_t blockIndex = SgOmpOrderClause::pools.size();
   53871           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderClause);
   53872             : 
   53873           2 :     while ( (blockIndex * SgOmpOrderClause::pool_size) < newPoolSize)
   53874             :       {
   53875             : #if ROSE_ALLOC_TRACE
   53876             :         if (blockIndex > 0) {
   53877             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderClause) = %" PRIuPTR " SgOmpOrderClause::pool_size = %d \n",
   53878             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderClause),SgOmpOrderClause::pool_size);
   53879             :         }
   53880             : #endif
   53881             : 
   53882           0 :         SgOmpOrderClause * pointer = (SgOmpOrderClause*) ROSE_MALLOC ( SgOmpOrderClause::pool_size * sizeof(SgOmpOrderClause) );
   53883           0 :         assert( pointer != NULL );
   53884             : #if ROSE_ALLOC_MEMSET == 1
   53885             :         memset(pointer, 0x00, SgOmpOrderClause::pool_size * sizeof(SgOmpOrderClause));
   53886             : #elif ROSE_ALLOC_MEMSET == 2
   53887             :         memset(pointer, 0xCC, SgOmpOrderClause::pool_size * sizeof(SgOmpOrderClause));
   53888             : #endif
   53889           0 :         SgOmpOrderClause::pools.push_back( (unsigned char*)(pointer) );
   53890           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpOrderClause::pool_size * sizeof(SgOmpOrderClause), V_SgOmpOrderClause ) );
   53891             : 
   53892           0 :         if ( SgOmpOrderClause::next_node != NULL ) {
   53893           0 :           if ( blockIndex > 0 ) {
   53894           0 :             SgOmpOrderClause * blkptr = (SgOmpOrderClause*)(SgOmpOrderClause::pools[blockIndex-1]);
   53895           0 :             blkptr[ SgOmpOrderClause::pool_size - 1 ].set_freepointer(pointer);
   53896             :           }
   53897             :         } else {
   53898           0 :           SgOmpOrderClause::next_node = pointer;
   53899             :         }
   53900             : 
   53901           0 :         for (unsigned i = 0; i < SgOmpOrderClause::pool_size-1; ++i)
   53902             :            {
   53903           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   53904             :            }
   53905           0 :         pointer[ SgOmpOrderClause::pool_size -1 ].set_freepointer(NULL);
   53906             : 
   53907           0 :         blockIndex++;
   53908             :       }
   53909           2 :   }
   53910             : 
   53911             : //############################################################################
   53912             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   53913             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   53914             :  * not compressed. However, that stuff is not yet implemented! 
   53915             :  */
   53916             : unsigned long
   53917           0 : SgOmpOrderClause::getNumberOfLastValidPointer()
   53918             :    {
   53919           0 :       SgOmpOrderClause* testPointer = (SgOmpOrderClause*)(SgOmpOrderClause::pools.back());
   53920           0 :       unsigned long localIndex = SgOmpOrderClause::pool_size - 1;
   53921           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   53922             :          {
   53923           0 :            localIndex--;
   53924             :          }
   53925           0 :       return (localIndex + SgOmpOrderClause::pool_size * (SgOmpOrderClause::pools.size()-1));
   53926             :    }
   53927             : 
   53928             : //############################################################################
   53929             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   53930             :  * memory pool and initializes the data member in class SgOmpOrderClauseStroageClass
   53931             :  * from its counterpart of SgOmpOrderClause. The return value is just for checking, 
   53932             :  * that the whole StorageClassArray is initialized!
   53933             :  */
   53934             : unsigned long
   53935           0 : SgOmpOrderClause::initializeStorageClassArray( SgOmpOrderClauseStorageClass *storageArray )
   53936             :    {
   53937           0 :      unsigned long storageCounter = 0;
   53938           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpOrderClause::pools.begin();
   53939           0 :      SgOmpOrderClause* pointer = NULL;
   53940           0 :      while ( block != SgOmpOrderClause::pools.end() ) {
   53941           0 :           pointer = (SgOmpOrderClause*) (*block);
   53942           0 :           for ( unsigned i = 0; i < SgOmpOrderClause::pool_size; ++i ) {
   53943           0 :                if ( pointer->get_freepointer() != NULL ) {
   53944           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   53945           0 :                  storageArray++;
   53946           0 :                  storageCounter++;
   53947             :                }
   53948           0 :                pointer++;
   53949             :              }
   53950           0 :            block++;
   53951             :         }
   53952           0 :      return storageCounter;
   53953             :    }
   53954             : 
   53955             : /* #line 53956 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   53956             : 
   53957             : 
   53958             : 
   53959             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   53960             : 
   53961             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   53962             : 
   53963             : //############################################################################
   53964             : /* JH (02/02/2006) Constructor of the IR node SgOmpDistScheduleClause that takes its 
   53965             :  * corresponding StorageClass as parameter
   53966             :  */
   53967           0 : SgOmpDistScheduleClause :: SgOmpDistScheduleClause ( const SgOmpDistScheduleClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   53968             :    {
   53969             : 
   53970             : 
   53971             : /* #line 53972 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   53972             : 
   53973           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   53974           0 :      p_kind = storageSource.storageOf_kind ;
   53975           0 :      p_chunk_size =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_chunk_size) );
   53976             : 
   53977             : 
   53978             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   53979             : 
   53980             : 
   53981           0 :    }
   53982             : 
   53983             : //############################################################################
   53984             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   53985             :  * within the working AST. 
   53986             :  */
   53987           0 : SgOmpDistScheduleClause * SgOmpDistScheduleClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   53988           0 :      SgOmpDistScheduleClause* returnPointer = NULL;
   53989           0 :      if ( globalIndex != 0 )
   53990             :         {
   53991             : 
   53992             : #if FILE_IO_EXTRA_CHECK
   53993           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDistScheduleClause ) ) <= globalIndex ) ;
   53994           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistScheduleClause + 1 ) ) );
   53995             : #endif
   53996           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistScheduleClause )  
   53997           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDistScheduleClause );
   53998           0 :           unsigned long positionInPool = localIndex % SgOmpDistScheduleClause::pool_size;
   53999           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistScheduleClause::pool_size;
   54000             : 
   54001             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   54002             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   54003             : 
   54004           0 :           returnPointer = &( ( (SgOmpDistScheduleClause*)(SgOmpDistScheduleClause::pools[memoryBlock]) ) [positionInPool]) ;
   54005             : 
   54006           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   54007             :         }
   54008           0 :      return returnPointer ;
   54009             :    }
   54010             : 
   54011             : //############################################################################
   54012             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   54013             :   for the AST with the index astIndex
   54014             : */
   54015           0 : SgOmpDistScheduleClause * SgOmpDistScheduleClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   54016           0 :      SgOmpDistScheduleClause* returnPointer = NULL;
   54017           0 :      if ( globalIndex != 0 )
   54018             :         {
   54019             : 
   54020             : #if FILE_IO_EXTRA_CHECK
   54021           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDistScheduleClause ) ) <= globalIndex ) ;
   54022           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistScheduleClause + 1 ) ) );
   54023             : #endif
   54024           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistScheduleClause )
   54025           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDistScheduleClause );
   54026           0 :           unsigned long positionInPool = localIndex % SgOmpDistScheduleClause::pool_size ;
   54027           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistScheduleClause::pool_size ;
   54028             : 
   54029             : #if FILE_IO_EXTRA_CHECK
   54030             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   54031             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   54032             : #endif
   54033             : 
   54034           0 :           returnPointer = &( ( (SgOmpDistScheduleClause*)(SgOmpDistScheduleClause::pools[memoryBlock]) ) [positionInPool]) ;
   54035             : 
   54036             : #if FILE_IO_EXTRA_CHECK
   54037           0 :           assert ( returnPointer != NULL ) ;
   54038             : #endif
   54039             :         }
   54040           0 :      return returnPointer ;
   54041             :    }
   54042             : 
   54043             : //############################################################################
   54044             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   54045             :  * pool size! We set for every valid object in the memory pool the freepointer
   54046             :  * to the global index and increase the global index afterwards. For all the 
   54047             :  * invalid objects (means address ranges within the memory pool that were not
   54048             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   54049             :  * distinguish valid from invalid objects! 
   54050             :  */
   54051             : unsigned long
   54052           5 : SgOmpDistScheduleClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   54053             :    {
   54054           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   54055           5 :      SgOmpDistScheduleClause* pointer = NULL;
   54056           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   54057           5 :      std::vector < unsigned char* > :: const_iterator block;
   54058           5 :      for ( block = SgOmpDistScheduleClause::pools.begin(); block != SgOmpDistScheduleClause::pools.end() ; ++block )
   54059             :         {
   54060           0 :           pointer = (SgOmpDistScheduleClause*)(*block);
   54061           0 :           for (unsigned i = 0; i < SgOmpDistScheduleClause::pool_size; ++i )
   54062             :              {
   54063             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   54064             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   54065             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   54066             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   54067             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   54068             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   54069             :             // properly; so this will have to be checked next.
   54070             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   54071             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   54072           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   54073             :                   {
   54074           0 :                     pointer[i].set_freepointer((SgOmpDistScheduleClause*)(globalIndex));
   54075           0 :                     globalIndex++;
   54076             :                   }
   54077             :                else
   54078             :                   {
   54079           0 :                     pointer[i].set_freepointer(NULL);
   54080             :                   }
   54081             :               }
   54082             :         }
   54083           5 :      return globalIndex;
   54084             :    }
   54085             : 
   54086             : //############################################################################
   54087             : // JH (01/14/2006)
   54088             : void
   54089           5 : SgOmpDistScheduleClause::resetValidFreepointers( )
   54090             :    {
   54091           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   54092           5 :      SgOmpDistScheduleClause* pointer = NULL;
   54093           5 :      std::vector < unsigned char* > :: const_iterator block;
   54094           5 :      SgOmpDistScheduleClause* pointerOfLinkedList = NULL;
   54095           5 :      for ( block = SgOmpDistScheduleClause::pools.begin(); block != SgOmpDistScheduleClause::pools.end() ; ++block )
   54096             :         {
   54097           0 :           pointer = (SgOmpDistScheduleClause*)(*block);
   54098           0 :           for (unsigned i = 0; i < SgOmpDistScheduleClause::pool_size; ++i )
   54099             :              {
   54100             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   54101             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   54102             :             // memory blocks!.
   54103           0 :                if ( pointer[i].get_freepointer() != NULL )
   54104             :                   {
   54105           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   54106             :                   }
   54107             :                else
   54108             :                   {
   54109           0 :                     if ( pointerOfLinkedList == NULL )
   54110             :                        {
   54111           0 :                          SgOmpDistScheduleClause::next_node = &(pointer[i]);
   54112             :                        }
   54113             :                     else
   54114             :                        {
   54115             :                       // printf ("In SgOmpDistScheduleClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   54116           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   54117             :                        }
   54118             :                     pointerOfLinkedList = &(pointer[i]);
   54119             :                   }
   54120             :               }
   54121             :         }
   54122             : 
   54123           5 :      if ( pointerOfLinkedList != NULL )
   54124             :         {
   54125             :        // printf ("In SgOmpDistScheduleClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   54126           0 :           pointerOfLinkedList->set_freepointer(NULL);
   54127             :        // DQ (6/6/2010): Temporary debugging...
   54128             :        //   ROSE_ASSERT(false);
   54129             :         }
   54130             : 
   54131           5 :      return ;
   54132             :    }
   54133             : 
   54134             : //############################################################################
   54135             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   54136             :  * within the memory pool and resets the freepointers, in order to achieve a 
   54137             :  * linked list, that has no jumps and starts at the beginning! This function 
   54138             :  * does not extend the memory pool, since we do not delete any memory blocks,
   54139             :  * but delete the valid objects.  
   54140             :  */
   54141             : void
   54142           0 : SgOmpDistScheduleClause::clearMemoryPool( )
   54143             :    {
   54144             :   // printf ("Inside of SgOmpDistScheduleClause::clearMemoryPool() \n");
   54145             : 
   54146           0 :      SgOmpDistScheduleClause* pointer = NULL, *tempPointer = NULL;
   54147           0 :      std::vector < unsigned char* > :: const_iterator block;
   54148           0 :      if ( SgOmpDistScheduleClause::pools.empty() == false )
   54149             :         {
   54150           0 :           block = SgOmpDistScheduleClause::pools.begin() ;
   54151           0 :           SgOmpDistScheduleClause::next_node = (SgOmpDistScheduleClause*) (*block);
   54152             : 
   54153           0 :           while ( block != SgOmpDistScheduleClause::pools.end() )
   54154             :              {
   54155           0 :                pointer = (SgOmpDistScheduleClause*) (*block);
   54156           0 :                if ( tempPointer != NULL )
   54157             :                   {
   54158           0 :                     tempPointer->set_freepointer(pointer);
   54159             :                   }
   54160           0 :                for (unsigned i = 0; i < SgOmpDistScheduleClause::pool_size - 1; ++i)
   54161             :                   {
   54162           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   54163             :                   }
   54164           0 :                 pointer[SgOmpDistScheduleClause::pool_size-1].set_freepointer(NULL);
   54165           0 :                 tempPointer = &(pointer[SgOmpDistScheduleClause::pool_size-1]);
   54166           0 :                 ++block;
   54167             :              }
   54168             :         }
   54169           0 :    }
   54170             : 
   54171           5 : void SgOmpDistScheduleClause::deleteMemoryPool() {
   54172           5 :   for (auto p: SgOmpDistScheduleClause::pools) {
   54173           0 :     ROSE_FREE(p);
   54174             :   }
   54175           5 :   SgOmpDistScheduleClause::next_node = nullptr;
   54176           5 :   SgOmpDistScheduleClause::pools.clear();
   54177           5 : }
   54178             : 
   54179             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   54180             : //                 reading multiple binary files to for a single AST.
   54181             : /////////// new version ////////////////////////////////
   54182             : //############################################################################
   54183             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   54184             : void
   54185           2 : SgOmpDistScheduleClause::extendMemoryPoolForFileIO( )
   54186             :   {
   54187           2 :     size_t blockIndex = SgOmpDistScheduleClause::pools.size();
   54188           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistScheduleClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistScheduleClause);
   54189             : 
   54190           2 :     while ( (blockIndex * SgOmpDistScheduleClause::pool_size) < newPoolSize)
   54191             :       {
   54192             : #if ROSE_ALLOC_TRACE
   54193             :         if (blockIndex > 0) {
   54194             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistScheduleClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistScheduleClause) = %" PRIuPTR " SgOmpDistScheduleClause::pool_size = %d \n",
   54195             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistScheduleClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistScheduleClause),SgOmpDistScheduleClause::pool_size);
   54196             :         }
   54197             : #endif
   54198             : 
   54199           0 :         SgOmpDistScheduleClause * pointer = (SgOmpDistScheduleClause*) ROSE_MALLOC ( SgOmpDistScheduleClause::pool_size * sizeof(SgOmpDistScheduleClause) );
   54200           0 :         assert( pointer != NULL );
   54201             : #if ROSE_ALLOC_MEMSET == 1
   54202             :         memset(pointer, 0x00, SgOmpDistScheduleClause::pool_size * sizeof(SgOmpDistScheduleClause));
   54203             : #elif ROSE_ALLOC_MEMSET == 2
   54204             :         memset(pointer, 0xCC, SgOmpDistScheduleClause::pool_size * sizeof(SgOmpDistScheduleClause));
   54205             : #endif
   54206           0 :         SgOmpDistScheduleClause::pools.push_back( (unsigned char*)(pointer) );
   54207           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDistScheduleClause::pool_size * sizeof(SgOmpDistScheduleClause), V_SgOmpDistScheduleClause ) );
   54208             : 
   54209           0 :         if ( SgOmpDistScheduleClause::next_node != NULL ) {
   54210           0 :           if ( blockIndex > 0 ) {
   54211           0 :             SgOmpDistScheduleClause * blkptr = (SgOmpDistScheduleClause*)(SgOmpDistScheduleClause::pools[blockIndex-1]);
   54212           0 :             blkptr[ SgOmpDistScheduleClause::pool_size - 1 ].set_freepointer(pointer);
   54213             :           }
   54214             :         } else {
   54215           0 :           SgOmpDistScheduleClause::next_node = pointer;
   54216             :         }
   54217             : 
   54218           0 :         for (unsigned i = 0; i < SgOmpDistScheduleClause::pool_size-1; ++i)
   54219             :            {
   54220           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   54221             :            }
   54222           0 :         pointer[ SgOmpDistScheduleClause::pool_size -1 ].set_freepointer(NULL);
   54223             : 
   54224           0 :         blockIndex++;
   54225             :       }
   54226           2 :   }
   54227             : 
   54228             : //############################################################################
   54229             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   54230             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   54231             :  * not compressed. However, that stuff is not yet implemented! 
   54232             :  */
   54233             : unsigned long
   54234           0 : SgOmpDistScheduleClause::getNumberOfLastValidPointer()
   54235             :    {
   54236           0 :       SgOmpDistScheduleClause* testPointer = (SgOmpDistScheduleClause*)(SgOmpDistScheduleClause::pools.back());
   54237           0 :       unsigned long localIndex = SgOmpDistScheduleClause::pool_size - 1;
   54238           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   54239             :          {
   54240           0 :            localIndex--;
   54241             :          }
   54242           0 :       return (localIndex + SgOmpDistScheduleClause::pool_size * (SgOmpDistScheduleClause::pools.size()-1));
   54243             :    }
   54244             : 
   54245             : //############################################################################
   54246             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   54247             :  * memory pool and initializes the data member in class SgOmpDistScheduleClauseStroageClass
   54248             :  * from its counterpart of SgOmpDistScheduleClause. The return value is just for checking, 
   54249             :  * that the whole StorageClassArray is initialized!
   54250             :  */
   54251             : unsigned long
   54252           0 : SgOmpDistScheduleClause::initializeStorageClassArray( SgOmpDistScheduleClauseStorageClass *storageArray )
   54253             :    {
   54254           0 :      unsigned long storageCounter = 0;
   54255           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDistScheduleClause::pools.begin();
   54256           0 :      SgOmpDistScheduleClause* pointer = NULL;
   54257           0 :      while ( block != SgOmpDistScheduleClause::pools.end() ) {
   54258           0 :           pointer = (SgOmpDistScheduleClause*) (*block);
   54259           0 :           for ( unsigned i = 0; i < SgOmpDistScheduleClause::pool_size; ++i ) {
   54260           0 :                if ( pointer->get_freepointer() != NULL ) {
   54261           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   54262           0 :                  storageArray++;
   54263           0 :                  storageCounter++;
   54264             :                }
   54265           0 :                pointer++;
   54266             :              }
   54267           0 :            block++;
   54268             :         }
   54269           0 :      return storageCounter;
   54270             :    }
   54271             : 
   54272             : /* #line 54273 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   54273             : 
   54274             : 
   54275             : 
   54276             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   54277             : 
   54278             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   54279             : 
   54280             : //############################################################################
   54281             : /* JH (02/02/2006) Constructor of the IR node SgOmpExpressionClause that takes its 
   54282             :  * corresponding StorageClass as parameter
   54283             :  */
   54284           0 : SgOmpExpressionClause :: SgOmpExpressionClause ( const SgOmpExpressionClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   54285             :    {
   54286             : 
   54287             : 
   54288             : /* #line 54289 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   54289             : 
   54290           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   54291           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
   54292             : 
   54293             : 
   54294             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   54295             : 
   54296             : 
   54297           0 :    }
   54298             : 
   54299             : //############################################################################
   54300             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   54301             :  * within the working AST. 
   54302             :  */
   54303           0 : SgOmpExpressionClause * SgOmpExpressionClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   54304           0 :      SgOmpExpressionClause* returnPointer = NULL;
   54305           0 :      if ( globalIndex != 0 )
   54306             :         {
   54307             : 
   54308             : #if FILE_IO_EXTRA_CHECK
   54309           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpExpressionClause ) ) <= globalIndex ) ;
   54310           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpExpressionClause + 1 ) ) );
   54311             : #endif
   54312           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpExpressionClause )  
   54313           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpExpressionClause );
   54314           0 :           unsigned long positionInPool = localIndex % SgOmpExpressionClause::pool_size;
   54315           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpExpressionClause::pool_size;
   54316             : 
   54317             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   54318             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   54319             : 
   54320           0 :           returnPointer = &( ( (SgOmpExpressionClause*)(SgOmpExpressionClause::pools[memoryBlock]) ) [positionInPool]) ;
   54321             : 
   54322           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   54323             :         }
   54324           0 :      return returnPointer ;
   54325             :    }
   54326             : 
   54327             : //############################################################################
   54328             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   54329             :   for the AST with the index astIndex
   54330             : */
   54331           0 : SgOmpExpressionClause * SgOmpExpressionClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   54332           0 :      SgOmpExpressionClause* returnPointer = NULL;
   54333           0 :      if ( globalIndex != 0 )
   54334             :         {
   54335             : 
   54336             : #if FILE_IO_EXTRA_CHECK
   54337           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpExpressionClause ) ) <= globalIndex ) ;
   54338           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpExpressionClause + 1 ) ) );
   54339             : #endif
   54340           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpExpressionClause )
   54341           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpExpressionClause );
   54342           0 :           unsigned long positionInPool = localIndex % SgOmpExpressionClause::pool_size ;
   54343           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpExpressionClause::pool_size ;
   54344             : 
   54345             : #if FILE_IO_EXTRA_CHECK
   54346             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   54347             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   54348             : #endif
   54349             : 
   54350           0 :           returnPointer = &( ( (SgOmpExpressionClause*)(SgOmpExpressionClause::pools[memoryBlock]) ) [positionInPool]) ;
   54351             : 
   54352             : #if FILE_IO_EXTRA_CHECK
   54353           0 :           assert ( returnPointer != NULL ) ;
   54354             : #endif
   54355             :         }
   54356           0 :      return returnPointer ;
   54357             :    }
   54358             : 
   54359             : //############################################################################
   54360             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   54361             :  * pool size! We set for every valid object in the memory pool the freepointer
   54362             :  * to the global index and increase the global index afterwards. For all the 
   54363             :  * invalid objects (means address ranges within the memory pool that were not
   54364             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   54365             :  * distinguish valid from invalid objects! 
   54366             :  */
   54367             : unsigned long
   54368           5 : SgOmpExpressionClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   54369             :    {
   54370           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   54371           5 :      SgOmpExpressionClause* pointer = NULL;
   54372           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   54373           5 :      std::vector < unsigned char* > :: const_iterator block;
   54374           5 :      for ( block = SgOmpExpressionClause::pools.begin(); block != SgOmpExpressionClause::pools.end() ; ++block )
   54375             :         {
   54376           0 :           pointer = (SgOmpExpressionClause*)(*block);
   54377           0 :           for (unsigned i = 0; i < SgOmpExpressionClause::pool_size; ++i )
   54378             :              {
   54379             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   54380             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   54381             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   54382             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   54383             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   54384             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   54385             :             // properly; so this will have to be checked next.
   54386             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   54387             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   54388           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   54389             :                   {
   54390           0 :                     pointer[i].set_freepointer((SgOmpExpressionClause*)(globalIndex));
   54391           0 :                     globalIndex++;
   54392             :                   }
   54393             :                else
   54394             :                   {
   54395           0 :                     pointer[i].set_freepointer(NULL);
   54396             :                   }
   54397             :               }
   54398             :         }
   54399           5 :      return globalIndex;
   54400             :    }
   54401             : 
   54402             : //############################################################################
   54403             : // JH (01/14/2006)
   54404             : void
   54405           5 : SgOmpExpressionClause::resetValidFreepointers( )
   54406             :    {
   54407           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   54408           5 :      SgOmpExpressionClause* pointer = NULL;
   54409           5 :      std::vector < unsigned char* > :: const_iterator block;
   54410           5 :      SgOmpExpressionClause* pointerOfLinkedList = NULL;
   54411           5 :      for ( block = SgOmpExpressionClause::pools.begin(); block != SgOmpExpressionClause::pools.end() ; ++block )
   54412             :         {
   54413           0 :           pointer = (SgOmpExpressionClause*)(*block);
   54414           0 :           for (unsigned i = 0; i < SgOmpExpressionClause::pool_size; ++i )
   54415             :              {
   54416             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   54417             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   54418             :             // memory blocks!.
   54419           0 :                if ( pointer[i].get_freepointer() != NULL )
   54420             :                   {
   54421           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   54422             :                   }
   54423             :                else
   54424             :                   {
   54425           0 :                     if ( pointerOfLinkedList == NULL )
   54426             :                        {
   54427           0 :                          SgOmpExpressionClause::next_node = &(pointer[i]);
   54428             :                        }
   54429             :                     else
   54430             :                        {
   54431             :                       // printf ("In SgOmpExpressionClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   54432           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   54433             :                        }
   54434             :                     pointerOfLinkedList = &(pointer[i]);
   54435             :                   }
   54436             :               }
   54437             :         }
   54438             : 
   54439           5 :      if ( pointerOfLinkedList != NULL )
   54440             :         {
   54441             :        // printf ("In SgOmpExpressionClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   54442           0 :           pointerOfLinkedList->set_freepointer(NULL);
   54443             :        // DQ (6/6/2010): Temporary debugging...
   54444             :        //   ROSE_ASSERT(false);
   54445             :         }
   54446             : 
   54447           5 :      return ;
   54448             :    }
   54449             : 
   54450             : //############################################################################
   54451             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   54452             :  * within the memory pool and resets the freepointers, in order to achieve a 
   54453             :  * linked list, that has no jumps and starts at the beginning! This function 
   54454             :  * does not extend the memory pool, since we do not delete any memory blocks,
   54455             :  * but delete the valid objects.  
   54456             :  */
   54457             : void
   54458           0 : SgOmpExpressionClause::clearMemoryPool( )
   54459             :    {
   54460             :   // printf ("Inside of SgOmpExpressionClause::clearMemoryPool() \n");
   54461             : 
   54462           0 :      SgOmpExpressionClause* pointer = NULL, *tempPointer = NULL;
   54463           0 :      std::vector < unsigned char* > :: const_iterator block;
   54464           0 :      if ( SgOmpExpressionClause::pools.empty() == false )
   54465             :         {
   54466           0 :           block = SgOmpExpressionClause::pools.begin() ;
   54467           0 :           SgOmpExpressionClause::next_node = (SgOmpExpressionClause*) (*block);
   54468             : 
   54469           0 :           while ( block != SgOmpExpressionClause::pools.end() )
   54470             :              {
   54471           0 :                pointer = (SgOmpExpressionClause*) (*block);
   54472           0 :                if ( tempPointer != NULL )
   54473             :                   {
   54474           0 :                     tempPointer->set_freepointer(pointer);
   54475             :                   }
   54476           0 :                for (unsigned i = 0; i < SgOmpExpressionClause::pool_size - 1; ++i)
   54477             :                   {
   54478           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   54479             :                   }
   54480           0 :                 pointer[SgOmpExpressionClause::pool_size-1].set_freepointer(NULL);
   54481           0 :                 tempPointer = &(pointer[SgOmpExpressionClause::pool_size-1]);
   54482           0 :                 ++block;
   54483             :              }
   54484             :         }
   54485           0 :    }
   54486             : 
   54487           5 : void SgOmpExpressionClause::deleteMemoryPool() {
   54488           5 :   for (auto p: SgOmpExpressionClause::pools) {
   54489           0 :     ROSE_FREE(p);
   54490             :   }
   54491           5 :   SgOmpExpressionClause::next_node = nullptr;
   54492           5 :   SgOmpExpressionClause::pools.clear();
   54493           5 : }
   54494             : 
   54495             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   54496             : //                 reading multiple binary files to for a single AST.
   54497             : /////////// new version ////////////////////////////////
   54498             : //############################################################################
   54499             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   54500             : void
   54501           2 : SgOmpExpressionClause::extendMemoryPoolForFileIO( )
   54502             :   {
   54503           2 :     size_t blockIndex = SgOmpExpressionClause::pools.size();
   54504           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExpressionClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExpressionClause);
   54505             : 
   54506           2 :     while ( (blockIndex * SgOmpExpressionClause::pool_size) < newPoolSize)
   54507             :       {
   54508             : #if ROSE_ALLOC_TRACE
   54509             :         if (blockIndex > 0) {
   54510             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExpressionClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExpressionClause) = %" PRIuPTR " SgOmpExpressionClause::pool_size = %d \n",
   54511             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExpressionClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExpressionClause),SgOmpExpressionClause::pool_size);
   54512             :         }
   54513             : #endif
   54514             : 
   54515           0 :         SgOmpExpressionClause * pointer = (SgOmpExpressionClause*) ROSE_MALLOC ( SgOmpExpressionClause::pool_size * sizeof(SgOmpExpressionClause) );
   54516           0 :         assert( pointer != NULL );
   54517             : #if ROSE_ALLOC_MEMSET == 1
   54518             :         memset(pointer, 0x00, SgOmpExpressionClause::pool_size * sizeof(SgOmpExpressionClause));
   54519             : #elif ROSE_ALLOC_MEMSET == 2
   54520             :         memset(pointer, 0xCC, SgOmpExpressionClause::pool_size * sizeof(SgOmpExpressionClause));
   54521             : #endif
   54522           0 :         SgOmpExpressionClause::pools.push_back( (unsigned char*)(pointer) );
   54523           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpExpressionClause::pool_size * sizeof(SgOmpExpressionClause), V_SgOmpExpressionClause ) );
   54524             : 
   54525           0 :         if ( SgOmpExpressionClause::next_node != NULL ) {
   54526           0 :           if ( blockIndex > 0 ) {
   54527           0 :             SgOmpExpressionClause * blkptr = (SgOmpExpressionClause*)(SgOmpExpressionClause::pools[blockIndex-1]);
   54528           0 :             blkptr[ SgOmpExpressionClause::pool_size - 1 ].set_freepointer(pointer);
   54529             :           }
   54530             :         } else {
   54531           0 :           SgOmpExpressionClause::next_node = pointer;
   54532             :         }
   54533             : 
   54534           0 :         for (unsigned i = 0; i < SgOmpExpressionClause::pool_size-1; ++i)
   54535             :            {
   54536           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   54537             :            }
   54538           0 :         pointer[ SgOmpExpressionClause::pool_size -1 ].set_freepointer(NULL);
   54539             : 
   54540           0 :         blockIndex++;
   54541             :       }
   54542           2 :   }
   54543             : 
   54544             : //############################################################################
   54545             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   54546             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   54547             :  * not compressed. However, that stuff is not yet implemented! 
   54548             :  */
   54549             : unsigned long
   54550           0 : SgOmpExpressionClause::getNumberOfLastValidPointer()
   54551             :    {
   54552           0 :       SgOmpExpressionClause* testPointer = (SgOmpExpressionClause*)(SgOmpExpressionClause::pools.back());
   54553           0 :       unsigned long localIndex = SgOmpExpressionClause::pool_size - 1;
   54554           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   54555             :          {
   54556           0 :            localIndex--;
   54557             :          }
   54558           0 :       return (localIndex + SgOmpExpressionClause::pool_size * (SgOmpExpressionClause::pools.size()-1));
   54559             :    }
   54560             : 
   54561             : //############################################################################
   54562             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   54563             :  * memory pool and initializes the data member in class SgOmpExpressionClauseStroageClass
   54564             :  * from its counterpart of SgOmpExpressionClause. The return value is just for checking, 
   54565             :  * that the whole StorageClassArray is initialized!
   54566             :  */
   54567             : unsigned long
   54568           0 : SgOmpExpressionClause::initializeStorageClassArray( SgOmpExpressionClauseStorageClass *storageArray )
   54569             :    {
   54570           0 :      unsigned long storageCounter = 0;
   54571           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpExpressionClause::pools.begin();
   54572           0 :      SgOmpExpressionClause* pointer = NULL;
   54573           0 :      while ( block != SgOmpExpressionClause::pools.end() ) {
   54574           0 :           pointer = (SgOmpExpressionClause*) (*block);
   54575           0 :           for ( unsigned i = 0; i < SgOmpExpressionClause::pool_size; ++i ) {
   54576           0 :                if ( pointer->get_freepointer() != NULL ) {
   54577           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   54578           0 :                  storageArray++;
   54579           0 :                  storageCounter++;
   54580             :                }
   54581           0 :                pointer++;
   54582             :              }
   54583           0 :            block++;
   54584             :         }
   54585           0 :      return storageCounter;
   54586             :    }
   54587             : 
   54588             : /* #line 54589 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   54589             : 
   54590             : 
   54591             : 
   54592             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   54593             : 
   54594             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   54595             : 
   54596             : //############################################################################
   54597             : /* JH (02/02/2006) Constructor of the IR node SgOmpOrderedClause that takes its 
   54598             :  * corresponding StorageClass as parameter
   54599             :  */
   54600           0 : SgOmpOrderedClause :: SgOmpOrderedClause ( const SgOmpOrderedClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   54601             :    {
   54602             : 
   54603             : 
   54604             : /* #line 54605 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   54605             : 
   54606           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   54607             : 
   54608             : 
   54609             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   54610             : 
   54611             : 
   54612           0 :    }
   54613             : 
   54614             : //############################################################################
   54615             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   54616             :  * within the working AST. 
   54617             :  */
   54618           0 : SgOmpOrderedClause * SgOmpOrderedClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   54619           0 :      SgOmpOrderedClause* returnPointer = NULL;
   54620           0 :      if ( globalIndex != 0 )
   54621             :         {
   54622             : 
   54623             : #if FILE_IO_EXTRA_CHECK
   54624           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpOrderedClause ) ) <= globalIndex ) ;
   54625           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpOrderedClause + 1 ) ) );
   54626             : #endif
   54627           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpOrderedClause )  
   54628           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpOrderedClause );
   54629           0 :           unsigned long positionInPool = localIndex % SgOmpOrderedClause::pool_size;
   54630           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpOrderedClause::pool_size;
   54631             : 
   54632             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   54633             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   54634             : 
   54635           0 :           returnPointer = &( ( (SgOmpOrderedClause*)(SgOmpOrderedClause::pools[memoryBlock]) ) [positionInPool]) ;
   54636             : 
   54637           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   54638             :         }
   54639           0 :      return returnPointer ;
   54640             :    }
   54641             : 
   54642             : //############################################################################
   54643             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   54644             :   for the AST with the index astIndex
   54645             : */
   54646           0 : SgOmpOrderedClause * SgOmpOrderedClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   54647           0 :      SgOmpOrderedClause* returnPointer = NULL;
   54648           0 :      if ( globalIndex != 0 )
   54649             :         {
   54650             : 
   54651             : #if FILE_IO_EXTRA_CHECK
   54652           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpOrderedClause ) ) <= globalIndex ) ;
   54653           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpOrderedClause + 1 ) ) );
   54654             : #endif
   54655           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpOrderedClause )
   54656           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpOrderedClause );
   54657           0 :           unsigned long positionInPool = localIndex % SgOmpOrderedClause::pool_size ;
   54658           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpOrderedClause::pool_size ;
   54659             : 
   54660             : #if FILE_IO_EXTRA_CHECK
   54661             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   54662             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   54663             : #endif
   54664             : 
   54665           0 :           returnPointer = &( ( (SgOmpOrderedClause*)(SgOmpOrderedClause::pools[memoryBlock]) ) [positionInPool]) ;
   54666             : 
   54667             : #if FILE_IO_EXTRA_CHECK
   54668           0 :           assert ( returnPointer != NULL ) ;
   54669             : #endif
   54670             :         }
   54671           0 :      return returnPointer ;
   54672             :    }
   54673             : 
   54674             : //############################################################################
   54675             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   54676             :  * pool size! We set for every valid object in the memory pool the freepointer
   54677             :  * to the global index and increase the global index afterwards. For all the 
   54678             :  * invalid objects (means address ranges within the memory pool that were not
   54679             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   54680             :  * distinguish valid from invalid objects! 
   54681             :  */
   54682             : unsigned long
   54683           5 : SgOmpOrderedClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   54684             :    {
   54685           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   54686           5 :      SgOmpOrderedClause* pointer = NULL;
   54687           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   54688           5 :      std::vector < unsigned char* > :: const_iterator block;
   54689           5 :      for ( block = SgOmpOrderedClause::pools.begin(); block != SgOmpOrderedClause::pools.end() ; ++block )
   54690             :         {
   54691           0 :           pointer = (SgOmpOrderedClause*)(*block);
   54692           0 :           for (unsigned i = 0; i < SgOmpOrderedClause::pool_size; ++i )
   54693             :              {
   54694             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   54695             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   54696             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   54697             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   54698             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   54699             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   54700             :             // properly; so this will have to be checked next.
   54701             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   54702             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   54703           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   54704             :                   {
   54705           0 :                     pointer[i].set_freepointer((SgOmpOrderedClause*)(globalIndex));
   54706           0 :                     globalIndex++;
   54707             :                   }
   54708             :                else
   54709             :                   {
   54710           0 :                     pointer[i].set_freepointer(NULL);
   54711             :                   }
   54712             :               }
   54713             :         }
   54714           5 :      return globalIndex;
   54715             :    }
   54716             : 
   54717             : //############################################################################
   54718             : // JH (01/14/2006)
   54719             : void
   54720           5 : SgOmpOrderedClause::resetValidFreepointers( )
   54721             :    {
   54722           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   54723           5 :      SgOmpOrderedClause* pointer = NULL;
   54724           5 :      std::vector < unsigned char* > :: const_iterator block;
   54725           5 :      SgOmpOrderedClause* pointerOfLinkedList = NULL;
   54726           5 :      for ( block = SgOmpOrderedClause::pools.begin(); block != SgOmpOrderedClause::pools.end() ; ++block )
   54727             :         {
   54728           0 :           pointer = (SgOmpOrderedClause*)(*block);
   54729           0 :           for (unsigned i = 0; i < SgOmpOrderedClause::pool_size; ++i )
   54730             :              {
   54731             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   54732             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   54733             :             // memory blocks!.
   54734           0 :                if ( pointer[i].get_freepointer() != NULL )
   54735             :                   {
   54736           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   54737             :                   }
   54738             :                else
   54739             :                   {
   54740           0 :                     if ( pointerOfLinkedList == NULL )
   54741             :                        {
   54742           0 :                          SgOmpOrderedClause::next_node = &(pointer[i]);
   54743             :                        }
   54744             :                     else
   54745             :                        {
   54746             :                       // printf ("In SgOmpOrderedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   54747           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   54748             :                        }
   54749             :                     pointerOfLinkedList = &(pointer[i]);
   54750             :                   }
   54751             :               }
   54752             :         }
   54753             : 
   54754           5 :      if ( pointerOfLinkedList != NULL )
   54755             :         {
   54756             :        // printf ("In SgOmpOrderedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   54757           0 :           pointerOfLinkedList->set_freepointer(NULL);
   54758             :        // DQ (6/6/2010): Temporary debugging...
   54759             :        //   ROSE_ASSERT(false);
   54760             :         }
   54761             : 
   54762           5 :      return ;
   54763             :    }
   54764             : 
   54765             : //############################################################################
   54766             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   54767             :  * within the memory pool and resets the freepointers, in order to achieve a 
   54768             :  * linked list, that has no jumps and starts at the beginning! This function 
   54769             :  * does not extend the memory pool, since we do not delete any memory blocks,
   54770             :  * but delete the valid objects.  
   54771             :  */
   54772             : void
   54773           0 : SgOmpOrderedClause::clearMemoryPool( )
   54774             :    {
   54775             :   // printf ("Inside of SgOmpOrderedClause::clearMemoryPool() \n");
   54776             : 
   54777           0 :      SgOmpOrderedClause* pointer = NULL, *tempPointer = NULL;
   54778           0 :      std::vector < unsigned char* > :: const_iterator block;
   54779           0 :      if ( SgOmpOrderedClause::pools.empty() == false )
   54780             :         {
   54781           0 :           block = SgOmpOrderedClause::pools.begin() ;
   54782           0 :           SgOmpOrderedClause::next_node = (SgOmpOrderedClause*) (*block);
   54783             : 
   54784           0 :           while ( block != SgOmpOrderedClause::pools.end() )
   54785             :              {
   54786           0 :                pointer = (SgOmpOrderedClause*) (*block);
   54787           0 :                if ( tempPointer != NULL )
   54788             :                   {
   54789           0 :                     tempPointer->set_freepointer(pointer);
   54790             :                   }
   54791           0 :                for (unsigned i = 0; i < SgOmpOrderedClause::pool_size - 1; ++i)
   54792             :                   {
   54793           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   54794             :                   }
   54795           0 :                 pointer[SgOmpOrderedClause::pool_size-1].set_freepointer(NULL);
   54796           0 :                 tempPointer = &(pointer[SgOmpOrderedClause::pool_size-1]);
   54797           0 :                 ++block;
   54798             :              }
   54799             :         }
   54800           0 :    }
   54801             : 
   54802           5 : void SgOmpOrderedClause::deleteMemoryPool() {
   54803           5 :   for (auto p: SgOmpOrderedClause::pools) {
   54804           0 :     ROSE_FREE(p);
   54805             :   }
   54806           5 :   SgOmpOrderedClause::next_node = nullptr;
   54807           5 :   SgOmpOrderedClause::pools.clear();
   54808           5 : }
   54809             : 
   54810             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   54811             : //                 reading multiple binary files to for a single AST.
   54812             : /////////// new version ////////////////////////////////
   54813             : //############################################################################
   54814             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   54815             : void
   54816           2 : SgOmpOrderedClause::extendMemoryPoolForFileIO( )
   54817             :   {
   54818           2 :     size_t blockIndex = SgOmpOrderedClause::pools.size();
   54819           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedClause);
   54820             : 
   54821           2 :     while ( (blockIndex * SgOmpOrderedClause::pool_size) < newPoolSize)
   54822             :       {
   54823             : #if ROSE_ALLOC_TRACE
   54824             :         if (blockIndex > 0) {
   54825             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedClause) = %" PRIuPTR " SgOmpOrderedClause::pool_size = %d \n",
   54826             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedClause),SgOmpOrderedClause::pool_size);
   54827             :         }
   54828             : #endif
   54829             : 
   54830           0 :         SgOmpOrderedClause * pointer = (SgOmpOrderedClause*) ROSE_MALLOC ( SgOmpOrderedClause::pool_size * sizeof(SgOmpOrderedClause) );
   54831           0 :         assert( pointer != NULL );
   54832             : #if ROSE_ALLOC_MEMSET == 1
   54833             :         memset(pointer, 0x00, SgOmpOrderedClause::pool_size * sizeof(SgOmpOrderedClause));
   54834             : #elif ROSE_ALLOC_MEMSET == 2
   54835             :         memset(pointer, 0xCC, SgOmpOrderedClause::pool_size * sizeof(SgOmpOrderedClause));
   54836             : #endif
   54837           0 :         SgOmpOrderedClause::pools.push_back( (unsigned char*)(pointer) );
   54838           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpOrderedClause::pool_size * sizeof(SgOmpOrderedClause), V_SgOmpOrderedClause ) );
   54839             : 
   54840           0 :         if ( SgOmpOrderedClause::next_node != NULL ) {
   54841           0 :           if ( blockIndex > 0 ) {
   54842           0 :             SgOmpOrderedClause * blkptr = (SgOmpOrderedClause*)(SgOmpOrderedClause::pools[blockIndex-1]);
   54843           0 :             blkptr[ SgOmpOrderedClause::pool_size - 1 ].set_freepointer(pointer);
   54844             :           }
   54845             :         } else {
   54846           0 :           SgOmpOrderedClause::next_node = pointer;
   54847             :         }
   54848             : 
   54849           0 :         for (unsigned i = 0; i < SgOmpOrderedClause::pool_size-1; ++i)
   54850             :            {
   54851           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   54852             :            }
   54853           0 :         pointer[ SgOmpOrderedClause::pool_size -1 ].set_freepointer(NULL);
   54854             : 
   54855           0 :         blockIndex++;
   54856             :       }
   54857           2 :   }
   54858             : 
   54859             : //############################################################################
   54860             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   54861             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   54862             :  * not compressed. However, that stuff is not yet implemented! 
   54863             :  */
   54864             : unsigned long
   54865           0 : SgOmpOrderedClause::getNumberOfLastValidPointer()
   54866             :    {
   54867           0 :       SgOmpOrderedClause* testPointer = (SgOmpOrderedClause*)(SgOmpOrderedClause::pools.back());
   54868           0 :       unsigned long localIndex = SgOmpOrderedClause::pool_size - 1;
   54869           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   54870             :          {
   54871           0 :            localIndex--;
   54872             :          }
   54873           0 :       return (localIndex + SgOmpOrderedClause::pool_size * (SgOmpOrderedClause::pools.size()-1));
   54874             :    }
   54875             : 
   54876             : //############################################################################
   54877             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   54878             :  * memory pool and initializes the data member in class SgOmpOrderedClauseStroageClass
   54879             :  * from its counterpart of SgOmpOrderedClause. The return value is just for checking, 
   54880             :  * that the whole StorageClassArray is initialized!
   54881             :  */
   54882             : unsigned long
   54883           0 : SgOmpOrderedClause::initializeStorageClassArray( SgOmpOrderedClauseStorageClass *storageArray )
   54884             :    {
   54885           0 :      unsigned long storageCounter = 0;
   54886           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpOrderedClause::pools.begin();
   54887           0 :      SgOmpOrderedClause* pointer = NULL;
   54888           0 :      while ( block != SgOmpOrderedClause::pools.end() ) {
   54889           0 :           pointer = (SgOmpOrderedClause*) (*block);
   54890           0 :           for ( unsigned i = 0; i < SgOmpOrderedClause::pool_size; ++i ) {
   54891           0 :                if ( pointer->get_freepointer() != NULL ) {
   54892           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   54893           0 :                  storageArray++;
   54894           0 :                  storageCounter++;
   54895             :                }
   54896           0 :                pointer++;
   54897             :              }
   54898           0 :            block++;
   54899             :         }
   54900           0 :      return storageCounter;
   54901             :    }
   54902             : 
   54903             : /* #line 54904 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   54904             : 
   54905             : 
   54906             : 
   54907             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   54908             : 
   54909             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   54910             : 
   54911             : //############################################################################
   54912             : /* JH (02/02/2006) Constructor of the IR node SgOmpCollapseClause that takes its 
   54913             :  * corresponding StorageClass as parameter
   54914             :  */
   54915           0 : SgOmpCollapseClause :: SgOmpCollapseClause ( const SgOmpCollapseClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   54916             :    {
   54917             : 
   54918             : 
   54919             : /* #line 54920 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   54920             : 
   54921           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   54922             : 
   54923             : 
   54924             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   54925             : 
   54926             : 
   54927           0 :    }
   54928             : 
   54929             : //############################################################################
   54930             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   54931             :  * within the working AST. 
   54932             :  */
   54933           0 : SgOmpCollapseClause * SgOmpCollapseClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   54934           0 :      SgOmpCollapseClause* returnPointer = NULL;
   54935           0 :      if ( globalIndex != 0 )
   54936             :         {
   54937             : 
   54938             : #if FILE_IO_EXTRA_CHECK
   54939           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpCollapseClause ) ) <= globalIndex ) ;
   54940           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCollapseClause + 1 ) ) );
   54941             : #endif
   54942           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCollapseClause )  
   54943           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpCollapseClause );
   54944           0 :           unsigned long positionInPool = localIndex % SgOmpCollapseClause::pool_size;
   54945           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCollapseClause::pool_size;
   54946             : 
   54947             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   54948             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   54949             : 
   54950           0 :           returnPointer = &( ( (SgOmpCollapseClause*)(SgOmpCollapseClause::pools[memoryBlock]) ) [positionInPool]) ;
   54951             : 
   54952           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   54953             :         }
   54954           0 :      return returnPointer ;
   54955             :    }
   54956             : 
   54957             : //############################################################################
   54958             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   54959             :   for the AST with the index astIndex
   54960             : */
   54961           0 : SgOmpCollapseClause * SgOmpCollapseClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   54962           0 :      SgOmpCollapseClause* returnPointer = NULL;
   54963           0 :      if ( globalIndex != 0 )
   54964             :         {
   54965             : 
   54966             : #if FILE_IO_EXTRA_CHECK
   54967           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpCollapseClause ) ) <= globalIndex ) ;
   54968           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCollapseClause + 1 ) ) );
   54969             : #endif
   54970           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCollapseClause )
   54971           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpCollapseClause );
   54972           0 :           unsigned long positionInPool = localIndex % SgOmpCollapseClause::pool_size ;
   54973           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCollapseClause::pool_size ;
   54974             : 
   54975             : #if FILE_IO_EXTRA_CHECK
   54976             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   54977             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   54978             : #endif
   54979             : 
   54980           0 :           returnPointer = &( ( (SgOmpCollapseClause*)(SgOmpCollapseClause::pools[memoryBlock]) ) [positionInPool]) ;
   54981             : 
   54982             : #if FILE_IO_EXTRA_CHECK
   54983           0 :           assert ( returnPointer != NULL ) ;
   54984             : #endif
   54985             :         }
   54986           0 :      return returnPointer ;
   54987             :    }
   54988             : 
   54989             : //############################################################################
   54990             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   54991             :  * pool size! We set for every valid object in the memory pool the freepointer
   54992             :  * to the global index and increase the global index afterwards. For all the 
   54993             :  * invalid objects (means address ranges within the memory pool that were not
   54994             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   54995             :  * distinguish valid from invalid objects! 
   54996             :  */
   54997             : unsigned long
   54998           5 : SgOmpCollapseClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   54999             :    {
   55000           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   55001           5 :      SgOmpCollapseClause* pointer = NULL;
   55002           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   55003           5 :      std::vector < unsigned char* > :: const_iterator block;
   55004           5 :      for ( block = SgOmpCollapseClause::pools.begin(); block != SgOmpCollapseClause::pools.end() ; ++block )
   55005             :         {
   55006           0 :           pointer = (SgOmpCollapseClause*)(*block);
   55007           0 :           for (unsigned i = 0; i < SgOmpCollapseClause::pool_size; ++i )
   55008             :              {
   55009             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   55010             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   55011             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   55012             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   55013             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   55014             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   55015             :             // properly; so this will have to be checked next.
   55016             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   55017             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   55018           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   55019             :                   {
   55020           0 :                     pointer[i].set_freepointer((SgOmpCollapseClause*)(globalIndex));
   55021           0 :                     globalIndex++;
   55022             :                   }
   55023             :                else
   55024             :                   {
   55025           0 :                     pointer[i].set_freepointer(NULL);
   55026             :                   }
   55027             :               }
   55028             :         }
   55029           5 :      return globalIndex;
   55030             :    }
   55031             : 
   55032             : //############################################################################
   55033             : // JH (01/14/2006)
   55034             : void
   55035           5 : SgOmpCollapseClause::resetValidFreepointers( )
   55036             :    {
   55037           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   55038           5 :      SgOmpCollapseClause* pointer = NULL;
   55039           5 :      std::vector < unsigned char* > :: const_iterator block;
   55040           5 :      SgOmpCollapseClause* pointerOfLinkedList = NULL;
   55041           5 :      for ( block = SgOmpCollapseClause::pools.begin(); block != SgOmpCollapseClause::pools.end() ; ++block )
   55042             :         {
   55043           0 :           pointer = (SgOmpCollapseClause*)(*block);
   55044           0 :           for (unsigned i = 0; i < SgOmpCollapseClause::pool_size; ++i )
   55045             :              {
   55046             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   55047             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   55048             :             // memory blocks!.
   55049           0 :                if ( pointer[i].get_freepointer() != NULL )
   55050             :                   {
   55051           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   55052             :                   }
   55053             :                else
   55054             :                   {
   55055           0 :                     if ( pointerOfLinkedList == NULL )
   55056             :                        {
   55057           0 :                          SgOmpCollapseClause::next_node = &(pointer[i]);
   55058             :                        }
   55059             :                     else
   55060             :                        {
   55061             :                       // printf ("In SgOmpCollapseClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   55062           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   55063             :                        }
   55064             :                     pointerOfLinkedList = &(pointer[i]);
   55065             :                   }
   55066             :               }
   55067             :         }
   55068             : 
   55069           5 :      if ( pointerOfLinkedList != NULL )
   55070             :         {
   55071             :        // printf ("In SgOmpCollapseClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   55072           0 :           pointerOfLinkedList->set_freepointer(NULL);
   55073             :        // DQ (6/6/2010): Temporary debugging...
   55074             :        //   ROSE_ASSERT(false);
   55075             :         }
   55076             : 
   55077           5 :      return ;
   55078             :    }
   55079             : 
   55080             : //############################################################################
   55081             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   55082             :  * within the memory pool and resets the freepointers, in order to achieve a 
   55083             :  * linked list, that has no jumps and starts at the beginning! This function 
   55084             :  * does not extend the memory pool, since we do not delete any memory blocks,
   55085             :  * but delete the valid objects.  
   55086             :  */
   55087             : void
   55088           0 : SgOmpCollapseClause::clearMemoryPool( )
   55089             :    {
   55090             :   // printf ("Inside of SgOmpCollapseClause::clearMemoryPool() \n");
   55091             : 
   55092           0 :      SgOmpCollapseClause* pointer = NULL, *tempPointer = NULL;
   55093           0 :      std::vector < unsigned char* > :: const_iterator block;
   55094           0 :      if ( SgOmpCollapseClause::pools.empty() == false )
   55095             :         {
   55096           0 :           block = SgOmpCollapseClause::pools.begin() ;
   55097           0 :           SgOmpCollapseClause::next_node = (SgOmpCollapseClause*) (*block);
   55098             : 
   55099           0 :           while ( block != SgOmpCollapseClause::pools.end() )
   55100             :              {
   55101           0 :                pointer = (SgOmpCollapseClause*) (*block);
   55102           0 :                if ( tempPointer != NULL )
   55103             :                   {
   55104           0 :                     tempPointer->set_freepointer(pointer);
   55105             :                   }
   55106           0 :                for (unsigned i = 0; i < SgOmpCollapseClause::pool_size - 1; ++i)
   55107             :                   {
   55108           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   55109             :                   }
   55110           0 :                 pointer[SgOmpCollapseClause::pool_size-1].set_freepointer(NULL);
   55111           0 :                 tempPointer = &(pointer[SgOmpCollapseClause::pool_size-1]);
   55112           0 :                 ++block;
   55113             :              }
   55114             :         }
   55115           0 :    }
   55116             : 
   55117           5 : void SgOmpCollapseClause::deleteMemoryPool() {
   55118           5 :   for (auto p: SgOmpCollapseClause::pools) {
   55119           0 :     ROSE_FREE(p);
   55120             :   }
   55121           5 :   SgOmpCollapseClause::next_node = nullptr;
   55122           5 :   SgOmpCollapseClause::pools.clear();
   55123           5 : }
   55124             : 
   55125             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   55126             : //                 reading multiple binary files to for a single AST.
   55127             : /////////// new version ////////////////////////////////
   55128             : //############################################################################
   55129             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   55130             : void
   55131           2 : SgOmpCollapseClause::extendMemoryPoolForFileIO( )
   55132             :   {
   55133           2 :     size_t blockIndex = SgOmpCollapseClause::pools.size();
   55134           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCollapseClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCollapseClause);
   55135             : 
   55136           2 :     while ( (blockIndex * SgOmpCollapseClause::pool_size) < newPoolSize)
   55137             :       {
   55138             : #if ROSE_ALLOC_TRACE
   55139             :         if (blockIndex > 0) {
   55140             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCollapseClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCollapseClause) = %" PRIuPTR " SgOmpCollapseClause::pool_size = %d \n",
   55141             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCollapseClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCollapseClause),SgOmpCollapseClause::pool_size);
   55142             :         }
   55143             : #endif
   55144             : 
   55145           0 :         SgOmpCollapseClause * pointer = (SgOmpCollapseClause*) ROSE_MALLOC ( SgOmpCollapseClause::pool_size * sizeof(SgOmpCollapseClause) );
   55146           0 :         assert( pointer != NULL );
   55147             : #if ROSE_ALLOC_MEMSET == 1
   55148             :         memset(pointer, 0x00, SgOmpCollapseClause::pool_size * sizeof(SgOmpCollapseClause));
   55149             : #elif ROSE_ALLOC_MEMSET == 2
   55150             :         memset(pointer, 0xCC, SgOmpCollapseClause::pool_size * sizeof(SgOmpCollapseClause));
   55151             : #endif
   55152           0 :         SgOmpCollapseClause::pools.push_back( (unsigned char*)(pointer) );
   55153           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpCollapseClause::pool_size * sizeof(SgOmpCollapseClause), V_SgOmpCollapseClause ) );
   55154             : 
   55155           0 :         if ( SgOmpCollapseClause::next_node != NULL ) {
   55156           0 :           if ( blockIndex > 0 ) {
   55157           0 :             SgOmpCollapseClause * blkptr = (SgOmpCollapseClause*)(SgOmpCollapseClause::pools[blockIndex-1]);
   55158           0 :             blkptr[ SgOmpCollapseClause::pool_size - 1 ].set_freepointer(pointer);
   55159             :           }
   55160             :         } else {
   55161           0 :           SgOmpCollapseClause::next_node = pointer;
   55162             :         }
   55163             : 
   55164           0 :         for (unsigned i = 0; i < SgOmpCollapseClause::pool_size-1; ++i)
   55165             :            {
   55166           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   55167             :            }
   55168           0 :         pointer[ SgOmpCollapseClause::pool_size -1 ].set_freepointer(NULL);
   55169             : 
   55170           0 :         blockIndex++;
   55171             :       }
   55172           2 :   }
   55173             : 
   55174             : //############################################################################
   55175             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   55176             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   55177             :  * not compressed. However, that stuff is not yet implemented! 
   55178             :  */
   55179             : unsigned long
   55180           0 : SgOmpCollapseClause::getNumberOfLastValidPointer()
   55181             :    {
   55182           0 :       SgOmpCollapseClause* testPointer = (SgOmpCollapseClause*)(SgOmpCollapseClause::pools.back());
   55183           0 :       unsigned long localIndex = SgOmpCollapseClause::pool_size - 1;
   55184           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   55185             :          {
   55186           0 :            localIndex--;
   55187             :          }
   55188           0 :       return (localIndex + SgOmpCollapseClause::pool_size * (SgOmpCollapseClause::pools.size()-1));
   55189             :    }
   55190             : 
   55191             : //############################################################################
   55192             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   55193             :  * memory pool and initializes the data member in class SgOmpCollapseClauseStroageClass
   55194             :  * from its counterpart of SgOmpCollapseClause. The return value is just for checking, 
   55195             :  * that the whole StorageClassArray is initialized!
   55196             :  */
   55197             : unsigned long
   55198           0 : SgOmpCollapseClause::initializeStorageClassArray( SgOmpCollapseClauseStorageClass *storageArray )
   55199             :    {
   55200           0 :      unsigned long storageCounter = 0;
   55201           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpCollapseClause::pools.begin();
   55202           0 :      SgOmpCollapseClause* pointer = NULL;
   55203           0 :      while ( block != SgOmpCollapseClause::pools.end() ) {
   55204           0 :           pointer = (SgOmpCollapseClause*) (*block);
   55205           0 :           for ( unsigned i = 0; i < SgOmpCollapseClause::pool_size; ++i ) {
   55206           0 :                if ( pointer->get_freepointer() != NULL ) {
   55207           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   55208           0 :                  storageArray++;
   55209           0 :                  storageCounter++;
   55210             :                }
   55211           0 :                pointer++;
   55212             :              }
   55213           0 :            block++;
   55214             :         }
   55215           0 :      return storageCounter;
   55216             :    }
   55217             : 
   55218             : /* #line 55219 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   55219             : 
   55220             : 
   55221             : 
   55222             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   55223             : 
   55224             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   55225             : 
   55226             : //############################################################################
   55227             : /* JH (02/02/2006) Constructor of the IR node SgOmpIfClause that takes its 
   55228             :  * corresponding StorageClass as parameter
   55229             :  */
   55230           0 : SgOmpIfClause :: SgOmpIfClause ( const SgOmpIfClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   55231             :    {
   55232             : 
   55233             : 
   55234             : /* #line 55235 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   55235             : 
   55236           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   55237           0 :      p_modifier = storageSource.storageOf_modifier ;
   55238             : 
   55239             : 
   55240             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   55241             : 
   55242             : 
   55243           0 :    }
   55244             : 
   55245             : //############################################################################
   55246             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   55247             :  * within the working AST. 
   55248             :  */
   55249           0 : SgOmpIfClause * SgOmpIfClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   55250           0 :      SgOmpIfClause* returnPointer = NULL;
   55251           0 :      if ( globalIndex != 0 )
   55252             :         {
   55253             : 
   55254             : #if FILE_IO_EXTRA_CHECK
   55255           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpIfClause ) ) <= globalIndex ) ;
   55256           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpIfClause + 1 ) ) );
   55257             : #endif
   55258           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpIfClause )  
   55259           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpIfClause );
   55260           0 :           unsigned long positionInPool = localIndex % SgOmpIfClause::pool_size;
   55261           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpIfClause::pool_size;
   55262             : 
   55263             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   55264             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   55265             : 
   55266           0 :           returnPointer = &( ( (SgOmpIfClause*)(SgOmpIfClause::pools[memoryBlock]) ) [positionInPool]) ;
   55267             : 
   55268           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   55269             :         }
   55270           0 :      return returnPointer ;
   55271             :    }
   55272             : 
   55273             : //############################################################################
   55274             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   55275             :   for the AST with the index astIndex
   55276             : */
   55277           0 : SgOmpIfClause * SgOmpIfClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   55278           0 :      SgOmpIfClause* returnPointer = NULL;
   55279           0 :      if ( globalIndex != 0 )
   55280             :         {
   55281             : 
   55282             : #if FILE_IO_EXTRA_CHECK
   55283           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpIfClause ) ) <= globalIndex ) ;
   55284           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpIfClause + 1 ) ) );
   55285             : #endif
   55286           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpIfClause )
   55287           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpIfClause );
   55288           0 :           unsigned long positionInPool = localIndex % SgOmpIfClause::pool_size ;
   55289           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpIfClause::pool_size ;
   55290             : 
   55291             : #if FILE_IO_EXTRA_CHECK
   55292             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   55293             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   55294             : #endif
   55295             : 
   55296           0 :           returnPointer = &( ( (SgOmpIfClause*)(SgOmpIfClause::pools[memoryBlock]) ) [positionInPool]) ;
   55297             : 
   55298             : #if FILE_IO_EXTRA_CHECK
   55299           0 :           assert ( returnPointer != NULL ) ;
   55300             : #endif
   55301             :         }
   55302           0 :      return returnPointer ;
   55303             :    }
   55304             : 
   55305             : //############################################################################
   55306             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   55307             :  * pool size! We set for every valid object in the memory pool the freepointer
   55308             :  * to the global index and increase the global index afterwards. For all the 
   55309             :  * invalid objects (means address ranges within the memory pool that were not
   55310             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   55311             :  * distinguish valid from invalid objects! 
   55312             :  */
   55313             : unsigned long
   55314           5 : SgOmpIfClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   55315             :    {
   55316           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   55317           5 :      SgOmpIfClause* pointer = NULL;
   55318           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   55319           5 :      std::vector < unsigned char* > :: const_iterator block;
   55320           5 :      for ( block = SgOmpIfClause::pools.begin(); block != SgOmpIfClause::pools.end() ; ++block )
   55321             :         {
   55322           0 :           pointer = (SgOmpIfClause*)(*block);
   55323           0 :           for (unsigned i = 0; i < SgOmpIfClause::pool_size; ++i )
   55324             :              {
   55325             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   55326             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   55327             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   55328             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   55329             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   55330             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   55331             :             // properly; so this will have to be checked next.
   55332             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   55333             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   55334           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   55335             :                   {
   55336           0 :                     pointer[i].set_freepointer((SgOmpIfClause*)(globalIndex));
   55337           0 :                     globalIndex++;
   55338             :                   }
   55339             :                else
   55340             :                   {
   55341           0 :                     pointer[i].set_freepointer(NULL);
   55342             :                   }
   55343             :               }
   55344             :         }
   55345           5 :      return globalIndex;
   55346             :    }
   55347             : 
   55348             : //############################################################################
   55349             : // JH (01/14/2006)
   55350             : void
   55351           5 : SgOmpIfClause::resetValidFreepointers( )
   55352             :    {
   55353           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   55354           5 :      SgOmpIfClause* pointer = NULL;
   55355           5 :      std::vector < unsigned char* > :: const_iterator block;
   55356           5 :      SgOmpIfClause* pointerOfLinkedList = NULL;
   55357           5 :      for ( block = SgOmpIfClause::pools.begin(); block != SgOmpIfClause::pools.end() ; ++block )
   55358             :         {
   55359           0 :           pointer = (SgOmpIfClause*)(*block);
   55360           0 :           for (unsigned i = 0; i < SgOmpIfClause::pool_size; ++i )
   55361             :              {
   55362             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   55363             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   55364             :             // memory blocks!.
   55365           0 :                if ( pointer[i].get_freepointer() != NULL )
   55366             :                   {
   55367           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   55368             :                   }
   55369             :                else
   55370             :                   {
   55371           0 :                     if ( pointerOfLinkedList == NULL )
   55372             :                        {
   55373           0 :                          SgOmpIfClause::next_node = &(pointer[i]);
   55374             :                        }
   55375             :                     else
   55376             :                        {
   55377             :                       // printf ("In SgOmpIfClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   55378           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   55379             :                        }
   55380             :                     pointerOfLinkedList = &(pointer[i]);
   55381             :                   }
   55382             :               }
   55383             :         }
   55384             : 
   55385           5 :      if ( pointerOfLinkedList != NULL )
   55386             :         {
   55387             :        // printf ("In SgOmpIfClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   55388           0 :           pointerOfLinkedList->set_freepointer(NULL);
   55389             :        // DQ (6/6/2010): Temporary debugging...
   55390             :        //   ROSE_ASSERT(false);
   55391             :         }
   55392             : 
   55393           5 :      return ;
   55394             :    }
   55395             : 
   55396             : //############################################################################
   55397             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   55398             :  * within the memory pool and resets the freepointers, in order to achieve a 
   55399             :  * linked list, that has no jumps and starts at the beginning! This function 
   55400             :  * does not extend the memory pool, since we do not delete any memory blocks,
   55401             :  * but delete the valid objects.  
   55402             :  */
   55403             : void
   55404           0 : SgOmpIfClause::clearMemoryPool( )
   55405             :    {
   55406             :   // printf ("Inside of SgOmpIfClause::clearMemoryPool() \n");
   55407             : 
   55408           0 :      SgOmpIfClause* pointer = NULL, *tempPointer = NULL;
   55409           0 :      std::vector < unsigned char* > :: const_iterator block;
   55410           0 :      if ( SgOmpIfClause::pools.empty() == false )
   55411             :         {
   55412           0 :           block = SgOmpIfClause::pools.begin() ;
   55413           0 :           SgOmpIfClause::next_node = (SgOmpIfClause*) (*block);
   55414             : 
   55415           0 :           while ( block != SgOmpIfClause::pools.end() )
   55416             :              {
   55417           0 :                pointer = (SgOmpIfClause*) (*block);
   55418           0 :                if ( tempPointer != NULL )
   55419             :                   {
   55420           0 :                     tempPointer->set_freepointer(pointer);
   55421             :                   }
   55422           0 :                for (unsigned i = 0; i < SgOmpIfClause::pool_size - 1; ++i)
   55423             :                   {
   55424           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   55425             :                   }
   55426           0 :                 pointer[SgOmpIfClause::pool_size-1].set_freepointer(NULL);
   55427           0 :                 tempPointer = &(pointer[SgOmpIfClause::pool_size-1]);
   55428           0 :                 ++block;
   55429             :              }
   55430             :         }
   55431           0 :    }
   55432             : 
   55433           5 : void SgOmpIfClause::deleteMemoryPool() {
   55434           5 :   for (auto p: SgOmpIfClause::pools) {
   55435           0 :     ROSE_FREE(p);
   55436             :   }
   55437           5 :   SgOmpIfClause::next_node = nullptr;
   55438           5 :   SgOmpIfClause::pools.clear();
   55439           5 : }
   55440             : 
   55441             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   55442             : //                 reading multiple binary files to for a single AST.
   55443             : /////////// new version ////////////////////////////////
   55444             : //############################################################################
   55445             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   55446             : void
   55447           2 : SgOmpIfClause::extendMemoryPoolForFileIO( )
   55448             :   {
   55449           2 :     size_t blockIndex = SgOmpIfClause::pools.size();
   55450           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpIfClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpIfClause);
   55451             : 
   55452           2 :     while ( (blockIndex * SgOmpIfClause::pool_size) < newPoolSize)
   55453             :       {
   55454             : #if ROSE_ALLOC_TRACE
   55455             :         if (blockIndex > 0) {
   55456             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpIfClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpIfClause) = %" PRIuPTR " SgOmpIfClause::pool_size = %d \n",
   55457             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpIfClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpIfClause),SgOmpIfClause::pool_size);
   55458             :         }
   55459             : #endif
   55460             : 
   55461           0 :         SgOmpIfClause * pointer = (SgOmpIfClause*) ROSE_MALLOC ( SgOmpIfClause::pool_size * sizeof(SgOmpIfClause) );
   55462           0 :         assert( pointer != NULL );
   55463             : #if ROSE_ALLOC_MEMSET == 1
   55464             :         memset(pointer, 0x00, SgOmpIfClause::pool_size * sizeof(SgOmpIfClause));
   55465             : #elif ROSE_ALLOC_MEMSET == 2
   55466             :         memset(pointer, 0xCC, SgOmpIfClause::pool_size * sizeof(SgOmpIfClause));
   55467             : #endif
   55468           0 :         SgOmpIfClause::pools.push_back( (unsigned char*)(pointer) );
   55469           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpIfClause::pool_size * sizeof(SgOmpIfClause), V_SgOmpIfClause ) );
   55470             : 
   55471           0 :         if ( SgOmpIfClause::next_node != NULL ) {
   55472           0 :           if ( blockIndex > 0 ) {
   55473           0 :             SgOmpIfClause * blkptr = (SgOmpIfClause*)(SgOmpIfClause::pools[blockIndex-1]);
   55474           0 :             blkptr[ SgOmpIfClause::pool_size - 1 ].set_freepointer(pointer);
   55475             :           }
   55476             :         } else {
   55477           0 :           SgOmpIfClause::next_node = pointer;
   55478             :         }
   55479             : 
   55480           0 :         for (unsigned i = 0; i < SgOmpIfClause::pool_size-1; ++i)
   55481             :            {
   55482           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   55483             :            }
   55484           0 :         pointer[ SgOmpIfClause::pool_size -1 ].set_freepointer(NULL);
   55485             : 
   55486           0 :         blockIndex++;
   55487             :       }
   55488           2 :   }
   55489             : 
   55490             : //############################################################################
   55491             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   55492             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   55493             :  * not compressed. However, that stuff is not yet implemented! 
   55494             :  */
   55495             : unsigned long
   55496           0 : SgOmpIfClause::getNumberOfLastValidPointer()
   55497             :    {
   55498           0 :       SgOmpIfClause* testPointer = (SgOmpIfClause*)(SgOmpIfClause::pools.back());
   55499           0 :       unsigned long localIndex = SgOmpIfClause::pool_size - 1;
   55500           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   55501             :          {
   55502           0 :            localIndex--;
   55503             :          }
   55504           0 :       return (localIndex + SgOmpIfClause::pool_size * (SgOmpIfClause::pools.size()-1));
   55505             :    }
   55506             : 
   55507             : //############################################################################
   55508             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   55509             :  * memory pool and initializes the data member in class SgOmpIfClauseStroageClass
   55510             :  * from its counterpart of SgOmpIfClause. The return value is just for checking, 
   55511             :  * that the whole StorageClassArray is initialized!
   55512             :  */
   55513             : unsigned long
   55514           0 : SgOmpIfClause::initializeStorageClassArray( SgOmpIfClauseStorageClass *storageArray )
   55515             :    {
   55516           0 :      unsigned long storageCounter = 0;
   55517           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpIfClause::pools.begin();
   55518           0 :      SgOmpIfClause* pointer = NULL;
   55519           0 :      while ( block != SgOmpIfClause::pools.end() ) {
   55520           0 :           pointer = (SgOmpIfClause*) (*block);
   55521           0 :           for ( unsigned i = 0; i < SgOmpIfClause::pool_size; ++i ) {
   55522           0 :                if ( pointer->get_freepointer() != NULL ) {
   55523           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   55524           0 :                  storageArray++;
   55525           0 :                  storageCounter++;
   55526             :                }
   55527           0 :                pointer++;
   55528             :              }
   55529           0 :            block++;
   55530             :         }
   55531           0 :      return storageCounter;
   55532             :    }
   55533             : 
   55534             : /* #line 55535 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   55535             : 
   55536             : 
   55537             : 
   55538             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   55539             : 
   55540             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   55541             : 
   55542             : //############################################################################
   55543             : /* JH (02/02/2006) Constructor of the IR node SgUpirNumUnitsField that takes its 
   55544             :  * corresponding StorageClass as parameter
   55545             :  */
   55546           0 : SgUpirNumUnitsField :: SgUpirNumUnitsField ( const SgUpirNumUnitsFieldStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   55547             :    {
   55548             : 
   55549             : 
   55550             : /* #line 55551 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   55551             : 
   55552           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   55553             : 
   55554             : 
   55555             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   55556             : 
   55557             : 
   55558           0 :    }
   55559             : 
   55560             : //############################################################################
   55561             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   55562             :  * within the working AST. 
   55563             :  */
   55564           0 : SgUpirNumUnitsField * SgUpirNumUnitsField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   55565           0 :      SgUpirNumUnitsField* returnPointer = NULL;
   55566           0 :      if ( globalIndex != 0 )
   55567             :         {
   55568             : 
   55569             : #if FILE_IO_EXTRA_CHECK
   55570           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirNumUnitsField ) ) <= globalIndex ) ;
   55571           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirNumUnitsField + 1 ) ) );
   55572             : #endif
   55573           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirNumUnitsField )  
   55574           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirNumUnitsField );
   55575           0 :           unsigned long positionInPool = localIndex % SgUpirNumUnitsField::pool_size;
   55576           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirNumUnitsField::pool_size;
   55577             : 
   55578             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   55579             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   55580             : 
   55581           0 :           returnPointer = &( ( (SgUpirNumUnitsField*)(SgUpirNumUnitsField::pools[memoryBlock]) ) [positionInPool]) ;
   55582             : 
   55583           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   55584             :         }
   55585           0 :      return returnPointer ;
   55586             :    }
   55587             : 
   55588             : //############################################################################
   55589             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   55590             :   for the AST with the index astIndex
   55591             : */
   55592           0 : SgUpirNumUnitsField * SgUpirNumUnitsField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   55593           0 :      SgUpirNumUnitsField* returnPointer = NULL;
   55594           0 :      if ( globalIndex != 0 )
   55595             :         {
   55596             : 
   55597             : #if FILE_IO_EXTRA_CHECK
   55598           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirNumUnitsField ) ) <= globalIndex ) ;
   55599           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirNumUnitsField + 1 ) ) );
   55600             : #endif
   55601           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirNumUnitsField )
   55602           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirNumUnitsField );
   55603           0 :           unsigned long positionInPool = localIndex % SgUpirNumUnitsField::pool_size ;
   55604           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirNumUnitsField::pool_size ;
   55605             : 
   55606             : #if FILE_IO_EXTRA_CHECK
   55607             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   55608             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   55609             : #endif
   55610             : 
   55611           0 :           returnPointer = &( ( (SgUpirNumUnitsField*)(SgUpirNumUnitsField::pools[memoryBlock]) ) [positionInPool]) ;
   55612             : 
   55613             : #if FILE_IO_EXTRA_CHECK
   55614           0 :           assert ( returnPointer != NULL ) ;
   55615             : #endif
   55616             :         }
   55617           0 :      return returnPointer ;
   55618             :    }
   55619             : 
   55620             : //############################################################################
   55621             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   55622             :  * pool size! We set for every valid object in the memory pool the freepointer
   55623             :  * to the global index and increase the global index afterwards. For all the 
   55624             :  * invalid objects (means address ranges within the memory pool that were not
   55625             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   55626             :  * distinguish valid from invalid objects! 
   55627             :  */
   55628             : unsigned long
   55629           5 : SgUpirNumUnitsField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   55630             :    {
   55631           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   55632           5 :      SgUpirNumUnitsField* pointer = NULL;
   55633           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   55634           5 :      std::vector < unsigned char* > :: const_iterator block;
   55635           5 :      for ( block = SgUpirNumUnitsField::pools.begin(); block != SgUpirNumUnitsField::pools.end() ; ++block )
   55636             :         {
   55637           0 :           pointer = (SgUpirNumUnitsField*)(*block);
   55638           0 :           for (unsigned i = 0; i < SgUpirNumUnitsField::pool_size; ++i )
   55639             :              {
   55640             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   55641             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   55642             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   55643             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   55644             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   55645             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   55646             :             // properly; so this will have to be checked next.
   55647             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   55648             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   55649           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   55650             :                   {
   55651           0 :                     pointer[i].set_freepointer((SgUpirNumUnitsField*)(globalIndex));
   55652           0 :                     globalIndex++;
   55653             :                   }
   55654             :                else
   55655             :                   {
   55656           0 :                     pointer[i].set_freepointer(NULL);
   55657             :                   }
   55658             :               }
   55659             :         }
   55660           5 :      return globalIndex;
   55661             :    }
   55662             : 
   55663             : //############################################################################
   55664             : // JH (01/14/2006)
   55665             : void
   55666           5 : SgUpirNumUnitsField::resetValidFreepointers( )
   55667             :    {
   55668           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   55669           5 :      SgUpirNumUnitsField* pointer = NULL;
   55670           5 :      std::vector < unsigned char* > :: const_iterator block;
   55671           5 :      SgUpirNumUnitsField* pointerOfLinkedList = NULL;
   55672           5 :      for ( block = SgUpirNumUnitsField::pools.begin(); block != SgUpirNumUnitsField::pools.end() ; ++block )
   55673             :         {
   55674           0 :           pointer = (SgUpirNumUnitsField*)(*block);
   55675           0 :           for (unsigned i = 0; i < SgUpirNumUnitsField::pool_size; ++i )
   55676             :              {
   55677             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   55678             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   55679             :             // memory blocks!.
   55680           0 :                if ( pointer[i].get_freepointer() != NULL )
   55681             :                   {
   55682           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   55683             :                   }
   55684             :                else
   55685             :                   {
   55686           0 :                     if ( pointerOfLinkedList == NULL )
   55687             :                        {
   55688           0 :                          SgUpirNumUnitsField::next_node = &(pointer[i]);
   55689             :                        }
   55690             :                     else
   55691             :                        {
   55692             :                       // printf ("In SgUpirNumUnitsField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   55693           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   55694             :                        }
   55695             :                     pointerOfLinkedList = &(pointer[i]);
   55696             :                   }
   55697             :               }
   55698             :         }
   55699             : 
   55700           5 :      if ( pointerOfLinkedList != NULL )
   55701             :         {
   55702             :        // printf ("In SgUpirNumUnitsField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   55703           0 :           pointerOfLinkedList->set_freepointer(NULL);
   55704             :        // DQ (6/6/2010): Temporary debugging...
   55705             :        //   ROSE_ASSERT(false);
   55706             :         }
   55707             : 
   55708           5 :      return ;
   55709             :    }
   55710             : 
   55711             : //############################################################################
   55712             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   55713             :  * within the memory pool and resets the freepointers, in order to achieve a 
   55714             :  * linked list, that has no jumps and starts at the beginning! This function 
   55715             :  * does not extend the memory pool, since we do not delete any memory blocks,
   55716             :  * but delete the valid objects.  
   55717             :  */
   55718             : void
   55719           0 : SgUpirNumUnitsField::clearMemoryPool( )
   55720             :    {
   55721             :   // printf ("Inside of SgUpirNumUnitsField::clearMemoryPool() \n");
   55722             : 
   55723           0 :      SgUpirNumUnitsField* pointer = NULL, *tempPointer = NULL;
   55724           0 :      std::vector < unsigned char* > :: const_iterator block;
   55725           0 :      if ( SgUpirNumUnitsField::pools.empty() == false )
   55726             :         {
   55727           0 :           block = SgUpirNumUnitsField::pools.begin() ;
   55728           0 :           SgUpirNumUnitsField::next_node = (SgUpirNumUnitsField*) (*block);
   55729             : 
   55730           0 :           while ( block != SgUpirNumUnitsField::pools.end() )
   55731             :              {
   55732           0 :                pointer = (SgUpirNumUnitsField*) (*block);
   55733           0 :                if ( tempPointer != NULL )
   55734             :                   {
   55735           0 :                     tempPointer->set_freepointer(pointer);
   55736             :                   }
   55737           0 :                for (unsigned i = 0; i < SgUpirNumUnitsField::pool_size - 1; ++i)
   55738             :                   {
   55739           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   55740             :                   }
   55741           0 :                 pointer[SgUpirNumUnitsField::pool_size-1].set_freepointer(NULL);
   55742           0 :                 tempPointer = &(pointer[SgUpirNumUnitsField::pool_size-1]);
   55743           0 :                 ++block;
   55744             :              }
   55745             :         }
   55746           0 :    }
   55747             : 
   55748           5 : void SgUpirNumUnitsField::deleteMemoryPool() {
   55749           5 :   for (auto p: SgUpirNumUnitsField::pools) {
   55750           0 :     ROSE_FREE(p);
   55751             :   }
   55752           5 :   SgUpirNumUnitsField::next_node = nullptr;
   55753           5 :   SgUpirNumUnitsField::pools.clear();
   55754           5 : }
   55755             : 
   55756             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   55757             : //                 reading multiple binary files to for a single AST.
   55758             : /////////// new version ////////////////////////////////
   55759             : //############################################################################
   55760             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   55761             : void
   55762           2 : SgUpirNumUnitsField::extendMemoryPoolForFileIO( )
   55763             :   {
   55764           2 :     size_t blockIndex = SgUpirNumUnitsField::pools.size();
   55765           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNumUnitsField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNumUnitsField);
   55766             : 
   55767           2 :     while ( (blockIndex * SgUpirNumUnitsField::pool_size) < newPoolSize)
   55768             :       {
   55769             : #if ROSE_ALLOC_TRACE
   55770             :         if (blockIndex > 0) {
   55771             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNumUnitsField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNumUnitsField) = %" PRIuPTR " SgUpirNumUnitsField::pool_size = %d \n",
   55772             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNumUnitsField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNumUnitsField),SgUpirNumUnitsField::pool_size);
   55773             :         }
   55774             : #endif
   55775             : 
   55776           0 :         SgUpirNumUnitsField * pointer = (SgUpirNumUnitsField*) ROSE_MALLOC ( SgUpirNumUnitsField::pool_size * sizeof(SgUpirNumUnitsField) );
   55777           0 :         assert( pointer != NULL );
   55778             : #if ROSE_ALLOC_MEMSET == 1
   55779             :         memset(pointer, 0x00, SgUpirNumUnitsField::pool_size * sizeof(SgUpirNumUnitsField));
   55780             : #elif ROSE_ALLOC_MEMSET == 2
   55781             :         memset(pointer, 0xCC, SgUpirNumUnitsField::pool_size * sizeof(SgUpirNumUnitsField));
   55782             : #endif
   55783           0 :         SgUpirNumUnitsField::pools.push_back( (unsigned char*)(pointer) );
   55784           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirNumUnitsField::pool_size * sizeof(SgUpirNumUnitsField), V_SgUpirNumUnitsField ) );
   55785             : 
   55786           0 :         if ( SgUpirNumUnitsField::next_node != NULL ) {
   55787           0 :           if ( blockIndex > 0 ) {
   55788           0 :             SgUpirNumUnitsField * blkptr = (SgUpirNumUnitsField*)(SgUpirNumUnitsField::pools[blockIndex-1]);
   55789           0 :             blkptr[ SgUpirNumUnitsField::pool_size - 1 ].set_freepointer(pointer);
   55790             :           }
   55791             :         } else {
   55792           0 :           SgUpirNumUnitsField::next_node = pointer;
   55793             :         }
   55794             : 
   55795           0 :         for (unsigned i = 0; i < SgUpirNumUnitsField::pool_size-1; ++i)
   55796             :            {
   55797           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   55798             :            }
   55799           0 :         pointer[ SgUpirNumUnitsField::pool_size -1 ].set_freepointer(NULL);
   55800             : 
   55801           0 :         blockIndex++;
   55802             :       }
   55803           2 :   }
   55804             : 
   55805             : //############################################################################
   55806             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   55807             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   55808             :  * not compressed. However, that stuff is not yet implemented! 
   55809             :  */
   55810             : unsigned long
   55811           0 : SgUpirNumUnitsField::getNumberOfLastValidPointer()
   55812             :    {
   55813           0 :       SgUpirNumUnitsField* testPointer = (SgUpirNumUnitsField*)(SgUpirNumUnitsField::pools.back());
   55814           0 :       unsigned long localIndex = SgUpirNumUnitsField::pool_size - 1;
   55815           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   55816             :          {
   55817           0 :            localIndex--;
   55818             :          }
   55819           0 :       return (localIndex + SgUpirNumUnitsField::pool_size * (SgUpirNumUnitsField::pools.size()-1));
   55820             :    }
   55821             : 
   55822             : //############################################################################
   55823             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   55824             :  * memory pool and initializes the data member in class SgUpirNumUnitsFieldStroageClass
   55825             :  * from its counterpart of SgUpirNumUnitsField. The return value is just for checking, 
   55826             :  * that the whole StorageClassArray is initialized!
   55827             :  */
   55828             : unsigned long
   55829           0 : SgUpirNumUnitsField::initializeStorageClassArray( SgUpirNumUnitsFieldStorageClass *storageArray )
   55830             :    {
   55831           0 :      unsigned long storageCounter = 0;
   55832           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirNumUnitsField::pools.begin();
   55833           0 :      SgUpirNumUnitsField* pointer = NULL;
   55834           0 :      while ( block != SgUpirNumUnitsField::pools.end() ) {
   55835           0 :           pointer = (SgUpirNumUnitsField*) (*block);
   55836           0 :           for ( unsigned i = 0; i < SgUpirNumUnitsField::pool_size; ++i ) {
   55837           0 :                if ( pointer->get_freepointer() != NULL ) {
   55838           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   55839           0 :                  storageArray++;
   55840           0 :                  storageCounter++;
   55841             :                }
   55842           0 :                pointer++;
   55843             :              }
   55844           0 :            block++;
   55845             :         }
   55846           0 :      return storageCounter;
   55847             :    }
   55848             : 
   55849             : /* #line 55850 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   55850             : 
   55851             : 
   55852             : 
   55853             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   55854             : 
   55855             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   55856             : 
   55857             : //############################################################################
   55858             : /* JH (02/02/2006) Constructor of the IR node SgOmpNumTeamsClause that takes its 
   55859             :  * corresponding StorageClass as parameter
   55860             :  */
   55861           0 : SgOmpNumTeamsClause :: SgOmpNumTeamsClause ( const SgOmpNumTeamsClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   55862             :    {
   55863             : 
   55864             : 
   55865             : /* #line 55866 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   55866             : 
   55867           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   55868             : 
   55869             : 
   55870             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   55871             : 
   55872             : 
   55873           0 :    }
   55874             : 
   55875             : //############################################################################
   55876             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   55877             :  * within the working AST. 
   55878             :  */
   55879           0 : SgOmpNumTeamsClause * SgOmpNumTeamsClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   55880           0 :      SgOmpNumTeamsClause* returnPointer = NULL;
   55881           0 :      if ( globalIndex != 0 )
   55882             :         {
   55883             : 
   55884             : #if FILE_IO_EXTRA_CHECK
   55885           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpNumTeamsClause ) ) <= globalIndex ) ;
   55886           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNumTeamsClause + 1 ) ) );
   55887             : #endif
   55888           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNumTeamsClause )  
   55889           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpNumTeamsClause );
   55890           0 :           unsigned long positionInPool = localIndex % SgOmpNumTeamsClause::pool_size;
   55891           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNumTeamsClause::pool_size;
   55892             : 
   55893             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   55894             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   55895             : 
   55896           0 :           returnPointer = &( ( (SgOmpNumTeamsClause*)(SgOmpNumTeamsClause::pools[memoryBlock]) ) [positionInPool]) ;
   55897             : 
   55898           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   55899             :         }
   55900           0 :      return returnPointer ;
   55901             :    }
   55902             : 
   55903             : //############################################################################
   55904             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   55905             :   for the AST with the index astIndex
   55906             : */
   55907           0 : SgOmpNumTeamsClause * SgOmpNumTeamsClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   55908           0 :      SgOmpNumTeamsClause* returnPointer = NULL;
   55909           0 :      if ( globalIndex != 0 )
   55910             :         {
   55911             : 
   55912             : #if FILE_IO_EXTRA_CHECK
   55913           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpNumTeamsClause ) ) <= globalIndex ) ;
   55914           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNumTeamsClause + 1 ) ) );
   55915             : #endif
   55916           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNumTeamsClause )
   55917           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpNumTeamsClause );
   55918           0 :           unsigned long positionInPool = localIndex % SgOmpNumTeamsClause::pool_size ;
   55919           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNumTeamsClause::pool_size ;
   55920             : 
   55921             : #if FILE_IO_EXTRA_CHECK
   55922             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   55923             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   55924             : #endif
   55925             : 
   55926           0 :           returnPointer = &( ( (SgOmpNumTeamsClause*)(SgOmpNumTeamsClause::pools[memoryBlock]) ) [positionInPool]) ;
   55927             : 
   55928             : #if FILE_IO_EXTRA_CHECK
   55929           0 :           assert ( returnPointer != NULL ) ;
   55930             : #endif
   55931             :         }
   55932           0 :      return returnPointer ;
   55933             :    }
   55934             : 
   55935             : //############################################################################
   55936             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   55937             :  * pool size! We set for every valid object in the memory pool the freepointer
   55938             :  * to the global index and increase the global index afterwards. For all the 
   55939             :  * invalid objects (means address ranges within the memory pool that were not
   55940             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   55941             :  * distinguish valid from invalid objects! 
   55942             :  */
   55943             : unsigned long
   55944           5 : SgOmpNumTeamsClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   55945             :    {
   55946           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   55947           5 :      SgOmpNumTeamsClause* pointer = NULL;
   55948           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   55949           5 :      std::vector < unsigned char* > :: const_iterator block;
   55950           5 :      for ( block = SgOmpNumTeamsClause::pools.begin(); block != SgOmpNumTeamsClause::pools.end() ; ++block )
   55951             :         {
   55952           0 :           pointer = (SgOmpNumTeamsClause*)(*block);
   55953           0 :           for (unsigned i = 0; i < SgOmpNumTeamsClause::pool_size; ++i )
   55954             :              {
   55955             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   55956             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   55957             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   55958             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   55959             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   55960             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   55961             :             // properly; so this will have to be checked next.
   55962             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   55963             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   55964           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   55965             :                   {
   55966           0 :                     pointer[i].set_freepointer((SgOmpNumTeamsClause*)(globalIndex));
   55967           0 :                     globalIndex++;
   55968             :                   }
   55969             :                else
   55970             :                   {
   55971           0 :                     pointer[i].set_freepointer(NULL);
   55972             :                   }
   55973             :               }
   55974             :         }
   55975           5 :      return globalIndex;
   55976             :    }
   55977             : 
   55978             : //############################################################################
   55979             : // JH (01/14/2006)
   55980             : void
   55981           5 : SgOmpNumTeamsClause::resetValidFreepointers( )
   55982             :    {
   55983           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   55984           5 :      SgOmpNumTeamsClause* pointer = NULL;
   55985           5 :      std::vector < unsigned char* > :: const_iterator block;
   55986           5 :      SgOmpNumTeamsClause* pointerOfLinkedList = NULL;
   55987           5 :      for ( block = SgOmpNumTeamsClause::pools.begin(); block != SgOmpNumTeamsClause::pools.end() ; ++block )
   55988             :         {
   55989           0 :           pointer = (SgOmpNumTeamsClause*)(*block);
   55990           0 :           for (unsigned i = 0; i < SgOmpNumTeamsClause::pool_size; ++i )
   55991             :              {
   55992             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   55993             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   55994             :             // memory blocks!.
   55995           0 :                if ( pointer[i].get_freepointer() != NULL )
   55996             :                   {
   55997           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   55998             :                   }
   55999             :                else
   56000             :                   {
   56001           0 :                     if ( pointerOfLinkedList == NULL )
   56002             :                        {
   56003           0 :                          SgOmpNumTeamsClause::next_node = &(pointer[i]);
   56004             :                        }
   56005             :                     else
   56006             :                        {
   56007             :                       // printf ("In SgOmpNumTeamsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   56008           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   56009             :                        }
   56010             :                     pointerOfLinkedList = &(pointer[i]);
   56011             :                   }
   56012             :               }
   56013             :         }
   56014             : 
   56015           5 :      if ( pointerOfLinkedList != NULL )
   56016             :         {
   56017             :        // printf ("In SgOmpNumTeamsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   56018           0 :           pointerOfLinkedList->set_freepointer(NULL);
   56019             :        // DQ (6/6/2010): Temporary debugging...
   56020             :        //   ROSE_ASSERT(false);
   56021             :         }
   56022             : 
   56023           5 :      return ;
   56024             :    }
   56025             : 
   56026             : //############################################################################
   56027             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   56028             :  * within the memory pool and resets the freepointers, in order to achieve a 
   56029             :  * linked list, that has no jumps and starts at the beginning! This function 
   56030             :  * does not extend the memory pool, since we do not delete any memory blocks,
   56031             :  * but delete the valid objects.  
   56032             :  */
   56033             : void
   56034           0 : SgOmpNumTeamsClause::clearMemoryPool( )
   56035             :    {
   56036             :   // printf ("Inside of SgOmpNumTeamsClause::clearMemoryPool() \n");
   56037             : 
   56038           0 :      SgOmpNumTeamsClause* pointer = NULL, *tempPointer = NULL;
   56039           0 :      std::vector < unsigned char* > :: const_iterator block;
   56040           0 :      if ( SgOmpNumTeamsClause::pools.empty() == false )
   56041             :         {
   56042           0 :           block = SgOmpNumTeamsClause::pools.begin() ;
   56043           0 :           SgOmpNumTeamsClause::next_node = (SgOmpNumTeamsClause*) (*block);
   56044             : 
   56045           0 :           while ( block != SgOmpNumTeamsClause::pools.end() )
   56046             :              {
   56047           0 :                pointer = (SgOmpNumTeamsClause*) (*block);
   56048           0 :                if ( tempPointer != NULL )
   56049             :                   {
   56050           0 :                     tempPointer->set_freepointer(pointer);
   56051             :                   }
   56052           0 :                for (unsigned i = 0; i < SgOmpNumTeamsClause::pool_size - 1; ++i)
   56053             :                   {
   56054           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   56055             :                   }
   56056           0 :                 pointer[SgOmpNumTeamsClause::pool_size-1].set_freepointer(NULL);
   56057           0 :                 tempPointer = &(pointer[SgOmpNumTeamsClause::pool_size-1]);
   56058           0 :                 ++block;
   56059             :              }
   56060             :         }
   56061           0 :    }
   56062             : 
   56063           5 : void SgOmpNumTeamsClause::deleteMemoryPool() {
   56064           5 :   for (auto p: SgOmpNumTeamsClause::pools) {
   56065           0 :     ROSE_FREE(p);
   56066             :   }
   56067           5 :   SgOmpNumTeamsClause::next_node = nullptr;
   56068           5 :   SgOmpNumTeamsClause::pools.clear();
   56069           5 : }
   56070             : 
   56071             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   56072             : //                 reading multiple binary files to for a single AST.
   56073             : /////////// new version ////////////////////////////////
   56074             : //############################################################################
   56075             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   56076             : void
   56077           2 : SgOmpNumTeamsClause::extendMemoryPoolForFileIO( )
   56078             :   {
   56079           2 :     size_t blockIndex = SgOmpNumTeamsClause::pools.size();
   56080           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNumTeamsClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNumTeamsClause);
   56081             : 
   56082           2 :     while ( (blockIndex * SgOmpNumTeamsClause::pool_size) < newPoolSize)
   56083             :       {
   56084             : #if ROSE_ALLOC_TRACE
   56085             :         if (blockIndex > 0) {
   56086             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNumTeamsClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNumTeamsClause) = %" PRIuPTR " SgOmpNumTeamsClause::pool_size = %d \n",
   56087             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNumTeamsClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNumTeamsClause),SgOmpNumTeamsClause::pool_size);
   56088             :         }
   56089             : #endif
   56090             : 
   56091           0 :         SgOmpNumTeamsClause * pointer = (SgOmpNumTeamsClause*) ROSE_MALLOC ( SgOmpNumTeamsClause::pool_size * sizeof(SgOmpNumTeamsClause) );
   56092           0 :         assert( pointer != NULL );
   56093             : #if ROSE_ALLOC_MEMSET == 1
   56094             :         memset(pointer, 0x00, SgOmpNumTeamsClause::pool_size * sizeof(SgOmpNumTeamsClause));
   56095             : #elif ROSE_ALLOC_MEMSET == 2
   56096             :         memset(pointer, 0xCC, SgOmpNumTeamsClause::pool_size * sizeof(SgOmpNumTeamsClause));
   56097             : #endif
   56098           0 :         SgOmpNumTeamsClause::pools.push_back( (unsigned char*)(pointer) );
   56099           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpNumTeamsClause::pool_size * sizeof(SgOmpNumTeamsClause), V_SgOmpNumTeamsClause ) );
   56100             : 
   56101           0 :         if ( SgOmpNumTeamsClause::next_node != NULL ) {
   56102           0 :           if ( blockIndex > 0 ) {
   56103           0 :             SgOmpNumTeamsClause * blkptr = (SgOmpNumTeamsClause*)(SgOmpNumTeamsClause::pools[blockIndex-1]);
   56104           0 :             blkptr[ SgOmpNumTeamsClause::pool_size - 1 ].set_freepointer(pointer);
   56105             :           }
   56106             :         } else {
   56107           0 :           SgOmpNumTeamsClause::next_node = pointer;
   56108             :         }
   56109             : 
   56110           0 :         for (unsigned i = 0; i < SgOmpNumTeamsClause::pool_size-1; ++i)
   56111             :            {
   56112           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   56113             :            }
   56114           0 :         pointer[ SgOmpNumTeamsClause::pool_size -1 ].set_freepointer(NULL);
   56115             : 
   56116           0 :         blockIndex++;
   56117             :       }
   56118           2 :   }
   56119             : 
   56120             : //############################################################################
   56121             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   56122             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   56123             :  * not compressed. However, that stuff is not yet implemented! 
   56124             :  */
   56125             : unsigned long
   56126           0 : SgOmpNumTeamsClause::getNumberOfLastValidPointer()
   56127             :    {
   56128           0 :       SgOmpNumTeamsClause* testPointer = (SgOmpNumTeamsClause*)(SgOmpNumTeamsClause::pools.back());
   56129           0 :       unsigned long localIndex = SgOmpNumTeamsClause::pool_size - 1;
   56130           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   56131             :          {
   56132           0 :            localIndex--;
   56133             :          }
   56134           0 :       return (localIndex + SgOmpNumTeamsClause::pool_size * (SgOmpNumTeamsClause::pools.size()-1));
   56135             :    }
   56136             : 
   56137             : //############################################################################
   56138             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   56139             :  * memory pool and initializes the data member in class SgOmpNumTeamsClauseStroageClass
   56140             :  * from its counterpart of SgOmpNumTeamsClause. The return value is just for checking, 
   56141             :  * that the whole StorageClassArray is initialized!
   56142             :  */
   56143             : unsigned long
   56144           0 : SgOmpNumTeamsClause::initializeStorageClassArray( SgOmpNumTeamsClauseStorageClass *storageArray )
   56145             :    {
   56146           0 :      unsigned long storageCounter = 0;
   56147           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpNumTeamsClause::pools.begin();
   56148           0 :      SgOmpNumTeamsClause* pointer = NULL;
   56149           0 :      while ( block != SgOmpNumTeamsClause::pools.end() ) {
   56150           0 :           pointer = (SgOmpNumTeamsClause*) (*block);
   56151           0 :           for ( unsigned i = 0; i < SgOmpNumTeamsClause::pool_size; ++i ) {
   56152           0 :                if ( pointer->get_freepointer() != NULL ) {
   56153           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   56154           0 :                  storageArray++;
   56155           0 :                  storageCounter++;
   56156             :                }
   56157           0 :                pointer++;
   56158             :              }
   56159           0 :            block++;
   56160             :         }
   56161           0 :      return storageCounter;
   56162             :    }
   56163             : 
   56164             : /* #line 56165 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   56165             : 
   56166             : 
   56167             : 
   56168             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   56169             : 
   56170             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   56171             : 
   56172             : //############################################################################
   56173             : /* JH (02/02/2006) Constructor of the IR node SgOmpThreadLimitClause that takes its 
   56174             :  * corresponding StorageClass as parameter
   56175             :  */
   56176           0 : SgOmpThreadLimitClause :: SgOmpThreadLimitClause ( const SgOmpThreadLimitClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   56177             :    {
   56178             : 
   56179             : 
   56180             : /* #line 56181 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   56181             : 
   56182           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   56183             : 
   56184             : 
   56185             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   56186             : 
   56187             : 
   56188           0 :    }
   56189             : 
   56190             : //############################################################################
   56191             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   56192             :  * within the working AST. 
   56193             :  */
   56194           0 : SgOmpThreadLimitClause * SgOmpThreadLimitClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   56195           0 :      SgOmpThreadLimitClause* returnPointer = NULL;
   56196           0 :      if ( globalIndex != 0 )
   56197             :         {
   56198             : 
   56199             : #if FILE_IO_EXTRA_CHECK
   56200           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpThreadLimitClause ) ) <= globalIndex ) ;
   56201           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpThreadLimitClause + 1 ) ) );
   56202             : #endif
   56203           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpThreadLimitClause )  
   56204           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpThreadLimitClause );
   56205           0 :           unsigned long positionInPool = localIndex % SgOmpThreadLimitClause::pool_size;
   56206           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpThreadLimitClause::pool_size;
   56207             : 
   56208             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   56209             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   56210             : 
   56211           0 :           returnPointer = &( ( (SgOmpThreadLimitClause*)(SgOmpThreadLimitClause::pools[memoryBlock]) ) [positionInPool]) ;
   56212             : 
   56213           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   56214             :         }
   56215           0 :      return returnPointer ;
   56216             :    }
   56217             : 
   56218             : //############################################################################
   56219             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   56220             :   for the AST with the index astIndex
   56221             : */
   56222           0 : SgOmpThreadLimitClause * SgOmpThreadLimitClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   56223           0 :      SgOmpThreadLimitClause* returnPointer = NULL;
   56224           0 :      if ( globalIndex != 0 )
   56225             :         {
   56226             : 
   56227             : #if FILE_IO_EXTRA_CHECK
   56228           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpThreadLimitClause ) ) <= globalIndex ) ;
   56229           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpThreadLimitClause + 1 ) ) );
   56230             : #endif
   56231           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpThreadLimitClause )
   56232           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpThreadLimitClause );
   56233           0 :           unsigned long positionInPool = localIndex % SgOmpThreadLimitClause::pool_size ;
   56234           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpThreadLimitClause::pool_size ;
   56235             : 
   56236             : #if FILE_IO_EXTRA_CHECK
   56237             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   56238             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   56239             : #endif
   56240             : 
   56241           0 :           returnPointer = &( ( (SgOmpThreadLimitClause*)(SgOmpThreadLimitClause::pools[memoryBlock]) ) [positionInPool]) ;
   56242             : 
   56243             : #if FILE_IO_EXTRA_CHECK
   56244           0 :           assert ( returnPointer != NULL ) ;
   56245             : #endif
   56246             :         }
   56247           0 :      return returnPointer ;
   56248             :    }
   56249             : 
   56250             : //############################################################################
   56251             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   56252             :  * pool size! We set for every valid object in the memory pool the freepointer
   56253             :  * to the global index and increase the global index afterwards. For all the 
   56254             :  * invalid objects (means address ranges within the memory pool that were not
   56255             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   56256             :  * distinguish valid from invalid objects! 
   56257             :  */
   56258             : unsigned long
   56259           5 : SgOmpThreadLimitClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   56260             :    {
   56261           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   56262           5 :      SgOmpThreadLimitClause* pointer = NULL;
   56263           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   56264           5 :      std::vector < unsigned char* > :: const_iterator block;
   56265           5 :      for ( block = SgOmpThreadLimitClause::pools.begin(); block != SgOmpThreadLimitClause::pools.end() ; ++block )
   56266             :         {
   56267           0 :           pointer = (SgOmpThreadLimitClause*)(*block);
   56268           0 :           for (unsigned i = 0; i < SgOmpThreadLimitClause::pool_size; ++i )
   56269             :              {
   56270             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   56271             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   56272             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   56273             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   56274             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   56275             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   56276             :             // properly; so this will have to be checked next.
   56277             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   56278             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   56279           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   56280             :                   {
   56281           0 :                     pointer[i].set_freepointer((SgOmpThreadLimitClause*)(globalIndex));
   56282           0 :                     globalIndex++;
   56283             :                   }
   56284             :                else
   56285             :                   {
   56286           0 :                     pointer[i].set_freepointer(NULL);
   56287             :                   }
   56288             :               }
   56289             :         }
   56290           5 :      return globalIndex;
   56291             :    }
   56292             : 
   56293             : //############################################################################
   56294             : // JH (01/14/2006)
   56295             : void
   56296           5 : SgOmpThreadLimitClause::resetValidFreepointers( )
   56297             :    {
   56298           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   56299           5 :      SgOmpThreadLimitClause* pointer = NULL;
   56300           5 :      std::vector < unsigned char* > :: const_iterator block;
   56301           5 :      SgOmpThreadLimitClause* pointerOfLinkedList = NULL;
   56302           5 :      for ( block = SgOmpThreadLimitClause::pools.begin(); block != SgOmpThreadLimitClause::pools.end() ; ++block )
   56303             :         {
   56304           0 :           pointer = (SgOmpThreadLimitClause*)(*block);
   56305           0 :           for (unsigned i = 0; i < SgOmpThreadLimitClause::pool_size; ++i )
   56306             :              {
   56307             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   56308             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   56309             :             // memory blocks!.
   56310           0 :                if ( pointer[i].get_freepointer() != NULL )
   56311             :                   {
   56312           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   56313             :                   }
   56314             :                else
   56315             :                   {
   56316           0 :                     if ( pointerOfLinkedList == NULL )
   56317             :                        {
   56318           0 :                          SgOmpThreadLimitClause::next_node = &(pointer[i]);
   56319             :                        }
   56320             :                     else
   56321             :                        {
   56322             :                       // printf ("In SgOmpThreadLimitClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   56323           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   56324             :                        }
   56325             :                     pointerOfLinkedList = &(pointer[i]);
   56326             :                   }
   56327             :               }
   56328             :         }
   56329             : 
   56330           5 :      if ( pointerOfLinkedList != NULL )
   56331             :         {
   56332             :        // printf ("In SgOmpThreadLimitClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   56333           0 :           pointerOfLinkedList->set_freepointer(NULL);
   56334             :        // DQ (6/6/2010): Temporary debugging...
   56335             :        //   ROSE_ASSERT(false);
   56336             :         }
   56337             : 
   56338           5 :      return ;
   56339             :    }
   56340             : 
   56341             : //############################################################################
   56342             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   56343             :  * within the memory pool and resets the freepointers, in order to achieve a 
   56344             :  * linked list, that has no jumps and starts at the beginning! This function 
   56345             :  * does not extend the memory pool, since we do not delete any memory blocks,
   56346             :  * but delete the valid objects.  
   56347             :  */
   56348             : void
   56349           0 : SgOmpThreadLimitClause::clearMemoryPool( )
   56350             :    {
   56351             :   // printf ("Inside of SgOmpThreadLimitClause::clearMemoryPool() \n");
   56352             : 
   56353           0 :      SgOmpThreadLimitClause* pointer = NULL, *tempPointer = NULL;
   56354           0 :      std::vector < unsigned char* > :: const_iterator block;
   56355           0 :      if ( SgOmpThreadLimitClause::pools.empty() == false )
   56356             :         {
   56357           0 :           block = SgOmpThreadLimitClause::pools.begin() ;
   56358           0 :           SgOmpThreadLimitClause::next_node = (SgOmpThreadLimitClause*) (*block);
   56359             : 
   56360           0 :           while ( block != SgOmpThreadLimitClause::pools.end() )
   56361             :              {
   56362           0 :                pointer = (SgOmpThreadLimitClause*) (*block);
   56363           0 :                if ( tempPointer != NULL )
   56364             :                   {
   56365           0 :                     tempPointer->set_freepointer(pointer);
   56366             :                   }
   56367           0 :                for (unsigned i = 0; i < SgOmpThreadLimitClause::pool_size - 1; ++i)
   56368             :                   {
   56369           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   56370             :                   }
   56371           0 :                 pointer[SgOmpThreadLimitClause::pool_size-1].set_freepointer(NULL);
   56372           0 :                 tempPointer = &(pointer[SgOmpThreadLimitClause::pool_size-1]);
   56373           0 :                 ++block;
   56374             :              }
   56375             :         }
   56376           0 :    }
   56377             : 
   56378           5 : void SgOmpThreadLimitClause::deleteMemoryPool() {
   56379           5 :   for (auto p: SgOmpThreadLimitClause::pools) {
   56380           0 :     ROSE_FREE(p);
   56381             :   }
   56382           5 :   SgOmpThreadLimitClause::next_node = nullptr;
   56383           5 :   SgOmpThreadLimitClause::pools.clear();
   56384           5 : }
   56385             : 
   56386             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   56387             : //                 reading multiple binary files to for a single AST.
   56388             : /////////// new version ////////////////////////////////
   56389             : //############################################################################
   56390             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   56391             : void
   56392           2 : SgOmpThreadLimitClause::extendMemoryPoolForFileIO( )
   56393             :   {
   56394           2 :     size_t blockIndex = SgOmpThreadLimitClause::pools.size();
   56395           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadLimitClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadLimitClause);
   56396             : 
   56397           2 :     while ( (blockIndex * SgOmpThreadLimitClause::pool_size) < newPoolSize)
   56398             :       {
   56399             : #if ROSE_ALLOC_TRACE
   56400             :         if (blockIndex > 0) {
   56401             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadLimitClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadLimitClause) = %" PRIuPTR " SgOmpThreadLimitClause::pool_size = %d \n",
   56402             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadLimitClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadLimitClause),SgOmpThreadLimitClause::pool_size);
   56403             :         }
   56404             : #endif
   56405             : 
   56406           0 :         SgOmpThreadLimitClause * pointer = (SgOmpThreadLimitClause*) ROSE_MALLOC ( SgOmpThreadLimitClause::pool_size * sizeof(SgOmpThreadLimitClause) );
   56407           0 :         assert( pointer != NULL );
   56408             : #if ROSE_ALLOC_MEMSET == 1
   56409             :         memset(pointer, 0x00, SgOmpThreadLimitClause::pool_size * sizeof(SgOmpThreadLimitClause));
   56410             : #elif ROSE_ALLOC_MEMSET == 2
   56411             :         memset(pointer, 0xCC, SgOmpThreadLimitClause::pool_size * sizeof(SgOmpThreadLimitClause));
   56412             : #endif
   56413           0 :         SgOmpThreadLimitClause::pools.push_back( (unsigned char*)(pointer) );
   56414           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpThreadLimitClause::pool_size * sizeof(SgOmpThreadLimitClause), V_SgOmpThreadLimitClause ) );
   56415             : 
   56416           0 :         if ( SgOmpThreadLimitClause::next_node != NULL ) {
   56417           0 :           if ( blockIndex > 0 ) {
   56418           0 :             SgOmpThreadLimitClause * blkptr = (SgOmpThreadLimitClause*)(SgOmpThreadLimitClause::pools[blockIndex-1]);
   56419           0 :             blkptr[ SgOmpThreadLimitClause::pool_size - 1 ].set_freepointer(pointer);
   56420             :           }
   56421             :         } else {
   56422           0 :           SgOmpThreadLimitClause::next_node = pointer;
   56423             :         }
   56424             : 
   56425           0 :         for (unsigned i = 0; i < SgOmpThreadLimitClause::pool_size-1; ++i)
   56426             :            {
   56427           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   56428             :            }
   56429           0 :         pointer[ SgOmpThreadLimitClause::pool_size -1 ].set_freepointer(NULL);
   56430             : 
   56431           0 :         blockIndex++;
   56432             :       }
   56433           2 :   }
   56434             : 
   56435             : //############################################################################
   56436             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   56437             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   56438             :  * not compressed. However, that stuff is not yet implemented! 
   56439             :  */
   56440             : unsigned long
   56441           0 : SgOmpThreadLimitClause::getNumberOfLastValidPointer()
   56442             :    {
   56443           0 :       SgOmpThreadLimitClause* testPointer = (SgOmpThreadLimitClause*)(SgOmpThreadLimitClause::pools.back());
   56444           0 :       unsigned long localIndex = SgOmpThreadLimitClause::pool_size - 1;
   56445           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   56446             :          {
   56447           0 :            localIndex--;
   56448             :          }
   56449           0 :       return (localIndex + SgOmpThreadLimitClause::pool_size * (SgOmpThreadLimitClause::pools.size()-1));
   56450             :    }
   56451             : 
   56452             : //############################################################################
   56453             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   56454             :  * memory pool and initializes the data member in class SgOmpThreadLimitClauseStroageClass
   56455             :  * from its counterpart of SgOmpThreadLimitClause. The return value is just for checking, 
   56456             :  * that the whole StorageClassArray is initialized!
   56457             :  */
   56458             : unsigned long
   56459           0 : SgOmpThreadLimitClause::initializeStorageClassArray( SgOmpThreadLimitClauseStorageClass *storageArray )
   56460             :    {
   56461           0 :      unsigned long storageCounter = 0;
   56462           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpThreadLimitClause::pools.begin();
   56463           0 :      SgOmpThreadLimitClause* pointer = NULL;
   56464           0 :      while ( block != SgOmpThreadLimitClause::pools.end() ) {
   56465           0 :           pointer = (SgOmpThreadLimitClause*) (*block);
   56466           0 :           for ( unsigned i = 0; i < SgOmpThreadLimitClause::pool_size; ++i ) {
   56467           0 :                if ( pointer->get_freepointer() != NULL ) {
   56468           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   56469           0 :                  storageArray++;
   56470           0 :                  storageCounter++;
   56471             :                }
   56472           0 :                pointer++;
   56473             :              }
   56474           0 :            block++;
   56475             :         }
   56476           0 :      return storageCounter;
   56477             :    }
   56478             : 
   56479             : /* #line 56480 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   56480             : 
   56481             : 
   56482             : 
   56483             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   56484             : 
   56485             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   56486             : 
   56487             : //############################################################################
   56488             : /* JH (02/02/2006) Constructor of the IR node SgOmpDeviceClause that takes its 
   56489             :  * corresponding StorageClass as parameter
   56490             :  */
   56491           0 : SgOmpDeviceClause :: SgOmpDeviceClause ( const SgOmpDeviceClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   56492             :    {
   56493             : 
   56494             : 
   56495             : /* #line 56496 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   56496             : 
   56497           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   56498           0 :      p_modifier = storageSource.storageOf_modifier ;
   56499             : 
   56500             : 
   56501             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   56502             : 
   56503             : 
   56504           0 :    }
   56505             : 
   56506             : //############################################################################
   56507             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   56508             :  * within the working AST. 
   56509             :  */
   56510           0 : SgOmpDeviceClause * SgOmpDeviceClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   56511           0 :      SgOmpDeviceClause* returnPointer = NULL;
   56512           0 :      if ( globalIndex != 0 )
   56513             :         {
   56514             : 
   56515             : #if FILE_IO_EXTRA_CHECK
   56516           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDeviceClause ) ) <= globalIndex ) ;
   56517           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDeviceClause + 1 ) ) );
   56518             : #endif
   56519           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDeviceClause )  
   56520           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDeviceClause );
   56521           0 :           unsigned long positionInPool = localIndex % SgOmpDeviceClause::pool_size;
   56522           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDeviceClause::pool_size;
   56523             : 
   56524             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   56525             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   56526             : 
   56527           0 :           returnPointer = &( ( (SgOmpDeviceClause*)(SgOmpDeviceClause::pools[memoryBlock]) ) [positionInPool]) ;
   56528             : 
   56529           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   56530             :         }
   56531           0 :      return returnPointer ;
   56532             :    }
   56533             : 
   56534             : //############################################################################
   56535             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   56536             :   for the AST with the index astIndex
   56537             : */
   56538           0 : SgOmpDeviceClause * SgOmpDeviceClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   56539           0 :      SgOmpDeviceClause* returnPointer = NULL;
   56540           0 :      if ( globalIndex != 0 )
   56541             :         {
   56542             : 
   56543             : #if FILE_IO_EXTRA_CHECK
   56544           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDeviceClause ) ) <= globalIndex ) ;
   56545           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDeviceClause + 1 ) ) );
   56546             : #endif
   56547           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDeviceClause )
   56548           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDeviceClause );
   56549           0 :           unsigned long positionInPool = localIndex % SgOmpDeviceClause::pool_size ;
   56550           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDeviceClause::pool_size ;
   56551             : 
   56552             : #if FILE_IO_EXTRA_CHECK
   56553             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   56554             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   56555             : #endif
   56556             : 
   56557           0 :           returnPointer = &( ( (SgOmpDeviceClause*)(SgOmpDeviceClause::pools[memoryBlock]) ) [positionInPool]) ;
   56558             : 
   56559             : #if FILE_IO_EXTRA_CHECK
   56560           0 :           assert ( returnPointer != NULL ) ;
   56561             : #endif
   56562             :         }
   56563           0 :      return returnPointer ;
   56564             :    }
   56565             : 
   56566             : //############################################################################
   56567             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   56568             :  * pool size! We set for every valid object in the memory pool the freepointer
   56569             :  * to the global index and increase the global index afterwards. For all the 
   56570             :  * invalid objects (means address ranges within the memory pool that were not
   56571             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   56572             :  * distinguish valid from invalid objects! 
   56573             :  */
   56574             : unsigned long
   56575           5 : SgOmpDeviceClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   56576             :    {
   56577           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   56578           5 :      SgOmpDeviceClause* pointer = NULL;
   56579           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   56580           5 :      std::vector < unsigned char* > :: const_iterator block;
   56581           5 :      for ( block = SgOmpDeviceClause::pools.begin(); block != SgOmpDeviceClause::pools.end() ; ++block )
   56582             :         {
   56583           0 :           pointer = (SgOmpDeviceClause*)(*block);
   56584           0 :           for (unsigned i = 0; i < SgOmpDeviceClause::pool_size; ++i )
   56585             :              {
   56586             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   56587             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   56588             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   56589             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   56590             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   56591             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   56592             :             // properly; so this will have to be checked next.
   56593             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   56594             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   56595           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   56596             :                   {
   56597           0 :                     pointer[i].set_freepointer((SgOmpDeviceClause*)(globalIndex));
   56598           0 :                     globalIndex++;
   56599             :                   }
   56600             :                else
   56601             :                   {
   56602           0 :                     pointer[i].set_freepointer(NULL);
   56603             :                   }
   56604             :               }
   56605             :         }
   56606           5 :      return globalIndex;
   56607             :    }
   56608             : 
   56609             : //############################################################################
   56610             : // JH (01/14/2006)
   56611             : void
   56612           5 : SgOmpDeviceClause::resetValidFreepointers( )
   56613             :    {
   56614           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   56615           5 :      SgOmpDeviceClause* pointer = NULL;
   56616           5 :      std::vector < unsigned char* > :: const_iterator block;
   56617           5 :      SgOmpDeviceClause* pointerOfLinkedList = NULL;
   56618           5 :      for ( block = SgOmpDeviceClause::pools.begin(); block != SgOmpDeviceClause::pools.end() ; ++block )
   56619             :         {
   56620           0 :           pointer = (SgOmpDeviceClause*)(*block);
   56621           0 :           for (unsigned i = 0; i < SgOmpDeviceClause::pool_size; ++i )
   56622             :              {
   56623             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   56624             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   56625             :             // memory blocks!.
   56626           0 :                if ( pointer[i].get_freepointer() != NULL )
   56627             :                   {
   56628           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   56629             :                   }
   56630             :                else
   56631             :                   {
   56632           0 :                     if ( pointerOfLinkedList == NULL )
   56633             :                        {
   56634           0 :                          SgOmpDeviceClause::next_node = &(pointer[i]);
   56635             :                        }
   56636             :                     else
   56637             :                        {
   56638             :                       // printf ("In SgOmpDeviceClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   56639           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   56640             :                        }
   56641             :                     pointerOfLinkedList = &(pointer[i]);
   56642             :                   }
   56643             :               }
   56644             :         }
   56645             : 
   56646           5 :      if ( pointerOfLinkedList != NULL )
   56647             :         {
   56648             :        // printf ("In SgOmpDeviceClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   56649           0 :           pointerOfLinkedList->set_freepointer(NULL);
   56650             :        // DQ (6/6/2010): Temporary debugging...
   56651             :        //   ROSE_ASSERT(false);
   56652             :         }
   56653             : 
   56654           5 :      return ;
   56655             :    }
   56656             : 
   56657             : //############################################################################
   56658             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   56659             :  * within the memory pool and resets the freepointers, in order to achieve a 
   56660             :  * linked list, that has no jumps and starts at the beginning! This function 
   56661             :  * does not extend the memory pool, since we do not delete any memory blocks,
   56662             :  * but delete the valid objects.  
   56663             :  */
   56664             : void
   56665           0 : SgOmpDeviceClause::clearMemoryPool( )
   56666             :    {
   56667             :   // printf ("Inside of SgOmpDeviceClause::clearMemoryPool() \n");
   56668             : 
   56669           0 :      SgOmpDeviceClause* pointer = NULL, *tempPointer = NULL;
   56670           0 :      std::vector < unsigned char* > :: const_iterator block;
   56671           0 :      if ( SgOmpDeviceClause::pools.empty() == false )
   56672             :         {
   56673           0 :           block = SgOmpDeviceClause::pools.begin() ;
   56674           0 :           SgOmpDeviceClause::next_node = (SgOmpDeviceClause*) (*block);
   56675             : 
   56676           0 :           while ( block != SgOmpDeviceClause::pools.end() )
   56677             :              {
   56678           0 :                pointer = (SgOmpDeviceClause*) (*block);
   56679           0 :                if ( tempPointer != NULL )
   56680             :                   {
   56681           0 :                     tempPointer->set_freepointer(pointer);
   56682             :                   }
   56683           0 :                for (unsigned i = 0; i < SgOmpDeviceClause::pool_size - 1; ++i)
   56684             :                   {
   56685           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   56686             :                   }
   56687           0 :                 pointer[SgOmpDeviceClause::pool_size-1].set_freepointer(NULL);
   56688           0 :                 tempPointer = &(pointer[SgOmpDeviceClause::pool_size-1]);
   56689           0 :                 ++block;
   56690             :              }
   56691             :         }
   56692           0 :    }
   56693             : 
   56694           5 : void SgOmpDeviceClause::deleteMemoryPool() {
   56695           5 :   for (auto p: SgOmpDeviceClause::pools) {
   56696           0 :     ROSE_FREE(p);
   56697             :   }
   56698           5 :   SgOmpDeviceClause::next_node = nullptr;
   56699           5 :   SgOmpDeviceClause::pools.clear();
   56700           5 : }
   56701             : 
   56702             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   56703             : //                 reading multiple binary files to for a single AST.
   56704             : /////////// new version ////////////////////////////////
   56705             : //############################################################################
   56706             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   56707             : void
   56708           2 : SgOmpDeviceClause::extendMemoryPoolForFileIO( )
   56709             :   {
   56710           2 :     size_t blockIndex = SgOmpDeviceClause::pools.size();
   56711           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeviceClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeviceClause);
   56712             : 
   56713           2 :     while ( (blockIndex * SgOmpDeviceClause::pool_size) < newPoolSize)
   56714             :       {
   56715             : #if ROSE_ALLOC_TRACE
   56716             :         if (blockIndex > 0) {
   56717             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeviceClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeviceClause) = %" PRIuPTR " SgOmpDeviceClause::pool_size = %d \n",
   56718             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeviceClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeviceClause),SgOmpDeviceClause::pool_size);
   56719             :         }
   56720             : #endif
   56721             : 
   56722           0 :         SgOmpDeviceClause * pointer = (SgOmpDeviceClause*) ROSE_MALLOC ( SgOmpDeviceClause::pool_size * sizeof(SgOmpDeviceClause) );
   56723           0 :         assert( pointer != NULL );
   56724             : #if ROSE_ALLOC_MEMSET == 1
   56725             :         memset(pointer, 0x00, SgOmpDeviceClause::pool_size * sizeof(SgOmpDeviceClause));
   56726             : #elif ROSE_ALLOC_MEMSET == 2
   56727             :         memset(pointer, 0xCC, SgOmpDeviceClause::pool_size * sizeof(SgOmpDeviceClause));
   56728             : #endif
   56729           0 :         SgOmpDeviceClause::pools.push_back( (unsigned char*)(pointer) );
   56730           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDeviceClause::pool_size * sizeof(SgOmpDeviceClause), V_SgOmpDeviceClause ) );
   56731             : 
   56732           0 :         if ( SgOmpDeviceClause::next_node != NULL ) {
   56733           0 :           if ( blockIndex > 0 ) {
   56734           0 :             SgOmpDeviceClause * blkptr = (SgOmpDeviceClause*)(SgOmpDeviceClause::pools[blockIndex-1]);
   56735           0 :             blkptr[ SgOmpDeviceClause::pool_size - 1 ].set_freepointer(pointer);
   56736             :           }
   56737             :         } else {
   56738           0 :           SgOmpDeviceClause::next_node = pointer;
   56739             :         }
   56740             : 
   56741           0 :         for (unsigned i = 0; i < SgOmpDeviceClause::pool_size-1; ++i)
   56742             :            {
   56743           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   56744             :            }
   56745           0 :         pointer[ SgOmpDeviceClause::pool_size -1 ].set_freepointer(NULL);
   56746             : 
   56747           0 :         blockIndex++;
   56748             :       }
   56749           2 :   }
   56750             : 
   56751             : //############################################################################
   56752             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   56753             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   56754             :  * not compressed. However, that stuff is not yet implemented! 
   56755             :  */
   56756             : unsigned long
   56757           0 : SgOmpDeviceClause::getNumberOfLastValidPointer()
   56758             :    {
   56759           0 :       SgOmpDeviceClause* testPointer = (SgOmpDeviceClause*)(SgOmpDeviceClause::pools.back());
   56760           0 :       unsigned long localIndex = SgOmpDeviceClause::pool_size - 1;
   56761           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   56762             :          {
   56763           0 :            localIndex--;
   56764             :          }
   56765           0 :       return (localIndex + SgOmpDeviceClause::pool_size * (SgOmpDeviceClause::pools.size()-1));
   56766             :    }
   56767             : 
   56768             : //############################################################################
   56769             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   56770             :  * memory pool and initializes the data member in class SgOmpDeviceClauseStroageClass
   56771             :  * from its counterpart of SgOmpDeviceClause. The return value is just for checking, 
   56772             :  * that the whole StorageClassArray is initialized!
   56773             :  */
   56774             : unsigned long
   56775           0 : SgOmpDeviceClause::initializeStorageClassArray( SgOmpDeviceClauseStorageClass *storageArray )
   56776             :    {
   56777           0 :      unsigned long storageCounter = 0;
   56778           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDeviceClause::pools.begin();
   56779           0 :      SgOmpDeviceClause* pointer = NULL;
   56780           0 :      while ( block != SgOmpDeviceClause::pools.end() ) {
   56781           0 :           pointer = (SgOmpDeviceClause*) (*block);
   56782           0 :           for ( unsigned i = 0; i < SgOmpDeviceClause::pool_size; ++i ) {
   56783           0 :                if ( pointer->get_freepointer() != NULL ) {
   56784           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   56785           0 :                  storageArray++;
   56786           0 :                  storageCounter++;
   56787             :                }
   56788           0 :                pointer++;
   56789             :              }
   56790           0 :            block++;
   56791             :         }
   56792           0 :      return storageCounter;
   56793             :    }
   56794             : 
   56795             : /* #line 56796 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   56796             : 
   56797             : 
   56798             : 
   56799             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   56800             : 
   56801             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   56802             : 
   56803             : //############################################################################
   56804             : /* JH (02/02/2006) Constructor of the IR node SgOmpHintClause that takes its 
   56805             :  * corresponding StorageClass as parameter
   56806             :  */
   56807           0 : SgOmpHintClause :: SgOmpHintClause ( const SgOmpHintClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   56808             :    {
   56809             : 
   56810             : 
   56811             : /* #line 56812 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   56812             : 
   56813           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   56814             : 
   56815             : 
   56816             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   56817             : 
   56818             : 
   56819           0 :    }
   56820             : 
   56821             : //############################################################################
   56822             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   56823             :  * within the working AST. 
   56824             :  */
   56825           0 : SgOmpHintClause * SgOmpHintClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   56826           0 :      SgOmpHintClause* returnPointer = NULL;
   56827           0 :      if ( globalIndex != 0 )
   56828             :         {
   56829             : 
   56830             : #if FILE_IO_EXTRA_CHECK
   56831           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpHintClause ) ) <= globalIndex ) ;
   56832           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpHintClause + 1 ) ) );
   56833             : #endif
   56834           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpHintClause )  
   56835           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpHintClause );
   56836           0 :           unsigned long positionInPool = localIndex % SgOmpHintClause::pool_size;
   56837           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpHintClause::pool_size;
   56838             : 
   56839             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   56840             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   56841             : 
   56842           0 :           returnPointer = &( ( (SgOmpHintClause*)(SgOmpHintClause::pools[memoryBlock]) ) [positionInPool]) ;
   56843             : 
   56844           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   56845             :         }
   56846           0 :      return returnPointer ;
   56847             :    }
   56848             : 
   56849             : //############################################################################
   56850             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   56851             :   for the AST with the index astIndex
   56852             : */
   56853           0 : SgOmpHintClause * SgOmpHintClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   56854           0 :      SgOmpHintClause* returnPointer = NULL;
   56855           0 :      if ( globalIndex != 0 )
   56856             :         {
   56857             : 
   56858             : #if FILE_IO_EXTRA_CHECK
   56859           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpHintClause ) ) <= globalIndex ) ;
   56860           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpHintClause + 1 ) ) );
   56861             : #endif
   56862           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpHintClause )
   56863           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpHintClause );
   56864           0 :           unsigned long positionInPool = localIndex % SgOmpHintClause::pool_size ;
   56865           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpHintClause::pool_size ;
   56866             : 
   56867             : #if FILE_IO_EXTRA_CHECK
   56868             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   56869             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   56870             : #endif
   56871             : 
   56872           0 :           returnPointer = &( ( (SgOmpHintClause*)(SgOmpHintClause::pools[memoryBlock]) ) [positionInPool]) ;
   56873             : 
   56874             : #if FILE_IO_EXTRA_CHECK
   56875           0 :           assert ( returnPointer != NULL ) ;
   56876             : #endif
   56877             :         }
   56878           0 :      return returnPointer ;
   56879             :    }
   56880             : 
   56881             : //############################################################################
   56882             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   56883             :  * pool size! We set for every valid object in the memory pool the freepointer
   56884             :  * to the global index and increase the global index afterwards. For all the 
   56885             :  * invalid objects (means address ranges within the memory pool that were not
   56886             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   56887             :  * distinguish valid from invalid objects! 
   56888             :  */
   56889             : unsigned long
   56890           5 : SgOmpHintClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   56891             :    {
   56892           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   56893           5 :      SgOmpHintClause* pointer = NULL;
   56894           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   56895           5 :      std::vector < unsigned char* > :: const_iterator block;
   56896           5 :      for ( block = SgOmpHintClause::pools.begin(); block != SgOmpHintClause::pools.end() ; ++block )
   56897             :         {
   56898           0 :           pointer = (SgOmpHintClause*)(*block);
   56899           0 :           for (unsigned i = 0; i < SgOmpHintClause::pool_size; ++i )
   56900             :              {
   56901             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   56902             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   56903             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   56904             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   56905             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   56906             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   56907             :             // properly; so this will have to be checked next.
   56908             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   56909             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   56910           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   56911             :                   {
   56912           0 :                     pointer[i].set_freepointer((SgOmpHintClause*)(globalIndex));
   56913           0 :                     globalIndex++;
   56914             :                   }
   56915             :                else
   56916             :                   {
   56917           0 :                     pointer[i].set_freepointer(NULL);
   56918             :                   }
   56919             :               }
   56920             :         }
   56921           5 :      return globalIndex;
   56922             :    }
   56923             : 
   56924             : //############################################################################
   56925             : // JH (01/14/2006)
   56926             : void
   56927           5 : SgOmpHintClause::resetValidFreepointers( )
   56928             :    {
   56929           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   56930           5 :      SgOmpHintClause* pointer = NULL;
   56931           5 :      std::vector < unsigned char* > :: const_iterator block;
   56932           5 :      SgOmpHintClause* pointerOfLinkedList = NULL;
   56933           5 :      for ( block = SgOmpHintClause::pools.begin(); block != SgOmpHintClause::pools.end() ; ++block )
   56934             :         {
   56935           0 :           pointer = (SgOmpHintClause*)(*block);
   56936           0 :           for (unsigned i = 0; i < SgOmpHintClause::pool_size; ++i )
   56937             :              {
   56938             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   56939             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   56940             :             // memory blocks!.
   56941           0 :                if ( pointer[i].get_freepointer() != NULL )
   56942             :                   {
   56943           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   56944             :                   }
   56945             :                else
   56946             :                   {
   56947           0 :                     if ( pointerOfLinkedList == NULL )
   56948             :                        {
   56949           0 :                          SgOmpHintClause::next_node = &(pointer[i]);
   56950             :                        }
   56951             :                     else
   56952             :                        {
   56953             :                       // printf ("In SgOmpHintClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   56954           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   56955             :                        }
   56956             :                     pointerOfLinkedList = &(pointer[i]);
   56957             :                   }
   56958             :               }
   56959             :         }
   56960             : 
   56961           5 :      if ( pointerOfLinkedList != NULL )
   56962             :         {
   56963             :        // printf ("In SgOmpHintClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   56964           0 :           pointerOfLinkedList->set_freepointer(NULL);
   56965             :        // DQ (6/6/2010): Temporary debugging...
   56966             :        //   ROSE_ASSERT(false);
   56967             :         }
   56968             : 
   56969           5 :      return ;
   56970             :    }
   56971             : 
   56972             : //############################################################################
   56973             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   56974             :  * within the memory pool and resets the freepointers, in order to achieve a 
   56975             :  * linked list, that has no jumps and starts at the beginning! This function 
   56976             :  * does not extend the memory pool, since we do not delete any memory blocks,
   56977             :  * but delete the valid objects.  
   56978             :  */
   56979             : void
   56980           0 : SgOmpHintClause::clearMemoryPool( )
   56981             :    {
   56982             :   // printf ("Inside of SgOmpHintClause::clearMemoryPool() \n");
   56983             : 
   56984           0 :      SgOmpHintClause* pointer = NULL, *tempPointer = NULL;
   56985           0 :      std::vector < unsigned char* > :: const_iterator block;
   56986           0 :      if ( SgOmpHintClause::pools.empty() == false )
   56987             :         {
   56988           0 :           block = SgOmpHintClause::pools.begin() ;
   56989           0 :           SgOmpHintClause::next_node = (SgOmpHintClause*) (*block);
   56990             : 
   56991           0 :           while ( block != SgOmpHintClause::pools.end() )
   56992             :              {
   56993           0 :                pointer = (SgOmpHintClause*) (*block);
   56994           0 :                if ( tempPointer != NULL )
   56995             :                   {
   56996           0 :                     tempPointer->set_freepointer(pointer);
   56997             :                   }
   56998           0 :                for (unsigned i = 0; i < SgOmpHintClause::pool_size - 1; ++i)
   56999             :                   {
   57000           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   57001             :                   }
   57002           0 :                 pointer[SgOmpHintClause::pool_size-1].set_freepointer(NULL);
   57003           0 :                 tempPointer = &(pointer[SgOmpHintClause::pool_size-1]);
   57004           0 :                 ++block;
   57005             :              }
   57006             :         }
   57007           0 :    }
   57008             : 
   57009           5 : void SgOmpHintClause::deleteMemoryPool() {
   57010           5 :   for (auto p: SgOmpHintClause::pools) {
   57011           0 :     ROSE_FREE(p);
   57012             :   }
   57013           5 :   SgOmpHintClause::next_node = nullptr;
   57014           5 :   SgOmpHintClause::pools.clear();
   57015           5 : }
   57016             : 
   57017             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   57018             : //                 reading multiple binary files to for a single AST.
   57019             : /////////// new version ////////////////////////////////
   57020             : //############################################################################
   57021             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   57022             : void
   57023           2 : SgOmpHintClause::extendMemoryPoolForFileIO( )
   57024             :   {
   57025           2 :     size_t blockIndex = SgOmpHintClause::pools.size();
   57026           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpHintClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpHintClause);
   57027             : 
   57028           2 :     while ( (blockIndex * SgOmpHintClause::pool_size) < newPoolSize)
   57029             :       {
   57030             : #if ROSE_ALLOC_TRACE
   57031             :         if (blockIndex > 0) {
   57032             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpHintClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpHintClause) = %" PRIuPTR " SgOmpHintClause::pool_size = %d \n",
   57033             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpHintClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpHintClause),SgOmpHintClause::pool_size);
   57034             :         }
   57035             : #endif
   57036             : 
   57037           0 :         SgOmpHintClause * pointer = (SgOmpHintClause*) ROSE_MALLOC ( SgOmpHintClause::pool_size * sizeof(SgOmpHintClause) );
   57038           0 :         assert( pointer != NULL );
   57039             : #if ROSE_ALLOC_MEMSET == 1
   57040             :         memset(pointer, 0x00, SgOmpHintClause::pool_size * sizeof(SgOmpHintClause));
   57041             : #elif ROSE_ALLOC_MEMSET == 2
   57042             :         memset(pointer, 0xCC, SgOmpHintClause::pool_size * sizeof(SgOmpHintClause));
   57043             : #endif
   57044           0 :         SgOmpHintClause::pools.push_back( (unsigned char*)(pointer) );
   57045           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpHintClause::pool_size * sizeof(SgOmpHintClause), V_SgOmpHintClause ) );
   57046             : 
   57047           0 :         if ( SgOmpHintClause::next_node != NULL ) {
   57048           0 :           if ( blockIndex > 0 ) {
   57049           0 :             SgOmpHintClause * blkptr = (SgOmpHintClause*)(SgOmpHintClause::pools[blockIndex-1]);
   57050           0 :             blkptr[ SgOmpHintClause::pool_size - 1 ].set_freepointer(pointer);
   57051             :           }
   57052             :         } else {
   57053           0 :           SgOmpHintClause::next_node = pointer;
   57054             :         }
   57055             : 
   57056           0 :         for (unsigned i = 0; i < SgOmpHintClause::pool_size-1; ++i)
   57057             :            {
   57058           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   57059             :            }
   57060           0 :         pointer[ SgOmpHintClause::pool_size -1 ].set_freepointer(NULL);
   57061             : 
   57062           0 :         blockIndex++;
   57063             :       }
   57064           2 :   }
   57065             : 
   57066             : //############################################################################
   57067             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   57068             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   57069             :  * not compressed. However, that stuff is not yet implemented! 
   57070             :  */
   57071             : unsigned long
   57072           0 : SgOmpHintClause::getNumberOfLastValidPointer()
   57073             :    {
   57074           0 :       SgOmpHintClause* testPointer = (SgOmpHintClause*)(SgOmpHintClause::pools.back());
   57075           0 :       unsigned long localIndex = SgOmpHintClause::pool_size - 1;
   57076           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   57077             :          {
   57078           0 :            localIndex--;
   57079             :          }
   57080           0 :       return (localIndex + SgOmpHintClause::pool_size * (SgOmpHintClause::pools.size()-1));
   57081             :    }
   57082             : 
   57083             : //############################################################################
   57084             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   57085             :  * memory pool and initializes the data member in class SgOmpHintClauseStroageClass
   57086             :  * from its counterpart of SgOmpHintClause. The return value is just for checking, 
   57087             :  * that the whole StorageClassArray is initialized!
   57088             :  */
   57089             : unsigned long
   57090           0 : SgOmpHintClause::initializeStorageClassArray( SgOmpHintClauseStorageClass *storageArray )
   57091             :    {
   57092           0 :      unsigned long storageCounter = 0;
   57093           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpHintClause::pools.begin();
   57094           0 :      SgOmpHintClause* pointer = NULL;
   57095           0 :      while ( block != SgOmpHintClause::pools.end() ) {
   57096           0 :           pointer = (SgOmpHintClause*) (*block);
   57097           0 :           for ( unsigned i = 0; i < SgOmpHintClause::pool_size; ++i ) {
   57098           0 :                if ( pointer->get_freepointer() != NULL ) {
   57099           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   57100           0 :                  storageArray++;
   57101           0 :                  storageCounter++;
   57102             :                }
   57103           0 :                pointer++;
   57104             :              }
   57105           0 :            block++;
   57106             :         }
   57107           0 :      return storageCounter;
   57108             :    }
   57109             : 
   57110             : /* #line 57111 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   57111             : 
   57112             : 
   57113             : 
   57114             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   57115             : 
   57116             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   57117             : 
   57118             : //############################################################################
   57119             : /* JH (02/02/2006) Constructor of the IR node SgOmpGrainsizeClause that takes its 
   57120             :  * corresponding StorageClass as parameter
   57121             :  */
   57122           0 : SgOmpGrainsizeClause :: SgOmpGrainsizeClause ( const SgOmpGrainsizeClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   57123             :    {
   57124             : 
   57125             : 
   57126             : /* #line 57127 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   57127             : 
   57128           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   57129             : 
   57130             : 
   57131             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   57132             : 
   57133             : 
   57134           0 :    }
   57135             : 
   57136             : //############################################################################
   57137             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   57138             :  * within the working AST. 
   57139             :  */
   57140           0 : SgOmpGrainsizeClause * SgOmpGrainsizeClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   57141           0 :      SgOmpGrainsizeClause* returnPointer = NULL;
   57142           0 :      if ( globalIndex != 0 )
   57143             :         {
   57144             : 
   57145             : #if FILE_IO_EXTRA_CHECK
   57146           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpGrainsizeClause ) ) <= globalIndex ) ;
   57147           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpGrainsizeClause + 1 ) ) );
   57148             : #endif
   57149           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpGrainsizeClause )  
   57150           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpGrainsizeClause );
   57151           0 :           unsigned long positionInPool = localIndex % SgOmpGrainsizeClause::pool_size;
   57152           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpGrainsizeClause::pool_size;
   57153             : 
   57154             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   57155             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   57156             : 
   57157           0 :           returnPointer = &( ( (SgOmpGrainsizeClause*)(SgOmpGrainsizeClause::pools[memoryBlock]) ) [positionInPool]) ;
   57158             : 
   57159           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   57160             :         }
   57161           0 :      return returnPointer ;
   57162             :    }
   57163             : 
   57164             : //############################################################################
   57165             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   57166             :   for the AST with the index astIndex
   57167             : */
   57168           0 : SgOmpGrainsizeClause * SgOmpGrainsizeClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   57169           0 :      SgOmpGrainsizeClause* returnPointer = NULL;
   57170           0 :      if ( globalIndex != 0 )
   57171             :         {
   57172             : 
   57173             : #if FILE_IO_EXTRA_CHECK
   57174           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpGrainsizeClause ) ) <= globalIndex ) ;
   57175           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpGrainsizeClause + 1 ) ) );
   57176             : #endif
   57177           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpGrainsizeClause )
   57178           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpGrainsizeClause );
   57179           0 :           unsigned long positionInPool = localIndex % SgOmpGrainsizeClause::pool_size ;
   57180           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpGrainsizeClause::pool_size ;
   57181             : 
   57182             : #if FILE_IO_EXTRA_CHECK
   57183             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   57184             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   57185             : #endif
   57186             : 
   57187           0 :           returnPointer = &( ( (SgOmpGrainsizeClause*)(SgOmpGrainsizeClause::pools[memoryBlock]) ) [positionInPool]) ;
   57188             : 
   57189             : #if FILE_IO_EXTRA_CHECK
   57190           0 :           assert ( returnPointer != NULL ) ;
   57191             : #endif
   57192             :         }
   57193           0 :      return returnPointer ;
   57194             :    }
   57195             : 
   57196             : //############################################################################
   57197             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   57198             :  * pool size! We set for every valid object in the memory pool the freepointer
   57199             :  * to the global index and increase the global index afterwards. For all the 
   57200             :  * invalid objects (means address ranges within the memory pool that were not
   57201             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   57202             :  * distinguish valid from invalid objects! 
   57203             :  */
   57204             : unsigned long
   57205           5 : SgOmpGrainsizeClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   57206             :    {
   57207           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   57208           5 :      SgOmpGrainsizeClause* pointer = NULL;
   57209           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   57210           5 :      std::vector < unsigned char* > :: const_iterator block;
   57211           5 :      for ( block = SgOmpGrainsizeClause::pools.begin(); block != SgOmpGrainsizeClause::pools.end() ; ++block )
   57212             :         {
   57213           0 :           pointer = (SgOmpGrainsizeClause*)(*block);
   57214           0 :           for (unsigned i = 0; i < SgOmpGrainsizeClause::pool_size; ++i )
   57215             :              {
   57216             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   57217             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   57218             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   57219             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   57220             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   57221             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   57222             :             // properly; so this will have to be checked next.
   57223             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   57224             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   57225           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   57226             :                   {
   57227           0 :                     pointer[i].set_freepointer((SgOmpGrainsizeClause*)(globalIndex));
   57228           0 :                     globalIndex++;
   57229             :                   }
   57230             :                else
   57231             :                   {
   57232           0 :                     pointer[i].set_freepointer(NULL);
   57233             :                   }
   57234             :               }
   57235             :         }
   57236           5 :      return globalIndex;
   57237             :    }
   57238             : 
   57239             : //############################################################################
   57240             : // JH (01/14/2006)
   57241             : void
   57242           5 : SgOmpGrainsizeClause::resetValidFreepointers( )
   57243             :    {
   57244           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   57245           5 :      SgOmpGrainsizeClause* pointer = NULL;
   57246           5 :      std::vector < unsigned char* > :: const_iterator block;
   57247           5 :      SgOmpGrainsizeClause* pointerOfLinkedList = NULL;
   57248           5 :      for ( block = SgOmpGrainsizeClause::pools.begin(); block != SgOmpGrainsizeClause::pools.end() ; ++block )
   57249             :         {
   57250           0 :           pointer = (SgOmpGrainsizeClause*)(*block);
   57251           0 :           for (unsigned i = 0; i < SgOmpGrainsizeClause::pool_size; ++i )
   57252             :              {
   57253             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   57254             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   57255             :             // memory blocks!.
   57256           0 :                if ( pointer[i].get_freepointer() != NULL )
   57257             :                   {
   57258           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   57259             :                   }
   57260             :                else
   57261             :                   {
   57262           0 :                     if ( pointerOfLinkedList == NULL )
   57263             :                        {
   57264           0 :                          SgOmpGrainsizeClause::next_node = &(pointer[i]);
   57265             :                        }
   57266             :                     else
   57267             :                        {
   57268             :                       // printf ("In SgOmpGrainsizeClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   57269           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   57270             :                        }
   57271             :                     pointerOfLinkedList = &(pointer[i]);
   57272             :                   }
   57273             :               }
   57274             :         }
   57275             : 
   57276           5 :      if ( pointerOfLinkedList != NULL )
   57277             :         {
   57278             :        // printf ("In SgOmpGrainsizeClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   57279           0 :           pointerOfLinkedList->set_freepointer(NULL);
   57280             :        // DQ (6/6/2010): Temporary debugging...
   57281             :        //   ROSE_ASSERT(false);
   57282             :         }
   57283             : 
   57284           5 :      return ;
   57285             :    }
   57286             : 
   57287             : //############################################################################
   57288             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   57289             :  * within the memory pool and resets the freepointers, in order to achieve a 
   57290             :  * linked list, that has no jumps and starts at the beginning! This function 
   57291             :  * does not extend the memory pool, since we do not delete any memory blocks,
   57292             :  * but delete the valid objects.  
   57293             :  */
   57294             : void
   57295           0 : SgOmpGrainsizeClause::clearMemoryPool( )
   57296             :    {
   57297             :   // printf ("Inside of SgOmpGrainsizeClause::clearMemoryPool() \n");
   57298             : 
   57299           0 :      SgOmpGrainsizeClause* pointer = NULL, *tempPointer = NULL;
   57300           0 :      std::vector < unsigned char* > :: const_iterator block;
   57301           0 :      if ( SgOmpGrainsizeClause::pools.empty() == false )
   57302             :         {
   57303           0 :           block = SgOmpGrainsizeClause::pools.begin() ;
   57304           0 :           SgOmpGrainsizeClause::next_node = (SgOmpGrainsizeClause*) (*block);
   57305             : 
   57306           0 :           while ( block != SgOmpGrainsizeClause::pools.end() )
   57307             :              {
   57308           0 :                pointer = (SgOmpGrainsizeClause*) (*block);
   57309           0 :                if ( tempPointer != NULL )
   57310             :                   {
   57311           0 :                     tempPointer->set_freepointer(pointer);
   57312             :                   }
   57313           0 :                for (unsigned i = 0; i < SgOmpGrainsizeClause::pool_size - 1; ++i)
   57314             :                   {
   57315           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   57316             :                   }
   57317           0 :                 pointer[SgOmpGrainsizeClause::pool_size-1].set_freepointer(NULL);
   57318           0 :                 tempPointer = &(pointer[SgOmpGrainsizeClause::pool_size-1]);
   57319           0 :                 ++block;
   57320             :              }
   57321             :         }
   57322           0 :    }
   57323             : 
   57324           5 : void SgOmpGrainsizeClause::deleteMemoryPool() {
   57325           5 :   for (auto p: SgOmpGrainsizeClause::pools) {
   57326           0 :     ROSE_FREE(p);
   57327             :   }
   57328           5 :   SgOmpGrainsizeClause::next_node = nullptr;
   57329           5 :   SgOmpGrainsizeClause::pools.clear();
   57330           5 : }
   57331             : 
   57332             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   57333             : //                 reading multiple binary files to for a single AST.
   57334             : /////////// new version ////////////////////////////////
   57335             : //############################################################################
   57336             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   57337             : void
   57338           2 : SgOmpGrainsizeClause::extendMemoryPoolForFileIO( )
   57339             :   {
   57340           2 :     size_t blockIndex = SgOmpGrainsizeClause::pools.size();
   57341           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpGrainsizeClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpGrainsizeClause);
   57342             : 
   57343           2 :     while ( (blockIndex * SgOmpGrainsizeClause::pool_size) < newPoolSize)
   57344             :       {
   57345             : #if ROSE_ALLOC_TRACE
   57346             :         if (blockIndex > 0) {
   57347             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpGrainsizeClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpGrainsizeClause) = %" PRIuPTR " SgOmpGrainsizeClause::pool_size = %d \n",
   57348             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpGrainsizeClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpGrainsizeClause),SgOmpGrainsizeClause::pool_size);
   57349             :         }
   57350             : #endif
   57351             : 
   57352           0 :         SgOmpGrainsizeClause * pointer = (SgOmpGrainsizeClause*) ROSE_MALLOC ( SgOmpGrainsizeClause::pool_size * sizeof(SgOmpGrainsizeClause) );
   57353           0 :         assert( pointer != NULL );
   57354             : #if ROSE_ALLOC_MEMSET == 1
   57355             :         memset(pointer, 0x00, SgOmpGrainsizeClause::pool_size * sizeof(SgOmpGrainsizeClause));
   57356             : #elif ROSE_ALLOC_MEMSET == 2
   57357             :         memset(pointer, 0xCC, SgOmpGrainsizeClause::pool_size * sizeof(SgOmpGrainsizeClause));
   57358             : #endif
   57359           0 :         SgOmpGrainsizeClause::pools.push_back( (unsigned char*)(pointer) );
   57360           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpGrainsizeClause::pool_size * sizeof(SgOmpGrainsizeClause), V_SgOmpGrainsizeClause ) );
   57361             : 
   57362           0 :         if ( SgOmpGrainsizeClause::next_node != NULL ) {
   57363           0 :           if ( blockIndex > 0 ) {
   57364           0 :             SgOmpGrainsizeClause * blkptr = (SgOmpGrainsizeClause*)(SgOmpGrainsizeClause::pools[blockIndex-1]);
   57365           0 :             blkptr[ SgOmpGrainsizeClause::pool_size - 1 ].set_freepointer(pointer);
   57366             :           }
   57367             :         } else {
   57368           0 :           SgOmpGrainsizeClause::next_node = pointer;
   57369             :         }
   57370             : 
   57371           0 :         for (unsigned i = 0; i < SgOmpGrainsizeClause::pool_size-1; ++i)
   57372             :            {
   57373           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   57374             :            }
   57375           0 :         pointer[ SgOmpGrainsizeClause::pool_size -1 ].set_freepointer(NULL);
   57376             : 
   57377           0 :         blockIndex++;
   57378             :       }
   57379           2 :   }
   57380             : 
   57381             : //############################################################################
   57382             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   57383             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   57384             :  * not compressed. However, that stuff is not yet implemented! 
   57385             :  */
   57386             : unsigned long
   57387           0 : SgOmpGrainsizeClause::getNumberOfLastValidPointer()
   57388             :    {
   57389           0 :       SgOmpGrainsizeClause* testPointer = (SgOmpGrainsizeClause*)(SgOmpGrainsizeClause::pools.back());
   57390           0 :       unsigned long localIndex = SgOmpGrainsizeClause::pool_size - 1;
   57391           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   57392             :          {
   57393           0 :            localIndex--;
   57394             :          }
   57395           0 :       return (localIndex + SgOmpGrainsizeClause::pool_size * (SgOmpGrainsizeClause::pools.size()-1));
   57396             :    }
   57397             : 
   57398             : //############################################################################
   57399             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   57400             :  * memory pool and initializes the data member in class SgOmpGrainsizeClauseStroageClass
   57401             :  * from its counterpart of SgOmpGrainsizeClause. The return value is just for checking, 
   57402             :  * that the whole StorageClassArray is initialized!
   57403             :  */
   57404             : unsigned long
   57405           0 : SgOmpGrainsizeClause::initializeStorageClassArray( SgOmpGrainsizeClauseStorageClass *storageArray )
   57406             :    {
   57407           0 :      unsigned long storageCounter = 0;
   57408           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpGrainsizeClause::pools.begin();
   57409           0 :      SgOmpGrainsizeClause* pointer = NULL;
   57410           0 :      while ( block != SgOmpGrainsizeClause::pools.end() ) {
   57411           0 :           pointer = (SgOmpGrainsizeClause*) (*block);
   57412           0 :           for ( unsigned i = 0; i < SgOmpGrainsizeClause::pool_size; ++i ) {
   57413           0 :                if ( pointer->get_freepointer() != NULL ) {
   57414           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   57415           0 :                  storageArray++;
   57416           0 :                  storageCounter++;
   57417             :                }
   57418           0 :                pointer++;
   57419             :              }
   57420           0 :            block++;
   57421             :         }
   57422           0 :      return storageCounter;
   57423             :    }
   57424             : 
   57425             : /* #line 57426 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   57426             : 
   57427             : 
   57428             : 
   57429             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   57430             : 
   57431             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   57432             : 
   57433             : //############################################################################
   57434             : /* JH (02/02/2006) Constructor of the IR node SgOmpNumTasksClause that takes its 
   57435             :  * corresponding StorageClass as parameter
   57436             :  */
   57437           0 : SgOmpNumTasksClause :: SgOmpNumTasksClause ( const SgOmpNumTasksClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   57438             :    {
   57439             : 
   57440             : 
   57441             : /* #line 57442 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   57442             : 
   57443           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   57444             : 
   57445             : 
   57446             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   57447             : 
   57448             : 
   57449           0 :    }
   57450             : 
   57451             : //############################################################################
   57452             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   57453             :  * within the working AST. 
   57454             :  */
   57455           0 : SgOmpNumTasksClause * SgOmpNumTasksClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   57456           0 :      SgOmpNumTasksClause* returnPointer = NULL;
   57457           0 :      if ( globalIndex != 0 )
   57458             :         {
   57459             : 
   57460             : #if FILE_IO_EXTRA_CHECK
   57461           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpNumTasksClause ) ) <= globalIndex ) ;
   57462           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNumTasksClause + 1 ) ) );
   57463             : #endif
   57464           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNumTasksClause )  
   57465           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpNumTasksClause );
   57466           0 :           unsigned long positionInPool = localIndex % SgOmpNumTasksClause::pool_size;
   57467           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNumTasksClause::pool_size;
   57468             : 
   57469             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   57470             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   57471             : 
   57472           0 :           returnPointer = &( ( (SgOmpNumTasksClause*)(SgOmpNumTasksClause::pools[memoryBlock]) ) [positionInPool]) ;
   57473             : 
   57474           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   57475             :         }
   57476           0 :      return returnPointer ;
   57477             :    }
   57478             : 
   57479             : //############################################################################
   57480             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   57481             :   for the AST with the index astIndex
   57482             : */
   57483           0 : SgOmpNumTasksClause * SgOmpNumTasksClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   57484           0 :      SgOmpNumTasksClause* returnPointer = NULL;
   57485           0 :      if ( globalIndex != 0 )
   57486             :         {
   57487             : 
   57488             : #if FILE_IO_EXTRA_CHECK
   57489           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpNumTasksClause ) ) <= globalIndex ) ;
   57490           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNumTasksClause + 1 ) ) );
   57491             : #endif
   57492           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNumTasksClause )
   57493           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpNumTasksClause );
   57494           0 :           unsigned long positionInPool = localIndex % SgOmpNumTasksClause::pool_size ;
   57495           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNumTasksClause::pool_size ;
   57496             : 
   57497             : #if FILE_IO_EXTRA_CHECK
   57498             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   57499             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   57500             : #endif
   57501             : 
   57502           0 :           returnPointer = &( ( (SgOmpNumTasksClause*)(SgOmpNumTasksClause::pools[memoryBlock]) ) [positionInPool]) ;
   57503             : 
   57504             : #if FILE_IO_EXTRA_CHECK
   57505           0 :           assert ( returnPointer != NULL ) ;
   57506             : #endif
   57507             :         }
   57508           0 :      return returnPointer ;
   57509             :    }
   57510             : 
   57511             : //############################################################################
   57512             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   57513             :  * pool size! We set for every valid object in the memory pool the freepointer
   57514             :  * to the global index and increase the global index afterwards. For all the 
   57515             :  * invalid objects (means address ranges within the memory pool that were not
   57516             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   57517             :  * distinguish valid from invalid objects! 
   57518             :  */
   57519             : unsigned long
   57520           5 : SgOmpNumTasksClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   57521             :    {
   57522           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   57523           5 :      SgOmpNumTasksClause* pointer = NULL;
   57524           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   57525           5 :      std::vector < unsigned char* > :: const_iterator block;
   57526           5 :      for ( block = SgOmpNumTasksClause::pools.begin(); block != SgOmpNumTasksClause::pools.end() ; ++block )
   57527             :         {
   57528           0 :           pointer = (SgOmpNumTasksClause*)(*block);
   57529           0 :           for (unsigned i = 0; i < SgOmpNumTasksClause::pool_size; ++i )
   57530             :              {
   57531             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   57532             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   57533             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   57534             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   57535             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   57536             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   57537             :             // properly; so this will have to be checked next.
   57538             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   57539             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   57540           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   57541             :                   {
   57542           0 :                     pointer[i].set_freepointer((SgOmpNumTasksClause*)(globalIndex));
   57543           0 :                     globalIndex++;
   57544             :                   }
   57545             :                else
   57546             :                   {
   57547           0 :                     pointer[i].set_freepointer(NULL);
   57548             :                   }
   57549             :               }
   57550             :         }
   57551           5 :      return globalIndex;
   57552             :    }
   57553             : 
   57554             : //############################################################################
   57555             : // JH (01/14/2006)
   57556             : void
   57557           5 : SgOmpNumTasksClause::resetValidFreepointers( )
   57558             :    {
   57559           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   57560           5 :      SgOmpNumTasksClause* pointer = NULL;
   57561           5 :      std::vector < unsigned char* > :: const_iterator block;
   57562           5 :      SgOmpNumTasksClause* pointerOfLinkedList = NULL;
   57563           5 :      for ( block = SgOmpNumTasksClause::pools.begin(); block != SgOmpNumTasksClause::pools.end() ; ++block )
   57564             :         {
   57565           0 :           pointer = (SgOmpNumTasksClause*)(*block);
   57566           0 :           for (unsigned i = 0; i < SgOmpNumTasksClause::pool_size; ++i )
   57567             :              {
   57568             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   57569             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   57570             :             // memory blocks!.
   57571           0 :                if ( pointer[i].get_freepointer() != NULL )
   57572             :                   {
   57573           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   57574             :                   }
   57575             :                else
   57576             :                   {
   57577           0 :                     if ( pointerOfLinkedList == NULL )
   57578             :                        {
   57579           0 :                          SgOmpNumTasksClause::next_node = &(pointer[i]);
   57580             :                        }
   57581             :                     else
   57582             :                        {
   57583             :                       // printf ("In SgOmpNumTasksClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   57584           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   57585             :                        }
   57586             :                     pointerOfLinkedList = &(pointer[i]);
   57587             :                   }
   57588             :               }
   57589             :         }
   57590             : 
   57591           5 :      if ( pointerOfLinkedList != NULL )
   57592             :         {
   57593             :        // printf ("In SgOmpNumTasksClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   57594           0 :           pointerOfLinkedList->set_freepointer(NULL);
   57595             :        // DQ (6/6/2010): Temporary debugging...
   57596             :        //   ROSE_ASSERT(false);
   57597             :         }
   57598             : 
   57599           5 :      return ;
   57600             :    }
   57601             : 
   57602             : //############################################################################
   57603             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   57604             :  * within the memory pool and resets the freepointers, in order to achieve a 
   57605             :  * linked list, that has no jumps and starts at the beginning! This function 
   57606             :  * does not extend the memory pool, since we do not delete any memory blocks,
   57607             :  * but delete the valid objects.  
   57608             :  */
   57609             : void
   57610           0 : SgOmpNumTasksClause::clearMemoryPool( )
   57611             :    {
   57612             :   // printf ("Inside of SgOmpNumTasksClause::clearMemoryPool() \n");
   57613             : 
   57614           0 :      SgOmpNumTasksClause* pointer = NULL, *tempPointer = NULL;
   57615           0 :      std::vector < unsigned char* > :: const_iterator block;
   57616           0 :      if ( SgOmpNumTasksClause::pools.empty() == false )
   57617             :         {
   57618           0 :           block = SgOmpNumTasksClause::pools.begin() ;
   57619           0 :           SgOmpNumTasksClause::next_node = (SgOmpNumTasksClause*) (*block);
   57620             : 
   57621           0 :           while ( block != SgOmpNumTasksClause::pools.end() )
   57622             :              {
   57623           0 :                pointer = (SgOmpNumTasksClause*) (*block);
   57624           0 :                if ( tempPointer != NULL )
   57625             :                   {
   57626           0 :                     tempPointer->set_freepointer(pointer);
   57627             :                   }
   57628           0 :                for (unsigned i = 0; i < SgOmpNumTasksClause::pool_size - 1; ++i)
   57629             :                   {
   57630           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   57631             :                   }
   57632           0 :                 pointer[SgOmpNumTasksClause::pool_size-1].set_freepointer(NULL);
   57633           0 :                 tempPointer = &(pointer[SgOmpNumTasksClause::pool_size-1]);
   57634           0 :                 ++block;
   57635             :              }
   57636             :         }
   57637           0 :    }
   57638             : 
   57639           5 : void SgOmpNumTasksClause::deleteMemoryPool() {
   57640           5 :   for (auto p: SgOmpNumTasksClause::pools) {
   57641           0 :     ROSE_FREE(p);
   57642             :   }
   57643           5 :   SgOmpNumTasksClause::next_node = nullptr;
   57644           5 :   SgOmpNumTasksClause::pools.clear();
   57645           5 : }
   57646             : 
   57647             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   57648             : //                 reading multiple binary files to for a single AST.
   57649             : /////////// new version ////////////////////////////////
   57650             : //############################################################################
   57651             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   57652             : void
   57653           2 : SgOmpNumTasksClause::extendMemoryPoolForFileIO( )
   57654             :   {
   57655           2 :     size_t blockIndex = SgOmpNumTasksClause::pools.size();
   57656           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNumTasksClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNumTasksClause);
   57657             : 
   57658           2 :     while ( (blockIndex * SgOmpNumTasksClause::pool_size) < newPoolSize)
   57659             :       {
   57660             : #if ROSE_ALLOC_TRACE
   57661             :         if (blockIndex > 0) {
   57662             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNumTasksClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNumTasksClause) = %" PRIuPTR " SgOmpNumTasksClause::pool_size = %d \n",
   57663             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNumTasksClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNumTasksClause),SgOmpNumTasksClause::pool_size);
   57664             :         }
   57665             : #endif
   57666             : 
   57667           0 :         SgOmpNumTasksClause * pointer = (SgOmpNumTasksClause*) ROSE_MALLOC ( SgOmpNumTasksClause::pool_size * sizeof(SgOmpNumTasksClause) );
   57668           0 :         assert( pointer != NULL );
   57669             : #if ROSE_ALLOC_MEMSET == 1
   57670             :         memset(pointer, 0x00, SgOmpNumTasksClause::pool_size * sizeof(SgOmpNumTasksClause));
   57671             : #elif ROSE_ALLOC_MEMSET == 2
   57672             :         memset(pointer, 0xCC, SgOmpNumTasksClause::pool_size * sizeof(SgOmpNumTasksClause));
   57673             : #endif
   57674           0 :         SgOmpNumTasksClause::pools.push_back( (unsigned char*)(pointer) );
   57675           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpNumTasksClause::pool_size * sizeof(SgOmpNumTasksClause), V_SgOmpNumTasksClause ) );
   57676             : 
   57677           0 :         if ( SgOmpNumTasksClause::next_node != NULL ) {
   57678           0 :           if ( blockIndex > 0 ) {
   57679           0 :             SgOmpNumTasksClause * blkptr = (SgOmpNumTasksClause*)(SgOmpNumTasksClause::pools[blockIndex-1]);
   57680           0 :             blkptr[ SgOmpNumTasksClause::pool_size - 1 ].set_freepointer(pointer);
   57681             :           }
   57682             :         } else {
   57683           0 :           SgOmpNumTasksClause::next_node = pointer;
   57684             :         }
   57685             : 
   57686           0 :         for (unsigned i = 0; i < SgOmpNumTasksClause::pool_size-1; ++i)
   57687             :            {
   57688           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   57689             :            }
   57690           0 :         pointer[ SgOmpNumTasksClause::pool_size -1 ].set_freepointer(NULL);
   57691             : 
   57692           0 :         blockIndex++;
   57693             :       }
   57694           2 :   }
   57695             : 
   57696             : //############################################################################
   57697             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   57698             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   57699             :  * not compressed. However, that stuff is not yet implemented! 
   57700             :  */
   57701             : unsigned long
   57702           0 : SgOmpNumTasksClause::getNumberOfLastValidPointer()
   57703             :    {
   57704           0 :       SgOmpNumTasksClause* testPointer = (SgOmpNumTasksClause*)(SgOmpNumTasksClause::pools.back());
   57705           0 :       unsigned long localIndex = SgOmpNumTasksClause::pool_size - 1;
   57706           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   57707             :          {
   57708           0 :            localIndex--;
   57709             :          }
   57710           0 :       return (localIndex + SgOmpNumTasksClause::pool_size * (SgOmpNumTasksClause::pools.size()-1));
   57711             :    }
   57712             : 
   57713             : //############################################################################
   57714             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   57715             :  * memory pool and initializes the data member in class SgOmpNumTasksClauseStroageClass
   57716             :  * from its counterpart of SgOmpNumTasksClause. The return value is just for checking, 
   57717             :  * that the whole StorageClassArray is initialized!
   57718             :  */
   57719             : unsigned long
   57720           0 : SgOmpNumTasksClause::initializeStorageClassArray( SgOmpNumTasksClauseStorageClass *storageArray )
   57721             :    {
   57722           0 :      unsigned long storageCounter = 0;
   57723           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpNumTasksClause::pools.begin();
   57724           0 :      SgOmpNumTasksClause* pointer = NULL;
   57725           0 :      while ( block != SgOmpNumTasksClause::pools.end() ) {
   57726           0 :           pointer = (SgOmpNumTasksClause*) (*block);
   57727           0 :           for ( unsigned i = 0; i < SgOmpNumTasksClause::pool_size; ++i ) {
   57728           0 :                if ( pointer->get_freepointer() != NULL ) {
   57729           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   57730           0 :                  storageArray++;
   57731           0 :                  storageCounter++;
   57732             :                }
   57733           0 :                pointer++;
   57734             :              }
   57735           0 :            block++;
   57736             :         }
   57737           0 :      return storageCounter;
   57738             :    }
   57739             : 
   57740             : /* #line 57741 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   57741             : 
   57742             : 
   57743             : 
   57744             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   57745             : 
   57746             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   57747             : 
   57748             : //############################################################################
   57749             : /* JH (02/02/2006) Constructor of the IR node SgOmpDetachClause that takes its 
   57750             :  * corresponding StorageClass as parameter
   57751             :  */
   57752           0 : SgOmpDetachClause :: SgOmpDetachClause ( const SgOmpDetachClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   57753             :    {
   57754             : 
   57755             : 
   57756             : /* #line 57757 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   57757             : 
   57758           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   57759             : 
   57760             : 
   57761             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   57762             : 
   57763             : 
   57764           0 :    }
   57765             : 
   57766             : //############################################################################
   57767             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   57768             :  * within the working AST. 
   57769             :  */
   57770           0 : SgOmpDetachClause * SgOmpDetachClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   57771           0 :      SgOmpDetachClause* returnPointer = NULL;
   57772           0 :      if ( globalIndex != 0 )
   57773             :         {
   57774             : 
   57775             : #if FILE_IO_EXTRA_CHECK
   57776           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDetachClause ) ) <= globalIndex ) ;
   57777           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDetachClause + 1 ) ) );
   57778             : #endif
   57779           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDetachClause )  
   57780           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDetachClause );
   57781           0 :           unsigned long positionInPool = localIndex % SgOmpDetachClause::pool_size;
   57782           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDetachClause::pool_size;
   57783             : 
   57784             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   57785             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   57786             : 
   57787           0 :           returnPointer = &( ( (SgOmpDetachClause*)(SgOmpDetachClause::pools[memoryBlock]) ) [positionInPool]) ;
   57788             : 
   57789           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   57790             :         }
   57791           0 :      return returnPointer ;
   57792             :    }
   57793             : 
   57794             : //############################################################################
   57795             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   57796             :   for the AST with the index astIndex
   57797             : */
   57798           0 : SgOmpDetachClause * SgOmpDetachClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   57799           0 :      SgOmpDetachClause* returnPointer = NULL;
   57800           0 :      if ( globalIndex != 0 )
   57801             :         {
   57802             : 
   57803             : #if FILE_IO_EXTRA_CHECK
   57804           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDetachClause ) ) <= globalIndex ) ;
   57805           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDetachClause + 1 ) ) );
   57806             : #endif
   57807           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDetachClause )
   57808           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDetachClause );
   57809           0 :           unsigned long positionInPool = localIndex % SgOmpDetachClause::pool_size ;
   57810           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDetachClause::pool_size ;
   57811             : 
   57812             : #if FILE_IO_EXTRA_CHECK
   57813             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   57814             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   57815             : #endif
   57816             : 
   57817           0 :           returnPointer = &( ( (SgOmpDetachClause*)(SgOmpDetachClause::pools[memoryBlock]) ) [positionInPool]) ;
   57818             : 
   57819             : #if FILE_IO_EXTRA_CHECK
   57820           0 :           assert ( returnPointer != NULL ) ;
   57821             : #endif
   57822             :         }
   57823           0 :      return returnPointer ;
   57824             :    }
   57825             : 
   57826             : //############################################################################
   57827             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   57828             :  * pool size! We set for every valid object in the memory pool the freepointer
   57829             :  * to the global index and increase the global index afterwards. For all the 
   57830             :  * invalid objects (means address ranges within the memory pool that were not
   57831             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   57832             :  * distinguish valid from invalid objects! 
   57833             :  */
   57834             : unsigned long
   57835           5 : SgOmpDetachClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   57836             :    {
   57837           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   57838           5 :      SgOmpDetachClause* pointer = NULL;
   57839           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   57840           5 :      std::vector < unsigned char* > :: const_iterator block;
   57841           5 :      for ( block = SgOmpDetachClause::pools.begin(); block != SgOmpDetachClause::pools.end() ; ++block )
   57842             :         {
   57843           0 :           pointer = (SgOmpDetachClause*)(*block);
   57844           0 :           for (unsigned i = 0; i < SgOmpDetachClause::pool_size; ++i )
   57845             :              {
   57846             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   57847             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   57848             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   57849             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   57850             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   57851             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   57852             :             // properly; so this will have to be checked next.
   57853             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   57854             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   57855           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   57856             :                   {
   57857           0 :                     pointer[i].set_freepointer((SgOmpDetachClause*)(globalIndex));
   57858           0 :                     globalIndex++;
   57859             :                   }
   57860             :                else
   57861             :                   {
   57862           0 :                     pointer[i].set_freepointer(NULL);
   57863             :                   }
   57864             :               }
   57865             :         }
   57866           5 :      return globalIndex;
   57867             :    }
   57868             : 
   57869             : //############################################################################
   57870             : // JH (01/14/2006)
   57871             : void
   57872           5 : SgOmpDetachClause::resetValidFreepointers( )
   57873             :    {
   57874           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   57875           5 :      SgOmpDetachClause* pointer = NULL;
   57876           5 :      std::vector < unsigned char* > :: const_iterator block;
   57877           5 :      SgOmpDetachClause* pointerOfLinkedList = NULL;
   57878           5 :      for ( block = SgOmpDetachClause::pools.begin(); block != SgOmpDetachClause::pools.end() ; ++block )
   57879             :         {
   57880           0 :           pointer = (SgOmpDetachClause*)(*block);
   57881           0 :           for (unsigned i = 0; i < SgOmpDetachClause::pool_size; ++i )
   57882             :              {
   57883             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   57884             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   57885             :             // memory blocks!.
   57886           0 :                if ( pointer[i].get_freepointer() != NULL )
   57887             :                   {
   57888           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   57889             :                   }
   57890             :                else
   57891             :                   {
   57892           0 :                     if ( pointerOfLinkedList == NULL )
   57893             :                        {
   57894           0 :                          SgOmpDetachClause::next_node = &(pointer[i]);
   57895             :                        }
   57896             :                     else
   57897             :                        {
   57898             :                       // printf ("In SgOmpDetachClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   57899           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   57900             :                        }
   57901             :                     pointerOfLinkedList = &(pointer[i]);
   57902             :                   }
   57903             :               }
   57904             :         }
   57905             : 
   57906           5 :      if ( pointerOfLinkedList != NULL )
   57907             :         {
   57908             :        // printf ("In SgOmpDetachClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   57909           0 :           pointerOfLinkedList->set_freepointer(NULL);
   57910             :        // DQ (6/6/2010): Temporary debugging...
   57911             :        //   ROSE_ASSERT(false);
   57912             :         }
   57913             : 
   57914           5 :      return ;
   57915             :    }
   57916             : 
   57917             : //############################################################################
   57918             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   57919             :  * within the memory pool and resets the freepointers, in order to achieve a 
   57920             :  * linked list, that has no jumps and starts at the beginning! This function 
   57921             :  * does not extend the memory pool, since we do not delete any memory blocks,
   57922             :  * but delete the valid objects.  
   57923             :  */
   57924             : void
   57925           0 : SgOmpDetachClause::clearMemoryPool( )
   57926             :    {
   57927             :   // printf ("Inside of SgOmpDetachClause::clearMemoryPool() \n");
   57928             : 
   57929           0 :      SgOmpDetachClause* pointer = NULL, *tempPointer = NULL;
   57930           0 :      std::vector < unsigned char* > :: const_iterator block;
   57931           0 :      if ( SgOmpDetachClause::pools.empty() == false )
   57932             :         {
   57933           0 :           block = SgOmpDetachClause::pools.begin() ;
   57934           0 :           SgOmpDetachClause::next_node = (SgOmpDetachClause*) (*block);
   57935             : 
   57936           0 :           while ( block != SgOmpDetachClause::pools.end() )
   57937             :              {
   57938           0 :                pointer = (SgOmpDetachClause*) (*block);
   57939           0 :                if ( tempPointer != NULL )
   57940             :                   {
   57941           0 :                     tempPointer->set_freepointer(pointer);
   57942             :                   }
   57943           0 :                for (unsigned i = 0; i < SgOmpDetachClause::pool_size - 1; ++i)
   57944             :                   {
   57945           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   57946             :                   }
   57947           0 :                 pointer[SgOmpDetachClause::pool_size-1].set_freepointer(NULL);
   57948           0 :                 tempPointer = &(pointer[SgOmpDetachClause::pool_size-1]);
   57949           0 :                 ++block;
   57950             :              }
   57951             :         }
   57952           0 :    }
   57953             : 
   57954           5 : void SgOmpDetachClause::deleteMemoryPool() {
   57955           5 :   for (auto p: SgOmpDetachClause::pools) {
   57956           0 :     ROSE_FREE(p);
   57957             :   }
   57958           5 :   SgOmpDetachClause::next_node = nullptr;
   57959           5 :   SgOmpDetachClause::pools.clear();
   57960           5 : }
   57961             : 
   57962             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   57963             : //                 reading multiple binary files to for a single AST.
   57964             : /////////// new version ////////////////////////////////
   57965             : //############################################################################
   57966             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   57967             : void
   57968           2 : SgOmpDetachClause::extendMemoryPoolForFileIO( )
   57969             :   {
   57970           2 :     size_t blockIndex = SgOmpDetachClause::pools.size();
   57971           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDetachClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDetachClause);
   57972             : 
   57973           2 :     while ( (blockIndex * SgOmpDetachClause::pool_size) < newPoolSize)
   57974             :       {
   57975             : #if ROSE_ALLOC_TRACE
   57976             :         if (blockIndex > 0) {
   57977             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDetachClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDetachClause) = %" PRIuPTR " SgOmpDetachClause::pool_size = %d \n",
   57978             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDetachClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDetachClause),SgOmpDetachClause::pool_size);
   57979             :         }
   57980             : #endif
   57981             : 
   57982           0 :         SgOmpDetachClause * pointer = (SgOmpDetachClause*) ROSE_MALLOC ( SgOmpDetachClause::pool_size * sizeof(SgOmpDetachClause) );
   57983           0 :         assert( pointer != NULL );
   57984             : #if ROSE_ALLOC_MEMSET == 1
   57985             :         memset(pointer, 0x00, SgOmpDetachClause::pool_size * sizeof(SgOmpDetachClause));
   57986             : #elif ROSE_ALLOC_MEMSET == 2
   57987             :         memset(pointer, 0xCC, SgOmpDetachClause::pool_size * sizeof(SgOmpDetachClause));
   57988             : #endif
   57989           0 :         SgOmpDetachClause::pools.push_back( (unsigned char*)(pointer) );
   57990           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDetachClause::pool_size * sizeof(SgOmpDetachClause), V_SgOmpDetachClause ) );
   57991             : 
   57992           0 :         if ( SgOmpDetachClause::next_node != NULL ) {
   57993           0 :           if ( blockIndex > 0 ) {
   57994           0 :             SgOmpDetachClause * blkptr = (SgOmpDetachClause*)(SgOmpDetachClause::pools[blockIndex-1]);
   57995           0 :             blkptr[ SgOmpDetachClause::pool_size - 1 ].set_freepointer(pointer);
   57996             :           }
   57997             :         } else {
   57998           0 :           SgOmpDetachClause::next_node = pointer;
   57999             :         }
   58000             : 
   58001           0 :         for (unsigned i = 0; i < SgOmpDetachClause::pool_size-1; ++i)
   58002             :            {
   58003           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   58004             :            }
   58005           0 :         pointer[ SgOmpDetachClause::pool_size -1 ].set_freepointer(NULL);
   58006             : 
   58007           0 :         blockIndex++;
   58008             :       }
   58009           2 :   }
   58010             : 
   58011             : //############################################################################
   58012             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   58013             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   58014             :  * not compressed. However, that stuff is not yet implemented! 
   58015             :  */
   58016             : unsigned long
   58017           0 : SgOmpDetachClause::getNumberOfLastValidPointer()
   58018             :    {
   58019           0 :       SgOmpDetachClause* testPointer = (SgOmpDetachClause*)(SgOmpDetachClause::pools.back());
   58020           0 :       unsigned long localIndex = SgOmpDetachClause::pool_size - 1;
   58021           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   58022             :          {
   58023           0 :            localIndex--;
   58024             :          }
   58025           0 :       return (localIndex + SgOmpDetachClause::pool_size * (SgOmpDetachClause::pools.size()-1));
   58026             :    }
   58027             : 
   58028             : //############################################################################
   58029             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   58030             :  * memory pool and initializes the data member in class SgOmpDetachClauseStroageClass
   58031             :  * from its counterpart of SgOmpDetachClause. The return value is just for checking, 
   58032             :  * that the whole StorageClassArray is initialized!
   58033             :  */
   58034             : unsigned long
   58035           0 : SgOmpDetachClause::initializeStorageClassArray( SgOmpDetachClauseStorageClass *storageArray )
   58036             :    {
   58037           0 :      unsigned long storageCounter = 0;
   58038           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDetachClause::pools.begin();
   58039           0 :      SgOmpDetachClause* pointer = NULL;
   58040           0 :      while ( block != SgOmpDetachClause::pools.end() ) {
   58041           0 :           pointer = (SgOmpDetachClause*) (*block);
   58042           0 :           for ( unsigned i = 0; i < SgOmpDetachClause::pool_size; ++i ) {
   58043           0 :                if ( pointer->get_freepointer() != NULL ) {
   58044           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   58045           0 :                  storageArray++;
   58046           0 :                  storageCounter++;
   58047             :                }
   58048           0 :                pointer++;
   58049             :              }
   58050           0 :            block++;
   58051             :         }
   58052           0 :      return storageCounter;
   58053             :    }
   58054             : 
   58055             : /* #line 58056 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   58056             : 
   58057             : 
   58058             : 
   58059             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   58060             : 
   58061             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   58062             : 
   58063             : //############################################################################
   58064             : /* JH (02/02/2006) Constructor of the IR node SgOmpSafelenClause that takes its 
   58065             :  * corresponding StorageClass as parameter
   58066             :  */
   58067           0 : SgOmpSafelenClause :: SgOmpSafelenClause ( const SgOmpSafelenClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   58068             :    {
   58069             : 
   58070             : 
   58071             : /* #line 58072 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   58072             : 
   58073           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   58074             : 
   58075             : 
   58076             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   58077             : 
   58078             : 
   58079           0 :    }
   58080             : 
   58081             : //############################################################################
   58082             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   58083             :  * within the working AST. 
   58084             :  */
   58085           0 : SgOmpSafelenClause * SgOmpSafelenClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   58086           0 :      SgOmpSafelenClause* returnPointer = NULL;
   58087           0 :      if ( globalIndex != 0 )
   58088             :         {
   58089             : 
   58090             : #if FILE_IO_EXTRA_CHECK
   58091           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSafelenClause ) ) <= globalIndex ) ;
   58092           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSafelenClause + 1 ) ) );
   58093             : #endif
   58094           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSafelenClause )  
   58095           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSafelenClause );
   58096           0 :           unsigned long positionInPool = localIndex % SgOmpSafelenClause::pool_size;
   58097           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSafelenClause::pool_size;
   58098             : 
   58099             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   58100             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   58101             : 
   58102           0 :           returnPointer = &( ( (SgOmpSafelenClause*)(SgOmpSafelenClause::pools[memoryBlock]) ) [positionInPool]) ;
   58103             : 
   58104           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   58105             :         }
   58106           0 :      return returnPointer ;
   58107             :    }
   58108             : 
   58109             : //############################################################################
   58110             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   58111             :   for the AST with the index astIndex
   58112             : */
   58113           0 : SgOmpSafelenClause * SgOmpSafelenClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   58114           0 :      SgOmpSafelenClause* returnPointer = NULL;
   58115           0 :      if ( globalIndex != 0 )
   58116             :         {
   58117             : 
   58118             : #if FILE_IO_EXTRA_CHECK
   58119           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSafelenClause ) ) <= globalIndex ) ;
   58120           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSafelenClause + 1 ) ) );
   58121             : #endif
   58122           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSafelenClause )
   58123           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSafelenClause );
   58124           0 :           unsigned long positionInPool = localIndex % SgOmpSafelenClause::pool_size ;
   58125           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSafelenClause::pool_size ;
   58126             : 
   58127             : #if FILE_IO_EXTRA_CHECK
   58128             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   58129             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   58130             : #endif
   58131             : 
   58132           0 :           returnPointer = &( ( (SgOmpSafelenClause*)(SgOmpSafelenClause::pools[memoryBlock]) ) [positionInPool]) ;
   58133             : 
   58134             : #if FILE_IO_EXTRA_CHECK
   58135           0 :           assert ( returnPointer != NULL ) ;
   58136             : #endif
   58137             :         }
   58138           0 :      return returnPointer ;
   58139             :    }
   58140             : 
   58141             : //############################################################################
   58142             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   58143             :  * pool size! We set for every valid object in the memory pool the freepointer
   58144             :  * to the global index and increase the global index afterwards. For all the 
   58145             :  * invalid objects (means address ranges within the memory pool that were not
   58146             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   58147             :  * distinguish valid from invalid objects! 
   58148             :  */
   58149             : unsigned long
   58150           5 : SgOmpSafelenClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   58151             :    {
   58152           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   58153           5 :      SgOmpSafelenClause* pointer = NULL;
   58154           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   58155           5 :      std::vector < unsigned char* > :: const_iterator block;
   58156           5 :      for ( block = SgOmpSafelenClause::pools.begin(); block != SgOmpSafelenClause::pools.end() ; ++block )
   58157             :         {
   58158           0 :           pointer = (SgOmpSafelenClause*)(*block);
   58159           0 :           for (unsigned i = 0; i < SgOmpSafelenClause::pool_size; ++i )
   58160             :              {
   58161             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   58162             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   58163             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   58164             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   58165             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   58166             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   58167             :             // properly; so this will have to be checked next.
   58168             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   58169             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   58170           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   58171             :                   {
   58172           0 :                     pointer[i].set_freepointer((SgOmpSafelenClause*)(globalIndex));
   58173           0 :                     globalIndex++;
   58174             :                   }
   58175             :                else
   58176             :                   {
   58177           0 :                     pointer[i].set_freepointer(NULL);
   58178             :                   }
   58179             :               }
   58180             :         }
   58181           5 :      return globalIndex;
   58182             :    }
   58183             : 
   58184             : //############################################################################
   58185             : // JH (01/14/2006)
   58186             : void
   58187           5 : SgOmpSafelenClause::resetValidFreepointers( )
   58188             :    {
   58189           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   58190           5 :      SgOmpSafelenClause* pointer = NULL;
   58191           5 :      std::vector < unsigned char* > :: const_iterator block;
   58192           5 :      SgOmpSafelenClause* pointerOfLinkedList = NULL;
   58193           5 :      for ( block = SgOmpSafelenClause::pools.begin(); block != SgOmpSafelenClause::pools.end() ; ++block )
   58194             :         {
   58195           0 :           pointer = (SgOmpSafelenClause*)(*block);
   58196           0 :           for (unsigned i = 0; i < SgOmpSafelenClause::pool_size; ++i )
   58197             :              {
   58198             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   58199             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   58200             :             // memory blocks!.
   58201           0 :                if ( pointer[i].get_freepointer() != NULL )
   58202             :                   {
   58203           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   58204             :                   }
   58205             :                else
   58206             :                   {
   58207           0 :                     if ( pointerOfLinkedList == NULL )
   58208             :                        {
   58209           0 :                          SgOmpSafelenClause::next_node = &(pointer[i]);
   58210             :                        }
   58211             :                     else
   58212             :                        {
   58213             :                       // printf ("In SgOmpSafelenClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   58214           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   58215             :                        }
   58216             :                     pointerOfLinkedList = &(pointer[i]);
   58217             :                   }
   58218             :               }
   58219             :         }
   58220             : 
   58221           5 :      if ( pointerOfLinkedList != NULL )
   58222             :         {
   58223             :        // printf ("In SgOmpSafelenClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   58224           0 :           pointerOfLinkedList->set_freepointer(NULL);
   58225             :        // DQ (6/6/2010): Temporary debugging...
   58226             :        //   ROSE_ASSERT(false);
   58227             :         }
   58228             : 
   58229           5 :      return ;
   58230             :    }
   58231             : 
   58232             : //############################################################################
   58233             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   58234             :  * within the memory pool and resets the freepointers, in order to achieve a 
   58235             :  * linked list, that has no jumps and starts at the beginning! This function 
   58236             :  * does not extend the memory pool, since we do not delete any memory blocks,
   58237             :  * but delete the valid objects.  
   58238             :  */
   58239             : void
   58240           0 : SgOmpSafelenClause::clearMemoryPool( )
   58241             :    {
   58242             :   // printf ("Inside of SgOmpSafelenClause::clearMemoryPool() \n");
   58243             : 
   58244           0 :      SgOmpSafelenClause* pointer = NULL, *tempPointer = NULL;
   58245           0 :      std::vector < unsigned char* > :: const_iterator block;
   58246           0 :      if ( SgOmpSafelenClause::pools.empty() == false )
   58247             :         {
   58248           0 :           block = SgOmpSafelenClause::pools.begin() ;
   58249           0 :           SgOmpSafelenClause::next_node = (SgOmpSafelenClause*) (*block);
   58250             : 
   58251           0 :           while ( block != SgOmpSafelenClause::pools.end() )
   58252             :              {
   58253           0 :                pointer = (SgOmpSafelenClause*) (*block);
   58254           0 :                if ( tempPointer != NULL )
   58255             :                   {
   58256           0 :                     tempPointer->set_freepointer(pointer);
   58257             :                   }
   58258           0 :                for (unsigned i = 0; i < SgOmpSafelenClause::pool_size - 1; ++i)
   58259             :                   {
   58260           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   58261             :                   }
   58262           0 :                 pointer[SgOmpSafelenClause::pool_size-1].set_freepointer(NULL);
   58263           0 :                 tempPointer = &(pointer[SgOmpSafelenClause::pool_size-1]);
   58264           0 :                 ++block;
   58265             :              }
   58266             :         }
   58267           0 :    }
   58268             : 
   58269           5 : void SgOmpSafelenClause::deleteMemoryPool() {
   58270           5 :   for (auto p: SgOmpSafelenClause::pools) {
   58271           0 :     ROSE_FREE(p);
   58272             :   }
   58273           5 :   SgOmpSafelenClause::next_node = nullptr;
   58274           5 :   SgOmpSafelenClause::pools.clear();
   58275           5 : }
   58276             : 
   58277             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   58278             : //                 reading multiple binary files to for a single AST.
   58279             : /////////// new version ////////////////////////////////
   58280             : //############################################################################
   58281             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   58282             : void
   58283           2 : SgOmpSafelenClause::extendMemoryPoolForFileIO( )
   58284             :   {
   58285           2 :     size_t blockIndex = SgOmpSafelenClause::pools.size();
   58286           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSafelenClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSafelenClause);
   58287             : 
   58288           2 :     while ( (blockIndex * SgOmpSafelenClause::pool_size) < newPoolSize)
   58289             :       {
   58290             : #if ROSE_ALLOC_TRACE
   58291             :         if (blockIndex > 0) {
   58292             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSafelenClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSafelenClause) = %" PRIuPTR " SgOmpSafelenClause::pool_size = %d \n",
   58293             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSafelenClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSafelenClause),SgOmpSafelenClause::pool_size);
   58294             :         }
   58295             : #endif
   58296             : 
   58297           0 :         SgOmpSafelenClause * pointer = (SgOmpSafelenClause*) ROSE_MALLOC ( SgOmpSafelenClause::pool_size * sizeof(SgOmpSafelenClause) );
   58298           0 :         assert( pointer != NULL );
   58299             : #if ROSE_ALLOC_MEMSET == 1
   58300             :         memset(pointer, 0x00, SgOmpSafelenClause::pool_size * sizeof(SgOmpSafelenClause));
   58301             : #elif ROSE_ALLOC_MEMSET == 2
   58302             :         memset(pointer, 0xCC, SgOmpSafelenClause::pool_size * sizeof(SgOmpSafelenClause));
   58303             : #endif
   58304           0 :         SgOmpSafelenClause::pools.push_back( (unsigned char*)(pointer) );
   58305           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSafelenClause::pool_size * sizeof(SgOmpSafelenClause), V_SgOmpSafelenClause ) );
   58306             : 
   58307           0 :         if ( SgOmpSafelenClause::next_node != NULL ) {
   58308           0 :           if ( blockIndex > 0 ) {
   58309           0 :             SgOmpSafelenClause * blkptr = (SgOmpSafelenClause*)(SgOmpSafelenClause::pools[blockIndex-1]);
   58310           0 :             blkptr[ SgOmpSafelenClause::pool_size - 1 ].set_freepointer(pointer);
   58311             :           }
   58312             :         } else {
   58313           0 :           SgOmpSafelenClause::next_node = pointer;
   58314             :         }
   58315             : 
   58316           0 :         for (unsigned i = 0; i < SgOmpSafelenClause::pool_size-1; ++i)
   58317             :            {
   58318           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   58319             :            }
   58320           0 :         pointer[ SgOmpSafelenClause::pool_size -1 ].set_freepointer(NULL);
   58321             : 
   58322           0 :         blockIndex++;
   58323             :       }
   58324           2 :   }
   58325             : 
   58326             : //############################################################################
   58327             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   58328             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   58329             :  * not compressed. However, that stuff is not yet implemented! 
   58330             :  */
   58331             : unsigned long
   58332           0 : SgOmpSafelenClause::getNumberOfLastValidPointer()
   58333             :    {
   58334           0 :       SgOmpSafelenClause* testPointer = (SgOmpSafelenClause*)(SgOmpSafelenClause::pools.back());
   58335           0 :       unsigned long localIndex = SgOmpSafelenClause::pool_size - 1;
   58336           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   58337             :          {
   58338           0 :            localIndex--;
   58339             :          }
   58340           0 :       return (localIndex + SgOmpSafelenClause::pool_size * (SgOmpSafelenClause::pools.size()-1));
   58341             :    }
   58342             : 
   58343             : //############################################################################
   58344             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   58345             :  * memory pool and initializes the data member in class SgOmpSafelenClauseStroageClass
   58346             :  * from its counterpart of SgOmpSafelenClause. The return value is just for checking, 
   58347             :  * that the whole StorageClassArray is initialized!
   58348             :  */
   58349             : unsigned long
   58350           0 : SgOmpSafelenClause::initializeStorageClassArray( SgOmpSafelenClauseStorageClass *storageArray )
   58351             :    {
   58352           0 :      unsigned long storageCounter = 0;
   58353           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSafelenClause::pools.begin();
   58354           0 :      SgOmpSafelenClause* pointer = NULL;
   58355           0 :      while ( block != SgOmpSafelenClause::pools.end() ) {
   58356           0 :           pointer = (SgOmpSafelenClause*) (*block);
   58357           0 :           for ( unsigned i = 0; i < SgOmpSafelenClause::pool_size; ++i ) {
   58358           0 :                if ( pointer->get_freepointer() != NULL ) {
   58359           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   58360           0 :                  storageArray++;
   58361           0 :                  storageCounter++;
   58362             :                }
   58363           0 :                pointer++;
   58364             :              }
   58365           0 :            block++;
   58366             :         }
   58367           0 :      return storageCounter;
   58368             :    }
   58369             : 
   58370             : /* #line 58371 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   58371             : 
   58372             : 
   58373             : 
   58374             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   58375             : 
   58376             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   58377             : 
   58378             : //############################################################################
   58379             : /* JH (02/02/2006) Constructor of the IR node SgOmpSimdlenClause that takes its 
   58380             :  * corresponding StorageClass as parameter
   58381             :  */
   58382           0 : SgOmpSimdlenClause :: SgOmpSimdlenClause ( const SgOmpSimdlenClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   58383             :    {
   58384             : 
   58385             : 
   58386             : /* #line 58387 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   58387             : 
   58388           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   58389             : 
   58390             : 
   58391             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   58392             : 
   58393             : 
   58394           0 :    }
   58395             : 
   58396             : //############################################################################
   58397             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   58398             :  * within the working AST. 
   58399             :  */
   58400           0 : SgOmpSimdlenClause * SgOmpSimdlenClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   58401           0 :      SgOmpSimdlenClause* returnPointer = NULL;
   58402           0 :      if ( globalIndex != 0 )
   58403             :         {
   58404             : 
   58405             : #if FILE_IO_EXTRA_CHECK
   58406           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSimdlenClause ) ) <= globalIndex ) ;
   58407           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSimdlenClause + 1 ) ) );
   58408             : #endif
   58409           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSimdlenClause )  
   58410           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSimdlenClause );
   58411           0 :           unsigned long positionInPool = localIndex % SgOmpSimdlenClause::pool_size;
   58412           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSimdlenClause::pool_size;
   58413             : 
   58414             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   58415             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   58416             : 
   58417           0 :           returnPointer = &( ( (SgOmpSimdlenClause*)(SgOmpSimdlenClause::pools[memoryBlock]) ) [positionInPool]) ;
   58418             : 
   58419           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   58420             :         }
   58421           0 :      return returnPointer ;
   58422             :    }
   58423             : 
   58424             : //############################################################################
   58425             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   58426             :   for the AST with the index astIndex
   58427             : */
   58428           0 : SgOmpSimdlenClause * SgOmpSimdlenClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   58429           0 :      SgOmpSimdlenClause* returnPointer = NULL;
   58430           0 :      if ( globalIndex != 0 )
   58431             :         {
   58432             : 
   58433             : #if FILE_IO_EXTRA_CHECK
   58434           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSimdlenClause ) ) <= globalIndex ) ;
   58435           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSimdlenClause + 1 ) ) );
   58436             : #endif
   58437           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSimdlenClause )
   58438           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSimdlenClause );
   58439           0 :           unsigned long positionInPool = localIndex % SgOmpSimdlenClause::pool_size ;
   58440           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSimdlenClause::pool_size ;
   58441             : 
   58442             : #if FILE_IO_EXTRA_CHECK
   58443             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   58444             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   58445             : #endif
   58446             : 
   58447           0 :           returnPointer = &( ( (SgOmpSimdlenClause*)(SgOmpSimdlenClause::pools[memoryBlock]) ) [positionInPool]) ;
   58448             : 
   58449             : #if FILE_IO_EXTRA_CHECK
   58450           0 :           assert ( returnPointer != NULL ) ;
   58451             : #endif
   58452             :         }
   58453           0 :      return returnPointer ;
   58454             :    }
   58455             : 
   58456             : //############################################################################
   58457             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   58458             :  * pool size! We set for every valid object in the memory pool the freepointer
   58459             :  * to the global index and increase the global index afterwards. For all the 
   58460             :  * invalid objects (means address ranges within the memory pool that were not
   58461             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   58462             :  * distinguish valid from invalid objects! 
   58463             :  */
   58464             : unsigned long
   58465           5 : SgOmpSimdlenClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   58466             :    {
   58467           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   58468           5 :      SgOmpSimdlenClause* pointer = NULL;
   58469           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   58470           5 :      std::vector < unsigned char* > :: const_iterator block;
   58471           5 :      for ( block = SgOmpSimdlenClause::pools.begin(); block != SgOmpSimdlenClause::pools.end() ; ++block )
   58472             :         {
   58473           0 :           pointer = (SgOmpSimdlenClause*)(*block);
   58474           0 :           for (unsigned i = 0; i < SgOmpSimdlenClause::pool_size; ++i )
   58475             :              {
   58476             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   58477             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   58478             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   58479             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   58480             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   58481             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   58482             :             // properly; so this will have to be checked next.
   58483             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   58484             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   58485           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   58486             :                   {
   58487           0 :                     pointer[i].set_freepointer((SgOmpSimdlenClause*)(globalIndex));
   58488           0 :                     globalIndex++;
   58489             :                   }
   58490             :                else
   58491             :                   {
   58492           0 :                     pointer[i].set_freepointer(NULL);
   58493             :                   }
   58494             :               }
   58495             :         }
   58496           5 :      return globalIndex;
   58497             :    }
   58498             : 
   58499             : //############################################################################
   58500             : // JH (01/14/2006)
   58501             : void
   58502           5 : SgOmpSimdlenClause::resetValidFreepointers( )
   58503             :    {
   58504           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   58505           5 :      SgOmpSimdlenClause* pointer = NULL;
   58506           5 :      std::vector < unsigned char* > :: const_iterator block;
   58507           5 :      SgOmpSimdlenClause* pointerOfLinkedList = NULL;
   58508           5 :      for ( block = SgOmpSimdlenClause::pools.begin(); block != SgOmpSimdlenClause::pools.end() ; ++block )
   58509             :         {
   58510           0 :           pointer = (SgOmpSimdlenClause*)(*block);
   58511           0 :           for (unsigned i = 0; i < SgOmpSimdlenClause::pool_size; ++i )
   58512             :              {
   58513             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   58514             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   58515             :             // memory blocks!.
   58516           0 :                if ( pointer[i].get_freepointer() != NULL )
   58517             :                   {
   58518           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   58519             :                   }
   58520             :                else
   58521             :                   {
   58522           0 :                     if ( pointerOfLinkedList == NULL )
   58523             :                        {
   58524           0 :                          SgOmpSimdlenClause::next_node = &(pointer[i]);
   58525             :                        }
   58526             :                     else
   58527             :                        {
   58528             :                       // printf ("In SgOmpSimdlenClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   58529           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   58530             :                        }
   58531             :                     pointerOfLinkedList = &(pointer[i]);
   58532             :                   }
   58533             :               }
   58534             :         }
   58535             : 
   58536           5 :      if ( pointerOfLinkedList != NULL )
   58537             :         {
   58538             :        // printf ("In SgOmpSimdlenClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   58539           0 :           pointerOfLinkedList->set_freepointer(NULL);
   58540             :        // DQ (6/6/2010): Temporary debugging...
   58541             :        //   ROSE_ASSERT(false);
   58542             :         }
   58543             : 
   58544           5 :      return ;
   58545             :    }
   58546             : 
   58547             : //############################################################################
   58548             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   58549             :  * within the memory pool and resets the freepointers, in order to achieve a 
   58550             :  * linked list, that has no jumps and starts at the beginning! This function 
   58551             :  * does not extend the memory pool, since we do not delete any memory blocks,
   58552             :  * but delete the valid objects.  
   58553             :  */
   58554             : void
   58555           0 : SgOmpSimdlenClause::clearMemoryPool( )
   58556             :    {
   58557             :   // printf ("Inside of SgOmpSimdlenClause::clearMemoryPool() \n");
   58558             : 
   58559           0 :      SgOmpSimdlenClause* pointer = NULL, *tempPointer = NULL;
   58560           0 :      std::vector < unsigned char* > :: const_iterator block;
   58561           0 :      if ( SgOmpSimdlenClause::pools.empty() == false )
   58562             :         {
   58563           0 :           block = SgOmpSimdlenClause::pools.begin() ;
   58564           0 :           SgOmpSimdlenClause::next_node = (SgOmpSimdlenClause*) (*block);
   58565             : 
   58566           0 :           while ( block != SgOmpSimdlenClause::pools.end() )
   58567             :              {
   58568           0 :                pointer = (SgOmpSimdlenClause*) (*block);
   58569           0 :                if ( tempPointer != NULL )
   58570             :                   {
   58571           0 :                     tempPointer->set_freepointer(pointer);
   58572             :                   }
   58573           0 :                for (unsigned i = 0; i < SgOmpSimdlenClause::pool_size - 1; ++i)
   58574             :                   {
   58575           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   58576             :                   }
   58577           0 :                 pointer[SgOmpSimdlenClause::pool_size-1].set_freepointer(NULL);
   58578           0 :                 tempPointer = &(pointer[SgOmpSimdlenClause::pool_size-1]);
   58579           0 :                 ++block;
   58580             :              }
   58581             :         }
   58582           0 :    }
   58583             : 
   58584           5 : void SgOmpSimdlenClause::deleteMemoryPool() {
   58585           5 :   for (auto p: SgOmpSimdlenClause::pools) {
   58586           0 :     ROSE_FREE(p);
   58587             :   }
   58588           5 :   SgOmpSimdlenClause::next_node = nullptr;
   58589           5 :   SgOmpSimdlenClause::pools.clear();
   58590           5 : }
   58591             : 
   58592             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   58593             : //                 reading multiple binary files to for a single AST.
   58594             : /////////// new version ////////////////////////////////
   58595             : //############################################################################
   58596             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   58597             : void
   58598           2 : SgOmpSimdlenClause::extendMemoryPoolForFileIO( )
   58599             :   {
   58600           2 :     size_t blockIndex = SgOmpSimdlenClause::pools.size();
   58601           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSimdlenClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSimdlenClause);
   58602             : 
   58603           2 :     while ( (blockIndex * SgOmpSimdlenClause::pool_size) < newPoolSize)
   58604             :       {
   58605             : #if ROSE_ALLOC_TRACE
   58606             :         if (blockIndex > 0) {
   58607             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSimdlenClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSimdlenClause) = %" PRIuPTR " SgOmpSimdlenClause::pool_size = %d \n",
   58608             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSimdlenClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSimdlenClause),SgOmpSimdlenClause::pool_size);
   58609             :         }
   58610             : #endif
   58611             : 
   58612           0 :         SgOmpSimdlenClause * pointer = (SgOmpSimdlenClause*) ROSE_MALLOC ( SgOmpSimdlenClause::pool_size * sizeof(SgOmpSimdlenClause) );
   58613           0 :         assert( pointer != NULL );
   58614             : #if ROSE_ALLOC_MEMSET == 1
   58615             :         memset(pointer, 0x00, SgOmpSimdlenClause::pool_size * sizeof(SgOmpSimdlenClause));
   58616             : #elif ROSE_ALLOC_MEMSET == 2
   58617             :         memset(pointer, 0xCC, SgOmpSimdlenClause::pool_size * sizeof(SgOmpSimdlenClause));
   58618             : #endif
   58619           0 :         SgOmpSimdlenClause::pools.push_back( (unsigned char*)(pointer) );
   58620           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSimdlenClause::pool_size * sizeof(SgOmpSimdlenClause), V_SgOmpSimdlenClause ) );
   58621             : 
   58622           0 :         if ( SgOmpSimdlenClause::next_node != NULL ) {
   58623           0 :           if ( blockIndex > 0 ) {
   58624           0 :             SgOmpSimdlenClause * blkptr = (SgOmpSimdlenClause*)(SgOmpSimdlenClause::pools[blockIndex-1]);
   58625           0 :             blkptr[ SgOmpSimdlenClause::pool_size - 1 ].set_freepointer(pointer);
   58626             :           }
   58627             :         } else {
   58628           0 :           SgOmpSimdlenClause::next_node = pointer;
   58629             :         }
   58630             : 
   58631           0 :         for (unsigned i = 0; i < SgOmpSimdlenClause::pool_size-1; ++i)
   58632             :            {
   58633           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   58634             :            }
   58635           0 :         pointer[ SgOmpSimdlenClause::pool_size -1 ].set_freepointer(NULL);
   58636             : 
   58637           0 :         blockIndex++;
   58638             :       }
   58639           2 :   }
   58640             : 
   58641             : //############################################################################
   58642             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   58643             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   58644             :  * not compressed. However, that stuff is not yet implemented! 
   58645             :  */
   58646             : unsigned long
   58647           0 : SgOmpSimdlenClause::getNumberOfLastValidPointer()
   58648             :    {
   58649           0 :       SgOmpSimdlenClause* testPointer = (SgOmpSimdlenClause*)(SgOmpSimdlenClause::pools.back());
   58650           0 :       unsigned long localIndex = SgOmpSimdlenClause::pool_size - 1;
   58651           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   58652             :          {
   58653           0 :            localIndex--;
   58654             :          }
   58655           0 :       return (localIndex + SgOmpSimdlenClause::pool_size * (SgOmpSimdlenClause::pools.size()-1));
   58656             :    }
   58657             : 
   58658             : //############################################################################
   58659             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   58660             :  * memory pool and initializes the data member in class SgOmpSimdlenClauseStroageClass
   58661             :  * from its counterpart of SgOmpSimdlenClause. The return value is just for checking, 
   58662             :  * that the whole StorageClassArray is initialized!
   58663             :  */
   58664             : unsigned long
   58665           0 : SgOmpSimdlenClause::initializeStorageClassArray( SgOmpSimdlenClauseStorageClass *storageArray )
   58666             :    {
   58667           0 :      unsigned long storageCounter = 0;
   58668           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSimdlenClause::pools.begin();
   58669           0 :      SgOmpSimdlenClause* pointer = NULL;
   58670           0 :      while ( block != SgOmpSimdlenClause::pools.end() ) {
   58671           0 :           pointer = (SgOmpSimdlenClause*) (*block);
   58672           0 :           for ( unsigned i = 0; i < SgOmpSimdlenClause::pool_size; ++i ) {
   58673           0 :                if ( pointer->get_freepointer() != NULL ) {
   58674           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   58675           0 :                  storageArray++;
   58676           0 :                  storageCounter++;
   58677             :                }
   58678           0 :                pointer++;
   58679             :              }
   58680           0 :            block++;
   58681             :         }
   58682           0 :      return storageCounter;
   58683             :    }
   58684             : 
   58685             : /* #line 58686 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   58686             : 
   58687             : 
   58688             : 
   58689             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   58690             : 
   58691             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   58692             : 
   58693             : //############################################################################
   58694             : /* JH (02/02/2006) Constructor of the IR node SgOmpFinalClause that takes its 
   58695             :  * corresponding StorageClass as parameter
   58696             :  */
   58697           0 : SgOmpFinalClause :: SgOmpFinalClause ( const SgOmpFinalClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   58698             :    {
   58699             : 
   58700             : 
   58701             : /* #line 58702 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   58702             : 
   58703           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   58704             : 
   58705             : 
   58706             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   58707             : 
   58708             : 
   58709           0 :    }
   58710             : 
   58711             : //############################################################################
   58712             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   58713             :  * within the working AST. 
   58714             :  */
   58715           0 : SgOmpFinalClause * SgOmpFinalClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   58716           0 :      SgOmpFinalClause* returnPointer = NULL;
   58717           0 :      if ( globalIndex != 0 )
   58718             :         {
   58719             : 
   58720             : #if FILE_IO_EXTRA_CHECK
   58721           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpFinalClause ) ) <= globalIndex ) ;
   58722           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFinalClause + 1 ) ) );
   58723             : #endif
   58724           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFinalClause )  
   58725           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpFinalClause );
   58726           0 :           unsigned long positionInPool = localIndex % SgOmpFinalClause::pool_size;
   58727           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFinalClause::pool_size;
   58728             : 
   58729             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   58730             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   58731             : 
   58732           0 :           returnPointer = &( ( (SgOmpFinalClause*)(SgOmpFinalClause::pools[memoryBlock]) ) [positionInPool]) ;
   58733             : 
   58734           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   58735             :         }
   58736           0 :      return returnPointer ;
   58737             :    }
   58738             : 
   58739             : //############################################################################
   58740             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   58741             :   for the AST with the index astIndex
   58742             : */
   58743           0 : SgOmpFinalClause * SgOmpFinalClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   58744           0 :      SgOmpFinalClause* returnPointer = NULL;
   58745           0 :      if ( globalIndex != 0 )
   58746             :         {
   58747             : 
   58748             : #if FILE_IO_EXTRA_CHECK
   58749           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpFinalClause ) ) <= globalIndex ) ;
   58750           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFinalClause + 1 ) ) );
   58751             : #endif
   58752           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFinalClause )
   58753           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpFinalClause );
   58754           0 :           unsigned long positionInPool = localIndex % SgOmpFinalClause::pool_size ;
   58755           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFinalClause::pool_size ;
   58756             : 
   58757             : #if FILE_IO_EXTRA_CHECK
   58758             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   58759             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   58760             : #endif
   58761             : 
   58762           0 :           returnPointer = &( ( (SgOmpFinalClause*)(SgOmpFinalClause::pools[memoryBlock]) ) [positionInPool]) ;
   58763             : 
   58764             : #if FILE_IO_EXTRA_CHECK
   58765           0 :           assert ( returnPointer != NULL ) ;
   58766             : #endif
   58767             :         }
   58768           0 :      return returnPointer ;
   58769             :    }
   58770             : 
   58771             : //############################################################################
   58772             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   58773             :  * pool size! We set for every valid object in the memory pool the freepointer
   58774             :  * to the global index and increase the global index afterwards. For all the 
   58775             :  * invalid objects (means address ranges within the memory pool that were not
   58776             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   58777             :  * distinguish valid from invalid objects! 
   58778             :  */
   58779             : unsigned long
   58780           5 : SgOmpFinalClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   58781             :    {
   58782           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   58783           5 :      SgOmpFinalClause* pointer = NULL;
   58784           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   58785           5 :      std::vector < unsigned char* > :: const_iterator block;
   58786           5 :      for ( block = SgOmpFinalClause::pools.begin(); block != SgOmpFinalClause::pools.end() ; ++block )
   58787             :         {
   58788           0 :           pointer = (SgOmpFinalClause*)(*block);
   58789           0 :           for (unsigned i = 0; i < SgOmpFinalClause::pool_size; ++i )
   58790             :              {
   58791             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   58792             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   58793             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   58794             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   58795             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   58796             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   58797             :             // properly; so this will have to be checked next.
   58798             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   58799             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   58800           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   58801             :                   {
   58802           0 :                     pointer[i].set_freepointer((SgOmpFinalClause*)(globalIndex));
   58803           0 :                     globalIndex++;
   58804             :                   }
   58805             :                else
   58806             :                   {
   58807           0 :                     pointer[i].set_freepointer(NULL);
   58808             :                   }
   58809             :               }
   58810             :         }
   58811           5 :      return globalIndex;
   58812             :    }
   58813             : 
   58814             : //############################################################################
   58815             : // JH (01/14/2006)
   58816             : void
   58817           5 : SgOmpFinalClause::resetValidFreepointers( )
   58818             :    {
   58819           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   58820           5 :      SgOmpFinalClause* pointer = NULL;
   58821           5 :      std::vector < unsigned char* > :: const_iterator block;
   58822           5 :      SgOmpFinalClause* pointerOfLinkedList = NULL;
   58823           5 :      for ( block = SgOmpFinalClause::pools.begin(); block != SgOmpFinalClause::pools.end() ; ++block )
   58824             :         {
   58825           0 :           pointer = (SgOmpFinalClause*)(*block);
   58826           0 :           for (unsigned i = 0; i < SgOmpFinalClause::pool_size; ++i )
   58827             :              {
   58828             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   58829             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   58830             :             // memory blocks!.
   58831           0 :                if ( pointer[i].get_freepointer() != NULL )
   58832             :                   {
   58833           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   58834             :                   }
   58835             :                else
   58836             :                   {
   58837           0 :                     if ( pointerOfLinkedList == NULL )
   58838             :                        {
   58839           0 :                          SgOmpFinalClause::next_node = &(pointer[i]);
   58840             :                        }
   58841             :                     else
   58842             :                        {
   58843             :                       // printf ("In SgOmpFinalClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   58844           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   58845             :                        }
   58846             :                     pointerOfLinkedList = &(pointer[i]);
   58847             :                   }
   58848             :               }
   58849             :         }
   58850             : 
   58851           5 :      if ( pointerOfLinkedList != NULL )
   58852             :         {
   58853             :        // printf ("In SgOmpFinalClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   58854           0 :           pointerOfLinkedList->set_freepointer(NULL);
   58855             :        // DQ (6/6/2010): Temporary debugging...
   58856             :        //   ROSE_ASSERT(false);
   58857             :         }
   58858             : 
   58859           5 :      return ;
   58860             :    }
   58861             : 
   58862             : //############################################################################
   58863             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   58864             :  * within the memory pool and resets the freepointers, in order to achieve a 
   58865             :  * linked list, that has no jumps and starts at the beginning! This function 
   58866             :  * does not extend the memory pool, since we do not delete any memory blocks,
   58867             :  * but delete the valid objects.  
   58868             :  */
   58869             : void
   58870           0 : SgOmpFinalClause::clearMemoryPool( )
   58871             :    {
   58872             :   // printf ("Inside of SgOmpFinalClause::clearMemoryPool() \n");
   58873             : 
   58874           0 :      SgOmpFinalClause* pointer = NULL, *tempPointer = NULL;
   58875           0 :      std::vector < unsigned char* > :: const_iterator block;
   58876           0 :      if ( SgOmpFinalClause::pools.empty() == false )
   58877             :         {
   58878           0 :           block = SgOmpFinalClause::pools.begin() ;
   58879           0 :           SgOmpFinalClause::next_node = (SgOmpFinalClause*) (*block);
   58880             : 
   58881           0 :           while ( block != SgOmpFinalClause::pools.end() )
   58882             :              {
   58883           0 :                pointer = (SgOmpFinalClause*) (*block);
   58884           0 :                if ( tempPointer != NULL )
   58885             :                   {
   58886           0 :                     tempPointer->set_freepointer(pointer);
   58887             :                   }
   58888           0 :                for (unsigned i = 0; i < SgOmpFinalClause::pool_size - 1; ++i)
   58889             :                   {
   58890           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   58891             :                   }
   58892           0 :                 pointer[SgOmpFinalClause::pool_size-1].set_freepointer(NULL);
   58893           0 :                 tempPointer = &(pointer[SgOmpFinalClause::pool_size-1]);
   58894           0 :                 ++block;
   58895             :              }
   58896             :         }
   58897           0 :    }
   58898             : 
   58899           5 : void SgOmpFinalClause::deleteMemoryPool() {
   58900           5 :   for (auto p: SgOmpFinalClause::pools) {
   58901           0 :     ROSE_FREE(p);
   58902             :   }
   58903           5 :   SgOmpFinalClause::next_node = nullptr;
   58904           5 :   SgOmpFinalClause::pools.clear();
   58905           5 : }
   58906             : 
   58907             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   58908             : //                 reading multiple binary files to for a single AST.
   58909             : /////////// new version ////////////////////////////////
   58910             : //############################################################################
   58911             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   58912             : void
   58913           2 : SgOmpFinalClause::extendMemoryPoolForFileIO( )
   58914             :   {
   58915           2 :     size_t blockIndex = SgOmpFinalClause::pools.size();
   58916           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFinalClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFinalClause);
   58917             : 
   58918           2 :     while ( (blockIndex * SgOmpFinalClause::pool_size) < newPoolSize)
   58919             :       {
   58920             : #if ROSE_ALLOC_TRACE
   58921             :         if (blockIndex > 0) {
   58922             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFinalClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFinalClause) = %" PRIuPTR " SgOmpFinalClause::pool_size = %d \n",
   58923             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFinalClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFinalClause),SgOmpFinalClause::pool_size);
   58924             :         }
   58925             : #endif
   58926             : 
   58927           0 :         SgOmpFinalClause * pointer = (SgOmpFinalClause*) ROSE_MALLOC ( SgOmpFinalClause::pool_size * sizeof(SgOmpFinalClause) );
   58928           0 :         assert( pointer != NULL );
   58929             : #if ROSE_ALLOC_MEMSET == 1
   58930             :         memset(pointer, 0x00, SgOmpFinalClause::pool_size * sizeof(SgOmpFinalClause));
   58931             : #elif ROSE_ALLOC_MEMSET == 2
   58932             :         memset(pointer, 0xCC, SgOmpFinalClause::pool_size * sizeof(SgOmpFinalClause));
   58933             : #endif
   58934           0 :         SgOmpFinalClause::pools.push_back( (unsigned char*)(pointer) );
   58935           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpFinalClause::pool_size * sizeof(SgOmpFinalClause), V_SgOmpFinalClause ) );
   58936             : 
   58937           0 :         if ( SgOmpFinalClause::next_node != NULL ) {
   58938           0 :           if ( blockIndex > 0 ) {
   58939           0 :             SgOmpFinalClause * blkptr = (SgOmpFinalClause*)(SgOmpFinalClause::pools[blockIndex-1]);
   58940           0 :             blkptr[ SgOmpFinalClause::pool_size - 1 ].set_freepointer(pointer);
   58941             :           }
   58942             :         } else {
   58943           0 :           SgOmpFinalClause::next_node = pointer;
   58944             :         }
   58945             : 
   58946           0 :         for (unsigned i = 0; i < SgOmpFinalClause::pool_size-1; ++i)
   58947             :            {
   58948           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   58949             :            }
   58950           0 :         pointer[ SgOmpFinalClause::pool_size -1 ].set_freepointer(NULL);
   58951             : 
   58952           0 :         blockIndex++;
   58953             :       }
   58954           2 :   }
   58955             : 
   58956             : //############################################################################
   58957             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   58958             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   58959             :  * not compressed. However, that stuff is not yet implemented! 
   58960             :  */
   58961             : unsigned long
   58962           0 : SgOmpFinalClause::getNumberOfLastValidPointer()
   58963             :    {
   58964           0 :       SgOmpFinalClause* testPointer = (SgOmpFinalClause*)(SgOmpFinalClause::pools.back());
   58965           0 :       unsigned long localIndex = SgOmpFinalClause::pool_size - 1;
   58966           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   58967             :          {
   58968           0 :            localIndex--;
   58969             :          }
   58970           0 :       return (localIndex + SgOmpFinalClause::pool_size * (SgOmpFinalClause::pools.size()-1));
   58971             :    }
   58972             : 
   58973             : //############################################################################
   58974             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   58975             :  * memory pool and initializes the data member in class SgOmpFinalClauseStroageClass
   58976             :  * from its counterpart of SgOmpFinalClause. The return value is just for checking, 
   58977             :  * that the whole StorageClassArray is initialized!
   58978             :  */
   58979             : unsigned long
   58980           0 : SgOmpFinalClause::initializeStorageClassArray( SgOmpFinalClauseStorageClass *storageArray )
   58981             :    {
   58982           0 :      unsigned long storageCounter = 0;
   58983           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpFinalClause::pools.begin();
   58984           0 :      SgOmpFinalClause* pointer = NULL;
   58985           0 :      while ( block != SgOmpFinalClause::pools.end() ) {
   58986           0 :           pointer = (SgOmpFinalClause*) (*block);
   58987           0 :           for ( unsigned i = 0; i < SgOmpFinalClause::pool_size; ++i ) {
   58988           0 :                if ( pointer->get_freepointer() != NULL ) {
   58989           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   58990           0 :                  storageArray++;
   58991           0 :                  storageCounter++;
   58992             :                }
   58993           0 :                pointer++;
   58994             :              }
   58995           0 :            block++;
   58996             :         }
   58997           0 :      return storageCounter;
   58998             :    }
   58999             : 
   59000             : /* #line 59001 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   59001             : 
   59002             : 
   59003             : 
   59004             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   59005             : 
   59006             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   59007             : 
   59008             : //############################################################################
   59009             : /* JH (02/02/2006) Constructor of the IR node SgOmpPriorityClause that takes its 
   59010             :  * corresponding StorageClass as parameter
   59011             :  */
   59012           0 : SgOmpPriorityClause :: SgOmpPriorityClause ( const SgOmpPriorityClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   59013             :    {
   59014             : 
   59015             : 
   59016             : /* #line 59017 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   59017             : 
   59018           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   59019             : 
   59020             : 
   59021             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   59022             : 
   59023             : 
   59024           0 :    }
   59025             : 
   59026             : //############################################################################
   59027             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   59028             :  * within the working AST. 
   59029             :  */
   59030           0 : SgOmpPriorityClause * SgOmpPriorityClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   59031           0 :      SgOmpPriorityClause* returnPointer = NULL;
   59032           0 :      if ( globalIndex != 0 )
   59033             :         {
   59034             : 
   59035             : #if FILE_IO_EXTRA_CHECK
   59036           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpPriorityClause ) ) <= globalIndex ) ;
   59037           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpPriorityClause + 1 ) ) );
   59038             : #endif
   59039           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpPriorityClause )  
   59040           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpPriorityClause );
   59041           0 :           unsigned long positionInPool = localIndex % SgOmpPriorityClause::pool_size;
   59042           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpPriorityClause::pool_size;
   59043             : 
   59044             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   59045             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   59046             : 
   59047           0 :           returnPointer = &( ( (SgOmpPriorityClause*)(SgOmpPriorityClause::pools[memoryBlock]) ) [positionInPool]) ;
   59048             : 
   59049           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   59050             :         }
   59051           0 :      return returnPointer ;
   59052             :    }
   59053             : 
   59054             : //############################################################################
   59055             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   59056             :   for the AST with the index astIndex
   59057             : */
   59058           0 : SgOmpPriorityClause * SgOmpPriorityClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   59059           0 :      SgOmpPriorityClause* returnPointer = NULL;
   59060           0 :      if ( globalIndex != 0 )
   59061             :         {
   59062             : 
   59063             : #if FILE_IO_EXTRA_CHECK
   59064           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpPriorityClause ) ) <= globalIndex ) ;
   59065           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpPriorityClause + 1 ) ) );
   59066             : #endif
   59067           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpPriorityClause )
   59068           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpPriorityClause );
   59069           0 :           unsigned long positionInPool = localIndex % SgOmpPriorityClause::pool_size ;
   59070           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpPriorityClause::pool_size ;
   59071             : 
   59072             : #if FILE_IO_EXTRA_CHECK
   59073             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   59074             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   59075             : #endif
   59076             : 
   59077           0 :           returnPointer = &( ( (SgOmpPriorityClause*)(SgOmpPriorityClause::pools[memoryBlock]) ) [positionInPool]) ;
   59078             : 
   59079             : #if FILE_IO_EXTRA_CHECK
   59080           0 :           assert ( returnPointer != NULL ) ;
   59081             : #endif
   59082             :         }
   59083           0 :      return returnPointer ;
   59084             :    }
   59085             : 
   59086             : //############################################################################
   59087             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   59088             :  * pool size! We set for every valid object in the memory pool the freepointer
   59089             :  * to the global index and increase the global index afterwards. For all the 
   59090             :  * invalid objects (means address ranges within the memory pool that were not
   59091             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   59092             :  * distinguish valid from invalid objects! 
   59093             :  */
   59094             : unsigned long
   59095           5 : SgOmpPriorityClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   59096             :    {
   59097           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   59098           5 :      SgOmpPriorityClause* pointer = NULL;
   59099           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   59100           5 :      std::vector < unsigned char* > :: const_iterator block;
   59101           5 :      for ( block = SgOmpPriorityClause::pools.begin(); block != SgOmpPriorityClause::pools.end() ; ++block )
   59102             :         {
   59103           0 :           pointer = (SgOmpPriorityClause*)(*block);
   59104           0 :           for (unsigned i = 0; i < SgOmpPriorityClause::pool_size; ++i )
   59105             :              {
   59106             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   59107             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   59108             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   59109             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   59110             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   59111             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   59112             :             // properly; so this will have to be checked next.
   59113             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   59114             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   59115           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   59116             :                   {
   59117           0 :                     pointer[i].set_freepointer((SgOmpPriorityClause*)(globalIndex));
   59118           0 :                     globalIndex++;
   59119             :                   }
   59120             :                else
   59121             :                   {
   59122           0 :                     pointer[i].set_freepointer(NULL);
   59123             :                   }
   59124             :               }
   59125             :         }
   59126           5 :      return globalIndex;
   59127             :    }
   59128             : 
   59129             : //############################################################################
   59130             : // JH (01/14/2006)
   59131             : void
   59132           5 : SgOmpPriorityClause::resetValidFreepointers( )
   59133             :    {
   59134           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   59135           5 :      SgOmpPriorityClause* pointer = NULL;
   59136           5 :      std::vector < unsigned char* > :: const_iterator block;
   59137           5 :      SgOmpPriorityClause* pointerOfLinkedList = NULL;
   59138           5 :      for ( block = SgOmpPriorityClause::pools.begin(); block != SgOmpPriorityClause::pools.end() ; ++block )
   59139             :         {
   59140           0 :           pointer = (SgOmpPriorityClause*)(*block);
   59141           0 :           for (unsigned i = 0; i < SgOmpPriorityClause::pool_size; ++i )
   59142             :              {
   59143             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   59144             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   59145             :             // memory blocks!.
   59146           0 :                if ( pointer[i].get_freepointer() != NULL )
   59147             :                   {
   59148           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   59149             :                   }
   59150             :                else
   59151             :                   {
   59152           0 :                     if ( pointerOfLinkedList == NULL )
   59153             :                        {
   59154           0 :                          SgOmpPriorityClause::next_node = &(pointer[i]);
   59155             :                        }
   59156             :                     else
   59157             :                        {
   59158             :                       // printf ("In SgOmpPriorityClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   59159           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   59160             :                        }
   59161             :                     pointerOfLinkedList = &(pointer[i]);
   59162             :                   }
   59163             :               }
   59164             :         }
   59165             : 
   59166           5 :      if ( pointerOfLinkedList != NULL )
   59167             :         {
   59168             :        // printf ("In SgOmpPriorityClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   59169           0 :           pointerOfLinkedList->set_freepointer(NULL);
   59170             :        // DQ (6/6/2010): Temporary debugging...
   59171             :        //   ROSE_ASSERT(false);
   59172             :         }
   59173             : 
   59174           5 :      return ;
   59175             :    }
   59176             : 
   59177             : //############################################################################
   59178             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   59179             :  * within the memory pool and resets the freepointers, in order to achieve a 
   59180             :  * linked list, that has no jumps and starts at the beginning! This function 
   59181             :  * does not extend the memory pool, since we do not delete any memory blocks,
   59182             :  * but delete the valid objects.  
   59183             :  */
   59184             : void
   59185           0 : SgOmpPriorityClause::clearMemoryPool( )
   59186             :    {
   59187             :   // printf ("Inside of SgOmpPriorityClause::clearMemoryPool() \n");
   59188             : 
   59189           0 :      SgOmpPriorityClause* pointer = NULL, *tempPointer = NULL;
   59190           0 :      std::vector < unsigned char* > :: const_iterator block;
   59191           0 :      if ( SgOmpPriorityClause::pools.empty() == false )
   59192             :         {
   59193           0 :           block = SgOmpPriorityClause::pools.begin() ;
   59194           0 :           SgOmpPriorityClause::next_node = (SgOmpPriorityClause*) (*block);
   59195             : 
   59196           0 :           while ( block != SgOmpPriorityClause::pools.end() )
   59197             :              {
   59198           0 :                pointer = (SgOmpPriorityClause*) (*block);
   59199           0 :                if ( tempPointer != NULL )
   59200             :                   {
   59201           0 :                     tempPointer->set_freepointer(pointer);
   59202             :                   }
   59203           0 :                for (unsigned i = 0; i < SgOmpPriorityClause::pool_size - 1; ++i)
   59204             :                   {
   59205           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   59206             :                   }
   59207           0 :                 pointer[SgOmpPriorityClause::pool_size-1].set_freepointer(NULL);
   59208           0 :                 tempPointer = &(pointer[SgOmpPriorityClause::pool_size-1]);
   59209           0 :                 ++block;
   59210             :              }
   59211             :         }
   59212           0 :    }
   59213             : 
   59214           5 : void SgOmpPriorityClause::deleteMemoryPool() {
   59215           5 :   for (auto p: SgOmpPriorityClause::pools) {
   59216           0 :     ROSE_FREE(p);
   59217             :   }
   59218           5 :   SgOmpPriorityClause::next_node = nullptr;
   59219           5 :   SgOmpPriorityClause::pools.clear();
   59220           5 : }
   59221             : 
   59222             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   59223             : //                 reading multiple binary files to for a single AST.
   59224             : /////////// new version ////////////////////////////////
   59225             : //############################################################################
   59226             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   59227             : void
   59228           2 : SgOmpPriorityClause::extendMemoryPoolForFileIO( )
   59229             :   {
   59230           2 :     size_t blockIndex = SgOmpPriorityClause::pools.size();
   59231           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPriorityClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPriorityClause);
   59232             : 
   59233           2 :     while ( (blockIndex * SgOmpPriorityClause::pool_size) < newPoolSize)
   59234             :       {
   59235             : #if ROSE_ALLOC_TRACE
   59236             :         if (blockIndex > 0) {
   59237             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPriorityClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPriorityClause) = %" PRIuPTR " SgOmpPriorityClause::pool_size = %d \n",
   59238             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPriorityClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPriorityClause),SgOmpPriorityClause::pool_size);
   59239             :         }
   59240             : #endif
   59241             : 
   59242           0 :         SgOmpPriorityClause * pointer = (SgOmpPriorityClause*) ROSE_MALLOC ( SgOmpPriorityClause::pool_size * sizeof(SgOmpPriorityClause) );
   59243           0 :         assert( pointer != NULL );
   59244             : #if ROSE_ALLOC_MEMSET == 1
   59245             :         memset(pointer, 0x00, SgOmpPriorityClause::pool_size * sizeof(SgOmpPriorityClause));
   59246             : #elif ROSE_ALLOC_MEMSET == 2
   59247             :         memset(pointer, 0xCC, SgOmpPriorityClause::pool_size * sizeof(SgOmpPriorityClause));
   59248             : #endif
   59249           0 :         SgOmpPriorityClause::pools.push_back( (unsigned char*)(pointer) );
   59250           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpPriorityClause::pool_size * sizeof(SgOmpPriorityClause), V_SgOmpPriorityClause ) );
   59251             : 
   59252           0 :         if ( SgOmpPriorityClause::next_node != NULL ) {
   59253           0 :           if ( blockIndex > 0 ) {
   59254           0 :             SgOmpPriorityClause * blkptr = (SgOmpPriorityClause*)(SgOmpPriorityClause::pools[blockIndex-1]);
   59255           0 :             blkptr[ SgOmpPriorityClause::pool_size - 1 ].set_freepointer(pointer);
   59256             :           }
   59257             :         } else {
   59258           0 :           SgOmpPriorityClause::next_node = pointer;
   59259             :         }
   59260             : 
   59261           0 :         for (unsigned i = 0; i < SgOmpPriorityClause::pool_size-1; ++i)
   59262             :            {
   59263           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   59264             :            }
   59265           0 :         pointer[ SgOmpPriorityClause::pool_size -1 ].set_freepointer(NULL);
   59266             : 
   59267           0 :         blockIndex++;
   59268             :       }
   59269           2 :   }
   59270             : 
   59271             : //############################################################################
   59272             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   59273             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   59274             :  * not compressed. However, that stuff is not yet implemented! 
   59275             :  */
   59276             : unsigned long
   59277           0 : SgOmpPriorityClause::getNumberOfLastValidPointer()
   59278             :    {
   59279           0 :       SgOmpPriorityClause* testPointer = (SgOmpPriorityClause*)(SgOmpPriorityClause::pools.back());
   59280           0 :       unsigned long localIndex = SgOmpPriorityClause::pool_size - 1;
   59281           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   59282             :          {
   59283           0 :            localIndex--;
   59284             :          }
   59285           0 :       return (localIndex + SgOmpPriorityClause::pool_size * (SgOmpPriorityClause::pools.size()-1));
   59286             :    }
   59287             : 
   59288             : //############################################################################
   59289             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   59290             :  * memory pool and initializes the data member in class SgOmpPriorityClauseStroageClass
   59291             :  * from its counterpart of SgOmpPriorityClause. The return value is just for checking, 
   59292             :  * that the whole StorageClassArray is initialized!
   59293             :  */
   59294             : unsigned long
   59295           0 : SgOmpPriorityClause::initializeStorageClassArray( SgOmpPriorityClauseStorageClass *storageArray )
   59296             :    {
   59297           0 :      unsigned long storageCounter = 0;
   59298           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpPriorityClause::pools.begin();
   59299           0 :      SgOmpPriorityClause* pointer = NULL;
   59300           0 :      while ( block != SgOmpPriorityClause::pools.end() ) {
   59301           0 :           pointer = (SgOmpPriorityClause*) (*block);
   59302           0 :           for ( unsigned i = 0; i < SgOmpPriorityClause::pool_size; ++i ) {
   59303           0 :                if ( pointer->get_freepointer() != NULL ) {
   59304           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   59305           0 :                  storageArray++;
   59306           0 :                  storageCounter++;
   59307             :                }
   59308           0 :                pointer++;
   59309             :              }
   59310           0 :            block++;
   59311             :         }
   59312           0 :      return storageCounter;
   59313             :    }
   59314             : 
   59315             : /* #line 59316 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   59316             : 
   59317             : 
   59318             : 
   59319             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   59320             : 
   59321             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   59322             : 
   59323             : //############################################################################
   59324             : /* JH (02/02/2006) Constructor of the IR node SgOmpPartialClause that takes its 
   59325             :  * corresponding StorageClass as parameter
   59326             :  */
   59327           0 : SgOmpPartialClause :: SgOmpPartialClause ( const SgOmpPartialClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   59328             :    {
   59329             : 
   59330             : 
   59331             : /* #line 59332 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   59332             : 
   59333           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   59334             : 
   59335             : 
   59336             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   59337             : 
   59338             : 
   59339           0 :    }
   59340             : 
   59341             : //############################################################################
   59342             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   59343             :  * within the working AST. 
   59344             :  */
   59345           0 : SgOmpPartialClause * SgOmpPartialClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   59346           0 :      SgOmpPartialClause* returnPointer = NULL;
   59347           0 :      if ( globalIndex != 0 )
   59348             :         {
   59349             : 
   59350             : #if FILE_IO_EXTRA_CHECK
   59351           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpPartialClause ) ) <= globalIndex ) ;
   59352           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpPartialClause + 1 ) ) );
   59353             : #endif
   59354           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpPartialClause )  
   59355           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpPartialClause );
   59356           0 :           unsigned long positionInPool = localIndex % SgOmpPartialClause::pool_size;
   59357           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpPartialClause::pool_size;
   59358             : 
   59359             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   59360             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   59361             : 
   59362           0 :           returnPointer = &( ( (SgOmpPartialClause*)(SgOmpPartialClause::pools[memoryBlock]) ) [positionInPool]) ;
   59363             : 
   59364           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   59365             :         }
   59366           0 :      return returnPointer ;
   59367             :    }
   59368             : 
   59369             : //############################################################################
   59370             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   59371             :   for the AST with the index astIndex
   59372             : */
   59373           0 : SgOmpPartialClause * SgOmpPartialClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   59374           0 :      SgOmpPartialClause* returnPointer = NULL;
   59375           0 :      if ( globalIndex != 0 )
   59376             :         {
   59377             : 
   59378             : #if FILE_IO_EXTRA_CHECK
   59379           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpPartialClause ) ) <= globalIndex ) ;
   59380           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpPartialClause + 1 ) ) );
   59381             : #endif
   59382           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpPartialClause )
   59383           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpPartialClause );
   59384           0 :           unsigned long positionInPool = localIndex % SgOmpPartialClause::pool_size ;
   59385           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpPartialClause::pool_size ;
   59386             : 
   59387             : #if FILE_IO_EXTRA_CHECK
   59388             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   59389             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   59390             : #endif
   59391             : 
   59392           0 :           returnPointer = &( ( (SgOmpPartialClause*)(SgOmpPartialClause::pools[memoryBlock]) ) [positionInPool]) ;
   59393             : 
   59394             : #if FILE_IO_EXTRA_CHECK
   59395           0 :           assert ( returnPointer != NULL ) ;
   59396             : #endif
   59397             :         }
   59398           0 :      return returnPointer ;
   59399             :    }
   59400             : 
   59401             : //############################################################################
   59402             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   59403             :  * pool size! We set for every valid object in the memory pool the freepointer
   59404             :  * to the global index and increase the global index afterwards. For all the 
   59405             :  * invalid objects (means address ranges within the memory pool that were not
   59406             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   59407             :  * distinguish valid from invalid objects! 
   59408             :  */
   59409             : unsigned long
   59410           5 : SgOmpPartialClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   59411             :    {
   59412           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   59413           5 :      SgOmpPartialClause* pointer = NULL;
   59414           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   59415           5 :      std::vector < unsigned char* > :: const_iterator block;
   59416           5 :      for ( block = SgOmpPartialClause::pools.begin(); block != SgOmpPartialClause::pools.end() ; ++block )
   59417             :         {
   59418           0 :           pointer = (SgOmpPartialClause*)(*block);
   59419           0 :           for (unsigned i = 0; i < SgOmpPartialClause::pool_size; ++i )
   59420             :              {
   59421             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   59422             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   59423             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   59424             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   59425             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   59426             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   59427             :             // properly; so this will have to be checked next.
   59428             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   59429             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   59430           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   59431             :                   {
   59432           0 :                     pointer[i].set_freepointer((SgOmpPartialClause*)(globalIndex));
   59433           0 :                     globalIndex++;
   59434             :                   }
   59435             :                else
   59436             :                   {
   59437           0 :                     pointer[i].set_freepointer(NULL);
   59438             :                   }
   59439             :               }
   59440             :         }
   59441           5 :      return globalIndex;
   59442             :    }
   59443             : 
   59444             : //############################################################################
   59445             : // JH (01/14/2006)
   59446             : void
   59447           5 : SgOmpPartialClause::resetValidFreepointers( )
   59448             :    {
   59449           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   59450           5 :      SgOmpPartialClause* pointer = NULL;
   59451           5 :      std::vector < unsigned char* > :: const_iterator block;
   59452           5 :      SgOmpPartialClause* pointerOfLinkedList = NULL;
   59453           5 :      for ( block = SgOmpPartialClause::pools.begin(); block != SgOmpPartialClause::pools.end() ; ++block )
   59454             :         {
   59455           0 :           pointer = (SgOmpPartialClause*)(*block);
   59456           0 :           for (unsigned i = 0; i < SgOmpPartialClause::pool_size; ++i )
   59457             :              {
   59458             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   59459             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   59460             :             // memory blocks!.
   59461           0 :                if ( pointer[i].get_freepointer() != NULL )
   59462             :                   {
   59463           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   59464             :                   }
   59465             :                else
   59466             :                   {
   59467           0 :                     if ( pointerOfLinkedList == NULL )
   59468             :                        {
   59469           0 :                          SgOmpPartialClause::next_node = &(pointer[i]);
   59470             :                        }
   59471             :                     else
   59472             :                        {
   59473             :                       // printf ("In SgOmpPartialClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   59474           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   59475             :                        }
   59476             :                     pointerOfLinkedList = &(pointer[i]);
   59477             :                   }
   59478             :               }
   59479             :         }
   59480             : 
   59481           5 :      if ( pointerOfLinkedList != NULL )
   59482             :         {
   59483             :        // printf ("In SgOmpPartialClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   59484           0 :           pointerOfLinkedList->set_freepointer(NULL);
   59485             :        // DQ (6/6/2010): Temporary debugging...
   59486             :        //   ROSE_ASSERT(false);
   59487             :         }
   59488             : 
   59489           5 :      return ;
   59490             :    }
   59491             : 
   59492             : //############################################################################
   59493             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   59494             :  * within the memory pool and resets the freepointers, in order to achieve a 
   59495             :  * linked list, that has no jumps and starts at the beginning! This function 
   59496             :  * does not extend the memory pool, since we do not delete any memory blocks,
   59497             :  * but delete the valid objects.  
   59498             :  */
   59499             : void
   59500           0 : SgOmpPartialClause::clearMemoryPool( )
   59501             :    {
   59502             :   // printf ("Inside of SgOmpPartialClause::clearMemoryPool() \n");
   59503             : 
   59504           0 :      SgOmpPartialClause* pointer = NULL, *tempPointer = NULL;
   59505           0 :      std::vector < unsigned char* > :: const_iterator block;
   59506           0 :      if ( SgOmpPartialClause::pools.empty() == false )
   59507             :         {
   59508           0 :           block = SgOmpPartialClause::pools.begin() ;
   59509           0 :           SgOmpPartialClause::next_node = (SgOmpPartialClause*) (*block);
   59510             : 
   59511           0 :           while ( block != SgOmpPartialClause::pools.end() )
   59512             :              {
   59513           0 :                pointer = (SgOmpPartialClause*) (*block);
   59514           0 :                if ( tempPointer != NULL )
   59515             :                   {
   59516           0 :                     tempPointer->set_freepointer(pointer);
   59517             :                   }
   59518           0 :                for (unsigned i = 0; i < SgOmpPartialClause::pool_size - 1; ++i)
   59519             :                   {
   59520           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   59521             :                   }
   59522           0 :                 pointer[SgOmpPartialClause::pool_size-1].set_freepointer(NULL);
   59523           0 :                 tempPointer = &(pointer[SgOmpPartialClause::pool_size-1]);
   59524           0 :                 ++block;
   59525             :              }
   59526             :         }
   59527           0 :    }
   59528             : 
   59529           5 : void SgOmpPartialClause::deleteMemoryPool() {
   59530           5 :   for (auto p: SgOmpPartialClause::pools) {
   59531           0 :     ROSE_FREE(p);
   59532             :   }
   59533           5 :   SgOmpPartialClause::next_node = nullptr;
   59534           5 :   SgOmpPartialClause::pools.clear();
   59535           5 : }
   59536             : 
   59537             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   59538             : //                 reading multiple binary files to for a single AST.
   59539             : /////////// new version ////////////////////////////////
   59540             : //############################################################################
   59541             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   59542             : void
   59543           2 : SgOmpPartialClause::extendMemoryPoolForFileIO( )
   59544             :   {
   59545           2 :     size_t blockIndex = SgOmpPartialClause::pools.size();
   59546           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPartialClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPartialClause);
   59547             : 
   59548           2 :     while ( (blockIndex * SgOmpPartialClause::pool_size) < newPoolSize)
   59549             :       {
   59550             : #if ROSE_ALLOC_TRACE
   59551             :         if (blockIndex > 0) {
   59552             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPartialClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPartialClause) = %" PRIuPTR " SgOmpPartialClause::pool_size = %d \n",
   59553             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPartialClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPartialClause),SgOmpPartialClause::pool_size);
   59554             :         }
   59555             : #endif
   59556             : 
   59557           0 :         SgOmpPartialClause * pointer = (SgOmpPartialClause*) ROSE_MALLOC ( SgOmpPartialClause::pool_size * sizeof(SgOmpPartialClause) );
   59558           0 :         assert( pointer != NULL );
   59559             : #if ROSE_ALLOC_MEMSET == 1
   59560             :         memset(pointer, 0x00, SgOmpPartialClause::pool_size * sizeof(SgOmpPartialClause));
   59561             : #elif ROSE_ALLOC_MEMSET == 2
   59562             :         memset(pointer, 0xCC, SgOmpPartialClause::pool_size * sizeof(SgOmpPartialClause));
   59563             : #endif
   59564           0 :         SgOmpPartialClause::pools.push_back( (unsigned char*)(pointer) );
   59565           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpPartialClause::pool_size * sizeof(SgOmpPartialClause), V_SgOmpPartialClause ) );
   59566             : 
   59567           0 :         if ( SgOmpPartialClause::next_node != NULL ) {
   59568           0 :           if ( blockIndex > 0 ) {
   59569           0 :             SgOmpPartialClause * blkptr = (SgOmpPartialClause*)(SgOmpPartialClause::pools[blockIndex-1]);
   59570           0 :             blkptr[ SgOmpPartialClause::pool_size - 1 ].set_freepointer(pointer);
   59571             :           }
   59572             :         } else {
   59573           0 :           SgOmpPartialClause::next_node = pointer;
   59574             :         }
   59575             : 
   59576           0 :         for (unsigned i = 0; i < SgOmpPartialClause::pool_size-1; ++i)
   59577             :            {
   59578           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   59579             :            }
   59580           0 :         pointer[ SgOmpPartialClause::pool_size -1 ].set_freepointer(NULL);
   59581             : 
   59582           0 :         blockIndex++;
   59583             :       }
   59584           2 :   }
   59585             : 
   59586             : //############################################################################
   59587             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   59588             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   59589             :  * not compressed. However, that stuff is not yet implemented! 
   59590             :  */
   59591             : unsigned long
   59592           0 : SgOmpPartialClause::getNumberOfLastValidPointer()
   59593             :    {
   59594           0 :       SgOmpPartialClause* testPointer = (SgOmpPartialClause*)(SgOmpPartialClause::pools.back());
   59595           0 :       unsigned long localIndex = SgOmpPartialClause::pool_size - 1;
   59596           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   59597             :          {
   59598           0 :            localIndex--;
   59599             :          }
   59600           0 :       return (localIndex + SgOmpPartialClause::pool_size * (SgOmpPartialClause::pools.size()-1));
   59601             :    }
   59602             : 
   59603             : //############################################################################
   59604             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   59605             :  * memory pool and initializes the data member in class SgOmpPartialClauseStroageClass
   59606             :  * from its counterpart of SgOmpPartialClause. The return value is just for checking, 
   59607             :  * that the whole StorageClassArray is initialized!
   59608             :  */
   59609             : unsigned long
   59610           0 : SgOmpPartialClause::initializeStorageClassArray( SgOmpPartialClauseStorageClass *storageArray )
   59611             :    {
   59612           0 :      unsigned long storageCounter = 0;
   59613           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpPartialClause::pools.begin();
   59614           0 :      SgOmpPartialClause* pointer = NULL;
   59615           0 :      while ( block != SgOmpPartialClause::pools.end() ) {
   59616           0 :           pointer = (SgOmpPartialClause*) (*block);
   59617           0 :           for ( unsigned i = 0; i < SgOmpPartialClause::pool_size; ++i ) {
   59618           0 :                if ( pointer->get_freepointer() != NULL ) {
   59619           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   59620           0 :                  storageArray++;
   59621           0 :                  storageCounter++;
   59622             :                }
   59623           0 :                pointer++;
   59624             :              }
   59625           0 :            block++;
   59626             :         }
   59627           0 :      return storageCounter;
   59628             :    }
   59629             : 
   59630             : /* #line 59631 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   59631             : 
   59632             : 
   59633             : 
   59634             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   59635             : 
   59636             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   59637             : 
   59638             : //############################################################################
   59639             : /* JH (02/02/2006) Constructor of the IR node SgOmpSizesClause that takes its 
   59640             :  * corresponding StorageClass as parameter
   59641             :  */
   59642           0 : SgOmpSizesClause :: SgOmpSizesClause ( const SgOmpSizesClauseStorageClass& storageSource )   : SgOmpExpressionClause (storageSource)
   59643             :    {
   59644             : 
   59645             : 
   59646             : /* #line 59647 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   59647             : 
   59648           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   59649             : 
   59650             : 
   59651             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   59652             : 
   59653             : 
   59654           0 :    }
   59655             : 
   59656             : //############################################################################
   59657             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   59658             :  * within the working AST. 
   59659             :  */
   59660           0 : SgOmpSizesClause * SgOmpSizesClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   59661           0 :      SgOmpSizesClause* returnPointer = NULL;
   59662           0 :      if ( globalIndex != 0 )
   59663             :         {
   59664             : 
   59665             : #if FILE_IO_EXTRA_CHECK
   59666           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSizesClause ) ) <= globalIndex ) ;
   59667           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSizesClause + 1 ) ) );
   59668             : #endif
   59669           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSizesClause )  
   59670           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSizesClause );
   59671           0 :           unsigned long positionInPool = localIndex % SgOmpSizesClause::pool_size;
   59672           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSizesClause::pool_size;
   59673             : 
   59674             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   59675             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   59676             : 
   59677           0 :           returnPointer = &( ( (SgOmpSizesClause*)(SgOmpSizesClause::pools[memoryBlock]) ) [positionInPool]) ;
   59678             : 
   59679           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   59680             :         }
   59681           0 :      return returnPointer ;
   59682             :    }
   59683             : 
   59684             : //############################################################################
   59685             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   59686             :   for the AST with the index astIndex
   59687             : */
   59688           0 : SgOmpSizesClause * SgOmpSizesClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   59689           0 :      SgOmpSizesClause* returnPointer = NULL;
   59690           0 :      if ( globalIndex != 0 )
   59691             :         {
   59692             : 
   59693             : #if FILE_IO_EXTRA_CHECK
   59694           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSizesClause ) ) <= globalIndex ) ;
   59695           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSizesClause + 1 ) ) );
   59696             : #endif
   59697           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSizesClause )
   59698           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSizesClause );
   59699           0 :           unsigned long positionInPool = localIndex % SgOmpSizesClause::pool_size ;
   59700           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSizesClause::pool_size ;
   59701             : 
   59702             : #if FILE_IO_EXTRA_CHECK
   59703             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   59704             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   59705             : #endif
   59706             : 
   59707           0 :           returnPointer = &( ( (SgOmpSizesClause*)(SgOmpSizesClause::pools[memoryBlock]) ) [positionInPool]) ;
   59708             : 
   59709             : #if FILE_IO_EXTRA_CHECK
   59710           0 :           assert ( returnPointer != NULL ) ;
   59711             : #endif
   59712             :         }
   59713           0 :      return returnPointer ;
   59714             :    }
   59715             : 
   59716             : //############################################################################
   59717             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   59718             :  * pool size! We set for every valid object in the memory pool the freepointer
   59719             :  * to the global index and increase the global index afterwards. For all the 
   59720             :  * invalid objects (means address ranges within the memory pool that were not
   59721             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   59722             :  * distinguish valid from invalid objects! 
   59723             :  */
   59724             : unsigned long
   59725           5 : SgOmpSizesClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   59726             :    {
   59727           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   59728           5 :      SgOmpSizesClause* pointer = NULL;
   59729           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   59730           5 :      std::vector < unsigned char* > :: const_iterator block;
   59731           5 :      for ( block = SgOmpSizesClause::pools.begin(); block != SgOmpSizesClause::pools.end() ; ++block )
   59732             :         {
   59733           0 :           pointer = (SgOmpSizesClause*)(*block);
   59734           0 :           for (unsigned i = 0; i < SgOmpSizesClause::pool_size; ++i )
   59735             :              {
   59736             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   59737             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   59738             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   59739             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   59740             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   59741             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   59742             :             // properly; so this will have to be checked next.
   59743             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   59744             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   59745           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   59746             :                   {
   59747           0 :                     pointer[i].set_freepointer((SgOmpSizesClause*)(globalIndex));
   59748           0 :                     globalIndex++;
   59749             :                   }
   59750             :                else
   59751             :                   {
   59752           0 :                     pointer[i].set_freepointer(NULL);
   59753             :                   }
   59754             :               }
   59755             :         }
   59756           5 :      return globalIndex;
   59757             :    }
   59758             : 
   59759             : //############################################################################
   59760             : // JH (01/14/2006)
   59761             : void
   59762           5 : SgOmpSizesClause::resetValidFreepointers( )
   59763             :    {
   59764           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   59765           5 :      SgOmpSizesClause* pointer = NULL;
   59766           5 :      std::vector < unsigned char* > :: const_iterator block;
   59767           5 :      SgOmpSizesClause* pointerOfLinkedList = NULL;
   59768           5 :      for ( block = SgOmpSizesClause::pools.begin(); block != SgOmpSizesClause::pools.end() ; ++block )
   59769             :         {
   59770           0 :           pointer = (SgOmpSizesClause*)(*block);
   59771           0 :           for (unsigned i = 0; i < SgOmpSizesClause::pool_size; ++i )
   59772             :              {
   59773             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   59774             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   59775             :             // memory blocks!.
   59776           0 :                if ( pointer[i].get_freepointer() != NULL )
   59777             :                   {
   59778           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   59779             :                   }
   59780             :                else
   59781             :                   {
   59782           0 :                     if ( pointerOfLinkedList == NULL )
   59783             :                        {
   59784           0 :                          SgOmpSizesClause::next_node = &(pointer[i]);
   59785             :                        }
   59786             :                     else
   59787             :                        {
   59788             :                       // printf ("In SgOmpSizesClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   59789           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   59790             :                        }
   59791             :                     pointerOfLinkedList = &(pointer[i]);
   59792             :                   }
   59793             :               }
   59794             :         }
   59795             : 
   59796           5 :      if ( pointerOfLinkedList != NULL )
   59797             :         {
   59798             :        // printf ("In SgOmpSizesClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   59799           0 :           pointerOfLinkedList->set_freepointer(NULL);
   59800             :        // DQ (6/6/2010): Temporary debugging...
   59801             :        //   ROSE_ASSERT(false);
   59802             :         }
   59803             : 
   59804           5 :      return ;
   59805             :    }
   59806             : 
   59807             : //############################################################################
   59808             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   59809             :  * within the memory pool and resets the freepointers, in order to achieve a 
   59810             :  * linked list, that has no jumps and starts at the beginning! This function 
   59811             :  * does not extend the memory pool, since we do not delete any memory blocks,
   59812             :  * but delete the valid objects.  
   59813             :  */
   59814             : void
   59815           0 : SgOmpSizesClause::clearMemoryPool( )
   59816             :    {
   59817             :   // printf ("Inside of SgOmpSizesClause::clearMemoryPool() \n");
   59818             : 
   59819           0 :      SgOmpSizesClause* pointer = NULL, *tempPointer = NULL;
   59820           0 :      std::vector < unsigned char* > :: const_iterator block;
   59821           0 :      if ( SgOmpSizesClause::pools.empty() == false )
   59822             :         {
   59823           0 :           block = SgOmpSizesClause::pools.begin() ;
   59824           0 :           SgOmpSizesClause::next_node = (SgOmpSizesClause*) (*block);
   59825             : 
   59826           0 :           while ( block != SgOmpSizesClause::pools.end() )
   59827             :              {
   59828           0 :                pointer = (SgOmpSizesClause*) (*block);
   59829           0 :                if ( tempPointer != NULL )
   59830             :                   {
   59831           0 :                     tempPointer->set_freepointer(pointer);
   59832             :                   }
   59833           0 :                for (unsigned i = 0; i < SgOmpSizesClause::pool_size - 1; ++i)
   59834             :                   {
   59835           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   59836             :                   }
   59837           0 :                 pointer[SgOmpSizesClause::pool_size-1].set_freepointer(NULL);
   59838           0 :                 tempPointer = &(pointer[SgOmpSizesClause::pool_size-1]);
   59839           0 :                 ++block;
   59840             :              }
   59841             :         }
   59842           0 :    }
   59843             : 
   59844           5 : void SgOmpSizesClause::deleteMemoryPool() {
   59845           5 :   for (auto p: SgOmpSizesClause::pools) {
   59846           0 :     ROSE_FREE(p);
   59847             :   }
   59848           5 :   SgOmpSizesClause::next_node = nullptr;
   59849           5 :   SgOmpSizesClause::pools.clear();
   59850           5 : }
   59851             : 
   59852             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   59853             : //                 reading multiple binary files to for a single AST.
   59854             : /////////// new version ////////////////////////////////
   59855             : //############################################################################
   59856             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   59857             : void
   59858           2 : SgOmpSizesClause::extendMemoryPoolForFileIO( )
   59859             :   {
   59860           2 :     size_t blockIndex = SgOmpSizesClause::pools.size();
   59861           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSizesClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSizesClause);
   59862             : 
   59863           2 :     while ( (blockIndex * SgOmpSizesClause::pool_size) < newPoolSize)
   59864             :       {
   59865             : #if ROSE_ALLOC_TRACE
   59866             :         if (blockIndex > 0) {
   59867             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSizesClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSizesClause) = %" PRIuPTR " SgOmpSizesClause::pool_size = %d \n",
   59868             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSizesClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSizesClause),SgOmpSizesClause::pool_size);
   59869             :         }
   59870             : #endif
   59871             : 
   59872           0 :         SgOmpSizesClause * pointer = (SgOmpSizesClause*) ROSE_MALLOC ( SgOmpSizesClause::pool_size * sizeof(SgOmpSizesClause) );
   59873           0 :         assert( pointer != NULL );
   59874             : #if ROSE_ALLOC_MEMSET == 1
   59875             :         memset(pointer, 0x00, SgOmpSizesClause::pool_size * sizeof(SgOmpSizesClause));
   59876             : #elif ROSE_ALLOC_MEMSET == 2
   59877             :         memset(pointer, 0xCC, SgOmpSizesClause::pool_size * sizeof(SgOmpSizesClause));
   59878             : #endif
   59879           0 :         SgOmpSizesClause::pools.push_back( (unsigned char*)(pointer) );
   59880           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSizesClause::pool_size * sizeof(SgOmpSizesClause), V_SgOmpSizesClause ) );
   59881             : 
   59882           0 :         if ( SgOmpSizesClause::next_node != NULL ) {
   59883           0 :           if ( blockIndex > 0 ) {
   59884           0 :             SgOmpSizesClause * blkptr = (SgOmpSizesClause*)(SgOmpSizesClause::pools[blockIndex-1]);
   59885           0 :             blkptr[ SgOmpSizesClause::pool_size - 1 ].set_freepointer(pointer);
   59886             :           }
   59887             :         } else {
   59888           0 :           SgOmpSizesClause::next_node = pointer;
   59889             :         }
   59890             : 
   59891           0 :         for (unsigned i = 0; i < SgOmpSizesClause::pool_size-1; ++i)
   59892             :            {
   59893           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   59894             :            }
   59895           0 :         pointer[ SgOmpSizesClause::pool_size -1 ].set_freepointer(NULL);
   59896             : 
   59897           0 :         blockIndex++;
   59898             :       }
   59899           2 :   }
   59900             : 
   59901             : //############################################################################
   59902             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   59903             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   59904             :  * not compressed. However, that stuff is not yet implemented! 
   59905             :  */
   59906             : unsigned long
   59907           0 : SgOmpSizesClause::getNumberOfLastValidPointer()
   59908             :    {
   59909           0 :       SgOmpSizesClause* testPointer = (SgOmpSizesClause*)(SgOmpSizesClause::pools.back());
   59910           0 :       unsigned long localIndex = SgOmpSizesClause::pool_size - 1;
   59911           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   59912             :          {
   59913           0 :            localIndex--;
   59914             :          }
   59915           0 :       return (localIndex + SgOmpSizesClause::pool_size * (SgOmpSizesClause::pools.size()-1));
   59916             :    }
   59917             : 
   59918             : //############################################################################
   59919             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   59920             :  * memory pool and initializes the data member in class SgOmpSizesClauseStroageClass
   59921             :  * from its counterpart of SgOmpSizesClause. The return value is just for checking, 
   59922             :  * that the whole StorageClassArray is initialized!
   59923             :  */
   59924             : unsigned long
   59925           0 : SgOmpSizesClause::initializeStorageClassArray( SgOmpSizesClauseStorageClass *storageArray )
   59926             :    {
   59927           0 :      unsigned long storageCounter = 0;
   59928           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSizesClause::pools.begin();
   59929           0 :      SgOmpSizesClause* pointer = NULL;
   59930           0 :      while ( block != SgOmpSizesClause::pools.end() ) {
   59931           0 :           pointer = (SgOmpSizesClause*) (*block);
   59932           0 :           for ( unsigned i = 0; i < SgOmpSizesClause::pool_size; ++i ) {
   59933           0 :                if ( pointer->get_freepointer() != NULL ) {
   59934           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   59935           0 :                  storageArray++;
   59936           0 :                  storageCounter++;
   59937             :                }
   59938           0 :                pointer++;
   59939             :              }
   59940           0 :            block++;
   59941             :         }
   59942           0 :      return storageCounter;
   59943             :    }
   59944             : 
   59945             : /* #line 59946 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   59946             : 
   59947             : 
   59948             : 
   59949             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   59950             : 
   59951             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   59952             : 
   59953             : //############################################################################
   59954             : /* JH (02/02/2006) Constructor of the IR node SgOmpInbranchClause that takes its 
   59955             :  * corresponding StorageClass as parameter
   59956             :  */
   59957           0 : SgOmpInbranchClause :: SgOmpInbranchClause ( const SgOmpInbranchClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   59958             :    {
   59959             : 
   59960             : 
   59961             : /* #line 59962 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   59962             : 
   59963           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   59964             : 
   59965             : 
   59966             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   59967             : 
   59968             : 
   59969           0 :    }
   59970             : 
   59971             : //############################################################################
   59972             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   59973             :  * within the working AST. 
   59974             :  */
   59975           0 : SgOmpInbranchClause * SgOmpInbranchClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   59976           0 :      SgOmpInbranchClause* returnPointer = NULL;
   59977           0 :      if ( globalIndex != 0 )
   59978             :         {
   59979             : 
   59980             : #if FILE_IO_EXTRA_CHECK
   59981           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpInbranchClause ) ) <= globalIndex ) ;
   59982           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpInbranchClause + 1 ) ) );
   59983             : #endif
   59984           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpInbranchClause )  
   59985           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpInbranchClause );
   59986           0 :           unsigned long positionInPool = localIndex % SgOmpInbranchClause::pool_size;
   59987           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpInbranchClause::pool_size;
   59988             : 
   59989             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   59990             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   59991             : 
   59992           0 :           returnPointer = &( ( (SgOmpInbranchClause*)(SgOmpInbranchClause::pools[memoryBlock]) ) [positionInPool]) ;
   59993             : 
   59994           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   59995             :         }
   59996           0 :      return returnPointer ;
   59997             :    }
   59998             : 
   59999             : //############################################################################
   60000             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   60001             :   for the AST with the index astIndex
   60002             : */
   60003           0 : SgOmpInbranchClause * SgOmpInbranchClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   60004           0 :      SgOmpInbranchClause* returnPointer = NULL;
   60005           0 :      if ( globalIndex != 0 )
   60006             :         {
   60007             : 
   60008             : #if FILE_IO_EXTRA_CHECK
   60009           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpInbranchClause ) ) <= globalIndex ) ;
   60010           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpInbranchClause + 1 ) ) );
   60011             : #endif
   60012           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpInbranchClause )
   60013           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpInbranchClause );
   60014           0 :           unsigned long positionInPool = localIndex % SgOmpInbranchClause::pool_size ;
   60015           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpInbranchClause::pool_size ;
   60016             : 
   60017             : #if FILE_IO_EXTRA_CHECK
   60018             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   60019             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   60020             : #endif
   60021             : 
   60022           0 :           returnPointer = &( ( (SgOmpInbranchClause*)(SgOmpInbranchClause::pools[memoryBlock]) ) [positionInPool]) ;
   60023             : 
   60024             : #if FILE_IO_EXTRA_CHECK
   60025           0 :           assert ( returnPointer != NULL ) ;
   60026             : #endif
   60027             :         }
   60028           0 :      return returnPointer ;
   60029             :    }
   60030             : 
   60031             : //############################################################################
   60032             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   60033             :  * pool size! We set for every valid object in the memory pool the freepointer
   60034             :  * to the global index and increase the global index afterwards. For all the 
   60035             :  * invalid objects (means address ranges within the memory pool that were not
   60036             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   60037             :  * distinguish valid from invalid objects! 
   60038             :  */
   60039             : unsigned long
   60040           5 : SgOmpInbranchClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   60041             :    {
   60042           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   60043           5 :      SgOmpInbranchClause* pointer = NULL;
   60044           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   60045           5 :      std::vector < unsigned char* > :: const_iterator block;
   60046           5 :      for ( block = SgOmpInbranchClause::pools.begin(); block != SgOmpInbranchClause::pools.end() ; ++block )
   60047             :         {
   60048           0 :           pointer = (SgOmpInbranchClause*)(*block);
   60049           0 :           for (unsigned i = 0; i < SgOmpInbranchClause::pool_size; ++i )
   60050             :              {
   60051             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   60052             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   60053             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   60054             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   60055             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   60056             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   60057             :             // properly; so this will have to be checked next.
   60058             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   60059             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   60060           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   60061             :                   {
   60062           0 :                     pointer[i].set_freepointer((SgOmpInbranchClause*)(globalIndex));
   60063           0 :                     globalIndex++;
   60064             :                   }
   60065             :                else
   60066             :                   {
   60067           0 :                     pointer[i].set_freepointer(NULL);
   60068             :                   }
   60069             :               }
   60070             :         }
   60071           5 :      return globalIndex;
   60072             :    }
   60073             : 
   60074             : //############################################################################
   60075             : // JH (01/14/2006)
   60076             : void
   60077           5 : SgOmpInbranchClause::resetValidFreepointers( )
   60078             :    {
   60079           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   60080           5 :      SgOmpInbranchClause* pointer = NULL;
   60081           5 :      std::vector < unsigned char* > :: const_iterator block;
   60082           5 :      SgOmpInbranchClause* pointerOfLinkedList = NULL;
   60083           5 :      for ( block = SgOmpInbranchClause::pools.begin(); block != SgOmpInbranchClause::pools.end() ; ++block )
   60084             :         {
   60085           0 :           pointer = (SgOmpInbranchClause*)(*block);
   60086           0 :           for (unsigned i = 0; i < SgOmpInbranchClause::pool_size; ++i )
   60087             :              {
   60088             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   60089             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   60090             :             // memory blocks!.
   60091           0 :                if ( pointer[i].get_freepointer() != NULL )
   60092             :                   {
   60093           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   60094             :                   }
   60095             :                else
   60096             :                   {
   60097           0 :                     if ( pointerOfLinkedList == NULL )
   60098             :                        {
   60099           0 :                          SgOmpInbranchClause::next_node = &(pointer[i]);
   60100             :                        }
   60101             :                     else
   60102             :                        {
   60103             :                       // printf ("In SgOmpInbranchClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   60104           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   60105             :                        }
   60106             :                     pointerOfLinkedList = &(pointer[i]);
   60107             :                   }
   60108             :               }
   60109             :         }
   60110             : 
   60111           5 :      if ( pointerOfLinkedList != NULL )
   60112             :         {
   60113             :        // printf ("In SgOmpInbranchClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   60114           0 :           pointerOfLinkedList->set_freepointer(NULL);
   60115             :        // DQ (6/6/2010): Temporary debugging...
   60116             :        //   ROSE_ASSERT(false);
   60117             :         }
   60118             : 
   60119           5 :      return ;
   60120             :    }
   60121             : 
   60122             : //############################################################################
   60123             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   60124             :  * within the memory pool and resets the freepointers, in order to achieve a 
   60125             :  * linked list, that has no jumps and starts at the beginning! This function 
   60126             :  * does not extend the memory pool, since we do not delete any memory blocks,
   60127             :  * but delete the valid objects.  
   60128             :  */
   60129             : void
   60130           0 : SgOmpInbranchClause::clearMemoryPool( )
   60131             :    {
   60132             :   // printf ("Inside of SgOmpInbranchClause::clearMemoryPool() \n");
   60133             : 
   60134           0 :      SgOmpInbranchClause* pointer = NULL, *tempPointer = NULL;
   60135           0 :      std::vector < unsigned char* > :: const_iterator block;
   60136           0 :      if ( SgOmpInbranchClause::pools.empty() == false )
   60137             :         {
   60138           0 :           block = SgOmpInbranchClause::pools.begin() ;
   60139           0 :           SgOmpInbranchClause::next_node = (SgOmpInbranchClause*) (*block);
   60140             : 
   60141           0 :           while ( block != SgOmpInbranchClause::pools.end() )
   60142             :              {
   60143           0 :                pointer = (SgOmpInbranchClause*) (*block);
   60144           0 :                if ( tempPointer != NULL )
   60145             :                   {
   60146           0 :                     tempPointer->set_freepointer(pointer);
   60147             :                   }
   60148           0 :                for (unsigned i = 0; i < SgOmpInbranchClause::pool_size - 1; ++i)
   60149             :                   {
   60150           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   60151             :                   }
   60152           0 :                 pointer[SgOmpInbranchClause::pool_size-1].set_freepointer(NULL);
   60153           0 :                 tempPointer = &(pointer[SgOmpInbranchClause::pool_size-1]);
   60154           0 :                 ++block;
   60155             :              }
   60156             :         }
   60157           0 :    }
   60158             : 
   60159           5 : void SgOmpInbranchClause::deleteMemoryPool() {
   60160           5 :   for (auto p: SgOmpInbranchClause::pools) {
   60161           0 :     ROSE_FREE(p);
   60162             :   }
   60163           5 :   SgOmpInbranchClause::next_node = nullptr;
   60164           5 :   SgOmpInbranchClause::pools.clear();
   60165           5 : }
   60166             : 
   60167             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   60168             : //                 reading multiple binary files to for a single AST.
   60169             : /////////// new version ////////////////////////////////
   60170             : //############################################################################
   60171             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   60172             : void
   60173           2 : SgOmpInbranchClause::extendMemoryPoolForFileIO( )
   60174             :   {
   60175           2 :     size_t blockIndex = SgOmpInbranchClause::pools.size();
   60176           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInbranchClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInbranchClause);
   60177             : 
   60178           2 :     while ( (blockIndex * SgOmpInbranchClause::pool_size) < newPoolSize)
   60179             :       {
   60180             : #if ROSE_ALLOC_TRACE
   60181             :         if (blockIndex > 0) {
   60182             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInbranchClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInbranchClause) = %" PRIuPTR " SgOmpInbranchClause::pool_size = %d \n",
   60183             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInbranchClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInbranchClause),SgOmpInbranchClause::pool_size);
   60184             :         }
   60185             : #endif
   60186             : 
   60187           0 :         SgOmpInbranchClause * pointer = (SgOmpInbranchClause*) ROSE_MALLOC ( SgOmpInbranchClause::pool_size * sizeof(SgOmpInbranchClause) );
   60188           0 :         assert( pointer != NULL );
   60189             : #if ROSE_ALLOC_MEMSET == 1
   60190             :         memset(pointer, 0x00, SgOmpInbranchClause::pool_size * sizeof(SgOmpInbranchClause));
   60191             : #elif ROSE_ALLOC_MEMSET == 2
   60192             :         memset(pointer, 0xCC, SgOmpInbranchClause::pool_size * sizeof(SgOmpInbranchClause));
   60193             : #endif
   60194           0 :         SgOmpInbranchClause::pools.push_back( (unsigned char*)(pointer) );
   60195           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpInbranchClause::pool_size * sizeof(SgOmpInbranchClause), V_SgOmpInbranchClause ) );
   60196             : 
   60197           0 :         if ( SgOmpInbranchClause::next_node != NULL ) {
   60198           0 :           if ( blockIndex > 0 ) {
   60199           0 :             SgOmpInbranchClause * blkptr = (SgOmpInbranchClause*)(SgOmpInbranchClause::pools[blockIndex-1]);
   60200           0 :             blkptr[ SgOmpInbranchClause::pool_size - 1 ].set_freepointer(pointer);
   60201             :           }
   60202             :         } else {
   60203           0 :           SgOmpInbranchClause::next_node = pointer;
   60204             :         }
   60205             : 
   60206           0 :         for (unsigned i = 0; i < SgOmpInbranchClause::pool_size-1; ++i)
   60207             :            {
   60208           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   60209             :            }
   60210           0 :         pointer[ SgOmpInbranchClause::pool_size -1 ].set_freepointer(NULL);
   60211             : 
   60212           0 :         blockIndex++;
   60213             :       }
   60214           2 :   }
   60215             : 
   60216             : //############################################################################
   60217             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   60218             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   60219             :  * not compressed. However, that stuff is not yet implemented! 
   60220             :  */
   60221             : unsigned long
   60222           0 : SgOmpInbranchClause::getNumberOfLastValidPointer()
   60223             :    {
   60224           0 :       SgOmpInbranchClause* testPointer = (SgOmpInbranchClause*)(SgOmpInbranchClause::pools.back());
   60225           0 :       unsigned long localIndex = SgOmpInbranchClause::pool_size - 1;
   60226           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   60227             :          {
   60228           0 :            localIndex--;
   60229             :          }
   60230           0 :       return (localIndex + SgOmpInbranchClause::pool_size * (SgOmpInbranchClause::pools.size()-1));
   60231             :    }
   60232             : 
   60233             : //############################################################################
   60234             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   60235             :  * memory pool and initializes the data member in class SgOmpInbranchClauseStroageClass
   60236             :  * from its counterpart of SgOmpInbranchClause. The return value is just for checking, 
   60237             :  * that the whole StorageClassArray is initialized!
   60238             :  */
   60239             : unsigned long
   60240           0 : SgOmpInbranchClause::initializeStorageClassArray( SgOmpInbranchClauseStorageClass *storageArray )
   60241             :    {
   60242           0 :      unsigned long storageCounter = 0;
   60243           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpInbranchClause::pools.begin();
   60244           0 :      SgOmpInbranchClause* pointer = NULL;
   60245           0 :      while ( block != SgOmpInbranchClause::pools.end() ) {
   60246           0 :           pointer = (SgOmpInbranchClause*) (*block);
   60247           0 :           for ( unsigned i = 0; i < SgOmpInbranchClause::pool_size; ++i ) {
   60248           0 :                if ( pointer->get_freepointer() != NULL ) {
   60249           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   60250           0 :                  storageArray++;
   60251           0 :                  storageCounter++;
   60252             :                }
   60253           0 :                pointer++;
   60254             :              }
   60255           0 :            block++;
   60256             :         }
   60257           0 :      return storageCounter;
   60258             :    }
   60259             : 
   60260             : /* #line 60261 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   60261             : 
   60262             : 
   60263             : 
   60264             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   60265             : 
   60266             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   60267             : 
   60268             : //############################################################################
   60269             : /* JH (02/02/2006) Constructor of the IR node SgOmpNotinbranchClause that takes its 
   60270             :  * corresponding StorageClass as parameter
   60271             :  */
   60272           0 : SgOmpNotinbranchClause :: SgOmpNotinbranchClause ( const SgOmpNotinbranchClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   60273             :    {
   60274             : 
   60275             : 
   60276             : /* #line 60277 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   60277             : 
   60278           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   60279             : 
   60280             : 
   60281             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   60282             : 
   60283             : 
   60284           0 :    }
   60285             : 
   60286             : //############################################################################
   60287             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   60288             :  * within the working AST. 
   60289             :  */
   60290           0 : SgOmpNotinbranchClause * SgOmpNotinbranchClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   60291           0 :      SgOmpNotinbranchClause* returnPointer = NULL;
   60292           0 :      if ( globalIndex != 0 )
   60293             :         {
   60294             : 
   60295             : #if FILE_IO_EXTRA_CHECK
   60296           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpNotinbranchClause ) ) <= globalIndex ) ;
   60297           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNotinbranchClause + 1 ) ) );
   60298             : #endif
   60299           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNotinbranchClause )  
   60300           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpNotinbranchClause );
   60301           0 :           unsigned long positionInPool = localIndex % SgOmpNotinbranchClause::pool_size;
   60302           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNotinbranchClause::pool_size;
   60303             : 
   60304             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   60305             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   60306             : 
   60307           0 :           returnPointer = &( ( (SgOmpNotinbranchClause*)(SgOmpNotinbranchClause::pools[memoryBlock]) ) [positionInPool]) ;
   60308             : 
   60309           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   60310             :         }
   60311           0 :      return returnPointer ;
   60312             :    }
   60313             : 
   60314             : //############################################################################
   60315             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   60316             :   for the AST with the index astIndex
   60317             : */
   60318           0 : SgOmpNotinbranchClause * SgOmpNotinbranchClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   60319           0 :      SgOmpNotinbranchClause* returnPointer = NULL;
   60320           0 :      if ( globalIndex != 0 )
   60321             :         {
   60322             : 
   60323             : #if FILE_IO_EXTRA_CHECK
   60324           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpNotinbranchClause ) ) <= globalIndex ) ;
   60325           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNotinbranchClause + 1 ) ) );
   60326             : #endif
   60327           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNotinbranchClause )
   60328           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpNotinbranchClause );
   60329           0 :           unsigned long positionInPool = localIndex % SgOmpNotinbranchClause::pool_size ;
   60330           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNotinbranchClause::pool_size ;
   60331             : 
   60332             : #if FILE_IO_EXTRA_CHECK
   60333             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   60334             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   60335             : #endif
   60336             : 
   60337           0 :           returnPointer = &( ( (SgOmpNotinbranchClause*)(SgOmpNotinbranchClause::pools[memoryBlock]) ) [positionInPool]) ;
   60338             : 
   60339             : #if FILE_IO_EXTRA_CHECK
   60340           0 :           assert ( returnPointer != NULL ) ;
   60341             : #endif
   60342             :         }
   60343           0 :      return returnPointer ;
   60344             :    }
   60345             : 
   60346             : //############################################################################
   60347             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   60348             :  * pool size! We set for every valid object in the memory pool the freepointer
   60349             :  * to the global index and increase the global index afterwards. For all the 
   60350             :  * invalid objects (means address ranges within the memory pool that were not
   60351             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   60352             :  * distinguish valid from invalid objects! 
   60353             :  */
   60354             : unsigned long
   60355           5 : SgOmpNotinbranchClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   60356             :    {
   60357           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   60358           5 :      SgOmpNotinbranchClause* pointer = NULL;
   60359           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   60360           5 :      std::vector < unsigned char* > :: const_iterator block;
   60361           5 :      for ( block = SgOmpNotinbranchClause::pools.begin(); block != SgOmpNotinbranchClause::pools.end() ; ++block )
   60362             :         {
   60363           0 :           pointer = (SgOmpNotinbranchClause*)(*block);
   60364           0 :           for (unsigned i = 0; i < SgOmpNotinbranchClause::pool_size; ++i )
   60365             :              {
   60366             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   60367             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   60368             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   60369             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   60370             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   60371             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   60372             :             // properly; so this will have to be checked next.
   60373             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   60374             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   60375           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   60376             :                   {
   60377           0 :                     pointer[i].set_freepointer((SgOmpNotinbranchClause*)(globalIndex));
   60378           0 :                     globalIndex++;
   60379             :                   }
   60380             :                else
   60381             :                   {
   60382           0 :                     pointer[i].set_freepointer(NULL);
   60383             :                   }
   60384             :               }
   60385             :         }
   60386           5 :      return globalIndex;
   60387             :    }
   60388             : 
   60389             : //############################################################################
   60390             : // JH (01/14/2006)
   60391             : void
   60392           5 : SgOmpNotinbranchClause::resetValidFreepointers( )
   60393             :    {
   60394           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   60395           5 :      SgOmpNotinbranchClause* pointer = NULL;
   60396           5 :      std::vector < unsigned char* > :: const_iterator block;
   60397           5 :      SgOmpNotinbranchClause* pointerOfLinkedList = NULL;
   60398           5 :      for ( block = SgOmpNotinbranchClause::pools.begin(); block != SgOmpNotinbranchClause::pools.end() ; ++block )
   60399             :         {
   60400           0 :           pointer = (SgOmpNotinbranchClause*)(*block);
   60401           0 :           for (unsigned i = 0; i < SgOmpNotinbranchClause::pool_size; ++i )
   60402             :              {
   60403             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   60404             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   60405             :             // memory blocks!.
   60406           0 :                if ( pointer[i].get_freepointer() != NULL )
   60407             :                   {
   60408           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   60409             :                   }
   60410             :                else
   60411             :                   {
   60412           0 :                     if ( pointerOfLinkedList == NULL )
   60413             :                        {
   60414           0 :                          SgOmpNotinbranchClause::next_node = &(pointer[i]);
   60415             :                        }
   60416             :                     else
   60417             :                        {
   60418             :                       // printf ("In SgOmpNotinbranchClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   60419           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   60420             :                        }
   60421             :                     pointerOfLinkedList = &(pointer[i]);
   60422             :                   }
   60423             :               }
   60424             :         }
   60425             : 
   60426           5 :      if ( pointerOfLinkedList != NULL )
   60427             :         {
   60428             :        // printf ("In SgOmpNotinbranchClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   60429           0 :           pointerOfLinkedList->set_freepointer(NULL);
   60430             :        // DQ (6/6/2010): Temporary debugging...
   60431             :        //   ROSE_ASSERT(false);
   60432             :         }
   60433             : 
   60434           5 :      return ;
   60435             :    }
   60436             : 
   60437             : //############################################################################
   60438             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   60439             :  * within the memory pool and resets the freepointers, in order to achieve a 
   60440             :  * linked list, that has no jumps and starts at the beginning! This function 
   60441             :  * does not extend the memory pool, since we do not delete any memory blocks,
   60442             :  * but delete the valid objects.  
   60443             :  */
   60444             : void
   60445           0 : SgOmpNotinbranchClause::clearMemoryPool( )
   60446             :    {
   60447             :   // printf ("Inside of SgOmpNotinbranchClause::clearMemoryPool() \n");
   60448             : 
   60449           0 :      SgOmpNotinbranchClause* pointer = NULL, *tempPointer = NULL;
   60450           0 :      std::vector < unsigned char* > :: const_iterator block;
   60451           0 :      if ( SgOmpNotinbranchClause::pools.empty() == false )
   60452             :         {
   60453           0 :           block = SgOmpNotinbranchClause::pools.begin() ;
   60454           0 :           SgOmpNotinbranchClause::next_node = (SgOmpNotinbranchClause*) (*block);
   60455             : 
   60456           0 :           while ( block != SgOmpNotinbranchClause::pools.end() )
   60457             :              {
   60458           0 :                pointer = (SgOmpNotinbranchClause*) (*block);
   60459           0 :                if ( tempPointer != NULL )
   60460             :                   {
   60461           0 :                     tempPointer->set_freepointer(pointer);
   60462             :                   }
   60463           0 :                for (unsigned i = 0; i < SgOmpNotinbranchClause::pool_size - 1; ++i)
   60464             :                   {
   60465           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   60466             :                   }
   60467           0 :                 pointer[SgOmpNotinbranchClause::pool_size-1].set_freepointer(NULL);
   60468           0 :                 tempPointer = &(pointer[SgOmpNotinbranchClause::pool_size-1]);
   60469           0 :                 ++block;
   60470             :              }
   60471             :         }
   60472           0 :    }
   60473             : 
   60474           5 : void SgOmpNotinbranchClause::deleteMemoryPool() {
   60475           5 :   for (auto p: SgOmpNotinbranchClause::pools) {
   60476           0 :     ROSE_FREE(p);
   60477             :   }
   60478           5 :   SgOmpNotinbranchClause::next_node = nullptr;
   60479           5 :   SgOmpNotinbranchClause::pools.clear();
   60480           5 : }
   60481             : 
   60482             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   60483             : //                 reading multiple binary files to for a single AST.
   60484             : /////////// new version ////////////////////////////////
   60485             : //############################################################################
   60486             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   60487             : void
   60488           2 : SgOmpNotinbranchClause::extendMemoryPoolForFileIO( )
   60489             :   {
   60490           2 :     size_t blockIndex = SgOmpNotinbranchClause::pools.size();
   60491           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNotinbranchClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNotinbranchClause);
   60492             : 
   60493           2 :     while ( (blockIndex * SgOmpNotinbranchClause::pool_size) < newPoolSize)
   60494             :       {
   60495             : #if ROSE_ALLOC_TRACE
   60496             :         if (blockIndex > 0) {
   60497             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNotinbranchClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNotinbranchClause) = %" PRIuPTR " SgOmpNotinbranchClause::pool_size = %d \n",
   60498             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNotinbranchClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNotinbranchClause),SgOmpNotinbranchClause::pool_size);
   60499             :         }
   60500             : #endif
   60501             : 
   60502           0 :         SgOmpNotinbranchClause * pointer = (SgOmpNotinbranchClause*) ROSE_MALLOC ( SgOmpNotinbranchClause::pool_size * sizeof(SgOmpNotinbranchClause) );
   60503           0 :         assert( pointer != NULL );
   60504             : #if ROSE_ALLOC_MEMSET == 1
   60505             :         memset(pointer, 0x00, SgOmpNotinbranchClause::pool_size * sizeof(SgOmpNotinbranchClause));
   60506             : #elif ROSE_ALLOC_MEMSET == 2
   60507             :         memset(pointer, 0xCC, SgOmpNotinbranchClause::pool_size * sizeof(SgOmpNotinbranchClause));
   60508             : #endif
   60509           0 :         SgOmpNotinbranchClause::pools.push_back( (unsigned char*)(pointer) );
   60510           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpNotinbranchClause::pool_size * sizeof(SgOmpNotinbranchClause), V_SgOmpNotinbranchClause ) );
   60511             : 
   60512           0 :         if ( SgOmpNotinbranchClause::next_node != NULL ) {
   60513           0 :           if ( blockIndex > 0 ) {
   60514           0 :             SgOmpNotinbranchClause * blkptr = (SgOmpNotinbranchClause*)(SgOmpNotinbranchClause::pools[blockIndex-1]);
   60515           0 :             blkptr[ SgOmpNotinbranchClause::pool_size - 1 ].set_freepointer(pointer);
   60516             :           }
   60517             :         } else {
   60518           0 :           SgOmpNotinbranchClause::next_node = pointer;
   60519             :         }
   60520             : 
   60521           0 :         for (unsigned i = 0; i < SgOmpNotinbranchClause::pool_size-1; ++i)
   60522             :            {
   60523           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   60524             :            }
   60525           0 :         pointer[ SgOmpNotinbranchClause::pool_size -1 ].set_freepointer(NULL);
   60526             : 
   60527           0 :         blockIndex++;
   60528             :       }
   60529           2 :   }
   60530             : 
   60531             : //############################################################################
   60532             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   60533             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   60534             :  * not compressed. However, that stuff is not yet implemented! 
   60535             :  */
   60536             : unsigned long
   60537           0 : SgOmpNotinbranchClause::getNumberOfLastValidPointer()
   60538             :    {
   60539           0 :       SgOmpNotinbranchClause* testPointer = (SgOmpNotinbranchClause*)(SgOmpNotinbranchClause::pools.back());
   60540           0 :       unsigned long localIndex = SgOmpNotinbranchClause::pool_size - 1;
   60541           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   60542             :          {
   60543           0 :            localIndex--;
   60544             :          }
   60545           0 :       return (localIndex + SgOmpNotinbranchClause::pool_size * (SgOmpNotinbranchClause::pools.size()-1));
   60546             :    }
   60547             : 
   60548             : //############################################################################
   60549             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   60550             :  * memory pool and initializes the data member in class SgOmpNotinbranchClauseStroageClass
   60551             :  * from its counterpart of SgOmpNotinbranchClause. The return value is just for checking, 
   60552             :  * that the whole StorageClassArray is initialized!
   60553             :  */
   60554             : unsigned long
   60555           0 : SgOmpNotinbranchClause::initializeStorageClassArray( SgOmpNotinbranchClauseStorageClass *storageArray )
   60556             :    {
   60557           0 :      unsigned long storageCounter = 0;
   60558           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpNotinbranchClause::pools.begin();
   60559           0 :      SgOmpNotinbranchClause* pointer = NULL;
   60560           0 :      while ( block != SgOmpNotinbranchClause::pools.end() ) {
   60561           0 :           pointer = (SgOmpNotinbranchClause*) (*block);
   60562           0 :           for ( unsigned i = 0; i < SgOmpNotinbranchClause::pool_size; ++i ) {
   60563           0 :                if ( pointer->get_freepointer() != NULL ) {
   60564           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   60565           0 :                  storageArray++;
   60566           0 :                  storageCounter++;
   60567             :                }
   60568           0 :                pointer++;
   60569             :              }
   60570           0 :            block++;
   60571             :         }
   60572           0 :      return storageCounter;
   60573             :    }
   60574             : 
   60575             : /* #line 60576 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   60576             : 
   60577             : 
   60578             : 
   60579             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   60580             : 
   60581             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   60582             : 
   60583             : //############################################################################
   60584             : /* JH (02/02/2006) Constructor of the IR node SgOmpDefaultmapClause that takes its 
   60585             :  * corresponding StorageClass as parameter
   60586             :  */
   60587           0 : SgOmpDefaultmapClause :: SgOmpDefaultmapClause ( const SgOmpDefaultmapClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   60588             :    {
   60589             : 
   60590             : 
   60591             : /* #line 60592 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   60592             : 
   60593           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   60594           0 :      p_behavior = storageSource.storageOf_behavior ;
   60595           0 :      p_category = storageSource.storageOf_category ;
   60596             : 
   60597             : 
   60598             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   60599             : 
   60600             : 
   60601           0 :    }
   60602             : 
   60603             : //############################################################################
   60604             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   60605             :  * within the working AST. 
   60606             :  */
   60607           0 : SgOmpDefaultmapClause * SgOmpDefaultmapClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   60608           0 :      SgOmpDefaultmapClause* returnPointer = NULL;
   60609           0 :      if ( globalIndex != 0 )
   60610             :         {
   60611             : 
   60612             : #if FILE_IO_EXTRA_CHECK
   60613           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDefaultmapClause ) ) <= globalIndex ) ;
   60614           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDefaultmapClause + 1 ) ) );
   60615             : #endif
   60616           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDefaultmapClause )  
   60617           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDefaultmapClause );
   60618           0 :           unsigned long positionInPool = localIndex % SgOmpDefaultmapClause::pool_size;
   60619           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDefaultmapClause::pool_size;
   60620             : 
   60621             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   60622             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   60623             : 
   60624           0 :           returnPointer = &( ( (SgOmpDefaultmapClause*)(SgOmpDefaultmapClause::pools[memoryBlock]) ) [positionInPool]) ;
   60625             : 
   60626           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   60627             :         }
   60628           0 :      return returnPointer ;
   60629             :    }
   60630             : 
   60631             : //############################################################################
   60632             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   60633             :   for the AST with the index astIndex
   60634             : */
   60635           0 : SgOmpDefaultmapClause * SgOmpDefaultmapClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   60636           0 :      SgOmpDefaultmapClause* returnPointer = NULL;
   60637           0 :      if ( globalIndex != 0 )
   60638             :         {
   60639             : 
   60640             : #if FILE_IO_EXTRA_CHECK
   60641           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDefaultmapClause ) ) <= globalIndex ) ;
   60642           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDefaultmapClause + 1 ) ) );
   60643             : #endif
   60644           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDefaultmapClause )
   60645           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDefaultmapClause );
   60646           0 :           unsigned long positionInPool = localIndex % SgOmpDefaultmapClause::pool_size ;
   60647           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDefaultmapClause::pool_size ;
   60648             : 
   60649             : #if FILE_IO_EXTRA_CHECK
   60650             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   60651             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   60652             : #endif
   60653             : 
   60654           0 :           returnPointer = &( ( (SgOmpDefaultmapClause*)(SgOmpDefaultmapClause::pools[memoryBlock]) ) [positionInPool]) ;
   60655             : 
   60656             : #if FILE_IO_EXTRA_CHECK
   60657           0 :           assert ( returnPointer != NULL ) ;
   60658             : #endif
   60659             :         }
   60660           0 :      return returnPointer ;
   60661             :    }
   60662             : 
   60663             : //############################################################################
   60664             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   60665             :  * pool size! We set for every valid object in the memory pool the freepointer
   60666             :  * to the global index and increase the global index afterwards. For all the 
   60667             :  * invalid objects (means address ranges within the memory pool that were not
   60668             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   60669             :  * distinguish valid from invalid objects! 
   60670             :  */
   60671             : unsigned long
   60672           5 : SgOmpDefaultmapClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   60673             :    {
   60674           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   60675           5 :      SgOmpDefaultmapClause* pointer = NULL;
   60676           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   60677           5 :      std::vector < unsigned char* > :: const_iterator block;
   60678           5 :      for ( block = SgOmpDefaultmapClause::pools.begin(); block != SgOmpDefaultmapClause::pools.end() ; ++block )
   60679             :         {
   60680           0 :           pointer = (SgOmpDefaultmapClause*)(*block);
   60681           0 :           for (unsigned i = 0; i < SgOmpDefaultmapClause::pool_size; ++i )
   60682             :              {
   60683             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   60684             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   60685             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   60686             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   60687             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   60688             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   60689             :             // properly; so this will have to be checked next.
   60690             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   60691             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   60692           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   60693             :                   {
   60694           0 :                     pointer[i].set_freepointer((SgOmpDefaultmapClause*)(globalIndex));
   60695           0 :                     globalIndex++;
   60696             :                   }
   60697             :                else
   60698             :                   {
   60699           0 :                     pointer[i].set_freepointer(NULL);
   60700             :                   }
   60701             :               }
   60702             :         }
   60703           5 :      return globalIndex;
   60704             :    }
   60705             : 
   60706             : //############################################################################
   60707             : // JH (01/14/2006)
   60708             : void
   60709           5 : SgOmpDefaultmapClause::resetValidFreepointers( )
   60710             :    {
   60711           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   60712           5 :      SgOmpDefaultmapClause* pointer = NULL;
   60713           5 :      std::vector < unsigned char* > :: const_iterator block;
   60714           5 :      SgOmpDefaultmapClause* pointerOfLinkedList = NULL;
   60715           5 :      for ( block = SgOmpDefaultmapClause::pools.begin(); block != SgOmpDefaultmapClause::pools.end() ; ++block )
   60716             :         {
   60717           0 :           pointer = (SgOmpDefaultmapClause*)(*block);
   60718           0 :           for (unsigned i = 0; i < SgOmpDefaultmapClause::pool_size; ++i )
   60719             :              {
   60720             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   60721             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   60722             :             // memory blocks!.
   60723           0 :                if ( pointer[i].get_freepointer() != NULL )
   60724             :                   {
   60725           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   60726             :                   }
   60727             :                else
   60728             :                   {
   60729           0 :                     if ( pointerOfLinkedList == NULL )
   60730             :                        {
   60731           0 :                          SgOmpDefaultmapClause::next_node = &(pointer[i]);
   60732             :                        }
   60733             :                     else
   60734             :                        {
   60735             :                       // printf ("In SgOmpDefaultmapClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   60736           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   60737             :                        }
   60738             :                     pointerOfLinkedList = &(pointer[i]);
   60739             :                   }
   60740             :               }
   60741             :         }
   60742             : 
   60743           5 :      if ( pointerOfLinkedList != NULL )
   60744             :         {
   60745             :        // printf ("In SgOmpDefaultmapClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   60746           0 :           pointerOfLinkedList->set_freepointer(NULL);
   60747             :        // DQ (6/6/2010): Temporary debugging...
   60748             :        //   ROSE_ASSERT(false);
   60749             :         }
   60750             : 
   60751           5 :      return ;
   60752             :    }
   60753             : 
   60754             : //############################################################################
   60755             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   60756             :  * within the memory pool and resets the freepointers, in order to achieve a 
   60757             :  * linked list, that has no jumps and starts at the beginning! This function 
   60758             :  * does not extend the memory pool, since we do not delete any memory blocks,
   60759             :  * but delete the valid objects.  
   60760             :  */
   60761             : void
   60762           0 : SgOmpDefaultmapClause::clearMemoryPool( )
   60763             :    {
   60764             :   // printf ("Inside of SgOmpDefaultmapClause::clearMemoryPool() \n");
   60765             : 
   60766           0 :      SgOmpDefaultmapClause* pointer = NULL, *tempPointer = NULL;
   60767           0 :      std::vector < unsigned char* > :: const_iterator block;
   60768           0 :      if ( SgOmpDefaultmapClause::pools.empty() == false )
   60769             :         {
   60770           0 :           block = SgOmpDefaultmapClause::pools.begin() ;
   60771           0 :           SgOmpDefaultmapClause::next_node = (SgOmpDefaultmapClause*) (*block);
   60772             : 
   60773           0 :           while ( block != SgOmpDefaultmapClause::pools.end() )
   60774             :              {
   60775           0 :                pointer = (SgOmpDefaultmapClause*) (*block);
   60776           0 :                if ( tempPointer != NULL )
   60777             :                   {
   60778           0 :                     tempPointer->set_freepointer(pointer);
   60779             :                   }
   60780           0 :                for (unsigned i = 0; i < SgOmpDefaultmapClause::pool_size - 1; ++i)
   60781             :                   {
   60782           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   60783             :                   }
   60784           0 :                 pointer[SgOmpDefaultmapClause::pool_size-1].set_freepointer(NULL);
   60785           0 :                 tempPointer = &(pointer[SgOmpDefaultmapClause::pool_size-1]);
   60786           0 :                 ++block;
   60787             :              }
   60788             :         }
   60789           0 :    }
   60790             : 
   60791           5 : void SgOmpDefaultmapClause::deleteMemoryPool() {
   60792           5 :   for (auto p: SgOmpDefaultmapClause::pools) {
   60793           0 :     ROSE_FREE(p);
   60794             :   }
   60795           5 :   SgOmpDefaultmapClause::next_node = nullptr;
   60796           5 :   SgOmpDefaultmapClause::pools.clear();
   60797           5 : }
   60798             : 
   60799             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   60800             : //                 reading multiple binary files to for a single AST.
   60801             : /////////// new version ////////////////////////////////
   60802             : //############################################################################
   60803             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   60804             : void
   60805           2 : SgOmpDefaultmapClause::extendMemoryPoolForFileIO( )
   60806             :   {
   60807           2 :     size_t blockIndex = SgOmpDefaultmapClause::pools.size();
   60808           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDefaultmapClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDefaultmapClause);
   60809             : 
   60810           2 :     while ( (blockIndex * SgOmpDefaultmapClause::pool_size) < newPoolSize)
   60811             :       {
   60812             : #if ROSE_ALLOC_TRACE
   60813             :         if (blockIndex > 0) {
   60814             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDefaultmapClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDefaultmapClause) = %" PRIuPTR " SgOmpDefaultmapClause::pool_size = %d \n",
   60815             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDefaultmapClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDefaultmapClause),SgOmpDefaultmapClause::pool_size);
   60816             :         }
   60817             : #endif
   60818             : 
   60819           0 :         SgOmpDefaultmapClause * pointer = (SgOmpDefaultmapClause*) ROSE_MALLOC ( SgOmpDefaultmapClause::pool_size * sizeof(SgOmpDefaultmapClause) );
   60820           0 :         assert( pointer != NULL );
   60821             : #if ROSE_ALLOC_MEMSET == 1
   60822             :         memset(pointer, 0x00, SgOmpDefaultmapClause::pool_size * sizeof(SgOmpDefaultmapClause));
   60823             : #elif ROSE_ALLOC_MEMSET == 2
   60824             :         memset(pointer, 0xCC, SgOmpDefaultmapClause::pool_size * sizeof(SgOmpDefaultmapClause));
   60825             : #endif
   60826           0 :         SgOmpDefaultmapClause::pools.push_back( (unsigned char*)(pointer) );
   60827           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDefaultmapClause::pool_size * sizeof(SgOmpDefaultmapClause), V_SgOmpDefaultmapClause ) );
   60828             : 
   60829           0 :         if ( SgOmpDefaultmapClause::next_node != NULL ) {
   60830           0 :           if ( blockIndex > 0 ) {
   60831           0 :             SgOmpDefaultmapClause * blkptr = (SgOmpDefaultmapClause*)(SgOmpDefaultmapClause::pools[blockIndex-1]);
   60832           0 :             blkptr[ SgOmpDefaultmapClause::pool_size - 1 ].set_freepointer(pointer);
   60833             :           }
   60834             :         } else {
   60835           0 :           SgOmpDefaultmapClause::next_node = pointer;
   60836             :         }
   60837             : 
   60838           0 :         for (unsigned i = 0; i < SgOmpDefaultmapClause::pool_size-1; ++i)
   60839             :            {
   60840           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   60841             :            }
   60842           0 :         pointer[ SgOmpDefaultmapClause::pool_size -1 ].set_freepointer(NULL);
   60843             : 
   60844           0 :         blockIndex++;
   60845             :       }
   60846           2 :   }
   60847             : 
   60848             : //############################################################################
   60849             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   60850             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   60851             :  * not compressed. However, that stuff is not yet implemented! 
   60852             :  */
   60853             : unsigned long
   60854           0 : SgOmpDefaultmapClause::getNumberOfLastValidPointer()
   60855             :    {
   60856           0 :       SgOmpDefaultmapClause* testPointer = (SgOmpDefaultmapClause*)(SgOmpDefaultmapClause::pools.back());
   60857           0 :       unsigned long localIndex = SgOmpDefaultmapClause::pool_size - 1;
   60858           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   60859             :          {
   60860           0 :            localIndex--;
   60861             :          }
   60862           0 :       return (localIndex + SgOmpDefaultmapClause::pool_size * (SgOmpDefaultmapClause::pools.size()-1));
   60863             :    }
   60864             : 
   60865             : //############################################################################
   60866             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   60867             :  * memory pool and initializes the data member in class SgOmpDefaultmapClauseStroageClass
   60868             :  * from its counterpart of SgOmpDefaultmapClause. The return value is just for checking, 
   60869             :  * that the whole StorageClassArray is initialized!
   60870             :  */
   60871             : unsigned long
   60872           0 : SgOmpDefaultmapClause::initializeStorageClassArray( SgOmpDefaultmapClauseStorageClass *storageArray )
   60873             :    {
   60874           0 :      unsigned long storageCounter = 0;
   60875           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDefaultmapClause::pools.begin();
   60876           0 :      SgOmpDefaultmapClause* pointer = NULL;
   60877           0 :      while ( block != SgOmpDefaultmapClause::pools.end() ) {
   60878           0 :           pointer = (SgOmpDefaultmapClause*) (*block);
   60879           0 :           for ( unsigned i = 0; i < SgOmpDefaultmapClause::pool_size; ++i ) {
   60880           0 :                if ( pointer->get_freepointer() != NULL ) {
   60881           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   60882           0 :                  storageArray++;
   60883           0 :                  storageCounter++;
   60884             :                }
   60885           0 :                pointer++;
   60886             :              }
   60887           0 :            block++;
   60888             :         }
   60889           0 :      return storageCounter;
   60890             :    }
   60891             : 
   60892             : /* #line 60893 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   60893             : 
   60894             : 
   60895             : 
   60896             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   60897             : 
   60898             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   60899             : 
   60900             : //############################################################################
   60901             : /* JH (02/02/2006) Constructor of the IR node SgOmpAtomicDefaultMemOrderClause that takes its 
   60902             :  * corresponding StorageClass as parameter
   60903             :  */
   60904           0 : SgOmpAtomicDefaultMemOrderClause :: SgOmpAtomicDefaultMemOrderClause ( const SgOmpAtomicDefaultMemOrderClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   60905             :    {
   60906             : 
   60907             : 
   60908             : /* #line 60909 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   60909             : 
   60910           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   60911           0 :      p_kind = storageSource.storageOf_kind ;
   60912             : 
   60913             : 
   60914             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   60915             : 
   60916             : 
   60917           0 :    }
   60918             : 
   60919             : //############################################################################
   60920             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   60921             :  * within the working AST. 
   60922             :  */
   60923           0 : SgOmpAtomicDefaultMemOrderClause * SgOmpAtomicDefaultMemOrderClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   60924           0 :      SgOmpAtomicDefaultMemOrderClause* returnPointer = NULL;
   60925           0 :      if ( globalIndex != 0 )
   60926             :         {
   60927             : 
   60928             : #if FILE_IO_EXTRA_CHECK
   60929           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAtomicDefaultMemOrderClause ) ) <= globalIndex ) ;
   60930           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAtomicDefaultMemOrderClause + 1 ) ) );
   60931             : #endif
   60932           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAtomicDefaultMemOrderClause )  
   60933           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAtomicDefaultMemOrderClause );
   60934           0 :           unsigned long positionInPool = localIndex % SgOmpAtomicDefaultMemOrderClause::pool_size;
   60935           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAtomicDefaultMemOrderClause::pool_size;
   60936             : 
   60937             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   60938             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   60939             : 
   60940           0 :           returnPointer = &( ( (SgOmpAtomicDefaultMemOrderClause*)(SgOmpAtomicDefaultMemOrderClause::pools[memoryBlock]) ) [positionInPool]) ;
   60941             : 
   60942           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   60943             :         }
   60944           0 :      return returnPointer ;
   60945             :    }
   60946             : 
   60947             : //############################################################################
   60948             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   60949             :   for the AST with the index astIndex
   60950             : */
   60951           0 : SgOmpAtomicDefaultMemOrderClause * SgOmpAtomicDefaultMemOrderClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   60952           0 :      SgOmpAtomicDefaultMemOrderClause* returnPointer = NULL;
   60953           0 :      if ( globalIndex != 0 )
   60954             :         {
   60955             : 
   60956             : #if FILE_IO_EXTRA_CHECK
   60957           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAtomicDefaultMemOrderClause ) ) <= globalIndex ) ;
   60958           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAtomicDefaultMemOrderClause + 1 ) ) );
   60959             : #endif
   60960           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAtomicDefaultMemOrderClause )
   60961           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAtomicDefaultMemOrderClause );
   60962           0 :           unsigned long positionInPool = localIndex % SgOmpAtomicDefaultMemOrderClause::pool_size ;
   60963           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAtomicDefaultMemOrderClause::pool_size ;
   60964             : 
   60965             : #if FILE_IO_EXTRA_CHECK
   60966             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   60967             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   60968             : #endif
   60969             : 
   60970           0 :           returnPointer = &( ( (SgOmpAtomicDefaultMemOrderClause*)(SgOmpAtomicDefaultMemOrderClause::pools[memoryBlock]) ) [positionInPool]) ;
   60971             : 
   60972             : #if FILE_IO_EXTRA_CHECK
   60973           0 :           assert ( returnPointer != NULL ) ;
   60974             : #endif
   60975             :         }
   60976           0 :      return returnPointer ;
   60977             :    }
   60978             : 
   60979             : //############################################################################
   60980             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   60981             :  * pool size! We set for every valid object in the memory pool the freepointer
   60982             :  * to the global index and increase the global index afterwards. For all the 
   60983             :  * invalid objects (means address ranges within the memory pool that were not
   60984             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   60985             :  * distinguish valid from invalid objects! 
   60986             :  */
   60987             : unsigned long
   60988           5 : SgOmpAtomicDefaultMemOrderClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   60989             :    {
   60990           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   60991           5 :      SgOmpAtomicDefaultMemOrderClause* pointer = NULL;
   60992           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   60993           5 :      std::vector < unsigned char* > :: const_iterator block;
   60994           5 :      for ( block = SgOmpAtomicDefaultMemOrderClause::pools.begin(); block != SgOmpAtomicDefaultMemOrderClause::pools.end() ; ++block )
   60995             :         {
   60996           0 :           pointer = (SgOmpAtomicDefaultMemOrderClause*)(*block);
   60997           0 :           for (unsigned i = 0; i < SgOmpAtomicDefaultMemOrderClause::pool_size; ++i )
   60998             :              {
   60999             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   61000             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   61001             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   61002             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   61003             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   61004             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   61005             :             // properly; so this will have to be checked next.
   61006             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   61007             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   61008           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   61009             :                   {
   61010           0 :                     pointer[i].set_freepointer((SgOmpAtomicDefaultMemOrderClause*)(globalIndex));
   61011           0 :                     globalIndex++;
   61012             :                   }
   61013             :                else
   61014             :                   {
   61015           0 :                     pointer[i].set_freepointer(NULL);
   61016             :                   }
   61017             :               }
   61018             :         }
   61019           5 :      return globalIndex;
   61020             :    }
   61021             : 
   61022             : //############################################################################
   61023             : // JH (01/14/2006)
   61024             : void
   61025           5 : SgOmpAtomicDefaultMemOrderClause::resetValidFreepointers( )
   61026             :    {
   61027           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   61028           5 :      SgOmpAtomicDefaultMemOrderClause* pointer = NULL;
   61029           5 :      std::vector < unsigned char* > :: const_iterator block;
   61030           5 :      SgOmpAtomicDefaultMemOrderClause* pointerOfLinkedList = NULL;
   61031           5 :      for ( block = SgOmpAtomicDefaultMemOrderClause::pools.begin(); block != SgOmpAtomicDefaultMemOrderClause::pools.end() ; ++block )
   61032             :         {
   61033           0 :           pointer = (SgOmpAtomicDefaultMemOrderClause*)(*block);
   61034           0 :           for (unsigned i = 0; i < SgOmpAtomicDefaultMemOrderClause::pool_size; ++i )
   61035             :              {
   61036             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   61037             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   61038             :             // memory blocks!.
   61039           0 :                if ( pointer[i].get_freepointer() != NULL )
   61040             :                   {
   61041           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   61042             :                   }
   61043             :                else
   61044             :                   {
   61045           0 :                     if ( pointerOfLinkedList == NULL )
   61046             :                        {
   61047           0 :                          SgOmpAtomicDefaultMemOrderClause::next_node = &(pointer[i]);
   61048             :                        }
   61049             :                     else
   61050             :                        {
   61051             :                       // printf ("In SgOmpAtomicDefaultMemOrderClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   61052           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   61053             :                        }
   61054             :                     pointerOfLinkedList = &(pointer[i]);
   61055             :                   }
   61056             :               }
   61057             :         }
   61058             : 
   61059           5 :      if ( pointerOfLinkedList != NULL )
   61060             :         {
   61061             :        // printf ("In SgOmpAtomicDefaultMemOrderClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   61062           0 :           pointerOfLinkedList->set_freepointer(NULL);
   61063             :        // DQ (6/6/2010): Temporary debugging...
   61064             :        //   ROSE_ASSERT(false);
   61065             :         }
   61066             : 
   61067           5 :      return ;
   61068             :    }
   61069             : 
   61070             : //############################################################################
   61071             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   61072             :  * within the memory pool and resets the freepointers, in order to achieve a 
   61073             :  * linked list, that has no jumps and starts at the beginning! This function 
   61074             :  * does not extend the memory pool, since we do not delete any memory blocks,
   61075             :  * but delete the valid objects.  
   61076             :  */
   61077             : void
   61078           0 : SgOmpAtomicDefaultMemOrderClause::clearMemoryPool( )
   61079             :    {
   61080             :   // printf ("Inside of SgOmpAtomicDefaultMemOrderClause::clearMemoryPool() \n");
   61081             : 
   61082           0 :      SgOmpAtomicDefaultMemOrderClause* pointer = NULL, *tempPointer = NULL;
   61083           0 :      std::vector < unsigned char* > :: const_iterator block;
   61084           0 :      if ( SgOmpAtomicDefaultMemOrderClause::pools.empty() == false )
   61085             :         {
   61086           0 :           block = SgOmpAtomicDefaultMemOrderClause::pools.begin() ;
   61087           0 :           SgOmpAtomicDefaultMemOrderClause::next_node = (SgOmpAtomicDefaultMemOrderClause*) (*block);
   61088             : 
   61089           0 :           while ( block != SgOmpAtomicDefaultMemOrderClause::pools.end() )
   61090             :              {
   61091           0 :                pointer = (SgOmpAtomicDefaultMemOrderClause*) (*block);
   61092           0 :                if ( tempPointer != NULL )
   61093             :                   {
   61094           0 :                     tempPointer->set_freepointer(pointer);
   61095             :                   }
   61096           0 :                for (unsigned i = 0; i < SgOmpAtomicDefaultMemOrderClause::pool_size - 1; ++i)
   61097             :                   {
   61098           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   61099             :                   }
   61100           0 :                 pointer[SgOmpAtomicDefaultMemOrderClause::pool_size-1].set_freepointer(NULL);
   61101           0 :                 tempPointer = &(pointer[SgOmpAtomicDefaultMemOrderClause::pool_size-1]);
   61102           0 :                 ++block;
   61103             :              }
   61104             :         }
   61105           0 :    }
   61106             : 
   61107           5 : void SgOmpAtomicDefaultMemOrderClause::deleteMemoryPool() {
   61108           5 :   for (auto p: SgOmpAtomicDefaultMemOrderClause::pools) {
   61109           0 :     ROSE_FREE(p);
   61110             :   }
   61111           5 :   SgOmpAtomicDefaultMemOrderClause::next_node = nullptr;
   61112           5 :   SgOmpAtomicDefaultMemOrderClause::pools.clear();
   61113           5 : }
   61114             : 
   61115             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   61116             : //                 reading multiple binary files to for a single AST.
   61117             : /////////// new version ////////////////////////////////
   61118             : //############################################################################
   61119             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   61120             : void
   61121           2 : SgOmpAtomicDefaultMemOrderClause::extendMemoryPoolForFileIO( )
   61122             :   {
   61123           2 :     size_t blockIndex = SgOmpAtomicDefaultMemOrderClause::pools.size();
   61124           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicDefaultMemOrderClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicDefaultMemOrderClause);
   61125             : 
   61126           2 :     while ( (blockIndex * SgOmpAtomicDefaultMemOrderClause::pool_size) < newPoolSize)
   61127             :       {
   61128             : #if ROSE_ALLOC_TRACE
   61129             :         if (blockIndex > 0) {
   61130             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicDefaultMemOrderClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicDefaultMemOrderClause) = %" PRIuPTR " SgOmpAtomicDefaultMemOrderClause::pool_size = %d \n",
   61131             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicDefaultMemOrderClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicDefaultMemOrderClause),SgOmpAtomicDefaultMemOrderClause::pool_size);
   61132             :         }
   61133             : #endif
   61134             : 
   61135           0 :         SgOmpAtomicDefaultMemOrderClause * pointer = (SgOmpAtomicDefaultMemOrderClause*) ROSE_MALLOC ( SgOmpAtomicDefaultMemOrderClause::pool_size * sizeof(SgOmpAtomicDefaultMemOrderClause) );
   61136           0 :         assert( pointer != NULL );
   61137             : #if ROSE_ALLOC_MEMSET == 1
   61138             :         memset(pointer, 0x00, SgOmpAtomicDefaultMemOrderClause::pool_size * sizeof(SgOmpAtomicDefaultMemOrderClause));
   61139             : #elif ROSE_ALLOC_MEMSET == 2
   61140             :         memset(pointer, 0xCC, SgOmpAtomicDefaultMemOrderClause::pool_size * sizeof(SgOmpAtomicDefaultMemOrderClause));
   61141             : #endif
   61142           0 :         SgOmpAtomicDefaultMemOrderClause::pools.push_back( (unsigned char*)(pointer) );
   61143           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAtomicDefaultMemOrderClause::pool_size * sizeof(SgOmpAtomicDefaultMemOrderClause), V_SgOmpAtomicDefaultMemOrderClause ) );
   61144             : 
   61145           0 :         if ( SgOmpAtomicDefaultMemOrderClause::next_node != NULL ) {
   61146           0 :           if ( blockIndex > 0 ) {
   61147           0 :             SgOmpAtomicDefaultMemOrderClause * blkptr = (SgOmpAtomicDefaultMemOrderClause*)(SgOmpAtomicDefaultMemOrderClause::pools[blockIndex-1]);
   61148           0 :             blkptr[ SgOmpAtomicDefaultMemOrderClause::pool_size - 1 ].set_freepointer(pointer);
   61149             :           }
   61150             :         } else {
   61151           0 :           SgOmpAtomicDefaultMemOrderClause::next_node = pointer;
   61152             :         }
   61153             : 
   61154           0 :         for (unsigned i = 0; i < SgOmpAtomicDefaultMemOrderClause::pool_size-1; ++i)
   61155             :            {
   61156           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   61157             :            }
   61158           0 :         pointer[ SgOmpAtomicDefaultMemOrderClause::pool_size -1 ].set_freepointer(NULL);
   61159             : 
   61160           0 :         blockIndex++;
   61161             :       }
   61162           2 :   }
   61163             : 
   61164             : //############################################################################
   61165             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   61166             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   61167             :  * not compressed. However, that stuff is not yet implemented! 
   61168             :  */
   61169             : unsigned long
   61170           0 : SgOmpAtomicDefaultMemOrderClause::getNumberOfLastValidPointer()
   61171             :    {
   61172           0 :       SgOmpAtomicDefaultMemOrderClause* testPointer = (SgOmpAtomicDefaultMemOrderClause*)(SgOmpAtomicDefaultMemOrderClause::pools.back());
   61173           0 :       unsigned long localIndex = SgOmpAtomicDefaultMemOrderClause::pool_size - 1;
   61174           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   61175             :          {
   61176           0 :            localIndex--;
   61177             :          }
   61178           0 :       return (localIndex + SgOmpAtomicDefaultMemOrderClause::pool_size * (SgOmpAtomicDefaultMemOrderClause::pools.size()-1));
   61179             :    }
   61180             : 
   61181             : //############################################################################
   61182             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   61183             :  * memory pool and initializes the data member in class SgOmpAtomicDefaultMemOrderClauseStroageClass
   61184             :  * from its counterpart of SgOmpAtomicDefaultMemOrderClause. The return value is just for checking, 
   61185             :  * that the whole StorageClassArray is initialized!
   61186             :  */
   61187             : unsigned long
   61188           0 : SgOmpAtomicDefaultMemOrderClause::initializeStorageClassArray( SgOmpAtomicDefaultMemOrderClauseStorageClass *storageArray )
   61189             :    {
   61190           0 :      unsigned long storageCounter = 0;
   61191           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAtomicDefaultMemOrderClause::pools.begin();
   61192           0 :      SgOmpAtomicDefaultMemOrderClause* pointer = NULL;
   61193           0 :      while ( block != SgOmpAtomicDefaultMemOrderClause::pools.end() ) {
   61194           0 :           pointer = (SgOmpAtomicDefaultMemOrderClause*) (*block);
   61195           0 :           for ( unsigned i = 0; i < SgOmpAtomicDefaultMemOrderClause::pool_size; ++i ) {
   61196           0 :                if ( pointer->get_freepointer() != NULL ) {
   61197           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   61198           0 :                  storageArray++;
   61199           0 :                  storageCounter++;
   61200             :                }
   61201           0 :                pointer++;
   61202             :              }
   61203           0 :            block++;
   61204             :         }
   61205           0 :      return storageCounter;
   61206             :    }
   61207             : 
   61208             : /* #line 61209 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   61209             : 
   61210             : 
   61211             : 
   61212             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   61213             : 
   61214             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   61215             : 
   61216             : //############################################################################
   61217             : /* JH (02/02/2006) Constructor of the IR node SgOmpExtImplementationDefinedRequirementClause that takes its 
   61218             :  * corresponding StorageClass as parameter
   61219             :  */
   61220           0 : SgOmpExtImplementationDefinedRequirementClause :: SgOmpExtImplementationDefinedRequirementClause ( const SgOmpExtImplementationDefinedRequirementClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   61221             :    {
   61222             : 
   61223             : 
   61224             : /* #line 61225 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   61225             : 
   61226           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   61227           0 :      p_implementation_defined_requirement =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_implementation_defined_requirement) );
   61228             : 
   61229             : 
   61230             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   61231             : 
   61232             : 
   61233           0 :    }
   61234             : 
   61235             : //############################################################################
   61236             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   61237             :  * within the working AST. 
   61238             :  */
   61239           0 : SgOmpExtImplementationDefinedRequirementClause * SgOmpExtImplementationDefinedRequirementClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   61240           0 :      SgOmpExtImplementationDefinedRequirementClause* returnPointer = NULL;
   61241           0 :      if ( globalIndex != 0 )
   61242             :         {
   61243             : 
   61244             : #if FILE_IO_EXTRA_CHECK
   61245           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpExtImplementationDefinedRequirementClause ) ) <= globalIndex ) ;
   61246           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpExtImplementationDefinedRequirementClause + 1 ) ) );
   61247             : #endif
   61248           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpExtImplementationDefinedRequirementClause )  
   61249           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpExtImplementationDefinedRequirementClause );
   61250           0 :           unsigned long positionInPool = localIndex % SgOmpExtImplementationDefinedRequirementClause::pool_size;
   61251           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpExtImplementationDefinedRequirementClause::pool_size;
   61252             : 
   61253             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   61254             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   61255             : 
   61256           0 :           returnPointer = &( ( (SgOmpExtImplementationDefinedRequirementClause*)(SgOmpExtImplementationDefinedRequirementClause::pools[memoryBlock]) ) [positionInPool]) ;
   61257             : 
   61258           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   61259             :         }
   61260           0 :      return returnPointer ;
   61261             :    }
   61262             : 
   61263             : //############################################################################
   61264             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   61265             :   for the AST with the index astIndex
   61266             : */
   61267           0 : SgOmpExtImplementationDefinedRequirementClause * SgOmpExtImplementationDefinedRequirementClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   61268           0 :      SgOmpExtImplementationDefinedRequirementClause* returnPointer = NULL;
   61269           0 :      if ( globalIndex != 0 )
   61270             :         {
   61271             : 
   61272             : #if FILE_IO_EXTRA_CHECK
   61273           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpExtImplementationDefinedRequirementClause ) ) <= globalIndex ) ;
   61274           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpExtImplementationDefinedRequirementClause + 1 ) ) );
   61275             : #endif
   61276           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpExtImplementationDefinedRequirementClause )
   61277           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpExtImplementationDefinedRequirementClause );
   61278           0 :           unsigned long positionInPool = localIndex % SgOmpExtImplementationDefinedRequirementClause::pool_size ;
   61279           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpExtImplementationDefinedRequirementClause::pool_size ;
   61280             : 
   61281             : #if FILE_IO_EXTRA_CHECK
   61282             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   61283             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   61284             : #endif
   61285             : 
   61286           0 :           returnPointer = &( ( (SgOmpExtImplementationDefinedRequirementClause*)(SgOmpExtImplementationDefinedRequirementClause::pools[memoryBlock]) ) [positionInPool]) ;
   61287             : 
   61288             : #if FILE_IO_EXTRA_CHECK
   61289           0 :           assert ( returnPointer != NULL ) ;
   61290             : #endif
   61291             :         }
   61292           0 :      return returnPointer ;
   61293             :    }
   61294             : 
   61295             : //############################################################################
   61296             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   61297             :  * pool size! We set for every valid object in the memory pool the freepointer
   61298             :  * to the global index and increase the global index afterwards. For all the 
   61299             :  * invalid objects (means address ranges within the memory pool that were not
   61300             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   61301             :  * distinguish valid from invalid objects! 
   61302             :  */
   61303             : unsigned long
   61304           5 : SgOmpExtImplementationDefinedRequirementClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   61305             :    {
   61306           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   61307           5 :      SgOmpExtImplementationDefinedRequirementClause* pointer = NULL;
   61308           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   61309           5 :      std::vector < unsigned char* > :: const_iterator block;
   61310           5 :      for ( block = SgOmpExtImplementationDefinedRequirementClause::pools.begin(); block != SgOmpExtImplementationDefinedRequirementClause::pools.end() ; ++block )
   61311             :         {
   61312           0 :           pointer = (SgOmpExtImplementationDefinedRequirementClause*)(*block);
   61313           0 :           for (unsigned i = 0; i < SgOmpExtImplementationDefinedRequirementClause::pool_size; ++i )
   61314             :              {
   61315             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   61316             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   61317             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   61318             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   61319             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   61320             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   61321             :             // properly; so this will have to be checked next.
   61322             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   61323             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   61324           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   61325             :                   {
   61326           0 :                     pointer[i].set_freepointer((SgOmpExtImplementationDefinedRequirementClause*)(globalIndex));
   61327           0 :                     globalIndex++;
   61328             :                   }
   61329             :                else
   61330             :                   {
   61331           0 :                     pointer[i].set_freepointer(NULL);
   61332             :                   }
   61333             :               }
   61334             :         }
   61335           5 :      return globalIndex;
   61336             :    }
   61337             : 
   61338             : //############################################################################
   61339             : // JH (01/14/2006)
   61340             : void
   61341           5 : SgOmpExtImplementationDefinedRequirementClause::resetValidFreepointers( )
   61342             :    {
   61343           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   61344           5 :      SgOmpExtImplementationDefinedRequirementClause* pointer = NULL;
   61345           5 :      std::vector < unsigned char* > :: const_iterator block;
   61346           5 :      SgOmpExtImplementationDefinedRequirementClause* pointerOfLinkedList = NULL;
   61347           5 :      for ( block = SgOmpExtImplementationDefinedRequirementClause::pools.begin(); block != SgOmpExtImplementationDefinedRequirementClause::pools.end() ; ++block )
   61348             :         {
   61349           0 :           pointer = (SgOmpExtImplementationDefinedRequirementClause*)(*block);
   61350           0 :           for (unsigned i = 0; i < SgOmpExtImplementationDefinedRequirementClause::pool_size; ++i )
   61351             :              {
   61352             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   61353             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   61354             :             // memory blocks!.
   61355           0 :                if ( pointer[i].get_freepointer() != NULL )
   61356             :                   {
   61357           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   61358             :                   }
   61359             :                else
   61360             :                   {
   61361           0 :                     if ( pointerOfLinkedList == NULL )
   61362             :                        {
   61363           0 :                          SgOmpExtImplementationDefinedRequirementClause::next_node = &(pointer[i]);
   61364             :                        }
   61365             :                     else
   61366             :                        {
   61367             :                       // printf ("In SgOmpExtImplementationDefinedRequirementClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   61368           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   61369             :                        }
   61370             :                     pointerOfLinkedList = &(pointer[i]);
   61371             :                   }
   61372             :               }
   61373             :         }
   61374             : 
   61375           5 :      if ( pointerOfLinkedList != NULL )
   61376             :         {
   61377             :        // printf ("In SgOmpExtImplementationDefinedRequirementClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   61378           0 :           pointerOfLinkedList->set_freepointer(NULL);
   61379             :        // DQ (6/6/2010): Temporary debugging...
   61380             :        //   ROSE_ASSERT(false);
   61381             :         }
   61382             : 
   61383           5 :      return ;
   61384             :    }
   61385             : 
   61386             : //############################################################################
   61387             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   61388             :  * within the memory pool and resets the freepointers, in order to achieve a 
   61389             :  * linked list, that has no jumps and starts at the beginning! This function 
   61390             :  * does not extend the memory pool, since we do not delete any memory blocks,
   61391             :  * but delete the valid objects.  
   61392             :  */
   61393             : void
   61394           0 : SgOmpExtImplementationDefinedRequirementClause::clearMemoryPool( )
   61395             :    {
   61396             :   // printf ("Inside of SgOmpExtImplementationDefinedRequirementClause::clearMemoryPool() \n");
   61397             : 
   61398           0 :      SgOmpExtImplementationDefinedRequirementClause* pointer = NULL, *tempPointer = NULL;
   61399           0 :      std::vector < unsigned char* > :: const_iterator block;
   61400           0 :      if ( SgOmpExtImplementationDefinedRequirementClause::pools.empty() == false )
   61401             :         {
   61402           0 :           block = SgOmpExtImplementationDefinedRequirementClause::pools.begin() ;
   61403           0 :           SgOmpExtImplementationDefinedRequirementClause::next_node = (SgOmpExtImplementationDefinedRequirementClause*) (*block);
   61404             : 
   61405           0 :           while ( block != SgOmpExtImplementationDefinedRequirementClause::pools.end() )
   61406             :              {
   61407           0 :                pointer = (SgOmpExtImplementationDefinedRequirementClause*) (*block);
   61408           0 :                if ( tempPointer != NULL )
   61409             :                   {
   61410           0 :                     tempPointer->set_freepointer(pointer);
   61411             :                   }
   61412           0 :                for (unsigned i = 0; i < SgOmpExtImplementationDefinedRequirementClause::pool_size - 1; ++i)
   61413             :                   {
   61414           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   61415             :                   }
   61416           0 :                 pointer[SgOmpExtImplementationDefinedRequirementClause::pool_size-1].set_freepointer(NULL);
   61417           0 :                 tempPointer = &(pointer[SgOmpExtImplementationDefinedRequirementClause::pool_size-1]);
   61418           0 :                 ++block;
   61419             :              }
   61420             :         }
   61421           0 :    }
   61422             : 
   61423           5 : void SgOmpExtImplementationDefinedRequirementClause::deleteMemoryPool() {
   61424           5 :   for (auto p: SgOmpExtImplementationDefinedRequirementClause::pools) {
   61425           0 :     ROSE_FREE(p);
   61426             :   }
   61427           5 :   SgOmpExtImplementationDefinedRequirementClause::next_node = nullptr;
   61428           5 :   SgOmpExtImplementationDefinedRequirementClause::pools.clear();
   61429           5 : }
   61430             : 
   61431             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   61432             : //                 reading multiple binary files to for a single AST.
   61433             : /////////// new version ////////////////////////////////
   61434             : //############################################################################
   61435             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   61436             : void
   61437           2 : SgOmpExtImplementationDefinedRequirementClause::extendMemoryPoolForFileIO( )
   61438             :   {
   61439           2 :     size_t blockIndex = SgOmpExtImplementationDefinedRequirementClause::pools.size();
   61440           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExtImplementationDefinedRequirementClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExtImplementationDefinedRequirementClause);
   61441             : 
   61442           2 :     while ( (blockIndex * SgOmpExtImplementationDefinedRequirementClause::pool_size) < newPoolSize)
   61443             :       {
   61444             : #if ROSE_ALLOC_TRACE
   61445             :         if (blockIndex > 0) {
   61446             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExtImplementationDefinedRequirementClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExtImplementationDefinedRequirementClause) = %" PRIuPTR " SgOmpExtImplementationDefinedRequirementClause::pool_size = %d \n",
   61447             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExtImplementationDefinedRequirementClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExtImplementationDefinedRequirementClause),SgOmpExtImplementationDefinedRequirementClause::pool_size);
   61448             :         }
   61449             : #endif
   61450             : 
   61451           0 :         SgOmpExtImplementationDefinedRequirementClause * pointer = (SgOmpExtImplementationDefinedRequirementClause*) ROSE_MALLOC ( SgOmpExtImplementationDefinedRequirementClause::pool_size * sizeof(SgOmpExtImplementationDefinedRequirementClause) );
   61452           0 :         assert( pointer != NULL );
   61453             : #if ROSE_ALLOC_MEMSET == 1
   61454             :         memset(pointer, 0x00, SgOmpExtImplementationDefinedRequirementClause::pool_size * sizeof(SgOmpExtImplementationDefinedRequirementClause));
   61455             : #elif ROSE_ALLOC_MEMSET == 2
   61456             :         memset(pointer, 0xCC, SgOmpExtImplementationDefinedRequirementClause::pool_size * sizeof(SgOmpExtImplementationDefinedRequirementClause));
   61457             : #endif
   61458           0 :         SgOmpExtImplementationDefinedRequirementClause::pools.push_back( (unsigned char*)(pointer) );
   61459           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpExtImplementationDefinedRequirementClause::pool_size * sizeof(SgOmpExtImplementationDefinedRequirementClause), V_SgOmpExtImplementationDefinedRequirementClause ) );
   61460             : 
   61461           0 :         if ( SgOmpExtImplementationDefinedRequirementClause::next_node != NULL ) {
   61462           0 :           if ( blockIndex > 0 ) {
   61463           0 :             SgOmpExtImplementationDefinedRequirementClause * blkptr = (SgOmpExtImplementationDefinedRequirementClause*)(SgOmpExtImplementationDefinedRequirementClause::pools[blockIndex-1]);
   61464           0 :             blkptr[ SgOmpExtImplementationDefinedRequirementClause::pool_size - 1 ].set_freepointer(pointer);
   61465             :           }
   61466             :         } else {
   61467           0 :           SgOmpExtImplementationDefinedRequirementClause::next_node = pointer;
   61468             :         }
   61469             : 
   61470           0 :         for (unsigned i = 0; i < SgOmpExtImplementationDefinedRequirementClause::pool_size-1; ++i)
   61471             :            {
   61472           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   61473             :            }
   61474           0 :         pointer[ SgOmpExtImplementationDefinedRequirementClause::pool_size -1 ].set_freepointer(NULL);
   61475             : 
   61476           0 :         blockIndex++;
   61477             :       }
   61478           2 :   }
   61479             : 
   61480             : //############################################################################
   61481             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   61482             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   61483             :  * not compressed. However, that stuff is not yet implemented! 
   61484             :  */
   61485             : unsigned long
   61486           0 : SgOmpExtImplementationDefinedRequirementClause::getNumberOfLastValidPointer()
   61487             :    {
   61488           0 :       SgOmpExtImplementationDefinedRequirementClause* testPointer = (SgOmpExtImplementationDefinedRequirementClause*)(SgOmpExtImplementationDefinedRequirementClause::pools.back());
   61489           0 :       unsigned long localIndex = SgOmpExtImplementationDefinedRequirementClause::pool_size - 1;
   61490           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   61491             :          {
   61492           0 :            localIndex--;
   61493             :          }
   61494           0 :       return (localIndex + SgOmpExtImplementationDefinedRequirementClause::pool_size * (SgOmpExtImplementationDefinedRequirementClause::pools.size()-1));
   61495             :    }
   61496             : 
   61497             : //############################################################################
   61498             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   61499             :  * memory pool and initializes the data member in class SgOmpExtImplementationDefinedRequirementClauseStroageClass
   61500             :  * from its counterpart of SgOmpExtImplementationDefinedRequirementClause. The return value is just for checking, 
   61501             :  * that the whole StorageClassArray is initialized!
   61502             :  */
   61503             : unsigned long
   61504           0 : SgOmpExtImplementationDefinedRequirementClause::initializeStorageClassArray( SgOmpExtImplementationDefinedRequirementClauseStorageClass *storageArray )
   61505             :    {
   61506           0 :      unsigned long storageCounter = 0;
   61507           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpExtImplementationDefinedRequirementClause::pools.begin();
   61508           0 :      SgOmpExtImplementationDefinedRequirementClause* pointer = NULL;
   61509           0 :      while ( block != SgOmpExtImplementationDefinedRequirementClause::pools.end() ) {
   61510           0 :           pointer = (SgOmpExtImplementationDefinedRequirementClause*) (*block);
   61511           0 :           for ( unsigned i = 0; i < SgOmpExtImplementationDefinedRequirementClause::pool_size; ++i ) {
   61512           0 :                if ( pointer->get_freepointer() != NULL ) {
   61513           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   61514           0 :                  storageArray++;
   61515           0 :                  storageCounter++;
   61516             :                }
   61517           0 :                pointer++;
   61518             :              }
   61519           0 :            block++;
   61520             :         }
   61521           0 :      return storageCounter;
   61522             :    }
   61523             : 
   61524             : /* #line 61525 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   61525             : 
   61526             : 
   61527             : 
   61528             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   61529             : 
   61530             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   61531             : 
   61532             : //############################################################################
   61533             : /* JH (02/02/2006) Constructor of the IR node SgOmpUsesAllocatorsDefination that takes its 
   61534             :  * corresponding StorageClass as parameter
   61535             :  */
   61536           0 : SgOmpUsesAllocatorsDefination :: SgOmpUsesAllocatorsDefination ( const SgOmpUsesAllocatorsDefinationStorageClass& storageSource )   : SgOmpClause (storageSource)
   61537             :    {
   61538             : 
   61539             : 
   61540             : /* #line 61541 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   61541             : 
   61542           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   61543           0 :      p_allocator = storageSource.storageOf_allocator ;
   61544           0 :      p_user_defined_allocator =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_defined_allocator) );
   61545           0 :      p_allocator_traits_array =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_allocator_traits_array) );
   61546             : 
   61547             : 
   61548             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   61549             : 
   61550             : 
   61551           0 :    }
   61552             : 
   61553             : //############################################################################
   61554             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   61555             :  * within the working AST. 
   61556             :  */
   61557           0 : SgOmpUsesAllocatorsDefination * SgOmpUsesAllocatorsDefination::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   61558           0 :      SgOmpUsesAllocatorsDefination* returnPointer = NULL;
   61559           0 :      if ( globalIndex != 0 )
   61560             :         {
   61561             : 
   61562             : #if FILE_IO_EXTRA_CHECK
   61563           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUsesAllocatorsDefination ) ) <= globalIndex ) ;
   61564           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUsesAllocatorsDefination + 1 ) ) );
   61565             : #endif
   61566           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUsesAllocatorsDefination )  
   61567           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUsesAllocatorsDefination );
   61568           0 :           unsigned long positionInPool = localIndex % SgOmpUsesAllocatorsDefination::pool_size;
   61569           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUsesAllocatorsDefination::pool_size;
   61570             : 
   61571             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   61572             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   61573             : 
   61574           0 :           returnPointer = &( ( (SgOmpUsesAllocatorsDefination*)(SgOmpUsesAllocatorsDefination::pools[memoryBlock]) ) [positionInPool]) ;
   61575             : 
   61576           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   61577             :         }
   61578           0 :      return returnPointer ;
   61579             :    }
   61580             : 
   61581             : //############################################################################
   61582             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   61583             :   for the AST with the index astIndex
   61584             : */
   61585           0 : SgOmpUsesAllocatorsDefination * SgOmpUsesAllocatorsDefination::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   61586           0 :      SgOmpUsesAllocatorsDefination* returnPointer = NULL;
   61587           0 :      if ( globalIndex != 0 )
   61588             :         {
   61589             : 
   61590             : #if FILE_IO_EXTRA_CHECK
   61591           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUsesAllocatorsDefination ) ) <= globalIndex ) ;
   61592           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUsesAllocatorsDefination + 1 ) ) );
   61593             : #endif
   61594           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUsesAllocatorsDefination )
   61595           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUsesAllocatorsDefination );
   61596           0 :           unsigned long positionInPool = localIndex % SgOmpUsesAllocatorsDefination::pool_size ;
   61597           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUsesAllocatorsDefination::pool_size ;
   61598             : 
   61599             : #if FILE_IO_EXTRA_CHECK
   61600             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   61601             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   61602             : #endif
   61603             : 
   61604           0 :           returnPointer = &( ( (SgOmpUsesAllocatorsDefination*)(SgOmpUsesAllocatorsDefination::pools[memoryBlock]) ) [positionInPool]) ;
   61605             : 
   61606             : #if FILE_IO_EXTRA_CHECK
   61607           0 :           assert ( returnPointer != NULL ) ;
   61608             : #endif
   61609             :         }
   61610           0 :      return returnPointer ;
   61611             :    }
   61612             : 
   61613             : //############################################################################
   61614             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   61615             :  * pool size! We set for every valid object in the memory pool the freepointer
   61616             :  * to the global index and increase the global index afterwards. For all the 
   61617             :  * invalid objects (means address ranges within the memory pool that were not
   61618             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   61619             :  * distinguish valid from invalid objects! 
   61620             :  */
   61621             : unsigned long
   61622           5 : SgOmpUsesAllocatorsDefination::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   61623             :    {
   61624           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   61625           5 :      SgOmpUsesAllocatorsDefination* pointer = NULL;
   61626           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   61627           5 :      std::vector < unsigned char* > :: const_iterator block;
   61628           5 :      for ( block = SgOmpUsesAllocatorsDefination::pools.begin(); block != SgOmpUsesAllocatorsDefination::pools.end() ; ++block )
   61629             :         {
   61630           0 :           pointer = (SgOmpUsesAllocatorsDefination*)(*block);
   61631           0 :           for (unsigned i = 0; i < SgOmpUsesAllocatorsDefination::pool_size; ++i )
   61632             :              {
   61633             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   61634             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   61635             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   61636             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   61637             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   61638             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   61639             :             // properly; so this will have to be checked next.
   61640             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   61641             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   61642           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   61643             :                   {
   61644           0 :                     pointer[i].set_freepointer((SgOmpUsesAllocatorsDefination*)(globalIndex));
   61645           0 :                     globalIndex++;
   61646             :                   }
   61647             :                else
   61648             :                   {
   61649           0 :                     pointer[i].set_freepointer(NULL);
   61650             :                   }
   61651             :               }
   61652             :         }
   61653           5 :      return globalIndex;
   61654             :    }
   61655             : 
   61656             : //############################################################################
   61657             : // JH (01/14/2006)
   61658             : void
   61659           5 : SgOmpUsesAllocatorsDefination::resetValidFreepointers( )
   61660             :    {
   61661           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   61662           5 :      SgOmpUsesAllocatorsDefination* pointer = NULL;
   61663           5 :      std::vector < unsigned char* > :: const_iterator block;
   61664           5 :      SgOmpUsesAllocatorsDefination* pointerOfLinkedList = NULL;
   61665           5 :      for ( block = SgOmpUsesAllocatorsDefination::pools.begin(); block != SgOmpUsesAllocatorsDefination::pools.end() ; ++block )
   61666             :         {
   61667           0 :           pointer = (SgOmpUsesAllocatorsDefination*)(*block);
   61668           0 :           for (unsigned i = 0; i < SgOmpUsesAllocatorsDefination::pool_size; ++i )
   61669             :              {
   61670             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   61671             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   61672             :             // memory blocks!.
   61673           0 :                if ( pointer[i].get_freepointer() != NULL )
   61674             :                   {
   61675           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   61676             :                   }
   61677             :                else
   61678             :                   {
   61679           0 :                     if ( pointerOfLinkedList == NULL )
   61680             :                        {
   61681           0 :                          SgOmpUsesAllocatorsDefination::next_node = &(pointer[i]);
   61682             :                        }
   61683             :                     else
   61684             :                        {
   61685             :                       // printf ("In SgOmpUsesAllocatorsDefination::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   61686           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   61687             :                        }
   61688             :                     pointerOfLinkedList = &(pointer[i]);
   61689             :                   }
   61690             :               }
   61691             :         }
   61692             : 
   61693           5 :      if ( pointerOfLinkedList != NULL )
   61694             :         {
   61695             :        // printf ("In SgOmpUsesAllocatorsDefination::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   61696           0 :           pointerOfLinkedList->set_freepointer(NULL);
   61697             :        // DQ (6/6/2010): Temporary debugging...
   61698             :        //   ROSE_ASSERT(false);
   61699             :         }
   61700             : 
   61701           5 :      return ;
   61702             :    }
   61703             : 
   61704             : //############################################################################
   61705             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   61706             :  * within the memory pool and resets the freepointers, in order to achieve a 
   61707             :  * linked list, that has no jumps and starts at the beginning! This function 
   61708             :  * does not extend the memory pool, since we do not delete any memory blocks,
   61709             :  * but delete the valid objects.  
   61710             :  */
   61711             : void
   61712           0 : SgOmpUsesAllocatorsDefination::clearMemoryPool( )
   61713             :    {
   61714             :   // printf ("Inside of SgOmpUsesAllocatorsDefination::clearMemoryPool() \n");
   61715             : 
   61716           0 :      SgOmpUsesAllocatorsDefination* pointer = NULL, *tempPointer = NULL;
   61717           0 :      std::vector < unsigned char* > :: const_iterator block;
   61718           0 :      if ( SgOmpUsesAllocatorsDefination::pools.empty() == false )
   61719             :         {
   61720           0 :           block = SgOmpUsesAllocatorsDefination::pools.begin() ;
   61721           0 :           SgOmpUsesAllocatorsDefination::next_node = (SgOmpUsesAllocatorsDefination*) (*block);
   61722             : 
   61723           0 :           while ( block != SgOmpUsesAllocatorsDefination::pools.end() )
   61724             :              {
   61725           0 :                pointer = (SgOmpUsesAllocatorsDefination*) (*block);
   61726           0 :                if ( tempPointer != NULL )
   61727             :                   {
   61728           0 :                     tempPointer->set_freepointer(pointer);
   61729             :                   }
   61730           0 :                for (unsigned i = 0; i < SgOmpUsesAllocatorsDefination::pool_size - 1; ++i)
   61731             :                   {
   61732           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   61733             :                   }
   61734           0 :                 pointer[SgOmpUsesAllocatorsDefination::pool_size-1].set_freepointer(NULL);
   61735           0 :                 tempPointer = &(pointer[SgOmpUsesAllocatorsDefination::pool_size-1]);
   61736           0 :                 ++block;
   61737             :              }
   61738             :         }
   61739           0 :    }
   61740             : 
   61741           5 : void SgOmpUsesAllocatorsDefination::deleteMemoryPool() {
   61742           5 :   for (auto p: SgOmpUsesAllocatorsDefination::pools) {
   61743           0 :     ROSE_FREE(p);
   61744             :   }
   61745           5 :   SgOmpUsesAllocatorsDefination::next_node = nullptr;
   61746           5 :   SgOmpUsesAllocatorsDefination::pools.clear();
   61747           5 : }
   61748             : 
   61749             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   61750             : //                 reading multiple binary files to for a single AST.
   61751             : /////////// new version ////////////////////////////////
   61752             : //############################################################################
   61753             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   61754             : void
   61755           2 : SgOmpUsesAllocatorsDefination::extendMemoryPoolForFileIO( )
   61756             :   {
   61757           2 :     size_t blockIndex = SgOmpUsesAllocatorsDefination::pools.size();
   61758           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUsesAllocatorsDefination) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUsesAllocatorsDefination);
   61759             : 
   61760           2 :     while ( (blockIndex * SgOmpUsesAllocatorsDefination::pool_size) < newPoolSize)
   61761             :       {
   61762             : #if ROSE_ALLOC_TRACE
   61763             :         if (blockIndex > 0) {
   61764             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUsesAllocatorsDefination) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUsesAllocatorsDefination) = %" PRIuPTR " SgOmpUsesAllocatorsDefination::pool_size = %d \n",
   61765             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUsesAllocatorsDefination),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUsesAllocatorsDefination),SgOmpUsesAllocatorsDefination::pool_size);
   61766             :         }
   61767             : #endif
   61768             : 
   61769           0 :         SgOmpUsesAllocatorsDefination * pointer = (SgOmpUsesAllocatorsDefination*) ROSE_MALLOC ( SgOmpUsesAllocatorsDefination::pool_size * sizeof(SgOmpUsesAllocatorsDefination) );
   61770           0 :         assert( pointer != NULL );
   61771             : #if ROSE_ALLOC_MEMSET == 1
   61772             :         memset(pointer, 0x00, SgOmpUsesAllocatorsDefination::pool_size * sizeof(SgOmpUsesAllocatorsDefination));
   61773             : #elif ROSE_ALLOC_MEMSET == 2
   61774             :         memset(pointer, 0xCC, SgOmpUsesAllocatorsDefination::pool_size * sizeof(SgOmpUsesAllocatorsDefination));
   61775             : #endif
   61776           0 :         SgOmpUsesAllocatorsDefination::pools.push_back( (unsigned char*)(pointer) );
   61777           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUsesAllocatorsDefination::pool_size * sizeof(SgOmpUsesAllocatorsDefination), V_SgOmpUsesAllocatorsDefination ) );
   61778             : 
   61779           0 :         if ( SgOmpUsesAllocatorsDefination::next_node != NULL ) {
   61780           0 :           if ( blockIndex > 0 ) {
   61781           0 :             SgOmpUsesAllocatorsDefination * blkptr = (SgOmpUsesAllocatorsDefination*)(SgOmpUsesAllocatorsDefination::pools[blockIndex-1]);
   61782           0 :             blkptr[ SgOmpUsesAllocatorsDefination::pool_size - 1 ].set_freepointer(pointer);
   61783             :           }
   61784             :         } else {
   61785           0 :           SgOmpUsesAllocatorsDefination::next_node = pointer;
   61786             :         }
   61787             : 
   61788           0 :         for (unsigned i = 0; i < SgOmpUsesAllocatorsDefination::pool_size-1; ++i)
   61789             :            {
   61790           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   61791             :            }
   61792           0 :         pointer[ SgOmpUsesAllocatorsDefination::pool_size -1 ].set_freepointer(NULL);
   61793             : 
   61794           0 :         blockIndex++;
   61795             :       }
   61796           2 :   }
   61797             : 
   61798             : //############################################################################
   61799             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   61800             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   61801             :  * not compressed. However, that stuff is not yet implemented! 
   61802             :  */
   61803             : unsigned long
   61804           0 : SgOmpUsesAllocatorsDefination::getNumberOfLastValidPointer()
   61805             :    {
   61806           0 :       SgOmpUsesAllocatorsDefination* testPointer = (SgOmpUsesAllocatorsDefination*)(SgOmpUsesAllocatorsDefination::pools.back());
   61807           0 :       unsigned long localIndex = SgOmpUsesAllocatorsDefination::pool_size - 1;
   61808           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   61809             :          {
   61810           0 :            localIndex--;
   61811             :          }
   61812           0 :       return (localIndex + SgOmpUsesAllocatorsDefination::pool_size * (SgOmpUsesAllocatorsDefination::pools.size()-1));
   61813             :    }
   61814             : 
   61815             : //############################################################################
   61816             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   61817             :  * memory pool and initializes the data member in class SgOmpUsesAllocatorsDefinationStroageClass
   61818             :  * from its counterpart of SgOmpUsesAllocatorsDefination. The return value is just for checking, 
   61819             :  * that the whole StorageClassArray is initialized!
   61820             :  */
   61821             : unsigned long
   61822           0 : SgOmpUsesAllocatorsDefination::initializeStorageClassArray( SgOmpUsesAllocatorsDefinationStorageClass *storageArray )
   61823             :    {
   61824           0 :      unsigned long storageCounter = 0;
   61825           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUsesAllocatorsDefination::pools.begin();
   61826           0 :      SgOmpUsesAllocatorsDefination* pointer = NULL;
   61827           0 :      while ( block != SgOmpUsesAllocatorsDefination::pools.end() ) {
   61828           0 :           pointer = (SgOmpUsesAllocatorsDefination*) (*block);
   61829           0 :           for ( unsigned i = 0; i < SgOmpUsesAllocatorsDefination::pool_size; ++i ) {
   61830           0 :                if ( pointer->get_freepointer() != NULL ) {
   61831           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   61832           0 :                  storageArray++;
   61833           0 :                  storageCounter++;
   61834             :                }
   61835           0 :                pointer++;
   61836             :              }
   61837           0 :            block++;
   61838             :         }
   61839           0 :      return storageCounter;
   61840             :    }
   61841             : 
   61842             : /* #line 61843 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   61843             : 
   61844             : 
   61845             : 
   61846             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   61847             : 
   61848             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   61849             : 
   61850             : //############################################################################
   61851             : /* JH (02/02/2006) Constructor of the IR node SgOmpVariablesClause that takes its 
   61852             :  * corresponding StorageClass as parameter
   61853             :  */
   61854           0 : SgOmpVariablesClause :: SgOmpVariablesClause ( const SgOmpVariablesClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   61855             :    {
   61856             : 
   61857             : 
   61858             : /* #line 61859 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   61859             : 
   61860           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   61861           0 :      p_variables =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_variables) );
   61862             : 
   61863             : 
   61864             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   61865             : 
   61866             : 
   61867           0 :    }
   61868             : 
   61869             : //############################################################################
   61870             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   61871             :  * within the working AST. 
   61872             :  */
   61873           0 : SgOmpVariablesClause * SgOmpVariablesClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   61874           0 :      SgOmpVariablesClause* returnPointer = NULL;
   61875           0 :      if ( globalIndex != 0 )
   61876             :         {
   61877             : 
   61878             : #if FILE_IO_EXTRA_CHECK
   61879           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpVariablesClause ) ) <= globalIndex ) ;
   61880           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpVariablesClause + 1 ) ) );
   61881             : #endif
   61882           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpVariablesClause )  
   61883           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpVariablesClause );
   61884           0 :           unsigned long positionInPool = localIndex % SgOmpVariablesClause::pool_size;
   61885           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpVariablesClause::pool_size;
   61886             : 
   61887             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   61888             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   61889             : 
   61890           0 :           returnPointer = &( ( (SgOmpVariablesClause*)(SgOmpVariablesClause::pools[memoryBlock]) ) [positionInPool]) ;
   61891             : 
   61892           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   61893             :         }
   61894           0 :      return returnPointer ;
   61895             :    }
   61896             : 
   61897             : //############################################################################
   61898             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   61899             :   for the AST with the index astIndex
   61900             : */
   61901           0 : SgOmpVariablesClause * SgOmpVariablesClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   61902           0 :      SgOmpVariablesClause* returnPointer = NULL;
   61903           0 :      if ( globalIndex != 0 )
   61904             :         {
   61905             : 
   61906             : #if FILE_IO_EXTRA_CHECK
   61907           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpVariablesClause ) ) <= globalIndex ) ;
   61908           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpVariablesClause + 1 ) ) );
   61909             : #endif
   61910           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpVariablesClause )
   61911           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpVariablesClause );
   61912           0 :           unsigned long positionInPool = localIndex % SgOmpVariablesClause::pool_size ;
   61913           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpVariablesClause::pool_size ;
   61914             : 
   61915             : #if FILE_IO_EXTRA_CHECK
   61916             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   61917             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   61918             : #endif
   61919             : 
   61920           0 :           returnPointer = &( ( (SgOmpVariablesClause*)(SgOmpVariablesClause::pools[memoryBlock]) ) [positionInPool]) ;
   61921             : 
   61922             : #if FILE_IO_EXTRA_CHECK
   61923           0 :           assert ( returnPointer != NULL ) ;
   61924             : #endif
   61925             :         }
   61926           0 :      return returnPointer ;
   61927             :    }
   61928             : 
   61929             : //############################################################################
   61930             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   61931             :  * pool size! We set for every valid object in the memory pool the freepointer
   61932             :  * to the global index and increase the global index afterwards. For all the 
   61933             :  * invalid objects (means address ranges within the memory pool that were not
   61934             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   61935             :  * distinguish valid from invalid objects! 
   61936             :  */
   61937             : unsigned long
   61938           5 : SgOmpVariablesClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   61939             :    {
   61940           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   61941           5 :      SgOmpVariablesClause* pointer = NULL;
   61942           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   61943           5 :      std::vector < unsigned char* > :: const_iterator block;
   61944           5 :      for ( block = SgOmpVariablesClause::pools.begin(); block != SgOmpVariablesClause::pools.end() ; ++block )
   61945             :         {
   61946           0 :           pointer = (SgOmpVariablesClause*)(*block);
   61947           0 :           for (unsigned i = 0; i < SgOmpVariablesClause::pool_size; ++i )
   61948             :              {
   61949             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   61950             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   61951             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   61952             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   61953             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   61954             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   61955             :             // properly; so this will have to be checked next.
   61956             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   61957             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   61958           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   61959             :                   {
   61960           0 :                     pointer[i].set_freepointer((SgOmpVariablesClause*)(globalIndex));
   61961           0 :                     globalIndex++;
   61962             :                   }
   61963             :                else
   61964             :                   {
   61965           0 :                     pointer[i].set_freepointer(NULL);
   61966             :                   }
   61967             :               }
   61968             :         }
   61969           5 :      return globalIndex;
   61970             :    }
   61971             : 
   61972             : //############################################################################
   61973             : // JH (01/14/2006)
   61974             : void
   61975           5 : SgOmpVariablesClause::resetValidFreepointers( )
   61976             :    {
   61977           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   61978           5 :      SgOmpVariablesClause* pointer = NULL;
   61979           5 :      std::vector < unsigned char* > :: const_iterator block;
   61980           5 :      SgOmpVariablesClause* pointerOfLinkedList = NULL;
   61981           5 :      for ( block = SgOmpVariablesClause::pools.begin(); block != SgOmpVariablesClause::pools.end() ; ++block )
   61982             :         {
   61983           0 :           pointer = (SgOmpVariablesClause*)(*block);
   61984           0 :           for (unsigned i = 0; i < SgOmpVariablesClause::pool_size; ++i )
   61985             :              {
   61986             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   61987             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   61988             :             // memory blocks!.
   61989           0 :                if ( pointer[i].get_freepointer() != NULL )
   61990             :                   {
   61991           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   61992             :                   }
   61993             :                else
   61994             :                   {
   61995           0 :                     if ( pointerOfLinkedList == NULL )
   61996             :                        {
   61997           0 :                          SgOmpVariablesClause::next_node = &(pointer[i]);
   61998             :                        }
   61999             :                     else
   62000             :                        {
   62001             :                       // printf ("In SgOmpVariablesClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   62002           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   62003             :                        }
   62004             :                     pointerOfLinkedList = &(pointer[i]);
   62005             :                   }
   62006             :               }
   62007             :         }
   62008             : 
   62009           5 :      if ( pointerOfLinkedList != NULL )
   62010             :         {
   62011             :        // printf ("In SgOmpVariablesClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   62012           0 :           pointerOfLinkedList->set_freepointer(NULL);
   62013             :        // DQ (6/6/2010): Temporary debugging...
   62014             :        //   ROSE_ASSERT(false);
   62015             :         }
   62016             : 
   62017           5 :      return ;
   62018             :    }
   62019             : 
   62020             : //############################################################################
   62021             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   62022             :  * within the memory pool and resets the freepointers, in order to achieve a 
   62023             :  * linked list, that has no jumps and starts at the beginning! This function 
   62024             :  * does not extend the memory pool, since we do not delete any memory blocks,
   62025             :  * but delete the valid objects.  
   62026             :  */
   62027             : void
   62028           0 : SgOmpVariablesClause::clearMemoryPool( )
   62029             :    {
   62030             :   // printf ("Inside of SgOmpVariablesClause::clearMemoryPool() \n");
   62031             : 
   62032           0 :      SgOmpVariablesClause* pointer = NULL, *tempPointer = NULL;
   62033           0 :      std::vector < unsigned char* > :: const_iterator block;
   62034           0 :      if ( SgOmpVariablesClause::pools.empty() == false )
   62035             :         {
   62036           0 :           block = SgOmpVariablesClause::pools.begin() ;
   62037           0 :           SgOmpVariablesClause::next_node = (SgOmpVariablesClause*) (*block);
   62038             : 
   62039           0 :           while ( block != SgOmpVariablesClause::pools.end() )
   62040             :              {
   62041           0 :                pointer = (SgOmpVariablesClause*) (*block);
   62042           0 :                if ( tempPointer != NULL )
   62043             :                   {
   62044           0 :                     tempPointer->set_freepointer(pointer);
   62045             :                   }
   62046           0 :                for (unsigned i = 0; i < SgOmpVariablesClause::pool_size - 1; ++i)
   62047             :                   {
   62048           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   62049             :                   }
   62050           0 :                 pointer[SgOmpVariablesClause::pool_size-1].set_freepointer(NULL);
   62051           0 :                 tempPointer = &(pointer[SgOmpVariablesClause::pool_size-1]);
   62052           0 :                 ++block;
   62053             :              }
   62054             :         }
   62055           0 :    }
   62056             : 
   62057           5 : void SgOmpVariablesClause::deleteMemoryPool() {
   62058           5 :   for (auto p: SgOmpVariablesClause::pools) {
   62059           0 :     ROSE_FREE(p);
   62060             :   }
   62061           5 :   SgOmpVariablesClause::next_node = nullptr;
   62062           5 :   SgOmpVariablesClause::pools.clear();
   62063           5 : }
   62064             : 
   62065             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   62066             : //                 reading multiple binary files to for a single AST.
   62067             : /////////// new version ////////////////////////////////
   62068             : //############################################################################
   62069             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   62070             : void
   62071           2 : SgOmpVariablesClause::extendMemoryPoolForFileIO( )
   62072             :   {
   62073           2 :     size_t blockIndex = SgOmpVariablesClause::pools.size();
   62074           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpVariablesClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpVariablesClause);
   62075             : 
   62076           2 :     while ( (blockIndex * SgOmpVariablesClause::pool_size) < newPoolSize)
   62077             :       {
   62078             : #if ROSE_ALLOC_TRACE
   62079             :         if (blockIndex > 0) {
   62080             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpVariablesClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpVariablesClause) = %" PRIuPTR " SgOmpVariablesClause::pool_size = %d \n",
   62081             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpVariablesClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpVariablesClause),SgOmpVariablesClause::pool_size);
   62082             :         }
   62083             : #endif
   62084             : 
   62085           0 :         SgOmpVariablesClause * pointer = (SgOmpVariablesClause*) ROSE_MALLOC ( SgOmpVariablesClause::pool_size * sizeof(SgOmpVariablesClause) );
   62086           0 :         assert( pointer != NULL );
   62087             : #if ROSE_ALLOC_MEMSET == 1
   62088             :         memset(pointer, 0x00, SgOmpVariablesClause::pool_size * sizeof(SgOmpVariablesClause));
   62089             : #elif ROSE_ALLOC_MEMSET == 2
   62090             :         memset(pointer, 0xCC, SgOmpVariablesClause::pool_size * sizeof(SgOmpVariablesClause));
   62091             : #endif
   62092           0 :         SgOmpVariablesClause::pools.push_back( (unsigned char*)(pointer) );
   62093           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpVariablesClause::pool_size * sizeof(SgOmpVariablesClause), V_SgOmpVariablesClause ) );
   62094             : 
   62095           0 :         if ( SgOmpVariablesClause::next_node != NULL ) {
   62096           0 :           if ( blockIndex > 0 ) {
   62097           0 :             SgOmpVariablesClause * blkptr = (SgOmpVariablesClause*)(SgOmpVariablesClause::pools[blockIndex-1]);
   62098           0 :             blkptr[ SgOmpVariablesClause::pool_size - 1 ].set_freepointer(pointer);
   62099             :           }
   62100             :         } else {
   62101           0 :           SgOmpVariablesClause::next_node = pointer;
   62102             :         }
   62103             : 
   62104           0 :         for (unsigned i = 0; i < SgOmpVariablesClause::pool_size-1; ++i)
   62105             :            {
   62106           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   62107             :            }
   62108           0 :         pointer[ SgOmpVariablesClause::pool_size -1 ].set_freepointer(NULL);
   62109             : 
   62110           0 :         blockIndex++;
   62111             :       }
   62112           2 :   }
   62113             : 
   62114             : //############################################################################
   62115             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   62116             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   62117             :  * not compressed. However, that stuff is not yet implemented! 
   62118             :  */
   62119             : unsigned long
   62120           0 : SgOmpVariablesClause::getNumberOfLastValidPointer()
   62121             :    {
   62122           0 :       SgOmpVariablesClause* testPointer = (SgOmpVariablesClause*)(SgOmpVariablesClause::pools.back());
   62123           0 :       unsigned long localIndex = SgOmpVariablesClause::pool_size - 1;
   62124           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   62125             :          {
   62126           0 :            localIndex--;
   62127             :          }
   62128           0 :       return (localIndex + SgOmpVariablesClause::pool_size * (SgOmpVariablesClause::pools.size()-1));
   62129             :    }
   62130             : 
   62131             : //############################################################################
   62132             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   62133             :  * memory pool and initializes the data member in class SgOmpVariablesClauseStroageClass
   62134             :  * from its counterpart of SgOmpVariablesClause. The return value is just for checking, 
   62135             :  * that the whole StorageClassArray is initialized!
   62136             :  */
   62137             : unsigned long
   62138           0 : SgOmpVariablesClause::initializeStorageClassArray( SgOmpVariablesClauseStorageClass *storageArray )
   62139             :    {
   62140           0 :      unsigned long storageCounter = 0;
   62141           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpVariablesClause::pools.begin();
   62142           0 :      SgOmpVariablesClause* pointer = NULL;
   62143           0 :      while ( block != SgOmpVariablesClause::pools.end() ) {
   62144           0 :           pointer = (SgOmpVariablesClause*) (*block);
   62145           0 :           for ( unsigned i = 0; i < SgOmpVariablesClause::pool_size; ++i ) {
   62146           0 :                if ( pointer->get_freepointer() != NULL ) {
   62147           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   62148           0 :                  storageArray++;
   62149           0 :                  storageCounter++;
   62150             :                }
   62151           0 :                pointer++;
   62152             :              }
   62153           0 :            block++;
   62154             :         }
   62155           0 :      return storageCounter;
   62156             :    }
   62157             : 
   62158             : /* #line 62159 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   62159             : 
   62160             : 
   62161             : 
   62162             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   62163             : 
   62164             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   62165             : 
   62166             : //############################################################################
   62167             : /* JH (02/02/2006) Constructor of the IR node SgOmpCopyprivateClause that takes its 
   62168             :  * corresponding StorageClass as parameter
   62169             :  */
   62170           0 : SgOmpCopyprivateClause :: SgOmpCopyprivateClause ( const SgOmpCopyprivateClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   62171             :    {
   62172             : 
   62173             : 
   62174             : /* #line 62175 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   62175             : 
   62176           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   62177             : 
   62178             : 
   62179             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   62180             : 
   62181             : 
   62182           0 :    }
   62183             : 
   62184             : //############################################################################
   62185             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   62186             :  * within the working AST. 
   62187             :  */
   62188           0 : SgOmpCopyprivateClause * SgOmpCopyprivateClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   62189           0 :      SgOmpCopyprivateClause* returnPointer = NULL;
   62190           0 :      if ( globalIndex != 0 )
   62191             :         {
   62192             : 
   62193             : #if FILE_IO_EXTRA_CHECK
   62194           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpCopyprivateClause ) ) <= globalIndex ) ;
   62195           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCopyprivateClause + 1 ) ) );
   62196             : #endif
   62197           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCopyprivateClause )  
   62198           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpCopyprivateClause );
   62199           0 :           unsigned long positionInPool = localIndex % SgOmpCopyprivateClause::pool_size;
   62200           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCopyprivateClause::pool_size;
   62201             : 
   62202             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   62203             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   62204             : 
   62205           0 :           returnPointer = &( ( (SgOmpCopyprivateClause*)(SgOmpCopyprivateClause::pools[memoryBlock]) ) [positionInPool]) ;
   62206             : 
   62207           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   62208             :         }
   62209           0 :      return returnPointer ;
   62210             :    }
   62211             : 
   62212             : //############################################################################
   62213             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   62214             :   for the AST with the index astIndex
   62215             : */
   62216           0 : SgOmpCopyprivateClause * SgOmpCopyprivateClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   62217           0 :      SgOmpCopyprivateClause* returnPointer = NULL;
   62218           0 :      if ( globalIndex != 0 )
   62219             :         {
   62220             : 
   62221             : #if FILE_IO_EXTRA_CHECK
   62222           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpCopyprivateClause ) ) <= globalIndex ) ;
   62223           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCopyprivateClause + 1 ) ) );
   62224             : #endif
   62225           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCopyprivateClause )
   62226           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpCopyprivateClause );
   62227           0 :           unsigned long positionInPool = localIndex % SgOmpCopyprivateClause::pool_size ;
   62228           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCopyprivateClause::pool_size ;
   62229             : 
   62230             : #if FILE_IO_EXTRA_CHECK
   62231             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   62232             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   62233             : #endif
   62234             : 
   62235           0 :           returnPointer = &( ( (SgOmpCopyprivateClause*)(SgOmpCopyprivateClause::pools[memoryBlock]) ) [positionInPool]) ;
   62236             : 
   62237             : #if FILE_IO_EXTRA_CHECK
   62238           0 :           assert ( returnPointer != NULL ) ;
   62239             : #endif
   62240             :         }
   62241           0 :      return returnPointer ;
   62242             :    }
   62243             : 
   62244             : //############################################################################
   62245             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   62246             :  * pool size! We set for every valid object in the memory pool the freepointer
   62247             :  * to the global index and increase the global index afterwards. For all the 
   62248             :  * invalid objects (means address ranges within the memory pool that were not
   62249             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   62250             :  * distinguish valid from invalid objects! 
   62251             :  */
   62252             : unsigned long
   62253           5 : SgOmpCopyprivateClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   62254             :    {
   62255           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   62256           5 :      SgOmpCopyprivateClause* pointer = NULL;
   62257           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   62258           5 :      std::vector < unsigned char* > :: const_iterator block;
   62259           5 :      for ( block = SgOmpCopyprivateClause::pools.begin(); block != SgOmpCopyprivateClause::pools.end() ; ++block )
   62260             :         {
   62261           0 :           pointer = (SgOmpCopyprivateClause*)(*block);
   62262           0 :           for (unsigned i = 0; i < SgOmpCopyprivateClause::pool_size; ++i )
   62263             :              {
   62264             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   62265             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   62266             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   62267             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   62268             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   62269             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   62270             :             // properly; so this will have to be checked next.
   62271             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   62272             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   62273           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   62274             :                   {
   62275           0 :                     pointer[i].set_freepointer((SgOmpCopyprivateClause*)(globalIndex));
   62276           0 :                     globalIndex++;
   62277             :                   }
   62278             :                else
   62279             :                   {
   62280           0 :                     pointer[i].set_freepointer(NULL);
   62281             :                   }
   62282             :               }
   62283             :         }
   62284           5 :      return globalIndex;
   62285             :    }
   62286             : 
   62287             : //############################################################################
   62288             : // JH (01/14/2006)
   62289             : void
   62290           5 : SgOmpCopyprivateClause::resetValidFreepointers( )
   62291             :    {
   62292           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   62293           5 :      SgOmpCopyprivateClause* pointer = NULL;
   62294           5 :      std::vector < unsigned char* > :: const_iterator block;
   62295           5 :      SgOmpCopyprivateClause* pointerOfLinkedList = NULL;
   62296           5 :      for ( block = SgOmpCopyprivateClause::pools.begin(); block != SgOmpCopyprivateClause::pools.end() ; ++block )
   62297             :         {
   62298           0 :           pointer = (SgOmpCopyprivateClause*)(*block);
   62299           0 :           for (unsigned i = 0; i < SgOmpCopyprivateClause::pool_size; ++i )
   62300             :              {
   62301             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   62302             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   62303             :             // memory blocks!.
   62304           0 :                if ( pointer[i].get_freepointer() != NULL )
   62305             :                   {
   62306           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   62307             :                   }
   62308             :                else
   62309             :                   {
   62310           0 :                     if ( pointerOfLinkedList == NULL )
   62311             :                        {
   62312           0 :                          SgOmpCopyprivateClause::next_node = &(pointer[i]);
   62313             :                        }
   62314             :                     else
   62315             :                        {
   62316             :                       // printf ("In SgOmpCopyprivateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   62317           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   62318             :                        }
   62319             :                     pointerOfLinkedList = &(pointer[i]);
   62320             :                   }
   62321             :               }
   62322             :         }
   62323             : 
   62324           5 :      if ( pointerOfLinkedList != NULL )
   62325             :         {
   62326             :        // printf ("In SgOmpCopyprivateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   62327           0 :           pointerOfLinkedList->set_freepointer(NULL);
   62328             :        // DQ (6/6/2010): Temporary debugging...
   62329             :        //   ROSE_ASSERT(false);
   62330             :         }
   62331             : 
   62332           5 :      return ;
   62333             :    }
   62334             : 
   62335             : //############################################################################
   62336             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   62337             :  * within the memory pool and resets the freepointers, in order to achieve a 
   62338             :  * linked list, that has no jumps and starts at the beginning! This function 
   62339             :  * does not extend the memory pool, since we do not delete any memory blocks,
   62340             :  * but delete the valid objects.  
   62341             :  */
   62342             : void
   62343           0 : SgOmpCopyprivateClause::clearMemoryPool( )
   62344             :    {
   62345             :   // printf ("Inside of SgOmpCopyprivateClause::clearMemoryPool() \n");
   62346             : 
   62347           0 :      SgOmpCopyprivateClause* pointer = NULL, *tempPointer = NULL;
   62348           0 :      std::vector < unsigned char* > :: const_iterator block;
   62349           0 :      if ( SgOmpCopyprivateClause::pools.empty() == false )
   62350             :         {
   62351           0 :           block = SgOmpCopyprivateClause::pools.begin() ;
   62352           0 :           SgOmpCopyprivateClause::next_node = (SgOmpCopyprivateClause*) (*block);
   62353             : 
   62354           0 :           while ( block != SgOmpCopyprivateClause::pools.end() )
   62355             :              {
   62356           0 :                pointer = (SgOmpCopyprivateClause*) (*block);
   62357           0 :                if ( tempPointer != NULL )
   62358             :                   {
   62359           0 :                     tempPointer->set_freepointer(pointer);
   62360             :                   }
   62361           0 :                for (unsigned i = 0; i < SgOmpCopyprivateClause::pool_size - 1; ++i)
   62362             :                   {
   62363           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   62364             :                   }
   62365           0 :                 pointer[SgOmpCopyprivateClause::pool_size-1].set_freepointer(NULL);
   62366           0 :                 tempPointer = &(pointer[SgOmpCopyprivateClause::pool_size-1]);
   62367           0 :                 ++block;
   62368             :              }
   62369             :         }
   62370           0 :    }
   62371             : 
   62372           5 : void SgOmpCopyprivateClause::deleteMemoryPool() {
   62373           5 :   for (auto p: SgOmpCopyprivateClause::pools) {
   62374           0 :     ROSE_FREE(p);
   62375             :   }
   62376           5 :   SgOmpCopyprivateClause::next_node = nullptr;
   62377           5 :   SgOmpCopyprivateClause::pools.clear();
   62378           5 : }
   62379             : 
   62380             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   62381             : //                 reading multiple binary files to for a single AST.
   62382             : /////////// new version ////////////////////////////////
   62383             : //############################################################################
   62384             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   62385             : void
   62386           2 : SgOmpCopyprivateClause::extendMemoryPoolForFileIO( )
   62387             :   {
   62388           2 :     size_t blockIndex = SgOmpCopyprivateClause::pools.size();
   62389           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCopyprivateClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCopyprivateClause);
   62390             : 
   62391           2 :     while ( (blockIndex * SgOmpCopyprivateClause::pool_size) < newPoolSize)
   62392             :       {
   62393             : #if ROSE_ALLOC_TRACE
   62394             :         if (blockIndex > 0) {
   62395             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCopyprivateClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCopyprivateClause) = %" PRIuPTR " SgOmpCopyprivateClause::pool_size = %d \n",
   62396             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCopyprivateClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCopyprivateClause),SgOmpCopyprivateClause::pool_size);
   62397             :         }
   62398             : #endif
   62399             : 
   62400           0 :         SgOmpCopyprivateClause * pointer = (SgOmpCopyprivateClause*) ROSE_MALLOC ( SgOmpCopyprivateClause::pool_size * sizeof(SgOmpCopyprivateClause) );
   62401           0 :         assert( pointer != NULL );
   62402             : #if ROSE_ALLOC_MEMSET == 1
   62403             :         memset(pointer, 0x00, SgOmpCopyprivateClause::pool_size * sizeof(SgOmpCopyprivateClause));
   62404             : #elif ROSE_ALLOC_MEMSET == 2
   62405             :         memset(pointer, 0xCC, SgOmpCopyprivateClause::pool_size * sizeof(SgOmpCopyprivateClause));
   62406             : #endif
   62407           0 :         SgOmpCopyprivateClause::pools.push_back( (unsigned char*)(pointer) );
   62408           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpCopyprivateClause::pool_size * sizeof(SgOmpCopyprivateClause), V_SgOmpCopyprivateClause ) );
   62409             : 
   62410           0 :         if ( SgOmpCopyprivateClause::next_node != NULL ) {
   62411           0 :           if ( blockIndex > 0 ) {
   62412           0 :             SgOmpCopyprivateClause * blkptr = (SgOmpCopyprivateClause*)(SgOmpCopyprivateClause::pools[blockIndex-1]);
   62413           0 :             blkptr[ SgOmpCopyprivateClause::pool_size - 1 ].set_freepointer(pointer);
   62414             :           }
   62415             :         } else {
   62416           0 :           SgOmpCopyprivateClause::next_node = pointer;
   62417             :         }
   62418             : 
   62419           0 :         for (unsigned i = 0; i < SgOmpCopyprivateClause::pool_size-1; ++i)
   62420             :            {
   62421           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   62422             :            }
   62423           0 :         pointer[ SgOmpCopyprivateClause::pool_size -1 ].set_freepointer(NULL);
   62424             : 
   62425           0 :         blockIndex++;
   62426             :       }
   62427           2 :   }
   62428             : 
   62429             : //############################################################################
   62430             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   62431             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   62432             :  * not compressed. However, that stuff is not yet implemented! 
   62433             :  */
   62434             : unsigned long
   62435           0 : SgOmpCopyprivateClause::getNumberOfLastValidPointer()
   62436             :    {
   62437           0 :       SgOmpCopyprivateClause* testPointer = (SgOmpCopyprivateClause*)(SgOmpCopyprivateClause::pools.back());
   62438           0 :       unsigned long localIndex = SgOmpCopyprivateClause::pool_size - 1;
   62439           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   62440             :          {
   62441           0 :            localIndex--;
   62442             :          }
   62443           0 :       return (localIndex + SgOmpCopyprivateClause::pool_size * (SgOmpCopyprivateClause::pools.size()-1));
   62444             :    }
   62445             : 
   62446             : //############################################################################
   62447             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   62448             :  * memory pool and initializes the data member in class SgOmpCopyprivateClauseStroageClass
   62449             :  * from its counterpart of SgOmpCopyprivateClause. The return value is just for checking, 
   62450             :  * that the whole StorageClassArray is initialized!
   62451             :  */
   62452             : unsigned long
   62453           0 : SgOmpCopyprivateClause::initializeStorageClassArray( SgOmpCopyprivateClauseStorageClass *storageArray )
   62454             :    {
   62455           0 :      unsigned long storageCounter = 0;
   62456           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpCopyprivateClause::pools.begin();
   62457           0 :      SgOmpCopyprivateClause* pointer = NULL;
   62458           0 :      while ( block != SgOmpCopyprivateClause::pools.end() ) {
   62459           0 :           pointer = (SgOmpCopyprivateClause*) (*block);
   62460           0 :           for ( unsigned i = 0; i < SgOmpCopyprivateClause::pool_size; ++i ) {
   62461           0 :                if ( pointer->get_freepointer() != NULL ) {
   62462           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   62463           0 :                  storageArray++;
   62464           0 :                  storageCounter++;
   62465             :                }
   62466           0 :                pointer++;
   62467             :              }
   62468           0 :            block++;
   62469             :         }
   62470           0 :      return storageCounter;
   62471             :    }
   62472             : 
   62473             : /* #line 62474 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   62474             : 
   62475             : 
   62476             : 
   62477             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   62478             : 
   62479             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   62480             : 
   62481             : //############################################################################
   62482             : /* JH (02/02/2006) Constructor of the IR node SgOmpPrivateClause that takes its 
   62483             :  * corresponding StorageClass as parameter
   62484             :  */
   62485           0 : SgOmpPrivateClause :: SgOmpPrivateClause ( const SgOmpPrivateClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   62486             :    {
   62487             : 
   62488             : 
   62489             : /* #line 62490 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   62490             : 
   62491           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   62492             : 
   62493             : 
   62494             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   62495             : 
   62496             : 
   62497           0 :    }
   62498             : 
   62499             : //############################################################################
   62500             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   62501             :  * within the working AST. 
   62502             :  */
   62503           0 : SgOmpPrivateClause * SgOmpPrivateClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   62504           0 :      SgOmpPrivateClause* returnPointer = NULL;
   62505           0 :      if ( globalIndex != 0 )
   62506             :         {
   62507             : 
   62508             : #if FILE_IO_EXTRA_CHECK
   62509           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpPrivateClause ) ) <= globalIndex ) ;
   62510           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpPrivateClause + 1 ) ) );
   62511             : #endif
   62512           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpPrivateClause )  
   62513           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpPrivateClause );
   62514           0 :           unsigned long positionInPool = localIndex % SgOmpPrivateClause::pool_size;
   62515           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpPrivateClause::pool_size;
   62516             : 
   62517             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   62518             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   62519             : 
   62520           0 :           returnPointer = &( ( (SgOmpPrivateClause*)(SgOmpPrivateClause::pools[memoryBlock]) ) [positionInPool]) ;
   62521             : 
   62522           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   62523             :         }
   62524           0 :      return returnPointer ;
   62525             :    }
   62526             : 
   62527             : //############################################################################
   62528             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   62529             :   for the AST with the index astIndex
   62530             : */
   62531           0 : SgOmpPrivateClause * SgOmpPrivateClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   62532           0 :      SgOmpPrivateClause* returnPointer = NULL;
   62533           0 :      if ( globalIndex != 0 )
   62534             :         {
   62535             : 
   62536             : #if FILE_IO_EXTRA_CHECK
   62537           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpPrivateClause ) ) <= globalIndex ) ;
   62538           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpPrivateClause + 1 ) ) );
   62539             : #endif
   62540           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpPrivateClause )
   62541           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpPrivateClause );
   62542           0 :           unsigned long positionInPool = localIndex % SgOmpPrivateClause::pool_size ;
   62543           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpPrivateClause::pool_size ;
   62544             : 
   62545             : #if FILE_IO_EXTRA_CHECK
   62546             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   62547             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   62548             : #endif
   62549             : 
   62550           0 :           returnPointer = &( ( (SgOmpPrivateClause*)(SgOmpPrivateClause::pools[memoryBlock]) ) [positionInPool]) ;
   62551             : 
   62552             : #if FILE_IO_EXTRA_CHECK
   62553           0 :           assert ( returnPointer != NULL ) ;
   62554             : #endif
   62555             :         }
   62556           0 :      return returnPointer ;
   62557             :    }
   62558             : 
   62559             : //############################################################################
   62560             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   62561             :  * pool size! We set for every valid object in the memory pool the freepointer
   62562             :  * to the global index and increase the global index afterwards. For all the 
   62563             :  * invalid objects (means address ranges within the memory pool that were not
   62564             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   62565             :  * distinguish valid from invalid objects! 
   62566             :  */
   62567             : unsigned long
   62568           5 : SgOmpPrivateClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   62569             :    {
   62570           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   62571           5 :      SgOmpPrivateClause* pointer = NULL;
   62572           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   62573           5 :      std::vector < unsigned char* > :: const_iterator block;
   62574           5 :      for ( block = SgOmpPrivateClause::pools.begin(); block != SgOmpPrivateClause::pools.end() ; ++block )
   62575             :         {
   62576           0 :           pointer = (SgOmpPrivateClause*)(*block);
   62577           0 :           for (unsigned i = 0; i < SgOmpPrivateClause::pool_size; ++i )
   62578             :              {
   62579             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   62580             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   62581             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   62582             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   62583             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   62584             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   62585             :             // properly; so this will have to be checked next.
   62586             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   62587             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   62588           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   62589             :                   {
   62590           0 :                     pointer[i].set_freepointer((SgOmpPrivateClause*)(globalIndex));
   62591           0 :                     globalIndex++;
   62592             :                   }
   62593             :                else
   62594             :                   {
   62595           0 :                     pointer[i].set_freepointer(NULL);
   62596             :                   }
   62597             :               }
   62598             :         }
   62599           5 :      return globalIndex;
   62600             :    }
   62601             : 
   62602             : //############################################################################
   62603             : // JH (01/14/2006)
   62604             : void
   62605           5 : SgOmpPrivateClause::resetValidFreepointers( )
   62606             :    {
   62607           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   62608           5 :      SgOmpPrivateClause* pointer = NULL;
   62609           5 :      std::vector < unsigned char* > :: const_iterator block;
   62610           5 :      SgOmpPrivateClause* pointerOfLinkedList = NULL;
   62611           5 :      for ( block = SgOmpPrivateClause::pools.begin(); block != SgOmpPrivateClause::pools.end() ; ++block )
   62612             :         {
   62613           0 :           pointer = (SgOmpPrivateClause*)(*block);
   62614           0 :           for (unsigned i = 0; i < SgOmpPrivateClause::pool_size; ++i )
   62615             :              {
   62616             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   62617             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   62618             :             // memory blocks!.
   62619           0 :                if ( pointer[i].get_freepointer() != NULL )
   62620             :                   {
   62621           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   62622             :                   }
   62623             :                else
   62624             :                   {
   62625           0 :                     if ( pointerOfLinkedList == NULL )
   62626             :                        {
   62627           0 :                          SgOmpPrivateClause::next_node = &(pointer[i]);
   62628             :                        }
   62629             :                     else
   62630             :                        {
   62631             :                       // printf ("In SgOmpPrivateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   62632           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   62633             :                        }
   62634             :                     pointerOfLinkedList = &(pointer[i]);
   62635             :                   }
   62636             :               }
   62637             :         }
   62638             : 
   62639           5 :      if ( pointerOfLinkedList != NULL )
   62640             :         {
   62641             :        // printf ("In SgOmpPrivateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   62642           0 :           pointerOfLinkedList->set_freepointer(NULL);
   62643             :        // DQ (6/6/2010): Temporary debugging...
   62644             :        //   ROSE_ASSERT(false);
   62645             :         }
   62646             : 
   62647           5 :      return ;
   62648             :    }
   62649             : 
   62650             : //############################################################################
   62651             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   62652             :  * within the memory pool and resets the freepointers, in order to achieve a 
   62653             :  * linked list, that has no jumps and starts at the beginning! This function 
   62654             :  * does not extend the memory pool, since we do not delete any memory blocks,
   62655             :  * but delete the valid objects.  
   62656             :  */
   62657             : void
   62658           0 : SgOmpPrivateClause::clearMemoryPool( )
   62659             :    {
   62660             :   // printf ("Inside of SgOmpPrivateClause::clearMemoryPool() \n");
   62661             : 
   62662           0 :      SgOmpPrivateClause* pointer = NULL, *tempPointer = NULL;
   62663           0 :      std::vector < unsigned char* > :: const_iterator block;
   62664           0 :      if ( SgOmpPrivateClause::pools.empty() == false )
   62665             :         {
   62666           0 :           block = SgOmpPrivateClause::pools.begin() ;
   62667           0 :           SgOmpPrivateClause::next_node = (SgOmpPrivateClause*) (*block);
   62668             : 
   62669           0 :           while ( block != SgOmpPrivateClause::pools.end() )
   62670             :              {
   62671           0 :                pointer = (SgOmpPrivateClause*) (*block);
   62672           0 :                if ( tempPointer != NULL )
   62673             :                   {
   62674           0 :                     tempPointer->set_freepointer(pointer);
   62675             :                   }
   62676           0 :                for (unsigned i = 0; i < SgOmpPrivateClause::pool_size - 1; ++i)
   62677             :                   {
   62678           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   62679             :                   }
   62680           0 :                 pointer[SgOmpPrivateClause::pool_size-1].set_freepointer(NULL);
   62681           0 :                 tempPointer = &(pointer[SgOmpPrivateClause::pool_size-1]);
   62682           0 :                 ++block;
   62683             :              }
   62684             :         }
   62685           0 :    }
   62686             : 
   62687           5 : void SgOmpPrivateClause::deleteMemoryPool() {
   62688           5 :   for (auto p: SgOmpPrivateClause::pools) {
   62689           0 :     ROSE_FREE(p);
   62690             :   }
   62691           5 :   SgOmpPrivateClause::next_node = nullptr;
   62692           5 :   SgOmpPrivateClause::pools.clear();
   62693           5 : }
   62694             : 
   62695             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   62696             : //                 reading multiple binary files to for a single AST.
   62697             : /////////// new version ////////////////////////////////
   62698             : //############################################################################
   62699             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   62700             : void
   62701           2 : SgOmpPrivateClause::extendMemoryPoolForFileIO( )
   62702             :   {
   62703           2 :     size_t blockIndex = SgOmpPrivateClause::pools.size();
   62704           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPrivateClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPrivateClause);
   62705             : 
   62706           2 :     while ( (blockIndex * SgOmpPrivateClause::pool_size) < newPoolSize)
   62707             :       {
   62708             : #if ROSE_ALLOC_TRACE
   62709             :         if (blockIndex > 0) {
   62710             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPrivateClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPrivateClause) = %" PRIuPTR " SgOmpPrivateClause::pool_size = %d \n",
   62711             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpPrivateClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpPrivateClause),SgOmpPrivateClause::pool_size);
   62712             :         }
   62713             : #endif
   62714             : 
   62715           0 :         SgOmpPrivateClause * pointer = (SgOmpPrivateClause*) ROSE_MALLOC ( SgOmpPrivateClause::pool_size * sizeof(SgOmpPrivateClause) );
   62716           0 :         assert( pointer != NULL );
   62717             : #if ROSE_ALLOC_MEMSET == 1
   62718             :         memset(pointer, 0x00, SgOmpPrivateClause::pool_size * sizeof(SgOmpPrivateClause));
   62719             : #elif ROSE_ALLOC_MEMSET == 2
   62720             :         memset(pointer, 0xCC, SgOmpPrivateClause::pool_size * sizeof(SgOmpPrivateClause));
   62721             : #endif
   62722           0 :         SgOmpPrivateClause::pools.push_back( (unsigned char*)(pointer) );
   62723           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpPrivateClause::pool_size * sizeof(SgOmpPrivateClause), V_SgOmpPrivateClause ) );
   62724             : 
   62725           0 :         if ( SgOmpPrivateClause::next_node != NULL ) {
   62726           0 :           if ( blockIndex > 0 ) {
   62727           0 :             SgOmpPrivateClause * blkptr = (SgOmpPrivateClause*)(SgOmpPrivateClause::pools[blockIndex-1]);
   62728           0 :             blkptr[ SgOmpPrivateClause::pool_size - 1 ].set_freepointer(pointer);
   62729             :           }
   62730             :         } else {
   62731           0 :           SgOmpPrivateClause::next_node = pointer;
   62732             :         }
   62733             : 
   62734           0 :         for (unsigned i = 0; i < SgOmpPrivateClause::pool_size-1; ++i)
   62735             :            {
   62736           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   62737             :            }
   62738           0 :         pointer[ SgOmpPrivateClause::pool_size -1 ].set_freepointer(NULL);
   62739             : 
   62740           0 :         blockIndex++;
   62741             :       }
   62742           2 :   }
   62743             : 
   62744             : //############################################################################
   62745             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   62746             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   62747             :  * not compressed. However, that stuff is not yet implemented! 
   62748             :  */
   62749             : unsigned long
   62750           0 : SgOmpPrivateClause::getNumberOfLastValidPointer()
   62751             :    {
   62752           0 :       SgOmpPrivateClause* testPointer = (SgOmpPrivateClause*)(SgOmpPrivateClause::pools.back());
   62753           0 :       unsigned long localIndex = SgOmpPrivateClause::pool_size - 1;
   62754           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   62755             :          {
   62756           0 :            localIndex--;
   62757             :          }
   62758           0 :       return (localIndex + SgOmpPrivateClause::pool_size * (SgOmpPrivateClause::pools.size()-1));
   62759             :    }
   62760             : 
   62761             : //############################################################################
   62762             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   62763             :  * memory pool and initializes the data member in class SgOmpPrivateClauseStroageClass
   62764             :  * from its counterpart of SgOmpPrivateClause. The return value is just for checking, 
   62765             :  * that the whole StorageClassArray is initialized!
   62766             :  */
   62767             : unsigned long
   62768           0 : SgOmpPrivateClause::initializeStorageClassArray( SgOmpPrivateClauseStorageClass *storageArray )
   62769             :    {
   62770           0 :      unsigned long storageCounter = 0;
   62771           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpPrivateClause::pools.begin();
   62772           0 :      SgOmpPrivateClause* pointer = NULL;
   62773           0 :      while ( block != SgOmpPrivateClause::pools.end() ) {
   62774           0 :           pointer = (SgOmpPrivateClause*) (*block);
   62775           0 :           for ( unsigned i = 0; i < SgOmpPrivateClause::pool_size; ++i ) {
   62776           0 :                if ( pointer->get_freepointer() != NULL ) {
   62777           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   62778           0 :                  storageArray++;
   62779           0 :                  storageCounter++;
   62780             :                }
   62781           0 :                pointer++;
   62782             :              }
   62783           0 :            block++;
   62784             :         }
   62785           0 :      return storageCounter;
   62786             :    }
   62787             : 
   62788             : /* #line 62789 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   62789             : 
   62790             : 
   62791             : 
   62792             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   62793             : 
   62794             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   62795             : 
   62796             : //############################################################################
   62797             : /* JH (02/02/2006) Constructor of the IR node SgOmpFirstprivateClause that takes its 
   62798             :  * corresponding StorageClass as parameter
   62799             :  */
   62800           0 : SgOmpFirstprivateClause :: SgOmpFirstprivateClause ( const SgOmpFirstprivateClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   62801             :    {
   62802             : 
   62803             : 
   62804             : /* #line 62805 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   62805             : 
   62806           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   62807             : 
   62808             : 
   62809             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   62810             : 
   62811             : 
   62812           0 :    }
   62813             : 
   62814             : //############################################################################
   62815             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   62816             :  * within the working AST. 
   62817             :  */
   62818           0 : SgOmpFirstprivateClause * SgOmpFirstprivateClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   62819           0 :      SgOmpFirstprivateClause* returnPointer = NULL;
   62820           0 :      if ( globalIndex != 0 )
   62821             :         {
   62822             : 
   62823             : #if FILE_IO_EXTRA_CHECK
   62824           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpFirstprivateClause ) ) <= globalIndex ) ;
   62825           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFirstprivateClause + 1 ) ) );
   62826             : #endif
   62827           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFirstprivateClause )  
   62828           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpFirstprivateClause );
   62829           0 :           unsigned long positionInPool = localIndex % SgOmpFirstprivateClause::pool_size;
   62830           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFirstprivateClause::pool_size;
   62831             : 
   62832             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   62833             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   62834             : 
   62835           0 :           returnPointer = &( ( (SgOmpFirstprivateClause*)(SgOmpFirstprivateClause::pools[memoryBlock]) ) [positionInPool]) ;
   62836             : 
   62837           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   62838             :         }
   62839           0 :      return returnPointer ;
   62840             :    }
   62841             : 
   62842             : //############################################################################
   62843             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   62844             :   for the AST with the index astIndex
   62845             : */
   62846           0 : SgOmpFirstprivateClause * SgOmpFirstprivateClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   62847           0 :      SgOmpFirstprivateClause* returnPointer = NULL;
   62848           0 :      if ( globalIndex != 0 )
   62849             :         {
   62850             : 
   62851             : #if FILE_IO_EXTRA_CHECK
   62852           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpFirstprivateClause ) ) <= globalIndex ) ;
   62853           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFirstprivateClause + 1 ) ) );
   62854             : #endif
   62855           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFirstprivateClause )
   62856           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpFirstprivateClause );
   62857           0 :           unsigned long positionInPool = localIndex % SgOmpFirstprivateClause::pool_size ;
   62858           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFirstprivateClause::pool_size ;
   62859             : 
   62860             : #if FILE_IO_EXTRA_CHECK
   62861             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   62862             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   62863             : #endif
   62864             : 
   62865           0 :           returnPointer = &( ( (SgOmpFirstprivateClause*)(SgOmpFirstprivateClause::pools[memoryBlock]) ) [positionInPool]) ;
   62866             : 
   62867             : #if FILE_IO_EXTRA_CHECK
   62868           0 :           assert ( returnPointer != NULL ) ;
   62869             : #endif
   62870             :         }
   62871           0 :      return returnPointer ;
   62872             :    }
   62873             : 
   62874             : //############################################################################
   62875             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   62876             :  * pool size! We set for every valid object in the memory pool the freepointer
   62877             :  * to the global index and increase the global index afterwards. For all the 
   62878             :  * invalid objects (means address ranges within the memory pool that were not
   62879             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   62880             :  * distinguish valid from invalid objects! 
   62881             :  */
   62882             : unsigned long
   62883           5 : SgOmpFirstprivateClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   62884             :    {
   62885           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   62886           5 :      SgOmpFirstprivateClause* pointer = NULL;
   62887           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   62888           5 :      std::vector < unsigned char* > :: const_iterator block;
   62889           5 :      for ( block = SgOmpFirstprivateClause::pools.begin(); block != SgOmpFirstprivateClause::pools.end() ; ++block )
   62890             :         {
   62891           0 :           pointer = (SgOmpFirstprivateClause*)(*block);
   62892           0 :           for (unsigned i = 0; i < SgOmpFirstprivateClause::pool_size; ++i )
   62893             :              {
   62894             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   62895             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   62896             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   62897             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   62898             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   62899             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   62900             :             // properly; so this will have to be checked next.
   62901             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   62902             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   62903           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   62904             :                   {
   62905           0 :                     pointer[i].set_freepointer((SgOmpFirstprivateClause*)(globalIndex));
   62906           0 :                     globalIndex++;
   62907             :                   }
   62908             :                else
   62909             :                   {
   62910           0 :                     pointer[i].set_freepointer(NULL);
   62911             :                   }
   62912             :               }
   62913             :         }
   62914           5 :      return globalIndex;
   62915             :    }
   62916             : 
   62917             : //############################################################################
   62918             : // JH (01/14/2006)
   62919             : void
   62920           5 : SgOmpFirstprivateClause::resetValidFreepointers( )
   62921             :    {
   62922           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   62923           5 :      SgOmpFirstprivateClause* pointer = NULL;
   62924           5 :      std::vector < unsigned char* > :: const_iterator block;
   62925           5 :      SgOmpFirstprivateClause* pointerOfLinkedList = NULL;
   62926           5 :      for ( block = SgOmpFirstprivateClause::pools.begin(); block != SgOmpFirstprivateClause::pools.end() ; ++block )
   62927             :         {
   62928           0 :           pointer = (SgOmpFirstprivateClause*)(*block);
   62929           0 :           for (unsigned i = 0; i < SgOmpFirstprivateClause::pool_size; ++i )
   62930             :              {
   62931             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   62932             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   62933             :             // memory blocks!.
   62934           0 :                if ( pointer[i].get_freepointer() != NULL )
   62935             :                   {
   62936           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   62937             :                   }
   62938             :                else
   62939             :                   {
   62940           0 :                     if ( pointerOfLinkedList == NULL )
   62941             :                        {
   62942           0 :                          SgOmpFirstprivateClause::next_node = &(pointer[i]);
   62943             :                        }
   62944             :                     else
   62945             :                        {
   62946             :                       // printf ("In SgOmpFirstprivateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   62947           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   62948             :                        }
   62949             :                     pointerOfLinkedList = &(pointer[i]);
   62950             :                   }
   62951             :               }
   62952             :         }
   62953             : 
   62954           5 :      if ( pointerOfLinkedList != NULL )
   62955             :         {
   62956             :        // printf ("In SgOmpFirstprivateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   62957           0 :           pointerOfLinkedList->set_freepointer(NULL);
   62958             :        // DQ (6/6/2010): Temporary debugging...
   62959             :        //   ROSE_ASSERT(false);
   62960             :         }
   62961             : 
   62962           5 :      return ;
   62963             :    }
   62964             : 
   62965             : //############################################################################
   62966             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   62967             :  * within the memory pool and resets the freepointers, in order to achieve a 
   62968             :  * linked list, that has no jumps and starts at the beginning! This function 
   62969             :  * does not extend the memory pool, since we do not delete any memory blocks,
   62970             :  * but delete the valid objects.  
   62971             :  */
   62972             : void
   62973           0 : SgOmpFirstprivateClause::clearMemoryPool( )
   62974             :    {
   62975             :   // printf ("Inside of SgOmpFirstprivateClause::clearMemoryPool() \n");
   62976             : 
   62977           0 :      SgOmpFirstprivateClause* pointer = NULL, *tempPointer = NULL;
   62978           0 :      std::vector < unsigned char* > :: const_iterator block;
   62979           0 :      if ( SgOmpFirstprivateClause::pools.empty() == false )
   62980             :         {
   62981           0 :           block = SgOmpFirstprivateClause::pools.begin() ;
   62982           0 :           SgOmpFirstprivateClause::next_node = (SgOmpFirstprivateClause*) (*block);
   62983             : 
   62984           0 :           while ( block != SgOmpFirstprivateClause::pools.end() )
   62985             :              {
   62986           0 :                pointer = (SgOmpFirstprivateClause*) (*block);
   62987           0 :                if ( tempPointer != NULL )
   62988             :                   {
   62989           0 :                     tempPointer->set_freepointer(pointer);
   62990             :                   }
   62991           0 :                for (unsigned i = 0; i < SgOmpFirstprivateClause::pool_size - 1; ++i)
   62992             :                   {
   62993           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   62994             :                   }
   62995           0 :                 pointer[SgOmpFirstprivateClause::pool_size-1].set_freepointer(NULL);
   62996           0 :                 tempPointer = &(pointer[SgOmpFirstprivateClause::pool_size-1]);
   62997           0 :                 ++block;
   62998             :              }
   62999             :         }
   63000           0 :    }
   63001             : 
   63002           5 : void SgOmpFirstprivateClause::deleteMemoryPool() {
   63003           5 :   for (auto p: SgOmpFirstprivateClause::pools) {
   63004           0 :     ROSE_FREE(p);
   63005             :   }
   63006           5 :   SgOmpFirstprivateClause::next_node = nullptr;
   63007           5 :   SgOmpFirstprivateClause::pools.clear();
   63008           5 : }
   63009             : 
   63010             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   63011             : //                 reading multiple binary files to for a single AST.
   63012             : /////////// new version ////////////////////////////////
   63013             : //############################################################################
   63014             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   63015             : void
   63016           2 : SgOmpFirstprivateClause::extendMemoryPoolForFileIO( )
   63017             :   {
   63018           2 :     size_t blockIndex = SgOmpFirstprivateClause::pools.size();
   63019           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFirstprivateClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFirstprivateClause);
   63020             : 
   63021           2 :     while ( (blockIndex * SgOmpFirstprivateClause::pool_size) < newPoolSize)
   63022             :       {
   63023             : #if ROSE_ALLOC_TRACE
   63024             :         if (blockIndex > 0) {
   63025             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFirstprivateClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFirstprivateClause) = %" PRIuPTR " SgOmpFirstprivateClause::pool_size = %d \n",
   63026             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFirstprivateClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFirstprivateClause),SgOmpFirstprivateClause::pool_size);
   63027             :         }
   63028             : #endif
   63029             : 
   63030           0 :         SgOmpFirstprivateClause * pointer = (SgOmpFirstprivateClause*) ROSE_MALLOC ( SgOmpFirstprivateClause::pool_size * sizeof(SgOmpFirstprivateClause) );
   63031           0 :         assert( pointer != NULL );
   63032             : #if ROSE_ALLOC_MEMSET == 1
   63033             :         memset(pointer, 0x00, SgOmpFirstprivateClause::pool_size * sizeof(SgOmpFirstprivateClause));
   63034             : #elif ROSE_ALLOC_MEMSET == 2
   63035             :         memset(pointer, 0xCC, SgOmpFirstprivateClause::pool_size * sizeof(SgOmpFirstprivateClause));
   63036             : #endif
   63037           0 :         SgOmpFirstprivateClause::pools.push_back( (unsigned char*)(pointer) );
   63038           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpFirstprivateClause::pool_size * sizeof(SgOmpFirstprivateClause), V_SgOmpFirstprivateClause ) );
   63039             : 
   63040           0 :         if ( SgOmpFirstprivateClause::next_node != NULL ) {
   63041           0 :           if ( blockIndex > 0 ) {
   63042           0 :             SgOmpFirstprivateClause * blkptr = (SgOmpFirstprivateClause*)(SgOmpFirstprivateClause::pools[blockIndex-1]);
   63043           0 :             blkptr[ SgOmpFirstprivateClause::pool_size - 1 ].set_freepointer(pointer);
   63044             :           }
   63045             :         } else {
   63046           0 :           SgOmpFirstprivateClause::next_node = pointer;
   63047             :         }
   63048             : 
   63049           0 :         for (unsigned i = 0; i < SgOmpFirstprivateClause::pool_size-1; ++i)
   63050             :            {
   63051           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   63052             :            }
   63053           0 :         pointer[ SgOmpFirstprivateClause::pool_size -1 ].set_freepointer(NULL);
   63054             : 
   63055           0 :         blockIndex++;
   63056             :       }
   63057           2 :   }
   63058             : 
   63059             : //############################################################################
   63060             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   63061             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   63062             :  * not compressed. However, that stuff is not yet implemented! 
   63063             :  */
   63064             : unsigned long
   63065           0 : SgOmpFirstprivateClause::getNumberOfLastValidPointer()
   63066             :    {
   63067           0 :       SgOmpFirstprivateClause* testPointer = (SgOmpFirstprivateClause*)(SgOmpFirstprivateClause::pools.back());
   63068           0 :       unsigned long localIndex = SgOmpFirstprivateClause::pool_size - 1;
   63069           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   63070             :          {
   63071           0 :            localIndex--;
   63072             :          }
   63073           0 :       return (localIndex + SgOmpFirstprivateClause::pool_size * (SgOmpFirstprivateClause::pools.size()-1));
   63074             :    }
   63075             : 
   63076             : //############################################################################
   63077             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   63078             :  * memory pool and initializes the data member in class SgOmpFirstprivateClauseStroageClass
   63079             :  * from its counterpart of SgOmpFirstprivateClause. The return value is just for checking, 
   63080             :  * that the whole StorageClassArray is initialized!
   63081             :  */
   63082             : unsigned long
   63083           0 : SgOmpFirstprivateClause::initializeStorageClassArray( SgOmpFirstprivateClauseStorageClass *storageArray )
   63084             :    {
   63085           0 :      unsigned long storageCounter = 0;
   63086           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpFirstprivateClause::pools.begin();
   63087           0 :      SgOmpFirstprivateClause* pointer = NULL;
   63088           0 :      while ( block != SgOmpFirstprivateClause::pools.end() ) {
   63089           0 :           pointer = (SgOmpFirstprivateClause*) (*block);
   63090           0 :           for ( unsigned i = 0; i < SgOmpFirstprivateClause::pool_size; ++i ) {
   63091           0 :                if ( pointer->get_freepointer() != NULL ) {
   63092           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   63093           0 :                  storageArray++;
   63094           0 :                  storageCounter++;
   63095             :                }
   63096           0 :                pointer++;
   63097             :              }
   63098           0 :            block++;
   63099             :         }
   63100           0 :      return storageCounter;
   63101             :    }
   63102             : 
   63103             : /* #line 63104 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   63104             : 
   63105             : 
   63106             : 
   63107             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   63108             : 
   63109             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   63110             : 
   63111             : //############################################################################
   63112             : /* JH (02/02/2006) Constructor of the IR node SgOmpNontemporalClause that takes its 
   63113             :  * corresponding StorageClass as parameter
   63114             :  */
   63115           0 : SgOmpNontemporalClause :: SgOmpNontemporalClause ( const SgOmpNontemporalClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   63116             :    {
   63117             : 
   63118             : 
   63119             : /* #line 63120 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   63120             : 
   63121           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   63122             : 
   63123             : 
   63124             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   63125             : 
   63126             : 
   63127           0 :    }
   63128             : 
   63129             : //############################################################################
   63130             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   63131             :  * within the working AST. 
   63132             :  */
   63133           0 : SgOmpNontemporalClause * SgOmpNontemporalClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   63134           0 :      SgOmpNontemporalClause* returnPointer = NULL;
   63135           0 :      if ( globalIndex != 0 )
   63136             :         {
   63137             : 
   63138             : #if FILE_IO_EXTRA_CHECK
   63139           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpNontemporalClause ) ) <= globalIndex ) ;
   63140           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNontemporalClause + 1 ) ) );
   63141             : #endif
   63142           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpNontemporalClause )  
   63143           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpNontemporalClause );
   63144           0 :           unsigned long positionInPool = localIndex % SgOmpNontemporalClause::pool_size;
   63145           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNontemporalClause::pool_size;
   63146             : 
   63147             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   63148             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   63149             : 
   63150           0 :           returnPointer = &( ( (SgOmpNontemporalClause*)(SgOmpNontemporalClause::pools[memoryBlock]) ) [positionInPool]) ;
   63151             : 
   63152           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   63153             :         }
   63154           0 :      return returnPointer ;
   63155             :    }
   63156             : 
   63157             : //############################################################################
   63158             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   63159             :   for the AST with the index astIndex
   63160             : */
   63161           0 : SgOmpNontemporalClause * SgOmpNontemporalClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   63162           0 :      SgOmpNontemporalClause* returnPointer = NULL;
   63163           0 :      if ( globalIndex != 0 )
   63164             :         {
   63165             : 
   63166             : #if FILE_IO_EXTRA_CHECK
   63167           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpNontemporalClause ) ) <= globalIndex ) ;
   63168           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNontemporalClause + 1 ) ) );
   63169             : #endif
   63170           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpNontemporalClause )
   63171           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpNontemporalClause );
   63172           0 :           unsigned long positionInPool = localIndex % SgOmpNontemporalClause::pool_size ;
   63173           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpNontemporalClause::pool_size ;
   63174             : 
   63175             : #if FILE_IO_EXTRA_CHECK
   63176             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   63177             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   63178             : #endif
   63179             : 
   63180           0 :           returnPointer = &( ( (SgOmpNontemporalClause*)(SgOmpNontemporalClause::pools[memoryBlock]) ) [positionInPool]) ;
   63181             : 
   63182             : #if FILE_IO_EXTRA_CHECK
   63183           0 :           assert ( returnPointer != NULL ) ;
   63184             : #endif
   63185             :         }
   63186           0 :      return returnPointer ;
   63187             :    }
   63188             : 
   63189             : //############################################################################
   63190             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   63191             :  * pool size! We set for every valid object in the memory pool the freepointer
   63192             :  * to the global index and increase the global index afterwards. For all the 
   63193             :  * invalid objects (means address ranges within the memory pool that were not
   63194             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   63195             :  * distinguish valid from invalid objects! 
   63196             :  */
   63197             : unsigned long
   63198           5 : SgOmpNontemporalClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   63199             :    {
   63200           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   63201           5 :      SgOmpNontemporalClause* pointer = NULL;
   63202           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   63203           5 :      std::vector < unsigned char* > :: const_iterator block;
   63204           5 :      for ( block = SgOmpNontemporalClause::pools.begin(); block != SgOmpNontemporalClause::pools.end() ; ++block )
   63205             :         {
   63206           0 :           pointer = (SgOmpNontemporalClause*)(*block);
   63207           0 :           for (unsigned i = 0; i < SgOmpNontemporalClause::pool_size; ++i )
   63208             :              {
   63209             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   63210             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   63211             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   63212             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   63213             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   63214             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   63215             :             // properly; so this will have to be checked next.
   63216             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   63217             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   63218           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   63219             :                   {
   63220           0 :                     pointer[i].set_freepointer((SgOmpNontemporalClause*)(globalIndex));
   63221           0 :                     globalIndex++;
   63222             :                   }
   63223             :                else
   63224             :                   {
   63225           0 :                     pointer[i].set_freepointer(NULL);
   63226             :                   }
   63227             :               }
   63228             :         }
   63229           5 :      return globalIndex;
   63230             :    }
   63231             : 
   63232             : //############################################################################
   63233             : // JH (01/14/2006)
   63234             : void
   63235           5 : SgOmpNontemporalClause::resetValidFreepointers( )
   63236             :    {
   63237           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   63238           5 :      SgOmpNontemporalClause* pointer = NULL;
   63239           5 :      std::vector < unsigned char* > :: const_iterator block;
   63240           5 :      SgOmpNontemporalClause* pointerOfLinkedList = NULL;
   63241           5 :      for ( block = SgOmpNontemporalClause::pools.begin(); block != SgOmpNontemporalClause::pools.end() ; ++block )
   63242             :         {
   63243           0 :           pointer = (SgOmpNontemporalClause*)(*block);
   63244           0 :           for (unsigned i = 0; i < SgOmpNontemporalClause::pool_size; ++i )
   63245             :              {
   63246             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   63247             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   63248             :             // memory blocks!.
   63249           0 :                if ( pointer[i].get_freepointer() != NULL )
   63250             :                   {
   63251           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   63252             :                   }
   63253             :                else
   63254             :                   {
   63255           0 :                     if ( pointerOfLinkedList == NULL )
   63256             :                        {
   63257           0 :                          SgOmpNontemporalClause::next_node = &(pointer[i]);
   63258             :                        }
   63259             :                     else
   63260             :                        {
   63261             :                       // printf ("In SgOmpNontemporalClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   63262           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   63263             :                        }
   63264             :                     pointerOfLinkedList = &(pointer[i]);
   63265             :                   }
   63266             :               }
   63267             :         }
   63268             : 
   63269           5 :      if ( pointerOfLinkedList != NULL )
   63270             :         {
   63271             :        // printf ("In SgOmpNontemporalClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   63272           0 :           pointerOfLinkedList->set_freepointer(NULL);
   63273             :        // DQ (6/6/2010): Temporary debugging...
   63274             :        //   ROSE_ASSERT(false);
   63275             :         }
   63276             : 
   63277           5 :      return ;
   63278             :    }
   63279             : 
   63280             : //############################################################################
   63281             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   63282             :  * within the memory pool and resets the freepointers, in order to achieve a 
   63283             :  * linked list, that has no jumps and starts at the beginning! This function 
   63284             :  * does not extend the memory pool, since we do not delete any memory blocks,
   63285             :  * but delete the valid objects.  
   63286             :  */
   63287             : void
   63288           0 : SgOmpNontemporalClause::clearMemoryPool( )
   63289             :    {
   63290             :   // printf ("Inside of SgOmpNontemporalClause::clearMemoryPool() \n");
   63291             : 
   63292           0 :      SgOmpNontemporalClause* pointer = NULL, *tempPointer = NULL;
   63293           0 :      std::vector < unsigned char* > :: const_iterator block;
   63294           0 :      if ( SgOmpNontemporalClause::pools.empty() == false )
   63295             :         {
   63296           0 :           block = SgOmpNontemporalClause::pools.begin() ;
   63297           0 :           SgOmpNontemporalClause::next_node = (SgOmpNontemporalClause*) (*block);
   63298             : 
   63299           0 :           while ( block != SgOmpNontemporalClause::pools.end() )
   63300             :              {
   63301           0 :                pointer = (SgOmpNontemporalClause*) (*block);
   63302           0 :                if ( tempPointer != NULL )
   63303             :                   {
   63304           0 :                     tempPointer->set_freepointer(pointer);
   63305             :                   }
   63306           0 :                for (unsigned i = 0; i < SgOmpNontemporalClause::pool_size - 1; ++i)
   63307             :                   {
   63308           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   63309             :                   }
   63310           0 :                 pointer[SgOmpNontemporalClause::pool_size-1].set_freepointer(NULL);
   63311           0 :                 tempPointer = &(pointer[SgOmpNontemporalClause::pool_size-1]);
   63312           0 :                 ++block;
   63313             :              }
   63314             :         }
   63315           0 :    }
   63316             : 
   63317           5 : void SgOmpNontemporalClause::deleteMemoryPool() {
   63318           5 :   for (auto p: SgOmpNontemporalClause::pools) {
   63319           0 :     ROSE_FREE(p);
   63320             :   }
   63321           5 :   SgOmpNontemporalClause::next_node = nullptr;
   63322           5 :   SgOmpNontemporalClause::pools.clear();
   63323           5 : }
   63324             : 
   63325             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   63326             : //                 reading multiple binary files to for a single AST.
   63327             : /////////// new version ////////////////////////////////
   63328             : //############################################################################
   63329             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   63330             : void
   63331           2 : SgOmpNontemporalClause::extendMemoryPoolForFileIO( )
   63332             :   {
   63333           2 :     size_t blockIndex = SgOmpNontemporalClause::pools.size();
   63334           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNontemporalClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNontemporalClause);
   63335             : 
   63336           2 :     while ( (blockIndex * SgOmpNontemporalClause::pool_size) < newPoolSize)
   63337             :       {
   63338             : #if ROSE_ALLOC_TRACE
   63339             :         if (blockIndex > 0) {
   63340             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNontemporalClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNontemporalClause) = %" PRIuPTR " SgOmpNontemporalClause::pool_size = %d \n",
   63341             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpNontemporalClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpNontemporalClause),SgOmpNontemporalClause::pool_size);
   63342             :         }
   63343             : #endif
   63344             : 
   63345           0 :         SgOmpNontemporalClause * pointer = (SgOmpNontemporalClause*) ROSE_MALLOC ( SgOmpNontemporalClause::pool_size * sizeof(SgOmpNontemporalClause) );
   63346           0 :         assert( pointer != NULL );
   63347             : #if ROSE_ALLOC_MEMSET == 1
   63348             :         memset(pointer, 0x00, SgOmpNontemporalClause::pool_size * sizeof(SgOmpNontemporalClause));
   63349             : #elif ROSE_ALLOC_MEMSET == 2
   63350             :         memset(pointer, 0xCC, SgOmpNontemporalClause::pool_size * sizeof(SgOmpNontemporalClause));
   63351             : #endif
   63352           0 :         SgOmpNontemporalClause::pools.push_back( (unsigned char*)(pointer) );
   63353           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpNontemporalClause::pool_size * sizeof(SgOmpNontemporalClause), V_SgOmpNontemporalClause ) );
   63354             : 
   63355           0 :         if ( SgOmpNontemporalClause::next_node != NULL ) {
   63356           0 :           if ( blockIndex > 0 ) {
   63357           0 :             SgOmpNontemporalClause * blkptr = (SgOmpNontemporalClause*)(SgOmpNontemporalClause::pools[blockIndex-1]);
   63358           0 :             blkptr[ SgOmpNontemporalClause::pool_size - 1 ].set_freepointer(pointer);
   63359             :           }
   63360             :         } else {
   63361           0 :           SgOmpNontemporalClause::next_node = pointer;
   63362             :         }
   63363             : 
   63364           0 :         for (unsigned i = 0; i < SgOmpNontemporalClause::pool_size-1; ++i)
   63365             :            {
   63366           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   63367             :            }
   63368           0 :         pointer[ SgOmpNontemporalClause::pool_size -1 ].set_freepointer(NULL);
   63369             : 
   63370           0 :         blockIndex++;
   63371             :       }
   63372           2 :   }
   63373             : 
   63374             : //############################################################################
   63375             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   63376             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   63377             :  * not compressed. However, that stuff is not yet implemented! 
   63378             :  */
   63379             : unsigned long
   63380           0 : SgOmpNontemporalClause::getNumberOfLastValidPointer()
   63381             :    {
   63382           0 :       SgOmpNontemporalClause* testPointer = (SgOmpNontemporalClause*)(SgOmpNontemporalClause::pools.back());
   63383           0 :       unsigned long localIndex = SgOmpNontemporalClause::pool_size - 1;
   63384           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   63385             :          {
   63386           0 :            localIndex--;
   63387             :          }
   63388           0 :       return (localIndex + SgOmpNontemporalClause::pool_size * (SgOmpNontemporalClause::pools.size()-1));
   63389             :    }
   63390             : 
   63391             : //############################################################################
   63392             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   63393             :  * memory pool and initializes the data member in class SgOmpNontemporalClauseStroageClass
   63394             :  * from its counterpart of SgOmpNontemporalClause. The return value is just for checking, 
   63395             :  * that the whole StorageClassArray is initialized!
   63396             :  */
   63397             : unsigned long
   63398           0 : SgOmpNontemporalClause::initializeStorageClassArray( SgOmpNontemporalClauseStorageClass *storageArray )
   63399             :    {
   63400           0 :      unsigned long storageCounter = 0;
   63401           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpNontemporalClause::pools.begin();
   63402           0 :      SgOmpNontemporalClause* pointer = NULL;
   63403           0 :      while ( block != SgOmpNontemporalClause::pools.end() ) {
   63404           0 :           pointer = (SgOmpNontemporalClause*) (*block);
   63405           0 :           for ( unsigned i = 0; i < SgOmpNontemporalClause::pool_size; ++i ) {
   63406           0 :                if ( pointer->get_freepointer() != NULL ) {
   63407           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   63408           0 :                  storageArray++;
   63409           0 :                  storageCounter++;
   63410             :                }
   63411           0 :                pointer++;
   63412             :              }
   63413           0 :            block++;
   63414             :         }
   63415           0 :      return storageCounter;
   63416             :    }
   63417             : 
   63418             : /* #line 63419 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   63419             : 
   63420             : 
   63421             : 
   63422             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   63423             : 
   63424             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   63425             : 
   63426             : //############################################################################
   63427             : /* JH (02/02/2006) Constructor of the IR node SgOmpInclusiveClause that takes its 
   63428             :  * corresponding StorageClass as parameter
   63429             :  */
   63430           0 : SgOmpInclusiveClause :: SgOmpInclusiveClause ( const SgOmpInclusiveClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   63431             :    {
   63432             : 
   63433             : 
   63434             : /* #line 63435 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   63435             : 
   63436           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   63437             : 
   63438             : 
   63439             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   63440             : 
   63441             : 
   63442           0 :    }
   63443             : 
   63444             : //############################################################################
   63445             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   63446             :  * within the working AST. 
   63447             :  */
   63448           0 : SgOmpInclusiveClause * SgOmpInclusiveClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   63449           0 :      SgOmpInclusiveClause* returnPointer = NULL;
   63450           0 :      if ( globalIndex != 0 )
   63451             :         {
   63452             : 
   63453             : #if FILE_IO_EXTRA_CHECK
   63454           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpInclusiveClause ) ) <= globalIndex ) ;
   63455           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpInclusiveClause + 1 ) ) );
   63456             : #endif
   63457           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpInclusiveClause )  
   63458           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpInclusiveClause );
   63459           0 :           unsigned long positionInPool = localIndex % SgOmpInclusiveClause::pool_size;
   63460           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpInclusiveClause::pool_size;
   63461             : 
   63462             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   63463             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   63464             : 
   63465           0 :           returnPointer = &( ( (SgOmpInclusiveClause*)(SgOmpInclusiveClause::pools[memoryBlock]) ) [positionInPool]) ;
   63466             : 
   63467           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   63468             :         }
   63469           0 :      return returnPointer ;
   63470             :    }
   63471             : 
   63472             : //############################################################################
   63473             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   63474             :   for the AST with the index astIndex
   63475             : */
   63476           0 : SgOmpInclusiveClause * SgOmpInclusiveClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   63477           0 :      SgOmpInclusiveClause* returnPointer = NULL;
   63478           0 :      if ( globalIndex != 0 )
   63479             :         {
   63480             : 
   63481             : #if FILE_IO_EXTRA_CHECK
   63482           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpInclusiveClause ) ) <= globalIndex ) ;
   63483           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpInclusiveClause + 1 ) ) );
   63484             : #endif
   63485           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpInclusiveClause )
   63486           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpInclusiveClause );
   63487           0 :           unsigned long positionInPool = localIndex % SgOmpInclusiveClause::pool_size ;
   63488           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpInclusiveClause::pool_size ;
   63489             : 
   63490             : #if FILE_IO_EXTRA_CHECK
   63491             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   63492             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   63493             : #endif
   63494             : 
   63495           0 :           returnPointer = &( ( (SgOmpInclusiveClause*)(SgOmpInclusiveClause::pools[memoryBlock]) ) [positionInPool]) ;
   63496             : 
   63497             : #if FILE_IO_EXTRA_CHECK
   63498           0 :           assert ( returnPointer != NULL ) ;
   63499             : #endif
   63500             :         }
   63501           0 :      return returnPointer ;
   63502             :    }
   63503             : 
   63504             : //############################################################################
   63505             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   63506             :  * pool size! We set for every valid object in the memory pool the freepointer
   63507             :  * to the global index and increase the global index afterwards. For all the 
   63508             :  * invalid objects (means address ranges within the memory pool that were not
   63509             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   63510             :  * distinguish valid from invalid objects! 
   63511             :  */
   63512             : unsigned long
   63513           5 : SgOmpInclusiveClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   63514             :    {
   63515           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   63516           5 :      SgOmpInclusiveClause* pointer = NULL;
   63517           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   63518           5 :      std::vector < unsigned char* > :: const_iterator block;
   63519           5 :      for ( block = SgOmpInclusiveClause::pools.begin(); block != SgOmpInclusiveClause::pools.end() ; ++block )
   63520             :         {
   63521           0 :           pointer = (SgOmpInclusiveClause*)(*block);
   63522           0 :           for (unsigned i = 0; i < SgOmpInclusiveClause::pool_size; ++i )
   63523             :              {
   63524             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   63525             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   63526             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   63527             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   63528             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   63529             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   63530             :             // properly; so this will have to be checked next.
   63531             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   63532             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   63533           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   63534             :                   {
   63535           0 :                     pointer[i].set_freepointer((SgOmpInclusiveClause*)(globalIndex));
   63536           0 :                     globalIndex++;
   63537             :                   }
   63538             :                else
   63539             :                   {
   63540           0 :                     pointer[i].set_freepointer(NULL);
   63541             :                   }
   63542             :               }
   63543             :         }
   63544           5 :      return globalIndex;
   63545             :    }
   63546             : 
   63547             : //############################################################################
   63548             : // JH (01/14/2006)
   63549             : void
   63550           5 : SgOmpInclusiveClause::resetValidFreepointers( )
   63551             :    {
   63552           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   63553           5 :      SgOmpInclusiveClause* pointer = NULL;
   63554           5 :      std::vector < unsigned char* > :: const_iterator block;
   63555           5 :      SgOmpInclusiveClause* pointerOfLinkedList = NULL;
   63556           5 :      for ( block = SgOmpInclusiveClause::pools.begin(); block != SgOmpInclusiveClause::pools.end() ; ++block )
   63557             :         {
   63558           0 :           pointer = (SgOmpInclusiveClause*)(*block);
   63559           0 :           for (unsigned i = 0; i < SgOmpInclusiveClause::pool_size; ++i )
   63560             :              {
   63561             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   63562             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   63563             :             // memory blocks!.
   63564           0 :                if ( pointer[i].get_freepointer() != NULL )
   63565             :                   {
   63566           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   63567             :                   }
   63568             :                else
   63569             :                   {
   63570           0 :                     if ( pointerOfLinkedList == NULL )
   63571             :                        {
   63572           0 :                          SgOmpInclusiveClause::next_node = &(pointer[i]);
   63573             :                        }
   63574             :                     else
   63575             :                        {
   63576             :                       // printf ("In SgOmpInclusiveClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   63577           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   63578             :                        }
   63579             :                     pointerOfLinkedList = &(pointer[i]);
   63580             :                   }
   63581             :               }
   63582             :         }
   63583             : 
   63584           5 :      if ( pointerOfLinkedList != NULL )
   63585             :         {
   63586             :        // printf ("In SgOmpInclusiveClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   63587           0 :           pointerOfLinkedList->set_freepointer(NULL);
   63588             :        // DQ (6/6/2010): Temporary debugging...
   63589             :        //   ROSE_ASSERT(false);
   63590             :         }
   63591             : 
   63592           5 :      return ;
   63593             :    }
   63594             : 
   63595             : //############################################################################
   63596             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   63597             :  * within the memory pool and resets the freepointers, in order to achieve a 
   63598             :  * linked list, that has no jumps and starts at the beginning! This function 
   63599             :  * does not extend the memory pool, since we do not delete any memory blocks,
   63600             :  * but delete the valid objects.  
   63601             :  */
   63602             : void
   63603           0 : SgOmpInclusiveClause::clearMemoryPool( )
   63604             :    {
   63605             :   // printf ("Inside of SgOmpInclusiveClause::clearMemoryPool() \n");
   63606             : 
   63607           0 :      SgOmpInclusiveClause* pointer = NULL, *tempPointer = NULL;
   63608           0 :      std::vector < unsigned char* > :: const_iterator block;
   63609           0 :      if ( SgOmpInclusiveClause::pools.empty() == false )
   63610             :         {
   63611           0 :           block = SgOmpInclusiveClause::pools.begin() ;
   63612           0 :           SgOmpInclusiveClause::next_node = (SgOmpInclusiveClause*) (*block);
   63613             : 
   63614           0 :           while ( block != SgOmpInclusiveClause::pools.end() )
   63615             :              {
   63616           0 :                pointer = (SgOmpInclusiveClause*) (*block);
   63617           0 :                if ( tempPointer != NULL )
   63618             :                   {
   63619           0 :                     tempPointer->set_freepointer(pointer);
   63620             :                   }
   63621           0 :                for (unsigned i = 0; i < SgOmpInclusiveClause::pool_size - 1; ++i)
   63622             :                   {
   63623           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   63624             :                   }
   63625           0 :                 pointer[SgOmpInclusiveClause::pool_size-1].set_freepointer(NULL);
   63626           0 :                 tempPointer = &(pointer[SgOmpInclusiveClause::pool_size-1]);
   63627           0 :                 ++block;
   63628             :              }
   63629             :         }
   63630           0 :    }
   63631             : 
   63632           5 : void SgOmpInclusiveClause::deleteMemoryPool() {
   63633           5 :   for (auto p: SgOmpInclusiveClause::pools) {
   63634           0 :     ROSE_FREE(p);
   63635             :   }
   63636           5 :   SgOmpInclusiveClause::next_node = nullptr;
   63637           5 :   SgOmpInclusiveClause::pools.clear();
   63638           5 : }
   63639             : 
   63640             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   63641             : //                 reading multiple binary files to for a single AST.
   63642             : /////////// new version ////////////////////////////////
   63643             : //############################################################################
   63644             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   63645             : void
   63646           2 : SgOmpInclusiveClause::extendMemoryPoolForFileIO( )
   63647             :   {
   63648           2 :     size_t blockIndex = SgOmpInclusiveClause::pools.size();
   63649           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInclusiveClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInclusiveClause);
   63650             : 
   63651           2 :     while ( (blockIndex * SgOmpInclusiveClause::pool_size) < newPoolSize)
   63652             :       {
   63653             : #if ROSE_ALLOC_TRACE
   63654             :         if (blockIndex > 0) {
   63655             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInclusiveClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInclusiveClause) = %" PRIuPTR " SgOmpInclusiveClause::pool_size = %d \n",
   63656             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInclusiveClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInclusiveClause),SgOmpInclusiveClause::pool_size);
   63657             :         }
   63658             : #endif
   63659             : 
   63660           0 :         SgOmpInclusiveClause * pointer = (SgOmpInclusiveClause*) ROSE_MALLOC ( SgOmpInclusiveClause::pool_size * sizeof(SgOmpInclusiveClause) );
   63661           0 :         assert( pointer != NULL );
   63662             : #if ROSE_ALLOC_MEMSET == 1
   63663             :         memset(pointer, 0x00, SgOmpInclusiveClause::pool_size * sizeof(SgOmpInclusiveClause));
   63664             : #elif ROSE_ALLOC_MEMSET == 2
   63665             :         memset(pointer, 0xCC, SgOmpInclusiveClause::pool_size * sizeof(SgOmpInclusiveClause));
   63666             : #endif
   63667           0 :         SgOmpInclusiveClause::pools.push_back( (unsigned char*)(pointer) );
   63668           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpInclusiveClause::pool_size * sizeof(SgOmpInclusiveClause), V_SgOmpInclusiveClause ) );
   63669             : 
   63670           0 :         if ( SgOmpInclusiveClause::next_node != NULL ) {
   63671           0 :           if ( blockIndex > 0 ) {
   63672           0 :             SgOmpInclusiveClause * blkptr = (SgOmpInclusiveClause*)(SgOmpInclusiveClause::pools[blockIndex-1]);
   63673           0 :             blkptr[ SgOmpInclusiveClause::pool_size - 1 ].set_freepointer(pointer);
   63674             :           }
   63675             :         } else {
   63676           0 :           SgOmpInclusiveClause::next_node = pointer;
   63677             :         }
   63678             : 
   63679           0 :         for (unsigned i = 0; i < SgOmpInclusiveClause::pool_size-1; ++i)
   63680             :            {
   63681           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   63682             :            }
   63683           0 :         pointer[ SgOmpInclusiveClause::pool_size -1 ].set_freepointer(NULL);
   63684             : 
   63685           0 :         blockIndex++;
   63686             :       }
   63687           2 :   }
   63688             : 
   63689             : //############################################################################
   63690             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   63691             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   63692             :  * not compressed. However, that stuff is not yet implemented! 
   63693             :  */
   63694             : unsigned long
   63695           0 : SgOmpInclusiveClause::getNumberOfLastValidPointer()
   63696             :    {
   63697           0 :       SgOmpInclusiveClause* testPointer = (SgOmpInclusiveClause*)(SgOmpInclusiveClause::pools.back());
   63698           0 :       unsigned long localIndex = SgOmpInclusiveClause::pool_size - 1;
   63699           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   63700             :          {
   63701           0 :            localIndex--;
   63702             :          }
   63703           0 :       return (localIndex + SgOmpInclusiveClause::pool_size * (SgOmpInclusiveClause::pools.size()-1));
   63704             :    }
   63705             : 
   63706             : //############################################################################
   63707             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   63708             :  * memory pool and initializes the data member in class SgOmpInclusiveClauseStroageClass
   63709             :  * from its counterpart of SgOmpInclusiveClause. The return value is just for checking, 
   63710             :  * that the whole StorageClassArray is initialized!
   63711             :  */
   63712             : unsigned long
   63713           0 : SgOmpInclusiveClause::initializeStorageClassArray( SgOmpInclusiveClauseStorageClass *storageArray )
   63714             :    {
   63715           0 :      unsigned long storageCounter = 0;
   63716           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpInclusiveClause::pools.begin();
   63717           0 :      SgOmpInclusiveClause* pointer = NULL;
   63718           0 :      while ( block != SgOmpInclusiveClause::pools.end() ) {
   63719           0 :           pointer = (SgOmpInclusiveClause*) (*block);
   63720           0 :           for ( unsigned i = 0; i < SgOmpInclusiveClause::pool_size; ++i ) {
   63721           0 :                if ( pointer->get_freepointer() != NULL ) {
   63722           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   63723           0 :                  storageArray++;
   63724           0 :                  storageCounter++;
   63725             :                }
   63726           0 :                pointer++;
   63727             :              }
   63728           0 :            block++;
   63729             :         }
   63730           0 :      return storageCounter;
   63731             :    }
   63732             : 
   63733             : /* #line 63734 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   63734             : 
   63735             : 
   63736             : 
   63737             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   63738             : 
   63739             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   63740             : 
   63741             : //############################################################################
   63742             : /* JH (02/02/2006) Constructor of the IR node SgOmpExclusiveClause that takes its 
   63743             :  * corresponding StorageClass as parameter
   63744             :  */
   63745           0 : SgOmpExclusiveClause :: SgOmpExclusiveClause ( const SgOmpExclusiveClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   63746             :    {
   63747             : 
   63748             : 
   63749             : /* #line 63750 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   63750             : 
   63751           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   63752             : 
   63753             : 
   63754             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   63755             : 
   63756             : 
   63757           0 :    }
   63758             : 
   63759             : //############################################################################
   63760             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   63761             :  * within the working AST. 
   63762             :  */
   63763           0 : SgOmpExclusiveClause * SgOmpExclusiveClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   63764           0 :      SgOmpExclusiveClause* returnPointer = NULL;
   63765           0 :      if ( globalIndex != 0 )
   63766             :         {
   63767             : 
   63768             : #if FILE_IO_EXTRA_CHECK
   63769           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpExclusiveClause ) ) <= globalIndex ) ;
   63770           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpExclusiveClause + 1 ) ) );
   63771             : #endif
   63772           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpExclusiveClause )  
   63773           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpExclusiveClause );
   63774           0 :           unsigned long positionInPool = localIndex % SgOmpExclusiveClause::pool_size;
   63775           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpExclusiveClause::pool_size;
   63776             : 
   63777             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   63778             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   63779             : 
   63780           0 :           returnPointer = &( ( (SgOmpExclusiveClause*)(SgOmpExclusiveClause::pools[memoryBlock]) ) [positionInPool]) ;
   63781             : 
   63782           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   63783             :         }
   63784           0 :      return returnPointer ;
   63785             :    }
   63786             : 
   63787             : //############################################################################
   63788             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   63789             :   for the AST with the index astIndex
   63790             : */
   63791           0 : SgOmpExclusiveClause * SgOmpExclusiveClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   63792           0 :      SgOmpExclusiveClause* returnPointer = NULL;
   63793           0 :      if ( globalIndex != 0 )
   63794             :         {
   63795             : 
   63796             : #if FILE_IO_EXTRA_CHECK
   63797           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpExclusiveClause ) ) <= globalIndex ) ;
   63798           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpExclusiveClause + 1 ) ) );
   63799             : #endif
   63800           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpExclusiveClause )
   63801           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpExclusiveClause );
   63802           0 :           unsigned long positionInPool = localIndex % SgOmpExclusiveClause::pool_size ;
   63803           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpExclusiveClause::pool_size ;
   63804             : 
   63805             : #if FILE_IO_EXTRA_CHECK
   63806             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   63807             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   63808             : #endif
   63809             : 
   63810           0 :           returnPointer = &( ( (SgOmpExclusiveClause*)(SgOmpExclusiveClause::pools[memoryBlock]) ) [positionInPool]) ;
   63811             : 
   63812             : #if FILE_IO_EXTRA_CHECK
   63813           0 :           assert ( returnPointer != NULL ) ;
   63814             : #endif
   63815             :         }
   63816           0 :      return returnPointer ;
   63817             :    }
   63818             : 
   63819             : //############################################################################
   63820             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   63821             :  * pool size! We set for every valid object in the memory pool the freepointer
   63822             :  * to the global index and increase the global index afterwards. For all the 
   63823             :  * invalid objects (means address ranges within the memory pool that were not
   63824             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   63825             :  * distinguish valid from invalid objects! 
   63826             :  */
   63827             : unsigned long
   63828           5 : SgOmpExclusiveClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   63829             :    {
   63830           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   63831           5 :      SgOmpExclusiveClause* pointer = NULL;
   63832           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   63833           5 :      std::vector < unsigned char* > :: const_iterator block;
   63834           5 :      for ( block = SgOmpExclusiveClause::pools.begin(); block != SgOmpExclusiveClause::pools.end() ; ++block )
   63835             :         {
   63836           0 :           pointer = (SgOmpExclusiveClause*)(*block);
   63837           0 :           for (unsigned i = 0; i < SgOmpExclusiveClause::pool_size; ++i )
   63838             :              {
   63839             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   63840             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   63841             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   63842             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   63843             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   63844             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   63845             :             // properly; so this will have to be checked next.
   63846             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   63847             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   63848           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   63849             :                   {
   63850           0 :                     pointer[i].set_freepointer((SgOmpExclusiveClause*)(globalIndex));
   63851           0 :                     globalIndex++;
   63852             :                   }
   63853             :                else
   63854             :                   {
   63855           0 :                     pointer[i].set_freepointer(NULL);
   63856             :                   }
   63857             :               }
   63858             :         }
   63859           5 :      return globalIndex;
   63860             :    }
   63861             : 
   63862             : //############################################################################
   63863             : // JH (01/14/2006)
   63864             : void
   63865           5 : SgOmpExclusiveClause::resetValidFreepointers( )
   63866             :    {
   63867           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   63868           5 :      SgOmpExclusiveClause* pointer = NULL;
   63869           5 :      std::vector < unsigned char* > :: const_iterator block;
   63870           5 :      SgOmpExclusiveClause* pointerOfLinkedList = NULL;
   63871           5 :      for ( block = SgOmpExclusiveClause::pools.begin(); block != SgOmpExclusiveClause::pools.end() ; ++block )
   63872             :         {
   63873           0 :           pointer = (SgOmpExclusiveClause*)(*block);
   63874           0 :           for (unsigned i = 0; i < SgOmpExclusiveClause::pool_size; ++i )
   63875             :              {
   63876             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   63877             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   63878             :             // memory blocks!.
   63879           0 :                if ( pointer[i].get_freepointer() != NULL )
   63880             :                   {
   63881           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   63882             :                   }
   63883             :                else
   63884             :                   {
   63885           0 :                     if ( pointerOfLinkedList == NULL )
   63886             :                        {
   63887           0 :                          SgOmpExclusiveClause::next_node = &(pointer[i]);
   63888             :                        }
   63889             :                     else
   63890             :                        {
   63891             :                       // printf ("In SgOmpExclusiveClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   63892           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   63893             :                        }
   63894             :                     pointerOfLinkedList = &(pointer[i]);
   63895             :                   }
   63896             :               }
   63897             :         }
   63898             : 
   63899           5 :      if ( pointerOfLinkedList != NULL )
   63900             :         {
   63901             :        // printf ("In SgOmpExclusiveClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   63902           0 :           pointerOfLinkedList->set_freepointer(NULL);
   63903             :        // DQ (6/6/2010): Temporary debugging...
   63904             :        //   ROSE_ASSERT(false);
   63905             :         }
   63906             : 
   63907           5 :      return ;
   63908             :    }
   63909             : 
   63910             : //############################################################################
   63911             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   63912             :  * within the memory pool and resets the freepointers, in order to achieve a 
   63913             :  * linked list, that has no jumps and starts at the beginning! This function 
   63914             :  * does not extend the memory pool, since we do not delete any memory blocks,
   63915             :  * but delete the valid objects.  
   63916             :  */
   63917             : void
   63918           0 : SgOmpExclusiveClause::clearMemoryPool( )
   63919             :    {
   63920             :   // printf ("Inside of SgOmpExclusiveClause::clearMemoryPool() \n");
   63921             : 
   63922           0 :      SgOmpExclusiveClause* pointer = NULL, *tempPointer = NULL;
   63923           0 :      std::vector < unsigned char* > :: const_iterator block;
   63924           0 :      if ( SgOmpExclusiveClause::pools.empty() == false )
   63925             :         {
   63926           0 :           block = SgOmpExclusiveClause::pools.begin() ;
   63927           0 :           SgOmpExclusiveClause::next_node = (SgOmpExclusiveClause*) (*block);
   63928             : 
   63929           0 :           while ( block != SgOmpExclusiveClause::pools.end() )
   63930             :              {
   63931           0 :                pointer = (SgOmpExclusiveClause*) (*block);
   63932           0 :                if ( tempPointer != NULL )
   63933             :                   {
   63934           0 :                     tempPointer->set_freepointer(pointer);
   63935             :                   }
   63936           0 :                for (unsigned i = 0; i < SgOmpExclusiveClause::pool_size - 1; ++i)
   63937             :                   {
   63938           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   63939             :                   }
   63940           0 :                 pointer[SgOmpExclusiveClause::pool_size-1].set_freepointer(NULL);
   63941           0 :                 tempPointer = &(pointer[SgOmpExclusiveClause::pool_size-1]);
   63942           0 :                 ++block;
   63943             :              }
   63944             :         }
   63945           0 :    }
   63946             : 
   63947           5 : void SgOmpExclusiveClause::deleteMemoryPool() {
   63948           5 :   for (auto p: SgOmpExclusiveClause::pools) {
   63949           0 :     ROSE_FREE(p);
   63950             :   }
   63951           5 :   SgOmpExclusiveClause::next_node = nullptr;
   63952           5 :   SgOmpExclusiveClause::pools.clear();
   63953           5 : }
   63954             : 
   63955             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   63956             : //                 reading multiple binary files to for a single AST.
   63957             : /////////// new version ////////////////////////////////
   63958             : //############################################################################
   63959             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   63960             : void
   63961           2 : SgOmpExclusiveClause::extendMemoryPoolForFileIO( )
   63962             :   {
   63963           2 :     size_t blockIndex = SgOmpExclusiveClause::pools.size();
   63964           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExclusiveClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExclusiveClause);
   63965             : 
   63966           2 :     while ( (blockIndex * SgOmpExclusiveClause::pool_size) < newPoolSize)
   63967             :       {
   63968             : #if ROSE_ALLOC_TRACE
   63969             :         if (blockIndex > 0) {
   63970             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExclusiveClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExclusiveClause) = %" PRIuPTR " SgOmpExclusiveClause::pool_size = %d \n",
   63971             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpExclusiveClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpExclusiveClause),SgOmpExclusiveClause::pool_size);
   63972             :         }
   63973             : #endif
   63974             : 
   63975           0 :         SgOmpExclusiveClause * pointer = (SgOmpExclusiveClause*) ROSE_MALLOC ( SgOmpExclusiveClause::pool_size * sizeof(SgOmpExclusiveClause) );
   63976           0 :         assert( pointer != NULL );
   63977             : #if ROSE_ALLOC_MEMSET == 1
   63978             :         memset(pointer, 0x00, SgOmpExclusiveClause::pool_size * sizeof(SgOmpExclusiveClause));
   63979             : #elif ROSE_ALLOC_MEMSET == 2
   63980             :         memset(pointer, 0xCC, SgOmpExclusiveClause::pool_size * sizeof(SgOmpExclusiveClause));
   63981             : #endif
   63982           0 :         SgOmpExclusiveClause::pools.push_back( (unsigned char*)(pointer) );
   63983           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpExclusiveClause::pool_size * sizeof(SgOmpExclusiveClause), V_SgOmpExclusiveClause ) );
   63984             : 
   63985           0 :         if ( SgOmpExclusiveClause::next_node != NULL ) {
   63986           0 :           if ( blockIndex > 0 ) {
   63987           0 :             SgOmpExclusiveClause * blkptr = (SgOmpExclusiveClause*)(SgOmpExclusiveClause::pools[blockIndex-1]);
   63988           0 :             blkptr[ SgOmpExclusiveClause::pool_size - 1 ].set_freepointer(pointer);
   63989             :           }
   63990             :         } else {
   63991           0 :           SgOmpExclusiveClause::next_node = pointer;
   63992             :         }
   63993             : 
   63994           0 :         for (unsigned i = 0; i < SgOmpExclusiveClause::pool_size-1; ++i)
   63995             :            {
   63996           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   63997             :            }
   63998           0 :         pointer[ SgOmpExclusiveClause::pool_size -1 ].set_freepointer(NULL);
   63999             : 
   64000           0 :         blockIndex++;
   64001             :       }
   64002           2 :   }
   64003             : 
   64004             : //############################################################################
   64005             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   64006             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   64007             :  * not compressed. However, that stuff is not yet implemented! 
   64008             :  */
   64009             : unsigned long
   64010           0 : SgOmpExclusiveClause::getNumberOfLastValidPointer()
   64011             :    {
   64012           0 :       SgOmpExclusiveClause* testPointer = (SgOmpExclusiveClause*)(SgOmpExclusiveClause::pools.back());
   64013           0 :       unsigned long localIndex = SgOmpExclusiveClause::pool_size - 1;
   64014           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   64015             :          {
   64016           0 :            localIndex--;
   64017             :          }
   64018           0 :       return (localIndex + SgOmpExclusiveClause::pool_size * (SgOmpExclusiveClause::pools.size()-1));
   64019             :    }
   64020             : 
   64021             : //############################################################################
   64022             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   64023             :  * memory pool and initializes the data member in class SgOmpExclusiveClauseStroageClass
   64024             :  * from its counterpart of SgOmpExclusiveClause. The return value is just for checking, 
   64025             :  * that the whole StorageClassArray is initialized!
   64026             :  */
   64027             : unsigned long
   64028           0 : SgOmpExclusiveClause::initializeStorageClassArray( SgOmpExclusiveClauseStorageClass *storageArray )
   64029             :    {
   64030           0 :      unsigned long storageCounter = 0;
   64031           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpExclusiveClause::pools.begin();
   64032           0 :      SgOmpExclusiveClause* pointer = NULL;
   64033           0 :      while ( block != SgOmpExclusiveClause::pools.end() ) {
   64034           0 :           pointer = (SgOmpExclusiveClause*) (*block);
   64035           0 :           for ( unsigned i = 0; i < SgOmpExclusiveClause::pool_size; ++i ) {
   64036           0 :                if ( pointer->get_freepointer() != NULL ) {
   64037           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   64038           0 :                  storageArray++;
   64039           0 :                  storageCounter++;
   64040             :                }
   64041           0 :                pointer++;
   64042             :              }
   64043           0 :            block++;
   64044             :         }
   64045           0 :      return storageCounter;
   64046             :    }
   64047             : 
   64048             : /* #line 64049 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   64049             : 
   64050             : 
   64051             : 
   64052             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   64053             : 
   64054             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   64055             : 
   64056             : //############################################################################
   64057             : /* JH (02/02/2006) Constructor of the IR node SgOmpIsDevicePtrClause that takes its 
   64058             :  * corresponding StorageClass as parameter
   64059             :  */
   64060           0 : SgOmpIsDevicePtrClause :: SgOmpIsDevicePtrClause ( const SgOmpIsDevicePtrClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   64061             :    {
   64062             : 
   64063             : 
   64064             : /* #line 64065 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   64065             : 
   64066           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   64067             : 
   64068             : 
   64069             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   64070             : 
   64071             : 
   64072           0 :    }
   64073             : 
   64074             : //############################################################################
   64075             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   64076             :  * within the working AST. 
   64077             :  */
   64078           0 : SgOmpIsDevicePtrClause * SgOmpIsDevicePtrClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   64079           0 :      SgOmpIsDevicePtrClause* returnPointer = NULL;
   64080           0 :      if ( globalIndex != 0 )
   64081             :         {
   64082             : 
   64083             : #if FILE_IO_EXTRA_CHECK
   64084           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpIsDevicePtrClause ) ) <= globalIndex ) ;
   64085           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpIsDevicePtrClause + 1 ) ) );
   64086             : #endif
   64087           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpIsDevicePtrClause )  
   64088           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpIsDevicePtrClause );
   64089           0 :           unsigned long positionInPool = localIndex % SgOmpIsDevicePtrClause::pool_size;
   64090           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpIsDevicePtrClause::pool_size;
   64091             : 
   64092             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   64093             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   64094             : 
   64095           0 :           returnPointer = &( ( (SgOmpIsDevicePtrClause*)(SgOmpIsDevicePtrClause::pools[memoryBlock]) ) [positionInPool]) ;
   64096             : 
   64097           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   64098             :         }
   64099           0 :      return returnPointer ;
   64100             :    }
   64101             : 
   64102             : //############################################################################
   64103             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   64104             :   for the AST with the index astIndex
   64105             : */
   64106           0 : SgOmpIsDevicePtrClause * SgOmpIsDevicePtrClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   64107           0 :      SgOmpIsDevicePtrClause* returnPointer = NULL;
   64108           0 :      if ( globalIndex != 0 )
   64109             :         {
   64110             : 
   64111             : #if FILE_IO_EXTRA_CHECK
   64112           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpIsDevicePtrClause ) ) <= globalIndex ) ;
   64113           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpIsDevicePtrClause + 1 ) ) );
   64114             : #endif
   64115           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpIsDevicePtrClause )
   64116           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpIsDevicePtrClause );
   64117           0 :           unsigned long positionInPool = localIndex % SgOmpIsDevicePtrClause::pool_size ;
   64118           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpIsDevicePtrClause::pool_size ;
   64119             : 
   64120             : #if FILE_IO_EXTRA_CHECK
   64121             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   64122             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   64123             : #endif
   64124             : 
   64125           0 :           returnPointer = &( ( (SgOmpIsDevicePtrClause*)(SgOmpIsDevicePtrClause::pools[memoryBlock]) ) [positionInPool]) ;
   64126             : 
   64127             : #if FILE_IO_EXTRA_CHECK
   64128           0 :           assert ( returnPointer != NULL ) ;
   64129             : #endif
   64130             :         }
   64131           0 :      return returnPointer ;
   64132             :    }
   64133             : 
   64134             : //############################################################################
   64135             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   64136             :  * pool size! We set for every valid object in the memory pool the freepointer
   64137             :  * to the global index and increase the global index afterwards. For all the 
   64138             :  * invalid objects (means address ranges within the memory pool that were not
   64139             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   64140             :  * distinguish valid from invalid objects! 
   64141             :  */
   64142             : unsigned long
   64143           5 : SgOmpIsDevicePtrClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   64144             :    {
   64145           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   64146           5 :      SgOmpIsDevicePtrClause* pointer = NULL;
   64147           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   64148           5 :      std::vector < unsigned char* > :: const_iterator block;
   64149           5 :      for ( block = SgOmpIsDevicePtrClause::pools.begin(); block != SgOmpIsDevicePtrClause::pools.end() ; ++block )
   64150             :         {
   64151           0 :           pointer = (SgOmpIsDevicePtrClause*)(*block);
   64152           0 :           for (unsigned i = 0; i < SgOmpIsDevicePtrClause::pool_size; ++i )
   64153             :              {
   64154             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   64155             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   64156             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   64157             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   64158             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   64159             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   64160             :             // properly; so this will have to be checked next.
   64161             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   64162             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   64163           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   64164             :                   {
   64165           0 :                     pointer[i].set_freepointer((SgOmpIsDevicePtrClause*)(globalIndex));
   64166           0 :                     globalIndex++;
   64167             :                   }
   64168             :                else
   64169             :                   {
   64170           0 :                     pointer[i].set_freepointer(NULL);
   64171             :                   }
   64172             :               }
   64173             :         }
   64174           5 :      return globalIndex;
   64175             :    }
   64176             : 
   64177             : //############################################################################
   64178             : // JH (01/14/2006)
   64179             : void
   64180           5 : SgOmpIsDevicePtrClause::resetValidFreepointers( )
   64181             :    {
   64182           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   64183           5 :      SgOmpIsDevicePtrClause* pointer = NULL;
   64184           5 :      std::vector < unsigned char* > :: const_iterator block;
   64185           5 :      SgOmpIsDevicePtrClause* pointerOfLinkedList = NULL;
   64186           5 :      for ( block = SgOmpIsDevicePtrClause::pools.begin(); block != SgOmpIsDevicePtrClause::pools.end() ; ++block )
   64187             :         {
   64188           0 :           pointer = (SgOmpIsDevicePtrClause*)(*block);
   64189           0 :           for (unsigned i = 0; i < SgOmpIsDevicePtrClause::pool_size; ++i )
   64190             :              {
   64191             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   64192             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   64193             :             // memory blocks!.
   64194           0 :                if ( pointer[i].get_freepointer() != NULL )
   64195             :                   {
   64196           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   64197             :                   }
   64198             :                else
   64199             :                   {
   64200           0 :                     if ( pointerOfLinkedList == NULL )
   64201             :                        {
   64202           0 :                          SgOmpIsDevicePtrClause::next_node = &(pointer[i]);
   64203             :                        }
   64204             :                     else
   64205             :                        {
   64206             :                       // printf ("In SgOmpIsDevicePtrClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   64207           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   64208             :                        }
   64209             :                     pointerOfLinkedList = &(pointer[i]);
   64210             :                   }
   64211             :               }
   64212             :         }
   64213             : 
   64214           5 :      if ( pointerOfLinkedList != NULL )
   64215             :         {
   64216             :        // printf ("In SgOmpIsDevicePtrClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   64217           0 :           pointerOfLinkedList->set_freepointer(NULL);
   64218             :        // DQ (6/6/2010): Temporary debugging...
   64219             :        //   ROSE_ASSERT(false);
   64220             :         }
   64221             : 
   64222           5 :      return ;
   64223             :    }
   64224             : 
   64225             : //############################################################################
   64226             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   64227             :  * within the memory pool and resets the freepointers, in order to achieve a 
   64228             :  * linked list, that has no jumps and starts at the beginning! This function 
   64229             :  * does not extend the memory pool, since we do not delete any memory blocks,
   64230             :  * but delete the valid objects.  
   64231             :  */
   64232             : void
   64233           0 : SgOmpIsDevicePtrClause::clearMemoryPool( )
   64234             :    {
   64235             :   // printf ("Inside of SgOmpIsDevicePtrClause::clearMemoryPool() \n");
   64236             : 
   64237           0 :      SgOmpIsDevicePtrClause* pointer = NULL, *tempPointer = NULL;
   64238           0 :      std::vector < unsigned char* > :: const_iterator block;
   64239           0 :      if ( SgOmpIsDevicePtrClause::pools.empty() == false )
   64240             :         {
   64241           0 :           block = SgOmpIsDevicePtrClause::pools.begin() ;
   64242           0 :           SgOmpIsDevicePtrClause::next_node = (SgOmpIsDevicePtrClause*) (*block);
   64243             : 
   64244           0 :           while ( block != SgOmpIsDevicePtrClause::pools.end() )
   64245             :              {
   64246           0 :                pointer = (SgOmpIsDevicePtrClause*) (*block);
   64247           0 :                if ( tempPointer != NULL )
   64248             :                   {
   64249           0 :                     tempPointer->set_freepointer(pointer);
   64250             :                   }
   64251           0 :                for (unsigned i = 0; i < SgOmpIsDevicePtrClause::pool_size - 1; ++i)
   64252             :                   {
   64253           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   64254             :                   }
   64255           0 :                 pointer[SgOmpIsDevicePtrClause::pool_size-1].set_freepointer(NULL);
   64256           0 :                 tempPointer = &(pointer[SgOmpIsDevicePtrClause::pool_size-1]);
   64257           0 :                 ++block;
   64258             :              }
   64259             :         }
   64260           0 :    }
   64261             : 
   64262           5 : void SgOmpIsDevicePtrClause::deleteMemoryPool() {
   64263           5 :   for (auto p: SgOmpIsDevicePtrClause::pools) {
   64264           0 :     ROSE_FREE(p);
   64265             :   }
   64266           5 :   SgOmpIsDevicePtrClause::next_node = nullptr;
   64267           5 :   SgOmpIsDevicePtrClause::pools.clear();
   64268           5 : }
   64269             : 
   64270             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   64271             : //                 reading multiple binary files to for a single AST.
   64272             : /////////// new version ////////////////////////////////
   64273             : //############################################################################
   64274             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   64275             : void
   64276           2 : SgOmpIsDevicePtrClause::extendMemoryPoolForFileIO( )
   64277             :   {
   64278           2 :     size_t blockIndex = SgOmpIsDevicePtrClause::pools.size();
   64279           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpIsDevicePtrClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpIsDevicePtrClause);
   64280             : 
   64281           2 :     while ( (blockIndex * SgOmpIsDevicePtrClause::pool_size) < newPoolSize)
   64282             :       {
   64283             : #if ROSE_ALLOC_TRACE
   64284             :         if (blockIndex > 0) {
   64285             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpIsDevicePtrClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpIsDevicePtrClause) = %" PRIuPTR " SgOmpIsDevicePtrClause::pool_size = %d \n",
   64286             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpIsDevicePtrClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpIsDevicePtrClause),SgOmpIsDevicePtrClause::pool_size);
   64287             :         }
   64288             : #endif
   64289             : 
   64290           0 :         SgOmpIsDevicePtrClause * pointer = (SgOmpIsDevicePtrClause*) ROSE_MALLOC ( SgOmpIsDevicePtrClause::pool_size * sizeof(SgOmpIsDevicePtrClause) );
   64291           0 :         assert( pointer != NULL );
   64292             : #if ROSE_ALLOC_MEMSET == 1
   64293             :         memset(pointer, 0x00, SgOmpIsDevicePtrClause::pool_size * sizeof(SgOmpIsDevicePtrClause));
   64294             : #elif ROSE_ALLOC_MEMSET == 2
   64295             :         memset(pointer, 0xCC, SgOmpIsDevicePtrClause::pool_size * sizeof(SgOmpIsDevicePtrClause));
   64296             : #endif
   64297           0 :         SgOmpIsDevicePtrClause::pools.push_back( (unsigned char*)(pointer) );
   64298           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpIsDevicePtrClause::pool_size * sizeof(SgOmpIsDevicePtrClause), V_SgOmpIsDevicePtrClause ) );
   64299             : 
   64300           0 :         if ( SgOmpIsDevicePtrClause::next_node != NULL ) {
   64301           0 :           if ( blockIndex > 0 ) {
   64302           0 :             SgOmpIsDevicePtrClause * blkptr = (SgOmpIsDevicePtrClause*)(SgOmpIsDevicePtrClause::pools[blockIndex-1]);
   64303           0 :             blkptr[ SgOmpIsDevicePtrClause::pool_size - 1 ].set_freepointer(pointer);
   64304             :           }
   64305             :         } else {
   64306           0 :           SgOmpIsDevicePtrClause::next_node = pointer;
   64307             :         }
   64308             : 
   64309           0 :         for (unsigned i = 0; i < SgOmpIsDevicePtrClause::pool_size-1; ++i)
   64310             :            {
   64311           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   64312             :            }
   64313           0 :         pointer[ SgOmpIsDevicePtrClause::pool_size -1 ].set_freepointer(NULL);
   64314             : 
   64315           0 :         blockIndex++;
   64316             :       }
   64317           2 :   }
   64318             : 
   64319             : //############################################################################
   64320             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   64321             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   64322             :  * not compressed. However, that stuff is not yet implemented! 
   64323             :  */
   64324             : unsigned long
   64325           0 : SgOmpIsDevicePtrClause::getNumberOfLastValidPointer()
   64326             :    {
   64327           0 :       SgOmpIsDevicePtrClause* testPointer = (SgOmpIsDevicePtrClause*)(SgOmpIsDevicePtrClause::pools.back());
   64328           0 :       unsigned long localIndex = SgOmpIsDevicePtrClause::pool_size - 1;
   64329           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   64330             :          {
   64331           0 :            localIndex--;
   64332             :          }
   64333           0 :       return (localIndex + SgOmpIsDevicePtrClause::pool_size * (SgOmpIsDevicePtrClause::pools.size()-1));
   64334             :    }
   64335             : 
   64336             : //############################################################################
   64337             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   64338             :  * memory pool and initializes the data member in class SgOmpIsDevicePtrClauseStroageClass
   64339             :  * from its counterpart of SgOmpIsDevicePtrClause. The return value is just for checking, 
   64340             :  * that the whole StorageClassArray is initialized!
   64341             :  */
   64342             : unsigned long
   64343           0 : SgOmpIsDevicePtrClause::initializeStorageClassArray( SgOmpIsDevicePtrClauseStorageClass *storageArray )
   64344             :    {
   64345           0 :      unsigned long storageCounter = 0;
   64346           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpIsDevicePtrClause::pools.begin();
   64347           0 :      SgOmpIsDevicePtrClause* pointer = NULL;
   64348           0 :      while ( block != SgOmpIsDevicePtrClause::pools.end() ) {
   64349           0 :           pointer = (SgOmpIsDevicePtrClause*) (*block);
   64350           0 :           for ( unsigned i = 0; i < SgOmpIsDevicePtrClause::pool_size; ++i ) {
   64351           0 :                if ( pointer->get_freepointer() != NULL ) {
   64352           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   64353           0 :                  storageArray++;
   64354           0 :                  storageCounter++;
   64355             :                }
   64356           0 :                pointer++;
   64357             :              }
   64358           0 :            block++;
   64359             :         }
   64360           0 :      return storageCounter;
   64361             :    }
   64362             : 
   64363             : /* #line 64364 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   64364             : 
   64365             : 
   64366             : 
   64367             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   64368             : 
   64369             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   64370             : 
   64371             : //############################################################################
   64372             : /* JH (02/02/2006) Constructor of the IR node SgOmpUseDevicePtrClause that takes its 
   64373             :  * corresponding StorageClass as parameter
   64374             :  */
   64375           0 : SgOmpUseDevicePtrClause :: SgOmpUseDevicePtrClause ( const SgOmpUseDevicePtrClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   64376             :    {
   64377             : 
   64378             : 
   64379             : /* #line 64380 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   64380             : 
   64381           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   64382             : 
   64383             : 
   64384             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   64385             : 
   64386             : 
   64387           0 :    }
   64388             : 
   64389             : //############################################################################
   64390             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   64391             :  * within the working AST. 
   64392             :  */
   64393           0 : SgOmpUseDevicePtrClause * SgOmpUseDevicePtrClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   64394           0 :      SgOmpUseDevicePtrClause* returnPointer = NULL;
   64395           0 :      if ( globalIndex != 0 )
   64396             :         {
   64397             : 
   64398             : #if FILE_IO_EXTRA_CHECK
   64399           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUseDevicePtrClause ) ) <= globalIndex ) ;
   64400           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUseDevicePtrClause + 1 ) ) );
   64401             : #endif
   64402           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUseDevicePtrClause )  
   64403           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUseDevicePtrClause );
   64404           0 :           unsigned long positionInPool = localIndex % SgOmpUseDevicePtrClause::pool_size;
   64405           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUseDevicePtrClause::pool_size;
   64406             : 
   64407             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   64408             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   64409             : 
   64410           0 :           returnPointer = &( ( (SgOmpUseDevicePtrClause*)(SgOmpUseDevicePtrClause::pools[memoryBlock]) ) [positionInPool]) ;
   64411             : 
   64412           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   64413             :         }
   64414           0 :      return returnPointer ;
   64415             :    }
   64416             : 
   64417             : //############################################################################
   64418             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   64419             :   for the AST with the index astIndex
   64420             : */
   64421           0 : SgOmpUseDevicePtrClause * SgOmpUseDevicePtrClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   64422           0 :      SgOmpUseDevicePtrClause* returnPointer = NULL;
   64423           0 :      if ( globalIndex != 0 )
   64424             :         {
   64425             : 
   64426             : #if FILE_IO_EXTRA_CHECK
   64427           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUseDevicePtrClause ) ) <= globalIndex ) ;
   64428           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUseDevicePtrClause + 1 ) ) );
   64429             : #endif
   64430           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUseDevicePtrClause )
   64431           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUseDevicePtrClause );
   64432           0 :           unsigned long positionInPool = localIndex % SgOmpUseDevicePtrClause::pool_size ;
   64433           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUseDevicePtrClause::pool_size ;
   64434             : 
   64435             : #if FILE_IO_EXTRA_CHECK
   64436             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   64437             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   64438             : #endif
   64439             : 
   64440           0 :           returnPointer = &( ( (SgOmpUseDevicePtrClause*)(SgOmpUseDevicePtrClause::pools[memoryBlock]) ) [positionInPool]) ;
   64441             : 
   64442             : #if FILE_IO_EXTRA_CHECK
   64443           0 :           assert ( returnPointer != NULL ) ;
   64444             : #endif
   64445             :         }
   64446           0 :      return returnPointer ;
   64447             :    }
   64448             : 
   64449             : //############################################################################
   64450             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   64451             :  * pool size! We set for every valid object in the memory pool the freepointer
   64452             :  * to the global index and increase the global index afterwards. For all the 
   64453             :  * invalid objects (means address ranges within the memory pool that were not
   64454             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   64455             :  * distinguish valid from invalid objects! 
   64456             :  */
   64457             : unsigned long
   64458           5 : SgOmpUseDevicePtrClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   64459             :    {
   64460           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   64461           5 :      SgOmpUseDevicePtrClause* pointer = NULL;
   64462           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   64463           5 :      std::vector < unsigned char* > :: const_iterator block;
   64464           5 :      for ( block = SgOmpUseDevicePtrClause::pools.begin(); block != SgOmpUseDevicePtrClause::pools.end() ; ++block )
   64465             :         {
   64466           0 :           pointer = (SgOmpUseDevicePtrClause*)(*block);
   64467           0 :           for (unsigned i = 0; i < SgOmpUseDevicePtrClause::pool_size; ++i )
   64468             :              {
   64469             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   64470             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   64471             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   64472             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   64473             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   64474             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   64475             :             // properly; so this will have to be checked next.
   64476             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   64477             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   64478           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   64479             :                   {
   64480           0 :                     pointer[i].set_freepointer((SgOmpUseDevicePtrClause*)(globalIndex));
   64481           0 :                     globalIndex++;
   64482             :                   }
   64483             :                else
   64484             :                   {
   64485           0 :                     pointer[i].set_freepointer(NULL);
   64486             :                   }
   64487             :               }
   64488             :         }
   64489           5 :      return globalIndex;
   64490             :    }
   64491             : 
   64492             : //############################################################################
   64493             : // JH (01/14/2006)
   64494             : void
   64495           5 : SgOmpUseDevicePtrClause::resetValidFreepointers( )
   64496             :    {
   64497           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   64498           5 :      SgOmpUseDevicePtrClause* pointer = NULL;
   64499           5 :      std::vector < unsigned char* > :: const_iterator block;
   64500           5 :      SgOmpUseDevicePtrClause* pointerOfLinkedList = NULL;
   64501           5 :      for ( block = SgOmpUseDevicePtrClause::pools.begin(); block != SgOmpUseDevicePtrClause::pools.end() ; ++block )
   64502             :         {
   64503           0 :           pointer = (SgOmpUseDevicePtrClause*)(*block);
   64504           0 :           for (unsigned i = 0; i < SgOmpUseDevicePtrClause::pool_size; ++i )
   64505             :              {
   64506             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   64507             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   64508             :             // memory blocks!.
   64509           0 :                if ( pointer[i].get_freepointer() != NULL )
   64510             :                   {
   64511           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   64512             :                   }
   64513             :                else
   64514             :                   {
   64515           0 :                     if ( pointerOfLinkedList == NULL )
   64516             :                        {
   64517           0 :                          SgOmpUseDevicePtrClause::next_node = &(pointer[i]);
   64518             :                        }
   64519             :                     else
   64520             :                        {
   64521             :                       // printf ("In SgOmpUseDevicePtrClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   64522           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   64523             :                        }
   64524             :                     pointerOfLinkedList = &(pointer[i]);
   64525             :                   }
   64526             :               }
   64527             :         }
   64528             : 
   64529           5 :      if ( pointerOfLinkedList != NULL )
   64530             :         {
   64531             :        // printf ("In SgOmpUseDevicePtrClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   64532           0 :           pointerOfLinkedList->set_freepointer(NULL);
   64533             :        // DQ (6/6/2010): Temporary debugging...
   64534             :        //   ROSE_ASSERT(false);
   64535             :         }
   64536             : 
   64537           5 :      return ;
   64538             :    }
   64539             : 
   64540             : //############################################################################
   64541             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   64542             :  * within the memory pool and resets the freepointers, in order to achieve a 
   64543             :  * linked list, that has no jumps and starts at the beginning! This function 
   64544             :  * does not extend the memory pool, since we do not delete any memory blocks,
   64545             :  * but delete the valid objects.  
   64546             :  */
   64547             : void
   64548           0 : SgOmpUseDevicePtrClause::clearMemoryPool( )
   64549             :    {
   64550             :   // printf ("Inside of SgOmpUseDevicePtrClause::clearMemoryPool() \n");
   64551             : 
   64552           0 :      SgOmpUseDevicePtrClause* pointer = NULL, *tempPointer = NULL;
   64553           0 :      std::vector < unsigned char* > :: const_iterator block;
   64554           0 :      if ( SgOmpUseDevicePtrClause::pools.empty() == false )
   64555             :         {
   64556           0 :           block = SgOmpUseDevicePtrClause::pools.begin() ;
   64557           0 :           SgOmpUseDevicePtrClause::next_node = (SgOmpUseDevicePtrClause*) (*block);
   64558             : 
   64559           0 :           while ( block != SgOmpUseDevicePtrClause::pools.end() )
   64560             :              {
   64561           0 :                pointer = (SgOmpUseDevicePtrClause*) (*block);
   64562           0 :                if ( tempPointer != NULL )
   64563             :                   {
   64564           0 :                     tempPointer->set_freepointer(pointer);
   64565             :                   }
   64566           0 :                for (unsigned i = 0; i < SgOmpUseDevicePtrClause::pool_size - 1; ++i)
   64567             :                   {
   64568           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   64569             :                   }
   64570           0 :                 pointer[SgOmpUseDevicePtrClause::pool_size-1].set_freepointer(NULL);
   64571           0 :                 tempPointer = &(pointer[SgOmpUseDevicePtrClause::pool_size-1]);
   64572           0 :                 ++block;
   64573             :              }
   64574             :         }
   64575           0 :    }
   64576             : 
   64577           5 : void SgOmpUseDevicePtrClause::deleteMemoryPool() {
   64578           5 :   for (auto p: SgOmpUseDevicePtrClause::pools) {
   64579           0 :     ROSE_FREE(p);
   64580             :   }
   64581           5 :   SgOmpUseDevicePtrClause::next_node = nullptr;
   64582           5 :   SgOmpUseDevicePtrClause::pools.clear();
   64583           5 : }
   64584             : 
   64585             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   64586             : //                 reading multiple binary files to for a single AST.
   64587             : /////////// new version ////////////////////////////////
   64588             : //############################################################################
   64589             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   64590             : void
   64591           2 : SgOmpUseDevicePtrClause::extendMemoryPoolForFileIO( )
   64592             :   {
   64593           2 :     size_t blockIndex = SgOmpUseDevicePtrClause::pools.size();
   64594           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUseDevicePtrClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUseDevicePtrClause);
   64595             : 
   64596           2 :     while ( (blockIndex * SgOmpUseDevicePtrClause::pool_size) < newPoolSize)
   64597             :       {
   64598             : #if ROSE_ALLOC_TRACE
   64599             :         if (blockIndex > 0) {
   64600             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUseDevicePtrClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUseDevicePtrClause) = %" PRIuPTR " SgOmpUseDevicePtrClause::pool_size = %d \n",
   64601             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUseDevicePtrClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUseDevicePtrClause),SgOmpUseDevicePtrClause::pool_size);
   64602             :         }
   64603             : #endif
   64604             : 
   64605           0 :         SgOmpUseDevicePtrClause * pointer = (SgOmpUseDevicePtrClause*) ROSE_MALLOC ( SgOmpUseDevicePtrClause::pool_size * sizeof(SgOmpUseDevicePtrClause) );
   64606           0 :         assert( pointer != NULL );
   64607             : #if ROSE_ALLOC_MEMSET == 1
   64608             :         memset(pointer, 0x00, SgOmpUseDevicePtrClause::pool_size * sizeof(SgOmpUseDevicePtrClause));
   64609             : #elif ROSE_ALLOC_MEMSET == 2
   64610             :         memset(pointer, 0xCC, SgOmpUseDevicePtrClause::pool_size * sizeof(SgOmpUseDevicePtrClause));
   64611             : #endif
   64612           0 :         SgOmpUseDevicePtrClause::pools.push_back( (unsigned char*)(pointer) );
   64613           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUseDevicePtrClause::pool_size * sizeof(SgOmpUseDevicePtrClause), V_SgOmpUseDevicePtrClause ) );
   64614             : 
   64615           0 :         if ( SgOmpUseDevicePtrClause::next_node != NULL ) {
   64616           0 :           if ( blockIndex > 0 ) {
   64617           0 :             SgOmpUseDevicePtrClause * blkptr = (SgOmpUseDevicePtrClause*)(SgOmpUseDevicePtrClause::pools[blockIndex-1]);
   64618           0 :             blkptr[ SgOmpUseDevicePtrClause::pool_size - 1 ].set_freepointer(pointer);
   64619             :           }
   64620             :         } else {
   64621           0 :           SgOmpUseDevicePtrClause::next_node = pointer;
   64622             :         }
   64623             : 
   64624           0 :         for (unsigned i = 0; i < SgOmpUseDevicePtrClause::pool_size-1; ++i)
   64625             :            {
   64626           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   64627             :            }
   64628           0 :         pointer[ SgOmpUseDevicePtrClause::pool_size -1 ].set_freepointer(NULL);
   64629             : 
   64630           0 :         blockIndex++;
   64631             :       }
   64632           2 :   }
   64633             : 
   64634             : //############################################################################
   64635             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   64636             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   64637             :  * not compressed. However, that stuff is not yet implemented! 
   64638             :  */
   64639             : unsigned long
   64640           0 : SgOmpUseDevicePtrClause::getNumberOfLastValidPointer()
   64641             :    {
   64642           0 :       SgOmpUseDevicePtrClause* testPointer = (SgOmpUseDevicePtrClause*)(SgOmpUseDevicePtrClause::pools.back());
   64643           0 :       unsigned long localIndex = SgOmpUseDevicePtrClause::pool_size - 1;
   64644           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   64645             :          {
   64646           0 :            localIndex--;
   64647             :          }
   64648           0 :       return (localIndex + SgOmpUseDevicePtrClause::pool_size * (SgOmpUseDevicePtrClause::pools.size()-1));
   64649             :    }
   64650             : 
   64651             : //############################################################################
   64652             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   64653             :  * memory pool and initializes the data member in class SgOmpUseDevicePtrClauseStroageClass
   64654             :  * from its counterpart of SgOmpUseDevicePtrClause. The return value is just for checking, 
   64655             :  * that the whole StorageClassArray is initialized!
   64656             :  */
   64657             : unsigned long
   64658           0 : SgOmpUseDevicePtrClause::initializeStorageClassArray( SgOmpUseDevicePtrClauseStorageClass *storageArray )
   64659             :    {
   64660           0 :      unsigned long storageCounter = 0;
   64661           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUseDevicePtrClause::pools.begin();
   64662           0 :      SgOmpUseDevicePtrClause* pointer = NULL;
   64663           0 :      while ( block != SgOmpUseDevicePtrClause::pools.end() ) {
   64664           0 :           pointer = (SgOmpUseDevicePtrClause*) (*block);
   64665           0 :           for ( unsigned i = 0; i < SgOmpUseDevicePtrClause::pool_size; ++i ) {
   64666           0 :                if ( pointer->get_freepointer() != NULL ) {
   64667           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   64668           0 :                  storageArray++;
   64669           0 :                  storageCounter++;
   64670             :                }
   64671           0 :                pointer++;
   64672             :              }
   64673           0 :            block++;
   64674             :         }
   64675           0 :      return storageCounter;
   64676             :    }
   64677             : 
   64678             : /* #line 64679 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   64679             : 
   64680             : 
   64681             : 
   64682             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   64683             : 
   64684             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   64685             : 
   64686             : //############################################################################
   64687             : /* JH (02/02/2006) Constructor of the IR node SgOmpUseDeviceAddrClause that takes its 
   64688             :  * corresponding StorageClass as parameter
   64689             :  */
   64690           0 : SgOmpUseDeviceAddrClause :: SgOmpUseDeviceAddrClause ( const SgOmpUseDeviceAddrClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   64691             :    {
   64692             : 
   64693             : 
   64694             : /* #line 64695 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   64695             : 
   64696           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   64697             : 
   64698             : 
   64699             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   64700             : 
   64701             : 
   64702           0 :    }
   64703             : 
   64704             : //############################################################################
   64705             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   64706             :  * within the working AST. 
   64707             :  */
   64708           0 : SgOmpUseDeviceAddrClause * SgOmpUseDeviceAddrClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   64709           0 :      SgOmpUseDeviceAddrClause* returnPointer = NULL;
   64710           0 :      if ( globalIndex != 0 )
   64711             :         {
   64712             : 
   64713             : #if FILE_IO_EXTRA_CHECK
   64714           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUseDeviceAddrClause ) ) <= globalIndex ) ;
   64715           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUseDeviceAddrClause + 1 ) ) );
   64716             : #endif
   64717           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUseDeviceAddrClause )  
   64718           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUseDeviceAddrClause );
   64719           0 :           unsigned long positionInPool = localIndex % SgOmpUseDeviceAddrClause::pool_size;
   64720           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUseDeviceAddrClause::pool_size;
   64721             : 
   64722             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   64723             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   64724             : 
   64725           0 :           returnPointer = &( ( (SgOmpUseDeviceAddrClause*)(SgOmpUseDeviceAddrClause::pools[memoryBlock]) ) [positionInPool]) ;
   64726             : 
   64727           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   64728             :         }
   64729           0 :      return returnPointer ;
   64730             :    }
   64731             : 
   64732             : //############################################################################
   64733             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   64734             :   for the AST with the index astIndex
   64735             : */
   64736           0 : SgOmpUseDeviceAddrClause * SgOmpUseDeviceAddrClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   64737           0 :      SgOmpUseDeviceAddrClause* returnPointer = NULL;
   64738           0 :      if ( globalIndex != 0 )
   64739             :         {
   64740             : 
   64741             : #if FILE_IO_EXTRA_CHECK
   64742           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUseDeviceAddrClause ) ) <= globalIndex ) ;
   64743           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUseDeviceAddrClause + 1 ) ) );
   64744             : #endif
   64745           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUseDeviceAddrClause )
   64746           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUseDeviceAddrClause );
   64747           0 :           unsigned long positionInPool = localIndex % SgOmpUseDeviceAddrClause::pool_size ;
   64748           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUseDeviceAddrClause::pool_size ;
   64749             : 
   64750             : #if FILE_IO_EXTRA_CHECK
   64751             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   64752             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   64753             : #endif
   64754             : 
   64755           0 :           returnPointer = &( ( (SgOmpUseDeviceAddrClause*)(SgOmpUseDeviceAddrClause::pools[memoryBlock]) ) [positionInPool]) ;
   64756             : 
   64757             : #if FILE_IO_EXTRA_CHECK
   64758           0 :           assert ( returnPointer != NULL ) ;
   64759             : #endif
   64760             :         }
   64761           0 :      return returnPointer ;
   64762             :    }
   64763             : 
   64764             : //############################################################################
   64765             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   64766             :  * pool size! We set for every valid object in the memory pool the freepointer
   64767             :  * to the global index and increase the global index afterwards. For all the 
   64768             :  * invalid objects (means address ranges within the memory pool that were not
   64769             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   64770             :  * distinguish valid from invalid objects! 
   64771             :  */
   64772             : unsigned long
   64773           5 : SgOmpUseDeviceAddrClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   64774             :    {
   64775           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   64776           5 :      SgOmpUseDeviceAddrClause* pointer = NULL;
   64777           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   64778           5 :      std::vector < unsigned char* > :: const_iterator block;
   64779           5 :      for ( block = SgOmpUseDeviceAddrClause::pools.begin(); block != SgOmpUseDeviceAddrClause::pools.end() ; ++block )
   64780             :         {
   64781           0 :           pointer = (SgOmpUseDeviceAddrClause*)(*block);
   64782           0 :           for (unsigned i = 0; i < SgOmpUseDeviceAddrClause::pool_size; ++i )
   64783             :              {
   64784             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   64785             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   64786             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   64787             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   64788             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   64789             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   64790             :             // properly; so this will have to be checked next.
   64791             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   64792             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   64793           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   64794             :                   {
   64795           0 :                     pointer[i].set_freepointer((SgOmpUseDeviceAddrClause*)(globalIndex));
   64796           0 :                     globalIndex++;
   64797             :                   }
   64798             :                else
   64799             :                   {
   64800           0 :                     pointer[i].set_freepointer(NULL);
   64801             :                   }
   64802             :               }
   64803             :         }
   64804           5 :      return globalIndex;
   64805             :    }
   64806             : 
   64807             : //############################################################################
   64808             : // JH (01/14/2006)
   64809             : void
   64810           5 : SgOmpUseDeviceAddrClause::resetValidFreepointers( )
   64811             :    {
   64812           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   64813           5 :      SgOmpUseDeviceAddrClause* pointer = NULL;
   64814           5 :      std::vector < unsigned char* > :: const_iterator block;
   64815           5 :      SgOmpUseDeviceAddrClause* pointerOfLinkedList = NULL;
   64816           5 :      for ( block = SgOmpUseDeviceAddrClause::pools.begin(); block != SgOmpUseDeviceAddrClause::pools.end() ; ++block )
   64817             :         {
   64818           0 :           pointer = (SgOmpUseDeviceAddrClause*)(*block);
   64819           0 :           for (unsigned i = 0; i < SgOmpUseDeviceAddrClause::pool_size; ++i )
   64820             :              {
   64821             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   64822             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   64823             :             // memory blocks!.
   64824           0 :                if ( pointer[i].get_freepointer() != NULL )
   64825             :                   {
   64826           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   64827             :                   }
   64828             :                else
   64829             :                   {
   64830           0 :                     if ( pointerOfLinkedList == NULL )
   64831             :                        {
   64832           0 :                          SgOmpUseDeviceAddrClause::next_node = &(pointer[i]);
   64833             :                        }
   64834             :                     else
   64835             :                        {
   64836             :                       // printf ("In SgOmpUseDeviceAddrClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   64837           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   64838             :                        }
   64839             :                     pointerOfLinkedList = &(pointer[i]);
   64840             :                   }
   64841             :               }
   64842             :         }
   64843             : 
   64844           5 :      if ( pointerOfLinkedList != NULL )
   64845             :         {
   64846             :        // printf ("In SgOmpUseDeviceAddrClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   64847           0 :           pointerOfLinkedList->set_freepointer(NULL);
   64848             :        // DQ (6/6/2010): Temporary debugging...
   64849             :        //   ROSE_ASSERT(false);
   64850             :         }
   64851             : 
   64852           5 :      return ;
   64853             :    }
   64854             : 
   64855             : //############################################################################
   64856             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   64857             :  * within the memory pool and resets the freepointers, in order to achieve a 
   64858             :  * linked list, that has no jumps and starts at the beginning! This function 
   64859             :  * does not extend the memory pool, since we do not delete any memory blocks,
   64860             :  * but delete the valid objects.  
   64861             :  */
   64862             : void
   64863           0 : SgOmpUseDeviceAddrClause::clearMemoryPool( )
   64864             :    {
   64865             :   // printf ("Inside of SgOmpUseDeviceAddrClause::clearMemoryPool() \n");
   64866             : 
   64867           0 :      SgOmpUseDeviceAddrClause* pointer = NULL, *tempPointer = NULL;
   64868           0 :      std::vector < unsigned char* > :: const_iterator block;
   64869           0 :      if ( SgOmpUseDeviceAddrClause::pools.empty() == false )
   64870             :         {
   64871           0 :           block = SgOmpUseDeviceAddrClause::pools.begin() ;
   64872           0 :           SgOmpUseDeviceAddrClause::next_node = (SgOmpUseDeviceAddrClause*) (*block);
   64873             : 
   64874           0 :           while ( block != SgOmpUseDeviceAddrClause::pools.end() )
   64875             :              {
   64876           0 :                pointer = (SgOmpUseDeviceAddrClause*) (*block);
   64877           0 :                if ( tempPointer != NULL )
   64878             :                   {
   64879           0 :                     tempPointer->set_freepointer(pointer);
   64880             :                   }
   64881           0 :                for (unsigned i = 0; i < SgOmpUseDeviceAddrClause::pool_size - 1; ++i)
   64882             :                   {
   64883           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   64884             :                   }
   64885           0 :                 pointer[SgOmpUseDeviceAddrClause::pool_size-1].set_freepointer(NULL);
   64886           0 :                 tempPointer = &(pointer[SgOmpUseDeviceAddrClause::pool_size-1]);
   64887           0 :                 ++block;
   64888             :              }
   64889             :         }
   64890           0 :    }
   64891             : 
   64892           5 : void SgOmpUseDeviceAddrClause::deleteMemoryPool() {
   64893           5 :   for (auto p: SgOmpUseDeviceAddrClause::pools) {
   64894           0 :     ROSE_FREE(p);
   64895             :   }
   64896           5 :   SgOmpUseDeviceAddrClause::next_node = nullptr;
   64897           5 :   SgOmpUseDeviceAddrClause::pools.clear();
   64898           5 : }
   64899             : 
   64900             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   64901             : //                 reading multiple binary files to for a single AST.
   64902             : /////////// new version ////////////////////////////////
   64903             : //############################################################################
   64904             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   64905             : void
   64906           2 : SgOmpUseDeviceAddrClause::extendMemoryPoolForFileIO( )
   64907             :   {
   64908           2 :     size_t blockIndex = SgOmpUseDeviceAddrClause::pools.size();
   64909           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUseDeviceAddrClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUseDeviceAddrClause);
   64910             : 
   64911           2 :     while ( (blockIndex * SgOmpUseDeviceAddrClause::pool_size) < newPoolSize)
   64912             :       {
   64913             : #if ROSE_ALLOC_TRACE
   64914             :         if (blockIndex > 0) {
   64915             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUseDeviceAddrClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUseDeviceAddrClause) = %" PRIuPTR " SgOmpUseDeviceAddrClause::pool_size = %d \n",
   64916             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUseDeviceAddrClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUseDeviceAddrClause),SgOmpUseDeviceAddrClause::pool_size);
   64917             :         }
   64918             : #endif
   64919             : 
   64920           0 :         SgOmpUseDeviceAddrClause * pointer = (SgOmpUseDeviceAddrClause*) ROSE_MALLOC ( SgOmpUseDeviceAddrClause::pool_size * sizeof(SgOmpUseDeviceAddrClause) );
   64921           0 :         assert( pointer != NULL );
   64922             : #if ROSE_ALLOC_MEMSET == 1
   64923             :         memset(pointer, 0x00, SgOmpUseDeviceAddrClause::pool_size * sizeof(SgOmpUseDeviceAddrClause));
   64924             : #elif ROSE_ALLOC_MEMSET == 2
   64925             :         memset(pointer, 0xCC, SgOmpUseDeviceAddrClause::pool_size * sizeof(SgOmpUseDeviceAddrClause));
   64926             : #endif
   64927           0 :         SgOmpUseDeviceAddrClause::pools.push_back( (unsigned char*)(pointer) );
   64928           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUseDeviceAddrClause::pool_size * sizeof(SgOmpUseDeviceAddrClause), V_SgOmpUseDeviceAddrClause ) );
   64929             : 
   64930           0 :         if ( SgOmpUseDeviceAddrClause::next_node != NULL ) {
   64931           0 :           if ( blockIndex > 0 ) {
   64932           0 :             SgOmpUseDeviceAddrClause * blkptr = (SgOmpUseDeviceAddrClause*)(SgOmpUseDeviceAddrClause::pools[blockIndex-1]);
   64933           0 :             blkptr[ SgOmpUseDeviceAddrClause::pool_size - 1 ].set_freepointer(pointer);
   64934             :           }
   64935             :         } else {
   64936           0 :           SgOmpUseDeviceAddrClause::next_node = pointer;
   64937             :         }
   64938             : 
   64939           0 :         for (unsigned i = 0; i < SgOmpUseDeviceAddrClause::pool_size-1; ++i)
   64940             :            {
   64941           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   64942             :            }
   64943           0 :         pointer[ SgOmpUseDeviceAddrClause::pool_size -1 ].set_freepointer(NULL);
   64944             : 
   64945           0 :         blockIndex++;
   64946             :       }
   64947           2 :   }
   64948             : 
   64949             : //############################################################################
   64950             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   64951             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   64952             :  * not compressed. However, that stuff is not yet implemented! 
   64953             :  */
   64954             : unsigned long
   64955           0 : SgOmpUseDeviceAddrClause::getNumberOfLastValidPointer()
   64956             :    {
   64957           0 :       SgOmpUseDeviceAddrClause* testPointer = (SgOmpUseDeviceAddrClause*)(SgOmpUseDeviceAddrClause::pools.back());
   64958           0 :       unsigned long localIndex = SgOmpUseDeviceAddrClause::pool_size - 1;
   64959           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   64960             :          {
   64961           0 :            localIndex--;
   64962             :          }
   64963           0 :       return (localIndex + SgOmpUseDeviceAddrClause::pool_size * (SgOmpUseDeviceAddrClause::pools.size()-1));
   64964             :    }
   64965             : 
   64966             : //############################################################################
   64967             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   64968             :  * memory pool and initializes the data member in class SgOmpUseDeviceAddrClauseStroageClass
   64969             :  * from its counterpart of SgOmpUseDeviceAddrClause. The return value is just for checking, 
   64970             :  * that the whole StorageClassArray is initialized!
   64971             :  */
   64972             : unsigned long
   64973           0 : SgOmpUseDeviceAddrClause::initializeStorageClassArray( SgOmpUseDeviceAddrClauseStorageClass *storageArray )
   64974             :    {
   64975           0 :      unsigned long storageCounter = 0;
   64976           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUseDeviceAddrClause::pools.begin();
   64977           0 :      SgOmpUseDeviceAddrClause* pointer = NULL;
   64978           0 :      while ( block != SgOmpUseDeviceAddrClause::pools.end() ) {
   64979           0 :           pointer = (SgOmpUseDeviceAddrClause*) (*block);
   64980           0 :           for ( unsigned i = 0; i < SgOmpUseDeviceAddrClause::pool_size; ++i ) {
   64981           0 :                if ( pointer->get_freepointer() != NULL ) {
   64982           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   64983           0 :                  storageArray++;
   64984           0 :                  storageCounter++;
   64985             :                }
   64986           0 :                pointer++;
   64987             :              }
   64988           0 :            block++;
   64989             :         }
   64990           0 :      return storageCounter;
   64991             :    }
   64992             : 
   64993             : /* #line 64994 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   64994             : 
   64995             : 
   64996             : 
   64997             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   64998             : 
   64999             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   65000             : 
   65001             : //############################################################################
   65002             : /* JH (02/02/2006) Constructor of the IR node SgOmpSharedClause that takes its 
   65003             :  * corresponding StorageClass as parameter
   65004             :  */
   65005           0 : SgOmpSharedClause :: SgOmpSharedClause ( const SgOmpSharedClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   65006             :    {
   65007             : 
   65008             : 
   65009             : /* #line 65010 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   65010             : 
   65011           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   65012             : 
   65013             : 
   65014             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   65015             : 
   65016             : 
   65017           0 :    }
   65018             : 
   65019             : //############################################################################
   65020             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   65021             :  * within the working AST. 
   65022             :  */
   65023           0 : SgOmpSharedClause * SgOmpSharedClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   65024           0 :      SgOmpSharedClause* returnPointer = NULL;
   65025           0 :      if ( globalIndex != 0 )
   65026             :         {
   65027             : 
   65028             : #if FILE_IO_EXTRA_CHECK
   65029           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSharedClause ) ) <= globalIndex ) ;
   65030           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSharedClause + 1 ) ) );
   65031             : #endif
   65032           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSharedClause )  
   65033           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSharedClause );
   65034           0 :           unsigned long positionInPool = localIndex % SgOmpSharedClause::pool_size;
   65035           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSharedClause::pool_size;
   65036             : 
   65037             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   65038             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   65039             : 
   65040           0 :           returnPointer = &( ( (SgOmpSharedClause*)(SgOmpSharedClause::pools[memoryBlock]) ) [positionInPool]) ;
   65041             : 
   65042           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   65043             :         }
   65044           0 :      return returnPointer ;
   65045             :    }
   65046             : 
   65047             : //############################################################################
   65048             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   65049             :   for the AST with the index astIndex
   65050             : */
   65051           0 : SgOmpSharedClause * SgOmpSharedClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   65052           0 :      SgOmpSharedClause* returnPointer = NULL;
   65053           0 :      if ( globalIndex != 0 )
   65054             :         {
   65055             : 
   65056             : #if FILE_IO_EXTRA_CHECK
   65057           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSharedClause ) ) <= globalIndex ) ;
   65058           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSharedClause + 1 ) ) );
   65059             : #endif
   65060           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSharedClause )
   65061           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSharedClause );
   65062           0 :           unsigned long positionInPool = localIndex % SgOmpSharedClause::pool_size ;
   65063           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSharedClause::pool_size ;
   65064             : 
   65065             : #if FILE_IO_EXTRA_CHECK
   65066             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   65067             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   65068             : #endif
   65069             : 
   65070           0 :           returnPointer = &( ( (SgOmpSharedClause*)(SgOmpSharedClause::pools[memoryBlock]) ) [positionInPool]) ;
   65071             : 
   65072             : #if FILE_IO_EXTRA_CHECK
   65073           0 :           assert ( returnPointer != NULL ) ;
   65074             : #endif
   65075             :         }
   65076           0 :      return returnPointer ;
   65077             :    }
   65078             : 
   65079             : //############################################################################
   65080             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   65081             :  * pool size! We set for every valid object in the memory pool the freepointer
   65082             :  * to the global index and increase the global index afterwards. For all the 
   65083             :  * invalid objects (means address ranges within the memory pool that were not
   65084             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   65085             :  * distinguish valid from invalid objects! 
   65086             :  */
   65087             : unsigned long
   65088           5 : SgOmpSharedClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   65089             :    {
   65090           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   65091           5 :      SgOmpSharedClause* pointer = NULL;
   65092           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   65093           5 :      std::vector < unsigned char* > :: const_iterator block;
   65094           5 :      for ( block = SgOmpSharedClause::pools.begin(); block != SgOmpSharedClause::pools.end() ; ++block )
   65095             :         {
   65096           0 :           pointer = (SgOmpSharedClause*)(*block);
   65097           0 :           for (unsigned i = 0; i < SgOmpSharedClause::pool_size; ++i )
   65098             :              {
   65099             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   65100             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   65101             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   65102             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   65103             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   65104             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   65105             :             // properly; so this will have to be checked next.
   65106             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   65107             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   65108           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   65109             :                   {
   65110           0 :                     pointer[i].set_freepointer((SgOmpSharedClause*)(globalIndex));
   65111           0 :                     globalIndex++;
   65112             :                   }
   65113             :                else
   65114             :                   {
   65115           0 :                     pointer[i].set_freepointer(NULL);
   65116             :                   }
   65117             :               }
   65118             :         }
   65119           5 :      return globalIndex;
   65120             :    }
   65121             : 
   65122             : //############################################################################
   65123             : // JH (01/14/2006)
   65124             : void
   65125           5 : SgOmpSharedClause::resetValidFreepointers( )
   65126             :    {
   65127           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   65128           5 :      SgOmpSharedClause* pointer = NULL;
   65129           5 :      std::vector < unsigned char* > :: const_iterator block;
   65130           5 :      SgOmpSharedClause* pointerOfLinkedList = NULL;
   65131           5 :      for ( block = SgOmpSharedClause::pools.begin(); block != SgOmpSharedClause::pools.end() ; ++block )
   65132             :         {
   65133           0 :           pointer = (SgOmpSharedClause*)(*block);
   65134           0 :           for (unsigned i = 0; i < SgOmpSharedClause::pool_size; ++i )
   65135             :              {
   65136             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   65137             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   65138             :             // memory blocks!.
   65139           0 :                if ( pointer[i].get_freepointer() != NULL )
   65140             :                   {
   65141           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   65142             :                   }
   65143             :                else
   65144             :                   {
   65145           0 :                     if ( pointerOfLinkedList == NULL )
   65146             :                        {
   65147           0 :                          SgOmpSharedClause::next_node = &(pointer[i]);
   65148             :                        }
   65149             :                     else
   65150             :                        {
   65151             :                       // printf ("In SgOmpSharedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   65152           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   65153             :                        }
   65154             :                     pointerOfLinkedList = &(pointer[i]);
   65155             :                   }
   65156             :               }
   65157             :         }
   65158             : 
   65159           5 :      if ( pointerOfLinkedList != NULL )
   65160             :         {
   65161             :        // printf ("In SgOmpSharedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   65162           0 :           pointerOfLinkedList->set_freepointer(NULL);
   65163             :        // DQ (6/6/2010): Temporary debugging...
   65164             :        //   ROSE_ASSERT(false);
   65165             :         }
   65166             : 
   65167           5 :      return ;
   65168             :    }
   65169             : 
   65170             : //############################################################################
   65171             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   65172             :  * within the memory pool and resets the freepointers, in order to achieve a 
   65173             :  * linked list, that has no jumps and starts at the beginning! This function 
   65174             :  * does not extend the memory pool, since we do not delete any memory blocks,
   65175             :  * but delete the valid objects.  
   65176             :  */
   65177             : void
   65178           0 : SgOmpSharedClause::clearMemoryPool( )
   65179             :    {
   65180             :   // printf ("Inside of SgOmpSharedClause::clearMemoryPool() \n");
   65181             : 
   65182           0 :      SgOmpSharedClause* pointer = NULL, *tempPointer = NULL;
   65183           0 :      std::vector < unsigned char* > :: const_iterator block;
   65184           0 :      if ( SgOmpSharedClause::pools.empty() == false )
   65185             :         {
   65186           0 :           block = SgOmpSharedClause::pools.begin() ;
   65187           0 :           SgOmpSharedClause::next_node = (SgOmpSharedClause*) (*block);
   65188             : 
   65189           0 :           while ( block != SgOmpSharedClause::pools.end() )
   65190             :              {
   65191           0 :                pointer = (SgOmpSharedClause*) (*block);
   65192           0 :                if ( tempPointer != NULL )
   65193             :                   {
   65194           0 :                     tempPointer->set_freepointer(pointer);
   65195             :                   }
   65196           0 :                for (unsigned i = 0; i < SgOmpSharedClause::pool_size - 1; ++i)
   65197             :                   {
   65198           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   65199             :                   }
   65200           0 :                 pointer[SgOmpSharedClause::pool_size-1].set_freepointer(NULL);
   65201           0 :                 tempPointer = &(pointer[SgOmpSharedClause::pool_size-1]);
   65202           0 :                 ++block;
   65203             :              }
   65204             :         }
   65205           0 :    }
   65206             : 
   65207           5 : void SgOmpSharedClause::deleteMemoryPool() {
   65208           5 :   for (auto p: SgOmpSharedClause::pools) {
   65209           0 :     ROSE_FREE(p);
   65210             :   }
   65211           5 :   SgOmpSharedClause::next_node = nullptr;
   65212           5 :   SgOmpSharedClause::pools.clear();
   65213           5 : }
   65214             : 
   65215             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   65216             : //                 reading multiple binary files to for a single AST.
   65217             : /////////// new version ////////////////////////////////
   65218             : //############################################################################
   65219             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   65220             : void
   65221           2 : SgOmpSharedClause::extendMemoryPoolForFileIO( )
   65222             :   {
   65223           2 :     size_t blockIndex = SgOmpSharedClause::pools.size();
   65224           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSharedClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSharedClause);
   65225             : 
   65226           2 :     while ( (blockIndex * SgOmpSharedClause::pool_size) < newPoolSize)
   65227             :       {
   65228             : #if ROSE_ALLOC_TRACE
   65229             :         if (blockIndex > 0) {
   65230             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSharedClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSharedClause) = %" PRIuPTR " SgOmpSharedClause::pool_size = %d \n",
   65231             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSharedClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSharedClause),SgOmpSharedClause::pool_size);
   65232             :         }
   65233             : #endif
   65234             : 
   65235           0 :         SgOmpSharedClause * pointer = (SgOmpSharedClause*) ROSE_MALLOC ( SgOmpSharedClause::pool_size * sizeof(SgOmpSharedClause) );
   65236           0 :         assert( pointer != NULL );
   65237             : #if ROSE_ALLOC_MEMSET == 1
   65238             :         memset(pointer, 0x00, SgOmpSharedClause::pool_size * sizeof(SgOmpSharedClause));
   65239             : #elif ROSE_ALLOC_MEMSET == 2
   65240             :         memset(pointer, 0xCC, SgOmpSharedClause::pool_size * sizeof(SgOmpSharedClause));
   65241             : #endif
   65242           0 :         SgOmpSharedClause::pools.push_back( (unsigned char*)(pointer) );
   65243           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSharedClause::pool_size * sizeof(SgOmpSharedClause), V_SgOmpSharedClause ) );
   65244             : 
   65245           0 :         if ( SgOmpSharedClause::next_node != NULL ) {
   65246           0 :           if ( blockIndex > 0 ) {
   65247           0 :             SgOmpSharedClause * blkptr = (SgOmpSharedClause*)(SgOmpSharedClause::pools[blockIndex-1]);
   65248           0 :             blkptr[ SgOmpSharedClause::pool_size - 1 ].set_freepointer(pointer);
   65249             :           }
   65250             :         } else {
   65251           0 :           SgOmpSharedClause::next_node = pointer;
   65252             :         }
   65253             : 
   65254           0 :         for (unsigned i = 0; i < SgOmpSharedClause::pool_size-1; ++i)
   65255             :            {
   65256           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   65257             :            }
   65258           0 :         pointer[ SgOmpSharedClause::pool_size -1 ].set_freepointer(NULL);
   65259             : 
   65260           0 :         blockIndex++;
   65261             :       }
   65262           2 :   }
   65263             : 
   65264             : //############################################################################
   65265             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   65266             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   65267             :  * not compressed. However, that stuff is not yet implemented! 
   65268             :  */
   65269             : unsigned long
   65270           0 : SgOmpSharedClause::getNumberOfLastValidPointer()
   65271             :    {
   65272           0 :       SgOmpSharedClause* testPointer = (SgOmpSharedClause*)(SgOmpSharedClause::pools.back());
   65273           0 :       unsigned long localIndex = SgOmpSharedClause::pool_size - 1;
   65274           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   65275             :          {
   65276           0 :            localIndex--;
   65277             :          }
   65278           0 :       return (localIndex + SgOmpSharedClause::pool_size * (SgOmpSharedClause::pools.size()-1));
   65279             :    }
   65280             : 
   65281             : //############################################################################
   65282             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   65283             :  * memory pool and initializes the data member in class SgOmpSharedClauseStroageClass
   65284             :  * from its counterpart of SgOmpSharedClause. The return value is just for checking, 
   65285             :  * that the whole StorageClassArray is initialized!
   65286             :  */
   65287             : unsigned long
   65288           0 : SgOmpSharedClause::initializeStorageClassArray( SgOmpSharedClauseStorageClass *storageArray )
   65289             :    {
   65290           0 :      unsigned long storageCounter = 0;
   65291           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSharedClause::pools.begin();
   65292           0 :      SgOmpSharedClause* pointer = NULL;
   65293           0 :      while ( block != SgOmpSharedClause::pools.end() ) {
   65294           0 :           pointer = (SgOmpSharedClause*) (*block);
   65295           0 :           for ( unsigned i = 0; i < SgOmpSharedClause::pool_size; ++i ) {
   65296           0 :                if ( pointer->get_freepointer() != NULL ) {
   65297           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   65298           0 :                  storageArray++;
   65299           0 :                  storageCounter++;
   65300             :                }
   65301           0 :                pointer++;
   65302             :              }
   65303           0 :            block++;
   65304             :         }
   65305           0 :      return storageCounter;
   65306             :    }
   65307             : 
   65308             : /* #line 65309 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   65309             : 
   65310             : 
   65311             : 
   65312             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   65313             : 
   65314             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   65315             : 
   65316             : //############################################################################
   65317             : /* JH (02/02/2006) Constructor of the IR node SgOmpCopyinClause that takes its 
   65318             :  * corresponding StorageClass as parameter
   65319             :  */
   65320           0 : SgOmpCopyinClause :: SgOmpCopyinClause ( const SgOmpCopyinClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   65321             :    {
   65322             : 
   65323             : 
   65324             : /* #line 65325 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   65325             : 
   65326           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   65327             : 
   65328             : 
   65329             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   65330             : 
   65331             : 
   65332           0 :    }
   65333             : 
   65334             : //############################################################################
   65335             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   65336             :  * within the working AST. 
   65337             :  */
   65338           0 : SgOmpCopyinClause * SgOmpCopyinClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   65339           0 :      SgOmpCopyinClause* returnPointer = NULL;
   65340           0 :      if ( globalIndex != 0 )
   65341             :         {
   65342             : 
   65343             : #if FILE_IO_EXTRA_CHECK
   65344           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpCopyinClause ) ) <= globalIndex ) ;
   65345           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCopyinClause + 1 ) ) );
   65346             : #endif
   65347           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCopyinClause )  
   65348           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpCopyinClause );
   65349           0 :           unsigned long positionInPool = localIndex % SgOmpCopyinClause::pool_size;
   65350           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCopyinClause::pool_size;
   65351             : 
   65352             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   65353             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   65354             : 
   65355           0 :           returnPointer = &( ( (SgOmpCopyinClause*)(SgOmpCopyinClause::pools[memoryBlock]) ) [positionInPool]) ;
   65356             : 
   65357           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   65358             :         }
   65359           0 :      return returnPointer ;
   65360             :    }
   65361             : 
   65362             : //############################################################################
   65363             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   65364             :   for the AST with the index astIndex
   65365             : */
   65366           0 : SgOmpCopyinClause * SgOmpCopyinClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   65367           0 :      SgOmpCopyinClause* returnPointer = NULL;
   65368           0 :      if ( globalIndex != 0 )
   65369             :         {
   65370             : 
   65371             : #if FILE_IO_EXTRA_CHECK
   65372           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpCopyinClause ) ) <= globalIndex ) ;
   65373           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCopyinClause + 1 ) ) );
   65374             : #endif
   65375           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCopyinClause )
   65376           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpCopyinClause );
   65377           0 :           unsigned long positionInPool = localIndex % SgOmpCopyinClause::pool_size ;
   65378           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCopyinClause::pool_size ;
   65379             : 
   65380             : #if FILE_IO_EXTRA_CHECK
   65381             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   65382             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   65383             : #endif
   65384             : 
   65385           0 :           returnPointer = &( ( (SgOmpCopyinClause*)(SgOmpCopyinClause::pools[memoryBlock]) ) [positionInPool]) ;
   65386             : 
   65387             : #if FILE_IO_EXTRA_CHECK
   65388           0 :           assert ( returnPointer != NULL ) ;
   65389             : #endif
   65390             :         }
   65391           0 :      return returnPointer ;
   65392             :    }
   65393             : 
   65394             : //############################################################################
   65395             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   65396             :  * pool size! We set for every valid object in the memory pool the freepointer
   65397             :  * to the global index and increase the global index afterwards. For all the 
   65398             :  * invalid objects (means address ranges within the memory pool that were not
   65399             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   65400             :  * distinguish valid from invalid objects! 
   65401             :  */
   65402             : unsigned long
   65403           5 : SgOmpCopyinClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   65404             :    {
   65405           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   65406           5 :      SgOmpCopyinClause* pointer = NULL;
   65407           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   65408           5 :      std::vector < unsigned char* > :: const_iterator block;
   65409           5 :      for ( block = SgOmpCopyinClause::pools.begin(); block != SgOmpCopyinClause::pools.end() ; ++block )
   65410             :         {
   65411           0 :           pointer = (SgOmpCopyinClause*)(*block);
   65412           0 :           for (unsigned i = 0; i < SgOmpCopyinClause::pool_size; ++i )
   65413             :              {
   65414             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   65415             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   65416             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   65417             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   65418             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   65419             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   65420             :             // properly; so this will have to be checked next.
   65421             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   65422             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   65423           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   65424             :                   {
   65425           0 :                     pointer[i].set_freepointer((SgOmpCopyinClause*)(globalIndex));
   65426           0 :                     globalIndex++;
   65427             :                   }
   65428             :                else
   65429             :                   {
   65430           0 :                     pointer[i].set_freepointer(NULL);
   65431             :                   }
   65432             :               }
   65433             :         }
   65434           5 :      return globalIndex;
   65435             :    }
   65436             : 
   65437             : //############################################################################
   65438             : // JH (01/14/2006)
   65439             : void
   65440           5 : SgOmpCopyinClause::resetValidFreepointers( )
   65441             :    {
   65442           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   65443           5 :      SgOmpCopyinClause* pointer = NULL;
   65444           5 :      std::vector < unsigned char* > :: const_iterator block;
   65445           5 :      SgOmpCopyinClause* pointerOfLinkedList = NULL;
   65446           5 :      for ( block = SgOmpCopyinClause::pools.begin(); block != SgOmpCopyinClause::pools.end() ; ++block )
   65447             :         {
   65448           0 :           pointer = (SgOmpCopyinClause*)(*block);
   65449           0 :           for (unsigned i = 0; i < SgOmpCopyinClause::pool_size; ++i )
   65450             :              {
   65451             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   65452             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   65453             :             // memory blocks!.
   65454           0 :                if ( pointer[i].get_freepointer() != NULL )
   65455             :                   {
   65456           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   65457             :                   }
   65458             :                else
   65459             :                   {
   65460           0 :                     if ( pointerOfLinkedList == NULL )
   65461             :                        {
   65462           0 :                          SgOmpCopyinClause::next_node = &(pointer[i]);
   65463             :                        }
   65464             :                     else
   65465             :                        {
   65466             :                       // printf ("In SgOmpCopyinClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   65467           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   65468             :                        }
   65469             :                     pointerOfLinkedList = &(pointer[i]);
   65470             :                   }
   65471             :               }
   65472             :         }
   65473             : 
   65474           5 :      if ( pointerOfLinkedList != NULL )
   65475             :         {
   65476             :        // printf ("In SgOmpCopyinClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   65477           0 :           pointerOfLinkedList->set_freepointer(NULL);
   65478             :        // DQ (6/6/2010): Temporary debugging...
   65479             :        //   ROSE_ASSERT(false);
   65480             :         }
   65481             : 
   65482           5 :      return ;
   65483             :    }
   65484             : 
   65485             : //############################################################################
   65486             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   65487             :  * within the memory pool and resets the freepointers, in order to achieve a 
   65488             :  * linked list, that has no jumps and starts at the beginning! This function 
   65489             :  * does not extend the memory pool, since we do not delete any memory blocks,
   65490             :  * but delete the valid objects.  
   65491             :  */
   65492             : void
   65493           0 : SgOmpCopyinClause::clearMemoryPool( )
   65494             :    {
   65495             :   // printf ("Inside of SgOmpCopyinClause::clearMemoryPool() \n");
   65496             : 
   65497           0 :      SgOmpCopyinClause* pointer = NULL, *tempPointer = NULL;
   65498           0 :      std::vector < unsigned char* > :: const_iterator block;
   65499           0 :      if ( SgOmpCopyinClause::pools.empty() == false )
   65500             :         {
   65501           0 :           block = SgOmpCopyinClause::pools.begin() ;
   65502           0 :           SgOmpCopyinClause::next_node = (SgOmpCopyinClause*) (*block);
   65503             : 
   65504           0 :           while ( block != SgOmpCopyinClause::pools.end() )
   65505             :              {
   65506           0 :                pointer = (SgOmpCopyinClause*) (*block);
   65507           0 :                if ( tempPointer != NULL )
   65508             :                   {
   65509           0 :                     tempPointer->set_freepointer(pointer);
   65510             :                   }
   65511           0 :                for (unsigned i = 0; i < SgOmpCopyinClause::pool_size - 1; ++i)
   65512             :                   {
   65513           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   65514             :                   }
   65515           0 :                 pointer[SgOmpCopyinClause::pool_size-1].set_freepointer(NULL);
   65516           0 :                 tempPointer = &(pointer[SgOmpCopyinClause::pool_size-1]);
   65517           0 :                 ++block;
   65518             :              }
   65519             :         }
   65520           0 :    }
   65521             : 
   65522           5 : void SgOmpCopyinClause::deleteMemoryPool() {
   65523           5 :   for (auto p: SgOmpCopyinClause::pools) {
   65524           0 :     ROSE_FREE(p);
   65525             :   }
   65526           5 :   SgOmpCopyinClause::next_node = nullptr;
   65527           5 :   SgOmpCopyinClause::pools.clear();
   65528           5 : }
   65529             : 
   65530             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   65531             : //                 reading multiple binary files to for a single AST.
   65532             : /////////// new version ////////////////////////////////
   65533             : //############################################################################
   65534             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   65535             : void
   65536           2 : SgOmpCopyinClause::extendMemoryPoolForFileIO( )
   65537             :   {
   65538           2 :     size_t blockIndex = SgOmpCopyinClause::pools.size();
   65539           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCopyinClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCopyinClause);
   65540             : 
   65541           2 :     while ( (blockIndex * SgOmpCopyinClause::pool_size) < newPoolSize)
   65542             :       {
   65543             : #if ROSE_ALLOC_TRACE
   65544             :         if (blockIndex > 0) {
   65545             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCopyinClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCopyinClause) = %" PRIuPTR " SgOmpCopyinClause::pool_size = %d \n",
   65546             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCopyinClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCopyinClause),SgOmpCopyinClause::pool_size);
   65547             :         }
   65548             : #endif
   65549             : 
   65550           0 :         SgOmpCopyinClause * pointer = (SgOmpCopyinClause*) ROSE_MALLOC ( SgOmpCopyinClause::pool_size * sizeof(SgOmpCopyinClause) );
   65551           0 :         assert( pointer != NULL );
   65552             : #if ROSE_ALLOC_MEMSET == 1
   65553             :         memset(pointer, 0x00, SgOmpCopyinClause::pool_size * sizeof(SgOmpCopyinClause));
   65554             : #elif ROSE_ALLOC_MEMSET == 2
   65555             :         memset(pointer, 0xCC, SgOmpCopyinClause::pool_size * sizeof(SgOmpCopyinClause));
   65556             : #endif
   65557           0 :         SgOmpCopyinClause::pools.push_back( (unsigned char*)(pointer) );
   65558           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpCopyinClause::pool_size * sizeof(SgOmpCopyinClause), V_SgOmpCopyinClause ) );
   65559             : 
   65560           0 :         if ( SgOmpCopyinClause::next_node != NULL ) {
   65561           0 :           if ( blockIndex > 0 ) {
   65562           0 :             SgOmpCopyinClause * blkptr = (SgOmpCopyinClause*)(SgOmpCopyinClause::pools[blockIndex-1]);
   65563           0 :             blkptr[ SgOmpCopyinClause::pool_size - 1 ].set_freepointer(pointer);
   65564             :           }
   65565             :         } else {
   65566           0 :           SgOmpCopyinClause::next_node = pointer;
   65567             :         }
   65568             : 
   65569           0 :         for (unsigned i = 0; i < SgOmpCopyinClause::pool_size-1; ++i)
   65570             :            {
   65571           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   65572             :            }
   65573           0 :         pointer[ SgOmpCopyinClause::pool_size -1 ].set_freepointer(NULL);
   65574             : 
   65575           0 :         blockIndex++;
   65576             :       }
   65577           2 :   }
   65578             : 
   65579             : //############################################################################
   65580             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   65581             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   65582             :  * not compressed. However, that stuff is not yet implemented! 
   65583             :  */
   65584             : unsigned long
   65585           0 : SgOmpCopyinClause::getNumberOfLastValidPointer()
   65586             :    {
   65587           0 :       SgOmpCopyinClause* testPointer = (SgOmpCopyinClause*)(SgOmpCopyinClause::pools.back());
   65588           0 :       unsigned long localIndex = SgOmpCopyinClause::pool_size - 1;
   65589           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   65590             :          {
   65591           0 :            localIndex--;
   65592             :          }
   65593           0 :       return (localIndex + SgOmpCopyinClause::pool_size * (SgOmpCopyinClause::pools.size()-1));
   65594             :    }
   65595             : 
   65596             : //############################################################################
   65597             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   65598             :  * memory pool and initializes the data member in class SgOmpCopyinClauseStroageClass
   65599             :  * from its counterpart of SgOmpCopyinClause. The return value is just for checking, 
   65600             :  * that the whole StorageClassArray is initialized!
   65601             :  */
   65602             : unsigned long
   65603           0 : SgOmpCopyinClause::initializeStorageClassArray( SgOmpCopyinClauseStorageClass *storageArray )
   65604             :    {
   65605           0 :      unsigned long storageCounter = 0;
   65606           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpCopyinClause::pools.begin();
   65607           0 :      SgOmpCopyinClause* pointer = NULL;
   65608           0 :      while ( block != SgOmpCopyinClause::pools.end() ) {
   65609           0 :           pointer = (SgOmpCopyinClause*) (*block);
   65610           0 :           for ( unsigned i = 0; i < SgOmpCopyinClause::pool_size; ++i ) {
   65611           0 :                if ( pointer->get_freepointer() != NULL ) {
   65612           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   65613           0 :                  storageArray++;
   65614           0 :                  storageCounter++;
   65615             :                }
   65616           0 :                pointer++;
   65617             :              }
   65618           0 :            block++;
   65619             :         }
   65620           0 :      return storageCounter;
   65621             :    }
   65622             : 
   65623             : /* #line 65624 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   65624             : 
   65625             : 
   65626             : 
   65627             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   65628             : 
   65629             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   65630             : 
   65631             : //############################################################################
   65632             : /* JH (02/02/2006) Constructor of the IR node SgOmpLastprivateClause that takes its 
   65633             :  * corresponding StorageClass as parameter
   65634             :  */
   65635           0 : SgOmpLastprivateClause :: SgOmpLastprivateClause ( const SgOmpLastprivateClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   65636             :    {
   65637             : 
   65638             : 
   65639             : /* #line 65640 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   65640             : 
   65641           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   65642           0 :      p_modifier = storageSource.storageOf_modifier ;
   65643             : 
   65644             : 
   65645             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   65646             : 
   65647             : 
   65648           0 :    }
   65649             : 
   65650             : //############################################################################
   65651             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   65652             :  * within the working AST. 
   65653             :  */
   65654           0 : SgOmpLastprivateClause * SgOmpLastprivateClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   65655           0 :      SgOmpLastprivateClause* returnPointer = NULL;
   65656           0 :      if ( globalIndex != 0 )
   65657             :         {
   65658             : 
   65659             : #if FILE_IO_EXTRA_CHECK
   65660           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpLastprivateClause ) ) <= globalIndex ) ;
   65661           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpLastprivateClause + 1 ) ) );
   65662             : #endif
   65663           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpLastprivateClause )  
   65664           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpLastprivateClause );
   65665           0 :           unsigned long positionInPool = localIndex % SgOmpLastprivateClause::pool_size;
   65666           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpLastprivateClause::pool_size;
   65667             : 
   65668             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   65669             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   65670             : 
   65671           0 :           returnPointer = &( ( (SgOmpLastprivateClause*)(SgOmpLastprivateClause::pools[memoryBlock]) ) [positionInPool]) ;
   65672             : 
   65673           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   65674             :         }
   65675           0 :      return returnPointer ;
   65676             :    }
   65677             : 
   65678             : //############################################################################
   65679             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   65680             :   for the AST with the index astIndex
   65681             : */
   65682           0 : SgOmpLastprivateClause * SgOmpLastprivateClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   65683           0 :      SgOmpLastprivateClause* returnPointer = NULL;
   65684           0 :      if ( globalIndex != 0 )
   65685             :         {
   65686             : 
   65687             : #if FILE_IO_EXTRA_CHECK
   65688           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpLastprivateClause ) ) <= globalIndex ) ;
   65689           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpLastprivateClause + 1 ) ) );
   65690             : #endif
   65691           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpLastprivateClause )
   65692           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpLastprivateClause );
   65693           0 :           unsigned long positionInPool = localIndex % SgOmpLastprivateClause::pool_size ;
   65694           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpLastprivateClause::pool_size ;
   65695             : 
   65696             : #if FILE_IO_EXTRA_CHECK
   65697             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   65698             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   65699             : #endif
   65700             : 
   65701           0 :           returnPointer = &( ( (SgOmpLastprivateClause*)(SgOmpLastprivateClause::pools[memoryBlock]) ) [positionInPool]) ;
   65702             : 
   65703             : #if FILE_IO_EXTRA_CHECK
   65704           0 :           assert ( returnPointer != NULL ) ;
   65705             : #endif
   65706             :         }
   65707           0 :      return returnPointer ;
   65708             :    }
   65709             : 
   65710             : //############################################################################
   65711             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   65712             :  * pool size! We set for every valid object in the memory pool the freepointer
   65713             :  * to the global index and increase the global index afterwards. For all the 
   65714             :  * invalid objects (means address ranges within the memory pool that were not
   65715             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   65716             :  * distinguish valid from invalid objects! 
   65717             :  */
   65718             : unsigned long
   65719           5 : SgOmpLastprivateClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   65720             :    {
   65721           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   65722           5 :      SgOmpLastprivateClause* pointer = NULL;
   65723           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   65724           5 :      std::vector < unsigned char* > :: const_iterator block;
   65725           5 :      for ( block = SgOmpLastprivateClause::pools.begin(); block != SgOmpLastprivateClause::pools.end() ; ++block )
   65726             :         {
   65727           0 :           pointer = (SgOmpLastprivateClause*)(*block);
   65728           0 :           for (unsigned i = 0; i < SgOmpLastprivateClause::pool_size; ++i )
   65729             :              {
   65730             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   65731             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   65732             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   65733             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   65734             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   65735             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   65736             :             // properly; so this will have to be checked next.
   65737             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   65738             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   65739           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   65740             :                   {
   65741           0 :                     pointer[i].set_freepointer((SgOmpLastprivateClause*)(globalIndex));
   65742           0 :                     globalIndex++;
   65743             :                   }
   65744             :                else
   65745             :                   {
   65746           0 :                     pointer[i].set_freepointer(NULL);
   65747             :                   }
   65748             :               }
   65749             :         }
   65750           5 :      return globalIndex;
   65751             :    }
   65752             : 
   65753             : //############################################################################
   65754             : // JH (01/14/2006)
   65755             : void
   65756           5 : SgOmpLastprivateClause::resetValidFreepointers( )
   65757             :    {
   65758           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   65759           5 :      SgOmpLastprivateClause* pointer = NULL;
   65760           5 :      std::vector < unsigned char* > :: const_iterator block;
   65761           5 :      SgOmpLastprivateClause* pointerOfLinkedList = NULL;
   65762           5 :      for ( block = SgOmpLastprivateClause::pools.begin(); block != SgOmpLastprivateClause::pools.end() ; ++block )
   65763             :         {
   65764           0 :           pointer = (SgOmpLastprivateClause*)(*block);
   65765           0 :           for (unsigned i = 0; i < SgOmpLastprivateClause::pool_size; ++i )
   65766             :              {
   65767             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   65768             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   65769             :             // memory blocks!.
   65770           0 :                if ( pointer[i].get_freepointer() != NULL )
   65771             :                   {
   65772           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   65773             :                   }
   65774             :                else
   65775             :                   {
   65776           0 :                     if ( pointerOfLinkedList == NULL )
   65777             :                        {
   65778           0 :                          SgOmpLastprivateClause::next_node = &(pointer[i]);
   65779             :                        }
   65780             :                     else
   65781             :                        {
   65782             :                       // printf ("In SgOmpLastprivateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   65783           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   65784             :                        }
   65785             :                     pointerOfLinkedList = &(pointer[i]);
   65786             :                   }
   65787             :               }
   65788             :         }
   65789             : 
   65790           5 :      if ( pointerOfLinkedList != NULL )
   65791             :         {
   65792             :        // printf ("In SgOmpLastprivateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   65793           0 :           pointerOfLinkedList->set_freepointer(NULL);
   65794             :        // DQ (6/6/2010): Temporary debugging...
   65795             :        //   ROSE_ASSERT(false);
   65796             :         }
   65797             : 
   65798           5 :      return ;
   65799             :    }
   65800             : 
   65801             : //############################################################################
   65802             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   65803             :  * within the memory pool and resets the freepointers, in order to achieve a 
   65804             :  * linked list, that has no jumps and starts at the beginning! This function 
   65805             :  * does not extend the memory pool, since we do not delete any memory blocks,
   65806             :  * but delete the valid objects.  
   65807             :  */
   65808             : void
   65809           0 : SgOmpLastprivateClause::clearMemoryPool( )
   65810             :    {
   65811             :   // printf ("Inside of SgOmpLastprivateClause::clearMemoryPool() \n");
   65812             : 
   65813           0 :      SgOmpLastprivateClause* pointer = NULL, *tempPointer = NULL;
   65814           0 :      std::vector < unsigned char* > :: const_iterator block;
   65815           0 :      if ( SgOmpLastprivateClause::pools.empty() == false )
   65816             :         {
   65817           0 :           block = SgOmpLastprivateClause::pools.begin() ;
   65818           0 :           SgOmpLastprivateClause::next_node = (SgOmpLastprivateClause*) (*block);
   65819             : 
   65820           0 :           while ( block != SgOmpLastprivateClause::pools.end() )
   65821             :              {
   65822           0 :                pointer = (SgOmpLastprivateClause*) (*block);
   65823           0 :                if ( tempPointer != NULL )
   65824             :                   {
   65825           0 :                     tempPointer->set_freepointer(pointer);
   65826             :                   }
   65827           0 :                for (unsigned i = 0; i < SgOmpLastprivateClause::pool_size - 1; ++i)
   65828             :                   {
   65829           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   65830             :                   }
   65831           0 :                 pointer[SgOmpLastprivateClause::pool_size-1].set_freepointer(NULL);
   65832           0 :                 tempPointer = &(pointer[SgOmpLastprivateClause::pool_size-1]);
   65833           0 :                 ++block;
   65834             :              }
   65835             :         }
   65836           0 :    }
   65837             : 
   65838           5 : void SgOmpLastprivateClause::deleteMemoryPool() {
   65839           5 :   for (auto p: SgOmpLastprivateClause::pools) {
   65840           0 :     ROSE_FREE(p);
   65841             :   }
   65842           5 :   SgOmpLastprivateClause::next_node = nullptr;
   65843           5 :   SgOmpLastprivateClause::pools.clear();
   65844           5 : }
   65845             : 
   65846             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   65847             : //                 reading multiple binary files to for a single AST.
   65848             : /////////// new version ////////////////////////////////
   65849             : //############################################################################
   65850             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   65851             : void
   65852           2 : SgOmpLastprivateClause::extendMemoryPoolForFileIO( )
   65853             :   {
   65854           2 :     size_t blockIndex = SgOmpLastprivateClause::pools.size();
   65855           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLastprivateClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLastprivateClause);
   65856             : 
   65857           2 :     while ( (blockIndex * SgOmpLastprivateClause::pool_size) < newPoolSize)
   65858             :       {
   65859             : #if ROSE_ALLOC_TRACE
   65860             :         if (blockIndex > 0) {
   65861             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLastprivateClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLastprivateClause) = %" PRIuPTR " SgOmpLastprivateClause::pool_size = %d \n",
   65862             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLastprivateClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLastprivateClause),SgOmpLastprivateClause::pool_size);
   65863             :         }
   65864             : #endif
   65865             : 
   65866           0 :         SgOmpLastprivateClause * pointer = (SgOmpLastprivateClause*) ROSE_MALLOC ( SgOmpLastprivateClause::pool_size * sizeof(SgOmpLastprivateClause) );
   65867           0 :         assert( pointer != NULL );
   65868             : #if ROSE_ALLOC_MEMSET == 1
   65869             :         memset(pointer, 0x00, SgOmpLastprivateClause::pool_size * sizeof(SgOmpLastprivateClause));
   65870             : #elif ROSE_ALLOC_MEMSET == 2
   65871             :         memset(pointer, 0xCC, SgOmpLastprivateClause::pool_size * sizeof(SgOmpLastprivateClause));
   65872             : #endif
   65873           0 :         SgOmpLastprivateClause::pools.push_back( (unsigned char*)(pointer) );
   65874           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpLastprivateClause::pool_size * sizeof(SgOmpLastprivateClause), V_SgOmpLastprivateClause ) );
   65875             : 
   65876           0 :         if ( SgOmpLastprivateClause::next_node != NULL ) {
   65877           0 :           if ( blockIndex > 0 ) {
   65878           0 :             SgOmpLastprivateClause * blkptr = (SgOmpLastprivateClause*)(SgOmpLastprivateClause::pools[blockIndex-1]);
   65879           0 :             blkptr[ SgOmpLastprivateClause::pool_size - 1 ].set_freepointer(pointer);
   65880             :           }
   65881             :         } else {
   65882           0 :           SgOmpLastprivateClause::next_node = pointer;
   65883             :         }
   65884             : 
   65885           0 :         for (unsigned i = 0; i < SgOmpLastprivateClause::pool_size-1; ++i)
   65886             :            {
   65887           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   65888             :            }
   65889           0 :         pointer[ SgOmpLastprivateClause::pool_size -1 ].set_freepointer(NULL);
   65890             : 
   65891           0 :         blockIndex++;
   65892             :       }
   65893           2 :   }
   65894             : 
   65895             : //############################################################################
   65896             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   65897             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   65898             :  * not compressed. However, that stuff is not yet implemented! 
   65899             :  */
   65900             : unsigned long
   65901           0 : SgOmpLastprivateClause::getNumberOfLastValidPointer()
   65902             :    {
   65903           0 :       SgOmpLastprivateClause* testPointer = (SgOmpLastprivateClause*)(SgOmpLastprivateClause::pools.back());
   65904           0 :       unsigned long localIndex = SgOmpLastprivateClause::pool_size - 1;
   65905           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   65906             :          {
   65907           0 :            localIndex--;
   65908             :          }
   65909           0 :       return (localIndex + SgOmpLastprivateClause::pool_size * (SgOmpLastprivateClause::pools.size()-1));
   65910             :    }
   65911             : 
   65912             : //############################################################################
   65913             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   65914             :  * memory pool and initializes the data member in class SgOmpLastprivateClauseStroageClass
   65915             :  * from its counterpart of SgOmpLastprivateClause. The return value is just for checking, 
   65916             :  * that the whole StorageClassArray is initialized!
   65917             :  */
   65918             : unsigned long
   65919           0 : SgOmpLastprivateClause::initializeStorageClassArray( SgOmpLastprivateClauseStorageClass *storageArray )
   65920             :    {
   65921           0 :      unsigned long storageCounter = 0;
   65922           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpLastprivateClause::pools.begin();
   65923           0 :      SgOmpLastprivateClause* pointer = NULL;
   65924           0 :      while ( block != SgOmpLastprivateClause::pools.end() ) {
   65925           0 :           pointer = (SgOmpLastprivateClause*) (*block);
   65926           0 :           for ( unsigned i = 0; i < SgOmpLastprivateClause::pool_size; ++i ) {
   65927           0 :                if ( pointer->get_freepointer() != NULL ) {
   65928           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   65929           0 :                  storageArray++;
   65930           0 :                  storageCounter++;
   65931             :                }
   65932           0 :                pointer++;
   65933             :              }
   65934           0 :            block++;
   65935             :         }
   65936           0 :      return storageCounter;
   65937             :    }
   65938             : 
   65939             : /* #line 65940 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   65940             : 
   65941             : 
   65942             : 
   65943             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   65944             : 
   65945             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   65946             : 
   65947             : //############################################################################
   65948             : /* JH (02/02/2006) Constructor of the IR node SgOmpReductionClause that takes its 
   65949             :  * corresponding StorageClass as parameter
   65950             :  */
   65951           0 : SgOmpReductionClause :: SgOmpReductionClause ( const SgOmpReductionClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   65952             :    {
   65953             : 
   65954             : 
   65955             : /* #line 65956 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   65956             : 
   65957           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   65958           0 :      p_modifier = storageSource.storageOf_modifier ;
   65959           0 :      p_identifier = storageSource.storageOf_identifier ;
   65960           0 :      p_user_defined_identifier =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_defined_identifier) );
   65961             : 
   65962             : 
   65963             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   65964             : 
   65965             : 
   65966           0 :    }
   65967             : 
   65968             : //############################################################################
   65969             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   65970             :  * within the working AST. 
   65971             :  */
   65972           0 : SgOmpReductionClause * SgOmpReductionClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   65973           0 :      SgOmpReductionClause* returnPointer = NULL;
   65974           0 :      if ( globalIndex != 0 )
   65975             :         {
   65976             : 
   65977             : #if FILE_IO_EXTRA_CHECK
   65978           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpReductionClause ) ) <= globalIndex ) ;
   65979           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpReductionClause + 1 ) ) );
   65980             : #endif
   65981           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpReductionClause )  
   65982           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpReductionClause );
   65983           0 :           unsigned long positionInPool = localIndex % SgOmpReductionClause::pool_size;
   65984           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpReductionClause::pool_size;
   65985             : 
   65986             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   65987             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   65988             : 
   65989           0 :           returnPointer = &( ( (SgOmpReductionClause*)(SgOmpReductionClause::pools[memoryBlock]) ) [positionInPool]) ;
   65990             : 
   65991           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   65992             :         }
   65993           0 :      return returnPointer ;
   65994             :    }
   65995             : 
   65996             : //############################################################################
   65997             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   65998             :   for the AST with the index astIndex
   65999             : */
   66000           0 : SgOmpReductionClause * SgOmpReductionClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   66001           0 :      SgOmpReductionClause* returnPointer = NULL;
   66002           0 :      if ( globalIndex != 0 )
   66003             :         {
   66004             : 
   66005             : #if FILE_IO_EXTRA_CHECK
   66006           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpReductionClause ) ) <= globalIndex ) ;
   66007           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpReductionClause + 1 ) ) );
   66008             : #endif
   66009           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpReductionClause )
   66010           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpReductionClause );
   66011           0 :           unsigned long positionInPool = localIndex % SgOmpReductionClause::pool_size ;
   66012           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpReductionClause::pool_size ;
   66013             : 
   66014             : #if FILE_IO_EXTRA_CHECK
   66015             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   66016             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   66017             : #endif
   66018             : 
   66019           0 :           returnPointer = &( ( (SgOmpReductionClause*)(SgOmpReductionClause::pools[memoryBlock]) ) [positionInPool]) ;
   66020             : 
   66021             : #if FILE_IO_EXTRA_CHECK
   66022           0 :           assert ( returnPointer != NULL ) ;
   66023             : #endif
   66024             :         }
   66025           0 :      return returnPointer ;
   66026             :    }
   66027             : 
   66028             : //############################################################################
   66029             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   66030             :  * pool size! We set for every valid object in the memory pool the freepointer
   66031             :  * to the global index and increase the global index afterwards. For all the 
   66032             :  * invalid objects (means address ranges within the memory pool that were not
   66033             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   66034             :  * distinguish valid from invalid objects! 
   66035             :  */
   66036             : unsigned long
   66037           5 : SgOmpReductionClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   66038             :    {
   66039           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   66040           5 :      SgOmpReductionClause* pointer = NULL;
   66041           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   66042           5 :      std::vector < unsigned char* > :: const_iterator block;
   66043           5 :      for ( block = SgOmpReductionClause::pools.begin(); block != SgOmpReductionClause::pools.end() ; ++block )
   66044             :         {
   66045           0 :           pointer = (SgOmpReductionClause*)(*block);
   66046           0 :           for (unsigned i = 0; i < SgOmpReductionClause::pool_size; ++i )
   66047             :              {
   66048             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   66049             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   66050             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   66051             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   66052             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   66053             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   66054             :             // properly; so this will have to be checked next.
   66055             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   66056             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   66057           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   66058             :                   {
   66059           0 :                     pointer[i].set_freepointer((SgOmpReductionClause*)(globalIndex));
   66060           0 :                     globalIndex++;
   66061             :                   }
   66062             :                else
   66063             :                   {
   66064           0 :                     pointer[i].set_freepointer(NULL);
   66065             :                   }
   66066             :               }
   66067             :         }
   66068           5 :      return globalIndex;
   66069             :    }
   66070             : 
   66071             : //############################################################################
   66072             : // JH (01/14/2006)
   66073             : void
   66074           5 : SgOmpReductionClause::resetValidFreepointers( )
   66075             :    {
   66076           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   66077           5 :      SgOmpReductionClause* pointer = NULL;
   66078           5 :      std::vector < unsigned char* > :: const_iterator block;
   66079           5 :      SgOmpReductionClause* pointerOfLinkedList = NULL;
   66080           5 :      for ( block = SgOmpReductionClause::pools.begin(); block != SgOmpReductionClause::pools.end() ; ++block )
   66081             :         {
   66082           0 :           pointer = (SgOmpReductionClause*)(*block);
   66083           0 :           for (unsigned i = 0; i < SgOmpReductionClause::pool_size; ++i )
   66084             :              {
   66085             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   66086             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   66087             :             // memory blocks!.
   66088           0 :                if ( pointer[i].get_freepointer() != NULL )
   66089             :                   {
   66090           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   66091             :                   }
   66092             :                else
   66093             :                   {
   66094           0 :                     if ( pointerOfLinkedList == NULL )
   66095             :                        {
   66096           0 :                          SgOmpReductionClause::next_node = &(pointer[i]);
   66097             :                        }
   66098             :                     else
   66099             :                        {
   66100             :                       // printf ("In SgOmpReductionClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   66101           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   66102             :                        }
   66103             :                     pointerOfLinkedList = &(pointer[i]);
   66104             :                   }
   66105             :               }
   66106             :         }
   66107             : 
   66108           5 :      if ( pointerOfLinkedList != NULL )
   66109             :         {
   66110             :        // printf ("In SgOmpReductionClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   66111           0 :           pointerOfLinkedList->set_freepointer(NULL);
   66112             :        // DQ (6/6/2010): Temporary debugging...
   66113             :        //   ROSE_ASSERT(false);
   66114             :         }
   66115             : 
   66116           5 :      return ;
   66117             :    }
   66118             : 
   66119             : //############################################################################
   66120             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   66121             :  * within the memory pool and resets the freepointers, in order to achieve a 
   66122             :  * linked list, that has no jumps and starts at the beginning! This function 
   66123             :  * does not extend the memory pool, since we do not delete any memory blocks,
   66124             :  * but delete the valid objects.  
   66125             :  */
   66126             : void
   66127           0 : SgOmpReductionClause::clearMemoryPool( )
   66128             :    {
   66129             :   // printf ("Inside of SgOmpReductionClause::clearMemoryPool() \n");
   66130             : 
   66131           0 :      SgOmpReductionClause* pointer = NULL, *tempPointer = NULL;
   66132           0 :      std::vector < unsigned char* > :: const_iterator block;
   66133           0 :      if ( SgOmpReductionClause::pools.empty() == false )
   66134             :         {
   66135           0 :           block = SgOmpReductionClause::pools.begin() ;
   66136           0 :           SgOmpReductionClause::next_node = (SgOmpReductionClause*) (*block);
   66137             : 
   66138           0 :           while ( block != SgOmpReductionClause::pools.end() )
   66139             :              {
   66140           0 :                pointer = (SgOmpReductionClause*) (*block);
   66141           0 :                if ( tempPointer != NULL )
   66142             :                   {
   66143           0 :                     tempPointer->set_freepointer(pointer);
   66144             :                   }
   66145           0 :                for (unsigned i = 0; i < SgOmpReductionClause::pool_size - 1; ++i)
   66146             :                   {
   66147           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   66148             :                   }
   66149           0 :                 pointer[SgOmpReductionClause::pool_size-1].set_freepointer(NULL);
   66150           0 :                 tempPointer = &(pointer[SgOmpReductionClause::pool_size-1]);
   66151           0 :                 ++block;
   66152             :              }
   66153             :         }
   66154           0 :    }
   66155             : 
   66156           5 : void SgOmpReductionClause::deleteMemoryPool() {
   66157           5 :   for (auto p: SgOmpReductionClause::pools) {
   66158           0 :     ROSE_FREE(p);
   66159             :   }
   66160           5 :   SgOmpReductionClause::next_node = nullptr;
   66161           5 :   SgOmpReductionClause::pools.clear();
   66162           5 : }
   66163             : 
   66164             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   66165             : //                 reading multiple binary files to for a single AST.
   66166             : /////////// new version ////////////////////////////////
   66167             : //############################################################################
   66168             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   66169             : void
   66170           2 : SgOmpReductionClause::extendMemoryPoolForFileIO( )
   66171             :   {
   66172           2 :     size_t blockIndex = SgOmpReductionClause::pools.size();
   66173           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReductionClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReductionClause);
   66174             : 
   66175           2 :     while ( (blockIndex * SgOmpReductionClause::pool_size) < newPoolSize)
   66176             :       {
   66177             : #if ROSE_ALLOC_TRACE
   66178             :         if (blockIndex > 0) {
   66179             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReductionClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReductionClause) = %" PRIuPTR " SgOmpReductionClause::pool_size = %d \n",
   66180             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpReductionClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpReductionClause),SgOmpReductionClause::pool_size);
   66181             :         }
   66182             : #endif
   66183             : 
   66184           0 :         SgOmpReductionClause * pointer = (SgOmpReductionClause*) ROSE_MALLOC ( SgOmpReductionClause::pool_size * sizeof(SgOmpReductionClause) );
   66185           0 :         assert( pointer != NULL );
   66186             : #if ROSE_ALLOC_MEMSET == 1
   66187             :         memset(pointer, 0x00, SgOmpReductionClause::pool_size * sizeof(SgOmpReductionClause));
   66188             : #elif ROSE_ALLOC_MEMSET == 2
   66189             :         memset(pointer, 0xCC, SgOmpReductionClause::pool_size * sizeof(SgOmpReductionClause));
   66190             : #endif
   66191           0 :         SgOmpReductionClause::pools.push_back( (unsigned char*)(pointer) );
   66192           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpReductionClause::pool_size * sizeof(SgOmpReductionClause), V_SgOmpReductionClause ) );
   66193             : 
   66194           0 :         if ( SgOmpReductionClause::next_node != NULL ) {
   66195           0 :           if ( blockIndex > 0 ) {
   66196           0 :             SgOmpReductionClause * blkptr = (SgOmpReductionClause*)(SgOmpReductionClause::pools[blockIndex-1]);
   66197           0 :             blkptr[ SgOmpReductionClause::pool_size - 1 ].set_freepointer(pointer);
   66198             :           }
   66199             :         } else {
   66200           0 :           SgOmpReductionClause::next_node = pointer;
   66201             :         }
   66202             : 
   66203           0 :         for (unsigned i = 0; i < SgOmpReductionClause::pool_size-1; ++i)
   66204             :            {
   66205           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   66206             :            }
   66207           0 :         pointer[ SgOmpReductionClause::pool_size -1 ].set_freepointer(NULL);
   66208             : 
   66209           0 :         blockIndex++;
   66210             :       }
   66211           2 :   }
   66212             : 
   66213             : //############################################################################
   66214             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   66215             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   66216             :  * not compressed. However, that stuff is not yet implemented! 
   66217             :  */
   66218             : unsigned long
   66219           0 : SgOmpReductionClause::getNumberOfLastValidPointer()
   66220             :    {
   66221           0 :       SgOmpReductionClause* testPointer = (SgOmpReductionClause*)(SgOmpReductionClause::pools.back());
   66222           0 :       unsigned long localIndex = SgOmpReductionClause::pool_size - 1;
   66223           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   66224             :          {
   66225           0 :            localIndex--;
   66226             :          }
   66227           0 :       return (localIndex + SgOmpReductionClause::pool_size * (SgOmpReductionClause::pools.size()-1));
   66228             :    }
   66229             : 
   66230             : //############################################################################
   66231             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   66232             :  * memory pool and initializes the data member in class SgOmpReductionClauseStroageClass
   66233             :  * from its counterpart of SgOmpReductionClause. The return value is just for checking, 
   66234             :  * that the whole StorageClassArray is initialized!
   66235             :  */
   66236             : unsigned long
   66237           0 : SgOmpReductionClause::initializeStorageClassArray( SgOmpReductionClauseStorageClass *storageArray )
   66238             :    {
   66239           0 :      unsigned long storageCounter = 0;
   66240           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpReductionClause::pools.begin();
   66241           0 :      SgOmpReductionClause* pointer = NULL;
   66242           0 :      while ( block != SgOmpReductionClause::pools.end() ) {
   66243           0 :           pointer = (SgOmpReductionClause*) (*block);
   66244           0 :           for ( unsigned i = 0; i < SgOmpReductionClause::pool_size; ++i ) {
   66245           0 :                if ( pointer->get_freepointer() != NULL ) {
   66246           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   66247           0 :                  storageArray++;
   66248           0 :                  storageCounter++;
   66249             :                }
   66250           0 :                pointer++;
   66251             :              }
   66252           0 :            block++;
   66253             :         }
   66254           0 :      return storageCounter;
   66255             :    }
   66256             : 
   66257             : /* #line 66258 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   66258             : 
   66259             : 
   66260             : 
   66261             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   66262             : 
   66263             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   66264             : 
   66265             : //############################################################################
   66266             : /* JH (02/02/2006) Constructor of the IR node SgOmpInReductionClause that takes its 
   66267             :  * corresponding StorageClass as parameter
   66268             :  */
   66269           0 : SgOmpInReductionClause :: SgOmpInReductionClause ( const SgOmpInReductionClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   66270             :    {
   66271             : 
   66272             : 
   66273             : /* #line 66274 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   66274             : 
   66275           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   66276           0 :      p_identifier = storageSource.storageOf_identifier ;
   66277           0 :      p_user_defined_identifier =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_defined_identifier) );
   66278             : 
   66279             : 
   66280             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   66281             : 
   66282             : 
   66283           0 :    }
   66284             : 
   66285             : //############################################################################
   66286             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   66287             :  * within the working AST. 
   66288             :  */
   66289           0 : SgOmpInReductionClause * SgOmpInReductionClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   66290           0 :      SgOmpInReductionClause* returnPointer = NULL;
   66291           0 :      if ( globalIndex != 0 )
   66292             :         {
   66293             : 
   66294             : #if FILE_IO_EXTRA_CHECK
   66295           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpInReductionClause ) ) <= globalIndex ) ;
   66296           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpInReductionClause + 1 ) ) );
   66297             : #endif
   66298           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpInReductionClause )  
   66299           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpInReductionClause );
   66300           0 :           unsigned long positionInPool = localIndex % SgOmpInReductionClause::pool_size;
   66301           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpInReductionClause::pool_size;
   66302             : 
   66303             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   66304             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   66305             : 
   66306           0 :           returnPointer = &( ( (SgOmpInReductionClause*)(SgOmpInReductionClause::pools[memoryBlock]) ) [positionInPool]) ;
   66307             : 
   66308           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   66309             :         }
   66310           0 :      return returnPointer ;
   66311             :    }
   66312             : 
   66313             : //############################################################################
   66314             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   66315             :   for the AST with the index astIndex
   66316             : */
   66317           0 : SgOmpInReductionClause * SgOmpInReductionClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   66318           0 :      SgOmpInReductionClause* returnPointer = NULL;
   66319           0 :      if ( globalIndex != 0 )
   66320             :         {
   66321             : 
   66322             : #if FILE_IO_EXTRA_CHECK
   66323           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpInReductionClause ) ) <= globalIndex ) ;
   66324           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpInReductionClause + 1 ) ) );
   66325             : #endif
   66326           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpInReductionClause )
   66327           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpInReductionClause );
   66328           0 :           unsigned long positionInPool = localIndex % SgOmpInReductionClause::pool_size ;
   66329           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpInReductionClause::pool_size ;
   66330             : 
   66331             : #if FILE_IO_EXTRA_CHECK
   66332             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   66333             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   66334             : #endif
   66335             : 
   66336           0 :           returnPointer = &( ( (SgOmpInReductionClause*)(SgOmpInReductionClause::pools[memoryBlock]) ) [positionInPool]) ;
   66337             : 
   66338             : #if FILE_IO_EXTRA_CHECK
   66339           0 :           assert ( returnPointer != NULL ) ;
   66340             : #endif
   66341             :         }
   66342           0 :      return returnPointer ;
   66343             :    }
   66344             : 
   66345             : //############################################################################
   66346             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   66347             :  * pool size! We set for every valid object in the memory pool the freepointer
   66348             :  * to the global index and increase the global index afterwards. For all the 
   66349             :  * invalid objects (means address ranges within the memory pool that were not
   66350             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   66351             :  * distinguish valid from invalid objects! 
   66352             :  */
   66353             : unsigned long
   66354           5 : SgOmpInReductionClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   66355             :    {
   66356           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   66357           5 :      SgOmpInReductionClause* pointer = NULL;
   66358           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   66359           5 :      std::vector < unsigned char* > :: const_iterator block;
   66360           5 :      for ( block = SgOmpInReductionClause::pools.begin(); block != SgOmpInReductionClause::pools.end() ; ++block )
   66361             :         {
   66362           0 :           pointer = (SgOmpInReductionClause*)(*block);
   66363           0 :           for (unsigned i = 0; i < SgOmpInReductionClause::pool_size; ++i )
   66364             :              {
   66365             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   66366             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   66367             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   66368             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   66369             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   66370             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   66371             :             // properly; so this will have to be checked next.
   66372             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   66373             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   66374           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   66375             :                   {
   66376           0 :                     pointer[i].set_freepointer((SgOmpInReductionClause*)(globalIndex));
   66377           0 :                     globalIndex++;
   66378             :                   }
   66379             :                else
   66380             :                   {
   66381           0 :                     pointer[i].set_freepointer(NULL);
   66382             :                   }
   66383             :               }
   66384             :         }
   66385           5 :      return globalIndex;
   66386             :    }
   66387             : 
   66388             : //############################################################################
   66389             : // JH (01/14/2006)
   66390             : void
   66391           5 : SgOmpInReductionClause::resetValidFreepointers( )
   66392             :    {
   66393           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   66394           5 :      SgOmpInReductionClause* pointer = NULL;
   66395           5 :      std::vector < unsigned char* > :: const_iterator block;
   66396           5 :      SgOmpInReductionClause* pointerOfLinkedList = NULL;
   66397           5 :      for ( block = SgOmpInReductionClause::pools.begin(); block != SgOmpInReductionClause::pools.end() ; ++block )
   66398             :         {
   66399           0 :           pointer = (SgOmpInReductionClause*)(*block);
   66400           0 :           for (unsigned i = 0; i < SgOmpInReductionClause::pool_size; ++i )
   66401             :              {
   66402             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   66403             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   66404             :             // memory blocks!.
   66405           0 :                if ( pointer[i].get_freepointer() != NULL )
   66406             :                   {
   66407           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   66408             :                   }
   66409             :                else
   66410             :                   {
   66411           0 :                     if ( pointerOfLinkedList == NULL )
   66412             :                        {
   66413           0 :                          SgOmpInReductionClause::next_node = &(pointer[i]);
   66414             :                        }
   66415             :                     else
   66416             :                        {
   66417             :                       // printf ("In SgOmpInReductionClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   66418           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   66419             :                        }
   66420             :                     pointerOfLinkedList = &(pointer[i]);
   66421             :                   }
   66422             :               }
   66423             :         }
   66424             : 
   66425           5 :      if ( pointerOfLinkedList != NULL )
   66426             :         {
   66427             :        // printf ("In SgOmpInReductionClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   66428           0 :           pointerOfLinkedList->set_freepointer(NULL);
   66429             :        // DQ (6/6/2010): Temporary debugging...
   66430             :        //   ROSE_ASSERT(false);
   66431             :         }
   66432             : 
   66433           5 :      return ;
   66434             :    }
   66435             : 
   66436             : //############################################################################
   66437             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   66438             :  * within the memory pool and resets the freepointers, in order to achieve a 
   66439             :  * linked list, that has no jumps and starts at the beginning! This function 
   66440             :  * does not extend the memory pool, since we do not delete any memory blocks,
   66441             :  * but delete the valid objects.  
   66442             :  */
   66443             : void
   66444           0 : SgOmpInReductionClause::clearMemoryPool( )
   66445             :    {
   66446             :   // printf ("Inside of SgOmpInReductionClause::clearMemoryPool() \n");
   66447             : 
   66448           0 :      SgOmpInReductionClause* pointer = NULL, *tempPointer = NULL;
   66449           0 :      std::vector < unsigned char* > :: const_iterator block;
   66450           0 :      if ( SgOmpInReductionClause::pools.empty() == false )
   66451             :         {
   66452           0 :           block = SgOmpInReductionClause::pools.begin() ;
   66453           0 :           SgOmpInReductionClause::next_node = (SgOmpInReductionClause*) (*block);
   66454             : 
   66455           0 :           while ( block != SgOmpInReductionClause::pools.end() )
   66456             :              {
   66457           0 :                pointer = (SgOmpInReductionClause*) (*block);
   66458           0 :                if ( tempPointer != NULL )
   66459             :                   {
   66460           0 :                     tempPointer->set_freepointer(pointer);
   66461             :                   }
   66462           0 :                for (unsigned i = 0; i < SgOmpInReductionClause::pool_size - 1; ++i)
   66463             :                   {
   66464           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   66465             :                   }
   66466           0 :                 pointer[SgOmpInReductionClause::pool_size-1].set_freepointer(NULL);
   66467           0 :                 tempPointer = &(pointer[SgOmpInReductionClause::pool_size-1]);
   66468           0 :                 ++block;
   66469             :              }
   66470             :         }
   66471           0 :    }
   66472             : 
   66473           5 : void SgOmpInReductionClause::deleteMemoryPool() {
   66474           5 :   for (auto p: SgOmpInReductionClause::pools) {
   66475           0 :     ROSE_FREE(p);
   66476             :   }
   66477           5 :   SgOmpInReductionClause::next_node = nullptr;
   66478           5 :   SgOmpInReductionClause::pools.clear();
   66479           5 : }
   66480             : 
   66481             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   66482             : //                 reading multiple binary files to for a single AST.
   66483             : /////////// new version ////////////////////////////////
   66484             : //############################################################################
   66485             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   66486             : void
   66487           2 : SgOmpInReductionClause::extendMemoryPoolForFileIO( )
   66488             :   {
   66489           2 :     size_t blockIndex = SgOmpInReductionClause::pools.size();
   66490           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInReductionClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInReductionClause);
   66491             : 
   66492           2 :     while ( (blockIndex * SgOmpInReductionClause::pool_size) < newPoolSize)
   66493             :       {
   66494             : #if ROSE_ALLOC_TRACE
   66495             :         if (blockIndex > 0) {
   66496             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInReductionClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInReductionClause) = %" PRIuPTR " SgOmpInReductionClause::pool_size = %d \n",
   66497             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpInReductionClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpInReductionClause),SgOmpInReductionClause::pool_size);
   66498             :         }
   66499             : #endif
   66500             : 
   66501           0 :         SgOmpInReductionClause * pointer = (SgOmpInReductionClause*) ROSE_MALLOC ( SgOmpInReductionClause::pool_size * sizeof(SgOmpInReductionClause) );
   66502           0 :         assert( pointer != NULL );
   66503             : #if ROSE_ALLOC_MEMSET == 1
   66504             :         memset(pointer, 0x00, SgOmpInReductionClause::pool_size * sizeof(SgOmpInReductionClause));
   66505             : #elif ROSE_ALLOC_MEMSET == 2
   66506             :         memset(pointer, 0xCC, SgOmpInReductionClause::pool_size * sizeof(SgOmpInReductionClause));
   66507             : #endif
   66508           0 :         SgOmpInReductionClause::pools.push_back( (unsigned char*)(pointer) );
   66509           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpInReductionClause::pool_size * sizeof(SgOmpInReductionClause), V_SgOmpInReductionClause ) );
   66510             : 
   66511           0 :         if ( SgOmpInReductionClause::next_node != NULL ) {
   66512           0 :           if ( blockIndex > 0 ) {
   66513           0 :             SgOmpInReductionClause * blkptr = (SgOmpInReductionClause*)(SgOmpInReductionClause::pools[blockIndex-1]);
   66514           0 :             blkptr[ SgOmpInReductionClause::pool_size - 1 ].set_freepointer(pointer);
   66515             :           }
   66516             :         } else {
   66517           0 :           SgOmpInReductionClause::next_node = pointer;
   66518             :         }
   66519             : 
   66520           0 :         for (unsigned i = 0; i < SgOmpInReductionClause::pool_size-1; ++i)
   66521             :            {
   66522           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   66523             :            }
   66524           0 :         pointer[ SgOmpInReductionClause::pool_size -1 ].set_freepointer(NULL);
   66525             : 
   66526           0 :         blockIndex++;
   66527             :       }
   66528           2 :   }
   66529             : 
   66530             : //############################################################################
   66531             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   66532             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   66533             :  * not compressed. However, that stuff is not yet implemented! 
   66534             :  */
   66535             : unsigned long
   66536           0 : SgOmpInReductionClause::getNumberOfLastValidPointer()
   66537             :    {
   66538           0 :       SgOmpInReductionClause* testPointer = (SgOmpInReductionClause*)(SgOmpInReductionClause::pools.back());
   66539           0 :       unsigned long localIndex = SgOmpInReductionClause::pool_size - 1;
   66540           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   66541             :          {
   66542           0 :            localIndex--;
   66543             :          }
   66544           0 :       return (localIndex + SgOmpInReductionClause::pool_size * (SgOmpInReductionClause::pools.size()-1));
   66545             :    }
   66546             : 
   66547             : //############################################################################
   66548             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   66549             :  * memory pool and initializes the data member in class SgOmpInReductionClauseStroageClass
   66550             :  * from its counterpart of SgOmpInReductionClause. The return value is just for checking, 
   66551             :  * that the whole StorageClassArray is initialized!
   66552             :  */
   66553             : unsigned long
   66554           0 : SgOmpInReductionClause::initializeStorageClassArray( SgOmpInReductionClauseStorageClass *storageArray )
   66555             :    {
   66556           0 :      unsigned long storageCounter = 0;
   66557           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpInReductionClause::pools.begin();
   66558           0 :      SgOmpInReductionClause* pointer = NULL;
   66559           0 :      while ( block != SgOmpInReductionClause::pools.end() ) {
   66560           0 :           pointer = (SgOmpInReductionClause*) (*block);
   66561           0 :           for ( unsigned i = 0; i < SgOmpInReductionClause::pool_size; ++i ) {
   66562           0 :                if ( pointer->get_freepointer() != NULL ) {
   66563           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   66564           0 :                  storageArray++;
   66565           0 :                  storageCounter++;
   66566             :                }
   66567           0 :                pointer++;
   66568             :              }
   66569           0 :            block++;
   66570             :         }
   66571           0 :      return storageCounter;
   66572             :    }
   66573             : 
   66574             : /* #line 66575 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   66575             : 
   66576             : 
   66577             : 
   66578             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   66579             : 
   66580             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   66581             : 
   66582             : //############################################################################
   66583             : /* JH (02/02/2006) Constructor of the IR node SgOmpTaskReductionClause that takes its 
   66584             :  * corresponding StorageClass as parameter
   66585             :  */
   66586           0 : SgOmpTaskReductionClause :: SgOmpTaskReductionClause ( const SgOmpTaskReductionClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   66587             :    {
   66588             : 
   66589             : 
   66590             : /* #line 66591 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   66591             : 
   66592           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   66593           0 :      p_identifier = storageSource.storageOf_identifier ;
   66594           0 :      p_user_defined_identifier =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_defined_identifier) );
   66595             : 
   66596             : 
   66597             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   66598             : 
   66599             : 
   66600           0 :    }
   66601             : 
   66602             : //############################################################################
   66603             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   66604             :  * within the working AST. 
   66605             :  */
   66606           0 : SgOmpTaskReductionClause * SgOmpTaskReductionClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   66607           0 :      SgOmpTaskReductionClause* returnPointer = NULL;
   66608           0 :      if ( globalIndex != 0 )
   66609             :         {
   66610             : 
   66611             : #if FILE_IO_EXTRA_CHECK
   66612           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTaskReductionClause ) ) <= globalIndex ) ;
   66613           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskReductionClause + 1 ) ) );
   66614             : #endif
   66615           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskReductionClause )  
   66616           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTaskReductionClause );
   66617           0 :           unsigned long positionInPool = localIndex % SgOmpTaskReductionClause::pool_size;
   66618           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskReductionClause::pool_size;
   66619             : 
   66620             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   66621             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   66622             : 
   66623           0 :           returnPointer = &( ( (SgOmpTaskReductionClause*)(SgOmpTaskReductionClause::pools[memoryBlock]) ) [positionInPool]) ;
   66624             : 
   66625           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   66626             :         }
   66627           0 :      return returnPointer ;
   66628             :    }
   66629             : 
   66630             : //############################################################################
   66631             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   66632             :   for the AST with the index astIndex
   66633             : */
   66634           0 : SgOmpTaskReductionClause * SgOmpTaskReductionClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   66635           0 :      SgOmpTaskReductionClause* returnPointer = NULL;
   66636           0 :      if ( globalIndex != 0 )
   66637             :         {
   66638             : 
   66639             : #if FILE_IO_EXTRA_CHECK
   66640           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTaskReductionClause ) ) <= globalIndex ) ;
   66641           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskReductionClause + 1 ) ) );
   66642             : #endif
   66643           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskReductionClause )
   66644           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTaskReductionClause );
   66645           0 :           unsigned long positionInPool = localIndex % SgOmpTaskReductionClause::pool_size ;
   66646           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskReductionClause::pool_size ;
   66647             : 
   66648             : #if FILE_IO_EXTRA_CHECK
   66649             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   66650             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   66651             : #endif
   66652             : 
   66653           0 :           returnPointer = &( ( (SgOmpTaskReductionClause*)(SgOmpTaskReductionClause::pools[memoryBlock]) ) [positionInPool]) ;
   66654             : 
   66655             : #if FILE_IO_EXTRA_CHECK
   66656           0 :           assert ( returnPointer != NULL ) ;
   66657             : #endif
   66658             :         }
   66659           0 :      return returnPointer ;
   66660             :    }
   66661             : 
   66662             : //############################################################################
   66663             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   66664             :  * pool size! We set for every valid object in the memory pool the freepointer
   66665             :  * to the global index and increase the global index afterwards. For all the 
   66666             :  * invalid objects (means address ranges within the memory pool that were not
   66667             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   66668             :  * distinguish valid from invalid objects! 
   66669             :  */
   66670             : unsigned long
   66671           5 : SgOmpTaskReductionClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   66672             :    {
   66673           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   66674           5 :      SgOmpTaskReductionClause* pointer = NULL;
   66675           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   66676           5 :      std::vector < unsigned char* > :: const_iterator block;
   66677           5 :      for ( block = SgOmpTaskReductionClause::pools.begin(); block != SgOmpTaskReductionClause::pools.end() ; ++block )
   66678             :         {
   66679           0 :           pointer = (SgOmpTaskReductionClause*)(*block);
   66680           0 :           for (unsigned i = 0; i < SgOmpTaskReductionClause::pool_size; ++i )
   66681             :              {
   66682             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   66683             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   66684             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   66685             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   66686             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   66687             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   66688             :             // properly; so this will have to be checked next.
   66689             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   66690             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   66691           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   66692             :                   {
   66693           0 :                     pointer[i].set_freepointer((SgOmpTaskReductionClause*)(globalIndex));
   66694           0 :                     globalIndex++;
   66695             :                   }
   66696             :                else
   66697             :                   {
   66698           0 :                     pointer[i].set_freepointer(NULL);
   66699             :                   }
   66700             :               }
   66701             :         }
   66702           5 :      return globalIndex;
   66703             :    }
   66704             : 
   66705             : //############################################################################
   66706             : // JH (01/14/2006)
   66707             : void
   66708           5 : SgOmpTaskReductionClause::resetValidFreepointers( )
   66709             :    {
   66710           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   66711           5 :      SgOmpTaskReductionClause* pointer = NULL;
   66712           5 :      std::vector < unsigned char* > :: const_iterator block;
   66713           5 :      SgOmpTaskReductionClause* pointerOfLinkedList = NULL;
   66714           5 :      for ( block = SgOmpTaskReductionClause::pools.begin(); block != SgOmpTaskReductionClause::pools.end() ; ++block )
   66715             :         {
   66716           0 :           pointer = (SgOmpTaskReductionClause*)(*block);
   66717           0 :           for (unsigned i = 0; i < SgOmpTaskReductionClause::pool_size; ++i )
   66718             :              {
   66719             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   66720             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   66721             :             // memory blocks!.
   66722           0 :                if ( pointer[i].get_freepointer() != NULL )
   66723             :                   {
   66724           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   66725             :                   }
   66726             :                else
   66727             :                   {
   66728           0 :                     if ( pointerOfLinkedList == NULL )
   66729             :                        {
   66730           0 :                          SgOmpTaskReductionClause::next_node = &(pointer[i]);
   66731             :                        }
   66732             :                     else
   66733             :                        {
   66734             :                       // printf ("In SgOmpTaskReductionClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   66735           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   66736             :                        }
   66737             :                     pointerOfLinkedList = &(pointer[i]);
   66738             :                   }
   66739             :               }
   66740             :         }
   66741             : 
   66742           5 :      if ( pointerOfLinkedList != NULL )
   66743             :         {
   66744             :        // printf ("In SgOmpTaskReductionClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   66745           0 :           pointerOfLinkedList->set_freepointer(NULL);
   66746             :        // DQ (6/6/2010): Temporary debugging...
   66747             :        //   ROSE_ASSERT(false);
   66748             :         }
   66749             : 
   66750           5 :      return ;
   66751             :    }
   66752             : 
   66753             : //############################################################################
   66754             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   66755             :  * within the memory pool and resets the freepointers, in order to achieve a 
   66756             :  * linked list, that has no jumps and starts at the beginning! This function 
   66757             :  * does not extend the memory pool, since we do not delete any memory blocks,
   66758             :  * but delete the valid objects.  
   66759             :  */
   66760             : void
   66761           0 : SgOmpTaskReductionClause::clearMemoryPool( )
   66762             :    {
   66763             :   // printf ("Inside of SgOmpTaskReductionClause::clearMemoryPool() \n");
   66764             : 
   66765           0 :      SgOmpTaskReductionClause* pointer = NULL, *tempPointer = NULL;
   66766           0 :      std::vector < unsigned char* > :: const_iterator block;
   66767           0 :      if ( SgOmpTaskReductionClause::pools.empty() == false )
   66768             :         {
   66769           0 :           block = SgOmpTaskReductionClause::pools.begin() ;
   66770           0 :           SgOmpTaskReductionClause::next_node = (SgOmpTaskReductionClause*) (*block);
   66771             : 
   66772           0 :           while ( block != SgOmpTaskReductionClause::pools.end() )
   66773             :              {
   66774           0 :                pointer = (SgOmpTaskReductionClause*) (*block);
   66775           0 :                if ( tempPointer != NULL )
   66776             :                   {
   66777           0 :                     tempPointer->set_freepointer(pointer);
   66778             :                   }
   66779           0 :                for (unsigned i = 0; i < SgOmpTaskReductionClause::pool_size - 1; ++i)
   66780             :                   {
   66781           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   66782             :                   }
   66783           0 :                 pointer[SgOmpTaskReductionClause::pool_size-1].set_freepointer(NULL);
   66784           0 :                 tempPointer = &(pointer[SgOmpTaskReductionClause::pool_size-1]);
   66785           0 :                 ++block;
   66786             :              }
   66787             :         }
   66788           0 :    }
   66789             : 
   66790           5 : void SgOmpTaskReductionClause::deleteMemoryPool() {
   66791           5 :   for (auto p: SgOmpTaskReductionClause::pools) {
   66792           0 :     ROSE_FREE(p);
   66793             :   }
   66794           5 :   SgOmpTaskReductionClause::next_node = nullptr;
   66795           5 :   SgOmpTaskReductionClause::pools.clear();
   66796           5 : }
   66797             : 
   66798             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   66799             : //                 reading multiple binary files to for a single AST.
   66800             : /////////// new version ////////////////////////////////
   66801             : //############################################################################
   66802             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   66803             : void
   66804           2 : SgOmpTaskReductionClause::extendMemoryPoolForFileIO( )
   66805             :   {
   66806           2 :     size_t blockIndex = SgOmpTaskReductionClause::pools.size();
   66807           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskReductionClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskReductionClause);
   66808             : 
   66809           2 :     while ( (blockIndex * SgOmpTaskReductionClause::pool_size) < newPoolSize)
   66810             :       {
   66811             : #if ROSE_ALLOC_TRACE
   66812             :         if (blockIndex > 0) {
   66813             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskReductionClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskReductionClause) = %" PRIuPTR " SgOmpTaskReductionClause::pool_size = %d \n",
   66814             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskReductionClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskReductionClause),SgOmpTaskReductionClause::pool_size);
   66815             :         }
   66816             : #endif
   66817             : 
   66818           0 :         SgOmpTaskReductionClause * pointer = (SgOmpTaskReductionClause*) ROSE_MALLOC ( SgOmpTaskReductionClause::pool_size * sizeof(SgOmpTaskReductionClause) );
   66819           0 :         assert( pointer != NULL );
   66820             : #if ROSE_ALLOC_MEMSET == 1
   66821             :         memset(pointer, 0x00, SgOmpTaskReductionClause::pool_size * sizeof(SgOmpTaskReductionClause));
   66822             : #elif ROSE_ALLOC_MEMSET == 2
   66823             :         memset(pointer, 0xCC, SgOmpTaskReductionClause::pool_size * sizeof(SgOmpTaskReductionClause));
   66824             : #endif
   66825           0 :         SgOmpTaskReductionClause::pools.push_back( (unsigned char*)(pointer) );
   66826           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTaskReductionClause::pool_size * sizeof(SgOmpTaskReductionClause), V_SgOmpTaskReductionClause ) );
   66827             : 
   66828           0 :         if ( SgOmpTaskReductionClause::next_node != NULL ) {
   66829           0 :           if ( blockIndex > 0 ) {
   66830           0 :             SgOmpTaskReductionClause * blkptr = (SgOmpTaskReductionClause*)(SgOmpTaskReductionClause::pools[blockIndex-1]);
   66831           0 :             blkptr[ SgOmpTaskReductionClause::pool_size - 1 ].set_freepointer(pointer);
   66832             :           }
   66833             :         } else {
   66834           0 :           SgOmpTaskReductionClause::next_node = pointer;
   66835             :         }
   66836             : 
   66837           0 :         for (unsigned i = 0; i < SgOmpTaskReductionClause::pool_size-1; ++i)
   66838             :            {
   66839           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   66840             :            }
   66841           0 :         pointer[ SgOmpTaskReductionClause::pool_size -1 ].set_freepointer(NULL);
   66842             : 
   66843           0 :         blockIndex++;
   66844             :       }
   66845           2 :   }
   66846             : 
   66847             : //############################################################################
   66848             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   66849             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   66850             :  * not compressed. However, that stuff is not yet implemented! 
   66851             :  */
   66852             : unsigned long
   66853           0 : SgOmpTaskReductionClause::getNumberOfLastValidPointer()
   66854             :    {
   66855           0 :       SgOmpTaskReductionClause* testPointer = (SgOmpTaskReductionClause*)(SgOmpTaskReductionClause::pools.back());
   66856           0 :       unsigned long localIndex = SgOmpTaskReductionClause::pool_size - 1;
   66857           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   66858             :          {
   66859           0 :            localIndex--;
   66860             :          }
   66861           0 :       return (localIndex + SgOmpTaskReductionClause::pool_size * (SgOmpTaskReductionClause::pools.size()-1));
   66862             :    }
   66863             : 
   66864             : //############################################################################
   66865             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   66866             :  * memory pool and initializes the data member in class SgOmpTaskReductionClauseStroageClass
   66867             :  * from its counterpart of SgOmpTaskReductionClause. The return value is just for checking, 
   66868             :  * that the whole StorageClassArray is initialized!
   66869             :  */
   66870             : unsigned long
   66871           0 : SgOmpTaskReductionClause::initializeStorageClassArray( SgOmpTaskReductionClauseStorageClass *storageArray )
   66872             :    {
   66873           0 :      unsigned long storageCounter = 0;
   66874           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTaskReductionClause::pools.begin();
   66875           0 :      SgOmpTaskReductionClause* pointer = NULL;
   66876           0 :      while ( block != SgOmpTaskReductionClause::pools.end() ) {
   66877           0 :           pointer = (SgOmpTaskReductionClause*) (*block);
   66878           0 :           for ( unsigned i = 0; i < SgOmpTaskReductionClause::pool_size; ++i ) {
   66879           0 :                if ( pointer->get_freepointer() != NULL ) {
   66880           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   66881           0 :                  storageArray++;
   66882           0 :                  storageCounter++;
   66883             :                }
   66884           0 :                pointer++;
   66885             :              }
   66886           0 :            block++;
   66887             :         }
   66888           0 :      return storageCounter;
   66889             :    }
   66890             : 
   66891             : /* #line 66892 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   66892             : 
   66893             : 
   66894             : 
   66895             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   66896             : 
   66897             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   66898             : 
   66899             : //############################################################################
   66900             : /* JH (02/02/2006) Constructor of the IR node SgOmpMapClause that takes its 
   66901             :  * corresponding StorageClass as parameter
   66902             :  */
   66903           0 : SgOmpMapClause :: SgOmpMapClause ( const SgOmpMapClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   66904             :    {
   66905             : 
   66906             : 
   66907             : /* #line 66908 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   66908             : 
   66909           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   66910           0 :      p_operation = storageSource.storageOf_operation ;
   66911           0 :      p_array_dimensions = storageSource.storageOf_array_dimensions.rebuildDataStoredInEasyStorageClass() ;
   66912           0 :      p_dist_data_policies = storageSource.storageOf_dist_data_policies.rebuildDataStoredInEasyStorageClass() ;
   66913             : 
   66914             : 
   66915             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   66916             : 
   66917             : 
   66918           0 :    }
   66919             : 
   66920             : //############################################################################
   66921             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   66922             :  * within the working AST. 
   66923             :  */
   66924           0 : SgOmpMapClause * SgOmpMapClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   66925           0 :      SgOmpMapClause* returnPointer = NULL;
   66926           0 :      if ( globalIndex != 0 )
   66927             :         {
   66928             : 
   66929             : #if FILE_IO_EXTRA_CHECK
   66930           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpMapClause ) ) <= globalIndex ) ;
   66931           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMapClause + 1 ) ) );
   66932             : #endif
   66933           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMapClause )  
   66934           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpMapClause );
   66935           0 :           unsigned long positionInPool = localIndex % SgOmpMapClause::pool_size;
   66936           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMapClause::pool_size;
   66937             : 
   66938             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   66939             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   66940             : 
   66941           0 :           returnPointer = &( ( (SgOmpMapClause*)(SgOmpMapClause::pools[memoryBlock]) ) [positionInPool]) ;
   66942             : 
   66943           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   66944             :         }
   66945           0 :      return returnPointer ;
   66946             :    }
   66947             : 
   66948             : //############################################################################
   66949             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   66950             :   for the AST with the index astIndex
   66951             : */
   66952           0 : SgOmpMapClause * SgOmpMapClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   66953           0 :      SgOmpMapClause* returnPointer = NULL;
   66954           0 :      if ( globalIndex != 0 )
   66955             :         {
   66956             : 
   66957             : #if FILE_IO_EXTRA_CHECK
   66958           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpMapClause ) ) <= globalIndex ) ;
   66959           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMapClause + 1 ) ) );
   66960             : #endif
   66961           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMapClause )
   66962           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpMapClause );
   66963           0 :           unsigned long positionInPool = localIndex % SgOmpMapClause::pool_size ;
   66964           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMapClause::pool_size ;
   66965             : 
   66966             : #if FILE_IO_EXTRA_CHECK
   66967             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   66968             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   66969             : #endif
   66970             : 
   66971           0 :           returnPointer = &( ( (SgOmpMapClause*)(SgOmpMapClause::pools[memoryBlock]) ) [positionInPool]) ;
   66972             : 
   66973             : #if FILE_IO_EXTRA_CHECK
   66974           0 :           assert ( returnPointer != NULL ) ;
   66975             : #endif
   66976             :         }
   66977           0 :      return returnPointer ;
   66978             :    }
   66979             : 
   66980             : //############################################################################
   66981             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   66982             :  * pool size! We set for every valid object in the memory pool the freepointer
   66983             :  * to the global index and increase the global index afterwards. For all the 
   66984             :  * invalid objects (means address ranges within the memory pool that were not
   66985             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   66986             :  * distinguish valid from invalid objects! 
   66987             :  */
   66988             : unsigned long
   66989           5 : SgOmpMapClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   66990             :    {
   66991           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   66992           5 :      SgOmpMapClause* pointer = NULL;
   66993           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   66994           5 :      std::vector < unsigned char* > :: const_iterator block;
   66995           5 :      for ( block = SgOmpMapClause::pools.begin(); block != SgOmpMapClause::pools.end() ; ++block )
   66996             :         {
   66997           0 :           pointer = (SgOmpMapClause*)(*block);
   66998           0 :           for (unsigned i = 0; i < SgOmpMapClause::pool_size; ++i )
   66999             :              {
   67000             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   67001             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   67002             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   67003             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   67004             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   67005             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   67006             :             // properly; so this will have to be checked next.
   67007             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   67008             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   67009           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   67010             :                   {
   67011           0 :                     pointer[i].set_freepointer((SgOmpMapClause*)(globalIndex));
   67012           0 :                     globalIndex++;
   67013             :                   }
   67014             :                else
   67015             :                   {
   67016           0 :                     pointer[i].set_freepointer(NULL);
   67017             :                   }
   67018             :               }
   67019             :         }
   67020           5 :      return globalIndex;
   67021             :    }
   67022             : 
   67023             : //############################################################################
   67024             : // JH (01/14/2006)
   67025             : void
   67026           5 : SgOmpMapClause::resetValidFreepointers( )
   67027             :    {
   67028           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   67029           5 :      SgOmpMapClause* pointer = NULL;
   67030           5 :      std::vector < unsigned char* > :: const_iterator block;
   67031           5 :      SgOmpMapClause* pointerOfLinkedList = NULL;
   67032           5 :      for ( block = SgOmpMapClause::pools.begin(); block != SgOmpMapClause::pools.end() ; ++block )
   67033             :         {
   67034           0 :           pointer = (SgOmpMapClause*)(*block);
   67035           0 :           for (unsigned i = 0; i < SgOmpMapClause::pool_size; ++i )
   67036             :              {
   67037             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   67038             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   67039             :             // memory blocks!.
   67040           0 :                if ( pointer[i].get_freepointer() != NULL )
   67041             :                   {
   67042           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   67043             :                   }
   67044             :                else
   67045             :                   {
   67046           0 :                     if ( pointerOfLinkedList == NULL )
   67047             :                        {
   67048           0 :                          SgOmpMapClause::next_node = &(pointer[i]);
   67049             :                        }
   67050             :                     else
   67051             :                        {
   67052             :                       // printf ("In SgOmpMapClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   67053           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   67054             :                        }
   67055             :                     pointerOfLinkedList = &(pointer[i]);
   67056             :                   }
   67057             :               }
   67058             :         }
   67059             : 
   67060           5 :      if ( pointerOfLinkedList != NULL )
   67061             :         {
   67062             :        // printf ("In SgOmpMapClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   67063           0 :           pointerOfLinkedList->set_freepointer(NULL);
   67064             :        // DQ (6/6/2010): Temporary debugging...
   67065             :        //   ROSE_ASSERT(false);
   67066             :         }
   67067             : 
   67068           5 :      return ;
   67069             :    }
   67070             : 
   67071             : //############################################################################
   67072             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   67073             :  * within the memory pool and resets the freepointers, in order to achieve a 
   67074             :  * linked list, that has no jumps and starts at the beginning! This function 
   67075             :  * does not extend the memory pool, since we do not delete any memory blocks,
   67076             :  * but delete the valid objects.  
   67077             :  */
   67078             : void
   67079           0 : SgOmpMapClause::clearMemoryPool( )
   67080             :    {
   67081             :   // printf ("Inside of SgOmpMapClause::clearMemoryPool() \n");
   67082             : 
   67083           0 :      SgOmpMapClause* pointer = NULL, *tempPointer = NULL;
   67084           0 :      std::vector < unsigned char* > :: const_iterator block;
   67085           0 :      if ( SgOmpMapClause::pools.empty() == false )
   67086             :         {
   67087           0 :           block = SgOmpMapClause::pools.begin() ;
   67088           0 :           SgOmpMapClause::next_node = (SgOmpMapClause*) (*block);
   67089             : 
   67090           0 :           while ( block != SgOmpMapClause::pools.end() )
   67091             :              {
   67092           0 :                pointer = (SgOmpMapClause*) (*block);
   67093           0 :                if ( tempPointer != NULL )
   67094             :                   {
   67095           0 :                     tempPointer->set_freepointer(pointer);
   67096             :                   }
   67097           0 :                for (unsigned i = 0; i < SgOmpMapClause::pool_size - 1; ++i)
   67098             :                   {
   67099           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   67100             :                   }
   67101           0 :                 pointer[SgOmpMapClause::pool_size-1].set_freepointer(NULL);
   67102           0 :                 tempPointer = &(pointer[SgOmpMapClause::pool_size-1]);
   67103           0 :                 ++block;
   67104             :              }
   67105             :         }
   67106           0 :    }
   67107             : 
   67108           5 : void SgOmpMapClause::deleteMemoryPool() {
   67109           5 :   for (auto p: SgOmpMapClause::pools) {
   67110           0 :     ROSE_FREE(p);
   67111             :   }
   67112           5 :   SgOmpMapClause::next_node = nullptr;
   67113           5 :   SgOmpMapClause::pools.clear();
   67114           5 : }
   67115             : 
   67116             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   67117             : //                 reading multiple binary files to for a single AST.
   67118             : /////////// new version ////////////////////////////////
   67119             : //############################################################################
   67120             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   67121             : void
   67122           2 : SgOmpMapClause::extendMemoryPoolForFileIO( )
   67123             :   {
   67124           2 :     size_t blockIndex = SgOmpMapClause::pools.size();
   67125           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMapClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMapClause);
   67126             : 
   67127           2 :     while ( (blockIndex * SgOmpMapClause::pool_size) < newPoolSize)
   67128             :       {
   67129             : #if ROSE_ALLOC_TRACE
   67130             :         if (blockIndex > 0) {
   67131             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMapClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMapClause) = %" PRIuPTR " SgOmpMapClause::pool_size = %d \n",
   67132             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMapClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMapClause),SgOmpMapClause::pool_size);
   67133             :         }
   67134             : #endif
   67135             : 
   67136           0 :         SgOmpMapClause * pointer = (SgOmpMapClause*) ROSE_MALLOC ( SgOmpMapClause::pool_size * sizeof(SgOmpMapClause) );
   67137           0 :         assert( pointer != NULL );
   67138             : #if ROSE_ALLOC_MEMSET == 1
   67139             :         memset(pointer, 0x00, SgOmpMapClause::pool_size * sizeof(SgOmpMapClause));
   67140             : #elif ROSE_ALLOC_MEMSET == 2
   67141             :         memset(pointer, 0xCC, SgOmpMapClause::pool_size * sizeof(SgOmpMapClause));
   67142             : #endif
   67143           0 :         SgOmpMapClause::pools.push_back( (unsigned char*)(pointer) );
   67144           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpMapClause::pool_size * sizeof(SgOmpMapClause), V_SgOmpMapClause ) );
   67145             : 
   67146           0 :         if ( SgOmpMapClause::next_node != NULL ) {
   67147           0 :           if ( blockIndex > 0 ) {
   67148           0 :             SgOmpMapClause * blkptr = (SgOmpMapClause*)(SgOmpMapClause::pools[blockIndex-1]);
   67149           0 :             blkptr[ SgOmpMapClause::pool_size - 1 ].set_freepointer(pointer);
   67150             :           }
   67151             :         } else {
   67152           0 :           SgOmpMapClause::next_node = pointer;
   67153             :         }
   67154             : 
   67155           0 :         for (unsigned i = 0; i < SgOmpMapClause::pool_size-1; ++i)
   67156             :            {
   67157           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   67158             :            }
   67159           0 :         pointer[ SgOmpMapClause::pool_size -1 ].set_freepointer(NULL);
   67160             : 
   67161           0 :         blockIndex++;
   67162             :       }
   67163           2 :   }
   67164             : 
   67165             : //############################################################################
   67166             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   67167             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   67168             :  * not compressed. However, that stuff is not yet implemented! 
   67169             :  */
   67170             : unsigned long
   67171           0 : SgOmpMapClause::getNumberOfLastValidPointer()
   67172             :    {
   67173           0 :       SgOmpMapClause* testPointer = (SgOmpMapClause*)(SgOmpMapClause::pools.back());
   67174           0 :       unsigned long localIndex = SgOmpMapClause::pool_size - 1;
   67175           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   67176             :          {
   67177           0 :            localIndex--;
   67178             :          }
   67179           0 :       return (localIndex + SgOmpMapClause::pool_size * (SgOmpMapClause::pools.size()-1));
   67180             :    }
   67181             : 
   67182             : //############################################################################
   67183             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   67184             :  * memory pool and initializes the data member in class SgOmpMapClauseStroageClass
   67185             :  * from its counterpart of SgOmpMapClause. The return value is just for checking, 
   67186             :  * that the whole StorageClassArray is initialized!
   67187             :  */
   67188             : unsigned long
   67189           0 : SgOmpMapClause::initializeStorageClassArray( SgOmpMapClauseStorageClass *storageArray )
   67190             :    {
   67191           0 :      unsigned long storageCounter = 0;
   67192           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpMapClause::pools.begin();
   67193           0 :      SgOmpMapClause* pointer = NULL;
   67194           0 :      while ( block != SgOmpMapClause::pools.end() ) {
   67195           0 :           pointer = (SgOmpMapClause*) (*block);
   67196           0 :           for ( unsigned i = 0; i < SgOmpMapClause::pool_size; ++i ) {
   67197           0 :                if ( pointer->get_freepointer() != NULL ) {
   67198           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   67199           0 :                  storageArray++;
   67200           0 :                  storageCounter++;
   67201             :                }
   67202           0 :                pointer++;
   67203             :              }
   67204           0 :            block++;
   67205             :         }
   67206           0 :      return storageCounter;
   67207             :    }
   67208             : 
   67209             : /* #line 67210 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   67210             : 
   67211             : 
   67212             : 
   67213             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   67214             : 
   67215             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   67216             : 
   67217             : //############################################################################
   67218             : /* JH (02/02/2006) Constructor of the IR node SgOmpAllocateClause that takes its 
   67219             :  * corresponding StorageClass as parameter
   67220             :  */
   67221           0 : SgOmpAllocateClause :: SgOmpAllocateClause ( const SgOmpAllocateClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   67222             :    {
   67223             : 
   67224             : 
   67225             : /* #line 67226 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   67226             : 
   67227           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   67228           0 :      p_modifier = storageSource.storageOf_modifier ;
   67229           0 :      p_user_defined_modifier =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_defined_modifier) );
   67230             : 
   67231             : 
   67232             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   67233             : 
   67234             : 
   67235           0 :    }
   67236             : 
   67237             : //############################################################################
   67238             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   67239             :  * within the working AST. 
   67240             :  */
   67241           0 : SgOmpAllocateClause * SgOmpAllocateClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   67242           0 :      SgOmpAllocateClause* returnPointer = NULL;
   67243           0 :      if ( globalIndex != 0 )
   67244             :         {
   67245             : 
   67246             : #if FILE_IO_EXTRA_CHECK
   67247           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAllocateClause ) ) <= globalIndex ) ;
   67248           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAllocateClause + 1 ) ) );
   67249             : #endif
   67250           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAllocateClause )  
   67251           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAllocateClause );
   67252           0 :           unsigned long positionInPool = localIndex % SgOmpAllocateClause::pool_size;
   67253           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAllocateClause::pool_size;
   67254             : 
   67255             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   67256             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   67257             : 
   67258           0 :           returnPointer = &( ( (SgOmpAllocateClause*)(SgOmpAllocateClause::pools[memoryBlock]) ) [positionInPool]) ;
   67259             : 
   67260           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   67261             :         }
   67262           0 :      return returnPointer ;
   67263             :    }
   67264             : 
   67265             : //############################################################################
   67266             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   67267             :   for the AST with the index astIndex
   67268             : */
   67269           0 : SgOmpAllocateClause * SgOmpAllocateClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   67270           0 :      SgOmpAllocateClause* returnPointer = NULL;
   67271           0 :      if ( globalIndex != 0 )
   67272             :         {
   67273             : 
   67274             : #if FILE_IO_EXTRA_CHECK
   67275           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAllocateClause ) ) <= globalIndex ) ;
   67276           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAllocateClause + 1 ) ) );
   67277             : #endif
   67278           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAllocateClause )
   67279           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAllocateClause );
   67280           0 :           unsigned long positionInPool = localIndex % SgOmpAllocateClause::pool_size ;
   67281           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAllocateClause::pool_size ;
   67282             : 
   67283             : #if FILE_IO_EXTRA_CHECK
   67284             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   67285             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   67286             : #endif
   67287             : 
   67288           0 :           returnPointer = &( ( (SgOmpAllocateClause*)(SgOmpAllocateClause::pools[memoryBlock]) ) [positionInPool]) ;
   67289             : 
   67290             : #if FILE_IO_EXTRA_CHECK
   67291           0 :           assert ( returnPointer != NULL ) ;
   67292             : #endif
   67293             :         }
   67294           0 :      return returnPointer ;
   67295             :    }
   67296             : 
   67297             : //############################################################################
   67298             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   67299             :  * pool size! We set for every valid object in the memory pool the freepointer
   67300             :  * to the global index and increase the global index afterwards. For all the 
   67301             :  * invalid objects (means address ranges within the memory pool that were not
   67302             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   67303             :  * distinguish valid from invalid objects! 
   67304             :  */
   67305             : unsigned long
   67306           5 : SgOmpAllocateClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   67307             :    {
   67308           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   67309           5 :      SgOmpAllocateClause* pointer = NULL;
   67310           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   67311           5 :      std::vector < unsigned char* > :: const_iterator block;
   67312           5 :      for ( block = SgOmpAllocateClause::pools.begin(); block != SgOmpAllocateClause::pools.end() ; ++block )
   67313             :         {
   67314           0 :           pointer = (SgOmpAllocateClause*)(*block);
   67315           0 :           for (unsigned i = 0; i < SgOmpAllocateClause::pool_size; ++i )
   67316             :              {
   67317             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   67318             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   67319             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   67320             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   67321             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   67322             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   67323             :             // properly; so this will have to be checked next.
   67324             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   67325             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   67326           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   67327             :                   {
   67328           0 :                     pointer[i].set_freepointer((SgOmpAllocateClause*)(globalIndex));
   67329           0 :                     globalIndex++;
   67330             :                   }
   67331             :                else
   67332             :                   {
   67333           0 :                     pointer[i].set_freepointer(NULL);
   67334             :                   }
   67335             :               }
   67336             :         }
   67337           5 :      return globalIndex;
   67338             :    }
   67339             : 
   67340             : //############################################################################
   67341             : // JH (01/14/2006)
   67342             : void
   67343           5 : SgOmpAllocateClause::resetValidFreepointers( )
   67344             :    {
   67345           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   67346           5 :      SgOmpAllocateClause* pointer = NULL;
   67347           5 :      std::vector < unsigned char* > :: const_iterator block;
   67348           5 :      SgOmpAllocateClause* pointerOfLinkedList = NULL;
   67349           5 :      for ( block = SgOmpAllocateClause::pools.begin(); block != SgOmpAllocateClause::pools.end() ; ++block )
   67350             :         {
   67351           0 :           pointer = (SgOmpAllocateClause*)(*block);
   67352           0 :           for (unsigned i = 0; i < SgOmpAllocateClause::pool_size; ++i )
   67353             :              {
   67354             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   67355             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   67356             :             // memory blocks!.
   67357           0 :                if ( pointer[i].get_freepointer() != NULL )
   67358             :                   {
   67359           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   67360             :                   }
   67361             :                else
   67362             :                   {
   67363           0 :                     if ( pointerOfLinkedList == NULL )
   67364             :                        {
   67365           0 :                          SgOmpAllocateClause::next_node = &(pointer[i]);
   67366             :                        }
   67367             :                     else
   67368             :                        {
   67369             :                       // printf ("In SgOmpAllocateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   67370           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   67371             :                        }
   67372             :                     pointerOfLinkedList = &(pointer[i]);
   67373             :                   }
   67374             :               }
   67375             :         }
   67376             : 
   67377           5 :      if ( pointerOfLinkedList != NULL )
   67378             :         {
   67379             :        // printf ("In SgOmpAllocateClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   67380           0 :           pointerOfLinkedList->set_freepointer(NULL);
   67381             :        // DQ (6/6/2010): Temporary debugging...
   67382             :        //   ROSE_ASSERT(false);
   67383             :         }
   67384             : 
   67385           5 :      return ;
   67386             :    }
   67387             : 
   67388             : //############################################################################
   67389             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   67390             :  * within the memory pool and resets the freepointers, in order to achieve a 
   67391             :  * linked list, that has no jumps and starts at the beginning! This function 
   67392             :  * does not extend the memory pool, since we do not delete any memory blocks,
   67393             :  * but delete the valid objects.  
   67394             :  */
   67395             : void
   67396           0 : SgOmpAllocateClause::clearMemoryPool( )
   67397             :    {
   67398             :   // printf ("Inside of SgOmpAllocateClause::clearMemoryPool() \n");
   67399             : 
   67400           0 :      SgOmpAllocateClause* pointer = NULL, *tempPointer = NULL;
   67401           0 :      std::vector < unsigned char* > :: const_iterator block;
   67402           0 :      if ( SgOmpAllocateClause::pools.empty() == false )
   67403             :         {
   67404           0 :           block = SgOmpAllocateClause::pools.begin() ;
   67405           0 :           SgOmpAllocateClause::next_node = (SgOmpAllocateClause*) (*block);
   67406             : 
   67407           0 :           while ( block != SgOmpAllocateClause::pools.end() )
   67408             :              {
   67409           0 :                pointer = (SgOmpAllocateClause*) (*block);
   67410           0 :                if ( tempPointer != NULL )
   67411             :                   {
   67412           0 :                     tempPointer->set_freepointer(pointer);
   67413             :                   }
   67414           0 :                for (unsigned i = 0; i < SgOmpAllocateClause::pool_size - 1; ++i)
   67415             :                   {
   67416           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   67417             :                   }
   67418           0 :                 pointer[SgOmpAllocateClause::pool_size-1].set_freepointer(NULL);
   67419           0 :                 tempPointer = &(pointer[SgOmpAllocateClause::pool_size-1]);
   67420           0 :                 ++block;
   67421             :              }
   67422             :         }
   67423           0 :    }
   67424             : 
   67425           5 : void SgOmpAllocateClause::deleteMemoryPool() {
   67426           5 :   for (auto p: SgOmpAllocateClause::pools) {
   67427           0 :     ROSE_FREE(p);
   67428             :   }
   67429           5 :   SgOmpAllocateClause::next_node = nullptr;
   67430           5 :   SgOmpAllocateClause::pools.clear();
   67431           5 : }
   67432             : 
   67433             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   67434             : //                 reading multiple binary files to for a single AST.
   67435             : /////////// new version ////////////////////////////////
   67436             : //############################################################################
   67437             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   67438             : void
   67439           2 : SgOmpAllocateClause::extendMemoryPoolForFileIO( )
   67440             :   {
   67441           2 :     size_t blockIndex = SgOmpAllocateClause::pools.size();
   67442           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocateClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocateClause);
   67443             : 
   67444           2 :     while ( (blockIndex * SgOmpAllocateClause::pool_size) < newPoolSize)
   67445             :       {
   67446             : #if ROSE_ALLOC_TRACE
   67447             :         if (blockIndex > 0) {
   67448             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocateClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocateClause) = %" PRIuPTR " SgOmpAllocateClause::pool_size = %d \n",
   67449             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocateClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocateClause),SgOmpAllocateClause::pool_size);
   67450             :         }
   67451             : #endif
   67452             : 
   67453           0 :         SgOmpAllocateClause * pointer = (SgOmpAllocateClause*) ROSE_MALLOC ( SgOmpAllocateClause::pool_size * sizeof(SgOmpAllocateClause) );
   67454           0 :         assert( pointer != NULL );
   67455             : #if ROSE_ALLOC_MEMSET == 1
   67456             :         memset(pointer, 0x00, SgOmpAllocateClause::pool_size * sizeof(SgOmpAllocateClause));
   67457             : #elif ROSE_ALLOC_MEMSET == 2
   67458             :         memset(pointer, 0xCC, SgOmpAllocateClause::pool_size * sizeof(SgOmpAllocateClause));
   67459             : #endif
   67460           0 :         SgOmpAllocateClause::pools.push_back( (unsigned char*)(pointer) );
   67461           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAllocateClause::pool_size * sizeof(SgOmpAllocateClause), V_SgOmpAllocateClause ) );
   67462             : 
   67463           0 :         if ( SgOmpAllocateClause::next_node != NULL ) {
   67464           0 :           if ( blockIndex > 0 ) {
   67465           0 :             SgOmpAllocateClause * blkptr = (SgOmpAllocateClause*)(SgOmpAllocateClause::pools[blockIndex-1]);
   67466           0 :             blkptr[ SgOmpAllocateClause::pool_size - 1 ].set_freepointer(pointer);
   67467             :           }
   67468             :         } else {
   67469           0 :           SgOmpAllocateClause::next_node = pointer;
   67470             :         }
   67471             : 
   67472           0 :         for (unsigned i = 0; i < SgOmpAllocateClause::pool_size-1; ++i)
   67473             :            {
   67474           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   67475             :            }
   67476           0 :         pointer[ SgOmpAllocateClause::pool_size -1 ].set_freepointer(NULL);
   67477             : 
   67478           0 :         blockIndex++;
   67479             :       }
   67480           2 :   }
   67481             : 
   67482             : //############################################################################
   67483             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   67484             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   67485             :  * not compressed. However, that stuff is not yet implemented! 
   67486             :  */
   67487             : unsigned long
   67488           0 : SgOmpAllocateClause::getNumberOfLastValidPointer()
   67489             :    {
   67490           0 :       SgOmpAllocateClause* testPointer = (SgOmpAllocateClause*)(SgOmpAllocateClause::pools.back());
   67491           0 :       unsigned long localIndex = SgOmpAllocateClause::pool_size - 1;
   67492           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   67493             :          {
   67494           0 :            localIndex--;
   67495             :          }
   67496           0 :       return (localIndex + SgOmpAllocateClause::pool_size * (SgOmpAllocateClause::pools.size()-1));
   67497             :    }
   67498             : 
   67499             : //############################################################################
   67500             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   67501             :  * memory pool and initializes the data member in class SgOmpAllocateClauseStroageClass
   67502             :  * from its counterpart of SgOmpAllocateClause. The return value is just for checking, 
   67503             :  * that the whole StorageClassArray is initialized!
   67504             :  */
   67505             : unsigned long
   67506           0 : SgOmpAllocateClause::initializeStorageClassArray( SgOmpAllocateClauseStorageClass *storageArray )
   67507             :    {
   67508           0 :      unsigned long storageCounter = 0;
   67509           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAllocateClause::pools.begin();
   67510           0 :      SgOmpAllocateClause* pointer = NULL;
   67511           0 :      while ( block != SgOmpAllocateClause::pools.end() ) {
   67512           0 :           pointer = (SgOmpAllocateClause*) (*block);
   67513           0 :           for ( unsigned i = 0; i < SgOmpAllocateClause::pool_size; ++i ) {
   67514           0 :                if ( pointer->get_freepointer() != NULL ) {
   67515           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   67516           0 :                  storageArray++;
   67517           0 :                  storageCounter++;
   67518             :                }
   67519           0 :                pointer++;
   67520             :              }
   67521           0 :            block++;
   67522             :         }
   67523           0 :      return storageCounter;
   67524             :    }
   67525             : 
   67526             : /* #line 67527 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   67527             : 
   67528             : 
   67529             : 
   67530             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   67531             : 
   67532             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   67533             : 
   67534             : //############################################################################
   67535             : /* JH (02/02/2006) Constructor of the IR node SgOmpUniformClause that takes its 
   67536             :  * corresponding StorageClass as parameter
   67537             :  */
   67538           0 : SgOmpUniformClause :: SgOmpUniformClause ( const SgOmpUniformClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   67539             :    {
   67540             : 
   67541             : 
   67542             : /* #line 67543 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   67543             : 
   67544           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   67545             : 
   67546             : 
   67547             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   67548             : 
   67549             : 
   67550           0 :    }
   67551             : 
   67552             : //############################################################################
   67553             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   67554             :  * within the working AST. 
   67555             :  */
   67556           0 : SgOmpUniformClause * SgOmpUniformClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   67557           0 :      SgOmpUniformClause* returnPointer = NULL;
   67558           0 :      if ( globalIndex != 0 )
   67559             :         {
   67560             : 
   67561             : #if FILE_IO_EXTRA_CHECK
   67562           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUniformClause ) ) <= globalIndex ) ;
   67563           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUniformClause + 1 ) ) );
   67564             : #endif
   67565           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUniformClause )  
   67566           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUniformClause );
   67567           0 :           unsigned long positionInPool = localIndex % SgOmpUniformClause::pool_size;
   67568           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUniformClause::pool_size;
   67569             : 
   67570             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   67571             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   67572             : 
   67573           0 :           returnPointer = &( ( (SgOmpUniformClause*)(SgOmpUniformClause::pools[memoryBlock]) ) [positionInPool]) ;
   67574             : 
   67575           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   67576             :         }
   67577           0 :      return returnPointer ;
   67578             :    }
   67579             : 
   67580             : //############################################################################
   67581             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   67582             :   for the AST with the index astIndex
   67583             : */
   67584           0 : SgOmpUniformClause * SgOmpUniformClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   67585           0 :      SgOmpUniformClause* returnPointer = NULL;
   67586           0 :      if ( globalIndex != 0 )
   67587             :         {
   67588             : 
   67589             : #if FILE_IO_EXTRA_CHECK
   67590           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUniformClause ) ) <= globalIndex ) ;
   67591           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUniformClause + 1 ) ) );
   67592             : #endif
   67593           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUniformClause )
   67594           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUniformClause );
   67595           0 :           unsigned long positionInPool = localIndex % SgOmpUniformClause::pool_size ;
   67596           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUniformClause::pool_size ;
   67597             : 
   67598             : #if FILE_IO_EXTRA_CHECK
   67599             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   67600             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   67601             : #endif
   67602             : 
   67603           0 :           returnPointer = &( ( (SgOmpUniformClause*)(SgOmpUniformClause::pools[memoryBlock]) ) [positionInPool]) ;
   67604             : 
   67605             : #if FILE_IO_EXTRA_CHECK
   67606           0 :           assert ( returnPointer != NULL ) ;
   67607             : #endif
   67608             :         }
   67609           0 :      return returnPointer ;
   67610             :    }
   67611             : 
   67612             : //############################################################################
   67613             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   67614             :  * pool size! We set for every valid object in the memory pool the freepointer
   67615             :  * to the global index and increase the global index afterwards. For all the 
   67616             :  * invalid objects (means address ranges within the memory pool that were not
   67617             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   67618             :  * distinguish valid from invalid objects! 
   67619             :  */
   67620             : unsigned long
   67621           5 : SgOmpUniformClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   67622             :    {
   67623           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   67624           5 :      SgOmpUniformClause* pointer = NULL;
   67625           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   67626           5 :      std::vector < unsigned char* > :: const_iterator block;
   67627           5 :      for ( block = SgOmpUniformClause::pools.begin(); block != SgOmpUniformClause::pools.end() ; ++block )
   67628             :         {
   67629           0 :           pointer = (SgOmpUniformClause*)(*block);
   67630           0 :           for (unsigned i = 0; i < SgOmpUniformClause::pool_size; ++i )
   67631             :              {
   67632             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   67633             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   67634             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   67635             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   67636             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   67637             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   67638             :             // properly; so this will have to be checked next.
   67639             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   67640             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   67641           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   67642             :                   {
   67643           0 :                     pointer[i].set_freepointer((SgOmpUniformClause*)(globalIndex));
   67644           0 :                     globalIndex++;
   67645             :                   }
   67646             :                else
   67647             :                   {
   67648           0 :                     pointer[i].set_freepointer(NULL);
   67649             :                   }
   67650             :               }
   67651             :         }
   67652           5 :      return globalIndex;
   67653             :    }
   67654             : 
   67655             : //############################################################################
   67656             : // JH (01/14/2006)
   67657             : void
   67658           5 : SgOmpUniformClause::resetValidFreepointers( )
   67659             :    {
   67660           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   67661           5 :      SgOmpUniformClause* pointer = NULL;
   67662           5 :      std::vector < unsigned char* > :: const_iterator block;
   67663           5 :      SgOmpUniformClause* pointerOfLinkedList = NULL;
   67664           5 :      for ( block = SgOmpUniformClause::pools.begin(); block != SgOmpUniformClause::pools.end() ; ++block )
   67665             :         {
   67666           0 :           pointer = (SgOmpUniformClause*)(*block);
   67667           0 :           for (unsigned i = 0; i < SgOmpUniformClause::pool_size; ++i )
   67668             :              {
   67669             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   67670             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   67671             :             // memory blocks!.
   67672           0 :                if ( pointer[i].get_freepointer() != NULL )
   67673             :                   {
   67674           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   67675             :                   }
   67676             :                else
   67677             :                   {
   67678           0 :                     if ( pointerOfLinkedList == NULL )
   67679             :                        {
   67680           0 :                          SgOmpUniformClause::next_node = &(pointer[i]);
   67681             :                        }
   67682             :                     else
   67683             :                        {
   67684             :                       // printf ("In SgOmpUniformClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   67685           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   67686             :                        }
   67687             :                     pointerOfLinkedList = &(pointer[i]);
   67688             :                   }
   67689             :               }
   67690             :         }
   67691             : 
   67692           5 :      if ( pointerOfLinkedList != NULL )
   67693             :         {
   67694             :        // printf ("In SgOmpUniformClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   67695           0 :           pointerOfLinkedList->set_freepointer(NULL);
   67696             :        // DQ (6/6/2010): Temporary debugging...
   67697             :        //   ROSE_ASSERT(false);
   67698             :         }
   67699             : 
   67700           5 :      return ;
   67701             :    }
   67702             : 
   67703             : //############################################################################
   67704             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   67705             :  * within the memory pool and resets the freepointers, in order to achieve a 
   67706             :  * linked list, that has no jumps and starts at the beginning! This function 
   67707             :  * does not extend the memory pool, since we do not delete any memory blocks,
   67708             :  * but delete the valid objects.  
   67709             :  */
   67710             : void
   67711           0 : SgOmpUniformClause::clearMemoryPool( )
   67712             :    {
   67713             :   // printf ("Inside of SgOmpUniformClause::clearMemoryPool() \n");
   67714             : 
   67715           0 :      SgOmpUniformClause* pointer = NULL, *tempPointer = NULL;
   67716           0 :      std::vector < unsigned char* > :: const_iterator block;
   67717           0 :      if ( SgOmpUniformClause::pools.empty() == false )
   67718             :         {
   67719           0 :           block = SgOmpUniformClause::pools.begin() ;
   67720           0 :           SgOmpUniformClause::next_node = (SgOmpUniformClause*) (*block);
   67721             : 
   67722           0 :           while ( block != SgOmpUniformClause::pools.end() )
   67723             :              {
   67724           0 :                pointer = (SgOmpUniformClause*) (*block);
   67725           0 :                if ( tempPointer != NULL )
   67726             :                   {
   67727           0 :                     tempPointer->set_freepointer(pointer);
   67728             :                   }
   67729           0 :                for (unsigned i = 0; i < SgOmpUniformClause::pool_size - 1; ++i)
   67730             :                   {
   67731           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   67732             :                   }
   67733           0 :                 pointer[SgOmpUniformClause::pool_size-1].set_freepointer(NULL);
   67734           0 :                 tempPointer = &(pointer[SgOmpUniformClause::pool_size-1]);
   67735           0 :                 ++block;
   67736             :              }
   67737             :         }
   67738           0 :    }
   67739             : 
   67740           5 : void SgOmpUniformClause::deleteMemoryPool() {
   67741           5 :   for (auto p: SgOmpUniformClause::pools) {
   67742           0 :     ROSE_FREE(p);
   67743             :   }
   67744           5 :   SgOmpUniformClause::next_node = nullptr;
   67745           5 :   SgOmpUniformClause::pools.clear();
   67746           5 : }
   67747             : 
   67748             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   67749             : //                 reading multiple binary files to for a single AST.
   67750             : /////////// new version ////////////////////////////////
   67751             : //############################################################################
   67752             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   67753             : void
   67754           2 : SgOmpUniformClause::extendMemoryPoolForFileIO( )
   67755             :   {
   67756           2 :     size_t blockIndex = SgOmpUniformClause::pools.size();
   67757           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUniformClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUniformClause);
   67758             : 
   67759           2 :     while ( (blockIndex * SgOmpUniformClause::pool_size) < newPoolSize)
   67760             :       {
   67761             : #if ROSE_ALLOC_TRACE
   67762             :         if (blockIndex > 0) {
   67763             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUniformClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUniformClause) = %" PRIuPTR " SgOmpUniformClause::pool_size = %d \n",
   67764             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUniformClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUniformClause),SgOmpUniformClause::pool_size);
   67765             :         }
   67766             : #endif
   67767             : 
   67768           0 :         SgOmpUniformClause * pointer = (SgOmpUniformClause*) ROSE_MALLOC ( SgOmpUniformClause::pool_size * sizeof(SgOmpUniformClause) );
   67769           0 :         assert( pointer != NULL );
   67770             : #if ROSE_ALLOC_MEMSET == 1
   67771             :         memset(pointer, 0x00, SgOmpUniformClause::pool_size * sizeof(SgOmpUniformClause));
   67772             : #elif ROSE_ALLOC_MEMSET == 2
   67773             :         memset(pointer, 0xCC, SgOmpUniformClause::pool_size * sizeof(SgOmpUniformClause));
   67774             : #endif
   67775           0 :         SgOmpUniformClause::pools.push_back( (unsigned char*)(pointer) );
   67776           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUniformClause::pool_size * sizeof(SgOmpUniformClause), V_SgOmpUniformClause ) );
   67777             : 
   67778           0 :         if ( SgOmpUniformClause::next_node != NULL ) {
   67779           0 :           if ( blockIndex > 0 ) {
   67780           0 :             SgOmpUniformClause * blkptr = (SgOmpUniformClause*)(SgOmpUniformClause::pools[blockIndex-1]);
   67781           0 :             blkptr[ SgOmpUniformClause::pool_size - 1 ].set_freepointer(pointer);
   67782             :           }
   67783             :         } else {
   67784           0 :           SgOmpUniformClause::next_node = pointer;
   67785             :         }
   67786             : 
   67787           0 :         for (unsigned i = 0; i < SgOmpUniformClause::pool_size-1; ++i)
   67788             :            {
   67789           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   67790             :            }
   67791           0 :         pointer[ SgOmpUniformClause::pool_size -1 ].set_freepointer(NULL);
   67792             : 
   67793           0 :         blockIndex++;
   67794             :       }
   67795           2 :   }
   67796             : 
   67797             : //############################################################################
   67798             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   67799             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   67800             :  * not compressed. However, that stuff is not yet implemented! 
   67801             :  */
   67802             : unsigned long
   67803           0 : SgOmpUniformClause::getNumberOfLastValidPointer()
   67804             :    {
   67805           0 :       SgOmpUniformClause* testPointer = (SgOmpUniformClause*)(SgOmpUniformClause::pools.back());
   67806           0 :       unsigned long localIndex = SgOmpUniformClause::pool_size - 1;
   67807           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   67808             :          {
   67809           0 :            localIndex--;
   67810             :          }
   67811           0 :       return (localIndex + SgOmpUniformClause::pool_size * (SgOmpUniformClause::pools.size()-1));
   67812             :    }
   67813             : 
   67814             : //############################################################################
   67815             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   67816             :  * memory pool and initializes the data member in class SgOmpUniformClauseStroageClass
   67817             :  * from its counterpart of SgOmpUniformClause. The return value is just for checking, 
   67818             :  * that the whole StorageClassArray is initialized!
   67819             :  */
   67820             : unsigned long
   67821           0 : SgOmpUniformClause::initializeStorageClassArray( SgOmpUniformClauseStorageClass *storageArray )
   67822             :    {
   67823           0 :      unsigned long storageCounter = 0;
   67824           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUniformClause::pools.begin();
   67825           0 :      SgOmpUniformClause* pointer = NULL;
   67826           0 :      while ( block != SgOmpUniformClause::pools.end() ) {
   67827           0 :           pointer = (SgOmpUniformClause*) (*block);
   67828           0 :           for ( unsigned i = 0; i < SgOmpUniformClause::pool_size; ++i ) {
   67829           0 :                if ( pointer->get_freepointer() != NULL ) {
   67830           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   67831           0 :                  storageArray++;
   67832           0 :                  storageCounter++;
   67833             :                }
   67834           0 :                pointer++;
   67835             :              }
   67836           0 :            block++;
   67837             :         }
   67838           0 :      return storageCounter;
   67839             :    }
   67840             : 
   67841             : /* #line 67842 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   67842             : 
   67843             : 
   67844             : 
   67845             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   67846             : 
   67847             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   67848             : 
   67849             : //############################################################################
   67850             : /* JH (02/02/2006) Constructor of the IR node SgOmpAlignedClause that takes its 
   67851             :  * corresponding StorageClass as parameter
   67852             :  */
   67853           0 : SgOmpAlignedClause :: SgOmpAlignedClause ( const SgOmpAlignedClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   67854             :    {
   67855             : 
   67856             : 
   67857             : /* #line 67858 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   67858             : 
   67859           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   67860           0 :      p_alignment =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_alignment) );
   67861             : 
   67862             : 
   67863             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   67864             : 
   67865             : 
   67866           0 :    }
   67867             : 
   67868             : //############################################################################
   67869             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   67870             :  * within the working AST. 
   67871             :  */
   67872           0 : SgOmpAlignedClause * SgOmpAlignedClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   67873           0 :      SgOmpAlignedClause* returnPointer = NULL;
   67874           0 :      if ( globalIndex != 0 )
   67875             :         {
   67876             : 
   67877             : #if FILE_IO_EXTRA_CHECK
   67878           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAlignedClause ) ) <= globalIndex ) ;
   67879           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAlignedClause + 1 ) ) );
   67880             : #endif
   67881           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAlignedClause )  
   67882           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAlignedClause );
   67883           0 :           unsigned long positionInPool = localIndex % SgOmpAlignedClause::pool_size;
   67884           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAlignedClause::pool_size;
   67885             : 
   67886             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   67887             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   67888             : 
   67889           0 :           returnPointer = &( ( (SgOmpAlignedClause*)(SgOmpAlignedClause::pools[memoryBlock]) ) [positionInPool]) ;
   67890             : 
   67891           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   67892             :         }
   67893           0 :      return returnPointer ;
   67894             :    }
   67895             : 
   67896             : //############################################################################
   67897             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   67898             :   for the AST with the index astIndex
   67899             : */
   67900           0 : SgOmpAlignedClause * SgOmpAlignedClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   67901           0 :      SgOmpAlignedClause* returnPointer = NULL;
   67902           0 :      if ( globalIndex != 0 )
   67903             :         {
   67904             : 
   67905             : #if FILE_IO_EXTRA_CHECK
   67906           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAlignedClause ) ) <= globalIndex ) ;
   67907           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAlignedClause + 1 ) ) );
   67908             : #endif
   67909           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAlignedClause )
   67910           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAlignedClause );
   67911           0 :           unsigned long positionInPool = localIndex % SgOmpAlignedClause::pool_size ;
   67912           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAlignedClause::pool_size ;
   67913             : 
   67914             : #if FILE_IO_EXTRA_CHECK
   67915             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   67916             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   67917             : #endif
   67918             : 
   67919           0 :           returnPointer = &( ( (SgOmpAlignedClause*)(SgOmpAlignedClause::pools[memoryBlock]) ) [positionInPool]) ;
   67920             : 
   67921             : #if FILE_IO_EXTRA_CHECK
   67922           0 :           assert ( returnPointer != NULL ) ;
   67923             : #endif
   67924             :         }
   67925           0 :      return returnPointer ;
   67926             :    }
   67927             : 
   67928             : //############################################################################
   67929             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   67930             :  * pool size! We set for every valid object in the memory pool the freepointer
   67931             :  * to the global index and increase the global index afterwards. For all the 
   67932             :  * invalid objects (means address ranges within the memory pool that were not
   67933             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   67934             :  * distinguish valid from invalid objects! 
   67935             :  */
   67936             : unsigned long
   67937           5 : SgOmpAlignedClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   67938             :    {
   67939           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   67940           5 :      SgOmpAlignedClause* pointer = NULL;
   67941           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   67942           5 :      std::vector < unsigned char* > :: const_iterator block;
   67943           5 :      for ( block = SgOmpAlignedClause::pools.begin(); block != SgOmpAlignedClause::pools.end() ; ++block )
   67944             :         {
   67945           0 :           pointer = (SgOmpAlignedClause*)(*block);
   67946           0 :           for (unsigned i = 0; i < SgOmpAlignedClause::pool_size; ++i )
   67947             :              {
   67948             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   67949             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   67950             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   67951             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   67952             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   67953             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   67954             :             // properly; so this will have to be checked next.
   67955             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   67956             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   67957           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   67958             :                   {
   67959           0 :                     pointer[i].set_freepointer((SgOmpAlignedClause*)(globalIndex));
   67960           0 :                     globalIndex++;
   67961             :                   }
   67962             :                else
   67963             :                   {
   67964           0 :                     pointer[i].set_freepointer(NULL);
   67965             :                   }
   67966             :               }
   67967             :         }
   67968           5 :      return globalIndex;
   67969             :    }
   67970             : 
   67971             : //############################################################################
   67972             : // JH (01/14/2006)
   67973             : void
   67974           5 : SgOmpAlignedClause::resetValidFreepointers( )
   67975             :    {
   67976           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   67977           5 :      SgOmpAlignedClause* pointer = NULL;
   67978           5 :      std::vector < unsigned char* > :: const_iterator block;
   67979           5 :      SgOmpAlignedClause* pointerOfLinkedList = NULL;
   67980           5 :      for ( block = SgOmpAlignedClause::pools.begin(); block != SgOmpAlignedClause::pools.end() ; ++block )
   67981             :         {
   67982           0 :           pointer = (SgOmpAlignedClause*)(*block);
   67983           0 :           for (unsigned i = 0; i < SgOmpAlignedClause::pool_size; ++i )
   67984             :              {
   67985             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   67986             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   67987             :             // memory blocks!.
   67988           0 :                if ( pointer[i].get_freepointer() != NULL )
   67989             :                   {
   67990           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   67991             :                   }
   67992             :                else
   67993             :                   {
   67994           0 :                     if ( pointerOfLinkedList == NULL )
   67995             :                        {
   67996           0 :                          SgOmpAlignedClause::next_node = &(pointer[i]);
   67997             :                        }
   67998             :                     else
   67999             :                        {
   68000             :                       // printf ("In SgOmpAlignedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   68001           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   68002             :                        }
   68003             :                     pointerOfLinkedList = &(pointer[i]);
   68004             :                   }
   68005             :               }
   68006             :         }
   68007             : 
   68008           5 :      if ( pointerOfLinkedList != NULL )
   68009             :         {
   68010             :        // printf ("In SgOmpAlignedClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   68011           0 :           pointerOfLinkedList->set_freepointer(NULL);
   68012             :        // DQ (6/6/2010): Temporary debugging...
   68013             :        //   ROSE_ASSERT(false);
   68014             :         }
   68015             : 
   68016           5 :      return ;
   68017             :    }
   68018             : 
   68019             : //############################################################################
   68020             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   68021             :  * within the memory pool and resets the freepointers, in order to achieve a 
   68022             :  * linked list, that has no jumps and starts at the beginning! This function 
   68023             :  * does not extend the memory pool, since we do not delete any memory blocks,
   68024             :  * but delete the valid objects.  
   68025             :  */
   68026             : void
   68027           0 : SgOmpAlignedClause::clearMemoryPool( )
   68028             :    {
   68029             :   // printf ("Inside of SgOmpAlignedClause::clearMemoryPool() \n");
   68030             : 
   68031           0 :      SgOmpAlignedClause* pointer = NULL, *tempPointer = NULL;
   68032           0 :      std::vector < unsigned char* > :: const_iterator block;
   68033           0 :      if ( SgOmpAlignedClause::pools.empty() == false )
   68034             :         {
   68035           0 :           block = SgOmpAlignedClause::pools.begin() ;
   68036           0 :           SgOmpAlignedClause::next_node = (SgOmpAlignedClause*) (*block);
   68037             : 
   68038           0 :           while ( block != SgOmpAlignedClause::pools.end() )
   68039             :              {
   68040           0 :                pointer = (SgOmpAlignedClause*) (*block);
   68041           0 :                if ( tempPointer != NULL )
   68042             :                   {
   68043           0 :                     tempPointer->set_freepointer(pointer);
   68044             :                   }
   68045           0 :                for (unsigned i = 0; i < SgOmpAlignedClause::pool_size - 1; ++i)
   68046             :                   {
   68047           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   68048             :                   }
   68049           0 :                 pointer[SgOmpAlignedClause::pool_size-1].set_freepointer(NULL);
   68050           0 :                 tempPointer = &(pointer[SgOmpAlignedClause::pool_size-1]);
   68051           0 :                 ++block;
   68052             :              }
   68053             :         }
   68054           0 :    }
   68055             : 
   68056           5 : void SgOmpAlignedClause::deleteMemoryPool() {
   68057           5 :   for (auto p: SgOmpAlignedClause::pools) {
   68058           0 :     ROSE_FREE(p);
   68059             :   }
   68060           5 :   SgOmpAlignedClause::next_node = nullptr;
   68061           5 :   SgOmpAlignedClause::pools.clear();
   68062           5 : }
   68063             : 
   68064             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   68065             : //                 reading multiple binary files to for a single AST.
   68066             : /////////// new version ////////////////////////////////
   68067             : //############################################################################
   68068             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   68069             : void
   68070           2 : SgOmpAlignedClause::extendMemoryPoolForFileIO( )
   68071             :   {
   68072           2 :     size_t blockIndex = SgOmpAlignedClause::pools.size();
   68073           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAlignedClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAlignedClause);
   68074             : 
   68075           2 :     while ( (blockIndex * SgOmpAlignedClause::pool_size) < newPoolSize)
   68076             :       {
   68077             : #if ROSE_ALLOC_TRACE
   68078             :         if (blockIndex > 0) {
   68079             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAlignedClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAlignedClause) = %" PRIuPTR " SgOmpAlignedClause::pool_size = %d \n",
   68080             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAlignedClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAlignedClause),SgOmpAlignedClause::pool_size);
   68081             :         }
   68082             : #endif
   68083             : 
   68084           0 :         SgOmpAlignedClause * pointer = (SgOmpAlignedClause*) ROSE_MALLOC ( SgOmpAlignedClause::pool_size * sizeof(SgOmpAlignedClause) );
   68085           0 :         assert( pointer != NULL );
   68086             : #if ROSE_ALLOC_MEMSET == 1
   68087             :         memset(pointer, 0x00, SgOmpAlignedClause::pool_size * sizeof(SgOmpAlignedClause));
   68088             : #elif ROSE_ALLOC_MEMSET == 2
   68089             :         memset(pointer, 0xCC, SgOmpAlignedClause::pool_size * sizeof(SgOmpAlignedClause));
   68090             : #endif
   68091           0 :         SgOmpAlignedClause::pools.push_back( (unsigned char*)(pointer) );
   68092           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAlignedClause::pool_size * sizeof(SgOmpAlignedClause), V_SgOmpAlignedClause ) );
   68093             : 
   68094           0 :         if ( SgOmpAlignedClause::next_node != NULL ) {
   68095           0 :           if ( blockIndex > 0 ) {
   68096           0 :             SgOmpAlignedClause * blkptr = (SgOmpAlignedClause*)(SgOmpAlignedClause::pools[blockIndex-1]);
   68097           0 :             blkptr[ SgOmpAlignedClause::pool_size - 1 ].set_freepointer(pointer);
   68098             :           }
   68099             :         } else {
   68100           0 :           SgOmpAlignedClause::next_node = pointer;
   68101             :         }
   68102             : 
   68103           0 :         for (unsigned i = 0; i < SgOmpAlignedClause::pool_size-1; ++i)
   68104             :            {
   68105           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   68106             :            }
   68107           0 :         pointer[ SgOmpAlignedClause::pool_size -1 ].set_freepointer(NULL);
   68108             : 
   68109           0 :         blockIndex++;
   68110             :       }
   68111           2 :   }
   68112             : 
   68113             : //############################################################################
   68114             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   68115             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   68116             :  * not compressed. However, that stuff is not yet implemented! 
   68117             :  */
   68118             : unsigned long
   68119           0 : SgOmpAlignedClause::getNumberOfLastValidPointer()
   68120             :    {
   68121           0 :       SgOmpAlignedClause* testPointer = (SgOmpAlignedClause*)(SgOmpAlignedClause::pools.back());
   68122           0 :       unsigned long localIndex = SgOmpAlignedClause::pool_size - 1;
   68123           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   68124             :          {
   68125           0 :            localIndex--;
   68126             :          }
   68127           0 :       return (localIndex + SgOmpAlignedClause::pool_size * (SgOmpAlignedClause::pools.size()-1));
   68128             :    }
   68129             : 
   68130             : //############################################################################
   68131             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   68132             :  * memory pool and initializes the data member in class SgOmpAlignedClauseStroageClass
   68133             :  * from its counterpart of SgOmpAlignedClause. The return value is just for checking, 
   68134             :  * that the whole StorageClassArray is initialized!
   68135             :  */
   68136             : unsigned long
   68137           0 : SgOmpAlignedClause::initializeStorageClassArray( SgOmpAlignedClauseStorageClass *storageArray )
   68138             :    {
   68139           0 :      unsigned long storageCounter = 0;
   68140           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAlignedClause::pools.begin();
   68141           0 :      SgOmpAlignedClause* pointer = NULL;
   68142           0 :      while ( block != SgOmpAlignedClause::pools.end() ) {
   68143           0 :           pointer = (SgOmpAlignedClause*) (*block);
   68144           0 :           for ( unsigned i = 0; i < SgOmpAlignedClause::pool_size; ++i ) {
   68145           0 :                if ( pointer->get_freepointer() != NULL ) {
   68146           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   68147           0 :                  storageArray++;
   68148           0 :                  storageCounter++;
   68149             :                }
   68150           0 :                pointer++;
   68151             :              }
   68152           0 :            block++;
   68153             :         }
   68154           0 :      return storageCounter;
   68155             :    }
   68156             : 
   68157             : /* #line 68158 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   68158             : 
   68159             : 
   68160             : 
   68161             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   68162             : 
   68163             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   68164             : 
   68165             : //############################################################################
   68166             : /* JH (02/02/2006) Constructor of the IR node SgOmpLinearClause that takes its 
   68167             :  * corresponding StorageClass as parameter
   68168             :  */
   68169           0 : SgOmpLinearClause :: SgOmpLinearClause ( const SgOmpLinearClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   68170             :    {
   68171             : 
   68172             : 
   68173             : /* #line 68174 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   68174             : 
   68175           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   68176           0 :      p_step =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_step) );
   68177           0 :      p_modifier = storageSource.storageOf_modifier ;
   68178             : 
   68179             : 
   68180             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   68181             : 
   68182             : 
   68183           0 :    }
   68184             : 
   68185             : //############################################################################
   68186             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   68187             :  * within the working AST. 
   68188             :  */
   68189           0 : SgOmpLinearClause * SgOmpLinearClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   68190           0 :      SgOmpLinearClause* returnPointer = NULL;
   68191           0 :      if ( globalIndex != 0 )
   68192             :         {
   68193             : 
   68194             : #if FILE_IO_EXTRA_CHECK
   68195           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpLinearClause ) ) <= globalIndex ) ;
   68196           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpLinearClause + 1 ) ) );
   68197             : #endif
   68198           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpLinearClause )  
   68199           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpLinearClause );
   68200           0 :           unsigned long positionInPool = localIndex % SgOmpLinearClause::pool_size;
   68201           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpLinearClause::pool_size;
   68202             : 
   68203             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   68204             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   68205             : 
   68206           0 :           returnPointer = &( ( (SgOmpLinearClause*)(SgOmpLinearClause::pools[memoryBlock]) ) [positionInPool]) ;
   68207             : 
   68208           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   68209             :         }
   68210           0 :      return returnPointer ;
   68211             :    }
   68212             : 
   68213             : //############################################################################
   68214             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   68215             :   for the AST with the index astIndex
   68216             : */
   68217           0 : SgOmpLinearClause * SgOmpLinearClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   68218           0 :      SgOmpLinearClause* returnPointer = NULL;
   68219           0 :      if ( globalIndex != 0 )
   68220             :         {
   68221             : 
   68222             : #if FILE_IO_EXTRA_CHECK
   68223           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpLinearClause ) ) <= globalIndex ) ;
   68224           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpLinearClause + 1 ) ) );
   68225             : #endif
   68226           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpLinearClause )
   68227           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpLinearClause );
   68228           0 :           unsigned long positionInPool = localIndex % SgOmpLinearClause::pool_size ;
   68229           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpLinearClause::pool_size ;
   68230             : 
   68231             : #if FILE_IO_EXTRA_CHECK
   68232             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   68233             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   68234             : #endif
   68235             : 
   68236           0 :           returnPointer = &( ( (SgOmpLinearClause*)(SgOmpLinearClause::pools[memoryBlock]) ) [positionInPool]) ;
   68237             : 
   68238             : #if FILE_IO_EXTRA_CHECK
   68239           0 :           assert ( returnPointer != NULL ) ;
   68240             : #endif
   68241             :         }
   68242           0 :      return returnPointer ;
   68243             :    }
   68244             : 
   68245             : //############################################################################
   68246             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   68247             :  * pool size! We set for every valid object in the memory pool the freepointer
   68248             :  * to the global index and increase the global index afterwards. For all the 
   68249             :  * invalid objects (means address ranges within the memory pool that were not
   68250             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   68251             :  * distinguish valid from invalid objects! 
   68252             :  */
   68253             : unsigned long
   68254           5 : SgOmpLinearClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   68255             :    {
   68256           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   68257           5 :      SgOmpLinearClause* pointer = NULL;
   68258           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   68259           5 :      std::vector < unsigned char* > :: const_iterator block;
   68260           5 :      for ( block = SgOmpLinearClause::pools.begin(); block != SgOmpLinearClause::pools.end() ; ++block )
   68261             :         {
   68262           0 :           pointer = (SgOmpLinearClause*)(*block);
   68263           0 :           for (unsigned i = 0; i < SgOmpLinearClause::pool_size; ++i )
   68264             :              {
   68265             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   68266             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   68267             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   68268             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   68269             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   68270             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   68271             :             // properly; so this will have to be checked next.
   68272             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   68273             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   68274           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   68275             :                   {
   68276           0 :                     pointer[i].set_freepointer((SgOmpLinearClause*)(globalIndex));
   68277           0 :                     globalIndex++;
   68278             :                   }
   68279             :                else
   68280             :                   {
   68281           0 :                     pointer[i].set_freepointer(NULL);
   68282             :                   }
   68283             :               }
   68284             :         }
   68285           5 :      return globalIndex;
   68286             :    }
   68287             : 
   68288             : //############################################################################
   68289             : // JH (01/14/2006)
   68290             : void
   68291           5 : SgOmpLinearClause::resetValidFreepointers( )
   68292             :    {
   68293           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   68294           5 :      SgOmpLinearClause* pointer = NULL;
   68295           5 :      std::vector < unsigned char* > :: const_iterator block;
   68296           5 :      SgOmpLinearClause* pointerOfLinkedList = NULL;
   68297           5 :      for ( block = SgOmpLinearClause::pools.begin(); block != SgOmpLinearClause::pools.end() ; ++block )
   68298             :         {
   68299           0 :           pointer = (SgOmpLinearClause*)(*block);
   68300           0 :           for (unsigned i = 0; i < SgOmpLinearClause::pool_size; ++i )
   68301             :              {
   68302             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   68303             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   68304             :             // memory blocks!.
   68305           0 :                if ( pointer[i].get_freepointer() != NULL )
   68306             :                   {
   68307           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   68308             :                   }
   68309             :                else
   68310             :                   {
   68311           0 :                     if ( pointerOfLinkedList == NULL )
   68312             :                        {
   68313           0 :                          SgOmpLinearClause::next_node = &(pointer[i]);
   68314             :                        }
   68315             :                     else
   68316             :                        {
   68317             :                       // printf ("In SgOmpLinearClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   68318           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   68319             :                        }
   68320             :                     pointerOfLinkedList = &(pointer[i]);
   68321             :                   }
   68322             :               }
   68323             :         }
   68324             : 
   68325           5 :      if ( pointerOfLinkedList != NULL )
   68326             :         {
   68327             :        // printf ("In SgOmpLinearClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   68328           0 :           pointerOfLinkedList->set_freepointer(NULL);
   68329             :        // DQ (6/6/2010): Temporary debugging...
   68330             :        //   ROSE_ASSERT(false);
   68331             :         }
   68332             : 
   68333           5 :      return ;
   68334             :    }
   68335             : 
   68336             : //############################################################################
   68337             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   68338             :  * within the memory pool and resets the freepointers, in order to achieve a 
   68339             :  * linked list, that has no jumps and starts at the beginning! This function 
   68340             :  * does not extend the memory pool, since we do not delete any memory blocks,
   68341             :  * but delete the valid objects.  
   68342             :  */
   68343             : void
   68344           0 : SgOmpLinearClause::clearMemoryPool( )
   68345             :    {
   68346             :   // printf ("Inside of SgOmpLinearClause::clearMemoryPool() \n");
   68347             : 
   68348           0 :      SgOmpLinearClause* pointer = NULL, *tempPointer = NULL;
   68349           0 :      std::vector < unsigned char* > :: const_iterator block;
   68350           0 :      if ( SgOmpLinearClause::pools.empty() == false )
   68351             :         {
   68352           0 :           block = SgOmpLinearClause::pools.begin() ;
   68353           0 :           SgOmpLinearClause::next_node = (SgOmpLinearClause*) (*block);
   68354             : 
   68355           0 :           while ( block != SgOmpLinearClause::pools.end() )
   68356             :              {
   68357           0 :                pointer = (SgOmpLinearClause*) (*block);
   68358           0 :                if ( tempPointer != NULL )
   68359             :                   {
   68360           0 :                     tempPointer->set_freepointer(pointer);
   68361             :                   }
   68362           0 :                for (unsigned i = 0; i < SgOmpLinearClause::pool_size - 1; ++i)
   68363             :                   {
   68364           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   68365             :                   }
   68366           0 :                 pointer[SgOmpLinearClause::pool_size-1].set_freepointer(NULL);
   68367           0 :                 tempPointer = &(pointer[SgOmpLinearClause::pool_size-1]);
   68368           0 :                 ++block;
   68369             :              }
   68370             :         }
   68371           0 :    }
   68372             : 
   68373           5 : void SgOmpLinearClause::deleteMemoryPool() {
   68374           5 :   for (auto p: SgOmpLinearClause::pools) {
   68375           0 :     ROSE_FREE(p);
   68376             :   }
   68377           5 :   SgOmpLinearClause::next_node = nullptr;
   68378           5 :   SgOmpLinearClause::pools.clear();
   68379           5 : }
   68380             : 
   68381             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   68382             : //                 reading multiple binary files to for a single AST.
   68383             : /////////// new version ////////////////////////////////
   68384             : //############################################################################
   68385             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   68386             : void
   68387           2 : SgOmpLinearClause::extendMemoryPoolForFileIO( )
   68388             :   {
   68389           2 :     size_t blockIndex = SgOmpLinearClause::pools.size();
   68390           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLinearClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLinearClause);
   68391             : 
   68392           2 :     while ( (blockIndex * SgOmpLinearClause::pool_size) < newPoolSize)
   68393             :       {
   68394             : #if ROSE_ALLOC_TRACE
   68395             :         if (blockIndex > 0) {
   68396             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLinearClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLinearClause) = %" PRIuPTR " SgOmpLinearClause::pool_size = %d \n",
   68397             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLinearClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLinearClause),SgOmpLinearClause::pool_size);
   68398             :         }
   68399             : #endif
   68400             : 
   68401           0 :         SgOmpLinearClause * pointer = (SgOmpLinearClause*) ROSE_MALLOC ( SgOmpLinearClause::pool_size * sizeof(SgOmpLinearClause) );
   68402           0 :         assert( pointer != NULL );
   68403             : #if ROSE_ALLOC_MEMSET == 1
   68404             :         memset(pointer, 0x00, SgOmpLinearClause::pool_size * sizeof(SgOmpLinearClause));
   68405             : #elif ROSE_ALLOC_MEMSET == 2
   68406             :         memset(pointer, 0xCC, SgOmpLinearClause::pool_size * sizeof(SgOmpLinearClause));
   68407             : #endif
   68408           0 :         SgOmpLinearClause::pools.push_back( (unsigned char*)(pointer) );
   68409           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpLinearClause::pool_size * sizeof(SgOmpLinearClause), V_SgOmpLinearClause ) );
   68410             : 
   68411           0 :         if ( SgOmpLinearClause::next_node != NULL ) {
   68412           0 :           if ( blockIndex > 0 ) {
   68413           0 :             SgOmpLinearClause * blkptr = (SgOmpLinearClause*)(SgOmpLinearClause::pools[blockIndex-1]);
   68414           0 :             blkptr[ SgOmpLinearClause::pool_size - 1 ].set_freepointer(pointer);
   68415             :           }
   68416             :         } else {
   68417           0 :           SgOmpLinearClause::next_node = pointer;
   68418             :         }
   68419             : 
   68420           0 :         for (unsigned i = 0; i < SgOmpLinearClause::pool_size-1; ++i)
   68421             :            {
   68422           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   68423             :            }
   68424           0 :         pointer[ SgOmpLinearClause::pool_size -1 ].set_freepointer(NULL);
   68425             : 
   68426           0 :         blockIndex++;
   68427             :       }
   68428           2 :   }
   68429             : 
   68430             : //############################################################################
   68431             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   68432             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   68433             :  * not compressed. However, that stuff is not yet implemented! 
   68434             :  */
   68435             : unsigned long
   68436           0 : SgOmpLinearClause::getNumberOfLastValidPointer()
   68437             :    {
   68438           0 :       SgOmpLinearClause* testPointer = (SgOmpLinearClause*)(SgOmpLinearClause::pools.back());
   68439           0 :       unsigned long localIndex = SgOmpLinearClause::pool_size - 1;
   68440           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   68441             :          {
   68442           0 :            localIndex--;
   68443             :          }
   68444           0 :       return (localIndex + SgOmpLinearClause::pool_size * (SgOmpLinearClause::pools.size()-1));
   68445             :    }
   68446             : 
   68447             : //############################################################################
   68448             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   68449             :  * memory pool and initializes the data member in class SgOmpLinearClauseStroageClass
   68450             :  * from its counterpart of SgOmpLinearClause. The return value is just for checking, 
   68451             :  * that the whole StorageClassArray is initialized!
   68452             :  */
   68453             : unsigned long
   68454           0 : SgOmpLinearClause::initializeStorageClassArray( SgOmpLinearClauseStorageClass *storageArray )
   68455             :    {
   68456           0 :      unsigned long storageCounter = 0;
   68457           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpLinearClause::pools.begin();
   68458           0 :      SgOmpLinearClause* pointer = NULL;
   68459           0 :      while ( block != SgOmpLinearClause::pools.end() ) {
   68460           0 :           pointer = (SgOmpLinearClause*) (*block);
   68461           0 :           for ( unsigned i = 0; i < SgOmpLinearClause::pool_size; ++i ) {
   68462           0 :                if ( pointer->get_freepointer() != NULL ) {
   68463           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   68464           0 :                  storageArray++;
   68465           0 :                  storageCounter++;
   68466             :                }
   68467           0 :                pointer++;
   68468             :              }
   68469           0 :            block++;
   68470             :         }
   68471           0 :      return storageCounter;
   68472             :    }
   68473             : 
   68474             : /* #line 68475 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   68475             : 
   68476             : 
   68477             : 
   68478             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   68479             : 
   68480             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   68481             : 
   68482             : //############################################################################
   68483             : /* JH (02/02/2006) Constructor of the IR node SgOmpDependClause that takes its 
   68484             :  * corresponding StorageClass as parameter
   68485             :  */
   68486           0 : SgOmpDependClause :: SgOmpDependClause ( const SgOmpDependClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   68487             :    {
   68488             : 
   68489             : 
   68490             : /* #line 68491 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   68491             : 
   68492           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   68493           0 :      p_depend_modifier = storageSource.storageOf_depend_modifier ;
   68494           0 :      p_dependence_type = storageSource.storageOf_dependence_type ;
   68495           0 :      p_iterator = storageSource.storageOf_iterator.rebuildDataStoredInEasyStorageClass() ;
   68496           0 :      p_array_dimensions = storageSource.storageOf_array_dimensions.rebuildDataStoredInEasyStorageClass() ;
   68497           0 :      p_vec = storageSource.storageOf_vec.rebuildDataStoredInEasyStorageClass() ;
   68498             : 
   68499             : 
   68500             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   68501             : 
   68502             : 
   68503           0 :    }
   68504             : 
   68505             : //############################################################################
   68506             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   68507             :  * within the working AST. 
   68508             :  */
   68509           0 : SgOmpDependClause * SgOmpDependClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   68510           0 :      SgOmpDependClause* returnPointer = NULL;
   68511           0 :      if ( globalIndex != 0 )
   68512             :         {
   68513             : 
   68514             : #if FILE_IO_EXTRA_CHECK
   68515           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDependClause ) ) <= globalIndex ) ;
   68516           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDependClause + 1 ) ) );
   68517             : #endif
   68518           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDependClause )  
   68519           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDependClause );
   68520           0 :           unsigned long positionInPool = localIndex % SgOmpDependClause::pool_size;
   68521           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDependClause::pool_size;
   68522             : 
   68523             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   68524             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   68525             : 
   68526           0 :           returnPointer = &( ( (SgOmpDependClause*)(SgOmpDependClause::pools[memoryBlock]) ) [positionInPool]) ;
   68527             : 
   68528           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   68529             :         }
   68530           0 :      return returnPointer ;
   68531             :    }
   68532             : 
   68533             : //############################################################################
   68534             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   68535             :   for the AST with the index astIndex
   68536             : */
   68537           0 : SgOmpDependClause * SgOmpDependClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   68538           0 :      SgOmpDependClause* returnPointer = NULL;
   68539           0 :      if ( globalIndex != 0 )
   68540             :         {
   68541             : 
   68542             : #if FILE_IO_EXTRA_CHECK
   68543           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDependClause ) ) <= globalIndex ) ;
   68544           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDependClause + 1 ) ) );
   68545             : #endif
   68546           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDependClause )
   68547           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDependClause );
   68548           0 :           unsigned long positionInPool = localIndex % SgOmpDependClause::pool_size ;
   68549           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDependClause::pool_size ;
   68550             : 
   68551             : #if FILE_IO_EXTRA_CHECK
   68552             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   68553             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   68554             : #endif
   68555             : 
   68556           0 :           returnPointer = &( ( (SgOmpDependClause*)(SgOmpDependClause::pools[memoryBlock]) ) [positionInPool]) ;
   68557             : 
   68558             : #if FILE_IO_EXTRA_CHECK
   68559           0 :           assert ( returnPointer != NULL ) ;
   68560             : #endif
   68561             :         }
   68562           0 :      return returnPointer ;
   68563             :    }
   68564             : 
   68565             : //############################################################################
   68566             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   68567             :  * pool size! We set for every valid object in the memory pool the freepointer
   68568             :  * to the global index and increase the global index afterwards. For all the 
   68569             :  * invalid objects (means address ranges within the memory pool that were not
   68570             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   68571             :  * distinguish valid from invalid objects! 
   68572             :  */
   68573             : unsigned long
   68574           5 : SgOmpDependClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   68575             :    {
   68576           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   68577           5 :      SgOmpDependClause* pointer = NULL;
   68578           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   68579           5 :      std::vector < unsigned char* > :: const_iterator block;
   68580           5 :      for ( block = SgOmpDependClause::pools.begin(); block != SgOmpDependClause::pools.end() ; ++block )
   68581             :         {
   68582           0 :           pointer = (SgOmpDependClause*)(*block);
   68583           0 :           for (unsigned i = 0; i < SgOmpDependClause::pool_size; ++i )
   68584             :              {
   68585             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   68586             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   68587             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   68588             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   68589             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   68590             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   68591             :             // properly; so this will have to be checked next.
   68592             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   68593             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   68594           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   68595             :                   {
   68596           0 :                     pointer[i].set_freepointer((SgOmpDependClause*)(globalIndex));
   68597           0 :                     globalIndex++;
   68598             :                   }
   68599             :                else
   68600             :                   {
   68601           0 :                     pointer[i].set_freepointer(NULL);
   68602             :                   }
   68603             :               }
   68604             :         }
   68605           5 :      return globalIndex;
   68606             :    }
   68607             : 
   68608             : //############################################################################
   68609             : // JH (01/14/2006)
   68610             : void
   68611           5 : SgOmpDependClause::resetValidFreepointers( )
   68612             :    {
   68613           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   68614           5 :      SgOmpDependClause* pointer = NULL;
   68615           5 :      std::vector < unsigned char* > :: const_iterator block;
   68616           5 :      SgOmpDependClause* pointerOfLinkedList = NULL;
   68617           5 :      for ( block = SgOmpDependClause::pools.begin(); block != SgOmpDependClause::pools.end() ; ++block )
   68618             :         {
   68619           0 :           pointer = (SgOmpDependClause*)(*block);
   68620           0 :           for (unsigned i = 0; i < SgOmpDependClause::pool_size; ++i )
   68621             :              {
   68622             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   68623             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   68624             :             // memory blocks!.
   68625           0 :                if ( pointer[i].get_freepointer() != NULL )
   68626             :                   {
   68627           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   68628             :                   }
   68629             :                else
   68630             :                   {
   68631           0 :                     if ( pointerOfLinkedList == NULL )
   68632             :                        {
   68633           0 :                          SgOmpDependClause::next_node = &(pointer[i]);
   68634             :                        }
   68635             :                     else
   68636             :                        {
   68637             :                       // printf ("In SgOmpDependClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   68638           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   68639             :                        }
   68640             :                     pointerOfLinkedList = &(pointer[i]);
   68641             :                   }
   68642             :               }
   68643             :         }
   68644             : 
   68645           5 :      if ( pointerOfLinkedList != NULL )
   68646             :         {
   68647             :        // printf ("In SgOmpDependClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   68648           0 :           pointerOfLinkedList->set_freepointer(NULL);
   68649             :        // DQ (6/6/2010): Temporary debugging...
   68650             :        //   ROSE_ASSERT(false);
   68651             :         }
   68652             : 
   68653           5 :      return ;
   68654             :    }
   68655             : 
   68656             : //############################################################################
   68657             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   68658             :  * within the memory pool and resets the freepointers, in order to achieve a 
   68659             :  * linked list, that has no jumps and starts at the beginning! This function 
   68660             :  * does not extend the memory pool, since we do not delete any memory blocks,
   68661             :  * but delete the valid objects.  
   68662             :  */
   68663             : void
   68664           0 : SgOmpDependClause::clearMemoryPool( )
   68665             :    {
   68666             :   // printf ("Inside of SgOmpDependClause::clearMemoryPool() \n");
   68667             : 
   68668           0 :      SgOmpDependClause* pointer = NULL, *tempPointer = NULL;
   68669           0 :      std::vector < unsigned char* > :: const_iterator block;
   68670           0 :      if ( SgOmpDependClause::pools.empty() == false )
   68671             :         {
   68672           0 :           block = SgOmpDependClause::pools.begin() ;
   68673           0 :           SgOmpDependClause::next_node = (SgOmpDependClause*) (*block);
   68674             : 
   68675           0 :           while ( block != SgOmpDependClause::pools.end() )
   68676             :              {
   68677           0 :                pointer = (SgOmpDependClause*) (*block);
   68678           0 :                if ( tempPointer != NULL )
   68679             :                   {
   68680           0 :                     tempPointer->set_freepointer(pointer);
   68681             :                   }
   68682           0 :                for (unsigned i = 0; i < SgOmpDependClause::pool_size - 1; ++i)
   68683             :                   {
   68684           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   68685             :                   }
   68686           0 :                 pointer[SgOmpDependClause::pool_size-1].set_freepointer(NULL);
   68687           0 :                 tempPointer = &(pointer[SgOmpDependClause::pool_size-1]);
   68688           0 :                 ++block;
   68689             :              }
   68690             :         }
   68691           0 :    }
   68692             : 
   68693           5 : void SgOmpDependClause::deleteMemoryPool() {
   68694           5 :   for (auto p: SgOmpDependClause::pools) {
   68695           0 :     ROSE_FREE(p);
   68696             :   }
   68697           5 :   SgOmpDependClause::next_node = nullptr;
   68698           5 :   SgOmpDependClause::pools.clear();
   68699           5 : }
   68700             : 
   68701             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   68702             : //                 reading multiple binary files to for a single AST.
   68703             : /////////// new version ////////////////////////////////
   68704             : //############################################################################
   68705             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   68706             : void
   68707           2 : SgOmpDependClause::extendMemoryPoolForFileIO( )
   68708             :   {
   68709           2 :     size_t blockIndex = SgOmpDependClause::pools.size();
   68710           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDependClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDependClause);
   68711             : 
   68712           2 :     while ( (blockIndex * SgOmpDependClause::pool_size) < newPoolSize)
   68713             :       {
   68714             : #if ROSE_ALLOC_TRACE
   68715             :         if (blockIndex > 0) {
   68716             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDependClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDependClause) = %" PRIuPTR " SgOmpDependClause::pool_size = %d \n",
   68717             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDependClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDependClause),SgOmpDependClause::pool_size);
   68718             :         }
   68719             : #endif
   68720             : 
   68721           0 :         SgOmpDependClause * pointer = (SgOmpDependClause*) ROSE_MALLOC ( SgOmpDependClause::pool_size * sizeof(SgOmpDependClause) );
   68722           0 :         assert( pointer != NULL );
   68723             : #if ROSE_ALLOC_MEMSET == 1
   68724             :         memset(pointer, 0x00, SgOmpDependClause::pool_size * sizeof(SgOmpDependClause));
   68725             : #elif ROSE_ALLOC_MEMSET == 2
   68726             :         memset(pointer, 0xCC, SgOmpDependClause::pool_size * sizeof(SgOmpDependClause));
   68727             : #endif
   68728           0 :         SgOmpDependClause::pools.push_back( (unsigned char*)(pointer) );
   68729           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDependClause::pool_size * sizeof(SgOmpDependClause), V_SgOmpDependClause ) );
   68730             : 
   68731           0 :         if ( SgOmpDependClause::next_node != NULL ) {
   68732           0 :           if ( blockIndex > 0 ) {
   68733           0 :             SgOmpDependClause * blkptr = (SgOmpDependClause*)(SgOmpDependClause::pools[blockIndex-1]);
   68734           0 :             blkptr[ SgOmpDependClause::pool_size - 1 ].set_freepointer(pointer);
   68735             :           }
   68736             :         } else {
   68737           0 :           SgOmpDependClause::next_node = pointer;
   68738             :         }
   68739             : 
   68740           0 :         for (unsigned i = 0; i < SgOmpDependClause::pool_size-1; ++i)
   68741             :            {
   68742           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   68743             :            }
   68744           0 :         pointer[ SgOmpDependClause::pool_size -1 ].set_freepointer(NULL);
   68745             : 
   68746           0 :         blockIndex++;
   68747             :       }
   68748           2 :   }
   68749             : 
   68750             : //############################################################################
   68751             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   68752             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   68753             :  * not compressed. However, that stuff is not yet implemented! 
   68754             :  */
   68755             : unsigned long
   68756           0 : SgOmpDependClause::getNumberOfLastValidPointer()
   68757             :    {
   68758           0 :       SgOmpDependClause* testPointer = (SgOmpDependClause*)(SgOmpDependClause::pools.back());
   68759           0 :       unsigned long localIndex = SgOmpDependClause::pool_size - 1;
   68760           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   68761             :          {
   68762           0 :            localIndex--;
   68763             :          }
   68764           0 :       return (localIndex + SgOmpDependClause::pool_size * (SgOmpDependClause::pools.size()-1));
   68765             :    }
   68766             : 
   68767             : //############################################################################
   68768             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   68769             :  * memory pool and initializes the data member in class SgOmpDependClauseStroageClass
   68770             :  * from its counterpart of SgOmpDependClause. The return value is just for checking, 
   68771             :  * that the whole StorageClassArray is initialized!
   68772             :  */
   68773             : unsigned long
   68774           0 : SgOmpDependClause::initializeStorageClassArray( SgOmpDependClauseStorageClass *storageArray )
   68775             :    {
   68776           0 :      unsigned long storageCounter = 0;
   68777           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDependClause::pools.begin();
   68778           0 :      SgOmpDependClause* pointer = NULL;
   68779           0 :      while ( block != SgOmpDependClause::pools.end() ) {
   68780           0 :           pointer = (SgOmpDependClause*) (*block);
   68781           0 :           for ( unsigned i = 0; i < SgOmpDependClause::pool_size; ++i ) {
   68782           0 :                if ( pointer->get_freepointer() != NULL ) {
   68783           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   68784           0 :                  storageArray++;
   68785           0 :                  storageCounter++;
   68786             :                }
   68787           0 :                pointer++;
   68788             :              }
   68789           0 :            block++;
   68790             :         }
   68791           0 :      return storageCounter;
   68792             :    }
   68793             : 
   68794             : /* #line 68795 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   68795             : 
   68796             : 
   68797             : 
   68798             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   68799             : 
   68800             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   68801             : 
   68802             : //############################################################################
   68803             : /* JH (02/02/2006) Constructor of the IR node SgOmpAffinityClause that takes its 
   68804             :  * corresponding StorageClass as parameter
   68805             :  */
   68806           0 : SgOmpAffinityClause :: SgOmpAffinityClause ( const SgOmpAffinityClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   68807             :    {
   68808             : 
   68809             : 
   68810             : /* #line 68811 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   68811             : 
   68812           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   68813           0 :      p_affinity_modifier = storageSource.storageOf_affinity_modifier ;
   68814           0 :      p_iterator = storageSource.storageOf_iterator.rebuildDataStoredInEasyStorageClass() ;
   68815           0 :      p_array_dimensions = storageSource.storageOf_array_dimensions.rebuildDataStoredInEasyStorageClass() ;
   68816             : 
   68817             : 
   68818             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   68819             : 
   68820             : 
   68821           0 :    }
   68822             : 
   68823             : //############################################################################
   68824             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   68825             :  * within the working AST. 
   68826             :  */
   68827           0 : SgOmpAffinityClause * SgOmpAffinityClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   68828           0 :      SgOmpAffinityClause* returnPointer = NULL;
   68829           0 :      if ( globalIndex != 0 )
   68830             :         {
   68831             : 
   68832             : #if FILE_IO_EXTRA_CHECK
   68833           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAffinityClause ) ) <= globalIndex ) ;
   68834           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAffinityClause + 1 ) ) );
   68835             : #endif
   68836           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAffinityClause )  
   68837           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAffinityClause );
   68838           0 :           unsigned long positionInPool = localIndex % SgOmpAffinityClause::pool_size;
   68839           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAffinityClause::pool_size;
   68840             : 
   68841             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   68842             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   68843             : 
   68844           0 :           returnPointer = &( ( (SgOmpAffinityClause*)(SgOmpAffinityClause::pools[memoryBlock]) ) [positionInPool]) ;
   68845             : 
   68846           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   68847             :         }
   68848           0 :      return returnPointer ;
   68849             :    }
   68850             : 
   68851             : //############################################################################
   68852             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   68853             :   for the AST with the index astIndex
   68854             : */
   68855           0 : SgOmpAffinityClause * SgOmpAffinityClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   68856           0 :      SgOmpAffinityClause* returnPointer = NULL;
   68857           0 :      if ( globalIndex != 0 )
   68858             :         {
   68859             : 
   68860             : #if FILE_IO_EXTRA_CHECK
   68861           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAffinityClause ) ) <= globalIndex ) ;
   68862           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAffinityClause + 1 ) ) );
   68863             : #endif
   68864           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAffinityClause )
   68865           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAffinityClause );
   68866           0 :           unsigned long positionInPool = localIndex % SgOmpAffinityClause::pool_size ;
   68867           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAffinityClause::pool_size ;
   68868             : 
   68869             : #if FILE_IO_EXTRA_CHECK
   68870             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   68871             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   68872             : #endif
   68873             : 
   68874           0 :           returnPointer = &( ( (SgOmpAffinityClause*)(SgOmpAffinityClause::pools[memoryBlock]) ) [positionInPool]) ;
   68875             : 
   68876             : #if FILE_IO_EXTRA_CHECK
   68877           0 :           assert ( returnPointer != NULL ) ;
   68878             : #endif
   68879             :         }
   68880           0 :      return returnPointer ;
   68881             :    }
   68882             : 
   68883             : //############################################################################
   68884             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   68885             :  * pool size! We set for every valid object in the memory pool the freepointer
   68886             :  * to the global index and increase the global index afterwards. For all the 
   68887             :  * invalid objects (means address ranges within the memory pool that were not
   68888             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   68889             :  * distinguish valid from invalid objects! 
   68890             :  */
   68891             : unsigned long
   68892           5 : SgOmpAffinityClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   68893             :    {
   68894           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   68895           5 :      SgOmpAffinityClause* pointer = NULL;
   68896           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   68897           5 :      std::vector < unsigned char* > :: const_iterator block;
   68898           5 :      for ( block = SgOmpAffinityClause::pools.begin(); block != SgOmpAffinityClause::pools.end() ; ++block )
   68899             :         {
   68900           0 :           pointer = (SgOmpAffinityClause*)(*block);
   68901           0 :           for (unsigned i = 0; i < SgOmpAffinityClause::pool_size; ++i )
   68902             :              {
   68903             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   68904             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   68905             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   68906             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   68907             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   68908             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   68909             :             // properly; so this will have to be checked next.
   68910             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   68911             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   68912           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   68913             :                   {
   68914           0 :                     pointer[i].set_freepointer((SgOmpAffinityClause*)(globalIndex));
   68915           0 :                     globalIndex++;
   68916             :                   }
   68917             :                else
   68918             :                   {
   68919           0 :                     pointer[i].set_freepointer(NULL);
   68920             :                   }
   68921             :               }
   68922             :         }
   68923           5 :      return globalIndex;
   68924             :    }
   68925             : 
   68926             : //############################################################################
   68927             : // JH (01/14/2006)
   68928             : void
   68929           5 : SgOmpAffinityClause::resetValidFreepointers( )
   68930             :    {
   68931           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   68932           5 :      SgOmpAffinityClause* pointer = NULL;
   68933           5 :      std::vector < unsigned char* > :: const_iterator block;
   68934           5 :      SgOmpAffinityClause* pointerOfLinkedList = NULL;
   68935           5 :      for ( block = SgOmpAffinityClause::pools.begin(); block != SgOmpAffinityClause::pools.end() ; ++block )
   68936             :         {
   68937           0 :           pointer = (SgOmpAffinityClause*)(*block);
   68938           0 :           for (unsigned i = 0; i < SgOmpAffinityClause::pool_size; ++i )
   68939             :              {
   68940             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   68941             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   68942             :             // memory blocks!.
   68943           0 :                if ( pointer[i].get_freepointer() != NULL )
   68944             :                   {
   68945           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   68946             :                   }
   68947             :                else
   68948             :                   {
   68949           0 :                     if ( pointerOfLinkedList == NULL )
   68950             :                        {
   68951           0 :                          SgOmpAffinityClause::next_node = &(pointer[i]);
   68952             :                        }
   68953             :                     else
   68954             :                        {
   68955             :                       // printf ("In SgOmpAffinityClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   68956           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   68957             :                        }
   68958             :                     pointerOfLinkedList = &(pointer[i]);
   68959             :                   }
   68960             :               }
   68961             :         }
   68962             : 
   68963           5 :      if ( pointerOfLinkedList != NULL )
   68964             :         {
   68965             :        // printf ("In SgOmpAffinityClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   68966           0 :           pointerOfLinkedList->set_freepointer(NULL);
   68967             :        // DQ (6/6/2010): Temporary debugging...
   68968             :        //   ROSE_ASSERT(false);
   68969             :         }
   68970             : 
   68971           5 :      return ;
   68972             :    }
   68973             : 
   68974             : //############################################################################
   68975             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   68976             :  * within the memory pool and resets the freepointers, in order to achieve a 
   68977             :  * linked list, that has no jumps and starts at the beginning! This function 
   68978             :  * does not extend the memory pool, since we do not delete any memory blocks,
   68979             :  * but delete the valid objects.  
   68980             :  */
   68981             : void
   68982           0 : SgOmpAffinityClause::clearMemoryPool( )
   68983             :    {
   68984             :   // printf ("Inside of SgOmpAffinityClause::clearMemoryPool() \n");
   68985             : 
   68986           0 :      SgOmpAffinityClause* pointer = NULL, *tempPointer = NULL;
   68987           0 :      std::vector < unsigned char* > :: const_iterator block;
   68988           0 :      if ( SgOmpAffinityClause::pools.empty() == false )
   68989             :         {
   68990           0 :           block = SgOmpAffinityClause::pools.begin() ;
   68991           0 :           SgOmpAffinityClause::next_node = (SgOmpAffinityClause*) (*block);
   68992             : 
   68993           0 :           while ( block != SgOmpAffinityClause::pools.end() )
   68994             :              {
   68995           0 :                pointer = (SgOmpAffinityClause*) (*block);
   68996           0 :                if ( tempPointer != NULL )
   68997             :                   {
   68998           0 :                     tempPointer->set_freepointer(pointer);
   68999             :                   }
   69000           0 :                for (unsigned i = 0; i < SgOmpAffinityClause::pool_size - 1; ++i)
   69001             :                   {
   69002           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   69003             :                   }
   69004           0 :                 pointer[SgOmpAffinityClause::pool_size-1].set_freepointer(NULL);
   69005           0 :                 tempPointer = &(pointer[SgOmpAffinityClause::pool_size-1]);
   69006           0 :                 ++block;
   69007             :              }
   69008             :         }
   69009           0 :    }
   69010             : 
   69011           5 : void SgOmpAffinityClause::deleteMemoryPool() {
   69012           5 :   for (auto p: SgOmpAffinityClause::pools) {
   69013           0 :     ROSE_FREE(p);
   69014             :   }
   69015           5 :   SgOmpAffinityClause::next_node = nullptr;
   69016           5 :   SgOmpAffinityClause::pools.clear();
   69017           5 : }
   69018             : 
   69019             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   69020             : //                 reading multiple binary files to for a single AST.
   69021             : /////////// new version ////////////////////////////////
   69022             : //############################################################################
   69023             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   69024             : void
   69025           2 : SgOmpAffinityClause::extendMemoryPoolForFileIO( )
   69026             :   {
   69027           2 :     size_t blockIndex = SgOmpAffinityClause::pools.size();
   69028           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAffinityClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAffinityClause);
   69029             : 
   69030           2 :     while ( (blockIndex * SgOmpAffinityClause::pool_size) < newPoolSize)
   69031             :       {
   69032             : #if ROSE_ALLOC_TRACE
   69033             :         if (blockIndex > 0) {
   69034             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAffinityClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAffinityClause) = %" PRIuPTR " SgOmpAffinityClause::pool_size = %d \n",
   69035             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAffinityClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAffinityClause),SgOmpAffinityClause::pool_size);
   69036             :         }
   69037             : #endif
   69038             : 
   69039           0 :         SgOmpAffinityClause * pointer = (SgOmpAffinityClause*) ROSE_MALLOC ( SgOmpAffinityClause::pool_size * sizeof(SgOmpAffinityClause) );
   69040           0 :         assert( pointer != NULL );
   69041             : #if ROSE_ALLOC_MEMSET == 1
   69042             :         memset(pointer, 0x00, SgOmpAffinityClause::pool_size * sizeof(SgOmpAffinityClause));
   69043             : #elif ROSE_ALLOC_MEMSET == 2
   69044             :         memset(pointer, 0xCC, SgOmpAffinityClause::pool_size * sizeof(SgOmpAffinityClause));
   69045             : #endif
   69046           0 :         SgOmpAffinityClause::pools.push_back( (unsigned char*)(pointer) );
   69047           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAffinityClause::pool_size * sizeof(SgOmpAffinityClause), V_SgOmpAffinityClause ) );
   69048             : 
   69049           0 :         if ( SgOmpAffinityClause::next_node != NULL ) {
   69050           0 :           if ( blockIndex > 0 ) {
   69051           0 :             SgOmpAffinityClause * blkptr = (SgOmpAffinityClause*)(SgOmpAffinityClause::pools[blockIndex-1]);
   69052           0 :             blkptr[ SgOmpAffinityClause::pool_size - 1 ].set_freepointer(pointer);
   69053             :           }
   69054             :         } else {
   69055           0 :           SgOmpAffinityClause::next_node = pointer;
   69056             :         }
   69057             : 
   69058           0 :         for (unsigned i = 0; i < SgOmpAffinityClause::pool_size-1; ++i)
   69059             :            {
   69060           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   69061             :            }
   69062           0 :         pointer[ SgOmpAffinityClause::pool_size -1 ].set_freepointer(NULL);
   69063             : 
   69064           0 :         blockIndex++;
   69065             :       }
   69066           2 :   }
   69067             : 
   69068             : //############################################################################
   69069             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   69070             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   69071             :  * not compressed. However, that stuff is not yet implemented! 
   69072             :  */
   69073             : unsigned long
   69074           0 : SgOmpAffinityClause::getNumberOfLastValidPointer()
   69075             :    {
   69076           0 :       SgOmpAffinityClause* testPointer = (SgOmpAffinityClause*)(SgOmpAffinityClause::pools.back());
   69077           0 :       unsigned long localIndex = SgOmpAffinityClause::pool_size - 1;
   69078           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   69079             :          {
   69080           0 :            localIndex--;
   69081             :          }
   69082           0 :       return (localIndex + SgOmpAffinityClause::pool_size * (SgOmpAffinityClause::pools.size()-1));
   69083             :    }
   69084             : 
   69085             : //############################################################################
   69086             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   69087             :  * memory pool and initializes the data member in class SgOmpAffinityClauseStroageClass
   69088             :  * from its counterpart of SgOmpAffinityClause. The return value is just for checking, 
   69089             :  * that the whole StorageClassArray is initialized!
   69090             :  */
   69091             : unsigned long
   69092           0 : SgOmpAffinityClause::initializeStorageClassArray( SgOmpAffinityClauseStorageClass *storageArray )
   69093             :    {
   69094           0 :      unsigned long storageCounter = 0;
   69095           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAffinityClause::pools.begin();
   69096           0 :      SgOmpAffinityClause* pointer = NULL;
   69097           0 :      while ( block != SgOmpAffinityClause::pools.end() ) {
   69098           0 :           pointer = (SgOmpAffinityClause*) (*block);
   69099           0 :           for ( unsigned i = 0; i < SgOmpAffinityClause::pool_size; ++i ) {
   69100           0 :                if ( pointer->get_freepointer() != NULL ) {
   69101           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   69102           0 :                  storageArray++;
   69103           0 :                  storageCounter++;
   69104             :                }
   69105           0 :                pointer++;
   69106             :              }
   69107           0 :            block++;
   69108             :         }
   69109           0 :      return storageCounter;
   69110             :    }
   69111             : 
   69112             : /* #line 69113 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   69113             : 
   69114             : 
   69115             : 
   69116             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   69117             : 
   69118             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   69119             : 
   69120             : //############################################################################
   69121             : /* JH (02/02/2006) Constructor of the IR node SgOmpToClause that takes its 
   69122             :  * corresponding StorageClass as parameter
   69123             :  */
   69124           0 : SgOmpToClause :: SgOmpToClause ( const SgOmpToClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   69125             :    {
   69126             : 
   69127             : 
   69128             : /* #line 69129 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   69129             : 
   69130           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   69131           0 :      p_kind = storageSource.storageOf_kind ;
   69132           0 :      p_mapper_identifier =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_mapper_identifier) );
   69133           0 :      p_array_dimensions = storageSource.storageOf_array_dimensions.rebuildDataStoredInEasyStorageClass() ;
   69134             : 
   69135             : 
   69136             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   69137             : 
   69138             : 
   69139           0 :    }
   69140             : 
   69141             : //############################################################################
   69142             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   69143             :  * within the working AST. 
   69144             :  */
   69145           0 : SgOmpToClause * SgOmpToClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   69146           0 :      SgOmpToClause* returnPointer = NULL;
   69147           0 :      if ( globalIndex != 0 )
   69148             :         {
   69149             : 
   69150             : #if FILE_IO_EXTRA_CHECK
   69151           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpToClause ) ) <= globalIndex ) ;
   69152           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpToClause + 1 ) ) );
   69153             : #endif
   69154           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpToClause )  
   69155           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpToClause );
   69156           0 :           unsigned long positionInPool = localIndex % SgOmpToClause::pool_size;
   69157           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpToClause::pool_size;
   69158             : 
   69159             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   69160             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   69161             : 
   69162           0 :           returnPointer = &( ( (SgOmpToClause*)(SgOmpToClause::pools[memoryBlock]) ) [positionInPool]) ;
   69163             : 
   69164           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   69165             :         }
   69166           0 :      return returnPointer ;
   69167             :    }
   69168             : 
   69169             : //############################################################################
   69170             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   69171             :   for the AST with the index astIndex
   69172             : */
   69173           0 : SgOmpToClause * SgOmpToClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   69174           0 :      SgOmpToClause* returnPointer = NULL;
   69175           0 :      if ( globalIndex != 0 )
   69176             :         {
   69177             : 
   69178             : #if FILE_IO_EXTRA_CHECK
   69179           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpToClause ) ) <= globalIndex ) ;
   69180           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpToClause + 1 ) ) );
   69181             : #endif
   69182           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpToClause )
   69183           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpToClause );
   69184           0 :           unsigned long positionInPool = localIndex % SgOmpToClause::pool_size ;
   69185           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpToClause::pool_size ;
   69186             : 
   69187             : #if FILE_IO_EXTRA_CHECK
   69188             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   69189             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   69190             : #endif
   69191             : 
   69192           0 :           returnPointer = &( ( (SgOmpToClause*)(SgOmpToClause::pools[memoryBlock]) ) [positionInPool]) ;
   69193             : 
   69194             : #if FILE_IO_EXTRA_CHECK
   69195           0 :           assert ( returnPointer != NULL ) ;
   69196             : #endif
   69197             :         }
   69198           0 :      return returnPointer ;
   69199             :    }
   69200             : 
   69201             : //############################################################################
   69202             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   69203             :  * pool size! We set for every valid object in the memory pool the freepointer
   69204             :  * to the global index and increase the global index afterwards. For all the 
   69205             :  * invalid objects (means address ranges within the memory pool that were not
   69206             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   69207             :  * distinguish valid from invalid objects! 
   69208             :  */
   69209             : unsigned long
   69210           5 : SgOmpToClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   69211             :    {
   69212           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   69213           5 :      SgOmpToClause* pointer = NULL;
   69214           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   69215           5 :      std::vector < unsigned char* > :: const_iterator block;
   69216           5 :      for ( block = SgOmpToClause::pools.begin(); block != SgOmpToClause::pools.end() ; ++block )
   69217             :         {
   69218           0 :           pointer = (SgOmpToClause*)(*block);
   69219           0 :           for (unsigned i = 0; i < SgOmpToClause::pool_size; ++i )
   69220             :              {
   69221             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   69222             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   69223             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   69224             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   69225             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   69226             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   69227             :             // properly; so this will have to be checked next.
   69228             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   69229             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   69230           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   69231             :                   {
   69232           0 :                     pointer[i].set_freepointer((SgOmpToClause*)(globalIndex));
   69233           0 :                     globalIndex++;
   69234             :                   }
   69235             :                else
   69236             :                   {
   69237           0 :                     pointer[i].set_freepointer(NULL);
   69238             :                   }
   69239             :               }
   69240             :         }
   69241           5 :      return globalIndex;
   69242             :    }
   69243             : 
   69244             : //############################################################################
   69245             : // JH (01/14/2006)
   69246             : void
   69247           5 : SgOmpToClause::resetValidFreepointers( )
   69248             :    {
   69249           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   69250           5 :      SgOmpToClause* pointer = NULL;
   69251           5 :      std::vector < unsigned char* > :: const_iterator block;
   69252           5 :      SgOmpToClause* pointerOfLinkedList = NULL;
   69253           5 :      for ( block = SgOmpToClause::pools.begin(); block != SgOmpToClause::pools.end() ; ++block )
   69254             :         {
   69255           0 :           pointer = (SgOmpToClause*)(*block);
   69256           0 :           for (unsigned i = 0; i < SgOmpToClause::pool_size; ++i )
   69257             :              {
   69258             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   69259             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   69260             :             // memory blocks!.
   69261           0 :                if ( pointer[i].get_freepointer() != NULL )
   69262             :                   {
   69263           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   69264             :                   }
   69265             :                else
   69266             :                   {
   69267           0 :                     if ( pointerOfLinkedList == NULL )
   69268             :                        {
   69269           0 :                          SgOmpToClause::next_node = &(pointer[i]);
   69270             :                        }
   69271             :                     else
   69272             :                        {
   69273             :                       // printf ("In SgOmpToClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   69274           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   69275             :                        }
   69276             :                     pointerOfLinkedList = &(pointer[i]);
   69277             :                   }
   69278             :               }
   69279             :         }
   69280             : 
   69281           5 :      if ( pointerOfLinkedList != NULL )
   69282             :         {
   69283             :        // printf ("In SgOmpToClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   69284           0 :           pointerOfLinkedList->set_freepointer(NULL);
   69285             :        // DQ (6/6/2010): Temporary debugging...
   69286             :        //   ROSE_ASSERT(false);
   69287             :         }
   69288             : 
   69289           5 :      return ;
   69290             :    }
   69291             : 
   69292             : //############################################################################
   69293             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   69294             :  * within the memory pool and resets the freepointers, in order to achieve a 
   69295             :  * linked list, that has no jumps and starts at the beginning! This function 
   69296             :  * does not extend the memory pool, since we do not delete any memory blocks,
   69297             :  * but delete the valid objects.  
   69298             :  */
   69299             : void
   69300           0 : SgOmpToClause::clearMemoryPool( )
   69301             :    {
   69302             :   // printf ("Inside of SgOmpToClause::clearMemoryPool() \n");
   69303             : 
   69304           0 :      SgOmpToClause* pointer = NULL, *tempPointer = NULL;
   69305           0 :      std::vector < unsigned char* > :: const_iterator block;
   69306           0 :      if ( SgOmpToClause::pools.empty() == false )
   69307             :         {
   69308           0 :           block = SgOmpToClause::pools.begin() ;
   69309           0 :           SgOmpToClause::next_node = (SgOmpToClause*) (*block);
   69310             : 
   69311           0 :           while ( block != SgOmpToClause::pools.end() )
   69312             :              {
   69313           0 :                pointer = (SgOmpToClause*) (*block);
   69314           0 :                if ( tempPointer != NULL )
   69315             :                   {
   69316           0 :                     tempPointer->set_freepointer(pointer);
   69317             :                   }
   69318           0 :                for (unsigned i = 0; i < SgOmpToClause::pool_size - 1; ++i)
   69319             :                   {
   69320           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   69321             :                   }
   69322           0 :                 pointer[SgOmpToClause::pool_size-1].set_freepointer(NULL);
   69323           0 :                 tempPointer = &(pointer[SgOmpToClause::pool_size-1]);
   69324           0 :                 ++block;
   69325             :              }
   69326             :         }
   69327           0 :    }
   69328             : 
   69329           5 : void SgOmpToClause::deleteMemoryPool() {
   69330           5 :   for (auto p: SgOmpToClause::pools) {
   69331           0 :     ROSE_FREE(p);
   69332             :   }
   69333           5 :   SgOmpToClause::next_node = nullptr;
   69334           5 :   SgOmpToClause::pools.clear();
   69335           5 : }
   69336             : 
   69337             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   69338             : //                 reading multiple binary files to for a single AST.
   69339             : /////////// new version ////////////////////////////////
   69340             : //############################################################################
   69341             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   69342             : void
   69343           2 : SgOmpToClause::extendMemoryPoolForFileIO( )
   69344             :   {
   69345           2 :     size_t blockIndex = SgOmpToClause::pools.size();
   69346           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpToClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpToClause);
   69347             : 
   69348           2 :     while ( (blockIndex * SgOmpToClause::pool_size) < newPoolSize)
   69349             :       {
   69350             : #if ROSE_ALLOC_TRACE
   69351             :         if (blockIndex > 0) {
   69352             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpToClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpToClause) = %" PRIuPTR " SgOmpToClause::pool_size = %d \n",
   69353             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpToClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpToClause),SgOmpToClause::pool_size);
   69354             :         }
   69355             : #endif
   69356             : 
   69357           0 :         SgOmpToClause * pointer = (SgOmpToClause*) ROSE_MALLOC ( SgOmpToClause::pool_size * sizeof(SgOmpToClause) );
   69358           0 :         assert( pointer != NULL );
   69359             : #if ROSE_ALLOC_MEMSET == 1
   69360             :         memset(pointer, 0x00, SgOmpToClause::pool_size * sizeof(SgOmpToClause));
   69361             : #elif ROSE_ALLOC_MEMSET == 2
   69362             :         memset(pointer, 0xCC, SgOmpToClause::pool_size * sizeof(SgOmpToClause));
   69363             : #endif
   69364           0 :         SgOmpToClause::pools.push_back( (unsigned char*)(pointer) );
   69365           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpToClause::pool_size * sizeof(SgOmpToClause), V_SgOmpToClause ) );
   69366             : 
   69367           0 :         if ( SgOmpToClause::next_node != NULL ) {
   69368           0 :           if ( blockIndex > 0 ) {
   69369           0 :             SgOmpToClause * blkptr = (SgOmpToClause*)(SgOmpToClause::pools[blockIndex-1]);
   69370           0 :             blkptr[ SgOmpToClause::pool_size - 1 ].set_freepointer(pointer);
   69371             :           }
   69372             :         } else {
   69373           0 :           SgOmpToClause::next_node = pointer;
   69374             :         }
   69375             : 
   69376           0 :         for (unsigned i = 0; i < SgOmpToClause::pool_size-1; ++i)
   69377             :            {
   69378           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   69379             :            }
   69380           0 :         pointer[ SgOmpToClause::pool_size -1 ].set_freepointer(NULL);
   69381             : 
   69382           0 :         blockIndex++;
   69383             :       }
   69384           2 :   }
   69385             : 
   69386             : //############################################################################
   69387             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   69388             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   69389             :  * not compressed. However, that stuff is not yet implemented! 
   69390             :  */
   69391             : unsigned long
   69392           0 : SgOmpToClause::getNumberOfLastValidPointer()
   69393             :    {
   69394           0 :       SgOmpToClause* testPointer = (SgOmpToClause*)(SgOmpToClause::pools.back());
   69395           0 :       unsigned long localIndex = SgOmpToClause::pool_size - 1;
   69396           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   69397             :          {
   69398           0 :            localIndex--;
   69399             :          }
   69400           0 :       return (localIndex + SgOmpToClause::pool_size * (SgOmpToClause::pools.size()-1));
   69401             :    }
   69402             : 
   69403             : //############################################################################
   69404             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   69405             :  * memory pool and initializes the data member in class SgOmpToClauseStroageClass
   69406             :  * from its counterpart of SgOmpToClause. The return value is just for checking, 
   69407             :  * that the whole StorageClassArray is initialized!
   69408             :  */
   69409             : unsigned long
   69410           0 : SgOmpToClause::initializeStorageClassArray( SgOmpToClauseStorageClass *storageArray )
   69411             :    {
   69412           0 :      unsigned long storageCounter = 0;
   69413           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpToClause::pools.begin();
   69414           0 :      SgOmpToClause* pointer = NULL;
   69415           0 :      while ( block != SgOmpToClause::pools.end() ) {
   69416           0 :           pointer = (SgOmpToClause*) (*block);
   69417           0 :           for ( unsigned i = 0; i < SgOmpToClause::pool_size; ++i ) {
   69418           0 :                if ( pointer->get_freepointer() != NULL ) {
   69419           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   69420           0 :                  storageArray++;
   69421           0 :                  storageCounter++;
   69422             :                }
   69423           0 :                pointer++;
   69424             :              }
   69425           0 :            block++;
   69426             :         }
   69427           0 :      return storageCounter;
   69428             :    }
   69429             : 
   69430             : /* #line 69431 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   69431             : 
   69432             : 
   69433             : 
   69434             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   69435             : 
   69436             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   69437             : 
   69438             : //############################################################################
   69439             : /* JH (02/02/2006) Constructor of the IR node SgOmpFromClause that takes its 
   69440             :  * corresponding StorageClass as parameter
   69441             :  */
   69442           0 : SgOmpFromClause :: SgOmpFromClause ( const SgOmpFromClauseStorageClass& storageSource )   : SgOmpVariablesClause (storageSource)
   69443             :    {
   69444             : 
   69445             : 
   69446             : /* #line 69447 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   69447             : 
   69448           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   69449           0 :      p_kind = storageSource.storageOf_kind ;
   69450           0 :      p_mapper_identifier =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_mapper_identifier) );
   69451           0 :      p_array_dimensions = storageSource.storageOf_array_dimensions.rebuildDataStoredInEasyStorageClass() ;
   69452             : 
   69453             : 
   69454             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   69455             : 
   69456             : 
   69457           0 :    }
   69458             : 
   69459             : //############################################################################
   69460             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   69461             :  * within the working AST. 
   69462             :  */
   69463           0 : SgOmpFromClause * SgOmpFromClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   69464           0 :      SgOmpFromClause* returnPointer = NULL;
   69465           0 :      if ( globalIndex != 0 )
   69466             :         {
   69467             : 
   69468             : #if FILE_IO_EXTRA_CHECK
   69469           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpFromClause ) ) <= globalIndex ) ;
   69470           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFromClause + 1 ) ) );
   69471             : #endif
   69472           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFromClause )  
   69473           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpFromClause );
   69474           0 :           unsigned long positionInPool = localIndex % SgOmpFromClause::pool_size;
   69475           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFromClause::pool_size;
   69476             : 
   69477             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   69478             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   69479             : 
   69480           0 :           returnPointer = &( ( (SgOmpFromClause*)(SgOmpFromClause::pools[memoryBlock]) ) [positionInPool]) ;
   69481             : 
   69482           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   69483             :         }
   69484           0 :      return returnPointer ;
   69485             :    }
   69486             : 
   69487             : //############################################################################
   69488             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   69489             :   for the AST with the index astIndex
   69490             : */
   69491           0 : SgOmpFromClause * SgOmpFromClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   69492           0 :      SgOmpFromClause* returnPointer = NULL;
   69493           0 :      if ( globalIndex != 0 )
   69494             :         {
   69495             : 
   69496             : #if FILE_IO_EXTRA_CHECK
   69497           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpFromClause ) ) <= globalIndex ) ;
   69498           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFromClause + 1 ) ) );
   69499             : #endif
   69500           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFromClause )
   69501           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpFromClause );
   69502           0 :           unsigned long positionInPool = localIndex % SgOmpFromClause::pool_size ;
   69503           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFromClause::pool_size ;
   69504             : 
   69505             : #if FILE_IO_EXTRA_CHECK
   69506             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   69507             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   69508             : #endif
   69509             : 
   69510           0 :           returnPointer = &( ( (SgOmpFromClause*)(SgOmpFromClause::pools[memoryBlock]) ) [positionInPool]) ;
   69511             : 
   69512             : #if FILE_IO_EXTRA_CHECK
   69513           0 :           assert ( returnPointer != NULL ) ;
   69514             : #endif
   69515             :         }
   69516           0 :      return returnPointer ;
   69517             :    }
   69518             : 
   69519             : //############################################################################
   69520             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   69521             :  * pool size! We set for every valid object in the memory pool the freepointer
   69522             :  * to the global index and increase the global index afterwards. For all the 
   69523             :  * invalid objects (means address ranges within the memory pool that were not
   69524             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   69525             :  * distinguish valid from invalid objects! 
   69526             :  */
   69527             : unsigned long
   69528           5 : SgOmpFromClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   69529             :    {
   69530           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   69531           5 :      SgOmpFromClause* pointer = NULL;
   69532           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   69533           5 :      std::vector < unsigned char* > :: const_iterator block;
   69534           5 :      for ( block = SgOmpFromClause::pools.begin(); block != SgOmpFromClause::pools.end() ; ++block )
   69535             :         {
   69536           0 :           pointer = (SgOmpFromClause*)(*block);
   69537           0 :           for (unsigned i = 0; i < SgOmpFromClause::pool_size; ++i )
   69538             :              {
   69539             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   69540             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   69541             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   69542             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   69543             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   69544             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   69545             :             // properly; so this will have to be checked next.
   69546             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   69547             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   69548           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   69549             :                   {
   69550           0 :                     pointer[i].set_freepointer((SgOmpFromClause*)(globalIndex));
   69551           0 :                     globalIndex++;
   69552             :                   }
   69553             :                else
   69554             :                   {
   69555           0 :                     pointer[i].set_freepointer(NULL);
   69556             :                   }
   69557             :               }
   69558             :         }
   69559           5 :      return globalIndex;
   69560             :    }
   69561             : 
   69562             : //############################################################################
   69563             : // JH (01/14/2006)
   69564             : void
   69565           5 : SgOmpFromClause::resetValidFreepointers( )
   69566             :    {
   69567           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   69568           5 :      SgOmpFromClause* pointer = NULL;
   69569           5 :      std::vector < unsigned char* > :: const_iterator block;
   69570           5 :      SgOmpFromClause* pointerOfLinkedList = NULL;
   69571           5 :      for ( block = SgOmpFromClause::pools.begin(); block != SgOmpFromClause::pools.end() ; ++block )
   69572             :         {
   69573           0 :           pointer = (SgOmpFromClause*)(*block);
   69574           0 :           for (unsigned i = 0; i < SgOmpFromClause::pool_size; ++i )
   69575             :              {
   69576             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   69577             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   69578             :             // memory blocks!.
   69579           0 :                if ( pointer[i].get_freepointer() != NULL )
   69580             :                   {
   69581           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   69582             :                   }
   69583             :                else
   69584             :                   {
   69585           0 :                     if ( pointerOfLinkedList == NULL )
   69586             :                        {
   69587           0 :                          SgOmpFromClause::next_node = &(pointer[i]);
   69588             :                        }
   69589             :                     else
   69590             :                        {
   69591             :                       // printf ("In SgOmpFromClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   69592           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   69593             :                        }
   69594             :                     pointerOfLinkedList = &(pointer[i]);
   69595             :                   }
   69596             :               }
   69597             :         }
   69598             : 
   69599           5 :      if ( pointerOfLinkedList != NULL )
   69600             :         {
   69601             :        // printf ("In SgOmpFromClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   69602           0 :           pointerOfLinkedList->set_freepointer(NULL);
   69603             :        // DQ (6/6/2010): Temporary debugging...
   69604             :        //   ROSE_ASSERT(false);
   69605             :         }
   69606             : 
   69607           5 :      return ;
   69608             :    }
   69609             : 
   69610             : //############################################################################
   69611             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   69612             :  * within the memory pool and resets the freepointers, in order to achieve a 
   69613             :  * linked list, that has no jumps and starts at the beginning! This function 
   69614             :  * does not extend the memory pool, since we do not delete any memory blocks,
   69615             :  * but delete the valid objects.  
   69616             :  */
   69617             : void
   69618           0 : SgOmpFromClause::clearMemoryPool( )
   69619             :    {
   69620             :   // printf ("Inside of SgOmpFromClause::clearMemoryPool() \n");
   69621             : 
   69622           0 :      SgOmpFromClause* pointer = NULL, *tempPointer = NULL;
   69623           0 :      std::vector < unsigned char* > :: const_iterator block;
   69624           0 :      if ( SgOmpFromClause::pools.empty() == false )
   69625             :         {
   69626           0 :           block = SgOmpFromClause::pools.begin() ;
   69627           0 :           SgOmpFromClause::next_node = (SgOmpFromClause*) (*block);
   69628             : 
   69629           0 :           while ( block != SgOmpFromClause::pools.end() )
   69630             :              {
   69631           0 :                pointer = (SgOmpFromClause*) (*block);
   69632           0 :                if ( tempPointer != NULL )
   69633             :                   {
   69634           0 :                     tempPointer->set_freepointer(pointer);
   69635             :                   }
   69636           0 :                for (unsigned i = 0; i < SgOmpFromClause::pool_size - 1; ++i)
   69637             :                   {
   69638           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   69639             :                   }
   69640           0 :                 pointer[SgOmpFromClause::pool_size-1].set_freepointer(NULL);
   69641           0 :                 tempPointer = &(pointer[SgOmpFromClause::pool_size-1]);
   69642           0 :                 ++block;
   69643             :              }
   69644             :         }
   69645           0 :    }
   69646             : 
   69647           5 : void SgOmpFromClause::deleteMemoryPool() {
   69648           5 :   for (auto p: SgOmpFromClause::pools) {
   69649           0 :     ROSE_FREE(p);
   69650             :   }
   69651           5 :   SgOmpFromClause::next_node = nullptr;
   69652           5 :   SgOmpFromClause::pools.clear();
   69653           5 : }
   69654             : 
   69655             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   69656             : //                 reading multiple binary files to for a single AST.
   69657             : /////////// new version ////////////////////////////////
   69658             : //############################################################################
   69659             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   69660             : void
   69661           2 : SgOmpFromClause::extendMemoryPoolForFileIO( )
   69662             :   {
   69663           2 :     size_t blockIndex = SgOmpFromClause::pools.size();
   69664           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFromClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFromClause);
   69665             : 
   69666           2 :     while ( (blockIndex * SgOmpFromClause::pool_size) < newPoolSize)
   69667             :       {
   69668             : #if ROSE_ALLOC_TRACE
   69669             :         if (blockIndex > 0) {
   69670             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFromClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFromClause) = %" PRIuPTR " SgOmpFromClause::pool_size = %d \n",
   69671             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFromClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFromClause),SgOmpFromClause::pool_size);
   69672             :         }
   69673             : #endif
   69674             : 
   69675           0 :         SgOmpFromClause * pointer = (SgOmpFromClause*) ROSE_MALLOC ( SgOmpFromClause::pool_size * sizeof(SgOmpFromClause) );
   69676           0 :         assert( pointer != NULL );
   69677             : #if ROSE_ALLOC_MEMSET == 1
   69678             :         memset(pointer, 0x00, SgOmpFromClause::pool_size * sizeof(SgOmpFromClause));
   69679             : #elif ROSE_ALLOC_MEMSET == 2
   69680             :         memset(pointer, 0xCC, SgOmpFromClause::pool_size * sizeof(SgOmpFromClause));
   69681             : #endif
   69682           0 :         SgOmpFromClause::pools.push_back( (unsigned char*)(pointer) );
   69683           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpFromClause::pool_size * sizeof(SgOmpFromClause), V_SgOmpFromClause ) );
   69684             : 
   69685           0 :         if ( SgOmpFromClause::next_node != NULL ) {
   69686           0 :           if ( blockIndex > 0 ) {
   69687           0 :             SgOmpFromClause * blkptr = (SgOmpFromClause*)(SgOmpFromClause::pools[blockIndex-1]);
   69688           0 :             blkptr[ SgOmpFromClause::pool_size - 1 ].set_freepointer(pointer);
   69689             :           }
   69690             :         } else {
   69691           0 :           SgOmpFromClause::next_node = pointer;
   69692             :         }
   69693             : 
   69694           0 :         for (unsigned i = 0; i < SgOmpFromClause::pool_size-1; ++i)
   69695             :            {
   69696           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   69697             :            }
   69698           0 :         pointer[ SgOmpFromClause::pool_size -1 ].set_freepointer(NULL);
   69699             : 
   69700           0 :         blockIndex++;
   69701             :       }
   69702           2 :   }
   69703             : 
   69704             : //############################################################################
   69705             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   69706             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   69707             :  * not compressed. However, that stuff is not yet implemented! 
   69708             :  */
   69709             : unsigned long
   69710           0 : SgOmpFromClause::getNumberOfLastValidPointer()
   69711             :    {
   69712           0 :       SgOmpFromClause* testPointer = (SgOmpFromClause*)(SgOmpFromClause::pools.back());
   69713           0 :       unsigned long localIndex = SgOmpFromClause::pool_size - 1;
   69714           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   69715             :          {
   69716           0 :            localIndex--;
   69717             :          }
   69718           0 :       return (localIndex + SgOmpFromClause::pool_size * (SgOmpFromClause::pools.size()-1));
   69719             :    }
   69720             : 
   69721             : //############################################################################
   69722             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   69723             :  * memory pool and initializes the data member in class SgOmpFromClauseStroageClass
   69724             :  * from its counterpart of SgOmpFromClause. The return value is just for checking, 
   69725             :  * that the whole StorageClassArray is initialized!
   69726             :  */
   69727             : unsigned long
   69728           0 : SgOmpFromClause::initializeStorageClassArray( SgOmpFromClauseStorageClass *storageArray )
   69729             :    {
   69730           0 :      unsigned long storageCounter = 0;
   69731           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpFromClause::pools.begin();
   69732           0 :      SgOmpFromClause* pointer = NULL;
   69733           0 :      while ( block != SgOmpFromClause::pools.end() ) {
   69734           0 :           pointer = (SgOmpFromClause*) (*block);
   69735           0 :           for ( unsigned i = 0; i < SgOmpFromClause::pool_size; ++i ) {
   69736           0 :                if ( pointer->get_freepointer() != NULL ) {
   69737           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   69738           0 :                  storageArray++;
   69739           0 :                  storageCounter++;
   69740             :                }
   69741           0 :                pointer++;
   69742             :              }
   69743           0 :            block++;
   69744             :         }
   69745           0 :      return storageCounter;
   69746             :    }
   69747             : 
   69748             : /* #line 69749 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   69749             : 
   69750             : 
   69751             : 
   69752             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   69753             : 
   69754             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   69755             : 
   69756             : //############################################################################
   69757             : /* JH (02/02/2006) Constructor of the IR node SgOmpScheduleClause that takes its 
   69758             :  * corresponding StorageClass as parameter
   69759             :  */
   69760           0 : SgOmpScheduleClause :: SgOmpScheduleClause ( const SgOmpScheduleClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   69761             :    {
   69762             : 
   69763             : 
   69764             : /* #line 69765 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   69765             : 
   69766           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   69767           0 :      p_modifier = storageSource.storageOf_modifier ;
   69768           0 :      p_modifier1 = storageSource.storageOf_modifier1 ;
   69769           0 :      p_kind = storageSource.storageOf_kind ;
   69770           0 :      p_chunk_size =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_chunk_size) );
   69771             : 
   69772             : 
   69773             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   69774             : 
   69775             : 
   69776           0 :    }
   69777             : 
   69778             : //############################################################################
   69779             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   69780             :  * within the working AST. 
   69781             :  */
   69782           0 : SgOmpScheduleClause * SgOmpScheduleClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   69783           0 :      SgOmpScheduleClause* returnPointer = NULL;
   69784           0 :      if ( globalIndex != 0 )
   69785             :         {
   69786             : 
   69787             : #if FILE_IO_EXTRA_CHECK
   69788           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpScheduleClause ) ) <= globalIndex ) ;
   69789           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpScheduleClause + 1 ) ) );
   69790             : #endif
   69791           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpScheduleClause )  
   69792           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpScheduleClause );
   69793           0 :           unsigned long positionInPool = localIndex % SgOmpScheduleClause::pool_size;
   69794           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpScheduleClause::pool_size;
   69795             : 
   69796             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   69797             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   69798             : 
   69799           0 :           returnPointer = &( ( (SgOmpScheduleClause*)(SgOmpScheduleClause::pools[memoryBlock]) ) [positionInPool]) ;
   69800             : 
   69801           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   69802             :         }
   69803           0 :      return returnPointer ;
   69804             :    }
   69805             : 
   69806             : //############################################################################
   69807             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   69808             :   for the AST with the index astIndex
   69809             : */
   69810           0 : SgOmpScheduleClause * SgOmpScheduleClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   69811           0 :      SgOmpScheduleClause* returnPointer = NULL;
   69812           0 :      if ( globalIndex != 0 )
   69813             :         {
   69814             : 
   69815             : #if FILE_IO_EXTRA_CHECK
   69816           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpScheduleClause ) ) <= globalIndex ) ;
   69817           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpScheduleClause + 1 ) ) );
   69818             : #endif
   69819           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpScheduleClause )
   69820           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpScheduleClause );
   69821           0 :           unsigned long positionInPool = localIndex % SgOmpScheduleClause::pool_size ;
   69822           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpScheduleClause::pool_size ;
   69823             : 
   69824             : #if FILE_IO_EXTRA_CHECK
   69825             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   69826             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   69827             : #endif
   69828             : 
   69829           0 :           returnPointer = &( ( (SgOmpScheduleClause*)(SgOmpScheduleClause::pools[memoryBlock]) ) [positionInPool]) ;
   69830             : 
   69831             : #if FILE_IO_EXTRA_CHECK
   69832           0 :           assert ( returnPointer != NULL ) ;
   69833             : #endif
   69834             :         }
   69835           0 :      return returnPointer ;
   69836             :    }
   69837             : 
   69838             : //############################################################################
   69839             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   69840             :  * pool size! We set for every valid object in the memory pool the freepointer
   69841             :  * to the global index and increase the global index afterwards. For all the 
   69842             :  * invalid objects (means address ranges within the memory pool that were not
   69843             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   69844             :  * distinguish valid from invalid objects! 
   69845             :  */
   69846             : unsigned long
   69847           5 : SgOmpScheduleClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   69848             :    {
   69849           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   69850           5 :      SgOmpScheduleClause* pointer = NULL;
   69851           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   69852           5 :      std::vector < unsigned char* > :: const_iterator block;
   69853           5 :      for ( block = SgOmpScheduleClause::pools.begin(); block != SgOmpScheduleClause::pools.end() ; ++block )
   69854             :         {
   69855           0 :           pointer = (SgOmpScheduleClause*)(*block);
   69856           0 :           for (unsigned i = 0; i < SgOmpScheduleClause::pool_size; ++i )
   69857             :              {
   69858             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   69859             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   69860             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   69861             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   69862             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   69863             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   69864             :             // properly; so this will have to be checked next.
   69865             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   69866             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   69867           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   69868             :                   {
   69869           0 :                     pointer[i].set_freepointer((SgOmpScheduleClause*)(globalIndex));
   69870           0 :                     globalIndex++;
   69871             :                   }
   69872             :                else
   69873             :                   {
   69874           0 :                     pointer[i].set_freepointer(NULL);
   69875             :                   }
   69876             :               }
   69877             :         }
   69878           5 :      return globalIndex;
   69879             :    }
   69880             : 
   69881             : //############################################################################
   69882             : // JH (01/14/2006)
   69883             : void
   69884           5 : SgOmpScheduleClause::resetValidFreepointers( )
   69885             :    {
   69886           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   69887           5 :      SgOmpScheduleClause* pointer = NULL;
   69888           5 :      std::vector < unsigned char* > :: const_iterator block;
   69889           5 :      SgOmpScheduleClause* pointerOfLinkedList = NULL;
   69890           5 :      for ( block = SgOmpScheduleClause::pools.begin(); block != SgOmpScheduleClause::pools.end() ; ++block )
   69891             :         {
   69892           0 :           pointer = (SgOmpScheduleClause*)(*block);
   69893           0 :           for (unsigned i = 0; i < SgOmpScheduleClause::pool_size; ++i )
   69894             :              {
   69895             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   69896             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   69897             :             // memory blocks!.
   69898           0 :                if ( pointer[i].get_freepointer() != NULL )
   69899             :                   {
   69900           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   69901             :                   }
   69902             :                else
   69903             :                   {
   69904           0 :                     if ( pointerOfLinkedList == NULL )
   69905             :                        {
   69906           0 :                          SgOmpScheduleClause::next_node = &(pointer[i]);
   69907             :                        }
   69908             :                     else
   69909             :                        {
   69910             :                       // printf ("In SgOmpScheduleClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   69911           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   69912             :                        }
   69913             :                     pointerOfLinkedList = &(pointer[i]);
   69914             :                   }
   69915             :               }
   69916             :         }
   69917             : 
   69918           5 :      if ( pointerOfLinkedList != NULL )
   69919             :         {
   69920             :        // printf ("In SgOmpScheduleClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   69921           0 :           pointerOfLinkedList->set_freepointer(NULL);
   69922             :        // DQ (6/6/2010): Temporary debugging...
   69923             :        //   ROSE_ASSERT(false);
   69924             :         }
   69925             : 
   69926           5 :      return ;
   69927             :    }
   69928             : 
   69929             : //############################################################################
   69930             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   69931             :  * within the memory pool and resets the freepointers, in order to achieve a 
   69932             :  * linked list, that has no jumps and starts at the beginning! This function 
   69933             :  * does not extend the memory pool, since we do not delete any memory blocks,
   69934             :  * but delete the valid objects.  
   69935             :  */
   69936             : void
   69937           0 : SgOmpScheduleClause::clearMemoryPool( )
   69938             :    {
   69939             :   // printf ("Inside of SgOmpScheduleClause::clearMemoryPool() \n");
   69940             : 
   69941           0 :      SgOmpScheduleClause* pointer = NULL, *tempPointer = NULL;
   69942           0 :      std::vector < unsigned char* > :: const_iterator block;
   69943           0 :      if ( SgOmpScheduleClause::pools.empty() == false )
   69944             :         {
   69945           0 :           block = SgOmpScheduleClause::pools.begin() ;
   69946           0 :           SgOmpScheduleClause::next_node = (SgOmpScheduleClause*) (*block);
   69947             : 
   69948           0 :           while ( block != SgOmpScheduleClause::pools.end() )
   69949             :              {
   69950           0 :                pointer = (SgOmpScheduleClause*) (*block);
   69951           0 :                if ( tempPointer != NULL )
   69952             :                   {
   69953           0 :                     tempPointer->set_freepointer(pointer);
   69954             :                   }
   69955           0 :                for (unsigned i = 0; i < SgOmpScheduleClause::pool_size - 1; ++i)
   69956             :                   {
   69957           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   69958             :                   }
   69959           0 :                 pointer[SgOmpScheduleClause::pool_size-1].set_freepointer(NULL);
   69960           0 :                 tempPointer = &(pointer[SgOmpScheduleClause::pool_size-1]);
   69961           0 :                 ++block;
   69962             :              }
   69963             :         }
   69964           0 :    }
   69965             : 
   69966           5 : void SgOmpScheduleClause::deleteMemoryPool() {
   69967           5 :   for (auto p: SgOmpScheduleClause::pools) {
   69968           0 :     ROSE_FREE(p);
   69969             :   }
   69970           5 :   SgOmpScheduleClause::next_node = nullptr;
   69971           5 :   SgOmpScheduleClause::pools.clear();
   69972           5 : }
   69973             : 
   69974             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   69975             : //                 reading multiple binary files to for a single AST.
   69976             : /////////// new version ////////////////////////////////
   69977             : //############################################################################
   69978             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   69979             : void
   69980           2 : SgOmpScheduleClause::extendMemoryPoolForFileIO( )
   69981             :   {
   69982           2 :     size_t blockIndex = SgOmpScheduleClause::pools.size();
   69983           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpScheduleClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpScheduleClause);
   69984             : 
   69985           2 :     while ( (blockIndex * SgOmpScheduleClause::pool_size) < newPoolSize)
   69986             :       {
   69987             : #if ROSE_ALLOC_TRACE
   69988             :         if (blockIndex > 0) {
   69989             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpScheduleClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpScheduleClause) = %" PRIuPTR " SgOmpScheduleClause::pool_size = %d \n",
   69990             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpScheduleClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpScheduleClause),SgOmpScheduleClause::pool_size);
   69991             :         }
   69992             : #endif
   69993             : 
   69994           0 :         SgOmpScheduleClause * pointer = (SgOmpScheduleClause*) ROSE_MALLOC ( SgOmpScheduleClause::pool_size * sizeof(SgOmpScheduleClause) );
   69995           0 :         assert( pointer != NULL );
   69996             : #if ROSE_ALLOC_MEMSET == 1
   69997             :         memset(pointer, 0x00, SgOmpScheduleClause::pool_size * sizeof(SgOmpScheduleClause));
   69998             : #elif ROSE_ALLOC_MEMSET == 2
   69999             :         memset(pointer, 0xCC, SgOmpScheduleClause::pool_size * sizeof(SgOmpScheduleClause));
   70000             : #endif
   70001           0 :         SgOmpScheduleClause::pools.push_back( (unsigned char*)(pointer) );
   70002           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpScheduleClause::pool_size * sizeof(SgOmpScheduleClause), V_SgOmpScheduleClause ) );
   70003             : 
   70004           0 :         if ( SgOmpScheduleClause::next_node != NULL ) {
   70005           0 :           if ( blockIndex > 0 ) {
   70006           0 :             SgOmpScheduleClause * blkptr = (SgOmpScheduleClause*)(SgOmpScheduleClause::pools[blockIndex-1]);
   70007           0 :             blkptr[ SgOmpScheduleClause::pool_size - 1 ].set_freepointer(pointer);
   70008             :           }
   70009             :         } else {
   70010           0 :           SgOmpScheduleClause::next_node = pointer;
   70011             :         }
   70012             : 
   70013           0 :         for (unsigned i = 0; i < SgOmpScheduleClause::pool_size-1; ++i)
   70014             :            {
   70015           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   70016             :            }
   70017           0 :         pointer[ SgOmpScheduleClause::pool_size -1 ].set_freepointer(NULL);
   70018             : 
   70019           0 :         blockIndex++;
   70020             :       }
   70021           2 :   }
   70022             : 
   70023             : //############################################################################
   70024             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   70025             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   70026             :  * not compressed. However, that stuff is not yet implemented! 
   70027             :  */
   70028             : unsigned long
   70029           0 : SgOmpScheduleClause::getNumberOfLastValidPointer()
   70030             :    {
   70031           0 :       SgOmpScheduleClause* testPointer = (SgOmpScheduleClause*)(SgOmpScheduleClause::pools.back());
   70032           0 :       unsigned long localIndex = SgOmpScheduleClause::pool_size - 1;
   70033           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   70034             :          {
   70035           0 :            localIndex--;
   70036             :          }
   70037           0 :       return (localIndex + SgOmpScheduleClause::pool_size * (SgOmpScheduleClause::pools.size()-1));
   70038             :    }
   70039             : 
   70040             : //############################################################################
   70041             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   70042             :  * memory pool and initializes the data member in class SgOmpScheduleClauseStroageClass
   70043             :  * from its counterpart of SgOmpScheduleClause. The return value is just for checking, 
   70044             :  * that the whole StorageClassArray is initialized!
   70045             :  */
   70046             : unsigned long
   70047           0 : SgOmpScheduleClause::initializeStorageClassArray( SgOmpScheduleClauseStorageClass *storageArray )
   70048             :    {
   70049           0 :      unsigned long storageCounter = 0;
   70050           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpScheduleClause::pools.begin();
   70051           0 :      SgOmpScheduleClause* pointer = NULL;
   70052           0 :      while ( block != SgOmpScheduleClause::pools.end() ) {
   70053           0 :           pointer = (SgOmpScheduleClause*) (*block);
   70054           0 :           for ( unsigned i = 0; i < SgOmpScheduleClause::pool_size; ++i ) {
   70055           0 :                if ( pointer->get_freepointer() != NULL ) {
   70056           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   70057           0 :                  storageArray++;
   70058           0 :                  storageCounter++;
   70059             :                }
   70060           0 :                pointer++;
   70061             :              }
   70062           0 :            block++;
   70063             :         }
   70064           0 :      return storageCounter;
   70065             :    }
   70066             : 
   70067             : /* #line 70068 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   70068             : 
   70069             : 
   70070             : 
   70071             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   70072             : 
   70073             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   70074             : 
   70075             : //############################################################################
   70076             : /* JH (02/02/2006) Constructor of the IR node SgOmpMergeableClause that takes its 
   70077             :  * corresponding StorageClass as parameter
   70078             :  */
   70079           0 : SgOmpMergeableClause :: SgOmpMergeableClause ( const SgOmpMergeableClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   70080             :    {
   70081             : 
   70082             : 
   70083             : /* #line 70084 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   70084             : 
   70085           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   70086             : 
   70087             : 
   70088             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   70089             : 
   70090             : 
   70091           0 :    }
   70092             : 
   70093             : //############################################################################
   70094             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   70095             :  * within the working AST. 
   70096             :  */
   70097           0 : SgOmpMergeableClause * SgOmpMergeableClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   70098           0 :      SgOmpMergeableClause* returnPointer = NULL;
   70099           0 :      if ( globalIndex != 0 )
   70100             :         {
   70101             : 
   70102             : #if FILE_IO_EXTRA_CHECK
   70103           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpMergeableClause ) ) <= globalIndex ) ;
   70104           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMergeableClause + 1 ) ) );
   70105             : #endif
   70106           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMergeableClause )  
   70107           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpMergeableClause );
   70108           0 :           unsigned long positionInPool = localIndex % SgOmpMergeableClause::pool_size;
   70109           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMergeableClause::pool_size;
   70110             : 
   70111             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   70112             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   70113             : 
   70114           0 :           returnPointer = &( ( (SgOmpMergeableClause*)(SgOmpMergeableClause::pools[memoryBlock]) ) [positionInPool]) ;
   70115             : 
   70116           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   70117             :         }
   70118           0 :      return returnPointer ;
   70119             :    }
   70120             : 
   70121             : //############################################################################
   70122             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   70123             :   for the AST with the index astIndex
   70124             : */
   70125           0 : SgOmpMergeableClause * SgOmpMergeableClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   70126           0 :      SgOmpMergeableClause* returnPointer = NULL;
   70127           0 :      if ( globalIndex != 0 )
   70128             :         {
   70129             : 
   70130             : #if FILE_IO_EXTRA_CHECK
   70131           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpMergeableClause ) ) <= globalIndex ) ;
   70132           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMergeableClause + 1 ) ) );
   70133             : #endif
   70134           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMergeableClause )
   70135           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpMergeableClause );
   70136           0 :           unsigned long positionInPool = localIndex % SgOmpMergeableClause::pool_size ;
   70137           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMergeableClause::pool_size ;
   70138             : 
   70139             : #if FILE_IO_EXTRA_CHECK
   70140             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   70141             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   70142             : #endif
   70143             : 
   70144           0 :           returnPointer = &( ( (SgOmpMergeableClause*)(SgOmpMergeableClause::pools[memoryBlock]) ) [positionInPool]) ;
   70145             : 
   70146             : #if FILE_IO_EXTRA_CHECK
   70147           0 :           assert ( returnPointer != NULL ) ;
   70148             : #endif
   70149             :         }
   70150           0 :      return returnPointer ;
   70151             :    }
   70152             : 
   70153             : //############################################################################
   70154             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   70155             :  * pool size! We set for every valid object in the memory pool the freepointer
   70156             :  * to the global index and increase the global index afterwards. For all the 
   70157             :  * invalid objects (means address ranges within the memory pool that were not
   70158             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   70159             :  * distinguish valid from invalid objects! 
   70160             :  */
   70161             : unsigned long
   70162           5 : SgOmpMergeableClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   70163             :    {
   70164           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   70165           5 :      SgOmpMergeableClause* pointer = NULL;
   70166           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   70167           5 :      std::vector < unsigned char* > :: const_iterator block;
   70168           5 :      for ( block = SgOmpMergeableClause::pools.begin(); block != SgOmpMergeableClause::pools.end() ; ++block )
   70169             :         {
   70170           0 :           pointer = (SgOmpMergeableClause*)(*block);
   70171           0 :           for (unsigned i = 0; i < SgOmpMergeableClause::pool_size; ++i )
   70172             :              {
   70173             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   70174             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   70175             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   70176             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   70177             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   70178             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   70179             :             // properly; so this will have to be checked next.
   70180             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   70181             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   70182           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   70183             :                   {
   70184           0 :                     pointer[i].set_freepointer((SgOmpMergeableClause*)(globalIndex));
   70185           0 :                     globalIndex++;
   70186             :                   }
   70187             :                else
   70188             :                   {
   70189           0 :                     pointer[i].set_freepointer(NULL);
   70190             :                   }
   70191             :               }
   70192             :         }
   70193           5 :      return globalIndex;
   70194             :    }
   70195             : 
   70196             : //############################################################################
   70197             : // JH (01/14/2006)
   70198             : void
   70199           5 : SgOmpMergeableClause::resetValidFreepointers( )
   70200             :    {
   70201           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   70202           5 :      SgOmpMergeableClause* pointer = NULL;
   70203           5 :      std::vector < unsigned char* > :: const_iterator block;
   70204           5 :      SgOmpMergeableClause* pointerOfLinkedList = NULL;
   70205           5 :      for ( block = SgOmpMergeableClause::pools.begin(); block != SgOmpMergeableClause::pools.end() ; ++block )
   70206             :         {
   70207           0 :           pointer = (SgOmpMergeableClause*)(*block);
   70208           0 :           for (unsigned i = 0; i < SgOmpMergeableClause::pool_size; ++i )
   70209             :              {
   70210             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   70211             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   70212             :             // memory blocks!.
   70213           0 :                if ( pointer[i].get_freepointer() != NULL )
   70214             :                   {
   70215           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   70216             :                   }
   70217             :                else
   70218             :                   {
   70219           0 :                     if ( pointerOfLinkedList == NULL )
   70220             :                        {
   70221           0 :                          SgOmpMergeableClause::next_node = &(pointer[i]);
   70222             :                        }
   70223             :                     else
   70224             :                        {
   70225             :                       // printf ("In SgOmpMergeableClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   70226           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   70227             :                        }
   70228             :                     pointerOfLinkedList = &(pointer[i]);
   70229             :                   }
   70230             :               }
   70231             :         }
   70232             : 
   70233           5 :      if ( pointerOfLinkedList != NULL )
   70234             :         {
   70235             :        // printf ("In SgOmpMergeableClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   70236           0 :           pointerOfLinkedList->set_freepointer(NULL);
   70237             :        // DQ (6/6/2010): Temporary debugging...
   70238             :        //   ROSE_ASSERT(false);
   70239             :         }
   70240             : 
   70241           5 :      return ;
   70242             :    }
   70243             : 
   70244             : //############################################################################
   70245             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   70246             :  * within the memory pool and resets the freepointers, in order to achieve a 
   70247             :  * linked list, that has no jumps and starts at the beginning! This function 
   70248             :  * does not extend the memory pool, since we do not delete any memory blocks,
   70249             :  * but delete the valid objects.  
   70250             :  */
   70251             : void
   70252           0 : SgOmpMergeableClause::clearMemoryPool( )
   70253             :    {
   70254             :   // printf ("Inside of SgOmpMergeableClause::clearMemoryPool() \n");
   70255             : 
   70256           0 :      SgOmpMergeableClause* pointer = NULL, *tempPointer = NULL;
   70257           0 :      std::vector < unsigned char* > :: const_iterator block;
   70258           0 :      if ( SgOmpMergeableClause::pools.empty() == false )
   70259             :         {
   70260           0 :           block = SgOmpMergeableClause::pools.begin() ;
   70261           0 :           SgOmpMergeableClause::next_node = (SgOmpMergeableClause*) (*block);
   70262             : 
   70263           0 :           while ( block != SgOmpMergeableClause::pools.end() )
   70264             :              {
   70265           0 :                pointer = (SgOmpMergeableClause*) (*block);
   70266           0 :                if ( tempPointer != NULL )
   70267             :                   {
   70268           0 :                     tempPointer->set_freepointer(pointer);
   70269             :                   }
   70270           0 :                for (unsigned i = 0; i < SgOmpMergeableClause::pool_size - 1; ++i)
   70271             :                   {
   70272           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   70273             :                   }
   70274           0 :                 pointer[SgOmpMergeableClause::pool_size-1].set_freepointer(NULL);
   70275           0 :                 tempPointer = &(pointer[SgOmpMergeableClause::pool_size-1]);
   70276           0 :                 ++block;
   70277             :              }
   70278             :         }
   70279           0 :    }
   70280             : 
   70281           5 : void SgOmpMergeableClause::deleteMemoryPool() {
   70282           5 :   for (auto p: SgOmpMergeableClause::pools) {
   70283           0 :     ROSE_FREE(p);
   70284             :   }
   70285           5 :   SgOmpMergeableClause::next_node = nullptr;
   70286           5 :   SgOmpMergeableClause::pools.clear();
   70287           5 : }
   70288             : 
   70289             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   70290             : //                 reading multiple binary files to for a single AST.
   70291             : /////////// new version ////////////////////////////////
   70292             : //############################################################################
   70293             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   70294             : void
   70295           2 : SgOmpMergeableClause::extendMemoryPoolForFileIO( )
   70296             :   {
   70297           2 :     size_t blockIndex = SgOmpMergeableClause::pools.size();
   70298           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMergeableClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMergeableClause);
   70299             : 
   70300           2 :     while ( (blockIndex * SgOmpMergeableClause::pool_size) < newPoolSize)
   70301             :       {
   70302             : #if ROSE_ALLOC_TRACE
   70303             :         if (blockIndex > 0) {
   70304             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMergeableClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMergeableClause) = %" PRIuPTR " SgOmpMergeableClause::pool_size = %d \n",
   70305             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMergeableClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMergeableClause),SgOmpMergeableClause::pool_size);
   70306             :         }
   70307             : #endif
   70308             : 
   70309           0 :         SgOmpMergeableClause * pointer = (SgOmpMergeableClause*) ROSE_MALLOC ( SgOmpMergeableClause::pool_size * sizeof(SgOmpMergeableClause) );
   70310           0 :         assert( pointer != NULL );
   70311             : #if ROSE_ALLOC_MEMSET == 1
   70312             :         memset(pointer, 0x00, SgOmpMergeableClause::pool_size * sizeof(SgOmpMergeableClause));
   70313             : #elif ROSE_ALLOC_MEMSET == 2
   70314             :         memset(pointer, 0xCC, SgOmpMergeableClause::pool_size * sizeof(SgOmpMergeableClause));
   70315             : #endif
   70316           0 :         SgOmpMergeableClause::pools.push_back( (unsigned char*)(pointer) );
   70317           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpMergeableClause::pool_size * sizeof(SgOmpMergeableClause), V_SgOmpMergeableClause ) );
   70318             : 
   70319           0 :         if ( SgOmpMergeableClause::next_node != NULL ) {
   70320           0 :           if ( blockIndex > 0 ) {
   70321           0 :             SgOmpMergeableClause * blkptr = (SgOmpMergeableClause*)(SgOmpMergeableClause::pools[blockIndex-1]);
   70322           0 :             blkptr[ SgOmpMergeableClause::pool_size - 1 ].set_freepointer(pointer);
   70323             :           }
   70324             :         } else {
   70325           0 :           SgOmpMergeableClause::next_node = pointer;
   70326             :         }
   70327             : 
   70328           0 :         for (unsigned i = 0; i < SgOmpMergeableClause::pool_size-1; ++i)
   70329             :            {
   70330           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   70331             :            }
   70332           0 :         pointer[ SgOmpMergeableClause::pool_size -1 ].set_freepointer(NULL);
   70333             : 
   70334           0 :         blockIndex++;
   70335             :       }
   70336           2 :   }
   70337             : 
   70338             : //############################################################################
   70339             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   70340             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   70341             :  * not compressed. However, that stuff is not yet implemented! 
   70342             :  */
   70343             : unsigned long
   70344           0 : SgOmpMergeableClause::getNumberOfLastValidPointer()
   70345             :    {
   70346           0 :       SgOmpMergeableClause* testPointer = (SgOmpMergeableClause*)(SgOmpMergeableClause::pools.back());
   70347           0 :       unsigned long localIndex = SgOmpMergeableClause::pool_size - 1;
   70348           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   70349             :          {
   70350           0 :            localIndex--;
   70351             :          }
   70352           0 :       return (localIndex + SgOmpMergeableClause::pool_size * (SgOmpMergeableClause::pools.size()-1));
   70353             :    }
   70354             : 
   70355             : //############################################################################
   70356             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   70357             :  * memory pool and initializes the data member in class SgOmpMergeableClauseStroageClass
   70358             :  * from its counterpart of SgOmpMergeableClause. The return value is just for checking, 
   70359             :  * that the whole StorageClassArray is initialized!
   70360             :  */
   70361             : unsigned long
   70362           0 : SgOmpMergeableClause::initializeStorageClassArray( SgOmpMergeableClauseStorageClass *storageArray )
   70363             :    {
   70364           0 :      unsigned long storageCounter = 0;
   70365           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpMergeableClause::pools.begin();
   70366           0 :      SgOmpMergeableClause* pointer = NULL;
   70367           0 :      while ( block != SgOmpMergeableClause::pools.end() ) {
   70368           0 :           pointer = (SgOmpMergeableClause*) (*block);
   70369           0 :           for ( unsigned i = 0; i < SgOmpMergeableClause::pool_size; ++i ) {
   70370           0 :                if ( pointer->get_freepointer() != NULL ) {
   70371           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   70372           0 :                  storageArray++;
   70373           0 :                  storageCounter++;
   70374             :                }
   70375           0 :                pointer++;
   70376             :              }
   70377           0 :            block++;
   70378             :         }
   70379           0 :      return storageCounter;
   70380             :    }
   70381             : 
   70382             : /* #line 70383 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   70383             : 
   70384             : 
   70385             : 
   70386             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   70387             : 
   70388             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   70389             : 
   70390             : //############################################################################
   70391             : /* JH (02/02/2006) Constructor of the IR node SgOmpWhenClause that takes its 
   70392             :  * corresponding StorageClass as parameter
   70393             :  */
   70394           0 : SgOmpWhenClause :: SgOmpWhenClause ( const SgOmpWhenClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   70395             :    {
   70396             : 
   70397             : 
   70398             : /* #line 70399 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   70399             : 
   70400           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   70401           0 :      p_user_condition =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_condition) );
   70402           0 :      p_user_condition_score =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_condition_score) );
   70403           0 :      p_construct_directives = storageSource.storageOf_construct_directives.rebuildDataStoredInEasyStorageClass() ;
   70404           0 :      p_device_arch =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_device_arch) );
   70405           0 :      p_device_isa =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_device_isa) );
   70406           0 :      p_device_kind = storageSource.storageOf_device_kind ;
   70407           0 :      p_implementation_vendor = storageSource.storageOf_implementation_vendor ;
   70408           0 :      p_implementation_user_defined =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_implementation_user_defined) );
   70409           0 :      p_implementation_extension =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_implementation_extension) );
   70410           0 :      p_variant_directive =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_variant_directive) );
   70411             : 
   70412             : 
   70413             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   70414             : 
   70415             : 
   70416           0 :    }
   70417             : 
   70418             : //############################################################################
   70419             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   70420             :  * within the working AST. 
   70421             :  */
   70422           0 : SgOmpWhenClause * SgOmpWhenClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   70423           0 :      SgOmpWhenClause* returnPointer = NULL;
   70424           0 :      if ( globalIndex != 0 )
   70425             :         {
   70426             : 
   70427             : #if FILE_IO_EXTRA_CHECK
   70428           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpWhenClause ) ) <= globalIndex ) ;
   70429           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpWhenClause + 1 ) ) );
   70430             : #endif
   70431           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpWhenClause )  
   70432           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpWhenClause );
   70433           0 :           unsigned long positionInPool = localIndex % SgOmpWhenClause::pool_size;
   70434           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpWhenClause::pool_size;
   70435             : 
   70436             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   70437             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   70438             : 
   70439           0 :           returnPointer = &( ( (SgOmpWhenClause*)(SgOmpWhenClause::pools[memoryBlock]) ) [positionInPool]) ;
   70440             : 
   70441           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   70442             :         }
   70443           0 :      return returnPointer ;
   70444             :    }
   70445             : 
   70446             : //############################################################################
   70447             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   70448             :   for the AST with the index astIndex
   70449             : */
   70450           0 : SgOmpWhenClause * SgOmpWhenClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   70451           0 :      SgOmpWhenClause* returnPointer = NULL;
   70452           0 :      if ( globalIndex != 0 )
   70453             :         {
   70454             : 
   70455             : #if FILE_IO_EXTRA_CHECK
   70456           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpWhenClause ) ) <= globalIndex ) ;
   70457           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpWhenClause + 1 ) ) );
   70458             : #endif
   70459           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpWhenClause )
   70460           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpWhenClause );
   70461           0 :           unsigned long positionInPool = localIndex % SgOmpWhenClause::pool_size ;
   70462           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpWhenClause::pool_size ;
   70463             : 
   70464             : #if FILE_IO_EXTRA_CHECK
   70465             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   70466             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   70467             : #endif
   70468             : 
   70469           0 :           returnPointer = &( ( (SgOmpWhenClause*)(SgOmpWhenClause::pools[memoryBlock]) ) [positionInPool]) ;
   70470             : 
   70471             : #if FILE_IO_EXTRA_CHECK
   70472           0 :           assert ( returnPointer != NULL ) ;
   70473             : #endif
   70474             :         }
   70475           0 :      return returnPointer ;
   70476             :    }
   70477             : 
   70478             : //############################################################################
   70479             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   70480             :  * pool size! We set for every valid object in the memory pool the freepointer
   70481             :  * to the global index and increase the global index afterwards. For all the 
   70482             :  * invalid objects (means address ranges within the memory pool that were not
   70483             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   70484             :  * distinguish valid from invalid objects! 
   70485             :  */
   70486             : unsigned long
   70487           5 : SgOmpWhenClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   70488             :    {
   70489           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   70490           5 :      SgOmpWhenClause* pointer = NULL;
   70491           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   70492           5 :      std::vector < unsigned char* > :: const_iterator block;
   70493           5 :      for ( block = SgOmpWhenClause::pools.begin(); block != SgOmpWhenClause::pools.end() ; ++block )
   70494             :         {
   70495           0 :           pointer = (SgOmpWhenClause*)(*block);
   70496           0 :           for (unsigned i = 0; i < SgOmpWhenClause::pool_size; ++i )
   70497             :              {
   70498             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   70499             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   70500             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   70501             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   70502             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   70503             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   70504             :             // properly; so this will have to be checked next.
   70505             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   70506             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   70507           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   70508             :                   {
   70509           0 :                     pointer[i].set_freepointer((SgOmpWhenClause*)(globalIndex));
   70510           0 :                     globalIndex++;
   70511             :                   }
   70512             :                else
   70513             :                   {
   70514           0 :                     pointer[i].set_freepointer(NULL);
   70515             :                   }
   70516             :               }
   70517             :         }
   70518           5 :      return globalIndex;
   70519             :    }
   70520             : 
   70521             : //############################################################################
   70522             : // JH (01/14/2006)
   70523             : void
   70524           5 : SgOmpWhenClause::resetValidFreepointers( )
   70525             :    {
   70526           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   70527           5 :      SgOmpWhenClause* pointer = NULL;
   70528           5 :      std::vector < unsigned char* > :: const_iterator block;
   70529           5 :      SgOmpWhenClause* pointerOfLinkedList = NULL;
   70530           5 :      for ( block = SgOmpWhenClause::pools.begin(); block != SgOmpWhenClause::pools.end() ; ++block )
   70531             :         {
   70532           0 :           pointer = (SgOmpWhenClause*)(*block);
   70533           0 :           for (unsigned i = 0; i < SgOmpWhenClause::pool_size; ++i )
   70534             :              {
   70535             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   70536             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   70537             :             // memory blocks!.
   70538           0 :                if ( pointer[i].get_freepointer() != NULL )
   70539             :                   {
   70540           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   70541             :                   }
   70542             :                else
   70543             :                   {
   70544           0 :                     if ( pointerOfLinkedList == NULL )
   70545             :                        {
   70546           0 :                          SgOmpWhenClause::next_node = &(pointer[i]);
   70547             :                        }
   70548             :                     else
   70549             :                        {
   70550             :                       // printf ("In SgOmpWhenClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   70551           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   70552             :                        }
   70553             :                     pointerOfLinkedList = &(pointer[i]);
   70554             :                   }
   70555             :               }
   70556             :         }
   70557             : 
   70558           5 :      if ( pointerOfLinkedList != NULL )
   70559             :         {
   70560             :        // printf ("In SgOmpWhenClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   70561           0 :           pointerOfLinkedList->set_freepointer(NULL);
   70562             :        // DQ (6/6/2010): Temporary debugging...
   70563             :        //   ROSE_ASSERT(false);
   70564             :         }
   70565             : 
   70566           5 :      return ;
   70567             :    }
   70568             : 
   70569             : //############################################################################
   70570             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   70571             :  * within the memory pool and resets the freepointers, in order to achieve a 
   70572             :  * linked list, that has no jumps and starts at the beginning! This function 
   70573             :  * does not extend the memory pool, since we do not delete any memory blocks,
   70574             :  * but delete the valid objects.  
   70575             :  */
   70576             : void
   70577           0 : SgOmpWhenClause::clearMemoryPool( )
   70578             :    {
   70579             :   // printf ("Inside of SgOmpWhenClause::clearMemoryPool() \n");
   70580             : 
   70581           0 :      SgOmpWhenClause* pointer = NULL, *tempPointer = NULL;
   70582           0 :      std::vector < unsigned char* > :: const_iterator block;
   70583           0 :      if ( SgOmpWhenClause::pools.empty() == false )
   70584             :         {
   70585           0 :           block = SgOmpWhenClause::pools.begin() ;
   70586           0 :           SgOmpWhenClause::next_node = (SgOmpWhenClause*) (*block);
   70587             : 
   70588           0 :           while ( block != SgOmpWhenClause::pools.end() )
   70589             :              {
   70590           0 :                pointer = (SgOmpWhenClause*) (*block);
   70591           0 :                if ( tempPointer != NULL )
   70592             :                   {
   70593           0 :                     tempPointer->set_freepointer(pointer);
   70594             :                   }
   70595           0 :                for (unsigned i = 0; i < SgOmpWhenClause::pool_size - 1; ++i)
   70596             :                   {
   70597           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   70598             :                   }
   70599           0 :                 pointer[SgOmpWhenClause::pool_size-1].set_freepointer(NULL);
   70600           0 :                 tempPointer = &(pointer[SgOmpWhenClause::pool_size-1]);
   70601           0 :                 ++block;
   70602             :              }
   70603             :         }
   70604           0 :    }
   70605             : 
   70606           5 : void SgOmpWhenClause::deleteMemoryPool() {
   70607           5 :   for (auto p: SgOmpWhenClause::pools) {
   70608           0 :     ROSE_FREE(p);
   70609             :   }
   70610           5 :   SgOmpWhenClause::next_node = nullptr;
   70611           5 :   SgOmpWhenClause::pools.clear();
   70612           5 : }
   70613             : 
   70614             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   70615             : //                 reading multiple binary files to for a single AST.
   70616             : /////////// new version ////////////////////////////////
   70617             : //############################################################################
   70618             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   70619             : void
   70620           2 : SgOmpWhenClause::extendMemoryPoolForFileIO( )
   70621             :   {
   70622           2 :     size_t blockIndex = SgOmpWhenClause::pools.size();
   70623           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWhenClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWhenClause);
   70624             : 
   70625           2 :     while ( (blockIndex * SgOmpWhenClause::pool_size) < newPoolSize)
   70626             :       {
   70627             : #if ROSE_ALLOC_TRACE
   70628             :         if (blockIndex > 0) {
   70629             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWhenClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWhenClause) = %" PRIuPTR " SgOmpWhenClause::pool_size = %d \n",
   70630             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWhenClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWhenClause),SgOmpWhenClause::pool_size);
   70631             :         }
   70632             : #endif
   70633             : 
   70634           0 :         SgOmpWhenClause * pointer = (SgOmpWhenClause*) ROSE_MALLOC ( SgOmpWhenClause::pool_size * sizeof(SgOmpWhenClause) );
   70635           0 :         assert( pointer != NULL );
   70636             : #if ROSE_ALLOC_MEMSET == 1
   70637             :         memset(pointer, 0x00, SgOmpWhenClause::pool_size * sizeof(SgOmpWhenClause));
   70638             : #elif ROSE_ALLOC_MEMSET == 2
   70639             :         memset(pointer, 0xCC, SgOmpWhenClause::pool_size * sizeof(SgOmpWhenClause));
   70640             : #endif
   70641           0 :         SgOmpWhenClause::pools.push_back( (unsigned char*)(pointer) );
   70642           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpWhenClause::pool_size * sizeof(SgOmpWhenClause), V_SgOmpWhenClause ) );
   70643             : 
   70644           0 :         if ( SgOmpWhenClause::next_node != NULL ) {
   70645           0 :           if ( blockIndex > 0 ) {
   70646           0 :             SgOmpWhenClause * blkptr = (SgOmpWhenClause*)(SgOmpWhenClause::pools[blockIndex-1]);
   70647           0 :             blkptr[ SgOmpWhenClause::pool_size - 1 ].set_freepointer(pointer);
   70648             :           }
   70649             :         } else {
   70650           0 :           SgOmpWhenClause::next_node = pointer;
   70651             :         }
   70652             : 
   70653           0 :         for (unsigned i = 0; i < SgOmpWhenClause::pool_size-1; ++i)
   70654             :            {
   70655           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   70656             :            }
   70657           0 :         pointer[ SgOmpWhenClause::pool_size -1 ].set_freepointer(NULL);
   70658             : 
   70659           0 :         blockIndex++;
   70660             :       }
   70661           2 :   }
   70662             : 
   70663             : //############################################################################
   70664             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   70665             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   70666             :  * not compressed. However, that stuff is not yet implemented! 
   70667             :  */
   70668             : unsigned long
   70669           0 : SgOmpWhenClause::getNumberOfLastValidPointer()
   70670             :    {
   70671           0 :       SgOmpWhenClause* testPointer = (SgOmpWhenClause*)(SgOmpWhenClause::pools.back());
   70672           0 :       unsigned long localIndex = SgOmpWhenClause::pool_size - 1;
   70673           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   70674             :          {
   70675           0 :            localIndex--;
   70676             :          }
   70677           0 :       return (localIndex + SgOmpWhenClause::pool_size * (SgOmpWhenClause::pools.size()-1));
   70678             :    }
   70679             : 
   70680             : //############################################################################
   70681             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   70682             :  * memory pool and initializes the data member in class SgOmpWhenClauseStroageClass
   70683             :  * from its counterpart of SgOmpWhenClause. The return value is just for checking, 
   70684             :  * that the whole StorageClassArray is initialized!
   70685             :  */
   70686             : unsigned long
   70687           0 : SgOmpWhenClause::initializeStorageClassArray( SgOmpWhenClauseStorageClass *storageArray )
   70688             :    {
   70689           0 :      unsigned long storageCounter = 0;
   70690           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpWhenClause::pools.begin();
   70691           0 :      SgOmpWhenClause* pointer = NULL;
   70692           0 :      while ( block != SgOmpWhenClause::pools.end() ) {
   70693           0 :           pointer = (SgOmpWhenClause*) (*block);
   70694           0 :           for ( unsigned i = 0; i < SgOmpWhenClause::pool_size; ++i ) {
   70695           0 :                if ( pointer->get_freepointer() != NULL ) {
   70696           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   70697           0 :                  storageArray++;
   70698           0 :                  storageCounter++;
   70699             :                }
   70700           0 :                pointer++;
   70701             :              }
   70702           0 :            block++;
   70703             :         }
   70704           0 :      return storageCounter;
   70705             :    }
   70706             : 
   70707             : /* #line 70708 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   70708             : 
   70709             : 
   70710             : 
   70711             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   70712             : 
   70713             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   70714             : 
   70715             : //############################################################################
   70716             : /* JH (02/02/2006) Constructor of the IR node SgOmpUsesAllocatorsClause that takes its 
   70717             :  * corresponding StorageClass as parameter
   70718             :  */
   70719           0 : SgOmpUsesAllocatorsClause :: SgOmpUsesAllocatorsClause ( const SgOmpUsesAllocatorsClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   70720             :    {
   70721             : 
   70722             : 
   70723             : /* #line 70724 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   70724             : 
   70725           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   70726           0 :      p_uses_allocators_defination = storageSource.storageOf_uses_allocators_defination.rebuildDataStoredInEasyStorageClass() ;
   70727             : 
   70728             : 
   70729             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   70730             : 
   70731             : 
   70732           0 :    }
   70733             : 
   70734             : //############################################################################
   70735             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   70736             :  * within the working AST. 
   70737             :  */
   70738           0 : SgOmpUsesAllocatorsClause * SgOmpUsesAllocatorsClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   70739           0 :      SgOmpUsesAllocatorsClause* returnPointer = NULL;
   70740           0 :      if ( globalIndex != 0 )
   70741             :         {
   70742             : 
   70743             : #if FILE_IO_EXTRA_CHECK
   70744           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUsesAllocatorsClause ) ) <= globalIndex ) ;
   70745           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUsesAllocatorsClause + 1 ) ) );
   70746             : #endif
   70747           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUsesAllocatorsClause )  
   70748           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUsesAllocatorsClause );
   70749           0 :           unsigned long positionInPool = localIndex % SgOmpUsesAllocatorsClause::pool_size;
   70750           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUsesAllocatorsClause::pool_size;
   70751             : 
   70752             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   70753             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   70754             : 
   70755           0 :           returnPointer = &( ( (SgOmpUsesAllocatorsClause*)(SgOmpUsesAllocatorsClause::pools[memoryBlock]) ) [positionInPool]) ;
   70756             : 
   70757           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   70758             :         }
   70759           0 :      return returnPointer ;
   70760             :    }
   70761             : 
   70762             : //############################################################################
   70763             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   70764             :   for the AST with the index astIndex
   70765             : */
   70766           0 : SgOmpUsesAllocatorsClause * SgOmpUsesAllocatorsClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   70767           0 :      SgOmpUsesAllocatorsClause* returnPointer = NULL;
   70768           0 :      if ( globalIndex != 0 )
   70769             :         {
   70770             : 
   70771             : #if FILE_IO_EXTRA_CHECK
   70772           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUsesAllocatorsClause ) ) <= globalIndex ) ;
   70773           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUsesAllocatorsClause + 1 ) ) );
   70774             : #endif
   70775           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUsesAllocatorsClause )
   70776           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUsesAllocatorsClause );
   70777           0 :           unsigned long positionInPool = localIndex % SgOmpUsesAllocatorsClause::pool_size ;
   70778           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUsesAllocatorsClause::pool_size ;
   70779             : 
   70780             : #if FILE_IO_EXTRA_CHECK
   70781             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   70782             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   70783             : #endif
   70784             : 
   70785           0 :           returnPointer = &( ( (SgOmpUsesAllocatorsClause*)(SgOmpUsesAllocatorsClause::pools[memoryBlock]) ) [positionInPool]) ;
   70786             : 
   70787             : #if FILE_IO_EXTRA_CHECK
   70788           0 :           assert ( returnPointer != NULL ) ;
   70789             : #endif
   70790             :         }
   70791           0 :      return returnPointer ;
   70792             :    }
   70793             : 
   70794             : //############################################################################
   70795             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   70796             :  * pool size! We set for every valid object in the memory pool the freepointer
   70797             :  * to the global index and increase the global index afterwards. For all the 
   70798             :  * invalid objects (means address ranges within the memory pool that were not
   70799             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   70800             :  * distinguish valid from invalid objects! 
   70801             :  */
   70802             : unsigned long
   70803           5 : SgOmpUsesAllocatorsClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   70804             :    {
   70805           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   70806           5 :      SgOmpUsesAllocatorsClause* pointer = NULL;
   70807           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   70808           5 :      std::vector < unsigned char* > :: const_iterator block;
   70809           5 :      for ( block = SgOmpUsesAllocatorsClause::pools.begin(); block != SgOmpUsesAllocatorsClause::pools.end() ; ++block )
   70810             :         {
   70811           0 :           pointer = (SgOmpUsesAllocatorsClause*)(*block);
   70812           0 :           for (unsigned i = 0; i < SgOmpUsesAllocatorsClause::pool_size; ++i )
   70813             :              {
   70814             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   70815             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   70816             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   70817             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   70818             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   70819             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   70820             :             // properly; so this will have to be checked next.
   70821             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   70822             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   70823           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   70824             :                   {
   70825           0 :                     pointer[i].set_freepointer((SgOmpUsesAllocatorsClause*)(globalIndex));
   70826           0 :                     globalIndex++;
   70827             :                   }
   70828             :                else
   70829             :                   {
   70830           0 :                     pointer[i].set_freepointer(NULL);
   70831             :                   }
   70832             :               }
   70833             :         }
   70834           5 :      return globalIndex;
   70835             :    }
   70836             : 
   70837             : //############################################################################
   70838             : // JH (01/14/2006)
   70839             : void
   70840           5 : SgOmpUsesAllocatorsClause::resetValidFreepointers( )
   70841             :    {
   70842           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   70843           5 :      SgOmpUsesAllocatorsClause* pointer = NULL;
   70844           5 :      std::vector < unsigned char* > :: const_iterator block;
   70845           5 :      SgOmpUsesAllocatorsClause* pointerOfLinkedList = NULL;
   70846           5 :      for ( block = SgOmpUsesAllocatorsClause::pools.begin(); block != SgOmpUsesAllocatorsClause::pools.end() ; ++block )
   70847             :         {
   70848           0 :           pointer = (SgOmpUsesAllocatorsClause*)(*block);
   70849           0 :           for (unsigned i = 0; i < SgOmpUsesAllocatorsClause::pool_size; ++i )
   70850             :              {
   70851             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   70852             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   70853             :             // memory blocks!.
   70854           0 :                if ( pointer[i].get_freepointer() != NULL )
   70855             :                   {
   70856           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   70857             :                   }
   70858             :                else
   70859             :                   {
   70860           0 :                     if ( pointerOfLinkedList == NULL )
   70861             :                        {
   70862           0 :                          SgOmpUsesAllocatorsClause::next_node = &(pointer[i]);
   70863             :                        }
   70864             :                     else
   70865             :                        {
   70866             :                       // printf ("In SgOmpUsesAllocatorsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   70867           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   70868             :                        }
   70869             :                     pointerOfLinkedList = &(pointer[i]);
   70870             :                   }
   70871             :               }
   70872             :         }
   70873             : 
   70874           5 :      if ( pointerOfLinkedList != NULL )
   70875             :         {
   70876             :        // printf ("In SgOmpUsesAllocatorsClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   70877           0 :           pointerOfLinkedList->set_freepointer(NULL);
   70878             :        // DQ (6/6/2010): Temporary debugging...
   70879             :        //   ROSE_ASSERT(false);
   70880             :         }
   70881             : 
   70882           5 :      return ;
   70883             :    }
   70884             : 
   70885             : //############################################################################
   70886             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   70887             :  * within the memory pool and resets the freepointers, in order to achieve a 
   70888             :  * linked list, that has no jumps and starts at the beginning! This function 
   70889             :  * does not extend the memory pool, since we do not delete any memory blocks,
   70890             :  * but delete the valid objects.  
   70891             :  */
   70892             : void
   70893           0 : SgOmpUsesAllocatorsClause::clearMemoryPool( )
   70894             :    {
   70895             :   // printf ("Inside of SgOmpUsesAllocatorsClause::clearMemoryPool() \n");
   70896             : 
   70897           0 :      SgOmpUsesAllocatorsClause* pointer = NULL, *tempPointer = NULL;
   70898           0 :      std::vector < unsigned char* > :: const_iterator block;
   70899           0 :      if ( SgOmpUsesAllocatorsClause::pools.empty() == false )
   70900             :         {
   70901           0 :           block = SgOmpUsesAllocatorsClause::pools.begin() ;
   70902           0 :           SgOmpUsesAllocatorsClause::next_node = (SgOmpUsesAllocatorsClause*) (*block);
   70903             : 
   70904           0 :           while ( block != SgOmpUsesAllocatorsClause::pools.end() )
   70905             :              {
   70906           0 :                pointer = (SgOmpUsesAllocatorsClause*) (*block);
   70907           0 :                if ( tempPointer != NULL )
   70908             :                   {
   70909           0 :                     tempPointer->set_freepointer(pointer);
   70910             :                   }
   70911           0 :                for (unsigned i = 0; i < SgOmpUsesAllocatorsClause::pool_size - 1; ++i)
   70912             :                   {
   70913           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   70914             :                   }
   70915           0 :                 pointer[SgOmpUsesAllocatorsClause::pool_size-1].set_freepointer(NULL);
   70916           0 :                 tempPointer = &(pointer[SgOmpUsesAllocatorsClause::pool_size-1]);
   70917           0 :                 ++block;
   70918             :              }
   70919             :         }
   70920           0 :    }
   70921             : 
   70922           5 : void SgOmpUsesAllocatorsClause::deleteMemoryPool() {
   70923           5 :   for (auto p: SgOmpUsesAllocatorsClause::pools) {
   70924           0 :     ROSE_FREE(p);
   70925             :   }
   70926           5 :   SgOmpUsesAllocatorsClause::next_node = nullptr;
   70927           5 :   SgOmpUsesAllocatorsClause::pools.clear();
   70928           5 : }
   70929             : 
   70930             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   70931             : //                 reading multiple binary files to for a single AST.
   70932             : /////////// new version ////////////////////////////////
   70933             : //############################################################################
   70934             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   70935             : void
   70936           2 : SgOmpUsesAllocatorsClause::extendMemoryPoolForFileIO( )
   70937             :   {
   70938           2 :     size_t blockIndex = SgOmpUsesAllocatorsClause::pools.size();
   70939           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUsesAllocatorsClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUsesAllocatorsClause);
   70940             : 
   70941           2 :     while ( (blockIndex * SgOmpUsesAllocatorsClause::pool_size) < newPoolSize)
   70942             :       {
   70943             : #if ROSE_ALLOC_TRACE
   70944             :         if (blockIndex > 0) {
   70945             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUsesAllocatorsClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUsesAllocatorsClause) = %" PRIuPTR " SgOmpUsesAllocatorsClause::pool_size = %d \n",
   70946             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUsesAllocatorsClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUsesAllocatorsClause),SgOmpUsesAllocatorsClause::pool_size);
   70947             :         }
   70948             : #endif
   70949             : 
   70950           0 :         SgOmpUsesAllocatorsClause * pointer = (SgOmpUsesAllocatorsClause*) ROSE_MALLOC ( SgOmpUsesAllocatorsClause::pool_size * sizeof(SgOmpUsesAllocatorsClause) );
   70951           0 :         assert( pointer != NULL );
   70952             : #if ROSE_ALLOC_MEMSET == 1
   70953             :         memset(pointer, 0x00, SgOmpUsesAllocatorsClause::pool_size * sizeof(SgOmpUsesAllocatorsClause));
   70954             : #elif ROSE_ALLOC_MEMSET == 2
   70955             :         memset(pointer, 0xCC, SgOmpUsesAllocatorsClause::pool_size * sizeof(SgOmpUsesAllocatorsClause));
   70956             : #endif
   70957           0 :         SgOmpUsesAllocatorsClause::pools.push_back( (unsigned char*)(pointer) );
   70958           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUsesAllocatorsClause::pool_size * sizeof(SgOmpUsesAllocatorsClause), V_SgOmpUsesAllocatorsClause ) );
   70959             : 
   70960           0 :         if ( SgOmpUsesAllocatorsClause::next_node != NULL ) {
   70961           0 :           if ( blockIndex > 0 ) {
   70962           0 :             SgOmpUsesAllocatorsClause * blkptr = (SgOmpUsesAllocatorsClause*)(SgOmpUsesAllocatorsClause::pools[blockIndex-1]);
   70963           0 :             blkptr[ SgOmpUsesAllocatorsClause::pool_size - 1 ].set_freepointer(pointer);
   70964             :           }
   70965             :         } else {
   70966           0 :           SgOmpUsesAllocatorsClause::next_node = pointer;
   70967             :         }
   70968             : 
   70969           0 :         for (unsigned i = 0; i < SgOmpUsesAllocatorsClause::pool_size-1; ++i)
   70970             :            {
   70971           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   70972             :            }
   70973           0 :         pointer[ SgOmpUsesAllocatorsClause::pool_size -1 ].set_freepointer(NULL);
   70974             : 
   70975           0 :         blockIndex++;
   70976             :       }
   70977           2 :   }
   70978             : 
   70979             : //############################################################################
   70980             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   70981             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   70982             :  * not compressed. However, that stuff is not yet implemented! 
   70983             :  */
   70984             : unsigned long
   70985           0 : SgOmpUsesAllocatorsClause::getNumberOfLastValidPointer()
   70986             :    {
   70987           0 :       SgOmpUsesAllocatorsClause* testPointer = (SgOmpUsesAllocatorsClause*)(SgOmpUsesAllocatorsClause::pools.back());
   70988           0 :       unsigned long localIndex = SgOmpUsesAllocatorsClause::pool_size - 1;
   70989           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   70990             :          {
   70991           0 :            localIndex--;
   70992             :          }
   70993           0 :       return (localIndex + SgOmpUsesAllocatorsClause::pool_size * (SgOmpUsesAllocatorsClause::pools.size()-1));
   70994             :    }
   70995             : 
   70996             : //############################################################################
   70997             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   70998             :  * memory pool and initializes the data member in class SgOmpUsesAllocatorsClauseStroageClass
   70999             :  * from its counterpart of SgOmpUsesAllocatorsClause. The return value is just for checking, 
   71000             :  * that the whole StorageClassArray is initialized!
   71001             :  */
   71002             : unsigned long
   71003           0 : SgOmpUsesAllocatorsClause::initializeStorageClassArray( SgOmpUsesAllocatorsClauseStorageClass *storageArray )
   71004             :    {
   71005           0 :      unsigned long storageCounter = 0;
   71006           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUsesAllocatorsClause::pools.begin();
   71007           0 :      SgOmpUsesAllocatorsClause* pointer = NULL;
   71008           0 :      while ( block != SgOmpUsesAllocatorsClause::pools.end() ) {
   71009           0 :           pointer = (SgOmpUsesAllocatorsClause*) (*block);
   71010           0 :           for ( unsigned i = 0; i < SgOmpUsesAllocatorsClause::pool_size; ++i ) {
   71011           0 :                if ( pointer->get_freepointer() != NULL ) {
   71012           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   71013           0 :                  storageArray++;
   71014           0 :                  storageCounter++;
   71015             :                }
   71016           0 :                pointer++;
   71017             :              }
   71018           0 :            block++;
   71019             :         }
   71020           0 :      return storageCounter;
   71021             :    }
   71022             : 
   71023             : /* #line 71024 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   71024             : 
   71025             : 
   71026             : 
   71027             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   71028             : 
   71029             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   71030             : 
   71031             : //############################################################################
   71032             : /* JH (02/02/2006) Constructor of the IR node SgOmpFullClause that takes its 
   71033             :  * corresponding StorageClass as parameter
   71034             :  */
   71035           0 : SgOmpFullClause :: SgOmpFullClause ( const SgOmpFullClauseStorageClass& storageSource )   : SgOmpClause (storageSource)
   71036             :    {
   71037             : 
   71038             : 
   71039             : /* #line 71040 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   71040             : 
   71041           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   71042             : 
   71043             : 
   71044             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   71045             : 
   71046             : 
   71047           0 :    }
   71048             : 
   71049             : //############################################################################
   71050             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   71051             :  * within the working AST. 
   71052             :  */
   71053           0 : SgOmpFullClause * SgOmpFullClause::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   71054           0 :      SgOmpFullClause* returnPointer = NULL;
   71055           0 :      if ( globalIndex != 0 )
   71056             :         {
   71057             : 
   71058             : #if FILE_IO_EXTRA_CHECK
   71059           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpFullClause ) ) <= globalIndex ) ;
   71060           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFullClause + 1 ) ) );
   71061             : #endif
   71062           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFullClause )  
   71063           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpFullClause );
   71064           0 :           unsigned long positionInPool = localIndex % SgOmpFullClause::pool_size;
   71065           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFullClause::pool_size;
   71066             : 
   71067             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   71068             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   71069             : 
   71070           0 :           returnPointer = &( ( (SgOmpFullClause*)(SgOmpFullClause::pools[memoryBlock]) ) [positionInPool]) ;
   71071             : 
   71072           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   71073             :         }
   71074           0 :      return returnPointer ;
   71075             :    }
   71076             : 
   71077             : //############################################################################
   71078             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   71079             :   for the AST with the index astIndex
   71080             : */
   71081           0 : SgOmpFullClause * SgOmpFullClause::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   71082           0 :      SgOmpFullClause* returnPointer = NULL;
   71083           0 :      if ( globalIndex != 0 )
   71084             :         {
   71085             : 
   71086             : #if FILE_IO_EXTRA_CHECK
   71087           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpFullClause ) ) <= globalIndex ) ;
   71088           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFullClause + 1 ) ) );
   71089             : #endif
   71090           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFullClause )
   71091           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpFullClause );
   71092           0 :           unsigned long positionInPool = localIndex % SgOmpFullClause::pool_size ;
   71093           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFullClause::pool_size ;
   71094             : 
   71095             : #if FILE_IO_EXTRA_CHECK
   71096             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   71097             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   71098             : #endif
   71099             : 
   71100           0 :           returnPointer = &( ( (SgOmpFullClause*)(SgOmpFullClause::pools[memoryBlock]) ) [positionInPool]) ;
   71101             : 
   71102             : #if FILE_IO_EXTRA_CHECK
   71103           0 :           assert ( returnPointer != NULL ) ;
   71104             : #endif
   71105             :         }
   71106           0 :      return returnPointer ;
   71107             :    }
   71108             : 
   71109             : //############################################################################
   71110             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   71111             :  * pool size! We set for every valid object in the memory pool the freepointer
   71112             :  * to the global index and increase the global index afterwards. For all the 
   71113             :  * invalid objects (means address ranges within the memory pool that were not
   71114             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   71115             :  * distinguish valid from invalid objects! 
   71116             :  */
   71117             : unsigned long
   71118           5 : SgOmpFullClause::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   71119             :    {
   71120           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   71121           5 :      SgOmpFullClause* pointer = NULL;
   71122           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   71123           5 :      std::vector < unsigned char* > :: const_iterator block;
   71124           5 :      for ( block = SgOmpFullClause::pools.begin(); block != SgOmpFullClause::pools.end() ; ++block )
   71125             :         {
   71126           0 :           pointer = (SgOmpFullClause*)(*block);
   71127           0 :           for (unsigned i = 0; i < SgOmpFullClause::pool_size; ++i )
   71128             :              {
   71129             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   71130             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   71131             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   71132             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   71133             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   71134             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   71135             :             // properly; so this will have to be checked next.
   71136             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   71137             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   71138           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   71139             :                   {
   71140           0 :                     pointer[i].set_freepointer((SgOmpFullClause*)(globalIndex));
   71141           0 :                     globalIndex++;
   71142             :                   }
   71143             :                else
   71144             :                   {
   71145           0 :                     pointer[i].set_freepointer(NULL);
   71146             :                   }
   71147             :               }
   71148             :         }
   71149           5 :      return globalIndex;
   71150             :    }
   71151             : 
   71152             : //############################################################################
   71153             : // JH (01/14/2006)
   71154             : void
   71155           5 : SgOmpFullClause::resetValidFreepointers( )
   71156             :    {
   71157           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   71158           5 :      SgOmpFullClause* pointer = NULL;
   71159           5 :      std::vector < unsigned char* > :: const_iterator block;
   71160           5 :      SgOmpFullClause* pointerOfLinkedList = NULL;
   71161           5 :      for ( block = SgOmpFullClause::pools.begin(); block != SgOmpFullClause::pools.end() ; ++block )
   71162             :         {
   71163           0 :           pointer = (SgOmpFullClause*)(*block);
   71164           0 :           for (unsigned i = 0; i < SgOmpFullClause::pool_size; ++i )
   71165             :              {
   71166             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   71167             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   71168             :             // memory blocks!.
   71169           0 :                if ( pointer[i].get_freepointer() != NULL )
   71170             :                   {
   71171           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   71172             :                   }
   71173             :                else
   71174             :                   {
   71175           0 :                     if ( pointerOfLinkedList == NULL )
   71176             :                        {
   71177           0 :                          SgOmpFullClause::next_node = &(pointer[i]);
   71178             :                        }
   71179             :                     else
   71180             :                        {
   71181             :                       // printf ("In SgOmpFullClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   71182           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   71183             :                        }
   71184             :                     pointerOfLinkedList = &(pointer[i]);
   71185             :                   }
   71186             :               }
   71187             :         }
   71188             : 
   71189           5 :      if ( pointerOfLinkedList != NULL )
   71190             :         {
   71191             :        // printf ("In SgOmpFullClause::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   71192           0 :           pointerOfLinkedList->set_freepointer(NULL);
   71193             :        // DQ (6/6/2010): Temporary debugging...
   71194             :        //   ROSE_ASSERT(false);
   71195             :         }
   71196             : 
   71197           5 :      return ;
   71198             :    }
   71199             : 
   71200             : //############################################################################
   71201             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   71202             :  * within the memory pool and resets the freepointers, in order to achieve a 
   71203             :  * linked list, that has no jumps and starts at the beginning! This function 
   71204             :  * does not extend the memory pool, since we do not delete any memory blocks,
   71205             :  * but delete the valid objects.  
   71206             :  */
   71207             : void
   71208           0 : SgOmpFullClause::clearMemoryPool( )
   71209             :    {
   71210             :   // printf ("Inside of SgOmpFullClause::clearMemoryPool() \n");
   71211             : 
   71212           0 :      SgOmpFullClause* pointer = NULL, *tempPointer = NULL;
   71213           0 :      std::vector < unsigned char* > :: const_iterator block;
   71214           0 :      if ( SgOmpFullClause::pools.empty() == false )
   71215             :         {
   71216           0 :           block = SgOmpFullClause::pools.begin() ;
   71217           0 :           SgOmpFullClause::next_node = (SgOmpFullClause*) (*block);
   71218             : 
   71219           0 :           while ( block != SgOmpFullClause::pools.end() )
   71220             :              {
   71221           0 :                pointer = (SgOmpFullClause*) (*block);
   71222           0 :                if ( tempPointer != NULL )
   71223             :                   {
   71224           0 :                     tempPointer->set_freepointer(pointer);
   71225             :                   }
   71226           0 :                for (unsigned i = 0; i < SgOmpFullClause::pool_size - 1; ++i)
   71227             :                   {
   71228           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   71229             :                   }
   71230           0 :                 pointer[SgOmpFullClause::pool_size-1].set_freepointer(NULL);
   71231           0 :                 tempPointer = &(pointer[SgOmpFullClause::pool_size-1]);
   71232           0 :                 ++block;
   71233             :              }
   71234             :         }
   71235           0 :    }
   71236             : 
   71237           5 : void SgOmpFullClause::deleteMemoryPool() {
   71238           5 :   for (auto p: SgOmpFullClause::pools) {
   71239           0 :     ROSE_FREE(p);
   71240             :   }
   71241           5 :   SgOmpFullClause::next_node = nullptr;
   71242           5 :   SgOmpFullClause::pools.clear();
   71243           5 : }
   71244             : 
   71245             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   71246             : //                 reading multiple binary files to for a single AST.
   71247             : /////////// new version ////////////////////////////////
   71248             : //############################################################################
   71249             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   71250             : void
   71251           2 : SgOmpFullClause::extendMemoryPoolForFileIO( )
   71252             :   {
   71253           2 :     size_t blockIndex = SgOmpFullClause::pools.size();
   71254           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFullClause) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFullClause);
   71255             : 
   71256           2 :     while ( (blockIndex * SgOmpFullClause::pool_size) < newPoolSize)
   71257             :       {
   71258             : #if ROSE_ALLOC_TRACE
   71259             :         if (blockIndex > 0) {
   71260             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFullClause) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFullClause) = %" PRIuPTR " SgOmpFullClause::pool_size = %d \n",
   71261             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFullClause),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFullClause),SgOmpFullClause::pool_size);
   71262             :         }
   71263             : #endif
   71264             : 
   71265           0 :         SgOmpFullClause * pointer = (SgOmpFullClause*) ROSE_MALLOC ( SgOmpFullClause::pool_size * sizeof(SgOmpFullClause) );
   71266           0 :         assert( pointer != NULL );
   71267             : #if ROSE_ALLOC_MEMSET == 1
   71268             :         memset(pointer, 0x00, SgOmpFullClause::pool_size * sizeof(SgOmpFullClause));
   71269             : #elif ROSE_ALLOC_MEMSET == 2
   71270             :         memset(pointer, 0xCC, SgOmpFullClause::pool_size * sizeof(SgOmpFullClause));
   71271             : #endif
   71272           0 :         SgOmpFullClause::pools.push_back( (unsigned char*)(pointer) );
   71273           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpFullClause::pool_size * sizeof(SgOmpFullClause), V_SgOmpFullClause ) );
   71274             : 
   71275           0 :         if ( SgOmpFullClause::next_node != NULL ) {
   71276           0 :           if ( blockIndex > 0 ) {
   71277           0 :             SgOmpFullClause * blkptr = (SgOmpFullClause*)(SgOmpFullClause::pools[blockIndex-1]);
   71278           0 :             blkptr[ SgOmpFullClause::pool_size - 1 ].set_freepointer(pointer);
   71279             :           }
   71280             :         } else {
   71281           0 :           SgOmpFullClause::next_node = pointer;
   71282             :         }
   71283             : 
   71284           0 :         for (unsigned i = 0; i < SgOmpFullClause::pool_size-1; ++i)
   71285             :            {
   71286           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   71287             :            }
   71288           0 :         pointer[ SgOmpFullClause::pool_size -1 ].set_freepointer(NULL);
   71289             : 
   71290           0 :         blockIndex++;
   71291             :       }
   71292           2 :   }
   71293             : 
   71294             : //############################################################################
   71295             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   71296             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   71297             :  * not compressed. However, that stuff is not yet implemented! 
   71298             :  */
   71299             : unsigned long
   71300           0 : SgOmpFullClause::getNumberOfLastValidPointer()
   71301             :    {
   71302           0 :       SgOmpFullClause* testPointer = (SgOmpFullClause*)(SgOmpFullClause::pools.back());
   71303           0 :       unsigned long localIndex = SgOmpFullClause::pool_size - 1;
   71304           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   71305             :          {
   71306           0 :            localIndex--;
   71307             :          }
   71308           0 :       return (localIndex + SgOmpFullClause::pool_size * (SgOmpFullClause::pools.size()-1));
   71309             :    }
   71310             : 
   71311             : //############################################################################
   71312             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   71313             :  * memory pool and initializes the data member in class SgOmpFullClauseStroageClass
   71314             :  * from its counterpart of SgOmpFullClause. The return value is just for checking, 
   71315             :  * that the whole StorageClassArray is initialized!
   71316             :  */
   71317             : unsigned long
   71318           0 : SgOmpFullClause::initializeStorageClassArray( SgOmpFullClauseStorageClass *storageArray )
   71319             :    {
   71320           0 :      unsigned long storageCounter = 0;
   71321           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpFullClause::pools.begin();
   71322           0 :      SgOmpFullClause* pointer = NULL;
   71323           0 :      while ( block != SgOmpFullClause::pools.end() ) {
   71324           0 :           pointer = (SgOmpFullClause*) (*block);
   71325           0 :           for ( unsigned i = 0; i < SgOmpFullClause::pool_size; ++i ) {
   71326           0 :                if ( pointer->get_freepointer() != NULL ) {
   71327           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   71328           0 :                  storageArray++;
   71329           0 :                  storageCounter++;
   71330             :                }
   71331           0 :                pointer++;
   71332             :              }
   71333           0 :            block++;
   71334             :         }
   71335           0 :      return storageCounter;
   71336             :    }
   71337             : 
   71338             : /* #line 71339 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   71339             : 
   71340             : 
   71341             : 
   71342             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   71343             : 
   71344             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   71345             : 
   71346             : //############################################################################
   71347             : /* JH (02/02/2006) Constructor of the IR node SgUpirBranchField that takes its 
   71348             :  * corresponding StorageClass as parameter
   71349             :  */
   71350           0 : SgUpirBranchField :: SgUpirBranchField ( const SgUpirBranchFieldStorageClass& storageSource )   : SgOmpClause (storageSource)
   71351             :    {
   71352             : 
   71353             : 
   71354             : /* #line 71355 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   71355             : 
   71356           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   71357           0 :      p_branches = storageSource.storageOf_branches.rebuildDataStoredInEasyStorageClass() ;
   71358             : 
   71359             : 
   71360             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   71361             : 
   71362             : 
   71363           0 :    }
   71364             : 
   71365             : //############################################################################
   71366             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   71367             :  * within the working AST. 
   71368             :  */
   71369           0 : SgUpirBranchField * SgUpirBranchField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   71370           0 :      SgUpirBranchField* returnPointer = NULL;
   71371           0 :      if ( globalIndex != 0 )
   71372             :         {
   71373             : 
   71374             : #if FILE_IO_EXTRA_CHECK
   71375           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirBranchField ) ) <= globalIndex ) ;
   71376           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirBranchField + 1 ) ) );
   71377             : #endif
   71378           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirBranchField )  
   71379           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirBranchField );
   71380           0 :           unsigned long positionInPool = localIndex % SgUpirBranchField::pool_size;
   71381           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirBranchField::pool_size;
   71382             : 
   71383             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   71384             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   71385             : 
   71386           0 :           returnPointer = &( ( (SgUpirBranchField*)(SgUpirBranchField::pools[memoryBlock]) ) [positionInPool]) ;
   71387             : 
   71388           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   71389             :         }
   71390           0 :      return returnPointer ;
   71391             :    }
   71392             : 
   71393             : //############################################################################
   71394             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   71395             :   for the AST with the index astIndex
   71396             : */
   71397           0 : SgUpirBranchField * SgUpirBranchField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   71398           0 :      SgUpirBranchField* returnPointer = NULL;
   71399           0 :      if ( globalIndex != 0 )
   71400             :         {
   71401             : 
   71402             : #if FILE_IO_EXTRA_CHECK
   71403           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirBranchField ) ) <= globalIndex ) ;
   71404           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirBranchField + 1 ) ) );
   71405             : #endif
   71406           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirBranchField )
   71407           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirBranchField );
   71408           0 :           unsigned long positionInPool = localIndex % SgUpirBranchField::pool_size ;
   71409           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirBranchField::pool_size ;
   71410             : 
   71411             : #if FILE_IO_EXTRA_CHECK
   71412             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   71413             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   71414             : #endif
   71415             : 
   71416           0 :           returnPointer = &( ( (SgUpirBranchField*)(SgUpirBranchField::pools[memoryBlock]) ) [positionInPool]) ;
   71417             : 
   71418             : #if FILE_IO_EXTRA_CHECK
   71419           0 :           assert ( returnPointer != NULL ) ;
   71420             : #endif
   71421             :         }
   71422           0 :      return returnPointer ;
   71423             :    }
   71424             : 
   71425             : //############################################################################
   71426             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   71427             :  * pool size! We set for every valid object in the memory pool the freepointer
   71428             :  * to the global index and increase the global index afterwards. For all the 
   71429             :  * invalid objects (means address ranges within the memory pool that were not
   71430             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   71431             :  * distinguish valid from invalid objects! 
   71432             :  */
   71433             : unsigned long
   71434           5 : SgUpirBranchField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   71435             :    {
   71436           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   71437           5 :      SgUpirBranchField* pointer = NULL;
   71438           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   71439           5 :      std::vector < unsigned char* > :: const_iterator block;
   71440           5 :      for ( block = SgUpirBranchField::pools.begin(); block != SgUpirBranchField::pools.end() ; ++block )
   71441             :         {
   71442           0 :           pointer = (SgUpirBranchField*)(*block);
   71443           0 :           for (unsigned i = 0; i < SgUpirBranchField::pool_size; ++i )
   71444             :              {
   71445             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   71446             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   71447             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   71448             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   71449             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   71450             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   71451             :             // properly; so this will have to be checked next.
   71452             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   71453             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   71454           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   71455             :                   {
   71456           0 :                     pointer[i].set_freepointer((SgUpirBranchField*)(globalIndex));
   71457           0 :                     globalIndex++;
   71458             :                   }
   71459             :                else
   71460             :                   {
   71461           0 :                     pointer[i].set_freepointer(NULL);
   71462             :                   }
   71463             :               }
   71464             :         }
   71465           5 :      return globalIndex;
   71466             :    }
   71467             : 
   71468             : //############################################################################
   71469             : // JH (01/14/2006)
   71470             : void
   71471           5 : SgUpirBranchField::resetValidFreepointers( )
   71472             :    {
   71473           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   71474           5 :      SgUpirBranchField* pointer = NULL;
   71475           5 :      std::vector < unsigned char* > :: const_iterator block;
   71476           5 :      SgUpirBranchField* pointerOfLinkedList = NULL;
   71477           5 :      for ( block = SgUpirBranchField::pools.begin(); block != SgUpirBranchField::pools.end() ; ++block )
   71478             :         {
   71479           0 :           pointer = (SgUpirBranchField*)(*block);
   71480           0 :           for (unsigned i = 0; i < SgUpirBranchField::pool_size; ++i )
   71481             :              {
   71482             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   71483             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   71484             :             // memory blocks!.
   71485           0 :                if ( pointer[i].get_freepointer() != NULL )
   71486             :                   {
   71487           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   71488             :                   }
   71489             :                else
   71490             :                   {
   71491           0 :                     if ( pointerOfLinkedList == NULL )
   71492             :                        {
   71493           0 :                          SgUpirBranchField::next_node = &(pointer[i]);
   71494             :                        }
   71495             :                     else
   71496             :                        {
   71497             :                       // printf ("In SgUpirBranchField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   71498           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   71499             :                        }
   71500             :                     pointerOfLinkedList = &(pointer[i]);
   71501             :                   }
   71502             :               }
   71503             :         }
   71504             : 
   71505           5 :      if ( pointerOfLinkedList != NULL )
   71506             :         {
   71507             :        // printf ("In SgUpirBranchField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   71508           0 :           pointerOfLinkedList->set_freepointer(NULL);
   71509             :        // DQ (6/6/2010): Temporary debugging...
   71510             :        //   ROSE_ASSERT(false);
   71511             :         }
   71512             : 
   71513           5 :      return ;
   71514             :    }
   71515             : 
   71516             : //############################################################################
   71517             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   71518             :  * within the memory pool and resets the freepointers, in order to achieve a 
   71519             :  * linked list, that has no jumps and starts at the beginning! This function 
   71520             :  * does not extend the memory pool, since we do not delete any memory blocks,
   71521             :  * but delete the valid objects.  
   71522             :  */
   71523             : void
   71524           0 : SgUpirBranchField::clearMemoryPool( )
   71525             :    {
   71526             :   // printf ("Inside of SgUpirBranchField::clearMemoryPool() \n");
   71527             : 
   71528           0 :      SgUpirBranchField* pointer = NULL, *tempPointer = NULL;
   71529           0 :      std::vector < unsigned char* > :: const_iterator block;
   71530           0 :      if ( SgUpirBranchField::pools.empty() == false )
   71531             :         {
   71532           0 :           block = SgUpirBranchField::pools.begin() ;
   71533           0 :           SgUpirBranchField::next_node = (SgUpirBranchField*) (*block);
   71534             : 
   71535           0 :           while ( block != SgUpirBranchField::pools.end() )
   71536             :              {
   71537           0 :                pointer = (SgUpirBranchField*) (*block);
   71538           0 :                if ( tempPointer != NULL )
   71539             :                   {
   71540           0 :                     tempPointer->set_freepointer(pointer);
   71541             :                   }
   71542           0 :                for (unsigned i = 0; i < SgUpirBranchField::pool_size - 1; ++i)
   71543             :                   {
   71544           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   71545             :                   }
   71546           0 :                 pointer[SgUpirBranchField::pool_size-1].set_freepointer(NULL);
   71547           0 :                 tempPointer = &(pointer[SgUpirBranchField::pool_size-1]);
   71548           0 :                 ++block;
   71549             :              }
   71550             :         }
   71551           0 :    }
   71552             : 
   71553           5 : void SgUpirBranchField::deleteMemoryPool() {
   71554           5 :   for (auto p: SgUpirBranchField::pools) {
   71555           0 :     ROSE_FREE(p);
   71556             :   }
   71557           5 :   SgUpirBranchField::next_node = nullptr;
   71558           5 :   SgUpirBranchField::pools.clear();
   71559           5 : }
   71560             : 
   71561             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   71562             : //                 reading multiple binary files to for a single AST.
   71563             : /////////// new version ////////////////////////////////
   71564             : //############################################################################
   71565             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   71566             : void
   71567           2 : SgUpirBranchField::extendMemoryPoolForFileIO( )
   71568             :   {
   71569           2 :     size_t blockIndex = SgUpirBranchField::pools.size();
   71570           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBranchField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBranchField);
   71571             : 
   71572           2 :     while ( (blockIndex * SgUpirBranchField::pool_size) < newPoolSize)
   71573             :       {
   71574             : #if ROSE_ALLOC_TRACE
   71575             :         if (blockIndex > 0) {
   71576             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBranchField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBranchField) = %" PRIuPTR " SgUpirBranchField::pool_size = %d \n",
   71577             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBranchField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBranchField),SgUpirBranchField::pool_size);
   71578             :         }
   71579             : #endif
   71580             : 
   71581           0 :         SgUpirBranchField * pointer = (SgUpirBranchField*) ROSE_MALLOC ( SgUpirBranchField::pool_size * sizeof(SgUpirBranchField) );
   71582           0 :         assert( pointer != NULL );
   71583             : #if ROSE_ALLOC_MEMSET == 1
   71584             :         memset(pointer, 0x00, SgUpirBranchField::pool_size * sizeof(SgUpirBranchField));
   71585             : #elif ROSE_ALLOC_MEMSET == 2
   71586             :         memset(pointer, 0xCC, SgUpirBranchField::pool_size * sizeof(SgUpirBranchField));
   71587             : #endif
   71588           0 :         SgUpirBranchField::pools.push_back( (unsigned char*)(pointer) );
   71589           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirBranchField::pool_size * sizeof(SgUpirBranchField), V_SgUpirBranchField ) );
   71590             : 
   71591           0 :         if ( SgUpirBranchField::next_node != NULL ) {
   71592           0 :           if ( blockIndex > 0 ) {
   71593           0 :             SgUpirBranchField * blkptr = (SgUpirBranchField*)(SgUpirBranchField::pools[blockIndex-1]);
   71594           0 :             blkptr[ SgUpirBranchField::pool_size - 1 ].set_freepointer(pointer);
   71595             :           }
   71596             :         } else {
   71597           0 :           SgUpirBranchField::next_node = pointer;
   71598             :         }
   71599             : 
   71600           0 :         for (unsigned i = 0; i < SgUpirBranchField::pool_size-1; ++i)
   71601             :            {
   71602           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   71603             :            }
   71604           0 :         pointer[ SgUpirBranchField::pool_size -1 ].set_freepointer(NULL);
   71605             : 
   71606           0 :         blockIndex++;
   71607             :       }
   71608           2 :   }
   71609             : 
   71610             : //############################################################################
   71611             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   71612             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   71613             :  * not compressed. However, that stuff is not yet implemented! 
   71614             :  */
   71615             : unsigned long
   71616           0 : SgUpirBranchField::getNumberOfLastValidPointer()
   71617             :    {
   71618           0 :       SgUpirBranchField* testPointer = (SgUpirBranchField*)(SgUpirBranchField::pools.back());
   71619           0 :       unsigned long localIndex = SgUpirBranchField::pool_size - 1;
   71620           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   71621             :          {
   71622           0 :            localIndex--;
   71623             :          }
   71624           0 :       return (localIndex + SgUpirBranchField::pool_size * (SgUpirBranchField::pools.size()-1));
   71625             :    }
   71626             : 
   71627             : //############################################################################
   71628             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   71629             :  * memory pool and initializes the data member in class SgUpirBranchFieldStroageClass
   71630             :  * from its counterpart of SgUpirBranchField. The return value is just for checking, 
   71631             :  * that the whole StorageClassArray is initialized!
   71632             :  */
   71633             : unsigned long
   71634           0 : SgUpirBranchField::initializeStorageClassArray( SgUpirBranchFieldStorageClass *storageArray )
   71635             :    {
   71636           0 :      unsigned long storageCounter = 0;
   71637           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirBranchField::pools.begin();
   71638           0 :      SgUpirBranchField* pointer = NULL;
   71639           0 :      while ( block != SgUpirBranchField::pools.end() ) {
   71640           0 :           pointer = (SgUpirBranchField*) (*block);
   71641           0 :           for ( unsigned i = 0; i < SgUpirBranchField::pool_size; ++i ) {
   71642           0 :                if ( pointer->get_freepointer() != NULL ) {
   71643           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   71644           0 :                  storageArray++;
   71645           0 :                  storageCounter++;
   71646             :                }
   71647           0 :                pointer++;
   71648             :              }
   71649           0 :            block++;
   71650             :         }
   71651           0 :      return storageCounter;
   71652             :    }
   71653             : 
   71654             : /* #line 71655 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   71655             : 
   71656             : 
   71657             : 
   71658             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   71659             : 
   71660             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   71661             : 
   71662             : //############################################################################
   71663             : /* JH (02/02/2006) Constructor of the IR node SgUpirNestedLevelField that takes its 
   71664             :  * corresponding StorageClass as parameter
   71665             :  */
   71666           0 : SgUpirNestedLevelField :: SgUpirNestedLevelField ( const SgUpirNestedLevelFieldStorageClass& storageSource )   : SgOmpClause (storageSource)
   71667             :    {
   71668             : 
   71669             : 
   71670             : /* #line 71671 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   71671             : 
   71672           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   71673           0 :      p_nested_level = storageSource.storageOf_nested_level ;
   71674             : 
   71675             : 
   71676             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   71677             : 
   71678             : 
   71679           0 :    }
   71680             : 
   71681             : //############################################################################
   71682             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   71683             :  * within the working AST. 
   71684             :  */
   71685           0 : SgUpirNestedLevelField * SgUpirNestedLevelField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   71686           0 :      SgUpirNestedLevelField* returnPointer = NULL;
   71687           0 :      if ( globalIndex != 0 )
   71688             :         {
   71689             : 
   71690             : #if FILE_IO_EXTRA_CHECK
   71691           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirNestedLevelField ) ) <= globalIndex ) ;
   71692           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirNestedLevelField + 1 ) ) );
   71693             : #endif
   71694           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirNestedLevelField )  
   71695           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirNestedLevelField );
   71696           0 :           unsigned long positionInPool = localIndex % SgUpirNestedLevelField::pool_size;
   71697           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirNestedLevelField::pool_size;
   71698             : 
   71699             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   71700             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   71701             : 
   71702           0 :           returnPointer = &( ( (SgUpirNestedLevelField*)(SgUpirNestedLevelField::pools[memoryBlock]) ) [positionInPool]) ;
   71703             : 
   71704           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   71705             :         }
   71706           0 :      return returnPointer ;
   71707             :    }
   71708             : 
   71709             : //############################################################################
   71710             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   71711             :   for the AST with the index astIndex
   71712             : */
   71713           0 : SgUpirNestedLevelField * SgUpirNestedLevelField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   71714           0 :      SgUpirNestedLevelField* returnPointer = NULL;
   71715           0 :      if ( globalIndex != 0 )
   71716             :         {
   71717             : 
   71718             : #if FILE_IO_EXTRA_CHECK
   71719           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirNestedLevelField ) ) <= globalIndex ) ;
   71720           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirNestedLevelField + 1 ) ) );
   71721             : #endif
   71722           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirNestedLevelField )
   71723           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirNestedLevelField );
   71724           0 :           unsigned long positionInPool = localIndex % SgUpirNestedLevelField::pool_size ;
   71725           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirNestedLevelField::pool_size ;
   71726             : 
   71727             : #if FILE_IO_EXTRA_CHECK
   71728             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   71729             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   71730             : #endif
   71731             : 
   71732           0 :           returnPointer = &( ( (SgUpirNestedLevelField*)(SgUpirNestedLevelField::pools[memoryBlock]) ) [positionInPool]) ;
   71733             : 
   71734             : #if FILE_IO_EXTRA_CHECK
   71735           0 :           assert ( returnPointer != NULL ) ;
   71736             : #endif
   71737             :         }
   71738           0 :      return returnPointer ;
   71739             :    }
   71740             : 
   71741             : //############################################################################
   71742             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   71743             :  * pool size! We set for every valid object in the memory pool the freepointer
   71744             :  * to the global index and increase the global index afterwards. For all the 
   71745             :  * invalid objects (means address ranges within the memory pool that were not
   71746             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   71747             :  * distinguish valid from invalid objects! 
   71748             :  */
   71749             : unsigned long
   71750           5 : SgUpirNestedLevelField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   71751             :    {
   71752           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   71753           5 :      SgUpirNestedLevelField* pointer = NULL;
   71754           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   71755           5 :      std::vector < unsigned char* > :: const_iterator block;
   71756           5 :      for ( block = SgUpirNestedLevelField::pools.begin(); block != SgUpirNestedLevelField::pools.end() ; ++block )
   71757             :         {
   71758           0 :           pointer = (SgUpirNestedLevelField*)(*block);
   71759           0 :           for (unsigned i = 0; i < SgUpirNestedLevelField::pool_size; ++i )
   71760             :              {
   71761             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   71762             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   71763             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   71764             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   71765             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   71766             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   71767             :             // properly; so this will have to be checked next.
   71768             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   71769             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   71770           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   71771             :                   {
   71772           0 :                     pointer[i].set_freepointer((SgUpirNestedLevelField*)(globalIndex));
   71773           0 :                     globalIndex++;
   71774             :                   }
   71775             :                else
   71776             :                   {
   71777           0 :                     pointer[i].set_freepointer(NULL);
   71778             :                   }
   71779             :               }
   71780             :         }
   71781           5 :      return globalIndex;
   71782             :    }
   71783             : 
   71784             : //############################################################################
   71785             : // JH (01/14/2006)
   71786             : void
   71787           5 : SgUpirNestedLevelField::resetValidFreepointers( )
   71788             :    {
   71789           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   71790           5 :      SgUpirNestedLevelField* pointer = NULL;
   71791           5 :      std::vector < unsigned char* > :: const_iterator block;
   71792           5 :      SgUpirNestedLevelField* pointerOfLinkedList = NULL;
   71793           5 :      for ( block = SgUpirNestedLevelField::pools.begin(); block != SgUpirNestedLevelField::pools.end() ; ++block )
   71794             :         {
   71795           0 :           pointer = (SgUpirNestedLevelField*)(*block);
   71796           0 :           for (unsigned i = 0; i < SgUpirNestedLevelField::pool_size; ++i )
   71797             :              {
   71798             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   71799             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   71800             :             // memory blocks!.
   71801           0 :                if ( pointer[i].get_freepointer() != NULL )
   71802             :                   {
   71803           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   71804             :                   }
   71805             :                else
   71806             :                   {
   71807           0 :                     if ( pointerOfLinkedList == NULL )
   71808             :                        {
   71809           0 :                          SgUpirNestedLevelField::next_node = &(pointer[i]);
   71810             :                        }
   71811             :                     else
   71812             :                        {
   71813             :                       // printf ("In SgUpirNestedLevelField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   71814           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   71815             :                        }
   71816             :                     pointerOfLinkedList = &(pointer[i]);
   71817             :                   }
   71818             :               }
   71819             :         }
   71820             : 
   71821           5 :      if ( pointerOfLinkedList != NULL )
   71822             :         {
   71823             :        // printf ("In SgUpirNestedLevelField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   71824           0 :           pointerOfLinkedList->set_freepointer(NULL);
   71825             :        // DQ (6/6/2010): Temporary debugging...
   71826             :        //   ROSE_ASSERT(false);
   71827             :         }
   71828             : 
   71829           5 :      return ;
   71830             :    }
   71831             : 
   71832             : //############################################################################
   71833             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   71834             :  * within the memory pool and resets the freepointers, in order to achieve a 
   71835             :  * linked list, that has no jumps and starts at the beginning! This function 
   71836             :  * does not extend the memory pool, since we do not delete any memory blocks,
   71837             :  * but delete the valid objects.  
   71838             :  */
   71839             : void
   71840           0 : SgUpirNestedLevelField::clearMemoryPool( )
   71841             :    {
   71842             :   // printf ("Inside of SgUpirNestedLevelField::clearMemoryPool() \n");
   71843             : 
   71844           0 :      SgUpirNestedLevelField* pointer = NULL, *tempPointer = NULL;
   71845           0 :      std::vector < unsigned char* > :: const_iterator block;
   71846           0 :      if ( SgUpirNestedLevelField::pools.empty() == false )
   71847             :         {
   71848           0 :           block = SgUpirNestedLevelField::pools.begin() ;
   71849           0 :           SgUpirNestedLevelField::next_node = (SgUpirNestedLevelField*) (*block);
   71850             : 
   71851           0 :           while ( block != SgUpirNestedLevelField::pools.end() )
   71852             :              {
   71853           0 :                pointer = (SgUpirNestedLevelField*) (*block);
   71854           0 :                if ( tempPointer != NULL )
   71855             :                   {
   71856           0 :                     tempPointer->set_freepointer(pointer);
   71857             :                   }
   71858           0 :                for (unsigned i = 0; i < SgUpirNestedLevelField::pool_size - 1; ++i)
   71859             :                   {
   71860           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   71861             :                   }
   71862           0 :                 pointer[SgUpirNestedLevelField::pool_size-1].set_freepointer(NULL);
   71863           0 :                 tempPointer = &(pointer[SgUpirNestedLevelField::pool_size-1]);
   71864           0 :                 ++block;
   71865             :              }
   71866             :         }
   71867           0 :    }
   71868             : 
   71869           5 : void SgUpirNestedLevelField::deleteMemoryPool() {
   71870           5 :   for (auto p: SgUpirNestedLevelField::pools) {
   71871           0 :     ROSE_FREE(p);
   71872             :   }
   71873           5 :   SgUpirNestedLevelField::next_node = nullptr;
   71874           5 :   SgUpirNestedLevelField::pools.clear();
   71875           5 : }
   71876             : 
   71877             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   71878             : //                 reading multiple binary files to for a single AST.
   71879             : /////////// new version ////////////////////////////////
   71880             : //############################################################################
   71881             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   71882             : void
   71883           2 : SgUpirNestedLevelField::extendMemoryPoolForFileIO( )
   71884             :   {
   71885           2 :     size_t blockIndex = SgUpirNestedLevelField::pools.size();
   71886           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedLevelField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedLevelField);
   71887             : 
   71888           2 :     while ( (blockIndex * SgUpirNestedLevelField::pool_size) < newPoolSize)
   71889             :       {
   71890             : #if ROSE_ALLOC_TRACE
   71891             :         if (blockIndex > 0) {
   71892             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedLevelField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedLevelField) = %" PRIuPTR " SgUpirNestedLevelField::pool_size = %d \n",
   71893             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedLevelField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedLevelField),SgUpirNestedLevelField::pool_size);
   71894             :         }
   71895             : #endif
   71896             : 
   71897           0 :         SgUpirNestedLevelField * pointer = (SgUpirNestedLevelField*) ROSE_MALLOC ( SgUpirNestedLevelField::pool_size * sizeof(SgUpirNestedLevelField) );
   71898           0 :         assert( pointer != NULL );
   71899             : #if ROSE_ALLOC_MEMSET == 1
   71900             :         memset(pointer, 0x00, SgUpirNestedLevelField::pool_size * sizeof(SgUpirNestedLevelField));
   71901             : #elif ROSE_ALLOC_MEMSET == 2
   71902             :         memset(pointer, 0xCC, SgUpirNestedLevelField::pool_size * sizeof(SgUpirNestedLevelField));
   71903             : #endif
   71904           0 :         SgUpirNestedLevelField::pools.push_back( (unsigned char*)(pointer) );
   71905           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirNestedLevelField::pool_size * sizeof(SgUpirNestedLevelField), V_SgUpirNestedLevelField ) );
   71906             : 
   71907           0 :         if ( SgUpirNestedLevelField::next_node != NULL ) {
   71908           0 :           if ( blockIndex > 0 ) {
   71909           0 :             SgUpirNestedLevelField * blkptr = (SgUpirNestedLevelField*)(SgUpirNestedLevelField::pools[blockIndex-1]);
   71910           0 :             blkptr[ SgUpirNestedLevelField::pool_size - 1 ].set_freepointer(pointer);
   71911             :           }
   71912             :         } else {
   71913           0 :           SgUpirNestedLevelField::next_node = pointer;
   71914             :         }
   71915             : 
   71916           0 :         for (unsigned i = 0; i < SgUpirNestedLevelField::pool_size-1; ++i)
   71917             :            {
   71918           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   71919             :            }
   71920           0 :         pointer[ SgUpirNestedLevelField::pool_size -1 ].set_freepointer(NULL);
   71921             : 
   71922           0 :         blockIndex++;
   71923             :       }
   71924           2 :   }
   71925             : 
   71926             : //############################################################################
   71927             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   71928             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   71929             :  * not compressed. However, that stuff is not yet implemented! 
   71930             :  */
   71931             : unsigned long
   71932           0 : SgUpirNestedLevelField::getNumberOfLastValidPointer()
   71933             :    {
   71934           0 :       SgUpirNestedLevelField* testPointer = (SgUpirNestedLevelField*)(SgUpirNestedLevelField::pools.back());
   71935           0 :       unsigned long localIndex = SgUpirNestedLevelField::pool_size - 1;
   71936           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   71937             :          {
   71938           0 :            localIndex--;
   71939             :          }
   71940           0 :       return (localIndex + SgUpirNestedLevelField::pool_size * (SgUpirNestedLevelField::pools.size()-1));
   71941             :    }
   71942             : 
   71943             : //############################################################################
   71944             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   71945             :  * memory pool and initializes the data member in class SgUpirNestedLevelFieldStroageClass
   71946             :  * from its counterpart of SgUpirNestedLevelField. The return value is just for checking, 
   71947             :  * that the whole StorageClassArray is initialized!
   71948             :  */
   71949             : unsigned long
   71950           0 : SgUpirNestedLevelField::initializeStorageClassArray( SgUpirNestedLevelFieldStorageClass *storageArray )
   71951             :    {
   71952           0 :      unsigned long storageCounter = 0;
   71953           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirNestedLevelField::pools.begin();
   71954           0 :      SgUpirNestedLevelField* pointer = NULL;
   71955           0 :      while ( block != SgUpirNestedLevelField::pools.end() ) {
   71956           0 :           pointer = (SgUpirNestedLevelField*) (*block);
   71957           0 :           for ( unsigned i = 0; i < SgUpirNestedLevelField::pool_size; ++i ) {
   71958           0 :                if ( pointer->get_freepointer() != NULL ) {
   71959           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   71960           0 :                  storageArray++;
   71961           0 :                  storageCounter++;
   71962             :                }
   71963           0 :                pointer++;
   71964             :              }
   71965           0 :            block++;
   71966             :         }
   71967           0 :      return storageCounter;
   71968             :    }
   71969             : 
   71970             : /* #line 71971 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   71971             : 
   71972             : 
   71973             : 
   71974             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   71975             : 
   71976             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   71977             : 
   71978             : //############################################################################
   71979             : /* JH (02/02/2006) Constructor of the IR node SgUpirNestedParentField that takes its 
   71980             :  * corresponding StorageClass as parameter
   71981             :  */
   71982           0 : SgUpirNestedParentField :: SgUpirNestedParentField ( const SgUpirNestedParentFieldStorageClass& storageSource )   : SgOmpClause (storageSource)
   71983             :    {
   71984             : 
   71985             : 
   71986             : /* #line 71987 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   71987             : 
   71988           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   71989           0 :      p_nested_parent =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nested_parent) );
   71990             : 
   71991             : 
   71992             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   71993             : 
   71994             : 
   71995           0 :    }
   71996             : 
   71997             : //############################################################################
   71998             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   71999             :  * within the working AST. 
   72000             :  */
   72001           0 : SgUpirNestedParentField * SgUpirNestedParentField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   72002           0 :      SgUpirNestedParentField* returnPointer = NULL;
   72003           0 :      if ( globalIndex != 0 )
   72004             :         {
   72005             : 
   72006             : #if FILE_IO_EXTRA_CHECK
   72007           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirNestedParentField ) ) <= globalIndex ) ;
   72008           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirNestedParentField + 1 ) ) );
   72009             : #endif
   72010           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirNestedParentField )  
   72011           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirNestedParentField );
   72012           0 :           unsigned long positionInPool = localIndex % SgUpirNestedParentField::pool_size;
   72013           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirNestedParentField::pool_size;
   72014             : 
   72015             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   72016             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   72017             : 
   72018           0 :           returnPointer = &( ( (SgUpirNestedParentField*)(SgUpirNestedParentField::pools[memoryBlock]) ) [positionInPool]) ;
   72019             : 
   72020           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   72021             :         }
   72022           0 :      return returnPointer ;
   72023             :    }
   72024             : 
   72025             : //############################################################################
   72026             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   72027             :   for the AST with the index astIndex
   72028             : */
   72029           0 : SgUpirNestedParentField * SgUpirNestedParentField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   72030           0 :      SgUpirNestedParentField* returnPointer = NULL;
   72031           0 :      if ( globalIndex != 0 )
   72032             :         {
   72033             : 
   72034             : #if FILE_IO_EXTRA_CHECK
   72035           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirNestedParentField ) ) <= globalIndex ) ;
   72036           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirNestedParentField + 1 ) ) );
   72037             : #endif
   72038           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirNestedParentField )
   72039           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirNestedParentField );
   72040           0 :           unsigned long positionInPool = localIndex % SgUpirNestedParentField::pool_size ;
   72041           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirNestedParentField::pool_size ;
   72042             : 
   72043             : #if FILE_IO_EXTRA_CHECK
   72044             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   72045             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   72046             : #endif
   72047             : 
   72048           0 :           returnPointer = &( ( (SgUpirNestedParentField*)(SgUpirNestedParentField::pools[memoryBlock]) ) [positionInPool]) ;
   72049             : 
   72050             : #if FILE_IO_EXTRA_CHECK
   72051           0 :           assert ( returnPointer != NULL ) ;
   72052             : #endif
   72053             :         }
   72054           0 :      return returnPointer ;
   72055             :    }
   72056             : 
   72057             : //############################################################################
   72058             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   72059             :  * pool size! We set for every valid object in the memory pool the freepointer
   72060             :  * to the global index and increase the global index afterwards. For all the 
   72061             :  * invalid objects (means address ranges within the memory pool that were not
   72062             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   72063             :  * distinguish valid from invalid objects! 
   72064             :  */
   72065             : unsigned long
   72066           5 : SgUpirNestedParentField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   72067             :    {
   72068           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   72069           5 :      SgUpirNestedParentField* pointer = NULL;
   72070           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   72071           5 :      std::vector < unsigned char* > :: const_iterator block;
   72072           5 :      for ( block = SgUpirNestedParentField::pools.begin(); block != SgUpirNestedParentField::pools.end() ; ++block )
   72073             :         {
   72074           0 :           pointer = (SgUpirNestedParentField*)(*block);
   72075           0 :           for (unsigned i = 0; i < SgUpirNestedParentField::pool_size; ++i )
   72076             :              {
   72077             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   72078             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   72079             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   72080             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   72081             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   72082             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   72083             :             // properly; so this will have to be checked next.
   72084             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   72085             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   72086           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   72087             :                   {
   72088           0 :                     pointer[i].set_freepointer((SgUpirNestedParentField*)(globalIndex));
   72089           0 :                     globalIndex++;
   72090             :                   }
   72091             :                else
   72092             :                   {
   72093           0 :                     pointer[i].set_freepointer(NULL);
   72094             :                   }
   72095             :               }
   72096             :         }
   72097           5 :      return globalIndex;
   72098             :    }
   72099             : 
   72100             : //############################################################################
   72101             : // JH (01/14/2006)
   72102             : void
   72103           5 : SgUpirNestedParentField::resetValidFreepointers( )
   72104             :    {
   72105           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   72106           5 :      SgUpirNestedParentField* pointer = NULL;
   72107           5 :      std::vector < unsigned char* > :: const_iterator block;
   72108           5 :      SgUpirNestedParentField* pointerOfLinkedList = NULL;
   72109           5 :      for ( block = SgUpirNestedParentField::pools.begin(); block != SgUpirNestedParentField::pools.end() ; ++block )
   72110             :         {
   72111           0 :           pointer = (SgUpirNestedParentField*)(*block);
   72112           0 :           for (unsigned i = 0; i < SgUpirNestedParentField::pool_size; ++i )
   72113             :              {
   72114             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   72115             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   72116             :             // memory blocks!.
   72117           0 :                if ( pointer[i].get_freepointer() != NULL )
   72118             :                   {
   72119           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   72120             :                   }
   72121             :                else
   72122             :                   {
   72123           0 :                     if ( pointerOfLinkedList == NULL )
   72124             :                        {
   72125           0 :                          SgUpirNestedParentField::next_node = &(pointer[i]);
   72126             :                        }
   72127             :                     else
   72128             :                        {
   72129             :                       // printf ("In SgUpirNestedParentField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   72130           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   72131             :                        }
   72132             :                     pointerOfLinkedList = &(pointer[i]);
   72133             :                   }
   72134             :               }
   72135             :         }
   72136             : 
   72137           5 :      if ( pointerOfLinkedList != NULL )
   72138             :         {
   72139             :        // printf ("In SgUpirNestedParentField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   72140           0 :           pointerOfLinkedList->set_freepointer(NULL);
   72141             :        // DQ (6/6/2010): Temporary debugging...
   72142             :        //   ROSE_ASSERT(false);
   72143             :         }
   72144             : 
   72145           5 :      return ;
   72146             :    }
   72147             : 
   72148             : //############################################################################
   72149             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   72150             :  * within the memory pool and resets the freepointers, in order to achieve a 
   72151             :  * linked list, that has no jumps and starts at the beginning! This function 
   72152             :  * does not extend the memory pool, since we do not delete any memory blocks,
   72153             :  * but delete the valid objects.  
   72154             :  */
   72155             : void
   72156           0 : SgUpirNestedParentField::clearMemoryPool( )
   72157             :    {
   72158             :   // printf ("Inside of SgUpirNestedParentField::clearMemoryPool() \n");
   72159             : 
   72160           0 :      SgUpirNestedParentField* pointer = NULL, *tempPointer = NULL;
   72161           0 :      std::vector < unsigned char* > :: const_iterator block;
   72162           0 :      if ( SgUpirNestedParentField::pools.empty() == false )
   72163             :         {
   72164           0 :           block = SgUpirNestedParentField::pools.begin() ;
   72165           0 :           SgUpirNestedParentField::next_node = (SgUpirNestedParentField*) (*block);
   72166             : 
   72167           0 :           while ( block != SgUpirNestedParentField::pools.end() )
   72168             :              {
   72169           0 :                pointer = (SgUpirNestedParentField*) (*block);
   72170           0 :                if ( tempPointer != NULL )
   72171             :                   {
   72172           0 :                     tempPointer->set_freepointer(pointer);
   72173             :                   }
   72174           0 :                for (unsigned i = 0; i < SgUpirNestedParentField::pool_size - 1; ++i)
   72175             :                   {
   72176           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   72177             :                   }
   72178           0 :                 pointer[SgUpirNestedParentField::pool_size-1].set_freepointer(NULL);
   72179           0 :                 tempPointer = &(pointer[SgUpirNestedParentField::pool_size-1]);
   72180           0 :                 ++block;
   72181             :              }
   72182             :         }
   72183           0 :    }
   72184             : 
   72185           5 : void SgUpirNestedParentField::deleteMemoryPool() {
   72186           5 :   for (auto p: SgUpirNestedParentField::pools) {
   72187           0 :     ROSE_FREE(p);
   72188             :   }
   72189           5 :   SgUpirNestedParentField::next_node = nullptr;
   72190           5 :   SgUpirNestedParentField::pools.clear();
   72191           5 : }
   72192             : 
   72193             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   72194             : //                 reading multiple binary files to for a single AST.
   72195             : /////////// new version ////////////////////////////////
   72196             : //############################################################################
   72197             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   72198             : void
   72199           2 : SgUpirNestedParentField::extendMemoryPoolForFileIO( )
   72200             :   {
   72201           2 :     size_t blockIndex = SgUpirNestedParentField::pools.size();
   72202           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedParentField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedParentField);
   72203             : 
   72204           2 :     while ( (blockIndex * SgUpirNestedParentField::pool_size) < newPoolSize)
   72205             :       {
   72206             : #if ROSE_ALLOC_TRACE
   72207             :         if (blockIndex > 0) {
   72208             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedParentField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedParentField) = %" PRIuPTR " SgUpirNestedParentField::pool_size = %d \n",
   72209             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedParentField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedParentField),SgUpirNestedParentField::pool_size);
   72210             :         }
   72211             : #endif
   72212             : 
   72213           0 :         SgUpirNestedParentField * pointer = (SgUpirNestedParentField*) ROSE_MALLOC ( SgUpirNestedParentField::pool_size * sizeof(SgUpirNestedParentField) );
   72214           0 :         assert( pointer != NULL );
   72215             : #if ROSE_ALLOC_MEMSET == 1
   72216             :         memset(pointer, 0x00, SgUpirNestedParentField::pool_size * sizeof(SgUpirNestedParentField));
   72217             : #elif ROSE_ALLOC_MEMSET == 2
   72218             :         memset(pointer, 0xCC, SgUpirNestedParentField::pool_size * sizeof(SgUpirNestedParentField));
   72219             : #endif
   72220           0 :         SgUpirNestedParentField::pools.push_back( (unsigned char*)(pointer) );
   72221           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirNestedParentField::pool_size * sizeof(SgUpirNestedParentField), V_SgUpirNestedParentField ) );
   72222             : 
   72223           0 :         if ( SgUpirNestedParentField::next_node != NULL ) {
   72224           0 :           if ( blockIndex > 0 ) {
   72225           0 :             SgUpirNestedParentField * blkptr = (SgUpirNestedParentField*)(SgUpirNestedParentField::pools[blockIndex-1]);
   72226           0 :             blkptr[ SgUpirNestedParentField::pool_size - 1 ].set_freepointer(pointer);
   72227             :           }
   72228             :         } else {
   72229           0 :           SgUpirNestedParentField::next_node = pointer;
   72230             :         }
   72231             : 
   72232           0 :         for (unsigned i = 0; i < SgUpirNestedParentField::pool_size-1; ++i)
   72233             :            {
   72234           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   72235             :            }
   72236           0 :         pointer[ SgUpirNestedParentField::pool_size -1 ].set_freepointer(NULL);
   72237             : 
   72238           0 :         blockIndex++;
   72239             :       }
   72240           2 :   }
   72241             : 
   72242             : //############################################################################
   72243             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   72244             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   72245             :  * not compressed. However, that stuff is not yet implemented! 
   72246             :  */
   72247             : unsigned long
   72248           0 : SgUpirNestedParentField::getNumberOfLastValidPointer()
   72249             :    {
   72250           0 :       SgUpirNestedParentField* testPointer = (SgUpirNestedParentField*)(SgUpirNestedParentField::pools.back());
   72251           0 :       unsigned long localIndex = SgUpirNestedParentField::pool_size - 1;
   72252           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   72253             :          {
   72254           0 :            localIndex--;
   72255             :          }
   72256           0 :       return (localIndex + SgUpirNestedParentField::pool_size * (SgUpirNestedParentField::pools.size()-1));
   72257             :    }
   72258             : 
   72259             : //############################################################################
   72260             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   72261             :  * memory pool and initializes the data member in class SgUpirNestedParentFieldStroageClass
   72262             :  * from its counterpart of SgUpirNestedParentField. The return value is just for checking, 
   72263             :  * that the whole StorageClassArray is initialized!
   72264             :  */
   72265             : unsigned long
   72266           0 : SgUpirNestedParentField::initializeStorageClassArray( SgUpirNestedParentFieldStorageClass *storageArray )
   72267             :    {
   72268           0 :      unsigned long storageCounter = 0;
   72269           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirNestedParentField::pools.begin();
   72270           0 :      SgUpirNestedParentField* pointer = NULL;
   72271           0 :      while ( block != SgUpirNestedParentField::pools.end() ) {
   72272           0 :           pointer = (SgUpirNestedParentField*) (*block);
   72273           0 :           for ( unsigned i = 0; i < SgUpirNestedParentField::pool_size; ++i ) {
   72274           0 :                if ( pointer->get_freepointer() != NULL ) {
   72275           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   72276           0 :                  storageArray++;
   72277           0 :                  storageCounter++;
   72278             :                }
   72279           0 :                pointer++;
   72280             :              }
   72281           0 :            block++;
   72282             :         }
   72283           0 :      return storageCounter;
   72284             :    }
   72285             : 
   72286             : /* #line 72287 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   72287             : 
   72288             : 
   72289             : 
   72290             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   72291             : 
   72292             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   72293             : 
   72294             : //############################################################################
   72295             : /* JH (02/02/2006) Constructor of the IR node SgUpirNestedChildField that takes its 
   72296             :  * corresponding StorageClass as parameter
   72297             :  */
   72298           0 : SgUpirNestedChildField :: SgUpirNestedChildField ( const SgUpirNestedChildFieldStorageClass& storageSource )   : SgOmpClause (storageSource)
   72299             :    {
   72300             : 
   72301             : 
   72302             : /* #line 72303 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   72303             : 
   72304           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   72305           0 :      p_nested_child =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nested_child) );
   72306             : 
   72307             : 
   72308             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   72309             : 
   72310             : 
   72311           0 :    }
   72312             : 
   72313             : //############################################################################
   72314             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   72315             :  * within the working AST. 
   72316             :  */
   72317           0 : SgUpirNestedChildField * SgUpirNestedChildField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   72318           0 :      SgUpirNestedChildField* returnPointer = NULL;
   72319           0 :      if ( globalIndex != 0 )
   72320             :         {
   72321             : 
   72322             : #if FILE_IO_EXTRA_CHECK
   72323           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirNestedChildField ) ) <= globalIndex ) ;
   72324           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirNestedChildField + 1 ) ) );
   72325             : #endif
   72326           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirNestedChildField )  
   72327           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirNestedChildField );
   72328           0 :           unsigned long positionInPool = localIndex % SgUpirNestedChildField::pool_size;
   72329           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirNestedChildField::pool_size;
   72330             : 
   72331             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   72332             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   72333             : 
   72334           0 :           returnPointer = &( ( (SgUpirNestedChildField*)(SgUpirNestedChildField::pools[memoryBlock]) ) [positionInPool]) ;
   72335             : 
   72336           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   72337             :         }
   72338           0 :      return returnPointer ;
   72339             :    }
   72340             : 
   72341             : //############################################################################
   72342             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   72343             :   for the AST with the index astIndex
   72344             : */
   72345           0 : SgUpirNestedChildField * SgUpirNestedChildField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   72346           0 :      SgUpirNestedChildField* returnPointer = NULL;
   72347           0 :      if ( globalIndex != 0 )
   72348             :         {
   72349             : 
   72350             : #if FILE_IO_EXTRA_CHECK
   72351           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirNestedChildField ) ) <= globalIndex ) ;
   72352           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirNestedChildField + 1 ) ) );
   72353             : #endif
   72354           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirNestedChildField )
   72355           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirNestedChildField );
   72356           0 :           unsigned long positionInPool = localIndex % SgUpirNestedChildField::pool_size ;
   72357           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirNestedChildField::pool_size ;
   72358             : 
   72359             : #if FILE_IO_EXTRA_CHECK
   72360             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   72361             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   72362             : #endif
   72363             : 
   72364           0 :           returnPointer = &( ( (SgUpirNestedChildField*)(SgUpirNestedChildField::pools[memoryBlock]) ) [positionInPool]) ;
   72365             : 
   72366             : #if FILE_IO_EXTRA_CHECK
   72367           0 :           assert ( returnPointer != NULL ) ;
   72368             : #endif
   72369             :         }
   72370           0 :      return returnPointer ;
   72371             :    }
   72372             : 
   72373             : //############################################################################
   72374             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   72375             :  * pool size! We set for every valid object in the memory pool the freepointer
   72376             :  * to the global index and increase the global index afterwards. For all the 
   72377             :  * invalid objects (means address ranges within the memory pool that were not
   72378             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   72379             :  * distinguish valid from invalid objects! 
   72380             :  */
   72381             : unsigned long
   72382           5 : SgUpirNestedChildField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   72383             :    {
   72384           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   72385           5 :      SgUpirNestedChildField* pointer = NULL;
   72386           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   72387           5 :      std::vector < unsigned char* > :: const_iterator block;
   72388           5 :      for ( block = SgUpirNestedChildField::pools.begin(); block != SgUpirNestedChildField::pools.end() ; ++block )
   72389             :         {
   72390           0 :           pointer = (SgUpirNestedChildField*)(*block);
   72391           0 :           for (unsigned i = 0; i < SgUpirNestedChildField::pool_size; ++i )
   72392             :              {
   72393             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   72394             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   72395             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   72396             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   72397             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   72398             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   72399             :             // properly; so this will have to be checked next.
   72400             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   72401             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   72402           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   72403             :                   {
   72404           0 :                     pointer[i].set_freepointer((SgUpirNestedChildField*)(globalIndex));
   72405           0 :                     globalIndex++;
   72406             :                   }
   72407             :                else
   72408             :                   {
   72409           0 :                     pointer[i].set_freepointer(NULL);
   72410             :                   }
   72411             :               }
   72412             :         }
   72413           5 :      return globalIndex;
   72414             :    }
   72415             : 
   72416             : //############################################################################
   72417             : // JH (01/14/2006)
   72418             : void
   72419           5 : SgUpirNestedChildField::resetValidFreepointers( )
   72420             :    {
   72421           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   72422           5 :      SgUpirNestedChildField* pointer = NULL;
   72423           5 :      std::vector < unsigned char* > :: const_iterator block;
   72424           5 :      SgUpirNestedChildField* pointerOfLinkedList = NULL;
   72425           5 :      for ( block = SgUpirNestedChildField::pools.begin(); block != SgUpirNestedChildField::pools.end() ; ++block )
   72426             :         {
   72427           0 :           pointer = (SgUpirNestedChildField*)(*block);
   72428           0 :           for (unsigned i = 0; i < SgUpirNestedChildField::pool_size; ++i )
   72429             :              {
   72430             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   72431             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   72432             :             // memory blocks!.
   72433           0 :                if ( pointer[i].get_freepointer() != NULL )
   72434             :                   {
   72435           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   72436             :                   }
   72437             :                else
   72438             :                   {
   72439           0 :                     if ( pointerOfLinkedList == NULL )
   72440             :                        {
   72441           0 :                          SgUpirNestedChildField::next_node = &(pointer[i]);
   72442             :                        }
   72443             :                     else
   72444             :                        {
   72445             :                       // printf ("In SgUpirNestedChildField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   72446           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   72447             :                        }
   72448             :                     pointerOfLinkedList = &(pointer[i]);
   72449             :                   }
   72450             :               }
   72451             :         }
   72452             : 
   72453           5 :      if ( pointerOfLinkedList != NULL )
   72454             :         {
   72455             :        // printf ("In SgUpirNestedChildField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   72456           0 :           pointerOfLinkedList->set_freepointer(NULL);
   72457             :        // DQ (6/6/2010): Temporary debugging...
   72458             :        //   ROSE_ASSERT(false);
   72459             :         }
   72460             : 
   72461           5 :      return ;
   72462             :    }
   72463             : 
   72464             : //############################################################################
   72465             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   72466             :  * within the memory pool and resets the freepointers, in order to achieve a 
   72467             :  * linked list, that has no jumps and starts at the beginning! This function 
   72468             :  * does not extend the memory pool, since we do not delete any memory blocks,
   72469             :  * but delete the valid objects.  
   72470             :  */
   72471             : void
   72472           0 : SgUpirNestedChildField::clearMemoryPool( )
   72473             :    {
   72474             :   // printf ("Inside of SgUpirNestedChildField::clearMemoryPool() \n");
   72475             : 
   72476           0 :      SgUpirNestedChildField* pointer = NULL, *tempPointer = NULL;
   72477           0 :      std::vector < unsigned char* > :: const_iterator block;
   72478           0 :      if ( SgUpirNestedChildField::pools.empty() == false )
   72479             :         {
   72480           0 :           block = SgUpirNestedChildField::pools.begin() ;
   72481           0 :           SgUpirNestedChildField::next_node = (SgUpirNestedChildField*) (*block);
   72482             : 
   72483           0 :           while ( block != SgUpirNestedChildField::pools.end() )
   72484             :              {
   72485           0 :                pointer = (SgUpirNestedChildField*) (*block);
   72486           0 :                if ( tempPointer != NULL )
   72487             :                   {
   72488           0 :                     tempPointer->set_freepointer(pointer);
   72489             :                   }
   72490           0 :                for (unsigned i = 0; i < SgUpirNestedChildField::pool_size - 1; ++i)
   72491             :                   {
   72492           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   72493             :                   }
   72494           0 :                 pointer[SgUpirNestedChildField::pool_size-1].set_freepointer(NULL);
   72495           0 :                 tempPointer = &(pointer[SgUpirNestedChildField::pool_size-1]);
   72496           0 :                 ++block;
   72497             :              }
   72498             :         }
   72499           0 :    }
   72500             : 
   72501           5 : void SgUpirNestedChildField::deleteMemoryPool() {
   72502           5 :   for (auto p: SgUpirNestedChildField::pools) {
   72503           0 :     ROSE_FREE(p);
   72504             :   }
   72505           5 :   SgUpirNestedChildField::next_node = nullptr;
   72506           5 :   SgUpirNestedChildField::pools.clear();
   72507           5 : }
   72508             : 
   72509             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   72510             : //                 reading multiple binary files to for a single AST.
   72511             : /////////// new version ////////////////////////////////
   72512             : //############################################################################
   72513             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   72514             : void
   72515           2 : SgUpirNestedChildField::extendMemoryPoolForFileIO( )
   72516             :   {
   72517           2 :     size_t blockIndex = SgUpirNestedChildField::pools.size();
   72518           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedChildField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedChildField);
   72519             : 
   72520           2 :     while ( (blockIndex * SgUpirNestedChildField::pool_size) < newPoolSize)
   72521             :       {
   72522             : #if ROSE_ALLOC_TRACE
   72523             :         if (blockIndex > 0) {
   72524             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedChildField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedChildField) = %" PRIuPTR " SgUpirNestedChildField::pool_size = %d \n",
   72525             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirNestedChildField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirNestedChildField),SgUpirNestedChildField::pool_size);
   72526             :         }
   72527             : #endif
   72528             : 
   72529           0 :         SgUpirNestedChildField * pointer = (SgUpirNestedChildField*) ROSE_MALLOC ( SgUpirNestedChildField::pool_size * sizeof(SgUpirNestedChildField) );
   72530           0 :         assert( pointer != NULL );
   72531             : #if ROSE_ALLOC_MEMSET == 1
   72532             :         memset(pointer, 0x00, SgUpirNestedChildField::pool_size * sizeof(SgUpirNestedChildField));
   72533             : #elif ROSE_ALLOC_MEMSET == 2
   72534             :         memset(pointer, 0xCC, SgUpirNestedChildField::pool_size * sizeof(SgUpirNestedChildField));
   72535             : #endif
   72536           0 :         SgUpirNestedChildField::pools.push_back( (unsigned char*)(pointer) );
   72537           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirNestedChildField::pool_size * sizeof(SgUpirNestedChildField), V_SgUpirNestedChildField ) );
   72538             : 
   72539           0 :         if ( SgUpirNestedChildField::next_node != NULL ) {
   72540           0 :           if ( blockIndex > 0 ) {
   72541           0 :             SgUpirNestedChildField * blkptr = (SgUpirNestedChildField*)(SgUpirNestedChildField::pools[blockIndex-1]);
   72542           0 :             blkptr[ SgUpirNestedChildField::pool_size - 1 ].set_freepointer(pointer);
   72543             :           }
   72544             :         } else {
   72545           0 :           SgUpirNestedChildField::next_node = pointer;
   72546             :         }
   72547             : 
   72548           0 :         for (unsigned i = 0; i < SgUpirNestedChildField::pool_size-1; ++i)
   72549             :            {
   72550           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   72551             :            }
   72552           0 :         pointer[ SgUpirNestedChildField::pool_size -1 ].set_freepointer(NULL);
   72553             : 
   72554           0 :         blockIndex++;
   72555             :       }
   72556           2 :   }
   72557             : 
   72558             : //############################################################################
   72559             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   72560             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   72561             :  * not compressed. However, that stuff is not yet implemented! 
   72562             :  */
   72563             : unsigned long
   72564           0 : SgUpirNestedChildField::getNumberOfLastValidPointer()
   72565             :    {
   72566           0 :       SgUpirNestedChildField* testPointer = (SgUpirNestedChildField*)(SgUpirNestedChildField::pools.back());
   72567           0 :       unsigned long localIndex = SgUpirNestedChildField::pool_size - 1;
   72568           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   72569             :          {
   72570           0 :            localIndex--;
   72571             :          }
   72572           0 :       return (localIndex + SgUpirNestedChildField::pool_size * (SgUpirNestedChildField::pools.size()-1));
   72573             :    }
   72574             : 
   72575             : //############################################################################
   72576             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   72577             :  * memory pool and initializes the data member in class SgUpirNestedChildFieldStroageClass
   72578             :  * from its counterpart of SgUpirNestedChildField. The return value is just for checking, 
   72579             :  * that the whole StorageClassArray is initialized!
   72580             :  */
   72581             : unsigned long
   72582           0 : SgUpirNestedChildField::initializeStorageClassArray( SgUpirNestedChildFieldStorageClass *storageArray )
   72583             :    {
   72584           0 :      unsigned long storageCounter = 0;
   72585           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirNestedChildField::pools.begin();
   72586           0 :      SgUpirNestedChildField* pointer = NULL;
   72587           0 :      while ( block != SgUpirNestedChildField::pools.end() ) {
   72588           0 :           pointer = (SgUpirNestedChildField*) (*block);
   72589           0 :           for ( unsigned i = 0; i < SgUpirNestedChildField::pool_size; ++i ) {
   72590           0 :                if ( pointer->get_freepointer() != NULL ) {
   72591           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   72592           0 :                  storageArray++;
   72593           0 :                  storageCounter++;
   72594             :                }
   72595           0 :                pointer++;
   72596             :              }
   72597           0 :            block++;
   72598             :         }
   72599           0 :      return storageCounter;
   72600             :    }
   72601             : 
   72602             : /* #line 72603 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   72603             : 
   72604             : 
   72605             : 
   72606             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   72607             : 
   72608             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   72609             : 
   72610             : //############################################################################
   72611             : /* JH (02/02/2006) Constructor of the IR node SgUpirSyncField that takes its 
   72612             :  * corresponding StorageClass as parameter
   72613             :  */
   72614           0 : SgUpirSyncField :: SgUpirSyncField ( const SgUpirSyncFieldStorageClass& storageSource )   : SgOmpClause (storageSource)
   72615             :    {
   72616             : 
   72617             : 
   72618             : /* #line 72619 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   72619             : 
   72620           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   72621           0 :      p_sync =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_sync) );
   72622             : 
   72623             : 
   72624             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   72625             : 
   72626             : 
   72627           0 :    }
   72628             : 
   72629             : //############################################################################
   72630             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   72631             :  * within the working AST. 
   72632             :  */
   72633           0 : SgUpirSyncField * SgUpirSyncField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   72634           0 :      SgUpirSyncField* returnPointer = NULL;
   72635           0 :      if ( globalIndex != 0 )
   72636             :         {
   72637             : 
   72638             : #if FILE_IO_EXTRA_CHECK
   72639           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirSyncField ) ) <= globalIndex ) ;
   72640           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirSyncField + 1 ) ) );
   72641             : #endif
   72642           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirSyncField )  
   72643           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirSyncField );
   72644           0 :           unsigned long positionInPool = localIndex % SgUpirSyncField::pool_size;
   72645           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirSyncField::pool_size;
   72646             : 
   72647             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   72648             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   72649             : 
   72650           0 :           returnPointer = &( ( (SgUpirSyncField*)(SgUpirSyncField::pools[memoryBlock]) ) [positionInPool]) ;
   72651             : 
   72652           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   72653             :         }
   72654           0 :      return returnPointer ;
   72655             :    }
   72656             : 
   72657             : //############################################################################
   72658             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   72659             :   for the AST with the index astIndex
   72660             : */
   72661           0 : SgUpirSyncField * SgUpirSyncField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   72662           0 :      SgUpirSyncField* returnPointer = NULL;
   72663           0 :      if ( globalIndex != 0 )
   72664             :         {
   72665             : 
   72666             : #if FILE_IO_EXTRA_CHECK
   72667           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirSyncField ) ) <= globalIndex ) ;
   72668           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirSyncField + 1 ) ) );
   72669             : #endif
   72670           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirSyncField )
   72671           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirSyncField );
   72672           0 :           unsigned long positionInPool = localIndex % SgUpirSyncField::pool_size ;
   72673           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirSyncField::pool_size ;
   72674             : 
   72675             : #if FILE_IO_EXTRA_CHECK
   72676             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   72677             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   72678             : #endif
   72679             : 
   72680           0 :           returnPointer = &( ( (SgUpirSyncField*)(SgUpirSyncField::pools[memoryBlock]) ) [positionInPool]) ;
   72681             : 
   72682             : #if FILE_IO_EXTRA_CHECK
   72683           0 :           assert ( returnPointer != NULL ) ;
   72684             : #endif
   72685             :         }
   72686           0 :      return returnPointer ;
   72687             :    }
   72688             : 
   72689             : //############################################################################
   72690             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   72691             :  * pool size! We set for every valid object in the memory pool the freepointer
   72692             :  * to the global index and increase the global index afterwards. For all the 
   72693             :  * invalid objects (means address ranges within the memory pool that were not
   72694             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   72695             :  * distinguish valid from invalid objects! 
   72696             :  */
   72697             : unsigned long
   72698           5 : SgUpirSyncField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   72699             :    {
   72700           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   72701           5 :      SgUpirSyncField* pointer = NULL;
   72702           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   72703           5 :      std::vector < unsigned char* > :: const_iterator block;
   72704           5 :      for ( block = SgUpirSyncField::pools.begin(); block != SgUpirSyncField::pools.end() ; ++block )
   72705             :         {
   72706           0 :           pointer = (SgUpirSyncField*)(*block);
   72707           0 :           for (unsigned i = 0; i < SgUpirSyncField::pool_size; ++i )
   72708             :              {
   72709             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   72710             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   72711             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   72712             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   72713             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   72714             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   72715             :             // properly; so this will have to be checked next.
   72716             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   72717             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   72718           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   72719             :                   {
   72720           0 :                     pointer[i].set_freepointer((SgUpirSyncField*)(globalIndex));
   72721           0 :                     globalIndex++;
   72722             :                   }
   72723             :                else
   72724             :                   {
   72725           0 :                     pointer[i].set_freepointer(NULL);
   72726             :                   }
   72727             :               }
   72728             :         }
   72729           5 :      return globalIndex;
   72730             :    }
   72731             : 
   72732             : //############################################################################
   72733             : // JH (01/14/2006)
   72734             : void
   72735           5 : SgUpirSyncField::resetValidFreepointers( )
   72736             :    {
   72737           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   72738           5 :      SgUpirSyncField* pointer = NULL;
   72739           5 :      std::vector < unsigned char* > :: const_iterator block;
   72740           5 :      SgUpirSyncField* pointerOfLinkedList = NULL;
   72741           5 :      for ( block = SgUpirSyncField::pools.begin(); block != SgUpirSyncField::pools.end() ; ++block )
   72742             :         {
   72743           0 :           pointer = (SgUpirSyncField*)(*block);
   72744           0 :           for (unsigned i = 0; i < SgUpirSyncField::pool_size; ++i )
   72745             :              {
   72746             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   72747             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   72748             :             // memory blocks!.
   72749           0 :                if ( pointer[i].get_freepointer() != NULL )
   72750             :                   {
   72751           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   72752             :                   }
   72753             :                else
   72754             :                   {
   72755           0 :                     if ( pointerOfLinkedList == NULL )
   72756             :                        {
   72757           0 :                          SgUpirSyncField::next_node = &(pointer[i]);
   72758             :                        }
   72759             :                     else
   72760             :                        {
   72761             :                       // printf ("In SgUpirSyncField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   72762           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   72763             :                        }
   72764             :                     pointerOfLinkedList = &(pointer[i]);
   72765             :                   }
   72766             :               }
   72767             :         }
   72768             : 
   72769           5 :      if ( pointerOfLinkedList != NULL )
   72770             :         {
   72771             :        // printf ("In SgUpirSyncField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   72772           0 :           pointerOfLinkedList->set_freepointer(NULL);
   72773             :        // DQ (6/6/2010): Temporary debugging...
   72774             :        //   ROSE_ASSERT(false);
   72775             :         }
   72776             : 
   72777           5 :      return ;
   72778             :    }
   72779             : 
   72780             : //############################################################################
   72781             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   72782             :  * within the memory pool and resets the freepointers, in order to achieve a 
   72783             :  * linked list, that has no jumps and starts at the beginning! This function 
   72784             :  * does not extend the memory pool, since we do not delete any memory blocks,
   72785             :  * but delete the valid objects.  
   72786             :  */
   72787             : void
   72788           0 : SgUpirSyncField::clearMemoryPool( )
   72789             :    {
   72790             :   // printf ("Inside of SgUpirSyncField::clearMemoryPool() \n");
   72791             : 
   72792           0 :      SgUpirSyncField* pointer = NULL, *tempPointer = NULL;
   72793           0 :      std::vector < unsigned char* > :: const_iterator block;
   72794           0 :      if ( SgUpirSyncField::pools.empty() == false )
   72795             :         {
   72796           0 :           block = SgUpirSyncField::pools.begin() ;
   72797           0 :           SgUpirSyncField::next_node = (SgUpirSyncField*) (*block);
   72798             : 
   72799           0 :           while ( block != SgUpirSyncField::pools.end() )
   72800             :              {
   72801           0 :                pointer = (SgUpirSyncField*) (*block);
   72802           0 :                if ( tempPointer != NULL )
   72803             :                   {
   72804           0 :                     tempPointer->set_freepointer(pointer);
   72805             :                   }
   72806           0 :                for (unsigned i = 0; i < SgUpirSyncField::pool_size - 1; ++i)
   72807             :                   {
   72808           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   72809             :                   }
   72810           0 :                 pointer[SgUpirSyncField::pool_size-1].set_freepointer(NULL);
   72811           0 :                 tempPointer = &(pointer[SgUpirSyncField::pool_size-1]);
   72812           0 :                 ++block;
   72813             :              }
   72814             :         }
   72815           0 :    }
   72816             : 
   72817           5 : void SgUpirSyncField::deleteMemoryPool() {
   72818           5 :   for (auto p: SgUpirSyncField::pools) {
   72819           0 :     ROSE_FREE(p);
   72820             :   }
   72821           5 :   SgUpirSyncField::next_node = nullptr;
   72822           5 :   SgUpirSyncField::pools.clear();
   72823           5 : }
   72824             : 
   72825             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   72826             : //                 reading multiple binary files to for a single AST.
   72827             : /////////// new version ////////////////////////////////
   72828             : //############################################################################
   72829             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   72830             : void
   72831           2 : SgUpirSyncField::extendMemoryPoolForFileIO( )
   72832             :   {
   72833           2 :     size_t blockIndex = SgUpirSyncField::pools.size();
   72834           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSyncField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSyncField);
   72835             : 
   72836           2 :     while ( (blockIndex * SgUpirSyncField::pool_size) < newPoolSize)
   72837             :       {
   72838             : #if ROSE_ALLOC_TRACE
   72839             :         if (blockIndex > 0) {
   72840             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSyncField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSyncField) = %" PRIuPTR " SgUpirSyncField::pool_size = %d \n",
   72841             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSyncField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSyncField),SgUpirSyncField::pool_size);
   72842             :         }
   72843             : #endif
   72844             : 
   72845           0 :         SgUpirSyncField * pointer = (SgUpirSyncField*) ROSE_MALLOC ( SgUpirSyncField::pool_size * sizeof(SgUpirSyncField) );
   72846           0 :         assert( pointer != NULL );
   72847             : #if ROSE_ALLOC_MEMSET == 1
   72848             :         memset(pointer, 0x00, SgUpirSyncField::pool_size * sizeof(SgUpirSyncField));
   72849             : #elif ROSE_ALLOC_MEMSET == 2
   72850             :         memset(pointer, 0xCC, SgUpirSyncField::pool_size * sizeof(SgUpirSyncField));
   72851             : #endif
   72852           0 :         SgUpirSyncField::pools.push_back( (unsigned char*)(pointer) );
   72853           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirSyncField::pool_size * sizeof(SgUpirSyncField), V_SgUpirSyncField ) );
   72854             : 
   72855           0 :         if ( SgUpirSyncField::next_node != NULL ) {
   72856           0 :           if ( blockIndex > 0 ) {
   72857           0 :             SgUpirSyncField * blkptr = (SgUpirSyncField*)(SgUpirSyncField::pools[blockIndex-1]);
   72858           0 :             blkptr[ SgUpirSyncField::pool_size - 1 ].set_freepointer(pointer);
   72859             :           }
   72860             :         } else {
   72861           0 :           SgUpirSyncField::next_node = pointer;
   72862             :         }
   72863             : 
   72864           0 :         for (unsigned i = 0; i < SgUpirSyncField::pool_size-1; ++i)
   72865             :            {
   72866           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   72867             :            }
   72868           0 :         pointer[ SgUpirSyncField::pool_size -1 ].set_freepointer(NULL);
   72869             : 
   72870           0 :         blockIndex++;
   72871             :       }
   72872           2 :   }
   72873             : 
   72874             : //############################################################################
   72875             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   72876             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   72877             :  * not compressed. However, that stuff is not yet implemented! 
   72878             :  */
   72879             : unsigned long
   72880           0 : SgUpirSyncField::getNumberOfLastValidPointer()
   72881             :    {
   72882           0 :       SgUpirSyncField* testPointer = (SgUpirSyncField*)(SgUpirSyncField::pools.back());
   72883           0 :       unsigned long localIndex = SgUpirSyncField::pool_size - 1;
   72884           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   72885             :          {
   72886           0 :            localIndex--;
   72887             :          }
   72888           0 :       return (localIndex + SgUpirSyncField::pool_size * (SgUpirSyncField::pools.size()-1));
   72889             :    }
   72890             : 
   72891             : //############################################################################
   72892             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   72893             :  * memory pool and initializes the data member in class SgUpirSyncFieldStroageClass
   72894             :  * from its counterpart of SgUpirSyncField. The return value is just for checking, 
   72895             :  * that the whole StorageClassArray is initialized!
   72896             :  */
   72897             : unsigned long
   72898           0 : SgUpirSyncField::initializeStorageClassArray( SgUpirSyncFieldStorageClass *storageArray )
   72899             :    {
   72900           0 :      unsigned long storageCounter = 0;
   72901           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirSyncField::pools.begin();
   72902           0 :      SgUpirSyncField* pointer = NULL;
   72903           0 :      while ( block != SgUpirSyncField::pools.end() ) {
   72904           0 :           pointer = (SgUpirSyncField*) (*block);
   72905           0 :           for ( unsigned i = 0; i < SgUpirSyncField::pool_size; ++i ) {
   72906           0 :                if ( pointer->get_freepointer() != NULL ) {
   72907           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   72908           0 :                  storageArray++;
   72909           0 :                  storageCounter++;
   72910             :                }
   72911           0 :                pointer++;
   72912             :              }
   72913           0 :            block++;
   72914             :         }
   72915           0 :      return storageCounter;
   72916             :    }
   72917             : 
   72918             : /* #line 72919 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   72919             : 
   72920             : 
   72921             : 
   72922             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   72923             : 
   72924             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   72925             : 
   72926             : //############################################################################
   72927             : /* JH (02/02/2006) Constructor of the IR node SgUpirDataField that takes its 
   72928             :  * corresponding StorageClass as parameter
   72929             :  */
   72930           0 : SgUpirDataField :: SgUpirDataField ( const SgUpirDataFieldStorageClass& storageSource )   : SgOmpClause (storageSource)
   72931             :    {
   72932             : 
   72933             : 
   72934             : /* #line 72935 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   72935             : 
   72936           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   72937           0 :      p_data = storageSource.storageOf_data.rebuildDataStoredInEasyStorageClass() ;
   72938           0 :      p_shared_data = storageSource.storageOf_shared_data.rebuildDataStoredInEasyStorageClass() ;
   72939           0 :      p_private_data = storageSource.storageOf_private_data.rebuildDataStoredInEasyStorageClass() ;
   72940           0 :      p_firstprivate_data = storageSource.storageOf_firstprivate_data.rebuildDataStoredInEasyStorageClass() ;
   72941           0 :      p_lastprivate_data = storageSource.storageOf_lastprivate_data.rebuildDataStoredInEasyStorageClass() ;
   72942           0 :      p_reduction_data = storageSource.storageOf_reduction_data.rebuildDataStoredInEasyStorageClass() ;
   72943           0 :      p_map_to_data = storageSource.storageOf_map_to_data.rebuildDataStoredInEasyStorageClass() ;
   72944           0 :      p_map_from_data = storageSource.storageOf_map_from_data.rebuildDataStoredInEasyStorageClass() ;
   72945           0 :      p_map_tofrom_data = storageSource.storageOf_map_tofrom_data.rebuildDataStoredInEasyStorageClass() ;
   72946           0 :      p_map_alloc_data = storageSource.storageOf_map_alloc_data.rebuildDataStoredInEasyStorageClass() ;
   72947             : 
   72948             : 
   72949             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   72950             : 
   72951             : 
   72952           0 :    }
   72953             : 
   72954             : //############################################################################
   72955             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   72956             :  * within the working AST. 
   72957             :  */
   72958           0 : SgUpirDataField * SgUpirDataField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   72959           0 :      SgUpirDataField* returnPointer = NULL;
   72960           0 :      if ( globalIndex != 0 )
   72961             :         {
   72962             : 
   72963             : #if FILE_IO_EXTRA_CHECK
   72964           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirDataField ) ) <= globalIndex ) ;
   72965           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirDataField + 1 ) ) );
   72966             : #endif
   72967           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirDataField )  
   72968           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirDataField );
   72969           0 :           unsigned long positionInPool = localIndex % SgUpirDataField::pool_size;
   72970           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirDataField::pool_size;
   72971             : 
   72972             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   72973             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   72974             : 
   72975           0 :           returnPointer = &( ( (SgUpirDataField*)(SgUpirDataField::pools[memoryBlock]) ) [positionInPool]) ;
   72976             : 
   72977           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   72978             :         }
   72979           0 :      return returnPointer ;
   72980             :    }
   72981             : 
   72982             : //############################################################################
   72983             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   72984             :   for the AST with the index astIndex
   72985             : */
   72986           0 : SgUpirDataField * SgUpirDataField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   72987           0 :      SgUpirDataField* returnPointer = NULL;
   72988           0 :      if ( globalIndex != 0 )
   72989             :         {
   72990             : 
   72991             : #if FILE_IO_EXTRA_CHECK
   72992           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirDataField ) ) <= globalIndex ) ;
   72993           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirDataField + 1 ) ) );
   72994             : #endif
   72995           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirDataField )
   72996           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirDataField );
   72997           0 :           unsigned long positionInPool = localIndex % SgUpirDataField::pool_size ;
   72998           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirDataField::pool_size ;
   72999             : 
   73000             : #if FILE_IO_EXTRA_CHECK
   73001             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   73002             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   73003             : #endif
   73004             : 
   73005           0 :           returnPointer = &( ( (SgUpirDataField*)(SgUpirDataField::pools[memoryBlock]) ) [positionInPool]) ;
   73006             : 
   73007             : #if FILE_IO_EXTRA_CHECK
   73008           0 :           assert ( returnPointer != NULL ) ;
   73009             : #endif
   73010             :         }
   73011           0 :      return returnPointer ;
   73012             :    }
   73013             : 
   73014             : //############################################################################
   73015             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   73016             :  * pool size! We set for every valid object in the memory pool the freepointer
   73017             :  * to the global index and increase the global index afterwards. For all the 
   73018             :  * invalid objects (means address ranges within the memory pool that were not
   73019             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   73020             :  * distinguish valid from invalid objects! 
   73021             :  */
   73022             : unsigned long
   73023           5 : SgUpirDataField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   73024             :    {
   73025           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   73026           5 :      SgUpirDataField* pointer = NULL;
   73027           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   73028           5 :      std::vector < unsigned char* > :: const_iterator block;
   73029           5 :      for ( block = SgUpirDataField::pools.begin(); block != SgUpirDataField::pools.end() ; ++block )
   73030             :         {
   73031           0 :           pointer = (SgUpirDataField*)(*block);
   73032           0 :           for (unsigned i = 0; i < SgUpirDataField::pool_size; ++i )
   73033             :              {
   73034             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   73035             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   73036             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   73037             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   73038             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   73039             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   73040             :             // properly; so this will have to be checked next.
   73041             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   73042             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   73043           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   73044             :                   {
   73045           0 :                     pointer[i].set_freepointer((SgUpirDataField*)(globalIndex));
   73046           0 :                     globalIndex++;
   73047             :                   }
   73048             :                else
   73049             :                   {
   73050           0 :                     pointer[i].set_freepointer(NULL);
   73051             :                   }
   73052             :               }
   73053             :         }
   73054           5 :      return globalIndex;
   73055             :    }
   73056             : 
   73057             : //############################################################################
   73058             : // JH (01/14/2006)
   73059             : void
   73060           5 : SgUpirDataField::resetValidFreepointers( )
   73061             :    {
   73062           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   73063           5 :      SgUpirDataField* pointer = NULL;
   73064           5 :      std::vector < unsigned char* > :: const_iterator block;
   73065           5 :      SgUpirDataField* pointerOfLinkedList = NULL;
   73066           5 :      for ( block = SgUpirDataField::pools.begin(); block != SgUpirDataField::pools.end() ; ++block )
   73067             :         {
   73068           0 :           pointer = (SgUpirDataField*)(*block);
   73069           0 :           for (unsigned i = 0; i < SgUpirDataField::pool_size; ++i )
   73070             :              {
   73071             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   73072             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   73073             :             // memory blocks!.
   73074           0 :                if ( pointer[i].get_freepointer() != NULL )
   73075             :                   {
   73076           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   73077             :                   }
   73078             :                else
   73079             :                   {
   73080           0 :                     if ( pointerOfLinkedList == NULL )
   73081             :                        {
   73082           0 :                          SgUpirDataField::next_node = &(pointer[i]);
   73083             :                        }
   73084             :                     else
   73085             :                        {
   73086             :                       // printf ("In SgUpirDataField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   73087           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   73088             :                        }
   73089             :                     pointerOfLinkedList = &(pointer[i]);
   73090             :                   }
   73091             :               }
   73092             :         }
   73093             : 
   73094           5 :      if ( pointerOfLinkedList != NULL )
   73095             :         {
   73096             :        // printf ("In SgUpirDataField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   73097           0 :           pointerOfLinkedList->set_freepointer(NULL);
   73098             :        // DQ (6/6/2010): Temporary debugging...
   73099             :        //   ROSE_ASSERT(false);
   73100             :         }
   73101             : 
   73102           5 :      return ;
   73103             :    }
   73104             : 
   73105             : //############################################################################
   73106             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   73107             :  * within the memory pool and resets the freepointers, in order to achieve a 
   73108             :  * linked list, that has no jumps and starts at the beginning! This function 
   73109             :  * does not extend the memory pool, since we do not delete any memory blocks,
   73110             :  * but delete the valid objects.  
   73111             :  */
   73112             : void
   73113           0 : SgUpirDataField::clearMemoryPool( )
   73114             :    {
   73115             :   // printf ("Inside of SgUpirDataField::clearMemoryPool() \n");
   73116             : 
   73117           0 :      SgUpirDataField* pointer = NULL, *tempPointer = NULL;
   73118           0 :      std::vector < unsigned char* > :: const_iterator block;
   73119           0 :      if ( SgUpirDataField::pools.empty() == false )
   73120             :         {
   73121           0 :           block = SgUpirDataField::pools.begin() ;
   73122           0 :           SgUpirDataField::next_node = (SgUpirDataField*) (*block);
   73123             : 
   73124           0 :           while ( block != SgUpirDataField::pools.end() )
   73125             :              {
   73126           0 :                pointer = (SgUpirDataField*) (*block);
   73127           0 :                if ( tempPointer != NULL )
   73128             :                   {
   73129           0 :                     tempPointer->set_freepointer(pointer);
   73130             :                   }
   73131           0 :                for (unsigned i = 0; i < SgUpirDataField::pool_size - 1; ++i)
   73132             :                   {
   73133           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   73134             :                   }
   73135           0 :                 pointer[SgUpirDataField::pool_size-1].set_freepointer(NULL);
   73136           0 :                 tempPointer = &(pointer[SgUpirDataField::pool_size-1]);
   73137           0 :                 ++block;
   73138             :              }
   73139             :         }
   73140           0 :    }
   73141             : 
   73142           5 : void SgUpirDataField::deleteMemoryPool() {
   73143           5 :   for (auto p: SgUpirDataField::pools) {
   73144           0 :     ROSE_FREE(p);
   73145             :   }
   73146           5 :   SgUpirDataField::next_node = nullptr;
   73147           5 :   SgUpirDataField::pools.clear();
   73148           5 : }
   73149             : 
   73150             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   73151             : //                 reading multiple binary files to for a single AST.
   73152             : /////////// new version ////////////////////////////////
   73153             : //############################################################################
   73154             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   73155             : void
   73156           2 : SgUpirDataField::extendMemoryPoolForFileIO( )
   73157             :   {
   73158           2 :     size_t blockIndex = SgUpirDataField::pools.size();
   73159           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirDataField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirDataField);
   73160             : 
   73161           2 :     while ( (blockIndex * SgUpirDataField::pool_size) < newPoolSize)
   73162             :       {
   73163             : #if ROSE_ALLOC_TRACE
   73164             :         if (blockIndex > 0) {
   73165             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirDataField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirDataField) = %" PRIuPTR " SgUpirDataField::pool_size = %d \n",
   73166             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirDataField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirDataField),SgUpirDataField::pool_size);
   73167             :         }
   73168             : #endif
   73169             : 
   73170           0 :         SgUpirDataField * pointer = (SgUpirDataField*) ROSE_MALLOC ( SgUpirDataField::pool_size * sizeof(SgUpirDataField) );
   73171           0 :         assert( pointer != NULL );
   73172             : #if ROSE_ALLOC_MEMSET == 1
   73173             :         memset(pointer, 0x00, SgUpirDataField::pool_size * sizeof(SgUpirDataField));
   73174             : #elif ROSE_ALLOC_MEMSET == 2
   73175             :         memset(pointer, 0xCC, SgUpirDataField::pool_size * sizeof(SgUpirDataField));
   73176             : #endif
   73177           0 :         SgUpirDataField::pools.push_back( (unsigned char*)(pointer) );
   73178           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirDataField::pool_size * sizeof(SgUpirDataField), V_SgUpirDataField ) );
   73179             : 
   73180           0 :         if ( SgUpirDataField::next_node != NULL ) {
   73181           0 :           if ( blockIndex > 0 ) {
   73182           0 :             SgUpirDataField * blkptr = (SgUpirDataField*)(SgUpirDataField::pools[blockIndex-1]);
   73183           0 :             blkptr[ SgUpirDataField::pool_size - 1 ].set_freepointer(pointer);
   73184             :           }
   73185             :         } else {
   73186           0 :           SgUpirDataField::next_node = pointer;
   73187             :         }
   73188             : 
   73189           0 :         for (unsigned i = 0; i < SgUpirDataField::pool_size-1; ++i)
   73190             :            {
   73191           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   73192             :            }
   73193           0 :         pointer[ SgUpirDataField::pool_size -1 ].set_freepointer(NULL);
   73194             : 
   73195           0 :         blockIndex++;
   73196             :       }
   73197           2 :   }
   73198             : 
   73199             : //############################################################################
   73200             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   73201             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   73202             :  * not compressed. However, that stuff is not yet implemented! 
   73203             :  */
   73204             : unsigned long
   73205           0 : SgUpirDataField::getNumberOfLastValidPointer()
   73206             :    {
   73207           0 :       SgUpirDataField* testPointer = (SgUpirDataField*)(SgUpirDataField::pools.back());
   73208           0 :       unsigned long localIndex = SgUpirDataField::pool_size - 1;
   73209           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   73210             :          {
   73211           0 :            localIndex--;
   73212             :          }
   73213           0 :       return (localIndex + SgUpirDataField::pool_size * (SgUpirDataField::pools.size()-1));
   73214             :    }
   73215             : 
   73216             : //############################################################################
   73217             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   73218             :  * memory pool and initializes the data member in class SgUpirDataFieldStroageClass
   73219             :  * from its counterpart of SgUpirDataField. The return value is just for checking, 
   73220             :  * that the whole StorageClassArray is initialized!
   73221             :  */
   73222             : unsigned long
   73223           0 : SgUpirDataField::initializeStorageClassArray( SgUpirDataFieldStorageClass *storageArray )
   73224             :    {
   73225           0 :      unsigned long storageCounter = 0;
   73226           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirDataField::pools.begin();
   73227           0 :      SgUpirDataField* pointer = NULL;
   73228           0 :      while ( block != SgUpirDataField::pools.end() ) {
   73229           0 :           pointer = (SgUpirDataField*) (*block);
   73230           0 :           for ( unsigned i = 0; i < SgUpirDataField::pool_size; ++i ) {
   73231           0 :                if ( pointer->get_freepointer() != NULL ) {
   73232           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   73233           0 :                  storageArray++;
   73234           0 :                  storageCounter++;
   73235             :                }
   73236           0 :                pointer++;
   73237             :              }
   73238           0 :            block++;
   73239             :         }
   73240           0 :      return storageCounter;
   73241             :    }
   73242             : 
   73243             : /* #line 73244 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   73244             : 
   73245             : 
   73246             : 
   73247             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   73248             : 
   73249             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   73250             : 
   73251             : //############################################################################
   73252             : /* JH (02/02/2006) Constructor of the IR node SgUpirTargetField that takes its 
   73253             :  * corresponding StorageClass as parameter
   73254             :  */
   73255           0 : SgUpirTargetField :: SgUpirTargetField ( const SgUpirTargetFieldStorageClass& storageSource )   : SgOmpClause (storageSource)
   73256             :    {
   73257             : 
   73258             : 
   73259             : /* #line 73260 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   73260             : 
   73261           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   73262           0 :      p_target_type = storageSource.storageOf_target_type.rebuildDataStoredInEasyStorageClass() ;
   73263             : 
   73264             : 
   73265             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   73266             : 
   73267             : 
   73268           0 :    }
   73269             : 
   73270             : //############################################################################
   73271             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   73272             :  * within the working AST. 
   73273             :  */
   73274           0 : SgUpirTargetField * SgUpirTargetField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   73275           0 :      SgUpirTargetField* returnPointer = NULL;
   73276           0 :      if ( globalIndex != 0 )
   73277             :         {
   73278             : 
   73279             : #if FILE_IO_EXTRA_CHECK
   73280           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirTargetField ) ) <= globalIndex ) ;
   73281           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirTargetField + 1 ) ) );
   73282             : #endif
   73283           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirTargetField )  
   73284           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirTargetField );
   73285           0 :           unsigned long positionInPool = localIndex % SgUpirTargetField::pool_size;
   73286           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirTargetField::pool_size;
   73287             : 
   73288             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   73289             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   73290             : 
   73291           0 :           returnPointer = &( ( (SgUpirTargetField*)(SgUpirTargetField::pools[memoryBlock]) ) [positionInPool]) ;
   73292             : 
   73293           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   73294             :         }
   73295           0 :      return returnPointer ;
   73296             :    }
   73297             : 
   73298             : //############################################################################
   73299             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   73300             :   for the AST with the index astIndex
   73301             : */
   73302           0 : SgUpirTargetField * SgUpirTargetField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   73303           0 :      SgUpirTargetField* returnPointer = NULL;
   73304           0 :      if ( globalIndex != 0 )
   73305             :         {
   73306             : 
   73307             : #if FILE_IO_EXTRA_CHECK
   73308           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirTargetField ) ) <= globalIndex ) ;
   73309           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirTargetField + 1 ) ) );
   73310             : #endif
   73311           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirTargetField )
   73312           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirTargetField );
   73313           0 :           unsigned long positionInPool = localIndex % SgUpirTargetField::pool_size ;
   73314           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirTargetField::pool_size ;
   73315             : 
   73316             : #if FILE_IO_EXTRA_CHECK
   73317             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   73318             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   73319             : #endif
   73320             : 
   73321           0 :           returnPointer = &( ( (SgUpirTargetField*)(SgUpirTargetField::pools[memoryBlock]) ) [positionInPool]) ;
   73322             : 
   73323             : #if FILE_IO_EXTRA_CHECK
   73324           0 :           assert ( returnPointer != NULL ) ;
   73325             : #endif
   73326             :         }
   73327           0 :      return returnPointer ;
   73328             :    }
   73329             : 
   73330             : //############################################################################
   73331             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   73332             :  * pool size! We set for every valid object in the memory pool the freepointer
   73333             :  * to the global index and increase the global index afterwards. For all the 
   73334             :  * invalid objects (means address ranges within the memory pool that were not
   73335             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   73336             :  * distinguish valid from invalid objects! 
   73337             :  */
   73338             : unsigned long
   73339           5 : SgUpirTargetField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   73340             :    {
   73341           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   73342           5 :      SgUpirTargetField* pointer = NULL;
   73343           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   73344           5 :      std::vector < unsigned char* > :: const_iterator block;
   73345           5 :      for ( block = SgUpirTargetField::pools.begin(); block != SgUpirTargetField::pools.end() ; ++block )
   73346             :         {
   73347           0 :           pointer = (SgUpirTargetField*)(*block);
   73348           0 :           for (unsigned i = 0; i < SgUpirTargetField::pool_size; ++i )
   73349             :              {
   73350             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   73351             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   73352             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   73353             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   73354             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   73355             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   73356             :             // properly; so this will have to be checked next.
   73357             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   73358             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   73359           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   73360             :                   {
   73361           0 :                     pointer[i].set_freepointer((SgUpirTargetField*)(globalIndex));
   73362           0 :                     globalIndex++;
   73363             :                   }
   73364             :                else
   73365             :                   {
   73366           0 :                     pointer[i].set_freepointer(NULL);
   73367             :                   }
   73368             :               }
   73369             :         }
   73370           5 :      return globalIndex;
   73371             :    }
   73372             : 
   73373             : //############################################################################
   73374             : // JH (01/14/2006)
   73375             : void
   73376           5 : SgUpirTargetField::resetValidFreepointers( )
   73377             :    {
   73378           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   73379           5 :      SgUpirTargetField* pointer = NULL;
   73380           5 :      std::vector < unsigned char* > :: const_iterator block;
   73381           5 :      SgUpirTargetField* pointerOfLinkedList = NULL;
   73382           5 :      for ( block = SgUpirTargetField::pools.begin(); block != SgUpirTargetField::pools.end() ; ++block )
   73383             :         {
   73384           0 :           pointer = (SgUpirTargetField*)(*block);
   73385           0 :           for (unsigned i = 0; i < SgUpirTargetField::pool_size; ++i )
   73386             :              {
   73387             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   73388             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   73389             :             // memory blocks!.
   73390           0 :                if ( pointer[i].get_freepointer() != NULL )
   73391             :                   {
   73392           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   73393             :                   }
   73394             :                else
   73395             :                   {
   73396           0 :                     if ( pointerOfLinkedList == NULL )
   73397             :                        {
   73398           0 :                          SgUpirTargetField::next_node = &(pointer[i]);
   73399             :                        }
   73400             :                     else
   73401             :                        {
   73402             :                       // printf ("In SgUpirTargetField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   73403           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   73404             :                        }
   73405             :                     pointerOfLinkedList = &(pointer[i]);
   73406             :                   }
   73407             :               }
   73408             :         }
   73409             : 
   73410           5 :      if ( pointerOfLinkedList != NULL )
   73411             :         {
   73412             :        // printf ("In SgUpirTargetField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   73413           0 :           pointerOfLinkedList->set_freepointer(NULL);
   73414             :        // DQ (6/6/2010): Temporary debugging...
   73415             :        //   ROSE_ASSERT(false);
   73416             :         }
   73417             : 
   73418           5 :      return ;
   73419             :    }
   73420             : 
   73421             : //############################################################################
   73422             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   73423             :  * within the memory pool and resets the freepointers, in order to achieve a 
   73424             :  * linked list, that has no jumps and starts at the beginning! This function 
   73425             :  * does not extend the memory pool, since we do not delete any memory blocks,
   73426             :  * but delete the valid objects.  
   73427             :  */
   73428             : void
   73429           0 : SgUpirTargetField::clearMemoryPool( )
   73430             :    {
   73431             :   // printf ("Inside of SgUpirTargetField::clearMemoryPool() \n");
   73432             : 
   73433           0 :      SgUpirTargetField* pointer = NULL, *tempPointer = NULL;
   73434           0 :      std::vector < unsigned char* > :: const_iterator block;
   73435           0 :      if ( SgUpirTargetField::pools.empty() == false )
   73436             :         {
   73437           0 :           block = SgUpirTargetField::pools.begin() ;
   73438           0 :           SgUpirTargetField::next_node = (SgUpirTargetField*) (*block);
   73439             : 
   73440           0 :           while ( block != SgUpirTargetField::pools.end() )
   73441             :              {
   73442           0 :                pointer = (SgUpirTargetField*) (*block);
   73443           0 :                if ( tempPointer != NULL )
   73444             :                   {
   73445           0 :                     tempPointer->set_freepointer(pointer);
   73446             :                   }
   73447           0 :                for (unsigned i = 0; i < SgUpirTargetField::pool_size - 1; ++i)
   73448             :                   {
   73449           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   73450             :                   }
   73451           0 :                 pointer[SgUpirTargetField::pool_size-1].set_freepointer(NULL);
   73452           0 :                 tempPointer = &(pointer[SgUpirTargetField::pool_size-1]);
   73453           0 :                 ++block;
   73454             :              }
   73455             :         }
   73456           0 :    }
   73457             : 
   73458           5 : void SgUpirTargetField::deleteMemoryPool() {
   73459           5 :   for (auto p: SgUpirTargetField::pools) {
   73460           0 :     ROSE_FREE(p);
   73461             :   }
   73462           5 :   SgUpirTargetField::next_node = nullptr;
   73463           5 :   SgUpirTargetField::pools.clear();
   73464           5 : }
   73465             : 
   73466             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   73467             : //                 reading multiple binary files to for a single AST.
   73468             : /////////// new version ////////////////////////////////
   73469             : //############################################################################
   73470             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   73471             : void
   73472           2 : SgUpirTargetField::extendMemoryPoolForFileIO( )
   73473             :   {
   73474           2 :     size_t blockIndex = SgUpirTargetField::pools.size();
   73475           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirTargetField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirTargetField);
   73476             : 
   73477           2 :     while ( (blockIndex * SgUpirTargetField::pool_size) < newPoolSize)
   73478             :       {
   73479             : #if ROSE_ALLOC_TRACE
   73480             :         if (blockIndex > 0) {
   73481             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirTargetField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirTargetField) = %" PRIuPTR " SgUpirTargetField::pool_size = %d \n",
   73482             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirTargetField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirTargetField),SgUpirTargetField::pool_size);
   73483             :         }
   73484             : #endif
   73485             : 
   73486           0 :         SgUpirTargetField * pointer = (SgUpirTargetField*) ROSE_MALLOC ( SgUpirTargetField::pool_size * sizeof(SgUpirTargetField) );
   73487           0 :         assert( pointer != NULL );
   73488             : #if ROSE_ALLOC_MEMSET == 1
   73489             :         memset(pointer, 0x00, SgUpirTargetField::pool_size * sizeof(SgUpirTargetField));
   73490             : #elif ROSE_ALLOC_MEMSET == 2
   73491             :         memset(pointer, 0xCC, SgUpirTargetField::pool_size * sizeof(SgUpirTargetField));
   73492             : #endif
   73493           0 :         SgUpirTargetField::pools.push_back( (unsigned char*)(pointer) );
   73494           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirTargetField::pool_size * sizeof(SgUpirTargetField), V_SgUpirTargetField ) );
   73495             : 
   73496           0 :         if ( SgUpirTargetField::next_node != NULL ) {
   73497           0 :           if ( blockIndex > 0 ) {
   73498           0 :             SgUpirTargetField * blkptr = (SgUpirTargetField*)(SgUpirTargetField::pools[blockIndex-1]);
   73499           0 :             blkptr[ SgUpirTargetField::pool_size - 1 ].set_freepointer(pointer);
   73500             :           }
   73501             :         } else {
   73502           0 :           SgUpirTargetField::next_node = pointer;
   73503             :         }
   73504             : 
   73505           0 :         for (unsigned i = 0; i < SgUpirTargetField::pool_size-1; ++i)
   73506             :            {
   73507           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   73508             :            }
   73509           0 :         pointer[ SgUpirTargetField::pool_size -1 ].set_freepointer(NULL);
   73510             : 
   73511           0 :         blockIndex++;
   73512             :       }
   73513           2 :   }
   73514             : 
   73515             : //############################################################################
   73516             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   73517             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   73518             :  * not compressed. However, that stuff is not yet implemented! 
   73519             :  */
   73520             : unsigned long
   73521           0 : SgUpirTargetField::getNumberOfLastValidPointer()
   73522             :    {
   73523           0 :       SgUpirTargetField* testPointer = (SgUpirTargetField*)(SgUpirTargetField::pools.back());
   73524           0 :       unsigned long localIndex = SgUpirTargetField::pool_size - 1;
   73525           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   73526             :          {
   73527           0 :            localIndex--;
   73528             :          }
   73529           0 :       return (localIndex + SgUpirTargetField::pool_size * (SgUpirTargetField::pools.size()-1));
   73530             :    }
   73531             : 
   73532             : //############################################################################
   73533             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   73534             :  * memory pool and initializes the data member in class SgUpirTargetFieldStroageClass
   73535             :  * from its counterpart of SgUpirTargetField. The return value is just for checking, 
   73536             :  * that the whole StorageClassArray is initialized!
   73537             :  */
   73538             : unsigned long
   73539           0 : SgUpirTargetField::initializeStorageClassArray( SgUpirTargetFieldStorageClass *storageArray )
   73540             :    {
   73541           0 :      unsigned long storageCounter = 0;
   73542           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirTargetField::pools.begin();
   73543           0 :      SgUpirTargetField* pointer = NULL;
   73544           0 :      while ( block != SgUpirTargetField::pools.end() ) {
   73545           0 :           pointer = (SgUpirTargetField*) (*block);
   73546           0 :           for ( unsigned i = 0; i < SgUpirTargetField::pool_size; ++i ) {
   73547           0 :                if ( pointer->get_freepointer() != NULL ) {
   73548           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   73549           0 :                  storageArray++;
   73550           0 :                  storageCounter++;
   73551             :                }
   73552           0 :                pointer++;
   73553             :              }
   73554           0 :            block++;
   73555             :         }
   73556           0 :      return storageCounter;
   73557             :    }
   73558             : 
   73559             : /* #line 73560 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   73560             : 
   73561             : 
   73562             : 
   73563             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   73564             : 
   73565             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   73566             : 
   73567             : //############################################################################
   73568             : /* JH (02/02/2006) Constructor of the IR node SgUpirDataItemField that takes its 
   73569             :  * corresponding StorageClass as parameter
   73570             :  */
   73571           0 : SgUpirDataItemField :: SgUpirDataItemField ( const SgUpirDataItemFieldStorageClass& storageSource )   : SgOmpClause (storageSource)
   73572             :    {
   73573             : 
   73574             : 
   73575             : /* #line 73576 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   73576             : 
   73577           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   73578           0 :      p_symbol =  (SgSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol) );
   73579           0 :      p_sharing_property = storageSource.storageOf_sharing_property ;
   73580           0 :      p_sharing_visibility = storageSource.storageOf_sharing_visibility ;
   73581           0 :      p_mapping_property = storageSource.storageOf_mapping_property ;
   73582           0 :      p_mapping_visibility = storageSource.storageOf_mapping_visibility ;
   73583           0 :      p_mapper =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_mapper) );
   73584           0 :      p_access_property = storageSource.storageOf_access_property ;
   73585           0 :      p_unit_id =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_unit_id) );
   73586           0 :      p_distribution_pattern = storageSource.storageOf_distribution_pattern ;
   73587           0 :      p_section = storageSource.storageOf_section.rebuildDataStoredInEasyStorageClass() ;
   73588           0 :      p_allocator = storageSource.storageOf_allocator ;
   73589           0 :      p_user_defined_allocator =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_defined_allocator) );
   73590           0 :      p_deallocator = storageSource.storageOf_deallocator ;
   73591           0 :      p_user_defined_deallocator =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_user_defined_deallocator) );
   73592           0 :      p_memcpy_helper =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_memcpy_helper) );
   73593             : 
   73594             : 
   73595             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   73596             : 
   73597             : 
   73598           0 :    }
   73599             : 
   73600             : //############################################################################
   73601             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   73602             :  * within the working AST. 
   73603             :  */
   73604           0 : SgUpirDataItemField * SgUpirDataItemField::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   73605           0 :      SgUpirDataItemField* returnPointer = NULL;
   73606           0 :      if ( globalIndex != 0 )
   73607             :         {
   73608             : 
   73609             : #if FILE_IO_EXTRA_CHECK
   73610           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirDataItemField ) ) <= globalIndex ) ;
   73611           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirDataItemField + 1 ) ) );
   73612             : #endif
   73613           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirDataItemField )  
   73614           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirDataItemField );
   73615           0 :           unsigned long positionInPool = localIndex % SgUpirDataItemField::pool_size;
   73616           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirDataItemField::pool_size;
   73617             : 
   73618             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   73619             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   73620             : 
   73621           0 :           returnPointer = &( ( (SgUpirDataItemField*)(SgUpirDataItemField::pools[memoryBlock]) ) [positionInPool]) ;
   73622             : 
   73623           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   73624             :         }
   73625           0 :      return returnPointer ;
   73626             :    }
   73627             : 
   73628             : //############################################################################
   73629             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   73630             :   for the AST with the index astIndex
   73631             : */
   73632           0 : SgUpirDataItemField * SgUpirDataItemField::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   73633           0 :      SgUpirDataItemField* returnPointer = NULL;
   73634           0 :      if ( globalIndex != 0 )
   73635             :         {
   73636             : 
   73637             : #if FILE_IO_EXTRA_CHECK
   73638           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirDataItemField ) ) <= globalIndex ) ;
   73639           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirDataItemField + 1 ) ) );
   73640             : #endif
   73641           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirDataItemField )
   73642           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirDataItemField );
   73643           0 :           unsigned long positionInPool = localIndex % SgUpirDataItemField::pool_size ;
   73644           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirDataItemField::pool_size ;
   73645             : 
   73646             : #if FILE_IO_EXTRA_CHECK
   73647             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   73648             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   73649             : #endif
   73650             : 
   73651           0 :           returnPointer = &( ( (SgUpirDataItemField*)(SgUpirDataItemField::pools[memoryBlock]) ) [positionInPool]) ;
   73652             : 
   73653             : #if FILE_IO_EXTRA_CHECK
   73654           0 :           assert ( returnPointer != NULL ) ;
   73655             : #endif
   73656             :         }
   73657           0 :      return returnPointer ;
   73658             :    }
   73659             : 
   73660             : //############################################################################
   73661             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   73662             :  * pool size! We set for every valid object in the memory pool the freepointer
   73663             :  * to the global index and increase the global index afterwards. For all the 
   73664             :  * invalid objects (means address ranges within the memory pool that were not
   73665             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   73666             :  * distinguish valid from invalid objects! 
   73667             :  */
   73668             : unsigned long
   73669           5 : SgUpirDataItemField::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   73670             :    {
   73671           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   73672           5 :      SgUpirDataItemField* pointer = NULL;
   73673           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   73674           5 :      std::vector < unsigned char* > :: const_iterator block;
   73675           5 :      for ( block = SgUpirDataItemField::pools.begin(); block != SgUpirDataItemField::pools.end() ; ++block )
   73676             :         {
   73677           0 :           pointer = (SgUpirDataItemField*)(*block);
   73678           0 :           for (unsigned i = 0; i < SgUpirDataItemField::pool_size; ++i )
   73679             :              {
   73680             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   73681             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   73682             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   73683             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   73684             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   73685             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   73686             :             // properly; so this will have to be checked next.
   73687             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   73688             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   73689           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   73690             :                   {
   73691           0 :                     pointer[i].set_freepointer((SgUpirDataItemField*)(globalIndex));
   73692           0 :                     globalIndex++;
   73693             :                   }
   73694             :                else
   73695             :                   {
   73696           0 :                     pointer[i].set_freepointer(NULL);
   73697             :                   }
   73698             :               }
   73699             :         }
   73700           5 :      return globalIndex;
   73701             :    }
   73702             : 
   73703             : //############################################################################
   73704             : // JH (01/14/2006)
   73705             : void
   73706           5 : SgUpirDataItemField::resetValidFreepointers( )
   73707             :    {
   73708           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   73709           5 :      SgUpirDataItemField* pointer = NULL;
   73710           5 :      std::vector < unsigned char* > :: const_iterator block;
   73711           5 :      SgUpirDataItemField* pointerOfLinkedList = NULL;
   73712           5 :      for ( block = SgUpirDataItemField::pools.begin(); block != SgUpirDataItemField::pools.end() ; ++block )
   73713             :         {
   73714           0 :           pointer = (SgUpirDataItemField*)(*block);
   73715           0 :           for (unsigned i = 0; i < SgUpirDataItemField::pool_size; ++i )
   73716             :              {
   73717             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   73718             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   73719             :             // memory blocks!.
   73720           0 :                if ( pointer[i].get_freepointer() != NULL )
   73721             :                   {
   73722           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   73723             :                   }
   73724             :                else
   73725             :                   {
   73726           0 :                     if ( pointerOfLinkedList == NULL )
   73727             :                        {
   73728           0 :                          SgUpirDataItemField::next_node = &(pointer[i]);
   73729             :                        }
   73730             :                     else
   73731             :                        {
   73732             :                       // printf ("In SgUpirDataItemField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   73733           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   73734             :                        }
   73735             :                     pointerOfLinkedList = &(pointer[i]);
   73736             :                   }
   73737             :               }
   73738             :         }
   73739             : 
   73740           5 :      if ( pointerOfLinkedList != NULL )
   73741             :         {
   73742             :        // printf ("In SgUpirDataItemField::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   73743           0 :           pointerOfLinkedList->set_freepointer(NULL);
   73744             :        // DQ (6/6/2010): Temporary debugging...
   73745             :        //   ROSE_ASSERT(false);
   73746             :         }
   73747             : 
   73748           5 :      return ;
   73749             :    }
   73750             : 
   73751             : //############################################################################
   73752             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   73753             :  * within the memory pool and resets the freepointers, in order to achieve a 
   73754             :  * linked list, that has no jumps and starts at the beginning! This function 
   73755             :  * does not extend the memory pool, since we do not delete any memory blocks,
   73756             :  * but delete the valid objects.  
   73757             :  */
   73758             : void
   73759           0 : SgUpirDataItemField::clearMemoryPool( )
   73760             :    {
   73761             :   // printf ("Inside of SgUpirDataItemField::clearMemoryPool() \n");
   73762             : 
   73763           0 :      SgUpirDataItemField* pointer = NULL, *tempPointer = NULL;
   73764           0 :      std::vector < unsigned char* > :: const_iterator block;
   73765           0 :      if ( SgUpirDataItemField::pools.empty() == false )
   73766             :         {
   73767           0 :           block = SgUpirDataItemField::pools.begin() ;
   73768           0 :           SgUpirDataItemField::next_node = (SgUpirDataItemField*) (*block);
   73769             : 
   73770           0 :           while ( block != SgUpirDataItemField::pools.end() )
   73771             :              {
   73772           0 :                pointer = (SgUpirDataItemField*) (*block);
   73773           0 :                if ( tempPointer != NULL )
   73774             :                   {
   73775           0 :                     tempPointer->set_freepointer(pointer);
   73776             :                   }
   73777           0 :                for (unsigned i = 0; i < SgUpirDataItemField::pool_size - 1; ++i)
   73778             :                   {
   73779           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   73780             :                   }
   73781           0 :                 pointer[SgUpirDataItemField::pool_size-1].set_freepointer(NULL);
   73782           0 :                 tempPointer = &(pointer[SgUpirDataItemField::pool_size-1]);
   73783           0 :                 ++block;
   73784             :              }
   73785             :         }
   73786           0 :    }
   73787             : 
   73788           5 : void SgUpirDataItemField::deleteMemoryPool() {
   73789           5 :   for (auto p: SgUpirDataItemField::pools) {
   73790           0 :     ROSE_FREE(p);
   73791             :   }
   73792           5 :   SgUpirDataItemField::next_node = nullptr;
   73793           5 :   SgUpirDataItemField::pools.clear();
   73794           5 : }
   73795             : 
   73796             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   73797             : //                 reading multiple binary files to for a single AST.
   73798             : /////////// new version ////////////////////////////////
   73799             : //############################################################################
   73800             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   73801             : void
   73802           2 : SgUpirDataItemField::extendMemoryPoolForFileIO( )
   73803             :   {
   73804           2 :     size_t blockIndex = SgUpirDataItemField::pools.size();
   73805           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirDataItemField) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirDataItemField);
   73806             : 
   73807           2 :     while ( (blockIndex * SgUpirDataItemField::pool_size) < newPoolSize)
   73808             :       {
   73809             : #if ROSE_ALLOC_TRACE
   73810             :         if (blockIndex > 0) {
   73811             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirDataItemField) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirDataItemField) = %" PRIuPTR " SgUpirDataItemField::pool_size = %d \n",
   73812             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirDataItemField),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirDataItemField),SgUpirDataItemField::pool_size);
   73813             :         }
   73814             : #endif
   73815             : 
   73816           0 :         SgUpirDataItemField * pointer = (SgUpirDataItemField*) ROSE_MALLOC ( SgUpirDataItemField::pool_size * sizeof(SgUpirDataItemField) );
   73817           0 :         assert( pointer != NULL );
   73818             : #if ROSE_ALLOC_MEMSET == 1
   73819             :         memset(pointer, 0x00, SgUpirDataItemField::pool_size * sizeof(SgUpirDataItemField));
   73820             : #elif ROSE_ALLOC_MEMSET == 2
   73821             :         memset(pointer, 0xCC, SgUpirDataItemField::pool_size * sizeof(SgUpirDataItemField));
   73822             : #endif
   73823           0 :         SgUpirDataItemField::pools.push_back( (unsigned char*)(pointer) );
   73824           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirDataItemField::pool_size * sizeof(SgUpirDataItemField), V_SgUpirDataItemField ) );
   73825             : 
   73826           0 :         if ( SgUpirDataItemField::next_node != NULL ) {
   73827           0 :           if ( blockIndex > 0 ) {
   73828           0 :             SgUpirDataItemField * blkptr = (SgUpirDataItemField*)(SgUpirDataItemField::pools[blockIndex-1]);
   73829           0 :             blkptr[ SgUpirDataItemField::pool_size - 1 ].set_freepointer(pointer);
   73830             :           }
   73831             :         } else {
   73832           0 :           SgUpirDataItemField::next_node = pointer;
   73833             :         }
   73834             : 
   73835           0 :         for (unsigned i = 0; i < SgUpirDataItemField::pool_size-1; ++i)
   73836             :            {
   73837           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   73838             :            }
   73839           0 :         pointer[ SgUpirDataItemField::pool_size -1 ].set_freepointer(NULL);
   73840             : 
   73841           0 :         blockIndex++;
   73842             :       }
   73843           2 :   }
   73844             : 
   73845             : //############################################################################
   73846             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   73847             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   73848             :  * not compressed. However, that stuff is not yet implemented! 
   73849             :  */
   73850             : unsigned long
   73851           0 : SgUpirDataItemField::getNumberOfLastValidPointer()
   73852             :    {
   73853           0 :       SgUpirDataItemField* testPointer = (SgUpirDataItemField*)(SgUpirDataItemField::pools.back());
   73854           0 :       unsigned long localIndex = SgUpirDataItemField::pool_size - 1;
   73855           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   73856             :          {
   73857           0 :            localIndex--;
   73858             :          }
   73859           0 :       return (localIndex + SgUpirDataItemField::pool_size * (SgUpirDataItemField::pools.size()-1));
   73860             :    }
   73861             : 
   73862             : //############################################################################
   73863             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   73864             :  * memory pool and initializes the data member in class SgUpirDataItemFieldStroageClass
   73865             :  * from its counterpart of SgUpirDataItemField. The return value is just for checking, 
   73866             :  * that the whole StorageClassArray is initialized!
   73867             :  */
   73868             : unsigned long
   73869           0 : SgUpirDataItemField::initializeStorageClassArray( SgUpirDataItemFieldStorageClass *storageArray )
   73870             :    {
   73871           0 :      unsigned long storageCounter = 0;
   73872           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirDataItemField::pools.begin();
   73873           0 :      SgUpirDataItemField* pointer = NULL;
   73874           0 :      while ( block != SgUpirDataItemField::pools.end() ) {
   73875           0 :           pointer = (SgUpirDataItemField*) (*block);
   73876           0 :           for ( unsigned i = 0; i < SgUpirDataItemField::pool_size; ++i ) {
   73877           0 :                if ( pointer->get_freepointer() != NULL ) {
   73878           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   73879           0 :                  storageArray++;
   73880           0 :                  storageCounter++;
   73881             :                }
   73882           0 :                pointer++;
   73883             :              }
   73884           0 :            block++;
   73885             :         }
   73886           0 :      return storageCounter;
   73887             :    }
   73888             : 
   73889             : /* #line 73890 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   73890             : 
   73891             : 
   73892             : 
   73893             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   73894             : 
   73895             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   73896             : 
   73897             : //############################################################################
   73898             : /* JH (02/02/2006) Constructor of the IR node SgLambdaCapture that takes its 
   73899             :  * corresponding StorageClass as parameter
   73900             :  */
   73901           0 : SgLambdaCapture :: SgLambdaCapture ( const SgLambdaCaptureStorageClass& storageSource )   : SgLocatedNodeSupport (storageSource)
   73902             :    {
   73903             : 
   73904             : 
   73905             : /* #line 73906 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   73906             : 
   73907           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   73908           0 :      p_capture_variable =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_capture_variable) );
   73909           0 :      p_source_closure_variable =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_source_closure_variable) );
   73910           0 :      p_closure_variable =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_closure_variable) );
   73911           0 :      p_capture_by_reference = storageSource.storageOf_capture_by_reference ;
   73912           0 :      p_implicit = storageSource.storageOf_implicit ;
   73913           0 :      p_pack_expansion = storageSource.storageOf_pack_expansion ;
   73914             : 
   73915             : 
   73916             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   73917             : 
   73918             : 
   73919           0 :    }
   73920             : 
   73921             : //############################################################################
   73922             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   73923             :  * within the working AST. 
   73924             :  */
   73925           0 : SgLambdaCapture * SgLambdaCapture::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   73926           0 :      SgLambdaCapture* returnPointer = NULL;
   73927           0 :      if ( globalIndex != 0 )
   73928             :         {
   73929             : 
   73930             : #if FILE_IO_EXTRA_CHECK
   73931           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLambdaCapture ) ) <= globalIndex ) ;
   73932           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLambdaCapture + 1 ) ) );
   73933             : #endif
   73934           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLambdaCapture )  
   73935           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLambdaCapture );
   73936           0 :           unsigned long positionInPool = localIndex % SgLambdaCapture::pool_size;
   73937           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLambdaCapture::pool_size;
   73938             : 
   73939             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   73940             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   73941             : 
   73942           0 :           returnPointer = &( ( (SgLambdaCapture*)(SgLambdaCapture::pools[memoryBlock]) ) [positionInPool]) ;
   73943             : 
   73944           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   73945             :         }
   73946           0 :      return returnPointer ;
   73947             :    }
   73948             : 
   73949             : //############################################################################
   73950             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   73951             :   for the AST with the index astIndex
   73952             : */
   73953           0 : SgLambdaCapture * SgLambdaCapture::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   73954           0 :      SgLambdaCapture* returnPointer = NULL;
   73955           0 :      if ( globalIndex != 0 )
   73956             :         {
   73957             : 
   73958             : #if FILE_IO_EXTRA_CHECK
   73959           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLambdaCapture ) ) <= globalIndex ) ;
   73960           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLambdaCapture + 1 ) ) );
   73961             : #endif
   73962           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLambdaCapture )
   73963           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLambdaCapture );
   73964           0 :           unsigned long positionInPool = localIndex % SgLambdaCapture::pool_size ;
   73965           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLambdaCapture::pool_size ;
   73966             : 
   73967             : #if FILE_IO_EXTRA_CHECK
   73968             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   73969             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   73970             : #endif
   73971             : 
   73972           0 :           returnPointer = &( ( (SgLambdaCapture*)(SgLambdaCapture::pools[memoryBlock]) ) [positionInPool]) ;
   73973             : 
   73974             : #if FILE_IO_EXTRA_CHECK
   73975           0 :           assert ( returnPointer != NULL ) ;
   73976             : #endif
   73977             :         }
   73978           0 :      return returnPointer ;
   73979             :    }
   73980             : 
   73981             : //############################################################################
   73982             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   73983             :  * pool size! We set for every valid object in the memory pool the freepointer
   73984             :  * to the global index and increase the global index afterwards. For all the 
   73985             :  * invalid objects (means address ranges within the memory pool that were not
   73986             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   73987             :  * distinguish valid from invalid objects! 
   73988             :  */
   73989             : unsigned long
   73990           5 : SgLambdaCapture::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   73991             :    {
   73992           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   73993           5 :      SgLambdaCapture* pointer = NULL;
   73994           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   73995           5 :      std::vector < unsigned char* > :: const_iterator block;
   73996           5 :      for ( block = SgLambdaCapture::pools.begin(); block != SgLambdaCapture::pools.end() ; ++block )
   73997             :         {
   73998           0 :           pointer = (SgLambdaCapture*)(*block);
   73999           0 :           for (unsigned i = 0; i < SgLambdaCapture::pool_size; ++i )
   74000             :              {
   74001             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   74002             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   74003             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   74004             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   74005             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   74006             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   74007             :             // properly; so this will have to be checked next.
   74008             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   74009             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   74010           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   74011             :                   {
   74012           0 :                     pointer[i].set_freepointer((SgLambdaCapture*)(globalIndex));
   74013           0 :                     globalIndex++;
   74014             :                   }
   74015             :                else
   74016             :                   {
   74017           0 :                     pointer[i].set_freepointer(NULL);
   74018             :                   }
   74019             :               }
   74020             :         }
   74021           5 :      return globalIndex;
   74022             :    }
   74023             : 
   74024             : //############################################################################
   74025             : // JH (01/14/2006)
   74026             : void
   74027           5 : SgLambdaCapture::resetValidFreepointers( )
   74028             :    {
   74029           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   74030           5 :      SgLambdaCapture* pointer = NULL;
   74031           5 :      std::vector < unsigned char* > :: const_iterator block;
   74032           5 :      SgLambdaCapture* pointerOfLinkedList = NULL;
   74033           5 :      for ( block = SgLambdaCapture::pools.begin(); block != SgLambdaCapture::pools.end() ; ++block )
   74034             :         {
   74035           0 :           pointer = (SgLambdaCapture*)(*block);
   74036           0 :           for (unsigned i = 0; i < SgLambdaCapture::pool_size; ++i )
   74037             :              {
   74038             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   74039             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   74040             :             // memory blocks!.
   74041           0 :                if ( pointer[i].get_freepointer() != NULL )
   74042             :                   {
   74043           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   74044             :                   }
   74045             :                else
   74046             :                   {
   74047           0 :                     if ( pointerOfLinkedList == NULL )
   74048             :                        {
   74049           0 :                          SgLambdaCapture::next_node = &(pointer[i]);
   74050             :                        }
   74051             :                     else
   74052             :                        {
   74053             :                       // printf ("In SgLambdaCapture::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   74054           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   74055             :                        }
   74056             :                     pointerOfLinkedList = &(pointer[i]);
   74057             :                   }
   74058             :               }
   74059             :         }
   74060             : 
   74061           5 :      if ( pointerOfLinkedList != NULL )
   74062             :         {
   74063             :        // printf ("In SgLambdaCapture::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   74064           0 :           pointerOfLinkedList->set_freepointer(NULL);
   74065             :        // DQ (6/6/2010): Temporary debugging...
   74066             :        //   ROSE_ASSERT(false);
   74067             :         }
   74068             : 
   74069           5 :      return ;
   74070             :    }
   74071             : 
   74072             : //############################################################################
   74073             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   74074             :  * within the memory pool and resets the freepointers, in order to achieve a 
   74075             :  * linked list, that has no jumps and starts at the beginning! This function 
   74076             :  * does not extend the memory pool, since we do not delete any memory blocks,
   74077             :  * but delete the valid objects.  
   74078             :  */
   74079             : void
   74080           0 : SgLambdaCapture::clearMemoryPool( )
   74081             :    {
   74082             :   // printf ("Inside of SgLambdaCapture::clearMemoryPool() \n");
   74083             : 
   74084           0 :      SgLambdaCapture* pointer = NULL, *tempPointer = NULL;
   74085           0 :      std::vector < unsigned char* > :: const_iterator block;
   74086           0 :      if ( SgLambdaCapture::pools.empty() == false )
   74087             :         {
   74088           0 :           block = SgLambdaCapture::pools.begin() ;
   74089           0 :           SgLambdaCapture::next_node = (SgLambdaCapture*) (*block);
   74090             : 
   74091           0 :           while ( block != SgLambdaCapture::pools.end() )
   74092             :              {
   74093           0 :                pointer = (SgLambdaCapture*) (*block);
   74094           0 :                if ( tempPointer != NULL )
   74095             :                   {
   74096           0 :                     tempPointer->set_freepointer(pointer);
   74097             :                   }
   74098           0 :                for (unsigned i = 0; i < SgLambdaCapture::pool_size - 1; ++i)
   74099             :                   {
   74100           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   74101             :                   }
   74102           0 :                 pointer[SgLambdaCapture::pool_size-1].set_freepointer(NULL);
   74103           0 :                 tempPointer = &(pointer[SgLambdaCapture::pool_size-1]);
   74104           0 :                 ++block;
   74105             :              }
   74106             :         }
   74107           0 :    }
   74108             : 
   74109           5 : void SgLambdaCapture::deleteMemoryPool() {
   74110           5 :   for (auto p: SgLambdaCapture::pools) {
   74111           0 :     ROSE_FREE(p);
   74112             :   }
   74113           5 :   SgLambdaCapture::next_node = nullptr;
   74114           5 :   SgLambdaCapture::pools.clear();
   74115           5 : }
   74116             : 
   74117             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   74118             : //                 reading multiple binary files to for a single AST.
   74119             : /////////// new version ////////////////////////////////
   74120             : //############################################################################
   74121             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   74122             : void
   74123           2 : SgLambdaCapture::extendMemoryPoolForFileIO( )
   74124             :   {
   74125           2 :     size_t blockIndex = SgLambdaCapture::pools.size();
   74126           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaCapture) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaCapture);
   74127             : 
   74128           2 :     while ( (blockIndex * SgLambdaCapture::pool_size) < newPoolSize)
   74129             :       {
   74130             : #if ROSE_ALLOC_TRACE
   74131             :         if (blockIndex > 0) {
   74132             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaCapture) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaCapture) = %" PRIuPTR " SgLambdaCapture::pool_size = %d \n",
   74133             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaCapture),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaCapture),SgLambdaCapture::pool_size);
   74134             :         }
   74135             : #endif
   74136             : 
   74137           0 :         SgLambdaCapture * pointer = (SgLambdaCapture*) ROSE_MALLOC ( SgLambdaCapture::pool_size * sizeof(SgLambdaCapture) );
   74138           0 :         assert( pointer != NULL );
   74139             : #if ROSE_ALLOC_MEMSET == 1
   74140             :         memset(pointer, 0x00, SgLambdaCapture::pool_size * sizeof(SgLambdaCapture));
   74141             : #elif ROSE_ALLOC_MEMSET == 2
   74142             :         memset(pointer, 0xCC, SgLambdaCapture::pool_size * sizeof(SgLambdaCapture));
   74143             : #endif
   74144           0 :         SgLambdaCapture::pools.push_back( (unsigned char*)(pointer) );
   74145           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLambdaCapture::pool_size * sizeof(SgLambdaCapture), V_SgLambdaCapture ) );
   74146             : 
   74147           0 :         if ( SgLambdaCapture::next_node != NULL ) {
   74148           0 :           if ( blockIndex > 0 ) {
   74149           0 :             SgLambdaCapture * blkptr = (SgLambdaCapture*)(SgLambdaCapture::pools[blockIndex-1]);
   74150           0 :             blkptr[ SgLambdaCapture::pool_size - 1 ].set_freepointer(pointer);
   74151             :           }
   74152             :         } else {
   74153           0 :           SgLambdaCapture::next_node = pointer;
   74154             :         }
   74155             : 
   74156           0 :         for (unsigned i = 0; i < SgLambdaCapture::pool_size-1; ++i)
   74157             :            {
   74158           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   74159             :            }
   74160           0 :         pointer[ SgLambdaCapture::pool_size -1 ].set_freepointer(NULL);
   74161             : 
   74162           0 :         blockIndex++;
   74163             :       }
   74164           2 :   }
   74165             : 
   74166             : //############################################################################
   74167             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   74168             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   74169             :  * not compressed. However, that stuff is not yet implemented! 
   74170             :  */
   74171             : unsigned long
   74172           0 : SgLambdaCapture::getNumberOfLastValidPointer()
   74173             :    {
   74174           0 :       SgLambdaCapture* testPointer = (SgLambdaCapture*)(SgLambdaCapture::pools.back());
   74175           0 :       unsigned long localIndex = SgLambdaCapture::pool_size - 1;
   74176           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   74177             :          {
   74178           0 :            localIndex--;
   74179             :          }
   74180           0 :       return (localIndex + SgLambdaCapture::pool_size * (SgLambdaCapture::pools.size()-1));
   74181             :    }
   74182             : 
   74183             : //############################################################################
   74184             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   74185             :  * memory pool and initializes the data member in class SgLambdaCaptureStroageClass
   74186             :  * from its counterpart of SgLambdaCapture. The return value is just for checking, 
   74187             :  * that the whole StorageClassArray is initialized!
   74188             :  */
   74189             : unsigned long
   74190           0 : SgLambdaCapture::initializeStorageClassArray( SgLambdaCaptureStorageClass *storageArray )
   74191             :    {
   74192           0 :      unsigned long storageCounter = 0;
   74193           0 :      std::vector < unsigned char* > :: const_iterator block = SgLambdaCapture::pools.begin();
   74194           0 :      SgLambdaCapture* pointer = NULL;
   74195           0 :      while ( block != SgLambdaCapture::pools.end() ) {
   74196           0 :           pointer = (SgLambdaCapture*) (*block);
   74197           0 :           for ( unsigned i = 0; i < SgLambdaCapture::pool_size; ++i ) {
   74198           0 :                if ( pointer->get_freepointer() != NULL ) {
   74199           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   74200           0 :                  storageArray++;
   74201           0 :                  storageCounter++;
   74202             :                }
   74203           0 :                pointer++;
   74204             :              }
   74205           0 :            block++;
   74206             :         }
   74207           0 :      return storageCounter;
   74208             :    }
   74209             : 
   74210             : /* #line 74211 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   74211             : 
   74212             : 
   74213             : 
   74214             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   74215             : 
   74216             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   74217             : 
   74218             : //############################################################################
   74219             : /* JH (02/02/2006) Constructor of the IR node SgLambdaCaptureList that takes its 
   74220             :  * corresponding StorageClass as parameter
   74221             :  */
   74222           0 : SgLambdaCaptureList :: SgLambdaCaptureList ( const SgLambdaCaptureListStorageClass& storageSource )   : SgLocatedNodeSupport (storageSource)
   74223             :    {
   74224             : 
   74225             : 
   74226             : /* #line 74227 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   74227             : 
   74228           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   74229           0 :      p_capture_list = storageSource.storageOf_capture_list.rebuildDataStoredInEasyStorageClass() ;
   74230           0 :      SgLambdaCapturePtrList::iterator i_capture_list = p_capture_list.begin() ; 
   74231           0 :      for ( ; i_capture_list != p_capture_list.end(); ++i_capture_list ) 
   74232             :         {
   74233           0 :           (*i_capture_list) = (SgLambdaCapturePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_capture_list) ) );
   74234             :         }
   74235             : 
   74236             : 
   74237             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   74238             : 
   74239             : 
   74240           0 :    }
   74241             : 
   74242             : //############################################################################
   74243             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   74244             :  * within the working AST. 
   74245             :  */
   74246           0 : SgLambdaCaptureList * SgLambdaCaptureList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   74247           0 :      SgLambdaCaptureList* returnPointer = NULL;
   74248           0 :      if ( globalIndex != 0 )
   74249             :         {
   74250             : 
   74251             : #if FILE_IO_EXTRA_CHECK
   74252           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLambdaCaptureList ) ) <= globalIndex ) ;
   74253           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLambdaCaptureList + 1 ) ) );
   74254             : #endif
   74255           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLambdaCaptureList )  
   74256           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLambdaCaptureList );
   74257           0 :           unsigned long positionInPool = localIndex % SgLambdaCaptureList::pool_size;
   74258           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLambdaCaptureList::pool_size;
   74259             : 
   74260             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   74261             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   74262             : 
   74263           0 :           returnPointer = &( ( (SgLambdaCaptureList*)(SgLambdaCaptureList::pools[memoryBlock]) ) [positionInPool]) ;
   74264             : 
   74265           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   74266             :         }
   74267           0 :      return returnPointer ;
   74268             :    }
   74269             : 
   74270             : //############################################################################
   74271             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   74272             :   for the AST with the index astIndex
   74273             : */
   74274           0 : SgLambdaCaptureList * SgLambdaCaptureList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   74275           0 :      SgLambdaCaptureList* returnPointer = NULL;
   74276           0 :      if ( globalIndex != 0 )
   74277             :         {
   74278             : 
   74279             : #if FILE_IO_EXTRA_CHECK
   74280           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLambdaCaptureList ) ) <= globalIndex ) ;
   74281           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLambdaCaptureList + 1 ) ) );
   74282             : #endif
   74283           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLambdaCaptureList )
   74284           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLambdaCaptureList );
   74285           0 :           unsigned long positionInPool = localIndex % SgLambdaCaptureList::pool_size ;
   74286           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLambdaCaptureList::pool_size ;
   74287             : 
   74288             : #if FILE_IO_EXTRA_CHECK
   74289             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   74290             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   74291             : #endif
   74292             : 
   74293           0 :           returnPointer = &( ( (SgLambdaCaptureList*)(SgLambdaCaptureList::pools[memoryBlock]) ) [positionInPool]) ;
   74294             : 
   74295             : #if FILE_IO_EXTRA_CHECK
   74296           0 :           assert ( returnPointer != NULL ) ;
   74297             : #endif
   74298             :         }
   74299           0 :      return returnPointer ;
   74300             :    }
   74301             : 
   74302             : //############################################################################
   74303             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   74304             :  * pool size! We set for every valid object in the memory pool the freepointer
   74305             :  * to the global index and increase the global index afterwards. For all the 
   74306             :  * invalid objects (means address ranges within the memory pool that were not
   74307             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   74308             :  * distinguish valid from invalid objects! 
   74309             :  */
   74310             : unsigned long
   74311           5 : SgLambdaCaptureList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   74312             :    {
   74313           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   74314           5 :      SgLambdaCaptureList* pointer = NULL;
   74315           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   74316           5 :      std::vector < unsigned char* > :: const_iterator block;
   74317           5 :      for ( block = SgLambdaCaptureList::pools.begin(); block != SgLambdaCaptureList::pools.end() ; ++block )
   74318             :         {
   74319           0 :           pointer = (SgLambdaCaptureList*)(*block);
   74320           0 :           for (unsigned i = 0; i < SgLambdaCaptureList::pool_size; ++i )
   74321             :              {
   74322             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   74323             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   74324             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   74325             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   74326             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   74327             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   74328             :             // properly; so this will have to be checked next.
   74329             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   74330             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   74331           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   74332             :                   {
   74333           0 :                     pointer[i].set_freepointer((SgLambdaCaptureList*)(globalIndex));
   74334           0 :                     globalIndex++;
   74335             :                   }
   74336             :                else
   74337             :                   {
   74338           0 :                     pointer[i].set_freepointer(NULL);
   74339             :                   }
   74340             :               }
   74341             :         }
   74342           5 :      return globalIndex;
   74343             :    }
   74344             : 
   74345             : //############################################################################
   74346             : // JH (01/14/2006)
   74347             : void
   74348           5 : SgLambdaCaptureList::resetValidFreepointers( )
   74349             :    {
   74350           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   74351           5 :      SgLambdaCaptureList* pointer = NULL;
   74352           5 :      std::vector < unsigned char* > :: const_iterator block;
   74353           5 :      SgLambdaCaptureList* pointerOfLinkedList = NULL;
   74354           5 :      for ( block = SgLambdaCaptureList::pools.begin(); block != SgLambdaCaptureList::pools.end() ; ++block )
   74355             :         {
   74356           0 :           pointer = (SgLambdaCaptureList*)(*block);
   74357           0 :           for (unsigned i = 0; i < SgLambdaCaptureList::pool_size; ++i )
   74358             :              {
   74359             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   74360             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   74361             :             // memory blocks!.
   74362           0 :                if ( pointer[i].get_freepointer() != NULL )
   74363             :                   {
   74364           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   74365             :                   }
   74366             :                else
   74367             :                   {
   74368           0 :                     if ( pointerOfLinkedList == NULL )
   74369             :                        {
   74370           0 :                          SgLambdaCaptureList::next_node = &(pointer[i]);
   74371             :                        }
   74372             :                     else
   74373             :                        {
   74374             :                       // printf ("In SgLambdaCaptureList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   74375           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   74376             :                        }
   74377             :                     pointerOfLinkedList = &(pointer[i]);
   74378             :                   }
   74379             :               }
   74380             :         }
   74381             : 
   74382           5 :      if ( pointerOfLinkedList != NULL )
   74383             :         {
   74384             :        // printf ("In SgLambdaCaptureList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   74385           0 :           pointerOfLinkedList->set_freepointer(NULL);
   74386             :        // DQ (6/6/2010): Temporary debugging...
   74387             :        //   ROSE_ASSERT(false);
   74388             :         }
   74389             : 
   74390           5 :      return ;
   74391             :    }
   74392             : 
   74393             : //############################################################################
   74394             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   74395             :  * within the memory pool and resets the freepointers, in order to achieve a 
   74396             :  * linked list, that has no jumps and starts at the beginning! This function 
   74397             :  * does not extend the memory pool, since we do not delete any memory blocks,
   74398             :  * but delete the valid objects.  
   74399             :  */
   74400             : void
   74401           0 : SgLambdaCaptureList::clearMemoryPool( )
   74402             :    {
   74403             :   // printf ("Inside of SgLambdaCaptureList::clearMemoryPool() \n");
   74404             : 
   74405           0 :      SgLambdaCaptureList* pointer = NULL, *tempPointer = NULL;
   74406           0 :      std::vector < unsigned char* > :: const_iterator block;
   74407           0 :      if ( SgLambdaCaptureList::pools.empty() == false )
   74408             :         {
   74409           0 :           block = SgLambdaCaptureList::pools.begin() ;
   74410           0 :           SgLambdaCaptureList::next_node = (SgLambdaCaptureList*) (*block);
   74411             : 
   74412           0 :           while ( block != SgLambdaCaptureList::pools.end() )
   74413             :              {
   74414           0 :                pointer = (SgLambdaCaptureList*) (*block);
   74415           0 :                if ( tempPointer != NULL )
   74416             :                   {
   74417           0 :                     tempPointer->set_freepointer(pointer);
   74418             :                   }
   74419           0 :                for (unsigned i = 0; i < SgLambdaCaptureList::pool_size - 1; ++i)
   74420             :                   {
   74421           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   74422             :                   }
   74423           0 :                 pointer[SgLambdaCaptureList::pool_size-1].set_freepointer(NULL);
   74424           0 :                 tempPointer = &(pointer[SgLambdaCaptureList::pool_size-1]);
   74425           0 :                 ++block;
   74426             :              }
   74427             :         }
   74428           0 :    }
   74429             : 
   74430           5 : void SgLambdaCaptureList::deleteMemoryPool() {
   74431           5 :   for (auto p: SgLambdaCaptureList::pools) {
   74432           0 :     ROSE_FREE(p);
   74433             :   }
   74434           5 :   SgLambdaCaptureList::next_node = nullptr;
   74435           5 :   SgLambdaCaptureList::pools.clear();
   74436           5 : }
   74437             : 
   74438             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   74439             : //                 reading multiple binary files to for a single AST.
   74440             : /////////// new version ////////////////////////////////
   74441             : //############################################################################
   74442             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   74443             : void
   74444           2 : SgLambdaCaptureList::extendMemoryPoolForFileIO( )
   74445             :   {
   74446           2 :     size_t blockIndex = SgLambdaCaptureList::pools.size();
   74447           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaCaptureList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaCaptureList);
   74448             : 
   74449           2 :     while ( (blockIndex * SgLambdaCaptureList::pool_size) < newPoolSize)
   74450             :       {
   74451             : #if ROSE_ALLOC_TRACE
   74452             :         if (blockIndex > 0) {
   74453             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaCaptureList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaCaptureList) = %" PRIuPTR " SgLambdaCaptureList::pool_size = %d \n",
   74454             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaCaptureList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaCaptureList),SgLambdaCaptureList::pool_size);
   74455             :         }
   74456             : #endif
   74457             : 
   74458           0 :         SgLambdaCaptureList * pointer = (SgLambdaCaptureList*) ROSE_MALLOC ( SgLambdaCaptureList::pool_size * sizeof(SgLambdaCaptureList) );
   74459           0 :         assert( pointer != NULL );
   74460             : #if ROSE_ALLOC_MEMSET == 1
   74461             :         memset(pointer, 0x00, SgLambdaCaptureList::pool_size * sizeof(SgLambdaCaptureList));
   74462             : #elif ROSE_ALLOC_MEMSET == 2
   74463             :         memset(pointer, 0xCC, SgLambdaCaptureList::pool_size * sizeof(SgLambdaCaptureList));
   74464             : #endif
   74465           0 :         SgLambdaCaptureList::pools.push_back( (unsigned char*)(pointer) );
   74466           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLambdaCaptureList::pool_size * sizeof(SgLambdaCaptureList), V_SgLambdaCaptureList ) );
   74467             : 
   74468           0 :         if ( SgLambdaCaptureList::next_node != NULL ) {
   74469           0 :           if ( blockIndex > 0 ) {
   74470           0 :             SgLambdaCaptureList * blkptr = (SgLambdaCaptureList*)(SgLambdaCaptureList::pools[blockIndex-1]);
   74471           0 :             blkptr[ SgLambdaCaptureList::pool_size - 1 ].set_freepointer(pointer);
   74472             :           }
   74473             :         } else {
   74474           0 :           SgLambdaCaptureList::next_node = pointer;
   74475             :         }
   74476             : 
   74477           0 :         for (unsigned i = 0; i < SgLambdaCaptureList::pool_size-1; ++i)
   74478             :            {
   74479           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   74480             :            }
   74481           0 :         pointer[ SgLambdaCaptureList::pool_size -1 ].set_freepointer(NULL);
   74482             : 
   74483           0 :         blockIndex++;
   74484             :       }
   74485           2 :   }
   74486             : 
   74487             : //############################################################################
   74488             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   74489             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   74490             :  * not compressed. However, that stuff is not yet implemented! 
   74491             :  */
   74492             : unsigned long
   74493           0 : SgLambdaCaptureList::getNumberOfLastValidPointer()
   74494             :    {
   74495           0 :       SgLambdaCaptureList* testPointer = (SgLambdaCaptureList*)(SgLambdaCaptureList::pools.back());
   74496           0 :       unsigned long localIndex = SgLambdaCaptureList::pool_size - 1;
   74497           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   74498             :          {
   74499           0 :            localIndex--;
   74500             :          }
   74501           0 :       return (localIndex + SgLambdaCaptureList::pool_size * (SgLambdaCaptureList::pools.size()-1));
   74502             :    }
   74503             : 
   74504             : //############################################################################
   74505             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   74506             :  * memory pool and initializes the data member in class SgLambdaCaptureListStroageClass
   74507             :  * from its counterpart of SgLambdaCaptureList. The return value is just for checking, 
   74508             :  * that the whole StorageClassArray is initialized!
   74509             :  */
   74510             : unsigned long
   74511           0 : SgLambdaCaptureList::initializeStorageClassArray( SgLambdaCaptureListStorageClass *storageArray )
   74512             :    {
   74513           0 :      unsigned long storageCounter = 0;
   74514           0 :      std::vector < unsigned char* > :: const_iterator block = SgLambdaCaptureList::pools.begin();
   74515           0 :      SgLambdaCaptureList* pointer = NULL;
   74516           0 :      while ( block != SgLambdaCaptureList::pools.end() ) {
   74517           0 :           pointer = (SgLambdaCaptureList*) (*block);
   74518           0 :           for ( unsigned i = 0; i < SgLambdaCaptureList::pool_size; ++i ) {
   74519           0 :                if ( pointer->get_freepointer() != NULL ) {
   74520           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   74521           0 :                  storageArray++;
   74522           0 :                  storageCounter++;
   74523             :                }
   74524           0 :                pointer++;
   74525             :              }
   74526           0 :            block++;
   74527             :         }
   74528           0 :      return storageCounter;
   74529             :    }
   74530             : 
   74531             : /* #line 74532 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   74532             : 
   74533             : 
   74534             : 
   74535             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   74536             : 
   74537             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   74538             : 
   74539             : //############################################################################
   74540             : /* JH (02/02/2006) Constructor of the IR node SgStatement that takes its 
   74541             :  * corresponding StorageClass as parameter
   74542             :  */
   74543       71100 : SgStatement :: SgStatement ( const SgStatementStorageClass& storageSource )   : SgLocatedNode (storageSource)
   74544             :    {
   74545             : 
   74546             : 
   74547             : /* #line 74548 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   74548             : 
   74549       71100 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   74550       71100 :      p_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_numeric_label) );
   74551       71100 :      p_source_sequence_value = storageSource.storageOf_source_sequence_value ;
   74552             : 
   74553             : 
   74554             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   74555             : 
   74556             : 
   74557       71100 :    }
   74558             : 
   74559             : //############################################################################
   74560             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   74561             :  * within the working AST. 
   74562             :  */
   74563           0 : SgStatement * SgStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   74564           0 :      SgStatement* returnPointer = NULL;
   74565           0 :      if ( globalIndex != 0 )
   74566             :         {
   74567             : 
   74568             : #if FILE_IO_EXTRA_CHECK
   74569           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStatement ) ) <= globalIndex ) ;
   74570           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStatement + 1 ) ) );
   74571             : #endif
   74572           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStatement )  
   74573           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStatement );
   74574           0 :           unsigned long positionInPool = localIndex % SgStatement::pool_size;
   74575           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStatement::pool_size;
   74576             : 
   74577             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   74578             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   74579             : 
   74580           0 :           returnPointer = &( ( (SgStatement*)(SgStatement::pools[memoryBlock]) ) [positionInPool]) ;
   74581             : 
   74582           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   74583             :         }
   74584           0 :      return returnPointer ;
   74585             :    }
   74586             : 
   74587             : //############################################################################
   74588             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   74589             :   for the AST with the index astIndex
   74590             : */
   74591           0 : SgStatement * SgStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   74592           0 :      SgStatement* returnPointer = NULL;
   74593           0 :      if ( globalIndex != 0 )
   74594             :         {
   74595             : 
   74596             : #if FILE_IO_EXTRA_CHECK
   74597           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStatement ) ) <= globalIndex ) ;
   74598           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStatement + 1 ) ) );
   74599             : #endif
   74600           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStatement )
   74601           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStatement );
   74602           0 :           unsigned long positionInPool = localIndex % SgStatement::pool_size ;
   74603           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStatement::pool_size ;
   74604             : 
   74605             : #if FILE_IO_EXTRA_CHECK
   74606             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   74607             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   74608             : #endif
   74609             : 
   74610           0 :           returnPointer = &( ( (SgStatement*)(SgStatement::pools[memoryBlock]) ) [positionInPool]) ;
   74611             : 
   74612             : #if FILE_IO_EXTRA_CHECK
   74613           0 :           assert ( returnPointer != NULL ) ;
   74614             : #endif
   74615             :         }
   74616           0 :      return returnPointer ;
   74617             :    }
   74618             : 
   74619             : //############################################################################
   74620             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   74621             :  * pool size! We set for every valid object in the memory pool the freepointer
   74622             :  * to the global index and increase the global index afterwards. For all the 
   74623             :  * invalid objects (means address ranges within the memory pool that were not
   74624             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   74625             :  * distinguish valid from invalid objects! 
   74626             :  */
   74627             : unsigned long
   74628           5 : SgStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   74629             :    {
   74630           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   74631           5 :      SgStatement* pointer = NULL;
   74632           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   74633           5 :      std::vector < unsigned char* > :: const_iterator block;
   74634           5 :      for ( block = SgStatement::pools.begin(); block != SgStatement::pools.end() ; ++block )
   74635             :         {
   74636           0 :           pointer = (SgStatement*)(*block);
   74637           0 :           for (unsigned i = 0; i < SgStatement::pool_size; ++i )
   74638             :              {
   74639             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   74640             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   74641             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   74642             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   74643             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   74644             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   74645             :             // properly; so this will have to be checked next.
   74646             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   74647             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   74648           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   74649             :                   {
   74650           0 :                     pointer[i].set_freepointer((SgStatement*)(globalIndex));
   74651           0 :                     globalIndex++;
   74652             :                   }
   74653             :                else
   74654             :                   {
   74655           0 :                     pointer[i].set_freepointer(NULL);
   74656             :                   }
   74657             :               }
   74658             :         }
   74659           5 :      return globalIndex;
   74660             :    }
   74661             : 
   74662             : //############################################################################
   74663             : // JH (01/14/2006)
   74664             : void
   74665           5 : SgStatement::resetValidFreepointers( )
   74666             :    {
   74667           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   74668           5 :      SgStatement* pointer = NULL;
   74669           5 :      std::vector < unsigned char* > :: const_iterator block;
   74670           5 :      SgStatement* pointerOfLinkedList = NULL;
   74671           5 :      for ( block = SgStatement::pools.begin(); block != SgStatement::pools.end() ; ++block )
   74672             :         {
   74673           0 :           pointer = (SgStatement*)(*block);
   74674           0 :           for (unsigned i = 0; i < SgStatement::pool_size; ++i )
   74675             :              {
   74676             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   74677             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   74678             :             // memory blocks!.
   74679           0 :                if ( pointer[i].get_freepointer() != NULL )
   74680             :                   {
   74681           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   74682             :                   }
   74683             :                else
   74684             :                   {
   74685           0 :                     if ( pointerOfLinkedList == NULL )
   74686             :                        {
   74687           0 :                          SgStatement::next_node = &(pointer[i]);
   74688             :                        }
   74689             :                     else
   74690             :                        {
   74691             :                       // printf ("In SgStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   74692           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   74693             :                        }
   74694             :                     pointerOfLinkedList = &(pointer[i]);
   74695             :                   }
   74696             :               }
   74697             :         }
   74698             : 
   74699           5 :      if ( pointerOfLinkedList != NULL )
   74700             :         {
   74701             :        // printf ("In SgStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   74702           0 :           pointerOfLinkedList->set_freepointer(NULL);
   74703             :        // DQ (6/6/2010): Temporary debugging...
   74704             :        //   ROSE_ASSERT(false);
   74705             :         }
   74706             : 
   74707           5 :      return ;
   74708             :    }
   74709             : 
   74710             : //############################################################################
   74711             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   74712             :  * within the memory pool and resets the freepointers, in order to achieve a 
   74713             :  * linked list, that has no jumps and starts at the beginning! This function 
   74714             :  * does not extend the memory pool, since we do not delete any memory blocks,
   74715             :  * but delete the valid objects.  
   74716             :  */
   74717             : void
   74718           0 : SgStatement::clearMemoryPool( )
   74719             :    {
   74720             :   // printf ("Inside of SgStatement::clearMemoryPool() \n");
   74721             : 
   74722           0 :      SgStatement* pointer = NULL, *tempPointer = NULL;
   74723           0 :      std::vector < unsigned char* > :: const_iterator block;
   74724           0 :      if ( SgStatement::pools.empty() == false )
   74725             :         {
   74726           0 :           block = SgStatement::pools.begin() ;
   74727           0 :           SgStatement::next_node = (SgStatement*) (*block);
   74728             : 
   74729           0 :           while ( block != SgStatement::pools.end() )
   74730             :              {
   74731           0 :                pointer = (SgStatement*) (*block);
   74732           0 :                if ( tempPointer != NULL )
   74733             :                   {
   74734           0 :                     tempPointer->set_freepointer(pointer);
   74735             :                   }
   74736           0 :                for (unsigned i = 0; i < SgStatement::pool_size - 1; ++i)
   74737             :                   {
   74738           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   74739             :                   }
   74740           0 :                 pointer[SgStatement::pool_size-1].set_freepointer(NULL);
   74741           0 :                 tempPointer = &(pointer[SgStatement::pool_size-1]);
   74742           0 :                 ++block;
   74743             :              }
   74744             :         }
   74745           0 :    }
   74746             : 
   74747           5 : void SgStatement::deleteMemoryPool() {
   74748           5 :   for (auto p: SgStatement::pools) {
   74749           0 :     ROSE_FREE(p);
   74750             :   }
   74751           5 :   SgStatement::next_node = nullptr;
   74752           5 :   SgStatement::pools.clear();
   74753           5 : }
   74754             : 
   74755             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   74756             : //                 reading multiple binary files to for a single AST.
   74757             : /////////// new version ////////////////////////////////
   74758             : //############################################################################
   74759             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   74760             : void
   74761           2 : SgStatement::extendMemoryPoolForFileIO( )
   74762             :   {
   74763           2 :     size_t blockIndex = SgStatement::pools.size();
   74764           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatement);
   74765             : 
   74766           2 :     while ( (blockIndex * SgStatement::pool_size) < newPoolSize)
   74767             :       {
   74768             : #if ROSE_ALLOC_TRACE
   74769             :         if (blockIndex > 0) {
   74770             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatement) = %" PRIuPTR " SgStatement::pool_size = %d \n",
   74771             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatement),SgStatement::pool_size);
   74772             :         }
   74773             : #endif
   74774             : 
   74775           0 :         SgStatement * pointer = (SgStatement*) ROSE_MALLOC ( SgStatement::pool_size * sizeof(SgStatement) );
   74776           0 :         assert( pointer != NULL );
   74777             : #if ROSE_ALLOC_MEMSET == 1
   74778             :         memset(pointer, 0x00, SgStatement::pool_size * sizeof(SgStatement));
   74779             : #elif ROSE_ALLOC_MEMSET == 2
   74780             :         memset(pointer, 0xCC, SgStatement::pool_size * sizeof(SgStatement));
   74781             : #endif
   74782           0 :         SgStatement::pools.push_back( (unsigned char*)(pointer) );
   74783           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStatement::pool_size * sizeof(SgStatement), V_SgStatement ) );
   74784             : 
   74785           0 :         if ( SgStatement::next_node != NULL ) {
   74786           0 :           if ( blockIndex > 0 ) {
   74787           0 :             SgStatement * blkptr = (SgStatement*)(SgStatement::pools[blockIndex-1]);
   74788           0 :             blkptr[ SgStatement::pool_size - 1 ].set_freepointer(pointer);
   74789             :           }
   74790             :         } else {
   74791           0 :           SgStatement::next_node = pointer;
   74792             :         }
   74793             : 
   74794           0 :         for (unsigned i = 0; i < SgStatement::pool_size-1; ++i)
   74795             :            {
   74796           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   74797             :            }
   74798           0 :         pointer[ SgStatement::pool_size -1 ].set_freepointer(NULL);
   74799             : 
   74800           0 :         blockIndex++;
   74801             :       }
   74802           2 :   }
   74803             : 
   74804             : //############################################################################
   74805             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   74806             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   74807             :  * not compressed. However, that stuff is not yet implemented! 
   74808             :  */
   74809             : unsigned long
   74810           0 : SgStatement::getNumberOfLastValidPointer()
   74811             :    {
   74812           0 :       SgStatement* testPointer = (SgStatement*)(SgStatement::pools.back());
   74813           0 :       unsigned long localIndex = SgStatement::pool_size - 1;
   74814           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   74815             :          {
   74816           0 :            localIndex--;
   74817             :          }
   74818           0 :       return (localIndex + SgStatement::pool_size * (SgStatement::pools.size()-1));
   74819             :    }
   74820             : 
   74821             : //############################################################################
   74822             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   74823             :  * memory pool and initializes the data member in class SgStatementStroageClass
   74824             :  * from its counterpart of SgStatement. The return value is just for checking, 
   74825             :  * that the whole StorageClassArray is initialized!
   74826             :  */
   74827             : unsigned long
   74828           0 : SgStatement::initializeStorageClassArray( SgStatementStorageClass *storageArray )
   74829             :    {
   74830           0 :      unsigned long storageCounter = 0;
   74831           0 :      std::vector < unsigned char* > :: const_iterator block = SgStatement::pools.begin();
   74832           0 :      SgStatement* pointer = NULL;
   74833           0 :      while ( block != SgStatement::pools.end() ) {
   74834           0 :           pointer = (SgStatement*) (*block);
   74835           0 :           for ( unsigned i = 0; i < SgStatement::pool_size; ++i ) {
   74836           0 :                if ( pointer->get_freepointer() != NULL ) {
   74837           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   74838           0 :                  storageArray++;
   74839           0 :                  storageCounter++;
   74840             :                }
   74841           0 :                pointer++;
   74842             :              }
   74843           0 :            block++;
   74844             :         }
   74845           0 :      return storageCounter;
   74846             :    }
   74847             : 
   74848             : /* #line 74849 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   74849             : 
   74850             : 
   74851             : 
   74852             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   74853             : 
   74854             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   74855             : 
   74856             : //############################################################################
   74857             : /* JH (02/02/2006) Constructor of the IR node SgScopeStatement that takes its 
   74858             :  * corresponding StorageClass as parameter
   74859             :  */
   74860       13448 : SgScopeStatement :: SgScopeStatement ( const SgScopeStatementStorageClass& storageSource )   : SgStatement (storageSource)
   74861             :    {
   74862             : 
   74863             : 
   74864             : /* #line 74865 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   74865             : 
   74866       13448 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   74867       13448 :      p_symbol_table =  (SgSymbolTable*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol_table) );
   74868       13448 :      p_type_table =  (SgTypeTable*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type_table) );
   74869       13448 :      p_type_elaboration_list = storageSource.storageOf_type_elaboration_list.rebuildDataStoredInEasyStorageClass() ;
   74870       13448 :      p_hidden_type_list = storageSource.storageOf_hidden_type_list.rebuildDataStoredInEasyStorageClass() ;
   74871       13448 :      p_hidden_declaration_list = storageSource.storageOf_hidden_declaration_list.rebuildDataStoredInEasyStorageClass() ;
   74872       13448 :      p_pragma =  (SgPragma*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pragma) );
   74873             : 
   74874             : 
   74875             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   74876             : 
   74877             : 
   74878       13448 :    }
   74879             : 
   74880             : //############################################################################
   74881             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   74882             :  * within the working AST. 
   74883             :  */
   74884           0 : SgScopeStatement * SgScopeStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   74885           0 :      SgScopeStatement* returnPointer = NULL;
   74886           0 :      if ( globalIndex != 0 )
   74887             :         {
   74888             : 
   74889             : #if FILE_IO_EXTRA_CHECK
   74890           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgScopeStatement ) ) <= globalIndex ) ;
   74891           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgScopeStatement + 1 ) ) );
   74892             : #endif
   74893           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgScopeStatement )  
   74894           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgScopeStatement );
   74895           0 :           unsigned long positionInPool = localIndex % SgScopeStatement::pool_size;
   74896           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgScopeStatement::pool_size;
   74897             : 
   74898             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   74899             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   74900             : 
   74901           0 :           returnPointer = &( ( (SgScopeStatement*)(SgScopeStatement::pools[memoryBlock]) ) [positionInPool]) ;
   74902             : 
   74903           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   74904             :         }
   74905           0 :      return returnPointer ;
   74906             :    }
   74907             : 
   74908             : //############################################################################
   74909             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   74910             :   for the AST with the index astIndex
   74911             : */
   74912           0 : SgScopeStatement * SgScopeStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   74913           0 :      SgScopeStatement* returnPointer = NULL;
   74914           0 :      if ( globalIndex != 0 )
   74915             :         {
   74916             : 
   74917             : #if FILE_IO_EXTRA_CHECK
   74918           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgScopeStatement ) ) <= globalIndex ) ;
   74919           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgScopeStatement + 1 ) ) );
   74920             : #endif
   74921           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgScopeStatement )
   74922           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgScopeStatement );
   74923           0 :           unsigned long positionInPool = localIndex % SgScopeStatement::pool_size ;
   74924           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgScopeStatement::pool_size ;
   74925             : 
   74926             : #if FILE_IO_EXTRA_CHECK
   74927             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   74928             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   74929             : #endif
   74930             : 
   74931           0 :           returnPointer = &( ( (SgScopeStatement*)(SgScopeStatement::pools[memoryBlock]) ) [positionInPool]) ;
   74932             : 
   74933             : #if FILE_IO_EXTRA_CHECK
   74934           0 :           assert ( returnPointer != NULL ) ;
   74935             : #endif
   74936             :         }
   74937           0 :      return returnPointer ;
   74938             :    }
   74939             : 
   74940             : //############################################################################
   74941             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   74942             :  * pool size! We set for every valid object in the memory pool the freepointer
   74943             :  * to the global index and increase the global index afterwards. For all the 
   74944             :  * invalid objects (means address ranges within the memory pool that were not
   74945             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   74946             :  * distinguish valid from invalid objects! 
   74947             :  */
   74948             : unsigned long
   74949           5 : SgScopeStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   74950             :    {
   74951           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   74952           5 :      SgScopeStatement* pointer = NULL;
   74953           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   74954           5 :      std::vector < unsigned char* > :: const_iterator block;
   74955           5 :      for ( block = SgScopeStatement::pools.begin(); block != SgScopeStatement::pools.end() ; ++block )
   74956             :         {
   74957           0 :           pointer = (SgScopeStatement*)(*block);
   74958           0 :           for (unsigned i = 0; i < SgScopeStatement::pool_size; ++i )
   74959             :              {
   74960             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   74961             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   74962             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   74963             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   74964             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   74965             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   74966             :             // properly; so this will have to be checked next.
   74967             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   74968             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   74969           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   74970             :                   {
   74971           0 :                     pointer[i].set_freepointer((SgScopeStatement*)(globalIndex));
   74972           0 :                     globalIndex++;
   74973             :                   }
   74974             :                else
   74975             :                   {
   74976           0 :                     pointer[i].set_freepointer(NULL);
   74977             :                   }
   74978             :               }
   74979             :         }
   74980           5 :      return globalIndex;
   74981             :    }
   74982             : 
   74983             : //############################################################################
   74984             : // JH (01/14/2006)
   74985             : void
   74986           5 : SgScopeStatement::resetValidFreepointers( )
   74987             :    {
   74988           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   74989           5 :      SgScopeStatement* pointer = NULL;
   74990           5 :      std::vector < unsigned char* > :: const_iterator block;
   74991           5 :      SgScopeStatement* pointerOfLinkedList = NULL;
   74992           5 :      for ( block = SgScopeStatement::pools.begin(); block != SgScopeStatement::pools.end() ; ++block )
   74993             :         {
   74994           0 :           pointer = (SgScopeStatement*)(*block);
   74995           0 :           for (unsigned i = 0; i < SgScopeStatement::pool_size; ++i )
   74996             :              {
   74997             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   74998             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   74999             :             // memory blocks!.
   75000           0 :                if ( pointer[i].get_freepointer() != NULL )
   75001             :                   {
   75002           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   75003             :                   }
   75004             :                else
   75005             :                   {
   75006           0 :                     if ( pointerOfLinkedList == NULL )
   75007             :                        {
   75008           0 :                          SgScopeStatement::next_node = &(pointer[i]);
   75009             :                        }
   75010             :                     else
   75011             :                        {
   75012             :                       // printf ("In SgScopeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   75013           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   75014             :                        }
   75015             :                     pointerOfLinkedList = &(pointer[i]);
   75016             :                   }
   75017             :               }
   75018             :         }
   75019             : 
   75020           5 :      if ( pointerOfLinkedList != NULL )
   75021             :         {
   75022             :        // printf ("In SgScopeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   75023           0 :           pointerOfLinkedList->set_freepointer(NULL);
   75024             :        // DQ (6/6/2010): Temporary debugging...
   75025             :        //   ROSE_ASSERT(false);
   75026             :         }
   75027             : 
   75028           5 :      return ;
   75029             :    }
   75030             : 
   75031             : //############################################################################
   75032             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   75033             :  * within the memory pool and resets the freepointers, in order to achieve a 
   75034             :  * linked list, that has no jumps and starts at the beginning! This function 
   75035             :  * does not extend the memory pool, since we do not delete any memory blocks,
   75036             :  * but delete the valid objects.  
   75037             :  */
   75038             : void
   75039           0 : SgScopeStatement::clearMemoryPool( )
   75040             :    {
   75041             :   // printf ("Inside of SgScopeStatement::clearMemoryPool() \n");
   75042             : 
   75043           0 :      SgScopeStatement* pointer = NULL, *tempPointer = NULL;
   75044           0 :      std::vector < unsigned char* > :: const_iterator block;
   75045           0 :      if ( SgScopeStatement::pools.empty() == false )
   75046             :         {
   75047           0 :           block = SgScopeStatement::pools.begin() ;
   75048           0 :           SgScopeStatement::next_node = (SgScopeStatement*) (*block);
   75049             : 
   75050           0 :           while ( block != SgScopeStatement::pools.end() )
   75051             :              {
   75052           0 :                pointer = (SgScopeStatement*) (*block);
   75053           0 :                if ( tempPointer != NULL )
   75054             :                   {
   75055           0 :                     tempPointer->set_freepointer(pointer);
   75056             :                   }
   75057           0 :                for (unsigned i = 0; i < SgScopeStatement::pool_size - 1; ++i)
   75058             :                   {
   75059           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   75060             :                   }
   75061           0 :                 pointer[SgScopeStatement::pool_size-1].set_freepointer(NULL);
   75062           0 :                 tempPointer = &(pointer[SgScopeStatement::pool_size-1]);
   75063           0 :                 ++block;
   75064             :              }
   75065             :         }
   75066           0 :    }
   75067             : 
   75068           5 : void SgScopeStatement::deleteMemoryPool() {
   75069           5 :   for (auto p: SgScopeStatement::pools) {
   75070           0 :     ROSE_FREE(p);
   75071             :   }
   75072           5 :   SgScopeStatement::next_node = nullptr;
   75073           5 :   SgScopeStatement::pools.clear();
   75074           5 : }
   75075             : 
   75076             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   75077             : //                 reading multiple binary files to for a single AST.
   75078             : /////////// new version ////////////////////////////////
   75079             : //############################################################################
   75080             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   75081             : void
   75082           2 : SgScopeStatement::extendMemoryPoolForFileIO( )
   75083             :   {
   75084           2 :     size_t blockIndex = SgScopeStatement::pools.size();
   75085           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgScopeStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgScopeStatement);
   75086             : 
   75087           2 :     while ( (blockIndex * SgScopeStatement::pool_size) < newPoolSize)
   75088             :       {
   75089             : #if ROSE_ALLOC_TRACE
   75090             :         if (blockIndex > 0) {
   75091             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgScopeStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgScopeStatement) = %" PRIuPTR " SgScopeStatement::pool_size = %d \n",
   75092             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgScopeStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgScopeStatement),SgScopeStatement::pool_size);
   75093             :         }
   75094             : #endif
   75095             : 
   75096           0 :         SgScopeStatement * pointer = (SgScopeStatement*) ROSE_MALLOC ( SgScopeStatement::pool_size * sizeof(SgScopeStatement) );
   75097           0 :         assert( pointer != NULL );
   75098             : #if ROSE_ALLOC_MEMSET == 1
   75099             :         memset(pointer, 0x00, SgScopeStatement::pool_size * sizeof(SgScopeStatement));
   75100             : #elif ROSE_ALLOC_MEMSET == 2
   75101             :         memset(pointer, 0xCC, SgScopeStatement::pool_size * sizeof(SgScopeStatement));
   75102             : #endif
   75103           0 :         SgScopeStatement::pools.push_back( (unsigned char*)(pointer) );
   75104           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgScopeStatement::pool_size * sizeof(SgScopeStatement), V_SgScopeStatement ) );
   75105             : 
   75106           0 :         if ( SgScopeStatement::next_node != NULL ) {
   75107           0 :           if ( blockIndex > 0 ) {
   75108           0 :             SgScopeStatement * blkptr = (SgScopeStatement*)(SgScopeStatement::pools[blockIndex-1]);
   75109           0 :             blkptr[ SgScopeStatement::pool_size - 1 ].set_freepointer(pointer);
   75110             :           }
   75111             :         } else {
   75112           0 :           SgScopeStatement::next_node = pointer;
   75113             :         }
   75114             : 
   75115           0 :         for (unsigned i = 0; i < SgScopeStatement::pool_size-1; ++i)
   75116             :            {
   75117           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   75118             :            }
   75119           0 :         pointer[ SgScopeStatement::pool_size -1 ].set_freepointer(NULL);
   75120             : 
   75121           0 :         blockIndex++;
   75122             :       }
   75123           2 :   }
   75124             : 
   75125             : //############################################################################
   75126             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   75127             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   75128             :  * not compressed. However, that stuff is not yet implemented! 
   75129             :  */
   75130             : unsigned long
   75131           0 : SgScopeStatement::getNumberOfLastValidPointer()
   75132             :    {
   75133           0 :       SgScopeStatement* testPointer = (SgScopeStatement*)(SgScopeStatement::pools.back());
   75134           0 :       unsigned long localIndex = SgScopeStatement::pool_size - 1;
   75135           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   75136             :          {
   75137           0 :            localIndex--;
   75138             :          }
   75139           0 :       return (localIndex + SgScopeStatement::pool_size * (SgScopeStatement::pools.size()-1));
   75140             :    }
   75141             : 
   75142             : //############################################################################
   75143             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   75144             :  * memory pool and initializes the data member in class SgScopeStatementStroageClass
   75145             :  * from its counterpart of SgScopeStatement. The return value is just for checking, 
   75146             :  * that the whole StorageClassArray is initialized!
   75147             :  */
   75148             : unsigned long
   75149           0 : SgScopeStatement::initializeStorageClassArray( SgScopeStatementStorageClass *storageArray )
   75150             :    {
   75151           0 :      unsigned long storageCounter = 0;
   75152           0 :      std::vector < unsigned char* > :: const_iterator block = SgScopeStatement::pools.begin();
   75153           0 :      SgScopeStatement* pointer = NULL;
   75154           0 :      while ( block != SgScopeStatement::pools.end() ) {
   75155           0 :           pointer = (SgScopeStatement*) (*block);
   75156           0 :           for ( unsigned i = 0; i < SgScopeStatement::pool_size; ++i ) {
   75157           0 :                if ( pointer->get_freepointer() != NULL ) {
   75158           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   75159           0 :                  storageArray++;
   75160           0 :                  storageCounter++;
   75161             :                }
   75162           0 :                pointer++;
   75163             :              }
   75164           0 :            block++;
   75165             :         }
   75166           0 :      return storageCounter;
   75167             :    }
   75168             : 
   75169             : /* #line 75170 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   75170             : 
   75171             : 
   75172             : 
   75173             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   75174             : 
   75175             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   75176             : 
   75177             : //############################################################################
   75178             : /* JH (02/02/2006) Constructor of the IR node SgGlobal that takes its 
   75179             :  * corresponding StorageClass as parameter
   75180             :  */
   75181           4 : SgGlobal :: SgGlobal ( const SgGlobalStorageClass& storageSource )   : SgScopeStatement (storageSource)
   75182             :    {
   75183             : 
   75184             : 
   75185             : /* #line 75186 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   75186             : 
   75187           4 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   75188           4 :      p_declarations = storageSource.storageOf_declarations.rebuildDataStoredInEasyStorageClass() ;
   75189           4 :      SgDeclarationStatementPtrList::iterator i_declarations = p_declarations.begin() ; 
   75190        9175 :      for ( ; i_declarations != p_declarations.end(); ++i_declarations ) 
   75191             :         {
   75192        9171 :           (*i_declarations) = (SgDeclarationStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_declarations) ) );
   75193             :         }
   75194             : 
   75195             : 
   75196             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   75197             : 
   75198             : 
   75199           4 :    }
   75200             : 
   75201             : //############################################################################
   75202             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   75203             :  * within the working AST. 
   75204             :  */
   75205       59049 : SgGlobal * SgGlobal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   75206       59049 :      SgGlobal* returnPointer = NULL;
   75207       59049 :      if ( globalIndex != 0 )
   75208             :         {
   75209             : 
   75210             : #if FILE_IO_EXTRA_CHECK
   75211       59049 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGlobal ) ) <= globalIndex ) ;
   75212       59049 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGlobal + 1 ) ) );
   75213             : #endif
   75214       59049 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGlobal )  
   75215       59049 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGlobal );
   75216       59049 :           unsigned long positionInPool = localIndex % SgGlobal::pool_size;
   75217       59049 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGlobal::pool_size;
   75218             : 
   75219             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   75220             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   75221             : 
   75222       59049 :           returnPointer = &( ( (SgGlobal*)(SgGlobal::pools[memoryBlock]) ) [positionInPool]) ;
   75223             : 
   75224       59049 :           ROSE_ASSERT( returnPointer != NULL ) ;
   75225             :         }
   75226       59049 :      return returnPointer ;
   75227             :    }
   75228             : 
   75229             : //############################################################################
   75230             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   75231             :   for the AST with the index astIndex
   75232             : */
   75233           0 : SgGlobal * SgGlobal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   75234           0 :      SgGlobal* returnPointer = NULL;
   75235           0 :      if ( globalIndex != 0 )
   75236             :         {
   75237             : 
   75238             : #if FILE_IO_EXTRA_CHECK
   75239           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGlobal ) ) <= globalIndex ) ;
   75240           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGlobal + 1 ) ) );
   75241             : #endif
   75242           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGlobal )
   75243           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGlobal );
   75244           0 :           unsigned long positionInPool = localIndex % SgGlobal::pool_size ;
   75245           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGlobal::pool_size ;
   75246             : 
   75247             : #if FILE_IO_EXTRA_CHECK
   75248             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   75249             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   75250             : #endif
   75251             : 
   75252           0 :           returnPointer = &( ( (SgGlobal*)(SgGlobal::pools[memoryBlock]) ) [positionInPool]) ;
   75253             : 
   75254             : #if FILE_IO_EXTRA_CHECK
   75255           0 :           assert ( returnPointer != NULL ) ;
   75256             : #endif
   75257             :         }
   75258           0 :      return returnPointer ;
   75259             :    }
   75260             : 
   75261             : //############################################################################
   75262             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   75263             :  * pool size! We set for every valid object in the memory pool the freepointer
   75264             :  * to the global index and increase the global index afterwards. For all the 
   75265             :  * invalid objects (means address ranges within the memory pool that were not
   75266             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   75267             :  * distinguish valid from invalid objects! 
   75268             :  */
   75269             : unsigned long
   75270           5 : SgGlobal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   75271             :    {
   75272           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   75273           5 :      SgGlobal* pointer = NULL;
   75274           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   75275           5 :      std::vector < unsigned char* > :: const_iterator block;
   75276          10 :      for ( block = SgGlobal::pools.begin(); block != SgGlobal::pools.end() ; ++block )
   75277             :         {
   75278           5 :           pointer = (SgGlobal*)(*block);
   75279       10005 :           for (unsigned i = 0; i < SgGlobal::pool_size; ++i )
   75280             :              {
   75281             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   75282             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   75283             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   75284             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   75285             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   75286             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   75287             :             // properly; so this will have to be checked next.
   75288             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   75289             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   75290       10000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   75291             :                   {
   75292           8 :                     pointer[i].set_freepointer((SgGlobal*)(globalIndex));
   75293           8 :                     globalIndex++;
   75294             :                   }
   75295             :                else
   75296             :                   {
   75297        9992 :                     pointer[i].set_freepointer(NULL);
   75298             :                   }
   75299             :               }
   75300             :         }
   75301           5 :      return globalIndex;
   75302             :    }
   75303             : 
   75304             : //############################################################################
   75305             : // JH (01/14/2006)
   75306             : void
   75307           5 : SgGlobal::resetValidFreepointers( )
   75308             :    {
   75309           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   75310           5 :      SgGlobal* pointer = NULL;
   75311           5 :      std::vector < unsigned char* > :: const_iterator block;
   75312           5 :      SgGlobal* pointerOfLinkedList = NULL;
   75313          10 :      for ( block = SgGlobal::pools.begin(); block != SgGlobal::pools.end() ; ++block )
   75314             :         {
   75315           5 :           pointer = (SgGlobal*)(*block);
   75316       10005 :           for (unsigned i = 0; i < SgGlobal::pool_size; ++i )
   75317             :              {
   75318             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   75319             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   75320             :             // memory blocks!.
   75321       10000 :                if ( pointer[i].get_freepointer() != NULL )
   75322             :                   {
   75323           8 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   75324             :                   }
   75325             :                else
   75326             :                   {
   75327        9992 :                     if ( pointerOfLinkedList == NULL )
   75328             :                        {
   75329           5 :                          SgGlobal::next_node = &(pointer[i]);
   75330             :                        }
   75331             :                     else
   75332             :                        {
   75333             :                       // printf ("In SgGlobal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   75334        9987 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   75335             :                        }
   75336             :                     pointerOfLinkedList = &(pointer[i]);
   75337             :                   }
   75338             :               }
   75339             :         }
   75340             : 
   75341           5 :      if ( pointerOfLinkedList != NULL )
   75342             :         {
   75343             :        // printf ("In SgGlobal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   75344           5 :           pointerOfLinkedList->set_freepointer(NULL);
   75345             :        // DQ (6/6/2010): Temporary debugging...
   75346             :        //   ROSE_ASSERT(false);
   75347             :         }
   75348             : 
   75349           5 :      return ;
   75350             :    }
   75351             : 
   75352             : //############################################################################
   75353             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   75354             :  * within the memory pool and resets the freepointers, in order to achieve a 
   75355             :  * linked list, that has no jumps and starts at the beginning! This function 
   75356             :  * does not extend the memory pool, since we do not delete any memory blocks,
   75357             :  * but delete the valid objects.  
   75358             :  */
   75359             : void
   75360           0 : SgGlobal::clearMemoryPool( )
   75361             :    {
   75362             :   // printf ("Inside of SgGlobal::clearMemoryPool() \n");
   75363             : 
   75364           0 :      SgGlobal* pointer = NULL, *tempPointer = NULL;
   75365           0 :      std::vector < unsigned char* > :: const_iterator block;
   75366           0 :      if ( SgGlobal::pools.empty() == false )
   75367             :         {
   75368           0 :           block = SgGlobal::pools.begin() ;
   75369           0 :           SgGlobal::next_node = (SgGlobal*) (*block);
   75370             : 
   75371           0 :           while ( block != SgGlobal::pools.end() )
   75372             :              {
   75373           0 :                pointer = (SgGlobal*) (*block);
   75374           0 :                if ( tempPointer != NULL )
   75375             :                   {
   75376           0 :                     tempPointer->set_freepointer(pointer);
   75377             :                   }
   75378           0 :                for (unsigned i = 0; i < SgGlobal::pool_size - 1; ++i)
   75379             :                   {
   75380           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   75381             :                   }
   75382           0 :                 pointer[SgGlobal::pool_size-1].set_freepointer(NULL);
   75383           0 :                 tempPointer = &(pointer[SgGlobal::pool_size-1]);
   75384           0 :                 ++block;
   75385             :              }
   75386             :         }
   75387           0 :    }
   75388             : 
   75389           5 : void SgGlobal::deleteMemoryPool() {
   75390          10 :   for (auto p: SgGlobal::pools) {
   75391           5 :     ROSE_FREE(p);
   75392             :   }
   75393           5 :   SgGlobal::next_node = nullptr;
   75394           5 :   SgGlobal::pools.clear();
   75395           5 : }
   75396             : 
   75397             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   75398             : //                 reading multiple binary files to for a single AST.
   75399             : /////////// new version ////////////////////////////////
   75400             : //############################################################################
   75401             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   75402             : void
   75403           2 : SgGlobal::extendMemoryPoolForFileIO( )
   75404             :   {
   75405           2 :     size_t blockIndex = SgGlobal::pools.size();
   75406           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGlobal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGlobal);
   75407             : 
   75408           2 :     while ( (blockIndex * SgGlobal::pool_size) < newPoolSize)
   75409             :       {
   75410             : #if ROSE_ALLOC_TRACE
   75411             :         if (blockIndex > 0) {
   75412             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGlobal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGlobal) = %" PRIuPTR " SgGlobal::pool_size = %d \n",
   75413             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGlobal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGlobal),SgGlobal::pool_size);
   75414             :         }
   75415             : #endif
   75416             : 
   75417           0 :         SgGlobal * pointer = (SgGlobal*) ROSE_MALLOC ( SgGlobal::pool_size * sizeof(SgGlobal) );
   75418           0 :         assert( pointer != NULL );
   75419             : #if ROSE_ALLOC_MEMSET == 1
   75420             :         memset(pointer, 0x00, SgGlobal::pool_size * sizeof(SgGlobal));
   75421             : #elif ROSE_ALLOC_MEMSET == 2
   75422             :         memset(pointer, 0xCC, SgGlobal::pool_size * sizeof(SgGlobal));
   75423             : #endif
   75424           0 :         SgGlobal::pools.push_back( (unsigned char*)(pointer) );
   75425           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGlobal::pool_size * sizeof(SgGlobal), V_SgGlobal ) );
   75426             : 
   75427           0 :         if ( SgGlobal::next_node != NULL ) {
   75428           0 :           if ( blockIndex > 0 ) {
   75429           0 :             SgGlobal * blkptr = (SgGlobal*)(SgGlobal::pools[blockIndex-1]);
   75430           0 :             blkptr[ SgGlobal::pool_size - 1 ].set_freepointer(pointer);
   75431             :           }
   75432             :         } else {
   75433           0 :           SgGlobal::next_node = pointer;
   75434             :         }
   75435             : 
   75436           0 :         for (unsigned i = 0; i < SgGlobal::pool_size-1; ++i)
   75437             :            {
   75438           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   75439             :            }
   75440           0 :         pointer[ SgGlobal::pool_size -1 ].set_freepointer(NULL);
   75441             : 
   75442           0 :         blockIndex++;
   75443             :       }
   75444           2 :   }
   75445             : 
   75446             : //############################################################################
   75447             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   75448             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   75449             :  * not compressed. However, that stuff is not yet implemented! 
   75450             :  */
   75451             : unsigned long
   75452           0 : SgGlobal::getNumberOfLastValidPointer()
   75453             :    {
   75454           0 :       SgGlobal* testPointer = (SgGlobal*)(SgGlobal::pools.back());
   75455           0 :       unsigned long localIndex = SgGlobal::pool_size - 1;
   75456           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   75457             :          {
   75458           0 :            localIndex--;
   75459             :          }
   75460           0 :       return (localIndex + SgGlobal::pool_size * (SgGlobal::pools.size()-1));
   75461             :    }
   75462             : 
   75463             : //############################################################################
   75464             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   75465             :  * memory pool and initializes the data member in class SgGlobalStroageClass
   75466             :  * from its counterpart of SgGlobal. The return value is just for checking, 
   75467             :  * that the whole StorageClassArray is initialized!
   75468             :  */
   75469             : unsigned long
   75470           3 : SgGlobal::initializeStorageClassArray( SgGlobalStorageClass *storageArray )
   75471             :    {
   75472           3 :      unsigned long storageCounter = 0;
   75473           3 :      std::vector < unsigned char* > :: const_iterator block = SgGlobal::pools.begin();
   75474           3 :      SgGlobal* pointer = NULL;
   75475           6 :      while ( block != SgGlobal::pools.end() ) {
   75476           3 :           pointer = (SgGlobal*) (*block);
   75477        6003 :           for ( unsigned i = 0; i < SgGlobal::pool_size; ++i ) {
   75478        6000 :                if ( pointer->get_freepointer() != NULL ) {
   75479           6 :                  storageArray->pickOutIRNodeData (pointer) ;
   75480           6 :                  storageArray++;
   75481           6 :                  storageCounter++;
   75482             :                }
   75483        6000 :                pointer++;
   75484             :              }
   75485           3 :            block++;
   75486             :         }
   75487           3 :      return storageCounter;
   75488             :    }
   75489             : 
   75490             : /* #line 75491 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   75491             : 
   75492             : 
   75493             : 
   75494             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   75495             : 
   75496             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   75497             : 
   75498             : //############################################################################
   75499             : /* JH (02/02/2006) Constructor of the IR node SgBasicBlock that takes its 
   75500             :  * corresponding StorageClass as parameter
   75501             :  */
   75502        2865 : SgBasicBlock :: SgBasicBlock ( const SgBasicBlockStorageClass& storageSource )   : SgScopeStatement (storageSource)
   75503             :    {
   75504             : 
   75505             : 
   75506             : /* #line 75507 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   75507             : 
   75508        2865 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   75509        2865 :      p_statements = storageSource.storageOf_statements.rebuildDataStoredInEasyStorageClass() ;
   75510        2865 :      SgStatementPtrList::iterator i_statements = p_statements.begin() ; 
   75511        7262 :      for ( ; i_statements != p_statements.end(); ++i_statements ) 
   75512             :         {
   75513        4397 :           (*i_statements) = (SgStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_statements) ) );
   75514             :         }
   75515        2865 :      p_asm_function_body = storageSource.storageOf_asm_function_body.rebuildDataStoredInEasyStorageClass() ;
   75516        2865 :      p_string_label = storageSource.storageOf_string_label.rebuildDataStoredInEasyStorageClass() ;
   75517             : 
   75518             : 
   75519             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   75520             : 
   75521             : 
   75522        2865 :    }
   75523             : 
   75524             : //############################################################################
   75525             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   75526             :  * within the working AST. 
   75527             :  */
   75528       18453 : SgBasicBlock * SgBasicBlock::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   75529       18453 :      SgBasicBlock* returnPointer = NULL;
   75530       18453 :      if ( globalIndex != 0 )
   75531             :         {
   75532             : 
   75533             : #if FILE_IO_EXTRA_CHECK
   75534       18453 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBasicBlock ) ) <= globalIndex ) ;
   75535       18453 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBasicBlock + 1 ) ) );
   75536             : #endif
   75537       18453 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBasicBlock )  
   75538       18453 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBasicBlock );
   75539       18453 :           unsigned long positionInPool = localIndex % SgBasicBlock::pool_size;
   75540       18453 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBasicBlock::pool_size;
   75541             : 
   75542             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   75543             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   75544             : 
   75545       18453 :           returnPointer = &( ( (SgBasicBlock*)(SgBasicBlock::pools[memoryBlock]) ) [positionInPool]) ;
   75546             : 
   75547       18453 :           ROSE_ASSERT( returnPointer != NULL ) ;
   75548             :         }
   75549       18453 :      return returnPointer ;
   75550             :    }
   75551             : 
   75552             : //############################################################################
   75553             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   75554             :   for the AST with the index astIndex
   75555             : */
   75556           0 : SgBasicBlock * SgBasicBlock::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   75557           0 :      SgBasicBlock* returnPointer = NULL;
   75558           0 :      if ( globalIndex != 0 )
   75559             :         {
   75560             : 
   75561             : #if FILE_IO_EXTRA_CHECK
   75562           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBasicBlock ) ) <= globalIndex ) ;
   75563           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBasicBlock + 1 ) ) );
   75564             : #endif
   75565           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBasicBlock )
   75566           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBasicBlock );
   75567           0 :           unsigned long positionInPool = localIndex % SgBasicBlock::pool_size ;
   75568           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBasicBlock::pool_size ;
   75569             : 
   75570             : #if FILE_IO_EXTRA_CHECK
   75571             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   75572             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   75573             : #endif
   75574             : 
   75575           0 :           returnPointer = &( ( (SgBasicBlock*)(SgBasicBlock::pools[memoryBlock]) ) [positionInPool]) ;
   75576             : 
   75577             : #if FILE_IO_EXTRA_CHECK
   75578           0 :           assert ( returnPointer != NULL ) ;
   75579             : #endif
   75580             :         }
   75581           0 :      return returnPointer ;
   75582             :    }
   75583             : 
   75584             : //############################################################################
   75585             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   75586             :  * pool size! We set for every valid object in the memory pool the freepointer
   75587             :  * to the global index and increase the global index afterwards. For all the 
   75588             :  * invalid objects (means address ranges within the memory pool that were not
   75589             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   75590             :  * distinguish valid from invalid objects! 
   75591             :  */
   75592             : unsigned long
   75593           5 : SgBasicBlock::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   75594             :    {
   75595           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   75596           5 :      SgBasicBlock* pointer = NULL;
   75597           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   75598           5 :      std::vector < unsigned char* > :: const_iterator block;
   75599           9 :      for ( block = SgBasicBlock::pools.begin(); block != SgBasicBlock::pools.end() ; ++block )
   75600             :         {
   75601           4 :           pointer = (SgBasicBlock*)(*block);
   75602        8004 :           for (unsigned i = 0; i < SgBasicBlock::pool_size; ++i )
   75603             :              {
   75604             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   75605             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   75606             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   75607             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   75608             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   75609             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   75610             :             // properly; so this will have to be checked next.
   75611             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   75612             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   75613        8000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   75614             :                   {
   75615        2866 :                     pointer[i].set_freepointer((SgBasicBlock*)(globalIndex));
   75616        2866 :                     globalIndex++;
   75617             :                   }
   75618             :                else
   75619             :                   {
   75620        5134 :                     pointer[i].set_freepointer(NULL);
   75621             :                   }
   75622             :               }
   75623             :         }
   75624           5 :      return globalIndex;
   75625             :    }
   75626             : 
   75627             : //############################################################################
   75628             : // JH (01/14/2006)
   75629             : void
   75630           5 : SgBasicBlock::resetValidFreepointers( )
   75631             :    {
   75632           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   75633           5 :      SgBasicBlock* pointer = NULL;
   75634           5 :      std::vector < unsigned char* > :: const_iterator block;
   75635           5 :      SgBasicBlock* pointerOfLinkedList = NULL;
   75636           9 :      for ( block = SgBasicBlock::pools.begin(); block != SgBasicBlock::pools.end() ; ++block )
   75637             :         {
   75638           4 :           pointer = (SgBasicBlock*)(*block);
   75639        8004 :           for (unsigned i = 0; i < SgBasicBlock::pool_size; ++i )
   75640             :              {
   75641             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   75642             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   75643             :             // memory blocks!.
   75644        8000 :                if ( pointer[i].get_freepointer() != NULL )
   75645             :                   {
   75646        2866 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   75647             :                   }
   75648             :                else
   75649             :                   {
   75650        5134 :                     if ( pointerOfLinkedList == NULL )
   75651             :                        {
   75652           3 :                          SgBasicBlock::next_node = &(pointer[i]);
   75653             :                        }
   75654             :                     else
   75655             :                        {
   75656             :                       // printf ("In SgBasicBlock::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   75657        5131 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   75658             :                        }
   75659             :                     pointerOfLinkedList = &(pointer[i]);
   75660             :                   }
   75661             :               }
   75662             :         }
   75663             : 
   75664           5 :      if ( pointerOfLinkedList != NULL )
   75665             :         {
   75666             :        // printf ("In SgBasicBlock::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   75667           3 :           pointerOfLinkedList->set_freepointer(NULL);
   75668             :        // DQ (6/6/2010): Temporary debugging...
   75669             :        //   ROSE_ASSERT(false);
   75670             :         }
   75671             : 
   75672           5 :      return ;
   75673             :    }
   75674             : 
   75675             : //############################################################################
   75676             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   75677             :  * within the memory pool and resets the freepointers, in order to achieve a 
   75678             :  * linked list, that has no jumps and starts at the beginning! This function 
   75679             :  * does not extend the memory pool, since we do not delete any memory blocks,
   75680             :  * but delete the valid objects.  
   75681             :  */
   75682             : void
   75683           0 : SgBasicBlock::clearMemoryPool( )
   75684             :    {
   75685             :   // printf ("Inside of SgBasicBlock::clearMemoryPool() \n");
   75686             : 
   75687           0 :      SgBasicBlock* pointer = NULL, *tempPointer = NULL;
   75688           0 :      std::vector < unsigned char* > :: const_iterator block;
   75689           0 :      if ( SgBasicBlock::pools.empty() == false )
   75690             :         {
   75691           0 :           block = SgBasicBlock::pools.begin() ;
   75692           0 :           SgBasicBlock::next_node = (SgBasicBlock*) (*block);
   75693             : 
   75694           0 :           while ( block != SgBasicBlock::pools.end() )
   75695             :              {
   75696           0 :                pointer = (SgBasicBlock*) (*block);
   75697           0 :                if ( tempPointer != NULL )
   75698             :                   {
   75699           0 :                     tempPointer->set_freepointer(pointer);
   75700             :                   }
   75701           0 :                for (unsigned i = 0; i < SgBasicBlock::pool_size - 1; ++i)
   75702             :                   {
   75703           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   75704             :                   }
   75705           0 :                 pointer[SgBasicBlock::pool_size-1].set_freepointer(NULL);
   75706           0 :                 tempPointer = &(pointer[SgBasicBlock::pool_size-1]);
   75707           0 :                 ++block;
   75708             :              }
   75709             :         }
   75710           0 :    }
   75711             : 
   75712           5 : void SgBasicBlock::deleteMemoryPool() {
   75713          12 :   for (auto p: SgBasicBlock::pools) {
   75714           7 :     ROSE_FREE(p);
   75715             :   }
   75716           5 :   SgBasicBlock::next_node = nullptr;
   75717           5 :   SgBasicBlock::pools.clear();
   75718           5 : }
   75719             : 
   75720             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   75721             : //                 reading multiple binary files to for a single AST.
   75722             : /////////// new version ////////////////////////////////
   75723             : //############################################################################
   75724             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   75725             : void
   75726           2 : SgBasicBlock::extendMemoryPoolForFileIO( )
   75727             :   {
   75728           2 :     size_t blockIndex = SgBasicBlock::pools.size();
   75729           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBasicBlock) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBasicBlock);
   75730             : 
   75731           5 :     while ( (blockIndex * SgBasicBlock::pool_size) < newPoolSize)
   75732             :       {
   75733             : #if ROSE_ALLOC_TRACE
   75734             :         if (blockIndex > 0) {
   75735             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBasicBlock) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBasicBlock) = %" PRIuPTR " SgBasicBlock::pool_size = %d \n",
   75736             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBasicBlock),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBasicBlock),SgBasicBlock::pool_size);
   75737             :         }
   75738             : #endif
   75739             : 
   75740           3 :         SgBasicBlock * pointer = (SgBasicBlock*) ROSE_MALLOC ( SgBasicBlock::pool_size * sizeof(SgBasicBlock) );
   75741           3 :         assert( pointer != NULL );
   75742             : #if ROSE_ALLOC_MEMSET == 1
   75743             :         memset(pointer, 0x00, SgBasicBlock::pool_size * sizeof(SgBasicBlock));
   75744             : #elif ROSE_ALLOC_MEMSET == 2
   75745             :         memset(pointer, 0xCC, SgBasicBlock::pool_size * sizeof(SgBasicBlock));
   75746             : #endif
   75747           3 :         SgBasicBlock::pools.push_back( (unsigned char*)(pointer) );
   75748           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBasicBlock::pool_size * sizeof(SgBasicBlock), V_SgBasicBlock ) );
   75749             : 
   75750           3 :         if ( SgBasicBlock::next_node != NULL ) {
   75751           1 :           if ( blockIndex > 0 ) {
   75752           1 :             SgBasicBlock * blkptr = (SgBasicBlock*)(SgBasicBlock::pools[blockIndex-1]);
   75753           1 :             blkptr[ SgBasicBlock::pool_size - 1 ].set_freepointer(pointer);
   75754             :           }
   75755             :         } else {
   75756           2 :           SgBasicBlock::next_node = pointer;
   75757             :         }
   75758             : 
   75759        6000 :         for (unsigned i = 0; i < SgBasicBlock::pool_size-1; ++i)
   75760             :            {
   75761        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   75762             :            }
   75763           3 :         pointer[ SgBasicBlock::pool_size -1 ].set_freepointer(NULL);
   75764             : 
   75765           3 :         blockIndex++;
   75766             :       }
   75767           2 :   }
   75768             : 
   75769             : //############################################################################
   75770             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   75771             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   75772             :  * not compressed. However, that stuff is not yet implemented! 
   75773             :  */
   75774             : unsigned long
   75775           0 : SgBasicBlock::getNumberOfLastValidPointer()
   75776             :    {
   75777           0 :       SgBasicBlock* testPointer = (SgBasicBlock*)(SgBasicBlock::pools.back());
   75778           0 :       unsigned long localIndex = SgBasicBlock::pool_size - 1;
   75779           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   75780             :          {
   75781           0 :            localIndex--;
   75782             :          }
   75783           0 :       return (localIndex + SgBasicBlock::pool_size * (SgBasicBlock::pools.size()-1));
   75784             :    }
   75785             : 
   75786             : //############################################################################
   75787             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   75788             :  * memory pool and initializes the data member in class SgBasicBlockStroageClass
   75789             :  * from its counterpart of SgBasicBlock. The return value is just for checking, 
   75790             :  * that the whole StorageClassArray is initialized!
   75791             :  */
   75792             : unsigned long
   75793           3 : SgBasicBlock::initializeStorageClassArray( SgBasicBlockStorageClass *storageArray )
   75794             :    {
   75795           3 :      unsigned long storageCounter = 0;
   75796           3 :      std::vector < unsigned char* > :: const_iterator block = SgBasicBlock::pools.begin();
   75797           3 :      SgBasicBlock* pointer = NULL;
   75798           7 :      while ( block != SgBasicBlock::pools.end() ) {
   75799           4 :           pointer = (SgBasicBlock*) (*block);
   75800        8004 :           for ( unsigned i = 0; i < SgBasicBlock::pool_size; ++i ) {
   75801        8000 :                if ( pointer->get_freepointer() != NULL ) {
   75802        2866 :                  storageArray->pickOutIRNodeData (pointer) ;
   75803        2866 :                  storageArray++;
   75804        2866 :                  storageCounter++;
   75805             :                }
   75806        8000 :                pointer++;
   75807             :              }
   75808           4 :            block++;
   75809             :         }
   75810           3 :      return storageCounter;
   75811             :    }
   75812             : 
   75813             : /* #line 75814 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   75814             : 
   75815             : 
   75816             : 
   75817             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   75818             : 
   75819             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   75820             : 
   75821             : //############################################################################
   75822             : /* JH (02/02/2006) Constructor of the IR node SgIfStmt that takes its 
   75823             :  * corresponding StorageClass as parameter
   75824             :  */
   75825         592 : SgIfStmt :: SgIfStmt ( const SgIfStmtStorageClass& storageSource )   : SgScopeStatement (storageSource)
   75826             :    {
   75827             : 
   75828             : 
   75829             : /* #line 75830 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   75830             : 
   75831         592 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   75832         592 :      p_conditional =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_conditional) );
   75833         592 :      p_true_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_true_body) );
   75834         592 :      p_false_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_false_body) );
   75835         592 :      p_is_if_constexpr_statement = storageSource.storageOf_is_if_constexpr_statement ;
   75836         592 :      p_if_constexpr_value_known = storageSource.storageOf_if_constexpr_value_known ;
   75837         592 :      p_if_constexpr_value = storageSource.storageOf_if_constexpr_value ;
   75838         592 :      p_else_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_else_numeric_label) );
   75839         592 :      p_string_label = storageSource.storageOf_string_label.rebuildDataStoredInEasyStorageClass() ;
   75840         592 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   75841         592 :      p_has_end_statement = storageSource.storageOf_has_end_statement ;
   75842         592 :      p_use_then_keyword = storageSource.storageOf_use_then_keyword ;
   75843         592 :      p_is_else_if_statement = storageSource.storageOf_is_else_if_statement ;
   75844             : 
   75845             : 
   75846             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   75847             : 
   75848             : 
   75849         592 :    }
   75850             : 
   75851             : //############################################################################
   75852             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   75853             :  * within the working AST. 
   75854             :  */
   75855        4949 : SgIfStmt * SgIfStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   75856        4949 :      SgIfStmt* returnPointer = NULL;
   75857        4949 :      if ( globalIndex != 0 )
   75858             :         {
   75859             : 
   75860             : #if FILE_IO_EXTRA_CHECK
   75861        4949 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIfStmt ) ) <= globalIndex ) ;
   75862        4949 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIfStmt + 1 ) ) );
   75863             : #endif
   75864        4949 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIfStmt )  
   75865        4949 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIfStmt );
   75866        4949 :           unsigned long positionInPool = localIndex % SgIfStmt::pool_size;
   75867        4949 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIfStmt::pool_size;
   75868             : 
   75869             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   75870             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   75871             : 
   75872        4949 :           returnPointer = &( ( (SgIfStmt*)(SgIfStmt::pools[memoryBlock]) ) [positionInPool]) ;
   75873             : 
   75874        4949 :           ROSE_ASSERT( returnPointer != NULL ) ;
   75875             :         }
   75876        4949 :      return returnPointer ;
   75877             :    }
   75878             : 
   75879             : //############################################################################
   75880             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   75881             :   for the AST with the index astIndex
   75882             : */
   75883           0 : SgIfStmt * SgIfStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   75884           0 :      SgIfStmt* returnPointer = NULL;
   75885           0 :      if ( globalIndex != 0 )
   75886             :         {
   75887             : 
   75888             : #if FILE_IO_EXTRA_CHECK
   75889           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIfStmt ) ) <= globalIndex ) ;
   75890           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIfStmt + 1 ) ) );
   75891             : #endif
   75892           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIfStmt )
   75893           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIfStmt );
   75894           0 :           unsigned long positionInPool = localIndex % SgIfStmt::pool_size ;
   75895           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIfStmt::pool_size ;
   75896             : 
   75897             : #if FILE_IO_EXTRA_CHECK
   75898             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   75899             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   75900             : #endif
   75901             : 
   75902           0 :           returnPointer = &( ( (SgIfStmt*)(SgIfStmt::pools[memoryBlock]) ) [positionInPool]) ;
   75903             : 
   75904             : #if FILE_IO_EXTRA_CHECK
   75905           0 :           assert ( returnPointer != NULL ) ;
   75906             : #endif
   75907             :         }
   75908           0 :      return returnPointer ;
   75909             :    }
   75910             : 
   75911             : //############################################################################
   75912             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   75913             :  * pool size! We set for every valid object in the memory pool the freepointer
   75914             :  * to the global index and increase the global index afterwards. For all the 
   75915             :  * invalid objects (means address ranges within the memory pool that were not
   75916             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   75917             :  * distinguish valid from invalid objects! 
   75918             :  */
   75919             : unsigned long
   75920           5 : SgIfStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   75921             :    {
   75922           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   75923           5 :      SgIfStmt* pointer = NULL;
   75924           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   75925           5 :      std::vector < unsigned char* > :: const_iterator block;
   75926           6 :      for ( block = SgIfStmt::pools.begin(); block != SgIfStmt::pools.end() ; ++block )
   75927             :         {
   75928           1 :           pointer = (SgIfStmt*)(*block);
   75929        2001 :           for (unsigned i = 0; i < SgIfStmt::pool_size; ++i )
   75930             :              {
   75931             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   75932             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   75933             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   75934             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   75935             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   75936             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   75937             :             // properly; so this will have to be checked next.
   75938             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   75939             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   75940        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   75941             :                   {
   75942         592 :                     pointer[i].set_freepointer((SgIfStmt*)(globalIndex));
   75943         592 :                     globalIndex++;
   75944             :                   }
   75945             :                else
   75946             :                   {
   75947        1408 :                     pointer[i].set_freepointer(NULL);
   75948             :                   }
   75949             :               }
   75950             :         }
   75951           5 :      return globalIndex;
   75952             :    }
   75953             : 
   75954             : //############################################################################
   75955             : // JH (01/14/2006)
   75956             : void
   75957           5 : SgIfStmt::resetValidFreepointers( )
   75958             :    {
   75959           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   75960           5 :      SgIfStmt* pointer = NULL;
   75961           5 :      std::vector < unsigned char* > :: const_iterator block;
   75962           5 :      SgIfStmt* pointerOfLinkedList = NULL;
   75963           6 :      for ( block = SgIfStmt::pools.begin(); block != SgIfStmt::pools.end() ; ++block )
   75964             :         {
   75965           1 :           pointer = (SgIfStmt*)(*block);
   75966        2001 :           for (unsigned i = 0; i < SgIfStmt::pool_size; ++i )
   75967             :              {
   75968             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   75969             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   75970             :             // memory blocks!.
   75971        2000 :                if ( pointer[i].get_freepointer() != NULL )
   75972             :                   {
   75973         592 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   75974             :                   }
   75975             :                else
   75976             :                   {
   75977        1408 :                     if ( pointerOfLinkedList == NULL )
   75978             :                        {
   75979           1 :                          SgIfStmt::next_node = &(pointer[i]);
   75980             :                        }
   75981             :                     else
   75982             :                        {
   75983             :                       // printf ("In SgIfStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   75984        1407 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   75985             :                        }
   75986             :                     pointerOfLinkedList = &(pointer[i]);
   75987             :                   }
   75988             :               }
   75989             :         }
   75990             : 
   75991           5 :      if ( pointerOfLinkedList != NULL )
   75992             :         {
   75993             :        // printf ("In SgIfStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   75994           1 :           pointerOfLinkedList->set_freepointer(NULL);
   75995             :        // DQ (6/6/2010): Temporary debugging...
   75996             :        //   ROSE_ASSERT(false);
   75997             :         }
   75998             : 
   75999           5 :      return ;
   76000             :    }
   76001             : 
   76002             : //############################################################################
   76003             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   76004             :  * within the memory pool and resets the freepointers, in order to achieve a 
   76005             :  * linked list, that has no jumps and starts at the beginning! This function 
   76006             :  * does not extend the memory pool, since we do not delete any memory blocks,
   76007             :  * but delete the valid objects.  
   76008             :  */
   76009             : void
   76010           0 : SgIfStmt::clearMemoryPool( )
   76011             :    {
   76012             :   // printf ("Inside of SgIfStmt::clearMemoryPool() \n");
   76013             : 
   76014           0 :      SgIfStmt* pointer = NULL, *tempPointer = NULL;
   76015           0 :      std::vector < unsigned char* > :: const_iterator block;
   76016           0 :      if ( SgIfStmt::pools.empty() == false )
   76017             :         {
   76018           0 :           block = SgIfStmt::pools.begin() ;
   76019           0 :           SgIfStmt::next_node = (SgIfStmt*) (*block);
   76020             : 
   76021           0 :           while ( block != SgIfStmt::pools.end() )
   76022             :              {
   76023           0 :                pointer = (SgIfStmt*) (*block);
   76024           0 :                if ( tempPointer != NULL )
   76025             :                   {
   76026           0 :                     tempPointer->set_freepointer(pointer);
   76027             :                   }
   76028           0 :                for (unsigned i = 0; i < SgIfStmt::pool_size - 1; ++i)
   76029             :                   {
   76030           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   76031             :                   }
   76032           0 :                 pointer[SgIfStmt::pool_size-1].set_freepointer(NULL);
   76033           0 :                 tempPointer = &(pointer[SgIfStmt::pool_size-1]);
   76034           0 :                 ++block;
   76035             :              }
   76036             :         }
   76037           0 :    }
   76038             : 
   76039           5 : void SgIfStmt::deleteMemoryPool() {
   76040           7 :   for (auto p: SgIfStmt::pools) {
   76041           2 :     ROSE_FREE(p);
   76042             :   }
   76043           5 :   SgIfStmt::next_node = nullptr;
   76044           5 :   SgIfStmt::pools.clear();
   76045           5 : }
   76046             : 
   76047             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   76048             : //                 reading multiple binary files to for a single AST.
   76049             : /////////// new version ////////////////////////////////
   76050             : //############################################################################
   76051             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   76052             : void
   76053           2 : SgIfStmt::extendMemoryPoolForFileIO( )
   76054             :   {
   76055           2 :     size_t blockIndex = SgIfStmt::pools.size();
   76056           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIfStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfStmt);
   76057             : 
   76058           3 :     while ( (blockIndex * SgIfStmt::pool_size) < newPoolSize)
   76059             :       {
   76060             : #if ROSE_ALLOC_TRACE
   76061             :         if (blockIndex > 0) {
   76062             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIfStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfStmt) = %" PRIuPTR " SgIfStmt::pool_size = %d \n",
   76063             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIfStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfStmt),SgIfStmt::pool_size);
   76064             :         }
   76065             : #endif
   76066             : 
   76067           1 :         SgIfStmt * pointer = (SgIfStmt*) ROSE_MALLOC ( SgIfStmt::pool_size * sizeof(SgIfStmt) );
   76068           1 :         assert( pointer != NULL );
   76069             : #if ROSE_ALLOC_MEMSET == 1
   76070             :         memset(pointer, 0x00, SgIfStmt::pool_size * sizeof(SgIfStmt));
   76071             : #elif ROSE_ALLOC_MEMSET == 2
   76072             :         memset(pointer, 0xCC, SgIfStmt::pool_size * sizeof(SgIfStmt));
   76073             : #endif
   76074           1 :         SgIfStmt::pools.push_back( (unsigned char*)(pointer) );
   76075           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIfStmt::pool_size * sizeof(SgIfStmt), V_SgIfStmt ) );
   76076             : 
   76077           1 :         if ( SgIfStmt::next_node != NULL ) {
   76078           0 :           if ( blockIndex > 0 ) {
   76079           0 :             SgIfStmt * blkptr = (SgIfStmt*)(SgIfStmt::pools[blockIndex-1]);
   76080           0 :             blkptr[ SgIfStmt::pool_size - 1 ].set_freepointer(pointer);
   76081             :           }
   76082             :         } else {
   76083           1 :           SgIfStmt::next_node = pointer;
   76084             :         }
   76085             : 
   76086        2000 :         for (unsigned i = 0; i < SgIfStmt::pool_size-1; ++i)
   76087             :            {
   76088        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   76089             :            }
   76090           1 :         pointer[ SgIfStmt::pool_size -1 ].set_freepointer(NULL);
   76091             : 
   76092           1 :         blockIndex++;
   76093             :       }
   76094           2 :   }
   76095             : 
   76096             : //############################################################################
   76097             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   76098             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   76099             :  * not compressed. However, that stuff is not yet implemented! 
   76100             :  */
   76101             : unsigned long
   76102           0 : SgIfStmt::getNumberOfLastValidPointer()
   76103             :    {
   76104           0 :       SgIfStmt* testPointer = (SgIfStmt*)(SgIfStmt::pools.back());
   76105           0 :       unsigned long localIndex = SgIfStmt::pool_size - 1;
   76106           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   76107             :          {
   76108           0 :            localIndex--;
   76109             :          }
   76110           0 :       return (localIndex + SgIfStmt::pool_size * (SgIfStmt::pools.size()-1));
   76111             :    }
   76112             : 
   76113             : //############################################################################
   76114             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   76115             :  * memory pool and initializes the data member in class SgIfStmtStroageClass
   76116             :  * from its counterpart of SgIfStmt. The return value is just for checking, 
   76117             :  * that the whole StorageClassArray is initialized!
   76118             :  */
   76119             : unsigned long
   76120           1 : SgIfStmt::initializeStorageClassArray( SgIfStmtStorageClass *storageArray )
   76121             :    {
   76122           1 :      unsigned long storageCounter = 0;
   76123           1 :      std::vector < unsigned char* > :: const_iterator block = SgIfStmt::pools.begin();
   76124           1 :      SgIfStmt* pointer = NULL;
   76125           2 :      while ( block != SgIfStmt::pools.end() ) {
   76126           1 :           pointer = (SgIfStmt*) (*block);
   76127        2001 :           for ( unsigned i = 0; i < SgIfStmt::pool_size; ++i ) {
   76128        2000 :                if ( pointer->get_freepointer() != NULL ) {
   76129         592 :                  storageArray->pickOutIRNodeData (pointer) ;
   76130         592 :                  storageArray++;
   76131         592 :                  storageCounter++;
   76132             :                }
   76133        2000 :                pointer++;
   76134             :              }
   76135           1 :            block++;
   76136             :         }
   76137           1 :      return storageCounter;
   76138             :    }
   76139             : 
   76140             : /* #line 76141 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   76141             : 
   76142             : 
   76143             : 
   76144             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   76145             : 
   76146             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   76147             : 
   76148             : //############################################################################
   76149             : /* JH (02/02/2006) Constructor of the IR node SgForStatement that takes its 
   76150             :  * corresponding StorageClass as parameter
   76151             :  */
   76152          40 : SgForStatement :: SgForStatement ( const SgForStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   76153             :    {
   76154             : 
   76155             : 
   76156             : /* #line 76157 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   76157             : 
   76158          40 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   76159          40 :      p_for_init_stmt =  (SgForInitStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_for_init_stmt) );
   76160          40 :      p_test =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_test) );
   76161          40 :      p_increment =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_increment) );
   76162          40 :      p_loop_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_loop_body) );
   76163          40 :      p_else_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_else_body) );
   76164          40 :      p_string_label = storageSource.storageOf_string_label.rebuildDataStoredInEasyStorageClass() ;
   76165             : 
   76166             : 
   76167             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   76168             : 
   76169             : 
   76170          40 :    }
   76171             : 
   76172             : //############################################################################
   76173             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   76174             :  * within the working AST. 
   76175             :  */
   76176         380 : SgForStatement * SgForStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   76177         380 :      SgForStatement* returnPointer = NULL;
   76178         380 :      if ( globalIndex != 0 )
   76179             :         {
   76180             : 
   76181             : #if FILE_IO_EXTRA_CHECK
   76182         380 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgForStatement ) ) <= globalIndex ) ;
   76183         380 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgForStatement + 1 ) ) );
   76184             : #endif
   76185         380 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgForStatement )  
   76186         380 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgForStatement );
   76187         380 :           unsigned long positionInPool = localIndex % SgForStatement::pool_size;
   76188         380 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgForStatement::pool_size;
   76189             : 
   76190             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   76191             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   76192             : 
   76193         380 :           returnPointer = &( ( (SgForStatement*)(SgForStatement::pools[memoryBlock]) ) [positionInPool]) ;
   76194             : 
   76195         380 :           ROSE_ASSERT( returnPointer != NULL ) ;
   76196             :         }
   76197         380 :      return returnPointer ;
   76198             :    }
   76199             : 
   76200             : //############################################################################
   76201             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   76202             :   for the AST with the index astIndex
   76203             : */
   76204           0 : SgForStatement * SgForStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   76205           0 :      SgForStatement* returnPointer = NULL;
   76206           0 :      if ( globalIndex != 0 )
   76207             :         {
   76208             : 
   76209             : #if FILE_IO_EXTRA_CHECK
   76210           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgForStatement ) ) <= globalIndex ) ;
   76211           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgForStatement + 1 ) ) );
   76212             : #endif
   76213           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgForStatement )
   76214           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgForStatement );
   76215           0 :           unsigned long positionInPool = localIndex % SgForStatement::pool_size ;
   76216           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgForStatement::pool_size ;
   76217             : 
   76218             : #if FILE_IO_EXTRA_CHECK
   76219             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   76220             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   76221             : #endif
   76222             : 
   76223           0 :           returnPointer = &( ( (SgForStatement*)(SgForStatement::pools[memoryBlock]) ) [positionInPool]) ;
   76224             : 
   76225             : #if FILE_IO_EXTRA_CHECK
   76226           0 :           assert ( returnPointer != NULL ) ;
   76227             : #endif
   76228             :         }
   76229           0 :      return returnPointer ;
   76230             :    }
   76231             : 
   76232             : //############################################################################
   76233             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   76234             :  * pool size! We set for every valid object in the memory pool the freepointer
   76235             :  * to the global index and increase the global index afterwards. For all the 
   76236             :  * invalid objects (means address ranges within the memory pool that were not
   76237             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   76238             :  * distinguish valid from invalid objects! 
   76239             :  */
   76240             : unsigned long
   76241           5 : SgForStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   76242             :    {
   76243           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   76244           5 :      SgForStatement* pointer = NULL;
   76245           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   76246           5 :      std::vector < unsigned char* > :: const_iterator block;
   76247           6 :      for ( block = SgForStatement::pools.begin(); block != SgForStatement::pools.end() ; ++block )
   76248             :         {
   76249           1 :           pointer = (SgForStatement*)(*block);
   76250        2001 :           for (unsigned i = 0; i < SgForStatement::pool_size; ++i )
   76251             :              {
   76252             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   76253             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   76254             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   76255             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   76256             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   76257             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   76258             :             // properly; so this will have to be checked next.
   76259             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   76260             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   76261        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   76262             :                   {
   76263          40 :                     pointer[i].set_freepointer((SgForStatement*)(globalIndex));
   76264          40 :                     globalIndex++;
   76265             :                   }
   76266             :                else
   76267             :                   {
   76268        1960 :                     pointer[i].set_freepointer(NULL);
   76269             :                   }
   76270             :               }
   76271             :         }
   76272           5 :      return globalIndex;
   76273             :    }
   76274             : 
   76275             : //############################################################################
   76276             : // JH (01/14/2006)
   76277             : void
   76278           5 : SgForStatement::resetValidFreepointers( )
   76279             :    {
   76280           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   76281           5 :      SgForStatement* pointer = NULL;
   76282           5 :      std::vector < unsigned char* > :: const_iterator block;
   76283           5 :      SgForStatement* pointerOfLinkedList = NULL;
   76284           6 :      for ( block = SgForStatement::pools.begin(); block != SgForStatement::pools.end() ; ++block )
   76285             :         {
   76286           1 :           pointer = (SgForStatement*)(*block);
   76287        2001 :           for (unsigned i = 0; i < SgForStatement::pool_size; ++i )
   76288             :              {
   76289             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   76290             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   76291             :             // memory blocks!.
   76292        2000 :                if ( pointer[i].get_freepointer() != NULL )
   76293             :                   {
   76294          40 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   76295             :                   }
   76296             :                else
   76297             :                   {
   76298        1960 :                     if ( pointerOfLinkedList == NULL )
   76299             :                        {
   76300           1 :                          SgForStatement::next_node = &(pointer[i]);
   76301             :                        }
   76302             :                     else
   76303             :                        {
   76304             :                       // printf ("In SgForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   76305        1959 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   76306             :                        }
   76307             :                     pointerOfLinkedList = &(pointer[i]);
   76308             :                   }
   76309             :               }
   76310             :         }
   76311             : 
   76312           5 :      if ( pointerOfLinkedList != NULL )
   76313             :         {
   76314             :        // printf ("In SgForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   76315           1 :           pointerOfLinkedList->set_freepointer(NULL);
   76316             :        // DQ (6/6/2010): Temporary debugging...
   76317             :        //   ROSE_ASSERT(false);
   76318             :         }
   76319             : 
   76320           5 :      return ;
   76321             :    }
   76322             : 
   76323             : //############################################################################
   76324             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   76325             :  * within the memory pool and resets the freepointers, in order to achieve a 
   76326             :  * linked list, that has no jumps and starts at the beginning! This function 
   76327             :  * does not extend the memory pool, since we do not delete any memory blocks,
   76328             :  * but delete the valid objects.  
   76329             :  */
   76330             : void
   76331           0 : SgForStatement::clearMemoryPool( )
   76332             :    {
   76333             :   // printf ("Inside of SgForStatement::clearMemoryPool() \n");
   76334             : 
   76335           0 :      SgForStatement* pointer = NULL, *tempPointer = NULL;
   76336           0 :      std::vector < unsigned char* > :: const_iterator block;
   76337           0 :      if ( SgForStatement::pools.empty() == false )
   76338             :         {
   76339           0 :           block = SgForStatement::pools.begin() ;
   76340           0 :           SgForStatement::next_node = (SgForStatement*) (*block);
   76341             : 
   76342           0 :           while ( block != SgForStatement::pools.end() )
   76343             :              {
   76344           0 :                pointer = (SgForStatement*) (*block);
   76345           0 :                if ( tempPointer != NULL )
   76346             :                   {
   76347           0 :                     tempPointer->set_freepointer(pointer);
   76348             :                   }
   76349           0 :                for (unsigned i = 0; i < SgForStatement::pool_size - 1; ++i)
   76350             :                   {
   76351           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   76352             :                   }
   76353           0 :                 pointer[SgForStatement::pool_size-1].set_freepointer(NULL);
   76354           0 :                 tempPointer = &(pointer[SgForStatement::pool_size-1]);
   76355           0 :                 ++block;
   76356             :              }
   76357             :         }
   76358           0 :    }
   76359             : 
   76360           5 : void SgForStatement::deleteMemoryPool() {
   76361           7 :   for (auto p: SgForStatement::pools) {
   76362           2 :     ROSE_FREE(p);
   76363             :   }
   76364           5 :   SgForStatement::next_node = nullptr;
   76365           5 :   SgForStatement::pools.clear();
   76366           5 : }
   76367             : 
   76368             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   76369             : //                 reading multiple binary files to for a single AST.
   76370             : /////////// new version ////////////////////////////////
   76371             : //############################################################################
   76372             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   76373             : void
   76374           2 : SgForStatement::extendMemoryPoolForFileIO( )
   76375             :   {
   76376           2 :     size_t blockIndex = SgForStatement::pools.size();
   76377           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgForStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgForStatement);
   76378             : 
   76379           3 :     while ( (blockIndex * SgForStatement::pool_size) < newPoolSize)
   76380             :       {
   76381             : #if ROSE_ALLOC_TRACE
   76382             :         if (blockIndex > 0) {
   76383             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgForStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgForStatement) = %" PRIuPTR " SgForStatement::pool_size = %d \n",
   76384             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgForStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgForStatement),SgForStatement::pool_size);
   76385             :         }
   76386             : #endif
   76387             : 
   76388           1 :         SgForStatement * pointer = (SgForStatement*) ROSE_MALLOC ( SgForStatement::pool_size * sizeof(SgForStatement) );
   76389           1 :         assert( pointer != NULL );
   76390             : #if ROSE_ALLOC_MEMSET == 1
   76391             :         memset(pointer, 0x00, SgForStatement::pool_size * sizeof(SgForStatement));
   76392             : #elif ROSE_ALLOC_MEMSET == 2
   76393             :         memset(pointer, 0xCC, SgForStatement::pool_size * sizeof(SgForStatement));
   76394             : #endif
   76395           1 :         SgForStatement::pools.push_back( (unsigned char*)(pointer) );
   76396           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgForStatement::pool_size * sizeof(SgForStatement), V_SgForStatement ) );
   76397             : 
   76398           1 :         if ( SgForStatement::next_node != NULL ) {
   76399           0 :           if ( blockIndex > 0 ) {
   76400           0 :             SgForStatement * blkptr = (SgForStatement*)(SgForStatement::pools[blockIndex-1]);
   76401           0 :             blkptr[ SgForStatement::pool_size - 1 ].set_freepointer(pointer);
   76402             :           }
   76403             :         } else {
   76404           1 :           SgForStatement::next_node = pointer;
   76405             :         }
   76406             : 
   76407        2000 :         for (unsigned i = 0; i < SgForStatement::pool_size-1; ++i)
   76408             :            {
   76409        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   76410             :            }
   76411           1 :         pointer[ SgForStatement::pool_size -1 ].set_freepointer(NULL);
   76412             : 
   76413           1 :         blockIndex++;
   76414             :       }
   76415           2 :   }
   76416             : 
   76417             : //############################################################################
   76418             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   76419             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   76420             :  * not compressed. However, that stuff is not yet implemented! 
   76421             :  */
   76422             : unsigned long
   76423           0 : SgForStatement::getNumberOfLastValidPointer()
   76424             :    {
   76425           0 :       SgForStatement* testPointer = (SgForStatement*)(SgForStatement::pools.back());
   76426           0 :       unsigned long localIndex = SgForStatement::pool_size - 1;
   76427           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   76428             :          {
   76429           0 :            localIndex--;
   76430             :          }
   76431           0 :       return (localIndex + SgForStatement::pool_size * (SgForStatement::pools.size()-1));
   76432             :    }
   76433             : 
   76434             : //############################################################################
   76435             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   76436             :  * memory pool and initializes the data member in class SgForStatementStroageClass
   76437             :  * from its counterpart of SgForStatement. The return value is just for checking, 
   76438             :  * that the whole StorageClassArray is initialized!
   76439             :  */
   76440             : unsigned long
   76441           1 : SgForStatement::initializeStorageClassArray( SgForStatementStorageClass *storageArray )
   76442             :    {
   76443           1 :      unsigned long storageCounter = 0;
   76444           1 :      std::vector < unsigned char* > :: const_iterator block = SgForStatement::pools.begin();
   76445           1 :      SgForStatement* pointer = NULL;
   76446           2 :      while ( block != SgForStatement::pools.end() ) {
   76447           1 :           pointer = (SgForStatement*) (*block);
   76448        2001 :           for ( unsigned i = 0; i < SgForStatement::pool_size; ++i ) {
   76449        2000 :                if ( pointer->get_freepointer() != NULL ) {
   76450          40 :                  storageArray->pickOutIRNodeData (pointer) ;
   76451          40 :                  storageArray++;
   76452          40 :                  storageCounter++;
   76453             :                }
   76454        2000 :                pointer++;
   76455             :              }
   76456           1 :            block++;
   76457             :         }
   76458           1 :      return storageCounter;
   76459             :    }
   76460             : 
   76461             : /* #line 76462 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   76462             : 
   76463             : 
   76464             : 
   76465             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   76466             : 
   76467             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   76468             : 
   76469             : //############################################################################
   76470             : /* JH (02/02/2006) Constructor of the IR node SgFunctionDefinition that takes its 
   76471             :  * corresponding StorageClass as parameter
   76472             :  */
   76473        1897 : SgFunctionDefinition :: SgFunctionDefinition ( const SgFunctionDefinitionStorageClass& storageSource )   : SgScopeStatement (storageSource)
   76474             :    {
   76475             : 
   76476             : 
   76477             : /* #line 76478 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   76478             : 
   76479        1897 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   76480        1897 :      p_body =  (SgBasicBlock*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   76481        1897 :      p_scope_number_list = storageSource.storageOf_scope_number_list.rebuildDataStoredInEasyStorageClass() ;
   76482             : 
   76483             : 
   76484             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   76485             : 
   76486             : 
   76487        1897 :    }
   76488             : 
   76489             : //############################################################################
   76490             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   76491             :  * within the working AST. 
   76492             :  */
   76493       11761 : SgFunctionDefinition * SgFunctionDefinition::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   76494       11761 :      SgFunctionDefinition* returnPointer = NULL;
   76495       11761 :      if ( globalIndex != 0 )
   76496             :         {
   76497             : 
   76498             : #if FILE_IO_EXTRA_CHECK
   76499       11761 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionDefinition ) ) <= globalIndex ) ;
   76500       11761 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionDefinition + 1 ) ) );
   76501             : #endif
   76502       11761 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionDefinition )  
   76503       11761 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionDefinition );
   76504       11761 :           unsigned long positionInPool = localIndex % SgFunctionDefinition::pool_size;
   76505       11761 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionDefinition::pool_size;
   76506             : 
   76507             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   76508             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   76509             : 
   76510       11761 :           returnPointer = &( ( (SgFunctionDefinition*)(SgFunctionDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   76511             : 
   76512       11761 :           ROSE_ASSERT( returnPointer != NULL ) ;
   76513             :         }
   76514       11761 :      return returnPointer ;
   76515             :    }
   76516             : 
   76517             : //############################################################################
   76518             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   76519             :   for the AST with the index astIndex
   76520             : */
   76521           0 : SgFunctionDefinition * SgFunctionDefinition::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   76522           0 :      SgFunctionDefinition* returnPointer = NULL;
   76523           0 :      if ( globalIndex != 0 )
   76524             :         {
   76525             : 
   76526             : #if FILE_IO_EXTRA_CHECK
   76527           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionDefinition ) ) <= globalIndex ) ;
   76528           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionDefinition + 1 ) ) );
   76529             : #endif
   76530           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionDefinition )
   76531           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionDefinition );
   76532           0 :           unsigned long positionInPool = localIndex % SgFunctionDefinition::pool_size ;
   76533           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionDefinition::pool_size ;
   76534             : 
   76535             : #if FILE_IO_EXTRA_CHECK
   76536             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   76537             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   76538             : #endif
   76539             : 
   76540           0 :           returnPointer = &( ( (SgFunctionDefinition*)(SgFunctionDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   76541             : 
   76542             : #if FILE_IO_EXTRA_CHECK
   76543           0 :           assert ( returnPointer != NULL ) ;
   76544             : #endif
   76545             :         }
   76546           0 :      return returnPointer ;
   76547             :    }
   76548             : 
   76549             : //############################################################################
   76550             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   76551             :  * pool size! We set for every valid object in the memory pool the freepointer
   76552             :  * to the global index and increase the global index afterwards. For all the 
   76553             :  * invalid objects (means address ranges within the memory pool that were not
   76554             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   76555             :  * distinguish valid from invalid objects! 
   76556             :  */
   76557             : unsigned long
   76558           5 : SgFunctionDefinition::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   76559             :    {
   76560           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   76561           5 :      SgFunctionDefinition* pointer = NULL;
   76562           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   76563           5 :      std::vector < unsigned char* > :: const_iterator block;
   76564           8 :      for ( block = SgFunctionDefinition::pools.begin(); block != SgFunctionDefinition::pools.end() ; ++block )
   76565             :         {
   76566           3 :           pointer = (SgFunctionDefinition*)(*block);
   76567        6003 :           for (unsigned i = 0; i < SgFunctionDefinition::pool_size; ++i )
   76568             :              {
   76569             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   76570             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   76571             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   76572             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   76573             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   76574             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   76575             :             // properly; so this will have to be checked next.
   76576             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   76577             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   76578        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   76579             :                   {
   76580        1583 :                     pointer[i].set_freepointer((SgFunctionDefinition*)(globalIndex));
   76581        1583 :                     globalIndex++;
   76582             :                   }
   76583             :                else
   76584             :                   {
   76585        4417 :                     pointer[i].set_freepointer(NULL);
   76586             :                   }
   76587             :               }
   76588             :         }
   76589           5 :      return globalIndex;
   76590             :    }
   76591             : 
   76592             : //############################################################################
   76593             : // JH (01/14/2006)
   76594             : void
   76595           5 : SgFunctionDefinition::resetValidFreepointers( )
   76596             :    {
   76597           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   76598           5 :      SgFunctionDefinition* pointer = NULL;
   76599           5 :      std::vector < unsigned char* > :: const_iterator block;
   76600           5 :      SgFunctionDefinition* pointerOfLinkedList = NULL;
   76601           8 :      for ( block = SgFunctionDefinition::pools.begin(); block != SgFunctionDefinition::pools.end() ; ++block )
   76602             :         {
   76603           3 :           pointer = (SgFunctionDefinition*)(*block);
   76604        6003 :           for (unsigned i = 0; i < SgFunctionDefinition::pool_size; ++i )
   76605             :              {
   76606             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   76607             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   76608             :             // memory blocks!.
   76609        6000 :                if ( pointer[i].get_freepointer() != NULL )
   76610             :                   {
   76611        1583 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   76612             :                   }
   76613             :                else
   76614             :                   {
   76615        4417 :                     if ( pointerOfLinkedList == NULL )
   76616             :                        {
   76617           3 :                          SgFunctionDefinition::next_node = &(pointer[i]);
   76618             :                        }
   76619             :                     else
   76620             :                        {
   76621             :                       // printf ("In SgFunctionDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   76622        4414 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   76623             :                        }
   76624             :                     pointerOfLinkedList = &(pointer[i]);
   76625             :                   }
   76626             :               }
   76627             :         }
   76628             : 
   76629           5 :      if ( pointerOfLinkedList != NULL )
   76630             :         {
   76631             :        // printf ("In SgFunctionDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   76632           3 :           pointerOfLinkedList->set_freepointer(NULL);
   76633             :        // DQ (6/6/2010): Temporary debugging...
   76634             :        //   ROSE_ASSERT(false);
   76635             :         }
   76636             : 
   76637           5 :      return ;
   76638             :    }
   76639             : 
   76640             : //############################################################################
   76641             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   76642             :  * within the memory pool and resets the freepointers, in order to achieve a 
   76643             :  * linked list, that has no jumps and starts at the beginning! This function 
   76644             :  * does not extend the memory pool, since we do not delete any memory blocks,
   76645             :  * but delete the valid objects.  
   76646             :  */
   76647             : void
   76648           0 : SgFunctionDefinition::clearMemoryPool( )
   76649             :    {
   76650             :   // printf ("Inside of SgFunctionDefinition::clearMemoryPool() \n");
   76651             : 
   76652           0 :      SgFunctionDefinition* pointer = NULL, *tempPointer = NULL;
   76653           0 :      std::vector < unsigned char* > :: const_iterator block;
   76654           0 :      if ( SgFunctionDefinition::pools.empty() == false )
   76655             :         {
   76656           0 :           block = SgFunctionDefinition::pools.begin() ;
   76657           0 :           SgFunctionDefinition::next_node = (SgFunctionDefinition*) (*block);
   76658             : 
   76659           0 :           while ( block != SgFunctionDefinition::pools.end() )
   76660             :              {
   76661           0 :                pointer = (SgFunctionDefinition*) (*block);
   76662           0 :                if ( tempPointer != NULL )
   76663             :                   {
   76664           0 :                     tempPointer->set_freepointer(pointer);
   76665             :                   }
   76666           0 :                for (unsigned i = 0; i < SgFunctionDefinition::pool_size - 1; ++i)
   76667             :                   {
   76668           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   76669             :                   }
   76670           0 :                 pointer[SgFunctionDefinition::pool_size-1].set_freepointer(NULL);
   76671           0 :                 tempPointer = &(pointer[SgFunctionDefinition::pool_size-1]);
   76672           0 :                 ++block;
   76673             :              }
   76674             :         }
   76675           0 :    }
   76676             : 
   76677           5 : void SgFunctionDefinition::deleteMemoryPool() {
   76678          10 :   for (auto p: SgFunctionDefinition::pools) {
   76679           5 :     ROSE_FREE(p);
   76680             :   }
   76681           5 :   SgFunctionDefinition::next_node = nullptr;
   76682           5 :   SgFunctionDefinition::pools.clear();
   76683           5 : }
   76684             : 
   76685             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   76686             : //                 reading multiple binary files to for a single AST.
   76687             : /////////// new version ////////////////////////////////
   76688             : //############################################################################
   76689             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   76690             : void
   76691           2 : SgFunctionDefinition::extendMemoryPoolForFileIO( )
   76692             :   {
   76693           2 :     size_t blockIndex = SgFunctionDefinition::pools.size();
   76694           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionDefinition) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionDefinition);
   76695             : 
   76696           4 :     while ( (blockIndex * SgFunctionDefinition::pool_size) < newPoolSize)
   76697             :       {
   76698             : #if ROSE_ALLOC_TRACE
   76699             :         if (blockIndex > 0) {
   76700             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionDefinition) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionDefinition) = %" PRIuPTR " SgFunctionDefinition::pool_size = %d \n",
   76701             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionDefinition),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionDefinition),SgFunctionDefinition::pool_size);
   76702             :         }
   76703             : #endif
   76704             : 
   76705           2 :         SgFunctionDefinition * pointer = (SgFunctionDefinition*) ROSE_MALLOC ( SgFunctionDefinition::pool_size * sizeof(SgFunctionDefinition) );
   76706           2 :         assert( pointer != NULL );
   76707             : #if ROSE_ALLOC_MEMSET == 1
   76708             :         memset(pointer, 0x00, SgFunctionDefinition::pool_size * sizeof(SgFunctionDefinition));
   76709             : #elif ROSE_ALLOC_MEMSET == 2
   76710             :         memset(pointer, 0xCC, SgFunctionDefinition::pool_size * sizeof(SgFunctionDefinition));
   76711             : #endif
   76712           2 :         SgFunctionDefinition::pools.push_back( (unsigned char*)(pointer) );
   76713           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionDefinition::pool_size * sizeof(SgFunctionDefinition), V_SgFunctionDefinition ) );
   76714             : 
   76715           2 :         if ( SgFunctionDefinition::next_node != NULL ) {
   76716           0 :           if ( blockIndex > 0 ) {
   76717           0 :             SgFunctionDefinition * blkptr = (SgFunctionDefinition*)(SgFunctionDefinition::pools[blockIndex-1]);
   76718           0 :             blkptr[ SgFunctionDefinition::pool_size - 1 ].set_freepointer(pointer);
   76719             :           }
   76720             :         } else {
   76721           2 :           SgFunctionDefinition::next_node = pointer;
   76722             :         }
   76723             : 
   76724        4000 :         for (unsigned i = 0; i < SgFunctionDefinition::pool_size-1; ++i)
   76725             :            {
   76726        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   76727             :            }
   76728           2 :         pointer[ SgFunctionDefinition::pool_size -1 ].set_freepointer(NULL);
   76729             : 
   76730           2 :         blockIndex++;
   76731             :       }
   76732           2 :   }
   76733             : 
   76734             : //############################################################################
   76735             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   76736             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   76737             :  * not compressed. However, that stuff is not yet implemented! 
   76738             :  */
   76739             : unsigned long
   76740           0 : SgFunctionDefinition::getNumberOfLastValidPointer()
   76741             :    {
   76742           0 :       SgFunctionDefinition* testPointer = (SgFunctionDefinition*)(SgFunctionDefinition::pools.back());
   76743           0 :       unsigned long localIndex = SgFunctionDefinition::pool_size - 1;
   76744           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   76745             :          {
   76746           0 :            localIndex--;
   76747             :          }
   76748           0 :       return (localIndex + SgFunctionDefinition::pool_size * (SgFunctionDefinition::pools.size()-1));
   76749             :    }
   76750             : 
   76751             : //############################################################################
   76752             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   76753             :  * memory pool and initializes the data member in class SgFunctionDefinitionStroageClass
   76754             :  * from its counterpart of SgFunctionDefinition. The return value is just for checking, 
   76755             :  * that the whole StorageClassArray is initialized!
   76756             :  */
   76757             : unsigned long
   76758           3 : SgFunctionDefinition::initializeStorageClassArray( SgFunctionDefinitionStorageClass *storageArray )
   76759             :    {
   76760           3 :      unsigned long storageCounter = 0;
   76761           3 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionDefinition::pools.begin();
   76762           3 :      SgFunctionDefinition* pointer = NULL;
   76763           6 :      while ( block != SgFunctionDefinition::pools.end() ) {
   76764           3 :           pointer = (SgFunctionDefinition*) (*block);
   76765        6003 :           for ( unsigned i = 0; i < SgFunctionDefinition::pool_size; ++i ) {
   76766        6000 :                if ( pointer->get_freepointer() != NULL ) {
   76767        1583 :                  storageArray->pickOutIRNodeData (pointer) ;
   76768        1583 :                  storageArray++;
   76769        1583 :                  storageCounter++;
   76770             :                }
   76771        6000 :                pointer++;
   76772             :              }
   76773           3 :            block++;
   76774             :         }
   76775           3 :      return storageCounter;
   76776             :    }
   76777             : 
   76778             : /* #line 76779 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   76779             : 
   76780             : 
   76781             : 
   76782             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   76783             : 
   76784             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   76785             : 
   76786             : //############################################################################
   76787             : /* JH (02/02/2006) Constructor of the IR node SgTemplateFunctionDefinition that takes its 
   76788             :  * corresponding StorageClass as parameter
   76789             :  */
   76790         315 : SgTemplateFunctionDefinition :: SgTemplateFunctionDefinition ( const SgTemplateFunctionDefinitionStorageClass& storageSource )   : SgFunctionDefinition (storageSource)
   76791             :    {
   76792             : 
   76793             : 
   76794             : /* #line 76795 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   76795             : 
   76796         315 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   76797             : 
   76798             : 
   76799             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   76800             : 
   76801             : 
   76802         315 :    }
   76803             : 
   76804             : //############################################################################
   76805             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   76806             :  * within the working AST. 
   76807             :  */
   76808        2528 : SgTemplateFunctionDefinition * SgTemplateFunctionDefinition::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   76809        2528 :      SgTemplateFunctionDefinition* returnPointer = NULL;
   76810        2528 :      if ( globalIndex != 0 )
   76811             :         {
   76812             : 
   76813             : #if FILE_IO_EXTRA_CHECK
   76814        2528 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateFunctionDefinition ) ) <= globalIndex ) ;
   76815        2528 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateFunctionDefinition + 1 ) ) );
   76816             : #endif
   76817        2528 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateFunctionDefinition )  
   76818        2528 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateFunctionDefinition );
   76819        2528 :           unsigned long positionInPool = localIndex % SgTemplateFunctionDefinition::pool_size;
   76820        2528 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateFunctionDefinition::pool_size;
   76821             : 
   76822             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   76823             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   76824             : 
   76825        2528 :           returnPointer = &( ( (SgTemplateFunctionDefinition*)(SgTemplateFunctionDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   76826             : 
   76827        2528 :           ROSE_ASSERT( returnPointer != NULL ) ;
   76828             :         }
   76829        2528 :      return returnPointer ;
   76830             :    }
   76831             : 
   76832             : //############################################################################
   76833             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   76834             :   for the AST with the index astIndex
   76835             : */
   76836           0 : SgTemplateFunctionDefinition * SgTemplateFunctionDefinition::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   76837           0 :      SgTemplateFunctionDefinition* returnPointer = NULL;
   76838           0 :      if ( globalIndex != 0 )
   76839             :         {
   76840             : 
   76841             : #if FILE_IO_EXTRA_CHECK
   76842           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateFunctionDefinition ) ) <= globalIndex ) ;
   76843           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateFunctionDefinition + 1 ) ) );
   76844             : #endif
   76845           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateFunctionDefinition )
   76846           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateFunctionDefinition );
   76847           0 :           unsigned long positionInPool = localIndex % SgTemplateFunctionDefinition::pool_size ;
   76848           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateFunctionDefinition::pool_size ;
   76849             : 
   76850             : #if FILE_IO_EXTRA_CHECK
   76851             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   76852             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   76853             : #endif
   76854             : 
   76855           0 :           returnPointer = &( ( (SgTemplateFunctionDefinition*)(SgTemplateFunctionDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   76856             : 
   76857             : #if FILE_IO_EXTRA_CHECK
   76858           0 :           assert ( returnPointer != NULL ) ;
   76859             : #endif
   76860             :         }
   76861           0 :      return returnPointer ;
   76862             :    }
   76863             : 
   76864             : //############################################################################
   76865             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   76866             :  * pool size! We set for every valid object in the memory pool the freepointer
   76867             :  * to the global index and increase the global index afterwards. For all the 
   76868             :  * invalid objects (means address ranges within the memory pool that were not
   76869             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   76870             :  * distinguish valid from invalid objects! 
   76871             :  */
   76872             : unsigned long
   76873           5 : SgTemplateFunctionDefinition::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   76874             :    {
   76875           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   76876           5 :      SgTemplateFunctionDefinition* pointer = NULL;
   76877           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   76878           5 :      std::vector < unsigned char* > :: const_iterator block;
   76879           6 :      for ( block = SgTemplateFunctionDefinition::pools.begin(); block != SgTemplateFunctionDefinition::pools.end() ; ++block )
   76880             :         {
   76881           1 :           pointer = (SgTemplateFunctionDefinition*)(*block);
   76882        2001 :           for (unsigned i = 0; i < SgTemplateFunctionDefinition::pool_size; ++i )
   76883             :              {
   76884             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   76885             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   76886             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   76887             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   76888             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   76889             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   76890             :             // properly; so this will have to be checked next.
   76891             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   76892             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   76893        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   76894             :                   {
   76895         315 :                     pointer[i].set_freepointer((SgTemplateFunctionDefinition*)(globalIndex));
   76896         315 :                     globalIndex++;
   76897             :                   }
   76898             :                else
   76899             :                   {
   76900        1685 :                     pointer[i].set_freepointer(NULL);
   76901             :                   }
   76902             :               }
   76903             :         }
   76904           5 :      return globalIndex;
   76905             :    }
   76906             : 
   76907             : //############################################################################
   76908             : // JH (01/14/2006)
   76909             : void
   76910           5 : SgTemplateFunctionDefinition::resetValidFreepointers( )
   76911             :    {
   76912           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   76913           5 :      SgTemplateFunctionDefinition* pointer = NULL;
   76914           5 :      std::vector < unsigned char* > :: const_iterator block;
   76915           5 :      SgTemplateFunctionDefinition* pointerOfLinkedList = NULL;
   76916           6 :      for ( block = SgTemplateFunctionDefinition::pools.begin(); block != SgTemplateFunctionDefinition::pools.end() ; ++block )
   76917             :         {
   76918           1 :           pointer = (SgTemplateFunctionDefinition*)(*block);
   76919        2001 :           for (unsigned i = 0; i < SgTemplateFunctionDefinition::pool_size; ++i )
   76920             :              {
   76921             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   76922             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   76923             :             // memory blocks!.
   76924        2000 :                if ( pointer[i].get_freepointer() != NULL )
   76925             :                   {
   76926         315 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   76927             :                   }
   76928             :                else
   76929             :                   {
   76930        1685 :                     if ( pointerOfLinkedList == NULL )
   76931             :                        {
   76932           1 :                          SgTemplateFunctionDefinition::next_node = &(pointer[i]);
   76933             :                        }
   76934             :                     else
   76935             :                        {
   76936             :                       // printf ("In SgTemplateFunctionDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   76937        1684 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   76938             :                        }
   76939             :                     pointerOfLinkedList = &(pointer[i]);
   76940             :                   }
   76941             :               }
   76942             :         }
   76943             : 
   76944           5 :      if ( pointerOfLinkedList != NULL )
   76945             :         {
   76946             :        // printf ("In SgTemplateFunctionDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   76947           1 :           pointerOfLinkedList->set_freepointer(NULL);
   76948             :        // DQ (6/6/2010): Temporary debugging...
   76949             :        //   ROSE_ASSERT(false);
   76950             :         }
   76951             : 
   76952           5 :      return ;
   76953             :    }
   76954             : 
   76955             : //############################################################################
   76956             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   76957             :  * within the memory pool and resets the freepointers, in order to achieve a 
   76958             :  * linked list, that has no jumps and starts at the beginning! This function 
   76959             :  * does not extend the memory pool, since we do not delete any memory blocks,
   76960             :  * but delete the valid objects.  
   76961             :  */
   76962             : void
   76963           0 : SgTemplateFunctionDefinition::clearMemoryPool( )
   76964             :    {
   76965             :   // printf ("Inside of SgTemplateFunctionDefinition::clearMemoryPool() \n");
   76966             : 
   76967           0 :      SgTemplateFunctionDefinition* pointer = NULL, *tempPointer = NULL;
   76968           0 :      std::vector < unsigned char* > :: const_iterator block;
   76969           0 :      if ( SgTemplateFunctionDefinition::pools.empty() == false )
   76970             :         {
   76971           0 :           block = SgTemplateFunctionDefinition::pools.begin() ;
   76972           0 :           SgTemplateFunctionDefinition::next_node = (SgTemplateFunctionDefinition*) (*block);
   76973             : 
   76974           0 :           while ( block != SgTemplateFunctionDefinition::pools.end() )
   76975             :              {
   76976           0 :                pointer = (SgTemplateFunctionDefinition*) (*block);
   76977           0 :                if ( tempPointer != NULL )
   76978             :                   {
   76979           0 :                     tempPointer->set_freepointer(pointer);
   76980             :                   }
   76981           0 :                for (unsigned i = 0; i < SgTemplateFunctionDefinition::pool_size - 1; ++i)
   76982             :                   {
   76983           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   76984             :                   }
   76985           0 :                 pointer[SgTemplateFunctionDefinition::pool_size-1].set_freepointer(NULL);
   76986           0 :                 tempPointer = &(pointer[SgTemplateFunctionDefinition::pool_size-1]);
   76987           0 :                 ++block;
   76988             :              }
   76989             :         }
   76990           0 :    }
   76991             : 
   76992           5 : void SgTemplateFunctionDefinition::deleteMemoryPool() {
   76993           7 :   for (auto p: SgTemplateFunctionDefinition::pools) {
   76994           2 :     ROSE_FREE(p);
   76995             :   }
   76996           5 :   SgTemplateFunctionDefinition::next_node = nullptr;
   76997           5 :   SgTemplateFunctionDefinition::pools.clear();
   76998           5 : }
   76999             : 
   77000             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   77001             : //                 reading multiple binary files to for a single AST.
   77002             : /////////// new version ////////////////////////////////
   77003             : //############################################################################
   77004             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   77005             : void
   77006           2 : SgTemplateFunctionDefinition::extendMemoryPoolForFileIO( )
   77007             :   {
   77008           2 :     size_t blockIndex = SgTemplateFunctionDefinition::pools.size();
   77009           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionDefinition) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionDefinition);
   77010             : 
   77011           3 :     while ( (blockIndex * SgTemplateFunctionDefinition::pool_size) < newPoolSize)
   77012             :       {
   77013             : #if ROSE_ALLOC_TRACE
   77014             :         if (blockIndex > 0) {
   77015             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionDefinition) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionDefinition) = %" PRIuPTR " SgTemplateFunctionDefinition::pool_size = %d \n",
   77016             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionDefinition),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionDefinition),SgTemplateFunctionDefinition::pool_size);
   77017             :         }
   77018             : #endif
   77019             : 
   77020           1 :         SgTemplateFunctionDefinition * pointer = (SgTemplateFunctionDefinition*) ROSE_MALLOC ( SgTemplateFunctionDefinition::pool_size * sizeof(SgTemplateFunctionDefinition) );
   77021           1 :         assert( pointer != NULL );
   77022             : #if ROSE_ALLOC_MEMSET == 1
   77023             :         memset(pointer, 0x00, SgTemplateFunctionDefinition::pool_size * sizeof(SgTemplateFunctionDefinition));
   77024             : #elif ROSE_ALLOC_MEMSET == 2
   77025             :         memset(pointer, 0xCC, SgTemplateFunctionDefinition::pool_size * sizeof(SgTemplateFunctionDefinition));
   77026             : #endif
   77027           1 :         SgTemplateFunctionDefinition::pools.push_back( (unsigned char*)(pointer) );
   77028           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateFunctionDefinition::pool_size * sizeof(SgTemplateFunctionDefinition), V_SgTemplateFunctionDefinition ) );
   77029             : 
   77030           1 :         if ( SgTemplateFunctionDefinition::next_node != NULL ) {
   77031           0 :           if ( blockIndex > 0 ) {
   77032           0 :             SgTemplateFunctionDefinition * blkptr = (SgTemplateFunctionDefinition*)(SgTemplateFunctionDefinition::pools[blockIndex-1]);
   77033           0 :             blkptr[ SgTemplateFunctionDefinition::pool_size - 1 ].set_freepointer(pointer);
   77034             :           }
   77035             :         } else {
   77036           1 :           SgTemplateFunctionDefinition::next_node = pointer;
   77037             :         }
   77038             : 
   77039        2000 :         for (unsigned i = 0; i < SgTemplateFunctionDefinition::pool_size-1; ++i)
   77040             :            {
   77041        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   77042             :            }
   77043           1 :         pointer[ SgTemplateFunctionDefinition::pool_size -1 ].set_freepointer(NULL);
   77044             : 
   77045           1 :         blockIndex++;
   77046             :       }
   77047           2 :   }
   77048             : 
   77049             : //############################################################################
   77050             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   77051             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   77052             :  * not compressed. However, that stuff is not yet implemented! 
   77053             :  */
   77054             : unsigned long
   77055           0 : SgTemplateFunctionDefinition::getNumberOfLastValidPointer()
   77056             :    {
   77057           0 :       SgTemplateFunctionDefinition* testPointer = (SgTemplateFunctionDefinition*)(SgTemplateFunctionDefinition::pools.back());
   77058           0 :       unsigned long localIndex = SgTemplateFunctionDefinition::pool_size - 1;
   77059           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   77060             :          {
   77061           0 :            localIndex--;
   77062             :          }
   77063           0 :       return (localIndex + SgTemplateFunctionDefinition::pool_size * (SgTemplateFunctionDefinition::pools.size()-1));
   77064             :    }
   77065             : 
   77066             : //############################################################################
   77067             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   77068             :  * memory pool and initializes the data member in class SgTemplateFunctionDefinitionStroageClass
   77069             :  * from its counterpart of SgTemplateFunctionDefinition. The return value is just for checking, 
   77070             :  * that the whole StorageClassArray is initialized!
   77071             :  */
   77072             : unsigned long
   77073           1 : SgTemplateFunctionDefinition::initializeStorageClassArray( SgTemplateFunctionDefinitionStorageClass *storageArray )
   77074             :    {
   77075           1 :      unsigned long storageCounter = 0;
   77076           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateFunctionDefinition::pools.begin();
   77077           1 :      SgTemplateFunctionDefinition* pointer = NULL;
   77078           2 :      while ( block != SgTemplateFunctionDefinition::pools.end() ) {
   77079           1 :           pointer = (SgTemplateFunctionDefinition*) (*block);
   77080        2001 :           for ( unsigned i = 0; i < SgTemplateFunctionDefinition::pool_size; ++i ) {
   77081        2000 :                if ( pointer->get_freepointer() != NULL ) {
   77082         315 :                  storageArray->pickOutIRNodeData (pointer) ;
   77083         315 :                  storageArray++;
   77084         315 :                  storageCounter++;
   77085             :                }
   77086        2000 :                pointer++;
   77087             :              }
   77088           1 :            block++;
   77089             :         }
   77090           1 :      return storageCounter;
   77091             :    }
   77092             : 
   77093             : /* #line 77094 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   77094             : 
   77095             : 
   77096             : 
   77097             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   77098             : 
   77099             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   77100             : 
   77101             : //############################################################################
   77102             : /* JH (02/02/2006) Constructor of the IR node SgClassDefinition that takes its 
   77103             :  * corresponding StorageClass as parameter
   77104             :  */
   77105        1275 : SgClassDefinition :: SgClassDefinition ( const SgClassDefinitionStorageClass& storageSource )   : SgScopeStatement (storageSource)
   77106             :    {
   77107             : 
   77108             : 
   77109             : /* #line 77110 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   77110             : 
   77111        1275 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   77112        1275 :      p_members = storageSource.storageOf_members.rebuildDataStoredInEasyStorageClass() ;
   77113        1275 :      SgDeclarationStatementPtrList::iterator i_members = p_members.begin() ; 
   77114        6311 :      for ( ; i_members != p_members.end(); ++i_members ) 
   77115             :         {
   77116        5036 :           (*i_members) = (SgDeclarationStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_members) ) );
   77117             :         }
   77118        1275 :      p_inheritances = storageSource.storageOf_inheritances.rebuildDataStoredInEasyStorageClass() ;
   77119        1275 :      SgBaseClassPtrList::iterator i_inheritances = p_inheritances.begin() ; 
   77120        1895 :      for ( ; i_inheritances != p_inheritances.end(); ++i_inheritances ) 
   77121             :         {
   77122         620 :           (*i_inheritances) = (SgBaseClassPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_inheritances) ) );
   77123             :         }
   77124        1275 :      p_packingAlignment = storageSource.storageOf_packingAlignment ;
   77125        1275 :      p_isSequence = storageSource.storageOf_isSequence ;
   77126        1275 :      p_isPrivate = storageSource.storageOf_isPrivate ;
   77127        1275 :      p_isAbstract = storageSource.storageOf_isAbstract ;
   77128             : 
   77129             : 
   77130             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   77131             : 
   77132             : 
   77133        1275 :    }
   77134             : 
   77135             : //############################################################################
   77136             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   77137             :  * within the working AST. 
   77138             :  */
   77139        3720 : SgClassDefinition * SgClassDefinition::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   77140        3720 :      SgClassDefinition* returnPointer = NULL;
   77141        3720 :      if ( globalIndex != 0 )
   77142             :         {
   77143             : 
   77144             : #if FILE_IO_EXTRA_CHECK
   77145        3720 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClassDefinition ) ) <= globalIndex ) ;
   77146        3720 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassDefinition + 1 ) ) );
   77147             : #endif
   77148        3720 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassDefinition )  
   77149        3720 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClassDefinition );
   77150        3720 :           unsigned long positionInPool = localIndex % SgClassDefinition::pool_size;
   77151        3720 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassDefinition::pool_size;
   77152             : 
   77153             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   77154             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   77155             : 
   77156        3720 :           returnPointer = &( ( (SgClassDefinition*)(SgClassDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   77157             : 
   77158        3720 :           ROSE_ASSERT( returnPointer != NULL ) ;
   77159             :         }
   77160        3720 :      return returnPointer ;
   77161             :    }
   77162             : 
   77163             : //############################################################################
   77164             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   77165             :   for the AST with the index astIndex
   77166             : */
   77167           0 : SgClassDefinition * SgClassDefinition::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   77168           0 :      SgClassDefinition* returnPointer = NULL;
   77169           0 :      if ( globalIndex != 0 )
   77170             :         {
   77171             : 
   77172             : #if FILE_IO_EXTRA_CHECK
   77173           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClassDefinition ) ) <= globalIndex ) ;
   77174           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassDefinition + 1 ) ) );
   77175             : #endif
   77176           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassDefinition )
   77177           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClassDefinition );
   77178           0 :           unsigned long positionInPool = localIndex % SgClassDefinition::pool_size ;
   77179           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassDefinition::pool_size ;
   77180             : 
   77181             : #if FILE_IO_EXTRA_CHECK
   77182             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   77183             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   77184             : #endif
   77185             : 
   77186           0 :           returnPointer = &( ( (SgClassDefinition*)(SgClassDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   77187             : 
   77188             : #if FILE_IO_EXTRA_CHECK
   77189           0 :           assert ( returnPointer != NULL ) ;
   77190             : #endif
   77191             :         }
   77192           0 :      return returnPointer ;
   77193             :    }
   77194             : 
   77195             : //############################################################################
   77196             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   77197             :  * pool size! We set for every valid object in the memory pool the freepointer
   77198             :  * to the global index and increase the global index afterwards. For all the 
   77199             :  * invalid objects (means address ranges within the memory pool that were not
   77200             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   77201             :  * distinguish valid from invalid objects! 
   77202             :  */
   77203             : unsigned long
   77204           5 : SgClassDefinition::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   77205             :    {
   77206           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   77207           5 :      SgClassDefinition* pointer = NULL;
   77208           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   77209           5 :      std::vector < unsigned char* > :: const_iterator block;
   77210           7 :      for ( block = SgClassDefinition::pools.begin(); block != SgClassDefinition::pools.end() ; ++block )
   77211             :         {
   77212           2 :           pointer = (SgClassDefinition*)(*block);
   77213        4002 :           for (unsigned i = 0; i < SgClassDefinition::pool_size; ++i )
   77214             :              {
   77215             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   77216             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   77217             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   77218             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   77219             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   77220             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   77221             :             // properly; so this will have to be checked next.
   77222             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   77223             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   77224        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   77225             :                   {
   77226         168 :                     pointer[i].set_freepointer((SgClassDefinition*)(globalIndex));
   77227         168 :                     globalIndex++;
   77228             :                   }
   77229             :                else
   77230             :                   {
   77231        3832 :                     pointer[i].set_freepointer(NULL);
   77232             :                   }
   77233             :               }
   77234             :         }
   77235           5 :      return globalIndex;
   77236             :    }
   77237             : 
   77238             : //############################################################################
   77239             : // JH (01/14/2006)
   77240             : void
   77241           5 : SgClassDefinition::resetValidFreepointers( )
   77242             :    {
   77243           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   77244           5 :      SgClassDefinition* pointer = NULL;
   77245           5 :      std::vector < unsigned char* > :: const_iterator block;
   77246           5 :      SgClassDefinition* pointerOfLinkedList = NULL;
   77247           7 :      for ( block = SgClassDefinition::pools.begin(); block != SgClassDefinition::pools.end() ; ++block )
   77248             :         {
   77249           2 :           pointer = (SgClassDefinition*)(*block);
   77250        4002 :           for (unsigned i = 0; i < SgClassDefinition::pool_size; ++i )
   77251             :              {
   77252             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   77253             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   77254             :             // memory blocks!.
   77255        4000 :                if ( pointer[i].get_freepointer() != NULL )
   77256             :                   {
   77257         168 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   77258             :                   }
   77259             :                else
   77260             :                   {
   77261        3832 :                     if ( pointerOfLinkedList == NULL )
   77262             :                        {
   77263           2 :                          SgClassDefinition::next_node = &(pointer[i]);
   77264             :                        }
   77265             :                     else
   77266             :                        {
   77267             :                       // printf ("In SgClassDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   77268        3830 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   77269             :                        }
   77270             :                     pointerOfLinkedList = &(pointer[i]);
   77271             :                   }
   77272             :               }
   77273             :         }
   77274             : 
   77275           5 :      if ( pointerOfLinkedList != NULL )
   77276             :         {
   77277             :        // printf ("In SgClassDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   77278           2 :           pointerOfLinkedList->set_freepointer(NULL);
   77279             :        // DQ (6/6/2010): Temporary debugging...
   77280             :        //   ROSE_ASSERT(false);
   77281             :         }
   77282             : 
   77283           5 :      return ;
   77284             :    }
   77285             : 
   77286             : //############################################################################
   77287             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   77288             :  * within the memory pool and resets the freepointers, in order to achieve a 
   77289             :  * linked list, that has no jumps and starts at the beginning! This function 
   77290             :  * does not extend the memory pool, since we do not delete any memory blocks,
   77291             :  * but delete the valid objects.  
   77292             :  */
   77293             : void
   77294           0 : SgClassDefinition::clearMemoryPool( )
   77295             :    {
   77296             :   // printf ("Inside of SgClassDefinition::clearMemoryPool() \n");
   77297             : 
   77298           0 :      SgClassDefinition* pointer = NULL, *tempPointer = NULL;
   77299           0 :      std::vector < unsigned char* > :: const_iterator block;
   77300           0 :      if ( SgClassDefinition::pools.empty() == false )
   77301             :         {
   77302           0 :           block = SgClassDefinition::pools.begin() ;
   77303           0 :           SgClassDefinition::next_node = (SgClassDefinition*) (*block);
   77304             : 
   77305           0 :           while ( block != SgClassDefinition::pools.end() )
   77306             :              {
   77307           0 :                pointer = (SgClassDefinition*) (*block);
   77308           0 :                if ( tempPointer != NULL )
   77309             :                   {
   77310           0 :                     tempPointer->set_freepointer(pointer);
   77311             :                   }
   77312           0 :                for (unsigned i = 0; i < SgClassDefinition::pool_size - 1; ++i)
   77313             :                   {
   77314           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   77315             :                   }
   77316           0 :                 pointer[SgClassDefinition::pool_size-1].set_freepointer(NULL);
   77317           0 :                 tempPointer = &(pointer[SgClassDefinition::pool_size-1]);
   77318           0 :                 ++block;
   77319             :              }
   77320             :         }
   77321           0 :    }
   77322             : 
   77323           5 : void SgClassDefinition::deleteMemoryPool() {
   77324           9 :   for (auto p: SgClassDefinition::pools) {
   77325           4 :     ROSE_FREE(p);
   77326             :   }
   77327           5 :   SgClassDefinition::next_node = nullptr;
   77328           5 :   SgClassDefinition::pools.clear();
   77329           5 : }
   77330             : 
   77331             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   77332             : //                 reading multiple binary files to for a single AST.
   77333             : /////////// new version ////////////////////////////////
   77334             : //############################################################################
   77335             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   77336             : void
   77337           2 : SgClassDefinition::extendMemoryPoolForFileIO( )
   77338             :   {
   77339           2 :     size_t blockIndex = SgClassDefinition::pools.size();
   77340           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDefinition) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDefinition);
   77341             : 
   77342           4 :     while ( (blockIndex * SgClassDefinition::pool_size) < newPoolSize)
   77343             :       {
   77344             : #if ROSE_ALLOC_TRACE
   77345             :         if (blockIndex > 0) {
   77346             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDefinition) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDefinition) = %" PRIuPTR " SgClassDefinition::pool_size = %d \n",
   77347             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDefinition),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDefinition),SgClassDefinition::pool_size);
   77348             :         }
   77349             : #endif
   77350             : 
   77351           2 :         SgClassDefinition * pointer = (SgClassDefinition*) ROSE_MALLOC ( SgClassDefinition::pool_size * sizeof(SgClassDefinition) );
   77352           2 :         assert( pointer != NULL );
   77353             : #if ROSE_ALLOC_MEMSET == 1
   77354             :         memset(pointer, 0x00, SgClassDefinition::pool_size * sizeof(SgClassDefinition));
   77355             : #elif ROSE_ALLOC_MEMSET == 2
   77356             :         memset(pointer, 0xCC, SgClassDefinition::pool_size * sizeof(SgClassDefinition));
   77357             : #endif
   77358           2 :         SgClassDefinition::pools.push_back( (unsigned char*)(pointer) );
   77359           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClassDefinition::pool_size * sizeof(SgClassDefinition), V_SgClassDefinition ) );
   77360             : 
   77361           2 :         if ( SgClassDefinition::next_node != NULL ) {
   77362           0 :           if ( blockIndex > 0 ) {
   77363           0 :             SgClassDefinition * blkptr = (SgClassDefinition*)(SgClassDefinition::pools[blockIndex-1]);
   77364           0 :             blkptr[ SgClassDefinition::pool_size - 1 ].set_freepointer(pointer);
   77365             :           }
   77366             :         } else {
   77367           2 :           SgClassDefinition::next_node = pointer;
   77368             :         }
   77369             : 
   77370        4000 :         for (unsigned i = 0; i < SgClassDefinition::pool_size-1; ++i)
   77371             :            {
   77372        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   77373             :            }
   77374           2 :         pointer[ SgClassDefinition::pool_size -1 ].set_freepointer(NULL);
   77375             : 
   77376           2 :         blockIndex++;
   77377             :       }
   77378           2 :   }
   77379             : 
   77380             : //############################################################################
   77381             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   77382             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   77383             :  * not compressed. However, that stuff is not yet implemented! 
   77384             :  */
   77385             : unsigned long
   77386           0 : SgClassDefinition::getNumberOfLastValidPointer()
   77387             :    {
   77388           0 :       SgClassDefinition* testPointer = (SgClassDefinition*)(SgClassDefinition::pools.back());
   77389           0 :       unsigned long localIndex = SgClassDefinition::pool_size - 1;
   77390           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   77391             :          {
   77392           0 :            localIndex--;
   77393             :          }
   77394           0 :       return (localIndex + SgClassDefinition::pool_size * (SgClassDefinition::pools.size()-1));
   77395             :    }
   77396             : 
   77397             : //############################################################################
   77398             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   77399             :  * memory pool and initializes the data member in class SgClassDefinitionStroageClass
   77400             :  * from its counterpart of SgClassDefinition. The return value is just for checking, 
   77401             :  * that the whole StorageClassArray is initialized!
   77402             :  */
   77403             : unsigned long
   77404           2 : SgClassDefinition::initializeStorageClassArray( SgClassDefinitionStorageClass *storageArray )
   77405             :    {
   77406           2 :      unsigned long storageCounter = 0;
   77407           2 :      std::vector < unsigned char* > :: const_iterator block = SgClassDefinition::pools.begin();
   77408           2 :      SgClassDefinition* pointer = NULL;
   77409           4 :      while ( block != SgClassDefinition::pools.end() ) {
   77410           2 :           pointer = (SgClassDefinition*) (*block);
   77411        4002 :           for ( unsigned i = 0; i < SgClassDefinition::pool_size; ++i ) {
   77412        4000 :                if ( pointer->get_freepointer() != NULL ) {
   77413         168 :                  storageArray->pickOutIRNodeData (pointer) ;
   77414         168 :                  storageArray++;
   77415         168 :                  storageCounter++;
   77416             :                }
   77417        4000 :                pointer++;
   77418             :              }
   77419           2 :            block++;
   77420             :         }
   77421           2 :      return storageCounter;
   77422             :    }
   77423             : 
   77424             : /* #line 77425 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   77425             : 
   77426             : 
   77427             : 
   77428             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   77429             : 
   77430             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   77431             : 
   77432             : //############################################################################
   77433             : /* JH (02/02/2006) Constructor of the IR node SgTemplateInstantiationDefn that takes its 
   77434             :  * corresponding StorageClass as parameter
   77435             :  */
   77436         601 : SgTemplateInstantiationDefn :: SgTemplateInstantiationDefn ( const SgTemplateInstantiationDefnStorageClass& storageSource )   : SgClassDefinition (storageSource)
   77437             :    {
   77438             : 
   77439             : 
   77440             : /* #line 77441 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   77441             : 
   77442         601 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   77443             : 
   77444             : 
   77445             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   77446             : 
   77447             : 
   77448         601 :    }
   77449             : 
   77450             : //############################################################################
   77451             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   77452             :  * within the working AST. 
   77453             :  */
   77454       15069 : SgTemplateInstantiationDefn * SgTemplateInstantiationDefn::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   77455       15069 :      SgTemplateInstantiationDefn* returnPointer = NULL;
   77456       15069 :      if ( globalIndex != 0 )
   77457             :         {
   77458             : 
   77459             : #if FILE_IO_EXTRA_CHECK
   77460       15069 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateInstantiationDefn ) ) <= globalIndex ) ;
   77461       15069 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationDefn + 1 ) ) );
   77462             : #endif
   77463       15069 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationDefn )  
   77464       15069 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateInstantiationDefn );
   77465       15069 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationDefn::pool_size;
   77466       15069 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationDefn::pool_size;
   77467             : 
   77468             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   77469             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   77470             : 
   77471       15069 :           returnPointer = &( ( (SgTemplateInstantiationDefn*)(SgTemplateInstantiationDefn::pools[memoryBlock]) ) [positionInPool]) ;
   77472             : 
   77473       15069 :           ROSE_ASSERT( returnPointer != NULL ) ;
   77474             :         }
   77475       15069 :      return returnPointer ;
   77476             :    }
   77477             : 
   77478             : //############################################################################
   77479             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   77480             :   for the AST with the index astIndex
   77481             : */
   77482           0 : SgTemplateInstantiationDefn * SgTemplateInstantiationDefn::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   77483           0 :      SgTemplateInstantiationDefn* returnPointer = NULL;
   77484           0 :      if ( globalIndex != 0 )
   77485             :         {
   77486             : 
   77487             : #if FILE_IO_EXTRA_CHECK
   77488           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateInstantiationDefn ) ) <= globalIndex ) ;
   77489           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationDefn + 1 ) ) );
   77490             : #endif
   77491           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationDefn )
   77492           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateInstantiationDefn );
   77493           0 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationDefn::pool_size ;
   77494           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationDefn::pool_size ;
   77495             : 
   77496             : #if FILE_IO_EXTRA_CHECK
   77497             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   77498             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   77499             : #endif
   77500             : 
   77501           0 :           returnPointer = &( ( (SgTemplateInstantiationDefn*)(SgTemplateInstantiationDefn::pools[memoryBlock]) ) [positionInPool]) ;
   77502             : 
   77503             : #if FILE_IO_EXTRA_CHECK
   77504           0 :           assert ( returnPointer != NULL ) ;
   77505             : #endif
   77506             :         }
   77507           0 :      return returnPointer ;
   77508             :    }
   77509             : 
   77510             : //############################################################################
   77511             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   77512             :  * pool size! We set for every valid object in the memory pool the freepointer
   77513             :  * to the global index and increase the global index afterwards. For all the 
   77514             :  * invalid objects (means address ranges within the memory pool that were not
   77515             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   77516             :  * distinguish valid from invalid objects! 
   77517             :  */
   77518             : unsigned long
   77519           5 : SgTemplateInstantiationDefn::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   77520             :    {
   77521           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   77522           5 :      SgTemplateInstantiationDefn* pointer = NULL;
   77523           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   77524           5 :      std::vector < unsigned char* > :: const_iterator block;
   77525           6 :      for ( block = SgTemplateInstantiationDefn::pools.begin(); block != SgTemplateInstantiationDefn::pools.end() ; ++block )
   77526             :         {
   77527           1 :           pointer = (SgTemplateInstantiationDefn*)(*block);
   77528        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationDefn::pool_size; ++i )
   77529             :              {
   77530             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   77531             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   77532             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   77533             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   77534             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   77535             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   77536             :             // properly; so this will have to be checked next.
   77537             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   77538             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   77539        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   77540             :                   {
   77541         601 :                     pointer[i].set_freepointer((SgTemplateInstantiationDefn*)(globalIndex));
   77542         601 :                     globalIndex++;
   77543             :                   }
   77544             :                else
   77545             :                   {
   77546        1399 :                     pointer[i].set_freepointer(NULL);
   77547             :                   }
   77548             :               }
   77549             :         }
   77550           5 :      return globalIndex;
   77551             :    }
   77552             : 
   77553             : //############################################################################
   77554             : // JH (01/14/2006)
   77555             : void
   77556           5 : SgTemplateInstantiationDefn::resetValidFreepointers( )
   77557             :    {
   77558           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   77559           5 :      SgTemplateInstantiationDefn* pointer = NULL;
   77560           5 :      std::vector < unsigned char* > :: const_iterator block;
   77561           5 :      SgTemplateInstantiationDefn* pointerOfLinkedList = NULL;
   77562           6 :      for ( block = SgTemplateInstantiationDefn::pools.begin(); block != SgTemplateInstantiationDefn::pools.end() ; ++block )
   77563             :         {
   77564           1 :           pointer = (SgTemplateInstantiationDefn*)(*block);
   77565        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationDefn::pool_size; ++i )
   77566             :              {
   77567             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   77568             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   77569             :             // memory blocks!.
   77570        2000 :                if ( pointer[i].get_freepointer() != NULL )
   77571             :                   {
   77572         601 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   77573             :                   }
   77574             :                else
   77575             :                   {
   77576        1399 :                     if ( pointerOfLinkedList == NULL )
   77577             :                        {
   77578           1 :                          SgTemplateInstantiationDefn::next_node = &(pointer[i]);
   77579             :                        }
   77580             :                     else
   77581             :                        {
   77582             :                       // printf ("In SgTemplateInstantiationDefn::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   77583        1398 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   77584             :                        }
   77585             :                     pointerOfLinkedList = &(pointer[i]);
   77586             :                   }
   77587             :               }
   77588             :         }
   77589             : 
   77590           5 :      if ( pointerOfLinkedList != NULL )
   77591             :         {
   77592             :        // printf ("In SgTemplateInstantiationDefn::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   77593           1 :           pointerOfLinkedList->set_freepointer(NULL);
   77594             :        // DQ (6/6/2010): Temporary debugging...
   77595             :        //   ROSE_ASSERT(false);
   77596             :         }
   77597             : 
   77598           5 :      return ;
   77599             :    }
   77600             : 
   77601             : //############################################################################
   77602             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   77603             :  * within the memory pool and resets the freepointers, in order to achieve a 
   77604             :  * linked list, that has no jumps and starts at the beginning! This function 
   77605             :  * does not extend the memory pool, since we do not delete any memory blocks,
   77606             :  * but delete the valid objects.  
   77607             :  */
   77608             : void
   77609           0 : SgTemplateInstantiationDefn::clearMemoryPool( )
   77610             :    {
   77611             :   // printf ("Inside of SgTemplateInstantiationDefn::clearMemoryPool() \n");
   77612             : 
   77613           0 :      SgTemplateInstantiationDefn* pointer = NULL, *tempPointer = NULL;
   77614           0 :      std::vector < unsigned char* > :: const_iterator block;
   77615           0 :      if ( SgTemplateInstantiationDefn::pools.empty() == false )
   77616             :         {
   77617           0 :           block = SgTemplateInstantiationDefn::pools.begin() ;
   77618           0 :           SgTemplateInstantiationDefn::next_node = (SgTemplateInstantiationDefn*) (*block);
   77619             : 
   77620           0 :           while ( block != SgTemplateInstantiationDefn::pools.end() )
   77621             :              {
   77622           0 :                pointer = (SgTemplateInstantiationDefn*) (*block);
   77623           0 :                if ( tempPointer != NULL )
   77624             :                   {
   77625           0 :                     tempPointer->set_freepointer(pointer);
   77626             :                   }
   77627           0 :                for (unsigned i = 0; i < SgTemplateInstantiationDefn::pool_size - 1; ++i)
   77628             :                   {
   77629           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   77630             :                   }
   77631           0 :                 pointer[SgTemplateInstantiationDefn::pool_size-1].set_freepointer(NULL);
   77632           0 :                 tempPointer = &(pointer[SgTemplateInstantiationDefn::pool_size-1]);
   77633           0 :                 ++block;
   77634             :              }
   77635             :         }
   77636           0 :    }
   77637             : 
   77638           5 : void SgTemplateInstantiationDefn::deleteMemoryPool() {
   77639           7 :   for (auto p: SgTemplateInstantiationDefn::pools) {
   77640           2 :     ROSE_FREE(p);
   77641             :   }
   77642           5 :   SgTemplateInstantiationDefn::next_node = nullptr;
   77643           5 :   SgTemplateInstantiationDefn::pools.clear();
   77644           5 : }
   77645             : 
   77646             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   77647             : //                 reading multiple binary files to for a single AST.
   77648             : /////////// new version ////////////////////////////////
   77649             : //############################################################################
   77650             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   77651             : void
   77652           2 : SgTemplateInstantiationDefn::extendMemoryPoolForFileIO( )
   77653             :   {
   77654           2 :     size_t blockIndex = SgTemplateInstantiationDefn::pools.size();
   77655           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDefn) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDefn);
   77656             : 
   77657           3 :     while ( (blockIndex * SgTemplateInstantiationDefn::pool_size) < newPoolSize)
   77658             :       {
   77659             : #if ROSE_ALLOC_TRACE
   77660             :         if (blockIndex > 0) {
   77661             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDefn) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDefn) = %" PRIuPTR " SgTemplateInstantiationDefn::pool_size = %d \n",
   77662             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDefn),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDefn),SgTemplateInstantiationDefn::pool_size);
   77663             :         }
   77664             : #endif
   77665             : 
   77666           1 :         SgTemplateInstantiationDefn * pointer = (SgTemplateInstantiationDefn*) ROSE_MALLOC ( SgTemplateInstantiationDefn::pool_size * sizeof(SgTemplateInstantiationDefn) );
   77667           1 :         assert( pointer != NULL );
   77668             : #if ROSE_ALLOC_MEMSET == 1
   77669             :         memset(pointer, 0x00, SgTemplateInstantiationDefn::pool_size * sizeof(SgTemplateInstantiationDefn));
   77670             : #elif ROSE_ALLOC_MEMSET == 2
   77671             :         memset(pointer, 0xCC, SgTemplateInstantiationDefn::pool_size * sizeof(SgTemplateInstantiationDefn));
   77672             : #endif
   77673           1 :         SgTemplateInstantiationDefn::pools.push_back( (unsigned char*)(pointer) );
   77674           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateInstantiationDefn::pool_size * sizeof(SgTemplateInstantiationDefn), V_SgTemplateInstantiationDefn ) );
   77675             : 
   77676           1 :         if ( SgTemplateInstantiationDefn::next_node != NULL ) {
   77677           0 :           if ( blockIndex > 0 ) {
   77678           0 :             SgTemplateInstantiationDefn * blkptr = (SgTemplateInstantiationDefn*)(SgTemplateInstantiationDefn::pools[blockIndex-1]);
   77679           0 :             blkptr[ SgTemplateInstantiationDefn::pool_size - 1 ].set_freepointer(pointer);
   77680             :           }
   77681             :         } else {
   77682           1 :           SgTemplateInstantiationDefn::next_node = pointer;
   77683             :         }
   77684             : 
   77685        2000 :         for (unsigned i = 0; i < SgTemplateInstantiationDefn::pool_size-1; ++i)
   77686             :            {
   77687        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   77688             :            }
   77689           1 :         pointer[ SgTemplateInstantiationDefn::pool_size -1 ].set_freepointer(NULL);
   77690             : 
   77691           1 :         blockIndex++;
   77692             :       }
   77693           2 :   }
   77694             : 
   77695             : //############################################################################
   77696             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   77697             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   77698             :  * not compressed. However, that stuff is not yet implemented! 
   77699             :  */
   77700             : unsigned long
   77701           0 : SgTemplateInstantiationDefn::getNumberOfLastValidPointer()
   77702             :    {
   77703           0 :       SgTemplateInstantiationDefn* testPointer = (SgTemplateInstantiationDefn*)(SgTemplateInstantiationDefn::pools.back());
   77704           0 :       unsigned long localIndex = SgTemplateInstantiationDefn::pool_size - 1;
   77705           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   77706             :          {
   77707           0 :            localIndex--;
   77708             :          }
   77709           0 :       return (localIndex + SgTemplateInstantiationDefn::pool_size * (SgTemplateInstantiationDefn::pools.size()-1));
   77710             :    }
   77711             : 
   77712             : //############################################################################
   77713             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   77714             :  * memory pool and initializes the data member in class SgTemplateInstantiationDefnStroageClass
   77715             :  * from its counterpart of SgTemplateInstantiationDefn. The return value is just for checking, 
   77716             :  * that the whole StorageClassArray is initialized!
   77717             :  */
   77718             : unsigned long
   77719           1 : SgTemplateInstantiationDefn::initializeStorageClassArray( SgTemplateInstantiationDefnStorageClass *storageArray )
   77720             :    {
   77721           1 :      unsigned long storageCounter = 0;
   77722           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateInstantiationDefn::pools.begin();
   77723           1 :      SgTemplateInstantiationDefn* pointer = NULL;
   77724           2 :      while ( block != SgTemplateInstantiationDefn::pools.end() ) {
   77725           1 :           pointer = (SgTemplateInstantiationDefn*) (*block);
   77726        2001 :           for ( unsigned i = 0; i < SgTemplateInstantiationDefn::pool_size; ++i ) {
   77727        2000 :                if ( pointer->get_freepointer() != NULL ) {
   77728         601 :                  storageArray->pickOutIRNodeData (pointer) ;
   77729         601 :                  storageArray++;
   77730         601 :                  storageCounter++;
   77731             :                }
   77732        2000 :                pointer++;
   77733             :              }
   77734           1 :            block++;
   77735             :         }
   77736           1 :      return storageCounter;
   77737             :    }
   77738             : 
   77739             : /* #line 77740 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   77740             : 
   77741             : 
   77742             : 
   77743             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   77744             : 
   77745             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   77746             : 
   77747             : //############################################################################
   77748             : /* JH (02/02/2006) Constructor of the IR node SgTemplateClassDefinition that takes its 
   77749             :  * corresponding StorageClass as parameter
   77750             :  */
   77751         506 : SgTemplateClassDefinition :: SgTemplateClassDefinition ( const SgTemplateClassDefinitionStorageClass& storageSource )   : SgClassDefinition (storageSource)
   77752             :    {
   77753             : 
   77754             : 
   77755             : /* #line 77756 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   77756             : 
   77757         506 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   77758             : 
   77759             : 
   77760             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   77761             : 
   77762             : 
   77763         506 :    }
   77764             : 
   77765             : //############################################################################
   77766             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   77767             :  * within the working AST. 
   77768             :  */
   77769        7932 : SgTemplateClassDefinition * SgTemplateClassDefinition::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   77770        7932 :      SgTemplateClassDefinition* returnPointer = NULL;
   77771        7932 :      if ( globalIndex != 0 )
   77772             :         {
   77773             : 
   77774             : #if FILE_IO_EXTRA_CHECK
   77775        7932 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateClassDefinition ) ) <= globalIndex ) ;
   77776        7932 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateClassDefinition + 1 ) ) );
   77777             : #endif
   77778        7932 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateClassDefinition )  
   77779        7932 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateClassDefinition );
   77780        7932 :           unsigned long positionInPool = localIndex % SgTemplateClassDefinition::pool_size;
   77781        7932 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateClassDefinition::pool_size;
   77782             : 
   77783             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   77784             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   77785             : 
   77786        7932 :           returnPointer = &( ( (SgTemplateClassDefinition*)(SgTemplateClassDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   77787             : 
   77788        7932 :           ROSE_ASSERT( returnPointer != NULL ) ;
   77789             :         }
   77790        7932 :      return returnPointer ;
   77791             :    }
   77792             : 
   77793             : //############################################################################
   77794             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   77795             :   for the AST with the index astIndex
   77796             : */
   77797           0 : SgTemplateClassDefinition * SgTemplateClassDefinition::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   77798           0 :      SgTemplateClassDefinition* returnPointer = NULL;
   77799           0 :      if ( globalIndex != 0 )
   77800             :         {
   77801             : 
   77802             : #if FILE_IO_EXTRA_CHECK
   77803           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateClassDefinition ) ) <= globalIndex ) ;
   77804           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateClassDefinition + 1 ) ) );
   77805             : #endif
   77806           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateClassDefinition )
   77807           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateClassDefinition );
   77808           0 :           unsigned long positionInPool = localIndex % SgTemplateClassDefinition::pool_size ;
   77809           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateClassDefinition::pool_size ;
   77810             : 
   77811             : #if FILE_IO_EXTRA_CHECK
   77812             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   77813             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   77814             : #endif
   77815             : 
   77816           0 :           returnPointer = &( ( (SgTemplateClassDefinition*)(SgTemplateClassDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   77817             : 
   77818             : #if FILE_IO_EXTRA_CHECK
   77819           0 :           assert ( returnPointer != NULL ) ;
   77820             : #endif
   77821             :         }
   77822           0 :      return returnPointer ;
   77823             :    }
   77824             : 
   77825             : //############################################################################
   77826             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   77827             :  * pool size! We set for every valid object in the memory pool the freepointer
   77828             :  * to the global index and increase the global index afterwards. For all the 
   77829             :  * invalid objects (means address ranges within the memory pool that were not
   77830             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   77831             :  * distinguish valid from invalid objects! 
   77832             :  */
   77833             : unsigned long
   77834           5 : SgTemplateClassDefinition::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   77835             :    {
   77836           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   77837           5 :      SgTemplateClassDefinition* pointer = NULL;
   77838           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   77839           5 :      std::vector < unsigned char* > :: const_iterator block;
   77840           6 :      for ( block = SgTemplateClassDefinition::pools.begin(); block != SgTemplateClassDefinition::pools.end() ; ++block )
   77841             :         {
   77842           1 :           pointer = (SgTemplateClassDefinition*)(*block);
   77843        2001 :           for (unsigned i = 0; i < SgTemplateClassDefinition::pool_size; ++i )
   77844             :              {
   77845             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   77846             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   77847             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   77848             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   77849             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   77850             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   77851             :             // properly; so this will have to be checked next.
   77852             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   77853             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   77854        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   77855             :                   {
   77856         506 :                     pointer[i].set_freepointer((SgTemplateClassDefinition*)(globalIndex));
   77857         506 :                     globalIndex++;
   77858             :                   }
   77859             :                else
   77860             :                   {
   77861        1494 :                     pointer[i].set_freepointer(NULL);
   77862             :                   }
   77863             :               }
   77864             :         }
   77865           5 :      return globalIndex;
   77866             :    }
   77867             : 
   77868             : //############################################################################
   77869             : // JH (01/14/2006)
   77870             : void
   77871           5 : SgTemplateClassDefinition::resetValidFreepointers( )
   77872             :    {
   77873           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   77874           5 :      SgTemplateClassDefinition* pointer = NULL;
   77875           5 :      std::vector < unsigned char* > :: const_iterator block;
   77876           5 :      SgTemplateClassDefinition* pointerOfLinkedList = NULL;
   77877           6 :      for ( block = SgTemplateClassDefinition::pools.begin(); block != SgTemplateClassDefinition::pools.end() ; ++block )
   77878             :         {
   77879           1 :           pointer = (SgTemplateClassDefinition*)(*block);
   77880        2001 :           for (unsigned i = 0; i < SgTemplateClassDefinition::pool_size; ++i )
   77881             :              {
   77882             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   77883             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   77884             :             // memory blocks!.
   77885        2000 :                if ( pointer[i].get_freepointer() != NULL )
   77886             :                   {
   77887         506 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   77888             :                   }
   77889             :                else
   77890             :                   {
   77891        1494 :                     if ( pointerOfLinkedList == NULL )
   77892             :                        {
   77893           1 :                          SgTemplateClassDefinition::next_node = &(pointer[i]);
   77894             :                        }
   77895             :                     else
   77896             :                        {
   77897             :                       // printf ("In SgTemplateClassDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   77898        1493 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   77899             :                        }
   77900             :                     pointerOfLinkedList = &(pointer[i]);
   77901             :                   }
   77902             :               }
   77903             :         }
   77904             : 
   77905           5 :      if ( pointerOfLinkedList != NULL )
   77906             :         {
   77907             :        // printf ("In SgTemplateClassDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   77908           1 :           pointerOfLinkedList->set_freepointer(NULL);
   77909             :        // DQ (6/6/2010): Temporary debugging...
   77910             :        //   ROSE_ASSERT(false);
   77911             :         }
   77912             : 
   77913           5 :      return ;
   77914             :    }
   77915             : 
   77916             : //############################################################################
   77917             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   77918             :  * within the memory pool and resets the freepointers, in order to achieve a 
   77919             :  * linked list, that has no jumps and starts at the beginning! This function 
   77920             :  * does not extend the memory pool, since we do not delete any memory blocks,
   77921             :  * but delete the valid objects.  
   77922             :  */
   77923             : void
   77924           0 : SgTemplateClassDefinition::clearMemoryPool( )
   77925             :    {
   77926             :   // printf ("Inside of SgTemplateClassDefinition::clearMemoryPool() \n");
   77927             : 
   77928           0 :      SgTemplateClassDefinition* pointer = NULL, *tempPointer = NULL;
   77929           0 :      std::vector < unsigned char* > :: const_iterator block;
   77930           0 :      if ( SgTemplateClassDefinition::pools.empty() == false )
   77931             :         {
   77932           0 :           block = SgTemplateClassDefinition::pools.begin() ;
   77933           0 :           SgTemplateClassDefinition::next_node = (SgTemplateClassDefinition*) (*block);
   77934             : 
   77935           0 :           while ( block != SgTemplateClassDefinition::pools.end() )
   77936             :              {
   77937           0 :                pointer = (SgTemplateClassDefinition*) (*block);
   77938           0 :                if ( tempPointer != NULL )
   77939             :                   {
   77940           0 :                     tempPointer->set_freepointer(pointer);
   77941             :                   }
   77942           0 :                for (unsigned i = 0; i < SgTemplateClassDefinition::pool_size - 1; ++i)
   77943             :                   {
   77944           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   77945             :                   }
   77946           0 :                 pointer[SgTemplateClassDefinition::pool_size-1].set_freepointer(NULL);
   77947           0 :                 tempPointer = &(pointer[SgTemplateClassDefinition::pool_size-1]);
   77948           0 :                 ++block;
   77949             :              }
   77950             :         }
   77951           0 :    }
   77952             : 
   77953           5 : void SgTemplateClassDefinition::deleteMemoryPool() {
   77954           7 :   for (auto p: SgTemplateClassDefinition::pools) {
   77955           2 :     ROSE_FREE(p);
   77956             :   }
   77957           5 :   SgTemplateClassDefinition::next_node = nullptr;
   77958           5 :   SgTemplateClassDefinition::pools.clear();
   77959           5 : }
   77960             : 
   77961             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   77962             : //                 reading multiple binary files to for a single AST.
   77963             : /////////// new version ////////////////////////////////
   77964             : //############################################################################
   77965             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   77966             : void
   77967           2 : SgTemplateClassDefinition::extendMemoryPoolForFileIO( )
   77968             :   {
   77969           2 :     size_t blockIndex = SgTemplateClassDefinition::pools.size();
   77970           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassDefinition) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassDefinition);
   77971             : 
   77972           3 :     while ( (blockIndex * SgTemplateClassDefinition::pool_size) < newPoolSize)
   77973             :       {
   77974             : #if ROSE_ALLOC_TRACE
   77975             :         if (blockIndex > 0) {
   77976             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassDefinition) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassDefinition) = %" PRIuPTR " SgTemplateClassDefinition::pool_size = %d \n",
   77977             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassDefinition),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassDefinition),SgTemplateClassDefinition::pool_size);
   77978             :         }
   77979             : #endif
   77980             : 
   77981           1 :         SgTemplateClassDefinition * pointer = (SgTemplateClassDefinition*) ROSE_MALLOC ( SgTemplateClassDefinition::pool_size * sizeof(SgTemplateClassDefinition) );
   77982           1 :         assert( pointer != NULL );
   77983             : #if ROSE_ALLOC_MEMSET == 1
   77984             :         memset(pointer, 0x00, SgTemplateClassDefinition::pool_size * sizeof(SgTemplateClassDefinition));
   77985             : #elif ROSE_ALLOC_MEMSET == 2
   77986             :         memset(pointer, 0xCC, SgTemplateClassDefinition::pool_size * sizeof(SgTemplateClassDefinition));
   77987             : #endif
   77988           1 :         SgTemplateClassDefinition::pools.push_back( (unsigned char*)(pointer) );
   77989           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateClassDefinition::pool_size * sizeof(SgTemplateClassDefinition), V_SgTemplateClassDefinition ) );
   77990             : 
   77991           1 :         if ( SgTemplateClassDefinition::next_node != NULL ) {
   77992           0 :           if ( blockIndex > 0 ) {
   77993           0 :             SgTemplateClassDefinition * blkptr = (SgTemplateClassDefinition*)(SgTemplateClassDefinition::pools[blockIndex-1]);
   77994           0 :             blkptr[ SgTemplateClassDefinition::pool_size - 1 ].set_freepointer(pointer);
   77995             :           }
   77996             :         } else {
   77997           1 :           SgTemplateClassDefinition::next_node = pointer;
   77998             :         }
   77999             : 
   78000        2000 :         for (unsigned i = 0; i < SgTemplateClassDefinition::pool_size-1; ++i)
   78001             :            {
   78002        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   78003             :            }
   78004           1 :         pointer[ SgTemplateClassDefinition::pool_size -1 ].set_freepointer(NULL);
   78005             : 
   78006           1 :         blockIndex++;
   78007             :       }
   78008           2 :   }
   78009             : 
   78010             : //############################################################################
   78011             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   78012             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   78013             :  * not compressed. However, that stuff is not yet implemented! 
   78014             :  */
   78015             : unsigned long
   78016           0 : SgTemplateClassDefinition::getNumberOfLastValidPointer()
   78017             :    {
   78018           0 :       SgTemplateClassDefinition* testPointer = (SgTemplateClassDefinition*)(SgTemplateClassDefinition::pools.back());
   78019           0 :       unsigned long localIndex = SgTemplateClassDefinition::pool_size - 1;
   78020           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   78021             :          {
   78022           0 :            localIndex--;
   78023             :          }
   78024           0 :       return (localIndex + SgTemplateClassDefinition::pool_size * (SgTemplateClassDefinition::pools.size()-1));
   78025             :    }
   78026             : 
   78027             : //############################################################################
   78028             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   78029             :  * memory pool and initializes the data member in class SgTemplateClassDefinitionStroageClass
   78030             :  * from its counterpart of SgTemplateClassDefinition. The return value is just for checking, 
   78031             :  * that the whole StorageClassArray is initialized!
   78032             :  */
   78033             : unsigned long
   78034           1 : SgTemplateClassDefinition::initializeStorageClassArray( SgTemplateClassDefinitionStorageClass *storageArray )
   78035             :    {
   78036           1 :      unsigned long storageCounter = 0;
   78037           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateClassDefinition::pools.begin();
   78038           1 :      SgTemplateClassDefinition* pointer = NULL;
   78039           2 :      while ( block != SgTemplateClassDefinition::pools.end() ) {
   78040           1 :           pointer = (SgTemplateClassDefinition*) (*block);
   78041        2001 :           for ( unsigned i = 0; i < SgTemplateClassDefinition::pool_size; ++i ) {
   78042        2000 :                if ( pointer->get_freepointer() != NULL ) {
   78043         506 :                  storageArray->pickOutIRNodeData (pointer) ;
   78044         506 :                  storageArray++;
   78045         506 :                  storageCounter++;
   78046             :                }
   78047        2000 :                pointer++;
   78048             :              }
   78049           1 :            block++;
   78050             :         }
   78051           1 :      return storageCounter;
   78052             :    }
   78053             : 
   78054             : /* #line 78055 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   78055             : 
   78056             : 
   78057             : 
   78058             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   78059             : 
   78060             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   78061             : 
   78062             : //############################################################################
   78063             : /* JH (02/02/2006) Constructor of the IR node SgWhileStmt that takes its 
   78064             :  * corresponding StorageClass as parameter
   78065             :  */
   78066          47 : SgWhileStmt :: SgWhileStmt ( const SgWhileStmtStorageClass& storageSource )   : SgScopeStatement (storageSource)
   78067             :    {
   78068             : 
   78069             : 
   78070             : /* #line 78071 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   78071             : 
   78072          47 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   78073          47 :      p_condition =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_condition) );
   78074          47 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   78075          47 :      p_else_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_else_body) );
   78076          47 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   78077          47 :      p_string_label = storageSource.storageOf_string_label.rebuildDataStoredInEasyStorageClass() ;
   78078          47 :      p_has_end_statement = storageSource.storageOf_has_end_statement ;
   78079             : 
   78080             : 
   78081             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   78082             : 
   78083             : 
   78084          47 :    }
   78085             : 
   78086             : //############################################################################
   78087             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   78088             :  * within the working AST. 
   78089             :  */
   78090         335 : SgWhileStmt * SgWhileStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   78091         335 :      SgWhileStmt* returnPointer = NULL;
   78092         335 :      if ( globalIndex != 0 )
   78093             :         {
   78094             : 
   78095             : #if FILE_IO_EXTRA_CHECK
   78096         335 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgWhileStmt ) ) <= globalIndex ) ;
   78097         335 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWhileStmt + 1 ) ) );
   78098             : #endif
   78099         335 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWhileStmt )  
   78100         335 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgWhileStmt );
   78101         335 :           unsigned long positionInPool = localIndex % SgWhileStmt::pool_size;
   78102         335 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWhileStmt::pool_size;
   78103             : 
   78104             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   78105             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   78106             : 
   78107         335 :           returnPointer = &( ( (SgWhileStmt*)(SgWhileStmt::pools[memoryBlock]) ) [positionInPool]) ;
   78108             : 
   78109         335 :           ROSE_ASSERT( returnPointer != NULL ) ;
   78110             :         }
   78111         335 :      return returnPointer ;
   78112             :    }
   78113             : 
   78114             : //############################################################################
   78115             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   78116             :   for the AST with the index astIndex
   78117             : */
   78118           0 : SgWhileStmt * SgWhileStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   78119           0 :      SgWhileStmt* returnPointer = NULL;
   78120           0 :      if ( globalIndex != 0 )
   78121             :         {
   78122             : 
   78123             : #if FILE_IO_EXTRA_CHECK
   78124           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgWhileStmt ) ) <= globalIndex ) ;
   78125           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWhileStmt + 1 ) ) );
   78126             : #endif
   78127           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWhileStmt )
   78128           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgWhileStmt );
   78129           0 :           unsigned long positionInPool = localIndex % SgWhileStmt::pool_size ;
   78130           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWhileStmt::pool_size ;
   78131             : 
   78132             : #if FILE_IO_EXTRA_CHECK
   78133             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   78134             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   78135             : #endif
   78136             : 
   78137           0 :           returnPointer = &( ( (SgWhileStmt*)(SgWhileStmt::pools[memoryBlock]) ) [positionInPool]) ;
   78138             : 
   78139             : #if FILE_IO_EXTRA_CHECK
   78140           0 :           assert ( returnPointer != NULL ) ;
   78141             : #endif
   78142             :         }
   78143           0 :      return returnPointer ;
   78144             :    }
   78145             : 
   78146             : //############################################################################
   78147             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   78148             :  * pool size! We set for every valid object in the memory pool the freepointer
   78149             :  * to the global index and increase the global index afterwards. For all the 
   78150             :  * invalid objects (means address ranges within the memory pool that were not
   78151             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   78152             :  * distinguish valid from invalid objects! 
   78153             :  */
   78154             : unsigned long
   78155           5 : SgWhileStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   78156             :    {
   78157           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   78158           5 :      SgWhileStmt* pointer = NULL;
   78159           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   78160           5 :      std::vector < unsigned char* > :: const_iterator block;
   78161           6 :      for ( block = SgWhileStmt::pools.begin(); block != SgWhileStmt::pools.end() ; ++block )
   78162             :         {
   78163           1 :           pointer = (SgWhileStmt*)(*block);
   78164        2001 :           for (unsigned i = 0; i < SgWhileStmt::pool_size; ++i )
   78165             :              {
   78166             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   78167             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   78168             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   78169             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   78170             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   78171             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   78172             :             // properly; so this will have to be checked next.
   78173             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   78174             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   78175        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   78176             :                   {
   78177          47 :                     pointer[i].set_freepointer((SgWhileStmt*)(globalIndex));
   78178          47 :                     globalIndex++;
   78179             :                   }
   78180             :                else
   78181             :                   {
   78182        1953 :                     pointer[i].set_freepointer(NULL);
   78183             :                   }
   78184             :               }
   78185             :         }
   78186           5 :      return globalIndex;
   78187             :    }
   78188             : 
   78189             : //############################################################################
   78190             : // JH (01/14/2006)
   78191             : void
   78192           5 : SgWhileStmt::resetValidFreepointers( )
   78193             :    {
   78194           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   78195           5 :      SgWhileStmt* pointer = NULL;
   78196           5 :      std::vector < unsigned char* > :: const_iterator block;
   78197           5 :      SgWhileStmt* pointerOfLinkedList = NULL;
   78198           6 :      for ( block = SgWhileStmt::pools.begin(); block != SgWhileStmt::pools.end() ; ++block )
   78199             :         {
   78200           1 :           pointer = (SgWhileStmt*)(*block);
   78201        2001 :           for (unsigned i = 0; i < SgWhileStmt::pool_size; ++i )
   78202             :              {
   78203             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   78204             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   78205             :             // memory blocks!.
   78206        2000 :                if ( pointer[i].get_freepointer() != NULL )
   78207             :                   {
   78208          47 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   78209             :                   }
   78210             :                else
   78211             :                   {
   78212        1953 :                     if ( pointerOfLinkedList == NULL )
   78213             :                        {
   78214           1 :                          SgWhileStmt::next_node = &(pointer[i]);
   78215             :                        }
   78216             :                     else
   78217             :                        {
   78218             :                       // printf ("In SgWhileStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   78219        1952 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   78220             :                        }
   78221             :                     pointerOfLinkedList = &(pointer[i]);
   78222             :                   }
   78223             :               }
   78224             :         }
   78225             : 
   78226           5 :      if ( pointerOfLinkedList != NULL )
   78227             :         {
   78228             :        // printf ("In SgWhileStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   78229           1 :           pointerOfLinkedList->set_freepointer(NULL);
   78230             :        // DQ (6/6/2010): Temporary debugging...
   78231             :        //   ROSE_ASSERT(false);
   78232             :         }
   78233             : 
   78234           5 :      return ;
   78235             :    }
   78236             : 
   78237             : //############################################################################
   78238             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   78239             :  * within the memory pool and resets the freepointers, in order to achieve a 
   78240             :  * linked list, that has no jumps and starts at the beginning! This function 
   78241             :  * does not extend the memory pool, since we do not delete any memory blocks,
   78242             :  * but delete the valid objects.  
   78243             :  */
   78244             : void
   78245           0 : SgWhileStmt::clearMemoryPool( )
   78246             :    {
   78247             :   // printf ("Inside of SgWhileStmt::clearMemoryPool() \n");
   78248             : 
   78249           0 :      SgWhileStmt* pointer = NULL, *tempPointer = NULL;
   78250           0 :      std::vector < unsigned char* > :: const_iterator block;
   78251           0 :      if ( SgWhileStmt::pools.empty() == false )
   78252             :         {
   78253           0 :           block = SgWhileStmt::pools.begin() ;
   78254           0 :           SgWhileStmt::next_node = (SgWhileStmt*) (*block);
   78255             : 
   78256           0 :           while ( block != SgWhileStmt::pools.end() )
   78257             :              {
   78258           0 :                pointer = (SgWhileStmt*) (*block);
   78259           0 :                if ( tempPointer != NULL )
   78260             :                   {
   78261           0 :                     tempPointer->set_freepointer(pointer);
   78262             :                   }
   78263           0 :                for (unsigned i = 0; i < SgWhileStmt::pool_size - 1; ++i)
   78264             :                   {
   78265           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   78266             :                   }
   78267           0 :                 pointer[SgWhileStmt::pool_size-1].set_freepointer(NULL);
   78268           0 :                 tempPointer = &(pointer[SgWhileStmt::pool_size-1]);
   78269           0 :                 ++block;
   78270             :              }
   78271             :         }
   78272           0 :    }
   78273             : 
   78274           5 : void SgWhileStmt::deleteMemoryPool() {
   78275           7 :   for (auto p: SgWhileStmt::pools) {
   78276           2 :     ROSE_FREE(p);
   78277             :   }
   78278           5 :   SgWhileStmt::next_node = nullptr;
   78279           5 :   SgWhileStmt::pools.clear();
   78280           5 : }
   78281             : 
   78282             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   78283             : //                 reading multiple binary files to for a single AST.
   78284             : /////////// new version ////////////////////////////////
   78285             : //############################################################################
   78286             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   78287             : void
   78288           2 : SgWhileStmt::extendMemoryPoolForFileIO( )
   78289             :   {
   78290           2 :     size_t blockIndex = SgWhileStmt::pools.size();
   78291           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgWhileStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgWhileStmt);
   78292             : 
   78293           3 :     while ( (blockIndex * SgWhileStmt::pool_size) < newPoolSize)
   78294             :       {
   78295             : #if ROSE_ALLOC_TRACE
   78296             :         if (blockIndex > 0) {
   78297             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgWhileStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgWhileStmt) = %" PRIuPTR " SgWhileStmt::pool_size = %d \n",
   78298             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgWhileStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgWhileStmt),SgWhileStmt::pool_size);
   78299             :         }
   78300             : #endif
   78301             : 
   78302           1 :         SgWhileStmt * pointer = (SgWhileStmt*) ROSE_MALLOC ( SgWhileStmt::pool_size * sizeof(SgWhileStmt) );
   78303           1 :         assert( pointer != NULL );
   78304             : #if ROSE_ALLOC_MEMSET == 1
   78305             :         memset(pointer, 0x00, SgWhileStmt::pool_size * sizeof(SgWhileStmt));
   78306             : #elif ROSE_ALLOC_MEMSET == 2
   78307             :         memset(pointer, 0xCC, SgWhileStmt::pool_size * sizeof(SgWhileStmt));
   78308             : #endif
   78309           1 :         SgWhileStmt::pools.push_back( (unsigned char*)(pointer) );
   78310           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgWhileStmt::pool_size * sizeof(SgWhileStmt), V_SgWhileStmt ) );
   78311             : 
   78312           1 :         if ( SgWhileStmt::next_node != NULL ) {
   78313           0 :           if ( blockIndex > 0 ) {
   78314           0 :             SgWhileStmt * blkptr = (SgWhileStmt*)(SgWhileStmt::pools[blockIndex-1]);
   78315           0 :             blkptr[ SgWhileStmt::pool_size - 1 ].set_freepointer(pointer);
   78316             :           }
   78317             :         } else {
   78318           1 :           SgWhileStmt::next_node = pointer;
   78319             :         }
   78320             : 
   78321        2000 :         for (unsigned i = 0; i < SgWhileStmt::pool_size-1; ++i)
   78322             :            {
   78323        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   78324             :            }
   78325           1 :         pointer[ SgWhileStmt::pool_size -1 ].set_freepointer(NULL);
   78326             : 
   78327           1 :         blockIndex++;
   78328             :       }
   78329           2 :   }
   78330             : 
   78331             : //############################################################################
   78332             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   78333             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   78334             :  * not compressed. However, that stuff is not yet implemented! 
   78335             :  */
   78336             : unsigned long
   78337           0 : SgWhileStmt::getNumberOfLastValidPointer()
   78338             :    {
   78339           0 :       SgWhileStmt* testPointer = (SgWhileStmt*)(SgWhileStmt::pools.back());
   78340           0 :       unsigned long localIndex = SgWhileStmt::pool_size - 1;
   78341           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   78342             :          {
   78343           0 :            localIndex--;
   78344             :          }
   78345           0 :       return (localIndex + SgWhileStmt::pool_size * (SgWhileStmt::pools.size()-1));
   78346             :    }
   78347             : 
   78348             : //############################################################################
   78349             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   78350             :  * memory pool and initializes the data member in class SgWhileStmtStroageClass
   78351             :  * from its counterpart of SgWhileStmt. The return value is just for checking, 
   78352             :  * that the whole StorageClassArray is initialized!
   78353             :  */
   78354             : unsigned long
   78355           1 : SgWhileStmt::initializeStorageClassArray( SgWhileStmtStorageClass *storageArray )
   78356             :    {
   78357           1 :      unsigned long storageCounter = 0;
   78358           1 :      std::vector < unsigned char* > :: const_iterator block = SgWhileStmt::pools.begin();
   78359           1 :      SgWhileStmt* pointer = NULL;
   78360           2 :      while ( block != SgWhileStmt::pools.end() ) {
   78361           1 :           pointer = (SgWhileStmt*) (*block);
   78362        2001 :           for ( unsigned i = 0; i < SgWhileStmt::pool_size; ++i ) {
   78363        2000 :                if ( pointer->get_freepointer() != NULL ) {
   78364          47 :                  storageArray->pickOutIRNodeData (pointer) ;
   78365          47 :                  storageArray++;
   78366          47 :                  storageCounter++;
   78367             :                }
   78368        2000 :                pointer++;
   78369             :              }
   78370           1 :            block++;
   78371             :         }
   78372           1 :      return storageCounter;
   78373             :    }
   78374             : 
   78375             : /* #line 78376 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   78376             : 
   78377             : 
   78378             : 
   78379             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   78380             : 
   78381             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   78382             : 
   78383             : //############################################################################
   78384             : /* JH (02/02/2006) Constructor of the IR node SgDoWhileStmt that takes its 
   78385             :  * corresponding StorageClass as parameter
   78386             :  */
   78387           7 : SgDoWhileStmt :: SgDoWhileStmt ( const SgDoWhileStmtStorageClass& storageSource )   : SgScopeStatement (storageSource)
   78388             :    {
   78389             : 
   78390             : 
   78391             : /* #line 78392 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   78392             : 
   78393           7 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   78394           7 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   78395           7 :      p_condition =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_condition) );
   78396             : 
   78397             : 
   78398             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   78399             : 
   78400             : 
   78401           7 :    }
   78402             : 
   78403             : //############################################################################
   78404             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   78405             :  * within the working AST. 
   78406             :  */
   78407          49 : SgDoWhileStmt * SgDoWhileStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   78408          49 :      SgDoWhileStmt* returnPointer = NULL;
   78409          49 :      if ( globalIndex != 0 )
   78410             :         {
   78411             : 
   78412             : #if FILE_IO_EXTRA_CHECK
   78413          49 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDoWhileStmt ) ) <= globalIndex ) ;
   78414          49 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDoWhileStmt + 1 ) ) );
   78415             : #endif
   78416          49 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDoWhileStmt )  
   78417          49 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDoWhileStmt );
   78418          49 :           unsigned long positionInPool = localIndex % SgDoWhileStmt::pool_size;
   78419          49 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDoWhileStmt::pool_size;
   78420             : 
   78421             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   78422             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   78423             : 
   78424          49 :           returnPointer = &( ( (SgDoWhileStmt*)(SgDoWhileStmt::pools[memoryBlock]) ) [positionInPool]) ;
   78425             : 
   78426          49 :           ROSE_ASSERT( returnPointer != NULL ) ;
   78427             :         }
   78428          49 :      return returnPointer ;
   78429             :    }
   78430             : 
   78431             : //############################################################################
   78432             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   78433             :   for the AST with the index astIndex
   78434             : */
   78435           0 : SgDoWhileStmt * SgDoWhileStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   78436           0 :      SgDoWhileStmt* returnPointer = NULL;
   78437           0 :      if ( globalIndex != 0 )
   78438             :         {
   78439             : 
   78440             : #if FILE_IO_EXTRA_CHECK
   78441           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDoWhileStmt ) ) <= globalIndex ) ;
   78442           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDoWhileStmt + 1 ) ) );
   78443             : #endif
   78444           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDoWhileStmt )
   78445           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDoWhileStmt );
   78446           0 :           unsigned long positionInPool = localIndex % SgDoWhileStmt::pool_size ;
   78447           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDoWhileStmt::pool_size ;
   78448             : 
   78449             : #if FILE_IO_EXTRA_CHECK
   78450             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   78451             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   78452             : #endif
   78453             : 
   78454           0 :           returnPointer = &( ( (SgDoWhileStmt*)(SgDoWhileStmt::pools[memoryBlock]) ) [positionInPool]) ;
   78455             : 
   78456             : #if FILE_IO_EXTRA_CHECK
   78457           0 :           assert ( returnPointer != NULL ) ;
   78458             : #endif
   78459             :         }
   78460           0 :      return returnPointer ;
   78461             :    }
   78462             : 
   78463             : //############################################################################
   78464             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   78465             :  * pool size! We set for every valid object in the memory pool the freepointer
   78466             :  * to the global index and increase the global index afterwards. For all the 
   78467             :  * invalid objects (means address ranges within the memory pool that were not
   78468             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   78469             :  * distinguish valid from invalid objects! 
   78470             :  */
   78471             : unsigned long
   78472           5 : SgDoWhileStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   78473             :    {
   78474           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   78475           5 :      SgDoWhileStmt* pointer = NULL;
   78476           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   78477           5 :      std::vector < unsigned char* > :: const_iterator block;
   78478           6 :      for ( block = SgDoWhileStmt::pools.begin(); block != SgDoWhileStmt::pools.end() ; ++block )
   78479             :         {
   78480           1 :           pointer = (SgDoWhileStmt*)(*block);
   78481        2001 :           for (unsigned i = 0; i < SgDoWhileStmt::pool_size; ++i )
   78482             :              {
   78483             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   78484             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   78485             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   78486             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   78487             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   78488             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   78489             :             // properly; so this will have to be checked next.
   78490             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   78491             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   78492        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   78493             :                   {
   78494           7 :                     pointer[i].set_freepointer((SgDoWhileStmt*)(globalIndex));
   78495           7 :                     globalIndex++;
   78496             :                   }
   78497             :                else
   78498             :                   {
   78499        1993 :                     pointer[i].set_freepointer(NULL);
   78500             :                   }
   78501             :               }
   78502             :         }
   78503           5 :      return globalIndex;
   78504             :    }
   78505             : 
   78506             : //############################################################################
   78507             : // JH (01/14/2006)
   78508             : void
   78509           5 : SgDoWhileStmt::resetValidFreepointers( )
   78510             :    {
   78511           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   78512           5 :      SgDoWhileStmt* pointer = NULL;
   78513           5 :      std::vector < unsigned char* > :: const_iterator block;
   78514           5 :      SgDoWhileStmt* pointerOfLinkedList = NULL;
   78515           6 :      for ( block = SgDoWhileStmt::pools.begin(); block != SgDoWhileStmt::pools.end() ; ++block )
   78516             :         {
   78517           1 :           pointer = (SgDoWhileStmt*)(*block);
   78518        2001 :           for (unsigned i = 0; i < SgDoWhileStmt::pool_size; ++i )
   78519             :              {
   78520             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   78521             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   78522             :             // memory blocks!.
   78523        2000 :                if ( pointer[i].get_freepointer() != NULL )
   78524             :                   {
   78525           7 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   78526             :                   }
   78527             :                else
   78528             :                   {
   78529        1993 :                     if ( pointerOfLinkedList == NULL )
   78530             :                        {
   78531           1 :                          SgDoWhileStmt::next_node = &(pointer[i]);
   78532             :                        }
   78533             :                     else
   78534             :                        {
   78535             :                       // printf ("In SgDoWhileStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   78536        1992 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   78537             :                        }
   78538             :                     pointerOfLinkedList = &(pointer[i]);
   78539             :                   }
   78540             :               }
   78541             :         }
   78542             : 
   78543           5 :      if ( pointerOfLinkedList != NULL )
   78544             :         {
   78545             :        // printf ("In SgDoWhileStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   78546           1 :           pointerOfLinkedList->set_freepointer(NULL);
   78547             :        // DQ (6/6/2010): Temporary debugging...
   78548             :        //   ROSE_ASSERT(false);
   78549             :         }
   78550             : 
   78551           5 :      return ;
   78552             :    }
   78553             : 
   78554             : //############################################################################
   78555             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   78556             :  * within the memory pool and resets the freepointers, in order to achieve a 
   78557             :  * linked list, that has no jumps and starts at the beginning! This function 
   78558             :  * does not extend the memory pool, since we do not delete any memory blocks,
   78559             :  * but delete the valid objects.  
   78560             :  */
   78561             : void
   78562           0 : SgDoWhileStmt::clearMemoryPool( )
   78563             :    {
   78564             :   // printf ("Inside of SgDoWhileStmt::clearMemoryPool() \n");
   78565             : 
   78566           0 :      SgDoWhileStmt* pointer = NULL, *tempPointer = NULL;
   78567           0 :      std::vector < unsigned char* > :: const_iterator block;
   78568           0 :      if ( SgDoWhileStmt::pools.empty() == false )
   78569             :         {
   78570           0 :           block = SgDoWhileStmt::pools.begin() ;
   78571           0 :           SgDoWhileStmt::next_node = (SgDoWhileStmt*) (*block);
   78572             : 
   78573           0 :           while ( block != SgDoWhileStmt::pools.end() )
   78574             :              {
   78575           0 :                pointer = (SgDoWhileStmt*) (*block);
   78576           0 :                if ( tempPointer != NULL )
   78577             :                   {
   78578           0 :                     tempPointer->set_freepointer(pointer);
   78579             :                   }
   78580           0 :                for (unsigned i = 0; i < SgDoWhileStmt::pool_size - 1; ++i)
   78581             :                   {
   78582           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   78583             :                   }
   78584           0 :                 pointer[SgDoWhileStmt::pool_size-1].set_freepointer(NULL);
   78585           0 :                 tempPointer = &(pointer[SgDoWhileStmt::pool_size-1]);
   78586           0 :                 ++block;
   78587             :              }
   78588             :         }
   78589           0 :    }
   78590             : 
   78591           5 : void SgDoWhileStmt::deleteMemoryPool() {
   78592           7 :   for (auto p: SgDoWhileStmt::pools) {
   78593           2 :     ROSE_FREE(p);
   78594             :   }
   78595           5 :   SgDoWhileStmt::next_node = nullptr;
   78596           5 :   SgDoWhileStmt::pools.clear();
   78597           5 : }
   78598             : 
   78599             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   78600             : //                 reading multiple binary files to for a single AST.
   78601             : /////////// new version ////////////////////////////////
   78602             : //############################################################################
   78603             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   78604             : void
   78605           2 : SgDoWhileStmt::extendMemoryPoolForFileIO( )
   78606             :   {
   78607           2 :     size_t blockIndex = SgDoWhileStmt::pools.size();
   78608           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDoWhileStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDoWhileStmt);
   78609             : 
   78610           3 :     while ( (blockIndex * SgDoWhileStmt::pool_size) < newPoolSize)
   78611             :       {
   78612             : #if ROSE_ALLOC_TRACE
   78613             :         if (blockIndex > 0) {
   78614             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDoWhileStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDoWhileStmt) = %" PRIuPTR " SgDoWhileStmt::pool_size = %d \n",
   78615             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDoWhileStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDoWhileStmt),SgDoWhileStmt::pool_size);
   78616             :         }
   78617             : #endif
   78618             : 
   78619           1 :         SgDoWhileStmt * pointer = (SgDoWhileStmt*) ROSE_MALLOC ( SgDoWhileStmt::pool_size * sizeof(SgDoWhileStmt) );
   78620           1 :         assert( pointer != NULL );
   78621             : #if ROSE_ALLOC_MEMSET == 1
   78622             :         memset(pointer, 0x00, SgDoWhileStmt::pool_size * sizeof(SgDoWhileStmt));
   78623             : #elif ROSE_ALLOC_MEMSET == 2
   78624             :         memset(pointer, 0xCC, SgDoWhileStmt::pool_size * sizeof(SgDoWhileStmt));
   78625             : #endif
   78626           1 :         SgDoWhileStmt::pools.push_back( (unsigned char*)(pointer) );
   78627           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDoWhileStmt::pool_size * sizeof(SgDoWhileStmt), V_SgDoWhileStmt ) );
   78628             : 
   78629           1 :         if ( SgDoWhileStmt::next_node != NULL ) {
   78630           0 :           if ( blockIndex > 0 ) {
   78631           0 :             SgDoWhileStmt * blkptr = (SgDoWhileStmt*)(SgDoWhileStmt::pools[blockIndex-1]);
   78632           0 :             blkptr[ SgDoWhileStmt::pool_size - 1 ].set_freepointer(pointer);
   78633             :           }
   78634             :         } else {
   78635           1 :           SgDoWhileStmt::next_node = pointer;
   78636             :         }
   78637             : 
   78638        2000 :         for (unsigned i = 0; i < SgDoWhileStmt::pool_size-1; ++i)
   78639             :            {
   78640        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   78641             :            }
   78642           1 :         pointer[ SgDoWhileStmt::pool_size -1 ].set_freepointer(NULL);
   78643             : 
   78644           1 :         blockIndex++;
   78645             :       }
   78646           2 :   }
   78647             : 
   78648             : //############################################################################
   78649             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   78650             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   78651             :  * not compressed. However, that stuff is not yet implemented! 
   78652             :  */
   78653             : unsigned long
   78654           0 : SgDoWhileStmt::getNumberOfLastValidPointer()
   78655             :    {
   78656           0 :       SgDoWhileStmt* testPointer = (SgDoWhileStmt*)(SgDoWhileStmt::pools.back());
   78657           0 :       unsigned long localIndex = SgDoWhileStmt::pool_size - 1;
   78658           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   78659             :          {
   78660           0 :            localIndex--;
   78661             :          }
   78662           0 :       return (localIndex + SgDoWhileStmt::pool_size * (SgDoWhileStmt::pools.size()-1));
   78663             :    }
   78664             : 
   78665             : //############################################################################
   78666             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   78667             :  * memory pool and initializes the data member in class SgDoWhileStmtStroageClass
   78668             :  * from its counterpart of SgDoWhileStmt. The return value is just for checking, 
   78669             :  * that the whole StorageClassArray is initialized!
   78670             :  */
   78671             : unsigned long
   78672           1 : SgDoWhileStmt::initializeStorageClassArray( SgDoWhileStmtStorageClass *storageArray )
   78673             :    {
   78674           1 :      unsigned long storageCounter = 0;
   78675           1 :      std::vector < unsigned char* > :: const_iterator block = SgDoWhileStmt::pools.begin();
   78676           1 :      SgDoWhileStmt* pointer = NULL;
   78677           2 :      while ( block != SgDoWhileStmt::pools.end() ) {
   78678           1 :           pointer = (SgDoWhileStmt*) (*block);
   78679        2001 :           for ( unsigned i = 0; i < SgDoWhileStmt::pool_size; ++i ) {
   78680        2000 :                if ( pointer->get_freepointer() != NULL ) {
   78681           7 :                  storageArray->pickOutIRNodeData (pointer) ;
   78682           7 :                  storageArray++;
   78683           7 :                  storageCounter++;
   78684             :                }
   78685        2000 :                pointer++;
   78686             :              }
   78687           1 :            block++;
   78688             :         }
   78689           1 :      return storageCounter;
   78690             :    }
   78691             : 
   78692             : /* #line 78693 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   78693             : 
   78694             : 
   78695             : 
   78696             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   78697             : 
   78698             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   78699             : 
   78700             : //############################################################################
   78701             : /* JH (02/02/2006) Constructor of the IR node SgSwitchStatement that takes its 
   78702             :  * corresponding StorageClass as parameter
   78703             :  */
   78704           0 : SgSwitchStatement :: SgSwitchStatement ( const SgSwitchStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   78705             :    {
   78706             : 
   78707             : 
   78708             : /* #line 78709 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   78709             : 
   78710           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   78711           0 :      p_item_selector =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_item_selector) );
   78712           0 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   78713           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   78714           0 :      p_string_label = storageSource.storageOf_string_label.rebuildDataStoredInEasyStorageClass() ;
   78715             : 
   78716             : 
   78717             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   78718             : 
   78719             : 
   78720           0 :    }
   78721             : 
   78722             : //############################################################################
   78723             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   78724             :  * within the working AST. 
   78725             :  */
   78726           0 : SgSwitchStatement * SgSwitchStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   78727           0 :      SgSwitchStatement* returnPointer = NULL;
   78728           0 :      if ( globalIndex != 0 )
   78729             :         {
   78730             : 
   78731             : #if FILE_IO_EXTRA_CHECK
   78732           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSwitchStatement ) ) <= globalIndex ) ;
   78733           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSwitchStatement + 1 ) ) );
   78734             : #endif
   78735           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSwitchStatement )  
   78736           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSwitchStatement );
   78737           0 :           unsigned long positionInPool = localIndex % SgSwitchStatement::pool_size;
   78738           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSwitchStatement::pool_size;
   78739             : 
   78740             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   78741             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   78742             : 
   78743           0 :           returnPointer = &( ( (SgSwitchStatement*)(SgSwitchStatement::pools[memoryBlock]) ) [positionInPool]) ;
   78744             : 
   78745           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   78746             :         }
   78747           0 :      return returnPointer ;
   78748             :    }
   78749             : 
   78750             : //############################################################################
   78751             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   78752             :   for the AST with the index astIndex
   78753             : */
   78754           0 : SgSwitchStatement * SgSwitchStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   78755           0 :      SgSwitchStatement* returnPointer = NULL;
   78756           0 :      if ( globalIndex != 0 )
   78757             :         {
   78758             : 
   78759             : #if FILE_IO_EXTRA_CHECK
   78760           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSwitchStatement ) ) <= globalIndex ) ;
   78761           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSwitchStatement + 1 ) ) );
   78762             : #endif
   78763           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSwitchStatement )
   78764           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSwitchStatement );
   78765           0 :           unsigned long positionInPool = localIndex % SgSwitchStatement::pool_size ;
   78766           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSwitchStatement::pool_size ;
   78767             : 
   78768             : #if FILE_IO_EXTRA_CHECK
   78769             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   78770             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   78771             : #endif
   78772             : 
   78773           0 :           returnPointer = &( ( (SgSwitchStatement*)(SgSwitchStatement::pools[memoryBlock]) ) [positionInPool]) ;
   78774             : 
   78775             : #if FILE_IO_EXTRA_CHECK
   78776           0 :           assert ( returnPointer != NULL ) ;
   78777             : #endif
   78778             :         }
   78779           0 :      return returnPointer ;
   78780             :    }
   78781             : 
   78782             : //############################################################################
   78783             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   78784             :  * pool size! We set for every valid object in the memory pool the freepointer
   78785             :  * to the global index and increase the global index afterwards. For all the 
   78786             :  * invalid objects (means address ranges within the memory pool that were not
   78787             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   78788             :  * distinguish valid from invalid objects! 
   78789             :  */
   78790             : unsigned long
   78791           5 : SgSwitchStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   78792             :    {
   78793           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   78794           5 :      SgSwitchStatement* pointer = NULL;
   78795           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   78796           5 :      std::vector < unsigned char* > :: const_iterator block;
   78797           5 :      for ( block = SgSwitchStatement::pools.begin(); block != SgSwitchStatement::pools.end() ; ++block )
   78798             :         {
   78799           0 :           pointer = (SgSwitchStatement*)(*block);
   78800           0 :           for (unsigned i = 0; i < SgSwitchStatement::pool_size; ++i )
   78801             :              {
   78802             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   78803             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   78804             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   78805             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   78806             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   78807             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   78808             :             // properly; so this will have to be checked next.
   78809             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   78810             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   78811           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   78812             :                   {
   78813           0 :                     pointer[i].set_freepointer((SgSwitchStatement*)(globalIndex));
   78814           0 :                     globalIndex++;
   78815             :                   }
   78816             :                else
   78817             :                   {
   78818           0 :                     pointer[i].set_freepointer(NULL);
   78819             :                   }
   78820             :               }
   78821             :         }
   78822           5 :      return globalIndex;
   78823             :    }
   78824             : 
   78825             : //############################################################################
   78826             : // JH (01/14/2006)
   78827             : void
   78828           5 : SgSwitchStatement::resetValidFreepointers( )
   78829             :    {
   78830           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   78831           5 :      SgSwitchStatement* pointer = NULL;
   78832           5 :      std::vector < unsigned char* > :: const_iterator block;
   78833           5 :      SgSwitchStatement* pointerOfLinkedList = NULL;
   78834           5 :      for ( block = SgSwitchStatement::pools.begin(); block != SgSwitchStatement::pools.end() ; ++block )
   78835             :         {
   78836           0 :           pointer = (SgSwitchStatement*)(*block);
   78837           0 :           for (unsigned i = 0; i < SgSwitchStatement::pool_size; ++i )
   78838             :              {
   78839             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   78840             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   78841             :             // memory blocks!.
   78842           0 :                if ( pointer[i].get_freepointer() != NULL )
   78843             :                   {
   78844           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   78845             :                   }
   78846             :                else
   78847             :                   {
   78848           0 :                     if ( pointerOfLinkedList == NULL )
   78849             :                        {
   78850           0 :                          SgSwitchStatement::next_node = &(pointer[i]);
   78851             :                        }
   78852             :                     else
   78853             :                        {
   78854             :                       // printf ("In SgSwitchStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   78855           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   78856             :                        }
   78857             :                     pointerOfLinkedList = &(pointer[i]);
   78858             :                   }
   78859             :               }
   78860             :         }
   78861             : 
   78862           5 :      if ( pointerOfLinkedList != NULL )
   78863             :         {
   78864             :        // printf ("In SgSwitchStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   78865           0 :           pointerOfLinkedList->set_freepointer(NULL);
   78866             :        // DQ (6/6/2010): Temporary debugging...
   78867             :        //   ROSE_ASSERT(false);
   78868             :         }
   78869             : 
   78870           5 :      return ;
   78871             :    }
   78872             : 
   78873             : //############################################################################
   78874             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   78875             :  * within the memory pool and resets the freepointers, in order to achieve a 
   78876             :  * linked list, that has no jumps and starts at the beginning! This function 
   78877             :  * does not extend the memory pool, since we do not delete any memory blocks,
   78878             :  * but delete the valid objects.  
   78879             :  */
   78880             : void
   78881           0 : SgSwitchStatement::clearMemoryPool( )
   78882             :    {
   78883             :   // printf ("Inside of SgSwitchStatement::clearMemoryPool() \n");
   78884             : 
   78885           0 :      SgSwitchStatement* pointer = NULL, *tempPointer = NULL;
   78886           0 :      std::vector < unsigned char* > :: const_iterator block;
   78887           0 :      if ( SgSwitchStatement::pools.empty() == false )
   78888             :         {
   78889           0 :           block = SgSwitchStatement::pools.begin() ;
   78890           0 :           SgSwitchStatement::next_node = (SgSwitchStatement*) (*block);
   78891             : 
   78892           0 :           while ( block != SgSwitchStatement::pools.end() )
   78893             :              {
   78894           0 :                pointer = (SgSwitchStatement*) (*block);
   78895           0 :                if ( tempPointer != NULL )
   78896             :                   {
   78897           0 :                     tempPointer->set_freepointer(pointer);
   78898             :                   }
   78899           0 :                for (unsigned i = 0; i < SgSwitchStatement::pool_size - 1; ++i)
   78900             :                   {
   78901           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   78902             :                   }
   78903           0 :                 pointer[SgSwitchStatement::pool_size-1].set_freepointer(NULL);
   78904           0 :                 tempPointer = &(pointer[SgSwitchStatement::pool_size-1]);
   78905           0 :                 ++block;
   78906             :              }
   78907             :         }
   78908           0 :    }
   78909             : 
   78910           5 : void SgSwitchStatement::deleteMemoryPool() {
   78911           5 :   for (auto p: SgSwitchStatement::pools) {
   78912           0 :     ROSE_FREE(p);
   78913             :   }
   78914           5 :   SgSwitchStatement::next_node = nullptr;
   78915           5 :   SgSwitchStatement::pools.clear();
   78916           5 : }
   78917             : 
   78918             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   78919             : //                 reading multiple binary files to for a single AST.
   78920             : /////////// new version ////////////////////////////////
   78921             : //############################################################################
   78922             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   78923             : void
   78924           2 : SgSwitchStatement::extendMemoryPoolForFileIO( )
   78925             :   {
   78926           2 :     size_t blockIndex = SgSwitchStatement::pools.size();
   78927           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSwitchStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSwitchStatement);
   78928             : 
   78929           2 :     while ( (blockIndex * SgSwitchStatement::pool_size) < newPoolSize)
   78930             :       {
   78931             : #if ROSE_ALLOC_TRACE
   78932             :         if (blockIndex > 0) {
   78933             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSwitchStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSwitchStatement) = %" PRIuPTR " SgSwitchStatement::pool_size = %d \n",
   78934             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSwitchStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSwitchStatement),SgSwitchStatement::pool_size);
   78935             :         }
   78936             : #endif
   78937             : 
   78938           0 :         SgSwitchStatement * pointer = (SgSwitchStatement*) ROSE_MALLOC ( SgSwitchStatement::pool_size * sizeof(SgSwitchStatement) );
   78939           0 :         assert( pointer != NULL );
   78940             : #if ROSE_ALLOC_MEMSET == 1
   78941             :         memset(pointer, 0x00, SgSwitchStatement::pool_size * sizeof(SgSwitchStatement));
   78942             : #elif ROSE_ALLOC_MEMSET == 2
   78943             :         memset(pointer, 0xCC, SgSwitchStatement::pool_size * sizeof(SgSwitchStatement));
   78944             : #endif
   78945           0 :         SgSwitchStatement::pools.push_back( (unsigned char*)(pointer) );
   78946           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSwitchStatement::pool_size * sizeof(SgSwitchStatement), V_SgSwitchStatement ) );
   78947             : 
   78948           0 :         if ( SgSwitchStatement::next_node != NULL ) {
   78949           0 :           if ( blockIndex > 0 ) {
   78950           0 :             SgSwitchStatement * blkptr = (SgSwitchStatement*)(SgSwitchStatement::pools[blockIndex-1]);
   78951           0 :             blkptr[ SgSwitchStatement::pool_size - 1 ].set_freepointer(pointer);
   78952             :           }
   78953             :         } else {
   78954           0 :           SgSwitchStatement::next_node = pointer;
   78955             :         }
   78956             : 
   78957           0 :         for (unsigned i = 0; i < SgSwitchStatement::pool_size-1; ++i)
   78958             :            {
   78959           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   78960             :            }
   78961           0 :         pointer[ SgSwitchStatement::pool_size -1 ].set_freepointer(NULL);
   78962             : 
   78963           0 :         blockIndex++;
   78964             :       }
   78965           2 :   }
   78966             : 
   78967             : //############################################################################
   78968             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   78969             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   78970             :  * not compressed. However, that stuff is not yet implemented! 
   78971             :  */
   78972             : unsigned long
   78973           0 : SgSwitchStatement::getNumberOfLastValidPointer()
   78974             :    {
   78975           0 :       SgSwitchStatement* testPointer = (SgSwitchStatement*)(SgSwitchStatement::pools.back());
   78976           0 :       unsigned long localIndex = SgSwitchStatement::pool_size - 1;
   78977           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   78978             :          {
   78979           0 :            localIndex--;
   78980             :          }
   78981           0 :       return (localIndex + SgSwitchStatement::pool_size * (SgSwitchStatement::pools.size()-1));
   78982             :    }
   78983             : 
   78984             : //############################################################################
   78985             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   78986             :  * memory pool and initializes the data member in class SgSwitchStatementStroageClass
   78987             :  * from its counterpart of SgSwitchStatement. The return value is just for checking, 
   78988             :  * that the whole StorageClassArray is initialized!
   78989             :  */
   78990             : unsigned long
   78991           0 : SgSwitchStatement::initializeStorageClassArray( SgSwitchStatementStorageClass *storageArray )
   78992             :    {
   78993           0 :      unsigned long storageCounter = 0;
   78994           0 :      std::vector < unsigned char* > :: const_iterator block = SgSwitchStatement::pools.begin();
   78995           0 :      SgSwitchStatement* pointer = NULL;
   78996           0 :      while ( block != SgSwitchStatement::pools.end() ) {
   78997           0 :           pointer = (SgSwitchStatement*) (*block);
   78998           0 :           for ( unsigned i = 0; i < SgSwitchStatement::pool_size; ++i ) {
   78999           0 :                if ( pointer->get_freepointer() != NULL ) {
   79000           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   79001           0 :                  storageArray++;
   79002           0 :                  storageCounter++;
   79003             :                }
   79004           0 :                pointer++;
   79005             :              }
   79006           0 :            block++;
   79007             :         }
   79008           0 :      return storageCounter;
   79009             :    }
   79010             : 
   79011             : /* #line 79012 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   79012             : 
   79013             : 
   79014             : 
   79015             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   79016             : 
   79017             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   79018             : 
   79019             : //############################################################################
   79020             : /* JH (02/02/2006) Constructor of the IR node SgCatchOptionStmt that takes its 
   79021             :  * corresponding StorageClass as parameter
   79022             :  */
   79023          90 : SgCatchOptionStmt :: SgCatchOptionStmt ( const SgCatchOptionStmtStorageClass& storageSource )   : SgScopeStatement (storageSource)
   79024             :    {
   79025             : 
   79026             : 
   79027             : /* #line 79028 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   79028             : 
   79029          90 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   79030          90 :      p_condition =  (SgVariableDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_condition) );
   79031          90 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   79032          90 :      p_trystmt =  (SgTryStmt*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_trystmt) );
   79033             : 
   79034             : 
   79035             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   79036             : 
   79037             : 
   79038          90 :    }
   79039             : 
   79040             : //############################################################################
   79041             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   79042             :  * within the working AST. 
   79043             :  */
   79044         720 : SgCatchOptionStmt * SgCatchOptionStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   79045         720 :      SgCatchOptionStmt* returnPointer = NULL;
   79046         720 :      if ( globalIndex != 0 )
   79047             :         {
   79048             : 
   79049             : #if FILE_IO_EXTRA_CHECK
   79050         720 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCatchOptionStmt ) ) <= globalIndex ) ;
   79051         720 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCatchOptionStmt + 1 ) ) );
   79052             : #endif
   79053         720 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCatchOptionStmt )  
   79054         720 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCatchOptionStmt );
   79055         720 :           unsigned long positionInPool = localIndex % SgCatchOptionStmt::pool_size;
   79056         720 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCatchOptionStmt::pool_size;
   79057             : 
   79058             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   79059             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   79060             : 
   79061         720 :           returnPointer = &( ( (SgCatchOptionStmt*)(SgCatchOptionStmt::pools[memoryBlock]) ) [positionInPool]) ;
   79062             : 
   79063         720 :           ROSE_ASSERT( returnPointer != NULL ) ;
   79064             :         }
   79065         720 :      return returnPointer ;
   79066             :    }
   79067             : 
   79068             : //############################################################################
   79069             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   79070             :   for the AST with the index astIndex
   79071             : */
   79072           0 : SgCatchOptionStmt * SgCatchOptionStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   79073           0 :      SgCatchOptionStmt* returnPointer = NULL;
   79074           0 :      if ( globalIndex != 0 )
   79075             :         {
   79076             : 
   79077             : #if FILE_IO_EXTRA_CHECK
   79078           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCatchOptionStmt ) ) <= globalIndex ) ;
   79079           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCatchOptionStmt + 1 ) ) );
   79080             : #endif
   79081           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCatchOptionStmt )
   79082           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCatchOptionStmt );
   79083           0 :           unsigned long positionInPool = localIndex % SgCatchOptionStmt::pool_size ;
   79084           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCatchOptionStmt::pool_size ;
   79085             : 
   79086             : #if FILE_IO_EXTRA_CHECK
   79087             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   79088             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   79089             : #endif
   79090             : 
   79091           0 :           returnPointer = &( ( (SgCatchOptionStmt*)(SgCatchOptionStmt::pools[memoryBlock]) ) [positionInPool]) ;
   79092             : 
   79093             : #if FILE_IO_EXTRA_CHECK
   79094           0 :           assert ( returnPointer != NULL ) ;
   79095             : #endif
   79096             :         }
   79097           0 :      return returnPointer ;
   79098             :    }
   79099             : 
   79100             : //############################################################################
   79101             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   79102             :  * pool size! We set for every valid object in the memory pool the freepointer
   79103             :  * to the global index and increase the global index afterwards. For all the 
   79104             :  * invalid objects (means address ranges within the memory pool that were not
   79105             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   79106             :  * distinguish valid from invalid objects! 
   79107             :  */
   79108             : unsigned long
   79109           5 : SgCatchOptionStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   79110             :    {
   79111           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   79112           5 :      SgCatchOptionStmt* pointer = NULL;
   79113           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   79114           5 :      std::vector < unsigned char* > :: const_iterator block;
   79115           6 :      for ( block = SgCatchOptionStmt::pools.begin(); block != SgCatchOptionStmt::pools.end() ; ++block )
   79116             :         {
   79117           1 :           pointer = (SgCatchOptionStmt*)(*block);
   79118        2001 :           for (unsigned i = 0; i < SgCatchOptionStmt::pool_size; ++i )
   79119             :              {
   79120             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   79121             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   79122             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   79123             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   79124             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   79125             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   79126             :             // properly; so this will have to be checked next.
   79127             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   79128             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   79129        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   79130             :                   {
   79131          90 :                     pointer[i].set_freepointer((SgCatchOptionStmt*)(globalIndex));
   79132          90 :                     globalIndex++;
   79133             :                   }
   79134             :                else
   79135             :                   {
   79136        1910 :                     pointer[i].set_freepointer(NULL);
   79137             :                   }
   79138             :               }
   79139             :         }
   79140           5 :      return globalIndex;
   79141             :    }
   79142             : 
   79143             : //############################################################################
   79144             : // JH (01/14/2006)
   79145             : void
   79146           5 : SgCatchOptionStmt::resetValidFreepointers( )
   79147             :    {
   79148           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   79149           5 :      SgCatchOptionStmt* pointer = NULL;
   79150           5 :      std::vector < unsigned char* > :: const_iterator block;
   79151           5 :      SgCatchOptionStmt* pointerOfLinkedList = NULL;
   79152           6 :      for ( block = SgCatchOptionStmt::pools.begin(); block != SgCatchOptionStmt::pools.end() ; ++block )
   79153             :         {
   79154           1 :           pointer = (SgCatchOptionStmt*)(*block);
   79155        2001 :           for (unsigned i = 0; i < SgCatchOptionStmt::pool_size; ++i )
   79156             :              {
   79157             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   79158             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   79159             :             // memory blocks!.
   79160        2000 :                if ( pointer[i].get_freepointer() != NULL )
   79161             :                   {
   79162          90 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   79163             :                   }
   79164             :                else
   79165             :                   {
   79166        1910 :                     if ( pointerOfLinkedList == NULL )
   79167             :                        {
   79168           1 :                          SgCatchOptionStmt::next_node = &(pointer[i]);
   79169             :                        }
   79170             :                     else
   79171             :                        {
   79172             :                       // printf ("In SgCatchOptionStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   79173        1909 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   79174             :                        }
   79175             :                     pointerOfLinkedList = &(pointer[i]);
   79176             :                   }
   79177             :               }
   79178             :         }
   79179             : 
   79180           5 :      if ( pointerOfLinkedList != NULL )
   79181             :         {
   79182             :        // printf ("In SgCatchOptionStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   79183           1 :           pointerOfLinkedList->set_freepointer(NULL);
   79184             :        // DQ (6/6/2010): Temporary debugging...
   79185             :        //   ROSE_ASSERT(false);
   79186             :         }
   79187             : 
   79188           5 :      return ;
   79189             :    }
   79190             : 
   79191             : //############################################################################
   79192             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   79193             :  * within the memory pool and resets the freepointers, in order to achieve a 
   79194             :  * linked list, that has no jumps and starts at the beginning! This function 
   79195             :  * does not extend the memory pool, since we do not delete any memory blocks,
   79196             :  * but delete the valid objects.  
   79197             :  */
   79198             : void
   79199           0 : SgCatchOptionStmt::clearMemoryPool( )
   79200             :    {
   79201             :   // printf ("Inside of SgCatchOptionStmt::clearMemoryPool() \n");
   79202             : 
   79203           0 :      SgCatchOptionStmt* pointer = NULL, *tempPointer = NULL;
   79204           0 :      std::vector < unsigned char* > :: const_iterator block;
   79205           0 :      if ( SgCatchOptionStmt::pools.empty() == false )
   79206             :         {
   79207           0 :           block = SgCatchOptionStmt::pools.begin() ;
   79208           0 :           SgCatchOptionStmt::next_node = (SgCatchOptionStmt*) (*block);
   79209             : 
   79210           0 :           while ( block != SgCatchOptionStmt::pools.end() )
   79211             :              {
   79212           0 :                pointer = (SgCatchOptionStmt*) (*block);
   79213           0 :                if ( tempPointer != NULL )
   79214             :                   {
   79215           0 :                     tempPointer->set_freepointer(pointer);
   79216             :                   }
   79217           0 :                for (unsigned i = 0; i < SgCatchOptionStmt::pool_size - 1; ++i)
   79218             :                   {
   79219           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   79220             :                   }
   79221           0 :                 pointer[SgCatchOptionStmt::pool_size-1].set_freepointer(NULL);
   79222           0 :                 tempPointer = &(pointer[SgCatchOptionStmt::pool_size-1]);
   79223           0 :                 ++block;
   79224             :              }
   79225             :         }
   79226           0 :    }
   79227             : 
   79228           5 : void SgCatchOptionStmt::deleteMemoryPool() {
   79229           7 :   for (auto p: SgCatchOptionStmt::pools) {
   79230           2 :     ROSE_FREE(p);
   79231             :   }
   79232           5 :   SgCatchOptionStmt::next_node = nullptr;
   79233           5 :   SgCatchOptionStmt::pools.clear();
   79234           5 : }
   79235             : 
   79236             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   79237             : //                 reading multiple binary files to for a single AST.
   79238             : /////////// new version ////////////////////////////////
   79239             : //############################################################################
   79240             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   79241             : void
   79242           2 : SgCatchOptionStmt::extendMemoryPoolForFileIO( )
   79243             :   {
   79244           2 :     size_t blockIndex = SgCatchOptionStmt::pools.size();
   79245           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCatchOptionStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCatchOptionStmt);
   79246             : 
   79247           3 :     while ( (blockIndex * SgCatchOptionStmt::pool_size) < newPoolSize)
   79248             :       {
   79249             : #if ROSE_ALLOC_TRACE
   79250             :         if (blockIndex > 0) {
   79251             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCatchOptionStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCatchOptionStmt) = %" PRIuPTR " SgCatchOptionStmt::pool_size = %d \n",
   79252             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCatchOptionStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCatchOptionStmt),SgCatchOptionStmt::pool_size);
   79253             :         }
   79254             : #endif
   79255             : 
   79256           1 :         SgCatchOptionStmt * pointer = (SgCatchOptionStmt*) ROSE_MALLOC ( SgCatchOptionStmt::pool_size * sizeof(SgCatchOptionStmt) );
   79257           1 :         assert( pointer != NULL );
   79258             : #if ROSE_ALLOC_MEMSET == 1
   79259             :         memset(pointer, 0x00, SgCatchOptionStmt::pool_size * sizeof(SgCatchOptionStmt));
   79260             : #elif ROSE_ALLOC_MEMSET == 2
   79261             :         memset(pointer, 0xCC, SgCatchOptionStmt::pool_size * sizeof(SgCatchOptionStmt));
   79262             : #endif
   79263           1 :         SgCatchOptionStmt::pools.push_back( (unsigned char*)(pointer) );
   79264           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCatchOptionStmt::pool_size * sizeof(SgCatchOptionStmt), V_SgCatchOptionStmt ) );
   79265             : 
   79266           1 :         if ( SgCatchOptionStmt::next_node != NULL ) {
   79267           0 :           if ( blockIndex > 0 ) {
   79268           0 :             SgCatchOptionStmt * blkptr = (SgCatchOptionStmt*)(SgCatchOptionStmt::pools[blockIndex-1]);
   79269           0 :             blkptr[ SgCatchOptionStmt::pool_size - 1 ].set_freepointer(pointer);
   79270             :           }
   79271             :         } else {
   79272           1 :           SgCatchOptionStmt::next_node = pointer;
   79273             :         }
   79274             : 
   79275        2000 :         for (unsigned i = 0; i < SgCatchOptionStmt::pool_size-1; ++i)
   79276             :            {
   79277        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   79278             :            }
   79279           1 :         pointer[ SgCatchOptionStmt::pool_size -1 ].set_freepointer(NULL);
   79280             : 
   79281           1 :         blockIndex++;
   79282             :       }
   79283           2 :   }
   79284             : 
   79285             : //############################################################################
   79286             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   79287             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   79288             :  * not compressed. However, that stuff is not yet implemented! 
   79289             :  */
   79290             : unsigned long
   79291           0 : SgCatchOptionStmt::getNumberOfLastValidPointer()
   79292             :    {
   79293           0 :       SgCatchOptionStmt* testPointer = (SgCatchOptionStmt*)(SgCatchOptionStmt::pools.back());
   79294           0 :       unsigned long localIndex = SgCatchOptionStmt::pool_size - 1;
   79295           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   79296             :          {
   79297           0 :            localIndex--;
   79298             :          }
   79299           0 :       return (localIndex + SgCatchOptionStmt::pool_size * (SgCatchOptionStmt::pools.size()-1));
   79300             :    }
   79301             : 
   79302             : //############################################################################
   79303             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   79304             :  * memory pool and initializes the data member in class SgCatchOptionStmtStroageClass
   79305             :  * from its counterpart of SgCatchOptionStmt. The return value is just for checking, 
   79306             :  * that the whole StorageClassArray is initialized!
   79307             :  */
   79308             : unsigned long
   79309           1 : SgCatchOptionStmt::initializeStorageClassArray( SgCatchOptionStmtStorageClass *storageArray )
   79310             :    {
   79311           1 :      unsigned long storageCounter = 0;
   79312           1 :      std::vector < unsigned char* > :: const_iterator block = SgCatchOptionStmt::pools.begin();
   79313           1 :      SgCatchOptionStmt* pointer = NULL;
   79314           2 :      while ( block != SgCatchOptionStmt::pools.end() ) {
   79315           1 :           pointer = (SgCatchOptionStmt*) (*block);
   79316        2001 :           for ( unsigned i = 0; i < SgCatchOptionStmt::pool_size; ++i ) {
   79317        2000 :                if ( pointer->get_freepointer() != NULL ) {
   79318          90 :                  storageArray->pickOutIRNodeData (pointer) ;
   79319          90 :                  storageArray++;
   79320          90 :                  storageCounter++;
   79321             :                }
   79322        2000 :                pointer++;
   79323             :              }
   79324           1 :            block++;
   79325             :         }
   79326           1 :      return storageCounter;
   79327             :    }
   79328             : 
   79329             : /* #line 79330 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   79330             : 
   79331             : 
   79332             : 
   79333             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   79334             : 
   79335             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   79336             : 
   79337             : //############################################################################
   79338             : /* JH (02/02/2006) Constructor of the IR node SgNamespaceDefinitionStatement that takes its 
   79339             :  * corresponding StorageClass as parameter
   79340             :  */
   79341         135 : SgNamespaceDefinitionStatement :: SgNamespaceDefinitionStatement ( const SgNamespaceDefinitionStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   79342             :    {
   79343             : 
   79344             : 
   79345             : /* #line 79346 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   79346             : 
   79347         135 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   79348         135 :      p_declarations = storageSource.storageOf_declarations.rebuildDataStoredInEasyStorageClass() ;
   79349         135 :      SgDeclarationStatementPtrList::iterator i_declarations = p_declarations.begin() ; 
   79350        2817 :      for ( ; i_declarations != p_declarations.end(); ++i_declarations ) 
   79351             :         {
   79352        2682 :           (*i_declarations) = (SgDeclarationStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_declarations) ) );
   79353             :         }
   79354         135 :      p_namespaceDeclaration =  (SgNamespaceDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_namespaceDeclaration) );
   79355         135 :      p_previousNamespaceDefinition =  (SgNamespaceDefinitionStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_previousNamespaceDefinition) );
   79356         135 :      p_nextNamespaceDefinition =  (SgNamespaceDefinitionStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nextNamespaceDefinition) );
   79357         135 :      p_global_definition =  (SgNamespaceDefinitionStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_global_definition) );
   79358         135 :      p_isUnionOfReentrantNamespaceDefinitions = storageSource.storageOf_isUnionOfReentrantNamespaceDefinitions ;
   79359             : 
   79360             : 
   79361             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   79362             : 
   79363             : 
   79364         135 :    }
   79365             : 
   79366             : //############################################################################
   79367             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   79368             :  * within the working AST. 
   79369             :  */
   79370       11357 : SgNamespaceDefinitionStatement * SgNamespaceDefinitionStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   79371       11357 :      SgNamespaceDefinitionStatement* returnPointer = NULL;
   79372       11357 :      if ( globalIndex != 0 )
   79373             :         {
   79374             : 
   79375             : #if FILE_IO_EXTRA_CHECK
   79376       11357 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNamespaceDefinitionStatement ) ) <= globalIndex ) ;
   79377       11357 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamespaceDefinitionStatement + 1 ) ) );
   79378             : #endif
   79379       11357 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamespaceDefinitionStatement )  
   79380       11357 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNamespaceDefinitionStatement );
   79381       11357 :           unsigned long positionInPool = localIndex % SgNamespaceDefinitionStatement::pool_size;
   79382       11357 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamespaceDefinitionStatement::pool_size;
   79383             : 
   79384             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   79385             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   79386             : 
   79387       11357 :           returnPointer = &( ( (SgNamespaceDefinitionStatement*)(SgNamespaceDefinitionStatement::pools[memoryBlock]) ) [positionInPool]) ;
   79388             : 
   79389       11357 :           ROSE_ASSERT( returnPointer != NULL ) ;
   79390             :         }
   79391       11357 :      return returnPointer ;
   79392             :    }
   79393             : 
   79394             : //############################################################################
   79395             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   79396             :   for the AST with the index astIndex
   79397             : */
   79398           0 : SgNamespaceDefinitionStatement * SgNamespaceDefinitionStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   79399           0 :      SgNamespaceDefinitionStatement* returnPointer = NULL;
   79400           0 :      if ( globalIndex != 0 )
   79401             :         {
   79402             : 
   79403             : #if FILE_IO_EXTRA_CHECK
   79404           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNamespaceDefinitionStatement ) ) <= globalIndex ) ;
   79405           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamespaceDefinitionStatement + 1 ) ) );
   79406             : #endif
   79407           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamespaceDefinitionStatement )
   79408           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNamespaceDefinitionStatement );
   79409           0 :           unsigned long positionInPool = localIndex % SgNamespaceDefinitionStatement::pool_size ;
   79410           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamespaceDefinitionStatement::pool_size ;
   79411             : 
   79412             : #if FILE_IO_EXTRA_CHECK
   79413             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   79414             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   79415             : #endif
   79416             : 
   79417           0 :           returnPointer = &( ( (SgNamespaceDefinitionStatement*)(SgNamespaceDefinitionStatement::pools[memoryBlock]) ) [positionInPool]) ;
   79418             : 
   79419             : #if FILE_IO_EXTRA_CHECK
   79420           0 :           assert ( returnPointer != NULL ) ;
   79421             : #endif
   79422             :         }
   79423           0 :      return returnPointer ;
   79424             :    }
   79425             : 
   79426             : //############################################################################
   79427             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   79428             :  * pool size! We set for every valid object in the memory pool the freepointer
   79429             :  * to the global index and increase the global index afterwards. For all the 
   79430             :  * invalid objects (means address ranges within the memory pool that were not
   79431             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   79432             :  * distinguish valid from invalid objects! 
   79433             :  */
   79434             : unsigned long
   79435           5 : SgNamespaceDefinitionStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   79436             :    {
   79437           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   79438           5 :      SgNamespaceDefinitionStatement* pointer = NULL;
   79439           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   79440           5 :      std::vector < unsigned char* > :: const_iterator block;
   79441           6 :      for ( block = SgNamespaceDefinitionStatement::pools.begin(); block != SgNamespaceDefinitionStatement::pools.end() ; ++block )
   79442             :         {
   79443           1 :           pointer = (SgNamespaceDefinitionStatement*)(*block);
   79444        2001 :           for (unsigned i = 0; i < SgNamespaceDefinitionStatement::pool_size; ++i )
   79445             :              {
   79446             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   79447             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   79448             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   79449             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   79450             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   79451             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   79452             :             // properly; so this will have to be checked next.
   79453             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   79454             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   79455        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   79456             :                   {
   79457         135 :                     pointer[i].set_freepointer((SgNamespaceDefinitionStatement*)(globalIndex));
   79458         135 :                     globalIndex++;
   79459             :                   }
   79460             :                else
   79461             :                   {
   79462        1865 :                     pointer[i].set_freepointer(NULL);
   79463             :                   }
   79464             :               }
   79465             :         }
   79466           5 :      return globalIndex;
   79467             :    }
   79468             : 
   79469             : //############################################################################
   79470             : // JH (01/14/2006)
   79471             : void
   79472           5 : SgNamespaceDefinitionStatement::resetValidFreepointers( )
   79473             :    {
   79474           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   79475           5 :      SgNamespaceDefinitionStatement* pointer = NULL;
   79476           5 :      std::vector < unsigned char* > :: const_iterator block;
   79477           5 :      SgNamespaceDefinitionStatement* pointerOfLinkedList = NULL;
   79478           6 :      for ( block = SgNamespaceDefinitionStatement::pools.begin(); block != SgNamespaceDefinitionStatement::pools.end() ; ++block )
   79479             :         {
   79480           1 :           pointer = (SgNamespaceDefinitionStatement*)(*block);
   79481        2001 :           for (unsigned i = 0; i < SgNamespaceDefinitionStatement::pool_size; ++i )
   79482             :              {
   79483             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   79484             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   79485             :             // memory blocks!.
   79486        2000 :                if ( pointer[i].get_freepointer() != NULL )
   79487             :                   {
   79488         135 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   79489             :                   }
   79490             :                else
   79491             :                   {
   79492        1865 :                     if ( pointerOfLinkedList == NULL )
   79493             :                        {
   79494           1 :                          SgNamespaceDefinitionStatement::next_node = &(pointer[i]);
   79495             :                        }
   79496             :                     else
   79497             :                        {
   79498             :                       // printf ("In SgNamespaceDefinitionStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   79499        1864 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   79500             :                        }
   79501             :                     pointerOfLinkedList = &(pointer[i]);
   79502             :                   }
   79503             :               }
   79504             :         }
   79505             : 
   79506           5 :      if ( pointerOfLinkedList != NULL )
   79507             :         {
   79508             :        // printf ("In SgNamespaceDefinitionStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   79509           1 :           pointerOfLinkedList->set_freepointer(NULL);
   79510             :        // DQ (6/6/2010): Temporary debugging...
   79511             :        //   ROSE_ASSERT(false);
   79512             :         }
   79513             : 
   79514           5 :      return ;
   79515             :    }
   79516             : 
   79517             : //############################################################################
   79518             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   79519             :  * within the memory pool and resets the freepointers, in order to achieve a 
   79520             :  * linked list, that has no jumps and starts at the beginning! This function 
   79521             :  * does not extend the memory pool, since we do not delete any memory blocks,
   79522             :  * but delete the valid objects.  
   79523             :  */
   79524             : void
   79525           0 : SgNamespaceDefinitionStatement::clearMemoryPool( )
   79526             :    {
   79527             :   // printf ("Inside of SgNamespaceDefinitionStatement::clearMemoryPool() \n");
   79528             : 
   79529           0 :      SgNamespaceDefinitionStatement* pointer = NULL, *tempPointer = NULL;
   79530           0 :      std::vector < unsigned char* > :: const_iterator block;
   79531           0 :      if ( SgNamespaceDefinitionStatement::pools.empty() == false )
   79532             :         {
   79533           0 :           block = SgNamespaceDefinitionStatement::pools.begin() ;
   79534           0 :           SgNamespaceDefinitionStatement::next_node = (SgNamespaceDefinitionStatement*) (*block);
   79535             : 
   79536           0 :           while ( block != SgNamespaceDefinitionStatement::pools.end() )
   79537             :              {
   79538           0 :                pointer = (SgNamespaceDefinitionStatement*) (*block);
   79539           0 :                if ( tempPointer != NULL )
   79540             :                   {
   79541           0 :                     tempPointer->set_freepointer(pointer);
   79542             :                   }
   79543           0 :                for (unsigned i = 0; i < SgNamespaceDefinitionStatement::pool_size - 1; ++i)
   79544             :                   {
   79545           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   79546             :                   }
   79547           0 :                 pointer[SgNamespaceDefinitionStatement::pool_size-1].set_freepointer(NULL);
   79548           0 :                 tempPointer = &(pointer[SgNamespaceDefinitionStatement::pool_size-1]);
   79549           0 :                 ++block;
   79550             :              }
   79551             :         }
   79552           0 :    }
   79553             : 
   79554           5 : void SgNamespaceDefinitionStatement::deleteMemoryPool() {
   79555           7 :   for (auto p: SgNamespaceDefinitionStatement::pools) {
   79556           2 :     ROSE_FREE(p);
   79557             :   }
   79558           5 :   SgNamespaceDefinitionStatement::next_node = nullptr;
   79559           5 :   SgNamespaceDefinitionStatement::pools.clear();
   79560           5 : }
   79561             : 
   79562             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   79563             : //                 reading multiple binary files to for a single AST.
   79564             : /////////// new version ////////////////////////////////
   79565             : //############################################################################
   79566             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   79567             : void
   79568           2 : SgNamespaceDefinitionStatement::extendMemoryPoolForFileIO( )
   79569             :   {
   79570           2 :     size_t blockIndex = SgNamespaceDefinitionStatement::pools.size();
   79571           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceDefinitionStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceDefinitionStatement);
   79572             : 
   79573           3 :     while ( (blockIndex * SgNamespaceDefinitionStatement::pool_size) < newPoolSize)
   79574             :       {
   79575             : #if ROSE_ALLOC_TRACE
   79576             :         if (blockIndex > 0) {
   79577             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceDefinitionStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceDefinitionStatement) = %" PRIuPTR " SgNamespaceDefinitionStatement::pool_size = %d \n",
   79578             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceDefinitionStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceDefinitionStatement),SgNamespaceDefinitionStatement::pool_size);
   79579             :         }
   79580             : #endif
   79581             : 
   79582           1 :         SgNamespaceDefinitionStatement * pointer = (SgNamespaceDefinitionStatement*) ROSE_MALLOC ( SgNamespaceDefinitionStatement::pool_size * sizeof(SgNamespaceDefinitionStatement) );
   79583           1 :         assert( pointer != NULL );
   79584             : #if ROSE_ALLOC_MEMSET == 1
   79585             :         memset(pointer, 0x00, SgNamespaceDefinitionStatement::pool_size * sizeof(SgNamespaceDefinitionStatement));
   79586             : #elif ROSE_ALLOC_MEMSET == 2
   79587             :         memset(pointer, 0xCC, SgNamespaceDefinitionStatement::pool_size * sizeof(SgNamespaceDefinitionStatement));
   79588             : #endif
   79589           1 :         SgNamespaceDefinitionStatement::pools.push_back( (unsigned char*)(pointer) );
   79590           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNamespaceDefinitionStatement::pool_size * sizeof(SgNamespaceDefinitionStatement), V_SgNamespaceDefinitionStatement ) );
   79591             : 
   79592           1 :         if ( SgNamespaceDefinitionStatement::next_node != NULL ) {
   79593           0 :           if ( blockIndex > 0 ) {
   79594           0 :             SgNamespaceDefinitionStatement * blkptr = (SgNamespaceDefinitionStatement*)(SgNamespaceDefinitionStatement::pools[blockIndex-1]);
   79595           0 :             blkptr[ SgNamespaceDefinitionStatement::pool_size - 1 ].set_freepointer(pointer);
   79596             :           }
   79597             :         } else {
   79598           1 :           SgNamespaceDefinitionStatement::next_node = pointer;
   79599             :         }
   79600             : 
   79601        2000 :         for (unsigned i = 0; i < SgNamespaceDefinitionStatement::pool_size-1; ++i)
   79602             :            {
   79603        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   79604             :            }
   79605           1 :         pointer[ SgNamespaceDefinitionStatement::pool_size -1 ].set_freepointer(NULL);
   79606             : 
   79607           1 :         blockIndex++;
   79608             :       }
   79609           2 :   }
   79610             : 
   79611             : //############################################################################
   79612             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   79613             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   79614             :  * not compressed. However, that stuff is not yet implemented! 
   79615             :  */
   79616             : unsigned long
   79617           0 : SgNamespaceDefinitionStatement::getNumberOfLastValidPointer()
   79618             :    {
   79619           0 :       SgNamespaceDefinitionStatement* testPointer = (SgNamespaceDefinitionStatement*)(SgNamespaceDefinitionStatement::pools.back());
   79620           0 :       unsigned long localIndex = SgNamespaceDefinitionStatement::pool_size - 1;
   79621           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   79622             :          {
   79623           0 :            localIndex--;
   79624             :          }
   79625           0 :       return (localIndex + SgNamespaceDefinitionStatement::pool_size * (SgNamespaceDefinitionStatement::pools.size()-1));
   79626             :    }
   79627             : 
   79628             : //############################################################################
   79629             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   79630             :  * memory pool and initializes the data member in class SgNamespaceDefinitionStatementStroageClass
   79631             :  * from its counterpart of SgNamespaceDefinitionStatement. The return value is just for checking, 
   79632             :  * that the whole StorageClassArray is initialized!
   79633             :  */
   79634             : unsigned long
   79635           1 : SgNamespaceDefinitionStatement::initializeStorageClassArray( SgNamespaceDefinitionStatementStorageClass *storageArray )
   79636             :    {
   79637           1 :      unsigned long storageCounter = 0;
   79638           1 :      std::vector < unsigned char* > :: const_iterator block = SgNamespaceDefinitionStatement::pools.begin();
   79639           1 :      SgNamespaceDefinitionStatement* pointer = NULL;
   79640           2 :      while ( block != SgNamespaceDefinitionStatement::pools.end() ) {
   79641           1 :           pointer = (SgNamespaceDefinitionStatement*) (*block);
   79642        2001 :           for ( unsigned i = 0; i < SgNamespaceDefinitionStatement::pool_size; ++i ) {
   79643        2000 :                if ( pointer->get_freepointer() != NULL ) {
   79644         135 :                  storageArray->pickOutIRNodeData (pointer) ;
   79645         135 :                  storageArray++;
   79646         135 :                  storageCounter++;
   79647             :                }
   79648        2000 :                pointer++;
   79649             :              }
   79650           1 :            block++;
   79651             :         }
   79652           1 :      return storageCounter;
   79653             :    }
   79654             : 
   79655             : /* #line 79656 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   79656             : 
   79657             : 
   79658             : 
   79659             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   79660             : 
   79661             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   79662             : 
   79663             : //############################################################################
   79664             : /* JH (02/02/2006) Constructor of the IR node SgBlockDataStatement that takes its 
   79665             :  * corresponding StorageClass as parameter
   79666             :  */
   79667           0 : SgBlockDataStatement :: SgBlockDataStatement ( const SgBlockDataStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   79668             :    {
   79669             : 
   79670             : 
   79671             : /* #line 79672 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   79672             : 
   79673           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   79674           0 :      p_body =  (SgBasicBlock*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   79675             : 
   79676             : 
   79677             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   79678             : 
   79679             : 
   79680           0 :    }
   79681             : 
   79682             : //############################################################################
   79683             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   79684             :  * within the working AST. 
   79685             :  */
   79686           0 : SgBlockDataStatement * SgBlockDataStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   79687           0 :      SgBlockDataStatement* returnPointer = NULL;
   79688           0 :      if ( globalIndex != 0 )
   79689             :         {
   79690             : 
   79691             : #if FILE_IO_EXTRA_CHECK
   79692           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBlockDataStatement ) ) <= globalIndex ) ;
   79693           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBlockDataStatement + 1 ) ) );
   79694             : #endif
   79695           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBlockDataStatement )  
   79696           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBlockDataStatement );
   79697           0 :           unsigned long positionInPool = localIndex % SgBlockDataStatement::pool_size;
   79698           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBlockDataStatement::pool_size;
   79699             : 
   79700             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   79701             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   79702             : 
   79703           0 :           returnPointer = &( ( (SgBlockDataStatement*)(SgBlockDataStatement::pools[memoryBlock]) ) [positionInPool]) ;
   79704             : 
   79705           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   79706             :         }
   79707           0 :      return returnPointer ;
   79708             :    }
   79709             : 
   79710             : //############################################################################
   79711             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   79712             :   for the AST with the index astIndex
   79713             : */
   79714           0 : SgBlockDataStatement * SgBlockDataStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   79715           0 :      SgBlockDataStatement* returnPointer = NULL;
   79716           0 :      if ( globalIndex != 0 )
   79717             :         {
   79718             : 
   79719             : #if FILE_IO_EXTRA_CHECK
   79720           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBlockDataStatement ) ) <= globalIndex ) ;
   79721           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBlockDataStatement + 1 ) ) );
   79722             : #endif
   79723           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBlockDataStatement )
   79724           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBlockDataStatement );
   79725           0 :           unsigned long positionInPool = localIndex % SgBlockDataStatement::pool_size ;
   79726           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBlockDataStatement::pool_size ;
   79727             : 
   79728             : #if FILE_IO_EXTRA_CHECK
   79729             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   79730             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   79731             : #endif
   79732             : 
   79733           0 :           returnPointer = &( ( (SgBlockDataStatement*)(SgBlockDataStatement::pools[memoryBlock]) ) [positionInPool]) ;
   79734             : 
   79735             : #if FILE_IO_EXTRA_CHECK
   79736           0 :           assert ( returnPointer != NULL ) ;
   79737             : #endif
   79738             :         }
   79739           0 :      return returnPointer ;
   79740             :    }
   79741             : 
   79742             : //############################################################################
   79743             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   79744             :  * pool size! We set for every valid object in the memory pool the freepointer
   79745             :  * to the global index and increase the global index afterwards. For all the 
   79746             :  * invalid objects (means address ranges within the memory pool that were not
   79747             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   79748             :  * distinguish valid from invalid objects! 
   79749             :  */
   79750             : unsigned long
   79751           5 : SgBlockDataStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   79752             :    {
   79753           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   79754           5 :      SgBlockDataStatement* pointer = NULL;
   79755           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   79756           5 :      std::vector < unsigned char* > :: const_iterator block;
   79757           5 :      for ( block = SgBlockDataStatement::pools.begin(); block != SgBlockDataStatement::pools.end() ; ++block )
   79758             :         {
   79759           0 :           pointer = (SgBlockDataStatement*)(*block);
   79760           0 :           for (unsigned i = 0; i < SgBlockDataStatement::pool_size; ++i )
   79761             :              {
   79762             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   79763             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   79764             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   79765             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   79766             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   79767             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   79768             :             // properly; so this will have to be checked next.
   79769             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   79770             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   79771           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   79772             :                   {
   79773           0 :                     pointer[i].set_freepointer((SgBlockDataStatement*)(globalIndex));
   79774           0 :                     globalIndex++;
   79775             :                   }
   79776             :                else
   79777             :                   {
   79778           0 :                     pointer[i].set_freepointer(NULL);
   79779             :                   }
   79780             :               }
   79781             :         }
   79782           5 :      return globalIndex;
   79783             :    }
   79784             : 
   79785             : //############################################################################
   79786             : // JH (01/14/2006)
   79787             : void
   79788           5 : SgBlockDataStatement::resetValidFreepointers( )
   79789             :    {
   79790           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   79791           5 :      SgBlockDataStatement* pointer = NULL;
   79792           5 :      std::vector < unsigned char* > :: const_iterator block;
   79793           5 :      SgBlockDataStatement* pointerOfLinkedList = NULL;
   79794           5 :      for ( block = SgBlockDataStatement::pools.begin(); block != SgBlockDataStatement::pools.end() ; ++block )
   79795             :         {
   79796           0 :           pointer = (SgBlockDataStatement*)(*block);
   79797           0 :           for (unsigned i = 0; i < SgBlockDataStatement::pool_size; ++i )
   79798             :              {
   79799             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   79800             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   79801             :             // memory blocks!.
   79802           0 :                if ( pointer[i].get_freepointer() != NULL )
   79803             :                   {
   79804           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   79805             :                   }
   79806             :                else
   79807             :                   {
   79808           0 :                     if ( pointerOfLinkedList == NULL )
   79809             :                        {
   79810           0 :                          SgBlockDataStatement::next_node = &(pointer[i]);
   79811             :                        }
   79812             :                     else
   79813             :                        {
   79814             :                       // printf ("In SgBlockDataStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   79815           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   79816             :                        }
   79817             :                     pointerOfLinkedList = &(pointer[i]);
   79818             :                   }
   79819             :               }
   79820             :         }
   79821             : 
   79822           5 :      if ( pointerOfLinkedList != NULL )
   79823             :         {
   79824             :        // printf ("In SgBlockDataStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   79825           0 :           pointerOfLinkedList->set_freepointer(NULL);
   79826             :        // DQ (6/6/2010): Temporary debugging...
   79827             :        //   ROSE_ASSERT(false);
   79828             :         }
   79829             : 
   79830           5 :      return ;
   79831             :    }
   79832             : 
   79833             : //############################################################################
   79834             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   79835             :  * within the memory pool and resets the freepointers, in order to achieve a 
   79836             :  * linked list, that has no jumps and starts at the beginning! This function 
   79837             :  * does not extend the memory pool, since we do not delete any memory blocks,
   79838             :  * but delete the valid objects.  
   79839             :  */
   79840             : void
   79841           0 : SgBlockDataStatement::clearMemoryPool( )
   79842             :    {
   79843             :   // printf ("Inside of SgBlockDataStatement::clearMemoryPool() \n");
   79844             : 
   79845           0 :      SgBlockDataStatement* pointer = NULL, *tempPointer = NULL;
   79846           0 :      std::vector < unsigned char* > :: const_iterator block;
   79847           0 :      if ( SgBlockDataStatement::pools.empty() == false )
   79848             :         {
   79849           0 :           block = SgBlockDataStatement::pools.begin() ;
   79850           0 :           SgBlockDataStatement::next_node = (SgBlockDataStatement*) (*block);
   79851             : 
   79852           0 :           while ( block != SgBlockDataStatement::pools.end() )
   79853             :              {
   79854           0 :                pointer = (SgBlockDataStatement*) (*block);
   79855           0 :                if ( tempPointer != NULL )
   79856             :                   {
   79857           0 :                     tempPointer->set_freepointer(pointer);
   79858             :                   }
   79859           0 :                for (unsigned i = 0; i < SgBlockDataStatement::pool_size - 1; ++i)
   79860             :                   {
   79861           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   79862             :                   }
   79863           0 :                 pointer[SgBlockDataStatement::pool_size-1].set_freepointer(NULL);
   79864           0 :                 tempPointer = &(pointer[SgBlockDataStatement::pool_size-1]);
   79865           0 :                 ++block;
   79866             :              }
   79867             :         }
   79868           0 :    }
   79869             : 
   79870           5 : void SgBlockDataStatement::deleteMemoryPool() {
   79871           5 :   for (auto p: SgBlockDataStatement::pools) {
   79872           0 :     ROSE_FREE(p);
   79873             :   }
   79874           5 :   SgBlockDataStatement::next_node = nullptr;
   79875           5 :   SgBlockDataStatement::pools.clear();
   79876           5 : }
   79877             : 
   79878             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   79879             : //                 reading multiple binary files to for a single AST.
   79880             : /////////// new version ////////////////////////////////
   79881             : //############################################################################
   79882             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   79883             : void
   79884           2 : SgBlockDataStatement::extendMemoryPoolForFileIO( )
   79885             :   {
   79886           2 :     size_t blockIndex = SgBlockDataStatement::pools.size();
   79887           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBlockDataStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBlockDataStatement);
   79888             : 
   79889           2 :     while ( (blockIndex * SgBlockDataStatement::pool_size) < newPoolSize)
   79890             :       {
   79891             : #if ROSE_ALLOC_TRACE
   79892             :         if (blockIndex > 0) {
   79893             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBlockDataStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBlockDataStatement) = %" PRIuPTR " SgBlockDataStatement::pool_size = %d \n",
   79894             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBlockDataStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBlockDataStatement),SgBlockDataStatement::pool_size);
   79895             :         }
   79896             : #endif
   79897             : 
   79898           0 :         SgBlockDataStatement * pointer = (SgBlockDataStatement*) ROSE_MALLOC ( SgBlockDataStatement::pool_size * sizeof(SgBlockDataStatement) );
   79899           0 :         assert( pointer != NULL );
   79900             : #if ROSE_ALLOC_MEMSET == 1
   79901             :         memset(pointer, 0x00, SgBlockDataStatement::pool_size * sizeof(SgBlockDataStatement));
   79902             : #elif ROSE_ALLOC_MEMSET == 2
   79903             :         memset(pointer, 0xCC, SgBlockDataStatement::pool_size * sizeof(SgBlockDataStatement));
   79904             : #endif
   79905           0 :         SgBlockDataStatement::pools.push_back( (unsigned char*)(pointer) );
   79906           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBlockDataStatement::pool_size * sizeof(SgBlockDataStatement), V_SgBlockDataStatement ) );
   79907             : 
   79908           0 :         if ( SgBlockDataStatement::next_node != NULL ) {
   79909           0 :           if ( blockIndex > 0 ) {
   79910           0 :             SgBlockDataStatement * blkptr = (SgBlockDataStatement*)(SgBlockDataStatement::pools[blockIndex-1]);
   79911           0 :             blkptr[ SgBlockDataStatement::pool_size - 1 ].set_freepointer(pointer);
   79912             :           }
   79913             :         } else {
   79914           0 :           SgBlockDataStatement::next_node = pointer;
   79915             :         }
   79916             : 
   79917           0 :         for (unsigned i = 0; i < SgBlockDataStatement::pool_size-1; ++i)
   79918             :            {
   79919           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   79920             :            }
   79921           0 :         pointer[ SgBlockDataStatement::pool_size -1 ].set_freepointer(NULL);
   79922             : 
   79923           0 :         blockIndex++;
   79924             :       }
   79925           2 :   }
   79926             : 
   79927             : //############################################################################
   79928             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   79929             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   79930             :  * not compressed. However, that stuff is not yet implemented! 
   79931             :  */
   79932             : unsigned long
   79933           0 : SgBlockDataStatement::getNumberOfLastValidPointer()
   79934             :    {
   79935           0 :       SgBlockDataStatement* testPointer = (SgBlockDataStatement*)(SgBlockDataStatement::pools.back());
   79936           0 :       unsigned long localIndex = SgBlockDataStatement::pool_size - 1;
   79937           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   79938             :          {
   79939           0 :            localIndex--;
   79940             :          }
   79941           0 :       return (localIndex + SgBlockDataStatement::pool_size * (SgBlockDataStatement::pools.size()-1));
   79942             :    }
   79943             : 
   79944             : //############################################################################
   79945             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   79946             :  * memory pool and initializes the data member in class SgBlockDataStatementStroageClass
   79947             :  * from its counterpart of SgBlockDataStatement. The return value is just for checking, 
   79948             :  * that the whole StorageClassArray is initialized!
   79949             :  */
   79950             : unsigned long
   79951           0 : SgBlockDataStatement::initializeStorageClassArray( SgBlockDataStatementStorageClass *storageArray )
   79952             :    {
   79953           0 :      unsigned long storageCounter = 0;
   79954           0 :      std::vector < unsigned char* > :: const_iterator block = SgBlockDataStatement::pools.begin();
   79955           0 :      SgBlockDataStatement* pointer = NULL;
   79956           0 :      while ( block != SgBlockDataStatement::pools.end() ) {
   79957           0 :           pointer = (SgBlockDataStatement*) (*block);
   79958           0 :           for ( unsigned i = 0; i < SgBlockDataStatement::pool_size; ++i ) {
   79959           0 :                if ( pointer->get_freepointer() != NULL ) {
   79960           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   79961           0 :                  storageArray++;
   79962           0 :                  storageCounter++;
   79963             :                }
   79964           0 :                pointer++;
   79965             :              }
   79966           0 :            block++;
   79967             :         }
   79968           0 :      return storageCounter;
   79969             :    }
   79970             : 
   79971             : /* #line 79972 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   79972             : 
   79973             : 
   79974             : 
   79975             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   79976             : 
   79977             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   79978             : 
   79979             : //############################################################################
   79980             : /* JH (02/02/2006) Constructor of the IR node SgAssociateStatement that takes its 
   79981             :  * corresponding StorageClass as parameter
   79982             :  */
   79983           0 : SgAssociateStatement :: SgAssociateStatement ( const SgAssociateStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   79984             :    {
   79985             : 
   79986             : 
   79987             : /* #line 79988 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   79988             : 
   79989           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   79990           0 :      p_associates = storageSource.storageOf_associates.rebuildDataStoredInEasyStorageClass() ;
   79991           0 :      SgDeclarationStatementPtrList::iterator i_associates = p_associates.begin() ; 
   79992           0 :      for ( ; i_associates != p_associates.end(); ++i_associates ) 
   79993             :         {
   79994           0 :           (*i_associates) = (SgDeclarationStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_associates) ) );
   79995             :         }
   79996           0 :      p_body =  (SgBasicBlock*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   79997             : 
   79998             : 
   79999             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   80000             : 
   80001             : 
   80002           0 :    }
   80003             : 
   80004             : //############################################################################
   80005             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   80006             :  * within the working AST. 
   80007             :  */
   80008           0 : SgAssociateStatement * SgAssociateStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   80009           0 :      SgAssociateStatement* returnPointer = NULL;
   80010           0 :      if ( globalIndex != 0 )
   80011             :         {
   80012             : 
   80013             : #if FILE_IO_EXTRA_CHECK
   80014           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAssociateStatement ) ) <= globalIndex ) ;
   80015           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssociateStatement + 1 ) ) );
   80016             : #endif
   80017           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssociateStatement )  
   80018           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAssociateStatement );
   80019           0 :           unsigned long positionInPool = localIndex % SgAssociateStatement::pool_size;
   80020           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssociateStatement::pool_size;
   80021             : 
   80022             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   80023             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   80024             : 
   80025           0 :           returnPointer = &( ( (SgAssociateStatement*)(SgAssociateStatement::pools[memoryBlock]) ) [positionInPool]) ;
   80026             : 
   80027           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   80028             :         }
   80029           0 :      return returnPointer ;
   80030             :    }
   80031             : 
   80032             : //############################################################################
   80033             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   80034             :   for the AST with the index astIndex
   80035             : */
   80036           0 : SgAssociateStatement * SgAssociateStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   80037           0 :      SgAssociateStatement* returnPointer = NULL;
   80038           0 :      if ( globalIndex != 0 )
   80039             :         {
   80040             : 
   80041             : #if FILE_IO_EXTRA_CHECK
   80042           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAssociateStatement ) ) <= globalIndex ) ;
   80043           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssociateStatement + 1 ) ) );
   80044             : #endif
   80045           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssociateStatement )
   80046           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAssociateStatement );
   80047           0 :           unsigned long positionInPool = localIndex % SgAssociateStatement::pool_size ;
   80048           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssociateStatement::pool_size ;
   80049             : 
   80050             : #if FILE_IO_EXTRA_CHECK
   80051             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   80052             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   80053             : #endif
   80054             : 
   80055           0 :           returnPointer = &( ( (SgAssociateStatement*)(SgAssociateStatement::pools[memoryBlock]) ) [positionInPool]) ;
   80056             : 
   80057             : #if FILE_IO_EXTRA_CHECK
   80058           0 :           assert ( returnPointer != NULL ) ;
   80059             : #endif
   80060             :         }
   80061           0 :      return returnPointer ;
   80062             :    }
   80063             : 
   80064             : //############################################################################
   80065             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   80066             :  * pool size! We set for every valid object in the memory pool the freepointer
   80067             :  * to the global index and increase the global index afterwards. For all the 
   80068             :  * invalid objects (means address ranges within the memory pool that were not
   80069             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   80070             :  * distinguish valid from invalid objects! 
   80071             :  */
   80072             : unsigned long
   80073           5 : SgAssociateStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   80074             :    {
   80075           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   80076           5 :      SgAssociateStatement* pointer = NULL;
   80077           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   80078           5 :      std::vector < unsigned char* > :: const_iterator block;
   80079           5 :      for ( block = SgAssociateStatement::pools.begin(); block != SgAssociateStatement::pools.end() ; ++block )
   80080             :         {
   80081           0 :           pointer = (SgAssociateStatement*)(*block);
   80082           0 :           for (unsigned i = 0; i < SgAssociateStatement::pool_size; ++i )
   80083             :              {
   80084             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   80085             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   80086             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   80087             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   80088             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   80089             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   80090             :             // properly; so this will have to be checked next.
   80091             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   80092             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   80093           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   80094             :                   {
   80095           0 :                     pointer[i].set_freepointer((SgAssociateStatement*)(globalIndex));
   80096           0 :                     globalIndex++;
   80097             :                   }
   80098             :                else
   80099             :                   {
   80100           0 :                     pointer[i].set_freepointer(NULL);
   80101             :                   }
   80102             :               }
   80103             :         }
   80104           5 :      return globalIndex;
   80105             :    }
   80106             : 
   80107             : //############################################################################
   80108             : // JH (01/14/2006)
   80109             : void
   80110           5 : SgAssociateStatement::resetValidFreepointers( )
   80111             :    {
   80112           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   80113           5 :      SgAssociateStatement* pointer = NULL;
   80114           5 :      std::vector < unsigned char* > :: const_iterator block;
   80115           5 :      SgAssociateStatement* pointerOfLinkedList = NULL;
   80116           5 :      for ( block = SgAssociateStatement::pools.begin(); block != SgAssociateStatement::pools.end() ; ++block )
   80117             :         {
   80118           0 :           pointer = (SgAssociateStatement*)(*block);
   80119           0 :           for (unsigned i = 0; i < SgAssociateStatement::pool_size; ++i )
   80120             :              {
   80121             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   80122             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   80123             :             // memory blocks!.
   80124           0 :                if ( pointer[i].get_freepointer() != NULL )
   80125             :                   {
   80126           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   80127             :                   }
   80128             :                else
   80129             :                   {
   80130           0 :                     if ( pointerOfLinkedList == NULL )
   80131             :                        {
   80132           0 :                          SgAssociateStatement::next_node = &(pointer[i]);
   80133             :                        }
   80134             :                     else
   80135             :                        {
   80136             :                       // printf ("In SgAssociateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   80137           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   80138             :                        }
   80139             :                     pointerOfLinkedList = &(pointer[i]);
   80140             :                   }
   80141             :               }
   80142             :         }
   80143             : 
   80144           5 :      if ( pointerOfLinkedList != NULL )
   80145             :         {
   80146             :        // printf ("In SgAssociateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   80147           0 :           pointerOfLinkedList->set_freepointer(NULL);
   80148             :        // DQ (6/6/2010): Temporary debugging...
   80149             :        //   ROSE_ASSERT(false);
   80150             :         }
   80151             : 
   80152           5 :      return ;
   80153             :    }
   80154             : 
   80155             : //############################################################################
   80156             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   80157             :  * within the memory pool and resets the freepointers, in order to achieve a 
   80158             :  * linked list, that has no jumps and starts at the beginning! This function 
   80159             :  * does not extend the memory pool, since we do not delete any memory blocks,
   80160             :  * but delete the valid objects.  
   80161             :  */
   80162             : void
   80163           0 : SgAssociateStatement::clearMemoryPool( )
   80164             :    {
   80165             :   // printf ("Inside of SgAssociateStatement::clearMemoryPool() \n");
   80166             : 
   80167           0 :      SgAssociateStatement* pointer = NULL, *tempPointer = NULL;
   80168           0 :      std::vector < unsigned char* > :: const_iterator block;
   80169           0 :      if ( SgAssociateStatement::pools.empty() == false )
   80170             :         {
   80171           0 :           block = SgAssociateStatement::pools.begin() ;
   80172           0 :           SgAssociateStatement::next_node = (SgAssociateStatement*) (*block);
   80173             : 
   80174           0 :           while ( block != SgAssociateStatement::pools.end() )
   80175             :              {
   80176           0 :                pointer = (SgAssociateStatement*) (*block);
   80177           0 :                if ( tempPointer != NULL )
   80178             :                   {
   80179           0 :                     tempPointer->set_freepointer(pointer);
   80180             :                   }
   80181           0 :                for (unsigned i = 0; i < SgAssociateStatement::pool_size - 1; ++i)
   80182             :                   {
   80183           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   80184             :                   }
   80185           0 :                 pointer[SgAssociateStatement::pool_size-1].set_freepointer(NULL);
   80186           0 :                 tempPointer = &(pointer[SgAssociateStatement::pool_size-1]);
   80187           0 :                 ++block;
   80188             :              }
   80189             :         }
   80190           0 :    }
   80191             : 
   80192           5 : void SgAssociateStatement::deleteMemoryPool() {
   80193           5 :   for (auto p: SgAssociateStatement::pools) {
   80194           0 :     ROSE_FREE(p);
   80195             :   }
   80196           5 :   SgAssociateStatement::next_node = nullptr;
   80197           5 :   SgAssociateStatement::pools.clear();
   80198           5 : }
   80199             : 
   80200             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   80201             : //                 reading multiple binary files to for a single AST.
   80202             : /////////// new version ////////////////////////////////
   80203             : //############################################################################
   80204             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   80205             : void
   80206           2 : SgAssociateStatement::extendMemoryPoolForFileIO( )
   80207             :   {
   80208           2 :     size_t blockIndex = SgAssociateStatement::pools.size();
   80209           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAssociateStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssociateStatement);
   80210             : 
   80211           2 :     while ( (blockIndex * SgAssociateStatement::pool_size) < newPoolSize)
   80212             :       {
   80213             : #if ROSE_ALLOC_TRACE
   80214             :         if (blockIndex > 0) {
   80215             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAssociateStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssociateStatement) = %" PRIuPTR " SgAssociateStatement::pool_size = %d \n",
   80216             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAssociateStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssociateStatement),SgAssociateStatement::pool_size);
   80217             :         }
   80218             : #endif
   80219             : 
   80220           0 :         SgAssociateStatement * pointer = (SgAssociateStatement*) ROSE_MALLOC ( SgAssociateStatement::pool_size * sizeof(SgAssociateStatement) );
   80221           0 :         assert( pointer != NULL );
   80222             : #if ROSE_ALLOC_MEMSET == 1
   80223             :         memset(pointer, 0x00, SgAssociateStatement::pool_size * sizeof(SgAssociateStatement));
   80224             : #elif ROSE_ALLOC_MEMSET == 2
   80225             :         memset(pointer, 0xCC, SgAssociateStatement::pool_size * sizeof(SgAssociateStatement));
   80226             : #endif
   80227           0 :         SgAssociateStatement::pools.push_back( (unsigned char*)(pointer) );
   80228           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAssociateStatement::pool_size * sizeof(SgAssociateStatement), V_SgAssociateStatement ) );
   80229             : 
   80230           0 :         if ( SgAssociateStatement::next_node != NULL ) {
   80231           0 :           if ( blockIndex > 0 ) {
   80232           0 :             SgAssociateStatement * blkptr = (SgAssociateStatement*)(SgAssociateStatement::pools[blockIndex-1]);
   80233           0 :             blkptr[ SgAssociateStatement::pool_size - 1 ].set_freepointer(pointer);
   80234             :           }
   80235             :         } else {
   80236           0 :           SgAssociateStatement::next_node = pointer;
   80237             :         }
   80238             : 
   80239           0 :         for (unsigned i = 0; i < SgAssociateStatement::pool_size-1; ++i)
   80240             :            {
   80241           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   80242             :            }
   80243           0 :         pointer[ SgAssociateStatement::pool_size -1 ].set_freepointer(NULL);
   80244             : 
   80245           0 :         blockIndex++;
   80246             :       }
   80247           2 :   }
   80248             : 
   80249             : //############################################################################
   80250             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   80251             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   80252             :  * not compressed. However, that stuff is not yet implemented! 
   80253             :  */
   80254             : unsigned long
   80255           0 : SgAssociateStatement::getNumberOfLastValidPointer()
   80256             :    {
   80257           0 :       SgAssociateStatement* testPointer = (SgAssociateStatement*)(SgAssociateStatement::pools.back());
   80258           0 :       unsigned long localIndex = SgAssociateStatement::pool_size - 1;
   80259           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   80260             :          {
   80261           0 :            localIndex--;
   80262             :          }
   80263           0 :       return (localIndex + SgAssociateStatement::pool_size * (SgAssociateStatement::pools.size()-1));
   80264             :    }
   80265             : 
   80266             : //############################################################################
   80267             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   80268             :  * memory pool and initializes the data member in class SgAssociateStatementStroageClass
   80269             :  * from its counterpart of SgAssociateStatement. The return value is just for checking, 
   80270             :  * that the whole StorageClassArray is initialized!
   80271             :  */
   80272             : unsigned long
   80273           0 : SgAssociateStatement::initializeStorageClassArray( SgAssociateStatementStorageClass *storageArray )
   80274             :    {
   80275           0 :      unsigned long storageCounter = 0;
   80276           0 :      std::vector < unsigned char* > :: const_iterator block = SgAssociateStatement::pools.begin();
   80277           0 :      SgAssociateStatement* pointer = NULL;
   80278           0 :      while ( block != SgAssociateStatement::pools.end() ) {
   80279           0 :           pointer = (SgAssociateStatement*) (*block);
   80280           0 :           for ( unsigned i = 0; i < SgAssociateStatement::pool_size; ++i ) {
   80281           0 :                if ( pointer->get_freepointer() != NULL ) {
   80282           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   80283           0 :                  storageArray++;
   80284           0 :                  storageCounter++;
   80285             :                }
   80286           0 :                pointer++;
   80287             :              }
   80288           0 :            block++;
   80289             :         }
   80290           0 :      return storageCounter;
   80291             :    }
   80292             : 
   80293             : /* #line 80294 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   80294             : 
   80295             : 
   80296             : 
   80297             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   80298             : 
   80299             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   80300             : 
   80301             : //############################################################################
   80302             : /* JH (02/02/2006) Constructor of the IR node SgFortranDo that takes its 
   80303             :  * corresponding StorageClass as parameter
   80304             :  */
   80305           0 : SgFortranDo :: SgFortranDo ( const SgFortranDoStorageClass& storageSource )   : SgScopeStatement (storageSource)
   80306             :    {
   80307             : 
   80308             : 
   80309             : /* #line 80310 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   80310             : 
   80311           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   80312           0 :      p_initialization =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initialization) );
   80313           0 :      p_bound =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_bound) );
   80314           0 :      p_increment =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_increment) );
   80315           0 :      p_body =  (SgBasicBlock*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   80316           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   80317           0 :      p_string_label = storageSource.storageOf_string_label.rebuildDataStoredInEasyStorageClass() ;
   80318           0 :      p_old_style = storageSource.storageOf_old_style ;
   80319           0 :      p_has_end_statement = storageSource.storageOf_has_end_statement ;
   80320             : 
   80321             : 
   80322             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   80323             : 
   80324             : 
   80325           0 :    }
   80326             : 
   80327             : //############################################################################
   80328             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   80329             :  * within the working AST. 
   80330             :  */
   80331           0 : SgFortranDo * SgFortranDo::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   80332           0 :      SgFortranDo* returnPointer = NULL;
   80333           0 :      if ( globalIndex != 0 )
   80334             :         {
   80335             : 
   80336             : #if FILE_IO_EXTRA_CHECK
   80337           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFortranDo ) ) <= globalIndex ) ;
   80338           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFortranDo + 1 ) ) );
   80339             : #endif
   80340           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFortranDo )  
   80341           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFortranDo );
   80342           0 :           unsigned long positionInPool = localIndex % SgFortranDo::pool_size;
   80343           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFortranDo::pool_size;
   80344             : 
   80345             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   80346             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   80347             : 
   80348           0 :           returnPointer = &( ( (SgFortranDo*)(SgFortranDo::pools[memoryBlock]) ) [positionInPool]) ;
   80349             : 
   80350           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   80351             :         }
   80352           0 :      return returnPointer ;
   80353             :    }
   80354             : 
   80355             : //############################################################################
   80356             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   80357             :   for the AST with the index astIndex
   80358             : */
   80359           0 : SgFortranDo * SgFortranDo::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   80360           0 :      SgFortranDo* returnPointer = NULL;
   80361           0 :      if ( globalIndex != 0 )
   80362             :         {
   80363             : 
   80364             : #if FILE_IO_EXTRA_CHECK
   80365           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFortranDo ) ) <= globalIndex ) ;
   80366           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFortranDo + 1 ) ) );
   80367             : #endif
   80368           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFortranDo )
   80369           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFortranDo );
   80370           0 :           unsigned long positionInPool = localIndex % SgFortranDo::pool_size ;
   80371           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFortranDo::pool_size ;
   80372             : 
   80373             : #if FILE_IO_EXTRA_CHECK
   80374             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   80375             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   80376             : #endif
   80377             : 
   80378           0 :           returnPointer = &( ( (SgFortranDo*)(SgFortranDo::pools[memoryBlock]) ) [positionInPool]) ;
   80379             : 
   80380             : #if FILE_IO_EXTRA_CHECK
   80381           0 :           assert ( returnPointer != NULL ) ;
   80382             : #endif
   80383             :         }
   80384           0 :      return returnPointer ;
   80385             :    }
   80386             : 
   80387             : //############################################################################
   80388             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   80389             :  * pool size! We set for every valid object in the memory pool the freepointer
   80390             :  * to the global index and increase the global index afterwards. For all the 
   80391             :  * invalid objects (means address ranges within the memory pool that were not
   80392             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   80393             :  * distinguish valid from invalid objects! 
   80394             :  */
   80395             : unsigned long
   80396           5 : SgFortranDo::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   80397             :    {
   80398           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   80399           5 :      SgFortranDo* pointer = NULL;
   80400           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   80401           5 :      std::vector < unsigned char* > :: const_iterator block;
   80402           5 :      for ( block = SgFortranDo::pools.begin(); block != SgFortranDo::pools.end() ; ++block )
   80403             :         {
   80404           0 :           pointer = (SgFortranDo*)(*block);
   80405           0 :           for (unsigned i = 0; i < SgFortranDo::pool_size; ++i )
   80406             :              {
   80407             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   80408             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   80409             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   80410             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   80411             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   80412             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   80413             :             // properly; so this will have to be checked next.
   80414             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   80415             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   80416           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   80417             :                   {
   80418           0 :                     pointer[i].set_freepointer((SgFortranDo*)(globalIndex));
   80419           0 :                     globalIndex++;
   80420             :                   }
   80421             :                else
   80422             :                   {
   80423           0 :                     pointer[i].set_freepointer(NULL);
   80424             :                   }
   80425             :               }
   80426             :         }
   80427           5 :      return globalIndex;
   80428             :    }
   80429             : 
   80430             : //############################################################################
   80431             : // JH (01/14/2006)
   80432             : void
   80433           5 : SgFortranDo::resetValidFreepointers( )
   80434             :    {
   80435           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   80436           5 :      SgFortranDo* pointer = NULL;
   80437           5 :      std::vector < unsigned char* > :: const_iterator block;
   80438           5 :      SgFortranDo* pointerOfLinkedList = NULL;
   80439           5 :      for ( block = SgFortranDo::pools.begin(); block != SgFortranDo::pools.end() ; ++block )
   80440             :         {
   80441           0 :           pointer = (SgFortranDo*)(*block);
   80442           0 :           for (unsigned i = 0; i < SgFortranDo::pool_size; ++i )
   80443             :              {
   80444             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   80445             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   80446             :             // memory blocks!.
   80447           0 :                if ( pointer[i].get_freepointer() != NULL )
   80448             :                   {
   80449           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   80450             :                   }
   80451             :                else
   80452             :                   {
   80453           0 :                     if ( pointerOfLinkedList == NULL )
   80454             :                        {
   80455           0 :                          SgFortranDo::next_node = &(pointer[i]);
   80456             :                        }
   80457             :                     else
   80458             :                        {
   80459             :                       // printf ("In SgFortranDo::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   80460           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   80461             :                        }
   80462             :                     pointerOfLinkedList = &(pointer[i]);
   80463             :                   }
   80464             :               }
   80465             :         }
   80466             : 
   80467           5 :      if ( pointerOfLinkedList != NULL )
   80468             :         {
   80469             :        // printf ("In SgFortranDo::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   80470           0 :           pointerOfLinkedList->set_freepointer(NULL);
   80471             :        // DQ (6/6/2010): Temporary debugging...
   80472             :        //   ROSE_ASSERT(false);
   80473             :         }
   80474             : 
   80475           5 :      return ;
   80476             :    }
   80477             : 
   80478             : //############################################################################
   80479             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   80480             :  * within the memory pool and resets the freepointers, in order to achieve a 
   80481             :  * linked list, that has no jumps and starts at the beginning! This function 
   80482             :  * does not extend the memory pool, since we do not delete any memory blocks,
   80483             :  * but delete the valid objects.  
   80484             :  */
   80485             : void
   80486           0 : SgFortranDo::clearMemoryPool( )
   80487             :    {
   80488             :   // printf ("Inside of SgFortranDo::clearMemoryPool() \n");
   80489             : 
   80490           0 :      SgFortranDo* pointer = NULL, *tempPointer = NULL;
   80491           0 :      std::vector < unsigned char* > :: const_iterator block;
   80492           0 :      if ( SgFortranDo::pools.empty() == false )
   80493             :         {
   80494           0 :           block = SgFortranDo::pools.begin() ;
   80495           0 :           SgFortranDo::next_node = (SgFortranDo*) (*block);
   80496             : 
   80497           0 :           while ( block != SgFortranDo::pools.end() )
   80498             :              {
   80499           0 :                pointer = (SgFortranDo*) (*block);
   80500           0 :                if ( tempPointer != NULL )
   80501             :                   {
   80502           0 :                     tempPointer->set_freepointer(pointer);
   80503             :                   }
   80504           0 :                for (unsigned i = 0; i < SgFortranDo::pool_size - 1; ++i)
   80505             :                   {
   80506           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   80507             :                   }
   80508           0 :                 pointer[SgFortranDo::pool_size-1].set_freepointer(NULL);
   80509           0 :                 tempPointer = &(pointer[SgFortranDo::pool_size-1]);
   80510           0 :                 ++block;
   80511             :              }
   80512             :         }
   80513           0 :    }
   80514             : 
   80515           5 : void SgFortranDo::deleteMemoryPool() {
   80516           5 :   for (auto p: SgFortranDo::pools) {
   80517           0 :     ROSE_FREE(p);
   80518             :   }
   80519           5 :   SgFortranDo::next_node = nullptr;
   80520           5 :   SgFortranDo::pools.clear();
   80521           5 : }
   80522             : 
   80523             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   80524             : //                 reading multiple binary files to for a single AST.
   80525             : /////////// new version ////////////////////////////////
   80526             : //############################################################################
   80527             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   80528             : void
   80529           2 : SgFortranDo::extendMemoryPoolForFileIO( )
   80530             :   {
   80531           2 :     size_t blockIndex = SgFortranDo::pools.size();
   80532           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranDo) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranDo);
   80533             : 
   80534           2 :     while ( (blockIndex * SgFortranDo::pool_size) < newPoolSize)
   80535             :       {
   80536             : #if ROSE_ALLOC_TRACE
   80537             :         if (blockIndex > 0) {
   80538             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranDo) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranDo) = %" PRIuPTR " SgFortranDo::pool_size = %d \n",
   80539             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranDo),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranDo),SgFortranDo::pool_size);
   80540             :         }
   80541             : #endif
   80542             : 
   80543           0 :         SgFortranDo * pointer = (SgFortranDo*) ROSE_MALLOC ( SgFortranDo::pool_size * sizeof(SgFortranDo) );
   80544           0 :         assert( pointer != NULL );
   80545             : #if ROSE_ALLOC_MEMSET == 1
   80546             :         memset(pointer, 0x00, SgFortranDo::pool_size * sizeof(SgFortranDo));
   80547             : #elif ROSE_ALLOC_MEMSET == 2
   80548             :         memset(pointer, 0xCC, SgFortranDo::pool_size * sizeof(SgFortranDo));
   80549             : #endif
   80550           0 :         SgFortranDo::pools.push_back( (unsigned char*)(pointer) );
   80551           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFortranDo::pool_size * sizeof(SgFortranDo), V_SgFortranDo ) );
   80552             : 
   80553           0 :         if ( SgFortranDo::next_node != NULL ) {
   80554           0 :           if ( blockIndex > 0 ) {
   80555           0 :             SgFortranDo * blkptr = (SgFortranDo*)(SgFortranDo::pools[blockIndex-1]);
   80556           0 :             blkptr[ SgFortranDo::pool_size - 1 ].set_freepointer(pointer);
   80557             :           }
   80558             :         } else {
   80559           0 :           SgFortranDo::next_node = pointer;
   80560             :         }
   80561             : 
   80562           0 :         for (unsigned i = 0; i < SgFortranDo::pool_size-1; ++i)
   80563             :            {
   80564           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   80565             :            }
   80566           0 :         pointer[ SgFortranDo::pool_size -1 ].set_freepointer(NULL);
   80567             : 
   80568           0 :         blockIndex++;
   80569             :       }
   80570           2 :   }
   80571             : 
   80572             : //############################################################################
   80573             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   80574             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   80575             :  * not compressed. However, that stuff is not yet implemented! 
   80576             :  */
   80577             : unsigned long
   80578           0 : SgFortranDo::getNumberOfLastValidPointer()
   80579             :    {
   80580           0 :       SgFortranDo* testPointer = (SgFortranDo*)(SgFortranDo::pools.back());
   80581           0 :       unsigned long localIndex = SgFortranDo::pool_size - 1;
   80582           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   80583             :          {
   80584           0 :            localIndex--;
   80585             :          }
   80586           0 :       return (localIndex + SgFortranDo::pool_size * (SgFortranDo::pools.size()-1));
   80587             :    }
   80588             : 
   80589             : //############################################################################
   80590             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   80591             :  * memory pool and initializes the data member in class SgFortranDoStroageClass
   80592             :  * from its counterpart of SgFortranDo. The return value is just for checking, 
   80593             :  * that the whole StorageClassArray is initialized!
   80594             :  */
   80595             : unsigned long
   80596           0 : SgFortranDo::initializeStorageClassArray( SgFortranDoStorageClass *storageArray )
   80597             :    {
   80598           0 :      unsigned long storageCounter = 0;
   80599           0 :      std::vector < unsigned char* > :: const_iterator block = SgFortranDo::pools.begin();
   80600           0 :      SgFortranDo* pointer = NULL;
   80601           0 :      while ( block != SgFortranDo::pools.end() ) {
   80602           0 :           pointer = (SgFortranDo*) (*block);
   80603           0 :           for ( unsigned i = 0; i < SgFortranDo::pool_size; ++i ) {
   80604           0 :                if ( pointer->get_freepointer() != NULL ) {
   80605           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   80606           0 :                  storageArray++;
   80607           0 :                  storageCounter++;
   80608             :                }
   80609           0 :                pointer++;
   80610             :              }
   80611           0 :            block++;
   80612             :         }
   80613           0 :      return storageCounter;
   80614             :    }
   80615             : 
   80616             : /* #line 80617 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   80617             : 
   80618             : 
   80619             : 
   80620             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   80621             : 
   80622             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   80623             : 
   80624             : //############################################################################
   80625             : /* JH (02/02/2006) Constructor of the IR node SgFortranNonblockedDo that takes its 
   80626             :  * corresponding StorageClass as parameter
   80627             :  */
   80628           0 : SgFortranNonblockedDo :: SgFortranNonblockedDo ( const SgFortranNonblockedDoStorageClass& storageSource )   : SgFortranDo (storageSource)
   80629             :    {
   80630             : 
   80631             : 
   80632             : /* #line 80633 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   80633             : 
   80634           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   80635           0 :      p_end_statement =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_statement) );
   80636             : 
   80637             : 
   80638             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   80639             : 
   80640             : 
   80641           0 :    }
   80642             : 
   80643             : //############################################################################
   80644             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   80645             :  * within the working AST. 
   80646             :  */
   80647           0 : SgFortranNonblockedDo * SgFortranNonblockedDo::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   80648           0 :      SgFortranNonblockedDo* returnPointer = NULL;
   80649           0 :      if ( globalIndex != 0 )
   80650             :         {
   80651             : 
   80652             : #if FILE_IO_EXTRA_CHECK
   80653           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFortranNonblockedDo ) ) <= globalIndex ) ;
   80654           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFortranNonblockedDo + 1 ) ) );
   80655             : #endif
   80656           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFortranNonblockedDo )  
   80657           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFortranNonblockedDo );
   80658           0 :           unsigned long positionInPool = localIndex % SgFortranNonblockedDo::pool_size;
   80659           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFortranNonblockedDo::pool_size;
   80660             : 
   80661             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   80662             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   80663             : 
   80664           0 :           returnPointer = &( ( (SgFortranNonblockedDo*)(SgFortranNonblockedDo::pools[memoryBlock]) ) [positionInPool]) ;
   80665             : 
   80666           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   80667             :         }
   80668           0 :      return returnPointer ;
   80669             :    }
   80670             : 
   80671             : //############################################################################
   80672             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   80673             :   for the AST with the index astIndex
   80674             : */
   80675           0 : SgFortranNonblockedDo * SgFortranNonblockedDo::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   80676           0 :      SgFortranNonblockedDo* returnPointer = NULL;
   80677           0 :      if ( globalIndex != 0 )
   80678             :         {
   80679             : 
   80680             : #if FILE_IO_EXTRA_CHECK
   80681           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFortranNonblockedDo ) ) <= globalIndex ) ;
   80682           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFortranNonblockedDo + 1 ) ) );
   80683             : #endif
   80684           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFortranNonblockedDo )
   80685           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFortranNonblockedDo );
   80686           0 :           unsigned long positionInPool = localIndex % SgFortranNonblockedDo::pool_size ;
   80687           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFortranNonblockedDo::pool_size ;
   80688             : 
   80689             : #if FILE_IO_EXTRA_CHECK
   80690             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   80691             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   80692             : #endif
   80693             : 
   80694           0 :           returnPointer = &( ( (SgFortranNonblockedDo*)(SgFortranNonblockedDo::pools[memoryBlock]) ) [positionInPool]) ;
   80695             : 
   80696             : #if FILE_IO_EXTRA_CHECK
   80697           0 :           assert ( returnPointer != NULL ) ;
   80698             : #endif
   80699             :         }
   80700           0 :      return returnPointer ;
   80701             :    }
   80702             : 
   80703             : //############################################################################
   80704             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   80705             :  * pool size! We set for every valid object in the memory pool the freepointer
   80706             :  * to the global index and increase the global index afterwards. For all the 
   80707             :  * invalid objects (means address ranges within the memory pool that were not
   80708             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   80709             :  * distinguish valid from invalid objects! 
   80710             :  */
   80711             : unsigned long
   80712           5 : SgFortranNonblockedDo::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   80713             :    {
   80714           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   80715           5 :      SgFortranNonblockedDo* pointer = NULL;
   80716           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   80717           5 :      std::vector < unsigned char* > :: const_iterator block;
   80718           5 :      for ( block = SgFortranNonblockedDo::pools.begin(); block != SgFortranNonblockedDo::pools.end() ; ++block )
   80719             :         {
   80720           0 :           pointer = (SgFortranNonblockedDo*)(*block);
   80721           0 :           for (unsigned i = 0; i < SgFortranNonblockedDo::pool_size; ++i )
   80722             :              {
   80723             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   80724             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   80725             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   80726             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   80727             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   80728             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   80729             :             // properly; so this will have to be checked next.
   80730             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   80731             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   80732           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   80733             :                   {
   80734           0 :                     pointer[i].set_freepointer((SgFortranNonblockedDo*)(globalIndex));
   80735           0 :                     globalIndex++;
   80736             :                   }
   80737             :                else
   80738             :                   {
   80739           0 :                     pointer[i].set_freepointer(NULL);
   80740             :                   }
   80741             :               }
   80742             :         }
   80743           5 :      return globalIndex;
   80744             :    }
   80745             : 
   80746             : //############################################################################
   80747             : // JH (01/14/2006)
   80748             : void
   80749           5 : SgFortranNonblockedDo::resetValidFreepointers( )
   80750             :    {
   80751           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   80752           5 :      SgFortranNonblockedDo* pointer = NULL;
   80753           5 :      std::vector < unsigned char* > :: const_iterator block;
   80754           5 :      SgFortranNonblockedDo* pointerOfLinkedList = NULL;
   80755           5 :      for ( block = SgFortranNonblockedDo::pools.begin(); block != SgFortranNonblockedDo::pools.end() ; ++block )
   80756             :         {
   80757           0 :           pointer = (SgFortranNonblockedDo*)(*block);
   80758           0 :           for (unsigned i = 0; i < SgFortranNonblockedDo::pool_size; ++i )
   80759             :              {
   80760             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   80761             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   80762             :             // memory blocks!.
   80763           0 :                if ( pointer[i].get_freepointer() != NULL )
   80764             :                   {
   80765           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   80766             :                   }
   80767             :                else
   80768             :                   {
   80769           0 :                     if ( pointerOfLinkedList == NULL )
   80770             :                        {
   80771           0 :                          SgFortranNonblockedDo::next_node = &(pointer[i]);
   80772             :                        }
   80773             :                     else
   80774             :                        {
   80775             :                       // printf ("In SgFortranNonblockedDo::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   80776           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   80777             :                        }
   80778             :                     pointerOfLinkedList = &(pointer[i]);
   80779             :                   }
   80780             :               }
   80781             :         }
   80782             : 
   80783           5 :      if ( pointerOfLinkedList != NULL )
   80784             :         {
   80785             :        // printf ("In SgFortranNonblockedDo::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   80786           0 :           pointerOfLinkedList->set_freepointer(NULL);
   80787             :        // DQ (6/6/2010): Temporary debugging...
   80788             :        //   ROSE_ASSERT(false);
   80789             :         }
   80790             : 
   80791           5 :      return ;
   80792             :    }
   80793             : 
   80794             : //############################################################################
   80795             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   80796             :  * within the memory pool and resets the freepointers, in order to achieve a 
   80797             :  * linked list, that has no jumps and starts at the beginning! This function 
   80798             :  * does not extend the memory pool, since we do not delete any memory blocks,
   80799             :  * but delete the valid objects.  
   80800             :  */
   80801             : void
   80802           0 : SgFortranNonblockedDo::clearMemoryPool( )
   80803             :    {
   80804             :   // printf ("Inside of SgFortranNonblockedDo::clearMemoryPool() \n");
   80805             : 
   80806           0 :      SgFortranNonblockedDo* pointer = NULL, *tempPointer = NULL;
   80807           0 :      std::vector < unsigned char* > :: const_iterator block;
   80808           0 :      if ( SgFortranNonblockedDo::pools.empty() == false )
   80809             :         {
   80810           0 :           block = SgFortranNonblockedDo::pools.begin() ;
   80811           0 :           SgFortranNonblockedDo::next_node = (SgFortranNonblockedDo*) (*block);
   80812             : 
   80813           0 :           while ( block != SgFortranNonblockedDo::pools.end() )
   80814             :              {
   80815           0 :                pointer = (SgFortranNonblockedDo*) (*block);
   80816           0 :                if ( tempPointer != NULL )
   80817             :                   {
   80818           0 :                     tempPointer->set_freepointer(pointer);
   80819             :                   }
   80820           0 :                for (unsigned i = 0; i < SgFortranNonblockedDo::pool_size - 1; ++i)
   80821             :                   {
   80822           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   80823             :                   }
   80824           0 :                 pointer[SgFortranNonblockedDo::pool_size-1].set_freepointer(NULL);
   80825           0 :                 tempPointer = &(pointer[SgFortranNonblockedDo::pool_size-1]);
   80826           0 :                 ++block;
   80827             :              }
   80828             :         }
   80829           0 :    }
   80830             : 
   80831           5 : void SgFortranNonblockedDo::deleteMemoryPool() {
   80832           5 :   for (auto p: SgFortranNonblockedDo::pools) {
   80833           0 :     ROSE_FREE(p);
   80834             :   }
   80835           5 :   SgFortranNonblockedDo::next_node = nullptr;
   80836           5 :   SgFortranNonblockedDo::pools.clear();
   80837           5 : }
   80838             : 
   80839             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   80840             : //                 reading multiple binary files to for a single AST.
   80841             : /////////// new version ////////////////////////////////
   80842             : //############################################################################
   80843             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   80844             : void
   80845           2 : SgFortranNonblockedDo::extendMemoryPoolForFileIO( )
   80846             :   {
   80847           2 :     size_t blockIndex = SgFortranNonblockedDo::pools.size();
   80848           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranNonblockedDo) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranNonblockedDo);
   80849             : 
   80850           2 :     while ( (blockIndex * SgFortranNonblockedDo::pool_size) < newPoolSize)
   80851             :       {
   80852             : #if ROSE_ALLOC_TRACE
   80853             :         if (blockIndex > 0) {
   80854             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranNonblockedDo) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranNonblockedDo) = %" PRIuPTR " SgFortranNonblockedDo::pool_size = %d \n",
   80855             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranNonblockedDo),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranNonblockedDo),SgFortranNonblockedDo::pool_size);
   80856             :         }
   80857             : #endif
   80858             : 
   80859           0 :         SgFortranNonblockedDo * pointer = (SgFortranNonblockedDo*) ROSE_MALLOC ( SgFortranNonblockedDo::pool_size * sizeof(SgFortranNonblockedDo) );
   80860           0 :         assert( pointer != NULL );
   80861             : #if ROSE_ALLOC_MEMSET == 1
   80862             :         memset(pointer, 0x00, SgFortranNonblockedDo::pool_size * sizeof(SgFortranNonblockedDo));
   80863             : #elif ROSE_ALLOC_MEMSET == 2
   80864             :         memset(pointer, 0xCC, SgFortranNonblockedDo::pool_size * sizeof(SgFortranNonblockedDo));
   80865             : #endif
   80866           0 :         SgFortranNonblockedDo::pools.push_back( (unsigned char*)(pointer) );
   80867           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFortranNonblockedDo::pool_size * sizeof(SgFortranNonblockedDo), V_SgFortranNonblockedDo ) );
   80868             : 
   80869           0 :         if ( SgFortranNonblockedDo::next_node != NULL ) {
   80870           0 :           if ( blockIndex > 0 ) {
   80871           0 :             SgFortranNonblockedDo * blkptr = (SgFortranNonblockedDo*)(SgFortranNonblockedDo::pools[blockIndex-1]);
   80872           0 :             blkptr[ SgFortranNonblockedDo::pool_size - 1 ].set_freepointer(pointer);
   80873             :           }
   80874             :         } else {
   80875           0 :           SgFortranNonblockedDo::next_node = pointer;
   80876             :         }
   80877             : 
   80878           0 :         for (unsigned i = 0; i < SgFortranNonblockedDo::pool_size-1; ++i)
   80879             :            {
   80880           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   80881             :            }
   80882           0 :         pointer[ SgFortranNonblockedDo::pool_size -1 ].set_freepointer(NULL);
   80883             : 
   80884           0 :         blockIndex++;
   80885             :       }
   80886           2 :   }
   80887             : 
   80888             : //############################################################################
   80889             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   80890             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   80891             :  * not compressed. However, that stuff is not yet implemented! 
   80892             :  */
   80893             : unsigned long
   80894           0 : SgFortranNonblockedDo::getNumberOfLastValidPointer()
   80895             :    {
   80896           0 :       SgFortranNonblockedDo* testPointer = (SgFortranNonblockedDo*)(SgFortranNonblockedDo::pools.back());
   80897           0 :       unsigned long localIndex = SgFortranNonblockedDo::pool_size - 1;
   80898           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   80899             :          {
   80900           0 :            localIndex--;
   80901             :          }
   80902           0 :       return (localIndex + SgFortranNonblockedDo::pool_size * (SgFortranNonblockedDo::pools.size()-1));
   80903             :    }
   80904             : 
   80905             : //############################################################################
   80906             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   80907             :  * memory pool and initializes the data member in class SgFortranNonblockedDoStroageClass
   80908             :  * from its counterpart of SgFortranNonblockedDo. The return value is just for checking, 
   80909             :  * that the whole StorageClassArray is initialized!
   80910             :  */
   80911             : unsigned long
   80912           0 : SgFortranNonblockedDo::initializeStorageClassArray( SgFortranNonblockedDoStorageClass *storageArray )
   80913             :    {
   80914           0 :      unsigned long storageCounter = 0;
   80915           0 :      std::vector < unsigned char* > :: const_iterator block = SgFortranNonblockedDo::pools.begin();
   80916           0 :      SgFortranNonblockedDo* pointer = NULL;
   80917           0 :      while ( block != SgFortranNonblockedDo::pools.end() ) {
   80918           0 :           pointer = (SgFortranNonblockedDo*) (*block);
   80919           0 :           for ( unsigned i = 0; i < SgFortranNonblockedDo::pool_size; ++i ) {
   80920           0 :                if ( pointer->get_freepointer() != NULL ) {
   80921           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   80922           0 :                  storageArray++;
   80923           0 :                  storageCounter++;
   80924             :                }
   80925           0 :                pointer++;
   80926             :              }
   80927           0 :            block++;
   80928             :         }
   80929           0 :      return storageCounter;
   80930             :    }
   80931             : 
   80932             : /* #line 80933 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   80933             : 
   80934             : 
   80935             : 
   80936             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   80937             : 
   80938             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   80939             : 
   80940             : //############################################################################
   80941             : /* JH (02/02/2006) Constructor of the IR node SgForAllStatement that takes its 
   80942             :  * corresponding StorageClass as parameter
   80943             :  */
   80944           0 : SgForAllStatement :: SgForAllStatement ( const SgForAllStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   80945             :    {
   80946             : 
   80947             : 
   80948             : /* #line 80949 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   80949             : 
   80950           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   80951           0 :      p_forall_header =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_forall_header) );
   80952           0 :      p_body =  (SgBasicBlock*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   80953           0 :      p_has_end_statement = storageSource.storageOf_has_end_statement ;
   80954           0 :      p_string_label = storageSource.storageOf_string_label.rebuildDataStoredInEasyStorageClass() ;
   80955           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   80956           0 :      p_forall_statement_kind = storageSource.storageOf_forall_statement_kind ;
   80957             : 
   80958             : 
   80959             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   80960             : 
   80961             : 
   80962           0 :    }
   80963             : 
   80964             : //############################################################################
   80965             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   80966             :  * within the working AST. 
   80967             :  */
   80968           0 : SgForAllStatement * SgForAllStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   80969           0 :      SgForAllStatement* returnPointer = NULL;
   80970           0 :      if ( globalIndex != 0 )
   80971             :         {
   80972             : 
   80973             : #if FILE_IO_EXTRA_CHECK
   80974           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgForAllStatement ) ) <= globalIndex ) ;
   80975           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgForAllStatement + 1 ) ) );
   80976             : #endif
   80977           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgForAllStatement )  
   80978           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgForAllStatement );
   80979           0 :           unsigned long positionInPool = localIndex % SgForAllStatement::pool_size;
   80980           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgForAllStatement::pool_size;
   80981             : 
   80982             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   80983             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   80984             : 
   80985           0 :           returnPointer = &( ( (SgForAllStatement*)(SgForAllStatement::pools[memoryBlock]) ) [positionInPool]) ;
   80986             : 
   80987           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   80988             :         }
   80989           0 :      return returnPointer ;
   80990             :    }
   80991             : 
   80992             : //############################################################################
   80993             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   80994             :   for the AST with the index astIndex
   80995             : */
   80996           0 : SgForAllStatement * SgForAllStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   80997           0 :      SgForAllStatement* returnPointer = NULL;
   80998           0 :      if ( globalIndex != 0 )
   80999             :         {
   81000             : 
   81001             : #if FILE_IO_EXTRA_CHECK
   81002           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgForAllStatement ) ) <= globalIndex ) ;
   81003           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgForAllStatement + 1 ) ) );
   81004             : #endif
   81005           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgForAllStatement )
   81006           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgForAllStatement );
   81007           0 :           unsigned long positionInPool = localIndex % SgForAllStatement::pool_size ;
   81008           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgForAllStatement::pool_size ;
   81009             : 
   81010             : #if FILE_IO_EXTRA_CHECK
   81011             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   81012             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   81013             : #endif
   81014             : 
   81015           0 :           returnPointer = &( ( (SgForAllStatement*)(SgForAllStatement::pools[memoryBlock]) ) [positionInPool]) ;
   81016             : 
   81017             : #if FILE_IO_EXTRA_CHECK
   81018           0 :           assert ( returnPointer != NULL ) ;
   81019             : #endif
   81020             :         }
   81021           0 :      return returnPointer ;
   81022             :    }
   81023             : 
   81024             : //############################################################################
   81025             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   81026             :  * pool size! We set for every valid object in the memory pool the freepointer
   81027             :  * to the global index and increase the global index afterwards. For all the 
   81028             :  * invalid objects (means address ranges within the memory pool that were not
   81029             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   81030             :  * distinguish valid from invalid objects! 
   81031             :  */
   81032             : unsigned long
   81033           5 : SgForAllStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   81034             :    {
   81035           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   81036           5 :      SgForAllStatement* pointer = NULL;
   81037           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   81038           5 :      std::vector < unsigned char* > :: const_iterator block;
   81039           5 :      for ( block = SgForAllStatement::pools.begin(); block != SgForAllStatement::pools.end() ; ++block )
   81040             :         {
   81041           0 :           pointer = (SgForAllStatement*)(*block);
   81042           0 :           for (unsigned i = 0; i < SgForAllStatement::pool_size; ++i )
   81043             :              {
   81044             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   81045             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   81046             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   81047             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   81048             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   81049             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   81050             :             // properly; so this will have to be checked next.
   81051             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   81052             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   81053           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   81054             :                   {
   81055           0 :                     pointer[i].set_freepointer((SgForAllStatement*)(globalIndex));
   81056           0 :                     globalIndex++;
   81057             :                   }
   81058             :                else
   81059             :                   {
   81060           0 :                     pointer[i].set_freepointer(NULL);
   81061             :                   }
   81062             :               }
   81063             :         }
   81064           5 :      return globalIndex;
   81065             :    }
   81066             : 
   81067             : //############################################################################
   81068             : // JH (01/14/2006)
   81069             : void
   81070           5 : SgForAllStatement::resetValidFreepointers( )
   81071             :    {
   81072           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   81073           5 :      SgForAllStatement* pointer = NULL;
   81074           5 :      std::vector < unsigned char* > :: const_iterator block;
   81075           5 :      SgForAllStatement* pointerOfLinkedList = NULL;
   81076           5 :      for ( block = SgForAllStatement::pools.begin(); block != SgForAllStatement::pools.end() ; ++block )
   81077             :         {
   81078           0 :           pointer = (SgForAllStatement*)(*block);
   81079           0 :           for (unsigned i = 0; i < SgForAllStatement::pool_size; ++i )
   81080             :              {
   81081             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   81082             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   81083             :             // memory blocks!.
   81084           0 :                if ( pointer[i].get_freepointer() != NULL )
   81085             :                   {
   81086           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   81087             :                   }
   81088             :                else
   81089             :                   {
   81090           0 :                     if ( pointerOfLinkedList == NULL )
   81091             :                        {
   81092           0 :                          SgForAllStatement::next_node = &(pointer[i]);
   81093             :                        }
   81094             :                     else
   81095             :                        {
   81096             :                       // printf ("In SgForAllStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   81097           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   81098             :                        }
   81099             :                     pointerOfLinkedList = &(pointer[i]);
   81100             :                   }
   81101             :               }
   81102             :         }
   81103             : 
   81104           5 :      if ( pointerOfLinkedList != NULL )
   81105             :         {
   81106             :        // printf ("In SgForAllStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   81107           0 :           pointerOfLinkedList->set_freepointer(NULL);
   81108             :        // DQ (6/6/2010): Temporary debugging...
   81109             :        //   ROSE_ASSERT(false);
   81110             :         }
   81111             : 
   81112           5 :      return ;
   81113             :    }
   81114             : 
   81115             : //############################################################################
   81116             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   81117             :  * within the memory pool and resets the freepointers, in order to achieve a 
   81118             :  * linked list, that has no jumps and starts at the beginning! This function 
   81119             :  * does not extend the memory pool, since we do not delete any memory blocks,
   81120             :  * but delete the valid objects.  
   81121             :  */
   81122             : void
   81123           0 : SgForAllStatement::clearMemoryPool( )
   81124             :    {
   81125             :   // printf ("Inside of SgForAllStatement::clearMemoryPool() \n");
   81126             : 
   81127           0 :      SgForAllStatement* pointer = NULL, *tempPointer = NULL;
   81128           0 :      std::vector < unsigned char* > :: const_iterator block;
   81129           0 :      if ( SgForAllStatement::pools.empty() == false )
   81130             :         {
   81131           0 :           block = SgForAllStatement::pools.begin() ;
   81132           0 :           SgForAllStatement::next_node = (SgForAllStatement*) (*block);
   81133             : 
   81134           0 :           while ( block != SgForAllStatement::pools.end() )
   81135             :              {
   81136           0 :                pointer = (SgForAllStatement*) (*block);
   81137           0 :                if ( tempPointer != NULL )
   81138             :                   {
   81139           0 :                     tempPointer->set_freepointer(pointer);
   81140             :                   }
   81141           0 :                for (unsigned i = 0; i < SgForAllStatement::pool_size - 1; ++i)
   81142             :                   {
   81143           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   81144             :                   }
   81145           0 :                 pointer[SgForAllStatement::pool_size-1].set_freepointer(NULL);
   81146           0 :                 tempPointer = &(pointer[SgForAllStatement::pool_size-1]);
   81147           0 :                 ++block;
   81148             :              }
   81149             :         }
   81150           0 :    }
   81151             : 
   81152           5 : void SgForAllStatement::deleteMemoryPool() {
   81153           5 :   for (auto p: SgForAllStatement::pools) {
   81154           0 :     ROSE_FREE(p);
   81155             :   }
   81156           5 :   SgForAllStatement::next_node = nullptr;
   81157           5 :   SgForAllStatement::pools.clear();
   81158           5 : }
   81159             : 
   81160             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   81161             : //                 reading multiple binary files to for a single AST.
   81162             : /////////// new version ////////////////////////////////
   81163             : //############################################################################
   81164             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   81165             : void
   81166           2 : SgForAllStatement::extendMemoryPoolForFileIO( )
   81167             :   {
   81168           2 :     size_t blockIndex = SgForAllStatement::pools.size();
   81169           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgForAllStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgForAllStatement);
   81170             : 
   81171           2 :     while ( (blockIndex * SgForAllStatement::pool_size) < newPoolSize)
   81172             :       {
   81173             : #if ROSE_ALLOC_TRACE
   81174             :         if (blockIndex > 0) {
   81175             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgForAllStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgForAllStatement) = %" PRIuPTR " SgForAllStatement::pool_size = %d \n",
   81176             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgForAllStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgForAllStatement),SgForAllStatement::pool_size);
   81177             :         }
   81178             : #endif
   81179             : 
   81180           0 :         SgForAllStatement * pointer = (SgForAllStatement*) ROSE_MALLOC ( SgForAllStatement::pool_size * sizeof(SgForAllStatement) );
   81181           0 :         assert( pointer != NULL );
   81182             : #if ROSE_ALLOC_MEMSET == 1
   81183             :         memset(pointer, 0x00, SgForAllStatement::pool_size * sizeof(SgForAllStatement));
   81184             : #elif ROSE_ALLOC_MEMSET == 2
   81185             :         memset(pointer, 0xCC, SgForAllStatement::pool_size * sizeof(SgForAllStatement));
   81186             : #endif
   81187           0 :         SgForAllStatement::pools.push_back( (unsigned char*)(pointer) );
   81188           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgForAllStatement::pool_size * sizeof(SgForAllStatement), V_SgForAllStatement ) );
   81189             : 
   81190           0 :         if ( SgForAllStatement::next_node != NULL ) {
   81191           0 :           if ( blockIndex > 0 ) {
   81192           0 :             SgForAllStatement * blkptr = (SgForAllStatement*)(SgForAllStatement::pools[blockIndex-1]);
   81193           0 :             blkptr[ SgForAllStatement::pool_size - 1 ].set_freepointer(pointer);
   81194             :           }
   81195             :         } else {
   81196           0 :           SgForAllStatement::next_node = pointer;
   81197             :         }
   81198             : 
   81199           0 :         for (unsigned i = 0; i < SgForAllStatement::pool_size-1; ++i)
   81200             :            {
   81201           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   81202             :            }
   81203           0 :         pointer[ SgForAllStatement::pool_size -1 ].set_freepointer(NULL);
   81204             : 
   81205           0 :         blockIndex++;
   81206             :       }
   81207           2 :   }
   81208             : 
   81209             : //############################################################################
   81210             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   81211             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   81212             :  * not compressed. However, that stuff is not yet implemented! 
   81213             :  */
   81214             : unsigned long
   81215           0 : SgForAllStatement::getNumberOfLastValidPointer()
   81216             :    {
   81217           0 :       SgForAllStatement* testPointer = (SgForAllStatement*)(SgForAllStatement::pools.back());
   81218           0 :       unsigned long localIndex = SgForAllStatement::pool_size - 1;
   81219           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   81220             :          {
   81221           0 :            localIndex--;
   81222             :          }
   81223           0 :       return (localIndex + SgForAllStatement::pool_size * (SgForAllStatement::pools.size()-1));
   81224             :    }
   81225             : 
   81226             : //############################################################################
   81227             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   81228             :  * memory pool and initializes the data member in class SgForAllStatementStroageClass
   81229             :  * from its counterpart of SgForAllStatement. The return value is just for checking, 
   81230             :  * that the whole StorageClassArray is initialized!
   81231             :  */
   81232             : unsigned long
   81233           0 : SgForAllStatement::initializeStorageClassArray( SgForAllStatementStorageClass *storageArray )
   81234             :    {
   81235           0 :      unsigned long storageCounter = 0;
   81236           0 :      std::vector < unsigned char* > :: const_iterator block = SgForAllStatement::pools.begin();
   81237           0 :      SgForAllStatement* pointer = NULL;
   81238           0 :      while ( block != SgForAllStatement::pools.end() ) {
   81239           0 :           pointer = (SgForAllStatement*) (*block);
   81240           0 :           for ( unsigned i = 0; i < SgForAllStatement::pool_size; ++i ) {
   81241           0 :                if ( pointer->get_freepointer() != NULL ) {
   81242           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   81243           0 :                  storageArray++;
   81244           0 :                  storageCounter++;
   81245             :                }
   81246           0 :                pointer++;
   81247             :              }
   81248           0 :            block++;
   81249             :         }
   81250           0 :      return storageCounter;
   81251             :    }
   81252             : 
   81253             : /* #line 81254 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   81254             : 
   81255             : 
   81256             : 
   81257             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   81258             : 
   81259             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   81260             : 
   81261             : //############################################################################
   81262             : /* JH (02/02/2006) Constructor of the IR node SgUpcForAllStatement that takes its 
   81263             :  * corresponding StorageClass as parameter
   81264             :  */
   81265           0 : SgUpcForAllStatement :: SgUpcForAllStatement ( const SgUpcForAllStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   81266             :    {
   81267             : 
   81268             : 
   81269             : /* #line 81270 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   81270             : 
   81271           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   81272           0 :      p_for_init_stmt =  (SgForInitStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_for_init_stmt) );
   81273           0 :      p_test =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_test) );
   81274           0 :      p_increment =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_increment) );
   81275           0 :      p_affinity =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_affinity) );
   81276           0 :      p_loop_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_loop_body) );
   81277             : 
   81278             : 
   81279             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   81280             : 
   81281             : 
   81282           0 :    }
   81283             : 
   81284             : //############################################################################
   81285             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   81286             :  * within the working AST. 
   81287             :  */
   81288           0 : SgUpcForAllStatement * SgUpcForAllStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   81289           0 :      SgUpcForAllStatement* returnPointer = NULL;
   81290           0 :      if ( globalIndex != 0 )
   81291             :         {
   81292             : 
   81293             : #if FILE_IO_EXTRA_CHECK
   81294           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcForAllStatement ) ) <= globalIndex ) ;
   81295           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcForAllStatement + 1 ) ) );
   81296             : #endif
   81297           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcForAllStatement )  
   81298           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcForAllStatement );
   81299           0 :           unsigned long positionInPool = localIndex % SgUpcForAllStatement::pool_size;
   81300           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcForAllStatement::pool_size;
   81301             : 
   81302             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   81303             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   81304             : 
   81305           0 :           returnPointer = &( ( (SgUpcForAllStatement*)(SgUpcForAllStatement::pools[memoryBlock]) ) [positionInPool]) ;
   81306             : 
   81307           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   81308             :         }
   81309           0 :      return returnPointer ;
   81310             :    }
   81311             : 
   81312             : //############################################################################
   81313             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   81314             :   for the AST with the index astIndex
   81315             : */
   81316           0 : SgUpcForAllStatement * SgUpcForAllStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   81317           0 :      SgUpcForAllStatement* returnPointer = NULL;
   81318           0 :      if ( globalIndex != 0 )
   81319             :         {
   81320             : 
   81321             : #if FILE_IO_EXTRA_CHECK
   81322           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcForAllStatement ) ) <= globalIndex ) ;
   81323           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcForAllStatement + 1 ) ) );
   81324             : #endif
   81325           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcForAllStatement )
   81326           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcForAllStatement );
   81327           0 :           unsigned long positionInPool = localIndex % SgUpcForAllStatement::pool_size ;
   81328           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcForAllStatement::pool_size ;
   81329             : 
   81330             : #if FILE_IO_EXTRA_CHECK
   81331             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   81332             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   81333             : #endif
   81334             : 
   81335           0 :           returnPointer = &( ( (SgUpcForAllStatement*)(SgUpcForAllStatement::pools[memoryBlock]) ) [positionInPool]) ;
   81336             : 
   81337             : #if FILE_IO_EXTRA_CHECK
   81338           0 :           assert ( returnPointer != NULL ) ;
   81339             : #endif
   81340             :         }
   81341           0 :      return returnPointer ;
   81342             :    }
   81343             : 
   81344             : //############################################################################
   81345             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   81346             :  * pool size! We set for every valid object in the memory pool the freepointer
   81347             :  * to the global index and increase the global index afterwards. For all the 
   81348             :  * invalid objects (means address ranges within the memory pool that were not
   81349             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   81350             :  * distinguish valid from invalid objects! 
   81351             :  */
   81352             : unsigned long
   81353           5 : SgUpcForAllStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   81354             :    {
   81355           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   81356           5 :      SgUpcForAllStatement* pointer = NULL;
   81357           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   81358           5 :      std::vector < unsigned char* > :: const_iterator block;
   81359           5 :      for ( block = SgUpcForAllStatement::pools.begin(); block != SgUpcForAllStatement::pools.end() ; ++block )
   81360             :         {
   81361           0 :           pointer = (SgUpcForAllStatement*)(*block);
   81362           0 :           for (unsigned i = 0; i < SgUpcForAllStatement::pool_size; ++i )
   81363             :              {
   81364             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   81365             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   81366             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   81367             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   81368             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   81369             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   81370             :             // properly; so this will have to be checked next.
   81371             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   81372             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   81373           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   81374             :                   {
   81375           0 :                     pointer[i].set_freepointer((SgUpcForAllStatement*)(globalIndex));
   81376           0 :                     globalIndex++;
   81377             :                   }
   81378             :                else
   81379             :                   {
   81380           0 :                     pointer[i].set_freepointer(NULL);
   81381             :                   }
   81382             :               }
   81383             :         }
   81384           5 :      return globalIndex;
   81385             :    }
   81386             : 
   81387             : //############################################################################
   81388             : // JH (01/14/2006)
   81389             : void
   81390           5 : SgUpcForAllStatement::resetValidFreepointers( )
   81391             :    {
   81392           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   81393           5 :      SgUpcForAllStatement* pointer = NULL;
   81394           5 :      std::vector < unsigned char* > :: const_iterator block;
   81395           5 :      SgUpcForAllStatement* pointerOfLinkedList = NULL;
   81396           5 :      for ( block = SgUpcForAllStatement::pools.begin(); block != SgUpcForAllStatement::pools.end() ; ++block )
   81397             :         {
   81398           0 :           pointer = (SgUpcForAllStatement*)(*block);
   81399           0 :           for (unsigned i = 0; i < SgUpcForAllStatement::pool_size; ++i )
   81400             :              {
   81401             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   81402             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   81403             :             // memory blocks!.
   81404           0 :                if ( pointer[i].get_freepointer() != NULL )
   81405             :                   {
   81406           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   81407             :                   }
   81408             :                else
   81409             :                   {
   81410           0 :                     if ( pointerOfLinkedList == NULL )
   81411             :                        {
   81412           0 :                          SgUpcForAllStatement::next_node = &(pointer[i]);
   81413             :                        }
   81414             :                     else
   81415             :                        {
   81416             :                       // printf ("In SgUpcForAllStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   81417           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   81418             :                        }
   81419             :                     pointerOfLinkedList = &(pointer[i]);
   81420             :                   }
   81421             :               }
   81422             :         }
   81423             : 
   81424           5 :      if ( pointerOfLinkedList != NULL )
   81425             :         {
   81426             :        // printf ("In SgUpcForAllStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   81427           0 :           pointerOfLinkedList->set_freepointer(NULL);
   81428             :        // DQ (6/6/2010): Temporary debugging...
   81429             :        //   ROSE_ASSERT(false);
   81430             :         }
   81431             : 
   81432           5 :      return ;
   81433             :    }
   81434             : 
   81435             : //############################################################################
   81436             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   81437             :  * within the memory pool and resets the freepointers, in order to achieve a 
   81438             :  * linked list, that has no jumps and starts at the beginning! This function 
   81439             :  * does not extend the memory pool, since we do not delete any memory blocks,
   81440             :  * but delete the valid objects.  
   81441             :  */
   81442             : void
   81443           0 : SgUpcForAllStatement::clearMemoryPool( )
   81444             :    {
   81445             :   // printf ("Inside of SgUpcForAllStatement::clearMemoryPool() \n");
   81446             : 
   81447           0 :      SgUpcForAllStatement* pointer = NULL, *tempPointer = NULL;
   81448           0 :      std::vector < unsigned char* > :: const_iterator block;
   81449           0 :      if ( SgUpcForAllStatement::pools.empty() == false )
   81450             :         {
   81451           0 :           block = SgUpcForAllStatement::pools.begin() ;
   81452           0 :           SgUpcForAllStatement::next_node = (SgUpcForAllStatement*) (*block);
   81453             : 
   81454           0 :           while ( block != SgUpcForAllStatement::pools.end() )
   81455             :              {
   81456           0 :                pointer = (SgUpcForAllStatement*) (*block);
   81457           0 :                if ( tempPointer != NULL )
   81458             :                   {
   81459           0 :                     tempPointer->set_freepointer(pointer);
   81460             :                   }
   81461           0 :                for (unsigned i = 0; i < SgUpcForAllStatement::pool_size - 1; ++i)
   81462             :                   {
   81463           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   81464             :                   }
   81465           0 :                 pointer[SgUpcForAllStatement::pool_size-1].set_freepointer(NULL);
   81466           0 :                 tempPointer = &(pointer[SgUpcForAllStatement::pool_size-1]);
   81467           0 :                 ++block;
   81468             :              }
   81469             :         }
   81470           0 :    }
   81471             : 
   81472           5 : void SgUpcForAllStatement::deleteMemoryPool() {
   81473           5 :   for (auto p: SgUpcForAllStatement::pools) {
   81474           0 :     ROSE_FREE(p);
   81475             :   }
   81476           5 :   SgUpcForAllStatement::next_node = nullptr;
   81477           5 :   SgUpcForAllStatement::pools.clear();
   81478           5 : }
   81479             : 
   81480             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   81481             : //                 reading multiple binary files to for a single AST.
   81482             : /////////// new version ////////////////////////////////
   81483             : //############################################################################
   81484             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   81485             : void
   81486           2 : SgUpcForAllStatement::extendMemoryPoolForFileIO( )
   81487             :   {
   81488           2 :     size_t blockIndex = SgUpcForAllStatement::pools.size();
   81489           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcForAllStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcForAllStatement);
   81490             : 
   81491           2 :     while ( (blockIndex * SgUpcForAllStatement::pool_size) < newPoolSize)
   81492             :       {
   81493             : #if ROSE_ALLOC_TRACE
   81494             :         if (blockIndex > 0) {
   81495             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcForAllStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcForAllStatement) = %" PRIuPTR " SgUpcForAllStatement::pool_size = %d \n",
   81496             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcForAllStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcForAllStatement),SgUpcForAllStatement::pool_size);
   81497             :         }
   81498             : #endif
   81499             : 
   81500           0 :         SgUpcForAllStatement * pointer = (SgUpcForAllStatement*) ROSE_MALLOC ( SgUpcForAllStatement::pool_size * sizeof(SgUpcForAllStatement) );
   81501           0 :         assert( pointer != NULL );
   81502             : #if ROSE_ALLOC_MEMSET == 1
   81503             :         memset(pointer, 0x00, SgUpcForAllStatement::pool_size * sizeof(SgUpcForAllStatement));
   81504             : #elif ROSE_ALLOC_MEMSET == 2
   81505             :         memset(pointer, 0xCC, SgUpcForAllStatement::pool_size * sizeof(SgUpcForAllStatement));
   81506             : #endif
   81507           0 :         SgUpcForAllStatement::pools.push_back( (unsigned char*)(pointer) );
   81508           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcForAllStatement::pool_size * sizeof(SgUpcForAllStatement), V_SgUpcForAllStatement ) );
   81509             : 
   81510           0 :         if ( SgUpcForAllStatement::next_node != NULL ) {
   81511           0 :           if ( blockIndex > 0 ) {
   81512           0 :             SgUpcForAllStatement * blkptr = (SgUpcForAllStatement*)(SgUpcForAllStatement::pools[blockIndex-1]);
   81513           0 :             blkptr[ SgUpcForAllStatement::pool_size - 1 ].set_freepointer(pointer);
   81514             :           }
   81515             :         } else {
   81516           0 :           SgUpcForAllStatement::next_node = pointer;
   81517             :         }
   81518             : 
   81519           0 :         for (unsigned i = 0; i < SgUpcForAllStatement::pool_size-1; ++i)
   81520             :            {
   81521           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   81522             :            }
   81523           0 :         pointer[ SgUpcForAllStatement::pool_size -1 ].set_freepointer(NULL);
   81524             : 
   81525           0 :         blockIndex++;
   81526             :       }
   81527           2 :   }
   81528             : 
   81529             : //############################################################################
   81530             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   81531             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   81532             :  * not compressed. However, that stuff is not yet implemented! 
   81533             :  */
   81534             : unsigned long
   81535           0 : SgUpcForAllStatement::getNumberOfLastValidPointer()
   81536             :    {
   81537           0 :       SgUpcForAllStatement* testPointer = (SgUpcForAllStatement*)(SgUpcForAllStatement::pools.back());
   81538           0 :       unsigned long localIndex = SgUpcForAllStatement::pool_size - 1;
   81539           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   81540             :          {
   81541           0 :            localIndex--;
   81542             :          }
   81543           0 :       return (localIndex + SgUpcForAllStatement::pool_size * (SgUpcForAllStatement::pools.size()-1));
   81544             :    }
   81545             : 
   81546             : //############################################################################
   81547             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   81548             :  * memory pool and initializes the data member in class SgUpcForAllStatementStroageClass
   81549             :  * from its counterpart of SgUpcForAllStatement. The return value is just for checking, 
   81550             :  * that the whole StorageClassArray is initialized!
   81551             :  */
   81552             : unsigned long
   81553           0 : SgUpcForAllStatement::initializeStorageClassArray( SgUpcForAllStatementStorageClass *storageArray )
   81554             :    {
   81555           0 :      unsigned long storageCounter = 0;
   81556           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcForAllStatement::pools.begin();
   81557           0 :      SgUpcForAllStatement* pointer = NULL;
   81558           0 :      while ( block != SgUpcForAllStatement::pools.end() ) {
   81559           0 :           pointer = (SgUpcForAllStatement*) (*block);
   81560           0 :           for ( unsigned i = 0; i < SgUpcForAllStatement::pool_size; ++i ) {
   81561           0 :                if ( pointer->get_freepointer() != NULL ) {
   81562           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   81563           0 :                  storageArray++;
   81564           0 :                  storageCounter++;
   81565             :                }
   81566           0 :                pointer++;
   81567             :              }
   81568           0 :            block++;
   81569             :         }
   81570           0 :      return storageCounter;
   81571             :    }
   81572             : 
   81573             : /* #line 81574 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   81574             : 
   81575             : 
   81576             : 
   81577             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   81578             : 
   81579             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   81580             : 
   81581             : //############################################################################
   81582             : /* JH (02/02/2006) Constructor of the IR node SgCAFWithTeamStatement that takes its 
   81583             :  * corresponding StorageClass as parameter
   81584             :  */
   81585           0 : SgCAFWithTeamStatement :: SgCAFWithTeamStatement ( const SgCAFWithTeamStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   81586             :    {
   81587             : 
   81588             : 
   81589             : /* #line 81590 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   81590             : 
   81591           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   81592           0 :      p_teamId =  (SgVarRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_teamId) );
   81593           0 :      p_body =  (SgBasicBlock*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
   81594           0 :      p_endHasTeamId = storageSource.storageOf_endHasTeamId ;
   81595             : 
   81596             : 
   81597             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   81598             : 
   81599             : 
   81600           0 :    }
   81601             : 
   81602             : //############################################################################
   81603             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   81604             :  * within the working AST. 
   81605             :  */
   81606           0 : SgCAFWithTeamStatement * SgCAFWithTeamStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   81607           0 :      SgCAFWithTeamStatement* returnPointer = NULL;
   81608           0 :      if ( globalIndex != 0 )
   81609             :         {
   81610             : 
   81611             : #if FILE_IO_EXTRA_CHECK
   81612           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCAFWithTeamStatement ) ) <= globalIndex ) ;
   81613           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCAFWithTeamStatement + 1 ) ) );
   81614             : #endif
   81615           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCAFWithTeamStatement )  
   81616           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCAFWithTeamStatement );
   81617           0 :           unsigned long positionInPool = localIndex % SgCAFWithTeamStatement::pool_size;
   81618           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCAFWithTeamStatement::pool_size;
   81619             : 
   81620             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   81621             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   81622             : 
   81623           0 :           returnPointer = &( ( (SgCAFWithTeamStatement*)(SgCAFWithTeamStatement::pools[memoryBlock]) ) [positionInPool]) ;
   81624             : 
   81625           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   81626             :         }
   81627           0 :      return returnPointer ;
   81628             :    }
   81629             : 
   81630             : //############################################################################
   81631             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   81632             :   for the AST with the index astIndex
   81633             : */
   81634           0 : SgCAFWithTeamStatement * SgCAFWithTeamStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   81635           0 :      SgCAFWithTeamStatement* returnPointer = NULL;
   81636           0 :      if ( globalIndex != 0 )
   81637             :         {
   81638             : 
   81639             : #if FILE_IO_EXTRA_CHECK
   81640           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCAFWithTeamStatement ) ) <= globalIndex ) ;
   81641           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCAFWithTeamStatement + 1 ) ) );
   81642             : #endif
   81643           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCAFWithTeamStatement )
   81644           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCAFWithTeamStatement );
   81645           0 :           unsigned long positionInPool = localIndex % SgCAFWithTeamStatement::pool_size ;
   81646           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCAFWithTeamStatement::pool_size ;
   81647             : 
   81648             : #if FILE_IO_EXTRA_CHECK
   81649             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   81650             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   81651             : #endif
   81652             : 
   81653           0 :           returnPointer = &( ( (SgCAFWithTeamStatement*)(SgCAFWithTeamStatement::pools[memoryBlock]) ) [positionInPool]) ;
   81654             : 
   81655             : #if FILE_IO_EXTRA_CHECK
   81656           0 :           assert ( returnPointer != NULL ) ;
   81657             : #endif
   81658             :         }
   81659           0 :      return returnPointer ;
   81660             :    }
   81661             : 
   81662             : //############################################################################
   81663             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   81664             :  * pool size! We set for every valid object in the memory pool the freepointer
   81665             :  * to the global index and increase the global index afterwards. For all the 
   81666             :  * invalid objects (means address ranges within the memory pool that were not
   81667             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   81668             :  * distinguish valid from invalid objects! 
   81669             :  */
   81670             : unsigned long
   81671           5 : SgCAFWithTeamStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   81672             :    {
   81673           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   81674           5 :      SgCAFWithTeamStatement* pointer = NULL;
   81675           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   81676           5 :      std::vector < unsigned char* > :: const_iterator block;
   81677           5 :      for ( block = SgCAFWithTeamStatement::pools.begin(); block != SgCAFWithTeamStatement::pools.end() ; ++block )
   81678             :         {
   81679           0 :           pointer = (SgCAFWithTeamStatement*)(*block);
   81680           0 :           for (unsigned i = 0; i < SgCAFWithTeamStatement::pool_size; ++i )
   81681             :              {
   81682             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   81683             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   81684             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   81685             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   81686             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   81687             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   81688             :             // properly; so this will have to be checked next.
   81689             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   81690             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   81691           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   81692             :                   {
   81693           0 :                     pointer[i].set_freepointer((SgCAFWithTeamStatement*)(globalIndex));
   81694           0 :                     globalIndex++;
   81695             :                   }
   81696             :                else
   81697             :                   {
   81698           0 :                     pointer[i].set_freepointer(NULL);
   81699             :                   }
   81700             :               }
   81701             :         }
   81702           5 :      return globalIndex;
   81703             :    }
   81704             : 
   81705             : //############################################################################
   81706             : // JH (01/14/2006)
   81707             : void
   81708           5 : SgCAFWithTeamStatement::resetValidFreepointers( )
   81709             :    {
   81710           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   81711           5 :      SgCAFWithTeamStatement* pointer = NULL;
   81712           5 :      std::vector < unsigned char* > :: const_iterator block;
   81713           5 :      SgCAFWithTeamStatement* pointerOfLinkedList = NULL;
   81714           5 :      for ( block = SgCAFWithTeamStatement::pools.begin(); block != SgCAFWithTeamStatement::pools.end() ; ++block )
   81715             :         {
   81716           0 :           pointer = (SgCAFWithTeamStatement*)(*block);
   81717           0 :           for (unsigned i = 0; i < SgCAFWithTeamStatement::pool_size; ++i )
   81718             :              {
   81719             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   81720             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   81721             :             // memory blocks!.
   81722           0 :                if ( pointer[i].get_freepointer() != NULL )
   81723             :                   {
   81724           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   81725             :                   }
   81726             :                else
   81727             :                   {
   81728           0 :                     if ( pointerOfLinkedList == NULL )
   81729             :                        {
   81730           0 :                          SgCAFWithTeamStatement::next_node = &(pointer[i]);
   81731             :                        }
   81732             :                     else
   81733             :                        {
   81734             :                       // printf ("In SgCAFWithTeamStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   81735           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   81736             :                        }
   81737             :                     pointerOfLinkedList = &(pointer[i]);
   81738             :                   }
   81739             :               }
   81740             :         }
   81741             : 
   81742           5 :      if ( pointerOfLinkedList != NULL )
   81743             :         {
   81744             :        // printf ("In SgCAFWithTeamStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   81745           0 :           pointerOfLinkedList->set_freepointer(NULL);
   81746             :        // DQ (6/6/2010): Temporary debugging...
   81747             :        //   ROSE_ASSERT(false);
   81748             :         }
   81749             : 
   81750           5 :      return ;
   81751             :    }
   81752             : 
   81753             : //############################################################################
   81754             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   81755             :  * within the memory pool and resets the freepointers, in order to achieve a 
   81756             :  * linked list, that has no jumps and starts at the beginning! This function 
   81757             :  * does not extend the memory pool, since we do not delete any memory blocks,
   81758             :  * but delete the valid objects.  
   81759             :  */
   81760             : void
   81761           0 : SgCAFWithTeamStatement::clearMemoryPool( )
   81762             :    {
   81763             :   // printf ("Inside of SgCAFWithTeamStatement::clearMemoryPool() \n");
   81764             : 
   81765           0 :      SgCAFWithTeamStatement* pointer = NULL, *tempPointer = NULL;
   81766           0 :      std::vector < unsigned char* > :: const_iterator block;
   81767           0 :      if ( SgCAFWithTeamStatement::pools.empty() == false )
   81768             :         {
   81769           0 :           block = SgCAFWithTeamStatement::pools.begin() ;
   81770           0 :           SgCAFWithTeamStatement::next_node = (SgCAFWithTeamStatement*) (*block);
   81771             : 
   81772           0 :           while ( block != SgCAFWithTeamStatement::pools.end() )
   81773             :              {
   81774           0 :                pointer = (SgCAFWithTeamStatement*) (*block);
   81775           0 :                if ( tempPointer != NULL )
   81776             :                   {
   81777           0 :                     tempPointer->set_freepointer(pointer);
   81778             :                   }
   81779           0 :                for (unsigned i = 0; i < SgCAFWithTeamStatement::pool_size - 1; ++i)
   81780             :                   {
   81781           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   81782             :                   }
   81783           0 :                 pointer[SgCAFWithTeamStatement::pool_size-1].set_freepointer(NULL);
   81784           0 :                 tempPointer = &(pointer[SgCAFWithTeamStatement::pool_size-1]);
   81785           0 :                 ++block;
   81786             :              }
   81787             :         }
   81788           0 :    }
   81789             : 
   81790           5 : void SgCAFWithTeamStatement::deleteMemoryPool() {
   81791           5 :   for (auto p: SgCAFWithTeamStatement::pools) {
   81792           0 :     ROSE_FREE(p);
   81793             :   }
   81794           5 :   SgCAFWithTeamStatement::next_node = nullptr;
   81795           5 :   SgCAFWithTeamStatement::pools.clear();
   81796           5 : }
   81797             : 
   81798             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   81799             : //                 reading multiple binary files to for a single AST.
   81800             : /////////// new version ////////////////////////////////
   81801             : //############################################################################
   81802             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   81803             : void
   81804           2 : SgCAFWithTeamStatement::extendMemoryPoolForFileIO( )
   81805             :   {
   81806           2 :     size_t blockIndex = SgCAFWithTeamStatement::pools.size();
   81807           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCAFWithTeamStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCAFWithTeamStatement);
   81808             : 
   81809           2 :     while ( (blockIndex * SgCAFWithTeamStatement::pool_size) < newPoolSize)
   81810             :       {
   81811             : #if ROSE_ALLOC_TRACE
   81812             :         if (blockIndex > 0) {
   81813             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCAFWithTeamStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCAFWithTeamStatement) = %" PRIuPTR " SgCAFWithTeamStatement::pool_size = %d \n",
   81814             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCAFWithTeamStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCAFWithTeamStatement),SgCAFWithTeamStatement::pool_size);
   81815             :         }
   81816             : #endif
   81817             : 
   81818           0 :         SgCAFWithTeamStatement * pointer = (SgCAFWithTeamStatement*) ROSE_MALLOC ( SgCAFWithTeamStatement::pool_size * sizeof(SgCAFWithTeamStatement) );
   81819           0 :         assert( pointer != NULL );
   81820             : #if ROSE_ALLOC_MEMSET == 1
   81821             :         memset(pointer, 0x00, SgCAFWithTeamStatement::pool_size * sizeof(SgCAFWithTeamStatement));
   81822             : #elif ROSE_ALLOC_MEMSET == 2
   81823             :         memset(pointer, 0xCC, SgCAFWithTeamStatement::pool_size * sizeof(SgCAFWithTeamStatement));
   81824             : #endif
   81825           0 :         SgCAFWithTeamStatement::pools.push_back( (unsigned char*)(pointer) );
   81826           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCAFWithTeamStatement::pool_size * sizeof(SgCAFWithTeamStatement), V_SgCAFWithTeamStatement ) );
   81827             : 
   81828           0 :         if ( SgCAFWithTeamStatement::next_node != NULL ) {
   81829           0 :           if ( blockIndex > 0 ) {
   81830           0 :             SgCAFWithTeamStatement * blkptr = (SgCAFWithTeamStatement*)(SgCAFWithTeamStatement::pools[blockIndex-1]);
   81831           0 :             blkptr[ SgCAFWithTeamStatement::pool_size - 1 ].set_freepointer(pointer);
   81832             :           }
   81833             :         } else {
   81834           0 :           SgCAFWithTeamStatement::next_node = pointer;
   81835             :         }
   81836             : 
   81837           0 :         for (unsigned i = 0; i < SgCAFWithTeamStatement::pool_size-1; ++i)
   81838             :            {
   81839           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   81840             :            }
   81841           0 :         pointer[ SgCAFWithTeamStatement::pool_size -1 ].set_freepointer(NULL);
   81842             : 
   81843           0 :         blockIndex++;
   81844             :       }
   81845           2 :   }
   81846             : 
   81847             : //############################################################################
   81848             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   81849             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   81850             :  * not compressed. However, that stuff is not yet implemented! 
   81851             :  */
   81852             : unsigned long
   81853           0 : SgCAFWithTeamStatement::getNumberOfLastValidPointer()
   81854             :    {
   81855           0 :       SgCAFWithTeamStatement* testPointer = (SgCAFWithTeamStatement*)(SgCAFWithTeamStatement::pools.back());
   81856           0 :       unsigned long localIndex = SgCAFWithTeamStatement::pool_size - 1;
   81857           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   81858             :          {
   81859           0 :            localIndex--;
   81860             :          }
   81861           0 :       return (localIndex + SgCAFWithTeamStatement::pool_size * (SgCAFWithTeamStatement::pools.size()-1));
   81862             :    }
   81863             : 
   81864             : //############################################################################
   81865             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   81866             :  * memory pool and initializes the data member in class SgCAFWithTeamStatementStroageClass
   81867             :  * from its counterpart of SgCAFWithTeamStatement. The return value is just for checking, 
   81868             :  * that the whole StorageClassArray is initialized!
   81869             :  */
   81870             : unsigned long
   81871           0 : SgCAFWithTeamStatement::initializeStorageClassArray( SgCAFWithTeamStatementStorageClass *storageArray )
   81872             :    {
   81873           0 :      unsigned long storageCounter = 0;
   81874           0 :      std::vector < unsigned char* > :: const_iterator block = SgCAFWithTeamStatement::pools.begin();
   81875           0 :      SgCAFWithTeamStatement* pointer = NULL;
   81876           0 :      while ( block != SgCAFWithTeamStatement::pools.end() ) {
   81877           0 :           pointer = (SgCAFWithTeamStatement*) (*block);
   81878           0 :           for ( unsigned i = 0; i < SgCAFWithTeamStatement::pool_size; ++i ) {
   81879           0 :                if ( pointer->get_freepointer() != NULL ) {
   81880           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   81881           0 :                  storageArray++;
   81882           0 :                  storageCounter++;
   81883             :                }
   81884           0 :                pointer++;
   81885             :              }
   81886           0 :            block++;
   81887             :         }
   81888           0 :      return storageCounter;
   81889             :    }
   81890             : 
   81891             : /* #line 81892 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   81892             : 
   81893             : 
   81894             : 
   81895             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   81896             : 
   81897             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   81898             : 
   81899             : //############################################################################
   81900             : /* JH (02/02/2006) Constructor of the IR node SgFunctionParameterScope that takes its 
   81901             :  * corresponding StorageClass as parameter
   81902             :  */
   81903           0 : SgFunctionParameterScope :: SgFunctionParameterScope ( const SgFunctionParameterScopeStorageClass& storageSource )   : SgScopeStatement (storageSource)
   81904             :    {
   81905             : 
   81906             : 
   81907             : /* #line 81908 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   81908             : 
   81909           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   81910           0 :      p_declarations = storageSource.storageOf_declarations.rebuildDataStoredInEasyStorageClass() ;
   81911           0 :      SgDeclarationStatementPtrList::iterator i_declarations = p_declarations.begin() ; 
   81912           0 :      for ( ; i_declarations != p_declarations.end(); ++i_declarations ) 
   81913             :         {
   81914           0 :           (*i_declarations) = (SgDeclarationStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_declarations) ) );
   81915             :         }
   81916             : 
   81917             : 
   81918             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   81919             : 
   81920             : 
   81921           0 :    }
   81922             : 
   81923             : //############################################################################
   81924             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   81925             :  * within the working AST. 
   81926             :  */
   81927           0 : SgFunctionParameterScope * SgFunctionParameterScope::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   81928           0 :      SgFunctionParameterScope* returnPointer = NULL;
   81929           0 :      if ( globalIndex != 0 )
   81930             :         {
   81931             : 
   81932             : #if FILE_IO_EXTRA_CHECK
   81933           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionParameterScope ) ) <= globalIndex ) ;
   81934           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionParameterScope + 1 ) ) );
   81935             : #endif
   81936           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionParameterScope )  
   81937           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionParameterScope );
   81938           0 :           unsigned long positionInPool = localIndex % SgFunctionParameterScope::pool_size;
   81939           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionParameterScope::pool_size;
   81940             : 
   81941             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   81942             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   81943             : 
   81944           0 :           returnPointer = &( ( (SgFunctionParameterScope*)(SgFunctionParameterScope::pools[memoryBlock]) ) [positionInPool]) ;
   81945             : 
   81946           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   81947             :         }
   81948           0 :      return returnPointer ;
   81949             :    }
   81950             : 
   81951             : //############################################################################
   81952             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   81953             :   for the AST with the index astIndex
   81954             : */
   81955           0 : SgFunctionParameterScope * SgFunctionParameterScope::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   81956           0 :      SgFunctionParameterScope* returnPointer = NULL;
   81957           0 :      if ( globalIndex != 0 )
   81958             :         {
   81959             : 
   81960             : #if FILE_IO_EXTRA_CHECK
   81961           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionParameterScope ) ) <= globalIndex ) ;
   81962           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionParameterScope + 1 ) ) );
   81963             : #endif
   81964           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionParameterScope )
   81965           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionParameterScope );
   81966           0 :           unsigned long positionInPool = localIndex % SgFunctionParameterScope::pool_size ;
   81967           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionParameterScope::pool_size ;
   81968             : 
   81969             : #if FILE_IO_EXTRA_CHECK
   81970             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   81971             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   81972             : #endif
   81973             : 
   81974           0 :           returnPointer = &( ( (SgFunctionParameterScope*)(SgFunctionParameterScope::pools[memoryBlock]) ) [positionInPool]) ;
   81975             : 
   81976             : #if FILE_IO_EXTRA_CHECK
   81977           0 :           assert ( returnPointer != NULL ) ;
   81978             : #endif
   81979             :         }
   81980           0 :      return returnPointer ;
   81981             :    }
   81982             : 
   81983             : //############################################################################
   81984             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   81985             :  * pool size! We set for every valid object in the memory pool the freepointer
   81986             :  * to the global index and increase the global index afterwards. For all the 
   81987             :  * invalid objects (means address ranges within the memory pool that were not
   81988             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   81989             :  * distinguish valid from invalid objects! 
   81990             :  */
   81991             : unsigned long
   81992           5 : SgFunctionParameterScope::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   81993             :    {
   81994           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   81995           5 :      SgFunctionParameterScope* pointer = NULL;
   81996           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   81997           5 :      std::vector < unsigned char* > :: const_iterator block;
   81998           5 :      for ( block = SgFunctionParameterScope::pools.begin(); block != SgFunctionParameterScope::pools.end() ; ++block )
   81999             :         {
   82000           0 :           pointer = (SgFunctionParameterScope*)(*block);
   82001           0 :           for (unsigned i = 0; i < SgFunctionParameterScope::pool_size; ++i )
   82002             :              {
   82003             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   82004             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   82005             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   82006             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   82007             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   82008             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   82009             :             // properly; so this will have to be checked next.
   82010             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   82011             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   82012           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   82013             :                   {
   82014           0 :                     pointer[i].set_freepointer((SgFunctionParameterScope*)(globalIndex));
   82015           0 :                     globalIndex++;
   82016             :                   }
   82017             :                else
   82018             :                   {
   82019           0 :                     pointer[i].set_freepointer(NULL);
   82020             :                   }
   82021             :               }
   82022             :         }
   82023           5 :      return globalIndex;
   82024             :    }
   82025             : 
   82026             : //############################################################################
   82027             : // JH (01/14/2006)
   82028             : void
   82029           5 : SgFunctionParameterScope::resetValidFreepointers( )
   82030             :    {
   82031           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   82032           5 :      SgFunctionParameterScope* pointer = NULL;
   82033           5 :      std::vector < unsigned char* > :: const_iterator block;
   82034           5 :      SgFunctionParameterScope* pointerOfLinkedList = NULL;
   82035           5 :      for ( block = SgFunctionParameterScope::pools.begin(); block != SgFunctionParameterScope::pools.end() ; ++block )
   82036             :         {
   82037           0 :           pointer = (SgFunctionParameterScope*)(*block);
   82038           0 :           for (unsigned i = 0; i < SgFunctionParameterScope::pool_size; ++i )
   82039             :              {
   82040             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   82041             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   82042             :             // memory blocks!.
   82043           0 :                if ( pointer[i].get_freepointer() != NULL )
   82044             :                   {
   82045           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   82046             :                   }
   82047             :                else
   82048             :                   {
   82049           0 :                     if ( pointerOfLinkedList == NULL )
   82050             :                        {
   82051           0 :                          SgFunctionParameterScope::next_node = &(pointer[i]);
   82052             :                        }
   82053             :                     else
   82054             :                        {
   82055             :                       // printf ("In SgFunctionParameterScope::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   82056           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   82057             :                        }
   82058             :                     pointerOfLinkedList = &(pointer[i]);
   82059             :                   }
   82060             :               }
   82061             :         }
   82062             : 
   82063           5 :      if ( pointerOfLinkedList != NULL )
   82064             :         {
   82065             :        // printf ("In SgFunctionParameterScope::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   82066           0 :           pointerOfLinkedList->set_freepointer(NULL);
   82067             :        // DQ (6/6/2010): Temporary debugging...
   82068             :        //   ROSE_ASSERT(false);
   82069             :         }
   82070             : 
   82071           5 :      return ;
   82072             :    }
   82073             : 
   82074             : //############################################################################
   82075             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   82076             :  * within the memory pool and resets the freepointers, in order to achieve a 
   82077             :  * linked list, that has no jumps and starts at the beginning! This function 
   82078             :  * does not extend the memory pool, since we do not delete any memory blocks,
   82079             :  * but delete the valid objects.  
   82080             :  */
   82081             : void
   82082           0 : SgFunctionParameterScope::clearMemoryPool( )
   82083             :    {
   82084             :   // printf ("Inside of SgFunctionParameterScope::clearMemoryPool() \n");
   82085             : 
   82086           0 :      SgFunctionParameterScope* pointer = NULL, *tempPointer = NULL;
   82087           0 :      std::vector < unsigned char* > :: const_iterator block;
   82088           0 :      if ( SgFunctionParameterScope::pools.empty() == false )
   82089             :         {
   82090           0 :           block = SgFunctionParameterScope::pools.begin() ;
   82091           0 :           SgFunctionParameterScope::next_node = (SgFunctionParameterScope*) (*block);
   82092             : 
   82093           0 :           while ( block != SgFunctionParameterScope::pools.end() )
   82094             :              {
   82095           0 :                pointer = (SgFunctionParameterScope*) (*block);
   82096           0 :                if ( tempPointer != NULL )
   82097             :                   {
   82098           0 :                     tempPointer->set_freepointer(pointer);
   82099             :                   }
   82100           0 :                for (unsigned i = 0; i < SgFunctionParameterScope::pool_size - 1; ++i)
   82101             :                   {
   82102           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   82103             :                   }
   82104           0 :                 pointer[SgFunctionParameterScope::pool_size-1].set_freepointer(NULL);
   82105           0 :                 tempPointer = &(pointer[SgFunctionParameterScope::pool_size-1]);
   82106           0 :                 ++block;
   82107             :              }
   82108             :         }
   82109           0 :    }
   82110             : 
   82111           5 : void SgFunctionParameterScope::deleteMemoryPool() {
   82112           5 :   for (auto p: SgFunctionParameterScope::pools) {
   82113           0 :     ROSE_FREE(p);
   82114             :   }
   82115           5 :   SgFunctionParameterScope::next_node = nullptr;
   82116           5 :   SgFunctionParameterScope::pools.clear();
   82117           5 : }
   82118             : 
   82119             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   82120             : //                 reading multiple binary files to for a single AST.
   82121             : /////////// new version ////////////////////////////////
   82122             : //############################################################################
   82123             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   82124             : void
   82125           2 : SgFunctionParameterScope::extendMemoryPoolForFileIO( )
   82126             :   {
   82127           2 :     size_t blockIndex = SgFunctionParameterScope::pools.size();
   82128           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterScope) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterScope);
   82129             : 
   82130           2 :     while ( (blockIndex * SgFunctionParameterScope::pool_size) < newPoolSize)
   82131             :       {
   82132             : #if ROSE_ALLOC_TRACE
   82133             :         if (blockIndex > 0) {
   82134             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterScope) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterScope) = %" PRIuPTR " SgFunctionParameterScope::pool_size = %d \n",
   82135             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterScope),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterScope),SgFunctionParameterScope::pool_size);
   82136             :         }
   82137             : #endif
   82138             : 
   82139           0 :         SgFunctionParameterScope * pointer = (SgFunctionParameterScope*) ROSE_MALLOC ( SgFunctionParameterScope::pool_size * sizeof(SgFunctionParameterScope) );
   82140           0 :         assert( pointer != NULL );
   82141             : #if ROSE_ALLOC_MEMSET == 1
   82142             :         memset(pointer, 0x00, SgFunctionParameterScope::pool_size * sizeof(SgFunctionParameterScope));
   82143             : #elif ROSE_ALLOC_MEMSET == 2
   82144             :         memset(pointer, 0xCC, SgFunctionParameterScope::pool_size * sizeof(SgFunctionParameterScope));
   82145             : #endif
   82146           0 :         SgFunctionParameterScope::pools.push_back( (unsigned char*)(pointer) );
   82147           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionParameterScope::pool_size * sizeof(SgFunctionParameterScope), V_SgFunctionParameterScope ) );
   82148             : 
   82149           0 :         if ( SgFunctionParameterScope::next_node != NULL ) {
   82150           0 :           if ( blockIndex > 0 ) {
   82151           0 :             SgFunctionParameterScope * blkptr = (SgFunctionParameterScope*)(SgFunctionParameterScope::pools[blockIndex-1]);
   82152           0 :             blkptr[ SgFunctionParameterScope::pool_size - 1 ].set_freepointer(pointer);
   82153             :           }
   82154             :         } else {
   82155           0 :           SgFunctionParameterScope::next_node = pointer;
   82156             :         }
   82157             : 
   82158           0 :         for (unsigned i = 0; i < SgFunctionParameterScope::pool_size-1; ++i)
   82159             :            {
   82160           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   82161             :            }
   82162           0 :         pointer[ SgFunctionParameterScope::pool_size -1 ].set_freepointer(NULL);
   82163             : 
   82164           0 :         blockIndex++;
   82165             :       }
   82166           2 :   }
   82167             : 
   82168             : //############################################################################
   82169             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   82170             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   82171             :  * not compressed. However, that stuff is not yet implemented! 
   82172             :  */
   82173             : unsigned long
   82174           0 : SgFunctionParameterScope::getNumberOfLastValidPointer()
   82175             :    {
   82176           0 :       SgFunctionParameterScope* testPointer = (SgFunctionParameterScope*)(SgFunctionParameterScope::pools.back());
   82177           0 :       unsigned long localIndex = SgFunctionParameterScope::pool_size - 1;
   82178           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   82179             :          {
   82180           0 :            localIndex--;
   82181             :          }
   82182           0 :       return (localIndex + SgFunctionParameterScope::pool_size * (SgFunctionParameterScope::pools.size()-1));
   82183             :    }
   82184             : 
   82185             : //############################################################################
   82186             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   82187             :  * memory pool and initializes the data member in class SgFunctionParameterScopeStroageClass
   82188             :  * from its counterpart of SgFunctionParameterScope. The return value is just for checking, 
   82189             :  * that the whole StorageClassArray is initialized!
   82190             :  */
   82191             : unsigned long
   82192           0 : SgFunctionParameterScope::initializeStorageClassArray( SgFunctionParameterScopeStorageClass *storageArray )
   82193             :    {
   82194           0 :      unsigned long storageCounter = 0;
   82195           0 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionParameterScope::pools.begin();
   82196           0 :      SgFunctionParameterScope* pointer = NULL;
   82197           0 :      while ( block != SgFunctionParameterScope::pools.end() ) {
   82198           0 :           pointer = (SgFunctionParameterScope*) (*block);
   82199           0 :           for ( unsigned i = 0; i < SgFunctionParameterScope::pool_size; ++i ) {
   82200           0 :                if ( pointer->get_freepointer() != NULL ) {
   82201           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   82202           0 :                  storageArray++;
   82203           0 :                  storageCounter++;
   82204             :                }
   82205           0 :                pointer++;
   82206             :              }
   82207           0 :            block++;
   82208             :         }
   82209           0 :      return storageCounter;
   82210             :    }
   82211             : 
   82212             : /* #line 82213 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   82213             : 
   82214             : 
   82215             : 
   82216             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   82217             : 
   82218             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   82219             : 
   82220             : //############################################################################
   82221             : /* JH (02/02/2006) Constructor of the IR node SgDeclarationScope that takes its 
   82222             :  * corresponding StorageClass as parameter
   82223             :  */
   82224        6496 : SgDeclarationScope :: SgDeclarationScope ( const SgDeclarationScopeStorageClass& storageSource )   : SgScopeStatement (storageSource)
   82225             :    {
   82226             : 
   82227             : 
   82228             : /* #line 82229 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   82229             : 
   82230        6496 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   82231             : 
   82232             : 
   82233             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   82234             : 
   82235             : 
   82236        6496 :    }
   82237             : 
   82238             : //############################################################################
   82239             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   82240             :  * within the working AST. 
   82241             :  */
   82242       46319 : SgDeclarationScope * SgDeclarationScope::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   82243       46319 :      SgDeclarationScope* returnPointer = NULL;
   82244       46319 :      if ( globalIndex != 0 )
   82245             :         {
   82246             : 
   82247             : #if FILE_IO_EXTRA_CHECK
   82248       46319 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDeclarationScope ) ) <= globalIndex ) ;
   82249       46319 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeclarationScope + 1 ) ) );
   82250             : #endif
   82251       46319 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeclarationScope )  
   82252       46319 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDeclarationScope );
   82253       46319 :           unsigned long positionInPool = localIndex % SgDeclarationScope::pool_size;
   82254       46319 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeclarationScope::pool_size;
   82255             : 
   82256             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   82257             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   82258             : 
   82259       46319 :           returnPointer = &( ( (SgDeclarationScope*)(SgDeclarationScope::pools[memoryBlock]) ) [positionInPool]) ;
   82260             : 
   82261       46319 :           ROSE_ASSERT( returnPointer != NULL ) ;
   82262             :         }
   82263       46319 :      return returnPointer ;
   82264             :    }
   82265             : 
   82266             : //############################################################################
   82267             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   82268             :   for the AST with the index astIndex
   82269             : */
   82270           0 : SgDeclarationScope * SgDeclarationScope::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   82271           0 :      SgDeclarationScope* returnPointer = NULL;
   82272           0 :      if ( globalIndex != 0 )
   82273             :         {
   82274             : 
   82275             : #if FILE_IO_EXTRA_CHECK
   82276           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDeclarationScope ) ) <= globalIndex ) ;
   82277           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeclarationScope + 1 ) ) );
   82278             : #endif
   82279           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeclarationScope )
   82280           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDeclarationScope );
   82281           0 :           unsigned long positionInPool = localIndex % SgDeclarationScope::pool_size ;
   82282           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeclarationScope::pool_size ;
   82283             : 
   82284             : #if FILE_IO_EXTRA_CHECK
   82285             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   82286             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   82287             : #endif
   82288             : 
   82289           0 :           returnPointer = &( ( (SgDeclarationScope*)(SgDeclarationScope::pools[memoryBlock]) ) [positionInPool]) ;
   82290             : 
   82291             : #if FILE_IO_EXTRA_CHECK
   82292           0 :           assert ( returnPointer != NULL ) ;
   82293             : #endif
   82294             :         }
   82295           0 :      return returnPointer ;
   82296             :    }
   82297             : 
   82298             : //############################################################################
   82299             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   82300             :  * pool size! We set for every valid object in the memory pool the freepointer
   82301             :  * to the global index and increase the global index afterwards. For all the 
   82302             :  * invalid objects (means address ranges within the memory pool that were not
   82303             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   82304             :  * distinguish valid from invalid objects! 
   82305             :  */
   82306             : unsigned long
   82307           5 : SgDeclarationScope::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   82308             :    {
   82309           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   82310           5 :      SgDeclarationScope* pointer = NULL;
   82311           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   82312           5 :      std::vector < unsigned char* > :: const_iterator block;
   82313          10 :      for ( block = SgDeclarationScope::pools.begin(); block != SgDeclarationScope::pools.end() ; ++block )
   82314             :         {
   82315           5 :           pointer = (SgDeclarationScope*)(*block);
   82316       10005 :           for (unsigned i = 0; i < SgDeclarationScope::pool_size; ++i )
   82317             :              {
   82318             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   82319             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   82320             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   82321             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   82322             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   82323             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   82324             :             // properly; so this will have to be checked next.
   82325             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   82326             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   82327       10000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   82328             :                   {
   82329        6496 :                     pointer[i].set_freepointer((SgDeclarationScope*)(globalIndex));
   82330        6496 :                     globalIndex++;
   82331             :                   }
   82332             :                else
   82333             :                   {
   82334        3504 :                     pointer[i].set_freepointer(NULL);
   82335             :                   }
   82336             :               }
   82337             :         }
   82338           5 :      return globalIndex;
   82339             :    }
   82340             : 
   82341             : //############################################################################
   82342             : // JH (01/14/2006)
   82343             : void
   82344           5 : SgDeclarationScope::resetValidFreepointers( )
   82345             :    {
   82346           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   82347           5 :      SgDeclarationScope* pointer = NULL;
   82348           5 :      std::vector < unsigned char* > :: const_iterator block;
   82349           5 :      SgDeclarationScope* pointerOfLinkedList = NULL;
   82350          10 :      for ( block = SgDeclarationScope::pools.begin(); block != SgDeclarationScope::pools.end() ; ++block )
   82351             :         {
   82352           5 :           pointer = (SgDeclarationScope*)(*block);
   82353       10005 :           for (unsigned i = 0; i < SgDeclarationScope::pool_size; ++i )
   82354             :              {
   82355             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   82356             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   82357             :             // memory blocks!.
   82358       10000 :                if ( pointer[i].get_freepointer() != NULL )
   82359             :                   {
   82360        6496 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   82361             :                   }
   82362             :                else
   82363             :                   {
   82364        3504 :                     if ( pointerOfLinkedList == NULL )
   82365             :                        {
   82366           2 :                          SgDeclarationScope::next_node = &(pointer[i]);
   82367             :                        }
   82368             :                     else
   82369             :                        {
   82370             :                       // printf ("In SgDeclarationScope::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   82371        3502 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   82372             :                        }
   82373             :                     pointerOfLinkedList = &(pointer[i]);
   82374             :                   }
   82375             :               }
   82376             :         }
   82377             : 
   82378           5 :      if ( pointerOfLinkedList != NULL )
   82379             :         {
   82380             :        // printf ("In SgDeclarationScope::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   82381           2 :           pointerOfLinkedList->set_freepointer(NULL);
   82382             :        // DQ (6/6/2010): Temporary debugging...
   82383             :        //   ROSE_ASSERT(false);
   82384             :         }
   82385             : 
   82386           5 :      return ;
   82387             :    }
   82388             : 
   82389             : //############################################################################
   82390             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   82391             :  * within the memory pool and resets the freepointers, in order to achieve a 
   82392             :  * linked list, that has no jumps and starts at the beginning! This function 
   82393             :  * does not extend the memory pool, since we do not delete any memory blocks,
   82394             :  * but delete the valid objects.  
   82395             :  */
   82396             : void
   82397           0 : SgDeclarationScope::clearMemoryPool( )
   82398             :    {
   82399             :   // printf ("Inside of SgDeclarationScope::clearMemoryPool() \n");
   82400             : 
   82401           0 :      SgDeclarationScope* pointer = NULL, *tempPointer = NULL;
   82402           0 :      std::vector < unsigned char* > :: const_iterator block;
   82403           0 :      if ( SgDeclarationScope::pools.empty() == false )
   82404             :         {
   82405           0 :           block = SgDeclarationScope::pools.begin() ;
   82406           0 :           SgDeclarationScope::next_node = (SgDeclarationScope*) (*block);
   82407             : 
   82408           0 :           while ( block != SgDeclarationScope::pools.end() )
   82409             :              {
   82410           0 :                pointer = (SgDeclarationScope*) (*block);
   82411           0 :                if ( tempPointer != NULL )
   82412             :                   {
   82413           0 :                     tempPointer->set_freepointer(pointer);
   82414             :                   }
   82415           0 :                for (unsigned i = 0; i < SgDeclarationScope::pool_size - 1; ++i)
   82416             :                   {
   82417           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   82418             :                   }
   82419           0 :                 pointer[SgDeclarationScope::pool_size-1].set_freepointer(NULL);
   82420           0 :                 tempPointer = &(pointer[SgDeclarationScope::pool_size-1]);
   82421           0 :                 ++block;
   82422             :              }
   82423             :         }
   82424           0 :    }
   82425             : 
   82426           5 : void SgDeclarationScope::deleteMemoryPool() {
   82427          14 :   for (auto p: SgDeclarationScope::pools) {
   82428           9 :     ROSE_FREE(p);
   82429             :   }
   82430           5 :   SgDeclarationScope::next_node = nullptr;
   82431           5 :   SgDeclarationScope::pools.clear();
   82432           5 : }
   82433             : 
   82434             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   82435             : //                 reading multiple binary files to for a single AST.
   82436             : /////////// new version ////////////////////////////////
   82437             : //############################################################################
   82438             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   82439             : void
   82440           2 : SgDeclarationScope::extendMemoryPoolForFileIO( )
   82441             :   {
   82442           2 :     size_t blockIndex = SgDeclarationScope::pools.size();
   82443           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationScope) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationScope);
   82444             : 
   82445           6 :     while ( (blockIndex * SgDeclarationScope::pool_size) < newPoolSize)
   82446             :       {
   82447             : #if ROSE_ALLOC_TRACE
   82448             :         if (blockIndex > 0) {
   82449             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationScope) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationScope) = %" PRIuPTR " SgDeclarationScope::pool_size = %d \n",
   82450             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationScope),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationScope),SgDeclarationScope::pool_size);
   82451             :         }
   82452             : #endif
   82453             : 
   82454           4 :         SgDeclarationScope * pointer = (SgDeclarationScope*) ROSE_MALLOC ( SgDeclarationScope::pool_size * sizeof(SgDeclarationScope) );
   82455           4 :         assert( pointer != NULL );
   82456             : #if ROSE_ALLOC_MEMSET == 1
   82457             :         memset(pointer, 0x00, SgDeclarationScope::pool_size * sizeof(SgDeclarationScope));
   82458             : #elif ROSE_ALLOC_MEMSET == 2
   82459             :         memset(pointer, 0xCC, SgDeclarationScope::pool_size * sizeof(SgDeclarationScope));
   82460             : #endif
   82461           4 :         SgDeclarationScope::pools.push_back( (unsigned char*)(pointer) );
   82462           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDeclarationScope::pool_size * sizeof(SgDeclarationScope), V_SgDeclarationScope ) );
   82463             : 
   82464           4 :         if ( SgDeclarationScope::next_node != NULL ) {
   82465           3 :           if ( blockIndex > 0 ) {
   82466           3 :             SgDeclarationScope * blkptr = (SgDeclarationScope*)(SgDeclarationScope::pools[blockIndex-1]);
   82467           3 :             blkptr[ SgDeclarationScope::pool_size - 1 ].set_freepointer(pointer);
   82468             :           }
   82469             :         } else {
   82470           1 :           SgDeclarationScope::next_node = pointer;
   82471             :         }
   82472             : 
   82473        8000 :         for (unsigned i = 0; i < SgDeclarationScope::pool_size-1; ++i)
   82474             :            {
   82475        7996 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   82476             :            }
   82477           4 :         pointer[ SgDeclarationScope::pool_size -1 ].set_freepointer(NULL);
   82478             : 
   82479           4 :         blockIndex++;
   82480             :       }
   82481           2 :   }
   82482             : 
   82483             : //############################################################################
   82484             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   82485             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   82486             :  * not compressed. However, that stuff is not yet implemented! 
   82487             :  */
   82488             : unsigned long
   82489           0 : SgDeclarationScope::getNumberOfLastValidPointer()
   82490             :    {
   82491           0 :       SgDeclarationScope* testPointer = (SgDeclarationScope*)(SgDeclarationScope::pools.back());
   82492           0 :       unsigned long localIndex = SgDeclarationScope::pool_size - 1;
   82493           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   82494             :          {
   82495           0 :            localIndex--;
   82496             :          }
   82497           0 :       return (localIndex + SgDeclarationScope::pool_size * (SgDeclarationScope::pools.size()-1));
   82498             :    }
   82499             : 
   82500             : //############################################################################
   82501             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   82502             :  * memory pool and initializes the data member in class SgDeclarationScopeStroageClass
   82503             :  * from its counterpart of SgDeclarationScope. The return value is just for checking, 
   82504             :  * that the whole StorageClassArray is initialized!
   82505             :  */
   82506             : unsigned long
   82507           1 : SgDeclarationScope::initializeStorageClassArray( SgDeclarationScopeStorageClass *storageArray )
   82508             :    {
   82509           1 :      unsigned long storageCounter = 0;
   82510           1 :      std::vector < unsigned char* > :: const_iterator block = SgDeclarationScope::pools.begin();
   82511           1 :      SgDeclarationScope* pointer = NULL;
   82512           5 :      while ( block != SgDeclarationScope::pools.end() ) {
   82513           4 :           pointer = (SgDeclarationScope*) (*block);
   82514        8004 :           for ( unsigned i = 0; i < SgDeclarationScope::pool_size; ++i ) {
   82515        8000 :                if ( pointer->get_freepointer() != NULL ) {
   82516        6496 :                  storageArray->pickOutIRNodeData (pointer) ;
   82517        6496 :                  storageArray++;
   82518        6496 :                  storageCounter++;
   82519             :                }
   82520        8000 :                pointer++;
   82521             :              }
   82522           4 :            block++;
   82523             :         }
   82524           1 :      return storageCounter;
   82525             :    }
   82526             : 
   82527             : /* #line 82528 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   82528             : 
   82529             : 
   82530             : 
   82531             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   82532             : 
   82533             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   82534             : 
   82535             : //############################################################################
   82536             : /* JH (02/02/2006) Constructor of the IR node SgRangeBasedForStatement that takes its 
   82537             :  * corresponding StorageClass as parameter
   82538             :  */
   82539           0 : SgRangeBasedForStatement :: SgRangeBasedForStatement ( const SgRangeBasedForStatementStorageClass& storageSource )   : SgScopeStatement (storageSource)
   82540             :    {
   82541             : 
   82542             : 
   82543             : /* #line 82544 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   82544             : 
   82545           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   82546           0 :      p_iterator_declaration =  (SgVariableDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_iterator_declaration) );
   82547           0 :      p_range_declaration =  (SgVariableDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_range_declaration) );
   82548           0 :      p_begin_declaration =  (SgVariableDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_begin_declaration) );
   82549           0 :      p_end_declaration =  (SgVariableDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_declaration) );
   82550           0 :      p_not_equal_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_not_equal_expression) );
   82551           0 :      p_increment_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_increment_expression) );
   82552           0 :      p_loop_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_loop_body) );
   82553             : 
   82554             : 
   82555             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   82556             : 
   82557             : 
   82558           0 :    }
   82559             : 
   82560             : //############################################################################
   82561             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   82562             :  * within the working AST. 
   82563             :  */
   82564           0 : SgRangeBasedForStatement * SgRangeBasedForStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   82565           0 :      SgRangeBasedForStatement* returnPointer = NULL;
   82566           0 :      if ( globalIndex != 0 )
   82567             :         {
   82568             : 
   82569             : #if FILE_IO_EXTRA_CHECK
   82570           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRangeBasedForStatement ) ) <= globalIndex ) ;
   82571           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRangeBasedForStatement + 1 ) ) );
   82572             : #endif
   82573           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRangeBasedForStatement )  
   82574           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRangeBasedForStatement );
   82575           0 :           unsigned long positionInPool = localIndex % SgRangeBasedForStatement::pool_size;
   82576           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRangeBasedForStatement::pool_size;
   82577             : 
   82578             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   82579             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   82580             : 
   82581           0 :           returnPointer = &( ( (SgRangeBasedForStatement*)(SgRangeBasedForStatement::pools[memoryBlock]) ) [positionInPool]) ;
   82582             : 
   82583           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   82584             :         }
   82585           0 :      return returnPointer ;
   82586             :    }
   82587             : 
   82588             : //############################################################################
   82589             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   82590             :   for the AST with the index astIndex
   82591             : */
   82592           0 : SgRangeBasedForStatement * SgRangeBasedForStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   82593           0 :      SgRangeBasedForStatement* returnPointer = NULL;
   82594           0 :      if ( globalIndex != 0 )
   82595             :         {
   82596             : 
   82597             : #if FILE_IO_EXTRA_CHECK
   82598           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRangeBasedForStatement ) ) <= globalIndex ) ;
   82599           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRangeBasedForStatement + 1 ) ) );
   82600             : #endif
   82601           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRangeBasedForStatement )
   82602           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRangeBasedForStatement );
   82603           0 :           unsigned long positionInPool = localIndex % SgRangeBasedForStatement::pool_size ;
   82604           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRangeBasedForStatement::pool_size ;
   82605             : 
   82606             : #if FILE_IO_EXTRA_CHECK
   82607             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   82608             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   82609             : #endif
   82610             : 
   82611           0 :           returnPointer = &( ( (SgRangeBasedForStatement*)(SgRangeBasedForStatement::pools[memoryBlock]) ) [positionInPool]) ;
   82612             : 
   82613             : #if FILE_IO_EXTRA_CHECK
   82614           0 :           assert ( returnPointer != NULL ) ;
   82615             : #endif
   82616             :         }
   82617           0 :      return returnPointer ;
   82618             :    }
   82619             : 
   82620             : //############################################################################
   82621             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   82622             :  * pool size! We set for every valid object in the memory pool the freepointer
   82623             :  * to the global index and increase the global index afterwards. For all the 
   82624             :  * invalid objects (means address ranges within the memory pool that were not
   82625             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   82626             :  * distinguish valid from invalid objects! 
   82627             :  */
   82628             : unsigned long
   82629           5 : SgRangeBasedForStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   82630             :    {
   82631           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   82632           5 :      SgRangeBasedForStatement* pointer = NULL;
   82633           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   82634           5 :      std::vector < unsigned char* > :: const_iterator block;
   82635           5 :      for ( block = SgRangeBasedForStatement::pools.begin(); block != SgRangeBasedForStatement::pools.end() ; ++block )
   82636             :         {
   82637           0 :           pointer = (SgRangeBasedForStatement*)(*block);
   82638           0 :           for (unsigned i = 0; i < SgRangeBasedForStatement::pool_size; ++i )
   82639             :              {
   82640             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   82641             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   82642             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   82643             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   82644             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   82645             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   82646             :             // properly; so this will have to be checked next.
   82647             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   82648             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   82649           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   82650             :                   {
   82651           0 :                     pointer[i].set_freepointer((SgRangeBasedForStatement*)(globalIndex));
   82652           0 :                     globalIndex++;
   82653             :                   }
   82654             :                else
   82655             :                   {
   82656           0 :                     pointer[i].set_freepointer(NULL);
   82657             :                   }
   82658             :               }
   82659             :         }
   82660           5 :      return globalIndex;
   82661             :    }
   82662             : 
   82663             : //############################################################################
   82664             : // JH (01/14/2006)
   82665             : void
   82666           5 : SgRangeBasedForStatement::resetValidFreepointers( )
   82667             :    {
   82668           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   82669           5 :      SgRangeBasedForStatement* pointer = NULL;
   82670           5 :      std::vector < unsigned char* > :: const_iterator block;
   82671           5 :      SgRangeBasedForStatement* pointerOfLinkedList = NULL;
   82672           5 :      for ( block = SgRangeBasedForStatement::pools.begin(); block != SgRangeBasedForStatement::pools.end() ; ++block )
   82673             :         {
   82674           0 :           pointer = (SgRangeBasedForStatement*)(*block);
   82675           0 :           for (unsigned i = 0; i < SgRangeBasedForStatement::pool_size; ++i )
   82676             :              {
   82677             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   82678             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   82679             :             // memory blocks!.
   82680           0 :                if ( pointer[i].get_freepointer() != NULL )
   82681             :                   {
   82682           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   82683             :                   }
   82684             :                else
   82685             :                   {
   82686           0 :                     if ( pointerOfLinkedList == NULL )
   82687             :                        {
   82688           0 :                          SgRangeBasedForStatement::next_node = &(pointer[i]);
   82689             :                        }
   82690             :                     else
   82691             :                        {
   82692             :                       // printf ("In SgRangeBasedForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   82693           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   82694             :                        }
   82695             :                     pointerOfLinkedList = &(pointer[i]);
   82696             :                   }
   82697             :               }
   82698             :         }
   82699             : 
   82700           5 :      if ( pointerOfLinkedList != NULL )
   82701             :         {
   82702             :        // printf ("In SgRangeBasedForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   82703           0 :           pointerOfLinkedList->set_freepointer(NULL);
   82704             :        // DQ (6/6/2010): Temporary debugging...
   82705             :        //   ROSE_ASSERT(false);
   82706             :         }
   82707             : 
   82708           5 :      return ;
   82709             :    }
   82710             : 
   82711             : //############################################################################
   82712             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   82713             :  * within the memory pool and resets the freepointers, in order to achieve a 
   82714             :  * linked list, that has no jumps and starts at the beginning! This function 
   82715             :  * does not extend the memory pool, since we do not delete any memory blocks,
   82716             :  * but delete the valid objects.  
   82717             :  */
   82718             : void
   82719           0 : SgRangeBasedForStatement::clearMemoryPool( )
   82720             :    {
   82721             :   // printf ("Inside of SgRangeBasedForStatement::clearMemoryPool() \n");
   82722             : 
   82723           0 :      SgRangeBasedForStatement* pointer = NULL, *tempPointer = NULL;
   82724           0 :      std::vector < unsigned char* > :: const_iterator block;
   82725           0 :      if ( SgRangeBasedForStatement::pools.empty() == false )
   82726             :         {
   82727           0 :           block = SgRangeBasedForStatement::pools.begin() ;
   82728           0 :           SgRangeBasedForStatement::next_node = (SgRangeBasedForStatement*) (*block);
   82729             : 
   82730           0 :           while ( block != SgRangeBasedForStatement::pools.end() )
   82731             :              {
   82732           0 :                pointer = (SgRangeBasedForStatement*) (*block);
   82733           0 :                if ( tempPointer != NULL )
   82734             :                   {
   82735           0 :                     tempPointer->set_freepointer(pointer);
   82736             :                   }
   82737           0 :                for (unsigned i = 0; i < SgRangeBasedForStatement::pool_size - 1; ++i)
   82738             :                   {
   82739           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   82740             :                   }
   82741           0 :                 pointer[SgRangeBasedForStatement::pool_size-1].set_freepointer(NULL);
   82742           0 :                 tempPointer = &(pointer[SgRangeBasedForStatement::pool_size-1]);
   82743           0 :                 ++block;
   82744             :              }
   82745             :         }
   82746           0 :    }
   82747             : 
   82748           5 : void SgRangeBasedForStatement::deleteMemoryPool() {
   82749           5 :   for (auto p: SgRangeBasedForStatement::pools) {
   82750           0 :     ROSE_FREE(p);
   82751             :   }
   82752           5 :   SgRangeBasedForStatement::next_node = nullptr;
   82753           5 :   SgRangeBasedForStatement::pools.clear();
   82754           5 : }
   82755             : 
   82756             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   82757             : //                 reading multiple binary files to for a single AST.
   82758             : /////////// new version ////////////////////////////////
   82759             : //############################################################################
   82760             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   82761             : void
   82762           2 : SgRangeBasedForStatement::extendMemoryPoolForFileIO( )
   82763             :   {
   82764           2 :     size_t blockIndex = SgRangeBasedForStatement::pools.size();
   82765           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRangeBasedForStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRangeBasedForStatement);
   82766             : 
   82767           2 :     while ( (blockIndex * SgRangeBasedForStatement::pool_size) < newPoolSize)
   82768             :       {
   82769             : #if ROSE_ALLOC_TRACE
   82770             :         if (blockIndex > 0) {
   82771             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRangeBasedForStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRangeBasedForStatement) = %" PRIuPTR " SgRangeBasedForStatement::pool_size = %d \n",
   82772             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRangeBasedForStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRangeBasedForStatement),SgRangeBasedForStatement::pool_size);
   82773             :         }
   82774             : #endif
   82775             : 
   82776           0 :         SgRangeBasedForStatement * pointer = (SgRangeBasedForStatement*) ROSE_MALLOC ( SgRangeBasedForStatement::pool_size * sizeof(SgRangeBasedForStatement) );
   82777           0 :         assert( pointer != NULL );
   82778             : #if ROSE_ALLOC_MEMSET == 1
   82779             :         memset(pointer, 0x00, SgRangeBasedForStatement::pool_size * sizeof(SgRangeBasedForStatement));
   82780             : #elif ROSE_ALLOC_MEMSET == 2
   82781             :         memset(pointer, 0xCC, SgRangeBasedForStatement::pool_size * sizeof(SgRangeBasedForStatement));
   82782             : #endif
   82783           0 :         SgRangeBasedForStatement::pools.push_back( (unsigned char*)(pointer) );
   82784           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRangeBasedForStatement::pool_size * sizeof(SgRangeBasedForStatement), V_SgRangeBasedForStatement ) );
   82785             : 
   82786           0 :         if ( SgRangeBasedForStatement::next_node != NULL ) {
   82787           0 :           if ( blockIndex > 0 ) {
   82788           0 :             SgRangeBasedForStatement * blkptr = (SgRangeBasedForStatement*)(SgRangeBasedForStatement::pools[blockIndex-1]);
   82789           0 :             blkptr[ SgRangeBasedForStatement::pool_size - 1 ].set_freepointer(pointer);
   82790             :           }
   82791             :         } else {
   82792           0 :           SgRangeBasedForStatement::next_node = pointer;
   82793             :         }
   82794             : 
   82795           0 :         for (unsigned i = 0; i < SgRangeBasedForStatement::pool_size-1; ++i)
   82796             :            {
   82797           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   82798             :            }
   82799           0 :         pointer[ SgRangeBasedForStatement::pool_size -1 ].set_freepointer(NULL);
   82800             : 
   82801           0 :         blockIndex++;
   82802             :       }
   82803           2 :   }
   82804             : 
   82805             : //############################################################################
   82806             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   82807             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   82808             :  * not compressed. However, that stuff is not yet implemented! 
   82809             :  */
   82810             : unsigned long
   82811           0 : SgRangeBasedForStatement::getNumberOfLastValidPointer()
   82812             :    {
   82813           0 :       SgRangeBasedForStatement* testPointer = (SgRangeBasedForStatement*)(SgRangeBasedForStatement::pools.back());
   82814           0 :       unsigned long localIndex = SgRangeBasedForStatement::pool_size - 1;
   82815           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   82816             :          {
   82817           0 :            localIndex--;
   82818             :          }
   82819           0 :       return (localIndex + SgRangeBasedForStatement::pool_size * (SgRangeBasedForStatement::pools.size()-1));
   82820             :    }
   82821             : 
   82822             : //############################################################################
   82823             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   82824             :  * memory pool and initializes the data member in class SgRangeBasedForStatementStroageClass
   82825             :  * from its counterpart of SgRangeBasedForStatement. The return value is just for checking, 
   82826             :  * that the whole StorageClassArray is initialized!
   82827             :  */
   82828             : unsigned long
   82829           0 : SgRangeBasedForStatement::initializeStorageClassArray( SgRangeBasedForStatementStorageClass *storageArray )
   82830             :    {
   82831           0 :      unsigned long storageCounter = 0;
   82832           0 :      std::vector < unsigned char* > :: const_iterator block = SgRangeBasedForStatement::pools.begin();
   82833           0 :      SgRangeBasedForStatement* pointer = NULL;
   82834           0 :      while ( block != SgRangeBasedForStatement::pools.end() ) {
   82835           0 :           pointer = (SgRangeBasedForStatement*) (*block);
   82836           0 :           for ( unsigned i = 0; i < SgRangeBasedForStatement::pool_size; ++i ) {
   82837           0 :                if ( pointer->get_freepointer() != NULL ) {
   82838           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   82839           0 :                  storageArray++;
   82840           0 :                  storageCounter++;
   82841             :                }
   82842           0 :                pointer++;
   82843             :              }
   82844           0 :            block++;
   82845             :         }
   82846           0 :      return storageCounter;
   82847             :    }
   82848             : 
   82849             : /* #line 82850 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   82850             : 
   82851             : 
   82852             : 
   82853             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   82854             : 
   82855             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   82856             : 
   82857             : //############################################################################
   82858             : /* JH (02/02/2006) Constructor of the IR node SgFunctionTypeTable that takes its 
   82859             :  * corresponding StorageClass as parameter
   82860             :  */
   82861           2 : SgFunctionTypeTable :: SgFunctionTypeTable ( const SgFunctionTypeTableStorageClass& storageSource )   : SgStatement (storageSource)
   82862             :    {
   82863             : 
   82864             : 
   82865             : /* #line 82866 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   82866             : 
   82867           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   82868           2 :      p_function_type_table =  (SgSymbolTable*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_function_type_table) );
   82869             : 
   82870             : 
   82871             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   82872             : 
   82873             : 
   82874           2 :    }
   82875             : 
   82876             : //############################################################################
   82877             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   82878             :  * within the working AST. 
   82879             :  */
   82880           8 : SgFunctionTypeTable * SgFunctionTypeTable::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   82881           8 :      SgFunctionTypeTable* returnPointer = NULL;
   82882           8 :      if ( globalIndex != 0 )
   82883             :         {
   82884             : 
   82885             : #if FILE_IO_EXTRA_CHECK
   82886           8 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionTypeTable ) ) <= globalIndex ) ;
   82887           8 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionTypeTable + 1 ) ) );
   82888             : #endif
   82889           8 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionTypeTable )  
   82890           8 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionTypeTable );
   82891           8 :           unsigned long positionInPool = localIndex % SgFunctionTypeTable::pool_size;
   82892           8 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionTypeTable::pool_size;
   82893             : 
   82894             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   82895             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   82896             : 
   82897           8 :           returnPointer = &( ( (SgFunctionTypeTable*)(SgFunctionTypeTable::pools[memoryBlock]) ) [positionInPool]) ;
   82898             : 
   82899           8 :           ROSE_ASSERT( returnPointer != NULL ) ;
   82900             :         }
   82901           8 :      return returnPointer ;
   82902             :    }
   82903             : 
   82904             : //############################################################################
   82905             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   82906             :   for the AST with the index astIndex
   82907             : */
   82908           0 : SgFunctionTypeTable * SgFunctionTypeTable::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   82909           0 :      SgFunctionTypeTable* returnPointer = NULL;
   82910           0 :      if ( globalIndex != 0 )
   82911             :         {
   82912             : 
   82913             : #if FILE_IO_EXTRA_CHECK
   82914           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionTypeTable ) ) <= globalIndex ) ;
   82915           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionTypeTable + 1 ) ) );
   82916             : #endif
   82917           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionTypeTable )
   82918           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionTypeTable );
   82919           0 :           unsigned long positionInPool = localIndex % SgFunctionTypeTable::pool_size ;
   82920           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionTypeTable::pool_size ;
   82921             : 
   82922             : #if FILE_IO_EXTRA_CHECK
   82923             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   82924             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   82925             : #endif
   82926             : 
   82927           0 :           returnPointer = &( ( (SgFunctionTypeTable*)(SgFunctionTypeTable::pools[memoryBlock]) ) [positionInPool]) ;
   82928             : 
   82929             : #if FILE_IO_EXTRA_CHECK
   82930           0 :           assert ( returnPointer != NULL ) ;
   82931             : #endif
   82932             :         }
   82933           0 :      return returnPointer ;
   82934             :    }
   82935             : 
   82936             : //############################################################################
   82937             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   82938             :  * pool size! We set for every valid object in the memory pool the freepointer
   82939             :  * to the global index and increase the global index afterwards. For all the 
   82940             :  * invalid objects (means address ranges within the memory pool that were not
   82941             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   82942             :  * distinguish valid from invalid objects! 
   82943             :  */
   82944             : unsigned long
   82945           5 : SgFunctionTypeTable::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   82946             :    {
   82947           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   82948           5 :      SgFunctionTypeTable* pointer = NULL;
   82949           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   82950           5 :      std::vector < unsigned char* > :: const_iterator block;
   82951          10 :      for ( block = SgFunctionTypeTable::pools.begin(); block != SgFunctionTypeTable::pools.end() ; ++block )
   82952             :         {
   82953           5 :           pointer = (SgFunctionTypeTable*)(*block);
   82954       10005 :           for (unsigned i = 0; i < SgFunctionTypeTable::pool_size; ++i )
   82955             :              {
   82956             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   82957             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   82958             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   82959             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   82960             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   82961             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   82962             :             // properly; so this will have to be checked next.
   82963             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   82964             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   82965       10000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   82966             :                   {
   82967           5 :                     pointer[i].set_freepointer((SgFunctionTypeTable*)(globalIndex));
   82968           5 :                     globalIndex++;
   82969             :                   }
   82970             :                else
   82971             :                   {
   82972        9995 :                     pointer[i].set_freepointer(NULL);
   82973             :                   }
   82974             :               }
   82975             :         }
   82976           5 :      return globalIndex;
   82977             :    }
   82978             : 
   82979             : //############################################################################
   82980             : // JH (01/14/2006)
   82981             : void
   82982           5 : SgFunctionTypeTable::resetValidFreepointers( )
   82983             :    {
   82984           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   82985           5 :      SgFunctionTypeTable* pointer = NULL;
   82986           5 :      std::vector < unsigned char* > :: const_iterator block;
   82987           5 :      SgFunctionTypeTable* pointerOfLinkedList = NULL;
   82988          10 :      for ( block = SgFunctionTypeTable::pools.begin(); block != SgFunctionTypeTable::pools.end() ; ++block )
   82989             :         {
   82990           5 :           pointer = (SgFunctionTypeTable*)(*block);
   82991       10005 :           for (unsigned i = 0; i < SgFunctionTypeTable::pool_size; ++i )
   82992             :              {
   82993             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   82994             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   82995             :             // memory blocks!.
   82996       10000 :                if ( pointer[i].get_freepointer() != NULL )
   82997             :                   {
   82998           5 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   82999             :                   }
   83000             :                else
   83001             :                   {
   83002        9995 :                     if ( pointerOfLinkedList == NULL )
   83003             :                        {
   83004           5 :                          SgFunctionTypeTable::next_node = &(pointer[i]);
   83005             :                        }
   83006             :                     else
   83007             :                        {
   83008             :                       // printf ("In SgFunctionTypeTable::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   83009        9990 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   83010             :                        }
   83011             :                     pointerOfLinkedList = &(pointer[i]);
   83012             :                   }
   83013             :               }
   83014             :         }
   83015             : 
   83016           5 :      if ( pointerOfLinkedList != NULL )
   83017             :         {
   83018             :        // printf ("In SgFunctionTypeTable::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   83019           5 :           pointerOfLinkedList->set_freepointer(NULL);
   83020             :        // DQ (6/6/2010): Temporary debugging...
   83021             :        //   ROSE_ASSERT(false);
   83022             :         }
   83023             : 
   83024           5 :      return ;
   83025             :    }
   83026             : 
   83027             : //############################################################################
   83028             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   83029             :  * within the memory pool and resets the freepointers, in order to achieve a 
   83030             :  * linked list, that has no jumps and starts at the beginning! This function 
   83031             :  * does not extend the memory pool, since we do not delete any memory blocks,
   83032             :  * but delete the valid objects.  
   83033             :  */
   83034             : void
   83035           0 : SgFunctionTypeTable::clearMemoryPool( )
   83036             :    {
   83037             :   // printf ("Inside of SgFunctionTypeTable::clearMemoryPool() \n");
   83038             : 
   83039           0 :      SgFunctionTypeTable* pointer = NULL, *tempPointer = NULL;
   83040           0 :      std::vector < unsigned char* > :: const_iterator block;
   83041           0 :      if ( SgFunctionTypeTable::pools.empty() == false )
   83042             :         {
   83043           0 :           block = SgFunctionTypeTable::pools.begin() ;
   83044           0 :           SgFunctionTypeTable::next_node = (SgFunctionTypeTable*) (*block);
   83045             : 
   83046           0 :           while ( block != SgFunctionTypeTable::pools.end() )
   83047             :              {
   83048           0 :                pointer = (SgFunctionTypeTable*) (*block);
   83049           0 :                if ( tempPointer != NULL )
   83050             :                   {
   83051           0 :                     tempPointer->set_freepointer(pointer);
   83052             :                   }
   83053           0 :                for (unsigned i = 0; i < SgFunctionTypeTable::pool_size - 1; ++i)
   83054             :                   {
   83055           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   83056             :                   }
   83057           0 :                 pointer[SgFunctionTypeTable::pool_size-1].set_freepointer(NULL);
   83058           0 :                 tempPointer = &(pointer[SgFunctionTypeTable::pool_size-1]);
   83059           0 :                 ++block;
   83060             :              }
   83061             :         }
   83062           0 :    }
   83063             : 
   83064           5 : void SgFunctionTypeTable::deleteMemoryPool() {
   83065          10 :   for (auto p: SgFunctionTypeTable::pools) {
   83066           5 :     ROSE_FREE(p);
   83067             :   }
   83068           5 :   SgFunctionTypeTable::next_node = nullptr;
   83069           5 :   SgFunctionTypeTable::pools.clear();
   83070           5 : }
   83071             : 
   83072             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   83073             : //                 reading multiple binary files to for a single AST.
   83074             : /////////// new version ////////////////////////////////
   83075             : //############################################################################
   83076             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   83077             : void
   83078           2 : SgFunctionTypeTable::extendMemoryPoolForFileIO( )
   83079             :   {
   83080           2 :     size_t blockIndex = SgFunctionTypeTable::pools.size();
   83081           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionTypeTable) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionTypeTable);
   83082             : 
   83083           2 :     while ( (blockIndex * SgFunctionTypeTable::pool_size) < newPoolSize)
   83084             :       {
   83085             : #if ROSE_ALLOC_TRACE
   83086             :         if (blockIndex > 0) {
   83087             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionTypeTable) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionTypeTable) = %" PRIuPTR " SgFunctionTypeTable::pool_size = %d \n",
   83088             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionTypeTable),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionTypeTable),SgFunctionTypeTable::pool_size);
   83089             :         }
   83090             : #endif
   83091             : 
   83092           0 :         SgFunctionTypeTable * pointer = (SgFunctionTypeTable*) ROSE_MALLOC ( SgFunctionTypeTable::pool_size * sizeof(SgFunctionTypeTable) );
   83093           0 :         assert( pointer != NULL );
   83094             : #if ROSE_ALLOC_MEMSET == 1
   83095             :         memset(pointer, 0x00, SgFunctionTypeTable::pool_size * sizeof(SgFunctionTypeTable));
   83096             : #elif ROSE_ALLOC_MEMSET == 2
   83097             :         memset(pointer, 0xCC, SgFunctionTypeTable::pool_size * sizeof(SgFunctionTypeTable));
   83098             : #endif
   83099           0 :         SgFunctionTypeTable::pools.push_back( (unsigned char*)(pointer) );
   83100           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionTypeTable::pool_size * sizeof(SgFunctionTypeTable), V_SgFunctionTypeTable ) );
   83101             : 
   83102           0 :         if ( SgFunctionTypeTable::next_node != NULL ) {
   83103           0 :           if ( blockIndex > 0 ) {
   83104           0 :             SgFunctionTypeTable * blkptr = (SgFunctionTypeTable*)(SgFunctionTypeTable::pools[blockIndex-1]);
   83105           0 :             blkptr[ SgFunctionTypeTable::pool_size - 1 ].set_freepointer(pointer);
   83106             :           }
   83107             :         } else {
   83108           0 :           SgFunctionTypeTable::next_node = pointer;
   83109             :         }
   83110             : 
   83111           0 :         for (unsigned i = 0; i < SgFunctionTypeTable::pool_size-1; ++i)
   83112             :            {
   83113           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   83114             :            }
   83115           0 :         pointer[ SgFunctionTypeTable::pool_size -1 ].set_freepointer(NULL);
   83116             : 
   83117           0 :         blockIndex++;
   83118             :       }
   83119           2 :   }
   83120             : 
   83121             : //############################################################################
   83122             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   83123             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   83124             :  * not compressed. However, that stuff is not yet implemented! 
   83125             :  */
   83126             : unsigned long
   83127           0 : SgFunctionTypeTable::getNumberOfLastValidPointer()
   83128             :    {
   83129           0 :       SgFunctionTypeTable* testPointer = (SgFunctionTypeTable*)(SgFunctionTypeTable::pools.back());
   83130           0 :       unsigned long localIndex = SgFunctionTypeTable::pool_size - 1;
   83131           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   83132             :          {
   83133           0 :            localIndex--;
   83134             :          }
   83135           0 :       return (localIndex + SgFunctionTypeTable::pool_size * (SgFunctionTypeTable::pools.size()-1));
   83136             :    }
   83137             : 
   83138             : //############################################################################
   83139             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   83140             :  * memory pool and initializes the data member in class SgFunctionTypeTableStroageClass
   83141             :  * from its counterpart of SgFunctionTypeTable. The return value is just for checking, 
   83142             :  * that the whole StorageClassArray is initialized!
   83143             :  */
   83144             : unsigned long
   83145           3 : SgFunctionTypeTable::initializeStorageClassArray( SgFunctionTypeTableStorageClass *storageArray )
   83146             :    {
   83147           3 :      unsigned long storageCounter = 0;
   83148           3 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionTypeTable::pools.begin();
   83149           3 :      SgFunctionTypeTable* pointer = NULL;
   83150           6 :      while ( block != SgFunctionTypeTable::pools.end() ) {
   83151           3 :           pointer = (SgFunctionTypeTable*) (*block);
   83152        6003 :           for ( unsigned i = 0; i < SgFunctionTypeTable::pool_size; ++i ) {
   83153        6000 :                if ( pointer->get_freepointer() != NULL ) {
   83154           3 :                  storageArray->pickOutIRNodeData (pointer) ;
   83155           3 :                  storageArray++;
   83156           3 :                  storageCounter++;
   83157             :                }
   83158        6000 :                pointer++;
   83159             :              }
   83160           3 :            block++;
   83161             :         }
   83162           3 :      return storageCounter;
   83163             :    }
   83164             : 
   83165             : /* #line 83166 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   83166             : 
   83167             : 
   83168             : 
   83169             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   83170             : 
   83171             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   83172             : 
   83173             : //############################################################################
   83174             : /* JH (02/02/2006) Constructor of the IR node SgDeclarationStatement that takes its 
   83175             :  * corresponding StorageClass as parameter
   83176             :  */
   83177       53837 : SgDeclarationStatement :: SgDeclarationStatement ( const SgDeclarationStatementStorageClass& storageSource )   : SgStatement (storageSource)
   83178             :    {
   83179             : 
   83180             : 
   83181             : /* #line 83182 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   83182             : 
   83183       53837 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   83184       53837 :      p_decl_attributes = storageSource.storageOf_decl_attributes ;
   83185       53837 :      p_linkage = storageSource.storageOf_linkage.rebuildDataStoredInEasyStorageClass() ;
   83186       53837 :      p_declarationModifier = SgDeclarationModifier ( storageSource.storageOf_declarationModifier ) ;
   83187       53837 :      p_nameOnly = storageSource.storageOf_nameOnly ;
   83188       53837 :      p_forward = storageSource.storageOf_forward ;
   83189       53837 :      p_externBrace = storageSource.storageOf_externBrace ;
   83190       53837 :      p_skipElaborateType = storageSource.storageOf_skipElaborateType ;
   83191       53837 :      p_definingDeclaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_definingDeclaration) );
   83192       53837 :      p_firstNondefiningDeclaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_firstNondefiningDeclaration) );
   83193       53837 :      p_qualifiedNameList = storageSource.storageOf_qualifiedNameList.rebuildDataStoredInEasyStorageClass() ;
   83194       53837 :      SgQualifiedNamePtrList::iterator i_qualifiedNameList = p_qualifiedNameList.begin() ; 
   83195       53837 :      for ( ; i_qualifiedNameList != p_qualifiedNameList.end(); ++i_qualifiedNameList ) 
   83196             :         {
   83197           0 :           (*i_qualifiedNameList) = (SgQualifiedNamePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_qualifiedNameList) ) );
   83198             :         }
   83199       53837 :      p_binding_label = storageSource.storageOf_binding_label.rebuildDataStoredInEasyStorageClass() ;
   83200       53837 :      p_declarationScope =  (SgDeclarationScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declarationScope) );
   83201       53837 :      p_unparse_template_ast = storageSource.storageOf_unparse_template_ast ;
   83202             : 
   83203             : 
   83204             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   83205             : 
   83206             : 
   83207       53837 :    }
   83208             : 
   83209             : //############################################################################
   83210             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   83211             :  * within the working AST. 
   83212             :  */
   83213           0 : SgDeclarationStatement * SgDeclarationStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   83214           0 :      SgDeclarationStatement* returnPointer = NULL;
   83215           0 :      if ( globalIndex != 0 )
   83216             :         {
   83217             : 
   83218             : #if FILE_IO_EXTRA_CHECK
   83219           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDeclarationStatement ) ) <= globalIndex ) ;
   83220           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeclarationStatement + 1 ) ) );
   83221             : #endif
   83222           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeclarationStatement )  
   83223           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDeclarationStatement );
   83224           0 :           unsigned long positionInPool = localIndex % SgDeclarationStatement::pool_size;
   83225           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeclarationStatement::pool_size;
   83226             : 
   83227             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   83228             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   83229             : 
   83230           0 :           returnPointer = &( ( (SgDeclarationStatement*)(SgDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   83231             : 
   83232           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   83233             :         }
   83234           0 :      return returnPointer ;
   83235             :    }
   83236             : 
   83237             : //############################################################################
   83238             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   83239             :   for the AST with the index astIndex
   83240             : */
   83241           0 : SgDeclarationStatement * SgDeclarationStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   83242           0 :      SgDeclarationStatement* returnPointer = NULL;
   83243           0 :      if ( globalIndex != 0 )
   83244             :         {
   83245             : 
   83246             : #if FILE_IO_EXTRA_CHECK
   83247           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDeclarationStatement ) ) <= globalIndex ) ;
   83248           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeclarationStatement + 1 ) ) );
   83249             : #endif
   83250           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeclarationStatement )
   83251           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDeclarationStatement );
   83252           0 :           unsigned long positionInPool = localIndex % SgDeclarationStatement::pool_size ;
   83253           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeclarationStatement::pool_size ;
   83254             : 
   83255             : #if FILE_IO_EXTRA_CHECK
   83256             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   83257             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   83258             : #endif
   83259             : 
   83260           0 :           returnPointer = &( ( (SgDeclarationStatement*)(SgDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   83261             : 
   83262             : #if FILE_IO_EXTRA_CHECK
   83263           0 :           assert ( returnPointer != NULL ) ;
   83264             : #endif
   83265             :         }
   83266           0 :      return returnPointer ;
   83267             :    }
   83268             : 
   83269             : //############################################################################
   83270             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   83271             :  * pool size! We set for every valid object in the memory pool the freepointer
   83272             :  * to the global index and increase the global index afterwards. For all the 
   83273             :  * invalid objects (means address ranges within the memory pool that were not
   83274             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   83275             :  * distinguish valid from invalid objects! 
   83276             :  */
   83277             : unsigned long
   83278           5 : SgDeclarationStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   83279             :    {
   83280           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   83281           5 :      SgDeclarationStatement* pointer = NULL;
   83282           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   83283           5 :      std::vector < unsigned char* > :: const_iterator block;
   83284           5 :      for ( block = SgDeclarationStatement::pools.begin(); block != SgDeclarationStatement::pools.end() ; ++block )
   83285             :         {
   83286           0 :           pointer = (SgDeclarationStatement*)(*block);
   83287           0 :           for (unsigned i = 0; i < SgDeclarationStatement::pool_size; ++i )
   83288             :              {
   83289             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   83290             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   83291             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   83292             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   83293             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   83294             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   83295             :             // properly; so this will have to be checked next.
   83296             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   83297             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   83298           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   83299             :                   {
   83300           0 :                     pointer[i].set_freepointer((SgDeclarationStatement*)(globalIndex));
   83301           0 :                     globalIndex++;
   83302             :                   }
   83303             :                else
   83304             :                   {
   83305           0 :                     pointer[i].set_freepointer(NULL);
   83306             :                   }
   83307             :               }
   83308             :         }
   83309           5 :      return globalIndex;
   83310             :    }
   83311             : 
   83312             : //############################################################################
   83313             : // JH (01/14/2006)
   83314             : void
   83315           5 : SgDeclarationStatement::resetValidFreepointers( )
   83316             :    {
   83317           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   83318           5 :      SgDeclarationStatement* pointer = NULL;
   83319           5 :      std::vector < unsigned char* > :: const_iterator block;
   83320           5 :      SgDeclarationStatement* pointerOfLinkedList = NULL;
   83321           5 :      for ( block = SgDeclarationStatement::pools.begin(); block != SgDeclarationStatement::pools.end() ; ++block )
   83322             :         {
   83323           0 :           pointer = (SgDeclarationStatement*)(*block);
   83324           0 :           for (unsigned i = 0; i < SgDeclarationStatement::pool_size; ++i )
   83325             :              {
   83326             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   83327             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   83328             :             // memory blocks!.
   83329           0 :                if ( pointer[i].get_freepointer() != NULL )
   83330             :                   {
   83331           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   83332             :                   }
   83333             :                else
   83334             :                   {
   83335           0 :                     if ( pointerOfLinkedList == NULL )
   83336             :                        {
   83337           0 :                          SgDeclarationStatement::next_node = &(pointer[i]);
   83338             :                        }
   83339             :                     else
   83340             :                        {
   83341             :                       // printf ("In SgDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   83342           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   83343             :                        }
   83344             :                     pointerOfLinkedList = &(pointer[i]);
   83345             :                   }
   83346             :               }
   83347             :         }
   83348             : 
   83349           5 :      if ( pointerOfLinkedList != NULL )
   83350             :         {
   83351             :        // printf ("In SgDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   83352           0 :           pointerOfLinkedList->set_freepointer(NULL);
   83353             :        // DQ (6/6/2010): Temporary debugging...
   83354             :        //   ROSE_ASSERT(false);
   83355             :         }
   83356             : 
   83357           5 :      return ;
   83358             :    }
   83359             : 
   83360             : //############################################################################
   83361             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   83362             :  * within the memory pool and resets the freepointers, in order to achieve a 
   83363             :  * linked list, that has no jumps and starts at the beginning! This function 
   83364             :  * does not extend the memory pool, since we do not delete any memory blocks,
   83365             :  * but delete the valid objects.  
   83366             :  */
   83367             : void
   83368           0 : SgDeclarationStatement::clearMemoryPool( )
   83369             :    {
   83370             :   // printf ("Inside of SgDeclarationStatement::clearMemoryPool() \n");
   83371             : 
   83372           0 :      SgDeclarationStatement* pointer = NULL, *tempPointer = NULL;
   83373           0 :      std::vector < unsigned char* > :: const_iterator block;
   83374           0 :      if ( SgDeclarationStatement::pools.empty() == false )
   83375             :         {
   83376           0 :           block = SgDeclarationStatement::pools.begin() ;
   83377           0 :           SgDeclarationStatement::next_node = (SgDeclarationStatement*) (*block);
   83378             : 
   83379           0 :           while ( block != SgDeclarationStatement::pools.end() )
   83380             :              {
   83381           0 :                pointer = (SgDeclarationStatement*) (*block);
   83382           0 :                if ( tempPointer != NULL )
   83383             :                   {
   83384           0 :                     tempPointer->set_freepointer(pointer);
   83385             :                   }
   83386           0 :                for (unsigned i = 0; i < SgDeclarationStatement::pool_size - 1; ++i)
   83387             :                   {
   83388           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   83389             :                   }
   83390           0 :                 pointer[SgDeclarationStatement::pool_size-1].set_freepointer(NULL);
   83391           0 :                 tempPointer = &(pointer[SgDeclarationStatement::pool_size-1]);
   83392           0 :                 ++block;
   83393             :              }
   83394             :         }
   83395           0 :    }
   83396             : 
   83397           5 : void SgDeclarationStatement::deleteMemoryPool() {
   83398           5 :   for (auto p: SgDeclarationStatement::pools) {
   83399           0 :     ROSE_FREE(p);
   83400             :   }
   83401           5 :   SgDeclarationStatement::next_node = nullptr;
   83402           5 :   SgDeclarationStatement::pools.clear();
   83403           5 : }
   83404             : 
   83405             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   83406             : //                 reading multiple binary files to for a single AST.
   83407             : /////////// new version ////////////////////////////////
   83408             : //############################################################################
   83409             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   83410             : void
   83411           2 : SgDeclarationStatement::extendMemoryPoolForFileIO( )
   83412             :   {
   83413           2 :     size_t blockIndex = SgDeclarationStatement::pools.size();
   83414           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationStatement);
   83415             : 
   83416           2 :     while ( (blockIndex * SgDeclarationStatement::pool_size) < newPoolSize)
   83417             :       {
   83418             : #if ROSE_ALLOC_TRACE
   83419             :         if (blockIndex > 0) {
   83420             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationStatement) = %" PRIuPTR " SgDeclarationStatement::pool_size = %d \n",
   83421             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDeclarationStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeclarationStatement),SgDeclarationStatement::pool_size);
   83422             :         }
   83423             : #endif
   83424             : 
   83425           0 :         SgDeclarationStatement * pointer = (SgDeclarationStatement*) ROSE_MALLOC ( SgDeclarationStatement::pool_size * sizeof(SgDeclarationStatement) );
   83426           0 :         assert( pointer != NULL );
   83427             : #if ROSE_ALLOC_MEMSET == 1
   83428             :         memset(pointer, 0x00, SgDeclarationStatement::pool_size * sizeof(SgDeclarationStatement));
   83429             : #elif ROSE_ALLOC_MEMSET == 2
   83430             :         memset(pointer, 0xCC, SgDeclarationStatement::pool_size * sizeof(SgDeclarationStatement));
   83431             : #endif
   83432           0 :         SgDeclarationStatement::pools.push_back( (unsigned char*)(pointer) );
   83433           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDeclarationStatement::pool_size * sizeof(SgDeclarationStatement), V_SgDeclarationStatement ) );
   83434             : 
   83435           0 :         if ( SgDeclarationStatement::next_node != NULL ) {
   83436           0 :           if ( blockIndex > 0 ) {
   83437           0 :             SgDeclarationStatement * blkptr = (SgDeclarationStatement*)(SgDeclarationStatement::pools[blockIndex-1]);
   83438           0 :             blkptr[ SgDeclarationStatement::pool_size - 1 ].set_freepointer(pointer);
   83439             :           }
   83440             :         } else {
   83441           0 :           SgDeclarationStatement::next_node = pointer;
   83442             :         }
   83443             : 
   83444           0 :         for (unsigned i = 0; i < SgDeclarationStatement::pool_size-1; ++i)
   83445             :            {
   83446           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   83447             :            }
   83448           0 :         pointer[ SgDeclarationStatement::pool_size -1 ].set_freepointer(NULL);
   83449             : 
   83450           0 :         blockIndex++;
   83451             :       }
   83452           2 :   }
   83453             : 
   83454             : //############################################################################
   83455             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   83456             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   83457             :  * not compressed. However, that stuff is not yet implemented! 
   83458             :  */
   83459             : unsigned long
   83460           0 : SgDeclarationStatement::getNumberOfLastValidPointer()
   83461             :    {
   83462           0 :       SgDeclarationStatement* testPointer = (SgDeclarationStatement*)(SgDeclarationStatement::pools.back());
   83463           0 :       unsigned long localIndex = SgDeclarationStatement::pool_size - 1;
   83464           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   83465             :          {
   83466           0 :            localIndex--;
   83467             :          }
   83468           0 :       return (localIndex + SgDeclarationStatement::pool_size * (SgDeclarationStatement::pools.size()-1));
   83469             :    }
   83470             : 
   83471             : //############################################################################
   83472             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   83473             :  * memory pool and initializes the data member in class SgDeclarationStatementStroageClass
   83474             :  * from its counterpart of SgDeclarationStatement. The return value is just for checking, 
   83475             :  * that the whole StorageClassArray is initialized!
   83476             :  */
   83477             : unsigned long
   83478           0 : SgDeclarationStatement::initializeStorageClassArray( SgDeclarationStatementStorageClass *storageArray )
   83479             :    {
   83480           0 :      unsigned long storageCounter = 0;
   83481           0 :      std::vector < unsigned char* > :: const_iterator block = SgDeclarationStatement::pools.begin();
   83482           0 :      SgDeclarationStatement* pointer = NULL;
   83483           0 :      while ( block != SgDeclarationStatement::pools.end() ) {
   83484           0 :           pointer = (SgDeclarationStatement*) (*block);
   83485           0 :           for ( unsigned i = 0; i < SgDeclarationStatement::pool_size; ++i ) {
   83486           0 :                if ( pointer->get_freepointer() != NULL ) {
   83487           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   83488           0 :                  storageArray++;
   83489           0 :                  storageCounter++;
   83490             :                }
   83491           0 :                pointer++;
   83492             :              }
   83493           0 :            block++;
   83494             :         }
   83495           0 :      return storageCounter;
   83496             :    }
   83497             : 
   83498             : /* #line 83499 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   83499             : 
   83500             : 
   83501             : 
   83502             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   83503             : 
   83504             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   83505             : 
   83506             : //############################################################################
   83507             : /* JH (02/02/2006) Constructor of the IR node SgFunctionParameterList that takes its 
   83508             :  * corresponding StorageClass as parameter
   83509             :  */
   83510       22767 : SgFunctionParameterList :: SgFunctionParameterList ( const SgFunctionParameterListStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   83511             :    {
   83512             : 
   83513             : 
   83514             : /* #line 83515 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   83515             : 
   83516       22767 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   83517       22767 :      p_args = storageSource.storageOf_args.rebuildDataStoredInEasyStorageClass() ;
   83518       22767 :      SgInitializedNamePtrList::iterator i_args = p_args.begin() ; 
   83519       75923 :      for ( ; i_args != p_args.end(); ++i_args ) 
   83520             :         {
   83521       53156 :           (*i_args) = (SgInitializedNamePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_args) ) );
   83522             :         }
   83523             : 
   83524             : 
   83525             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   83526             : 
   83527             : 
   83528       22767 :    }
   83529             : 
   83530             : //############################################################################
   83531             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   83532             :  * within the working AST. 
   83533             :  */
   83534      144224 : SgFunctionParameterList * SgFunctionParameterList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   83535      144224 :      SgFunctionParameterList* returnPointer = NULL;
   83536      144224 :      if ( globalIndex != 0 )
   83537             :         {
   83538             : 
   83539             : #if FILE_IO_EXTRA_CHECK
   83540      144224 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionParameterList ) ) <= globalIndex ) ;
   83541      144224 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionParameterList + 1 ) ) );
   83542             : #endif
   83543      144224 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionParameterList )  
   83544      144224 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionParameterList );
   83545      144224 :           unsigned long positionInPool = localIndex % SgFunctionParameterList::pool_size;
   83546      144224 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionParameterList::pool_size;
   83547             : 
   83548             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   83549             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   83550             : 
   83551      144224 :           returnPointer = &( ( (SgFunctionParameterList*)(SgFunctionParameterList::pools[memoryBlock]) ) [positionInPool]) ;
   83552             : 
   83553      144224 :           ROSE_ASSERT( returnPointer != NULL ) ;
   83554             :         }
   83555      144224 :      return returnPointer ;
   83556             :    }
   83557             : 
   83558             : //############################################################################
   83559             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   83560             :   for the AST with the index astIndex
   83561             : */
   83562           0 : SgFunctionParameterList * SgFunctionParameterList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   83563           0 :      SgFunctionParameterList* returnPointer = NULL;
   83564           0 :      if ( globalIndex != 0 )
   83565             :         {
   83566             : 
   83567             : #if FILE_IO_EXTRA_CHECK
   83568           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionParameterList ) ) <= globalIndex ) ;
   83569           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionParameterList + 1 ) ) );
   83570             : #endif
   83571           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionParameterList )
   83572           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionParameterList );
   83573           0 :           unsigned long positionInPool = localIndex % SgFunctionParameterList::pool_size ;
   83574           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionParameterList::pool_size ;
   83575             : 
   83576             : #if FILE_IO_EXTRA_CHECK
   83577             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   83578             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   83579             : #endif
   83580             : 
   83581           0 :           returnPointer = &( ( (SgFunctionParameterList*)(SgFunctionParameterList::pools[memoryBlock]) ) [positionInPool]) ;
   83582             : 
   83583             : #if FILE_IO_EXTRA_CHECK
   83584           0 :           assert ( returnPointer != NULL ) ;
   83585             : #endif
   83586             :         }
   83587           0 :      return returnPointer ;
   83588             :    }
   83589             : 
   83590             : //############################################################################
   83591             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   83592             :  * pool size! We set for every valid object in the memory pool the freepointer
   83593             :  * to the global index and increase the global index afterwards. For all the 
   83594             :  * invalid objects (means address ranges within the memory pool that were not
   83595             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   83596             :  * distinguish valid from invalid objects! 
   83597             :  */
   83598             : unsigned long
   83599           5 : SgFunctionParameterList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   83600             :    {
   83601           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   83602           5 :      SgFunctionParameterList* pointer = NULL;
   83603           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   83604           5 :      std::vector < unsigned char* > :: const_iterator block;
   83605          19 :      for ( block = SgFunctionParameterList::pools.begin(); block != SgFunctionParameterList::pools.end() ; ++block )
   83606             :         {
   83607          14 :           pointer = (SgFunctionParameterList*)(*block);
   83608       28014 :           for (unsigned i = 0; i < SgFunctionParameterList::pool_size; ++i )
   83609             :              {
   83610             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   83611             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   83612             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   83613             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   83614             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   83615             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   83616             :             // properly; so this will have to be checked next.
   83617             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   83618             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   83619       28000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   83620             :                   {
   83621       22768 :                     pointer[i].set_freepointer((SgFunctionParameterList*)(globalIndex));
   83622       22768 :                     globalIndex++;
   83623             :                   }
   83624             :                else
   83625             :                   {
   83626        5232 :                     pointer[i].set_freepointer(NULL);
   83627             :                   }
   83628             :               }
   83629             :         }
   83630           5 :      return globalIndex;
   83631             :    }
   83632             : 
   83633             : //############################################################################
   83634             : // JH (01/14/2006)
   83635             : void
   83636           5 : SgFunctionParameterList::resetValidFreepointers( )
   83637             :    {
   83638           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   83639           5 :      SgFunctionParameterList* pointer = NULL;
   83640           5 :      std::vector < unsigned char* > :: const_iterator block;
   83641           5 :      SgFunctionParameterList* pointerOfLinkedList = NULL;
   83642          19 :      for ( block = SgFunctionParameterList::pools.begin(); block != SgFunctionParameterList::pools.end() ; ++block )
   83643             :         {
   83644          14 :           pointer = (SgFunctionParameterList*)(*block);
   83645       28014 :           for (unsigned i = 0; i < SgFunctionParameterList::pool_size; ++i )
   83646             :              {
   83647             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   83648             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   83649             :             // memory blocks!.
   83650       28000 :                if ( pointer[i].get_freepointer() != NULL )
   83651             :                   {
   83652       22768 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   83653             :                   }
   83654             :                else
   83655             :                   {
   83656        5232 :                     if ( pointerOfLinkedList == NULL )
   83657             :                        {
   83658           3 :                          SgFunctionParameterList::next_node = &(pointer[i]);
   83659             :                        }
   83660             :                     else
   83661             :                        {
   83662             :                       // printf ("In SgFunctionParameterList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   83663        5229 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   83664             :                        }
   83665             :                     pointerOfLinkedList = &(pointer[i]);
   83666             :                   }
   83667             :               }
   83668             :         }
   83669             : 
   83670           5 :      if ( pointerOfLinkedList != NULL )
   83671             :         {
   83672             :        // printf ("In SgFunctionParameterList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   83673           3 :           pointerOfLinkedList->set_freepointer(NULL);
   83674             :        // DQ (6/6/2010): Temporary debugging...
   83675             :        //   ROSE_ASSERT(false);
   83676             :         }
   83677             : 
   83678           5 :      return ;
   83679             :    }
   83680             : 
   83681             : //############################################################################
   83682             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   83683             :  * within the memory pool and resets the freepointers, in order to achieve a 
   83684             :  * linked list, that has no jumps and starts at the beginning! This function 
   83685             :  * does not extend the memory pool, since we do not delete any memory blocks,
   83686             :  * but delete the valid objects.  
   83687             :  */
   83688             : void
   83689           0 : SgFunctionParameterList::clearMemoryPool( )
   83690             :    {
   83691             :   // printf ("Inside of SgFunctionParameterList::clearMemoryPool() \n");
   83692             : 
   83693           0 :      SgFunctionParameterList* pointer = NULL, *tempPointer = NULL;
   83694           0 :      std::vector < unsigned char* > :: const_iterator block;
   83695           0 :      if ( SgFunctionParameterList::pools.empty() == false )
   83696             :         {
   83697           0 :           block = SgFunctionParameterList::pools.begin() ;
   83698           0 :           SgFunctionParameterList::next_node = (SgFunctionParameterList*) (*block);
   83699             : 
   83700           0 :           while ( block != SgFunctionParameterList::pools.end() )
   83701             :              {
   83702           0 :                pointer = (SgFunctionParameterList*) (*block);
   83703           0 :                if ( tempPointer != NULL )
   83704             :                   {
   83705           0 :                     tempPointer->set_freepointer(pointer);
   83706             :                   }
   83707           0 :                for (unsigned i = 0; i < SgFunctionParameterList::pool_size - 1; ++i)
   83708             :                   {
   83709           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   83710             :                   }
   83711           0 :                 pointer[SgFunctionParameterList::pool_size-1].set_freepointer(NULL);
   83712           0 :                 tempPointer = &(pointer[SgFunctionParameterList::pool_size-1]);
   83713           0 :                 ++block;
   83714             :              }
   83715             :         }
   83716           0 :    }
   83717             : 
   83718           5 : void SgFunctionParameterList::deleteMemoryPool() {
   83719          32 :   for (auto p: SgFunctionParameterList::pools) {
   83720          27 :     ROSE_FREE(p);
   83721             :   }
   83722           5 :   SgFunctionParameterList::next_node = nullptr;
   83723           5 :   SgFunctionParameterList::pools.clear();
   83724           5 : }
   83725             : 
   83726             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   83727             : //                 reading multiple binary files to for a single AST.
   83728             : /////////// new version ////////////////////////////////
   83729             : //############################################################################
   83730             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   83731             : void
   83732           2 : SgFunctionParameterList::extendMemoryPoolForFileIO( )
   83733             :   {
   83734           2 :     size_t blockIndex = SgFunctionParameterList::pools.size();
   83735           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterList);
   83736             : 
   83737          15 :     while ( (blockIndex * SgFunctionParameterList::pool_size) < newPoolSize)
   83738             :       {
   83739             : #if ROSE_ALLOC_TRACE
   83740             :         if (blockIndex > 0) {
   83741             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterList) = %" PRIuPTR " SgFunctionParameterList::pool_size = %d \n",
   83742             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterList),SgFunctionParameterList::pool_size);
   83743             :         }
   83744             : #endif
   83745             : 
   83746          13 :         SgFunctionParameterList * pointer = (SgFunctionParameterList*) ROSE_MALLOC ( SgFunctionParameterList::pool_size * sizeof(SgFunctionParameterList) );
   83747          13 :         assert( pointer != NULL );
   83748             : #if ROSE_ALLOC_MEMSET == 1
   83749             :         memset(pointer, 0x00, SgFunctionParameterList::pool_size * sizeof(SgFunctionParameterList));
   83750             : #elif ROSE_ALLOC_MEMSET == 2
   83751             :         memset(pointer, 0xCC, SgFunctionParameterList::pool_size * sizeof(SgFunctionParameterList));
   83752             : #endif
   83753          13 :         SgFunctionParameterList::pools.push_back( (unsigned char*)(pointer) );
   83754          13 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionParameterList::pool_size * sizeof(SgFunctionParameterList), V_SgFunctionParameterList ) );
   83755             : 
   83756          13 :         if ( SgFunctionParameterList::next_node != NULL ) {
   83757          11 :           if ( blockIndex > 0 ) {
   83758          11 :             SgFunctionParameterList * blkptr = (SgFunctionParameterList*)(SgFunctionParameterList::pools[blockIndex-1]);
   83759          11 :             blkptr[ SgFunctionParameterList::pool_size - 1 ].set_freepointer(pointer);
   83760             :           }
   83761             :         } else {
   83762           2 :           SgFunctionParameterList::next_node = pointer;
   83763             :         }
   83764             : 
   83765       26000 :         for (unsigned i = 0; i < SgFunctionParameterList::pool_size-1; ++i)
   83766             :            {
   83767       25987 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   83768             :            }
   83769          13 :         pointer[ SgFunctionParameterList::pool_size -1 ].set_freepointer(NULL);
   83770             : 
   83771          13 :         blockIndex++;
   83772             :       }
   83773           2 :   }
   83774             : 
   83775             : //############################################################################
   83776             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   83777             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   83778             :  * not compressed. However, that stuff is not yet implemented! 
   83779             :  */
   83780             : unsigned long
   83781           0 : SgFunctionParameterList::getNumberOfLastValidPointer()
   83782             :    {
   83783           0 :       SgFunctionParameterList* testPointer = (SgFunctionParameterList*)(SgFunctionParameterList::pools.back());
   83784           0 :       unsigned long localIndex = SgFunctionParameterList::pool_size - 1;
   83785           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   83786             :          {
   83787           0 :            localIndex--;
   83788             :          }
   83789           0 :       return (localIndex + SgFunctionParameterList::pool_size * (SgFunctionParameterList::pools.size()-1));
   83790             :    }
   83791             : 
   83792             : //############################################################################
   83793             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   83794             :  * memory pool and initializes the data member in class SgFunctionParameterListStroageClass
   83795             :  * from its counterpart of SgFunctionParameterList. The return value is just for checking, 
   83796             :  * that the whole StorageClassArray is initialized!
   83797             :  */
   83798             : unsigned long
   83799           3 : SgFunctionParameterList::initializeStorageClassArray( SgFunctionParameterListStorageClass *storageArray )
   83800             :    {
   83801           3 :      unsigned long storageCounter = 0;
   83802           3 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionParameterList::pools.begin();
   83803           3 :      SgFunctionParameterList* pointer = NULL;
   83804          17 :      while ( block != SgFunctionParameterList::pools.end() ) {
   83805          14 :           pointer = (SgFunctionParameterList*) (*block);
   83806       28014 :           for ( unsigned i = 0; i < SgFunctionParameterList::pool_size; ++i ) {
   83807       28000 :                if ( pointer->get_freepointer() != NULL ) {
   83808       22768 :                  storageArray->pickOutIRNodeData (pointer) ;
   83809       22768 :                  storageArray++;
   83810       22768 :                  storageCounter++;
   83811             :                }
   83812       28000 :                pointer++;
   83813             :              }
   83814          14 :            block++;
   83815             :         }
   83816           3 :      return storageCounter;
   83817             :    }
   83818             : 
   83819             : /* #line 83820 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   83820             : 
   83821             : 
   83822             : 
   83823             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   83824             : 
   83825             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   83826             : 
   83827             : //############################################################################
   83828             : /* JH (02/02/2006) Constructor of the IR node SgVariableDeclaration that takes its 
   83829             :  * corresponding StorageClass as parameter
   83830             :  */
   83831        1396 : SgVariableDeclaration :: SgVariableDeclaration ( const SgVariableDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   83832             :    {
   83833             : 
   83834             : 
   83835             : /* #line 83836 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   83836             : 
   83837        1396 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   83838        1396 :      p_baseTypeDefiningDeclaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_baseTypeDefiningDeclaration) );
   83839        1396 :      p_variables = storageSource.storageOf_variables.rebuildDataStoredInEasyStorageClass() ;
   83840        1396 :      SgInitializedNamePtrList::iterator i_variables = p_variables.begin() ; 
   83841        2792 :      for ( ; i_variables != p_variables.end(); ++i_variables ) 
   83842             :         {
   83843        1396 :           (*i_variables) = (SgInitializedNamePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_variables) ) );
   83844             :         }
   83845        1396 :      p_variableDeclarationContainsBaseTypeDefiningDeclaration = storageSource.storageOf_variableDeclarationContainsBaseTypeDefiningDeclaration ;
   83846        1396 :      p_specialization = storageSource.storageOf_specialization ;
   83847        1396 :      p_requiresGlobalNameQualificationOnType = storageSource.storageOf_requiresGlobalNameQualificationOnType ;
   83848        1396 :      p_gnu_extension_section = storageSource.storageOf_gnu_extension_section.rebuildDataStoredInEasyStorageClass() ;
   83849        1396 :      p_gnu_extension_alias = storageSource.storageOf_gnu_extension_alias.rebuildDataStoredInEasyStorageClass() ;
   83850        1396 :      p_gnu_extension_initialization_priority = storageSource.storageOf_gnu_extension_initialization_priority ;
   83851        1396 :      p_gnu_extension_visability = storageSource.storageOf_gnu_extension_visability ;
   83852        1396 :      p_gnu_extension_declaration_attribute = storageSource.storageOf_gnu_extension_declaration_attribute ;
   83853        1396 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   83854        1396 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   83855        1396 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   83856        1396 :      p_isAssociatedWithDeclarationList = storageSource.storageOf_isAssociatedWithDeclarationList ;
   83857        1396 :      p_isFirstDeclarationOfDeclarationList = storageSource.storageOf_isFirstDeclarationOfDeclarationList ;
   83858        1396 :      p_is_thread_local = storageSource.storageOf_is_thread_local ;
   83859        1396 :      p_is_constexpr = storageSource.storageOf_is_constexpr ;
   83860        1396 :      p_builtFromUseOnly = storageSource.storageOf_builtFromUseOnly ;
   83861             : 
   83862             : 
   83863             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   83864             : 
   83865             : 
   83866        1396 :    }
   83867             : 
   83868             : //############################################################################
   83869             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   83870             :  * within the working AST. 
   83871             :  */
   83872        6505 : SgVariableDeclaration * SgVariableDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   83873        6505 :      SgVariableDeclaration* returnPointer = NULL;
   83874        6505 :      if ( globalIndex != 0 )
   83875             :         {
   83876             : 
   83877             : #if FILE_IO_EXTRA_CHECK
   83878        6505 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVariableDeclaration ) ) <= globalIndex ) ;
   83879        6505 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariableDeclaration + 1 ) ) );
   83880             : #endif
   83881        6505 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariableDeclaration )  
   83882        6505 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVariableDeclaration );
   83883        6505 :           unsigned long positionInPool = localIndex % SgVariableDeclaration::pool_size;
   83884        6505 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariableDeclaration::pool_size;
   83885             : 
   83886             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   83887             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   83888             : 
   83889        6505 :           returnPointer = &( ( (SgVariableDeclaration*)(SgVariableDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   83890             : 
   83891        6505 :           ROSE_ASSERT( returnPointer != NULL ) ;
   83892             :         }
   83893        6505 :      return returnPointer ;
   83894             :    }
   83895             : 
   83896             : //############################################################################
   83897             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   83898             :   for the AST with the index astIndex
   83899             : */
   83900           0 : SgVariableDeclaration * SgVariableDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   83901           0 :      SgVariableDeclaration* returnPointer = NULL;
   83902           0 :      if ( globalIndex != 0 )
   83903             :         {
   83904             : 
   83905             : #if FILE_IO_EXTRA_CHECK
   83906           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVariableDeclaration ) ) <= globalIndex ) ;
   83907           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariableDeclaration + 1 ) ) );
   83908             : #endif
   83909           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariableDeclaration )
   83910           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVariableDeclaration );
   83911           0 :           unsigned long positionInPool = localIndex % SgVariableDeclaration::pool_size ;
   83912           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariableDeclaration::pool_size ;
   83913             : 
   83914             : #if FILE_IO_EXTRA_CHECK
   83915             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   83916             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   83917             : #endif
   83918             : 
   83919           0 :           returnPointer = &( ( (SgVariableDeclaration*)(SgVariableDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   83920             : 
   83921             : #if FILE_IO_EXTRA_CHECK
   83922           0 :           assert ( returnPointer != NULL ) ;
   83923             : #endif
   83924             :         }
   83925           0 :      return returnPointer ;
   83926             :    }
   83927             : 
   83928             : //############################################################################
   83929             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   83930             :  * pool size! We set for every valid object in the memory pool the freepointer
   83931             :  * to the global index and increase the global index afterwards. For all the 
   83932             :  * invalid objects (means address ranges within the memory pool that were not
   83933             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   83934             :  * distinguish valid from invalid objects! 
   83935             :  */
   83936             : unsigned long
   83937           5 : SgVariableDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   83938             :    {
   83939           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   83940           5 :      SgVariableDeclaration* pointer = NULL;
   83941           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   83942           5 :      std::vector < unsigned char* > :: const_iterator block;
   83943           7 :      for ( block = SgVariableDeclaration::pools.begin(); block != SgVariableDeclaration::pools.end() ; ++block )
   83944             :         {
   83945           2 :           pointer = (SgVariableDeclaration*)(*block);
   83946        4002 :           for (unsigned i = 0; i < SgVariableDeclaration::pool_size; ++i )
   83947             :              {
   83948             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   83949             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   83950             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   83951             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   83952             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   83953             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   83954             :             // properly; so this will have to be checked next.
   83955             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   83956             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   83957        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   83958             :                   {
   83959        1294 :                     pointer[i].set_freepointer((SgVariableDeclaration*)(globalIndex));
   83960        1294 :                     globalIndex++;
   83961             :                   }
   83962             :                else
   83963             :                   {
   83964        2706 :                     pointer[i].set_freepointer(NULL);
   83965             :                   }
   83966             :               }
   83967             :         }
   83968           5 :      return globalIndex;
   83969             :    }
   83970             : 
   83971             : //############################################################################
   83972             : // JH (01/14/2006)
   83973             : void
   83974           5 : SgVariableDeclaration::resetValidFreepointers( )
   83975             :    {
   83976           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   83977           5 :      SgVariableDeclaration* pointer = NULL;
   83978           5 :      std::vector < unsigned char* > :: const_iterator block;
   83979           5 :      SgVariableDeclaration* pointerOfLinkedList = NULL;
   83980           7 :      for ( block = SgVariableDeclaration::pools.begin(); block != SgVariableDeclaration::pools.end() ; ++block )
   83981             :         {
   83982           2 :           pointer = (SgVariableDeclaration*)(*block);
   83983        4002 :           for (unsigned i = 0; i < SgVariableDeclaration::pool_size; ++i )
   83984             :              {
   83985             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   83986             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   83987             :             // memory blocks!.
   83988        4000 :                if ( pointer[i].get_freepointer() != NULL )
   83989             :                   {
   83990        1294 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   83991             :                   }
   83992             :                else
   83993             :                   {
   83994        2706 :                     if ( pointerOfLinkedList == NULL )
   83995             :                        {
   83996           2 :                          SgVariableDeclaration::next_node = &(pointer[i]);
   83997             :                        }
   83998             :                     else
   83999             :                        {
   84000             :                       // printf ("In SgVariableDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   84001        2704 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   84002             :                        }
   84003             :                     pointerOfLinkedList = &(pointer[i]);
   84004             :                   }
   84005             :               }
   84006             :         }
   84007             : 
   84008           5 :      if ( pointerOfLinkedList != NULL )
   84009             :         {
   84010             :        // printf ("In SgVariableDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   84011           2 :           pointerOfLinkedList->set_freepointer(NULL);
   84012             :        // DQ (6/6/2010): Temporary debugging...
   84013             :        //   ROSE_ASSERT(false);
   84014             :         }
   84015             : 
   84016           5 :      return ;
   84017             :    }
   84018             : 
   84019             : //############################################################################
   84020             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   84021             :  * within the memory pool and resets the freepointers, in order to achieve a 
   84022             :  * linked list, that has no jumps and starts at the beginning! This function 
   84023             :  * does not extend the memory pool, since we do not delete any memory blocks,
   84024             :  * but delete the valid objects.  
   84025             :  */
   84026             : void
   84027           0 : SgVariableDeclaration::clearMemoryPool( )
   84028             :    {
   84029             :   // printf ("Inside of SgVariableDeclaration::clearMemoryPool() \n");
   84030             : 
   84031           0 :      SgVariableDeclaration* pointer = NULL, *tempPointer = NULL;
   84032           0 :      std::vector < unsigned char* > :: const_iterator block;
   84033           0 :      if ( SgVariableDeclaration::pools.empty() == false )
   84034             :         {
   84035           0 :           block = SgVariableDeclaration::pools.begin() ;
   84036           0 :           SgVariableDeclaration::next_node = (SgVariableDeclaration*) (*block);
   84037             : 
   84038           0 :           while ( block != SgVariableDeclaration::pools.end() )
   84039             :              {
   84040           0 :                pointer = (SgVariableDeclaration*) (*block);
   84041           0 :                if ( tempPointer != NULL )
   84042             :                   {
   84043           0 :                     tempPointer->set_freepointer(pointer);
   84044             :                   }
   84045           0 :                for (unsigned i = 0; i < SgVariableDeclaration::pool_size - 1; ++i)
   84046             :                   {
   84047           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   84048             :                   }
   84049           0 :                 pointer[SgVariableDeclaration::pool_size-1].set_freepointer(NULL);
   84050           0 :                 tempPointer = &(pointer[SgVariableDeclaration::pool_size-1]);
   84051           0 :                 ++block;
   84052             :              }
   84053             :         }
   84054           0 :    }
   84055             : 
   84056           5 : void SgVariableDeclaration::deleteMemoryPool() {
   84057           9 :   for (auto p: SgVariableDeclaration::pools) {
   84058           4 :     ROSE_FREE(p);
   84059             :   }
   84060           5 :   SgVariableDeclaration::next_node = nullptr;
   84061           5 :   SgVariableDeclaration::pools.clear();
   84062           5 : }
   84063             : 
   84064             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   84065             : //                 reading multiple binary files to for a single AST.
   84066             : /////////// new version ////////////////////////////////
   84067             : //############################################################################
   84068             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   84069             : void
   84070           2 : SgVariableDeclaration::extendMemoryPoolForFileIO( )
   84071             :   {
   84072           2 :     size_t blockIndex = SgVariableDeclaration::pools.size();
   84073           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableDeclaration);
   84074             : 
   84075           4 :     while ( (blockIndex * SgVariableDeclaration::pool_size) < newPoolSize)
   84076             :       {
   84077             : #if ROSE_ALLOC_TRACE
   84078             :         if (blockIndex > 0) {
   84079             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableDeclaration) = %" PRIuPTR " SgVariableDeclaration::pool_size = %d \n",
   84080             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableDeclaration),SgVariableDeclaration::pool_size);
   84081             :         }
   84082             : #endif
   84083             : 
   84084           2 :         SgVariableDeclaration * pointer = (SgVariableDeclaration*) ROSE_MALLOC ( SgVariableDeclaration::pool_size * sizeof(SgVariableDeclaration) );
   84085           2 :         assert( pointer != NULL );
   84086             : #if ROSE_ALLOC_MEMSET == 1
   84087             :         memset(pointer, 0x00, SgVariableDeclaration::pool_size * sizeof(SgVariableDeclaration));
   84088             : #elif ROSE_ALLOC_MEMSET == 2
   84089             :         memset(pointer, 0xCC, SgVariableDeclaration::pool_size * sizeof(SgVariableDeclaration));
   84090             : #endif
   84091           2 :         SgVariableDeclaration::pools.push_back( (unsigned char*)(pointer) );
   84092           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVariableDeclaration::pool_size * sizeof(SgVariableDeclaration), V_SgVariableDeclaration ) );
   84093             : 
   84094           2 :         if ( SgVariableDeclaration::next_node != NULL ) {
   84095           0 :           if ( blockIndex > 0 ) {
   84096           0 :             SgVariableDeclaration * blkptr = (SgVariableDeclaration*)(SgVariableDeclaration::pools[blockIndex-1]);
   84097           0 :             blkptr[ SgVariableDeclaration::pool_size - 1 ].set_freepointer(pointer);
   84098             :           }
   84099             :         } else {
   84100           2 :           SgVariableDeclaration::next_node = pointer;
   84101             :         }
   84102             : 
   84103        4000 :         for (unsigned i = 0; i < SgVariableDeclaration::pool_size-1; ++i)
   84104             :            {
   84105        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   84106             :            }
   84107           2 :         pointer[ SgVariableDeclaration::pool_size -1 ].set_freepointer(NULL);
   84108             : 
   84109           2 :         blockIndex++;
   84110             :       }
   84111           2 :   }
   84112             : 
   84113             : //############################################################################
   84114             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   84115             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   84116             :  * not compressed. However, that stuff is not yet implemented! 
   84117             :  */
   84118             : unsigned long
   84119           0 : SgVariableDeclaration::getNumberOfLastValidPointer()
   84120             :    {
   84121           0 :       SgVariableDeclaration* testPointer = (SgVariableDeclaration*)(SgVariableDeclaration::pools.back());
   84122           0 :       unsigned long localIndex = SgVariableDeclaration::pool_size - 1;
   84123           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   84124             :          {
   84125           0 :            localIndex--;
   84126             :          }
   84127           0 :       return (localIndex + SgVariableDeclaration::pool_size * (SgVariableDeclaration::pools.size()-1));
   84128             :    }
   84129             : 
   84130             : //############################################################################
   84131             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   84132             :  * memory pool and initializes the data member in class SgVariableDeclarationStroageClass
   84133             :  * from its counterpart of SgVariableDeclaration. The return value is just for checking, 
   84134             :  * that the whole StorageClassArray is initialized!
   84135             :  */
   84136             : unsigned long
   84137           2 : SgVariableDeclaration::initializeStorageClassArray( SgVariableDeclarationStorageClass *storageArray )
   84138             :    {
   84139           2 :      unsigned long storageCounter = 0;
   84140           2 :      std::vector < unsigned char* > :: const_iterator block = SgVariableDeclaration::pools.begin();
   84141           2 :      SgVariableDeclaration* pointer = NULL;
   84142           4 :      while ( block != SgVariableDeclaration::pools.end() ) {
   84143           2 :           pointer = (SgVariableDeclaration*) (*block);
   84144        4002 :           for ( unsigned i = 0; i < SgVariableDeclaration::pool_size; ++i ) {
   84145        4000 :                if ( pointer->get_freepointer() != NULL ) {
   84146        1294 :                  storageArray->pickOutIRNodeData (pointer) ;
   84147        1294 :                  storageArray++;
   84148        1294 :                  storageCounter++;
   84149             :                }
   84150        4000 :                pointer++;
   84151             :              }
   84152           2 :            block++;
   84153             :         }
   84154           2 :      return storageCounter;
   84155             :    }
   84156             : 
   84157             : /* #line 84158 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   84158             : 
   84159             : 
   84160             : 
   84161             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   84162             : 
   84163             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   84164             : 
   84165             : //############################################################################
   84166             : /* JH (02/02/2006) Constructor of the IR node SgTemplateVariableDeclaration that takes its 
   84167             :  * corresponding StorageClass as parameter
   84168             :  */
   84169         102 : SgTemplateVariableDeclaration :: SgTemplateVariableDeclaration ( const SgTemplateVariableDeclarationStorageClass& storageSource )   : SgVariableDeclaration (storageSource)
   84170             :    {
   84171             : 
   84172             : 
   84173             : /* #line 84174 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   84174             : 
   84175         102 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   84176         102 :      p_templateParameters = storageSource.storageOf_templateParameters.rebuildDataStoredInEasyStorageClass() ;
   84177         102 :      SgTemplateParameterPtrList::iterator i_templateParameters = p_templateParameters.begin() ; 
   84178         130 :      for ( ; i_templateParameters != p_templateParameters.end(); ++i_templateParameters ) 
   84179             :         {
   84180          28 :           (*i_templateParameters) = (SgTemplateParameterPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateParameters) ) );
   84181             :         }
   84182         102 :      p_templateSpecializationArguments = storageSource.storageOf_templateSpecializationArguments.rebuildDataStoredInEasyStorageClass() ;
   84183         102 :      SgTemplateArgumentPtrList::iterator i_templateSpecializationArguments = p_templateSpecializationArguments.begin() ; 
   84184         102 :      for ( ; i_templateSpecializationArguments != p_templateSpecializationArguments.end(); ++i_templateSpecializationArguments ) 
   84185             :         {
   84186           0 :           (*i_templateSpecializationArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateSpecializationArguments) ) );
   84187             :         }
   84188         102 :      p_string = SgName ( storageSource.storageOf_string ) ;
   84189         102 :      p_nonreal_decl_scope =  (SgDeclarationScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nonreal_decl_scope) );
   84190             : 
   84191             : 
   84192             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   84193             : 
   84194             : 
   84195         102 :    }
   84196             : 
   84197             : //############################################################################
   84198             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   84199             :  * within the working AST. 
   84200             :  */
   84201         558 : SgTemplateVariableDeclaration * SgTemplateVariableDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   84202         558 :      SgTemplateVariableDeclaration* returnPointer = NULL;
   84203         558 :      if ( globalIndex != 0 )
   84204             :         {
   84205             : 
   84206             : #if FILE_IO_EXTRA_CHECK
   84207         558 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateVariableDeclaration ) ) <= globalIndex ) ;
   84208         558 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateVariableDeclaration + 1 ) ) );
   84209             : #endif
   84210         558 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateVariableDeclaration )  
   84211         558 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateVariableDeclaration );
   84212         558 :           unsigned long positionInPool = localIndex % SgTemplateVariableDeclaration::pool_size;
   84213         558 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateVariableDeclaration::pool_size;
   84214             : 
   84215             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   84216             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   84217             : 
   84218         558 :           returnPointer = &( ( (SgTemplateVariableDeclaration*)(SgTemplateVariableDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   84219             : 
   84220         558 :           ROSE_ASSERT( returnPointer != NULL ) ;
   84221             :         }
   84222         558 :      return returnPointer ;
   84223             :    }
   84224             : 
   84225             : //############################################################################
   84226             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   84227             :   for the AST with the index astIndex
   84228             : */
   84229           0 : SgTemplateVariableDeclaration * SgTemplateVariableDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   84230           0 :      SgTemplateVariableDeclaration* returnPointer = NULL;
   84231           0 :      if ( globalIndex != 0 )
   84232             :         {
   84233             : 
   84234             : #if FILE_IO_EXTRA_CHECK
   84235           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateVariableDeclaration ) ) <= globalIndex ) ;
   84236           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateVariableDeclaration + 1 ) ) );
   84237             : #endif
   84238           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateVariableDeclaration )
   84239           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateVariableDeclaration );
   84240           0 :           unsigned long positionInPool = localIndex % SgTemplateVariableDeclaration::pool_size ;
   84241           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateVariableDeclaration::pool_size ;
   84242             : 
   84243             : #if FILE_IO_EXTRA_CHECK
   84244             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   84245             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   84246             : #endif
   84247             : 
   84248           0 :           returnPointer = &( ( (SgTemplateVariableDeclaration*)(SgTemplateVariableDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   84249             : 
   84250             : #if FILE_IO_EXTRA_CHECK
   84251           0 :           assert ( returnPointer != NULL ) ;
   84252             : #endif
   84253             :         }
   84254           0 :      return returnPointer ;
   84255             :    }
   84256             : 
   84257             : //############################################################################
   84258             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   84259             :  * pool size! We set for every valid object in the memory pool the freepointer
   84260             :  * to the global index and increase the global index afterwards. For all the 
   84261             :  * invalid objects (means address ranges within the memory pool that were not
   84262             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   84263             :  * distinguish valid from invalid objects! 
   84264             :  */
   84265             : unsigned long
   84266           5 : SgTemplateVariableDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   84267             :    {
   84268           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   84269           5 :      SgTemplateVariableDeclaration* pointer = NULL;
   84270           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   84271           5 :      std::vector < unsigned char* > :: const_iterator block;
   84272           6 :      for ( block = SgTemplateVariableDeclaration::pools.begin(); block != SgTemplateVariableDeclaration::pools.end() ; ++block )
   84273             :         {
   84274           1 :           pointer = (SgTemplateVariableDeclaration*)(*block);
   84275        2001 :           for (unsigned i = 0; i < SgTemplateVariableDeclaration::pool_size; ++i )
   84276             :              {
   84277             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   84278             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   84279             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   84280             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   84281             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   84282             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   84283             :             // properly; so this will have to be checked next.
   84284             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   84285             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   84286        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   84287             :                   {
   84288         102 :                     pointer[i].set_freepointer((SgTemplateVariableDeclaration*)(globalIndex));
   84289         102 :                     globalIndex++;
   84290             :                   }
   84291             :                else
   84292             :                   {
   84293        1898 :                     pointer[i].set_freepointer(NULL);
   84294             :                   }
   84295             :               }
   84296             :         }
   84297           5 :      return globalIndex;
   84298             :    }
   84299             : 
   84300             : //############################################################################
   84301             : // JH (01/14/2006)
   84302             : void
   84303           5 : SgTemplateVariableDeclaration::resetValidFreepointers( )
   84304             :    {
   84305           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   84306           5 :      SgTemplateVariableDeclaration* pointer = NULL;
   84307           5 :      std::vector < unsigned char* > :: const_iterator block;
   84308           5 :      SgTemplateVariableDeclaration* pointerOfLinkedList = NULL;
   84309           6 :      for ( block = SgTemplateVariableDeclaration::pools.begin(); block != SgTemplateVariableDeclaration::pools.end() ; ++block )
   84310             :         {
   84311           1 :           pointer = (SgTemplateVariableDeclaration*)(*block);
   84312        2001 :           for (unsigned i = 0; i < SgTemplateVariableDeclaration::pool_size; ++i )
   84313             :              {
   84314             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   84315             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   84316             :             // memory blocks!.
   84317        2000 :                if ( pointer[i].get_freepointer() != NULL )
   84318             :                   {
   84319         102 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   84320             :                   }
   84321             :                else
   84322             :                   {
   84323        1898 :                     if ( pointerOfLinkedList == NULL )
   84324             :                        {
   84325           1 :                          SgTemplateVariableDeclaration::next_node = &(pointer[i]);
   84326             :                        }
   84327             :                     else
   84328             :                        {
   84329             :                       // printf ("In SgTemplateVariableDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   84330        1897 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   84331             :                        }
   84332             :                     pointerOfLinkedList = &(pointer[i]);
   84333             :                   }
   84334             :               }
   84335             :         }
   84336             : 
   84337           5 :      if ( pointerOfLinkedList != NULL )
   84338             :         {
   84339             :        // printf ("In SgTemplateVariableDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   84340           1 :           pointerOfLinkedList->set_freepointer(NULL);
   84341             :        // DQ (6/6/2010): Temporary debugging...
   84342             :        //   ROSE_ASSERT(false);
   84343             :         }
   84344             : 
   84345           5 :      return ;
   84346             :    }
   84347             : 
   84348             : //############################################################################
   84349             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   84350             :  * within the memory pool and resets the freepointers, in order to achieve a 
   84351             :  * linked list, that has no jumps and starts at the beginning! This function 
   84352             :  * does not extend the memory pool, since we do not delete any memory blocks,
   84353             :  * but delete the valid objects.  
   84354             :  */
   84355             : void
   84356           0 : SgTemplateVariableDeclaration::clearMemoryPool( )
   84357             :    {
   84358             :   // printf ("Inside of SgTemplateVariableDeclaration::clearMemoryPool() \n");
   84359             : 
   84360           0 :      SgTemplateVariableDeclaration* pointer = NULL, *tempPointer = NULL;
   84361           0 :      std::vector < unsigned char* > :: const_iterator block;
   84362           0 :      if ( SgTemplateVariableDeclaration::pools.empty() == false )
   84363             :         {
   84364           0 :           block = SgTemplateVariableDeclaration::pools.begin() ;
   84365           0 :           SgTemplateVariableDeclaration::next_node = (SgTemplateVariableDeclaration*) (*block);
   84366             : 
   84367           0 :           while ( block != SgTemplateVariableDeclaration::pools.end() )
   84368             :              {
   84369           0 :                pointer = (SgTemplateVariableDeclaration*) (*block);
   84370           0 :                if ( tempPointer != NULL )
   84371             :                   {
   84372           0 :                     tempPointer->set_freepointer(pointer);
   84373             :                   }
   84374           0 :                for (unsigned i = 0; i < SgTemplateVariableDeclaration::pool_size - 1; ++i)
   84375             :                   {
   84376           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   84377             :                   }
   84378           0 :                 pointer[SgTemplateVariableDeclaration::pool_size-1].set_freepointer(NULL);
   84379           0 :                 tempPointer = &(pointer[SgTemplateVariableDeclaration::pool_size-1]);
   84380           0 :                 ++block;
   84381             :              }
   84382             :         }
   84383           0 :    }
   84384             : 
   84385           5 : void SgTemplateVariableDeclaration::deleteMemoryPool() {
   84386           7 :   for (auto p: SgTemplateVariableDeclaration::pools) {
   84387           2 :     ROSE_FREE(p);
   84388             :   }
   84389           5 :   SgTemplateVariableDeclaration::next_node = nullptr;
   84390           5 :   SgTemplateVariableDeclaration::pools.clear();
   84391           5 : }
   84392             : 
   84393             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   84394             : //                 reading multiple binary files to for a single AST.
   84395             : /////////// new version ////////////////////////////////
   84396             : //############################################################################
   84397             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   84398             : void
   84399           2 : SgTemplateVariableDeclaration::extendMemoryPoolForFileIO( )
   84400             :   {
   84401           2 :     size_t blockIndex = SgTemplateVariableDeclaration::pools.size();
   84402           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateVariableDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateVariableDeclaration);
   84403             : 
   84404           3 :     while ( (blockIndex * SgTemplateVariableDeclaration::pool_size) < newPoolSize)
   84405             :       {
   84406             : #if ROSE_ALLOC_TRACE
   84407             :         if (blockIndex > 0) {
   84408             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateVariableDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateVariableDeclaration) = %" PRIuPTR " SgTemplateVariableDeclaration::pool_size = %d \n",
   84409             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateVariableDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateVariableDeclaration),SgTemplateVariableDeclaration::pool_size);
   84410             :         }
   84411             : #endif
   84412             : 
   84413           1 :         SgTemplateVariableDeclaration * pointer = (SgTemplateVariableDeclaration*) ROSE_MALLOC ( SgTemplateVariableDeclaration::pool_size * sizeof(SgTemplateVariableDeclaration) );
   84414           1 :         assert( pointer != NULL );
   84415             : #if ROSE_ALLOC_MEMSET == 1
   84416             :         memset(pointer, 0x00, SgTemplateVariableDeclaration::pool_size * sizeof(SgTemplateVariableDeclaration));
   84417             : #elif ROSE_ALLOC_MEMSET == 2
   84418             :         memset(pointer, 0xCC, SgTemplateVariableDeclaration::pool_size * sizeof(SgTemplateVariableDeclaration));
   84419             : #endif
   84420           1 :         SgTemplateVariableDeclaration::pools.push_back( (unsigned char*)(pointer) );
   84421           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateVariableDeclaration::pool_size * sizeof(SgTemplateVariableDeclaration), V_SgTemplateVariableDeclaration ) );
   84422             : 
   84423           1 :         if ( SgTemplateVariableDeclaration::next_node != NULL ) {
   84424           0 :           if ( blockIndex > 0 ) {
   84425           0 :             SgTemplateVariableDeclaration * blkptr = (SgTemplateVariableDeclaration*)(SgTemplateVariableDeclaration::pools[blockIndex-1]);
   84426           0 :             blkptr[ SgTemplateVariableDeclaration::pool_size - 1 ].set_freepointer(pointer);
   84427             :           }
   84428             :         } else {
   84429           1 :           SgTemplateVariableDeclaration::next_node = pointer;
   84430             :         }
   84431             : 
   84432        2000 :         for (unsigned i = 0; i < SgTemplateVariableDeclaration::pool_size-1; ++i)
   84433             :            {
   84434        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   84435             :            }
   84436           1 :         pointer[ SgTemplateVariableDeclaration::pool_size -1 ].set_freepointer(NULL);
   84437             : 
   84438           1 :         blockIndex++;
   84439             :       }
   84440           2 :   }
   84441             : 
   84442             : //############################################################################
   84443             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   84444             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   84445             :  * not compressed. However, that stuff is not yet implemented! 
   84446             :  */
   84447             : unsigned long
   84448           0 : SgTemplateVariableDeclaration::getNumberOfLastValidPointer()
   84449             :    {
   84450           0 :       SgTemplateVariableDeclaration* testPointer = (SgTemplateVariableDeclaration*)(SgTemplateVariableDeclaration::pools.back());
   84451           0 :       unsigned long localIndex = SgTemplateVariableDeclaration::pool_size - 1;
   84452           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   84453             :          {
   84454           0 :            localIndex--;
   84455             :          }
   84456           0 :       return (localIndex + SgTemplateVariableDeclaration::pool_size * (SgTemplateVariableDeclaration::pools.size()-1));
   84457             :    }
   84458             : 
   84459             : //############################################################################
   84460             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   84461             :  * memory pool and initializes the data member in class SgTemplateVariableDeclarationStroageClass
   84462             :  * from its counterpart of SgTemplateVariableDeclaration. The return value is just for checking, 
   84463             :  * that the whole StorageClassArray is initialized!
   84464             :  */
   84465             : unsigned long
   84466           1 : SgTemplateVariableDeclaration::initializeStorageClassArray( SgTemplateVariableDeclarationStorageClass *storageArray )
   84467             :    {
   84468           1 :      unsigned long storageCounter = 0;
   84469           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateVariableDeclaration::pools.begin();
   84470           1 :      SgTemplateVariableDeclaration* pointer = NULL;
   84471           2 :      while ( block != SgTemplateVariableDeclaration::pools.end() ) {
   84472           1 :           pointer = (SgTemplateVariableDeclaration*) (*block);
   84473        2001 :           for ( unsigned i = 0; i < SgTemplateVariableDeclaration::pool_size; ++i ) {
   84474        2000 :                if ( pointer->get_freepointer() != NULL ) {
   84475         102 :                  storageArray->pickOutIRNodeData (pointer) ;
   84476         102 :                  storageArray++;
   84477         102 :                  storageCounter++;
   84478             :                }
   84479        2000 :                pointer++;
   84480             :              }
   84481           1 :            block++;
   84482             :         }
   84483           1 :      return storageCounter;
   84484             :    }
   84485             : 
   84486             : /* #line 84487 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   84487             : 
   84488             : 
   84489             : 
   84490             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   84491             : 
   84492             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   84493             : 
   84494             : //############################################################################
   84495             : /* JH (02/02/2006) Constructor of the IR node SgVariableDefinition that takes its 
   84496             :  * corresponding StorageClass as parameter
   84497             :  */
   84498        1396 : SgVariableDefinition :: SgVariableDefinition ( const SgVariableDefinitionStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   84499             :    {
   84500             : 
   84501             : 
   84502             : /* #line 84503 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   84503             : 
   84504        1396 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   84505        1396 :      p_vardefn =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_vardefn) );
   84506        1396 :      p_bitfield =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_bitfield) );
   84507             : 
   84508             : 
   84509             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   84510             : 
   84511             : 
   84512        1396 :    }
   84513             : 
   84514             : //############################################################################
   84515             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   84516             :  * within the working AST. 
   84517             :  */
   84518        4188 : SgVariableDefinition * SgVariableDefinition::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   84519        4188 :      SgVariableDefinition* returnPointer = NULL;
   84520        4188 :      if ( globalIndex != 0 )
   84521             :         {
   84522             : 
   84523             : #if FILE_IO_EXTRA_CHECK
   84524        4188 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVariableDefinition ) ) <= globalIndex ) ;
   84525        4188 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariableDefinition + 1 ) ) );
   84526             : #endif
   84527        4188 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariableDefinition )  
   84528        4188 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVariableDefinition );
   84529        4188 :           unsigned long positionInPool = localIndex % SgVariableDefinition::pool_size;
   84530        4188 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariableDefinition::pool_size;
   84531             : 
   84532             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   84533             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   84534             : 
   84535        4188 :           returnPointer = &( ( (SgVariableDefinition*)(SgVariableDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   84536             : 
   84537        4188 :           ROSE_ASSERT( returnPointer != NULL ) ;
   84538             :         }
   84539        4188 :      return returnPointer ;
   84540             :    }
   84541             : 
   84542             : //############################################################################
   84543             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   84544             :   for the AST with the index astIndex
   84545             : */
   84546           0 : SgVariableDefinition * SgVariableDefinition::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   84547           0 :      SgVariableDefinition* returnPointer = NULL;
   84548           0 :      if ( globalIndex != 0 )
   84549             :         {
   84550             : 
   84551             : #if FILE_IO_EXTRA_CHECK
   84552           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVariableDefinition ) ) <= globalIndex ) ;
   84553           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariableDefinition + 1 ) ) );
   84554             : #endif
   84555           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariableDefinition )
   84556           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVariableDefinition );
   84557           0 :           unsigned long positionInPool = localIndex % SgVariableDefinition::pool_size ;
   84558           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariableDefinition::pool_size ;
   84559             : 
   84560             : #if FILE_IO_EXTRA_CHECK
   84561             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   84562             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   84563             : #endif
   84564             : 
   84565           0 :           returnPointer = &( ( (SgVariableDefinition*)(SgVariableDefinition::pools[memoryBlock]) ) [positionInPool]) ;
   84566             : 
   84567             : #if FILE_IO_EXTRA_CHECK
   84568           0 :           assert ( returnPointer != NULL ) ;
   84569             : #endif
   84570             :         }
   84571           0 :      return returnPointer ;
   84572             :    }
   84573             : 
   84574             : //############################################################################
   84575             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   84576             :  * pool size! We set for every valid object in the memory pool the freepointer
   84577             :  * to the global index and increase the global index afterwards. For all the 
   84578             :  * invalid objects (means address ranges within the memory pool that were not
   84579             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   84580             :  * distinguish valid from invalid objects! 
   84581             :  */
   84582             : unsigned long
   84583           5 : SgVariableDefinition::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   84584             :    {
   84585           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   84586           5 :      SgVariableDefinition* pointer = NULL;
   84587           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   84588           5 :      std::vector < unsigned char* > :: const_iterator block;
   84589           7 :      for ( block = SgVariableDefinition::pools.begin(); block != SgVariableDefinition::pools.end() ; ++block )
   84590             :         {
   84591           2 :           pointer = (SgVariableDefinition*)(*block);
   84592        4002 :           for (unsigned i = 0; i < SgVariableDefinition::pool_size; ++i )
   84593             :              {
   84594             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   84595             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   84596             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   84597             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   84598             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   84599             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   84600             :             // properly; so this will have to be checked next.
   84601             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   84602             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   84603        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   84604             :                   {
   84605        1396 :                     pointer[i].set_freepointer((SgVariableDefinition*)(globalIndex));
   84606        1396 :                     globalIndex++;
   84607             :                   }
   84608             :                else
   84609             :                   {
   84610        2604 :                     pointer[i].set_freepointer(NULL);
   84611             :                   }
   84612             :               }
   84613             :         }
   84614           5 :      return globalIndex;
   84615             :    }
   84616             : 
   84617             : //############################################################################
   84618             : // JH (01/14/2006)
   84619             : void
   84620           5 : SgVariableDefinition::resetValidFreepointers( )
   84621             :    {
   84622           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   84623           5 :      SgVariableDefinition* pointer = NULL;
   84624           5 :      std::vector < unsigned char* > :: const_iterator block;
   84625           5 :      SgVariableDefinition* pointerOfLinkedList = NULL;
   84626           7 :      for ( block = SgVariableDefinition::pools.begin(); block != SgVariableDefinition::pools.end() ; ++block )
   84627             :         {
   84628           2 :           pointer = (SgVariableDefinition*)(*block);
   84629        4002 :           for (unsigned i = 0; i < SgVariableDefinition::pool_size; ++i )
   84630             :              {
   84631             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   84632             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   84633             :             // memory blocks!.
   84634        4000 :                if ( pointer[i].get_freepointer() != NULL )
   84635             :                   {
   84636        1396 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   84637             :                   }
   84638             :                else
   84639             :                   {
   84640        2604 :                     if ( pointerOfLinkedList == NULL )
   84641             :                        {
   84642           2 :                          SgVariableDefinition::next_node = &(pointer[i]);
   84643             :                        }
   84644             :                     else
   84645             :                        {
   84646             :                       // printf ("In SgVariableDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   84647        2602 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   84648             :                        }
   84649             :                     pointerOfLinkedList = &(pointer[i]);
   84650             :                   }
   84651             :               }
   84652             :         }
   84653             : 
   84654           5 :      if ( pointerOfLinkedList != NULL )
   84655             :         {
   84656             :        // printf ("In SgVariableDefinition::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   84657           2 :           pointerOfLinkedList->set_freepointer(NULL);
   84658             :        // DQ (6/6/2010): Temporary debugging...
   84659             :        //   ROSE_ASSERT(false);
   84660             :         }
   84661             : 
   84662           5 :      return ;
   84663             :    }
   84664             : 
   84665             : //############################################################################
   84666             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   84667             :  * within the memory pool and resets the freepointers, in order to achieve a 
   84668             :  * linked list, that has no jumps and starts at the beginning! This function 
   84669             :  * does not extend the memory pool, since we do not delete any memory blocks,
   84670             :  * but delete the valid objects.  
   84671             :  */
   84672             : void
   84673           0 : SgVariableDefinition::clearMemoryPool( )
   84674             :    {
   84675             :   // printf ("Inside of SgVariableDefinition::clearMemoryPool() \n");
   84676             : 
   84677           0 :      SgVariableDefinition* pointer = NULL, *tempPointer = NULL;
   84678           0 :      std::vector < unsigned char* > :: const_iterator block;
   84679           0 :      if ( SgVariableDefinition::pools.empty() == false )
   84680             :         {
   84681           0 :           block = SgVariableDefinition::pools.begin() ;
   84682           0 :           SgVariableDefinition::next_node = (SgVariableDefinition*) (*block);
   84683             : 
   84684           0 :           while ( block != SgVariableDefinition::pools.end() )
   84685             :              {
   84686           0 :                pointer = (SgVariableDefinition*) (*block);
   84687           0 :                if ( tempPointer != NULL )
   84688             :                   {
   84689           0 :                     tempPointer->set_freepointer(pointer);
   84690             :                   }
   84691           0 :                for (unsigned i = 0; i < SgVariableDefinition::pool_size - 1; ++i)
   84692             :                   {
   84693           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   84694             :                   }
   84695           0 :                 pointer[SgVariableDefinition::pool_size-1].set_freepointer(NULL);
   84696           0 :                 tempPointer = &(pointer[SgVariableDefinition::pool_size-1]);
   84697           0 :                 ++block;
   84698             :              }
   84699             :         }
   84700           0 :    }
   84701             : 
   84702           5 : void SgVariableDefinition::deleteMemoryPool() {
   84703           9 :   for (auto p: SgVariableDefinition::pools) {
   84704           4 :     ROSE_FREE(p);
   84705             :   }
   84706           5 :   SgVariableDefinition::next_node = nullptr;
   84707           5 :   SgVariableDefinition::pools.clear();
   84708           5 : }
   84709             : 
   84710             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   84711             : //                 reading multiple binary files to for a single AST.
   84712             : /////////// new version ////////////////////////////////
   84713             : //############################################################################
   84714             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   84715             : void
   84716           2 : SgVariableDefinition::extendMemoryPoolForFileIO( )
   84717             :   {
   84718           2 :     size_t blockIndex = SgVariableDefinition::pools.size();
   84719           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableDefinition) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableDefinition);
   84720             : 
   84721           4 :     while ( (blockIndex * SgVariableDefinition::pool_size) < newPoolSize)
   84722             :       {
   84723             : #if ROSE_ALLOC_TRACE
   84724             :         if (blockIndex > 0) {
   84725             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableDefinition) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableDefinition) = %" PRIuPTR " SgVariableDefinition::pool_size = %d \n",
   84726             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableDefinition),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableDefinition),SgVariableDefinition::pool_size);
   84727             :         }
   84728             : #endif
   84729             : 
   84730           2 :         SgVariableDefinition * pointer = (SgVariableDefinition*) ROSE_MALLOC ( SgVariableDefinition::pool_size * sizeof(SgVariableDefinition) );
   84731           2 :         assert( pointer != NULL );
   84732             : #if ROSE_ALLOC_MEMSET == 1
   84733             :         memset(pointer, 0x00, SgVariableDefinition::pool_size * sizeof(SgVariableDefinition));
   84734             : #elif ROSE_ALLOC_MEMSET == 2
   84735             :         memset(pointer, 0xCC, SgVariableDefinition::pool_size * sizeof(SgVariableDefinition));
   84736             : #endif
   84737           2 :         SgVariableDefinition::pools.push_back( (unsigned char*)(pointer) );
   84738           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVariableDefinition::pool_size * sizeof(SgVariableDefinition), V_SgVariableDefinition ) );
   84739             : 
   84740           2 :         if ( SgVariableDefinition::next_node != NULL ) {
   84741           0 :           if ( blockIndex > 0 ) {
   84742           0 :             SgVariableDefinition * blkptr = (SgVariableDefinition*)(SgVariableDefinition::pools[blockIndex-1]);
   84743           0 :             blkptr[ SgVariableDefinition::pool_size - 1 ].set_freepointer(pointer);
   84744             :           }
   84745             :         } else {
   84746           2 :           SgVariableDefinition::next_node = pointer;
   84747             :         }
   84748             : 
   84749        4000 :         for (unsigned i = 0; i < SgVariableDefinition::pool_size-1; ++i)
   84750             :            {
   84751        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   84752             :            }
   84753           2 :         pointer[ SgVariableDefinition::pool_size -1 ].set_freepointer(NULL);
   84754             : 
   84755           2 :         blockIndex++;
   84756             :       }
   84757           2 :   }
   84758             : 
   84759             : //############################################################################
   84760             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   84761             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   84762             :  * not compressed. However, that stuff is not yet implemented! 
   84763             :  */
   84764             : unsigned long
   84765           0 : SgVariableDefinition::getNumberOfLastValidPointer()
   84766             :    {
   84767           0 :       SgVariableDefinition* testPointer = (SgVariableDefinition*)(SgVariableDefinition::pools.back());
   84768           0 :       unsigned long localIndex = SgVariableDefinition::pool_size - 1;
   84769           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   84770             :          {
   84771           0 :            localIndex--;
   84772             :          }
   84773           0 :       return (localIndex + SgVariableDefinition::pool_size * (SgVariableDefinition::pools.size()-1));
   84774             :    }
   84775             : 
   84776             : //############################################################################
   84777             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   84778             :  * memory pool and initializes the data member in class SgVariableDefinitionStroageClass
   84779             :  * from its counterpart of SgVariableDefinition. The return value is just for checking, 
   84780             :  * that the whole StorageClassArray is initialized!
   84781             :  */
   84782             : unsigned long
   84783           2 : SgVariableDefinition::initializeStorageClassArray( SgVariableDefinitionStorageClass *storageArray )
   84784             :    {
   84785           2 :      unsigned long storageCounter = 0;
   84786           2 :      std::vector < unsigned char* > :: const_iterator block = SgVariableDefinition::pools.begin();
   84787           2 :      SgVariableDefinition* pointer = NULL;
   84788           4 :      while ( block != SgVariableDefinition::pools.end() ) {
   84789           2 :           pointer = (SgVariableDefinition*) (*block);
   84790        4002 :           for ( unsigned i = 0; i < SgVariableDefinition::pool_size; ++i ) {
   84791        4000 :                if ( pointer->get_freepointer() != NULL ) {
   84792        1396 :                  storageArray->pickOutIRNodeData (pointer) ;
   84793        1396 :                  storageArray++;
   84794        1396 :                  storageCounter++;
   84795             :                }
   84796        4000 :                pointer++;
   84797             :              }
   84798           2 :            block++;
   84799             :         }
   84800           2 :      return storageCounter;
   84801             :    }
   84802             : 
   84803             : /* #line 84804 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   84804             : 
   84805             : 
   84806             : 
   84807             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   84808             : 
   84809             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   84810             : 
   84811             : //############################################################################
   84812             : /* JH (02/02/2006) Constructor of the IR node SgClinkageDeclarationStatement that takes its 
   84813             :  * corresponding StorageClass as parameter
   84814             :  */
   84815           0 : SgClinkageDeclarationStatement :: SgClinkageDeclarationStatement ( const SgClinkageDeclarationStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   84816             :    {
   84817             : 
   84818             : 
   84819             : /* #line 84820 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   84820             : 
   84821           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   84822           0 :      p_languageSpecifier = storageSource.storageOf_languageSpecifier.rebuildDataStoredInEasyStorageClass() ;
   84823             : 
   84824             : 
   84825             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   84826             : 
   84827             : 
   84828           0 :    }
   84829             : 
   84830             : //############################################################################
   84831             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   84832             :  * within the working AST. 
   84833             :  */
   84834           0 : SgClinkageDeclarationStatement * SgClinkageDeclarationStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   84835           0 :      SgClinkageDeclarationStatement* returnPointer = NULL;
   84836           0 :      if ( globalIndex != 0 )
   84837             :         {
   84838             : 
   84839             : #if FILE_IO_EXTRA_CHECK
   84840           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClinkageDeclarationStatement ) ) <= globalIndex ) ;
   84841           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClinkageDeclarationStatement + 1 ) ) );
   84842             : #endif
   84843           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClinkageDeclarationStatement )  
   84844           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClinkageDeclarationStatement );
   84845           0 :           unsigned long positionInPool = localIndex % SgClinkageDeclarationStatement::pool_size;
   84846           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClinkageDeclarationStatement::pool_size;
   84847             : 
   84848             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   84849             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   84850             : 
   84851           0 :           returnPointer = &( ( (SgClinkageDeclarationStatement*)(SgClinkageDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   84852             : 
   84853           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   84854             :         }
   84855           0 :      return returnPointer ;
   84856             :    }
   84857             : 
   84858             : //############################################################################
   84859             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   84860             :   for the AST with the index astIndex
   84861             : */
   84862           0 : SgClinkageDeclarationStatement * SgClinkageDeclarationStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   84863           0 :      SgClinkageDeclarationStatement* returnPointer = NULL;
   84864           0 :      if ( globalIndex != 0 )
   84865             :         {
   84866             : 
   84867             : #if FILE_IO_EXTRA_CHECK
   84868           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClinkageDeclarationStatement ) ) <= globalIndex ) ;
   84869           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClinkageDeclarationStatement + 1 ) ) );
   84870             : #endif
   84871           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClinkageDeclarationStatement )
   84872           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClinkageDeclarationStatement );
   84873           0 :           unsigned long positionInPool = localIndex % SgClinkageDeclarationStatement::pool_size ;
   84874           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClinkageDeclarationStatement::pool_size ;
   84875             : 
   84876             : #if FILE_IO_EXTRA_CHECK
   84877             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   84878             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   84879             : #endif
   84880             : 
   84881           0 :           returnPointer = &( ( (SgClinkageDeclarationStatement*)(SgClinkageDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   84882             : 
   84883             : #if FILE_IO_EXTRA_CHECK
   84884           0 :           assert ( returnPointer != NULL ) ;
   84885             : #endif
   84886             :         }
   84887           0 :      return returnPointer ;
   84888             :    }
   84889             : 
   84890             : //############################################################################
   84891             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   84892             :  * pool size! We set for every valid object in the memory pool the freepointer
   84893             :  * to the global index and increase the global index afterwards. For all the 
   84894             :  * invalid objects (means address ranges within the memory pool that were not
   84895             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   84896             :  * distinguish valid from invalid objects! 
   84897             :  */
   84898             : unsigned long
   84899           5 : SgClinkageDeclarationStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   84900             :    {
   84901           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   84902           5 :      SgClinkageDeclarationStatement* pointer = NULL;
   84903           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   84904           5 :      std::vector < unsigned char* > :: const_iterator block;
   84905           5 :      for ( block = SgClinkageDeclarationStatement::pools.begin(); block != SgClinkageDeclarationStatement::pools.end() ; ++block )
   84906             :         {
   84907           0 :           pointer = (SgClinkageDeclarationStatement*)(*block);
   84908           0 :           for (unsigned i = 0; i < SgClinkageDeclarationStatement::pool_size; ++i )
   84909             :              {
   84910             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   84911             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   84912             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   84913             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   84914             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   84915             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   84916             :             // properly; so this will have to be checked next.
   84917             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   84918             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   84919           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   84920             :                   {
   84921           0 :                     pointer[i].set_freepointer((SgClinkageDeclarationStatement*)(globalIndex));
   84922           0 :                     globalIndex++;
   84923             :                   }
   84924             :                else
   84925             :                   {
   84926           0 :                     pointer[i].set_freepointer(NULL);
   84927             :                   }
   84928             :               }
   84929             :         }
   84930           5 :      return globalIndex;
   84931             :    }
   84932             : 
   84933             : //############################################################################
   84934             : // JH (01/14/2006)
   84935             : void
   84936           5 : SgClinkageDeclarationStatement::resetValidFreepointers( )
   84937             :    {
   84938           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   84939           5 :      SgClinkageDeclarationStatement* pointer = NULL;
   84940           5 :      std::vector < unsigned char* > :: const_iterator block;
   84941           5 :      SgClinkageDeclarationStatement* pointerOfLinkedList = NULL;
   84942           5 :      for ( block = SgClinkageDeclarationStatement::pools.begin(); block != SgClinkageDeclarationStatement::pools.end() ; ++block )
   84943             :         {
   84944           0 :           pointer = (SgClinkageDeclarationStatement*)(*block);
   84945           0 :           for (unsigned i = 0; i < SgClinkageDeclarationStatement::pool_size; ++i )
   84946             :              {
   84947             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   84948             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   84949             :             // memory blocks!.
   84950           0 :                if ( pointer[i].get_freepointer() != NULL )
   84951             :                   {
   84952           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   84953             :                   }
   84954             :                else
   84955             :                   {
   84956           0 :                     if ( pointerOfLinkedList == NULL )
   84957             :                        {
   84958           0 :                          SgClinkageDeclarationStatement::next_node = &(pointer[i]);
   84959             :                        }
   84960             :                     else
   84961             :                        {
   84962             :                       // printf ("In SgClinkageDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   84963           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   84964             :                        }
   84965             :                     pointerOfLinkedList = &(pointer[i]);
   84966             :                   }
   84967             :               }
   84968             :         }
   84969             : 
   84970           5 :      if ( pointerOfLinkedList != NULL )
   84971             :         {
   84972             :        // printf ("In SgClinkageDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   84973           0 :           pointerOfLinkedList->set_freepointer(NULL);
   84974             :        // DQ (6/6/2010): Temporary debugging...
   84975             :        //   ROSE_ASSERT(false);
   84976             :         }
   84977             : 
   84978           5 :      return ;
   84979             :    }
   84980             : 
   84981             : //############################################################################
   84982             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   84983             :  * within the memory pool and resets the freepointers, in order to achieve a 
   84984             :  * linked list, that has no jumps and starts at the beginning! This function 
   84985             :  * does not extend the memory pool, since we do not delete any memory blocks,
   84986             :  * but delete the valid objects.  
   84987             :  */
   84988             : void
   84989           0 : SgClinkageDeclarationStatement::clearMemoryPool( )
   84990             :    {
   84991             :   // printf ("Inside of SgClinkageDeclarationStatement::clearMemoryPool() \n");
   84992             : 
   84993           0 :      SgClinkageDeclarationStatement* pointer = NULL, *tempPointer = NULL;
   84994           0 :      std::vector < unsigned char* > :: const_iterator block;
   84995           0 :      if ( SgClinkageDeclarationStatement::pools.empty() == false )
   84996             :         {
   84997           0 :           block = SgClinkageDeclarationStatement::pools.begin() ;
   84998           0 :           SgClinkageDeclarationStatement::next_node = (SgClinkageDeclarationStatement*) (*block);
   84999             : 
   85000           0 :           while ( block != SgClinkageDeclarationStatement::pools.end() )
   85001             :              {
   85002           0 :                pointer = (SgClinkageDeclarationStatement*) (*block);
   85003           0 :                if ( tempPointer != NULL )
   85004             :                   {
   85005           0 :                     tempPointer->set_freepointer(pointer);
   85006             :                   }
   85007           0 :                for (unsigned i = 0; i < SgClinkageDeclarationStatement::pool_size - 1; ++i)
   85008             :                   {
   85009           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   85010             :                   }
   85011           0 :                 pointer[SgClinkageDeclarationStatement::pool_size-1].set_freepointer(NULL);
   85012           0 :                 tempPointer = &(pointer[SgClinkageDeclarationStatement::pool_size-1]);
   85013           0 :                 ++block;
   85014             :              }
   85015             :         }
   85016           0 :    }
   85017             : 
   85018           5 : void SgClinkageDeclarationStatement::deleteMemoryPool() {
   85019           5 :   for (auto p: SgClinkageDeclarationStatement::pools) {
   85020           0 :     ROSE_FREE(p);
   85021             :   }
   85022           5 :   SgClinkageDeclarationStatement::next_node = nullptr;
   85023           5 :   SgClinkageDeclarationStatement::pools.clear();
   85024           5 : }
   85025             : 
   85026             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   85027             : //                 reading multiple binary files to for a single AST.
   85028             : /////////// new version ////////////////////////////////
   85029             : //############################################################################
   85030             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   85031             : void
   85032           2 : SgClinkageDeclarationStatement::extendMemoryPoolForFileIO( )
   85033             :   {
   85034           2 :     size_t blockIndex = SgClinkageDeclarationStatement::pools.size();
   85035           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageDeclarationStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageDeclarationStatement);
   85036             : 
   85037           2 :     while ( (blockIndex * SgClinkageDeclarationStatement::pool_size) < newPoolSize)
   85038             :       {
   85039             : #if ROSE_ALLOC_TRACE
   85040             :         if (blockIndex > 0) {
   85041             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageDeclarationStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageDeclarationStatement) = %" PRIuPTR " SgClinkageDeclarationStatement::pool_size = %d \n",
   85042             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageDeclarationStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageDeclarationStatement),SgClinkageDeclarationStatement::pool_size);
   85043             :         }
   85044             : #endif
   85045             : 
   85046           0 :         SgClinkageDeclarationStatement * pointer = (SgClinkageDeclarationStatement*) ROSE_MALLOC ( SgClinkageDeclarationStatement::pool_size * sizeof(SgClinkageDeclarationStatement) );
   85047           0 :         assert( pointer != NULL );
   85048             : #if ROSE_ALLOC_MEMSET == 1
   85049             :         memset(pointer, 0x00, SgClinkageDeclarationStatement::pool_size * sizeof(SgClinkageDeclarationStatement));
   85050             : #elif ROSE_ALLOC_MEMSET == 2
   85051             :         memset(pointer, 0xCC, SgClinkageDeclarationStatement::pool_size * sizeof(SgClinkageDeclarationStatement));
   85052             : #endif
   85053           0 :         SgClinkageDeclarationStatement::pools.push_back( (unsigned char*)(pointer) );
   85054           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClinkageDeclarationStatement::pool_size * sizeof(SgClinkageDeclarationStatement), V_SgClinkageDeclarationStatement ) );
   85055             : 
   85056           0 :         if ( SgClinkageDeclarationStatement::next_node != NULL ) {
   85057           0 :           if ( blockIndex > 0 ) {
   85058           0 :             SgClinkageDeclarationStatement * blkptr = (SgClinkageDeclarationStatement*)(SgClinkageDeclarationStatement::pools[blockIndex-1]);
   85059           0 :             blkptr[ SgClinkageDeclarationStatement::pool_size - 1 ].set_freepointer(pointer);
   85060             :           }
   85061             :         } else {
   85062           0 :           SgClinkageDeclarationStatement::next_node = pointer;
   85063             :         }
   85064             : 
   85065           0 :         for (unsigned i = 0; i < SgClinkageDeclarationStatement::pool_size-1; ++i)
   85066             :            {
   85067           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   85068             :            }
   85069           0 :         pointer[ SgClinkageDeclarationStatement::pool_size -1 ].set_freepointer(NULL);
   85070             : 
   85071           0 :         blockIndex++;
   85072             :       }
   85073           2 :   }
   85074             : 
   85075             : //############################################################################
   85076             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   85077             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   85078             :  * not compressed. However, that stuff is not yet implemented! 
   85079             :  */
   85080             : unsigned long
   85081           0 : SgClinkageDeclarationStatement::getNumberOfLastValidPointer()
   85082             :    {
   85083           0 :       SgClinkageDeclarationStatement* testPointer = (SgClinkageDeclarationStatement*)(SgClinkageDeclarationStatement::pools.back());
   85084           0 :       unsigned long localIndex = SgClinkageDeclarationStatement::pool_size - 1;
   85085           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   85086             :          {
   85087           0 :            localIndex--;
   85088             :          }
   85089           0 :       return (localIndex + SgClinkageDeclarationStatement::pool_size * (SgClinkageDeclarationStatement::pools.size()-1));
   85090             :    }
   85091             : 
   85092             : //############################################################################
   85093             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   85094             :  * memory pool and initializes the data member in class SgClinkageDeclarationStatementStroageClass
   85095             :  * from its counterpart of SgClinkageDeclarationStatement. The return value is just for checking, 
   85096             :  * that the whole StorageClassArray is initialized!
   85097             :  */
   85098             : unsigned long
   85099           0 : SgClinkageDeclarationStatement::initializeStorageClassArray( SgClinkageDeclarationStatementStorageClass *storageArray )
   85100             :    {
   85101           0 :      unsigned long storageCounter = 0;
   85102           0 :      std::vector < unsigned char* > :: const_iterator block = SgClinkageDeclarationStatement::pools.begin();
   85103           0 :      SgClinkageDeclarationStatement* pointer = NULL;
   85104           0 :      while ( block != SgClinkageDeclarationStatement::pools.end() ) {
   85105           0 :           pointer = (SgClinkageDeclarationStatement*) (*block);
   85106           0 :           for ( unsigned i = 0; i < SgClinkageDeclarationStatement::pool_size; ++i ) {
   85107           0 :                if ( pointer->get_freepointer() != NULL ) {
   85108           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   85109           0 :                  storageArray++;
   85110           0 :                  storageCounter++;
   85111             :                }
   85112           0 :                pointer++;
   85113             :              }
   85114           0 :            block++;
   85115             :         }
   85116           0 :      return storageCounter;
   85117             :    }
   85118             : 
   85119             : /* #line 85120 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   85120             : 
   85121             : 
   85122             : 
   85123             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   85124             : 
   85125             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   85126             : 
   85127             : //############################################################################
   85128             : /* JH (02/02/2006) Constructor of the IR node SgClinkageStartStatement that takes its 
   85129             :  * corresponding StorageClass as parameter
   85130             :  */
   85131           0 : SgClinkageStartStatement :: SgClinkageStartStatement ( const SgClinkageStartStatementStorageClass& storageSource )   : SgClinkageDeclarationStatement (storageSource)
   85132             :    {
   85133             : 
   85134             : 
   85135             : /* #line 85136 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   85136             : 
   85137           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   85138             : 
   85139             : 
   85140             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   85141             : 
   85142             : 
   85143           0 :    }
   85144             : 
   85145             : //############################################################################
   85146             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   85147             :  * within the working AST. 
   85148             :  */
   85149           0 : SgClinkageStartStatement * SgClinkageStartStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   85150           0 :      SgClinkageStartStatement* returnPointer = NULL;
   85151           0 :      if ( globalIndex != 0 )
   85152             :         {
   85153             : 
   85154             : #if FILE_IO_EXTRA_CHECK
   85155           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClinkageStartStatement ) ) <= globalIndex ) ;
   85156           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClinkageStartStatement + 1 ) ) );
   85157             : #endif
   85158           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClinkageStartStatement )  
   85159           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClinkageStartStatement );
   85160           0 :           unsigned long positionInPool = localIndex % SgClinkageStartStatement::pool_size;
   85161           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClinkageStartStatement::pool_size;
   85162             : 
   85163             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   85164             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   85165             : 
   85166           0 :           returnPointer = &( ( (SgClinkageStartStatement*)(SgClinkageStartStatement::pools[memoryBlock]) ) [positionInPool]) ;
   85167             : 
   85168           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   85169             :         }
   85170           0 :      return returnPointer ;
   85171             :    }
   85172             : 
   85173             : //############################################################################
   85174             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   85175             :   for the AST with the index astIndex
   85176             : */
   85177           0 : SgClinkageStartStatement * SgClinkageStartStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   85178           0 :      SgClinkageStartStatement* returnPointer = NULL;
   85179           0 :      if ( globalIndex != 0 )
   85180             :         {
   85181             : 
   85182             : #if FILE_IO_EXTRA_CHECK
   85183           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClinkageStartStatement ) ) <= globalIndex ) ;
   85184           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClinkageStartStatement + 1 ) ) );
   85185             : #endif
   85186           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClinkageStartStatement )
   85187           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClinkageStartStatement );
   85188           0 :           unsigned long positionInPool = localIndex % SgClinkageStartStatement::pool_size ;
   85189           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClinkageStartStatement::pool_size ;
   85190             : 
   85191             : #if FILE_IO_EXTRA_CHECK
   85192             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   85193             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   85194             : #endif
   85195             : 
   85196           0 :           returnPointer = &( ( (SgClinkageStartStatement*)(SgClinkageStartStatement::pools[memoryBlock]) ) [positionInPool]) ;
   85197             : 
   85198             : #if FILE_IO_EXTRA_CHECK
   85199           0 :           assert ( returnPointer != NULL ) ;
   85200             : #endif
   85201             :         }
   85202           0 :      return returnPointer ;
   85203             :    }
   85204             : 
   85205             : //############################################################################
   85206             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   85207             :  * pool size! We set for every valid object in the memory pool the freepointer
   85208             :  * to the global index and increase the global index afterwards. For all the 
   85209             :  * invalid objects (means address ranges within the memory pool that were not
   85210             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   85211             :  * distinguish valid from invalid objects! 
   85212             :  */
   85213             : unsigned long
   85214           5 : SgClinkageStartStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   85215             :    {
   85216           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   85217           5 :      SgClinkageStartStatement* pointer = NULL;
   85218           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   85219           5 :      std::vector < unsigned char* > :: const_iterator block;
   85220           5 :      for ( block = SgClinkageStartStatement::pools.begin(); block != SgClinkageStartStatement::pools.end() ; ++block )
   85221             :         {
   85222           0 :           pointer = (SgClinkageStartStatement*)(*block);
   85223           0 :           for (unsigned i = 0; i < SgClinkageStartStatement::pool_size; ++i )
   85224             :              {
   85225             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   85226             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   85227             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   85228             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   85229             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   85230             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   85231             :             // properly; so this will have to be checked next.
   85232             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   85233             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   85234           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   85235             :                   {
   85236           0 :                     pointer[i].set_freepointer((SgClinkageStartStatement*)(globalIndex));
   85237           0 :                     globalIndex++;
   85238             :                   }
   85239             :                else
   85240             :                   {
   85241           0 :                     pointer[i].set_freepointer(NULL);
   85242             :                   }
   85243             :               }
   85244             :         }
   85245           5 :      return globalIndex;
   85246             :    }
   85247             : 
   85248             : //############################################################################
   85249             : // JH (01/14/2006)
   85250             : void
   85251           5 : SgClinkageStartStatement::resetValidFreepointers( )
   85252             :    {
   85253           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   85254           5 :      SgClinkageStartStatement* pointer = NULL;
   85255           5 :      std::vector < unsigned char* > :: const_iterator block;
   85256           5 :      SgClinkageStartStatement* pointerOfLinkedList = NULL;
   85257           5 :      for ( block = SgClinkageStartStatement::pools.begin(); block != SgClinkageStartStatement::pools.end() ; ++block )
   85258             :         {
   85259           0 :           pointer = (SgClinkageStartStatement*)(*block);
   85260           0 :           for (unsigned i = 0; i < SgClinkageStartStatement::pool_size; ++i )
   85261             :              {
   85262             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   85263             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   85264             :             // memory blocks!.
   85265           0 :                if ( pointer[i].get_freepointer() != NULL )
   85266             :                   {
   85267           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   85268             :                   }
   85269             :                else
   85270             :                   {
   85271           0 :                     if ( pointerOfLinkedList == NULL )
   85272             :                        {
   85273           0 :                          SgClinkageStartStatement::next_node = &(pointer[i]);
   85274             :                        }
   85275             :                     else
   85276             :                        {
   85277             :                       // printf ("In SgClinkageStartStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   85278           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   85279             :                        }
   85280             :                     pointerOfLinkedList = &(pointer[i]);
   85281             :                   }
   85282             :               }
   85283             :         }
   85284             : 
   85285           5 :      if ( pointerOfLinkedList != NULL )
   85286             :         {
   85287             :        // printf ("In SgClinkageStartStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   85288           0 :           pointerOfLinkedList->set_freepointer(NULL);
   85289             :        // DQ (6/6/2010): Temporary debugging...
   85290             :        //   ROSE_ASSERT(false);
   85291             :         }
   85292             : 
   85293           5 :      return ;
   85294             :    }
   85295             : 
   85296             : //############################################################################
   85297             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   85298             :  * within the memory pool and resets the freepointers, in order to achieve a 
   85299             :  * linked list, that has no jumps and starts at the beginning! This function 
   85300             :  * does not extend the memory pool, since we do not delete any memory blocks,
   85301             :  * but delete the valid objects.  
   85302             :  */
   85303             : void
   85304           0 : SgClinkageStartStatement::clearMemoryPool( )
   85305             :    {
   85306             :   // printf ("Inside of SgClinkageStartStatement::clearMemoryPool() \n");
   85307             : 
   85308           0 :      SgClinkageStartStatement* pointer = NULL, *tempPointer = NULL;
   85309           0 :      std::vector < unsigned char* > :: const_iterator block;
   85310           0 :      if ( SgClinkageStartStatement::pools.empty() == false )
   85311             :         {
   85312           0 :           block = SgClinkageStartStatement::pools.begin() ;
   85313           0 :           SgClinkageStartStatement::next_node = (SgClinkageStartStatement*) (*block);
   85314             : 
   85315           0 :           while ( block != SgClinkageStartStatement::pools.end() )
   85316             :              {
   85317           0 :                pointer = (SgClinkageStartStatement*) (*block);
   85318           0 :                if ( tempPointer != NULL )
   85319             :                   {
   85320           0 :                     tempPointer->set_freepointer(pointer);
   85321             :                   }
   85322           0 :                for (unsigned i = 0; i < SgClinkageStartStatement::pool_size - 1; ++i)
   85323             :                   {
   85324           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   85325             :                   }
   85326           0 :                 pointer[SgClinkageStartStatement::pool_size-1].set_freepointer(NULL);
   85327           0 :                 tempPointer = &(pointer[SgClinkageStartStatement::pool_size-1]);
   85328           0 :                 ++block;
   85329             :              }
   85330             :         }
   85331           0 :    }
   85332             : 
   85333           5 : void SgClinkageStartStatement::deleteMemoryPool() {
   85334           5 :   for (auto p: SgClinkageStartStatement::pools) {
   85335           0 :     ROSE_FREE(p);
   85336             :   }
   85337           5 :   SgClinkageStartStatement::next_node = nullptr;
   85338           5 :   SgClinkageStartStatement::pools.clear();
   85339           5 : }
   85340             : 
   85341             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   85342             : //                 reading multiple binary files to for a single AST.
   85343             : /////////// new version ////////////////////////////////
   85344             : //############################################################################
   85345             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   85346             : void
   85347           2 : SgClinkageStartStatement::extendMemoryPoolForFileIO( )
   85348             :   {
   85349           2 :     size_t blockIndex = SgClinkageStartStatement::pools.size();
   85350           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageStartStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageStartStatement);
   85351             : 
   85352           2 :     while ( (blockIndex * SgClinkageStartStatement::pool_size) < newPoolSize)
   85353             :       {
   85354             : #if ROSE_ALLOC_TRACE
   85355             :         if (blockIndex > 0) {
   85356             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageStartStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageStartStatement) = %" PRIuPTR " SgClinkageStartStatement::pool_size = %d \n",
   85357             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageStartStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageStartStatement),SgClinkageStartStatement::pool_size);
   85358             :         }
   85359             : #endif
   85360             : 
   85361           0 :         SgClinkageStartStatement * pointer = (SgClinkageStartStatement*) ROSE_MALLOC ( SgClinkageStartStatement::pool_size * sizeof(SgClinkageStartStatement) );
   85362           0 :         assert( pointer != NULL );
   85363             : #if ROSE_ALLOC_MEMSET == 1
   85364             :         memset(pointer, 0x00, SgClinkageStartStatement::pool_size * sizeof(SgClinkageStartStatement));
   85365             : #elif ROSE_ALLOC_MEMSET == 2
   85366             :         memset(pointer, 0xCC, SgClinkageStartStatement::pool_size * sizeof(SgClinkageStartStatement));
   85367             : #endif
   85368           0 :         SgClinkageStartStatement::pools.push_back( (unsigned char*)(pointer) );
   85369           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClinkageStartStatement::pool_size * sizeof(SgClinkageStartStatement), V_SgClinkageStartStatement ) );
   85370             : 
   85371           0 :         if ( SgClinkageStartStatement::next_node != NULL ) {
   85372           0 :           if ( blockIndex > 0 ) {
   85373           0 :             SgClinkageStartStatement * blkptr = (SgClinkageStartStatement*)(SgClinkageStartStatement::pools[blockIndex-1]);
   85374           0 :             blkptr[ SgClinkageStartStatement::pool_size - 1 ].set_freepointer(pointer);
   85375             :           }
   85376             :         } else {
   85377           0 :           SgClinkageStartStatement::next_node = pointer;
   85378             :         }
   85379             : 
   85380           0 :         for (unsigned i = 0; i < SgClinkageStartStatement::pool_size-1; ++i)
   85381             :            {
   85382           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   85383             :            }
   85384           0 :         pointer[ SgClinkageStartStatement::pool_size -1 ].set_freepointer(NULL);
   85385             : 
   85386           0 :         blockIndex++;
   85387             :       }
   85388           2 :   }
   85389             : 
   85390             : //############################################################################
   85391             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   85392             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   85393             :  * not compressed. However, that stuff is not yet implemented! 
   85394             :  */
   85395             : unsigned long
   85396           0 : SgClinkageStartStatement::getNumberOfLastValidPointer()
   85397             :    {
   85398           0 :       SgClinkageStartStatement* testPointer = (SgClinkageStartStatement*)(SgClinkageStartStatement::pools.back());
   85399           0 :       unsigned long localIndex = SgClinkageStartStatement::pool_size - 1;
   85400           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   85401             :          {
   85402           0 :            localIndex--;
   85403             :          }
   85404           0 :       return (localIndex + SgClinkageStartStatement::pool_size * (SgClinkageStartStatement::pools.size()-1));
   85405             :    }
   85406             : 
   85407             : //############################################################################
   85408             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   85409             :  * memory pool and initializes the data member in class SgClinkageStartStatementStroageClass
   85410             :  * from its counterpart of SgClinkageStartStatement. The return value is just for checking, 
   85411             :  * that the whole StorageClassArray is initialized!
   85412             :  */
   85413             : unsigned long
   85414           0 : SgClinkageStartStatement::initializeStorageClassArray( SgClinkageStartStatementStorageClass *storageArray )
   85415             :    {
   85416           0 :      unsigned long storageCounter = 0;
   85417           0 :      std::vector < unsigned char* > :: const_iterator block = SgClinkageStartStatement::pools.begin();
   85418           0 :      SgClinkageStartStatement* pointer = NULL;
   85419           0 :      while ( block != SgClinkageStartStatement::pools.end() ) {
   85420           0 :           pointer = (SgClinkageStartStatement*) (*block);
   85421           0 :           for ( unsigned i = 0; i < SgClinkageStartStatement::pool_size; ++i ) {
   85422           0 :                if ( pointer->get_freepointer() != NULL ) {
   85423           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   85424           0 :                  storageArray++;
   85425           0 :                  storageCounter++;
   85426             :                }
   85427           0 :                pointer++;
   85428             :              }
   85429           0 :            block++;
   85430             :         }
   85431           0 :      return storageCounter;
   85432             :    }
   85433             : 
   85434             : /* #line 85435 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   85435             : 
   85436             : 
   85437             : 
   85438             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   85439             : 
   85440             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   85441             : 
   85442             : //############################################################################
   85443             : /* JH (02/02/2006) Constructor of the IR node SgClinkageEndStatement that takes its 
   85444             :  * corresponding StorageClass as parameter
   85445             :  */
   85446           0 : SgClinkageEndStatement :: SgClinkageEndStatement ( const SgClinkageEndStatementStorageClass& storageSource )   : SgClinkageDeclarationStatement (storageSource)
   85447             :    {
   85448             : 
   85449             : 
   85450             : /* #line 85451 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   85451             : 
   85452           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   85453             : 
   85454             : 
   85455             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   85456             : 
   85457             : 
   85458           0 :    }
   85459             : 
   85460             : //############################################################################
   85461             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   85462             :  * within the working AST. 
   85463             :  */
   85464           0 : SgClinkageEndStatement * SgClinkageEndStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   85465           0 :      SgClinkageEndStatement* returnPointer = NULL;
   85466           0 :      if ( globalIndex != 0 )
   85467             :         {
   85468             : 
   85469             : #if FILE_IO_EXTRA_CHECK
   85470           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClinkageEndStatement ) ) <= globalIndex ) ;
   85471           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClinkageEndStatement + 1 ) ) );
   85472             : #endif
   85473           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClinkageEndStatement )  
   85474           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClinkageEndStatement );
   85475           0 :           unsigned long positionInPool = localIndex % SgClinkageEndStatement::pool_size;
   85476           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClinkageEndStatement::pool_size;
   85477             : 
   85478             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   85479             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   85480             : 
   85481           0 :           returnPointer = &( ( (SgClinkageEndStatement*)(SgClinkageEndStatement::pools[memoryBlock]) ) [positionInPool]) ;
   85482             : 
   85483           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   85484             :         }
   85485           0 :      return returnPointer ;
   85486             :    }
   85487             : 
   85488             : //############################################################################
   85489             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   85490             :   for the AST with the index astIndex
   85491             : */
   85492           0 : SgClinkageEndStatement * SgClinkageEndStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   85493           0 :      SgClinkageEndStatement* returnPointer = NULL;
   85494           0 :      if ( globalIndex != 0 )
   85495             :         {
   85496             : 
   85497             : #if FILE_IO_EXTRA_CHECK
   85498           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClinkageEndStatement ) ) <= globalIndex ) ;
   85499           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClinkageEndStatement + 1 ) ) );
   85500             : #endif
   85501           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClinkageEndStatement )
   85502           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClinkageEndStatement );
   85503           0 :           unsigned long positionInPool = localIndex % SgClinkageEndStatement::pool_size ;
   85504           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClinkageEndStatement::pool_size ;
   85505             : 
   85506             : #if FILE_IO_EXTRA_CHECK
   85507             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   85508             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   85509             : #endif
   85510             : 
   85511           0 :           returnPointer = &( ( (SgClinkageEndStatement*)(SgClinkageEndStatement::pools[memoryBlock]) ) [positionInPool]) ;
   85512             : 
   85513             : #if FILE_IO_EXTRA_CHECK
   85514           0 :           assert ( returnPointer != NULL ) ;
   85515             : #endif
   85516             :         }
   85517           0 :      return returnPointer ;
   85518             :    }
   85519             : 
   85520             : //############################################################################
   85521             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   85522             :  * pool size! We set for every valid object in the memory pool the freepointer
   85523             :  * to the global index and increase the global index afterwards. For all the 
   85524             :  * invalid objects (means address ranges within the memory pool that were not
   85525             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   85526             :  * distinguish valid from invalid objects! 
   85527             :  */
   85528             : unsigned long
   85529           5 : SgClinkageEndStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   85530             :    {
   85531           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   85532           5 :      SgClinkageEndStatement* pointer = NULL;
   85533           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   85534           5 :      std::vector < unsigned char* > :: const_iterator block;
   85535           5 :      for ( block = SgClinkageEndStatement::pools.begin(); block != SgClinkageEndStatement::pools.end() ; ++block )
   85536             :         {
   85537           0 :           pointer = (SgClinkageEndStatement*)(*block);
   85538           0 :           for (unsigned i = 0; i < SgClinkageEndStatement::pool_size; ++i )
   85539             :              {
   85540             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   85541             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   85542             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   85543             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   85544             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   85545             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   85546             :             // properly; so this will have to be checked next.
   85547             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   85548             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   85549           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   85550             :                   {
   85551           0 :                     pointer[i].set_freepointer((SgClinkageEndStatement*)(globalIndex));
   85552           0 :                     globalIndex++;
   85553             :                   }
   85554             :                else
   85555             :                   {
   85556           0 :                     pointer[i].set_freepointer(NULL);
   85557             :                   }
   85558             :               }
   85559             :         }
   85560           5 :      return globalIndex;
   85561             :    }
   85562             : 
   85563             : //############################################################################
   85564             : // JH (01/14/2006)
   85565             : void
   85566           5 : SgClinkageEndStatement::resetValidFreepointers( )
   85567             :    {
   85568           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   85569           5 :      SgClinkageEndStatement* pointer = NULL;
   85570           5 :      std::vector < unsigned char* > :: const_iterator block;
   85571           5 :      SgClinkageEndStatement* pointerOfLinkedList = NULL;
   85572           5 :      for ( block = SgClinkageEndStatement::pools.begin(); block != SgClinkageEndStatement::pools.end() ; ++block )
   85573             :         {
   85574           0 :           pointer = (SgClinkageEndStatement*)(*block);
   85575           0 :           for (unsigned i = 0; i < SgClinkageEndStatement::pool_size; ++i )
   85576             :              {
   85577             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   85578             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   85579             :             // memory blocks!.
   85580           0 :                if ( pointer[i].get_freepointer() != NULL )
   85581             :                   {
   85582           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   85583             :                   }
   85584             :                else
   85585             :                   {
   85586           0 :                     if ( pointerOfLinkedList == NULL )
   85587             :                        {
   85588           0 :                          SgClinkageEndStatement::next_node = &(pointer[i]);
   85589             :                        }
   85590             :                     else
   85591             :                        {
   85592             :                       // printf ("In SgClinkageEndStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   85593           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   85594             :                        }
   85595             :                     pointerOfLinkedList = &(pointer[i]);
   85596             :                   }
   85597             :               }
   85598             :         }
   85599             : 
   85600           5 :      if ( pointerOfLinkedList != NULL )
   85601             :         {
   85602             :        // printf ("In SgClinkageEndStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   85603           0 :           pointerOfLinkedList->set_freepointer(NULL);
   85604             :        // DQ (6/6/2010): Temporary debugging...
   85605             :        //   ROSE_ASSERT(false);
   85606             :         }
   85607             : 
   85608           5 :      return ;
   85609             :    }
   85610             : 
   85611             : //############################################################################
   85612             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   85613             :  * within the memory pool and resets the freepointers, in order to achieve a 
   85614             :  * linked list, that has no jumps and starts at the beginning! This function 
   85615             :  * does not extend the memory pool, since we do not delete any memory blocks,
   85616             :  * but delete the valid objects.  
   85617             :  */
   85618             : void
   85619           0 : SgClinkageEndStatement::clearMemoryPool( )
   85620             :    {
   85621             :   // printf ("Inside of SgClinkageEndStatement::clearMemoryPool() \n");
   85622             : 
   85623           0 :      SgClinkageEndStatement* pointer = NULL, *tempPointer = NULL;
   85624           0 :      std::vector < unsigned char* > :: const_iterator block;
   85625           0 :      if ( SgClinkageEndStatement::pools.empty() == false )
   85626             :         {
   85627           0 :           block = SgClinkageEndStatement::pools.begin() ;
   85628           0 :           SgClinkageEndStatement::next_node = (SgClinkageEndStatement*) (*block);
   85629             : 
   85630           0 :           while ( block != SgClinkageEndStatement::pools.end() )
   85631             :              {
   85632           0 :                pointer = (SgClinkageEndStatement*) (*block);
   85633           0 :                if ( tempPointer != NULL )
   85634             :                   {
   85635           0 :                     tempPointer->set_freepointer(pointer);
   85636             :                   }
   85637           0 :                for (unsigned i = 0; i < SgClinkageEndStatement::pool_size - 1; ++i)
   85638             :                   {
   85639           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   85640             :                   }
   85641           0 :                 pointer[SgClinkageEndStatement::pool_size-1].set_freepointer(NULL);
   85642           0 :                 tempPointer = &(pointer[SgClinkageEndStatement::pool_size-1]);
   85643           0 :                 ++block;
   85644             :              }
   85645             :         }
   85646           0 :    }
   85647             : 
   85648           5 : void SgClinkageEndStatement::deleteMemoryPool() {
   85649           5 :   for (auto p: SgClinkageEndStatement::pools) {
   85650           0 :     ROSE_FREE(p);
   85651             :   }
   85652           5 :   SgClinkageEndStatement::next_node = nullptr;
   85653           5 :   SgClinkageEndStatement::pools.clear();
   85654           5 : }
   85655             : 
   85656             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   85657             : //                 reading multiple binary files to for a single AST.
   85658             : /////////// new version ////////////////////////////////
   85659             : //############################################################################
   85660             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   85661             : void
   85662           2 : SgClinkageEndStatement::extendMemoryPoolForFileIO( )
   85663             :   {
   85664           2 :     size_t blockIndex = SgClinkageEndStatement::pools.size();
   85665           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageEndStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageEndStatement);
   85666             : 
   85667           2 :     while ( (blockIndex * SgClinkageEndStatement::pool_size) < newPoolSize)
   85668             :       {
   85669             : #if ROSE_ALLOC_TRACE
   85670             :         if (blockIndex > 0) {
   85671             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageEndStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageEndStatement) = %" PRIuPTR " SgClinkageEndStatement::pool_size = %d \n",
   85672             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClinkageEndStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClinkageEndStatement),SgClinkageEndStatement::pool_size);
   85673             :         }
   85674             : #endif
   85675             : 
   85676           0 :         SgClinkageEndStatement * pointer = (SgClinkageEndStatement*) ROSE_MALLOC ( SgClinkageEndStatement::pool_size * sizeof(SgClinkageEndStatement) );
   85677           0 :         assert( pointer != NULL );
   85678             : #if ROSE_ALLOC_MEMSET == 1
   85679             :         memset(pointer, 0x00, SgClinkageEndStatement::pool_size * sizeof(SgClinkageEndStatement));
   85680             : #elif ROSE_ALLOC_MEMSET == 2
   85681             :         memset(pointer, 0xCC, SgClinkageEndStatement::pool_size * sizeof(SgClinkageEndStatement));
   85682             : #endif
   85683           0 :         SgClinkageEndStatement::pools.push_back( (unsigned char*)(pointer) );
   85684           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClinkageEndStatement::pool_size * sizeof(SgClinkageEndStatement), V_SgClinkageEndStatement ) );
   85685             : 
   85686           0 :         if ( SgClinkageEndStatement::next_node != NULL ) {
   85687           0 :           if ( blockIndex > 0 ) {
   85688           0 :             SgClinkageEndStatement * blkptr = (SgClinkageEndStatement*)(SgClinkageEndStatement::pools[blockIndex-1]);
   85689           0 :             blkptr[ SgClinkageEndStatement::pool_size - 1 ].set_freepointer(pointer);
   85690             :           }
   85691             :         } else {
   85692           0 :           SgClinkageEndStatement::next_node = pointer;
   85693             :         }
   85694             : 
   85695           0 :         for (unsigned i = 0; i < SgClinkageEndStatement::pool_size-1; ++i)
   85696             :            {
   85697           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   85698             :            }
   85699           0 :         pointer[ SgClinkageEndStatement::pool_size -1 ].set_freepointer(NULL);
   85700             : 
   85701           0 :         blockIndex++;
   85702             :       }
   85703           2 :   }
   85704             : 
   85705             : //############################################################################
   85706             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   85707             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   85708             :  * not compressed. However, that stuff is not yet implemented! 
   85709             :  */
   85710             : unsigned long
   85711           0 : SgClinkageEndStatement::getNumberOfLastValidPointer()
   85712             :    {
   85713           0 :       SgClinkageEndStatement* testPointer = (SgClinkageEndStatement*)(SgClinkageEndStatement::pools.back());
   85714           0 :       unsigned long localIndex = SgClinkageEndStatement::pool_size - 1;
   85715           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   85716             :          {
   85717           0 :            localIndex--;
   85718             :          }
   85719           0 :       return (localIndex + SgClinkageEndStatement::pool_size * (SgClinkageEndStatement::pools.size()-1));
   85720             :    }
   85721             : 
   85722             : //############################################################################
   85723             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   85724             :  * memory pool and initializes the data member in class SgClinkageEndStatementStroageClass
   85725             :  * from its counterpart of SgClinkageEndStatement. The return value is just for checking, 
   85726             :  * that the whole StorageClassArray is initialized!
   85727             :  */
   85728             : unsigned long
   85729           0 : SgClinkageEndStatement::initializeStorageClassArray( SgClinkageEndStatementStorageClass *storageArray )
   85730             :    {
   85731           0 :      unsigned long storageCounter = 0;
   85732           0 :      std::vector < unsigned char* > :: const_iterator block = SgClinkageEndStatement::pools.begin();
   85733           0 :      SgClinkageEndStatement* pointer = NULL;
   85734           0 :      while ( block != SgClinkageEndStatement::pools.end() ) {
   85735           0 :           pointer = (SgClinkageEndStatement*) (*block);
   85736           0 :           for ( unsigned i = 0; i < SgClinkageEndStatement::pool_size; ++i ) {
   85737           0 :                if ( pointer->get_freepointer() != NULL ) {
   85738           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   85739           0 :                  storageArray++;
   85740           0 :                  storageCounter++;
   85741             :                }
   85742           0 :                pointer++;
   85743             :              }
   85744           0 :            block++;
   85745             :         }
   85746           0 :      return storageCounter;
   85747             :    }
   85748             : 
   85749             : /* #line 85750 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   85750             : 
   85751             : 
   85752             : 
   85753             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   85754             : 
   85755             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   85756             : 
   85757             : //############################################################################
   85758             : /* JH (02/02/2006) Constructor of the IR node SgEnumDeclaration that takes its 
   85759             :  * corresponding StorageClass as parameter
   85760             :  */
   85761         176 : SgEnumDeclaration :: SgEnumDeclaration ( const SgEnumDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   85762             :    {
   85763             : 
   85764             : 
   85765             : /* #line 85766 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   85766             : 
   85767         176 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   85768         176 :      p_name = SgName ( storageSource.storageOf_name ) ;
   85769         176 :      p_embedded = storageSource.storageOf_embedded ;
   85770         176 :      p_type =  (SgEnumType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
   85771         176 :      p_adaParentType =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_adaParentType) );
   85772         176 :      p_enumerators = storageSource.storageOf_enumerators.rebuildDataStoredInEasyStorageClass() ;
   85773         176 :      SgInitializedNamePtrList::iterator i_enumerators = p_enumerators.begin() ; 
   85774         461 :      for ( ; i_enumerators != p_enumerators.end(); ++i_enumerators ) 
   85775             :         {
   85776         285 :           (*i_enumerators) = (SgInitializedNamePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_enumerators) ) );
   85777             :         }
   85778         176 :      p_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scope) );
   85779         176 :      p_isUnNamed = storageSource.storageOf_isUnNamed ;
   85780         176 :      p_isAutonomousDeclaration = storageSource.storageOf_isAutonomousDeclaration ;
   85781         176 :      p_field_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_field_type) );
   85782         176 :      p_isScopedEnum = storageSource.storageOf_isScopedEnum ;
   85783         176 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   85784         176 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   85785         176 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   85786             : 
   85787             : 
   85788             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   85789             : 
   85790             : 
   85791         176 :    }
   85792             : 
   85793             : //############################################################################
   85794             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   85795             :  * within the working AST. 
   85796             :  */
   85797        2094 : SgEnumDeclaration * SgEnumDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   85798        2094 :      SgEnumDeclaration* returnPointer = NULL;
   85799        2094 :      if ( globalIndex != 0 )
   85800             :         {
   85801             : 
   85802             : #if FILE_IO_EXTRA_CHECK
   85803        2094 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEnumDeclaration ) ) <= globalIndex ) ;
   85804        2094 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumDeclaration + 1 ) ) );
   85805             : #endif
   85806        2094 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumDeclaration )  
   85807        2094 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEnumDeclaration );
   85808        2094 :           unsigned long positionInPool = localIndex % SgEnumDeclaration::pool_size;
   85809        2094 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumDeclaration::pool_size;
   85810             : 
   85811             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   85812             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   85813             : 
   85814        2094 :           returnPointer = &( ( (SgEnumDeclaration*)(SgEnumDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   85815             : 
   85816        2094 :           ROSE_ASSERT( returnPointer != NULL ) ;
   85817             :         }
   85818        2094 :      return returnPointer ;
   85819             :    }
   85820             : 
   85821             : //############################################################################
   85822             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   85823             :   for the AST with the index astIndex
   85824             : */
   85825           0 : SgEnumDeclaration * SgEnumDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   85826           0 :      SgEnumDeclaration* returnPointer = NULL;
   85827           0 :      if ( globalIndex != 0 )
   85828             :         {
   85829             : 
   85830             : #if FILE_IO_EXTRA_CHECK
   85831           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEnumDeclaration ) ) <= globalIndex ) ;
   85832           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumDeclaration + 1 ) ) );
   85833             : #endif
   85834           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumDeclaration )
   85835           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEnumDeclaration );
   85836           0 :           unsigned long positionInPool = localIndex % SgEnumDeclaration::pool_size ;
   85837           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumDeclaration::pool_size ;
   85838             : 
   85839             : #if FILE_IO_EXTRA_CHECK
   85840             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   85841             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   85842             : #endif
   85843             : 
   85844           0 :           returnPointer = &( ( (SgEnumDeclaration*)(SgEnumDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   85845             : 
   85846             : #if FILE_IO_EXTRA_CHECK
   85847           0 :           assert ( returnPointer != NULL ) ;
   85848             : #endif
   85849             :         }
   85850           0 :      return returnPointer ;
   85851             :    }
   85852             : 
   85853             : //############################################################################
   85854             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   85855             :  * pool size! We set for every valid object in the memory pool the freepointer
   85856             :  * to the global index and increase the global index afterwards. For all the 
   85857             :  * invalid objects (means address ranges within the memory pool that were not
   85858             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   85859             :  * distinguish valid from invalid objects! 
   85860             :  */
   85861             : unsigned long
   85862           5 : SgEnumDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   85863             :    {
   85864           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   85865           5 :      SgEnumDeclaration* pointer = NULL;
   85866           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   85867           5 :      std::vector < unsigned char* > :: const_iterator block;
   85868           6 :      for ( block = SgEnumDeclaration::pools.begin(); block != SgEnumDeclaration::pools.end() ; ++block )
   85869             :         {
   85870           1 :           pointer = (SgEnumDeclaration*)(*block);
   85871        2001 :           for (unsigned i = 0; i < SgEnumDeclaration::pool_size; ++i )
   85872             :              {
   85873             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   85874             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   85875             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   85876             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   85877             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   85878             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   85879             :             // properly; so this will have to be checked next.
   85880             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   85881             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   85882        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   85883             :                   {
   85884         176 :                     pointer[i].set_freepointer((SgEnumDeclaration*)(globalIndex));
   85885         176 :                     globalIndex++;
   85886             :                   }
   85887             :                else
   85888             :                   {
   85889        1824 :                     pointer[i].set_freepointer(NULL);
   85890             :                   }
   85891             :               }
   85892             :         }
   85893           5 :      return globalIndex;
   85894             :    }
   85895             : 
   85896             : //############################################################################
   85897             : // JH (01/14/2006)
   85898             : void
   85899           5 : SgEnumDeclaration::resetValidFreepointers( )
   85900             :    {
   85901           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   85902           5 :      SgEnumDeclaration* pointer = NULL;
   85903           5 :      std::vector < unsigned char* > :: const_iterator block;
   85904           5 :      SgEnumDeclaration* pointerOfLinkedList = NULL;
   85905           6 :      for ( block = SgEnumDeclaration::pools.begin(); block != SgEnumDeclaration::pools.end() ; ++block )
   85906             :         {
   85907           1 :           pointer = (SgEnumDeclaration*)(*block);
   85908        2001 :           for (unsigned i = 0; i < SgEnumDeclaration::pool_size; ++i )
   85909             :              {
   85910             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   85911             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   85912             :             // memory blocks!.
   85913        2000 :                if ( pointer[i].get_freepointer() != NULL )
   85914             :                   {
   85915         176 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   85916             :                   }
   85917             :                else
   85918             :                   {
   85919        1824 :                     if ( pointerOfLinkedList == NULL )
   85920             :                        {
   85921           1 :                          SgEnumDeclaration::next_node = &(pointer[i]);
   85922             :                        }
   85923             :                     else
   85924             :                        {
   85925             :                       // printf ("In SgEnumDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   85926        1823 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   85927             :                        }
   85928             :                     pointerOfLinkedList = &(pointer[i]);
   85929             :                   }
   85930             :               }
   85931             :         }
   85932             : 
   85933           5 :      if ( pointerOfLinkedList != NULL )
   85934             :         {
   85935             :        // printf ("In SgEnumDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   85936           1 :           pointerOfLinkedList->set_freepointer(NULL);
   85937             :        // DQ (6/6/2010): Temporary debugging...
   85938             :        //   ROSE_ASSERT(false);
   85939             :         }
   85940             : 
   85941           5 :      return ;
   85942             :    }
   85943             : 
   85944             : //############################################################################
   85945             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   85946             :  * within the memory pool and resets the freepointers, in order to achieve a 
   85947             :  * linked list, that has no jumps and starts at the beginning! This function 
   85948             :  * does not extend the memory pool, since we do not delete any memory blocks,
   85949             :  * but delete the valid objects.  
   85950             :  */
   85951             : void
   85952           0 : SgEnumDeclaration::clearMemoryPool( )
   85953             :    {
   85954             :   // printf ("Inside of SgEnumDeclaration::clearMemoryPool() \n");
   85955             : 
   85956           0 :      SgEnumDeclaration* pointer = NULL, *tempPointer = NULL;
   85957           0 :      std::vector < unsigned char* > :: const_iterator block;
   85958           0 :      if ( SgEnumDeclaration::pools.empty() == false )
   85959             :         {
   85960           0 :           block = SgEnumDeclaration::pools.begin() ;
   85961           0 :           SgEnumDeclaration::next_node = (SgEnumDeclaration*) (*block);
   85962             : 
   85963           0 :           while ( block != SgEnumDeclaration::pools.end() )
   85964             :              {
   85965           0 :                pointer = (SgEnumDeclaration*) (*block);
   85966           0 :                if ( tempPointer != NULL )
   85967             :                   {
   85968           0 :                     tempPointer->set_freepointer(pointer);
   85969             :                   }
   85970           0 :                for (unsigned i = 0; i < SgEnumDeclaration::pool_size - 1; ++i)
   85971             :                   {
   85972           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   85973             :                   }
   85974           0 :                 pointer[SgEnumDeclaration::pool_size-1].set_freepointer(NULL);
   85975           0 :                 tempPointer = &(pointer[SgEnumDeclaration::pool_size-1]);
   85976           0 :                 ++block;
   85977             :              }
   85978             :         }
   85979           0 :    }
   85980             : 
   85981           5 : void SgEnumDeclaration::deleteMemoryPool() {
   85982           7 :   for (auto p: SgEnumDeclaration::pools) {
   85983           2 :     ROSE_FREE(p);
   85984             :   }
   85985           5 :   SgEnumDeclaration::next_node = nullptr;
   85986           5 :   SgEnumDeclaration::pools.clear();
   85987           5 : }
   85988             : 
   85989             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   85990             : //                 reading multiple binary files to for a single AST.
   85991             : /////////// new version ////////////////////////////////
   85992             : //############################################################################
   85993             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   85994             : void
   85995           2 : SgEnumDeclaration::extendMemoryPoolForFileIO( )
   85996             :   {
   85997           2 :     size_t blockIndex = SgEnumDeclaration::pools.size();
   85998           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumDeclaration);
   85999             : 
   86000           3 :     while ( (blockIndex * SgEnumDeclaration::pool_size) < newPoolSize)
   86001             :       {
   86002             : #if ROSE_ALLOC_TRACE
   86003             :         if (blockIndex > 0) {
   86004             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumDeclaration) = %" PRIuPTR " SgEnumDeclaration::pool_size = %d \n",
   86005             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumDeclaration),SgEnumDeclaration::pool_size);
   86006             :         }
   86007             : #endif
   86008             : 
   86009           1 :         SgEnumDeclaration * pointer = (SgEnumDeclaration*) ROSE_MALLOC ( SgEnumDeclaration::pool_size * sizeof(SgEnumDeclaration) );
   86010           1 :         assert( pointer != NULL );
   86011             : #if ROSE_ALLOC_MEMSET == 1
   86012             :         memset(pointer, 0x00, SgEnumDeclaration::pool_size * sizeof(SgEnumDeclaration));
   86013             : #elif ROSE_ALLOC_MEMSET == 2
   86014             :         memset(pointer, 0xCC, SgEnumDeclaration::pool_size * sizeof(SgEnumDeclaration));
   86015             : #endif
   86016           1 :         SgEnumDeclaration::pools.push_back( (unsigned char*)(pointer) );
   86017           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEnumDeclaration::pool_size * sizeof(SgEnumDeclaration), V_SgEnumDeclaration ) );
   86018             : 
   86019           1 :         if ( SgEnumDeclaration::next_node != NULL ) {
   86020           0 :           if ( blockIndex > 0 ) {
   86021           0 :             SgEnumDeclaration * blkptr = (SgEnumDeclaration*)(SgEnumDeclaration::pools[blockIndex-1]);
   86022           0 :             blkptr[ SgEnumDeclaration::pool_size - 1 ].set_freepointer(pointer);
   86023             :           }
   86024             :         } else {
   86025           1 :           SgEnumDeclaration::next_node = pointer;
   86026             :         }
   86027             : 
   86028        2000 :         for (unsigned i = 0; i < SgEnumDeclaration::pool_size-1; ++i)
   86029             :            {
   86030        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   86031             :            }
   86032           1 :         pointer[ SgEnumDeclaration::pool_size -1 ].set_freepointer(NULL);
   86033             : 
   86034           1 :         blockIndex++;
   86035             :       }
   86036           2 :   }
   86037             : 
   86038             : //############################################################################
   86039             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   86040             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   86041             :  * not compressed. However, that stuff is not yet implemented! 
   86042             :  */
   86043             : unsigned long
   86044           0 : SgEnumDeclaration::getNumberOfLastValidPointer()
   86045             :    {
   86046           0 :       SgEnumDeclaration* testPointer = (SgEnumDeclaration*)(SgEnumDeclaration::pools.back());
   86047           0 :       unsigned long localIndex = SgEnumDeclaration::pool_size - 1;
   86048           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   86049             :          {
   86050           0 :            localIndex--;
   86051             :          }
   86052           0 :       return (localIndex + SgEnumDeclaration::pool_size * (SgEnumDeclaration::pools.size()-1));
   86053             :    }
   86054             : 
   86055             : //############################################################################
   86056             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   86057             :  * memory pool and initializes the data member in class SgEnumDeclarationStroageClass
   86058             :  * from its counterpart of SgEnumDeclaration. The return value is just for checking, 
   86059             :  * that the whole StorageClassArray is initialized!
   86060             :  */
   86061             : unsigned long
   86062           1 : SgEnumDeclaration::initializeStorageClassArray( SgEnumDeclarationStorageClass *storageArray )
   86063             :    {
   86064           1 :      unsigned long storageCounter = 0;
   86065           1 :      std::vector < unsigned char* > :: const_iterator block = SgEnumDeclaration::pools.begin();
   86066           1 :      SgEnumDeclaration* pointer = NULL;
   86067           2 :      while ( block != SgEnumDeclaration::pools.end() ) {
   86068           1 :           pointer = (SgEnumDeclaration*) (*block);
   86069        2001 :           for ( unsigned i = 0; i < SgEnumDeclaration::pool_size; ++i ) {
   86070        2000 :                if ( pointer->get_freepointer() != NULL ) {
   86071         176 :                  storageArray->pickOutIRNodeData (pointer) ;
   86072         176 :                  storageArray++;
   86073         176 :                  storageCounter++;
   86074             :                }
   86075        2000 :                pointer++;
   86076             :              }
   86077           1 :            block++;
   86078             :         }
   86079           1 :      return storageCounter;
   86080             :    }
   86081             : 
   86082             : /* #line 86083 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   86083             : 
   86084             : 
   86085             : 
   86086             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   86087             : 
   86088             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   86089             : 
   86090             : //############################################################################
   86091             : /* JH (02/02/2006) Constructor of the IR node SgAsmStmt that takes its 
   86092             :  * corresponding StorageClass as parameter
   86093             :  */
   86094           0 : SgAsmStmt :: SgAsmStmt ( const SgAsmStmtStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   86095             :    {
   86096             : 
   86097             : 
   86098             : /* #line 86099 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   86099             : 
   86100           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   86101           0 :      p_assemblyCode = storageSource.storageOf_assemblyCode.rebuildDataStoredInEasyStorageClass() ;
   86102           0 :      p_useGnuExtendedFormat = storageSource.storageOf_useGnuExtendedFormat ;
   86103           0 :      p_operands = storageSource.storageOf_operands.rebuildDataStoredInEasyStorageClass() ;
   86104           0 :      SgExpressionPtrList::iterator i_operands = p_operands.begin() ; 
   86105           0 :      for ( ; i_operands != p_operands.end(); ++i_operands ) 
   86106             :         {
   86107           0 :           (*i_operands) = (SgExpressionPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_operands) ) );
   86108             :         }
   86109           0 :      p_clobberRegisterList = storageSource.storageOf_clobberRegisterList.rebuildDataStoredInEasyStorageClass() ;
   86110           0 :      p_isVolatile = storageSource.storageOf_isVolatile ;
   86111             : 
   86112             : 
   86113             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   86114             : 
   86115             : 
   86116           0 :    }
   86117             : 
   86118             : //############################################################################
   86119             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   86120             :  * within the working AST. 
   86121             :  */
   86122           0 : SgAsmStmt * SgAsmStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   86123           0 :      SgAsmStmt* returnPointer = NULL;
   86124           0 :      if ( globalIndex != 0 )
   86125             :         {
   86126             : 
   86127             : #if FILE_IO_EXTRA_CHECK
   86128           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAsmStmt ) ) <= globalIndex ) ;
   86129           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAsmStmt + 1 ) ) );
   86130             : #endif
   86131           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAsmStmt )  
   86132           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAsmStmt );
   86133           0 :           unsigned long positionInPool = localIndex % SgAsmStmt::pool_size;
   86134           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAsmStmt::pool_size;
   86135             : 
   86136             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   86137             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   86138             : 
   86139           0 :           returnPointer = &( ( (SgAsmStmt*)(SgAsmStmt::pools[memoryBlock]) ) [positionInPool]) ;
   86140             : 
   86141           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   86142             :         }
   86143           0 :      return returnPointer ;
   86144             :    }
   86145             : 
   86146             : //############################################################################
   86147             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   86148             :   for the AST with the index astIndex
   86149             : */
   86150           0 : SgAsmStmt * SgAsmStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   86151           0 :      SgAsmStmt* returnPointer = NULL;
   86152           0 :      if ( globalIndex != 0 )
   86153             :         {
   86154             : 
   86155             : #if FILE_IO_EXTRA_CHECK
   86156           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAsmStmt ) ) <= globalIndex ) ;
   86157           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAsmStmt + 1 ) ) );
   86158             : #endif
   86159           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAsmStmt )
   86160           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAsmStmt );
   86161           0 :           unsigned long positionInPool = localIndex % SgAsmStmt::pool_size ;
   86162           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAsmStmt::pool_size ;
   86163             : 
   86164             : #if FILE_IO_EXTRA_CHECK
   86165             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   86166             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   86167             : #endif
   86168             : 
   86169           0 :           returnPointer = &( ( (SgAsmStmt*)(SgAsmStmt::pools[memoryBlock]) ) [positionInPool]) ;
   86170             : 
   86171             : #if FILE_IO_EXTRA_CHECK
   86172           0 :           assert ( returnPointer != NULL ) ;
   86173             : #endif
   86174             :         }
   86175           0 :      return returnPointer ;
   86176             :    }
   86177             : 
   86178             : //############################################################################
   86179             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   86180             :  * pool size! We set for every valid object in the memory pool the freepointer
   86181             :  * to the global index and increase the global index afterwards. For all the 
   86182             :  * invalid objects (means address ranges within the memory pool that were not
   86183             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   86184             :  * distinguish valid from invalid objects! 
   86185             :  */
   86186             : unsigned long
   86187           5 : SgAsmStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   86188             :    {
   86189           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   86190           5 :      SgAsmStmt* pointer = NULL;
   86191           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   86192           5 :      std::vector < unsigned char* > :: const_iterator block;
   86193           5 :      for ( block = SgAsmStmt::pools.begin(); block != SgAsmStmt::pools.end() ; ++block )
   86194             :         {
   86195           0 :           pointer = (SgAsmStmt*)(*block);
   86196           0 :           for (unsigned i = 0; i < SgAsmStmt::pool_size; ++i )
   86197             :              {
   86198             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   86199             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   86200             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   86201             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   86202             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   86203             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   86204             :             // properly; so this will have to be checked next.
   86205             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   86206             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   86207           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   86208             :                   {
   86209           0 :                     pointer[i].set_freepointer((SgAsmStmt*)(globalIndex));
   86210           0 :                     globalIndex++;
   86211             :                   }
   86212             :                else
   86213             :                   {
   86214           0 :                     pointer[i].set_freepointer(NULL);
   86215             :                   }
   86216             :               }
   86217             :         }
   86218           5 :      return globalIndex;
   86219             :    }
   86220             : 
   86221             : //############################################################################
   86222             : // JH (01/14/2006)
   86223             : void
   86224           5 : SgAsmStmt::resetValidFreepointers( )
   86225             :    {
   86226           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   86227           5 :      SgAsmStmt* pointer = NULL;
   86228           5 :      std::vector < unsigned char* > :: const_iterator block;
   86229           5 :      SgAsmStmt* pointerOfLinkedList = NULL;
   86230           5 :      for ( block = SgAsmStmt::pools.begin(); block != SgAsmStmt::pools.end() ; ++block )
   86231             :         {
   86232           0 :           pointer = (SgAsmStmt*)(*block);
   86233           0 :           for (unsigned i = 0; i < SgAsmStmt::pool_size; ++i )
   86234             :              {
   86235             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   86236             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   86237             :             // memory blocks!.
   86238           0 :                if ( pointer[i].get_freepointer() != NULL )
   86239             :                   {
   86240           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   86241             :                   }
   86242             :                else
   86243             :                   {
   86244           0 :                     if ( pointerOfLinkedList == NULL )
   86245             :                        {
   86246           0 :                          SgAsmStmt::next_node = &(pointer[i]);
   86247             :                        }
   86248             :                     else
   86249             :                        {
   86250             :                       // printf ("In SgAsmStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   86251           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   86252             :                        }
   86253             :                     pointerOfLinkedList = &(pointer[i]);
   86254             :                   }
   86255             :               }
   86256             :         }
   86257             : 
   86258           5 :      if ( pointerOfLinkedList != NULL )
   86259             :         {
   86260             :        // printf ("In SgAsmStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   86261           0 :           pointerOfLinkedList->set_freepointer(NULL);
   86262             :        // DQ (6/6/2010): Temporary debugging...
   86263             :        //   ROSE_ASSERT(false);
   86264             :         }
   86265             : 
   86266           5 :      return ;
   86267             :    }
   86268             : 
   86269             : //############################################################################
   86270             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   86271             :  * within the memory pool and resets the freepointers, in order to achieve a 
   86272             :  * linked list, that has no jumps and starts at the beginning! This function 
   86273             :  * does not extend the memory pool, since we do not delete any memory blocks,
   86274             :  * but delete the valid objects.  
   86275             :  */
   86276             : void
   86277           0 : SgAsmStmt::clearMemoryPool( )
   86278             :    {
   86279             :   // printf ("Inside of SgAsmStmt::clearMemoryPool() \n");
   86280             : 
   86281           0 :      SgAsmStmt* pointer = NULL, *tempPointer = NULL;
   86282           0 :      std::vector < unsigned char* > :: const_iterator block;
   86283           0 :      if ( SgAsmStmt::pools.empty() == false )
   86284             :         {
   86285           0 :           block = SgAsmStmt::pools.begin() ;
   86286           0 :           SgAsmStmt::next_node = (SgAsmStmt*) (*block);
   86287             : 
   86288           0 :           while ( block != SgAsmStmt::pools.end() )
   86289             :              {
   86290           0 :                pointer = (SgAsmStmt*) (*block);
   86291           0 :                if ( tempPointer != NULL )
   86292             :                   {
   86293           0 :                     tempPointer->set_freepointer(pointer);
   86294             :                   }
   86295           0 :                for (unsigned i = 0; i < SgAsmStmt::pool_size - 1; ++i)
   86296             :                   {
   86297           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   86298             :                   }
   86299           0 :                 pointer[SgAsmStmt::pool_size-1].set_freepointer(NULL);
   86300           0 :                 tempPointer = &(pointer[SgAsmStmt::pool_size-1]);
   86301           0 :                 ++block;
   86302             :              }
   86303             :         }
   86304           0 :    }
   86305             : 
   86306           5 : void SgAsmStmt::deleteMemoryPool() {
   86307           5 :   for (auto p: SgAsmStmt::pools) {
   86308           0 :     ROSE_FREE(p);
   86309             :   }
   86310           5 :   SgAsmStmt::next_node = nullptr;
   86311           5 :   SgAsmStmt::pools.clear();
   86312           5 : }
   86313             : 
   86314             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   86315             : //                 reading multiple binary files to for a single AST.
   86316             : /////////// new version ////////////////////////////////
   86317             : //############################################################################
   86318             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   86319             : void
   86320           2 : SgAsmStmt::extendMemoryPoolForFileIO( )
   86321             :   {
   86322           2 :     size_t blockIndex = SgAsmStmt::pools.size();
   86323           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAsmStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsmStmt);
   86324             : 
   86325           2 :     while ( (blockIndex * SgAsmStmt::pool_size) < newPoolSize)
   86326             :       {
   86327             : #if ROSE_ALLOC_TRACE
   86328             :         if (blockIndex > 0) {
   86329             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAsmStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsmStmt) = %" PRIuPTR " SgAsmStmt::pool_size = %d \n",
   86330             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAsmStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsmStmt),SgAsmStmt::pool_size);
   86331             :         }
   86332             : #endif
   86333             : 
   86334           0 :         SgAsmStmt * pointer = (SgAsmStmt*) ROSE_MALLOC ( SgAsmStmt::pool_size * sizeof(SgAsmStmt) );
   86335           0 :         assert( pointer != NULL );
   86336             : #if ROSE_ALLOC_MEMSET == 1
   86337             :         memset(pointer, 0x00, SgAsmStmt::pool_size * sizeof(SgAsmStmt));
   86338             : #elif ROSE_ALLOC_MEMSET == 2
   86339             :         memset(pointer, 0xCC, SgAsmStmt::pool_size * sizeof(SgAsmStmt));
   86340             : #endif
   86341           0 :         SgAsmStmt::pools.push_back( (unsigned char*)(pointer) );
   86342           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAsmStmt::pool_size * sizeof(SgAsmStmt), V_SgAsmStmt ) );
   86343             : 
   86344           0 :         if ( SgAsmStmt::next_node != NULL ) {
   86345           0 :           if ( blockIndex > 0 ) {
   86346           0 :             SgAsmStmt * blkptr = (SgAsmStmt*)(SgAsmStmt::pools[blockIndex-1]);
   86347           0 :             blkptr[ SgAsmStmt::pool_size - 1 ].set_freepointer(pointer);
   86348             :           }
   86349             :         } else {
   86350           0 :           SgAsmStmt::next_node = pointer;
   86351             :         }
   86352             : 
   86353           0 :         for (unsigned i = 0; i < SgAsmStmt::pool_size-1; ++i)
   86354             :            {
   86355           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   86356             :            }
   86357           0 :         pointer[ SgAsmStmt::pool_size -1 ].set_freepointer(NULL);
   86358             : 
   86359           0 :         blockIndex++;
   86360             :       }
   86361           2 :   }
   86362             : 
   86363             : //############################################################################
   86364             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   86365             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   86366             :  * not compressed. However, that stuff is not yet implemented! 
   86367             :  */
   86368             : unsigned long
   86369           0 : SgAsmStmt::getNumberOfLastValidPointer()
   86370             :    {
   86371           0 :       SgAsmStmt* testPointer = (SgAsmStmt*)(SgAsmStmt::pools.back());
   86372           0 :       unsigned long localIndex = SgAsmStmt::pool_size - 1;
   86373           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   86374             :          {
   86375           0 :            localIndex--;
   86376             :          }
   86377           0 :       return (localIndex + SgAsmStmt::pool_size * (SgAsmStmt::pools.size()-1));
   86378             :    }
   86379             : 
   86380             : //############################################################################
   86381             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   86382             :  * memory pool and initializes the data member in class SgAsmStmtStroageClass
   86383             :  * from its counterpart of SgAsmStmt. The return value is just for checking, 
   86384             :  * that the whole StorageClassArray is initialized!
   86385             :  */
   86386             : unsigned long
   86387           0 : SgAsmStmt::initializeStorageClassArray( SgAsmStmtStorageClass *storageArray )
   86388             :    {
   86389           0 :      unsigned long storageCounter = 0;
   86390           0 :      std::vector < unsigned char* > :: const_iterator block = SgAsmStmt::pools.begin();
   86391           0 :      SgAsmStmt* pointer = NULL;
   86392           0 :      while ( block != SgAsmStmt::pools.end() ) {
   86393           0 :           pointer = (SgAsmStmt*) (*block);
   86394           0 :           for ( unsigned i = 0; i < SgAsmStmt::pool_size; ++i ) {
   86395           0 :                if ( pointer->get_freepointer() != NULL ) {
   86396           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   86397           0 :                  storageArray++;
   86398           0 :                  storageCounter++;
   86399             :                }
   86400           0 :                pointer++;
   86401             :              }
   86402           0 :            block++;
   86403             :         }
   86404           0 :      return storageCounter;
   86405             :    }
   86406             : 
   86407             : /* #line 86408 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   86408             : 
   86409             : 
   86410             : 
   86411             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   86412             : 
   86413             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   86414             : 
   86415             : //############################################################################
   86416             : /* JH (02/02/2006) Constructor of the IR node SgAttributeSpecificationStatement that takes its 
   86417             :  * corresponding StorageClass as parameter
   86418             :  */
   86419           0 : SgAttributeSpecificationStatement :: SgAttributeSpecificationStatement ( const SgAttributeSpecificationStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   86420             :    {
   86421             : 
   86422             : 
   86423             : /* #line 86424 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   86424             : 
   86425           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   86426           0 :      p_name_list = storageSource.storageOf_name_list.rebuildDataStoredInEasyStorageClass() ;
   86427           0 :      p_attribute_kind = storageSource.storageOf_attribute_kind ;
   86428           0 :      p_intent = storageSource.storageOf_intent ;
   86429           0 :      p_parameter_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parameter_list) );
   86430           0 :      p_data_statement_group_list = storageSource.storageOf_data_statement_group_list.rebuildDataStoredInEasyStorageClass() ;
   86431           0 :      SgDataStatementGroupPtrList::iterator i_data_statement_group_list = p_data_statement_group_list.begin() ; 
   86432           0 :      for ( ; i_data_statement_group_list != p_data_statement_group_list.end(); ++i_data_statement_group_list ) 
   86433             :         {
   86434           0 :           (*i_data_statement_group_list) = (SgDataStatementGroupPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_data_statement_group_list) ) );
   86435             :         }
   86436           0 :      p_bind_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_bind_list) );
   86437           0 :      p_dimension_object_list = storageSource.storageOf_dimension_object_list.rebuildDataStoredInEasyStorageClass() ;
   86438           0 :      SgDimensionObjectPtrList::iterator i_dimension_object_list = p_dimension_object_list.begin() ; 
   86439           0 :      for ( ; i_dimension_object_list != p_dimension_object_list.end(); ++i_dimension_object_list ) 
   86440             :         {
   86441           0 :           (*i_dimension_object_list) = (SgDimensionObjectPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_dimension_object_list) ) );
   86442             :         }
   86443             : 
   86444             : 
   86445             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   86446             : 
   86447             : 
   86448           0 :    }
   86449             : 
   86450             : //############################################################################
   86451             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   86452             :  * within the working AST. 
   86453             :  */
   86454           0 : SgAttributeSpecificationStatement * SgAttributeSpecificationStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   86455           0 :      SgAttributeSpecificationStatement* returnPointer = NULL;
   86456           0 :      if ( globalIndex != 0 )
   86457             :         {
   86458             : 
   86459             : #if FILE_IO_EXTRA_CHECK
   86460           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAttributeSpecificationStatement ) ) <= globalIndex ) ;
   86461           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAttributeSpecificationStatement + 1 ) ) );
   86462             : #endif
   86463           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAttributeSpecificationStatement )  
   86464           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAttributeSpecificationStatement );
   86465           0 :           unsigned long positionInPool = localIndex % SgAttributeSpecificationStatement::pool_size;
   86466           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAttributeSpecificationStatement::pool_size;
   86467             : 
   86468             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   86469             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   86470             : 
   86471           0 :           returnPointer = &( ( (SgAttributeSpecificationStatement*)(SgAttributeSpecificationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   86472             : 
   86473           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   86474             :         }
   86475           0 :      return returnPointer ;
   86476             :    }
   86477             : 
   86478             : //############################################################################
   86479             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   86480             :   for the AST with the index astIndex
   86481             : */
   86482           0 : SgAttributeSpecificationStatement * SgAttributeSpecificationStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   86483           0 :      SgAttributeSpecificationStatement* returnPointer = NULL;
   86484           0 :      if ( globalIndex != 0 )
   86485             :         {
   86486             : 
   86487             : #if FILE_IO_EXTRA_CHECK
   86488           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAttributeSpecificationStatement ) ) <= globalIndex ) ;
   86489           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAttributeSpecificationStatement + 1 ) ) );
   86490             : #endif
   86491           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAttributeSpecificationStatement )
   86492           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAttributeSpecificationStatement );
   86493           0 :           unsigned long positionInPool = localIndex % SgAttributeSpecificationStatement::pool_size ;
   86494           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAttributeSpecificationStatement::pool_size ;
   86495             : 
   86496             : #if FILE_IO_EXTRA_CHECK
   86497             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   86498             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   86499             : #endif
   86500             : 
   86501           0 :           returnPointer = &( ( (SgAttributeSpecificationStatement*)(SgAttributeSpecificationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   86502             : 
   86503             : #if FILE_IO_EXTRA_CHECK
   86504           0 :           assert ( returnPointer != NULL ) ;
   86505             : #endif
   86506             :         }
   86507           0 :      return returnPointer ;
   86508             :    }
   86509             : 
   86510             : //############################################################################
   86511             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   86512             :  * pool size! We set for every valid object in the memory pool the freepointer
   86513             :  * to the global index and increase the global index afterwards. For all the 
   86514             :  * invalid objects (means address ranges within the memory pool that were not
   86515             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   86516             :  * distinguish valid from invalid objects! 
   86517             :  */
   86518             : unsigned long
   86519           5 : SgAttributeSpecificationStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   86520             :    {
   86521           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   86522           5 :      SgAttributeSpecificationStatement* pointer = NULL;
   86523           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   86524           5 :      std::vector < unsigned char* > :: const_iterator block;
   86525           5 :      for ( block = SgAttributeSpecificationStatement::pools.begin(); block != SgAttributeSpecificationStatement::pools.end() ; ++block )
   86526             :         {
   86527           0 :           pointer = (SgAttributeSpecificationStatement*)(*block);
   86528           0 :           for (unsigned i = 0; i < SgAttributeSpecificationStatement::pool_size; ++i )
   86529             :              {
   86530             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   86531             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   86532             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   86533             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   86534             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   86535             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   86536             :             // properly; so this will have to be checked next.
   86537             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   86538             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   86539           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   86540             :                   {
   86541           0 :                     pointer[i].set_freepointer((SgAttributeSpecificationStatement*)(globalIndex));
   86542           0 :                     globalIndex++;
   86543             :                   }
   86544             :                else
   86545             :                   {
   86546           0 :                     pointer[i].set_freepointer(NULL);
   86547             :                   }
   86548             :               }
   86549             :         }
   86550           5 :      return globalIndex;
   86551             :    }
   86552             : 
   86553             : //############################################################################
   86554             : // JH (01/14/2006)
   86555             : void
   86556           5 : SgAttributeSpecificationStatement::resetValidFreepointers( )
   86557             :    {
   86558           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   86559           5 :      SgAttributeSpecificationStatement* pointer = NULL;
   86560           5 :      std::vector < unsigned char* > :: const_iterator block;
   86561           5 :      SgAttributeSpecificationStatement* pointerOfLinkedList = NULL;
   86562           5 :      for ( block = SgAttributeSpecificationStatement::pools.begin(); block != SgAttributeSpecificationStatement::pools.end() ; ++block )
   86563             :         {
   86564           0 :           pointer = (SgAttributeSpecificationStatement*)(*block);
   86565           0 :           for (unsigned i = 0; i < SgAttributeSpecificationStatement::pool_size; ++i )
   86566             :              {
   86567             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   86568             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   86569             :             // memory blocks!.
   86570           0 :                if ( pointer[i].get_freepointer() != NULL )
   86571             :                   {
   86572           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   86573             :                   }
   86574             :                else
   86575             :                   {
   86576           0 :                     if ( pointerOfLinkedList == NULL )
   86577             :                        {
   86578           0 :                          SgAttributeSpecificationStatement::next_node = &(pointer[i]);
   86579             :                        }
   86580             :                     else
   86581             :                        {
   86582             :                       // printf ("In SgAttributeSpecificationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   86583           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   86584             :                        }
   86585             :                     pointerOfLinkedList = &(pointer[i]);
   86586             :                   }
   86587             :               }
   86588             :         }
   86589             : 
   86590           5 :      if ( pointerOfLinkedList != NULL )
   86591             :         {
   86592             :        // printf ("In SgAttributeSpecificationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   86593           0 :           pointerOfLinkedList->set_freepointer(NULL);
   86594             :        // DQ (6/6/2010): Temporary debugging...
   86595             :        //   ROSE_ASSERT(false);
   86596             :         }
   86597             : 
   86598           5 :      return ;
   86599             :    }
   86600             : 
   86601             : //############################################################################
   86602             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   86603             :  * within the memory pool and resets the freepointers, in order to achieve a 
   86604             :  * linked list, that has no jumps and starts at the beginning! This function 
   86605             :  * does not extend the memory pool, since we do not delete any memory blocks,
   86606             :  * but delete the valid objects.  
   86607             :  */
   86608             : void
   86609           0 : SgAttributeSpecificationStatement::clearMemoryPool( )
   86610             :    {
   86611             :   // printf ("Inside of SgAttributeSpecificationStatement::clearMemoryPool() \n");
   86612             : 
   86613           0 :      SgAttributeSpecificationStatement* pointer = NULL, *tempPointer = NULL;
   86614           0 :      std::vector < unsigned char* > :: const_iterator block;
   86615           0 :      if ( SgAttributeSpecificationStatement::pools.empty() == false )
   86616             :         {
   86617           0 :           block = SgAttributeSpecificationStatement::pools.begin() ;
   86618           0 :           SgAttributeSpecificationStatement::next_node = (SgAttributeSpecificationStatement*) (*block);
   86619             : 
   86620           0 :           while ( block != SgAttributeSpecificationStatement::pools.end() )
   86621             :              {
   86622           0 :                pointer = (SgAttributeSpecificationStatement*) (*block);
   86623           0 :                if ( tempPointer != NULL )
   86624             :                   {
   86625           0 :                     tempPointer->set_freepointer(pointer);
   86626             :                   }
   86627           0 :                for (unsigned i = 0; i < SgAttributeSpecificationStatement::pool_size - 1; ++i)
   86628             :                   {
   86629           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   86630             :                   }
   86631           0 :                 pointer[SgAttributeSpecificationStatement::pool_size-1].set_freepointer(NULL);
   86632           0 :                 tempPointer = &(pointer[SgAttributeSpecificationStatement::pool_size-1]);
   86633           0 :                 ++block;
   86634             :              }
   86635             :         }
   86636           0 :    }
   86637             : 
   86638           5 : void SgAttributeSpecificationStatement::deleteMemoryPool() {
   86639           5 :   for (auto p: SgAttributeSpecificationStatement::pools) {
   86640           0 :     ROSE_FREE(p);
   86641             :   }
   86642           5 :   SgAttributeSpecificationStatement::next_node = nullptr;
   86643           5 :   SgAttributeSpecificationStatement::pools.clear();
   86644           5 : }
   86645             : 
   86646             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   86647             : //                 reading multiple binary files to for a single AST.
   86648             : /////////// new version ////////////////////////////////
   86649             : //############################################################################
   86650             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   86651             : void
   86652           2 : SgAttributeSpecificationStatement::extendMemoryPoolForFileIO( )
   86653             :   {
   86654           2 :     size_t blockIndex = SgAttributeSpecificationStatement::pools.size();
   86655           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAttributeSpecificationStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAttributeSpecificationStatement);
   86656             : 
   86657           2 :     while ( (blockIndex * SgAttributeSpecificationStatement::pool_size) < newPoolSize)
   86658             :       {
   86659             : #if ROSE_ALLOC_TRACE
   86660             :         if (blockIndex > 0) {
   86661             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAttributeSpecificationStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAttributeSpecificationStatement) = %" PRIuPTR " SgAttributeSpecificationStatement::pool_size = %d \n",
   86662             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAttributeSpecificationStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAttributeSpecificationStatement),SgAttributeSpecificationStatement::pool_size);
   86663             :         }
   86664             : #endif
   86665             : 
   86666           0 :         SgAttributeSpecificationStatement * pointer = (SgAttributeSpecificationStatement*) ROSE_MALLOC ( SgAttributeSpecificationStatement::pool_size * sizeof(SgAttributeSpecificationStatement) );
   86667           0 :         assert( pointer != NULL );
   86668             : #if ROSE_ALLOC_MEMSET == 1
   86669             :         memset(pointer, 0x00, SgAttributeSpecificationStatement::pool_size * sizeof(SgAttributeSpecificationStatement));
   86670             : #elif ROSE_ALLOC_MEMSET == 2
   86671             :         memset(pointer, 0xCC, SgAttributeSpecificationStatement::pool_size * sizeof(SgAttributeSpecificationStatement));
   86672             : #endif
   86673           0 :         SgAttributeSpecificationStatement::pools.push_back( (unsigned char*)(pointer) );
   86674           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAttributeSpecificationStatement::pool_size * sizeof(SgAttributeSpecificationStatement), V_SgAttributeSpecificationStatement ) );
   86675             : 
   86676           0 :         if ( SgAttributeSpecificationStatement::next_node != NULL ) {
   86677           0 :           if ( blockIndex > 0 ) {
   86678           0 :             SgAttributeSpecificationStatement * blkptr = (SgAttributeSpecificationStatement*)(SgAttributeSpecificationStatement::pools[blockIndex-1]);
   86679           0 :             blkptr[ SgAttributeSpecificationStatement::pool_size - 1 ].set_freepointer(pointer);
   86680             :           }
   86681             :         } else {
   86682           0 :           SgAttributeSpecificationStatement::next_node = pointer;
   86683             :         }
   86684             : 
   86685           0 :         for (unsigned i = 0; i < SgAttributeSpecificationStatement::pool_size-1; ++i)
   86686             :            {
   86687           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   86688             :            }
   86689           0 :         pointer[ SgAttributeSpecificationStatement::pool_size -1 ].set_freepointer(NULL);
   86690             : 
   86691           0 :         blockIndex++;
   86692             :       }
   86693           2 :   }
   86694             : 
   86695             : //############################################################################
   86696             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   86697             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   86698             :  * not compressed. However, that stuff is not yet implemented! 
   86699             :  */
   86700             : unsigned long
   86701           0 : SgAttributeSpecificationStatement::getNumberOfLastValidPointer()
   86702             :    {
   86703           0 :       SgAttributeSpecificationStatement* testPointer = (SgAttributeSpecificationStatement*)(SgAttributeSpecificationStatement::pools.back());
   86704           0 :       unsigned long localIndex = SgAttributeSpecificationStatement::pool_size - 1;
   86705           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   86706             :          {
   86707           0 :            localIndex--;
   86708             :          }
   86709           0 :       return (localIndex + SgAttributeSpecificationStatement::pool_size * (SgAttributeSpecificationStatement::pools.size()-1));
   86710             :    }
   86711             : 
   86712             : //############################################################################
   86713             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   86714             :  * memory pool and initializes the data member in class SgAttributeSpecificationStatementStroageClass
   86715             :  * from its counterpart of SgAttributeSpecificationStatement. The return value is just for checking, 
   86716             :  * that the whole StorageClassArray is initialized!
   86717             :  */
   86718             : unsigned long
   86719           0 : SgAttributeSpecificationStatement::initializeStorageClassArray( SgAttributeSpecificationStatementStorageClass *storageArray )
   86720             :    {
   86721           0 :      unsigned long storageCounter = 0;
   86722           0 :      std::vector < unsigned char* > :: const_iterator block = SgAttributeSpecificationStatement::pools.begin();
   86723           0 :      SgAttributeSpecificationStatement* pointer = NULL;
   86724           0 :      while ( block != SgAttributeSpecificationStatement::pools.end() ) {
   86725           0 :           pointer = (SgAttributeSpecificationStatement*) (*block);
   86726           0 :           for ( unsigned i = 0; i < SgAttributeSpecificationStatement::pool_size; ++i ) {
   86727           0 :                if ( pointer->get_freepointer() != NULL ) {
   86728           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   86729           0 :                  storageArray++;
   86730           0 :                  storageCounter++;
   86731             :                }
   86732           0 :                pointer++;
   86733             :              }
   86734           0 :            block++;
   86735             :         }
   86736           0 :      return storageCounter;
   86737             :    }
   86738             : 
   86739             : /* #line 86740 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   86740             : 
   86741             : 
   86742             : 
   86743             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   86744             : 
   86745             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   86746             : 
   86747             : //############################################################################
   86748             : /* JH (02/02/2006) Constructor of the IR node SgFormatStatement that takes its 
   86749             :  * corresponding StorageClass as parameter
   86750             :  */
   86751           0 : SgFormatStatement :: SgFormatStatement ( const SgFormatStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   86752             :    {
   86753             : 
   86754             : 
   86755             : /* #line 86756 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   86756             : 
   86757           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   86758           0 :      p_format_item_list =  (SgFormatItemList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_format_item_list) );
   86759             : 
   86760             : 
   86761             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   86762             : 
   86763             : 
   86764           0 :    }
   86765             : 
   86766             : //############################################################################
   86767             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   86768             :  * within the working AST. 
   86769             :  */
   86770           0 : SgFormatStatement * SgFormatStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   86771           0 :      SgFormatStatement* returnPointer = NULL;
   86772           0 :      if ( globalIndex != 0 )
   86773             :         {
   86774             : 
   86775             : #if FILE_IO_EXTRA_CHECK
   86776           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFormatStatement ) ) <= globalIndex ) ;
   86777           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFormatStatement + 1 ) ) );
   86778             : #endif
   86779           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFormatStatement )  
   86780           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFormatStatement );
   86781           0 :           unsigned long positionInPool = localIndex % SgFormatStatement::pool_size;
   86782           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFormatStatement::pool_size;
   86783             : 
   86784             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   86785             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   86786             : 
   86787           0 :           returnPointer = &( ( (SgFormatStatement*)(SgFormatStatement::pools[memoryBlock]) ) [positionInPool]) ;
   86788             : 
   86789           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   86790             :         }
   86791           0 :      return returnPointer ;
   86792             :    }
   86793             : 
   86794             : //############################################################################
   86795             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   86796             :   for the AST with the index astIndex
   86797             : */
   86798           0 : SgFormatStatement * SgFormatStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   86799           0 :      SgFormatStatement* returnPointer = NULL;
   86800           0 :      if ( globalIndex != 0 )
   86801             :         {
   86802             : 
   86803             : #if FILE_IO_EXTRA_CHECK
   86804           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFormatStatement ) ) <= globalIndex ) ;
   86805           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFormatStatement + 1 ) ) );
   86806             : #endif
   86807           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFormatStatement )
   86808           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFormatStatement );
   86809           0 :           unsigned long positionInPool = localIndex % SgFormatStatement::pool_size ;
   86810           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFormatStatement::pool_size ;
   86811             : 
   86812             : #if FILE_IO_EXTRA_CHECK
   86813             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   86814             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   86815             : #endif
   86816             : 
   86817           0 :           returnPointer = &( ( (SgFormatStatement*)(SgFormatStatement::pools[memoryBlock]) ) [positionInPool]) ;
   86818             : 
   86819             : #if FILE_IO_EXTRA_CHECK
   86820           0 :           assert ( returnPointer != NULL ) ;
   86821             : #endif
   86822             :         }
   86823           0 :      return returnPointer ;
   86824             :    }
   86825             : 
   86826             : //############################################################################
   86827             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   86828             :  * pool size! We set for every valid object in the memory pool the freepointer
   86829             :  * to the global index and increase the global index afterwards. For all the 
   86830             :  * invalid objects (means address ranges within the memory pool that were not
   86831             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   86832             :  * distinguish valid from invalid objects! 
   86833             :  */
   86834             : unsigned long
   86835           5 : SgFormatStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   86836             :    {
   86837           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   86838           5 :      SgFormatStatement* pointer = NULL;
   86839           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   86840           5 :      std::vector < unsigned char* > :: const_iterator block;
   86841           5 :      for ( block = SgFormatStatement::pools.begin(); block != SgFormatStatement::pools.end() ; ++block )
   86842             :         {
   86843           0 :           pointer = (SgFormatStatement*)(*block);
   86844           0 :           for (unsigned i = 0; i < SgFormatStatement::pool_size; ++i )
   86845             :              {
   86846             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   86847             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   86848             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   86849             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   86850             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   86851             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   86852             :             // properly; so this will have to be checked next.
   86853             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   86854             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   86855           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   86856             :                   {
   86857           0 :                     pointer[i].set_freepointer((SgFormatStatement*)(globalIndex));
   86858           0 :                     globalIndex++;
   86859             :                   }
   86860             :                else
   86861             :                   {
   86862           0 :                     pointer[i].set_freepointer(NULL);
   86863             :                   }
   86864             :               }
   86865             :         }
   86866           5 :      return globalIndex;
   86867             :    }
   86868             : 
   86869             : //############################################################################
   86870             : // JH (01/14/2006)
   86871             : void
   86872           5 : SgFormatStatement::resetValidFreepointers( )
   86873             :    {
   86874           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   86875           5 :      SgFormatStatement* pointer = NULL;
   86876           5 :      std::vector < unsigned char* > :: const_iterator block;
   86877           5 :      SgFormatStatement* pointerOfLinkedList = NULL;
   86878           5 :      for ( block = SgFormatStatement::pools.begin(); block != SgFormatStatement::pools.end() ; ++block )
   86879             :         {
   86880           0 :           pointer = (SgFormatStatement*)(*block);
   86881           0 :           for (unsigned i = 0; i < SgFormatStatement::pool_size; ++i )
   86882             :              {
   86883             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   86884             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   86885             :             // memory blocks!.
   86886           0 :                if ( pointer[i].get_freepointer() != NULL )
   86887             :                   {
   86888           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   86889             :                   }
   86890             :                else
   86891             :                   {
   86892           0 :                     if ( pointerOfLinkedList == NULL )
   86893             :                        {
   86894           0 :                          SgFormatStatement::next_node = &(pointer[i]);
   86895             :                        }
   86896             :                     else
   86897             :                        {
   86898             :                       // printf ("In SgFormatStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   86899           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   86900             :                        }
   86901             :                     pointerOfLinkedList = &(pointer[i]);
   86902             :                   }
   86903             :               }
   86904             :         }
   86905             : 
   86906           5 :      if ( pointerOfLinkedList != NULL )
   86907             :         {
   86908             :        // printf ("In SgFormatStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   86909           0 :           pointerOfLinkedList->set_freepointer(NULL);
   86910             :        // DQ (6/6/2010): Temporary debugging...
   86911             :        //   ROSE_ASSERT(false);
   86912             :         }
   86913             : 
   86914           5 :      return ;
   86915             :    }
   86916             : 
   86917             : //############################################################################
   86918             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   86919             :  * within the memory pool and resets the freepointers, in order to achieve a 
   86920             :  * linked list, that has no jumps and starts at the beginning! This function 
   86921             :  * does not extend the memory pool, since we do not delete any memory blocks,
   86922             :  * but delete the valid objects.  
   86923             :  */
   86924             : void
   86925           0 : SgFormatStatement::clearMemoryPool( )
   86926             :    {
   86927             :   // printf ("Inside of SgFormatStatement::clearMemoryPool() \n");
   86928             : 
   86929           0 :      SgFormatStatement* pointer = NULL, *tempPointer = NULL;
   86930           0 :      std::vector < unsigned char* > :: const_iterator block;
   86931           0 :      if ( SgFormatStatement::pools.empty() == false )
   86932             :         {
   86933           0 :           block = SgFormatStatement::pools.begin() ;
   86934           0 :           SgFormatStatement::next_node = (SgFormatStatement*) (*block);
   86935             : 
   86936           0 :           while ( block != SgFormatStatement::pools.end() )
   86937             :              {
   86938           0 :                pointer = (SgFormatStatement*) (*block);
   86939           0 :                if ( tempPointer != NULL )
   86940             :                   {
   86941           0 :                     tempPointer->set_freepointer(pointer);
   86942             :                   }
   86943           0 :                for (unsigned i = 0; i < SgFormatStatement::pool_size - 1; ++i)
   86944             :                   {
   86945           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   86946             :                   }
   86947           0 :                 pointer[SgFormatStatement::pool_size-1].set_freepointer(NULL);
   86948           0 :                 tempPointer = &(pointer[SgFormatStatement::pool_size-1]);
   86949           0 :                 ++block;
   86950             :              }
   86951             :         }
   86952           0 :    }
   86953             : 
   86954           5 : void SgFormatStatement::deleteMemoryPool() {
   86955           5 :   for (auto p: SgFormatStatement::pools) {
   86956           0 :     ROSE_FREE(p);
   86957             :   }
   86958           5 :   SgFormatStatement::next_node = nullptr;
   86959           5 :   SgFormatStatement::pools.clear();
   86960           5 : }
   86961             : 
   86962             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   86963             : //                 reading multiple binary files to for a single AST.
   86964             : /////////// new version ////////////////////////////////
   86965             : //############################################################################
   86966             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   86967             : void
   86968           2 : SgFormatStatement::extendMemoryPoolForFileIO( )
   86969             :   {
   86970           2 :     size_t blockIndex = SgFormatStatement::pools.size();
   86971           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatStatement);
   86972             : 
   86973           2 :     while ( (blockIndex * SgFormatStatement::pool_size) < newPoolSize)
   86974             :       {
   86975             : #if ROSE_ALLOC_TRACE
   86976             :         if (blockIndex > 0) {
   86977             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatStatement) = %" PRIuPTR " SgFormatStatement::pool_size = %d \n",
   86978             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFormatStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFormatStatement),SgFormatStatement::pool_size);
   86979             :         }
   86980             : #endif
   86981             : 
   86982           0 :         SgFormatStatement * pointer = (SgFormatStatement*) ROSE_MALLOC ( SgFormatStatement::pool_size * sizeof(SgFormatStatement) );
   86983           0 :         assert( pointer != NULL );
   86984             : #if ROSE_ALLOC_MEMSET == 1
   86985             :         memset(pointer, 0x00, SgFormatStatement::pool_size * sizeof(SgFormatStatement));
   86986             : #elif ROSE_ALLOC_MEMSET == 2
   86987             :         memset(pointer, 0xCC, SgFormatStatement::pool_size * sizeof(SgFormatStatement));
   86988             : #endif
   86989           0 :         SgFormatStatement::pools.push_back( (unsigned char*)(pointer) );
   86990           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFormatStatement::pool_size * sizeof(SgFormatStatement), V_SgFormatStatement ) );
   86991             : 
   86992           0 :         if ( SgFormatStatement::next_node != NULL ) {
   86993           0 :           if ( blockIndex > 0 ) {
   86994           0 :             SgFormatStatement * blkptr = (SgFormatStatement*)(SgFormatStatement::pools[blockIndex-1]);
   86995           0 :             blkptr[ SgFormatStatement::pool_size - 1 ].set_freepointer(pointer);
   86996             :           }
   86997             :         } else {
   86998           0 :           SgFormatStatement::next_node = pointer;
   86999             :         }
   87000             : 
   87001           0 :         for (unsigned i = 0; i < SgFormatStatement::pool_size-1; ++i)
   87002             :            {
   87003           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   87004             :            }
   87005           0 :         pointer[ SgFormatStatement::pool_size -1 ].set_freepointer(NULL);
   87006             : 
   87007           0 :         blockIndex++;
   87008             :       }
   87009           2 :   }
   87010             : 
   87011             : //############################################################################
   87012             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   87013             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   87014             :  * not compressed. However, that stuff is not yet implemented! 
   87015             :  */
   87016             : unsigned long
   87017           0 : SgFormatStatement::getNumberOfLastValidPointer()
   87018             :    {
   87019           0 :       SgFormatStatement* testPointer = (SgFormatStatement*)(SgFormatStatement::pools.back());
   87020           0 :       unsigned long localIndex = SgFormatStatement::pool_size - 1;
   87021           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   87022             :          {
   87023           0 :            localIndex--;
   87024             :          }
   87025           0 :       return (localIndex + SgFormatStatement::pool_size * (SgFormatStatement::pools.size()-1));
   87026             :    }
   87027             : 
   87028             : //############################################################################
   87029             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   87030             :  * memory pool and initializes the data member in class SgFormatStatementStroageClass
   87031             :  * from its counterpart of SgFormatStatement. The return value is just for checking, 
   87032             :  * that the whole StorageClassArray is initialized!
   87033             :  */
   87034             : unsigned long
   87035           0 : SgFormatStatement::initializeStorageClassArray( SgFormatStatementStorageClass *storageArray )
   87036             :    {
   87037           0 :      unsigned long storageCounter = 0;
   87038           0 :      std::vector < unsigned char* > :: const_iterator block = SgFormatStatement::pools.begin();
   87039           0 :      SgFormatStatement* pointer = NULL;
   87040           0 :      while ( block != SgFormatStatement::pools.end() ) {
   87041           0 :           pointer = (SgFormatStatement*) (*block);
   87042           0 :           for ( unsigned i = 0; i < SgFormatStatement::pool_size; ++i ) {
   87043           0 :                if ( pointer->get_freepointer() != NULL ) {
   87044           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   87045           0 :                  storageArray++;
   87046           0 :                  storageCounter++;
   87047             :                }
   87048           0 :                pointer++;
   87049             :              }
   87050           0 :            block++;
   87051             :         }
   87052           0 :      return storageCounter;
   87053             :    }
   87054             : 
   87055             : /* #line 87056 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   87056             : 
   87057             : 
   87058             : 
   87059             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   87060             : 
   87061             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   87062             : 
   87063             : //############################################################################
   87064             : /* JH (02/02/2006) Constructor of the IR node SgTemplateDeclaration that takes its 
   87065             :  * corresponding StorageClass as parameter
   87066             :  */
   87067           0 : SgTemplateDeclaration :: SgTemplateDeclaration ( const SgTemplateDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   87068             :    {
   87069             : 
   87070             : 
   87071             : /* #line 87072 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   87072             : 
   87073           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   87074           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
   87075           0 :      p_string = SgName ( storageSource.storageOf_string ) ;
   87076           0 :      p_template_kind = storageSource.storageOf_template_kind ;
   87077           0 :      p_templateParameters = storageSource.storageOf_templateParameters.rebuildDataStoredInEasyStorageClass() ;
   87078           0 :      SgTemplateParameterPtrList::iterator i_templateParameters = p_templateParameters.begin() ; 
   87079           0 :      for ( ; i_templateParameters != p_templateParameters.end(); ++i_templateParameters ) 
   87080             :         {
   87081           0 :           (*i_templateParameters) = (SgTemplateParameterPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateParameters) ) );
   87082             :         }
   87083           0 :      p_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scope) );
   87084           0 :      p_nonreal_decl_scope =  (SgDeclarationScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nonreal_decl_scope) );
   87085             : 
   87086             : 
   87087             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   87088             : 
   87089             : 
   87090           0 :    }
   87091             : 
   87092             : //############################################################################
   87093             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   87094             :  * within the working AST. 
   87095             :  */
   87096           0 : SgTemplateDeclaration * SgTemplateDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   87097           0 :      SgTemplateDeclaration* returnPointer = NULL;
   87098           0 :      if ( globalIndex != 0 )
   87099             :         {
   87100             : 
   87101             : #if FILE_IO_EXTRA_CHECK
   87102           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateDeclaration ) ) <= globalIndex ) ;
   87103           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateDeclaration + 1 ) ) );
   87104             : #endif
   87105           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateDeclaration )  
   87106           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateDeclaration );
   87107           0 :           unsigned long positionInPool = localIndex % SgTemplateDeclaration::pool_size;
   87108           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateDeclaration::pool_size;
   87109             : 
   87110             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   87111             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   87112             : 
   87113           0 :           returnPointer = &( ( (SgTemplateDeclaration*)(SgTemplateDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   87114             : 
   87115           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   87116             :         }
   87117           0 :      return returnPointer ;
   87118             :    }
   87119             : 
   87120             : //############################################################################
   87121             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   87122             :   for the AST with the index astIndex
   87123             : */
   87124           0 : SgTemplateDeclaration * SgTemplateDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   87125           0 :      SgTemplateDeclaration* returnPointer = NULL;
   87126           0 :      if ( globalIndex != 0 )
   87127             :         {
   87128             : 
   87129             : #if FILE_IO_EXTRA_CHECK
   87130           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateDeclaration ) ) <= globalIndex ) ;
   87131           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateDeclaration + 1 ) ) );
   87132             : #endif
   87133           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateDeclaration )
   87134           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateDeclaration );
   87135           0 :           unsigned long positionInPool = localIndex % SgTemplateDeclaration::pool_size ;
   87136           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateDeclaration::pool_size ;
   87137             : 
   87138             : #if FILE_IO_EXTRA_CHECK
   87139             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   87140             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   87141             : #endif
   87142             : 
   87143           0 :           returnPointer = &( ( (SgTemplateDeclaration*)(SgTemplateDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   87144             : 
   87145             : #if FILE_IO_EXTRA_CHECK
   87146           0 :           assert ( returnPointer != NULL ) ;
   87147             : #endif
   87148             :         }
   87149           0 :      return returnPointer ;
   87150             :    }
   87151             : 
   87152             : //############################################################################
   87153             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   87154             :  * pool size! We set for every valid object in the memory pool the freepointer
   87155             :  * to the global index and increase the global index afterwards. For all the 
   87156             :  * invalid objects (means address ranges within the memory pool that were not
   87157             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   87158             :  * distinguish valid from invalid objects! 
   87159             :  */
   87160             : unsigned long
   87161           5 : SgTemplateDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   87162             :    {
   87163           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   87164           5 :      SgTemplateDeclaration* pointer = NULL;
   87165           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   87166           5 :      std::vector < unsigned char* > :: const_iterator block;
   87167           5 :      for ( block = SgTemplateDeclaration::pools.begin(); block != SgTemplateDeclaration::pools.end() ; ++block )
   87168             :         {
   87169           0 :           pointer = (SgTemplateDeclaration*)(*block);
   87170           0 :           for (unsigned i = 0; i < SgTemplateDeclaration::pool_size; ++i )
   87171             :              {
   87172             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   87173             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   87174             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   87175             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   87176             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   87177             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   87178             :             // properly; so this will have to be checked next.
   87179             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   87180             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   87181           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   87182             :                   {
   87183           0 :                     pointer[i].set_freepointer((SgTemplateDeclaration*)(globalIndex));
   87184           0 :                     globalIndex++;
   87185             :                   }
   87186             :                else
   87187             :                   {
   87188           0 :                     pointer[i].set_freepointer(NULL);
   87189             :                   }
   87190             :               }
   87191             :         }
   87192           5 :      return globalIndex;
   87193             :    }
   87194             : 
   87195             : //############################################################################
   87196             : // JH (01/14/2006)
   87197             : void
   87198           5 : SgTemplateDeclaration::resetValidFreepointers( )
   87199             :    {
   87200           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   87201           5 :      SgTemplateDeclaration* pointer = NULL;
   87202           5 :      std::vector < unsigned char* > :: const_iterator block;
   87203           5 :      SgTemplateDeclaration* pointerOfLinkedList = NULL;
   87204           5 :      for ( block = SgTemplateDeclaration::pools.begin(); block != SgTemplateDeclaration::pools.end() ; ++block )
   87205             :         {
   87206           0 :           pointer = (SgTemplateDeclaration*)(*block);
   87207           0 :           for (unsigned i = 0; i < SgTemplateDeclaration::pool_size; ++i )
   87208             :              {
   87209             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   87210             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   87211             :             // memory blocks!.
   87212           0 :                if ( pointer[i].get_freepointer() != NULL )
   87213             :                   {
   87214           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   87215             :                   }
   87216             :                else
   87217             :                   {
   87218           0 :                     if ( pointerOfLinkedList == NULL )
   87219             :                        {
   87220           0 :                          SgTemplateDeclaration::next_node = &(pointer[i]);
   87221             :                        }
   87222             :                     else
   87223             :                        {
   87224             :                       // printf ("In SgTemplateDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   87225           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   87226             :                        }
   87227             :                     pointerOfLinkedList = &(pointer[i]);
   87228             :                   }
   87229             :               }
   87230             :         }
   87231             : 
   87232           5 :      if ( pointerOfLinkedList != NULL )
   87233             :         {
   87234             :        // printf ("In SgTemplateDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   87235           0 :           pointerOfLinkedList->set_freepointer(NULL);
   87236             :        // DQ (6/6/2010): Temporary debugging...
   87237             :        //   ROSE_ASSERT(false);
   87238             :         }
   87239             : 
   87240           5 :      return ;
   87241             :    }
   87242             : 
   87243             : //############################################################################
   87244             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   87245             :  * within the memory pool and resets the freepointers, in order to achieve a 
   87246             :  * linked list, that has no jumps and starts at the beginning! This function 
   87247             :  * does not extend the memory pool, since we do not delete any memory blocks,
   87248             :  * but delete the valid objects.  
   87249             :  */
   87250             : void
   87251           0 : SgTemplateDeclaration::clearMemoryPool( )
   87252             :    {
   87253             :   // printf ("Inside of SgTemplateDeclaration::clearMemoryPool() \n");
   87254             : 
   87255           0 :      SgTemplateDeclaration* pointer = NULL, *tempPointer = NULL;
   87256           0 :      std::vector < unsigned char* > :: const_iterator block;
   87257           0 :      if ( SgTemplateDeclaration::pools.empty() == false )
   87258             :         {
   87259           0 :           block = SgTemplateDeclaration::pools.begin() ;
   87260           0 :           SgTemplateDeclaration::next_node = (SgTemplateDeclaration*) (*block);
   87261             : 
   87262           0 :           while ( block != SgTemplateDeclaration::pools.end() )
   87263             :              {
   87264           0 :                pointer = (SgTemplateDeclaration*) (*block);
   87265           0 :                if ( tempPointer != NULL )
   87266             :                   {
   87267           0 :                     tempPointer->set_freepointer(pointer);
   87268             :                   }
   87269           0 :                for (unsigned i = 0; i < SgTemplateDeclaration::pool_size - 1; ++i)
   87270             :                   {
   87271           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   87272             :                   }
   87273           0 :                 pointer[SgTemplateDeclaration::pool_size-1].set_freepointer(NULL);
   87274           0 :                 tempPointer = &(pointer[SgTemplateDeclaration::pool_size-1]);
   87275           0 :                 ++block;
   87276             :              }
   87277             :         }
   87278           0 :    }
   87279             : 
   87280           5 : void SgTemplateDeclaration::deleteMemoryPool() {
   87281           5 :   for (auto p: SgTemplateDeclaration::pools) {
   87282           0 :     ROSE_FREE(p);
   87283             :   }
   87284           5 :   SgTemplateDeclaration::next_node = nullptr;
   87285           5 :   SgTemplateDeclaration::pools.clear();
   87286           5 : }
   87287             : 
   87288             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   87289             : //                 reading multiple binary files to for a single AST.
   87290             : /////////// new version ////////////////////////////////
   87291             : //############################################################################
   87292             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   87293             : void
   87294           2 : SgTemplateDeclaration::extendMemoryPoolForFileIO( )
   87295             :   {
   87296           2 :     size_t blockIndex = SgTemplateDeclaration::pools.size();
   87297           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateDeclaration);
   87298             : 
   87299           2 :     while ( (blockIndex * SgTemplateDeclaration::pool_size) < newPoolSize)
   87300             :       {
   87301             : #if ROSE_ALLOC_TRACE
   87302             :         if (blockIndex > 0) {
   87303             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateDeclaration) = %" PRIuPTR " SgTemplateDeclaration::pool_size = %d \n",
   87304             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateDeclaration),SgTemplateDeclaration::pool_size);
   87305             :         }
   87306             : #endif
   87307             : 
   87308           0 :         SgTemplateDeclaration * pointer = (SgTemplateDeclaration*) ROSE_MALLOC ( SgTemplateDeclaration::pool_size * sizeof(SgTemplateDeclaration) );
   87309           0 :         assert( pointer != NULL );
   87310             : #if ROSE_ALLOC_MEMSET == 1
   87311             :         memset(pointer, 0x00, SgTemplateDeclaration::pool_size * sizeof(SgTemplateDeclaration));
   87312             : #elif ROSE_ALLOC_MEMSET == 2
   87313             :         memset(pointer, 0xCC, SgTemplateDeclaration::pool_size * sizeof(SgTemplateDeclaration));
   87314             : #endif
   87315           0 :         SgTemplateDeclaration::pools.push_back( (unsigned char*)(pointer) );
   87316           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateDeclaration::pool_size * sizeof(SgTemplateDeclaration), V_SgTemplateDeclaration ) );
   87317             : 
   87318           0 :         if ( SgTemplateDeclaration::next_node != NULL ) {
   87319           0 :           if ( blockIndex > 0 ) {
   87320           0 :             SgTemplateDeclaration * blkptr = (SgTemplateDeclaration*)(SgTemplateDeclaration::pools[blockIndex-1]);
   87321           0 :             blkptr[ SgTemplateDeclaration::pool_size - 1 ].set_freepointer(pointer);
   87322             :           }
   87323             :         } else {
   87324           0 :           SgTemplateDeclaration::next_node = pointer;
   87325             :         }
   87326             : 
   87327           0 :         for (unsigned i = 0; i < SgTemplateDeclaration::pool_size-1; ++i)
   87328             :            {
   87329           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   87330             :            }
   87331           0 :         pointer[ SgTemplateDeclaration::pool_size -1 ].set_freepointer(NULL);
   87332             : 
   87333           0 :         blockIndex++;
   87334             :       }
   87335           2 :   }
   87336             : 
   87337             : //############################################################################
   87338             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   87339             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   87340             :  * not compressed. However, that stuff is not yet implemented! 
   87341             :  */
   87342             : unsigned long
   87343           0 : SgTemplateDeclaration::getNumberOfLastValidPointer()
   87344             :    {
   87345           0 :       SgTemplateDeclaration* testPointer = (SgTemplateDeclaration*)(SgTemplateDeclaration::pools.back());
   87346           0 :       unsigned long localIndex = SgTemplateDeclaration::pool_size - 1;
   87347           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   87348             :          {
   87349           0 :            localIndex--;
   87350             :          }
   87351           0 :       return (localIndex + SgTemplateDeclaration::pool_size * (SgTemplateDeclaration::pools.size()-1));
   87352             :    }
   87353             : 
   87354             : //############################################################################
   87355             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   87356             :  * memory pool and initializes the data member in class SgTemplateDeclarationStroageClass
   87357             :  * from its counterpart of SgTemplateDeclaration. The return value is just for checking, 
   87358             :  * that the whole StorageClassArray is initialized!
   87359             :  */
   87360             : unsigned long
   87361           0 : SgTemplateDeclaration::initializeStorageClassArray( SgTemplateDeclarationStorageClass *storageArray )
   87362             :    {
   87363           0 :      unsigned long storageCounter = 0;
   87364           0 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateDeclaration::pools.begin();
   87365           0 :      SgTemplateDeclaration* pointer = NULL;
   87366           0 :      while ( block != SgTemplateDeclaration::pools.end() ) {
   87367           0 :           pointer = (SgTemplateDeclaration*) (*block);
   87368           0 :           for ( unsigned i = 0; i < SgTemplateDeclaration::pool_size; ++i ) {
   87369           0 :                if ( pointer->get_freepointer() != NULL ) {
   87370           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   87371           0 :                  storageArray++;
   87372           0 :                  storageCounter++;
   87373             :                }
   87374           0 :                pointer++;
   87375             :              }
   87376           0 :            block++;
   87377             :         }
   87378           0 :      return storageCounter;
   87379             :    }
   87380             : 
   87381             : /* #line 87382 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   87382             : 
   87383             : 
   87384             : 
   87385             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   87386             : 
   87387             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   87388             : 
   87389             : //############################################################################
   87390             : /* JH (02/02/2006) Constructor of the IR node SgTemplateInstantiationDirectiveStatement that takes its 
   87391             :  * corresponding StorageClass as parameter
   87392             :  */
   87393         124 : SgTemplateInstantiationDirectiveStatement :: SgTemplateInstantiationDirectiveStatement ( const SgTemplateInstantiationDirectiveStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   87394             :    {
   87395             : 
   87396             : 
   87397             : /* #line 87398 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   87398             : 
   87399         124 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   87400         124 :      p_declaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
   87401         124 :      p_do_not_instantiate = storageSource.storageOf_do_not_instantiate ;
   87402             : 
   87403             : 
   87404             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   87405             : 
   87406             : 
   87407         124 :    }
   87408             : 
   87409             : //############################################################################
   87410             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   87411             :  * within the working AST. 
   87412             :  */
   87413         744 : SgTemplateInstantiationDirectiveStatement * SgTemplateInstantiationDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   87414         744 :      SgTemplateInstantiationDirectiveStatement* returnPointer = NULL;
   87415         744 :      if ( globalIndex != 0 )
   87416             :         {
   87417             : 
   87418             : #if FILE_IO_EXTRA_CHECK
   87419         744 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateInstantiationDirectiveStatement ) ) <= globalIndex ) ;
   87420         744 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationDirectiveStatement + 1 ) ) );
   87421             : #endif
   87422         744 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationDirectiveStatement )  
   87423         744 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateInstantiationDirectiveStatement );
   87424         744 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationDirectiveStatement::pool_size;
   87425         744 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationDirectiveStatement::pool_size;
   87426             : 
   87427             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   87428             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   87429             : 
   87430         744 :           returnPointer = &( ( (SgTemplateInstantiationDirectiveStatement*)(SgTemplateInstantiationDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   87431             : 
   87432         744 :           ROSE_ASSERT( returnPointer != NULL ) ;
   87433             :         }
   87434         744 :      return returnPointer ;
   87435             :    }
   87436             : 
   87437             : //############################################################################
   87438             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   87439             :   for the AST with the index astIndex
   87440             : */
   87441           0 : SgTemplateInstantiationDirectiveStatement * SgTemplateInstantiationDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   87442           0 :      SgTemplateInstantiationDirectiveStatement* returnPointer = NULL;
   87443           0 :      if ( globalIndex != 0 )
   87444             :         {
   87445             : 
   87446             : #if FILE_IO_EXTRA_CHECK
   87447           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateInstantiationDirectiveStatement ) ) <= globalIndex ) ;
   87448           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationDirectiveStatement + 1 ) ) );
   87449             : #endif
   87450           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationDirectiveStatement )
   87451           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateInstantiationDirectiveStatement );
   87452           0 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationDirectiveStatement::pool_size ;
   87453           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationDirectiveStatement::pool_size ;
   87454             : 
   87455             : #if FILE_IO_EXTRA_CHECK
   87456             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   87457             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   87458             : #endif
   87459             : 
   87460           0 :           returnPointer = &( ( (SgTemplateInstantiationDirectiveStatement*)(SgTemplateInstantiationDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   87461             : 
   87462             : #if FILE_IO_EXTRA_CHECK
   87463           0 :           assert ( returnPointer != NULL ) ;
   87464             : #endif
   87465             :         }
   87466           0 :      return returnPointer ;
   87467             :    }
   87468             : 
   87469             : //############################################################################
   87470             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   87471             :  * pool size! We set for every valid object in the memory pool the freepointer
   87472             :  * to the global index and increase the global index afterwards. For all the 
   87473             :  * invalid objects (means address ranges within the memory pool that were not
   87474             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   87475             :  * distinguish valid from invalid objects! 
   87476             :  */
   87477             : unsigned long
   87478           5 : SgTemplateInstantiationDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   87479             :    {
   87480           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   87481           5 :      SgTemplateInstantiationDirectiveStatement* pointer = NULL;
   87482           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   87483           5 :      std::vector < unsigned char* > :: const_iterator block;
   87484           6 :      for ( block = SgTemplateInstantiationDirectiveStatement::pools.begin(); block != SgTemplateInstantiationDirectiveStatement::pools.end() ; ++block )
   87485             :         {
   87486           1 :           pointer = (SgTemplateInstantiationDirectiveStatement*)(*block);
   87487        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationDirectiveStatement::pool_size; ++i )
   87488             :              {
   87489             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   87490             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   87491             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   87492             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   87493             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   87494             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   87495             :             // properly; so this will have to be checked next.
   87496             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   87497             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   87498        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   87499             :                   {
   87500         124 :                     pointer[i].set_freepointer((SgTemplateInstantiationDirectiveStatement*)(globalIndex));
   87501         124 :                     globalIndex++;
   87502             :                   }
   87503             :                else
   87504             :                   {
   87505        1876 :                     pointer[i].set_freepointer(NULL);
   87506             :                   }
   87507             :               }
   87508             :         }
   87509           5 :      return globalIndex;
   87510             :    }
   87511             : 
   87512             : //############################################################################
   87513             : // JH (01/14/2006)
   87514             : void
   87515           5 : SgTemplateInstantiationDirectiveStatement::resetValidFreepointers( )
   87516             :    {
   87517           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   87518           5 :      SgTemplateInstantiationDirectiveStatement* pointer = NULL;
   87519           5 :      std::vector < unsigned char* > :: const_iterator block;
   87520           5 :      SgTemplateInstantiationDirectiveStatement* pointerOfLinkedList = NULL;
   87521           6 :      for ( block = SgTemplateInstantiationDirectiveStatement::pools.begin(); block != SgTemplateInstantiationDirectiveStatement::pools.end() ; ++block )
   87522             :         {
   87523           1 :           pointer = (SgTemplateInstantiationDirectiveStatement*)(*block);
   87524        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationDirectiveStatement::pool_size; ++i )
   87525             :              {
   87526             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   87527             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   87528             :             // memory blocks!.
   87529        2000 :                if ( pointer[i].get_freepointer() != NULL )
   87530             :                   {
   87531         124 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   87532             :                   }
   87533             :                else
   87534             :                   {
   87535        1876 :                     if ( pointerOfLinkedList == NULL )
   87536             :                        {
   87537           1 :                          SgTemplateInstantiationDirectiveStatement::next_node = &(pointer[i]);
   87538             :                        }
   87539             :                     else
   87540             :                        {
   87541             :                       // printf ("In SgTemplateInstantiationDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   87542        1875 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   87543             :                        }
   87544             :                     pointerOfLinkedList = &(pointer[i]);
   87545             :                   }
   87546             :               }
   87547             :         }
   87548             : 
   87549           5 :      if ( pointerOfLinkedList != NULL )
   87550             :         {
   87551             :        // printf ("In SgTemplateInstantiationDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   87552           1 :           pointerOfLinkedList->set_freepointer(NULL);
   87553             :        // DQ (6/6/2010): Temporary debugging...
   87554             :        //   ROSE_ASSERT(false);
   87555             :         }
   87556             : 
   87557           5 :      return ;
   87558             :    }
   87559             : 
   87560             : //############################################################################
   87561             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   87562             :  * within the memory pool and resets the freepointers, in order to achieve a 
   87563             :  * linked list, that has no jumps and starts at the beginning! This function 
   87564             :  * does not extend the memory pool, since we do not delete any memory blocks,
   87565             :  * but delete the valid objects.  
   87566             :  */
   87567             : void
   87568           0 : SgTemplateInstantiationDirectiveStatement::clearMemoryPool( )
   87569             :    {
   87570             :   // printf ("Inside of SgTemplateInstantiationDirectiveStatement::clearMemoryPool() \n");
   87571             : 
   87572           0 :      SgTemplateInstantiationDirectiveStatement* pointer = NULL, *tempPointer = NULL;
   87573           0 :      std::vector < unsigned char* > :: const_iterator block;
   87574           0 :      if ( SgTemplateInstantiationDirectiveStatement::pools.empty() == false )
   87575             :         {
   87576           0 :           block = SgTemplateInstantiationDirectiveStatement::pools.begin() ;
   87577           0 :           SgTemplateInstantiationDirectiveStatement::next_node = (SgTemplateInstantiationDirectiveStatement*) (*block);
   87578             : 
   87579           0 :           while ( block != SgTemplateInstantiationDirectiveStatement::pools.end() )
   87580             :              {
   87581           0 :                pointer = (SgTemplateInstantiationDirectiveStatement*) (*block);
   87582           0 :                if ( tempPointer != NULL )
   87583             :                   {
   87584           0 :                     tempPointer->set_freepointer(pointer);
   87585             :                   }
   87586           0 :                for (unsigned i = 0; i < SgTemplateInstantiationDirectiveStatement::pool_size - 1; ++i)
   87587             :                   {
   87588           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   87589             :                   }
   87590           0 :                 pointer[SgTemplateInstantiationDirectiveStatement::pool_size-1].set_freepointer(NULL);
   87591           0 :                 tempPointer = &(pointer[SgTemplateInstantiationDirectiveStatement::pool_size-1]);
   87592           0 :                 ++block;
   87593             :              }
   87594             :         }
   87595           0 :    }
   87596             : 
   87597           5 : void SgTemplateInstantiationDirectiveStatement::deleteMemoryPool() {
   87598           7 :   for (auto p: SgTemplateInstantiationDirectiveStatement::pools) {
   87599           2 :     ROSE_FREE(p);
   87600             :   }
   87601           5 :   SgTemplateInstantiationDirectiveStatement::next_node = nullptr;
   87602           5 :   SgTemplateInstantiationDirectiveStatement::pools.clear();
   87603           5 : }
   87604             : 
   87605             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   87606             : //                 reading multiple binary files to for a single AST.
   87607             : /////////// new version ////////////////////////////////
   87608             : //############################################################################
   87609             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   87610             : void
   87611           2 : SgTemplateInstantiationDirectiveStatement::extendMemoryPoolForFileIO( )
   87612             :   {
   87613           2 :     size_t blockIndex = SgTemplateInstantiationDirectiveStatement::pools.size();
   87614           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDirectiveStatement);
   87615             : 
   87616           3 :     while ( (blockIndex * SgTemplateInstantiationDirectiveStatement::pool_size) < newPoolSize)
   87617             :       {
   87618             : #if ROSE_ALLOC_TRACE
   87619             :         if (blockIndex > 0) {
   87620             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDirectiveStatement) = %" PRIuPTR " SgTemplateInstantiationDirectiveStatement::pool_size = %d \n",
   87621             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDirectiveStatement),SgTemplateInstantiationDirectiveStatement::pool_size);
   87622             :         }
   87623             : #endif
   87624             : 
   87625           1 :         SgTemplateInstantiationDirectiveStatement * pointer = (SgTemplateInstantiationDirectiveStatement*) ROSE_MALLOC ( SgTemplateInstantiationDirectiveStatement::pool_size * sizeof(SgTemplateInstantiationDirectiveStatement) );
   87626           1 :         assert( pointer != NULL );
   87627             : #if ROSE_ALLOC_MEMSET == 1
   87628             :         memset(pointer, 0x00, SgTemplateInstantiationDirectiveStatement::pool_size * sizeof(SgTemplateInstantiationDirectiveStatement));
   87629             : #elif ROSE_ALLOC_MEMSET == 2
   87630             :         memset(pointer, 0xCC, SgTemplateInstantiationDirectiveStatement::pool_size * sizeof(SgTemplateInstantiationDirectiveStatement));
   87631             : #endif
   87632           1 :         SgTemplateInstantiationDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
   87633           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateInstantiationDirectiveStatement::pool_size * sizeof(SgTemplateInstantiationDirectiveStatement), V_SgTemplateInstantiationDirectiveStatement ) );
   87634             : 
   87635           1 :         if ( SgTemplateInstantiationDirectiveStatement::next_node != NULL ) {
   87636           0 :           if ( blockIndex > 0 ) {
   87637           0 :             SgTemplateInstantiationDirectiveStatement * blkptr = (SgTemplateInstantiationDirectiveStatement*)(SgTemplateInstantiationDirectiveStatement::pools[blockIndex-1]);
   87638           0 :             blkptr[ SgTemplateInstantiationDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
   87639             :           }
   87640             :         } else {
   87641           1 :           SgTemplateInstantiationDirectiveStatement::next_node = pointer;
   87642             :         }
   87643             : 
   87644        2000 :         for (unsigned i = 0; i < SgTemplateInstantiationDirectiveStatement::pool_size-1; ++i)
   87645             :            {
   87646        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   87647             :            }
   87648           1 :         pointer[ SgTemplateInstantiationDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
   87649             : 
   87650           1 :         blockIndex++;
   87651             :       }
   87652           2 :   }
   87653             : 
   87654             : //############################################################################
   87655             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   87656             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   87657             :  * not compressed. However, that stuff is not yet implemented! 
   87658             :  */
   87659             : unsigned long
   87660           0 : SgTemplateInstantiationDirectiveStatement::getNumberOfLastValidPointer()
   87661             :    {
   87662           0 :       SgTemplateInstantiationDirectiveStatement* testPointer = (SgTemplateInstantiationDirectiveStatement*)(SgTemplateInstantiationDirectiveStatement::pools.back());
   87663           0 :       unsigned long localIndex = SgTemplateInstantiationDirectiveStatement::pool_size - 1;
   87664           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   87665             :          {
   87666           0 :            localIndex--;
   87667             :          }
   87668           0 :       return (localIndex + SgTemplateInstantiationDirectiveStatement::pool_size * (SgTemplateInstantiationDirectiveStatement::pools.size()-1));
   87669             :    }
   87670             : 
   87671             : //############################################################################
   87672             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   87673             :  * memory pool and initializes the data member in class SgTemplateInstantiationDirectiveStatementStroageClass
   87674             :  * from its counterpart of SgTemplateInstantiationDirectiveStatement. The return value is just for checking, 
   87675             :  * that the whole StorageClassArray is initialized!
   87676             :  */
   87677             : unsigned long
   87678           1 : SgTemplateInstantiationDirectiveStatement::initializeStorageClassArray( SgTemplateInstantiationDirectiveStatementStorageClass *storageArray )
   87679             :    {
   87680           1 :      unsigned long storageCounter = 0;
   87681           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateInstantiationDirectiveStatement::pools.begin();
   87682           1 :      SgTemplateInstantiationDirectiveStatement* pointer = NULL;
   87683           2 :      while ( block != SgTemplateInstantiationDirectiveStatement::pools.end() ) {
   87684           1 :           pointer = (SgTemplateInstantiationDirectiveStatement*) (*block);
   87685        2001 :           for ( unsigned i = 0; i < SgTemplateInstantiationDirectiveStatement::pool_size; ++i ) {
   87686        2000 :                if ( pointer->get_freepointer() != NULL ) {
   87687         124 :                  storageArray->pickOutIRNodeData (pointer) ;
   87688         124 :                  storageArray++;
   87689         124 :                  storageCounter++;
   87690             :                }
   87691        2000 :                pointer++;
   87692             :              }
   87693           1 :            block++;
   87694             :         }
   87695           1 :      return storageCounter;
   87696             :    }
   87697             : 
   87698             : /* #line 87699 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   87699             : 
   87700             : 
   87701             : 
   87702             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   87703             : 
   87704             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   87705             : 
   87706             : //############################################################################
   87707             : /* JH (02/02/2006) Constructor of the IR node SgUseStatement that takes its 
   87708             :  * corresponding StorageClass as parameter
   87709             :  */
   87710           0 : SgUseStatement :: SgUseStatement ( const SgUseStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   87711             :    {
   87712             : 
   87713             : 
   87714             : /* #line 87715 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   87715             : 
   87716           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   87717           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
   87718           0 :      p_only_option = storageSource.storageOf_only_option ;
   87719           0 :      p_module_nature = storageSource.storageOf_module_nature.rebuildDataStoredInEasyStorageClass() ;
   87720           0 :      p_rename_list = storageSource.storageOf_rename_list.rebuildDataStoredInEasyStorageClass() ;
   87721           0 :      SgRenamePairPtrList::iterator i_rename_list = p_rename_list.begin() ; 
   87722           0 :      for ( ; i_rename_list != p_rename_list.end(); ++i_rename_list ) 
   87723             :         {
   87724           0 :           (*i_rename_list) = (SgRenamePairPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_rename_list) ) );
   87725             :         }
   87726           0 :      p_module =  (SgModuleStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_module) );
   87727             : 
   87728             : 
   87729             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   87730             : 
   87731             : 
   87732           0 :    }
   87733             : 
   87734             : //############################################################################
   87735             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   87736             :  * within the working AST. 
   87737             :  */
   87738           0 : SgUseStatement * SgUseStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   87739           0 :      SgUseStatement* returnPointer = NULL;
   87740           0 :      if ( globalIndex != 0 )
   87741             :         {
   87742             : 
   87743             : #if FILE_IO_EXTRA_CHECK
   87744           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUseStatement ) ) <= globalIndex ) ;
   87745           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUseStatement + 1 ) ) );
   87746             : #endif
   87747           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUseStatement )  
   87748           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUseStatement );
   87749           0 :           unsigned long positionInPool = localIndex % SgUseStatement::pool_size;
   87750           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUseStatement::pool_size;
   87751             : 
   87752             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   87753             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   87754             : 
   87755           0 :           returnPointer = &( ( (SgUseStatement*)(SgUseStatement::pools[memoryBlock]) ) [positionInPool]) ;
   87756             : 
   87757           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   87758             :         }
   87759           0 :      return returnPointer ;
   87760             :    }
   87761             : 
   87762             : //############################################################################
   87763             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   87764             :   for the AST with the index astIndex
   87765             : */
   87766           0 : SgUseStatement * SgUseStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   87767           0 :      SgUseStatement* returnPointer = NULL;
   87768           0 :      if ( globalIndex != 0 )
   87769             :         {
   87770             : 
   87771             : #if FILE_IO_EXTRA_CHECK
   87772           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUseStatement ) ) <= globalIndex ) ;
   87773           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUseStatement + 1 ) ) );
   87774             : #endif
   87775           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUseStatement )
   87776           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUseStatement );
   87777           0 :           unsigned long positionInPool = localIndex % SgUseStatement::pool_size ;
   87778           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUseStatement::pool_size ;
   87779             : 
   87780             : #if FILE_IO_EXTRA_CHECK
   87781             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   87782             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   87783             : #endif
   87784             : 
   87785           0 :           returnPointer = &( ( (SgUseStatement*)(SgUseStatement::pools[memoryBlock]) ) [positionInPool]) ;
   87786             : 
   87787             : #if FILE_IO_EXTRA_CHECK
   87788           0 :           assert ( returnPointer != NULL ) ;
   87789             : #endif
   87790             :         }
   87791           0 :      return returnPointer ;
   87792             :    }
   87793             : 
   87794             : //############################################################################
   87795             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   87796             :  * pool size! We set for every valid object in the memory pool the freepointer
   87797             :  * to the global index and increase the global index afterwards. For all the 
   87798             :  * invalid objects (means address ranges within the memory pool that were not
   87799             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   87800             :  * distinguish valid from invalid objects! 
   87801             :  */
   87802             : unsigned long
   87803           5 : SgUseStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   87804             :    {
   87805           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   87806           5 :      SgUseStatement* pointer = NULL;
   87807           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   87808           5 :      std::vector < unsigned char* > :: const_iterator block;
   87809           5 :      for ( block = SgUseStatement::pools.begin(); block != SgUseStatement::pools.end() ; ++block )
   87810             :         {
   87811           0 :           pointer = (SgUseStatement*)(*block);
   87812           0 :           for (unsigned i = 0; i < SgUseStatement::pool_size; ++i )
   87813             :              {
   87814             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   87815             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   87816             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   87817             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   87818             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   87819             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   87820             :             // properly; so this will have to be checked next.
   87821             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   87822             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   87823           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   87824             :                   {
   87825           0 :                     pointer[i].set_freepointer((SgUseStatement*)(globalIndex));
   87826           0 :                     globalIndex++;
   87827             :                   }
   87828             :                else
   87829             :                   {
   87830           0 :                     pointer[i].set_freepointer(NULL);
   87831             :                   }
   87832             :               }
   87833             :         }
   87834           5 :      return globalIndex;
   87835             :    }
   87836             : 
   87837             : //############################################################################
   87838             : // JH (01/14/2006)
   87839             : void
   87840           5 : SgUseStatement::resetValidFreepointers( )
   87841             :    {
   87842           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   87843           5 :      SgUseStatement* pointer = NULL;
   87844           5 :      std::vector < unsigned char* > :: const_iterator block;
   87845           5 :      SgUseStatement* pointerOfLinkedList = NULL;
   87846           5 :      for ( block = SgUseStatement::pools.begin(); block != SgUseStatement::pools.end() ; ++block )
   87847             :         {
   87848           0 :           pointer = (SgUseStatement*)(*block);
   87849           0 :           for (unsigned i = 0; i < SgUseStatement::pool_size; ++i )
   87850             :              {
   87851             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   87852             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   87853             :             // memory blocks!.
   87854           0 :                if ( pointer[i].get_freepointer() != NULL )
   87855             :                   {
   87856           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   87857             :                   }
   87858             :                else
   87859             :                   {
   87860           0 :                     if ( pointerOfLinkedList == NULL )
   87861             :                        {
   87862           0 :                          SgUseStatement::next_node = &(pointer[i]);
   87863             :                        }
   87864             :                     else
   87865             :                        {
   87866             :                       // printf ("In SgUseStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   87867           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   87868             :                        }
   87869             :                     pointerOfLinkedList = &(pointer[i]);
   87870             :                   }
   87871             :               }
   87872             :         }
   87873             : 
   87874           5 :      if ( pointerOfLinkedList != NULL )
   87875             :         {
   87876             :        // printf ("In SgUseStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   87877           0 :           pointerOfLinkedList->set_freepointer(NULL);
   87878             :        // DQ (6/6/2010): Temporary debugging...
   87879             :        //   ROSE_ASSERT(false);
   87880             :         }
   87881             : 
   87882           5 :      return ;
   87883             :    }
   87884             : 
   87885             : //############################################################################
   87886             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   87887             :  * within the memory pool and resets the freepointers, in order to achieve a 
   87888             :  * linked list, that has no jumps and starts at the beginning! This function 
   87889             :  * does not extend the memory pool, since we do not delete any memory blocks,
   87890             :  * but delete the valid objects.  
   87891             :  */
   87892             : void
   87893           0 : SgUseStatement::clearMemoryPool( )
   87894             :    {
   87895             :   // printf ("Inside of SgUseStatement::clearMemoryPool() \n");
   87896             : 
   87897           0 :      SgUseStatement* pointer = NULL, *tempPointer = NULL;
   87898           0 :      std::vector < unsigned char* > :: const_iterator block;
   87899           0 :      if ( SgUseStatement::pools.empty() == false )
   87900             :         {
   87901           0 :           block = SgUseStatement::pools.begin() ;
   87902           0 :           SgUseStatement::next_node = (SgUseStatement*) (*block);
   87903             : 
   87904           0 :           while ( block != SgUseStatement::pools.end() )
   87905             :              {
   87906           0 :                pointer = (SgUseStatement*) (*block);
   87907           0 :                if ( tempPointer != NULL )
   87908             :                   {
   87909           0 :                     tempPointer->set_freepointer(pointer);
   87910             :                   }
   87911           0 :                for (unsigned i = 0; i < SgUseStatement::pool_size - 1; ++i)
   87912             :                   {
   87913           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   87914             :                   }
   87915           0 :                 pointer[SgUseStatement::pool_size-1].set_freepointer(NULL);
   87916           0 :                 tempPointer = &(pointer[SgUseStatement::pool_size-1]);
   87917           0 :                 ++block;
   87918             :              }
   87919             :         }
   87920           0 :    }
   87921             : 
   87922           5 : void SgUseStatement::deleteMemoryPool() {
   87923           5 :   for (auto p: SgUseStatement::pools) {
   87924           0 :     ROSE_FREE(p);
   87925             :   }
   87926           5 :   SgUseStatement::next_node = nullptr;
   87927           5 :   SgUseStatement::pools.clear();
   87928           5 : }
   87929             : 
   87930             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   87931             : //                 reading multiple binary files to for a single AST.
   87932             : /////////// new version ////////////////////////////////
   87933             : //############################################################################
   87934             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   87935             : void
   87936           2 : SgUseStatement::extendMemoryPoolForFileIO( )
   87937             :   {
   87938           2 :     size_t blockIndex = SgUseStatement::pools.size();
   87939           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUseStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUseStatement);
   87940             : 
   87941           2 :     while ( (blockIndex * SgUseStatement::pool_size) < newPoolSize)
   87942             :       {
   87943             : #if ROSE_ALLOC_TRACE
   87944             :         if (blockIndex > 0) {
   87945             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUseStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUseStatement) = %" PRIuPTR " SgUseStatement::pool_size = %d \n",
   87946             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUseStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUseStatement),SgUseStatement::pool_size);
   87947             :         }
   87948             : #endif
   87949             : 
   87950           0 :         SgUseStatement * pointer = (SgUseStatement*) ROSE_MALLOC ( SgUseStatement::pool_size * sizeof(SgUseStatement) );
   87951           0 :         assert( pointer != NULL );
   87952             : #if ROSE_ALLOC_MEMSET == 1
   87953             :         memset(pointer, 0x00, SgUseStatement::pool_size * sizeof(SgUseStatement));
   87954             : #elif ROSE_ALLOC_MEMSET == 2
   87955             :         memset(pointer, 0xCC, SgUseStatement::pool_size * sizeof(SgUseStatement));
   87956             : #endif
   87957           0 :         SgUseStatement::pools.push_back( (unsigned char*)(pointer) );
   87958           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUseStatement::pool_size * sizeof(SgUseStatement), V_SgUseStatement ) );
   87959             : 
   87960           0 :         if ( SgUseStatement::next_node != NULL ) {
   87961           0 :           if ( blockIndex > 0 ) {
   87962           0 :             SgUseStatement * blkptr = (SgUseStatement*)(SgUseStatement::pools[blockIndex-1]);
   87963           0 :             blkptr[ SgUseStatement::pool_size - 1 ].set_freepointer(pointer);
   87964             :           }
   87965             :         } else {
   87966           0 :           SgUseStatement::next_node = pointer;
   87967             :         }
   87968             : 
   87969           0 :         for (unsigned i = 0; i < SgUseStatement::pool_size-1; ++i)
   87970             :            {
   87971           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   87972             :            }
   87973           0 :         pointer[ SgUseStatement::pool_size -1 ].set_freepointer(NULL);
   87974             : 
   87975           0 :         blockIndex++;
   87976             :       }
   87977           2 :   }
   87978             : 
   87979             : //############################################################################
   87980             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   87981             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   87982             :  * not compressed. However, that stuff is not yet implemented! 
   87983             :  */
   87984             : unsigned long
   87985           0 : SgUseStatement::getNumberOfLastValidPointer()
   87986             :    {
   87987           0 :       SgUseStatement* testPointer = (SgUseStatement*)(SgUseStatement::pools.back());
   87988           0 :       unsigned long localIndex = SgUseStatement::pool_size - 1;
   87989           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   87990             :          {
   87991           0 :            localIndex--;
   87992             :          }
   87993           0 :       return (localIndex + SgUseStatement::pool_size * (SgUseStatement::pools.size()-1));
   87994             :    }
   87995             : 
   87996             : //############################################################################
   87997             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   87998             :  * memory pool and initializes the data member in class SgUseStatementStroageClass
   87999             :  * from its counterpart of SgUseStatement. The return value is just for checking, 
   88000             :  * that the whole StorageClassArray is initialized!
   88001             :  */
   88002             : unsigned long
   88003           0 : SgUseStatement::initializeStorageClassArray( SgUseStatementStorageClass *storageArray )
   88004             :    {
   88005           0 :      unsigned long storageCounter = 0;
   88006           0 :      std::vector < unsigned char* > :: const_iterator block = SgUseStatement::pools.begin();
   88007           0 :      SgUseStatement* pointer = NULL;
   88008           0 :      while ( block != SgUseStatement::pools.end() ) {
   88009           0 :           pointer = (SgUseStatement*) (*block);
   88010           0 :           for ( unsigned i = 0; i < SgUseStatement::pool_size; ++i ) {
   88011           0 :                if ( pointer->get_freepointer() != NULL ) {
   88012           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   88013           0 :                  storageArray++;
   88014           0 :                  storageCounter++;
   88015             :                }
   88016           0 :                pointer++;
   88017             :              }
   88018           0 :            block++;
   88019             :         }
   88020           0 :      return storageCounter;
   88021             :    }
   88022             : 
   88023             : /* #line 88024 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   88024             : 
   88025             : 
   88026             : 
   88027             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   88028             : 
   88029             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   88030             : 
   88031             : //############################################################################
   88032             : /* JH (02/02/2006) Constructor of the IR node SgParameterStatement that takes its 
   88033             :  * corresponding StorageClass as parameter
   88034             :  */
   88035           0 : SgParameterStatement :: SgParameterStatement ( const SgParameterStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   88036             :    {
   88037             : 
   88038             : 
   88039             : /* #line 88040 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   88040             : 
   88041           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   88042             : 
   88043             : 
   88044             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   88045             : 
   88046             : 
   88047           0 :    }
   88048             : 
   88049             : //############################################################################
   88050             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   88051             :  * within the working AST. 
   88052             :  */
   88053           0 : SgParameterStatement * SgParameterStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   88054           0 :      SgParameterStatement* returnPointer = NULL;
   88055           0 :      if ( globalIndex != 0 )
   88056             :         {
   88057             : 
   88058             : #if FILE_IO_EXTRA_CHECK
   88059           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgParameterStatement ) ) <= globalIndex ) ;
   88060           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgParameterStatement + 1 ) ) );
   88061             : #endif
   88062           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgParameterStatement )  
   88063           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgParameterStatement );
   88064           0 :           unsigned long positionInPool = localIndex % SgParameterStatement::pool_size;
   88065           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgParameterStatement::pool_size;
   88066             : 
   88067             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   88068             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   88069             : 
   88070           0 :           returnPointer = &( ( (SgParameterStatement*)(SgParameterStatement::pools[memoryBlock]) ) [positionInPool]) ;
   88071             : 
   88072           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   88073             :         }
   88074           0 :      return returnPointer ;
   88075             :    }
   88076             : 
   88077             : //############################################################################
   88078             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   88079             :   for the AST with the index astIndex
   88080             : */
   88081           0 : SgParameterStatement * SgParameterStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   88082           0 :      SgParameterStatement* returnPointer = NULL;
   88083           0 :      if ( globalIndex != 0 )
   88084             :         {
   88085             : 
   88086             : #if FILE_IO_EXTRA_CHECK
   88087           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgParameterStatement ) ) <= globalIndex ) ;
   88088           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgParameterStatement + 1 ) ) );
   88089             : #endif
   88090           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgParameterStatement )
   88091           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgParameterStatement );
   88092           0 :           unsigned long positionInPool = localIndex % SgParameterStatement::pool_size ;
   88093           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgParameterStatement::pool_size ;
   88094             : 
   88095             : #if FILE_IO_EXTRA_CHECK
   88096             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   88097             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   88098             : #endif
   88099             : 
   88100           0 :           returnPointer = &( ( (SgParameterStatement*)(SgParameterStatement::pools[memoryBlock]) ) [positionInPool]) ;
   88101             : 
   88102             : #if FILE_IO_EXTRA_CHECK
   88103           0 :           assert ( returnPointer != NULL ) ;
   88104             : #endif
   88105             :         }
   88106           0 :      return returnPointer ;
   88107             :    }
   88108             : 
   88109             : //############################################################################
   88110             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   88111             :  * pool size! We set for every valid object in the memory pool the freepointer
   88112             :  * to the global index and increase the global index afterwards. For all the 
   88113             :  * invalid objects (means address ranges within the memory pool that were not
   88114             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   88115             :  * distinguish valid from invalid objects! 
   88116             :  */
   88117             : unsigned long
   88118           5 : SgParameterStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   88119             :    {
   88120           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   88121           5 :      SgParameterStatement* pointer = NULL;
   88122           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   88123           5 :      std::vector < unsigned char* > :: const_iterator block;
   88124           5 :      for ( block = SgParameterStatement::pools.begin(); block != SgParameterStatement::pools.end() ; ++block )
   88125             :         {
   88126           0 :           pointer = (SgParameterStatement*)(*block);
   88127           0 :           for (unsigned i = 0; i < SgParameterStatement::pool_size; ++i )
   88128             :              {
   88129             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   88130             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   88131             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   88132             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   88133             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   88134             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   88135             :             // properly; so this will have to be checked next.
   88136             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   88137             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   88138           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   88139             :                   {
   88140           0 :                     pointer[i].set_freepointer((SgParameterStatement*)(globalIndex));
   88141           0 :                     globalIndex++;
   88142             :                   }
   88143             :                else
   88144             :                   {
   88145           0 :                     pointer[i].set_freepointer(NULL);
   88146             :                   }
   88147             :               }
   88148             :         }
   88149           5 :      return globalIndex;
   88150             :    }
   88151             : 
   88152             : //############################################################################
   88153             : // JH (01/14/2006)
   88154             : void
   88155           5 : SgParameterStatement::resetValidFreepointers( )
   88156             :    {
   88157           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   88158           5 :      SgParameterStatement* pointer = NULL;
   88159           5 :      std::vector < unsigned char* > :: const_iterator block;
   88160           5 :      SgParameterStatement* pointerOfLinkedList = NULL;
   88161           5 :      for ( block = SgParameterStatement::pools.begin(); block != SgParameterStatement::pools.end() ; ++block )
   88162             :         {
   88163           0 :           pointer = (SgParameterStatement*)(*block);
   88164           0 :           for (unsigned i = 0; i < SgParameterStatement::pool_size; ++i )
   88165             :              {
   88166             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   88167             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   88168             :             // memory blocks!.
   88169           0 :                if ( pointer[i].get_freepointer() != NULL )
   88170             :                   {
   88171           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   88172             :                   }
   88173             :                else
   88174             :                   {
   88175           0 :                     if ( pointerOfLinkedList == NULL )
   88176             :                        {
   88177           0 :                          SgParameterStatement::next_node = &(pointer[i]);
   88178             :                        }
   88179             :                     else
   88180             :                        {
   88181             :                       // printf ("In SgParameterStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   88182           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   88183             :                        }
   88184             :                     pointerOfLinkedList = &(pointer[i]);
   88185             :                   }
   88186             :               }
   88187             :         }
   88188             : 
   88189           5 :      if ( pointerOfLinkedList != NULL )
   88190             :         {
   88191             :        // printf ("In SgParameterStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   88192           0 :           pointerOfLinkedList->set_freepointer(NULL);
   88193             :        // DQ (6/6/2010): Temporary debugging...
   88194             :        //   ROSE_ASSERT(false);
   88195             :         }
   88196             : 
   88197           5 :      return ;
   88198             :    }
   88199             : 
   88200             : //############################################################################
   88201             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   88202             :  * within the memory pool and resets the freepointers, in order to achieve a 
   88203             :  * linked list, that has no jumps and starts at the beginning! This function 
   88204             :  * does not extend the memory pool, since we do not delete any memory blocks,
   88205             :  * but delete the valid objects.  
   88206             :  */
   88207             : void
   88208           0 : SgParameterStatement::clearMemoryPool( )
   88209             :    {
   88210             :   // printf ("Inside of SgParameterStatement::clearMemoryPool() \n");
   88211             : 
   88212           0 :      SgParameterStatement* pointer = NULL, *tempPointer = NULL;
   88213           0 :      std::vector < unsigned char* > :: const_iterator block;
   88214           0 :      if ( SgParameterStatement::pools.empty() == false )
   88215             :         {
   88216           0 :           block = SgParameterStatement::pools.begin() ;
   88217           0 :           SgParameterStatement::next_node = (SgParameterStatement*) (*block);
   88218             : 
   88219           0 :           while ( block != SgParameterStatement::pools.end() )
   88220             :              {
   88221           0 :                pointer = (SgParameterStatement*) (*block);
   88222           0 :                if ( tempPointer != NULL )
   88223             :                   {
   88224           0 :                     tempPointer->set_freepointer(pointer);
   88225             :                   }
   88226           0 :                for (unsigned i = 0; i < SgParameterStatement::pool_size - 1; ++i)
   88227             :                   {
   88228           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   88229             :                   }
   88230           0 :                 pointer[SgParameterStatement::pool_size-1].set_freepointer(NULL);
   88231           0 :                 tempPointer = &(pointer[SgParameterStatement::pool_size-1]);
   88232           0 :                 ++block;
   88233             :              }
   88234             :         }
   88235           0 :    }
   88236             : 
   88237           5 : void SgParameterStatement::deleteMemoryPool() {
   88238           5 :   for (auto p: SgParameterStatement::pools) {
   88239           0 :     ROSE_FREE(p);
   88240             :   }
   88241           5 :   SgParameterStatement::next_node = nullptr;
   88242           5 :   SgParameterStatement::pools.clear();
   88243           5 : }
   88244             : 
   88245             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   88246             : //                 reading multiple binary files to for a single AST.
   88247             : /////////// new version ////////////////////////////////
   88248             : //############################################################################
   88249             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   88250             : void
   88251           2 : SgParameterStatement::extendMemoryPoolForFileIO( )
   88252             :   {
   88253           2 :     size_t blockIndex = SgParameterStatement::pools.size();
   88254           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgParameterStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgParameterStatement);
   88255             : 
   88256           2 :     while ( (blockIndex * SgParameterStatement::pool_size) < newPoolSize)
   88257             :       {
   88258             : #if ROSE_ALLOC_TRACE
   88259             :         if (blockIndex > 0) {
   88260             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgParameterStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgParameterStatement) = %" PRIuPTR " SgParameterStatement::pool_size = %d \n",
   88261             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgParameterStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgParameterStatement),SgParameterStatement::pool_size);
   88262             :         }
   88263             : #endif
   88264             : 
   88265           0 :         SgParameterStatement * pointer = (SgParameterStatement*) ROSE_MALLOC ( SgParameterStatement::pool_size * sizeof(SgParameterStatement) );
   88266           0 :         assert( pointer != NULL );
   88267             : #if ROSE_ALLOC_MEMSET == 1
   88268             :         memset(pointer, 0x00, SgParameterStatement::pool_size * sizeof(SgParameterStatement));
   88269             : #elif ROSE_ALLOC_MEMSET == 2
   88270             :         memset(pointer, 0xCC, SgParameterStatement::pool_size * sizeof(SgParameterStatement));
   88271             : #endif
   88272           0 :         SgParameterStatement::pools.push_back( (unsigned char*)(pointer) );
   88273           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgParameterStatement::pool_size * sizeof(SgParameterStatement), V_SgParameterStatement ) );
   88274             : 
   88275           0 :         if ( SgParameterStatement::next_node != NULL ) {
   88276           0 :           if ( blockIndex > 0 ) {
   88277           0 :             SgParameterStatement * blkptr = (SgParameterStatement*)(SgParameterStatement::pools[blockIndex-1]);
   88278           0 :             blkptr[ SgParameterStatement::pool_size - 1 ].set_freepointer(pointer);
   88279             :           }
   88280             :         } else {
   88281           0 :           SgParameterStatement::next_node = pointer;
   88282             :         }
   88283             : 
   88284           0 :         for (unsigned i = 0; i < SgParameterStatement::pool_size-1; ++i)
   88285             :            {
   88286           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   88287             :            }
   88288           0 :         pointer[ SgParameterStatement::pool_size -1 ].set_freepointer(NULL);
   88289             : 
   88290           0 :         blockIndex++;
   88291             :       }
   88292           2 :   }
   88293             : 
   88294             : //############################################################################
   88295             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   88296             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   88297             :  * not compressed. However, that stuff is not yet implemented! 
   88298             :  */
   88299             : unsigned long
   88300           0 : SgParameterStatement::getNumberOfLastValidPointer()
   88301             :    {
   88302           0 :       SgParameterStatement* testPointer = (SgParameterStatement*)(SgParameterStatement::pools.back());
   88303           0 :       unsigned long localIndex = SgParameterStatement::pool_size - 1;
   88304           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   88305             :          {
   88306           0 :            localIndex--;
   88307             :          }
   88308           0 :       return (localIndex + SgParameterStatement::pool_size * (SgParameterStatement::pools.size()-1));
   88309             :    }
   88310             : 
   88311             : //############################################################################
   88312             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   88313             :  * memory pool and initializes the data member in class SgParameterStatementStroageClass
   88314             :  * from its counterpart of SgParameterStatement. The return value is just for checking, 
   88315             :  * that the whole StorageClassArray is initialized!
   88316             :  */
   88317             : unsigned long
   88318           0 : SgParameterStatement::initializeStorageClassArray( SgParameterStatementStorageClass *storageArray )
   88319             :    {
   88320           0 :      unsigned long storageCounter = 0;
   88321           0 :      std::vector < unsigned char* > :: const_iterator block = SgParameterStatement::pools.begin();
   88322           0 :      SgParameterStatement* pointer = NULL;
   88323           0 :      while ( block != SgParameterStatement::pools.end() ) {
   88324           0 :           pointer = (SgParameterStatement*) (*block);
   88325           0 :           for ( unsigned i = 0; i < SgParameterStatement::pool_size; ++i ) {
   88326           0 :                if ( pointer->get_freepointer() != NULL ) {
   88327           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   88328           0 :                  storageArray++;
   88329           0 :                  storageCounter++;
   88330             :                }
   88331           0 :                pointer++;
   88332             :              }
   88333           0 :            block++;
   88334             :         }
   88335           0 :      return storageCounter;
   88336             :    }
   88337             : 
   88338             : /* #line 88339 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   88339             : 
   88340             : 
   88341             : 
   88342             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   88343             : 
   88344             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   88345             : 
   88346             : //############################################################################
   88347             : /* JH (02/02/2006) Constructor of the IR node SgNamespaceDeclarationStatement that takes its 
   88348             :  * corresponding StorageClass as parameter
   88349             :  */
   88350         121 : SgNamespaceDeclarationStatement :: SgNamespaceDeclarationStatement ( const SgNamespaceDeclarationStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   88351             :    {
   88352             : 
   88353             : 
   88354             : /* #line 88355 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   88355             : 
   88356         121 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   88357         121 :      p_name = SgName ( storageSource.storageOf_name ) ;
   88358         121 :      p_definition =  (SgNamespaceDefinitionStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_definition) );
   88359         121 :      p_isUnnamedNamespace = storageSource.storageOf_isUnnamedNamespace ;
   88360         121 :      p_isInlinedNamespace = storageSource.storageOf_isInlinedNamespace ;
   88361             : 
   88362             : 
   88363             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   88364             : 
   88365             : 
   88366         121 :    }
   88367             : 
   88368             : //############################################################################
   88369             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   88370             :  * within the working AST. 
   88371             :  */
   88372         769 : SgNamespaceDeclarationStatement * SgNamespaceDeclarationStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   88373         769 :      SgNamespaceDeclarationStatement* returnPointer = NULL;
   88374         769 :      if ( globalIndex != 0 )
   88375             :         {
   88376             : 
   88377             : #if FILE_IO_EXTRA_CHECK
   88378         769 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNamespaceDeclarationStatement ) ) <= globalIndex ) ;
   88379         769 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamespaceDeclarationStatement + 1 ) ) );
   88380             : #endif
   88381         769 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamespaceDeclarationStatement )  
   88382         769 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNamespaceDeclarationStatement );
   88383         769 :           unsigned long positionInPool = localIndex % SgNamespaceDeclarationStatement::pool_size;
   88384         769 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamespaceDeclarationStatement::pool_size;
   88385             : 
   88386             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   88387             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   88388             : 
   88389         769 :           returnPointer = &( ( (SgNamespaceDeclarationStatement*)(SgNamespaceDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   88390             : 
   88391         769 :           ROSE_ASSERT( returnPointer != NULL ) ;
   88392             :         }
   88393         769 :      return returnPointer ;
   88394             :    }
   88395             : 
   88396             : //############################################################################
   88397             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   88398             :   for the AST with the index astIndex
   88399             : */
   88400           0 : SgNamespaceDeclarationStatement * SgNamespaceDeclarationStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   88401           0 :      SgNamespaceDeclarationStatement* returnPointer = NULL;
   88402           0 :      if ( globalIndex != 0 )
   88403             :         {
   88404             : 
   88405             : #if FILE_IO_EXTRA_CHECK
   88406           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNamespaceDeclarationStatement ) ) <= globalIndex ) ;
   88407           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamespaceDeclarationStatement + 1 ) ) );
   88408             : #endif
   88409           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamespaceDeclarationStatement )
   88410           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNamespaceDeclarationStatement );
   88411           0 :           unsigned long positionInPool = localIndex % SgNamespaceDeclarationStatement::pool_size ;
   88412           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamespaceDeclarationStatement::pool_size ;
   88413             : 
   88414             : #if FILE_IO_EXTRA_CHECK
   88415             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   88416             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   88417             : #endif
   88418             : 
   88419           0 :           returnPointer = &( ( (SgNamespaceDeclarationStatement*)(SgNamespaceDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   88420             : 
   88421             : #if FILE_IO_EXTRA_CHECK
   88422           0 :           assert ( returnPointer != NULL ) ;
   88423             : #endif
   88424             :         }
   88425           0 :      return returnPointer ;
   88426             :    }
   88427             : 
   88428             : //############################################################################
   88429             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   88430             :  * pool size! We set for every valid object in the memory pool the freepointer
   88431             :  * to the global index and increase the global index afterwards. For all the 
   88432             :  * invalid objects (means address ranges within the memory pool that were not
   88433             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   88434             :  * distinguish valid from invalid objects! 
   88435             :  */
   88436             : unsigned long
   88437           5 : SgNamespaceDeclarationStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   88438             :    {
   88439           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   88440           5 :      SgNamespaceDeclarationStatement* pointer = NULL;
   88441           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   88442           5 :      std::vector < unsigned char* > :: const_iterator block;
   88443           6 :      for ( block = SgNamespaceDeclarationStatement::pools.begin(); block != SgNamespaceDeclarationStatement::pools.end() ; ++block )
   88444             :         {
   88445           1 :           pointer = (SgNamespaceDeclarationStatement*)(*block);
   88446        2001 :           for (unsigned i = 0; i < SgNamespaceDeclarationStatement::pool_size; ++i )
   88447             :              {
   88448             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   88449             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   88450             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   88451             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   88452             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   88453             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   88454             :             // properly; so this will have to be checked next.
   88455             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   88456             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   88457        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   88458             :                   {
   88459         121 :                     pointer[i].set_freepointer((SgNamespaceDeclarationStatement*)(globalIndex));
   88460         121 :                     globalIndex++;
   88461             :                   }
   88462             :                else
   88463             :                   {
   88464        1879 :                     pointer[i].set_freepointer(NULL);
   88465             :                   }
   88466             :               }
   88467             :         }
   88468           5 :      return globalIndex;
   88469             :    }
   88470             : 
   88471             : //############################################################################
   88472             : // JH (01/14/2006)
   88473             : void
   88474           5 : SgNamespaceDeclarationStatement::resetValidFreepointers( )
   88475             :    {
   88476           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   88477           5 :      SgNamespaceDeclarationStatement* pointer = NULL;
   88478           5 :      std::vector < unsigned char* > :: const_iterator block;
   88479           5 :      SgNamespaceDeclarationStatement* pointerOfLinkedList = NULL;
   88480           6 :      for ( block = SgNamespaceDeclarationStatement::pools.begin(); block != SgNamespaceDeclarationStatement::pools.end() ; ++block )
   88481             :         {
   88482           1 :           pointer = (SgNamespaceDeclarationStatement*)(*block);
   88483        2001 :           for (unsigned i = 0; i < SgNamespaceDeclarationStatement::pool_size; ++i )
   88484             :              {
   88485             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   88486             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   88487             :             // memory blocks!.
   88488        2000 :                if ( pointer[i].get_freepointer() != NULL )
   88489             :                   {
   88490         121 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   88491             :                   }
   88492             :                else
   88493             :                   {
   88494        1879 :                     if ( pointerOfLinkedList == NULL )
   88495             :                        {
   88496           1 :                          SgNamespaceDeclarationStatement::next_node = &(pointer[i]);
   88497             :                        }
   88498             :                     else
   88499             :                        {
   88500             :                       // printf ("In SgNamespaceDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   88501        1878 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   88502             :                        }
   88503             :                     pointerOfLinkedList = &(pointer[i]);
   88504             :                   }
   88505             :               }
   88506             :         }
   88507             : 
   88508           5 :      if ( pointerOfLinkedList != NULL )
   88509             :         {
   88510             :        // printf ("In SgNamespaceDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   88511           1 :           pointerOfLinkedList->set_freepointer(NULL);
   88512             :        // DQ (6/6/2010): Temporary debugging...
   88513             :        //   ROSE_ASSERT(false);
   88514             :         }
   88515             : 
   88516           5 :      return ;
   88517             :    }
   88518             : 
   88519             : //############################################################################
   88520             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   88521             :  * within the memory pool and resets the freepointers, in order to achieve a 
   88522             :  * linked list, that has no jumps and starts at the beginning! This function 
   88523             :  * does not extend the memory pool, since we do not delete any memory blocks,
   88524             :  * but delete the valid objects.  
   88525             :  */
   88526             : void
   88527           0 : SgNamespaceDeclarationStatement::clearMemoryPool( )
   88528             :    {
   88529             :   // printf ("Inside of SgNamespaceDeclarationStatement::clearMemoryPool() \n");
   88530             : 
   88531           0 :      SgNamespaceDeclarationStatement* pointer = NULL, *tempPointer = NULL;
   88532           0 :      std::vector < unsigned char* > :: const_iterator block;
   88533           0 :      if ( SgNamespaceDeclarationStatement::pools.empty() == false )
   88534             :         {
   88535           0 :           block = SgNamespaceDeclarationStatement::pools.begin() ;
   88536           0 :           SgNamespaceDeclarationStatement::next_node = (SgNamespaceDeclarationStatement*) (*block);
   88537             : 
   88538           0 :           while ( block != SgNamespaceDeclarationStatement::pools.end() )
   88539             :              {
   88540           0 :                pointer = (SgNamespaceDeclarationStatement*) (*block);
   88541           0 :                if ( tempPointer != NULL )
   88542             :                   {
   88543           0 :                     tempPointer->set_freepointer(pointer);
   88544             :                   }
   88545           0 :                for (unsigned i = 0; i < SgNamespaceDeclarationStatement::pool_size - 1; ++i)
   88546             :                   {
   88547           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   88548             :                   }
   88549           0 :                 pointer[SgNamespaceDeclarationStatement::pool_size-1].set_freepointer(NULL);
   88550           0 :                 tempPointer = &(pointer[SgNamespaceDeclarationStatement::pool_size-1]);
   88551           0 :                 ++block;
   88552             :              }
   88553             :         }
   88554           0 :    }
   88555             : 
   88556           5 : void SgNamespaceDeclarationStatement::deleteMemoryPool() {
   88557           7 :   for (auto p: SgNamespaceDeclarationStatement::pools) {
   88558           2 :     ROSE_FREE(p);
   88559             :   }
   88560           5 :   SgNamespaceDeclarationStatement::next_node = nullptr;
   88561           5 :   SgNamespaceDeclarationStatement::pools.clear();
   88562           5 : }
   88563             : 
   88564             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   88565             : //                 reading multiple binary files to for a single AST.
   88566             : /////////// new version ////////////////////////////////
   88567             : //############################################################################
   88568             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   88569             : void
   88570           2 : SgNamespaceDeclarationStatement::extendMemoryPoolForFileIO( )
   88571             :   {
   88572           2 :     size_t blockIndex = SgNamespaceDeclarationStatement::pools.size();
   88573           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceDeclarationStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceDeclarationStatement);
   88574             : 
   88575           3 :     while ( (blockIndex * SgNamespaceDeclarationStatement::pool_size) < newPoolSize)
   88576             :       {
   88577             : #if ROSE_ALLOC_TRACE
   88578             :         if (blockIndex > 0) {
   88579             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceDeclarationStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceDeclarationStatement) = %" PRIuPTR " SgNamespaceDeclarationStatement::pool_size = %d \n",
   88580             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceDeclarationStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceDeclarationStatement),SgNamespaceDeclarationStatement::pool_size);
   88581             :         }
   88582             : #endif
   88583             : 
   88584           1 :         SgNamespaceDeclarationStatement * pointer = (SgNamespaceDeclarationStatement*) ROSE_MALLOC ( SgNamespaceDeclarationStatement::pool_size * sizeof(SgNamespaceDeclarationStatement) );
   88585           1 :         assert( pointer != NULL );
   88586             : #if ROSE_ALLOC_MEMSET == 1
   88587             :         memset(pointer, 0x00, SgNamespaceDeclarationStatement::pool_size * sizeof(SgNamespaceDeclarationStatement));
   88588             : #elif ROSE_ALLOC_MEMSET == 2
   88589             :         memset(pointer, 0xCC, SgNamespaceDeclarationStatement::pool_size * sizeof(SgNamespaceDeclarationStatement));
   88590             : #endif
   88591           1 :         SgNamespaceDeclarationStatement::pools.push_back( (unsigned char*)(pointer) );
   88592           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNamespaceDeclarationStatement::pool_size * sizeof(SgNamespaceDeclarationStatement), V_SgNamespaceDeclarationStatement ) );
   88593             : 
   88594           1 :         if ( SgNamespaceDeclarationStatement::next_node != NULL ) {
   88595           0 :           if ( blockIndex > 0 ) {
   88596           0 :             SgNamespaceDeclarationStatement * blkptr = (SgNamespaceDeclarationStatement*)(SgNamespaceDeclarationStatement::pools[blockIndex-1]);
   88597           0 :             blkptr[ SgNamespaceDeclarationStatement::pool_size - 1 ].set_freepointer(pointer);
   88598             :           }
   88599             :         } else {
   88600           1 :           SgNamespaceDeclarationStatement::next_node = pointer;
   88601             :         }
   88602             : 
   88603        2000 :         for (unsigned i = 0; i < SgNamespaceDeclarationStatement::pool_size-1; ++i)
   88604             :            {
   88605        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   88606             :            }
   88607           1 :         pointer[ SgNamespaceDeclarationStatement::pool_size -1 ].set_freepointer(NULL);
   88608             : 
   88609           1 :         blockIndex++;
   88610             :       }
   88611           2 :   }
   88612             : 
   88613             : //############################################################################
   88614             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   88615             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   88616             :  * not compressed. However, that stuff is not yet implemented! 
   88617             :  */
   88618             : unsigned long
   88619           0 : SgNamespaceDeclarationStatement::getNumberOfLastValidPointer()
   88620             :    {
   88621           0 :       SgNamespaceDeclarationStatement* testPointer = (SgNamespaceDeclarationStatement*)(SgNamespaceDeclarationStatement::pools.back());
   88622           0 :       unsigned long localIndex = SgNamespaceDeclarationStatement::pool_size - 1;
   88623           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   88624             :          {
   88625           0 :            localIndex--;
   88626             :          }
   88627           0 :       return (localIndex + SgNamespaceDeclarationStatement::pool_size * (SgNamespaceDeclarationStatement::pools.size()-1));
   88628             :    }
   88629             : 
   88630             : //############################################################################
   88631             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   88632             :  * memory pool and initializes the data member in class SgNamespaceDeclarationStatementStroageClass
   88633             :  * from its counterpart of SgNamespaceDeclarationStatement. The return value is just for checking, 
   88634             :  * that the whole StorageClassArray is initialized!
   88635             :  */
   88636             : unsigned long
   88637           1 : SgNamespaceDeclarationStatement::initializeStorageClassArray( SgNamespaceDeclarationStatementStorageClass *storageArray )
   88638             :    {
   88639           1 :      unsigned long storageCounter = 0;
   88640           1 :      std::vector < unsigned char* > :: const_iterator block = SgNamespaceDeclarationStatement::pools.begin();
   88641           1 :      SgNamespaceDeclarationStatement* pointer = NULL;
   88642           2 :      while ( block != SgNamespaceDeclarationStatement::pools.end() ) {
   88643           1 :           pointer = (SgNamespaceDeclarationStatement*) (*block);
   88644        2001 :           for ( unsigned i = 0; i < SgNamespaceDeclarationStatement::pool_size; ++i ) {
   88645        2000 :                if ( pointer->get_freepointer() != NULL ) {
   88646         121 :                  storageArray->pickOutIRNodeData (pointer) ;
   88647         121 :                  storageArray++;
   88648         121 :                  storageCounter++;
   88649             :                }
   88650        2000 :                pointer++;
   88651             :              }
   88652           1 :            block++;
   88653             :         }
   88654           1 :      return storageCounter;
   88655             :    }
   88656             : 
   88657             : /* #line 88658 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   88658             : 
   88659             : 
   88660             : 
   88661             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   88662             : 
   88663             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   88664             : 
   88665             : //############################################################################
   88666             : /* JH (02/02/2006) Constructor of the IR node SgEquivalenceStatement that takes its 
   88667             :  * corresponding StorageClass as parameter
   88668             :  */
   88669           0 : SgEquivalenceStatement :: SgEquivalenceStatement ( const SgEquivalenceStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   88670             :    {
   88671             : 
   88672             : 
   88673             : /* #line 88674 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   88674             : 
   88675           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   88676           0 :      p_equivalence_set_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_equivalence_set_list) );
   88677             : 
   88678             : 
   88679             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   88680             : 
   88681             : 
   88682           0 :    }
   88683             : 
   88684             : //############################################################################
   88685             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   88686             :  * within the working AST. 
   88687             :  */
   88688           0 : SgEquivalenceStatement * SgEquivalenceStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   88689           0 :      SgEquivalenceStatement* returnPointer = NULL;
   88690           0 :      if ( globalIndex != 0 )
   88691             :         {
   88692             : 
   88693             : #if FILE_IO_EXTRA_CHECK
   88694           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEquivalenceStatement ) ) <= globalIndex ) ;
   88695           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEquivalenceStatement + 1 ) ) );
   88696             : #endif
   88697           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEquivalenceStatement )  
   88698           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEquivalenceStatement );
   88699           0 :           unsigned long positionInPool = localIndex % SgEquivalenceStatement::pool_size;
   88700           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEquivalenceStatement::pool_size;
   88701             : 
   88702             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   88703             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   88704             : 
   88705           0 :           returnPointer = &( ( (SgEquivalenceStatement*)(SgEquivalenceStatement::pools[memoryBlock]) ) [positionInPool]) ;
   88706             : 
   88707           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   88708             :         }
   88709           0 :      return returnPointer ;
   88710             :    }
   88711             : 
   88712             : //############################################################################
   88713             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   88714             :   for the AST with the index astIndex
   88715             : */
   88716           0 : SgEquivalenceStatement * SgEquivalenceStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   88717           0 :      SgEquivalenceStatement* returnPointer = NULL;
   88718           0 :      if ( globalIndex != 0 )
   88719             :         {
   88720             : 
   88721             : #if FILE_IO_EXTRA_CHECK
   88722           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEquivalenceStatement ) ) <= globalIndex ) ;
   88723           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEquivalenceStatement + 1 ) ) );
   88724             : #endif
   88725           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEquivalenceStatement )
   88726           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEquivalenceStatement );
   88727           0 :           unsigned long positionInPool = localIndex % SgEquivalenceStatement::pool_size ;
   88728           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEquivalenceStatement::pool_size ;
   88729             : 
   88730             : #if FILE_IO_EXTRA_CHECK
   88731             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   88732             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   88733             : #endif
   88734             : 
   88735           0 :           returnPointer = &( ( (SgEquivalenceStatement*)(SgEquivalenceStatement::pools[memoryBlock]) ) [positionInPool]) ;
   88736             : 
   88737             : #if FILE_IO_EXTRA_CHECK
   88738           0 :           assert ( returnPointer != NULL ) ;
   88739             : #endif
   88740             :         }
   88741           0 :      return returnPointer ;
   88742             :    }
   88743             : 
   88744             : //############################################################################
   88745             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   88746             :  * pool size! We set for every valid object in the memory pool the freepointer
   88747             :  * to the global index and increase the global index afterwards. For all the 
   88748             :  * invalid objects (means address ranges within the memory pool that were not
   88749             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   88750             :  * distinguish valid from invalid objects! 
   88751             :  */
   88752             : unsigned long
   88753           5 : SgEquivalenceStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   88754             :    {
   88755           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   88756           5 :      SgEquivalenceStatement* pointer = NULL;
   88757           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   88758           5 :      std::vector < unsigned char* > :: const_iterator block;
   88759           5 :      for ( block = SgEquivalenceStatement::pools.begin(); block != SgEquivalenceStatement::pools.end() ; ++block )
   88760             :         {
   88761           0 :           pointer = (SgEquivalenceStatement*)(*block);
   88762           0 :           for (unsigned i = 0; i < SgEquivalenceStatement::pool_size; ++i )
   88763             :              {
   88764             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   88765             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   88766             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   88767             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   88768             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   88769             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   88770             :             // properly; so this will have to be checked next.
   88771             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   88772             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   88773           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   88774             :                   {
   88775           0 :                     pointer[i].set_freepointer((SgEquivalenceStatement*)(globalIndex));
   88776           0 :                     globalIndex++;
   88777             :                   }
   88778             :                else
   88779             :                   {
   88780           0 :                     pointer[i].set_freepointer(NULL);
   88781             :                   }
   88782             :               }
   88783             :         }
   88784           5 :      return globalIndex;
   88785             :    }
   88786             : 
   88787             : //############################################################################
   88788             : // JH (01/14/2006)
   88789             : void
   88790           5 : SgEquivalenceStatement::resetValidFreepointers( )
   88791             :    {
   88792           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   88793           5 :      SgEquivalenceStatement* pointer = NULL;
   88794           5 :      std::vector < unsigned char* > :: const_iterator block;
   88795           5 :      SgEquivalenceStatement* pointerOfLinkedList = NULL;
   88796           5 :      for ( block = SgEquivalenceStatement::pools.begin(); block != SgEquivalenceStatement::pools.end() ; ++block )
   88797             :         {
   88798           0 :           pointer = (SgEquivalenceStatement*)(*block);
   88799           0 :           for (unsigned i = 0; i < SgEquivalenceStatement::pool_size; ++i )
   88800             :              {
   88801             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   88802             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   88803             :             // memory blocks!.
   88804           0 :                if ( pointer[i].get_freepointer() != NULL )
   88805             :                   {
   88806           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   88807             :                   }
   88808             :                else
   88809             :                   {
   88810           0 :                     if ( pointerOfLinkedList == NULL )
   88811             :                        {
   88812           0 :                          SgEquivalenceStatement::next_node = &(pointer[i]);
   88813             :                        }
   88814             :                     else
   88815             :                        {
   88816             :                       // printf ("In SgEquivalenceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   88817           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   88818             :                        }
   88819             :                     pointerOfLinkedList = &(pointer[i]);
   88820             :                   }
   88821             :               }
   88822             :         }
   88823             : 
   88824           5 :      if ( pointerOfLinkedList != NULL )
   88825             :         {
   88826             :        // printf ("In SgEquivalenceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   88827           0 :           pointerOfLinkedList->set_freepointer(NULL);
   88828             :        // DQ (6/6/2010): Temporary debugging...
   88829             :        //   ROSE_ASSERT(false);
   88830             :         }
   88831             : 
   88832           5 :      return ;
   88833             :    }
   88834             : 
   88835             : //############################################################################
   88836             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   88837             :  * within the memory pool and resets the freepointers, in order to achieve a 
   88838             :  * linked list, that has no jumps and starts at the beginning! This function 
   88839             :  * does not extend the memory pool, since we do not delete any memory blocks,
   88840             :  * but delete the valid objects.  
   88841             :  */
   88842             : void
   88843           0 : SgEquivalenceStatement::clearMemoryPool( )
   88844             :    {
   88845             :   // printf ("Inside of SgEquivalenceStatement::clearMemoryPool() \n");
   88846             : 
   88847           0 :      SgEquivalenceStatement* pointer = NULL, *tempPointer = NULL;
   88848           0 :      std::vector < unsigned char* > :: const_iterator block;
   88849           0 :      if ( SgEquivalenceStatement::pools.empty() == false )
   88850             :         {
   88851           0 :           block = SgEquivalenceStatement::pools.begin() ;
   88852           0 :           SgEquivalenceStatement::next_node = (SgEquivalenceStatement*) (*block);
   88853             : 
   88854           0 :           while ( block != SgEquivalenceStatement::pools.end() )
   88855             :              {
   88856           0 :                pointer = (SgEquivalenceStatement*) (*block);
   88857           0 :                if ( tempPointer != NULL )
   88858             :                   {
   88859           0 :                     tempPointer->set_freepointer(pointer);
   88860             :                   }
   88861           0 :                for (unsigned i = 0; i < SgEquivalenceStatement::pool_size - 1; ++i)
   88862             :                   {
   88863           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   88864             :                   }
   88865           0 :                 pointer[SgEquivalenceStatement::pool_size-1].set_freepointer(NULL);
   88866           0 :                 tempPointer = &(pointer[SgEquivalenceStatement::pool_size-1]);
   88867           0 :                 ++block;
   88868             :              }
   88869             :         }
   88870           0 :    }
   88871             : 
   88872           5 : void SgEquivalenceStatement::deleteMemoryPool() {
   88873           5 :   for (auto p: SgEquivalenceStatement::pools) {
   88874           0 :     ROSE_FREE(p);
   88875             :   }
   88876           5 :   SgEquivalenceStatement::next_node = nullptr;
   88877           5 :   SgEquivalenceStatement::pools.clear();
   88878           5 : }
   88879             : 
   88880             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   88881             : //                 reading multiple binary files to for a single AST.
   88882             : /////////// new version ////////////////////////////////
   88883             : //############################################################################
   88884             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   88885             : void
   88886           2 : SgEquivalenceStatement::extendMemoryPoolForFileIO( )
   88887             :   {
   88888           2 :     size_t blockIndex = SgEquivalenceStatement::pools.size();
   88889           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEquivalenceStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEquivalenceStatement);
   88890             : 
   88891           2 :     while ( (blockIndex * SgEquivalenceStatement::pool_size) < newPoolSize)
   88892             :       {
   88893             : #if ROSE_ALLOC_TRACE
   88894             :         if (blockIndex > 0) {
   88895             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEquivalenceStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEquivalenceStatement) = %" PRIuPTR " SgEquivalenceStatement::pool_size = %d \n",
   88896             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEquivalenceStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEquivalenceStatement),SgEquivalenceStatement::pool_size);
   88897             :         }
   88898             : #endif
   88899             : 
   88900           0 :         SgEquivalenceStatement * pointer = (SgEquivalenceStatement*) ROSE_MALLOC ( SgEquivalenceStatement::pool_size * sizeof(SgEquivalenceStatement) );
   88901           0 :         assert( pointer != NULL );
   88902             : #if ROSE_ALLOC_MEMSET == 1
   88903             :         memset(pointer, 0x00, SgEquivalenceStatement::pool_size * sizeof(SgEquivalenceStatement));
   88904             : #elif ROSE_ALLOC_MEMSET == 2
   88905             :         memset(pointer, 0xCC, SgEquivalenceStatement::pool_size * sizeof(SgEquivalenceStatement));
   88906             : #endif
   88907           0 :         SgEquivalenceStatement::pools.push_back( (unsigned char*)(pointer) );
   88908           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEquivalenceStatement::pool_size * sizeof(SgEquivalenceStatement), V_SgEquivalenceStatement ) );
   88909             : 
   88910           0 :         if ( SgEquivalenceStatement::next_node != NULL ) {
   88911           0 :           if ( blockIndex > 0 ) {
   88912           0 :             SgEquivalenceStatement * blkptr = (SgEquivalenceStatement*)(SgEquivalenceStatement::pools[blockIndex-1]);
   88913           0 :             blkptr[ SgEquivalenceStatement::pool_size - 1 ].set_freepointer(pointer);
   88914             :           }
   88915             :         } else {
   88916           0 :           SgEquivalenceStatement::next_node = pointer;
   88917             :         }
   88918             : 
   88919           0 :         for (unsigned i = 0; i < SgEquivalenceStatement::pool_size-1; ++i)
   88920             :            {
   88921           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   88922             :            }
   88923           0 :         pointer[ SgEquivalenceStatement::pool_size -1 ].set_freepointer(NULL);
   88924             : 
   88925           0 :         blockIndex++;
   88926             :       }
   88927           2 :   }
   88928             : 
   88929             : //############################################################################
   88930             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   88931             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   88932             :  * not compressed. However, that stuff is not yet implemented! 
   88933             :  */
   88934             : unsigned long
   88935           0 : SgEquivalenceStatement::getNumberOfLastValidPointer()
   88936             :    {
   88937           0 :       SgEquivalenceStatement* testPointer = (SgEquivalenceStatement*)(SgEquivalenceStatement::pools.back());
   88938           0 :       unsigned long localIndex = SgEquivalenceStatement::pool_size - 1;
   88939           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   88940             :          {
   88941           0 :            localIndex--;
   88942             :          }
   88943           0 :       return (localIndex + SgEquivalenceStatement::pool_size * (SgEquivalenceStatement::pools.size()-1));
   88944             :    }
   88945             : 
   88946             : //############################################################################
   88947             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   88948             :  * memory pool and initializes the data member in class SgEquivalenceStatementStroageClass
   88949             :  * from its counterpart of SgEquivalenceStatement. The return value is just for checking, 
   88950             :  * that the whole StorageClassArray is initialized!
   88951             :  */
   88952             : unsigned long
   88953           0 : SgEquivalenceStatement::initializeStorageClassArray( SgEquivalenceStatementStorageClass *storageArray )
   88954             :    {
   88955           0 :      unsigned long storageCounter = 0;
   88956           0 :      std::vector < unsigned char* > :: const_iterator block = SgEquivalenceStatement::pools.begin();
   88957           0 :      SgEquivalenceStatement* pointer = NULL;
   88958           0 :      while ( block != SgEquivalenceStatement::pools.end() ) {
   88959           0 :           pointer = (SgEquivalenceStatement*) (*block);
   88960           0 :           for ( unsigned i = 0; i < SgEquivalenceStatement::pool_size; ++i ) {
   88961           0 :                if ( pointer->get_freepointer() != NULL ) {
   88962           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   88963           0 :                  storageArray++;
   88964           0 :                  storageCounter++;
   88965             :                }
   88966           0 :                pointer++;
   88967             :              }
   88968           0 :            block++;
   88969             :         }
   88970           0 :      return storageCounter;
   88971             :    }
   88972             : 
   88973             : /* #line 88974 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   88974             : 
   88975             : 
   88976             : 
   88977             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   88978             : 
   88979             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   88980             : 
   88981             : //############################################################################
   88982             : /* JH (02/02/2006) Constructor of the IR node SgInterfaceStatement that takes its 
   88983             :  * corresponding StorageClass as parameter
   88984             :  */
   88985           0 : SgInterfaceStatement :: SgInterfaceStatement ( const SgInterfaceStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   88986             :    {
   88987             : 
   88988             : 
   88989             : /* #line 88990 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   88990             : 
   88991           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   88992           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
   88993           0 :      p_generic_spec = storageSource.storageOf_generic_spec ;
   88994           0 :      p_interface_body_list = storageSource.storageOf_interface_body_list.rebuildDataStoredInEasyStorageClass() ;
   88995           0 :      SgInterfaceBodyPtrList::iterator i_interface_body_list = p_interface_body_list.begin() ; 
   88996           0 :      for ( ; i_interface_body_list != p_interface_body_list.end(); ++i_interface_body_list ) 
   88997             :         {
   88998           0 :           (*i_interface_body_list) = (SgInterfaceBodyPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_interface_body_list) ) );
   88999             :         }
   89000           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   89001             : 
   89002             : 
   89003             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   89004             : 
   89005             : 
   89006           0 :    }
   89007             : 
   89008             : //############################################################################
   89009             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   89010             :  * within the working AST. 
   89011             :  */
   89012           0 : SgInterfaceStatement * SgInterfaceStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   89013           0 :      SgInterfaceStatement* returnPointer = NULL;
   89014           0 :      if ( globalIndex != 0 )
   89015             :         {
   89016             : 
   89017             : #if FILE_IO_EXTRA_CHECK
   89018           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgInterfaceStatement ) ) <= globalIndex ) ;
   89019           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInterfaceStatement + 1 ) ) );
   89020             : #endif
   89021           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInterfaceStatement )  
   89022           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgInterfaceStatement );
   89023           0 :           unsigned long positionInPool = localIndex % SgInterfaceStatement::pool_size;
   89024           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInterfaceStatement::pool_size;
   89025             : 
   89026             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   89027             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   89028             : 
   89029           0 :           returnPointer = &( ( (SgInterfaceStatement*)(SgInterfaceStatement::pools[memoryBlock]) ) [positionInPool]) ;
   89030             : 
   89031           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   89032             :         }
   89033           0 :      return returnPointer ;
   89034             :    }
   89035             : 
   89036             : //############################################################################
   89037             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   89038             :   for the AST with the index astIndex
   89039             : */
   89040           0 : SgInterfaceStatement * SgInterfaceStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   89041           0 :      SgInterfaceStatement* returnPointer = NULL;
   89042           0 :      if ( globalIndex != 0 )
   89043             :         {
   89044             : 
   89045             : #if FILE_IO_EXTRA_CHECK
   89046           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgInterfaceStatement ) ) <= globalIndex ) ;
   89047           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInterfaceStatement + 1 ) ) );
   89048             : #endif
   89049           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInterfaceStatement )
   89050           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgInterfaceStatement );
   89051           0 :           unsigned long positionInPool = localIndex % SgInterfaceStatement::pool_size ;
   89052           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInterfaceStatement::pool_size ;
   89053             : 
   89054             : #if FILE_IO_EXTRA_CHECK
   89055             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   89056             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   89057             : #endif
   89058             : 
   89059           0 :           returnPointer = &( ( (SgInterfaceStatement*)(SgInterfaceStatement::pools[memoryBlock]) ) [positionInPool]) ;
   89060             : 
   89061             : #if FILE_IO_EXTRA_CHECK
   89062           0 :           assert ( returnPointer != NULL ) ;
   89063             : #endif
   89064             :         }
   89065           0 :      return returnPointer ;
   89066             :    }
   89067             : 
   89068             : //############################################################################
   89069             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   89070             :  * pool size! We set for every valid object in the memory pool the freepointer
   89071             :  * to the global index and increase the global index afterwards. For all the 
   89072             :  * invalid objects (means address ranges within the memory pool that were not
   89073             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   89074             :  * distinguish valid from invalid objects! 
   89075             :  */
   89076             : unsigned long
   89077           5 : SgInterfaceStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   89078             :    {
   89079           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   89080           5 :      SgInterfaceStatement* pointer = NULL;
   89081           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   89082           5 :      std::vector < unsigned char* > :: const_iterator block;
   89083           5 :      for ( block = SgInterfaceStatement::pools.begin(); block != SgInterfaceStatement::pools.end() ; ++block )
   89084             :         {
   89085           0 :           pointer = (SgInterfaceStatement*)(*block);
   89086           0 :           for (unsigned i = 0; i < SgInterfaceStatement::pool_size; ++i )
   89087             :              {
   89088             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   89089             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   89090             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   89091             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   89092             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   89093             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   89094             :             // properly; so this will have to be checked next.
   89095             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   89096             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   89097           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   89098             :                   {
   89099           0 :                     pointer[i].set_freepointer((SgInterfaceStatement*)(globalIndex));
   89100           0 :                     globalIndex++;
   89101             :                   }
   89102             :                else
   89103             :                   {
   89104           0 :                     pointer[i].set_freepointer(NULL);
   89105             :                   }
   89106             :               }
   89107             :         }
   89108           5 :      return globalIndex;
   89109             :    }
   89110             : 
   89111             : //############################################################################
   89112             : // JH (01/14/2006)
   89113             : void
   89114           5 : SgInterfaceStatement::resetValidFreepointers( )
   89115             :    {
   89116           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   89117           5 :      SgInterfaceStatement* pointer = NULL;
   89118           5 :      std::vector < unsigned char* > :: const_iterator block;
   89119           5 :      SgInterfaceStatement* pointerOfLinkedList = NULL;
   89120           5 :      for ( block = SgInterfaceStatement::pools.begin(); block != SgInterfaceStatement::pools.end() ; ++block )
   89121             :         {
   89122           0 :           pointer = (SgInterfaceStatement*)(*block);
   89123           0 :           for (unsigned i = 0; i < SgInterfaceStatement::pool_size; ++i )
   89124             :              {
   89125             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   89126             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   89127             :             // memory blocks!.
   89128           0 :                if ( pointer[i].get_freepointer() != NULL )
   89129             :                   {
   89130           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   89131             :                   }
   89132             :                else
   89133             :                   {
   89134           0 :                     if ( pointerOfLinkedList == NULL )
   89135             :                        {
   89136           0 :                          SgInterfaceStatement::next_node = &(pointer[i]);
   89137             :                        }
   89138             :                     else
   89139             :                        {
   89140             :                       // printf ("In SgInterfaceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   89141           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   89142             :                        }
   89143             :                     pointerOfLinkedList = &(pointer[i]);
   89144             :                   }
   89145             :               }
   89146             :         }
   89147             : 
   89148           5 :      if ( pointerOfLinkedList != NULL )
   89149             :         {
   89150             :        // printf ("In SgInterfaceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   89151           0 :           pointerOfLinkedList->set_freepointer(NULL);
   89152             :        // DQ (6/6/2010): Temporary debugging...
   89153             :        //   ROSE_ASSERT(false);
   89154             :         }
   89155             : 
   89156           5 :      return ;
   89157             :    }
   89158             : 
   89159             : //############################################################################
   89160             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   89161             :  * within the memory pool and resets the freepointers, in order to achieve a 
   89162             :  * linked list, that has no jumps and starts at the beginning! This function 
   89163             :  * does not extend the memory pool, since we do not delete any memory blocks,
   89164             :  * but delete the valid objects.  
   89165             :  */
   89166             : void
   89167           0 : SgInterfaceStatement::clearMemoryPool( )
   89168             :    {
   89169             :   // printf ("Inside of SgInterfaceStatement::clearMemoryPool() \n");
   89170             : 
   89171           0 :      SgInterfaceStatement* pointer = NULL, *tempPointer = NULL;
   89172           0 :      std::vector < unsigned char* > :: const_iterator block;
   89173           0 :      if ( SgInterfaceStatement::pools.empty() == false )
   89174             :         {
   89175           0 :           block = SgInterfaceStatement::pools.begin() ;
   89176           0 :           SgInterfaceStatement::next_node = (SgInterfaceStatement*) (*block);
   89177             : 
   89178           0 :           while ( block != SgInterfaceStatement::pools.end() )
   89179             :              {
   89180           0 :                pointer = (SgInterfaceStatement*) (*block);
   89181           0 :                if ( tempPointer != NULL )
   89182             :                   {
   89183           0 :                     tempPointer->set_freepointer(pointer);
   89184             :                   }
   89185           0 :                for (unsigned i = 0; i < SgInterfaceStatement::pool_size - 1; ++i)
   89186             :                   {
   89187           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   89188             :                   }
   89189           0 :                 pointer[SgInterfaceStatement::pool_size-1].set_freepointer(NULL);
   89190           0 :                 tempPointer = &(pointer[SgInterfaceStatement::pool_size-1]);
   89191           0 :                 ++block;
   89192             :              }
   89193             :         }
   89194           0 :    }
   89195             : 
   89196           5 : void SgInterfaceStatement::deleteMemoryPool() {
   89197           5 :   for (auto p: SgInterfaceStatement::pools) {
   89198           0 :     ROSE_FREE(p);
   89199             :   }
   89200           5 :   SgInterfaceStatement::next_node = nullptr;
   89201           5 :   SgInterfaceStatement::pools.clear();
   89202           5 : }
   89203             : 
   89204             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   89205             : //                 reading multiple binary files to for a single AST.
   89206             : /////////// new version ////////////////////////////////
   89207             : //############################################################################
   89208             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   89209             : void
   89210           2 : SgInterfaceStatement::extendMemoryPoolForFileIO( )
   89211             :   {
   89212           2 :     size_t blockIndex = SgInterfaceStatement::pools.size();
   89213           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceStatement);
   89214             : 
   89215           2 :     while ( (blockIndex * SgInterfaceStatement::pool_size) < newPoolSize)
   89216             :       {
   89217             : #if ROSE_ALLOC_TRACE
   89218             :         if (blockIndex > 0) {
   89219             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceStatement) = %" PRIuPTR " SgInterfaceStatement::pool_size = %d \n",
   89220             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceStatement),SgInterfaceStatement::pool_size);
   89221             :         }
   89222             : #endif
   89223             : 
   89224           0 :         SgInterfaceStatement * pointer = (SgInterfaceStatement*) ROSE_MALLOC ( SgInterfaceStatement::pool_size * sizeof(SgInterfaceStatement) );
   89225           0 :         assert( pointer != NULL );
   89226             : #if ROSE_ALLOC_MEMSET == 1
   89227             :         memset(pointer, 0x00, SgInterfaceStatement::pool_size * sizeof(SgInterfaceStatement));
   89228             : #elif ROSE_ALLOC_MEMSET == 2
   89229             :         memset(pointer, 0xCC, SgInterfaceStatement::pool_size * sizeof(SgInterfaceStatement));
   89230             : #endif
   89231           0 :         SgInterfaceStatement::pools.push_back( (unsigned char*)(pointer) );
   89232           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgInterfaceStatement::pool_size * sizeof(SgInterfaceStatement), V_SgInterfaceStatement ) );
   89233             : 
   89234           0 :         if ( SgInterfaceStatement::next_node != NULL ) {
   89235           0 :           if ( blockIndex > 0 ) {
   89236           0 :             SgInterfaceStatement * blkptr = (SgInterfaceStatement*)(SgInterfaceStatement::pools[blockIndex-1]);
   89237           0 :             blkptr[ SgInterfaceStatement::pool_size - 1 ].set_freepointer(pointer);
   89238             :           }
   89239             :         } else {
   89240           0 :           SgInterfaceStatement::next_node = pointer;
   89241             :         }
   89242             : 
   89243           0 :         for (unsigned i = 0; i < SgInterfaceStatement::pool_size-1; ++i)
   89244             :            {
   89245           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   89246             :            }
   89247           0 :         pointer[ SgInterfaceStatement::pool_size -1 ].set_freepointer(NULL);
   89248             : 
   89249           0 :         blockIndex++;
   89250             :       }
   89251           2 :   }
   89252             : 
   89253             : //############################################################################
   89254             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   89255             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   89256             :  * not compressed. However, that stuff is not yet implemented! 
   89257             :  */
   89258             : unsigned long
   89259           0 : SgInterfaceStatement::getNumberOfLastValidPointer()
   89260             :    {
   89261           0 :       SgInterfaceStatement* testPointer = (SgInterfaceStatement*)(SgInterfaceStatement::pools.back());
   89262           0 :       unsigned long localIndex = SgInterfaceStatement::pool_size - 1;
   89263           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   89264             :          {
   89265           0 :            localIndex--;
   89266             :          }
   89267           0 :       return (localIndex + SgInterfaceStatement::pool_size * (SgInterfaceStatement::pools.size()-1));
   89268             :    }
   89269             : 
   89270             : //############################################################################
   89271             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   89272             :  * memory pool and initializes the data member in class SgInterfaceStatementStroageClass
   89273             :  * from its counterpart of SgInterfaceStatement. The return value is just for checking, 
   89274             :  * that the whole StorageClassArray is initialized!
   89275             :  */
   89276             : unsigned long
   89277           0 : SgInterfaceStatement::initializeStorageClassArray( SgInterfaceStatementStorageClass *storageArray )
   89278             :    {
   89279           0 :      unsigned long storageCounter = 0;
   89280           0 :      std::vector < unsigned char* > :: const_iterator block = SgInterfaceStatement::pools.begin();
   89281           0 :      SgInterfaceStatement* pointer = NULL;
   89282           0 :      while ( block != SgInterfaceStatement::pools.end() ) {
   89283           0 :           pointer = (SgInterfaceStatement*) (*block);
   89284           0 :           for ( unsigned i = 0; i < SgInterfaceStatement::pool_size; ++i ) {
   89285           0 :                if ( pointer->get_freepointer() != NULL ) {
   89286           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   89287           0 :                  storageArray++;
   89288           0 :                  storageCounter++;
   89289             :                }
   89290           0 :                pointer++;
   89291             :              }
   89292           0 :            block++;
   89293             :         }
   89294           0 :      return storageCounter;
   89295             :    }
   89296             : 
   89297             : /* #line 89298 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   89298             : 
   89299             : 
   89300             : 
   89301             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   89302             : 
   89303             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   89304             : 
   89305             : //############################################################################
   89306             : /* JH (02/02/2006) Constructor of the IR node SgNamespaceAliasDeclarationStatement that takes its 
   89307             :  * corresponding StorageClass as parameter
   89308             :  */
   89309           0 : SgNamespaceAliasDeclarationStatement :: SgNamespaceAliasDeclarationStatement ( const SgNamespaceAliasDeclarationStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   89310             :    {
   89311             : 
   89312             : 
   89313             : /* #line 89314 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   89314             : 
   89315           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   89316           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
   89317           0 :      p_namespaceDeclaration =  (SgNamespaceDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_namespaceDeclaration) );
   89318           0 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   89319           0 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   89320           0 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   89321           0 :      p_is_alias_for_another_namespace_alias = storageSource.storageOf_is_alias_for_another_namespace_alias ;
   89322           0 :      p_namespaceAliasDeclaration =  (SgNamespaceAliasDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_namespaceAliasDeclaration) );
   89323             : 
   89324             : 
   89325             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   89326             : 
   89327             : 
   89328           0 :    }
   89329             : 
   89330             : //############################################################################
   89331             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   89332             :  * within the working AST. 
   89333             :  */
   89334           0 : SgNamespaceAliasDeclarationStatement * SgNamespaceAliasDeclarationStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   89335           0 :      SgNamespaceAliasDeclarationStatement* returnPointer = NULL;
   89336           0 :      if ( globalIndex != 0 )
   89337             :         {
   89338             : 
   89339             : #if FILE_IO_EXTRA_CHECK
   89340           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNamespaceAliasDeclarationStatement ) ) <= globalIndex ) ;
   89341           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamespaceAliasDeclarationStatement + 1 ) ) );
   89342             : #endif
   89343           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamespaceAliasDeclarationStatement )  
   89344           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNamespaceAliasDeclarationStatement );
   89345           0 :           unsigned long positionInPool = localIndex % SgNamespaceAliasDeclarationStatement::pool_size;
   89346           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamespaceAliasDeclarationStatement::pool_size;
   89347             : 
   89348             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   89349             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   89350             : 
   89351           0 :           returnPointer = &( ( (SgNamespaceAliasDeclarationStatement*)(SgNamespaceAliasDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   89352             : 
   89353           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   89354             :         }
   89355           0 :      return returnPointer ;
   89356             :    }
   89357             : 
   89358             : //############################################################################
   89359             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   89360             :   for the AST with the index astIndex
   89361             : */
   89362           0 : SgNamespaceAliasDeclarationStatement * SgNamespaceAliasDeclarationStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   89363           0 :      SgNamespaceAliasDeclarationStatement* returnPointer = NULL;
   89364           0 :      if ( globalIndex != 0 )
   89365             :         {
   89366             : 
   89367             : #if FILE_IO_EXTRA_CHECK
   89368           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNamespaceAliasDeclarationStatement ) ) <= globalIndex ) ;
   89369           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamespaceAliasDeclarationStatement + 1 ) ) );
   89370             : #endif
   89371           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamespaceAliasDeclarationStatement )
   89372           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNamespaceAliasDeclarationStatement );
   89373           0 :           unsigned long positionInPool = localIndex % SgNamespaceAliasDeclarationStatement::pool_size ;
   89374           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamespaceAliasDeclarationStatement::pool_size ;
   89375             : 
   89376             : #if FILE_IO_EXTRA_CHECK
   89377             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   89378             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   89379             : #endif
   89380             : 
   89381           0 :           returnPointer = &( ( (SgNamespaceAliasDeclarationStatement*)(SgNamespaceAliasDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   89382             : 
   89383             : #if FILE_IO_EXTRA_CHECK
   89384           0 :           assert ( returnPointer != NULL ) ;
   89385             : #endif
   89386             :         }
   89387           0 :      return returnPointer ;
   89388             :    }
   89389             : 
   89390             : //############################################################################
   89391             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   89392             :  * pool size! We set for every valid object in the memory pool the freepointer
   89393             :  * to the global index and increase the global index afterwards. For all the 
   89394             :  * invalid objects (means address ranges within the memory pool that were not
   89395             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   89396             :  * distinguish valid from invalid objects! 
   89397             :  */
   89398             : unsigned long
   89399           5 : SgNamespaceAliasDeclarationStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   89400             :    {
   89401           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   89402           5 :      SgNamespaceAliasDeclarationStatement* pointer = NULL;
   89403           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   89404           5 :      std::vector < unsigned char* > :: const_iterator block;
   89405           5 :      for ( block = SgNamespaceAliasDeclarationStatement::pools.begin(); block != SgNamespaceAliasDeclarationStatement::pools.end() ; ++block )
   89406             :         {
   89407           0 :           pointer = (SgNamespaceAliasDeclarationStatement*)(*block);
   89408           0 :           for (unsigned i = 0; i < SgNamespaceAliasDeclarationStatement::pool_size; ++i )
   89409             :              {
   89410             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   89411             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   89412             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   89413             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   89414             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   89415             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   89416             :             // properly; so this will have to be checked next.
   89417             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   89418             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   89419           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   89420             :                   {
   89421           0 :                     pointer[i].set_freepointer((SgNamespaceAliasDeclarationStatement*)(globalIndex));
   89422           0 :                     globalIndex++;
   89423             :                   }
   89424             :                else
   89425             :                   {
   89426           0 :                     pointer[i].set_freepointer(NULL);
   89427             :                   }
   89428             :               }
   89429             :         }
   89430           5 :      return globalIndex;
   89431             :    }
   89432             : 
   89433             : //############################################################################
   89434             : // JH (01/14/2006)
   89435             : void
   89436           5 : SgNamespaceAliasDeclarationStatement::resetValidFreepointers( )
   89437             :    {
   89438           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   89439           5 :      SgNamespaceAliasDeclarationStatement* pointer = NULL;
   89440           5 :      std::vector < unsigned char* > :: const_iterator block;
   89441           5 :      SgNamespaceAliasDeclarationStatement* pointerOfLinkedList = NULL;
   89442           5 :      for ( block = SgNamespaceAliasDeclarationStatement::pools.begin(); block != SgNamespaceAliasDeclarationStatement::pools.end() ; ++block )
   89443             :         {
   89444           0 :           pointer = (SgNamespaceAliasDeclarationStatement*)(*block);
   89445           0 :           for (unsigned i = 0; i < SgNamespaceAliasDeclarationStatement::pool_size; ++i )
   89446             :              {
   89447             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   89448             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   89449             :             // memory blocks!.
   89450           0 :                if ( pointer[i].get_freepointer() != NULL )
   89451             :                   {
   89452           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   89453             :                   }
   89454             :                else
   89455             :                   {
   89456           0 :                     if ( pointerOfLinkedList == NULL )
   89457             :                        {
   89458           0 :                          SgNamespaceAliasDeclarationStatement::next_node = &(pointer[i]);
   89459             :                        }
   89460             :                     else
   89461             :                        {
   89462             :                       // printf ("In SgNamespaceAliasDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   89463           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   89464             :                        }
   89465             :                     pointerOfLinkedList = &(pointer[i]);
   89466             :                   }
   89467             :               }
   89468             :         }
   89469             : 
   89470           5 :      if ( pointerOfLinkedList != NULL )
   89471             :         {
   89472             :        // printf ("In SgNamespaceAliasDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   89473           0 :           pointerOfLinkedList->set_freepointer(NULL);
   89474             :        // DQ (6/6/2010): Temporary debugging...
   89475             :        //   ROSE_ASSERT(false);
   89476             :         }
   89477             : 
   89478           5 :      return ;
   89479             :    }
   89480             : 
   89481             : //############################################################################
   89482             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   89483             :  * within the memory pool and resets the freepointers, in order to achieve a 
   89484             :  * linked list, that has no jumps and starts at the beginning! This function 
   89485             :  * does not extend the memory pool, since we do not delete any memory blocks,
   89486             :  * but delete the valid objects.  
   89487             :  */
   89488             : void
   89489           0 : SgNamespaceAliasDeclarationStatement::clearMemoryPool( )
   89490             :    {
   89491             :   // printf ("Inside of SgNamespaceAliasDeclarationStatement::clearMemoryPool() \n");
   89492             : 
   89493           0 :      SgNamespaceAliasDeclarationStatement* pointer = NULL, *tempPointer = NULL;
   89494           0 :      std::vector < unsigned char* > :: const_iterator block;
   89495           0 :      if ( SgNamespaceAliasDeclarationStatement::pools.empty() == false )
   89496             :         {
   89497           0 :           block = SgNamespaceAliasDeclarationStatement::pools.begin() ;
   89498           0 :           SgNamespaceAliasDeclarationStatement::next_node = (SgNamespaceAliasDeclarationStatement*) (*block);
   89499             : 
   89500           0 :           while ( block != SgNamespaceAliasDeclarationStatement::pools.end() )
   89501             :              {
   89502           0 :                pointer = (SgNamespaceAliasDeclarationStatement*) (*block);
   89503           0 :                if ( tempPointer != NULL )
   89504             :                   {
   89505           0 :                     tempPointer->set_freepointer(pointer);
   89506             :                   }
   89507           0 :                for (unsigned i = 0; i < SgNamespaceAliasDeclarationStatement::pool_size - 1; ++i)
   89508             :                   {
   89509           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   89510             :                   }
   89511           0 :                 pointer[SgNamespaceAliasDeclarationStatement::pool_size-1].set_freepointer(NULL);
   89512           0 :                 tempPointer = &(pointer[SgNamespaceAliasDeclarationStatement::pool_size-1]);
   89513           0 :                 ++block;
   89514             :              }
   89515             :         }
   89516           0 :    }
   89517             : 
   89518           5 : void SgNamespaceAliasDeclarationStatement::deleteMemoryPool() {
   89519           5 :   for (auto p: SgNamespaceAliasDeclarationStatement::pools) {
   89520           0 :     ROSE_FREE(p);
   89521             :   }
   89522           5 :   SgNamespaceAliasDeclarationStatement::next_node = nullptr;
   89523           5 :   SgNamespaceAliasDeclarationStatement::pools.clear();
   89524           5 : }
   89525             : 
   89526             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   89527             : //                 reading multiple binary files to for a single AST.
   89528             : /////////// new version ////////////////////////////////
   89529             : //############################################################################
   89530             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   89531             : void
   89532           2 : SgNamespaceAliasDeclarationStatement::extendMemoryPoolForFileIO( )
   89533             :   {
   89534           2 :     size_t blockIndex = SgNamespaceAliasDeclarationStatement::pools.size();
   89535           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceAliasDeclarationStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceAliasDeclarationStatement);
   89536             : 
   89537           2 :     while ( (blockIndex * SgNamespaceAliasDeclarationStatement::pool_size) < newPoolSize)
   89538             :       {
   89539             : #if ROSE_ALLOC_TRACE
   89540             :         if (blockIndex > 0) {
   89541             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceAliasDeclarationStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceAliasDeclarationStatement) = %" PRIuPTR " SgNamespaceAliasDeclarationStatement::pool_size = %d \n",
   89542             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceAliasDeclarationStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceAliasDeclarationStatement),SgNamespaceAliasDeclarationStatement::pool_size);
   89543             :         }
   89544             : #endif
   89545             : 
   89546           0 :         SgNamespaceAliasDeclarationStatement * pointer = (SgNamespaceAliasDeclarationStatement*) ROSE_MALLOC ( SgNamespaceAliasDeclarationStatement::pool_size * sizeof(SgNamespaceAliasDeclarationStatement) );
   89547           0 :         assert( pointer != NULL );
   89548             : #if ROSE_ALLOC_MEMSET == 1
   89549             :         memset(pointer, 0x00, SgNamespaceAliasDeclarationStatement::pool_size * sizeof(SgNamespaceAliasDeclarationStatement));
   89550             : #elif ROSE_ALLOC_MEMSET == 2
   89551             :         memset(pointer, 0xCC, SgNamespaceAliasDeclarationStatement::pool_size * sizeof(SgNamespaceAliasDeclarationStatement));
   89552             : #endif
   89553           0 :         SgNamespaceAliasDeclarationStatement::pools.push_back( (unsigned char*)(pointer) );
   89554           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNamespaceAliasDeclarationStatement::pool_size * sizeof(SgNamespaceAliasDeclarationStatement), V_SgNamespaceAliasDeclarationStatement ) );
   89555             : 
   89556           0 :         if ( SgNamespaceAliasDeclarationStatement::next_node != NULL ) {
   89557           0 :           if ( blockIndex > 0 ) {
   89558           0 :             SgNamespaceAliasDeclarationStatement * blkptr = (SgNamespaceAliasDeclarationStatement*)(SgNamespaceAliasDeclarationStatement::pools[blockIndex-1]);
   89559           0 :             blkptr[ SgNamespaceAliasDeclarationStatement::pool_size - 1 ].set_freepointer(pointer);
   89560             :           }
   89561             :         } else {
   89562           0 :           SgNamespaceAliasDeclarationStatement::next_node = pointer;
   89563             :         }
   89564             : 
   89565           0 :         for (unsigned i = 0; i < SgNamespaceAliasDeclarationStatement::pool_size-1; ++i)
   89566             :            {
   89567           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   89568             :            }
   89569           0 :         pointer[ SgNamespaceAliasDeclarationStatement::pool_size -1 ].set_freepointer(NULL);
   89570             : 
   89571           0 :         blockIndex++;
   89572             :       }
   89573           2 :   }
   89574             : 
   89575             : //############################################################################
   89576             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   89577             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   89578             :  * not compressed. However, that stuff is not yet implemented! 
   89579             :  */
   89580             : unsigned long
   89581           0 : SgNamespaceAliasDeclarationStatement::getNumberOfLastValidPointer()
   89582             :    {
   89583           0 :       SgNamespaceAliasDeclarationStatement* testPointer = (SgNamespaceAliasDeclarationStatement*)(SgNamespaceAliasDeclarationStatement::pools.back());
   89584           0 :       unsigned long localIndex = SgNamespaceAliasDeclarationStatement::pool_size - 1;
   89585           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   89586             :          {
   89587           0 :            localIndex--;
   89588             :          }
   89589           0 :       return (localIndex + SgNamespaceAliasDeclarationStatement::pool_size * (SgNamespaceAliasDeclarationStatement::pools.size()-1));
   89590             :    }
   89591             : 
   89592             : //############################################################################
   89593             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   89594             :  * memory pool and initializes the data member in class SgNamespaceAliasDeclarationStatementStroageClass
   89595             :  * from its counterpart of SgNamespaceAliasDeclarationStatement. The return value is just for checking, 
   89596             :  * that the whole StorageClassArray is initialized!
   89597             :  */
   89598             : unsigned long
   89599           0 : SgNamespaceAliasDeclarationStatement::initializeStorageClassArray( SgNamespaceAliasDeclarationStatementStorageClass *storageArray )
   89600             :    {
   89601           0 :      unsigned long storageCounter = 0;
   89602           0 :      std::vector < unsigned char* > :: const_iterator block = SgNamespaceAliasDeclarationStatement::pools.begin();
   89603           0 :      SgNamespaceAliasDeclarationStatement* pointer = NULL;
   89604           0 :      while ( block != SgNamespaceAliasDeclarationStatement::pools.end() ) {
   89605           0 :           pointer = (SgNamespaceAliasDeclarationStatement*) (*block);
   89606           0 :           for ( unsigned i = 0; i < SgNamespaceAliasDeclarationStatement::pool_size; ++i ) {
   89607           0 :                if ( pointer->get_freepointer() != NULL ) {
   89608           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   89609           0 :                  storageArray++;
   89610           0 :                  storageCounter++;
   89611             :                }
   89612           0 :                pointer++;
   89613             :              }
   89614           0 :            block++;
   89615             :         }
   89616           0 :      return storageCounter;
   89617             :    }
   89618             : 
   89619             : /* #line 89620 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   89620             : 
   89621             : 
   89622             : 
   89623             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   89624             : 
   89625             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   89626             : 
   89627             : //############################################################################
   89628             : /* JH (02/02/2006) Constructor of the IR node SgCommonBlock that takes its 
   89629             :  * corresponding StorageClass as parameter
   89630             :  */
   89631           0 : SgCommonBlock :: SgCommonBlock ( const SgCommonBlockStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   89632             :    {
   89633             : 
   89634             : 
   89635             : /* #line 89636 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   89636             : 
   89637           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   89638           0 :      p_block_list = storageSource.storageOf_block_list.rebuildDataStoredInEasyStorageClass() ;
   89639           0 :      SgCommonBlockObjectPtrList::iterator i_block_list = p_block_list.begin() ; 
   89640           0 :      for ( ; i_block_list != p_block_list.end(); ++i_block_list ) 
   89641             :         {
   89642           0 :           (*i_block_list) = (SgCommonBlockObjectPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_block_list) ) );
   89643             :         }
   89644             : 
   89645             : 
   89646             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   89647             : 
   89648             : 
   89649           0 :    }
   89650             : 
   89651             : //############################################################################
   89652             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   89653             :  * within the working AST. 
   89654             :  */
   89655           0 : SgCommonBlock * SgCommonBlock::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   89656           0 :      SgCommonBlock* returnPointer = NULL;
   89657           0 :      if ( globalIndex != 0 )
   89658             :         {
   89659             : 
   89660             : #if FILE_IO_EXTRA_CHECK
   89661           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCommonBlock ) ) <= globalIndex ) ;
   89662           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCommonBlock + 1 ) ) );
   89663             : #endif
   89664           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCommonBlock )  
   89665           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCommonBlock );
   89666           0 :           unsigned long positionInPool = localIndex % SgCommonBlock::pool_size;
   89667           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCommonBlock::pool_size;
   89668             : 
   89669             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   89670             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   89671             : 
   89672           0 :           returnPointer = &( ( (SgCommonBlock*)(SgCommonBlock::pools[memoryBlock]) ) [positionInPool]) ;
   89673             : 
   89674           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   89675             :         }
   89676           0 :      return returnPointer ;
   89677             :    }
   89678             : 
   89679             : //############################################################################
   89680             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   89681             :   for the AST with the index astIndex
   89682             : */
   89683           0 : SgCommonBlock * SgCommonBlock::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   89684           0 :      SgCommonBlock* returnPointer = NULL;
   89685           0 :      if ( globalIndex != 0 )
   89686             :         {
   89687             : 
   89688             : #if FILE_IO_EXTRA_CHECK
   89689           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCommonBlock ) ) <= globalIndex ) ;
   89690           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCommonBlock + 1 ) ) );
   89691             : #endif
   89692           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCommonBlock )
   89693           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCommonBlock );
   89694           0 :           unsigned long positionInPool = localIndex % SgCommonBlock::pool_size ;
   89695           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCommonBlock::pool_size ;
   89696             : 
   89697             : #if FILE_IO_EXTRA_CHECK
   89698             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   89699             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   89700             : #endif
   89701             : 
   89702           0 :           returnPointer = &( ( (SgCommonBlock*)(SgCommonBlock::pools[memoryBlock]) ) [positionInPool]) ;
   89703             : 
   89704             : #if FILE_IO_EXTRA_CHECK
   89705           0 :           assert ( returnPointer != NULL ) ;
   89706             : #endif
   89707             :         }
   89708           0 :      return returnPointer ;
   89709             :    }
   89710             : 
   89711             : //############################################################################
   89712             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   89713             :  * pool size! We set for every valid object in the memory pool the freepointer
   89714             :  * to the global index and increase the global index afterwards. For all the 
   89715             :  * invalid objects (means address ranges within the memory pool that were not
   89716             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   89717             :  * distinguish valid from invalid objects! 
   89718             :  */
   89719             : unsigned long
   89720           5 : SgCommonBlock::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   89721             :    {
   89722           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   89723           5 :      SgCommonBlock* pointer = NULL;
   89724           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   89725           5 :      std::vector < unsigned char* > :: const_iterator block;
   89726           5 :      for ( block = SgCommonBlock::pools.begin(); block != SgCommonBlock::pools.end() ; ++block )
   89727             :         {
   89728           0 :           pointer = (SgCommonBlock*)(*block);
   89729           0 :           for (unsigned i = 0; i < SgCommonBlock::pool_size; ++i )
   89730             :              {
   89731             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   89732             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   89733             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   89734             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   89735             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   89736             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   89737             :             // properly; so this will have to be checked next.
   89738             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   89739             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   89740           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   89741             :                   {
   89742           0 :                     pointer[i].set_freepointer((SgCommonBlock*)(globalIndex));
   89743           0 :                     globalIndex++;
   89744             :                   }
   89745             :                else
   89746             :                   {
   89747           0 :                     pointer[i].set_freepointer(NULL);
   89748             :                   }
   89749             :               }
   89750             :         }
   89751           5 :      return globalIndex;
   89752             :    }
   89753             : 
   89754             : //############################################################################
   89755             : // JH (01/14/2006)
   89756             : void
   89757           5 : SgCommonBlock::resetValidFreepointers( )
   89758             :    {
   89759           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   89760           5 :      SgCommonBlock* pointer = NULL;
   89761           5 :      std::vector < unsigned char* > :: const_iterator block;
   89762           5 :      SgCommonBlock* pointerOfLinkedList = NULL;
   89763           5 :      for ( block = SgCommonBlock::pools.begin(); block != SgCommonBlock::pools.end() ; ++block )
   89764             :         {
   89765           0 :           pointer = (SgCommonBlock*)(*block);
   89766           0 :           for (unsigned i = 0; i < SgCommonBlock::pool_size; ++i )
   89767             :              {
   89768             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   89769             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   89770             :             // memory blocks!.
   89771           0 :                if ( pointer[i].get_freepointer() != NULL )
   89772             :                   {
   89773           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   89774             :                   }
   89775             :                else
   89776             :                   {
   89777           0 :                     if ( pointerOfLinkedList == NULL )
   89778             :                        {
   89779           0 :                          SgCommonBlock::next_node = &(pointer[i]);
   89780             :                        }
   89781             :                     else
   89782             :                        {
   89783             :                       // printf ("In SgCommonBlock::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   89784           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   89785             :                        }
   89786             :                     pointerOfLinkedList = &(pointer[i]);
   89787             :                   }
   89788             :               }
   89789             :         }
   89790             : 
   89791           5 :      if ( pointerOfLinkedList != NULL )
   89792             :         {
   89793             :        // printf ("In SgCommonBlock::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   89794           0 :           pointerOfLinkedList->set_freepointer(NULL);
   89795             :        // DQ (6/6/2010): Temporary debugging...
   89796             :        //   ROSE_ASSERT(false);
   89797             :         }
   89798             : 
   89799           5 :      return ;
   89800             :    }
   89801             : 
   89802             : //############################################################################
   89803             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   89804             :  * within the memory pool and resets the freepointers, in order to achieve a 
   89805             :  * linked list, that has no jumps and starts at the beginning! This function 
   89806             :  * does not extend the memory pool, since we do not delete any memory blocks,
   89807             :  * but delete the valid objects.  
   89808             :  */
   89809             : void
   89810           0 : SgCommonBlock::clearMemoryPool( )
   89811             :    {
   89812             :   // printf ("Inside of SgCommonBlock::clearMemoryPool() \n");
   89813             : 
   89814           0 :      SgCommonBlock* pointer = NULL, *tempPointer = NULL;
   89815           0 :      std::vector < unsigned char* > :: const_iterator block;
   89816           0 :      if ( SgCommonBlock::pools.empty() == false )
   89817             :         {
   89818           0 :           block = SgCommonBlock::pools.begin() ;
   89819           0 :           SgCommonBlock::next_node = (SgCommonBlock*) (*block);
   89820             : 
   89821           0 :           while ( block != SgCommonBlock::pools.end() )
   89822             :              {
   89823           0 :                pointer = (SgCommonBlock*) (*block);
   89824           0 :                if ( tempPointer != NULL )
   89825             :                   {
   89826           0 :                     tempPointer->set_freepointer(pointer);
   89827             :                   }
   89828           0 :                for (unsigned i = 0; i < SgCommonBlock::pool_size - 1; ++i)
   89829             :                   {
   89830           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   89831             :                   }
   89832           0 :                 pointer[SgCommonBlock::pool_size-1].set_freepointer(NULL);
   89833           0 :                 tempPointer = &(pointer[SgCommonBlock::pool_size-1]);
   89834           0 :                 ++block;
   89835             :              }
   89836             :         }
   89837           0 :    }
   89838             : 
   89839           5 : void SgCommonBlock::deleteMemoryPool() {
   89840           5 :   for (auto p: SgCommonBlock::pools) {
   89841           0 :     ROSE_FREE(p);
   89842             :   }
   89843           5 :   SgCommonBlock::next_node = nullptr;
   89844           5 :   SgCommonBlock::pools.clear();
   89845           5 : }
   89846             : 
   89847             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   89848             : //                 reading multiple binary files to for a single AST.
   89849             : /////////// new version ////////////////////////////////
   89850             : //############################################################################
   89851             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   89852             : void
   89853           2 : SgCommonBlock::extendMemoryPoolForFileIO( )
   89854             :   {
   89855           2 :     size_t blockIndex = SgCommonBlock::pools.size();
   89856           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonBlock) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonBlock);
   89857             : 
   89858           2 :     while ( (blockIndex * SgCommonBlock::pool_size) < newPoolSize)
   89859             :       {
   89860             : #if ROSE_ALLOC_TRACE
   89861             :         if (blockIndex > 0) {
   89862             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonBlock) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonBlock) = %" PRIuPTR " SgCommonBlock::pool_size = %d \n",
   89863             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonBlock),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonBlock),SgCommonBlock::pool_size);
   89864             :         }
   89865             : #endif
   89866             : 
   89867           0 :         SgCommonBlock * pointer = (SgCommonBlock*) ROSE_MALLOC ( SgCommonBlock::pool_size * sizeof(SgCommonBlock) );
   89868           0 :         assert( pointer != NULL );
   89869             : #if ROSE_ALLOC_MEMSET == 1
   89870             :         memset(pointer, 0x00, SgCommonBlock::pool_size * sizeof(SgCommonBlock));
   89871             : #elif ROSE_ALLOC_MEMSET == 2
   89872             :         memset(pointer, 0xCC, SgCommonBlock::pool_size * sizeof(SgCommonBlock));
   89873             : #endif
   89874           0 :         SgCommonBlock::pools.push_back( (unsigned char*)(pointer) );
   89875           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCommonBlock::pool_size * sizeof(SgCommonBlock), V_SgCommonBlock ) );
   89876             : 
   89877           0 :         if ( SgCommonBlock::next_node != NULL ) {
   89878           0 :           if ( blockIndex > 0 ) {
   89879           0 :             SgCommonBlock * blkptr = (SgCommonBlock*)(SgCommonBlock::pools[blockIndex-1]);
   89880           0 :             blkptr[ SgCommonBlock::pool_size - 1 ].set_freepointer(pointer);
   89881             :           }
   89882             :         } else {
   89883           0 :           SgCommonBlock::next_node = pointer;
   89884             :         }
   89885             : 
   89886           0 :         for (unsigned i = 0; i < SgCommonBlock::pool_size-1; ++i)
   89887             :            {
   89888           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   89889             :            }
   89890           0 :         pointer[ SgCommonBlock::pool_size -1 ].set_freepointer(NULL);
   89891             : 
   89892           0 :         blockIndex++;
   89893             :       }
   89894           2 :   }
   89895             : 
   89896             : //############################################################################
   89897             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   89898             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   89899             :  * not compressed. However, that stuff is not yet implemented! 
   89900             :  */
   89901             : unsigned long
   89902           0 : SgCommonBlock::getNumberOfLastValidPointer()
   89903             :    {
   89904           0 :       SgCommonBlock* testPointer = (SgCommonBlock*)(SgCommonBlock::pools.back());
   89905           0 :       unsigned long localIndex = SgCommonBlock::pool_size - 1;
   89906           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   89907             :          {
   89908           0 :            localIndex--;
   89909             :          }
   89910           0 :       return (localIndex + SgCommonBlock::pool_size * (SgCommonBlock::pools.size()-1));
   89911             :    }
   89912             : 
   89913             : //############################################################################
   89914             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   89915             :  * memory pool and initializes the data member in class SgCommonBlockStroageClass
   89916             :  * from its counterpart of SgCommonBlock. The return value is just for checking, 
   89917             :  * that the whole StorageClassArray is initialized!
   89918             :  */
   89919             : unsigned long
   89920           0 : SgCommonBlock::initializeStorageClassArray( SgCommonBlockStorageClass *storageArray )
   89921             :    {
   89922           0 :      unsigned long storageCounter = 0;
   89923           0 :      std::vector < unsigned char* > :: const_iterator block = SgCommonBlock::pools.begin();
   89924           0 :      SgCommonBlock* pointer = NULL;
   89925           0 :      while ( block != SgCommonBlock::pools.end() ) {
   89926           0 :           pointer = (SgCommonBlock*) (*block);
   89927           0 :           for ( unsigned i = 0; i < SgCommonBlock::pool_size; ++i ) {
   89928           0 :                if ( pointer->get_freepointer() != NULL ) {
   89929           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   89930           0 :                  storageArray++;
   89931           0 :                  storageCounter++;
   89932             :                }
   89933           0 :                pointer++;
   89934             :              }
   89935           0 :            block++;
   89936             :         }
   89937           0 :      return storageCounter;
   89938             :    }
   89939             : 
   89940             : /* #line 89941 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   89941             : 
   89942             : 
   89943             : 
   89944             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   89945             : 
   89946             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   89947             : 
   89948             : //############################################################################
   89949             : /* JH (02/02/2006) Constructor of the IR node SgTypedefDeclaration that takes its 
   89950             :  * corresponding StorageClass as parameter
   89951             :  */
   89952        1879 : SgTypedefDeclaration :: SgTypedefDeclaration ( const SgTypedefDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   89953             :    {
   89954             : 
   89955             : 
   89956             : /* #line 89957 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   89957             : 
   89958        1879 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   89959        1879 :      p_name = SgName ( storageSource.storageOf_name ) ;
   89960        1879 :      p_base_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_base_type) );
   89961        1879 :      p_type =  (SgTypedefType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
   89962        1879 :      p_declaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
   89963        1879 :      p_parent_scope =  (SgSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parent_scope) );
   89964        1879 :      p_typedefBaseTypeContainsDefiningDeclaration = storageSource.storageOf_typedefBaseTypeContainsDefiningDeclaration ;
   89965        1879 :      p_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scope) );
   89966        1879 :      p_requiresGlobalNameQualificationOnType = storageSource.storageOf_requiresGlobalNameQualificationOnType ;
   89967        1879 :      p_name_qualification_length_for_base_type = storageSource.storageOf_name_qualification_length_for_base_type ;
   89968        1879 :      p_type_elaboration_required_for_base_type = storageSource.storageOf_type_elaboration_required_for_base_type ;
   89969        1879 :      p_global_qualification_required_for_base_type = storageSource.storageOf_global_qualification_required_for_base_type ;
   89970        1879 :      p_isAutonomousDeclaration = storageSource.storageOf_isAutonomousDeclaration ;
   89971        1879 :      p_isAssociatedWithDeclarationList = storageSource.storageOf_isAssociatedWithDeclarationList ;
   89972        1879 :      p_isFirstDeclarationOfDeclarationList = storageSource.storageOf_isFirstDeclarationOfDeclarationList ;
   89973        1879 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   89974        1879 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   89975        1879 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   89976             : 
   89977             : 
   89978             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   89979             : 
   89980             : 
   89981        1879 :    }
   89982             : 
   89983             : //############################################################################
   89984             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   89985             :  * within the working AST. 
   89986             :  */
   89987       10440 : SgTypedefDeclaration * SgTypedefDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   89988       10440 :      SgTypedefDeclaration* returnPointer = NULL;
   89989       10440 :      if ( globalIndex != 0 )
   89990             :         {
   89991             : 
   89992             : #if FILE_IO_EXTRA_CHECK
   89993       10440 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypedefDeclaration ) ) <= globalIndex ) ;
   89994       10440 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypedefDeclaration + 1 ) ) );
   89995             : #endif
   89996       10440 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypedefDeclaration )  
   89997       10440 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypedefDeclaration );
   89998       10440 :           unsigned long positionInPool = localIndex % SgTypedefDeclaration::pool_size;
   89999       10440 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypedefDeclaration::pool_size;
   90000             : 
   90001             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   90002             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   90003             : 
   90004       10440 :           returnPointer = &( ( (SgTypedefDeclaration*)(SgTypedefDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   90005             : 
   90006       10440 :           ROSE_ASSERT( returnPointer != NULL ) ;
   90007             :         }
   90008       10440 :      return returnPointer ;
   90009             :    }
   90010             : 
   90011             : //############################################################################
   90012             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   90013             :   for the AST with the index astIndex
   90014             : */
   90015           0 : SgTypedefDeclaration * SgTypedefDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   90016           0 :      SgTypedefDeclaration* returnPointer = NULL;
   90017           0 :      if ( globalIndex != 0 )
   90018             :         {
   90019             : 
   90020             : #if FILE_IO_EXTRA_CHECK
   90021           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypedefDeclaration ) ) <= globalIndex ) ;
   90022           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypedefDeclaration + 1 ) ) );
   90023             : #endif
   90024           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypedefDeclaration )
   90025           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypedefDeclaration );
   90026           0 :           unsigned long positionInPool = localIndex % SgTypedefDeclaration::pool_size ;
   90027           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypedefDeclaration::pool_size ;
   90028             : 
   90029             : #if FILE_IO_EXTRA_CHECK
   90030             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   90031             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   90032             : #endif
   90033             : 
   90034           0 :           returnPointer = &( ( (SgTypedefDeclaration*)(SgTypedefDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   90035             : 
   90036             : #if FILE_IO_EXTRA_CHECK
   90037           0 :           assert ( returnPointer != NULL ) ;
   90038             : #endif
   90039             :         }
   90040           0 :      return returnPointer ;
   90041             :    }
   90042             : 
   90043             : //############################################################################
   90044             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   90045             :  * pool size! We set for every valid object in the memory pool the freepointer
   90046             :  * to the global index and increase the global index afterwards. For all the 
   90047             :  * invalid objects (means address ranges within the memory pool that were not
   90048             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   90049             :  * distinguish valid from invalid objects! 
   90050             :  */
   90051             : unsigned long
   90052           5 : SgTypedefDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   90053             :    {
   90054           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   90055           5 :      SgTypedefDeclaration* pointer = NULL;
   90056           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   90057           5 :      std::vector < unsigned char* > :: const_iterator block;
   90058           7 :      for ( block = SgTypedefDeclaration::pools.begin(); block != SgTypedefDeclaration::pools.end() ; ++block )
   90059             :         {
   90060           2 :           pointer = (SgTypedefDeclaration*)(*block);
   90061        4002 :           for (unsigned i = 0; i < SgTypedefDeclaration::pool_size; ++i )
   90062             :              {
   90063             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   90064             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   90065             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   90066             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   90067             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   90068             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   90069             :             // properly; so this will have to be checked next.
   90070             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   90071             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   90072        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   90073             :                   {
   90074        1719 :                     pointer[i].set_freepointer((SgTypedefDeclaration*)(globalIndex));
   90075        1719 :                     globalIndex++;
   90076             :                   }
   90077             :                else
   90078             :                   {
   90079        2281 :                     pointer[i].set_freepointer(NULL);
   90080             :                   }
   90081             :               }
   90082             :         }
   90083           5 :      return globalIndex;
   90084             :    }
   90085             : 
   90086             : //############################################################################
   90087             : // JH (01/14/2006)
   90088             : void
   90089           5 : SgTypedefDeclaration::resetValidFreepointers( )
   90090             :    {
   90091           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   90092           5 :      SgTypedefDeclaration* pointer = NULL;
   90093           5 :      std::vector < unsigned char* > :: const_iterator block;
   90094           5 :      SgTypedefDeclaration* pointerOfLinkedList = NULL;
   90095           7 :      for ( block = SgTypedefDeclaration::pools.begin(); block != SgTypedefDeclaration::pools.end() ; ++block )
   90096             :         {
   90097           2 :           pointer = (SgTypedefDeclaration*)(*block);
   90098        4002 :           for (unsigned i = 0; i < SgTypedefDeclaration::pool_size; ++i )
   90099             :              {
   90100             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   90101             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   90102             :             // memory blocks!.
   90103        4000 :                if ( pointer[i].get_freepointer() != NULL )
   90104             :                   {
   90105        1719 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   90106             :                   }
   90107             :                else
   90108             :                   {
   90109        2281 :                     if ( pointerOfLinkedList == NULL )
   90110             :                        {
   90111           2 :                          SgTypedefDeclaration::next_node = &(pointer[i]);
   90112             :                        }
   90113             :                     else
   90114             :                        {
   90115             :                       // printf ("In SgTypedefDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   90116        2279 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   90117             :                        }
   90118             :                     pointerOfLinkedList = &(pointer[i]);
   90119             :                   }
   90120             :               }
   90121             :         }
   90122             : 
   90123           5 :      if ( pointerOfLinkedList != NULL )
   90124             :         {
   90125             :        // printf ("In SgTypedefDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   90126           2 :           pointerOfLinkedList->set_freepointer(NULL);
   90127             :        // DQ (6/6/2010): Temporary debugging...
   90128             :        //   ROSE_ASSERT(false);
   90129             :         }
   90130             : 
   90131           5 :      return ;
   90132             :    }
   90133             : 
   90134             : //############################################################################
   90135             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   90136             :  * within the memory pool and resets the freepointers, in order to achieve a 
   90137             :  * linked list, that has no jumps and starts at the beginning! This function 
   90138             :  * does not extend the memory pool, since we do not delete any memory blocks,
   90139             :  * but delete the valid objects.  
   90140             :  */
   90141             : void
   90142           0 : SgTypedefDeclaration::clearMemoryPool( )
   90143             :    {
   90144             :   // printf ("Inside of SgTypedefDeclaration::clearMemoryPool() \n");
   90145             : 
   90146           0 :      SgTypedefDeclaration* pointer = NULL, *tempPointer = NULL;
   90147           0 :      std::vector < unsigned char* > :: const_iterator block;
   90148           0 :      if ( SgTypedefDeclaration::pools.empty() == false )
   90149             :         {
   90150           0 :           block = SgTypedefDeclaration::pools.begin() ;
   90151           0 :           SgTypedefDeclaration::next_node = (SgTypedefDeclaration*) (*block);
   90152             : 
   90153           0 :           while ( block != SgTypedefDeclaration::pools.end() )
   90154             :              {
   90155           0 :                pointer = (SgTypedefDeclaration*) (*block);
   90156           0 :                if ( tempPointer != NULL )
   90157             :                   {
   90158           0 :                     tempPointer->set_freepointer(pointer);
   90159             :                   }
   90160           0 :                for (unsigned i = 0; i < SgTypedefDeclaration::pool_size - 1; ++i)
   90161             :                   {
   90162           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   90163             :                   }
   90164           0 :                 pointer[SgTypedefDeclaration::pool_size-1].set_freepointer(NULL);
   90165           0 :                 tempPointer = &(pointer[SgTypedefDeclaration::pool_size-1]);
   90166           0 :                 ++block;
   90167             :              }
   90168             :         }
   90169           0 :    }
   90170             : 
   90171           5 : void SgTypedefDeclaration::deleteMemoryPool() {
   90172           9 :   for (auto p: SgTypedefDeclaration::pools) {
   90173           4 :     ROSE_FREE(p);
   90174             :   }
   90175           5 :   SgTypedefDeclaration::next_node = nullptr;
   90176           5 :   SgTypedefDeclaration::pools.clear();
   90177           5 : }
   90178             : 
   90179             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   90180             : //                 reading multiple binary files to for a single AST.
   90181             : /////////// new version ////////////////////////////////
   90182             : //############################################################################
   90183             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   90184             : void
   90185           2 : SgTypedefDeclaration::extendMemoryPoolForFileIO( )
   90186             :   {
   90187           2 :     size_t blockIndex = SgTypedefDeclaration::pools.size();
   90188           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefDeclaration);
   90189             : 
   90190           4 :     while ( (blockIndex * SgTypedefDeclaration::pool_size) < newPoolSize)
   90191             :       {
   90192             : #if ROSE_ALLOC_TRACE
   90193             :         if (blockIndex > 0) {
   90194             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefDeclaration) = %" PRIuPTR " SgTypedefDeclaration::pool_size = %d \n",
   90195             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefDeclaration),SgTypedefDeclaration::pool_size);
   90196             :         }
   90197             : #endif
   90198             : 
   90199           2 :         SgTypedefDeclaration * pointer = (SgTypedefDeclaration*) ROSE_MALLOC ( SgTypedefDeclaration::pool_size * sizeof(SgTypedefDeclaration) );
   90200           2 :         assert( pointer != NULL );
   90201             : #if ROSE_ALLOC_MEMSET == 1
   90202             :         memset(pointer, 0x00, SgTypedefDeclaration::pool_size * sizeof(SgTypedefDeclaration));
   90203             : #elif ROSE_ALLOC_MEMSET == 2
   90204             :         memset(pointer, 0xCC, SgTypedefDeclaration::pool_size * sizeof(SgTypedefDeclaration));
   90205             : #endif
   90206           2 :         SgTypedefDeclaration::pools.push_back( (unsigned char*)(pointer) );
   90207           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypedefDeclaration::pool_size * sizeof(SgTypedefDeclaration), V_SgTypedefDeclaration ) );
   90208             : 
   90209           2 :         if ( SgTypedefDeclaration::next_node != NULL ) {
   90210           0 :           if ( blockIndex > 0 ) {
   90211           0 :             SgTypedefDeclaration * blkptr = (SgTypedefDeclaration*)(SgTypedefDeclaration::pools[blockIndex-1]);
   90212           0 :             blkptr[ SgTypedefDeclaration::pool_size - 1 ].set_freepointer(pointer);
   90213             :           }
   90214             :         } else {
   90215           2 :           SgTypedefDeclaration::next_node = pointer;
   90216             :         }
   90217             : 
   90218        4000 :         for (unsigned i = 0; i < SgTypedefDeclaration::pool_size-1; ++i)
   90219             :            {
   90220        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   90221             :            }
   90222           2 :         pointer[ SgTypedefDeclaration::pool_size -1 ].set_freepointer(NULL);
   90223             : 
   90224           2 :         blockIndex++;
   90225             :       }
   90226           2 :   }
   90227             : 
   90228             : //############################################################################
   90229             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   90230             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   90231             :  * not compressed. However, that stuff is not yet implemented! 
   90232             :  */
   90233             : unsigned long
   90234           0 : SgTypedefDeclaration::getNumberOfLastValidPointer()
   90235             :    {
   90236           0 :       SgTypedefDeclaration* testPointer = (SgTypedefDeclaration*)(SgTypedefDeclaration::pools.back());
   90237           0 :       unsigned long localIndex = SgTypedefDeclaration::pool_size - 1;
   90238           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   90239             :          {
   90240           0 :            localIndex--;
   90241             :          }
   90242           0 :       return (localIndex + SgTypedefDeclaration::pool_size * (SgTypedefDeclaration::pools.size()-1));
   90243             :    }
   90244             : 
   90245             : //############################################################################
   90246             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   90247             :  * memory pool and initializes the data member in class SgTypedefDeclarationStroageClass
   90248             :  * from its counterpart of SgTypedefDeclaration. The return value is just for checking, 
   90249             :  * that the whole StorageClassArray is initialized!
   90250             :  */
   90251             : unsigned long
   90252           2 : SgTypedefDeclaration::initializeStorageClassArray( SgTypedefDeclarationStorageClass *storageArray )
   90253             :    {
   90254           2 :      unsigned long storageCounter = 0;
   90255           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypedefDeclaration::pools.begin();
   90256           2 :      SgTypedefDeclaration* pointer = NULL;
   90257           4 :      while ( block != SgTypedefDeclaration::pools.end() ) {
   90258           2 :           pointer = (SgTypedefDeclaration*) (*block);
   90259        4002 :           for ( unsigned i = 0; i < SgTypedefDeclaration::pool_size; ++i ) {
   90260        4000 :                if ( pointer->get_freepointer() != NULL ) {
   90261        1719 :                  storageArray->pickOutIRNodeData (pointer) ;
   90262        1719 :                  storageArray++;
   90263        1719 :                  storageCounter++;
   90264             :                }
   90265        4000 :                pointer++;
   90266             :              }
   90267           2 :            block++;
   90268             :         }
   90269           2 :      return storageCounter;
   90270             :    }
   90271             : 
   90272             : /* #line 90273 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   90273             : 
   90274             : 
   90275             : 
   90276             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   90277             : 
   90278             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   90279             : 
   90280             : //############################################################################
   90281             : /* JH (02/02/2006) Constructor of the IR node SgTemplateTypedefDeclaration that takes its 
   90282             :  * corresponding StorageClass as parameter
   90283             :  */
   90284          95 : SgTemplateTypedefDeclaration :: SgTemplateTypedefDeclaration ( const SgTemplateTypedefDeclarationStorageClass& storageSource )   : SgTypedefDeclaration (storageSource)
   90285             :    {
   90286             : 
   90287             : 
   90288             : /* #line 90289 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   90289             : 
   90290          95 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   90291          95 :      p_templateParameters = storageSource.storageOf_templateParameters.rebuildDataStoredInEasyStorageClass() ;
   90292          95 :      SgTemplateParameterPtrList::iterator i_templateParameters = p_templateParameters.begin() ; 
   90293         215 :      for ( ; i_templateParameters != p_templateParameters.end(); ++i_templateParameters ) 
   90294             :         {
   90295         120 :           (*i_templateParameters) = (SgTemplateParameterPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateParameters) ) );
   90296             :         }
   90297          95 :      p_templateSpecializationArguments = storageSource.storageOf_templateSpecializationArguments.rebuildDataStoredInEasyStorageClass() ;
   90298          95 :      SgTemplateArgumentPtrList::iterator i_templateSpecializationArguments = p_templateSpecializationArguments.begin() ; 
   90299          95 :      for ( ; i_templateSpecializationArguments != p_templateSpecializationArguments.end(); ++i_templateSpecializationArguments ) 
   90300             :         {
   90301           0 :           (*i_templateSpecializationArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateSpecializationArguments) ) );
   90302             :         }
   90303          95 :      p_string = SgName ( storageSource.storageOf_string ) ;
   90304          95 :      p_nonreal_decl_scope =  (SgDeclarationScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nonreal_decl_scope) );
   90305             : 
   90306             : 
   90307             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   90308             : 
   90309             : 
   90310          95 :    }
   90311             : 
   90312             : //############################################################################
   90313             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   90314             :  * within the working AST. 
   90315             :  */
   90316         942 : SgTemplateTypedefDeclaration * SgTemplateTypedefDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   90317         942 :      SgTemplateTypedefDeclaration* returnPointer = NULL;
   90318         942 :      if ( globalIndex != 0 )
   90319             :         {
   90320             : 
   90321             : #if FILE_IO_EXTRA_CHECK
   90322         942 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateTypedefDeclaration ) ) <= globalIndex ) ;
   90323         942 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateTypedefDeclaration + 1 ) ) );
   90324             : #endif
   90325         942 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateTypedefDeclaration )  
   90326         942 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateTypedefDeclaration );
   90327         942 :           unsigned long positionInPool = localIndex % SgTemplateTypedefDeclaration::pool_size;
   90328         942 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateTypedefDeclaration::pool_size;
   90329             : 
   90330             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   90331             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   90332             : 
   90333         942 :           returnPointer = &( ( (SgTemplateTypedefDeclaration*)(SgTemplateTypedefDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   90334             : 
   90335         942 :           ROSE_ASSERT( returnPointer != NULL ) ;
   90336             :         }
   90337         942 :      return returnPointer ;
   90338             :    }
   90339             : 
   90340             : //############################################################################
   90341             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   90342             :   for the AST with the index astIndex
   90343             : */
   90344           0 : SgTemplateTypedefDeclaration * SgTemplateTypedefDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   90345           0 :      SgTemplateTypedefDeclaration* returnPointer = NULL;
   90346           0 :      if ( globalIndex != 0 )
   90347             :         {
   90348             : 
   90349             : #if FILE_IO_EXTRA_CHECK
   90350           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateTypedefDeclaration ) ) <= globalIndex ) ;
   90351           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateTypedefDeclaration + 1 ) ) );
   90352             : #endif
   90353           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateTypedefDeclaration )
   90354           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateTypedefDeclaration );
   90355           0 :           unsigned long positionInPool = localIndex % SgTemplateTypedefDeclaration::pool_size ;
   90356           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateTypedefDeclaration::pool_size ;
   90357             : 
   90358             : #if FILE_IO_EXTRA_CHECK
   90359             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   90360             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   90361             : #endif
   90362             : 
   90363           0 :           returnPointer = &( ( (SgTemplateTypedefDeclaration*)(SgTemplateTypedefDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   90364             : 
   90365             : #if FILE_IO_EXTRA_CHECK
   90366           0 :           assert ( returnPointer != NULL ) ;
   90367             : #endif
   90368             :         }
   90369           0 :      return returnPointer ;
   90370             :    }
   90371             : 
   90372             : //############################################################################
   90373             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   90374             :  * pool size! We set for every valid object in the memory pool the freepointer
   90375             :  * to the global index and increase the global index afterwards. For all the 
   90376             :  * invalid objects (means address ranges within the memory pool that were not
   90377             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   90378             :  * distinguish valid from invalid objects! 
   90379             :  */
   90380             : unsigned long
   90381           5 : SgTemplateTypedefDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   90382             :    {
   90383           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   90384           5 :      SgTemplateTypedefDeclaration* pointer = NULL;
   90385           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   90386           5 :      std::vector < unsigned char* > :: const_iterator block;
   90387           6 :      for ( block = SgTemplateTypedefDeclaration::pools.begin(); block != SgTemplateTypedefDeclaration::pools.end() ; ++block )
   90388             :         {
   90389           1 :           pointer = (SgTemplateTypedefDeclaration*)(*block);
   90390        2001 :           for (unsigned i = 0; i < SgTemplateTypedefDeclaration::pool_size; ++i )
   90391             :              {
   90392             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   90393             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   90394             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   90395             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   90396             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   90397             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   90398             :             // properly; so this will have to be checked next.
   90399             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   90400             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   90401        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   90402             :                   {
   90403          95 :                     pointer[i].set_freepointer((SgTemplateTypedefDeclaration*)(globalIndex));
   90404          95 :                     globalIndex++;
   90405             :                   }
   90406             :                else
   90407             :                   {
   90408        1905 :                     pointer[i].set_freepointer(NULL);
   90409             :                   }
   90410             :               }
   90411             :         }
   90412           5 :      return globalIndex;
   90413             :    }
   90414             : 
   90415             : //############################################################################
   90416             : // JH (01/14/2006)
   90417             : void
   90418           5 : SgTemplateTypedefDeclaration::resetValidFreepointers( )
   90419             :    {
   90420           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   90421           5 :      SgTemplateTypedefDeclaration* pointer = NULL;
   90422           5 :      std::vector < unsigned char* > :: const_iterator block;
   90423           5 :      SgTemplateTypedefDeclaration* pointerOfLinkedList = NULL;
   90424           6 :      for ( block = SgTemplateTypedefDeclaration::pools.begin(); block != SgTemplateTypedefDeclaration::pools.end() ; ++block )
   90425             :         {
   90426           1 :           pointer = (SgTemplateTypedefDeclaration*)(*block);
   90427        2001 :           for (unsigned i = 0; i < SgTemplateTypedefDeclaration::pool_size; ++i )
   90428             :              {
   90429             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   90430             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   90431             :             // memory blocks!.
   90432        2000 :                if ( pointer[i].get_freepointer() != NULL )
   90433             :                   {
   90434          95 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   90435             :                   }
   90436             :                else
   90437             :                   {
   90438        1905 :                     if ( pointerOfLinkedList == NULL )
   90439             :                        {
   90440           1 :                          SgTemplateTypedefDeclaration::next_node = &(pointer[i]);
   90441             :                        }
   90442             :                     else
   90443             :                        {
   90444             :                       // printf ("In SgTemplateTypedefDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   90445        1904 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   90446             :                        }
   90447             :                     pointerOfLinkedList = &(pointer[i]);
   90448             :                   }
   90449             :               }
   90450             :         }
   90451             : 
   90452           5 :      if ( pointerOfLinkedList != NULL )
   90453             :         {
   90454             :        // printf ("In SgTemplateTypedefDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   90455           1 :           pointerOfLinkedList->set_freepointer(NULL);
   90456             :        // DQ (6/6/2010): Temporary debugging...
   90457             :        //   ROSE_ASSERT(false);
   90458             :         }
   90459             : 
   90460           5 :      return ;
   90461             :    }
   90462             : 
   90463             : //############################################################################
   90464             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   90465             :  * within the memory pool and resets the freepointers, in order to achieve a 
   90466             :  * linked list, that has no jumps and starts at the beginning! This function 
   90467             :  * does not extend the memory pool, since we do not delete any memory blocks,
   90468             :  * but delete the valid objects.  
   90469             :  */
   90470             : void
   90471           0 : SgTemplateTypedefDeclaration::clearMemoryPool( )
   90472             :    {
   90473             :   // printf ("Inside of SgTemplateTypedefDeclaration::clearMemoryPool() \n");
   90474             : 
   90475           0 :      SgTemplateTypedefDeclaration* pointer = NULL, *tempPointer = NULL;
   90476           0 :      std::vector < unsigned char* > :: const_iterator block;
   90477           0 :      if ( SgTemplateTypedefDeclaration::pools.empty() == false )
   90478             :         {
   90479           0 :           block = SgTemplateTypedefDeclaration::pools.begin() ;
   90480           0 :           SgTemplateTypedefDeclaration::next_node = (SgTemplateTypedefDeclaration*) (*block);
   90481             : 
   90482           0 :           while ( block != SgTemplateTypedefDeclaration::pools.end() )
   90483             :              {
   90484           0 :                pointer = (SgTemplateTypedefDeclaration*) (*block);
   90485           0 :                if ( tempPointer != NULL )
   90486             :                   {
   90487           0 :                     tempPointer->set_freepointer(pointer);
   90488             :                   }
   90489           0 :                for (unsigned i = 0; i < SgTemplateTypedefDeclaration::pool_size - 1; ++i)
   90490             :                   {
   90491           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   90492             :                   }
   90493           0 :                 pointer[SgTemplateTypedefDeclaration::pool_size-1].set_freepointer(NULL);
   90494           0 :                 tempPointer = &(pointer[SgTemplateTypedefDeclaration::pool_size-1]);
   90495           0 :                 ++block;
   90496             :              }
   90497             :         }
   90498           0 :    }
   90499             : 
   90500           5 : void SgTemplateTypedefDeclaration::deleteMemoryPool() {
   90501           7 :   for (auto p: SgTemplateTypedefDeclaration::pools) {
   90502           2 :     ROSE_FREE(p);
   90503             :   }
   90504           5 :   SgTemplateTypedefDeclaration::next_node = nullptr;
   90505           5 :   SgTemplateTypedefDeclaration::pools.clear();
   90506           5 : }
   90507             : 
   90508             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   90509             : //                 reading multiple binary files to for a single AST.
   90510             : /////////// new version ////////////////////////////////
   90511             : //############################################################################
   90512             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   90513             : void
   90514           2 : SgTemplateTypedefDeclaration::extendMemoryPoolForFileIO( )
   90515             :   {
   90516           2 :     size_t blockIndex = SgTemplateTypedefDeclaration::pools.size();
   90517           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateTypedefDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateTypedefDeclaration);
   90518             : 
   90519           3 :     while ( (blockIndex * SgTemplateTypedefDeclaration::pool_size) < newPoolSize)
   90520             :       {
   90521             : #if ROSE_ALLOC_TRACE
   90522             :         if (blockIndex > 0) {
   90523             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateTypedefDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateTypedefDeclaration) = %" PRIuPTR " SgTemplateTypedefDeclaration::pool_size = %d \n",
   90524             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateTypedefDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateTypedefDeclaration),SgTemplateTypedefDeclaration::pool_size);
   90525             :         }
   90526             : #endif
   90527             : 
   90528           1 :         SgTemplateTypedefDeclaration * pointer = (SgTemplateTypedefDeclaration*) ROSE_MALLOC ( SgTemplateTypedefDeclaration::pool_size * sizeof(SgTemplateTypedefDeclaration) );
   90529           1 :         assert( pointer != NULL );
   90530             : #if ROSE_ALLOC_MEMSET == 1
   90531             :         memset(pointer, 0x00, SgTemplateTypedefDeclaration::pool_size * sizeof(SgTemplateTypedefDeclaration));
   90532             : #elif ROSE_ALLOC_MEMSET == 2
   90533             :         memset(pointer, 0xCC, SgTemplateTypedefDeclaration::pool_size * sizeof(SgTemplateTypedefDeclaration));
   90534             : #endif
   90535           1 :         SgTemplateTypedefDeclaration::pools.push_back( (unsigned char*)(pointer) );
   90536           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateTypedefDeclaration::pool_size * sizeof(SgTemplateTypedefDeclaration), V_SgTemplateTypedefDeclaration ) );
   90537             : 
   90538           1 :         if ( SgTemplateTypedefDeclaration::next_node != NULL ) {
   90539           0 :           if ( blockIndex > 0 ) {
   90540           0 :             SgTemplateTypedefDeclaration * blkptr = (SgTemplateTypedefDeclaration*)(SgTemplateTypedefDeclaration::pools[blockIndex-1]);
   90541           0 :             blkptr[ SgTemplateTypedefDeclaration::pool_size - 1 ].set_freepointer(pointer);
   90542             :           }
   90543             :         } else {
   90544           1 :           SgTemplateTypedefDeclaration::next_node = pointer;
   90545             :         }
   90546             : 
   90547        2000 :         for (unsigned i = 0; i < SgTemplateTypedefDeclaration::pool_size-1; ++i)
   90548             :            {
   90549        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   90550             :            }
   90551           1 :         pointer[ SgTemplateTypedefDeclaration::pool_size -1 ].set_freepointer(NULL);
   90552             : 
   90553           1 :         blockIndex++;
   90554             :       }
   90555           2 :   }
   90556             : 
   90557             : //############################################################################
   90558             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   90559             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   90560             :  * not compressed. However, that stuff is not yet implemented! 
   90561             :  */
   90562             : unsigned long
   90563           0 : SgTemplateTypedefDeclaration::getNumberOfLastValidPointer()
   90564             :    {
   90565           0 :       SgTemplateTypedefDeclaration* testPointer = (SgTemplateTypedefDeclaration*)(SgTemplateTypedefDeclaration::pools.back());
   90566           0 :       unsigned long localIndex = SgTemplateTypedefDeclaration::pool_size - 1;
   90567           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   90568             :          {
   90569           0 :            localIndex--;
   90570             :          }
   90571           0 :       return (localIndex + SgTemplateTypedefDeclaration::pool_size * (SgTemplateTypedefDeclaration::pools.size()-1));
   90572             :    }
   90573             : 
   90574             : //############################################################################
   90575             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   90576             :  * memory pool and initializes the data member in class SgTemplateTypedefDeclarationStroageClass
   90577             :  * from its counterpart of SgTemplateTypedefDeclaration. The return value is just for checking, 
   90578             :  * that the whole StorageClassArray is initialized!
   90579             :  */
   90580             : unsigned long
   90581           1 : SgTemplateTypedefDeclaration::initializeStorageClassArray( SgTemplateTypedefDeclarationStorageClass *storageArray )
   90582             :    {
   90583           1 :      unsigned long storageCounter = 0;
   90584           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateTypedefDeclaration::pools.begin();
   90585           1 :      SgTemplateTypedefDeclaration* pointer = NULL;
   90586           2 :      while ( block != SgTemplateTypedefDeclaration::pools.end() ) {
   90587           1 :           pointer = (SgTemplateTypedefDeclaration*) (*block);
   90588        2001 :           for ( unsigned i = 0; i < SgTemplateTypedefDeclaration::pool_size; ++i ) {
   90589        2000 :                if ( pointer->get_freepointer() != NULL ) {
   90590          95 :                  storageArray->pickOutIRNodeData (pointer) ;
   90591          95 :                  storageArray++;
   90592          95 :                  storageCounter++;
   90593             :                }
   90594        2000 :                pointer++;
   90595             :              }
   90596           1 :            block++;
   90597             :         }
   90598           1 :      return storageCounter;
   90599             :    }
   90600             : 
   90601             : /* #line 90602 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   90602             : 
   90603             : 
   90604             : 
   90605             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   90606             : 
   90607             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   90608             : 
   90609             : //############################################################################
   90610             : /* JH (02/02/2006) Constructor of the IR node SgTemplateInstantiationTypedefDeclaration that takes its 
   90611             :  * corresponding StorageClass as parameter
   90612             :  */
   90613          65 : SgTemplateInstantiationTypedefDeclaration :: SgTemplateInstantiationTypedefDeclaration ( const SgTemplateInstantiationTypedefDeclarationStorageClass& storageSource )   : SgTypedefDeclaration (storageSource)
   90614             :    {
   90615             : 
   90616             : 
   90617             : /* #line 90618 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   90618             : 
   90619          65 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   90620          65 :      p_templateName = SgName ( storageSource.storageOf_templateName ) ;
   90621          65 :      p_templateHeader = SgName ( storageSource.storageOf_templateHeader ) ;
   90622          65 :      p_templateDeclaration =  (SgTemplateTypedefDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_templateDeclaration) );
   90623          65 :      p_templateArguments = storageSource.storageOf_templateArguments.rebuildDataStoredInEasyStorageClass() ;
   90624          65 :      SgTemplateArgumentPtrList::iterator i_templateArguments = p_templateArguments.begin() ; 
   90625         180 :      for ( ; i_templateArguments != p_templateArguments.end(); ++i_templateArguments ) 
   90626             :         {
   90627         115 :           (*i_templateArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateArguments) ) );
   90628             :         }
   90629          65 :      p_nameResetFromMangledForm = storageSource.storageOf_nameResetFromMangledForm ;
   90630             : 
   90631             : 
   90632             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   90633             : 
   90634             : 
   90635          65 :    }
   90636             : 
   90637             : //############################################################################
   90638             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   90639             :  * within the working AST. 
   90640             :  */
   90641         511 : SgTemplateInstantiationTypedefDeclaration * SgTemplateInstantiationTypedefDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   90642         511 :      SgTemplateInstantiationTypedefDeclaration* returnPointer = NULL;
   90643         511 :      if ( globalIndex != 0 )
   90644             :         {
   90645             : 
   90646             : #if FILE_IO_EXTRA_CHECK
   90647         511 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateInstantiationTypedefDeclaration ) ) <= globalIndex ) ;
   90648         511 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationTypedefDeclaration + 1 ) ) );
   90649             : #endif
   90650         511 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationTypedefDeclaration )  
   90651         511 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateInstantiationTypedefDeclaration );
   90652         511 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationTypedefDeclaration::pool_size;
   90653         511 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationTypedefDeclaration::pool_size;
   90654             : 
   90655             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   90656             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   90657             : 
   90658         511 :           returnPointer = &( ( (SgTemplateInstantiationTypedefDeclaration*)(SgTemplateInstantiationTypedefDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   90659             : 
   90660         511 :           ROSE_ASSERT( returnPointer != NULL ) ;
   90661             :         }
   90662         511 :      return returnPointer ;
   90663             :    }
   90664             : 
   90665             : //############################################################################
   90666             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   90667             :   for the AST with the index astIndex
   90668             : */
   90669           0 : SgTemplateInstantiationTypedefDeclaration * SgTemplateInstantiationTypedefDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   90670           0 :      SgTemplateInstantiationTypedefDeclaration* returnPointer = NULL;
   90671           0 :      if ( globalIndex != 0 )
   90672             :         {
   90673             : 
   90674             : #if FILE_IO_EXTRA_CHECK
   90675           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateInstantiationTypedefDeclaration ) ) <= globalIndex ) ;
   90676           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationTypedefDeclaration + 1 ) ) );
   90677             : #endif
   90678           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationTypedefDeclaration )
   90679           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateInstantiationTypedefDeclaration );
   90680           0 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationTypedefDeclaration::pool_size ;
   90681           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationTypedefDeclaration::pool_size ;
   90682             : 
   90683             : #if FILE_IO_EXTRA_CHECK
   90684             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   90685             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   90686             : #endif
   90687             : 
   90688           0 :           returnPointer = &( ( (SgTemplateInstantiationTypedefDeclaration*)(SgTemplateInstantiationTypedefDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   90689             : 
   90690             : #if FILE_IO_EXTRA_CHECK
   90691           0 :           assert ( returnPointer != NULL ) ;
   90692             : #endif
   90693             :         }
   90694           0 :      return returnPointer ;
   90695             :    }
   90696             : 
   90697             : //############################################################################
   90698             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   90699             :  * pool size! We set for every valid object in the memory pool the freepointer
   90700             :  * to the global index and increase the global index afterwards. For all the 
   90701             :  * invalid objects (means address ranges within the memory pool that were not
   90702             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   90703             :  * distinguish valid from invalid objects! 
   90704             :  */
   90705             : unsigned long
   90706           5 : SgTemplateInstantiationTypedefDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   90707             :    {
   90708           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   90709           5 :      SgTemplateInstantiationTypedefDeclaration* pointer = NULL;
   90710           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   90711           5 :      std::vector < unsigned char* > :: const_iterator block;
   90712           6 :      for ( block = SgTemplateInstantiationTypedefDeclaration::pools.begin(); block != SgTemplateInstantiationTypedefDeclaration::pools.end() ; ++block )
   90713             :         {
   90714           1 :           pointer = (SgTemplateInstantiationTypedefDeclaration*)(*block);
   90715        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationTypedefDeclaration::pool_size; ++i )
   90716             :              {
   90717             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   90718             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   90719             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   90720             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   90721             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   90722             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   90723             :             // properly; so this will have to be checked next.
   90724             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   90725             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   90726        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   90727             :                   {
   90728          65 :                     pointer[i].set_freepointer((SgTemplateInstantiationTypedefDeclaration*)(globalIndex));
   90729          65 :                     globalIndex++;
   90730             :                   }
   90731             :                else
   90732             :                   {
   90733        1935 :                     pointer[i].set_freepointer(NULL);
   90734             :                   }
   90735             :               }
   90736             :         }
   90737           5 :      return globalIndex;
   90738             :    }
   90739             : 
   90740             : //############################################################################
   90741             : // JH (01/14/2006)
   90742             : void
   90743           5 : SgTemplateInstantiationTypedefDeclaration::resetValidFreepointers( )
   90744             :    {
   90745           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   90746           5 :      SgTemplateInstantiationTypedefDeclaration* pointer = NULL;
   90747           5 :      std::vector < unsigned char* > :: const_iterator block;
   90748           5 :      SgTemplateInstantiationTypedefDeclaration* pointerOfLinkedList = NULL;
   90749           6 :      for ( block = SgTemplateInstantiationTypedefDeclaration::pools.begin(); block != SgTemplateInstantiationTypedefDeclaration::pools.end() ; ++block )
   90750             :         {
   90751           1 :           pointer = (SgTemplateInstantiationTypedefDeclaration*)(*block);
   90752        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationTypedefDeclaration::pool_size; ++i )
   90753             :              {
   90754             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   90755             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   90756             :             // memory blocks!.
   90757        2000 :                if ( pointer[i].get_freepointer() != NULL )
   90758             :                   {
   90759          65 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   90760             :                   }
   90761             :                else
   90762             :                   {
   90763        1935 :                     if ( pointerOfLinkedList == NULL )
   90764             :                        {
   90765           1 :                          SgTemplateInstantiationTypedefDeclaration::next_node = &(pointer[i]);
   90766             :                        }
   90767             :                     else
   90768             :                        {
   90769             :                       // printf ("In SgTemplateInstantiationTypedefDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   90770        1934 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   90771             :                        }
   90772             :                     pointerOfLinkedList = &(pointer[i]);
   90773             :                   }
   90774             :               }
   90775             :         }
   90776             : 
   90777           5 :      if ( pointerOfLinkedList != NULL )
   90778             :         {
   90779             :        // printf ("In SgTemplateInstantiationTypedefDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   90780           1 :           pointerOfLinkedList->set_freepointer(NULL);
   90781             :        // DQ (6/6/2010): Temporary debugging...
   90782             :        //   ROSE_ASSERT(false);
   90783             :         }
   90784             : 
   90785           5 :      return ;
   90786             :    }
   90787             : 
   90788             : //############################################################################
   90789             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   90790             :  * within the memory pool and resets the freepointers, in order to achieve a 
   90791             :  * linked list, that has no jumps and starts at the beginning! This function 
   90792             :  * does not extend the memory pool, since we do not delete any memory blocks,
   90793             :  * but delete the valid objects.  
   90794             :  */
   90795             : void
   90796           0 : SgTemplateInstantiationTypedefDeclaration::clearMemoryPool( )
   90797             :    {
   90798             :   // printf ("Inside of SgTemplateInstantiationTypedefDeclaration::clearMemoryPool() \n");
   90799             : 
   90800           0 :      SgTemplateInstantiationTypedefDeclaration* pointer = NULL, *tempPointer = NULL;
   90801           0 :      std::vector < unsigned char* > :: const_iterator block;
   90802           0 :      if ( SgTemplateInstantiationTypedefDeclaration::pools.empty() == false )
   90803             :         {
   90804           0 :           block = SgTemplateInstantiationTypedefDeclaration::pools.begin() ;
   90805           0 :           SgTemplateInstantiationTypedefDeclaration::next_node = (SgTemplateInstantiationTypedefDeclaration*) (*block);
   90806             : 
   90807           0 :           while ( block != SgTemplateInstantiationTypedefDeclaration::pools.end() )
   90808             :              {
   90809           0 :                pointer = (SgTemplateInstantiationTypedefDeclaration*) (*block);
   90810           0 :                if ( tempPointer != NULL )
   90811             :                   {
   90812           0 :                     tempPointer->set_freepointer(pointer);
   90813             :                   }
   90814           0 :                for (unsigned i = 0; i < SgTemplateInstantiationTypedefDeclaration::pool_size - 1; ++i)
   90815             :                   {
   90816           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   90817             :                   }
   90818           0 :                 pointer[SgTemplateInstantiationTypedefDeclaration::pool_size-1].set_freepointer(NULL);
   90819           0 :                 tempPointer = &(pointer[SgTemplateInstantiationTypedefDeclaration::pool_size-1]);
   90820           0 :                 ++block;
   90821             :              }
   90822             :         }
   90823           0 :    }
   90824             : 
   90825           5 : void SgTemplateInstantiationTypedefDeclaration::deleteMemoryPool() {
   90826           7 :   for (auto p: SgTemplateInstantiationTypedefDeclaration::pools) {
   90827           2 :     ROSE_FREE(p);
   90828             :   }
   90829           5 :   SgTemplateInstantiationTypedefDeclaration::next_node = nullptr;
   90830           5 :   SgTemplateInstantiationTypedefDeclaration::pools.clear();
   90831           5 : }
   90832             : 
   90833             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   90834             : //                 reading multiple binary files to for a single AST.
   90835             : /////////// new version ////////////////////////////////
   90836             : //############################################################################
   90837             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   90838             : void
   90839           2 : SgTemplateInstantiationTypedefDeclaration::extendMemoryPoolForFileIO( )
   90840             :   {
   90841           2 :     size_t blockIndex = SgTemplateInstantiationTypedefDeclaration::pools.size();
   90842           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationTypedefDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationTypedefDeclaration);
   90843             : 
   90844           3 :     while ( (blockIndex * SgTemplateInstantiationTypedefDeclaration::pool_size) < newPoolSize)
   90845             :       {
   90846             : #if ROSE_ALLOC_TRACE
   90847             :         if (blockIndex > 0) {
   90848             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationTypedefDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationTypedefDeclaration) = %" PRIuPTR " SgTemplateInstantiationTypedefDeclaration::pool_size = %d \n",
   90849             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationTypedefDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationTypedefDeclaration),SgTemplateInstantiationTypedefDeclaration::pool_size);
   90850             :         }
   90851             : #endif
   90852             : 
   90853           1 :         SgTemplateInstantiationTypedefDeclaration * pointer = (SgTemplateInstantiationTypedefDeclaration*) ROSE_MALLOC ( SgTemplateInstantiationTypedefDeclaration::pool_size * sizeof(SgTemplateInstantiationTypedefDeclaration) );
   90854           1 :         assert( pointer != NULL );
   90855             : #if ROSE_ALLOC_MEMSET == 1
   90856             :         memset(pointer, 0x00, SgTemplateInstantiationTypedefDeclaration::pool_size * sizeof(SgTemplateInstantiationTypedefDeclaration));
   90857             : #elif ROSE_ALLOC_MEMSET == 2
   90858             :         memset(pointer, 0xCC, SgTemplateInstantiationTypedefDeclaration::pool_size * sizeof(SgTemplateInstantiationTypedefDeclaration));
   90859             : #endif
   90860           1 :         SgTemplateInstantiationTypedefDeclaration::pools.push_back( (unsigned char*)(pointer) );
   90861           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateInstantiationTypedefDeclaration::pool_size * sizeof(SgTemplateInstantiationTypedefDeclaration), V_SgTemplateInstantiationTypedefDeclaration ) );
   90862             : 
   90863           1 :         if ( SgTemplateInstantiationTypedefDeclaration::next_node != NULL ) {
   90864           0 :           if ( blockIndex > 0 ) {
   90865           0 :             SgTemplateInstantiationTypedefDeclaration * blkptr = (SgTemplateInstantiationTypedefDeclaration*)(SgTemplateInstantiationTypedefDeclaration::pools[blockIndex-1]);
   90866           0 :             blkptr[ SgTemplateInstantiationTypedefDeclaration::pool_size - 1 ].set_freepointer(pointer);
   90867             :           }
   90868             :         } else {
   90869           1 :           SgTemplateInstantiationTypedefDeclaration::next_node = pointer;
   90870             :         }
   90871             : 
   90872        2000 :         for (unsigned i = 0; i < SgTemplateInstantiationTypedefDeclaration::pool_size-1; ++i)
   90873             :            {
   90874        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   90875             :            }
   90876           1 :         pointer[ SgTemplateInstantiationTypedefDeclaration::pool_size -1 ].set_freepointer(NULL);
   90877             : 
   90878           1 :         blockIndex++;
   90879             :       }
   90880           2 :   }
   90881             : 
   90882             : //############################################################################
   90883             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   90884             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   90885             :  * not compressed. However, that stuff is not yet implemented! 
   90886             :  */
   90887             : unsigned long
   90888           0 : SgTemplateInstantiationTypedefDeclaration::getNumberOfLastValidPointer()
   90889             :    {
   90890           0 :       SgTemplateInstantiationTypedefDeclaration* testPointer = (SgTemplateInstantiationTypedefDeclaration*)(SgTemplateInstantiationTypedefDeclaration::pools.back());
   90891           0 :       unsigned long localIndex = SgTemplateInstantiationTypedefDeclaration::pool_size - 1;
   90892           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   90893             :          {
   90894           0 :            localIndex--;
   90895             :          }
   90896           0 :       return (localIndex + SgTemplateInstantiationTypedefDeclaration::pool_size * (SgTemplateInstantiationTypedefDeclaration::pools.size()-1));
   90897             :    }
   90898             : 
   90899             : //############################################################################
   90900             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   90901             :  * memory pool and initializes the data member in class SgTemplateInstantiationTypedefDeclarationStroageClass
   90902             :  * from its counterpart of SgTemplateInstantiationTypedefDeclaration. The return value is just for checking, 
   90903             :  * that the whole StorageClassArray is initialized!
   90904             :  */
   90905             : unsigned long
   90906           1 : SgTemplateInstantiationTypedefDeclaration::initializeStorageClassArray( SgTemplateInstantiationTypedefDeclarationStorageClass *storageArray )
   90907             :    {
   90908           1 :      unsigned long storageCounter = 0;
   90909           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateInstantiationTypedefDeclaration::pools.begin();
   90910           1 :      SgTemplateInstantiationTypedefDeclaration* pointer = NULL;
   90911           2 :      while ( block != SgTemplateInstantiationTypedefDeclaration::pools.end() ) {
   90912           1 :           pointer = (SgTemplateInstantiationTypedefDeclaration*) (*block);
   90913        2001 :           for ( unsigned i = 0; i < SgTemplateInstantiationTypedefDeclaration::pool_size; ++i ) {
   90914        2000 :                if ( pointer->get_freepointer() != NULL ) {
   90915          65 :                  storageArray->pickOutIRNodeData (pointer) ;
   90916          65 :                  storageArray++;
   90917          65 :                  storageCounter++;
   90918             :                }
   90919        2000 :                pointer++;
   90920             :              }
   90921           1 :            block++;
   90922             :         }
   90923           1 :      return storageCounter;
   90924             :    }
   90925             : 
   90926             : /* #line 90927 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   90927             : 
   90928             : 
   90929             : 
   90930             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   90931             : 
   90932             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   90933             : 
   90934             : //############################################################################
   90935             : /* JH (02/02/2006) Constructor of the IR node SgStatementFunctionStatement that takes its 
   90936             :  * corresponding StorageClass as parameter
   90937             :  */
   90938           0 : SgStatementFunctionStatement :: SgStatementFunctionStatement ( const SgStatementFunctionStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   90939             :    {
   90940             : 
   90941             : 
   90942             : /* #line 90943 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   90943             : 
   90944           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   90945           0 :      p_function =  (SgFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_function) );
   90946           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
   90947             : 
   90948             : 
   90949             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   90950             : 
   90951             : 
   90952           0 :    }
   90953             : 
   90954             : //############################################################################
   90955             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   90956             :  * within the working AST. 
   90957             :  */
   90958           0 : SgStatementFunctionStatement * SgStatementFunctionStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   90959           0 :      SgStatementFunctionStatement* returnPointer = NULL;
   90960           0 :      if ( globalIndex != 0 )
   90961             :         {
   90962             : 
   90963             : #if FILE_IO_EXTRA_CHECK
   90964           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStatementFunctionStatement ) ) <= globalIndex ) ;
   90965           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStatementFunctionStatement + 1 ) ) );
   90966             : #endif
   90967           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStatementFunctionStatement )  
   90968           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStatementFunctionStatement );
   90969           0 :           unsigned long positionInPool = localIndex % SgStatementFunctionStatement::pool_size;
   90970           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStatementFunctionStatement::pool_size;
   90971             : 
   90972             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   90973             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   90974             : 
   90975           0 :           returnPointer = &( ( (SgStatementFunctionStatement*)(SgStatementFunctionStatement::pools[memoryBlock]) ) [positionInPool]) ;
   90976             : 
   90977           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   90978             :         }
   90979           0 :      return returnPointer ;
   90980             :    }
   90981             : 
   90982             : //############################################################################
   90983             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   90984             :   for the AST with the index astIndex
   90985             : */
   90986           0 : SgStatementFunctionStatement * SgStatementFunctionStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   90987           0 :      SgStatementFunctionStatement* returnPointer = NULL;
   90988           0 :      if ( globalIndex != 0 )
   90989             :         {
   90990             : 
   90991             : #if FILE_IO_EXTRA_CHECK
   90992           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStatementFunctionStatement ) ) <= globalIndex ) ;
   90993           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStatementFunctionStatement + 1 ) ) );
   90994             : #endif
   90995           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStatementFunctionStatement )
   90996           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStatementFunctionStatement );
   90997           0 :           unsigned long positionInPool = localIndex % SgStatementFunctionStatement::pool_size ;
   90998           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStatementFunctionStatement::pool_size ;
   90999             : 
   91000             : #if FILE_IO_EXTRA_CHECK
   91001             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   91002             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   91003             : #endif
   91004             : 
   91005           0 :           returnPointer = &( ( (SgStatementFunctionStatement*)(SgStatementFunctionStatement::pools[memoryBlock]) ) [positionInPool]) ;
   91006             : 
   91007             : #if FILE_IO_EXTRA_CHECK
   91008           0 :           assert ( returnPointer != NULL ) ;
   91009             : #endif
   91010             :         }
   91011           0 :      return returnPointer ;
   91012             :    }
   91013             : 
   91014             : //############################################################################
   91015             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   91016             :  * pool size! We set for every valid object in the memory pool the freepointer
   91017             :  * to the global index and increase the global index afterwards. For all the 
   91018             :  * invalid objects (means address ranges within the memory pool that were not
   91019             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   91020             :  * distinguish valid from invalid objects! 
   91021             :  */
   91022             : unsigned long
   91023           5 : SgStatementFunctionStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   91024             :    {
   91025           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   91026           5 :      SgStatementFunctionStatement* pointer = NULL;
   91027           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   91028           5 :      std::vector < unsigned char* > :: const_iterator block;
   91029           5 :      for ( block = SgStatementFunctionStatement::pools.begin(); block != SgStatementFunctionStatement::pools.end() ; ++block )
   91030             :         {
   91031           0 :           pointer = (SgStatementFunctionStatement*)(*block);
   91032           0 :           for (unsigned i = 0; i < SgStatementFunctionStatement::pool_size; ++i )
   91033             :              {
   91034             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   91035             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   91036             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   91037             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   91038             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   91039             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   91040             :             // properly; so this will have to be checked next.
   91041             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   91042             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   91043           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   91044             :                   {
   91045           0 :                     pointer[i].set_freepointer((SgStatementFunctionStatement*)(globalIndex));
   91046           0 :                     globalIndex++;
   91047             :                   }
   91048             :                else
   91049             :                   {
   91050           0 :                     pointer[i].set_freepointer(NULL);
   91051             :                   }
   91052             :               }
   91053             :         }
   91054           5 :      return globalIndex;
   91055             :    }
   91056             : 
   91057             : //############################################################################
   91058             : // JH (01/14/2006)
   91059             : void
   91060           5 : SgStatementFunctionStatement::resetValidFreepointers( )
   91061             :    {
   91062           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   91063           5 :      SgStatementFunctionStatement* pointer = NULL;
   91064           5 :      std::vector < unsigned char* > :: const_iterator block;
   91065           5 :      SgStatementFunctionStatement* pointerOfLinkedList = NULL;
   91066           5 :      for ( block = SgStatementFunctionStatement::pools.begin(); block != SgStatementFunctionStatement::pools.end() ; ++block )
   91067             :         {
   91068           0 :           pointer = (SgStatementFunctionStatement*)(*block);
   91069           0 :           for (unsigned i = 0; i < SgStatementFunctionStatement::pool_size; ++i )
   91070             :              {
   91071             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   91072             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   91073             :             // memory blocks!.
   91074           0 :                if ( pointer[i].get_freepointer() != NULL )
   91075             :                   {
   91076           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   91077             :                   }
   91078             :                else
   91079             :                   {
   91080           0 :                     if ( pointerOfLinkedList == NULL )
   91081             :                        {
   91082           0 :                          SgStatementFunctionStatement::next_node = &(pointer[i]);
   91083             :                        }
   91084             :                     else
   91085             :                        {
   91086             :                       // printf ("In SgStatementFunctionStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   91087           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   91088             :                        }
   91089             :                     pointerOfLinkedList = &(pointer[i]);
   91090             :                   }
   91091             :               }
   91092             :         }
   91093             : 
   91094           5 :      if ( pointerOfLinkedList != NULL )
   91095             :         {
   91096             :        // printf ("In SgStatementFunctionStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   91097           0 :           pointerOfLinkedList->set_freepointer(NULL);
   91098             :        // DQ (6/6/2010): Temporary debugging...
   91099             :        //   ROSE_ASSERT(false);
   91100             :         }
   91101             : 
   91102           5 :      return ;
   91103             :    }
   91104             : 
   91105             : //############################################################################
   91106             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   91107             :  * within the memory pool and resets the freepointers, in order to achieve a 
   91108             :  * linked list, that has no jumps and starts at the beginning! This function 
   91109             :  * does not extend the memory pool, since we do not delete any memory blocks,
   91110             :  * but delete the valid objects.  
   91111             :  */
   91112             : void
   91113           0 : SgStatementFunctionStatement::clearMemoryPool( )
   91114             :    {
   91115             :   // printf ("Inside of SgStatementFunctionStatement::clearMemoryPool() \n");
   91116             : 
   91117           0 :      SgStatementFunctionStatement* pointer = NULL, *tempPointer = NULL;
   91118           0 :      std::vector < unsigned char* > :: const_iterator block;
   91119           0 :      if ( SgStatementFunctionStatement::pools.empty() == false )
   91120             :         {
   91121           0 :           block = SgStatementFunctionStatement::pools.begin() ;
   91122           0 :           SgStatementFunctionStatement::next_node = (SgStatementFunctionStatement*) (*block);
   91123             : 
   91124           0 :           while ( block != SgStatementFunctionStatement::pools.end() )
   91125             :              {
   91126           0 :                pointer = (SgStatementFunctionStatement*) (*block);
   91127           0 :                if ( tempPointer != NULL )
   91128             :                   {
   91129           0 :                     tempPointer->set_freepointer(pointer);
   91130             :                   }
   91131           0 :                for (unsigned i = 0; i < SgStatementFunctionStatement::pool_size - 1; ++i)
   91132             :                   {
   91133           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   91134             :                   }
   91135           0 :                 pointer[SgStatementFunctionStatement::pool_size-1].set_freepointer(NULL);
   91136           0 :                 tempPointer = &(pointer[SgStatementFunctionStatement::pool_size-1]);
   91137           0 :                 ++block;
   91138             :              }
   91139             :         }
   91140           0 :    }
   91141             : 
   91142           5 : void SgStatementFunctionStatement::deleteMemoryPool() {
   91143           5 :   for (auto p: SgStatementFunctionStatement::pools) {
   91144           0 :     ROSE_FREE(p);
   91145             :   }
   91146           5 :   SgStatementFunctionStatement::next_node = nullptr;
   91147           5 :   SgStatementFunctionStatement::pools.clear();
   91148           5 : }
   91149             : 
   91150             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   91151             : //                 reading multiple binary files to for a single AST.
   91152             : /////////// new version ////////////////////////////////
   91153             : //############################################################################
   91154             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   91155             : void
   91156           2 : SgStatementFunctionStatement::extendMemoryPoolForFileIO( )
   91157             :   {
   91158           2 :     size_t blockIndex = SgStatementFunctionStatement::pools.size();
   91159           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStatementFunctionStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatementFunctionStatement);
   91160             : 
   91161           2 :     while ( (blockIndex * SgStatementFunctionStatement::pool_size) < newPoolSize)
   91162             :       {
   91163             : #if ROSE_ALLOC_TRACE
   91164             :         if (blockIndex > 0) {
   91165             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStatementFunctionStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatementFunctionStatement) = %" PRIuPTR " SgStatementFunctionStatement::pool_size = %d \n",
   91166             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStatementFunctionStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatementFunctionStatement),SgStatementFunctionStatement::pool_size);
   91167             :         }
   91168             : #endif
   91169             : 
   91170           0 :         SgStatementFunctionStatement * pointer = (SgStatementFunctionStatement*) ROSE_MALLOC ( SgStatementFunctionStatement::pool_size * sizeof(SgStatementFunctionStatement) );
   91171           0 :         assert( pointer != NULL );
   91172             : #if ROSE_ALLOC_MEMSET == 1
   91173             :         memset(pointer, 0x00, SgStatementFunctionStatement::pool_size * sizeof(SgStatementFunctionStatement));
   91174             : #elif ROSE_ALLOC_MEMSET == 2
   91175             :         memset(pointer, 0xCC, SgStatementFunctionStatement::pool_size * sizeof(SgStatementFunctionStatement));
   91176             : #endif
   91177           0 :         SgStatementFunctionStatement::pools.push_back( (unsigned char*)(pointer) );
   91178           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStatementFunctionStatement::pool_size * sizeof(SgStatementFunctionStatement), V_SgStatementFunctionStatement ) );
   91179             : 
   91180           0 :         if ( SgStatementFunctionStatement::next_node != NULL ) {
   91181           0 :           if ( blockIndex > 0 ) {
   91182           0 :             SgStatementFunctionStatement * blkptr = (SgStatementFunctionStatement*)(SgStatementFunctionStatement::pools[blockIndex-1]);
   91183           0 :             blkptr[ SgStatementFunctionStatement::pool_size - 1 ].set_freepointer(pointer);
   91184             :           }
   91185             :         } else {
   91186           0 :           SgStatementFunctionStatement::next_node = pointer;
   91187             :         }
   91188             : 
   91189           0 :         for (unsigned i = 0; i < SgStatementFunctionStatement::pool_size-1; ++i)
   91190             :            {
   91191           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   91192             :            }
   91193           0 :         pointer[ SgStatementFunctionStatement::pool_size -1 ].set_freepointer(NULL);
   91194             : 
   91195           0 :         blockIndex++;
   91196             :       }
   91197           2 :   }
   91198             : 
   91199             : //############################################################################
   91200             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   91201             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   91202             :  * not compressed. However, that stuff is not yet implemented! 
   91203             :  */
   91204             : unsigned long
   91205           0 : SgStatementFunctionStatement::getNumberOfLastValidPointer()
   91206             :    {
   91207           0 :       SgStatementFunctionStatement* testPointer = (SgStatementFunctionStatement*)(SgStatementFunctionStatement::pools.back());
   91208           0 :       unsigned long localIndex = SgStatementFunctionStatement::pool_size - 1;
   91209           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   91210             :          {
   91211           0 :            localIndex--;
   91212             :          }
   91213           0 :       return (localIndex + SgStatementFunctionStatement::pool_size * (SgStatementFunctionStatement::pools.size()-1));
   91214             :    }
   91215             : 
   91216             : //############################################################################
   91217             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   91218             :  * memory pool and initializes the data member in class SgStatementFunctionStatementStroageClass
   91219             :  * from its counterpart of SgStatementFunctionStatement. The return value is just for checking, 
   91220             :  * that the whole StorageClassArray is initialized!
   91221             :  */
   91222             : unsigned long
   91223           0 : SgStatementFunctionStatement::initializeStorageClassArray( SgStatementFunctionStatementStorageClass *storageArray )
   91224             :    {
   91225           0 :      unsigned long storageCounter = 0;
   91226           0 :      std::vector < unsigned char* > :: const_iterator block = SgStatementFunctionStatement::pools.begin();
   91227           0 :      SgStatementFunctionStatement* pointer = NULL;
   91228           0 :      while ( block != SgStatementFunctionStatement::pools.end() ) {
   91229           0 :           pointer = (SgStatementFunctionStatement*) (*block);
   91230           0 :           for ( unsigned i = 0; i < SgStatementFunctionStatement::pool_size; ++i ) {
   91231           0 :                if ( pointer->get_freepointer() != NULL ) {
   91232           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   91233           0 :                  storageArray++;
   91234           0 :                  storageCounter++;
   91235             :                }
   91236           0 :                pointer++;
   91237             :              }
   91238           0 :            block++;
   91239             :         }
   91240           0 :      return storageCounter;
   91241             :    }
   91242             : 
   91243             : /* #line 91244 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   91244             : 
   91245             : 
   91246             : 
   91247             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   91248             : 
   91249             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   91250             : 
   91251             : //############################################################################
   91252             : /* JH (02/02/2006) Constructor of the IR node SgCtorInitializerList that takes its 
   91253             :  * corresponding StorageClass as parameter
   91254             :  */
   91255        4428 : SgCtorInitializerList :: SgCtorInitializerList ( const SgCtorInitializerListStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   91256             :    {
   91257             : 
   91258             : 
   91259             : /* #line 91260 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   91260             : 
   91261        4428 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   91262        4428 :      p_ctors = storageSource.storageOf_ctors.rebuildDataStoredInEasyStorageClass() ;
   91263        4428 :      SgInitializedNamePtrList::iterator i_ctors = p_ctors.begin() ; 
   91264        4691 :      for ( ; i_ctors != p_ctors.end(); ++i_ctors ) 
   91265             :         {
   91266         263 :           (*i_ctors) = (SgInitializedNamePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_ctors) ) );
   91267             :         }
   91268             : 
   91269             : 
   91270             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   91271             : 
   91272             : 
   91273        4428 :    }
   91274             : 
   91275             : //############################################################################
   91276             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   91277             :  * within the working AST. 
   91278             :  */
   91279       22401 : SgCtorInitializerList * SgCtorInitializerList::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   91280       22401 :      SgCtorInitializerList* returnPointer = NULL;
   91281       22401 :      if ( globalIndex != 0 )
   91282             :         {
   91283             : 
   91284             : #if FILE_IO_EXTRA_CHECK
   91285       22401 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCtorInitializerList ) ) <= globalIndex ) ;
   91286       22401 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCtorInitializerList + 1 ) ) );
   91287             : #endif
   91288       22401 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCtorInitializerList )  
   91289       22401 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCtorInitializerList );
   91290       22401 :           unsigned long positionInPool = localIndex % SgCtorInitializerList::pool_size;
   91291       22401 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCtorInitializerList::pool_size;
   91292             : 
   91293             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   91294             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   91295             : 
   91296       22401 :           returnPointer = &( ( (SgCtorInitializerList*)(SgCtorInitializerList::pools[memoryBlock]) ) [positionInPool]) ;
   91297             : 
   91298       22401 :           ROSE_ASSERT( returnPointer != NULL ) ;
   91299             :         }
   91300       22401 :      return returnPointer ;
   91301             :    }
   91302             : 
   91303             : //############################################################################
   91304             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   91305             :   for the AST with the index astIndex
   91306             : */
   91307           0 : SgCtorInitializerList * SgCtorInitializerList::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   91308           0 :      SgCtorInitializerList* returnPointer = NULL;
   91309           0 :      if ( globalIndex != 0 )
   91310             :         {
   91311             : 
   91312             : #if FILE_IO_EXTRA_CHECK
   91313           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCtorInitializerList ) ) <= globalIndex ) ;
   91314           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCtorInitializerList + 1 ) ) );
   91315             : #endif
   91316           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCtorInitializerList )
   91317           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCtorInitializerList );
   91318           0 :           unsigned long positionInPool = localIndex % SgCtorInitializerList::pool_size ;
   91319           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCtorInitializerList::pool_size ;
   91320             : 
   91321             : #if FILE_IO_EXTRA_CHECK
   91322             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   91323             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   91324             : #endif
   91325             : 
   91326           0 :           returnPointer = &( ( (SgCtorInitializerList*)(SgCtorInitializerList::pools[memoryBlock]) ) [positionInPool]) ;
   91327             : 
   91328             : #if FILE_IO_EXTRA_CHECK
   91329           0 :           assert ( returnPointer != NULL ) ;
   91330             : #endif
   91331             :         }
   91332           0 :      return returnPointer ;
   91333             :    }
   91334             : 
   91335             : //############################################################################
   91336             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   91337             :  * pool size! We set for every valid object in the memory pool the freepointer
   91338             :  * to the global index and increase the global index afterwards. For all the 
   91339             :  * invalid objects (means address ranges within the memory pool that were not
   91340             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   91341             :  * distinguish valid from invalid objects! 
   91342             :  */
   91343             : unsigned long
   91344           5 : SgCtorInitializerList::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   91345             :    {
   91346           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   91347           5 :      SgCtorInitializerList* pointer = NULL;
   91348           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   91349           5 :      std::vector < unsigned char* > :: const_iterator block;
   91350           8 :      for ( block = SgCtorInitializerList::pools.begin(); block != SgCtorInitializerList::pools.end() ; ++block )
   91351             :         {
   91352           3 :           pointer = (SgCtorInitializerList*)(*block);
   91353        6003 :           for (unsigned i = 0; i < SgCtorInitializerList::pool_size; ++i )
   91354             :              {
   91355             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   91356             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   91357             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   91358             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   91359             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   91360             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   91361             :             // properly; so this will have to be checked next.
   91362             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   91363             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   91364        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   91365             :                   {
   91366        4428 :                     pointer[i].set_freepointer((SgCtorInitializerList*)(globalIndex));
   91367        4428 :                     globalIndex++;
   91368             :                   }
   91369             :                else
   91370             :                   {
   91371        1572 :                     pointer[i].set_freepointer(NULL);
   91372             :                   }
   91373             :               }
   91374             :         }
   91375           5 :      return globalIndex;
   91376             :    }
   91377             : 
   91378             : //############################################################################
   91379             : // JH (01/14/2006)
   91380             : void
   91381           5 : SgCtorInitializerList::resetValidFreepointers( )
   91382             :    {
   91383           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   91384           5 :      SgCtorInitializerList* pointer = NULL;
   91385           5 :      std::vector < unsigned char* > :: const_iterator block;
   91386           5 :      SgCtorInitializerList* pointerOfLinkedList = NULL;
   91387           8 :      for ( block = SgCtorInitializerList::pools.begin(); block != SgCtorInitializerList::pools.end() ; ++block )
   91388             :         {
   91389           3 :           pointer = (SgCtorInitializerList*)(*block);
   91390        6003 :           for (unsigned i = 0; i < SgCtorInitializerList::pool_size; ++i )
   91391             :              {
   91392             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   91393             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   91394             :             // memory blocks!.
   91395        6000 :                if ( pointer[i].get_freepointer() != NULL )
   91396             :                   {
   91397        4428 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   91398             :                   }
   91399             :                else
   91400             :                   {
   91401        1572 :                     if ( pointerOfLinkedList == NULL )
   91402             :                        {
   91403           1 :                          SgCtorInitializerList::next_node = &(pointer[i]);
   91404             :                        }
   91405             :                     else
   91406             :                        {
   91407             :                       // printf ("In SgCtorInitializerList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   91408        1571 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   91409             :                        }
   91410             :                     pointerOfLinkedList = &(pointer[i]);
   91411             :                   }
   91412             :               }
   91413             :         }
   91414             : 
   91415           5 :      if ( pointerOfLinkedList != NULL )
   91416             :         {
   91417             :        // printf ("In SgCtorInitializerList::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   91418           1 :           pointerOfLinkedList->set_freepointer(NULL);
   91419             :        // DQ (6/6/2010): Temporary debugging...
   91420             :        //   ROSE_ASSERT(false);
   91421             :         }
   91422             : 
   91423           5 :      return ;
   91424             :    }
   91425             : 
   91426             : //############################################################################
   91427             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   91428             :  * within the memory pool and resets the freepointers, in order to achieve a 
   91429             :  * linked list, that has no jumps and starts at the beginning! This function 
   91430             :  * does not extend the memory pool, since we do not delete any memory blocks,
   91431             :  * but delete the valid objects.  
   91432             :  */
   91433             : void
   91434           0 : SgCtorInitializerList::clearMemoryPool( )
   91435             :    {
   91436             :   // printf ("Inside of SgCtorInitializerList::clearMemoryPool() \n");
   91437             : 
   91438           0 :      SgCtorInitializerList* pointer = NULL, *tempPointer = NULL;
   91439           0 :      std::vector < unsigned char* > :: const_iterator block;
   91440           0 :      if ( SgCtorInitializerList::pools.empty() == false )
   91441             :         {
   91442           0 :           block = SgCtorInitializerList::pools.begin() ;
   91443           0 :           SgCtorInitializerList::next_node = (SgCtorInitializerList*) (*block);
   91444             : 
   91445           0 :           while ( block != SgCtorInitializerList::pools.end() )
   91446             :              {
   91447           0 :                pointer = (SgCtorInitializerList*) (*block);
   91448           0 :                if ( tempPointer != NULL )
   91449             :                   {
   91450           0 :                     tempPointer->set_freepointer(pointer);
   91451             :                   }
   91452           0 :                for (unsigned i = 0; i < SgCtorInitializerList::pool_size - 1; ++i)
   91453             :                   {
   91454           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   91455             :                   }
   91456           0 :                 pointer[SgCtorInitializerList::pool_size-1].set_freepointer(NULL);
   91457           0 :                 tempPointer = &(pointer[SgCtorInitializerList::pool_size-1]);
   91458           0 :                 ++block;
   91459             :              }
   91460             :         }
   91461           0 :    }
   91462             : 
   91463           5 : void SgCtorInitializerList::deleteMemoryPool() {
   91464          11 :   for (auto p: SgCtorInitializerList::pools) {
   91465           6 :     ROSE_FREE(p);
   91466             :   }
   91467           5 :   SgCtorInitializerList::next_node = nullptr;
   91468           5 :   SgCtorInitializerList::pools.clear();
   91469           5 : }
   91470             : 
   91471             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   91472             : //                 reading multiple binary files to for a single AST.
   91473             : /////////// new version ////////////////////////////////
   91474             : //############################################################################
   91475             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   91476             : void
   91477           2 : SgCtorInitializerList::extendMemoryPoolForFileIO( )
   91478             :   {
   91479           2 :     size_t blockIndex = SgCtorInitializerList::pools.size();
   91480           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCtorInitializerList) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCtorInitializerList);
   91481             : 
   91482           5 :     while ( (blockIndex * SgCtorInitializerList::pool_size) < newPoolSize)
   91483             :       {
   91484             : #if ROSE_ALLOC_TRACE
   91485             :         if (blockIndex > 0) {
   91486             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCtorInitializerList) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCtorInitializerList) = %" PRIuPTR " SgCtorInitializerList::pool_size = %d \n",
   91487             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCtorInitializerList),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCtorInitializerList),SgCtorInitializerList::pool_size);
   91488             :         }
   91489             : #endif
   91490             : 
   91491           3 :         SgCtorInitializerList * pointer = (SgCtorInitializerList*) ROSE_MALLOC ( SgCtorInitializerList::pool_size * sizeof(SgCtorInitializerList) );
   91492           3 :         assert( pointer != NULL );
   91493             : #if ROSE_ALLOC_MEMSET == 1
   91494             :         memset(pointer, 0x00, SgCtorInitializerList::pool_size * sizeof(SgCtorInitializerList));
   91495             : #elif ROSE_ALLOC_MEMSET == 2
   91496             :         memset(pointer, 0xCC, SgCtorInitializerList::pool_size * sizeof(SgCtorInitializerList));
   91497             : #endif
   91498           3 :         SgCtorInitializerList::pools.push_back( (unsigned char*)(pointer) );
   91499           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCtorInitializerList::pool_size * sizeof(SgCtorInitializerList), V_SgCtorInitializerList ) );
   91500             : 
   91501           3 :         if ( SgCtorInitializerList::next_node != NULL ) {
   91502           2 :           if ( blockIndex > 0 ) {
   91503           2 :             SgCtorInitializerList * blkptr = (SgCtorInitializerList*)(SgCtorInitializerList::pools[blockIndex-1]);
   91504           2 :             blkptr[ SgCtorInitializerList::pool_size - 1 ].set_freepointer(pointer);
   91505             :           }
   91506             :         } else {
   91507           1 :           SgCtorInitializerList::next_node = pointer;
   91508             :         }
   91509             : 
   91510        6000 :         for (unsigned i = 0; i < SgCtorInitializerList::pool_size-1; ++i)
   91511             :            {
   91512        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   91513             :            }
   91514           3 :         pointer[ SgCtorInitializerList::pool_size -1 ].set_freepointer(NULL);
   91515             : 
   91516           3 :         blockIndex++;
   91517             :       }
   91518           2 :   }
   91519             : 
   91520             : //############################################################################
   91521             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   91522             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   91523             :  * not compressed. However, that stuff is not yet implemented! 
   91524             :  */
   91525             : unsigned long
   91526           0 : SgCtorInitializerList::getNumberOfLastValidPointer()
   91527             :    {
   91528           0 :       SgCtorInitializerList* testPointer = (SgCtorInitializerList*)(SgCtorInitializerList::pools.back());
   91529           0 :       unsigned long localIndex = SgCtorInitializerList::pool_size - 1;
   91530           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   91531             :          {
   91532           0 :            localIndex--;
   91533             :          }
   91534           0 :       return (localIndex + SgCtorInitializerList::pool_size * (SgCtorInitializerList::pools.size()-1));
   91535             :    }
   91536             : 
   91537             : //############################################################################
   91538             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   91539             :  * memory pool and initializes the data member in class SgCtorInitializerListStroageClass
   91540             :  * from its counterpart of SgCtorInitializerList. The return value is just for checking, 
   91541             :  * that the whole StorageClassArray is initialized!
   91542             :  */
   91543             : unsigned long
   91544           1 : SgCtorInitializerList::initializeStorageClassArray( SgCtorInitializerListStorageClass *storageArray )
   91545             :    {
   91546           1 :      unsigned long storageCounter = 0;
   91547           1 :      std::vector < unsigned char* > :: const_iterator block = SgCtorInitializerList::pools.begin();
   91548           1 :      SgCtorInitializerList* pointer = NULL;
   91549           4 :      while ( block != SgCtorInitializerList::pools.end() ) {
   91550           3 :           pointer = (SgCtorInitializerList*) (*block);
   91551        6003 :           for ( unsigned i = 0; i < SgCtorInitializerList::pool_size; ++i ) {
   91552        6000 :                if ( pointer->get_freepointer() != NULL ) {
   91553        4428 :                  storageArray->pickOutIRNodeData (pointer) ;
   91554        4428 :                  storageArray++;
   91555        4428 :                  storageCounter++;
   91556             :                }
   91557        6000 :                pointer++;
   91558             :              }
   91559           3 :            block++;
   91560             :         }
   91561           1 :      return storageCounter;
   91562             :    }
   91563             : 
   91564             : /* #line 91565 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   91565             : 
   91566             : 
   91567             : 
   91568             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   91569             : 
   91570             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   91571             : 
   91572             : //############################################################################
   91573             : /* JH (02/02/2006) Constructor of the IR node SgPragmaDeclaration that takes its 
   91574             :  * corresponding StorageClass as parameter
   91575             :  */
   91576          97 : SgPragmaDeclaration :: SgPragmaDeclaration ( const SgPragmaDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   91577             :    {
   91578             : 
   91579             : 
   91580             : /* #line 91581 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   91581             : 
   91582          97 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   91583          97 :      p_pragma =  (SgPragma*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pragma) );
   91584             : 
   91585             : 
   91586             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   91587             : 
   91588             : 
   91589          97 :    }
   91590             : 
   91591             : //############################################################################
   91592             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   91593             :  * within the working AST. 
   91594             :  */
   91595         582 : SgPragmaDeclaration * SgPragmaDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   91596         582 :      SgPragmaDeclaration* returnPointer = NULL;
   91597         582 :      if ( globalIndex != 0 )
   91598             :         {
   91599             : 
   91600             : #if FILE_IO_EXTRA_CHECK
   91601         582 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPragmaDeclaration ) ) <= globalIndex ) ;
   91602         582 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPragmaDeclaration + 1 ) ) );
   91603             : #endif
   91604         582 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPragmaDeclaration )  
   91605         582 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPragmaDeclaration );
   91606         582 :           unsigned long positionInPool = localIndex % SgPragmaDeclaration::pool_size;
   91607         582 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPragmaDeclaration::pool_size;
   91608             : 
   91609             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   91610             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   91611             : 
   91612         582 :           returnPointer = &( ( (SgPragmaDeclaration*)(SgPragmaDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   91613             : 
   91614         582 :           ROSE_ASSERT( returnPointer != NULL ) ;
   91615             :         }
   91616         582 :      return returnPointer ;
   91617             :    }
   91618             : 
   91619             : //############################################################################
   91620             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   91621             :   for the AST with the index astIndex
   91622             : */
   91623           0 : SgPragmaDeclaration * SgPragmaDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   91624           0 :      SgPragmaDeclaration* returnPointer = NULL;
   91625           0 :      if ( globalIndex != 0 )
   91626             :         {
   91627             : 
   91628             : #if FILE_IO_EXTRA_CHECK
   91629           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPragmaDeclaration ) ) <= globalIndex ) ;
   91630           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPragmaDeclaration + 1 ) ) );
   91631             : #endif
   91632           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPragmaDeclaration )
   91633           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPragmaDeclaration );
   91634           0 :           unsigned long positionInPool = localIndex % SgPragmaDeclaration::pool_size ;
   91635           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPragmaDeclaration::pool_size ;
   91636             : 
   91637             : #if FILE_IO_EXTRA_CHECK
   91638             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   91639             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   91640             : #endif
   91641             : 
   91642           0 :           returnPointer = &( ( (SgPragmaDeclaration*)(SgPragmaDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   91643             : 
   91644             : #if FILE_IO_EXTRA_CHECK
   91645           0 :           assert ( returnPointer != NULL ) ;
   91646             : #endif
   91647             :         }
   91648           0 :      return returnPointer ;
   91649             :    }
   91650             : 
   91651             : //############################################################################
   91652             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   91653             :  * pool size! We set for every valid object in the memory pool the freepointer
   91654             :  * to the global index and increase the global index afterwards. For all the 
   91655             :  * invalid objects (means address ranges within the memory pool that were not
   91656             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   91657             :  * distinguish valid from invalid objects! 
   91658             :  */
   91659             : unsigned long
   91660           5 : SgPragmaDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   91661             :    {
   91662           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   91663           5 :      SgPragmaDeclaration* pointer = NULL;
   91664           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   91665           5 :      std::vector < unsigned char* > :: const_iterator block;
   91666           6 :      for ( block = SgPragmaDeclaration::pools.begin(); block != SgPragmaDeclaration::pools.end() ; ++block )
   91667             :         {
   91668           1 :           pointer = (SgPragmaDeclaration*)(*block);
   91669        2001 :           for (unsigned i = 0; i < SgPragmaDeclaration::pool_size; ++i )
   91670             :              {
   91671             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   91672             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   91673             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   91674             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   91675             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   91676             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   91677             :             // properly; so this will have to be checked next.
   91678             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   91679             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   91680        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   91681             :                   {
   91682          97 :                     pointer[i].set_freepointer((SgPragmaDeclaration*)(globalIndex));
   91683          97 :                     globalIndex++;
   91684             :                   }
   91685             :                else
   91686             :                   {
   91687        1903 :                     pointer[i].set_freepointer(NULL);
   91688             :                   }
   91689             :               }
   91690             :         }
   91691           5 :      return globalIndex;
   91692             :    }
   91693             : 
   91694             : //############################################################################
   91695             : // JH (01/14/2006)
   91696             : void
   91697           5 : SgPragmaDeclaration::resetValidFreepointers( )
   91698             :    {
   91699           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   91700           5 :      SgPragmaDeclaration* pointer = NULL;
   91701           5 :      std::vector < unsigned char* > :: const_iterator block;
   91702           5 :      SgPragmaDeclaration* pointerOfLinkedList = NULL;
   91703           6 :      for ( block = SgPragmaDeclaration::pools.begin(); block != SgPragmaDeclaration::pools.end() ; ++block )
   91704             :         {
   91705           1 :           pointer = (SgPragmaDeclaration*)(*block);
   91706        2001 :           for (unsigned i = 0; i < SgPragmaDeclaration::pool_size; ++i )
   91707             :              {
   91708             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   91709             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   91710             :             // memory blocks!.
   91711        2000 :                if ( pointer[i].get_freepointer() != NULL )
   91712             :                   {
   91713          97 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   91714             :                   }
   91715             :                else
   91716             :                   {
   91717        1903 :                     if ( pointerOfLinkedList == NULL )
   91718             :                        {
   91719           1 :                          SgPragmaDeclaration::next_node = &(pointer[i]);
   91720             :                        }
   91721             :                     else
   91722             :                        {
   91723             :                       // printf ("In SgPragmaDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   91724        1902 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   91725             :                        }
   91726             :                     pointerOfLinkedList = &(pointer[i]);
   91727             :                   }
   91728             :               }
   91729             :         }
   91730             : 
   91731           5 :      if ( pointerOfLinkedList != NULL )
   91732             :         {
   91733             :        // printf ("In SgPragmaDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   91734           1 :           pointerOfLinkedList->set_freepointer(NULL);
   91735             :        // DQ (6/6/2010): Temporary debugging...
   91736             :        //   ROSE_ASSERT(false);
   91737             :         }
   91738             : 
   91739           5 :      return ;
   91740             :    }
   91741             : 
   91742             : //############################################################################
   91743             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   91744             :  * within the memory pool and resets the freepointers, in order to achieve a 
   91745             :  * linked list, that has no jumps and starts at the beginning! This function 
   91746             :  * does not extend the memory pool, since we do not delete any memory blocks,
   91747             :  * but delete the valid objects.  
   91748             :  */
   91749             : void
   91750           0 : SgPragmaDeclaration::clearMemoryPool( )
   91751             :    {
   91752             :   // printf ("Inside of SgPragmaDeclaration::clearMemoryPool() \n");
   91753             : 
   91754           0 :      SgPragmaDeclaration* pointer = NULL, *tempPointer = NULL;
   91755           0 :      std::vector < unsigned char* > :: const_iterator block;
   91756           0 :      if ( SgPragmaDeclaration::pools.empty() == false )
   91757             :         {
   91758           0 :           block = SgPragmaDeclaration::pools.begin() ;
   91759           0 :           SgPragmaDeclaration::next_node = (SgPragmaDeclaration*) (*block);
   91760             : 
   91761           0 :           while ( block != SgPragmaDeclaration::pools.end() )
   91762             :              {
   91763           0 :                pointer = (SgPragmaDeclaration*) (*block);
   91764           0 :                if ( tempPointer != NULL )
   91765             :                   {
   91766           0 :                     tempPointer->set_freepointer(pointer);
   91767             :                   }
   91768           0 :                for (unsigned i = 0; i < SgPragmaDeclaration::pool_size - 1; ++i)
   91769             :                   {
   91770           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   91771             :                   }
   91772           0 :                 pointer[SgPragmaDeclaration::pool_size-1].set_freepointer(NULL);
   91773           0 :                 tempPointer = &(pointer[SgPragmaDeclaration::pool_size-1]);
   91774           0 :                 ++block;
   91775             :              }
   91776             :         }
   91777           0 :    }
   91778             : 
   91779           5 : void SgPragmaDeclaration::deleteMemoryPool() {
   91780           7 :   for (auto p: SgPragmaDeclaration::pools) {
   91781           2 :     ROSE_FREE(p);
   91782             :   }
   91783           5 :   SgPragmaDeclaration::next_node = nullptr;
   91784           5 :   SgPragmaDeclaration::pools.clear();
   91785           5 : }
   91786             : 
   91787             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   91788             : //                 reading multiple binary files to for a single AST.
   91789             : /////////// new version ////////////////////////////////
   91790             : //############################################################################
   91791             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   91792             : void
   91793           2 : SgPragmaDeclaration::extendMemoryPoolForFileIO( )
   91794             :   {
   91795           2 :     size_t blockIndex = SgPragmaDeclaration::pools.size();
   91796           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPragmaDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPragmaDeclaration);
   91797             : 
   91798           3 :     while ( (blockIndex * SgPragmaDeclaration::pool_size) < newPoolSize)
   91799             :       {
   91800             : #if ROSE_ALLOC_TRACE
   91801             :         if (blockIndex > 0) {
   91802             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPragmaDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPragmaDeclaration) = %" PRIuPTR " SgPragmaDeclaration::pool_size = %d \n",
   91803             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPragmaDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPragmaDeclaration),SgPragmaDeclaration::pool_size);
   91804             :         }
   91805             : #endif
   91806             : 
   91807           1 :         SgPragmaDeclaration * pointer = (SgPragmaDeclaration*) ROSE_MALLOC ( SgPragmaDeclaration::pool_size * sizeof(SgPragmaDeclaration) );
   91808           1 :         assert( pointer != NULL );
   91809             : #if ROSE_ALLOC_MEMSET == 1
   91810             :         memset(pointer, 0x00, SgPragmaDeclaration::pool_size * sizeof(SgPragmaDeclaration));
   91811             : #elif ROSE_ALLOC_MEMSET == 2
   91812             :         memset(pointer, 0xCC, SgPragmaDeclaration::pool_size * sizeof(SgPragmaDeclaration));
   91813             : #endif
   91814           1 :         SgPragmaDeclaration::pools.push_back( (unsigned char*)(pointer) );
   91815           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPragmaDeclaration::pool_size * sizeof(SgPragmaDeclaration), V_SgPragmaDeclaration ) );
   91816             : 
   91817           1 :         if ( SgPragmaDeclaration::next_node != NULL ) {
   91818           0 :           if ( blockIndex > 0 ) {
   91819           0 :             SgPragmaDeclaration * blkptr = (SgPragmaDeclaration*)(SgPragmaDeclaration::pools[blockIndex-1]);
   91820           0 :             blkptr[ SgPragmaDeclaration::pool_size - 1 ].set_freepointer(pointer);
   91821             :           }
   91822             :         } else {
   91823           1 :           SgPragmaDeclaration::next_node = pointer;
   91824             :         }
   91825             : 
   91826        2000 :         for (unsigned i = 0; i < SgPragmaDeclaration::pool_size-1; ++i)
   91827             :            {
   91828        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   91829             :            }
   91830           1 :         pointer[ SgPragmaDeclaration::pool_size -1 ].set_freepointer(NULL);
   91831             : 
   91832           1 :         blockIndex++;
   91833             :       }
   91834           2 :   }
   91835             : 
   91836             : //############################################################################
   91837             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   91838             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   91839             :  * not compressed. However, that stuff is not yet implemented! 
   91840             :  */
   91841             : unsigned long
   91842           0 : SgPragmaDeclaration::getNumberOfLastValidPointer()
   91843             :    {
   91844           0 :       SgPragmaDeclaration* testPointer = (SgPragmaDeclaration*)(SgPragmaDeclaration::pools.back());
   91845           0 :       unsigned long localIndex = SgPragmaDeclaration::pool_size - 1;
   91846           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   91847             :          {
   91848           0 :            localIndex--;
   91849             :          }
   91850           0 :       return (localIndex + SgPragmaDeclaration::pool_size * (SgPragmaDeclaration::pools.size()-1));
   91851             :    }
   91852             : 
   91853             : //############################################################################
   91854             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   91855             :  * memory pool and initializes the data member in class SgPragmaDeclarationStroageClass
   91856             :  * from its counterpart of SgPragmaDeclaration. The return value is just for checking, 
   91857             :  * that the whole StorageClassArray is initialized!
   91858             :  */
   91859             : unsigned long
   91860           1 : SgPragmaDeclaration::initializeStorageClassArray( SgPragmaDeclarationStorageClass *storageArray )
   91861             :    {
   91862           1 :      unsigned long storageCounter = 0;
   91863           1 :      std::vector < unsigned char* > :: const_iterator block = SgPragmaDeclaration::pools.begin();
   91864           1 :      SgPragmaDeclaration* pointer = NULL;
   91865           2 :      while ( block != SgPragmaDeclaration::pools.end() ) {
   91866           1 :           pointer = (SgPragmaDeclaration*) (*block);
   91867        2001 :           for ( unsigned i = 0; i < SgPragmaDeclaration::pool_size; ++i ) {
   91868        2000 :                if ( pointer->get_freepointer() != NULL ) {
   91869          97 :                  storageArray->pickOutIRNodeData (pointer) ;
   91870          97 :                  storageArray++;
   91871          97 :                  storageCounter++;
   91872             :                }
   91873        2000 :                pointer++;
   91874             :              }
   91875           1 :            block++;
   91876             :         }
   91877           1 :      return storageCounter;
   91878             :    }
   91879             : 
   91880             : /* #line 91881 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   91881             : 
   91882             : 
   91883             : 
   91884             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   91885             : 
   91886             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   91887             : 
   91888             : //############################################################################
   91889             : /* JH (02/02/2006) Constructor of the IR node SgUsingDirectiveStatement that takes its 
   91890             :  * corresponding StorageClass as parameter
   91891             :  */
   91892           1 : SgUsingDirectiveStatement :: SgUsingDirectiveStatement ( const SgUsingDirectiveStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   91893             :    {
   91894             : 
   91895             : 
   91896             : /* #line 91897 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   91897             : 
   91898           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   91899           1 :      p_namespaceDeclaration =  (SgNamespaceDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_namespaceDeclaration) );
   91900           1 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   91901           1 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   91902           1 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   91903             : 
   91904             : 
   91905             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   91906             : 
   91907             : 
   91908           1 :    }
   91909             : 
   91910             : //############################################################################
   91911             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   91912             :  * within the working AST. 
   91913             :  */
   91914           5 : SgUsingDirectiveStatement * SgUsingDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   91915           5 :      SgUsingDirectiveStatement* returnPointer = NULL;
   91916           5 :      if ( globalIndex != 0 )
   91917             :         {
   91918             : 
   91919             : #if FILE_IO_EXTRA_CHECK
   91920           5 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUsingDirectiveStatement ) ) <= globalIndex ) ;
   91921           5 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUsingDirectiveStatement + 1 ) ) );
   91922             : #endif
   91923           5 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUsingDirectiveStatement )  
   91924           5 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUsingDirectiveStatement );
   91925           5 :           unsigned long positionInPool = localIndex % SgUsingDirectiveStatement::pool_size;
   91926           5 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUsingDirectiveStatement::pool_size;
   91927             : 
   91928             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   91929             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   91930             : 
   91931           5 :           returnPointer = &( ( (SgUsingDirectiveStatement*)(SgUsingDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   91932             : 
   91933           5 :           ROSE_ASSERT( returnPointer != NULL ) ;
   91934             :         }
   91935           5 :      return returnPointer ;
   91936             :    }
   91937             : 
   91938             : //############################################################################
   91939             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   91940             :   for the AST with the index astIndex
   91941             : */
   91942           0 : SgUsingDirectiveStatement * SgUsingDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   91943           0 :      SgUsingDirectiveStatement* returnPointer = NULL;
   91944           0 :      if ( globalIndex != 0 )
   91945             :         {
   91946             : 
   91947             : #if FILE_IO_EXTRA_CHECK
   91948           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUsingDirectiveStatement ) ) <= globalIndex ) ;
   91949           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUsingDirectiveStatement + 1 ) ) );
   91950             : #endif
   91951           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUsingDirectiveStatement )
   91952           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUsingDirectiveStatement );
   91953           0 :           unsigned long positionInPool = localIndex % SgUsingDirectiveStatement::pool_size ;
   91954           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUsingDirectiveStatement::pool_size ;
   91955             : 
   91956             : #if FILE_IO_EXTRA_CHECK
   91957             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   91958             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   91959             : #endif
   91960             : 
   91961           0 :           returnPointer = &( ( (SgUsingDirectiveStatement*)(SgUsingDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   91962             : 
   91963             : #if FILE_IO_EXTRA_CHECK
   91964           0 :           assert ( returnPointer != NULL ) ;
   91965             : #endif
   91966             :         }
   91967           0 :      return returnPointer ;
   91968             :    }
   91969             : 
   91970             : //############################################################################
   91971             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   91972             :  * pool size! We set for every valid object in the memory pool the freepointer
   91973             :  * to the global index and increase the global index afterwards. For all the 
   91974             :  * invalid objects (means address ranges within the memory pool that were not
   91975             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   91976             :  * distinguish valid from invalid objects! 
   91977             :  */
   91978             : unsigned long
   91979           5 : SgUsingDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   91980             :    {
   91981           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   91982           5 :      SgUsingDirectiveStatement* pointer = NULL;
   91983           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   91984           5 :      std::vector < unsigned char* > :: const_iterator block;
   91985           6 :      for ( block = SgUsingDirectiveStatement::pools.begin(); block != SgUsingDirectiveStatement::pools.end() ; ++block )
   91986             :         {
   91987           1 :           pointer = (SgUsingDirectiveStatement*)(*block);
   91988        2001 :           for (unsigned i = 0; i < SgUsingDirectiveStatement::pool_size; ++i )
   91989             :              {
   91990             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   91991             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   91992             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   91993             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   91994             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   91995             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   91996             :             // properly; so this will have to be checked next.
   91997             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   91998             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   91999        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   92000             :                   {
   92001           1 :                     pointer[i].set_freepointer((SgUsingDirectiveStatement*)(globalIndex));
   92002           1 :                     globalIndex++;
   92003             :                   }
   92004             :                else
   92005             :                   {
   92006        1999 :                     pointer[i].set_freepointer(NULL);
   92007             :                   }
   92008             :               }
   92009             :         }
   92010           5 :      return globalIndex;
   92011             :    }
   92012             : 
   92013             : //############################################################################
   92014             : // JH (01/14/2006)
   92015             : void
   92016           5 : SgUsingDirectiveStatement::resetValidFreepointers( )
   92017             :    {
   92018           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   92019           5 :      SgUsingDirectiveStatement* pointer = NULL;
   92020           5 :      std::vector < unsigned char* > :: const_iterator block;
   92021           5 :      SgUsingDirectiveStatement* pointerOfLinkedList = NULL;
   92022           6 :      for ( block = SgUsingDirectiveStatement::pools.begin(); block != SgUsingDirectiveStatement::pools.end() ; ++block )
   92023             :         {
   92024           1 :           pointer = (SgUsingDirectiveStatement*)(*block);
   92025        2001 :           for (unsigned i = 0; i < SgUsingDirectiveStatement::pool_size; ++i )
   92026             :              {
   92027             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   92028             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   92029             :             // memory blocks!.
   92030        2000 :                if ( pointer[i].get_freepointer() != NULL )
   92031             :                   {
   92032           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   92033             :                   }
   92034             :                else
   92035             :                   {
   92036        1999 :                     if ( pointerOfLinkedList == NULL )
   92037             :                        {
   92038           1 :                          SgUsingDirectiveStatement::next_node = &(pointer[i]);
   92039             :                        }
   92040             :                     else
   92041             :                        {
   92042             :                       // printf ("In SgUsingDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   92043        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   92044             :                        }
   92045             :                     pointerOfLinkedList = &(pointer[i]);
   92046             :                   }
   92047             :               }
   92048             :         }
   92049             : 
   92050           5 :      if ( pointerOfLinkedList != NULL )
   92051             :         {
   92052             :        // printf ("In SgUsingDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   92053           1 :           pointerOfLinkedList->set_freepointer(NULL);
   92054             :        // DQ (6/6/2010): Temporary debugging...
   92055             :        //   ROSE_ASSERT(false);
   92056             :         }
   92057             : 
   92058           5 :      return ;
   92059             :    }
   92060             : 
   92061             : //############################################################################
   92062             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   92063             :  * within the memory pool and resets the freepointers, in order to achieve a 
   92064             :  * linked list, that has no jumps and starts at the beginning! This function 
   92065             :  * does not extend the memory pool, since we do not delete any memory blocks,
   92066             :  * but delete the valid objects.  
   92067             :  */
   92068             : void
   92069           0 : SgUsingDirectiveStatement::clearMemoryPool( )
   92070             :    {
   92071             :   // printf ("Inside of SgUsingDirectiveStatement::clearMemoryPool() \n");
   92072             : 
   92073           0 :      SgUsingDirectiveStatement* pointer = NULL, *tempPointer = NULL;
   92074           0 :      std::vector < unsigned char* > :: const_iterator block;
   92075           0 :      if ( SgUsingDirectiveStatement::pools.empty() == false )
   92076             :         {
   92077           0 :           block = SgUsingDirectiveStatement::pools.begin() ;
   92078           0 :           SgUsingDirectiveStatement::next_node = (SgUsingDirectiveStatement*) (*block);
   92079             : 
   92080           0 :           while ( block != SgUsingDirectiveStatement::pools.end() )
   92081             :              {
   92082           0 :                pointer = (SgUsingDirectiveStatement*) (*block);
   92083           0 :                if ( tempPointer != NULL )
   92084             :                   {
   92085           0 :                     tempPointer->set_freepointer(pointer);
   92086             :                   }
   92087           0 :                for (unsigned i = 0; i < SgUsingDirectiveStatement::pool_size - 1; ++i)
   92088             :                   {
   92089           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   92090             :                   }
   92091           0 :                 pointer[SgUsingDirectiveStatement::pool_size-1].set_freepointer(NULL);
   92092           0 :                 tempPointer = &(pointer[SgUsingDirectiveStatement::pool_size-1]);
   92093           0 :                 ++block;
   92094             :              }
   92095             :         }
   92096           0 :    }
   92097             : 
   92098           5 : void SgUsingDirectiveStatement::deleteMemoryPool() {
   92099           7 :   for (auto p: SgUsingDirectiveStatement::pools) {
   92100           2 :     ROSE_FREE(p);
   92101             :   }
   92102           5 :   SgUsingDirectiveStatement::next_node = nullptr;
   92103           5 :   SgUsingDirectiveStatement::pools.clear();
   92104           5 : }
   92105             : 
   92106             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   92107             : //                 reading multiple binary files to for a single AST.
   92108             : /////////// new version ////////////////////////////////
   92109             : //############################################################################
   92110             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   92111             : void
   92112           2 : SgUsingDirectiveStatement::extendMemoryPoolForFileIO( )
   92113             :   {
   92114           2 :     size_t blockIndex = SgUsingDirectiveStatement::pools.size();
   92115           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUsingDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUsingDirectiveStatement);
   92116             : 
   92117           3 :     while ( (blockIndex * SgUsingDirectiveStatement::pool_size) < newPoolSize)
   92118             :       {
   92119             : #if ROSE_ALLOC_TRACE
   92120             :         if (blockIndex > 0) {
   92121             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUsingDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUsingDirectiveStatement) = %" PRIuPTR " SgUsingDirectiveStatement::pool_size = %d \n",
   92122             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUsingDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUsingDirectiveStatement),SgUsingDirectiveStatement::pool_size);
   92123             :         }
   92124             : #endif
   92125             : 
   92126           1 :         SgUsingDirectiveStatement * pointer = (SgUsingDirectiveStatement*) ROSE_MALLOC ( SgUsingDirectiveStatement::pool_size * sizeof(SgUsingDirectiveStatement) );
   92127           1 :         assert( pointer != NULL );
   92128             : #if ROSE_ALLOC_MEMSET == 1
   92129             :         memset(pointer, 0x00, SgUsingDirectiveStatement::pool_size * sizeof(SgUsingDirectiveStatement));
   92130             : #elif ROSE_ALLOC_MEMSET == 2
   92131             :         memset(pointer, 0xCC, SgUsingDirectiveStatement::pool_size * sizeof(SgUsingDirectiveStatement));
   92132             : #endif
   92133           1 :         SgUsingDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
   92134           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUsingDirectiveStatement::pool_size * sizeof(SgUsingDirectiveStatement), V_SgUsingDirectiveStatement ) );
   92135             : 
   92136           1 :         if ( SgUsingDirectiveStatement::next_node != NULL ) {
   92137           0 :           if ( blockIndex > 0 ) {
   92138           0 :             SgUsingDirectiveStatement * blkptr = (SgUsingDirectiveStatement*)(SgUsingDirectiveStatement::pools[blockIndex-1]);
   92139           0 :             blkptr[ SgUsingDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
   92140             :           }
   92141             :         } else {
   92142           1 :           SgUsingDirectiveStatement::next_node = pointer;
   92143             :         }
   92144             : 
   92145        2000 :         for (unsigned i = 0; i < SgUsingDirectiveStatement::pool_size-1; ++i)
   92146             :            {
   92147        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   92148             :            }
   92149           1 :         pointer[ SgUsingDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
   92150             : 
   92151           1 :         blockIndex++;
   92152             :       }
   92153           2 :   }
   92154             : 
   92155             : //############################################################################
   92156             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   92157             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   92158             :  * not compressed. However, that stuff is not yet implemented! 
   92159             :  */
   92160             : unsigned long
   92161           0 : SgUsingDirectiveStatement::getNumberOfLastValidPointer()
   92162             :    {
   92163           0 :       SgUsingDirectiveStatement* testPointer = (SgUsingDirectiveStatement*)(SgUsingDirectiveStatement::pools.back());
   92164           0 :       unsigned long localIndex = SgUsingDirectiveStatement::pool_size - 1;
   92165           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   92166             :          {
   92167           0 :            localIndex--;
   92168             :          }
   92169           0 :       return (localIndex + SgUsingDirectiveStatement::pool_size * (SgUsingDirectiveStatement::pools.size()-1));
   92170             :    }
   92171             : 
   92172             : //############################################################################
   92173             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   92174             :  * memory pool and initializes the data member in class SgUsingDirectiveStatementStroageClass
   92175             :  * from its counterpart of SgUsingDirectiveStatement. The return value is just for checking, 
   92176             :  * that the whole StorageClassArray is initialized!
   92177             :  */
   92178             : unsigned long
   92179           1 : SgUsingDirectiveStatement::initializeStorageClassArray( SgUsingDirectiveStatementStorageClass *storageArray )
   92180             :    {
   92181           1 :      unsigned long storageCounter = 0;
   92182           1 :      std::vector < unsigned char* > :: const_iterator block = SgUsingDirectiveStatement::pools.begin();
   92183           1 :      SgUsingDirectiveStatement* pointer = NULL;
   92184           2 :      while ( block != SgUsingDirectiveStatement::pools.end() ) {
   92185           1 :           pointer = (SgUsingDirectiveStatement*) (*block);
   92186        2001 :           for ( unsigned i = 0; i < SgUsingDirectiveStatement::pool_size; ++i ) {
   92187        2000 :                if ( pointer->get_freepointer() != NULL ) {
   92188           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   92189           1 :                  storageArray++;
   92190           1 :                  storageCounter++;
   92191             :                }
   92192        2000 :                pointer++;
   92193             :              }
   92194           1 :            block++;
   92195             :         }
   92196           1 :      return storageCounter;
   92197             :    }
   92198             : 
   92199             : /* #line 92200 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   92200             : 
   92201             : 
   92202             : 
   92203             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   92204             : 
   92205             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   92206             : 
   92207             : //############################################################################
   92208             : /* JH (02/02/2006) Constructor of the IR node SgClassDeclaration that takes its 
   92209             :  * corresponding StorageClass as parameter
   92210             :  */
   92211        2780 : SgClassDeclaration :: SgClassDeclaration ( const SgClassDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   92212             :    {
   92213             : 
   92214             : 
   92215             : /* #line 92216 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   92216             : 
   92217        2780 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   92218        2780 :      p_name = SgName ( storageSource.storageOf_name ) ;
   92219        2780 :      p_class_type = storageSource.storageOf_class_type ;
   92220        2780 :      p_type =  (SgClassType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
   92221        2780 :      p_definition =  (SgClassDefinition*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_definition) );
   92222        2780 :      p_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scope) );
   92223        2780 :      p_specialization = storageSource.storageOf_specialization ;
   92224        2780 :      p_from_template = storageSource.storageOf_from_template ;
   92225        2780 :      p_fixupScope = storageSource.storageOf_fixupScope ;
   92226        2780 :      p_isUnNamed = storageSource.storageOf_isUnNamed ;
   92227        2780 :      p_explicit_annotation_interface = storageSource.storageOf_explicit_annotation_interface ;
   92228        2780 :      p_explicit_interface = storageSource.storageOf_explicit_interface ;
   92229        2780 :      p_explicit_enum = storageSource.storageOf_explicit_enum ;
   92230        2780 :      p_explicit_anonymous = storageSource.storageOf_explicit_anonymous ;
   92231        2780 :      p_decoratorList =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_decoratorList) );
   92232        2780 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   92233        2780 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   92234        2780 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   92235        2780 :      p_isAutonomousDeclaration = storageSource.storageOf_isAutonomousDeclaration ;
   92236        2780 :      p_isRepresentingTemplateParameterInTemplateDeclaration = storageSource.storageOf_isRepresentingTemplateParameterInTemplateDeclaration ;
   92237        2780 :      p_adaParentType =  (SgBaseClass*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_adaParentType) );
   92238             : 
   92239             : 
   92240             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   92241             : 
   92242             : 
   92243        2780 :    }
   92244             : 
   92245             : //############################################################################
   92246             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   92247             :  * within the working AST. 
   92248             :  */
   92249        2657 : SgClassDeclaration * SgClassDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   92250        2657 :      SgClassDeclaration* returnPointer = NULL;
   92251        2657 :      if ( globalIndex != 0 )
   92252             :         {
   92253             : 
   92254             : #if FILE_IO_EXTRA_CHECK
   92255        2657 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClassDeclaration ) ) <= globalIndex ) ;
   92256        2657 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassDeclaration + 1 ) ) );
   92257             : #endif
   92258        2657 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassDeclaration )  
   92259        2657 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClassDeclaration );
   92260        2657 :           unsigned long positionInPool = localIndex % SgClassDeclaration::pool_size;
   92261        2657 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassDeclaration::pool_size;
   92262             : 
   92263             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   92264             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   92265             : 
   92266        2657 :           returnPointer = &( ( (SgClassDeclaration*)(SgClassDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   92267             : 
   92268        2657 :           ROSE_ASSERT( returnPointer != NULL ) ;
   92269             :         }
   92270        2657 :      return returnPointer ;
   92271             :    }
   92272             : 
   92273             : //############################################################################
   92274             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   92275             :   for the AST with the index astIndex
   92276             : */
   92277           0 : SgClassDeclaration * SgClassDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   92278           0 :      SgClassDeclaration* returnPointer = NULL;
   92279           0 :      if ( globalIndex != 0 )
   92280             :         {
   92281             : 
   92282             : #if FILE_IO_EXTRA_CHECK
   92283           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClassDeclaration ) ) <= globalIndex ) ;
   92284           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassDeclaration + 1 ) ) );
   92285             : #endif
   92286           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassDeclaration )
   92287           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClassDeclaration );
   92288           0 :           unsigned long positionInPool = localIndex % SgClassDeclaration::pool_size ;
   92289           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassDeclaration::pool_size ;
   92290             : 
   92291             : #if FILE_IO_EXTRA_CHECK
   92292             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   92293             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   92294             : #endif
   92295             : 
   92296           0 :           returnPointer = &( ( (SgClassDeclaration*)(SgClassDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   92297             : 
   92298             : #if FILE_IO_EXTRA_CHECK
   92299           0 :           assert ( returnPointer != NULL ) ;
   92300             : #endif
   92301             :         }
   92302           0 :      return returnPointer ;
   92303             :    }
   92304             : 
   92305             : //############################################################################
   92306             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   92307             :  * pool size! We set for every valid object in the memory pool the freepointer
   92308             :  * to the global index and increase the global index afterwards. For all the 
   92309             :  * invalid objects (means address ranges within the memory pool that were not
   92310             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   92311             :  * distinguish valid from invalid objects! 
   92312             :  */
   92313             : unsigned long
   92314           5 : SgClassDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   92315             :    {
   92316           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   92317           5 :      SgClassDeclaration* pointer = NULL;
   92318           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   92319           5 :      std::vector < unsigned char* > :: const_iterator block;
   92320           7 :      for ( block = SgClassDeclaration::pools.begin(); block != SgClassDeclaration::pools.end() ; ++block )
   92321             :         {
   92322           2 :           pointer = (SgClassDeclaration*)(*block);
   92323        4002 :           for (unsigned i = 0; i < SgClassDeclaration::pool_size; ++i )
   92324             :              {
   92325             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   92326             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   92327             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   92328             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   92329             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   92330             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   92331             :             // properly; so this will have to be checked next.
   92332             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   92333             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   92334        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   92335             :                   {
   92336         371 :                     pointer[i].set_freepointer((SgClassDeclaration*)(globalIndex));
   92337         371 :                     globalIndex++;
   92338             :                   }
   92339             :                else
   92340             :                   {
   92341        3629 :                     pointer[i].set_freepointer(NULL);
   92342             :                   }
   92343             :               }
   92344             :         }
   92345           5 :      return globalIndex;
   92346             :    }
   92347             : 
   92348             : //############################################################################
   92349             : // JH (01/14/2006)
   92350             : void
   92351           5 : SgClassDeclaration::resetValidFreepointers( )
   92352             :    {
   92353           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   92354           5 :      SgClassDeclaration* pointer = NULL;
   92355           5 :      std::vector < unsigned char* > :: const_iterator block;
   92356           5 :      SgClassDeclaration* pointerOfLinkedList = NULL;
   92357           7 :      for ( block = SgClassDeclaration::pools.begin(); block != SgClassDeclaration::pools.end() ; ++block )
   92358             :         {
   92359           2 :           pointer = (SgClassDeclaration*)(*block);
   92360        4002 :           for (unsigned i = 0; i < SgClassDeclaration::pool_size; ++i )
   92361             :              {
   92362             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   92363             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   92364             :             // memory blocks!.
   92365        4000 :                if ( pointer[i].get_freepointer() != NULL )
   92366             :                   {
   92367         371 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   92368             :                   }
   92369             :                else
   92370             :                   {
   92371        3629 :                     if ( pointerOfLinkedList == NULL )
   92372             :                        {
   92373           2 :                          SgClassDeclaration::next_node = &(pointer[i]);
   92374             :                        }
   92375             :                     else
   92376             :                        {
   92377             :                       // printf ("In SgClassDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   92378        3627 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   92379             :                        }
   92380             :                     pointerOfLinkedList = &(pointer[i]);
   92381             :                   }
   92382             :               }
   92383             :         }
   92384             : 
   92385           5 :      if ( pointerOfLinkedList != NULL )
   92386             :         {
   92387             :        // printf ("In SgClassDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   92388           2 :           pointerOfLinkedList->set_freepointer(NULL);
   92389             :        // DQ (6/6/2010): Temporary debugging...
   92390             :        //   ROSE_ASSERT(false);
   92391             :         }
   92392             : 
   92393           5 :      return ;
   92394             :    }
   92395             : 
   92396             : //############################################################################
   92397             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   92398             :  * within the memory pool and resets the freepointers, in order to achieve a 
   92399             :  * linked list, that has no jumps and starts at the beginning! This function 
   92400             :  * does not extend the memory pool, since we do not delete any memory blocks,
   92401             :  * but delete the valid objects.  
   92402             :  */
   92403             : void
   92404           0 : SgClassDeclaration::clearMemoryPool( )
   92405             :    {
   92406             :   // printf ("Inside of SgClassDeclaration::clearMemoryPool() \n");
   92407             : 
   92408           0 :      SgClassDeclaration* pointer = NULL, *tempPointer = NULL;
   92409           0 :      std::vector < unsigned char* > :: const_iterator block;
   92410           0 :      if ( SgClassDeclaration::pools.empty() == false )
   92411             :         {
   92412           0 :           block = SgClassDeclaration::pools.begin() ;
   92413           0 :           SgClassDeclaration::next_node = (SgClassDeclaration*) (*block);
   92414             : 
   92415           0 :           while ( block != SgClassDeclaration::pools.end() )
   92416             :              {
   92417           0 :                pointer = (SgClassDeclaration*) (*block);
   92418           0 :                if ( tempPointer != NULL )
   92419             :                   {
   92420           0 :                     tempPointer->set_freepointer(pointer);
   92421             :                   }
   92422           0 :                for (unsigned i = 0; i < SgClassDeclaration::pool_size - 1; ++i)
   92423             :                   {
   92424           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   92425             :                   }
   92426           0 :                 pointer[SgClassDeclaration::pool_size-1].set_freepointer(NULL);
   92427           0 :                 tempPointer = &(pointer[SgClassDeclaration::pool_size-1]);
   92428           0 :                 ++block;
   92429             :              }
   92430             :         }
   92431           0 :    }
   92432             : 
   92433           5 : void SgClassDeclaration::deleteMemoryPool() {
   92434           9 :   for (auto p: SgClassDeclaration::pools) {
   92435           4 :     ROSE_FREE(p);
   92436             :   }
   92437           5 :   SgClassDeclaration::next_node = nullptr;
   92438           5 :   SgClassDeclaration::pools.clear();
   92439           5 : }
   92440             : 
   92441             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   92442             : //                 reading multiple binary files to for a single AST.
   92443             : /////////// new version ////////////////////////////////
   92444             : //############################################################################
   92445             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   92446             : void
   92447           2 : SgClassDeclaration::extendMemoryPoolForFileIO( )
   92448             :   {
   92449           2 :     size_t blockIndex = SgClassDeclaration::pools.size();
   92450           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDeclaration);
   92451             : 
   92452           4 :     while ( (blockIndex * SgClassDeclaration::pool_size) < newPoolSize)
   92453             :       {
   92454             : #if ROSE_ALLOC_TRACE
   92455             :         if (blockIndex > 0) {
   92456             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDeclaration) = %" PRIuPTR " SgClassDeclaration::pool_size = %d \n",
   92457             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClassDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassDeclaration),SgClassDeclaration::pool_size);
   92458             :         }
   92459             : #endif
   92460             : 
   92461           2 :         SgClassDeclaration * pointer = (SgClassDeclaration*) ROSE_MALLOC ( SgClassDeclaration::pool_size * sizeof(SgClassDeclaration) );
   92462           2 :         assert( pointer != NULL );
   92463             : #if ROSE_ALLOC_MEMSET == 1
   92464             :         memset(pointer, 0x00, SgClassDeclaration::pool_size * sizeof(SgClassDeclaration));
   92465             : #elif ROSE_ALLOC_MEMSET == 2
   92466             :         memset(pointer, 0xCC, SgClassDeclaration::pool_size * sizeof(SgClassDeclaration));
   92467             : #endif
   92468           2 :         SgClassDeclaration::pools.push_back( (unsigned char*)(pointer) );
   92469           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClassDeclaration::pool_size * sizeof(SgClassDeclaration), V_SgClassDeclaration ) );
   92470             : 
   92471           2 :         if ( SgClassDeclaration::next_node != NULL ) {
   92472           0 :           if ( blockIndex > 0 ) {
   92473           0 :             SgClassDeclaration * blkptr = (SgClassDeclaration*)(SgClassDeclaration::pools[blockIndex-1]);
   92474           0 :             blkptr[ SgClassDeclaration::pool_size - 1 ].set_freepointer(pointer);
   92475             :           }
   92476             :         } else {
   92477           2 :           SgClassDeclaration::next_node = pointer;
   92478             :         }
   92479             : 
   92480        4000 :         for (unsigned i = 0; i < SgClassDeclaration::pool_size-1; ++i)
   92481             :            {
   92482        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   92483             :            }
   92484           2 :         pointer[ SgClassDeclaration::pool_size -1 ].set_freepointer(NULL);
   92485             : 
   92486           2 :         blockIndex++;
   92487             :       }
   92488           2 :   }
   92489             : 
   92490             : //############################################################################
   92491             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   92492             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   92493             :  * not compressed. However, that stuff is not yet implemented! 
   92494             :  */
   92495             : unsigned long
   92496           0 : SgClassDeclaration::getNumberOfLastValidPointer()
   92497             :    {
   92498           0 :       SgClassDeclaration* testPointer = (SgClassDeclaration*)(SgClassDeclaration::pools.back());
   92499           0 :       unsigned long localIndex = SgClassDeclaration::pool_size - 1;
   92500           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   92501             :          {
   92502           0 :            localIndex--;
   92503             :          }
   92504           0 :       return (localIndex + SgClassDeclaration::pool_size * (SgClassDeclaration::pools.size()-1));
   92505             :    }
   92506             : 
   92507             : //############################################################################
   92508             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   92509             :  * memory pool and initializes the data member in class SgClassDeclarationStroageClass
   92510             :  * from its counterpart of SgClassDeclaration. The return value is just for checking, 
   92511             :  * that the whole StorageClassArray is initialized!
   92512             :  */
   92513             : unsigned long
   92514           2 : SgClassDeclaration::initializeStorageClassArray( SgClassDeclarationStorageClass *storageArray )
   92515             :    {
   92516           2 :      unsigned long storageCounter = 0;
   92517           2 :      std::vector < unsigned char* > :: const_iterator block = SgClassDeclaration::pools.begin();
   92518           2 :      SgClassDeclaration* pointer = NULL;
   92519           4 :      while ( block != SgClassDeclaration::pools.end() ) {
   92520           2 :           pointer = (SgClassDeclaration*) (*block);
   92521        4002 :           for ( unsigned i = 0; i < SgClassDeclaration::pool_size; ++i ) {
   92522        4000 :                if ( pointer->get_freepointer() != NULL ) {
   92523         371 :                  storageArray->pickOutIRNodeData (pointer) ;
   92524         371 :                  storageArray++;
   92525         371 :                  storageCounter++;
   92526             :                }
   92527        4000 :                pointer++;
   92528             :              }
   92529           2 :            block++;
   92530             :         }
   92531           2 :      return storageCounter;
   92532             :    }
   92533             : 
   92534             : /* #line 92535 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   92535             : 
   92536             : 
   92537             : 
   92538             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   92539             : 
   92540             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   92541             : 
   92542             : //############################################################################
   92543             : /* JH (02/02/2006) Constructor of the IR node SgTemplateClassDeclaration that takes its 
   92544             :  * corresponding StorageClass as parameter
   92545             :  */
   92546        1090 : SgTemplateClassDeclaration :: SgTemplateClassDeclaration ( const SgTemplateClassDeclarationStorageClass& storageSource )   : SgClassDeclaration (storageSource)
   92547             :    {
   92548             : 
   92549             : 
   92550             : /* #line 92551 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   92551             : 
   92552        1090 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   92553        1090 :      p_templateParameters = storageSource.storageOf_templateParameters.rebuildDataStoredInEasyStorageClass() ;
   92554        1090 :      SgTemplateParameterPtrList::iterator i_templateParameters = p_templateParameters.begin() ; 
   92555        2771 :      for ( ; i_templateParameters != p_templateParameters.end(); ++i_templateParameters ) 
   92556             :         {
   92557        1681 :           (*i_templateParameters) = (SgTemplateParameterPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateParameters) ) );
   92558             :         }
   92559        1090 :      p_templateSpecializationArguments = storageSource.storageOf_templateSpecializationArguments.rebuildDataStoredInEasyStorageClass() ;
   92560        1090 :      SgTemplateArgumentPtrList::iterator i_templateSpecializationArguments = p_templateSpecializationArguments.begin() ; 
   92561        1862 :      for ( ; i_templateSpecializationArguments != p_templateSpecializationArguments.end(); ++i_templateSpecializationArguments ) 
   92562             :         {
   92563         772 :           (*i_templateSpecializationArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateSpecializationArguments) ) );
   92564             :         }
   92565        1090 :      p_string = SgName ( storageSource.storageOf_string ) ;
   92566        1090 :      p_templateName = SgName ( storageSource.storageOf_templateName ) ;
   92567        1090 :      p_nonreal_decl_scope =  (SgDeclarationScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nonreal_decl_scope) );
   92568             : 
   92569             : 
   92570             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   92571             : 
   92572             : 
   92573        1090 :    }
   92574             : 
   92575             : //############################################################################
   92576             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   92577             :  * within the working AST. 
   92578             :  */
   92579       12056 : SgTemplateClassDeclaration * SgTemplateClassDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   92580       12056 :      SgTemplateClassDeclaration* returnPointer = NULL;
   92581       12056 :      if ( globalIndex != 0 )
   92582             :         {
   92583             : 
   92584             : #if FILE_IO_EXTRA_CHECK
   92585       12056 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateClassDeclaration ) ) <= globalIndex ) ;
   92586       12056 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateClassDeclaration + 1 ) ) );
   92587             : #endif
   92588       12056 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateClassDeclaration )  
   92589       12056 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateClassDeclaration );
   92590       12056 :           unsigned long positionInPool = localIndex % SgTemplateClassDeclaration::pool_size;
   92591       12056 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateClassDeclaration::pool_size;
   92592             : 
   92593             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   92594             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   92595             : 
   92596       12056 :           returnPointer = &( ( (SgTemplateClassDeclaration*)(SgTemplateClassDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   92597             : 
   92598       12056 :           ROSE_ASSERT( returnPointer != NULL ) ;
   92599             :         }
   92600       12056 :      return returnPointer ;
   92601             :    }
   92602             : 
   92603             : //############################################################################
   92604             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   92605             :   for the AST with the index astIndex
   92606             : */
   92607           0 : SgTemplateClassDeclaration * SgTemplateClassDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   92608           0 :      SgTemplateClassDeclaration* returnPointer = NULL;
   92609           0 :      if ( globalIndex != 0 )
   92610             :         {
   92611             : 
   92612             : #if FILE_IO_EXTRA_CHECK
   92613           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateClassDeclaration ) ) <= globalIndex ) ;
   92614           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateClassDeclaration + 1 ) ) );
   92615             : #endif
   92616           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateClassDeclaration )
   92617           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateClassDeclaration );
   92618           0 :           unsigned long positionInPool = localIndex % SgTemplateClassDeclaration::pool_size ;
   92619           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateClassDeclaration::pool_size ;
   92620             : 
   92621             : #if FILE_IO_EXTRA_CHECK
   92622             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   92623             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   92624             : #endif
   92625             : 
   92626           0 :           returnPointer = &( ( (SgTemplateClassDeclaration*)(SgTemplateClassDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   92627             : 
   92628             : #if FILE_IO_EXTRA_CHECK
   92629           0 :           assert ( returnPointer != NULL ) ;
   92630             : #endif
   92631             :         }
   92632           0 :      return returnPointer ;
   92633             :    }
   92634             : 
   92635             : //############################################################################
   92636             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   92637             :  * pool size! We set for every valid object in the memory pool the freepointer
   92638             :  * to the global index and increase the global index afterwards. For all the 
   92639             :  * invalid objects (means address ranges within the memory pool that were not
   92640             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   92641             :  * distinguish valid from invalid objects! 
   92642             :  */
   92643             : unsigned long
   92644           5 : SgTemplateClassDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   92645             :    {
   92646           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   92647           5 :      SgTemplateClassDeclaration* pointer = NULL;
   92648           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   92649           5 :      std::vector < unsigned char* > :: const_iterator block;
   92650           6 :      for ( block = SgTemplateClassDeclaration::pools.begin(); block != SgTemplateClassDeclaration::pools.end() ; ++block )
   92651             :         {
   92652           1 :           pointer = (SgTemplateClassDeclaration*)(*block);
   92653        2001 :           for (unsigned i = 0; i < SgTemplateClassDeclaration::pool_size; ++i )
   92654             :              {
   92655             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   92656             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   92657             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   92658             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   92659             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   92660             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   92661             :             // properly; so this will have to be checked next.
   92662             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   92663             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   92664        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   92665             :                   {
   92666        1090 :                     pointer[i].set_freepointer((SgTemplateClassDeclaration*)(globalIndex));
   92667        1090 :                     globalIndex++;
   92668             :                   }
   92669             :                else
   92670             :                   {
   92671         910 :                     pointer[i].set_freepointer(NULL);
   92672             :                   }
   92673             :               }
   92674             :         }
   92675           5 :      return globalIndex;
   92676             :    }
   92677             : 
   92678             : //############################################################################
   92679             : // JH (01/14/2006)
   92680             : void
   92681           5 : SgTemplateClassDeclaration::resetValidFreepointers( )
   92682             :    {
   92683           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   92684           5 :      SgTemplateClassDeclaration* pointer = NULL;
   92685           5 :      std::vector < unsigned char* > :: const_iterator block;
   92686           5 :      SgTemplateClassDeclaration* pointerOfLinkedList = NULL;
   92687           6 :      for ( block = SgTemplateClassDeclaration::pools.begin(); block != SgTemplateClassDeclaration::pools.end() ; ++block )
   92688             :         {
   92689           1 :           pointer = (SgTemplateClassDeclaration*)(*block);
   92690        2001 :           for (unsigned i = 0; i < SgTemplateClassDeclaration::pool_size; ++i )
   92691             :              {
   92692             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   92693             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   92694             :             // memory blocks!.
   92695        2000 :                if ( pointer[i].get_freepointer() != NULL )
   92696             :                   {
   92697        1090 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   92698             :                   }
   92699             :                else
   92700             :                   {
   92701         910 :                     if ( pointerOfLinkedList == NULL )
   92702             :                        {
   92703           1 :                          SgTemplateClassDeclaration::next_node = &(pointer[i]);
   92704             :                        }
   92705             :                     else
   92706             :                        {
   92707             :                       // printf ("In SgTemplateClassDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   92708         909 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   92709             :                        }
   92710             :                     pointerOfLinkedList = &(pointer[i]);
   92711             :                   }
   92712             :               }
   92713             :         }
   92714             : 
   92715           5 :      if ( pointerOfLinkedList != NULL )
   92716             :         {
   92717             :        // printf ("In SgTemplateClassDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   92718           1 :           pointerOfLinkedList->set_freepointer(NULL);
   92719             :        // DQ (6/6/2010): Temporary debugging...
   92720             :        //   ROSE_ASSERT(false);
   92721             :         }
   92722             : 
   92723           5 :      return ;
   92724             :    }
   92725             : 
   92726             : //############################################################################
   92727             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   92728             :  * within the memory pool and resets the freepointers, in order to achieve a 
   92729             :  * linked list, that has no jumps and starts at the beginning! This function 
   92730             :  * does not extend the memory pool, since we do not delete any memory blocks,
   92731             :  * but delete the valid objects.  
   92732             :  */
   92733             : void
   92734           0 : SgTemplateClassDeclaration::clearMemoryPool( )
   92735             :    {
   92736             :   // printf ("Inside of SgTemplateClassDeclaration::clearMemoryPool() \n");
   92737             : 
   92738           0 :      SgTemplateClassDeclaration* pointer = NULL, *tempPointer = NULL;
   92739           0 :      std::vector < unsigned char* > :: const_iterator block;
   92740           0 :      if ( SgTemplateClassDeclaration::pools.empty() == false )
   92741             :         {
   92742           0 :           block = SgTemplateClassDeclaration::pools.begin() ;
   92743           0 :           SgTemplateClassDeclaration::next_node = (SgTemplateClassDeclaration*) (*block);
   92744             : 
   92745           0 :           while ( block != SgTemplateClassDeclaration::pools.end() )
   92746             :              {
   92747           0 :                pointer = (SgTemplateClassDeclaration*) (*block);
   92748           0 :                if ( tempPointer != NULL )
   92749             :                   {
   92750           0 :                     tempPointer->set_freepointer(pointer);
   92751             :                   }
   92752           0 :                for (unsigned i = 0; i < SgTemplateClassDeclaration::pool_size - 1; ++i)
   92753             :                   {
   92754           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   92755             :                   }
   92756           0 :                 pointer[SgTemplateClassDeclaration::pool_size-1].set_freepointer(NULL);
   92757           0 :                 tempPointer = &(pointer[SgTemplateClassDeclaration::pool_size-1]);
   92758           0 :                 ++block;
   92759             :              }
   92760             :         }
   92761           0 :    }
   92762             : 
   92763           5 : void SgTemplateClassDeclaration::deleteMemoryPool() {
   92764           7 :   for (auto p: SgTemplateClassDeclaration::pools) {
   92765           2 :     ROSE_FREE(p);
   92766             :   }
   92767           5 :   SgTemplateClassDeclaration::next_node = nullptr;
   92768           5 :   SgTemplateClassDeclaration::pools.clear();
   92769           5 : }
   92770             : 
   92771             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   92772             : //                 reading multiple binary files to for a single AST.
   92773             : /////////// new version ////////////////////////////////
   92774             : //############################################################################
   92775             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   92776             : void
   92777           2 : SgTemplateClassDeclaration::extendMemoryPoolForFileIO( )
   92778             :   {
   92779           2 :     size_t blockIndex = SgTemplateClassDeclaration::pools.size();
   92780           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassDeclaration);
   92781             : 
   92782           3 :     while ( (blockIndex * SgTemplateClassDeclaration::pool_size) < newPoolSize)
   92783             :       {
   92784             : #if ROSE_ALLOC_TRACE
   92785             :         if (blockIndex > 0) {
   92786             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassDeclaration) = %" PRIuPTR " SgTemplateClassDeclaration::pool_size = %d \n",
   92787             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassDeclaration),SgTemplateClassDeclaration::pool_size);
   92788             :         }
   92789             : #endif
   92790             : 
   92791           1 :         SgTemplateClassDeclaration * pointer = (SgTemplateClassDeclaration*) ROSE_MALLOC ( SgTemplateClassDeclaration::pool_size * sizeof(SgTemplateClassDeclaration) );
   92792           1 :         assert( pointer != NULL );
   92793             : #if ROSE_ALLOC_MEMSET == 1
   92794             :         memset(pointer, 0x00, SgTemplateClassDeclaration::pool_size * sizeof(SgTemplateClassDeclaration));
   92795             : #elif ROSE_ALLOC_MEMSET == 2
   92796             :         memset(pointer, 0xCC, SgTemplateClassDeclaration::pool_size * sizeof(SgTemplateClassDeclaration));
   92797             : #endif
   92798           1 :         SgTemplateClassDeclaration::pools.push_back( (unsigned char*)(pointer) );
   92799           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateClassDeclaration::pool_size * sizeof(SgTemplateClassDeclaration), V_SgTemplateClassDeclaration ) );
   92800             : 
   92801           1 :         if ( SgTemplateClassDeclaration::next_node != NULL ) {
   92802           0 :           if ( blockIndex > 0 ) {
   92803           0 :             SgTemplateClassDeclaration * blkptr = (SgTemplateClassDeclaration*)(SgTemplateClassDeclaration::pools[blockIndex-1]);
   92804           0 :             blkptr[ SgTemplateClassDeclaration::pool_size - 1 ].set_freepointer(pointer);
   92805             :           }
   92806             :         } else {
   92807           1 :           SgTemplateClassDeclaration::next_node = pointer;
   92808             :         }
   92809             : 
   92810        2000 :         for (unsigned i = 0; i < SgTemplateClassDeclaration::pool_size-1; ++i)
   92811             :            {
   92812        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   92813             :            }
   92814           1 :         pointer[ SgTemplateClassDeclaration::pool_size -1 ].set_freepointer(NULL);
   92815             : 
   92816           1 :         blockIndex++;
   92817             :       }
   92818           2 :   }
   92819             : 
   92820             : //############################################################################
   92821             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   92822             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   92823             :  * not compressed. However, that stuff is not yet implemented! 
   92824             :  */
   92825             : unsigned long
   92826           0 : SgTemplateClassDeclaration::getNumberOfLastValidPointer()
   92827             :    {
   92828           0 :       SgTemplateClassDeclaration* testPointer = (SgTemplateClassDeclaration*)(SgTemplateClassDeclaration::pools.back());
   92829           0 :       unsigned long localIndex = SgTemplateClassDeclaration::pool_size - 1;
   92830           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   92831             :          {
   92832           0 :            localIndex--;
   92833             :          }
   92834           0 :       return (localIndex + SgTemplateClassDeclaration::pool_size * (SgTemplateClassDeclaration::pools.size()-1));
   92835             :    }
   92836             : 
   92837             : //############################################################################
   92838             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   92839             :  * memory pool and initializes the data member in class SgTemplateClassDeclarationStroageClass
   92840             :  * from its counterpart of SgTemplateClassDeclaration. The return value is just for checking, 
   92841             :  * that the whole StorageClassArray is initialized!
   92842             :  */
   92843             : unsigned long
   92844           1 : SgTemplateClassDeclaration::initializeStorageClassArray( SgTemplateClassDeclarationStorageClass *storageArray )
   92845             :    {
   92846           1 :      unsigned long storageCounter = 0;
   92847           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateClassDeclaration::pools.begin();
   92848           1 :      SgTemplateClassDeclaration* pointer = NULL;
   92849           2 :      while ( block != SgTemplateClassDeclaration::pools.end() ) {
   92850           1 :           pointer = (SgTemplateClassDeclaration*) (*block);
   92851        2001 :           for ( unsigned i = 0; i < SgTemplateClassDeclaration::pool_size; ++i ) {
   92852        2000 :                if ( pointer->get_freepointer() != NULL ) {
   92853        1090 :                  storageArray->pickOutIRNodeData (pointer) ;
   92854        1090 :                  storageArray++;
   92855        1090 :                  storageCounter++;
   92856             :                }
   92857        2000 :                pointer++;
   92858             :              }
   92859           1 :            block++;
   92860             :         }
   92861           1 :      return storageCounter;
   92862             :    }
   92863             : 
   92864             : /* #line 92865 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   92865             : 
   92866             : 
   92867             : 
   92868             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   92869             : 
   92870             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   92871             : 
   92872             : //############################################################################
   92873             : /* JH (02/02/2006) Constructor of the IR node SgTemplateInstantiationDecl that takes its 
   92874             :  * corresponding StorageClass as parameter
   92875             :  */
   92876        1319 : SgTemplateInstantiationDecl :: SgTemplateInstantiationDecl ( const SgTemplateInstantiationDeclStorageClass& storageSource )   : SgClassDeclaration (storageSource)
   92877             :    {
   92878             : 
   92879             : 
   92880             : /* #line 92881 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   92881             : 
   92882        1319 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   92883        1319 :      p_templateName = SgName ( storageSource.storageOf_templateName ) ;
   92884        1319 :      p_templateHeader = SgName ( storageSource.storageOf_templateHeader ) ;
   92885        1319 :      p_templateDeclaration =  (SgTemplateClassDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_templateDeclaration) );
   92886        1319 :      p_templateArguments = storageSource.storageOf_templateArguments.rebuildDataStoredInEasyStorageClass() ;
   92887        1319 :      SgTemplateArgumentPtrList::iterator i_templateArguments = p_templateArguments.begin() ; 
   92888        3387 :      for ( ; i_templateArguments != p_templateArguments.end(); ++i_templateArguments ) 
   92889             :         {
   92890        2068 :           (*i_templateArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateArguments) ) );
   92891             :         }
   92892        1319 :      p_nameResetFromMangledForm = storageSource.storageOf_nameResetFromMangledForm ;
   92893             : 
   92894             : 
   92895             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   92896             : 
   92897             : 
   92898        1319 :    }
   92899             : 
   92900             : //############################################################################
   92901             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   92902             :  * within the working AST. 
   92903             :  */
   92904       10595 : SgTemplateInstantiationDecl * SgTemplateInstantiationDecl::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   92905       10595 :      SgTemplateInstantiationDecl* returnPointer = NULL;
   92906       10595 :      if ( globalIndex != 0 )
   92907             :         {
   92908             : 
   92909             : #if FILE_IO_EXTRA_CHECK
   92910       10595 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateInstantiationDecl ) ) <= globalIndex ) ;
   92911       10595 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationDecl + 1 ) ) );
   92912             : #endif
   92913       10595 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationDecl )  
   92914       10595 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateInstantiationDecl );
   92915       10595 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationDecl::pool_size;
   92916       10595 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationDecl::pool_size;
   92917             : 
   92918             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   92919             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   92920             : 
   92921       10595 :           returnPointer = &( ( (SgTemplateInstantiationDecl*)(SgTemplateInstantiationDecl::pools[memoryBlock]) ) [positionInPool]) ;
   92922             : 
   92923       10595 :           ROSE_ASSERT( returnPointer != NULL ) ;
   92924             :         }
   92925       10595 :      return returnPointer ;
   92926             :    }
   92927             : 
   92928             : //############################################################################
   92929             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   92930             :   for the AST with the index astIndex
   92931             : */
   92932           0 : SgTemplateInstantiationDecl * SgTemplateInstantiationDecl::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   92933           0 :      SgTemplateInstantiationDecl* returnPointer = NULL;
   92934           0 :      if ( globalIndex != 0 )
   92935             :         {
   92936             : 
   92937             : #if FILE_IO_EXTRA_CHECK
   92938           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateInstantiationDecl ) ) <= globalIndex ) ;
   92939           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationDecl + 1 ) ) );
   92940             : #endif
   92941           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationDecl )
   92942           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateInstantiationDecl );
   92943           0 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationDecl::pool_size ;
   92944           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationDecl::pool_size ;
   92945             : 
   92946             : #if FILE_IO_EXTRA_CHECK
   92947             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   92948             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   92949             : #endif
   92950             : 
   92951           0 :           returnPointer = &( ( (SgTemplateInstantiationDecl*)(SgTemplateInstantiationDecl::pools[memoryBlock]) ) [positionInPool]) ;
   92952             : 
   92953             : #if FILE_IO_EXTRA_CHECK
   92954           0 :           assert ( returnPointer != NULL ) ;
   92955             : #endif
   92956             :         }
   92957           0 :      return returnPointer ;
   92958             :    }
   92959             : 
   92960             : //############################################################################
   92961             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   92962             :  * pool size! We set for every valid object in the memory pool the freepointer
   92963             :  * to the global index and increase the global index afterwards. For all the 
   92964             :  * invalid objects (means address ranges within the memory pool that were not
   92965             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   92966             :  * distinguish valid from invalid objects! 
   92967             :  */
   92968             : unsigned long
   92969           5 : SgTemplateInstantiationDecl::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   92970             :    {
   92971           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   92972           5 :      SgTemplateInstantiationDecl* pointer = NULL;
   92973           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   92974           5 :      std::vector < unsigned char* > :: const_iterator block;
   92975           6 :      for ( block = SgTemplateInstantiationDecl::pools.begin(); block != SgTemplateInstantiationDecl::pools.end() ; ++block )
   92976             :         {
   92977           1 :           pointer = (SgTemplateInstantiationDecl*)(*block);
   92978        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationDecl::pool_size; ++i )
   92979             :              {
   92980             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   92981             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   92982             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   92983             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   92984             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   92985             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   92986             :             // properly; so this will have to be checked next.
   92987             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   92988             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   92989        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   92990             :                   {
   92991        1319 :                     pointer[i].set_freepointer((SgTemplateInstantiationDecl*)(globalIndex));
   92992        1319 :                     globalIndex++;
   92993             :                   }
   92994             :                else
   92995             :                   {
   92996         681 :                     pointer[i].set_freepointer(NULL);
   92997             :                   }
   92998             :               }
   92999             :         }
   93000           5 :      return globalIndex;
   93001             :    }
   93002             : 
   93003             : //############################################################################
   93004             : // JH (01/14/2006)
   93005             : void
   93006           5 : SgTemplateInstantiationDecl::resetValidFreepointers( )
   93007             :    {
   93008           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   93009           5 :      SgTemplateInstantiationDecl* pointer = NULL;
   93010           5 :      std::vector < unsigned char* > :: const_iterator block;
   93011           5 :      SgTemplateInstantiationDecl* pointerOfLinkedList = NULL;
   93012           6 :      for ( block = SgTemplateInstantiationDecl::pools.begin(); block != SgTemplateInstantiationDecl::pools.end() ; ++block )
   93013             :         {
   93014           1 :           pointer = (SgTemplateInstantiationDecl*)(*block);
   93015        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationDecl::pool_size; ++i )
   93016             :              {
   93017             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   93018             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   93019             :             // memory blocks!.
   93020        2000 :                if ( pointer[i].get_freepointer() != NULL )
   93021             :                   {
   93022        1319 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   93023             :                   }
   93024             :                else
   93025             :                   {
   93026         681 :                     if ( pointerOfLinkedList == NULL )
   93027             :                        {
   93028           1 :                          SgTemplateInstantiationDecl::next_node = &(pointer[i]);
   93029             :                        }
   93030             :                     else
   93031             :                        {
   93032             :                       // printf ("In SgTemplateInstantiationDecl::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   93033         680 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   93034             :                        }
   93035             :                     pointerOfLinkedList = &(pointer[i]);
   93036             :                   }
   93037             :               }
   93038             :         }
   93039             : 
   93040           5 :      if ( pointerOfLinkedList != NULL )
   93041             :         {
   93042             :        // printf ("In SgTemplateInstantiationDecl::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   93043           1 :           pointerOfLinkedList->set_freepointer(NULL);
   93044             :        // DQ (6/6/2010): Temporary debugging...
   93045             :        //   ROSE_ASSERT(false);
   93046             :         }
   93047             : 
   93048           5 :      return ;
   93049             :    }
   93050             : 
   93051             : //############################################################################
   93052             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   93053             :  * within the memory pool and resets the freepointers, in order to achieve a 
   93054             :  * linked list, that has no jumps and starts at the beginning! This function 
   93055             :  * does not extend the memory pool, since we do not delete any memory blocks,
   93056             :  * but delete the valid objects.  
   93057             :  */
   93058             : void
   93059           0 : SgTemplateInstantiationDecl::clearMemoryPool( )
   93060             :    {
   93061             :   // printf ("Inside of SgTemplateInstantiationDecl::clearMemoryPool() \n");
   93062             : 
   93063           0 :      SgTemplateInstantiationDecl* pointer = NULL, *tempPointer = NULL;
   93064           0 :      std::vector < unsigned char* > :: const_iterator block;
   93065           0 :      if ( SgTemplateInstantiationDecl::pools.empty() == false )
   93066             :         {
   93067           0 :           block = SgTemplateInstantiationDecl::pools.begin() ;
   93068           0 :           SgTemplateInstantiationDecl::next_node = (SgTemplateInstantiationDecl*) (*block);
   93069             : 
   93070           0 :           while ( block != SgTemplateInstantiationDecl::pools.end() )
   93071             :              {
   93072           0 :                pointer = (SgTemplateInstantiationDecl*) (*block);
   93073           0 :                if ( tempPointer != NULL )
   93074             :                   {
   93075           0 :                     tempPointer->set_freepointer(pointer);
   93076             :                   }
   93077           0 :                for (unsigned i = 0; i < SgTemplateInstantiationDecl::pool_size - 1; ++i)
   93078             :                   {
   93079           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   93080             :                   }
   93081           0 :                 pointer[SgTemplateInstantiationDecl::pool_size-1].set_freepointer(NULL);
   93082           0 :                 tempPointer = &(pointer[SgTemplateInstantiationDecl::pool_size-1]);
   93083           0 :                 ++block;
   93084             :              }
   93085             :         }
   93086           0 :    }
   93087             : 
   93088           5 : void SgTemplateInstantiationDecl::deleteMemoryPool() {
   93089           7 :   for (auto p: SgTemplateInstantiationDecl::pools) {
   93090           2 :     ROSE_FREE(p);
   93091             :   }
   93092           5 :   SgTemplateInstantiationDecl::next_node = nullptr;
   93093           5 :   SgTemplateInstantiationDecl::pools.clear();
   93094           5 : }
   93095             : 
   93096             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   93097             : //                 reading multiple binary files to for a single AST.
   93098             : /////////// new version ////////////////////////////////
   93099             : //############################################################################
   93100             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   93101             : void
   93102           2 : SgTemplateInstantiationDecl::extendMemoryPoolForFileIO( )
   93103             :   {
   93104           2 :     size_t blockIndex = SgTemplateInstantiationDecl::pools.size();
   93105           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDecl) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDecl);
   93106             : 
   93107           3 :     while ( (blockIndex * SgTemplateInstantiationDecl::pool_size) < newPoolSize)
   93108             :       {
   93109             : #if ROSE_ALLOC_TRACE
   93110             :         if (blockIndex > 0) {
   93111             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDecl) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDecl) = %" PRIuPTR " SgTemplateInstantiationDecl::pool_size = %d \n",
   93112             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationDecl),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationDecl),SgTemplateInstantiationDecl::pool_size);
   93113             :         }
   93114             : #endif
   93115             : 
   93116           1 :         SgTemplateInstantiationDecl * pointer = (SgTemplateInstantiationDecl*) ROSE_MALLOC ( SgTemplateInstantiationDecl::pool_size * sizeof(SgTemplateInstantiationDecl) );
   93117           1 :         assert( pointer != NULL );
   93118             : #if ROSE_ALLOC_MEMSET == 1
   93119             :         memset(pointer, 0x00, SgTemplateInstantiationDecl::pool_size * sizeof(SgTemplateInstantiationDecl));
   93120             : #elif ROSE_ALLOC_MEMSET == 2
   93121             :         memset(pointer, 0xCC, SgTemplateInstantiationDecl::pool_size * sizeof(SgTemplateInstantiationDecl));
   93122             : #endif
   93123           1 :         SgTemplateInstantiationDecl::pools.push_back( (unsigned char*)(pointer) );
   93124           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateInstantiationDecl::pool_size * sizeof(SgTemplateInstantiationDecl), V_SgTemplateInstantiationDecl ) );
   93125             : 
   93126           1 :         if ( SgTemplateInstantiationDecl::next_node != NULL ) {
   93127           0 :           if ( blockIndex > 0 ) {
   93128           0 :             SgTemplateInstantiationDecl * blkptr = (SgTemplateInstantiationDecl*)(SgTemplateInstantiationDecl::pools[blockIndex-1]);
   93129           0 :             blkptr[ SgTemplateInstantiationDecl::pool_size - 1 ].set_freepointer(pointer);
   93130             :           }
   93131             :         } else {
   93132           1 :           SgTemplateInstantiationDecl::next_node = pointer;
   93133             :         }
   93134             : 
   93135        2000 :         for (unsigned i = 0; i < SgTemplateInstantiationDecl::pool_size-1; ++i)
   93136             :            {
   93137        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   93138             :            }
   93139           1 :         pointer[ SgTemplateInstantiationDecl::pool_size -1 ].set_freepointer(NULL);
   93140             : 
   93141           1 :         blockIndex++;
   93142             :       }
   93143           2 :   }
   93144             : 
   93145             : //############################################################################
   93146             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   93147             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   93148             :  * not compressed. However, that stuff is not yet implemented! 
   93149             :  */
   93150             : unsigned long
   93151           0 : SgTemplateInstantiationDecl::getNumberOfLastValidPointer()
   93152             :    {
   93153           0 :       SgTemplateInstantiationDecl* testPointer = (SgTemplateInstantiationDecl*)(SgTemplateInstantiationDecl::pools.back());
   93154           0 :       unsigned long localIndex = SgTemplateInstantiationDecl::pool_size - 1;
   93155           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   93156             :          {
   93157           0 :            localIndex--;
   93158             :          }
   93159           0 :       return (localIndex + SgTemplateInstantiationDecl::pool_size * (SgTemplateInstantiationDecl::pools.size()-1));
   93160             :    }
   93161             : 
   93162             : //############################################################################
   93163             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   93164             :  * memory pool and initializes the data member in class SgTemplateInstantiationDeclStroageClass
   93165             :  * from its counterpart of SgTemplateInstantiationDecl. The return value is just for checking, 
   93166             :  * that the whole StorageClassArray is initialized!
   93167             :  */
   93168             : unsigned long
   93169           1 : SgTemplateInstantiationDecl::initializeStorageClassArray( SgTemplateInstantiationDeclStorageClass *storageArray )
   93170             :    {
   93171           1 :      unsigned long storageCounter = 0;
   93172           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateInstantiationDecl::pools.begin();
   93173           1 :      SgTemplateInstantiationDecl* pointer = NULL;
   93174           2 :      while ( block != SgTemplateInstantiationDecl::pools.end() ) {
   93175           1 :           pointer = (SgTemplateInstantiationDecl*) (*block);
   93176        2001 :           for ( unsigned i = 0; i < SgTemplateInstantiationDecl::pool_size; ++i ) {
   93177        2000 :                if ( pointer->get_freepointer() != NULL ) {
   93178        1319 :                  storageArray->pickOutIRNodeData (pointer) ;
   93179        1319 :                  storageArray++;
   93180        1319 :                  storageCounter++;
   93181             :                }
   93182        2000 :                pointer++;
   93183             :              }
   93184           1 :            block++;
   93185             :         }
   93186           1 :      return storageCounter;
   93187             :    }
   93188             : 
   93189             : /* #line 93190 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   93190             : 
   93191             : 
   93192             : 
   93193             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   93194             : 
   93195             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   93196             : 
   93197             : //############################################################################
   93198             : /* JH (02/02/2006) Constructor of the IR node SgDerivedTypeStatement that takes its 
   93199             :  * corresponding StorageClass as parameter
   93200             :  */
   93201           0 : SgDerivedTypeStatement :: SgDerivedTypeStatement ( const SgDerivedTypeStatementStorageClass& storageSource )   : SgClassDeclaration (storageSource)
   93202             :    {
   93203             : 
   93204             : 
   93205             : /* #line 93206 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   93206             : 
   93207           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   93208           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   93209             : 
   93210             : 
   93211             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   93212             : 
   93213             : 
   93214           0 :    }
   93215             : 
   93216             : //############################################################################
   93217             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   93218             :  * within the working AST. 
   93219             :  */
   93220           0 : SgDerivedTypeStatement * SgDerivedTypeStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   93221           0 :      SgDerivedTypeStatement* returnPointer = NULL;
   93222           0 :      if ( globalIndex != 0 )
   93223             :         {
   93224             : 
   93225             : #if FILE_IO_EXTRA_CHECK
   93226           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDerivedTypeStatement ) ) <= globalIndex ) ;
   93227           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDerivedTypeStatement + 1 ) ) );
   93228             : #endif
   93229           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDerivedTypeStatement )  
   93230           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDerivedTypeStatement );
   93231           0 :           unsigned long positionInPool = localIndex % SgDerivedTypeStatement::pool_size;
   93232           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDerivedTypeStatement::pool_size;
   93233             : 
   93234             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   93235             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   93236             : 
   93237           0 :           returnPointer = &( ( (SgDerivedTypeStatement*)(SgDerivedTypeStatement::pools[memoryBlock]) ) [positionInPool]) ;
   93238             : 
   93239           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   93240             :         }
   93241           0 :      return returnPointer ;
   93242             :    }
   93243             : 
   93244             : //############################################################################
   93245             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   93246             :   for the AST with the index astIndex
   93247             : */
   93248           0 : SgDerivedTypeStatement * SgDerivedTypeStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   93249           0 :      SgDerivedTypeStatement* returnPointer = NULL;
   93250           0 :      if ( globalIndex != 0 )
   93251             :         {
   93252             : 
   93253             : #if FILE_IO_EXTRA_CHECK
   93254           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDerivedTypeStatement ) ) <= globalIndex ) ;
   93255           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDerivedTypeStatement + 1 ) ) );
   93256             : #endif
   93257           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDerivedTypeStatement )
   93258           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDerivedTypeStatement );
   93259           0 :           unsigned long positionInPool = localIndex % SgDerivedTypeStatement::pool_size ;
   93260           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDerivedTypeStatement::pool_size ;
   93261             : 
   93262             : #if FILE_IO_EXTRA_CHECK
   93263             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   93264             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   93265             : #endif
   93266             : 
   93267           0 :           returnPointer = &( ( (SgDerivedTypeStatement*)(SgDerivedTypeStatement::pools[memoryBlock]) ) [positionInPool]) ;
   93268             : 
   93269             : #if FILE_IO_EXTRA_CHECK
   93270           0 :           assert ( returnPointer != NULL ) ;
   93271             : #endif
   93272             :         }
   93273           0 :      return returnPointer ;
   93274             :    }
   93275             : 
   93276             : //############################################################################
   93277             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   93278             :  * pool size! We set for every valid object in the memory pool the freepointer
   93279             :  * to the global index and increase the global index afterwards. For all the 
   93280             :  * invalid objects (means address ranges within the memory pool that were not
   93281             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   93282             :  * distinguish valid from invalid objects! 
   93283             :  */
   93284             : unsigned long
   93285           5 : SgDerivedTypeStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   93286             :    {
   93287           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   93288           5 :      SgDerivedTypeStatement* pointer = NULL;
   93289           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   93290           5 :      std::vector < unsigned char* > :: const_iterator block;
   93291           5 :      for ( block = SgDerivedTypeStatement::pools.begin(); block != SgDerivedTypeStatement::pools.end() ; ++block )
   93292             :         {
   93293           0 :           pointer = (SgDerivedTypeStatement*)(*block);
   93294           0 :           for (unsigned i = 0; i < SgDerivedTypeStatement::pool_size; ++i )
   93295             :              {
   93296             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   93297             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   93298             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   93299             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   93300             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   93301             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   93302             :             // properly; so this will have to be checked next.
   93303             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   93304             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   93305           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   93306             :                   {
   93307           0 :                     pointer[i].set_freepointer((SgDerivedTypeStatement*)(globalIndex));
   93308           0 :                     globalIndex++;
   93309             :                   }
   93310             :                else
   93311             :                   {
   93312           0 :                     pointer[i].set_freepointer(NULL);
   93313             :                   }
   93314             :               }
   93315             :         }
   93316           5 :      return globalIndex;
   93317             :    }
   93318             : 
   93319             : //############################################################################
   93320             : // JH (01/14/2006)
   93321             : void
   93322           5 : SgDerivedTypeStatement::resetValidFreepointers( )
   93323             :    {
   93324           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   93325           5 :      SgDerivedTypeStatement* pointer = NULL;
   93326           5 :      std::vector < unsigned char* > :: const_iterator block;
   93327           5 :      SgDerivedTypeStatement* pointerOfLinkedList = NULL;
   93328           5 :      for ( block = SgDerivedTypeStatement::pools.begin(); block != SgDerivedTypeStatement::pools.end() ; ++block )
   93329             :         {
   93330           0 :           pointer = (SgDerivedTypeStatement*)(*block);
   93331           0 :           for (unsigned i = 0; i < SgDerivedTypeStatement::pool_size; ++i )
   93332             :              {
   93333             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   93334             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   93335             :             // memory blocks!.
   93336           0 :                if ( pointer[i].get_freepointer() != NULL )
   93337             :                   {
   93338           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   93339             :                   }
   93340             :                else
   93341             :                   {
   93342           0 :                     if ( pointerOfLinkedList == NULL )
   93343             :                        {
   93344           0 :                          SgDerivedTypeStatement::next_node = &(pointer[i]);
   93345             :                        }
   93346             :                     else
   93347             :                        {
   93348             :                       // printf ("In SgDerivedTypeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   93349           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   93350             :                        }
   93351             :                     pointerOfLinkedList = &(pointer[i]);
   93352             :                   }
   93353             :               }
   93354             :         }
   93355             : 
   93356           5 :      if ( pointerOfLinkedList != NULL )
   93357             :         {
   93358             :        // printf ("In SgDerivedTypeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   93359           0 :           pointerOfLinkedList->set_freepointer(NULL);
   93360             :        // DQ (6/6/2010): Temporary debugging...
   93361             :        //   ROSE_ASSERT(false);
   93362             :         }
   93363             : 
   93364           5 :      return ;
   93365             :    }
   93366             : 
   93367             : //############################################################################
   93368             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   93369             :  * within the memory pool and resets the freepointers, in order to achieve a 
   93370             :  * linked list, that has no jumps and starts at the beginning! This function 
   93371             :  * does not extend the memory pool, since we do not delete any memory blocks,
   93372             :  * but delete the valid objects.  
   93373             :  */
   93374             : void
   93375           0 : SgDerivedTypeStatement::clearMemoryPool( )
   93376             :    {
   93377             :   // printf ("Inside of SgDerivedTypeStatement::clearMemoryPool() \n");
   93378             : 
   93379           0 :      SgDerivedTypeStatement* pointer = NULL, *tempPointer = NULL;
   93380           0 :      std::vector < unsigned char* > :: const_iterator block;
   93381           0 :      if ( SgDerivedTypeStatement::pools.empty() == false )
   93382             :         {
   93383           0 :           block = SgDerivedTypeStatement::pools.begin() ;
   93384           0 :           SgDerivedTypeStatement::next_node = (SgDerivedTypeStatement*) (*block);
   93385             : 
   93386           0 :           while ( block != SgDerivedTypeStatement::pools.end() )
   93387             :              {
   93388           0 :                pointer = (SgDerivedTypeStatement*) (*block);
   93389           0 :                if ( tempPointer != NULL )
   93390             :                   {
   93391           0 :                     tempPointer->set_freepointer(pointer);
   93392             :                   }
   93393           0 :                for (unsigned i = 0; i < SgDerivedTypeStatement::pool_size - 1; ++i)
   93394             :                   {
   93395           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   93396             :                   }
   93397           0 :                 pointer[SgDerivedTypeStatement::pool_size-1].set_freepointer(NULL);
   93398           0 :                 tempPointer = &(pointer[SgDerivedTypeStatement::pool_size-1]);
   93399           0 :                 ++block;
   93400             :              }
   93401             :         }
   93402           0 :    }
   93403             : 
   93404           5 : void SgDerivedTypeStatement::deleteMemoryPool() {
   93405           5 :   for (auto p: SgDerivedTypeStatement::pools) {
   93406           0 :     ROSE_FREE(p);
   93407             :   }
   93408           5 :   SgDerivedTypeStatement::next_node = nullptr;
   93409           5 :   SgDerivedTypeStatement::pools.clear();
   93410           5 : }
   93411             : 
   93412             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   93413             : //                 reading multiple binary files to for a single AST.
   93414             : /////////// new version ////////////////////////////////
   93415             : //############################################################################
   93416             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   93417             : void
   93418           2 : SgDerivedTypeStatement::extendMemoryPoolForFileIO( )
   93419             :   {
   93420           2 :     size_t blockIndex = SgDerivedTypeStatement::pools.size();
   93421           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDerivedTypeStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDerivedTypeStatement);
   93422             : 
   93423           2 :     while ( (blockIndex * SgDerivedTypeStatement::pool_size) < newPoolSize)
   93424             :       {
   93425             : #if ROSE_ALLOC_TRACE
   93426             :         if (blockIndex > 0) {
   93427             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDerivedTypeStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDerivedTypeStatement) = %" PRIuPTR " SgDerivedTypeStatement::pool_size = %d \n",
   93428             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDerivedTypeStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDerivedTypeStatement),SgDerivedTypeStatement::pool_size);
   93429             :         }
   93430             : #endif
   93431             : 
   93432           0 :         SgDerivedTypeStatement * pointer = (SgDerivedTypeStatement*) ROSE_MALLOC ( SgDerivedTypeStatement::pool_size * sizeof(SgDerivedTypeStatement) );
   93433           0 :         assert( pointer != NULL );
   93434             : #if ROSE_ALLOC_MEMSET == 1
   93435             :         memset(pointer, 0x00, SgDerivedTypeStatement::pool_size * sizeof(SgDerivedTypeStatement));
   93436             : #elif ROSE_ALLOC_MEMSET == 2
   93437             :         memset(pointer, 0xCC, SgDerivedTypeStatement::pool_size * sizeof(SgDerivedTypeStatement));
   93438             : #endif
   93439           0 :         SgDerivedTypeStatement::pools.push_back( (unsigned char*)(pointer) );
   93440           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDerivedTypeStatement::pool_size * sizeof(SgDerivedTypeStatement), V_SgDerivedTypeStatement ) );
   93441             : 
   93442           0 :         if ( SgDerivedTypeStatement::next_node != NULL ) {
   93443           0 :           if ( blockIndex > 0 ) {
   93444           0 :             SgDerivedTypeStatement * blkptr = (SgDerivedTypeStatement*)(SgDerivedTypeStatement::pools[blockIndex-1]);
   93445           0 :             blkptr[ SgDerivedTypeStatement::pool_size - 1 ].set_freepointer(pointer);
   93446             :           }
   93447             :         } else {
   93448           0 :           SgDerivedTypeStatement::next_node = pointer;
   93449             :         }
   93450             : 
   93451           0 :         for (unsigned i = 0; i < SgDerivedTypeStatement::pool_size-1; ++i)
   93452             :            {
   93453           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   93454             :            }
   93455           0 :         pointer[ SgDerivedTypeStatement::pool_size -1 ].set_freepointer(NULL);
   93456             : 
   93457           0 :         blockIndex++;
   93458             :       }
   93459           2 :   }
   93460             : 
   93461             : //############################################################################
   93462             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   93463             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   93464             :  * not compressed. However, that stuff is not yet implemented! 
   93465             :  */
   93466             : unsigned long
   93467           0 : SgDerivedTypeStatement::getNumberOfLastValidPointer()
   93468             :    {
   93469           0 :       SgDerivedTypeStatement* testPointer = (SgDerivedTypeStatement*)(SgDerivedTypeStatement::pools.back());
   93470           0 :       unsigned long localIndex = SgDerivedTypeStatement::pool_size - 1;
   93471           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   93472             :          {
   93473           0 :            localIndex--;
   93474             :          }
   93475           0 :       return (localIndex + SgDerivedTypeStatement::pool_size * (SgDerivedTypeStatement::pools.size()-1));
   93476             :    }
   93477             : 
   93478             : //############################################################################
   93479             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   93480             :  * memory pool and initializes the data member in class SgDerivedTypeStatementStroageClass
   93481             :  * from its counterpart of SgDerivedTypeStatement. The return value is just for checking, 
   93482             :  * that the whole StorageClassArray is initialized!
   93483             :  */
   93484             : unsigned long
   93485           0 : SgDerivedTypeStatement::initializeStorageClassArray( SgDerivedTypeStatementStorageClass *storageArray )
   93486             :    {
   93487           0 :      unsigned long storageCounter = 0;
   93488           0 :      std::vector < unsigned char* > :: const_iterator block = SgDerivedTypeStatement::pools.begin();
   93489           0 :      SgDerivedTypeStatement* pointer = NULL;
   93490           0 :      while ( block != SgDerivedTypeStatement::pools.end() ) {
   93491           0 :           pointer = (SgDerivedTypeStatement*) (*block);
   93492           0 :           for ( unsigned i = 0; i < SgDerivedTypeStatement::pool_size; ++i ) {
   93493           0 :                if ( pointer->get_freepointer() != NULL ) {
   93494           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   93495           0 :                  storageArray++;
   93496           0 :                  storageCounter++;
   93497             :                }
   93498           0 :                pointer++;
   93499             :              }
   93500           0 :            block++;
   93501             :         }
   93502           0 :      return storageCounter;
   93503             :    }
   93504             : 
   93505             : /* #line 93506 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   93506             : 
   93507             : 
   93508             : 
   93509             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   93510             : 
   93511             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   93512             : 
   93513             : //############################################################################
   93514             : /* JH (02/02/2006) Constructor of the IR node SgModuleStatement that takes its 
   93515             :  * corresponding StorageClass as parameter
   93516             :  */
   93517           0 : SgModuleStatement :: SgModuleStatement ( const SgModuleStatementStorageClass& storageSource )   : SgClassDeclaration (storageSource)
   93518             :    {
   93519             : 
   93520             : 
   93521             : /* #line 93522 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   93522             : 
   93523           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   93524           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   93525             : 
   93526             : 
   93527             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   93528             : 
   93529             : 
   93530           0 :    }
   93531             : 
   93532             : //############################################################################
   93533             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   93534             :  * within the working AST. 
   93535             :  */
   93536           0 : SgModuleStatement * SgModuleStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   93537           0 :      SgModuleStatement* returnPointer = NULL;
   93538           0 :      if ( globalIndex != 0 )
   93539             :         {
   93540             : 
   93541             : #if FILE_IO_EXTRA_CHECK
   93542           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgModuleStatement ) ) <= globalIndex ) ;
   93543           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModuleStatement + 1 ) ) );
   93544             : #endif
   93545           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModuleStatement )  
   93546           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgModuleStatement );
   93547           0 :           unsigned long positionInPool = localIndex % SgModuleStatement::pool_size;
   93548           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModuleStatement::pool_size;
   93549             : 
   93550             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   93551             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   93552             : 
   93553           0 :           returnPointer = &( ( (SgModuleStatement*)(SgModuleStatement::pools[memoryBlock]) ) [positionInPool]) ;
   93554             : 
   93555           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   93556             :         }
   93557           0 :      return returnPointer ;
   93558             :    }
   93559             : 
   93560             : //############################################################################
   93561             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   93562             :   for the AST with the index astIndex
   93563             : */
   93564           0 : SgModuleStatement * SgModuleStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   93565           0 :      SgModuleStatement* returnPointer = NULL;
   93566           0 :      if ( globalIndex != 0 )
   93567             :         {
   93568             : 
   93569             : #if FILE_IO_EXTRA_CHECK
   93570           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgModuleStatement ) ) <= globalIndex ) ;
   93571           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModuleStatement + 1 ) ) );
   93572             : #endif
   93573           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModuleStatement )
   93574           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgModuleStatement );
   93575           0 :           unsigned long positionInPool = localIndex % SgModuleStatement::pool_size ;
   93576           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModuleStatement::pool_size ;
   93577             : 
   93578             : #if FILE_IO_EXTRA_CHECK
   93579             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   93580             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   93581             : #endif
   93582             : 
   93583           0 :           returnPointer = &( ( (SgModuleStatement*)(SgModuleStatement::pools[memoryBlock]) ) [positionInPool]) ;
   93584             : 
   93585             : #if FILE_IO_EXTRA_CHECK
   93586           0 :           assert ( returnPointer != NULL ) ;
   93587             : #endif
   93588             :         }
   93589           0 :      return returnPointer ;
   93590             :    }
   93591             : 
   93592             : //############################################################################
   93593             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   93594             :  * pool size! We set for every valid object in the memory pool the freepointer
   93595             :  * to the global index and increase the global index afterwards. For all the 
   93596             :  * invalid objects (means address ranges within the memory pool that were not
   93597             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   93598             :  * distinguish valid from invalid objects! 
   93599             :  */
   93600             : unsigned long
   93601           5 : SgModuleStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   93602             :    {
   93603           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   93604           5 :      SgModuleStatement* pointer = NULL;
   93605           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   93606           5 :      std::vector < unsigned char* > :: const_iterator block;
   93607           5 :      for ( block = SgModuleStatement::pools.begin(); block != SgModuleStatement::pools.end() ; ++block )
   93608             :         {
   93609           0 :           pointer = (SgModuleStatement*)(*block);
   93610           0 :           for (unsigned i = 0; i < SgModuleStatement::pool_size; ++i )
   93611             :              {
   93612             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   93613             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   93614             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   93615             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   93616             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   93617             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   93618             :             // properly; so this will have to be checked next.
   93619             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   93620             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   93621           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   93622             :                   {
   93623           0 :                     pointer[i].set_freepointer((SgModuleStatement*)(globalIndex));
   93624           0 :                     globalIndex++;
   93625             :                   }
   93626             :                else
   93627             :                   {
   93628           0 :                     pointer[i].set_freepointer(NULL);
   93629             :                   }
   93630             :               }
   93631             :         }
   93632           5 :      return globalIndex;
   93633             :    }
   93634             : 
   93635             : //############################################################################
   93636             : // JH (01/14/2006)
   93637             : void
   93638           5 : SgModuleStatement::resetValidFreepointers( )
   93639             :    {
   93640           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   93641           5 :      SgModuleStatement* pointer = NULL;
   93642           5 :      std::vector < unsigned char* > :: const_iterator block;
   93643           5 :      SgModuleStatement* pointerOfLinkedList = NULL;
   93644           5 :      for ( block = SgModuleStatement::pools.begin(); block != SgModuleStatement::pools.end() ; ++block )
   93645             :         {
   93646           0 :           pointer = (SgModuleStatement*)(*block);
   93647           0 :           for (unsigned i = 0; i < SgModuleStatement::pool_size; ++i )
   93648             :              {
   93649             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   93650             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   93651             :             // memory blocks!.
   93652           0 :                if ( pointer[i].get_freepointer() != NULL )
   93653             :                   {
   93654           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   93655             :                   }
   93656             :                else
   93657             :                   {
   93658           0 :                     if ( pointerOfLinkedList == NULL )
   93659             :                        {
   93660           0 :                          SgModuleStatement::next_node = &(pointer[i]);
   93661             :                        }
   93662             :                     else
   93663             :                        {
   93664             :                       // printf ("In SgModuleStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   93665           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   93666             :                        }
   93667             :                     pointerOfLinkedList = &(pointer[i]);
   93668             :                   }
   93669             :               }
   93670             :         }
   93671             : 
   93672           5 :      if ( pointerOfLinkedList != NULL )
   93673             :         {
   93674             :        // printf ("In SgModuleStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   93675           0 :           pointerOfLinkedList->set_freepointer(NULL);
   93676             :        // DQ (6/6/2010): Temporary debugging...
   93677             :        //   ROSE_ASSERT(false);
   93678             :         }
   93679             : 
   93680           5 :      return ;
   93681             :    }
   93682             : 
   93683             : //############################################################################
   93684             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   93685             :  * within the memory pool and resets the freepointers, in order to achieve a 
   93686             :  * linked list, that has no jumps and starts at the beginning! This function 
   93687             :  * does not extend the memory pool, since we do not delete any memory blocks,
   93688             :  * but delete the valid objects.  
   93689             :  */
   93690             : void
   93691           0 : SgModuleStatement::clearMemoryPool( )
   93692             :    {
   93693             :   // printf ("Inside of SgModuleStatement::clearMemoryPool() \n");
   93694             : 
   93695           0 :      SgModuleStatement* pointer = NULL, *tempPointer = NULL;
   93696           0 :      std::vector < unsigned char* > :: const_iterator block;
   93697           0 :      if ( SgModuleStatement::pools.empty() == false )
   93698             :         {
   93699           0 :           block = SgModuleStatement::pools.begin() ;
   93700           0 :           SgModuleStatement::next_node = (SgModuleStatement*) (*block);
   93701             : 
   93702           0 :           while ( block != SgModuleStatement::pools.end() )
   93703             :              {
   93704           0 :                pointer = (SgModuleStatement*) (*block);
   93705           0 :                if ( tempPointer != NULL )
   93706             :                   {
   93707           0 :                     tempPointer->set_freepointer(pointer);
   93708             :                   }
   93709           0 :                for (unsigned i = 0; i < SgModuleStatement::pool_size - 1; ++i)
   93710             :                   {
   93711           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   93712             :                   }
   93713           0 :                 pointer[SgModuleStatement::pool_size-1].set_freepointer(NULL);
   93714           0 :                 tempPointer = &(pointer[SgModuleStatement::pool_size-1]);
   93715           0 :                 ++block;
   93716             :              }
   93717             :         }
   93718           0 :    }
   93719             : 
   93720           5 : void SgModuleStatement::deleteMemoryPool() {
   93721           5 :   for (auto p: SgModuleStatement::pools) {
   93722           0 :     ROSE_FREE(p);
   93723             :   }
   93724           5 :   SgModuleStatement::next_node = nullptr;
   93725           5 :   SgModuleStatement::pools.clear();
   93726           5 : }
   93727             : 
   93728             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   93729             : //                 reading multiple binary files to for a single AST.
   93730             : /////////// new version ////////////////////////////////
   93731             : //############################################################################
   93732             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   93733             : void
   93734           2 : SgModuleStatement::extendMemoryPoolForFileIO( )
   93735             :   {
   93736           2 :     size_t blockIndex = SgModuleStatement::pools.size();
   93737           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgModuleStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgModuleStatement);
   93738             : 
   93739           2 :     while ( (blockIndex * SgModuleStatement::pool_size) < newPoolSize)
   93740             :       {
   93741             : #if ROSE_ALLOC_TRACE
   93742             :         if (blockIndex > 0) {
   93743             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgModuleStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgModuleStatement) = %" PRIuPTR " SgModuleStatement::pool_size = %d \n",
   93744             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgModuleStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgModuleStatement),SgModuleStatement::pool_size);
   93745             :         }
   93746             : #endif
   93747             : 
   93748           0 :         SgModuleStatement * pointer = (SgModuleStatement*) ROSE_MALLOC ( SgModuleStatement::pool_size * sizeof(SgModuleStatement) );
   93749           0 :         assert( pointer != NULL );
   93750             : #if ROSE_ALLOC_MEMSET == 1
   93751             :         memset(pointer, 0x00, SgModuleStatement::pool_size * sizeof(SgModuleStatement));
   93752             : #elif ROSE_ALLOC_MEMSET == 2
   93753             :         memset(pointer, 0xCC, SgModuleStatement::pool_size * sizeof(SgModuleStatement));
   93754             : #endif
   93755           0 :         SgModuleStatement::pools.push_back( (unsigned char*)(pointer) );
   93756           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgModuleStatement::pool_size * sizeof(SgModuleStatement), V_SgModuleStatement ) );
   93757             : 
   93758           0 :         if ( SgModuleStatement::next_node != NULL ) {
   93759           0 :           if ( blockIndex > 0 ) {
   93760           0 :             SgModuleStatement * blkptr = (SgModuleStatement*)(SgModuleStatement::pools[blockIndex-1]);
   93761           0 :             blkptr[ SgModuleStatement::pool_size - 1 ].set_freepointer(pointer);
   93762             :           }
   93763             :         } else {
   93764           0 :           SgModuleStatement::next_node = pointer;
   93765             :         }
   93766             : 
   93767           0 :         for (unsigned i = 0; i < SgModuleStatement::pool_size-1; ++i)
   93768             :            {
   93769           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   93770             :            }
   93771           0 :         pointer[ SgModuleStatement::pool_size -1 ].set_freepointer(NULL);
   93772             : 
   93773           0 :         blockIndex++;
   93774             :       }
   93775           2 :   }
   93776             : 
   93777             : //############################################################################
   93778             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   93779             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   93780             :  * not compressed. However, that stuff is not yet implemented! 
   93781             :  */
   93782             : unsigned long
   93783           0 : SgModuleStatement::getNumberOfLastValidPointer()
   93784             :    {
   93785           0 :       SgModuleStatement* testPointer = (SgModuleStatement*)(SgModuleStatement::pools.back());
   93786           0 :       unsigned long localIndex = SgModuleStatement::pool_size - 1;
   93787           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   93788             :          {
   93789           0 :            localIndex--;
   93790             :          }
   93791           0 :       return (localIndex + SgModuleStatement::pool_size * (SgModuleStatement::pools.size()-1));
   93792             :    }
   93793             : 
   93794             : //############################################################################
   93795             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   93796             :  * memory pool and initializes the data member in class SgModuleStatementStroageClass
   93797             :  * from its counterpart of SgModuleStatement. The return value is just for checking, 
   93798             :  * that the whole StorageClassArray is initialized!
   93799             :  */
   93800             : unsigned long
   93801           0 : SgModuleStatement::initializeStorageClassArray( SgModuleStatementStorageClass *storageArray )
   93802             :    {
   93803           0 :      unsigned long storageCounter = 0;
   93804           0 :      std::vector < unsigned char* > :: const_iterator block = SgModuleStatement::pools.begin();
   93805           0 :      SgModuleStatement* pointer = NULL;
   93806           0 :      while ( block != SgModuleStatement::pools.end() ) {
   93807           0 :           pointer = (SgModuleStatement*) (*block);
   93808           0 :           for ( unsigned i = 0; i < SgModuleStatement::pool_size; ++i ) {
   93809           0 :                if ( pointer->get_freepointer() != NULL ) {
   93810           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   93811           0 :                  storageArray++;
   93812           0 :                  storageCounter++;
   93813             :                }
   93814           0 :                pointer++;
   93815             :              }
   93816           0 :            block++;
   93817             :         }
   93818           0 :      return storageCounter;
   93819             :    }
   93820             : 
   93821             : /* #line 93822 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   93822             : 
   93823             : 
   93824             : 
   93825             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   93826             : 
   93827             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   93828             : 
   93829             : //############################################################################
   93830             : /* JH (02/02/2006) Constructor of the IR node SgImplicitStatement that takes its 
   93831             :  * corresponding StorageClass as parameter
   93832             :  */
   93833           0 : SgImplicitStatement :: SgImplicitStatement ( const SgImplicitStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   93834             :    {
   93835             : 
   93836             : 
   93837             : /* #line 93838 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   93838             : 
   93839           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   93840           0 :      p_implicit_none = storageSource.storageOf_implicit_none ;
   93841           0 :      p_implicit_spec = storageSource.storageOf_implicit_spec ;
   93842           0 :      p_variables = storageSource.storageOf_variables.rebuildDataStoredInEasyStorageClass() ;
   93843           0 :      SgInitializedNamePtrList::iterator i_variables = p_variables.begin() ; 
   93844           0 :      for ( ; i_variables != p_variables.end(); ++i_variables ) 
   93845             :         {
   93846           0 :           (*i_variables) = (SgInitializedNamePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_variables) ) );
   93847             :         }
   93848             : 
   93849             : 
   93850             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   93851             : 
   93852             : 
   93853           0 :    }
   93854             : 
   93855             : //############################################################################
   93856             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   93857             :  * within the working AST. 
   93858             :  */
   93859           0 : SgImplicitStatement * SgImplicitStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   93860           0 :      SgImplicitStatement* returnPointer = NULL;
   93861           0 :      if ( globalIndex != 0 )
   93862             :         {
   93863             : 
   93864             : #if FILE_IO_EXTRA_CHECK
   93865           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgImplicitStatement ) ) <= globalIndex ) ;
   93866           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImplicitStatement + 1 ) ) );
   93867             : #endif
   93868           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImplicitStatement )  
   93869           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgImplicitStatement );
   93870           0 :           unsigned long positionInPool = localIndex % SgImplicitStatement::pool_size;
   93871           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImplicitStatement::pool_size;
   93872             : 
   93873             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   93874             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   93875             : 
   93876           0 :           returnPointer = &( ( (SgImplicitStatement*)(SgImplicitStatement::pools[memoryBlock]) ) [positionInPool]) ;
   93877             : 
   93878           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   93879             :         }
   93880           0 :      return returnPointer ;
   93881             :    }
   93882             : 
   93883             : //############################################################################
   93884             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   93885             :   for the AST with the index astIndex
   93886             : */
   93887           0 : SgImplicitStatement * SgImplicitStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   93888           0 :      SgImplicitStatement* returnPointer = NULL;
   93889           0 :      if ( globalIndex != 0 )
   93890             :         {
   93891             : 
   93892             : #if FILE_IO_EXTRA_CHECK
   93893           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgImplicitStatement ) ) <= globalIndex ) ;
   93894           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImplicitStatement + 1 ) ) );
   93895             : #endif
   93896           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImplicitStatement )
   93897           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgImplicitStatement );
   93898           0 :           unsigned long positionInPool = localIndex % SgImplicitStatement::pool_size ;
   93899           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImplicitStatement::pool_size ;
   93900             : 
   93901             : #if FILE_IO_EXTRA_CHECK
   93902             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   93903             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   93904             : #endif
   93905             : 
   93906           0 :           returnPointer = &( ( (SgImplicitStatement*)(SgImplicitStatement::pools[memoryBlock]) ) [positionInPool]) ;
   93907             : 
   93908             : #if FILE_IO_EXTRA_CHECK
   93909           0 :           assert ( returnPointer != NULL ) ;
   93910             : #endif
   93911             :         }
   93912           0 :      return returnPointer ;
   93913             :    }
   93914             : 
   93915             : //############################################################################
   93916             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   93917             :  * pool size! We set for every valid object in the memory pool the freepointer
   93918             :  * to the global index and increase the global index afterwards. For all the 
   93919             :  * invalid objects (means address ranges within the memory pool that were not
   93920             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   93921             :  * distinguish valid from invalid objects! 
   93922             :  */
   93923             : unsigned long
   93924           5 : SgImplicitStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   93925             :    {
   93926           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   93927           5 :      SgImplicitStatement* pointer = NULL;
   93928           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   93929           5 :      std::vector < unsigned char* > :: const_iterator block;
   93930           5 :      for ( block = SgImplicitStatement::pools.begin(); block != SgImplicitStatement::pools.end() ; ++block )
   93931             :         {
   93932           0 :           pointer = (SgImplicitStatement*)(*block);
   93933           0 :           for (unsigned i = 0; i < SgImplicitStatement::pool_size; ++i )
   93934             :              {
   93935             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   93936             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   93937             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   93938             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   93939             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   93940             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   93941             :             // properly; so this will have to be checked next.
   93942             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   93943             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   93944           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   93945             :                   {
   93946           0 :                     pointer[i].set_freepointer((SgImplicitStatement*)(globalIndex));
   93947           0 :                     globalIndex++;
   93948             :                   }
   93949             :                else
   93950             :                   {
   93951           0 :                     pointer[i].set_freepointer(NULL);
   93952             :                   }
   93953             :               }
   93954             :         }
   93955           5 :      return globalIndex;
   93956             :    }
   93957             : 
   93958             : //############################################################################
   93959             : // JH (01/14/2006)
   93960             : void
   93961           5 : SgImplicitStatement::resetValidFreepointers( )
   93962             :    {
   93963           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   93964           5 :      SgImplicitStatement* pointer = NULL;
   93965           5 :      std::vector < unsigned char* > :: const_iterator block;
   93966           5 :      SgImplicitStatement* pointerOfLinkedList = NULL;
   93967           5 :      for ( block = SgImplicitStatement::pools.begin(); block != SgImplicitStatement::pools.end() ; ++block )
   93968             :         {
   93969           0 :           pointer = (SgImplicitStatement*)(*block);
   93970           0 :           for (unsigned i = 0; i < SgImplicitStatement::pool_size; ++i )
   93971             :              {
   93972             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   93973             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   93974             :             // memory blocks!.
   93975           0 :                if ( pointer[i].get_freepointer() != NULL )
   93976             :                   {
   93977           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   93978             :                   }
   93979             :                else
   93980             :                   {
   93981           0 :                     if ( pointerOfLinkedList == NULL )
   93982             :                        {
   93983           0 :                          SgImplicitStatement::next_node = &(pointer[i]);
   93984             :                        }
   93985             :                     else
   93986             :                        {
   93987             :                       // printf ("In SgImplicitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   93988           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   93989             :                        }
   93990             :                     pointerOfLinkedList = &(pointer[i]);
   93991             :                   }
   93992             :               }
   93993             :         }
   93994             : 
   93995           5 :      if ( pointerOfLinkedList != NULL )
   93996             :         {
   93997             :        // printf ("In SgImplicitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   93998           0 :           pointerOfLinkedList->set_freepointer(NULL);
   93999             :        // DQ (6/6/2010): Temporary debugging...
   94000             :        //   ROSE_ASSERT(false);
   94001             :         }
   94002             : 
   94003           5 :      return ;
   94004             :    }
   94005             : 
   94006             : //############################################################################
   94007             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   94008             :  * within the memory pool and resets the freepointers, in order to achieve a 
   94009             :  * linked list, that has no jumps and starts at the beginning! This function 
   94010             :  * does not extend the memory pool, since we do not delete any memory blocks,
   94011             :  * but delete the valid objects.  
   94012             :  */
   94013             : void
   94014           0 : SgImplicitStatement::clearMemoryPool( )
   94015             :    {
   94016             :   // printf ("Inside of SgImplicitStatement::clearMemoryPool() \n");
   94017             : 
   94018           0 :      SgImplicitStatement* pointer = NULL, *tempPointer = NULL;
   94019           0 :      std::vector < unsigned char* > :: const_iterator block;
   94020           0 :      if ( SgImplicitStatement::pools.empty() == false )
   94021             :         {
   94022           0 :           block = SgImplicitStatement::pools.begin() ;
   94023           0 :           SgImplicitStatement::next_node = (SgImplicitStatement*) (*block);
   94024             : 
   94025           0 :           while ( block != SgImplicitStatement::pools.end() )
   94026             :              {
   94027           0 :                pointer = (SgImplicitStatement*) (*block);
   94028           0 :                if ( tempPointer != NULL )
   94029             :                   {
   94030           0 :                     tempPointer->set_freepointer(pointer);
   94031             :                   }
   94032           0 :                for (unsigned i = 0; i < SgImplicitStatement::pool_size - 1; ++i)
   94033             :                   {
   94034           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   94035             :                   }
   94036           0 :                 pointer[SgImplicitStatement::pool_size-1].set_freepointer(NULL);
   94037           0 :                 tempPointer = &(pointer[SgImplicitStatement::pool_size-1]);
   94038           0 :                 ++block;
   94039             :              }
   94040             :         }
   94041           0 :    }
   94042             : 
   94043           5 : void SgImplicitStatement::deleteMemoryPool() {
   94044           5 :   for (auto p: SgImplicitStatement::pools) {
   94045           0 :     ROSE_FREE(p);
   94046             :   }
   94047           5 :   SgImplicitStatement::next_node = nullptr;
   94048           5 :   SgImplicitStatement::pools.clear();
   94049           5 : }
   94050             : 
   94051             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   94052             : //                 reading multiple binary files to for a single AST.
   94053             : /////////// new version ////////////////////////////////
   94054             : //############################################################################
   94055             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   94056             : void
   94057           2 : SgImplicitStatement::extendMemoryPoolForFileIO( )
   94058             :   {
   94059           2 :     size_t blockIndex = SgImplicitStatement::pools.size();
   94060           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgImplicitStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgImplicitStatement);
   94061             : 
   94062           2 :     while ( (blockIndex * SgImplicitStatement::pool_size) < newPoolSize)
   94063             :       {
   94064             : #if ROSE_ALLOC_TRACE
   94065             :         if (blockIndex > 0) {
   94066             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgImplicitStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgImplicitStatement) = %" PRIuPTR " SgImplicitStatement::pool_size = %d \n",
   94067             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgImplicitStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgImplicitStatement),SgImplicitStatement::pool_size);
   94068             :         }
   94069             : #endif
   94070             : 
   94071           0 :         SgImplicitStatement * pointer = (SgImplicitStatement*) ROSE_MALLOC ( SgImplicitStatement::pool_size * sizeof(SgImplicitStatement) );
   94072           0 :         assert( pointer != NULL );
   94073             : #if ROSE_ALLOC_MEMSET == 1
   94074             :         memset(pointer, 0x00, SgImplicitStatement::pool_size * sizeof(SgImplicitStatement));
   94075             : #elif ROSE_ALLOC_MEMSET == 2
   94076             :         memset(pointer, 0xCC, SgImplicitStatement::pool_size * sizeof(SgImplicitStatement));
   94077             : #endif
   94078           0 :         SgImplicitStatement::pools.push_back( (unsigned char*)(pointer) );
   94079           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgImplicitStatement::pool_size * sizeof(SgImplicitStatement), V_SgImplicitStatement ) );
   94080             : 
   94081           0 :         if ( SgImplicitStatement::next_node != NULL ) {
   94082           0 :           if ( blockIndex > 0 ) {
   94083           0 :             SgImplicitStatement * blkptr = (SgImplicitStatement*)(SgImplicitStatement::pools[blockIndex-1]);
   94084           0 :             blkptr[ SgImplicitStatement::pool_size - 1 ].set_freepointer(pointer);
   94085             :           }
   94086             :         } else {
   94087           0 :           SgImplicitStatement::next_node = pointer;
   94088             :         }
   94089             : 
   94090           0 :         for (unsigned i = 0; i < SgImplicitStatement::pool_size-1; ++i)
   94091             :            {
   94092           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   94093             :            }
   94094           0 :         pointer[ SgImplicitStatement::pool_size -1 ].set_freepointer(NULL);
   94095             : 
   94096           0 :         blockIndex++;
   94097             :       }
   94098           2 :   }
   94099             : 
   94100             : //############################################################################
   94101             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   94102             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   94103             :  * not compressed. However, that stuff is not yet implemented! 
   94104             :  */
   94105             : unsigned long
   94106           0 : SgImplicitStatement::getNumberOfLastValidPointer()
   94107             :    {
   94108           0 :       SgImplicitStatement* testPointer = (SgImplicitStatement*)(SgImplicitStatement::pools.back());
   94109           0 :       unsigned long localIndex = SgImplicitStatement::pool_size - 1;
   94110           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   94111             :          {
   94112           0 :            localIndex--;
   94113             :          }
   94114           0 :       return (localIndex + SgImplicitStatement::pool_size * (SgImplicitStatement::pools.size()-1));
   94115             :    }
   94116             : 
   94117             : //############################################################################
   94118             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   94119             :  * memory pool and initializes the data member in class SgImplicitStatementStroageClass
   94120             :  * from its counterpart of SgImplicitStatement. The return value is just for checking, 
   94121             :  * that the whole StorageClassArray is initialized!
   94122             :  */
   94123             : unsigned long
   94124           0 : SgImplicitStatement::initializeStorageClassArray( SgImplicitStatementStorageClass *storageArray )
   94125             :    {
   94126           0 :      unsigned long storageCounter = 0;
   94127           0 :      std::vector < unsigned char* > :: const_iterator block = SgImplicitStatement::pools.begin();
   94128           0 :      SgImplicitStatement* pointer = NULL;
   94129           0 :      while ( block != SgImplicitStatement::pools.end() ) {
   94130           0 :           pointer = (SgImplicitStatement*) (*block);
   94131           0 :           for ( unsigned i = 0; i < SgImplicitStatement::pool_size; ++i ) {
   94132           0 :                if ( pointer->get_freepointer() != NULL ) {
   94133           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   94134           0 :                  storageArray++;
   94135           0 :                  storageCounter++;
   94136             :                }
   94137           0 :                pointer++;
   94138             :              }
   94139           0 :            block++;
   94140             :         }
   94141           0 :      return storageCounter;
   94142             :    }
   94143             : 
   94144             : /* #line 94145 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   94145             : 
   94146             : 
   94147             : 
   94148             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   94149             : 
   94150             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   94151             : 
   94152             : //############################################################################
   94153             : /* JH (02/02/2006) Constructor of the IR node SgUsingDeclarationStatement that takes its 
   94154             :  * corresponding StorageClass as parameter
   94155             :  */
   94156         275 : SgUsingDeclarationStatement :: SgUsingDeclarationStatement ( const SgUsingDeclarationStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   94157             :    {
   94158             : 
   94159             : 
   94160             : /* #line 94161 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   94161             : 
   94162         275 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   94163         275 :      p_declaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
   94164         275 :      p_initializedName =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initializedName) );
   94165         275 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   94166         275 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   94167         275 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   94168         275 :      p_is_inheriting_constructor = storageSource.storageOf_is_inheriting_constructor ;
   94169             : 
   94170             : 
   94171             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   94172             : 
   94173             : 
   94174         275 :    }
   94175             : 
   94176             : //############################################################################
   94177             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   94178             :  * within the working AST. 
   94179             :  */
   94180        1375 : SgUsingDeclarationStatement * SgUsingDeclarationStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   94181        1375 :      SgUsingDeclarationStatement* returnPointer = NULL;
   94182        1375 :      if ( globalIndex != 0 )
   94183             :         {
   94184             : 
   94185             : #if FILE_IO_EXTRA_CHECK
   94186        1375 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUsingDeclarationStatement ) ) <= globalIndex ) ;
   94187        1375 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUsingDeclarationStatement + 1 ) ) );
   94188             : #endif
   94189        1375 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUsingDeclarationStatement )  
   94190        1375 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUsingDeclarationStatement );
   94191        1375 :           unsigned long positionInPool = localIndex % SgUsingDeclarationStatement::pool_size;
   94192        1375 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUsingDeclarationStatement::pool_size;
   94193             : 
   94194             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   94195             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   94196             : 
   94197        1375 :           returnPointer = &( ( (SgUsingDeclarationStatement*)(SgUsingDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   94198             : 
   94199        1375 :           ROSE_ASSERT( returnPointer != NULL ) ;
   94200             :         }
   94201        1375 :      return returnPointer ;
   94202             :    }
   94203             : 
   94204             : //############################################################################
   94205             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   94206             :   for the AST with the index astIndex
   94207             : */
   94208           0 : SgUsingDeclarationStatement * SgUsingDeclarationStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   94209           0 :      SgUsingDeclarationStatement* returnPointer = NULL;
   94210           0 :      if ( globalIndex != 0 )
   94211             :         {
   94212             : 
   94213             : #if FILE_IO_EXTRA_CHECK
   94214           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUsingDeclarationStatement ) ) <= globalIndex ) ;
   94215           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUsingDeclarationStatement + 1 ) ) );
   94216             : #endif
   94217           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUsingDeclarationStatement )
   94218           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUsingDeclarationStatement );
   94219           0 :           unsigned long positionInPool = localIndex % SgUsingDeclarationStatement::pool_size ;
   94220           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUsingDeclarationStatement::pool_size ;
   94221             : 
   94222             : #if FILE_IO_EXTRA_CHECK
   94223             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   94224             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   94225             : #endif
   94226             : 
   94227           0 :           returnPointer = &( ( (SgUsingDeclarationStatement*)(SgUsingDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
   94228             : 
   94229             : #if FILE_IO_EXTRA_CHECK
   94230           0 :           assert ( returnPointer != NULL ) ;
   94231             : #endif
   94232             :         }
   94233           0 :      return returnPointer ;
   94234             :    }
   94235             : 
   94236             : //############################################################################
   94237             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   94238             :  * pool size! We set for every valid object in the memory pool the freepointer
   94239             :  * to the global index and increase the global index afterwards. For all the 
   94240             :  * invalid objects (means address ranges within the memory pool that were not
   94241             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   94242             :  * distinguish valid from invalid objects! 
   94243             :  */
   94244             : unsigned long
   94245           5 : SgUsingDeclarationStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   94246             :    {
   94247           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   94248           5 :      SgUsingDeclarationStatement* pointer = NULL;
   94249           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   94250           5 :      std::vector < unsigned char* > :: const_iterator block;
   94251           6 :      for ( block = SgUsingDeclarationStatement::pools.begin(); block != SgUsingDeclarationStatement::pools.end() ; ++block )
   94252             :         {
   94253           1 :           pointer = (SgUsingDeclarationStatement*)(*block);
   94254        2001 :           for (unsigned i = 0; i < SgUsingDeclarationStatement::pool_size; ++i )
   94255             :              {
   94256             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   94257             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   94258             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   94259             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   94260             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   94261             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   94262             :             // properly; so this will have to be checked next.
   94263             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   94264             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   94265        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   94266             :                   {
   94267         275 :                     pointer[i].set_freepointer((SgUsingDeclarationStatement*)(globalIndex));
   94268         275 :                     globalIndex++;
   94269             :                   }
   94270             :                else
   94271             :                   {
   94272        1725 :                     pointer[i].set_freepointer(NULL);
   94273             :                   }
   94274             :               }
   94275             :         }
   94276           5 :      return globalIndex;
   94277             :    }
   94278             : 
   94279             : //############################################################################
   94280             : // JH (01/14/2006)
   94281             : void
   94282           5 : SgUsingDeclarationStatement::resetValidFreepointers( )
   94283             :    {
   94284           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   94285           5 :      SgUsingDeclarationStatement* pointer = NULL;
   94286           5 :      std::vector < unsigned char* > :: const_iterator block;
   94287           5 :      SgUsingDeclarationStatement* pointerOfLinkedList = NULL;
   94288           6 :      for ( block = SgUsingDeclarationStatement::pools.begin(); block != SgUsingDeclarationStatement::pools.end() ; ++block )
   94289             :         {
   94290           1 :           pointer = (SgUsingDeclarationStatement*)(*block);
   94291        2001 :           for (unsigned i = 0; i < SgUsingDeclarationStatement::pool_size; ++i )
   94292             :              {
   94293             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   94294             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   94295             :             // memory blocks!.
   94296        2000 :                if ( pointer[i].get_freepointer() != NULL )
   94297             :                   {
   94298         275 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   94299             :                   }
   94300             :                else
   94301             :                   {
   94302        1725 :                     if ( pointerOfLinkedList == NULL )
   94303             :                        {
   94304           1 :                          SgUsingDeclarationStatement::next_node = &(pointer[i]);
   94305             :                        }
   94306             :                     else
   94307             :                        {
   94308             :                       // printf ("In SgUsingDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   94309        1724 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   94310             :                        }
   94311             :                     pointerOfLinkedList = &(pointer[i]);
   94312             :                   }
   94313             :               }
   94314             :         }
   94315             : 
   94316           5 :      if ( pointerOfLinkedList != NULL )
   94317             :         {
   94318             :        // printf ("In SgUsingDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   94319           1 :           pointerOfLinkedList->set_freepointer(NULL);
   94320             :        // DQ (6/6/2010): Temporary debugging...
   94321             :        //   ROSE_ASSERT(false);
   94322             :         }
   94323             : 
   94324           5 :      return ;
   94325             :    }
   94326             : 
   94327             : //############################################################################
   94328             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   94329             :  * within the memory pool and resets the freepointers, in order to achieve a 
   94330             :  * linked list, that has no jumps and starts at the beginning! This function 
   94331             :  * does not extend the memory pool, since we do not delete any memory blocks,
   94332             :  * but delete the valid objects.  
   94333             :  */
   94334             : void
   94335           0 : SgUsingDeclarationStatement::clearMemoryPool( )
   94336             :    {
   94337             :   // printf ("Inside of SgUsingDeclarationStatement::clearMemoryPool() \n");
   94338             : 
   94339           0 :      SgUsingDeclarationStatement* pointer = NULL, *tempPointer = NULL;
   94340           0 :      std::vector < unsigned char* > :: const_iterator block;
   94341           0 :      if ( SgUsingDeclarationStatement::pools.empty() == false )
   94342             :         {
   94343           0 :           block = SgUsingDeclarationStatement::pools.begin() ;
   94344           0 :           SgUsingDeclarationStatement::next_node = (SgUsingDeclarationStatement*) (*block);
   94345             : 
   94346           0 :           while ( block != SgUsingDeclarationStatement::pools.end() )
   94347             :              {
   94348           0 :                pointer = (SgUsingDeclarationStatement*) (*block);
   94349           0 :                if ( tempPointer != NULL )
   94350             :                   {
   94351           0 :                     tempPointer->set_freepointer(pointer);
   94352             :                   }
   94353           0 :                for (unsigned i = 0; i < SgUsingDeclarationStatement::pool_size - 1; ++i)
   94354             :                   {
   94355           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   94356             :                   }
   94357           0 :                 pointer[SgUsingDeclarationStatement::pool_size-1].set_freepointer(NULL);
   94358           0 :                 tempPointer = &(pointer[SgUsingDeclarationStatement::pool_size-1]);
   94359           0 :                 ++block;
   94360             :              }
   94361             :         }
   94362           0 :    }
   94363             : 
   94364           5 : void SgUsingDeclarationStatement::deleteMemoryPool() {
   94365           7 :   for (auto p: SgUsingDeclarationStatement::pools) {
   94366           2 :     ROSE_FREE(p);
   94367             :   }
   94368           5 :   SgUsingDeclarationStatement::next_node = nullptr;
   94369           5 :   SgUsingDeclarationStatement::pools.clear();
   94370           5 : }
   94371             : 
   94372             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   94373             : //                 reading multiple binary files to for a single AST.
   94374             : /////////// new version ////////////////////////////////
   94375             : //############################################################################
   94376             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   94377             : void
   94378           2 : SgUsingDeclarationStatement::extendMemoryPoolForFileIO( )
   94379             :   {
   94380           2 :     size_t blockIndex = SgUsingDeclarationStatement::pools.size();
   94381           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUsingDeclarationStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUsingDeclarationStatement);
   94382             : 
   94383           3 :     while ( (blockIndex * SgUsingDeclarationStatement::pool_size) < newPoolSize)
   94384             :       {
   94385             : #if ROSE_ALLOC_TRACE
   94386             :         if (blockIndex > 0) {
   94387             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUsingDeclarationStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUsingDeclarationStatement) = %" PRIuPTR " SgUsingDeclarationStatement::pool_size = %d \n",
   94388             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUsingDeclarationStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUsingDeclarationStatement),SgUsingDeclarationStatement::pool_size);
   94389             :         }
   94390             : #endif
   94391             : 
   94392           1 :         SgUsingDeclarationStatement * pointer = (SgUsingDeclarationStatement*) ROSE_MALLOC ( SgUsingDeclarationStatement::pool_size * sizeof(SgUsingDeclarationStatement) );
   94393           1 :         assert( pointer != NULL );
   94394             : #if ROSE_ALLOC_MEMSET == 1
   94395             :         memset(pointer, 0x00, SgUsingDeclarationStatement::pool_size * sizeof(SgUsingDeclarationStatement));
   94396             : #elif ROSE_ALLOC_MEMSET == 2
   94397             :         memset(pointer, 0xCC, SgUsingDeclarationStatement::pool_size * sizeof(SgUsingDeclarationStatement));
   94398             : #endif
   94399           1 :         SgUsingDeclarationStatement::pools.push_back( (unsigned char*)(pointer) );
   94400           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUsingDeclarationStatement::pool_size * sizeof(SgUsingDeclarationStatement), V_SgUsingDeclarationStatement ) );
   94401             : 
   94402           1 :         if ( SgUsingDeclarationStatement::next_node != NULL ) {
   94403           0 :           if ( blockIndex > 0 ) {
   94404           0 :             SgUsingDeclarationStatement * blkptr = (SgUsingDeclarationStatement*)(SgUsingDeclarationStatement::pools[blockIndex-1]);
   94405           0 :             blkptr[ SgUsingDeclarationStatement::pool_size - 1 ].set_freepointer(pointer);
   94406             :           }
   94407             :         } else {
   94408           1 :           SgUsingDeclarationStatement::next_node = pointer;
   94409             :         }
   94410             : 
   94411        2000 :         for (unsigned i = 0; i < SgUsingDeclarationStatement::pool_size-1; ++i)
   94412             :            {
   94413        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   94414             :            }
   94415           1 :         pointer[ SgUsingDeclarationStatement::pool_size -1 ].set_freepointer(NULL);
   94416             : 
   94417           1 :         blockIndex++;
   94418             :       }
   94419           2 :   }
   94420             : 
   94421             : //############################################################################
   94422             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   94423             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   94424             :  * not compressed. However, that stuff is not yet implemented! 
   94425             :  */
   94426             : unsigned long
   94427           0 : SgUsingDeclarationStatement::getNumberOfLastValidPointer()
   94428             :    {
   94429           0 :       SgUsingDeclarationStatement* testPointer = (SgUsingDeclarationStatement*)(SgUsingDeclarationStatement::pools.back());
   94430           0 :       unsigned long localIndex = SgUsingDeclarationStatement::pool_size - 1;
   94431           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   94432             :          {
   94433           0 :            localIndex--;
   94434             :          }
   94435           0 :       return (localIndex + SgUsingDeclarationStatement::pool_size * (SgUsingDeclarationStatement::pools.size()-1));
   94436             :    }
   94437             : 
   94438             : //############################################################################
   94439             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   94440             :  * memory pool and initializes the data member in class SgUsingDeclarationStatementStroageClass
   94441             :  * from its counterpart of SgUsingDeclarationStatement. The return value is just for checking, 
   94442             :  * that the whole StorageClassArray is initialized!
   94443             :  */
   94444             : unsigned long
   94445           1 : SgUsingDeclarationStatement::initializeStorageClassArray( SgUsingDeclarationStatementStorageClass *storageArray )
   94446             :    {
   94447           1 :      unsigned long storageCounter = 0;
   94448           1 :      std::vector < unsigned char* > :: const_iterator block = SgUsingDeclarationStatement::pools.begin();
   94449           1 :      SgUsingDeclarationStatement* pointer = NULL;
   94450           2 :      while ( block != SgUsingDeclarationStatement::pools.end() ) {
   94451           1 :           pointer = (SgUsingDeclarationStatement*) (*block);
   94452        2001 :           for ( unsigned i = 0; i < SgUsingDeclarationStatement::pool_size; ++i ) {
   94453        2000 :                if ( pointer->get_freepointer() != NULL ) {
   94454         275 :                  storageArray->pickOutIRNodeData (pointer) ;
   94455         275 :                  storageArray++;
   94456         275 :                  storageCounter++;
   94457             :                }
   94458        2000 :                pointer++;
   94459             :              }
   94460           1 :            block++;
   94461             :         }
   94462           1 :      return storageCounter;
   94463             :    }
   94464             : 
   94465             : /* #line 94466 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   94466             : 
   94467             : 
   94468             : 
   94469             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   94470             : 
   94471             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   94472             : 
   94473             : //############################################################################
   94474             : /* JH (02/02/2006) Constructor of the IR node SgNamelistStatement that takes its 
   94475             :  * corresponding StorageClass as parameter
   94476             :  */
   94477           0 : SgNamelistStatement :: SgNamelistStatement ( const SgNamelistStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   94478             :    {
   94479             : 
   94480             : 
   94481             : /* #line 94482 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   94482             : 
   94483           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   94484           0 :      p_group_list = storageSource.storageOf_group_list.rebuildDataStoredInEasyStorageClass() ;
   94485           0 :      SgNameGroupPtrList::iterator i_group_list = p_group_list.begin() ; 
   94486           0 :      for ( ; i_group_list != p_group_list.end(); ++i_group_list ) 
   94487             :         {
   94488           0 :           (*i_group_list) = (SgNameGroupPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_group_list) ) );
   94489             :         }
   94490             : 
   94491             : 
   94492             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   94493             : 
   94494             : 
   94495           0 :    }
   94496             : 
   94497             : //############################################################################
   94498             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   94499             :  * within the working AST. 
   94500             :  */
   94501           0 : SgNamelistStatement * SgNamelistStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   94502           0 :      SgNamelistStatement* returnPointer = NULL;
   94503           0 :      if ( globalIndex != 0 )
   94504             :         {
   94505             : 
   94506             : #if FILE_IO_EXTRA_CHECK
   94507           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNamelistStatement ) ) <= globalIndex ) ;
   94508           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamelistStatement + 1 ) ) );
   94509             : #endif
   94510           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamelistStatement )  
   94511           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNamelistStatement );
   94512           0 :           unsigned long positionInPool = localIndex % SgNamelistStatement::pool_size;
   94513           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamelistStatement::pool_size;
   94514             : 
   94515             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   94516             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   94517             : 
   94518           0 :           returnPointer = &( ( (SgNamelistStatement*)(SgNamelistStatement::pools[memoryBlock]) ) [positionInPool]) ;
   94519             : 
   94520           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   94521             :         }
   94522           0 :      return returnPointer ;
   94523             :    }
   94524             : 
   94525             : //############################################################################
   94526             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   94527             :   for the AST with the index astIndex
   94528             : */
   94529           0 : SgNamelistStatement * SgNamelistStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   94530           0 :      SgNamelistStatement* returnPointer = NULL;
   94531           0 :      if ( globalIndex != 0 )
   94532             :         {
   94533             : 
   94534             : #if FILE_IO_EXTRA_CHECK
   94535           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNamelistStatement ) ) <= globalIndex ) ;
   94536           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamelistStatement + 1 ) ) );
   94537             : #endif
   94538           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamelistStatement )
   94539           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNamelistStatement );
   94540           0 :           unsigned long positionInPool = localIndex % SgNamelistStatement::pool_size ;
   94541           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamelistStatement::pool_size ;
   94542             : 
   94543             : #if FILE_IO_EXTRA_CHECK
   94544             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   94545             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   94546             : #endif
   94547             : 
   94548           0 :           returnPointer = &( ( (SgNamelistStatement*)(SgNamelistStatement::pools[memoryBlock]) ) [positionInPool]) ;
   94549             : 
   94550             : #if FILE_IO_EXTRA_CHECK
   94551           0 :           assert ( returnPointer != NULL ) ;
   94552             : #endif
   94553             :         }
   94554           0 :      return returnPointer ;
   94555             :    }
   94556             : 
   94557             : //############################################################################
   94558             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   94559             :  * pool size! We set for every valid object in the memory pool the freepointer
   94560             :  * to the global index and increase the global index afterwards. For all the 
   94561             :  * invalid objects (means address ranges within the memory pool that were not
   94562             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   94563             :  * distinguish valid from invalid objects! 
   94564             :  */
   94565             : unsigned long
   94566           5 : SgNamelistStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   94567             :    {
   94568           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   94569           5 :      SgNamelistStatement* pointer = NULL;
   94570           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   94571           5 :      std::vector < unsigned char* > :: const_iterator block;
   94572           5 :      for ( block = SgNamelistStatement::pools.begin(); block != SgNamelistStatement::pools.end() ; ++block )
   94573             :         {
   94574           0 :           pointer = (SgNamelistStatement*)(*block);
   94575           0 :           for (unsigned i = 0; i < SgNamelistStatement::pool_size; ++i )
   94576             :              {
   94577             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   94578             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   94579             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   94580             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   94581             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   94582             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   94583             :             // properly; so this will have to be checked next.
   94584             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   94585             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   94586           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   94587             :                   {
   94588           0 :                     pointer[i].set_freepointer((SgNamelistStatement*)(globalIndex));
   94589           0 :                     globalIndex++;
   94590             :                   }
   94591             :                else
   94592             :                   {
   94593           0 :                     pointer[i].set_freepointer(NULL);
   94594             :                   }
   94595             :               }
   94596             :         }
   94597           5 :      return globalIndex;
   94598             :    }
   94599             : 
   94600             : //############################################################################
   94601             : // JH (01/14/2006)
   94602             : void
   94603           5 : SgNamelistStatement::resetValidFreepointers( )
   94604             :    {
   94605           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   94606           5 :      SgNamelistStatement* pointer = NULL;
   94607           5 :      std::vector < unsigned char* > :: const_iterator block;
   94608           5 :      SgNamelistStatement* pointerOfLinkedList = NULL;
   94609           5 :      for ( block = SgNamelistStatement::pools.begin(); block != SgNamelistStatement::pools.end() ; ++block )
   94610             :         {
   94611           0 :           pointer = (SgNamelistStatement*)(*block);
   94612           0 :           for (unsigned i = 0; i < SgNamelistStatement::pool_size; ++i )
   94613             :              {
   94614             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   94615             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   94616             :             // memory blocks!.
   94617           0 :                if ( pointer[i].get_freepointer() != NULL )
   94618             :                   {
   94619           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   94620             :                   }
   94621             :                else
   94622             :                   {
   94623           0 :                     if ( pointerOfLinkedList == NULL )
   94624             :                        {
   94625           0 :                          SgNamelistStatement::next_node = &(pointer[i]);
   94626             :                        }
   94627             :                     else
   94628             :                        {
   94629             :                       // printf ("In SgNamelistStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   94630           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   94631             :                        }
   94632             :                     pointerOfLinkedList = &(pointer[i]);
   94633             :                   }
   94634             :               }
   94635             :         }
   94636             : 
   94637           5 :      if ( pointerOfLinkedList != NULL )
   94638             :         {
   94639             :        // printf ("In SgNamelistStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   94640           0 :           pointerOfLinkedList->set_freepointer(NULL);
   94641             :        // DQ (6/6/2010): Temporary debugging...
   94642             :        //   ROSE_ASSERT(false);
   94643             :         }
   94644             : 
   94645           5 :      return ;
   94646             :    }
   94647             : 
   94648             : //############################################################################
   94649             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   94650             :  * within the memory pool and resets the freepointers, in order to achieve a 
   94651             :  * linked list, that has no jumps and starts at the beginning! This function 
   94652             :  * does not extend the memory pool, since we do not delete any memory blocks,
   94653             :  * but delete the valid objects.  
   94654             :  */
   94655             : void
   94656           0 : SgNamelistStatement::clearMemoryPool( )
   94657             :    {
   94658             :   // printf ("Inside of SgNamelistStatement::clearMemoryPool() \n");
   94659             : 
   94660           0 :      SgNamelistStatement* pointer = NULL, *tempPointer = NULL;
   94661           0 :      std::vector < unsigned char* > :: const_iterator block;
   94662           0 :      if ( SgNamelistStatement::pools.empty() == false )
   94663             :         {
   94664           0 :           block = SgNamelistStatement::pools.begin() ;
   94665           0 :           SgNamelistStatement::next_node = (SgNamelistStatement*) (*block);
   94666             : 
   94667           0 :           while ( block != SgNamelistStatement::pools.end() )
   94668             :              {
   94669           0 :                pointer = (SgNamelistStatement*) (*block);
   94670           0 :                if ( tempPointer != NULL )
   94671             :                   {
   94672           0 :                     tempPointer->set_freepointer(pointer);
   94673             :                   }
   94674           0 :                for (unsigned i = 0; i < SgNamelistStatement::pool_size - 1; ++i)
   94675             :                   {
   94676           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   94677             :                   }
   94678           0 :                 pointer[SgNamelistStatement::pool_size-1].set_freepointer(NULL);
   94679           0 :                 tempPointer = &(pointer[SgNamelistStatement::pool_size-1]);
   94680           0 :                 ++block;
   94681             :              }
   94682             :         }
   94683           0 :    }
   94684             : 
   94685           5 : void SgNamelistStatement::deleteMemoryPool() {
   94686           5 :   for (auto p: SgNamelistStatement::pools) {
   94687           0 :     ROSE_FREE(p);
   94688             :   }
   94689           5 :   SgNamelistStatement::next_node = nullptr;
   94690           5 :   SgNamelistStatement::pools.clear();
   94691           5 : }
   94692             : 
   94693             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   94694             : //                 reading multiple binary files to for a single AST.
   94695             : /////////// new version ////////////////////////////////
   94696             : //############################################################################
   94697             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   94698             : void
   94699           2 : SgNamelistStatement::extendMemoryPoolForFileIO( )
   94700             :   {
   94701           2 :     size_t blockIndex = SgNamelistStatement::pools.size();
   94702           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNamelistStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamelistStatement);
   94703             : 
   94704           2 :     while ( (blockIndex * SgNamelistStatement::pool_size) < newPoolSize)
   94705             :       {
   94706             : #if ROSE_ALLOC_TRACE
   94707             :         if (blockIndex > 0) {
   94708             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNamelistStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamelistStatement) = %" PRIuPTR " SgNamelistStatement::pool_size = %d \n",
   94709             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNamelistStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamelistStatement),SgNamelistStatement::pool_size);
   94710             :         }
   94711             : #endif
   94712             : 
   94713           0 :         SgNamelistStatement * pointer = (SgNamelistStatement*) ROSE_MALLOC ( SgNamelistStatement::pool_size * sizeof(SgNamelistStatement) );
   94714           0 :         assert( pointer != NULL );
   94715             : #if ROSE_ALLOC_MEMSET == 1
   94716             :         memset(pointer, 0x00, SgNamelistStatement::pool_size * sizeof(SgNamelistStatement));
   94717             : #elif ROSE_ALLOC_MEMSET == 2
   94718             :         memset(pointer, 0xCC, SgNamelistStatement::pool_size * sizeof(SgNamelistStatement));
   94719             : #endif
   94720           0 :         SgNamelistStatement::pools.push_back( (unsigned char*)(pointer) );
   94721           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNamelistStatement::pool_size * sizeof(SgNamelistStatement), V_SgNamelistStatement ) );
   94722             : 
   94723           0 :         if ( SgNamelistStatement::next_node != NULL ) {
   94724           0 :           if ( blockIndex > 0 ) {
   94725           0 :             SgNamelistStatement * blkptr = (SgNamelistStatement*)(SgNamelistStatement::pools[blockIndex-1]);
   94726           0 :             blkptr[ SgNamelistStatement::pool_size - 1 ].set_freepointer(pointer);
   94727             :           }
   94728             :         } else {
   94729           0 :           SgNamelistStatement::next_node = pointer;
   94730             :         }
   94731             : 
   94732           0 :         for (unsigned i = 0; i < SgNamelistStatement::pool_size-1; ++i)
   94733             :            {
   94734           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   94735             :            }
   94736           0 :         pointer[ SgNamelistStatement::pool_size -1 ].set_freepointer(NULL);
   94737             : 
   94738           0 :         blockIndex++;
   94739             :       }
   94740           2 :   }
   94741             : 
   94742             : //############################################################################
   94743             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   94744             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   94745             :  * not compressed. However, that stuff is not yet implemented! 
   94746             :  */
   94747             : unsigned long
   94748           0 : SgNamelistStatement::getNumberOfLastValidPointer()
   94749             :    {
   94750           0 :       SgNamelistStatement* testPointer = (SgNamelistStatement*)(SgNamelistStatement::pools.back());
   94751           0 :       unsigned long localIndex = SgNamelistStatement::pool_size - 1;
   94752           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   94753             :          {
   94754           0 :            localIndex--;
   94755             :          }
   94756           0 :       return (localIndex + SgNamelistStatement::pool_size * (SgNamelistStatement::pools.size()-1));
   94757             :    }
   94758             : 
   94759             : //############################################################################
   94760             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   94761             :  * memory pool and initializes the data member in class SgNamelistStatementStroageClass
   94762             :  * from its counterpart of SgNamelistStatement. The return value is just for checking, 
   94763             :  * that the whole StorageClassArray is initialized!
   94764             :  */
   94765             : unsigned long
   94766           0 : SgNamelistStatement::initializeStorageClassArray( SgNamelistStatementStorageClass *storageArray )
   94767             :    {
   94768           0 :      unsigned long storageCounter = 0;
   94769           0 :      std::vector < unsigned char* > :: const_iterator block = SgNamelistStatement::pools.begin();
   94770           0 :      SgNamelistStatement* pointer = NULL;
   94771           0 :      while ( block != SgNamelistStatement::pools.end() ) {
   94772           0 :           pointer = (SgNamelistStatement*) (*block);
   94773           0 :           for ( unsigned i = 0; i < SgNamelistStatement::pool_size; ++i ) {
   94774           0 :                if ( pointer->get_freepointer() != NULL ) {
   94775           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   94776           0 :                  storageArray++;
   94777           0 :                  storageCounter++;
   94778             :                }
   94779           0 :                pointer++;
   94780             :              }
   94781           0 :            block++;
   94782             :         }
   94783           0 :      return storageCounter;
   94784             :    }
   94785             : 
   94786             : /* #line 94787 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   94787             : 
   94788             : 
   94789             : 
   94790             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   94791             : 
   94792             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   94793             : 
   94794             : //############################################################################
   94795             : /* JH (02/02/2006) Constructor of the IR node SgImportStatement that takes its 
   94796             :  * corresponding StorageClass as parameter
   94797             :  */
   94798           0 : SgImportStatement :: SgImportStatement ( const SgImportStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   94799             :    {
   94800             : 
   94801             : 
   94802             : /* #line 94803 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   94803             : 
   94804           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   94805           0 :      p_import_list = storageSource.storageOf_import_list.rebuildDataStoredInEasyStorageClass() ;
   94806           0 :      SgExpressionPtrList::iterator i_import_list = p_import_list.begin() ; 
   94807           0 :      for ( ; i_import_list != p_import_list.end(); ++i_import_list ) 
   94808             :         {
   94809           0 :           (*i_import_list) = (SgExpressionPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_import_list) ) );
   94810             :         }
   94811             : 
   94812             : 
   94813             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   94814             : 
   94815             : 
   94816           0 :    }
   94817             : 
   94818             : //############################################################################
   94819             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   94820             :  * within the working AST. 
   94821             :  */
   94822           0 : SgImportStatement * SgImportStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   94823           0 :      SgImportStatement* returnPointer = NULL;
   94824           0 :      if ( globalIndex != 0 )
   94825             :         {
   94826             : 
   94827             : #if FILE_IO_EXTRA_CHECK
   94828           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgImportStatement ) ) <= globalIndex ) ;
   94829           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImportStatement + 1 ) ) );
   94830             : #endif
   94831           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImportStatement )  
   94832           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgImportStatement );
   94833           0 :           unsigned long positionInPool = localIndex % SgImportStatement::pool_size;
   94834           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImportStatement::pool_size;
   94835             : 
   94836             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   94837             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   94838             : 
   94839           0 :           returnPointer = &( ( (SgImportStatement*)(SgImportStatement::pools[memoryBlock]) ) [positionInPool]) ;
   94840             : 
   94841           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   94842             :         }
   94843           0 :      return returnPointer ;
   94844             :    }
   94845             : 
   94846             : //############################################################################
   94847             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   94848             :   for the AST with the index astIndex
   94849             : */
   94850           0 : SgImportStatement * SgImportStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   94851           0 :      SgImportStatement* returnPointer = NULL;
   94852           0 :      if ( globalIndex != 0 )
   94853             :         {
   94854             : 
   94855             : #if FILE_IO_EXTRA_CHECK
   94856           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgImportStatement ) ) <= globalIndex ) ;
   94857           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImportStatement + 1 ) ) );
   94858             : #endif
   94859           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImportStatement )
   94860           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgImportStatement );
   94861           0 :           unsigned long positionInPool = localIndex % SgImportStatement::pool_size ;
   94862           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImportStatement::pool_size ;
   94863             : 
   94864             : #if FILE_IO_EXTRA_CHECK
   94865             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   94866             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   94867             : #endif
   94868             : 
   94869           0 :           returnPointer = &( ( (SgImportStatement*)(SgImportStatement::pools[memoryBlock]) ) [positionInPool]) ;
   94870             : 
   94871             : #if FILE_IO_EXTRA_CHECK
   94872           0 :           assert ( returnPointer != NULL ) ;
   94873             : #endif
   94874             :         }
   94875           0 :      return returnPointer ;
   94876             :    }
   94877             : 
   94878             : //############################################################################
   94879             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   94880             :  * pool size! We set for every valid object in the memory pool the freepointer
   94881             :  * to the global index and increase the global index afterwards. For all the 
   94882             :  * invalid objects (means address ranges within the memory pool that were not
   94883             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   94884             :  * distinguish valid from invalid objects! 
   94885             :  */
   94886             : unsigned long
   94887           5 : SgImportStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   94888             :    {
   94889           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   94890           5 :      SgImportStatement* pointer = NULL;
   94891           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   94892           5 :      std::vector < unsigned char* > :: const_iterator block;
   94893           5 :      for ( block = SgImportStatement::pools.begin(); block != SgImportStatement::pools.end() ; ++block )
   94894             :         {
   94895           0 :           pointer = (SgImportStatement*)(*block);
   94896           0 :           for (unsigned i = 0; i < SgImportStatement::pool_size; ++i )
   94897             :              {
   94898             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   94899             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   94900             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   94901             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   94902             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   94903             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   94904             :             // properly; so this will have to be checked next.
   94905             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   94906             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   94907           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   94908             :                   {
   94909           0 :                     pointer[i].set_freepointer((SgImportStatement*)(globalIndex));
   94910           0 :                     globalIndex++;
   94911             :                   }
   94912             :                else
   94913             :                   {
   94914           0 :                     pointer[i].set_freepointer(NULL);
   94915             :                   }
   94916             :               }
   94917             :         }
   94918           5 :      return globalIndex;
   94919             :    }
   94920             : 
   94921             : //############################################################################
   94922             : // JH (01/14/2006)
   94923             : void
   94924           5 : SgImportStatement::resetValidFreepointers( )
   94925             :    {
   94926           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   94927           5 :      SgImportStatement* pointer = NULL;
   94928           5 :      std::vector < unsigned char* > :: const_iterator block;
   94929           5 :      SgImportStatement* pointerOfLinkedList = NULL;
   94930           5 :      for ( block = SgImportStatement::pools.begin(); block != SgImportStatement::pools.end() ; ++block )
   94931             :         {
   94932           0 :           pointer = (SgImportStatement*)(*block);
   94933           0 :           for (unsigned i = 0; i < SgImportStatement::pool_size; ++i )
   94934             :              {
   94935             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   94936             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   94937             :             // memory blocks!.
   94938           0 :                if ( pointer[i].get_freepointer() != NULL )
   94939             :                   {
   94940           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   94941             :                   }
   94942             :                else
   94943             :                   {
   94944           0 :                     if ( pointerOfLinkedList == NULL )
   94945             :                        {
   94946           0 :                          SgImportStatement::next_node = &(pointer[i]);
   94947             :                        }
   94948             :                     else
   94949             :                        {
   94950             :                       // printf ("In SgImportStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   94951           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   94952             :                        }
   94953             :                     pointerOfLinkedList = &(pointer[i]);
   94954             :                   }
   94955             :               }
   94956             :         }
   94957             : 
   94958           5 :      if ( pointerOfLinkedList != NULL )
   94959             :         {
   94960             :        // printf ("In SgImportStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   94961           0 :           pointerOfLinkedList->set_freepointer(NULL);
   94962             :        // DQ (6/6/2010): Temporary debugging...
   94963             :        //   ROSE_ASSERT(false);
   94964             :         }
   94965             : 
   94966           5 :      return ;
   94967             :    }
   94968             : 
   94969             : //############################################################################
   94970             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   94971             :  * within the memory pool and resets the freepointers, in order to achieve a 
   94972             :  * linked list, that has no jumps and starts at the beginning! This function 
   94973             :  * does not extend the memory pool, since we do not delete any memory blocks,
   94974             :  * but delete the valid objects.  
   94975             :  */
   94976             : void
   94977           0 : SgImportStatement::clearMemoryPool( )
   94978             :    {
   94979             :   // printf ("Inside of SgImportStatement::clearMemoryPool() \n");
   94980             : 
   94981           0 :      SgImportStatement* pointer = NULL, *tempPointer = NULL;
   94982           0 :      std::vector < unsigned char* > :: const_iterator block;
   94983           0 :      if ( SgImportStatement::pools.empty() == false )
   94984             :         {
   94985           0 :           block = SgImportStatement::pools.begin() ;
   94986           0 :           SgImportStatement::next_node = (SgImportStatement*) (*block);
   94987             : 
   94988           0 :           while ( block != SgImportStatement::pools.end() )
   94989             :              {
   94990           0 :                pointer = (SgImportStatement*) (*block);
   94991           0 :                if ( tempPointer != NULL )
   94992             :                   {
   94993           0 :                     tempPointer->set_freepointer(pointer);
   94994             :                   }
   94995           0 :                for (unsigned i = 0; i < SgImportStatement::pool_size - 1; ++i)
   94996             :                   {
   94997           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   94998             :                   }
   94999           0 :                 pointer[SgImportStatement::pool_size-1].set_freepointer(NULL);
   95000           0 :                 tempPointer = &(pointer[SgImportStatement::pool_size-1]);
   95001           0 :                 ++block;
   95002             :              }
   95003             :         }
   95004           0 :    }
   95005             : 
   95006           5 : void SgImportStatement::deleteMemoryPool() {
   95007           5 :   for (auto p: SgImportStatement::pools) {
   95008           0 :     ROSE_FREE(p);
   95009             :   }
   95010           5 :   SgImportStatement::next_node = nullptr;
   95011           5 :   SgImportStatement::pools.clear();
   95012           5 : }
   95013             : 
   95014             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   95015             : //                 reading multiple binary files to for a single AST.
   95016             : /////////// new version ////////////////////////////////
   95017             : //############################################################################
   95018             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   95019             : void
   95020           2 : SgImportStatement::extendMemoryPoolForFileIO( )
   95021             :   {
   95022           2 :     size_t blockIndex = SgImportStatement::pools.size();
   95023           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgImportStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgImportStatement);
   95024             : 
   95025           2 :     while ( (blockIndex * SgImportStatement::pool_size) < newPoolSize)
   95026             :       {
   95027             : #if ROSE_ALLOC_TRACE
   95028             :         if (blockIndex > 0) {
   95029             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgImportStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgImportStatement) = %" PRIuPTR " SgImportStatement::pool_size = %d \n",
   95030             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgImportStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgImportStatement),SgImportStatement::pool_size);
   95031             :         }
   95032             : #endif
   95033             : 
   95034           0 :         SgImportStatement * pointer = (SgImportStatement*) ROSE_MALLOC ( SgImportStatement::pool_size * sizeof(SgImportStatement) );
   95035           0 :         assert( pointer != NULL );
   95036             : #if ROSE_ALLOC_MEMSET == 1
   95037             :         memset(pointer, 0x00, SgImportStatement::pool_size * sizeof(SgImportStatement));
   95038             : #elif ROSE_ALLOC_MEMSET == 2
   95039             :         memset(pointer, 0xCC, SgImportStatement::pool_size * sizeof(SgImportStatement));
   95040             : #endif
   95041           0 :         SgImportStatement::pools.push_back( (unsigned char*)(pointer) );
   95042           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgImportStatement::pool_size * sizeof(SgImportStatement), V_SgImportStatement ) );
   95043             : 
   95044           0 :         if ( SgImportStatement::next_node != NULL ) {
   95045           0 :           if ( blockIndex > 0 ) {
   95046           0 :             SgImportStatement * blkptr = (SgImportStatement*)(SgImportStatement::pools[blockIndex-1]);
   95047           0 :             blkptr[ SgImportStatement::pool_size - 1 ].set_freepointer(pointer);
   95048             :           }
   95049             :         } else {
   95050           0 :           SgImportStatement::next_node = pointer;
   95051             :         }
   95052             : 
   95053           0 :         for (unsigned i = 0; i < SgImportStatement::pool_size-1; ++i)
   95054             :            {
   95055           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   95056             :            }
   95057           0 :         pointer[ SgImportStatement::pool_size -1 ].set_freepointer(NULL);
   95058             : 
   95059           0 :         blockIndex++;
   95060             :       }
   95061           2 :   }
   95062             : 
   95063             : //############################################################################
   95064             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   95065             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   95066             :  * not compressed. However, that stuff is not yet implemented! 
   95067             :  */
   95068             : unsigned long
   95069           0 : SgImportStatement::getNumberOfLastValidPointer()
   95070             :    {
   95071           0 :       SgImportStatement* testPointer = (SgImportStatement*)(SgImportStatement::pools.back());
   95072           0 :       unsigned long localIndex = SgImportStatement::pool_size - 1;
   95073           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   95074             :          {
   95075           0 :            localIndex--;
   95076             :          }
   95077           0 :       return (localIndex + SgImportStatement::pool_size * (SgImportStatement::pools.size()-1));
   95078             :    }
   95079             : 
   95080             : //############################################################################
   95081             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   95082             :  * memory pool and initializes the data member in class SgImportStatementStroageClass
   95083             :  * from its counterpart of SgImportStatement. The return value is just for checking, 
   95084             :  * that the whole StorageClassArray is initialized!
   95085             :  */
   95086             : unsigned long
   95087           0 : SgImportStatement::initializeStorageClassArray( SgImportStatementStorageClass *storageArray )
   95088             :    {
   95089           0 :      unsigned long storageCounter = 0;
   95090           0 :      std::vector < unsigned char* > :: const_iterator block = SgImportStatement::pools.begin();
   95091           0 :      SgImportStatement* pointer = NULL;
   95092           0 :      while ( block != SgImportStatement::pools.end() ) {
   95093           0 :           pointer = (SgImportStatement*) (*block);
   95094           0 :           for ( unsigned i = 0; i < SgImportStatement::pool_size; ++i ) {
   95095           0 :                if ( pointer->get_freepointer() != NULL ) {
   95096           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   95097           0 :                  storageArray++;
   95098           0 :                  storageCounter++;
   95099             :                }
   95100           0 :                pointer++;
   95101             :              }
   95102           0 :            block++;
   95103             :         }
   95104           0 :      return storageCounter;
   95105             :    }
   95106             : 
   95107             : /* #line 95108 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   95108             : 
   95109             : 
   95110             : 
   95111             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   95112             : 
   95113             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   95114             : 
   95115             : //############################################################################
   95116             : /* JH (02/02/2006) Constructor of the IR node SgFunctionDeclaration that takes its 
   95117             :  * corresponding StorageClass as parameter
   95118             :  */
   95119       13303 : SgFunctionDeclaration :: SgFunctionDeclaration ( const SgFunctionDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   95120             :    {
   95121             : 
   95122             : 
   95123             : /* #line 95124 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   95124             : 
   95125       13303 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   95126       13303 :      p_name = SgName ( storageSource.storageOf_name ) ;
   95127       13303 :      p_parameterList =  (SgFunctionParameterList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parameterList) );
   95128       13303 :      p_functionModifier = SgFunctionModifier ( storageSource.storageOf_functionModifier ) ;
   95129       13303 :      p_specialFunctionModifier = SgSpecialFunctionModifier ( storageSource.storageOf_specialFunctionModifier ) ;
   95130       13303 :      p_exceptionSpecification = storageSource.storageOf_exceptionSpecification.rebuildDataStoredInEasyStorageClass() ;
   95131       13303 :      SgTypePtrList::iterator i_exceptionSpecification = p_exceptionSpecification.begin() ; 
   95132       13303 :      for ( ; i_exceptionSpecification != p_exceptionSpecification.end(); ++i_exceptionSpecification ) 
   95133             :         {
   95134           0 :           (*i_exceptionSpecification) = (SgTypePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_exceptionSpecification) ) );
   95135             :         }
   95136       13303 :      p_named_in_end_statement = storageSource.storageOf_named_in_end_statement ;
   95137       13303 :      p_asm_name = storageSource.storageOf_asm_name.rebuildDataStoredInEasyStorageClass() ;
   95138       13303 :      p_decoratorList =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_decoratorList) );
   95139       13303 :      p_ada_formal_subprogram_decl = storageSource.storageOf_ada_formal_subprogram_decl ;
   95140       13303 :      p_type =  (SgFunctionType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
   95141       13303 :      p_definition =  (SgFunctionDefinition*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_definition) );
   95142       13303 :      p_oldStyleDefinition = storageSource.storageOf_oldStyleDefinition ;
   95143       13303 :      p_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scope) );
   95144       13303 :      p_specialization = storageSource.storageOf_specialization ;
   95145       13303 :      p_requiresNameQualificationOnReturnType = storageSource.storageOf_requiresNameQualificationOnReturnType ;
   95146       13303 :      p_gnu_extension_section = storageSource.storageOf_gnu_extension_section.rebuildDataStoredInEasyStorageClass() ;
   95147       13303 :      p_gnu_extension_alias = storageSource.storageOf_gnu_extension_alias.rebuildDataStoredInEasyStorageClass() ;
   95148       13303 :      p_gnu_extension_visability = storageSource.storageOf_gnu_extension_visability ;
   95149       13303 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
   95150       13303 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
   95151       13303 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
   95152       13303 :      p_name_qualification_length_for_return_type = storageSource.storageOf_name_qualification_length_for_return_type ;
   95153       13303 :      p_type_elaboration_required_for_return_type = storageSource.storageOf_type_elaboration_required_for_return_type ;
   95154       13303 :      p_global_qualification_required_for_return_type = storageSource.storageOf_global_qualification_required_for_return_type ;
   95155       13303 :      p_prototypeIsWithoutParameters = storageSource.storageOf_prototypeIsWithoutParameters ;
   95156       13303 :      p_gnu_regparm_attribute = storageSource.storageOf_gnu_regparm_attribute ;
   95157       13303 :      p_type_syntax =  (SgFunctionType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type_syntax) );
   95158       13303 :      p_type_syntax_is_available = storageSource.storageOf_type_syntax_is_available ;
   95159       13303 :      p_parameterList_syntax =  (SgFunctionParameterList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parameterList_syntax) );
   95160       13303 :      p_using_C11_Noreturn_keyword = storageSource.storageOf_using_C11_Noreturn_keyword ;
   95161       13303 :      p_is_constexpr = storageSource.storageOf_is_constexpr ;
   95162       13303 :      p_using_new_function_return_type_syntax = storageSource.storageOf_using_new_function_return_type_syntax ;
   95163       13303 :      p_functionParameterScope =  (SgFunctionParameterScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_functionParameterScope) );
   95164       13303 :      p_marked_as_edg_normalization = storageSource.storageOf_marked_as_edg_normalization ;
   95165       13303 :      p_is_implicit_function = storageSource.storageOf_is_implicit_function ;
   95166             : 
   95167             : 
   95168             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   95169             : 
   95170             : 
   95171       13303 :    }
   95172             : 
   95173             : //############################################################################
   95174             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   95175             :  * within the working AST. 
   95176             :  */
   95177       74714 : SgFunctionDeclaration * SgFunctionDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   95178       74714 :      SgFunctionDeclaration* returnPointer = NULL;
   95179       74714 :      if ( globalIndex != 0 )
   95180             :         {
   95181             : 
   95182             : #if FILE_IO_EXTRA_CHECK
   95183       74714 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionDeclaration ) ) <= globalIndex ) ;
   95184       74714 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionDeclaration + 1 ) ) );
   95185             : #endif
   95186       74714 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionDeclaration )  
   95187       74714 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionDeclaration );
   95188       74714 :           unsigned long positionInPool = localIndex % SgFunctionDeclaration::pool_size;
   95189       74714 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionDeclaration::pool_size;
   95190             : 
   95191             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   95192             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   95193             : 
   95194       74714 :           returnPointer = &( ( (SgFunctionDeclaration*)(SgFunctionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   95195             : 
   95196       74714 :           ROSE_ASSERT( returnPointer != NULL ) ;
   95197             :         }
   95198       74714 :      return returnPointer ;
   95199             :    }
   95200             : 
   95201             : //############################################################################
   95202             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   95203             :   for the AST with the index astIndex
   95204             : */
   95205           0 : SgFunctionDeclaration * SgFunctionDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   95206           0 :      SgFunctionDeclaration* returnPointer = NULL;
   95207           0 :      if ( globalIndex != 0 )
   95208             :         {
   95209             : 
   95210             : #if FILE_IO_EXTRA_CHECK
   95211           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionDeclaration ) ) <= globalIndex ) ;
   95212           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionDeclaration + 1 ) ) );
   95213             : #endif
   95214           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionDeclaration )
   95215           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionDeclaration );
   95216           0 :           unsigned long positionInPool = localIndex % SgFunctionDeclaration::pool_size ;
   95217           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionDeclaration::pool_size ;
   95218             : 
   95219             : #if FILE_IO_EXTRA_CHECK
   95220             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   95221             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   95222             : #endif
   95223             : 
   95224           0 :           returnPointer = &( ( (SgFunctionDeclaration*)(SgFunctionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   95225             : 
   95226             : #if FILE_IO_EXTRA_CHECK
   95227           0 :           assert ( returnPointer != NULL ) ;
   95228             : #endif
   95229             :         }
   95230           0 :      return returnPointer ;
   95231             :    }
   95232             : 
   95233             : //############################################################################
   95234             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   95235             :  * pool size! We set for every valid object in the memory pool the freepointer
   95236             :  * to the global index and increase the global index afterwards. For all the 
   95237             :  * invalid objects (means address ranges within the memory pool that were not
   95238             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   95239             :  * distinguish valid from invalid objects! 
   95240             :  */
   95241             : unsigned long
   95242           5 : SgFunctionDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   95243             :    {
   95244           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   95245           5 :      SgFunctionDeclaration* pointer = NULL;
   95246           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   95247           5 :      std::vector < unsigned char* > :: const_iterator block;
   95248          10 :      for ( block = SgFunctionDeclaration::pools.begin(); block != SgFunctionDeclaration::pools.end() ; ++block )
   95249             :         {
   95250           5 :           pointer = (SgFunctionDeclaration*)(*block);
   95251       10005 :           for (unsigned i = 0; i < SgFunctionDeclaration::pool_size; ++i )
   95252             :              {
   95253             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   95254             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   95255             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   95256             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   95257             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   95258             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   95259             :             // properly; so this will have to be checked next.
   95260             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   95261             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   95262       10000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   95263             :                   {
   95264        7916 :                     pointer[i].set_freepointer((SgFunctionDeclaration*)(globalIndex));
   95265        7916 :                     globalIndex++;
   95266             :                   }
   95267             :                else
   95268             :                   {
   95269        2084 :                     pointer[i].set_freepointer(NULL);
   95270             :                   }
   95271             :               }
   95272             :         }
   95273           5 :      return globalIndex;
   95274             :    }
   95275             : 
   95276             : //############################################################################
   95277             : // JH (01/14/2006)
   95278             : void
   95279           5 : SgFunctionDeclaration::resetValidFreepointers( )
   95280             :    {
   95281           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   95282           5 :      SgFunctionDeclaration* pointer = NULL;
   95283           5 :      std::vector < unsigned char* > :: const_iterator block;
   95284           5 :      SgFunctionDeclaration* pointerOfLinkedList = NULL;
   95285          10 :      for ( block = SgFunctionDeclaration::pools.begin(); block != SgFunctionDeclaration::pools.end() ; ++block )
   95286             :         {
   95287           5 :           pointer = (SgFunctionDeclaration*)(*block);
   95288       10005 :           for (unsigned i = 0; i < SgFunctionDeclaration::pool_size; ++i )
   95289             :              {
   95290             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   95291             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   95292             :             // memory blocks!.
   95293       10000 :                if ( pointer[i].get_freepointer() != NULL )
   95294             :                   {
   95295        7916 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   95296             :                   }
   95297             :                else
   95298             :                   {
   95299        2084 :                     if ( pointerOfLinkedList == NULL )
   95300             :                        {
   95301           2 :                          SgFunctionDeclaration::next_node = &(pointer[i]);
   95302             :                        }
   95303             :                     else
   95304             :                        {
   95305             :                       // printf ("In SgFunctionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   95306        2082 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   95307             :                        }
   95308             :                     pointerOfLinkedList = &(pointer[i]);
   95309             :                   }
   95310             :               }
   95311             :         }
   95312             : 
   95313           5 :      if ( pointerOfLinkedList != NULL )
   95314             :         {
   95315             :        // printf ("In SgFunctionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   95316           2 :           pointerOfLinkedList->set_freepointer(NULL);
   95317             :        // DQ (6/6/2010): Temporary debugging...
   95318             :        //   ROSE_ASSERT(false);
   95319             :         }
   95320             : 
   95321           5 :      return ;
   95322             :    }
   95323             : 
   95324             : //############################################################################
   95325             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   95326             :  * within the memory pool and resets the freepointers, in order to achieve a 
   95327             :  * linked list, that has no jumps and starts at the beginning! This function 
   95328             :  * does not extend the memory pool, since we do not delete any memory blocks,
   95329             :  * but delete the valid objects.  
   95330             :  */
   95331             : void
   95332           0 : SgFunctionDeclaration::clearMemoryPool( )
   95333             :    {
   95334             :   // printf ("Inside of SgFunctionDeclaration::clearMemoryPool() \n");
   95335             : 
   95336           0 :      SgFunctionDeclaration* pointer = NULL, *tempPointer = NULL;
   95337           0 :      std::vector < unsigned char* > :: const_iterator block;
   95338           0 :      if ( SgFunctionDeclaration::pools.empty() == false )
   95339             :         {
   95340           0 :           block = SgFunctionDeclaration::pools.begin() ;
   95341           0 :           SgFunctionDeclaration::next_node = (SgFunctionDeclaration*) (*block);
   95342             : 
   95343           0 :           while ( block != SgFunctionDeclaration::pools.end() )
   95344             :              {
   95345           0 :                pointer = (SgFunctionDeclaration*) (*block);
   95346           0 :                if ( tempPointer != NULL )
   95347             :                   {
   95348           0 :                     tempPointer->set_freepointer(pointer);
   95349             :                   }
   95350           0 :                for (unsigned i = 0; i < SgFunctionDeclaration::pool_size - 1; ++i)
   95351             :                   {
   95352           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   95353             :                   }
   95354           0 :                 pointer[SgFunctionDeclaration::pool_size-1].set_freepointer(NULL);
   95355           0 :                 tempPointer = &(pointer[SgFunctionDeclaration::pool_size-1]);
   95356           0 :                 ++block;
   95357             :              }
   95358             :         }
   95359           0 :    }
   95360             : 
   95361           5 : void SgFunctionDeclaration::deleteMemoryPool() {
   95362          15 :   for (auto p: SgFunctionDeclaration::pools) {
   95363          10 :     ROSE_FREE(p);
   95364             :   }
   95365           5 :   SgFunctionDeclaration::next_node = nullptr;
   95366           5 :   SgFunctionDeclaration::pools.clear();
   95367           5 : }
   95368             : 
   95369             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   95370             : //                 reading multiple binary files to for a single AST.
   95371             : /////////// new version ////////////////////////////////
   95372             : //############################################################################
   95373             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   95374             : void
   95375           2 : SgFunctionDeclaration::extendMemoryPoolForFileIO( )
   95376             :   {
   95377           2 :     size_t blockIndex = SgFunctionDeclaration::pools.size();
   95378           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionDeclaration);
   95379             : 
   95380           7 :     while ( (blockIndex * SgFunctionDeclaration::pool_size) < newPoolSize)
   95381             :       {
   95382             : #if ROSE_ALLOC_TRACE
   95383             :         if (blockIndex > 0) {
   95384             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionDeclaration) = %" PRIuPTR " SgFunctionDeclaration::pool_size = %d \n",
   95385             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionDeclaration),SgFunctionDeclaration::pool_size);
   95386             :         }
   95387             : #endif
   95388             : 
   95389           5 :         SgFunctionDeclaration * pointer = (SgFunctionDeclaration*) ROSE_MALLOC ( SgFunctionDeclaration::pool_size * sizeof(SgFunctionDeclaration) );
   95390           5 :         assert( pointer != NULL );
   95391             : #if ROSE_ALLOC_MEMSET == 1
   95392             :         memset(pointer, 0x00, SgFunctionDeclaration::pool_size * sizeof(SgFunctionDeclaration));
   95393             : #elif ROSE_ALLOC_MEMSET == 2
   95394             :         memset(pointer, 0xCC, SgFunctionDeclaration::pool_size * sizeof(SgFunctionDeclaration));
   95395             : #endif
   95396           5 :         SgFunctionDeclaration::pools.push_back( (unsigned char*)(pointer) );
   95397           5 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionDeclaration::pool_size * sizeof(SgFunctionDeclaration), V_SgFunctionDeclaration ) );
   95398             : 
   95399           5 :         if ( SgFunctionDeclaration::next_node != NULL ) {
   95400           3 :           if ( blockIndex > 0 ) {
   95401           3 :             SgFunctionDeclaration * blkptr = (SgFunctionDeclaration*)(SgFunctionDeclaration::pools[blockIndex-1]);
   95402           3 :             blkptr[ SgFunctionDeclaration::pool_size - 1 ].set_freepointer(pointer);
   95403             :           }
   95404             :         } else {
   95405           2 :           SgFunctionDeclaration::next_node = pointer;
   95406             :         }
   95407             : 
   95408       10000 :         for (unsigned i = 0; i < SgFunctionDeclaration::pool_size-1; ++i)
   95409             :            {
   95410        9995 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   95411             :            }
   95412           5 :         pointer[ SgFunctionDeclaration::pool_size -1 ].set_freepointer(NULL);
   95413             : 
   95414           5 :         blockIndex++;
   95415             :       }
   95416           2 :   }
   95417             : 
   95418             : //############################################################################
   95419             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   95420             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   95421             :  * not compressed. However, that stuff is not yet implemented! 
   95422             :  */
   95423             : unsigned long
   95424           0 : SgFunctionDeclaration::getNumberOfLastValidPointer()
   95425             :    {
   95426           0 :       SgFunctionDeclaration* testPointer = (SgFunctionDeclaration*)(SgFunctionDeclaration::pools.back());
   95427           0 :       unsigned long localIndex = SgFunctionDeclaration::pool_size - 1;
   95428           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   95429             :          {
   95430           0 :            localIndex--;
   95431             :          }
   95432           0 :       return (localIndex + SgFunctionDeclaration::pool_size * (SgFunctionDeclaration::pools.size()-1));
   95433             :    }
   95434             : 
   95435             : //############################################################################
   95436             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   95437             :  * memory pool and initializes the data member in class SgFunctionDeclarationStroageClass
   95438             :  * from its counterpart of SgFunctionDeclaration. The return value is just for checking, 
   95439             :  * that the whole StorageClassArray is initialized!
   95440             :  */
   95441             : unsigned long
   95442           2 : SgFunctionDeclaration::initializeStorageClassArray( SgFunctionDeclarationStorageClass *storageArray )
   95443             :    {
   95444           2 :      unsigned long storageCounter = 0;
   95445           2 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionDeclaration::pools.begin();
   95446           2 :      SgFunctionDeclaration* pointer = NULL;
   95447           7 :      while ( block != SgFunctionDeclaration::pools.end() ) {
   95448           5 :           pointer = (SgFunctionDeclaration*) (*block);
   95449       10005 :           for ( unsigned i = 0; i < SgFunctionDeclaration::pool_size; ++i ) {
   95450       10000 :                if ( pointer->get_freepointer() != NULL ) {
   95451        7916 :                  storageArray->pickOutIRNodeData (pointer) ;
   95452        7916 :                  storageArray++;
   95453        7916 :                  storageCounter++;
   95454             :                }
   95455       10000 :                pointer++;
   95456             :              }
   95457           5 :            block++;
   95458             :         }
   95459           2 :      return storageCounter;
   95460             :    }
   95461             : 
   95462             : /* #line 95463 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   95463             : 
   95464             : 
   95465             : 
   95466             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   95467             : 
   95468             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   95469             : 
   95470             : //############################################################################
   95471             : /* JH (02/02/2006) Constructor of the IR node SgTemplateFunctionDeclaration that takes its 
   95472             :  * corresponding StorageClass as parameter
   95473             :  */
   95474         676 : SgTemplateFunctionDeclaration :: SgTemplateFunctionDeclaration ( const SgTemplateFunctionDeclarationStorageClass& storageSource )   : SgFunctionDeclaration (storageSource)
   95475             :    {
   95476             : 
   95477             : 
   95478             : /* #line 95479 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   95479             : 
   95480         676 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   95481         676 :      p_templateParameters = storageSource.storageOf_templateParameters.rebuildDataStoredInEasyStorageClass() ;
   95482         676 :      SgTemplateParameterPtrList::iterator i_templateParameters = p_templateParameters.begin() ; 
   95483        1866 :      for ( ; i_templateParameters != p_templateParameters.end(); ++i_templateParameters ) 
   95484             :         {
   95485        1190 :           (*i_templateParameters) = (SgTemplateParameterPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateParameters) ) );
   95486             :         }
   95487         676 :      p_templateSpecializationArguments = storageSource.storageOf_templateSpecializationArguments.rebuildDataStoredInEasyStorageClass() ;
   95488         676 :      SgTemplateArgumentPtrList::iterator i_templateSpecializationArguments = p_templateSpecializationArguments.begin() ; 
   95489         676 :      for ( ; i_templateSpecializationArguments != p_templateSpecializationArguments.end(); ++i_templateSpecializationArguments ) 
   95490             :         {
   95491           0 :           (*i_templateSpecializationArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateSpecializationArguments) ) );
   95492             :         }
   95493         676 :      p_string = SgName ( storageSource.storageOf_string ) ;
   95494         676 :      p_string_represents_function_body = storageSource.storageOf_string_represents_function_body ;
   95495         676 :      p_nonreal_decl_scope =  (SgDeclarationScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nonreal_decl_scope) );
   95496             : 
   95497             : 
   95498             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   95499             : 
   95500             : 
   95501         676 :    }
   95502             : 
   95503             : //############################################################################
   95504             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   95505             :  * within the working AST. 
   95506             :  */
   95507        7172 : SgTemplateFunctionDeclaration * SgTemplateFunctionDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   95508        7172 :      SgTemplateFunctionDeclaration* returnPointer = NULL;
   95509        7172 :      if ( globalIndex != 0 )
   95510             :         {
   95511             : 
   95512             : #if FILE_IO_EXTRA_CHECK
   95513        7172 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateFunctionDeclaration ) ) <= globalIndex ) ;
   95514        7172 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateFunctionDeclaration + 1 ) ) );
   95515             : #endif
   95516        7172 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateFunctionDeclaration )  
   95517        7172 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateFunctionDeclaration );
   95518        7172 :           unsigned long positionInPool = localIndex % SgTemplateFunctionDeclaration::pool_size;
   95519        7172 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateFunctionDeclaration::pool_size;
   95520             : 
   95521             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   95522             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   95523             : 
   95524        7172 :           returnPointer = &( ( (SgTemplateFunctionDeclaration*)(SgTemplateFunctionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   95525             : 
   95526        7172 :           ROSE_ASSERT( returnPointer != NULL ) ;
   95527             :         }
   95528        7172 :      return returnPointer ;
   95529             :    }
   95530             : 
   95531             : //############################################################################
   95532             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   95533             :   for the AST with the index astIndex
   95534             : */
   95535           0 : SgTemplateFunctionDeclaration * SgTemplateFunctionDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   95536           0 :      SgTemplateFunctionDeclaration* returnPointer = NULL;
   95537           0 :      if ( globalIndex != 0 )
   95538             :         {
   95539             : 
   95540             : #if FILE_IO_EXTRA_CHECK
   95541           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateFunctionDeclaration ) ) <= globalIndex ) ;
   95542           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateFunctionDeclaration + 1 ) ) );
   95543             : #endif
   95544           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateFunctionDeclaration )
   95545           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateFunctionDeclaration );
   95546           0 :           unsigned long positionInPool = localIndex % SgTemplateFunctionDeclaration::pool_size ;
   95547           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateFunctionDeclaration::pool_size ;
   95548             : 
   95549             : #if FILE_IO_EXTRA_CHECK
   95550             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   95551             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   95552             : #endif
   95553             : 
   95554           0 :           returnPointer = &( ( (SgTemplateFunctionDeclaration*)(SgTemplateFunctionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   95555             : 
   95556             : #if FILE_IO_EXTRA_CHECK
   95557           0 :           assert ( returnPointer != NULL ) ;
   95558             : #endif
   95559             :         }
   95560           0 :      return returnPointer ;
   95561             :    }
   95562             : 
   95563             : //############################################################################
   95564             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   95565             :  * pool size! We set for every valid object in the memory pool the freepointer
   95566             :  * to the global index and increase the global index afterwards. For all the 
   95567             :  * invalid objects (means address ranges within the memory pool that were not
   95568             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   95569             :  * distinguish valid from invalid objects! 
   95570             :  */
   95571             : unsigned long
   95572           5 : SgTemplateFunctionDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   95573             :    {
   95574           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   95575           5 :      SgTemplateFunctionDeclaration* pointer = NULL;
   95576           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   95577           5 :      std::vector < unsigned char* > :: const_iterator block;
   95578           6 :      for ( block = SgTemplateFunctionDeclaration::pools.begin(); block != SgTemplateFunctionDeclaration::pools.end() ; ++block )
   95579             :         {
   95580           1 :           pointer = (SgTemplateFunctionDeclaration*)(*block);
   95581        2001 :           for (unsigned i = 0; i < SgTemplateFunctionDeclaration::pool_size; ++i )
   95582             :              {
   95583             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   95584             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   95585             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   95586             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   95587             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   95588             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   95589             :             // properly; so this will have to be checked next.
   95590             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   95591             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   95592        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   95593             :                   {
   95594         676 :                     pointer[i].set_freepointer((SgTemplateFunctionDeclaration*)(globalIndex));
   95595         676 :                     globalIndex++;
   95596             :                   }
   95597             :                else
   95598             :                   {
   95599        1324 :                     pointer[i].set_freepointer(NULL);
   95600             :                   }
   95601             :               }
   95602             :         }
   95603           5 :      return globalIndex;
   95604             :    }
   95605             : 
   95606             : //############################################################################
   95607             : // JH (01/14/2006)
   95608             : void
   95609           5 : SgTemplateFunctionDeclaration::resetValidFreepointers( )
   95610             :    {
   95611           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   95612           5 :      SgTemplateFunctionDeclaration* pointer = NULL;
   95613           5 :      std::vector < unsigned char* > :: const_iterator block;
   95614           5 :      SgTemplateFunctionDeclaration* pointerOfLinkedList = NULL;
   95615           6 :      for ( block = SgTemplateFunctionDeclaration::pools.begin(); block != SgTemplateFunctionDeclaration::pools.end() ; ++block )
   95616             :         {
   95617           1 :           pointer = (SgTemplateFunctionDeclaration*)(*block);
   95618        2001 :           for (unsigned i = 0; i < SgTemplateFunctionDeclaration::pool_size; ++i )
   95619             :              {
   95620             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   95621             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   95622             :             // memory blocks!.
   95623        2000 :                if ( pointer[i].get_freepointer() != NULL )
   95624             :                   {
   95625         676 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   95626             :                   }
   95627             :                else
   95628             :                   {
   95629        1324 :                     if ( pointerOfLinkedList == NULL )
   95630             :                        {
   95631           1 :                          SgTemplateFunctionDeclaration::next_node = &(pointer[i]);
   95632             :                        }
   95633             :                     else
   95634             :                        {
   95635             :                       // printf ("In SgTemplateFunctionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   95636        1323 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   95637             :                        }
   95638             :                     pointerOfLinkedList = &(pointer[i]);
   95639             :                   }
   95640             :               }
   95641             :         }
   95642             : 
   95643           5 :      if ( pointerOfLinkedList != NULL )
   95644             :         {
   95645             :        // printf ("In SgTemplateFunctionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   95646           1 :           pointerOfLinkedList->set_freepointer(NULL);
   95647             :        // DQ (6/6/2010): Temporary debugging...
   95648             :        //   ROSE_ASSERT(false);
   95649             :         }
   95650             : 
   95651           5 :      return ;
   95652             :    }
   95653             : 
   95654             : //############################################################################
   95655             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   95656             :  * within the memory pool and resets the freepointers, in order to achieve a 
   95657             :  * linked list, that has no jumps and starts at the beginning! This function 
   95658             :  * does not extend the memory pool, since we do not delete any memory blocks,
   95659             :  * but delete the valid objects.  
   95660             :  */
   95661             : void
   95662           0 : SgTemplateFunctionDeclaration::clearMemoryPool( )
   95663             :    {
   95664             :   // printf ("Inside of SgTemplateFunctionDeclaration::clearMemoryPool() \n");
   95665             : 
   95666           0 :      SgTemplateFunctionDeclaration* pointer = NULL, *tempPointer = NULL;
   95667           0 :      std::vector < unsigned char* > :: const_iterator block;
   95668           0 :      if ( SgTemplateFunctionDeclaration::pools.empty() == false )
   95669             :         {
   95670           0 :           block = SgTemplateFunctionDeclaration::pools.begin() ;
   95671           0 :           SgTemplateFunctionDeclaration::next_node = (SgTemplateFunctionDeclaration*) (*block);
   95672             : 
   95673           0 :           while ( block != SgTemplateFunctionDeclaration::pools.end() )
   95674             :              {
   95675           0 :                pointer = (SgTemplateFunctionDeclaration*) (*block);
   95676           0 :                if ( tempPointer != NULL )
   95677             :                   {
   95678           0 :                     tempPointer->set_freepointer(pointer);
   95679             :                   }
   95680           0 :                for (unsigned i = 0; i < SgTemplateFunctionDeclaration::pool_size - 1; ++i)
   95681             :                   {
   95682           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   95683             :                   }
   95684           0 :                 pointer[SgTemplateFunctionDeclaration::pool_size-1].set_freepointer(NULL);
   95685           0 :                 tempPointer = &(pointer[SgTemplateFunctionDeclaration::pool_size-1]);
   95686           0 :                 ++block;
   95687             :              }
   95688             :         }
   95689           0 :    }
   95690             : 
   95691           5 : void SgTemplateFunctionDeclaration::deleteMemoryPool() {
   95692           7 :   for (auto p: SgTemplateFunctionDeclaration::pools) {
   95693           2 :     ROSE_FREE(p);
   95694             :   }
   95695           5 :   SgTemplateFunctionDeclaration::next_node = nullptr;
   95696           5 :   SgTemplateFunctionDeclaration::pools.clear();
   95697           5 : }
   95698             : 
   95699             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   95700             : //                 reading multiple binary files to for a single AST.
   95701             : /////////// new version ////////////////////////////////
   95702             : //############################################################################
   95703             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   95704             : void
   95705           2 : SgTemplateFunctionDeclaration::extendMemoryPoolForFileIO( )
   95706             :   {
   95707           2 :     size_t blockIndex = SgTemplateFunctionDeclaration::pools.size();
   95708           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionDeclaration);
   95709             : 
   95710           3 :     while ( (blockIndex * SgTemplateFunctionDeclaration::pool_size) < newPoolSize)
   95711             :       {
   95712             : #if ROSE_ALLOC_TRACE
   95713             :         if (blockIndex > 0) {
   95714             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionDeclaration) = %" PRIuPTR " SgTemplateFunctionDeclaration::pool_size = %d \n",
   95715             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionDeclaration),SgTemplateFunctionDeclaration::pool_size);
   95716             :         }
   95717             : #endif
   95718             : 
   95719           1 :         SgTemplateFunctionDeclaration * pointer = (SgTemplateFunctionDeclaration*) ROSE_MALLOC ( SgTemplateFunctionDeclaration::pool_size * sizeof(SgTemplateFunctionDeclaration) );
   95720           1 :         assert( pointer != NULL );
   95721             : #if ROSE_ALLOC_MEMSET == 1
   95722             :         memset(pointer, 0x00, SgTemplateFunctionDeclaration::pool_size * sizeof(SgTemplateFunctionDeclaration));
   95723             : #elif ROSE_ALLOC_MEMSET == 2
   95724             :         memset(pointer, 0xCC, SgTemplateFunctionDeclaration::pool_size * sizeof(SgTemplateFunctionDeclaration));
   95725             : #endif
   95726           1 :         SgTemplateFunctionDeclaration::pools.push_back( (unsigned char*)(pointer) );
   95727           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateFunctionDeclaration::pool_size * sizeof(SgTemplateFunctionDeclaration), V_SgTemplateFunctionDeclaration ) );
   95728             : 
   95729           1 :         if ( SgTemplateFunctionDeclaration::next_node != NULL ) {
   95730           0 :           if ( blockIndex > 0 ) {
   95731           0 :             SgTemplateFunctionDeclaration * blkptr = (SgTemplateFunctionDeclaration*)(SgTemplateFunctionDeclaration::pools[blockIndex-1]);
   95732           0 :             blkptr[ SgTemplateFunctionDeclaration::pool_size - 1 ].set_freepointer(pointer);
   95733             :           }
   95734             :         } else {
   95735           1 :           SgTemplateFunctionDeclaration::next_node = pointer;
   95736             :         }
   95737             : 
   95738        2000 :         for (unsigned i = 0; i < SgTemplateFunctionDeclaration::pool_size-1; ++i)
   95739             :            {
   95740        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   95741             :            }
   95742           1 :         pointer[ SgTemplateFunctionDeclaration::pool_size -1 ].set_freepointer(NULL);
   95743             : 
   95744           1 :         blockIndex++;
   95745             :       }
   95746           2 :   }
   95747             : 
   95748             : //############################################################################
   95749             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   95750             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   95751             :  * not compressed. However, that stuff is not yet implemented! 
   95752             :  */
   95753             : unsigned long
   95754           0 : SgTemplateFunctionDeclaration::getNumberOfLastValidPointer()
   95755             :    {
   95756           0 :       SgTemplateFunctionDeclaration* testPointer = (SgTemplateFunctionDeclaration*)(SgTemplateFunctionDeclaration::pools.back());
   95757           0 :       unsigned long localIndex = SgTemplateFunctionDeclaration::pool_size - 1;
   95758           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   95759             :          {
   95760           0 :            localIndex--;
   95761             :          }
   95762           0 :       return (localIndex + SgTemplateFunctionDeclaration::pool_size * (SgTemplateFunctionDeclaration::pools.size()-1));
   95763             :    }
   95764             : 
   95765             : //############################################################################
   95766             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   95767             :  * memory pool and initializes the data member in class SgTemplateFunctionDeclarationStroageClass
   95768             :  * from its counterpart of SgTemplateFunctionDeclaration. The return value is just for checking, 
   95769             :  * that the whole StorageClassArray is initialized!
   95770             :  */
   95771             : unsigned long
   95772           1 : SgTemplateFunctionDeclaration::initializeStorageClassArray( SgTemplateFunctionDeclarationStorageClass *storageArray )
   95773             :    {
   95774           1 :      unsigned long storageCounter = 0;
   95775           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateFunctionDeclaration::pools.begin();
   95776           1 :      SgTemplateFunctionDeclaration* pointer = NULL;
   95777           2 :      while ( block != SgTemplateFunctionDeclaration::pools.end() ) {
   95778           1 :           pointer = (SgTemplateFunctionDeclaration*) (*block);
   95779        2001 :           for ( unsigned i = 0; i < SgTemplateFunctionDeclaration::pool_size; ++i ) {
   95780        2000 :                if ( pointer->get_freepointer() != NULL ) {
   95781         676 :                  storageArray->pickOutIRNodeData (pointer) ;
   95782         676 :                  storageArray++;
   95783         676 :                  storageCounter++;
   95784             :                }
   95785        2000 :                pointer++;
   95786             :              }
   95787           1 :            block++;
   95788             :         }
   95789           1 :      return storageCounter;
   95790             :    }
   95791             : 
   95792             : /* #line 95793 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   95793             : 
   95794             : 
   95795             : 
   95796             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   95797             : 
   95798             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   95799             : 
   95800             : //############################################################################
   95801             : /* JH (02/02/2006) Constructor of the IR node SgMemberFunctionDeclaration that takes its 
   95802             :  * corresponding StorageClass as parameter
   95803             :  */
   95804        4428 : SgMemberFunctionDeclaration :: SgMemberFunctionDeclaration ( const SgMemberFunctionDeclarationStorageClass& storageSource )   : SgFunctionDeclaration (storageSource)
   95805             :    {
   95806             : 
   95807             : 
   95808             : /* #line 95809 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   95809             : 
   95810        4428 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   95811        4428 :      p_CtorInitializerList =  (SgCtorInitializerList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_CtorInitializerList) );
   95812        4428 :      p_associatedClassDeclaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_associatedClassDeclaration) );
   95813             : 
   95814             : 
   95815             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   95816             : 
   95817             : 
   95818        4428 :    }
   95819             : 
   95820             : //############################################################################
   95821             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   95822             :  * within the working AST. 
   95823             :  */
   95824        6877 : SgMemberFunctionDeclaration * SgMemberFunctionDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   95825        6877 :      SgMemberFunctionDeclaration* returnPointer = NULL;
   95826        6877 :      if ( globalIndex != 0 )
   95827             :         {
   95828             : 
   95829             : #if FILE_IO_EXTRA_CHECK
   95830        6877 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMemberFunctionDeclaration ) ) <= globalIndex ) ;
   95831        6877 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMemberFunctionDeclaration + 1 ) ) );
   95832             : #endif
   95833        6877 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMemberFunctionDeclaration )  
   95834        6877 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMemberFunctionDeclaration );
   95835        6877 :           unsigned long positionInPool = localIndex % SgMemberFunctionDeclaration::pool_size;
   95836        6877 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMemberFunctionDeclaration::pool_size;
   95837             : 
   95838             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   95839             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   95840             : 
   95841        6877 :           returnPointer = &( ( (SgMemberFunctionDeclaration*)(SgMemberFunctionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   95842             : 
   95843        6877 :           ROSE_ASSERT( returnPointer != NULL ) ;
   95844             :         }
   95845        6877 :      return returnPointer ;
   95846             :    }
   95847             : 
   95848             : //############################################################################
   95849             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   95850             :   for the AST with the index astIndex
   95851             : */
   95852           0 : SgMemberFunctionDeclaration * SgMemberFunctionDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   95853           0 :      SgMemberFunctionDeclaration* returnPointer = NULL;
   95854           0 :      if ( globalIndex != 0 )
   95855             :         {
   95856             : 
   95857             : #if FILE_IO_EXTRA_CHECK
   95858           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMemberFunctionDeclaration ) ) <= globalIndex ) ;
   95859           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMemberFunctionDeclaration + 1 ) ) );
   95860             : #endif
   95861           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMemberFunctionDeclaration )
   95862           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMemberFunctionDeclaration );
   95863           0 :           unsigned long positionInPool = localIndex % SgMemberFunctionDeclaration::pool_size ;
   95864           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMemberFunctionDeclaration::pool_size ;
   95865             : 
   95866             : #if FILE_IO_EXTRA_CHECK
   95867             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   95868             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   95869             : #endif
   95870             : 
   95871           0 :           returnPointer = &( ( (SgMemberFunctionDeclaration*)(SgMemberFunctionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   95872             : 
   95873             : #if FILE_IO_EXTRA_CHECK
   95874           0 :           assert ( returnPointer != NULL ) ;
   95875             : #endif
   95876             :         }
   95877           0 :      return returnPointer ;
   95878             :    }
   95879             : 
   95880             : //############################################################################
   95881             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   95882             :  * pool size! We set for every valid object in the memory pool the freepointer
   95883             :  * to the global index and increase the global index afterwards. For all the 
   95884             :  * invalid objects (means address ranges within the memory pool that were not
   95885             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   95886             :  * distinguish valid from invalid objects! 
   95887             :  */
   95888             : unsigned long
   95889           5 : SgMemberFunctionDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   95890             :    {
   95891           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   95892           5 :      SgMemberFunctionDeclaration* pointer = NULL;
   95893           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   95894           5 :      std::vector < unsigned char* > :: const_iterator block;
   95895           6 :      for ( block = SgMemberFunctionDeclaration::pools.begin(); block != SgMemberFunctionDeclaration::pools.end() ; ++block )
   95896             :         {
   95897           1 :           pointer = (SgMemberFunctionDeclaration*)(*block);
   95898        2001 :           for (unsigned i = 0; i < SgMemberFunctionDeclaration::pool_size; ++i )
   95899             :              {
   95900             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   95901             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   95902             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   95903             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   95904             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   95905             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   95906             :             // properly; so this will have to be checked next.
   95907             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   95908             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   95909        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   95910             :                   {
   95911         784 :                     pointer[i].set_freepointer((SgMemberFunctionDeclaration*)(globalIndex));
   95912         784 :                     globalIndex++;
   95913             :                   }
   95914             :                else
   95915             :                   {
   95916        1216 :                     pointer[i].set_freepointer(NULL);
   95917             :                   }
   95918             :               }
   95919             :         }
   95920           5 :      return globalIndex;
   95921             :    }
   95922             : 
   95923             : //############################################################################
   95924             : // JH (01/14/2006)
   95925             : void
   95926           5 : SgMemberFunctionDeclaration::resetValidFreepointers( )
   95927             :    {
   95928           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   95929           5 :      SgMemberFunctionDeclaration* pointer = NULL;
   95930           5 :      std::vector < unsigned char* > :: const_iterator block;
   95931           5 :      SgMemberFunctionDeclaration* pointerOfLinkedList = NULL;
   95932           6 :      for ( block = SgMemberFunctionDeclaration::pools.begin(); block != SgMemberFunctionDeclaration::pools.end() ; ++block )
   95933             :         {
   95934           1 :           pointer = (SgMemberFunctionDeclaration*)(*block);
   95935        2001 :           for (unsigned i = 0; i < SgMemberFunctionDeclaration::pool_size; ++i )
   95936             :              {
   95937             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   95938             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   95939             :             // memory blocks!.
   95940        2000 :                if ( pointer[i].get_freepointer() != NULL )
   95941             :                   {
   95942         784 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   95943             :                   }
   95944             :                else
   95945             :                   {
   95946        1216 :                     if ( pointerOfLinkedList == NULL )
   95947             :                        {
   95948           1 :                          SgMemberFunctionDeclaration::next_node = &(pointer[i]);
   95949             :                        }
   95950             :                     else
   95951             :                        {
   95952             :                       // printf ("In SgMemberFunctionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   95953        1215 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   95954             :                        }
   95955             :                     pointerOfLinkedList = &(pointer[i]);
   95956             :                   }
   95957             :               }
   95958             :         }
   95959             : 
   95960           5 :      if ( pointerOfLinkedList != NULL )
   95961             :         {
   95962             :        // printf ("In SgMemberFunctionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   95963           1 :           pointerOfLinkedList->set_freepointer(NULL);
   95964             :        // DQ (6/6/2010): Temporary debugging...
   95965             :        //   ROSE_ASSERT(false);
   95966             :         }
   95967             : 
   95968           5 :      return ;
   95969             :    }
   95970             : 
   95971             : //############################################################################
   95972             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   95973             :  * within the memory pool and resets the freepointers, in order to achieve a 
   95974             :  * linked list, that has no jumps and starts at the beginning! This function 
   95975             :  * does not extend the memory pool, since we do not delete any memory blocks,
   95976             :  * but delete the valid objects.  
   95977             :  */
   95978             : void
   95979           0 : SgMemberFunctionDeclaration::clearMemoryPool( )
   95980             :    {
   95981             :   // printf ("Inside of SgMemberFunctionDeclaration::clearMemoryPool() \n");
   95982             : 
   95983           0 :      SgMemberFunctionDeclaration* pointer = NULL, *tempPointer = NULL;
   95984           0 :      std::vector < unsigned char* > :: const_iterator block;
   95985           0 :      if ( SgMemberFunctionDeclaration::pools.empty() == false )
   95986             :         {
   95987           0 :           block = SgMemberFunctionDeclaration::pools.begin() ;
   95988           0 :           SgMemberFunctionDeclaration::next_node = (SgMemberFunctionDeclaration*) (*block);
   95989             : 
   95990           0 :           while ( block != SgMemberFunctionDeclaration::pools.end() )
   95991             :              {
   95992           0 :                pointer = (SgMemberFunctionDeclaration*) (*block);
   95993           0 :                if ( tempPointer != NULL )
   95994             :                   {
   95995           0 :                     tempPointer->set_freepointer(pointer);
   95996             :                   }
   95997           0 :                for (unsigned i = 0; i < SgMemberFunctionDeclaration::pool_size - 1; ++i)
   95998             :                   {
   95999           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   96000             :                   }
   96001           0 :                 pointer[SgMemberFunctionDeclaration::pool_size-1].set_freepointer(NULL);
   96002           0 :                 tempPointer = &(pointer[SgMemberFunctionDeclaration::pool_size-1]);
   96003           0 :                 ++block;
   96004             :              }
   96005             :         }
   96006           0 :    }
   96007             : 
   96008           5 : void SgMemberFunctionDeclaration::deleteMemoryPool() {
   96009           7 :   for (auto p: SgMemberFunctionDeclaration::pools) {
   96010           2 :     ROSE_FREE(p);
   96011             :   }
   96012           5 :   SgMemberFunctionDeclaration::next_node = nullptr;
   96013           5 :   SgMemberFunctionDeclaration::pools.clear();
   96014           5 : }
   96015             : 
   96016             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   96017             : //                 reading multiple binary files to for a single AST.
   96018             : /////////// new version ////////////////////////////////
   96019             : //############################################################################
   96020             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   96021             : void
   96022           2 : SgMemberFunctionDeclaration::extendMemoryPoolForFileIO( )
   96023             :   {
   96024           2 :     size_t blockIndex = SgMemberFunctionDeclaration::pools.size();
   96025           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionDeclaration);
   96026             : 
   96027           3 :     while ( (blockIndex * SgMemberFunctionDeclaration::pool_size) < newPoolSize)
   96028             :       {
   96029             : #if ROSE_ALLOC_TRACE
   96030             :         if (blockIndex > 0) {
   96031             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionDeclaration) = %" PRIuPTR " SgMemberFunctionDeclaration::pool_size = %d \n",
   96032             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionDeclaration),SgMemberFunctionDeclaration::pool_size);
   96033             :         }
   96034             : #endif
   96035             : 
   96036           1 :         SgMemberFunctionDeclaration * pointer = (SgMemberFunctionDeclaration*) ROSE_MALLOC ( SgMemberFunctionDeclaration::pool_size * sizeof(SgMemberFunctionDeclaration) );
   96037           1 :         assert( pointer != NULL );
   96038             : #if ROSE_ALLOC_MEMSET == 1
   96039             :         memset(pointer, 0x00, SgMemberFunctionDeclaration::pool_size * sizeof(SgMemberFunctionDeclaration));
   96040             : #elif ROSE_ALLOC_MEMSET == 2
   96041             :         memset(pointer, 0xCC, SgMemberFunctionDeclaration::pool_size * sizeof(SgMemberFunctionDeclaration));
   96042             : #endif
   96043           1 :         SgMemberFunctionDeclaration::pools.push_back( (unsigned char*)(pointer) );
   96044           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMemberFunctionDeclaration::pool_size * sizeof(SgMemberFunctionDeclaration), V_SgMemberFunctionDeclaration ) );
   96045             : 
   96046           1 :         if ( SgMemberFunctionDeclaration::next_node != NULL ) {
   96047           0 :           if ( blockIndex > 0 ) {
   96048           0 :             SgMemberFunctionDeclaration * blkptr = (SgMemberFunctionDeclaration*)(SgMemberFunctionDeclaration::pools[blockIndex-1]);
   96049           0 :             blkptr[ SgMemberFunctionDeclaration::pool_size - 1 ].set_freepointer(pointer);
   96050             :           }
   96051             :         } else {
   96052           1 :           SgMemberFunctionDeclaration::next_node = pointer;
   96053             :         }
   96054             : 
   96055        2000 :         for (unsigned i = 0; i < SgMemberFunctionDeclaration::pool_size-1; ++i)
   96056             :            {
   96057        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   96058             :            }
   96059           1 :         pointer[ SgMemberFunctionDeclaration::pool_size -1 ].set_freepointer(NULL);
   96060             : 
   96061           1 :         blockIndex++;
   96062             :       }
   96063           2 :   }
   96064             : 
   96065             : //############################################################################
   96066             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   96067             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   96068             :  * not compressed. However, that stuff is not yet implemented! 
   96069             :  */
   96070             : unsigned long
   96071           0 : SgMemberFunctionDeclaration::getNumberOfLastValidPointer()
   96072             :    {
   96073           0 :       SgMemberFunctionDeclaration* testPointer = (SgMemberFunctionDeclaration*)(SgMemberFunctionDeclaration::pools.back());
   96074           0 :       unsigned long localIndex = SgMemberFunctionDeclaration::pool_size - 1;
   96075           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   96076             :          {
   96077           0 :            localIndex--;
   96078             :          }
   96079           0 :       return (localIndex + SgMemberFunctionDeclaration::pool_size * (SgMemberFunctionDeclaration::pools.size()-1));
   96080             :    }
   96081             : 
   96082             : //############################################################################
   96083             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   96084             :  * memory pool and initializes the data member in class SgMemberFunctionDeclarationStroageClass
   96085             :  * from its counterpart of SgMemberFunctionDeclaration. The return value is just for checking, 
   96086             :  * that the whole StorageClassArray is initialized!
   96087             :  */
   96088             : unsigned long
   96089           1 : SgMemberFunctionDeclaration::initializeStorageClassArray( SgMemberFunctionDeclarationStorageClass *storageArray )
   96090             :    {
   96091           1 :      unsigned long storageCounter = 0;
   96092           1 :      std::vector < unsigned char* > :: const_iterator block = SgMemberFunctionDeclaration::pools.begin();
   96093           1 :      SgMemberFunctionDeclaration* pointer = NULL;
   96094           2 :      while ( block != SgMemberFunctionDeclaration::pools.end() ) {
   96095           1 :           pointer = (SgMemberFunctionDeclaration*) (*block);
   96096        2001 :           for ( unsigned i = 0; i < SgMemberFunctionDeclaration::pool_size; ++i ) {
   96097        2000 :                if ( pointer->get_freepointer() != NULL ) {
   96098         784 :                  storageArray->pickOutIRNodeData (pointer) ;
   96099         784 :                  storageArray++;
   96100         784 :                  storageCounter++;
   96101             :                }
   96102        2000 :                pointer++;
   96103             :              }
   96104           1 :            block++;
   96105             :         }
   96106           1 :      return storageCounter;
   96107             :    }
   96108             : 
   96109             : /* #line 96110 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   96110             : 
   96111             : 
   96112             : 
   96113             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   96114             : 
   96115             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   96116             : 
   96117             : //############################################################################
   96118             : /* JH (02/02/2006) Constructor of the IR node SgTemplateMemberFunctionDeclaration that takes its 
   96119             :  * corresponding StorageClass as parameter
   96120             :  */
   96121        1905 : SgTemplateMemberFunctionDeclaration :: SgTemplateMemberFunctionDeclaration ( const SgTemplateMemberFunctionDeclarationStorageClass& storageSource )   : SgMemberFunctionDeclaration (storageSource)
   96122             :    {
   96123             : 
   96124             : 
   96125             : /* #line 96126 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   96126             : 
   96127        1905 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   96128        1905 :      p_templateParameters = storageSource.storageOf_templateParameters.rebuildDataStoredInEasyStorageClass() ;
   96129        1905 :      SgTemplateParameterPtrList::iterator i_templateParameters = p_templateParameters.begin() ; 
   96130        2649 :      for ( ; i_templateParameters != p_templateParameters.end(); ++i_templateParameters ) 
   96131             :         {
   96132         744 :           (*i_templateParameters) = (SgTemplateParameterPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateParameters) ) );
   96133             :         }
   96134        1905 :      p_templateSpecializationArguments = storageSource.storageOf_templateSpecializationArguments.rebuildDataStoredInEasyStorageClass() ;
   96135        1905 :      SgTemplateArgumentPtrList::iterator i_templateSpecializationArguments = p_templateSpecializationArguments.begin() ; 
   96136        1905 :      for ( ; i_templateSpecializationArguments != p_templateSpecializationArguments.end(); ++i_templateSpecializationArguments ) 
   96137             :         {
   96138           0 :           (*i_templateSpecializationArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateSpecializationArguments) ) );
   96139             :         }
   96140        1905 :      p_string = SgName ( storageSource.storageOf_string ) ;
   96141        1905 :      p_string_represents_function_body = storageSource.storageOf_string_represents_function_body ;
   96142        1905 :      p_nonreal_decl_scope =  (SgDeclarationScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nonreal_decl_scope) );
   96143             : 
   96144             : 
   96145             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   96146             : 
   96147             : 
   96148        1905 :    }
   96149             : 
   96150             : //############################################################################
   96151             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   96152             :  * within the working AST. 
   96153             :  */
   96154       20539 : SgTemplateMemberFunctionDeclaration * SgTemplateMemberFunctionDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   96155       20539 :      SgTemplateMemberFunctionDeclaration* returnPointer = NULL;
   96156       20539 :      if ( globalIndex != 0 )
   96157             :         {
   96158             : 
   96159             : #if FILE_IO_EXTRA_CHECK
   96160       20539 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateMemberFunctionDeclaration ) ) <= globalIndex ) ;
   96161       20539 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateMemberFunctionDeclaration + 1 ) ) );
   96162             : #endif
   96163       20539 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateMemberFunctionDeclaration )  
   96164       20539 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateMemberFunctionDeclaration );
   96165       20539 :           unsigned long positionInPool = localIndex % SgTemplateMemberFunctionDeclaration::pool_size;
   96166       20539 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateMemberFunctionDeclaration::pool_size;
   96167             : 
   96168             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   96169             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   96170             : 
   96171       20539 :           returnPointer = &( ( (SgTemplateMemberFunctionDeclaration*)(SgTemplateMemberFunctionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   96172             : 
   96173       20539 :           ROSE_ASSERT( returnPointer != NULL ) ;
   96174             :         }
   96175       20539 :      return returnPointer ;
   96176             :    }
   96177             : 
   96178             : //############################################################################
   96179             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   96180             :   for the AST with the index astIndex
   96181             : */
   96182           0 : SgTemplateMemberFunctionDeclaration * SgTemplateMemberFunctionDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   96183           0 :      SgTemplateMemberFunctionDeclaration* returnPointer = NULL;
   96184           0 :      if ( globalIndex != 0 )
   96185             :         {
   96186             : 
   96187             : #if FILE_IO_EXTRA_CHECK
   96188           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateMemberFunctionDeclaration ) ) <= globalIndex ) ;
   96189           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateMemberFunctionDeclaration + 1 ) ) );
   96190             : #endif
   96191           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateMemberFunctionDeclaration )
   96192           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateMemberFunctionDeclaration );
   96193           0 :           unsigned long positionInPool = localIndex % SgTemplateMemberFunctionDeclaration::pool_size ;
   96194           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateMemberFunctionDeclaration::pool_size ;
   96195             : 
   96196             : #if FILE_IO_EXTRA_CHECK
   96197             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   96198             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   96199             : #endif
   96200             : 
   96201           0 :           returnPointer = &( ( (SgTemplateMemberFunctionDeclaration*)(SgTemplateMemberFunctionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
   96202             : 
   96203             : #if FILE_IO_EXTRA_CHECK
   96204           0 :           assert ( returnPointer != NULL ) ;
   96205             : #endif
   96206             :         }
   96207           0 :      return returnPointer ;
   96208             :    }
   96209             : 
   96210             : //############################################################################
   96211             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   96212             :  * pool size! We set for every valid object in the memory pool the freepointer
   96213             :  * to the global index and increase the global index afterwards. For all the 
   96214             :  * invalid objects (means address ranges within the memory pool that were not
   96215             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   96216             :  * distinguish valid from invalid objects! 
   96217             :  */
   96218             : unsigned long
   96219           5 : SgTemplateMemberFunctionDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   96220             :    {
   96221           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   96222           5 :      SgTemplateMemberFunctionDeclaration* pointer = NULL;
   96223           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   96224           5 :      std::vector < unsigned char* > :: const_iterator block;
   96225           6 :      for ( block = SgTemplateMemberFunctionDeclaration::pools.begin(); block != SgTemplateMemberFunctionDeclaration::pools.end() ; ++block )
   96226             :         {
   96227           1 :           pointer = (SgTemplateMemberFunctionDeclaration*)(*block);
   96228        2001 :           for (unsigned i = 0; i < SgTemplateMemberFunctionDeclaration::pool_size; ++i )
   96229             :              {
   96230             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   96231             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   96232             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   96233             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   96234             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   96235             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   96236             :             // properly; so this will have to be checked next.
   96237             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   96238             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   96239        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   96240             :                   {
   96241        1905 :                     pointer[i].set_freepointer((SgTemplateMemberFunctionDeclaration*)(globalIndex));
   96242        1905 :                     globalIndex++;
   96243             :                   }
   96244             :                else
   96245             :                   {
   96246          95 :                     pointer[i].set_freepointer(NULL);
   96247             :                   }
   96248             :               }
   96249             :         }
   96250           5 :      return globalIndex;
   96251             :    }
   96252             : 
   96253             : //############################################################################
   96254             : // JH (01/14/2006)
   96255             : void
   96256           5 : SgTemplateMemberFunctionDeclaration::resetValidFreepointers( )
   96257             :    {
   96258           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   96259           5 :      SgTemplateMemberFunctionDeclaration* pointer = NULL;
   96260           5 :      std::vector < unsigned char* > :: const_iterator block;
   96261           5 :      SgTemplateMemberFunctionDeclaration* pointerOfLinkedList = NULL;
   96262           6 :      for ( block = SgTemplateMemberFunctionDeclaration::pools.begin(); block != SgTemplateMemberFunctionDeclaration::pools.end() ; ++block )
   96263             :         {
   96264           1 :           pointer = (SgTemplateMemberFunctionDeclaration*)(*block);
   96265        2001 :           for (unsigned i = 0; i < SgTemplateMemberFunctionDeclaration::pool_size; ++i )
   96266             :              {
   96267             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   96268             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   96269             :             // memory blocks!.
   96270        2000 :                if ( pointer[i].get_freepointer() != NULL )
   96271             :                   {
   96272        1905 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   96273             :                   }
   96274             :                else
   96275             :                   {
   96276          95 :                     if ( pointerOfLinkedList == NULL )
   96277             :                        {
   96278           1 :                          SgTemplateMemberFunctionDeclaration::next_node = &(pointer[i]);
   96279             :                        }
   96280             :                     else
   96281             :                        {
   96282             :                       // printf ("In SgTemplateMemberFunctionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   96283          94 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   96284             :                        }
   96285             :                     pointerOfLinkedList = &(pointer[i]);
   96286             :                   }
   96287             :               }
   96288             :         }
   96289             : 
   96290           5 :      if ( pointerOfLinkedList != NULL )
   96291             :         {
   96292             :        // printf ("In SgTemplateMemberFunctionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   96293           1 :           pointerOfLinkedList->set_freepointer(NULL);
   96294             :        // DQ (6/6/2010): Temporary debugging...
   96295             :        //   ROSE_ASSERT(false);
   96296             :         }
   96297             : 
   96298           5 :      return ;
   96299             :    }
   96300             : 
   96301             : //############################################################################
   96302             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   96303             :  * within the memory pool and resets the freepointers, in order to achieve a 
   96304             :  * linked list, that has no jumps and starts at the beginning! This function 
   96305             :  * does not extend the memory pool, since we do not delete any memory blocks,
   96306             :  * but delete the valid objects.  
   96307             :  */
   96308             : void
   96309           0 : SgTemplateMemberFunctionDeclaration::clearMemoryPool( )
   96310             :    {
   96311             :   // printf ("Inside of SgTemplateMemberFunctionDeclaration::clearMemoryPool() \n");
   96312             : 
   96313           0 :      SgTemplateMemberFunctionDeclaration* pointer = NULL, *tempPointer = NULL;
   96314           0 :      std::vector < unsigned char* > :: const_iterator block;
   96315           0 :      if ( SgTemplateMemberFunctionDeclaration::pools.empty() == false )
   96316             :         {
   96317           0 :           block = SgTemplateMemberFunctionDeclaration::pools.begin() ;
   96318           0 :           SgTemplateMemberFunctionDeclaration::next_node = (SgTemplateMemberFunctionDeclaration*) (*block);
   96319             : 
   96320           0 :           while ( block != SgTemplateMemberFunctionDeclaration::pools.end() )
   96321             :              {
   96322           0 :                pointer = (SgTemplateMemberFunctionDeclaration*) (*block);
   96323           0 :                if ( tempPointer != NULL )
   96324             :                   {
   96325           0 :                     tempPointer->set_freepointer(pointer);
   96326             :                   }
   96327           0 :                for (unsigned i = 0; i < SgTemplateMemberFunctionDeclaration::pool_size - 1; ++i)
   96328             :                   {
   96329           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   96330             :                   }
   96331           0 :                 pointer[SgTemplateMemberFunctionDeclaration::pool_size-1].set_freepointer(NULL);
   96332           0 :                 tempPointer = &(pointer[SgTemplateMemberFunctionDeclaration::pool_size-1]);
   96333           0 :                 ++block;
   96334             :              }
   96335             :         }
   96336           0 :    }
   96337             : 
   96338           5 : void SgTemplateMemberFunctionDeclaration::deleteMemoryPool() {
   96339           7 :   for (auto p: SgTemplateMemberFunctionDeclaration::pools) {
   96340           2 :     ROSE_FREE(p);
   96341             :   }
   96342           5 :   SgTemplateMemberFunctionDeclaration::next_node = nullptr;
   96343           5 :   SgTemplateMemberFunctionDeclaration::pools.clear();
   96344           5 : }
   96345             : 
   96346             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   96347             : //                 reading multiple binary files to for a single AST.
   96348             : /////////// new version ////////////////////////////////
   96349             : //############################################################################
   96350             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   96351             : void
   96352           2 : SgTemplateMemberFunctionDeclaration::extendMemoryPoolForFileIO( )
   96353             :   {
   96354           2 :     size_t blockIndex = SgTemplateMemberFunctionDeclaration::pools.size();
   96355           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionDeclaration);
   96356             : 
   96357           3 :     while ( (blockIndex * SgTemplateMemberFunctionDeclaration::pool_size) < newPoolSize)
   96358             :       {
   96359             : #if ROSE_ALLOC_TRACE
   96360             :         if (blockIndex > 0) {
   96361             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionDeclaration) = %" PRIuPTR " SgTemplateMemberFunctionDeclaration::pool_size = %d \n",
   96362             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionDeclaration),SgTemplateMemberFunctionDeclaration::pool_size);
   96363             :         }
   96364             : #endif
   96365             : 
   96366           1 :         SgTemplateMemberFunctionDeclaration * pointer = (SgTemplateMemberFunctionDeclaration*) ROSE_MALLOC ( SgTemplateMemberFunctionDeclaration::pool_size * sizeof(SgTemplateMemberFunctionDeclaration) );
   96367           1 :         assert( pointer != NULL );
   96368             : #if ROSE_ALLOC_MEMSET == 1
   96369             :         memset(pointer, 0x00, SgTemplateMemberFunctionDeclaration::pool_size * sizeof(SgTemplateMemberFunctionDeclaration));
   96370             : #elif ROSE_ALLOC_MEMSET == 2
   96371             :         memset(pointer, 0xCC, SgTemplateMemberFunctionDeclaration::pool_size * sizeof(SgTemplateMemberFunctionDeclaration));
   96372             : #endif
   96373           1 :         SgTemplateMemberFunctionDeclaration::pools.push_back( (unsigned char*)(pointer) );
   96374           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateMemberFunctionDeclaration::pool_size * sizeof(SgTemplateMemberFunctionDeclaration), V_SgTemplateMemberFunctionDeclaration ) );
   96375             : 
   96376           1 :         if ( SgTemplateMemberFunctionDeclaration::next_node != NULL ) {
   96377           0 :           if ( blockIndex > 0 ) {
   96378           0 :             SgTemplateMemberFunctionDeclaration * blkptr = (SgTemplateMemberFunctionDeclaration*)(SgTemplateMemberFunctionDeclaration::pools[blockIndex-1]);
   96379           0 :             blkptr[ SgTemplateMemberFunctionDeclaration::pool_size - 1 ].set_freepointer(pointer);
   96380             :           }
   96381             :         } else {
   96382           1 :           SgTemplateMemberFunctionDeclaration::next_node = pointer;
   96383             :         }
   96384             : 
   96385        2000 :         for (unsigned i = 0; i < SgTemplateMemberFunctionDeclaration::pool_size-1; ++i)
   96386             :            {
   96387        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   96388             :            }
   96389           1 :         pointer[ SgTemplateMemberFunctionDeclaration::pool_size -1 ].set_freepointer(NULL);
   96390             : 
   96391           1 :         blockIndex++;
   96392             :       }
   96393           2 :   }
   96394             : 
   96395             : //############################################################################
   96396             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   96397             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   96398             :  * not compressed. However, that stuff is not yet implemented! 
   96399             :  */
   96400             : unsigned long
   96401           0 : SgTemplateMemberFunctionDeclaration::getNumberOfLastValidPointer()
   96402             :    {
   96403           0 :       SgTemplateMemberFunctionDeclaration* testPointer = (SgTemplateMemberFunctionDeclaration*)(SgTemplateMemberFunctionDeclaration::pools.back());
   96404           0 :       unsigned long localIndex = SgTemplateMemberFunctionDeclaration::pool_size - 1;
   96405           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   96406             :          {
   96407           0 :            localIndex--;
   96408             :          }
   96409           0 :       return (localIndex + SgTemplateMemberFunctionDeclaration::pool_size * (SgTemplateMemberFunctionDeclaration::pools.size()-1));
   96410             :    }
   96411             : 
   96412             : //############################################################################
   96413             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   96414             :  * memory pool and initializes the data member in class SgTemplateMemberFunctionDeclarationStroageClass
   96415             :  * from its counterpart of SgTemplateMemberFunctionDeclaration. The return value is just for checking, 
   96416             :  * that the whole StorageClassArray is initialized!
   96417             :  */
   96418             : unsigned long
   96419           1 : SgTemplateMemberFunctionDeclaration::initializeStorageClassArray( SgTemplateMemberFunctionDeclarationStorageClass *storageArray )
   96420             :    {
   96421           1 :      unsigned long storageCounter = 0;
   96422           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateMemberFunctionDeclaration::pools.begin();
   96423           1 :      SgTemplateMemberFunctionDeclaration* pointer = NULL;
   96424           2 :      while ( block != SgTemplateMemberFunctionDeclaration::pools.end() ) {
   96425           1 :           pointer = (SgTemplateMemberFunctionDeclaration*) (*block);
   96426        2001 :           for ( unsigned i = 0; i < SgTemplateMemberFunctionDeclaration::pool_size; ++i ) {
   96427        2000 :                if ( pointer->get_freepointer() != NULL ) {
   96428        1905 :                  storageArray->pickOutIRNodeData (pointer) ;
   96429        1905 :                  storageArray++;
   96430        1905 :                  storageCounter++;
   96431             :                }
   96432        2000 :                pointer++;
   96433             :              }
   96434           1 :            block++;
   96435             :         }
   96436           1 :      return storageCounter;
   96437             :    }
   96438             : 
   96439             : /* #line 96440 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   96440             : 
   96441             : 
   96442             : 
   96443             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   96444             : 
   96445             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   96446             : 
   96447             : //############################################################################
   96448             : /* JH (02/02/2006) Constructor of the IR node SgTemplateInstantiationMemberFunctionDecl that takes its 
   96449             :  * corresponding StorageClass as parameter
   96450             :  */
   96451        1739 : SgTemplateInstantiationMemberFunctionDecl :: SgTemplateInstantiationMemberFunctionDecl ( const SgTemplateInstantiationMemberFunctionDeclStorageClass& storageSource )   : SgMemberFunctionDeclaration (storageSource)
   96452             :    {
   96453             : 
   96454             : 
   96455             : /* #line 96456 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   96456             : 
   96457        1739 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   96458        1739 :      p_templateName = SgName ( storageSource.storageOf_templateName ) ;
   96459        1739 :      p_templateDeclaration =  (SgTemplateMemberFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_templateDeclaration) );
   96460        1739 :      p_templateArguments = storageSource.storageOf_templateArguments.rebuildDataStoredInEasyStorageClass() ;
   96461        1739 :      SgTemplateArgumentPtrList::iterator i_templateArguments = p_templateArguments.begin() ; 
   96462        1877 :      for ( ; i_templateArguments != p_templateArguments.end(); ++i_templateArguments ) 
   96463             :         {
   96464         138 :           (*i_templateArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateArguments) ) );
   96465             :         }
   96466        1739 :      p_nameResetFromMangledForm = storageSource.storageOf_nameResetFromMangledForm ;
   96467        1739 :      p_template_argument_list_is_explicit = storageSource.storageOf_template_argument_list_is_explicit ;
   96468             : 
   96469             : 
   96470             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   96471             : 
   96472             : 
   96473        1739 :    }
   96474             : 
   96475             : //############################################################################
   96476             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   96477             :  * within the working AST. 
   96478             :  */
   96479       16664 : SgTemplateInstantiationMemberFunctionDecl * SgTemplateInstantiationMemberFunctionDecl::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   96480       16664 :      SgTemplateInstantiationMemberFunctionDecl* returnPointer = NULL;
   96481       16664 :      if ( globalIndex != 0 )
   96482             :         {
   96483             : 
   96484             : #if FILE_IO_EXTRA_CHECK
   96485       16664 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateInstantiationMemberFunctionDecl ) ) <= globalIndex ) ;
   96486       16664 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationMemberFunctionDecl + 1 ) ) );
   96487             : #endif
   96488       16664 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationMemberFunctionDecl )  
   96489       16664 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateInstantiationMemberFunctionDecl );
   96490       16664 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationMemberFunctionDecl::pool_size;
   96491       16664 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationMemberFunctionDecl::pool_size;
   96492             : 
   96493             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   96494             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   96495             : 
   96496       16664 :           returnPointer = &( ( (SgTemplateInstantiationMemberFunctionDecl*)(SgTemplateInstantiationMemberFunctionDecl::pools[memoryBlock]) ) [positionInPool]) ;
   96497             : 
   96498       16664 :           ROSE_ASSERT( returnPointer != NULL ) ;
   96499             :         }
   96500       16664 :      return returnPointer ;
   96501             :    }
   96502             : 
   96503             : //############################################################################
   96504             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   96505             :   for the AST with the index astIndex
   96506             : */
   96507           0 : SgTemplateInstantiationMemberFunctionDecl * SgTemplateInstantiationMemberFunctionDecl::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   96508           0 :      SgTemplateInstantiationMemberFunctionDecl* returnPointer = NULL;
   96509           0 :      if ( globalIndex != 0 )
   96510             :         {
   96511             : 
   96512             : #if FILE_IO_EXTRA_CHECK
   96513           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateInstantiationMemberFunctionDecl ) ) <= globalIndex ) ;
   96514           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationMemberFunctionDecl + 1 ) ) );
   96515             : #endif
   96516           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationMemberFunctionDecl )
   96517           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateInstantiationMemberFunctionDecl );
   96518           0 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationMemberFunctionDecl::pool_size ;
   96519           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationMemberFunctionDecl::pool_size ;
   96520             : 
   96521             : #if FILE_IO_EXTRA_CHECK
   96522             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   96523             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   96524             : #endif
   96525             : 
   96526           0 :           returnPointer = &( ( (SgTemplateInstantiationMemberFunctionDecl*)(SgTemplateInstantiationMemberFunctionDecl::pools[memoryBlock]) ) [positionInPool]) ;
   96527             : 
   96528             : #if FILE_IO_EXTRA_CHECK
   96529           0 :           assert ( returnPointer != NULL ) ;
   96530             : #endif
   96531             :         }
   96532           0 :      return returnPointer ;
   96533             :    }
   96534             : 
   96535             : //############################################################################
   96536             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   96537             :  * pool size! We set for every valid object in the memory pool the freepointer
   96538             :  * to the global index and increase the global index afterwards. For all the 
   96539             :  * invalid objects (means address ranges within the memory pool that were not
   96540             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   96541             :  * distinguish valid from invalid objects! 
   96542             :  */
   96543             : unsigned long
   96544           5 : SgTemplateInstantiationMemberFunctionDecl::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   96545             :    {
   96546           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   96547           5 :      SgTemplateInstantiationMemberFunctionDecl* pointer = NULL;
   96548           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   96549           5 :      std::vector < unsigned char* > :: const_iterator block;
   96550           6 :      for ( block = SgTemplateInstantiationMemberFunctionDecl::pools.begin(); block != SgTemplateInstantiationMemberFunctionDecl::pools.end() ; ++block )
   96551             :         {
   96552           1 :           pointer = (SgTemplateInstantiationMemberFunctionDecl*)(*block);
   96553        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationMemberFunctionDecl::pool_size; ++i )
   96554             :              {
   96555             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   96556             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   96557             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   96558             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   96559             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   96560             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   96561             :             // properly; so this will have to be checked next.
   96562             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   96563             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   96564        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   96565             :                   {
   96566        1739 :                     pointer[i].set_freepointer((SgTemplateInstantiationMemberFunctionDecl*)(globalIndex));
   96567        1739 :                     globalIndex++;
   96568             :                   }
   96569             :                else
   96570             :                   {
   96571         261 :                     pointer[i].set_freepointer(NULL);
   96572             :                   }
   96573             :               }
   96574             :         }
   96575           5 :      return globalIndex;
   96576             :    }
   96577             : 
   96578             : //############################################################################
   96579             : // JH (01/14/2006)
   96580             : void
   96581           5 : SgTemplateInstantiationMemberFunctionDecl::resetValidFreepointers( )
   96582             :    {
   96583           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   96584           5 :      SgTemplateInstantiationMemberFunctionDecl* pointer = NULL;
   96585           5 :      std::vector < unsigned char* > :: const_iterator block;
   96586           5 :      SgTemplateInstantiationMemberFunctionDecl* pointerOfLinkedList = NULL;
   96587           6 :      for ( block = SgTemplateInstantiationMemberFunctionDecl::pools.begin(); block != SgTemplateInstantiationMemberFunctionDecl::pools.end() ; ++block )
   96588             :         {
   96589           1 :           pointer = (SgTemplateInstantiationMemberFunctionDecl*)(*block);
   96590        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationMemberFunctionDecl::pool_size; ++i )
   96591             :              {
   96592             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   96593             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   96594             :             // memory blocks!.
   96595        2000 :                if ( pointer[i].get_freepointer() != NULL )
   96596             :                   {
   96597        1739 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   96598             :                   }
   96599             :                else
   96600             :                   {
   96601         261 :                     if ( pointerOfLinkedList == NULL )
   96602             :                        {
   96603           1 :                          SgTemplateInstantiationMemberFunctionDecl::next_node = &(pointer[i]);
   96604             :                        }
   96605             :                     else
   96606             :                        {
   96607             :                       // printf ("In SgTemplateInstantiationMemberFunctionDecl::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   96608         260 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   96609             :                        }
   96610             :                     pointerOfLinkedList = &(pointer[i]);
   96611             :                   }
   96612             :               }
   96613             :         }
   96614             : 
   96615           5 :      if ( pointerOfLinkedList != NULL )
   96616             :         {
   96617             :        // printf ("In SgTemplateInstantiationMemberFunctionDecl::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   96618           1 :           pointerOfLinkedList->set_freepointer(NULL);
   96619             :        // DQ (6/6/2010): Temporary debugging...
   96620             :        //   ROSE_ASSERT(false);
   96621             :         }
   96622             : 
   96623           5 :      return ;
   96624             :    }
   96625             : 
   96626             : //############################################################################
   96627             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   96628             :  * within the memory pool and resets the freepointers, in order to achieve a 
   96629             :  * linked list, that has no jumps and starts at the beginning! This function 
   96630             :  * does not extend the memory pool, since we do not delete any memory blocks,
   96631             :  * but delete the valid objects.  
   96632             :  */
   96633             : void
   96634           0 : SgTemplateInstantiationMemberFunctionDecl::clearMemoryPool( )
   96635             :    {
   96636             :   // printf ("Inside of SgTemplateInstantiationMemberFunctionDecl::clearMemoryPool() \n");
   96637             : 
   96638           0 :      SgTemplateInstantiationMemberFunctionDecl* pointer = NULL, *tempPointer = NULL;
   96639           0 :      std::vector < unsigned char* > :: const_iterator block;
   96640           0 :      if ( SgTemplateInstantiationMemberFunctionDecl::pools.empty() == false )
   96641             :         {
   96642           0 :           block = SgTemplateInstantiationMemberFunctionDecl::pools.begin() ;
   96643           0 :           SgTemplateInstantiationMemberFunctionDecl::next_node = (SgTemplateInstantiationMemberFunctionDecl*) (*block);
   96644             : 
   96645           0 :           while ( block != SgTemplateInstantiationMemberFunctionDecl::pools.end() )
   96646             :              {
   96647           0 :                pointer = (SgTemplateInstantiationMemberFunctionDecl*) (*block);
   96648           0 :                if ( tempPointer != NULL )
   96649             :                   {
   96650           0 :                     tempPointer->set_freepointer(pointer);
   96651             :                   }
   96652           0 :                for (unsigned i = 0; i < SgTemplateInstantiationMemberFunctionDecl::pool_size - 1; ++i)
   96653             :                   {
   96654           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   96655             :                   }
   96656           0 :                 pointer[SgTemplateInstantiationMemberFunctionDecl::pool_size-1].set_freepointer(NULL);
   96657           0 :                 tempPointer = &(pointer[SgTemplateInstantiationMemberFunctionDecl::pool_size-1]);
   96658           0 :                 ++block;
   96659             :              }
   96660             :         }
   96661           0 :    }
   96662             : 
   96663           5 : void SgTemplateInstantiationMemberFunctionDecl::deleteMemoryPool() {
   96664           7 :   for (auto p: SgTemplateInstantiationMemberFunctionDecl::pools) {
   96665           2 :     ROSE_FREE(p);
   96666             :   }
   96667           5 :   SgTemplateInstantiationMemberFunctionDecl::next_node = nullptr;
   96668           5 :   SgTemplateInstantiationMemberFunctionDecl::pools.clear();
   96669           5 : }
   96670             : 
   96671             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   96672             : //                 reading multiple binary files to for a single AST.
   96673             : /////////// new version ////////////////////////////////
   96674             : //############################################################################
   96675             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   96676             : void
   96677           2 : SgTemplateInstantiationMemberFunctionDecl::extendMemoryPoolForFileIO( )
   96678             :   {
   96679           2 :     size_t blockIndex = SgTemplateInstantiationMemberFunctionDecl::pools.size();
   96680           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationMemberFunctionDecl) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationMemberFunctionDecl);
   96681             : 
   96682           3 :     while ( (blockIndex * SgTemplateInstantiationMemberFunctionDecl::pool_size) < newPoolSize)
   96683             :       {
   96684             : #if ROSE_ALLOC_TRACE
   96685             :         if (blockIndex > 0) {
   96686             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationMemberFunctionDecl) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationMemberFunctionDecl) = %" PRIuPTR " SgTemplateInstantiationMemberFunctionDecl::pool_size = %d \n",
   96687             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationMemberFunctionDecl),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationMemberFunctionDecl),SgTemplateInstantiationMemberFunctionDecl::pool_size);
   96688             :         }
   96689             : #endif
   96690             : 
   96691           1 :         SgTemplateInstantiationMemberFunctionDecl * pointer = (SgTemplateInstantiationMemberFunctionDecl*) ROSE_MALLOC ( SgTemplateInstantiationMemberFunctionDecl::pool_size * sizeof(SgTemplateInstantiationMemberFunctionDecl) );
   96692           1 :         assert( pointer != NULL );
   96693             : #if ROSE_ALLOC_MEMSET == 1
   96694             :         memset(pointer, 0x00, SgTemplateInstantiationMemberFunctionDecl::pool_size * sizeof(SgTemplateInstantiationMemberFunctionDecl));
   96695             : #elif ROSE_ALLOC_MEMSET == 2
   96696             :         memset(pointer, 0xCC, SgTemplateInstantiationMemberFunctionDecl::pool_size * sizeof(SgTemplateInstantiationMemberFunctionDecl));
   96697             : #endif
   96698           1 :         SgTemplateInstantiationMemberFunctionDecl::pools.push_back( (unsigned char*)(pointer) );
   96699           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateInstantiationMemberFunctionDecl::pool_size * sizeof(SgTemplateInstantiationMemberFunctionDecl), V_SgTemplateInstantiationMemberFunctionDecl ) );
   96700             : 
   96701           1 :         if ( SgTemplateInstantiationMemberFunctionDecl::next_node != NULL ) {
   96702           0 :           if ( blockIndex > 0 ) {
   96703           0 :             SgTemplateInstantiationMemberFunctionDecl * blkptr = (SgTemplateInstantiationMemberFunctionDecl*)(SgTemplateInstantiationMemberFunctionDecl::pools[blockIndex-1]);
   96704           0 :             blkptr[ SgTemplateInstantiationMemberFunctionDecl::pool_size - 1 ].set_freepointer(pointer);
   96705             :           }
   96706             :         } else {
   96707           1 :           SgTemplateInstantiationMemberFunctionDecl::next_node = pointer;
   96708             :         }
   96709             : 
   96710        2000 :         for (unsigned i = 0; i < SgTemplateInstantiationMemberFunctionDecl::pool_size-1; ++i)
   96711             :            {
   96712        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   96713             :            }
   96714           1 :         pointer[ SgTemplateInstantiationMemberFunctionDecl::pool_size -1 ].set_freepointer(NULL);
   96715             : 
   96716           1 :         blockIndex++;
   96717             :       }
   96718           2 :   }
   96719             : 
   96720             : //############################################################################
   96721             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   96722             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   96723             :  * not compressed. However, that stuff is not yet implemented! 
   96724             :  */
   96725             : unsigned long
   96726           0 : SgTemplateInstantiationMemberFunctionDecl::getNumberOfLastValidPointer()
   96727             :    {
   96728           0 :       SgTemplateInstantiationMemberFunctionDecl* testPointer = (SgTemplateInstantiationMemberFunctionDecl*)(SgTemplateInstantiationMemberFunctionDecl::pools.back());
   96729           0 :       unsigned long localIndex = SgTemplateInstantiationMemberFunctionDecl::pool_size - 1;
   96730           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   96731             :          {
   96732           0 :            localIndex--;
   96733             :          }
   96734           0 :       return (localIndex + SgTemplateInstantiationMemberFunctionDecl::pool_size * (SgTemplateInstantiationMemberFunctionDecl::pools.size()-1));
   96735             :    }
   96736             : 
   96737             : //############################################################################
   96738             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   96739             :  * memory pool and initializes the data member in class SgTemplateInstantiationMemberFunctionDeclStroageClass
   96740             :  * from its counterpart of SgTemplateInstantiationMemberFunctionDecl. The return value is just for checking, 
   96741             :  * that the whole StorageClassArray is initialized!
   96742             :  */
   96743             : unsigned long
   96744           1 : SgTemplateInstantiationMemberFunctionDecl::initializeStorageClassArray( SgTemplateInstantiationMemberFunctionDeclStorageClass *storageArray )
   96745             :    {
   96746           1 :      unsigned long storageCounter = 0;
   96747           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateInstantiationMemberFunctionDecl::pools.begin();
   96748           1 :      SgTemplateInstantiationMemberFunctionDecl* pointer = NULL;
   96749           2 :      while ( block != SgTemplateInstantiationMemberFunctionDecl::pools.end() ) {
   96750           1 :           pointer = (SgTemplateInstantiationMemberFunctionDecl*) (*block);
   96751        2001 :           for ( unsigned i = 0; i < SgTemplateInstantiationMemberFunctionDecl::pool_size; ++i ) {
   96752        2000 :                if ( pointer->get_freepointer() != NULL ) {
   96753        1739 :                  storageArray->pickOutIRNodeData (pointer) ;
   96754        1739 :                  storageArray++;
   96755        1739 :                  storageCounter++;
   96756             :                }
   96757        2000 :                pointer++;
   96758             :              }
   96759           1 :            block++;
   96760             :         }
   96761           1 :      return storageCounter;
   96762             :    }
   96763             : 
   96764             : /* #line 96765 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   96765             : 
   96766             : 
   96767             : 
   96768             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   96769             : 
   96770             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   96771             : 
   96772             : //############################################################################
   96773             : /* JH (02/02/2006) Constructor of the IR node SgTemplateInstantiationFunctionDecl that takes its 
   96774             :  * corresponding StorageClass as parameter
   96775             :  */
   96776         283 : SgTemplateInstantiationFunctionDecl :: SgTemplateInstantiationFunctionDecl ( const SgTemplateInstantiationFunctionDeclStorageClass& storageSource )   : SgFunctionDeclaration (storageSource)
   96777             :    {
   96778             : 
   96779             : 
   96780             : /* #line 96781 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   96781             : 
   96782         283 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   96783         283 :      p_templateName = SgName ( storageSource.storageOf_templateName ) ;
   96784         283 :      p_templateDeclaration =  (SgTemplateFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_templateDeclaration) );
   96785         283 :      p_templateArguments = storageSource.storageOf_templateArguments.rebuildDataStoredInEasyStorageClass() ;
   96786         283 :      SgTemplateArgumentPtrList::iterator i_templateArguments = p_templateArguments.begin() ; 
   96787         791 :      for ( ; i_templateArguments != p_templateArguments.end(); ++i_templateArguments ) 
   96788             :         {
   96789         508 :           (*i_templateArguments) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_templateArguments) ) );
   96790             :         }
   96791         283 :      p_nameResetFromMangledForm = storageSource.storageOf_nameResetFromMangledForm ;
   96792         283 :      p_template_argument_list_is_explicit = storageSource.storageOf_template_argument_list_is_explicit ;
   96793             : 
   96794             : 
   96795             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   96796             : 
   96797             : 
   96798         283 :    }
   96799             : 
   96800             : //############################################################################
   96801             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   96802             :  * within the working AST. 
   96803             :  */
   96804        2777 : SgTemplateInstantiationFunctionDecl * SgTemplateInstantiationFunctionDecl::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   96805        2777 :      SgTemplateInstantiationFunctionDecl* returnPointer = NULL;
   96806        2777 :      if ( globalIndex != 0 )
   96807             :         {
   96808             : 
   96809             : #if FILE_IO_EXTRA_CHECK
   96810        2777 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateInstantiationFunctionDecl ) ) <= globalIndex ) ;
   96811        2777 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationFunctionDecl + 1 ) ) );
   96812             : #endif
   96813        2777 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateInstantiationFunctionDecl )  
   96814        2777 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateInstantiationFunctionDecl );
   96815        2777 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationFunctionDecl::pool_size;
   96816        2777 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationFunctionDecl::pool_size;
   96817             : 
   96818             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   96819             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   96820             : 
   96821        2777 :           returnPointer = &( ( (SgTemplateInstantiationFunctionDecl*)(SgTemplateInstantiationFunctionDecl::pools[memoryBlock]) ) [positionInPool]) ;
   96822             : 
   96823        2777 :           ROSE_ASSERT( returnPointer != NULL ) ;
   96824             :         }
   96825        2777 :      return returnPointer ;
   96826             :    }
   96827             : 
   96828             : //############################################################################
   96829             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   96830             :   for the AST with the index astIndex
   96831             : */
   96832           0 : SgTemplateInstantiationFunctionDecl * SgTemplateInstantiationFunctionDecl::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   96833           0 :      SgTemplateInstantiationFunctionDecl* returnPointer = NULL;
   96834           0 :      if ( globalIndex != 0 )
   96835             :         {
   96836             : 
   96837             : #if FILE_IO_EXTRA_CHECK
   96838           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateInstantiationFunctionDecl ) ) <= globalIndex ) ;
   96839           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationFunctionDecl + 1 ) ) );
   96840             : #endif
   96841           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateInstantiationFunctionDecl )
   96842           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateInstantiationFunctionDecl );
   96843           0 :           unsigned long positionInPool = localIndex % SgTemplateInstantiationFunctionDecl::pool_size ;
   96844           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateInstantiationFunctionDecl::pool_size ;
   96845             : 
   96846             : #if FILE_IO_EXTRA_CHECK
   96847             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   96848             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   96849             : #endif
   96850             : 
   96851           0 :           returnPointer = &( ( (SgTemplateInstantiationFunctionDecl*)(SgTemplateInstantiationFunctionDecl::pools[memoryBlock]) ) [positionInPool]) ;
   96852             : 
   96853             : #if FILE_IO_EXTRA_CHECK
   96854           0 :           assert ( returnPointer != NULL ) ;
   96855             : #endif
   96856             :         }
   96857           0 :      return returnPointer ;
   96858             :    }
   96859             : 
   96860             : //############################################################################
   96861             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   96862             :  * pool size! We set for every valid object in the memory pool the freepointer
   96863             :  * to the global index and increase the global index afterwards. For all the 
   96864             :  * invalid objects (means address ranges within the memory pool that were not
   96865             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   96866             :  * distinguish valid from invalid objects! 
   96867             :  */
   96868             : unsigned long
   96869           5 : SgTemplateInstantiationFunctionDecl::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   96870             :    {
   96871           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   96872           5 :      SgTemplateInstantiationFunctionDecl* pointer = NULL;
   96873           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   96874           5 :      std::vector < unsigned char* > :: const_iterator block;
   96875           6 :      for ( block = SgTemplateInstantiationFunctionDecl::pools.begin(); block != SgTemplateInstantiationFunctionDecl::pools.end() ; ++block )
   96876             :         {
   96877           1 :           pointer = (SgTemplateInstantiationFunctionDecl*)(*block);
   96878        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationFunctionDecl::pool_size; ++i )
   96879             :              {
   96880             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   96881             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   96882             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   96883             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   96884             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   96885             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   96886             :             // properly; so this will have to be checked next.
   96887             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   96888             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   96889        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   96890             :                   {
   96891         283 :                     pointer[i].set_freepointer((SgTemplateInstantiationFunctionDecl*)(globalIndex));
   96892         283 :                     globalIndex++;
   96893             :                   }
   96894             :                else
   96895             :                   {
   96896        1717 :                     pointer[i].set_freepointer(NULL);
   96897             :                   }
   96898             :               }
   96899             :         }
   96900           5 :      return globalIndex;
   96901             :    }
   96902             : 
   96903             : //############################################################################
   96904             : // JH (01/14/2006)
   96905             : void
   96906           5 : SgTemplateInstantiationFunctionDecl::resetValidFreepointers( )
   96907             :    {
   96908           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   96909           5 :      SgTemplateInstantiationFunctionDecl* pointer = NULL;
   96910           5 :      std::vector < unsigned char* > :: const_iterator block;
   96911           5 :      SgTemplateInstantiationFunctionDecl* pointerOfLinkedList = NULL;
   96912           6 :      for ( block = SgTemplateInstantiationFunctionDecl::pools.begin(); block != SgTemplateInstantiationFunctionDecl::pools.end() ; ++block )
   96913             :         {
   96914           1 :           pointer = (SgTemplateInstantiationFunctionDecl*)(*block);
   96915        2001 :           for (unsigned i = 0; i < SgTemplateInstantiationFunctionDecl::pool_size; ++i )
   96916             :              {
   96917             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   96918             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   96919             :             // memory blocks!.
   96920        2000 :                if ( pointer[i].get_freepointer() != NULL )
   96921             :                   {
   96922         283 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   96923             :                   }
   96924             :                else
   96925             :                   {
   96926        1717 :                     if ( pointerOfLinkedList == NULL )
   96927             :                        {
   96928           1 :                          SgTemplateInstantiationFunctionDecl::next_node = &(pointer[i]);
   96929             :                        }
   96930             :                     else
   96931             :                        {
   96932             :                       // printf ("In SgTemplateInstantiationFunctionDecl::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   96933        1716 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   96934             :                        }
   96935             :                     pointerOfLinkedList = &(pointer[i]);
   96936             :                   }
   96937             :               }
   96938             :         }
   96939             : 
   96940           5 :      if ( pointerOfLinkedList != NULL )
   96941             :         {
   96942             :        // printf ("In SgTemplateInstantiationFunctionDecl::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   96943           1 :           pointerOfLinkedList->set_freepointer(NULL);
   96944             :        // DQ (6/6/2010): Temporary debugging...
   96945             :        //   ROSE_ASSERT(false);
   96946             :         }
   96947             : 
   96948           5 :      return ;
   96949             :    }
   96950             : 
   96951             : //############################################################################
   96952             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   96953             :  * within the memory pool and resets the freepointers, in order to achieve a 
   96954             :  * linked list, that has no jumps and starts at the beginning! This function 
   96955             :  * does not extend the memory pool, since we do not delete any memory blocks,
   96956             :  * but delete the valid objects.  
   96957             :  */
   96958             : void
   96959           0 : SgTemplateInstantiationFunctionDecl::clearMemoryPool( )
   96960             :    {
   96961             :   // printf ("Inside of SgTemplateInstantiationFunctionDecl::clearMemoryPool() \n");
   96962             : 
   96963           0 :      SgTemplateInstantiationFunctionDecl* pointer = NULL, *tempPointer = NULL;
   96964           0 :      std::vector < unsigned char* > :: const_iterator block;
   96965           0 :      if ( SgTemplateInstantiationFunctionDecl::pools.empty() == false )
   96966             :         {
   96967           0 :           block = SgTemplateInstantiationFunctionDecl::pools.begin() ;
   96968           0 :           SgTemplateInstantiationFunctionDecl::next_node = (SgTemplateInstantiationFunctionDecl*) (*block);
   96969             : 
   96970           0 :           while ( block != SgTemplateInstantiationFunctionDecl::pools.end() )
   96971             :              {
   96972           0 :                pointer = (SgTemplateInstantiationFunctionDecl*) (*block);
   96973           0 :                if ( tempPointer != NULL )
   96974             :                   {
   96975           0 :                     tempPointer->set_freepointer(pointer);
   96976             :                   }
   96977           0 :                for (unsigned i = 0; i < SgTemplateInstantiationFunctionDecl::pool_size - 1; ++i)
   96978             :                   {
   96979           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   96980             :                   }
   96981           0 :                 pointer[SgTemplateInstantiationFunctionDecl::pool_size-1].set_freepointer(NULL);
   96982           0 :                 tempPointer = &(pointer[SgTemplateInstantiationFunctionDecl::pool_size-1]);
   96983           0 :                 ++block;
   96984             :              }
   96985             :         }
   96986           0 :    }
   96987             : 
   96988           5 : void SgTemplateInstantiationFunctionDecl::deleteMemoryPool() {
   96989           7 :   for (auto p: SgTemplateInstantiationFunctionDecl::pools) {
   96990           2 :     ROSE_FREE(p);
   96991             :   }
   96992           5 :   SgTemplateInstantiationFunctionDecl::next_node = nullptr;
   96993           5 :   SgTemplateInstantiationFunctionDecl::pools.clear();
   96994           5 : }
   96995             : 
   96996             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   96997             : //                 reading multiple binary files to for a single AST.
   96998             : /////////// new version ////////////////////////////////
   96999             : //############################################################################
   97000             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   97001             : void
   97002           2 : SgTemplateInstantiationFunctionDecl::extendMemoryPoolForFileIO( )
   97003             :   {
   97004           2 :     size_t blockIndex = SgTemplateInstantiationFunctionDecl::pools.size();
   97005           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationFunctionDecl) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationFunctionDecl);
   97006             : 
   97007           3 :     while ( (blockIndex * SgTemplateInstantiationFunctionDecl::pool_size) < newPoolSize)
   97008             :       {
   97009             : #if ROSE_ALLOC_TRACE
   97010             :         if (blockIndex > 0) {
   97011             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationFunctionDecl) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationFunctionDecl) = %" PRIuPTR " SgTemplateInstantiationFunctionDecl::pool_size = %d \n",
   97012             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateInstantiationFunctionDecl),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateInstantiationFunctionDecl),SgTemplateInstantiationFunctionDecl::pool_size);
   97013             :         }
   97014             : #endif
   97015             : 
   97016           1 :         SgTemplateInstantiationFunctionDecl * pointer = (SgTemplateInstantiationFunctionDecl*) ROSE_MALLOC ( SgTemplateInstantiationFunctionDecl::pool_size * sizeof(SgTemplateInstantiationFunctionDecl) );
   97017           1 :         assert( pointer != NULL );
   97018             : #if ROSE_ALLOC_MEMSET == 1
   97019             :         memset(pointer, 0x00, SgTemplateInstantiationFunctionDecl::pool_size * sizeof(SgTemplateInstantiationFunctionDecl));
   97020             : #elif ROSE_ALLOC_MEMSET == 2
   97021             :         memset(pointer, 0xCC, SgTemplateInstantiationFunctionDecl::pool_size * sizeof(SgTemplateInstantiationFunctionDecl));
   97022             : #endif
   97023           1 :         SgTemplateInstantiationFunctionDecl::pools.push_back( (unsigned char*)(pointer) );
   97024           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateInstantiationFunctionDecl::pool_size * sizeof(SgTemplateInstantiationFunctionDecl), V_SgTemplateInstantiationFunctionDecl ) );
   97025             : 
   97026           1 :         if ( SgTemplateInstantiationFunctionDecl::next_node != NULL ) {
   97027           0 :           if ( blockIndex > 0 ) {
   97028           0 :             SgTemplateInstantiationFunctionDecl * blkptr = (SgTemplateInstantiationFunctionDecl*)(SgTemplateInstantiationFunctionDecl::pools[blockIndex-1]);
   97029           0 :             blkptr[ SgTemplateInstantiationFunctionDecl::pool_size - 1 ].set_freepointer(pointer);
   97030             :           }
   97031             :         } else {
   97032           1 :           SgTemplateInstantiationFunctionDecl::next_node = pointer;
   97033             :         }
   97034             : 
   97035        2000 :         for (unsigned i = 0; i < SgTemplateInstantiationFunctionDecl::pool_size-1; ++i)
   97036             :            {
   97037        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   97038             :            }
   97039           1 :         pointer[ SgTemplateInstantiationFunctionDecl::pool_size -1 ].set_freepointer(NULL);
   97040             : 
   97041           1 :         blockIndex++;
   97042             :       }
   97043           2 :   }
   97044             : 
   97045             : //############################################################################
   97046             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   97047             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   97048             :  * not compressed. However, that stuff is not yet implemented! 
   97049             :  */
   97050             : unsigned long
   97051           0 : SgTemplateInstantiationFunctionDecl::getNumberOfLastValidPointer()
   97052             :    {
   97053           0 :       SgTemplateInstantiationFunctionDecl* testPointer = (SgTemplateInstantiationFunctionDecl*)(SgTemplateInstantiationFunctionDecl::pools.back());
   97054           0 :       unsigned long localIndex = SgTemplateInstantiationFunctionDecl::pool_size - 1;
   97055           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   97056             :          {
   97057           0 :            localIndex--;
   97058             :          }
   97059           0 :       return (localIndex + SgTemplateInstantiationFunctionDecl::pool_size * (SgTemplateInstantiationFunctionDecl::pools.size()-1));
   97060             :    }
   97061             : 
   97062             : //############################################################################
   97063             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   97064             :  * memory pool and initializes the data member in class SgTemplateInstantiationFunctionDeclStroageClass
   97065             :  * from its counterpart of SgTemplateInstantiationFunctionDecl. The return value is just for checking, 
   97066             :  * that the whole StorageClassArray is initialized!
   97067             :  */
   97068             : unsigned long
   97069           1 : SgTemplateInstantiationFunctionDecl::initializeStorageClassArray( SgTemplateInstantiationFunctionDeclStorageClass *storageArray )
   97070             :    {
   97071           1 :      unsigned long storageCounter = 0;
   97072           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateInstantiationFunctionDecl::pools.begin();
   97073           1 :      SgTemplateInstantiationFunctionDecl* pointer = NULL;
   97074           2 :      while ( block != SgTemplateInstantiationFunctionDecl::pools.end() ) {
   97075           1 :           pointer = (SgTemplateInstantiationFunctionDecl*) (*block);
   97076        2001 :           for ( unsigned i = 0; i < SgTemplateInstantiationFunctionDecl::pool_size; ++i ) {
   97077        2000 :                if ( pointer->get_freepointer() != NULL ) {
   97078         283 :                  storageArray->pickOutIRNodeData (pointer) ;
   97079         283 :                  storageArray++;
   97080         283 :                  storageCounter++;
   97081             :                }
   97082        2000 :                pointer++;
   97083             :              }
   97084           1 :            block++;
   97085             :         }
   97086           1 :      return storageCounter;
   97087             :    }
   97088             : 
   97089             : /* #line 97090 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   97090             : 
   97091             : 
   97092             : 
   97093             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   97094             : 
   97095             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   97096             : 
   97097             : //############################################################################
   97098             : /* JH (02/02/2006) Constructor of the IR node SgProgramHeaderStatement that takes its 
   97099             :  * corresponding StorageClass as parameter
   97100             :  */
   97101           0 : SgProgramHeaderStatement :: SgProgramHeaderStatement ( const SgProgramHeaderStatementStorageClass& storageSource )   : SgFunctionDeclaration (storageSource)
   97102             :    {
   97103             : 
   97104             : 
   97105             : /* #line 97106 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   97106             : 
   97107           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   97108           0 :      p_program_statement_explicit = storageSource.storageOf_program_statement_explicit ;
   97109           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   97110             : 
   97111             : 
   97112             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   97113             : 
   97114             : 
   97115           0 :    }
   97116             : 
   97117             : //############################################################################
   97118             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   97119             :  * within the working AST. 
   97120             :  */
   97121           0 : SgProgramHeaderStatement * SgProgramHeaderStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   97122           0 :      SgProgramHeaderStatement* returnPointer = NULL;
   97123           0 :      if ( globalIndex != 0 )
   97124             :         {
   97125             : 
   97126             : #if FILE_IO_EXTRA_CHECK
   97127           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgProgramHeaderStatement ) ) <= globalIndex ) ;
   97128           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgProgramHeaderStatement + 1 ) ) );
   97129             : #endif
   97130           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgProgramHeaderStatement )  
   97131           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgProgramHeaderStatement );
   97132           0 :           unsigned long positionInPool = localIndex % SgProgramHeaderStatement::pool_size;
   97133           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgProgramHeaderStatement::pool_size;
   97134             : 
   97135             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   97136             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   97137             : 
   97138           0 :           returnPointer = &( ( (SgProgramHeaderStatement*)(SgProgramHeaderStatement::pools[memoryBlock]) ) [positionInPool]) ;
   97139             : 
   97140           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   97141             :         }
   97142           0 :      return returnPointer ;
   97143             :    }
   97144             : 
   97145             : //############################################################################
   97146             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   97147             :   for the AST with the index astIndex
   97148             : */
   97149           0 : SgProgramHeaderStatement * SgProgramHeaderStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   97150           0 :      SgProgramHeaderStatement* returnPointer = NULL;
   97151           0 :      if ( globalIndex != 0 )
   97152             :         {
   97153             : 
   97154             : #if FILE_IO_EXTRA_CHECK
   97155           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgProgramHeaderStatement ) ) <= globalIndex ) ;
   97156           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgProgramHeaderStatement + 1 ) ) );
   97157             : #endif
   97158           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgProgramHeaderStatement )
   97159           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgProgramHeaderStatement );
   97160           0 :           unsigned long positionInPool = localIndex % SgProgramHeaderStatement::pool_size ;
   97161           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgProgramHeaderStatement::pool_size ;
   97162             : 
   97163             : #if FILE_IO_EXTRA_CHECK
   97164             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   97165             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   97166             : #endif
   97167             : 
   97168           0 :           returnPointer = &( ( (SgProgramHeaderStatement*)(SgProgramHeaderStatement::pools[memoryBlock]) ) [positionInPool]) ;
   97169             : 
   97170             : #if FILE_IO_EXTRA_CHECK
   97171           0 :           assert ( returnPointer != NULL ) ;
   97172             : #endif
   97173             :         }
   97174           0 :      return returnPointer ;
   97175             :    }
   97176             : 
   97177             : //############################################################################
   97178             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   97179             :  * pool size! We set for every valid object in the memory pool the freepointer
   97180             :  * to the global index and increase the global index afterwards. For all the 
   97181             :  * invalid objects (means address ranges within the memory pool that were not
   97182             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   97183             :  * distinguish valid from invalid objects! 
   97184             :  */
   97185             : unsigned long
   97186           5 : SgProgramHeaderStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   97187             :    {
   97188           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   97189           5 :      SgProgramHeaderStatement* pointer = NULL;
   97190           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   97191           5 :      std::vector < unsigned char* > :: const_iterator block;
   97192           6 :      for ( block = SgProgramHeaderStatement::pools.begin(); block != SgProgramHeaderStatement::pools.end() ; ++block )
   97193             :         {
   97194           1 :           pointer = (SgProgramHeaderStatement*)(*block);
   97195        2001 :           for (unsigned i = 0; i < SgProgramHeaderStatement::pool_size; ++i )
   97196             :              {
   97197             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   97198             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   97199             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   97200             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   97201             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   97202             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   97203             :             // properly; so this will have to be checked next.
   97204             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   97205             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   97206        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   97207             :                   {
   97208           1 :                     pointer[i].set_freepointer((SgProgramHeaderStatement*)(globalIndex));
   97209           1 :                     globalIndex++;
   97210             :                   }
   97211             :                else
   97212             :                   {
   97213        1999 :                     pointer[i].set_freepointer(NULL);
   97214             :                   }
   97215             :               }
   97216             :         }
   97217           5 :      return globalIndex;
   97218             :    }
   97219             : 
   97220             : //############################################################################
   97221             : // JH (01/14/2006)
   97222             : void
   97223           5 : SgProgramHeaderStatement::resetValidFreepointers( )
   97224             :    {
   97225           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   97226           5 :      SgProgramHeaderStatement* pointer = NULL;
   97227           5 :      std::vector < unsigned char* > :: const_iterator block;
   97228           5 :      SgProgramHeaderStatement* pointerOfLinkedList = NULL;
   97229           6 :      for ( block = SgProgramHeaderStatement::pools.begin(); block != SgProgramHeaderStatement::pools.end() ; ++block )
   97230             :         {
   97231           1 :           pointer = (SgProgramHeaderStatement*)(*block);
   97232        2001 :           for (unsigned i = 0; i < SgProgramHeaderStatement::pool_size; ++i )
   97233             :              {
   97234             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   97235             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   97236             :             // memory blocks!.
   97237        2000 :                if ( pointer[i].get_freepointer() != NULL )
   97238             :                   {
   97239           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   97240             :                   }
   97241             :                else
   97242             :                   {
   97243        1999 :                     if ( pointerOfLinkedList == NULL )
   97244             :                        {
   97245           1 :                          SgProgramHeaderStatement::next_node = &(pointer[i]);
   97246             :                        }
   97247             :                     else
   97248             :                        {
   97249             :                       // printf ("In SgProgramHeaderStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   97250        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   97251             :                        }
   97252             :                     pointerOfLinkedList = &(pointer[i]);
   97253             :                   }
   97254             :               }
   97255             :         }
   97256             : 
   97257           5 :      if ( pointerOfLinkedList != NULL )
   97258             :         {
   97259             :        // printf ("In SgProgramHeaderStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   97260           1 :           pointerOfLinkedList->set_freepointer(NULL);
   97261             :        // DQ (6/6/2010): Temporary debugging...
   97262             :        //   ROSE_ASSERT(false);
   97263             :         }
   97264             : 
   97265           5 :      return ;
   97266             :    }
   97267             : 
   97268             : //############################################################################
   97269             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   97270             :  * within the memory pool and resets the freepointers, in order to achieve a 
   97271             :  * linked list, that has no jumps and starts at the beginning! This function 
   97272             :  * does not extend the memory pool, since we do not delete any memory blocks,
   97273             :  * but delete the valid objects.  
   97274             :  */
   97275             : void
   97276           0 : SgProgramHeaderStatement::clearMemoryPool( )
   97277             :    {
   97278             :   // printf ("Inside of SgProgramHeaderStatement::clearMemoryPool() \n");
   97279             : 
   97280           0 :      SgProgramHeaderStatement* pointer = NULL, *tempPointer = NULL;
   97281           0 :      std::vector < unsigned char* > :: const_iterator block;
   97282           0 :      if ( SgProgramHeaderStatement::pools.empty() == false )
   97283             :         {
   97284           0 :           block = SgProgramHeaderStatement::pools.begin() ;
   97285           0 :           SgProgramHeaderStatement::next_node = (SgProgramHeaderStatement*) (*block);
   97286             : 
   97287           0 :           while ( block != SgProgramHeaderStatement::pools.end() )
   97288             :              {
   97289           0 :                pointer = (SgProgramHeaderStatement*) (*block);
   97290           0 :                if ( tempPointer != NULL )
   97291             :                   {
   97292           0 :                     tempPointer->set_freepointer(pointer);
   97293             :                   }
   97294           0 :                for (unsigned i = 0; i < SgProgramHeaderStatement::pool_size - 1; ++i)
   97295             :                   {
   97296           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   97297             :                   }
   97298           0 :                 pointer[SgProgramHeaderStatement::pool_size-1].set_freepointer(NULL);
   97299           0 :                 tempPointer = &(pointer[SgProgramHeaderStatement::pool_size-1]);
   97300           0 :                 ++block;
   97301             :              }
   97302             :         }
   97303           0 :    }
   97304             : 
   97305           5 : void SgProgramHeaderStatement::deleteMemoryPool() {
   97306           6 :   for (auto p: SgProgramHeaderStatement::pools) {
   97307           1 :     ROSE_FREE(p);
   97308             :   }
   97309           5 :   SgProgramHeaderStatement::next_node = nullptr;
   97310           5 :   SgProgramHeaderStatement::pools.clear();
   97311           5 : }
   97312             : 
   97313             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   97314             : //                 reading multiple binary files to for a single AST.
   97315             : /////////// new version ////////////////////////////////
   97316             : //############################################################################
   97317             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   97318             : void
   97319           2 : SgProgramHeaderStatement::extendMemoryPoolForFileIO( )
   97320             :   {
   97321           2 :     size_t blockIndex = SgProgramHeaderStatement::pools.size();
   97322           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgProgramHeaderStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgProgramHeaderStatement);
   97323             : 
   97324           2 :     while ( (blockIndex * SgProgramHeaderStatement::pool_size) < newPoolSize)
   97325             :       {
   97326             : #if ROSE_ALLOC_TRACE
   97327             :         if (blockIndex > 0) {
   97328             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgProgramHeaderStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgProgramHeaderStatement) = %" PRIuPTR " SgProgramHeaderStatement::pool_size = %d \n",
   97329             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgProgramHeaderStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgProgramHeaderStatement),SgProgramHeaderStatement::pool_size);
   97330             :         }
   97331             : #endif
   97332             : 
   97333           0 :         SgProgramHeaderStatement * pointer = (SgProgramHeaderStatement*) ROSE_MALLOC ( SgProgramHeaderStatement::pool_size * sizeof(SgProgramHeaderStatement) );
   97334           0 :         assert( pointer != NULL );
   97335             : #if ROSE_ALLOC_MEMSET == 1
   97336             :         memset(pointer, 0x00, SgProgramHeaderStatement::pool_size * sizeof(SgProgramHeaderStatement));
   97337             : #elif ROSE_ALLOC_MEMSET == 2
   97338             :         memset(pointer, 0xCC, SgProgramHeaderStatement::pool_size * sizeof(SgProgramHeaderStatement));
   97339             : #endif
   97340           0 :         SgProgramHeaderStatement::pools.push_back( (unsigned char*)(pointer) );
   97341           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgProgramHeaderStatement::pool_size * sizeof(SgProgramHeaderStatement), V_SgProgramHeaderStatement ) );
   97342             : 
   97343           0 :         if ( SgProgramHeaderStatement::next_node != NULL ) {
   97344           0 :           if ( blockIndex > 0 ) {
   97345           0 :             SgProgramHeaderStatement * blkptr = (SgProgramHeaderStatement*)(SgProgramHeaderStatement::pools[blockIndex-1]);
   97346           0 :             blkptr[ SgProgramHeaderStatement::pool_size - 1 ].set_freepointer(pointer);
   97347             :           }
   97348             :         } else {
   97349           0 :           SgProgramHeaderStatement::next_node = pointer;
   97350             :         }
   97351             : 
   97352           0 :         for (unsigned i = 0; i < SgProgramHeaderStatement::pool_size-1; ++i)
   97353             :            {
   97354           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   97355             :            }
   97356           0 :         pointer[ SgProgramHeaderStatement::pool_size -1 ].set_freepointer(NULL);
   97357             : 
   97358           0 :         blockIndex++;
   97359             :       }
   97360           2 :   }
   97361             : 
   97362             : //############################################################################
   97363             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   97364             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   97365             :  * not compressed. However, that stuff is not yet implemented! 
   97366             :  */
   97367             : unsigned long
   97368           0 : SgProgramHeaderStatement::getNumberOfLastValidPointer()
   97369             :    {
   97370           0 :       SgProgramHeaderStatement* testPointer = (SgProgramHeaderStatement*)(SgProgramHeaderStatement::pools.back());
   97371           0 :       unsigned long localIndex = SgProgramHeaderStatement::pool_size - 1;
   97372           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   97373             :          {
   97374           0 :            localIndex--;
   97375             :          }
   97376           0 :       return (localIndex + SgProgramHeaderStatement::pool_size * (SgProgramHeaderStatement::pools.size()-1));
   97377             :    }
   97378             : 
   97379             : //############################################################################
   97380             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   97381             :  * memory pool and initializes the data member in class SgProgramHeaderStatementStroageClass
   97382             :  * from its counterpart of SgProgramHeaderStatement. The return value is just for checking, 
   97383             :  * that the whole StorageClassArray is initialized!
   97384             :  */
   97385             : unsigned long
   97386           1 : SgProgramHeaderStatement::initializeStorageClassArray( SgProgramHeaderStatementStorageClass *storageArray )
   97387             :    {
   97388           1 :      unsigned long storageCounter = 0;
   97389           1 :      std::vector < unsigned char* > :: const_iterator block = SgProgramHeaderStatement::pools.begin();
   97390           1 :      SgProgramHeaderStatement* pointer = NULL;
   97391           2 :      while ( block != SgProgramHeaderStatement::pools.end() ) {
   97392           1 :           pointer = (SgProgramHeaderStatement*) (*block);
   97393        2001 :           for ( unsigned i = 0; i < SgProgramHeaderStatement::pool_size; ++i ) {
   97394        2000 :                if ( pointer->get_freepointer() != NULL ) {
   97395           1 :                  storageArray->pickOutIRNodeData (pointer) ;
   97396           1 :                  storageArray++;
   97397           1 :                  storageCounter++;
   97398             :                }
   97399        2000 :                pointer++;
   97400             :              }
   97401           1 :            block++;
   97402             :         }
   97403           1 :      return storageCounter;
   97404             :    }
   97405             : 
   97406             : /* #line 97407 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   97407             : 
   97408             : 
   97409             : 
   97410             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   97411             : 
   97412             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   97413             : 
   97414             : //############################################################################
   97415             : /* JH (02/02/2006) Constructor of the IR node SgProcedureHeaderStatement that takes its 
   97416             :  * corresponding StorageClass as parameter
   97417             :  */
   97418           0 : SgProcedureHeaderStatement :: SgProcedureHeaderStatement ( const SgProcedureHeaderStatementStorageClass& storageSource )   : SgFunctionDeclaration (storageSource)
   97419             :    {
   97420             : 
   97421             : 
   97422             : /* #line 97423 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   97423             : 
   97424           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   97425           0 :      p_subprogram_kind = storageSource.storageOf_subprogram_kind ;
   97426           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
   97427           0 :      p_result_name =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_result_name) );
   97428             : 
   97429             : 
   97430             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   97431             : 
   97432             : 
   97433           0 :    }
   97434             : 
   97435             : //############################################################################
   97436             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   97437             :  * within the working AST. 
   97438             :  */
   97439           0 : SgProcedureHeaderStatement * SgProcedureHeaderStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   97440           0 :      SgProcedureHeaderStatement* returnPointer = NULL;
   97441           0 :      if ( globalIndex != 0 )
   97442             :         {
   97443             : 
   97444             : #if FILE_IO_EXTRA_CHECK
   97445           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgProcedureHeaderStatement ) ) <= globalIndex ) ;
   97446           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgProcedureHeaderStatement + 1 ) ) );
   97447             : #endif
   97448           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgProcedureHeaderStatement )  
   97449           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgProcedureHeaderStatement );
   97450           0 :           unsigned long positionInPool = localIndex % SgProcedureHeaderStatement::pool_size;
   97451           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgProcedureHeaderStatement::pool_size;
   97452             : 
   97453             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   97454             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   97455             : 
   97456           0 :           returnPointer = &( ( (SgProcedureHeaderStatement*)(SgProcedureHeaderStatement::pools[memoryBlock]) ) [positionInPool]) ;
   97457             : 
   97458           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   97459             :         }
   97460           0 :      return returnPointer ;
   97461             :    }
   97462             : 
   97463             : //############################################################################
   97464             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   97465             :   for the AST with the index astIndex
   97466             : */
   97467           0 : SgProcedureHeaderStatement * SgProcedureHeaderStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   97468           0 :      SgProcedureHeaderStatement* returnPointer = NULL;
   97469           0 :      if ( globalIndex != 0 )
   97470             :         {
   97471             : 
   97472             : #if FILE_IO_EXTRA_CHECK
   97473           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgProcedureHeaderStatement ) ) <= globalIndex ) ;
   97474           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgProcedureHeaderStatement + 1 ) ) );
   97475             : #endif
   97476           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgProcedureHeaderStatement )
   97477           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgProcedureHeaderStatement );
   97478           0 :           unsigned long positionInPool = localIndex % SgProcedureHeaderStatement::pool_size ;
   97479           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgProcedureHeaderStatement::pool_size ;
   97480             : 
   97481             : #if FILE_IO_EXTRA_CHECK
   97482             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   97483             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   97484             : #endif
   97485             : 
   97486           0 :           returnPointer = &( ( (SgProcedureHeaderStatement*)(SgProcedureHeaderStatement::pools[memoryBlock]) ) [positionInPool]) ;
   97487             : 
   97488             : #if FILE_IO_EXTRA_CHECK
   97489           0 :           assert ( returnPointer != NULL ) ;
   97490             : #endif
   97491             :         }
   97492           0 :      return returnPointer ;
   97493             :    }
   97494             : 
   97495             : //############################################################################
   97496             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   97497             :  * pool size! We set for every valid object in the memory pool the freepointer
   97498             :  * to the global index and increase the global index afterwards. For all the 
   97499             :  * invalid objects (means address ranges within the memory pool that were not
   97500             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   97501             :  * distinguish valid from invalid objects! 
   97502             :  */
   97503             : unsigned long
   97504           5 : SgProcedureHeaderStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   97505             :    {
   97506           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   97507           5 :      SgProcedureHeaderStatement* pointer = NULL;
   97508           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   97509           5 :      std::vector < unsigned char* > :: const_iterator block;
   97510           5 :      for ( block = SgProcedureHeaderStatement::pools.begin(); block != SgProcedureHeaderStatement::pools.end() ; ++block )
   97511             :         {
   97512           0 :           pointer = (SgProcedureHeaderStatement*)(*block);
   97513           0 :           for (unsigned i = 0; i < SgProcedureHeaderStatement::pool_size; ++i )
   97514             :              {
   97515             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   97516             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   97517             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   97518             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   97519             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   97520             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   97521             :             // properly; so this will have to be checked next.
   97522             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   97523             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   97524           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   97525             :                   {
   97526           0 :                     pointer[i].set_freepointer((SgProcedureHeaderStatement*)(globalIndex));
   97527           0 :                     globalIndex++;
   97528             :                   }
   97529             :                else
   97530             :                   {
   97531           0 :                     pointer[i].set_freepointer(NULL);
   97532             :                   }
   97533             :               }
   97534             :         }
   97535           5 :      return globalIndex;
   97536             :    }
   97537             : 
   97538             : //############################################################################
   97539             : // JH (01/14/2006)
   97540             : void
   97541           5 : SgProcedureHeaderStatement::resetValidFreepointers( )
   97542             :    {
   97543           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   97544           5 :      SgProcedureHeaderStatement* pointer = NULL;
   97545           5 :      std::vector < unsigned char* > :: const_iterator block;
   97546           5 :      SgProcedureHeaderStatement* pointerOfLinkedList = NULL;
   97547           5 :      for ( block = SgProcedureHeaderStatement::pools.begin(); block != SgProcedureHeaderStatement::pools.end() ; ++block )
   97548             :         {
   97549           0 :           pointer = (SgProcedureHeaderStatement*)(*block);
   97550           0 :           for (unsigned i = 0; i < SgProcedureHeaderStatement::pool_size; ++i )
   97551             :              {
   97552             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   97553             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   97554             :             // memory blocks!.
   97555           0 :                if ( pointer[i].get_freepointer() != NULL )
   97556             :                   {
   97557           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   97558             :                   }
   97559             :                else
   97560             :                   {
   97561           0 :                     if ( pointerOfLinkedList == NULL )
   97562             :                        {
   97563           0 :                          SgProcedureHeaderStatement::next_node = &(pointer[i]);
   97564             :                        }
   97565             :                     else
   97566             :                        {
   97567             :                       // printf ("In SgProcedureHeaderStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   97568           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   97569             :                        }
   97570             :                     pointerOfLinkedList = &(pointer[i]);
   97571             :                   }
   97572             :               }
   97573             :         }
   97574             : 
   97575           5 :      if ( pointerOfLinkedList != NULL )
   97576             :         {
   97577             :        // printf ("In SgProcedureHeaderStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   97578           0 :           pointerOfLinkedList->set_freepointer(NULL);
   97579             :        // DQ (6/6/2010): Temporary debugging...
   97580             :        //   ROSE_ASSERT(false);
   97581             :         }
   97582             : 
   97583           5 :      return ;
   97584             :    }
   97585             : 
   97586             : //############################################################################
   97587             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   97588             :  * within the memory pool and resets the freepointers, in order to achieve a 
   97589             :  * linked list, that has no jumps and starts at the beginning! This function 
   97590             :  * does not extend the memory pool, since we do not delete any memory blocks,
   97591             :  * but delete the valid objects.  
   97592             :  */
   97593             : void
   97594           0 : SgProcedureHeaderStatement::clearMemoryPool( )
   97595             :    {
   97596             :   // printf ("Inside of SgProcedureHeaderStatement::clearMemoryPool() \n");
   97597             : 
   97598           0 :      SgProcedureHeaderStatement* pointer = NULL, *tempPointer = NULL;
   97599           0 :      std::vector < unsigned char* > :: const_iterator block;
   97600           0 :      if ( SgProcedureHeaderStatement::pools.empty() == false )
   97601             :         {
   97602           0 :           block = SgProcedureHeaderStatement::pools.begin() ;
   97603           0 :           SgProcedureHeaderStatement::next_node = (SgProcedureHeaderStatement*) (*block);
   97604             : 
   97605           0 :           while ( block != SgProcedureHeaderStatement::pools.end() )
   97606             :              {
   97607           0 :                pointer = (SgProcedureHeaderStatement*) (*block);
   97608           0 :                if ( tempPointer != NULL )
   97609             :                   {
   97610           0 :                     tempPointer->set_freepointer(pointer);
   97611             :                   }
   97612           0 :                for (unsigned i = 0; i < SgProcedureHeaderStatement::pool_size - 1; ++i)
   97613             :                   {
   97614           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   97615             :                   }
   97616           0 :                 pointer[SgProcedureHeaderStatement::pool_size-1].set_freepointer(NULL);
   97617           0 :                 tempPointer = &(pointer[SgProcedureHeaderStatement::pool_size-1]);
   97618           0 :                 ++block;
   97619             :              }
   97620             :         }
   97621           0 :    }
   97622             : 
   97623           5 : void SgProcedureHeaderStatement::deleteMemoryPool() {
   97624           5 :   for (auto p: SgProcedureHeaderStatement::pools) {
   97625           0 :     ROSE_FREE(p);
   97626             :   }
   97627           5 :   SgProcedureHeaderStatement::next_node = nullptr;
   97628           5 :   SgProcedureHeaderStatement::pools.clear();
   97629           5 : }
   97630             : 
   97631             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   97632             : //                 reading multiple binary files to for a single AST.
   97633             : /////////// new version ////////////////////////////////
   97634             : //############################################################################
   97635             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   97636             : void
   97637           2 : SgProcedureHeaderStatement::extendMemoryPoolForFileIO( )
   97638             :   {
   97639           2 :     size_t blockIndex = SgProcedureHeaderStatement::pools.size();
   97640           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgProcedureHeaderStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgProcedureHeaderStatement);
   97641             : 
   97642           2 :     while ( (blockIndex * SgProcedureHeaderStatement::pool_size) < newPoolSize)
   97643             :       {
   97644             : #if ROSE_ALLOC_TRACE
   97645             :         if (blockIndex > 0) {
   97646             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgProcedureHeaderStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgProcedureHeaderStatement) = %" PRIuPTR " SgProcedureHeaderStatement::pool_size = %d \n",
   97647             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgProcedureHeaderStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgProcedureHeaderStatement),SgProcedureHeaderStatement::pool_size);
   97648             :         }
   97649             : #endif
   97650             : 
   97651           0 :         SgProcedureHeaderStatement * pointer = (SgProcedureHeaderStatement*) ROSE_MALLOC ( SgProcedureHeaderStatement::pool_size * sizeof(SgProcedureHeaderStatement) );
   97652           0 :         assert( pointer != NULL );
   97653             : #if ROSE_ALLOC_MEMSET == 1
   97654             :         memset(pointer, 0x00, SgProcedureHeaderStatement::pool_size * sizeof(SgProcedureHeaderStatement));
   97655             : #elif ROSE_ALLOC_MEMSET == 2
   97656             :         memset(pointer, 0xCC, SgProcedureHeaderStatement::pool_size * sizeof(SgProcedureHeaderStatement));
   97657             : #endif
   97658           0 :         SgProcedureHeaderStatement::pools.push_back( (unsigned char*)(pointer) );
   97659           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgProcedureHeaderStatement::pool_size * sizeof(SgProcedureHeaderStatement), V_SgProcedureHeaderStatement ) );
   97660             : 
   97661           0 :         if ( SgProcedureHeaderStatement::next_node != NULL ) {
   97662           0 :           if ( blockIndex > 0 ) {
   97663           0 :             SgProcedureHeaderStatement * blkptr = (SgProcedureHeaderStatement*)(SgProcedureHeaderStatement::pools[blockIndex-1]);
   97664           0 :             blkptr[ SgProcedureHeaderStatement::pool_size - 1 ].set_freepointer(pointer);
   97665             :           }
   97666             :         } else {
   97667           0 :           SgProcedureHeaderStatement::next_node = pointer;
   97668             :         }
   97669             : 
   97670           0 :         for (unsigned i = 0; i < SgProcedureHeaderStatement::pool_size-1; ++i)
   97671             :            {
   97672           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   97673             :            }
   97674           0 :         pointer[ SgProcedureHeaderStatement::pool_size -1 ].set_freepointer(NULL);
   97675             : 
   97676           0 :         blockIndex++;
   97677             :       }
   97678           2 :   }
   97679             : 
   97680             : //############################################################################
   97681             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   97682             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   97683             :  * not compressed. However, that stuff is not yet implemented! 
   97684             :  */
   97685             : unsigned long
   97686           0 : SgProcedureHeaderStatement::getNumberOfLastValidPointer()
   97687             :    {
   97688           0 :       SgProcedureHeaderStatement* testPointer = (SgProcedureHeaderStatement*)(SgProcedureHeaderStatement::pools.back());
   97689           0 :       unsigned long localIndex = SgProcedureHeaderStatement::pool_size - 1;
   97690           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   97691             :          {
   97692           0 :            localIndex--;
   97693             :          }
   97694           0 :       return (localIndex + SgProcedureHeaderStatement::pool_size * (SgProcedureHeaderStatement::pools.size()-1));
   97695             :    }
   97696             : 
   97697             : //############################################################################
   97698             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   97699             :  * memory pool and initializes the data member in class SgProcedureHeaderStatementStroageClass
   97700             :  * from its counterpart of SgProcedureHeaderStatement. The return value is just for checking, 
   97701             :  * that the whole StorageClassArray is initialized!
   97702             :  */
   97703             : unsigned long
   97704           0 : SgProcedureHeaderStatement::initializeStorageClassArray( SgProcedureHeaderStatementStorageClass *storageArray )
   97705             :    {
   97706           0 :      unsigned long storageCounter = 0;
   97707           0 :      std::vector < unsigned char* > :: const_iterator block = SgProcedureHeaderStatement::pools.begin();
   97708           0 :      SgProcedureHeaderStatement* pointer = NULL;
   97709           0 :      while ( block != SgProcedureHeaderStatement::pools.end() ) {
   97710           0 :           pointer = (SgProcedureHeaderStatement*) (*block);
   97711           0 :           for ( unsigned i = 0; i < SgProcedureHeaderStatement::pool_size; ++i ) {
   97712           0 :                if ( pointer->get_freepointer() != NULL ) {
   97713           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   97714           0 :                  storageArray++;
   97715           0 :                  storageCounter++;
   97716             :                }
   97717           0 :                pointer++;
   97718             :              }
   97719           0 :            block++;
   97720             :         }
   97721           0 :      return storageCounter;
   97722             :    }
   97723             : 
   97724             : /* #line 97725 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   97725             : 
   97726             : 
   97727             : 
   97728             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   97729             : 
   97730             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   97731             : 
   97732             : //############################################################################
   97733             : /* JH (02/02/2006) Constructor of the IR node SgEntryStatement that takes its 
   97734             :  * corresponding StorageClass as parameter
   97735             :  */
   97736           0 : SgEntryStatement :: SgEntryStatement ( const SgEntryStatementStorageClass& storageSource )   : SgFunctionDeclaration (storageSource)
   97737             :    {
   97738             : 
   97739             : 
   97740             : /* #line 97741 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   97741             : 
   97742           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   97743           0 :      p_result_name =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_result_name) );
   97744             : 
   97745             : 
   97746             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   97747             : 
   97748             : 
   97749           0 :    }
   97750             : 
   97751             : //############################################################################
   97752             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   97753             :  * within the working AST. 
   97754             :  */
   97755           0 : SgEntryStatement * SgEntryStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   97756           0 :      SgEntryStatement* returnPointer = NULL;
   97757           0 :      if ( globalIndex != 0 )
   97758             :         {
   97759             : 
   97760             : #if FILE_IO_EXTRA_CHECK
   97761           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEntryStatement ) ) <= globalIndex ) ;
   97762           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEntryStatement + 1 ) ) );
   97763             : #endif
   97764           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEntryStatement )  
   97765           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEntryStatement );
   97766           0 :           unsigned long positionInPool = localIndex % SgEntryStatement::pool_size;
   97767           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEntryStatement::pool_size;
   97768             : 
   97769             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   97770             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   97771             : 
   97772           0 :           returnPointer = &( ( (SgEntryStatement*)(SgEntryStatement::pools[memoryBlock]) ) [positionInPool]) ;
   97773             : 
   97774           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   97775             :         }
   97776           0 :      return returnPointer ;
   97777             :    }
   97778             : 
   97779             : //############################################################################
   97780             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   97781             :   for the AST with the index astIndex
   97782             : */
   97783           0 : SgEntryStatement * SgEntryStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   97784           0 :      SgEntryStatement* returnPointer = NULL;
   97785           0 :      if ( globalIndex != 0 )
   97786             :         {
   97787             : 
   97788             : #if FILE_IO_EXTRA_CHECK
   97789           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEntryStatement ) ) <= globalIndex ) ;
   97790           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEntryStatement + 1 ) ) );
   97791             : #endif
   97792           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEntryStatement )
   97793           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEntryStatement );
   97794           0 :           unsigned long positionInPool = localIndex % SgEntryStatement::pool_size ;
   97795           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEntryStatement::pool_size ;
   97796             : 
   97797             : #if FILE_IO_EXTRA_CHECK
   97798             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   97799             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   97800             : #endif
   97801             : 
   97802           0 :           returnPointer = &( ( (SgEntryStatement*)(SgEntryStatement::pools[memoryBlock]) ) [positionInPool]) ;
   97803             : 
   97804             : #if FILE_IO_EXTRA_CHECK
   97805           0 :           assert ( returnPointer != NULL ) ;
   97806             : #endif
   97807             :         }
   97808           0 :      return returnPointer ;
   97809             :    }
   97810             : 
   97811             : //############################################################################
   97812             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   97813             :  * pool size! We set for every valid object in the memory pool the freepointer
   97814             :  * to the global index and increase the global index afterwards. For all the 
   97815             :  * invalid objects (means address ranges within the memory pool that were not
   97816             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   97817             :  * distinguish valid from invalid objects! 
   97818             :  */
   97819             : unsigned long
   97820           5 : SgEntryStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   97821             :    {
   97822           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   97823           5 :      SgEntryStatement* pointer = NULL;
   97824           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   97825           5 :      std::vector < unsigned char* > :: const_iterator block;
   97826           5 :      for ( block = SgEntryStatement::pools.begin(); block != SgEntryStatement::pools.end() ; ++block )
   97827             :         {
   97828           0 :           pointer = (SgEntryStatement*)(*block);
   97829           0 :           for (unsigned i = 0; i < SgEntryStatement::pool_size; ++i )
   97830             :              {
   97831             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   97832             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   97833             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   97834             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   97835             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   97836             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   97837             :             // properly; so this will have to be checked next.
   97838             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   97839             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   97840           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   97841             :                   {
   97842           0 :                     pointer[i].set_freepointer((SgEntryStatement*)(globalIndex));
   97843           0 :                     globalIndex++;
   97844             :                   }
   97845             :                else
   97846             :                   {
   97847           0 :                     pointer[i].set_freepointer(NULL);
   97848             :                   }
   97849             :               }
   97850             :         }
   97851           5 :      return globalIndex;
   97852             :    }
   97853             : 
   97854             : //############################################################################
   97855             : // JH (01/14/2006)
   97856             : void
   97857           5 : SgEntryStatement::resetValidFreepointers( )
   97858             :    {
   97859           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   97860           5 :      SgEntryStatement* pointer = NULL;
   97861           5 :      std::vector < unsigned char* > :: const_iterator block;
   97862           5 :      SgEntryStatement* pointerOfLinkedList = NULL;
   97863           5 :      for ( block = SgEntryStatement::pools.begin(); block != SgEntryStatement::pools.end() ; ++block )
   97864             :         {
   97865           0 :           pointer = (SgEntryStatement*)(*block);
   97866           0 :           for (unsigned i = 0; i < SgEntryStatement::pool_size; ++i )
   97867             :              {
   97868             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   97869             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   97870             :             // memory blocks!.
   97871           0 :                if ( pointer[i].get_freepointer() != NULL )
   97872             :                   {
   97873           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   97874             :                   }
   97875             :                else
   97876             :                   {
   97877           0 :                     if ( pointerOfLinkedList == NULL )
   97878             :                        {
   97879           0 :                          SgEntryStatement::next_node = &(pointer[i]);
   97880             :                        }
   97881             :                     else
   97882             :                        {
   97883             :                       // printf ("In SgEntryStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   97884           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   97885             :                        }
   97886             :                     pointerOfLinkedList = &(pointer[i]);
   97887             :                   }
   97888             :               }
   97889             :         }
   97890             : 
   97891           5 :      if ( pointerOfLinkedList != NULL )
   97892             :         {
   97893             :        // printf ("In SgEntryStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   97894           0 :           pointerOfLinkedList->set_freepointer(NULL);
   97895             :        // DQ (6/6/2010): Temporary debugging...
   97896             :        //   ROSE_ASSERT(false);
   97897             :         }
   97898             : 
   97899           5 :      return ;
   97900             :    }
   97901             : 
   97902             : //############################################################################
   97903             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   97904             :  * within the memory pool and resets the freepointers, in order to achieve a 
   97905             :  * linked list, that has no jumps and starts at the beginning! This function 
   97906             :  * does not extend the memory pool, since we do not delete any memory blocks,
   97907             :  * but delete the valid objects.  
   97908             :  */
   97909             : void
   97910           0 : SgEntryStatement::clearMemoryPool( )
   97911             :    {
   97912             :   // printf ("Inside of SgEntryStatement::clearMemoryPool() \n");
   97913             : 
   97914           0 :      SgEntryStatement* pointer = NULL, *tempPointer = NULL;
   97915           0 :      std::vector < unsigned char* > :: const_iterator block;
   97916           0 :      if ( SgEntryStatement::pools.empty() == false )
   97917             :         {
   97918           0 :           block = SgEntryStatement::pools.begin() ;
   97919           0 :           SgEntryStatement::next_node = (SgEntryStatement*) (*block);
   97920             : 
   97921           0 :           while ( block != SgEntryStatement::pools.end() )
   97922             :              {
   97923           0 :                pointer = (SgEntryStatement*) (*block);
   97924           0 :                if ( tempPointer != NULL )
   97925             :                   {
   97926           0 :                     tempPointer->set_freepointer(pointer);
   97927             :                   }
   97928           0 :                for (unsigned i = 0; i < SgEntryStatement::pool_size - 1; ++i)
   97929             :                   {
   97930           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   97931             :                   }
   97932           0 :                 pointer[SgEntryStatement::pool_size-1].set_freepointer(NULL);
   97933           0 :                 tempPointer = &(pointer[SgEntryStatement::pool_size-1]);
   97934           0 :                 ++block;
   97935             :              }
   97936             :         }
   97937           0 :    }
   97938             : 
   97939           5 : void SgEntryStatement::deleteMemoryPool() {
   97940           5 :   for (auto p: SgEntryStatement::pools) {
   97941           0 :     ROSE_FREE(p);
   97942             :   }
   97943           5 :   SgEntryStatement::next_node = nullptr;
   97944           5 :   SgEntryStatement::pools.clear();
   97945           5 : }
   97946             : 
   97947             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   97948             : //                 reading multiple binary files to for a single AST.
   97949             : /////////// new version ////////////////////////////////
   97950             : //############################################################################
   97951             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   97952             : void
   97953           2 : SgEntryStatement::extendMemoryPoolForFileIO( )
   97954             :   {
   97955           2 :     size_t blockIndex = SgEntryStatement::pools.size();
   97956           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEntryStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEntryStatement);
   97957             : 
   97958           2 :     while ( (blockIndex * SgEntryStatement::pool_size) < newPoolSize)
   97959             :       {
   97960             : #if ROSE_ALLOC_TRACE
   97961             :         if (blockIndex > 0) {
   97962             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEntryStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEntryStatement) = %" PRIuPTR " SgEntryStatement::pool_size = %d \n",
   97963             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEntryStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEntryStatement),SgEntryStatement::pool_size);
   97964             :         }
   97965             : #endif
   97966             : 
   97967           0 :         SgEntryStatement * pointer = (SgEntryStatement*) ROSE_MALLOC ( SgEntryStatement::pool_size * sizeof(SgEntryStatement) );
   97968           0 :         assert( pointer != NULL );
   97969             : #if ROSE_ALLOC_MEMSET == 1
   97970             :         memset(pointer, 0x00, SgEntryStatement::pool_size * sizeof(SgEntryStatement));
   97971             : #elif ROSE_ALLOC_MEMSET == 2
   97972             :         memset(pointer, 0xCC, SgEntryStatement::pool_size * sizeof(SgEntryStatement));
   97973             : #endif
   97974           0 :         SgEntryStatement::pools.push_back( (unsigned char*)(pointer) );
   97975           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEntryStatement::pool_size * sizeof(SgEntryStatement), V_SgEntryStatement ) );
   97976             : 
   97977           0 :         if ( SgEntryStatement::next_node != NULL ) {
   97978           0 :           if ( blockIndex > 0 ) {
   97979           0 :             SgEntryStatement * blkptr = (SgEntryStatement*)(SgEntryStatement::pools[blockIndex-1]);
   97980           0 :             blkptr[ SgEntryStatement::pool_size - 1 ].set_freepointer(pointer);
   97981             :           }
   97982             :         } else {
   97983           0 :           SgEntryStatement::next_node = pointer;
   97984             :         }
   97985             : 
   97986           0 :         for (unsigned i = 0; i < SgEntryStatement::pool_size-1; ++i)
   97987             :            {
   97988           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   97989             :            }
   97990           0 :         pointer[ SgEntryStatement::pool_size -1 ].set_freepointer(NULL);
   97991             : 
   97992           0 :         blockIndex++;
   97993             :       }
   97994           2 :   }
   97995             : 
   97996             : //############################################################################
   97997             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   97998             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   97999             :  * not compressed. However, that stuff is not yet implemented! 
   98000             :  */
   98001             : unsigned long
   98002           0 : SgEntryStatement::getNumberOfLastValidPointer()
   98003             :    {
   98004           0 :       SgEntryStatement* testPointer = (SgEntryStatement*)(SgEntryStatement::pools.back());
   98005           0 :       unsigned long localIndex = SgEntryStatement::pool_size - 1;
   98006           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   98007             :          {
   98008           0 :            localIndex--;
   98009             :          }
   98010           0 :       return (localIndex + SgEntryStatement::pool_size * (SgEntryStatement::pools.size()-1));
   98011             :    }
   98012             : 
   98013             : //############################################################################
   98014             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   98015             :  * memory pool and initializes the data member in class SgEntryStatementStroageClass
   98016             :  * from its counterpart of SgEntryStatement. The return value is just for checking, 
   98017             :  * that the whole StorageClassArray is initialized!
   98018             :  */
   98019             : unsigned long
   98020           0 : SgEntryStatement::initializeStorageClassArray( SgEntryStatementStorageClass *storageArray )
   98021             :    {
   98022           0 :      unsigned long storageCounter = 0;
   98023           0 :      std::vector < unsigned char* > :: const_iterator block = SgEntryStatement::pools.begin();
   98024           0 :      SgEntryStatement* pointer = NULL;
   98025           0 :      while ( block != SgEntryStatement::pools.end() ) {
   98026           0 :           pointer = (SgEntryStatement*) (*block);
   98027           0 :           for ( unsigned i = 0; i < SgEntryStatement::pool_size; ++i ) {
   98028           0 :                if ( pointer->get_freepointer() != NULL ) {
   98029           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   98030           0 :                  storageArray++;
   98031           0 :                  storageCounter++;
   98032             :                }
   98033           0 :                pointer++;
   98034             :              }
   98035           0 :            block++;
   98036             :         }
   98037           0 :      return storageCounter;
   98038             :    }
   98039             : 
   98040             : /* #line 98041 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   98041             : 
   98042             : 
   98043             : 
   98044             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   98045             : 
   98046             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   98047             : 
   98048             : //############################################################################
   98049             : /* JH (02/02/2006) Constructor of the IR node SgContainsStatement that takes its 
   98050             :  * corresponding StorageClass as parameter
   98051             :  */
   98052           0 : SgContainsStatement :: SgContainsStatement ( const SgContainsStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   98053             :    {
   98054             : 
   98055             : 
   98056             : /* #line 98057 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   98057             : 
   98058           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   98059             : 
   98060             : 
   98061             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   98062             : 
   98063             : 
   98064           0 :    }
   98065             : 
   98066             : //############################################################################
   98067             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   98068             :  * within the working AST. 
   98069             :  */
   98070           0 : SgContainsStatement * SgContainsStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   98071           0 :      SgContainsStatement* returnPointer = NULL;
   98072           0 :      if ( globalIndex != 0 )
   98073             :         {
   98074             : 
   98075             : #if FILE_IO_EXTRA_CHECK
   98076           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgContainsStatement ) ) <= globalIndex ) ;
   98077           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgContainsStatement + 1 ) ) );
   98078             : #endif
   98079           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgContainsStatement )  
   98080           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgContainsStatement );
   98081           0 :           unsigned long positionInPool = localIndex % SgContainsStatement::pool_size;
   98082           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgContainsStatement::pool_size;
   98083             : 
   98084             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   98085             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   98086             : 
   98087           0 :           returnPointer = &( ( (SgContainsStatement*)(SgContainsStatement::pools[memoryBlock]) ) [positionInPool]) ;
   98088             : 
   98089           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   98090             :         }
   98091           0 :      return returnPointer ;
   98092             :    }
   98093             : 
   98094             : //############################################################################
   98095             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   98096             :   for the AST with the index astIndex
   98097             : */
   98098           0 : SgContainsStatement * SgContainsStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   98099           0 :      SgContainsStatement* returnPointer = NULL;
   98100           0 :      if ( globalIndex != 0 )
   98101             :         {
   98102             : 
   98103             : #if FILE_IO_EXTRA_CHECK
   98104           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgContainsStatement ) ) <= globalIndex ) ;
   98105           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgContainsStatement + 1 ) ) );
   98106             : #endif
   98107           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgContainsStatement )
   98108           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgContainsStatement );
   98109           0 :           unsigned long positionInPool = localIndex % SgContainsStatement::pool_size ;
   98110           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgContainsStatement::pool_size ;
   98111             : 
   98112             : #if FILE_IO_EXTRA_CHECK
   98113             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   98114             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   98115             : #endif
   98116             : 
   98117           0 :           returnPointer = &( ( (SgContainsStatement*)(SgContainsStatement::pools[memoryBlock]) ) [positionInPool]) ;
   98118             : 
   98119             : #if FILE_IO_EXTRA_CHECK
   98120           0 :           assert ( returnPointer != NULL ) ;
   98121             : #endif
   98122             :         }
   98123           0 :      return returnPointer ;
   98124             :    }
   98125             : 
   98126             : //############################################################################
   98127             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   98128             :  * pool size! We set for every valid object in the memory pool the freepointer
   98129             :  * to the global index and increase the global index afterwards. For all the 
   98130             :  * invalid objects (means address ranges within the memory pool that were not
   98131             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   98132             :  * distinguish valid from invalid objects! 
   98133             :  */
   98134             : unsigned long
   98135           5 : SgContainsStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   98136             :    {
   98137           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   98138           5 :      SgContainsStatement* pointer = NULL;
   98139           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   98140           5 :      std::vector < unsigned char* > :: const_iterator block;
   98141           5 :      for ( block = SgContainsStatement::pools.begin(); block != SgContainsStatement::pools.end() ; ++block )
   98142             :         {
   98143           0 :           pointer = (SgContainsStatement*)(*block);
   98144           0 :           for (unsigned i = 0; i < SgContainsStatement::pool_size; ++i )
   98145             :              {
   98146             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   98147             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   98148             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   98149             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   98150             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   98151             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   98152             :             // properly; so this will have to be checked next.
   98153             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   98154             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   98155           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   98156             :                   {
   98157           0 :                     pointer[i].set_freepointer((SgContainsStatement*)(globalIndex));
   98158           0 :                     globalIndex++;
   98159             :                   }
   98160             :                else
   98161             :                   {
   98162           0 :                     pointer[i].set_freepointer(NULL);
   98163             :                   }
   98164             :               }
   98165             :         }
   98166           5 :      return globalIndex;
   98167             :    }
   98168             : 
   98169             : //############################################################################
   98170             : // JH (01/14/2006)
   98171             : void
   98172           5 : SgContainsStatement::resetValidFreepointers( )
   98173             :    {
   98174           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   98175           5 :      SgContainsStatement* pointer = NULL;
   98176           5 :      std::vector < unsigned char* > :: const_iterator block;
   98177           5 :      SgContainsStatement* pointerOfLinkedList = NULL;
   98178           5 :      for ( block = SgContainsStatement::pools.begin(); block != SgContainsStatement::pools.end() ; ++block )
   98179             :         {
   98180           0 :           pointer = (SgContainsStatement*)(*block);
   98181           0 :           for (unsigned i = 0; i < SgContainsStatement::pool_size; ++i )
   98182             :              {
   98183             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   98184             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   98185             :             // memory blocks!.
   98186           0 :                if ( pointer[i].get_freepointer() != NULL )
   98187             :                   {
   98188           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   98189             :                   }
   98190             :                else
   98191             :                   {
   98192           0 :                     if ( pointerOfLinkedList == NULL )
   98193             :                        {
   98194           0 :                          SgContainsStatement::next_node = &(pointer[i]);
   98195             :                        }
   98196             :                     else
   98197             :                        {
   98198             :                       // printf ("In SgContainsStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   98199           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   98200             :                        }
   98201             :                     pointerOfLinkedList = &(pointer[i]);
   98202             :                   }
   98203             :               }
   98204             :         }
   98205             : 
   98206           5 :      if ( pointerOfLinkedList != NULL )
   98207             :         {
   98208             :        // printf ("In SgContainsStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   98209           0 :           pointerOfLinkedList->set_freepointer(NULL);
   98210             :        // DQ (6/6/2010): Temporary debugging...
   98211             :        //   ROSE_ASSERT(false);
   98212             :         }
   98213             : 
   98214           5 :      return ;
   98215             :    }
   98216             : 
   98217             : //############################################################################
   98218             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   98219             :  * within the memory pool and resets the freepointers, in order to achieve a 
   98220             :  * linked list, that has no jumps and starts at the beginning! This function 
   98221             :  * does not extend the memory pool, since we do not delete any memory blocks,
   98222             :  * but delete the valid objects.  
   98223             :  */
   98224             : void
   98225           0 : SgContainsStatement::clearMemoryPool( )
   98226             :    {
   98227             :   // printf ("Inside of SgContainsStatement::clearMemoryPool() \n");
   98228             : 
   98229           0 :      SgContainsStatement* pointer = NULL, *tempPointer = NULL;
   98230           0 :      std::vector < unsigned char* > :: const_iterator block;
   98231           0 :      if ( SgContainsStatement::pools.empty() == false )
   98232             :         {
   98233           0 :           block = SgContainsStatement::pools.begin() ;
   98234           0 :           SgContainsStatement::next_node = (SgContainsStatement*) (*block);
   98235             : 
   98236           0 :           while ( block != SgContainsStatement::pools.end() )
   98237             :              {
   98238           0 :                pointer = (SgContainsStatement*) (*block);
   98239           0 :                if ( tempPointer != NULL )
   98240             :                   {
   98241           0 :                     tempPointer->set_freepointer(pointer);
   98242             :                   }
   98243           0 :                for (unsigned i = 0; i < SgContainsStatement::pool_size - 1; ++i)
   98244             :                   {
   98245           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   98246             :                   }
   98247           0 :                 pointer[SgContainsStatement::pool_size-1].set_freepointer(NULL);
   98248           0 :                 tempPointer = &(pointer[SgContainsStatement::pool_size-1]);
   98249           0 :                 ++block;
   98250             :              }
   98251             :         }
   98252           0 :    }
   98253             : 
   98254           5 : void SgContainsStatement::deleteMemoryPool() {
   98255           5 :   for (auto p: SgContainsStatement::pools) {
   98256           0 :     ROSE_FREE(p);
   98257             :   }
   98258           5 :   SgContainsStatement::next_node = nullptr;
   98259           5 :   SgContainsStatement::pools.clear();
   98260           5 : }
   98261             : 
   98262             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   98263             : //                 reading multiple binary files to for a single AST.
   98264             : /////////// new version ////////////////////////////////
   98265             : //############################################################################
   98266             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   98267             : void
   98268           2 : SgContainsStatement::extendMemoryPoolForFileIO( )
   98269             :   {
   98270           2 :     size_t blockIndex = SgContainsStatement::pools.size();
   98271           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgContainsStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgContainsStatement);
   98272             : 
   98273           2 :     while ( (blockIndex * SgContainsStatement::pool_size) < newPoolSize)
   98274             :       {
   98275             : #if ROSE_ALLOC_TRACE
   98276             :         if (blockIndex > 0) {
   98277             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgContainsStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgContainsStatement) = %" PRIuPTR " SgContainsStatement::pool_size = %d \n",
   98278             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgContainsStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgContainsStatement),SgContainsStatement::pool_size);
   98279             :         }
   98280             : #endif
   98281             : 
   98282           0 :         SgContainsStatement * pointer = (SgContainsStatement*) ROSE_MALLOC ( SgContainsStatement::pool_size * sizeof(SgContainsStatement) );
   98283           0 :         assert( pointer != NULL );
   98284             : #if ROSE_ALLOC_MEMSET == 1
   98285             :         memset(pointer, 0x00, SgContainsStatement::pool_size * sizeof(SgContainsStatement));
   98286             : #elif ROSE_ALLOC_MEMSET == 2
   98287             :         memset(pointer, 0xCC, SgContainsStatement::pool_size * sizeof(SgContainsStatement));
   98288             : #endif
   98289           0 :         SgContainsStatement::pools.push_back( (unsigned char*)(pointer) );
   98290           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgContainsStatement::pool_size * sizeof(SgContainsStatement), V_SgContainsStatement ) );
   98291             : 
   98292           0 :         if ( SgContainsStatement::next_node != NULL ) {
   98293           0 :           if ( blockIndex > 0 ) {
   98294           0 :             SgContainsStatement * blkptr = (SgContainsStatement*)(SgContainsStatement::pools[blockIndex-1]);
   98295           0 :             blkptr[ SgContainsStatement::pool_size - 1 ].set_freepointer(pointer);
   98296             :           }
   98297             :         } else {
   98298           0 :           SgContainsStatement::next_node = pointer;
   98299             :         }
   98300             : 
   98301           0 :         for (unsigned i = 0; i < SgContainsStatement::pool_size-1; ++i)
   98302             :            {
   98303           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   98304             :            }
   98305           0 :         pointer[ SgContainsStatement::pool_size -1 ].set_freepointer(NULL);
   98306             : 
   98307           0 :         blockIndex++;
   98308             :       }
   98309           2 :   }
   98310             : 
   98311             : //############################################################################
   98312             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   98313             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   98314             :  * not compressed. However, that stuff is not yet implemented! 
   98315             :  */
   98316             : unsigned long
   98317           0 : SgContainsStatement::getNumberOfLastValidPointer()
   98318             :    {
   98319           0 :       SgContainsStatement* testPointer = (SgContainsStatement*)(SgContainsStatement::pools.back());
   98320           0 :       unsigned long localIndex = SgContainsStatement::pool_size - 1;
   98321           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   98322             :          {
   98323           0 :            localIndex--;
   98324             :          }
   98325           0 :       return (localIndex + SgContainsStatement::pool_size * (SgContainsStatement::pools.size()-1));
   98326             :    }
   98327             : 
   98328             : //############################################################################
   98329             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   98330             :  * memory pool and initializes the data member in class SgContainsStatementStroageClass
   98331             :  * from its counterpart of SgContainsStatement. The return value is just for checking, 
   98332             :  * that the whole StorageClassArray is initialized!
   98333             :  */
   98334             : unsigned long
   98335           0 : SgContainsStatement::initializeStorageClassArray( SgContainsStatementStorageClass *storageArray )
   98336             :    {
   98337           0 :      unsigned long storageCounter = 0;
   98338           0 :      std::vector < unsigned char* > :: const_iterator block = SgContainsStatement::pools.begin();
   98339           0 :      SgContainsStatement* pointer = NULL;
   98340           0 :      while ( block != SgContainsStatement::pools.end() ) {
   98341           0 :           pointer = (SgContainsStatement*) (*block);
   98342           0 :           for ( unsigned i = 0; i < SgContainsStatement::pool_size; ++i ) {
   98343           0 :                if ( pointer->get_freepointer() != NULL ) {
   98344           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   98345           0 :                  storageArray++;
   98346           0 :                  storageCounter++;
   98347             :                }
   98348           0 :                pointer++;
   98349             :              }
   98350           0 :            block++;
   98351             :         }
   98352           0 :      return storageCounter;
   98353             :    }
   98354             : 
   98355             : /* #line 98356 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   98356             : 
   98357             : 
   98358             : 
   98359             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   98360             : 
   98361             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   98362             : 
   98363             : //############################################################################
   98364             : /* JH (02/02/2006) Constructor of the IR node SgC_PreprocessorDirectiveStatement that takes its 
   98365             :  * corresponding StorageClass as parameter
   98366             :  */
   98367           0 : SgC_PreprocessorDirectiveStatement :: SgC_PreprocessorDirectiveStatement ( const SgC_PreprocessorDirectiveStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
   98368             :    {
   98369             : 
   98370             : 
   98371             : /* #line 98372 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   98372             : 
   98373           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   98374           0 :      p_directiveString = storageSource.storageOf_directiveString.rebuildDataStoredInEasyStorageClass() ;
   98375             : 
   98376             : 
   98377             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   98378             : 
   98379             : 
   98380           0 :    }
   98381             : 
   98382             : //############################################################################
   98383             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   98384             :  * within the working AST. 
   98385             :  */
   98386           0 : SgC_PreprocessorDirectiveStatement * SgC_PreprocessorDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   98387           0 :      SgC_PreprocessorDirectiveStatement* returnPointer = NULL;
   98388           0 :      if ( globalIndex != 0 )
   98389             :         {
   98390             : 
   98391             : #if FILE_IO_EXTRA_CHECK
   98392           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgC_PreprocessorDirectiveStatement ) ) <= globalIndex ) ;
   98393           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgC_PreprocessorDirectiveStatement + 1 ) ) );
   98394             : #endif
   98395           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgC_PreprocessorDirectiveStatement )  
   98396           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgC_PreprocessorDirectiveStatement );
   98397           0 :           unsigned long positionInPool = localIndex % SgC_PreprocessorDirectiveStatement::pool_size;
   98398           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgC_PreprocessorDirectiveStatement::pool_size;
   98399             : 
   98400             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   98401             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   98402             : 
   98403           0 :           returnPointer = &( ( (SgC_PreprocessorDirectiveStatement*)(SgC_PreprocessorDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   98404             : 
   98405           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   98406             :         }
   98407           0 :      return returnPointer ;
   98408             :    }
   98409             : 
   98410             : //############################################################################
   98411             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   98412             :   for the AST with the index astIndex
   98413             : */
   98414           0 : SgC_PreprocessorDirectiveStatement * SgC_PreprocessorDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   98415           0 :      SgC_PreprocessorDirectiveStatement* returnPointer = NULL;
   98416           0 :      if ( globalIndex != 0 )
   98417             :         {
   98418             : 
   98419             : #if FILE_IO_EXTRA_CHECK
   98420           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgC_PreprocessorDirectiveStatement ) ) <= globalIndex ) ;
   98421           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgC_PreprocessorDirectiveStatement + 1 ) ) );
   98422             : #endif
   98423           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgC_PreprocessorDirectiveStatement )
   98424           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgC_PreprocessorDirectiveStatement );
   98425           0 :           unsigned long positionInPool = localIndex % SgC_PreprocessorDirectiveStatement::pool_size ;
   98426           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgC_PreprocessorDirectiveStatement::pool_size ;
   98427             : 
   98428             : #if FILE_IO_EXTRA_CHECK
   98429             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   98430             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   98431             : #endif
   98432             : 
   98433           0 :           returnPointer = &( ( (SgC_PreprocessorDirectiveStatement*)(SgC_PreprocessorDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   98434             : 
   98435             : #if FILE_IO_EXTRA_CHECK
   98436           0 :           assert ( returnPointer != NULL ) ;
   98437             : #endif
   98438             :         }
   98439           0 :      return returnPointer ;
   98440             :    }
   98441             : 
   98442             : //############################################################################
   98443             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   98444             :  * pool size! We set for every valid object in the memory pool the freepointer
   98445             :  * to the global index and increase the global index afterwards. For all the 
   98446             :  * invalid objects (means address ranges within the memory pool that were not
   98447             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   98448             :  * distinguish valid from invalid objects! 
   98449             :  */
   98450             : unsigned long
   98451           5 : SgC_PreprocessorDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   98452             :    {
   98453           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   98454           5 :      SgC_PreprocessorDirectiveStatement* pointer = NULL;
   98455           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   98456           5 :      std::vector < unsigned char* > :: const_iterator block;
   98457           5 :      for ( block = SgC_PreprocessorDirectiveStatement::pools.begin(); block != SgC_PreprocessorDirectiveStatement::pools.end() ; ++block )
   98458             :         {
   98459           0 :           pointer = (SgC_PreprocessorDirectiveStatement*)(*block);
   98460           0 :           for (unsigned i = 0; i < SgC_PreprocessorDirectiveStatement::pool_size; ++i )
   98461             :              {
   98462             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   98463             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   98464             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   98465             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   98466             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   98467             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   98468             :             // properly; so this will have to be checked next.
   98469             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   98470             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   98471           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   98472             :                   {
   98473           0 :                     pointer[i].set_freepointer((SgC_PreprocessorDirectiveStatement*)(globalIndex));
   98474           0 :                     globalIndex++;
   98475             :                   }
   98476             :                else
   98477             :                   {
   98478           0 :                     pointer[i].set_freepointer(NULL);
   98479             :                   }
   98480             :               }
   98481             :         }
   98482           5 :      return globalIndex;
   98483             :    }
   98484             : 
   98485             : //############################################################################
   98486             : // JH (01/14/2006)
   98487             : void
   98488           5 : SgC_PreprocessorDirectiveStatement::resetValidFreepointers( )
   98489             :    {
   98490           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   98491           5 :      SgC_PreprocessorDirectiveStatement* pointer = NULL;
   98492           5 :      std::vector < unsigned char* > :: const_iterator block;
   98493           5 :      SgC_PreprocessorDirectiveStatement* pointerOfLinkedList = NULL;
   98494           5 :      for ( block = SgC_PreprocessorDirectiveStatement::pools.begin(); block != SgC_PreprocessorDirectiveStatement::pools.end() ; ++block )
   98495             :         {
   98496           0 :           pointer = (SgC_PreprocessorDirectiveStatement*)(*block);
   98497           0 :           for (unsigned i = 0; i < SgC_PreprocessorDirectiveStatement::pool_size; ++i )
   98498             :              {
   98499             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   98500             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   98501             :             // memory blocks!.
   98502           0 :                if ( pointer[i].get_freepointer() != NULL )
   98503             :                   {
   98504           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   98505             :                   }
   98506             :                else
   98507             :                   {
   98508           0 :                     if ( pointerOfLinkedList == NULL )
   98509             :                        {
   98510           0 :                          SgC_PreprocessorDirectiveStatement::next_node = &(pointer[i]);
   98511             :                        }
   98512             :                     else
   98513             :                        {
   98514             :                       // printf ("In SgC_PreprocessorDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   98515           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   98516             :                        }
   98517             :                     pointerOfLinkedList = &(pointer[i]);
   98518             :                   }
   98519             :               }
   98520             :         }
   98521             : 
   98522           5 :      if ( pointerOfLinkedList != NULL )
   98523             :         {
   98524             :        // printf ("In SgC_PreprocessorDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   98525           0 :           pointerOfLinkedList->set_freepointer(NULL);
   98526             :        // DQ (6/6/2010): Temporary debugging...
   98527             :        //   ROSE_ASSERT(false);
   98528             :         }
   98529             : 
   98530           5 :      return ;
   98531             :    }
   98532             : 
   98533             : //############################################################################
   98534             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   98535             :  * within the memory pool and resets the freepointers, in order to achieve a 
   98536             :  * linked list, that has no jumps and starts at the beginning! This function 
   98537             :  * does not extend the memory pool, since we do not delete any memory blocks,
   98538             :  * but delete the valid objects.  
   98539             :  */
   98540             : void
   98541           0 : SgC_PreprocessorDirectiveStatement::clearMemoryPool( )
   98542             :    {
   98543             :   // printf ("Inside of SgC_PreprocessorDirectiveStatement::clearMemoryPool() \n");
   98544             : 
   98545           0 :      SgC_PreprocessorDirectiveStatement* pointer = NULL, *tempPointer = NULL;
   98546           0 :      std::vector < unsigned char* > :: const_iterator block;
   98547           0 :      if ( SgC_PreprocessorDirectiveStatement::pools.empty() == false )
   98548             :         {
   98549           0 :           block = SgC_PreprocessorDirectiveStatement::pools.begin() ;
   98550           0 :           SgC_PreprocessorDirectiveStatement::next_node = (SgC_PreprocessorDirectiveStatement*) (*block);
   98551             : 
   98552           0 :           while ( block != SgC_PreprocessorDirectiveStatement::pools.end() )
   98553             :              {
   98554           0 :                pointer = (SgC_PreprocessorDirectiveStatement*) (*block);
   98555           0 :                if ( tempPointer != NULL )
   98556             :                   {
   98557           0 :                     tempPointer->set_freepointer(pointer);
   98558             :                   }
   98559           0 :                for (unsigned i = 0; i < SgC_PreprocessorDirectiveStatement::pool_size - 1; ++i)
   98560             :                   {
   98561           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   98562             :                   }
   98563           0 :                 pointer[SgC_PreprocessorDirectiveStatement::pool_size-1].set_freepointer(NULL);
   98564           0 :                 tempPointer = &(pointer[SgC_PreprocessorDirectiveStatement::pool_size-1]);
   98565           0 :                 ++block;
   98566             :              }
   98567             :         }
   98568           0 :    }
   98569             : 
   98570           5 : void SgC_PreprocessorDirectiveStatement::deleteMemoryPool() {
   98571           5 :   for (auto p: SgC_PreprocessorDirectiveStatement::pools) {
   98572           0 :     ROSE_FREE(p);
   98573             :   }
   98574           5 :   SgC_PreprocessorDirectiveStatement::next_node = nullptr;
   98575           5 :   SgC_PreprocessorDirectiveStatement::pools.clear();
   98576           5 : }
   98577             : 
   98578             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   98579             : //                 reading multiple binary files to for a single AST.
   98580             : /////////// new version ////////////////////////////////
   98581             : //############################################################################
   98582             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   98583             : void
   98584           2 : SgC_PreprocessorDirectiveStatement::extendMemoryPoolForFileIO( )
   98585             :   {
   98586           2 :     size_t blockIndex = SgC_PreprocessorDirectiveStatement::pools.size();
   98587           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgC_PreprocessorDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgC_PreprocessorDirectiveStatement);
   98588             : 
   98589           2 :     while ( (blockIndex * SgC_PreprocessorDirectiveStatement::pool_size) < newPoolSize)
   98590             :       {
   98591             : #if ROSE_ALLOC_TRACE
   98592             :         if (blockIndex > 0) {
   98593             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgC_PreprocessorDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgC_PreprocessorDirectiveStatement) = %" PRIuPTR " SgC_PreprocessorDirectiveStatement::pool_size = %d \n",
   98594             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgC_PreprocessorDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgC_PreprocessorDirectiveStatement),SgC_PreprocessorDirectiveStatement::pool_size);
   98595             :         }
   98596             : #endif
   98597             : 
   98598           0 :         SgC_PreprocessorDirectiveStatement * pointer = (SgC_PreprocessorDirectiveStatement*) ROSE_MALLOC ( SgC_PreprocessorDirectiveStatement::pool_size * sizeof(SgC_PreprocessorDirectiveStatement) );
   98599           0 :         assert( pointer != NULL );
   98600             : #if ROSE_ALLOC_MEMSET == 1
   98601             :         memset(pointer, 0x00, SgC_PreprocessorDirectiveStatement::pool_size * sizeof(SgC_PreprocessorDirectiveStatement));
   98602             : #elif ROSE_ALLOC_MEMSET == 2
   98603             :         memset(pointer, 0xCC, SgC_PreprocessorDirectiveStatement::pool_size * sizeof(SgC_PreprocessorDirectiveStatement));
   98604             : #endif
   98605           0 :         SgC_PreprocessorDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
   98606           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgC_PreprocessorDirectiveStatement::pool_size * sizeof(SgC_PreprocessorDirectiveStatement), V_SgC_PreprocessorDirectiveStatement ) );
   98607             : 
   98608           0 :         if ( SgC_PreprocessorDirectiveStatement::next_node != NULL ) {
   98609           0 :           if ( blockIndex > 0 ) {
   98610           0 :             SgC_PreprocessorDirectiveStatement * blkptr = (SgC_PreprocessorDirectiveStatement*)(SgC_PreprocessorDirectiveStatement::pools[blockIndex-1]);
   98611           0 :             blkptr[ SgC_PreprocessorDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
   98612             :           }
   98613             :         } else {
   98614           0 :           SgC_PreprocessorDirectiveStatement::next_node = pointer;
   98615             :         }
   98616             : 
   98617           0 :         for (unsigned i = 0; i < SgC_PreprocessorDirectiveStatement::pool_size-1; ++i)
   98618             :            {
   98619           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   98620             :            }
   98621           0 :         pointer[ SgC_PreprocessorDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
   98622             : 
   98623           0 :         blockIndex++;
   98624             :       }
   98625           2 :   }
   98626             : 
   98627             : //############################################################################
   98628             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   98629             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   98630             :  * not compressed. However, that stuff is not yet implemented! 
   98631             :  */
   98632             : unsigned long
   98633           0 : SgC_PreprocessorDirectiveStatement::getNumberOfLastValidPointer()
   98634             :    {
   98635           0 :       SgC_PreprocessorDirectiveStatement* testPointer = (SgC_PreprocessorDirectiveStatement*)(SgC_PreprocessorDirectiveStatement::pools.back());
   98636           0 :       unsigned long localIndex = SgC_PreprocessorDirectiveStatement::pool_size - 1;
   98637           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   98638             :          {
   98639           0 :            localIndex--;
   98640             :          }
   98641           0 :       return (localIndex + SgC_PreprocessorDirectiveStatement::pool_size * (SgC_PreprocessorDirectiveStatement::pools.size()-1));
   98642             :    }
   98643             : 
   98644             : //############################################################################
   98645             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   98646             :  * memory pool and initializes the data member in class SgC_PreprocessorDirectiveStatementStroageClass
   98647             :  * from its counterpart of SgC_PreprocessorDirectiveStatement. The return value is just for checking, 
   98648             :  * that the whole StorageClassArray is initialized!
   98649             :  */
   98650             : unsigned long
   98651           0 : SgC_PreprocessorDirectiveStatement::initializeStorageClassArray( SgC_PreprocessorDirectiveStatementStorageClass *storageArray )
   98652             :    {
   98653           0 :      unsigned long storageCounter = 0;
   98654           0 :      std::vector < unsigned char* > :: const_iterator block = SgC_PreprocessorDirectiveStatement::pools.begin();
   98655           0 :      SgC_PreprocessorDirectiveStatement* pointer = NULL;
   98656           0 :      while ( block != SgC_PreprocessorDirectiveStatement::pools.end() ) {
   98657           0 :           pointer = (SgC_PreprocessorDirectiveStatement*) (*block);
   98658           0 :           for ( unsigned i = 0; i < SgC_PreprocessorDirectiveStatement::pool_size; ++i ) {
   98659           0 :                if ( pointer->get_freepointer() != NULL ) {
   98660           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   98661           0 :                  storageArray++;
   98662           0 :                  storageCounter++;
   98663             :                }
   98664           0 :                pointer++;
   98665             :              }
   98666           0 :            block++;
   98667             :         }
   98668           0 :      return storageCounter;
   98669             :    }
   98670             : 
   98671             : /* #line 98672 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   98672             : 
   98673             : 
   98674             : 
   98675             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   98676             : 
   98677             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   98678             : 
   98679             : //############################################################################
   98680             : /* JH (02/02/2006) Constructor of the IR node SgIncludeDirectiveStatement that takes its 
   98681             :  * corresponding StorageClass as parameter
   98682             :  */
   98683           0 : SgIncludeDirectiveStatement :: SgIncludeDirectiveStatement ( const SgIncludeDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
   98684             :    {
   98685             : 
   98686             : 
   98687             : /* #line 98688 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   98688             : 
   98689           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   98690           0 :      p_headerFileBody =  (SgHeaderFileBody*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_headerFileBody) );
   98691           0 :      p_include_file_heirarchy =  (SgIncludeFile*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_include_file_heirarchy) );
   98692           0 :      p_name_used_in_include_directive = storageSource.storageOf_name_used_in_include_directive.rebuildDataStoredInEasyStorageClass() ;
   98693             : 
   98694             : 
   98695             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   98696             : 
   98697             : 
   98698           0 :    }
   98699             : 
   98700             : //############################################################################
   98701             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   98702             :  * within the working AST. 
   98703             :  */
   98704           0 : SgIncludeDirectiveStatement * SgIncludeDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   98705           0 :      SgIncludeDirectiveStatement* returnPointer = NULL;
   98706           0 :      if ( globalIndex != 0 )
   98707             :         {
   98708             : 
   98709             : #if FILE_IO_EXTRA_CHECK
   98710           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIncludeDirectiveStatement ) ) <= globalIndex ) ;
   98711           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncludeDirectiveStatement + 1 ) ) );
   98712             : #endif
   98713           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncludeDirectiveStatement )  
   98714           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIncludeDirectiveStatement );
   98715           0 :           unsigned long positionInPool = localIndex % SgIncludeDirectiveStatement::pool_size;
   98716           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncludeDirectiveStatement::pool_size;
   98717             : 
   98718             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   98719             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   98720             : 
   98721           0 :           returnPointer = &( ( (SgIncludeDirectiveStatement*)(SgIncludeDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   98722             : 
   98723           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   98724             :         }
   98725           0 :      return returnPointer ;
   98726             :    }
   98727             : 
   98728             : //############################################################################
   98729             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   98730             :   for the AST with the index astIndex
   98731             : */
   98732           0 : SgIncludeDirectiveStatement * SgIncludeDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   98733           0 :      SgIncludeDirectiveStatement* returnPointer = NULL;
   98734           0 :      if ( globalIndex != 0 )
   98735             :         {
   98736             : 
   98737             : #if FILE_IO_EXTRA_CHECK
   98738           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIncludeDirectiveStatement ) ) <= globalIndex ) ;
   98739           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncludeDirectiveStatement + 1 ) ) );
   98740             : #endif
   98741           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncludeDirectiveStatement )
   98742           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIncludeDirectiveStatement );
   98743           0 :           unsigned long positionInPool = localIndex % SgIncludeDirectiveStatement::pool_size ;
   98744           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncludeDirectiveStatement::pool_size ;
   98745             : 
   98746             : #if FILE_IO_EXTRA_CHECK
   98747             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   98748             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   98749             : #endif
   98750             : 
   98751           0 :           returnPointer = &( ( (SgIncludeDirectiveStatement*)(SgIncludeDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   98752             : 
   98753             : #if FILE_IO_EXTRA_CHECK
   98754           0 :           assert ( returnPointer != NULL ) ;
   98755             : #endif
   98756             :         }
   98757           0 :      return returnPointer ;
   98758             :    }
   98759             : 
   98760             : //############################################################################
   98761             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   98762             :  * pool size! We set for every valid object in the memory pool the freepointer
   98763             :  * to the global index and increase the global index afterwards. For all the 
   98764             :  * invalid objects (means address ranges within the memory pool that were not
   98765             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   98766             :  * distinguish valid from invalid objects! 
   98767             :  */
   98768             : unsigned long
   98769           5 : SgIncludeDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   98770             :    {
   98771           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   98772           5 :      SgIncludeDirectiveStatement* pointer = NULL;
   98773           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   98774           5 :      std::vector < unsigned char* > :: const_iterator block;
   98775           5 :      for ( block = SgIncludeDirectiveStatement::pools.begin(); block != SgIncludeDirectiveStatement::pools.end() ; ++block )
   98776             :         {
   98777           0 :           pointer = (SgIncludeDirectiveStatement*)(*block);
   98778           0 :           for (unsigned i = 0; i < SgIncludeDirectiveStatement::pool_size; ++i )
   98779             :              {
   98780             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   98781             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   98782             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   98783             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   98784             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   98785             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   98786             :             // properly; so this will have to be checked next.
   98787             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   98788             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   98789           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   98790             :                   {
   98791           0 :                     pointer[i].set_freepointer((SgIncludeDirectiveStatement*)(globalIndex));
   98792           0 :                     globalIndex++;
   98793             :                   }
   98794             :                else
   98795             :                   {
   98796           0 :                     pointer[i].set_freepointer(NULL);
   98797             :                   }
   98798             :               }
   98799             :         }
   98800           5 :      return globalIndex;
   98801             :    }
   98802             : 
   98803             : //############################################################################
   98804             : // JH (01/14/2006)
   98805             : void
   98806           5 : SgIncludeDirectiveStatement::resetValidFreepointers( )
   98807             :    {
   98808           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   98809           5 :      SgIncludeDirectiveStatement* pointer = NULL;
   98810           5 :      std::vector < unsigned char* > :: const_iterator block;
   98811           5 :      SgIncludeDirectiveStatement* pointerOfLinkedList = NULL;
   98812           5 :      for ( block = SgIncludeDirectiveStatement::pools.begin(); block != SgIncludeDirectiveStatement::pools.end() ; ++block )
   98813             :         {
   98814           0 :           pointer = (SgIncludeDirectiveStatement*)(*block);
   98815           0 :           for (unsigned i = 0; i < SgIncludeDirectiveStatement::pool_size; ++i )
   98816             :              {
   98817             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   98818             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   98819             :             // memory blocks!.
   98820           0 :                if ( pointer[i].get_freepointer() != NULL )
   98821             :                   {
   98822           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   98823             :                   }
   98824             :                else
   98825             :                   {
   98826           0 :                     if ( pointerOfLinkedList == NULL )
   98827             :                        {
   98828           0 :                          SgIncludeDirectiveStatement::next_node = &(pointer[i]);
   98829             :                        }
   98830             :                     else
   98831             :                        {
   98832             :                       // printf ("In SgIncludeDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   98833           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   98834             :                        }
   98835             :                     pointerOfLinkedList = &(pointer[i]);
   98836             :                   }
   98837             :               }
   98838             :         }
   98839             : 
   98840           5 :      if ( pointerOfLinkedList != NULL )
   98841             :         {
   98842             :        // printf ("In SgIncludeDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   98843           0 :           pointerOfLinkedList->set_freepointer(NULL);
   98844             :        // DQ (6/6/2010): Temporary debugging...
   98845             :        //   ROSE_ASSERT(false);
   98846             :         }
   98847             : 
   98848           5 :      return ;
   98849             :    }
   98850             : 
   98851             : //############################################################################
   98852             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   98853             :  * within the memory pool and resets the freepointers, in order to achieve a 
   98854             :  * linked list, that has no jumps and starts at the beginning! This function 
   98855             :  * does not extend the memory pool, since we do not delete any memory blocks,
   98856             :  * but delete the valid objects.  
   98857             :  */
   98858             : void
   98859           0 : SgIncludeDirectiveStatement::clearMemoryPool( )
   98860             :    {
   98861             :   // printf ("Inside of SgIncludeDirectiveStatement::clearMemoryPool() \n");
   98862             : 
   98863           0 :      SgIncludeDirectiveStatement* pointer = NULL, *tempPointer = NULL;
   98864           0 :      std::vector < unsigned char* > :: const_iterator block;
   98865           0 :      if ( SgIncludeDirectiveStatement::pools.empty() == false )
   98866             :         {
   98867           0 :           block = SgIncludeDirectiveStatement::pools.begin() ;
   98868           0 :           SgIncludeDirectiveStatement::next_node = (SgIncludeDirectiveStatement*) (*block);
   98869             : 
   98870           0 :           while ( block != SgIncludeDirectiveStatement::pools.end() )
   98871             :              {
   98872           0 :                pointer = (SgIncludeDirectiveStatement*) (*block);
   98873           0 :                if ( tempPointer != NULL )
   98874             :                   {
   98875           0 :                     tempPointer->set_freepointer(pointer);
   98876             :                   }
   98877           0 :                for (unsigned i = 0; i < SgIncludeDirectiveStatement::pool_size - 1; ++i)
   98878             :                   {
   98879           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   98880             :                   }
   98881           0 :                 pointer[SgIncludeDirectiveStatement::pool_size-1].set_freepointer(NULL);
   98882           0 :                 tempPointer = &(pointer[SgIncludeDirectiveStatement::pool_size-1]);
   98883           0 :                 ++block;
   98884             :              }
   98885             :         }
   98886           0 :    }
   98887             : 
   98888           5 : void SgIncludeDirectiveStatement::deleteMemoryPool() {
   98889           5 :   for (auto p: SgIncludeDirectiveStatement::pools) {
   98890           0 :     ROSE_FREE(p);
   98891             :   }
   98892           5 :   SgIncludeDirectiveStatement::next_node = nullptr;
   98893           5 :   SgIncludeDirectiveStatement::pools.clear();
   98894           5 : }
   98895             : 
   98896             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   98897             : //                 reading multiple binary files to for a single AST.
   98898             : /////////// new version ////////////////////////////////
   98899             : //############################################################################
   98900             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   98901             : void
   98902           2 : SgIncludeDirectiveStatement::extendMemoryPoolForFileIO( )
   98903             :   {
   98904           2 :     size_t blockIndex = SgIncludeDirectiveStatement::pools.size();
   98905           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeDirectiveStatement);
   98906             : 
   98907           2 :     while ( (blockIndex * SgIncludeDirectiveStatement::pool_size) < newPoolSize)
   98908             :       {
   98909             : #if ROSE_ALLOC_TRACE
   98910             :         if (blockIndex > 0) {
   98911             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeDirectiveStatement) = %" PRIuPTR " SgIncludeDirectiveStatement::pool_size = %d \n",
   98912             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeDirectiveStatement),SgIncludeDirectiveStatement::pool_size);
   98913             :         }
   98914             : #endif
   98915             : 
   98916           0 :         SgIncludeDirectiveStatement * pointer = (SgIncludeDirectiveStatement*) ROSE_MALLOC ( SgIncludeDirectiveStatement::pool_size * sizeof(SgIncludeDirectiveStatement) );
   98917           0 :         assert( pointer != NULL );
   98918             : #if ROSE_ALLOC_MEMSET == 1
   98919             :         memset(pointer, 0x00, SgIncludeDirectiveStatement::pool_size * sizeof(SgIncludeDirectiveStatement));
   98920             : #elif ROSE_ALLOC_MEMSET == 2
   98921             :         memset(pointer, 0xCC, SgIncludeDirectiveStatement::pool_size * sizeof(SgIncludeDirectiveStatement));
   98922             : #endif
   98923           0 :         SgIncludeDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
   98924           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIncludeDirectiveStatement::pool_size * sizeof(SgIncludeDirectiveStatement), V_SgIncludeDirectiveStatement ) );
   98925             : 
   98926           0 :         if ( SgIncludeDirectiveStatement::next_node != NULL ) {
   98927           0 :           if ( blockIndex > 0 ) {
   98928           0 :             SgIncludeDirectiveStatement * blkptr = (SgIncludeDirectiveStatement*)(SgIncludeDirectiveStatement::pools[blockIndex-1]);
   98929           0 :             blkptr[ SgIncludeDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
   98930             :           }
   98931             :         } else {
   98932           0 :           SgIncludeDirectiveStatement::next_node = pointer;
   98933             :         }
   98934             : 
   98935           0 :         for (unsigned i = 0; i < SgIncludeDirectiveStatement::pool_size-1; ++i)
   98936             :            {
   98937           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   98938             :            }
   98939           0 :         pointer[ SgIncludeDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
   98940             : 
   98941           0 :         blockIndex++;
   98942             :       }
   98943           2 :   }
   98944             : 
   98945             : //############################################################################
   98946             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   98947             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   98948             :  * not compressed. However, that stuff is not yet implemented! 
   98949             :  */
   98950             : unsigned long
   98951           0 : SgIncludeDirectiveStatement::getNumberOfLastValidPointer()
   98952             :    {
   98953           0 :       SgIncludeDirectiveStatement* testPointer = (SgIncludeDirectiveStatement*)(SgIncludeDirectiveStatement::pools.back());
   98954           0 :       unsigned long localIndex = SgIncludeDirectiveStatement::pool_size - 1;
   98955           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   98956             :          {
   98957           0 :            localIndex--;
   98958             :          }
   98959           0 :       return (localIndex + SgIncludeDirectiveStatement::pool_size * (SgIncludeDirectiveStatement::pools.size()-1));
   98960             :    }
   98961             : 
   98962             : //############################################################################
   98963             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   98964             :  * memory pool and initializes the data member in class SgIncludeDirectiveStatementStroageClass
   98965             :  * from its counterpart of SgIncludeDirectiveStatement. The return value is just for checking, 
   98966             :  * that the whole StorageClassArray is initialized!
   98967             :  */
   98968             : unsigned long
   98969           0 : SgIncludeDirectiveStatement::initializeStorageClassArray( SgIncludeDirectiveStatementStorageClass *storageArray )
   98970             :    {
   98971           0 :      unsigned long storageCounter = 0;
   98972           0 :      std::vector < unsigned char* > :: const_iterator block = SgIncludeDirectiveStatement::pools.begin();
   98973           0 :      SgIncludeDirectiveStatement* pointer = NULL;
   98974           0 :      while ( block != SgIncludeDirectiveStatement::pools.end() ) {
   98975           0 :           pointer = (SgIncludeDirectiveStatement*) (*block);
   98976           0 :           for ( unsigned i = 0; i < SgIncludeDirectiveStatement::pool_size; ++i ) {
   98977           0 :                if ( pointer->get_freepointer() != NULL ) {
   98978           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   98979           0 :                  storageArray++;
   98980           0 :                  storageCounter++;
   98981             :                }
   98982           0 :                pointer++;
   98983             :              }
   98984           0 :            block++;
   98985             :         }
   98986           0 :      return storageCounter;
   98987             :    }
   98988             : 
   98989             : /* #line 98990 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   98990             : 
   98991             : 
   98992             : 
   98993             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   98994             : 
   98995             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   98996             : 
   98997             : //############################################################################
   98998             : /* JH (02/02/2006) Constructor of the IR node SgDefineDirectiveStatement that takes its 
   98999             :  * corresponding StorageClass as parameter
   99000             :  */
   99001           0 : SgDefineDirectiveStatement :: SgDefineDirectiveStatement ( const SgDefineDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
   99002             :    {
   99003             : 
   99004             : 
   99005             : /* #line 99006 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   99006             : 
   99007           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   99008             : 
   99009             : 
   99010             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   99011             : 
   99012             : 
   99013           0 :    }
   99014             : 
   99015             : //############################################################################
   99016             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   99017             :  * within the working AST. 
   99018             :  */
   99019           0 : SgDefineDirectiveStatement * SgDefineDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   99020           0 :      SgDefineDirectiveStatement* returnPointer = NULL;
   99021           0 :      if ( globalIndex != 0 )
   99022             :         {
   99023             : 
   99024             : #if FILE_IO_EXTRA_CHECK
   99025           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDefineDirectiveStatement ) ) <= globalIndex ) ;
   99026           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDefineDirectiveStatement + 1 ) ) );
   99027             : #endif
   99028           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDefineDirectiveStatement )  
   99029           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDefineDirectiveStatement );
   99030           0 :           unsigned long positionInPool = localIndex % SgDefineDirectiveStatement::pool_size;
   99031           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDefineDirectiveStatement::pool_size;
   99032             : 
   99033             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   99034             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   99035             : 
   99036           0 :           returnPointer = &( ( (SgDefineDirectiveStatement*)(SgDefineDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   99037             : 
   99038           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   99039             :         }
   99040           0 :      return returnPointer ;
   99041             :    }
   99042             : 
   99043             : //############################################################################
   99044             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   99045             :   for the AST with the index astIndex
   99046             : */
   99047           0 : SgDefineDirectiveStatement * SgDefineDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   99048           0 :      SgDefineDirectiveStatement* returnPointer = NULL;
   99049           0 :      if ( globalIndex != 0 )
   99050             :         {
   99051             : 
   99052             : #if FILE_IO_EXTRA_CHECK
   99053           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDefineDirectiveStatement ) ) <= globalIndex ) ;
   99054           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDefineDirectiveStatement + 1 ) ) );
   99055             : #endif
   99056           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDefineDirectiveStatement )
   99057           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDefineDirectiveStatement );
   99058           0 :           unsigned long positionInPool = localIndex % SgDefineDirectiveStatement::pool_size ;
   99059           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDefineDirectiveStatement::pool_size ;
   99060             : 
   99061             : #if FILE_IO_EXTRA_CHECK
   99062             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   99063             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   99064             : #endif
   99065             : 
   99066           0 :           returnPointer = &( ( (SgDefineDirectiveStatement*)(SgDefineDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   99067             : 
   99068             : #if FILE_IO_EXTRA_CHECK
   99069           0 :           assert ( returnPointer != NULL ) ;
   99070             : #endif
   99071             :         }
   99072           0 :      return returnPointer ;
   99073             :    }
   99074             : 
   99075             : //############################################################################
   99076             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   99077             :  * pool size! We set for every valid object in the memory pool the freepointer
   99078             :  * to the global index and increase the global index afterwards. For all the 
   99079             :  * invalid objects (means address ranges within the memory pool that were not
   99080             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   99081             :  * distinguish valid from invalid objects! 
   99082             :  */
   99083             : unsigned long
   99084           5 : SgDefineDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   99085             :    {
   99086           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   99087           5 :      SgDefineDirectiveStatement* pointer = NULL;
   99088           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   99089           5 :      std::vector < unsigned char* > :: const_iterator block;
   99090           5 :      for ( block = SgDefineDirectiveStatement::pools.begin(); block != SgDefineDirectiveStatement::pools.end() ; ++block )
   99091             :         {
   99092           0 :           pointer = (SgDefineDirectiveStatement*)(*block);
   99093           0 :           for (unsigned i = 0; i < SgDefineDirectiveStatement::pool_size; ++i )
   99094             :              {
   99095             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   99096             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   99097             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   99098             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   99099             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   99100             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   99101             :             // properly; so this will have to be checked next.
   99102             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   99103             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   99104           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   99105             :                   {
   99106           0 :                     pointer[i].set_freepointer((SgDefineDirectiveStatement*)(globalIndex));
   99107           0 :                     globalIndex++;
   99108             :                   }
   99109             :                else
   99110             :                   {
   99111           0 :                     pointer[i].set_freepointer(NULL);
   99112             :                   }
   99113             :               }
   99114             :         }
   99115           5 :      return globalIndex;
   99116             :    }
   99117             : 
   99118             : //############################################################################
   99119             : // JH (01/14/2006)
   99120             : void
   99121           5 : SgDefineDirectiveStatement::resetValidFreepointers( )
   99122             :    {
   99123           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   99124           5 :      SgDefineDirectiveStatement* pointer = NULL;
   99125           5 :      std::vector < unsigned char* > :: const_iterator block;
   99126           5 :      SgDefineDirectiveStatement* pointerOfLinkedList = NULL;
   99127           5 :      for ( block = SgDefineDirectiveStatement::pools.begin(); block != SgDefineDirectiveStatement::pools.end() ; ++block )
   99128             :         {
   99129           0 :           pointer = (SgDefineDirectiveStatement*)(*block);
   99130           0 :           for (unsigned i = 0; i < SgDefineDirectiveStatement::pool_size; ++i )
   99131             :              {
   99132             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   99133             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   99134             :             // memory blocks!.
   99135           0 :                if ( pointer[i].get_freepointer() != NULL )
   99136             :                   {
   99137           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   99138             :                   }
   99139             :                else
   99140             :                   {
   99141           0 :                     if ( pointerOfLinkedList == NULL )
   99142             :                        {
   99143           0 :                          SgDefineDirectiveStatement::next_node = &(pointer[i]);
   99144             :                        }
   99145             :                     else
   99146             :                        {
   99147             :                       // printf ("In SgDefineDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   99148           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   99149             :                        }
   99150             :                     pointerOfLinkedList = &(pointer[i]);
   99151             :                   }
   99152             :               }
   99153             :         }
   99154             : 
   99155           5 :      if ( pointerOfLinkedList != NULL )
   99156             :         {
   99157             :        // printf ("In SgDefineDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   99158           0 :           pointerOfLinkedList->set_freepointer(NULL);
   99159             :        // DQ (6/6/2010): Temporary debugging...
   99160             :        //   ROSE_ASSERT(false);
   99161             :         }
   99162             : 
   99163           5 :      return ;
   99164             :    }
   99165             : 
   99166             : //############################################################################
   99167             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   99168             :  * within the memory pool and resets the freepointers, in order to achieve a 
   99169             :  * linked list, that has no jumps and starts at the beginning! This function 
   99170             :  * does not extend the memory pool, since we do not delete any memory blocks,
   99171             :  * but delete the valid objects.  
   99172             :  */
   99173             : void
   99174           0 : SgDefineDirectiveStatement::clearMemoryPool( )
   99175             :    {
   99176             :   // printf ("Inside of SgDefineDirectiveStatement::clearMemoryPool() \n");
   99177             : 
   99178           0 :      SgDefineDirectiveStatement* pointer = NULL, *tempPointer = NULL;
   99179           0 :      std::vector < unsigned char* > :: const_iterator block;
   99180           0 :      if ( SgDefineDirectiveStatement::pools.empty() == false )
   99181             :         {
   99182           0 :           block = SgDefineDirectiveStatement::pools.begin() ;
   99183           0 :           SgDefineDirectiveStatement::next_node = (SgDefineDirectiveStatement*) (*block);
   99184             : 
   99185           0 :           while ( block != SgDefineDirectiveStatement::pools.end() )
   99186             :              {
   99187           0 :                pointer = (SgDefineDirectiveStatement*) (*block);
   99188           0 :                if ( tempPointer != NULL )
   99189             :                   {
   99190           0 :                     tempPointer->set_freepointer(pointer);
   99191             :                   }
   99192           0 :                for (unsigned i = 0; i < SgDefineDirectiveStatement::pool_size - 1; ++i)
   99193             :                   {
   99194           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   99195             :                   }
   99196           0 :                 pointer[SgDefineDirectiveStatement::pool_size-1].set_freepointer(NULL);
   99197           0 :                 tempPointer = &(pointer[SgDefineDirectiveStatement::pool_size-1]);
   99198           0 :                 ++block;
   99199             :              }
   99200             :         }
   99201           0 :    }
   99202             : 
   99203           5 : void SgDefineDirectiveStatement::deleteMemoryPool() {
   99204           5 :   for (auto p: SgDefineDirectiveStatement::pools) {
   99205           0 :     ROSE_FREE(p);
   99206             :   }
   99207           5 :   SgDefineDirectiveStatement::next_node = nullptr;
   99208           5 :   SgDefineDirectiveStatement::pools.clear();
   99209           5 : }
   99210             : 
   99211             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   99212             : //                 reading multiple binary files to for a single AST.
   99213             : /////////// new version ////////////////////////////////
   99214             : //############################################################################
   99215             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   99216             : void
   99217           2 : SgDefineDirectiveStatement::extendMemoryPoolForFileIO( )
   99218             :   {
   99219           2 :     size_t blockIndex = SgDefineDirectiveStatement::pools.size();
   99220           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDefineDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefineDirectiveStatement);
   99221             : 
   99222           2 :     while ( (blockIndex * SgDefineDirectiveStatement::pool_size) < newPoolSize)
   99223             :       {
   99224             : #if ROSE_ALLOC_TRACE
   99225             :         if (blockIndex > 0) {
   99226             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDefineDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefineDirectiveStatement) = %" PRIuPTR " SgDefineDirectiveStatement::pool_size = %d \n",
   99227             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDefineDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefineDirectiveStatement),SgDefineDirectiveStatement::pool_size);
   99228             :         }
   99229             : #endif
   99230             : 
   99231           0 :         SgDefineDirectiveStatement * pointer = (SgDefineDirectiveStatement*) ROSE_MALLOC ( SgDefineDirectiveStatement::pool_size * sizeof(SgDefineDirectiveStatement) );
   99232           0 :         assert( pointer != NULL );
   99233             : #if ROSE_ALLOC_MEMSET == 1
   99234             :         memset(pointer, 0x00, SgDefineDirectiveStatement::pool_size * sizeof(SgDefineDirectiveStatement));
   99235             : #elif ROSE_ALLOC_MEMSET == 2
   99236             :         memset(pointer, 0xCC, SgDefineDirectiveStatement::pool_size * sizeof(SgDefineDirectiveStatement));
   99237             : #endif
   99238           0 :         SgDefineDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
   99239           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDefineDirectiveStatement::pool_size * sizeof(SgDefineDirectiveStatement), V_SgDefineDirectiveStatement ) );
   99240             : 
   99241           0 :         if ( SgDefineDirectiveStatement::next_node != NULL ) {
   99242           0 :           if ( blockIndex > 0 ) {
   99243           0 :             SgDefineDirectiveStatement * blkptr = (SgDefineDirectiveStatement*)(SgDefineDirectiveStatement::pools[blockIndex-1]);
   99244           0 :             blkptr[ SgDefineDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
   99245             :           }
   99246             :         } else {
   99247           0 :           SgDefineDirectiveStatement::next_node = pointer;
   99248             :         }
   99249             : 
   99250           0 :         for (unsigned i = 0; i < SgDefineDirectiveStatement::pool_size-1; ++i)
   99251             :            {
   99252           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   99253             :            }
   99254           0 :         pointer[ SgDefineDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
   99255             : 
   99256           0 :         blockIndex++;
   99257             :       }
   99258           2 :   }
   99259             : 
   99260             : //############################################################################
   99261             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   99262             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   99263             :  * not compressed. However, that stuff is not yet implemented! 
   99264             :  */
   99265             : unsigned long
   99266           0 : SgDefineDirectiveStatement::getNumberOfLastValidPointer()
   99267             :    {
   99268           0 :       SgDefineDirectiveStatement* testPointer = (SgDefineDirectiveStatement*)(SgDefineDirectiveStatement::pools.back());
   99269           0 :       unsigned long localIndex = SgDefineDirectiveStatement::pool_size - 1;
   99270           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   99271             :          {
   99272           0 :            localIndex--;
   99273             :          }
   99274           0 :       return (localIndex + SgDefineDirectiveStatement::pool_size * (SgDefineDirectiveStatement::pools.size()-1));
   99275             :    }
   99276             : 
   99277             : //############################################################################
   99278             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   99279             :  * memory pool and initializes the data member in class SgDefineDirectiveStatementStroageClass
   99280             :  * from its counterpart of SgDefineDirectiveStatement. The return value is just for checking, 
   99281             :  * that the whole StorageClassArray is initialized!
   99282             :  */
   99283             : unsigned long
   99284           0 : SgDefineDirectiveStatement::initializeStorageClassArray( SgDefineDirectiveStatementStorageClass *storageArray )
   99285             :    {
   99286           0 :      unsigned long storageCounter = 0;
   99287           0 :      std::vector < unsigned char* > :: const_iterator block = SgDefineDirectiveStatement::pools.begin();
   99288           0 :      SgDefineDirectiveStatement* pointer = NULL;
   99289           0 :      while ( block != SgDefineDirectiveStatement::pools.end() ) {
   99290           0 :           pointer = (SgDefineDirectiveStatement*) (*block);
   99291           0 :           for ( unsigned i = 0; i < SgDefineDirectiveStatement::pool_size; ++i ) {
   99292           0 :                if ( pointer->get_freepointer() != NULL ) {
   99293           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   99294           0 :                  storageArray++;
   99295           0 :                  storageCounter++;
   99296             :                }
   99297           0 :                pointer++;
   99298             :              }
   99299           0 :            block++;
   99300             :         }
   99301           0 :      return storageCounter;
   99302             :    }
   99303             : 
   99304             : /* #line 99305 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   99305             : 
   99306             : 
   99307             : 
   99308             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   99309             : 
   99310             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   99311             : 
   99312             : //############################################################################
   99313             : /* JH (02/02/2006) Constructor of the IR node SgUndefDirectiveStatement that takes its 
   99314             :  * corresponding StorageClass as parameter
   99315             :  */
   99316           0 : SgUndefDirectiveStatement :: SgUndefDirectiveStatement ( const SgUndefDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
   99317             :    {
   99318             : 
   99319             : 
   99320             : /* #line 99321 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   99321             : 
   99322           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   99323             : 
   99324             : 
   99325             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   99326             : 
   99327             : 
   99328           0 :    }
   99329             : 
   99330             : //############################################################################
   99331             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   99332             :  * within the working AST. 
   99333             :  */
   99334           0 : SgUndefDirectiveStatement * SgUndefDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   99335           0 :      SgUndefDirectiveStatement* returnPointer = NULL;
   99336           0 :      if ( globalIndex != 0 )
   99337             :         {
   99338             : 
   99339             : #if FILE_IO_EXTRA_CHECK
   99340           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUndefDirectiveStatement ) ) <= globalIndex ) ;
   99341           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUndefDirectiveStatement + 1 ) ) );
   99342             : #endif
   99343           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUndefDirectiveStatement )  
   99344           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUndefDirectiveStatement );
   99345           0 :           unsigned long positionInPool = localIndex % SgUndefDirectiveStatement::pool_size;
   99346           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUndefDirectiveStatement::pool_size;
   99347             : 
   99348             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   99349             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   99350             : 
   99351           0 :           returnPointer = &( ( (SgUndefDirectiveStatement*)(SgUndefDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   99352             : 
   99353           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   99354             :         }
   99355           0 :      return returnPointer ;
   99356             :    }
   99357             : 
   99358             : //############################################################################
   99359             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   99360             :   for the AST with the index astIndex
   99361             : */
   99362           0 : SgUndefDirectiveStatement * SgUndefDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   99363           0 :      SgUndefDirectiveStatement* returnPointer = NULL;
   99364           0 :      if ( globalIndex != 0 )
   99365             :         {
   99366             : 
   99367             : #if FILE_IO_EXTRA_CHECK
   99368           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUndefDirectiveStatement ) ) <= globalIndex ) ;
   99369           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUndefDirectiveStatement + 1 ) ) );
   99370             : #endif
   99371           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUndefDirectiveStatement )
   99372           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUndefDirectiveStatement );
   99373           0 :           unsigned long positionInPool = localIndex % SgUndefDirectiveStatement::pool_size ;
   99374           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUndefDirectiveStatement::pool_size ;
   99375             : 
   99376             : #if FILE_IO_EXTRA_CHECK
   99377             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   99378             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   99379             : #endif
   99380             : 
   99381           0 :           returnPointer = &( ( (SgUndefDirectiveStatement*)(SgUndefDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   99382             : 
   99383             : #if FILE_IO_EXTRA_CHECK
   99384           0 :           assert ( returnPointer != NULL ) ;
   99385             : #endif
   99386             :         }
   99387           0 :      return returnPointer ;
   99388             :    }
   99389             : 
   99390             : //############################################################################
   99391             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   99392             :  * pool size! We set for every valid object in the memory pool the freepointer
   99393             :  * to the global index and increase the global index afterwards. For all the 
   99394             :  * invalid objects (means address ranges within the memory pool that were not
   99395             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   99396             :  * distinguish valid from invalid objects! 
   99397             :  */
   99398             : unsigned long
   99399           5 : SgUndefDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   99400             :    {
   99401           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   99402           5 :      SgUndefDirectiveStatement* pointer = NULL;
   99403           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   99404           5 :      std::vector < unsigned char* > :: const_iterator block;
   99405           5 :      for ( block = SgUndefDirectiveStatement::pools.begin(); block != SgUndefDirectiveStatement::pools.end() ; ++block )
   99406             :         {
   99407           0 :           pointer = (SgUndefDirectiveStatement*)(*block);
   99408           0 :           for (unsigned i = 0; i < SgUndefDirectiveStatement::pool_size; ++i )
   99409             :              {
   99410             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   99411             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   99412             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   99413             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   99414             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   99415             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   99416             :             // properly; so this will have to be checked next.
   99417             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   99418             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   99419           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   99420             :                   {
   99421           0 :                     pointer[i].set_freepointer((SgUndefDirectiveStatement*)(globalIndex));
   99422           0 :                     globalIndex++;
   99423             :                   }
   99424             :                else
   99425             :                   {
   99426           0 :                     pointer[i].set_freepointer(NULL);
   99427             :                   }
   99428             :               }
   99429             :         }
   99430           5 :      return globalIndex;
   99431             :    }
   99432             : 
   99433             : //############################################################################
   99434             : // JH (01/14/2006)
   99435             : void
   99436           5 : SgUndefDirectiveStatement::resetValidFreepointers( )
   99437             :    {
   99438           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   99439           5 :      SgUndefDirectiveStatement* pointer = NULL;
   99440           5 :      std::vector < unsigned char* > :: const_iterator block;
   99441           5 :      SgUndefDirectiveStatement* pointerOfLinkedList = NULL;
   99442           5 :      for ( block = SgUndefDirectiveStatement::pools.begin(); block != SgUndefDirectiveStatement::pools.end() ; ++block )
   99443             :         {
   99444           0 :           pointer = (SgUndefDirectiveStatement*)(*block);
   99445           0 :           for (unsigned i = 0; i < SgUndefDirectiveStatement::pool_size; ++i )
   99446             :              {
   99447             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   99448             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   99449             :             // memory blocks!.
   99450           0 :                if ( pointer[i].get_freepointer() != NULL )
   99451             :                   {
   99452           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   99453             :                   }
   99454             :                else
   99455             :                   {
   99456           0 :                     if ( pointerOfLinkedList == NULL )
   99457             :                        {
   99458           0 :                          SgUndefDirectiveStatement::next_node = &(pointer[i]);
   99459             :                        }
   99460             :                     else
   99461             :                        {
   99462             :                       // printf ("In SgUndefDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   99463           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   99464             :                        }
   99465             :                     pointerOfLinkedList = &(pointer[i]);
   99466             :                   }
   99467             :               }
   99468             :         }
   99469             : 
   99470           5 :      if ( pointerOfLinkedList != NULL )
   99471             :         {
   99472             :        // printf ("In SgUndefDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   99473           0 :           pointerOfLinkedList->set_freepointer(NULL);
   99474             :        // DQ (6/6/2010): Temporary debugging...
   99475             :        //   ROSE_ASSERT(false);
   99476             :         }
   99477             : 
   99478           5 :      return ;
   99479             :    }
   99480             : 
   99481             : //############################################################################
   99482             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   99483             :  * within the memory pool and resets the freepointers, in order to achieve a 
   99484             :  * linked list, that has no jumps and starts at the beginning! This function 
   99485             :  * does not extend the memory pool, since we do not delete any memory blocks,
   99486             :  * but delete the valid objects.  
   99487             :  */
   99488             : void
   99489           0 : SgUndefDirectiveStatement::clearMemoryPool( )
   99490             :    {
   99491             :   // printf ("Inside of SgUndefDirectiveStatement::clearMemoryPool() \n");
   99492             : 
   99493           0 :      SgUndefDirectiveStatement* pointer = NULL, *tempPointer = NULL;
   99494           0 :      std::vector < unsigned char* > :: const_iterator block;
   99495           0 :      if ( SgUndefDirectiveStatement::pools.empty() == false )
   99496             :         {
   99497           0 :           block = SgUndefDirectiveStatement::pools.begin() ;
   99498           0 :           SgUndefDirectiveStatement::next_node = (SgUndefDirectiveStatement*) (*block);
   99499             : 
   99500           0 :           while ( block != SgUndefDirectiveStatement::pools.end() )
   99501             :              {
   99502           0 :                pointer = (SgUndefDirectiveStatement*) (*block);
   99503           0 :                if ( tempPointer != NULL )
   99504             :                   {
   99505           0 :                     tempPointer->set_freepointer(pointer);
   99506             :                   }
   99507           0 :                for (unsigned i = 0; i < SgUndefDirectiveStatement::pool_size - 1; ++i)
   99508             :                   {
   99509           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   99510             :                   }
   99511           0 :                 pointer[SgUndefDirectiveStatement::pool_size-1].set_freepointer(NULL);
   99512           0 :                 tempPointer = &(pointer[SgUndefDirectiveStatement::pool_size-1]);
   99513           0 :                 ++block;
   99514             :              }
   99515             :         }
   99516           0 :    }
   99517             : 
   99518           5 : void SgUndefDirectiveStatement::deleteMemoryPool() {
   99519           5 :   for (auto p: SgUndefDirectiveStatement::pools) {
   99520           0 :     ROSE_FREE(p);
   99521             :   }
   99522           5 :   SgUndefDirectiveStatement::next_node = nullptr;
   99523           5 :   SgUndefDirectiveStatement::pools.clear();
   99524           5 : }
   99525             : 
   99526             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   99527             : //                 reading multiple binary files to for a single AST.
   99528             : /////////// new version ////////////////////////////////
   99529             : //############################################################################
   99530             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   99531             : void
   99532           2 : SgUndefDirectiveStatement::extendMemoryPoolForFileIO( )
   99533             :   {
   99534           2 :     size_t blockIndex = SgUndefDirectiveStatement::pools.size();
   99535           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUndefDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUndefDirectiveStatement);
   99536             : 
   99537           2 :     while ( (blockIndex * SgUndefDirectiveStatement::pool_size) < newPoolSize)
   99538             :       {
   99539             : #if ROSE_ALLOC_TRACE
   99540             :         if (blockIndex > 0) {
   99541             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUndefDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUndefDirectiveStatement) = %" PRIuPTR " SgUndefDirectiveStatement::pool_size = %d \n",
   99542             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUndefDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUndefDirectiveStatement),SgUndefDirectiveStatement::pool_size);
   99543             :         }
   99544             : #endif
   99545             : 
   99546           0 :         SgUndefDirectiveStatement * pointer = (SgUndefDirectiveStatement*) ROSE_MALLOC ( SgUndefDirectiveStatement::pool_size * sizeof(SgUndefDirectiveStatement) );
   99547           0 :         assert( pointer != NULL );
   99548             : #if ROSE_ALLOC_MEMSET == 1
   99549             :         memset(pointer, 0x00, SgUndefDirectiveStatement::pool_size * sizeof(SgUndefDirectiveStatement));
   99550             : #elif ROSE_ALLOC_MEMSET == 2
   99551             :         memset(pointer, 0xCC, SgUndefDirectiveStatement::pool_size * sizeof(SgUndefDirectiveStatement));
   99552             : #endif
   99553           0 :         SgUndefDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
   99554           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUndefDirectiveStatement::pool_size * sizeof(SgUndefDirectiveStatement), V_SgUndefDirectiveStatement ) );
   99555             : 
   99556           0 :         if ( SgUndefDirectiveStatement::next_node != NULL ) {
   99557           0 :           if ( blockIndex > 0 ) {
   99558           0 :             SgUndefDirectiveStatement * blkptr = (SgUndefDirectiveStatement*)(SgUndefDirectiveStatement::pools[blockIndex-1]);
   99559           0 :             blkptr[ SgUndefDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
   99560             :           }
   99561             :         } else {
   99562           0 :           SgUndefDirectiveStatement::next_node = pointer;
   99563             :         }
   99564             : 
   99565           0 :         for (unsigned i = 0; i < SgUndefDirectiveStatement::pool_size-1; ++i)
   99566             :            {
   99567           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   99568             :            }
   99569           0 :         pointer[ SgUndefDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
   99570             : 
   99571           0 :         blockIndex++;
   99572             :       }
   99573           2 :   }
   99574             : 
   99575             : //############################################################################
   99576             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   99577             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   99578             :  * not compressed. However, that stuff is not yet implemented! 
   99579             :  */
   99580             : unsigned long
   99581           0 : SgUndefDirectiveStatement::getNumberOfLastValidPointer()
   99582             :    {
   99583           0 :       SgUndefDirectiveStatement* testPointer = (SgUndefDirectiveStatement*)(SgUndefDirectiveStatement::pools.back());
   99584           0 :       unsigned long localIndex = SgUndefDirectiveStatement::pool_size - 1;
   99585           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   99586             :          {
   99587           0 :            localIndex--;
   99588             :          }
   99589           0 :       return (localIndex + SgUndefDirectiveStatement::pool_size * (SgUndefDirectiveStatement::pools.size()-1));
   99590             :    }
   99591             : 
   99592             : //############################################################################
   99593             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   99594             :  * memory pool and initializes the data member in class SgUndefDirectiveStatementStroageClass
   99595             :  * from its counterpart of SgUndefDirectiveStatement. The return value is just for checking, 
   99596             :  * that the whole StorageClassArray is initialized!
   99597             :  */
   99598             : unsigned long
   99599           0 : SgUndefDirectiveStatement::initializeStorageClassArray( SgUndefDirectiveStatementStorageClass *storageArray )
   99600             :    {
   99601           0 :      unsigned long storageCounter = 0;
   99602           0 :      std::vector < unsigned char* > :: const_iterator block = SgUndefDirectiveStatement::pools.begin();
   99603           0 :      SgUndefDirectiveStatement* pointer = NULL;
   99604           0 :      while ( block != SgUndefDirectiveStatement::pools.end() ) {
   99605           0 :           pointer = (SgUndefDirectiveStatement*) (*block);
   99606           0 :           for ( unsigned i = 0; i < SgUndefDirectiveStatement::pool_size; ++i ) {
   99607           0 :                if ( pointer->get_freepointer() != NULL ) {
   99608           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   99609           0 :                  storageArray++;
   99610           0 :                  storageCounter++;
   99611             :                }
   99612           0 :                pointer++;
   99613             :              }
   99614           0 :            block++;
   99615             :         }
   99616           0 :      return storageCounter;
   99617             :    }
   99618             : 
   99619             : /* #line 99620 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   99620             : 
   99621             : 
   99622             : 
   99623             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   99624             : 
   99625             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   99626             : 
   99627             : //############################################################################
   99628             : /* JH (02/02/2006) Constructor of the IR node SgIfdefDirectiveStatement that takes its 
   99629             :  * corresponding StorageClass as parameter
   99630             :  */
   99631           0 : SgIfdefDirectiveStatement :: SgIfdefDirectiveStatement ( const SgIfdefDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
   99632             :    {
   99633             : 
   99634             : 
   99635             : /* #line 99636 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   99636             : 
   99637           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   99638             : 
   99639             : 
   99640             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   99641             : 
   99642             : 
   99643           0 :    }
   99644             : 
   99645             : //############################################################################
   99646             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   99647             :  * within the working AST. 
   99648             :  */
   99649           0 : SgIfdefDirectiveStatement * SgIfdefDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   99650           0 :      SgIfdefDirectiveStatement* returnPointer = NULL;
   99651           0 :      if ( globalIndex != 0 )
   99652             :         {
   99653             : 
   99654             : #if FILE_IO_EXTRA_CHECK
   99655           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIfdefDirectiveStatement ) ) <= globalIndex ) ;
   99656           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIfdefDirectiveStatement + 1 ) ) );
   99657             : #endif
   99658           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIfdefDirectiveStatement )  
   99659           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIfdefDirectiveStatement );
   99660           0 :           unsigned long positionInPool = localIndex % SgIfdefDirectiveStatement::pool_size;
   99661           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIfdefDirectiveStatement::pool_size;
   99662             : 
   99663             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   99664             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   99665             : 
   99666           0 :           returnPointer = &( ( (SgIfdefDirectiveStatement*)(SgIfdefDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   99667             : 
   99668           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   99669             :         }
   99670           0 :      return returnPointer ;
   99671             :    }
   99672             : 
   99673             : //############################################################################
   99674             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   99675             :   for the AST with the index astIndex
   99676             : */
   99677           0 : SgIfdefDirectiveStatement * SgIfdefDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   99678           0 :      SgIfdefDirectiveStatement* returnPointer = NULL;
   99679           0 :      if ( globalIndex != 0 )
   99680             :         {
   99681             : 
   99682             : #if FILE_IO_EXTRA_CHECK
   99683           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIfdefDirectiveStatement ) ) <= globalIndex ) ;
   99684           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIfdefDirectiveStatement + 1 ) ) );
   99685             : #endif
   99686           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIfdefDirectiveStatement )
   99687           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIfdefDirectiveStatement );
   99688           0 :           unsigned long positionInPool = localIndex % SgIfdefDirectiveStatement::pool_size ;
   99689           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIfdefDirectiveStatement::pool_size ;
   99690             : 
   99691             : #if FILE_IO_EXTRA_CHECK
   99692             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   99693             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   99694             : #endif
   99695             : 
   99696           0 :           returnPointer = &( ( (SgIfdefDirectiveStatement*)(SgIfdefDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   99697             : 
   99698             : #if FILE_IO_EXTRA_CHECK
   99699           0 :           assert ( returnPointer != NULL ) ;
   99700             : #endif
   99701             :         }
   99702           0 :      return returnPointer ;
   99703             :    }
   99704             : 
   99705             : //############################################################################
   99706             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
   99707             :  * pool size! We set for every valid object in the memory pool the freepointer
   99708             :  * to the global index and increase the global index afterwards. For all the 
   99709             :  * invalid objects (means address ranges within the memory pool that were not
   99710             :  * returned by the new operator) the freepointer is set to NULL, in order to 
   99711             :  * distinguish valid from invalid objects! 
   99712             :  */
   99713             : unsigned long
   99714           5 : SgIfdefDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
   99715             :    {
   99716           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
   99717           5 :      SgIfdefDirectiveStatement* pointer = NULL;
   99718           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
   99719           5 :      std::vector < unsigned char* > :: const_iterator block;
   99720           5 :      for ( block = SgIfdefDirectiveStatement::pools.begin(); block != SgIfdefDirectiveStatement::pools.end() ; ++block )
   99721             :         {
   99722           0 :           pointer = (SgIfdefDirectiveStatement*)(*block);
   99723           0 :           for (unsigned i = 0; i < SgIfdefDirectiveStatement::pool_size; ++i )
   99724             :              {
   99725             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
   99726             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
   99727             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
   99728             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
   99729             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
   99730             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
   99731             :             // properly; so this will have to be checked next.
   99732             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   99733             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
   99734           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
   99735             :                   {
   99736           0 :                     pointer[i].set_freepointer((SgIfdefDirectiveStatement*)(globalIndex));
   99737           0 :                     globalIndex++;
   99738             :                   }
   99739             :                else
   99740             :                   {
   99741           0 :                     pointer[i].set_freepointer(NULL);
   99742             :                   }
   99743             :               }
   99744             :         }
   99745           5 :      return globalIndex;
   99746             :    }
   99747             : 
   99748             : //############################################################################
   99749             : // JH (01/14/2006)
   99750             : void
   99751           5 : SgIfdefDirectiveStatement::resetValidFreepointers( )
   99752             :    {
   99753           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
   99754           5 :      SgIfdefDirectiveStatement* pointer = NULL;
   99755           5 :      std::vector < unsigned char* > :: const_iterator block;
   99756           5 :      SgIfdefDirectiveStatement* pointerOfLinkedList = NULL;
   99757           5 :      for ( block = SgIfdefDirectiveStatement::pools.begin(); block != SgIfdefDirectiveStatement::pools.end() ; ++block )
   99758             :         {
   99759           0 :           pointer = (SgIfdefDirectiveStatement*)(*block);
   99760           0 :           for (unsigned i = 0; i < SgIfdefDirectiveStatement::pool_size; ++i )
   99761             :              {
   99762             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
   99763             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
   99764             :             // memory blocks!.
   99765           0 :                if ( pointer[i].get_freepointer() != NULL )
   99766             :                   {
   99767           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
   99768             :                   }
   99769             :                else
   99770             :                   {
   99771           0 :                     if ( pointerOfLinkedList == NULL )
   99772             :                        {
   99773           0 :                          SgIfdefDirectiveStatement::next_node = &(pointer[i]);
   99774             :                        }
   99775             :                     else
   99776             :                        {
   99777             :                       // printf ("In SgIfdefDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
   99778           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
   99779             :                        }
   99780             :                     pointerOfLinkedList = &(pointer[i]);
   99781             :                   }
   99782             :               }
   99783             :         }
   99784             : 
   99785           5 :      if ( pointerOfLinkedList != NULL )
   99786             :         {
   99787             :        // printf ("In SgIfdefDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
   99788           0 :           pointerOfLinkedList->set_freepointer(NULL);
   99789             :        // DQ (6/6/2010): Temporary debugging...
   99790             :        //   ROSE_ASSERT(false);
   99791             :         }
   99792             : 
   99793           5 :      return ;
   99794             :    }
   99795             : 
   99796             : //############################################################################
   99797             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
   99798             :  * within the memory pool and resets the freepointers, in order to achieve a 
   99799             :  * linked list, that has no jumps and starts at the beginning! This function 
   99800             :  * does not extend the memory pool, since we do not delete any memory blocks,
   99801             :  * but delete the valid objects.  
   99802             :  */
   99803             : void
   99804           0 : SgIfdefDirectiveStatement::clearMemoryPool( )
   99805             :    {
   99806             :   // printf ("Inside of SgIfdefDirectiveStatement::clearMemoryPool() \n");
   99807             : 
   99808           0 :      SgIfdefDirectiveStatement* pointer = NULL, *tempPointer = NULL;
   99809           0 :      std::vector < unsigned char* > :: const_iterator block;
   99810           0 :      if ( SgIfdefDirectiveStatement::pools.empty() == false )
   99811             :         {
   99812           0 :           block = SgIfdefDirectiveStatement::pools.begin() ;
   99813           0 :           SgIfdefDirectiveStatement::next_node = (SgIfdefDirectiveStatement*) (*block);
   99814             : 
   99815           0 :           while ( block != SgIfdefDirectiveStatement::pools.end() )
   99816             :              {
   99817           0 :                pointer = (SgIfdefDirectiveStatement*) (*block);
   99818           0 :                if ( tempPointer != NULL )
   99819             :                   {
   99820           0 :                     tempPointer->set_freepointer(pointer);
   99821             :                   }
   99822           0 :                for (unsigned i = 0; i < SgIfdefDirectiveStatement::pool_size - 1; ++i)
   99823             :                   {
   99824           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
   99825             :                   }
   99826           0 :                 pointer[SgIfdefDirectiveStatement::pool_size-1].set_freepointer(NULL);
   99827           0 :                 tempPointer = &(pointer[SgIfdefDirectiveStatement::pool_size-1]);
   99828           0 :                 ++block;
   99829             :              }
   99830             :         }
   99831           0 :    }
   99832             : 
   99833           5 : void SgIfdefDirectiveStatement::deleteMemoryPool() {
   99834           5 :   for (auto p: SgIfdefDirectiveStatement::pools) {
   99835           0 :     ROSE_FREE(p);
   99836             :   }
   99837           5 :   SgIfdefDirectiveStatement::next_node = nullptr;
   99838           5 :   SgIfdefDirectiveStatement::pools.clear();
   99839           5 : }
   99840             : 
   99841             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
   99842             : //                 reading multiple binary files to for a single AST.
   99843             : /////////// new version ////////////////////////////////
   99844             : //############################################################################
   99845             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
   99846             : void
   99847           2 : SgIfdefDirectiveStatement::extendMemoryPoolForFileIO( )
   99848             :   {
   99849           2 :     size_t blockIndex = SgIfdefDirectiveStatement::pools.size();
   99850           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIfdefDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfdefDirectiveStatement);
   99851             : 
   99852           2 :     while ( (blockIndex * SgIfdefDirectiveStatement::pool_size) < newPoolSize)
   99853             :       {
   99854             : #if ROSE_ALLOC_TRACE
   99855             :         if (blockIndex > 0) {
   99856             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIfdefDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfdefDirectiveStatement) = %" PRIuPTR " SgIfdefDirectiveStatement::pool_size = %d \n",
   99857             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIfdefDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfdefDirectiveStatement),SgIfdefDirectiveStatement::pool_size);
   99858             :         }
   99859             : #endif
   99860             : 
   99861           0 :         SgIfdefDirectiveStatement * pointer = (SgIfdefDirectiveStatement*) ROSE_MALLOC ( SgIfdefDirectiveStatement::pool_size * sizeof(SgIfdefDirectiveStatement) );
   99862           0 :         assert( pointer != NULL );
   99863             : #if ROSE_ALLOC_MEMSET == 1
   99864             :         memset(pointer, 0x00, SgIfdefDirectiveStatement::pool_size * sizeof(SgIfdefDirectiveStatement));
   99865             : #elif ROSE_ALLOC_MEMSET == 2
   99866             :         memset(pointer, 0xCC, SgIfdefDirectiveStatement::pool_size * sizeof(SgIfdefDirectiveStatement));
   99867             : #endif
   99868           0 :         SgIfdefDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
   99869           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIfdefDirectiveStatement::pool_size * sizeof(SgIfdefDirectiveStatement), V_SgIfdefDirectiveStatement ) );
   99870             : 
   99871           0 :         if ( SgIfdefDirectiveStatement::next_node != NULL ) {
   99872           0 :           if ( blockIndex > 0 ) {
   99873           0 :             SgIfdefDirectiveStatement * blkptr = (SgIfdefDirectiveStatement*)(SgIfdefDirectiveStatement::pools[blockIndex-1]);
   99874           0 :             blkptr[ SgIfdefDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
   99875             :           }
   99876             :         } else {
   99877           0 :           SgIfdefDirectiveStatement::next_node = pointer;
   99878             :         }
   99879             : 
   99880           0 :         for (unsigned i = 0; i < SgIfdefDirectiveStatement::pool_size-1; ++i)
   99881             :            {
   99882           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
   99883             :            }
   99884           0 :         pointer[ SgIfdefDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
   99885             : 
   99886           0 :         blockIndex++;
   99887             :       }
   99888           2 :   }
   99889             : 
   99890             : //############################################################################
   99891             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
   99892             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
   99893             :  * not compressed. However, that stuff is not yet implemented! 
   99894             :  */
   99895             : unsigned long
   99896           0 : SgIfdefDirectiveStatement::getNumberOfLastValidPointer()
   99897             :    {
   99898           0 :       SgIfdefDirectiveStatement* testPointer = (SgIfdefDirectiveStatement*)(SgIfdefDirectiveStatement::pools.back());
   99899           0 :       unsigned long localIndex = SgIfdefDirectiveStatement::pool_size - 1;
   99900           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
   99901             :          {
   99902           0 :            localIndex--;
   99903             :          }
   99904           0 :       return (localIndex + SgIfdefDirectiveStatement::pool_size * (SgIfdefDirectiveStatement::pools.size()-1));
   99905             :    }
   99906             : 
   99907             : //############################################################################
   99908             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
   99909             :  * memory pool and initializes the data member in class SgIfdefDirectiveStatementStroageClass
   99910             :  * from its counterpart of SgIfdefDirectiveStatement. The return value is just for checking, 
   99911             :  * that the whole StorageClassArray is initialized!
   99912             :  */
   99913             : unsigned long
   99914           0 : SgIfdefDirectiveStatement::initializeStorageClassArray( SgIfdefDirectiveStatementStorageClass *storageArray )
   99915             :    {
   99916           0 :      unsigned long storageCounter = 0;
   99917           0 :      std::vector < unsigned char* > :: const_iterator block = SgIfdefDirectiveStatement::pools.begin();
   99918           0 :      SgIfdefDirectiveStatement* pointer = NULL;
   99919           0 :      while ( block != SgIfdefDirectiveStatement::pools.end() ) {
   99920           0 :           pointer = (SgIfdefDirectiveStatement*) (*block);
   99921           0 :           for ( unsigned i = 0; i < SgIfdefDirectiveStatement::pool_size; ++i ) {
   99922           0 :                if ( pointer->get_freepointer() != NULL ) {
   99923           0 :                  storageArray->pickOutIRNodeData (pointer) ;
   99924           0 :                  storageArray++;
   99925           0 :                  storageCounter++;
   99926             :                }
   99927           0 :                pointer++;
   99928             :              }
   99929           0 :            block++;
   99930             :         }
   99931           0 :      return storageCounter;
   99932             :    }
   99933             : 
   99934             : /* #line 99935 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   99935             : 
   99936             : 
   99937             : 
   99938             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   99939             : 
   99940             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
   99941             : 
   99942             : //############################################################################
   99943             : /* JH (02/02/2006) Constructor of the IR node SgIfndefDirectiveStatement that takes its 
   99944             :  * corresponding StorageClass as parameter
   99945             :  */
   99946           0 : SgIfndefDirectiveStatement :: SgIfndefDirectiveStatement ( const SgIfndefDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
   99947             :    {
   99948             : 
   99949             : 
   99950             : /* #line 99951 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
   99951             : 
   99952           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
   99953             : 
   99954             : 
   99955             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
   99956             : 
   99957             : 
   99958           0 :    }
   99959             : 
   99960             : //############################################################################
   99961             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
   99962             :  * within the working AST. 
   99963             :  */
   99964           0 : SgIfndefDirectiveStatement * SgIfndefDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
   99965           0 :      SgIfndefDirectiveStatement* returnPointer = NULL;
   99966           0 :      if ( globalIndex != 0 )
   99967             :         {
   99968             : 
   99969             : #if FILE_IO_EXTRA_CHECK
   99970           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIfndefDirectiveStatement ) ) <= globalIndex ) ;
   99971           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIfndefDirectiveStatement + 1 ) ) );
   99972             : #endif
   99973           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIfndefDirectiveStatement )  
   99974           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIfndefDirectiveStatement );
   99975           0 :           unsigned long positionInPool = localIndex % SgIfndefDirectiveStatement::pool_size;
   99976           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIfndefDirectiveStatement::pool_size;
   99977             : 
   99978             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
   99979             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
   99980             : 
   99981           0 :           returnPointer = &( ( (SgIfndefDirectiveStatement*)(SgIfndefDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
   99982             : 
   99983           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
   99984             :         }
   99985           0 :      return returnPointer ;
   99986             :    }
   99987             : 
   99988             : //############################################################################
   99989             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
   99990             :   for the AST with the index astIndex
   99991             : */
   99992           0 : SgIfndefDirectiveStatement * SgIfndefDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
   99993           0 :      SgIfndefDirectiveStatement* returnPointer = NULL;
   99994           0 :      if ( globalIndex != 0 )
   99995             :         {
   99996             : 
   99997             : #if FILE_IO_EXTRA_CHECK
   99998           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIfndefDirectiveStatement ) ) <= globalIndex ) ;
   99999           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIfndefDirectiveStatement + 1 ) ) );
  100000             : #endif
  100001           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIfndefDirectiveStatement )
  100002           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIfndefDirectiveStatement );
  100003           0 :           unsigned long positionInPool = localIndex % SgIfndefDirectiveStatement::pool_size ;
  100004           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIfndefDirectiveStatement::pool_size ;
  100005             : 
  100006             : #if FILE_IO_EXTRA_CHECK
  100007             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  100008             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  100009             : #endif
  100010             : 
  100011           0 :           returnPointer = &( ( (SgIfndefDirectiveStatement*)(SgIfndefDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  100012             : 
  100013             : #if FILE_IO_EXTRA_CHECK
  100014           0 :           assert ( returnPointer != NULL ) ;
  100015             : #endif
  100016             :         }
  100017           0 :      return returnPointer ;
  100018             :    }
  100019             : 
  100020             : //############################################################################
  100021             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  100022             :  * pool size! We set for every valid object in the memory pool the freepointer
  100023             :  * to the global index and increase the global index afterwards. For all the 
  100024             :  * invalid objects (means address ranges within the memory pool that were not
  100025             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  100026             :  * distinguish valid from invalid objects! 
  100027             :  */
  100028             : unsigned long
  100029           5 : SgIfndefDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  100030             :    {
  100031           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  100032           5 :      SgIfndefDirectiveStatement* pointer = NULL;
  100033           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  100034           5 :      std::vector < unsigned char* > :: const_iterator block;
  100035           5 :      for ( block = SgIfndefDirectiveStatement::pools.begin(); block != SgIfndefDirectiveStatement::pools.end() ; ++block )
  100036             :         {
  100037           0 :           pointer = (SgIfndefDirectiveStatement*)(*block);
  100038           0 :           for (unsigned i = 0; i < SgIfndefDirectiveStatement::pool_size; ++i )
  100039             :              {
  100040             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  100041             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  100042             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  100043             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  100044             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  100045             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  100046             :             // properly; so this will have to be checked next.
  100047             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  100048             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  100049           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  100050             :                   {
  100051           0 :                     pointer[i].set_freepointer((SgIfndefDirectiveStatement*)(globalIndex));
  100052           0 :                     globalIndex++;
  100053             :                   }
  100054             :                else
  100055             :                   {
  100056           0 :                     pointer[i].set_freepointer(NULL);
  100057             :                   }
  100058             :               }
  100059             :         }
  100060           5 :      return globalIndex;
  100061             :    }
  100062             : 
  100063             : //############################################################################
  100064             : // JH (01/14/2006)
  100065             : void
  100066           5 : SgIfndefDirectiveStatement::resetValidFreepointers( )
  100067             :    {
  100068           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  100069           5 :      SgIfndefDirectiveStatement* pointer = NULL;
  100070           5 :      std::vector < unsigned char* > :: const_iterator block;
  100071           5 :      SgIfndefDirectiveStatement* pointerOfLinkedList = NULL;
  100072           5 :      for ( block = SgIfndefDirectiveStatement::pools.begin(); block != SgIfndefDirectiveStatement::pools.end() ; ++block )
  100073             :         {
  100074           0 :           pointer = (SgIfndefDirectiveStatement*)(*block);
  100075           0 :           for (unsigned i = 0; i < SgIfndefDirectiveStatement::pool_size; ++i )
  100076             :              {
  100077             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  100078             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  100079             :             // memory blocks!.
  100080           0 :                if ( pointer[i].get_freepointer() != NULL )
  100081             :                   {
  100082           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  100083             :                   }
  100084             :                else
  100085             :                   {
  100086           0 :                     if ( pointerOfLinkedList == NULL )
  100087             :                        {
  100088           0 :                          SgIfndefDirectiveStatement::next_node = &(pointer[i]);
  100089             :                        }
  100090             :                     else
  100091             :                        {
  100092             :                       // printf ("In SgIfndefDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  100093           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  100094             :                        }
  100095             :                     pointerOfLinkedList = &(pointer[i]);
  100096             :                   }
  100097             :               }
  100098             :         }
  100099             : 
  100100           5 :      if ( pointerOfLinkedList != NULL )
  100101             :         {
  100102             :        // printf ("In SgIfndefDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  100103           0 :           pointerOfLinkedList->set_freepointer(NULL);
  100104             :        // DQ (6/6/2010): Temporary debugging...
  100105             :        //   ROSE_ASSERT(false);
  100106             :         }
  100107             : 
  100108           5 :      return ;
  100109             :    }
  100110             : 
  100111             : //############################################################################
  100112             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  100113             :  * within the memory pool and resets the freepointers, in order to achieve a 
  100114             :  * linked list, that has no jumps and starts at the beginning! This function 
  100115             :  * does not extend the memory pool, since we do not delete any memory blocks,
  100116             :  * but delete the valid objects.  
  100117             :  */
  100118             : void
  100119           0 : SgIfndefDirectiveStatement::clearMemoryPool( )
  100120             :    {
  100121             :   // printf ("Inside of SgIfndefDirectiveStatement::clearMemoryPool() \n");
  100122             : 
  100123           0 :      SgIfndefDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  100124           0 :      std::vector < unsigned char* > :: const_iterator block;
  100125           0 :      if ( SgIfndefDirectiveStatement::pools.empty() == false )
  100126             :         {
  100127           0 :           block = SgIfndefDirectiveStatement::pools.begin() ;
  100128           0 :           SgIfndefDirectiveStatement::next_node = (SgIfndefDirectiveStatement*) (*block);
  100129             : 
  100130           0 :           while ( block != SgIfndefDirectiveStatement::pools.end() )
  100131             :              {
  100132           0 :                pointer = (SgIfndefDirectiveStatement*) (*block);
  100133           0 :                if ( tempPointer != NULL )
  100134             :                   {
  100135           0 :                     tempPointer->set_freepointer(pointer);
  100136             :                   }
  100137           0 :                for (unsigned i = 0; i < SgIfndefDirectiveStatement::pool_size - 1; ++i)
  100138             :                   {
  100139           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  100140             :                   }
  100141           0 :                 pointer[SgIfndefDirectiveStatement::pool_size-1].set_freepointer(NULL);
  100142           0 :                 tempPointer = &(pointer[SgIfndefDirectiveStatement::pool_size-1]);
  100143           0 :                 ++block;
  100144             :              }
  100145             :         }
  100146           0 :    }
  100147             : 
  100148           5 : void SgIfndefDirectiveStatement::deleteMemoryPool() {
  100149           5 :   for (auto p: SgIfndefDirectiveStatement::pools) {
  100150           0 :     ROSE_FREE(p);
  100151             :   }
  100152           5 :   SgIfndefDirectiveStatement::next_node = nullptr;
  100153           5 :   SgIfndefDirectiveStatement::pools.clear();
  100154           5 : }
  100155             : 
  100156             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  100157             : //                 reading multiple binary files to for a single AST.
  100158             : /////////// new version ////////////////////////////////
  100159             : //############################################################################
  100160             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  100161             : void
  100162           2 : SgIfndefDirectiveStatement::extendMemoryPoolForFileIO( )
  100163             :   {
  100164           2 :     size_t blockIndex = SgIfndefDirectiveStatement::pools.size();
  100165           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIfndefDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfndefDirectiveStatement);
  100166             : 
  100167           2 :     while ( (blockIndex * SgIfndefDirectiveStatement::pool_size) < newPoolSize)
  100168             :       {
  100169             : #if ROSE_ALLOC_TRACE
  100170             :         if (blockIndex > 0) {
  100171             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIfndefDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfndefDirectiveStatement) = %" PRIuPTR " SgIfndefDirectiveStatement::pool_size = %d \n",
  100172             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIfndefDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfndefDirectiveStatement),SgIfndefDirectiveStatement::pool_size);
  100173             :         }
  100174             : #endif
  100175             : 
  100176           0 :         SgIfndefDirectiveStatement * pointer = (SgIfndefDirectiveStatement*) ROSE_MALLOC ( SgIfndefDirectiveStatement::pool_size * sizeof(SgIfndefDirectiveStatement) );
  100177           0 :         assert( pointer != NULL );
  100178             : #if ROSE_ALLOC_MEMSET == 1
  100179             :         memset(pointer, 0x00, SgIfndefDirectiveStatement::pool_size * sizeof(SgIfndefDirectiveStatement));
  100180             : #elif ROSE_ALLOC_MEMSET == 2
  100181             :         memset(pointer, 0xCC, SgIfndefDirectiveStatement::pool_size * sizeof(SgIfndefDirectiveStatement));
  100182             : #endif
  100183           0 :         SgIfndefDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  100184           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIfndefDirectiveStatement::pool_size * sizeof(SgIfndefDirectiveStatement), V_SgIfndefDirectiveStatement ) );
  100185             : 
  100186           0 :         if ( SgIfndefDirectiveStatement::next_node != NULL ) {
  100187           0 :           if ( blockIndex > 0 ) {
  100188           0 :             SgIfndefDirectiveStatement * blkptr = (SgIfndefDirectiveStatement*)(SgIfndefDirectiveStatement::pools[blockIndex-1]);
  100189           0 :             blkptr[ SgIfndefDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  100190             :           }
  100191             :         } else {
  100192           0 :           SgIfndefDirectiveStatement::next_node = pointer;
  100193             :         }
  100194             : 
  100195           0 :         for (unsigned i = 0; i < SgIfndefDirectiveStatement::pool_size-1; ++i)
  100196             :            {
  100197           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  100198             :            }
  100199           0 :         pointer[ SgIfndefDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  100200             : 
  100201           0 :         blockIndex++;
  100202             :       }
  100203           2 :   }
  100204             : 
  100205             : //############################################################################
  100206             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  100207             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  100208             :  * not compressed. However, that stuff is not yet implemented! 
  100209             :  */
  100210             : unsigned long
  100211           0 : SgIfndefDirectiveStatement::getNumberOfLastValidPointer()
  100212             :    {
  100213           0 :       SgIfndefDirectiveStatement* testPointer = (SgIfndefDirectiveStatement*)(SgIfndefDirectiveStatement::pools.back());
  100214           0 :       unsigned long localIndex = SgIfndefDirectiveStatement::pool_size - 1;
  100215           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  100216             :          {
  100217           0 :            localIndex--;
  100218             :          }
  100219           0 :       return (localIndex + SgIfndefDirectiveStatement::pool_size * (SgIfndefDirectiveStatement::pools.size()-1));
  100220             :    }
  100221             : 
  100222             : //############################################################################
  100223             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  100224             :  * memory pool and initializes the data member in class SgIfndefDirectiveStatementStroageClass
  100225             :  * from its counterpart of SgIfndefDirectiveStatement. The return value is just for checking, 
  100226             :  * that the whole StorageClassArray is initialized!
  100227             :  */
  100228             : unsigned long
  100229           0 : SgIfndefDirectiveStatement::initializeStorageClassArray( SgIfndefDirectiveStatementStorageClass *storageArray )
  100230             :    {
  100231           0 :      unsigned long storageCounter = 0;
  100232           0 :      std::vector < unsigned char* > :: const_iterator block = SgIfndefDirectiveStatement::pools.begin();
  100233           0 :      SgIfndefDirectiveStatement* pointer = NULL;
  100234           0 :      while ( block != SgIfndefDirectiveStatement::pools.end() ) {
  100235           0 :           pointer = (SgIfndefDirectiveStatement*) (*block);
  100236           0 :           for ( unsigned i = 0; i < SgIfndefDirectiveStatement::pool_size; ++i ) {
  100237           0 :                if ( pointer->get_freepointer() != NULL ) {
  100238           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  100239           0 :                  storageArray++;
  100240           0 :                  storageCounter++;
  100241             :                }
  100242           0 :                pointer++;
  100243             :              }
  100244           0 :            block++;
  100245             :         }
  100246           0 :      return storageCounter;
  100247             :    }
  100248             : 
  100249             : /* #line 100250 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  100250             : 
  100251             : 
  100252             : 
  100253             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  100254             : 
  100255             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  100256             : 
  100257             : //############################################################################
  100258             : /* JH (02/02/2006) Constructor of the IR node SgIfDirectiveStatement that takes its 
  100259             :  * corresponding StorageClass as parameter
  100260             :  */
  100261           0 : SgIfDirectiveStatement :: SgIfDirectiveStatement ( const SgIfDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  100262             :    {
  100263             : 
  100264             : 
  100265             : /* #line 100266 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  100266             : 
  100267           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  100268             : 
  100269             : 
  100270             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  100271             : 
  100272             : 
  100273           0 :    }
  100274             : 
  100275             : //############################################################################
  100276             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  100277             :  * within the working AST. 
  100278             :  */
  100279           0 : SgIfDirectiveStatement * SgIfDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  100280           0 :      SgIfDirectiveStatement* returnPointer = NULL;
  100281           0 :      if ( globalIndex != 0 )
  100282             :         {
  100283             : 
  100284             : #if FILE_IO_EXTRA_CHECK
  100285           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIfDirectiveStatement ) ) <= globalIndex ) ;
  100286           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIfDirectiveStatement + 1 ) ) );
  100287             : #endif
  100288           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIfDirectiveStatement )  
  100289           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIfDirectiveStatement );
  100290           0 :           unsigned long positionInPool = localIndex % SgIfDirectiveStatement::pool_size;
  100291           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIfDirectiveStatement::pool_size;
  100292             : 
  100293             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  100294             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  100295             : 
  100296           0 :           returnPointer = &( ( (SgIfDirectiveStatement*)(SgIfDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  100297             : 
  100298           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  100299             :         }
  100300           0 :      return returnPointer ;
  100301             :    }
  100302             : 
  100303             : //############################################################################
  100304             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  100305             :   for the AST with the index astIndex
  100306             : */
  100307           0 : SgIfDirectiveStatement * SgIfDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  100308           0 :      SgIfDirectiveStatement* returnPointer = NULL;
  100309           0 :      if ( globalIndex != 0 )
  100310             :         {
  100311             : 
  100312             : #if FILE_IO_EXTRA_CHECK
  100313           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIfDirectiveStatement ) ) <= globalIndex ) ;
  100314           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIfDirectiveStatement + 1 ) ) );
  100315             : #endif
  100316           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIfDirectiveStatement )
  100317           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIfDirectiveStatement );
  100318           0 :           unsigned long positionInPool = localIndex % SgIfDirectiveStatement::pool_size ;
  100319           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIfDirectiveStatement::pool_size ;
  100320             : 
  100321             : #if FILE_IO_EXTRA_CHECK
  100322             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  100323             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  100324             : #endif
  100325             : 
  100326           0 :           returnPointer = &( ( (SgIfDirectiveStatement*)(SgIfDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  100327             : 
  100328             : #if FILE_IO_EXTRA_CHECK
  100329           0 :           assert ( returnPointer != NULL ) ;
  100330             : #endif
  100331             :         }
  100332           0 :      return returnPointer ;
  100333             :    }
  100334             : 
  100335             : //############################################################################
  100336             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  100337             :  * pool size! We set for every valid object in the memory pool the freepointer
  100338             :  * to the global index and increase the global index afterwards. For all the 
  100339             :  * invalid objects (means address ranges within the memory pool that were not
  100340             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  100341             :  * distinguish valid from invalid objects! 
  100342             :  */
  100343             : unsigned long
  100344           5 : SgIfDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  100345             :    {
  100346           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  100347           5 :      SgIfDirectiveStatement* pointer = NULL;
  100348           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  100349           5 :      std::vector < unsigned char* > :: const_iterator block;
  100350           5 :      for ( block = SgIfDirectiveStatement::pools.begin(); block != SgIfDirectiveStatement::pools.end() ; ++block )
  100351             :         {
  100352           0 :           pointer = (SgIfDirectiveStatement*)(*block);
  100353           0 :           for (unsigned i = 0; i < SgIfDirectiveStatement::pool_size; ++i )
  100354             :              {
  100355             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  100356             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  100357             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  100358             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  100359             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  100360             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  100361             :             // properly; so this will have to be checked next.
  100362             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  100363             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  100364           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  100365             :                   {
  100366           0 :                     pointer[i].set_freepointer((SgIfDirectiveStatement*)(globalIndex));
  100367           0 :                     globalIndex++;
  100368             :                   }
  100369             :                else
  100370             :                   {
  100371           0 :                     pointer[i].set_freepointer(NULL);
  100372             :                   }
  100373             :               }
  100374             :         }
  100375           5 :      return globalIndex;
  100376             :    }
  100377             : 
  100378             : //############################################################################
  100379             : // JH (01/14/2006)
  100380             : void
  100381           5 : SgIfDirectiveStatement::resetValidFreepointers( )
  100382             :    {
  100383           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  100384           5 :      SgIfDirectiveStatement* pointer = NULL;
  100385           5 :      std::vector < unsigned char* > :: const_iterator block;
  100386           5 :      SgIfDirectiveStatement* pointerOfLinkedList = NULL;
  100387           5 :      for ( block = SgIfDirectiveStatement::pools.begin(); block != SgIfDirectiveStatement::pools.end() ; ++block )
  100388             :         {
  100389           0 :           pointer = (SgIfDirectiveStatement*)(*block);
  100390           0 :           for (unsigned i = 0; i < SgIfDirectiveStatement::pool_size; ++i )
  100391             :              {
  100392             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  100393             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  100394             :             // memory blocks!.
  100395           0 :                if ( pointer[i].get_freepointer() != NULL )
  100396             :                   {
  100397           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  100398             :                   }
  100399             :                else
  100400             :                   {
  100401           0 :                     if ( pointerOfLinkedList == NULL )
  100402             :                        {
  100403           0 :                          SgIfDirectiveStatement::next_node = &(pointer[i]);
  100404             :                        }
  100405             :                     else
  100406             :                        {
  100407             :                       // printf ("In SgIfDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  100408           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  100409             :                        }
  100410             :                     pointerOfLinkedList = &(pointer[i]);
  100411             :                   }
  100412             :               }
  100413             :         }
  100414             : 
  100415           5 :      if ( pointerOfLinkedList != NULL )
  100416             :         {
  100417             :        // printf ("In SgIfDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  100418           0 :           pointerOfLinkedList->set_freepointer(NULL);
  100419             :        // DQ (6/6/2010): Temporary debugging...
  100420             :        //   ROSE_ASSERT(false);
  100421             :         }
  100422             : 
  100423           5 :      return ;
  100424             :    }
  100425             : 
  100426             : //############################################################################
  100427             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  100428             :  * within the memory pool and resets the freepointers, in order to achieve a 
  100429             :  * linked list, that has no jumps and starts at the beginning! This function 
  100430             :  * does not extend the memory pool, since we do not delete any memory blocks,
  100431             :  * but delete the valid objects.  
  100432             :  */
  100433             : void
  100434           0 : SgIfDirectiveStatement::clearMemoryPool( )
  100435             :    {
  100436             :   // printf ("Inside of SgIfDirectiveStatement::clearMemoryPool() \n");
  100437             : 
  100438           0 :      SgIfDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  100439           0 :      std::vector < unsigned char* > :: const_iterator block;
  100440           0 :      if ( SgIfDirectiveStatement::pools.empty() == false )
  100441             :         {
  100442           0 :           block = SgIfDirectiveStatement::pools.begin() ;
  100443           0 :           SgIfDirectiveStatement::next_node = (SgIfDirectiveStatement*) (*block);
  100444             : 
  100445           0 :           while ( block != SgIfDirectiveStatement::pools.end() )
  100446             :              {
  100447           0 :                pointer = (SgIfDirectiveStatement*) (*block);
  100448           0 :                if ( tempPointer != NULL )
  100449             :                   {
  100450           0 :                     tempPointer->set_freepointer(pointer);
  100451             :                   }
  100452           0 :                for (unsigned i = 0; i < SgIfDirectiveStatement::pool_size - 1; ++i)
  100453             :                   {
  100454           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  100455             :                   }
  100456           0 :                 pointer[SgIfDirectiveStatement::pool_size-1].set_freepointer(NULL);
  100457           0 :                 tempPointer = &(pointer[SgIfDirectiveStatement::pool_size-1]);
  100458           0 :                 ++block;
  100459             :              }
  100460             :         }
  100461           0 :    }
  100462             : 
  100463           5 : void SgIfDirectiveStatement::deleteMemoryPool() {
  100464           5 :   for (auto p: SgIfDirectiveStatement::pools) {
  100465           0 :     ROSE_FREE(p);
  100466             :   }
  100467           5 :   SgIfDirectiveStatement::next_node = nullptr;
  100468           5 :   SgIfDirectiveStatement::pools.clear();
  100469           5 : }
  100470             : 
  100471             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  100472             : //                 reading multiple binary files to for a single AST.
  100473             : /////////// new version ////////////////////////////////
  100474             : //############################################################################
  100475             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  100476             : void
  100477           2 : SgIfDirectiveStatement::extendMemoryPoolForFileIO( )
  100478             :   {
  100479           2 :     size_t blockIndex = SgIfDirectiveStatement::pools.size();
  100480           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIfDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfDirectiveStatement);
  100481             : 
  100482           2 :     while ( (blockIndex * SgIfDirectiveStatement::pool_size) < newPoolSize)
  100483             :       {
  100484             : #if ROSE_ALLOC_TRACE
  100485             :         if (blockIndex > 0) {
  100486             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIfDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfDirectiveStatement) = %" PRIuPTR " SgIfDirectiveStatement::pool_size = %d \n",
  100487             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIfDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIfDirectiveStatement),SgIfDirectiveStatement::pool_size);
  100488             :         }
  100489             : #endif
  100490             : 
  100491           0 :         SgIfDirectiveStatement * pointer = (SgIfDirectiveStatement*) ROSE_MALLOC ( SgIfDirectiveStatement::pool_size * sizeof(SgIfDirectiveStatement) );
  100492           0 :         assert( pointer != NULL );
  100493             : #if ROSE_ALLOC_MEMSET == 1
  100494             :         memset(pointer, 0x00, SgIfDirectiveStatement::pool_size * sizeof(SgIfDirectiveStatement));
  100495             : #elif ROSE_ALLOC_MEMSET == 2
  100496             :         memset(pointer, 0xCC, SgIfDirectiveStatement::pool_size * sizeof(SgIfDirectiveStatement));
  100497             : #endif
  100498           0 :         SgIfDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  100499           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIfDirectiveStatement::pool_size * sizeof(SgIfDirectiveStatement), V_SgIfDirectiveStatement ) );
  100500             : 
  100501           0 :         if ( SgIfDirectiveStatement::next_node != NULL ) {
  100502           0 :           if ( blockIndex > 0 ) {
  100503           0 :             SgIfDirectiveStatement * blkptr = (SgIfDirectiveStatement*)(SgIfDirectiveStatement::pools[blockIndex-1]);
  100504           0 :             blkptr[ SgIfDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  100505             :           }
  100506             :         } else {
  100507           0 :           SgIfDirectiveStatement::next_node = pointer;
  100508             :         }
  100509             : 
  100510           0 :         for (unsigned i = 0; i < SgIfDirectiveStatement::pool_size-1; ++i)
  100511             :            {
  100512           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  100513             :            }
  100514           0 :         pointer[ SgIfDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  100515             : 
  100516           0 :         blockIndex++;
  100517             :       }
  100518           2 :   }
  100519             : 
  100520             : //############################################################################
  100521             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  100522             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  100523             :  * not compressed. However, that stuff is not yet implemented! 
  100524             :  */
  100525             : unsigned long
  100526           0 : SgIfDirectiveStatement::getNumberOfLastValidPointer()
  100527             :    {
  100528           0 :       SgIfDirectiveStatement* testPointer = (SgIfDirectiveStatement*)(SgIfDirectiveStatement::pools.back());
  100529           0 :       unsigned long localIndex = SgIfDirectiveStatement::pool_size - 1;
  100530           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  100531             :          {
  100532           0 :            localIndex--;
  100533             :          }
  100534           0 :       return (localIndex + SgIfDirectiveStatement::pool_size * (SgIfDirectiveStatement::pools.size()-1));
  100535             :    }
  100536             : 
  100537             : //############################################################################
  100538             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  100539             :  * memory pool and initializes the data member in class SgIfDirectiveStatementStroageClass
  100540             :  * from its counterpart of SgIfDirectiveStatement. The return value is just for checking, 
  100541             :  * that the whole StorageClassArray is initialized!
  100542             :  */
  100543             : unsigned long
  100544           0 : SgIfDirectiveStatement::initializeStorageClassArray( SgIfDirectiveStatementStorageClass *storageArray )
  100545             :    {
  100546           0 :      unsigned long storageCounter = 0;
  100547           0 :      std::vector < unsigned char* > :: const_iterator block = SgIfDirectiveStatement::pools.begin();
  100548           0 :      SgIfDirectiveStatement* pointer = NULL;
  100549           0 :      while ( block != SgIfDirectiveStatement::pools.end() ) {
  100550           0 :           pointer = (SgIfDirectiveStatement*) (*block);
  100551           0 :           for ( unsigned i = 0; i < SgIfDirectiveStatement::pool_size; ++i ) {
  100552           0 :                if ( pointer->get_freepointer() != NULL ) {
  100553           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  100554           0 :                  storageArray++;
  100555           0 :                  storageCounter++;
  100556             :                }
  100557           0 :                pointer++;
  100558             :              }
  100559           0 :            block++;
  100560             :         }
  100561           0 :      return storageCounter;
  100562             :    }
  100563             : 
  100564             : /* #line 100565 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  100565             : 
  100566             : 
  100567             : 
  100568             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  100569             : 
  100570             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  100571             : 
  100572             : //############################################################################
  100573             : /* JH (02/02/2006) Constructor of the IR node SgDeadIfDirectiveStatement that takes its 
  100574             :  * corresponding StorageClass as parameter
  100575             :  */
  100576           0 : SgDeadIfDirectiveStatement :: SgDeadIfDirectiveStatement ( const SgDeadIfDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  100577             :    {
  100578             : 
  100579             : 
  100580             : /* #line 100581 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  100581             : 
  100582           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  100583             : 
  100584             : 
  100585             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  100586             : 
  100587             : 
  100588           0 :    }
  100589             : 
  100590             : //############################################################################
  100591             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  100592             :  * within the working AST. 
  100593             :  */
  100594           0 : SgDeadIfDirectiveStatement * SgDeadIfDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  100595           0 :      SgDeadIfDirectiveStatement* returnPointer = NULL;
  100596           0 :      if ( globalIndex != 0 )
  100597             :         {
  100598             : 
  100599             : #if FILE_IO_EXTRA_CHECK
  100600           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDeadIfDirectiveStatement ) ) <= globalIndex ) ;
  100601           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeadIfDirectiveStatement + 1 ) ) );
  100602             : #endif
  100603           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeadIfDirectiveStatement )  
  100604           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDeadIfDirectiveStatement );
  100605           0 :           unsigned long positionInPool = localIndex % SgDeadIfDirectiveStatement::pool_size;
  100606           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeadIfDirectiveStatement::pool_size;
  100607             : 
  100608             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  100609             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  100610             : 
  100611           0 :           returnPointer = &( ( (SgDeadIfDirectiveStatement*)(SgDeadIfDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  100612             : 
  100613           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  100614             :         }
  100615           0 :      return returnPointer ;
  100616             :    }
  100617             : 
  100618             : //############################################################################
  100619             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  100620             :   for the AST with the index astIndex
  100621             : */
  100622           0 : SgDeadIfDirectiveStatement * SgDeadIfDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  100623           0 :      SgDeadIfDirectiveStatement* returnPointer = NULL;
  100624           0 :      if ( globalIndex != 0 )
  100625             :         {
  100626             : 
  100627             : #if FILE_IO_EXTRA_CHECK
  100628           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDeadIfDirectiveStatement ) ) <= globalIndex ) ;
  100629           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeadIfDirectiveStatement + 1 ) ) );
  100630             : #endif
  100631           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeadIfDirectiveStatement )
  100632           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDeadIfDirectiveStatement );
  100633           0 :           unsigned long positionInPool = localIndex % SgDeadIfDirectiveStatement::pool_size ;
  100634           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeadIfDirectiveStatement::pool_size ;
  100635             : 
  100636             : #if FILE_IO_EXTRA_CHECK
  100637             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  100638             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  100639             : #endif
  100640             : 
  100641           0 :           returnPointer = &( ( (SgDeadIfDirectiveStatement*)(SgDeadIfDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  100642             : 
  100643             : #if FILE_IO_EXTRA_CHECK
  100644           0 :           assert ( returnPointer != NULL ) ;
  100645             : #endif
  100646             :         }
  100647           0 :      return returnPointer ;
  100648             :    }
  100649             : 
  100650             : //############################################################################
  100651             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  100652             :  * pool size! We set for every valid object in the memory pool the freepointer
  100653             :  * to the global index and increase the global index afterwards. For all the 
  100654             :  * invalid objects (means address ranges within the memory pool that were not
  100655             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  100656             :  * distinguish valid from invalid objects! 
  100657             :  */
  100658             : unsigned long
  100659           5 : SgDeadIfDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  100660             :    {
  100661           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  100662           5 :      SgDeadIfDirectiveStatement* pointer = NULL;
  100663           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  100664           5 :      std::vector < unsigned char* > :: const_iterator block;
  100665           5 :      for ( block = SgDeadIfDirectiveStatement::pools.begin(); block != SgDeadIfDirectiveStatement::pools.end() ; ++block )
  100666             :         {
  100667           0 :           pointer = (SgDeadIfDirectiveStatement*)(*block);
  100668           0 :           for (unsigned i = 0; i < SgDeadIfDirectiveStatement::pool_size; ++i )
  100669             :              {
  100670             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  100671             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  100672             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  100673             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  100674             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  100675             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  100676             :             // properly; so this will have to be checked next.
  100677             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  100678             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  100679           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  100680             :                   {
  100681           0 :                     pointer[i].set_freepointer((SgDeadIfDirectiveStatement*)(globalIndex));
  100682           0 :                     globalIndex++;
  100683             :                   }
  100684             :                else
  100685             :                   {
  100686           0 :                     pointer[i].set_freepointer(NULL);
  100687             :                   }
  100688             :               }
  100689             :         }
  100690           5 :      return globalIndex;
  100691             :    }
  100692             : 
  100693             : //############################################################################
  100694             : // JH (01/14/2006)
  100695             : void
  100696           5 : SgDeadIfDirectiveStatement::resetValidFreepointers( )
  100697             :    {
  100698           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  100699           5 :      SgDeadIfDirectiveStatement* pointer = NULL;
  100700           5 :      std::vector < unsigned char* > :: const_iterator block;
  100701           5 :      SgDeadIfDirectiveStatement* pointerOfLinkedList = NULL;
  100702           5 :      for ( block = SgDeadIfDirectiveStatement::pools.begin(); block != SgDeadIfDirectiveStatement::pools.end() ; ++block )
  100703             :         {
  100704           0 :           pointer = (SgDeadIfDirectiveStatement*)(*block);
  100705           0 :           for (unsigned i = 0; i < SgDeadIfDirectiveStatement::pool_size; ++i )
  100706             :              {
  100707             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  100708             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  100709             :             // memory blocks!.
  100710           0 :                if ( pointer[i].get_freepointer() != NULL )
  100711             :                   {
  100712           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  100713             :                   }
  100714             :                else
  100715             :                   {
  100716           0 :                     if ( pointerOfLinkedList == NULL )
  100717             :                        {
  100718           0 :                          SgDeadIfDirectiveStatement::next_node = &(pointer[i]);
  100719             :                        }
  100720             :                     else
  100721             :                        {
  100722             :                       // printf ("In SgDeadIfDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  100723           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  100724             :                        }
  100725             :                     pointerOfLinkedList = &(pointer[i]);
  100726             :                   }
  100727             :               }
  100728             :         }
  100729             : 
  100730           5 :      if ( pointerOfLinkedList != NULL )
  100731             :         {
  100732             :        // printf ("In SgDeadIfDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  100733           0 :           pointerOfLinkedList->set_freepointer(NULL);
  100734             :        // DQ (6/6/2010): Temporary debugging...
  100735             :        //   ROSE_ASSERT(false);
  100736             :         }
  100737             : 
  100738           5 :      return ;
  100739             :    }
  100740             : 
  100741             : //############################################################################
  100742             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  100743             :  * within the memory pool and resets the freepointers, in order to achieve a 
  100744             :  * linked list, that has no jumps and starts at the beginning! This function 
  100745             :  * does not extend the memory pool, since we do not delete any memory blocks,
  100746             :  * but delete the valid objects.  
  100747             :  */
  100748             : void
  100749           0 : SgDeadIfDirectiveStatement::clearMemoryPool( )
  100750             :    {
  100751             :   // printf ("Inside of SgDeadIfDirectiveStatement::clearMemoryPool() \n");
  100752             : 
  100753           0 :      SgDeadIfDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  100754           0 :      std::vector < unsigned char* > :: const_iterator block;
  100755           0 :      if ( SgDeadIfDirectiveStatement::pools.empty() == false )
  100756             :         {
  100757           0 :           block = SgDeadIfDirectiveStatement::pools.begin() ;
  100758           0 :           SgDeadIfDirectiveStatement::next_node = (SgDeadIfDirectiveStatement*) (*block);
  100759             : 
  100760           0 :           while ( block != SgDeadIfDirectiveStatement::pools.end() )
  100761             :              {
  100762           0 :                pointer = (SgDeadIfDirectiveStatement*) (*block);
  100763           0 :                if ( tempPointer != NULL )
  100764             :                   {
  100765           0 :                     tempPointer->set_freepointer(pointer);
  100766             :                   }
  100767           0 :                for (unsigned i = 0; i < SgDeadIfDirectiveStatement::pool_size - 1; ++i)
  100768             :                   {
  100769           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  100770             :                   }
  100771           0 :                 pointer[SgDeadIfDirectiveStatement::pool_size-1].set_freepointer(NULL);
  100772           0 :                 tempPointer = &(pointer[SgDeadIfDirectiveStatement::pool_size-1]);
  100773           0 :                 ++block;
  100774             :              }
  100775             :         }
  100776           0 :    }
  100777             : 
  100778           5 : void SgDeadIfDirectiveStatement::deleteMemoryPool() {
  100779           5 :   for (auto p: SgDeadIfDirectiveStatement::pools) {
  100780           0 :     ROSE_FREE(p);
  100781             :   }
  100782           5 :   SgDeadIfDirectiveStatement::next_node = nullptr;
  100783           5 :   SgDeadIfDirectiveStatement::pools.clear();
  100784           5 : }
  100785             : 
  100786             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  100787             : //                 reading multiple binary files to for a single AST.
  100788             : /////////// new version ////////////////////////////////
  100789             : //############################################################################
  100790             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  100791             : void
  100792           2 : SgDeadIfDirectiveStatement::extendMemoryPoolForFileIO( )
  100793             :   {
  100794           2 :     size_t blockIndex = SgDeadIfDirectiveStatement::pools.size();
  100795           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDeadIfDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeadIfDirectiveStatement);
  100796             : 
  100797           2 :     while ( (blockIndex * SgDeadIfDirectiveStatement::pool_size) < newPoolSize)
  100798             :       {
  100799             : #if ROSE_ALLOC_TRACE
  100800             :         if (blockIndex > 0) {
  100801             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDeadIfDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeadIfDirectiveStatement) = %" PRIuPTR " SgDeadIfDirectiveStatement::pool_size = %d \n",
  100802             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDeadIfDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeadIfDirectiveStatement),SgDeadIfDirectiveStatement::pool_size);
  100803             :         }
  100804             : #endif
  100805             : 
  100806           0 :         SgDeadIfDirectiveStatement * pointer = (SgDeadIfDirectiveStatement*) ROSE_MALLOC ( SgDeadIfDirectiveStatement::pool_size * sizeof(SgDeadIfDirectiveStatement) );
  100807           0 :         assert( pointer != NULL );
  100808             : #if ROSE_ALLOC_MEMSET == 1
  100809             :         memset(pointer, 0x00, SgDeadIfDirectiveStatement::pool_size * sizeof(SgDeadIfDirectiveStatement));
  100810             : #elif ROSE_ALLOC_MEMSET == 2
  100811             :         memset(pointer, 0xCC, SgDeadIfDirectiveStatement::pool_size * sizeof(SgDeadIfDirectiveStatement));
  100812             : #endif
  100813           0 :         SgDeadIfDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  100814           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDeadIfDirectiveStatement::pool_size * sizeof(SgDeadIfDirectiveStatement), V_SgDeadIfDirectiveStatement ) );
  100815             : 
  100816           0 :         if ( SgDeadIfDirectiveStatement::next_node != NULL ) {
  100817           0 :           if ( blockIndex > 0 ) {
  100818           0 :             SgDeadIfDirectiveStatement * blkptr = (SgDeadIfDirectiveStatement*)(SgDeadIfDirectiveStatement::pools[blockIndex-1]);
  100819           0 :             blkptr[ SgDeadIfDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  100820             :           }
  100821             :         } else {
  100822           0 :           SgDeadIfDirectiveStatement::next_node = pointer;
  100823             :         }
  100824             : 
  100825           0 :         for (unsigned i = 0; i < SgDeadIfDirectiveStatement::pool_size-1; ++i)
  100826             :            {
  100827           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  100828             :            }
  100829           0 :         pointer[ SgDeadIfDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  100830             : 
  100831           0 :         blockIndex++;
  100832             :       }
  100833           2 :   }
  100834             : 
  100835             : //############################################################################
  100836             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  100837             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  100838             :  * not compressed. However, that stuff is not yet implemented! 
  100839             :  */
  100840             : unsigned long
  100841           0 : SgDeadIfDirectiveStatement::getNumberOfLastValidPointer()
  100842             :    {
  100843           0 :       SgDeadIfDirectiveStatement* testPointer = (SgDeadIfDirectiveStatement*)(SgDeadIfDirectiveStatement::pools.back());
  100844           0 :       unsigned long localIndex = SgDeadIfDirectiveStatement::pool_size - 1;
  100845           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  100846             :          {
  100847           0 :            localIndex--;
  100848             :          }
  100849           0 :       return (localIndex + SgDeadIfDirectiveStatement::pool_size * (SgDeadIfDirectiveStatement::pools.size()-1));
  100850             :    }
  100851             : 
  100852             : //############################################################################
  100853             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  100854             :  * memory pool and initializes the data member in class SgDeadIfDirectiveStatementStroageClass
  100855             :  * from its counterpart of SgDeadIfDirectiveStatement. The return value is just for checking, 
  100856             :  * that the whole StorageClassArray is initialized!
  100857             :  */
  100858             : unsigned long
  100859           0 : SgDeadIfDirectiveStatement::initializeStorageClassArray( SgDeadIfDirectiveStatementStorageClass *storageArray )
  100860             :    {
  100861           0 :      unsigned long storageCounter = 0;
  100862           0 :      std::vector < unsigned char* > :: const_iterator block = SgDeadIfDirectiveStatement::pools.begin();
  100863           0 :      SgDeadIfDirectiveStatement* pointer = NULL;
  100864           0 :      while ( block != SgDeadIfDirectiveStatement::pools.end() ) {
  100865           0 :           pointer = (SgDeadIfDirectiveStatement*) (*block);
  100866           0 :           for ( unsigned i = 0; i < SgDeadIfDirectiveStatement::pool_size; ++i ) {
  100867           0 :                if ( pointer->get_freepointer() != NULL ) {
  100868           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  100869           0 :                  storageArray++;
  100870           0 :                  storageCounter++;
  100871             :                }
  100872           0 :                pointer++;
  100873             :              }
  100874           0 :            block++;
  100875             :         }
  100876           0 :      return storageCounter;
  100877             :    }
  100878             : 
  100879             : /* #line 100880 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  100880             : 
  100881             : 
  100882             : 
  100883             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  100884             : 
  100885             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  100886             : 
  100887             : //############################################################################
  100888             : /* JH (02/02/2006) Constructor of the IR node SgElseDirectiveStatement that takes its 
  100889             :  * corresponding StorageClass as parameter
  100890             :  */
  100891           0 : SgElseDirectiveStatement :: SgElseDirectiveStatement ( const SgElseDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  100892             :    {
  100893             : 
  100894             : 
  100895             : /* #line 100896 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  100896             : 
  100897           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  100898             : 
  100899             : 
  100900             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  100901             : 
  100902             : 
  100903           0 :    }
  100904             : 
  100905             : //############################################################################
  100906             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  100907             :  * within the working AST. 
  100908             :  */
  100909           0 : SgElseDirectiveStatement * SgElseDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  100910           0 :      SgElseDirectiveStatement* returnPointer = NULL;
  100911           0 :      if ( globalIndex != 0 )
  100912             :         {
  100913             : 
  100914             : #if FILE_IO_EXTRA_CHECK
  100915           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElseDirectiveStatement ) ) <= globalIndex ) ;
  100916           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElseDirectiveStatement + 1 ) ) );
  100917             : #endif
  100918           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElseDirectiveStatement )  
  100919           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElseDirectiveStatement );
  100920           0 :           unsigned long positionInPool = localIndex % SgElseDirectiveStatement::pool_size;
  100921           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElseDirectiveStatement::pool_size;
  100922             : 
  100923             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  100924             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  100925             : 
  100926           0 :           returnPointer = &( ( (SgElseDirectiveStatement*)(SgElseDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  100927             : 
  100928           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  100929             :         }
  100930           0 :      return returnPointer ;
  100931             :    }
  100932             : 
  100933             : //############################################################################
  100934             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  100935             :   for the AST with the index astIndex
  100936             : */
  100937           0 : SgElseDirectiveStatement * SgElseDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  100938           0 :      SgElseDirectiveStatement* returnPointer = NULL;
  100939           0 :      if ( globalIndex != 0 )
  100940             :         {
  100941             : 
  100942             : #if FILE_IO_EXTRA_CHECK
  100943           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElseDirectiveStatement ) ) <= globalIndex ) ;
  100944           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElseDirectiveStatement + 1 ) ) );
  100945             : #endif
  100946           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElseDirectiveStatement )
  100947           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElseDirectiveStatement );
  100948           0 :           unsigned long positionInPool = localIndex % SgElseDirectiveStatement::pool_size ;
  100949           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElseDirectiveStatement::pool_size ;
  100950             : 
  100951             : #if FILE_IO_EXTRA_CHECK
  100952             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  100953             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  100954             : #endif
  100955             : 
  100956           0 :           returnPointer = &( ( (SgElseDirectiveStatement*)(SgElseDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  100957             : 
  100958             : #if FILE_IO_EXTRA_CHECK
  100959           0 :           assert ( returnPointer != NULL ) ;
  100960             : #endif
  100961             :         }
  100962           0 :      return returnPointer ;
  100963             :    }
  100964             : 
  100965             : //############################################################################
  100966             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  100967             :  * pool size! We set for every valid object in the memory pool the freepointer
  100968             :  * to the global index and increase the global index afterwards. For all the 
  100969             :  * invalid objects (means address ranges within the memory pool that were not
  100970             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  100971             :  * distinguish valid from invalid objects! 
  100972             :  */
  100973             : unsigned long
  100974           5 : SgElseDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  100975             :    {
  100976           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  100977           5 :      SgElseDirectiveStatement* pointer = NULL;
  100978           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  100979           5 :      std::vector < unsigned char* > :: const_iterator block;
  100980           5 :      for ( block = SgElseDirectiveStatement::pools.begin(); block != SgElseDirectiveStatement::pools.end() ; ++block )
  100981             :         {
  100982           0 :           pointer = (SgElseDirectiveStatement*)(*block);
  100983           0 :           for (unsigned i = 0; i < SgElseDirectiveStatement::pool_size; ++i )
  100984             :              {
  100985             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  100986             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  100987             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  100988             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  100989             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  100990             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  100991             :             // properly; so this will have to be checked next.
  100992             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  100993             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  100994           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  100995             :                   {
  100996           0 :                     pointer[i].set_freepointer((SgElseDirectiveStatement*)(globalIndex));
  100997           0 :                     globalIndex++;
  100998             :                   }
  100999             :                else
  101000             :                   {
  101001           0 :                     pointer[i].set_freepointer(NULL);
  101002             :                   }
  101003             :               }
  101004             :         }
  101005           5 :      return globalIndex;
  101006             :    }
  101007             : 
  101008             : //############################################################################
  101009             : // JH (01/14/2006)
  101010             : void
  101011           5 : SgElseDirectiveStatement::resetValidFreepointers( )
  101012             :    {
  101013           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  101014           5 :      SgElseDirectiveStatement* pointer = NULL;
  101015           5 :      std::vector < unsigned char* > :: const_iterator block;
  101016           5 :      SgElseDirectiveStatement* pointerOfLinkedList = NULL;
  101017           5 :      for ( block = SgElseDirectiveStatement::pools.begin(); block != SgElseDirectiveStatement::pools.end() ; ++block )
  101018             :         {
  101019           0 :           pointer = (SgElseDirectiveStatement*)(*block);
  101020           0 :           for (unsigned i = 0; i < SgElseDirectiveStatement::pool_size; ++i )
  101021             :              {
  101022             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  101023             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  101024             :             // memory blocks!.
  101025           0 :                if ( pointer[i].get_freepointer() != NULL )
  101026             :                   {
  101027           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  101028             :                   }
  101029             :                else
  101030             :                   {
  101031           0 :                     if ( pointerOfLinkedList == NULL )
  101032             :                        {
  101033           0 :                          SgElseDirectiveStatement::next_node = &(pointer[i]);
  101034             :                        }
  101035             :                     else
  101036             :                        {
  101037             :                       // printf ("In SgElseDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  101038           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  101039             :                        }
  101040             :                     pointerOfLinkedList = &(pointer[i]);
  101041             :                   }
  101042             :               }
  101043             :         }
  101044             : 
  101045           5 :      if ( pointerOfLinkedList != NULL )
  101046             :         {
  101047             :        // printf ("In SgElseDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  101048           0 :           pointerOfLinkedList->set_freepointer(NULL);
  101049             :        // DQ (6/6/2010): Temporary debugging...
  101050             :        //   ROSE_ASSERT(false);
  101051             :         }
  101052             : 
  101053           5 :      return ;
  101054             :    }
  101055             : 
  101056             : //############################################################################
  101057             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  101058             :  * within the memory pool and resets the freepointers, in order to achieve a 
  101059             :  * linked list, that has no jumps and starts at the beginning! This function 
  101060             :  * does not extend the memory pool, since we do not delete any memory blocks,
  101061             :  * but delete the valid objects.  
  101062             :  */
  101063             : void
  101064           0 : SgElseDirectiveStatement::clearMemoryPool( )
  101065             :    {
  101066             :   // printf ("Inside of SgElseDirectiveStatement::clearMemoryPool() \n");
  101067             : 
  101068           0 :      SgElseDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  101069           0 :      std::vector < unsigned char* > :: const_iterator block;
  101070           0 :      if ( SgElseDirectiveStatement::pools.empty() == false )
  101071             :         {
  101072           0 :           block = SgElseDirectiveStatement::pools.begin() ;
  101073           0 :           SgElseDirectiveStatement::next_node = (SgElseDirectiveStatement*) (*block);
  101074             : 
  101075           0 :           while ( block != SgElseDirectiveStatement::pools.end() )
  101076             :              {
  101077           0 :                pointer = (SgElseDirectiveStatement*) (*block);
  101078           0 :                if ( tempPointer != NULL )
  101079             :                   {
  101080           0 :                     tempPointer->set_freepointer(pointer);
  101081             :                   }
  101082           0 :                for (unsigned i = 0; i < SgElseDirectiveStatement::pool_size - 1; ++i)
  101083             :                   {
  101084           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  101085             :                   }
  101086           0 :                 pointer[SgElseDirectiveStatement::pool_size-1].set_freepointer(NULL);
  101087           0 :                 tempPointer = &(pointer[SgElseDirectiveStatement::pool_size-1]);
  101088           0 :                 ++block;
  101089             :              }
  101090             :         }
  101091           0 :    }
  101092             : 
  101093           5 : void SgElseDirectiveStatement::deleteMemoryPool() {
  101094           5 :   for (auto p: SgElseDirectiveStatement::pools) {
  101095           0 :     ROSE_FREE(p);
  101096             :   }
  101097           5 :   SgElseDirectiveStatement::next_node = nullptr;
  101098           5 :   SgElseDirectiveStatement::pools.clear();
  101099           5 : }
  101100             : 
  101101             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  101102             : //                 reading multiple binary files to for a single AST.
  101103             : /////////// new version ////////////////////////////////
  101104             : //############################################################################
  101105             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  101106             : void
  101107           2 : SgElseDirectiveStatement::extendMemoryPoolForFileIO( )
  101108             :   {
  101109           2 :     size_t blockIndex = SgElseDirectiveStatement::pools.size();
  101110           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElseDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseDirectiveStatement);
  101111             : 
  101112           2 :     while ( (blockIndex * SgElseDirectiveStatement::pool_size) < newPoolSize)
  101113             :       {
  101114             : #if ROSE_ALLOC_TRACE
  101115             :         if (blockIndex > 0) {
  101116             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElseDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseDirectiveStatement) = %" PRIuPTR " SgElseDirectiveStatement::pool_size = %d \n",
  101117             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElseDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseDirectiveStatement),SgElseDirectiveStatement::pool_size);
  101118             :         }
  101119             : #endif
  101120             : 
  101121           0 :         SgElseDirectiveStatement * pointer = (SgElseDirectiveStatement*) ROSE_MALLOC ( SgElseDirectiveStatement::pool_size * sizeof(SgElseDirectiveStatement) );
  101122           0 :         assert( pointer != NULL );
  101123             : #if ROSE_ALLOC_MEMSET == 1
  101124             :         memset(pointer, 0x00, SgElseDirectiveStatement::pool_size * sizeof(SgElseDirectiveStatement));
  101125             : #elif ROSE_ALLOC_MEMSET == 2
  101126             :         memset(pointer, 0xCC, SgElseDirectiveStatement::pool_size * sizeof(SgElseDirectiveStatement));
  101127             : #endif
  101128           0 :         SgElseDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  101129           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElseDirectiveStatement::pool_size * sizeof(SgElseDirectiveStatement), V_SgElseDirectiveStatement ) );
  101130             : 
  101131           0 :         if ( SgElseDirectiveStatement::next_node != NULL ) {
  101132           0 :           if ( blockIndex > 0 ) {
  101133           0 :             SgElseDirectiveStatement * blkptr = (SgElseDirectiveStatement*)(SgElseDirectiveStatement::pools[blockIndex-1]);
  101134           0 :             blkptr[ SgElseDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  101135             :           }
  101136             :         } else {
  101137           0 :           SgElseDirectiveStatement::next_node = pointer;
  101138             :         }
  101139             : 
  101140           0 :         for (unsigned i = 0; i < SgElseDirectiveStatement::pool_size-1; ++i)
  101141             :            {
  101142           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  101143             :            }
  101144           0 :         pointer[ SgElseDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  101145             : 
  101146           0 :         blockIndex++;
  101147             :       }
  101148           2 :   }
  101149             : 
  101150             : //############################################################################
  101151             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  101152             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  101153             :  * not compressed. However, that stuff is not yet implemented! 
  101154             :  */
  101155             : unsigned long
  101156           0 : SgElseDirectiveStatement::getNumberOfLastValidPointer()
  101157             :    {
  101158           0 :       SgElseDirectiveStatement* testPointer = (SgElseDirectiveStatement*)(SgElseDirectiveStatement::pools.back());
  101159           0 :       unsigned long localIndex = SgElseDirectiveStatement::pool_size - 1;
  101160           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  101161             :          {
  101162           0 :            localIndex--;
  101163             :          }
  101164           0 :       return (localIndex + SgElseDirectiveStatement::pool_size * (SgElseDirectiveStatement::pools.size()-1));
  101165             :    }
  101166             : 
  101167             : //############################################################################
  101168             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  101169             :  * memory pool and initializes the data member in class SgElseDirectiveStatementStroageClass
  101170             :  * from its counterpart of SgElseDirectiveStatement. The return value is just for checking, 
  101171             :  * that the whole StorageClassArray is initialized!
  101172             :  */
  101173             : unsigned long
  101174           0 : SgElseDirectiveStatement::initializeStorageClassArray( SgElseDirectiveStatementStorageClass *storageArray )
  101175             :    {
  101176           0 :      unsigned long storageCounter = 0;
  101177           0 :      std::vector < unsigned char* > :: const_iterator block = SgElseDirectiveStatement::pools.begin();
  101178           0 :      SgElseDirectiveStatement* pointer = NULL;
  101179           0 :      while ( block != SgElseDirectiveStatement::pools.end() ) {
  101180           0 :           pointer = (SgElseDirectiveStatement*) (*block);
  101181           0 :           for ( unsigned i = 0; i < SgElseDirectiveStatement::pool_size; ++i ) {
  101182           0 :                if ( pointer->get_freepointer() != NULL ) {
  101183           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  101184           0 :                  storageArray++;
  101185           0 :                  storageCounter++;
  101186             :                }
  101187           0 :                pointer++;
  101188             :              }
  101189           0 :            block++;
  101190             :         }
  101191           0 :      return storageCounter;
  101192             :    }
  101193             : 
  101194             : /* #line 101195 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  101195             : 
  101196             : 
  101197             : 
  101198             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  101199             : 
  101200             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  101201             : 
  101202             : //############################################################################
  101203             : /* JH (02/02/2006) Constructor of the IR node SgElseifDirectiveStatement that takes its 
  101204             :  * corresponding StorageClass as parameter
  101205             :  */
  101206           0 : SgElseifDirectiveStatement :: SgElseifDirectiveStatement ( const SgElseifDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  101207             :    {
  101208             : 
  101209             : 
  101210             : /* #line 101211 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  101211             : 
  101212           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  101213             : 
  101214             : 
  101215             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  101216             : 
  101217             : 
  101218           0 :    }
  101219             : 
  101220             : //############################################################################
  101221             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  101222             :  * within the working AST. 
  101223             :  */
  101224           0 : SgElseifDirectiveStatement * SgElseifDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  101225           0 :      SgElseifDirectiveStatement* returnPointer = NULL;
  101226           0 :      if ( globalIndex != 0 )
  101227             :         {
  101228             : 
  101229             : #if FILE_IO_EXTRA_CHECK
  101230           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElseifDirectiveStatement ) ) <= globalIndex ) ;
  101231           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElseifDirectiveStatement + 1 ) ) );
  101232             : #endif
  101233           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElseifDirectiveStatement )  
  101234           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElseifDirectiveStatement );
  101235           0 :           unsigned long positionInPool = localIndex % SgElseifDirectiveStatement::pool_size;
  101236           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElseifDirectiveStatement::pool_size;
  101237             : 
  101238             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  101239             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  101240             : 
  101241           0 :           returnPointer = &( ( (SgElseifDirectiveStatement*)(SgElseifDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  101242             : 
  101243           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  101244             :         }
  101245           0 :      return returnPointer ;
  101246             :    }
  101247             : 
  101248             : //############################################################################
  101249             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  101250             :   for the AST with the index astIndex
  101251             : */
  101252           0 : SgElseifDirectiveStatement * SgElseifDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  101253           0 :      SgElseifDirectiveStatement* returnPointer = NULL;
  101254           0 :      if ( globalIndex != 0 )
  101255             :         {
  101256             : 
  101257             : #if FILE_IO_EXTRA_CHECK
  101258           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElseifDirectiveStatement ) ) <= globalIndex ) ;
  101259           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElseifDirectiveStatement + 1 ) ) );
  101260             : #endif
  101261           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElseifDirectiveStatement )
  101262           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElseifDirectiveStatement );
  101263           0 :           unsigned long positionInPool = localIndex % SgElseifDirectiveStatement::pool_size ;
  101264           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElseifDirectiveStatement::pool_size ;
  101265             : 
  101266             : #if FILE_IO_EXTRA_CHECK
  101267             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  101268             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  101269             : #endif
  101270             : 
  101271           0 :           returnPointer = &( ( (SgElseifDirectiveStatement*)(SgElseifDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  101272             : 
  101273             : #if FILE_IO_EXTRA_CHECK
  101274           0 :           assert ( returnPointer != NULL ) ;
  101275             : #endif
  101276             :         }
  101277           0 :      return returnPointer ;
  101278             :    }
  101279             : 
  101280             : //############################################################################
  101281             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  101282             :  * pool size! We set for every valid object in the memory pool the freepointer
  101283             :  * to the global index and increase the global index afterwards. For all the 
  101284             :  * invalid objects (means address ranges within the memory pool that were not
  101285             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  101286             :  * distinguish valid from invalid objects! 
  101287             :  */
  101288             : unsigned long
  101289           5 : SgElseifDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  101290             :    {
  101291           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  101292           5 :      SgElseifDirectiveStatement* pointer = NULL;
  101293           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  101294           5 :      std::vector < unsigned char* > :: const_iterator block;
  101295           5 :      for ( block = SgElseifDirectiveStatement::pools.begin(); block != SgElseifDirectiveStatement::pools.end() ; ++block )
  101296             :         {
  101297           0 :           pointer = (SgElseifDirectiveStatement*)(*block);
  101298           0 :           for (unsigned i = 0; i < SgElseifDirectiveStatement::pool_size; ++i )
  101299             :              {
  101300             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  101301             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  101302             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  101303             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  101304             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  101305             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  101306             :             // properly; so this will have to be checked next.
  101307             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  101308             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  101309           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  101310             :                   {
  101311           0 :                     pointer[i].set_freepointer((SgElseifDirectiveStatement*)(globalIndex));
  101312           0 :                     globalIndex++;
  101313             :                   }
  101314             :                else
  101315             :                   {
  101316           0 :                     pointer[i].set_freepointer(NULL);
  101317             :                   }
  101318             :               }
  101319             :         }
  101320           5 :      return globalIndex;
  101321             :    }
  101322             : 
  101323             : //############################################################################
  101324             : // JH (01/14/2006)
  101325             : void
  101326           5 : SgElseifDirectiveStatement::resetValidFreepointers( )
  101327             :    {
  101328           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  101329           5 :      SgElseifDirectiveStatement* pointer = NULL;
  101330           5 :      std::vector < unsigned char* > :: const_iterator block;
  101331           5 :      SgElseifDirectiveStatement* pointerOfLinkedList = NULL;
  101332           5 :      for ( block = SgElseifDirectiveStatement::pools.begin(); block != SgElseifDirectiveStatement::pools.end() ; ++block )
  101333             :         {
  101334           0 :           pointer = (SgElseifDirectiveStatement*)(*block);
  101335           0 :           for (unsigned i = 0; i < SgElseifDirectiveStatement::pool_size; ++i )
  101336             :              {
  101337             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  101338             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  101339             :             // memory blocks!.
  101340           0 :                if ( pointer[i].get_freepointer() != NULL )
  101341             :                   {
  101342           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  101343             :                   }
  101344             :                else
  101345             :                   {
  101346           0 :                     if ( pointerOfLinkedList == NULL )
  101347             :                        {
  101348           0 :                          SgElseifDirectiveStatement::next_node = &(pointer[i]);
  101349             :                        }
  101350             :                     else
  101351             :                        {
  101352             :                       // printf ("In SgElseifDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  101353           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  101354             :                        }
  101355             :                     pointerOfLinkedList = &(pointer[i]);
  101356             :                   }
  101357             :               }
  101358             :         }
  101359             : 
  101360           5 :      if ( pointerOfLinkedList != NULL )
  101361             :         {
  101362             :        // printf ("In SgElseifDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  101363           0 :           pointerOfLinkedList->set_freepointer(NULL);
  101364             :        // DQ (6/6/2010): Temporary debugging...
  101365             :        //   ROSE_ASSERT(false);
  101366             :         }
  101367             : 
  101368           5 :      return ;
  101369             :    }
  101370             : 
  101371             : //############################################################################
  101372             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  101373             :  * within the memory pool and resets the freepointers, in order to achieve a 
  101374             :  * linked list, that has no jumps and starts at the beginning! This function 
  101375             :  * does not extend the memory pool, since we do not delete any memory blocks,
  101376             :  * but delete the valid objects.  
  101377             :  */
  101378             : void
  101379           0 : SgElseifDirectiveStatement::clearMemoryPool( )
  101380             :    {
  101381             :   // printf ("Inside of SgElseifDirectiveStatement::clearMemoryPool() \n");
  101382             : 
  101383           0 :      SgElseifDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  101384           0 :      std::vector < unsigned char* > :: const_iterator block;
  101385           0 :      if ( SgElseifDirectiveStatement::pools.empty() == false )
  101386             :         {
  101387           0 :           block = SgElseifDirectiveStatement::pools.begin() ;
  101388           0 :           SgElseifDirectiveStatement::next_node = (SgElseifDirectiveStatement*) (*block);
  101389             : 
  101390           0 :           while ( block != SgElseifDirectiveStatement::pools.end() )
  101391             :              {
  101392           0 :                pointer = (SgElseifDirectiveStatement*) (*block);
  101393           0 :                if ( tempPointer != NULL )
  101394             :                   {
  101395           0 :                     tempPointer->set_freepointer(pointer);
  101396             :                   }
  101397           0 :                for (unsigned i = 0; i < SgElseifDirectiveStatement::pool_size - 1; ++i)
  101398             :                   {
  101399           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  101400             :                   }
  101401           0 :                 pointer[SgElseifDirectiveStatement::pool_size-1].set_freepointer(NULL);
  101402           0 :                 tempPointer = &(pointer[SgElseifDirectiveStatement::pool_size-1]);
  101403           0 :                 ++block;
  101404             :              }
  101405             :         }
  101406           0 :    }
  101407             : 
  101408           5 : void SgElseifDirectiveStatement::deleteMemoryPool() {
  101409           5 :   for (auto p: SgElseifDirectiveStatement::pools) {
  101410           0 :     ROSE_FREE(p);
  101411             :   }
  101412           5 :   SgElseifDirectiveStatement::next_node = nullptr;
  101413           5 :   SgElseifDirectiveStatement::pools.clear();
  101414           5 : }
  101415             : 
  101416             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  101417             : //                 reading multiple binary files to for a single AST.
  101418             : /////////// new version ////////////////////////////////
  101419             : //############################################################################
  101420             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  101421             : void
  101422           2 : SgElseifDirectiveStatement::extendMemoryPoolForFileIO( )
  101423             :   {
  101424           2 :     size_t blockIndex = SgElseifDirectiveStatement::pools.size();
  101425           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElseifDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseifDirectiveStatement);
  101426             : 
  101427           2 :     while ( (blockIndex * SgElseifDirectiveStatement::pool_size) < newPoolSize)
  101428             :       {
  101429             : #if ROSE_ALLOC_TRACE
  101430             :         if (blockIndex > 0) {
  101431             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElseifDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseifDirectiveStatement) = %" PRIuPTR " SgElseifDirectiveStatement::pool_size = %d \n",
  101432             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElseifDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseifDirectiveStatement),SgElseifDirectiveStatement::pool_size);
  101433             :         }
  101434             : #endif
  101435             : 
  101436           0 :         SgElseifDirectiveStatement * pointer = (SgElseifDirectiveStatement*) ROSE_MALLOC ( SgElseifDirectiveStatement::pool_size * sizeof(SgElseifDirectiveStatement) );
  101437           0 :         assert( pointer != NULL );
  101438             : #if ROSE_ALLOC_MEMSET == 1
  101439             :         memset(pointer, 0x00, SgElseifDirectiveStatement::pool_size * sizeof(SgElseifDirectiveStatement));
  101440             : #elif ROSE_ALLOC_MEMSET == 2
  101441             :         memset(pointer, 0xCC, SgElseifDirectiveStatement::pool_size * sizeof(SgElseifDirectiveStatement));
  101442             : #endif
  101443           0 :         SgElseifDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  101444           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElseifDirectiveStatement::pool_size * sizeof(SgElseifDirectiveStatement), V_SgElseifDirectiveStatement ) );
  101445             : 
  101446           0 :         if ( SgElseifDirectiveStatement::next_node != NULL ) {
  101447           0 :           if ( blockIndex > 0 ) {
  101448           0 :             SgElseifDirectiveStatement * blkptr = (SgElseifDirectiveStatement*)(SgElseifDirectiveStatement::pools[blockIndex-1]);
  101449           0 :             blkptr[ SgElseifDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  101450             :           }
  101451             :         } else {
  101452           0 :           SgElseifDirectiveStatement::next_node = pointer;
  101453             :         }
  101454             : 
  101455           0 :         for (unsigned i = 0; i < SgElseifDirectiveStatement::pool_size-1; ++i)
  101456             :            {
  101457           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  101458             :            }
  101459           0 :         pointer[ SgElseifDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  101460             : 
  101461           0 :         blockIndex++;
  101462             :       }
  101463           2 :   }
  101464             : 
  101465             : //############################################################################
  101466             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  101467             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  101468             :  * not compressed. However, that stuff is not yet implemented! 
  101469             :  */
  101470             : unsigned long
  101471           0 : SgElseifDirectiveStatement::getNumberOfLastValidPointer()
  101472             :    {
  101473           0 :       SgElseifDirectiveStatement* testPointer = (SgElseifDirectiveStatement*)(SgElseifDirectiveStatement::pools.back());
  101474           0 :       unsigned long localIndex = SgElseifDirectiveStatement::pool_size - 1;
  101475           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  101476             :          {
  101477           0 :            localIndex--;
  101478             :          }
  101479           0 :       return (localIndex + SgElseifDirectiveStatement::pool_size * (SgElseifDirectiveStatement::pools.size()-1));
  101480             :    }
  101481             : 
  101482             : //############################################################################
  101483             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  101484             :  * memory pool and initializes the data member in class SgElseifDirectiveStatementStroageClass
  101485             :  * from its counterpart of SgElseifDirectiveStatement. The return value is just for checking, 
  101486             :  * that the whole StorageClassArray is initialized!
  101487             :  */
  101488             : unsigned long
  101489           0 : SgElseifDirectiveStatement::initializeStorageClassArray( SgElseifDirectiveStatementStorageClass *storageArray )
  101490             :    {
  101491           0 :      unsigned long storageCounter = 0;
  101492           0 :      std::vector < unsigned char* > :: const_iterator block = SgElseifDirectiveStatement::pools.begin();
  101493           0 :      SgElseifDirectiveStatement* pointer = NULL;
  101494           0 :      while ( block != SgElseifDirectiveStatement::pools.end() ) {
  101495           0 :           pointer = (SgElseifDirectiveStatement*) (*block);
  101496           0 :           for ( unsigned i = 0; i < SgElseifDirectiveStatement::pool_size; ++i ) {
  101497           0 :                if ( pointer->get_freepointer() != NULL ) {
  101498           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  101499           0 :                  storageArray++;
  101500           0 :                  storageCounter++;
  101501             :                }
  101502           0 :                pointer++;
  101503             :              }
  101504           0 :            block++;
  101505             :         }
  101506           0 :      return storageCounter;
  101507             :    }
  101508             : 
  101509             : /* #line 101510 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  101510             : 
  101511             : 
  101512             : 
  101513             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  101514             : 
  101515             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  101516             : 
  101517             : //############################################################################
  101518             : /* JH (02/02/2006) Constructor of the IR node SgEndifDirectiveStatement that takes its 
  101519             :  * corresponding StorageClass as parameter
  101520             :  */
  101521           0 : SgEndifDirectiveStatement :: SgEndifDirectiveStatement ( const SgEndifDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  101522             :    {
  101523             : 
  101524             : 
  101525             : /* #line 101526 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  101526             : 
  101527           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  101528             : 
  101529             : 
  101530             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  101531             : 
  101532             : 
  101533           0 :    }
  101534             : 
  101535             : //############################################################################
  101536             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  101537             :  * within the working AST. 
  101538             :  */
  101539           0 : SgEndifDirectiveStatement * SgEndifDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  101540           0 :      SgEndifDirectiveStatement* returnPointer = NULL;
  101541           0 :      if ( globalIndex != 0 )
  101542             :         {
  101543             : 
  101544             : #if FILE_IO_EXTRA_CHECK
  101545           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEndifDirectiveStatement ) ) <= globalIndex ) ;
  101546           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEndifDirectiveStatement + 1 ) ) );
  101547             : #endif
  101548           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEndifDirectiveStatement )  
  101549           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEndifDirectiveStatement );
  101550           0 :           unsigned long positionInPool = localIndex % SgEndifDirectiveStatement::pool_size;
  101551           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEndifDirectiveStatement::pool_size;
  101552             : 
  101553             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  101554             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  101555             : 
  101556           0 :           returnPointer = &( ( (SgEndifDirectiveStatement*)(SgEndifDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  101557             : 
  101558           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  101559             :         }
  101560           0 :      return returnPointer ;
  101561             :    }
  101562             : 
  101563             : //############################################################################
  101564             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  101565             :   for the AST with the index astIndex
  101566             : */
  101567           0 : SgEndifDirectiveStatement * SgEndifDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  101568           0 :      SgEndifDirectiveStatement* returnPointer = NULL;
  101569           0 :      if ( globalIndex != 0 )
  101570             :         {
  101571             : 
  101572             : #if FILE_IO_EXTRA_CHECK
  101573           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEndifDirectiveStatement ) ) <= globalIndex ) ;
  101574           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEndifDirectiveStatement + 1 ) ) );
  101575             : #endif
  101576           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEndifDirectiveStatement )
  101577           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEndifDirectiveStatement );
  101578           0 :           unsigned long positionInPool = localIndex % SgEndifDirectiveStatement::pool_size ;
  101579           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEndifDirectiveStatement::pool_size ;
  101580             : 
  101581             : #if FILE_IO_EXTRA_CHECK
  101582             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  101583             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  101584             : #endif
  101585             : 
  101586           0 :           returnPointer = &( ( (SgEndifDirectiveStatement*)(SgEndifDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  101587             : 
  101588             : #if FILE_IO_EXTRA_CHECK
  101589           0 :           assert ( returnPointer != NULL ) ;
  101590             : #endif
  101591             :         }
  101592           0 :      return returnPointer ;
  101593             :    }
  101594             : 
  101595             : //############################################################################
  101596             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  101597             :  * pool size! We set for every valid object in the memory pool the freepointer
  101598             :  * to the global index and increase the global index afterwards. For all the 
  101599             :  * invalid objects (means address ranges within the memory pool that were not
  101600             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  101601             :  * distinguish valid from invalid objects! 
  101602             :  */
  101603             : unsigned long
  101604           5 : SgEndifDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  101605             :    {
  101606           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  101607           5 :      SgEndifDirectiveStatement* pointer = NULL;
  101608           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  101609           5 :      std::vector < unsigned char* > :: const_iterator block;
  101610           5 :      for ( block = SgEndifDirectiveStatement::pools.begin(); block != SgEndifDirectiveStatement::pools.end() ; ++block )
  101611             :         {
  101612           0 :           pointer = (SgEndifDirectiveStatement*)(*block);
  101613           0 :           for (unsigned i = 0; i < SgEndifDirectiveStatement::pool_size; ++i )
  101614             :              {
  101615             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  101616             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  101617             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  101618             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  101619             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  101620             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  101621             :             // properly; so this will have to be checked next.
  101622             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  101623             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  101624           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  101625             :                   {
  101626           0 :                     pointer[i].set_freepointer((SgEndifDirectiveStatement*)(globalIndex));
  101627           0 :                     globalIndex++;
  101628             :                   }
  101629             :                else
  101630             :                   {
  101631           0 :                     pointer[i].set_freepointer(NULL);
  101632             :                   }
  101633             :               }
  101634             :         }
  101635           5 :      return globalIndex;
  101636             :    }
  101637             : 
  101638             : //############################################################################
  101639             : // JH (01/14/2006)
  101640             : void
  101641           5 : SgEndifDirectiveStatement::resetValidFreepointers( )
  101642             :    {
  101643           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  101644           5 :      SgEndifDirectiveStatement* pointer = NULL;
  101645           5 :      std::vector < unsigned char* > :: const_iterator block;
  101646           5 :      SgEndifDirectiveStatement* pointerOfLinkedList = NULL;
  101647           5 :      for ( block = SgEndifDirectiveStatement::pools.begin(); block != SgEndifDirectiveStatement::pools.end() ; ++block )
  101648             :         {
  101649           0 :           pointer = (SgEndifDirectiveStatement*)(*block);
  101650           0 :           for (unsigned i = 0; i < SgEndifDirectiveStatement::pool_size; ++i )
  101651             :              {
  101652             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  101653             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  101654             :             // memory blocks!.
  101655           0 :                if ( pointer[i].get_freepointer() != NULL )
  101656             :                   {
  101657           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  101658             :                   }
  101659             :                else
  101660             :                   {
  101661           0 :                     if ( pointerOfLinkedList == NULL )
  101662             :                        {
  101663           0 :                          SgEndifDirectiveStatement::next_node = &(pointer[i]);
  101664             :                        }
  101665             :                     else
  101666             :                        {
  101667             :                       // printf ("In SgEndifDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  101668           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  101669             :                        }
  101670             :                     pointerOfLinkedList = &(pointer[i]);
  101671             :                   }
  101672             :               }
  101673             :         }
  101674             : 
  101675           5 :      if ( pointerOfLinkedList != NULL )
  101676             :         {
  101677             :        // printf ("In SgEndifDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  101678           0 :           pointerOfLinkedList->set_freepointer(NULL);
  101679             :        // DQ (6/6/2010): Temporary debugging...
  101680             :        //   ROSE_ASSERT(false);
  101681             :         }
  101682             : 
  101683           5 :      return ;
  101684             :    }
  101685             : 
  101686             : //############################################################################
  101687             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  101688             :  * within the memory pool and resets the freepointers, in order to achieve a 
  101689             :  * linked list, that has no jumps and starts at the beginning! This function 
  101690             :  * does not extend the memory pool, since we do not delete any memory blocks,
  101691             :  * but delete the valid objects.  
  101692             :  */
  101693             : void
  101694           0 : SgEndifDirectiveStatement::clearMemoryPool( )
  101695             :    {
  101696             :   // printf ("Inside of SgEndifDirectiveStatement::clearMemoryPool() \n");
  101697             : 
  101698           0 :      SgEndifDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  101699           0 :      std::vector < unsigned char* > :: const_iterator block;
  101700           0 :      if ( SgEndifDirectiveStatement::pools.empty() == false )
  101701             :         {
  101702           0 :           block = SgEndifDirectiveStatement::pools.begin() ;
  101703           0 :           SgEndifDirectiveStatement::next_node = (SgEndifDirectiveStatement*) (*block);
  101704             : 
  101705           0 :           while ( block != SgEndifDirectiveStatement::pools.end() )
  101706             :              {
  101707           0 :                pointer = (SgEndifDirectiveStatement*) (*block);
  101708           0 :                if ( tempPointer != NULL )
  101709             :                   {
  101710           0 :                     tempPointer->set_freepointer(pointer);
  101711             :                   }
  101712           0 :                for (unsigned i = 0; i < SgEndifDirectiveStatement::pool_size - 1; ++i)
  101713             :                   {
  101714           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  101715             :                   }
  101716           0 :                 pointer[SgEndifDirectiveStatement::pool_size-1].set_freepointer(NULL);
  101717           0 :                 tempPointer = &(pointer[SgEndifDirectiveStatement::pool_size-1]);
  101718           0 :                 ++block;
  101719             :              }
  101720             :         }
  101721           0 :    }
  101722             : 
  101723           5 : void SgEndifDirectiveStatement::deleteMemoryPool() {
  101724           5 :   for (auto p: SgEndifDirectiveStatement::pools) {
  101725           0 :     ROSE_FREE(p);
  101726             :   }
  101727           5 :   SgEndifDirectiveStatement::next_node = nullptr;
  101728           5 :   SgEndifDirectiveStatement::pools.clear();
  101729           5 : }
  101730             : 
  101731             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  101732             : //                 reading multiple binary files to for a single AST.
  101733             : /////////// new version ////////////////////////////////
  101734             : //############################################################################
  101735             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  101736             : void
  101737           2 : SgEndifDirectiveStatement::extendMemoryPoolForFileIO( )
  101738             :   {
  101739           2 :     size_t blockIndex = SgEndifDirectiveStatement::pools.size();
  101740           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEndifDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEndifDirectiveStatement);
  101741             : 
  101742           2 :     while ( (blockIndex * SgEndifDirectiveStatement::pool_size) < newPoolSize)
  101743             :       {
  101744             : #if ROSE_ALLOC_TRACE
  101745             :         if (blockIndex > 0) {
  101746             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEndifDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEndifDirectiveStatement) = %" PRIuPTR " SgEndifDirectiveStatement::pool_size = %d \n",
  101747             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEndifDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEndifDirectiveStatement),SgEndifDirectiveStatement::pool_size);
  101748             :         }
  101749             : #endif
  101750             : 
  101751           0 :         SgEndifDirectiveStatement * pointer = (SgEndifDirectiveStatement*) ROSE_MALLOC ( SgEndifDirectiveStatement::pool_size * sizeof(SgEndifDirectiveStatement) );
  101752           0 :         assert( pointer != NULL );
  101753             : #if ROSE_ALLOC_MEMSET == 1
  101754             :         memset(pointer, 0x00, SgEndifDirectiveStatement::pool_size * sizeof(SgEndifDirectiveStatement));
  101755             : #elif ROSE_ALLOC_MEMSET == 2
  101756             :         memset(pointer, 0xCC, SgEndifDirectiveStatement::pool_size * sizeof(SgEndifDirectiveStatement));
  101757             : #endif
  101758           0 :         SgEndifDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  101759           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEndifDirectiveStatement::pool_size * sizeof(SgEndifDirectiveStatement), V_SgEndifDirectiveStatement ) );
  101760             : 
  101761           0 :         if ( SgEndifDirectiveStatement::next_node != NULL ) {
  101762           0 :           if ( blockIndex > 0 ) {
  101763           0 :             SgEndifDirectiveStatement * blkptr = (SgEndifDirectiveStatement*)(SgEndifDirectiveStatement::pools[blockIndex-1]);
  101764           0 :             blkptr[ SgEndifDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  101765             :           }
  101766             :         } else {
  101767           0 :           SgEndifDirectiveStatement::next_node = pointer;
  101768             :         }
  101769             : 
  101770           0 :         for (unsigned i = 0; i < SgEndifDirectiveStatement::pool_size-1; ++i)
  101771             :            {
  101772           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  101773             :            }
  101774           0 :         pointer[ SgEndifDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  101775             : 
  101776           0 :         blockIndex++;
  101777             :       }
  101778           2 :   }
  101779             : 
  101780             : //############################################################################
  101781             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  101782             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  101783             :  * not compressed. However, that stuff is not yet implemented! 
  101784             :  */
  101785             : unsigned long
  101786           0 : SgEndifDirectiveStatement::getNumberOfLastValidPointer()
  101787             :    {
  101788           0 :       SgEndifDirectiveStatement* testPointer = (SgEndifDirectiveStatement*)(SgEndifDirectiveStatement::pools.back());
  101789           0 :       unsigned long localIndex = SgEndifDirectiveStatement::pool_size - 1;
  101790           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  101791             :          {
  101792           0 :            localIndex--;
  101793             :          }
  101794           0 :       return (localIndex + SgEndifDirectiveStatement::pool_size * (SgEndifDirectiveStatement::pools.size()-1));
  101795             :    }
  101796             : 
  101797             : //############################################################################
  101798             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  101799             :  * memory pool and initializes the data member in class SgEndifDirectiveStatementStroageClass
  101800             :  * from its counterpart of SgEndifDirectiveStatement. The return value is just for checking, 
  101801             :  * that the whole StorageClassArray is initialized!
  101802             :  */
  101803             : unsigned long
  101804           0 : SgEndifDirectiveStatement::initializeStorageClassArray( SgEndifDirectiveStatementStorageClass *storageArray )
  101805             :    {
  101806           0 :      unsigned long storageCounter = 0;
  101807           0 :      std::vector < unsigned char* > :: const_iterator block = SgEndifDirectiveStatement::pools.begin();
  101808           0 :      SgEndifDirectiveStatement* pointer = NULL;
  101809           0 :      while ( block != SgEndifDirectiveStatement::pools.end() ) {
  101810           0 :           pointer = (SgEndifDirectiveStatement*) (*block);
  101811           0 :           for ( unsigned i = 0; i < SgEndifDirectiveStatement::pool_size; ++i ) {
  101812           0 :                if ( pointer->get_freepointer() != NULL ) {
  101813           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  101814           0 :                  storageArray++;
  101815           0 :                  storageCounter++;
  101816             :                }
  101817           0 :                pointer++;
  101818             :              }
  101819           0 :            block++;
  101820             :         }
  101821           0 :      return storageCounter;
  101822             :    }
  101823             : 
  101824             : /* #line 101825 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  101825             : 
  101826             : 
  101827             : 
  101828             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  101829             : 
  101830             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  101831             : 
  101832             : //############################################################################
  101833             : /* JH (02/02/2006) Constructor of the IR node SgLineDirectiveStatement that takes its 
  101834             :  * corresponding StorageClass as parameter
  101835             :  */
  101836           0 : SgLineDirectiveStatement :: SgLineDirectiveStatement ( const SgLineDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  101837             :    {
  101838             : 
  101839             : 
  101840             : /* #line 101841 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  101841             : 
  101842           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  101843             : 
  101844             : 
  101845             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  101846             : 
  101847             : 
  101848           0 :    }
  101849             : 
  101850             : //############################################################################
  101851             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  101852             :  * within the working AST. 
  101853             :  */
  101854           0 : SgLineDirectiveStatement * SgLineDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  101855           0 :      SgLineDirectiveStatement* returnPointer = NULL;
  101856           0 :      if ( globalIndex != 0 )
  101857             :         {
  101858             : 
  101859             : #if FILE_IO_EXTRA_CHECK
  101860           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLineDirectiveStatement ) ) <= globalIndex ) ;
  101861           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLineDirectiveStatement + 1 ) ) );
  101862             : #endif
  101863           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLineDirectiveStatement )  
  101864           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLineDirectiveStatement );
  101865           0 :           unsigned long positionInPool = localIndex % SgLineDirectiveStatement::pool_size;
  101866           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLineDirectiveStatement::pool_size;
  101867             : 
  101868             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  101869             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  101870             : 
  101871           0 :           returnPointer = &( ( (SgLineDirectiveStatement*)(SgLineDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  101872             : 
  101873           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  101874             :         }
  101875           0 :      return returnPointer ;
  101876             :    }
  101877             : 
  101878             : //############################################################################
  101879             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  101880             :   for the AST with the index astIndex
  101881             : */
  101882           0 : SgLineDirectiveStatement * SgLineDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  101883           0 :      SgLineDirectiveStatement* returnPointer = NULL;
  101884           0 :      if ( globalIndex != 0 )
  101885             :         {
  101886             : 
  101887             : #if FILE_IO_EXTRA_CHECK
  101888           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLineDirectiveStatement ) ) <= globalIndex ) ;
  101889           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLineDirectiveStatement + 1 ) ) );
  101890             : #endif
  101891           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLineDirectiveStatement )
  101892           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLineDirectiveStatement );
  101893           0 :           unsigned long positionInPool = localIndex % SgLineDirectiveStatement::pool_size ;
  101894           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLineDirectiveStatement::pool_size ;
  101895             : 
  101896             : #if FILE_IO_EXTRA_CHECK
  101897             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  101898             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  101899             : #endif
  101900             : 
  101901           0 :           returnPointer = &( ( (SgLineDirectiveStatement*)(SgLineDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  101902             : 
  101903             : #if FILE_IO_EXTRA_CHECK
  101904           0 :           assert ( returnPointer != NULL ) ;
  101905             : #endif
  101906             :         }
  101907           0 :      return returnPointer ;
  101908             :    }
  101909             : 
  101910             : //############################################################################
  101911             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  101912             :  * pool size! We set for every valid object in the memory pool the freepointer
  101913             :  * to the global index and increase the global index afterwards. For all the 
  101914             :  * invalid objects (means address ranges within the memory pool that were not
  101915             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  101916             :  * distinguish valid from invalid objects! 
  101917             :  */
  101918             : unsigned long
  101919           5 : SgLineDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  101920             :    {
  101921           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  101922           5 :      SgLineDirectiveStatement* pointer = NULL;
  101923           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  101924           5 :      std::vector < unsigned char* > :: const_iterator block;
  101925           5 :      for ( block = SgLineDirectiveStatement::pools.begin(); block != SgLineDirectiveStatement::pools.end() ; ++block )
  101926             :         {
  101927           0 :           pointer = (SgLineDirectiveStatement*)(*block);
  101928           0 :           for (unsigned i = 0; i < SgLineDirectiveStatement::pool_size; ++i )
  101929             :              {
  101930             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  101931             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  101932             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  101933             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  101934             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  101935             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  101936             :             // properly; so this will have to be checked next.
  101937             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  101938             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  101939           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  101940             :                   {
  101941           0 :                     pointer[i].set_freepointer((SgLineDirectiveStatement*)(globalIndex));
  101942           0 :                     globalIndex++;
  101943             :                   }
  101944             :                else
  101945             :                   {
  101946           0 :                     pointer[i].set_freepointer(NULL);
  101947             :                   }
  101948             :               }
  101949             :         }
  101950           5 :      return globalIndex;
  101951             :    }
  101952             : 
  101953             : //############################################################################
  101954             : // JH (01/14/2006)
  101955             : void
  101956           5 : SgLineDirectiveStatement::resetValidFreepointers( )
  101957             :    {
  101958           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  101959           5 :      SgLineDirectiveStatement* pointer = NULL;
  101960           5 :      std::vector < unsigned char* > :: const_iterator block;
  101961           5 :      SgLineDirectiveStatement* pointerOfLinkedList = NULL;
  101962           5 :      for ( block = SgLineDirectiveStatement::pools.begin(); block != SgLineDirectiveStatement::pools.end() ; ++block )
  101963             :         {
  101964           0 :           pointer = (SgLineDirectiveStatement*)(*block);
  101965           0 :           for (unsigned i = 0; i < SgLineDirectiveStatement::pool_size; ++i )
  101966             :              {
  101967             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  101968             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  101969             :             // memory blocks!.
  101970           0 :                if ( pointer[i].get_freepointer() != NULL )
  101971             :                   {
  101972           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  101973             :                   }
  101974             :                else
  101975             :                   {
  101976           0 :                     if ( pointerOfLinkedList == NULL )
  101977             :                        {
  101978           0 :                          SgLineDirectiveStatement::next_node = &(pointer[i]);
  101979             :                        }
  101980             :                     else
  101981             :                        {
  101982             :                       // printf ("In SgLineDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  101983           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  101984             :                        }
  101985             :                     pointerOfLinkedList = &(pointer[i]);
  101986             :                   }
  101987             :               }
  101988             :         }
  101989             : 
  101990           5 :      if ( pointerOfLinkedList != NULL )
  101991             :         {
  101992             :        // printf ("In SgLineDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  101993           0 :           pointerOfLinkedList->set_freepointer(NULL);
  101994             :        // DQ (6/6/2010): Temporary debugging...
  101995             :        //   ROSE_ASSERT(false);
  101996             :         }
  101997             : 
  101998           5 :      return ;
  101999             :    }
  102000             : 
  102001             : //############################################################################
  102002             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  102003             :  * within the memory pool and resets the freepointers, in order to achieve a 
  102004             :  * linked list, that has no jumps and starts at the beginning! This function 
  102005             :  * does not extend the memory pool, since we do not delete any memory blocks,
  102006             :  * but delete the valid objects.  
  102007             :  */
  102008             : void
  102009           0 : SgLineDirectiveStatement::clearMemoryPool( )
  102010             :    {
  102011             :   // printf ("Inside of SgLineDirectiveStatement::clearMemoryPool() \n");
  102012             : 
  102013           0 :      SgLineDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  102014           0 :      std::vector < unsigned char* > :: const_iterator block;
  102015           0 :      if ( SgLineDirectiveStatement::pools.empty() == false )
  102016             :         {
  102017           0 :           block = SgLineDirectiveStatement::pools.begin() ;
  102018           0 :           SgLineDirectiveStatement::next_node = (SgLineDirectiveStatement*) (*block);
  102019             : 
  102020           0 :           while ( block != SgLineDirectiveStatement::pools.end() )
  102021             :              {
  102022           0 :                pointer = (SgLineDirectiveStatement*) (*block);
  102023           0 :                if ( tempPointer != NULL )
  102024             :                   {
  102025           0 :                     tempPointer->set_freepointer(pointer);
  102026             :                   }
  102027           0 :                for (unsigned i = 0; i < SgLineDirectiveStatement::pool_size - 1; ++i)
  102028             :                   {
  102029           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  102030             :                   }
  102031           0 :                 pointer[SgLineDirectiveStatement::pool_size-1].set_freepointer(NULL);
  102032           0 :                 tempPointer = &(pointer[SgLineDirectiveStatement::pool_size-1]);
  102033           0 :                 ++block;
  102034             :              }
  102035             :         }
  102036           0 :    }
  102037             : 
  102038           5 : void SgLineDirectiveStatement::deleteMemoryPool() {
  102039           5 :   for (auto p: SgLineDirectiveStatement::pools) {
  102040           0 :     ROSE_FREE(p);
  102041             :   }
  102042           5 :   SgLineDirectiveStatement::next_node = nullptr;
  102043           5 :   SgLineDirectiveStatement::pools.clear();
  102044           5 : }
  102045             : 
  102046             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  102047             : //                 reading multiple binary files to for a single AST.
  102048             : /////////// new version ////////////////////////////////
  102049             : //############################################################################
  102050             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  102051             : void
  102052           2 : SgLineDirectiveStatement::extendMemoryPoolForFileIO( )
  102053             :   {
  102054           2 :     size_t blockIndex = SgLineDirectiveStatement::pools.size();
  102055           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLineDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLineDirectiveStatement);
  102056             : 
  102057           2 :     while ( (blockIndex * SgLineDirectiveStatement::pool_size) < newPoolSize)
  102058             :       {
  102059             : #if ROSE_ALLOC_TRACE
  102060             :         if (blockIndex > 0) {
  102061             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLineDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLineDirectiveStatement) = %" PRIuPTR " SgLineDirectiveStatement::pool_size = %d \n",
  102062             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLineDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLineDirectiveStatement),SgLineDirectiveStatement::pool_size);
  102063             :         }
  102064             : #endif
  102065             : 
  102066           0 :         SgLineDirectiveStatement * pointer = (SgLineDirectiveStatement*) ROSE_MALLOC ( SgLineDirectiveStatement::pool_size * sizeof(SgLineDirectiveStatement) );
  102067           0 :         assert( pointer != NULL );
  102068             : #if ROSE_ALLOC_MEMSET == 1
  102069             :         memset(pointer, 0x00, SgLineDirectiveStatement::pool_size * sizeof(SgLineDirectiveStatement));
  102070             : #elif ROSE_ALLOC_MEMSET == 2
  102071             :         memset(pointer, 0xCC, SgLineDirectiveStatement::pool_size * sizeof(SgLineDirectiveStatement));
  102072             : #endif
  102073           0 :         SgLineDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  102074           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLineDirectiveStatement::pool_size * sizeof(SgLineDirectiveStatement), V_SgLineDirectiveStatement ) );
  102075             : 
  102076           0 :         if ( SgLineDirectiveStatement::next_node != NULL ) {
  102077           0 :           if ( blockIndex > 0 ) {
  102078           0 :             SgLineDirectiveStatement * blkptr = (SgLineDirectiveStatement*)(SgLineDirectiveStatement::pools[blockIndex-1]);
  102079           0 :             blkptr[ SgLineDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  102080             :           }
  102081             :         } else {
  102082           0 :           SgLineDirectiveStatement::next_node = pointer;
  102083             :         }
  102084             : 
  102085           0 :         for (unsigned i = 0; i < SgLineDirectiveStatement::pool_size-1; ++i)
  102086             :            {
  102087           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  102088             :            }
  102089           0 :         pointer[ SgLineDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  102090             : 
  102091           0 :         blockIndex++;
  102092             :       }
  102093           2 :   }
  102094             : 
  102095             : //############################################################################
  102096             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  102097             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  102098             :  * not compressed. However, that stuff is not yet implemented! 
  102099             :  */
  102100             : unsigned long
  102101           0 : SgLineDirectiveStatement::getNumberOfLastValidPointer()
  102102             :    {
  102103           0 :       SgLineDirectiveStatement* testPointer = (SgLineDirectiveStatement*)(SgLineDirectiveStatement::pools.back());
  102104           0 :       unsigned long localIndex = SgLineDirectiveStatement::pool_size - 1;
  102105           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  102106             :          {
  102107           0 :            localIndex--;
  102108             :          }
  102109           0 :       return (localIndex + SgLineDirectiveStatement::pool_size * (SgLineDirectiveStatement::pools.size()-1));
  102110             :    }
  102111             : 
  102112             : //############################################################################
  102113             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  102114             :  * memory pool and initializes the data member in class SgLineDirectiveStatementStroageClass
  102115             :  * from its counterpart of SgLineDirectiveStatement. The return value is just for checking, 
  102116             :  * that the whole StorageClassArray is initialized!
  102117             :  */
  102118             : unsigned long
  102119           0 : SgLineDirectiveStatement::initializeStorageClassArray( SgLineDirectiveStatementStorageClass *storageArray )
  102120             :    {
  102121           0 :      unsigned long storageCounter = 0;
  102122           0 :      std::vector < unsigned char* > :: const_iterator block = SgLineDirectiveStatement::pools.begin();
  102123           0 :      SgLineDirectiveStatement* pointer = NULL;
  102124           0 :      while ( block != SgLineDirectiveStatement::pools.end() ) {
  102125           0 :           pointer = (SgLineDirectiveStatement*) (*block);
  102126           0 :           for ( unsigned i = 0; i < SgLineDirectiveStatement::pool_size; ++i ) {
  102127           0 :                if ( pointer->get_freepointer() != NULL ) {
  102128           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  102129           0 :                  storageArray++;
  102130           0 :                  storageCounter++;
  102131             :                }
  102132           0 :                pointer++;
  102133             :              }
  102134           0 :            block++;
  102135             :         }
  102136           0 :      return storageCounter;
  102137             :    }
  102138             : 
  102139             : /* #line 102140 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  102140             : 
  102141             : 
  102142             : 
  102143             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  102144             : 
  102145             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  102146             : 
  102147             : //############################################################################
  102148             : /* JH (02/02/2006) Constructor of the IR node SgWarningDirectiveStatement that takes its 
  102149             :  * corresponding StorageClass as parameter
  102150             :  */
  102151           0 : SgWarningDirectiveStatement :: SgWarningDirectiveStatement ( const SgWarningDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  102152             :    {
  102153             : 
  102154             : 
  102155             : /* #line 102156 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  102156             : 
  102157           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  102158             : 
  102159             : 
  102160             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  102161             : 
  102162             : 
  102163           0 :    }
  102164             : 
  102165             : //############################################################################
  102166             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  102167             :  * within the working AST. 
  102168             :  */
  102169           0 : SgWarningDirectiveStatement * SgWarningDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  102170           0 :      SgWarningDirectiveStatement* returnPointer = NULL;
  102171           0 :      if ( globalIndex != 0 )
  102172             :         {
  102173             : 
  102174             : #if FILE_IO_EXTRA_CHECK
  102175           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgWarningDirectiveStatement ) ) <= globalIndex ) ;
  102176           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWarningDirectiveStatement + 1 ) ) );
  102177             : #endif
  102178           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWarningDirectiveStatement )  
  102179           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgWarningDirectiveStatement );
  102180           0 :           unsigned long positionInPool = localIndex % SgWarningDirectiveStatement::pool_size;
  102181           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWarningDirectiveStatement::pool_size;
  102182             : 
  102183             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  102184             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  102185             : 
  102186           0 :           returnPointer = &( ( (SgWarningDirectiveStatement*)(SgWarningDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  102187             : 
  102188           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  102189             :         }
  102190           0 :      return returnPointer ;
  102191             :    }
  102192             : 
  102193             : //############################################################################
  102194             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  102195             :   for the AST with the index astIndex
  102196             : */
  102197           0 : SgWarningDirectiveStatement * SgWarningDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  102198           0 :      SgWarningDirectiveStatement* returnPointer = NULL;
  102199           0 :      if ( globalIndex != 0 )
  102200             :         {
  102201             : 
  102202             : #if FILE_IO_EXTRA_CHECK
  102203           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgWarningDirectiveStatement ) ) <= globalIndex ) ;
  102204           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWarningDirectiveStatement + 1 ) ) );
  102205             : #endif
  102206           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWarningDirectiveStatement )
  102207           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgWarningDirectiveStatement );
  102208           0 :           unsigned long positionInPool = localIndex % SgWarningDirectiveStatement::pool_size ;
  102209           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWarningDirectiveStatement::pool_size ;
  102210             : 
  102211             : #if FILE_IO_EXTRA_CHECK
  102212             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  102213             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  102214             : #endif
  102215             : 
  102216           0 :           returnPointer = &( ( (SgWarningDirectiveStatement*)(SgWarningDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  102217             : 
  102218             : #if FILE_IO_EXTRA_CHECK
  102219           0 :           assert ( returnPointer != NULL ) ;
  102220             : #endif
  102221             :         }
  102222           0 :      return returnPointer ;
  102223             :    }
  102224             : 
  102225             : //############################################################################
  102226             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  102227             :  * pool size! We set for every valid object in the memory pool the freepointer
  102228             :  * to the global index and increase the global index afterwards. For all the 
  102229             :  * invalid objects (means address ranges within the memory pool that were not
  102230             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  102231             :  * distinguish valid from invalid objects! 
  102232             :  */
  102233             : unsigned long
  102234           5 : SgWarningDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  102235             :    {
  102236           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  102237           5 :      SgWarningDirectiveStatement* pointer = NULL;
  102238           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  102239           5 :      std::vector < unsigned char* > :: const_iterator block;
  102240           5 :      for ( block = SgWarningDirectiveStatement::pools.begin(); block != SgWarningDirectiveStatement::pools.end() ; ++block )
  102241             :         {
  102242           0 :           pointer = (SgWarningDirectiveStatement*)(*block);
  102243           0 :           for (unsigned i = 0; i < SgWarningDirectiveStatement::pool_size; ++i )
  102244             :              {
  102245             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  102246             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  102247             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  102248             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  102249             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  102250             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  102251             :             // properly; so this will have to be checked next.
  102252             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  102253             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  102254           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  102255             :                   {
  102256           0 :                     pointer[i].set_freepointer((SgWarningDirectiveStatement*)(globalIndex));
  102257           0 :                     globalIndex++;
  102258             :                   }
  102259             :                else
  102260             :                   {
  102261           0 :                     pointer[i].set_freepointer(NULL);
  102262             :                   }
  102263             :               }
  102264             :         }
  102265           5 :      return globalIndex;
  102266             :    }
  102267             : 
  102268             : //############################################################################
  102269             : // JH (01/14/2006)
  102270             : void
  102271           5 : SgWarningDirectiveStatement::resetValidFreepointers( )
  102272             :    {
  102273           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  102274           5 :      SgWarningDirectiveStatement* pointer = NULL;
  102275           5 :      std::vector < unsigned char* > :: const_iterator block;
  102276           5 :      SgWarningDirectiveStatement* pointerOfLinkedList = NULL;
  102277           5 :      for ( block = SgWarningDirectiveStatement::pools.begin(); block != SgWarningDirectiveStatement::pools.end() ; ++block )
  102278             :         {
  102279           0 :           pointer = (SgWarningDirectiveStatement*)(*block);
  102280           0 :           for (unsigned i = 0; i < SgWarningDirectiveStatement::pool_size; ++i )
  102281             :              {
  102282             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  102283             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  102284             :             // memory blocks!.
  102285           0 :                if ( pointer[i].get_freepointer() != NULL )
  102286             :                   {
  102287           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  102288             :                   }
  102289             :                else
  102290             :                   {
  102291           0 :                     if ( pointerOfLinkedList == NULL )
  102292             :                        {
  102293           0 :                          SgWarningDirectiveStatement::next_node = &(pointer[i]);
  102294             :                        }
  102295             :                     else
  102296             :                        {
  102297             :                       // printf ("In SgWarningDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  102298           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  102299             :                        }
  102300             :                     pointerOfLinkedList = &(pointer[i]);
  102301             :                   }
  102302             :               }
  102303             :         }
  102304             : 
  102305           5 :      if ( pointerOfLinkedList != NULL )
  102306             :         {
  102307             :        // printf ("In SgWarningDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  102308           0 :           pointerOfLinkedList->set_freepointer(NULL);
  102309             :        // DQ (6/6/2010): Temporary debugging...
  102310             :        //   ROSE_ASSERT(false);
  102311             :         }
  102312             : 
  102313           5 :      return ;
  102314             :    }
  102315             : 
  102316             : //############################################################################
  102317             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  102318             :  * within the memory pool and resets the freepointers, in order to achieve a 
  102319             :  * linked list, that has no jumps and starts at the beginning! This function 
  102320             :  * does not extend the memory pool, since we do not delete any memory blocks,
  102321             :  * but delete the valid objects.  
  102322             :  */
  102323             : void
  102324           0 : SgWarningDirectiveStatement::clearMemoryPool( )
  102325             :    {
  102326             :   // printf ("Inside of SgWarningDirectiveStatement::clearMemoryPool() \n");
  102327             : 
  102328           0 :      SgWarningDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  102329           0 :      std::vector < unsigned char* > :: const_iterator block;
  102330           0 :      if ( SgWarningDirectiveStatement::pools.empty() == false )
  102331             :         {
  102332           0 :           block = SgWarningDirectiveStatement::pools.begin() ;
  102333           0 :           SgWarningDirectiveStatement::next_node = (SgWarningDirectiveStatement*) (*block);
  102334             : 
  102335           0 :           while ( block != SgWarningDirectiveStatement::pools.end() )
  102336             :              {
  102337           0 :                pointer = (SgWarningDirectiveStatement*) (*block);
  102338           0 :                if ( tempPointer != NULL )
  102339             :                   {
  102340           0 :                     tempPointer->set_freepointer(pointer);
  102341             :                   }
  102342           0 :                for (unsigned i = 0; i < SgWarningDirectiveStatement::pool_size - 1; ++i)
  102343             :                   {
  102344           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  102345             :                   }
  102346           0 :                 pointer[SgWarningDirectiveStatement::pool_size-1].set_freepointer(NULL);
  102347           0 :                 tempPointer = &(pointer[SgWarningDirectiveStatement::pool_size-1]);
  102348           0 :                 ++block;
  102349             :              }
  102350             :         }
  102351           0 :    }
  102352             : 
  102353           5 : void SgWarningDirectiveStatement::deleteMemoryPool() {
  102354           5 :   for (auto p: SgWarningDirectiveStatement::pools) {
  102355           0 :     ROSE_FREE(p);
  102356             :   }
  102357           5 :   SgWarningDirectiveStatement::next_node = nullptr;
  102358           5 :   SgWarningDirectiveStatement::pools.clear();
  102359           5 : }
  102360             : 
  102361             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  102362             : //                 reading multiple binary files to for a single AST.
  102363             : /////////// new version ////////////////////////////////
  102364             : //############################################################################
  102365             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  102366             : void
  102367           2 : SgWarningDirectiveStatement::extendMemoryPoolForFileIO( )
  102368             :   {
  102369           2 :     size_t blockIndex = SgWarningDirectiveStatement::pools.size();
  102370           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgWarningDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgWarningDirectiveStatement);
  102371             : 
  102372           2 :     while ( (blockIndex * SgWarningDirectiveStatement::pool_size) < newPoolSize)
  102373             :       {
  102374             : #if ROSE_ALLOC_TRACE
  102375             :         if (blockIndex > 0) {
  102376             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgWarningDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgWarningDirectiveStatement) = %" PRIuPTR " SgWarningDirectiveStatement::pool_size = %d \n",
  102377             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgWarningDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgWarningDirectiveStatement),SgWarningDirectiveStatement::pool_size);
  102378             :         }
  102379             : #endif
  102380             : 
  102381           0 :         SgWarningDirectiveStatement * pointer = (SgWarningDirectiveStatement*) ROSE_MALLOC ( SgWarningDirectiveStatement::pool_size * sizeof(SgWarningDirectiveStatement) );
  102382           0 :         assert( pointer != NULL );
  102383             : #if ROSE_ALLOC_MEMSET == 1
  102384             :         memset(pointer, 0x00, SgWarningDirectiveStatement::pool_size * sizeof(SgWarningDirectiveStatement));
  102385             : #elif ROSE_ALLOC_MEMSET == 2
  102386             :         memset(pointer, 0xCC, SgWarningDirectiveStatement::pool_size * sizeof(SgWarningDirectiveStatement));
  102387             : #endif
  102388           0 :         SgWarningDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  102389           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgWarningDirectiveStatement::pool_size * sizeof(SgWarningDirectiveStatement), V_SgWarningDirectiveStatement ) );
  102390             : 
  102391           0 :         if ( SgWarningDirectiveStatement::next_node != NULL ) {
  102392           0 :           if ( blockIndex > 0 ) {
  102393           0 :             SgWarningDirectiveStatement * blkptr = (SgWarningDirectiveStatement*)(SgWarningDirectiveStatement::pools[blockIndex-1]);
  102394           0 :             blkptr[ SgWarningDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  102395             :           }
  102396             :         } else {
  102397           0 :           SgWarningDirectiveStatement::next_node = pointer;
  102398             :         }
  102399             : 
  102400           0 :         for (unsigned i = 0; i < SgWarningDirectiveStatement::pool_size-1; ++i)
  102401             :            {
  102402           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  102403             :            }
  102404           0 :         pointer[ SgWarningDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  102405             : 
  102406           0 :         blockIndex++;
  102407             :       }
  102408           2 :   }
  102409             : 
  102410             : //############################################################################
  102411             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  102412             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  102413             :  * not compressed. However, that stuff is not yet implemented! 
  102414             :  */
  102415             : unsigned long
  102416           0 : SgWarningDirectiveStatement::getNumberOfLastValidPointer()
  102417             :    {
  102418           0 :       SgWarningDirectiveStatement* testPointer = (SgWarningDirectiveStatement*)(SgWarningDirectiveStatement::pools.back());
  102419           0 :       unsigned long localIndex = SgWarningDirectiveStatement::pool_size - 1;
  102420           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  102421             :          {
  102422           0 :            localIndex--;
  102423             :          }
  102424           0 :       return (localIndex + SgWarningDirectiveStatement::pool_size * (SgWarningDirectiveStatement::pools.size()-1));
  102425             :    }
  102426             : 
  102427             : //############################################################################
  102428             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  102429             :  * memory pool and initializes the data member in class SgWarningDirectiveStatementStroageClass
  102430             :  * from its counterpart of SgWarningDirectiveStatement. The return value is just for checking, 
  102431             :  * that the whole StorageClassArray is initialized!
  102432             :  */
  102433             : unsigned long
  102434           0 : SgWarningDirectiveStatement::initializeStorageClassArray( SgWarningDirectiveStatementStorageClass *storageArray )
  102435             :    {
  102436           0 :      unsigned long storageCounter = 0;
  102437           0 :      std::vector < unsigned char* > :: const_iterator block = SgWarningDirectiveStatement::pools.begin();
  102438           0 :      SgWarningDirectiveStatement* pointer = NULL;
  102439           0 :      while ( block != SgWarningDirectiveStatement::pools.end() ) {
  102440           0 :           pointer = (SgWarningDirectiveStatement*) (*block);
  102441           0 :           for ( unsigned i = 0; i < SgWarningDirectiveStatement::pool_size; ++i ) {
  102442           0 :                if ( pointer->get_freepointer() != NULL ) {
  102443           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  102444           0 :                  storageArray++;
  102445           0 :                  storageCounter++;
  102446             :                }
  102447           0 :                pointer++;
  102448             :              }
  102449           0 :            block++;
  102450             :         }
  102451           0 :      return storageCounter;
  102452             :    }
  102453             : 
  102454             : /* #line 102455 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  102455             : 
  102456             : 
  102457             : 
  102458             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  102459             : 
  102460             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  102461             : 
  102462             : //############################################################################
  102463             : /* JH (02/02/2006) Constructor of the IR node SgErrorDirectiveStatement that takes its 
  102464             :  * corresponding StorageClass as parameter
  102465             :  */
  102466           0 : SgErrorDirectiveStatement :: SgErrorDirectiveStatement ( const SgErrorDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  102467             :    {
  102468             : 
  102469             : 
  102470             : /* #line 102471 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  102471             : 
  102472           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  102473             : 
  102474             : 
  102475             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  102476             : 
  102477             : 
  102478           0 :    }
  102479             : 
  102480             : //############################################################################
  102481             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  102482             :  * within the working AST. 
  102483             :  */
  102484           0 : SgErrorDirectiveStatement * SgErrorDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  102485           0 :      SgErrorDirectiveStatement* returnPointer = NULL;
  102486           0 :      if ( globalIndex != 0 )
  102487             :         {
  102488             : 
  102489             : #if FILE_IO_EXTRA_CHECK
  102490           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgErrorDirectiveStatement ) ) <= globalIndex ) ;
  102491           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgErrorDirectiveStatement + 1 ) ) );
  102492             : #endif
  102493           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgErrorDirectiveStatement )  
  102494           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgErrorDirectiveStatement );
  102495           0 :           unsigned long positionInPool = localIndex % SgErrorDirectiveStatement::pool_size;
  102496           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgErrorDirectiveStatement::pool_size;
  102497             : 
  102498             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  102499             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  102500             : 
  102501           0 :           returnPointer = &( ( (SgErrorDirectiveStatement*)(SgErrorDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  102502             : 
  102503           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  102504             :         }
  102505           0 :      return returnPointer ;
  102506             :    }
  102507             : 
  102508             : //############################################################################
  102509             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  102510             :   for the AST with the index astIndex
  102511             : */
  102512           0 : SgErrorDirectiveStatement * SgErrorDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  102513           0 :      SgErrorDirectiveStatement* returnPointer = NULL;
  102514           0 :      if ( globalIndex != 0 )
  102515             :         {
  102516             : 
  102517             : #if FILE_IO_EXTRA_CHECK
  102518           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgErrorDirectiveStatement ) ) <= globalIndex ) ;
  102519           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgErrorDirectiveStatement + 1 ) ) );
  102520             : #endif
  102521           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgErrorDirectiveStatement )
  102522           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgErrorDirectiveStatement );
  102523           0 :           unsigned long positionInPool = localIndex % SgErrorDirectiveStatement::pool_size ;
  102524           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgErrorDirectiveStatement::pool_size ;
  102525             : 
  102526             : #if FILE_IO_EXTRA_CHECK
  102527             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  102528             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  102529             : #endif
  102530             : 
  102531           0 :           returnPointer = &( ( (SgErrorDirectiveStatement*)(SgErrorDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  102532             : 
  102533             : #if FILE_IO_EXTRA_CHECK
  102534           0 :           assert ( returnPointer != NULL ) ;
  102535             : #endif
  102536             :         }
  102537           0 :      return returnPointer ;
  102538             :    }
  102539             : 
  102540             : //############################################################################
  102541             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  102542             :  * pool size! We set for every valid object in the memory pool the freepointer
  102543             :  * to the global index and increase the global index afterwards. For all the 
  102544             :  * invalid objects (means address ranges within the memory pool that were not
  102545             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  102546             :  * distinguish valid from invalid objects! 
  102547             :  */
  102548             : unsigned long
  102549           5 : SgErrorDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  102550             :    {
  102551           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  102552           5 :      SgErrorDirectiveStatement* pointer = NULL;
  102553           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  102554           5 :      std::vector < unsigned char* > :: const_iterator block;
  102555           5 :      for ( block = SgErrorDirectiveStatement::pools.begin(); block != SgErrorDirectiveStatement::pools.end() ; ++block )
  102556             :         {
  102557           0 :           pointer = (SgErrorDirectiveStatement*)(*block);
  102558           0 :           for (unsigned i = 0; i < SgErrorDirectiveStatement::pool_size; ++i )
  102559             :              {
  102560             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  102561             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  102562             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  102563             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  102564             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  102565             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  102566             :             // properly; so this will have to be checked next.
  102567             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  102568             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  102569           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  102570             :                   {
  102571           0 :                     pointer[i].set_freepointer((SgErrorDirectiveStatement*)(globalIndex));
  102572           0 :                     globalIndex++;
  102573             :                   }
  102574             :                else
  102575             :                   {
  102576           0 :                     pointer[i].set_freepointer(NULL);
  102577             :                   }
  102578             :               }
  102579             :         }
  102580           5 :      return globalIndex;
  102581             :    }
  102582             : 
  102583             : //############################################################################
  102584             : // JH (01/14/2006)
  102585             : void
  102586           5 : SgErrorDirectiveStatement::resetValidFreepointers( )
  102587             :    {
  102588           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  102589           5 :      SgErrorDirectiveStatement* pointer = NULL;
  102590           5 :      std::vector < unsigned char* > :: const_iterator block;
  102591           5 :      SgErrorDirectiveStatement* pointerOfLinkedList = NULL;
  102592           5 :      for ( block = SgErrorDirectiveStatement::pools.begin(); block != SgErrorDirectiveStatement::pools.end() ; ++block )
  102593             :         {
  102594           0 :           pointer = (SgErrorDirectiveStatement*)(*block);
  102595           0 :           for (unsigned i = 0; i < SgErrorDirectiveStatement::pool_size; ++i )
  102596             :              {
  102597             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  102598             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  102599             :             // memory blocks!.
  102600           0 :                if ( pointer[i].get_freepointer() != NULL )
  102601             :                   {
  102602           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  102603             :                   }
  102604             :                else
  102605             :                   {
  102606           0 :                     if ( pointerOfLinkedList == NULL )
  102607             :                        {
  102608           0 :                          SgErrorDirectiveStatement::next_node = &(pointer[i]);
  102609             :                        }
  102610             :                     else
  102611             :                        {
  102612             :                       // printf ("In SgErrorDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  102613           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  102614             :                        }
  102615             :                     pointerOfLinkedList = &(pointer[i]);
  102616             :                   }
  102617             :               }
  102618             :         }
  102619             : 
  102620           5 :      if ( pointerOfLinkedList != NULL )
  102621             :         {
  102622             :        // printf ("In SgErrorDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  102623           0 :           pointerOfLinkedList->set_freepointer(NULL);
  102624             :        // DQ (6/6/2010): Temporary debugging...
  102625             :        //   ROSE_ASSERT(false);
  102626             :         }
  102627             : 
  102628           5 :      return ;
  102629             :    }
  102630             : 
  102631             : //############################################################################
  102632             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  102633             :  * within the memory pool and resets the freepointers, in order to achieve a 
  102634             :  * linked list, that has no jumps and starts at the beginning! This function 
  102635             :  * does not extend the memory pool, since we do not delete any memory blocks,
  102636             :  * but delete the valid objects.  
  102637             :  */
  102638             : void
  102639           0 : SgErrorDirectiveStatement::clearMemoryPool( )
  102640             :    {
  102641             :   // printf ("Inside of SgErrorDirectiveStatement::clearMemoryPool() \n");
  102642             : 
  102643           0 :      SgErrorDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  102644           0 :      std::vector < unsigned char* > :: const_iterator block;
  102645           0 :      if ( SgErrorDirectiveStatement::pools.empty() == false )
  102646             :         {
  102647           0 :           block = SgErrorDirectiveStatement::pools.begin() ;
  102648           0 :           SgErrorDirectiveStatement::next_node = (SgErrorDirectiveStatement*) (*block);
  102649             : 
  102650           0 :           while ( block != SgErrorDirectiveStatement::pools.end() )
  102651             :              {
  102652           0 :                pointer = (SgErrorDirectiveStatement*) (*block);
  102653           0 :                if ( tempPointer != NULL )
  102654             :                   {
  102655           0 :                     tempPointer->set_freepointer(pointer);
  102656             :                   }
  102657           0 :                for (unsigned i = 0; i < SgErrorDirectiveStatement::pool_size - 1; ++i)
  102658             :                   {
  102659           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  102660             :                   }
  102661           0 :                 pointer[SgErrorDirectiveStatement::pool_size-1].set_freepointer(NULL);
  102662           0 :                 tempPointer = &(pointer[SgErrorDirectiveStatement::pool_size-1]);
  102663           0 :                 ++block;
  102664             :              }
  102665             :         }
  102666           0 :    }
  102667             : 
  102668           5 : void SgErrorDirectiveStatement::deleteMemoryPool() {
  102669           5 :   for (auto p: SgErrorDirectiveStatement::pools) {
  102670           0 :     ROSE_FREE(p);
  102671             :   }
  102672           5 :   SgErrorDirectiveStatement::next_node = nullptr;
  102673           5 :   SgErrorDirectiveStatement::pools.clear();
  102674           5 : }
  102675             : 
  102676             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  102677             : //                 reading multiple binary files to for a single AST.
  102678             : /////////// new version ////////////////////////////////
  102679             : //############################################################################
  102680             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  102681             : void
  102682           2 : SgErrorDirectiveStatement::extendMemoryPoolForFileIO( )
  102683             :   {
  102684           2 :     size_t blockIndex = SgErrorDirectiveStatement::pools.size();
  102685           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgErrorDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgErrorDirectiveStatement);
  102686             : 
  102687           2 :     while ( (blockIndex * SgErrorDirectiveStatement::pool_size) < newPoolSize)
  102688             :       {
  102689             : #if ROSE_ALLOC_TRACE
  102690             :         if (blockIndex > 0) {
  102691             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgErrorDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgErrorDirectiveStatement) = %" PRIuPTR " SgErrorDirectiveStatement::pool_size = %d \n",
  102692             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgErrorDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgErrorDirectiveStatement),SgErrorDirectiveStatement::pool_size);
  102693             :         }
  102694             : #endif
  102695             : 
  102696           0 :         SgErrorDirectiveStatement * pointer = (SgErrorDirectiveStatement*) ROSE_MALLOC ( SgErrorDirectiveStatement::pool_size * sizeof(SgErrorDirectiveStatement) );
  102697           0 :         assert( pointer != NULL );
  102698             : #if ROSE_ALLOC_MEMSET == 1
  102699             :         memset(pointer, 0x00, SgErrorDirectiveStatement::pool_size * sizeof(SgErrorDirectiveStatement));
  102700             : #elif ROSE_ALLOC_MEMSET == 2
  102701             :         memset(pointer, 0xCC, SgErrorDirectiveStatement::pool_size * sizeof(SgErrorDirectiveStatement));
  102702             : #endif
  102703           0 :         SgErrorDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  102704           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgErrorDirectiveStatement::pool_size * sizeof(SgErrorDirectiveStatement), V_SgErrorDirectiveStatement ) );
  102705             : 
  102706           0 :         if ( SgErrorDirectiveStatement::next_node != NULL ) {
  102707           0 :           if ( blockIndex > 0 ) {
  102708           0 :             SgErrorDirectiveStatement * blkptr = (SgErrorDirectiveStatement*)(SgErrorDirectiveStatement::pools[blockIndex-1]);
  102709           0 :             blkptr[ SgErrorDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  102710             :           }
  102711             :         } else {
  102712           0 :           SgErrorDirectiveStatement::next_node = pointer;
  102713             :         }
  102714             : 
  102715           0 :         for (unsigned i = 0; i < SgErrorDirectiveStatement::pool_size-1; ++i)
  102716             :            {
  102717           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  102718             :            }
  102719           0 :         pointer[ SgErrorDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  102720             : 
  102721           0 :         blockIndex++;
  102722             :       }
  102723           2 :   }
  102724             : 
  102725             : //############################################################################
  102726             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  102727             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  102728             :  * not compressed. However, that stuff is not yet implemented! 
  102729             :  */
  102730             : unsigned long
  102731           0 : SgErrorDirectiveStatement::getNumberOfLastValidPointer()
  102732             :    {
  102733           0 :       SgErrorDirectiveStatement* testPointer = (SgErrorDirectiveStatement*)(SgErrorDirectiveStatement::pools.back());
  102734           0 :       unsigned long localIndex = SgErrorDirectiveStatement::pool_size - 1;
  102735           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  102736             :          {
  102737           0 :            localIndex--;
  102738             :          }
  102739           0 :       return (localIndex + SgErrorDirectiveStatement::pool_size * (SgErrorDirectiveStatement::pools.size()-1));
  102740             :    }
  102741             : 
  102742             : //############################################################################
  102743             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  102744             :  * memory pool and initializes the data member in class SgErrorDirectiveStatementStroageClass
  102745             :  * from its counterpart of SgErrorDirectiveStatement. The return value is just for checking, 
  102746             :  * that the whole StorageClassArray is initialized!
  102747             :  */
  102748             : unsigned long
  102749           0 : SgErrorDirectiveStatement::initializeStorageClassArray( SgErrorDirectiveStatementStorageClass *storageArray )
  102750             :    {
  102751           0 :      unsigned long storageCounter = 0;
  102752           0 :      std::vector < unsigned char* > :: const_iterator block = SgErrorDirectiveStatement::pools.begin();
  102753           0 :      SgErrorDirectiveStatement* pointer = NULL;
  102754           0 :      while ( block != SgErrorDirectiveStatement::pools.end() ) {
  102755           0 :           pointer = (SgErrorDirectiveStatement*) (*block);
  102756           0 :           for ( unsigned i = 0; i < SgErrorDirectiveStatement::pool_size; ++i ) {
  102757           0 :                if ( pointer->get_freepointer() != NULL ) {
  102758           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  102759           0 :                  storageArray++;
  102760           0 :                  storageCounter++;
  102761             :                }
  102762           0 :                pointer++;
  102763             :              }
  102764           0 :            block++;
  102765             :         }
  102766           0 :      return storageCounter;
  102767             :    }
  102768             : 
  102769             : /* #line 102770 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  102770             : 
  102771             : 
  102772             : 
  102773             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  102774             : 
  102775             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  102776             : 
  102777             : //############################################################################
  102778             : /* JH (02/02/2006) Constructor of the IR node SgEmptyDirectiveStatement that takes its 
  102779             :  * corresponding StorageClass as parameter
  102780             :  */
  102781           0 : SgEmptyDirectiveStatement :: SgEmptyDirectiveStatement ( const SgEmptyDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  102782             :    {
  102783             : 
  102784             : 
  102785             : /* #line 102786 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  102786             : 
  102787           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  102788             : 
  102789             : 
  102790             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  102791             : 
  102792             : 
  102793           0 :    }
  102794             : 
  102795             : //############################################################################
  102796             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  102797             :  * within the working AST. 
  102798             :  */
  102799           0 : SgEmptyDirectiveStatement * SgEmptyDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  102800           0 :      SgEmptyDirectiveStatement* returnPointer = NULL;
  102801           0 :      if ( globalIndex != 0 )
  102802             :         {
  102803             : 
  102804             : #if FILE_IO_EXTRA_CHECK
  102805           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEmptyDirectiveStatement ) ) <= globalIndex ) ;
  102806           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEmptyDirectiveStatement + 1 ) ) );
  102807             : #endif
  102808           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEmptyDirectiveStatement )  
  102809           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEmptyDirectiveStatement );
  102810           0 :           unsigned long positionInPool = localIndex % SgEmptyDirectiveStatement::pool_size;
  102811           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEmptyDirectiveStatement::pool_size;
  102812             : 
  102813             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  102814             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  102815             : 
  102816           0 :           returnPointer = &( ( (SgEmptyDirectiveStatement*)(SgEmptyDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  102817             : 
  102818           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  102819             :         }
  102820           0 :      return returnPointer ;
  102821             :    }
  102822             : 
  102823             : //############################################################################
  102824             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  102825             :   for the AST with the index astIndex
  102826             : */
  102827           0 : SgEmptyDirectiveStatement * SgEmptyDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  102828           0 :      SgEmptyDirectiveStatement* returnPointer = NULL;
  102829           0 :      if ( globalIndex != 0 )
  102830             :         {
  102831             : 
  102832             : #if FILE_IO_EXTRA_CHECK
  102833           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEmptyDirectiveStatement ) ) <= globalIndex ) ;
  102834           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEmptyDirectiveStatement + 1 ) ) );
  102835             : #endif
  102836           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEmptyDirectiveStatement )
  102837           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEmptyDirectiveStatement );
  102838           0 :           unsigned long positionInPool = localIndex % SgEmptyDirectiveStatement::pool_size ;
  102839           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEmptyDirectiveStatement::pool_size ;
  102840             : 
  102841             : #if FILE_IO_EXTRA_CHECK
  102842             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  102843             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  102844             : #endif
  102845             : 
  102846           0 :           returnPointer = &( ( (SgEmptyDirectiveStatement*)(SgEmptyDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  102847             : 
  102848             : #if FILE_IO_EXTRA_CHECK
  102849           0 :           assert ( returnPointer != NULL ) ;
  102850             : #endif
  102851             :         }
  102852           0 :      return returnPointer ;
  102853             :    }
  102854             : 
  102855             : //############################################################################
  102856             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  102857             :  * pool size! We set for every valid object in the memory pool the freepointer
  102858             :  * to the global index and increase the global index afterwards. For all the 
  102859             :  * invalid objects (means address ranges within the memory pool that were not
  102860             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  102861             :  * distinguish valid from invalid objects! 
  102862             :  */
  102863             : unsigned long
  102864           5 : SgEmptyDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  102865             :    {
  102866           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  102867           5 :      SgEmptyDirectiveStatement* pointer = NULL;
  102868           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  102869           5 :      std::vector < unsigned char* > :: const_iterator block;
  102870           5 :      for ( block = SgEmptyDirectiveStatement::pools.begin(); block != SgEmptyDirectiveStatement::pools.end() ; ++block )
  102871             :         {
  102872           0 :           pointer = (SgEmptyDirectiveStatement*)(*block);
  102873           0 :           for (unsigned i = 0; i < SgEmptyDirectiveStatement::pool_size; ++i )
  102874             :              {
  102875             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  102876             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  102877             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  102878             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  102879             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  102880             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  102881             :             // properly; so this will have to be checked next.
  102882             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  102883             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  102884           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  102885             :                   {
  102886           0 :                     pointer[i].set_freepointer((SgEmptyDirectiveStatement*)(globalIndex));
  102887           0 :                     globalIndex++;
  102888             :                   }
  102889             :                else
  102890             :                   {
  102891           0 :                     pointer[i].set_freepointer(NULL);
  102892             :                   }
  102893             :               }
  102894             :         }
  102895           5 :      return globalIndex;
  102896             :    }
  102897             : 
  102898             : //############################################################################
  102899             : // JH (01/14/2006)
  102900             : void
  102901           5 : SgEmptyDirectiveStatement::resetValidFreepointers( )
  102902             :    {
  102903           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  102904           5 :      SgEmptyDirectiveStatement* pointer = NULL;
  102905           5 :      std::vector < unsigned char* > :: const_iterator block;
  102906           5 :      SgEmptyDirectiveStatement* pointerOfLinkedList = NULL;
  102907           5 :      for ( block = SgEmptyDirectiveStatement::pools.begin(); block != SgEmptyDirectiveStatement::pools.end() ; ++block )
  102908             :         {
  102909           0 :           pointer = (SgEmptyDirectiveStatement*)(*block);
  102910           0 :           for (unsigned i = 0; i < SgEmptyDirectiveStatement::pool_size; ++i )
  102911             :              {
  102912             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  102913             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  102914             :             // memory blocks!.
  102915           0 :                if ( pointer[i].get_freepointer() != NULL )
  102916             :                   {
  102917           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  102918             :                   }
  102919             :                else
  102920             :                   {
  102921           0 :                     if ( pointerOfLinkedList == NULL )
  102922             :                        {
  102923           0 :                          SgEmptyDirectiveStatement::next_node = &(pointer[i]);
  102924             :                        }
  102925             :                     else
  102926             :                        {
  102927             :                       // printf ("In SgEmptyDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  102928           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  102929             :                        }
  102930             :                     pointerOfLinkedList = &(pointer[i]);
  102931             :                   }
  102932             :               }
  102933             :         }
  102934             : 
  102935           5 :      if ( pointerOfLinkedList != NULL )
  102936             :         {
  102937             :        // printf ("In SgEmptyDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  102938           0 :           pointerOfLinkedList->set_freepointer(NULL);
  102939             :        // DQ (6/6/2010): Temporary debugging...
  102940             :        //   ROSE_ASSERT(false);
  102941             :         }
  102942             : 
  102943           5 :      return ;
  102944             :    }
  102945             : 
  102946             : //############################################################################
  102947             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  102948             :  * within the memory pool and resets the freepointers, in order to achieve a 
  102949             :  * linked list, that has no jumps and starts at the beginning! This function 
  102950             :  * does not extend the memory pool, since we do not delete any memory blocks,
  102951             :  * but delete the valid objects.  
  102952             :  */
  102953             : void
  102954           0 : SgEmptyDirectiveStatement::clearMemoryPool( )
  102955             :    {
  102956             :   // printf ("Inside of SgEmptyDirectiveStatement::clearMemoryPool() \n");
  102957             : 
  102958           0 :      SgEmptyDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  102959           0 :      std::vector < unsigned char* > :: const_iterator block;
  102960           0 :      if ( SgEmptyDirectiveStatement::pools.empty() == false )
  102961             :         {
  102962           0 :           block = SgEmptyDirectiveStatement::pools.begin() ;
  102963           0 :           SgEmptyDirectiveStatement::next_node = (SgEmptyDirectiveStatement*) (*block);
  102964             : 
  102965           0 :           while ( block != SgEmptyDirectiveStatement::pools.end() )
  102966             :              {
  102967           0 :                pointer = (SgEmptyDirectiveStatement*) (*block);
  102968           0 :                if ( tempPointer != NULL )
  102969             :                   {
  102970           0 :                     tempPointer->set_freepointer(pointer);
  102971             :                   }
  102972           0 :                for (unsigned i = 0; i < SgEmptyDirectiveStatement::pool_size - 1; ++i)
  102973             :                   {
  102974           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  102975             :                   }
  102976           0 :                 pointer[SgEmptyDirectiveStatement::pool_size-1].set_freepointer(NULL);
  102977           0 :                 tempPointer = &(pointer[SgEmptyDirectiveStatement::pool_size-1]);
  102978           0 :                 ++block;
  102979             :              }
  102980             :         }
  102981           0 :    }
  102982             : 
  102983           5 : void SgEmptyDirectiveStatement::deleteMemoryPool() {
  102984           5 :   for (auto p: SgEmptyDirectiveStatement::pools) {
  102985           0 :     ROSE_FREE(p);
  102986             :   }
  102987           5 :   SgEmptyDirectiveStatement::next_node = nullptr;
  102988           5 :   SgEmptyDirectiveStatement::pools.clear();
  102989           5 : }
  102990             : 
  102991             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  102992             : //                 reading multiple binary files to for a single AST.
  102993             : /////////// new version ////////////////////////////////
  102994             : //############################################################################
  102995             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  102996             : void
  102997           2 : SgEmptyDirectiveStatement::extendMemoryPoolForFileIO( )
  102998             :   {
  102999           2 :     size_t blockIndex = SgEmptyDirectiveStatement::pools.size();
  103000           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEmptyDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEmptyDirectiveStatement);
  103001             : 
  103002           2 :     while ( (blockIndex * SgEmptyDirectiveStatement::pool_size) < newPoolSize)
  103003             :       {
  103004             : #if ROSE_ALLOC_TRACE
  103005             :         if (blockIndex > 0) {
  103006             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEmptyDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEmptyDirectiveStatement) = %" PRIuPTR " SgEmptyDirectiveStatement::pool_size = %d \n",
  103007             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEmptyDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEmptyDirectiveStatement),SgEmptyDirectiveStatement::pool_size);
  103008             :         }
  103009             : #endif
  103010             : 
  103011           0 :         SgEmptyDirectiveStatement * pointer = (SgEmptyDirectiveStatement*) ROSE_MALLOC ( SgEmptyDirectiveStatement::pool_size * sizeof(SgEmptyDirectiveStatement) );
  103012           0 :         assert( pointer != NULL );
  103013             : #if ROSE_ALLOC_MEMSET == 1
  103014             :         memset(pointer, 0x00, SgEmptyDirectiveStatement::pool_size * sizeof(SgEmptyDirectiveStatement));
  103015             : #elif ROSE_ALLOC_MEMSET == 2
  103016             :         memset(pointer, 0xCC, SgEmptyDirectiveStatement::pool_size * sizeof(SgEmptyDirectiveStatement));
  103017             : #endif
  103018           0 :         SgEmptyDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  103019           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEmptyDirectiveStatement::pool_size * sizeof(SgEmptyDirectiveStatement), V_SgEmptyDirectiveStatement ) );
  103020             : 
  103021           0 :         if ( SgEmptyDirectiveStatement::next_node != NULL ) {
  103022           0 :           if ( blockIndex > 0 ) {
  103023           0 :             SgEmptyDirectiveStatement * blkptr = (SgEmptyDirectiveStatement*)(SgEmptyDirectiveStatement::pools[blockIndex-1]);
  103024           0 :             blkptr[ SgEmptyDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  103025             :           }
  103026             :         } else {
  103027           0 :           SgEmptyDirectiveStatement::next_node = pointer;
  103028             :         }
  103029             : 
  103030           0 :         for (unsigned i = 0; i < SgEmptyDirectiveStatement::pool_size-1; ++i)
  103031             :            {
  103032           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  103033             :            }
  103034           0 :         pointer[ SgEmptyDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  103035             : 
  103036           0 :         blockIndex++;
  103037             :       }
  103038           2 :   }
  103039             : 
  103040             : //############################################################################
  103041             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  103042             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  103043             :  * not compressed. However, that stuff is not yet implemented! 
  103044             :  */
  103045             : unsigned long
  103046           0 : SgEmptyDirectiveStatement::getNumberOfLastValidPointer()
  103047             :    {
  103048           0 :       SgEmptyDirectiveStatement* testPointer = (SgEmptyDirectiveStatement*)(SgEmptyDirectiveStatement::pools.back());
  103049           0 :       unsigned long localIndex = SgEmptyDirectiveStatement::pool_size - 1;
  103050           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  103051             :          {
  103052           0 :            localIndex--;
  103053             :          }
  103054           0 :       return (localIndex + SgEmptyDirectiveStatement::pool_size * (SgEmptyDirectiveStatement::pools.size()-1));
  103055             :    }
  103056             : 
  103057             : //############################################################################
  103058             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  103059             :  * memory pool and initializes the data member in class SgEmptyDirectiveStatementStroageClass
  103060             :  * from its counterpart of SgEmptyDirectiveStatement. The return value is just for checking, 
  103061             :  * that the whole StorageClassArray is initialized!
  103062             :  */
  103063             : unsigned long
  103064           0 : SgEmptyDirectiveStatement::initializeStorageClassArray( SgEmptyDirectiveStatementStorageClass *storageArray )
  103065             :    {
  103066           0 :      unsigned long storageCounter = 0;
  103067           0 :      std::vector < unsigned char* > :: const_iterator block = SgEmptyDirectiveStatement::pools.begin();
  103068           0 :      SgEmptyDirectiveStatement* pointer = NULL;
  103069           0 :      while ( block != SgEmptyDirectiveStatement::pools.end() ) {
  103070           0 :           pointer = (SgEmptyDirectiveStatement*) (*block);
  103071           0 :           for ( unsigned i = 0; i < SgEmptyDirectiveStatement::pool_size; ++i ) {
  103072           0 :                if ( pointer->get_freepointer() != NULL ) {
  103073           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  103074           0 :                  storageArray++;
  103075           0 :                  storageCounter++;
  103076             :                }
  103077           0 :                pointer++;
  103078             :              }
  103079           0 :            block++;
  103080             :         }
  103081           0 :      return storageCounter;
  103082             :    }
  103083             : 
  103084             : /* #line 103085 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  103085             : 
  103086             : 
  103087             : 
  103088             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  103089             : 
  103090             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  103091             : 
  103092             : //############################################################################
  103093             : /* JH (02/02/2006) Constructor of the IR node SgIncludeNextDirectiveStatement that takes its 
  103094             :  * corresponding StorageClass as parameter
  103095             :  */
  103096           0 : SgIncludeNextDirectiveStatement :: SgIncludeNextDirectiveStatement ( const SgIncludeNextDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  103097             :    {
  103098             : 
  103099             : 
  103100             : /* #line 103101 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  103101             : 
  103102           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  103103             : 
  103104             : 
  103105             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  103106             : 
  103107             : 
  103108           0 :    }
  103109             : 
  103110             : //############################################################################
  103111             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  103112             :  * within the working AST. 
  103113             :  */
  103114           0 : SgIncludeNextDirectiveStatement * SgIncludeNextDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  103115           0 :      SgIncludeNextDirectiveStatement* returnPointer = NULL;
  103116           0 :      if ( globalIndex != 0 )
  103117             :         {
  103118             : 
  103119             : #if FILE_IO_EXTRA_CHECK
  103120           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIncludeNextDirectiveStatement ) ) <= globalIndex ) ;
  103121           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncludeNextDirectiveStatement + 1 ) ) );
  103122             : #endif
  103123           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIncludeNextDirectiveStatement )  
  103124           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIncludeNextDirectiveStatement );
  103125           0 :           unsigned long positionInPool = localIndex % SgIncludeNextDirectiveStatement::pool_size;
  103126           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncludeNextDirectiveStatement::pool_size;
  103127             : 
  103128             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  103129             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  103130             : 
  103131           0 :           returnPointer = &( ( (SgIncludeNextDirectiveStatement*)(SgIncludeNextDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  103132             : 
  103133           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  103134             :         }
  103135           0 :      return returnPointer ;
  103136             :    }
  103137             : 
  103138             : //############################################################################
  103139             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  103140             :   for the AST with the index astIndex
  103141             : */
  103142           0 : SgIncludeNextDirectiveStatement * SgIncludeNextDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  103143           0 :      SgIncludeNextDirectiveStatement* returnPointer = NULL;
  103144           0 :      if ( globalIndex != 0 )
  103145             :         {
  103146             : 
  103147             : #if FILE_IO_EXTRA_CHECK
  103148           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIncludeNextDirectiveStatement ) ) <= globalIndex ) ;
  103149           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncludeNextDirectiveStatement + 1 ) ) );
  103150             : #endif
  103151           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIncludeNextDirectiveStatement )
  103152           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIncludeNextDirectiveStatement );
  103153           0 :           unsigned long positionInPool = localIndex % SgIncludeNextDirectiveStatement::pool_size ;
  103154           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIncludeNextDirectiveStatement::pool_size ;
  103155             : 
  103156             : #if FILE_IO_EXTRA_CHECK
  103157             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  103158             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  103159             : #endif
  103160             : 
  103161           0 :           returnPointer = &( ( (SgIncludeNextDirectiveStatement*)(SgIncludeNextDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  103162             : 
  103163             : #if FILE_IO_EXTRA_CHECK
  103164           0 :           assert ( returnPointer != NULL ) ;
  103165             : #endif
  103166             :         }
  103167           0 :      return returnPointer ;
  103168             :    }
  103169             : 
  103170             : //############################################################################
  103171             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  103172             :  * pool size! We set for every valid object in the memory pool the freepointer
  103173             :  * to the global index and increase the global index afterwards. For all the 
  103174             :  * invalid objects (means address ranges within the memory pool that were not
  103175             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  103176             :  * distinguish valid from invalid objects! 
  103177             :  */
  103178             : unsigned long
  103179           5 : SgIncludeNextDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  103180             :    {
  103181           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  103182           5 :      SgIncludeNextDirectiveStatement* pointer = NULL;
  103183           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  103184           5 :      std::vector < unsigned char* > :: const_iterator block;
  103185           5 :      for ( block = SgIncludeNextDirectiveStatement::pools.begin(); block != SgIncludeNextDirectiveStatement::pools.end() ; ++block )
  103186             :         {
  103187           0 :           pointer = (SgIncludeNextDirectiveStatement*)(*block);
  103188           0 :           for (unsigned i = 0; i < SgIncludeNextDirectiveStatement::pool_size; ++i )
  103189             :              {
  103190             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  103191             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  103192             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  103193             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  103194             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  103195             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  103196             :             // properly; so this will have to be checked next.
  103197             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  103198             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  103199           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  103200             :                   {
  103201           0 :                     pointer[i].set_freepointer((SgIncludeNextDirectiveStatement*)(globalIndex));
  103202           0 :                     globalIndex++;
  103203             :                   }
  103204             :                else
  103205             :                   {
  103206           0 :                     pointer[i].set_freepointer(NULL);
  103207             :                   }
  103208             :               }
  103209             :         }
  103210           5 :      return globalIndex;
  103211             :    }
  103212             : 
  103213             : //############################################################################
  103214             : // JH (01/14/2006)
  103215             : void
  103216           5 : SgIncludeNextDirectiveStatement::resetValidFreepointers( )
  103217             :    {
  103218           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  103219           5 :      SgIncludeNextDirectiveStatement* pointer = NULL;
  103220           5 :      std::vector < unsigned char* > :: const_iterator block;
  103221           5 :      SgIncludeNextDirectiveStatement* pointerOfLinkedList = NULL;
  103222           5 :      for ( block = SgIncludeNextDirectiveStatement::pools.begin(); block != SgIncludeNextDirectiveStatement::pools.end() ; ++block )
  103223             :         {
  103224           0 :           pointer = (SgIncludeNextDirectiveStatement*)(*block);
  103225           0 :           for (unsigned i = 0; i < SgIncludeNextDirectiveStatement::pool_size; ++i )
  103226             :              {
  103227             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  103228             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  103229             :             // memory blocks!.
  103230           0 :                if ( pointer[i].get_freepointer() != NULL )
  103231             :                   {
  103232           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  103233             :                   }
  103234             :                else
  103235             :                   {
  103236           0 :                     if ( pointerOfLinkedList == NULL )
  103237             :                        {
  103238           0 :                          SgIncludeNextDirectiveStatement::next_node = &(pointer[i]);
  103239             :                        }
  103240             :                     else
  103241             :                        {
  103242             :                       // printf ("In SgIncludeNextDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  103243           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  103244             :                        }
  103245             :                     pointerOfLinkedList = &(pointer[i]);
  103246             :                   }
  103247             :               }
  103248             :         }
  103249             : 
  103250           5 :      if ( pointerOfLinkedList != NULL )
  103251             :         {
  103252             :        // printf ("In SgIncludeNextDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  103253           0 :           pointerOfLinkedList->set_freepointer(NULL);
  103254             :        // DQ (6/6/2010): Temporary debugging...
  103255             :        //   ROSE_ASSERT(false);
  103256             :         }
  103257             : 
  103258           5 :      return ;
  103259             :    }
  103260             : 
  103261             : //############################################################################
  103262             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  103263             :  * within the memory pool and resets the freepointers, in order to achieve a 
  103264             :  * linked list, that has no jumps and starts at the beginning! This function 
  103265             :  * does not extend the memory pool, since we do not delete any memory blocks,
  103266             :  * but delete the valid objects.  
  103267             :  */
  103268             : void
  103269           0 : SgIncludeNextDirectiveStatement::clearMemoryPool( )
  103270             :    {
  103271             :   // printf ("Inside of SgIncludeNextDirectiveStatement::clearMemoryPool() \n");
  103272             : 
  103273           0 :      SgIncludeNextDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  103274           0 :      std::vector < unsigned char* > :: const_iterator block;
  103275           0 :      if ( SgIncludeNextDirectiveStatement::pools.empty() == false )
  103276             :         {
  103277           0 :           block = SgIncludeNextDirectiveStatement::pools.begin() ;
  103278           0 :           SgIncludeNextDirectiveStatement::next_node = (SgIncludeNextDirectiveStatement*) (*block);
  103279             : 
  103280           0 :           while ( block != SgIncludeNextDirectiveStatement::pools.end() )
  103281             :              {
  103282           0 :                pointer = (SgIncludeNextDirectiveStatement*) (*block);
  103283           0 :                if ( tempPointer != NULL )
  103284             :                   {
  103285           0 :                     tempPointer->set_freepointer(pointer);
  103286             :                   }
  103287           0 :                for (unsigned i = 0; i < SgIncludeNextDirectiveStatement::pool_size - 1; ++i)
  103288             :                   {
  103289           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  103290             :                   }
  103291           0 :                 pointer[SgIncludeNextDirectiveStatement::pool_size-1].set_freepointer(NULL);
  103292           0 :                 tempPointer = &(pointer[SgIncludeNextDirectiveStatement::pool_size-1]);
  103293           0 :                 ++block;
  103294             :              }
  103295             :         }
  103296           0 :    }
  103297             : 
  103298           5 : void SgIncludeNextDirectiveStatement::deleteMemoryPool() {
  103299           5 :   for (auto p: SgIncludeNextDirectiveStatement::pools) {
  103300           0 :     ROSE_FREE(p);
  103301             :   }
  103302           5 :   SgIncludeNextDirectiveStatement::next_node = nullptr;
  103303           5 :   SgIncludeNextDirectiveStatement::pools.clear();
  103304           5 : }
  103305             : 
  103306             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  103307             : //                 reading multiple binary files to for a single AST.
  103308             : /////////// new version ////////////////////////////////
  103309             : //############################################################################
  103310             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  103311             : void
  103312           2 : SgIncludeNextDirectiveStatement::extendMemoryPoolForFileIO( )
  103313             :   {
  103314           2 :     size_t blockIndex = SgIncludeNextDirectiveStatement::pools.size();
  103315           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeNextDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeNextDirectiveStatement);
  103316             : 
  103317           2 :     while ( (blockIndex * SgIncludeNextDirectiveStatement::pool_size) < newPoolSize)
  103318             :       {
  103319             : #if ROSE_ALLOC_TRACE
  103320             :         if (blockIndex > 0) {
  103321             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeNextDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeNextDirectiveStatement) = %" PRIuPTR " SgIncludeNextDirectiveStatement::pool_size = %d \n",
  103322             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIncludeNextDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIncludeNextDirectiveStatement),SgIncludeNextDirectiveStatement::pool_size);
  103323             :         }
  103324             : #endif
  103325             : 
  103326           0 :         SgIncludeNextDirectiveStatement * pointer = (SgIncludeNextDirectiveStatement*) ROSE_MALLOC ( SgIncludeNextDirectiveStatement::pool_size * sizeof(SgIncludeNextDirectiveStatement) );
  103327           0 :         assert( pointer != NULL );
  103328             : #if ROSE_ALLOC_MEMSET == 1
  103329             :         memset(pointer, 0x00, SgIncludeNextDirectiveStatement::pool_size * sizeof(SgIncludeNextDirectiveStatement));
  103330             : #elif ROSE_ALLOC_MEMSET == 2
  103331             :         memset(pointer, 0xCC, SgIncludeNextDirectiveStatement::pool_size * sizeof(SgIncludeNextDirectiveStatement));
  103332             : #endif
  103333           0 :         SgIncludeNextDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  103334           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIncludeNextDirectiveStatement::pool_size * sizeof(SgIncludeNextDirectiveStatement), V_SgIncludeNextDirectiveStatement ) );
  103335             : 
  103336           0 :         if ( SgIncludeNextDirectiveStatement::next_node != NULL ) {
  103337           0 :           if ( blockIndex > 0 ) {
  103338           0 :             SgIncludeNextDirectiveStatement * blkptr = (SgIncludeNextDirectiveStatement*)(SgIncludeNextDirectiveStatement::pools[blockIndex-1]);
  103339           0 :             blkptr[ SgIncludeNextDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  103340             :           }
  103341             :         } else {
  103342           0 :           SgIncludeNextDirectiveStatement::next_node = pointer;
  103343             :         }
  103344             : 
  103345           0 :         for (unsigned i = 0; i < SgIncludeNextDirectiveStatement::pool_size-1; ++i)
  103346             :            {
  103347           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  103348             :            }
  103349           0 :         pointer[ SgIncludeNextDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  103350             : 
  103351           0 :         blockIndex++;
  103352             :       }
  103353           2 :   }
  103354             : 
  103355             : //############################################################################
  103356             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  103357             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  103358             :  * not compressed. However, that stuff is not yet implemented! 
  103359             :  */
  103360             : unsigned long
  103361           0 : SgIncludeNextDirectiveStatement::getNumberOfLastValidPointer()
  103362             :    {
  103363           0 :       SgIncludeNextDirectiveStatement* testPointer = (SgIncludeNextDirectiveStatement*)(SgIncludeNextDirectiveStatement::pools.back());
  103364           0 :       unsigned long localIndex = SgIncludeNextDirectiveStatement::pool_size - 1;
  103365           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  103366             :          {
  103367           0 :            localIndex--;
  103368             :          }
  103369           0 :       return (localIndex + SgIncludeNextDirectiveStatement::pool_size * (SgIncludeNextDirectiveStatement::pools.size()-1));
  103370             :    }
  103371             : 
  103372             : //############################################################################
  103373             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  103374             :  * memory pool and initializes the data member in class SgIncludeNextDirectiveStatementStroageClass
  103375             :  * from its counterpart of SgIncludeNextDirectiveStatement. The return value is just for checking, 
  103376             :  * that the whole StorageClassArray is initialized!
  103377             :  */
  103378             : unsigned long
  103379           0 : SgIncludeNextDirectiveStatement::initializeStorageClassArray( SgIncludeNextDirectiveStatementStorageClass *storageArray )
  103380             :    {
  103381           0 :      unsigned long storageCounter = 0;
  103382           0 :      std::vector < unsigned char* > :: const_iterator block = SgIncludeNextDirectiveStatement::pools.begin();
  103383           0 :      SgIncludeNextDirectiveStatement* pointer = NULL;
  103384           0 :      while ( block != SgIncludeNextDirectiveStatement::pools.end() ) {
  103385           0 :           pointer = (SgIncludeNextDirectiveStatement*) (*block);
  103386           0 :           for ( unsigned i = 0; i < SgIncludeNextDirectiveStatement::pool_size; ++i ) {
  103387           0 :                if ( pointer->get_freepointer() != NULL ) {
  103388           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  103389           0 :                  storageArray++;
  103390           0 :                  storageCounter++;
  103391             :                }
  103392           0 :                pointer++;
  103393             :              }
  103394           0 :            block++;
  103395             :         }
  103396           0 :      return storageCounter;
  103397             :    }
  103398             : 
  103399             : /* #line 103400 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  103400             : 
  103401             : 
  103402             : 
  103403             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  103404             : 
  103405             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  103406             : 
  103407             : //############################################################################
  103408             : /* JH (02/02/2006) Constructor of the IR node SgIdentDirectiveStatement that takes its 
  103409             :  * corresponding StorageClass as parameter
  103410             :  */
  103411           0 : SgIdentDirectiveStatement :: SgIdentDirectiveStatement ( const SgIdentDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  103412             :    {
  103413             : 
  103414             : 
  103415             : /* #line 103416 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  103416             : 
  103417           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  103418             : 
  103419             : 
  103420             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  103421             : 
  103422             : 
  103423           0 :    }
  103424             : 
  103425             : //############################################################################
  103426             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  103427             :  * within the working AST. 
  103428             :  */
  103429           0 : SgIdentDirectiveStatement * SgIdentDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  103430           0 :      SgIdentDirectiveStatement* returnPointer = NULL;
  103431           0 :      if ( globalIndex != 0 )
  103432             :         {
  103433             : 
  103434             : #if FILE_IO_EXTRA_CHECK
  103435           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIdentDirectiveStatement ) ) <= globalIndex ) ;
  103436           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIdentDirectiveStatement + 1 ) ) );
  103437             : #endif
  103438           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIdentDirectiveStatement )  
  103439           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIdentDirectiveStatement );
  103440           0 :           unsigned long positionInPool = localIndex % SgIdentDirectiveStatement::pool_size;
  103441           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIdentDirectiveStatement::pool_size;
  103442             : 
  103443             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  103444             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  103445             : 
  103446           0 :           returnPointer = &( ( (SgIdentDirectiveStatement*)(SgIdentDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  103447             : 
  103448           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  103449             :         }
  103450           0 :      return returnPointer ;
  103451             :    }
  103452             : 
  103453             : //############################################################################
  103454             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  103455             :   for the AST with the index astIndex
  103456             : */
  103457           0 : SgIdentDirectiveStatement * SgIdentDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  103458           0 :      SgIdentDirectiveStatement* returnPointer = NULL;
  103459           0 :      if ( globalIndex != 0 )
  103460             :         {
  103461             : 
  103462             : #if FILE_IO_EXTRA_CHECK
  103463           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIdentDirectiveStatement ) ) <= globalIndex ) ;
  103464           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIdentDirectiveStatement + 1 ) ) );
  103465             : #endif
  103466           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIdentDirectiveStatement )
  103467           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIdentDirectiveStatement );
  103468           0 :           unsigned long positionInPool = localIndex % SgIdentDirectiveStatement::pool_size ;
  103469           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIdentDirectiveStatement::pool_size ;
  103470             : 
  103471             : #if FILE_IO_EXTRA_CHECK
  103472             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  103473             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  103474             : #endif
  103475             : 
  103476           0 :           returnPointer = &( ( (SgIdentDirectiveStatement*)(SgIdentDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  103477             : 
  103478             : #if FILE_IO_EXTRA_CHECK
  103479           0 :           assert ( returnPointer != NULL ) ;
  103480             : #endif
  103481             :         }
  103482           0 :      return returnPointer ;
  103483             :    }
  103484             : 
  103485             : //############################################################################
  103486             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  103487             :  * pool size! We set for every valid object in the memory pool the freepointer
  103488             :  * to the global index and increase the global index afterwards. For all the 
  103489             :  * invalid objects (means address ranges within the memory pool that were not
  103490             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  103491             :  * distinguish valid from invalid objects! 
  103492             :  */
  103493             : unsigned long
  103494           5 : SgIdentDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  103495             :    {
  103496           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  103497           5 :      SgIdentDirectiveStatement* pointer = NULL;
  103498           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  103499           5 :      std::vector < unsigned char* > :: const_iterator block;
  103500           5 :      for ( block = SgIdentDirectiveStatement::pools.begin(); block != SgIdentDirectiveStatement::pools.end() ; ++block )
  103501             :         {
  103502           0 :           pointer = (SgIdentDirectiveStatement*)(*block);
  103503           0 :           for (unsigned i = 0; i < SgIdentDirectiveStatement::pool_size; ++i )
  103504             :              {
  103505             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  103506             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  103507             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  103508             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  103509             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  103510             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  103511             :             // properly; so this will have to be checked next.
  103512             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  103513             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  103514           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  103515             :                   {
  103516           0 :                     pointer[i].set_freepointer((SgIdentDirectiveStatement*)(globalIndex));
  103517           0 :                     globalIndex++;
  103518             :                   }
  103519             :                else
  103520             :                   {
  103521           0 :                     pointer[i].set_freepointer(NULL);
  103522             :                   }
  103523             :               }
  103524             :         }
  103525           5 :      return globalIndex;
  103526             :    }
  103527             : 
  103528             : //############################################################################
  103529             : // JH (01/14/2006)
  103530             : void
  103531           5 : SgIdentDirectiveStatement::resetValidFreepointers( )
  103532             :    {
  103533           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  103534           5 :      SgIdentDirectiveStatement* pointer = NULL;
  103535           5 :      std::vector < unsigned char* > :: const_iterator block;
  103536           5 :      SgIdentDirectiveStatement* pointerOfLinkedList = NULL;
  103537           5 :      for ( block = SgIdentDirectiveStatement::pools.begin(); block != SgIdentDirectiveStatement::pools.end() ; ++block )
  103538             :         {
  103539           0 :           pointer = (SgIdentDirectiveStatement*)(*block);
  103540           0 :           for (unsigned i = 0; i < SgIdentDirectiveStatement::pool_size; ++i )
  103541             :              {
  103542             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  103543             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  103544             :             // memory blocks!.
  103545           0 :                if ( pointer[i].get_freepointer() != NULL )
  103546             :                   {
  103547           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  103548             :                   }
  103549             :                else
  103550             :                   {
  103551           0 :                     if ( pointerOfLinkedList == NULL )
  103552             :                        {
  103553           0 :                          SgIdentDirectiveStatement::next_node = &(pointer[i]);
  103554             :                        }
  103555             :                     else
  103556             :                        {
  103557             :                       // printf ("In SgIdentDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  103558           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  103559             :                        }
  103560             :                     pointerOfLinkedList = &(pointer[i]);
  103561             :                   }
  103562             :               }
  103563             :         }
  103564             : 
  103565           5 :      if ( pointerOfLinkedList != NULL )
  103566             :         {
  103567             :        // printf ("In SgIdentDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  103568           0 :           pointerOfLinkedList->set_freepointer(NULL);
  103569             :        // DQ (6/6/2010): Temporary debugging...
  103570             :        //   ROSE_ASSERT(false);
  103571             :         }
  103572             : 
  103573           5 :      return ;
  103574             :    }
  103575             : 
  103576             : //############################################################################
  103577             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  103578             :  * within the memory pool and resets the freepointers, in order to achieve a 
  103579             :  * linked list, that has no jumps and starts at the beginning! This function 
  103580             :  * does not extend the memory pool, since we do not delete any memory blocks,
  103581             :  * but delete the valid objects.  
  103582             :  */
  103583             : void
  103584           0 : SgIdentDirectiveStatement::clearMemoryPool( )
  103585             :    {
  103586             :   // printf ("Inside of SgIdentDirectiveStatement::clearMemoryPool() \n");
  103587             : 
  103588           0 :      SgIdentDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  103589           0 :      std::vector < unsigned char* > :: const_iterator block;
  103590           0 :      if ( SgIdentDirectiveStatement::pools.empty() == false )
  103591             :         {
  103592           0 :           block = SgIdentDirectiveStatement::pools.begin() ;
  103593           0 :           SgIdentDirectiveStatement::next_node = (SgIdentDirectiveStatement*) (*block);
  103594             : 
  103595           0 :           while ( block != SgIdentDirectiveStatement::pools.end() )
  103596             :              {
  103597           0 :                pointer = (SgIdentDirectiveStatement*) (*block);
  103598           0 :                if ( tempPointer != NULL )
  103599             :                   {
  103600           0 :                     tempPointer->set_freepointer(pointer);
  103601             :                   }
  103602           0 :                for (unsigned i = 0; i < SgIdentDirectiveStatement::pool_size - 1; ++i)
  103603             :                   {
  103604           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  103605             :                   }
  103606           0 :                 pointer[SgIdentDirectiveStatement::pool_size-1].set_freepointer(NULL);
  103607           0 :                 tempPointer = &(pointer[SgIdentDirectiveStatement::pool_size-1]);
  103608           0 :                 ++block;
  103609             :              }
  103610             :         }
  103611           0 :    }
  103612             : 
  103613           5 : void SgIdentDirectiveStatement::deleteMemoryPool() {
  103614           5 :   for (auto p: SgIdentDirectiveStatement::pools) {
  103615           0 :     ROSE_FREE(p);
  103616             :   }
  103617           5 :   SgIdentDirectiveStatement::next_node = nullptr;
  103618           5 :   SgIdentDirectiveStatement::pools.clear();
  103619           5 : }
  103620             : 
  103621             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  103622             : //                 reading multiple binary files to for a single AST.
  103623             : /////////// new version ////////////////////////////////
  103624             : //############################################################################
  103625             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  103626             : void
  103627           2 : SgIdentDirectiveStatement::extendMemoryPoolForFileIO( )
  103628             :   {
  103629           2 :     size_t blockIndex = SgIdentDirectiveStatement::pools.size();
  103630           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIdentDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIdentDirectiveStatement);
  103631             : 
  103632           2 :     while ( (blockIndex * SgIdentDirectiveStatement::pool_size) < newPoolSize)
  103633             :       {
  103634             : #if ROSE_ALLOC_TRACE
  103635             :         if (blockIndex > 0) {
  103636             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIdentDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIdentDirectiveStatement) = %" PRIuPTR " SgIdentDirectiveStatement::pool_size = %d \n",
  103637             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIdentDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIdentDirectiveStatement),SgIdentDirectiveStatement::pool_size);
  103638             :         }
  103639             : #endif
  103640             : 
  103641           0 :         SgIdentDirectiveStatement * pointer = (SgIdentDirectiveStatement*) ROSE_MALLOC ( SgIdentDirectiveStatement::pool_size * sizeof(SgIdentDirectiveStatement) );
  103642           0 :         assert( pointer != NULL );
  103643             : #if ROSE_ALLOC_MEMSET == 1
  103644             :         memset(pointer, 0x00, SgIdentDirectiveStatement::pool_size * sizeof(SgIdentDirectiveStatement));
  103645             : #elif ROSE_ALLOC_MEMSET == 2
  103646             :         memset(pointer, 0xCC, SgIdentDirectiveStatement::pool_size * sizeof(SgIdentDirectiveStatement));
  103647             : #endif
  103648           0 :         SgIdentDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  103649           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIdentDirectiveStatement::pool_size * sizeof(SgIdentDirectiveStatement), V_SgIdentDirectiveStatement ) );
  103650             : 
  103651           0 :         if ( SgIdentDirectiveStatement::next_node != NULL ) {
  103652           0 :           if ( blockIndex > 0 ) {
  103653           0 :             SgIdentDirectiveStatement * blkptr = (SgIdentDirectiveStatement*)(SgIdentDirectiveStatement::pools[blockIndex-1]);
  103654           0 :             blkptr[ SgIdentDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  103655             :           }
  103656             :         } else {
  103657           0 :           SgIdentDirectiveStatement::next_node = pointer;
  103658             :         }
  103659             : 
  103660           0 :         for (unsigned i = 0; i < SgIdentDirectiveStatement::pool_size-1; ++i)
  103661             :            {
  103662           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  103663             :            }
  103664           0 :         pointer[ SgIdentDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  103665             : 
  103666           0 :         blockIndex++;
  103667             :       }
  103668           2 :   }
  103669             : 
  103670             : //############################################################################
  103671             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  103672             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  103673             :  * not compressed. However, that stuff is not yet implemented! 
  103674             :  */
  103675             : unsigned long
  103676           0 : SgIdentDirectiveStatement::getNumberOfLastValidPointer()
  103677             :    {
  103678           0 :       SgIdentDirectiveStatement* testPointer = (SgIdentDirectiveStatement*)(SgIdentDirectiveStatement::pools.back());
  103679           0 :       unsigned long localIndex = SgIdentDirectiveStatement::pool_size - 1;
  103680           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  103681             :          {
  103682           0 :            localIndex--;
  103683             :          }
  103684           0 :       return (localIndex + SgIdentDirectiveStatement::pool_size * (SgIdentDirectiveStatement::pools.size()-1));
  103685             :    }
  103686             : 
  103687             : //############################################################################
  103688             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  103689             :  * memory pool and initializes the data member in class SgIdentDirectiveStatementStroageClass
  103690             :  * from its counterpart of SgIdentDirectiveStatement. The return value is just for checking, 
  103691             :  * that the whole StorageClassArray is initialized!
  103692             :  */
  103693             : unsigned long
  103694           0 : SgIdentDirectiveStatement::initializeStorageClassArray( SgIdentDirectiveStatementStorageClass *storageArray )
  103695             :    {
  103696           0 :      unsigned long storageCounter = 0;
  103697           0 :      std::vector < unsigned char* > :: const_iterator block = SgIdentDirectiveStatement::pools.begin();
  103698           0 :      SgIdentDirectiveStatement* pointer = NULL;
  103699           0 :      while ( block != SgIdentDirectiveStatement::pools.end() ) {
  103700           0 :           pointer = (SgIdentDirectiveStatement*) (*block);
  103701           0 :           for ( unsigned i = 0; i < SgIdentDirectiveStatement::pool_size; ++i ) {
  103702           0 :                if ( pointer->get_freepointer() != NULL ) {
  103703           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  103704           0 :                  storageArray++;
  103705           0 :                  storageCounter++;
  103706             :                }
  103707           0 :                pointer++;
  103708             :              }
  103709           0 :            block++;
  103710             :         }
  103711           0 :      return storageCounter;
  103712             :    }
  103713             : 
  103714             : /* #line 103715 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  103715             : 
  103716             : 
  103717             : 
  103718             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  103719             : 
  103720             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  103721             : 
  103722             : //############################################################################
  103723             : /* JH (02/02/2006) Constructor of the IR node SgLinemarkerDirectiveStatement that takes its 
  103724             :  * corresponding StorageClass as parameter
  103725             :  */
  103726           0 : SgLinemarkerDirectiveStatement :: SgLinemarkerDirectiveStatement ( const SgLinemarkerDirectiveStatementStorageClass& storageSource )   : SgC_PreprocessorDirectiveStatement (storageSource)
  103727             :    {
  103728             : 
  103729             : 
  103730             : /* #line 103731 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  103731             : 
  103732           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  103733           0 :      p_linenumber = storageSource.storageOf_linenumber ;
  103734           0 :      p_filename = storageSource.storageOf_filename.rebuildDataStoredInEasyStorageClass() ;
  103735           0 :      p_flaglist = storageSource.storageOf_flaglist.rebuildDataStoredInEasyStorageClass() ;
  103736             : 
  103737             : 
  103738             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  103739             : 
  103740             : 
  103741           0 :    }
  103742             : 
  103743             : //############################################################################
  103744             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  103745             :  * within the working AST. 
  103746             :  */
  103747           0 : SgLinemarkerDirectiveStatement * SgLinemarkerDirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  103748           0 :      SgLinemarkerDirectiveStatement* returnPointer = NULL;
  103749           0 :      if ( globalIndex != 0 )
  103750             :         {
  103751             : 
  103752             : #if FILE_IO_EXTRA_CHECK
  103753           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLinemarkerDirectiveStatement ) ) <= globalIndex ) ;
  103754           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLinemarkerDirectiveStatement + 1 ) ) );
  103755             : #endif
  103756           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLinemarkerDirectiveStatement )  
  103757           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLinemarkerDirectiveStatement );
  103758           0 :           unsigned long positionInPool = localIndex % SgLinemarkerDirectiveStatement::pool_size;
  103759           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLinemarkerDirectiveStatement::pool_size;
  103760             : 
  103761             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  103762             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  103763             : 
  103764           0 :           returnPointer = &( ( (SgLinemarkerDirectiveStatement*)(SgLinemarkerDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  103765             : 
  103766           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  103767             :         }
  103768           0 :      return returnPointer ;
  103769             :    }
  103770             : 
  103771             : //############################################################################
  103772             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  103773             :   for the AST with the index astIndex
  103774             : */
  103775           0 : SgLinemarkerDirectiveStatement * SgLinemarkerDirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  103776           0 :      SgLinemarkerDirectiveStatement* returnPointer = NULL;
  103777           0 :      if ( globalIndex != 0 )
  103778             :         {
  103779             : 
  103780             : #if FILE_IO_EXTRA_CHECK
  103781           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLinemarkerDirectiveStatement ) ) <= globalIndex ) ;
  103782           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLinemarkerDirectiveStatement + 1 ) ) );
  103783             : #endif
  103784           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLinemarkerDirectiveStatement )
  103785           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLinemarkerDirectiveStatement );
  103786           0 :           unsigned long positionInPool = localIndex % SgLinemarkerDirectiveStatement::pool_size ;
  103787           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLinemarkerDirectiveStatement::pool_size ;
  103788             : 
  103789             : #if FILE_IO_EXTRA_CHECK
  103790             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  103791             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  103792             : #endif
  103793             : 
  103794           0 :           returnPointer = &( ( (SgLinemarkerDirectiveStatement*)(SgLinemarkerDirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  103795             : 
  103796             : #if FILE_IO_EXTRA_CHECK
  103797           0 :           assert ( returnPointer != NULL ) ;
  103798             : #endif
  103799             :         }
  103800           0 :      return returnPointer ;
  103801             :    }
  103802             : 
  103803             : //############################################################################
  103804             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  103805             :  * pool size! We set for every valid object in the memory pool the freepointer
  103806             :  * to the global index and increase the global index afterwards. For all the 
  103807             :  * invalid objects (means address ranges within the memory pool that were not
  103808             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  103809             :  * distinguish valid from invalid objects! 
  103810             :  */
  103811             : unsigned long
  103812           5 : SgLinemarkerDirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  103813             :    {
  103814           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  103815           5 :      SgLinemarkerDirectiveStatement* pointer = NULL;
  103816           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  103817           5 :      std::vector < unsigned char* > :: const_iterator block;
  103818           5 :      for ( block = SgLinemarkerDirectiveStatement::pools.begin(); block != SgLinemarkerDirectiveStatement::pools.end() ; ++block )
  103819             :         {
  103820           0 :           pointer = (SgLinemarkerDirectiveStatement*)(*block);
  103821           0 :           for (unsigned i = 0; i < SgLinemarkerDirectiveStatement::pool_size; ++i )
  103822             :              {
  103823             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  103824             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  103825             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  103826             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  103827             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  103828             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  103829             :             // properly; so this will have to be checked next.
  103830             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  103831             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  103832           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  103833             :                   {
  103834           0 :                     pointer[i].set_freepointer((SgLinemarkerDirectiveStatement*)(globalIndex));
  103835           0 :                     globalIndex++;
  103836             :                   }
  103837             :                else
  103838             :                   {
  103839           0 :                     pointer[i].set_freepointer(NULL);
  103840             :                   }
  103841             :               }
  103842             :         }
  103843           5 :      return globalIndex;
  103844             :    }
  103845             : 
  103846             : //############################################################################
  103847             : // JH (01/14/2006)
  103848             : void
  103849           5 : SgLinemarkerDirectiveStatement::resetValidFreepointers( )
  103850             :    {
  103851           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  103852           5 :      SgLinemarkerDirectiveStatement* pointer = NULL;
  103853           5 :      std::vector < unsigned char* > :: const_iterator block;
  103854           5 :      SgLinemarkerDirectiveStatement* pointerOfLinkedList = NULL;
  103855           5 :      for ( block = SgLinemarkerDirectiveStatement::pools.begin(); block != SgLinemarkerDirectiveStatement::pools.end() ; ++block )
  103856             :         {
  103857           0 :           pointer = (SgLinemarkerDirectiveStatement*)(*block);
  103858           0 :           for (unsigned i = 0; i < SgLinemarkerDirectiveStatement::pool_size; ++i )
  103859             :              {
  103860             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  103861             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  103862             :             // memory blocks!.
  103863           0 :                if ( pointer[i].get_freepointer() != NULL )
  103864             :                   {
  103865           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  103866             :                   }
  103867             :                else
  103868             :                   {
  103869           0 :                     if ( pointerOfLinkedList == NULL )
  103870             :                        {
  103871           0 :                          SgLinemarkerDirectiveStatement::next_node = &(pointer[i]);
  103872             :                        }
  103873             :                     else
  103874             :                        {
  103875             :                       // printf ("In SgLinemarkerDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  103876           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  103877             :                        }
  103878             :                     pointerOfLinkedList = &(pointer[i]);
  103879             :                   }
  103880             :               }
  103881             :         }
  103882             : 
  103883           5 :      if ( pointerOfLinkedList != NULL )
  103884             :         {
  103885             :        // printf ("In SgLinemarkerDirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  103886           0 :           pointerOfLinkedList->set_freepointer(NULL);
  103887             :        // DQ (6/6/2010): Temporary debugging...
  103888             :        //   ROSE_ASSERT(false);
  103889             :         }
  103890             : 
  103891           5 :      return ;
  103892             :    }
  103893             : 
  103894             : //############################################################################
  103895             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  103896             :  * within the memory pool and resets the freepointers, in order to achieve a 
  103897             :  * linked list, that has no jumps and starts at the beginning! This function 
  103898             :  * does not extend the memory pool, since we do not delete any memory blocks,
  103899             :  * but delete the valid objects.  
  103900             :  */
  103901             : void
  103902           0 : SgLinemarkerDirectiveStatement::clearMemoryPool( )
  103903             :    {
  103904             :   // printf ("Inside of SgLinemarkerDirectiveStatement::clearMemoryPool() \n");
  103905             : 
  103906           0 :      SgLinemarkerDirectiveStatement* pointer = NULL, *tempPointer = NULL;
  103907           0 :      std::vector < unsigned char* > :: const_iterator block;
  103908           0 :      if ( SgLinemarkerDirectiveStatement::pools.empty() == false )
  103909             :         {
  103910           0 :           block = SgLinemarkerDirectiveStatement::pools.begin() ;
  103911           0 :           SgLinemarkerDirectiveStatement::next_node = (SgLinemarkerDirectiveStatement*) (*block);
  103912             : 
  103913           0 :           while ( block != SgLinemarkerDirectiveStatement::pools.end() )
  103914             :              {
  103915           0 :                pointer = (SgLinemarkerDirectiveStatement*) (*block);
  103916           0 :                if ( tempPointer != NULL )
  103917             :                   {
  103918           0 :                     tempPointer->set_freepointer(pointer);
  103919             :                   }
  103920           0 :                for (unsigned i = 0; i < SgLinemarkerDirectiveStatement::pool_size - 1; ++i)
  103921             :                   {
  103922           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  103923             :                   }
  103924           0 :                 pointer[SgLinemarkerDirectiveStatement::pool_size-1].set_freepointer(NULL);
  103925           0 :                 tempPointer = &(pointer[SgLinemarkerDirectiveStatement::pool_size-1]);
  103926           0 :                 ++block;
  103927             :              }
  103928             :         }
  103929           0 :    }
  103930             : 
  103931           5 : void SgLinemarkerDirectiveStatement::deleteMemoryPool() {
  103932           5 :   for (auto p: SgLinemarkerDirectiveStatement::pools) {
  103933           0 :     ROSE_FREE(p);
  103934             :   }
  103935           5 :   SgLinemarkerDirectiveStatement::next_node = nullptr;
  103936           5 :   SgLinemarkerDirectiveStatement::pools.clear();
  103937           5 : }
  103938             : 
  103939             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  103940             : //                 reading multiple binary files to for a single AST.
  103941             : /////////// new version ////////////////////////////////
  103942             : //############################################################################
  103943             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  103944             : void
  103945           2 : SgLinemarkerDirectiveStatement::extendMemoryPoolForFileIO( )
  103946             :   {
  103947           2 :     size_t blockIndex = SgLinemarkerDirectiveStatement::pools.size();
  103948           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLinemarkerDirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLinemarkerDirectiveStatement);
  103949             : 
  103950           2 :     while ( (blockIndex * SgLinemarkerDirectiveStatement::pool_size) < newPoolSize)
  103951             :       {
  103952             : #if ROSE_ALLOC_TRACE
  103953             :         if (blockIndex > 0) {
  103954             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLinemarkerDirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLinemarkerDirectiveStatement) = %" PRIuPTR " SgLinemarkerDirectiveStatement::pool_size = %d \n",
  103955             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLinemarkerDirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLinemarkerDirectiveStatement),SgLinemarkerDirectiveStatement::pool_size);
  103956             :         }
  103957             : #endif
  103958             : 
  103959           0 :         SgLinemarkerDirectiveStatement * pointer = (SgLinemarkerDirectiveStatement*) ROSE_MALLOC ( SgLinemarkerDirectiveStatement::pool_size * sizeof(SgLinemarkerDirectiveStatement) );
  103960           0 :         assert( pointer != NULL );
  103961             : #if ROSE_ALLOC_MEMSET == 1
  103962             :         memset(pointer, 0x00, SgLinemarkerDirectiveStatement::pool_size * sizeof(SgLinemarkerDirectiveStatement));
  103963             : #elif ROSE_ALLOC_MEMSET == 2
  103964             :         memset(pointer, 0xCC, SgLinemarkerDirectiveStatement::pool_size * sizeof(SgLinemarkerDirectiveStatement));
  103965             : #endif
  103966           0 :         SgLinemarkerDirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  103967           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLinemarkerDirectiveStatement::pool_size * sizeof(SgLinemarkerDirectiveStatement), V_SgLinemarkerDirectiveStatement ) );
  103968             : 
  103969           0 :         if ( SgLinemarkerDirectiveStatement::next_node != NULL ) {
  103970           0 :           if ( blockIndex > 0 ) {
  103971           0 :             SgLinemarkerDirectiveStatement * blkptr = (SgLinemarkerDirectiveStatement*)(SgLinemarkerDirectiveStatement::pools[blockIndex-1]);
  103972           0 :             blkptr[ SgLinemarkerDirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  103973             :           }
  103974             :         } else {
  103975           0 :           SgLinemarkerDirectiveStatement::next_node = pointer;
  103976             :         }
  103977             : 
  103978           0 :         for (unsigned i = 0; i < SgLinemarkerDirectiveStatement::pool_size-1; ++i)
  103979             :            {
  103980           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  103981             :            }
  103982           0 :         pointer[ SgLinemarkerDirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  103983             : 
  103984           0 :         blockIndex++;
  103985             :       }
  103986           2 :   }
  103987             : 
  103988             : //############################################################################
  103989             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  103990             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  103991             :  * not compressed. However, that stuff is not yet implemented! 
  103992             :  */
  103993             : unsigned long
  103994           0 : SgLinemarkerDirectiveStatement::getNumberOfLastValidPointer()
  103995             :    {
  103996           0 :       SgLinemarkerDirectiveStatement* testPointer = (SgLinemarkerDirectiveStatement*)(SgLinemarkerDirectiveStatement::pools.back());
  103997           0 :       unsigned long localIndex = SgLinemarkerDirectiveStatement::pool_size - 1;
  103998           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  103999             :          {
  104000           0 :            localIndex--;
  104001             :          }
  104002           0 :       return (localIndex + SgLinemarkerDirectiveStatement::pool_size * (SgLinemarkerDirectiveStatement::pools.size()-1));
  104003             :    }
  104004             : 
  104005             : //############################################################################
  104006             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  104007             :  * memory pool and initializes the data member in class SgLinemarkerDirectiveStatementStroageClass
  104008             :  * from its counterpart of SgLinemarkerDirectiveStatement. The return value is just for checking, 
  104009             :  * that the whole StorageClassArray is initialized!
  104010             :  */
  104011             : unsigned long
  104012           0 : SgLinemarkerDirectiveStatement::initializeStorageClassArray( SgLinemarkerDirectiveStatementStorageClass *storageArray )
  104013             :    {
  104014           0 :      unsigned long storageCounter = 0;
  104015           0 :      std::vector < unsigned char* > :: const_iterator block = SgLinemarkerDirectiveStatement::pools.begin();
  104016           0 :      SgLinemarkerDirectiveStatement* pointer = NULL;
  104017           0 :      while ( block != SgLinemarkerDirectiveStatement::pools.end() ) {
  104018           0 :           pointer = (SgLinemarkerDirectiveStatement*) (*block);
  104019           0 :           for ( unsigned i = 0; i < SgLinemarkerDirectiveStatement::pool_size; ++i ) {
  104020           0 :                if ( pointer->get_freepointer() != NULL ) {
  104021           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  104022           0 :                  storageArray++;
  104023           0 :                  storageCounter++;
  104024             :                }
  104025           0 :                pointer++;
  104026             :              }
  104027           0 :            block++;
  104028             :         }
  104029           0 :      return storageCounter;
  104030             :    }
  104031             : 
  104032             : /* #line 104033 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  104033             : 
  104034             : 
  104035             : 
  104036             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  104037             : 
  104038             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  104039             : 
  104040             : //############################################################################
  104041             : /* JH (02/02/2006) Constructor of the IR node SgOmpThreadprivateStatement that takes its 
  104042             :  * corresponding StorageClass as parameter
  104043             :  */
  104044           0 : SgOmpThreadprivateStatement :: SgOmpThreadprivateStatement ( const SgOmpThreadprivateStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  104045             :    {
  104046             : 
  104047             : 
  104048             : /* #line 104049 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  104049             : 
  104050           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  104051           0 :      p_variables = storageSource.storageOf_variables.rebuildDataStoredInEasyStorageClass() ;
  104052           0 :      SgVarRefExpPtrList::iterator i_variables = p_variables.begin() ; 
  104053           0 :      for ( ; i_variables != p_variables.end(); ++i_variables ) 
  104054             :         {
  104055           0 :           (*i_variables) = (SgVarRefExpPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_variables) ) );
  104056             :         }
  104057             : 
  104058             : 
  104059             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  104060             : 
  104061             : 
  104062           0 :    }
  104063             : 
  104064             : //############################################################################
  104065             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  104066             :  * within the working AST. 
  104067             :  */
  104068           0 : SgOmpThreadprivateStatement * SgOmpThreadprivateStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  104069           0 :      SgOmpThreadprivateStatement* returnPointer = NULL;
  104070           0 :      if ( globalIndex != 0 )
  104071             :         {
  104072             : 
  104073             : #if FILE_IO_EXTRA_CHECK
  104074           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpThreadprivateStatement ) ) <= globalIndex ) ;
  104075           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpThreadprivateStatement + 1 ) ) );
  104076             : #endif
  104077           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpThreadprivateStatement )  
  104078           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpThreadprivateStatement );
  104079           0 :           unsigned long positionInPool = localIndex % SgOmpThreadprivateStatement::pool_size;
  104080           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpThreadprivateStatement::pool_size;
  104081             : 
  104082             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  104083             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  104084             : 
  104085           0 :           returnPointer = &( ( (SgOmpThreadprivateStatement*)(SgOmpThreadprivateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  104086             : 
  104087           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  104088             :         }
  104089           0 :      return returnPointer ;
  104090             :    }
  104091             : 
  104092             : //############################################################################
  104093             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  104094             :   for the AST with the index astIndex
  104095             : */
  104096           0 : SgOmpThreadprivateStatement * SgOmpThreadprivateStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  104097           0 :      SgOmpThreadprivateStatement* returnPointer = NULL;
  104098           0 :      if ( globalIndex != 0 )
  104099             :         {
  104100             : 
  104101             : #if FILE_IO_EXTRA_CHECK
  104102           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpThreadprivateStatement ) ) <= globalIndex ) ;
  104103           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpThreadprivateStatement + 1 ) ) );
  104104             : #endif
  104105           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpThreadprivateStatement )
  104106           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpThreadprivateStatement );
  104107           0 :           unsigned long positionInPool = localIndex % SgOmpThreadprivateStatement::pool_size ;
  104108           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpThreadprivateStatement::pool_size ;
  104109             : 
  104110             : #if FILE_IO_EXTRA_CHECK
  104111             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  104112             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  104113             : #endif
  104114             : 
  104115           0 :           returnPointer = &( ( (SgOmpThreadprivateStatement*)(SgOmpThreadprivateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  104116             : 
  104117             : #if FILE_IO_EXTRA_CHECK
  104118           0 :           assert ( returnPointer != NULL ) ;
  104119             : #endif
  104120             :         }
  104121           0 :      return returnPointer ;
  104122             :    }
  104123             : 
  104124             : //############################################################################
  104125             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  104126             :  * pool size! We set for every valid object in the memory pool the freepointer
  104127             :  * to the global index and increase the global index afterwards. For all the 
  104128             :  * invalid objects (means address ranges within the memory pool that were not
  104129             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  104130             :  * distinguish valid from invalid objects! 
  104131             :  */
  104132             : unsigned long
  104133           5 : SgOmpThreadprivateStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  104134             :    {
  104135           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  104136           5 :      SgOmpThreadprivateStatement* pointer = NULL;
  104137           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  104138           5 :      std::vector < unsigned char* > :: const_iterator block;
  104139           5 :      for ( block = SgOmpThreadprivateStatement::pools.begin(); block != SgOmpThreadprivateStatement::pools.end() ; ++block )
  104140             :         {
  104141           0 :           pointer = (SgOmpThreadprivateStatement*)(*block);
  104142           0 :           for (unsigned i = 0; i < SgOmpThreadprivateStatement::pool_size; ++i )
  104143             :              {
  104144             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  104145             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  104146             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  104147             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  104148             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  104149             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  104150             :             // properly; so this will have to be checked next.
  104151             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  104152             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  104153           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  104154             :                   {
  104155           0 :                     pointer[i].set_freepointer((SgOmpThreadprivateStatement*)(globalIndex));
  104156           0 :                     globalIndex++;
  104157             :                   }
  104158             :                else
  104159             :                   {
  104160           0 :                     pointer[i].set_freepointer(NULL);
  104161             :                   }
  104162             :               }
  104163             :         }
  104164           5 :      return globalIndex;
  104165             :    }
  104166             : 
  104167             : //############################################################################
  104168             : // JH (01/14/2006)
  104169             : void
  104170           5 : SgOmpThreadprivateStatement::resetValidFreepointers( )
  104171             :    {
  104172           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  104173           5 :      SgOmpThreadprivateStatement* pointer = NULL;
  104174           5 :      std::vector < unsigned char* > :: const_iterator block;
  104175           5 :      SgOmpThreadprivateStatement* pointerOfLinkedList = NULL;
  104176           5 :      for ( block = SgOmpThreadprivateStatement::pools.begin(); block != SgOmpThreadprivateStatement::pools.end() ; ++block )
  104177             :         {
  104178           0 :           pointer = (SgOmpThreadprivateStatement*)(*block);
  104179           0 :           for (unsigned i = 0; i < SgOmpThreadprivateStatement::pool_size; ++i )
  104180             :              {
  104181             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  104182             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  104183             :             // memory blocks!.
  104184           0 :                if ( pointer[i].get_freepointer() != NULL )
  104185             :                   {
  104186           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  104187             :                   }
  104188             :                else
  104189             :                   {
  104190           0 :                     if ( pointerOfLinkedList == NULL )
  104191             :                        {
  104192           0 :                          SgOmpThreadprivateStatement::next_node = &(pointer[i]);
  104193             :                        }
  104194             :                     else
  104195             :                        {
  104196             :                       // printf ("In SgOmpThreadprivateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  104197           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  104198             :                        }
  104199             :                     pointerOfLinkedList = &(pointer[i]);
  104200             :                   }
  104201             :               }
  104202             :         }
  104203             : 
  104204           5 :      if ( pointerOfLinkedList != NULL )
  104205             :         {
  104206             :        // printf ("In SgOmpThreadprivateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  104207           0 :           pointerOfLinkedList->set_freepointer(NULL);
  104208             :        // DQ (6/6/2010): Temporary debugging...
  104209             :        //   ROSE_ASSERT(false);
  104210             :         }
  104211             : 
  104212           5 :      return ;
  104213             :    }
  104214             : 
  104215             : //############################################################################
  104216             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  104217             :  * within the memory pool and resets the freepointers, in order to achieve a 
  104218             :  * linked list, that has no jumps and starts at the beginning! This function 
  104219             :  * does not extend the memory pool, since we do not delete any memory blocks,
  104220             :  * but delete the valid objects.  
  104221             :  */
  104222             : void
  104223           0 : SgOmpThreadprivateStatement::clearMemoryPool( )
  104224             :    {
  104225             :   // printf ("Inside of SgOmpThreadprivateStatement::clearMemoryPool() \n");
  104226             : 
  104227           0 :      SgOmpThreadprivateStatement* pointer = NULL, *tempPointer = NULL;
  104228           0 :      std::vector < unsigned char* > :: const_iterator block;
  104229           0 :      if ( SgOmpThreadprivateStatement::pools.empty() == false )
  104230             :         {
  104231           0 :           block = SgOmpThreadprivateStatement::pools.begin() ;
  104232           0 :           SgOmpThreadprivateStatement::next_node = (SgOmpThreadprivateStatement*) (*block);
  104233             : 
  104234           0 :           while ( block != SgOmpThreadprivateStatement::pools.end() )
  104235             :              {
  104236           0 :                pointer = (SgOmpThreadprivateStatement*) (*block);
  104237           0 :                if ( tempPointer != NULL )
  104238             :                   {
  104239           0 :                     tempPointer->set_freepointer(pointer);
  104240             :                   }
  104241           0 :                for (unsigned i = 0; i < SgOmpThreadprivateStatement::pool_size - 1; ++i)
  104242             :                   {
  104243           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  104244             :                   }
  104245           0 :                 pointer[SgOmpThreadprivateStatement::pool_size-1].set_freepointer(NULL);
  104246           0 :                 tempPointer = &(pointer[SgOmpThreadprivateStatement::pool_size-1]);
  104247           0 :                 ++block;
  104248             :              }
  104249             :         }
  104250           0 :    }
  104251             : 
  104252           5 : void SgOmpThreadprivateStatement::deleteMemoryPool() {
  104253           5 :   for (auto p: SgOmpThreadprivateStatement::pools) {
  104254           0 :     ROSE_FREE(p);
  104255             :   }
  104256           5 :   SgOmpThreadprivateStatement::next_node = nullptr;
  104257           5 :   SgOmpThreadprivateStatement::pools.clear();
  104258           5 : }
  104259             : 
  104260             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  104261             : //                 reading multiple binary files to for a single AST.
  104262             : /////////// new version ////////////////////////////////
  104263             : //############################################################################
  104264             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  104265             : void
  104266           2 : SgOmpThreadprivateStatement::extendMemoryPoolForFileIO( )
  104267             :   {
  104268           2 :     size_t blockIndex = SgOmpThreadprivateStatement::pools.size();
  104269           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadprivateStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadprivateStatement);
  104270             : 
  104271           2 :     while ( (blockIndex * SgOmpThreadprivateStatement::pool_size) < newPoolSize)
  104272             :       {
  104273             : #if ROSE_ALLOC_TRACE
  104274             :         if (blockIndex > 0) {
  104275             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadprivateStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadprivateStatement) = %" PRIuPTR " SgOmpThreadprivateStatement::pool_size = %d \n",
  104276             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpThreadprivateStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpThreadprivateStatement),SgOmpThreadprivateStatement::pool_size);
  104277             :         }
  104278             : #endif
  104279             : 
  104280           0 :         SgOmpThreadprivateStatement * pointer = (SgOmpThreadprivateStatement*) ROSE_MALLOC ( SgOmpThreadprivateStatement::pool_size * sizeof(SgOmpThreadprivateStatement) );
  104281           0 :         assert( pointer != NULL );
  104282             : #if ROSE_ALLOC_MEMSET == 1
  104283             :         memset(pointer, 0x00, SgOmpThreadprivateStatement::pool_size * sizeof(SgOmpThreadprivateStatement));
  104284             : #elif ROSE_ALLOC_MEMSET == 2
  104285             :         memset(pointer, 0xCC, SgOmpThreadprivateStatement::pool_size * sizeof(SgOmpThreadprivateStatement));
  104286             : #endif
  104287           0 :         SgOmpThreadprivateStatement::pools.push_back( (unsigned char*)(pointer) );
  104288           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpThreadprivateStatement::pool_size * sizeof(SgOmpThreadprivateStatement), V_SgOmpThreadprivateStatement ) );
  104289             : 
  104290           0 :         if ( SgOmpThreadprivateStatement::next_node != NULL ) {
  104291           0 :           if ( blockIndex > 0 ) {
  104292           0 :             SgOmpThreadprivateStatement * blkptr = (SgOmpThreadprivateStatement*)(SgOmpThreadprivateStatement::pools[blockIndex-1]);
  104293           0 :             blkptr[ SgOmpThreadprivateStatement::pool_size - 1 ].set_freepointer(pointer);
  104294             :           }
  104295             :         } else {
  104296           0 :           SgOmpThreadprivateStatement::next_node = pointer;
  104297             :         }
  104298             : 
  104299           0 :         for (unsigned i = 0; i < SgOmpThreadprivateStatement::pool_size-1; ++i)
  104300             :            {
  104301           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  104302             :            }
  104303           0 :         pointer[ SgOmpThreadprivateStatement::pool_size -1 ].set_freepointer(NULL);
  104304             : 
  104305           0 :         blockIndex++;
  104306             :       }
  104307           2 :   }
  104308             : 
  104309             : //############################################################################
  104310             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  104311             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  104312             :  * not compressed. However, that stuff is not yet implemented! 
  104313             :  */
  104314             : unsigned long
  104315           0 : SgOmpThreadprivateStatement::getNumberOfLastValidPointer()
  104316             :    {
  104317           0 :       SgOmpThreadprivateStatement* testPointer = (SgOmpThreadprivateStatement*)(SgOmpThreadprivateStatement::pools.back());
  104318           0 :       unsigned long localIndex = SgOmpThreadprivateStatement::pool_size - 1;
  104319           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  104320             :          {
  104321           0 :            localIndex--;
  104322             :          }
  104323           0 :       return (localIndex + SgOmpThreadprivateStatement::pool_size * (SgOmpThreadprivateStatement::pools.size()-1));
  104324             :    }
  104325             : 
  104326             : //############################################################################
  104327             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  104328             :  * memory pool and initializes the data member in class SgOmpThreadprivateStatementStroageClass
  104329             :  * from its counterpart of SgOmpThreadprivateStatement. The return value is just for checking, 
  104330             :  * that the whole StorageClassArray is initialized!
  104331             :  */
  104332             : unsigned long
  104333           0 : SgOmpThreadprivateStatement::initializeStorageClassArray( SgOmpThreadprivateStatementStorageClass *storageArray )
  104334             :    {
  104335           0 :      unsigned long storageCounter = 0;
  104336           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpThreadprivateStatement::pools.begin();
  104337           0 :      SgOmpThreadprivateStatement* pointer = NULL;
  104338           0 :      while ( block != SgOmpThreadprivateStatement::pools.end() ) {
  104339           0 :           pointer = (SgOmpThreadprivateStatement*) (*block);
  104340           0 :           for ( unsigned i = 0; i < SgOmpThreadprivateStatement::pool_size; ++i ) {
  104341           0 :                if ( pointer->get_freepointer() != NULL ) {
  104342           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  104343           0 :                  storageArray++;
  104344           0 :                  storageCounter++;
  104345             :                }
  104346           0 :                pointer++;
  104347             :              }
  104348           0 :            block++;
  104349             :         }
  104350           0 :      return storageCounter;
  104351             :    }
  104352             : 
  104353             : /* #line 104354 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  104354             : 
  104355             : 
  104356             : 
  104357             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  104358             : 
  104359             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  104360             : 
  104361             : //############################################################################
  104362             : /* JH (02/02/2006) Constructor of the IR node SgOmpRequiresStatement that takes its 
  104363             :  * corresponding StorageClass as parameter
  104364             :  */
  104365           0 : SgOmpRequiresStatement :: SgOmpRequiresStatement ( const SgOmpRequiresStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  104366             :    {
  104367             : 
  104368             : 
  104369             : /* #line 104370 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  104370             : 
  104371           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  104372           0 :      p_clauses = storageSource.storageOf_clauses.rebuildDataStoredInEasyStorageClass() ;
  104373           0 :      SgOmpClausePtrList::iterator i_clauses = p_clauses.begin() ; 
  104374           0 :      for ( ; i_clauses != p_clauses.end(); ++i_clauses ) 
  104375             :         {
  104376           0 :           (*i_clauses) = (SgOmpClausePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_clauses) ) );
  104377             :         }
  104378             : 
  104379             : 
  104380             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  104381             : 
  104382             : 
  104383           0 :    }
  104384             : 
  104385             : //############################################################################
  104386             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  104387             :  * within the working AST. 
  104388             :  */
  104389           0 : SgOmpRequiresStatement * SgOmpRequiresStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  104390           0 :      SgOmpRequiresStatement* returnPointer = NULL;
  104391           0 :      if ( globalIndex != 0 )
  104392             :         {
  104393             : 
  104394             : #if FILE_IO_EXTRA_CHECK
  104395           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpRequiresStatement ) ) <= globalIndex ) ;
  104396           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpRequiresStatement + 1 ) ) );
  104397             : #endif
  104398           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpRequiresStatement )  
  104399           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpRequiresStatement );
  104400           0 :           unsigned long positionInPool = localIndex % SgOmpRequiresStatement::pool_size;
  104401           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpRequiresStatement::pool_size;
  104402             : 
  104403             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  104404             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  104405             : 
  104406           0 :           returnPointer = &( ( (SgOmpRequiresStatement*)(SgOmpRequiresStatement::pools[memoryBlock]) ) [positionInPool]) ;
  104407             : 
  104408           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  104409             :         }
  104410           0 :      return returnPointer ;
  104411             :    }
  104412             : 
  104413             : //############################################################################
  104414             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  104415             :   for the AST with the index astIndex
  104416             : */
  104417           0 : SgOmpRequiresStatement * SgOmpRequiresStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  104418           0 :      SgOmpRequiresStatement* returnPointer = NULL;
  104419           0 :      if ( globalIndex != 0 )
  104420             :         {
  104421             : 
  104422             : #if FILE_IO_EXTRA_CHECK
  104423           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpRequiresStatement ) ) <= globalIndex ) ;
  104424           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpRequiresStatement + 1 ) ) );
  104425             : #endif
  104426           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpRequiresStatement )
  104427           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpRequiresStatement );
  104428           0 :           unsigned long positionInPool = localIndex % SgOmpRequiresStatement::pool_size ;
  104429           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpRequiresStatement::pool_size ;
  104430             : 
  104431             : #if FILE_IO_EXTRA_CHECK
  104432             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  104433             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  104434             : #endif
  104435             : 
  104436           0 :           returnPointer = &( ( (SgOmpRequiresStatement*)(SgOmpRequiresStatement::pools[memoryBlock]) ) [positionInPool]) ;
  104437             : 
  104438             : #if FILE_IO_EXTRA_CHECK
  104439           0 :           assert ( returnPointer != NULL ) ;
  104440             : #endif
  104441             :         }
  104442           0 :      return returnPointer ;
  104443             :    }
  104444             : 
  104445             : //############################################################################
  104446             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  104447             :  * pool size! We set for every valid object in the memory pool the freepointer
  104448             :  * to the global index and increase the global index afterwards. For all the 
  104449             :  * invalid objects (means address ranges within the memory pool that were not
  104450             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  104451             :  * distinguish valid from invalid objects! 
  104452             :  */
  104453             : unsigned long
  104454           5 : SgOmpRequiresStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  104455             :    {
  104456           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  104457           5 :      SgOmpRequiresStatement* pointer = NULL;
  104458           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  104459           5 :      std::vector < unsigned char* > :: const_iterator block;
  104460           5 :      for ( block = SgOmpRequiresStatement::pools.begin(); block != SgOmpRequiresStatement::pools.end() ; ++block )
  104461             :         {
  104462           0 :           pointer = (SgOmpRequiresStatement*)(*block);
  104463           0 :           for (unsigned i = 0; i < SgOmpRequiresStatement::pool_size; ++i )
  104464             :              {
  104465             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  104466             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  104467             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  104468             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  104469             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  104470             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  104471             :             // properly; so this will have to be checked next.
  104472             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  104473             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  104474           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  104475             :                   {
  104476           0 :                     pointer[i].set_freepointer((SgOmpRequiresStatement*)(globalIndex));
  104477           0 :                     globalIndex++;
  104478             :                   }
  104479             :                else
  104480             :                   {
  104481           0 :                     pointer[i].set_freepointer(NULL);
  104482             :                   }
  104483             :               }
  104484             :         }
  104485           5 :      return globalIndex;
  104486             :    }
  104487             : 
  104488             : //############################################################################
  104489             : // JH (01/14/2006)
  104490             : void
  104491           5 : SgOmpRequiresStatement::resetValidFreepointers( )
  104492             :    {
  104493           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  104494           5 :      SgOmpRequiresStatement* pointer = NULL;
  104495           5 :      std::vector < unsigned char* > :: const_iterator block;
  104496           5 :      SgOmpRequiresStatement* pointerOfLinkedList = NULL;
  104497           5 :      for ( block = SgOmpRequiresStatement::pools.begin(); block != SgOmpRequiresStatement::pools.end() ; ++block )
  104498             :         {
  104499           0 :           pointer = (SgOmpRequiresStatement*)(*block);
  104500           0 :           for (unsigned i = 0; i < SgOmpRequiresStatement::pool_size; ++i )
  104501             :              {
  104502             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  104503             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  104504             :             // memory blocks!.
  104505           0 :                if ( pointer[i].get_freepointer() != NULL )
  104506             :                   {
  104507           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  104508             :                   }
  104509             :                else
  104510             :                   {
  104511           0 :                     if ( pointerOfLinkedList == NULL )
  104512             :                        {
  104513           0 :                          SgOmpRequiresStatement::next_node = &(pointer[i]);
  104514             :                        }
  104515             :                     else
  104516             :                        {
  104517             :                       // printf ("In SgOmpRequiresStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  104518           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  104519             :                        }
  104520             :                     pointerOfLinkedList = &(pointer[i]);
  104521             :                   }
  104522             :               }
  104523             :         }
  104524             : 
  104525           5 :      if ( pointerOfLinkedList != NULL )
  104526             :         {
  104527             :        // printf ("In SgOmpRequiresStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  104528           0 :           pointerOfLinkedList->set_freepointer(NULL);
  104529             :        // DQ (6/6/2010): Temporary debugging...
  104530             :        //   ROSE_ASSERT(false);
  104531             :         }
  104532             : 
  104533           5 :      return ;
  104534             :    }
  104535             : 
  104536             : //############################################################################
  104537             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  104538             :  * within the memory pool and resets the freepointers, in order to achieve a 
  104539             :  * linked list, that has no jumps and starts at the beginning! This function 
  104540             :  * does not extend the memory pool, since we do not delete any memory blocks,
  104541             :  * but delete the valid objects.  
  104542             :  */
  104543             : void
  104544           0 : SgOmpRequiresStatement::clearMemoryPool( )
  104545             :    {
  104546             :   // printf ("Inside of SgOmpRequiresStatement::clearMemoryPool() \n");
  104547             : 
  104548           0 :      SgOmpRequiresStatement* pointer = NULL, *tempPointer = NULL;
  104549           0 :      std::vector < unsigned char* > :: const_iterator block;
  104550           0 :      if ( SgOmpRequiresStatement::pools.empty() == false )
  104551             :         {
  104552           0 :           block = SgOmpRequiresStatement::pools.begin() ;
  104553           0 :           SgOmpRequiresStatement::next_node = (SgOmpRequiresStatement*) (*block);
  104554             : 
  104555           0 :           while ( block != SgOmpRequiresStatement::pools.end() )
  104556             :              {
  104557           0 :                pointer = (SgOmpRequiresStatement*) (*block);
  104558           0 :                if ( tempPointer != NULL )
  104559             :                   {
  104560           0 :                     tempPointer->set_freepointer(pointer);
  104561             :                   }
  104562           0 :                for (unsigned i = 0; i < SgOmpRequiresStatement::pool_size - 1; ++i)
  104563             :                   {
  104564           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  104565             :                   }
  104566           0 :                 pointer[SgOmpRequiresStatement::pool_size-1].set_freepointer(NULL);
  104567           0 :                 tempPointer = &(pointer[SgOmpRequiresStatement::pool_size-1]);
  104568           0 :                 ++block;
  104569             :              }
  104570             :         }
  104571           0 :    }
  104572             : 
  104573           5 : void SgOmpRequiresStatement::deleteMemoryPool() {
  104574           5 :   for (auto p: SgOmpRequiresStatement::pools) {
  104575           0 :     ROSE_FREE(p);
  104576             :   }
  104577           5 :   SgOmpRequiresStatement::next_node = nullptr;
  104578           5 :   SgOmpRequiresStatement::pools.clear();
  104579           5 : }
  104580             : 
  104581             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  104582             : //                 reading multiple binary files to for a single AST.
  104583             : /////////// new version ////////////////////////////////
  104584             : //############################################################################
  104585             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  104586             : void
  104587           2 : SgOmpRequiresStatement::extendMemoryPoolForFileIO( )
  104588             :   {
  104589           2 :     size_t blockIndex = SgOmpRequiresStatement::pools.size();
  104590           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpRequiresStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpRequiresStatement);
  104591             : 
  104592           2 :     while ( (blockIndex * SgOmpRequiresStatement::pool_size) < newPoolSize)
  104593             :       {
  104594             : #if ROSE_ALLOC_TRACE
  104595             :         if (blockIndex > 0) {
  104596             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpRequiresStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpRequiresStatement) = %" PRIuPTR " SgOmpRequiresStatement::pool_size = %d \n",
  104597             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpRequiresStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpRequiresStatement),SgOmpRequiresStatement::pool_size);
  104598             :         }
  104599             : #endif
  104600             : 
  104601           0 :         SgOmpRequiresStatement * pointer = (SgOmpRequiresStatement*) ROSE_MALLOC ( SgOmpRequiresStatement::pool_size * sizeof(SgOmpRequiresStatement) );
  104602           0 :         assert( pointer != NULL );
  104603             : #if ROSE_ALLOC_MEMSET == 1
  104604             :         memset(pointer, 0x00, SgOmpRequiresStatement::pool_size * sizeof(SgOmpRequiresStatement));
  104605             : #elif ROSE_ALLOC_MEMSET == 2
  104606             :         memset(pointer, 0xCC, SgOmpRequiresStatement::pool_size * sizeof(SgOmpRequiresStatement));
  104607             : #endif
  104608           0 :         SgOmpRequiresStatement::pools.push_back( (unsigned char*)(pointer) );
  104609           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpRequiresStatement::pool_size * sizeof(SgOmpRequiresStatement), V_SgOmpRequiresStatement ) );
  104610             : 
  104611           0 :         if ( SgOmpRequiresStatement::next_node != NULL ) {
  104612           0 :           if ( blockIndex > 0 ) {
  104613           0 :             SgOmpRequiresStatement * blkptr = (SgOmpRequiresStatement*)(SgOmpRequiresStatement::pools[blockIndex-1]);
  104614           0 :             blkptr[ SgOmpRequiresStatement::pool_size - 1 ].set_freepointer(pointer);
  104615             :           }
  104616             :         } else {
  104617           0 :           SgOmpRequiresStatement::next_node = pointer;
  104618             :         }
  104619             : 
  104620           0 :         for (unsigned i = 0; i < SgOmpRequiresStatement::pool_size-1; ++i)
  104621             :            {
  104622           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  104623             :            }
  104624           0 :         pointer[ SgOmpRequiresStatement::pool_size -1 ].set_freepointer(NULL);
  104625             : 
  104626           0 :         blockIndex++;
  104627             :       }
  104628           2 :   }
  104629             : 
  104630             : //############################################################################
  104631             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  104632             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  104633             :  * not compressed. However, that stuff is not yet implemented! 
  104634             :  */
  104635             : unsigned long
  104636           0 : SgOmpRequiresStatement::getNumberOfLastValidPointer()
  104637             :    {
  104638           0 :       SgOmpRequiresStatement* testPointer = (SgOmpRequiresStatement*)(SgOmpRequiresStatement::pools.back());
  104639           0 :       unsigned long localIndex = SgOmpRequiresStatement::pool_size - 1;
  104640           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  104641             :          {
  104642           0 :            localIndex--;
  104643             :          }
  104644           0 :       return (localIndex + SgOmpRequiresStatement::pool_size * (SgOmpRequiresStatement::pools.size()-1));
  104645             :    }
  104646             : 
  104647             : //############################################################################
  104648             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  104649             :  * memory pool and initializes the data member in class SgOmpRequiresStatementStroageClass
  104650             :  * from its counterpart of SgOmpRequiresStatement. The return value is just for checking, 
  104651             :  * that the whole StorageClassArray is initialized!
  104652             :  */
  104653             : unsigned long
  104654           0 : SgOmpRequiresStatement::initializeStorageClassArray( SgOmpRequiresStatementStorageClass *storageArray )
  104655             :    {
  104656           0 :      unsigned long storageCounter = 0;
  104657           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpRequiresStatement::pools.begin();
  104658           0 :      SgOmpRequiresStatement* pointer = NULL;
  104659           0 :      while ( block != SgOmpRequiresStatement::pools.end() ) {
  104660           0 :           pointer = (SgOmpRequiresStatement*) (*block);
  104661           0 :           for ( unsigned i = 0; i < SgOmpRequiresStatement::pool_size; ++i ) {
  104662           0 :                if ( pointer->get_freepointer() != NULL ) {
  104663           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  104664           0 :                  storageArray++;
  104665           0 :                  storageCounter++;
  104666             :                }
  104667           0 :                pointer++;
  104668             :              }
  104669           0 :            block++;
  104670             :         }
  104671           0 :      return storageCounter;
  104672             :    }
  104673             : 
  104674             : /* #line 104675 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  104675             : 
  104676             : 
  104677             : 
  104678             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  104679             : 
  104680             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  104681             : 
  104682             : //############################################################################
  104683             : /* JH (02/02/2006) Constructor of the IR node SgFortranIncludeLine that takes its 
  104684             :  * corresponding StorageClass as parameter
  104685             :  */
  104686           0 : SgFortranIncludeLine :: SgFortranIncludeLine ( const SgFortranIncludeLineStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  104687             :    {
  104688             : 
  104689             : 
  104690             : /* #line 104691 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  104691             : 
  104692           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  104693           0 :      p_filename = storageSource.storageOf_filename.rebuildDataStoredInEasyStorageClass() ;
  104694             : 
  104695             : 
  104696             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  104697             : 
  104698             : 
  104699           0 :    }
  104700             : 
  104701             : //############################################################################
  104702             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  104703             :  * within the working AST. 
  104704             :  */
  104705           0 : SgFortranIncludeLine * SgFortranIncludeLine::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  104706           0 :      SgFortranIncludeLine* returnPointer = NULL;
  104707           0 :      if ( globalIndex != 0 )
  104708             :         {
  104709             : 
  104710             : #if FILE_IO_EXTRA_CHECK
  104711           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFortranIncludeLine ) ) <= globalIndex ) ;
  104712           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFortranIncludeLine + 1 ) ) );
  104713             : #endif
  104714           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFortranIncludeLine )  
  104715           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFortranIncludeLine );
  104716           0 :           unsigned long positionInPool = localIndex % SgFortranIncludeLine::pool_size;
  104717           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFortranIncludeLine::pool_size;
  104718             : 
  104719             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  104720             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  104721             : 
  104722           0 :           returnPointer = &( ( (SgFortranIncludeLine*)(SgFortranIncludeLine::pools[memoryBlock]) ) [positionInPool]) ;
  104723             : 
  104724           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  104725             :         }
  104726           0 :      return returnPointer ;
  104727             :    }
  104728             : 
  104729             : //############################################################################
  104730             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  104731             :   for the AST with the index astIndex
  104732             : */
  104733           0 : SgFortranIncludeLine * SgFortranIncludeLine::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  104734           0 :      SgFortranIncludeLine* returnPointer = NULL;
  104735           0 :      if ( globalIndex != 0 )
  104736             :         {
  104737             : 
  104738             : #if FILE_IO_EXTRA_CHECK
  104739           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFortranIncludeLine ) ) <= globalIndex ) ;
  104740           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFortranIncludeLine + 1 ) ) );
  104741             : #endif
  104742           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFortranIncludeLine )
  104743           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFortranIncludeLine );
  104744           0 :           unsigned long positionInPool = localIndex % SgFortranIncludeLine::pool_size ;
  104745           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFortranIncludeLine::pool_size ;
  104746             : 
  104747             : #if FILE_IO_EXTRA_CHECK
  104748             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  104749             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  104750             : #endif
  104751             : 
  104752           0 :           returnPointer = &( ( (SgFortranIncludeLine*)(SgFortranIncludeLine::pools[memoryBlock]) ) [positionInPool]) ;
  104753             : 
  104754             : #if FILE_IO_EXTRA_CHECK
  104755           0 :           assert ( returnPointer != NULL ) ;
  104756             : #endif
  104757             :         }
  104758           0 :      return returnPointer ;
  104759             :    }
  104760             : 
  104761             : //############################################################################
  104762             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  104763             :  * pool size! We set for every valid object in the memory pool the freepointer
  104764             :  * to the global index and increase the global index afterwards. For all the 
  104765             :  * invalid objects (means address ranges within the memory pool that were not
  104766             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  104767             :  * distinguish valid from invalid objects! 
  104768             :  */
  104769             : unsigned long
  104770           5 : SgFortranIncludeLine::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  104771             :    {
  104772           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  104773           5 :      SgFortranIncludeLine* pointer = NULL;
  104774           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  104775           5 :      std::vector < unsigned char* > :: const_iterator block;
  104776           5 :      for ( block = SgFortranIncludeLine::pools.begin(); block != SgFortranIncludeLine::pools.end() ; ++block )
  104777             :         {
  104778           0 :           pointer = (SgFortranIncludeLine*)(*block);
  104779           0 :           for (unsigned i = 0; i < SgFortranIncludeLine::pool_size; ++i )
  104780             :              {
  104781             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  104782             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  104783             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  104784             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  104785             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  104786             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  104787             :             // properly; so this will have to be checked next.
  104788             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  104789             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  104790           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  104791             :                   {
  104792           0 :                     pointer[i].set_freepointer((SgFortranIncludeLine*)(globalIndex));
  104793           0 :                     globalIndex++;
  104794             :                   }
  104795             :                else
  104796             :                   {
  104797           0 :                     pointer[i].set_freepointer(NULL);
  104798             :                   }
  104799             :               }
  104800             :         }
  104801           5 :      return globalIndex;
  104802             :    }
  104803             : 
  104804             : //############################################################################
  104805             : // JH (01/14/2006)
  104806             : void
  104807           5 : SgFortranIncludeLine::resetValidFreepointers( )
  104808             :    {
  104809           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  104810           5 :      SgFortranIncludeLine* pointer = NULL;
  104811           5 :      std::vector < unsigned char* > :: const_iterator block;
  104812           5 :      SgFortranIncludeLine* pointerOfLinkedList = NULL;
  104813           5 :      for ( block = SgFortranIncludeLine::pools.begin(); block != SgFortranIncludeLine::pools.end() ; ++block )
  104814             :         {
  104815           0 :           pointer = (SgFortranIncludeLine*)(*block);
  104816           0 :           for (unsigned i = 0; i < SgFortranIncludeLine::pool_size; ++i )
  104817             :              {
  104818             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  104819             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  104820             :             // memory blocks!.
  104821           0 :                if ( pointer[i].get_freepointer() != NULL )
  104822             :                   {
  104823           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  104824             :                   }
  104825             :                else
  104826             :                   {
  104827           0 :                     if ( pointerOfLinkedList == NULL )
  104828             :                        {
  104829           0 :                          SgFortranIncludeLine::next_node = &(pointer[i]);
  104830             :                        }
  104831             :                     else
  104832             :                        {
  104833             :                       // printf ("In SgFortranIncludeLine::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  104834           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  104835             :                        }
  104836             :                     pointerOfLinkedList = &(pointer[i]);
  104837             :                   }
  104838             :               }
  104839             :         }
  104840             : 
  104841           5 :      if ( pointerOfLinkedList != NULL )
  104842             :         {
  104843             :        // printf ("In SgFortranIncludeLine::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  104844           0 :           pointerOfLinkedList->set_freepointer(NULL);
  104845             :        // DQ (6/6/2010): Temporary debugging...
  104846             :        //   ROSE_ASSERT(false);
  104847             :         }
  104848             : 
  104849           5 :      return ;
  104850             :    }
  104851             : 
  104852             : //############################################################################
  104853             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  104854             :  * within the memory pool and resets the freepointers, in order to achieve a 
  104855             :  * linked list, that has no jumps and starts at the beginning! This function 
  104856             :  * does not extend the memory pool, since we do not delete any memory blocks,
  104857             :  * but delete the valid objects.  
  104858             :  */
  104859             : void
  104860           0 : SgFortranIncludeLine::clearMemoryPool( )
  104861             :    {
  104862             :   // printf ("Inside of SgFortranIncludeLine::clearMemoryPool() \n");
  104863             : 
  104864           0 :      SgFortranIncludeLine* pointer = NULL, *tempPointer = NULL;
  104865           0 :      std::vector < unsigned char* > :: const_iterator block;
  104866           0 :      if ( SgFortranIncludeLine::pools.empty() == false )
  104867             :         {
  104868           0 :           block = SgFortranIncludeLine::pools.begin() ;
  104869           0 :           SgFortranIncludeLine::next_node = (SgFortranIncludeLine*) (*block);
  104870             : 
  104871           0 :           while ( block != SgFortranIncludeLine::pools.end() )
  104872             :              {
  104873           0 :                pointer = (SgFortranIncludeLine*) (*block);
  104874           0 :                if ( tempPointer != NULL )
  104875             :                   {
  104876           0 :                     tempPointer->set_freepointer(pointer);
  104877             :                   }
  104878           0 :                for (unsigned i = 0; i < SgFortranIncludeLine::pool_size - 1; ++i)
  104879             :                   {
  104880           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  104881             :                   }
  104882           0 :                 pointer[SgFortranIncludeLine::pool_size-1].set_freepointer(NULL);
  104883           0 :                 tempPointer = &(pointer[SgFortranIncludeLine::pool_size-1]);
  104884           0 :                 ++block;
  104885             :              }
  104886             :         }
  104887           0 :    }
  104888             : 
  104889           5 : void SgFortranIncludeLine::deleteMemoryPool() {
  104890           5 :   for (auto p: SgFortranIncludeLine::pools) {
  104891           0 :     ROSE_FREE(p);
  104892             :   }
  104893           5 :   SgFortranIncludeLine::next_node = nullptr;
  104894           5 :   SgFortranIncludeLine::pools.clear();
  104895           5 : }
  104896             : 
  104897             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  104898             : //                 reading multiple binary files to for a single AST.
  104899             : /////////// new version ////////////////////////////////
  104900             : //############################################################################
  104901             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  104902             : void
  104903           2 : SgFortranIncludeLine::extendMemoryPoolForFileIO( )
  104904             :   {
  104905           2 :     size_t blockIndex = SgFortranIncludeLine::pools.size();
  104906           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranIncludeLine) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranIncludeLine);
  104907             : 
  104908           2 :     while ( (blockIndex * SgFortranIncludeLine::pool_size) < newPoolSize)
  104909             :       {
  104910             : #if ROSE_ALLOC_TRACE
  104911             :         if (blockIndex > 0) {
  104912             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranIncludeLine) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranIncludeLine) = %" PRIuPTR " SgFortranIncludeLine::pool_size = %d \n",
  104913             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFortranIncludeLine),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFortranIncludeLine),SgFortranIncludeLine::pool_size);
  104914             :         }
  104915             : #endif
  104916             : 
  104917           0 :         SgFortranIncludeLine * pointer = (SgFortranIncludeLine*) ROSE_MALLOC ( SgFortranIncludeLine::pool_size * sizeof(SgFortranIncludeLine) );
  104918           0 :         assert( pointer != NULL );
  104919             : #if ROSE_ALLOC_MEMSET == 1
  104920             :         memset(pointer, 0x00, SgFortranIncludeLine::pool_size * sizeof(SgFortranIncludeLine));
  104921             : #elif ROSE_ALLOC_MEMSET == 2
  104922             :         memset(pointer, 0xCC, SgFortranIncludeLine::pool_size * sizeof(SgFortranIncludeLine));
  104923             : #endif
  104924           0 :         SgFortranIncludeLine::pools.push_back( (unsigned char*)(pointer) );
  104925           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFortranIncludeLine::pool_size * sizeof(SgFortranIncludeLine), V_SgFortranIncludeLine ) );
  104926             : 
  104927           0 :         if ( SgFortranIncludeLine::next_node != NULL ) {
  104928           0 :           if ( blockIndex > 0 ) {
  104929           0 :             SgFortranIncludeLine * blkptr = (SgFortranIncludeLine*)(SgFortranIncludeLine::pools[blockIndex-1]);
  104930           0 :             blkptr[ SgFortranIncludeLine::pool_size - 1 ].set_freepointer(pointer);
  104931             :           }
  104932             :         } else {
  104933           0 :           SgFortranIncludeLine::next_node = pointer;
  104934             :         }
  104935             : 
  104936           0 :         for (unsigned i = 0; i < SgFortranIncludeLine::pool_size-1; ++i)
  104937             :            {
  104938           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  104939             :            }
  104940           0 :         pointer[ SgFortranIncludeLine::pool_size -1 ].set_freepointer(NULL);
  104941             : 
  104942           0 :         blockIndex++;
  104943             :       }
  104944           2 :   }
  104945             : 
  104946             : //############################################################################
  104947             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  104948             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  104949             :  * not compressed. However, that stuff is not yet implemented! 
  104950             :  */
  104951             : unsigned long
  104952           0 : SgFortranIncludeLine::getNumberOfLastValidPointer()
  104953             :    {
  104954           0 :       SgFortranIncludeLine* testPointer = (SgFortranIncludeLine*)(SgFortranIncludeLine::pools.back());
  104955           0 :       unsigned long localIndex = SgFortranIncludeLine::pool_size - 1;
  104956           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  104957             :          {
  104958           0 :            localIndex--;
  104959             :          }
  104960           0 :       return (localIndex + SgFortranIncludeLine::pool_size * (SgFortranIncludeLine::pools.size()-1));
  104961             :    }
  104962             : 
  104963             : //############################################################################
  104964             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  104965             :  * memory pool and initializes the data member in class SgFortranIncludeLineStroageClass
  104966             :  * from its counterpart of SgFortranIncludeLine. The return value is just for checking, 
  104967             :  * that the whole StorageClassArray is initialized!
  104968             :  */
  104969             : unsigned long
  104970           0 : SgFortranIncludeLine::initializeStorageClassArray( SgFortranIncludeLineStorageClass *storageArray )
  104971             :    {
  104972           0 :      unsigned long storageCounter = 0;
  104973           0 :      std::vector < unsigned char* > :: const_iterator block = SgFortranIncludeLine::pools.begin();
  104974           0 :      SgFortranIncludeLine* pointer = NULL;
  104975           0 :      while ( block != SgFortranIncludeLine::pools.end() ) {
  104976           0 :           pointer = (SgFortranIncludeLine*) (*block);
  104977           0 :           for ( unsigned i = 0; i < SgFortranIncludeLine::pool_size; ++i ) {
  104978           0 :                if ( pointer->get_freepointer() != NULL ) {
  104979           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  104980           0 :                  storageArray++;
  104981           0 :                  storageCounter++;
  104982             :                }
  104983           0 :                pointer++;
  104984             :              }
  104985           0 :            block++;
  104986             :         }
  104987           0 :      return storageCounter;
  104988             :    }
  104989             : 
  104990             : /* #line 104991 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  104991             : 
  104992             : 
  104993             : 
  104994             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  104995             : 
  104996             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  104997             : 
  104998             : //############################################################################
  104999             : /* JH (02/02/2006) Constructor of the IR node SgOmpTaskwaitStatement that takes its 
  105000             :  * corresponding StorageClass as parameter
  105001             :  */
  105002           0 : SgOmpTaskwaitStatement :: SgOmpTaskwaitStatement ( const SgOmpTaskwaitStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  105003             :    {
  105004             : 
  105005             : 
  105006             : /* #line 105007 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  105007             : 
  105008           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  105009           0 :      p_clauses = storageSource.storageOf_clauses.rebuildDataStoredInEasyStorageClass() ;
  105010           0 :      SgOmpClausePtrList::iterator i_clauses = p_clauses.begin() ; 
  105011           0 :      for ( ; i_clauses != p_clauses.end(); ++i_clauses ) 
  105012             :         {
  105013           0 :           (*i_clauses) = (SgOmpClausePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_clauses) ) );
  105014             :         }
  105015             : 
  105016             : 
  105017             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  105018             : 
  105019             : 
  105020           0 :    }
  105021             : 
  105022             : //############################################################################
  105023             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  105024             :  * within the working AST. 
  105025             :  */
  105026           0 : SgOmpTaskwaitStatement * SgOmpTaskwaitStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  105027           0 :      SgOmpTaskwaitStatement* returnPointer = NULL;
  105028           0 :      if ( globalIndex != 0 )
  105029             :         {
  105030             : 
  105031             : #if FILE_IO_EXTRA_CHECK
  105032           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTaskwaitStatement ) ) <= globalIndex ) ;
  105033           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskwaitStatement + 1 ) ) );
  105034             : #endif
  105035           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskwaitStatement )  
  105036           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTaskwaitStatement );
  105037           0 :           unsigned long positionInPool = localIndex % SgOmpTaskwaitStatement::pool_size;
  105038           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskwaitStatement::pool_size;
  105039             : 
  105040             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  105041             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  105042             : 
  105043           0 :           returnPointer = &( ( (SgOmpTaskwaitStatement*)(SgOmpTaskwaitStatement::pools[memoryBlock]) ) [positionInPool]) ;
  105044             : 
  105045           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  105046             :         }
  105047           0 :      return returnPointer ;
  105048             :    }
  105049             : 
  105050             : //############################################################################
  105051             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  105052             :   for the AST with the index astIndex
  105053             : */
  105054           0 : SgOmpTaskwaitStatement * SgOmpTaskwaitStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  105055           0 :      SgOmpTaskwaitStatement* returnPointer = NULL;
  105056           0 :      if ( globalIndex != 0 )
  105057             :         {
  105058             : 
  105059             : #if FILE_IO_EXTRA_CHECK
  105060           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTaskwaitStatement ) ) <= globalIndex ) ;
  105061           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskwaitStatement + 1 ) ) );
  105062             : #endif
  105063           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskwaitStatement )
  105064           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTaskwaitStatement );
  105065           0 :           unsigned long positionInPool = localIndex % SgOmpTaskwaitStatement::pool_size ;
  105066           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskwaitStatement::pool_size ;
  105067             : 
  105068             : #if FILE_IO_EXTRA_CHECK
  105069             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  105070             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  105071             : #endif
  105072             : 
  105073           0 :           returnPointer = &( ( (SgOmpTaskwaitStatement*)(SgOmpTaskwaitStatement::pools[memoryBlock]) ) [positionInPool]) ;
  105074             : 
  105075             : #if FILE_IO_EXTRA_CHECK
  105076           0 :           assert ( returnPointer != NULL ) ;
  105077             : #endif
  105078             :         }
  105079           0 :      return returnPointer ;
  105080             :    }
  105081             : 
  105082             : //############################################################################
  105083             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  105084             :  * pool size! We set for every valid object in the memory pool the freepointer
  105085             :  * to the global index and increase the global index afterwards. For all the 
  105086             :  * invalid objects (means address ranges within the memory pool that were not
  105087             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  105088             :  * distinguish valid from invalid objects! 
  105089             :  */
  105090             : unsigned long
  105091           5 : SgOmpTaskwaitStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  105092             :    {
  105093           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  105094           5 :      SgOmpTaskwaitStatement* pointer = NULL;
  105095           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  105096           5 :      std::vector < unsigned char* > :: const_iterator block;
  105097           5 :      for ( block = SgOmpTaskwaitStatement::pools.begin(); block != SgOmpTaskwaitStatement::pools.end() ; ++block )
  105098             :         {
  105099           0 :           pointer = (SgOmpTaskwaitStatement*)(*block);
  105100           0 :           for (unsigned i = 0; i < SgOmpTaskwaitStatement::pool_size; ++i )
  105101             :              {
  105102             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  105103             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  105104             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  105105             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  105106             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  105107             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  105108             :             // properly; so this will have to be checked next.
  105109             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  105110             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  105111           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  105112             :                   {
  105113           0 :                     pointer[i].set_freepointer((SgOmpTaskwaitStatement*)(globalIndex));
  105114           0 :                     globalIndex++;
  105115             :                   }
  105116             :                else
  105117             :                   {
  105118           0 :                     pointer[i].set_freepointer(NULL);
  105119             :                   }
  105120             :               }
  105121             :         }
  105122           5 :      return globalIndex;
  105123             :    }
  105124             : 
  105125             : //############################################################################
  105126             : // JH (01/14/2006)
  105127             : void
  105128           5 : SgOmpTaskwaitStatement::resetValidFreepointers( )
  105129             :    {
  105130           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  105131           5 :      SgOmpTaskwaitStatement* pointer = NULL;
  105132           5 :      std::vector < unsigned char* > :: const_iterator block;
  105133           5 :      SgOmpTaskwaitStatement* pointerOfLinkedList = NULL;
  105134           5 :      for ( block = SgOmpTaskwaitStatement::pools.begin(); block != SgOmpTaskwaitStatement::pools.end() ; ++block )
  105135             :         {
  105136           0 :           pointer = (SgOmpTaskwaitStatement*)(*block);
  105137           0 :           for (unsigned i = 0; i < SgOmpTaskwaitStatement::pool_size; ++i )
  105138             :              {
  105139             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  105140             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  105141             :             // memory blocks!.
  105142           0 :                if ( pointer[i].get_freepointer() != NULL )
  105143             :                   {
  105144           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  105145             :                   }
  105146             :                else
  105147             :                   {
  105148           0 :                     if ( pointerOfLinkedList == NULL )
  105149             :                        {
  105150           0 :                          SgOmpTaskwaitStatement::next_node = &(pointer[i]);
  105151             :                        }
  105152             :                     else
  105153             :                        {
  105154             :                       // printf ("In SgOmpTaskwaitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  105155           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  105156             :                        }
  105157             :                     pointerOfLinkedList = &(pointer[i]);
  105158             :                   }
  105159             :               }
  105160             :         }
  105161             : 
  105162           5 :      if ( pointerOfLinkedList != NULL )
  105163             :         {
  105164             :        // printf ("In SgOmpTaskwaitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  105165           0 :           pointerOfLinkedList->set_freepointer(NULL);
  105166             :        // DQ (6/6/2010): Temporary debugging...
  105167             :        //   ROSE_ASSERT(false);
  105168             :         }
  105169             : 
  105170           5 :      return ;
  105171             :    }
  105172             : 
  105173             : //############################################################################
  105174             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  105175             :  * within the memory pool and resets the freepointers, in order to achieve a 
  105176             :  * linked list, that has no jumps and starts at the beginning! This function 
  105177             :  * does not extend the memory pool, since we do not delete any memory blocks,
  105178             :  * but delete the valid objects.  
  105179             :  */
  105180             : void
  105181           0 : SgOmpTaskwaitStatement::clearMemoryPool( )
  105182             :    {
  105183             :   // printf ("Inside of SgOmpTaskwaitStatement::clearMemoryPool() \n");
  105184             : 
  105185           0 :      SgOmpTaskwaitStatement* pointer = NULL, *tempPointer = NULL;
  105186           0 :      std::vector < unsigned char* > :: const_iterator block;
  105187           0 :      if ( SgOmpTaskwaitStatement::pools.empty() == false )
  105188             :         {
  105189           0 :           block = SgOmpTaskwaitStatement::pools.begin() ;
  105190           0 :           SgOmpTaskwaitStatement::next_node = (SgOmpTaskwaitStatement*) (*block);
  105191             : 
  105192           0 :           while ( block != SgOmpTaskwaitStatement::pools.end() )
  105193             :              {
  105194           0 :                pointer = (SgOmpTaskwaitStatement*) (*block);
  105195           0 :                if ( tempPointer != NULL )
  105196             :                   {
  105197           0 :                     tempPointer->set_freepointer(pointer);
  105198             :                   }
  105199           0 :                for (unsigned i = 0; i < SgOmpTaskwaitStatement::pool_size - 1; ++i)
  105200             :                   {
  105201           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  105202             :                   }
  105203           0 :                 pointer[SgOmpTaskwaitStatement::pool_size-1].set_freepointer(NULL);
  105204           0 :                 tempPointer = &(pointer[SgOmpTaskwaitStatement::pool_size-1]);
  105205           0 :                 ++block;
  105206             :              }
  105207             :         }
  105208           0 :    }
  105209             : 
  105210           5 : void SgOmpTaskwaitStatement::deleteMemoryPool() {
  105211           5 :   for (auto p: SgOmpTaskwaitStatement::pools) {
  105212           0 :     ROSE_FREE(p);
  105213             :   }
  105214           5 :   SgOmpTaskwaitStatement::next_node = nullptr;
  105215           5 :   SgOmpTaskwaitStatement::pools.clear();
  105216           5 : }
  105217             : 
  105218             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  105219             : //                 reading multiple binary files to for a single AST.
  105220             : /////////// new version ////////////////////////////////
  105221             : //############################################################################
  105222             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  105223             : void
  105224           2 : SgOmpTaskwaitStatement::extendMemoryPoolForFileIO( )
  105225             :   {
  105226           2 :     size_t blockIndex = SgOmpTaskwaitStatement::pools.size();
  105227           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskwaitStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskwaitStatement);
  105228             : 
  105229           2 :     while ( (blockIndex * SgOmpTaskwaitStatement::pool_size) < newPoolSize)
  105230             :       {
  105231             : #if ROSE_ALLOC_TRACE
  105232             :         if (blockIndex > 0) {
  105233             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskwaitStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskwaitStatement) = %" PRIuPTR " SgOmpTaskwaitStatement::pool_size = %d \n",
  105234             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskwaitStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskwaitStatement),SgOmpTaskwaitStatement::pool_size);
  105235             :         }
  105236             : #endif
  105237             : 
  105238           0 :         SgOmpTaskwaitStatement * pointer = (SgOmpTaskwaitStatement*) ROSE_MALLOC ( SgOmpTaskwaitStatement::pool_size * sizeof(SgOmpTaskwaitStatement) );
  105239           0 :         assert( pointer != NULL );
  105240             : #if ROSE_ALLOC_MEMSET == 1
  105241             :         memset(pointer, 0x00, SgOmpTaskwaitStatement::pool_size * sizeof(SgOmpTaskwaitStatement));
  105242             : #elif ROSE_ALLOC_MEMSET == 2
  105243             :         memset(pointer, 0xCC, SgOmpTaskwaitStatement::pool_size * sizeof(SgOmpTaskwaitStatement));
  105244             : #endif
  105245           0 :         SgOmpTaskwaitStatement::pools.push_back( (unsigned char*)(pointer) );
  105246           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTaskwaitStatement::pool_size * sizeof(SgOmpTaskwaitStatement), V_SgOmpTaskwaitStatement ) );
  105247             : 
  105248           0 :         if ( SgOmpTaskwaitStatement::next_node != NULL ) {
  105249           0 :           if ( blockIndex > 0 ) {
  105250           0 :             SgOmpTaskwaitStatement * blkptr = (SgOmpTaskwaitStatement*)(SgOmpTaskwaitStatement::pools[blockIndex-1]);
  105251           0 :             blkptr[ SgOmpTaskwaitStatement::pool_size - 1 ].set_freepointer(pointer);
  105252             :           }
  105253             :         } else {
  105254           0 :           SgOmpTaskwaitStatement::next_node = pointer;
  105255             :         }
  105256             : 
  105257           0 :         for (unsigned i = 0; i < SgOmpTaskwaitStatement::pool_size-1; ++i)
  105258             :            {
  105259           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  105260             :            }
  105261           0 :         pointer[ SgOmpTaskwaitStatement::pool_size -1 ].set_freepointer(NULL);
  105262             : 
  105263           0 :         blockIndex++;
  105264             :       }
  105265           2 :   }
  105266             : 
  105267             : //############################################################################
  105268             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  105269             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  105270             :  * not compressed. However, that stuff is not yet implemented! 
  105271             :  */
  105272             : unsigned long
  105273           0 : SgOmpTaskwaitStatement::getNumberOfLastValidPointer()
  105274             :    {
  105275           0 :       SgOmpTaskwaitStatement* testPointer = (SgOmpTaskwaitStatement*)(SgOmpTaskwaitStatement::pools.back());
  105276           0 :       unsigned long localIndex = SgOmpTaskwaitStatement::pool_size - 1;
  105277           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  105278             :          {
  105279           0 :            localIndex--;
  105280             :          }
  105281           0 :       return (localIndex + SgOmpTaskwaitStatement::pool_size * (SgOmpTaskwaitStatement::pools.size()-1));
  105282             :    }
  105283             : 
  105284             : //############################################################################
  105285             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  105286             :  * memory pool and initializes the data member in class SgOmpTaskwaitStatementStroageClass
  105287             :  * from its counterpart of SgOmpTaskwaitStatement. The return value is just for checking, 
  105288             :  * that the whole StorageClassArray is initialized!
  105289             :  */
  105290             : unsigned long
  105291           0 : SgOmpTaskwaitStatement::initializeStorageClassArray( SgOmpTaskwaitStatementStorageClass *storageArray )
  105292             :    {
  105293           0 :      unsigned long storageCounter = 0;
  105294           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTaskwaitStatement::pools.begin();
  105295           0 :      SgOmpTaskwaitStatement* pointer = NULL;
  105296           0 :      while ( block != SgOmpTaskwaitStatement::pools.end() ) {
  105297           0 :           pointer = (SgOmpTaskwaitStatement*) (*block);
  105298           0 :           for ( unsigned i = 0; i < SgOmpTaskwaitStatement::pool_size; ++i ) {
  105299           0 :                if ( pointer->get_freepointer() != NULL ) {
  105300           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  105301           0 :                  storageArray++;
  105302           0 :                  storageCounter++;
  105303             :                }
  105304           0 :                pointer++;
  105305             :              }
  105306           0 :            block++;
  105307             :         }
  105308           0 :      return storageCounter;
  105309             :    }
  105310             : 
  105311             : /* #line 105312 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  105312             : 
  105313             : 
  105314             : 
  105315             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  105316             : 
  105317             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  105318             : 
  105319             : //############################################################################
  105320             : /* JH (02/02/2006) Constructor of the IR node SgStmtDeclarationStatement that takes its 
  105321             :  * corresponding StorageClass as parameter
  105322             :  */
  105323           0 : SgStmtDeclarationStatement :: SgStmtDeclarationStatement ( const SgStmtDeclarationStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  105324             :    {
  105325             : 
  105326             : 
  105327             : /* #line 105328 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  105328             : 
  105329           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  105330           0 :      p_statement =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_statement) );
  105331             : 
  105332             : 
  105333             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  105334             : 
  105335             : 
  105336           0 :    }
  105337             : 
  105338             : //############################################################################
  105339             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  105340             :  * within the working AST. 
  105341             :  */
  105342           0 : SgStmtDeclarationStatement * SgStmtDeclarationStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  105343           0 :      SgStmtDeclarationStatement* returnPointer = NULL;
  105344           0 :      if ( globalIndex != 0 )
  105345             :         {
  105346             : 
  105347             : #if FILE_IO_EXTRA_CHECK
  105348           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStmtDeclarationStatement ) ) <= globalIndex ) ;
  105349           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStmtDeclarationStatement + 1 ) ) );
  105350             : #endif
  105351           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStmtDeclarationStatement )  
  105352           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStmtDeclarationStatement );
  105353           0 :           unsigned long positionInPool = localIndex % SgStmtDeclarationStatement::pool_size;
  105354           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStmtDeclarationStatement::pool_size;
  105355             : 
  105356             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  105357             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  105358             : 
  105359           0 :           returnPointer = &( ( (SgStmtDeclarationStatement*)(SgStmtDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
  105360             : 
  105361           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  105362             :         }
  105363           0 :      return returnPointer ;
  105364             :    }
  105365             : 
  105366             : //############################################################################
  105367             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  105368             :   for the AST with the index astIndex
  105369             : */
  105370           0 : SgStmtDeclarationStatement * SgStmtDeclarationStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  105371           0 :      SgStmtDeclarationStatement* returnPointer = NULL;
  105372           0 :      if ( globalIndex != 0 )
  105373             :         {
  105374             : 
  105375             : #if FILE_IO_EXTRA_CHECK
  105376           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStmtDeclarationStatement ) ) <= globalIndex ) ;
  105377           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStmtDeclarationStatement + 1 ) ) );
  105378             : #endif
  105379           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStmtDeclarationStatement )
  105380           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStmtDeclarationStatement );
  105381           0 :           unsigned long positionInPool = localIndex % SgStmtDeclarationStatement::pool_size ;
  105382           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStmtDeclarationStatement::pool_size ;
  105383             : 
  105384             : #if FILE_IO_EXTRA_CHECK
  105385             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  105386             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  105387             : #endif
  105388             : 
  105389           0 :           returnPointer = &( ( (SgStmtDeclarationStatement*)(SgStmtDeclarationStatement::pools[memoryBlock]) ) [positionInPool]) ;
  105390             : 
  105391             : #if FILE_IO_EXTRA_CHECK
  105392           0 :           assert ( returnPointer != NULL ) ;
  105393             : #endif
  105394             :         }
  105395           0 :      return returnPointer ;
  105396             :    }
  105397             : 
  105398             : //############################################################################
  105399             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  105400             :  * pool size! We set for every valid object in the memory pool the freepointer
  105401             :  * to the global index and increase the global index afterwards. For all the 
  105402             :  * invalid objects (means address ranges within the memory pool that were not
  105403             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  105404             :  * distinguish valid from invalid objects! 
  105405             :  */
  105406             : unsigned long
  105407           5 : SgStmtDeclarationStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  105408             :    {
  105409           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  105410           5 :      SgStmtDeclarationStatement* pointer = NULL;
  105411           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  105412           5 :      std::vector < unsigned char* > :: const_iterator block;
  105413           5 :      for ( block = SgStmtDeclarationStatement::pools.begin(); block != SgStmtDeclarationStatement::pools.end() ; ++block )
  105414             :         {
  105415           0 :           pointer = (SgStmtDeclarationStatement*)(*block);
  105416           0 :           for (unsigned i = 0; i < SgStmtDeclarationStatement::pool_size; ++i )
  105417             :              {
  105418             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  105419             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  105420             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  105421             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  105422             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  105423             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  105424             :             // properly; so this will have to be checked next.
  105425             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  105426             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  105427           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  105428             :                   {
  105429           0 :                     pointer[i].set_freepointer((SgStmtDeclarationStatement*)(globalIndex));
  105430           0 :                     globalIndex++;
  105431             :                   }
  105432             :                else
  105433             :                   {
  105434           0 :                     pointer[i].set_freepointer(NULL);
  105435             :                   }
  105436             :               }
  105437             :         }
  105438           5 :      return globalIndex;
  105439             :    }
  105440             : 
  105441             : //############################################################################
  105442             : // JH (01/14/2006)
  105443             : void
  105444           5 : SgStmtDeclarationStatement::resetValidFreepointers( )
  105445             :    {
  105446           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  105447           5 :      SgStmtDeclarationStatement* pointer = NULL;
  105448           5 :      std::vector < unsigned char* > :: const_iterator block;
  105449           5 :      SgStmtDeclarationStatement* pointerOfLinkedList = NULL;
  105450           5 :      for ( block = SgStmtDeclarationStatement::pools.begin(); block != SgStmtDeclarationStatement::pools.end() ; ++block )
  105451             :         {
  105452           0 :           pointer = (SgStmtDeclarationStatement*)(*block);
  105453           0 :           for (unsigned i = 0; i < SgStmtDeclarationStatement::pool_size; ++i )
  105454             :              {
  105455             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  105456             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  105457             :             // memory blocks!.
  105458           0 :                if ( pointer[i].get_freepointer() != NULL )
  105459             :                   {
  105460           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  105461             :                   }
  105462             :                else
  105463             :                   {
  105464           0 :                     if ( pointerOfLinkedList == NULL )
  105465             :                        {
  105466           0 :                          SgStmtDeclarationStatement::next_node = &(pointer[i]);
  105467             :                        }
  105468             :                     else
  105469             :                        {
  105470             :                       // printf ("In SgStmtDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  105471           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  105472             :                        }
  105473             :                     pointerOfLinkedList = &(pointer[i]);
  105474             :                   }
  105475             :               }
  105476             :         }
  105477             : 
  105478           5 :      if ( pointerOfLinkedList != NULL )
  105479             :         {
  105480             :        // printf ("In SgStmtDeclarationStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  105481           0 :           pointerOfLinkedList->set_freepointer(NULL);
  105482             :        // DQ (6/6/2010): Temporary debugging...
  105483             :        //   ROSE_ASSERT(false);
  105484             :         }
  105485             : 
  105486           5 :      return ;
  105487             :    }
  105488             : 
  105489             : //############################################################################
  105490             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  105491             :  * within the memory pool and resets the freepointers, in order to achieve a 
  105492             :  * linked list, that has no jumps and starts at the beginning! This function 
  105493             :  * does not extend the memory pool, since we do not delete any memory blocks,
  105494             :  * but delete the valid objects.  
  105495             :  */
  105496             : void
  105497           0 : SgStmtDeclarationStatement::clearMemoryPool( )
  105498             :    {
  105499             :   // printf ("Inside of SgStmtDeclarationStatement::clearMemoryPool() \n");
  105500             : 
  105501           0 :      SgStmtDeclarationStatement* pointer = NULL, *tempPointer = NULL;
  105502           0 :      std::vector < unsigned char* > :: const_iterator block;
  105503           0 :      if ( SgStmtDeclarationStatement::pools.empty() == false )
  105504             :         {
  105505           0 :           block = SgStmtDeclarationStatement::pools.begin() ;
  105506           0 :           SgStmtDeclarationStatement::next_node = (SgStmtDeclarationStatement*) (*block);
  105507             : 
  105508           0 :           while ( block != SgStmtDeclarationStatement::pools.end() )
  105509             :              {
  105510           0 :                pointer = (SgStmtDeclarationStatement*) (*block);
  105511           0 :                if ( tempPointer != NULL )
  105512             :                   {
  105513           0 :                     tempPointer->set_freepointer(pointer);
  105514             :                   }
  105515           0 :                for (unsigned i = 0; i < SgStmtDeclarationStatement::pool_size - 1; ++i)
  105516             :                   {
  105517           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  105518             :                   }
  105519           0 :                 pointer[SgStmtDeclarationStatement::pool_size-1].set_freepointer(NULL);
  105520           0 :                 tempPointer = &(pointer[SgStmtDeclarationStatement::pool_size-1]);
  105521           0 :                 ++block;
  105522             :              }
  105523             :         }
  105524           0 :    }
  105525             : 
  105526           5 : void SgStmtDeclarationStatement::deleteMemoryPool() {
  105527           5 :   for (auto p: SgStmtDeclarationStatement::pools) {
  105528           0 :     ROSE_FREE(p);
  105529             :   }
  105530           5 :   SgStmtDeclarationStatement::next_node = nullptr;
  105531           5 :   SgStmtDeclarationStatement::pools.clear();
  105532           5 : }
  105533             : 
  105534             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  105535             : //                 reading multiple binary files to for a single AST.
  105536             : /////////// new version ////////////////////////////////
  105537             : //############################################################################
  105538             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  105539             : void
  105540           2 : SgStmtDeclarationStatement::extendMemoryPoolForFileIO( )
  105541             :   {
  105542           2 :     size_t blockIndex = SgStmtDeclarationStatement::pools.size();
  105543           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStmtDeclarationStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStmtDeclarationStatement);
  105544             : 
  105545           2 :     while ( (blockIndex * SgStmtDeclarationStatement::pool_size) < newPoolSize)
  105546             :       {
  105547             : #if ROSE_ALLOC_TRACE
  105548             :         if (blockIndex > 0) {
  105549             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStmtDeclarationStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStmtDeclarationStatement) = %" PRIuPTR " SgStmtDeclarationStatement::pool_size = %d \n",
  105550             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStmtDeclarationStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStmtDeclarationStatement),SgStmtDeclarationStatement::pool_size);
  105551             :         }
  105552             : #endif
  105553             : 
  105554           0 :         SgStmtDeclarationStatement * pointer = (SgStmtDeclarationStatement*) ROSE_MALLOC ( SgStmtDeclarationStatement::pool_size * sizeof(SgStmtDeclarationStatement) );
  105555           0 :         assert( pointer != NULL );
  105556             : #if ROSE_ALLOC_MEMSET == 1
  105557             :         memset(pointer, 0x00, SgStmtDeclarationStatement::pool_size * sizeof(SgStmtDeclarationStatement));
  105558             : #elif ROSE_ALLOC_MEMSET == 2
  105559             :         memset(pointer, 0xCC, SgStmtDeclarationStatement::pool_size * sizeof(SgStmtDeclarationStatement));
  105560             : #endif
  105561           0 :         SgStmtDeclarationStatement::pools.push_back( (unsigned char*)(pointer) );
  105562           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStmtDeclarationStatement::pool_size * sizeof(SgStmtDeclarationStatement), V_SgStmtDeclarationStatement ) );
  105563             : 
  105564           0 :         if ( SgStmtDeclarationStatement::next_node != NULL ) {
  105565           0 :           if ( blockIndex > 0 ) {
  105566           0 :             SgStmtDeclarationStatement * blkptr = (SgStmtDeclarationStatement*)(SgStmtDeclarationStatement::pools[blockIndex-1]);
  105567           0 :             blkptr[ SgStmtDeclarationStatement::pool_size - 1 ].set_freepointer(pointer);
  105568             :           }
  105569             :         } else {
  105570           0 :           SgStmtDeclarationStatement::next_node = pointer;
  105571             :         }
  105572             : 
  105573           0 :         for (unsigned i = 0; i < SgStmtDeclarationStatement::pool_size-1; ++i)
  105574             :            {
  105575           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  105576             :            }
  105577           0 :         pointer[ SgStmtDeclarationStatement::pool_size -1 ].set_freepointer(NULL);
  105578             : 
  105579           0 :         blockIndex++;
  105580             :       }
  105581           2 :   }
  105582             : 
  105583             : //############################################################################
  105584             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  105585             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  105586             :  * not compressed. However, that stuff is not yet implemented! 
  105587             :  */
  105588             : unsigned long
  105589           0 : SgStmtDeclarationStatement::getNumberOfLastValidPointer()
  105590             :    {
  105591           0 :       SgStmtDeclarationStatement* testPointer = (SgStmtDeclarationStatement*)(SgStmtDeclarationStatement::pools.back());
  105592           0 :       unsigned long localIndex = SgStmtDeclarationStatement::pool_size - 1;
  105593           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  105594             :          {
  105595           0 :            localIndex--;
  105596             :          }
  105597           0 :       return (localIndex + SgStmtDeclarationStatement::pool_size * (SgStmtDeclarationStatement::pools.size()-1));
  105598             :    }
  105599             : 
  105600             : //############################################################################
  105601             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  105602             :  * memory pool and initializes the data member in class SgStmtDeclarationStatementStroageClass
  105603             :  * from its counterpart of SgStmtDeclarationStatement. The return value is just for checking, 
  105604             :  * that the whole StorageClassArray is initialized!
  105605             :  */
  105606             : unsigned long
  105607           0 : SgStmtDeclarationStatement::initializeStorageClassArray( SgStmtDeclarationStatementStorageClass *storageArray )
  105608             :    {
  105609           0 :      unsigned long storageCounter = 0;
  105610           0 :      std::vector < unsigned char* > :: const_iterator block = SgStmtDeclarationStatement::pools.begin();
  105611           0 :      SgStmtDeclarationStatement* pointer = NULL;
  105612           0 :      while ( block != SgStmtDeclarationStatement::pools.end() ) {
  105613           0 :           pointer = (SgStmtDeclarationStatement*) (*block);
  105614           0 :           for ( unsigned i = 0; i < SgStmtDeclarationStatement::pool_size; ++i ) {
  105615           0 :                if ( pointer->get_freepointer() != NULL ) {
  105616           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  105617           0 :                  storageArray++;
  105618           0 :                  storageCounter++;
  105619             :                }
  105620           0 :                pointer++;
  105621             :              }
  105622           0 :            block++;
  105623             :         }
  105624           0 :      return storageCounter;
  105625             :    }
  105626             : 
  105627             : /* #line 105628 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  105628             : 
  105629             : 
  105630             : 
  105631             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  105632             : 
  105633             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  105634             : 
  105635             : //############################################################################
  105636             : /* JH (02/02/2006) Constructor of the IR node SgStaticAssertionDeclaration that takes its 
  105637             :  * corresponding StorageClass as parameter
  105638             :  */
  105639          14 : SgStaticAssertionDeclaration :: SgStaticAssertionDeclaration ( const SgStaticAssertionDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  105640             :    {
  105641             : 
  105642             : 
  105643             : /* #line 105644 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  105644             : 
  105645          14 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  105646          14 :      p_condition =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_condition) );
  105647          14 :      p_string_literal = SgName ( storageSource.storageOf_string_literal ) ;
  105648             : 
  105649             : 
  105650             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  105651             : 
  105652             : 
  105653          14 :    }
  105654             : 
  105655             : //############################################################################
  105656             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  105657             :  * within the working AST. 
  105658             :  */
  105659          70 : SgStaticAssertionDeclaration * SgStaticAssertionDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  105660          70 :      SgStaticAssertionDeclaration* returnPointer = NULL;
  105661          70 :      if ( globalIndex != 0 )
  105662             :         {
  105663             : 
  105664             : #if FILE_IO_EXTRA_CHECK
  105665          70 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStaticAssertionDeclaration ) ) <= globalIndex ) ;
  105666          70 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStaticAssertionDeclaration + 1 ) ) );
  105667             : #endif
  105668          70 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStaticAssertionDeclaration )  
  105669          70 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStaticAssertionDeclaration );
  105670          70 :           unsigned long positionInPool = localIndex % SgStaticAssertionDeclaration::pool_size;
  105671          70 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStaticAssertionDeclaration::pool_size;
  105672             : 
  105673             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  105674             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  105675             : 
  105676          70 :           returnPointer = &( ( (SgStaticAssertionDeclaration*)(SgStaticAssertionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
  105677             : 
  105678          70 :           ROSE_ASSERT( returnPointer != NULL ) ;
  105679             :         }
  105680          70 :      return returnPointer ;
  105681             :    }
  105682             : 
  105683             : //############################################################################
  105684             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  105685             :   for the AST with the index astIndex
  105686             : */
  105687           0 : SgStaticAssertionDeclaration * SgStaticAssertionDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  105688           0 :      SgStaticAssertionDeclaration* returnPointer = NULL;
  105689           0 :      if ( globalIndex != 0 )
  105690             :         {
  105691             : 
  105692             : #if FILE_IO_EXTRA_CHECK
  105693           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStaticAssertionDeclaration ) ) <= globalIndex ) ;
  105694           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStaticAssertionDeclaration + 1 ) ) );
  105695             : #endif
  105696           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStaticAssertionDeclaration )
  105697           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStaticAssertionDeclaration );
  105698           0 :           unsigned long positionInPool = localIndex % SgStaticAssertionDeclaration::pool_size ;
  105699           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStaticAssertionDeclaration::pool_size ;
  105700             : 
  105701             : #if FILE_IO_EXTRA_CHECK
  105702             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  105703             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  105704             : #endif
  105705             : 
  105706           0 :           returnPointer = &( ( (SgStaticAssertionDeclaration*)(SgStaticAssertionDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
  105707             : 
  105708             : #if FILE_IO_EXTRA_CHECK
  105709           0 :           assert ( returnPointer != NULL ) ;
  105710             : #endif
  105711             :         }
  105712           0 :      return returnPointer ;
  105713             :    }
  105714             : 
  105715             : //############################################################################
  105716             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  105717             :  * pool size! We set for every valid object in the memory pool the freepointer
  105718             :  * to the global index and increase the global index afterwards. For all the 
  105719             :  * invalid objects (means address ranges within the memory pool that were not
  105720             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  105721             :  * distinguish valid from invalid objects! 
  105722             :  */
  105723             : unsigned long
  105724           5 : SgStaticAssertionDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  105725             :    {
  105726           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  105727           5 :      SgStaticAssertionDeclaration* pointer = NULL;
  105728           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  105729           5 :      std::vector < unsigned char* > :: const_iterator block;
  105730           6 :      for ( block = SgStaticAssertionDeclaration::pools.begin(); block != SgStaticAssertionDeclaration::pools.end() ; ++block )
  105731             :         {
  105732           1 :           pointer = (SgStaticAssertionDeclaration*)(*block);
  105733        2001 :           for (unsigned i = 0; i < SgStaticAssertionDeclaration::pool_size; ++i )
  105734             :              {
  105735             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  105736             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  105737             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  105738             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  105739             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  105740             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  105741             :             // properly; so this will have to be checked next.
  105742             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  105743             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  105744        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  105745             :                   {
  105746          14 :                     pointer[i].set_freepointer((SgStaticAssertionDeclaration*)(globalIndex));
  105747          14 :                     globalIndex++;
  105748             :                   }
  105749             :                else
  105750             :                   {
  105751        1986 :                     pointer[i].set_freepointer(NULL);
  105752             :                   }
  105753             :               }
  105754             :         }
  105755           5 :      return globalIndex;
  105756             :    }
  105757             : 
  105758             : //############################################################################
  105759             : // JH (01/14/2006)
  105760             : void
  105761           5 : SgStaticAssertionDeclaration::resetValidFreepointers( )
  105762             :    {
  105763           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  105764           5 :      SgStaticAssertionDeclaration* pointer = NULL;
  105765           5 :      std::vector < unsigned char* > :: const_iterator block;
  105766           5 :      SgStaticAssertionDeclaration* pointerOfLinkedList = NULL;
  105767           6 :      for ( block = SgStaticAssertionDeclaration::pools.begin(); block != SgStaticAssertionDeclaration::pools.end() ; ++block )
  105768             :         {
  105769           1 :           pointer = (SgStaticAssertionDeclaration*)(*block);
  105770        2001 :           for (unsigned i = 0; i < SgStaticAssertionDeclaration::pool_size; ++i )
  105771             :              {
  105772             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  105773             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  105774             :             // memory blocks!.
  105775        2000 :                if ( pointer[i].get_freepointer() != NULL )
  105776             :                   {
  105777          14 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  105778             :                   }
  105779             :                else
  105780             :                   {
  105781        1986 :                     if ( pointerOfLinkedList == NULL )
  105782             :                        {
  105783           1 :                          SgStaticAssertionDeclaration::next_node = &(pointer[i]);
  105784             :                        }
  105785             :                     else
  105786             :                        {
  105787             :                       // printf ("In SgStaticAssertionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  105788        1985 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  105789             :                        }
  105790             :                     pointerOfLinkedList = &(pointer[i]);
  105791             :                   }
  105792             :               }
  105793             :         }
  105794             : 
  105795           5 :      if ( pointerOfLinkedList != NULL )
  105796             :         {
  105797             :        // printf ("In SgStaticAssertionDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  105798           1 :           pointerOfLinkedList->set_freepointer(NULL);
  105799             :        // DQ (6/6/2010): Temporary debugging...
  105800             :        //   ROSE_ASSERT(false);
  105801             :         }
  105802             : 
  105803           5 :      return ;
  105804             :    }
  105805             : 
  105806             : //############################################################################
  105807             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  105808             :  * within the memory pool and resets the freepointers, in order to achieve a 
  105809             :  * linked list, that has no jumps and starts at the beginning! This function 
  105810             :  * does not extend the memory pool, since we do not delete any memory blocks,
  105811             :  * but delete the valid objects.  
  105812             :  */
  105813             : void
  105814           0 : SgStaticAssertionDeclaration::clearMemoryPool( )
  105815             :    {
  105816             :   // printf ("Inside of SgStaticAssertionDeclaration::clearMemoryPool() \n");
  105817             : 
  105818           0 :      SgStaticAssertionDeclaration* pointer = NULL, *tempPointer = NULL;
  105819           0 :      std::vector < unsigned char* > :: const_iterator block;
  105820           0 :      if ( SgStaticAssertionDeclaration::pools.empty() == false )
  105821             :         {
  105822           0 :           block = SgStaticAssertionDeclaration::pools.begin() ;
  105823           0 :           SgStaticAssertionDeclaration::next_node = (SgStaticAssertionDeclaration*) (*block);
  105824             : 
  105825           0 :           while ( block != SgStaticAssertionDeclaration::pools.end() )
  105826             :              {
  105827           0 :                pointer = (SgStaticAssertionDeclaration*) (*block);
  105828           0 :                if ( tempPointer != NULL )
  105829             :                   {
  105830           0 :                     tempPointer->set_freepointer(pointer);
  105831             :                   }
  105832           0 :                for (unsigned i = 0; i < SgStaticAssertionDeclaration::pool_size - 1; ++i)
  105833             :                   {
  105834           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  105835             :                   }
  105836           0 :                 pointer[SgStaticAssertionDeclaration::pool_size-1].set_freepointer(NULL);
  105837           0 :                 tempPointer = &(pointer[SgStaticAssertionDeclaration::pool_size-1]);
  105838           0 :                 ++block;
  105839             :              }
  105840             :         }
  105841           0 :    }
  105842             : 
  105843           5 : void SgStaticAssertionDeclaration::deleteMemoryPool() {
  105844           7 :   for (auto p: SgStaticAssertionDeclaration::pools) {
  105845           2 :     ROSE_FREE(p);
  105846             :   }
  105847           5 :   SgStaticAssertionDeclaration::next_node = nullptr;
  105848           5 :   SgStaticAssertionDeclaration::pools.clear();
  105849           5 : }
  105850             : 
  105851             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  105852             : //                 reading multiple binary files to for a single AST.
  105853             : /////////// new version ////////////////////////////////
  105854             : //############################################################################
  105855             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  105856             : void
  105857           2 : SgStaticAssertionDeclaration::extendMemoryPoolForFileIO( )
  105858             :   {
  105859           2 :     size_t blockIndex = SgStaticAssertionDeclaration::pools.size();
  105860           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStaticAssertionDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStaticAssertionDeclaration);
  105861             : 
  105862           3 :     while ( (blockIndex * SgStaticAssertionDeclaration::pool_size) < newPoolSize)
  105863             :       {
  105864             : #if ROSE_ALLOC_TRACE
  105865             :         if (blockIndex > 0) {
  105866             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStaticAssertionDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStaticAssertionDeclaration) = %" PRIuPTR " SgStaticAssertionDeclaration::pool_size = %d \n",
  105867             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStaticAssertionDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStaticAssertionDeclaration),SgStaticAssertionDeclaration::pool_size);
  105868             :         }
  105869             : #endif
  105870             : 
  105871           1 :         SgStaticAssertionDeclaration * pointer = (SgStaticAssertionDeclaration*) ROSE_MALLOC ( SgStaticAssertionDeclaration::pool_size * sizeof(SgStaticAssertionDeclaration) );
  105872           1 :         assert( pointer != NULL );
  105873             : #if ROSE_ALLOC_MEMSET == 1
  105874             :         memset(pointer, 0x00, SgStaticAssertionDeclaration::pool_size * sizeof(SgStaticAssertionDeclaration));
  105875             : #elif ROSE_ALLOC_MEMSET == 2
  105876             :         memset(pointer, 0xCC, SgStaticAssertionDeclaration::pool_size * sizeof(SgStaticAssertionDeclaration));
  105877             : #endif
  105878           1 :         SgStaticAssertionDeclaration::pools.push_back( (unsigned char*)(pointer) );
  105879           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStaticAssertionDeclaration::pool_size * sizeof(SgStaticAssertionDeclaration), V_SgStaticAssertionDeclaration ) );
  105880             : 
  105881           1 :         if ( SgStaticAssertionDeclaration::next_node != NULL ) {
  105882           0 :           if ( blockIndex > 0 ) {
  105883           0 :             SgStaticAssertionDeclaration * blkptr = (SgStaticAssertionDeclaration*)(SgStaticAssertionDeclaration::pools[blockIndex-1]);
  105884           0 :             blkptr[ SgStaticAssertionDeclaration::pool_size - 1 ].set_freepointer(pointer);
  105885             :           }
  105886             :         } else {
  105887           1 :           SgStaticAssertionDeclaration::next_node = pointer;
  105888             :         }
  105889             : 
  105890        2000 :         for (unsigned i = 0; i < SgStaticAssertionDeclaration::pool_size-1; ++i)
  105891             :            {
  105892        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  105893             :            }
  105894           1 :         pointer[ SgStaticAssertionDeclaration::pool_size -1 ].set_freepointer(NULL);
  105895             : 
  105896           1 :         blockIndex++;
  105897             :       }
  105898           2 :   }
  105899             : 
  105900             : //############################################################################
  105901             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  105902             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  105903             :  * not compressed. However, that stuff is not yet implemented! 
  105904             :  */
  105905             : unsigned long
  105906           0 : SgStaticAssertionDeclaration::getNumberOfLastValidPointer()
  105907             :    {
  105908           0 :       SgStaticAssertionDeclaration* testPointer = (SgStaticAssertionDeclaration*)(SgStaticAssertionDeclaration::pools.back());
  105909           0 :       unsigned long localIndex = SgStaticAssertionDeclaration::pool_size - 1;
  105910           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  105911             :          {
  105912           0 :            localIndex--;
  105913             :          }
  105914           0 :       return (localIndex + SgStaticAssertionDeclaration::pool_size * (SgStaticAssertionDeclaration::pools.size()-1));
  105915             :    }
  105916             : 
  105917             : //############################################################################
  105918             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  105919             :  * memory pool and initializes the data member in class SgStaticAssertionDeclarationStroageClass
  105920             :  * from its counterpart of SgStaticAssertionDeclaration. The return value is just for checking, 
  105921             :  * that the whole StorageClassArray is initialized!
  105922             :  */
  105923             : unsigned long
  105924           1 : SgStaticAssertionDeclaration::initializeStorageClassArray( SgStaticAssertionDeclarationStorageClass *storageArray )
  105925             :    {
  105926           1 :      unsigned long storageCounter = 0;
  105927           1 :      std::vector < unsigned char* > :: const_iterator block = SgStaticAssertionDeclaration::pools.begin();
  105928           1 :      SgStaticAssertionDeclaration* pointer = NULL;
  105929           2 :      while ( block != SgStaticAssertionDeclaration::pools.end() ) {
  105930           1 :           pointer = (SgStaticAssertionDeclaration*) (*block);
  105931        2001 :           for ( unsigned i = 0; i < SgStaticAssertionDeclaration::pool_size; ++i ) {
  105932        2000 :                if ( pointer->get_freepointer() != NULL ) {
  105933          14 :                  storageArray->pickOutIRNodeData (pointer) ;
  105934          14 :                  storageArray++;
  105935          14 :                  storageCounter++;
  105936             :                }
  105937        2000 :                pointer++;
  105938             :              }
  105939           1 :            block++;
  105940             :         }
  105941           1 :      return storageCounter;
  105942             :    }
  105943             : 
  105944             : /* #line 105945 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  105945             : 
  105946             : 
  105947             : 
  105948             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  105949             : 
  105950             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  105951             : 
  105952             : //############################################################################
  105953             : /* JH (02/02/2006) Constructor of the IR node SgOmpDeclareSimdStatement that takes its 
  105954             :  * corresponding StorageClass as parameter
  105955             :  */
  105956           0 : SgOmpDeclareSimdStatement :: SgOmpDeclareSimdStatement ( const SgOmpDeclareSimdStatementStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  105957             :    {
  105958             : 
  105959             : 
  105960             : /* #line 105961 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  105961             : 
  105962           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  105963           0 :      p_clauses = storageSource.storageOf_clauses.rebuildDataStoredInEasyStorageClass() ;
  105964           0 :      SgOmpClausePtrList::iterator i_clauses = p_clauses.begin() ; 
  105965           0 :      for ( ; i_clauses != p_clauses.end(); ++i_clauses ) 
  105966             :         {
  105967           0 :           (*i_clauses) = (SgOmpClausePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_clauses) ) );
  105968             :         }
  105969             : 
  105970             : 
  105971             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  105972             : 
  105973             : 
  105974           0 :    }
  105975             : 
  105976             : //############################################################################
  105977             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  105978             :  * within the working AST. 
  105979             :  */
  105980           0 : SgOmpDeclareSimdStatement * SgOmpDeclareSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  105981           0 :      SgOmpDeclareSimdStatement* returnPointer = NULL;
  105982           0 :      if ( globalIndex != 0 )
  105983             :         {
  105984             : 
  105985             : #if FILE_IO_EXTRA_CHECK
  105986           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDeclareSimdStatement ) ) <= globalIndex ) ;
  105987           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDeclareSimdStatement + 1 ) ) );
  105988             : #endif
  105989           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDeclareSimdStatement )  
  105990           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDeclareSimdStatement );
  105991           0 :           unsigned long positionInPool = localIndex % SgOmpDeclareSimdStatement::pool_size;
  105992           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDeclareSimdStatement::pool_size;
  105993             : 
  105994             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  105995             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  105996             : 
  105997           0 :           returnPointer = &( ( (SgOmpDeclareSimdStatement*)(SgOmpDeclareSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  105998             : 
  105999           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  106000             :         }
  106001           0 :      return returnPointer ;
  106002             :    }
  106003             : 
  106004             : //############################################################################
  106005             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  106006             :   for the AST with the index astIndex
  106007             : */
  106008           0 : SgOmpDeclareSimdStatement * SgOmpDeclareSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  106009           0 :      SgOmpDeclareSimdStatement* returnPointer = NULL;
  106010           0 :      if ( globalIndex != 0 )
  106011             :         {
  106012             : 
  106013             : #if FILE_IO_EXTRA_CHECK
  106014           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDeclareSimdStatement ) ) <= globalIndex ) ;
  106015           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDeclareSimdStatement + 1 ) ) );
  106016             : #endif
  106017           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDeclareSimdStatement )
  106018           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDeclareSimdStatement );
  106019           0 :           unsigned long positionInPool = localIndex % SgOmpDeclareSimdStatement::pool_size ;
  106020           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDeclareSimdStatement::pool_size ;
  106021             : 
  106022             : #if FILE_IO_EXTRA_CHECK
  106023             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  106024             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  106025             : #endif
  106026             : 
  106027           0 :           returnPointer = &( ( (SgOmpDeclareSimdStatement*)(SgOmpDeclareSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  106028             : 
  106029             : #if FILE_IO_EXTRA_CHECK
  106030           0 :           assert ( returnPointer != NULL ) ;
  106031             : #endif
  106032             :         }
  106033           0 :      return returnPointer ;
  106034             :    }
  106035             : 
  106036             : //############################################################################
  106037             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  106038             :  * pool size! We set for every valid object in the memory pool the freepointer
  106039             :  * to the global index and increase the global index afterwards. For all the 
  106040             :  * invalid objects (means address ranges within the memory pool that were not
  106041             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  106042             :  * distinguish valid from invalid objects! 
  106043             :  */
  106044             : unsigned long
  106045           5 : SgOmpDeclareSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  106046             :    {
  106047           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  106048           5 :      SgOmpDeclareSimdStatement* pointer = NULL;
  106049           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  106050           5 :      std::vector < unsigned char* > :: const_iterator block;
  106051           5 :      for ( block = SgOmpDeclareSimdStatement::pools.begin(); block != SgOmpDeclareSimdStatement::pools.end() ; ++block )
  106052             :         {
  106053           0 :           pointer = (SgOmpDeclareSimdStatement*)(*block);
  106054           0 :           for (unsigned i = 0; i < SgOmpDeclareSimdStatement::pool_size; ++i )
  106055             :              {
  106056             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  106057             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  106058             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  106059             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  106060             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  106061             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  106062             :             // properly; so this will have to be checked next.
  106063             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  106064             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  106065           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  106066             :                   {
  106067           0 :                     pointer[i].set_freepointer((SgOmpDeclareSimdStatement*)(globalIndex));
  106068           0 :                     globalIndex++;
  106069             :                   }
  106070             :                else
  106071             :                   {
  106072           0 :                     pointer[i].set_freepointer(NULL);
  106073             :                   }
  106074             :               }
  106075             :         }
  106076           5 :      return globalIndex;
  106077             :    }
  106078             : 
  106079             : //############################################################################
  106080             : // JH (01/14/2006)
  106081             : void
  106082           5 : SgOmpDeclareSimdStatement::resetValidFreepointers( )
  106083             :    {
  106084           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  106085           5 :      SgOmpDeclareSimdStatement* pointer = NULL;
  106086           5 :      std::vector < unsigned char* > :: const_iterator block;
  106087           5 :      SgOmpDeclareSimdStatement* pointerOfLinkedList = NULL;
  106088           5 :      for ( block = SgOmpDeclareSimdStatement::pools.begin(); block != SgOmpDeclareSimdStatement::pools.end() ; ++block )
  106089             :         {
  106090           0 :           pointer = (SgOmpDeclareSimdStatement*)(*block);
  106091           0 :           for (unsigned i = 0; i < SgOmpDeclareSimdStatement::pool_size; ++i )
  106092             :              {
  106093             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  106094             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  106095             :             // memory blocks!.
  106096           0 :                if ( pointer[i].get_freepointer() != NULL )
  106097             :                   {
  106098           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  106099             :                   }
  106100             :                else
  106101             :                   {
  106102           0 :                     if ( pointerOfLinkedList == NULL )
  106103             :                        {
  106104           0 :                          SgOmpDeclareSimdStatement::next_node = &(pointer[i]);
  106105             :                        }
  106106             :                     else
  106107             :                        {
  106108             :                       // printf ("In SgOmpDeclareSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  106109           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  106110             :                        }
  106111             :                     pointerOfLinkedList = &(pointer[i]);
  106112             :                   }
  106113             :               }
  106114             :         }
  106115             : 
  106116           5 :      if ( pointerOfLinkedList != NULL )
  106117             :         {
  106118             :        // printf ("In SgOmpDeclareSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  106119           0 :           pointerOfLinkedList->set_freepointer(NULL);
  106120             :        // DQ (6/6/2010): Temporary debugging...
  106121             :        //   ROSE_ASSERT(false);
  106122             :         }
  106123             : 
  106124           5 :      return ;
  106125             :    }
  106126             : 
  106127             : //############################################################################
  106128             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  106129             :  * within the memory pool and resets the freepointers, in order to achieve a 
  106130             :  * linked list, that has no jumps and starts at the beginning! This function 
  106131             :  * does not extend the memory pool, since we do not delete any memory blocks,
  106132             :  * but delete the valid objects.  
  106133             :  */
  106134             : void
  106135           0 : SgOmpDeclareSimdStatement::clearMemoryPool( )
  106136             :    {
  106137             :   // printf ("Inside of SgOmpDeclareSimdStatement::clearMemoryPool() \n");
  106138             : 
  106139           0 :      SgOmpDeclareSimdStatement* pointer = NULL, *tempPointer = NULL;
  106140           0 :      std::vector < unsigned char* > :: const_iterator block;
  106141           0 :      if ( SgOmpDeclareSimdStatement::pools.empty() == false )
  106142             :         {
  106143           0 :           block = SgOmpDeclareSimdStatement::pools.begin() ;
  106144           0 :           SgOmpDeclareSimdStatement::next_node = (SgOmpDeclareSimdStatement*) (*block);
  106145             : 
  106146           0 :           while ( block != SgOmpDeclareSimdStatement::pools.end() )
  106147             :              {
  106148           0 :                pointer = (SgOmpDeclareSimdStatement*) (*block);
  106149           0 :                if ( tempPointer != NULL )
  106150             :                   {
  106151           0 :                     tempPointer->set_freepointer(pointer);
  106152             :                   }
  106153           0 :                for (unsigned i = 0; i < SgOmpDeclareSimdStatement::pool_size - 1; ++i)
  106154             :                   {
  106155           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  106156             :                   }
  106157           0 :                 pointer[SgOmpDeclareSimdStatement::pool_size-1].set_freepointer(NULL);
  106158           0 :                 tempPointer = &(pointer[SgOmpDeclareSimdStatement::pool_size-1]);
  106159           0 :                 ++block;
  106160             :              }
  106161             :         }
  106162           0 :    }
  106163             : 
  106164           5 : void SgOmpDeclareSimdStatement::deleteMemoryPool() {
  106165           5 :   for (auto p: SgOmpDeclareSimdStatement::pools) {
  106166           0 :     ROSE_FREE(p);
  106167             :   }
  106168           5 :   SgOmpDeclareSimdStatement::next_node = nullptr;
  106169           5 :   SgOmpDeclareSimdStatement::pools.clear();
  106170           5 : }
  106171             : 
  106172             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  106173             : //                 reading multiple binary files to for a single AST.
  106174             : /////////// new version ////////////////////////////////
  106175             : //############################################################################
  106176             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  106177             : void
  106178           2 : SgOmpDeclareSimdStatement::extendMemoryPoolForFileIO( )
  106179             :   {
  106180           2 :     size_t blockIndex = SgOmpDeclareSimdStatement::pools.size();
  106181           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeclareSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeclareSimdStatement);
  106182             : 
  106183           2 :     while ( (blockIndex * SgOmpDeclareSimdStatement::pool_size) < newPoolSize)
  106184             :       {
  106185             : #if ROSE_ALLOC_TRACE
  106186             :         if (blockIndex > 0) {
  106187             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeclareSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeclareSimdStatement) = %" PRIuPTR " SgOmpDeclareSimdStatement::pool_size = %d \n",
  106188             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeclareSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeclareSimdStatement),SgOmpDeclareSimdStatement::pool_size);
  106189             :         }
  106190             : #endif
  106191             : 
  106192           0 :         SgOmpDeclareSimdStatement * pointer = (SgOmpDeclareSimdStatement*) ROSE_MALLOC ( SgOmpDeclareSimdStatement::pool_size * sizeof(SgOmpDeclareSimdStatement) );
  106193           0 :         assert( pointer != NULL );
  106194             : #if ROSE_ALLOC_MEMSET == 1
  106195             :         memset(pointer, 0x00, SgOmpDeclareSimdStatement::pool_size * sizeof(SgOmpDeclareSimdStatement));
  106196             : #elif ROSE_ALLOC_MEMSET == 2
  106197             :         memset(pointer, 0xCC, SgOmpDeclareSimdStatement::pool_size * sizeof(SgOmpDeclareSimdStatement));
  106198             : #endif
  106199           0 :         SgOmpDeclareSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  106200           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDeclareSimdStatement::pool_size * sizeof(SgOmpDeclareSimdStatement), V_SgOmpDeclareSimdStatement ) );
  106201             : 
  106202           0 :         if ( SgOmpDeclareSimdStatement::next_node != NULL ) {
  106203           0 :           if ( blockIndex > 0 ) {
  106204           0 :             SgOmpDeclareSimdStatement * blkptr = (SgOmpDeclareSimdStatement*)(SgOmpDeclareSimdStatement::pools[blockIndex-1]);
  106205           0 :             blkptr[ SgOmpDeclareSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  106206             :           }
  106207             :         } else {
  106208           0 :           SgOmpDeclareSimdStatement::next_node = pointer;
  106209             :         }
  106210             : 
  106211           0 :         for (unsigned i = 0; i < SgOmpDeclareSimdStatement::pool_size-1; ++i)
  106212             :            {
  106213           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  106214             :            }
  106215           0 :         pointer[ SgOmpDeclareSimdStatement::pool_size -1 ].set_freepointer(NULL);
  106216             : 
  106217           0 :         blockIndex++;
  106218             :       }
  106219           2 :   }
  106220             : 
  106221             : //############################################################################
  106222             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  106223             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  106224             :  * not compressed. However, that stuff is not yet implemented! 
  106225             :  */
  106226             : unsigned long
  106227           0 : SgOmpDeclareSimdStatement::getNumberOfLastValidPointer()
  106228             :    {
  106229           0 :       SgOmpDeclareSimdStatement* testPointer = (SgOmpDeclareSimdStatement*)(SgOmpDeclareSimdStatement::pools.back());
  106230           0 :       unsigned long localIndex = SgOmpDeclareSimdStatement::pool_size - 1;
  106231           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  106232             :          {
  106233           0 :            localIndex--;
  106234             :          }
  106235           0 :       return (localIndex + SgOmpDeclareSimdStatement::pool_size * (SgOmpDeclareSimdStatement::pools.size()-1));
  106236             :    }
  106237             : 
  106238             : //############################################################################
  106239             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  106240             :  * memory pool and initializes the data member in class SgOmpDeclareSimdStatementStroageClass
  106241             :  * from its counterpart of SgOmpDeclareSimdStatement. The return value is just for checking, 
  106242             :  * that the whole StorageClassArray is initialized!
  106243             :  */
  106244             : unsigned long
  106245           0 : SgOmpDeclareSimdStatement::initializeStorageClassArray( SgOmpDeclareSimdStatementStorageClass *storageArray )
  106246             :    {
  106247           0 :      unsigned long storageCounter = 0;
  106248           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDeclareSimdStatement::pools.begin();
  106249           0 :      SgOmpDeclareSimdStatement* pointer = NULL;
  106250           0 :      while ( block != SgOmpDeclareSimdStatement::pools.end() ) {
  106251           0 :           pointer = (SgOmpDeclareSimdStatement*) (*block);
  106252           0 :           for ( unsigned i = 0; i < SgOmpDeclareSimdStatement::pool_size; ++i ) {
  106253           0 :                if ( pointer->get_freepointer() != NULL ) {
  106254           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  106255           0 :                  storageArray++;
  106256           0 :                  storageCounter++;
  106257             :                }
  106258           0 :                pointer++;
  106259             :              }
  106260           0 :            block++;
  106261             :         }
  106262           0 :      return storageCounter;
  106263             :    }
  106264             : 
  106265             : /* #line 106266 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  106266             : 
  106267             : 
  106268             : 
  106269             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  106270             : 
  106271             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  106272             : 
  106273             : //############################################################################
  106274             : /* JH (02/02/2006) Constructor of the IR node SgMicrosoftAttributeDeclaration that takes its 
  106275             :  * corresponding StorageClass as parameter
  106276             :  */
  106277           0 : SgMicrosoftAttributeDeclaration :: SgMicrosoftAttributeDeclaration ( const SgMicrosoftAttributeDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  106278             :    {
  106279             : 
  106280             : 
  106281             : /* #line 106282 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  106282             : 
  106283           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  106284           0 :      p_attribute_string = SgName ( storageSource.storageOf_attribute_string ) ;
  106285             : 
  106286             : 
  106287             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  106288             : 
  106289             : 
  106290           0 :    }
  106291             : 
  106292             : //############################################################################
  106293             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  106294             :  * within the working AST. 
  106295             :  */
  106296           0 : SgMicrosoftAttributeDeclaration * SgMicrosoftAttributeDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  106297           0 :      SgMicrosoftAttributeDeclaration* returnPointer = NULL;
  106298           0 :      if ( globalIndex != 0 )
  106299             :         {
  106300             : 
  106301             : #if FILE_IO_EXTRA_CHECK
  106302           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMicrosoftAttributeDeclaration ) ) <= globalIndex ) ;
  106303           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMicrosoftAttributeDeclaration + 1 ) ) );
  106304             : #endif
  106305           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMicrosoftAttributeDeclaration )  
  106306           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMicrosoftAttributeDeclaration );
  106307           0 :           unsigned long positionInPool = localIndex % SgMicrosoftAttributeDeclaration::pool_size;
  106308           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMicrosoftAttributeDeclaration::pool_size;
  106309             : 
  106310             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  106311             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  106312             : 
  106313           0 :           returnPointer = &( ( (SgMicrosoftAttributeDeclaration*)(SgMicrosoftAttributeDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
  106314             : 
  106315           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  106316             :         }
  106317           0 :      return returnPointer ;
  106318             :    }
  106319             : 
  106320             : //############################################################################
  106321             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  106322             :   for the AST with the index astIndex
  106323             : */
  106324           0 : SgMicrosoftAttributeDeclaration * SgMicrosoftAttributeDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  106325           0 :      SgMicrosoftAttributeDeclaration* returnPointer = NULL;
  106326           0 :      if ( globalIndex != 0 )
  106327             :         {
  106328             : 
  106329             : #if FILE_IO_EXTRA_CHECK
  106330           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMicrosoftAttributeDeclaration ) ) <= globalIndex ) ;
  106331           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMicrosoftAttributeDeclaration + 1 ) ) );
  106332             : #endif
  106333           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMicrosoftAttributeDeclaration )
  106334           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMicrosoftAttributeDeclaration );
  106335           0 :           unsigned long positionInPool = localIndex % SgMicrosoftAttributeDeclaration::pool_size ;
  106336           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMicrosoftAttributeDeclaration::pool_size ;
  106337             : 
  106338             : #if FILE_IO_EXTRA_CHECK
  106339             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  106340             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  106341             : #endif
  106342             : 
  106343           0 :           returnPointer = &( ( (SgMicrosoftAttributeDeclaration*)(SgMicrosoftAttributeDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
  106344             : 
  106345             : #if FILE_IO_EXTRA_CHECK
  106346           0 :           assert ( returnPointer != NULL ) ;
  106347             : #endif
  106348             :         }
  106349           0 :      return returnPointer ;
  106350             :    }
  106351             : 
  106352             : //############################################################################
  106353             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  106354             :  * pool size! We set for every valid object in the memory pool the freepointer
  106355             :  * to the global index and increase the global index afterwards. For all the 
  106356             :  * invalid objects (means address ranges within the memory pool that were not
  106357             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  106358             :  * distinguish valid from invalid objects! 
  106359             :  */
  106360             : unsigned long
  106361           5 : SgMicrosoftAttributeDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  106362             :    {
  106363           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  106364           5 :      SgMicrosoftAttributeDeclaration* pointer = NULL;
  106365           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  106366           5 :      std::vector < unsigned char* > :: const_iterator block;
  106367           5 :      for ( block = SgMicrosoftAttributeDeclaration::pools.begin(); block != SgMicrosoftAttributeDeclaration::pools.end() ; ++block )
  106368             :         {
  106369           0 :           pointer = (SgMicrosoftAttributeDeclaration*)(*block);
  106370           0 :           for (unsigned i = 0; i < SgMicrosoftAttributeDeclaration::pool_size; ++i )
  106371             :              {
  106372             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  106373             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  106374             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  106375             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  106376             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  106377             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  106378             :             // properly; so this will have to be checked next.
  106379             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  106380             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  106381           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  106382             :                   {
  106383           0 :                     pointer[i].set_freepointer((SgMicrosoftAttributeDeclaration*)(globalIndex));
  106384           0 :                     globalIndex++;
  106385             :                   }
  106386             :                else
  106387             :                   {
  106388           0 :                     pointer[i].set_freepointer(NULL);
  106389             :                   }
  106390             :               }
  106391             :         }
  106392           5 :      return globalIndex;
  106393             :    }
  106394             : 
  106395             : //############################################################################
  106396             : // JH (01/14/2006)
  106397             : void
  106398           5 : SgMicrosoftAttributeDeclaration::resetValidFreepointers( )
  106399             :    {
  106400           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  106401           5 :      SgMicrosoftAttributeDeclaration* pointer = NULL;
  106402           5 :      std::vector < unsigned char* > :: const_iterator block;
  106403           5 :      SgMicrosoftAttributeDeclaration* pointerOfLinkedList = NULL;
  106404           5 :      for ( block = SgMicrosoftAttributeDeclaration::pools.begin(); block != SgMicrosoftAttributeDeclaration::pools.end() ; ++block )
  106405             :         {
  106406           0 :           pointer = (SgMicrosoftAttributeDeclaration*)(*block);
  106407           0 :           for (unsigned i = 0; i < SgMicrosoftAttributeDeclaration::pool_size; ++i )
  106408             :              {
  106409             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  106410             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  106411             :             // memory blocks!.
  106412           0 :                if ( pointer[i].get_freepointer() != NULL )
  106413             :                   {
  106414           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  106415             :                   }
  106416             :                else
  106417             :                   {
  106418           0 :                     if ( pointerOfLinkedList == NULL )
  106419             :                        {
  106420           0 :                          SgMicrosoftAttributeDeclaration::next_node = &(pointer[i]);
  106421             :                        }
  106422             :                     else
  106423             :                        {
  106424             :                       // printf ("In SgMicrosoftAttributeDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  106425           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  106426             :                        }
  106427             :                     pointerOfLinkedList = &(pointer[i]);
  106428             :                   }
  106429             :               }
  106430             :         }
  106431             : 
  106432           5 :      if ( pointerOfLinkedList != NULL )
  106433             :         {
  106434             :        // printf ("In SgMicrosoftAttributeDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  106435           0 :           pointerOfLinkedList->set_freepointer(NULL);
  106436             :        // DQ (6/6/2010): Temporary debugging...
  106437             :        //   ROSE_ASSERT(false);
  106438             :         }
  106439             : 
  106440           5 :      return ;
  106441             :    }
  106442             : 
  106443             : //############################################################################
  106444             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  106445             :  * within the memory pool and resets the freepointers, in order to achieve a 
  106446             :  * linked list, that has no jumps and starts at the beginning! This function 
  106447             :  * does not extend the memory pool, since we do not delete any memory blocks,
  106448             :  * but delete the valid objects.  
  106449             :  */
  106450             : void
  106451           0 : SgMicrosoftAttributeDeclaration::clearMemoryPool( )
  106452             :    {
  106453             :   // printf ("Inside of SgMicrosoftAttributeDeclaration::clearMemoryPool() \n");
  106454             : 
  106455           0 :      SgMicrosoftAttributeDeclaration* pointer = NULL, *tempPointer = NULL;
  106456           0 :      std::vector < unsigned char* > :: const_iterator block;
  106457           0 :      if ( SgMicrosoftAttributeDeclaration::pools.empty() == false )
  106458             :         {
  106459           0 :           block = SgMicrosoftAttributeDeclaration::pools.begin() ;
  106460           0 :           SgMicrosoftAttributeDeclaration::next_node = (SgMicrosoftAttributeDeclaration*) (*block);
  106461             : 
  106462           0 :           while ( block != SgMicrosoftAttributeDeclaration::pools.end() )
  106463             :              {
  106464           0 :                pointer = (SgMicrosoftAttributeDeclaration*) (*block);
  106465           0 :                if ( tempPointer != NULL )
  106466             :                   {
  106467           0 :                     tempPointer->set_freepointer(pointer);
  106468             :                   }
  106469           0 :                for (unsigned i = 0; i < SgMicrosoftAttributeDeclaration::pool_size - 1; ++i)
  106470             :                   {
  106471           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  106472             :                   }
  106473           0 :                 pointer[SgMicrosoftAttributeDeclaration::pool_size-1].set_freepointer(NULL);
  106474           0 :                 tempPointer = &(pointer[SgMicrosoftAttributeDeclaration::pool_size-1]);
  106475           0 :                 ++block;
  106476             :              }
  106477             :         }
  106478           0 :    }
  106479             : 
  106480           5 : void SgMicrosoftAttributeDeclaration::deleteMemoryPool() {
  106481           5 :   for (auto p: SgMicrosoftAttributeDeclaration::pools) {
  106482           0 :     ROSE_FREE(p);
  106483             :   }
  106484           5 :   SgMicrosoftAttributeDeclaration::next_node = nullptr;
  106485           5 :   SgMicrosoftAttributeDeclaration::pools.clear();
  106486           5 : }
  106487             : 
  106488             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  106489             : //                 reading multiple binary files to for a single AST.
  106490             : /////////// new version ////////////////////////////////
  106491             : //############################################################################
  106492             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  106493             : void
  106494           2 : SgMicrosoftAttributeDeclaration::extendMemoryPoolForFileIO( )
  106495             :   {
  106496           2 :     size_t blockIndex = SgMicrosoftAttributeDeclaration::pools.size();
  106497           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMicrosoftAttributeDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMicrosoftAttributeDeclaration);
  106498             : 
  106499           2 :     while ( (blockIndex * SgMicrosoftAttributeDeclaration::pool_size) < newPoolSize)
  106500             :       {
  106501             : #if ROSE_ALLOC_TRACE
  106502             :         if (blockIndex > 0) {
  106503             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMicrosoftAttributeDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMicrosoftAttributeDeclaration) = %" PRIuPTR " SgMicrosoftAttributeDeclaration::pool_size = %d \n",
  106504             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMicrosoftAttributeDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMicrosoftAttributeDeclaration),SgMicrosoftAttributeDeclaration::pool_size);
  106505             :         }
  106506             : #endif
  106507             : 
  106508           0 :         SgMicrosoftAttributeDeclaration * pointer = (SgMicrosoftAttributeDeclaration*) ROSE_MALLOC ( SgMicrosoftAttributeDeclaration::pool_size * sizeof(SgMicrosoftAttributeDeclaration) );
  106509           0 :         assert( pointer != NULL );
  106510             : #if ROSE_ALLOC_MEMSET == 1
  106511             :         memset(pointer, 0x00, SgMicrosoftAttributeDeclaration::pool_size * sizeof(SgMicrosoftAttributeDeclaration));
  106512             : #elif ROSE_ALLOC_MEMSET == 2
  106513             :         memset(pointer, 0xCC, SgMicrosoftAttributeDeclaration::pool_size * sizeof(SgMicrosoftAttributeDeclaration));
  106514             : #endif
  106515           0 :         SgMicrosoftAttributeDeclaration::pools.push_back( (unsigned char*)(pointer) );
  106516           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMicrosoftAttributeDeclaration::pool_size * sizeof(SgMicrosoftAttributeDeclaration), V_SgMicrosoftAttributeDeclaration ) );
  106517             : 
  106518           0 :         if ( SgMicrosoftAttributeDeclaration::next_node != NULL ) {
  106519           0 :           if ( blockIndex > 0 ) {
  106520           0 :             SgMicrosoftAttributeDeclaration * blkptr = (SgMicrosoftAttributeDeclaration*)(SgMicrosoftAttributeDeclaration::pools[blockIndex-1]);
  106521           0 :             blkptr[ SgMicrosoftAttributeDeclaration::pool_size - 1 ].set_freepointer(pointer);
  106522             :           }
  106523             :         } else {
  106524           0 :           SgMicrosoftAttributeDeclaration::next_node = pointer;
  106525             :         }
  106526             : 
  106527           0 :         for (unsigned i = 0; i < SgMicrosoftAttributeDeclaration::pool_size-1; ++i)
  106528             :            {
  106529           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  106530             :            }
  106531           0 :         pointer[ SgMicrosoftAttributeDeclaration::pool_size -1 ].set_freepointer(NULL);
  106532             : 
  106533           0 :         blockIndex++;
  106534             :       }
  106535           2 :   }
  106536             : 
  106537             : //############################################################################
  106538             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  106539             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  106540             :  * not compressed. However, that stuff is not yet implemented! 
  106541             :  */
  106542             : unsigned long
  106543           0 : SgMicrosoftAttributeDeclaration::getNumberOfLastValidPointer()
  106544             :    {
  106545           0 :       SgMicrosoftAttributeDeclaration* testPointer = (SgMicrosoftAttributeDeclaration*)(SgMicrosoftAttributeDeclaration::pools.back());
  106546           0 :       unsigned long localIndex = SgMicrosoftAttributeDeclaration::pool_size - 1;
  106547           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  106548             :          {
  106549           0 :            localIndex--;
  106550             :          }
  106551           0 :       return (localIndex + SgMicrosoftAttributeDeclaration::pool_size * (SgMicrosoftAttributeDeclaration::pools.size()-1));
  106552             :    }
  106553             : 
  106554             : //############################################################################
  106555             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  106556             :  * memory pool and initializes the data member in class SgMicrosoftAttributeDeclarationStroageClass
  106557             :  * from its counterpart of SgMicrosoftAttributeDeclaration. The return value is just for checking, 
  106558             :  * that the whole StorageClassArray is initialized!
  106559             :  */
  106560             : unsigned long
  106561           0 : SgMicrosoftAttributeDeclaration::initializeStorageClassArray( SgMicrosoftAttributeDeclarationStorageClass *storageArray )
  106562             :    {
  106563           0 :      unsigned long storageCounter = 0;
  106564           0 :      std::vector < unsigned char* > :: const_iterator block = SgMicrosoftAttributeDeclaration::pools.begin();
  106565           0 :      SgMicrosoftAttributeDeclaration* pointer = NULL;
  106566           0 :      while ( block != SgMicrosoftAttributeDeclaration::pools.end() ) {
  106567           0 :           pointer = (SgMicrosoftAttributeDeclaration*) (*block);
  106568           0 :           for ( unsigned i = 0; i < SgMicrosoftAttributeDeclaration::pool_size; ++i ) {
  106569           0 :                if ( pointer->get_freepointer() != NULL ) {
  106570           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  106571           0 :                  storageArray++;
  106572           0 :                  storageCounter++;
  106573             :                }
  106574           0 :                pointer++;
  106575             :              }
  106576           0 :            block++;
  106577             :         }
  106578           0 :      return storageCounter;
  106579             :    }
  106580             : 
  106581             : /* #line 106582 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  106582             : 
  106583             : 
  106584             : 
  106585             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  106586             : 
  106587             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  106588             : 
  106589             : //############################################################################
  106590             : /* JH (02/02/2006) Constructor of the IR node SgNonrealDecl that takes its 
  106591             :  * corresponding StorageClass as parameter
  106592             :  */
  106593        5080 : SgNonrealDecl :: SgNonrealDecl ( const SgNonrealDeclStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  106594             :    {
  106595             : 
  106596             : 
  106597             : /* #line 106598 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  106598             : 
  106599        5080 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  106600        5080 :      p_name = SgName ( storageSource.storageOf_name ) ;
  106601        5080 :      p_nonreal_decl_scope =  (SgDeclarationScope*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nonreal_decl_scope) );
  106602        5080 :      p_type =  (SgNonrealType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
  106603        5080 :      p_template_parameter_position = storageSource.storageOf_template_parameter_position ;
  106604        5080 :      p_template_parameter_depth = storageSource.storageOf_template_parameter_depth ;
  106605        5080 :      p_templateDeclaration =  (SgDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_templateDeclaration) );
  106606        5080 :      p_tpl_args = storageSource.storageOf_tpl_args.rebuildDataStoredInEasyStorageClass() ;
  106607        5080 :      SgTemplateArgumentPtrList::iterator i_tpl_args = p_tpl_args.begin() ; 
  106608        7999 :      for ( ; i_tpl_args != p_tpl_args.end(); ++i_tpl_args ) 
  106609             :         {
  106610        2919 :           (*i_tpl_args) = (SgTemplateArgumentPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_tpl_args) ) );
  106611             :         }
  106612        5080 :      p_tpl_params = storageSource.storageOf_tpl_params.rebuildDataStoredInEasyStorageClass() ;
  106613        5080 :      SgTemplateParameterPtrList::iterator i_tpl_params = p_tpl_params.begin() ; 
  106614        5090 :      for ( ; i_tpl_params != p_tpl_params.end(); ++i_tpl_params ) 
  106615             :         {
  106616          10 :           (*i_tpl_params) = (SgTemplateParameterPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_tpl_params) ) );
  106617             :         }
  106618        5080 :      p_is_class_member = storageSource.storageOf_is_class_member ;
  106619        5080 :      p_is_template_param = storageSource.storageOf_is_template_param ;
  106620        5080 :      p_is_template_template_param = storageSource.storageOf_is_template_template_param ;
  106621        5080 :      p_is_nonreal_template = storageSource.storageOf_is_nonreal_template ;
  106622        5080 :      p_is_nonreal_function = storageSource.storageOf_is_nonreal_function ;
  106623             : 
  106624             : 
  106625             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  106626             : 
  106627             : 
  106628        5080 :    }
  106629             : 
  106630             : //############################################################################
  106631             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  106632             :  * within the working AST. 
  106633             :  */
  106634       31109 : SgNonrealDecl * SgNonrealDecl::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  106635       31109 :      SgNonrealDecl* returnPointer = NULL;
  106636       31109 :      if ( globalIndex != 0 )
  106637             :         {
  106638             : 
  106639             : #if FILE_IO_EXTRA_CHECK
  106640       31109 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNonrealDecl ) ) <= globalIndex ) ;
  106641       31109 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealDecl + 1 ) ) );
  106642             : #endif
  106643       31109 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealDecl )  
  106644       31109 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNonrealDecl );
  106645       31109 :           unsigned long positionInPool = localIndex % SgNonrealDecl::pool_size;
  106646       31109 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealDecl::pool_size;
  106647             : 
  106648             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  106649             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  106650             : 
  106651       31109 :           returnPointer = &( ( (SgNonrealDecl*)(SgNonrealDecl::pools[memoryBlock]) ) [positionInPool]) ;
  106652             : 
  106653       31109 :           ROSE_ASSERT( returnPointer != NULL ) ;
  106654             :         }
  106655       31109 :      return returnPointer ;
  106656             :    }
  106657             : 
  106658             : //############################################################################
  106659             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  106660             :   for the AST with the index astIndex
  106661             : */
  106662           0 : SgNonrealDecl * SgNonrealDecl::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  106663           0 :      SgNonrealDecl* returnPointer = NULL;
  106664           0 :      if ( globalIndex != 0 )
  106665             :         {
  106666             : 
  106667             : #if FILE_IO_EXTRA_CHECK
  106668           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNonrealDecl ) ) <= globalIndex ) ;
  106669           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealDecl + 1 ) ) );
  106670             : #endif
  106671           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealDecl )
  106672           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNonrealDecl );
  106673           0 :           unsigned long positionInPool = localIndex % SgNonrealDecl::pool_size ;
  106674           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealDecl::pool_size ;
  106675             : 
  106676             : #if FILE_IO_EXTRA_CHECK
  106677             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  106678             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  106679             : #endif
  106680             : 
  106681           0 :           returnPointer = &( ( (SgNonrealDecl*)(SgNonrealDecl::pools[memoryBlock]) ) [positionInPool]) ;
  106682             : 
  106683             : #if FILE_IO_EXTRA_CHECK
  106684           0 :           assert ( returnPointer != NULL ) ;
  106685             : #endif
  106686             :         }
  106687           0 :      return returnPointer ;
  106688             :    }
  106689             : 
  106690             : //############################################################################
  106691             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  106692             :  * pool size! We set for every valid object in the memory pool the freepointer
  106693             :  * to the global index and increase the global index afterwards. For all the 
  106694             :  * invalid objects (means address ranges within the memory pool that were not
  106695             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  106696             :  * distinguish valid from invalid objects! 
  106697             :  */
  106698             : unsigned long
  106699           5 : SgNonrealDecl::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  106700             :    {
  106701           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  106702           5 :      SgNonrealDecl* pointer = NULL;
  106703           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  106704           5 :      std::vector < unsigned char* > :: const_iterator block;
  106705           8 :      for ( block = SgNonrealDecl::pools.begin(); block != SgNonrealDecl::pools.end() ; ++block )
  106706             :         {
  106707           3 :           pointer = (SgNonrealDecl*)(*block);
  106708        6003 :           for (unsigned i = 0; i < SgNonrealDecl::pool_size; ++i )
  106709             :              {
  106710             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  106711             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  106712             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  106713             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  106714             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  106715             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  106716             :             // properly; so this will have to be checked next.
  106717             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  106718             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  106719        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  106720             :                   {
  106721        5080 :                     pointer[i].set_freepointer((SgNonrealDecl*)(globalIndex));
  106722        5080 :                     globalIndex++;
  106723             :                   }
  106724             :                else
  106725             :                   {
  106726         920 :                     pointer[i].set_freepointer(NULL);
  106727             :                   }
  106728             :               }
  106729             :         }
  106730           5 :      return globalIndex;
  106731             :    }
  106732             : 
  106733             : //############################################################################
  106734             : // JH (01/14/2006)
  106735             : void
  106736           5 : SgNonrealDecl::resetValidFreepointers( )
  106737             :    {
  106738           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  106739           5 :      SgNonrealDecl* pointer = NULL;
  106740           5 :      std::vector < unsigned char* > :: const_iterator block;
  106741           5 :      SgNonrealDecl* pointerOfLinkedList = NULL;
  106742           8 :      for ( block = SgNonrealDecl::pools.begin(); block != SgNonrealDecl::pools.end() ; ++block )
  106743             :         {
  106744           3 :           pointer = (SgNonrealDecl*)(*block);
  106745        6003 :           for (unsigned i = 0; i < SgNonrealDecl::pool_size; ++i )
  106746             :              {
  106747             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  106748             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  106749             :             // memory blocks!.
  106750        6000 :                if ( pointer[i].get_freepointer() != NULL )
  106751             :                   {
  106752        5080 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  106753             :                   }
  106754             :                else
  106755             :                   {
  106756         920 :                     if ( pointerOfLinkedList == NULL )
  106757             :                        {
  106758           1 :                          SgNonrealDecl::next_node = &(pointer[i]);
  106759             :                        }
  106760             :                     else
  106761             :                        {
  106762             :                       // printf ("In SgNonrealDecl::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  106763         919 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  106764             :                        }
  106765             :                     pointerOfLinkedList = &(pointer[i]);
  106766             :                   }
  106767             :               }
  106768             :         }
  106769             : 
  106770           5 :      if ( pointerOfLinkedList != NULL )
  106771             :         {
  106772             :        // printf ("In SgNonrealDecl::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  106773           1 :           pointerOfLinkedList->set_freepointer(NULL);
  106774             :        // DQ (6/6/2010): Temporary debugging...
  106775             :        //   ROSE_ASSERT(false);
  106776             :         }
  106777             : 
  106778           5 :      return ;
  106779             :    }
  106780             : 
  106781             : //############################################################################
  106782             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  106783             :  * within the memory pool and resets the freepointers, in order to achieve a 
  106784             :  * linked list, that has no jumps and starts at the beginning! This function 
  106785             :  * does not extend the memory pool, since we do not delete any memory blocks,
  106786             :  * but delete the valid objects.  
  106787             :  */
  106788             : void
  106789           0 : SgNonrealDecl::clearMemoryPool( )
  106790             :    {
  106791             :   // printf ("Inside of SgNonrealDecl::clearMemoryPool() \n");
  106792             : 
  106793           0 :      SgNonrealDecl* pointer = NULL, *tempPointer = NULL;
  106794           0 :      std::vector < unsigned char* > :: const_iterator block;
  106795           0 :      if ( SgNonrealDecl::pools.empty() == false )
  106796             :         {
  106797           0 :           block = SgNonrealDecl::pools.begin() ;
  106798           0 :           SgNonrealDecl::next_node = (SgNonrealDecl*) (*block);
  106799             : 
  106800           0 :           while ( block != SgNonrealDecl::pools.end() )
  106801             :              {
  106802           0 :                pointer = (SgNonrealDecl*) (*block);
  106803           0 :                if ( tempPointer != NULL )
  106804             :                   {
  106805           0 :                     tempPointer->set_freepointer(pointer);
  106806             :                   }
  106807           0 :                for (unsigned i = 0; i < SgNonrealDecl::pool_size - 1; ++i)
  106808             :                   {
  106809           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  106810             :                   }
  106811           0 :                 pointer[SgNonrealDecl::pool_size-1].set_freepointer(NULL);
  106812           0 :                 tempPointer = &(pointer[SgNonrealDecl::pool_size-1]);
  106813           0 :                 ++block;
  106814             :              }
  106815             :         }
  106816           0 :    }
  106817             : 
  106818           5 : void SgNonrealDecl::deleteMemoryPool() {
  106819          11 :   for (auto p: SgNonrealDecl::pools) {
  106820           6 :     ROSE_FREE(p);
  106821             :   }
  106822           5 :   SgNonrealDecl::next_node = nullptr;
  106823           5 :   SgNonrealDecl::pools.clear();
  106824           5 : }
  106825             : 
  106826             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  106827             : //                 reading multiple binary files to for a single AST.
  106828             : /////////// new version ////////////////////////////////
  106829             : //############################################################################
  106830             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  106831             : void
  106832           2 : SgNonrealDecl::extendMemoryPoolForFileIO( )
  106833             :   {
  106834           2 :     size_t blockIndex = SgNonrealDecl::pools.size();
  106835           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealDecl) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealDecl);
  106836             : 
  106837           5 :     while ( (blockIndex * SgNonrealDecl::pool_size) < newPoolSize)
  106838             :       {
  106839             : #if ROSE_ALLOC_TRACE
  106840             :         if (blockIndex > 0) {
  106841             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealDecl) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealDecl) = %" PRIuPTR " SgNonrealDecl::pool_size = %d \n",
  106842             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealDecl),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealDecl),SgNonrealDecl::pool_size);
  106843             :         }
  106844             : #endif
  106845             : 
  106846           3 :         SgNonrealDecl * pointer = (SgNonrealDecl*) ROSE_MALLOC ( SgNonrealDecl::pool_size * sizeof(SgNonrealDecl) );
  106847           3 :         assert( pointer != NULL );
  106848             : #if ROSE_ALLOC_MEMSET == 1
  106849             :         memset(pointer, 0x00, SgNonrealDecl::pool_size * sizeof(SgNonrealDecl));
  106850             : #elif ROSE_ALLOC_MEMSET == 2
  106851             :         memset(pointer, 0xCC, SgNonrealDecl::pool_size * sizeof(SgNonrealDecl));
  106852             : #endif
  106853           3 :         SgNonrealDecl::pools.push_back( (unsigned char*)(pointer) );
  106854           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNonrealDecl::pool_size * sizeof(SgNonrealDecl), V_SgNonrealDecl ) );
  106855             : 
  106856           3 :         if ( SgNonrealDecl::next_node != NULL ) {
  106857           2 :           if ( blockIndex > 0 ) {
  106858           2 :             SgNonrealDecl * blkptr = (SgNonrealDecl*)(SgNonrealDecl::pools[blockIndex-1]);
  106859           2 :             blkptr[ SgNonrealDecl::pool_size - 1 ].set_freepointer(pointer);
  106860             :           }
  106861             :         } else {
  106862           1 :           SgNonrealDecl::next_node = pointer;
  106863             :         }
  106864             : 
  106865        6000 :         for (unsigned i = 0; i < SgNonrealDecl::pool_size-1; ++i)
  106866             :            {
  106867        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  106868             :            }
  106869           3 :         pointer[ SgNonrealDecl::pool_size -1 ].set_freepointer(NULL);
  106870             : 
  106871           3 :         blockIndex++;
  106872             :       }
  106873           2 :   }
  106874             : 
  106875             : //############################################################################
  106876             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  106877             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  106878             :  * not compressed. However, that stuff is not yet implemented! 
  106879             :  */
  106880             : unsigned long
  106881           0 : SgNonrealDecl::getNumberOfLastValidPointer()
  106882             :    {
  106883           0 :       SgNonrealDecl* testPointer = (SgNonrealDecl*)(SgNonrealDecl::pools.back());
  106884           0 :       unsigned long localIndex = SgNonrealDecl::pool_size - 1;
  106885           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  106886             :          {
  106887           0 :            localIndex--;
  106888             :          }
  106889           0 :       return (localIndex + SgNonrealDecl::pool_size * (SgNonrealDecl::pools.size()-1));
  106890             :    }
  106891             : 
  106892             : //############################################################################
  106893             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  106894             :  * memory pool and initializes the data member in class SgNonrealDeclStroageClass
  106895             :  * from its counterpart of SgNonrealDecl. The return value is just for checking, 
  106896             :  * that the whole StorageClassArray is initialized!
  106897             :  */
  106898             : unsigned long
  106899           1 : SgNonrealDecl::initializeStorageClassArray( SgNonrealDeclStorageClass *storageArray )
  106900             :    {
  106901           1 :      unsigned long storageCounter = 0;
  106902           1 :      std::vector < unsigned char* > :: const_iterator block = SgNonrealDecl::pools.begin();
  106903           1 :      SgNonrealDecl* pointer = NULL;
  106904           4 :      while ( block != SgNonrealDecl::pools.end() ) {
  106905           3 :           pointer = (SgNonrealDecl*) (*block);
  106906        6003 :           for ( unsigned i = 0; i < SgNonrealDecl::pool_size; ++i ) {
  106907        6000 :                if ( pointer->get_freepointer() != NULL ) {
  106908        5080 :                  storageArray->pickOutIRNodeData (pointer) ;
  106909        5080 :                  storageArray++;
  106910        5080 :                  storageCounter++;
  106911             :                }
  106912        6000 :                pointer++;
  106913             :              }
  106914           3 :            block++;
  106915             :         }
  106916           1 :      return storageCounter;
  106917             :    }
  106918             : 
  106919             : /* #line 106920 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  106920             : 
  106921             : 
  106922             : 
  106923             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  106924             : 
  106925             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  106926             : 
  106927             : //############################################################################
  106928             : /* JH (02/02/2006) Constructor of the IR node SgEmptyDeclaration that takes its 
  106929             :  * corresponding StorageClass as parameter
  106930             :  */
  106931           0 : SgEmptyDeclaration :: SgEmptyDeclaration ( const SgEmptyDeclarationStorageClass& storageSource )   : SgDeclarationStatement (storageSource)
  106932             :    {
  106933             : 
  106934             : 
  106935             : /* #line 106936 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  106936             : 
  106937           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  106938             : 
  106939             : 
  106940             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  106941             : 
  106942             : 
  106943           0 :    }
  106944             : 
  106945             : //############################################################################
  106946             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  106947             :  * within the working AST. 
  106948             :  */
  106949           0 : SgEmptyDeclaration * SgEmptyDeclaration::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  106950           0 :      SgEmptyDeclaration* returnPointer = NULL;
  106951           0 :      if ( globalIndex != 0 )
  106952             :         {
  106953             : 
  106954             : #if FILE_IO_EXTRA_CHECK
  106955           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEmptyDeclaration ) ) <= globalIndex ) ;
  106956           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEmptyDeclaration + 1 ) ) );
  106957             : #endif
  106958           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEmptyDeclaration )  
  106959           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEmptyDeclaration );
  106960           0 :           unsigned long positionInPool = localIndex % SgEmptyDeclaration::pool_size;
  106961           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEmptyDeclaration::pool_size;
  106962             : 
  106963             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  106964             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  106965             : 
  106966           0 :           returnPointer = &( ( (SgEmptyDeclaration*)(SgEmptyDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
  106967             : 
  106968           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  106969             :         }
  106970           0 :      return returnPointer ;
  106971             :    }
  106972             : 
  106973             : //############################################################################
  106974             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  106975             :   for the AST with the index astIndex
  106976             : */
  106977           0 : SgEmptyDeclaration * SgEmptyDeclaration::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  106978           0 :      SgEmptyDeclaration* returnPointer = NULL;
  106979           0 :      if ( globalIndex != 0 )
  106980             :         {
  106981             : 
  106982             : #if FILE_IO_EXTRA_CHECK
  106983           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEmptyDeclaration ) ) <= globalIndex ) ;
  106984           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEmptyDeclaration + 1 ) ) );
  106985             : #endif
  106986           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEmptyDeclaration )
  106987           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEmptyDeclaration );
  106988           0 :           unsigned long positionInPool = localIndex % SgEmptyDeclaration::pool_size ;
  106989           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEmptyDeclaration::pool_size ;
  106990             : 
  106991             : #if FILE_IO_EXTRA_CHECK
  106992             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  106993             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  106994             : #endif
  106995             : 
  106996           0 :           returnPointer = &( ( (SgEmptyDeclaration*)(SgEmptyDeclaration::pools[memoryBlock]) ) [positionInPool]) ;
  106997             : 
  106998             : #if FILE_IO_EXTRA_CHECK
  106999           0 :           assert ( returnPointer != NULL ) ;
  107000             : #endif
  107001             :         }
  107002           0 :      return returnPointer ;
  107003             :    }
  107004             : 
  107005             : //############################################################################
  107006             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  107007             :  * pool size! We set for every valid object in the memory pool the freepointer
  107008             :  * to the global index and increase the global index afterwards. For all the 
  107009             :  * invalid objects (means address ranges within the memory pool that were not
  107010             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  107011             :  * distinguish valid from invalid objects! 
  107012             :  */
  107013             : unsigned long
  107014           5 : SgEmptyDeclaration::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  107015             :    {
  107016           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  107017           5 :      SgEmptyDeclaration* pointer = NULL;
  107018           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  107019           5 :      std::vector < unsigned char* > :: const_iterator block;
  107020           5 :      for ( block = SgEmptyDeclaration::pools.begin(); block != SgEmptyDeclaration::pools.end() ; ++block )
  107021             :         {
  107022           0 :           pointer = (SgEmptyDeclaration*)(*block);
  107023           0 :           for (unsigned i = 0; i < SgEmptyDeclaration::pool_size; ++i )
  107024             :              {
  107025             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  107026             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  107027             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  107028             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  107029             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  107030             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  107031             :             // properly; so this will have to be checked next.
  107032             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  107033             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  107034           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  107035             :                   {
  107036           0 :                     pointer[i].set_freepointer((SgEmptyDeclaration*)(globalIndex));
  107037           0 :                     globalIndex++;
  107038             :                   }
  107039             :                else
  107040             :                   {
  107041           0 :                     pointer[i].set_freepointer(NULL);
  107042             :                   }
  107043             :               }
  107044             :         }
  107045           5 :      return globalIndex;
  107046             :    }
  107047             : 
  107048             : //############################################################################
  107049             : // JH (01/14/2006)
  107050             : void
  107051           5 : SgEmptyDeclaration::resetValidFreepointers( )
  107052             :    {
  107053           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  107054           5 :      SgEmptyDeclaration* pointer = NULL;
  107055           5 :      std::vector < unsigned char* > :: const_iterator block;
  107056           5 :      SgEmptyDeclaration* pointerOfLinkedList = NULL;
  107057           5 :      for ( block = SgEmptyDeclaration::pools.begin(); block != SgEmptyDeclaration::pools.end() ; ++block )
  107058             :         {
  107059           0 :           pointer = (SgEmptyDeclaration*)(*block);
  107060           0 :           for (unsigned i = 0; i < SgEmptyDeclaration::pool_size; ++i )
  107061             :              {
  107062             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  107063             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  107064             :             // memory blocks!.
  107065           0 :                if ( pointer[i].get_freepointer() != NULL )
  107066             :                   {
  107067           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  107068             :                   }
  107069             :                else
  107070             :                   {
  107071           0 :                     if ( pointerOfLinkedList == NULL )
  107072             :                        {
  107073           0 :                          SgEmptyDeclaration::next_node = &(pointer[i]);
  107074             :                        }
  107075             :                     else
  107076             :                        {
  107077             :                       // printf ("In SgEmptyDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  107078           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  107079             :                        }
  107080             :                     pointerOfLinkedList = &(pointer[i]);
  107081             :                   }
  107082             :               }
  107083             :         }
  107084             : 
  107085           5 :      if ( pointerOfLinkedList != NULL )
  107086             :         {
  107087             :        // printf ("In SgEmptyDeclaration::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  107088           0 :           pointerOfLinkedList->set_freepointer(NULL);
  107089             :        // DQ (6/6/2010): Temporary debugging...
  107090             :        //   ROSE_ASSERT(false);
  107091             :         }
  107092             : 
  107093           5 :      return ;
  107094             :    }
  107095             : 
  107096             : //############################################################################
  107097             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  107098             :  * within the memory pool and resets the freepointers, in order to achieve a 
  107099             :  * linked list, that has no jumps and starts at the beginning! This function 
  107100             :  * does not extend the memory pool, since we do not delete any memory blocks,
  107101             :  * but delete the valid objects.  
  107102             :  */
  107103             : void
  107104           0 : SgEmptyDeclaration::clearMemoryPool( )
  107105             :    {
  107106             :   // printf ("Inside of SgEmptyDeclaration::clearMemoryPool() \n");
  107107             : 
  107108           0 :      SgEmptyDeclaration* pointer = NULL, *tempPointer = NULL;
  107109           0 :      std::vector < unsigned char* > :: const_iterator block;
  107110           0 :      if ( SgEmptyDeclaration::pools.empty() == false )
  107111             :         {
  107112           0 :           block = SgEmptyDeclaration::pools.begin() ;
  107113           0 :           SgEmptyDeclaration::next_node = (SgEmptyDeclaration*) (*block);
  107114             : 
  107115           0 :           while ( block != SgEmptyDeclaration::pools.end() )
  107116             :              {
  107117           0 :                pointer = (SgEmptyDeclaration*) (*block);
  107118           0 :                if ( tempPointer != NULL )
  107119             :                   {
  107120           0 :                     tempPointer->set_freepointer(pointer);
  107121             :                   }
  107122           0 :                for (unsigned i = 0; i < SgEmptyDeclaration::pool_size - 1; ++i)
  107123             :                   {
  107124           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  107125             :                   }
  107126           0 :                 pointer[SgEmptyDeclaration::pool_size-1].set_freepointer(NULL);
  107127           0 :                 tempPointer = &(pointer[SgEmptyDeclaration::pool_size-1]);
  107128           0 :                 ++block;
  107129             :              }
  107130             :         }
  107131           0 :    }
  107132             : 
  107133           5 : void SgEmptyDeclaration::deleteMemoryPool() {
  107134           5 :   for (auto p: SgEmptyDeclaration::pools) {
  107135           0 :     ROSE_FREE(p);
  107136             :   }
  107137           5 :   SgEmptyDeclaration::next_node = nullptr;
  107138           5 :   SgEmptyDeclaration::pools.clear();
  107139           5 : }
  107140             : 
  107141             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  107142             : //                 reading multiple binary files to for a single AST.
  107143             : /////////// new version ////////////////////////////////
  107144             : //############################################################################
  107145             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  107146             : void
  107147           2 : SgEmptyDeclaration::extendMemoryPoolForFileIO( )
  107148             :   {
  107149           2 :     size_t blockIndex = SgEmptyDeclaration::pools.size();
  107150           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEmptyDeclaration) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEmptyDeclaration);
  107151             : 
  107152           2 :     while ( (blockIndex * SgEmptyDeclaration::pool_size) < newPoolSize)
  107153             :       {
  107154             : #if ROSE_ALLOC_TRACE
  107155             :         if (blockIndex > 0) {
  107156             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEmptyDeclaration) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEmptyDeclaration) = %" PRIuPTR " SgEmptyDeclaration::pool_size = %d \n",
  107157             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEmptyDeclaration),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEmptyDeclaration),SgEmptyDeclaration::pool_size);
  107158             :         }
  107159             : #endif
  107160             : 
  107161           0 :         SgEmptyDeclaration * pointer = (SgEmptyDeclaration*) ROSE_MALLOC ( SgEmptyDeclaration::pool_size * sizeof(SgEmptyDeclaration) );
  107162           0 :         assert( pointer != NULL );
  107163             : #if ROSE_ALLOC_MEMSET == 1
  107164             :         memset(pointer, 0x00, SgEmptyDeclaration::pool_size * sizeof(SgEmptyDeclaration));
  107165             : #elif ROSE_ALLOC_MEMSET == 2
  107166             :         memset(pointer, 0xCC, SgEmptyDeclaration::pool_size * sizeof(SgEmptyDeclaration));
  107167             : #endif
  107168           0 :         SgEmptyDeclaration::pools.push_back( (unsigned char*)(pointer) );
  107169           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEmptyDeclaration::pool_size * sizeof(SgEmptyDeclaration), V_SgEmptyDeclaration ) );
  107170             : 
  107171           0 :         if ( SgEmptyDeclaration::next_node != NULL ) {
  107172           0 :           if ( blockIndex > 0 ) {
  107173           0 :             SgEmptyDeclaration * blkptr = (SgEmptyDeclaration*)(SgEmptyDeclaration::pools[blockIndex-1]);
  107174           0 :             blkptr[ SgEmptyDeclaration::pool_size - 1 ].set_freepointer(pointer);
  107175             :           }
  107176             :         } else {
  107177           0 :           SgEmptyDeclaration::next_node = pointer;
  107178             :         }
  107179             : 
  107180           0 :         for (unsigned i = 0; i < SgEmptyDeclaration::pool_size-1; ++i)
  107181             :            {
  107182           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  107183             :            }
  107184           0 :         pointer[ SgEmptyDeclaration::pool_size -1 ].set_freepointer(NULL);
  107185             : 
  107186           0 :         blockIndex++;
  107187             :       }
  107188           2 :   }
  107189             : 
  107190             : //############################################################################
  107191             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  107192             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  107193             :  * not compressed. However, that stuff is not yet implemented! 
  107194             :  */
  107195             : unsigned long
  107196           0 : SgEmptyDeclaration::getNumberOfLastValidPointer()
  107197             :    {
  107198           0 :       SgEmptyDeclaration* testPointer = (SgEmptyDeclaration*)(SgEmptyDeclaration::pools.back());
  107199           0 :       unsigned long localIndex = SgEmptyDeclaration::pool_size - 1;
  107200           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  107201             :          {
  107202           0 :            localIndex--;
  107203             :          }
  107204           0 :       return (localIndex + SgEmptyDeclaration::pool_size * (SgEmptyDeclaration::pools.size()-1));
  107205             :    }
  107206             : 
  107207             : //############################################################################
  107208             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  107209             :  * memory pool and initializes the data member in class SgEmptyDeclarationStroageClass
  107210             :  * from its counterpart of SgEmptyDeclaration. The return value is just for checking, 
  107211             :  * that the whole StorageClassArray is initialized!
  107212             :  */
  107213             : unsigned long
  107214           0 : SgEmptyDeclaration::initializeStorageClassArray( SgEmptyDeclarationStorageClass *storageArray )
  107215             :    {
  107216           0 :      unsigned long storageCounter = 0;
  107217           0 :      std::vector < unsigned char* > :: const_iterator block = SgEmptyDeclaration::pools.begin();
  107218           0 :      SgEmptyDeclaration* pointer = NULL;
  107219           0 :      while ( block != SgEmptyDeclaration::pools.end() ) {
  107220           0 :           pointer = (SgEmptyDeclaration*) (*block);
  107221           0 :           for ( unsigned i = 0; i < SgEmptyDeclaration::pool_size; ++i ) {
  107222           0 :                if ( pointer->get_freepointer() != NULL ) {
  107223           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  107224           0 :                  storageArray++;
  107225           0 :                  storageCounter++;
  107226             :                }
  107227           0 :                pointer++;
  107228             :              }
  107229           0 :            block++;
  107230             :         }
  107231           0 :      return storageCounter;
  107232             :    }
  107233             : 
  107234             : /* #line 107235 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  107235             : 
  107236             : 
  107237             : 
  107238             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  107239             : 
  107240             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  107241             : 
  107242             : //############################################################################
  107243             : /* JH (02/02/2006) Constructor of the IR node SgExprStatement that takes its 
  107244             :  * corresponding StorageClass as parameter
  107245             :  */
  107246        2208 : SgExprStatement :: SgExprStatement ( const SgExprStatementStorageClass& storageSource )   : SgStatement (storageSource)
  107247             :    {
  107248             : 
  107249             : 
  107250             : /* #line 107251 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  107251             : 
  107252        2208 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  107253        2208 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  107254             : 
  107255             : 
  107256             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  107257             : 
  107258             : 
  107259        2208 :    }
  107260             : 
  107261             : //############################################################################
  107262             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  107263             :  * within the working AST. 
  107264             :  */
  107265        9216 : SgExprStatement * SgExprStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  107266        9216 :      SgExprStatement* returnPointer = NULL;
  107267        9216 :      if ( globalIndex != 0 )
  107268             :         {
  107269             : 
  107270             : #if FILE_IO_EXTRA_CHECK
  107271        9216 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgExprStatement ) ) <= globalIndex ) ;
  107272        9216 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExprStatement + 1 ) ) );
  107273             : #endif
  107274        9216 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExprStatement )  
  107275        9216 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgExprStatement );
  107276        9216 :           unsigned long positionInPool = localIndex % SgExprStatement::pool_size;
  107277        9216 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExprStatement::pool_size;
  107278             : 
  107279             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  107280             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  107281             : 
  107282        9216 :           returnPointer = &( ( (SgExprStatement*)(SgExprStatement::pools[memoryBlock]) ) [positionInPool]) ;
  107283             : 
  107284        9216 :           ROSE_ASSERT( returnPointer != NULL ) ;
  107285             :         }
  107286        9216 :      return returnPointer ;
  107287             :    }
  107288             : 
  107289             : //############################################################################
  107290             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  107291             :   for the AST with the index astIndex
  107292             : */
  107293           0 : SgExprStatement * SgExprStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  107294           0 :      SgExprStatement* returnPointer = NULL;
  107295           0 :      if ( globalIndex != 0 )
  107296             :         {
  107297             : 
  107298             : #if FILE_IO_EXTRA_CHECK
  107299           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgExprStatement ) ) <= globalIndex ) ;
  107300           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExprStatement + 1 ) ) );
  107301             : #endif
  107302           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExprStatement )
  107303           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgExprStatement );
  107304           0 :           unsigned long positionInPool = localIndex % SgExprStatement::pool_size ;
  107305           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExprStatement::pool_size ;
  107306             : 
  107307             : #if FILE_IO_EXTRA_CHECK
  107308             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  107309             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  107310             : #endif
  107311             : 
  107312           0 :           returnPointer = &( ( (SgExprStatement*)(SgExprStatement::pools[memoryBlock]) ) [positionInPool]) ;
  107313             : 
  107314             : #if FILE_IO_EXTRA_CHECK
  107315           0 :           assert ( returnPointer != NULL ) ;
  107316             : #endif
  107317             :         }
  107318           0 :      return returnPointer ;
  107319             :    }
  107320             : 
  107321             : //############################################################################
  107322             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  107323             :  * pool size! We set for every valid object in the memory pool the freepointer
  107324             :  * to the global index and increase the global index afterwards. For all the 
  107325             :  * invalid objects (means address ranges within the memory pool that were not
  107326             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  107327             :  * distinguish valid from invalid objects! 
  107328             :  */
  107329             : unsigned long
  107330           5 : SgExprStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  107331             :    {
  107332           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  107333           5 :      SgExprStatement* pointer = NULL;
  107334           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  107335           5 :      std::vector < unsigned char* > :: const_iterator block;
  107336           8 :      for ( block = SgExprStatement::pools.begin(); block != SgExprStatement::pools.end() ; ++block )
  107337             :         {
  107338           3 :           pointer = (SgExprStatement*)(*block);
  107339        6003 :           for (unsigned i = 0; i < SgExprStatement::pool_size; ++i )
  107340             :              {
  107341             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  107342             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  107343             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  107344             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  107345             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  107346             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  107347             :             // properly; so this will have to be checked next.
  107348             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  107349             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  107350        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  107351             :                   {
  107352        2208 :                     pointer[i].set_freepointer((SgExprStatement*)(globalIndex));
  107353        2208 :                     globalIndex++;
  107354             :                   }
  107355             :                else
  107356             :                   {
  107357        3792 :                     pointer[i].set_freepointer(NULL);
  107358             :                   }
  107359             :               }
  107360             :         }
  107361           5 :      return globalIndex;
  107362             :    }
  107363             : 
  107364             : //############################################################################
  107365             : // JH (01/14/2006)
  107366             : void
  107367           5 : SgExprStatement::resetValidFreepointers( )
  107368             :    {
  107369           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  107370           5 :      SgExprStatement* pointer = NULL;
  107371           5 :      std::vector < unsigned char* > :: const_iterator block;
  107372           5 :      SgExprStatement* pointerOfLinkedList = NULL;
  107373           8 :      for ( block = SgExprStatement::pools.begin(); block != SgExprStatement::pools.end() ; ++block )
  107374             :         {
  107375           3 :           pointer = (SgExprStatement*)(*block);
  107376        6003 :           for (unsigned i = 0; i < SgExprStatement::pool_size; ++i )
  107377             :              {
  107378             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  107379             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  107380             :             // memory blocks!.
  107381        6000 :                if ( pointer[i].get_freepointer() != NULL )
  107382             :                   {
  107383        2208 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  107384             :                   }
  107385             :                else
  107386             :                   {
  107387        3792 :                     if ( pointerOfLinkedList == NULL )
  107388             :                        {
  107389           2 :                          SgExprStatement::next_node = &(pointer[i]);
  107390             :                        }
  107391             :                     else
  107392             :                        {
  107393             :                       // printf ("In SgExprStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  107394        3790 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  107395             :                        }
  107396             :                     pointerOfLinkedList = &(pointer[i]);
  107397             :                   }
  107398             :               }
  107399             :         }
  107400             : 
  107401           5 :      if ( pointerOfLinkedList != NULL )
  107402             :         {
  107403             :        // printf ("In SgExprStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  107404           2 :           pointerOfLinkedList->set_freepointer(NULL);
  107405             :        // DQ (6/6/2010): Temporary debugging...
  107406             :        //   ROSE_ASSERT(false);
  107407             :         }
  107408             : 
  107409           5 :      return ;
  107410             :    }
  107411             : 
  107412             : //############################################################################
  107413             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  107414             :  * within the memory pool and resets the freepointers, in order to achieve a 
  107415             :  * linked list, that has no jumps and starts at the beginning! This function 
  107416             :  * does not extend the memory pool, since we do not delete any memory blocks,
  107417             :  * but delete the valid objects.  
  107418             :  */
  107419             : void
  107420           0 : SgExprStatement::clearMemoryPool( )
  107421             :    {
  107422             :   // printf ("Inside of SgExprStatement::clearMemoryPool() \n");
  107423             : 
  107424           0 :      SgExprStatement* pointer = NULL, *tempPointer = NULL;
  107425           0 :      std::vector < unsigned char* > :: const_iterator block;
  107426           0 :      if ( SgExprStatement::pools.empty() == false )
  107427             :         {
  107428           0 :           block = SgExprStatement::pools.begin() ;
  107429           0 :           SgExprStatement::next_node = (SgExprStatement*) (*block);
  107430             : 
  107431           0 :           while ( block != SgExprStatement::pools.end() )
  107432             :              {
  107433           0 :                pointer = (SgExprStatement*) (*block);
  107434           0 :                if ( tempPointer != NULL )
  107435             :                   {
  107436           0 :                     tempPointer->set_freepointer(pointer);
  107437             :                   }
  107438           0 :                for (unsigned i = 0; i < SgExprStatement::pool_size - 1; ++i)
  107439             :                   {
  107440           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  107441             :                   }
  107442           0 :                 pointer[SgExprStatement::pool_size-1].set_freepointer(NULL);
  107443           0 :                 tempPointer = &(pointer[SgExprStatement::pool_size-1]);
  107444           0 :                 ++block;
  107445             :              }
  107446             :         }
  107447           0 :    }
  107448             : 
  107449           5 : void SgExprStatement::deleteMemoryPool() {
  107450          11 :   for (auto p: SgExprStatement::pools) {
  107451           6 :     ROSE_FREE(p);
  107452             :   }
  107453           5 :   SgExprStatement::next_node = nullptr;
  107454           5 :   SgExprStatement::pools.clear();
  107455           5 : }
  107456             : 
  107457             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  107458             : //                 reading multiple binary files to for a single AST.
  107459             : /////////// new version ////////////////////////////////
  107460             : //############################################################################
  107461             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  107462             : void
  107463           2 : SgExprStatement::extendMemoryPoolForFileIO( )
  107464             :   {
  107465           2 :     size_t blockIndex = SgExprStatement::pools.size();
  107466           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgExprStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgExprStatement);
  107467             : 
  107468           5 :     while ( (blockIndex * SgExprStatement::pool_size) < newPoolSize)
  107469             :       {
  107470             : #if ROSE_ALLOC_TRACE
  107471             :         if (blockIndex > 0) {
  107472             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgExprStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgExprStatement) = %" PRIuPTR " SgExprStatement::pool_size = %d \n",
  107473             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgExprStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgExprStatement),SgExprStatement::pool_size);
  107474             :         }
  107475             : #endif
  107476             : 
  107477           3 :         SgExprStatement * pointer = (SgExprStatement*) ROSE_MALLOC ( SgExprStatement::pool_size * sizeof(SgExprStatement) );
  107478           3 :         assert( pointer != NULL );
  107479             : #if ROSE_ALLOC_MEMSET == 1
  107480             :         memset(pointer, 0x00, SgExprStatement::pool_size * sizeof(SgExprStatement));
  107481             : #elif ROSE_ALLOC_MEMSET == 2
  107482             :         memset(pointer, 0xCC, SgExprStatement::pool_size * sizeof(SgExprStatement));
  107483             : #endif
  107484           3 :         SgExprStatement::pools.push_back( (unsigned char*)(pointer) );
  107485           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgExprStatement::pool_size * sizeof(SgExprStatement), V_SgExprStatement ) );
  107486             : 
  107487           3 :         if ( SgExprStatement::next_node != NULL ) {
  107488           1 :           if ( blockIndex > 0 ) {
  107489           1 :             SgExprStatement * blkptr = (SgExprStatement*)(SgExprStatement::pools[blockIndex-1]);
  107490           1 :             blkptr[ SgExprStatement::pool_size - 1 ].set_freepointer(pointer);
  107491             :           }
  107492             :         } else {
  107493           2 :           SgExprStatement::next_node = pointer;
  107494             :         }
  107495             : 
  107496        6000 :         for (unsigned i = 0; i < SgExprStatement::pool_size-1; ++i)
  107497             :            {
  107498        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  107499             :            }
  107500           3 :         pointer[ SgExprStatement::pool_size -1 ].set_freepointer(NULL);
  107501             : 
  107502           3 :         blockIndex++;
  107503             :       }
  107504           2 :   }
  107505             : 
  107506             : //############################################################################
  107507             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  107508             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  107509             :  * not compressed. However, that stuff is not yet implemented! 
  107510             :  */
  107511             : unsigned long
  107512           0 : SgExprStatement::getNumberOfLastValidPointer()
  107513             :    {
  107514           0 :       SgExprStatement* testPointer = (SgExprStatement*)(SgExprStatement::pools.back());
  107515           0 :       unsigned long localIndex = SgExprStatement::pool_size - 1;
  107516           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  107517             :          {
  107518           0 :            localIndex--;
  107519             :          }
  107520           0 :       return (localIndex + SgExprStatement::pool_size * (SgExprStatement::pools.size()-1));
  107521             :    }
  107522             : 
  107523             : //############################################################################
  107524             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  107525             :  * memory pool and initializes the data member in class SgExprStatementStroageClass
  107526             :  * from its counterpart of SgExprStatement. The return value is just for checking, 
  107527             :  * that the whole StorageClassArray is initialized!
  107528             :  */
  107529             : unsigned long
  107530           2 : SgExprStatement::initializeStorageClassArray( SgExprStatementStorageClass *storageArray )
  107531             :    {
  107532           2 :      unsigned long storageCounter = 0;
  107533           2 :      std::vector < unsigned char* > :: const_iterator block = SgExprStatement::pools.begin();
  107534           2 :      SgExprStatement* pointer = NULL;
  107535           5 :      while ( block != SgExprStatement::pools.end() ) {
  107536           3 :           pointer = (SgExprStatement*) (*block);
  107537        6003 :           for ( unsigned i = 0; i < SgExprStatement::pool_size; ++i ) {
  107538        6000 :                if ( pointer->get_freepointer() != NULL ) {
  107539        2208 :                  storageArray->pickOutIRNodeData (pointer) ;
  107540        2208 :                  storageArray++;
  107541        2208 :                  storageCounter++;
  107542             :                }
  107543        6000 :                pointer++;
  107544             :              }
  107545           3 :            block++;
  107546             :         }
  107547           2 :      return storageCounter;
  107548             :    }
  107549             : 
  107550             : /* #line 107551 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  107551             : 
  107552             : 
  107553             : 
  107554             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  107555             : 
  107556             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  107557             : 
  107558             : //############################################################################
  107559             : /* JH (02/02/2006) Constructor of the IR node SgLabelStatement that takes its 
  107560             :  * corresponding StorageClass as parameter
  107561             :  */
  107562           0 : SgLabelStatement :: SgLabelStatement ( const SgLabelStatementStorageClass& storageSource )   : SgStatement (storageSource)
  107563             :    {
  107564             : 
  107565             : 
  107566             : /* #line 107567 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  107567             : 
  107568           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  107569           0 :      p_label = SgName ( storageSource.storageOf_label ) ;
  107570           0 :      p_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_scope) );
  107571           0 :      p_statement =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_statement) );
  107572           0 :      p_gnu_extension_unused = storageSource.storageOf_gnu_extension_unused ;
  107573             : 
  107574             : 
  107575             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  107576             : 
  107577             : 
  107578           0 :    }
  107579             : 
  107580             : //############################################################################
  107581             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  107582             :  * within the working AST. 
  107583             :  */
  107584           0 : SgLabelStatement * SgLabelStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  107585           0 :      SgLabelStatement* returnPointer = NULL;
  107586           0 :      if ( globalIndex != 0 )
  107587             :         {
  107588             : 
  107589             : #if FILE_IO_EXTRA_CHECK
  107590           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLabelStatement ) ) <= globalIndex ) ;
  107591           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLabelStatement + 1 ) ) );
  107592             : #endif
  107593           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLabelStatement )  
  107594           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLabelStatement );
  107595           0 :           unsigned long positionInPool = localIndex % SgLabelStatement::pool_size;
  107596           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLabelStatement::pool_size;
  107597             : 
  107598             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  107599             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  107600             : 
  107601           0 :           returnPointer = &( ( (SgLabelStatement*)(SgLabelStatement::pools[memoryBlock]) ) [positionInPool]) ;
  107602             : 
  107603           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  107604             :         }
  107605           0 :      return returnPointer ;
  107606             :    }
  107607             : 
  107608             : //############################################################################
  107609             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  107610             :   for the AST with the index astIndex
  107611             : */
  107612           0 : SgLabelStatement * SgLabelStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  107613           0 :      SgLabelStatement* returnPointer = NULL;
  107614           0 :      if ( globalIndex != 0 )
  107615             :         {
  107616             : 
  107617             : #if FILE_IO_EXTRA_CHECK
  107618           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLabelStatement ) ) <= globalIndex ) ;
  107619           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLabelStatement + 1 ) ) );
  107620             : #endif
  107621           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLabelStatement )
  107622           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLabelStatement );
  107623           0 :           unsigned long positionInPool = localIndex % SgLabelStatement::pool_size ;
  107624           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLabelStatement::pool_size ;
  107625             : 
  107626             : #if FILE_IO_EXTRA_CHECK
  107627             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  107628             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  107629             : #endif
  107630             : 
  107631           0 :           returnPointer = &( ( (SgLabelStatement*)(SgLabelStatement::pools[memoryBlock]) ) [positionInPool]) ;
  107632             : 
  107633             : #if FILE_IO_EXTRA_CHECK
  107634           0 :           assert ( returnPointer != NULL ) ;
  107635             : #endif
  107636             :         }
  107637           0 :      return returnPointer ;
  107638             :    }
  107639             : 
  107640             : //############################################################################
  107641             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  107642             :  * pool size! We set for every valid object in the memory pool the freepointer
  107643             :  * to the global index and increase the global index afterwards. For all the 
  107644             :  * invalid objects (means address ranges within the memory pool that were not
  107645             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  107646             :  * distinguish valid from invalid objects! 
  107647             :  */
  107648             : unsigned long
  107649           5 : SgLabelStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  107650             :    {
  107651           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  107652           5 :      SgLabelStatement* pointer = NULL;
  107653           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  107654           5 :      std::vector < unsigned char* > :: const_iterator block;
  107655           5 :      for ( block = SgLabelStatement::pools.begin(); block != SgLabelStatement::pools.end() ; ++block )
  107656             :         {
  107657           0 :           pointer = (SgLabelStatement*)(*block);
  107658           0 :           for (unsigned i = 0; i < SgLabelStatement::pool_size; ++i )
  107659             :              {
  107660             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  107661             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  107662             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  107663             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  107664             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  107665             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  107666             :             // properly; so this will have to be checked next.
  107667             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  107668             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  107669           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  107670             :                   {
  107671           0 :                     pointer[i].set_freepointer((SgLabelStatement*)(globalIndex));
  107672           0 :                     globalIndex++;
  107673             :                   }
  107674             :                else
  107675             :                   {
  107676           0 :                     pointer[i].set_freepointer(NULL);
  107677             :                   }
  107678             :               }
  107679             :         }
  107680           5 :      return globalIndex;
  107681             :    }
  107682             : 
  107683             : //############################################################################
  107684             : // JH (01/14/2006)
  107685             : void
  107686           5 : SgLabelStatement::resetValidFreepointers( )
  107687             :    {
  107688           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  107689           5 :      SgLabelStatement* pointer = NULL;
  107690           5 :      std::vector < unsigned char* > :: const_iterator block;
  107691           5 :      SgLabelStatement* pointerOfLinkedList = NULL;
  107692           5 :      for ( block = SgLabelStatement::pools.begin(); block != SgLabelStatement::pools.end() ; ++block )
  107693             :         {
  107694           0 :           pointer = (SgLabelStatement*)(*block);
  107695           0 :           for (unsigned i = 0; i < SgLabelStatement::pool_size; ++i )
  107696             :              {
  107697             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  107698             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  107699             :             // memory blocks!.
  107700           0 :                if ( pointer[i].get_freepointer() != NULL )
  107701             :                   {
  107702           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  107703             :                   }
  107704             :                else
  107705             :                   {
  107706           0 :                     if ( pointerOfLinkedList == NULL )
  107707             :                        {
  107708           0 :                          SgLabelStatement::next_node = &(pointer[i]);
  107709             :                        }
  107710             :                     else
  107711             :                        {
  107712             :                       // printf ("In SgLabelStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  107713           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  107714             :                        }
  107715             :                     pointerOfLinkedList = &(pointer[i]);
  107716             :                   }
  107717             :               }
  107718             :         }
  107719             : 
  107720           5 :      if ( pointerOfLinkedList != NULL )
  107721             :         {
  107722             :        // printf ("In SgLabelStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  107723           0 :           pointerOfLinkedList->set_freepointer(NULL);
  107724             :        // DQ (6/6/2010): Temporary debugging...
  107725             :        //   ROSE_ASSERT(false);
  107726             :         }
  107727             : 
  107728           5 :      return ;
  107729             :    }
  107730             : 
  107731             : //############################################################################
  107732             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  107733             :  * within the memory pool and resets the freepointers, in order to achieve a 
  107734             :  * linked list, that has no jumps and starts at the beginning! This function 
  107735             :  * does not extend the memory pool, since we do not delete any memory blocks,
  107736             :  * but delete the valid objects.  
  107737             :  */
  107738             : void
  107739           0 : SgLabelStatement::clearMemoryPool( )
  107740             :    {
  107741             :   // printf ("Inside of SgLabelStatement::clearMemoryPool() \n");
  107742             : 
  107743           0 :      SgLabelStatement* pointer = NULL, *tempPointer = NULL;
  107744           0 :      std::vector < unsigned char* > :: const_iterator block;
  107745           0 :      if ( SgLabelStatement::pools.empty() == false )
  107746             :         {
  107747           0 :           block = SgLabelStatement::pools.begin() ;
  107748           0 :           SgLabelStatement::next_node = (SgLabelStatement*) (*block);
  107749             : 
  107750           0 :           while ( block != SgLabelStatement::pools.end() )
  107751             :              {
  107752           0 :                pointer = (SgLabelStatement*) (*block);
  107753           0 :                if ( tempPointer != NULL )
  107754             :                   {
  107755           0 :                     tempPointer->set_freepointer(pointer);
  107756             :                   }
  107757           0 :                for (unsigned i = 0; i < SgLabelStatement::pool_size - 1; ++i)
  107758             :                   {
  107759           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  107760             :                   }
  107761           0 :                 pointer[SgLabelStatement::pool_size-1].set_freepointer(NULL);
  107762           0 :                 tempPointer = &(pointer[SgLabelStatement::pool_size-1]);
  107763           0 :                 ++block;
  107764             :              }
  107765             :         }
  107766           0 :    }
  107767             : 
  107768           5 : void SgLabelStatement::deleteMemoryPool() {
  107769           5 :   for (auto p: SgLabelStatement::pools) {
  107770           0 :     ROSE_FREE(p);
  107771             :   }
  107772           5 :   SgLabelStatement::next_node = nullptr;
  107773           5 :   SgLabelStatement::pools.clear();
  107774           5 : }
  107775             : 
  107776             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  107777             : //                 reading multiple binary files to for a single AST.
  107778             : /////////// new version ////////////////////////////////
  107779             : //############################################################################
  107780             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  107781             : void
  107782           2 : SgLabelStatement::extendMemoryPoolForFileIO( )
  107783             :   {
  107784           2 :     size_t blockIndex = SgLabelStatement::pools.size();
  107785           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelStatement);
  107786             : 
  107787           2 :     while ( (blockIndex * SgLabelStatement::pool_size) < newPoolSize)
  107788             :       {
  107789             : #if ROSE_ALLOC_TRACE
  107790             :         if (blockIndex > 0) {
  107791             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelStatement) = %" PRIuPTR " SgLabelStatement::pool_size = %d \n",
  107792             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelStatement),SgLabelStatement::pool_size);
  107793             :         }
  107794             : #endif
  107795             : 
  107796           0 :         SgLabelStatement * pointer = (SgLabelStatement*) ROSE_MALLOC ( SgLabelStatement::pool_size * sizeof(SgLabelStatement) );
  107797           0 :         assert( pointer != NULL );
  107798             : #if ROSE_ALLOC_MEMSET == 1
  107799             :         memset(pointer, 0x00, SgLabelStatement::pool_size * sizeof(SgLabelStatement));
  107800             : #elif ROSE_ALLOC_MEMSET == 2
  107801             :         memset(pointer, 0xCC, SgLabelStatement::pool_size * sizeof(SgLabelStatement));
  107802             : #endif
  107803           0 :         SgLabelStatement::pools.push_back( (unsigned char*)(pointer) );
  107804           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLabelStatement::pool_size * sizeof(SgLabelStatement), V_SgLabelStatement ) );
  107805             : 
  107806           0 :         if ( SgLabelStatement::next_node != NULL ) {
  107807           0 :           if ( blockIndex > 0 ) {
  107808           0 :             SgLabelStatement * blkptr = (SgLabelStatement*)(SgLabelStatement::pools[blockIndex-1]);
  107809           0 :             blkptr[ SgLabelStatement::pool_size - 1 ].set_freepointer(pointer);
  107810             :           }
  107811             :         } else {
  107812           0 :           SgLabelStatement::next_node = pointer;
  107813             :         }
  107814             : 
  107815           0 :         for (unsigned i = 0; i < SgLabelStatement::pool_size-1; ++i)
  107816             :            {
  107817           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  107818             :            }
  107819           0 :         pointer[ SgLabelStatement::pool_size -1 ].set_freepointer(NULL);
  107820             : 
  107821           0 :         blockIndex++;
  107822             :       }
  107823           2 :   }
  107824             : 
  107825             : //############################################################################
  107826             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  107827             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  107828             :  * not compressed. However, that stuff is not yet implemented! 
  107829             :  */
  107830             : unsigned long
  107831           0 : SgLabelStatement::getNumberOfLastValidPointer()
  107832             :    {
  107833           0 :       SgLabelStatement* testPointer = (SgLabelStatement*)(SgLabelStatement::pools.back());
  107834           0 :       unsigned long localIndex = SgLabelStatement::pool_size - 1;
  107835           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  107836             :          {
  107837           0 :            localIndex--;
  107838             :          }
  107839           0 :       return (localIndex + SgLabelStatement::pool_size * (SgLabelStatement::pools.size()-1));
  107840             :    }
  107841             : 
  107842             : //############################################################################
  107843             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  107844             :  * memory pool and initializes the data member in class SgLabelStatementStroageClass
  107845             :  * from its counterpart of SgLabelStatement. The return value is just for checking, 
  107846             :  * that the whole StorageClassArray is initialized!
  107847             :  */
  107848             : unsigned long
  107849           0 : SgLabelStatement::initializeStorageClassArray( SgLabelStatementStorageClass *storageArray )
  107850             :    {
  107851           0 :      unsigned long storageCounter = 0;
  107852           0 :      std::vector < unsigned char* > :: const_iterator block = SgLabelStatement::pools.begin();
  107853           0 :      SgLabelStatement* pointer = NULL;
  107854           0 :      while ( block != SgLabelStatement::pools.end() ) {
  107855           0 :           pointer = (SgLabelStatement*) (*block);
  107856           0 :           for ( unsigned i = 0; i < SgLabelStatement::pool_size; ++i ) {
  107857           0 :                if ( pointer->get_freepointer() != NULL ) {
  107858           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  107859           0 :                  storageArray++;
  107860           0 :                  storageCounter++;
  107861             :                }
  107862           0 :                pointer++;
  107863             :              }
  107864           0 :            block++;
  107865             :         }
  107866           0 :      return storageCounter;
  107867             :    }
  107868             : 
  107869             : /* #line 107870 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  107870             : 
  107871             : 
  107872             : 
  107873             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  107874             : 
  107875             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  107876             : 
  107877             : //############################################################################
  107878             : /* JH (02/02/2006) Constructor of the IR node SgCaseOptionStmt that takes its 
  107879             :  * corresponding StorageClass as parameter
  107880             :  */
  107881           0 : SgCaseOptionStmt :: SgCaseOptionStmt ( const SgCaseOptionStmtStorageClass& storageSource )   : SgStatement (storageSource)
  107882             :    {
  107883             : 
  107884             : 
  107885             : /* #line 107886 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  107886             : 
  107887           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  107888           0 :      p_key =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_key) );
  107889           0 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
  107890           0 :      p_key_range_end =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_key_range_end) );
  107891           0 :      p_case_construct_name = storageSource.storageOf_case_construct_name.rebuildDataStoredInEasyStorageClass() ;
  107892             : 
  107893             : 
  107894             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  107895             : 
  107896             : 
  107897           0 :    }
  107898             : 
  107899             : //############################################################################
  107900             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  107901             :  * within the working AST. 
  107902             :  */
  107903           0 : SgCaseOptionStmt * SgCaseOptionStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  107904           0 :      SgCaseOptionStmt* returnPointer = NULL;
  107905           0 :      if ( globalIndex != 0 )
  107906             :         {
  107907             : 
  107908             : #if FILE_IO_EXTRA_CHECK
  107909           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCaseOptionStmt ) ) <= globalIndex ) ;
  107910           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCaseOptionStmt + 1 ) ) );
  107911             : #endif
  107912           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCaseOptionStmt )  
  107913           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCaseOptionStmt );
  107914           0 :           unsigned long positionInPool = localIndex % SgCaseOptionStmt::pool_size;
  107915           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCaseOptionStmt::pool_size;
  107916             : 
  107917             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  107918             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  107919             : 
  107920           0 :           returnPointer = &( ( (SgCaseOptionStmt*)(SgCaseOptionStmt::pools[memoryBlock]) ) [positionInPool]) ;
  107921             : 
  107922           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  107923             :         }
  107924           0 :      return returnPointer ;
  107925             :    }
  107926             : 
  107927             : //############################################################################
  107928             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  107929             :   for the AST with the index astIndex
  107930             : */
  107931           0 : SgCaseOptionStmt * SgCaseOptionStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  107932           0 :      SgCaseOptionStmt* returnPointer = NULL;
  107933           0 :      if ( globalIndex != 0 )
  107934             :         {
  107935             : 
  107936             : #if FILE_IO_EXTRA_CHECK
  107937           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCaseOptionStmt ) ) <= globalIndex ) ;
  107938           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCaseOptionStmt + 1 ) ) );
  107939             : #endif
  107940           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCaseOptionStmt )
  107941           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCaseOptionStmt );
  107942           0 :           unsigned long positionInPool = localIndex % SgCaseOptionStmt::pool_size ;
  107943           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCaseOptionStmt::pool_size ;
  107944             : 
  107945             : #if FILE_IO_EXTRA_CHECK
  107946             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  107947             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  107948             : #endif
  107949             : 
  107950           0 :           returnPointer = &( ( (SgCaseOptionStmt*)(SgCaseOptionStmt::pools[memoryBlock]) ) [positionInPool]) ;
  107951             : 
  107952             : #if FILE_IO_EXTRA_CHECK
  107953           0 :           assert ( returnPointer != NULL ) ;
  107954             : #endif
  107955             :         }
  107956           0 :      return returnPointer ;
  107957             :    }
  107958             : 
  107959             : //############################################################################
  107960             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  107961             :  * pool size! We set for every valid object in the memory pool the freepointer
  107962             :  * to the global index and increase the global index afterwards. For all the 
  107963             :  * invalid objects (means address ranges within the memory pool that were not
  107964             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  107965             :  * distinguish valid from invalid objects! 
  107966             :  */
  107967             : unsigned long
  107968           5 : SgCaseOptionStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  107969             :    {
  107970           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  107971           5 :      SgCaseOptionStmt* pointer = NULL;
  107972           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  107973           5 :      std::vector < unsigned char* > :: const_iterator block;
  107974           5 :      for ( block = SgCaseOptionStmt::pools.begin(); block != SgCaseOptionStmt::pools.end() ; ++block )
  107975             :         {
  107976           0 :           pointer = (SgCaseOptionStmt*)(*block);
  107977           0 :           for (unsigned i = 0; i < SgCaseOptionStmt::pool_size; ++i )
  107978             :              {
  107979             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  107980             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  107981             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  107982             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  107983             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  107984             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  107985             :             // properly; so this will have to be checked next.
  107986             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  107987             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  107988           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  107989             :                   {
  107990           0 :                     pointer[i].set_freepointer((SgCaseOptionStmt*)(globalIndex));
  107991           0 :                     globalIndex++;
  107992             :                   }
  107993             :                else
  107994             :                   {
  107995           0 :                     pointer[i].set_freepointer(NULL);
  107996             :                   }
  107997             :               }
  107998             :         }
  107999           5 :      return globalIndex;
  108000             :    }
  108001             : 
  108002             : //############################################################################
  108003             : // JH (01/14/2006)
  108004             : void
  108005           5 : SgCaseOptionStmt::resetValidFreepointers( )
  108006             :    {
  108007           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  108008           5 :      SgCaseOptionStmt* pointer = NULL;
  108009           5 :      std::vector < unsigned char* > :: const_iterator block;
  108010           5 :      SgCaseOptionStmt* pointerOfLinkedList = NULL;
  108011           5 :      for ( block = SgCaseOptionStmt::pools.begin(); block != SgCaseOptionStmt::pools.end() ; ++block )
  108012             :         {
  108013           0 :           pointer = (SgCaseOptionStmt*)(*block);
  108014           0 :           for (unsigned i = 0; i < SgCaseOptionStmt::pool_size; ++i )
  108015             :              {
  108016             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  108017             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  108018             :             // memory blocks!.
  108019           0 :                if ( pointer[i].get_freepointer() != NULL )
  108020             :                   {
  108021           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  108022             :                   }
  108023             :                else
  108024             :                   {
  108025           0 :                     if ( pointerOfLinkedList == NULL )
  108026             :                        {
  108027           0 :                          SgCaseOptionStmt::next_node = &(pointer[i]);
  108028             :                        }
  108029             :                     else
  108030             :                        {
  108031             :                       // printf ("In SgCaseOptionStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  108032           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  108033             :                        }
  108034             :                     pointerOfLinkedList = &(pointer[i]);
  108035             :                   }
  108036             :               }
  108037             :         }
  108038             : 
  108039           5 :      if ( pointerOfLinkedList != NULL )
  108040             :         {
  108041             :        // printf ("In SgCaseOptionStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  108042           0 :           pointerOfLinkedList->set_freepointer(NULL);
  108043             :        // DQ (6/6/2010): Temporary debugging...
  108044             :        //   ROSE_ASSERT(false);
  108045             :         }
  108046             : 
  108047           5 :      return ;
  108048             :    }
  108049             : 
  108050             : //############################################################################
  108051             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  108052             :  * within the memory pool and resets the freepointers, in order to achieve a 
  108053             :  * linked list, that has no jumps and starts at the beginning! This function 
  108054             :  * does not extend the memory pool, since we do not delete any memory blocks,
  108055             :  * but delete the valid objects.  
  108056             :  */
  108057             : void
  108058           0 : SgCaseOptionStmt::clearMemoryPool( )
  108059             :    {
  108060             :   // printf ("Inside of SgCaseOptionStmt::clearMemoryPool() \n");
  108061             : 
  108062           0 :      SgCaseOptionStmt* pointer = NULL, *tempPointer = NULL;
  108063           0 :      std::vector < unsigned char* > :: const_iterator block;
  108064           0 :      if ( SgCaseOptionStmt::pools.empty() == false )
  108065             :         {
  108066           0 :           block = SgCaseOptionStmt::pools.begin() ;
  108067           0 :           SgCaseOptionStmt::next_node = (SgCaseOptionStmt*) (*block);
  108068             : 
  108069           0 :           while ( block != SgCaseOptionStmt::pools.end() )
  108070             :              {
  108071           0 :                pointer = (SgCaseOptionStmt*) (*block);
  108072           0 :                if ( tempPointer != NULL )
  108073             :                   {
  108074           0 :                     tempPointer->set_freepointer(pointer);
  108075             :                   }
  108076           0 :                for (unsigned i = 0; i < SgCaseOptionStmt::pool_size - 1; ++i)
  108077             :                   {
  108078           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  108079             :                   }
  108080           0 :                 pointer[SgCaseOptionStmt::pool_size-1].set_freepointer(NULL);
  108081           0 :                 tempPointer = &(pointer[SgCaseOptionStmt::pool_size-1]);
  108082           0 :                 ++block;
  108083             :              }
  108084             :         }
  108085           0 :    }
  108086             : 
  108087           5 : void SgCaseOptionStmt::deleteMemoryPool() {
  108088           5 :   for (auto p: SgCaseOptionStmt::pools) {
  108089           0 :     ROSE_FREE(p);
  108090             :   }
  108091           5 :   SgCaseOptionStmt::next_node = nullptr;
  108092           5 :   SgCaseOptionStmt::pools.clear();
  108093           5 : }
  108094             : 
  108095             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  108096             : //                 reading multiple binary files to for a single AST.
  108097             : /////////// new version ////////////////////////////////
  108098             : //############################################################################
  108099             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  108100             : void
  108101           2 : SgCaseOptionStmt::extendMemoryPoolForFileIO( )
  108102             :   {
  108103           2 :     size_t blockIndex = SgCaseOptionStmt::pools.size();
  108104           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCaseOptionStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCaseOptionStmt);
  108105             : 
  108106           2 :     while ( (blockIndex * SgCaseOptionStmt::pool_size) < newPoolSize)
  108107             :       {
  108108             : #if ROSE_ALLOC_TRACE
  108109             :         if (blockIndex > 0) {
  108110             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCaseOptionStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCaseOptionStmt) = %" PRIuPTR " SgCaseOptionStmt::pool_size = %d \n",
  108111             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCaseOptionStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCaseOptionStmt),SgCaseOptionStmt::pool_size);
  108112             :         }
  108113             : #endif
  108114             : 
  108115           0 :         SgCaseOptionStmt * pointer = (SgCaseOptionStmt*) ROSE_MALLOC ( SgCaseOptionStmt::pool_size * sizeof(SgCaseOptionStmt) );
  108116           0 :         assert( pointer != NULL );
  108117             : #if ROSE_ALLOC_MEMSET == 1
  108118             :         memset(pointer, 0x00, SgCaseOptionStmt::pool_size * sizeof(SgCaseOptionStmt));
  108119             : #elif ROSE_ALLOC_MEMSET == 2
  108120             :         memset(pointer, 0xCC, SgCaseOptionStmt::pool_size * sizeof(SgCaseOptionStmt));
  108121             : #endif
  108122           0 :         SgCaseOptionStmt::pools.push_back( (unsigned char*)(pointer) );
  108123           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCaseOptionStmt::pool_size * sizeof(SgCaseOptionStmt), V_SgCaseOptionStmt ) );
  108124             : 
  108125           0 :         if ( SgCaseOptionStmt::next_node != NULL ) {
  108126           0 :           if ( blockIndex > 0 ) {
  108127           0 :             SgCaseOptionStmt * blkptr = (SgCaseOptionStmt*)(SgCaseOptionStmt::pools[blockIndex-1]);
  108128           0 :             blkptr[ SgCaseOptionStmt::pool_size - 1 ].set_freepointer(pointer);
  108129             :           }
  108130             :         } else {
  108131           0 :           SgCaseOptionStmt::next_node = pointer;
  108132             :         }
  108133             : 
  108134           0 :         for (unsigned i = 0; i < SgCaseOptionStmt::pool_size-1; ++i)
  108135             :            {
  108136           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  108137             :            }
  108138           0 :         pointer[ SgCaseOptionStmt::pool_size -1 ].set_freepointer(NULL);
  108139             : 
  108140           0 :         blockIndex++;
  108141             :       }
  108142           2 :   }
  108143             : 
  108144             : //############################################################################
  108145             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  108146             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  108147             :  * not compressed. However, that stuff is not yet implemented! 
  108148             :  */
  108149             : unsigned long
  108150           0 : SgCaseOptionStmt::getNumberOfLastValidPointer()
  108151             :    {
  108152           0 :       SgCaseOptionStmt* testPointer = (SgCaseOptionStmt*)(SgCaseOptionStmt::pools.back());
  108153           0 :       unsigned long localIndex = SgCaseOptionStmt::pool_size - 1;
  108154           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  108155             :          {
  108156           0 :            localIndex--;
  108157             :          }
  108158           0 :       return (localIndex + SgCaseOptionStmt::pool_size * (SgCaseOptionStmt::pools.size()-1));
  108159             :    }
  108160             : 
  108161             : //############################################################################
  108162             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  108163             :  * memory pool and initializes the data member in class SgCaseOptionStmtStroageClass
  108164             :  * from its counterpart of SgCaseOptionStmt. The return value is just for checking, 
  108165             :  * that the whole StorageClassArray is initialized!
  108166             :  */
  108167             : unsigned long
  108168           0 : SgCaseOptionStmt::initializeStorageClassArray( SgCaseOptionStmtStorageClass *storageArray )
  108169             :    {
  108170           0 :      unsigned long storageCounter = 0;
  108171           0 :      std::vector < unsigned char* > :: const_iterator block = SgCaseOptionStmt::pools.begin();
  108172           0 :      SgCaseOptionStmt* pointer = NULL;
  108173           0 :      while ( block != SgCaseOptionStmt::pools.end() ) {
  108174           0 :           pointer = (SgCaseOptionStmt*) (*block);
  108175           0 :           for ( unsigned i = 0; i < SgCaseOptionStmt::pool_size; ++i ) {
  108176           0 :                if ( pointer->get_freepointer() != NULL ) {
  108177           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  108178           0 :                  storageArray++;
  108179           0 :                  storageCounter++;
  108180             :                }
  108181           0 :                pointer++;
  108182             :              }
  108183           0 :            block++;
  108184             :         }
  108185           0 :      return storageCounter;
  108186             :    }
  108187             : 
  108188             : /* #line 108189 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  108189             : 
  108190             : 
  108191             : 
  108192             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  108193             : 
  108194             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  108195             : 
  108196             : //############################################################################
  108197             : /* JH (02/02/2006) Constructor of the IR node SgTryStmt that takes its 
  108198             :  * corresponding StorageClass as parameter
  108199             :  */
  108200          54 : SgTryStmt :: SgTryStmt ( const SgTryStmtStorageClass& storageSource )   : SgStatement (storageSource)
  108201             :    {
  108202             : 
  108203             : 
  108204             : /* #line 108205 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  108205             : 
  108206          54 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  108207          54 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
  108208          54 :      p_catch_statement_seq_root =  (SgCatchStatementSeq*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_catch_statement_seq_root) );
  108209          54 :      p_else_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_else_body) );
  108210          54 :      p_finally_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_finally_body) );
  108211             : 
  108212             : 
  108213             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  108214             : 
  108215             : 
  108216          54 :    }
  108217             : 
  108218             : //############################################################################
  108219             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  108220             :  * within the working AST. 
  108221             :  */
  108222         271 : SgTryStmt * SgTryStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  108223         271 :      SgTryStmt* returnPointer = NULL;
  108224         271 :      if ( globalIndex != 0 )
  108225             :         {
  108226             : 
  108227             : #if FILE_IO_EXTRA_CHECK
  108228         271 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTryStmt ) ) <= globalIndex ) ;
  108229         271 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTryStmt + 1 ) ) );
  108230             : #endif
  108231         271 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTryStmt )  
  108232         271 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTryStmt );
  108233         271 :           unsigned long positionInPool = localIndex % SgTryStmt::pool_size;
  108234         271 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTryStmt::pool_size;
  108235             : 
  108236             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  108237             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  108238             : 
  108239         271 :           returnPointer = &( ( (SgTryStmt*)(SgTryStmt::pools[memoryBlock]) ) [positionInPool]) ;
  108240             : 
  108241         271 :           ROSE_ASSERT( returnPointer != NULL ) ;
  108242             :         }
  108243         271 :      return returnPointer ;
  108244             :    }
  108245             : 
  108246             : //############################################################################
  108247             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  108248             :   for the AST with the index astIndex
  108249             : */
  108250           0 : SgTryStmt * SgTryStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  108251           0 :      SgTryStmt* returnPointer = NULL;
  108252           0 :      if ( globalIndex != 0 )
  108253             :         {
  108254             : 
  108255             : #if FILE_IO_EXTRA_CHECK
  108256           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTryStmt ) ) <= globalIndex ) ;
  108257           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTryStmt + 1 ) ) );
  108258             : #endif
  108259           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTryStmt )
  108260           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTryStmt );
  108261           0 :           unsigned long positionInPool = localIndex % SgTryStmt::pool_size ;
  108262           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTryStmt::pool_size ;
  108263             : 
  108264             : #if FILE_IO_EXTRA_CHECK
  108265             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  108266             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  108267             : #endif
  108268             : 
  108269           0 :           returnPointer = &( ( (SgTryStmt*)(SgTryStmt::pools[memoryBlock]) ) [positionInPool]) ;
  108270             : 
  108271             : #if FILE_IO_EXTRA_CHECK
  108272           0 :           assert ( returnPointer != NULL ) ;
  108273             : #endif
  108274             :         }
  108275           0 :      return returnPointer ;
  108276             :    }
  108277             : 
  108278             : //############################################################################
  108279             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  108280             :  * pool size! We set for every valid object in the memory pool the freepointer
  108281             :  * to the global index and increase the global index afterwards. For all the 
  108282             :  * invalid objects (means address ranges within the memory pool that were not
  108283             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  108284             :  * distinguish valid from invalid objects! 
  108285             :  */
  108286             : unsigned long
  108287           5 : SgTryStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  108288             :    {
  108289           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  108290           5 :      SgTryStmt* pointer = NULL;
  108291           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  108292           5 :      std::vector < unsigned char* > :: const_iterator block;
  108293           6 :      for ( block = SgTryStmt::pools.begin(); block != SgTryStmt::pools.end() ; ++block )
  108294             :         {
  108295           1 :           pointer = (SgTryStmt*)(*block);
  108296        2001 :           for (unsigned i = 0; i < SgTryStmt::pool_size; ++i )
  108297             :              {
  108298             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  108299             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  108300             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  108301             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  108302             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  108303             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  108304             :             // properly; so this will have to be checked next.
  108305             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  108306             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  108307        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  108308             :                   {
  108309          54 :                     pointer[i].set_freepointer((SgTryStmt*)(globalIndex));
  108310          54 :                     globalIndex++;
  108311             :                   }
  108312             :                else
  108313             :                   {
  108314        1946 :                     pointer[i].set_freepointer(NULL);
  108315             :                   }
  108316             :               }
  108317             :         }
  108318           5 :      return globalIndex;
  108319             :    }
  108320             : 
  108321             : //############################################################################
  108322             : // JH (01/14/2006)
  108323             : void
  108324           5 : SgTryStmt::resetValidFreepointers( )
  108325             :    {
  108326           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  108327           5 :      SgTryStmt* pointer = NULL;
  108328           5 :      std::vector < unsigned char* > :: const_iterator block;
  108329           5 :      SgTryStmt* pointerOfLinkedList = NULL;
  108330           6 :      for ( block = SgTryStmt::pools.begin(); block != SgTryStmt::pools.end() ; ++block )
  108331             :         {
  108332           1 :           pointer = (SgTryStmt*)(*block);
  108333        2001 :           for (unsigned i = 0; i < SgTryStmt::pool_size; ++i )
  108334             :              {
  108335             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  108336             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  108337             :             // memory blocks!.
  108338        2000 :                if ( pointer[i].get_freepointer() != NULL )
  108339             :                   {
  108340          54 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  108341             :                   }
  108342             :                else
  108343             :                   {
  108344        1946 :                     if ( pointerOfLinkedList == NULL )
  108345             :                        {
  108346           1 :                          SgTryStmt::next_node = &(pointer[i]);
  108347             :                        }
  108348             :                     else
  108349             :                        {
  108350             :                       // printf ("In SgTryStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  108351        1945 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  108352             :                        }
  108353             :                     pointerOfLinkedList = &(pointer[i]);
  108354             :                   }
  108355             :               }
  108356             :         }
  108357             : 
  108358           5 :      if ( pointerOfLinkedList != NULL )
  108359             :         {
  108360             :        // printf ("In SgTryStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  108361           1 :           pointerOfLinkedList->set_freepointer(NULL);
  108362             :        // DQ (6/6/2010): Temporary debugging...
  108363             :        //   ROSE_ASSERT(false);
  108364             :         }
  108365             : 
  108366           5 :      return ;
  108367             :    }
  108368             : 
  108369             : //############################################################################
  108370             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  108371             :  * within the memory pool and resets the freepointers, in order to achieve a 
  108372             :  * linked list, that has no jumps and starts at the beginning! This function 
  108373             :  * does not extend the memory pool, since we do not delete any memory blocks,
  108374             :  * but delete the valid objects.  
  108375             :  */
  108376             : void
  108377           0 : SgTryStmt::clearMemoryPool( )
  108378             :    {
  108379             :   // printf ("Inside of SgTryStmt::clearMemoryPool() \n");
  108380             : 
  108381           0 :      SgTryStmt* pointer = NULL, *tempPointer = NULL;
  108382           0 :      std::vector < unsigned char* > :: const_iterator block;
  108383           0 :      if ( SgTryStmt::pools.empty() == false )
  108384             :         {
  108385           0 :           block = SgTryStmt::pools.begin() ;
  108386           0 :           SgTryStmt::next_node = (SgTryStmt*) (*block);
  108387             : 
  108388           0 :           while ( block != SgTryStmt::pools.end() )
  108389             :              {
  108390           0 :                pointer = (SgTryStmt*) (*block);
  108391           0 :                if ( tempPointer != NULL )
  108392             :                   {
  108393           0 :                     tempPointer->set_freepointer(pointer);
  108394             :                   }
  108395           0 :                for (unsigned i = 0; i < SgTryStmt::pool_size - 1; ++i)
  108396             :                   {
  108397           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  108398             :                   }
  108399           0 :                 pointer[SgTryStmt::pool_size-1].set_freepointer(NULL);
  108400           0 :                 tempPointer = &(pointer[SgTryStmt::pool_size-1]);
  108401           0 :                 ++block;
  108402             :              }
  108403             :         }
  108404           0 :    }
  108405             : 
  108406           5 : void SgTryStmt::deleteMemoryPool() {
  108407           7 :   for (auto p: SgTryStmt::pools) {
  108408           2 :     ROSE_FREE(p);
  108409             :   }
  108410           5 :   SgTryStmt::next_node = nullptr;
  108411           5 :   SgTryStmt::pools.clear();
  108412           5 : }
  108413             : 
  108414             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  108415             : //                 reading multiple binary files to for a single AST.
  108416             : /////////// new version ////////////////////////////////
  108417             : //############################################################################
  108418             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  108419             : void
  108420           2 : SgTryStmt::extendMemoryPoolForFileIO( )
  108421             :   {
  108422           2 :     size_t blockIndex = SgTryStmt::pools.size();
  108423           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTryStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTryStmt);
  108424             : 
  108425           3 :     while ( (blockIndex * SgTryStmt::pool_size) < newPoolSize)
  108426             :       {
  108427             : #if ROSE_ALLOC_TRACE
  108428             :         if (blockIndex > 0) {
  108429             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTryStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTryStmt) = %" PRIuPTR " SgTryStmt::pool_size = %d \n",
  108430             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTryStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTryStmt),SgTryStmt::pool_size);
  108431             :         }
  108432             : #endif
  108433             : 
  108434           1 :         SgTryStmt * pointer = (SgTryStmt*) ROSE_MALLOC ( SgTryStmt::pool_size * sizeof(SgTryStmt) );
  108435           1 :         assert( pointer != NULL );
  108436             : #if ROSE_ALLOC_MEMSET == 1
  108437             :         memset(pointer, 0x00, SgTryStmt::pool_size * sizeof(SgTryStmt));
  108438             : #elif ROSE_ALLOC_MEMSET == 2
  108439             :         memset(pointer, 0xCC, SgTryStmt::pool_size * sizeof(SgTryStmt));
  108440             : #endif
  108441           1 :         SgTryStmt::pools.push_back( (unsigned char*)(pointer) );
  108442           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTryStmt::pool_size * sizeof(SgTryStmt), V_SgTryStmt ) );
  108443             : 
  108444           1 :         if ( SgTryStmt::next_node != NULL ) {
  108445           0 :           if ( blockIndex > 0 ) {
  108446           0 :             SgTryStmt * blkptr = (SgTryStmt*)(SgTryStmt::pools[blockIndex-1]);
  108447           0 :             blkptr[ SgTryStmt::pool_size - 1 ].set_freepointer(pointer);
  108448             :           }
  108449             :         } else {
  108450           1 :           SgTryStmt::next_node = pointer;
  108451             :         }
  108452             : 
  108453        2000 :         for (unsigned i = 0; i < SgTryStmt::pool_size-1; ++i)
  108454             :            {
  108455        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  108456             :            }
  108457           1 :         pointer[ SgTryStmt::pool_size -1 ].set_freepointer(NULL);
  108458             : 
  108459           1 :         blockIndex++;
  108460             :       }
  108461           2 :   }
  108462             : 
  108463             : //############################################################################
  108464             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  108465             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  108466             :  * not compressed. However, that stuff is not yet implemented! 
  108467             :  */
  108468             : unsigned long
  108469           0 : SgTryStmt::getNumberOfLastValidPointer()
  108470             :    {
  108471           0 :       SgTryStmt* testPointer = (SgTryStmt*)(SgTryStmt::pools.back());
  108472           0 :       unsigned long localIndex = SgTryStmt::pool_size - 1;
  108473           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  108474             :          {
  108475           0 :            localIndex--;
  108476             :          }
  108477           0 :       return (localIndex + SgTryStmt::pool_size * (SgTryStmt::pools.size()-1));
  108478             :    }
  108479             : 
  108480             : //############################################################################
  108481             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  108482             :  * memory pool and initializes the data member in class SgTryStmtStroageClass
  108483             :  * from its counterpart of SgTryStmt. The return value is just for checking, 
  108484             :  * that the whole StorageClassArray is initialized!
  108485             :  */
  108486             : unsigned long
  108487           1 : SgTryStmt::initializeStorageClassArray( SgTryStmtStorageClass *storageArray )
  108488             :    {
  108489           1 :      unsigned long storageCounter = 0;
  108490           1 :      std::vector < unsigned char* > :: const_iterator block = SgTryStmt::pools.begin();
  108491           1 :      SgTryStmt* pointer = NULL;
  108492           2 :      while ( block != SgTryStmt::pools.end() ) {
  108493           1 :           pointer = (SgTryStmt*) (*block);
  108494        2001 :           for ( unsigned i = 0; i < SgTryStmt::pool_size; ++i ) {
  108495        2000 :                if ( pointer->get_freepointer() != NULL ) {
  108496          54 :                  storageArray->pickOutIRNodeData (pointer) ;
  108497          54 :                  storageArray++;
  108498          54 :                  storageCounter++;
  108499             :                }
  108500        2000 :                pointer++;
  108501             :              }
  108502           1 :            block++;
  108503             :         }
  108504           1 :      return storageCounter;
  108505             :    }
  108506             : 
  108507             : /* #line 108508 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  108508             : 
  108509             : 
  108510             : 
  108511             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  108512             : 
  108513             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  108514             : 
  108515             : //############################################################################
  108516             : /* JH (02/02/2006) Constructor of the IR node SgDefaultOptionStmt that takes its 
  108517             :  * corresponding StorageClass as parameter
  108518             :  */
  108519           0 : SgDefaultOptionStmt :: SgDefaultOptionStmt ( const SgDefaultOptionStmtStorageClass& storageSource )   : SgStatement (storageSource)
  108520             :    {
  108521             : 
  108522             : 
  108523             : /* #line 108524 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  108524             : 
  108525           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  108526           0 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
  108527           0 :      p_default_construct_name = storageSource.storageOf_default_construct_name.rebuildDataStoredInEasyStorageClass() ;
  108528             : 
  108529             : 
  108530             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  108531             : 
  108532             : 
  108533           0 :    }
  108534             : 
  108535             : //############################################################################
  108536             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  108537             :  * within the working AST. 
  108538             :  */
  108539           0 : SgDefaultOptionStmt * SgDefaultOptionStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  108540           0 :      SgDefaultOptionStmt* returnPointer = NULL;
  108541           0 :      if ( globalIndex != 0 )
  108542             :         {
  108543             : 
  108544             : #if FILE_IO_EXTRA_CHECK
  108545           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDefaultOptionStmt ) ) <= globalIndex ) ;
  108546           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDefaultOptionStmt + 1 ) ) );
  108547             : #endif
  108548           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDefaultOptionStmt )  
  108549           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDefaultOptionStmt );
  108550           0 :           unsigned long positionInPool = localIndex % SgDefaultOptionStmt::pool_size;
  108551           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDefaultOptionStmt::pool_size;
  108552             : 
  108553             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  108554             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  108555             : 
  108556           0 :           returnPointer = &( ( (SgDefaultOptionStmt*)(SgDefaultOptionStmt::pools[memoryBlock]) ) [positionInPool]) ;
  108557             : 
  108558           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  108559             :         }
  108560           0 :      return returnPointer ;
  108561             :    }
  108562             : 
  108563             : //############################################################################
  108564             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  108565             :   for the AST with the index astIndex
  108566             : */
  108567           0 : SgDefaultOptionStmt * SgDefaultOptionStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  108568           0 :      SgDefaultOptionStmt* returnPointer = NULL;
  108569           0 :      if ( globalIndex != 0 )
  108570             :         {
  108571             : 
  108572             : #if FILE_IO_EXTRA_CHECK
  108573           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDefaultOptionStmt ) ) <= globalIndex ) ;
  108574           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDefaultOptionStmt + 1 ) ) );
  108575             : #endif
  108576           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDefaultOptionStmt )
  108577           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDefaultOptionStmt );
  108578           0 :           unsigned long positionInPool = localIndex % SgDefaultOptionStmt::pool_size ;
  108579           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDefaultOptionStmt::pool_size ;
  108580             : 
  108581             : #if FILE_IO_EXTRA_CHECK
  108582             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  108583             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  108584             : #endif
  108585             : 
  108586           0 :           returnPointer = &( ( (SgDefaultOptionStmt*)(SgDefaultOptionStmt::pools[memoryBlock]) ) [positionInPool]) ;
  108587             : 
  108588             : #if FILE_IO_EXTRA_CHECK
  108589           0 :           assert ( returnPointer != NULL ) ;
  108590             : #endif
  108591             :         }
  108592           0 :      return returnPointer ;
  108593             :    }
  108594             : 
  108595             : //############################################################################
  108596             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  108597             :  * pool size! We set for every valid object in the memory pool the freepointer
  108598             :  * to the global index and increase the global index afterwards. For all the 
  108599             :  * invalid objects (means address ranges within the memory pool that were not
  108600             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  108601             :  * distinguish valid from invalid objects! 
  108602             :  */
  108603             : unsigned long
  108604           5 : SgDefaultOptionStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  108605             :    {
  108606           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  108607           5 :      SgDefaultOptionStmt* pointer = NULL;
  108608           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  108609           5 :      std::vector < unsigned char* > :: const_iterator block;
  108610           5 :      for ( block = SgDefaultOptionStmt::pools.begin(); block != SgDefaultOptionStmt::pools.end() ; ++block )
  108611             :         {
  108612           0 :           pointer = (SgDefaultOptionStmt*)(*block);
  108613           0 :           for (unsigned i = 0; i < SgDefaultOptionStmt::pool_size; ++i )
  108614             :              {
  108615             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  108616             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  108617             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  108618             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  108619             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  108620             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  108621             :             // properly; so this will have to be checked next.
  108622             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  108623             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  108624           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  108625             :                   {
  108626           0 :                     pointer[i].set_freepointer((SgDefaultOptionStmt*)(globalIndex));
  108627           0 :                     globalIndex++;
  108628             :                   }
  108629             :                else
  108630             :                   {
  108631           0 :                     pointer[i].set_freepointer(NULL);
  108632             :                   }
  108633             :               }
  108634             :         }
  108635           5 :      return globalIndex;
  108636             :    }
  108637             : 
  108638             : //############################################################################
  108639             : // JH (01/14/2006)
  108640             : void
  108641           5 : SgDefaultOptionStmt::resetValidFreepointers( )
  108642             :    {
  108643           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  108644           5 :      SgDefaultOptionStmt* pointer = NULL;
  108645           5 :      std::vector < unsigned char* > :: const_iterator block;
  108646           5 :      SgDefaultOptionStmt* pointerOfLinkedList = NULL;
  108647           5 :      for ( block = SgDefaultOptionStmt::pools.begin(); block != SgDefaultOptionStmt::pools.end() ; ++block )
  108648             :         {
  108649           0 :           pointer = (SgDefaultOptionStmt*)(*block);
  108650           0 :           for (unsigned i = 0; i < SgDefaultOptionStmt::pool_size; ++i )
  108651             :              {
  108652             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  108653             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  108654             :             // memory blocks!.
  108655           0 :                if ( pointer[i].get_freepointer() != NULL )
  108656             :                   {
  108657           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  108658             :                   }
  108659             :                else
  108660             :                   {
  108661           0 :                     if ( pointerOfLinkedList == NULL )
  108662             :                        {
  108663           0 :                          SgDefaultOptionStmt::next_node = &(pointer[i]);
  108664             :                        }
  108665             :                     else
  108666             :                        {
  108667             :                       // printf ("In SgDefaultOptionStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  108668           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  108669             :                        }
  108670             :                     pointerOfLinkedList = &(pointer[i]);
  108671             :                   }
  108672             :               }
  108673             :         }
  108674             : 
  108675           5 :      if ( pointerOfLinkedList != NULL )
  108676             :         {
  108677             :        // printf ("In SgDefaultOptionStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  108678           0 :           pointerOfLinkedList->set_freepointer(NULL);
  108679             :        // DQ (6/6/2010): Temporary debugging...
  108680             :        //   ROSE_ASSERT(false);
  108681             :         }
  108682             : 
  108683           5 :      return ;
  108684             :    }
  108685             : 
  108686             : //############################################################################
  108687             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  108688             :  * within the memory pool and resets the freepointers, in order to achieve a 
  108689             :  * linked list, that has no jumps and starts at the beginning! This function 
  108690             :  * does not extend the memory pool, since we do not delete any memory blocks,
  108691             :  * but delete the valid objects.  
  108692             :  */
  108693             : void
  108694           0 : SgDefaultOptionStmt::clearMemoryPool( )
  108695             :    {
  108696             :   // printf ("Inside of SgDefaultOptionStmt::clearMemoryPool() \n");
  108697             : 
  108698           0 :      SgDefaultOptionStmt* pointer = NULL, *tempPointer = NULL;
  108699           0 :      std::vector < unsigned char* > :: const_iterator block;
  108700           0 :      if ( SgDefaultOptionStmt::pools.empty() == false )
  108701             :         {
  108702           0 :           block = SgDefaultOptionStmt::pools.begin() ;
  108703           0 :           SgDefaultOptionStmt::next_node = (SgDefaultOptionStmt*) (*block);
  108704             : 
  108705           0 :           while ( block != SgDefaultOptionStmt::pools.end() )
  108706             :              {
  108707           0 :                pointer = (SgDefaultOptionStmt*) (*block);
  108708           0 :                if ( tempPointer != NULL )
  108709             :                   {
  108710           0 :                     tempPointer->set_freepointer(pointer);
  108711             :                   }
  108712           0 :                for (unsigned i = 0; i < SgDefaultOptionStmt::pool_size - 1; ++i)
  108713             :                   {
  108714           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  108715             :                   }
  108716           0 :                 pointer[SgDefaultOptionStmt::pool_size-1].set_freepointer(NULL);
  108717           0 :                 tempPointer = &(pointer[SgDefaultOptionStmt::pool_size-1]);
  108718           0 :                 ++block;
  108719             :              }
  108720             :         }
  108721           0 :    }
  108722             : 
  108723           5 : void SgDefaultOptionStmt::deleteMemoryPool() {
  108724           5 :   for (auto p: SgDefaultOptionStmt::pools) {
  108725           0 :     ROSE_FREE(p);
  108726             :   }
  108727           5 :   SgDefaultOptionStmt::next_node = nullptr;
  108728           5 :   SgDefaultOptionStmt::pools.clear();
  108729           5 : }
  108730             : 
  108731             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  108732             : //                 reading multiple binary files to for a single AST.
  108733             : /////////// new version ////////////////////////////////
  108734             : //############################################################################
  108735             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  108736             : void
  108737           2 : SgDefaultOptionStmt::extendMemoryPoolForFileIO( )
  108738             :   {
  108739           2 :     size_t blockIndex = SgDefaultOptionStmt::pools.size();
  108740           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDefaultOptionStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefaultOptionStmt);
  108741             : 
  108742           2 :     while ( (blockIndex * SgDefaultOptionStmt::pool_size) < newPoolSize)
  108743             :       {
  108744             : #if ROSE_ALLOC_TRACE
  108745             :         if (blockIndex > 0) {
  108746             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDefaultOptionStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefaultOptionStmt) = %" PRIuPTR " SgDefaultOptionStmt::pool_size = %d \n",
  108747             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDefaultOptionStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefaultOptionStmt),SgDefaultOptionStmt::pool_size);
  108748             :         }
  108749             : #endif
  108750             : 
  108751           0 :         SgDefaultOptionStmt * pointer = (SgDefaultOptionStmt*) ROSE_MALLOC ( SgDefaultOptionStmt::pool_size * sizeof(SgDefaultOptionStmt) );
  108752           0 :         assert( pointer != NULL );
  108753             : #if ROSE_ALLOC_MEMSET == 1
  108754             :         memset(pointer, 0x00, SgDefaultOptionStmt::pool_size * sizeof(SgDefaultOptionStmt));
  108755             : #elif ROSE_ALLOC_MEMSET == 2
  108756             :         memset(pointer, 0xCC, SgDefaultOptionStmt::pool_size * sizeof(SgDefaultOptionStmt));
  108757             : #endif
  108758           0 :         SgDefaultOptionStmt::pools.push_back( (unsigned char*)(pointer) );
  108759           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDefaultOptionStmt::pool_size * sizeof(SgDefaultOptionStmt), V_SgDefaultOptionStmt ) );
  108760             : 
  108761           0 :         if ( SgDefaultOptionStmt::next_node != NULL ) {
  108762           0 :           if ( blockIndex > 0 ) {
  108763           0 :             SgDefaultOptionStmt * blkptr = (SgDefaultOptionStmt*)(SgDefaultOptionStmt::pools[blockIndex-1]);
  108764           0 :             blkptr[ SgDefaultOptionStmt::pool_size - 1 ].set_freepointer(pointer);
  108765             :           }
  108766             :         } else {
  108767           0 :           SgDefaultOptionStmt::next_node = pointer;
  108768             :         }
  108769             : 
  108770           0 :         for (unsigned i = 0; i < SgDefaultOptionStmt::pool_size-1; ++i)
  108771             :            {
  108772           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  108773             :            }
  108774           0 :         pointer[ SgDefaultOptionStmt::pool_size -1 ].set_freepointer(NULL);
  108775             : 
  108776           0 :         blockIndex++;
  108777             :       }
  108778           2 :   }
  108779             : 
  108780             : //############################################################################
  108781             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  108782             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  108783             :  * not compressed. However, that stuff is not yet implemented! 
  108784             :  */
  108785             : unsigned long
  108786           0 : SgDefaultOptionStmt::getNumberOfLastValidPointer()
  108787             :    {
  108788           0 :       SgDefaultOptionStmt* testPointer = (SgDefaultOptionStmt*)(SgDefaultOptionStmt::pools.back());
  108789           0 :       unsigned long localIndex = SgDefaultOptionStmt::pool_size - 1;
  108790           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  108791             :          {
  108792           0 :            localIndex--;
  108793             :          }
  108794           0 :       return (localIndex + SgDefaultOptionStmt::pool_size * (SgDefaultOptionStmt::pools.size()-1));
  108795             :    }
  108796             : 
  108797             : //############################################################################
  108798             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  108799             :  * memory pool and initializes the data member in class SgDefaultOptionStmtStroageClass
  108800             :  * from its counterpart of SgDefaultOptionStmt. The return value is just for checking, 
  108801             :  * that the whole StorageClassArray is initialized!
  108802             :  */
  108803             : unsigned long
  108804           0 : SgDefaultOptionStmt::initializeStorageClassArray( SgDefaultOptionStmtStorageClass *storageArray )
  108805             :    {
  108806           0 :      unsigned long storageCounter = 0;
  108807           0 :      std::vector < unsigned char* > :: const_iterator block = SgDefaultOptionStmt::pools.begin();
  108808           0 :      SgDefaultOptionStmt* pointer = NULL;
  108809           0 :      while ( block != SgDefaultOptionStmt::pools.end() ) {
  108810           0 :           pointer = (SgDefaultOptionStmt*) (*block);
  108811           0 :           for ( unsigned i = 0; i < SgDefaultOptionStmt::pool_size; ++i ) {
  108812           0 :                if ( pointer->get_freepointer() != NULL ) {
  108813           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  108814           0 :                  storageArray++;
  108815           0 :                  storageCounter++;
  108816             :                }
  108817           0 :                pointer++;
  108818             :              }
  108819           0 :            block++;
  108820             :         }
  108821           0 :      return storageCounter;
  108822             :    }
  108823             : 
  108824             : /* #line 108825 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  108825             : 
  108826             : 
  108827             : 
  108828             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  108829             : 
  108830             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  108831             : 
  108832             : //############################################################################
  108833             : /* JH (02/02/2006) Constructor of the IR node SgBreakStmt that takes its 
  108834             :  * corresponding StorageClass as parameter
  108835             :  */
  108836          30 : SgBreakStmt :: SgBreakStmt ( const SgBreakStmtStorageClass& storageSource )   : SgStatement (storageSource)
  108837             :    {
  108838             : 
  108839             : 
  108840             : /* #line 108841 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  108841             : 
  108842          30 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  108843          30 :      p_do_string_label = storageSource.storageOf_do_string_label.rebuildDataStoredInEasyStorageClass() ;
  108844             : 
  108845             : 
  108846             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  108847             : 
  108848             : 
  108849          30 :    }
  108850             : 
  108851             : //############################################################################
  108852             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  108853             :  * within the working AST. 
  108854             :  */
  108855         111 : SgBreakStmt * SgBreakStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  108856         111 :      SgBreakStmt* returnPointer = NULL;
  108857         111 :      if ( globalIndex != 0 )
  108858             :         {
  108859             : 
  108860             : #if FILE_IO_EXTRA_CHECK
  108861         111 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBreakStmt ) ) <= globalIndex ) ;
  108862         111 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBreakStmt + 1 ) ) );
  108863             : #endif
  108864         111 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBreakStmt )  
  108865         111 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBreakStmt );
  108866         111 :           unsigned long positionInPool = localIndex % SgBreakStmt::pool_size;
  108867         111 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBreakStmt::pool_size;
  108868             : 
  108869             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  108870             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  108871             : 
  108872         111 :           returnPointer = &( ( (SgBreakStmt*)(SgBreakStmt::pools[memoryBlock]) ) [positionInPool]) ;
  108873             : 
  108874         111 :           ROSE_ASSERT( returnPointer != NULL ) ;
  108875             :         }
  108876         111 :      return returnPointer ;
  108877             :    }
  108878             : 
  108879             : //############################################################################
  108880             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  108881             :   for the AST with the index astIndex
  108882             : */
  108883           0 : SgBreakStmt * SgBreakStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  108884           0 :      SgBreakStmt* returnPointer = NULL;
  108885           0 :      if ( globalIndex != 0 )
  108886             :         {
  108887             : 
  108888             : #if FILE_IO_EXTRA_CHECK
  108889           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBreakStmt ) ) <= globalIndex ) ;
  108890           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBreakStmt + 1 ) ) );
  108891             : #endif
  108892           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBreakStmt )
  108893           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBreakStmt );
  108894           0 :           unsigned long positionInPool = localIndex % SgBreakStmt::pool_size ;
  108895           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBreakStmt::pool_size ;
  108896             : 
  108897             : #if FILE_IO_EXTRA_CHECK
  108898             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  108899             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  108900             : #endif
  108901             : 
  108902           0 :           returnPointer = &( ( (SgBreakStmt*)(SgBreakStmt::pools[memoryBlock]) ) [positionInPool]) ;
  108903             : 
  108904             : #if FILE_IO_EXTRA_CHECK
  108905           0 :           assert ( returnPointer != NULL ) ;
  108906             : #endif
  108907             :         }
  108908           0 :      return returnPointer ;
  108909             :    }
  108910             : 
  108911             : //############################################################################
  108912             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  108913             :  * pool size! We set for every valid object in the memory pool the freepointer
  108914             :  * to the global index and increase the global index afterwards. For all the 
  108915             :  * invalid objects (means address ranges within the memory pool that were not
  108916             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  108917             :  * distinguish valid from invalid objects! 
  108918             :  */
  108919             : unsigned long
  108920           5 : SgBreakStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  108921             :    {
  108922           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  108923           5 :      SgBreakStmt* pointer = NULL;
  108924           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  108925           5 :      std::vector < unsigned char* > :: const_iterator block;
  108926           6 :      for ( block = SgBreakStmt::pools.begin(); block != SgBreakStmt::pools.end() ; ++block )
  108927             :         {
  108928           1 :           pointer = (SgBreakStmt*)(*block);
  108929        2001 :           for (unsigned i = 0; i < SgBreakStmt::pool_size; ++i )
  108930             :              {
  108931             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  108932             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  108933             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  108934             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  108935             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  108936             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  108937             :             // properly; so this will have to be checked next.
  108938             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  108939             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  108940        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  108941             :                   {
  108942          30 :                     pointer[i].set_freepointer((SgBreakStmt*)(globalIndex));
  108943          30 :                     globalIndex++;
  108944             :                   }
  108945             :                else
  108946             :                   {
  108947        1970 :                     pointer[i].set_freepointer(NULL);
  108948             :                   }
  108949             :               }
  108950             :         }
  108951           5 :      return globalIndex;
  108952             :    }
  108953             : 
  108954             : //############################################################################
  108955             : // JH (01/14/2006)
  108956             : void
  108957           5 : SgBreakStmt::resetValidFreepointers( )
  108958             :    {
  108959           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  108960           5 :      SgBreakStmt* pointer = NULL;
  108961           5 :      std::vector < unsigned char* > :: const_iterator block;
  108962           5 :      SgBreakStmt* pointerOfLinkedList = NULL;
  108963           6 :      for ( block = SgBreakStmt::pools.begin(); block != SgBreakStmt::pools.end() ; ++block )
  108964             :         {
  108965           1 :           pointer = (SgBreakStmt*)(*block);
  108966        2001 :           for (unsigned i = 0; i < SgBreakStmt::pool_size; ++i )
  108967             :              {
  108968             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  108969             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  108970             :             // memory blocks!.
  108971        2000 :                if ( pointer[i].get_freepointer() != NULL )
  108972             :                   {
  108973          30 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  108974             :                   }
  108975             :                else
  108976             :                   {
  108977        1970 :                     if ( pointerOfLinkedList == NULL )
  108978             :                        {
  108979           1 :                          SgBreakStmt::next_node = &(pointer[i]);
  108980             :                        }
  108981             :                     else
  108982             :                        {
  108983             :                       // printf ("In SgBreakStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  108984        1969 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  108985             :                        }
  108986             :                     pointerOfLinkedList = &(pointer[i]);
  108987             :                   }
  108988             :               }
  108989             :         }
  108990             : 
  108991           5 :      if ( pointerOfLinkedList != NULL )
  108992             :         {
  108993             :        // printf ("In SgBreakStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  108994           1 :           pointerOfLinkedList->set_freepointer(NULL);
  108995             :        // DQ (6/6/2010): Temporary debugging...
  108996             :        //   ROSE_ASSERT(false);
  108997             :         }
  108998             : 
  108999           5 :      return ;
  109000             :    }
  109001             : 
  109002             : //############################################################################
  109003             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  109004             :  * within the memory pool and resets the freepointers, in order to achieve a 
  109005             :  * linked list, that has no jumps and starts at the beginning! This function 
  109006             :  * does not extend the memory pool, since we do not delete any memory blocks,
  109007             :  * but delete the valid objects.  
  109008             :  */
  109009             : void
  109010           0 : SgBreakStmt::clearMemoryPool( )
  109011             :    {
  109012             :   // printf ("Inside of SgBreakStmt::clearMemoryPool() \n");
  109013             : 
  109014           0 :      SgBreakStmt* pointer = NULL, *tempPointer = NULL;
  109015           0 :      std::vector < unsigned char* > :: const_iterator block;
  109016           0 :      if ( SgBreakStmt::pools.empty() == false )
  109017             :         {
  109018           0 :           block = SgBreakStmt::pools.begin() ;
  109019           0 :           SgBreakStmt::next_node = (SgBreakStmt*) (*block);
  109020             : 
  109021           0 :           while ( block != SgBreakStmt::pools.end() )
  109022             :              {
  109023           0 :                pointer = (SgBreakStmt*) (*block);
  109024           0 :                if ( tempPointer != NULL )
  109025             :                   {
  109026           0 :                     tempPointer->set_freepointer(pointer);
  109027             :                   }
  109028           0 :                for (unsigned i = 0; i < SgBreakStmt::pool_size - 1; ++i)
  109029             :                   {
  109030           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  109031             :                   }
  109032           0 :                 pointer[SgBreakStmt::pool_size-1].set_freepointer(NULL);
  109033           0 :                 tempPointer = &(pointer[SgBreakStmt::pool_size-1]);
  109034           0 :                 ++block;
  109035             :              }
  109036             :         }
  109037           0 :    }
  109038             : 
  109039           5 : void SgBreakStmt::deleteMemoryPool() {
  109040           7 :   for (auto p: SgBreakStmt::pools) {
  109041           2 :     ROSE_FREE(p);
  109042             :   }
  109043           5 :   SgBreakStmt::next_node = nullptr;
  109044           5 :   SgBreakStmt::pools.clear();
  109045           5 : }
  109046             : 
  109047             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  109048             : //                 reading multiple binary files to for a single AST.
  109049             : /////////// new version ////////////////////////////////
  109050             : //############################################################################
  109051             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  109052             : void
  109053           2 : SgBreakStmt::extendMemoryPoolForFileIO( )
  109054             :   {
  109055           2 :     size_t blockIndex = SgBreakStmt::pools.size();
  109056           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBreakStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBreakStmt);
  109057             : 
  109058           3 :     while ( (blockIndex * SgBreakStmt::pool_size) < newPoolSize)
  109059             :       {
  109060             : #if ROSE_ALLOC_TRACE
  109061             :         if (blockIndex > 0) {
  109062             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBreakStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBreakStmt) = %" PRIuPTR " SgBreakStmt::pool_size = %d \n",
  109063             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBreakStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBreakStmt),SgBreakStmt::pool_size);
  109064             :         }
  109065             : #endif
  109066             : 
  109067           1 :         SgBreakStmt * pointer = (SgBreakStmt*) ROSE_MALLOC ( SgBreakStmt::pool_size * sizeof(SgBreakStmt) );
  109068           1 :         assert( pointer != NULL );
  109069             : #if ROSE_ALLOC_MEMSET == 1
  109070             :         memset(pointer, 0x00, SgBreakStmt::pool_size * sizeof(SgBreakStmt));
  109071             : #elif ROSE_ALLOC_MEMSET == 2
  109072             :         memset(pointer, 0xCC, SgBreakStmt::pool_size * sizeof(SgBreakStmt));
  109073             : #endif
  109074           1 :         SgBreakStmt::pools.push_back( (unsigned char*)(pointer) );
  109075           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBreakStmt::pool_size * sizeof(SgBreakStmt), V_SgBreakStmt ) );
  109076             : 
  109077           1 :         if ( SgBreakStmt::next_node != NULL ) {
  109078           0 :           if ( blockIndex > 0 ) {
  109079           0 :             SgBreakStmt * blkptr = (SgBreakStmt*)(SgBreakStmt::pools[blockIndex-1]);
  109080           0 :             blkptr[ SgBreakStmt::pool_size - 1 ].set_freepointer(pointer);
  109081             :           }
  109082             :         } else {
  109083           1 :           SgBreakStmt::next_node = pointer;
  109084             :         }
  109085             : 
  109086        2000 :         for (unsigned i = 0; i < SgBreakStmt::pool_size-1; ++i)
  109087             :            {
  109088        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  109089             :            }
  109090           1 :         pointer[ SgBreakStmt::pool_size -1 ].set_freepointer(NULL);
  109091             : 
  109092           1 :         blockIndex++;
  109093             :       }
  109094           2 :   }
  109095             : 
  109096             : //############################################################################
  109097             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  109098             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  109099             :  * not compressed. However, that stuff is not yet implemented! 
  109100             :  */
  109101             : unsigned long
  109102           0 : SgBreakStmt::getNumberOfLastValidPointer()
  109103             :    {
  109104           0 :       SgBreakStmt* testPointer = (SgBreakStmt*)(SgBreakStmt::pools.back());
  109105           0 :       unsigned long localIndex = SgBreakStmt::pool_size - 1;
  109106           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  109107             :          {
  109108           0 :            localIndex--;
  109109             :          }
  109110           0 :       return (localIndex + SgBreakStmt::pool_size * (SgBreakStmt::pools.size()-1));
  109111             :    }
  109112             : 
  109113             : //############################################################################
  109114             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  109115             :  * memory pool and initializes the data member in class SgBreakStmtStroageClass
  109116             :  * from its counterpart of SgBreakStmt. The return value is just for checking, 
  109117             :  * that the whole StorageClassArray is initialized!
  109118             :  */
  109119             : unsigned long
  109120           1 : SgBreakStmt::initializeStorageClassArray( SgBreakStmtStorageClass *storageArray )
  109121             :    {
  109122           1 :      unsigned long storageCounter = 0;
  109123           1 :      std::vector < unsigned char* > :: const_iterator block = SgBreakStmt::pools.begin();
  109124           1 :      SgBreakStmt* pointer = NULL;
  109125           2 :      while ( block != SgBreakStmt::pools.end() ) {
  109126           1 :           pointer = (SgBreakStmt*) (*block);
  109127        2001 :           for ( unsigned i = 0; i < SgBreakStmt::pool_size; ++i ) {
  109128        2000 :                if ( pointer->get_freepointer() != NULL ) {
  109129          30 :                  storageArray->pickOutIRNodeData (pointer) ;
  109130          30 :                  storageArray++;
  109131          30 :                  storageCounter++;
  109132             :                }
  109133        2000 :                pointer++;
  109134             :              }
  109135           1 :            block++;
  109136             :         }
  109137           1 :      return storageCounter;
  109138             :    }
  109139             : 
  109140             : /* #line 109141 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  109141             : 
  109142             : 
  109143             : 
  109144             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  109145             : 
  109146             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  109147             : 
  109148             : //############################################################################
  109149             : /* JH (02/02/2006) Constructor of the IR node SgContinueStmt that takes its 
  109150             :  * corresponding StorageClass as parameter
  109151             :  */
  109152           2 : SgContinueStmt :: SgContinueStmt ( const SgContinueStmtStorageClass& storageSource )   : SgStatement (storageSource)
  109153             :    {
  109154             : 
  109155             : 
  109156             : /* #line 109157 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  109157             : 
  109158           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  109159           2 :      p_do_string_label = storageSource.storageOf_do_string_label.rebuildDataStoredInEasyStorageClass() ;
  109160             : 
  109161             : 
  109162             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  109163             : 
  109164             : 
  109165           2 :    }
  109166             : 
  109167             : //############################################################################
  109168             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  109169             :  * within the working AST. 
  109170             :  */
  109171           8 : SgContinueStmt * SgContinueStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  109172           8 :      SgContinueStmt* returnPointer = NULL;
  109173           8 :      if ( globalIndex != 0 )
  109174             :         {
  109175             : 
  109176             : #if FILE_IO_EXTRA_CHECK
  109177           8 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgContinueStmt ) ) <= globalIndex ) ;
  109178           8 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgContinueStmt + 1 ) ) );
  109179             : #endif
  109180           8 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgContinueStmt )  
  109181           8 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgContinueStmt );
  109182           8 :           unsigned long positionInPool = localIndex % SgContinueStmt::pool_size;
  109183           8 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgContinueStmt::pool_size;
  109184             : 
  109185             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  109186             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  109187             : 
  109188           8 :           returnPointer = &( ( (SgContinueStmt*)(SgContinueStmt::pools[memoryBlock]) ) [positionInPool]) ;
  109189             : 
  109190           8 :           ROSE_ASSERT( returnPointer != NULL ) ;
  109191             :         }
  109192           8 :      return returnPointer ;
  109193             :    }
  109194             : 
  109195             : //############################################################################
  109196             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  109197             :   for the AST with the index astIndex
  109198             : */
  109199           0 : SgContinueStmt * SgContinueStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  109200           0 :      SgContinueStmt* returnPointer = NULL;
  109201           0 :      if ( globalIndex != 0 )
  109202             :         {
  109203             : 
  109204             : #if FILE_IO_EXTRA_CHECK
  109205           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgContinueStmt ) ) <= globalIndex ) ;
  109206           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgContinueStmt + 1 ) ) );
  109207             : #endif
  109208           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgContinueStmt )
  109209           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgContinueStmt );
  109210           0 :           unsigned long positionInPool = localIndex % SgContinueStmt::pool_size ;
  109211           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgContinueStmt::pool_size ;
  109212             : 
  109213             : #if FILE_IO_EXTRA_CHECK
  109214             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  109215             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  109216             : #endif
  109217             : 
  109218           0 :           returnPointer = &( ( (SgContinueStmt*)(SgContinueStmt::pools[memoryBlock]) ) [positionInPool]) ;
  109219             : 
  109220             : #if FILE_IO_EXTRA_CHECK
  109221           0 :           assert ( returnPointer != NULL ) ;
  109222             : #endif
  109223             :         }
  109224           0 :      return returnPointer ;
  109225             :    }
  109226             : 
  109227             : //############################################################################
  109228             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  109229             :  * pool size! We set for every valid object in the memory pool the freepointer
  109230             :  * to the global index and increase the global index afterwards. For all the 
  109231             :  * invalid objects (means address ranges within the memory pool that were not
  109232             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  109233             :  * distinguish valid from invalid objects! 
  109234             :  */
  109235             : unsigned long
  109236           5 : SgContinueStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  109237             :    {
  109238           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  109239           5 :      SgContinueStmt* pointer = NULL;
  109240           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  109241           5 :      std::vector < unsigned char* > :: const_iterator block;
  109242           6 :      for ( block = SgContinueStmt::pools.begin(); block != SgContinueStmt::pools.end() ; ++block )
  109243             :         {
  109244           1 :           pointer = (SgContinueStmt*)(*block);
  109245        2001 :           for (unsigned i = 0; i < SgContinueStmt::pool_size; ++i )
  109246             :              {
  109247             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  109248             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  109249             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  109250             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  109251             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  109252             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  109253             :             // properly; so this will have to be checked next.
  109254             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  109255             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  109256        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  109257             :                   {
  109258           2 :                     pointer[i].set_freepointer((SgContinueStmt*)(globalIndex));
  109259           2 :                     globalIndex++;
  109260             :                   }
  109261             :                else
  109262             :                   {
  109263        1998 :                     pointer[i].set_freepointer(NULL);
  109264             :                   }
  109265             :               }
  109266             :         }
  109267           5 :      return globalIndex;
  109268             :    }
  109269             : 
  109270             : //############################################################################
  109271             : // JH (01/14/2006)
  109272             : void
  109273           5 : SgContinueStmt::resetValidFreepointers( )
  109274             :    {
  109275           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  109276           5 :      SgContinueStmt* pointer = NULL;
  109277           5 :      std::vector < unsigned char* > :: const_iterator block;
  109278           5 :      SgContinueStmt* pointerOfLinkedList = NULL;
  109279           6 :      for ( block = SgContinueStmt::pools.begin(); block != SgContinueStmt::pools.end() ; ++block )
  109280             :         {
  109281           1 :           pointer = (SgContinueStmt*)(*block);
  109282        2001 :           for (unsigned i = 0; i < SgContinueStmt::pool_size; ++i )
  109283             :              {
  109284             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  109285             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  109286             :             // memory blocks!.
  109287        2000 :                if ( pointer[i].get_freepointer() != NULL )
  109288             :                   {
  109289           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  109290             :                   }
  109291             :                else
  109292             :                   {
  109293        1998 :                     if ( pointerOfLinkedList == NULL )
  109294             :                        {
  109295           1 :                          SgContinueStmt::next_node = &(pointer[i]);
  109296             :                        }
  109297             :                     else
  109298             :                        {
  109299             :                       // printf ("In SgContinueStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  109300        1997 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  109301             :                        }
  109302             :                     pointerOfLinkedList = &(pointer[i]);
  109303             :                   }
  109304             :               }
  109305             :         }
  109306             : 
  109307           5 :      if ( pointerOfLinkedList != NULL )
  109308             :         {
  109309             :        // printf ("In SgContinueStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  109310           1 :           pointerOfLinkedList->set_freepointer(NULL);
  109311             :        // DQ (6/6/2010): Temporary debugging...
  109312             :        //   ROSE_ASSERT(false);
  109313             :         }
  109314             : 
  109315           5 :      return ;
  109316             :    }
  109317             : 
  109318             : //############################################################################
  109319             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  109320             :  * within the memory pool and resets the freepointers, in order to achieve a 
  109321             :  * linked list, that has no jumps and starts at the beginning! This function 
  109322             :  * does not extend the memory pool, since we do not delete any memory blocks,
  109323             :  * but delete the valid objects.  
  109324             :  */
  109325             : void
  109326           0 : SgContinueStmt::clearMemoryPool( )
  109327             :    {
  109328             :   // printf ("Inside of SgContinueStmt::clearMemoryPool() \n");
  109329             : 
  109330           0 :      SgContinueStmt* pointer = NULL, *tempPointer = NULL;
  109331           0 :      std::vector < unsigned char* > :: const_iterator block;
  109332           0 :      if ( SgContinueStmt::pools.empty() == false )
  109333             :         {
  109334           0 :           block = SgContinueStmt::pools.begin() ;
  109335           0 :           SgContinueStmt::next_node = (SgContinueStmt*) (*block);
  109336             : 
  109337           0 :           while ( block != SgContinueStmt::pools.end() )
  109338             :              {
  109339           0 :                pointer = (SgContinueStmt*) (*block);
  109340           0 :                if ( tempPointer != NULL )
  109341             :                   {
  109342           0 :                     tempPointer->set_freepointer(pointer);
  109343             :                   }
  109344           0 :                for (unsigned i = 0; i < SgContinueStmt::pool_size - 1; ++i)
  109345             :                   {
  109346           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  109347             :                   }
  109348           0 :                 pointer[SgContinueStmt::pool_size-1].set_freepointer(NULL);
  109349           0 :                 tempPointer = &(pointer[SgContinueStmt::pool_size-1]);
  109350           0 :                 ++block;
  109351             :              }
  109352             :         }
  109353           0 :    }
  109354             : 
  109355           5 : void SgContinueStmt::deleteMemoryPool() {
  109356           7 :   for (auto p: SgContinueStmt::pools) {
  109357           2 :     ROSE_FREE(p);
  109358             :   }
  109359           5 :   SgContinueStmt::next_node = nullptr;
  109360           5 :   SgContinueStmt::pools.clear();
  109361           5 : }
  109362             : 
  109363             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  109364             : //                 reading multiple binary files to for a single AST.
  109365             : /////////// new version ////////////////////////////////
  109366             : //############################################################################
  109367             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  109368             : void
  109369           2 : SgContinueStmt::extendMemoryPoolForFileIO( )
  109370             :   {
  109371           2 :     size_t blockIndex = SgContinueStmt::pools.size();
  109372           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgContinueStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgContinueStmt);
  109373             : 
  109374           3 :     while ( (blockIndex * SgContinueStmt::pool_size) < newPoolSize)
  109375             :       {
  109376             : #if ROSE_ALLOC_TRACE
  109377             :         if (blockIndex > 0) {
  109378             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgContinueStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgContinueStmt) = %" PRIuPTR " SgContinueStmt::pool_size = %d \n",
  109379             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgContinueStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgContinueStmt),SgContinueStmt::pool_size);
  109380             :         }
  109381             : #endif
  109382             : 
  109383           1 :         SgContinueStmt * pointer = (SgContinueStmt*) ROSE_MALLOC ( SgContinueStmt::pool_size * sizeof(SgContinueStmt) );
  109384           1 :         assert( pointer != NULL );
  109385             : #if ROSE_ALLOC_MEMSET == 1
  109386             :         memset(pointer, 0x00, SgContinueStmt::pool_size * sizeof(SgContinueStmt));
  109387             : #elif ROSE_ALLOC_MEMSET == 2
  109388             :         memset(pointer, 0xCC, SgContinueStmt::pool_size * sizeof(SgContinueStmt));
  109389             : #endif
  109390           1 :         SgContinueStmt::pools.push_back( (unsigned char*)(pointer) );
  109391           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgContinueStmt::pool_size * sizeof(SgContinueStmt), V_SgContinueStmt ) );
  109392             : 
  109393           1 :         if ( SgContinueStmt::next_node != NULL ) {
  109394           0 :           if ( blockIndex > 0 ) {
  109395           0 :             SgContinueStmt * blkptr = (SgContinueStmt*)(SgContinueStmt::pools[blockIndex-1]);
  109396           0 :             blkptr[ SgContinueStmt::pool_size - 1 ].set_freepointer(pointer);
  109397             :           }
  109398             :         } else {
  109399           1 :           SgContinueStmt::next_node = pointer;
  109400             :         }
  109401             : 
  109402        2000 :         for (unsigned i = 0; i < SgContinueStmt::pool_size-1; ++i)
  109403             :            {
  109404        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  109405             :            }
  109406           1 :         pointer[ SgContinueStmt::pool_size -1 ].set_freepointer(NULL);
  109407             : 
  109408           1 :         blockIndex++;
  109409             :       }
  109410           2 :   }
  109411             : 
  109412             : //############################################################################
  109413             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  109414             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  109415             :  * not compressed. However, that stuff is not yet implemented! 
  109416             :  */
  109417             : unsigned long
  109418           0 : SgContinueStmt::getNumberOfLastValidPointer()
  109419             :    {
  109420           0 :       SgContinueStmt* testPointer = (SgContinueStmt*)(SgContinueStmt::pools.back());
  109421           0 :       unsigned long localIndex = SgContinueStmt::pool_size - 1;
  109422           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  109423             :          {
  109424           0 :            localIndex--;
  109425             :          }
  109426           0 :       return (localIndex + SgContinueStmt::pool_size * (SgContinueStmt::pools.size()-1));
  109427             :    }
  109428             : 
  109429             : //############################################################################
  109430             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  109431             :  * memory pool and initializes the data member in class SgContinueStmtStroageClass
  109432             :  * from its counterpart of SgContinueStmt. The return value is just for checking, 
  109433             :  * that the whole StorageClassArray is initialized!
  109434             :  */
  109435             : unsigned long
  109436           1 : SgContinueStmt::initializeStorageClassArray( SgContinueStmtStorageClass *storageArray )
  109437             :    {
  109438           1 :      unsigned long storageCounter = 0;
  109439           1 :      std::vector < unsigned char* > :: const_iterator block = SgContinueStmt::pools.begin();
  109440           1 :      SgContinueStmt* pointer = NULL;
  109441           2 :      while ( block != SgContinueStmt::pools.end() ) {
  109442           1 :           pointer = (SgContinueStmt*) (*block);
  109443        2001 :           for ( unsigned i = 0; i < SgContinueStmt::pool_size; ++i ) {
  109444        2000 :                if ( pointer->get_freepointer() != NULL ) {
  109445           2 :                  storageArray->pickOutIRNodeData (pointer) ;
  109446           2 :                  storageArray++;
  109447           2 :                  storageCounter++;
  109448             :                }
  109449        2000 :                pointer++;
  109450             :              }
  109451           1 :            block++;
  109452             :         }
  109453           1 :      return storageCounter;
  109454             :    }
  109455             : 
  109456             : /* #line 109457 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  109457             : 
  109458             : 
  109459             : 
  109460             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  109461             : 
  109462             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  109463             : 
  109464             : //############################################################################
  109465             : /* JH (02/02/2006) Constructor of the IR node SgReturnStmt that takes its 
  109466             :  * corresponding StorageClass as parameter
  109467             :  */
  109468        1405 : SgReturnStmt :: SgReturnStmt ( const SgReturnStmtStorageClass& storageSource )   : SgStatement (storageSource)
  109469             :    {
  109470             : 
  109471             : 
  109472             : /* #line 109473 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  109473             : 
  109474        1405 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  109475        1405 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  109476             : 
  109477             : 
  109478             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  109479             : 
  109480             : 
  109481        1405 :    }
  109482             : 
  109483             : //############################################################################
  109484             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  109485             :  * within the working AST. 
  109486             :  */
  109487        5706 : SgReturnStmt * SgReturnStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  109488        5706 :      SgReturnStmt* returnPointer = NULL;
  109489        5706 :      if ( globalIndex != 0 )
  109490             :         {
  109491             : 
  109492             : #if FILE_IO_EXTRA_CHECK
  109493        5706 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgReturnStmt ) ) <= globalIndex ) ;
  109494        5706 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgReturnStmt + 1 ) ) );
  109495             : #endif
  109496        5706 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgReturnStmt )  
  109497        5706 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgReturnStmt );
  109498        5706 :           unsigned long positionInPool = localIndex % SgReturnStmt::pool_size;
  109499        5706 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgReturnStmt::pool_size;
  109500             : 
  109501             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  109502             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  109503             : 
  109504        5706 :           returnPointer = &( ( (SgReturnStmt*)(SgReturnStmt::pools[memoryBlock]) ) [positionInPool]) ;
  109505             : 
  109506        5706 :           ROSE_ASSERT( returnPointer != NULL ) ;
  109507             :         }
  109508        5706 :      return returnPointer ;
  109509             :    }
  109510             : 
  109511             : //############################################################################
  109512             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  109513             :   for the AST with the index astIndex
  109514             : */
  109515           0 : SgReturnStmt * SgReturnStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  109516           0 :      SgReturnStmt* returnPointer = NULL;
  109517           0 :      if ( globalIndex != 0 )
  109518             :         {
  109519             : 
  109520             : #if FILE_IO_EXTRA_CHECK
  109521           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgReturnStmt ) ) <= globalIndex ) ;
  109522           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgReturnStmt + 1 ) ) );
  109523             : #endif
  109524           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgReturnStmt )
  109525           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgReturnStmt );
  109526           0 :           unsigned long positionInPool = localIndex % SgReturnStmt::pool_size ;
  109527           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgReturnStmt::pool_size ;
  109528             : 
  109529             : #if FILE_IO_EXTRA_CHECK
  109530             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  109531             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  109532             : #endif
  109533             : 
  109534           0 :           returnPointer = &( ( (SgReturnStmt*)(SgReturnStmt::pools[memoryBlock]) ) [positionInPool]) ;
  109535             : 
  109536             : #if FILE_IO_EXTRA_CHECK
  109537           0 :           assert ( returnPointer != NULL ) ;
  109538             : #endif
  109539             :         }
  109540           0 :      return returnPointer ;
  109541             :    }
  109542             : 
  109543             : //############################################################################
  109544             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  109545             :  * pool size! We set for every valid object in the memory pool the freepointer
  109546             :  * to the global index and increase the global index afterwards. For all the 
  109547             :  * invalid objects (means address ranges within the memory pool that were not
  109548             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  109549             :  * distinguish valid from invalid objects! 
  109550             :  */
  109551             : unsigned long
  109552           5 : SgReturnStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  109553             :    {
  109554           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  109555           5 :      SgReturnStmt* pointer = NULL;
  109556           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  109557           5 :      std::vector < unsigned char* > :: const_iterator block;
  109558           7 :      for ( block = SgReturnStmt::pools.begin(); block != SgReturnStmt::pools.end() ; ++block )
  109559             :         {
  109560           2 :           pointer = (SgReturnStmt*)(*block);
  109561        4002 :           for (unsigned i = 0; i < SgReturnStmt::pool_size; ++i )
  109562             :              {
  109563             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  109564             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  109565             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  109566             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  109567             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  109568             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  109569             :             // properly; so this will have to be checked next.
  109570             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  109571             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  109572        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  109573             :                   {
  109574        1405 :                     pointer[i].set_freepointer((SgReturnStmt*)(globalIndex));
  109575        1405 :                     globalIndex++;
  109576             :                   }
  109577             :                else
  109578             :                   {
  109579        2595 :                     pointer[i].set_freepointer(NULL);
  109580             :                   }
  109581             :               }
  109582             :         }
  109583           5 :      return globalIndex;
  109584             :    }
  109585             : 
  109586             : //############################################################################
  109587             : // JH (01/14/2006)
  109588             : void
  109589           5 : SgReturnStmt::resetValidFreepointers( )
  109590             :    {
  109591           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  109592           5 :      SgReturnStmt* pointer = NULL;
  109593           5 :      std::vector < unsigned char* > :: const_iterator block;
  109594           5 :      SgReturnStmt* pointerOfLinkedList = NULL;
  109595           7 :      for ( block = SgReturnStmt::pools.begin(); block != SgReturnStmt::pools.end() ; ++block )
  109596             :         {
  109597           2 :           pointer = (SgReturnStmt*)(*block);
  109598        4002 :           for (unsigned i = 0; i < SgReturnStmt::pool_size; ++i )
  109599             :              {
  109600             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  109601             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  109602             :             // memory blocks!.
  109603        4000 :                if ( pointer[i].get_freepointer() != NULL )
  109604             :                   {
  109605        1405 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  109606             :                   }
  109607             :                else
  109608             :                   {
  109609        2595 :                     if ( pointerOfLinkedList == NULL )
  109610             :                        {
  109611           2 :                          SgReturnStmt::next_node = &(pointer[i]);
  109612             :                        }
  109613             :                     else
  109614             :                        {
  109615             :                       // printf ("In SgReturnStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  109616        2593 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  109617             :                        }
  109618             :                     pointerOfLinkedList = &(pointer[i]);
  109619             :                   }
  109620             :               }
  109621             :         }
  109622             : 
  109623           5 :      if ( pointerOfLinkedList != NULL )
  109624             :         {
  109625             :        // printf ("In SgReturnStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  109626           2 :           pointerOfLinkedList->set_freepointer(NULL);
  109627             :        // DQ (6/6/2010): Temporary debugging...
  109628             :        //   ROSE_ASSERT(false);
  109629             :         }
  109630             : 
  109631           5 :      return ;
  109632             :    }
  109633             : 
  109634             : //############################################################################
  109635             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  109636             :  * within the memory pool and resets the freepointers, in order to achieve a 
  109637             :  * linked list, that has no jumps and starts at the beginning! This function 
  109638             :  * does not extend the memory pool, since we do not delete any memory blocks,
  109639             :  * but delete the valid objects.  
  109640             :  */
  109641             : void
  109642           0 : SgReturnStmt::clearMemoryPool( )
  109643             :    {
  109644             :   // printf ("Inside of SgReturnStmt::clearMemoryPool() \n");
  109645             : 
  109646           0 :      SgReturnStmt* pointer = NULL, *tempPointer = NULL;
  109647           0 :      std::vector < unsigned char* > :: const_iterator block;
  109648           0 :      if ( SgReturnStmt::pools.empty() == false )
  109649             :         {
  109650           0 :           block = SgReturnStmt::pools.begin() ;
  109651           0 :           SgReturnStmt::next_node = (SgReturnStmt*) (*block);
  109652             : 
  109653           0 :           while ( block != SgReturnStmt::pools.end() )
  109654             :              {
  109655           0 :                pointer = (SgReturnStmt*) (*block);
  109656           0 :                if ( tempPointer != NULL )
  109657             :                   {
  109658           0 :                     tempPointer->set_freepointer(pointer);
  109659             :                   }
  109660           0 :                for (unsigned i = 0; i < SgReturnStmt::pool_size - 1; ++i)
  109661             :                   {
  109662           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  109663             :                   }
  109664           0 :                 pointer[SgReturnStmt::pool_size-1].set_freepointer(NULL);
  109665           0 :                 tempPointer = &(pointer[SgReturnStmt::pool_size-1]);
  109666           0 :                 ++block;
  109667             :              }
  109668             :         }
  109669           0 :    }
  109670             : 
  109671           5 : void SgReturnStmt::deleteMemoryPool() {
  109672           9 :   for (auto p: SgReturnStmt::pools) {
  109673           4 :     ROSE_FREE(p);
  109674             :   }
  109675           5 :   SgReturnStmt::next_node = nullptr;
  109676           5 :   SgReturnStmt::pools.clear();
  109677           5 : }
  109678             : 
  109679             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  109680             : //                 reading multiple binary files to for a single AST.
  109681             : /////////// new version ////////////////////////////////
  109682             : //############################################################################
  109683             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  109684             : void
  109685           2 : SgReturnStmt::extendMemoryPoolForFileIO( )
  109686             :   {
  109687           2 :     size_t blockIndex = SgReturnStmt::pools.size();
  109688           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgReturnStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgReturnStmt);
  109689             : 
  109690           4 :     while ( (blockIndex * SgReturnStmt::pool_size) < newPoolSize)
  109691             :       {
  109692             : #if ROSE_ALLOC_TRACE
  109693             :         if (blockIndex > 0) {
  109694             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgReturnStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgReturnStmt) = %" PRIuPTR " SgReturnStmt::pool_size = %d \n",
  109695             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgReturnStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgReturnStmt),SgReturnStmt::pool_size);
  109696             :         }
  109697             : #endif
  109698             : 
  109699           2 :         SgReturnStmt * pointer = (SgReturnStmt*) ROSE_MALLOC ( SgReturnStmt::pool_size * sizeof(SgReturnStmt) );
  109700           2 :         assert( pointer != NULL );
  109701             : #if ROSE_ALLOC_MEMSET == 1
  109702             :         memset(pointer, 0x00, SgReturnStmt::pool_size * sizeof(SgReturnStmt));
  109703             : #elif ROSE_ALLOC_MEMSET == 2
  109704             :         memset(pointer, 0xCC, SgReturnStmt::pool_size * sizeof(SgReturnStmt));
  109705             : #endif
  109706           2 :         SgReturnStmt::pools.push_back( (unsigned char*)(pointer) );
  109707           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgReturnStmt::pool_size * sizeof(SgReturnStmt), V_SgReturnStmt ) );
  109708             : 
  109709           2 :         if ( SgReturnStmt::next_node != NULL ) {
  109710           0 :           if ( blockIndex > 0 ) {
  109711           0 :             SgReturnStmt * blkptr = (SgReturnStmt*)(SgReturnStmt::pools[blockIndex-1]);
  109712           0 :             blkptr[ SgReturnStmt::pool_size - 1 ].set_freepointer(pointer);
  109713             :           }
  109714             :         } else {
  109715           2 :           SgReturnStmt::next_node = pointer;
  109716             :         }
  109717             : 
  109718        4000 :         for (unsigned i = 0; i < SgReturnStmt::pool_size-1; ++i)
  109719             :            {
  109720        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  109721             :            }
  109722           2 :         pointer[ SgReturnStmt::pool_size -1 ].set_freepointer(NULL);
  109723             : 
  109724           2 :         blockIndex++;
  109725             :       }
  109726           2 :   }
  109727             : 
  109728             : //############################################################################
  109729             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  109730             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  109731             :  * not compressed. However, that stuff is not yet implemented! 
  109732             :  */
  109733             : unsigned long
  109734           0 : SgReturnStmt::getNumberOfLastValidPointer()
  109735             :    {
  109736           0 :       SgReturnStmt* testPointer = (SgReturnStmt*)(SgReturnStmt::pools.back());
  109737           0 :       unsigned long localIndex = SgReturnStmt::pool_size - 1;
  109738           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  109739             :          {
  109740           0 :            localIndex--;
  109741             :          }
  109742           0 :       return (localIndex + SgReturnStmt::pool_size * (SgReturnStmt::pools.size()-1));
  109743             :    }
  109744             : 
  109745             : //############################################################################
  109746             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  109747             :  * memory pool and initializes the data member in class SgReturnStmtStroageClass
  109748             :  * from its counterpart of SgReturnStmt. The return value is just for checking, 
  109749             :  * that the whole StorageClassArray is initialized!
  109750             :  */
  109751             : unsigned long
  109752           2 : SgReturnStmt::initializeStorageClassArray( SgReturnStmtStorageClass *storageArray )
  109753             :    {
  109754           2 :      unsigned long storageCounter = 0;
  109755           2 :      std::vector < unsigned char* > :: const_iterator block = SgReturnStmt::pools.begin();
  109756           2 :      SgReturnStmt* pointer = NULL;
  109757           4 :      while ( block != SgReturnStmt::pools.end() ) {
  109758           2 :           pointer = (SgReturnStmt*) (*block);
  109759        4002 :           for ( unsigned i = 0; i < SgReturnStmt::pool_size; ++i ) {
  109760        4000 :                if ( pointer->get_freepointer() != NULL ) {
  109761        1405 :                  storageArray->pickOutIRNodeData (pointer) ;
  109762        1405 :                  storageArray++;
  109763        1405 :                  storageCounter++;
  109764             :                }
  109765        4000 :                pointer++;
  109766             :              }
  109767           2 :            block++;
  109768             :         }
  109769           2 :      return storageCounter;
  109770             :    }
  109771             : 
  109772             : /* #line 109773 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  109773             : 
  109774             : 
  109775             : 
  109776             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  109777             : 
  109778             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  109779             : 
  109780             : //############################################################################
  109781             : /* JH (02/02/2006) Constructor of the IR node SgGotoStatement that takes its 
  109782             :  * corresponding StorageClass as parameter
  109783             :  */
  109784           0 : SgGotoStatement :: SgGotoStatement ( const SgGotoStatementStorageClass& storageSource )   : SgStatement (storageSource)
  109785             :    {
  109786             : 
  109787             : 
  109788             : /* #line 109789 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  109789             : 
  109790           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  109791           0 :      p_label =  (SgLabelStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_label) );
  109792           0 :      p_label_expression =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_label_expression) );
  109793           0 :      p_selector_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_selector_expression) );
  109794             : 
  109795             : 
  109796             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  109797             : 
  109798             : 
  109799           0 :    }
  109800             : 
  109801             : //############################################################################
  109802             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  109803             :  * within the working AST. 
  109804             :  */
  109805           0 : SgGotoStatement * SgGotoStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  109806           0 :      SgGotoStatement* returnPointer = NULL;
  109807           0 :      if ( globalIndex != 0 )
  109808             :         {
  109809             : 
  109810             : #if FILE_IO_EXTRA_CHECK
  109811           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGotoStatement ) ) <= globalIndex ) ;
  109812           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGotoStatement + 1 ) ) );
  109813             : #endif
  109814           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGotoStatement )  
  109815           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGotoStatement );
  109816           0 :           unsigned long positionInPool = localIndex % SgGotoStatement::pool_size;
  109817           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGotoStatement::pool_size;
  109818             : 
  109819             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  109820             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  109821             : 
  109822           0 :           returnPointer = &( ( (SgGotoStatement*)(SgGotoStatement::pools[memoryBlock]) ) [positionInPool]) ;
  109823             : 
  109824           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  109825             :         }
  109826           0 :      return returnPointer ;
  109827             :    }
  109828             : 
  109829             : //############################################################################
  109830             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  109831             :   for the AST with the index astIndex
  109832             : */
  109833           0 : SgGotoStatement * SgGotoStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  109834           0 :      SgGotoStatement* returnPointer = NULL;
  109835           0 :      if ( globalIndex != 0 )
  109836             :         {
  109837             : 
  109838             : #if FILE_IO_EXTRA_CHECK
  109839           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGotoStatement ) ) <= globalIndex ) ;
  109840           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGotoStatement + 1 ) ) );
  109841             : #endif
  109842           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGotoStatement )
  109843           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGotoStatement );
  109844           0 :           unsigned long positionInPool = localIndex % SgGotoStatement::pool_size ;
  109845           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGotoStatement::pool_size ;
  109846             : 
  109847             : #if FILE_IO_EXTRA_CHECK
  109848             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  109849             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  109850             : #endif
  109851             : 
  109852           0 :           returnPointer = &( ( (SgGotoStatement*)(SgGotoStatement::pools[memoryBlock]) ) [positionInPool]) ;
  109853             : 
  109854             : #if FILE_IO_EXTRA_CHECK
  109855           0 :           assert ( returnPointer != NULL ) ;
  109856             : #endif
  109857             :         }
  109858           0 :      return returnPointer ;
  109859             :    }
  109860             : 
  109861             : //############################################################################
  109862             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  109863             :  * pool size! We set for every valid object in the memory pool the freepointer
  109864             :  * to the global index and increase the global index afterwards. For all the 
  109865             :  * invalid objects (means address ranges within the memory pool that were not
  109866             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  109867             :  * distinguish valid from invalid objects! 
  109868             :  */
  109869             : unsigned long
  109870           5 : SgGotoStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  109871             :    {
  109872           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  109873           5 :      SgGotoStatement* pointer = NULL;
  109874           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  109875           5 :      std::vector < unsigned char* > :: const_iterator block;
  109876           5 :      for ( block = SgGotoStatement::pools.begin(); block != SgGotoStatement::pools.end() ; ++block )
  109877             :         {
  109878           0 :           pointer = (SgGotoStatement*)(*block);
  109879           0 :           for (unsigned i = 0; i < SgGotoStatement::pool_size; ++i )
  109880             :              {
  109881             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  109882             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  109883             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  109884             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  109885             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  109886             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  109887             :             // properly; so this will have to be checked next.
  109888             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  109889             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  109890           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  109891             :                   {
  109892           0 :                     pointer[i].set_freepointer((SgGotoStatement*)(globalIndex));
  109893           0 :                     globalIndex++;
  109894             :                   }
  109895             :                else
  109896             :                   {
  109897           0 :                     pointer[i].set_freepointer(NULL);
  109898             :                   }
  109899             :               }
  109900             :         }
  109901           5 :      return globalIndex;
  109902             :    }
  109903             : 
  109904             : //############################################################################
  109905             : // JH (01/14/2006)
  109906             : void
  109907           5 : SgGotoStatement::resetValidFreepointers( )
  109908             :    {
  109909           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  109910           5 :      SgGotoStatement* pointer = NULL;
  109911           5 :      std::vector < unsigned char* > :: const_iterator block;
  109912           5 :      SgGotoStatement* pointerOfLinkedList = NULL;
  109913           5 :      for ( block = SgGotoStatement::pools.begin(); block != SgGotoStatement::pools.end() ; ++block )
  109914             :         {
  109915           0 :           pointer = (SgGotoStatement*)(*block);
  109916           0 :           for (unsigned i = 0; i < SgGotoStatement::pool_size; ++i )
  109917             :              {
  109918             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  109919             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  109920             :             // memory blocks!.
  109921           0 :                if ( pointer[i].get_freepointer() != NULL )
  109922             :                   {
  109923           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  109924             :                   }
  109925             :                else
  109926             :                   {
  109927           0 :                     if ( pointerOfLinkedList == NULL )
  109928             :                        {
  109929           0 :                          SgGotoStatement::next_node = &(pointer[i]);
  109930             :                        }
  109931             :                     else
  109932             :                        {
  109933             :                       // printf ("In SgGotoStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  109934           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  109935             :                        }
  109936             :                     pointerOfLinkedList = &(pointer[i]);
  109937             :                   }
  109938             :               }
  109939             :         }
  109940             : 
  109941           5 :      if ( pointerOfLinkedList != NULL )
  109942             :         {
  109943             :        // printf ("In SgGotoStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  109944           0 :           pointerOfLinkedList->set_freepointer(NULL);
  109945             :        // DQ (6/6/2010): Temporary debugging...
  109946             :        //   ROSE_ASSERT(false);
  109947             :         }
  109948             : 
  109949           5 :      return ;
  109950             :    }
  109951             : 
  109952             : //############################################################################
  109953             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  109954             :  * within the memory pool and resets the freepointers, in order to achieve a 
  109955             :  * linked list, that has no jumps and starts at the beginning! This function 
  109956             :  * does not extend the memory pool, since we do not delete any memory blocks,
  109957             :  * but delete the valid objects.  
  109958             :  */
  109959             : void
  109960           0 : SgGotoStatement::clearMemoryPool( )
  109961             :    {
  109962             :   // printf ("Inside of SgGotoStatement::clearMemoryPool() \n");
  109963             : 
  109964           0 :      SgGotoStatement* pointer = NULL, *tempPointer = NULL;
  109965           0 :      std::vector < unsigned char* > :: const_iterator block;
  109966           0 :      if ( SgGotoStatement::pools.empty() == false )
  109967             :         {
  109968           0 :           block = SgGotoStatement::pools.begin() ;
  109969           0 :           SgGotoStatement::next_node = (SgGotoStatement*) (*block);
  109970             : 
  109971           0 :           while ( block != SgGotoStatement::pools.end() )
  109972             :              {
  109973           0 :                pointer = (SgGotoStatement*) (*block);
  109974           0 :                if ( tempPointer != NULL )
  109975             :                   {
  109976           0 :                     tempPointer->set_freepointer(pointer);
  109977             :                   }
  109978           0 :                for (unsigned i = 0; i < SgGotoStatement::pool_size - 1; ++i)
  109979             :                   {
  109980           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  109981             :                   }
  109982           0 :                 pointer[SgGotoStatement::pool_size-1].set_freepointer(NULL);
  109983           0 :                 tempPointer = &(pointer[SgGotoStatement::pool_size-1]);
  109984           0 :                 ++block;
  109985             :              }
  109986             :         }
  109987           0 :    }
  109988             : 
  109989           5 : void SgGotoStatement::deleteMemoryPool() {
  109990           5 :   for (auto p: SgGotoStatement::pools) {
  109991           0 :     ROSE_FREE(p);
  109992             :   }
  109993           5 :   SgGotoStatement::next_node = nullptr;
  109994           5 :   SgGotoStatement::pools.clear();
  109995           5 : }
  109996             : 
  109997             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  109998             : //                 reading multiple binary files to for a single AST.
  109999             : /////////// new version ////////////////////////////////
  110000             : //############################################################################
  110001             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  110002             : void
  110003           2 : SgGotoStatement::extendMemoryPoolForFileIO( )
  110004             :   {
  110005           2 :     size_t blockIndex = SgGotoStatement::pools.size();
  110006           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGotoStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGotoStatement);
  110007             : 
  110008           2 :     while ( (blockIndex * SgGotoStatement::pool_size) < newPoolSize)
  110009             :       {
  110010             : #if ROSE_ALLOC_TRACE
  110011             :         if (blockIndex > 0) {
  110012             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGotoStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGotoStatement) = %" PRIuPTR " SgGotoStatement::pool_size = %d \n",
  110013             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGotoStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGotoStatement),SgGotoStatement::pool_size);
  110014             :         }
  110015             : #endif
  110016             : 
  110017           0 :         SgGotoStatement * pointer = (SgGotoStatement*) ROSE_MALLOC ( SgGotoStatement::pool_size * sizeof(SgGotoStatement) );
  110018           0 :         assert( pointer != NULL );
  110019             : #if ROSE_ALLOC_MEMSET == 1
  110020             :         memset(pointer, 0x00, SgGotoStatement::pool_size * sizeof(SgGotoStatement));
  110021             : #elif ROSE_ALLOC_MEMSET == 2
  110022             :         memset(pointer, 0xCC, SgGotoStatement::pool_size * sizeof(SgGotoStatement));
  110023             : #endif
  110024           0 :         SgGotoStatement::pools.push_back( (unsigned char*)(pointer) );
  110025           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGotoStatement::pool_size * sizeof(SgGotoStatement), V_SgGotoStatement ) );
  110026             : 
  110027           0 :         if ( SgGotoStatement::next_node != NULL ) {
  110028           0 :           if ( blockIndex > 0 ) {
  110029           0 :             SgGotoStatement * blkptr = (SgGotoStatement*)(SgGotoStatement::pools[blockIndex-1]);
  110030           0 :             blkptr[ SgGotoStatement::pool_size - 1 ].set_freepointer(pointer);
  110031             :           }
  110032             :         } else {
  110033           0 :           SgGotoStatement::next_node = pointer;
  110034             :         }
  110035             : 
  110036           0 :         for (unsigned i = 0; i < SgGotoStatement::pool_size-1; ++i)
  110037             :            {
  110038           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  110039             :            }
  110040           0 :         pointer[ SgGotoStatement::pool_size -1 ].set_freepointer(NULL);
  110041             : 
  110042           0 :         blockIndex++;
  110043             :       }
  110044           2 :   }
  110045             : 
  110046             : //############################################################################
  110047             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  110048             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  110049             :  * not compressed. However, that stuff is not yet implemented! 
  110050             :  */
  110051             : unsigned long
  110052           0 : SgGotoStatement::getNumberOfLastValidPointer()
  110053             :    {
  110054           0 :       SgGotoStatement* testPointer = (SgGotoStatement*)(SgGotoStatement::pools.back());
  110055           0 :       unsigned long localIndex = SgGotoStatement::pool_size - 1;
  110056           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  110057             :          {
  110058           0 :            localIndex--;
  110059             :          }
  110060           0 :       return (localIndex + SgGotoStatement::pool_size * (SgGotoStatement::pools.size()-1));
  110061             :    }
  110062             : 
  110063             : //############################################################################
  110064             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  110065             :  * memory pool and initializes the data member in class SgGotoStatementStroageClass
  110066             :  * from its counterpart of SgGotoStatement. The return value is just for checking, 
  110067             :  * that the whole StorageClassArray is initialized!
  110068             :  */
  110069             : unsigned long
  110070           0 : SgGotoStatement::initializeStorageClassArray( SgGotoStatementStorageClass *storageArray )
  110071             :    {
  110072           0 :      unsigned long storageCounter = 0;
  110073           0 :      std::vector < unsigned char* > :: const_iterator block = SgGotoStatement::pools.begin();
  110074           0 :      SgGotoStatement* pointer = NULL;
  110075           0 :      while ( block != SgGotoStatement::pools.end() ) {
  110076           0 :           pointer = (SgGotoStatement*) (*block);
  110077           0 :           for ( unsigned i = 0; i < SgGotoStatement::pool_size; ++i ) {
  110078           0 :                if ( pointer->get_freepointer() != NULL ) {
  110079           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  110080           0 :                  storageArray++;
  110081           0 :                  storageCounter++;
  110082             :                }
  110083           0 :                pointer++;
  110084             :              }
  110085           0 :            block++;
  110086             :         }
  110087           0 :      return storageCounter;
  110088             :    }
  110089             : 
  110090             : /* #line 110091 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  110091             : 
  110092             : 
  110093             : 
  110094             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  110095             : 
  110096             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  110097             : 
  110098             : //############################################################################
  110099             : /* JH (02/02/2006) Constructor of the IR node SgSpawnStmt that takes its 
  110100             :  * corresponding StorageClass as parameter
  110101             :  */
  110102           0 : SgSpawnStmt :: SgSpawnStmt ( const SgSpawnStmtStorageClass& storageSource )   : SgStatement (storageSource)
  110103             :    {
  110104             : 
  110105             : 
  110106             : /* #line 110107 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  110107             : 
  110108           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  110109           0 :      p_the_func =  (SgFunctionCallExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_the_func) );
  110110             : 
  110111             : 
  110112             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  110113             : 
  110114             : 
  110115           0 :    }
  110116             : 
  110117             : //############################################################################
  110118             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  110119             :  * within the working AST. 
  110120             :  */
  110121           0 : SgSpawnStmt * SgSpawnStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  110122           0 :      SgSpawnStmt* returnPointer = NULL;
  110123           0 :      if ( globalIndex != 0 )
  110124             :         {
  110125             : 
  110126             : #if FILE_IO_EXTRA_CHECK
  110127           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSpawnStmt ) ) <= globalIndex ) ;
  110128           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSpawnStmt + 1 ) ) );
  110129             : #endif
  110130           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSpawnStmt )  
  110131           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSpawnStmt );
  110132           0 :           unsigned long positionInPool = localIndex % SgSpawnStmt::pool_size;
  110133           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSpawnStmt::pool_size;
  110134             : 
  110135             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  110136             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  110137             : 
  110138           0 :           returnPointer = &( ( (SgSpawnStmt*)(SgSpawnStmt::pools[memoryBlock]) ) [positionInPool]) ;
  110139             : 
  110140           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  110141             :         }
  110142           0 :      return returnPointer ;
  110143             :    }
  110144             : 
  110145             : //############################################################################
  110146             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  110147             :   for the AST with the index astIndex
  110148             : */
  110149           0 : SgSpawnStmt * SgSpawnStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  110150           0 :      SgSpawnStmt* returnPointer = NULL;
  110151           0 :      if ( globalIndex != 0 )
  110152             :         {
  110153             : 
  110154             : #if FILE_IO_EXTRA_CHECK
  110155           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSpawnStmt ) ) <= globalIndex ) ;
  110156           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSpawnStmt + 1 ) ) );
  110157             : #endif
  110158           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSpawnStmt )
  110159           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSpawnStmt );
  110160           0 :           unsigned long positionInPool = localIndex % SgSpawnStmt::pool_size ;
  110161           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSpawnStmt::pool_size ;
  110162             : 
  110163             : #if FILE_IO_EXTRA_CHECK
  110164             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  110165             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  110166             : #endif
  110167             : 
  110168           0 :           returnPointer = &( ( (SgSpawnStmt*)(SgSpawnStmt::pools[memoryBlock]) ) [positionInPool]) ;
  110169             : 
  110170             : #if FILE_IO_EXTRA_CHECK
  110171           0 :           assert ( returnPointer != NULL ) ;
  110172             : #endif
  110173             :         }
  110174           0 :      return returnPointer ;
  110175             :    }
  110176             : 
  110177             : //############################################################################
  110178             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  110179             :  * pool size! We set for every valid object in the memory pool the freepointer
  110180             :  * to the global index and increase the global index afterwards. For all the 
  110181             :  * invalid objects (means address ranges within the memory pool that were not
  110182             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  110183             :  * distinguish valid from invalid objects! 
  110184             :  */
  110185             : unsigned long
  110186           5 : SgSpawnStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  110187             :    {
  110188           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  110189           5 :      SgSpawnStmt* pointer = NULL;
  110190           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  110191           5 :      std::vector < unsigned char* > :: const_iterator block;
  110192           5 :      for ( block = SgSpawnStmt::pools.begin(); block != SgSpawnStmt::pools.end() ; ++block )
  110193             :         {
  110194           0 :           pointer = (SgSpawnStmt*)(*block);
  110195           0 :           for (unsigned i = 0; i < SgSpawnStmt::pool_size; ++i )
  110196             :              {
  110197             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  110198             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  110199             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  110200             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  110201             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  110202             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  110203             :             // properly; so this will have to be checked next.
  110204             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  110205             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  110206           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  110207             :                   {
  110208           0 :                     pointer[i].set_freepointer((SgSpawnStmt*)(globalIndex));
  110209           0 :                     globalIndex++;
  110210             :                   }
  110211             :                else
  110212             :                   {
  110213           0 :                     pointer[i].set_freepointer(NULL);
  110214             :                   }
  110215             :               }
  110216             :         }
  110217           5 :      return globalIndex;
  110218             :    }
  110219             : 
  110220             : //############################################################################
  110221             : // JH (01/14/2006)
  110222             : void
  110223           5 : SgSpawnStmt::resetValidFreepointers( )
  110224             :    {
  110225           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  110226           5 :      SgSpawnStmt* pointer = NULL;
  110227           5 :      std::vector < unsigned char* > :: const_iterator block;
  110228           5 :      SgSpawnStmt* pointerOfLinkedList = NULL;
  110229           5 :      for ( block = SgSpawnStmt::pools.begin(); block != SgSpawnStmt::pools.end() ; ++block )
  110230             :         {
  110231           0 :           pointer = (SgSpawnStmt*)(*block);
  110232           0 :           for (unsigned i = 0; i < SgSpawnStmt::pool_size; ++i )
  110233             :              {
  110234             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  110235             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  110236             :             // memory blocks!.
  110237           0 :                if ( pointer[i].get_freepointer() != NULL )
  110238             :                   {
  110239           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  110240             :                   }
  110241             :                else
  110242             :                   {
  110243           0 :                     if ( pointerOfLinkedList == NULL )
  110244             :                        {
  110245           0 :                          SgSpawnStmt::next_node = &(pointer[i]);
  110246             :                        }
  110247             :                     else
  110248             :                        {
  110249             :                       // printf ("In SgSpawnStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  110250           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  110251             :                        }
  110252             :                     pointerOfLinkedList = &(pointer[i]);
  110253             :                   }
  110254             :               }
  110255             :         }
  110256             : 
  110257           5 :      if ( pointerOfLinkedList != NULL )
  110258             :         {
  110259             :        // printf ("In SgSpawnStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  110260           0 :           pointerOfLinkedList->set_freepointer(NULL);
  110261             :        // DQ (6/6/2010): Temporary debugging...
  110262             :        //   ROSE_ASSERT(false);
  110263             :         }
  110264             : 
  110265           5 :      return ;
  110266             :    }
  110267             : 
  110268             : //############################################################################
  110269             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  110270             :  * within the memory pool and resets the freepointers, in order to achieve a 
  110271             :  * linked list, that has no jumps and starts at the beginning! This function 
  110272             :  * does not extend the memory pool, since we do not delete any memory blocks,
  110273             :  * but delete the valid objects.  
  110274             :  */
  110275             : void
  110276           0 : SgSpawnStmt::clearMemoryPool( )
  110277             :    {
  110278             :   // printf ("Inside of SgSpawnStmt::clearMemoryPool() \n");
  110279             : 
  110280           0 :      SgSpawnStmt* pointer = NULL, *tempPointer = NULL;
  110281           0 :      std::vector < unsigned char* > :: const_iterator block;
  110282           0 :      if ( SgSpawnStmt::pools.empty() == false )
  110283             :         {
  110284           0 :           block = SgSpawnStmt::pools.begin() ;
  110285           0 :           SgSpawnStmt::next_node = (SgSpawnStmt*) (*block);
  110286             : 
  110287           0 :           while ( block != SgSpawnStmt::pools.end() )
  110288             :              {
  110289           0 :                pointer = (SgSpawnStmt*) (*block);
  110290           0 :                if ( tempPointer != NULL )
  110291             :                   {
  110292           0 :                     tempPointer->set_freepointer(pointer);
  110293             :                   }
  110294           0 :                for (unsigned i = 0; i < SgSpawnStmt::pool_size - 1; ++i)
  110295             :                   {
  110296           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  110297             :                   }
  110298           0 :                 pointer[SgSpawnStmt::pool_size-1].set_freepointer(NULL);
  110299           0 :                 tempPointer = &(pointer[SgSpawnStmt::pool_size-1]);
  110300           0 :                 ++block;
  110301             :              }
  110302             :         }
  110303           0 :    }
  110304             : 
  110305           5 : void SgSpawnStmt::deleteMemoryPool() {
  110306           5 :   for (auto p: SgSpawnStmt::pools) {
  110307           0 :     ROSE_FREE(p);
  110308             :   }
  110309           5 :   SgSpawnStmt::next_node = nullptr;
  110310           5 :   SgSpawnStmt::pools.clear();
  110311           5 : }
  110312             : 
  110313             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  110314             : //                 reading multiple binary files to for a single AST.
  110315             : /////////// new version ////////////////////////////////
  110316             : //############################################################################
  110317             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  110318             : void
  110319           2 : SgSpawnStmt::extendMemoryPoolForFileIO( )
  110320             :   {
  110321           2 :     size_t blockIndex = SgSpawnStmt::pools.size();
  110322           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSpawnStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpawnStmt);
  110323             : 
  110324           2 :     while ( (blockIndex * SgSpawnStmt::pool_size) < newPoolSize)
  110325             :       {
  110326             : #if ROSE_ALLOC_TRACE
  110327             :         if (blockIndex > 0) {
  110328             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSpawnStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpawnStmt) = %" PRIuPTR " SgSpawnStmt::pool_size = %d \n",
  110329             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSpawnStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpawnStmt),SgSpawnStmt::pool_size);
  110330             :         }
  110331             : #endif
  110332             : 
  110333           0 :         SgSpawnStmt * pointer = (SgSpawnStmt*) ROSE_MALLOC ( SgSpawnStmt::pool_size * sizeof(SgSpawnStmt) );
  110334           0 :         assert( pointer != NULL );
  110335             : #if ROSE_ALLOC_MEMSET == 1
  110336             :         memset(pointer, 0x00, SgSpawnStmt::pool_size * sizeof(SgSpawnStmt));
  110337             : #elif ROSE_ALLOC_MEMSET == 2
  110338             :         memset(pointer, 0xCC, SgSpawnStmt::pool_size * sizeof(SgSpawnStmt));
  110339             : #endif
  110340           0 :         SgSpawnStmt::pools.push_back( (unsigned char*)(pointer) );
  110341           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSpawnStmt::pool_size * sizeof(SgSpawnStmt), V_SgSpawnStmt ) );
  110342             : 
  110343           0 :         if ( SgSpawnStmt::next_node != NULL ) {
  110344           0 :           if ( blockIndex > 0 ) {
  110345           0 :             SgSpawnStmt * blkptr = (SgSpawnStmt*)(SgSpawnStmt::pools[blockIndex-1]);
  110346           0 :             blkptr[ SgSpawnStmt::pool_size - 1 ].set_freepointer(pointer);
  110347             :           }
  110348             :         } else {
  110349           0 :           SgSpawnStmt::next_node = pointer;
  110350             :         }
  110351             : 
  110352           0 :         for (unsigned i = 0; i < SgSpawnStmt::pool_size-1; ++i)
  110353             :            {
  110354           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  110355             :            }
  110356           0 :         pointer[ SgSpawnStmt::pool_size -1 ].set_freepointer(NULL);
  110357             : 
  110358           0 :         blockIndex++;
  110359             :       }
  110360           2 :   }
  110361             : 
  110362             : //############################################################################
  110363             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  110364             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  110365             :  * not compressed. However, that stuff is not yet implemented! 
  110366             :  */
  110367             : unsigned long
  110368           0 : SgSpawnStmt::getNumberOfLastValidPointer()
  110369             :    {
  110370           0 :       SgSpawnStmt* testPointer = (SgSpawnStmt*)(SgSpawnStmt::pools.back());
  110371           0 :       unsigned long localIndex = SgSpawnStmt::pool_size - 1;
  110372           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  110373             :          {
  110374           0 :            localIndex--;
  110375             :          }
  110376           0 :       return (localIndex + SgSpawnStmt::pool_size * (SgSpawnStmt::pools.size()-1));
  110377             :    }
  110378             : 
  110379             : //############################################################################
  110380             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  110381             :  * memory pool and initializes the data member in class SgSpawnStmtStroageClass
  110382             :  * from its counterpart of SgSpawnStmt. The return value is just for checking, 
  110383             :  * that the whole StorageClassArray is initialized!
  110384             :  */
  110385             : unsigned long
  110386           0 : SgSpawnStmt::initializeStorageClassArray( SgSpawnStmtStorageClass *storageArray )
  110387             :    {
  110388           0 :      unsigned long storageCounter = 0;
  110389           0 :      std::vector < unsigned char* > :: const_iterator block = SgSpawnStmt::pools.begin();
  110390           0 :      SgSpawnStmt* pointer = NULL;
  110391           0 :      while ( block != SgSpawnStmt::pools.end() ) {
  110392           0 :           pointer = (SgSpawnStmt*) (*block);
  110393           0 :           for ( unsigned i = 0; i < SgSpawnStmt::pool_size; ++i ) {
  110394           0 :                if ( pointer->get_freepointer() != NULL ) {
  110395           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  110396           0 :                  storageArray++;
  110397           0 :                  storageCounter++;
  110398             :                }
  110399           0 :                pointer++;
  110400             :              }
  110401           0 :            block++;
  110402             :         }
  110403           0 :      return storageCounter;
  110404             :    }
  110405             : 
  110406             : /* #line 110407 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  110407             : 
  110408             : 
  110409             : 
  110410             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  110411             : 
  110412             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  110413             : 
  110414             : //############################################################################
  110415             : /* JH (02/02/2006) Constructor of the IR node SgNullStatement that takes its 
  110416             :  * corresponding StorageClass as parameter
  110417             :  */
  110418          20 : SgNullStatement :: SgNullStatement ( const SgNullStatementStorageClass& storageSource )   : SgStatement (storageSource)
  110419             :    {
  110420             : 
  110421             : 
  110422             : /* #line 110423 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  110423             : 
  110424          20 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  110425             : 
  110426             : 
  110427             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  110428             : 
  110429             : 
  110430          20 :    }
  110431             : 
  110432             : //############################################################################
  110433             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  110434             :  * within the working AST. 
  110435             :  */
  110436          60 : SgNullStatement * SgNullStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  110437          60 :      SgNullStatement* returnPointer = NULL;
  110438          60 :      if ( globalIndex != 0 )
  110439             :         {
  110440             : 
  110441             : #if FILE_IO_EXTRA_CHECK
  110442          60 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNullStatement ) ) <= globalIndex ) ;
  110443          60 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNullStatement + 1 ) ) );
  110444             : #endif
  110445          60 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNullStatement )  
  110446          60 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNullStatement );
  110447          60 :           unsigned long positionInPool = localIndex % SgNullStatement::pool_size;
  110448          60 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNullStatement::pool_size;
  110449             : 
  110450             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  110451             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  110452             : 
  110453          60 :           returnPointer = &( ( (SgNullStatement*)(SgNullStatement::pools[memoryBlock]) ) [positionInPool]) ;
  110454             : 
  110455          60 :           ROSE_ASSERT( returnPointer != NULL ) ;
  110456             :         }
  110457          60 :      return returnPointer ;
  110458             :    }
  110459             : 
  110460             : //############################################################################
  110461             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  110462             :   for the AST with the index astIndex
  110463             : */
  110464           0 : SgNullStatement * SgNullStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  110465           0 :      SgNullStatement* returnPointer = NULL;
  110466           0 :      if ( globalIndex != 0 )
  110467             :         {
  110468             : 
  110469             : #if FILE_IO_EXTRA_CHECK
  110470           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNullStatement ) ) <= globalIndex ) ;
  110471           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNullStatement + 1 ) ) );
  110472             : #endif
  110473           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNullStatement )
  110474           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNullStatement );
  110475           0 :           unsigned long positionInPool = localIndex % SgNullStatement::pool_size ;
  110476           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNullStatement::pool_size ;
  110477             : 
  110478             : #if FILE_IO_EXTRA_CHECK
  110479             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  110480             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  110481             : #endif
  110482             : 
  110483           0 :           returnPointer = &( ( (SgNullStatement*)(SgNullStatement::pools[memoryBlock]) ) [positionInPool]) ;
  110484             : 
  110485             : #if FILE_IO_EXTRA_CHECK
  110486           0 :           assert ( returnPointer != NULL ) ;
  110487             : #endif
  110488             :         }
  110489           0 :      return returnPointer ;
  110490             :    }
  110491             : 
  110492             : //############################################################################
  110493             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  110494             :  * pool size! We set for every valid object in the memory pool the freepointer
  110495             :  * to the global index and increase the global index afterwards. For all the 
  110496             :  * invalid objects (means address ranges within the memory pool that were not
  110497             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  110498             :  * distinguish valid from invalid objects! 
  110499             :  */
  110500             : unsigned long
  110501           5 : SgNullStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  110502             :    {
  110503           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  110504           5 :      SgNullStatement* pointer = NULL;
  110505           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  110506           5 :      std::vector < unsigned char* > :: const_iterator block;
  110507           6 :      for ( block = SgNullStatement::pools.begin(); block != SgNullStatement::pools.end() ; ++block )
  110508             :         {
  110509           1 :           pointer = (SgNullStatement*)(*block);
  110510        2001 :           for (unsigned i = 0; i < SgNullStatement::pool_size; ++i )
  110511             :              {
  110512             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  110513             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  110514             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  110515             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  110516             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  110517             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  110518             :             // properly; so this will have to be checked next.
  110519             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  110520             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  110521        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  110522             :                   {
  110523          20 :                     pointer[i].set_freepointer((SgNullStatement*)(globalIndex));
  110524          20 :                     globalIndex++;
  110525             :                   }
  110526             :                else
  110527             :                   {
  110528        1980 :                     pointer[i].set_freepointer(NULL);
  110529             :                   }
  110530             :               }
  110531             :         }
  110532           5 :      return globalIndex;
  110533             :    }
  110534             : 
  110535             : //############################################################################
  110536             : // JH (01/14/2006)
  110537             : void
  110538           5 : SgNullStatement::resetValidFreepointers( )
  110539             :    {
  110540           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  110541           5 :      SgNullStatement* pointer = NULL;
  110542           5 :      std::vector < unsigned char* > :: const_iterator block;
  110543           5 :      SgNullStatement* pointerOfLinkedList = NULL;
  110544           6 :      for ( block = SgNullStatement::pools.begin(); block != SgNullStatement::pools.end() ; ++block )
  110545             :         {
  110546           1 :           pointer = (SgNullStatement*)(*block);
  110547        2001 :           for (unsigned i = 0; i < SgNullStatement::pool_size; ++i )
  110548             :              {
  110549             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  110550             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  110551             :             // memory blocks!.
  110552        2000 :                if ( pointer[i].get_freepointer() != NULL )
  110553             :                   {
  110554          20 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  110555             :                   }
  110556             :                else
  110557             :                   {
  110558        1980 :                     if ( pointerOfLinkedList == NULL )
  110559             :                        {
  110560           1 :                          SgNullStatement::next_node = &(pointer[i]);
  110561             :                        }
  110562             :                     else
  110563             :                        {
  110564             :                       // printf ("In SgNullStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  110565        1979 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  110566             :                        }
  110567             :                     pointerOfLinkedList = &(pointer[i]);
  110568             :                   }
  110569             :               }
  110570             :         }
  110571             : 
  110572           5 :      if ( pointerOfLinkedList != NULL )
  110573             :         {
  110574             :        // printf ("In SgNullStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  110575           1 :           pointerOfLinkedList->set_freepointer(NULL);
  110576             :        // DQ (6/6/2010): Temporary debugging...
  110577             :        //   ROSE_ASSERT(false);
  110578             :         }
  110579             : 
  110580           5 :      return ;
  110581             :    }
  110582             : 
  110583             : //############################################################################
  110584             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  110585             :  * within the memory pool and resets the freepointers, in order to achieve a 
  110586             :  * linked list, that has no jumps and starts at the beginning! This function 
  110587             :  * does not extend the memory pool, since we do not delete any memory blocks,
  110588             :  * but delete the valid objects.  
  110589             :  */
  110590             : void
  110591           0 : SgNullStatement::clearMemoryPool( )
  110592             :    {
  110593             :   // printf ("Inside of SgNullStatement::clearMemoryPool() \n");
  110594             : 
  110595           0 :      SgNullStatement* pointer = NULL, *tempPointer = NULL;
  110596           0 :      std::vector < unsigned char* > :: const_iterator block;
  110597           0 :      if ( SgNullStatement::pools.empty() == false )
  110598             :         {
  110599           0 :           block = SgNullStatement::pools.begin() ;
  110600           0 :           SgNullStatement::next_node = (SgNullStatement*) (*block);
  110601             : 
  110602           0 :           while ( block != SgNullStatement::pools.end() )
  110603             :              {
  110604           0 :                pointer = (SgNullStatement*) (*block);
  110605           0 :                if ( tempPointer != NULL )
  110606             :                   {
  110607           0 :                     tempPointer->set_freepointer(pointer);
  110608             :                   }
  110609           0 :                for (unsigned i = 0; i < SgNullStatement::pool_size - 1; ++i)
  110610             :                   {
  110611           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  110612             :                   }
  110613           0 :                 pointer[SgNullStatement::pool_size-1].set_freepointer(NULL);
  110614           0 :                 tempPointer = &(pointer[SgNullStatement::pool_size-1]);
  110615           0 :                 ++block;
  110616             :              }
  110617             :         }
  110618           0 :    }
  110619             : 
  110620           5 : void SgNullStatement::deleteMemoryPool() {
  110621           7 :   for (auto p: SgNullStatement::pools) {
  110622           2 :     ROSE_FREE(p);
  110623             :   }
  110624           5 :   SgNullStatement::next_node = nullptr;
  110625           5 :   SgNullStatement::pools.clear();
  110626           5 : }
  110627             : 
  110628             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  110629             : //                 reading multiple binary files to for a single AST.
  110630             : /////////// new version ////////////////////////////////
  110631             : //############################################################################
  110632             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  110633             : void
  110634           2 : SgNullStatement::extendMemoryPoolForFileIO( )
  110635             :   {
  110636           2 :     size_t blockIndex = SgNullStatement::pools.size();
  110637           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNullStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullStatement);
  110638             : 
  110639           3 :     while ( (blockIndex * SgNullStatement::pool_size) < newPoolSize)
  110640             :       {
  110641             : #if ROSE_ALLOC_TRACE
  110642             :         if (blockIndex > 0) {
  110643             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNullStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullStatement) = %" PRIuPTR " SgNullStatement::pool_size = %d \n",
  110644             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNullStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullStatement),SgNullStatement::pool_size);
  110645             :         }
  110646             : #endif
  110647             : 
  110648           1 :         SgNullStatement * pointer = (SgNullStatement*) ROSE_MALLOC ( SgNullStatement::pool_size * sizeof(SgNullStatement) );
  110649           1 :         assert( pointer != NULL );
  110650             : #if ROSE_ALLOC_MEMSET == 1
  110651             :         memset(pointer, 0x00, SgNullStatement::pool_size * sizeof(SgNullStatement));
  110652             : #elif ROSE_ALLOC_MEMSET == 2
  110653             :         memset(pointer, 0xCC, SgNullStatement::pool_size * sizeof(SgNullStatement));
  110654             : #endif
  110655           1 :         SgNullStatement::pools.push_back( (unsigned char*)(pointer) );
  110656           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNullStatement::pool_size * sizeof(SgNullStatement), V_SgNullStatement ) );
  110657             : 
  110658           1 :         if ( SgNullStatement::next_node != NULL ) {
  110659           0 :           if ( blockIndex > 0 ) {
  110660           0 :             SgNullStatement * blkptr = (SgNullStatement*)(SgNullStatement::pools[blockIndex-1]);
  110661           0 :             blkptr[ SgNullStatement::pool_size - 1 ].set_freepointer(pointer);
  110662             :           }
  110663             :         } else {
  110664           1 :           SgNullStatement::next_node = pointer;
  110665             :         }
  110666             : 
  110667        2000 :         for (unsigned i = 0; i < SgNullStatement::pool_size-1; ++i)
  110668             :            {
  110669        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  110670             :            }
  110671           1 :         pointer[ SgNullStatement::pool_size -1 ].set_freepointer(NULL);
  110672             : 
  110673           1 :         blockIndex++;
  110674             :       }
  110675           2 :   }
  110676             : 
  110677             : //############################################################################
  110678             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  110679             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  110680             :  * not compressed. However, that stuff is not yet implemented! 
  110681             :  */
  110682             : unsigned long
  110683           0 : SgNullStatement::getNumberOfLastValidPointer()
  110684             :    {
  110685           0 :       SgNullStatement* testPointer = (SgNullStatement*)(SgNullStatement::pools.back());
  110686           0 :       unsigned long localIndex = SgNullStatement::pool_size - 1;
  110687           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  110688             :          {
  110689           0 :            localIndex--;
  110690             :          }
  110691           0 :       return (localIndex + SgNullStatement::pool_size * (SgNullStatement::pools.size()-1));
  110692             :    }
  110693             : 
  110694             : //############################################################################
  110695             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  110696             :  * memory pool and initializes the data member in class SgNullStatementStroageClass
  110697             :  * from its counterpart of SgNullStatement. The return value is just for checking, 
  110698             :  * that the whole StorageClassArray is initialized!
  110699             :  */
  110700             : unsigned long
  110701           1 : SgNullStatement::initializeStorageClassArray( SgNullStatementStorageClass *storageArray )
  110702             :    {
  110703           1 :      unsigned long storageCounter = 0;
  110704           1 :      std::vector < unsigned char* > :: const_iterator block = SgNullStatement::pools.begin();
  110705           1 :      SgNullStatement* pointer = NULL;
  110706           2 :      while ( block != SgNullStatement::pools.end() ) {
  110707           1 :           pointer = (SgNullStatement*) (*block);
  110708        2001 :           for ( unsigned i = 0; i < SgNullStatement::pool_size; ++i ) {
  110709        2000 :                if ( pointer->get_freepointer() != NULL ) {
  110710          20 :                  storageArray->pickOutIRNodeData (pointer) ;
  110711          20 :                  storageArray++;
  110712          20 :                  storageCounter++;
  110713             :                }
  110714        2000 :                pointer++;
  110715             :              }
  110716           1 :            block++;
  110717             :         }
  110718           1 :      return storageCounter;
  110719             :    }
  110720             : 
  110721             : /* #line 110722 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  110722             : 
  110723             : 
  110724             : 
  110725             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  110726             : 
  110727             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  110728             : 
  110729             : //############################################################################
  110730             : /* JH (02/02/2006) Constructor of the IR node SgVariantStatement that takes its 
  110731             :  * corresponding StorageClass as parameter
  110732             :  */
  110733           0 : SgVariantStatement :: SgVariantStatement ( const SgVariantStatementStorageClass& storageSource )   : SgStatement (storageSource)
  110734             :    {
  110735             : 
  110736             : 
  110737             : /* #line 110738 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  110738             : 
  110739           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  110740             : 
  110741             : 
  110742             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  110743             : 
  110744             : 
  110745           0 :    }
  110746             : 
  110747             : //############################################################################
  110748             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  110749             :  * within the working AST. 
  110750             :  */
  110751           0 : SgVariantStatement * SgVariantStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  110752           0 :      SgVariantStatement* returnPointer = NULL;
  110753           0 :      if ( globalIndex != 0 )
  110754             :         {
  110755             : 
  110756             : #if FILE_IO_EXTRA_CHECK
  110757           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVariantStatement ) ) <= globalIndex ) ;
  110758           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariantStatement + 1 ) ) );
  110759             : #endif
  110760           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariantStatement )  
  110761           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVariantStatement );
  110762           0 :           unsigned long positionInPool = localIndex % SgVariantStatement::pool_size;
  110763           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariantStatement::pool_size;
  110764             : 
  110765             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  110766             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  110767             : 
  110768           0 :           returnPointer = &( ( (SgVariantStatement*)(SgVariantStatement::pools[memoryBlock]) ) [positionInPool]) ;
  110769             : 
  110770           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  110771             :         }
  110772           0 :      return returnPointer ;
  110773             :    }
  110774             : 
  110775             : //############################################################################
  110776             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  110777             :   for the AST with the index astIndex
  110778             : */
  110779           0 : SgVariantStatement * SgVariantStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  110780           0 :      SgVariantStatement* returnPointer = NULL;
  110781           0 :      if ( globalIndex != 0 )
  110782             :         {
  110783             : 
  110784             : #if FILE_IO_EXTRA_CHECK
  110785           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVariantStatement ) ) <= globalIndex ) ;
  110786           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariantStatement + 1 ) ) );
  110787             : #endif
  110788           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariantStatement )
  110789           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVariantStatement );
  110790           0 :           unsigned long positionInPool = localIndex % SgVariantStatement::pool_size ;
  110791           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariantStatement::pool_size ;
  110792             : 
  110793             : #if FILE_IO_EXTRA_CHECK
  110794             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  110795             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  110796             : #endif
  110797             : 
  110798           0 :           returnPointer = &( ( (SgVariantStatement*)(SgVariantStatement::pools[memoryBlock]) ) [positionInPool]) ;
  110799             : 
  110800             : #if FILE_IO_EXTRA_CHECK
  110801           0 :           assert ( returnPointer != NULL ) ;
  110802             : #endif
  110803             :         }
  110804           0 :      return returnPointer ;
  110805             :    }
  110806             : 
  110807             : //############################################################################
  110808             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  110809             :  * pool size! We set for every valid object in the memory pool the freepointer
  110810             :  * to the global index and increase the global index afterwards. For all the 
  110811             :  * invalid objects (means address ranges within the memory pool that were not
  110812             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  110813             :  * distinguish valid from invalid objects! 
  110814             :  */
  110815             : unsigned long
  110816           5 : SgVariantStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  110817             :    {
  110818           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  110819           5 :      SgVariantStatement* pointer = NULL;
  110820           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  110821           5 :      std::vector < unsigned char* > :: const_iterator block;
  110822           5 :      for ( block = SgVariantStatement::pools.begin(); block != SgVariantStatement::pools.end() ; ++block )
  110823             :         {
  110824           0 :           pointer = (SgVariantStatement*)(*block);
  110825           0 :           for (unsigned i = 0; i < SgVariantStatement::pool_size; ++i )
  110826             :              {
  110827             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  110828             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  110829             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  110830             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  110831             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  110832             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  110833             :             // properly; so this will have to be checked next.
  110834             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  110835             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  110836           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  110837             :                   {
  110838           0 :                     pointer[i].set_freepointer((SgVariantStatement*)(globalIndex));
  110839           0 :                     globalIndex++;
  110840             :                   }
  110841             :                else
  110842             :                   {
  110843           0 :                     pointer[i].set_freepointer(NULL);
  110844             :                   }
  110845             :               }
  110846             :         }
  110847           5 :      return globalIndex;
  110848             :    }
  110849             : 
  110850             : //############################################################################
  110851             : // JH (01/14/2006)
  110852             : void
  110853           5 : SgVariantStatement::resetValidFreepointers( )
  110854             :    {
  110855           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  110856           5 :      SgVariantStatement* pointer = NULL;
  110857           5 :      std::vector < unsigned char* > :: const_iterator block;
  110858           5 :      SgVariantStatement* pointerOfLinkedList = NULL;
  110859           5 :      for ( block = SgVariantStatement::pools.begin(); block != SgVariantStatement::pools.end() ; ++block )
  110860             :         {
  110861           0 :           pointer = (SgVariantStatement*)(*block);
  110862           0 :           for (unsigned i = 0; i < SgVariantStatement::pool_size; ++i )
  110863             :              {
  110864             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  110865             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  110866             :             // memory blocks!.
  110867           0 :                if ( pointer[i].get_freepointer() != NULL )
  110868             :                   {
  110869           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  110870             :                   }
  110871             :                else
  110872             :                   {
  110873           0 :                     if ( pointerOfLinkedList == NULL )
  110874             :                        {
  110875           0 :                          SgVariantStatement::next_node = &(pointer[i]);
  110876             :                        }
  110877             :                     else
  110878             :                        {
  110879             :                       // printf ("In SgVariantStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  110880           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  110881             :                        }
  110882             :                     pointerOfLinkedList = &(pointer[i]);
  110883             :                   }
  110884             :               }
  110885             :         }
  110886             : 
  110887           5 :      if ( pointerOfLinkedList != NULL )
  110888             :         {
  110889             :        // printf ("In SgVariantStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  110890           0 :           pointerOfLinkedList->set_freepointer(NULL);
  110891             :        // DQ (6/6/2010): Temporary debugging...
  110892             :        //   ROSE_ASSERT(false);
  110893             :         }
  110894             : 
  110895           5 :      return ;
  110896             :    }
  110897             : 
  110898             : //############################################################################
  110899             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  110900             :  * within the memory pool and resets the freepointers, in order to achieve a 
  110901             :  * linked list, that has no jumps and starts at the beginning! This function 
  110902             :  * does not extend the memory pool, since we do not delete any memory blocks,
  110903             :  * but delete the valid objects.  
  110904             :  */
  110905             : void
  110906           0 : SgVariantStatement::clearMemoryPool( )
  110907             :    {
  110908             :   // printf ("Inside of SgVariantStatement::clearMemoryPool() \n");
  110909             : 
  110910           0 :      SgVariantStatement* pointer = NULL, *tempPointer = NULL;
  110911           0 :      std::vector < unsigned char* > :: const_iterator block;
  110912           0 :      if ( SgVariantStatement::pools.empty() == false )
  110913             :         {
  110914           0 :           block = SgVariantStatement::pools.begin() ;
  110915           0 :           SgVariantStatement::next_node = (SgVariantStatement*) (*block);
  110916             : 
  110917           0 :           while ( block != SgVariantStatement::pools.end() )
  110918             :              {
  110919           0 :                pointer = (SgVariantStatement*) (*block);
  110920           0 :                if ( tempPointer != NULL )
  110921             :                   {
  110922           0 :                     tempPointer->set_freepointer(pointer);
  110923             :                   }
  110924           0 :                for (unsigned i = 0; i < SgVariantStatement::pool_size - 1; ++i)
  110925             :                   {
  110926           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  110927             :                   }
  110928           0 :                 pointer[SgVariantStatement::pool_size-1].set_freepointer(NULL);
  110929           0 :                 tempPointer = &(pointer[SgVariantStatement::pool_size-1]);
  110930           0 :                 ++block;
  110931             :              }
  110932             :         }
  110933           0 :    }
  110934             : 
  110935           5 : void SgVariantStatement::deleteMemoryPool() {
  110936           5 :   for (auto p: SgVariantStatement::pools) {
  110937           0 :     ROSE_FREE(p);
  110938             :   }
  110939           5 :   SgVariantStatement::next_node = nullptr;
  110940           5 :   SgVariantStatement::pools.clear();
  110941           5 : }
  110942             : 
  110943             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  110944             : //                 reading multiple binary files to for a single AST.
  110945             : /////////// new version ////////////////////////////////
  110946             : //############################################################################
  110947             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  110948             : void
  110949           2 : SgVariantStatement::extendMemoryPoolForFileIO( )
  110950             :   {
  110951           2 :     size_t blockIndex = SgVariantStatement::pools.size();
  110952           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVariantStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariantStatement);
  110953             : 
  110954           2 :     while ( (blockIndex * SgVariantStatement::pool_size) < newPoolSize)
  110955             :       {
  110956             : #if ROSE_ALLOC_TRACE
  110957             :         if (blockIndex > 0) {
  110958             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVariantStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariantStatement) = %" PRIuPTR " SgVariantStatement::pool_size = %d \n",
  110959             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVariantStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariantStatement),SgVariantStatement::pool_size);
  110960             :         }
  110961             : #endif
  110962             : 
  110963           0 :         SgVariantStatement * pointer = (SgVariantStatement*) ROSE_MALLOC ( SgVariantStatement::pool_size * sizeof(SgVariantStatement) );
  110964           0 :         assert( pointer != NULL );
  110965             : #if ROSE_ALLOC_MEMSET == 1
  110966             :         memset(pointer, 0x00, SgVariantStatement::pool_size * sizeof(SgVariantStatement));
  110967             : #elif ROSE_ALLOC_MEMSET == 2
  110968             :         memset(pointer, 0xCC, SgVariantStatement::pool_size * sizeof(SgVariantStatement));
  110969             : #endif
  110970           0 :         SgVariantStatement::pools.push_back( (unsigned char*)(pointer) );
  110971           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVariantStatement::pool_size * sizeof(SgVariantStatement), V_SgVariantStatement ) );
  110972             : 
  110973           0 :         if ( SgVariantStatement::next_node != NULL ) {
  110974           0 :           if ( blockIndex > 0 ) {
  110975           0 :             SgVariantStatement * blkptr = (SgVariantStatement*)(SgVariantStatement::pools[blockIndex-1]);
  110976           0 :             blkptr[ SgVariantStatement::pool_size - 1 ].set_freepointer(pointer);
  110977             :           }
  110978             :         } else {
  110979           0 :           SgVariantStatement::next_node = pointer;
  110980             :         }
  110981             : 
  110982           0 :         for (unsigned i = 0; i < SgVariantStatement::pool_size-1; ++i)
  110983             :            {
  110984           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  110985             :            }
  110986           0 :         pointer[ SgVariantStatement::pool_size -1 ].set_freepointer(NULL);
  110987             : 
  110988           0 :         blockIndex++;
  110989             :       }
  110990           2 :   }
  110991             : 
  110992             : //############################################################################
  110993             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  110994             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  110995             :  * not compressed. However, that stuff is not yet implemented! 
  110996             :  */
  110997             : unsigned long
  110998           0 : SgVariantStatement::getNumberOfLastValidPointer()
  110999             :    {
  111000           0 :       SgVariantStatement* testPointer = (SgVariantStatement*)(SgVariantStatement::pools.back());
  111001           0 :       unsigned long localIndex = SgVariantStatement::pool_size - 1;
  111002           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  111003             :          {
  111004           0 :            localIndex--;
  111005             :          }
  111006           0 :       return (localIndex + SgVariantStatement::pool_size * (SgVariantStatement::pools.size()-1));
  111007             :    }
  111008             : 
  111009             : //############################################################################
  111010             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  111011             :  * memory pool and initializes the data member in class SgVariantStatementStroageClass
  111012             :  * from its counterpart of SgVariantStatement. The return value is just for checking, 
  111013             :  * that the whole StorageClassArray is initialized!
  111014             :  */
  111015             : unsigned long
  111016           0 : SgVariantStatement::initializeStorageClassArray( SgVariantStatementStorageClass *storageArray )
  111017             :    {
  111018           0 :      unsigned long storageCounter = 0;
  111019           0 :      std::vector < unsigned char* > :: const_iterator block = SgVariantStatement::pools.begin();
  111020           0 :      SgVariantStatement* pointer = NULL;
  111021           0 :      while ( block != SgVariantStatement::pools.end() ) {
  111022           0 :           pointer = (SgVariantStatement*) (*block);
  111023           0 :           for ( unsigned i = 0; i < SgVariantStatement::pool_size; ++i ) {
  111024           0 :                if ( pointer->get_freepointer() != NULL ) {
  111025           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  111026           0 :                  storageArray++;
  111027           0 :                  storageCounter++;
  111028             :                }
  111029           0 :                pointer++;
  111030             :              }
  111031           0 :            block++;
  111032             :         }
  111033           0 :      return storageCounter;
  111034             :    }
  111035             : 
  111036             : /* #line 111037 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  111037             : 
  111038             : 
  111039             : 
  111040             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  111041             : 
  111042             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  111043             : 
  111044             : //############################################################################
  111045             : /* JH (02/02/2006) Constructor of the IR node SgForInitStatement that takes its 
  111046             :  * corresponding StorageClass as parameter
  111047             :  */
  111048          40 : SgForInitStatement :: SgForInitStatement ( const SgForInitStatementStorageClass& storageSource )   : SgStatement (storageSource)
  111049             :    {
  111050             : 
  111051             : 
  111052             : /* #line 111053 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  111053             : 
  111054          40 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  111055          40 :      p_init_stmt = storageSource.storageOf_init_stmt.rebuildDataStoredInEasyStorageClass() ;
  111056          40 :      SgStatementPtrList::iterator i_init_stmt = p_init_stmt.begin() ; 
  111057          80 :      for ( ; i_init_stmt != p_init_stmt.end(); ++i_init_stmt ) 
  111058             :         {
  111059          40 :           (*i_init_stmt) = (SgStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_init_stmt) ) );
  111060             :         }
  111061             : 
  111062             : 
  111063             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  111064             : 
  111065             : 
  111066          40 :    }
  111067             : 
  111068             : //############################################################################
  111069             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  111070             :  * within the working AST. 
  111071             :  */
  111072         160 : SgForInitStatement * SgForInitStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  111073         160 :      SgForInitStatement* returnPointer = NULL;
  111074         160 :      if ( globalIndex != 0 )
  111075             :         {
  111076             : 
  111077             : #if FILE_IO_EXTRA_CHECK
  111078         160 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgForInitStatement ) ) <= globalIndex ) ;
  111079         160 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgForInitStatement + 1 ) ) );
  111080             : #endif
  111081         160 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgForInitStatement )  
  111082         160 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgForInitStatement );
  111083         160 :           unsigned long positionInPool = localIndex % SgForInitStatement::pool_size;
  111084         160 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgForInitStatement::pool_size;
  111085             : 
  111086             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  111087             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  111088             : 
  111089         160 :           returnPointer = &( ( (SgForInitStatement*)(SgForInitStatement::pools[memoryBlock]) ) [positionInPool]) ;
  111090             : 
  111091         160 :           ROSE_ASSERT( returnPointer != NULL ) ;
  111092             :         }
  111093         160 :      return returnPointer ;
  111094             :    }
  111095             : 
  111096             : //############################################################################
  111097             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  111098             :   for the AST with the index astIndex
  111099             : */
  111100           0 : SgForInitStatement * SgForInitStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  111101           0 :      SgForInitStatement* returnPointer = NULL;
  111102           0 :      if ( globalIndex != 0 )
  111103             :         {
  111104             : 
  111105             : #if FILE_IO_EXTRA_CHECK
  111106           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgForInitStatement ) ) <= globalIndex ) ;
  111107           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgForInitStatement + 1 ) ) );
  111108             : #endif
  111109           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgForInitStatement )
  111110           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgForInitStatement );
  111111           0 :           unsigned long positionInPool = localIndex % SgForInitStatement::pool_size ;
  111112           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgForInitStatement::pool_size ;
  111113             : 
  111114             : #if FILE_IO_EXTRA_CHECK
  111115             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  111116             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  111117             : #endif
  111118             : 
  111119           0 :           returnPointer = &( ( (SgForInitStatement*)(SgForInitStatement::pools[memoryBlock]) ) [positionInPool]) ;
  111120             : 
  111121             : #if FILE_IO_EXTRA_CHECK
  111122           0 :           assert ( returnPointer != NULL ) ;
  111123             : #endif
  111124             :         }
  111125           0 :      return returnPointer ;
  111126             :    }
  111127             : 
  111128             : //############################################################################
  111129             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  111130             :  * pool size! We set for every valid object in the memory pool the freepointer
  111131             :  * to the global index and increase the global index afterwards. For all the 
  111132             :  * invalid objects (means address ranges within the memory pool that were not
  111133             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  111134             :  * distinguish valid from invalid objects! 
  111135             :  */
  111136             : unsigned long
  111137           5 : SgForInitStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  111138             :    {
  111139           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  111140           5 :      SgForInitStatement* pointer = NULL;
  111141           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  111142           5 :      std::vector < unsigned char* > :: const_iterator block;
  111143           6 :      for ( block = SgForInitStatement::pools.begin(); block != SgForInitStatement::pools.end() ; ++block )
  111144             :         {
  111145           1 :           pointer = (SgForInitStatement*)(*block);
  111146        2001 :           for (unsigned i = 0; i < SgForInitStatement::pool_size; ++i )
  111147             :              {
  111148             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  111149             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  111150             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  111151             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  111152             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  111153             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  111154             :             // properly; so this will have to be checked next.
  111155             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  111156             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  111157        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  111158             :                   {
  111159          40 :                     pointer[i].set_freepointer((SgForInitStatement*)(globalIndex));
  111160          40 :                     globalIndex++;
  111161             :                   }
  111162             :                else
  111163             :                   {
  111164        1960 :                     pointer[i].set_freepointer(NULL);
  111165             :                   }
  111166             :               }
  111167             :         }
  111168           5 :      return globalIndex;
  111169             :    }
  111170             : 
  111171             : //############################################################################
  111172             : // JH (01/14/2006)
  111173             : void
  111174           5 : SgForInitStatement::resetValidFreepointers( )
  111175             :    {
  111176           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  111177           5 :      SgForInitStatement* pointer = NULL;
  111178           5 :      std::vector < unsigned char* > :: const_iterator block;
  111179           5 :      SgForInitStatement* pointerOfLinkedList = NULL;
  111180           6 :      for ( block = SgForInitStatement::pools.begin(); block != SgForInitStatement::pools.end() ; ++block )
  111181             :         {
  111182           1 :           pointer = (SgForInitStatement*)(*block);
  111183        2001 :           for (unsigned i = 0; i < SgForInitStatement::pool_size; ++i )
  111184             :              {
  111185             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  111186             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  111187             :             // memory blocks!.
  111188        2000 :                if ( pointer[i].get_freepointer() != NULL )
  111189             :                   {
  111190          40 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  111191             :                   }
  111192             :                else
  111193             :                   {
  111194        1960 :                     if ( pointerOfLinkedList == NULL )
  111195             :                        {
  111196           1 :                          SgForInitStatement::next_node = &(pointer[i]);
  111197             :                        }
  111198             :                     else
  111199             :                        {
  111200             :                       // printf ("In SgForInitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  111201        1959 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  111202             :                        }
  111203             :                     pointerOfLinkedList = &(pointer[i]);
  111204             :                   }
  111205             :               }
  111206             :         }
  111207             : 
  111208           5 :      if ( pointerOfLinkedList != NULL )
  111209             :         {
  111210             :        // printf ("In SgForInitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  111211           1 :           pointerOfLinkedList->set_freepointer(NULL);
  111212             :        // DQ (6/6/2010): Temporary debugging...
  111213             :        //   ROSE_ASSERT(false);
  111214             :         }
  111215             : 
  111216           5 :      return ;
  111217             :    }
  111218             : 
  111219             : //############################################################################
  111220             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  111221             :  * within the memory pool and resets the freepointers, in order to achieve a 
  111222             :  * linked list, that has no jumps and starts at the beginning! This function 
  111223             :  * does not extend the memory pool, since we do not delete any memory blocks,
  111224             :  * but delete the valid objects.  
  111225             :  */
  111226             : void
  111227           0 : SgForInitStatement::clearMemoryPool( )
  111228             :    {
  111229             :   // printf ("Inside of SgForInitStatement::clearMemoryPool() \n");
  111230             : 
  111231           0 :      SgForInitStatement* pointer = NULL, *tempPointer = NULL;
  111232           0 :      std::vector < unsigned char* > :: const_iterator block;
  111233           0 :      if ( SgForInitStatement::pools.empty() == false )
  111234             :         {
  111235           0 :           block = SgForInitStatement::pools.begin() ;
  111236           0 :           SgForInitStatement::next_node = (SgForInitStatement*) (*block);
  111237             : 
  111238           0 :           while ( block != SgForInitStatement::pools.end() )
  111239             :              {
  111240           0 :                pointer = (SgForInitStatement*) (*block);
  111241           0 :                if ( tempPointer != NULL )
  111242             :                   {
  111243           0 :                     tempPointer->set_freepointer(pointer);
  111244             :                   }
  111245           0 :                for (unsigned i = 0; i < SgForInitStatement::pool_size - 1; ++i)
  111246             :                   {
  111247           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  111248             :                   }
  111249           0 :                 pointer[SgForInitStatement::pool_size-1].set_freepointer(NULL);
  111250           0 :                 tempPointer = &(pointer[SgForInitStatement::pool_size-1]);
  111251           0 :                 ++block;
  111252             :              }
  111253             :         }
  111254           0 :    }
  111255             : 
  111256           5 : void SgForInitStatement::deleteMemoryPool() {
  111257           7 :   for (auto p: SgForInitStatement::pools) {
  111258           2 :     ROSE_FREE(p);
  111259             :   }
  111260           5 :   SgForInitStatement::next_node = nullptr;
  111261           5 :   SgForInitStatement::pools.clear();
  111262           5 : }
  111263             : 
  111264             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  111265             : //                 reading multiple binary files to for a single AST.
  111266             : /////////// new version ////////////////////////////////
  111267             : //############################################################################
  111268             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  111269             : void
  111270           2 : SgForInitStatement::extendMemoryPoolForFileIO( )
  111271             :   {
  111272           2 :     size_t blockIndex = SgForInitStatement::pools.size();
  111273           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgForInitStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgForInitStatement);
  111274             : 
  111275           3 :     while ( (blockIndex * SgForInitStatement::pool_size) < newPoolSize)
  111276             :       {
  111277             : #if ROSE_ALLOC_TRACE
  111278             :         if (blockIndex > 0) {
  111279             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgForInitStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgForInitStatement) = %" PRIuPTR " SgForInitStatement::pool_size = %d \n",
  111280             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgForInitStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgForInitStatement),SgForInitStatement::pool_size);
  111281             :         }
  111282             : #endif
  111283             : 
  111284           1 :         SgForInitStatement * pointer = (SgForInitStatement*) ROSE_MALLOC ( SgForInitStatement::pool_size * sizeof(SgForInitStatement) );
  111285           1 :         assert( pointer != NULL );
  111286             : #if ROSE_ALLOC_MEMSET == 1
  111287             :         memset(pointer, 0x00, SgForInitStatement::pool_size * sizeof(SgForInitStatement));
  111288             : #elif ROSE_ALLOC_MEMSET == 2
  111289             :         memset(pointer, 0xCC, SgForInitStatement::pool_size * sizeof(SgForInitStatement));
  111290             : #endif
  111291           1 :         SgForInitStatement::pools.push_back( (unsigned char*)(pointer) );
  111292           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgForInitStatement::pool_size * sizeof(SgForInitStatement), V_SgForInitStatement ) );
  111293             : 
  111294           1 :         if ( SgForInitStatement::next_node != NULL ) {
  111295           0 :           if ( blockIndex > 0 ) {
  111296           0 :             SgForInitStatement * blkptr = (SgForInitStatement*)(SgForInitStatement::pools[blockIndex-1]);
  111297           0 :             blkptr[ SgForInitStatement::pool_size - 1 ].set_freepointer(pointer);
  111298             :           }
  111299             :         } else {
  111300           1 :           SgForInitStatement::next_node = pointer;
  111301             :         }
  111302             : 
  111303        2000 :         for (unsigned i = 0; i < SgForInitStatement::pool_size-1; ++i)
  111304             :            {
  111305        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  111306             :            }
  111307           1 :         pointer[ SgForInitStatement::pool_size -1 ].set_freepointer(NULL);
  111308             : 
  111309           1 :         blockIndex++;
  111310             :       }
  111311           2 :   }
  111312             : 
  111313             : //############################################################################
  111314             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  111315             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  111316             :  * not compressed. However, that stuff is not yet implemented! 
  111317             :  */
  111318             : unsigned long
  111319           0 : SgForInitStatement::getNumberOfLastValidPointer()
  111320             :    {
  111321           0 :       SgForInitStatement* testPointer = (SgForInitStatement*)(SgForInitStatement::pools.back());
  111322           0 :       unsigned long localIndex = SgForInitStatement::pool_size - 1;
  111323           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  111324             :          {
  111325           0 :            localIndex--;
  111326             :          }
  111327           0 :       return (localIndex + SgForInitStatement::pool_size * (SgForInitStatement::pools.size()-1));
  111328             :    }
  111329             : 
  111330             : //############################################################################
  111331             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  111332             :  * memory pool and initializes the data member in class SgForInitStatementStroageClass
  111333             :  * from its counterpart of SgForInitStatement. The return value is just for checking, 
  111334             :  * that the whole StorageClassArray is initialized!
  111335             :  */
  111336             : unsigned long
  111337           1 : SgForInitStatement::initializeStorageClassArray( SgForInitStatementStorageClass *storageArray )
  111338             :    {
  111339           1 :      unsigned long storageCounter = 0;
  111340           1 :      std::vector < unsigned char* > :: const_iterator block = SgForInitStatement::pools.begin();
  111341           1 :      SgForInitStatement* pointer = NULL;
  111342           2 :      while ( block != SgForInitStatement::pools.end() ) {
  111343           1 :           pointer = (SgForInitStatement*) (*block);
  111344        2001 :           for ( unsigned i = 0; i < SgForInitStatement::pool_size; ++i ) {
  111345        2000 :                if ( pointer->get_freepointer() != NULL ) {
  111346          40 :                  storageArray->pickOutIRNodeData (pointer) ;
  111347          40 :                  storageArray++;
  111348          40 :                  storageCounter++;
  111349             :                }
  111350        2000 :                pointer++;
  111351             :              }
  111352           1 :            block++;
  111353             :         }
  111354           1 :      return storageCounter;
  111355             :    }
  111356             : 
  111357             : /* #line 111358 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  111358             : 
  111359             : 
  111360             : 
  111361             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  111362             : 
  111363             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  111364             : 
  111365             : //############################################################################
  111366             : /* JH (02/02/2006) Constructor of the IR node SgCatchStatementSeq that takes its 
  111367             :  * corresponding StorageClass as parameter
  111368             :  */
  111369          54 : SgCatchStatementSeq :: SgCatchStatementSeq ( const SgCatchStatementSeqStorageClass& storageSource )   : SgStatement (storageSource)
  111370             :    {
  111371             : 
  111372             : 
  111373             : /* #line 111374 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  111374             : 
  111375          54 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  111376          54 :      p_catch_statement_seq = storageSource.storageOf_catch_statement_seq.rebuildDataStoredInEasyStorageClass() ;
  111377          54 :      SgStatementPtrList::iterator i_catch_statement_seq = p_catch_statement_seq.begin() ; 
  111378         144 :      for ( ; i_catch_statement_seq != p_catch_statement_seq.end(); ++i_catch_statement_seq ) 
  111379             :         {
  111380          90 :           (*i_catch_statement_seq) = (SgStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_catch_statement_seq) ) );
  111381             :         }
  111382             : 
  111383             : 
  111384             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  111385             : 
  111386             : 
  111387          54 :    }
  111388             : 
  111389             : //############################################################################
  111390             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  111391             :  * within the working AST. 
  111392             :  */
  111393         252 : SgCatchStatementSeq * SgCatchStatementSeq::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  111394         252 :      SgCatchStatementSeq* returnPointer = NULL;
  111395         252 :      if ( globalIndex != 0 )
  111396             :         {
  111397             : 
  111398             : #if FILE_IO_EXTRA_CHECK
  111399         252 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCatchStatementSeq ) ) <= globalIndex ) ;
  111400         252 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCatchStatementSeq + 1 ) ) );
  111401             : #endif
  111402         252 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCatchStatementSeq )  
  111403         252 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCatchStatementSeq );
  111404         252 :           unsigned long positionInPool = localIndex % SgCatchStatementSeq::pool_size;
  111405         252 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCatchStatementSeq::pool_size;
  111406             : 
  111407             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  111408             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  111409             : 
  111410         252 :           returnPointer = &( ( (SgCatchStatementSeq*)(SgCatchStatementSeq::pools[memoryBlock]) ) [positionInPool]) ;
  111411             : 
  111412         252 :           ROSE_ASSERT( returnPointer != NULL ) ;
  111413             :         }
  111414         252 :      return returnPointer ;
  111415             :    }
  111416             : 
  111417             : //############################################################################
  111418             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  111419             :   for the AST with the index astIndex
  111420             : */
  111421           0 : SgCatchStatementSeq * SgCatchStatementSeq::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  111422           0 :      SgCatchStatementSeq* returnPointer = NULL;
  111423           0 :      if ( globalIndex != 0 )
  111424             :         {
  111425             : 
  111426             : #if FILE_IO_EXTRA_CHECK
  111427           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCatchStatementSeq ) ) <= globalIndex ) ;
  111428           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCatchStatementSeq + 1 ) ) );
  111429             : #endif
  111430           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCatchStatementSeq )
  111431           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCatchStatementSeq );
  111432           0 :           unsigned long positionInPool = localIndex % SgCatchStatementSeq::pool_size ;
  111433           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCatchStatementSeq::pool_size ;
  111434             : 
  111435             : #if FILE_IO_EXTRA_CHECK
  111436             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  111437             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  111438             : #endif
  111439             : 
  111440           0 :           returnPointer = &( ( (SgCatchStatementSeq*)(SgCatchStatementSeq::pools[memoryBlock]) ) [positionInPool]) ;
  111441             : 
  111442             : #if FILE_IO_EXTRA_CHECK
  111443           0 :           assert ( returnPointer != NULL ) ;
  111444             : #endif
  111445             :         }
  111446           0 :      return returnPointer ;
  111447             :    }
  111448             : 
  111449             : //############################################################################
  111450             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  111451             :  * pool size! We set for every valid object in the memory pool the freepointer
  111452             :  * to the global index and increase the global index afterwards. For all the 
  111453             :  * invalid objects (means address ranges within the memory pool that were not
  111454             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  111455             :  * distinguish valid from invalid objects! 
  111456             :  */
  111457             : unsigned long
  111458           5 : SgCatchStatementSeq::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  111459             :    {
  111460           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  111461           5 :      SgCatchStatementSeq* pointer = NULL;
  111462           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  111463           5 :      std::vector < unsigned char* > :: const_iterator block;
  111464           6 :      for ( block = SgCatchStatementSeq::pools.begin(); block != SgCatchStatementSeq::pools.end() ; ++block )
  111465             :         {
  111466           1 :           pointer = (SgCatchStatementSeq*)(*block);
  111467        2001 :           for (unsigned i = 0; i < SgCatchStatementSeq::pool_size; ++i )
  111468             :              {
  111469             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  111470             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  111471             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  111472             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  111473             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  111474             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  111475             :             // properly; so this will have to be checked next.
  111476             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  111477             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  111478        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  111479             :                   {
  111480          54 :                     pointer[i].set_freepointer((SgCatchStatementSeq*)(globalIndex));
  111481          54 :                     globalIndex++;
  111482             :                   }
  111483             :                else
  111484             :                   {
  111485        1946 :                     pointer[i].set_freepointer(NULL);
  111486             :                   }
  111487             :               }
  111488             :         }
  111489           5 :      return globalIndex;
  111490             :    }
  111491             : 
  111492             : //############################################################################
  111493             : // JH (01/14/2006)
  111494             : void
  111495           5 : SgCatchStatementSeq::resetValidFreepointers( )
  111496             :    {
  111497           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  111498           5 :      SgCatchStatementSeq* pointer = NULL;
  111499           5 :      std::vector < unsigned char* > :: const_iterator block;
  111500           5 :      SgCatchStatementSeq* pointerOfLinkedList = NULL;
  111501           6 :      for ( block = SgCatchStatementSeq::pools.begin(); block != SgCatchStatementSeq::pools.end() ; ++block )
  111502             :         {
  111503           1 :           pointer = (SgCatchStatementSeq*)(*block);
  111504        2001 :           for (unsigned i = 0; i < SgCatchStatementSeq::pool_size; ++i )
  111505             :              {
  111506             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  111507             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  111508             :             // memory blocks!.
  111509        2000 :                if ( pointer[i].get_freepointer() != NULL )
  111510             :                   {
  111511          54 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  111512             :                   }
  111513             :                else
  111514             :                   {
  111515        1946 :                     if ( pointerOfLinkedList == NULL )
  111516             :                        {
  111517           1 :                          SgCatchStatementSeq::next_node = &(pointer[i]);
  111518             :                        }
  111519             :                     else
  111520             :                        {
  111521             :                       // printf ("In SgCatchStatementSeq::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  111522        1945 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  111523             :                        }
  111524             :                     pointerOfLinkedList = &(pointer[i]);
  111525             :                   }
  111526             :               }
  111527             :         }
  111528             : 
  111529           5 :      if ( pointerOfLinkedList != NULL )
  111530             :         {
  111531             :        // printf ("In SgCatchStatementSeq::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  111532           1 :           pointerOfLinkedList->set_freepointer(NULL);
  111533             :        // DQ (6/6/2010): Temporary debugging...
  111534             :        //   ROSE_ASSERT(false);
  111535             :         }
  111536             : 
  111537           5 :      return ;
  111538             :    }
  111539             : 
  111540             : //############################################################################
  111541             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  111542             :  * within the memory pool and resets the freepointers, in order to achieve a 
  111543             :  * linked list, that has no jumps and starts at the beginning! This function 
  111544             :  * does not extend the memory pool, since we do not delete any memory blocks,
  111545             :  * but delete the valid objects.  
  111546             :  */
  111547             : void
  111548           0 : SgCatchStatementSeq::clearMemoryPool( )
  111549             :    {
  111550             :   // printf ("Inside of SgCatchStatementSeq::clearMemoryPool() \n");
  111551             : 
  111552           0 :      SgCatchStatementSeq* pointer = NULL, *tempPointer = NULL;
  111553           0 :      std::vector < unsigned char* > :: const_iterator block;
  111554           0 :      if ( SgCatchStatementSeq::pools.empty() == false )
  111555             :         {
  111556           0 :           block = SgCatchStatementSeq::pools.begin() ;
  111557           0 :           SgCatchStatementSeq::next_node = (SgCatchStatementSeq*) (*block);
  111558             : 
  111559           0 :           while ( block != SgCatchStatementSeq::pools.end() )
  111560             :              {
  111561           0 :                pointer = (SgCatchStatementSeq*) (*block);
  111562           0 :                if ( tempPointer != NULL )
  111563             :                   {
  111564           0 :                     tempPointer->set_freepointer(pointer);
  111565             :                   }
  111566           0 :                for (unsigned i = 0; i < SgCatchStatementSeq::pool_size - 1; ++i)
  111567             :                   {
  111568           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  111569             :                   }
  111570           0 :                 pointer[SgCatchStatementSeq::pool_size-1].set_freepointer(NULL);
  111571           0 :                 tempPointer = &(pointer[SgCatchStatementSeq::pool_size-1]);
  111572           0 :                 ++block;
  111573             :              }
  111574             :         }
  111575           0 :    }
  111576             : 
  111577           5 : void SgCatchStatementSeq::deleteMemoryPool() {
  111578           7 :   for (auto p: SgCatchStatementSeq::pools) {
  111579           2 :     ROSE_FREE(p);
  111580             :   }
  111581           5 :   SgCatchStatementSeq::next_node = nullptr;
  111582           5 :   SgCatchStatementSeq::pools.clear();
  111583           5 : }
  111584             : 
  111585             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  111586             : //                 reading multiple binary files to for a single AST.
  111587             : /////////// new version ////////////////////////////////
  111588             : //############################################################################
  111589             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  111590             : void
  111591           2 : SgCatchStatementSeq::extendMemoryPoolForFileIO( )
  111592             :   {
  111593           2 :     size_t blockIndex = SgCatchStatementSeq::pools.size();
  111594           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCatchStatementSeq) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCatchStatementSeq);
  111595             : 
  111596           3 :     while ( (blockIndex * SgCatchStatementSeq::pool_size) < newPoolSize)
  111597             :       {
  111598             : #if ROSE_ALLOC_TRACE
  111599             :         if (blockIndex > 0) {
  111600             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCatchStatementSeq) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCatchStatementSeq) = %" PRIuPTR " SgCatchStatementSeq::pool_size = %d \n",
  111601             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCatchStatementSeq),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCatchStatementSeq),SgCatchStatementSeq::pool_size);
  111602             :         }
  111603             : #endif
  111604             : 
  111605           1 :         SgCatchStatementSeq * pointer = (SgCatchStatementSeq*) ROSE_MALLOC ( SgCatchStatementSeq::pool_size * sizeof(SgCatchStatementSeq) );
  111606           1 :         assert( pointer != NULL );
  111607             : #if ROSE_ALLOC_MEMSET == 1
  111608             :         memset(pointer, 0x00, SgCatchStatementSeq::pool_size * sizeof(SgCatchStatementSeq));
  111609             : #elif ROSE_ALLOC_MEMSET == 2
  111610             :         memset(pointer, 0xCC, SgCatchStatementSeq::pool_size * sizeof(SgCatchStatementSeq));
  111611             : #endif
  111612           1 :         SgCatchStatementSeq::pools.push_back( (unsigned char*)(pointer) );
  111613           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCatchStatementSeq::pool_size * sizeof(SgCatchStatementSeq), V_SgCatchStatementSeq ) );
  111614             : 
  111615           1 :         if ( SgCatchStatementSeq::next_node != NULL ) {
  111616           0 :           if ( blockIndex > 0 ) {
  111617           0 :             SgCatchStatementSeq * blkptr = (SgCatchStatementSeq*)(SgCatchStatementSeq::pools[blockIndex-1]);
  111618           0 :             blkptr[ SgCatchStatementSeq::pool_size - 1 ].set_freepointer(pointer);
  111619             :           }
  111620             :         } else {
  111621           1 :           SgCatchStatementSeq::next_node = pointer;
  111622             :         }
  111623             : 
  111624        2000 :         for (unsigned i = 0; i < SgCatchStatementSeq::pool_size-1; ++i)
  111625             :            {
  111626        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  111627             :            }
  111628           1 :         pointer[ SgCatchStatementSeq::pool_size -1 ].set_freepointer(NULL);
  111629             : 
  111630           1 :         blockIndex++;
  111631             :       }
  111632           2 :   }
  111633             : 
  111634             : //############################################################################
  111635             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  111636             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  111637             :  * not compressed. However, that stuff is not yet implemented! 
  111638             :  */
  111639             : unsigned long
  111640           0 : SgCatchStatementSeq::getNumberOfLastValidPointer()
  111641             :    {
  111642           0 :       SgCatchStatementSeq* testPointer = (SgCatchStatementSeq*)(SgCatchStatementSeq::pools.back());
  111643           0 :       unsigned long localIndex = SgCatchStatementSeq::pool_size - 1;
  111644           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  111645             :          {
  111646           0 :            localIndex--;
  111647             :          }
  111648           0 :       return (localIndex + SgCatchStatementSeq::pool_size * (SgCatchStatementSeq::pools.size()-1));
  111649             :    }
  111650             : 
  111651             : //############################################################################
  111652             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  111653             :  * memory pool and initializes the data member in class SgCatchStatementSeqStroageClass
  111654             :  * from its counterpart of SgCatchStatementSeq. The return value is just for checking, 
  111655             :  * that the whole StorageClassArray is initialized!
  111656             :  */
  111657             : unsigned long
  111658           1 : SgCatchStatementSeq::initializeStorageClassArray( SgCatchStatementSeqStorageClass *storageArray )
  111659             :    {
  111660           1 :      unsigned long storageCounter = 0;
  111661           1 :      std::vector < unsigned char* > :: const_iterator block = SgCatchStatementSeq::pools.begin();
  111662           1 :      SgCatchStatementSeq* pointer = NULL;
  111663           2 :      while ( block != SgCatchStatementSeq::pools.end() ) {
  111664           1 :           pointer = (SgCatchStatementSeq*) (*block);
  111665        2001 :           for ( unsigned i = 0; i < SgCatchStatementSeq::pool_size; ++i ) {
  111666        2000 :                if ( pointer->get_freepointer() != NULL ) {
  111667          54 :                  storageArray->pickOutIRNodeData (pointer) ;
  111668          54 :                  storageArray++;
  111669          54 :                  storageCounter++;
  111670             :                }
  111671        2000 :                pointer++;
  111672             :              }
  111673           1 :            block++;
  111674             :         }
  111675           1 :      return storageCounter;
  111676             :    }
  111677             : 
  111678             : /* #line 111679 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  111679             : 
  111680             : 
  111681             : 
  111682             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  111683             : 
  111684             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  111685             : 
  111686             : //############################################################################
  111687             : /* JH (02/02/2006) Constructor of the IR node SgProcessControlStatement that takes its 
  111688             :  * corresponding StorageClass as parameter
  111689             :  */
  111690           0 : SgProcessControlStatement :: SgProcessControlStatement ( const SgProcessControlStatementStorageClass& storageSource )   : SgStatement (storageSource)
  111691             :    {
  111692             : 
  111693             : 
  111694             : /* #line 111695 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  111695             : 
  111696           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  111697           0 :      p_control_kind = storageSource.storageOf_control_kind ;
  111698           0 :      p_code =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_code) );
  111699           0 :      p_quiet =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_quiet) );
  111700             : 
  111701             : 
  111702             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  111703             : 
  111704             : 
  111705           0 :    }
  111706             : 
  111707             : //############################################################################
  111708             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  111709             :  * within the working AST. 
  111710             :  */
  111711           0 : SgProcessControlStatement * SgProcessControlStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  111712           0 :      SgProcessControlStatement* returnPointer = NULL;
  111713           0 :      if ( globalIndex != 0 )
  111714             :         {
  111715             : 
  111716             : #if FILE_IO_EXTRA_CHECK
  111717           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgProcessControlStatement ) ) <= globalIndex ) ;
  111718           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgProcessControlStatement + 1 ) ) );
  111719             : #endif
  111720           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgProcessControlStatement )  
  111721           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgProcessControlStatement );
  111722           0 :           unsigned long positionInPool = localIndex % SgProcessControlStatement::pool_size;
  111723           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgProcessControlStatement::pool_size;
  111724             : 
  111725             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  111726             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  111727             : 
  111728           0 :           returnPointer = &( ( (SgProcessControlStatement*)(SgProcessControlStatement::pools[memoryBlock]) ) [positionInPool]) ;
  111729             : 
  111730           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  111731             :         }
  111732           0 :      return returnPointer ;
  111733             :    }
  111734             : 
  111735             : //############################################################################
  111736             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  111737             :   for the AST with the index astIndex
  111738             : */
  111739           0 : SgProcessControlStatement * SgProcessControlStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  111740           0 :      SgProcessControlStatement* returnPointer = NULL;
  111741           0 :      if ( globalIndex != 0 )
  111742             :         {
  111743             : 
  111744             : #if FILE_IO_EXTRA_CHECK
  111745           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgProcessControlStatement ) ) <= globalIndex ) ;
  111746           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgProcessControlStatement + 1 ) ) );
  111747             : #endif
  111748           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgProcessControlStatement )
  111749           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgProcessControlStatement );
  111750           0 :           unsigned long positionInPool = localIndex % SgProcessControlStatement::pool_size ;
  111751           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgProcessControlStatement::pool_size ;
  111752             : 
  111753             : #if FILE_IO_EXTRA_CHECK
  111754             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  111755             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  111756             : #endif
  111757             : 
  111758           0 :           returnPointer = &( ( (SgProcessControlStatement*)(SgProcessControlStatement::pools[memoryBlock]) ) [positionInPool]) ;
  111759             : 
  111760             : #if FILE_IO_EXTRA_CHECK
  111761           0 :           assert ( returnPointer != NULL ) ;
  111762             : #endif
  111763             :         }
  111764           0 :      return returnPointer ;
  111765             :    }
  111766             : 
  111767             : //############################################################################
  111768             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  111769             :  * pool size! We set for every valid object in the memory pool the freepointer
  111770             :  * to the global index and increase the global index afterwards. For all the 
  111771             :  * invalid objects (means address ranges within the memory pool that were not
  111772             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  111773             :  * distinguish valid from invalid objects! 
  111774             :  */
  111775             : unsigned long
  111776           5 : SgProcessControlStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  111777             :    {
  111778           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  111779           5 :      SgProcessControlStatement* pointer = NULL;
  111780           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  111781           5 :      std::vector < unsigned char* > :: const_iterator block;
  111782           5 :      for ( block = SgProcessControlStatement::pools.begin(); block != SgProcessControlStatement::pools.end() ; ++block )
  111783             :         {
  111784           0 :           pointer = (SgProcessControlStatement*)(*block);
  111785           0 :           for (unsigned i = 0; i < SgProcessControlStatement::pool_size; ++i )
  111786             :              {
  111787             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  111788             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  111789             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  111790             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  111791             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  111792             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  111793             :             // properly; so this will have to be checked next.
  111794             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  111795             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  111796           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  111797             :                   {
  111798           0 :                     pointer[i].set_freepointer((SgProcessControlStatement*)(globalIndex));
  111799           0 :                     globalIndex++;
  111800             :                   }
  111801             :                else
  111802             :                   {
  111803           0 :                     pointer[i].set_freepointer(NULL);
  111804             :                   }
  111805             :               }
  111806             :         }
  111807           5 :      return globalIndex;
  111808             :    }
  111809             : 
  111810             : //############################################################################
  111811             : // JH (01/14/2006)
  111812             : void
  111813           5 : SgProcessControlStatement::resetValidFreepointers( )
  111814             :    {
  111815           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  111816           5 :      SgProcessControlStatement* pointer = NULL;
  111817           5 :      std::vector < unsigned char* > :: const_iterator block;
  111818           5 :      SgProcessControlStatement* pointerOfLinkedList = NULL;
  111819           5 :      for ( block = SgProcessControlStatement::pools.begin(); block != SgProcessControlStatement::pools.end() ; ++block )
  111820             :         {
  111821           0 :           pointer = (SgProcessControlStatement*)(*block);
  111822           0 :           for (unsigned i = 0; i < SgProcessControlStatement::pool_size; ++i )
  111823             :              {
  111824             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  111825             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  111826             :             // memory blocks!.
  111827           0 :                if ( pointer[i].get_freepointer() != NULL )
  111828             :                   {
  111829           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  111830             :                   }
  111831             :                else
  111832             :                   {
  111833           0 :                     if ( pointerOfLinkedList == NULL )
  111834             :                        {
  111835           0 :                          SgProcessControlStatement::next_node = &(pointer[i]);
  111836             :                        }
  111837             :                     else
  111838             :                        {
  111839             :                       // printf ("In SgProcessControlStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  111840           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  111841             :                        }
  111842             :                     pointerOfLinkedList = &(pointer[i]);
  111843             :                   }
  111844             :               }
  111845             :         }
  111846             : 
  111847           5 :      if ( pointerOfLinkedList != NULL )
  111848             :         {
  111849             :        // printf ("In SgProcessControlStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  111850           0 :           pointerOfLinkedList->set_freepointer(NULL);
  111851             :        // DQ (6/6/2010): Temporary debugging...
  111852             :        //   ROSE_ASSERT(false);
  111853             :         }
  111854             : 
  111855           5 :      return ;
  111856             :    }
  111857             : 
  111858             : //############################################################################
  111859             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  111860             :  * within the memory pool and resets the freepointers, in order to achieve a 
  111861             :  * linked list, that has no jumps and starts at the beginning! This function 
  111862             :  * does not extend the memory pool, since we do not delete any memory blocks,
  111863             :  * but delete the valid objects.  
  111864             :  */
  111865             : void
  111866           0 : SgProcessControlStatement::clearMemoryPool( )
  111867             :    {
  111868             :   // printf ("Inside of SgProcessControlStatement::clearMemoryPool() \n");
  111869             : 
  111870           0 :      SgProcessControlStatement* pointer = NULL, *tempPointer = NULL;
  111871           0 :      std::vector < unsigned char* > :: const_iterator block;
  111872           0 :      if ( SgProcessControlStatement::pools.empty() == false )
  111873             :         {
  111874           0 :           block = SgProcessControlStatement::pools.begin() ;
  111875           0 :           SgProcessControlStatement::next_node = (SgProcessControlStatement*) (*block);
  111876             : 
  111877           0 :           while ( block != SgProcessControlStatement::pools.end() )
  111878             :              {
  111879           0 :                pointer = (SgProcessControlStatement*) (*block);
  111880           0 :                if ( tempPointer != NULL )
  111881             :                   {
  111882           0 :                     tempPointer->set_freepointer(pointer);
  111883             :                   }
  111884           0 :                for (unsigned i = 0; i < SgProcessControlStatement::pool_size - 1; ++i)
  111885             :                   {
  111886           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  111887             :                   }
  111888           0 :                 pointer[SgProcessControlStatement::pool_size-1].set_freepointer(NULL);
  111889           0 :                 tempPointer = &(pointer[SgProcessControlStatement::pool_size-1]);
  111890           0 :                 ++block;
  111891             :              }
  111892             :         }
  111893           0 :    }
  111894             : 
  111895           5 : void SgProcessControlStatement::deleteMemoryPool() {
  111896           5 :   for (auto p: SgProcessControlStatement::pools) {
  111897           0 :     ROSE_FREE(p);
  111898             :   }
  111899           5 :   SgProcessControlStatement::next_node = nullptr;
  111900           5 :   SgProcessControlStatement::pools.clear();
  111901           5 : }
  111902             : 
  111903             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  111904             : //                 reading multiple binary files to for a single AST.
  111905             : /////////// new version ////////////////////////////////
  111906             : //############################################################################
  111907             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  111908             : void
  111909           2 : SgProcessControlStatement::extendMemoryPoolForFileIO( )
  111910             :   {
  111911           2 :     size_t blockIndex = SgProcessControlStatement::pools.size();
  111912           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgProcessControlStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgProcessControlStatement);
  111913             : 
  111914           2 :     while ( (blockIndex * SgProcessControlStatement::pool_size) < newPoolSize)
  111915             :       {
  111916             : #if ROSE_ALLOC_TRACE
  111917             :         if (blockIndex > 0) {
  111918             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgProcessControlStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgProcessControlStatement) = %" PRIuPTR " SgProcessControlStatement::pool_size = %d \n",
  111919             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgProcessControlStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgProcessControlStatement),SgProcessControlStatement::pool_size);
  111920             :         }
  111921             : #endif
  111922             : 
  111923           0 :         SgProcessControlStatement * pointer = (SgProcessControlStatement*) ROSE_MALLOC ( SgProcessControlStatement::pool_size * sizeof(SgProcessControlStatement) );
  111924           0 :         assert( pointer != NULL );
  111925             : #if ROSE_ALLOC_MEMSET == 1
  111926             :         memset(pointer, 0x00, SgProcessControlStatement::pool_size * sizeof(SgProcessControlStatement));
  111927             : #elif ROSE_ALLOC_MEMSET == 2
  111928             :         memset(pointer, 0xCC, SgProcessControlStatement::pool_size * sizeof(SgProcessControlStatement));
  111929             : #endif
  111930           0 :         SgProcessControlStatement::pools.push_back( (unsigned char*)(pointer) );
  111931           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgProcessControlStatement::pool_size * sizeof(SgProcessControlStatement), V_SgProcessControlStatement ) );
  111932             : 
  111933           0 :         if ( SgProcessControlStatement::next_node != NULL ) {
  111934           0 :           if ( blockIndex > 0 ) {
  111935           0 :             SgProcessControlStatement * blkptr = (SgProcessControlStatement*)(SgProcessControlStatement::pools[blockIndex-1]);
  111936           0 :             blkptr[ SgProcessControlStatement::pool_size - 1 ].set_freepointer(pointer);
  111937             :           }
  111938             :         } else {
  111939           0 :           SgProcessControlStatement::next_node = pointer;
  111940             :         }
  111941             : 
  111942           0 :         for (unsigned i = 0; i < SgProcessControlStatement::pool_size-1; ++i)
  111943             :            {
  111944           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  111945             :            }
  111946           0 :         pointer[ SgProcessControlStatement::pool_size -1 ].set_freepointer(NULL);
  111947             : 
  111948           0 :         blockIndex++;
  111949             :       }
  111950           2 :   }
  111951             : 
  111952             : //############################################################################
  111953             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  111954             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  111955             :  * not compressed. However, that stuff is not yet implemented! 
  111956             :  */
  111957             : unsigned long
  111958           0 : SgProcessControlStatement::getNumberOfLastValidPointer()
  111959             :    {
  111960           0 :       SgProcessControlStatement* testPointer = (SgProcessControlStatement*)(SgProcessControlStatement::pools.back());
  111961           0 :       unsigned long localIndex = SgProcessControlStatement::pool_size - 1;
  111962           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  111963             :          {
  111964           0 :            localIndex--;
  111965             :          }
  111966           0 :       return (localIndex + SgProcessControlStatement::pool_size * (SgProcessControlStatement::pools.size()-1));
  111967             :    }
  111968             : 
  111969             : //############################################################################
  111970             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  111971             :  * memory pool and initializes the data member in class SgProcessControlStatementStroageClass
  111972             :  * from its counterpart of SgProcessControlStatement. The return value is just for checking, 
  111973             :  * that the whole StorageClassArray is initialized!
  111974             :  */
  111975             : unsigned long
  111976           0 : SgProcessControlStatement::initializeStorageClassArray( SgProcessControlStatementStorageClass *storageArray )
  111977             :    {
  111978           0 :      unsigned long storageCounter = 0;
  111979           0 :      std::vector < unsigned char* > :: const_iterator block = SgProcessControlStatement::pools.begin();
  111980           0 :      SgProcessControlStatement* pointer = NULL;
  111981           0 :      while ( block != SgProcessControlStatement::pools.end() ) {
  111982           0 :           pointer = (SgProcessControlStatement*) (*block);
  111983           0 :           for ( unsigned i = 0; i < SgProcessControlStatement::pool_size; ++i ) {
  111984           0 :                if ( pointer->get_freepointer() != NULL ) {
  111985           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  111986           0 :                  storageArray++;
  111987           0 :                  storageCounter++;
  111988             :                }
  111989           0 :                pointer++;
  111990             :              }
  111991           0 :            block++;
  111992             :         }
  111993           0 :      return storageCounter;
  111994             :    }
  111995             : 
  111996             : /* #line 111997 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  111997             : 
  111998             : 
  111999             : 
  112000             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  112001             : 
  112002             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  112003             : 
  112004             : //############################################################################
  112005             : /* JH (02/02/2006) Constructor of the IR node SgIOStatement that takes its 
  112006             :  * corresponding StorageClass as parameter
  112007             :  */
  112008           0 : SgIOStatement :: SgIOStatement ( const SgIOStatementStorageClass& storageSource )   : SgStatement (storageSource)
  112009             :    {
  112010             : 
  112011             : 
  112012             : /* #line 112013 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  112013             : 
  112014           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  112015           0 :      p_io_statement = storageSource.storageOf_io_statement ;
  112016           0 :      p_io_stmt_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_io_stmt_list) );
  112017           0 :      p_unit =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_unit) );
  112018           0 :      p_iostat =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_iostat) );
  112019           0 :      p_err =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_err) );
  112020           0 :      p_iomsg =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_iomsg) );
  112021             : 
  112022             : 
  112023             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  112024             : 
  112025             : 
  112026           0 :    }
  112027             : 
  112028             : //############################################################################
  112029             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  112030             :  * within the working AST. 
  112031             :  */
  112032           0 : SgIOStatement * SgIOStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  112033           0 :      SgIOStatement* returnPointer = NULL;
  112034           0 :      if ( globalIndex != 0 )
  112035             :         {
  112036             : 
  112037             : #if FILE_IO_EXTRA_CHECK
  112038           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIOStatement ) ) <= globalIndex ) ;
  112039           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIOStatement + 1 ) ) );
  112040             : #endif
  112041           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIOStatement )  
  112042           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIOStatement );
  112043           0 :           unsigned long positionInPool = localIndex % SgIOStatement::pool_size;
  112044           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIOStatement::pool_size;
  112045             : 
  112046             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  112047             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  112048             : 
  112049           0 :           returnPointer = &( ( (SgIOStatement*)(SgIOStatement::pools[memoryBlock]) ) [positionInPool]) ;
  112050             : 
  112051           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  112052             :         }
  112053           0 :      return returnPointer ;
  112054             :    }
  112055             : 
  112056             : //############################################################################
  112057             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  112058             :   for the AST with the index astIndex
  112059             : */
  112060           0 : SgIOStatement * SgIOStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  112061           0 :      SgIOStatement* returnPointer = NULL;
  112062           0 :      if ( globalIndex != 0 )
  112063             :         {
  112064             : 
  112065             : #if FILE_IO_EXTRA_CHECK
  112066           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIOStatement ) ) <= globalIndex ) ;
  112067           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIOStatement + 1 ) ) );
  112068             : #endif
  112069           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIOStatement )
  112070           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIOStatement );
  112071           0 :           unsigned long positionInPool = localIndex % SgIOStatement::pool_size ;
  112072           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIOStatement::pool_size ;
  112073             : 
  112074             : #if FILE_IO_EXTRA_CHECK
  112075             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  112076             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  112077             : #endif
  112078             : 
  112079           0 :           returnPointer = &( ( (SgIOStatement*)(SgIOStatement::pools[memoryBlock]) ) [positionInPool]) ;
  112080             : 
  112081             : #if FILE_IO_EXTRA_CHECK
  112082           0 :           assert ( returnPointer != NULL ) ;
  112083             : #endif
  112084             :         }
  112085           0 :      return returnPointer ;
  112086             :    }
  112087             : 
  112088             : //############################################################################
  112089             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  112090             :  * pool size! We set for every valid object in the memory pool the freepointer
  112091             :  * to the global index and increase the global index afterwards. For all the 
  112092             :  * invalid objects (means address ranges within the memory pool that were not
  112093             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  112094             :  * distinguish valid from invalid objects! 
  112095             :  */
  112096             : unsigned long
  112097           5 : SgIOStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  112098             :    {
  112099           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  112100           5 :      SgIOStatement* pointer = NULL;
  112101           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  112102           5 :      std::vector < unsigned char* > :: const_iterator block;
  112103           5 :      for ( block = SgIOStatement::pools.begin(); block != SgIOStatement::pools.end() ; ++block )
  112104             :         {
  112105           0 :           pointer = (SgIOStatement*)(*block);
  112106           0 :           for (unsigned i = 0; i < SgIOStatement::pool_size; ++i )
  112107             :              {
  112108             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  112109             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  112110             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  112111             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  112112             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  112113             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  112114             :             // properly; so this will have to be checked next.
  112115             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  112116             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  112117           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  112118             :                   {
  112119           0 :                     pointer[i].set_freepointer((SgIOStatement*)(globalIndex));
  112120           0 :                     globalIndex++;
  112121             :                   }
  112122             :                else
  112123             :                   {
  112124           0 :                     pointer[i].set_freepointer(NULL);
  112125             :                   }
  112126             :               }
  112127             :         }
  112128           5 :      return globalIndex;
  112129             :    }
  112130             : 
  112131             : //############################################################################
  112132             : // JH (01/14/2006)
  112133             : void
  112134           5 : SgIOStatement::resetValidFreepointers( )
  112135             :    {
  112136           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  112137           5 :      SgIOStatement* pointer = NULL;
  112138           5 :      std::vector < unsigned char* > :: const_iterator block;
  112139           5 :      SgIOStatement* pointerOfLinkedList = NULL;
  112140           5 :      for ( block = SgIOStatement::pools.begin(); block != SgIOStatement::pools.end() ; ++block )
  112141             :         {
  112142           0 :           pointer = (SgIOStatement*)(*block);
  112143           0 :           for (unsigned i = 0; i < SgIOStatement::pool_size; ++i )
  112144             :              {
  112145             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  112146             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  112147             :             // memory blocks!.
  112148           0 :                if ( pointer[i].get_freepointer() != NULL )
  112149             :                   {
  112150           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  112151             :                   }
  112152             :                else
  112153             :                   {
  112154           0 :                     if ( pointerOfLinkedList == NULL )
  112155             :                        {
  112156           0 :                          SgIOStatement::next_node = &(pointer[i]);
  112157             :                        }
  112158             :                     else
  112159             :                        {
  112160             :                       // printf ("In SgIOStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  112161           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  112162             :                        }
  112163             :                     pointerOfLinkedList = &(pointer[i]);
  112164             :                   }
  112165             :               }
  112166             :         }
  112167             : 
  112168           5 :      if ( pointerOfLinkedList != NULL )
  112169             :         {
  112170             :        // printf ("In SgIOStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  112171           0 :           pointerOfLinkedList->set_freepointer(NULL);
  112172             :        // DQ (6/6/2010): Temporary debugging...
  112173             :        //   ROSE_ASSERT(false);
  112174             :         }
  112175             : 
  112176           5 :      return ;
  112177             :    }
  112178             : 
  112179             : //############################################################################
  112180             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  112181             :  * within the memory pool and resets the freepointers, in order to achieve a 
  112182             :  * linked list, that has no jumps and starts at the beginning! This function 
  112183             :  * does not extend the memory pool, since we do not delete any memory blocks,
  112184             :  * but delete the valid objects.  
  112185             :  */
  112186             : void
  112187           0 : SgIOStatement::clearMemoryPool( )
  112188             :    {
  112189             :   // printf ("Inside of SgIOStatement::clearMemoryPool() \n");
  112190             : 
  112191           0 :      SgIOStatement* pointer = NULL, *tempPointer = NULL;
  112192           0 :      std::vector < unsigned char* > :: const_iterator block;
  112193           0 :      if ( SgIOStatement::pools.empty() == false )
  112194             :         {
  112195           0 :           block = SgIOStatement::pools.begin() ;
  112196           0 :           SgIOStatement::next_node = (SgIOStatement*) (*block);
  112197             : 
  112198           0 :           while ( block != SgIOStatement::pools.end() )
  112199             :              {
  112200           0 :                pointer = (SgIOStatement*) (*block);
  112201           0 :                if ( tempPointer != NULL )
  112202             :                   {
  112203           0 :                     tempPointer->set_freepointer(pointer);
  112204             :                   }
  112205           0 :                for (unsigned i = 0; i < SgIOStatement::pool_size - 1; ++i)
  112206             :                   {
  112207           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  112208             :                   }
  112209           0 :                 pointer[SgIOStatement::pool_size-1].set_freepointer(NULL);
  112210           0 :                 tempPointer = &(pointer[SgIOStatement::pool_size-1]);
  112211           0 :                 ++block;
  112212             :              }
  112213             :         }
  112214           0 :    }
  112215             : 
  112216           5 : void SgIOStatement::deleteMemoryPool() {
  112217           5 :   for (auto p: SgIOStatement::pools) {
  112218           0 :     ROSE_FREE(p);
  112219             :   }
  112220           5 :   SgIOStatement::next_node = nullptr;
  112221           5 :   SgIOStatement::pools.clear();
  112222           5 : }
  112223             : 
  112224             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  112225             : //                 reading multiple binary files to for a single AST.
  112226             : /////////// new version ////////////////////////////////
  112227             : //############################################################################
  112228             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  112229             : void
  112230           2 : SgIOStatement::extendMemoryPoolForFileIO( )
  112231             :   {
  112232           2 :     size_t blockIndex = SgIOStatement::pools.size();
  112233           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIOStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIOStatement);
  112234             : 
  112235           2 :     while ( (blockIndex * SgIOStatement::pool_size) < newPoolSize)
  112236             :       {
  112237             : #if ROSE_ALLOC_TRACE
  112238             :         if (blockIndex > 0) {
  112239             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIOStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIOStatement) = %" PRIuPTR " SgIOStatement::pool_size = %d \n",
  112240             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIOStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIOStatement),SgIOStatement::pool_size);
  112241             :         }
  112242             : #endif
  112243             : 
  112244           0 :         SgIOStatement * pointer = (SgIOStatement*) ROSE_MALLOC ( SgIOStatement::pool_size * sizeof(SgIOStatement) );
  112245           0 :         assert( pointer != NULL );
  112246             : #if ROSE_ALLOC_MEMSET == 1
  112247             :         memset(pointer, 0x00, SgIOStatement::pool_size * sizeof(SgIOStatement));
  112248             : #elif ROSE_ALLOC_MEMSET == 2
  112249             :         memset(pointer, 0xCC, SgIOStatement::pool_size * sizeof(SgIOStatement));
  112250             : #endif
  112251           0 :         SgIOStatement::pools.push_back( (unsigned char*)(pointer) );
  112252           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIOStatement::pool_size * sizeof(SgIOStatement), V_SgIOStatement ) );
  112253             : 
  112254           0 :         if ( SgIOStatement::next_node != NULL ) {
  112255           0 :           if ( blockIndex > 0 ) {
  112256           0 :             SgIOStatement * blkptr = (SgIOStatement*)(SgIOStatement::pools[blockIndex-1]);
  112257           0 :             blkptr[ SgIOStatement::pool_size - 1 ].set_freepointer(pointer);
  112258             :           }
  112259             :         } else {
  112260           0 :           SgIOStatement::next_node = pointer;
  112261             :         }
  112262             : 
  112263           0 :         for (unsigned i = 0; i < SgIOStatement::pool_size-1; ++i)
  112264             :            {
  112265           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  112266             :            }
  112267           0 :         pointer[ SgIOStatement::pool_size -1 ].set_freepointer(NULL);
  112268             : 
  112269           0 :         blockIndex++;
  112270             :       }
  112271           2 :   }
  112272             : 
  112273             : //############################################################################
  112274             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  112275             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  112276             :  * not compressed. However, that stuff is not yet implemented! 
  112277             :  */
  112278             : unsigned long
  112279           0 : SgIOStatement::getNumberOfLastValidPointer()
  112280             :    {
  112281           0 :       SgIOStatement* testPointer = (SgIOStatement*)(SgIOStatement::pools.back());
  112282           0 :       unsigned long localIndex = SgIOStatement::pool_size - 1;
  112283           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  112284             :          {
  112285           0 :            localIndex--;
  112286             :          }
  112287           0 :       return (localIndex + SgIOStatement::pool_size * (SgIOStatement::pools.size()-1));
  112288             :    }
  112289             : 
  112290             : //############################################################################
  112291             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  112292             :  * memory pool and initializes the data member in class SgIOStatementStroageClass
  112293             :  * from its counterpart of SgIOStatement. The return value is just for checking, 
  112294             :  * that the whole StorageClassArray is initialized!
  112295             :  */
  112296             : unsigned long
  112297           0 : SgIOStatement::initializeStorageClassArray( SgIOStatementStorageClass *storageArray )
  112298             :    {
  112299           0 :      unsigned long storageCounter = 0;
  112300           0 :      std::vector < unsigned char* > :: const_iterator block = SgIOStatement::pools.begin();
  112301           0 :      SgIOStatement* pointer = NULL;
  112302           0 :      while ( block != SgIOStatement::pools.end() ) {
  112303           0 :           pointer = (SgIOStatement*) (*block);
  112304           0 :           for ( unsigned i = 0; i < SgIOStatement::pool_size; ++i ) {
  112305           0 :                if ( pointer->get_freepointer() != NULL ) {
  112306           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  112307           0 :                  storageArray++;
  112308           0 :                  storageCounter++;
  112309             :                }
  112310           0 :                pointer++;
  112311             :              }
  112312           0 :            block++;
  112313             :         }
  112314           0 :      return storageCounter;
  112315             :    }
  112316             : 
  112317             : /* #line 112318 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  112318             : 
  112319             : 
  112320             : 
  112321             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  112322             : 
  112323             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  112324             : 
  112325             : //############################################################################
  112326             : /* JH (02/02/2006) Constructor of the IR node SgPrintStatement that takes its 
  112327             :  * corresponding StorageClass as parameter
  112328             :  */
  112329           0 : SgPrintStatement :: SgPrintStatement ( const SgPrintStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  112330             :    {
  112331             : 
  112332             : 
  112333             : /* #line 112334 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  112334             : 
  112335           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  112336           0 :      p_format =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_format) );
  112337             : 
  112338             : 
  112339             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  112340             : 
  112341             : 
  112342           0 :    }
  112343             : 
  112344             : //############################################################################
  112345             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  112346             :  * within the working AST. 
  112347             :  */
  112348           0 : SgPrintStatement * SgPrintStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  112349           0 :      SgPrintStatement* returnPointer = NULL;
  112350           0 :      if ( globalIndex != 0 )
  112351             :         {
  112352             : 
  112353             : #if FILE_IO_EXTRA_CHECK
  112354           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPrintStatement ) ) <= globalIndex ) ;
  112355           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPrintStatement + 1 ) ) );
  112356             : #endif
  112357           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPrintStatement )  
  112358           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPrintStatement );
  112359           0 :           unsigned long positionInPool = localIndex % SgPrintStatement::pool_size;
  112360           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPrintStatement::pool_size;
  112361             : 
  112362             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  112363             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  112364             : 
  112365           0 :           returnPointer = &( ( (SgPrintStatement*)(SgPrintStatement::pools[memoryBlock]) ) [positionInPool]) ;
  112366             : 
  112367           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  112368             :         }
  112369           0 :      return returnPointer ;
  112370             :    }
  112371             : 
  112372             : //############################################################################
  112373             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  112374             :   for the AST with the index astIndex
  112375             : */
  112376           0 : SgPrintStatement * SgPrintStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  112377           0 :      SgPrintStatement* returnPointer = NULL;
  112378           0 :      if ( globalIndex != 0 )
  112379             :         {
  112380             : 
  112381             : #if FILE_IO_EXTRA_CHECK
  112382           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPrintStatement ) ) <= globalIndex ) ;
  112383           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPrintStatement + 1 ) ) );
  112384             : #endif
  112385           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPrintStatement )
  112386           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPrintStatement );
  112387           0 :           unsigned long positionInPool = localIndex % SgPrintStatement::pool_size ;
  112388           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPrintStatement::pool_size ;
  112389             : 
  112390             : #if FILE_IO_EXTRA_CHECK
  112391             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  112392             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  112393             : #endif
  112394             : 
  112395           0 :           returnPointer = &( ( (SgPrintStatement*)(SgPrintStatement::pools[memoryBlock]) ) [positionInPool]) ;
  112396             : 
  112397             : #if FILE_IO_EXTRA_CHECK
  112398           0 :           assert ( returnPointer != NULL ) ;
  112399             : #endif
  112400             :         }
  112401           0 :      return returnPointer ;
  112402             :    }
  112403             : 
  112404             : //############################################################################
  112405             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  112406             :  * pool size! We set for every valid object in the memory pool the freepointer
  112407             :  * to the global index and increase the global index afterwards. For all the 
  112408             :  * invalid objects (means address ranges within the memory pool that were not
  112409             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  112410             :  * distinguish valid from invalid objects! 
  112411             :  */
  112412             : unsigned long
  112413           5 : SgPrintStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  112414             :    {
  112415           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  112416           5 :      SgPrintStatement* pointer = NULL;
  112417           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  112418           5 :      std::vector < unsigned char* > :: const_iterator block;
  112419           6 :      for ( block = SgPrintStatement::pools.begin(); block != SgPrintStatement::pools.end() ; ++block )
  112420             :         {
  112421           1 :           pointer = (SgPrintStatement*)(*block);
  112422        2001 :           for (unsigned i = 0; i < SgPrintStatement::pool_size; ++i )
  112423             :              {
  112424             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  112425             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  112426             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  112427             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  112428             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  112429             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  112430             :             // properly; so this will have to be checked next.
  112431             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  112432             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  112433        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  112434             :                   {
  112435           1 :                     pointer[i].set_freepointer((SgPrintStatement*)(globalIndex));
  112436           1 :                     globalIndex++;
  112437             :                   }
  112438             :                else
  112439             :                   {
  112440        1999 :                     pointer[i].set_freepointer(NULL);
  112441             :                   }
  112442             :               }
  112443             :         }
  112444           5 :      return globalIndex;
  112445             :    }
  112446             : 
  112447             : //############################################################################
  112448             : // JH (01/14/2006)
  112449             : void
  112450           5 : SgPrintStatement::resetValidFreepointers( )
  112451             :    {
  112452           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  112453           5 :      SgPrintStatement* pointer = NULL;
  112454           5 :      std::vector < unsigned char* > :: const_iterator block;
  112455           5 :      SgPrintStatement* pointerOfLinkedList = NULL;
  112456           6 :      for ( block = SgPrintStatement::pools.begin(); block != SgPrintStatement::pools.end() ; ++block )
  112457             :         {
  112458           1 :           pointer = (SgPrintStatement*)(*block);
  112459        2001 :           for (unsigned i = 0; i < SgPrintStatement::pool_size; ++i )
  112460             :              {
  112461             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  112462             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  112463             :             // memory blocks!.
  112464        2000 :                if ( pointer[i].get_freepointer() != NULL )
  112465             :                   {
  112466           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  112467             :                   }
  112468             :                else
  112469             :                   {
  112470        1999 :                     if ( pointerOfLinkedList == NULL )
  112471             :                        {
  112472           1 :                          SgPrintStatement::next_node = &(pointer[i]);
  112473             :                        }
  112474             :                     else
  112475             :                        {
  112476             :                       // printf ("In SgPrintStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  112477        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  112478             :                        }
  112479             :                     pointerOfLinkedList = &(pointer[i]);
  112480             :                   }
  112481             :               }
  112482             :         }
  112483             : 
  112484           5 :      if ( pointerOfLinkedList != NULL )
  112485             :         {
  112486             :        // printf ("In SgPrintStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  112487           1 :           pointerOfLinkedList->set_freepointer(NULL);
  112488             :        // DQ (6/6/2010): Temporary debugging...
  112489             :        //   ROSE_ASSERT(false);
  112490             :         }
  112491             : 
  112492           5 :      return ;
  112493             :    }
  112494             : 
  112495             : //############################################################################
  112496             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  112497             :  * within the memory pool and resets the freepointers, in order to achieve a 
  112498             :  * linked list, that has no jumps and starts at the beginning! This function 
  112499             :  * does not extend the memory pool, since we do not delete any memory blocks,
  112500             :  * but delete the valid objects.  
  112501             :  */
  112502             : void
  112503           0 : SgPrintStatement::clearMemoryPool( )
  112504             :    {
  112505             :   // printf ("Inside of SgPrintStatement::clearMemoryPool() \n");
  112506             : 
  112507           0 :      SgPrintStatement* pointer = NULL, *tempPointer = NULL;
  112508           0 :      std::vector < unsigned char* > :: const_iterator block;
  112509           0 :      if ( SgPrintStatement::pools.empty() == false )
  112510             :         {
  112511           0 :           block = SgPrintStatement::pools.begin() ;
  112512           0 :           SgPrintStatement::next_node = (SgPrintStatement*) (*block);
  112513             : 
  112514           0 :           while ( block != SgPrintStatement::pools.end() )
  112515             :              {
  112516           0 :                pointer = (SgPrintStatement*) (*block);
  112517           0 :                if ( tempPointer != NULL )
  112518             :                   {
  112519           0 :                     tempPointer->set_freepointer(pointer);
  112520             :                   }
  112521           0 :                for (unsigned i = 0; i < SgPrintStatement::pool_size - 1; ++i)
  112522             :                   {
  112523           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  112524             :                   }
  112525           0 :                 pointer[SgPrintStatement::pool_size-1].set_freepointer(NULL);
  112526           0 :                 tempPointer = &(pointer[SgPrintStatement::pool_size-1]);
  112527           0 :                 ++block;
  112528             :              }
  112529             :         }
  112530           0 :    }
  112531             : 
  112532           5 : void SgPrintStatement::deleteMemoryPool() {
  112533           6 :   for (auto p: SgPrintStatement::pools) {
  112534           1 :     ROSE_FREE(p);
  112535             :   }
  112536           5 :   SgPrintStatement::next_node = nullptr;
  112537           5 :   SgPrintStatement::pools.clear();
  112538           5 : }
  112539             : 
  112540             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  112541             : //                 reading multiple binary files to for a single AST.
  112542             : /////////// new version ////////////////////////////////
  112543             : //############################################################################
  112544             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  112545             : void
  112546           2 : SgPrintStatement::extendMemoryPoolForFileIO( )
  112547             :   {
  112548           2 :     size_t blockIndex = SgPrintStatement::pools.size();
  112549           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPrintStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPrintStatement);
  112550             : 
  112551           2 :     while ( (blockIndex * SgPrintStatement::pool_size) < newPoolSize)
  112552             :       {
  112553             : #if ROSE_ALLOC_TRACE
  112554             :         if (blockIndex > 0) {
  112555             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPrintStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPrintStatement) = %" PRIuPTR " SgPrintStatement::pool_size = %d \n",
  112556             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPrintStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPrintStatement),SgPrintStatement::pool_size);
  112557             :         }
  112558             : #endif
  112559             : 
  112560           0 :         SgPrintStatement * pointer = (SgPrintStatement*) ROSE_MALLOC ( SgPrintStatement::pool_size * sizeof(SgPrintStatement) );
  112561           0 :         assert( pointer != NULL );
  112562             : #if ROSE_ALLOC_MEMSET == 1
  112563             :         memset(pointer, 0x00, SgPrintStatement::pool_size * sizeof(SgPrintStatement));
  112564             : #elif ROSE_ALLOC_MEMSET == 2
  112565             :         memset(pointer, 0xCC, SgPrintStatement::pool_size * sizeof(SgPrintStatement));
  112566             : #endif
  112567           0 :         SgPrintStatement::pools.push_back( (unsigned char*)(pointer) );
  112568           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPrintStatement::pool_size * sizeof(SgPrintStatement), V_SgPrintStatement ) );
  112569             : 
  112570           0 :         if ( SgPrintStatement::next_node != NULL ) {
  112571           0 :           if ( blockIndex > 0 ) {
  112572           0 :             SgPrintStatement * blkptr = (SgPrintStatement*)(SgPrintStatement::pools[blockIndex-1]);
  112573           0 :             blkptr[ SgPrintStatement::pool_size - 1 ].set_freepointer(pointer);
  112574             :           }
  112575             :         } else {
  112576           0 :           SgPrintStatement::next_node = pointer;
  112577             :         }
  112578             : 
  112579           0 :         for (unsigned i = 0; i < SgPrintStatement::pool_size-1; ++i)
  112580             :            {
  112581           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  112582             :            }
  112583           0 :         pointer[ SgPrintStatement::pool_size -1 ].set_freepointer(NULL);
  112584             : 
  112585           0 :         blockIndex++;
  112586             :       }
  112587           2 :   }
  112588             : 
  112589             : //############################################################################
  112590             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  112591             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  112592             :  * not compressed. However, that stuff is not yet implemented! 
  112593             :  */
  112594             : unsigned long
  112595           0 : SgPrintStatement::getNumberOfLastValidPointer()
  112596             :    {
  112597           0 :       SgPrintStatement* testPointer = (SgPrintStatement*)(SgPrintStatement::pools.back());
  112598           0 :       unsigned long localIndex = SgPrintStatement::pool_size - 1;
  112599           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  112600             :          {
  112601           0 :            localIndex--;
  112602             :          }
  112603           0 :       return (localIndex + SgPrintStatement::pool_size * (SgPrintStatement::pools.size()-1));
  112604             :    }
  112605             : 
  112606             : //############################################################################
  112607             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  112608             :  * memory pool and initializes the data member in class SgPrintStatementStroageClass
  112609             :  * from its counterpart of SgPrintStatement. The return value is just for checking, 
  112610             :  * that the whole StorageClassArray is initialized!
  112611             :  */
  112612             : unsigned long
  112613           1 : SgPrintStatement::initializeStorageClassArray( SgPrintStatementStorageClass *storageArray )
  112614             :    {
  112615           1 :      unsigned long storageCounter = 0;
  112616           1 :      std::vector < unsigned char* > :: const_iterator block = SgPrintStatement::pools.begin();
  112617           1 :      SgPrintStatement* pointer = NULL;
  112618           2 :      while ( block != SgPrintStatement::pools.end() ) {
  112619           1 :           pointer = (SgPrintStatement*) (*block);
  112620        2001 :           for ( unsigned i = 0; i < SgPrintStatement::pool_size; ++i ) {
  112621        2000 :                if ( pointer->get_freepointer() != NULL ) {
  112622           1 :                  storageArray->pickOutIRNodeData (pointer) ;
  112623           1 :                  storageArray++;
  112624           1 :                  storageCounter++;
  112625             :                }
  112626        2000 :                pointer++;
  112627             :              }
  112628           1 :            block++;
  112629             :         }
  112630           1 :      return storageCounter;
  112631             :    }
  112632             : 
  112633             : /* #line 112634 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  112634             : 
  112635             : 
  112636             : 
  112637             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  112638             : 
  112639             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  112640             : 
  112641             : //############################################################################
  112642             : /* JH (02/02/2006) Constructor of the IR node SgReadStatement that takes its 
  112643             :  * corresponding StorageClass as parameter
  112644             :  */
  112645           0 : SgReadStatement :: SgReadStatement ( const SgReadStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  112646             :    {
  112647             : 
  112648             : 
  112649             : /* #line 112650 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  112650             : 
  112651           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  112652           0 :      p_format =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_format) );
  112653           0 :      p_namelist =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_namelist) );
  112654           0 :      p_advance =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_advance) );
  112655           0 :      p_asynchronous =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_asynchronous) );
  112656           0 :      p_blank =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_blank) );
  112657           0 :      p_decimal =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_decimal) );
  112658           0 :      p_delim =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_delim) );
  112659           0 :      p_end =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end) );
  112660           0 :      p_eor =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_eor) );
  112661           0 :      p_id =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_id) );
  112662           0 :      p_pad =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pad) );
  112663           0 :      p_pos =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pos) );
  112664           0 :      p_rec =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_rec) );
  112665           0 :      p_round =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_round) );
  112666           0 :      p_sign =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_sign) );
  112667           0 :      p_size =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_size) );
  112668             : 
  112669             : 
  112670             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  112671             : 
  112672             : 
  112673           0 :    }
  112674             : 
  112675             : //############################################################################
  112676             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  112677             :  * within the working AST. 
  112678             :  */
  112679           0 : SgReadStatement * SgReadStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  112680           0 :      SgReadStatement* returnPointer = NULL;
  112681           0 :      if ( globalIndex != 0 )
  112682             :         {
  112683             : 
  112684             : #if FILE_IO_EXTRA_CHECK
  112685           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgReadStatement ) ) <= globalIndex ) ;
  112686           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgReadStatement + 1 ) ) );
  112687             : #endif
  112688           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgReadStatement )  
  112689           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgReadStatement );
  112690           0 :           unsigned long positionInPool = localIndex % SgReadStatement::pool_size;
  112691           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgReadStatement::pool_size;
  112692             : 
  112693             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  112694             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  112695             : 
  112696           0 :           returnPointer = &( ( (SgReadStatement*)(SgReadStatement::pools[memoryBlock]) ) [positionInPool]) ;
  112697             : 
  112698           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  112699             :         }
  112700           0 :      return returnPointer ;
  112701             :    }
  112702             : 
  112703             : //############################################################################
  112704             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  112705             :   for the AST with the index astIndex
  112706             : */
  112707           0 : SgReadStatement * SgReadStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  112708           0 :      SgReadStatement* returnPointer = NULL;
  112709           0 :      if ( globalIndex != 0 )
  112710             :         {
  112711             : 
  112712             : #if FILE_IO_EXTRA_CHECK
  112713           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgReadStatement ) ) <= globalIndex ) ;
  112714           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgReadStatement + 1 ) ) );
  112715             : #endif
  112716           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgReadStatement )
  112717           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgReadStatement );
  112718           0 :           unsigned long positionInPool = localIndex % SgReadStatement::pool_size ;
  112719           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgReadStatement::pool_size ;
  112720             : 
  112721             : #if FILE_IO_EXTRA_CHECK
  112722             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  112723             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  112724             : #endif
  112725             : 
  112726           0 :           returnPointer = &( ( (SgReadStatement*)(SgReadStatement::pools[memoryBlock]) ) [positionInPool]) ;
  112727             : 
  112728             : #if FILE_IO_EXTRA_CHECK
  112729           0 :           assert ( returnPointer != NULL ) ;
  112730             : #endif
  112731             :         }
  112732           0 :      return returnPointer ;
  112733             :    }
  112734             : 
  112735             : //############################################################################
  112736             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  112737             :  * pool size! We set for every valid object in the memory pool the freepointer
  112738             :  * to the global index and increase the global index afterwards. For all the 
  112739             :  * invalid objects (means address ranges within the memory pool that were not
  112740             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  112741             :  * distinguish valid from invalid objects! 
  112742             :  */
  112743             : unsigned long
  112744           5 : SgReadStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  112745             :    {
  112746           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  112747           5 :      SgReadStatement* pointer = NULL;
  112748           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  112749           5 :      std::vector < unsigned char* > :: const_iterator block;
  112750           5 :      for ( block = SgReadStatement::pools.begin(); block != SgReadStatement::pools.end() ; ++block )
  112751             :         {
  112752           0 :           pointer = (SgReadStatement*)(*block);
  112753           0 :           for (unsigned i = 0; i < SgReadStatement::pool_size; ++i )
  112754             :              {
  112755             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  112756             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  112757             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  112758             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  112759             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  112760             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  112761             :             // properly; so this will have to be checked next.
  112762             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  112763             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  112764           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  112765             :                   {
  112766           0 :                     pointer[i].set_freepointer((SgReadStatement*)(globalIndex));
  112767           0 :                     globalIndex++;
  112768             :                   }
  112769             :                else
  112770             :                   {
  112771           0 :                     pointer[i].set_freepointer(NULL);
  112772             :                   }
  112773             :               }
  112774             :         }
  112775           5 :      return globalIndex;
  112776             :    }
  112777             : 
  112778             : //############################################################################
  112779             : // JH (01/14/2006)
  112780             : void
  112781           5 : SgReadStatement::resetValidFreepointers( )
  112782             :    {
  112783           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  112784           5 :      SgReadStatement* pointer = NULL;
  112785           5 :      std::vector < unsigned char* > :: const_iterator block;
  112786           5 :      SgReadStatement* pointerOfLinkedList = NULL;
  112787           5 :      for ( block = SgReadStatement::pools.begin(); block != SgReadStatement::pools.end() ; ++block )
  112788             :         {
  112789           0 :           pointer = (SgReadStatement*)(*block);
  112790           0 :           for (unsigned i = 0; i < SgReadStatement::pool_size; ++i )
  112791             :              {
  112792             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  112793             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  112794             :             // memory blocks!.
  112795           0 :                if ( pointer[i].get_freepointer() != NULL )
  112796             :                   {
  112797           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  112798             :                   }
  112799             :                else
  112800             :                   {
  112801           0 :                     if ( pointerOfLinkedList == NULL )
  112802             :                        {
  112803           0 :                          SgReadStatement::next_node = &(pointer[i]);
  112804             :                        }
  112805             :                     else
  112806             :                        {
  112807             :                       // printf ("In SgReadStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  112808           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  112809             :                        }
  112810             :                     pointerOfLinkedList = &(pointer[i]);
  112811             :                   }
  112812             :               }
  112813             :         }
  112814             : 
  112815           5 :      if ( pointerOfLinkedList != NULL )
  112816             :         {
  112817             :        // printf ("In SgReadStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  112818           0 :           pointerOfLinkedList->set_freepointer(NULL);
  112819             :        // DQ (6/6/2010): Temporary debugging...
  112820             :        //   ROSE_ASSERT(false);
  112821             :         }
  112822             : 
  112823           5 :      return ;
  112824             :    }
  112825             : 
  112826             : //############################################################################
  112827             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  112828             :  * within the memory pool and resets the freepointers, in order to achieve a 
  112829             :  * linked list, that has no jumps and starts at the beginning! This function 
  112830             :  * does not extend the memory pool, since we do not delete any memory blocks,
  112831             :  * but delete the valid objects.  
  112832             :  */
  112833             : void
  112834           0 : SgReadStatement::clearMemoryPool( )
  112835             :    {
  112836             :   // printf ("Inside of SgReadStatement::clearMemoryPool() \n");
  112837             : 
  112838           0 :      SgReadStatement* pointer = NULL, *tempPointer = NULL;
  112839           0 :      std::vector < unsigned char* > :: const_iterator block;
  112840           0 :      if ( SgReadStatement::pools.empty() == false )
  112841             :         {
  112842           0 :           block = SgReadStatement::pools.begin() ;
  112843           0 :           SgReadStatement::next_node = (SgReadStatement*) (*block);
  112844             : 
  112845           0 :           while ( block != SgReadStatement::pools.end() )
  112846             :              {
  112847           0 :                pointer = (SgReadStatement*) (*block);
  112848           0 :                if ( tempPointer != NULL )
  112849             :                   {
  112850           0 :                     tempPointer->set_freepointer(pointer);
  112851             :                   }
  112852           0 :                for (unsigned i = 0; i < SgReadStatement::pool_size - 1; ++i)
  112853             :                   {
  112854           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  112855             :                   }
  112856           0 :                 pointer[SgReadStatement::pool_size-1].set_freepointer(NULL);
  112857           0 :                 tempPointer = &(pointer[SgReadStatement::pool_size-1]);
  112858           0 :                 ++block;
  112859             :              }
  112860             :         }
  112861           0 :    }
  112862             : 
  112863           5 : void SgReadStatement::deleteMemoryPool() {
  112864           5 :   for (auto p: SgReadStatement::pools) {
  112865           0 :     ROSE_FREE(p);
  112866             :   }
  112867           5 :   SgReadStatement::next_node = nullptr;
  112868           5 :   SgReadStatement::pools.clear();
  112869           5 : }
  112870             : 
  112871             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  112872             : //                 reading multiple binary files to for a single AST.
  112873             : /////////// new version ////////////////////////////////
  112874             : //############################################################################
  112875             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  112876             : void
  112877           2 : SgReadStatement::extendMemoryPoolForFileIO( )
  112878             :   {
  112879           2 :     size_t blockIndex = SgReadStatement::pools.size();
  112880           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgReadStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgReadStatement);
  112881             : 
  112882           2 :     while ( (blockIndex * SgReadStatement::pool_size) < newPoolSize)
  112883             :       {
  112884             : #if ROSE_ALLOC_TRACE
  112885             :         if (blockIndex > 0) {
  112886             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgReadStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgReadStatement) = %" PRIuPTR " SgReadStatement::pool_size = %d \n",
  112887             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgReadStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgReadStatement),SgReadStatement::pool_size);
  112888             :         }
  112889             : #endif
  112890             : 
  112891           0 :         SgReadStatement * pointer = (SgReadStatement*) ROSE_MALLOC ( SgReadStatement::pool_size * sizeof(SgReadStatement) );
  112892           0 :         assert( pointer != NULL );
  112893             : #if ROSE_ALLOC_MEMSET == 1
  112894             :         memset(pointer, 0x00, SgReadStatement::pool_size * sizeof(SgReadStatement));
  112895             : #elif ROSE_ALLOC_MEMSET == 2
  112896             :         memset(pointer, 0xCC, SgReadStatement::pool_size * sizeof(SgReadStatement));
  112897             : #endif
  112898           0 :         SgReadStatement::pools.push_back( (unsigned char*)(pointer) );
  112899           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgReadStatement::pool_size * sizeof(SgReadStatement), V_SgReadStatement ) );
  112900             : 
  112901           0 :         if ( SgReadStatement::next_node != NULL ) {
  112902           0 :           if ( blockIndex > 0 ) {
  112903           0 :             SgReadStatement * blkptr = (SgReadStatement*)(SgReadStatement::pools[blockIndex-1]);
  112904           0 :             blkptr[ SgReadStatement::pool_size - 1 ].set_freepointer(pointer);
  112905             :           }
  112906             :         } else {
  112907           0 :           SgReadStatement::next_node = pointer;
  112908             :         }
  112909             : 
  112910           0 :         for (unsigned i = 0; i < SgReadStatement::pool_size-1; ++i)
  112911             :            {
  112912           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  112913             :            }
  112914           0 :         pointer[ SgReadStatement::pool_size -1 ].set_freepointer(NULL);
  112915             : 
  112916           0 :         blockIndex++;
  112917             :       }
  112918           2 :   }
  112919             : 
  112920             : //############################################################################
  112921             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  112922             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  112923             :  * not compressed. However, that stuff is not yet implemented! 
  112924             :  */
  112925             : unsigned long
  112926           0 : SgReadStatement::getNumberOfLastValidPointer()
  112927             :    {
  112928           0 :       SgReadStatement* testPointer = (SgReadStatement*)(SgReadStatement::pools.back());
  112929           0 :       unsigned long localIndex = SgReadStatement::pool_size - 1;
  112930           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  112931             :          {
  112932           0 :            localIndex--;
  112933             :          }
  112934           0 :       return (localIndex + SgReadStatement::pool_size * (SgReadStatement::pools.size()-1));
  112935             :    }
  112936             : 
  112937             : //############################################################################
  112938             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  112939             :  * memory pool and initializes the data member in class SgReadStatementStroageClass
  112940             :  * from its counterpart of SgReadStatement. The return value is just for checking, 
  112941             :  * that the whole StorageClassArray is initialized!
  112942             :  */
  112943             : unsigned long
  112944           0 : SgReadStatement::initializeStorageClassArray( SgReadStatementStorageClass *storageArray )
  112945             :    {
  112946           0 :      unsigned long storageCounter = 0;
  112947           0 :      std::vector < unsigned char* > :: const_iterator block = SgReadStatement::pools.begin();
  112948           0 :      SgReadStatement* pointer = NULL;
  112949           0 :      while ( block != SgReadStatement::pools.end() ) {
  112950           0 :           pointer = (SgReadStatement*) (*block);
  112951           0 :           for ( unsigned i = 0; i < SgReadStatement::pool_size; ++i ) {
  112952           0 :                if ( pointer->get_freepointer() != NULL ) {
  112953           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  112954           0 :                  storageArray++;
  112955           0 :                  storageCounter++;
  112956             :                }
  112957           0 :                pointer++;
  112958             :              }
  112959           0 :            block++;
  112960             :         }
  112961           0 :      return storageCounter;
  112962             :    }
  112963             : 
  112964             : /* #line 112965 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  112965             : 
  112966             : 
  112967             : 
  112968             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  112969             : 
  112970             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  112971             : 
  112972             : //############################################################################
  112973             : /* JH (02/02/2006) Constructor of the IR node SgWriteStatement that takes its 
  112974             :  * corresponding StorageClass as parameter
  112975             :  */
  112976           0 : SgWriteStatement :: SgWriteStatement ( const SgWriteStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  112977             :    {
  112978             : 
  112979             : 
  112980             : /* #line 112981 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  112981             : 
  112982           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  112983           0 :      p_format =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_format) );
  112984           0 :      p_namelist =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_namelist) );
  112985           0 :      p_advance =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_advance) );
  112986           0 :      p_asynchronous =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_asynchronous) );
  112987           0 :      p_blank =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_blank) );
  112988           0 :      p_decimal =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_decimal) );
  112989           0 :      p_delim =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_delim) );
  112990           0 :      p_end =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end) );
  112991           0 :      p_eor =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_eor) );
  112992           0 :      p_id =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_id) );
  112993           0 :      p_pad =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pad) );
  112994           0 :      p_pos =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pos) );
  112995           0 :      p_rec =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_rec) );
  112996           0 :      p_round =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_round) );
  112997           0 :      p_sign =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_sign) );
  112998           0 :      p_size =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_size) );
  112999             : 
  113000             : 
  113001             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  113002             : 
  113003             : 
  113004           0 :    }
  113005             : 
  113006             : //############################################################################
  113007             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  113008             :  * within the working AST. 
  113009             :  */
  113010           0 : SgWriteStatement * SgWriteStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  113011           0 :      SgWriteStatement* returnPointer = NULL;
  113012           0 :      if ( globalIndex != 0 )
  113013             :         {
  113014             : 
  113015             : #if FILE_IO_EXTRA_CHECK
  113016           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgWriteStatement ) ) <= globalIndex ) ;
  113017           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWriteStatement + 1 ) ) );
  113018             : #endif
  113019           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWriteStatement )  
  113020           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgWriteStatement );
  113021           0 :           unsigned long positionInPool = localIndex % SgWriteStatement::pool_size;
  113022           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWriteStatement::pool_size;
  113023             : 
  113024             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  113025             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  113026             : 
  113027           0 :           returnPointer = &( ( (SgWriteStatement*)(SgWriteStatement::pools[memoryBlock]) ) [positionInPool]) ;
  113028             : 
  113029           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  113030             :         }
  113031           0 :      return returnPointer ;
  113032             :    }
  113033             : 
  113034             : //############################################################################
  113035             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  113036             :   for the AST with the index astIndex
  113037             : */
  113038           0 : SgWriteStatement * SgWriteStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  113039           0 :      SgWriteStatement* returnPointer = NULL;
  113040           0 :      if ( globalIndex != 0 )
  113041             :         {
  113042             : 
  113043             : #if FILE_IO_EXTRA_CHECK
  113044           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgWriteStatement ) ) <= globalIndex ) ;
  113045           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWriteStatement + 1 ) ) );
  113046             : #endif
  113047           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWriteStatement )
  113048           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgWriteStatement );
  113049           0 :           unsigned long positionInPool = localIndex % SgWriteStatement::pool_size ;
  113050           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWriteStatement::pool_size ;
  113051             : 
  113052             : #if FILE_IO_EXTRA_CHECK
  113053             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  113054             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  113055             : #endif
  113056             : 
  113057           0 :           returnPointer = &( ( (SgWriteStatement*)(SgWriteStatement::pools[memoryBlock]) ) [positionInPool]) ;
  113058             : 
  113059             : #if FILE_IO_EXTRA_CHECK
  113060           0 :           assert ( returnPointer != NULL ) ;
  113061             : #endif
  113062             :         }
  113063           0 :      return returnPointer ;
  113064             :    }
  113065             : 
  113066             : //############################################################################
  113067             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  113068             :  * pool size! We set for every valid object in the memory pool the freepointer
  113069             :  * to the global index and increase the global index afterwards. For all the 
  113070             :  * invalid objects (means address ranges within the memory pool that were not
  113071             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  113072             :  * distinguish valid from invalid objects! 
  113073             :  */
  113074             : unsigned long
  113075           5 : SgWriteStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  113076             :    {
  113077           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  113078           5 :      SgWriteStatement* pointer = NULL;
  113079           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  113080           5 :      std::vector < unsigned char* > :: const_iterator block;
  113081           5 :      for ( block = SgWriteStatement::pools.begin(); block != SgWriteStatement::pools.end() ; ++block )
  113082             :         {
  113083           0 :           pointer = (SgWriteStatement*)(*block);
  113084           0 :           for (unsigned i = 0; i < SgWriteStatement::pool_size; ++i )
  113085             :              {
  113086             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  113087             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  113088             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  113089             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  113090             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  113091             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  113092             :             // properly; so this will have to be checked next.
  113093             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  113094             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  113095           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  113096             :                   {
  113097           0 :                     pointer[i].set_freepointer((SgWriteStatement*)(globalIndex));
  113098           0 :                     globalIndex++;
  113099             :                   }
  113100             :                else
  113101             :                   {
  113102           0 :                     pointer[i].set_freepointer(NULL);
  113103             :                   }
  113104             :               }
  113105             :         }
  113106           5 :      return globalIndex;
  113107             :    }
  113108             : 
  113109             : //############################################################################
  113110             : // JH (01/14/2006)
  113111             : void
  113112           5 : SgWriteStatement::resetValidFreepointers( )
  113113             :    {
  113114           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  113115           5 :      SgWriteStatement* pointer = NULL;
  113116           5 :      std::vector < unsigned char* > :: const_iterator block;
  113117           5 :      SgWriteStatement* pointerOfLinkedList = NULL;
  113118           5 :      for ( block = SgWriteStatement::pools.begin(); block != SgWriteStatement::pools.end() ; ++block )
  113119             :         {
  113120           0 :           pointer = (SgWriteStatement*)(*block);
  113121           0 :           for (unsigned i = 0; i < SgWriteStatement::pool_size; ++i )
  113122             :              {
  113123             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  113124             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  113125             :             // memory blocks!.
  113126           0 :                if ( pointer[i].get_freepointer() != NULL )
  113127             :                   {
  113128           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  113129             :                   }
  113130             :                else
  113131             :                   {
  113132           0 :                     if ( pointerOfLinkedList == NULL )
  113133             :                        {
  113134           0 :                          SgWriteStatement::next_node = &(pointer[i]);
  113135             :                        }
  113136             :                     else
  113137             :                        {
  113138             :                       // printf ("In SgWriteStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  113139           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  113140             :                        }
  113141             :                     pointerOfLinkedList = &(pointer[i]);
  113142             :                   }
  113143             :               }
  113144             :         }
  113145             : 
  113146           5 :      if ( pointerOfLinkedList != NULL )
  113147             :         {
  113148             :        // printf ("In SgWriteStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  113149           0 :           pointerOfLinkedList->set_freepointer(NULL);
  113150             :        // DQ (6/6/2010): Temporary debugging...
  113151             :        //   ROSE_ASSERT(false);
  113152             :         }
  113153             : 
  113154           5 :      return ;
  113155             :    }
  113156             : 
  113157             : //############################################################################
  113158             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  113159             :  * within the memory pool and resets the freepointers, in order to achieve a 
  113160             :  * linked list, that has no jumps and starts at the beginning! This function 
  113161             :  * does not extend the memory pool, since we do not delete any memory blocks,
  113162             :  * but delete the valid objects.  
  113163             :  */
  113164             : void
  113165           0 : SgWriteStatement::clearMemoryPool( )
  113166             :    {
  113167             :   // printf ("Inside of SgWriteStatement::clearMemoryPool() \n");
  113168             : 
  113169           0 :      SgWriteStatement* pointer = NULL, *tempPointer = NULL;
  113170           0 :      std::vector < unsigned char* > :: const_iterator block;
  113171           0 :      if ( SgWriteStatement::pools.empty() == false )
  113172             :         {
  113173           0 :           block = SgWriteStatement::pools.begin() ;
  113174           0 :           SgWriteStatement::next_node = (SgWriteStatement*) (*block);
  113175             : 
  113176           0 :           while ( block != SgWriteStatement::pools.end() )
  113177             :              {
  113178           0 :                pointer = (SgWriteStatement*) (*block);
  113179           0 :                if ( tempPointer != NULL )
  113180             :                   {
  113181           0 :                     tempPointer->set_freepointer(pointer);
  113182             :                   }
  113183           0 :                for (unsigned i = 0; i < SgWriteStatement::pool_size - 1; ++i)
  113184             :                   {
  113185           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  113186             :                   }
  113187           0 :                 pointer[SgWriteStatement::pool_size-1].set_freepointer(NULL);
  113188           0 :                 tempPointer = &(pointer[SgWriteStatement::pool_size-1]);
  113189           0 :                 ++block;
  113190             :              }
  113191             :         }
  113192           0 :    }
  113193             : 
  113194           5 : void SgWriteStatement::deleteMemoryPool() {
  113195           5 :   for (auto p: SgWriteStatement::pools) {
  113196           0 :     ROSE_FREE(p);
  113197             :   }
  113198           5 :   SgWriteStatement::next_node = nullptr;
  113199           5 :   SgWriteStatement::pools.clear();
  113200           5 : }
  113201             : 
  113202             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  113203             : //                 reading multiple binary files to for a single AST.
  113204             : /////////// new version ////////////////////////////////
  113205             : //############################################################################
  113206             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  113207             : void
  113208           2 : SgWriteStatement::extendMemoryPoolForFileIO( )
  113209             :   {
  113210           2 :     size_t blockIndex = SgWriteStatement::pools.size();
  113211           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgWriteStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgWriteStatement);
  113212             : 
  113213           2 :     while ( (blockIndex * SgWriteStatement::pool_size) < newPoolSize)
  113214             :       {
  113215             : #if ROSE_ALLOC_TRACE
  113216             :         if (blockIndex > 0) {
  113217             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgWriteStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgWriteStatement) = %" PRIuPTR " SgWriteStatement::pool_size = %d \n",
  113218             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgWriteStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgWriteStatement),SgWriteStatement::pool_size);
  113219             :         }
  113220             : #endif
  113221             : 
  113222           0 :         SgWriteStatement * pointer = (SgWriteStatement*) ROSE_MALLOC ( SgWriteStatement::pool_size * sizeof(SgWriteStatement) );
  113223           0 :         assert( pointer != NULL );
  113224             : #if ROSE_ALLOC_MEMSET == 1
  113225             :         memset(pointer, 0x00, SgWriteStatement::pool_size * sizeof(SgWriteStatement));
  113226             : #elif ROSE_ALLOC_MEMSET == 2
  113227             :         memset(pointer, 0xCC, SgWriteStatement::pool_size * sizeof(SgWriteStatement));
  113228             : #endif
  113229           0 :         SgWriteStatement::pools.push_back( (unsigned char*)(pointer) );
  113230           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgWriteStatement::pool_size * sizeof(SgWriteStatement), V_SgWriteStatement ) );
  113231             : 
  113232           0 :         if ( SgWriteStatement::next_node != NULL ) {
  113233           0 :           if ( blockIndex > 0 ) {
  113234           0 :             SgWriteStatement * blkptr = (SgWriteStatement*)(SgWriteStatement::pools[blockIndex-1]);
  113235           0 :             blkptr[ SgWriteStatement::pool_size - 1 ].set_freepointer(pointer);
  113236             :           }
  113237             :         } else {
  113238           0 :           SgWriteStatement::next_node = pointer;
  113239             :         }
  113240             : 
  113241           0 :         for (unsigned i = 0; i < SgWriteStatement::pool_size-1; ++i)
  113242             :            {
  113243           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  113244             :            }
  113245           0 :         pointer[ SgWriteStatement::pool_size -1 ].set_freepointer(NULL);
  113246             : 
  113247           0 :         blockIndex++;
  113248             :       }
  113249           2 :   }
  113250             : 
  113251             : //############################################################################
  113252             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  113253             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  113254             :  * not compressed. However, that stuff is not yet implemented! 
  113255             :  */
  113256             : unsigned long
  113257           0 : SgWriteStatement::getNumberOfLastValidPointer()
  113258             :    {
  113259           0 :       SgWriteStatement* testPointer = (SgWriteStatement*)(SgWriteStatement::pools.back());
  113260           0 :       unsigned long localIndex = SgWriteStatement::pool_size - 1;
  113261           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  113262             :          {
  113263           0 :            localIndex--;
  113264             :          }
  113265           0 :       return (localIndex + SgWriteStatement::pool_size * (SgWriteStatement::pools.size()-1));
  113266             :    }
  113267             : 
  113268             : //############################################################################
  113269             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  113270             :  * memory pool and initializes the data member in class SgWriteStatementStroageClass
  113271             :  * from its counterpart of SgWriteStatement. The return value is just for checking, 
  113272             :  * that the whole StorageClassArray is initialized!
  113273             :  */
  113274             : unsigned long
  113275           0 : SgWriteStatement::initializeStorageClassArray( SgWriteStatementStorageClass *storageArray )
  113276             :    {
  113277           0 :      unsigned long storageCounter = 0;
  113278           0 :      std::vector < unsigned char* > :: const_iterator block = SgWriteStatement::pools.begin();
  113279           0 :      SgWriteStatement* pointer = NULL;
  113280           0 :      while ( block != SgWriteStatement::pools.end() ) {
  113281           0 :           pointer = (SgWriteStatement*) (*block);
  113282           0 :           for ( unsigned i = 0; i < SgWriteStatement::pool_size; ++i ) {
  113283           0 :                if ( pointer->get_freepointer() != NULL ) {
  113284           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  113285           0 :                  storageArray++;
  113286           0 :                  storageCounter++;
  113287             :                }
  113288           0 :                pointer++;
  113289             :              }
  113290           0 :            block++;
  113291             :         }
  113292           0 :      return storageCounter;
  113293             :    }
  113294             : 
  113295             : /* #line 113296 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  113296             : 
  113297             : 
  113298             : 
  113299             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  113300             : 
  113301             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  113302             : 
  113303             : //############################################################################
  113304             : /* JH (02/02/2006) Constructor of the IR node SgOpenStatement that takes its 
  113305             :  * corresponding StorageClass as parameter
  113306             :  */
  113307           0 : SgOpenStatement :: SgOpenStatement ( const SgOpenStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  113308             :    {
  113309             : 
  113310             : 
  113311             : /* #line 113312 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  113312             : 
  113313           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  113314           0 :      p_file =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_file) );
  113315           0 :      p_status =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_status) );
  113316           0 :      p_access =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_access) );
  113317           0 :      p_form =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_form) );
  113318           0 :      p_recl =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_recl) );
  113319           0 :      p_blank =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_blank) );
  113320           0 :      p_position =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_position) );
  113321           0 :      p_action =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_action) );
  113322           0 :      p_delim =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_delim) );
  113323           0 :      p_pad =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pad) );
  113324           0 :      p_round =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_round) );
  113325           0 :      p_sign =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_sign) );
  113326           0 :      p_asynchronous =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_asynchronous) );
  113327             : 
  113328             : 
  113329             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  113330             : 
  113331             : 
  113332           0 :    }
  113333             : 
  113334             : //############################################################################
  113335             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  113336             :  * within the working AST. 
  113337             :  */
  113338           0 : SgOpenStatement * SgOpenStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  113339           0 :      SgOpenStatement* returnPointer = NULL;
  113340           0 :      if ( globalIndex != 0 )
  113341             :         {
  113342             : 
  113343             : #if FILE_IO_EXTRA_CHECK
  113344           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOpenStatement ) ) <= globalIndex ) ;
  113345           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOpenStatement + 1 ) ) );
  113346             : #endif
  113347           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOpenStatement )  
  113348           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOpenStatement );
  113349           0 :           unsigned long positionInPool = localIndex % SgOpenStatement::pool_size;
  113350           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOpenStatement::pool_size;
  113351             : 
  113352             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  113353             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  113354             : 
  113355           0 :           returnPointer = &( ( (SgOpenStatement*)(SgOpenStatement::pools[memoryBlock]) ) [positionInPool]) ;
  113356             : 
  113357           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  113358             :         }
  113359           0 :      return returnPointer ;
  113360             :    }
  113361             : 
  113362             : //############################################################################
  113363             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  113364             :   for the AST with the index astIndex
  113365             : */
  113366           0 : SgOpenStatement * SgOpenStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  113367           0 :      SgOpenStatement* returnPointer = NULL;
  113368           0 :      if ( globalIndex != 0 )
  113369             :         {
  113370             : 
  113371             : #if FILE_IO_EXTRA_CHECK
  113372           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOpenStatement ) ) <= globalIndex ) ;
  113373           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOpenStatement + 1 ) ) );
  113374             : #endif
  113375           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOpenStatement )
  113376           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOpenStatement );
  113377           0 :           unsigned long positionInPool = localIndex % SgOpenStatement::pool_size ;
  113378           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOpenStatement::pool_size ;
  113379             : 
  113380             : #if FILE_IO_EXTRA_CHECK
  113381             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  113382             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  113383             : #endif
  113384             : 
  113385           0 :           returnPointer = &( ( (SgOpenStatement*)(SgOpenStatement::pools[memoryBlock]) ) [positionInPool]) ;
  113386             : 
  113387             : #if FILE_IO_EXTRA_CHECK
  113388           0 :           assert ( returnPointer != NULL ) ;
  113389             : #endif
  113390             :         }
  113391           0 :      return returnPointer ;
  113392             :    }
  113393             : 
  113394             : //############################################################################
  113395             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  113396             :  * pool size! We set for every valid object in the memory pool the freepointer
  113397             :  * to the global index and increase the global index afterwards. For all the 
  113398             :  * invalid objects (means address ranges within the memory pool that were not
  113399             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  113400             :  * distinguish valid from invalid objects! 
  113401             :  */
  113402             : unsigned long
  113403           5 : SgOpenStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  113404             :    {
  113405           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  113406           5 :      SgOpenStatement* pointer = NULL;
  113407           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  113408           5 :      std::vector < unsigned char* > :: const_iterator block;
  113409           5 :      for ( block = SgOpenStatement::pools.begin(); block != SgOpenStatement::pools.end() ; ++block )
  113410             :         {
  113411           0 :           pointer = (SgOpenStatement*)(*block);
  113412           0 :           for (unsigned i = 0; i < SgOpenStatement::pool_size; ++i )
  113413             :              {
  113414             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  113415             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  113416             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  113417             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  113418             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  113419             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  113420             :             // properly; so this will have to be checked next.
  113421             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  113422             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  113423           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  113424             :                   {
  113425           0 :                     pointer[i].set_freepointer((SgOpenStatement*)(globalIndex));
  113426           0 :                     globalIndex++;
  113427             :                   }
  113428             :                else
  113429             :                   {
  113430           0 :                     pointer[i].set_freepointer(NULL);
  113431             :                   }
  113432             :               }
  113433             :         }
  113434           5 :      return globalIndex;
  113435             :    }
  113436             : 
  113437             : //############################################################################
  113438             : // JH (01/14/2006)
  113439             : void
  113440           5 : SgOpenStatement::resetValidFreepointers( )
  113441             :    {
  113442           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  113443           5 :      SgOpenStatement* pointer = NULL;
  113444           5 :      std::vector < unsigned char* > :: const_iterator block;
  113445           5 :      SgOpenStatement* pointerOfLinkedList = NULL;
  113446           5 :      for ( block = SgOpenStatement::pools.begin(); block != SgOpenStatement::pools.end() ; ++block )
  113447             :         {
  113448           0 :           pointer = (SgOpenStatement*)(*block);
  113449           0 :           for (unsigned i = 0; i < SgOpenStatement::pool_size; ++i )
  113450             :              {
  113451             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  113452             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  113453             :             // memory blocks!.
  113454           0 :                if ( pointer[i].get_freepointer() != NULL )
  113455             :                   {
  113456           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  113457             :                   }
  113458             :                else
  113459             :                   {
  113460           0 :                     if ( pointerOfLinkedList == NULL )
  113461             :                        {
  113462           0 :                          SgOpenStatement::next_node = &(pointer[i]);
  113463             :                        }
  113464             :                     else
  113465             :                        {
  113466             :                       // printf ("In SgOpenStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  113467           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  113468             :                        }
  113469             :                     pointerOfLinkedList = &(pointer[i]);
  113470             :                   }
  113471             :               }
  113472             :         }
  113473             : 
  113474           5 :      if ( pointerOfLinkedList != NULL )
  113475             :         {
  113476             :        // printf ("In SgOpenStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  113477           0 :           pointerOfLinkedList->set_freepointer(NULL);
  113478             :        // DQ (6/6/2010): Temporary debugging...
  113479             :        //   ROSE_ASSERT(false);
  113480             :         }
  113481             : 
  113482           5 :      return ;
  113483             :    }
  113484             : 
  113485             : //############################################################################
  113486             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  113487             :  * within the memory pool and resets the freepointers, in order to achieve a 
  113488             :  * linked list, that has no jumps and starts at the beginning! This function 
  113489             :  * does not extend the memory pool, since we do not delete any memory blocks,
  113490             :  * but delete the valid objects.  
  113491             :  */
  113492             : void
  113493           0 : SgOpenStatement::clearMemoryPool( )
  113494             :    {
  113495             :   // printf ("Inside of SgOpenStatement::clearMemoryPool() \n");
  113496             : 
  113497           0 :      SgOpenStatement* pointer = NULL, *tempPointer = NULL;
  113498           0 :      std::vector < unsigned char* > :: const_iterator block;
  113499           0 :      if ( SgOpenStatement::pools.empty() == false )
  113500             :         {
  113501           0 :           block = SgOpenStatement::pools.begin() ;
  113502           0 :           SgOpenStatement::next_node = (SgOpenStatement*) (*block);
  113503             : 
  113504           0 :           while ( block != SgOpenStatement::pools.end() )
  113505             :              {
  113506           0 :                pointer = (SgOpenStatement*) (*block);
  113507           0 :                if ( tempPointer != NULL )
  113508             :                   {
  113509           0 :                     tempPointer->set_freepointer(pointer);
  113510             :                   }
  113511           0 :                for (unsigned i = 0; i < SgOpenStatement::pool_size - 1; ++i)
  113512             :                   {
  113513           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  113514             :                   }
  113515           0 :                 pointer[SgOpenStatement::pool_size-1].set_freepointer(NULL);
  113516           0 :                 tempPointer = &(pointer[SgOpenStatement::pool_size-1]);
  113517           0 :                 ++block;
  113518             :              }
  113519             :         }
  113520           0 :    }
  113521             : 
  113522           5 : void SgOpenStatement::deleteMemoryPool() {
  113523           5 :   for (auto p: SgOpenStatement::pools) {
  113524           0 :     ROSE_FREE(p);
  113525             :   }
  113526           5 :   SgOpenStatement::next_node = nullptr;
  113527           5 :   SgOpenStatement::pools.clear();
  113528           5 : }
  113529             : 
  113530             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  113531             : //                 reading multiple binary files to for a single AST.
  113532             : /////////// new version ////////////////////////////////
  113533             : //############################################################################
  113534             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  113535             : void
  113536           2 : SgOpenStatement::extendMemoryPoolForFileIO( )
  113537             :   {
  113538           2 :     size_t blockIndex = SgOpenStatement::pools.size();
  113539           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOpenStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOpenStatement);
  113540             : 
  113541           2 :     while ( (blockIndex * SgOpenStatement::pool_size) < newPoolSize)
  113542             :       {
  113543             : #if ROSE_ALLOC_TRACE
  113544             :         if (blockIndex > 0) {
  113545             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOpenStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOpenStatement) = %" PRIuPTR " SgOpenStatement::pool_size = %d \n",
  113546             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOpenStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOpenStatement),SgOpenStatement::pool_size);
  113547             :         }
  113548             : #endif
  113549             : 
  113550           0 :         SgOpenStatement * pointer = (SgOpenStatement*) ROSE_MALLOC ( SgOpenStatement::pool_size * sizeof(SgOpenStatement) );
  113551           0 :         assert( pointer != NULL );
  113552             : #if ROSE_ALLOC_MEMSET == 1
  113553             :         memset(pointer, 0x00, SgOpenStatement::pool_size * sizeof(SgOpenStatement));
  113554             : #elif ROSE_ALLOC_MEMSET == 2
  113555             :         memset(pointer, 0xCC, SgOpenStatement::pool_size * sizeof(SgOpenStatement));
  113556             : #endif
  113557           0 :         SgOpenStatement::pools.push_back( (unsigned char*)(pointer) );
  113558           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOpenStatement::pool_size * sizeof(SgOpenStatement), V_SgOpenStatement ) );
  113559             : 
  113560           0 :         if ( SgOpenStatement::next_node != NULL ) {
  113561           0 :           if ( blockIndex > 0 ) {
  113562           0 :             SgOpenStatement * blkptr = (SgOpenStatement*)(SgOpenStatement::pools[blockIndex-1]);
  113563           0 :             blkptr[ SgOpenStatement::pool_size - 1 ].set_freepointer(pointer);
  113564             :           }
  113565             :         } else {
  113566           0 :           SgOpenStatement::next_node = pointer;
  113567             :         }
  113568             : 
  113569           0 :         for (unsigned i = 0; i < SgOpenStatement::pool_size-1; ++i)
  113570             :            {
  113571           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  113572             :            }
  113573           0 :         pointer[ SgOpenStatement::pool_size -1 ].set_freepointer(NULL);
  113574             : 
  113575           0 :         blockIndex++;
  113576             :       }
  113577           2 :   }
  113578             : 
  113579             : //############################################################################
  113580             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  113581             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  113582             :  * not compressed. However, that stuff is not yet implemented! 
  113583             :  */
  113584             : unsigned long
  113585           0 : SgOpenStatement::getNumberOfLastValidPointer()
  113586             :    {
  113587           0 :       SgOpenStatement* testPointer = (SgOpenStatement*)(SgOpenStatement::pools.back());
  113588           0 :       unsigned long localIndex = SgOpenStatement::pool_size - 1;
  113589           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  113590             :          {
  113591           0 :            localIndex--;
  113592             :          }
  113593           0 :       return (localIndex + SgOpenStatement::pool_size * (SgOpenStatement::pools.size()-1));
  113594             :    }
  113595             : 
  113596             : //############################################################################
  113597             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  113598             :  * memory pool and initializes the data member in class SgOpenStatementStroageClass
  113599             :  * from its counterpart of SgOpenStatement. The return value is just for checking, 
  113600             :  * that the whole StorageClassArray is initialized!
  113601             :  */
  113602             : unsigned long
  113603           0 : SgOpenStatement::initializeStorageClassArray( SgOpenStatementStorageClass *storageArray )
  113604             :    {
  113605           0 :      unsigned long storageCounter = 0;
  113606           0 :      std::vector < unsigned char* > :: const_iterator block = SgOpenStatement::pools.begin();
  113607           0 :      SgOpenStatement* pointer = NULL;
  113608           0 :      while ( block != SgOpenStatement::pools.end() ) {
  113609           0 :           pointer = (SgOpenStatement*) (*block);
  113610           0 :           for ( unsigned i = 0; i < SgOpenStatement::pool_size; ++i ) {
  113611           0 :                if ( pointer->get_freepointer() != NULL ) {
  113612           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  113613           0 :                  storageArray++;
  113614           0 :                  storageCounter++;
  113615             :                }
  113616           0 :                pointer++;
  113617             :              }
  113618           0 :            block++;
  113619             :         }
  113620           0 :      return storageCounter;
  113621             :    }
  113622             : 
  113623             : /* #line 113624 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  113624             : 
  113625             : 
  113626             : 
  113627             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  113628             : 
  113629             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  113630             : 
  113631             : //############################################################################
  113632             : /* JH (02/02/2006) Constructor of the IR node SgCloseStatement that takes its 
  113633             :  * corresponding StorageClass as parameter
  113634             :  */
  113635           0 : SgCloseStatement :: SgCloseStatement ( const SgCloseStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  113636             :    {
  113637             : 
  113638             : 
  113639             : /* #line 113640 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  113640             : 
  113641           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  113642           0 :      p_status =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_status) );
  113643             : 
  113644             : 
  113645             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  113646             : 
  113647             : 
  113648           0 :    }
  113649             : 
  113650             : //############################################################################
  113651             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  113652             :  * within the working AST. 
  113653             :  */
  113654           0 : SgCloseStatement * SgCloseStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  113655           0 :      SgCloseStatement* returnPointer = NULL;
  113656           0 :      if ( globalIndex != 0 )
  113657             :         {
  113658             : 
  113659             : #if FILE_IO_EXTRA_CHECK
  113660           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCloseStatement ) ) <= globalIndex ) ;
  113661           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCloseStatement + 1 ) ) );
  113662             : #endif
  113663           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCloseStatement )  
  113664           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCloseStatement );
  113665           0 :           unsigned long positionInPool = localIndex % SgCloseStatement::pool_size;
  113666           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCloseStatement::pool_size;
  113667             : 
  113668             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  113669             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  113670             : 
  113671           0 :           returnPointer = &( ( (SgCloseStatement*)(SgCloseStatement::pools[memoryBlock]) ) [positionInPool]) ;
  113672             : 
  113673           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  113674             :         }
  113675           0 :      return returnPointer ;
  113676             :    }
  113677             : 
  113678             : //############################################################################
  113679             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  113680             :   for the AST with the index astIndex
  113681             : */
  113682           0 : SgCloseStatement * SgCloseStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  113683           0 :      SgCloseStatement* returnPointer = NULL;
  113684           0 :      if ( globalIndex != 0 )
  113685             :         {
  113686             : 
  113687             : #if FILE_IO_EXTRA_CHECK
  113688           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCloseStatement ) ) <= globalIndex ) ;
  113689           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCloseStatement + 1 ) ) );
  113690             : #endif
  113691           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCloseStatement )
  113692           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCloseStatement );
  113693           0 :           unsigned long positionInPool = localIndex % SgCloseStatement::pool_size ;
  113694           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCloseStatement::pool_size ;
  113695             : 
  113696             : #if FILE_IO_EXTRA_CHECK
  113697             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  113698             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  113699             : #endif
  113700             : 
  113701           0 :           returnPointer = &( ( (SgCloseStatement*)(SgCloseStatement::pools[memoryBlock]) ) [positionInPool]) ;
  113702             : 
  113703             : #if FILE_IO_EXTRA_CHECK
  113704           0 :           assert ( returnPointer != NULL ) ;
  113705             : #endif
  113706             :         }
  113707           0 :      return returnPointer ;
  113708             :    }
  113709             : 
  113710             : //############################################################################
  113711             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  113712             :  * pool size! We set for every valid object in the memory pool the freepointer
  113713             :  * to the global index and increase the global index afterwards. For all the 
  113714             :  * invalid objects (means address ranges within the memory pool that were not
  113715             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  113716             :  * distinguish valid from invalid objects! 
  113717             :  */
  113718             : unsigned long
  113719           5 : SgCloseStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  113720             :    {
  113721           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  113722           5 :      SgCloseStatement* pointer = NULL;
  113723           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  113724           5 :      std::vector < unsigned char* > :: const_iterator block;
  113725           5 :      for ( block = SgCloseStatement::pools.begin(); block != SgCloseStatement::pools.end() ; ++block )
  113726             :         {
  113727           0 :           pointer = (SgCloseStatement*)(*block);
  113728           0 :           for (unsigned i = 0; i < SgCloseStatement::pool_size; ++i )
  113729             :              {
  113730             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  113731             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  113732             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  113733             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  113734             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  113735             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  113736             :             // properly; so this will have to be checked next.
  113737             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  113738             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  113739           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  113740             :                   {
  113741           0 :                     pointer[i].set_freepointer((SgCloseStatement*)(globalIndex));
  113742           0 :                     globalIndex++;
  113743             :                   }
  113744             :                else
  113745             :                   {
  113746           0 :                     pointer[i].set_freepointer(NULL);
  113747             :                   }
  113748             :               }
  113749             :         }
  113750           5 :      return globalIndex;
  113751             :    }
  113752             : 
  113753             : //############################################################################
  113754             : // JH (01/14/2006)
  113755             : void
  113756           5 : SgCloseStatement::resetValidFreepointers( )
  113757             :    {
  113758           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  113759           5 :      SgCloseStatement* pointer = NULL;
  113760           5 :      std::vector < unsigned char* > :: const_iterator block;
  113761           5 :      SgCloseStatement* pointerOfLinkedList = NULL;
  113762           5 :      for ( block = SgCloseStatement::pools.begin(); block != SgCloseStatement::pools.end() ; ++block )
  113763             :         {
  113764           0 :           pointer = (SgCloseStatement*)(*block);
  113765           0 :           for (unsigned i = 0; i < SgCloseStatement::pool_size; ++i )
  113766             :              {
  113767             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  113768             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  113769             :             // memory blocks!.
  113770           0 :                if ( pointer[i].get_freepointer() != NULL )
  113771             :                   {
  113772           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  113773             :                   }
  113774             :                else
  113775             :                   {
  113776           0 :                     if ( pointerOfLinkedList == NULL )
  113777             :                        {
  113778           0 :                          SgCloseStatement::next_node = &(pointer[i]);
  113779             :                        }
  113780             :                     else
  113781             :                        {
  113782             :                       // printf ("In SgCloseStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  113783           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  113784             :                        }
  113785             :                     pointerOfLinkedList = &(pointer[i]);
  113786             :                   }
  113787             :               }
  113788             :         }
  113789             : 
  113790           5 :      if ( pointerOfLinkedList != NULL )
  113791             :         {
  113792             :        // printf ("In SgCloseStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  113793           0 :           pointerOfLinkedList->set_freepointer(NULL);
  113794             :        // DQ (6/6/2010): Temporary debugging...
  113795             :        //   ROSE_ASSERT(false);
  113796             :         }
  113797             : 
  113798           5 :      return ;
  113799             :    }
  113800             : 
  113801             : //############################################################################
  113802             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  113803             :  * within the memory pool and resets the freepointers, in order to achieve a 
  113804             :  * linked list, that has no jumps and starts at the beginning! This function 
  113805             :  * does not extend the memory pool, since we do not delete any memory blocks,
  113806             :  * but delete the valid objects.  
  113807             :  */
  113808             : void
  113809           0 : SgCloseStatement::clearMemoryPool( )
  113810             :    {
  113811             :   // printf ("Inside of SgCloseStatement::clearMemoryPool() \n");
  113812             : 
  113813           0 :      SgCloseStatement* pointer = NULL, *tempPointer = NULL;
  113814           0 :      std::vector < unsigned char* > :: const_iterator block;
  113815           0 :      if ( SgCloseStatement::pools.empty() == false )
  113816             :         {
  113817           0 :           block = SgCloseStatement::pools.begin() ;
  113818           0 :           SgCloseStatement::next_node = (SgCloseStatement*) (*block);
  113819             : 
  113820           0 :           while ( block != SgCloseStatement::pools.end() )
  113821             :              {
  113822           0 :                pointer = (SgCloseStatement*) (*block);
  113823           0 :                if ( tempPointer != NULL )
  113824             :                   {
  113825           0 :                     tempPointer->set_freepointer(pointer);
  113826             :                   }
  113827           0 :                for (unsigned i = 0; i < SgCloseStatement::pool_size - 1; ++i)
  113828             :                   {
  113829           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  113830             :                   }
  113831           0 :                 pointer[SgCloseStatement::pool_size-1].set_freepointer(NULL);
  113832           0 :                 tempPointer = &(pointer[SgCloseStatement::pool_size-1]);
  113833           0 :                 ++block;
  113834             :              }
  113835             :         }
  113836           0 :    }
  113837             : 
  113838           5 : void SgCloseStatement::deleteMemoryPool() {
  113839           5 :   for (auto p: SgCloseStatement::pools) {
  113840           0 :     ROSE_FREE(p);
  113841             :   }
  113842           5 :   SgCloseStatement::next_node = nullptr;
  113843           5 :   SgCloseStatement::pools.clear();
  113844           5 : }
  113845             : 
  113846             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  113847             : //                 reading multiple binary files to for a single AST.
  113848             : /////////// new version ////////////////////////////////
  113849             : //############################################################################
  113850             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  113851             : void
  113852           2 : SgCloseStatement::extendMemoryPoolForFileIO( )
  113853             :   {
  113854           2 :     size_t blockIndex = SgCloseStatement::pools.size();
  113855           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCloseStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCloseStatement);
  113856             : 
  113857           2 :     while ( (blockIndex * SgCloseStatement::pool_size) < newPoolSize)
  113858             :       {
  113859             : #if ROSE_ALLOC_TRACE
  113860             :         if (blockIndex > 0) {
  113861             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCloseStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCloseStatement) = %" PRIuPTR " SgCloseStatement::pool_size = %d \n",
  113862             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCloseStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCloseStatement),SgCloseStatement::pool_size);
  113863             :         }
  113864             : #endif
  113865             : 
  113866           0 :         SgCloseStatement * pointer = (SgCloseStatement*) ROSE_MALLOC ( SgCloseStatement::pool_size * sizeof(SgCloseStatement) );
  113867           0 :         assert( pointer != NULL );
  113868             : #if ROSE_ALLOC_MEMSET == 1
  113869             :         memset(pointer, 0x00, SgCloseStatement::pool_size * sizeof(SgCloseStatement));
  113870             : #elif ROSE_ALLOC_MEMSET == 2
  113871             :         memset(pointer, 0xCC, SgCloseStatement::pool_size * sizeof(SgCloseStatement));
  113872             : #endif
  113873           0 :         SgCloseStatement::pools.push_back( (unsigned char*)(pointer) );
  113874           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCloseStatement::pool_size * sizeof(SgCloseStatement), V_SgCloseStatement ) );
  113875             : 
  113876           0 :         if ( SgCloseStatement::next_node != NULL ) {
  113877           0 :           if ( blockIndex > 0 ) {
  113878           0 :             SgCloseStatement * blkptr = (SgCloseStatement*)(SgCloseStatement::pools[blockIndex-1]);
  113879           0 :             blkptr[ SgCloseStatement::pool_size - 1 ].set_freepointer(pointer);
  113880             :           }
  113881             :         } else {
  113882           0 :           SgCloseStatement::next_node = pointer;
  113883             :         }
  113884             : 
  113885           0 :         for (unsigned i = 0; i < SgCloseStatement::pool_size-1; ++i)
  113886             :            {
  113887           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  113888             :            }
  113889           0 :         pointer[ SgCloseStatement::pool_size -1 ].set_freepointer(NULL);
  113890             : 
  113891           0 :         blockIndex++;
  113892             :       }
  113893           2 :   }
  113894             : 
  113895             : //############################################################################
  113896             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  113897             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  113898             :  * not compressed. However, that stuff is not yet implemented! 
  113899             :  */
  113900             : unsigned long
  113901           0 : SgCloseStatement::getNumberOfLastValidPointer()
  113902             :    {
  113903           0 :       SgCloseStatement* testPointer = (SgCloseStatement*)(SgCloseStatement::pools.back());
  113904           0 :       unsigned long localIndex = SgCloseStatement::pool_size - 1;
  113905           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  113906             :          {
  113907           0 :            localIndex--;
  113908             :          }
  113909           0 :       return (localIndex + SgCloseStatement::pool_size * (SgCloseStatement::pools.size()-1));
  113910             :    }
  113911             : 
  113912             : //############################################################################
  113913             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  113914             :  * memory pool and initializes the data member in class SgCloseStatementStroageClass
  113915             :  * from its counterpart of SgCloseStatement. The return value is just for checking, 
  113916             :  * that the whole StorageClassArray is initialized!
  113917             :  */
  113918             : unsigned long
  113919           0 : SgCloseStatement::initializeStorageClassArray( SgCloseStatementStorageClass *storageArray )
  113920             :    {
  113921           0 :      unsigned long storageCounter = 0;
  113922           0 :      std::vector < unsigned char* > :: const_iterator block = SgCloseStatement::pools.begin();
  113923           0 :      SgCloseStatement* pointer = NULL;
  113924           0 :      while ( block != SgCloseStatement::pools.end() ) {
  113925           0 :           pointer = (SgCloseStatement*) (*block);
  113926           0 :           for ( unsigned i = 0; i < SgCloseStatement::pool_size; ++i ) {
  113927           0 :                if ( pointer->get_freepointer() != NULL ) {
  113928           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  113929           0 :                  storageArray++;
  113930           0 :                  storageCounter++;
  113931             :                }
  113932           0 :                pointer++;
  113933             :              }
  113934           0 :            block++;
  113935             :         }
  113936           0 :      return storageCounter;
  113937             :    }
  113938             : 
  113939             : /* #line 113940 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  113940             : 
  113941             : 
  113942             : 
  113943             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  113944             : 
  113945             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  113946             : 
  113947             : //############################################################################
  113948             : /* JH (02/02/2006) Constructor of the IR node SgInquireStatement that takes its 
  113949             :  * corresponding StorageClass as parameter
  113950             :  */
  113951           0 : SgInquireStatement :: SgInquireStatement ( const SgInquireStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  113952             :    {
  113953             : 
  113954             : 
  113955             : /* #line 113956 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  113956             : 
  113957           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  113958           0 :      p_file =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_file) );
  113959           0 :      p_access =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_access) );
  113960           0 :      p_form =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_form) );
  113961           0 :      p_recl =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_recl) );
  113962           0 :      p_blank =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_blank) );
  113963           0 :      p_exist =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_exist) );
  113964           0 :      p_opened =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_opened) );
  113965           0 :      p_number =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_number) );
  113966           0 :      p_named =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_named) );
  113967           0 :      p_name =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_name) );
  113968           0 :      p_sequential =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_sequential) );
  113969           0 :      p_direct =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_direct) );
  113970           0 :      p_formatted =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_formatted) );
  113971           0 :      p_unformatted =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_unformatted) );
  113972           0 :      p_nextrec =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nextrec) );
  113973           0 :      p_position =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_position) );
  113974           0 :      p_action =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_action) );
  113975           0 :      p_read =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_read) );
  113976           0 :      p_write =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_write) );
  113977           0 :      p_readwrite =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_readwrite) );
  113978           0 :      p_delim =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_delim) );
  113979           0 :      p_pad =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pad) );
  113980           0 :      p_asynchronous =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_asynchronous) );
  113981           0 :      p_decimal =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_decimal) );
  113982           0 :      p_stream =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_stream) );
  113983           0 :      p_size =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_size) );
  113984           0 :      p_pending =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pending) );
  113985           0 :      p_iolengthExp =  (SgVarRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_iolengthExp) );
  113986             : 
  113987             : 
  113988             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  113989             : 
  113990             : 
  113991           0 :    }
  113992             : 
  113993             : //############################################################################
  113994             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  113995             :  * within the working AST. 
  113996             :  */
  113997           0 : SgInquireStatement * SgInquireStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  113998           0 :      SgInquireStatement* returnPointer = NULL;
  113999           0 :      if ( globalIndex != 0 )
  114000             :         {
  114001             : 
  114002             : #if FILE_IO_EXTRA_CHECK
  114003           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgInquireStatement ) ) <= globalIndex ) ;
  114004           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInquireStatement + 1 ) ) );
  114005             : #endif
  114006           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInquireStatement )  
  114007           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgInquireStatement );
  114008           0 :           unsigned long positionInPool = localIndex % SgInquireStatement::pool_size;
  114009           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInquireStatement::pool_size;
  114010             : 
  114011             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  114012             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  114013             : 
  114014           0 :           returnPointer = &( ( (SgInquireStatement*)(SgInquireStatement::pools[memoryBlock]) ) [positionInPool]) ;
  114015             : 
  114016           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  114017             :         }
  114018           0 :      return returnPointer ;
  114019             :    }
  114020             : 
  114021             : //############################################################################
  114022             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  114023             :   for the AST with the index astIndex
  114024             : */
  114025           0 : SgInquireStatement * SgInquireStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  114026           0 :      SgInquireStatement* returnPointer = NULL;
  114027           0 :      if ( globalIndex != 0 )
  114028             :         {
  114029             : 
  114030             : #if FILE_IO_EXTRA_CHECK
  114031           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgInquireStatement ) ) <= globalIndex ) ;
  114032           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInquireStatement + 1 ) ) );
  114033             : #endif
  114034           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInquireStatement )
  114035           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgInquireStatement );
  114036           0 :           unsigned long positionInPool = localIndex % SgInquireStatement::pool_size ;
  114037           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInquireStatement::pool_size ;
  114038             : 
  114039             : #if FILE_IO_EXTRA_CHECK
  114040             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  114041             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  114042             : #endif
  114043             : 
  114044           0 :           returnPointer = &( ( (SgInquireStatement*)(SgInquireStatement::pools[memoryBlock]) ) [positionInPool]) ;
  114045             : 
  114046             : #if FILE_IO_EXTRA_CHECK
  114047           0 :           assert ( returnPointer != NULL ) ;
  114048             : #endif
  114049             :         }
  114050           0 :      return returnPointer ;
  114051             :    }
  114052             : 
  114053             : //############################################################################
  114054             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  114055             :  * pool size! We set for every valid object in the memory pool the freepointer
  114056             :  * to the global index and increase the global index afterwards. For all the 
  114057             :  * invalid objects (means address ranges within the memory pool that were not
  114058             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  114059             :  * distinguish valid from invalid objects! 
  114060             :  */
  114061             : unsigned long
  114062           5 : SgInquireStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  114063             :    {
  114064           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  114065           5 :      SgInquireStatement* pointer = NULL;
  114066           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  114067           5 :      std::vector < unsigned char* > :: const_iterator block;
  114068           5 :      for ( block = SgInquireStatement::pools.begin(); block != SgInquireStatement::pools.end() ; ++block )
  114069             :         {
  114070           0 :           pointer = (SgInquireStatement*)(*block);
  114071           0 :           for (unsigned i = 0; i < SgInquireStatement::pool_size; ++i )
  114072             :              {
  114073             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  114074             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  114075             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  114076             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  114077             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  114078             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  114079             :             // properly; so this will have to be checked next.
  114080             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  114081             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  114082           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  114083             :                   {
  114084           0 :                     pointer[i].set_freepointer((SgInquireStatement*)(globalIndex));
  114085           0 :                     globalIndex++;
  114086             :                   }
  114087             :                else
  114088             :                   {
  114089           0 :                     pointer[i].set_freepointer(NULL);
  114090             :                   }
  114091             :               }
  114092             :         }
  114093           5 :      return globalIndex;
  114094             :    }
  114095             : 
  114096             : //############################################################################
  114097             : // JH (01/14/2006)
  114098             : void
  114099           5 : SgInquireStatement::resetValidFreepointers( )
  114100             :    {
  114101           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  114102           5 :      SgInquireStatement* pointer = NULL;
  114103           5 :      std::vector < unsigned char* > :: const_iterator block;
  114104           5 :      SgInquireStatement* pointerOfLinkedList = NULL;
  114105           5 :      for ( block = SgInquireStatement::pools.begin(); block != SgInquireStatement::pools.end() ; ++block )
  114106             :         {
  114107           0 :           pointer = (SgInquireStatement*)(*block);
  114108           0 :           for (unsigned i = 0; i < SgInquireStatement::pool_size; ++i )
  114109             :              {
  114110             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  114111             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  114112             :             // memory blocks!.
  114113           0 :                if ( pointer[i].get_freepointer() != NULL )
  114114             :                   {
  114115           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  114116             :                   }
  114117             :                else
  114118             :                   {
  114119           0 :                     if ( pointerOfLinkedList == NULL )
  114120             :                        {
  114121           0 :                          SgInquireStatement::next_node = &(pointer[i]);
  114122             :                        }
  114123             :                     else
  114124             :                        {
  114125             :                       // printf ("In SgInquireStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  114126           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  114127             :                        }
  114128             :                     pointerOfLinkedList = &(pointer[i]);
  114129             :                   }
  114130             :               }
  114131             :         }
  114132             : 
  114133           5 :      if ( pointerOfLinkedList != NULL )
  114134             :         {
  114135             :        // printf ("In SgInquireStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  114136           0 :           pointerOfLinkedList->set_freepointer(NULL);
  114137             :        // DQ (6/6/2010): Temporary debugging...
  114138             :        //   ROSE_ASSERT(false);
  114139             :         }
  114140             : 
  114141           5 :      return ;
  114142             :    }
  114143             : 
  114144             : //############################################################################
  114145             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  114146             :  * within the memory pool and resets the freepointers, in order to achieve a 
  114147             :  * linked list, that has no jumps and starts at the beginning! This function 
  114148             :  * does not extend the memory pool, since we do not delete any memory blocks,
  114149             :  * but delete the valid objects.  
  114150             :  */
  114151             : void
  114152           0 : SgInquireStatement::clearMemoryPool( )
  114153             :    {
  114154             :   // printf ("Inside of SgInquireStatement::clearMemoryPool() \n");
  114155             : 
  114156           0 :      SgInquireStatement* pointer = NULL, *tempPointer = NULL;
  114157           0 :      std::vector < unsigned char* > :: const_iterator block;
  114158           0 :      if ( SgInquireStatement::pools.empty() == false )
  114159             :         {
  114160           0 :           block = SgInquireStatement::pools.begin() ;
  114161           0 :           SgInquireStatement::next_node = (SgInquireStatement*) (*block);
  114162             : 
  114163           0 :           while ( block != SgInquireStatement::pools.end() )
  114164             :              {
  114165           0 :                pointer = (SgInquireStatement*) (*block);
  114166           0 :                if ( tempPointer != NULL )
  114167             :                   {
  114168           0 :                     tempPointer->set_freepointer(pointer);
  114169             :                   }
  114170           0 :                for (unsigned i = 0; i < SgInquireStatement::pool_size - 1; ++i)
  114171             :                   {
  114172           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  114173             :                   }
  114174           0 :                 pointer[SgInquireStatement::pool_size-1].set_freepointer(NULL);
  114175           0 :                 tempPointer = &(pointer[SgInquireStatement::pool_size-1]);
  114176           0 :                 ++block;
  114177             :              }
  114178             :         }
  114179           0 :    }
  114180             : 
  114181           5 : void SgInquireStatement::deleteMemoryPool() {
  114182           5 :   for (auto p: SgInquireStatement::pools) {
  114183           0 :     ROSE_FREE(p);
  114184             :   }
  114185           5 :   SgInquireStatement::next_node = nullptr;
  114186           5 :   SgInquireStatement::pools.clear();
  114187           5 : }
  114188             : 
  114189             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  114190             : //                 reading multiple binary files to for a single AST.
  114191             : /////////// new version ////////////////////////////////
  114192             : //############################################################################
  114193             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  114194             : void
  114195           2 : SgInquireStatement::extendMemoryPoolForFileIO( )
  114196             :   {
  114197           2 :     size_t blockIndex = SgInquireStatement::pools.size();
  114198           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgInquireStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgInquireStatement);
  114199             : 
  114200           2 :     while ( (blockIndex * SgInquireStatement::pool_size) < newPoolSize)
  114201             :       {
  114202             : #if ROSE_ALLOC_TRACE
  114203             :         if (blockIndex > 0) {
  114204             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgInquireStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgInquireStatement) = %" PRIuPTR " SgInquireStatement::pool_size = %d \n",
  114205             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgInquireStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgInquireStatement),SgInquireStatement::pool_size);
  114206             :         }
  114207             : #endif
  114208             : 
  114209           0 :         SgInquireStatement * pointer = (SgInquireStatement*) ROSE_MALLOC ( SgInquireStatement::pool_size * sizeof(SgInquireStatement) );
  114210           0 :         assert( pointer != NULL );
  114211             : #if ROSE_ALLOC_MEMSET == 1
  114212             :         memset(pointer, 0x00, SgInquireStatement::pool_size * sizeof(SgInquireStatement));
  114213             : #elif ROSE_ALLOC_MEMSET == 2
  114214             :         memset(pointer, 0xCC, SgInquireStatement::pool_size * sizeof(SgInquireStatement));
  114215             : #endif
  114216           0 :         SgInquireStatement::pools.push_back( (unsigned char*)(pointer) );
  114217           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgInquireStatement::pool_size * sizeof(SgInquireStatement), V_SgInquireStatement ) );
  114218             : 
  114219           0 :         if ( SgInquireStatement::next_node != NULL ) {
  114220           0 :           if ( blockIndex > 0 ) {
  114221           0 :             SgInquireStatement * blkptr = (SgInquireStatement*)(SgInquireStatement::pools[blockIndex-1]);
  114222           0 :             blkptr[ SgInquireStatement::pool_size - 1 ].set_freepointer(pointer);
  114223             :           }
  114224             :         } else {
  114225           0 :           SgInquireStatement::next_node = pointer;
  114226             :         }
  114227             : 
  114228           0 :         for (unsigned i = 0; i < SgInquireStatement::pool_size-1; ++i)
  114229             :            {
  114230           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  114231             :            }
  114232           0 :         pointer[ SgInquireStatement::pool_size -1 ].set_freepointer(NULL);
  114233             : 
  114234           0 :         blockIndex++;
  114235             :       }
  114236           2 :   }
  114237             : 
  114238             : //############################################################################
  114239             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  114240             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  114241             :  * not compressed. However, that stuff is not yet implemented! 
  114242             :  */
  114243             : unsigned long
  114244           0 : SgInquireStatement::getNumberOfLastValidPointer()
  114245             :    {
  114246           0 :       SgInquireStatement* testPointer = (SgInquireStatement*)(SgInquireStatement::pools.back());
  114247           0 :       unsigned long localIndex = SgInquireStatement::pool_size - 1;
  114248           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  114249             :          {
  114250           0 :            localIndex--;
  114251             :          }
  114252           0 :       return (localIndex + SgInquireStatement::pool_size * (SgInquireStatement::pools.size()-1));
  114253             :    }
  114254             : 
  114255             : //############################################################################
  114256             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  114257             :  * memory pool and initializes the data member in class SgInquireStatementStroageClass
  114258             :  * from its counterpart of SgInquireStatement. The return value is just for checking, 
  114259             :  * that the whole StorageClassArray is initialized!
  114260             :  */
  114261             : unsigned long
  114262           0 : SgInquireStatement::initializeStorageClassArray( SgInquireStatementStorageClass *storageArray )
  114263             :    {
  114264           0 :      unsigned long storageCounter = 0;
  114265           0 :      std::vector < unsigned char* > :: const_iterator block = SgInquireStatement::pools.begin();
  114266           0 :      SgInquireStatement* pointer = NULL;
  114267           0 :      while ( block != SgInquireStatement::pools.end() ) {
  114268           0 :           pointer = (SgInquireStatement*) (*block);
  114269           0 :           for ( unsigned i = 0; i < SgInquireStatement::pool_size; ++i ) {
  114270           0 :                if ( pointer->get_freepointer() != NULL ) {
  114271           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  114272           0 :                  storageArray++;
  114273           0 :                  storageCounter++;
  114274             :                }
  114275           0 :                pointer++;
  114276             :              }
  114277           0 :            block++;
  114278             :         }
  114279           0 :      return storageCounter;
  114280             :    }
  114281             : 
  114282             : /* #line 114283 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  114283             : 
  114284             : 
  114285             : 
  114286             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  114287             : 
  114288             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  114289             : 
  114290             : //############################################################################
  114291             : /* JH (02/02/2006) Constructor of the IR node SgFlushStatement that takes its 
  114292             :  * corresponding StorageClass as parameter
  114293             :  */
  114294           0 : SgFlushStatement :: SgFlushStatement ( const SgFlushStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  114295             :    {
  114296             : 
  114297             : 
  114298             : /* #line 114299 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  114299             : 
  114300           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  114301             : 
  114302             : 
  114303             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  114304             : 
  114305             : 
  114306           0 :    }
  114307             : 
  114308             : //############################################################################
  114309             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  114310             :  * within the working AST. 
  114311             :  */
  114312           0 : SgFlushStatement * SgFlushStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  114313           0 :      SgFlushStatement* returnPointer = NULL;
  114314           0 :      if ( globalIndex != 0 )
  114315             :         {
  114316             : 
  114317             : #if FILE_IO_EXTRA_CHECK
  114318           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFlushStatement ) ) <= globalIndex ) ;
  114319           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFlushStatement + 1 ) ) );
  114320             : #endif
  114321           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFlushStatement )  
  114322           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFlushStatement );
  114323           0 :           unsigned long positionInPool = localIndex % SgFlushStatement::pool_size;
  114324           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFlushStatement::pool_size;
  114325             : 
  114326             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  114327             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  114328             : 
  114329           0 :           returnPointer = &( ( (SgFlushStatement*)(SgFlushStatement::pools[memoryBlock]) ) [positionInPool]) ;
  114330             : 
  114331           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  114332             :         }
  114333           0 :      return returnPointer ;
  114334             :    }
  114335             : 
  114336             : //############################################################################
  114337             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  114338             :   for the AST with the index astIndex
  114339             : */
  114340           0 : SgFlushStatement * SgFlushStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  114341           0 :      SgFlushStatement* returnPointer = NULL;
  114342           0 :      if ( globalIndex != 0 )
  114343             :         {
  114344             : 
  114345             : #if FILE_IO_EXTRA_CHECK
  114346           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFlushStatement ) ) <= globalIndex ) ;
  114347           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFlushStatement + 1 ) ) );
  114348             : #endif
  114349           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFlushStatement )
  114350           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFlushStatement );
  114351           0 :           unsigned long positionInPool = localIndex % SgFlushStatement::pool_size ;
  114352           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFlushStatement::pool_size ;
  114353             : 
  114354             : #if FILE_IO_EXTRA_CHECK
  114355             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  114356             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  114357             : #endif
  114358             : 
  114359           0 :           returnPointer = &( ( (SgFlushStatement*)(SgFlushStatement::pools[memoryBlock]) ) [positionInPool]) ;
  114360             : 
  114361             : #if FILE_IO_EXTRA_CHECK
  114362           0 :           assert ( returnPointer != NULL ) ;
  114363             : #endif
  114364             :         }
  114365           0 :      return returnPointer ;
  114366             :    }
  114367             : 
  114368             : //############################################################################
  114369             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  114370             :  * pool size! We set for every valid object in the memory pool the freepointer
  114371             :  * to the global index and increase the global index afterwards. For all the 
  114372             :  * invalid objects (means address ranges within the memory pool that were not
  114373             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  114374             :  * distinguish valid from invalid objects! 
  114375             :  */
  114376             : unsigned long
  114377           5 : SgFlushStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  114378             :    {
  114379           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  114380           5 :      SgFlushStatement* pointer = NULL;
  114381           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  114382           5 :      std::vector < unsigned char* > :: const_iterator block;
  114383           5 :      for ( block = SgFlushStatement::pools.begin(); block != SgFlushStatement::pools.end() ; ++block )
  114384             :         {
  114385           0 :           pointer = (SgFlushStatement*)(*block);
  114386           0 :           for (unsigned i = 0; i < SgFlushStatement::pool_size; ++i )
  114387             :              {
  114388             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  114389             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  114390             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  114391             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  114392             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  114393             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  114394             :             // properly; so this will have to be checked next.
  114395             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  114396             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  114397           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  114398             :                   {
  114399           0 :                     pointer[i].set_freepointer((SgFlushStatement*)(globalIndex));
  114400           0 :                     globalIndex++;
  114401             :                   }
  114402             :                else
  114403             :                   {
  114404           0 :                     pointer[i].set_freepointer(NULL);
  114405             :                   }
  114406             :               }
  114407             :         }
  114408           5 :      return globalIndex;
  114409             :    }
  114410             : 
  114411             : //############################################################################
  114412             : // JH (01/14/2006)
  114413             : void
  114414           5 : SgFlushStatement::resetValidFreepointers( )
  114415             :    {
  114416           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  114417           5 :      SgFlushStatement* pointer = NULL;
  114418           5 :      std::vector < unsigned char* > :: const_iterator block;
  114419           5 :      SgFlushStatement* pointerOfLinkedList = NULL;
  114420           5 :      for ( block = SgFlushStatement::pools.begin(); block != SgFlushStatement::pools.end() ; ++block )
  114421             :         {
  114422           0 :           pointer = (SgFlushStatement*)(*block);
  114423           0 :           for (unsigned i = 0; i < SgFlushStatement::pool_size; ++i )
  114424             :              {
  114425             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  114426             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  114427             :             // memory blocks!.
  114428           0 :                if ( pointer[i].get_freepointer() != NULL )
  114429             :                   {
  114430           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  114431             :                   }
  114432             :                else
  114433             :                   {
  114434           0 :                     if ( pointerOfLinkedList == NULL )
  114435             :                        {
  114436           0 :                          SgFlushStatement::next_node = &(pointer[i]);
  114437             :                        }
  114438             :                     else
  114439             :                        {
  114440             :                       // printf ("In SgFlushStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  114441           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  114442             :                        }
  114443             :                     pointerOfLinkedList = &(pointer[i]);
  114444             :                   }
  114445             :               }
  114446             :         }
  114447             : 
  114448           5 :      if ( pointerOfLinkedList != NULL )
  114449             :         {
  114450             :        // printf ("In SgFlushStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  114451           0 :           pointerOfLinkedList->set_freepointer(NULL);
  114452             :        // DQ (6/6/2010): Temporary debugging...
  114453             :        //   ROSE_ASSERT(false);
  114454             :         }
  114455             : 
  114456           5 :      return ;
  114457             :    }
  114458             : 
  114459             : //############################################################################
  114460             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  114461             :  * within the memory pool and resets the freepointers, in order to achieve a 
  114462             :  * linked list, that has no jumps and starts at the beginning! This function 
  114463             :  * does not extend the memory pool, since we do not delete any memory blocks,
  114464             :  * but delete the valid objects.  
  114465             :  */
  114466             : void
  114467           0 : SgFlushStatement::clearMemoryPool( )
  114468             :    {
  114469             :   // printf ("Inside of SgFlushStatement::clearMemoryPool() \n");
  114470             : 
  114471           0 :      SgFlushStatement* pointer = NULL, *tempPointer = NULL;
  114472           0 :      std::vector < unsigned char* > :: const_iterator block;
  114473           0 :      if ( SgFlushStatement::pools.empty() == false )
  114474             :         {
  114475           0 :           block = SgFlushStatement::pools.begin() ;
  114476           0 :           SgFlushStatement::next_node = (SgFlushStatement*) (*block);
  114477             : 
  114478           0 :           while ( block != SgFlushStatement::pools.end() )
  114479             :              {
  114480           0 :                pointer = (SgFlushStatement*) (*block);
  114481           0 :                if ( tempPointer != NULL )
  114482             :                   {
  114483           0 :                     tempPointer->set_freepointer(pointer);
  114484             :                   }
  114485           0 :                for (unsigned i = 0; i < SgFlushStatement::pool_size - 1; ++i)
  114486             :                   {
  114487           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  114488             :                   }
  114489           0 :                 pointer[SgFlushStatement::pool_size-1].set_freepointer(NULL);
  114490           0 :                 tempPointer = &(pointer[SgFlushStatement::pool_size-1]);
  114491           0 :                 ++block;
  114492             :              }
  114493             :         }
  114494           0 :    }
  114495             : 
  114496           5 : void SgFlushStatement::deleteMemoryPool() {
  114497           5 :   for (auto p: SgFlushStatement::pools) {
  114498           0 :     ROSE_FREE(p);
  114499             :   }
  114500           5 :   SgFlushStatement::next_node = nullptr;
  114501           5 :   SgFlushStatement::pools.clear();
  114502           5 : }
  114503             : 
  114504             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  114505             : //                 reading multiple binary files to for a single AST.
  114506             : /////////// new version ////////////////////////////////
  114507             : //############################################################################
  114508             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  114509             : void
  114510           2 : SgFlushStatement::extendMemoryPoolForFileIO( )
  114511             :   {
  114512           2 :     size_t blockIndex = SgFlushStatement::pools.size();
  114513           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFlushStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFlushStatement);
  114514             : 
  114515           2 :     while ( (blockIndex * SgFlushStatement::pool_size) < newPoolSize)
  114516             :       {
  114517             : #if ROSE_ALLOC_TRACE
  114518             :         if (blockIndex > 0) {
  114519             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFlushStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFlushStatement) = %" PRIuPTR " SgFlushStatement::pool_size = %d \n",
  114520             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFlushStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFlushStatement),SgFlushStatement::pool_size);
  114521             :         }
  114522             : #endif
  114523             : 
  114524           0 :         SgFlushStatement * pointer = (SgFlushStatement*) ROSE_MALLOC ( SgFlushStatement::pool_size * sizeof(SgFlushStatement) );
  114525           0 :         assert( pointer != NULL );
  114526             : #if ROSE_ALLOC_MEMSET == 1
  114527             :         memset(pointer, 0x00, SgFlushStatement::pool_size * sizeof(SgFlushStatement));
  114528             : #elif ROSE_ALLOC_MEMSET == 2
  114529             :         memset(pointer, 0xCC, SgFlushStatement::pool_size * sizeof(SgFlushStatement));
  114530             : #endif
  114531           0 :         SgFlushStatement::pools.push_back( (unsigned char*)(pointer) );
  114532           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFlushStatement::pool_size * sizeof(SgFlushStatement), V_SgFlushStatement ) );
  114533             : 
  114534           0 :         if ( SgFlushStatement::next_node != NULL ) {
  114535           0 :           if ( blockIndex > 0 ) {
  114536           0 :             SgFlushStatement * blkptr = (SgFlushStatement*)(SgFlushStatement::pools[blockIndex-1]);
  114537           0 :             blkptr[ SgFlushStatement::pool_size - 1 ].set_freepointer(pointer);
  114538             :           }
  114539             :         } else {
  114540           0 :           SgFlushStatement::next_node = pointer;
  114541             :         }
  114542             : 
  114543           0 :         for (unsigned i = 0; i < SgFlushStatement::pool_size-1; ++i)
  114544             :            {
  114545           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  114546             :            }
  114547           0 :         pointer[ SgFlushStatement::pool_size -1 ].set_freepointer(NULL);
  114548             : 
  114549           0 :         blockIndex++;
  114550             :       }
  114551           2 :   }
  114552             : 
  114553             : //############################################################################
  114554             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  114555             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  114556             :  * not compressed. However, that stuff is not yet implemented! 
  114557             :  */
  114558             : unsigned long
  114559           0 : SgFlushStatement::getNumberOfLastValidPointer()
  114560             :    {
  114561           0 :       SgFlushStatement* testPointer = (SgFlushStatement*)(SgFlushStatement::pools.back());
  114562           0 :       unsigned long localIndex = SgFlushStatement::pool_size - 1;
  114563           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  114564             :          {
  114565           0 :            localIndex--;
  114566             :          }
  114567           0 :       return (localIndex + SgFlushStatement::pool_size * (SgFlushStatement::pools.size()-1));
  114568             :    }
  114569             : 
  114570             : //############################################################################
  114571             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  114572             :  * memory pool and initializes the data member in class SgFlushStatementStroageClass
  114573             :  * from its counterpart of SgFlushStatement. The return value is just for checking, 
  114574             :  * that the whole StorageClassArray is initialized!
  114575             :  */
  114576             : unsigned long
  114577           0 : SgFlushStatement::initializeStorageClassArray( SgFlushStatementStorageClass *storageArray )
  114578             :    {
  114579           0 :      unsigned long storageCounter = 0;
  114580           0 :      std::vector < unsigned char* > :: const_iterator block = SgFlushStatement::pools.begin();
  114581           0 :      SgFlushStatement* pointer = NULL;
  114582           0 :      while ( block != SgFlushStatement::pools.end() ) {
  114583           0 :           pointer = (SgFlushStatement*) (*block);
  114584           0 :           for ( unsigned i = 0; i < SgFlushStatement::pool_size; ++i ) {
  114585           0 :                if ( pointer->get_freepointer() != NULL ) {
  114586           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  114587           0 :                  storageArray++;
  114588           0 :                  storageCounter++;
  114589             :                }
  114590           0 :                pointer++;
  114591             :              }
  114592           0 :            block++;
  114593             :         }
  114594           0 :      return storageCounter;
  114595             :    }
  114596             : 
  114597             : /* #line 114598 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  114598             : 
  114599             : 
  114600             : 
  114601             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  114602             : 
  114603             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  114604             : 
  114605             : //############################################################################
  114606             : /* JH (02/02/2006) Constructor of the IR node SgBackspaceStatement that takes its 
  114607             :  * corresponding StorageClass as parameter
  114608             :  */
  114609           0 : SgBackspaceStatement :: SgBackspaceStatement ( const SgBackspaceStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  114610             :    {
  114611             : 
  114612             : 
  114613             : /* #line 114614 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  114614             : 
  114615           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  114616             : 
  114617             : 
  114618             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  114619             : 
  114620             : 
  114621           0 :    }
  114622             : 
  114623             : //############################################################################
  114624             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  114625             :  * within the working AST. 
  114626             :  */
  114627           0 : SgBackspaceStatement * SgBackspaceStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  114628           0 :      SgBackspaceStatement* returnPointer = NULL;
  114629           0 :      if ( globalIndex != 0 )
  114630             :         {
  114631             : 
  114632             : #if FILE_IO_EXTRA_CHECK
  114633           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBackspaceStatement ) ) <= globalIndex ) ;
  114634           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBackspaceStatement + 1 ) ) );
  114635             : #endif
  114636           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBackspaceStatement )  
  114637           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBackspaceStatement );
  114638           0 :           unsigned long positionInPool = localIndex % SgBackspaceStatement::pool_size;
  114639           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBackspaceStatement::pool_size;
  114640             : 
  114641             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  114642             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  114643             : 
  114644           0 :           returnPointer = &( ( (SgBackspaceStatement*)(SgBackspaceStatement::pools[memoryBlock]) ) [positionInPool]) ;
  114645             : 
  114646           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  114647             :         }
  114648           0 :      return returnPointer ;
  114649             :    }
  114650             : 
  114651             : //############################################################################
  114652             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  114653             :   for the AST with the index astIndex
  114654             : */
  114655           0 : SgBackspaceStatement * SgBackspaceStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  114656           0 :      SgBackspaceStatement* returnPointer = NULL;
  114657           0 :      if ( globalIndex != 0 )
  114658             :         {
  114659             : 
  114660             : #if FILE_IO_EXTRA_CHECK
  114661           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBackspaceStatement ) ) <= globalIndex ) ;
  114662           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBackspaceStatement + 1 ) ) );
  114663             : #endif
  114664           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBackspaceStatement )
  114665           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBackspaceStatement );
  114666           0 :           unsigned long positionInPool = localIndex % SgBackspaceStatement::pool_size ;
  114667           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBackspaceStatement::pool_size ;
  114668             : 
  114669             : #if FILE_IO_EXTRA_CHECK
  114670             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  114671             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  114672             : #endif
  114673             : 
  114674           0 :           returnPointer = &( ( (SgBackspaceStatement*)(SgBackspaceStatement::pools[memoryBlock]) ) [positionInPool]) ;
  114675             : 
  114676             : #if FILE_IO_EXTRA_CHECK
  114677           0 :           assert ( returnPointer != NULL ) ;
  114678             : #endif
  114679             :         }
  114680           0 :      return returnPointer ;
  114681             :    }
  114682             : 
  114683             : //############################################################################
  114684             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  114685             :  * pool size! We set for every valid object in the memory pool the freepointer
  114686             :  * to the global index and increase the global index afterwards. For all the 
  114687             :  * invalid objects (means address ranges within the memory pool that were not
  114688             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  114689             :  * distinguish valid from invalid objects! 
  114690             :  */
  114691             : unsigned long
  114692           5 : SgBackspaceStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  114693             :    {
  114694           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  114695           5 :      SgBackspaceStatement* pointer = NULL;
  114696           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  114697           5 :      std::vector < unsigned char* > :: const_iterator block;
  114698           5 :      for ( block = SgBackspaceStatement::pools.begin(); block != SgBackspaceStatement::pools.end() ; ++block )
  114699             :         {
  114700           0 :           pointer = (SgBackspaceStatement*)(*block);
  114701           0 :           for (unsigned i = 0; i < SgBackspaceStatement::pool_size; ++i )
  114702             :              {
  114703             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  114704             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  114705             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  114706             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  114707             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  114708             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  114709             :             // properly; so this will have to be checked next.
  114710             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  114711             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  114712           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  114713             :                   {
  114714           0 :                     pointer[i].set_freepointer((SgBackspaceStatement*)(globalIndex));
  114715           0 :                     globalIndex++;
  114716             :                   }
  114717             :                else
  114718             :                   {
  114719           0 :                     pointer[i].set_freepointer(NULL);
  114720             :                   }
  114721             :               }
  114722             :         }
  114723           5 :      return globalIndex;
  114724             :    }
  114725             : 
  114726             : //############################################################################
  114727             : // JH (01/14/2006)
  114728             : void
  114729           5 : SgBackspaceStatement::resetValidFreepointers( )
  114730             :    {
  114731           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  114732           5 :      SgBackspaceStatement* pointer = NULL;
  114733           5 :      std::vector < unsigned char* > :: const_iterator block;
  114734           5 :      SgBackspaceStatement* pointerOfLinkedList = NULL;
  114735           5 :      for ( block = SgBackspaceStatement::pools.begin(); block != SgBackspaceStatement::pools.end() ; ++block )
  114736             :         {
  114737           0 :           pointer = (SgBackspaceStatement*)(*block);
  114738           0 :           for (unsigned i = 0; i < SgBackspaceStatement::pool_size; ++i )
  114739             :              {
  114740             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  114741             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  114742             :             // memory blocks!.
  114743           0 :                if ( pointer[i].get_freepointer() != NULL )
  114744             :                   {
  114745           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  114746             :                   }
  114747             :                else
  114748             :                   {
  114749           0 :                     if ( pointerOfLinkedList == NULL )
  114750             :                        {
  114751           0 :                          SgBackspaceStatement::next_node = &(pointer[i]);
  114752             :                        }
  114753             :                     else
  114754             :                        {
  114755             :                       // printf ("In SgBackspaceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  114756           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  114757             :                        }
  114758             :                     pointerOfLinkedList = &(pointer[i]);
  114759             :                   }
  114760             :               }
  114761             :         }
  114762             : 
  114763           5 :      if ( pointerOfLinkedList != NULL )
  114764             :         {
  114765             :        // printf ("In SgBackspaceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  114766           0 :           pointerOfLinkedList->set_freepointer(NULL);
  114767             :        // DQ (6/6/2010): Temporary debugging...
  114768             :        //   ROSE_ASSERT(false);
  114769             :         }
  114770             : 
  114771           5 :      return ;
  114772             :    }
  114773             : 
  114774             : //############################################################################
  114775             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  114776             :  * within the memory pool and resets the freepointers, in order to achieve a 
  114777             :  * linked list, that has no jumps and starts at the beginning! This function 
  114778             :  * does not extend the memory pool, since we do not delete any memory blocks,
  114779             :  * but delete the valid objects.  
  114780             :  */
  114781             : void
  114782           0 : SgBackspaceStatement::clearMemoryPool( )
  114783             :    {
  114784             :   // printf ("Inside of SgBackspaceStatement::clearMemoryPool() \n");
  114785             : 
  114786           0 :      SgBackspaceStatement* pointer = NULL, *tempPointer = NULL;
  114787           0 :      std::vector < unsigned char* > :: const_iterator block;
  114788           0 :      if ( SgBackspaceStatement::pools.empty() == false )
  114789             :         {
  114790           0 :           block = SgBackspaceStatement::pools.begin() ;
  114791           0 :           SgBackspaceStatement::next_node = (SgBackspaceStatement*) (*block);
  114792             : 
  114793           0 :           while ( block != SgBackspaceStatement::pools.end() )
  114794             :              {
  114795           0 :                pointer = (SgBackspaceStatement*) (*block);
  114796           0 :                if ( tempPointer != NULL )
  114797             :                   {
  114798           0 :                     tempPointer->set_freepointer(pointer);
  114799             :                   }
  114800           0 :                for (unsigned i = 0; i < SgBackspaceStatement::pool_size - 1; ++i)
  114801             :                   {
  114802           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  114803             :                   }
  114804           0 :                 pointer[SgBackspaceStatement::pool_size-1].set_freepointer(NULL);
  114805           0 :                 tempPointer = &(pointer[SgBackspaceStatement::pool_size-1]);
  114806           0 :                 ++block;
  114807             :              }
  114808             :         }
  114809           0 :    }
  114810             : 
  114811           5 : void SgBackspaceStatement::deleteMemoryPool() {
  114812           5 :   for (auto p: SgBackspaceStatement::pools) {
  114813           0 :     ROSE_FREE(p);
  114814             :   }
  114815           5 :   SgBackspaceStatement::next_node = nullptr;
  114816           5 :   SgBackspaceStatement::pools.clear();
  114817           5 : }
  114818             : 
  114819             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  114820             : //                 reading multiple binary files to for a single AST.
  114821             : /////////// new version ////////////////////////////////
  114822             : //############################################################################
  114823             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  114824             : void
  114825           2 : SgBackspaceStatement::extendMemoryPoolForFileIO( )
  114826             :   {
  114827           2 :     size_t blockIndex = SgBackspaceStatement::pools.size();
  114828           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBackspaceStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBackspaceStatement);
  114829             : 
  114830           2 :     while ( (blockIndex * SgBackspaceStatement::pool_size) < newPoolSize)
  114831             :       {
  114832             : #if ROSE_ALLOC_TRACE
  114833             :         if (blockIndex > 0) {
  114834             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBackspaceStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBackspaceStatement) = %" PRIuPTR " SgBackspaceStatement::pool_size = %d \n",
  114835             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBackspaceStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBackspaceStatement),SgBackspaceStatement::pool_size);
  114836             :         }
  114837             : #endif
  114838             : 
  114839           0 :         SgBackspaceStatement * pointer = (SgBackspaceStatement*) ROSE_MALLOC ( SgBackspaceStatement::pool_size * sizeof(SgBackspaceStatement) );
  114840           0 :         assert( pointer != NULL );
  114841             : #if ROSE_ALLOC_MEMSET == 1
  114842             :         memset(pointer, 0x00, SgBackspaceStatement::pool_size * sizeof(SgBackspaceStatement));
  114843             : #elif ROSE_ALLOC_MEMSET == 2
  114844             :         memset(pointer, 0xCC, SgBackspaceStatement::pool_size * sizeof(SgBackspaceStatement));
  114845             : #endif
  114846           0 :         SgBackspaceStatement::pools.push_back( (unsigned char*)(pointer) );
  114847           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBackspaceStatement::pool_size * sizeof(SgBackspaceStatement), V_SgBackspaceStatement ) );
  114848             : 
  114849           0 :         if ( SgBackspaceStatement::next_node != NULL ) {
  114850           0 :           if ( blockIndex > 0 ) {
  114851           0 :             SgBackspaceStatement * blkptr = (SgBackspaceStatement*)(SgBackspaceStatement::pools[blockIndex-1]);
  114852           0 :             blkptr[ SgBackspaceStatement::pool_size - 1 ].set_freepointer(pointer);
  114853             :           }
  114854             :         } else {
  114855           0 :           SgBackspaceStatement::next_node = pointer;
  114856             :         }
  114857             : 
  114858           0 :         for (unsigned i = 0; i < SgBackspaceStatement::pool_size-1; ++i)
  114859             :            {
  114860           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  114861             :            }
  114862           0 :         pointer[ SgBackspaceStatement::pool_size -1 ].set_freepointer(NULL);
  114863             : 
  114864           0 :         blockIndex++;
  114865             :       }
  114866           2 :   }
  114867             : 
  114868             : //############################################################################
  114869             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  114870             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  114871             :  * not compressed. However, that stuff is not yet implemented! 
  114872             :  */
  114873             : unsigned long
  114874           0 : SgBackspaceStatement::getNumberOfLastValidPointer()
  114875             :    {
  114876           0 :       SgBackspaceStatement* testPointer = (SgBackspaceStatement*)(SgBackspaceStatement::pools.back());
  114877           0 :       unsigned long localIndex = SgBackspaceStatement::pool_size - 1;
  114878           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  114879             :          {
  114880           0 :            localIndex--;
  114881             :          }
  114882           0 :       return (localIndex + SgBackspaceStatement::pool_size * (SgBackspaceStatement::pools.size()-1));
  114883             :    }
  114884             : 
  114885             : //############################################################################
  114886             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  114887             :  * memory pool and initializes the data member in class SgBackspaceStatementStroageClass
  114888             :  * from its counterpart of SgBackspaceStatement. The return value is just for checking, 
  114889             :  * that the whole StorageClassArray is initialized!
  114890             :  */
  114891             : unsigned long
  114892           0 : SgBackspaceStatement::initializeStorageClassArray( SgBackspaceStatementStorageClass *storageArray )
  114893             :    {
  114894           0 :      unsigned long storageCounter = 0;
  114895           0 :      std::vector < unsigned char* > :: const_iterator block = SgBackspaceStatement::pools.begin();
  114896           0 :      SgBackspaceStatement* pointer = NULL;
  114897           0 :      while ( block != SgBackspaceStatement::pools.end() ) {
  114898           0 :           pointer = (SgBackspaceStatement*) (*block);
  114899           0 :           for ( unsigned i = 0; i < SgBackspaceStatement::pool_size; ++i ) {
  114900           0 :                if ( pointer->get_freepointer() != NULL ) {
  114901           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  114902           0 :                  storageArray++;
  114903           0 :                  storageCounter++;
  114904             :                }
  114905           0 :                pointer++;
  114906             :              }
  114907           0 :            block++;
  114908             :         }
  114909           0 :      return storageCounter;
  114910             :    }
  114911             : 
  114912             : /* #line 114913 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  114913             : 
  114914             : 
  114915             : 
  114916             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  114917             : 
  114918             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  114919             : 
  114920             : //############################################################################
  114921             : /* JH (02/02/2006) Constructor of the IR node SgRewindStatement that takes its 
  114922             :  * corresponding StorageClass as parameter
  114923             :  */
  114924           0 : SgRewindStatement :: SgRewindStatement ( const SgRewindStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  114925             :    {
  114926             : 
  114927             : 
  114928             : /* #line 114929 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  114929             : 
  114930           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  114931             : 
  114932             : 
  114933             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  114934             : 
  114935             : 
  114936           0 :    }
  114937             : 
  114938             : //############################################################################
  114939             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  114940             :  * within the working AST. 
  114941             :  */
  114942           0 : SgRewindStatement * SgRewindStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  114943           0 :      SgRewindStatement* returnPointer = NULL;
  114944           0 :      if ( globalIndex != 0 )
  114945             :         {
  114946             : 
  114947             : #if FILE_IO_EXTRA_CHECK
  114948           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRewindStatement ) ) <= globalIndex ) ;
  114949           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRewindStatement + 1 ) ) );
  114950             : #endif
  114951           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRewindStatement )  
  114952           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRewindStatement );
  114953           0 :           unsigned long positionInPool = localIndex % SgRewindStatement::pool_size;
  114954           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRewindStatement::pool_size;
  114955             : 
  114956             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  114957             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  114958             : 
  114959           0 :           returnPointer = &( ( (SgRewindStatement*)(SgRewindStatement::pools[memoryBlock]) ) [positionInPool]) ;
  114960             : 
  114961           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  114962             :         }
  114963           0 :      return returnPointer ;
  114964             :    }
  114965             : 
  114966             : //############################################################################
  114967             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  114968             :   for the AST with the index astIndex
  114969             : */
  114970           0 : SgRewindStatement * SgRewindStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  114971           0 :      SgRewindStatement* returnPointer = NULL;
  114972           0 :      if ( globalIndex != 0 )
  114973             :         {
  114974             : 
  114975             : #if FILE_IO_EXTRA_CHECK
  114976           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRewindStatement ) ) <= globalIndex ) ;
  114977           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRewindStatement + 1 ) ) );
  114978             : #endif
  114979           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRewindStatement )
  114980           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRewindStatement );
  114981           0 :           unsigned long positionInPool = localIndex % SgRewindStatement::pool_size ;
  114982           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRewindStatement::pool_size ;
  114983             : 
  114984             : #if FILE_IO_EXTRA_CHECK
  114985             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  114986             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  114987             : #endif
  114988             : 
  114989           0 :           returnPointer = &( ( (SgRewindStatement*)(SgRewindStatement::pools[memoryBlock]) ) [positionInPool]) ;
  114990             : 
  114991             : #if FILE_IO_EXTRA_CHECK
  114992           0 :           assert ( returnPointer != NULL ) ;
  114993             : #endif
  114994             :         }
  114995           0 :      return returnPointer ;
  114996             :    }
  114997             : 
  114998             : //############################################################################
  114999             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  115000             :  * pool size! We set for every valid object in the memory pool the freepointer
  115001             :  * to the global index and increase the global index afterwards. For all the 
  115002             :  * invalid objects (means address ranges within the memory pool that were not
  115003             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  115004             :  * distinguish valid from invalid objects! 
  115005             :  */
  115006             : unsigned long
  115007           5 : SgRewindStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  115008             :    {
  115009           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  115010           5 :      SgRewindStatement* pointer = NULL;
  115011           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  115012           5 :      std::vector < unsigned char* > :: const_iterator block;
  115013           5 :      for ( block = SgRewindStatement::pools.begin(); block != SgRewindStatement::pools.end() ; ++block )
  115014             :         {
  115015           0 :           pointer = (SgRewindStatement*)(*block);
  115016           0 :           for (unsigned i = 0; i < SgRewindStatement::pool_size; ++i )
  115017             :              {
  115018             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  115019             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  115020             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  115021             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  115022             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  115023             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  115024             :             // properly; so this will have to be checked next.
  115025             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  115026             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  115027           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  115028             :                   {
  115029           0 :                     pointer[i].set_freepointer((SgRewindStatement*)(globalIndex));
  115030           0 :                     globalIndex++;
  115031             :                   }
  115032             :                else
  115033             :                   {
  115034           0 :                     pointer[i].set_freepointer(NULL);
  115035             :                   }
  115036             :               }
  115037             :         }
  115038           5 :      return globalIndex;
  115039             :    }
  115040             : 
  115041             : //############################################################################
  115042             : // JH (01/14/2006)
  115043             : void
  115044           5 : SgRewindStatement::resetValidFreepointers( )
  115045             :    {
  115046           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  115047           5 :      SgRewindStatement* pointer = NULL;
  115048           5 :      std::vector < unsigned char* > :: const_iterator block;
  115049           5 :      SgRewindStatement* pointerOfLinkedList = NULL;
  115050           5 :      for ( block = SgRewindStatement::pools.begin(); block != SgRewindStatement::pools.end() ; ++block )
  115051             :         {
  115052           0 :           pointer = (SgRewindStatement*)(*block);
  115053           0 :           for (unsigned i = 0; i < SgRewindStatement::pool_size; ++i )
  115054             :              {
  115055             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  115056             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  115057             :             // memory blocks!.
  115058           0 :                if ( pointer[i].get_freepointer() != NULL )
  115059             :                   {
  115060           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  115061             :                   }
  115062             :                else
  115063             :                   {
  115064           0 :                     if ( pointerOfLinkedList == NULL )
  115065             :                        {
  115066           0 :                          SgRewindStatement::next_node = &(pointer[i]);
  115067             :                        }
  115068             :                     else
  115069             :                        {
  115070             :                       // printf ("In SgRewindStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  115071           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  115072             :                        }
  115073             :                     pointerOfLinkedList = &(pointer[i]);
  115074             :                   }
  115075             :               }
  115076             :         }
  115077             : 
  115078           5 :      if ( pointerOfLinkedList != NULL )
  115079             :         {
  115080             :        // printf ("In SgRewindStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  115081           0 :           pointerOfLinkedList->set_freepointer(NULL);
  115082             :        // DQ (6/6/2010): Temporary debugging...
  115083             :        //   ROSE_ASSERT(false);
  115084             :         }
  115085             : 
  115086           5 :      return ;
  115087             :    }
  115088             : 
  115089             : //############################################################################
  115090             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  115091             :  * within the memory pool and resets the freepointers, in order to achieve a 
  115092             :  * linked list, that has no jumps and starts at the beginning! This function 
  115093             :  * does not extend the memory pool, since we do not delete any memory blocks,
  115094             :  * but delete the valid objects.  
  115095             :  */
  115096             : void
  115097           0 : SgRewindStatement::clearMemoryPool( )
  115098             :    {
  115099             :   // printf ("Inside of SgRewindStatement::clearMemoryPool() \n");
  115100             : 
  115101           0 :      SgRewindStatement* pointer = NULL, *tempPointer = NULL;
  115102           0 :      std::vector < unsigned char* > :: const_iterator block;
  115103           0 :      if ( SgRewindStatement::pools.empty() == false )
  115104             :         {
  115105           0 :           block = SgRewindStatement::pools.begin() ;
  115106           0 :           SgRewindStatement::next_node = (SgRewindStatement*) (*block);
  115107             : 
  115108           0 :           while ( block != SgRewindStatement::pools.end() )
  115109             :              {
  115110           0 :                pointer = (SgRewindStatement*) (*block);
  115111           0 :                if ( tempPointer != NULL )
  115112             :                   {
  115113           0 :                     tempPointer->set_freepointer(pointer);
  115114             :                   }
  115115           0 :                for (unsigned i = 0; i < SgRewindStatement::pool_size - 1; ++i)
  115116             :                   {
  115117           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  115118             :                   }
  115119           0 :                 pointer[SgRewindStatement::pool_size-1].set_freepointer(NULL);
  115120           0 :                 tempPointer = &(pointer[SgRewindStatement::pool_size-1]);
  115121           0 :                 ++block;
  115122             :              }
  115123             :         }
  115124           0 :    }
  115125             : 
  115126           5 : void SgRewindStatement::deleteMemoryPool() {
  115127           5 :   for (auto p: SgRewindStatement::pools) {
  115128           0 :     ROSE_FREE(p);
  115129             :   }
  115130           5 :   SgRewindStatement::next_node = nullptr;
  115131           5 :   SgRewindStatement::pools.clear();
  115132           5 : }
  115133             : 
  115134             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  115135             : //                 reading multiple binary files to for a single AST.
  115136             : /////////// new version ////////////////////////////////
  115137             : //############################################################################
  115138             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  115139             : void
  115140           2 : SgRewindStatement::extendMemoryPoolForFileIO( )
  115141             :   {
  115142           2 :     size_t blockIndex = SgRewindStatement::pools.size();
  115143           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRewindStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRewindStatement);
  115144             : 
  115145           2 :     while ( (blockIndex * SgRewindStatement::pool_size) < newPoolSize)
  115146             :       {
  115147             : #if ROSE_ALLOC_TRACE
  115148             :         if (blockIndex > 0) {
  115149             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRewindStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRewindStatement) = %" PRIuPTR " SgRewindStatement::pool_size = %d \n",
  115150             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRewindStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRewindStatement),SgRewindStatement::pool_size);
  115151             :         }
  115152             : #endif
  115153             : 
  115154           0 :         SgRewindStatement * pointer = (SgRewindStatement*) ROSE_MALLOC ( SgRewindStatement::pool_size * sizeof(SgRewindStatement) );
  115155           0 :         assert( pointer != NULL );
  115156             : #if ROSE_ALLOC_MEMSET == 1
  115157             :         memset(pointer, 0x00, SgRewindStatement::pool_size * sizeof(SgRewindStatement));
  115158             : #elif ROSE_ALLOC_MEMSET == 2
  115159             :         memset(pointer, 0xCC, SgRewindStatement::pool_size * sizeof(SgRewindStatement));
  115160             : #endif
  115161           0 :         SgRewindStatement::pools.push_back( (unsigned char*)(pointer) );
  115162           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRewindStatement::pool_size * sizeof(SgRewindStatement), V_SgRewindStatement ) );
  115163             : 
  115164           0 :         if ( SgRewindStatement::next_node != NULL ) {
  115165           0 :           if ( blockIndex > 0 ) {
  115166           0 :             SgRewindStatement * blkptr = (SgRewindStatement*)(SgRewindStatement::pools[blockIndex-1]);
  115167           0 :             blkptr[ SgRewindStatement::pool_size - 1 ].set_freepointer(pointer);
  115168             :           }
  115169             :         } else {
  115170           0 :           SgRewindStatement::next_node = pointer;
  115171             :         }
  115172             : 
  115173           0 :         for (unsigned i = 0; i < SgRewindStatement::pool_size-1; ++i)
  115174             :            {
  115175           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  115176             :            }
  115177           0 :         pointer[ SgRewindStatement::pool_size -1 ].set_freepointer(NULL);
  115178             : 
  115179           0 :         blockIndex++;
  115180             :       }
  115181           2 :   }
  115182             : 
  115183             : //############################################################################
  115184             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  115185             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  115186             :  * not compressed. However, that stuff is not yet implemented! 
  115187             :  */
  115188             : unsigned long
  115189           0 : SgRewindStatement::getNumberOfLastValidPointer()
  115190             :    {
  115191           0 :       SgRewindStatement* testPointer = (SgRewindStatement*)(SgRewindStatement::pools.back());
  115192           0 :       unsigned long localIndex = SgRewindStatement::pool_size - 1;
  115193           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  115194             :          {
  115195           0 :            localIndex--;
  115196             :          }
  115197           0 :       return (localIndex + SgRewindStatement::pool_size * (SgRewindStatement::pools.size()-1));
  115198             :    }
  115199             : 
  115200             : //############################################################################
  115201             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  115202             :  * memory pool and initializes the data member in class SgRewindStatementStroageClass
  115203             :  * from its counterpart of SgRewindStatement. The return value is just for checking, 
  115204             :  * that the whole StorageClassArray is initialized!
  115205             :  */
  115206             : unsigned long
  115207           0 : SgRewindStatement::initializeStorageClassArray( SgRewindStatementStorageClass *storageArray )
  115208             :    {
  115209           0 :      unsigned long storageCounter = 0;
  115210           0 :      std::vector < unsigned char* > :: const_iterator block = SgRewindStatement::pools.begin();
  115211           0 :      SgRewindStatement* pointer = NULL;
  115212           0 :      while ( block != SgRewindStatement::pools.end() ) {
  115213           0 :           pointer = (SgRewindStatement*) (*block);
  115214           0 :           for ( unsigned i = 0; i < SgRewindStatement::pool_size; ++i ) {
  115215           0 :                if ( pointer->get_freepointer() != NULL ) {
  115216           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  115217           0 :                  storageArray++;
  115218           0 :                  storageCounter++;
  115219             :                }
  115220           0 :                pointer++;
  115221             :              }
  115222           0 :            block++;
  115223             :         }
  115224           0 :      return storageCounter;
  115225             :    }
  115226             : 
  115227             : /* #line 115228 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  115228             : 
  115229             : 
  115230             : 
  115231             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  115232             : 
  115233             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  115234             : 
  115235             : //############################################################################
  115236             : /* JH (02/02/2006) Constructor of the IR node SgEndfileStatement that takes its 
  115237             :  * corresponding StorageClass as parameter
  115238             :  */
  115239           0 : SgEndfileStatement :: SgEndfileStatement ( const SgEndfileStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  115240             :    {
  115241             : 
  115242             : 
  115243             : /* #line 115244 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  115244             : 
  115245           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  115246             : 
  115247             : 
  115248             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  115249             : 
  115250             : 
  115251           0 :    }
  115252             : 
  115253             : //############################################################################
  115254             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  115255             :  * within the working AST. 
  115256             :  */
  115257           0 : SgEndfileStatement * SgEndfileStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  115258           0 :      SgEndfileStatement* returnPointer = NULL;
  115259           0 :      if ( globalIndex != 0 )
  115260             :         {
  115261             : 
  115262             : #if FILE_IO_EXTRA_CHECK
  115263           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEndfileStatement ) ) <= globalIndex ) ;
  115264           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEndfileStatement + 1 ) ) );
  115265             : #endif
  115266           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEndfileStatement )  
  115267           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEndfileStatement );
  115268           0 :           unsigned long positionInPool = localIndex % SgEndfileStatement::pool_size;
  115269           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEndfileStatement::pool_size;
  115270             : 
  115271             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  115272             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  115273             : 
  115274           0 :           returnPointer = &( ( (SgEndfileStatement*)(SgEndfileStatement::pools[memoryBlock]) ) [positionInPool]) ;
  115275             : 
  115276           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  115277             :         }
  115278           0 :      return returnPointer ;
  115279             :    }
  115280             : 
  115281             : //############################################################################
  115282             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  115283             :   for the AST with the index astIndex
  115284             : */
  115285           0 : SgEndfileStatement * SgEndfileStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  115286           0 :      SgEndfileStatement* returnPointer = NULL;
  115287           0 :      if ( globalIndex != 0 )
  115288             :         {
  115289             : 
  115290             : #if FILE_IO_EXTRA_CHECK
  115291           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEndfileStatement ) ) <= globalIndex ) ;
  115292           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEndfileStatement + 1 ) ) );
  115293             : #endif
  115294           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEndfileStatement )
  115295           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEndfileStatement );
  115296           0 :           unsigned long positionInPool = localIndex % SgEndfileStatement::pool_size ;
  115297           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEndfileStatement::pool_size ;
  115298             : 
  115299             : #if FILE_IO_EXTRA_CHECK
  115300             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  115301             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  115302             : #endif
  115303             : 
  115304           0 :           returnPointer = &( ( (SgEndfileStatement*)(SgEndfileStatement::pools[memoryBlock]) ) [positionInPool]) ;
  115305             : 
  115306             : #if FILE_IO_EXTRA_CHECK
  115307           0 :           assert ( returnPointer != NULL ) ;
  115308             : #endif
  115309             :         }
  115310           0 :      return returnPointer ;
  115311             :    }
  115312             : 
  115313             : //############################################################################
  115314             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  115315             :  * pool size! We set for every valid object in the memory pool the freepointer
  115316             :  * to the global index and increase the global index afterwards. For all the 
  115317             :  * invalid objects (means address ranges within the memory pool that were not
  115318             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  115319             :  * distinguish valid from invalid objects! 
  115320             :  */
  115321             : unsigned long
  115322           5 : SgEndfileStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  115323             :    {
  115324           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  115325           5 :      SgEndfileStatement* pointer = NULL;
  115326           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  115327           5 :      std::vector < unsigned char* > :: const_iterator block;
  115328           5 :      for ( block = SgEndfileStatement::pools.begin(); block != SgEndfileStatement::pools.end() ; ++block )
  115329             :         {
  115330           0 :           pointer = (SgEndfileStatement*)(*block);
  115331           0 :           for (unsigned i = 0; i < SgEndfileStatement::pool_size; ++i )
  115332             :              {
  115333             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  115334             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  115335             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  115336             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  115337             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  115338             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  115339             :             // properly; so this will have to be checked next.
  115340             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  115341             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  115342           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  115343             :                   {
  115344           0 :                     pointer[i].set_freepointer((SgEndfileStatement*)(globalIndex));
  115345           0 :                     globalIndex++;
  115346             :                   }
  115347             :                else
  115348             :                   {
  115349           0 :                     pointer[i].set_freepointer(NULL);
  115350             :                   }
  115351             :               }
  115352             :         }
  115353           5 :      return globalIndex;
  115354             :    }
  115355             : 
  115356             : //############################################################################
  115357             : // JH (01/14/2006)
  115358             : void
  115359           5 : SgEndfileStatement::resetValidFreepointers( )
  115360             :    {
  115361           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  115362           5 :      SgEndfileStatement* pointer = NULL;
  115363           5 :      std::vector < unsigned char* > :: const_iterator block;
  115364           5 :      SgEndfileStatement* pointerOfLinkedList = NULL;
  115365           5 :      for ( block = SgEndfileStatement::pools.begin(); block != SgEndfileStatement::pools.end() ; ++block )
  115366             :         {
  115367           0 :           pointer = (SgEndfileStatement*)(*block);
  115368           0 :           for (unsigned i = 0; i < SgEndfileStatement::pool_size; ++i )
  115369             :              {
  115370             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  115371             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  115372             :             // memory blocks!.
  115373           0 :                if ( pointer[i].get_freepointer() != NULL )
  115374             :                   {
  115375           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  115376             :                   }
  115377             :                else
  115378             :                   {
  115379           0 :                     if ( pointerOfLinkedList == NULL )
  115380             :                        {
  115381           0 :                          SgEndfileStatement::next_node = &(pointer[i]);
  115382             :                        }
  115383             :                     else
  115384             :                        {
  115385             :                       // printf ("In SgEndfileStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  115386           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  115387             :                        }
  115388             :                     pointerOfLinkedList = &(pointer[i]);
  115389             :                   }
  115390             :               }
  115391             :         }
  115392             : 
  115393           5 :      if ( pointerOfLinkedList != NULL )
  115394             :         {
  115395             :        // printf ("In SgEndfileStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  115396           0 :           pointerOfLinkedList->set_freepointer(NULL);
  115397             :        // DQ (6/6/2010): Temporary debugging...
  115398             :        //   ROSE_ASSERT(false);
  115399             :         }
  115400             : 
  115401           5 :      return ;
  115402             :    }
  115403             : 
  115404             : //############################################################################
  115405             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  115406             :  * within the memory pool and resets the freepointers, in order to achieve a 
  115407             :  * linked list, that has no jumps and starts at the beginning! This function 
  115408             :  * does not extend the memory pool, since we do not delete any memory blocks,
  115409             :  * but delete the valid objects.  
  115410             :  */
  115411             : void
  115412           0 : SgEndfileStatement::clearMemoryPool( )
  115413             :    {
  115414             :   // printf ("Inside of SgEndfileStatement::clearMemoryPool() \n");
  115415             : 
  115416           0 :      SgEndfileStatement* pointer = NULL, *tempPointer = NULL;
  115417           0 :      std::vector < unsigned char* > :: const_iterator block;
  115418           0 :      if ( SgEndfileStatement::pools.empty() == false )
  115419             :         {
  115420           0 :           block = SgEndfileStatement::pools.begin() ;
  115421           0 :           SgEndfileStatement::next_node = (SgEndfileStatement*) (*block);
  115422             : 
  115423           0 :           while ( block != SgEndfileStatement::pools.end() )
  115424             :              {
  115425           0 :                pointer = (SgEndfileStatement*) (*block);
  115426           0 :                if ( tempPointer != NULL )
  115427             :                   {
  115428           0 :                     tempPointer->set_freepointer(pointer);
  115429             :                   }
  115430           0 :                for (unsigned i = 0; i < SgEndfileStatement::pool_size - 1; ++i)
  115431             :                   {
  115432           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  115433             :                   }
  115434           0 :                 pointer[SgEndfileStatement::pool_size-1].set_freepointer(NULL);
  115435           0 :                 tempPointer = &(pointer[SgEndfileStatement::pool_size-1]);
  115436           0 :                 ++block;
  115437             :              }
  115438             :         }
  115439           0 :    }
  115440             : 
  115441           5 : void SgEndfileStatement::deleteMemoryPool() {
  115442           5 :   for (auto p: SgEndfileStatement::pools) {
  115443           0 :     ROSE_FREE(p);
  115444             :   }
  115445           5 :   SgEndfileStatement::next_node = nullptr;
  115446           5 :   SgEndfileStatement::pools.clear();
  115447           5 : }
  115448             : 
  115449             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  115450             : //                 reading multiple binary files to for a single AST.
  115451             : /////////// new version ////////////////////////////////
  115452             : //############################################################################
  115453             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  115454             : void
  115455           2 : SgEndfileStatement::extendMemoryPoolForFileIO( )
  115456             :   {
  115457           2 :     size_t blockIndex = SgEndfileStatement::pools.size();
  115458           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEndfileStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEndfileStatement);
  115459             : 
  115460           2 :     while ( (blockIndex * SgEndfileStatement::pool_size) < newPoolSize)
  115461             :       {
  115462             : #if ROSE_ALLOC_TRACE
  115463             :         if (blockIndex > 0) {
  115464             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEndfileStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEndfileStatement) = %" PRIuPTR " SgEndfileStatement::pool_size = %d \n",
  115465             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEndfileStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEndfileStatement),SgEndfileStatement::pool_size);
  115466             :         }
  115467             : #endif
  115468             : 
  115469           0 :         SgEndfileStatement * pointer = (SgEndfileStatement*) ROSE_MALLOC ( SgEndfileStatement::pool_size * sizeof(SgEndfileStatement) );
  115470           0 :         assert( pointer != NULL );
  115471             : #if ROSE_ALLOC_MEMSET == 1
  115472             :         memset(pointer, 0x00, SgEndfileStatement::pool_size * sizeof(SgEndfileStatement));
  115473             : #elif ROSE_ALLOC_MEMSET == 2
  115474             :         memset(pointer, 0xCC, SgEndfileStatement::pool_size * sizeof(SgEndfileStatement));
  115475             : #endif
  115476           0 :         SgEndfileStatement::pools.push_back( (unsigned char*)(pointer) );
  115477           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEndfileStatement::pool_size * sizeof(SgEndfileStatement), V_SgEndfileStatement ) );
  115478             : 
  115479           0 :         if ( SgEndfileStatement::next_node != NULL ) {
  115480           0 :           if ( blockIndex > 0 ) {
  115481           0 :             SgEndfileStatement * blkptr = (SgEndfileStatement*)(SgEndfileStatement::pools[blockIndex-1]);
  115482           0 :             blkptr[ SgEndfileStatement::pool_size - 1 ].set_freepointer(pointer);
  115483             :           }
  115484             :         } else {
  115485           0 :           SgEndfileStatement::next_node = pointer;
  115486             :         }
  115487             : 
  115488           0 :         for (unsigned i = 0; i < SgEndfileStatement::pool_size-1; ++i)
  115489             :            {
  115490           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  115491             :            }
  115492           0 :         pointer[ SgEndfileStatement::pool_size -1 ].set_freepointer(NULL);
  115493             : 
  115494           0 :         blockIndex++;
  115495             :       }
  115496           2 :   }
  115497             : 
  115498             : //############################################################################
  115499             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  115500             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  115501             :  * not compressed. However, that stuff is not yet implemented! 
  115502             :  */
  115503             : unsigned long
  115504           0 : SgEndfileStatement::getNumberOfLastValidPointer()
  115505             :    {
  115506           0 :       SgEndfileStatement* testPointer = (SgEndfileStatement*)(SgEndfileStatement::pools.back());
  115507           0 :       unsigned long localIndex = SgEndfileStatement::pool_size - 1;
  115508           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  115509             :          {
  115510           0 :            localIndex--;
  115511             :          }
  115512           0 :       return (localIndex + SgEndfileStatement::pool_size * (SgEndfileStatement::pools.size()-1));
  115513             :    }
  115514             : 
  115515             : //############################################################################
  115516             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  115517             :  * memory pool and initializes the data member in class SgEndfileStatementStroageClass
  115518             :  * from its counterpart of SgEndfileStatement. The return value is just for checking, 
  115519             :  * that the whole StorageClassArray is initialized!
  115520             :  */
  115521             : unsigned long
  115522           0 : SgEndfileStatement::initializeStorageClassArray( SgEndfileStatementStorageClass *storageArray )
  115523             :    {
  115524           0 :      unsigned long storageCounter = 0;
  115525           0 :      std::vector < unsigned char* > :: const_iterator block = SgEndfileStatement::pools.begin();
  115526           0 :      SgEndfileStatement* pointer = NULL;
  115527           0 :      while ( block != SgEndfileStatement::pools.end() ) {
  115528           0 :           pointer = (SgEndfileStatement*) (*block);
  115529           0 :           for ( unsigned i = 0; i < SgEndfileStatement::pool_size; ++i ) {
  115530           0 :                if ( pointer->get_freepointer() != NULL ) {
  115531           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  115532           0 :                  storageArray++;
  115533           0 :                  storageCounter++;
  115534             :                }
  115535           0 :                pointer++;
  115536             :              }
  115537           0 :            block++;
  115538             :         }
  115539           0 :      return storageCounter;
  115540             :    }
  115541             : 
  115542             : /* #line 115543 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  115543             : 
  115544             : 
  115545             : 
  115546             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  115547             : 
  115548             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  115549             : 
  115550             : //############################################################################
  115551             : /* JH (02/02/2006) Constructor of the IR node SgWaitStatement that takes its 
  115552             :  * corresponding StorageClass as parameter
  115553             :  */
  115554           0 : SgWaitStatement :: SgWaitStatement ( const SgWaitStatementStorageClass& storageSource )   : SgIOStatement (storageSource)
  115555             :    {
  115556             : 
  115557             : 
  115558             : /* #line 115559 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  115559             : 
  115560           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  115561             : 
  115562             : 
  115563             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  115564             : 
  115565             : 
  115566           0 :    }
  115567             : 
  115568             : //############################################################################
  115569             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  115570             :  * within the working AST. 
  115571             :  */
  115572           0 : SgWaitStatement * SgWaitStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  115573           0 :      SgWaitStatement* returnPointer = NULL;
  115574           0 :      if ( globalIndex != 0 )
  115575             :         {
  115576             : 
  115577             : #if FILE_IO_EXTRA_CHECK
  115578           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgWaitStatement ) ) <= globalIndex ) ;
  115579           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWaitStatement + 1 ) ) );
  115580             : #endif
  115581           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWaitStatement )  
  115582           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgWaitStatement );
  115583           0 :           unsigned long positionInPool = localIndex % SgWaitStatement::pool_size;
  115584           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWaitStatement::pool_size;
  115585             : 
  115586             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  115587             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  115588             : 
  115589           0 :           returnPointer = &( ( (SgWaitStatement*)(SgWaitStatement::pools[memoryBlock]) ) [positionInPool]) ;
  115590             : 
  115591           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  115592             :         }
  115593           0 :      return returnPointer ;
  115594             :    }
  115595             : 
  115596             : //############################################################################
  115597             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  115598             :   for the AST with the index astIndex
  115599             : */
  115600           0 : SgWaitStatement * SgWaitStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  115601           0 :      SgWaitStatement* returnPointer = NULL;
  115602           0 :      if ( globalIndex != 0 )
  115603             :         {
  115604             : 
  115605             : #if FILE_IO_EXTRA_CHECK
  115606           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgWaitStatement ) ) <= globalIndex ) ;
  115607           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWaitStatement + 1 ) ) );
  115608             : #endif
  115609           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWaitStatement )
  115610           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgWaitStatement );
  115611           0 :           unsigned long positionInPool = localIndex % SgWaitStatement::pool_size ;
  115612           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWaitStatement::pool_size ;
  115613             : 
  115614             : #if FILE_IO_EXTRA_CHECK
  115615             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  115616             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  115617             : #endif
  115618             : 
  115619           0 :           returnPointer = &( ( (SgWaitStatement*)(SgWaitStatement::pools[memoryBlock]) ) [positionInPool]) ;
  115620             : 
  115621             : #if FILE_IO_EXTRA_CHECK
  115622           0 :           assert ( returnPointer != NULL ) ;
  115623             : #endif
  115624             :         }
  115625           0 :      return returnPointer ;
  115626             :    }
  115627             : 
  115628             : //############################################################################
  115629             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  115630             :  * pool size! We set for every valid object in the memory pool the freepointer
  115631             :  * to the global index and increase the global index afterwards. For all the 
  115632             :  * invalid objects (means address ranges within the memory pool that were not
  115633             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  115634             :  * distinguish valid from invalid objects! 
  115635             :  */
  115636             : unsigned long
  115637           5 : SgWaitStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  115638             :    {
  115639           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  115640           5 :      SgWaitStatement* pointer = NULL;
  115641           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  115642           5 :      std::vector < unsigned char* > :: const_iterator block;
  115643           5 :      for ( block = SgWaitStatement::pools.begin(); block != SgWaitStatement::pools.end() ; ++block )
  115644             :         {
  115645           0 :           pointer = (SgWaitStatement*)(*block);
  115646           0 :           for (unsigned i = 0; i < SgWaitStatement::pool_size; ++i )
  115647             :              {
  115648             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  115649             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  115650             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  115651             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  115652             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  115653             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  115654             :             // properly; so this will have to be checked next.
  115655             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  115656             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  115657           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  115658             :                   {
  115659           0 :                     pointer[i].set_freepointer((SgWaitStatement*)(globalIndex));
  115660           0 :                     globalIndex++;
  115661             :                   }
  115662             :                else
  115663             :                   {
  115664           0 :                     pointer[i].set_freepointer(NULL);
  115665             :                   }
  115666             :               }
  115667             :         }
  115668           5 :      return globalIndex;
  115669             :    }
  115670             : 
  115671             : //############################################################################
  115672             : // JH (01/14/2006)
  115673             : void
  115674           5 : SgWaitStatement::resetValidFreepointers( )
  115675             :    {
  115676           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  115677           5 :      SgWaitStatement* pointer = NULL;
  115678           5 :      std::vector < unsigned char* > :: const_iterator block;
  115679           5 :      SgWaitStatement* pointerOfLinkedList = NULL;
  115680           5 :      for ( block = SgWaitStatement::pools.begin(); block != SgWaitStatement::pools.end() ; ++block )
  115681             :         {
  115682           0 :           pointer = (SgWaitStatement*)(*block);
  115683           0 :           for (unsigned i = 0; i < SgWaitStatement::pool_size; ++i )
  115684             :              {
  115685             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  115686             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  115687             :             // memory blocks!.
  115688           0 :                if ( pointer[i].get_freepointer() != NULL )
  115689             :                   {
  115690           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  115691             :                   }
  115692             :                else
  115693             :                   {
  115694           0 :                     if ( pointerOfLinkedList == NULL )
  115695             :                        {
  115696           0 :                          SgWaitStatement::next_node = &(pointer[i]);
  115697             :                        }
  115698             :                     else
  115699             :                        {
  115700             :                       // printf ("In SgWaitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  115701           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  115702             :                        }
  115703             :                     pointerOfLinkedList = &(pointer[i]);
  115704             :                   }
  115705             :               }
  115706             :         }
  115707             : 
  115708           5 :      if ( pointerOfLinkedList != NULL )
  115709             :         {
  115710             :        // printf ("In SgWaitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  115711           0 :           pointerOfLinkedList->set_freepointer(NULL);
  115712             :        // DQ (6/6/2010): Temporary debugging...
  115713             :        //   ROSE_ASSERT(false);
  115714             :         }
  115715             : 
  115716           5 :      return ;
  115717             :    }
  115718             : 
  115719             : //############################################################################
  115720             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  115721             :  * within the memory pool and resets the freepointers, in order to achieve a 
  115722             :  * linked list, that has no jumps and starts at the beginning! This function 
  115723             :  * does not extend the memory pool, since we do not delete any memory blocks,
  115724             :  * but delete the valid objects.  
  115725             :  */
  115726             : void
  115727           0 : SgWaitStatement::clearMemoryPool( )
  115728             :    {
  115729             :   // printf ("Inside of SgWaitStatement::clearMemoryPool() \n");
  115730             : 
  115731           0 :      SgWaitStatement* pointer = NULL, *tempPointer = NULL;
  115732           0 :      std::vector < unsigned char* > :: const_iterator block;
  115733           0 :      if ( SgWaitStatement::pools.empty() == false )
  115734             :         {
  115735           0 :           block = SgWaitStatement::pools.begin() ;
  115736           0 :           SgWaitStatement::next_node = (SgWaitStatement*) (*block);
  115737             : 
  115738           0 :           while ( block != SgWaitStatement::pools.end() )
  115739             :              {
  115740           0 :                pointer = (SgWaitStatement*) (*block);
  115741           0 :                if ( tempPointer != NULL )
  115742             :                   {
  115743           0 :                     tempPointer->set_freepointer(pointer);
  115744             :                   }
  115745           0 :                for (unsigned i = 0; i < SgWaitStatement::pool_size - 1; ++i)
  115746             :                   {
  115747           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  115748             :                   }
  115749           0 :                 pointer[SgWaitStatement::pool_size-1].set_freepointer(NULL);
  115750           0 :                 tempPointer = &(pointer[SgWaitStatement::pool_size-1]);
  115751           0 :                 ++block;
  115752             :              }
  115753             :         }
  115754           0 :    }
  115755             : 
  115756           5 : void SgWaitStatement::deleteMemoryPool() {
  115757           5 :   for (auto p: SgWaitStatement::pools) {
  115758           0 :     ROSE_FREE(p);
  115759             :   }
  115760           5 :   SgWaitStatement::next_node = nullptr;
  115761           5 :   SgWaitStatement::pools.clear();
  115762           5 : }
  115763             : 
  115764             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  115765             : //                 reading multiple binary files to for a single AST.
  115766             : /////////// new version ////////////////////////////////
  115767             : //############################################################################
  115768             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  115769             : void
  115770           2 : SgWaitStatement::extendMemoryPoolForFileIO( )
  115771             :   {
  115772           2 :     size_t blockIndex = SgWaitStatement::pools.size();
  115773           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgWaitStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgWaitStatement);
  115774             : 
  115775           2 :     while ( (blockIndex * SgWaitStatement::pool_size) < newPoolSize)
  115776             :       {
  115777             : #if ROSE_ALLOC_TRACE
  115778             :         if (blockIndex > 0) {
  115779             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgWaitStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgWaitStatement) = %" PRIuPTR " SgWaitStatement::pool_size = %d \n",
  115780             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgWaitStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgWaitStatement),SgWaitStatement::pool_size);
  115781             :         }
  115782             : #endif
  115783             : 
  115784           0 :         SgWaitStatement * pointer = (SgWaitStatement*) ROSE_MALLOC ( SgWaitStatement::pool_size * sizeof(SgWaitStatement) );
  115785           0 :         assert( pointer != NULL );
  115786             : #if ROSE_ALLOC_MEMSET == 1
  115787             :         memset(pointer, 0x00, SgWaitStatement::pool_size * sizeof(SgWaitStatement));
  115788             : #elif ROSE_ALLOC_MEMSET == 2
  115789             :         memset(pointer, 0xCC, SgWaitStatement::pool_size * sizeof(SgWaitStatement));
  115790             : #endif
  115791           0 :         SgWaitStatement::pools.push_back( (unsigned char*)(pointer) );
  115792           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgWaitStatement::pool_size * sizeof(SgWaitStatement), V_SgWaitStatement ) );
  115793             : 
  115794           0 :         if ( SgWaitStatement::next_node != NULL ) {
  115795           0 :           if ( blockIndex > 0 ) {
  115796           0 :             SgWaitStatement * blkptr = (SgWaitStatement*)(SgWaitStatement::pools[blockIndex-1]);
  115797           0 :             blkptr[ SgWaitStatement::pool_size - 1 ].set_freepointer(pointer);
  115798             :           }
  115799             :         } else {
  115800           0 :           SgWaitStatement::next_node = pointer;
  115801             :         }
  115802             : 
  115803           0 :         for (unsigned i = 0; i < SgWaitStatement::pool_size-1; ++i)
  115804             :            {
  115805           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  115806             :            }
  115807           0 :         pointer[ SgWaitStatement::pool_size -1 ].set_freepointer(NULL);
  115808             : 
  115809           0 :         blockIndex++;
  115810             :       }
  115811           2 :   }
  115812             : 
  115813             : //############################################################################
  115814             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  115815             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  115816             :  * not compressed. However, that stuff is not yet implemented! 
  115817             :  */
  115818             : unsigned long
  115819           0 : SgWaitStatement::getNumberOfLastValidPointer()
  115820             :    {
  115821           0 :       SgWaitStatement* testPointer = (SgWaitStatement*)(SgWaitStatement::pools.back());
  115822           0 :       unsigned long localIndex = SgWaitStatement::pool_size - 1;
  115823           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  115824             :          {
  115825           0 :            localIndex--;
  115826             :          }
  115827           0 :       return (localIndex + SgWaitStatement::pool_size * (SgWaitStatement::pools.size()-1));
  115828             :    }
  115829             : 
  115830             : //############################################################################
  115831             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  115832             :  * memory pool and initializes the data member in class SgWaitStatementStroageClass
  115833             :  * from its counterpart of SgWaitStatement. The return value is just for checking, 
  115834             :  * that the whole StorageClassArray is initialized!
  115835             :  */
  115836             : unsigned long
  115837           0 : SgWaitStatement::initializeStorageClassArray( SgWaitStatementStorageClass *storageArray )
  115838             :    {
  115839           0 :      unsigned long storageCounter = 0;
  115840           0 :      std::vector < unsigned char* > :: const_iterator block = SgWaitStatement::pools.begin();
  115841           0 :      SgWaitStatement* pointer = NULL;
  115842           0 :      while ( block != SgWaitStatement::pools.end() ) {
  115843           0 :           pointer = (SgWaitStatement*) (*block);
  115844           0 :           for ( unsigned i = 0; i < SgWaitStatement::pool_size; ++i ) {
  115845           0 :                if ( pointer->get_freepointer() != NULL ) {
  115846           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  115847           0 :                  storageArray++;
  115848           0 :                  storageCounter++;
  115849             :                }
  115850           0 :                pointer++;
  115851             :              }
  115852           0 :            block++;
  115853             :         }
  115854           0 :      return storageCounter;
  115855             :    }
  115856             : 
  115857             : /* #line 115858 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  115858             : 
  115859             : 
  115860             : 
  115861             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  115862             : 
  115863             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  115864             : 
  115865             : //############################################################################
  115866             : /* JH (02/02/2006) Constructor of the IR node SgWhereStatement that takes its 
  115867             :  * corresponding StorageClass as parameter
  115868             :  */
  115869           0 : SgWhereStatement :: SgWhereStatement ( const SgWhereStatementStorageClass& storageSource )   : SgStatement (storageSource)
  115870             :    {
  115871             : 
  115872             : 
  115873             : /* #line 115874 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  115874             : 
  115875           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  115876           0 :      p_condition =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_condition) );
  115877           0 :      p_body =  (SgBasicBlock*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
  115878           0 :      p_elsewhere =  (SgElseWhereStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_elsewhere) );
  115879           0 :      p_end_numeric_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end_numeric_label) );
  115880           0 :      p_string_label = storageSource.storageOf_string_label.rebuildDataStoredInEasyStorageClass() ;
  115881           0 :      p_has_end_statement = storageSource.storageOf_has_end_statement ;
  115882             : 
  115883             : 
  115884             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  115885             : 
  115886             : 
  115887           0 :    }
  115888             : 
  115889             : //############################################################################
  115890             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  115891             :  * within the working AST. 
  115892             :  */
  115893           0 : SgWhereStatement * SgWhereStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  115894           0 :      SgWhereStatement* returnPointer = NULL;
  115895           0 :      if ( globalIndex != 0 )
  115896             :         {
  115897             : 
  115898             : #if FILE_IO_EXTRA_CHECK
  115899           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgWhereStatement ) ) <= globalIndex ) ;
  115900           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWhereStatement + 1 ) ) );
  115901             : #endif
  115902           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWhereStatement )  
  115903           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgWhereStatement );
  115904           0 :           unsigned long positionInPool = localIndex % SgWhereStatement::pool_size;
  115905           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWhereStatement::pool_size;
  115906             : 
  115907             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  115908             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  115909             : 
  115910           0 :           returnPointer = &( ( (SgWhereStatement*)(SgWhereStatement::pools[memoryBlock]) ) [positionInPool]) ;
  115911             : 
  115912           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  115913             :         }
  115914           0 :      return returnPointer ;
  115915             :    }
  115916             : 
  115917             : //############################################################################
  115918             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  115919             :   for the AST with the index astIndex
  115920             : */
  115921           0 : SgWhereStatement * SgWhereStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  115922           0 :      SgWhereStatement* returnPointer = NULL;
  115923           0 :      if ( globalIndex != 0 )
  115924             :         {
  115925             : 
  115926             : #if FILE_IO_EXTRA_CHECK
  115927           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgWhereStatement ) ) <= globalIndex ) ;
  115928           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWhereStatement + 1 ) ) );
  115929             : #endif
  115930           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWhereStatement )
  115931           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgWhereStatement );
  115932           0 :           unsigned long positionInPool = localIndex % SgWhereStatement::pool_size ;
  115933           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWhereStatement::pool_size ;
  115934             : 
  115935             : #if FILE_IO_EXTRA_CHECK
  115936             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  115937             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  115938             : #endif
  115939             : 
  115940           0 :           returnPointer = &( ( (SgWhereStatement*)(SgWhereStatement::pools[memoryBlock]) ) [positionInPool]) ;
  115941             : 
  115942             : #if FILE_IO_EXTRA_CHECK
  115943           0 :           assert ( returnPointer != NULL ) ;
  115944             : #endif
  115945             :         }
  115946           0 :      return returnPointer ;
  115947             :    }
  115948             : 
  115949             : //############################################################################
  115950             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  115951             :  * pool size! We set for every valid object in the memory pool the freepointer
  115952             :  * to the global index and increase the global index afterwards. For all the 
  115953             :  * invalid objects (means address ranges within the memory pool that were not
  115954             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  115955             :  * distinguish valid from invalid objects! 
  115956             :  */
  115957             : unsigned long
  115958           5 : SgWhereStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  115959             :    {
  115960           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  115961           5 :      SgWhereStatement* pointer = NULL;
  115962           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  115963           5 :      std::vector < unsigned char* > :: const_iterator block;
  115964           5 :      for ( block = SgWhereStatement::pools.begin(); block != SgWhereStatement::pools.end() ; ++block )
  115965             :         {
  115966           0 :           pointer = (SgWhereStatement*)(*block);
  115967           0 :           for (unsigned i = 0; i < SgWhereStatement::pool_size; ++i )
  115968             :              {
  115969             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  115970             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  115971             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  115972             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  115973             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  115974             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  115975             :             // properly; so this will have to be checked next.
  115976             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  115977             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  115978           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  115979             :                   {
  115980           0 :                     pointer[i].set_freepointer((SgWhereStatement*)(globalIndex));
  115981           0 :                     globalIndex++;
  115982             :                   }
  115983             :                else
  115984             :                   {
  115985           0 :                     pointer[i].set_freepointer(NULL);
  115986             :                   }
  115987             :               }
  115988             :         }
  115989           5 :      return globalIndex;
  115990             :    }
  115991             : 
  115992             : //############################################################################
  115993             : // JH (01/14/2006)
  115994             : void
  115995           5 : SgWhereStatement::resetValidFreepointers( )
  115996             :    {
  115997           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  115998           5 :      SgWhereStatement* pointer = NULL;
  115999           5 :      std::vector < unsigned char* > :: const_iterator block;
  116000           5 :      SgWhereStatement* pointerOfLinkedList = NULL;
  116001           5 :      for ( block = SgWhereStatement::pools.begin(); block != SgWhereStatement::pools.end() ; ++block )
  116002             :         {
  116003           0 :           pointer = (SgWhereStatement*)(*block);
  116004           0 :           for (unsigned i = 0; i < SgWhereStatement::pool_size; ++i )
  116005             :              {
  116006             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  116007             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  116008             :             // memory blocks!.
  116009           0 :                if ( pointer[i].get_freepointer() != NULL )
  116010             :                   {
  116011           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  116012             :                   }
  116013             :                else
  116014             :                   {
  116015           0 :                     if ( pointerOfLinkedList == NULL )
  116016             :                        {
  116017           0 :                          SgWhereStatement::next_node = &(pointer[i]);
  116018             :                        }
  116019             :                     else
  116020             :                        {
  116021             :                       // printf ("In SgWhereStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  116022           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  116023             :                        }
  116024             :                     pointerOfLinkedList = &(pointer[i]);
  116025             :                   }
  116026             :               }
  116027             :         }
  116028             : 
  116029           5 :      if ( pointerOfLinkedList != NULL )
  116030             :         {
  116031             :        // printf ("In SgWhereStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  116032           0 :           pointerOfLinkedList->set_freepointer(NULL);
  116033             :        // DQ (6/6/2010): Temporary debugging...
  116034             :        //   ROSE_ASSERT(false);
  116035             :         }
  116036             : 
  116037           5 :      return ;
  116038             :    }
  116039             : 
  116040             : //############################################################################
  116041             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  116042             :  * within the memory pool and resets the freepointers, in order to achieve a 
  116043             :  * linked list, that has no jumps and starts at the beginning! This function 
  116044             :  * does not extend the memory pool, since we do not delete any memory blocks,
  116045             :  * but delete the valid objects.  
  116046             :  */
  116047             : void
  116048           0 : SgWhereStatement::clearMemoryPool( )
  116049             :    {
  116050             :   // printf ("Inside of SgWhereStatement::clearMemoryPool() \n");
  116051             : 
  116052           0 :      SgWhereStatement* pointer = NULL, *tempPointer = NULL;
  116053           0 :      std::vector < unsigned char* > :: const_iterator block;
  116054           0 :      if ( SgWhereStatement::pools.empty() == false )
  116055             :         {
  116056           0 :           block = SgWhereStatement::pools.begin() ;
  116057           0 :           SgWhereStatement::next_node = (SgWhereStatement*) (*block);
  116058             : 
  116059           0 :           while ( block != SgWhereStatement::pools.end() )
  116060             :              {
  116061           0 :                pointer = (SgWhereStatement*) (*block);
  116062           0 :                if ( tempPointer != NULL )
  116063             :                   {
  116064           0 :                     tempPointer->set_freepointer(pointer);
  116065             :                   }
  116066           0 :                for (unsigned i = 0; i < SgWhereStatement::pool_size - 1; ++i)
  116067             :                   {
  116068           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  116069             :                   }
  116070           0 :                 pointer[SgWhereStatement::pool_size-1].set_freepointer(NULL);
  116071           0 :                 tempPointer = &(pointer[SgWhereStatement::pool_size-1]);
  116072           0 :                 ++block;
  116073             :              }
  116074             :         }
  116075           0 :    }
  116076             : 
  116077           5 : void SgWhereStatement::deleteMemoryPool() {
  116078           5 :   for (auto p: SgWhereStatement::pools) {
  116079           0 :     ROSE_FREE(p);
  116080             :   }
  116081           5 :   SgWhereStatement::next_node = nullptr;
  116082           5 :   SgWhereStatement::pools.clear();
  116083           5 : }
  116084             : 
  116085             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  116086             : //                 reading multiple binary files to for a single AST.
  116087             : /////////// new version ////////////////////////////////
  116088             : //############################################################################
  116089             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  116090             : void
  116091           2 : SgWhereStatement::extendMemoryPoolForFileIO( )
  116092             :   {
  116093           2 :     size_t blockIndex = SgWhereStatement::pools.size();
  116094           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgWhereStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgWhereStatement);
  116095             : 
  116096           2 :     while ( (blockIndex * SgWhereStatement::pool_size) < newPoolSize)
  116097             :       {
  116098             : #if ROSE_ALLOC_TRACE
  116099             :         if (blockIndex > 0) {
  116100             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgWhereStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgWhereStatement) = %" PRIuPTR " SgWhereStatement::pool_size = %d \n",
  116101             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgWhereStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgWhereStatement),SgWhereStatement::pool_size);
  116102             :         }
  116103             : #endif
  116104             : 
  116105           0 :         SgWhereStatement * pointer = (SgWhereStatement*) ROSE_MALLOC ( SgWhereStatement::pool_size * sizeof(SgWhereStatement) );
  116106           0 :         assert( pointer != NULL );
  116107             : #if ROSE_ALLOC_MEMSET == 1
  116108             :         memset(pointer, 0x00, SgWhereStatement::pool_size * sizeof(SgWhereStatement));
  116109             : #elif ROSE_ALLOC_MEMSET == 2
  116110             :         memset(pointer, 0xCC, SgWhereStatement::pool_size * sizeof(SgWhereStatement));
  116111             : #endif
  116112           0 :         SgWhereStatement::pools.push_back( (unsigned char*)(pointer) );
  116113           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgWhereStatement::pool_size * sizeof(SgWhereStatement), V_SgWhereStatement ) );
  116114             : 
  116115           0 :         if ( SgWhereStatement::next_node != NULL ) {
  116116           0 :           if ( blockIndex > 0 ) {
  116117           0 :             SgWhereStatement * blkptr = (SgWhereStatement*)(SgWhereStatement::pools[blockIndex-1]);
  116118           0 :             blkptr[ SgWhereStatement::pool_size - 1 ].set_freepointer(pointer);
  116119             :           }
  116120             :         } else {
  116121           0 :           SgWhereStatement::next_node = pointer;
  116122             :         }
  116123             : 
  116124           0 :         for (unsigned i = 0; i < SgWhereStatement::pool_size-1; ++i)
  116125             :            {
  116126           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  116127             :            }
  116128           0 :         pointer[ SgWhereStatement::pool_size -1 ].set_freepointer(NULL);
  116129             : 
  116130           0 :         blockIndex++;
  116131             :       }
  116132           2 :   }
  116133             : 
  116134             : //############################################################################
  116135             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  116136             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  116137             :  * not compressed. However, that stuff is not yet implemented! 
  116138             :  */
  116139             : unsigned long
  116140           0 : SgWhereStatement::getNumberOfLastValidPointer()
  116141             :    {
  116142           0 :       SgWhereStatement* testPointer = (SgWhereStatement*)(SgWhereStatement::pools.back());
  116143           0 :       unsigned long localIndex = SgWhereStatement::pool_size - 1;
  116144           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  116145             :          {
  116146           0 :            localIndex--;
  116147             :          }
  116148           0 :       return (localIndex + SgWhereStatement::pool_size * (SgWhereStatement::pools.size()-1));
  116149             :    }
  116150             : 
  116151             : //############################################################################
  116152             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  116153             :  * memory pool and initializes the data member in class SgWhereStatementStroageClass
  116154             :  * from its counterpart of SgWhereStatement. The return value is just for checking, 
  116155             :  * that the whole StorageClassArray is initialized!
  116156             :  */
  116157             : unsigned long
  116158           0 : SgWhereStatement::initializeStorageClassArray( SgWhereStatementStorageClass *storageArray )
  116159             :    {
  116160           0 :      unsigned long storageCounter = 0;
  116161           0 :      std::vector < unsigned char* > :: const_iterator block = SgWhereStatement::pools.begin();
  116162           0 :      SgWhereStatement* pointer = NULL;
  116163           0 :      while ( block != SgWhereStatement::pools.end() ) {
  116164           0 :           pointer = (SgWhereStatement*) (*block);
  116165           0 :           for ( unsigned i = 0; i < SgWhereStatement::pool_size; ++i ) {
  116166           0 :                if ( pointer->get_freepointer() != NULL ) {
  116167           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  116168           0 :                  storageArray++;
  116169           0 :                  storageCounter++;
  116170             :                }
  116171           0 :                pointer++;
  116172             :              }
  116173           0 :            block++;
  116174             :         }
  116175           0 :      return storageCounter;
  116176             :    }
  116177             : 
  116178             : /* #line 116179 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  116179             : 
  116180             : 
  116181             : 
  116182             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  116183             : 
  116184             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  116185             : 
  116186             : //############################################################################
  116187             : /* JH (02/02/2006) Constructor of the IR node SgElseWhereStatement that takes its 
  116188             :  * corresponding StorageClass as parameter
  116189             :  */
  116190           0 : SgElseWhereStatement :: SgElseWhereStatement ( const SgElseWhereStatementStorageClass& storageSource )   : SgStatement (storageSource)
  116191             :    {
  116192             : 
  116193             : 
  116194             : /* #line 116195 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  116195             : 
  116196           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  116197           0 :      p_condition =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_condition) );
  116198           0 :      p_body =  (SgBasicBlock*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
  116199           0 :      p_elsewhere =  (SgElseWhereStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_elsewhere) );
  116200             : 
  116201             : 
  116202             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  116203             : 
  116204             : 
  116205           0 :    }
  116206             : 
  116207             : //############################################################################
  116208             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  116209             :  * within the working AST. 
  116210             :  */
  116211           0 : SgElseWhereStatement * SgElseWhereStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  116212           0 :      SgElseWhereStatement* returnPointer = NULL;
  116213           0 :      if ( globalIndex != 0 )
  116214             :         {
  116215             : 
  116216             : #if FILE_IO_EXTRA_CHECK
  116217           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElseWhereStatement ) ) <= globalIndex ) ;
  116218           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElseWhereStatement + 1 ) ) );
  116219             : #endif
  116220           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElseWhereStatement )  
  116221           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElseWhereStatement );
  116222           0 :           unsigned long positionInPool = localIndex % SgElseWhereStatement::pool_size;
  116223           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElseWhereStatement::pool_size;
  116224             : 
  116225             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  116226             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  116227             : 
  116228           0 :           returnPointer = &( ( (SgElseWhereStatement*)(SgElseWhereStatement::pools[memoryBlock]) ) [positionInPool]) ;
  116229             : 
  116230           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  116231             :         }
  116232           0 :      return returnPointer ;
  116233             :    }
  116234             : 
  116235             : //############################################################################
  116236             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  116237             :   for the AST with the index astIndex
  116238             : */
  116239           0 : SgElseWhereStatement * SgElseWhereStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  116240           0 :      SgElseWhereStatement* returnPointer = NULL;
  116241           0 :      if ( globalIndex != 0 )
  116242             :         {
  116243             : 
  116244             : #if FILE_IO_EXTRA_CHECK
  116245           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElseWhereStatement ) ) <= globalIndex ) ;
  116246           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElseWhereStatement + 1 ) ) );
  116247             : #endif
  116248           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElseWhereStatement )
  116249           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElseWhereStatement );
  116250           0 :           unsigned long positionInPool = localIndex % SgElseWhereStatement::pool_size ;
  116251           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElseWhereStatement::pool_size ;
  116252             : 
  116253             : #if FILE_IO_EXTRA_CHECK
  116254             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  116255             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  116256             : #endif
  116257             : 
  116258           0 :           returnPointer = &( ( (SgElseWhereStatement*)(SgElseWhereStatement::pools[memoryBlock]) ) [positionInPool]) ;
  116259             : 
  116260             : #if FILE_IO_EXTRA_CHECK
  116261           0 :           assert ( returnPointer != NULL ) ;
  116262             : #endif
  116263             :         }
  116264           0 :      return returnPointer ;
  116265             :    }
  116266             : 
  116267             : //############################################################################
  116268             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  116269             :  * pool size! We set for every valid object in the memory pool the freepointer
  116270             :  * to the global index and increase the global index afterwards. For all the 
  116271             :  * invalid objects (means address ranges within the memory pool that were not
  116272             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  116273             :  * distinguish valid from invalid objects! 
  116274             :  */
  116275             : unsigned long
  116276           5 : SgElseWhereStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  116277             :    {
  116278           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  116279           5 :      SgElseWhereStatement* pointer = NULL;
  116280           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  116281           5 :      std::vector < unsigned char* > :: const_iterator block;
  116282           5 :      for ( block = SgElseWhereStatement::pools.begin(); block != SgElseWhereStatement::pools.end() ; ++block )
  116283             :         {
  116284           0 :           pointer = (SgElseWhereStatement*)(*block);
  116285           0 :           for (unsigned i = 0; i < SgElseWhereStatement::pool_size; ++i )
  116286             :              {
  116287             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  116288             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  116289             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  116290             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  116291             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  116292             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  116293             :             // properly; so this will have to be checked next.
  116294             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  116295             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  116296           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  116297             :                   {
  116298           0 :                     pointer[i].set_freepointer((SgElseWhereStatement*)(globalIndex));
  116299           0 :                     globalIndex++;
  116300             :                   }
  116301             :                else
  116302             :                   {
  116303           0 :                     pointer[i].set_freepointer(NULL);
  116304             :                   }
  116305             :               }
  116306             :         }
  116307           5 :      return globalIndex;
  116308             :    }
  116309             : 
  116310             : //############################################################################
  116311             : // JH (01/14/2006)
  116312             : void
  116313           5 : SgElseWhereStatement::resetValidFreepointers( )
  116314             :    {
  116315           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  116316           5 :      SgElseWhereStatement* pointer = NULL;
  116317           5 :      std::vector < unsigned char* > :: const_iterator block;
  116318           5 :      SgElseWhereStatement* pointerOfLinkedList = NULL;
  116319           5 :      for ( block = SgElseWhereStatement::pools.begin(); block != SgElseWhereStatement::pools.end() ; ++block )
  116320             :         {
  116321           0 :           pointer = (SgElseWhereStatement*)(*block);
  116322           0 :           for (unsigned i = 0; i < SgElseWhereStatement::pool_size; ++i )
  116323             :              {
  116324             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  116325             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  116326             :             // memory blocks!.
  116327           0 :                if ( pointer[i].get_freepointer() != NULL )
  116328             :                   {
  116329           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  116330             :                   }
  116331             :                else
  116332             :                   {
  116333           0 :                     if ( pointerOfLinkedList == NULL )
  116334             :                        {
  116335           0 :                          SgElseWhereStatement::next_node = &(pointer[i]);
  116336             :                        }
  116337             :                     else
  116338             :                        {
  116339             :                       // printf ("In SgElseWhereStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  116340           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  116341             :                        }
  116342             :                     pointerOfLinkedList = &(pointer[i]);
  116343             :                   }
  116344             :               }
  116345             :         }
  116346             : 
  116347           5 :      if ( pointerOfLinkedList != NULL )
  116348             :         {
  116349             :        // printf ("In SgElseWhereStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  116350           0 :           pointerOfLinkedList->set_freepointer(NULL);
  116351             :        // DQ (6/6/2010): Temporary debugging...
  116352             :        //   ROSE_ASSERT(false);
  116353             :         }
  116354             : 
  116355           5 :      return ;
  116356             :    }
  116357             : 
  116358             : //############################################################################
  116359             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  116360             :  * within the memory pool and resets the freepointers, in order to achieve a 
  116361             :  * linked list, that has no jumps and starts at the beginning! This function 
  116362             :  * does not extend the memory pool, since we do not delete any memory blocks,
  116363             :  * but delete the valid objects.  
  116364             :  */
  116365             : void
  116366           0 : SgElseWhereStatement::clearMemoryPool( )
  116367             :    {
  116368             :   // printf ("Inside of SgElseWhereStatement::clearMemoryPool() \n");
  116369             : 
  116370           0 :      SgElseWhereStatement* pointer = NULL, *tempPointer = NULL;
  116371           0 :      std::vector < unsigned char* > :: const_iterator block;
  116372           0 :      if ( SgElseWhereStatement::pools.empty() == false )
  116373             :         {
  116374           0 :           block = SgElseWhereStatement::pools.begin() ;
  116375           0 :           SgElseWhereStatement::next_node = (SgElseWhereStatement*) (*block);
  116376             : 
  116377           0 :           while ( block != SgElseWhereStatement::pools.end() )
  116378             :              {
  116379           0 :                pointer = (SgElseWhereStatement*) (*block);
  116380           0 :                if ( tempPointer != NULL )
  116381             :                   {
  116382           0 :                     tempPointer->set_freepointer(pointer);
  116383             :                   }
  116384           0 :                for (unsigned i = 0; i < SgElseWhereStatement::pool_size - 1; ++i)
  116385             :                   {
  116386           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  116387             :                   }
  116388           0 :                 pointer[SgElseWhereStatement::pool_size-1].set_freepointer(NULL);
  116389           0 :                 tempPointer = &(pointer[SgElseWhereStatement::pool_size-1]);
  116390           0 :                 ++block;
  116391             :              }
  116392             :         }
  116393           0 :    }
  116394             : 
  116395           5 : void SgElseWhereStatement::deleteMemoryPool() {
  116396           5 :   for (auto p: SgElseWhereStatement::pools) {
  116397           0 :     ROSE_FREE(p);
  116398             :   }
  116399           5 :   SgElseWhereStatement::next_node = nullptr;
  116400           5 :   SgElseWhereStatement::pools.clear();
  116401           5 : }
  116402             : 
  116403             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  116404             : //                 reading multiple binary files to for a single AST.
  116405             : /////////// new version ////////////////////////////////
  116406             : //############################################################################
  116407             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  116408             : void
  116409           2 : SgElseWhereStatement::extendMemoryPoolForFileIO( )
  116410             :   {
  116411           2 :     size_t blockIndex = SgElseWhereStatement::pools.size();
  116412           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElseWhereStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseWhereStatement);
  116413             : 
  116414           2 :     while ( (blockIndex * SgElseWhereStatement::pool_size) < newPoolSize)
  116415             :       {
  116416             : #if ROSE_ALLOC_TRACE
  116417             :         if (blockIndex > 0) {
  116418             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElseWhereStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseWhereStatement) = %" PRIuPTR " SgElseWhereStatement::pool_size = %d \n",
  116419             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElseWhereStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElseWhereStatement),SgElseWhereStatement::pool_size);
  116420             :         }
  116421             : #endif
  116422             : 
  116423           0 :         SgElseWhereStatement * pointer = (SgElseWhereStatement*) ROSE_MALLOC ( SgElseWhereStatement::pool_size * sizeof(SgElseWhereStatement) );
  116424           0 :         assert( pointer != NULL );
  116425             : #if ROSE_ALLOC_MEMSET == 1
  116426             :         memset(pointer, 0x00, SgElseWhereStatement::pool_size * sizeof(SgElseWhereStatement));
  116427             : #elif ROSE_ALLOC_MEMSET == 2
  116428             :         memset(pointer, 0xCC, SgElseWhereStatement::pool_size * sizeof(SgElseWhereStatement));
  116429             : #endif
  116430           0 :         SgElseWhereStatement::pools.push_back( (unsigned char*)(pointer) );
  116431           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElseWhereStatement::pool_size * sizeof(SgElseWhereStatement), V_SgElseWhereStatement ) );
  116432             : 
  116433           0 :         if ( SgElseWhereStatement::next_node != NULL ) {
  116434           0 :           if ( blockIndex > 0 ) {
  116435           0 :             SgElseWhereStatement * blkptr = (SgElseWhereStatement*)(SgElseWhereStatement::pools[blockIndex-1]);
  116436           0 :             blkptr[ SgElseWhereStatement::pool_size - 1 ].set_freepointer(pointer);
  116437             :           }
  116438             :         } else {
  116439           0 :           SgElseWhereStatement::next_node = pointer;
  116440             :         }
  116441             : 
  116442           0 :         for (unsigned i = 0; i < SgElseWhereStatement::pool_size-1; ++i)
  116443             :            {
  116444           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  116445             :            }
  116446           0 :         pointer[ SgElseWhereStatement::pool_size -1 ].set_freepointer(NULL);
  116447             : 
  116448           0 :         blockIndex++;
  116449             :       }
  116450           2 :   }
  116451             : 
  116452             : //############################################################################
  116453             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  116454             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  116455             :  * not compressed. However, that stuff is not yet implemented! 
  116456             :  */
  116457             : unsigned long
  116458           0 : SgElseWhereStatement::getNumberOfLastValidPointer()
  116459             :    {
  116460           0 :       SgElseWhereStatement* testPointer = (SgElseWhereStatement*)(SgElseWhereStatement::pools.back());
  116461           0 :       unsigned long localIndex = SgElseWhereStatement::pool_size - 1;
  116462           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  116463             :          {
  116464           0 :            localIndex--;
  116465             :          }
  116466           0 :       return (localIndex + SgElseWhereStatement::pool_size * (SgElseWhereStatement::pools.size()-1));
  116467             :    }
  116468             : 
  116469             : //############################################################################
  116470             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  116471             :  * memory pool and initializes the data member in class SgElseWhereStatementStroageClass
  116472             :  * from its counterpart of SgElseWhereStatement. The return value is just for checking, 
  116473             :  * that the whole StorageClassArray is initialized!
  116474             :  */
  116475             : unsigned long
  116476           0 : SgElseWhereStatement::initializeStorageClassArray( SgElseWhereStatementStorageClass *storageArray )
  116477             :    {
  116478           0 :      unsigned long storageCounter = 0;
  116479           0 :      std::vector < unsigned char* > :: const_iterator block = SgElseWhereStatement::pools.begin();
  116480           0 :      SgElseWhereStatement* pointer = NULL;
  116481           0 :      while ( block != SgElseWhereStatement::pools.end() ) {
  116482           0 :           pointer = (SgElseWhereStatement*) (*block);
  116483           0 :           for ( unsigned i = 0; i < SgElseWhereStatement::pool_size; ++i ) {
  116484           0 :                if ( pointer->get_freepointer() != NULL ) {
  116485           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  116486           0 :                  storageArray++;
  116487           0 :                  storageCounter++;
  116488             :                }
  116489           0 :                pointer++;
  116490             :              }
  116491           0 :            block++;
  116492             :         }
  116493           0 :      return storageCounter;
  116494             :    }
  116495             : 
  116496             : /* #line 116497 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  116497             : 
  116498             : 
  116499             : 
  116500             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  116501             : 
  116502             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  116503             : 
  116504             : //############################################################################
  116505             : /* JH (02/02/2006) Constructor of the IR node SgNullifyStatement that takes its 
  116506             :  * corresponding StorageClass as parameter
  116507             :  */
  116508           0 : SgNullifyStatement :: SgNullifyStatement ( const SgNullifyStatementStorageClass& storageSource )   : SgStatement (storageSource)
  116509             :    {
  116510             : 
  116511             : 
  116512             : /* #line 116513 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  116513             : 
  116514           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  116515           0 :      p_pointer_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_pointer_list) );
  116516             : 
  116517             : 
  116518             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  116519             : 
  116520             : 
  116521           0 :    }
  116522             : 
  116523             : //############################################################################
  116524             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  116525             :  * within the working AST. 
  116526             :  */
  116527           0 : SgNullifyStatement * SgNullifyStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  116528           0 :      SgNullifyStatement* returnPointer = NULL;
  116529           0 :      if ( globalIndex != 0 )
  116530             :         {
  116531             : 
  116532             : #if FILE_IO_EXTRA_CHECK
  116533           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNullifyStatement ) ) <= globalIndex ) ;
  116534           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNullifyStatement + 1 ) ) );
  116535             : #endif
  116536           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNullifyStatement )  
  116537           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNullifyStatement );
  116538           0 :           unsigned long positionInPool = localIndex % SgNullifyStatement::pool_size;
  116539           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNullifyStatement::pool_size;
  116540             : 
  116541             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  116542             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  116543             : 
  116544           0 :           returnPointer = &( ( (SgNullifyStatement*)(SgNullifyStatement::pools[memoryBlock]) ) [positionInPool]) ;
  116545             : 
  116546           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  116547             :         }
  116548           0 :      return returnPointer ;
  116549             :    }
  116550             : 
  116551             : //############################################################################
  116552             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  116553             :   for the AST with the index astIndex
  116554             : */
  116555           0 : SgNullifyStatement * SgNullifyStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  116556           0 :      SgNullifyStatement* returnPointer = NULL;
  116557           0 :      if ( globalIndex != 0 )
  116558             :         {
  116559             : 
  116560             : #if FILE_IO_EXTRA_CHECK
  116561           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNullifyStatement ) ) <= globalIndex ) ;
  116562           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNullifyStatement + 1 ) ) );
  116563             : #endif
  116564           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNullifyStatement )
  116565           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNullifyStatement );
  116566           0 :           unsigned long positionInPool = localIndex % SgNullifyStatement::pool_size ;
  116567           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNullifyStatement::pool_size ;
  116568             : 
  116569             : #if FILE_IO_EXTRA_CHECK
  116570             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  116571             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  116572             : #endif
  116573             : 
  116574           0 :           returnPointer = &( ( (SgNullifyStatement*)(SgNullifyStatement::pools[memoryBlock]) ) [positionInPool]) ;
  116575             : 
  116576             : #if FILE_IO_EXTRA_CHECK
  116577           0 :           assert ( returnPointer != NULL ) ;
  116578             : #endif
  116579             :         }
  116580           0 :      return returnPointer ;
  116581             :    }
  116582             : 
  116583             : //############################################################################
  116584             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  116585             :  * pool size! We set for every valid object in the memory pool the freepointer
  116586             :  * to the global index and increase the global index afterwards. For all the 
  116587             :  * invalid objects (means address ranges within the memory pool that were not
  116588             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  116589             :  * distinguish valid from invalid objects! 
  116590             :  */
  116591             : unsigned long
  116592           5 : SgNullifyStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  116593             :    {
  116594           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  116595           5 :      SgNullifyStatement* pointer = NULL;
  116596           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  116597           5 :      std::vector < unsigned char* > :: const_iterator block;
  116598           5 :      for ( block = SgNullifyStatement::pools.begin(); block != SgNullifyStatement::pools.end() ; ++block )
  116599             :         {
  116600           0 :           pointer = (SgNullifyStatement*)(*block);
  116601           0 :           for (unsigned i = 0; i < SgNullifyStatement::pool_size; ++i )
  116602             :              {
  116603             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  116604             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  116605             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  116606             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  116607             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  116608             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  116609             :             // properly; so this will have to be checked next.
  116610             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  116611             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  116612           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  116613             :                   {
  116614           0 :                     pointer[i].set_freepointer((SgNullifyStatement*)(globalIndex));
  116615           0 :                     globalIndex++;
  116616             :                   }
  116617             :                else
  116618             :                   {
  116619           0 :                     pointer[i].set_freepointer(NULL);
  116620             :                   }
  116621             :               }
  116622             :         }
  116623           5 :      return globalIndex;
  116624             :    }
  116625             : 
  116626             : //############################################################################
  116627             : // JH (01/14/2006)
  116628             : void
  116629           5 : SgNullifyStatement::resetValidFreepointers( )
  116630             :    {
  116631           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  116632           5 :      SgNullifyStatement* pointer = NULL;
  116633           5 :      std::vector < unsigned char* > :: const_iterator block;
  116634           5 :      SgNullifyStatement* pointerOfLinkedList = NULL;
  116635           5 :      for ( block = SgNullifyStatement::pools.begin(); block != SgNullifyStatement::pools.end() ; ++block )
  116636             :         {
  116637           0 :           pointer = (SgNullifyStatement*)(*block);
  116638           0 :           for (unsigned i = 0; i < SgNullifyStatement::pool_size; ++i )
  116639             :              {
  116640             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  116641             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  116642             :             // memory blocks!.
  116643           0 :                if ( pointer[i].get_freepointer() != NULL )
  116644             :                   {
  116645           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  116646             :                   }
  116647             :                else
  116648             :                   {
  116649           0 :                     if ( pointerOfLinkedList == NULL )
  116650             :                        {
  116651           0 :                          SgNullifyStatement::next_node = &(pointer[i]);
  116652             :                        }
  116653             :                     else
  116654             :                        {
  116655             :                       // printf ("In SgNullifyStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  116656           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  116657             :                        }
  116658             :                     pointerOfLinkedList = &(pointer[i]);
  116659             :                   }
  116660             :               }
  116661             :         }
  116662             : 
  116663           5 :      if ( pointerOfLinkedList != NULL )
  116664             :         {
  116665             :        // printf ("In SgNullifyStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  116666           0 :           pointerOfLinkedList->set_freepointer(NULL);
  116667             :        // DQ (6/6/2010): Temporary debugging...
  116668             :        //   ROSE_ASSERT(false);
  116669             :         }
  116670             : 
  116671           5 :      return ;
  116672             :    }
  116673             : 
  116674             : //############################################################################
  116675             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  116676             :  * within the memory pool and resets the freepointers, in order to achieve a 
  116677             :  * linked list, that has no jumps and starts at the beginning! This function 
  116678             :  * does not extend the memory pool, since we do not delete any memory blocks,
  116679             :  * but delete the valid objects.  
  116680             :  */
  116681             : void
  116682           0 : SgNullifyStatement::clearMemoryPool( )
  116683             :    {
  116684             :   // printf ("Inside of SgNullifyStatement::clearMemoryPool() \n");
  116685             : 
  116686           0 :      SgNullifyStatement* pointer = NULL, *tempPointer = NULL;
  116687           0 :      std::vector < unsigned char* > :: const_iterator block;
  116688           0 :      if ( SgNullifyStatement::pools.empty() == false )
  116689             :         {
  116690           0 :           block = SgNullifyStatement::pools.begin() ;
  116691           0 :           SgNullifyStatement::next_node = (SgNullifyStatement*) (*block);
  116692             : 
  116693           0 :           while ( block != SgNullifyStatement::pools.end() )
  116694             :              {
  116695           0 :                pointer = (SgNullifyStatement*) (*block);
  116696           0 :                if ( tempPointer != NULL )
  116697             :                   {
  116698           0 :                     tempPointer->set_freepointer(pointer);
  116699             :                   }
  116700           0 :                for (unsigned i = 0; i < SgNullifyStatement::pool_size - 1; ++i)
  116701             :                   {
  116702           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  116703             :                   }
  116704           0 :                 pointer[SgNullifyStatement::pool_size-1].set_freepointer(NULL);
  116705           0 :                 tempPointer = &(pointer[SgNullifyStatement::pool_size-1]);
  116706           0 :                 ++block;
  116707             :              }
  116708             :         }
  116709           0 :    }
  116710             : 
  116711           5 : void SgNullifyStatement::deleteMemoryPool() {
  116712           5 :   for (auto p: SgNullifyStatement::pools) {
  116713           0 :     ROSE_FREE(p);
  116714             :   }
  116715           5 :   SgNullifyStatement::next_node = nullptr;
  116716           5 :   SgNullifyStatement::pools.clear();
  116717           5 : }
  116718             : 
  116719             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  116720             : //                 reading multiple binary files to for a single AST.
  116721             : /////////// new version ////////////////////////////////
  116722             : //############################################################################
  116723             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  116724             : void
  116725           2 : SgNullifyStatement::extendMemoryPoolForFileIO( )
  116726             :   {
  116727           2 :     size_t blockIndex = SgNullifyStatement::pools.size();
  116728           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNullifyStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullifyStatement);
  116729             : 
  116730           2 :     while ( (blockIndex * SgNullifyStatement::pool_size) < newPoolSize)
  116731             :       {
  116732             : #if ROSE_ALLOC_TRACE
  116733             :         if (blockIndex > 0) {
  116734             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNullifyStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullifyStatement) = %" PRIuPTR " SgNullifyStatement::pool_size = %d \n",
  116735             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNullifyStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullifyStatement),SgNullifyStatement::pool_size);
  116736             :         }
  116737             : #endif
  116738             : 
  116739           0 :         SgNullifyStatement * pointer = (SgNullifyStatement*) ROSE_MALLOC ( SgNullifyStatement::pool_size * sizeof(SgNullifyStatement) );
  116740           0 :         assert( pointer != NULL );
  116741             : #if ROSE_ALLOC_MEMSET == 1
  116742             :         memset(pointer, 0x00, SgNullifyStatement::pool_size * sizeof(SgNullifyStatement));
  116743             : #elif ROSE_ALLOC_MEMSET == 2
  116744             :         memset(pointer, 0xCC, SgNullifyStatement::pool_size * sizeof(SgNullifyStatement));
  116745             : #endif
  116746           0 :         SgNullifyStatement::pools.push_back( (unsigned char*)(pointer) );
  116747           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNullifyStatement::pool_size * sizeof(SgNullifyStatement), V_SgNullifyStatement ) );
  116748             : 
  116749           0 :         if ( SgNullifyStatement::next_node != NULL ) {
  116750           0 :           if ( blockIndex > 0 ) {
  116751           0 :             SgNullifyStatement * blkptr = (SgNullifyStatement*)(SgNullifyStatement::pools[blockIndex-1]);
  116752           0 :             blkptr[ SgNullifyStatement::pool_size - 1 ].set_freepointer(pointer);
  116753             :           }
  116754             :         } else {
  116755           0 :           SgNullifyStatement::next_node = pointer;
  116756             :         }
  116757             : 
  116758           0 :         for (unsigned i = 0; i < SgNullifyStatement::pool_size-1; ++i)
  116759             :            {
  116760           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  116761             :            }
  116762           0 :         pointer[ SgNullifyStatement::pool_size -1 ].set_freepointer(NULL);
  116763             : 
  116764           0 :         blockIndex++;
  116765             :       }
  116766           2 :   }
  116767             : 
  116768             : //############################################################################
  116769             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  116770             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  116771             :  * not compressed. However, that stuff is not yet implemented! 
  116772             :  */
  116773             : unsigned long
  116774           0 : SgNullifyStatement::getNumberOfLastValidPointer()
  116775             :    {
  116776           0 :       SgNullifyStatement* testPointer = (SgNullifyStatement*)(SgNullifyStatement::pools.back());
  116777           0 :       unsigned long localIndex = SgNullifyStatement::pool_size - 1;
  116778           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  116779             :          {
  116780           0 :            localIndex--;
  116781             :          }
  116782           0 :       return (localIndex + SgNullifyStatement::pool_size * (SgNullifyStatement::pools.size()-1));
  116783             :    }
  116784             : 
  116785             : //############################################################################
  116786             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  116787             :  * memory pool and initializes the data member in class SgNullifyStatementStroageClass
  116788             :  * from its counterpart of SgNullifyStatement. The return value is just for checking, 
  116789             :  * that the whole StorageClassArray is initialized!
  116790             :  */
  116791             : unsigned long
  116792           0 : SgNullifyStatement::initializeStorageClassArray( SgNullifyStatementStorageClass *storageArray )
  116793             :    {
  116794           0 :      unsigned long storageCounter = 0;
  116795           0 :      std::vector < unsigned char* > :: const_iterator block = SgNullifyStatement::pools.begin();
  116796           0 :      SgNullifyStatement* pointer = NULL;
  116797           0 :      while ( block != SgNullifyStatement::pools.end() ) {
  116798           0 :           pointer = (SgNullifyStatement*) (*block);
  116799           0 :           for ( unsigned i = 0; i < SgNullifyStatement::pool_size; ++i ) {
  116800           0 :                if ( pointer->get_freepointer() != NULL ) {
  116801           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  116802           0 :                  storageArray++;
  116803           0 :                  storageCounter++;
  116804             :                }
  116805           0 :                pointer++;
  116806             :              }
  116807           0 :            block++;
  116808             :         }
  116809           0 :      return storageCounter;
  116810             :    }
  116811             : 
  116812             : /* #line 116813 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  116813             : 
  116814             : 
  116815             : 
  116816             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  116817             : 
  116818             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  116819             : 
  116820             : //############################################################################
  116821             : /* JH (02/02/2006) Constructor of the IR node SgArithmeticIfStatement that takes its 
  116822             :  * corresponding StorageClass as parameter
  116823             :  */
  116824           0 : SgArithmeticIfStatement :: SgArithmeticIfStatement ( const SgArithmeticIfStatementStorageClass& storageSource )   : SgStatement (storageSource)
  116825             :    {
  116826             : 
  116827             : 
  116828             : /* #line 116829 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  116829             : 
  116830           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  116831           0 :      p_conditional =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_conditional) );
  116832           0 :      p_less_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_less_label) );
  116833           0 :      p_equal_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_equal_label) );
  116834           0 :      p_greater_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_greater_label) );
  116835             : 
  116836             : 
  116837             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  116838             : 
  116839             : 
  116840           0 :    }
  116841             : 
  116842             : //############################################################################
  116843             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  116844             :  * within the working AST. 
  116845             :  */
  116846           0 : SgArithmeticIfStatement * SgArithmeticIfStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  116847           0 :      SgArithmeticIfStatement* returnPointer = NULL;
  116848           0 :      if ( globalIndex != 0 )
  116849             :         {
  116850             : 
  116851             : #if FILE_IO_EXTRA_CHECK
  116852           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgArithmeticIfStatement ) ) <= globalIndex ) ;
  116853           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgArithmeticIfStatement + 1 ) ) );
  116854             : #endif
  116855           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgArithmeticIfStatement )  
  116856           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgArithmeticIfStatement );
  116857           0 :           unsigned long positionInPool = localIndex % SgArithmeticIfStatement::pool_size;
  116858           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgArithmeticIfStatement::pool_size;
  116859             : 
  116860             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  116861             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  116862             : 
  116863           0 :           returnPointer = &( ( (SgArithmeticIfStatement*)(SgArithmeticIfStatement::pools[memoryBlock]) ) [positionInPool]) ;
  116864             : 
  116865           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  116866             :         }
  116867           0 :      return returnPointer ;
  116868             :    }
  116869             : 
  116870             : //############################################################################
  116871             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  116872             :   for the AST with the index astIndex
  116873             : */
  116874           0 : SgArithmeticIfStatement * SgArithmeticIfStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  116875           0 :      SgArithmeticIfStatement* returnPointer = NULL;
  116876           0 :      if ( globalIndex != 0 )
  116877             :         {
  116878             : 
  116879             : #if FILE_IO_EXTRA_CHECK
  116880           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgArithmeticIfStatement ) ) <= globalIndex ) ;
  116881           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgArithmeticIfStatement + 1 ) ) );
  116882             : #endif
  116883           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgArithmeticIfStatement )
  116884           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgArithmeticIfStatement );
  116885           0 :           unsigned long positionInPool = localIndex % SgArithmeticIfStatement::pool_size ;
  116886           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgArithmeticIfStatement::pool_size ;
  116887             : 
  116888             : #if FILE_IO_EXTRA_CHECK
  116889             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  116890             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  116891             : #endif
  116892             : 
  116893           0 :           returnPointer = &( ( (SgArithmeticIfStatement*)(SgArithmeticIfStatement::pools[memoryBlock]) ) [positionInPool]) ;
  116894             : 
  116895             : #if FILE_IO_EXTRA_CHECK
  116896           0 :           assert ( returnPointer != NULL ) ;
  116897             : #endif
  116898             :         }
  116899           0 :      return returnPointer ;
  116900             :    }
  116901             : 
  116902             : //############################################################################
  116903             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  116904             :  * pool size! We set for every valid object in the memory pool the freepointer
  116905             :  * to the global index and increase the global index afterwards. For all the 
  116906             :  * invalid objects (means address ranges within the memory pool that were not
  116907             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  116908             :  * distinguish valid from invalid objects! 
  116909             :  */
  116910             : unsigned long
  116911           5 : SgArithmeticIfStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  116912             :    {
  116913           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  116914           5 :      SgArithmeticIfStatement* pointer = NULL;
  116915           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  116916           5 :      std::vector < unsigned char* > :: const_iterator block;
  116917           5 :      for ( block = SgArithmeticIfStatement::pools.begin(); block != SgArithmeticIfStatement::pools.end() ; ++block )
  116918             :         {
  116919           0 :           pointer = (SgArithmeticIfStatement*)(*block);
  116920           0 :           for (unsigned i = 0; i < SgArithmeticIfStatement::pool_size; ++i )
  116921             :              {
  116922             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  116923             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  116924             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  116925             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  116926             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  116927             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  116928             :             // properly; so this will have to be checked next.
  116929             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  116930             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  116931           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  116932             :                   {
  116933           0 :                     pointer[i].set_freepointer((SgArithmeticIfStatement*)(globalIndex));
  116934           0 :                     globalIndex++;
  116935             :                   }
  116936             :                else
  116937             :                   {
  116938           0 :                     pointer[i].set_freepointer(NULL);
  116939             :                   }
  116940             :               }
  116941             :         }
  116942           5 :      return globalIndex;
  116943             :    }
  116944             : 
  116945             : //############################################################################
  116946             : // JH (01/14/2006)
  116947             : void
  116948           5 : SgArithmeticIfStatement::resetValidFreepointers( )
  116949             :    {
  116950           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  116951           5 :      SgArithmeticIfStatement* pointer = NULL;
  116952           5 :      std::vector < unsigned char* > :: const_iterator block;
  116953           5 :      SgArithmeticIfStatement* pointerOfLinkedList = NULL;
  116954           5 :      for ( block = SgArithmeticIfStatement::pools.begin(); block != SgArithmeticIfStatement::pools.end() ; ++block )
  116955             :         {
  116956           0 :           pointer = (SgArithmeticIfStatement*)(*block);
  116957           0 :           for (unsigned i = 0; i < SgArithmeticIfStatement::pool_size; ++i )
  116958             :              {
  116959             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  116960             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  116961             :             // memory blocks!.
  116962           0 :                if ( pointer[i].get_freepointer() != NULL )
  116963             :                   {
  116964           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  116965             :                   }
  116966             :                else
  116967             :                   {
  116968           0 :                     if ( pointerOfLinkedList == NULL )
  116969             :                        {
  116970           0 :                          SgArithmeticIfStatement::next_node = &(pointer[i]);
  116971             :                        }
  116972             :                     else
  116973             :                        {
  116974             :                       // printf ("In SgArithmeticIfStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  116975           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  116976             :                        }
  116977             :                     pointerOfLinkedList = &(pointer[i]);
  116978             :                   }
  116979             :               }
  116980             :         }
  116981             : 
  116982           5 :      if ( pointerOfLinkedList != NULL )
  116983             :         {
  116984             :        // printf ("In SgArithmeticIfStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  116985           0 :           pointerOfLinkedList->set_freepointer(NULL);
  116986             :        // DQ (6/6/2010): Temporary debugging...
  116987             :        //   ROSE_ASSERT(false);
  116988             :         }
  116989             : 
  116990           5 :      return ;
  116991             :    }
  116992             : 
  116993             : //############################################################################
  116994             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  116995             :  * within the memory pool and resets the freepointers, in order to achieve a 
  116996             :  * linked list, that has no jumps and starts at the beginning! This function 
  116997             :  * does not extend the memory pool, since we do not delete any memory blocks,
  116998             :  * but delete the valid objects.  
  116999             :  */
  117000             : void
  117001           0 : SgArithmeticIfStatement::clearMemoryPool( )
  117002             :    {
  117003             :   // printf ("Inside of SgArithmeticIfStatement::clearMemoryPool() \n");
  117004             : 
  117005           0 :      SgArithmeticIfStatement* pointer = NULL, *tempPointer = NULL;
  117006           0 :      std::vector < unsigned char* > :: const_iterator block;
  117007           0 :      if ( SgArithmeticIfStatement::pools.empty() == false )
  117008             :         {
  117009           0 :           block = SgArithmeticIfStatement::pools.begin() ;
  117010           0 :           SgArithmeticIfStatement::next_node = (SgArithmeticIfStatement*) (*block);
  117011             : 
  117012           0 :           while ( block != SgArithmeticIfStatement::pools.end() )
  117013             :              {
  117014           0 :                pointer = (SgArithmeticIfStatement*) (*block);
  117015           0 :                if ( tempPointer != NULL )
  117016             :                   {
  117017           0 :                     tempPointer->set_freepointer(pointer);
  117018             :                   }
  117019           0 :                for (unsigned i = 0; i < SgArithmeticIfStatement::pool_size - 1; ++i)
  117020             :                   {
  117021           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  117022             :                   }
  117023           0 :                 pointer[SgArithmeticIfStatement::pool_size-1].set_freepointer(NULL);
  117024           0 :                 tempPointer = &(pointer[SgArithmeticIfStatement::pool_size-1]);
  117025           0 :                 ++block;
  117026             :              }
  117027             :         }
  117028           0 :    }
  117029             : 
  117030           5 : void SgArithmeticIfStatement::deleteMemoryPool() {
  117031           5 :   for (auto p: SgArithmeticIfStatement::pools) {
  117032           0 :     ROSE_FREE(p);
  117033             :   }
  117034           5 :   SgArithmeticIfStatement::next_node = nullptr;
  117035           5 :   SgArithmeticIfStatement::pools.clear();
  117036           5 : }
  117037             : 
  117038             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  117039             : //                 reading multiple binary files to for a single AST.
  117040             : /////////// new version ////////////////////////////////
  117041             : //############################################################################
  117042             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  117043             : void
  117044           2 : SgArithmeticIfStatement::extendMemoryPoolForFileIO( )
  117045             :   {
  117046           2 :     size_t blockIndex = SgArithmeticIfStatement::pools.size();
  117047           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgArithmeticIfStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgArithmeticIfStatement);
  117048             : 
  117049           2 :     while ( (blockIndex * SgArithmeticIfStatement::pool_size) < newPoolSize)
  117050             :       {
  117051             : #if ROSE_ALLOC_TRACE
  117052             :         if (blockIndex > 0) {
  117053             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgArithmeticIfStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgArithmeticIfStatement) = %" PRIuPTR " SgArithmeticIfStatement::pool_size = %d \n",
  117054             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgArithmeticIfStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgArithmeticIfStatement),SgArithmeticIfStatement::pool_size);
  117055             :         }
  117056             : #endif
  117057             : 
  117058           0 :         SgArithmeticIfStatement * pointer = (SgArithmeticIfStatement*) ROSE_MALLOC ( SgArithmeticIfStatement::pool_size * sizeof(SgArithmeticIfStatement) );
  117059           0 :         assert( pointer != NULL );
  117060             : #if ROSE_ALLOC_MEMSET == 1
  117061             :         memset(pointer, 0x00, SgArithmeticIfStatement::pool_size * sizeof(SgArithmeticIfStatement));
  117062             : #elif ROSE_ALLOC_MEMSET == 2
  117063             :         memset(pointer, 0xCC, SgArithmeticIfStatement::pool_size * sizeof(SgArithmeticIfStatement));
  117064             : #endif
  117065           0 :         SgArithmeticIfStatement::pools.push_back( (unsigned char*)(pointer) );
  117066           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgArithmeticIfStatement::pool_size * sizeof(SgArithmeticIfStatement), V_SgArithmeticIfStatement ) );
  117067             : 
  117068           0 :         if ( SgArithmeticIfStatement::next_node != NULL ) {
  117069           0 :           if ( blockIndex > 0 ) {
  117070           0 :             SgArithmeticIfStatement * blkptr = (SgArithmeticIfStatement*)(SgArithmeticIfStatement::pools[blockIndex-1]);
  117071           0 :             blkptr[ SgArithmeticIfStatement::pool_size - 1 ].set_freepointer(pointer);
  117072             :           }
  117073             :         } else {
  117074           0 :           SgArithmeticIfStatement::next_node = pointer;
  117075             :         }
  117076             : 
  117077           0 :         for (unsigned i = 0; i < SgArithmeticIfStatement::pool_size-1; ++i)
  117078             :            {
  117079           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  117080             :            }
  117081           0 :         pointer[ SgArithmeticIfStatement::pool_size -1 ].set_freepointer(NULL);
  117082             : 
  117083           0 :         blockIndex++;
  117084             :       }
  117085           2 :   }
  117086             : 
  117087             : //############################################################################
  117088             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  117089             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  117090             :  * not compressed. However, that stuff is not yet implemented! 
  117091             :  */
  117092             : unsigned long
  117093           0 : SgArithmeticIfStatement::getNumberOfLastValidPointer()
  117094             :    {
  117095           0 :       SgArithmeticIfStatement* testPointer = (SgArithmeticIfStatement*)(SgArithmeticIfStatement::pools.back());
  117096           0 :       unsigned long localIndex = SgArithmeticIfStatement::pool_size - 1;
  117097           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  117098             :          {
  117099           0 :            localIndex--;
  117100             :          }
  117101           0 :       return (localIndex + SgArithmeticIfStatement::pool_size * (SgArithmeticIfStatement::pools.size()-1));
  117102             :    }
  117103             : 
  117104             : //############################################################################
  117105             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  117106             :  * memory pool and initializes the data member in class SgArithmeticIfStatementStroageClass
  117107             :  * from its counterpart of SgArithmeticIfStatement. The return value is just for checking, 
  117108             :  * that the whole StorageClassArray is initialized!
  117109             :  */
  117110             : unsigned long
  117111           0 : SgArithmeticIfStatement::initializeStorageClassArray( SgArithmeticIfStatementStorageClass *storageArray )
  117112             :    {
  117113           0 :      unsigned long storageCounter = 0;
  117114           0 :      std::vector < unsigned char* > :: const_iterator block = SgArithmeticIfStatement::pools.begin();
  117115           0 :      SgArithmeticIfStatement* pointer = NULL;
  117116           0 :      while ( block != SgArithmeticIfStatement::pools.end() ) {
  117117           0 :           pointer = (SgArithmeticIfStatement*) (*block);
  117118           0 :           for ( unsigned i = 0; i < SgArithmeticIfStatement::pool_size; ++i ) {
  117119           0 :                if ( pointer->get_freepointer() != NULL ) {
  117120           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  117121           0 :                  storageArray++;
  117122           0 :                  storageCounter++;
  117123             :                }
  117124           0 :                pointer++;
  117125             :              }
  117126           0 :            block++;
  117127             :         }
  117128           0 :      return storageCounter;
  117129             :    }
  117130             : 
  117131             : /* #line 117132 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  117132             : 
  117133             : 
  117134             : 
  117135             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  117136             : 
  117137             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  117138             : 
  117139             : //############################################################################
  117140             : /* JH (02/02/2006) Constructor of the IR node SgAssignStatement that takes its 
  117141             :  * corresponding StorageClass as parameter
  117142             :  */
  117143           0 : SgAssignStatement :: SgAssignStatement ( const SgAssignStatementStorageClass& storageSource )   : SgStatement (storageSource)
  117144             :    {
  117145             : 
  117146             : 
  117147             : /* #line 117148 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  117148             : 
  117149           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  117150           0 :      p_label =  (SgLabelRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_label) );
  117151           0 :      p_value =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_value) );
  117152             : 
  117153             : 
  117154             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  117155             : 
  117156             : 
  117157           0 :    }
  117158             : 
  117159             : //############################################################################
  117160             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  117161             :  * within the working AST. 
  117162             :  */
  117163           0 : SgAssignStatement * SgAssignStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  117164           0 :      SgAssignStatement* returnPointer = NULL;
  117165           0 :      if ( globalIndex != 0 )
  117166             :         {
  117167             : 
  117168             : #if FILE_IO_EXTRA_CHECK
  117169           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAssignStatement ) ) <= globalIndex ) ;
  117170           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssignStatement + 1 ) ) );
  117171             : #endif
  117172           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssignStatement )  
  117173           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAssignStatement );
  117174           0 :           unsigned long positionInPool = localIndex % SgAssignStatement::pool_size;
  117175           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssignStatement::pool_size;
  117176             : 
  117177             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  117178             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  117179             : 
  117180           0 :           returnPointer = &( ( (SgAssignStatement*)(SgAssignStatement::pools[memoryBlock]) ) [positionInPool]) ;
  117181             : 
  117182           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  117183             :         }
  117184           0 :      return returnPointer ;
  117185             :    }
  117186             : 
  117187             : //############################################################################
  117188             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  117189             :   for the AST with the index astIndex
  117190             : */
  117191           0 : SgAssignStatement * SgAssignStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  117192           0 :      SgAssignStatement* returnPointer = NULL;
  117193           0 :      if ( globalIndex != 0 )
  117194             :         {
  117195             : 
  117196             : #if FILE_IO_EXTRA_CHECK
  117197           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAssignStatement ) ) <= globalIndex ) ;
  117198           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssignStatement + 1 ) ) );
  117199             : #endif
  117200           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssignStatement )
  117201           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAssignStatement );
  117202           0 :           unsigned long positionInPool = localIndex % SgAssignStatement::pool_size ;
  117203           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssignStatement::pool_size ;
  117204             : 
  117205             : #if FILE_IO_EXTRA_CHECK
  117206             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  117207             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  117208             : #endif
  117209             : 
  117210           0 :           returnPointer = &( ( (SgAssignStatement*)(SgAssignStatement::pools[memoryBlock]) ) [positionInPool]) ;
  117211             : 
  117212             : #if FILE_IO_EXTRA_CHECK
  117213           0 :           assert ( returnPointer != NULL ) ;
  117214             : #endif
  117215             :         }
  117216           0 :      return returnPointer ;
  117217             :    }
  117218             : 
  117219             : //############################################################################
  117220             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  117221             :  * pool size! We set for every valid object in the memory pool the freepointer
  117222             :  * to the global index and increase the global index afterwards. For all the 
  117223             :  * invalid objects (means address ranges within the memory pool that were not
  117224             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  117225             :  * distinguish valid from invalid objects! 
  117226             :  */
  117227             : unsigned long
  117228           5 : SgAssignStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  117229             :    {
  117230           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  117231           5 :      SgAssignStatement* pointer = NULL;
  117232           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  117233           5 :      std::vector < unsigned char* > :: const_iterator block;
  117234           5 :      for ( block = SgAssignStatement::pools.begin(); block != SgAssignStatement::pools.end() ; ++block )
  117235             :         {
  117236           0 :           pointer = (SgAssignStatement*)(*block);
  117237           0 :           for (unsigned i = 0; i < SgAssignStatement::pool_size; ++i )
  117238             :              {
  117239             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  117240             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  117241             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  117242             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  117243             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  117244             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  117245             :             // properly; so this will have to be checked next.
  117246             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  117247             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  117248           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  117249             :                   {
  117250           0 :                     pointer[i].set_freepointer((SgAssignStatement*)(globalIndex));
  117251           0 :                     globalIndex++;
  117252             :                   }
  117253             :                else
  117254             :                   {
  117255           0 :                     pointer[i].set_freepointer(NULL);
  117256             :                   }
  117257             :               }
  117258             :         }
  117259           5 :      return globalIndex;
  117260             :    }
  117261             : 
  117262             : //############################################################################
  117263             : // JH (01/14/2006)
  117264             : void
  117265           5 : SgAssignStatement::resetValidFreepointers( )
  117266             :    {
  117267           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  117268           5 :      SgAssignStatement* pointer = NULL;
  117269           5 :      std::vector < unsigned char* > :: const_iterator block;
  117270           5 :      SgAssignStatement* pointerOfLinkedList = NULL;
  117271           5 :      for ( block = SgAssignStatement::pools.begin(); block != SgAssignStatement::pools.end() ; ++block )
  117272             :         {
  117273           0 :           pointer = (SgAssignStatement*)(*block);
  117274           0 :           for (unsigned i = 0; i < SgAssignStatement::pool_size; ++i )
  117275             :              {
  117276             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  117277             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  117278             :             // memory blocks!.
  117279           0 :                if ( pointer[i].get_freepointer() != NULL )
  117280             :                   {
  117281           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  117282             :                   }
  117283             :                else
  117284             :                   {
  117285           0 :                     if ( pointerOfLinkedList == NULL )
  117286             :                        {
  117287           0 :                          SgAssignStatement::next_node = &(pointer[i]);
  117288             :                        }
  117289             :                     else
  117290             :                        {
  117291             :                       // printf ("In SgAssignStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  117292           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  117293             :                        }
  117294             :                     pointerOfLinkedList = &(pointer[i]);
  117295             :                   }
  117296             :               }
  117297             :         }
  117298             : 
  117299           5 :      if ( pointerOfLinkedList != NULL )
  117300             :         {
  117301             :        // printf ("In SgAssignStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  117302           0 :           pointerOfLinkedList->set_freepointer(NULL);
  117303             :        // DQ (6/6/2010): Temporary debugging...
  117304             :        //   ROSE_ASSERT(false);
  117305             :         }
  117306             : 
  117307           5 :      return ;
  117308             :    }
  117309             : 
  117310             : //############################################################################
  117311             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  117312             :  * within the memory pool and resets the freepointers, in order to achieve a 
  117313             :  * linked list, that has no jumps and starts at the beginning! This function 
  117314             :  * does not extend the memory pool, since we do not delete any memory blocks,
  117315             :  * but delete the valid objects.  
  117316             :  */
  117317             : void
  117318           0 : SgAssignStatement::clearMemoryPool( )
  117319             :    {
  117320             :   // printf ("Inside of SgAssignStatement::clearMemoryPool() \n");
  117321             : 
  117322           0 :      SgAssignStatement* pointer = NULL, *tempPointer = NULL;
  117323           0 :      std::vector < unsigned char* > :: const_iterator block;
  117324           0 :      if ( SgAssignStatement::pools.empty() == false )
  117325             :         {
  117326           0 :           block = SgAssignStatement::pools.begin() ;
  117327           0 :           SgAssignStatement::next_node = (SgAssignStatement*) (*block);
  117328             : 
  117329           0 :           while ( block != SgAssignStatement::pools.end() )
  117330             :              {
  117331           0 :                pointer = (SgAssignStatement*) (*block);
  117332           0 :                if ( tempPointer != NULL )
  117333             :                   {
  117334           0 :                     tempPointer->set_freepointer(pointer);
  117335             :                   }
  117336           0 :                for (unsigned i = 0; i < SgAssignStatement::pool_size - 1; ++i)
  117337             :                   {
  117338           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  117339             :                   }
  117340           0 :                 pointer[SgAssignStatement::pool_size-1].set_freepointer(NULL);
  117341           0 :                 tempPointer = &(pointer[SgAssignStatement::pool_size-1]);
  117342           0 :                 ++block;
  117343             :              }
  117344             :         }
  117345           0 :    }
  117346             : 
  117347           5 : void SgAssignStatement::deleteMemoryPool() {
  117348           5 :   for (auto p: SgAssignStatement::pools) {
  117349           0 :     ROSE_FREE(p);
  117350             :   }
  117351           5 :   SgAssignStatement::next_node = nullptr;
  117352           5 :   SgAssignStatement::pools.clear();
  117353           5 : }
  117354             : 
  117355             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  117356             : //                 reading multiple binary files to for a single AST.
  117357             : /////////// new version ////////////////////////////////
  117358             : //############################################################################
  117359             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  117360             : void
  117361           2 : SgAssignStatement::extendMemoryPoolForFileIO( )
  117362             :   {
  117363           2 :     size_t blockIndex = SgAssignStatement::pools.size();
  117364           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignStatement);
  117365             : 
  117366           2 :     while ( (blockIndex * SgAssignStatement::pool_size) < newPoolSize)
  117367             :       {
  117368             : #if ROSE_ALLOC_TRACE
  117369             :         if (blockIndex > 0) {
  117370             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignStatement) = %" PRIuPTR " SgAssignStatement::pool_size = %d \n",
  117371             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignStatement),SgAssignStatement::pool_size);
  117372             :         }
  117373             : #endif
  117374             : 
  117375           0 :         SgAssignStatement * pointer = (SgAssignStatement*) ROSE_MALLOC ( SgAssignStatement::pool_size * sizeof(SgAssignStatement) );
  117376           0 :         assert( pointer != NULL );
  117377             : #if ROSE_ALLOC_MEMSET == 1
  117378             :         memset(pointer, 0x00, SgAssignStatement::pool_size * sizeof(SgAssignStatement));
  117379             : #elif ROSE_ALLOC_MEMSET == 2
  117380             :         memset(pointer, 0xCC, SgAssignStatement::pool_size * sizeof(SgAssignStatement));
  117381             : #endif
  117382           0 :         SgAssignStatement::pools.push_back( (unsigned char*)(pointer) );
  117383           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAssignStatement::pool_size * sizeof(SgAssignStatement), V_SgAssignStatement ) );
  117384             : 
  117385           0 :         if ( SgAssignStatement::next_node != NULL ) {
  117386           0 :           if ( blockIndex > 0 ) {
  117387           0 :             SgAssignStatement * blkptr = (SgAssignStatement*)(SgAssignStatement::pools[blockIndex-1]);
  117388           0 :             blkptr[ SgAssignStatement::pool_size - 1 ].set_freepointer(pointer);
  117389             :           }
  117390             :         } else {
  117391           0 :           SgAssignStatement::next_node = pointer;
  117392             :         }
  117393             : 
  117394           0 :         for (unsigned i = 0; i < SgAssignStatement::pool_size-1; ++i)
  117395             :            {
  117396           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  117397             :            }
  117398           0 :         pointer[ SgAssignStatement::pool_size -1 ].set_freepointer(NULL);
  117399             : 
  117400           0 :         blockIndex++;
  117401             :       }
  117402           2 :   }
  117403             : 
  117404             : //############################################################################
  117405             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  117406             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  117407             :  * not compressed. However, that stuff is not yet implemented! 
  117408             :  */
  117409             : unsigned long
  117410           0 : SgAssignStatement::getNumberOfLastValidPointer()
  117411             :    {
  117412           0 :       SgAssignStatement* testPointer = (SgAssignStatement*)(SgAssignStatement::pools.back());
  117413           0 :       unsigned long localIndex = SgAssignStatement::pool_size - 1;
  117414           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  117415             :          {
  117416           0 :            localIndex--;
  117417             :          }
  117418           0 :       return (localIndex + SgAssignStatement::pool_size * (SgAssignStatement::pools.size()-1));
  117419             :    }
  117420             : 
  117421             : //############################################################################
  117422             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  117423             :  * memory pool and initializes the data member in class SgAssignStatementStroageClass
  117424             :  * from its counterpart of SgAssignStatement. The return value is just for checking, 
  117425             :  * that the whole StorageClassArray is initialized!
  117426             :  */
  117427             : unsigned long
  117428           0 : SgAssignStatement::initializeStorageClassArray( SgAssignStatementStorageClass *storageArray )
  117429             :    {
  117430           0 :      unsigned long storageCounter = 0;
  117431           0 :      std::vector < unsigned char* > :: const_iterator block = SgAssignStatement::pools.begin();
  117432           0 :      SgAssignStatement* pointer = NULL;
  117433           0 :      while ( block != SgAssignStatement::pools.end() ) {
  117434           0 :           pointer = (SgAssignStatement*) (*block);
  117435           0 :           for ( unsigned i = 0; i < SgAssignStatement::pool_size; ++i ) {
  117436           0 :                if ( pointer->get_freepointer() != NULL ) {
  117437           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  117438           0 :                  storageArray++;
  117439           0 :                  storageCounter++;
  117440             :                }
  117441           0 :                pointer++;
  117442             :              }
  117443           0 :            block++;
  117444             :         }
  117445           0 :      return storageCounter;
  117446             :    }
  117447             : 
  117448             : /* #line 117449 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  117449             : 
  117450             : 
  117451             : 
  117452             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  117453             : 
  117454             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  117455             : 
  117456             : //############################################################################
  117457             : /* JH (02/02/2006) Constructor of the IR node SgComputedGotoStatement that takes its 
  117458             :  * corresponding StorageClass as parameter
  117459             :  */
  117460           0 : SgComputedGotoStatement :: SgComputedGotoStatement ( const SgComputedGotoStatementStorageClass& storageSource )   : SgStatement (storageSource)
  117461             :    {
  117462             : 
  117463             : 
  117464             : /* #line 117465 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  117465             : 
  117466           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  117467           0 :      p_labelList =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_labelList) );
  117468           0 :      p_label_index =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_label_index) );
  117469             : 
  117470             : 
  117471             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  117472             : 
  117473             : 
  117474           0 :    }
  117475             : 
  117476             : //############################################################################
  117477             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  117478             :  * within the working AST. 
  117479             :  */
  117480           0 : SgComputedGotoStatement * SgComputedGotoStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  117481           0 :      SgComputedGotoStatement* returnPointer = NULL;
  117482           0 :      if ( globalIndex != 0 )
  117483             :         {
  117484             : 
  117485             : #if FILE_IO_EXTRA_CHECK
  117486           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgComputedGotoStatement ) ) <= globalIndex ) ;
  117487           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgComputedGotoStatement + 1 ) ) );
  117488             : #endif
  117489           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgComputedGotoStatement )  
  117490           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgComputedGotoStatement );
  117491           0 :           unsigned long positionInPool = localIndex % SgComputedGotoStatement::pool_size;
  117492           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgComputedGotoStatement::pool_size;
  117493             : 
  117494             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  117495             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  117496             : 
  117497           0 :           returnPointer = &( ( (SgComputedGotoStatement*)(SgComputedGotoStatement::pools[memoryBlock]) ) [positionInPool]) ;
  117498             : 
  117499           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  117500             :         }
  117501           0 :      return returnPointer ;
  117502             :    }
  117503             : 
  117504             : //############################################################################
  117505             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  117506             :   for the AST with the index astIndex
  117507             : */
  117508           0 : SgComputedGotoStatement * SgComputedGotoStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  117509           0 :      SgComputedGotoStatement* returnPointer = NULL;
  117510           0 :      if ( globalIndex != 0 )
  117511             :         {
  117512             : 
  117513             : #if FILE_IO_EXTRA_CHECK
  117514           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgComputedGotoStatement ) ) <= globalIndex ) ;
  117515           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgComputedGotoStatement + 1 ) ) );
  117516             : #endif
  117517           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgComputedGotoStatement )
  117518           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgComputedGotoStatement );
  117519           0 :           unsigned long positionInPool = localIndex % SgComputedGotoStatement::pool_size ;
  117520           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgComputedGotoStatement::pool_size ;
  117521             : 
  117522             : #if FILE_IO_EXTRA_CHECK
  117523             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  117524             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  117525             : #endif
  117526             : 
  117527           0 :           returnPointer = &( ( (SgComputedGotoStatement*)(SgComputedGotoStatement::pools[memoryBlock]) ) [positionInPool]) ;
  117528             : 
  117529             : #if FILE_IO_EXTRA_CHECK
  117530           0 :           assert ( returnPointer != NULL ) ;
  117531             : #endif
  117532             :         }
  117533           0 :      return returnPointer ;
  117534             :    }
  117535             : 
  117536             : //############################################################################
  117537             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  117538             :  * pool size! We set for every valid object in the memory pool the freepointer
  117539             :  * to the global index and increase the global index afterwards. For all the 
  117540             :  * invalid objects (means address ranges within the memory pool that were not
  117541             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  117542             :  * distinguish valid from invalid objects! 
  117543             :  */
  117544             : unsigned long
  117545           5 : SgComputedGotoStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  117546             :    {
  117547           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  117548           5 :      SgComputedGotoStatement* pointer = NULL;
  117549           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  117550           5 :      std::vector < unsigned char* > :: const_iterator block;
  117551           5 :      for ( block = SgComputedGotoStatement::pools.begin(); block != SgComputedGotoStatement::pools.end() ; ++block )
  117552             :         {
  117553           0 :           pointer = (SgComputedGotoStatement*)(*block);
  117554           0 :           for (unsigned i = 0; i < SgComputedGotoStatement::pool_size; ++i )
  117555             :              {
  117556             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  117557             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  117558             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  117559             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  117560             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  117561             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  117562             :             // properly; so this will have to be checked next.
  117563             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  117564             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  117565           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  117566             :                   {
  117567           0 :                     pointer[i].set_freepointer((SgComputedGotoStatement*)(globalIndex));
  117568           0 :                     globalIndex++;
  117569             :                   }
  117570             :                else
  117571             :                   {
  117572           0 :                     pointer[i].set_freepointer(NULL);
  117573             :                   }
  117574             :               }
  117575             :         }
  117576           5 :      return globalIndex;
  117577             :    }
  117578             : 
  117579             : //############################################################################
  117580             : // JH (01/14/2006)
  117581             : void
  117582           5 : SgComputedGotoStatement::resetValidFreepointers( )
  117583             :    {
  117584           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  117585           5 :      SgComputedGotoStatement* pointer = NULL;
  117586           5 :      std::vector < unsigned char* > :: const_iterator block;
  117587           5 :      SgComputedGotoStatement* pointerOfLinkedList = NULL;
  117588           5 :      for ( block = SgComputedGotoStatement::pools.begin(); block != SgComputedGotoStatement::pools.end() ; ++block )
  117589             :         {
  117590           0 :           pointer = (SgComputedGotoStatement*)(*block);
  117591           0 :           for (unsigned i = 0; i < SgComputedGotoStatement::pool_size; ++i )
  117592             :              {
  117593             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  117594             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  117595             :             // memory blocks!.
  117596           0 :                if ( pointer[i].get_freepointer() != NULL )
  117597             :                   {
  117598           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  117599             :                   }
  117600             :                else
  117601             :                   {
  117602           0 :                     if ( pointerOfLinkedList == NULL )
  117603             :                        {
  117604           0 :                          SgComputedGotoStatement::next_node = &(pointer[i]);
  117605             :                        }
  117606             :                     else
  117607             :                        {
  117608             :                       // printf ("In SgComputedGotoStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  117609           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  117610             :                        }
  117611             :                     pointerOfLinkedList = &(pointer[i]);
  117612             :                   }
  117613             :               }
  117614             :         }
  117615             : 
  117616           5 :      if ( pointerOfLinkedList != NULL )
  117617             :         {
  117618             :        // printf ("In SgComputedGotoStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  117619           0 :           pointerOfLinkedList->set_freepointer(NULL);
  117620             :        // DQ (6/6/2010): Temporary debugging...
  117621             :        //   ROSE_ASSERT(false);
  117622             :         }
  117623             : 
  117624           5 :      return ;
  117625             :    }
  117626             : 
  117627             : //############################################################################
  117628             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  117629             :  * within the memory pool and resets the freepointers, in order to achieve a 
  117630             :  * linked list, that has no jumps and starts at the beginning! This function 
  117631             :  * does not extend the memory pool, since we do not delete any memory blocks,
  117632             :  * but delete the valid objects.  
  117633             :  */
  117634             : void
  117635           0 : SgComputedGotoStatement::clearMemoryPool( )
  117636             :    {
  117637             :   // printf ("Inside of SgComputedGotoStatement::clearMemoryPool() \n");
  117638             : 
  117639           0 :      SgComputedGotoStatement* pointer = NULL, *tempPointer = NULL;
  117640           0 :      std::vector < unsigned char* > :: const_iterator block;
  117641           0 :      if ( SgComputedGotoStatement::pools.empty() == false )
  117642             :         {
  117643           0 :           block = SgComputedGotoStatement::pools.begin() ;
  117644           0 :           SgComputedGotoStatement::next_node = (SgComputedGotoStatement*) (*block);
  117645             : 
  117646           0 :           while ( block != SgComputedGotoStatement::pools.end() )
  117647             :              {
  117648           0 :                pointer = (SgComputedGotoStatement*) (*block);
  117649           0 :                if ( tempPointer != NULL )
  117650             :                   {
  117651           0 :                     tempPointer->set_freepointer(pointer);
  117652             :                   }
  117653           0 :                for (unsigned i = 0; i < SgComputedGotoStatement::pool_size - 1; ++i)
  117654             :                   {
  117655           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  117656             :                   }
  117657           0 :                 pointer[SgComputedGotoStatement::pool_size-1].set_freepointer(NULL);
  117658           0 :                 tempPointer = &(pointer[SgComputedGotoStatement::pool_size-1]);
  117659           0 :                 ++block;
  117660             :              }
  117661             :         }
  117662           0 :    }
  117663             : 
  117664           5 : void SgComputedGotoStatement::deleteMemoryPool() {
  117665           5 :   for (auto p: SgComputedGotoStatement::pools) {
  117666           0 :     ROSE_FREE(p);
  117667             :   }
  117668           5 :   SgComputedGotoStatement::next_node = nullptr;
  117669           5 :   SgComputedGotoStatement::pools.clear();
  117670           5 : }
  117671             : 
  117672             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  117673             : //                 reading multiple binary files to for a single AST.
  117674             : /////////// new version ////////////////////////////////
  117675             : //############################################################################
  117676             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  117677             : void
  117678           2 : SgComputedGotoStatement::extendMemoryPoolForFileIO( )
  117679             :   {
  117680           2 :     size_t blockIndex = SgComputedGotoStatement::pools.size();
  117681           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgComputedGotoStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgComputedGotoStatement);
  117682             : 
  117683           2 :     while ( (blockIndex * SgComputedGotoStatement::pool_size) < newPoolSize)
  117684             :       {
  117685             : #if ROSE_ALLOC_TRACE
  117686             :         if (blockIndex > 0) {
  117687             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgComputedGotoStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgComputedGotoStatement) = %" PRIuPTR " SgComputedGotoStatement::pool_size = %d \n",
  117688             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgComputedGotoStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgComputedGotoStatement),SgComputedGotoStatement::pool_size);
  117689             :         }
  117690             : #endif
  117691             : 
  117692           0 :         SgComputedGotoStatement * pointer = (SgComputedGotoStatement*) ROSE_MALLOC ( SgComputedGotoStatement::pool_size * sizeof(SgComputedGotoStatement) );
  117693           0 :         assert( pointer != NULL );
  117694             : #if ROSE_ALLOC_MEMSET == 1
  117695             :         memset(pointer, 0x00, SgComputedGotoStatement::pool_size * sizeof(SgComputedGotoStatement));
  117696             : #elif ROSE_ALLOC_MEMSET == 2
  117697             :         memset(pointer, 0xCC, SgComputedGotoStatement::pool_size * sizeof(SgComputedGotoStatement));
  117698             : #endif
  117699           0 :         SgComputedGotoStatement::pools.push_back( (unsigned char*)(pointer) );
  117700           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgComputedGotoStatement::pool_size * sizeof(SgComputedGotoStatement), V_SgComputedGotoStatement ) );
  117701             : 
  117702           0 :         if ( SgComputedGotoStatement::next_node != NULL ) {
  117703           0 :           if ( blockIndex > 0 ) {
  117704           0 :             SgComputedGotoStatement * blkptr = (SgComputedGotoStatement*)(SgComputedGotoStatement::pools[blockIndex-1]);
  117705           0 :             blkptr[ SgComputedGotoStatement::pool_size - 1 ].set_freepointer(pointer);
  117706             :           }
  117707             :         } else {
  117708           0 :           SgComputedGotoStatement::next_node = pointer;
  117709             :         }
  117710             : 
  117711           0 :         for (unsigned i = 0; i < SgComputedGotoStatement::pool_size-1; ++i)
  117712             :            {
  117713           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  117714             :            }
  117715           0 :         pointer[ SgComputedGotoStatement::pool_size -1 ].set_freepointer(NULL);
  117716             : 
  117717           0 :         blockIndex++;
  117718             :       }
  117719           2 :   }
  117720             : 
  117721             : //############################################################################
  117722             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  117723             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  117724             :  * not compressed. However, that stuff is not yet implemented! 
  117725             :  */
  117726             : unsigned long
  117727           0 : SgComputedGotoStatement::getNumberOfLastValidPointer()
  117728             :    {
  117729           0 :       SgComputedGotoStatement* testPointer = (SgComputedGotoStatement*)(SgComputedGotoStatement::pools.back());
  117730           0 :       unsigned long localIndex = SgComputedGotoStatement::pool_size - 1;
  117731           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  117732             :          {
  117733           0 :            localIndex--;
  117734             :          }
  117735           0 :       return (localIndex + SgComputedGotoStatement::pool_size * (SgComputedGotoStatement::pools.size()-1));
  117736             :    }
  117737             : 
  117738             : //############################################################################
  117739             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  117740             :  * memory pool and initializes the data member in class SgComputedGotoStatementStroageClass
  117741             :  * from its counterpart of SgComputedGotoStatement. The return value is just for checking, 
  117742             :  * that the whole StorageClassArray is initialized!
  117743             :  */
  117744             : unsigned long
  117745           0 : SgComputedGotoStatement::initializeStorageClassArray( SgComputedGotoStatementStorageClass *storageArray )
  117746             :    {
  117747           0 :      unsigned long storageCounter = 0;
  117748           0 :      std::vector < unsigned char* > :: const_iterator block = SgComputedGotoStatement::pools.begin();
  117749           0 :      SgComputedGotoStatement* pointer = NULL;
  117750           0 :      while ( block != SgComputedGotoStatement::pools.end() ) {
  117751           0 :           pointer = (SgComputedGotoStatement*) (*block);
  117752           0 :           for ( unsigned i = 0; i < SgComputedGotoStatement::pool_size; ++i ) {
  117753           0 :                if ( pointer->get_freepointer() != NULL ) {
  117754           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  117755           0 :                  storageArray++;
  117756           0 :                  storageCounter++;
  117757             :                }
  117758           0 :                pointer++;
  117759             :              }
  117760           0 :            block++;
  117761             :         }
  117762           0 :      return storageCounter;
  117763             :    }
  117764             : 
  117765             : /* #line 117766 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  117766             : 
  117767             : 
  117768             : 
  117769             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  117770             : 
  117771             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  117772             : 
  117773             : //############################################################################
  117774             : /* JH (02/02/2006) Constructor of the IR node SgAssignedGotoStatement that takes its 
  117775             :  * corresponding StorageClass as parameter
  117776             :  */
  117777           0 : SgAssignedGotoStatement :: SgAssignedGotoStatement ( const SgAssignedGotoStatementStorageClass& storageSource )   : SgStatement (storageSource)
  117778             :    {
  117779             : 
  117780             : 
  117781             : /* #line 117782 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  117782             : 
  117783           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  117784           0 :      p_targets =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_targets) );
  117785             : 
  117786             : 
  117787             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  117788             : 
  117789             : 
  117790           0 :    }
  117791             : 
  117792             : //############################################################################
  117793             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  117794             :  * within the working AST. 
  117795             :  */
  117796           0 : SgAssignedGotoStatement * SgAssignedGotoStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  117797           0 :      SgAssignedGotoStatement* returnPointer = NULL;
  117798           0 :      if ( globalIndex != 0 )
  117799             :         {
  117800             : 
  117801             : #if FILE_IO_EXTRA_CHECK
  117802           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAssignedGotoStatement ) ) <= globalIndex ) ;
  117803           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssignedGotoStatement + 1 ) ) );
  117804             : #endif
  117805           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssignedGotoStatement )  
  117806           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAssignedGotoStatement );
  117807           0 :           unsigned long positionInPool = localIndex % SgAssignedGotoStatement::pool_size;
  117808           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssignedGotoStatement::pool_size;
  117809             : 
  117810             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  117811             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  117812             : 
  117813           0 :           returnPointer = &( ( (SgAssignedGotoStatement*)(SgAssignedGotoStatement::pools[memoryBlock]) ) [positionInPool]) ;
  117814             : 
  117815           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  117816             :         }
  117817           0 :      return returnPointer ;
  117818             :    }
  117819             : 
  117820             : //############################################################################
  117821             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  117822             :   for the AST with the index astIndex
  117823             : */
  117824           0 : SgAssignedGotoStatement * SgAssignedGotoStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  117825           0 :      SgAssignedGotoStatement* returnPointer = NULL;
  117826           0 :      if ( globalIndex != 0 )
  117827             :         {
  117828             : 
  117829             : #if FILE_IO_EXTRA_CHECK
  117830           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAssignedGotoStatement ) ) <= globalIndex ) ;
  117831           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssignedGotoStatement + 1 ) ) );
  117832             : #endif
  117833           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssignedGotoStatement )
  117834           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAssignedGotoStatement );
  117835           0 :           unsigned long positionInPool = localIndex % SgAssignedGotoStatement::pool_size ;
  117836           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssignedGotoStatement::pool_size ;
  117837             : 
  117838             : #if FILE_IO_EXTRA_CHECK
  117839             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  117840             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  117841             : #endif
  117842             : 
  117843           0 :           returnPointer = &( ( (SgAssignedGotoStatement*)(SgAssignedGotoStatement::pools[memoryBlock]) ) [positionInPool]) ;
  117844             : 
  117845             : #if FILE_IO_EXTRA_CHECK
  117846           0 :           assert ( returnPointer != NULL ) ;
  117847             : #endif
  117848             :         }
  117849           0 :      return returnPointer ;
  117850             :    }
  117851             : 
  117852             : //############################################################################
  117853             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  117854             :  * pool size! We set for every valid object in the memory pool the freepointer
  117855             :  * to the global index and increase the global index afterwards. For all the 
  117856             :  * invalid objects (means address ranges within the memory pool that were not
  117857             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  117858             :  * distinguish valid from invalid objects! 
  117859             :  */
  117860             : unsigned long
  117861           5 : SgAssignedGotoStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  117862             :    {
  117863           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  117864           5 :      SgAssignedGotoStatement* pointer = NULL;
  117865           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  117866           5 :      std::vector < unsigned char* > :: const_iterator block;
  117867           5 :      for ( block = SgAssignedGotoStatement::pools.begin(); block != SgAssignedGotoStatement::pools.end() ; ++block )
  117868             :         {
  117869           0 :           pointer = (SgAssignedGotoStatement*)(*block);
  117870           0 :           for (unsigned i = 0; i < SgAssignedGotoStatement::pool_size; ++i )
  117871             :              {
  117872             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  117873             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  117874             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  117875             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  117876             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  117877             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  117878             :             // properly; so this will have to be checked next.
  117879             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  117880             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  117881           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  117882             :                   {
  117883           0 :                     pointer[i].set_freepointer((SgAssignedGotoStatement*)(globalIndex));
  117884           0 :                     globalIndex++;
  117885             :                   }
  117886             :                else
  117887             :                   {
  117888           0 :                     pointer[i].set_freepointer(NULL);
  117889             :                   }
  117890             :               }
  117891             :         }
  117892           5 :      return globalIndex;
  117893             :    }
  117894             : 
  117895             : //############################################################################
  117896             : // JH (01/14/2006)
  117897             : void
  117898           5 : SgAssignedGotoStatement::resetValidFreepointers( )
  117899             :    {
  117900           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  117901           5 :      SgAssignedGotoStatement* pointer = NULL;
  117902           5 :      std::vector < unsigned char* > :: const_iterator block;
  117903           5 :      SgAssignedGotoStatement* pointerOfLinkedList = NULL;
  117904           5 :      for ( block = SgAssignedGotoStatement::pools.begin(); block != SgAssignedGotoStatement::pools.end() ; ++block )
  117905             :         {
  117906           0 :           pointer = (SgAssignedGotoStatement*)(*block);
  117907           0 :           for (unsigned i = 0; i < SgAssignedGotoStatement::pool_size; ++i )
  117908             :              {
  117909             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  117910             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  117911             :             // memory blocks!.
  117912           0 :                if ( pointer[i].get_freepointer() != NULL )
  117913             :                   {
  117914           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  117915             :                   }
  117916             :                else
  117917             :                   {
  117918           0 :                     if ( pointerOfLinkedList == NULL )
  117919             :                        {
  117920           0 :                          SgAssignedGotoStatement::next_node = &(pointer[i]);
  117921             :                        }
  117922             :                     else
  117923             :                        {
  117924             :                       // printf ("In SgAssignedGotoStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  117925           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  117926             :                        }
  117927             :                     pointerOfLinkedList = &(pointer[i]);
  117928             :                   }
  117929             :               }
  117930             :         }
  117931             : 
  117932           5 :      if ( pointerOfLinkedList != NULL )
  117933             :         {
  117934             :        // printf ("In SgAssignedGotoStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  117935           0 :           pointerOfLinkedList->set_freepointer(NULL);
  117936             :        // DQ (6/6/2010): Temporary debugging...
  117937             :        //   ROSE_ASSERT(false);
  117938             :         }
  117939             : 
  117940           5 :      return ;
  117941             :    }
  117942             : 
  117943             : //############################################################################
  117944             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  117945             :  * within the memory pool and resets the freepointers, in order to achieve a 
  117946             :  * linked list, that has no jumps and starts at the beginning! This function 
  117947             :  * does not extend the memory pool, since we do not delete any memory blocks,
  117948             :  * but delete the valid objects.  
  117949             :  */
  117950             : void
  117951           0 : SgAssignedGotoStatement::clearMemoryPool( )
  117952             :    {
  117953             :   // printf ("Inside of SgAssignedGotoStatement::clearMemoryPool() \n");
  117954             : 
  117955           0 :      SgAssignedGotoStatement* pointer = NULL, *tempPointer = NULL;
  117956           0 :      std::vector < unsigned char* > :: const_iterator block;
  117957           0 :      if ( SgAssignedGotoStatement::pools.empty() == false )
  117958             :         {
  117959           0 :           block = SgAssignedGotoStatement::pools.begin() ;
  117960           0 :           SgAssignedGotoStatement::next_node = (SgAssignedGotoStatement*) (*block);
  117961             : 
  117962           0 :           while ( block != SgAssignedGotoStatement::pools.end() )
  117963             :              {
  117964           0 :                pointer = (SgAssignedGotoStatement*) (*block);
  117965           0 :                if ( tempPointer != NULL )
  117966             :                   {
  117967           0 :                     tempPointer->set_freepointer(pointer);
  117968             :                   }
  117969           0 :                for (unsigned i = 0; i < SgAssignedGotoStatement::pool_size - 1; ++i)
  117970             :                   {
  117971           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  117972             :                   }
  117973           0 :                 pointer[SgAssignedGotoStatement::pool_size-1].set_freepointer(NULL);
  117974           0 :                 tempPointer = &(pointer[SgAssignedGotoStatement::pool_size-1]);
  117975           0 :                 ++block;
  117976             :              }
  117977             :         }
  117978           0 :    }
  117979             : 
  117980           5 : void SgAssignedGotoStatement::deleteMemoryPool() {
  117981           5 :   for (auto p: SgAssignedGotoStatement::pools) {
  117982           0 :     ROSE_FREE(p);
  117983             :   }
  117984           5 :   SgAssignedGotoStatement::next_node = nullptr;
  117985           5 :   SgAssignedGotoStatement::pools.clear();
  117986           5 : }
  117987             : 
  117988             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  117989             : //                 reading multiple binary files to for a single AST.
  117990             : /////////// new version ////////////////////////////////
  117991             : //############################################################################
  117992             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  117993             : void
  117994           2 : SgAssignedGotoStatement::extendMemoryPoolForFileIO( )
  117995             :   {
  117996           2 :     size_t blockIndex = SgAssignedGotoStatement::pools.size();
  117997           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignedGotoStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignedGotoStatement);
  117998             : 
  117999           2 :     while ( (blockIndex * SgAssignedGotoStatement::pool_size) < newPoolSize)
  118000             :       {
  118001             : #if ROSE_ALLOC_TRACE
  118002             :         if (blockIndex > 0) {
  118003             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignedGotoStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignedGotoStatement) = %" PRIuPTR " SgAssignedGotoStatement::pool_size = %d \n",
  118004             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignedGotoStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignedGotoStatement),SgAssignedGotoStatement::pool_size);
  118005             :         }
  118006             : #endif
  118007             : 
  118008           0 :         SgAssignedGotoStatement * pointer = (SgAssignedGotoStatement*) ROSE_MALLOC ( SgAssignedGotoStatement::pool_size * sizeof(SgAssignedGotoStatement) );
  118009           0 :         assert( pointer != NULL );
  118010             : #if ROSE_ALLOC_MEMSET == 1
  118011             :         memset(pointer, 0x00, SgAssignedGotoStatement::pool_size * sizeof(SgAssignedGotoStatement));
  118012             : #elif ROSE_ALLOC_MEMSET == 2
  118013             :         memset(pointer, 0xCC, SgAssignedGotoStatement::pool_size * sizeof(SgAssignedGotoStatement));
  118014             : #endif
  118015           0 :         SgAssignedGotoStatement::pools.push_back( (unsigned char*)(pointer) );
  118016           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAssignedGotoStatement::pool_size * sizeof(SgAssignedGotoStatement), V_SgAssignedGotoStatement ) );
  118017             : 
  118018           0 :         if ( SgAssignedGotoStatement::next_node != NULL ) {
  118019           0 :           if ( blockIndex > 0 ) {
  118020           0 :             SgAssignedGotoStatement * blkptr = (SgAssignedGotoStatement*)(SgAssignedGotoStatement::pools[blockIndex-1]);
  118021           0 :             blkptr[ SgAssignedGotoStatement::pool_size - 1 ].set_freepointer(pointer);
  118022             :           }
  118023             :         } else {
  118024           0 :           SgAssignedGotoStatement::next_node = pointer;
  118025             :         }
  118026             : 
  118027           0 :         for (unsigned i = 0; i < SgAssignedGotoStatement::pool_size-1; ++i)
  118028             :            {
  118029           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  118030             :            }
  118031           0 :         pointer[ SgAssignedGotoStatement::pool_size -1 ].set_freepointer(NULL);
  118032             : 
  118033           0 :         blockIndex++;
  118034             :       }
  118035           2 :   }
  118036             : 
  118037             : //############################################################################
  118038             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  118039             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  118040             :  * not compressed. However, that stuff is not yet implemented! 
  118041             :  */
  118042             : unsigned long
  118043           0 : SgAssignedGotoStatement::getNumberOfLastValidPointer()
  118044             :    {
  118045           0 :       SgAssignedGotoStatement* testPointer = (SgAssignedGotoStatement*)(SgAssignedGotoStatement::pools.back());
  118046           0 :       unsigned long localIndex = SgAssignedGotoStatement::pool_size - 1;
  118047           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  118048             :          {
  118049           0 :            localIndex--;
  118050             :          }
  118051           0 :       return (localIndex + SgAssignedGotoStatement::pool_size * (SgAssignedGotoStatement::pools.size()-1));
  118052             :    }
  118053             : 
  118054             : //############################################################################
  118055             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  118056             :  * memory pool and initializes the data member in class SgAssignedGotoStatementStroageClass
  118057             :  * from its counterpart of SgAssignedGotoStatement. The return value is just for checking, 
  118058             :  * that the whole StorageClassArray is initialized!
  118059             :  */
  118060             : unsigned long
  118061           0 : SgAssignedGotoStatement::initializeStorageClassArray( SgAssignedGotoStatementStorageClass *storageArray )
  118062             :    {
  118063           0 :      unsigned long storageCounter = 0;
  118064           0 :      std::vector < unsigned char* > :: const_iterator block = SgAssignedGotoStatement::pools.begin();
  118065           0 :      SgAssignedGotoStatement* pointer = NULL;
  118066           0 :      while ( block != SgAssignedGotoStatement::pools.end() ) {
  118067           0 :           pointer = (SgAssignedGotoStatement*) (*block);
  118068           0 :           for ( unsigned i = 0; i < SgAssignedGotoStatement::pool_size; ++i ) {
  118069           0 :                if ( pointer->get_freepointer() != NULL ) {
  118070           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  118071           0 :                  storageArray++;
  118072           0 :                  storageCounter++;
  118073             :                }
  118074           0 :                pointer++;
  118075             :              }
  118076           0 :            block++;
  118077             :         }
  118078           0 :      return storageCounter;
  118079             :    }
  118080             : 
  118081             : /* #line 118082 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  118082             : 
  118083             : 
  118084             : 
  118085             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  118086             : 
  118087             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  118088             : 
  118089             : //############################################################################
  118090             : /* JH (02/02/2006) Constructor of the IR node SgAllocateStatement that takes its 
  118091             :  * corresponding StorageClass as parameter
  118092             :  */
  118093           0 : SgAllocateStatement :: SgAllocateStatement ( const SgAllocateStatementStorageClass& storageSource )   : SgStatement (storageSource)
  118094             :    {
  118095             : 
  118096             : 
  118097             : /* #line 118098 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  118098             : 
  118099           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  118100           0 :      p_expr_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expr_list) );
  118101           0 :      p_stat_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_stat_expression) );
  118102           0 :      p_errmsg_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_errmsg_expression) );
  118103           0 :      p_source_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_source_expression) );
  118104             : 
  118105             : 
  118106             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  118107             : 
  118108             : 
  118109           0 :    }
  118110             : 
  118111             : //############################################################################
  118112             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  118113             :  * within the working AST. 
  118114             :  */
  118115           0 : SgAllocateStatement * SgAllocateStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  118116           0 :      SgAllocateStatement* returnPointer = NULL;
  118117           0 :      if ( globalIndex != 0 )
  118118             :         {
  118119             : 
  118120             : #if FILE_IO_EXTRA_CHECK
  118121           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAllocateStatement ) ) <= globalIndex ) ;
  118122           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAllocateStatement + 1 ) ) );
  118123             : #endif
  118124           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAllocateStatement )  
  118125           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAllocateStatement );
  118126           0 :           unsigned long positionInPool = localIndex % SgAllocateStatement::pool_size;
  118127           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAllocateStatement::pool_size;
  118128             : 
  118129             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  118130             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  118131             : 
  118132           0 :           returnPointer = &( ( (SgAllocateStatement*)(SgAllocateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  118133             : 
  118134           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  118135             :         }
  118136           0 :      return returnPointer ;
  118137             :    }
  118138             : 
  118139             : //############################################################################
  118140             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  118141             :   for the AST with the index astIndex
  118142             : */
  118143           0 : SgAllocateStatement * SgAllocateStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  118144           0 :      SgAllocateStatement* returnPointer = NULL;
  118145           0 :      if ( globalIndex != 0 )
  118146             :         {
  118147             : 
  118148             : #if FILE_IO_EXTRA_CHECK
  118149           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAllocateStatement ) ) <= globalIndex ) ;
  118150           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAllocateStatement + 1 ) ) );
  118151             : #endif
  118152           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAllocateStatement )
  118153           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAllocateStatement );
  118154           0 :           unsigned long positionInPool = localIndex % SgAllocateStatement::pool_size ;
  118155           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAllocateStatement::pool_size ;
  118156             : 
  118157             : #if FILE_IO_EXTRA_CHECK
  118158             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  118159             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  118160             : #endif
  118161             : 
  118162           0 :           returnPointer = &( ( (SgAllocateStatement*)(SgAllocateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  118163             : 
  118164             : #if FILE_IO_EXTRA_CHECK
  118165           0 :           assert ( returnPointer != NULL ) ;
  118166             : #endif
  118167             :         }
  118168           0 :      return returnPointer ;
  118169             :    }
  118170             : 
  118171             : //############################################################################
  118172             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  118173             :  * pool size! We set for every valid object in the memory pool the freepointer
  118174             :  * to the global index and increase the global index afterwards. For all the 
  118175             :  * invalid objects (means address ranges within the memory pool that were not
  118176             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  118177             :  * distinguish valid from invalid objects! 
  118178             :  */
  118179             : unsigned long
  118180           5 : SgAllocateStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  118181             :    {
  118182           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  118183           5 :      SgAllocateStatement* pointer = NULL;
  118184           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  118185           5 :      std::vector < unsigned char* > :: const_iterator block;
  118186           5 :      for ( block = SgAllocateStatement::pools.begin(); block != SgAllocateStatement::pools.end() ; ++block )
  118187             :         {
  118188           0 :           pointer = (SgAllocateStatement*)(*block);
  118189           0 :           for (unsigned i = 0; i < SgAllocateStatement::pool_size; ++i )
  118190             :              {
  118191             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  118192             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  118193             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  118194             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  118195             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  118196             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  118197             :             // properly; so this will have to be checked next.
  118198             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  118199             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  118200           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  118201             :                   {
  118202           0 :                     pointer[i].set_freepointer((SgAllocateStatement*)(globalIndex));
  118203           0 :                     globalIndex++;
  118204             :                   }
  118205             :                else
  118206             :                   {
  118207           0 :                     pointer[i].set_freepointer(NULL);
  118208             :                   }
  118209             :               }
  118210             :         }
  118211           5 :      return globalIndex;
  118212             :    }
  118213             : 
  118214             : //############################################################################
  118215             : // JH (01/14/2006)
  118216             : void
  118217           5 : SgAllocateStatement::resetValidFreepointers( )
  118218             :    {
  118219           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  118220           5 :      SgAllocateStatement* pointer = NULL;
  118221           5 :      std::vector < unsigned char* > :: const_iterator block;
  118222           5 :      SgAllocateStatement* pointerOfLinkedList = NULL;
  118223           5 :      for ( block = SgAllocateStatement::pools.begin(); block != SgAllocateStatement::pools.end() ; ++block )
  118224             :         {
  118225           0 :           pointer = (SgAllocateStatement*)(*block);
  118226           0 :           for (unsigned i = 0; i < SgAllocateStatement::pool_size; ++i )
  118227             :              {
  118228             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  118229             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  118230             :             // memory blocks!.
  118231           0 :                if ( pointer[i].get_freepointer() != NULL )
  118232             :                   {
  118233           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  118234             :                   }
  118235             :                else
  118236             :                   {
  118237           0 :                     if ( pointerOfLinkedList == NULL )
  118238             :                        {
  118239           0 :                          SgAllocateStatement::next_node = &(pointer[i]);
  118240             :                        }
  118241             :                     else
  118242             :                        {
  118243             :                       // printf ("In SgAllocateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  118244           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  118245             :                        }
  118246             :                     pointerOfLinkedList = &(pointer[i]);
  118247             :                   }
  118248             :               }
  118249             :         }
  118250             : 
  118251           5 :      if ( pointerOfLinkedList != NULL )
  118252             :         {
  118253             :        // printf ("In SgAllocateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  118254           0 :           pointerOfLinkedList->set_freepointer(NULL);
  118255             :        // DQ (6/6/2010): Temporary debugging...
  118256             :        //   ROSE_ASSERT(false);
  118257             :         }
  118258             : 
  118259           5 :      return ;
  118260             :    }
  118261             : 
  118262             : //############################################################################
  118263             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  118264             :  * within the memory pool and resets the freepointers, in order to achieve a 
  118265             :  * linked list, that has no jumps and starts at the beginning! This function 
  118266             :  * does not extend the memory pool, since we do not delete any memory blocks,
  118267             :  * but delete the valid objects.  
  118268             :  */
  118269             : void
  118270           0 : SgAllocateStatement::clearMemoryPool( )
  118271             :    {
  118272             :   // printf ("Inside of SgAllocateStatement::clearMemoryPool() \n");
  118273             : 
  118274           0 :      SgAllocateStatement* pointer = NULL, *tempPointer = NULL;
  118275           0 :      std::vector < unsigned char* > :: const_iterator block;
  118276           0 :      if ( SgAllocateStatement::pools.empty() == false )
  118277             :         {
  118278           0 :           block = SgAllocateStatement::pools.begin() ;
  118279           0 :           SgAllocateStatement::next_node = (SgAllocateStatement*) (*block);
  118280             : 
  118281           0 :           while ( block != SgAllocateStatement::pools.end() )
  118282             :              {
  118283           0 :                pointer = (SgAllocateStatement*) (*block);
  118284           0 :                if ( tempPointer != NULL )
  118285             :                   {
  118286           0 :                     tempPointer->set_freepointer(pointer);
  118287             :                   }
  118288           0 :                for (unsigned i = 0; i < SgAllocateStatement::pool_size - 1; ++i)
  118289             :                   {
  118290           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  118291             :                   }
  118292           0 :                 pointer[SgAllocateStatement::pool_size-1].set_freepointer(NULL);
  118293           0 :                 tempPointer = &(pointer[SgAllocateStatement::pool_size-1]);
  118294           0 :                 ++block;
  118295             :              }
  118296             :         }
  118297           0 :    }
  118298             : 
  118299           5 : void SgAllocateStatement::deleteMemoryPool() {
  118300           5 :   for (auto p: SgAllocateStatement::pools) {
  118301           0 :     ROSE_FREE(p);
  118302             :   }
  118303           5 :   SgAllocateStatement::next_node = nullptr;
  118304           5 :   SgAllocateStatement::pools.clear();
  118305           5 : }
  118306             : 
  118307             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  118308             : //                 reading multiple binary files to for a single AST.
  118309             : /////////// new version ////////////////////////////////
  118310             : //############################################################################
  118311             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  118312             : void
  118313           2 : SgAllocateStatement::extendMemoryPoolForFileIO( )
  118314             :   {
  118315           2 :     size_t blockIndex = SgAllocateStatement::pools.size();
  118316           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAllocateStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAllocateStatement);
  118317             : 
  118318           2 :     while ( (blockIndex * SgAllocateStatement::pool_size) < newPoolSize)
  118319             :       {
  118320             : #if ROSE_ALLOC_TRACE
  118321             :         if (blockIndex > 0) {
  118322             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAllocateStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAllocateStatement) = %" PRIuPTR " SgAllocateStatement::pool_size = %d \n",
  118323             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAllocateStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAllocateStatement),SgAllocateStatement::pool_size);
  118324             :         }
  118325             : #endif
  118326             : 
  118327           0 :         SgAllocateStatement * pointer = (SgAllocateStatement*) ROSE_MALLOC ( SgAllocateStatement::pool_size * sizeof(SgAllocateStatement) );
  118328           0 :         assert( pointer != NULL );
  118329             : #if ROSE_ALLOC_MEMSET == 1
  118330             :         memset(pointer, 0x00, SgAllocateStatement::pool_size * sizeof(SgAllocateStatement));
  118331             : #elif ROSE_ALLOC_MEMSET == 2
  118332             :         memset(pointer, 0xCC, SgAllocateStatement::pool_size * sizeof(SgAllocateStatement));
  118333             : #endif
  118334           0 :         SgAllocateStatement::pools.push_back( (unsigned char*)(pointer) );
  118335           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAllocateStatement::pool_size * sizeof(SgAllocateStatement), V_SgAllocateStatement ) );
  118336             : 
  118337           0 :         if ( SgAllocateStatement::next_node != NULL ) {
  118338           0 :           if ( blockIndex > 0 ) {
  118339           0 :             SgAllocateStatement * blkptr = (SgAllocateStatement*)(SgAllocateStatement::pools[blockIndex-1]);
  118340           0 :             blkptr[ SgAllocateStatement::pool_size - 1 ].set_freepointer(pointer);
  118341             :           }
  118342             :         } else {
  118343           0 :           SgAllocateStatement::next_node = pointer;
  118344             :         }
  118345             : 
  118346           0 :         for (unsigned i = 0; i < SgAllocateStatement::pool_size-1; ++i)
  118347             :            {
  118348           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  118349             :            }
  118350           0 :         pointer[ SgAllocateStatement::pool_size -1 ].set_freepointer(NULL);
  118351             : 
  118352           0 :         blockIndex++;
  118353             :       }
  118354           2 :   }
  118355             : 
  118356             : //############################################################################
  118357             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  118358             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  118359             :  * not compressed. However, that stuff is not yet implemented! 
  118360             :  */
  118361             : unsigned long
  118362           0 : SgAllocateStatement::getNumberOfLastValidPointer()
  118363             :    {
  118364           0 :       SgAllocateStatement* testPointer = (SgAllocateStatement*)(SgAllocateStatement::pools.back());
  118365           0 :       unsigned long localIndex = SgAllocateStatement::pool_size - 1;
  118366           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  118367             :          {
  118368           0 :            localIndex--;
  118369             :          }
  118370           0 :       return (localIndex + SgAllocateStatement::pool_size * (SgAllocateStatement::pools.size()-1));
  118371             :    }
  118372             : 
  118373             : //############################################################################
  118374             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  118375             :  * memory pool and initializes the data member in class SgAllocateStatementStroageClass
  118376             :  * from its counterpart of SgAllocateStatement. The return value is just for checking, 
  118377             :  * that the whole StorageClassArray is initialized!
  118378             :  */
  118379             : unsigned long
  118380           0 : SgAllocateStatement::initializeStorageClassArray( SgAllocateStatementStorageClass *storageArray )
  118381             :    {
  118382           0 :      unsigned long storageCounter = 0;
  118383           0 :      std::vector < unsigned char* > :: const_iterator block = SgAllocateStatement::pools.begin();
  118384           0 :      SgAllocateStatement* pointer = NULL;
  118385           0 :      while ( block != SgAllocateStatement::pools.end() ) {
  118386           0 :           pointer = (SgAllocateStatement*) (*block);
  118387           0 :           for ( unsigned i = 0; i < SgAllocateStatement::pool_size; ++i ) {
  118388           0 :                if ( pointer->get_freepointer() != NULL ) {
  118389           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  118390           0 :                  storageArray++;
  118391           0 :                  storageCounter++;
  118392             :                }
  118393           0 :                pointer++;
  118394             :              }
  118395           0 :            block++;
  118396             :         }
  118397           0 :      return storageCounter;
  118398             :    }
  118399             : 
  118400             : /* #line 118401 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  118401             : 
  118402             : 
  118403             : 
  118404             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  118405             : 
  118406             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  118407             : 
  118408             : //############################################################################
  118409             : /* JH (02/02/2006) Constructor of the IR node SgDeallocateStatement that takes its 
  118410             :  * corresponding StorageClass as parameter
  118411             :  */
  118412           0 : SgDeallocateStatement :: SgDeallocateStatement ( const SgDeallocateStatementStorageClass& storageSource )   : SgStatement (storageSource)
  118413             :    {
  118414             : 
  118415             : 
  118416             : /* #line 118417 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  118417             : 
  118418           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  118419           0 :      p_expr_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expr_list) );
  118420           0 :      p_stat_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_stat_expression) );
  118421           0 :      p_errmsg_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_errmsg_expression) );
  118422             : 
  118423             : 
  118424             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  118425             : 
  118426             : 
  118427           0 :    }
  118428             : 
  118429             : //############################################################################
  118430             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  118431             :  * within the working AST. 
  118432             :  */
  118433           0 : SgDeallocateStatement * SgDeallocateStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  118434           0 :      SgDeallocateStatement* returnPointer = NULL;
  118435           0 :      if ( globalIndex != 0 )
  118436             :         {
  118437             : 
  118438             : #if FILE_IO_EXTRA_CHECK
  118439           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDeallocateStatement ) ) <= globalIndex ) ;
  118440           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeallocateStatement + 1 ) ) );
  118441             : #endif
  118442           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeallocateStatement )  
  118443           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDeallocateStatement );
  118444           0 :           unsigned long positionInPool = localIndex % SgDeallocateStatement::pool_size;
  118445           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeallocateStatement::pool_size;
  118446             : 
  118447             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  118448             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  118449             : 
  118450           0 :           returnPointer = &( ( (SgDeallocateStatement*)(SgDeallocateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  118451             : 
  118452           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  118453             :         }
  118454           0 :      return returnPointer ;
  118455             :    }
  118456             : 
  118457             : //############################################################################
  118458             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  118459             :   for the AST with the index astIndex
  118460             : */
  118461           0 : SgDeallocateStatement * SgDeallocateStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  118462           0 :      SgDeallocateStatement* returnPointer = NULL;
  118463           0 :      if ( globalIndex != 0 )
  118464             :         {
  118465             : 
  118466             : #if FILE_IO_EXTRA_CHECK
  118467           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDeallocateStatement ) ) <= globalIndex ) ;
  118468           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeallocateStatement + 1 ) ) );
  118469             : #endif
  118470           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeallocateStatement )
  118471           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDeallocateStatement );
  118472           0 :           unsigned long positionInPool = localIndex % SgDeallocateStatement::pool_size ;
  118473           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeallocateStatement::pool_size ;
  118474             : 
  118475             : #if FILE_IO_EXTRA_CHECK
  118476             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  118477             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  118478             : #endif
  118479             : 
  118480           0 :           returnPointer = &( ( (SgDeallocateStatement*)(SgDeallocateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  118481             : 
  118482             : #if FILE_IO_EXTRA_CHECK
  118483           0 :           assert ( returnPointer != NULL ) ;
  118484             : #endif
  118485             :         }
  118486           0 :      return returnPointer ;
  118487             :    }
  118488             : 
  118489             : //############################################################################
  118490             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  118491             :  * pool size! We set for every valid object in the memory pool the freepointer
  118492             :  * to the global index and increase the global index afterwards. For all the 
  118493             :  * invalid objects (means address ranges within the memory pool that were not
  118494             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  118495             :  * distinguish valid from invalid objects! 
  118496             :  */
  118497             : unsigned long
  118498           5 : SgDeallocateStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  118499             :    {
  118500           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  118501           5 :      SgDeallocateStatement* pointer = NULL;
  118502           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  118503           5 :      std::vector < unsigned char* > :: const_iterator block;
  118504           5 :      for ( block = SgDeallocateStatement::pools.begin(); block != SgDeallocateStatement::pools.end() ; ++block )
  118505             :         {
  118506           0 :           pointer = (SgDeallocateStatement*)(*block);
  118507           0 :           for (unsigned i = 0; i < SgDeallocateStatement::pool_size; ++i )
  118508             :              {
  118509             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  118510             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  118511             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  118512             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  118513             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  118514             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  118515             :             // properly; so this will have to be checked next.
  118516             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  118517             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  118518           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  118519             :                   {
  118520           0 :                     pointer[i].set_freepointer((SgDeallocateStatement*)(globalIndex));
  118521           0 :                     globalIndex++;
  118522             :                   }
  118523             :                else
  118524             :                   {
  118525           0 :                     pointer[i].set_freepointer(NULL);
  118526             :                   }
  118527             :               }
  118528             :         }
  118529           5 :      return globalIndex;
  118530             :    }
  118531             : 
  118532             : //############################################################################
  118533             : // JH (01/14/2006)
  118534             : void
  118535           5 : SgDeallocateStatement::resetValidFreepointers( )
  118536             :    {
  118537           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  118538           5 :      SgDeallocateStatement* pointer = NULL;
  118539           5 :      std::vector < unsigned char* > :: const_iterator block;
  118540           5 :      SgDeallocateStatement* pointerOfLinkedList = NULL;
  118541           5 :      for ( block = SgDeallocateStatement::pools.begin(); block != SgDeallocateStatement::pools.end() ; ++block )
  118542             :         {
  118543           0 :           pointer = (SgDeallocateStatement*)(*block);
  118544           0 :           for (unsigned i = 0; i < SgDeallocateStatement::pool_size; ++i )
  118545             :              {
  118546             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  118547             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  118548             :             // memory blocks!.
  118549           0 :                if ( pointer[i].get_freepointer() != NULL )
  118550             :                   {
  118551           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  118552             :                   }
  118553             :                else
  118554             :                   {
  118555           0 :                     if ( pointerOfLinkedList == NULL )
  118556             :                        {
  118557           0 :                          SgDeallocateStatement::next_node = &(pointer[i]);
  118558             :                        }
  118559             :                     else
  118560             :                        {
  118561             :                       // printf ("In SgDeallocateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  118562           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  118563             :                        }
  118564             :                     pointerOfLinkedList = &(pointer[i]);
  118565             :                   }
  118566             :               }
  118567             :         }
  118568             : 
  118569           5 :      if ( pointerOfLinkedList != NULL )
  118570             :         {
  118571             :        // printf ("In SgDeallocateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  118572           0 :           pointerOfLinkedList->set_freepointer(NULL);
  118573             :        // DQ (6/6/2010): Temporary debugging...
  118574             :        //   ROSE_ASSERT(false);
  118575             :         }
  118576             : 
  118577           5 :      return ;
  118578             :    }
  118579             : 
  118580             : //############################################################################
  118581             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  118582             :  * within the memory pool and resets the freepointers, in order to achieve a 
  118583             :  * linked list, that has no jumps and starts at the beginning! This function 
  118584             :  * does not extend the memory pool, since we do not delete any memory blocks,
  118585             :  * but delete the valid objects.  
  118586             :  */
  118587             : void
  118588           0 : SgDeallocateStatement::clearMemoryPool( )
  118589             :    {
  118590             :   // printf ("Inside of SgDeallocateStatement::clearMemoryPool() \n");
  118591             : 
  118592           0 :      SgDeallocateStatement* pointer = NULL, *tempPointer = NULL;
  118593           0 :      std::vector < unsigned char* > :: const_iterator block;
  118594           0 :      if ( SgDeallocateStatement::pools.empty() == false )
  118595             :         {
  118596           0 :           block = SgDeallocateStatement::pools.begin() ;
  118597           0 :           SgDeallocateStatement::next_node = (SgDeallocateStatement*) (*block);
  118598             : 
  118599           0 :           while ( block != SgDeallocateStatement::pools.end() )
  118600             :              {
  118601           0 :                pointer = (SgDeallocateStatement*) (*block);
  118602           0 :                if ( tempPointer != NULL )
  118603             :                   {
  118604           0 :                     tempPointer->set_freepointer(pointer);
  118605             :                   }
  118606           0 :                for (unsigned i = 0; i < SgDeallocateStatement::pool_size - 1; ++i)
  118607             :                   {
  118608           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  118609             :                   }
  118610           0 :                 pointer[SgDeallocateStatement::pool_size-1].set_freepointer(NULL);
  118611           0 :                 tempPointer = &(pointer[SgDeallocateStatement::pool_size-1]);
  118612           0 :                 ++block;
  118613             :              }
  118614             :         }
  118615           0 :    }
  118616             : 
  118617           5 : void SgDeallocateStatement::deleteMemoryPool() {
  118618           5 :   for (auto p: SgDeallocateStatement::pools) {
  118619           0 :     ROSE_FREE(p);
  118620             :   }
  118621           5 :   SgDeallocateStatement::next_node = nullptr;
  118622           5 :   SgDeallocateStatement::pools.clear();
  118623           5 : }
  118624             : 
  118625             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  118626             : //                 reading multiple binary files to for a single AST.
  118627             : /////////// new version ////////////////////////////////
  118628             : //############################################################################
  118629             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  118630             : void
  118631           2 : SgDeallocateStatement::extendMemoryPoolForFileIO( )
  118632             :   {
  118633           2 :     size_t blockIndex = SgDeallocateStatement::pools.size();
  118634           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDeallocateStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeallocateStatement);
  118635             : 
  118636           2 :     while ( (blockIndex * SgDeallocateStatement::pool_size) < newPoolSize)
  118637             :       {
  118638             : #if ROSE_ALLOC_TRACE
  118639             :         if (blockIndex > 0) {
  118640             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDeallocateStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeallocateStatement) = %" PRIuPTR " SgDeallocateStatement::pool_size = %d \n",
  118641             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDeallocateStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeallocateStatement),SgDeallocateStatement::pool_size);
  118642             :         }
  118643             : #endif
  118644             : 
  118645           0 :         SgDeallocateStatement * pointer = (SgDeallocateStatement*) ROSE_MALLOC ( SgDeallocateStatement::pool_size * sizeof(SgDeallocateStatement) );
  118646           0 :         assert( pointer != NULL );
  118647             : #if ROSE_ALLOC_MEMSET == 1
  118648             :         memset(pointer, 0x00, SgDeallocateStatement::pool_size * sizeof(SgDeallocateStatement));
  118649             : #elif ROSE_ALLOC_MEMSET == 2
  118650             :         memset(pointer, 0xCC, SgDeallocateStatement::pool_size * sizeof(SgDeallocateStatement));
  118651             : #endif
  118652           0 :         SgDeallocateStatement::pools.push_back( (unsigned char*)(pointer) );
  118653           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDeallocateStatement::pool_size * sizeof(SgDeallocateStatement), V_SgDeallocateStatement ) );
  118654             : 
  118655           0 :         if ( SgDeallocateStatement::next_node != NULL ) {
  118656           0 :           if ( blockIndex > 0 ) {
  118657           0 :             SgDeallocateStatement * blkptr = (SgDeallocateStatement*)(SgDeallocateStatement::pools[blockIndex-1]);
  118658           0 :             blkptr[ SgDeallocateStatement::pool_size - 1 ].set_freepointer(pointer);
  118659             :           }
  118660             :         } else {
  118661           0 :           SgDeallocateStatement::next_node = pointer;
  118662             :         }
  118663             : 
  118664           0 :         for (unsigned i = 0; i < SgDeallocateStatement::pool_size-1; ++i)
  118665             :            {
  118666           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  118667             :            }
  118668           0 :         pointer[ SgDeallocateStatement::pool_size -1 ].set_freepointer(NULL);
  118669             : 
  118670           0 :         blockIndex++;
  118671             :       }
  118672           2 :   }
  118673             : 
  118674             : //############################################################################
  118675             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  118676             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  118677             :  * not compressed. However, that stuff is not yet implemented! 
  118678             :  */
  118679             : unsigned long
  118680           0 : SgDeallocateStatement::getNumberOfLastValidPointer()
  118681             :    {
  118682           0 :       SgDeallocateStatement* testPointer = (SgDeallocateStatement*)(SgDeallocateStatement::pools.back());
  118683           0 :       unsigned long localIndex = SgDeallocateStatement::pool_size - 1;
  118684           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  118685             :          {
  118686           0 :            localIndex--;
  118687             :          }
  118688           0 :       return (localIndex + SgDeallocateStatement::pool_size * (SgDeallocateStatement::pools.size()-1));
  118689             :    }
  118690             : 
  118691             : //############################################################################
  118692             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  118693             :  * memory pool and initializes the data member in class SgDeallocateStatementStroageClass
  118694             :  * from its counterpart of SgDeallocateStatement. The return value is just for checking, 
  118695             :  * that the whole StorageClassArray is initialized!
  118696             :  */
  118697             : unsigned long
  118698           0 : SgDeallocateStatement::initializeStorageClassArray( SgDeallocateStatementStorageClass *storageArray )
  118699             :    {
  118700           0 :      unsigned long storageCounter = 0;
  118701           0 :      std::vector < unsigned char* > :: const_iterator block = SgDeallocateStatement::pools.begin();
  118702           0 :      SgDeallocateStatement* pointer = NULL;
  118703           0 :      while ( block != SgDeallocateStatement::pools.end() ) {
  118704           0 :           pointer = (SgDeallocateStatement*) (*block);
  118705           0 :           for ( unsigned i = 0; i < SgDeallocateStatement::pool_size; ++i ) {
  118706           0 :                if ( pointer->get_freepointer() != NULL ) {
  118707           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  118708           0 :                  storageArray++;
  118709           0 :                  storageCounter++;
  118710             :                }
  118711           0 :                pointer++;
  118712             :              }
  118713           0 :            block++;
  118714             :         }
  118715           0 :      return storageCounter;
  118716             :    }
  118717             : 
  118718             : /* #line 118719 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  118719             : 
  118720             : 
  118721             : 
  118722             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  118723             : 
  118724             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  118725             : 
  118726             : //############################################################################
  118727             : /* JH (02/02/2006) Constructor of the IR node SgUpcNotifyStatement that takes its 
  118728             :  * corresponding StorageClass as parameter
  118729             :  */
  118730           0 : SgUpcNotifyStatement :: SgUpcNotifyStatement ( const SgUpcNotifyStatementStorageClass& storageSource )   : SgStatement (storageSource)
  118731             :    {
  118732             : 
  118733             : 
  118734             : /* #line 118735 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  118735             : 
  118736           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  118737           0 :      p_notify_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_notify_expression) );
  118738             : 
  118739             : 
  118740             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  118741             : 
  118742             : 
  118743           0 :    }
  118744             : 
  118745             : //############################################################################
  118746             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  118747             :  * within the working AST. 
  118748             :  */
  118749           0 : SgUpcNotifyStatement * SgUpcNotifyStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  118750           0 :      SgUpcNotifyStatement* returnPointer = NULL;
  118751           0 :      if ( globalIndex != 0 )
  118752             :         {
  118753             : 
  118754             : #if FILE_IO_EXTRA_CHECK
  118755           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcNotifyStatement ) ) <= globalIndex ) ;
  118756           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcNotifyStatement + 1 ) ) );
  118757             : #endif
  118758           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcNotifyStatement )  
  118759           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcNotifyStatement );
  118760           0 :           unsigned long positionInPool = localIndex % SgUpcNotifyStatement::pool_size;
  118761           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcNotifyStatement::pool_size;
  118762             : 
  118763             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  118764             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  118765             : 
  118766           0 :           returnPointer = &( ( (SgUpcNotifyStatement*)(SgUpcNotifyStatement::pools[memoryBlock]) ) [positionInPool]) ;
  118767             : 
  118768           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  118769             :         }
  118770           0 :      return returnPointer ;
  118771             :    }
  118772             : 
  118773             : //############################################################################
  118774             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  118775             :   for the AST with the index astIndex
  118776             : */
  118777           0 : SgUpcNotifyStatement * SgUpcNotifyStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  118778           0 :      SgUpcNotifyStatement* returnPointer = NULL;
  118779           0 :      if ( globalIndex != 0 )
  118780             :         {
  118781             : 
  118782             : #if FILE_IO_EXTRA_CHECK
  118783           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcNotifyStatement ) ) <= globalIndex ) ;
  118784           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcNotifyStatement + 1 ) ) );
  118785             : #endif
  118786           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcNotifyStatement )
  118787           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcNotifyStatement );
  118788           0 :           unsigned long positionInPool = localIndex % SgUpcNotifyStatement::pool_size ;
  118789           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcNotifyStatement::pool_size ;
  118790             : 
  118791             : #if FILE_IO_EXTRA_CHECK
  118792             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  118793             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  118794             : #endif
  118795             : 
  118796           0 :           returnPointer = &( ( (SgUpcNotifyStatement*)(SgUpcNotifyStatement::pools[memoryBlock]) ) [positionInPool]) ;
  118797             : 
  118798             : #if FILE_IO_EXTRA_CHECK
  118799           0 :           assert ( returnPointer != NULL ) ;
  118800             : #endif
  118801             :         }
  118802           0 :      return returnPointer ;
  118803             :    }
  118804             : 
  118805             : //############################################################################
  118806             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  118807             :  * pool size! We set for every valid object in the memory pool the freepointer
  118808             :  * to the global index and increase the global index afterwards. For all the 
  118809             :  * invalid objects (means address ranges within the memory pool that were not
  118810             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  118811             :  * distinguish valid from invalid objects! 
  118812             :  */
  118813             : unsigned long
  118814           5 : SgUpcNotifyStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  118815             :    {
  118816           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  118817           5 :      SgUpcNotifyStatement* pointer = NULL;
  118818           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  118819           5 :      std::vector < unsigned char* > :: const_iterator block;
  118820           5 :      for ( block = SgUpcNotifyStatement::pools.begin(); block != SgUpcNotifyStatement::pools.end() ; ++block )
  118821             :         {
  118822           0 :           pointer = (SgUpcNotifyStatement*)(*block);
  118823           0 :           for (unsigned i = 0; i < SgUpcNotifyStatement::pool_size; ++i )
  118824             :              {
  118825             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  118826             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  118827             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  118828             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  118829             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  118830             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  118831             :             // properly; so this will have to be checked next.
  118832             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  118833             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  118834           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  118835             :                   {
  118836           0 :                     pointer[i].set_freepointer((SgUpcNotifyStatement*)(globalIndex));
  118837           0 :                     globalIndex++;
  118838             :                   }
  118839             :                else
  118840             :                   {
  118841           0 :                     pointer[i].set_freepointer(NULL);
  118842             :                   }
  118843             :               }
  118844             :         }
  118845           5 :      return globalIndex;
  118846             :    }
  118847             : 
  118848             : //############################################################################
  118849             : // JH (01/14/2006)
  118850             : void
  118851           5 : SgUpcNotifyStatement::resetValidFreepointers( )
  118852             :    {
  118853           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  118854           5 :      SgUpcNotifyStatement* pointer = NULL;
  118855           5 :      std::vector < unsigned char* > :: const_iterator block;
  118856           5 :      SgUpcNotifyStatement* pointerOfLinkedList = NULL;
  118857           5 :      for ( block = SgUpcNotifyStatement::pools.begin(); block != SgUpcNotifyStatement::pools.end() ; ++block )
  118858             :         {
  118859           0 :           pointer = (SgUpcNotifyStatement*)(*block);
  118860           0 :           for (unsigned i = 0; i < SgUpcNotifyStatement::pool_size; ++i )
  118861             :              {
  118862             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  118863             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  118864             :             // memory blocks!.
  118865           0 :                if ( pointer[i].get_freepointer() != NULL )
  118866             :                   {
  118867           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  118868             :                   }
  118869             :                else
  118870             :                   {
  118871           0 :                     if ( pointerOfLinkedList == NULL )
  118872             :                        {
  118873           0 :                          SgUpcNotifyStatement::next_node = &(pointer[i]);
  118874             :                        }
  118875             :                     else
  118876             :                        {
  118877             :                       // printf ("In SgUpcNotifyStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  118878           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  118879             :                        }
  118880             :                     pointerOfLinkedList = &(pointer[i]);
  118881             :                   }
  118882             :               }
  118883             :         }
  118884             : 
  118885           5 :      if ( pointerOfLinkedList != NULL )
  118886             :         {
  118887             :        // printf ("In SgUpcNotifyStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  118888           0 :           pointerOfLinkedList->set_freepointer(NULL);
  118889             :        // DQ (6/6/2010): Temporary debugging...
  118890             :        //   ROSE_ASSERT(false);
  118891             :         }
  118892             : 
  118893           5 :      return ;
  118894             :    }
  118895             : 
  118896             : //############################################################################
  118897             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  118898             :  * within the memory pool and resets the freepointers, in order to achieve a 
  118899             :  * linked list, that has no jumps and starts at the beginning! This function 
  118900             :  * does not extend the memory pool, since we do not delete any memory blocks,
  118901             :  * but delete the valid objects.  
  118902             :  */
  118903             : void
  118904           0 : SgUpcNotifyStatement::clearMemoryPool( )
  118905             :    {
  118906             :   // printf ("Inside of SgUpcNotifyStatement::clearMemoryPool() \n");
  118907             : 
  118908           0 :      SgUpcNotifyStatement* pointer = NULL, *tempPointer = NULL;
  118909           0 :      std::vector < unsigned char* > :: const_iterator block;
  118910           0 :      if ( SgUpcNotifyStatement::pools.empty() == false )
  118911             :         {
  118912           0 :           block = SgUpcNotifyStatement::pools.begin() ;
  118913           0 :           SgUpcNotifyStatement::next_node = (SgUpcNotifyStatement*) (*block);
  118914             : 
  118915           0 :           while ( block != SgUpcNotifyStatement::pools.end() )
  118916             :              {
  118917           0 :                pointer = (SgUpcNotifyStatement*) (*block);
  118918           0 :                if ( tempPointer != NULL )
  118919             :                   {
  118920           0 :                     tempPointer->set_freepointer(pointer);
  118921             :                   }
  118922           0 :                for (unsigned i = 0; i < SgUpcNotifyStatement::pool_size - 1; ++i)
  118923             :                   {
  118924           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  118925             :                   }
  118926           0 :                 pointer[SgUpcNotifyStatement::pool_size-1].set_freepointer(NULL);
  118927           0 :                 tempPointer = &(pointer[SgUpcNotifyStatement::pool_size-1]);
  118928           0 :                 ++block;
  118929             :              }
  118930             :         }
  118931           0 :    }
  118932             : 
  118933           5 : void SgUpcNotifyStatement::deleteMemoryPool() {
  118934           5 :   for (auto p: SgUpcNotifyStatement::pools) {
  118935           0 :     ROSE_FREE(p);
  118936             :   }
  118937           5 :   SgUpcNotifyStatement::next_node = nullptr;
  118938           5 :   SgUpcNotifyStatement::pools.clear();
  118939           5 : }
  118940             : 
  118941             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  118942             : //                 reading multiple binary files to for a single AST.
  118943             : /////////// new version ////////////////////////////////
  118944             : //############################################################################
  118945             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  118946             : void
  118947           2 : SgUpcNotifyStatement::extendMemoryPoolForFileIO( )
  118948             :   {
  118949           2 :     size_t blockIndex = SgUpcNotifyStatement::pools.size();
  118950           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcNotifyStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcNotifyStatement);
  118951             : 
  118952           2 :     while ( (blockIndex * SgUpcNotifyStatement::pool_size) < newPoolSize)
  118953             :       {
  118954             : #if ROSE_ALLOC_TRACE
  118955             :         if (blockIndex > 0) {
  118956             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcNotifyStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcNotifyStatement) = %" PRIuPTR " SgUpcNotifyStatement::pool_size = %d \n",
  118957             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcNotifyStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcNotifyStatement),SgUpcNotifyStatement::pool_size);
  118958             :         }
  118959             : #endif
  118960             : 
  118961           0 :         SgUpcNotifyStatement * pointer = (SgUpcNotifyStatement*) ROSE_MALLOC ( SgUpcNotifyStatement::pool_size * sizeof(SgUpcNotifyStatement) );
  118962           0 :         assert( pointer != NULL );
  118963             : #if ROSE_ALLOC_MEMSET == 1
  118964             :         memset(pointer, 0x00, SgUpcNotifyStatement::pool_size * sizeof(SgUpcNotifyStatement));
  118965             : #elif ROSE_ALLOC_MEMSET == 2
  118966             :         memset(pointer, 0xCC, SgUpcNotifyStatement::pool_size * sizeof(SgUpcNotifyStatement));
  118967             : #endif
  118968           0 :         SgUpcNotifyStatement::pools.push_back( (unsigned char*)(pointer) );
  118969           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcNotifyStatement::pool_size * sizeof(SgUpcNotifyStatement), V_SgUpcNotifyStatement ) );
  118970             : 
  118971           0 :         if ( SgUpcNotifyStatement::next_node != NULL ) {
  118972           0 :           if ( blockIndex > 0 ) {
  118973           0 :             SgUpcNotifyStatement * blkptr = (SgUpcNotifyStatement*)(SgUpcNotifyStatement::pools[blockIndex-1]);
  118974           0 :             blkptr[ SgUpcNotifyStatement::pool_size - 1 ].set_freepointer(pointer);
  118975             :           }
  118976             :         } else {
  118977           0 :           SgUpcNotifyStatement::next_node = pointer;
  118978             :         }
  118979             : 
  118980           0 :         for (unsigned i = 0; i < SgUpcNotifyStatement::pool_size-1; ++i)
  118981             :            {
  118982           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  118983             :            }
  118984           0 :         pointer[ SgUpcNotifyStatement::pool_size -1 ].set_freepointer(NULL);
  118985             : 
  118986           0 :         blockIndex++;
  118987             :       }
  118988           2 :   }
  118989             : 
  118990             : //############################################################################
  118991             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  118992             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  118993             :  * not compressed. However, that stuff is not yet implemented! 
  118994             :  */
  118995             : unsigned long
  118996           0 : SgUpcNotifyStatement::getNumberOfLastValidPointer()
  118997             :    {
  118998           0 :       SgUpcNotifyStatement* testPointer = (SgUpcNotifyStatement*)(SgUpcNotifyStatement::pools.back());
  118999           0 :       unsigned long localIndex = SgUpcNotifyStatement::pool_size - 1;
  119000           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  119001             :          {
  119002           0 :            localIndex--;
  119003             :          }
  119004           0 :       return (localIndex + SgUpcNotifyStatement::pool_size * (SgUpcNotifyStatement::pools.size()-1));
  119005             :    }
  119006             : 
  119007             : //############################################################################
  119008             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  119009             :  * memory pool and initializes the data member in class SgUpcNotifyStatementStroageClass
  119010             :  * from its counterpart of SgUpcNotifyStatement. The return value is just for checking, 
  119011             :  * that the whole StorageClassArray is initialized!
  119012             :  */
  119013             : unsigned long
  119014           0 : SgUpcNotifyStatement::initializeStorageClassArray( SgUpcNotifyStatementStorageClass *storageArray )
  119015             :    {
  119016           0 :      unsigned long storageCounter = 0;
  119017           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcNotifyStatement::pools.begin();
  119018           0 :      SgUpcNotifyStatement* pointer = NULL;
  119019           0 :      while ( block != SgUpcNotifyStatement::pools.end() ) {
  119020           0 :           pointer = (SgUpcNotifyStatement*) (*block);
  119021           0 :           for ( unsigned i = 0; i < SgUpcNotifyStatement::pool_size; ++i ) {
  119022           0 :                if ( pointer->get_freepointer() != NULL ) {
  119023           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  119024           0 :                  storageArray++;
  119025           0 :                  storageCounter++;
  119026             :                }
  119027           0 :                pointer++;
  119028             :              }
  119029           0 :            block++;
  119030             :         }
  119031           0 :      return storageCounter;
  119032             :    }
  119033             : 
  119034             : /* #line 119035 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  119035             : 
  119036             : 
  119037             : 
  119038             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  119039             : 
  119040             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  119041             : 
  119042             : //############################################################################
  119043             : /* JH (02/02/2006) Constructor of the IR node SgUpcWaitStatement that takes its 
  119044             :  * corresponding StorageClass as parameter
  119045             :  */
  119046           0 : SgUpcWaitStatement :: SgUpcWaitStatement ( const SgUpcWaitStatementStorageClass& storageSource )   : SgStatement (storageSource)
  119047             :    {
  119048             : 
  119049             : 
  119050             : /* #line 119051 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  119051             : 
  119052           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  119053           0 :      p_wait_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_wait_expression) );
  119054             : 
  119055             : 
  119056             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  119057             : 
  119058             : 
  119059           0 :    }
  119060             : 
  119061             : //############################################################################
  119062             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  119063             :  * within the working AST. 
  119064             :  */
  119065           0 : SgUpcWaitStatement * SgUpcWaitStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  119066           0 :      SgUpcWaitStatement* returnPointer = NULL;
  119067           0 :      if ( globalIndex != 0 )
  119068             :         {
  119069             : 
  119070             : #if FILE_IO_EXTRA_CHECK
  119071           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcWaitStatement ) ) <= globalIndex ) ;
  119072           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcWaitStatement + 1 ) ) );
  119073             : #endif
  119074           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcWaitStatement )  
  119075           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcWaitStatement );
  119076           0 :           unsigned long positionInPool = localIndex % SgUpcWaitStatement::pool_size;
  119077           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcWaitStatement::pool_size;
  119078             : 
  119079             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  119080             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  119081             : 
  119082           0 :           returnPointer = &( ( (SgUpcWaitStatement*)(SgUpcWaitStatement::pools[memoryBlock]) ) [positionInPool]) ;
  119083             : 
  119084           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  119085             :         }
  119086           0 :      return returnPointer ;
  119087             :    }
  119088             : 
  119089             : //############################################################################
  119090             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  119091             :   for the AST with the index astIndex
  119092             : */
  119093           0 : SgUpcWaitStatement * SgUpcWaitStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  119094           0 :      SgUpcWaitStatement* returnPointer = NULL;
  119095           0 :      if ( globalIndex != 0 )
  119096             :         {
  119097             : 
  119098             : #if FILE_IO_EXTRA_CHECK
  119099           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcWaitStatement ) ) <= globalIndex ) ;
  119100           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcWaitStatement + 1 ) ) );
  119101             : #endif
  119102           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcWaitStatement )
  119103           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcWaitStatement );
  119104           0 :           unsigned long positionInPool = localIndex % SgUpcWaitStatement::pool_size ;
  119105           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcWaitStatement::pool_size ;
  119106             : 
  119107             : #if FILE_IO_EXTRA_CHECK
  119108             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  119109             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  119110             : #endif
  119111             : 
  119112           0 :           returnPointer = &( ( (SgUpcWaitStatement*)(SgUpcWaitStatement::pools[memoryBlock]) ) [positionInPool]) ;
  119113             : 
  119114             : #if FILE_IO_EXTRA_CHECK
  119115           0 :           assert ( returnPointer != NULL ) ;
  119116             : #endif
  119117             :         }
  119118           0 :      return returnPointer ;
  119119             :    }
  119120             : 
  119121             : //############################################################################
  119122             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  119123             :  * pool size! We set for every valid object in the memory pool the freepointer
  119124             :  * to the global index and increase the global index afterwards. For all the 
  119125             :  * invalid objects (means address ranges within the memory pool that were not
  119126             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  119127             :  * distinguish valid from invalid objects! 
  119128             :  */
  119129             : unsigned long
  119130           5 : SgUpcWaitStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  119131             :    {
  119132           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  119133           5 :      SgUpcWaitStatement* pointer = NULL;
  119134           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  119135           5 :      std::vector < unsigned char* > :: const_iterator block;
  119136           5 :      for ( block = SgUpcWaitStatement::pools.begin(); block != SgUpcWaitStatement::pools.end() ; ++block )
  119137             :         {
  119138           0 :           pointer = (SgUpcWaitStatement*)(*block);
  119139           0 :           for (unsigned i = 0; i < SgUpcWaitStatement::pool_size; ++i )
  119140             :              {
  119141             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  119142             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  119143             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  119144             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  119145             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  119146             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  119147             :             // properly; so this will have to be checked next.
  119148             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  119149             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  119150           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  119151             :                   {
  119152           0 :                     pointer[i].set_freepointer((SgUpcWaitStatement*)(globalIndex));
  119153           0 :                     globalIndex++;
  119154             :                   }
  119155             :                else
  119156             :                   {
  119157           0 :                     pointer[i].set_freepointer(NULL);
  119158             :                   }
  119159             :               }
  119160             :         }
  119161           5 :      return globalIndex;
  119162             :    }
  119163             : 
  119164             : //############################################################################
  119165             : // JH (01/14/2006)
  119166             : void
  119167           5 : SgUpcWaitStatement::resetValidFreepointers( )
  119168             :    {
  119169           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  119170           5 :      SgUpcWaitStatement* pointer = NULL;
  119171           5 :      std::vector < unsigned char* > :: const_iterator block;
  119172           5 :      SgUpcWaitStatement* pointerOfLinkedList = NULL;
  119173           5 :      for ( block = SgUpcWaitStatement::pools.begin(); block != SgUpcWaitStatement::pools.end() ; ++block )
  119174             :         {
  119175           0 :           pointer = (SgUpcWaitStatement*)(*block);
  119176           0 :           for (unsigned i = 0; i < SgUpcWaitStatement::pool_size; ++i )
  119177             :              {
  119178             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  119179             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  119180             :             // memory blocks!.
  119181           0 :                if ( pointer[i].get_freepointer() != NULL )
  119182             :                   {
  119183           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  119184             :                   }
  119185             :                else
  119186             :                   {
  119187           0 :                     if ( pointerOfLinkedList == NULL )
  119188             :                        {
  119189           0 :                          SgUpcWaitStatement::next_node = &(pointer[i]);
  119190             :                        }
  119191             :                     else
  119192             :                        {
  119193             :                       // printf ("In SgUpcWaitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  119194           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  119195             :                        }
  119196             :                     pointerOfLinkedList = &(pointer[i]);
  119197             :                   }
  119198             :               }
  119199             :         }
  119200             : 
  119201           5 :      if ( pointerOfLinkedList != NULL )
  119202             :         {
  119203             :        // printf ("In SgUpcWaitStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  119204           0 :           pointerOfLinkedList->set_freepointer(NULL);
  119205             :        // DQ (6/6/2010): Temporary debugging...
  119206             :        //   ROSE_ASSERT(false);
  119207             :         }
  119208             : 
  119209           5 :      return ;
  119210             :    }
  119211             : 
  119212             : //############################################################################
  119213             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  119214             :  * within the memory pool and resets the freepointers, in order to achieve a 
  119215             :  * linked list, that has no jumps and starts at the beginning! This function 
  119216             :  * does not extend the memory pool, since we do not delete any memory blocks,
  119217             :  * but delete the valid objects.  
  119218             :  */
  119219             : void
  119220           0 : SgUpcWaitStatement::clearMemoryPool( )
  119221             :    {
  119222             :   // printf ("Inside of SgUpcWaitStatement::clearMemoryPool() \n");
  119223             : 
  119224           0 :      SgUpcWaitStatement* pointer = NULL, *tempPointer = NULL;
  119225           0 :      std::vector < unsigned char* > :: const_iterator block;
  119226           0 :      if ( SgUpcWaitStatement::pools.empty() == false )
  119227             :         {
  119228           0 :           block = SgUpcWaitStatement::pools.begin() ;
  119229           0 :           SgUpcWaitStatement::next_node = (SgUpcWaitStatement*) (*block);
  119230             : 
  119231           0 :           while ( block != SgUpcWaitStatement::pools.end() )
  119232             :              {
  119233           0 :                pointer = (SgUpcWaitStatement*) (*block);
  119234           0 :                if ( tempPointer != NULL )
  119235             :                   {
  119236           0 :                     tempPointer->set_freepointer(pointer);
  119237             :                   }
  119238           0 :                for (unsigned i = 0; i < SgUpcWaitStatement::pool_size - 1; ++i)
  119239             :                   {
  119240           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  119241             :                   }
  119242           0 :                 pointer[SgUpcWaitStatement::pool_size-1].set_freepointer(NULL);
  119243           0 :                 tempPointer = &(pointer[SgUpcWaitStatement::pool_size-1]);
  119244           0 :                 ++block;
  119245             :              }
  119246             :         }
  119247           0 :    }
  119248             : 
  119249           5 : void SgUpcWaitStatement::deleteMemoryPool() {
  119250           5 :   for (auto p: SgUpcWaitStatement::pools) {
  119251           0 :     ROSE_FREE(p);
  119252             :   }
  119253           5 :   SgUpcWaitStatement::next_node = nullptr;
  119254           5 :   SgUpcWaitStatement::pools.clear();
  119255           5 : }
  119256             : 
  119257             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  119258             : //                 reading multiple binary files to for a single AST.
  119259             : /////////// new version ////////////////////////////////
  119260             : //############################################################################
  119261             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  119262             : void
  119263           2 : SgUpcWaitStatement::extendMemoryPoolForFileIO( )
  119264             :   {
  119265           2 :     size_t blockIndex = SgUpcWaitStatement::pools.size();
  119266           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcWaitStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcWaitStatement);
  119267             : 
  119268           2 :     while ( (blockIndex * SgUpcWaitStatement::pool_size) < newPoolSize)
  119269             :       {
  119270             : #if ROSE_ALLOC_TRACE
  119271             :         if (blockIndex > 0) {
  119272             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcWaitStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcWaitStatement) = %" PRIuPTR " SgUpcWaitStatement::pool_size = %d \n",
  119273             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcWaitStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcWaitStatement),SgUpcWaitStatement::pool_size);
  119274             :         }
  119275             : #endif
  119276             : 
  119277           0 :         SgUpcWaitStatement * pointer = (SgUpcWaitStatement*) ROSE_MALLOC ( SgUpcWaitStatement::pool_size * sizeof(SgUpcWaitStatement) );
  119278           0 :         assert( pointer != NULL );
  119279             : #if ROSE_ALLOC_MEMSET == 1
  119280             :         memset(pointer, 0x00, SgUpcWaitStatement::pool_size * sizeof(SgUpcWaitStatement));
  119281             : #elif ROSE_ALLOC_MEMSET == 2
  119282             :         memset(pointer, 0xCC, SgUpcWaitStatement::pool_size * sizeof(SgUpcWaitStatement));
  119283             : #endif
  119284           0 :         SgUpcWaitStatement::pools.push_back( (unsigned char*)(pointer) );
  119285           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcWaitStatement::pool_size * sizeof(SgUpcWaitStatement), V_SgUpcWaitStatement ) );
  119286             : 
  119287           0 :         if ( SgUpcWaitStatement::next_node != NULL ) {
  119288           0 :           if ( blockIndex > 0 ) {
  119289           0 :             SgUpcWaitStatement * blkptr = (SgUpcWaitStatement*)(SgUpcWaitStatement::pools[blockIndex-1]);
  119290           0 :             blkptr[ SgUpcWaitStatement::pool_size - 1 ].set_freepointer(pointer);
  119291             :           }
  119292             :         } else {
  119293           0 :           SgUpcWaitStatement::next_node = pointer;
  119294             :         }
  119295             : 
  119296           0 :         for (unsigned i = 0; i < SgUpcWaitStatement::pool_size-1; ++i)
  119297             :            {
  119298           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  119299             :            }
  119300           0 :         pointer[ SgUpcWaitStatement::pool_size -1 ].set_freepointer(NULL);
  119301             : 
  119302           0 :         blockIndex++;
  119303             :       }
  119304           2 :   }
  119305             : 
  119306             : //############################################################################
  119307             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  119308             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  119309             :  * not compressed. However, that stuff is not yet implemented! 
  119310             :  */
  119311             : unsigned long
  119312           0 : SgUpcWaitStatement::getNumberOfLastValidPointer()
  119313             :    {
  119314           0 :       SgUpcWaitStatement* testPointer = (SgUpcWaitStatement*)(SgUpcWaitStatement::pools.back());
  119315           0 :       unsigned long localIndex = SgUpcWaitStatement::pool_size - 1;
  119316           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  119317             :          {
  119318           0 :            localIndex--;
  119319             :          }
  119320           0 :       return (localIndex + SgUpcWaitStatement::pool_size * (SgUpcWaitStatement::pools.size()-1));
  119321             :    }
  119322             : 
  119323             : //############################################################################
  119324             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  119325             :  * memory pool and initializes the data member in class SgUpcWaitStatementStroageClass
  119326             :  * from its counterpart of SgUpcWaitStatement. The return value is just for checking, 
  119327             :  * that the whole StorageClassArray is initialized!
  119328             :  */
  119329             : unsigned long
  119330           0 : SgUpcWaitStatement::initializeStorageClassArray( SgUpcWaitStatementStorageClass *storageArray )
  119331             :    {
  119332           0 :      unsigned long storageCounter = 0;
  119333           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcWaitStatement::pools.begin();
  119334           0 :      SgUpcWaitStatement* pointer = NULL;
  119335           0 :      while ( block != SgUpcWaitStatement::pools.end() ) {
  119336           0 :           pointer = (SgUpcWaitStatement*) (*block);
  119337           0 :           for ( unsigned i = 0; i < SgUpcWaitStatement::pool_size; ++i ) {
  119338           0 :                if ( pointer->get_freepointer() != NULL ) {
  119339           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  119340           0 :                  storageArray++;
  119341           0 :                  storageCounter++;
  119342             :                }
  119343           0 :                pointer++;
  119344             :              }
  119345           0 :            block++;
  119346             :         }
  119347           0 :      return storageCounter;
  119348             :    }
  119349             : 
  119350             : /* #line 119351 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  119351             : 
  119352             : 
  119353             : 
  119354             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  119355             : 
  119356             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  119357             : 
  119358             : //############################################################################
  119359             : /* JH (02/02/2006) Constructor of the IR node SgUpcBarrierStatement that takes its 
  119360             :  * corresponding StorageClass as parameter
  119361             :  */
  119362           0 : SgUpcBarrierStatement :: SgUpcBarrierStatement ( const SgUpcBarrierStatementStorageClass& storageSource )   : SgStatement (storageSource)
  119363             :    {
  119364             : 
  119365             : 
  119366             : /* #line 119367 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  119367             : 
  119368           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  119369           0 :      p_barrier_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_barrier_expression) );
  119370             : 
  119371             : 
  119372             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  119373             : 
  119374             : 
  119375           0 :    }
  119376             : 
  119377             : //############################################################################
  119378             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  119379             :  * within the working AST. 
  119380             :  */
  119381           0 : SgUpcBarrierStatement * SgUpcBarrierStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  119382           0 :      SgUpcBarrierStatement* returnPointer = NULL;
  119383           0 :      if ( globalIndex != 0 )
  119384             :         {
  119385             : 
  119386             : #if FILE_IO_EXTRA_CHECK
  119387           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcBarrierStatement ) ) <= globalIndex ) ;
  119388           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcBarrierStatement + 1 ) ) );
  119389             : #endif
  119390           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcBarrierStatement )  
  119391           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcBarrierStatement );
  119392           0 :           unsigned long positionInPool = localIndex % SgUpcBarrierStatement::pool_size;
  119393           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcBarrierStatement::pool_size;
  119394             : 
  119395             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  119396             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  119397             : 
  119398           0 :           returnPointer = &( ( (SgUpcBarrierStatement*)(SgUpcBarrierStatement::pools[memoryBlock]) ) [positionInPool]) ;
  119399             : 
  119400           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  119401             :         }
  119402           0 :      return returnPointer ;
  119403             :    }
  119404             : 
  119405             : //############################################################################
  119406             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  119407             :   for the AST with the index astIndex
  119408             : */
  119409           0 : SgUpcBarrierStatement * SgUpcBarrierStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  119410           0 :      SgUpcBarrierStatement* returnPointer = NULL;
  119411           0 :      if ( globalIndex != 0 )
  119412             :         {
  119413             : 
  119414             : #if FILE_IO_EXTRA_CHECK
  119415           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcBarrierStatement ) ) <= globalIndex ) ;
  119416           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcBarrierStatement + 1 ) ) );
  119417             : #endif
  119418           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcBarrierStatement )
  119419           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcBarrierStatement );
  119420           0 :           unsigned long positionInPool = localIndex % SgUpcBarrierStatement::pool_size ;
  119421           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcBarrierStatement::pool_size ;
  119422             : 
  119423             : #if FILE_IO_EXTRA_CHECK
  119424             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  119425             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  119426             : #endif
  119427             : 
  119428           0 :           returnPointer = &( ( (SgUpcBarrierStatement*)(SgUpcBarrierStatement::pools[memoryBlock]) ) [positionInPool]) ;
  119429             : 
  119430             : #if FILE_IO_EXTRA_CHECK
  119431           0 :           assert ( returnPointer != NULL ) ;
  119432             : #endif
  119433             :         }
  119434           0 :      return returnPointer ;
  119435             :    }
  119436             : 
  119437             : //############################################################################
  119438             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  119439             :  * pool size! We set for every valid object in the memory pool the freepointer
  119440             :  * to the global index and increase the global index afterwards. For all the 
  119441             :  * invalid objects (means address ranges within the memory pool that were not
  119442             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  119443             :  * distinguish valid from invalid objects! 
  119444             :  */
  119445             : unsigned long
  119446           5 : SgUpcBarrierStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  119447             :    {
  119448           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  119449           5 :      SgUpcBarrierStatement* pointer = NULL;
  119450           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  119451           5 :      std::vector < unsigned char* > :: const_iterator block;
  119452           5 :      for ( block = SgUpcBarrierStatement::pools.begin(); block != SgUpcBarrierStatement::pools.end() ; ++block )
  119453             :         {
  119454           0 :           pointer = (SgUpcBarrierStatement*)(*block);
  119455           0 :           for (unsigned i = 0; i < SgUpcBarrierStatement::pool_size; ++i )
  119456             :              {
  119457             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  119458             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  119459             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  119460             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  119461             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  119462             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  119463             :             // properly; so this will have to be checked next.
  119464             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  119465             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  119466           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  119467             :                   {
  119468           0 :                     pointer[i].set_freepointer((SgUpcBarrierStatement*)(globalIndex));
  119469           0 :                     globalIndex++;
  119470             :                   }
  119471             :                else
  119472             :                   {
  119473           0 :                     pointer[i].set_freepointer(NULL);
  119474             :                   }
  119475             :               }
  119476             :         }
  119477           5 :      return globalIndex;
  119478             :    }
  119479             : 
  119480             : //############################################################################
  119481             : // JH (01/14/2006)
  119482             : void
  119483           5 : SgUpcBarrierStatement::resetValidFreepointers( )
  119484             :    {
  119485           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  119486           5 :      SgUpcBarrierStatement* pointer = NULL;
  119487           5 :      std::vector < unsigned char* > :: const_iterator block;
  119488           5 :      SgUpcBarrierStatement* pointerOfLinkedList = NULL;
  119489           5 :      for ( block = SgUpcBarrierStatement::pools.begin(); block != SgUpcBarrierStatement::pools.end() ; ++block )
  119490             :         {
  119491           0 :           pointer = (SgUpcBarrierStatement*)(*block);
  119492           0 :           for (unsigned i = 0; i < SgUpcBarrierStatement::pool_size; ++i )
  119493             :              {
  119494             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  119495             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  119496             :             // memory blocks!.
  119497           0 :                if ( pointer[i].get_freepointer() != NULL )
  119498             :                   {
  119499           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  119500             :                   }
  119501             :                else
  119502             :                   {
  119503           0 :                     if ( pointerOfLinkedList == NULL )
  119504             :                        {
  119505           0 :                          SgUpcBarrierStatement::next_node = &(pointer[i]);
  119506             :                        }
  119507             :                     else
  119508             :                        {
  119509             :                       // printf ("In SgUpcBarrierStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  119510           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  119511             :                        }
  119512             :                     pointerOfLinkedList = &(pointer[i]);
  119513             :                   }
  119514             :               }
  119515             :         }
  119516             : 
  119517           5 :      if ( pointerOfLinkedList != NULL )
  119518             :         {
  119519             :        // printf ("In SgUpcBarrierStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  119520           0 :           pointerOfLinkedList->set_freepointer(NULL);
  119521             :        // DQ (6/6/2010): Temporary debugging...
  119522             :        //   ROSE_ASSERT(false);
  119523             :         }
  119524             : 
  119525           5 :      return ;
  119526             :    }
  119527             : 
  119528             : //############################################################################
  119529             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  119530             :  * within the memory pool and resets the freepointers, in order to achieve a 
  119531             :  * linked list, that has no jumps and starts at the beginning! This function 
  119532             :  * does not extend the memory pool, since we do not delete any memory blocks,
  119533             :  * but delete the valid objects.  
  119534             :  */
  119535             : void
  119536           0 : SgUpcBarrierStatement::clearMemoryPool( )
  119537             :    {
  119538             :   // printf ("Inside of SgUpcBarrierStatement::clearMemoryPool() \n");
  119539             : 
  119540           0 :      SgUpcBarrierStatement* pointer = NULL, *tempPointer = NULL;
  119541           0 :      std::vector < unsigned char* > :: const_iterator block;
  119542           0 :      if ( SgUpcBarrierStatement::pools.empty() == false )
  119543             :         {
  119544           0 :           block = SgUpcBarrierStatement::pools.begin() ;
  119545           0 :           SgUpcBarrierStatement::next_node = (SgUpcBarrierStatement*) (*block);
  119546             : 
  119547           0 :           while ( block != SgUpcBarrierStatement::pools.end() )
  119548             :              {
  119549           0 :                pointer = (SgUpcBarrierStatement*) (*block);
  119550           0 :                if ( tempPointer != NULL )
  119551             :                   {
  119552           0 :                     tempPointer->set_freepointer(pointer);
  119553             :                   }
  119554           0 :                for (unsigned i = 0; i < SgUpcBarrierStatement::pool_size - 1; ++i)
  119555             :                   {
  119556           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  119557             :                   }
  119558           0 :                 pointer[SgUpcBarrierStatement::pool_size-1].set_freepointer(NULL);
  119559           0 :                 tempPointer = &(pointer[SgUpcBarrierStatement::pool_size-1]);
  119560           0 :                 ++block;
  119561             :              }
  119562             :         }
  119563           0 :    }
  119564             : 
  119565           5 : void SgUpcBarrierStatement::deleteMemoryPool() {
  119566           5 :   for (auto p: SgUpcBarrierStatement::pools) {
  119567           0 :     ROSE_FREE(p);
  119568             :   }
  119569           5 :   SgUpcBarrierStatement::next_node = nullptr;
  119570           5 :   SgUpcBarrierStatement::pools.clear();
  119571           5 : }
  119572             : 
  119573             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  119574             : //                 reading multiple binary files to for a single AST.
  119575             : /////////// new version ////////////////////////////////
  119576             : //############################################################################
  119577             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  119578             : void
  119579           2 : SgUpcBarrierStatement::extendMemoryPoolForFileIO( )
  119580             :   {
  119581           2 :     size_t blockIndex = SgUpcBarrierStatement::pools.size();
  119582           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcBarrierStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcBarrierStatement);
  119583             : 
  119584           2 :     while ( (blockIndex * SgUpcBarrierStatement::pool_size) < newPoolSize)
  119585             :       {
  119586             : #if ROSE_ALLOC_TRACE
  119587             :         if (blockIndex > 0) {
  119588             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcBarrierStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcBarrierStatement) = %" PRIuPTR " SgUpcBarrierStatement::pool_size = %d \n",
  119589             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcBarrierStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcBarrierStatement),SgUpcBarrierStatement::pool_size);
  119590             :         }
  119591             : #endif
  119592             : 
  119593           0 :         SgUpcBarrierStatement * pointer = (SgUpcBarrierStatement*) ROSE_MALLOC ( SgUpcBarrierStatement::pool_size * sizeof(SgUpcBarrierStatement) );
  119594           0 :         assert( pointer != NULL );
  119595             : #if ROSE_ALLOC_MEMSET == 1
  119596             :         memset(pointer, 0x00, SgUpcBarrierStatement::pool_size * sizeof(SgUpcBarrierStatement));
  119597             : #elif ROSE_ALLOC_MEMSET == 2
  119598             :         memset(pointer, 0xCC, SgUpcBarrierStatement::pool_size * sizeof(SgUpcBarrierStatement));
  119599             : #endif
  119600           0 :         SgUpcBarrierStatement::pools.push_back( (unsigned char*)(pointer) );
  119601           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcBarrierStatement::pool_size * sizeof(SgUpcBarrierStatement), V_SgUpcBarrierStatement ) );
  119602             : 
  119603           0 :         if ( SgUpcBarrierStatement::next_node != NULL ) {
  119604           0 :           if ( blockIndex > 0 ) {
  119605           0 :             SgUpcBarrierStatement * blkptr = (SgUpcBarrierStatement*)(SgUpcBarrierStatement::pools[blockIndex-1]);
  119606           0 :             blkptr[ SgUpcBarrierStatement::pool_size - 1 ].set_freepointer(pointer);
  119607             :           }
  119608             :         } else {
  119609           0 :           SgUpcBarrierStatement::next_node = pointer;
  119610             :         }
  119611             : 
  119612           0 :         for (unsigned i = 0; i < SgUpcBarrierStatement::pool_size-1; ++i)
  119613             :            {
  119614           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  119615             :            }
  119616           0 :         pointer[ SgUpcBarrierStatement::pool_size -1 ].set_freepointer(NULL);
  119617             : 
  119618           0 :         blockIndex++;
  119619             :       }
  119620           2 :   }
  119621             : 
  119622             : //############################################################################
  119623             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  119624             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  119625             :  * not compressed. However, that stuff is not yet implemented! 
  119626             :  */
  119627             : unsigned long
  119628           0 : SgUpcBarrierStatement::getNumberOfLastValidPointer()
  119629             :    {
  119630           0 :       SgUpcBarrierStatement* testPointer = (SgUpcBarrierStatement*)(SgUpcBarrierStatement::pools.back());
  119631           0 :       unsigned long localIndex = SgUpcBarrierStatement::pool_size - 1;
  119632           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  119633             :          {
  119634           0 :            localIndex--;
  119635             :          }
  119636           0 :       return (localIndex + SgUpcBarrierStatement::pool_size * (SgUpcBarrierStatement::pools.size()-1));
  119637             :    }
  119638             : 
  119639             : //############################################################################
  119640             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  119641             :  * memory pool and initializes the data member in class SgUpcBarrierStatementStroageClass
  119642             :  * from its counterpart of SgUpcBarrierStatement. The return value is just for checking, 
  119643             :  * that the whole StorageClassArray is initialized!
  119644             :  */
  119645             : unsigned long
  119646           0 : SgUpcBarrierStatement::initializeStorageClassArray( SgUpcBarrierStatementStorageClass *storageArray )
  119647             :    {
  119648           0 :      unsigned long storageCounter = 0;
  119649           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcBarrierStatement::pools.begin();
  119650           0 :      SgUpcBarrierStatement* pointer = NULL;
  119651           0 :      while ( block != SgUpcBarrierStatement::pools.end() ) {
  119652           0 :           pointer = (SgUpcBarrierStatement*) (*block);
  119653           0 :           for ( unsigned i = 0; i < SgUpcBarrierStatement::pool_size; ++i ) {
  119654           0 :                if ( pointer->get_freepointer() != NULL ) {
  119655           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  119656           0 :                  storageArray++;
  119657           0 :                  storageCounter++;
  119658             :                }
  119659           0 :                pointer++;
  119660             :              }
  119661           0 :            block++;
  119662             :         }
  119663           0 :      return storageCounter;
  119664             :    }
  119665             : 
  119666             : /* #line 119667 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  119667             : 
  119668             : 
  119669             : 
  119670             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  119671             : 
  119672             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  119673             : 
  119674             : //############################################################################
  119675             : /* JH (02/02/2006) Constructor of the IR node SgUpcFenceStatement that takes its 
  119676             :  * corresponding StorageClass as parameter
  119677             :  */
  119678           0 : SgUpcFenceStatement :: SgUpcFenceStatement ( const SgUpcFenceStatementStorageClass& storageSource )   : SgStatement (storageSource)
  119679             :    {
  119680             : 
  119681             : 
  119682             : /* #line 119683 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  119683             : 
  119684           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  119685             : 
  119686             : 
  119687             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  119688             : 
  119689             : 
  119690           0 :    }
  119691             : 
  119692             : //############################################################################
  119693             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  119694             :  * within the working AST. 
  119695             :  */
  119696           0 : SgUpcFenceStatement * SgUpcFenceStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  119697           0 :      SgUpcFenceStatement* returnPointer = NULL;
  119698           0 :      if ( globalIndex != 0 )
  119699             :         {
  119700             : 
  119701             : #if FILE_IO_EXTRA_CHECK
  119702           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcFenceStatement ) ) <= globalIndex ) ;
  119703           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcFenceStatement + 1 ) ) );
  119704             : #endif
  119705           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcFenceStatement )  
  119706           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcFenceStatement );
  119707           0 :           unsigned long positionInPool = localIndex % SgUpcFenceStatement::pool_size;
  119708           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcFenceStatement::pool_size;
  119709             : 
  119710             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  119711             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  119712             : 
  119713           0 :           returnPointer = &( ( (SgUpcFenceStatement*)(SgUpcFenceStatement::pools[memoryBlock]) ) [positionInPool]) ;
  119714             : 
  119715           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  119716             :         }
  119717           0 :      return returnPointer ;
  119718             :    }
  119719             : 
  119720             : //############################################################################
  119721             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  119722             :   for the AST with the index astIndex
  119723             : */
  119724           0 : SgUpcFenceStatement * SgUpcFenceStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  119725           0 :      SgUpcFenceStatement* returnPointer = NULL;
  119726           0 :      if ( globalIndex != 0 )
  119727             :         {
  119728             : 
  119729             : #if FILE_IO_EXTRA_CHECK
  119730           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcFenceStatement ) ) <= globalIndex ) ;
  119731           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcFenceStatement + 1 ) ) );
  119732             : #endif
  119733           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcFenceStatement )
  119734           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcFenceStatement );
  119735           0 :           unsigned long positionInPool = localIndex % SgUpcFenceStatement::pool_size ;
  119736           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcFenceStatement::pool_size ;
  119737             : 
  119738             : #if FILE_IO_EXTRA_CHECK
  119739             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  119740             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  119741             : #endif
  119742             : 
  119743           0 :           returnPointer = &( ( (SgUpcFenceStatement*)(SgUpcFenceStatement::pools[memoryBlock]) ) [positionInPool]) ;
  119744             : 
  119745             : #if FILE_IO_EXTRA_CHECK
  119746           0 :           assert ( returnPointer != NULL ) ;
  119747             : #endif
  119748             :         }
  119749           0 :      return returnPointer ;
  119750             :    }
  119751             : 
  119752             : //############################################################################
  119753             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  119754             :  * pool size! We set for every valid object in the memory pool the freepointer
  119755             :  * to the global index and increase the global index afterwards. For all the 
  119756             :  * invalid objects (means address ranges within the memory pool that were not
  119757             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  119758             :  * distinguish valid from invalid objects! 
  119759             :  */
  119760             : unsigned long
  119761           5 : SgUpcFenceStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  119762             :    {
  119763           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  119764           5 :      SgUpcFenceStatement* pointer = NULL;
  119765           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  119766           5 :      std::vector < unsigned char* > :: const_iterator block;
  119767           5 :      for ( block = SgUpcFenceStatement::pools.begin(); block != SgUpcFenceStatement::pools.end() ; ++block )
  119768             :         {
  119769           0 :           pointer = (SgUpcFenceStatement*)(*block);
  119770           0 :           for (unsigned i = 0; i < SgUpcFenceStatement::pool_size; ++i )
  119771             :              {
  119772             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  119773             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  119774             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  119775             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  119776             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  119777             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  119778             :             // properly; so this will have to be checked next.
  119779             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  119780             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  119781           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  119782             :                   {
  119783           0 :                     pointer[i].set_freepointer((SgUpcFenceStatement*)(globalIndex));
  119784           0 :                     globalIndex++;
  119785             :                   }
  119786             :                else
  119787             :                   {
  119788           0 :                     pointer[i].set_freepointer(NULL);
  119789             :                   }
  119790             :               }
  119791             :         }
  119792           5 :      return globalIndex;
  119793             :    }
  119794             : 
  119795             : //############################################################################
  119796             : // JH (01/14/2006)
  119797             : void
  119798           5 : SgUpcFenceStatement::resetValidFreepointers( )
  119799             :    {
  119800           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  119801           5 :      SgUpcFenceStatement* pointer = NULL;
  119802           5 :      std::vector < unsigned char* > :: const_iterator block;
  119803           5 :      SgUpcFenceStatement* pointerOfLinkedList = NULL;
  119804           5 :      for ( block = SgUpcFenceStatement::pools.begin(); block != SgUpcFenceStatement::pools.end() ; ++block )
  119805             :         {
  119806           0 :           pointer = (SgUpcFenceStatement*)(*block);
  119807           0 :           for (unsigned i = 0; i < SgUpcFenceStatement::pool_size; ++i )
  119808             :              {
  119809             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  119810             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  119811             :             // memory blocks!.
  119812           0 :                if ( pointer[i].get_freepointer() != NULL )
  119813             :                   {
  119814           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  119815             :                   }
  119816             :                else
  119817             :                   {
  119818           0 :                     if ( pointerOfLinkedList == NULL )
  119819             :                        {
  119820           0 :                          SgUpcFenceStatement::next_node = &(pointer[i]);
  119821             :                        }
  119822             :                     else
  119823             :                        {
  119824             :                       // printf ("In SgUpcFenceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  119825           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  119826             :                        }
  119827             :                     pointerOfLinkedList = &(pointer[i]);
  119828             :                   }
  119829             :               }
  119830             :         }
  119831             : 
  119832           5 :      if ( pointerOfLinkedList != NULL )
  119833             :         {
  119834             :        // printf ("In SgUpcFenceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  119835           0 :           pointerOfLinkedList->set_freepointer(NULL);
  119836             :        // DQ (6/6/2010): Temporary debugging...
  119837             :        //   ROSE_ASSERT(false);
  119838             :         }
  119839             : 
  119840           5 :      return ;
  119841             :    }
  119842             : 
  119843             : //############################################################################
  119844             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  119845             :  * within the memory pool and resets the freepointers, in order to achieve a 
  119846             :  * linked list, that has no jumps and starts at the beginning! This function 
  119847             :  * does not extend the memory pool, since we do not delete any memory blocks,
  119848             :  * but delete the valid objects.  
  119849             :  */
  119850             : void
  119851           0 : SgUpcFenceStatement::clearMemoryPool( )
  119852             :    {
  119853             :   // printf ("Inside of SgUpcFenceStatement::clearMemoryPool() \n");
  119854             : 
  119855           0 :      SgUpcFenceStatement* pointer = NULL, *tempPointer = NULL;
  119856           0 :      std::vector < unsigned char* > :: const_iterator block;
  119857           0 :      if ( SgUpcFenceStatement::pools.empty() == false )
  119858             :         {
  119859           0 :           block = SgUpcFenceStatement::pools.begin() ;
  119860           0 :           SgUpcFenceStatement::next_node = (SgUpcFenceStatement*) (*block);
  119861             : 
  119862           0 :           while ( block != SgUpcFenceStatement::pools.end() )
  119863             :              {
  119864           0 :                pointer = (SgUpcFenceStatement*) (*block);
  119865           0 :                if ( tempPointer != NULL )
  119866             :                   {
  119867           0 :                     tempPointer->set_freepointer(pointer);
  119868             :                   }
  119869           0 :                for (unsigned i = 0; i < SgUpcFenceStatement::pool_size - 1; ++i)
  119870             :                   {
  119871           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  119872             :                   }
  119873           0 :                 pointer[SgUpcFenceStatement::pool_size-1].set_freepointer(NULL);
  119874           0 :                 tempPointer = &(pointer[SgUpcFenceStatement::pool_size-1]);
  119875           0 :                 ++block;
  119876             :              }
  119877             :         }
  119878           0 :    }
  119879             : 
  119880           5 : void SgUpcFenceStatement::deleteMemoryPool() {
  119881           5 :   for (auto p: SgUpcFenceStatement::pools) {
  119882           0 :     ROSE_FREE(p);
  119883             :   }
  119884           5 :   SgUpcFenceStatement::next_node = nullptr;
  119885           5 :   SgUpcFenceStatement::pools.clear();
  119886           5 : }
  119887             : 
  119888             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  119889             : //                 reading multiple binary files to for a single AST.
  119890             : /////////// new version ////////////////////////////////
  119891             : //############################################################################
  119892             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  119893             : void
  119894           2 : SgUpcFenceStatement::extendMemoryPoolForFileIO( )
  119895             :   {
  119896           2 :     size_t blockIndex = SgUpcFenceStatement::pools.size();
  119897           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcFenceStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcFenceStatement);
  119898             : 
  119899           2 :     while ( (blockIndex * SgUpcFenceStatement::pool_size) < newPoolSize)
  119900             :       {
  119901             : #if ROSE_ALLOC_TRACE
  119902             :         if (blockIndex > 0) {
  119903             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcFenceStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcFenceStatement) = %" PRIuPTR " SgUpcFenceStatement::pool_size = %d \n",
  119904             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcFenceStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcFenceStatement),SgUpcFenceStatement::pool_size);
  119905             :         }
  119906             : #endif
  119907             : 
  119908           0 :         SgUpcFenceStatement * pointer = (SgUpcFenceStatement*) ROSE_MALLOC ( SgUpcFenceStatement::pool_size * sizeof(SgUpcFenceStatement) );
  119909           0 :         assert( pointer != NULL );
  119910             : #if ROSE_ALLOC_MEMSET == 1
  119911             :         memset(pointer, 0x00, SgUpcFenceStatement::pool_size * sizeof(SgUpcFenceStatement));
  119912             : #elif ROSE_ALLOC_MEMSET == 2
  119913             :         memset(pointer, 0xCC, SgUpcFenceStatement::pool_size * sizeof(SgUpcFenceStatement));
  119914             : #endif
  119915           0 :         SgUpcFenceStatement::pools.push_back( (unsigned char*)(pointer) );
  119916           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcFenceStatement::pool_size * sizeof(SgUpcFenceStatement), V_SgUpcFenceStatement ) );
  119917             : 
  119918           0 :         if ( SgUpcFenceStatement::next_node != NULL ) {
  119919           0 :           if ( blockIndex > 0 ) {
  119920           0 :             SgUpcFenceStatement * blkptr = (SgUpcFenceStatement*)(SgUpcFenceStatement::pools[blockIndex-1]);
  119921           0 :             blkptr[ SgUpcFenceStatement::pool_size - 1 ].set_freepointer(pointer);
  119922             :           }
  119923             :         } else {
  119924           0 :           SgUpcFenceStatement::next_node = pointer;
  119925             :         }
  119926             : 
  119927           0 :         for (unsigned i = 0; i < SgUpcFenceStatement::pool_size-1; ++i)
  119928             :            {
  119929           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  119930             :            }
  119931           0 :         pointer[ SgUpcFenceStatement::pool_size -1 ].set_freepointer(NULL);
  119932             : 
  119933           0 :         blockIndex++;
  119934             :       }
  119935           2 :   }
  119936             : 
  119937             : //############################################################################
  119938             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  119939             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  119940             :  * not compressed. However, that stuff is not yet implemented! 
  119941             :  */
  119942             : unsigned long
  119943           0 : SgUpcFenceStatement::getNumberOfLastValidPointer()
  119944             :    {
  119945           0 :       SgUpcFenceStatement* testPointer = (SgUpcFenceStatement*)(SgUpcFenceStatement::pools.back());
  119946           0 :       unsigned long localIndex = SgUpcFenceStatement::pool_size - 1;
  119947           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  119948             :          {
  119949           0 :            localIndex--;
  119950             :          }
  119951           0 :       return (localIndex + SgUpcFenceStatement::pool_size * (SgUpcFenceStatement::pools.size()-1));
  119952             :    }
  119953             : 
  119954             : //############################################################################
  119955             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  119956             :  * memory pool and initializes the data member in class SgUpcFenceStatementStroageClass
  119957             :  * from its counterpart of SgUpcFenceStatement. The return value is just for checking, 
  119958             :  * that the whole StorageClassArray is initialized!
  119959             :  */
  119960             : unsigned long
  119961           0 : SgUpcFenceStatement::initializeStorageClassArray( SgUpcFenceStatementStorageClass *storageArray )
  119962             :    {
  119963           0 :      unsigned long storageCounter = 0;
  119964           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcFenceStatement::pools.begin();
  119965           0 :      SgUpcFenceStatement* pointer = NULL;
  119966           0 :      while ( block != SgUpcFenceStatement::pools.end() ) {
  119967           0 :           pointer = (SgUpcFenceStatement*) (*block);
  119968           0 :           for ( unsigned i = 0; i < SgUpcFenceStatement::pool_size; ++i ) {
  119969           0 :                if ( pointer->get_freepointer() != NULL ) {
  119970           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  119971           0 :                  storageArray++;
  119972           0 :                  storageCounter++;
  119973             :                }
  119974           0 :                pointer++;
  119975             :              }
  119976           0 :            block++;
  119977             :         }
  119978           0 :      return storageCounter;
  119979             :    }
  119980             : 
  119981             : /* #line 119982 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  119982             : 
  119983             : 
  119984             : 
  119985             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  119986             : 
  119987             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  119988             : 
  119989             : //############################################################################
  119990             : /* JH (02/02/2006) Constructor of the IR node SgUpirBaseStatement that takes its 
  119991             :  * corresponding StorageClass as parameter
  119992             :  */
  119993           0 : SgUpirBaseStatement :: SgUpirBaseStatement ( const SgUpirBaseStatementStorageClass& storageSource )   : SgStatement (storageSource)
  119994             :    {
  119995             : 
  119996             : 
  119997             : /* #line 119998 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  119998             : 
  119999           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  120000           0 :      p_upir_parent =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_upir_parent) );
  120001           0 :      p_upir_children = storageSource.storageOf_upir_children.rebuildDataStoredInEasyStorageClass() ;
  120002           0 :      SgStatementPtrList::iterator i_upir_children = p_upir_children.begin() ; 
  120003           0 :      for ( ; i_upir_children != p_upir_children.end(); ++i_upir_children ) 
  120004             :         {
  120005           0 :           (*i_upir_children) = (SgStatementPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_upir_children) ) );
  120006             :         }
  120007             : 
  120008             : 
  120009             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  120010             : 
  120011             : 
  120012           0 :    }
  120013             : 
  120014             : //############################################################################
  120015             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  120016             :  * within the working AST. 
  120017             :  */
  120018           0 : SgUpirBaseStatement * SgUpirBaseStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  120019           0 :      SgUpirBaseStatement* returnPointer = NULL;
  120020           0 :      if ( globalIndex != 0 )
  120021             :         {
  120022             : 
  120023             : #if FILE_IO_EXTRA_CHECK
  120024           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirBaseStatement ) ) <= globalIndex ) ;
  120025           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirBaseStatement + 1 ) ) );
  120026             : #endif
  120027           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirBaseStatement )  
  120028           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirBaseStatement );
  120029           0 :           unsigned long positionInPool = localIndex % SgUpirBaseStatement::pool_size;
  120030           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirBaseStatement::pool_size;
  120031             : 
  120032             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  120033             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  120034             : 
  120035           0 :           returnPointer = &( ( (SgUpirBaseStatement*)(SgUpirBaseStatement::pools[memoryBlock]) ) [positionInPool]) ;
  120036             : 
  120037           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  120038             :         }
  120039           0 :      return returnPointer ;
  120040             :    }
  120041             : 
  120042             : //############################################################################
  120043             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  120044             :   for the AST with the index astIndex
  120045             : */
  120046           0 : SgUpirBaseStatement * SgUpirBaseStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  120047           0 :      SgUpirBaseStatement* returnPointer = NULL;
  120048           0 :      if ( globalIndex != 0 )
  120049             :         {
  120050             : 
  120051             : #if FILE_IO_EXTRA_CHECK
  120052           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirBaseStatement ) ) <= globalIndex ) ;
  120053           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirBaseStatement + 1 ) ) );
  120054             : #endif
  120055           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirBaseStatement )
  120056           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirBaseStatement );
  120057           0 :           unsigned long positionInPool = localIndex % SgUpirBaseStatement::pool_size ;
  120058           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirBaseStatement::pool_size ;
  120059             : 
  120060             : #if FILE_IO_EXTRA_CHECK
  120061             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  120062             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  120063             : #endif
  120064             : 
  120065           0 :           returnPointer = &( ( (SgUpirBaseStatement*)(SgUpirBaseStatement::pools[memoryBlock]) ) [positionInPool]) ;
  120066             : 
  120067             : #if FILE_IO_EXTRA_CHECK
  120068           0 :           assert ( returnPointer != NULL ) ;
  120069             : #endif
  120070             :         }
  120071           0 :      return returnPointer ;
  120072             :    }
  120073             : 
  120074             : //############################################################################
  120075             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  120076             :  * pool size! We set for every valid object in the memory pool the freepointer
  120077             :  * to the global index and increase the global index afterwards. For all the 
  120078             :  * invalid objects (means address ranges within the memory pool that were not
  120079             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  120080             :  * distinguish valid from invalid objects! 
  120081             :  */
  120082             : unsigned long
  120083           5 : SgUpirBaseStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  120084             :    {
  120085           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  120086           5 :      SgUpirBaseStatement* pointer = NULL;
  120087           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  120088           5 :      std::vector < unsigned char* > :: const_iterator block;
  120089           5 :      for ( block = SgUpirBaseStatement::pools.begin(); block != SgUpirBaseStatement::pools.end() ; ++block )
  120090             :         {
  120091           0 :           pointer = (SgUpirBaseStatement*)(*block);
  120092           0 :           for (unsigned i = 0; i < SgUpirBaseStatement::pool_size; ++i )
  120093             :              {
  120094             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  120095             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  120096             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  120097             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  120098             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  120099             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  120100             :             // properly; so this will have to be checked next.
  120101             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  120102             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  120103           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  120104             :                   {
  120105           0 :                     pointer[i].set_freepointer((SgUpirBaseStatement*)(globalIndex));
  120106           0 :                     globalIndex++;
  120107             :                   }
  120108             :                else
  120109             :                   {
  120110           0 :                     pointer[i].set_freepointer(NULL);
  120111             :                   }
  120112             :               }
  120113             :         }
  120114           5 :      return globalIndex;
  120115             :    }
  120116             : 
  120117             : //############################################################################
  120118             : // JH (01/14/2006)
  120119             : void
  120120           5 : SgUpirBaseStatement::resetValidFreepointers( )
  120121             :    {
  120122           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  120123           5 :      SgUpirBaseStatement* pointer = NULL;
  120124           5 :      std::vector < unsigned char* > :: const_iterator block;
  120125           5 :      SgUpirBaseStatement* pointerOfLinkedList = NULL;
  120126           5 :      for ( block = SgUpirBaseStatement::pools.begin(); block != SgUpirBaseStatement::pools.end() ; ++block )
  120127             :         {
  120128           0 :           pointer = (SgUpirBaseStatement*)(*block);
  120129           0 :           for (unsigned i = 0; i < SgUpirBaseStatement::pool_size; ++i )
  120130             :              {
  120131             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  120132             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  120133             :             // memory blocks!.
  120134           0 :                if ( pointer[i].get_freepointer() != NULL )
  120135             :                   {
  120136           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  120137             :                   }
  120138             :                else
  120139             :                   {
  120140           0 :                     if ( pointerOfLinkedList == NULL )
  120141             :                        {
  120142           0 :                          SgUpirBaseStatement::next_node = &(pointer[i]);
  120143             :                        }
  120144             :                     else
  120145             :                        {
  120146             :                       // printf ("In SgUpirBaseStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  120147           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  120148             :                        }
  120149             :                     pointerOfLinkedList = &(pointer[i]);
  120150             :                   }
  120151             :               }
  120152             :         }
  120153             : 
  120154           5 :      if ( pointerOfLinkedList != NULL )
  120155             :         {
  120156             :        // printf ("In SgUpirBaseStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  120157           0 :           pointerOfLinkedList->set_freepointer(NULL);
  120158             :        // DQ (6/6/2010): Temporary debugging...
  120159             :        //   ROSE_ASSERT(false);
  120160             :         }
  120161             : 
  120162           5 :      return ;
  120163             :    }
  120164             : 
  120165             : //############################################################################
  120166             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  120167             :  * within the memory pool and resets the freepointers, in order to achieve a 
  120168             :  * linked list, that has no jumps and starts at the beginning! This function 
  120169             :  * does not extend the memory pool, since we do not delete any memory blocks,
  120170             :  * but delete the valid objects.  
  120171             :  */
  120172             : void
  120173           0 : SgUpirBaseStatement::clearMemoryPool( )
  120174             :    {
  120175             :   // printf ("Inside of SgUpirBaseStatement::clearMemoryPool() \n");
  120176             : 
  120177           0 :      SgUpirBaseStatement* pointer = NULL, *tempPointer = NULL;
  120178           0 :      std::vector < unsigned char* > :: const_iterator block;
  120179           0 :      if ( SgUpirBaseStatement::pools.empty() == false )
  120180             :         {
  120181           0 :           block = SgUpirBaseStatement::pools.begin() ;
  120182           0 :           SgUpirBaseStatement::next_node = (SgUpirBaseStatement*) (*block);
  120183             : 
  120184           0 :           while ( block != SgUpirBaseStatement::pools.end() )
  120185             :              {
  120186           0 :                pointer = (SgUpirBaseStatement*) (*block);
  120187           0 :                if ( tempPointer != NULL )
  120188             :                   {
  120189           0 :                     tempPointer->set_freepointer(pointer);
  120190             :                   }
  120191           0 :                for (unsigned i = 0; i < SgUpirBaseStatement::pool_size - 1; ++i)
  120192             :                   {
  120193           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  120194             :                   }
  120195           0 :                 pointer[SgUpirBaseStatement::pool_size-1].set_freepointer(NULL);
  120196           0 :                 tempPointer = &(pointer[SgUpirBaseStatement::pool_size-1]);
  120197           0 :                 ++block;
  120198             :              }
  120199             :         }
  120200           0 :    }
  120201             : 
  120202           5 : void SgUpirBaseStatement::deleteMemoryPool() {
  120203           5 :   for (auto p: SgUpirBaseStatement::pools) {
  120204           0 :     ROSE_FREE(p);
  120205             :   }
  120206           5 :   SgUpirBaseStatement::next_node = nullptr;
  120207           5 :   SgUpirBaseStatement::pools.clear();
  120208           5 : }
  120209             : 
  120210             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  120211             : //                 reading multiple binary files to for a single AST.
  120212             : /////////// new version ////////////////////////////////
  120213             : //############################################################################
  120214             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  120215             : void
  120216           2 : SgUpirBaseStatement::extendMemoryPoolForFileIO( )
  120217             :   {
  120218           2 :     size_t blockIndex = SgUpirBaseStatement::pools.size();
  120219           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBaseStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBaseStatement);
  120220             : 
  120221           2 :     while ( (blockIndex * SgUpirBaseStatement::pool_size) < newPoolSize)
  120222             :       {
  120223             : #if ROSE_ALLOC_TRACE
  120224             :         if (blockIndex > 0) {
  120225             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBaseStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBaseStatement) = %" PRIuPTR " SgUpirBaseStatement::pool_size = %d \n",
  120226             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBaseStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBaseStatement),SgUpirBaseStatement::pool_size);
  120227             :         }
  120228             : #endif
  120229             : 
  120230           0 :         SgUpirBaseStatement * pointer = (SgUpirBaseStatement*) ROSE_MALLOC ( SgUpirBaseStatement::pool_size * sizeof(SgUpirBaseStatement) );
  120231           0 :         assert( pointer != NULL );
  120232             : #if ROSE_ALLOC_MEMSET == 1
  120233             :         memset(pointer, 0x00, SgUpirBaseStatement::pool_size * sizeof(SgUpirBaseStatement));
  120234             : #elif ROSE_ALLOC_MEMSET == 2
  120235             :         memset(pointer, 0xCC, SgUpirBaseStatement::pool_size * sizeof(SgUpirBaseStatement));
  120236             : #endif
  120237           0 :         SgUpirBaseStatement::pools.push_back( (unsigned char*)(pointer) );
  120238           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirBaseStatement::pool_size * sizeof(SgUpirBaseStatement), V_SgUpirBaseStatement ) );
  120239             : 
  120240           0 :         if ( SgUpirBaseStatement::next_node != NULL ) {
  120241           0 :           if ( blockIndex > 0 ) {
  120242           0 :             SgUpirBaseStatement * blkptr = (SgUpirBaseStatement*)(SgUpirBaseStatement::pools[blockIndex-1]);
  120243           0 :             blkptr[ SgUpirBaseStatement::pool_size - 1 ].set_freepointer(pointer);
  120244             :           }
  120245             :         } else {
  120246           0 :           SgUpirBaseStatement::next_node = pointer;
  120247             :         }
  120248             : 
  120249           0 :         for (unsigned i = 0; i < SgUpirBaseStatement::pool_size-1; ++i)
  120250             :            {
  120251           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  120252             :            }
  120253           0 :         pointer[ SgUpirBaseStatement::pool_size -1 ].set_freepointer(NULL);
  120254             : 
  120255           0 :         blockIndex++;
  120256             :       }
  120257           2 :   }
  120258             : 
  120259             : //############################################################################
  120260             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  120261             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  120262             :  * not compressed. However, that stuff is not yet implemented! 
  120263             :  */
  120264             : unsigned long
  120265           0 : SgUpirBaseStatement::getNumberOfLastValidPointer()
  120266             :    {
  120267           0 :       SgUpirBaseStatement* testPointer = (SgUpirBaseStatement*)(SgUpirBaseStatement::pools.back());
  120268           0 :       unsigned long localIndex = SgUpirBaseStatement::pool_size - 1;
  120269           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  120270             :          {
  120271           0 :            localIndex--;
  120272             :          }
  120273           0 :       return (localIndex + SgUpirBaseStatement::pool_size * (SgUpirBaseStatement::pools.size()-1));
  120274             :    }
  120275             : 
  120276             : //############################################################################
  120277             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  120278             :  * memory pool and initializes the data member in class SgUpirBaseStatementStroageClass
  120279             :  * from its counterpart of SgUpirBaseStatement. The return value is just for checking, 
  120280             :  * that the whole StorageClassArray is initialized!
  120281             :  */
  120282             : unsigned long
  120283           0 : SgUpirBaseStatement::initializeStorageClassArray( SgUpirBaseStatementStorageClass *storageArray )
  120284             :    {
  120285           0 :      unsigned long storageCounter = 0;
  120286           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirBaseStatement::pools.begin();
  120287           0 :      SgUpirBaseStatement* pointer = NULL;
  120288           0 :      while ( block != SgUpirBaseStatement::pools.end() ) {
  120289           0 :           pointer = (SgUpirBaseStatement*) (*block);
  120290           0 :           for ( unsigned i = 0; i < SgUpirBaseStatement::pool_size; ++i ) {
  120291           0 :                if ( pointer->get_freepointer() != NULL ) {
  120292           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  120293           0 :                  storageArray++;
  120294           0 :                  storageCounter++;
  120295             :                }
  120296           0 :                pointer++;
  120297             :              }
  120298           0 :            block++;
  120299             :         }
  120300           0 :      return storageCounter;
  120301             :    }
  120302             : 
  120303             : /* #line 120304 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  120304             : 
  120305             : 
  120306             : 
  120307             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  120308             : 
  120309             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  120310             : 
  120311             : //############################################################################
  120312             : /* JH (02/02/2006) Constructor of the IR node SgOmpTaskyieldStatement that takes its 
  120313             :  * corresponding StorageClass as parameter
  120314             :  */
  120315           0 : SgOmpTaskyieldStatement :: SgOmpTaskyieldStatement ( const SgOmpTaskyieldStatementStorageClass& storageSource )   : SgUpirBaseStatement (storageSource)
  120316             :    {
  120317             : 
  120318             : 
  120319             : /* #line 120320 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  120320             : 
  120321           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  120322             : 
  120323             : 
  120324             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  120325             : 
  120326             : 
  120327           0 :    }
  120328             : 
  120329             : //############################################################################
  120330             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  120331             :  * within the working AST. 
  120332             :  */
  120333           0 : SgOmpTaskyieldStatement * SgOmpTaskyieldStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  120334           0 :      SgOmpTaskyieldStatement* returnPointer = NULL;
  120335           0 :      if ( globalIndex != 0 )
  120336             :         {
  120337             : 
  120338             : #if FILE_IO_EXTRA_CHECK
  120339           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTaskyieldStatement ) ) <= globalIndex ) ;
  120340           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskyieldStatement + 1 ) ) );
  120341             : #endif
  120342           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskyieldStatement )  
  120343           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTaskyieldStatement );
  120344           0 :           unsigned long positionInPool = localIndex % SgOmpTaskyieldStatement::pool_size;
  120345           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskyieldStatement::pool_size;
  120346             : 
  120347             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  120348             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  120349             : 
  120350           0 :           returnPointer = &( ( (SgOmpTaskyieldStatement*)(SgOmpTaskyieldStatement::pools[memoryBlock]) ) [positionInPool]) ;
  120351             : 
  120352           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  120353             :         }
  120354           0 :      return returnPointer ;
  120355             :    }
  120356             : 
  120357             : //############################################################################
  120358             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  120359             :   for the AST with the index astIndex
  120360             : */
  120361           0 : SgOmpTaskyieldStatement * SgOmpTaskyieldStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  120362           0 :      SgOmpTaskyieldStatement* returnPointer = NULL;
  120363           0 :      if ( globalIndex != 0 )
  120364             :         {
  120365             : 
  120366             : #if FILE_IO_EXTRA_CHECK
  120367           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTaskyieldStatement ) ) <= globalIndex ) ;
  120368           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskyieldStatement + 1 ) ) );
  120369             : #endif
  120370           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskyieldStatement )
  120371           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTaskyieldStatement );
  120372           0 :           unsigned long positionInPool = localIndex % SgOmpTaskyieldStatement::pool_size ;
  120373           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskyieldStatement::pool_size ;
  120374             : 
  120375             : #if FILE_IO_EXTRA_CHECK
  120376             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  120377             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  120378             : #endif
  120379             : 
  120380           0 :           returnPointer = &( ( (SgOmpTaskyieldStatement*)(SgOmpTaskyieldStatement::pools[memoryBlock]) ) [positionInPool]) ;
  120381             : 
  120382             : #if FILE_IO_EXTRA_CHECK
  120383           0 :           assert ( returnPointer != NULL ) ;
  120384             : #endif
  120385             :         }
  120386           0 :      return returnPointer ;
  120387             :    }
  120388             : 
  120389             : //############################################################################
  120390             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  120391             :  * pool size! We set for every valid object in the memory pool the freepointer
  120392             :  * to the global index and increase the global index afterwards. For all the 
  120393             :  * invalid objects (means address ranges within the memory pool that were not
  120394             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  120395             :  * distinguish valid from invalid objects! 
  120396             :  */
  120397             : unsigned long
  120398           5 : SgOmpTaskyieldStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  120399             :    {
  120400           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  120401           5 :      SgOmpTaskyieldStatement* pointer = NULL;
  120402           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  120403           5 :      std::vector < unsigned char* > :: const_iterator block;
  120404           5 :      for ( block = SgOmpTaskyieldStatement::pools.begin(); block != SgOmpTaskyieldStatement::pools.end() ; ++block )
  120405             :         {
  120406           0 :           pointer = (SgOmpTaskyieldStatement*)(*block);
  120407           0 :           for (unsigned i = 0; i < SgOmpTaskyieldStatement::pool_size; ++i )
  120408             :              {
  120409             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  120410             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  120411             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  120412             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  120413             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  120414             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  120415             :             // properly; so this will have to be checked next.
  120416             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  120417             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  120418           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  120419             :                   {
  120420           0 :                     pointer[i].set_freepointer((SgOmpTaskyieldStatement*)(globalIndex));
  120421           0 :                     globalIndex++;
  120422             :                   }
  120423             :                else
  120424             :                   {
  120425           0 :                     pointer[i].set_freepointer(NULL);
  120426             :                   }
  120427             :               }
  120428             :         }
  120429           5 :      return globalIndex;
  120430             :    }
  120431             : 
  120432             : //############################################################################
  120433             : // JH (01/14/2006)
  120434             : void
  120435           5 : SgOmpTaskyieldStatement::resetValidFreepointers( )
  120436             :    {
  120437           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  120438           5 :      SgOmpTaskyieldStatement* pointer = NULL;
  120439           5 :      std::vector < unsigned char* > :: const_iterator block;
  120440           5 :      SgOmpTaskyieldStatement* pointerOfLinkedList = NULL;
  120441           5 :      for ( block = SgOmpTaskyieldStatement::pools.begin(); block != SgOmpTaskyieldStatement::pools.end() ; ++block )
  120442             :         {
  120443           0 :           pointer = (SgOmpTaskyieldStatement*)(*block);
  120444           0 :           for (unsigned i = 0; i < SgOmpTaskyieldStatement::pool_size; ++i )
  120445             :              {
  120446             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  120447             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  120448             :             // memory blocks!.
  120449           0 :                if ( pointer[i].get_freepointer() != NULL )
  120450             :                   {
  120451           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  120452             :                   }
  120453             :                else
  120454             :                   {
  120455           0 :                     if ( pointerOfLinkedList == NULL )
  120456             :                        {
  120457           0 :                          SgOmpTaskyieldStatement::next_node = &(pointer[i]);
  120458             :                        }
  120459             :                     else
  120460             :                        {
  120461             :                       // printf ("In SgOmpTaskyieldStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  120462           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  120463             :                        }
  120464             :                     pointerOfLinkedList = &(pointer[i]);
  120465             :                   }
  120466             :               }
  120467             :         }
  120468             : 
  120469           5 :      if ( pointerOfLinkedList != NULL )
  120470             :         {
  120471             :        // printf ("In SgOmpTaskyieldStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  120472           0 :           pointerOfLinkedList->set_freepointer(NULL);
  120473             :        // DQ (6/6/2010): Temporary debugging...
  120474             :        //   ROSE_ASSERT(false);
  120475             :         }
  120476             : 
  120477           5 :      return ;
  120478             :    }
  120479             : 
  120480             : //############################################################################
  120481             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  120482             :  * within the memory pool and resets the freepointers, in order to achieve a 
  120483             :  * linked list, that has no jumps and starts at the beginning! This function 
  120484             :  * does not extend the memory pool, since we do not delete any memory blocks,
  120485             :  * but delete the valid objects.  
  120486             :  */
  120487             : void
  120488           0 : SgOmpTaskyieldStatement::clearMemoryPool( )
  120489             :    {
  120490             :   // printf ("Inside of SgOmpTaskyieldStatement::clearMemoryPool() \n");
  120491             : 
  120492           0 :      SgOmpTaskyieldStatement* pointer = NULL, *tempPointer = NULL;
  120493           0 :      std::vector < unsigned char* > :: const_iterator block;
  120494           0 :      if ( SgOmpTaskyieldStatement::pools.empty() == false )
  120495             :         {
  120496           0 :           block = SgOmpTaskyieldStatement::pools.begin() ;
  120497           0 :           SgOmpTaskyieldStatement::next_node = (SgOmpTaskyieldStatement*) (*block);
  120498             : 
  120499           0 :           while ( block != SgOmpTaskyieldStatement::pools.end() )
  120500             :              {
  120501           0 :                pointer = (SgOmpTaskyieldStatement*) (*block);
  120502           0 :                if ( tempPointer != NULL )
  120503             :                   {
  120504           0 :                     tempPointer->set_freepointer(pointer);
  120505             :                   }
  120506           0 :                for (unsigned i = 0; i < SgOmpTaskyieldStatement::pool_size - 1; ++i)
  120507             :                   {
  120508           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  120509             :                   }
  120510           0 :                 pointer[SgOmpTaskyieldStatement::pool_size-1].set_freepointer(NULL);
  120511           0 :                 tempPointer = &(pointer[SgOmpTaskyieldStatement::pool_size-1]);
  120512           0 :                 ++block;
  120513             :              }
  120514             :         }
  120515           0 :    }
  120516             : 
  120517           5 : void SgOmpTaskyieldStatement::deleteMemoryPool() {
  120518           5 :   for (auto p: SgOmpTaskyieldStatement::pools) {
  120519           0 :     ROSE_FREE(p);
  120520             :   }
  120521           5 :   SgOmpTaskyieldStatement::next_node = nullptr;
  120522           5 :   SgOmpTaskyieldStatement::pools.clear();
  120523           5 : }
  120524             : 
  120525             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  120526             : //                 reading multiple binary files to for a single AST.
  120527             : /////////// new version ////////////////////////////////
  120528             : //############################################################################
  120529             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  120530             : void
  120531           2 : SgOmpTaskyieldStatement::extendMemoryPoolForFileIO( )
  120532             :   {
  120533           2 :     size_t blockIndex = SgOmpTaskyieldStatement::pools.size();
  120534           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskyieldStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskyieldStatement);
  120535             : 
  120536           2 :     while ( (blockIndex * SgOmpTaskyieldStatement::pool_size) < newPoolSize)
  120537             :       {
  120538             : #if ROSE_ALLOC_TRACE
  120539             :         if (blockIndex > 0) {
  120540             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskyieldStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskyieldStatement) = %" PRIuPTR " SgOmpTaskyieldStatement::pool_size = %d \n",
  120541             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskyieldStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskyieldStatement),SgOmpTaskyieldStatement::pool_size);
  120542             :         }
  120543             : #endif
  120544             : 
  120545           0 :         SgOmpTaskyieldStatement * pointer = (SgOmpTaskyieldStatement*) ROSE_MALLOC ( SgOmpTaskyieldStatement::pool_size * sizeof(SgOmpTaskyieldStatement) );
  120546           0 :         assert( pointer != NULL );
  120547             : #if ROSE_ALLOC_MEMSET == 1
  120548             :         memset(pointer, 0x00, SgOmpTaskyieldStatement::pool_size * sizeof(SgOmpTaskyieldStatement));
  120549             : #elif ROSE_ALLOC_MEMSET == 2
  120550             :         memset(pointer, 0xCC, SgOmpTaskyieldStatement::pool_size * sizeof(SgOmpTaskyieldStatement));
  120551             : #endif
  120552           0 :         SgOmpTaskyieldStatement::pools.push_back( (unsigned char*)(pointer) );
  120553           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTaskyieldStatement::pool_size * sizeof(SgOmpTaskyieldStatement), V_SgOmpTaskyieldStatement ) );
  120554             : 
  120555           0 :         if ( SgOmpTaskyieldStatement::next_node != NULL ) {
  120556           0 :           if ( blockIndex > 0 ) {
  120557           0 :             SgOmpTaskyieldStatement * blkptr = (SgOmpTaskyieldStatement*)(SgOmpTaskyieldStatement::pools[blockIndex-1]);
  120558           0 :             blkptr[ SgOmpTaskyieldStatement::pool_size - 1 ].set_freepointer(pointer);
  120559             :           }
  120560             :         } else {
  120561           0 :           SgOmpTaskyieldStatement::next_node = pointer;
  120562             :         }
  120563             : 
  120564           0 :         for (unsigned i = 0; i < SgOmpTaskyieldStatement::pool_size-1; ++i)
  120565             :            {
  120566           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  120567             :            }
  120568           0 :         pointer[ SgOmpTaskyieldStatement::pool_size -1 ].set_freepointer(NULL);
  120569             : 
  120570           0 :         blockIndex++;
  120571             :       }
  120572           2 :   }
  120573             : 
  120574             : //############################################################################
  120575             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  120576             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  120577             :  * not compressed. However, that stuff is not yet implemented! 
  120578             :  */
  120579             : unsigned long
  120580           0 : SgOmpTaskyieldStatement::getNumberOfLastValidPointer()
  120581             :    {
  120582           0 :       SgOmpTaskyieldStatement* testPointer = (SgOmpTaskyieldStatement*)(SgOmpTaskyieldStatement::pools.back());
  120583           0 :       unsigned long localIndex = SgOmpTaskyieldStatement::pool_size - 1;
  120584           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  120585             :          {
  120586           0 :            localIndex--;
  120587             :          }
  120588           0 :       return (localIndex + SgOmpTaskyieldStatement::pool_size * (SgOmpTaskyieldStatement::pools.size()-1));
  120589             :    }
  120590             : 
  120591             : //############################################################################
  120592             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  120593             :  * memory pool and initializes the data member in class SgOmpTaskyieldStatementStroageClass
  120594             :  * from its counterpart of SgOmpTaskyieldStatement. The return value is just for checking, 
  120595             :  * that the whole StorageClassArray is initialized!
  120596             :  */
  120597             : unsigned long
  120598           0 : SgOmpTaskyieldStatement::initializeStorageClassArray( SgOmpTaskyieldStatementStorageClass *storageArray )
  120599             :    {
  120600           0 :      unsigned long storageCounter = 0;
  120601           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTaskyieldStatement::pools.begin();
  120602           0 :      SgOmpTaskyieldStatement* pointer = NULL;
  120603           0 :      while ( block != SgOmpTaskyieldStatement::pools.end() ) {
  120604           0 :           pointer = (SgOmpTaskyieldStatement*) (*block);
  120605           0 :           for ( unsigned i = 0; i < SgOmpTaskyieldStatement::pool_size; ++i ) {
  120606           0 :                if ( pointer->get_freepointer() != NULL ) {
  120607           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  120608           0 :                  storageArray++;
  120609           0 :                  storageCounter++;
  120610             :                }
  120611           0 :                pointer++;
  120612             :              }
  120613           0 :            block++;
  120614             :         }
  120615           0 :      return storageCounter;
  120616             :    }
  120617             : 
  120618             : /* #line 120619 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  120619             : 
  120620             : 
  120621             : 
  120622             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  120623             : 
  120624             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  120625             : 
  120626             : //############################################################################
  120627             : /* JH (02/02/2006) Constructor of the IR node SgOmpBarrierStatement that takes its 
  120628             :  * corresponding StorageClass as parameter
  120629             :  */
  120630           0 : SgOmpBarrierStatement :: SgOmpBarrierStatement ( const SgOmpBarrierStatementStorageClass& storageSource )   : SgUpirBaseStatement (storageSource)
  120631             :    {
  120632             : 
  120633             : 
  120634             : /* #line 120635 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  120635             : 
  120636           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  120637             : 
  120638             : 
  120639             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  120640             : 
  120641             : 
  120642           0 :    }
  120643             : 
  120644             : //############################################################################
  120645             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  120646             :  * within the working AST. 
  120647             :  */
  120648           0 : SgOmpBarrierStatement * SgOmpBarrierStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  120649           0 :      SgOmpBarrierStatement* returnPointer = NULL;
  120650           0 :      if ( globalIndex != 0 )
  120651             :         {
  120652             : 
  120653             : #if FILE_IO_EXTRA_CHECK
  120654           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpBarrierStatement ) ) <= globalIndex ) ;
  120655           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpBarrierStatement + 1 ) ) );
  120656             : #endif
  120657           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpBarrierStatement )  
  120658           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpBarrierStatement );
  120659           0 :           unsigned long positionInPool = localIndex % SgOmpBarrierStatement::pool_size;
  120660           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpBarrierStatement::pool_size;
  120661             : 
  120662             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  120663             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  120664             : 
  120665           0 :           returnPointer = &( ( (SgOmpBarrierStatement*)(SgOmpBarrierStatement::pools[memoryBlock]) ) [positionInPool]) ;
  120666             : 
  120667           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  120668             :         }
  120669           0 :      return returnPointer ;
  120670             :    }
  120671             : 
  120672             : //############################################################################
  120673             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  120674             :   for the AST with the index astIndex
  120675             : */
  120676           0 : SgOmpBarrierStatement * SgOmpBarrierStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  120677           0 :      SgOmpBarrierStatement* returnPointer = NULL;
  120678           0 :      if ( globalIndex != 0 )
  120679             :         {
  120680             : 
  120681             : #if FILE_IO_EXTRA_CHECK
  120682           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpBarrierStatement ) ) <= globalIndex ) ;
  120683           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpBarrierStatement + 1 ) ) );
  120684             : #endif
  120685           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpBarrierStatement )
  120686           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpBarrierStatement );
  120687           0 :           unsigned long positionInPool = localIndex % SgOmpBarrierStatement::pool_size ;
  120688           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpBarrierStatement::pool_size ;
  120689             : 
  120690             : #if FILE_IO_EXTRA_CHECK
  120691             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  120692             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  120693             : #endif
  120694             : 
  120695           0 :           returnPointer = &( ( (SgOmpBarrierStatement*)(SgOmpBarrierStatement::pools[memoryBlock]) ) [positionInPool]) ;
  120696             : 
  120697             : #if FILE_IO_EXTRA_CHECK
  120698           0 :           assert ( returnPointer != NULL ) ;
  120699             : #endif
  120700             :         }
  120701           0 :      return returnPointer ;
  120702             :    }
  120703             : 
  120704             : //############################################################################
  120705             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  120706             :  * pool size! We set for every valid object in the memory pool the freepointer
  120707             :  * to the global index and increase the global index afterwards. For all the 
  120708             :  * invalid objects (means address ranges within the memory pool that were not
  120709             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  120710             :  * distinguish valid from invalid objects! 
  120711             :  */
  120712             : unsigned long
  120713           5 : SgOmpBarrierStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  120714             :    {
  120715           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  120716           5 :      SgOmpBarrierStatement* pointer = NULL;
  120717           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  120718           5 :      std::vector < unsigned char* > :: const_iterator block;
  120719           5 :      for ( block = SgOmpBarrierStatement::pools.begin(); block != SgOmpBarrierStatement::pools.end() ; ++block )
  120720             :         {
  120721           0 :           pointer = (SgOmpBarrierStatement*)(*block);
  120722           0 :           for (unsigned i = 0; i < SgOmpBarrierStatement::pool_size; ++i )
  120723             :              {
  120724             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  120725             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  120726             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  120727             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  120728             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  120729             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  120730             :             // properly; so this will have to be checked next.
  120731             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  120732             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  120733           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  120734             :                   {
  120735           0 :                     pointer[i].set_freepointer((SgOmpBarrierStatement*)(globalIndex));
  120736           0 :                     globalIndex++;
  120737             :                   }
  120738             :                else
  120739             :                   {
  120740           0 :                     pointer[i].set_freepointer(NULL);
  120741             :                   }
  120742             :               }
  120743             :         }
  120744           5 :      return globalIndex;
  120745             :    }
  120746             : 
  120747             : //############################################################################
  120748             : // JH (01/14/2006)
  120749             : void
  120750           5 : SgOmpBarrierStatement::resetValidFreepointers( )
  120751             :    {
  120752           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  120753           5 :      SgOmpBarrierStatement* pointer = NULL;
  120754           5 :      std::vector < unsigned char* > :: const_iterator block;
  120755           5 :      SgOmpBarrierStatement* pointerOfLinkedList = NULL;
  120756           5 :      for ( block = SgOmpBarrierStatement::pools.begin(); block != SgOmpBarrierStatement::pools.end() ; ++block )
  120757             :         {
  120758           0 :           pointer = (SgOmpBarrierStatement*)(*block);
  120759           0 :           for (unsigned i = 0; i < SgOmpBarrierStatement::pool_size; ++i )
  120760             :              {
  120761             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  120762             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  120763             :             // memory blocks!.
  120764           0 :                if ( pointer[i].get_freepointer() != NULL )
  120765             :                   {
  120766           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  120767             :                   }
  120768             :                else
  120769             :                   {
  120770           0 :                     if ( pointerOfLinkedList == NULL )
  120771             :                        {
  120772           0 :                          SgOmpBarrierStatement::next_node = &(pointer[i]);
  120773             :                        }
  120774             :                     else
  120775             :                        {
  120776             :                       // printf ("In SgOmpBarrierStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  120777           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  120778             :                        }
  120779             :                     pointerOfLinkedList = &(pointer[i]);
  120780             :                   }
  120781             :               }
  120782             :         }
  120783             : 
  120784           5 :      if ( pointerOfLinkedList != NULL )
  120785             :         {
  120786             :        // printf ("In SgOmpBarrierStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  120787           0 :           pointerOfLinkedList->set_freepointer(NULL);
  120788             :        // DQ (6/6/2010): Temporary debugging...
  120789             :        //   ROSE_ASSERT(false);
  120790             :         }
  120791             : 
  120792           5 :      return ;
  120793             :    }
  120794             : 
  120795             : //############################################################################
  120796             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  120797             :  * within the memory pool and resets the freepointers, in order to achieve a 
  120798             :  * linked list, that has no jumps and starts at the beginning! This function 
  120799             :  * does not extend the memory pool, since we do not delete any memory blocks,
  120800             :  * but delete the valid objects.  
  120801             :  */
  120802             : void
  120803           0 : SgOmpBarrierStatement::clearMemoryPool( )
  120804             :    {
  120805             :   // printf ("Inside of SgOmpBarrierStatement::clearMemoryPool() \n");
  120806             : 
  120807           0 :      SgOmpBarrierStatement* pointer = NULL, *tempPointer = NULL;
  120808           0 :      std::vector < unsigned char* > :: const_iterator block;
  120809           0 :      if ( SgOmpBarrierStatement::pools.empty() == false )
  120810             :         {
  120811           0 :           block = SgOmpBarrierStatement::pools.begin() ;
  120812           0 :           SgOmpBarrierStatement::next_node = (SgOmpBarrierStatement*) (*block);
  120813             : 
  120814           0 :           while ( block != SgOmpBarrierStatement::pools.end() )
  120815             :              {
  120816           0 :                pointer = (SgOmpBarrierStatement*) (*block);
  120817           0 :                if ( tempPointer != NULL )
  120818             :                   {
  120819           0 :                     tempPointer->set_freepointer(pointer);
  120820             :                   }
  120821           0 :                for (unsigned i = 0; i < SgOmpBarrierStatement::pool_size - 1; ++i)
  120822             :                   {
  120823           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  120824             :                   }
  120825           0 :                 pointer[SgOmpBarrierStatement::pool_size-1].set_freepointer(NULL);
  120826           0 :                 tempPointer = &(pointer[SgOmpBarrierStatement::pool_size-1]);
  120827           0 :                 ++block;
  120828             :              }
  120829             :         }
  120830           0 :    }
  120831             : 
  120832           5 : void SgOmpBarrierStatement::deleteMemoryPool() {
  120833           5 :   for (auto p: SgOmpBarrierStatement::pools) {
  120834           0 :     ROSE_FREE(p);
  120835             :   }
  120836           5 :   SgOmpBarrierStatement::next_node = nullptr;
  120837           5 :   SgOmpBarrierStatement::pools.clear();
  120838           5 : }
  120839             : 
  120840             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  120841             : //                 reading multiple binary files to for a single AST.
  120842             : /////////// new version ////////////////////////////////
  120843             : //############################################################################
  120844             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  120845             : void
  120846           2 : SgOmpBarrierStatement::extendMemoryPoolForFileIO( )
  120847             :   {
  120848           2 :     size_t blockIndex = SgOmpBarrierStatement::pools.size();
  120849           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBarrierStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBarrierStatement);
  120850             : 
  120851           2 :     while ( (blockIndex * SgOmpBarrierStatement::pool_size) < newPoolSize)
  120852             :       {
  120853             : #if ROSE_ALLOC_TRACE
  120854             :         if (blockIndex > 0) {
  120855             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBarrierStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBarrierStatement) = %" PRIuPTR " SgOmpBarrierStatement::pool_size = %d \n",
  120856             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpBarrierStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpBarrierStatement),SgOmpBarrierStatement::pool_size);
  120857             :         }
  120858             : #endif
  120859             : 
  120860           0 :         SgOmpBarrierStatement * pointer = (SgOmpBarrierStatement*) ROSE_MALLOC ( SgOmpBarrierStatement::pool_size * sizeof(SgOmpBarrierStatement) );
  120861           0 :         assert( pointer != NULL );
  120862             : #if ROSE_ALLOC_MEMSET == 1
  120863             :         memset(pointer, 0x00, SgOmpBarrierStatement::pool_size * sizeof(SgOmpBarrierStatement));
  120864             : #elif ROSE_ALLOC_MEMSET == 2
  120865             :         memset(pointer, 0xCC, SgOmpBarrierStatement::pool_size * sizeof(SgOmpBarrierStatement));
  120866             : #endif
  120867           0 :         SgOmpBarrierStatement::pools.push_back( (unsigned char*)(pointer) );
  120868           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpBarrierStatement::pool_size * sizeof(SgOmpBarrierStatement), V_SgOmpBarrierStatement ) );
  120869             : 
  120870           0 :         if ( SgOmpBarrierStatement::next_node != NULL ) {
  120871           0 :           if ( blockIndex > 0 ) {
  120872           0 :             SgOmpBarrierStatement * blkptr = (SgOmpBarrierStatement*)(SgOmpBarrierStatement::pools[blockIndex-1]);
  120873           0 :             blkptr[ SgOmpBarrierStatement::pool_size - 1 ].set_freepointer(pointer);
  120874             :           }
  120875             :         } else {
  120876           0 :           SgOmpBarrierStatement::next_node = pointer;
  120877             :         }
  120878             : 
  120879           0 :         for (unsigned i = 0; i < SgOmpBarrierStatement::pool_size-1; ++i)
  120880             :            {
  120881           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  120882             :            }
  120883           0 :         pointer[ SgOmpBarrierStatement::pool_size -1 ].set_freepointer(NULL);
  120884             : 
  120885           0 :         blockIndex++;
  120886             :       }
  120887           2 :   }
  120888             : 
  120889             : //############################################################################
  120890             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  120891             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  120892             :  * not compressed. However, that stuff is not yet implemented! 
  120893             :  */
  120894             : unsigned long
  120895           0 : SgOmpBarrierStatement::getNumberOfLastValidPointer()
  120896             :    {
  120897           0 :       SgOmpBarrierStatement* testPointer = (SgOmpBarrierStatement*)(SgOmpBarrierStatement::pools.back());
  120898           0 :       unsigned long localIndex = SgOmpBarrierStatement::pool_size - 1;
  120899           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  120900             :          {
  120901           0 :            localIndex--;
  120902             :          }
  120903           0 :       return (localIndex + SgOmpBarrierStatement::pool_size * (SgOmpBarrierStatement::pools.size()-1));
  120904             :    }
  120905             : 
  120906             : //############################################################################
  120907             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  120908             :  * memory pool and initializes the data member in class SgOmpBarrierStatementStroageClass
  120909             :  * from its counterpart of SgOmpBarrierStatement. The return value is just for checking, 
  120910             :  * that the whole StorageClassArray is initialized!
  120911             :  */
  120912             : unsigned long
  120913           0 : SgOmpBarrierStatement::initializeStorageClassArray( SgOmpBarrierStatementStorageClass *storageArray )
  120914             :    {
  120915           0 :      unsigned long storageCounter = 0;
  120916           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpBarrierStatement::pools.begin();
  120917           0 :      SgOmpBarrierStatement* pointer = NULL;
  120918           0 :      while ( block != SgOmpBarrierStatement::pools.end() ) {
  120919           0 :           pointer = (SgOmpBarrierStatement*) (*block);
  120920           0 :           for ( unsigned i = 0; i < SgOmpBarrierStatement::pool_size; ++i ) {
  120921           0 :                if ( pointer->get_freepointer() != NULL ) {
  120922           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  120923           0 :                  storageArray++;
  120924           0 :                  storageCounter++;
  120925             :                }
  120926           0 :                pointer++;
  120927             :              }
  120928           0 :            block++;
  120929             :         }
  120930           0 :      return storageCounter;
  120931             :    }
  120932             : 
  120933             : /* #line 120934 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  120934             : 
  120935             : 
  120936             : 
  120937             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  120938             : 
  120939             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  120940             : 
  120941             : //############################################################################
  120942             : /* JH (02/02/2006) Constructor of the IR node SgUpirBodyStatement that takes its 
  120943             :  * corresponding StorageClass as parameter
  120944             :  */
  120945           0 : SgUpirBodyStatement :: SgUpirBodyStatement ( const SgUpirBodyStatementStorageClass& storageSource )   : SgUpirBaseStatement (storageSource)
  120946             :    {
  120947             : 
  120948             : 
  120949             : /* #line 120950 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  120950             : 
  120951           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  120952           0 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
  120953             : 
  120954             : 
  120955             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  120956             : 
  120957             : 
  120958           0 :    }
  120959             : 
  120960             : //############################################################################
  120961             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  120962             :  * within the working AST. 
  120963             :  */
  120964           0 : SgUpirBodyStatement * SgUpirBodyStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  120965           0 :      SgUpirBodyStatement* returnPointer = NULL;
  120966           0 :      if ( globalIndex != 0 )
  120967             :         {
  120968             : 
  120969             : #if FILE_IO_EXTRA_CHECK
  120970           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirBodyStatement ) ) <= globalIndex ) ;
  120971           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirBodyStatement + 1 ) ) );
  120972             : #endif
  120973           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirBodyStatement )  
  120974           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirBodyStatement );
  120975           0 :           unsigned long positionInPool = localIndex % SgUpirBodyStatement::pool_size;
  120976           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirBodyStatement::pool_size;
  120977             : 
  120978             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  120979             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  120980             : 
  120981           0 :           returnPointer = &( ( (SgUpirBodyStatement*)(SgUpirBodyStatement::pools[memoryBlock]) ) [positionInPool]) ;
  120982             : 
  120983           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  120984             :         }
  120985           0 :      return returnPointer ;
  120986             :    }
  120987             : 
  120988             : //############################################################################
  120989             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  120990             :   for the AST with the index astIndex
  120991             : */
  120992           0 : SgUpirBodyStatement * SgUpirBodyStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  120993           0 :      SgUpirBodyStatement* returnPointer = NULL;
  120994           0 :      if ( globalIndex != 0 )
  120995             :         {
  120996             : 
  120997             : #if FILE_IO_EXTRA_CHECK
  120998           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirBodyStatement ) ) <= globalIndex ) ;
  120999           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirBodyStatement + 1 ) ) );
  121000             : #endif
  121001           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirBodyStatement )
  121002           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirBodyStatement );
  121003           0 :           unsigned long positionInPool = localIndex % SgUpirBodyStatement::pool_size ;
  121004           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirBodyStatement::pool_size ;
  121005             : 
  121006             : #if FILE_IO_EXTRA_CHECK
  121007             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  121008             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  121009             : #endif
  121010             : 
  121011           0 :           returnPointer = &( ( (SgUpirBodyStatement*)(SgUpirBodyStatement::pools[memoryBlock]) ) [positionInPool]) ;
  121012             : 
  121013             : #if FILE_IO_EXTRA_CHECK
  121014           0 :           assert ( returnPointer != NULL ) ;
  121015             : #endif
  121016             :         }
  121017           0 :      return returnPointer ;
  121018             :    }
  121019             : 
  121020             : //############################################################################
  121021             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  121022             :  * pool size! We set for every valid object in the memory pool the freepointer
  121023             :  * to the global index and increase the global index afterwards. For all the 
  121024             :  * invalid objects (means address ranges within the memory pool that were not
  121025             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  121026             :  * distinguish valid from invalid objects! 
  121027             :  */
  121028             : unsigned long
  121029           5 : SgUpirBodyStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  121030             :    {
  121031           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  121032           5 :      SgUpirBodyStatement* pointer = NULL;
  121033           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  121034           5 :      std::vector < unsigned char* > :: const_iterator block;
  121035           5 :      for ( block = SgUpirBodyStatement::pools.begin(); block != SgUpirBodyStatement::pools.end() ; ++block )
  121036             :         {
  121037           0 :           pointer = (SgUpirBodyStatement*)(*block);
  121038           0 :           for (unsigned i = 0; i < SgUpirBodyStatement::pool_size; ++i )
  121039             :              {
  121040             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  121041             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  121042             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  121043             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  121044             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  121045             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  121046             :             // properly; so this will have to be checked next.
  121047             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  121048             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  121049           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  121050             :                   {
  121051           0 :                     pointer[i].set_freepointer((SgUpirBodyStatement*)(globalIndex));
  121052           0 :                     globalIndex++;
  121053             :                   }
  121054             :                else
  121055             :                   {
  121056           0 :                     pointer[i].set_freepointer(NULL);
  121057             :                   }
  121058             :               }
  121059             :         }
  121060           5 :      return globalIndex;
  121061             :    }
  121062             : 
  121063             : //############################################################################
  121064             : // JH (01/14/2006)
  121065             : void
  121066           5 : SgUpirBodyStatement::resetValidFreepointers( )
  121067             :    {
  121068           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  121069           5 :      SgUpirBodyStatement* pointer = NULL;
  121070           5 :      std::vector < unsigned char* > :: const_iterator block;
  121071           5 :      SgUpirBodyStatement* pointerOfLinkedList = NULL;
  121072           5 :      for ( block = SgUpirBodyStatement::pools.begin(); block != SgUpirBodyStatement::pools.end() ; ++block )
  121073             :         {
  121074           0 :           pointer = (SgUpirBodyStatement*)(*block);
  121075           0 :           for (unsigned i = 0; i < SgUpirBodyStatement::pool_size; ++i )
  121076             :              {
  121077             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  121078             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  121079             :             // memory blocks!.
  121080           0 :                if ( pointer[i].get_freepointer() != NULL )
  121081             :                   {
  121082           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  121083             :                   }
  121084             :                else
  121085             :                   {
  121086           0 :                     if ( pointerOfLinkedList == NULL )
  121087             :                        {
  121088           0 :                          SgUpirBodyStatement::next_node = &(pointer[i]);
  121089             :                        }
  121090             :                     else
  121091             :                        {
  121092             :                       // printf ("In SgUpirBodyStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  121093           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  121094             :                        }
  121095             :                     pointerOfLinkedList = &(pointer[i]);
  121096             :                   }
  121097             :               }
  121098             :         }
  121099             : 
  121100           5 :      if ( pointerOfLinkedList != NULL )
  121101             :         {
  121102             :        // printf ("In SgUpirBodyStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  121103           0 :           pointerOfLinkedList->set_freepointer(NULL);
  121104             :        // DQ (6/6/2010): Temporary debugging...
  121105             :        //   ROSE_ASSERT(false);
  121106             :         }
  121107             : 
  121108           5 :      return ;
  121109             :    }
  121110             : 
  121111             : //############################################################################
  121112             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  121113             :  * within the memory pool and resets the freepointers, in order to achieve a 
  121114             :  * linked list, that has no jumps and starts at the beginning! This function 
  121115             :  * does not extend the memory pool, since we do not delete any memory blocks,
  121116             :  * but delete the valid objects.  
  121117             :  */
  121118             : void
  121119           0 : SgUpirBodyStatement::clearMemoryPool( )
  121120             :    {
  121121             :   // printf ("Inside of SgUpirBodyStatement::clearMemoryPool() \n");
  121122             : 
  121123           0 :      SgUpirBodyStatement* pointer = NULL, *tempPointer = NULL;
  121124           0 :      std::vector < unsigned char* > :: const_iterator block;
  121125           0 :      if ( SgUpirBodyStatement::pools.empty() == false )
  121126             :         {
  121127           0 :           block = SgUpirBodyStatement::pools.begin() ;
  121128           0 :           SgUpirBodyStatement::next_node = (SgUpirBodyStatement*) (*block);
  121129             : 
  121130           0 :           while ( block != SgUpirBodyStatement::pools.end() )
  121131             :              {
  121132           0 :                pointer = (SgUpirBodyStatement*) (*block);
  121133           0 :                if ( tempPointer != NULL )
  121134             :                   {
  121135           0 :                     tempPointer->set_freepointer(pointer);
  121136             :                   }
  121137           0 :                for (unsigned i = 0; i < SgUpirBodyStatement::pool_size - 1; ++i)
  121138             :                   {
  121139           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  121140             :                   }
  121141           0 :                 pointer[SgUpirBodyStatement::pool_size-1].set_freepointer(NULL);
  121142           0 :                 tempPointer = &(pointer[SgUpirBodyStatement::pool_size-1]);
  121143           0 :                 ++block;
  121144             :              }
  121145             :         }
  121146           0 :    }
  121147             : 
  121148           5 : void SgUpirBodyStatement::deleteMemoryPool() {
  121149           5 :   for (auto p: SgUpirBodyStatement::pools) {
  121150           0 :     ROSE_FREE(p);
  121151             :   }
  121152           5 :   SgUpirBodyStatement::next_node = nullptr;
  121153           5 :   SgUpirBodyStatement::pools.clear();
  121154           5 : }
  121155             : 
  121156             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  121157             : //                 reading multiple binary files to for a single AST.
  121158             : /////////// new version ////////////////////////////////
  121159             : //############################################################################
  121160             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  121161             : void
  121162           2 : SgUpirBodyStatement::extendMemoryPoolForFileIO( )
  121163             :   {
  121164           2 :     size_t blockIndex = SgUpirBodyStatement::pools.size();
  121165           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBodyStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBodyStatement);
  121166             : 
  121167           2 :     while ( (blockIndex * SgUpirBodyStatement::pool_size) < newPoolSize)
  121168             :       {
  121169             : #if ROSE_ALLOC_TRACE
  121170             :         if (blockIndex > 0) {
  121171             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBodyStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBodyStatement) = %" PRIuPTR " SgUpirBodyStatement::pool_size = %d \n",
  121172             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirBodyStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirBodyStatement),SgUpirBodyStatement::pool_size);
  121173             :         }
  121174             : #endif
  121175             : 
  121176           0 :         SgUpirBodyStatement * pointer = (SgUpirBodyStatement*) ROSE_MALLOC ( SgUpirBodyStatement::pool_size * sizeof(SgUpirBodyStatement) );
  121177           0 :         assert( pointer != NULL );
  121178             : #if ROSE_ALLOC_MEMSET == 1
  121179             :         memset(pointer, 0x00, SgUpirBodyStatement::pool_size * sizeof(SgUpirBodyStatement));
  121180             : #elif ROSE_ALLOC_MEMSET == 2
  121181             :         memset(pointer, 0xCC, SgUpirBodyStatement::pool_size * sizeof(SgUpirBodyStatement));
  121182             : #endif
  121183           0 :         SgUpirBodyStatement::pools.push_back( (unsigned char*)(pointer) );
  121184           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirBodyStatement::pool_size * sizeof(SgUpirBodyStatement), V_SgUpirBodyStatement ) );
  121185             : 
  121186           0 :         if ( SgUpirBodyStatement::next_node != NULL ) {
  121187           0 :           if ( blockIndex > 0 ) {
  121188           0 :             SgUpirBodyStatement * blkptr = (SgUpirBodyStatement*)(SgUpirBodyStatement::pools[blockIndex-1]);
  121189           0 :             blkptr[ SgUpirBodyStatement::pool_size - 1 ].set_freepointer(pointer);
  121190             :           }
  121191             :         } else {
  121192           0 :           SgUpirBodyStatement::next_node = pointer;
  121193             :         }
  121194             : 
  121195           0 :         for (unsigned i = 0; i < SgUpirBodyStatement::pool_size-1; ++i)
  121196             :            {
  121197           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  121198             :            }
  121199           0 :         pointer[ SgUpirBodyStatement::pool_size -1 ].set_freepointer(NULL);
  121200             : 
  121201           0 :         blockIndex++;
  121202             :       }
  121203           2 :   }
  121204             : 
  121205             : //############################################################################
  121206             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  121207             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  121208             :  * not compressed. However, that stuff is not yet implemented! 
  121209             :  */
  121210             : unsigned long
  121211           0 : SgUpirBodyStatement::getNumberOfLastValidPointer()
  121212             :    {
  121213           0 :       SgUpirBodyStatement* testPointer = (SgUpirBodyStatement*)(SgUpirBodyStatement::pools.back());
  121214           0 :       unsigned long localIndex = SgUpirBodyStatement::pool_size - 1;
  121215           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  121216             :          {
  121217           0 :            localIndex--;
  121218             :          }
  121219           0 :       return (localIndex + SgUpirBodyStatement::pool_size * (SgUpirBodyStatement::pools.size()-1));
  121220             :    }
  121221             : 
  121222             : //############################################################################
  121223             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  121224             :  * memory pool and initializes the data member in class SgUpirBodyStatementStroageClass
  121225             :  * from its counterpart of SgUpirBodyStatement. The return value is just for checking, 
  121226             :  * that the whole StorageClassArray is initialized!
  121227             :  */
  121228             : unsigned long
  121229           0 : SgUpirBodyStatement::initializeStorageClassArray( SgUpirBodyStatementStorageClass *storageArray )
  121230             :    {
  121231           0 :      unsigned long storageCounter = 0;
  121232           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirBodyStatement::pools.begin();
  121233           0 :      SgUpirBodyStatement* pointer = NULL;
  121234           0 :      while ( block != SgUpirBodyStatement::pools.end() ) {
  121235           0 :           pointer = (SgUpirBodyStatement*) (*block);
  121236           0 :           for ( unsigned i = 0; i < SgUpirBodyStatement::pool_size; ++i ) {
  121237           0 :                if ( pointer->get_freepointer() != NULL ) {
  121238           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  121239           0 :                  storageArray++;
  121240           0 :                  storageCounter++;
  121241             :                }
  121242           0 :                pointer++;
  121243             :              }
  121244           0 :            block++;
  121245             :         }
  121246           0 :      return storageCounter;
  121247             :    }
  121248             : 
  121249             : /* #line 121250 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  121250             : 
  121251             : 
  121252             : 
  121253             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  121254             : 
  121255             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  121256             : 
  121257             : //############################################################################
  121258             : /* JH (02/02/2006) Constructor of the IR node SgOmpMasterStatement that takes its 
  121259             :  * corresponding StorageClass as parameter
  121260             :  */
  121261           0 : SgOmpMasterStatement :: SgOmpMasterStatement ( const SgOmpMasterStatementStorageClass& storageSource )   : SgUpirBodyStatement (storageSource)
  121262             :    {
  121263             : 
  121264             : 
  121265             : /* #line 121266 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  121266             : 
  121267           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  121268             : 
  121269             : 
  121270             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  121271             : 
  121272             : 
  121273           0 :    }
  121274             : 
  121275             : //############################################################################
  121276             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  121277             :  * within the working AST. 
  121278             :  */
  121279           0 : SgOmpMasterStatement * SgOmpMasterStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  121280           0 :      SgOmpMasterStatement* returnPointer = NULL;
  121281           0 :      if ( globalIndex != 0 )
  121282             :         {
  121283             : 
  121284             : #if FILE_IO_EXTRA_CHECK
  121285           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpMasterStatement ) ) <= globalIndex ) ;
  121286           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMasterStatement + 1 ) ) );
  121287             : #endif
  121288           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMasterStatement )  
  121289           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpMasterStatement );
  121290           0 :           unsigned long positionInPool = localIndex % SgOmpMasterStatement::pool_size;
  121291           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMasterStatement::pool_size;
  121292             : 
  121293             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  121294             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  121295             : 
  121296           0 :           returnPointer = &( ( (SgOmpMasterStatement*)(SgOmpMasterStatement::pools[memoryBlock]) ) [positionInPool]) ;
  121297             : 
  121298           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  121299             :         }
  121300           0 :      return returnPointer ;
  121301             :    }
  121302             : 
  121303             : //############################################################################
  121304             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  121305             :   for the AST with the index astIndex
  121306             : */
  121307           0 : SgOmpMasterStatement * SgOmpMasterStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  121308           0 :      SgOmpMasterStatement* returnPointer = NULL;
  121309           0 :      if ( globalIndex != 0 )
  121310             :         {
  121311             : 
  121312             : #if FILE_IO_EXTRA_CHECK
  121313           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpMasterStatement ) ) <= globalIndex ) ;
  121314           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMasterStatement + 1 ) ) );
  121315             : #endif
  121316           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMasterStatement )
  121317           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpMasterStatement );
  121318           0 :           unsigned long positionInPool = localIndex % SgOmpMasterStatement::pool_size ;
  121319           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMasterStatement::pool_size ;
  121320             : 
  121321             : #if FILE_IO_EXTRA_CHECK
  121322             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  121323             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  121324             : #endif
  121325             : 
  121326           0 :           returnPointer = &( ( (SgOmpMasterStatement*)(SgOmpMasterStatement::pools[memoryBlock]) ) [positionInPool]) ;
  121327             : 
  121328             : #if FILE_IO_EXTRA_CHECK
  121329           0 :           assert ( returnPointer != NULL ) ;
  121330             : #endif
  121331             :         }
  121332           0 :      return returnPointer ;
  121333             :    }
  121334             : 
  121335             : //############################################################################
  121336             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  121337             :  * pool size! We set for every valid object in the memory pool the freepointer
  121338             :  * to the global index and increase the global index afterwards. For all the 
  121339             :  * invalid objects (means address ranges within the memory pool that were not
  121340             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  121341             :  * distinguish valid from invalid objects! 
  121342             :  */
  121343             : unsigned long
  121344           5 : SgOmpMasterStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  121345             :    {
  121346           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  121347           5 :      SgOmpMasterStatement* pointer = NULL;
  121348           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  121349           5 :      std::vector < unsigned char* > :: const_iterator block;
  121350           5 :      for ( block = SgOmpMasterStatement::pools.begin(); block != SgOmpMasterStatement::pools.end() ; ++block )
  121351             :         {
  121352           0 :           pointer = (SgOmpMasterStatement*)(*block);
  121353           0 :           for (unsigned i = 0; i < SgOmpMasterStatement::pool_size; ++i )
  121354             :              {
  121355             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  121356             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  121357             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  121358             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  121359             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  121360             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  121361             :             // properly; so this will have to be checked next.
  121362             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  121363             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  121364           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  121365             :                   {
  121366           0 :                     pointer[i].set_freepointer((SgOmpMasterStatement*)(globalIndex));
  121367           0 :                     globalIndex++;
  121368             :                   }
  121369             :                else
  121370             :                   {
  121371           0 :                     pointer[i].set_freepointer(NULL);
  121372             :                   }
  121373             :               }
  121374             :         }
  121375           5 :      return globalIndex;
  121376             :    }
  121377             : 
  121378             : //############################################################################
  121379             : // JH (01/14/2006)
  121380             : void
  121381           5 : SgOmpMasterStatement::resetValidFreepointers( )
  121382             :    {
  121383           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  121384           5 :      SgOmpMasterStatement* pointer = NULL;
  121385           5 :      std::vector < unsigned char* > :: const_iterator block;
  121386           5 :      SgOmpMasterStatement* pointerOfLinkedList = NULL;
  121387           5 :      for ( block = SgOmpMasterStatement::pools.begin(); block != SgOmpMasterStatement::pools.end() ; ++block )
  121388             :         {
  121389           0 :           pointer = (SgOmpMasterStatement*)(*block);
  121390           0 :           for (unsigned i = 0; i < SgOmpMasterStatement::pool_size; ++i )
  121391             :              {
  121392             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  121393             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  121394             :             // memory blocks!.
  121395           0 :                if ( pointer[i].get_freepointer() != NULL )
  121396             :                   {
  121397           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  121398             :                   }
  121399             :                else
  121400             :                   {
  121401           0 :                     if ( pointerOfLinkedList == NULL )
  121402             :                        {
  121403           0 :                          SgOmpMasterStatement::next_node = &(pointer[i]);
  121404             :                        }
  121405             :                     else
  121406             :                        {
  121407             :                       // printf ("In SgOmpMasterStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  121408           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  121409             :                        }
  121410             :                     pointerOfLinkedList = &(pointer[i]);
  121411             :                   }
  121412             :               }
  121413             :         }
  121414             : 
  121415           5 :      if ( pointerOfLinkedList != NULL )
  121416             :         {
  121417             :        // printf ("In SgOmpMasterStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  121418           0 :           pointerOfLinkedList->set_freepointer(NULL);
  121419             :        // DQ (6/6/2010): Temporary debugging...
  121420             :        //   ROSE_ASSERT(false);
  121421             :         }
  121422             : 
  121423           5 :      return ;
  121424             :    }
  121425             : 
  121426             : //############################################################################
  121427             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  121428             :  * within the memory pool and resets the freepointers, in order to achieve a 
  121429             :  * linked list, that has no jumps and starts at the beginning! This function 
  121430             :  * does not extend the memory pool, since we do not delete any memory blocks,
  121431             :  * but delete the valid objects.  
  121432             :  */
  121433             : void
  121434           0 : SgOmpMasterStatement::clearMemoryPool( )
  121435             :    {
  121436             :   // printf ("Inside of SgOmpMasterStatement::clearMemoryPool() \n");
  121437             : 
  121438           0 :      SgOmpMasterStatement* pointer = NULL, *tempPointer = NULL;
  121439           0 :      std::vector < unsigned char* > :: const_iterator block;
  121440           0 :      if ( SgOmpMasterStatement::pools.empty() == false )
  121441             :         {
  121442           0 :           block = SgOmpMasterStatement::pools.begin() ;
  121443           0 :           SgOmpMasterStatement::next_node = (SgOmpMasterStatement*) (*block);
  121444             : 
  121445           0 :           while ( block != SgOmpMasterStatement::pools.end() )
  121446             :              {
  121447           0 :                pointer = (SgOmpMasterStatement*) (*block);
  121448           0 :                if ( tempPointer != NULL )
  121449             :                   {
  121450           0 :                     tempPointer->set_freepointer(pointer);
  121451             :                   }
  121452           0 :                for (unsigned i = 0; i < SgOmpMasterStatement::pool_size - 1; ++i)
  121453             :                   {
  121454           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  121455             :                   }
  121456           0 :                 pointer[SgOmpMasterStatement::pool_size-1].set_freepointer(NULL);
  121457           0 :                 tempPointer = &(pointer[SgOmpMasterStatement::pool_size-1]);
  121458           0 :                 ++block;
  121459             :              }
  121460             :         }
  121461           0 :    }
  121462             : 
  121463           5 : void SgOmpMasterStatement::deleteMemoryPool() {
  121464           5 :   for (auto p: SgOmpMasterStatement::pools) {
  121465           0 :     ROSE_FREE(p);
  121466             :   }
  121467           5 :   SgOmpMasterStatement::next_node = nullptr;
  121468           5 :   SgOmpMasterStatement::pools.clear();
  121469           5 : }
  121470             : 
  121471             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  121472             : //                 reading multiple binary files to for a single AST.
  121473             : /////////// new version ////////////////////////////////
  121474             : //############################################################################
  121475             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  121476             : void
  121477           2 : SgOmpMasterStatement::extendMemoryPoolForFileIO( )
  121478             :   {
  121479           2 :     size_t blockIndex = SgOmpMasterStatement::pools.size();
  121480           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterStatement);
  121481             : 
  121482           2 :     while ( (blockIndex * SgOmpMasterStatement::pool_size) < newPoolSize)
  121483             :       {
  121484             : #if ROSE_ALLOC_TRACE
  121485             :         if (blockIndex > 0) {
  121486             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterStatement) = %" PRIuPTR " SgOmpMasterStatement::pool_size = %d \n",
  121487             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterStatement),SgOmpMasterStatement::pool_size);
  121488             :         }
  121489             : #endif
  121490             : 
  121491           0 :         SgOmpMasterStatement * pointer = (SgOmpMasterStatement*) ROSE_MALLOC ( SgOmpMasterStatement::pool_size * sizeof(SgOmpMasterStatement) );
  121492           0 :         assert( pointer != NULL );
  121493             : #if ROSE_ALLOC_MEMSET == 1
  121494             :         memset(pointer, 0x00, SgOmpMasterStatement::pool_size * sizeof(SgOmpMasterStatement));
  121495             : #elif ROSE_ALLOC_MEMSET == 2
  121496             :         memset(pointer, 0xCC, SgOmpMasterStatement::pool_size * sizeof(SgOmpMasterStatement));
  121497             : #endif
  121498           0 :         SgOmpMasterStatement::pools.push_back( (unsigned char*)(pointer) );
  121499           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpMasterStatement::pool_size * sizeof(SgOmpMasterStatement), V_SgOmpMasterStatement ) );
  121500             : 
  121501           0 :         if ( SgOmpMasterStatement::next_node != NULL ) {
  121502           0 :           if ( blockIndex > 0 ) {
  121503           0 :             SgOmpMasterStatement * blkptr = (SgOmpMasterStatement*)(SgOmpMasterStatement::pools[blockIndex-1]);
  121504           0 :             blkptr[ SgOmpMasterStatement::pool_size - 1 ].set_freepointer(pointer);
  121505             :           }
  121506             :         } else {
  121507           0 :           SgOmpMasterStatement::next_node = pointer;
  121508             :         }
  121509             : 
  121510           0 :         for (unsigned i = 0; i < SgOmpMasterStatement::pool_size-1; ++i)
  121511             :            {
  121512           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  121513             :            }
  121514           0 :         pointer[ SgOmpMasterStatement::pool_size -1 ].set_freepointer(NULL);
  121515             : 
  121516           0 :         blockIndex++;
  121517             :       }
  121518           2 :   }
  121519             : 
  121520             : //############################################################################
  121521             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  121522             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  121523             :  * not compressed. However, that stuff is not yet implemented! 
  121524             :  */
  121525             : unsigned long
  121526           0 : SgOmpMasterStatement::getNumberOfLastValidPointer()
  121527             :    {
  121528           0 :       SgOmpMasterStatement* testPointer = (SgOmpMasterStatement*)(SgOmpMasterStatement::pools.back());
  121529           0 :       unsigned long localIndex = SgOmpMasterStatement::pool_size - 1;
  121530           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  121531             :          {
  121532           0 :            localIndex--;
  121533             :          }
  121534           0 :       return (localIndex + SgOmpMasterStatement::pool_size * (SgOmpMasterStatement::pools.size()-1));
  121535             :    }
  121536             : 
  121537             : //############################################################################
  121538             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  121539             :  * memory pool and initializes the data member in class SgOmpMasterStatementStroageClass
  121540             :  * from its counterpart of SgOmpMasterStatement. The return value is just for checking, 
  121541             :  * that the whole StorageClassArray is initialized!
  121542             :  */
  121543             : unsigned long
  121544           0 : SgOmpMasterStatement::initializeStorageClassArray( SgOmpMasterStatementStorageClass *storageArray )
  121545             :    {
  121546           0 :      unsigned long storageCounter = 0;
  121547           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpMasterStatement::pools.begin();
  121548           0 :      SgOmpMasterStatement* pointer = NULL;
  121549           0 :      while ( block != SgOmpMasterStatement::pools.end() ) {
  121550           0 :           pointer = (SgOmpMasterStatement*) (*block);
  121551           0 :           for ( unsigned i = 0; i < SgOmpMasterStatement::pool_size; ++i ) {
  121552           0 :                if ( pointer->get_freepointer() != NULL ) {
  121553           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  121554           0 :                  storageArray++;
  121555           0 :                  storageCounter++;
  121556             :                }
  121557           0 :                pointer++;
  121558             :              }
  121559           0 :            block++;
  121560             :         }
  121561           0 :      return storageCounter;
  121562             :    }
  121563             : 
  121564             : /* #line 121565 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  121565             : 
  121566             : 
  121567             : 
  121568             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  121569             : 
  121570             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  121571             : 
  121572             : //############################################################################
  121573             : /* JH (02/02/2006) Constructor of the IR node SgOmpSectionStatement that takes its 
  121574             :  * corresponding StorageClass as parameter
  121575             :  */
  121576           0 : SgOmpSectionStatement :: SgOmpSectionStatement ( const SgOmpSectionStatementStorageClass& storageSource )   : SgUpirBodyStatement (storageSource)
  121577             :    {
  121578             : 
  121579             : 
  121580             : /* #line 121581 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  121581             : 
  121582           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  121583             : 
  121584             : 
  121585             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  121586             : 
  121587             : 
  121588           0 :    }
  121589             : 
  121590             : //############################################################################
  121591             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  121592             :  * within the working AST. 
  121593             :  */
  121594           0 : SgOmpSectionStatement * SgOmpSectionStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  121595           0 :      SgOmpSectionStatement* returnPointer = NULL;
  121596           0 :      if ( globalIndex != 0 )
  121597             :         {
  121598             : 
  121599             : #if FILE_IO_EXTRA_CHECK
  121600           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSectionStatement ) ) <= globalIndex ) ;
  121601           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSectionStatement + 1 ) ) );
  121602             : #endif
  121603           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSectionStatement )  
  121604           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSectionStatement );
  121605           0 :           unsigned long positionInPool = localIndex % SgOmpSectionStatement::pool_size;
  121606           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSectionStatement::pool_size;
  121607             : 
  121608             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  121609             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  121610             : 
  121611           0 :           returnPointer = &( ( (SgOmpSectionStatement*)(SgOmpSectionStatement::pools[memoryBlock]) ) [positionInPool]) ;
  121612             : 
  121613           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  121614             :         }
  121615           0 :      return returnPointer ;
  121616             :    }
  121617             : 
  121618             : //############################################################################
  121619             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  121620             :   for the AST with the index astIndex
  121621             : */
  121622           0 : SgOmpSectionStatement * SgOmpSectionStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  121623           0 :      SgOmpSectionStatement* returnPointer = NULL;
  121624           0 :      if ( globalIndex != 0 )
  121625             :         {
  121626             : 
  121627             : #if FILE_IO_EXTRA_CHECK
  121628           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSectionStatement ) ) <= globalIndex ) ;
  121629           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSectionStatement + 1 ) ) );
  121630             : #endif
  121631           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSectionStatement )
  121632           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSectionStatement );
  121633           0 :           unsigned long positionInPool = localIndex % SgOmpSectionStatement::pool_size ;
  121634           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSectionStatement::pool_size ;
  121635             : 
  121636             : #if FILE_IO_EXTRA_CHECK
  121637             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  121638             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  121639             : #endif
  121640             : 
  121641           0 :           returnPointer = &( ( (SgOmpSectionStatement*)(SgOmpSectionStatement::pools[memoryBlock]) ) [positionInPool]) ;
  121642             : 
  121643             : #if FILE_IO_EXTRA_CHECK
  121644           0 :           assert ( returnPointer != NULL ) ;
  121645             : #endif
  121646             :         }
  121647           0 :      return returnPointer ;
  121648             :    }
  121649             : 
  121650             : //############################################################################
  121651             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  121652             :  * pool size! We set for every valid object in the memory pool the freepointer
  121653             :  * to the global index and increase the global index afterwards. For all the 
  121654             :  * invalid objects (means address ranges within the memory pool that were not
  121655             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  121656             :  * distinguish valid from invalid objects! 
  121657             :  */
  121658             : unsigned long
  121659           5 : SgOmpSectionStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  121660             :    {
  121661           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  121662           5 :      SgOmpSectionStatement* pointer = NULL;
  121663           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  121664           5 :      std::vector < unsigned char* > :: const_iterator block;
  121665           5 :      for ( block = SgOmpSectionStatement::pools.begin(); block != SgOmpSectionStatement::pools.end() ; ++block )
  121666             :         {
  121667           0 :           pointer = (SgOmpSectionStatement*)(*block);
  121668           0 :           for (unsigned i = 0; i < SgOmpSectionStatement::pool_size; ++i )
  121669             :              {
  121670             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  121671             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  121672             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  121673             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  121674             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  121675             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  121676             :             // properly; so this will have to be checked next.
  121677             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  121678             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  121679           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  121680             :                   {
  121681           0 :                     pointer[i].set_freepointer((SgOmpSectionStatement*)(globalIndex));
  121682           0 :                     globalIndex++;
  121683             :                   }
  121684             :                else
  121685             :                   {
  121686           0 :                     pointer[i].set_freepointer(NULL);
  121687             :                   }
  121688             :               }
  121689             :         }
  121690           5 :      return globalIndex;
  121691             :    }
  121692             : 
  121693             : //############################################################################
  121694             : // JH (01/14/2006)
  121695             : void
  121696           5 : SgOmpSectionStatement::resetValidFreepointers( )
  121697             :    {
  121698           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  121699           5 :      SgOmpSectionStatement* pointer = NULL;
  121700           5 :      std::vector < unsigned char* > :: const_iterator block;
  121701           5 :      SgOmpSectionStatement* pointerOfLinkedList = NULL;
  121702           5 :      for ( block = SgOmpSectionStatement::pools.begin(); block != SgOmpSectionStatement::pools.end() ; ++block )
  121703             :         {
  121704           0 :           pointer = (SgOmpSectionStatement*)(*block);
  121705           0 :           for (unsigned i = 0; i < SgOmpSectionStatement::pool_size; ++i )
  121706             :              {
  121707             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  121708             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  121709             :             // memory blocks!.
  121710           0 :                if ( pointer[i].get_freepointer() != NULL )
  121711             :                   {
  121712           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  121713             :                   }
  121714             :                else
  121715             :                   {
  121716           0 :                     if ( pointerOfLinkedList == NULL )
  121717             :                        {
  121718           0 :                          SgOmpSectionStatement::next_node = &(pointer[i]);
  121719             :                        }
  121720             :                     else
  121721             :                        {
  121722             :                       // printf ("In SgOmpSectionStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  121723           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  121724             :                        }
  121725             :                     pointerOfLinkedList = &(pointer[i]);
  121726             :                   }
  121727             :               }
  121728             :         }
  121729             : 
  121730           5 :      if ( pointerOfLinkedList != NULL )
  121731             :         {
  121732             :        // printf ("In SgOmpSectionStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  121733           0 :           pointerOfLinkedList->set_freepointer(NULL);
  121734             :        // DQ (6/6/2010): Temporary debugging...
  121735             :        //   ROSE_ASSERT(false);
  121736             :         }
  121737             : 
  121738           5 :      return ;
  121739             :    }
  121740             : 
  121741             : //############################################################################
  121742             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  121743             :  * within the memory pool and resets the freepointers, in order to achieve a 
  121744             :  * linked list, that has no jumps and starts at the beginning! This function 
  121745             :  * does not extend the memory pool, since we do not delete any memory blocks,
  121746             :  * but delete the valid objects.  
  121747             :  */
  121748             : void
  121749           0 : SgOmpSectionStatement::clearMemoryPool( )
  121750             :    {
  121751             :   // printf ("Inside of SgOmpSectionStatement::clearMemoryPool() \n");
  121752             : 
  121753           0 :      SgOmpSectionStatement* pointer = NULL, *tempPointer = NULL;
  121754           0 :      std::vector < unsigned char* > :: const_iterator block;
  121755           0 :      if ( SgOmpSectionStatement::pools.empty() == false )
  121756             :         {
  121757           0 :           block = SgOmpSectionStatement::pools.begin() ;
  121758           0 :           SgOmpSectionStatement::next_node = (SgOmpSectionStatement*) (*block);
  121759             : 
  121760           0 :           while ( block != SgOmpSectionStatement::pools.end() )
  121761             :              {
  121762           0 :                pointer = (SgOmpSectionStatement*) (*block);
  121763           0 :                if ( tempPointer != NULL )
  121764             :                   {
  121765           0 :                     tempPointer->set_freepointer(pointer);
  121766             :                   }
  121767           0 :                for (unsigned i = 0; i < SgOmpSectionStatement::pool_size - 1; ++i)
  121768             :                   {
  121769           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  121770             :                   }
  121771           0 :                 pointer[SgOmpSectionStatement::pool_size-1].set_freepointer(NULL);
  121772           0 :                 tempPointer = &(pointer[SgOmpSectionStatement::pool_size-1]);
  121773           0 :                 ++block;
  121774             :              }
  121775             :         }
  121776           0 :    }
  121777             : 
  121778           5 : void SgOmpSectionStatement::deleteMemoryPool() {
  121779           5 :   for (auto p: SgOmpSectionStatement::pools) {
  121780           0 :     ROSE_FREE(p);
  121781             :   }
  121782           5 :   SgOmpSectionStatement::next_node = nullptr;
  121783           5 :   SgOmpSectionStatement::pools.clear();
  121784           5 : }
  121785             : 
  121786             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  121787             : //                 reading multiple binary files to for a single AST.
  121788             : /////////// new version ////////////////////////////////
  121789             : //############################################################################
  121790             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  121791             : void
  121792           2 : SgOmpSectionStatement::extendMemoryPoolForFileIO( )
  121793             :   {
  121794           2 :     size_t blockIndex = SgOmpSectionStatement::pools.size();
  121795           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionStatement);
  121796             : 
  121797           2 :     while ( (blockIndex * SgOmpSectionStatement::pool_size) < newPoolSize)
  121798             :       {
  121799             : #if ROSE_ALLOC_TRACE
  121800             :         if (blockIndex > 0) {
  121801             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionStatement) = %" PRIuPTR " SgOmpSectionStatement::pool_size = %d \n",
  121802             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionStatement),SgOmpSectionStatement::pool_size);
  121803             :         }
  121804             : #endif
  121805             : 
  121806           0 :         SgOmpSectionStatement * pointer = (SgOmpSectionStatement*) ROSE_MALLOC ( SgOmpSectionStatement::pool_size * sizeof(SgOmpSectionStatement) );
  121807           0 :         assert( pointer != NULL );
  121808             : #if ROSE_ALLOC_MEMSET == 1
  121809             :         memset(pointer, 0x00, SgOmpSectionStatement::pool_size * sizeof(SgOmpSectionStatement));
  121810             : #elif ROSE_ALLOC_MEMSET == 2
  121811             :         memset(pointer, 0xCC, SgOmpSectionStatement::pool_size * sizeof(SgOmpSectionStatement));
  121812             : #endif
  121813           0 :         SgOmpSectionStatement::pools.push_back( (unsigned char*)(pointer) );
  121814           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSectionStatement::pool_size * sizeof(SgOmpSectionStatement), V_SgOmpSectionStatement ) );
  121815             : 
  121816           0 :         if ( SgOmpSectionStatement::next_node != NULL ) {
  121817           0 :           if ( blockIndex > 0 ) {
  121818           0 :             SgOmpSectionStatement * blkptr = (SgOmpSectionStatement*)(SgOmpSectionStatement::pools[blockIndex-1]);
  121819           0 :             blkptr[ SgOmpSectionStatement::pool_size - 1 ].set_freepointer(pointer);
  121820             :           }
  121821             :         } else {
  121822           0 :           SgOmpSectionStatement::next_node = pointer;
  121823             :         }
  121824             : 
  121825           0 :         for (unsigned i = 0; i < SgOmpSectionStatement::pool_size-1; ++i)
  121826             :            {
  121827           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  121828             :            }
  121829           0 :         pointer[ SgOmpSectionStatement::pool_size -1 ].set_freepointer(NULL);
  121830             : 
  121831           0 :         blockIndex++;
  121832             :       }
  121833           2 :   }
  121834             : 
  121835             : //############################################################################
  121836             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  121837             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  121838             :  * not compressed. However, that stuff is not yet implemented! 
  121839             :  */
  121840             : unsigned long
  121841           0 : SgOmpSectionStatement::getNumberOfLastValidPointer()
  121842             :    {
  121843           0 :       SgOmpSectionStatement* testPointer = (SgOmpSectionStatement*)(SgOmpSectionStatement::pools.back());
  121844           0 :       unsigned long localIndex = SgOmpSectionStatement::pool_size - 1;
  121845           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  121846             :          {
  121847           0 :            localIndex--;
  121848             :          }
  121849           0 :       return (localIndex + SgOmpSectionStatement::pool_size * (SgOmpSectionStatement::pools.size()-1));
  121850             :    }
  121851             : 
  121852             : //############################################################################
  121853             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  121854             :  * memory pool and initializes the data member in class SgOmpSectionStatementStroageClass
  121855             :  * from its counterpart of SgOmpSectionStatement. The return value is just for checking, 
  121856             :  * that the whole StorageClassArray is initialized!
  121857             :  */
  121858             : unsigned long
  121859           0 : SgOmpSectionStatement::initializeStorageClassArray( SgOmpSectionStatementStorageClass *storageArray )
  121860             :    {
  121861           0 :      unsigned long storageCounter = 0;
  121862           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSectionStatement::pools.begin();
  121863           0 :      SgOmpSectionStatement* pointer = NULL;
  121864           0 :      while ( block != SgOmpSectionStatement::pools.end() ) {
  121865           0 :           pointer = (SgOmpSectionStatement*) (*block);
  121866           0 :           for ( unsigned i = 0; i < SgOmpSectionStatement::pool_size; ++i ) {
  121867           0 :                if ( pointer->get_freepointer() != NULL ) {
  121868           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  121869           0 :                  storageArray++;
  121870           0 :                  storageCounter++;
  121871             :                }
  121872           0 :                pointer++;
  121873             :              }
  121874           0 :            block++;
  121875             :         }
  121876           0 :      return storageCounter;
  121877             :    }
  121878             : 
  121879             : /* #line 121880 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  121880             : 
  121881             : 
  121882             : 
  121883             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  121884             : 
  121885             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  121886             : 
  121887             : //############################################################################
  121888             : /* JH (02/02/2006) Constructor of the IR node SgOmpWorkshareStatement that takes its 
  121889             :  * corresponding StorageClass as parameter
  121890             :  */
  121891           0 : SgOmpWorkshareStatement :: SgOmpWorkshareStatement ( const SgOmpWorkshareStatementStorageClass& storageSource )   : SgUpirBodyStatement (storageSource)
  121892             :    {
  121893             : 
  121894             : 
  121895             : /* #line 121896 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  121896             : 
  121897           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  121898             : 
  121899             : 
  121900             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  121901             : 
  121902             : 
  121903           0 :    }
  121904             : 
  121905             : //############################################################################
  121906             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  121907             :  * within the working AST. 
  121908             :  */
  121909           0 : SgOmpWorkshareStatement * SgOmpWorkshareStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  121910           0 :      SgOmpWorkshareStatement* returnPointer = NULL;
  121911           0 :      if ( globalIndex != 0 )
  121912             :         {
  121913             : 
  121914             : #if FILE_IO_EXTRA_CHECK
  121915           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpWorkshareStatement ) ) <= globalIndex ) ;
  121916           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpWorkshareStatement + 1 ) ) );
  121917             : #endif
  121918           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpWorkshareStatement )  
  121919           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpWorkshareStatement );
  121920           0 :           unsigned long positionInPool = localIndex % SgOmpWorkshareStatement::pool_size;
  121921           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpWorkshareStatement::pool_size;
  121922             : 
  121923             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  121924             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  121925             : 
  121926           0 :           returnPointer = &( ( (SgOmpWorkshareStatement*)(SgOmpWorkshareStatement::pools[memoryBlock]) ) [positionInPool]) ;
  121927             : 
  121928           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  121929             :         }
  121930           0 :      return returnPointer ;
  121931             :    }
  121932             : 
  121933             : //############################################################################
  121934             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  121935             :   for the AST with the index astIndex
  121936             : */
  121937           0 : SgOmpWorkshareStatement * SgOmpWorkshareStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  121938           0 :      SgOmpWorkshareStatement* returnPointer = NULL;
  121939           0 :      if ( globalIndex != 0 )
  121940             :         {
  121941             : 
  121942             : #if FILE_IO_EXTRA_CHECK
  121943           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpWorkshareStatement ) ) <= globalIndex ) ;
  121944           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpWorkshareStatement + 1 ) ) );
  121945             : #endif
  121946           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpWorkshareStatement )
  121947           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpWorkshareStatement );
  121948           0 :           unsigned long positionInPool = localIndex % SgOmpWorkshareStatement::pool_size ;
  121949           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpWorkshareStatement::pool_size ;
  121950             : 
  121951             : #if FILE_IO_EXTRA_CHECK
  121952             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  121953             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  121954             : #endif
  121955             : 
  121956           0 :           returnPointer = &( ( (SgOmpWorkshareStatement*)(SgOmpWorkshareStatement::pools[memoryBlock]) ) [positionInPool]) ;
  121957             : 
  121958             : #if FILE_IO_EXTRA_CHECK
  121959           0 :           assert ( returnPointer != NULL ) ;
  121960             : #endif
  121961             :         }
  121962           0 :      return returnPointer ;
  121963             :    }
  121964             : 
  121965             : //############################################################################
  121966             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  121967             :  * pool size! We set for every valid object in the memory pool the freepointer
  121968             :  * to the global index and increase the global index afterwards. For all the 
  121969             :  * invalid objects (means address ranges within the memory pool that were not
  121970             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  121971             :  * distinguish valid from invalid objects! 
  121972             :  */
  121973             : unsigned long
  121974           5 : SgOmpWorkshareStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  121975             :    {
  121976           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  121977           5 :      SgOmpWorkshareStatement* pointer = NULL;
  121978           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  121979           5 :      std::vector < unsigned char* > :: const_iterator block;
  121980           5 :      for ( block = SgOmpWorkshareStatement::pools.begin(); block != SgOmpWorkshareStatement::pools.end() ; ++block )
  121981             :         {
  121982           0 :           pointer = (SgOmpWorkshareStatement*)(*block);
  121983           0 :           for (unsigned i = 0; i < SgOmpWorkshareStatement::pool_size; ++i )
  121984             :              {
  121985             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  121986             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  121987             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  121988             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  121989             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  121990             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  121991             :             // properly; so this will have to be checked next.
  121992             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  121993             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  121994           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  121995             :                   {
  121996           0 :                     pointer[i].set_freepointer((SgOmpWorkshareStatement*)(globalIndex));
  121997           0 :                     globalIndex++;
  121998             :                   }
  121999             :                else
  122000             :                   {
  122001           0 :                     pointer[i].set_freepointer(NULL);
  122002             :                   }
  122003             :               }
  122004             :         }
  122005           5 :      return globalIndex;
  122006             :    }
  122007             : 
  122008             : //############################################################################
  122009             : // JH (01/14/2006)
  122010             : void
  122011           5 : SgOmpWorkshareStatement::resetValidFreepointers( )
  122012             :    {
  122013           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  122014           5 :      SgOmpWorkshareStatement* pointer = NULL;
  122015           5 :      std::vector < unsigned char* > :: const_iterator block;
  122016           5 :      SgOmpWorkshareStatement* pointerOfLinkedList = NULL;
  122017           5 :      for ( block = SgOmpWorkshareStatement::pools.begin(); block != SgOmpWorkshareStatement::pools.end() ; ++block )
  122018             :         {
  122019           0 :           pointer = (SgOmpWorkshareStatement*)(*block);
  122020           0 :           for (unsigned i = 0; i < SgOmpWorkshareStatement::pool_size; ++i )
  122021             :              {
  122022             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  122023             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  122024             :             // memory blocks!.
  122025           0 :                if ( pointer[i].get_freepointer() != NULL )
  122026             :                   {
  122027           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  122028             :                   }
  122029             :                else
  122030             :                   {
  122031           0 :                     if ( pointerOfLinkedList == NULL )
  122032             :                        {
  122033           0 :                          SgOmpWorkshareStatement::next_node = &(pointer[i]);
  122034             :                        }
  122035             :                     else
  122036             :                        {
  122037             :                       // printf ("In SgOmpWorkshareStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  122038           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  122039             :                        }
  122040             :                     pointerOfLinkedList = &(pointer[i]);
  122041             :                   }
  122042             :               }
  122043             :         }
  122044             : 
  122045           5 :      if ( pointerOfLinkedList != NULL )
  122046             :         {
  122047             :        // printf ("In SgOmpWorkshareStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  122048           0 :           pointerOfLinkedList->set_freepointer(NULL);
  122049             :        // DQ (6/6/2010): Temporary debugging...
  122050             :        //   ROSE_ASSERT(false);
  122051             :         }
  122052             : 
  122053           5 :      return ;
  122054             :    }
  122055             : 
  122056             : //############################################################################
  122057             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  122058             :  * within the memory pool and resets the freepointers, in order to achieve a 
  122059             :  * linked list, that has no jumps and starts at the beginning! This function 
  122060             :  * does not extend the memory pool, since we do not delete any memory blocks,
  122061             :  * but delete the valid objects.  
  122062             :  */
  122063             : void
  122064           0 : SgOmpWorkshareStatement::clearMemoryPool( )
  122065             :    {
  122066             :   // printf ("Inside of SgOmpWorkshareStatement::clearMemoryPool() \n");
  122067             : 
  122068           0 :      SgOmpWorkshareStatement* pointer = NULL, *tempPointer = NULL;
  122069           0 :      std::vector < unsigned char* > :: const_iterator block;
  122070           0 :      if ( SgOmpWorkshareStatement::pools.empty() == false )
  122071             :         {
  122072           0 :           block = SgOmpWorkshareStatement::pools.begin() ;
  122073           0 :           SgOmpWorkshareStatement::next_node = (SgOmpWorkshareStatement*) (*block);
  122074             : 
  122075           0 :           while ( block != SgOmpWorkshareStatement::pools.end() )
  122076             :              {
  122077           0 :                pointer = (SgOmpWorkshareStatement*) (*block);
  122078           0 :                if ( tempPointer != NULL )
  122079             :                   {
  122080           0 :                     tempPointer->set_freepointer(pointer);
  122081             :                   }
  122082           0 :                for (unsigned i = 0; i < SgOmpWorkshareStatement::pool_size - 1; ++i)
  122083             :                   {
  122084           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  122085             :                   }
  122086           0 :                 pointer[SgOmpWorkshareStatement::pool_size-1].set_freepointer(NULL);
  122087           0 :                 tempPointer = &(pointer[SgOmpWorkshareStatement::pool_size-1]);
  122088           0 :                 ++block;
  122089             :              }
  122090             :         }
  122091           0 :    }
  122092             : 
  122093           5 : void SgOmpWorkshareStatement::deleteMemoryPool() {
  122094           5 :   for (auto p: SgOmpWorkshareStatement::pools) {
  122095           0 :     ROSE_FREE(p);
  122096             :   }
  122097           5 :   SgOmpWorkshareStatement::next_node = nullptr;
  122098           5 :   SgOmpWorkshareStatement::pools.clear();
  122099           5 : }
  122100             : 
  122101             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  122102             : //                 reading multiple binary files to for a single AST.
  122103             : /////////// new version ////////////////////////////////
  122104             : //############################################################################
  122105             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  122106             : void
  122107           2 : SgOmpWorkshareStatement::extendMemoryPoolForFileIO( )
  122108             :   {
  122109           2 :     size_t blockIndex = SgOmpWorkshareStatement::pools.size();
  122110           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWorkshareStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWorkshareStatement);
  122111             : 
  122112           2 :     while ( (blockIndex * SgOmpWorkshareStatement::pool_size) < newPoolSize)
  122113             :       {
  122114             : #if ROSE_ALLOC_TRACE
  122115             :         if (blockIndex > 0) {
  122116             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWorkshareStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWorkshareStatement) = %" PRIuPTR " SgOmpWorkshareStatement::pool_size = %d \n",
  122117             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpWorkshareStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpWorkshareStatement),SgOmpWorkshareStatement::pool_size);
  122118             :         }
  122119             : #endif
  122120             : 
  122121           0 :         SgOmpWorkshareStatement * pointer = (SgOmpWorkshareStatement*) ROSE_MALLOC ( SgOmpWorkshareStatement::pool_size * sizeof(SgOmpWorkshareStatement) );
  122122           0 :         assert( pointer != NULL );
  122123             : #if ROSE_ALLOC_MEMSET == 1
  122124             :         memset(pointer, 0x00, SgOmpWorkshareStatement::pool_size * sizeof(SgOmpWorkshareStatement));
  122125             : #elif ROSE_ALLOC_MEMSET == 2
  122126             :         memset(pointer, 0xCC, SgOmpWorkshareStatement::pool_size * sizeof(SgOmpWorkshareStatement));
  122127             : #endif
  122128           0 :         SgOmpWorkshareStatement::pools.push_back( (unsigned char*)(pointer) );
  122129           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpWorkshareStatement::pool_size * sizeof(SgOmpWorkshareStatement), V_SgOmpWorkshareStatement ) );
  122130             : 
  122131           0 :         if ( SgOmpWorkshareStatement::next_node != NULL ) {
  122132           0 :           if ( blockIndex > 0 ) {
  122133           0 :             SgOmpWorkshareStatement * blkptr = (SgOmpWorkshareStatement*)(SgOmpWorkshareStatement::pools[blockIndex-1]);
  122134           0 :             blkptr[ SgOmpWorkshareStatement::pool_size - 1 ].set_freepointer(pointer);
  122135             :           }
  122136             :         } else {
  122137           0 :           SgOmpWorkshareStatement::next_node = pointer;
  122138             :         }
  122139             : 
  122140           0 :         for (unsigned i = 0; i < SgOmpWorkshareStatement::pool_size-1; ++i)
  122141             :            {
  122142           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  122143             :            }
  122144           0 :         pointer[ SgOmpWorkshareStatement::pool_size -1 ].set_freepointer(NULL);
  122145             : 
  122146           0 :         blockIndex++;
  122147             :       }
  122148           2 :   }
  122149             : 
  122150             : //############################################################################
  122151             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  122152             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  122153             :  * not compressed. However, that stuff is not yet implemented! 
  122154             :  */
  122155             : unsigned long
  122156           0 : SgOmpWorkshareStatement::getNumberOfLastValidPointer()
  122157             :    {
  122158           0 :       SgOmpWorkshareStatement* testPointer = (SgOmpWorkshareStatement*)(SgOmpWorkshareStatement::pools.back());
  122159           0 :       unsigned long localIndex = SgOmpWorkshareStatement::pool_size - 1;
  122160           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  122161             :          {
  122162           0 :            localIndex--;
  122163             :          }
  122164           0 :       return (localIndex + SgOmpWorkshareStatement::pool_size * (SgOmpWorkshareStatement::pools.size()-1));
  122165             :    }
  122166             : 
  122167             : //############################################################################
  122168             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  122169             :  * memory pool and initializes the data member in class SgOmpWorkshareStatementStroageClass
  122170             :  * from its counterpart of SgOmpWorkshareStatement. The return value is just for checking, 
  122171             :  * that the whole StorageClassArray is initialized!
  122172             :  */
  122173             : unsigned long
  122174           0 : SgOmpWorkshareStatement::initializeStorageClassArray( SgOmpWorkshareStatementStorageClass *storageArray )
  122175             :    {
  122176           0 :      unsigned long storageCounter = 0;
  122177           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpWorkshareStatement::pools.begin();
  122178           0 :      SgOmpWorkshareStatement* pointer = NULL;
  122179           0 :      while ( block != SgOmpWorkshareStatement::pools.end() ) {
  122180           0 :           pointer = (SgOmpWorkshareStatement*) (*block);
  122181           0 :           for ( unsigned i = 0; i < SgOmpWorkshareStatement::pool_size; ++i ) {
  122182           0 :                if ( pointer->get_freepointer() != NULL ) {
  122183           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  122184           0 :                  storageArray++;
  122185           0 :                  storageCounter++;
  122186             :                }
  122187           0 :                pointer++;
  122188             :              }
  122189           0 :            block++;
  122190             :         }
  122191           0 :      return storageCounter;
  122192             :    }
  122193             : 
  122194             : /* #line 122195 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  122195             : 
  122196             : 
  122197             : 
  122198             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  122199             : 
  122200             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  122201             : 
  122202             : //############################################################################
  122203             : /* JH (02/02/2006) Constructor of the IR node SgUpirFieldBodyStatement that takes its 
  122204             :  * corresponding StorageClass as parameter
  122205             :  */
  122206           0 : SgUpirFieldBodyStatement :: SgUpirFieldBodyStatement ( const SgUpirFieldBodyStatementStorageClass& storageSource )   : SgUpirBodyStatement (storageSource)
  122207             :    {
  122208             : 
  122209             : 
  122210             : /* #line 122211 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  122211             : 
  122212           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  122213           0 :      p_clauses = storageSource.storageOf_clauses.rebuildDataStoredInEasyStorageClass() ;
  122214           0 :      SgOmpClausePtrList::iterator i_clauses = p_clauses.begin() ; 
  122215           0 :      for ( ; i_clauses != p_clauses.end(); ++i_clauses ) 
  122216             :         {
  122217           0 :           (*i_clauses) = (SgOmpClausePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_clauses) ) );
  122218             :         }
  122219             : 
  122220             : 
  122221             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  122222             : 
  122223             : 
  122224           0 :    }
  122225             : 
  122226             : //############################################################################
  122227             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  122228             :  * within the working AST. 
  122229             :  */
  122230           0 : SgUpirFieldBodyStatement * SgUpirFieldBodyStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  122231           0 :      SgUpirFieldBodyStatement* returnPointer = NULL;
  122232           0 :      if ( globalIndex != 0 )
  122233             :         {
  122234             : 
  122235             : #if FILE_IO_EXTRA_CHECK
  122236           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirFieldBodyStatement ) ) <= globalIndex ) ;
  122237           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirFieldBodyStatement + 1 ) ) );
  122238             : #endif
  122239           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirFieldBodyStatement )  
  122240           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirFieldBodyStatement );
  122241           0 :           unsigned long positionInPool = localIndex % SgUpirFieldBodyStatement::pool_size;
  122242           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirFieldBodyStatement::pool_size;
  122243             : 
  122244             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  122245             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  122246             : 
  122247           0 :           returnPointer = &( ( (SgUpirFieldBodyStatement*)(SgUpirFieldBodyStatement::pools[memoryBlock]) ) [positionInPool]) ;
  122248             : 
  122249           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  122250             :         }
  122251           0 :      return returnPointer ;
  122252             :    }
  122253             : 
  122254             : //############################################################################
  122255             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  122256             :   for the AST with the index astIndex
  122257             : */
  122258           0 : SgUpirFieldBodyStatement * SgUpirFieldBodyStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  122259           0 :      SgUpirFieldBodyStatement* returnPointer = NULL;
  122260           0 :      if ( globalIndex != 0 )
  122261             :         {
  122262             : 
  122263             : #if FILE_IO_EXTRA_CHECK
  122264           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirFieldBodyStatement ) ) <= globalIndex ) ;
  122265           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirFieldBodyStatement + 1 ) ) );
  122266             : #endif
  122267           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirFieldBodyStatement )
  122268           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirFieldBodyStatement );
  122269           0 :           unsigned long positionInPool = localIndex % SgUpirFieldBodyStatement::pool_size ;
  122270           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirFieldBodyStatement::pool_size ;
  122271             : 
  122272             : #if FILE_IO_EXTRA_CHECK
  122273             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  122274             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  122275             : #endif
  122276             : 
  122277           0 :           returnPointer = &( ( (SgUpirFieldBodyStatement*)(SgUpirFieldBodyStatement::pools[memoryBlock]) ) [positionInPool]) ;
  122278             : 
  122279             : #if FILE_IO_EXTRA_CHECK
  122280           0 :           assert ( returnPointer != NULL ) ;
  122281             : #endif
  122282             :         }
  122283           0 :      return returnPointer ;
  122284             :    }
  122285             : 
  122286             : //############################################################################
  122287             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  122288             :  * pool size! We set for every valid object in the memory pool the freepointer
  122289             :  * to the global index and increase the global index afterwards. For all the 
  122290             :  * invalid objects (means address ranges within the memory pool that were not
  122291             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  122292             :  * distinguish valid from invalid objects! 
  122293             :  */
  122294             : unsigned long
  122295           5 : SgUpirFieldBodyStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  122296             :    {
  122297           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  122298           5 :      SgUpirFieldBodyStatement* pointer = NULL;
  122299           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  122300           5 :      std::vector < unsigned char* > :: const_iterator block;
  122301           5 :      for ( block = SgUpirFieldBodyStatement::pools.begin(); block != SgUpirFieldBodyStatement::pools.end() ; ++block )
  122302             :         {
  122303           0 :           pointer = (SgUpirFieldBodyStatement*)(*block);
  122304           0 :           for (unsigned i = 0; i < SgUpirFieldBodyStatement::pool_size; ++i )
  122305             :              {
  122306             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  122307             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  122308             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  122309             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  122310             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  122311             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  122312             :             // properly; so this will have to be checked next.
  122313             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  122314             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  122315           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  122316             :                   {
  122317           0 :                     pointer[i].set_freepointer((SgUpirFieldBodyStatement*)(globalIndex));
  122318           0 :                     globalIndex++;
  122319             :                   }
  122320             :                else
  122321             :                   {
  122322           0 :                     pointer[i].set_freepointer(NULL);
  122323             :                   }
  122324             :               }
  122325             :         }
  122326           5 :      return globalIndex;
  122327             :    }
  122328             : 
  122329             : //############################################################################
  122330             : // JH (01/14/2006)
  122331             : void
  122332           5 : SgUpirFieldBodyStatement::resetValidFreepointers( )
  122333             :    {
  122334           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  122335           5 :      SgUpirFieldBodyStatement* pointer = NULL;
  122336           5 :      std::vector < unsigned char* > :: const_iterator block;
  122337           5 :      SgUpirFieldBodyStatement* pointerOfLinkedList = NULL;
  122338           5 :      for ( block = SgUpirFieldBodyStatement::pools.begin(); block != SgUpirFieldBodyStatement::pools.end() ; ++block )
  122339             :         {
  122340           0 :           pointer = (SgUpirFieldBodyStatement*)(*block);
  122341           0 :           for (unsigned i = 0; i < SgUpirFieldBodyStatement::pool_size; ++i )
  122342             :              {
  122343             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  122344             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  122345             :             // memory blocks!.
  122346           0 :                if ( pointer[i].get_freepointer() != NULL )
  122347             :                   {
  122348           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  122349             :                   }
  122350             :                else
  122351             :                   {
  122352           0 :                     if ( pointerOfLinkedList == NULL )
  122353             :                        {
  122354           0 :                          SgUpirFieldBodyStatement::next_node = &(pointer[i]);
  122355             :                        }
  122356             :                     else
  122357             :                        {
  122358             :                       // printf ("In SgUpirFieldBodyStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  122359           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  122360             :                        }
  122361             :                     pointerOfLinkedList = &(pointer[i]);
  122362             :                   }
  122363             :               }
  122364             :         }
  122365             : 
  122366           5 :      if ( pointerOfLinkedList != NULL )
  122367             :         {
  122368             :        // printf ("In SgUpirFieldBodyStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  122369           0 :           pointerOfLinkedList->set_freepointer(NULL);
  122370             :        // DQ (6/6/2010): Temporary debugging...
  122371             :        //   ROSE_ASSERT(false);
  122372             :         }
  122373             : 
  122374           5 :      return ;
  122375             :    }
  122376             : 
  122377             : //############################################################################
  122378             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  122379             :  * within the memory pool and resets the freepointers, in order to achieve a 
  122380             :  * linked list, that has no jumps and starts at the beginning! This function 
  122381             :  * does not extend the memory pool, since we do not delete any memory blocks,
  122382             :  * but delete the valid objects.  
  122383             :  */
  122384             : void
  122385           0 : SgUpirFieldBodyStatement::clearMemoryPool( )
  122386             :    {
  122387             :   // printf ("Inside of SgUpirFieldBodyStatement::clearMemoryPool() \n");
  122388             : 
  122389           0 :      SgUpirFieldBodyStatement* pointer = NULL, *tempPointer = NULL;
  122390           0 :      std::vector < unsigned char* > :: const_iterator block;
  122391           0 :      if ( SgUpirFieldBodyStatement::pools.empty() == false )
  122392             :         {
  122393           0 :           block = SgUpirFieldBodyStatement::pools.begin() ;
  122394           0 :           SgUpirFieldBodyStatement::next_node = (SgUpirFieldBodyStatement*) (*block);
  122395             : 
  122396           0 :           while ( block != SgUpirFieldBodyStatement::pools.end() )
  122397             :              {
  122398           0 :                pointer = (SgUpirFieldBodyStatement*) (*block);
  122399           0 :                if ( tempPointer != NULL )
  122400             :                   {
  122401           0 :                     tempPointer->set_freepointer(pointer);
  122402             :                   }
  122403           0 :                for (unsigned i = 0; i < SgUpirFieldBodyStatement::pool_size - 1; ++i)
  122404             :                   {
  122405           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  122406             :                   }
  122407           0 :                 pointer[SgUpirFieldBodyStatement::pool_size-1].set_freepointer(NULL);
  122408           0 :                 tempPointer = &(pointer[SgUpirFieldBodyStatement::pool_size-1]);
  122409           0 :                 ++block;
  122410             :              }
  122411             :         }
  122412           0 :    }
  122413             : 
  122414           5 : void SgUpirFieldBodyStatement::deleteMemoryPool() {
  122415           5 :   for (auto p: SgUpirFieldBodyStatement::pools) {
  122416           0 :     ROSE_FREE(p);
  122417             :   }
  122418           5 :   SgUpirFieldBodyStatement::next_node = nullptr;
  122419           5 :   SgUpirFieldBodyStatement::pools.clear();
  122420           5 : }
  122421             : 
  122422             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  122423             : //                 reading multiple binary files to for a single AST.
  122424             : /////////// new version ////////////////////////////////
  122425             : //############################################################################
  122426             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  122427             : void
  122428           2 : SgUpirFieldBodyStatement::extendMemoryPoolForFileIO( )
  122429             :   {
  122430           2 :     size_t blockIndex = SgUpirFieldBodyStatement::pools.size();
  122431           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirFieldBodyStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirFieldBodyStatement);
  122432             : 
  122433           2 :     while ( (blockIndex * SgUpirFieldBodyStatement::pool_size) < newPoolSize)
  122434             :       {
  122435             : #if ROSE_ALLOC_TRACE
  122436             :         if (blockIndex > 0) {
  122437             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirFieldBodyStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirFieldBodyStatement) = %" PRIuPTR " SgUpirFieldBodyStatement::pool_size = %d \n",
  122438             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirFieldBodyStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirFieldBodyStatement),SgUpirFieldBodyStatement::pool_size);
  122439             :         }
  122440             : #endif
  122441             : 
  122442           0 :         SgUpirFieldBodyStatement * pointer = (SgUpirFieldBodyStatement*) ROSE_MALLOC ( SgUpirFieldBodyStatement::pool_size * sizeof(SgUpirFieldBodyStatement) );
  122443           0 :         assert( pointer != NULL );
  122444             : #if ROSE_ALLOC_MEMSET == 1
  122445             :         memset(pointer, 0x00, SgUpirFieldBodyStatement::pool_size * sizeof(SgUpirFieldBodyStatement));
  122446             : #elif ROSE_ALLOC_MEMSET == 2
  122447             :         memset(pointer, 0xCC, SgUpirFieldBodyStatement::pool_size * sizeof(SgUpirFieldBodyStatement));
  122448             : #endif
  122449           0 :         SgUpirFieldBodyStatement::pools.push_back( (unsigned char*)(pointer) );
  122450           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirFieldBodyStatement::pool_size * sizeof(SgUpirFieldBodyStatement), V_SgUpirFieldBodyStatement ) );
  122451             : 
  122452           0 :         if ( SgUpirFieldBodyStatement::next_node != NULL ) {
  122453           0 :           if ( blockIndex > 0 ) {
  122454           0 :             SgUpirFieldBodyStatement * blkptr = (SgUpirFieldBodyStatement*)(SgUpirFieldBodyStatement::pools[blockIndex-1]);
  122455           0 :             blkptr[ SgUpirFieldBodyStatement::pool_size - 1 ].set_freepointer(pointer);
  122456             :           }
  122457             :         } else {
  122458           0 :           SgUpirFieldBodyStatement::next_node = pointer;
  122459             :         }
  122460             : 
  122461           0 :         for (unsigned i = 0; i < SgUpirFieldBodyStatement::pool_size-1; ++i)
  122462             :            {
  122463           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  122464             :            }
  122465           0 :         pointer[ SgUpirFieldBodyStatement::pool_size -1 ].set_freepointer(NULL);
  122466             : 
  122467           0 :         blockIndex++;
  122468             :       }
  122469           2 :   }
  122470             : 
  122471             : //############################################################################
  122472             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  122473             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  122474             :  * not compressed. However, that stuff is not yet implemented! 
  122475             :  */
  122476             : unsigned long
  122477           0 : SgUpirFieldBodyStatement::getNumberOfLastValidPointer()
  122478             :    {
  122479           0 :       SgUpirFieldBodyStatement* testPointer = (SgUpirFieldBodyStatement*)(SgUpirFieldBodyStatement::pools.back());
  122480           0 :       unsigned long localIndex = SgUpirFieldBodyStatement::pool_size - 1;
  122481           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  122482             :          {
  122483           0 :            localIndex--;
  122484             :          }
  122485           0 :       return (localIndex + SgUpirFieldBodyStatement::pool_size * (SgUpirFieldBodyStatement::pools.size()-1));
  122486             :    }
  122487             : 
  122488             : //############################################################################
  122489             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  122490             :  * memory pool and initializes the data member in class SgUpirFieldBodyStatementStroageClass
  122491             :  * from its counterpart of SgUpirFieldBodyStatement. The return value is just for checking, 
  122492             :  * that the whole StorageClassArray is initialized!
  122493             :  */
  122494             : unsigned long
  122495           0 : SgUpirFieldBodyStatement::initializeStorageClassArray( SgUpirFieldBodyStatementStorageClass *storageArray )
  122496             :    {
  122497           0 :      unsigned long storageCounter = 0;
  122498           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirFieldBodyStatement::pools.begin();
  122499           0 :      SgUpirFieldBodyStatement* pointer = NULL;
  122500           0 :      while ( block != SgUpirFieldBodyStatement::pools.end() ) {
  122501           0 :           pointer = (SgUpirFieldBodyStatement*) (*block);
  122502           0 :           for ( unsigned i = 0; i < SgUpirFieldBodyStatement::pool_size; ++i ) {
  122503           0 :                if ( pointer->get_freepointer() != NULL ) {
  122504           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  122505           0 :                  storageArray++;
  122506           0 :                  storageCounter++;
  122507             :                }
  122508           0 :                pointer++;
  122509             :              }
  122510           0 :            block++;
  122511             :         }
  122512           0 :      return storageCounter;
  122513             :    }
  122514             : 
  122515             : /* #line 122516 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  122516             : 
  122517             : 
  122518             : 
  122519             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  122520             : 
  122521             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  122522             : 
  122523             : //############################################################################
  122524             : /* JH (02/02/2006) Constructor of the IR node SgUpirSpmdStatement that takes its 
  122525             :  * corresponding StorageClass as parameter
  122526             :  */
  122527           0 : SgUpirSpmdStatement :: SgUpirSpmdStatement ( const SgUpirSpmdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  122528             :    {
  122529             : 
  122530             : 
  122531             : /* #line 122532 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  122532             : 
  122533           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  122534             : 
  122535             : 
  122536             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  122537             : 
  122538             : 
  122539           0 :    }
  122540             : 
  122541             : //############################################################################
  122542             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  122543             :  * within the working AST. 
  122544             :  */
  122545           0 : SgUpirSpmdStatement * SgUpirSpmdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  122546           0 :      SgUpirSpmdStatement* returnPointer = NULL;
  122547           0 :      if ( globalIndex != 0 )
  122548             :         {
  122549             : 
  122550             : #if FILE_IO_EXTRA_CHECK
  122551           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirSpmdStatement ) ) <= globalIndex ) ;
  122552           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirSpmdStatement + 1 ) ) );
  122553             : #endif
  122554           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirSpmdStatement )  
  122555           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirSpmdStatement );
  122556           0 :           unsigned long positionInPool = localIndex % SgUpirSpmdStatement::pool_size;
  122557           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirSpmdStatement::pool_size;
  122558             : 
  122559             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  122560             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  122561             : 
  122562           0 :           returnPointer = &( ( (SgUpirSpmdStatement*)(SgUpirSpmdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  122563             : 
  122564           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  122565             :         }
  122566           0 :      return returnPointer ;
  122567             :    }
  122568             : 
  122569             : //############################################################################
  122570             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  122571             :   for the AST with the index astIndex
  122572             : */
  122573           0 : SgUpirSpmdStatement * SgUpirSpmdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  122574           0 :      SgUpirSpmdStatement* returnPointer = NULL;
  122575           0 :      if ( globalIndex != 0 )
  122576             :         {
  122577             : 
  122578             : #if FILE_IO_EXTRA_CHECK
  122579           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirSpmdStatement ) ) <= globalIndex ) ;
  122580           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirSpmdStatement + 1 ) ) );
  122581             : #endif
  122582           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirSpmdStatement )
  122583           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirSpmdStatement );
  122584           0 :           unsigned long positionInPool = localIndex % SgUpirSpmdStatement::pool_size ;
  122585           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirSpmdStatement::pool_size ;
  122586             : 
  122587             : #if FILE_IO_EXTRA_CHECK
  122588             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  122589             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  122590             : #endif
  122591             : 
  122592           0 :           returnPointer = &( ( (SgUpirSpmdStatement*)(SgUpirSpmdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  122593             : 
  122594             : #if FILE_IO_EXTRA_CHECK
  122595           0 :           assert ( returnPointer != NULL ) ;
  122596             : #endif
  122597             :         }
  122598           0 :      return returnPointer ;
  122599             :    }
  122600             : 
  122601             : //############################################################################
  122602             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  122603             :  * pool size! We set for every valid object in the memory pool the freepointer
  122604             :  * to the global index and increase the global index afterwards. For all the 
  122605             :  * invalid objects (means address ranges within the memory pool that were not
  122606             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  122607             :  * distinguish valid from invalid objects! 
  122608             :  */
  122609             : unsigned long
  122610           5 : SgUpirSpmdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  122611             :    {
  122612           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  122613           5 :      SgUpirSpmdStatement* pointer = NULL;
  122614           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  122615           5 :      std::vector < unsigned char* > :: const_iterator block;
  122616           5 :      for ( block = SgUpirSpmdStatement::pools.begin(); block != SgUpirSpmdStatement::pools.end() ; ++block )
  122617             :         {
  122618           0 :           pointer = (SgUpirSpmdStatement*)(*block);
  122619           0 :           for (unsigned i = 0; i < SgUpirSpmdStatement::pool_size; ++i )
  122620             :              {
  122621             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  122622             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  122623             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  122624             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  122625             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  122626             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  122627             :             // properly; so this will have to be checked next.
  122628             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  122629             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  122630           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  122631             :                   {
  122632           0 :                     pointer[i].set_freepointer((SgUpirSpmdStatement*)(globalIndex));
  122633           0 :                     globalIndex++;
  122634             :                   }
  122635             :                else
  122636             :                   {
  122637           0 :                     pointer[i].set_freepointer(NULL);
  122638             :                   }
  122639             :               }
  122640             :         }
  122641           5 :      return globalIndex;
  122642             :    }
  122643             : 
  122644             : //############################################################################
  122645             : // JH (01/14/2006)
  122646             : void
  122647           5 : SgUpirSpmdStatement::resetValidFreepointers( )
  122648             :    {
  122649           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  122650           5 :      SgUpirSpmdStatement* pointer = NULL;
  122651           5 :      std::vector < unsigned char* > :: const_iterator block;
  122652           5 :      SgUpirSpmdStatement* pointerOfLinkedList = NULL;
  122653           5 :      for ( block = SgUpirSpmdStatement::pools.begin(); block != SgUpirSpmdStatement::pools.end() ; ++block )
  122654             :         {
  122655           0 :           pointer = (SgUpirSpmdStatement*)(*block);
  122656           0 :           for (unsigned i = 0; i < SgUpirSpmdStatement::pool_size; ++i )
  122657             :              {
  122658             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  122659             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  122660             :             // memory blocks!.
  122661           0 :                if ( pointer[i].get_freepointer() != NULL )
  122662             :                   {
  122663           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  122664             :                   }
  122665             :                else
  122666             :                   {
  122667           0 :                     if ( pointerOfLinkedList == NULL )
  122668             :                        {
  122669           0 :                          SgUpirSpmdStatement::next_node = &(pointer[i]);
  122670             :                        }
  122671             :                     else
  122672             :                        {
  122673             :                       // printf ("In SgUpirSpmdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  122674           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  122675             :                        }
  122676             :                     pointerOfLinkedList = &(pointer[i]);
  122677             :                   }
  122678             :               }
  122679             :         }
  122680             : 
  122681           5 :      if ( pointerOfLinkedList != NULL )
  122682             :         {
  122683             :        // printf ("In SgUpirSpmdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  122684           0 :           pointerOfLinkedList->set_freepointer(NULL);
  122685             :        // DQ (6/6/2010): Temporary debugging...
  122686             :        //   ROSE_ASSERT(false);
  122687             :         }
  122688             : 
  122689           5 :      return ;
  122690             :    }
  122691             : 
  122692             : //############################################################################
  122693             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  122694             :  * within the memory pool and resets the freepointers, in order to achieve a 
  122695             :  * linked list, that has no jumps and starts at the beginning! This function 
  122696             :  * does not extend the memory pool, since we do not delete any memory blocks,
  122697             :  * but delete the valid objects.  
  122698             :  */
  122699             : void
  122700           0 : SgUpirSpmdStatement::clearMemoryPool( )
  122701             :    {
  122702             :   // printf ("Inside of SgUpirSpmdStatement::clearMemoryPool() \n");
  122703             : 
  122704           0 :      SgUpirSpmdStatement* pointer = NULL, *tempPointer = NULL;
  122705           0 :      std::vector < unsigned char* > :: const_iterator block;
  122706           0 :      if ( SgUpirSpmdStatement::pools.empty() == false )
  122707             :         {
  122708           0 :           block = SgUpirSpmdStatement::pools.begin() ;
  122709           0 :           SgUpirSpmdStatement::next_node = (SgUpirSpmdStatement*) (*block);
  122710             : 
  122711           0 :           while ( block != SgUpirSpmdStatement::pools.end() )
  122712             :              {
  122713           0 :                pointer = (SgUpirSpmdStatement*) (*block);
  122714           0 :                if ( tempPointer != NULL )
  122715             :                   {
  122716           0 :                     tempPointer->set_freepointer(pointer);
  122717             :                   }
  122718           0 :                for (unsigned i = 0; i < SgUpirSpmdStatement::pool_size - 1; ++i)
  122719             :                   {
  122720           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  122721             :                   }
  122722           0 :                 pointer[SgUpirSpmdStatement::pool_size-1].set_freepointer(NULL);
  122723           0 :                 tempPointer = &(pointer[SgUpirSpmdStatement::pool_size-1]);
  122724           0 :                 ++block;
  122725             :              }
  122726             :         }
  122727           0 :    }
  122728             : 
  122729           5 : void SgUpirSpmdStatement::deleteMemoryPool() {
  122730           5 :   for (auto p: SgUpirSpmdStatement::pools) {
  122731           0 :     ROSE_FREE(p);
  122732             :   }
  122733           5 :   SgUpirSpmdStatement::next_node = nullptr;
  122734           5 :   SgUpirSpmdStatement::pools.clear();
  122735           5 : }
  122736             : 
  122737             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  122738             : //                 reading multiple binary files to for a single AST.
  122739             : /////////// new version ////////////////////////////////
  122740             : //############################################################################
  122741             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  122742             : void
  122743           2 : SgUpirSpmdStatement::extendMemoryPoolForFileIO( )
  122744             :   {
  122745           2 :     size_t blockIndex = SgUpirSpmdStatement::pools.size();
  122746           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSpmdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSpmdStatement);
  122747             : 
  122748           2 :     while ( (blockIndex * SgUpirSpmdStatement::pool_size) < newPoolSize)
  122749             :       {
  122750             : #if ROSE_ALLOC_TRACE
  122751             :         if (blockIndex > 0) {
  122752             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSpmdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSpmdStatement) = %" PRIuPTR " SgUpirSpmdStatement::pool_size = %d \n",
  122753             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSpmdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSpmdStatement),SgUpirSpmdStatement::pool_size);
  122754             :         }
  122755             : #endif
  122756             : 
  122757           0 :         SgUpirSpmdStatement * pointer = (SgUpirSpmdStatement*) ROSE_MALLOC ( SgUpirSpmdStatement::pool_size * sizeof(SgUpirSpmdStatement) );
  122758           0 :         assert( pointer != NULL );
  122759             : #if ROSE_ALLOC_MEMSET == 1
  122760             :         memset(pointer, 0x00, SgUpirSpmdStatement::pool_size * sizeof(SgUpirSpmdStatement));
  122761             : #elif ROSE_ALLOC_MEMSET == 2
  122762             :         memset(pointer, 0xCC, SgUpirSpmdStatement::pool_size * sizeof(SgUpirSpmdStatement));
  122763             : #endif
  122764           0 :         SgUpirSpmdStatement::pools.push_back( (unsigned char*)(pointer) );
  122765           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirSpmdStatement::pool_size * sizeof(SgUpirSpmdStatement), V_SgUpirSpmdStatement ) );
  122766             : 
  122767           0 :         if ( SgUpirSpmdStatement::next_node != NULL ) {
  122768           0 :           if ( blockIndex > 0 ) {
  122769           0 :             SgUpirSpmdStatement * blkptr = (SgUpirSpmdStatement*)(SgUpirSpmdStatement::pools[blockIndex-1]);
  122770           0 :             blkptr[ SgUpirSpmdStatement::pool_size - 1 ].set_freepointer(pointer);
  122771             :           }
  122772             :         } else {
  122773           0 :           SgUpirSpmdStatement::next_node = pointer;
  122774             :         }
  122775             : 
  122776           0 :         for (unsigned i = 0; i < SgUpirSpmdStatement::pool_size-1; ++i)
  122777             :            {
  122778           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  122779             :            }
  122780           0 :         pointer[ SgUpirSpmdStatement::pool_size -1 ].set_freepointer(NULL);
  122781             : 
  122782           0 :         blockIndex++;
  122783             :       }
  122784           2 :   }
  122785             : 
  122786             : //############################################################################
  122787             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  122788             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  122789             :  * not compressed. However, that stuff is not yet implemented! 
  122790             :  */
  122791             : unsigned long
  122792           0 : SgUpirSpmdStatement::getNumberOfLastValidPointer()
  122793             :    {
  122794           0 :       SgUpirSpmdStatement* testPointer = (SgUpirSpmdStatement*)(SgUpirSpmdStatement::pools.back());
  122795           0 :       unsigned long localIndex = SgUpirSpmdStatement::pool_size - 1;
  122796           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  122797             :          {
  122798           0 :            localIndex--;
  122799             :          }
  122800           0 :       return (localIndex + SgUpirSpmdStatement::pool_size * (SgUpirSpmdStatement::pools.size()-1));
  122801             :    }
  122802             : 
  122803             : //############################################################################
  122804             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  122805             :  * memory pool and initializes the data member in class SgUpirSpmdStatementStroageClass
  122806             :  * from its counterpart of SgUpirSpmdStatement. The return value is just for checking, 
  122807             :  * that the whole StorageClassArray is initialized!
  122808             :  */
  122809             : unsigned long
  122810           0 : SgUpirSpmdStatement::initializeStorageClassArray( SgUpirSpmdStatementStorageClass *storageArray )
  122811             :    {
  122812           0 :      unsigned long storageCounter = 0;
  122813           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirSpmdStatement::pools.begin();
  122814           0 :      SgUpirSpmdStatement* pointer = NULL;
  122815           0 :      while ( block != SgUpirSpmdStatement::pools.end() ) {
  122816           0 :           pointer = (SgUpirSpmdStatement*) (*block);
  122817           0 :           for ( unsigned i = 0; i < SgUpirSpmdStatement::pool_size; ++i ) {
  122818           0 :                if ( pointer->get_freepointer() != NULL ) {
  122819           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  122820           0 :                  storageArray++;
  122821           0 :                  storageCounter++;
  122822             :                }
  122823           0 :                pointer++;
  122824             :              }
  122825           0 :            block++;
  122826             :         }
  122827           0 :      return storageCounter;
  122828             :    }
  122829             : 
  122830             : /* #line 122831 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  122831             : 
  122832             : 
  122833             : 
  122834             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  122835             : 
  122836             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  122837             : 
  122838             : //############################################################################
  122839             : /* JH (02/02/2006) Constructor of the IR node SgOmpTeamsStatement that takes its 
  122840             :  * corresponding StorageClass as parameter
  122841             :  */
  122842           0 : SgOmpTeamsStatement :: SgOmpTeamsStatement ( const SgOmpTeamsStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  122843             :    {
  122844             : 
  122845             : 
  122846             : /* #line 122847 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  122847             : 
  122848           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  122849             : 
  122850             : 
  122851             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  122852             : 
  122853             : 
  122854           0 :    }
  122855             : 
  122856             : //############################################################################
  122857             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  122858             :  * within the working AST. 
  122859             :  */
  122860           0 : SgOmpTeamsStatement * SgOmpTeamsStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  122861           0 :      SgOmpTeamsStatement* returnPointer = NULL;
  122862           0 :      if ( globalIndex != 0 )
  122863             :         {
  122864             : 
  122865             : #if FILE_IO_EXTRA_CHECK
  122866           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTeamsStatement ) ) <= globalIndex ) ;
  122867           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsStatement + 1 ) ) );
  122868             : #endif
  122869           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsStatement )  
  122870           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTeamsStatement );
  122871           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsStatement::pool_size;
  122872           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsStatement::pool_size;
  122873             : 
  122874             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  122875             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  122876             : 
  122877           0 :           returnPointer = &( ( (SgOmpTeamsStatement*)(SgOmpTeamsStatement::pools[memoryBlock]) ) [positionInPool]) ;
  122878             : 
  122879           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  122880             :         }
  122881           0 :      return returnPointer ;
  122882             :    }
  122883             : 
  122884             : //############################################################################
  122885             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  122886             :   for the AST with the index astIndex
  122887             : */
  122888           0 : SgOmpTeamsStatement * SgOmpTeamsStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  122889           0 :      SgOmpTeamsStatement* returnPointer = NULL;
  122890           0 :      if ( globalIndex != 0 )
  122891             :         {
  122892             : 
  122893             : #if FILE_IO_EXTRA_CHECK
  122894           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTeamsStatement ) ) <= globalIndex ) ;
  122895           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsStatement + 1 ) ) );
  122896             : #endif
  122897           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsStatement )
  122898           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTeamsStatement );
  122899           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsStatement::pool_size ;
  122900           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsStatement::pool_size ;
  122901             : 
  122902             : #if FILE_IO_EXTRA_CHECK
  122903             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  122904             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  122905             : #endif
  122906             : 
  122907           0 :           returnPointer = &( ( (SgOmpTeamsStatement*)(SgOmpTeamsStatement::pools[memoryBlock]) ) [positionInPool]) ;
  122908             : 
  122909             : #if FILE_IO_EXTRA_CHECK
  122910           0 :           assert ( returnPointer != NULL ) ;
  122911             : #endif
  122912             :         }
  122913           0 :      return returnPointer ;
  122914             :    }
  122915             : 
  122916             : //############################################################################
  122917             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  122918             :  * pool size! We set for every valid object in the memory pool the freepointer
  122919             :  * to the global index and increase the global index afterwards. For all the 
  122920             :  * invalid objects (means address ranges within the memory pool that were not
  122921             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  122922             :  * distinguish valid from invalid objects! 
  122923             :  */
  122924             : unsigned long
  122925           5 : SgOmpTeamsStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  122926             :    {
  122927           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  122928           5 :      SgOmpTeamsStatement* pointer = NULL;
  122929           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  122930           5 :      std::vector < unsigned char* > :: const_iterator block;
  122931           5 :      for ( block = SgOmpTeamsStatement::pools.begin(); block != SgOmpTeamsStatement::pools.end() ; ++block )
  122932             :         {
  122933           0 :           pointer = (SgOmpTeamsStatement*)(*block);
  122934           0 :           for (unsigned i = 0; i < SgOmpTeamsStatement::pool_size; ++i )
  122935             :              {
  122936             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  122937             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  122938             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  122939             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  122940             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  122941             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  122942             :             // properly; so this will have to be checked next.
  122943             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  122944             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  122945           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  122946             :                   {
  122947           0 :                     pointer[i].set_freepointer((SgOmpTeamsStatement*)(globalIndex));
  122948           0 :                     globalIndex++;
  122949             :                   }
  122950             :                else
  122951             :                   {
  122952           0 :                     pointer[i].set_freepointer(NULL);
  122953             :                   }
  122954             :               }
  122955             :         }
  122956           5 :      return globalIndex;
  122957             :    }
  122958             : 
  122959             : //############################################################################
  122960             : // JH (01/14/2006)
  122961             : void
  122962           5 : SgOmpTeamsStatement::resetValidFreepointers( )
  122963             :    {
  122964           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  122965           5 :      SgOmpTeamsStatement* pointer = NULL;
  122966           5 :      std::vector < unsigned char* > :: const_iterator block;
  122967           5 :      SgOmpTeamsStatement* pointerOfLinkedList = NULL;
  122968           5 :      for ( block = SgOmpTeamsStatement::pools.begin(); block != SgOmpTeamsStatement::pools.end() ; ++block )
  122969             :         {
  122970           0 :           pointer = (SgOmpTeamsStatement*)(*block);
  122971           0 :           for (unsigned i = 0; i < SgOmpTeamsStatement::pool_size; ++i )
  122972             :              {
  122973             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  122974             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  122975             :             // memory blocks!.
  122976           0 :                if ( pointer[i].get_freepointer() != NULL )
  122977             :                   {
  122978           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  122979             :                   }
  122980             :                else
  122981             :                   {
  122982           0 :                     if ( pointerOfLinkedList == NULL )
  122983             :                        {
  122984           0 :                          SgOmpTeamsStatement::next_node = &(pointer[i]);
  122985             :                        }
  122986             :                     else
  122987             :                        {
  122988             :                       // printf ("In SgOmpTeamsStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  122989           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  122990             :                        }
  122991             :                     pointerOfLinkedList = &(pointer[i]);
  122992             :                   }
  122993             :               }
  122994             :         }
  122995             : 
  122996           5 :      if ( pointerOfLinkedList != NULL )
  122997             :         {
  122998             :        // printf ("In SgOmpTeamsStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  122999           0 :           pointerOfLinkedList->set_freepointer(NULL);
  123000             :        // DQ (6/6/2010): Temporary debugging...
  123001             :        //   ROSE_ASSERT(false);
  123002             :         }
  123003             : 
  123004           5 :      return ;
  123005             :    }
  123006             : 
  123007             : //############################################################################
  123008             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  123009             :  * within the memory pool and resets the freepointers, in order to achieve a 
  123010             :  * linked list, that has no jumps and starts at the beginning! This function 
  123011             :  * does not extend the memory pool, since we do not delete any memory blocks,
  123012             :  * but delete the valid objects.  
  123013             :  */
  123014             : void
  123015           0 : SgOmpTeamsStatement::clearMemoryPool( )
  123016             :    {
  123017             :   // printf ("Inside of SgOmpTeamsStatement::clearMemoryPool() \n");
  123018             : 
  123019           0 :      SgOmpTeamsStatement* pointer = NULL, *tempPointer = NULL;
  123020           0 :      std::vector < unsigned char* > :: const_iterator block;
  123021           0 :      if ( SgOmpTeamsStatement::pools.empty() == false )
  123022             :         {
  123023           0 :           block = SgOmpTeamsStatement::pools.begin() ;
  123024           0 :           SgOmpTeamsStatement::next_node = (SgOmpTeamsStatement*) (*block);
  123025             : 
  123026           0 :           while ( block != SgOmpTeamsStatement::pools.end() )
  123027             :              {
  123028           0 :                pointer = (SgOmpTeamsStatement*) (*block);
  123029           0 :                if ( tempPointer != NULL )
  123030             :                   {
  123031           0 :                     tempPointer->set_freepointer(pointer);
  123032             :                   }
  123033           0 :                for (unsigned i = 0; i < SgOmpTeamsStatement::pool_size - 1; ++i)
  123034             :                   {
  123035           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  123036             :                   }
  123037           0 :                 pointer[SgOmpTeamsStatement::pool_size-1].set_freepointer(NULL);
  123038           0 :                 tempPointer = &(pointer[SgOmpTeamsStatement::pool_size-1]);
  123039           0 :                 ++block;
  123040             :              }
  123041             :         }
  123042           0 :    }
  123043             : 
  123044           5 : void SgOmpTeamsStatement::deleteMemoryPool() {
  123045           5 :   for (auto p: SgOmpTeamsStatement::pools) {
  123046           0 :     ROSE_FREE(p);
  123047             :   }
  123048           5 :   SgOmpTeamsStatement::next_node = nullptr;
  123049           5 :   SgOmpTeamsStatement::pools.clear();
  123050           5 : }
  123051             : 
  123052             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  123053             : //                 reading multiple binary files to for a single AST.
  123054             : /////////// new version ////////////////////////////////
  123055             : //############################################################################
  123056             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  123057             : void
  123058           2 : SgOmpTeamsStatement::extendMemoryPoolForFileIO( )
  123059             :   {
  123060           2 :     size_t blockIndex = SgOmpTeamsStatement::pools.size();
  123061           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsStatement);
  123062             : 
  123063           2 :     while ( (blockIndex * SgOmpTeamsStatement::pool_size) < newPoolSize)
  123064             :       {
  123065             : #if ROSE_ALLOC_TRACE
  123066             :         if (blockIndex > 0) {
  123067             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsStatement) = %" PRIuPTR " SgOmpTeamsStatement::pool_size = %d \n",
  123068             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsStatement),SgOmpTeamsStatement::pool_size);
  123069             :         }
  123070             : #endif
  123071             : 
  123072           0 :         SgOmpTeamsStatement * pointer = (SgOmpTeamsStatement*) ROSE_MALLOC ( SgOmpTeamsStatement::pool_size * sizeof(SgOmpTeamsStatement) );
  123073           0 :         assert( pointer != NULL );
  123074             : #if ROSE_ALLOC_MEMSET == 1
  123075             :         memset(pointer, 0x00, SgOmpTeamsStatement::pool_size * sizeof(SgOmpTeamsStatement));
  123076             : #elif ROSE_ALLOC_MEMSET == 2
  123077             :         memset(pointer, 0xCC, SgOmpTeamsStatement::pool_size * sizeof(SgOmpTeamsStatement));
  123078             : #endif
  123079           0 :         SgOmpTeamsStatement::pools.push_back( (unsigned char*)(pointer) );
  123080           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTeamsStatement::pool_size * sizeof(SgOmpTeamsStatement), V_SgOmpTeamsStatement ) );
  123081             : 
  123082           0 :         if ( SgOmpTeamsStatement::next_node != NULL ) {
  123083           0 :           if ( blockIndex > 0 ) {
  123084           0 :             SgOmpTeamsStatement * blkptr = (SgOmpTeamsStatement*)(SgOmpTeamsStatement::pools[blockIndex-1]);
  123085           0 :             blkptr[ SgOmpTeamsStatement::pool_size - 1 ].set_freepointer(pointer);
  123086             :           }
  123087             :         } else {
  123088           0 :           SgOmpTeamsStatement::next_node = pointer;
  123089             :         }
  123090             : 
  123091           0 :         for (unsigned i = 0; i < SgOmpTeamsStatement::pool_size-1; ++i)
  123092             :            {
  123093           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  123094             :            }
  123095           0 :         pointer[ SgOmpTeamsStatement::pool_size -1 ].set_freepointer(NULL);
  123096             : 
  123097           0 :         blockIndex++;
  123098             :       }
  123099           2 :   }
  123100             : 
  123101             : //############################################################################
  123102             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  123103             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  123104             :  * not compressed. However, that stuff is not yet implemented! 
  123105             :  */
  123106             : unsigned long
  123107           0 : SgOmpTeamsStatement::getNumberOfLastValidPointer()
  123108             :    {
  123109           0 :       SgOmpTeamsStatement* testPointer = (SgOmpTeamsStatement*)(SgOmpTeamsStatement::pools.back());
  123110           0 :       unsigned long localIndex = SgOmpTeamsStatement::pool_size - 1;
  123111           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  123112             :          {
  123113           0 :            localIndex--;
  123114             :          }
  123115           0 :       return (localIndex + SgOmpTeamsStatement::pool_size * (SgOmpTeamsStatement::pools.size()-1));
  123116             :    }
  123117             : 
  123118             : //############################################################################
  123119             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  123120             :  * memory pool and initializes the data member in class SgOmpTeamsStatementStroageClass
  123121             :  * from its counterpart of SgOmpTeamsStatement. The return value is just for checking, 
  123122             :  * that the whole StorageClassArray is initialized!
  123123             :  */
  123124             : unsigned long
  123125           0 : SgOmpTeamsStatement::initializeStorageClassArray( SgOmpTeamsStatementStorageClass *storageArray )
  123126             :    {
  123127           0 :      unsigned long storageCounter = 0;
  123128           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTeamsStatement::pools.begin();
  123129           0 :      SgOmpTeamsStatement* pointer = NULL;
  123130           0 :      while ( block != SgOmpTeamsStatement::pools.end() ) {
  123131           0 :           pointer = (SgOmpTeamsStatement*) (*block);
  123132           0 :           for ( unsigned i = 0; i < SgOmpTeamsStatement::pool_size; ++i ) {
  123133           0 :                if ( pointer->get_freepointer() != NULL ) {
  123134           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  123135           0 :                  storageArray++;
  123136           0 :                  storageCounter++;
  123137             :                }
  123138           0 :                pointer++;
  123139             :              }
  123140           0 :            block++;
  123141             :         }
  123142           0 :      return storageCounter;
  123143             :    }
  123144             : 
  123145             : /* #line 123146 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  123146             : 
  123147             : 
  123148             : 
  123149             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  123150             : 
  123151             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  123152             : 
  123153             : //############################################################################
  123154             : /* JH (02/02/2006) Constructor of the IR node SgOmpSingleStatement that takes its 
  123155             :  * corresponding StorageClass as parameter
  123156             :  */
  123157           0 : SgOmpSingleStatement :: SgOmpSingleStatement ( const SgOmpSingleStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  123158             :    {
  123159             : 
  123160             : 
  123161             : /* #line 123162 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  123162             : 
  123163           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  123164             : 
  123165             : 
  123166             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  123167             : 
  123168             : 
  123169           0 :    }
  123170             : 
  123171             : //############################################################################
  123172             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  123173             :  * within the working AST. 
  123174             :  */
  123175           0 : SgOmpSingleStatement * SgOmpSingleStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  123176           0 :      SgOmpSingleStatement* returnPointer = NULL;
  123177           0 :      if ( globalIndex != 0 )
  123178             :         {
  123179             : 
  123180             : #if FILE_IO_EXTRA_CHECK
  123181           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSingleStatement ) ) <= globalIndex ) ;
  123182           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSingleStatement + 1 ) ) );
  123183             : #endif
  123184           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSingleStatement )  
  123185           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSingleStatement );
  123186           0 :           unsigned long positionInPool = localIndex % SgOmpSingleStatement::pool_size;
  123187           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSingleStatement::pool_size;
  123188             : 
  123189             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  123190             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  123191             : 
  123192           0 :           returnPointer = &( ( (SgOmpSingleStatement*)(SgOmpSingleStatement::pools[memoryBlock]) ) [positionInPool]) ;
  123193             : 
  123194           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  123195             :         }
  123196           0 :      return returnPointer ;
  123197             :    }
  123198             : 
  123199             : //############################################################################
  123200             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  123201             :   for the AST with the index astIndex
  123202             : */
  123203           0 : SgOmpSingleStatement * SgOmpSingleStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  123204           0 :      SgOmpSingleStatement* returnPointer = NULL;
  123205           0 :      if ( globalIndex != 0 )
  123206             :         {
  123207             : 
  123208             : #if FILE_IO_EXTRA_CHECK
  123209           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSingleStatement ) ) <= globalIndex ) ;
  123210           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSingleStatement + 1 ) ) );
  123211             : #endif
  123212           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSingleStatement )
  123213           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSingleStatement );
  123214           0 :           unsigned long positionInPool = localIndex % SgOmpSingleStatement::pool_size ;
  123215           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSingleStatement::pool_size ;
  123216             : 
  123217             : #if FILE_IO_EXTRA_CHECK
  123218             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  123219             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  123220             : #endif
  123221             : 
  123222           0 :           returnPointer = &( ( (SgOmpSingleStatement*)(SgOmpSingleStatement::pools[memoryBlock]) ) [positionInPool]) ;
  123223             : 
  123224             : #if FILE_IO_EXTRA_CHECK
  123225           0 :           assert ( returnPointer != NULL ) ;
  123226             : #endif
  123227             :         }
  123228           0 :      return returnPointer ;
  123229             :    }
  123230             : 
  123231             : //############################################################################
  123232             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  123233             :  * pool size! We set for every valid object in the memory pool the freepointer
  123234             :  * to the global index and increase the global index afterwards. For all the 
  123235             :  * invalid objects (means address ranges within the memory pool that were not
  123236             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  123237             :  * distinguish valid from invalid objects! 
  123238             :  */
  123239             : unsigned long
  123240           5 : SgOmpSingleStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  123241             :    {
  123242           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  123243           5 :      SgOmpSingleStatement* pointer = NULL;
  123244           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  123245           5 :      std::vector < unsigned char* > :: const_iterator block;
  123246           5 :      for ( block = SgOmpSingleStatement::pools.begin(); block != SgOmpSingleStatement::pools.end() ; ++block )
  123247             :         {
  123248           0 :           pointer = (SgOmpSingleStatement*)(*block);
  123249           0 :           for (unsigned i = 0; i < SgOmpSingleStatement::pool_size; ++i )
  123250             :              {
  123251             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  123252             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  123253             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  123254             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  123255             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  123256             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  123257             :             // properly; so this will have to be checked next.
  123258             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  123259             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  123260           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  123261             :                   {
  123262           0 :                     pointer[i].set_freepointer((SgOmpSingleStatement*)(globalIndex));
  123263           0 :                     globalIndex++;
  123264             :                   }
  123265             :                else
  123266             :                   {
  123267           0 :                     pointer[i].set_freepointer(NULL);
  123268             :                   }
  123269             :               }
  123270             :         }
  123271           5 :      return globalIndex;
  123272             :    }
  123273             : 
  123274             : //############################################################################
  123275             : // JH (01/14/2006)
  123276             : void
  123277           5 : SgOmpSingleStatement::resetValidFreepointers( )
  123278             :    {
  123279           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  123280           5 :      SgOmpSingleStatement* pointer = NULL;
  123281           5 :      std::vector < unsigned char* > :: const_iterator block;
  123282           5 :      SgOmpSingleStatement* pointerOfLinkedList = NULL;
  123283           5 :      for ( block = SgOmpSingleStatement::pools.begin(); block != SgOmpSingleStatement::pools.end() ; ++block )
  123284             :         {
  123285           0 :           pointer = (SgOmpSingleStatement*)(*block);
  123286           0 :           for (unsigned i = 0; i < SgOmpSingleStatement::pool_size; ++i )
  123287             :              {
  123288             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  123289             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  123290             :             // memory blocks!.
  123291           0 :                if ( pointer[i].get_freepointer() != NULL )
  123292             :                   {
  123293           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  123294             :                   }
  123295             :                else
  123296             :                   {
  123297           0 :                     if ( pointerOfLinkedList == NULL )
  123298             :                        {
  123299           0 :                          SgOmpSingleStatement::next_node = &(pointer[i]);
  123300             :                        }
  123301             :                     else
  123302             :                        {
  123303             :                       // printf ("In SgOmpSingleStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  123304           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  123305             :                        }
  123306             :                     pointerOfLinkedList = &(pointer[i]);
  123307             :                   }
  123308             :               }
  123309             :         }
  123310             : 
  123311           5 :      if ( pointerOfLinkedList != NULL )
  123312             :         {
  123313             :        // printf ("In SgOmpSingleStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  123314           0 :           pointerOfLinkedList->set_freepointer(NULL);
  123315             :        // DQ (6/6/2010): Temporary debugging...
  123316             :        //   ROSE_ASSERT(false);
  123317             :         }
  123318             : 
  123319           5 :      return ;
  123320             :    }
  123321             : 
  123322             : //############################################################################
  123323             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  123324             :  * within the memory pool and resets the freepointers, in order to achieve a 
  123325             :  * linked list, that has no jumps and starts at the beginning! This function 
  123326             :  * does not extend the memory pool, since we do not delete any memory blocks,
  123327             :  * but delete the valid objects.  
  123328             :  */
  123329             : void
  123330           0 : SgOmpSingleStatement::clearMemoryPool( )
  123331             :    {
  123332             :   // printf ("Inside of SgOmpSingleStatement::clearMemoryPool() \n");
  123333             : 
  123334           0 :      SgOmpSingleStatement* pointer = NULL, *tempPointer = NULL;
  123335           0 :      std::vector < unsigned char* > :: const_iterator block;
  123336           0 :      if ( SgOmpSingleStatement::pools.empty() == false )
  123337             :         {
  123338           0 :           block = SgOmpSingleStatement::pools.begin() ;
  123339           0 :           SgOmpSingleStatement::next_node = (SgOmpSingleStatement*) (*block);
  123340             : 
  123341           0 :           while ( block != SgOmpSingleStatement::pools.end() )
  123342             :              {
  123343           0 :                pointer = (SgOmpSingleStatement*) (*block);
  123344           0 :                if ( tempPointer != NULL )
  123345             :                   {
  123346           0 :                     tempPointer->set_freepointer(pointer);
  123347             :                   }
  123348           0 :                for (unsigned i = 0; i < SgOmpSingleStatement::pool_size - 1; ++i)
  123349             :                   {
  123350           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  123351             :                   }
  123352           0 :                 pointer[SgOmpSingleStatement::pool_size-1].set_freepointer(NULL);
  123353           0 :                 tempPointer = &(pointer[SgOmpSingleStatement::pool_size-1]);
  123354           0 :                 ++block;
  123355             :              }
  123356             :         }
  123357           0 :    }
  123358             : 
  123359           5 : void SgOmpSingleStatement::deleteMemoryPool() {
  123360           5 :   for (auto p: SgOmpSingleStatement::pools) {
  123361           0 :     ROSE_FREE(p);
  123362             :   }
  123363           5 :   SgOmpSingleStatement::next_node = nullptr;
  123364           5 :   SgOmpSingleStatement::pools.clear();
  123365           5 : }
  123366             : 
  123367             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  123368             : //                 reading multiple binary files to for a single AST.
  123369             : /////////// new version ////////////////////////////////
  123370             : //############################################################################
  123371             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  123372             : void
  123373           2 : SgOmpSingleStatement::extendMemoryPoolForFileIO( )
  123374             :   {
  123375           2 :     size_t blockIndex = SgOmpSingleStatement::pools.size();
  123376           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSingleStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSingleStatement);
  123377             : 
  123378           2 :     while ( (blockIndex * SgOmpSingleStatement::pool_size) < newPoolSize)
  123379             :       {
  123380             : #if ROSE_ALLOC_TRACE
  123381             :         if (blockIndex > 0) {
  123382             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSingleStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSingleStatement) = %" PRIuPTR " SgOmpSingleStatement::pool_size = %d \n",
  123383             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSingleStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSingleStatement),SgOmpSingleStatement::pool_size);
  123384             :         }
  123385             : #endif
  123386             : 
  123387           0 :         SgOmpSingleStatement * pointer = (SgOmpSingleStatement*) ROSE_MALLOC ( SgOmpSingleStatement::pool_size * sizeof(SgOmpSingleStatement) );
  123388           0 :         assert( pointer != NULL );
  123389             : #if ROSE_ALLOC_MEMSET == 1
  123390             :         memset(pointer, 0x00, SgOmpSingleStatement::pool_size * sizeof(SgOmpSingleStatement));
  123391             : #elif ROSE_ALLOC_MEMSET == 2
  123392             :         memset(pointer, 0xCC, SgOmpSingleStatement::pool_size * sizeof(SgOmpSingleStatement));
  123393             : #endif
  123394           0 :         SgOmpSingleStatement::pools.push_back( (unsigned char*)(pointer) );
  123395           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSingleStatement::pool_size * sizeof(SgOmpSingleStatement), V_SgOmpSingleStatement ) );
  123396             : 
  123397           0 :         if ( SgOmpSingleStatement::next_node != NULL ) {
  123398           0 :           if ( blockIndex > 0 ) {
  123399           0 :             SgOmpSingleStatement * blkptr = (SgOmpSingleStatement*)(SgOmpSingleStatement::pools[blockIndex-1]);
  123400           0 :             blkptr[ SgOmpSingleStatement::pool_size - 1 ].set_freepointer(pointer);
  123401             :           }
  123402             :         } else {
  123403           0 :           SgOmpSingleStatement::next_node = pointer;
  123404             :         }
  123405             : 
  123406           0 :         for (unsigned i = 0; i < SgOmpSingleStatement::pool_size-1; ++i)
  123407             :            {
  123408           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  123409             :            }
  123410           0 :         pointer[ SgOmpSingleStatement::pool_size -1 ].set_freepointer(NULL);
  123411             : 
  123412           0 :         blockIndex++;
  123413             :       }
  123414           2 :   }
  123415             : 
  123416             : //############################################################################
  123417             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  123418             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  123419             :  * not compressed. However, that stuff is not yet implemented! 
  123420             :  */
  123421             : unsigned long
  123422           0 : SgOmpSingleStatement::getNumberOfLastValidPointer()
  123423             :    {
  123424           0 :       SgOmpSingleStatement* testPointer = (SgOmpSingleStatement*)(SgOmpSingleStatement::pools.back());
  123425           0 :       unsigned long localIndex = SgOmpSingleStatement::pool_size - 1;
  123426           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  123427             :          {
  123428           0 :            localIndex--;
  123429             :          }
  123430           0 :       return (localIndex + SgOmpSingleStatement::pool_size * (SgOmpSingleStatement::pools.size()-1));
  123431             :    }
  123432             : 
  123433             : //############################################################################
  123434             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  123435             :  * memory pool and initializes the data member in class SgOmpSingleStatementStroageClass
  123436             :  * from its counterpart of SgOmpSingleStatement. The return value is just for checking, 
  123437             :  * that the whole StorageClassArray is initialized!
  123438             :  */
  123439             : unsigned long
  123440           0 : SgOmpSingleStatement::initializeStorageClassArray( SgOmpSingleStatementStorageClass *storageArray )
  123441             :    {
  123442           0 :      unsigned long storageCounter = 0;
  123443           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSingleStatement::pools.begin();
  123444           0 :      SgOmpSingleStatement* pointer = NULL;
  123445           0 :      while ( block != SgOmpSingleStatement::pools.end() ) {
  123446           0 :           pointer = (SgOmpSingleStatement*) (*block);
  123447           0 :           for ( unsigned i = 0; i < SgOmpSingleStatement::pool_size; ++i ) {
  123448           0 :                if ( pointer->get_freepointer() != NULL ) {
  123449           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  123450           0 :                  storageArray++;
  123451           0 :                  storageCounter++;
  123452             :                }
  123453           0 :                pointer++;
  123454             :              }
  123455           0 :            block++;
  123456             :         }
  123457           0 :      return storageCounter;
  123458             :    }
  123459             : 
  123460             : /* #line 123461 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  123461             : 
  123462             : 
  123463             : 
  123464             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  123465             : 
  123466             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  123467             : 
  123468             : //############################################################################
  123469             : /* JH (02/02/2006) Constructor of the IR node SgOmpAtomicStatement that takes its 
  123470             :  * corresponding StorageClass as parameter
  123471             :  */
  123472           0 : SgOmpAtomicStatement :: SgOmpAtomicStatement ( const SgOmpAtomicStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  123473             :    {
  123474             : 
  123475             : 
  123476             : /* #line 123477 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  123477             : 
  123478           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  123479             : 
  123480             : 
  123481             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  123482             : 
  123483             : 
  123484           0 :    }
  123485             : 
  123486             : //############################################################################
  123487             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  123488             :  * within the working AST. 
  123489             :  */
  123490           0 : SgOmpAtomicStatement * SgOmpAtomicStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  123491           0 :      SgOmpAtomicStatement* returnPointer = NULL;
  123492           0 :      if ( globalIndex != 0 )
  123493             :         {
  123494             : 
  123495             : #if FILE_IO_EXTRA_CHECK
  123496           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAtomicStatement ) ) <= globalIndex ) ;
  123497           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAtomicStatement + 1 ) ) );
  123498             : #endif
  123499           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAtomicStatement )  
  123500           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAtomicStatement );
  123501           0 :           unsigned long positionInPool = localIndex % SgOmpAtomicStatement::pool_size;
  123502           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAtomicStatement::pool_size;
  123503             : 
  123504             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  123505             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  123506             : 
  123507           0 :           returnPointer = &( ( (SgOmpAtomicStatement*)(SgOmpAtomicStatement::pools[memoryBlock]) ) [positionInPool]) ;
  123508             : 
  123509           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  123510             :         }
  123511           0 :      return returnPointer ;
  123512             :    }
  123513             : 
  123514             : //############################################################################
  123515             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  123516             :   for the AST with the index astIndex
  123517             : */
  123518           0 : SgOmpAtomicStatement * SgOmpAtomicStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  123519           0 :      SgOmpAtomicStatement* returnPointer = NULL;
  123520           0 :      if ( globalIndex != 0 )
  123521             :         {
  123522             : 
  123523             : #if FILE_IO_EXTRA_CHECK
  123524           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAtomicStatement ) ) <= globalIndex ) ;
  123525           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAtomicStatement + 1 ) ) );
  123526             : #endif
  123527           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAtomicStatement )
  123528           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAtomicStatement );
  123529           0 :           unsigned long positionInPool = localIndex % SgOmpAtomicStatement::pool_size ;
  123530           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAtomicStatement::pool_size ;
  123531             : 
  123532             : #if FILE_IO_EXTRA_CHECK
  123533             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  123534             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  123535             : #endif
  123536             : 
  123537           0 :           returnPointer = &( ( (SgOmpAtomicStatement*)(SgOmpAtomicStatement::pools[memoryBlock]) ) [positionInPool]) ;
  123538             : 
  123539             : #if FILE_IO_EXTRA_CHECK
  123540           0 :           assert ( returnPointer != NULL ) ;
  123541             : #endif
  123542             :         }
  123543           0 :      return returnPointer ;
  123544             :    }
  123545             : 
  123546             : //############################################################################
  123547             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  123548             :  * pool size! We set for every valid object in the memory pool the freepointer
  123549             :  * to the global index and increase the global index afterwards. For all the 
  123550             :  * invalid objects (means address ranges within the memory pool that were not
  123551             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  123552             :  * distinguish valid from invalid objects! 
  123553             :  */
  123554             : unsigned long
  123555           5 : SgOmpAtomicStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  123556             :    {
  123557           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  123558           5 :      SgOmpAtomicStatement* pointer = NULL;
  123559           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  123560           5 :      std::vector < unsigned char* > :: const_iterator block;
  123561           5 :      for ( block = SgOmpAtomicStatement::pools.begin(); block != SgOmpAtomicStatement::pools.end() ; ++block )
  123562             :         {
  123563           0 :           pointer = (SgOmpAtomicStatement*)(*block);
  123564           0 :           for (unsigned i = 0; i < SgOmpAtomicStatement::pool_size; ++i )
  123565             :              {
  123566             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  123567             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  123568             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  123569             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  123570             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  123571             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  123572             :             // properly; so this will have to be checked next.
  123573             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  123574             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  123575           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  123576             :                   {
  123577           0 :                     pointer[i].set_freepointer((SgOmpAtomicStatement*)(globalIndex));
  123578           0 :                     globalIndex++;
  123579             :                   }
  123580             :                else
  123581             :                   {
  123582           0 :                     pointer[i].set_freepointer(NULL);
  123583             :                   }
  123584             :               }
  123585             :         }
  123586           5 :      return globalIndex;
  123587             :    }
  123588             : 
  123589             : //############################################################################
  123590             : // JH (01/14/2006)
  123591             : void
  123592           5 : SgOmpAtomicStatement::resetValidFreepointers( )
  123593             :    {
  123594           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  123595           5 :      SgOmpAtomicStatement* pointer = NULL;
  123596           5 :      std::vector < unsigned char* > :: const_iterator block;
  123597           5 :      SgOmpAtomicStatement* pointerOfLinkedList = NULL;
  123598           5 :      for ( block = SgOmpAtomicStatement::pools.begin(); block != SgOmpAtomicStatement::pools.end() ; ++block )
  123599             :         {
  123600           0 :           pointer = (SgOmpAtomicStatement*)(*block);
  123601           0 :           for (unsigned i = 0; i < SgOmpAtomicStatement::pool_size; ++i )
  123602             :              {
  123603             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  123604             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  123605             :             // memory blocks!.
  123606           0 :                if ( pointer[i].get_freepointer() != NULL )
  123607             :                   {
  123608           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  123609             :                   }
  123610             :                else
  123611             :                   {
  123612           0 :                     if ( pointerOfLinkedList == NULL )
  123613             :                        {
  123614           0 :                          SgOmpAtomicStatement::next_node = &(pointer[i]);
  123615             :                        }
  123616             :                     else
  123617             :                        {
  123618             :                       // printf ("In SgOmpAtomicStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  123619           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  123620             :                        }
  123621             :                     pointerOfLinkedList = &(pointer[i]);
  123622             :                   }
  123623             :               }
  123624             :         }
  123625             : 
  123626           5 :      if ( pointerOfLinkedList != NULL )
  123627             :         {
  123628             :        // printf ("In SgOmpAtomicStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  123629           0 :           pointerOfLinkedList->set_freepointer(NULL);
  123630             :        // DQ (6/6/2010): Temporary debugging...
  123631             :        //   ROSE_ASSERT(false);
  123632             :         }
  123633             : 
  123634           5 :      return ;
  123635             :    }
  123636             : 
  123637             : //############################################################################
  123638             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  123639             :  * within the memory pool and resets the freepointers, in order to achieve a 
  123640             :  * linked list, that has no jumps and starts at the beginning! This function 
  123641             :  * does not extend the memory pool, since we do not delete any memory blocks,
  123642             :  * but delete the valid objects.  
  123643             :  */
  123644             : void
  123645           0 : SgOmpAtomicStatement::clearMemoryPool( )
  123646             :    {
  123647             :   // printf ("Inside of SgOmpAtomicStatement::clearMemoryPool() \n");
  123648             : 
  123649           0 :      SgOmpAtomicStatement* pointer = NULL, *tempPointer = NULL;
  123650           0 :      std::vector < unsigned char* > :: const_iterator block;
  123651           0 :      if ( SgOmpAtomicStatement::pools.empty() == false )
  123652             :         {
  123653           0 :           block = SgOmpAtomicStatement::pools.begin() ;
  123654           0 :           SgOmpAtomicStatement::next_node = (SgOmpAtomicStatement*) (*block);
  123655             : 
  123656           0 :           while ( block != SgOmpAtomicStatement::pools.end() )
  123657             :              {
  123658           0 :                pointer = (SgOmpAtomicStatement*) (*block);
  123659           0 :                if ( tempPointer != NULL )
  123660             :                   {
  123661           0 :                     tempPointer->set_freepointer(pointer);
  123662             :                   }
  123663           0 :                for (unsigned i = 0; i < SgOmpAtomicStatement::pool_size - 1; ++i)
  123664             :                   {
  123665           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  123666             :                   }
  123667           0 :                 pointer[SgOmpAtomicStatement::pool_size-1].set_freepointer(NULL);
  123668           0 :                 tempPointer = &(pointer[SgOmpAtomicStatement::pool_size-1]);
  123669           0 :                 ++block;
  123670             :              }
  123671             :         }
  123672           0 :    }
  123673             : 
  123674           5 : void SgOmpAtomicStatement::deleteMemoryPool() {
  123675           5 :   for (auto p: SgOmpAtomicStatement::pools) {
  123676           0 :     ROSE_FREE(p);
  123677             :   }
  123678           5 :   SgOmpAtomicStatement::next_node = nullptr;
  123679           5 :   SgOmpAtomicStatement::pools.clear();
  123680           5 : }
  123681             : 
  123682             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  123683             : //                 reading multiple binary files to for a single AST.
  123684             : /////////// new version ////////////////////////////////
  123685             : //############################################################################
  123686             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  123687             : void
  123688           2 : SgOmpAtomicStatement::extendMemoryPoolForFileIO( )
  123689             :   {
  123690           2 :     size_t blockIndex = SgOmpAtomicStatement::pools.size();
  123691           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicStatement);
  123692             : 
  123693           2 :     while ( (blockIndex * SgOmpAtomicStatement::pool_size) < newPoolSize)
  123694             :       {
  123695             : #if ROSE_ALLOC_TRACE
  123696             :         if (blockIndex > 0) {
  123697             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicStatement) = %" PRIuPTR " SgOmpAtomicStatement::pool_size = %d \n",
  123698             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAtomicStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAtomicStatement),SgOmpAtomicStatement::pool_size);
  123699             :         }
  123700             : #endif
  123701             : 
  123702           0 :         SgOmpAtomicStatement * pointer = (SgOmpAtomicStatement*) ROSE_MALLOC ( SgOmpAtomicStatement::pool_size * sizeof(SgOmpAtomicStatement) );
  123703           0 :         assert( pointer != NULL );
  123704             : #if ROSE_ALLOC_MEMSET == 1
  123705             :         memset(pointer, 0x00, SgOmpAtomicStatement::pool_size * sizeof(SgOmpAtomicStatement));
  123706             : #elif ROSE_ALLOC_MEMSET == 2
  123707             :         memset(pointer, 0xCC, SgOmpAtomicStatement::pool_size * sizeof(SgOmpAtomicStatement));
  123708             : #endif
  123709           0 :         SgOmpAtomicStatement::pools.push_back( (unsigned char*)(pointer) );
  123710           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAtomicStatement::pool_size * sizeof(SgOmpAtomicStatement), V_SgOmpAtomicStatement ) );
  123711             : 
  123712           0 :         if ( SgOmpAtomicStatement::next_node != NULL ) {
  123713           0 :           if ( blockIndex > 0 ) {
  123714           0 :             SgOmpAtomicStatement * blkptr = (SgOmpAtomicStatement*)(SgOmpAtomicStatement::pools[blockIndex-1]);
  123715           0 :             blkptr[ SgOmpAtomicStatement::pool_size - 1 ].set_freepointer(pointer);
  123716             :           }
  123717             :         } else {
  123718           0 :           SgOmpAtomicStatement::next_node = pointer;
  123719             :         }
  123720             : 
  123721           0 :         for (unsigned i = 0; i < SgOmpAtomicStatement::pool_size-1; ++i)
  123722             :            {
  123723           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  123724             :            }
  123725           0 :         pointer[ SgOmpAtomicStatement::pool_size -1 ].set_freepointer(NULL);
  123726             : 
  123727           0 :         blockIndex++;
  123728             :       }
  123729           2 :   }
  123730             : 
  123731             : //############################################################################
  123732             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  123733             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  123734             :  * not compressed. However, that stuff is not yet implemented! 
  123735             :  */
  123736             : unsigned long
  123737           0 : SgOmpAtomicStatement::getNumberOfLastValidPointer()
  123738             :    {
  123739           0 :       SgOmpAtomicStatement* testPointer = (SgOmpAtomicStatement*)(SgOmpAtomicStatement::pools.back());
  123740           0 :       unsigned long localIndex = SgOmpAtomicStatement::pool_size - 1;
  123741           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  123742             :          {
  123743           0 :            localIndex--;
  123744             :          }
  123745           0 :       return (localIndex + SgOmpAtomicStatement::pool_size * (SgOmpAtomicStatement::pools.size()-1));
  123746             :    }
  123747             : 
  123748             : //############################################################################
  123749             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  123750             :  * memory pool and initializes the data member in class SgOmpAtomicStatementStroageClass
  123751             :  * from its counterpart of SgOmpAtomicStatement. The return value is just for checking, 
  123752             :  * that the whole StorageClassArray is initialized!
  123753             :  */
  123754             : unsigned long
  123755           0 : SgOmpAtomicStatement::initializeStorageClassArray( SgOmpAtomicStatementStorageClass *storageArray )
  123756             :    {
  123757           0 :      unsigned long storageCounter = 0;
  123758           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAtomicStatement::pools.begin();
  123759           0 :      SgOmpAtomicStatement* pointer = NULL;
  123760           0 :      while ( block != SgOmpAtomicStatement::pools.end() ) {
  123761           0 :           pointer = (SgOmpAtomicStatement*) (*block);
  123762           0 :           for ( unsigned i = 0; i < SgOmpAtomicStatement::pool_size; ++i ) {
  123763           0 :                if ( pointer->get_freepointer() != NULL ) {
  123764           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  123765           0 :                  storageArray++;
  123766           0 :                  storageCounter++;
  123767             :                }
  123768           0 :                pointer++;
  123769             :              }
  123770           0 :            block++;
  123771             :         }
  123772           0 :      return storageCounter;
  123773             :    }
  123774             : 
  123775             : /* #line 123776 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  123776             : 
  123777             : 
  123778             : 
  123779             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  123780             : 
  123781             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  123782             : 
  123783             : //############################################################################
  123784             : /* JH (02/02/2006) Constructor of the IR node SgOmpScanStatement that takes its 
  123785             :  * corresponding StorageClass as parameter
  123786             :  */
  123787           0 : SgOmpScanStatement :: SgOmpScanStatement ( const SgOmpScanStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  123788             :    {
  123789             : 
  123790             : 
  123791             : /* #line 123792 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  123792             : 
  123793           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  123794             : 
  123795             : 
  123796             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  123797             : 
  123798             : 
  123799           0 :    }
  123800             : 
  123801             : //############################################################################
  123802             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  123803             :  * within the working AST. 
  123804             :  */
  123805           0 : SgOmpScanStatement * SgOmpScanStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  123806           0 :      SgOmpScanStatement* returnPointer = NULL;
  123807           0 :      if ( globalIndex != 0 )
  123808             :         {
  123809             : 
  123810             : #if FILE_IO_EXTRA_CHECK
  123811           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpScanStatement ) ) <= globalIndex ) ;
  123812           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpScanStatement + 1 ) ) );
  123813             : #endif
  123814           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpScanStatement )  
  123815           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpScanStatement );
  123816           0 :           unsigned long positionInPool = localIndex % SgOmpScanStatement::pool_size;
  123817           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpScanStatement::pool_size;
  123818             : 
  123819             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  123820             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  123821             : 
  123822           0 :           returnPointer = &( ( (SgOmpScanStatement*)(SgOmpScanStatement::pools[memoryBlock]) ) [positionInPool]) ;
  123823             : 
  123824           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  123825             :         }
  123826           0 :      return returnPointer ;
  123827             :    }
  123828             : 
  123829             : //############################################################################
  123830             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  123831             :   for the AST with the index astIndex
  123832             : */
  123833           0 : SgOmpScanStatement * SgOmpScanStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  123834           0 :      SgOmpScanStatement* returnPointer = NULL;
  123835           0 :      if ( globalIndex != 0 )
  123836             :         {
  123837             : 
  123838             : #if FILE_IO_EXTRA_CHECK
  123839           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpScanStatement ) ) <= globalIndex ) ;
  123840           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpScanStatement + 1 ) ) );
  123841             : #endif
  123842           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpScanStatement )
  123843           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpScanStatement );
  123844           0 :           unsigned long positionInPool = localIndex % SgOmpScanStatement::pool_size ;
  123845           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpScanStatement::pool_size ;
  123846             : 
  123847             : #if FILE_IO_EXTRA_CHECK
  123848             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  123849             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  123850             : #endif
  123851             : 
  123852           0 :           returnPointer = &( ( (SgOmpScanStatement*)(SgOmpScanStatement::pools[memoryBlock]) ) [positionInPool]) ;
  123853             : 
  123854             : #if FILE_IO_EXTRA_CHECK
  123855           0 :           assert ( returnPointer != NULL ) ;
  123856             : #endif
  123857             :         }
  123858           0 :      return returnPointer ;
  123859             :    }
  123860             : 
  123861             : //############################################################################
  123862             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  123863             :  * pool size! We set for every valid object in the memory pool the freepointer
  123864             :  * to the global index and increase the global index afterwards. For all the 
  123865             :  * invalid objects (means address ranges within the memory pool that were not
  123866             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  123867             :  * distinguish valid from invalid objects! 
  123868             :  */
  123869             : unsigned long
  123870           5 : SgOmpScanStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  123871             :    {
  123872           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  123873           5 :      SgOmpScanStatement* pointer = NULL;
  123874           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  123875           5 :      std::vector < unsigned char* > :: const_iterator block;
  123876           5 :      for ( block = SgOmpScanStatement::pools.begin(); block != SgOmpScanStatement::pools.end() ; ++block )
  123877             :         {
  123878           0 :           pointer = (SgOmpScanStatement*)(*block);
  123879           0 :           for (unsigned i = 0; i < SgOmpScanStatement::pool_size; ++i )
  123880             :              {
  123881             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  123882             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  123883             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  123884             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  123885             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  123886             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  123887             :             // properly; so this will have to be checked next.
  123888             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  123889             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  123890           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  123891             :                   {
  123892           0 :                     pointer[i].set_freepointer((SgOmpScanStatement*)(globalIndex));
  123893           0 :                     globalIndex++;
  123894             :                   }
  123895             :                else
  123896             :                   {
  123897           0 :                     pointer[i].set_freepointer(NULL);
  123898             :                   }
  123899             :               }
  123900             :         }
  123901           5 :      return globalIndex;
  123902             :    }
  123903             : 
  123904             : //############################################################################
  123905             : // JH (01/14/2006)
  123906             : void
  123907           5 : SgOmpScanStatement::resetValidFreepointers( )
  123908             :    {
  123909           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  123910           5 :      SgOmpScanStatement* pointer = NULL;
  123911           5 :      std::vector < unsigned char* > :: const_iterator block;
  123912           5 :      SgOmpScanStatement* pointerOfLinkedList = NULL;
  123913           5 :      for ( block = SgOmpScanStatement::pools.begin(); block != SgOmpScanStatement::pools.end() ; ++block )
  123914             :         {
  123915           0 :           pointer = (SgOmpScanStatement*)(*block);
  123916           0 :           for (unsigned i = 0; i < SgOmpScanStatement::pool_size; ++i )
  123917             :              {
  123918             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  123919             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  123920             :             // memory blocks!.
  123921           0 :                if ( pointer[i].get_freepointer() != NULL )
  123922             :                   {
  123923           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  123924             :                   }
  123925             :                else
  123926             :                   {
  123927           0 :                     if ( pointerOfLinkedList == NULL )
  123928             :                        {
  123929           0 :                          SgOmpScanStatement::next_node = &(pointer[i]);
  123930             :                        }
  123931             :                     else
  123932             :                        {
  123933             :                       // printf ("In SgOmpScanStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  123934           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  123935             :                        }
  123936             :                     pointerOfLinkedList = &(pointer[i]);
  123937             :                   }
  123938             :               }
  123939             :         }
  123940             : 
  123941           5 :      if ( pointerOfLinkedList != NULL )
  123942             :         {
  123943             :        // printf ("In SgOmpScanStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  123944           0 :           pointerOfLinkedList->set_freepointer(NULL);
  123945             :        // DQ (6/6/2010): Temporary debugging...
  123946             :        //   ROSE_ASSERT(false);
  123947             :         }
  123948             : 
  123949           5 :      return ;
  123950             :    }
  123951             : 
  123952             : //############################################################################
  123953             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  123954             :  * within the memory pool and resets the freepointers, in order to achieve a 
  123955             :  * linked list, that has no jumps and starts at the beginning! This function 
  123956             :  * does not extend the memory pool, since we do not delete any memory blocks,
  123957             :  * but delete the valid objects.  
  123958             :  */
  123959             : void
  123960           0 : SgOmpScanStatement::clearMemoryPool( )
  123961             :    {
  123962             :   // printf ("Inside of SgOmpScanStatement::clearMemoryPool() \n");
  123963             : 
  123964           0 :      SgOmpScanStatement* pointer = NULL, *tempPointer = NULL;
  123965           0 :      std::vector < unsigned char* > :: const_iterator block;
  123966           0 :      if ( SgOmpScanStatement::pools.empty() == false )
  123967             :         {
  123968           0 :           block = SgOmpScanStatement::pools.begin() ;
  123969           0 :           SgOmpScanStatement::next_node = (SgOmpScanStatement*) (*block);
  123970             : 
  123971           0 :           while ( block != SgOmpScanStatement::pools.end() )
  123972             :              {
  123973           0 :                pointer = (SgOmpScanStatement*) (*block);
  123974           0 :                if ( tempPointer != NULL )
  123975             :                   {
  123976           0 :                     tempPointer->set_freepointer(pointer);
  123977             :                   }
  123978           0 :                for (unsigned i = 0; i < SgOmpScanStatement::pool_size - 1; ++i)
  123979             :                   {
  123980           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  123981             :                   }
  123982           0 :                 pointer[SgOmpScanStatement::pool_size-1].set_freepointer(NULL);
  123983           0 :                 tempPointer = &(pointer[SgOmpScanStatement::pool_size-1]);
  123984           0 :                 ++block;
  123985             :              }
  123986             :         }
  123987           0 :    }
  123988             : 
  123989           5 : void SgOmpScanStatement::deleteMemoryPool() {
  123990           5 :   for (auto p: SgOmpScanStatement::pools) {
  123991           0 :     ROSE_FREE(p);
  123992             :   }
  123993           5 :   SgOmpScanStatement::next_node = nullptr;
  123994           5 :   SgOmpScanStatement::pools.clear();
  123995           5 : }
  123996             : 
  123997             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  123998             : //                 reading multiple binary files to for a single AST.
  123999             : /////////// new version ////////////////////////////////
  124000             : //############################################################################
  124001             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  124002             : void
  124003           2 : SgOmpScanStatement::extendMemoryPoolForFileIO( )
  124004             :   {
  124005           2 :     size_t blockIndex = SgOmpScanStatement::pools.size();
  124006           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpScanStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpScanStatement);
  124007             : 
  124008           2 :     while ( (blockIndex * SgOmpScanStatement::pool_size) < newPoolSize)
  124009             :       {
  124010             : #if ROSE_ALLOC_TRACE
  124011             :         if (blockIndex > 0) {
  124012             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpScanStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpScanStatement) = %" PRIuPTR " SgOmpScanStatement::pool_size = %d \n",
  124013             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpScanStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpScanStatement),SgOmpScanStatement::pool_size);
  124014             :         }
  124015             : #endif
  124016             : 
  124017           0 :         SgOmpScanStatement * pointer = (SgOmpScanStatement*) ROSE_MALLOC ( SgOmpScanStatement::pool_size * sizeof(SgOmpScanStatement) );
  124018           0 :         assert( pointer != NULL );
  124019             : #if ROSE_ALLOC_MEMSET == 1
  124020             :         memset(pointer, 0x00, SgOmpScanStatement::pool_size * sizeof(SgOmpScanStatement));
  124021             : #elif ROSE_ALLOC_MEMSET == 2
  124022             :         memset(pointer, 0xCC, SgOmpScanStatement::pool_size * sizeof(SgOmpScanStatement));
  124023             : #endif
  124024           0 :         SgOmpScanStatement::pools.push_back( (unsigned char*)(pointer) );
  124025           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpScanStatement::pool_size * sizeof(SgOmpScanStatement), V_SgOmpScanStatement ) );
  124026             : 
  124027           0 :         if ( SgOmpScanStatement::next_node != NULL ) {
  124028           0 :           if ( blockIndex > 0 ) {
  124029           0 :             SgOmpScanStatement * blkptr = (SgOmpScanStatement*)(SgOmpScanStatement::pools[blockIndex-1]);
  124030           0 :             blkptr[ SgOmpScanStatement::pool_size - 1 ].set_freepointer(pointer);
  124031             :           }
  124032             :         } else {
  124033           0 :           SgOmpScanStatement::next_node = pointer;
  124034             :         }
  124035             : 
  124036           0 :         for (unsigned i = 0; i < SgOmpScanStatement::pool_size-1; ++i)
  124037             :            {
  124038           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  124039             :            }
  124040           0 :         pointer[ SgOmpScanStatement::pool_size -1 ].set_freepointer(NULL);
  124041             : 
  124042           0 :         blockIndex++;
  124043             :       }
  124044           2 :   }
  124045             : 
  124046             : //############################################################################
  124047             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  124048             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  124049             :  * not compressed. However, that stuff is not yet implemented! 
  124050             :  */
  124051             : unsigned long
  124052           0 : SgOmpScanStatement::getNumberOfLastValidPointer()
  124053             :    {
  124054           0 :       SgOmpScanStatement* testPointer = (SgOmpScanStatement*)(SgOmpScanStatement::pools.back());
  124055           0 :       unsigned long localIndex = SgOmpScanStatement::pool_size - 1;
  124056           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  124057             :          {
  124058           0 :            localIndex--;
  124059             :          }
  124060           0 :       return (localIndex + SgOmpScanStatement::pool_size * (SgOmpScanStatement::pools.size()-1));
  124061             :    }
  124062             : 
  124063             : //############################################################################
  124064             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  124065             :  * memory pool and initializes the data member in class SgOmpScanStatementStroageClass
  124066             :  * from its counterpart of SgOmpScanStatement. The return value is just for checking, 
  124067             :  * that the whole StorageClassArray is initialized!
  124068             :  */
  124069             : unsigned long
  124070           0 : SgOmpScanStatement::initializeStorageClassArray( SgOmpScanStatementStorageClass *storageArray )
  124071             :    {
  124072           0 :      unsigned long storageCounter = 0;
  124073           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpScanStatement::pools.begin();
  124074           0 :      SgOmpScanStatement* pointer = NULL;
  124075           0 :      while ( block != SgOmpScanStatement::pools.end() ) {
  124076           0 :           pointer = (SgOmpScanStatement*) (*block);
  124077           0 :           for ( unsigned i = 0; i < SgOmpScanStatement::pool_size; ++i ) {
  124078           0 :                if ( pointer->get_freepointer() != NULL ) {
  124079           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  124080           0 :                  storageArray++;
  124081           0 :                  storageCounter++;
  124082             :                }
  124083           0 :                pointer++;
  124084             :              }
  124085           0 :            block++;
  124086             :         }
  124087           0 :      return storageCounter;
  124088             :    }
  124089             : 
  124090             : /* #line 124091 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  124091             : 
  124092             : 
  124093             : 
  124094             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  124095             : 
  124096             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  124097             : 
  124098             : //############################################################################
  124099             : /* JH (02/02/2006) Constructor of the IR node SgOmpMetadirectiveStatement that takes its 
  124100             :  * corresponding StorageClass as parameter
  124101             :  */
  124102           0 : SgOmpMetadirectiveStatement :: SgOmpMetadirectiveStatement ( const SgOmpMetadirectiveStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  124103             :    {
  124104             : 
  124105             : 
  124106             : /* #line 124107 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  124107             : 
  124108           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  124109             : 
  124110             : 
  124111             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  124112             : 
  124113             : 
  124114           0 :    }
  124115             : 
  124116             : //############################################################################
  124117             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  124118             :  * within the working AST. 
  124119             :  */
  124120           0 : SgOmpMetadirectiveStatement * SgOmpMetadirectiveStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  124121           0 :      SgOmpMetadirectiveStatement* returnPointer = NULL;
  124122           0 :      if ( globalIndex != 0 )
  124123             :         {
  124124             : 
  124125             : #if FILE_IO_EXTRA_CHECK
  124126           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpMetadirectiveStatement ) ) <= globalIndex ) ;
  124127           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMetadirectiveStatement + 1 ) ) );
  124128             : #endif
  124129           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMetadirectiveStatement )  
  124130           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpMetadirectiveStatement );
  124131           0 :           unsigned long positionInPool = localIndex % SgOmpMetadirectiveStatement::pool_size;
  124132           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMetadirectiveStatement::pool_size;
  124133             : 
  124134             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  124135             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  124136             : 
  124137           0 :           returnPointer = &( ( (SgOmpMetadirectiveStatement*)(SgOmpMetadirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  124138             : 
  124139           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  124140             :         }
  124141           0 :      return returnPointer ;
  124142             :    }
  124143             : 
  124144             : //############################################################################
  124145             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  124146             :   for the AST with the index astIndex
  124147             : */
  124148           0 : SgOmpMetadirectiveStatement * SgOmpMetadirectiveStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  124149           0 :      SgOmpMetadirectiveStatement* returnPointer = NULL;
  124150           0 :      if ( globalIndex != 0 )
  124151             :         {
  124152             : 
  124153             : #if FILE_IO_EXTRA_CHECK
  124154           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpMetadirectiveStatement ) ) <= globalIndex ) ;
  124155           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMetadirectiveStatement + 1 ) ) );
  124156             : #endif
  124157           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMetadirectiveStatement )
  124158           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpMetadirectiveStatement );
  124159           0 :           unsigned long positionInPool = localIndex % SgOmpMetadirectiveStatement::pool_size ;
  124160           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMetadirectiveStatement::pool_size ;
  124161             : 
  124162             : #if FILE_IO_EXTRA_CHECK
  124163             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  124164             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  124165             : #endif
  124166             : 
  124167           0 :           returnPointer = &( ( (SgOmpMetadirectiveStatement*)(SgOmpMetadirectiveStatement::pools[memoryBlock]) ) [positionInPool]) ;
  124168             : 
  124169             : #if FILE_IO_EXTRA_CHECK
  124170           0 :           assert ( returnPointer != NULL ) ;
  124171             : #endif
  124172             :         }
  124173           0 :      return returnPointer ;
  124174             :    }
  124175             : 
  124176             : //############################################################################
  124177             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  124178             :  * pool size! We set for every valid object in the memory pool the freepointer
  124179             :  * to the global index and increase the global index afterwards. For all the 
  124180             :  * invalid objects (means address ranges within the memory pool that were not
  124181             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  124182             :  * distinguish valid from invalid objects! 
  124183             :  */
  124184             : unsigned long
  124185           5 : SgOmpMetadirectiveStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  124186             :    {
  124187           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  124188           5 :      SgOmpMetadirectiveStatement* pointer = NULL;
  124189           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  124190           5 :      std::vector < unsigned char* > :: const_iterator block;
  124191           5 :      for ( block = SgOmpMetadirectiveStatement::pools.begin(); block != SgOmpMetadirectiveStatement::pools.end() ; ++block )
  124192             :         {
  124193           0 :           pointer = (SgOmpMetadirectiveStatement*)(*block);
  124194           0 :           for (unsigned i = 0; i < SgOmpMetadirectiveStatement::pool_size; ++i )
  124195             :              {
  124196             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  124197             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  124198             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  124199             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  124200             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  124201             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  124202             :             // properly; so this will have to be checked next.
  124203             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  124204             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  124205           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  124206             :                   {
  124207           0 :                     pointer[i].set_freepointer((SgOmpMetadirectiveStatement*)(globalIndex));
  124208           0 :                     globalIndex++;
  124209             :                   }
  124210             :                else
  124211             :                   {
  124212           0 :                     pointer[i].set_freepointer(NULL);
  124213             :                   }
  124214             :               }
  124215             :         }
  124216           5 :      return globalIndex;
  124217             :    }
  124218             : 
  124219             : //############################################################################
  124220             : // JH (01/14/2006)
  124221             : void
  124222           5 : SgOmpMetadirectiveStatement::resetValidFreepointers( )
  124223             :    {
  124224           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  124225           5 :      SgOmpMetadirectiveStatement* pointer = NULL;
  124226           5 :      std::vector < unsigned char* > :: const_iterator block;
  124227           5 :      SgOmpMetadirectiveStatement* pointerOfLinkedList = NULL;
  124228           5 :      for ( block = SgOmpMetadirectiveStatement::pools.begin(); block != SgOmpMetadirectiveStatement::pools.end() ; ++block )
  124229             :         {
  124230           0 :           pointer = (SgOmpMetadirectiveStatement*)(*block);
  124231           0 :           for (unsigned i = 0; i < SgOmpMetadirectiveStatement::pool_size; ++i )
  124232             :              {
  124233             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  124234             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  124235             :             // memory blocks!.
  124236           0 :                if ( pointer[i].get_freepointer() != NULL )
  124237             :                   {
  124238           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  124239             :                   }
  124240             :                else
  124241             :                   {
  124242           0 :                     if ( pointerOfLinkedList == NULL )
  124243             :                        {
  124244           0 :                          SgOmpMetadirectiveStatement::next_node = &(pointer[i]);
  124245             :                        }
  124246             :                     else
  124247             :                        {
  124248             :                       // printf ("In SgOmpMetadirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  124249           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  124250             :                        }
  124251             :                     pointerOfLinkedList = &(pointer[i]);
  124252             :                   }
  124253             :               }
  124254             :         }
  124255             : 
  124256           5 :      if ( pointerOfLinkedList != NULL )
  124257             :         {
  124258             :        // printf ("In SgOmpMetadirectiveStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  124259           0 :           pointerOfLinkedList->set_freepointer(NULL);
  124260             :        // DQ (6/6/2010): Temporary debugging...
  124261             :        //   ROSE_ASSERT(false);
  124262             :         }
  124263             : 
  124264           5 :      return ;
  124265             :    }
  124266             : 
  124267             : //############################################################################
  124268             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  124269             :  * within the memory pool and resets the freepointers, in order to achieve a 
  124270             :  * linked list, that has no jumps and starts at the beginning! This function 
  124271             :  * does not extend the memory pool, since we do not delete any memory blocks,
  124272             :  * but delete the valid objects.  
  124273             :  */
  124274             : void
  124275           0 : SgOmpMetadirectiveStatement::clearMemoryPool( )
  124276             :    {
  124277             :   // printf ("Inside of SgOmpMetadirectiveStatement::clearMemoryPool() \n");
  124278             : 
  124279           0 :      SgOmpMetadirectiveStatement* pointer = NULL, *tempPointer = NULL;
  124280           0 :      std::vector < unsigned char* > :: const_iterator block;
  124281           0 :      if ( SgOmpMetadirectiveStatement::pools.empty() == false )
  124282             :         {
  124283           0 :           block = SgOmpMetadirectiveStatement::pools.begin() ;
  124284           0 :           SgOmpMetadirectiveStatement::next_node = (SgOmpMetadirectiveStatement*) (*block);
  124285             : 
  124286           0 :           while ( block != SgOmpMetadirectiveStatement::pools.end() )
  124287             :              {
  124288           0 :                pointer = (SgOmpMetadirectiveStatement*) (*block);
  124289           0 :                if ( tempPointer != NULL )
  124290             :                   {
  124291           0 :                     tempPointer->set_freepointer(pointer);
  124292             :                   }
  124293           0 :                for (unsigned i = 0; i < SgOmpMetadirectiveStatement::pool_size - 1; ++i)
  124294             :                   {
  124295           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  124296             :                   }
  124297           0 :                 pointer[SgOmpMetadirectiveStatement::pool_size-1].set_freepointer(NULL);
  124298           0 :                 tempPointer = &(pointer[SgOmpMetadirectiveStatement::pool_size-1]);
  124299           0 :                 ++block;
  124300             :              }
  124301             :         }
  124302           0 :    }
  124303             : 
  124304           5 : void SgOmpMetadirectiveStatement::deleteMemoryPool() {
  124305           5 :   for (auto p: SgOmpMetadirectiveStatement::pools) {
  124306           0 :     ROSE_FREE(p);
  124307             :   }
  124308           5 :   SgOmpMetadirectiveStatement::next_node = nullptr;
  124309           5 :   SgOmpMetadirectiveStatement::pools.clear();
  124310           5 : }
  124311             : 
  124312             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  124313             : //                 reading multiple binary files to for a single AST.
  124314             : /////////// new version ////////////////////////////////
  124315             : //############################################################################
  124316             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  124317             : void
  124318           2 : SgOmpMetadirectiveStatement::extendMemoryPoolForFileIO( )
  124319             :   {
  124320           2 :     size_t blockIndex = SgOmpMetadirectiveStatement::pools.size();
  124321           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMetadirectiveStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMetadirectiveStatement);
  124322             : 
  124323           2 :     while ( (blockIndex * SgOmpMetadirectiveStatement::pool_size) < newPoolSize)
  124324             :       {
  124325             : #if ROSE_ALLOC_TRACE
  124326             :         if (blockIndex > 0) {
  124327             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMetadirectiveStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMetadirectiveStatement) = %" PRIuPTR " SgOmpMetadirectiveStatement::pool_size = %d \n",
  124328             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMetadirectiveStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMetadirectiveStatement),SgOmpMetadirectiveStatement::pool_size);
  124329             :         }
  124330             : #endif
  124331             : 
  124332           0 :         SgOmpMetadirectiveStatement * pointer = (SgOmpMetadirectiveStatement*) ROSE_MALLOC ( SgOmpMetadirectiveStatement::pool_size * sizeof(SgOmpMetadirectiveStatement) );
  124333           0 :         assert( pointer != NULL );
  124334             : #if ROSE_ALLOC_MEMSET == 1
  124335             :         memset(pointer, 0x00, SgOmpMetadirectiveStatement::pool_size * sizeof(SgOmpMetadirectiveStatement));
  124336             : #elif ROSE_ALLOC_MEMSET == 2
  124337             :         memset(pointer, 0xCC, SgOmpMetadirectiveStatement::pool_size * sizeof(SgOmpMetadirectiveStatement));
  124338             : #endif
  124339           0 :         SgOmpMetadirectiveStatement::pools.push_back( (unsigned char*)(pointer) );
  124340           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpMetadirectiveStatement::pool_size * sizeof(SgOmpMetadirectiveStatement), V_SgOmpMetadirectiveStatement ) );
  124341             : 
  124342           0 :         if ( SgOmpMetadirectiveStatement::next_node != NULL ) {
  124343           0 :           if ( blockIndex > 0 ) {
  124344           0 :             SgOmpMetadirectiveStatement * blkptr = (SgOmpMetadirectiveStatement*)(SgOmpMetadirectiveStatement::pools[blockIndex-1]);
  124345           0 :             blkptr[ SgOmpMetadirectiveStatement::pool_size - 1 ].set_freepointer(pointer);
  124346             :           }
  124347             :         } else {
  124348           0 :           SgOmpMetadirectiveStatement::next_node = pointer;
  124349             :         }
  124350             : 
  124351           0 :         for (unsigned i = 0; i < SgOmpMetadirectiveStatement::pool_size-1; ++i)
  124352             :            {
  124353           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  124354             :            }
  124355           0 :         pointer[ SgOmpMetadirectiveStatement::pool_size -1 ].set_freepointer(NULL);
  124356             : 
  124357           0 :         blockIndex++;
  124358             :       }
  124359           2 :   }
  124360             : 
  124361             : //############################################################################
  124362             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  124363             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  124364             :  * not compressed. However, that stuff is not yet implemented! 
  124365             :  */
  124366             : unsigned long
  124367           0 : SgOmpMetadirectiveStatement::getNumberOfLastValidPointer()
  124368             :    {
  124369           0 :       SgOmpMetadirectiveStatement* testPointer = (SgOmpMetadirectiveStatement*)(SgOmpMetadirectiveStatement::pools.back());
  124370           0 :       unsigned long localIndex = SgOmpMetadirectiveStatement::pool_size - 1;
  124371           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  124372             :          {
  124373           0 :            localIndex--;
  124374             :          }
  124375           0 :       return (localIndex + SgOmpMetadirectiveStatement::pool_size * (SgOmpMetadirectiveStatement::pools.size()-1));
  124376             :    }
  124377             : 
  124378             : //############################################################################
  124379             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  124380             :  * memory pool and initializes the data member in class SgOmpMetadirectiveStatementStroageClass
  124381             :  * from its counterpart of SgOmpMetadirectiveStatement. The return value is just for checking, 
  124382             :  * that the whole StorageClassArray is initialized!
  124383             :  */
  124384             : unsigned long
  124385           0 : SgOmpMetadirectiveStatement::initializeStorageClassArray( SgOmpMetadirectiveStatementStorageClass *storageArray )
  124386             :    {
  124387           0 :      unsigned long storageCounter = 0;
  124388           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpMetadirectiveStatement::pools.begin();
  124389           0 :      SgOmpMetadirectiveStatement* pointer = NULL;
  124390           0 :      while ( block != SgOmpMetadirectiveStatement::pools.end() ) {
  124391           0 :           pointer = (SgOmpMetadirectiveStatement*) (*block);
  124392           0 :           for ( unsigned i = 0; i < SgOmpMetadirectiveStatement::pool_size; ++i ) {
  124393           0 :                if ( pointer->get_freepointer() != NULL ) {
  124394           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  124395           0 :                  storageArray++;
  124396           0 :                  storageCounter++;
  124397             :                }
  124398           0 :                pointer++;
  124399             :              }
  124400           0 :            block++;
  124401             :         }
  124402           0 :      return storageCounter;
  124403             :    }
  124404             : 
  124405             : /* #line 124406 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  124406             : 
  124407             : 
  124408             : 
  124409             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  124410             : 
  124411             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  124412             : 
  124413             : //############################################################################
  124414             : /* JH (02/02/2006) Constructor of the IR node SgOmpLoopStatement that takes its 
  124415             :  * corresponding StorageClass as parameter
  124416             :  */
  124417           0 : SgOmpLoopStatement :: SgOmpLoopStatement ( const SgOmpLoopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  124418             :    {
  124419             : 
  124420             : 
  124421             : /* #line 124422 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  124422             : 
  124423           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  124424             : 
  124425             : 
  124426             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  124427             : 
  124428             : 
  124429           0 :    }
  124430             : 
  124431             : //############################################################################
  124432             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  124433             :  * within the working AST. 
  124434             :  */
  124435           0 : SgOmpLoopStatement * SgOmpLoopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  124436           0 :      SgOmpLoopStatement* returnPointer = NULL;
  124437           0 :      if ( globalIndex != 0 )
  124438             :         {
  124439             : 
  124440             : #if FILE_IO_EXTRA_CHECK
  124441           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpLoopStatement ) ) <= globalIndex ) ;
  124442           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpLoopStatement + 1 ) ) );
  124443             : #endif
  124444           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpLoopStatement )  
  124445           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpLoopStatement );
  124446           0 :           unsigned long positionInPool = localIndex % SgOmpLoopStatement::pool_size;
  124447           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpLoopStatement::pool_size;
  124448             : 
  124449             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  124450             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  124451             : 
  124452           0 :           returnPointer = &( ( (SgOmpLoopStatement*)(SgOmpLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  124453             : 
  124454           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  124455             :         }
  124456           0 :      return returnPointer ;
  124457             :    }
  124458             : 
  124459             : //############################################################################
  124460             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  124461             :   for the AST with the index astIndex
  124462             : */
  124463           0 : SgOmpLoopStatement * SgOmpLoopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  124464           0 :      SgOmpLoopStatement* returnPointer = NULL;
  124465           0 :      if ( globalIndex != 0 )
  124466             :         {
  124467             : 
  124468             : #if FILE_IO_EXTRA_CHECK
  124469           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpLoopStatement ) ) <= globalIndex ) ;
  124470           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpLoopStatement + 1 ) ) );
  124471             : #endif
  124472           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpLoopStatement )
  124473           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpLoopStatement );
  124474           0 :           unsigned long positionInPool = localIndex % SgOmpLoopStatement::pool_size ;
  124475           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpLoopStatement::pool_size ;
  124476             : 
  124477             : #if FILE_IO_EXTRA_CHECK
  124478             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  124479             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  124480             : #endif
  124481             : 
  124482           0 :           returnPointer = &( ( (SgOmpLoopStatement*)(SgOmpLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  124483             : 
  124484             : #if FILE_IO_EXTRA_CHECK
  124485           0 :           assert ( returnPointer != NULL ) ;
  124486             : #endif
  124487             :         }
  124488           0 :      return returnPointer ;
  124489             :    }
  124490             : 
  124491             : //############################################################################
  124492             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  124493             :  * pool size! We set for every valid object in the memory pool the freepointer
  124494             :  * to the global index and increase the global index afterwards. For all the 
  124495             :  * invalid objects (means address ranges within the memory pool that were not
  124496             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  124497             :  * distinguish valid from invalid objects! 
  124498             :  */
  124499             : unsigned long
  124500           5 : SgOmpLoopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  124501             :    {
  124502           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  124503           5 :      SgOmpLoopStatement* pointer = NULL;
  124504           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  124505           5 :      std::vector < unsigned char* > :: const_iterator block;
  124506           5 :      for ( block = SgOmpLoopStatement::pools.begin(); block != SgOmpLoopStatement::pools.end() ; ++block )
  124507             :         {
  124508           0 :           pointer = (SgOmpLoopStatement*)(*block);
  124509           0 :           for (unsigned i = 0; i < SgOmpLoopStatement::pool_size; ++i )
  124510             :              {
  124511             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  124512             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  124513             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  124514             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  124515             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  124516             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  124517             :             // properly; so this will have to be checked next.
  124518             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  124519             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  124520           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  124521             :                   {
  124522           0 :                     pointer[i].set_freepointer((SgOmpLoopStatement*)(globalIndex));
  124523           0 :                     globalIndex++;
  124524             :                   }
  124525             :                else
  124526             :                   {
  124527           0 :                     pointer[i].set_freepointer(NULL);
  124528             :                   }
  124529             :               }
  124530             :         }
  124531           5 :      return globalIndex;
  124532             :    }
  124533             : 
  124534             : //############################################################################
  124535             : // JH (01/14/2006)
  124536             : void
  124537           5 : SgOmpLoopStatement::resetValidFreepointers( )
  124538             :    {
  124539           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  124540           5 :      SgOmpLoopStatement* pointer = NULL;
  124541           5 :      std::vector < unsigned char* > :: const_iterator block;
  124542           5 :      SgOmpLoopStatement* pointerOfLinkedList = NULL;
  124543           5 :      for ( block = SgOmpLoopStatement::pools.begin(); block != SgOmpLoopStatement::pools.end() ; ++block )
  124544             :         {
  124545           0 :           pointer = (SgOmpLoopStatement*)(*block);
  124546           0 :           for (unsigned i = 0; i < SgOmpLoopStatement::pool_size; ++i )
  124547             :              {
  124548             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  124549             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  124550             :             // memory blocks!.
  124551           0 :                if ( pointer[i].get_freepointer() != NULL )
  124552             :                   {
  124553           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  124554             :                   }
  124555             :                else
  124556             :                   {
  124557           0 :                     if ( pointerOfLinkedList == NULL )
  124558             :                        {
  124559           0 :                          SgOmpLoopStatement::next_node = &(pointer[i]);
  124560             :                        }
  124561             :                     else
  124562             :                        {
  124563             :                       // printf ("In SgOmpLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  124564           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  124565             :                        }
  124566             :                     pointerOfLinkedList = &(pointer[i]);
  124567             :                   }
  124568             :               }
  124569             :         }
  124570             : 
  124571           5 :      if ( pointerOfLinkedList != NULL )
  124572             :         {
  124573             :        // printf ("In SgOmpLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  124574           0 :           pointerOfLinkedList->set_freepointer(NULL);
  124575             :        // DQ (6/6/2010): Temporary debugging...
  124576             :        //   ROSE_ASSERT(false);
  124577             :         }
  124578             : 
  124579           5 :      return ;
  124580             :    }
  124581             : 
  124582             : //############################################################################
  124583             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  124584             :  * within the memory pool and resets the freepointers, in order to achieve a 
  124585             :  * linked list, that has no jumps and starts at the beginning! This function 
  124586             :  * does not extend the memory pool, since we do not delete any memory blocks,
  124587             :  * but delete the valid objects.  
  124588             :  */
  124589             : void
  124590           0 : SgOmpLoopStatement::clearMemoryPool( )
  124591             :    {
  124592             :   // printf ("Inside of SgOmpLoopStatement::clearMemoryPool() \n");
  124593             : 
  124594           0 :      SgOmpLoopStatement* pointer = NULL, *tempPointer = NULL;
  124595           0 :      std::vector < unsigned char* > :: const_iterator block;
  124596           0 :      if ( SgOmpLoopStatement::pools.empty() == false )
  124597             :         {
  124598           0 :           block = SgOmpLoopStatement::pools.begin() ;
  124599           0 :           SgOmpLoopStatement::next_node = (SgOmpLoopStatement*) (*block);
  124600             : 
  124601           0 :           while ( block != SgOmpLoopStatement::pools.end() )
  124602             :              {
  124603           0 :                pointer = (SgOmpLoopStatement*) (*block);
  124604           0 :                if ( tempPointer != NULL )
  124605             :                   {
  124606           0 :                     tempPointer->set_freepointer(pointer);
  124607             :                   }
  124608           0 :                for (unsigned i = 0; i < SgOmpLoopStatement::pool_size - 1; ++i)
  124609             :                   {
  124610           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  124611             :                   }
  124612           0 :                 pointer[SgOmpLoopStatement::pool_size-1].set_freepointer(NULL);
  124613           0 :                 tempPointer = &(pointer[SgOmpLoopStatement::pool_size-1]);
  124614           0 :                 ++block;
  124615             :              }
  124616             :         }
  124617           0 :    }
  124618             : 
  124619           5 : void SgOmpLoopStatement::deleteMemoryPool() {
  124620           5 :   for (auto p: SgOmpLoopStatement::pools) {
  124621           0 :     ROSE_FREE(p);
  124622             :   }
  124623           5 :   SgOmpLoopStatement::next_node = nullptr;
  124624           5 :   SgOmpLoopStatement::pools.clear();
  124625           5 : }
  124626             : 
  124627             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  124628             : //                 reading multiple binary files to for a single AST.
  124629             : /////////// new version ////////////////////////////////
  124630             : //############################################################################
  124631             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  124632             : void
  124633           2 : SgOmpLoopStatement::extendMemoryPoolForFileIO( )
  124634             :   {
  124635           2 :     size_t blockIndex = SgOmpLoopStatement::pools.size();
  124636           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLoopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLoopStatement);
  124637             : 
  124638           2 :     while ( (blockIndex * SgOmpLoopStatement::pool_size) < newPoolSize)
  124639             :       {
  124640             : #if ROSE_ALLOC_TRACE
  124641             :         if (blockIndex > 0) {
  124642             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLoopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLoopStatement) = %" PRIuPTR " SgOmpLoopStatement::pool_size = %d \n",
  124643             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpLoopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpLoopStatement),SgOmpLoopStatement::pool_size);
  124644             :         }
  124645             : #endif
  124646             : 
  124647           0 :         SgOmpLoopStatement * pointer = (SgOmpLoopStatement*) ROSE_MALLOC ( SgOmpLoopStatement::pool_size * sizeof(SgOmpLoopStatement) );
  124648           0 :         assert( pointer != NULL );
  124649             : #if ROSE_ALLOC_MEMSET == 1
  124650             :         memset(pointer, 0x00, SgOmpLoopStatement::pool_size * sizeof(SgOmpLoopStatement));
  124651             : #elif ROSE_ALLOC_MEMSET == 2
  124652             :         memset(pointer, 0xCC, SgOmpLoopStatement::pool_size * sizeof(SgOmpLoopStatement));
  124653             : #endif
  124654           0 :         SgOmpLoopStatement::pools.push_back( (unsigned char*)(pointer) );
  124655           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpLoopStatement::pool_size * sizeof(SgOmpLoopStatement), V_SgOmpLoopStatement ) );
  124656             : 
  124657           0 :         if ( SgOmpLoopStatement::next_node != NULL ) {
  124658           0 :           if ( blockIndex > 0 ) {
  124659           0 :             SgOmpLoopStatement * blkptr = (SgOmpLoopStatement*)(SgOmpLoopStatement::pools[blockIndex-1]);
  124660           0 :             blkptr[ SgOmpLoopStatement::pool_size - 1 ].set_freepointer(pointer);
  124661             :           }
  124662             :         } else {
  124663           0 :           SgOmpLoopStatement::next_node = pointer;
  124664             :         }
  124665             : 
  124666           0 :         for (unsigned i = 0; i < SgOmpLoopStatement::pool_size-1; ++i)
  124667             :            {
  124668           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  124669             :            }
  124670           0 :         pointer[ SgOmpLoopStatement::pool_size -1 ].set_freepointer(NULL);
  124671             : 
  124672           0 :         blockIndex++;
  124673             :       }
  124674           2 :   }
  124675             : 
  124676             : //############################################################################
  124677             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  124678             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  124679             :  * not compressed. However, that stuff is not yet implemented! 
  124680             :  */
  124681             : unsigned long
  124682           0 : SgOmpLoopStatement::getNumberOfLastValidPointer()
  124683             :    {
  124684           0 :       SgOmpLoopStatement* testPointer = (SgOmpLoopStatement*)(SgOmpLoopStatement::pools.back());
  124685           0 :       unsigned long localIndex = SgOmpLoopStatement::pool_size - 1;
  124686           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  124687             :          {
  124688           0 :            localIndex--;
  124689             :          }
  124690           0 :       return (localIndex + SgOmpLoopStatement::pool_size * (SgOmpLoopStatement::pools.size()-1));
  124691             :    }
  124692             : 
  124693             : //############################################################################
  124694             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  124695             :  * memory pool and initializes the data member in class SgOmpLoopStatementStroageClass
  124696             :  * from its counterpart of SgOmpLoopStatement. The return value is just for checking, 
  124697             :  * that the whole StorageClassArray is initialized!
  124698             :  */
  124699             : unsigned long
  124700           0 : SgOmpLoopStatement::initializeStorageClassArray( SgOmpLoopStatementStorageClass *storageArray )
  124701             :    {
  124702           0 :      unsigned long storageCounter = 0;
  124703           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpLoopStatement::pools.begin();
  124704           0 :      SgOmpLoopStatement* pointer = NULL;
  124705           0 :      while ( block != SgOmpLoopStatement::pools.end() ) {
  124706           0 :           pointer = (SgOmpLoopStatement*) (*block);
  124707           0 :           for ( unsigned i = 0; i < SgOmpLoopStatement::pool_size; ++i ) {
  124708           0 :                if ( pointer->get_freepointer() != NULL ) {
  124709           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  124710           0 :                  storageArray++;
  124711           0 :                  storageCounter++;
  124712             :                }
  124713           0 :                pointer++;
  124714             :              }
  124715           0 :            block++;
  124716             :         }
  124717           0 :      return storageCounter;
  124718             :    }
  124719             : 
  124720             : /* #line 124721 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  124721             : 
  124722             : 
  124723             : 
  124724             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  124725             : 
  124726             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  124727             : 
  124728             : //############################################################################
  124729             : /* JH (02/02/2006) Constructor of the IR node SgOmpOrderedStatement that takes its 
  124730             :  * corresponding StorageClass as parameter
  124731             :  */
  124732           0 : SgOmpOrderedStatement :: SgOmpOrderedStatement ( const SgOmpOrderedStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  124733             :    {
  124734             : 
  124735             : 
  124736             : /* #line 124737 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  124737             : 
  124738           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  124739             : 
  124740             : 
  124741             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  124742             : 
  124743             : 
  124744           0 :    }
  124745             : 
  124746             : //############################################################################
  124747             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  124748             :  * within the working AST. 
  124749             :  */
  124750           0 : SgOmpOrderedStatement * SgOmpOrderedStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  124751           0 :      SgOmpOrderedStatement* returnPointer = NULL;
  124752           0 :      if ( globalIndex != 0 )
  124753             :         {
  124754             : 
  124755             : #if FILE_IO_EXTRA_CHECK
  124756           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpOrderedStatement ) ) <= globalIndex ) ;
  124757           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpOrderedStatement + 1 ) ) );
  124758             : #endif
  124759           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpOrderedStatement )  
  124760           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpOrderedStatement );
  124761           0 :           unsigned long positionInPool = localIndex % SgOmpOrderedStatement::pool_size;
  124762           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpOrderedStatement::pool_size;
  124763             : 
  124764             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  124765             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  124766             : 
  124767           0 :           returnPointer = &( ( (SgOmpOrderedStatement*)(SgOmpOrderedStatement::pools[memoryBlock]) ) [positionInPool]) ;
  124768             : 
  124769           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  124770             :         }
  124771           0 :      return returnPointer ;
  124772             :    }
  124773             : 
  124774             : //############################################################################
  124775             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  124776             :   for the AST with the index astIndex
  124777             : */
  124778           0 : SgOmpOrderedStatement * SgOmpOrderedStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  124779           0 :      SgOmpOrderedStatement* returnPointer = NULL;
  124780           0 :      if ( globalIndex != 0 )
  124781             :         {
  124782             : 
  124783             : #if FILE_IO_EXTRA_CHECK
  124784           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpOrderedStatement ) ) <= globalIndex ) ;
  124785           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpOrderedStatement + 1 ) ) );
  124786             : #endif
  124787           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpOrderedStatement )
  124788           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpOrderedStatement );
  124789           0 :           unsigned long positionInPool = localIndex % SgOmpOrderedStatement::pool_size ;
  124790           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpOrderedStatement::pool_size ;
  124791             : 
  124792             : #if FILE_IO_EXTRA_CHECK
  124793             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  124794             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  124795             : #endif
  124796             : 
  124797           0 :           returnPointer = &( ( (SgOmpOrderedStatement*)(SgOmpOrderedStatement::pools[memoryBlock]) ) [positionInPool]) ;
  124798             : 
  124799             : #if FILE_IO_EXTRA_CHECK
  124800           0 :           assert ( returnPointer != NULL ) ;
  124801             : #endif
  124802             :         }
  124803           0 :      return returnPointer ;
  124804             :    }
  124805             : 
  124806             : //############################################################################
  124807             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  124808             :  * pool size! We set for every valid object in the memory pool the freepointer
  124809             :  * to the global index and increase the global index afterwards. For all the 
  124810             :  * invalid objects (means address ranges within the memory pool that were not
  124811             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  124812             :  * distinguish valid from invalid objects! 
  124813             :  */
  124814             : unsigned long
  124815           5 : SgOmpOrderedStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  124816             :    {
  124817           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  124818           5 :      SgOmpOrderedStatement* pointer = NULL;
  124819           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  124820           5 :      std::vector < unsigned char* > :: const_iterator block;
  124821           5 :      for ( block = SgOmpOrderedStatement::pools.begin(); block != SgOmpOrderedStatement::pools.end() ; ++block )
  124822             :         {
  124823           0 :           pointer = (SgOmpOrderedStatement*)(*block);
  124824           0 :           for (unsigned i = 0; i < SgOmpOrderedStatement::pool_size; ++i )
  124825             :              {
  124826             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  124827             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  124828             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  124829             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  124830             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  124831             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  124832             :             // properly; so this will have to be checked next.
  124833             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  124834             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  124835           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  124836             :                   {
  124837           0 :                     pointer[i].set_freepointer((SgOmpOrderedStatement*)(globalIndex));
  124838           0 :                     globalIndex++;
  124839             :                   }
  124840             :                else
  124841             :                   {
  124842           0 :                     pointer[i].set_freepointer(NULL);
  124843             :                   }
  124844             :               }
  124845             :         }
  124846           5 :      return globalIndex;
  124847             :    }
  124848             : 
  124849             : //############################################################################
  124850             : // JH (01/14/2006)
  124851             : void
  124852           5 : SgOmpOrderedStatement::resetValidFreepointers( )
  124853             :    {
  124854           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  124855           5 :      SgOmpOrderedStatement* pointer = NULL;
  124856           5 :      std::vector < unsigned char* > :: const_iterator block;
  124857           5 :      SgOmpOrderedStatement* pointerOfLinkedList = NULL;
  124858           5 :      for ( block = SgOmpOrderedStatement::pools.begin(); block != SgOmpOrderedStatement::pools.end() ; ++block )
  124859             :         {
  124860           0 :           pointer = (SgOmpOrderedStatement*)(*block);
  124861           0 :           for (unsigned i = 0; i < SgOmpOrderedStatement::pool_size; ++i )
  124862             :              {
  124863             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  124864             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  124865             :             // memory blocks!.
  124866           0 :                if ( pointer[i].get_freepointer() != NULL )
  124867             :                   {
  124868           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  124869             :                   }
  124870             :                else
  124871             :                   {
  124872           0 :                     if ( pointerOfLinkedList == NULL )
  124873             :                        {
  124874           0 :                          SgOmpOrderedStatement::next_node = &(pointer[i]);
  124875             :                        }
  124876             :                     else
  124877             :                        {
  124878             :                       // printf ("In SgOmpOrderedStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  124879           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  124880             :                        }
  124881             :                     pointerOfLinkedList = &(pointer[i]);
  124882             :                   }
  124883             :               }
  124884             :         }
  124885             : 
  124886           5 :      if ( pointerOfLinkedList != NULL )
  124887             :         {
  124888             :        // printf ("In SgOmpOrderedStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  124889           0 :           pointerOfLinkedList->set_freepointer(NULL);
  124890             :        // DQ (6/6/2010): Temporary debugging...
  124891             :        //   ROSE_ASSERT(false);
  124892             :         }
  124893             : 
  124894           5 :      return ;
  124895             :    }
  124896             : 
  124897             : //############################################################################
  124898             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  124899             :  * within the memory pool and resets the freepointers, in order to achieve a 
  124900             :  * linked list, that has no jumps and starts at the beginning! This function 
  124901             :  * does not extend the memory pool, since we do not delete any memory blocks,
  124902             :  * but delete the valid objects.  
  124903             :  */
  124904             : void
  124905           0 : SgOmpOrderedStatement::clearMemoryPool( )
  124906             :    {
  124907             :   // printf ("Inside of SgOmpOrderedStatement::clearMemoryPool() \n");
  124908             : 
  124909           0 :      SgOmpOrderedStatement* pointer = NULL, *tempPointer = NULL;
  124910           0 :      std::vector < unsigned char* > :: const_iterator block;
  124911           0 :      if ( SgOmpOrderedStatement::pools.empty() == false )
  124912             :         {
  124913           0 :           block = SgOmpOrderedStatement::pools.begin() ;
  124914           0 :           SgOmpOrderedStatement::next_node = (SgOmpOrderedStatement*) (*block);
  124915             : 
  124916           0 :           while ( block != SgOmpOrderedStatement::pools.end() )
  124917             :              {
  124918           0 :                pointer = (SgOmpOrderedStatement*) (*block);
  124919           0 :                if ( tempPointer != NULL )
  124920             :                   {
  124921           0 :                     tempPointer->set_freepointer(pointer);
  124922             :                   }
  124923           0 :                for (unsigned i = 0; i < SgOmpOrderedStatement::pool_size - 1; ++i)
  124924             :                   {
  124925           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  124926             :                   }
  124927           0 :                 pointer[SgOmpOrderedStatement::pool_size-1].set_freepointer(NULL);
  124928           0 :                 tempPointer = &(pointer[SgOmpOrderedStatement::pool_size-1]);
  124929           0 :                 ++block;
  124930             :              }
  124931             :         }
  124932           0 :    }
  124933             : 
  124934           5 : void SgOmpOrderedStatement::deleteMemoryPool() {
  124935           5 :   for (auto p: SgOmpOrderedStatement::pools) {
  124936           0 :     ROSE_FREE(p);
  124937             :   }
  124938           5 :   SgOmpOrderedStatement::next_node = nullptr;
  124939           5 :   SgOmpOrderedStatement::pools.clear();
  124940           5 : }
  124941             : 
  124942             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  124943             : //                 reading multiple binary files to for a single AST.
  124944             : /////////// new version ////////////////////////////////
  124945             : //############################################################################
  124946             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  124947             : void
  124948           2 : SgOmpOrderedStatement::extendMemoryPoolForFileIO( )
  124949             :   {
  124950           2 :     size_t blockIndex = SgOmpOrderedStatement::pools.size();
  124951           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedStatement);
  124952             : 
  124953           2 :     while ( (blockIndex * SgOmpOrderedStatement::pool_size) < newPoolSize)
  124954             :       {
  124955             : #if ROSE_ALLOC_TRACE
  124956             :         if (blockIndex > 0) {
  124957             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedStatement) = %" PRIuPTR " SgOmpOrderedStatement::pool_size = %d \n",
  124958             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedStatement),SgOmpOrderedStatement::pool_size);
  124959             :         }
  124960             : #endif
  124961             : 
  124962           0 :         SgOmpOrderedStatement * pointer = (SgOmpOrderedStatement*) ROSE_MALLOC ( SgOmpOrderedStatement::pool_size * sizeof(SgOmpOrderedStatement) );
  124963           0 :         assert( pointer != NULL );
  124964             : #if ROSE_ALLOC_MEMSET == 1
  124965             :         memset(pointer, 0x00, SgOmpOrderedStatement::pool_size * sizeof(SgOmpOrderedStatement));
  124966             : #elif ROSE_ALLOC_MEMSET == 2
  124967             :         memset(pointer, 0xCC, SgOmpOrderedStatement::pool_size * sizeof(SgOmpOrderedStatement));
  124968             : #endif
  124969           0 :         SgOmpOrderedStatement::pools.push_back( (unsigned char*)(pointer) );
  124970           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpOrderedStatement::pool_size * sizeof(SgOmpOrderedStatement), V_SgOmpOrderedStatement ) );
  124971             : 
  124972           0 :         if ( SgOmpOrderedStatement::next_node != NULL ) {
  124973           0 :           if ( blockIndex > 0 ) {
  124974           0 :             SgOmpOrderedStatement * blkptr = (SgOmpOrderedStatement*)(SgOmpOrderedStatement::pools[blockIndex-1]);
  124975           0 :             blkptr[ SgOmpOrderedStatement::pool_size - 1 ].set_freepointer(pointer);
  124976             :           }
  124977             :         } else {
  124978           0 :           SgOmpOrderedStatement::next_node = pointer;
  124979             :         }
  124980             : 
  124981           0 :         for (unsigned i = 0; i < SgOmpOrderedStatement::pool_size-1; ++i)
  124982             :            {
  124983           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  124984             :            }
  124985           0 :         pointer[ SgOmpOrderedStatement::pool_size -1 ].set_freepointer(NULL);
  124986             : 
  124987           0 :         blockIndex++;
  124988             :       }
  124989           2 :   }
  124990             : 
  124991             : //############################################################################
  124992             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  124993             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  124994             :  * not compressed. However, that stuff is not yet implemented! 
  124995             :  */
  124996             : unsigned long
  124997           0 : SgOmpOrderedStatement::getNumberOfLastValidPointer()
  124998             :    {
  124999           0 :       SgOmpOrderedStatement* testPointer = (SgOmpOrderedStatement*)(SgOmpOrderedStatement::pools.back());
  125000           0 :       unsigned long localIndex = SgOmpOrderedStatement::pool_size - 1;
  125001           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  125002             :          {
  125003           0 :            localIndex--;
  125004             :          }
  125005           0 :       return (localIndex + SgOmpOrderedStatement::pool_size * (SgOmpOrderedStatement::pools.size()-1));
  125006             :    }
  125007             : 
  125008             : //############################################################################
  125009             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  125010             :  * memory pool and initializes the data member in class SgOmpOrderedStatementStroageClass
  125011             :  * from its counterpart of SgOmpOrderedStatement. The return value is just for checking, 
  125012             :  * that the whole StorageClassArray is initialized!
  125013             :  */
  125014             : unsigned long
  125015           0 : SgOmpOrderedStatement::initializeStorageClassArray( SgOmpOrderedStatementStorageClass *storageArray )
  125016             :    {
  125017           0 :      unsigned long storageCounter = 0;
  125018           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpOrderedStatement::pools.begin();
  125019           0 :      SgOmpOrderedStatement* pointer = NULL;
  125020           0 :      while ( block != SgOmpOrderedStatement::pools.end() ) {
  125021           0 :           pointer = (SgOmpOrderedStatement*) (*block);
  125022           0 :           for ( unsigned i = 0; i < SgOmpOrderedStatement::pool_size; ++i ) {
  125023           0 :                if ( pointer->get_freepointer() != NULL ) {
  125024           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  125025           0 :                  storageArray++;
  125026           0 :                  storageCounter++;
  125027             :                }
  125028           0 :                pointer++;
  125029             :              }
  125030           0 :            block++;
  125031             :         }
  125032           0 :      return storageCounter;
  125033             :    }
  125034             : 
  125035             : /* #line 125036 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  125036             : 
  125037             : 
  125038             : 
  125039             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  125040             : 
  125041             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  125042             : 
  125043             : //############################################################################
  125044             : /* JH (02/02/2006) Constructor of the IR node SgOmpTaskgroupStatement that takes its 
  125045             :  * corresponding StorageClass as parameter
  125046             :  */
  125047           0 : SgOmpTaskgroupStatement :: SgOmpTaskgroupStatement ( const SgOmpTaskgroupStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  125048             :    {
  125049             : 
  125050             : 
  125051             : /* #line 125052 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  125052             : 
  125053           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  125054             : 
  125055             : 
  125056             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  125057             : 
  125058             : 
  125059           0 :    }
  125060             : 
  125061             : //############################################################################
  125062             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  125063             :  * within the working AST. 
  125064             :  */
  125065           0 : SgOmpTaskgroupStatement * SgOmpTaskgroupStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  125066           0 :      SgOmpTaskgroupStatement* returnPointer = NULL;
  125067           0 :      if ( globalIndex != 0 )
  125068             :         {
  125069             : 
  125070             : #if FILE_IO_EXTRA_CHECK
  125071           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTaskgroupStatement ) ) <= globalIndex ) ;
  125072           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskgroupStatement + 1 ) ) );
  125073             : #endif
  125074           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskgroupStatement )  
  125075           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTaskgroupStatement );
  125076           0 :           unsigned long positionInPool = localIndex % SgOmpTaskgroupStatement::pool_size;
  125077           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskgroupStatement::pool_size;
  125078             : 
  125079             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  125080             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  125081             : 
  125082           0 :           returnPointer = &( ( (SgOmpTaskgroupStatement*)(SgOmpTaskgroupStatement::pools[memoryBlock]) ) [positionInPool]) ;
  125083             : 
  125084           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  125085             :         }
  125086           0 :      return returnPointer ;
  125087             :    }
  125088             : 
  125089             : //############################################################################
  125090             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  125091             :   for the AST with the index astIndex
  125092             : */
  125093           0 : SgOmpTaskgroupStatement * SgOmpTaskgroupStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  125094           0 :      SgOmpTaskgroupStatement* returnPointer = NULL;
  125095           0 :      if ( globalIndex != 0 )
  125096             :         {
  125097             : 
  125098             : #if FILE_IO_EXTRA_CHECK
  125099           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTaskgroupStatement ) ) <= globalIndex ) ;
  125100           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskgroupStatement + 1 ) ) );
  125101             : #endif
  125102           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskgroupStatement )
  125103           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTaskgroupStatement );
  125104           0 :           unsigned long positionInPool = localIndex % SgOmpTaskgroupStatement::pool_size ;
  125105           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskgroupStatement::pool_size ;
  125106             : 
  125107             : #if FILE_IO_EXTRA_CHECK
  125108             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  125109             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  125110             : #endif
  125111             : 
  125112           0 :           returnPointer = &( ( (SgOmpTaskgroupStatement*)(SgOmpTaskgroupStatement::pools[memoryBlock]) ) [positionInPool]) ;
  125113             : 
  125114             : #if FILE_IO_EXTRA_CHECK
  125115           0 :           assert ( returnPointer != NULL ) ;
  125116             : #endif
  125117             :         }
  125118           0 :      return returnPointer ;
  125119             :    }
  125120             : 
  125121             : //############################################################################
  125122             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  125123             :  * pool size! We set for every valid object in the memory pool the freepointer
  125124             :  * to the global index and increase the global index afterwards. For all the 
  125125             :  * invalid objects (means address ranges within the memory pool that were not
  125126             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  125127             :  * distinguish valid from invalid objects! 
  125128             :  */
  125129             : unsigned long
  125130           5 : SgOmpTaskgroupStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  125131             :    {
  125132           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  125133           5 :      SgOmpTaskgroupStatement* pointer = NULL;
  125134           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  125135           5 :      std::vector < unsigned char* > :: const_iterator block;
  125136           5 :      for ( block = SgOmpTaskgroupStatement::pools.begin(); block != SgOmpTaskgroupStatement::pools.end() ; ++block )
  125137             :         {
  125138           0 :           pointer = (SgOmpTaskgroupStatement*)(*block);
  125139           0 :           for (unsigned i = 0; i < SgOmpTaskgroupStatement::pool_size; ++i )
  125140             :              {
  125141             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  125142             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  125143             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  125144             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  125145             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  125146             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  125147             :             // properly; so this will have to be checked next.
  125148             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  125149             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  125150           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  125151             :                   {
  125152           0 :                     pointer[i].set_freepointer((SgOmpTaskgroupStatement*)(globalIndex));
  125153           0 :                     globalIndex++;
  125154             :                   }
  125155             :                else
  125156             :                   {
  125157           0 :                     pointer[i].set_freepointer(NULL);
  125158             :                   }
  125159             :               }
  125160             :         }
  125161           5 :      return globalIndex;
  125162             :    }
  125163             : 
  125164             : //############################################################################
  125165             : // JH (01/14/2006)
  125166             : void
  125167           5 : SgOmpTaskgroupStatement::resetValidFreepointers( )
  125168             :    {
  125169           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  125170           5 :      SgOmpTaskgroupStatement* pointer = NULL;
  125171           5 :      std::vector < unsigned char* > :: const_iterator block;
  125172           5 :      SgOmpTaskgroupStatement* pointerOfLinkedList = NULL;
  125173           5 :      for ( block = SgOmpTaskgroupStatement::pools.begin(); block != SgOmpTaskgroupStatement::pools.end() ; ++block )
  125174             :         {
  125175           0 :           pointer = (SgOmpTaskgroupStatement*)(*block);
  125176           0 :           for (unsigned i = 0; i < SgOmpTaskgroupStatement::pool_size; ++i )
  125177             :              {
  125178             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  125179             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  125180             :             // memory blocks!.
  125181           0 :                if ( pointer[i].get_freepointer() != NULL )
  125182             :                   {
  125183           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  125184             :                   }
  125185             :                else
  125186             :                   {
  125187           0 :                     if ( pointerOfLinkedList == NULL )
  125188             :                        {
  125189           0 :                          SgOmpTaskgroupStatement::next_node = &(pointer[i]);
  125190             :                        }
  125191             :                     else
  125192             :                        {
  125193             :                       // printf ("In SgOmpTaskgroupStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  125194           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  125195             :                        }
  125196             :                     pointerOfLinkedList = &(pointer[i]);
  125197             :                   }
  125198             :               }
  125199             :         }
  125200             : 
  125201           5 :      if ( pointerOfLinkedList != NULL )
  125202             :         {
  125203             :        // printf ("In SgOmpTaskgroupStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  125204           0 :           pointerOfLinkedList->set_freepointer(NULL);
  125205             :        // DQ (6/6/2010): Temporary debugging...
  125206             :        //   ROSE_ASSERT(false);
  125207             :         }
  125208             : 
  125209           5 :      return ;
  125210             :    }
  125211             : 
  125212             : //############################################################################
  125213             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  125214             :  * within the memory pool and resets the freepointers, in order to achieve a 
  125215             :  * linked list, that has no jumps and starts at the beginning! This function 
  125216             :  * does not extend the memory pool, since we do not delete any memory blocks,
  125217             :  * but delete the valid objects.  
  125218             :  */
  125219             : void
  125220           0 : SgOmpTaskgroupStatement::clearMemoryPool( )
  125221             :    {
  125222             :   // printf ("Inside of SgOmpTaskgroupStatement::clearMemoryPool() \n");
  125223             : 
  125224           0 :      SgOmpTaskgroupStatement* pointer = NULL, *tempPointer = NULL;
  125225           0 :      std::vector < unsigned char* > :: const_iterator block;
  125226           0 :      if ( SgOmpTaskgroupStatement::pools.empty() == false )
  125227             :         {
  125228           0 :           block = SgOmpTaskgroupStatement::pools.begin() ;
  125229           0 :           SgOmpTaskgroupStatement::next_node = (SgOmpTaskgroupStatement*) (*block);
  125230             : 
  125231           0 :           while ( block != SgOmpTaskgroupStatement::pools.end() )
  125232             :              {
  125233           0 :                pointer = (SgOmpTaskgroupStatement*) (*block);
  125234           0 :                if ( tempPointer != NULL )
  125235             :                   {
  125236           0 :                     tempPointer->set_freepointer(pointer);
  125237             :                   }
  125238           0 :                for (unsigned i = 0; i < SgOmpTaskgroupStatement::pool_size - 1; ++i)
  125239             :                   {
  125240           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  125241             :                   }
  125242           0 :                 pointer[SgOmpTaskgroupStatement::pool_size-1].set_freepointer(NULL);
  125243           0 :                 tempPointer = &(pointer[SgOmpTaskgroupStatement::pool_size-1]);
  125244           0 :                 ++block;
  125245             :              }
  125246             :         }
  125247           0 :    }
  125248             : 
  125249           5 : void SgOmpTaskgroupStatement::deleteMemoryPool() {
  125250           5 :   for (auto p: SgOmpTaskgroupStatement::pools) {
  125251           0 :     ROSE_FREE(p);
  125252             :   }
  125253           5 :   SgOmpTaskgroupStatement::next_node = nullptr;
  125254           5 :   SgOmpTaskgroupStatement::pools.clear();
  125255           5 : }
  125256             : 
  125257             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  125258             : //                 reading multiple binary files to for a single AST.
  125259             : /////////// new version ////////////////////////////////
  125260             : //############################################################################
  125261             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  125262             : void
  125263           2 : SgOmpTaskgroupStatement::extendMemoryPoolForFileIO( )
  125264             :   {
  125265           2 :     size_t blockIndex = SgOmpTaskgroupStatement::pools.size();
  125266           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskgroupStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskgroupStatement);
  125267             : 
  125268           2 :     while ( (blockIndex * SgOmpTaskgroupStatement::pool_size) < newPoolSize)
  125269             :       {
  125270             : #if ROSE_ALLOC_TRACE
  125271             :         if (blockIndex > 0) {
  125272             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskgroupStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskgroupStatement) = %" PRIuPTR " SgOmpTaskgroupStatement::pool_size = %d \n",
  125273             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskgroupStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskgroupStatement),SgOmpTaskgroupStatement::pool_size);
  125274             :         }
  125275             : #endif
  125276             : 
  125277           0 :         SgOmpTaskgroupStatement * pointer = (SgOmpTaskgroupStatement*) ROSE_MALLOC ( SgOmpTaskgroupStatement::pool_size * sizeof(SgOmpTaskgroupStatement) );
  125278           0 :         assert( pointer != NULL );
  125279             : #if ROSE_ALLOC_MEMSET == 1
  125280             :         memset(pointer, 0x00, SgOmpTaskgroupStatement::pool_size * sizeof(SgOmpTaskgroupStatement));
  125281             : #elif ROSE_ALLOC_MEMSET == 2
  125282             :         memset(pointer, 0xCC, SgOmpTaskgroupStatement::pool_size * sizeof(SgOmpTaskgroupStatement));
  125283             : #endif
  125284           0 :         SgOmpTaskgroupStatement::pools.push_back( (unsigned char*)(pointer) );
  125285           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTaskgroupStatement::pool_size * sizeof(SgOmpTaskgroupStatement), V_SgOmpTaskgroupStatement ) );
  125286             : 
  125287           0 :         if ( SgOmpTaskgroupStatement::next_node != NULL ) {
  125288           0 :           if ( blockIndex > 0 ) {
  125289           0 :             SgOmpTaskgroupStatement * blkptr = (SgOmpTaskgroupStatement*)(SgOmpTaskgroupStatement::pools[blockIndex-1]);
  125290           0 :             blkptr[ SgOmpTaskgroupStatement::pool_size - 1 ].set_freepointer(pointer);
  125291             :           }
  125292             :         } else {
  125293           0 :           SgOmpTaskgroupStatement::next_node = pointer;
  125294             :         }
  125295             : 
  125296           0 :         for (unsigned i = 0; i < SgOmpTaskgroupStatement::pool_size-1; ++i)
  125297             :            {
  125298           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  125299             :            }
  125300           0 :         pointer[ SgOmpTaskgroupStatement::pool_size -1 ].set_freepointer(NULL);
  125301             : 
  125302           0 :         blockIndex++;
  125303             :       }
  125304           2 :   }
  125305             : 
  125306             : //############################################################################
  125307             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  125308             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  125309             :  * not compressed. However, that stuff is not yet implemented! 
  125310             :  */
  125311             : unsigned long
  125312           0 : SgOmpTaskgroupStatement::getNumberOfLastValidPointer()
  125313             :    {
  125314           0 :       SgOmpTaskgroupStatement* testPointer = (SgOmpTaskgroupStatement*)(SgOmpTaskgroupStatement::pools.back());
  125315           0 :       unsigned long localIndex = SgOmpTaskgroupStatement::pool_size - 1;
  125316           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  125317             :          {
  125318           0 :            localIndex--;
  125319             :          }
  125320           0 :       return (localIndex + SgOmpTaskgroupStatement::pool_size * (SgOmpTaskgroupStatement::pools.size()-1));
  125321             :    }
  125322             : 
  125323             : //############################################################################
  125324             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  125325             :  * memory pool and initializes the data member in class SgOmpTaskgroupStatementStroageClass
  125326             :  * from its counterpart of SgOmpTaskgroupStatement. The return value is just for checking, 
  125327             :  * that the whole StorageClassArray is initialized!
  125328             :  */
  125329             : unsigned long
  125330           0 : SgOmpTaskgroupStatement::initializeStorageClassArray( SgOmpTaskgroupStatementStorageClass *storageArray )
  125331             :    {
  125332           0 :      unsigned long storageCounter = 0;
  125333           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTaskgroupStatement::pools.begin();
  125334           0 :      SgOmpTaskgroupStatement* pointer = NULL;
  125335           0 :      while ( block != SgOmpTaskgroupStatement::pools.end() ) {
  125336           0 :           pointer = (SgOmpTaskgroupStatement*) (*block);
  125337           0 :           for ( unsigned i = 0; i < SgOmpTaskgroupStatement::pool_size; ++i ) {
  125338           0 :                if ( pointer->get_freepointer() != NULL ) {
  125339           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  125340           0 :                  storageArray++;
  125341           0 :                  storageCounter++;
  125342             :                }
  125343           0 :                pointer++;
  125344             :              }
  125345           0 :            block++;
  125346             :         }
  125347           0 :      return storageCounter;
  125348             :    }
  125349             : 
  125350             : /* #line 125351 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  125351             : 
  125352             : 
  125353             : 
  125354             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  125355             : 
  125356             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  125357             : 
  125358             : //############################################################################
  125359             : /* JH (02/02/2006) Constructor of the IR node SgOmpTaskloopStatement that takes its 
  125360             :  * corresponding StorageClass as parameter
  125361             :  */
  125362           0 : SgOmpTaskloopStatement :: SgOmpTaskloopStatement ( const SgOmpTaskloopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  125363             :    {
  125364             : 
  125365             : 
  125366             : /* #line 125367 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  125367             : 
  125368           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  125369             : 
  125370             : 
  125371             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  125372             : 
  125373             : 
  125374           0 :    }
  125375             : 
  125376             : //############################################################################
  125377             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  125378             :  * within the working AST. 
  125379             :  */
  125380           0 : SgOmpTaskloopStatement * SgOmpTaskloopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  125381           0 :      SgOmpTaskloopStatement* returnPointer = NULL;
  125382           0 :      if ( globalIndex != 0 )
  125383             :         {
  125384             : 
  125385             : #if FILE_IO_EXTRA_CHECK
  125386           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTaskloopStatement ) ) <= globalIndex ) ;
  125387           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskloopStatement + 1 ) ) );
  125388             : #endif
  125389           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskloopStatement )  
  125390           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTaskloopStatement );
  125391           0 :           unsigned long positionInPool = localIndex % SgOmpTaskloopStatement::pool_size;
  125392           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskloopStatement::pool_size;
  125393             : 
  125394             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  125395             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  125396             : 
  125397           0 :           returnPointer = &( ( (SgOmpTaskloopStatement*)(SgOmpTaskloopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  125398             : 
  125399           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  125400             :         }
  125401           0 :      return returnPointer ;
  125402             :    }
  125403             : 
  125404             : //############################################################################
  125405             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  125406             :   for the AST with the index astIndex
  125407             : */
  125408           0 : SgOmpTaskloopStatement * SgOmpTaskloopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  125409           0 :      SgOmpTaskloopStatement* returnPointer = NULL;
  125410           0 :      if ( globalIndex != 0 )
  125411             :         {
  125412             : 
  125413             : #if FILE_IO_EXTRA_CHECK
  125414           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTaskloopStatement ) ) <= globalIndex ) ;
  125415           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskloopStatement + 1 ) ) );
  125416             : #endif
  125417           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskloopStatement )
  125418           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTaskloopStatement );
  125419           0 :           unsigned long positionInPool = localIndex % SgOmpTaskloopStatement::pool_size ;
  125420           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskloopStatement::pool_size ;
  125421             : 
  125422             : #if FILE_IO_EXTRA_CHECK
  125423             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  125424             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  125425             : #endif
  125426             : 
  125427           0 :           returnPointer = &( ( (SgOmpTaskloopStatement*)(SgOmpTaskloopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  125428             : 
  125429             : #if FILE_IO_EXTRA_CHECK
  125430           0 :           assert ( returnPointer != NULL ) ;
  125431             : #endif
  125432             :         }
  125433           0 :      return returnPointer ;
  125434             :    }
  125435             : 
  125436             : //############################################################################
  125437             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  125438             :  * pool size! We set for every valid object in the memory pool the freepointer
  125439             :  * to the global index and increase the global index afterwards. For all the 
  125440             :  * invalid objects (means address ranges within the memory pool that were not
  125441             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  125442             :  * distinguish valid from invalid objects! 
  125443             :  */
  125444             : unsigned long
  125445           5 : SgOmpTaskloopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  125446             :    {
  125447           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  125448           5 :      SgOmpTaskloopStatement* pointer = NULL;
  125449           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  125450           5 :      std::vector < unsigned char* > :: const_iterator block;
  125451           5 :      for ( block = SgOmpTaskloopStatement::pools.begin(); block != SgOmpTaskloopStatement::pools.end() ; ++block )
  125452             :         {
  125453           0 :           pointer = (SgOmpTaskloopStatement*)(*block);
  125454           0 :           for (unsigned i = 0; i < SgOmpTaskloopStatement::pool_size; ++i )
  125455             :              {
  125456             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  125457             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  125458             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  125459             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  125460             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  125461             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  125462             :             // properly; so this will have to be checked next.
  125463             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  125464             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  125465           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  125466             :                   {
  125467           0 :                     pointer[i].set_freepointer((SgOmpTaskloopStatement*)(globalIndex));
  125468           0 :                     globalIndex++;
  125469             :                   }
  125470             :                else
  125471             :                   {
  125472           0 :                     pointer[i].set_freepointer(NULL);
  125473             :                   }
  125474             :               }
  125475             :         }
  125476           5 :      return globalIndex;
  125477             :    }
  125478             : 
  125479             : //############################################################################
  125480             : // JH (01/14/2006)
  125481             : void
  125482           5 : SgOmpTaskloopStatement::resetValidFreepointers( )
  125483             :    {
  125484           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  125485           5 :      SgOmpTaskloopStatement* pointer = NULL;
  125486           5 :      std::vector < unsigned char* > :: const_iterator block;
  125487           5 :      SgOmpTaskloopStatement* pointerOfLinkedList = NULL;
  125488           5 :      for ( block = SgOmpTaskloopStatement::pools.begin(); block != SgOmpTaskloopStatement::pools.end() ; ++block )
  125489             :         {
  125490           0 :           pointer = (SgOmpTaskloopStatement*)(*block);
  125491           0 :           for (unsigned i = 0; i < SgOmpTaskloopStatement::pool_size; ++i )
  125492             :              {
  125493             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  125494             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  125495             :             // memory blocks!.
  125496           0 :                if ( pointer[i].get_freepointer() != NULL )
  125497             :                   {
  125498           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  125499             :                   }
  125500             :                else
  125501             :                   {
  125502           0 :                     if ( pointerOfLinkedList == NULL )
  125503             :                        {
  125504           0 :                          SgOmpTaskloopStatement::next_node = &(pointer[i]);
  125505             :                        }
  125506             :                     else
  125507             :                        {
  125508             :                       // printf ("In SgOmpTaskloopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  125509           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  125510             :                        }
  125511             :                     pointerOfLinkedList = &(pointer[i]);
  125512             :                   }
  125513             :               }
  125514             :         }
  125515             : 
  125516           5 :      if ( pointerOfLinkedList != NULL )
  125517             :         {
  125518             :        // printf ("In SgOmpTaskloopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  125519           0 :           pointerOfLinkedList->set_freepointer(NULL);
  125520             :        // DQ (6/6/2010): Temporary debugging...
  125521             :        //   ROSE_ASSERT(false);
  125522             :         }
  125523             : 
  125524           5 :      return ;
  125525             :    }
  125526             : 
  125527             : //############################################################################
  125528             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  125529             :  * within the memory pool and resets the freepointers, in order to achieve a 
  125530             :  * linked list, that has no jumps and starts at the beginning! This function 
  125531             :  * does not extend the memory pool, since we do not delete any memory blocks,
  125532             :  * but delete the valid objects.  
  125533             :  */
  125534             : void
  125535           0 : SgOmpTaskloopStatement::clearMemoryPool( )
  125536             :    {
  125537             :   // printf ("Inside of SgOmpTaskloopStatement::clearMemoryPool() \n");
  125538             : 
  125539           0 :      SgOmpTaskloopStatement* pointer = NULL, *tempPointer = NULL;
  125540           0 :      std::vector < unsigned char* > :: const_iterator block;
  125541           0 :      if ( SgOmpTaskloopStatement::pools.empty() == false )
  125542             :         {
  125543           0 :           block = SgOmpTaskloopStatement::pools.begin() ;
  125544           0 :           SgOmpTaskloopStatement::next_node = (SgOmpTaskloopStatement*) (*block);
  125545             : 
  125546           0 :           while ( block != SgOmpTaskloopStatement::pools.end() )
  125547             :              {
  125548           0 :                pointer = (SgOmpTaskloopStatement*) (*block);
  125549           0 :                if ( tempPointer != NULL )
  125550             :                   {
  125551           0 :                     tempPointer->set_freepointer(pointer);
  125552             :                   }
  125553           0 :                for (unsigned i = 0; i < SgOmpTaskloopStatement::pool_size - 1; ++i)
  125554             :                   {
  125555           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  125556             :                   }
  125557           0 :                 pointer[SgOmpTaskloopStatement::pool_size-1].set_freepointer(NULL);
  125558           0 :                 tempPointer = &(pointer[SgOmpTaskloopStatement::pool_size-1]);
  125559           0 :                 ++block;
  125560             :              }
  125561             :         }
  125562           0 :    }
  125563             : 
  125564           5 : void SgOmpTaskloopStatement::deleteMemoryPool() {
  125565           5 :   for (auto p: SgOmpTaskloopStatement::pools) {
  125566           0 :     ROSE_FREE(p);
  125567             :   }
  125568           5 :   SgOmpTaskloopStatement::next_node = nullptr;
  125569           5 :   SgOmpTaskloopStatement::pools.clear();
  125570           5 : }
  125571             : 
  125572             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  125573             : //                 reading multiple binary files to for a single AST.
  125574             : /////////// new version ////////////////////////////////
  125575             : //############################################################################
  125576             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  125577             : void
  125578           2 : SgOmpTaskloopStatement::extendMemoryPoolForFileIO( )
  125579             :   {
  125580           2 :     size_t blockIndex = SgOmpTaskloopStatement::pools.size();
  125581           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskloopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskloopStatement);
  125582             : 
  125583           2 :     while ( (blockIndex * SgOmpTaskloopStatement::pool_size) < newPoolSize)
  125584             :       {
  125585             : #if ROSE_ALLOC_TRACE
  125586             :         if (blockIndex > 0) {
  125587             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskloopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskloopStatement) = %" PRIuPTR " SgOmpTaskloopStatement::pool_size = %d \n",
  125588             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskloopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskloopStatement),SgOmpTaskloopStatement::pool_size);
  125589             :         }
  125590             : #endif
  125591             : 
  125592           0 :         SgOmpTaskloopStatement * pointer = (SgOmpTaskloopStatement*) ROSE_MALLOC ( SgOmpTaskloopStatement::pool_size * sizeof(SgOmpTaskloopStatement) );
  125593           0 :         assert( pointer != NULL );
  125594             : #if ROSE_ALLOC_MEMSET == 1
  125595             :         memset(pointer, 0x00, SgOmpTaskloopStatement::pool_size * sizeof(SgOmpTaskloopStatement));
  125596             : #elif ROSE_ALLOC_MEMSET == 2
  125597             :         memset(pointer, 0xCC, SgOmpTaskloopStatement::pool_size * sizeof(SgOmpTaskloopStatement));
  125598             : #endif
  125599           0 :         SgOmpTaskloopStatement::pools.push_back( (unsigned char*)(pointer) );
  125600           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTaskloopStatement::pool_size * sizeof(SgOmpTaskloopStatement), V_SgOmpTaskloopStatement ) );
  125601             : 
  125602           0 :         if ( SgOmpTaskloopStatement::next_node != NULL ) {
  125603           0 :           if ( blockIndex > 0 ) {
  125604           0 :             SgOmpTaskloopStatement * blkptr = (SgOmpTaskloopStatement*)(SgOmpTaskloopStatement::pools[blockIndex-1]);
  125605           0 :             blkptr[ SgOmpTaskloopStatement::pool_size - 1 ].set_freepointer(pointer);
  125606             :           }
  125607             :         } else {
  125608           0 :           SgOmpTaskloopStatement::next_node = pointer;
  125609             :         }
  125610             : 
  125611           0 :         for (unsigned i = 0; i < SgOmpTaskloopStatement::pool_size-1; ++i)
  125612             :            {
  125613           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  125614             :            }
  125615           0 :         pointer[ SgOmpTaskloopStatement::pool_size -1 ].set_freepointer(NULL);
  125616             : 
  125617           0 :         blockIndex++;
  125618             :       }
  125619           2 :   }
  125620             : 
  125621             : //############################################################################
  125622             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  125623             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  125624             :  * not compressed. However, that stuff is not yet implemented! 
  125625             :  */
  125626             : unsigned long
  125627           0 : SgOmpTaskloopStatement::getNumberOfLastValidPointer()
  125628             :    {
  125629           0 :       SgOmpTaskloopStatement* testPointer = (SgOmpTaskloopStatement*)(SgOmpTaskloopStatement::pools.back());
  125630           0 :       unsigned long localIndex = SgOmpTaskloopStatement::pool_size - 1;
  125631           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  125632             :          {
  125633           0 :            localIndex--;
  125634             :          }
  125635           0 :       return (localIndex + SgOmpTaskloopStatement::pool_size * (SgOmpTaskloopStatement::pools.size()-1));
  125636             :    }
  125637             : 
  125638             : //############################################################################
  125639             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  125640             :  * memory pool and initializes the data member in class SgOmpTaskloopStatementStroageClass
  125641             :  * from its counterpart of SgOmpTaskloopStatement. The return value is just for checking, 
  125642             :  * that the whole StorageClassArray is initialized!
  125643             :  */
  125644             : unsigned long
  125645           0 : SgOmpTaskloopStatement::initializeStorageClassArray( SgOmpTaskloopStatementStorageClass *storageArray )
  125646             :    {
  125647           0 :      unsigned long storageCounter = 0;
  125648           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTaskloopStatement::pools.begin();
  125649           0 :      SgOmpTaskloopStatement* pointer = NULL;
  125650           0 :      while ( block != SgOmpTaskloopStatement::pools.end() ) {
  125651           0 :           pointer = (SgOmpTaskloopStatement*) (*block);
  125652           0 :           for ( unsigned i = 0; i < SgOmpTaskloopStatement::pool_size; ++i ) {
  125653           0 :                if ( pointer->get_freepointer() != NULL ) {
  125654           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  125655           0 :                  storageArray++;
  125656           0 :                  storageCounter++;
  125657             :                }
  125658           0 :                pointer++;
  125659             :              }
  125660           0 :            block++;
  125661             :         }
  125662           0 :      return storageCounter;
  125663             :    }
  125664             : 
  125665             : /* #line 125666 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  125666             : 
  125667             : 
  125668             : 
  125669             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  125670             : 
  125671             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  125672             : 
  125673             : //############################################################################
  125674             : /* JH (02/02/2006) Constructor of the IR node SgOmpDepobjStatement that takes its 
  125675             :  * corresponding StorageClass as parameter
  125676             :  */
  125677           0 : SgOmpDepobjStatement :: SgOmpDepobjStatement ( const SgOmpDepobjStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  125678             :    {
  125679             : 
  125680             : 
  125681             : /* #line 125682 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  125682             : 
  125683           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  125684           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
  125685             : 
  125686             : 
  125687             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  125688             : 
  125689             : 
  125690           0 :    }
  125691             : 
  125692             : //############################################################################
  125693             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  125694             :  * within the working AST. 
  125695             :  */
  125696           0 : SgOmpDepobjStatement * SgOmpDepobjStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  125697           0 :      SgOmpDepobjStatement* returnPointer = NULL;
  125698           0 :      if ( globalIndex != 0 )
  125699             :         {
  125700             : 
  125701             : #if FILE_IO_EXTRA_CHECK
  125702           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDepobjStatement ) ) <= globalIndex ) ;
  125703           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDepobjStatement + 1 ) ) );
  125704             : #endif
  125705           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDepobjStatement )  
  125706           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDepobjStatement );
  125707           0 :           unsigned long positionInPool = localIndex % SgOmpDepobjStatement::pool_size;
  125708           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDepobjStatement::pool_size;
  125709             : 
  125710             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  125711             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  125712             : 
  125713           0 :           returnPointer = &( ( (SgOmpDepobjStatement*)(SgOmpDepobjStatement::pools[memoryBlock]) ) [positionInPool]) ;
  125714             : 
  125715           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  125716             :         }
  125717           0 :      return returnPointer ;
  125718             :    }
  125719             : 
  125720             : //############################################################################
  125721             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  125722             :   for the AST with the index astIndex
  125723             : */
  125724           0 : SgOmpDepobjStatement * SgOmpDepobjStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  125725           0 :      SgOmpDepobjStatement* returnPointer = NULL;
  125726           0 :      if ( globalIndex != 0 )
  125727             :         {
  125728             : 
  125729             : #if FILE_IO_EXTRA_CHECK
  125730           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDepobjStatement ) ) <= globalIndex ) ;
  125731           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDepobjStatement + 1 ) ) );
  125732             : #endif
  125733           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDepobjStatement )
  125734           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDepobjStatement );
  125735           0 :           unsigned long positionInPool = localIndex % SgOmpDepobjStatement::pool_size ;
  125736           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDepobjStatement::pool_size ;
  125737             : 
  125738             : #if FILE_IO_EXTRA_CHECK
  125739             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  125740             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  125741             : #endif
  125742             : 
  125743           0 :           returnPointer = &( ( (SgOmpDepobjStatement*)(SgOmpDepobjStatement::pools[memoryBlock]) ) [positionInPool]) ;
  125744             : 
  125745             : #if FILE_IO_EXTRA_CHECK
  125746           0 :           assert ( returnPointer != NULL ) ;
  125747             : #endif
  125748             :         }
  125749           0 :      return returnPointer ;
  125750             :    }
  125751             : 
  125752             : //############################################################################
  125753             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  125754             :  * pool size! We set for every valid object in the memory pool the freepointer
  125755             :  * to the global index and increase the global index afterwards. For all the 
  125756             :  * invalid objects (means address ranges within the memory pool that were not
  125757             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  125758             :  * distinguish valid from invalid objects! 
  125759             :  */
  125760             : unsigned long
  125761           5 : SgOmpDepobjStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  125762             :    {
  125763           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  125764           5 :      SgOmpDepobjStatement* pointer = NULL;
  125765           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  125766           5 :      std::vector < unsigned char* > :: const_iterator block;
  125767           5 :      for ( block = SgOmpDepobjStatement::pools.begin(); block != SgOmpDepobjStatement::pools.end() ; ++block )
  125768             :         {
  125769           0 :           pointer = (SgOmpDepobjStatement*)(*block);
  125770           0 :           for (unsigned i = 0; i < SgOmpDepobjStatement::pool_size; ++i )
  125771             :              {
  125772             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  125773             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  125774             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  125775             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  125776             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  125777             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  125778             :             // properly; so this will have to be checked next.
  125779             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  125780             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  125781           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  125782             :                   {
  125783           0 :                     pointer[i].set_freepointer((SgOmpDepobjStatement*)(globalIndex));
  125784           0 :                     globalIndex++;
  125785             :                   }
  125786             :                else
  125787             :                   {
  125788           0 :                     pointer[i].set_freepointer(NULL);
  125789             :                   }
  125790             :               }
  125791             :         }
  125792           5 :      return globalIndex;
  125793             :    }
  125794             : 
  125795             : //############################################################################
  125796             : // JH (01/14/2006)
  125797             : void
  125798           5 : SgOmpDepobjStatement::resetValidFreepointers( )
  125799             :    {
  125800           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  125801           5 :      SgOmpDepobjStatement* pointer = NULL;
  125802           5 :      std::vector < unsigned char* > :: const_iterator block;
  125803           5 :      SgOmpDepobjStatement* pointerOfLinkedList = NULL;
  125804           5 :      for ( block = SgOmpDepobjStatement::pools.begin(); block != SgOmpDepobjStatement::pools.end() ; ++block )
  125805             :         {
  125806           0 :           pointer = (SgOmpDepobjStatement*)(*block);
  125807           0 :           for (unsigned i = 0; i < SgOmpDepobjStatement::pool_size; ++i )
  125808             :              {
  125809             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  125810             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  125811             :             // memory blocks!.
  125812           0 :                if ( pointer[i].get_freepointer() != NULL )
  125813             :                   {
  125814           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  125815             :                   }
  125816             :                else
  125817             :                   {
  125818           0 :                     if ( pointerOfLinkedList == NULL )
  125819             :                        {
  125820           0 :                          SgOmpDepobjStatement::next_node = &(pointer[i]);
  125821             :                        }
  125822             :                     else
  125823             :                        {
  125824             :                       // printf ("In SgOmpDepobjStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  125825           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  125826             :                        }
  125827             :                     pointerOfLinkedList = &(pointer[i]);
  125828             :                   }
  125829             :               }
  125830             :         }
  125831             : 
  125832           5 :      if ( pointerOfLinkedList != NULL )
  125833             :         {
  125834             :        // printf ("In SgOmpDepobjStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  125835           0 :           pointerOfLinkedList->set_freepointer(NULL);
  125836             :        // DQ (6/6/2010): Temporary debugging...
  125837             :        //   ROSE_ASSERT(false);
  125838             :         }
  125839             : 
  125840           5 :      return ;
  125841             :    }
  125842             : 
  125843             : //############################################################################
  125844             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  125845             :  * within the memory pool and resets the freepointers, in order to achieve a 
  125846             :  * linked list, that has no jumps and starts at the beginning! This function 
  125847             :  * does not extend the memory pool, since we do not delete any memory blocks,
  125848             :  * but delete the valid objects.  
  125849             :  */
  125850             : void
  125851           0 : SgOmpDepobjStatement::clearMemoryPool( )
  125852             :    {
  125853             :   // printf ("Inside of SgOmpDepobjStatement::clearMemoryPool() \n");
  125854             : 
  125855           0 :      SgOmpDepobjStatement* pointer = NULL, *tempPointer = NULL;
  125856           0 :      std::vector < unsigned char* > :: const_iterator block;
  125857           0 :      if ( SgOmpDepobjStatement::pools.empty() == false )
  125858             :         {
  125859           0 :           block = SgOmpDepobjStatement::pools.begin() ;
  125860           0 :           SgOmpDepobjStatement::next_node = (SgOmpDepobjStatement*) (*block);
  125861             : 
  125862           0 :           while ( block != SgOmpDepobjStatement::pools.end() )
  125863             :              {
  125864           0 :                pointer = (SgOmpDepobjStatement*) (*block);
  125865           0 :                if ( tempPointer != NULL )
  125866             :                   {
  125867           0 :                     tempPointer->set_freepointer(pointer);
  125868             :                   }
  125869           0 :                for (unsigned i = 0; i < SgOmpDepobjStatement::pool_size - 1; ++i)
  125870             :                   {
  125871           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  125872             :                   }
  125873           0 :                 pointer[SgOmpDepobjStatement::pool_size-1].set_freepointer(NULL);
  125874           0 :                 tempPointer = &(pointer[SgOmpDepobjStatement::pool_size-1]);
  125875           0 :                 ++block;
  125876             :              }
  125877             :         }
  125878           0 :    }
  125879             : 
  125880           5 : void SgOmpDepobjStatement::deleteMemoryPool() {
  125881           5 :   for (auto p: SgOmpDepobjStatement::pools) {
  125882           0 :     ROSE_FREE(p);
  125883             :   }
  125884           5 :   SgOmpDepobjStatement::next_node = nullptr;
  125885           5 :   SgOmpDepobjStatement::pools.clear();
  125886           5 : }
  125887             : 
  125888             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  125889             : //                 reading multiple binary files to for a single AST.
  125890             : /////////// new version ////////////////////////////////
  125891             : //############################################################################
  125892             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  125893             : void
  125894           2 : SgOmpDepobjStatement::extendMemoryPoolForFileIO( )
  125895             :   {
  125896           2 :     size_t blockIndex = SgOmpDepobjStatement::pools.size();
  125897           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDepobjStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDepobjStatement);
  125898             : 
  125899           2 :     while ( (blockIndex * SgOmpDepobjStatement::pool_size) < newPoolSize)
  125900             :       {
  125901             : #if ROSE_ALLOC_TRACE
  125902             :         if (blockIndex > 0) {
  125903             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDepobjStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDepobjStatement) = %" PRIuPTR " SgOmpDepobjStatement::pool_size = %d \n",
  125904             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDepobjStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDepobjStatement),SgOmpDepobjStatement::pool_size);
  125905             :         }
  125906             : #endif
  125907             : 
  125908           0 :         SgOmpDepobjStatement * pointer = (SgOmpDepobjStatement*) ROSE_MALLOC ( SgOmpDepobjStatement::pool_size * sizeof(SgOmpDepobjStatement) );
  125909           0 :         assert( pointer != NULL );
  125910             : #if ROSE_ALLOC_MEMSET == 1
  125911             :         memset(pointer, 0x00, SgOmpDepobjStatement::pool_size * sizeof(SgOmpDepobjStatement));
  125912             : #elif ROSE_ALLOC_MEMSET == 2
  125913             :         memset(pointer, 0xCC, SgOmpDepobjStatement::pool_size * sizeof(SgOmpDepobjStatement));
  125914             : #endif
  125915           0 :         SgOmpDepobjStatement::pools.push_back( (unsigned char*)(pointer) );
  125916           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDepobjStatement::pool_size * sizeof(SgOmpDepobjStatement), V_SgOmpDepobjStatement ) );
  125917             : 
  125918           0 :         if ( SgOmpDepobjStatement::next_node != NULL ) {
  125919           0 :           if ( blockIndex > 0 ) {
  125920           0 :             SgOmpDepobjStatement * blkptr = (SgOmpDepobjStatement*)(SgOmpDepobjStatement::pools[blockIndex-1]);
  125921           0 :             blkptr[ SgOmpDepobjStatement::pool_size - 1 ].set_freepointer(pointer);
  125922             :           }
  125923             :         } else {
  125924           0 :           SgOmpDepobjStatement::next_node = pointer;
  125925             :         }
  125926             : 
  125927           0 :         for (unsigned i = 0; i < SgOmpDepobjStatement::pool_size-1; ++i)
  125928             :            {
  125929           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  125930             :            }
  125931           0 :         pointer[ SgOmpDepobjStatement::pool_size -1 ].set_freepointer(NULL);
  125932             : 
  125933           0 :         blockIndex++;
  125934             :       }
  125935           2 :   }
  125936             : 
  125937             : //############################################################################
  125938             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  125939             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  125940             :  * not compressed. However, that stuff is not yet implemented! 
  125941             :  */
  125942             : unsigned long
  125943           0 : SgOmpDepobjStatement::getNumberOfLastValidPointer()
  125944             :    {
  125945           0 :       SgOmpDepobjStatement* testPointer = (SgOmpDepobjStatement*)(SgOmpDepobjStatement::pools.back());
  125946           0 :       unsigned long localIndex = SgOmpDepobjStatement::pool_size - 1;
  125947           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  125948             :          {
  125949           0 :            localIndex--;
  125950             :          }
  125951           0 :       return (localIndex + SgOmpDepobjStatement::pool_size * (SgOmpDepobjStatement::pools.size()-1));
  125952             :    }
  125953             : 
  125954             : //############################################################################
  125955             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  125956             :  * memory pool and initializes the data member in class SgOmpDepobjStatementStroageClass
  125957             :  * from its counterpart of SgOmpDepobjStatement. The return value is just for checking, 
  125958             :  * that the whole StorageClassArray is initialized!
  125959             :  */
  125960             : unsigned long
  125961           0 : SgOmpDepobjStatement::initializeStorageClassArray( SgOmpDepobjStatementStorageClass *storageArray )
  125962             :    {
  125963           0 :      unsigned long storageCounter = 0;
  125964           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDepobjStatement::pools.begin();
  125965           0 :      SgOmpDepobjStatement* pointer = NULL;
  125966           0 :      while ( block != SgOmpDepobjStatement::pools.end() ) {
  125967           0 :           pointer = (SgOmpDepobjStatement*) (*block);
  125968           0 :           for ( unsigned i = 0; i < SgOmpDepobjStatement::pool_size; ++i ) {
  125969           0 :                if ( pointer->get_freepointer() != NULL ) {
  125970           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  125971           0 :                  storageArray++;
  125972           0 :                  storageCounter++;
  125973             :                }
  125974           0 :                pointer++;
  125975             :              }
  125976           0 :            block++;
  125977             :         }
  125978           0 :      return storageCounter;
  125979             :    }
  125980             : 
  125981             : /* #line 125982 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  125982             : 
  125983             : 
  125984             : 
  125985             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  125986             : 
  125987             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  125988             : 
  125989             : //############################################################################
  125990             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetEnterDataStatement that takes its 
  125991             :  * corresponding StorageClass as parameter
  125992             :  */
  125993           0 : SgOmpTargetEnterDataStatement :: SgOmpTargetEnterDataStatement ( const SgOmpTargetEnterDataStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  125994             :    {
  125995             : 
  125996             : 
  125997             : /* #line 125998 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  125998             : 
  125999           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  126000             : 
  126001             : 
  126002             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  126003             : 
  126004             : 
  126005           0 :    }
  126006             : 
  126007             : //############################################################################
  126008             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  126009             :  * within the working AST. 
  126010             :  */
  126011           0 : SgOmpTargetEnterDataStatement * SgOmpTargetEnterDataStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  126012           0 :      SgOmpTargetEnterDataStatement* returnPointer = NULL;
  126013           0 :      if ( globalIndex != 0 )
  126014             :         {
  126015             : 
  126016             : #if FILE_IO_EXTRA_CHECK
  126017           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetEnterDataStatement ) ) <= globalIndex ) ;
  126018           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetEnterDataStatement + 1 ) ) );
  126019             : #endif
  126020           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetEnterDataStatement )  
  126021           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetEnterDataStatement );
  126022           0 :           unsigned long positionInPool = localIndex % SgOmpTargetEnterDataStatement::pool_size;
  126023           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetEnterDataStatement::pool_size;
  126024             : 
  126025             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  126026             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  126027             : 
  126028           0 :           returnPointer = &( ( (SgOmpTargetEnterDataStatement*)(SgOmpTargetEnterDataStatement::pools[memoryBlock]) ) [positionInPool]) ;
  126029             : 
  126030           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  126031             :         }
  126032           0 :      return returnPointer ;
  126033             :    }
  126034             : 
  126035             : //############################################################################
  126036             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  126037             :   for the AST with the index astIndex
  126038             : */
  126039           0 : SgOmpTargetEnterDataStatement * SgOmpTargetEnterDataStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  126040           0 :      SgOmpTargetEnterDataStatement* returnPointer = NULL;
  126041           0 :      if ( globalIndex != 0 )
  126042             :         {
  126043             : 
  126044             : #if FILE_IO_EXTRA_CHECK
  126045           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetEnterDataStatement ) ) <= globalIndex ) ;
  126046           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetEnterDataStatement + 1 ) ) );
  126047             : #endif
  126048           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetEnterDataStatement )
  126049           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetEnterDataStatement );
  126050           0 :           unsigned long positionInPool = localIndex % SgOmpTargetEnterDataStatement::pool_size ;
  126051           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetEnterDataStatement::pool_size ;
  126052             : 
  126053             : #if FILE_IO_EXTRA_CHECK
  126054             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  126055             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  126056             : #endif
  126057             : 
  126058           0 :           returnPointer = &( ( (SgOmpTargetEnterDataStatement*)(SgOmpTargetEnterDataStatement::pools[memoryBlock]) ) [positionInPool]) ;
  126059             : 
  126060             : #if FILE_IO_EXTRA_CHECK
  126061           0 :           assert ( returnPointer != NULL ) ;
  126062             : #endif
  126063             :         }
  126064           0 :      return returnPointer ;
  126065             :    }
  126066             : 
  126067             : //############################################################################
  126068             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  126069             :  * pool size! We set for every valid object in the memory pool the freepointer
  126070             :  * to the global index and increase the global index afterwards. For all the 
  126071             :  * invalid objects (means address ranges within the memory pool that were not
  126072             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  126073             :  * distinguish valid from invalid objects! 
  126074             :  */
  126075             : unsigned long
  126076           5 : SgOmpTargetEnterDataStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  126077             :    {
  126078           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  126079           5 :      SgOmpTargetEnterDataStatement* pointer = NULL;
  126080           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  126081           5 :      std::vector < unsigned char* > :: const_iterator block;
  126082           5 :      for ( block = SgOmpTargetEnterDataStatement::pools.begin(); block != SgOmpTargetEnterDataStatement::pools.end() ; ++block )
  126083             :         {
  126084           0 :           pointer = (SgOmpTargetEnterDataStatement*)(*block);
  126085           0 :           for (unsigned i = 0; i < SgOmpTargetEnterDataStatement::pool_size; ++i )
  126086             :              {
  126087             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  126088             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  126089             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  126090             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  126091             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  126092             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  126093             :             // properly; so this will have to be checked next.
  126094             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  126095             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  126096           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  126097             :                   {
  126098           0 :                     pointer[i].set_freepointer((SgOmpTargetEnterDataStatement*)(globalIndex));
  126099           0 :                     globalIndex++;
  126100             :                   }
  126101             :                else
  126102             :                   {
  126103           0 :                     pointer[i].set_freepointer(NULL);
  126104             :                   }
  126105             :               }
  126106             :         }
  126107           5 :      return globalIndex;
  126108             :    }
  126109             : 
  126110             : //############################################################################
  126111             : // JH (01/14/2006)
  126112             : void
  126113           5 : SgOmpTargetEnterDataStatement::resetValidFreepointers( )
  126114             :    {
  126115           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  126116           5 :      SgOmpTargetEnterDataStatement* pointer = NULL;
  126117           5 :      std::vector < unsigned char* > :: const_iterator block;
  126118           5 :      SgOmpTargetEnterDataStatement* pointerOfLinkedList = NULL;
  126119           5 :      for ( block = SgOmpTargetEnterDataStatement::pools.begin(); block != SgOmpTargetEnterDataStatement::pools.end() ; ++block )
  126120             :         {
  126121           0 :           pointer = (SgOmpTargetEnterDataStatement*)(*block);
  126122           0 :           for (unsigned i = 0; i < SgOmpTargetEnterDataStatement::pool_size; ++i )
  126123             :              {
  126124             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  126125             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  126126             :             // memory blocks!.
  126127           0 :                if ( pointer[i].get_freepointer() != NULL )
  126128             :                   {
  126129           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  126130             :                   }
  126131             :                else
  126132             :                   {
  126133           0 :                     if ( pointerOfLinkedList == NULL )
  126134             :                        {
  126135           0 :                          SgOmpTargetEnterDataStatement::next_node = &(pointer[i]);
  126136             :                        }
  126137             :                     else
  126138             :                        {
  126139             :                       // printf ("In SgOmpTargetEnterDataStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  126140           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  126141             :                        }
  126142             :                     pointerOfLinkedList = &(pointer[i]);
  126143             :                   }
  126144             :               }
  126145             :         }
  126146             : 
  126147           5 :      if ( pointerOfLinkedList != NULL )
  126148             :         {
  126149             :        // printf ("In SgOmpTargetEnterDataStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  126150           0 :           pointerOfLinkedList->set_freepointer(NULL);
  126151             :        // DQ (6/6/2010): Temporary debugging...
  126152             :        //   ROSE_ASSERT(false);
  126153             :         }
  126154             : 
  126155           5 :      return ;
  126156             :    }
  126157             : 
  126158             : //############################################################################
  126159             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  126160             :  * within the memory pool and resets the freepointers, in order to achieve a 
  126161             :  * linked list, that has no jumps and starts at the beginning! This function 
  126162             :  * does not extend the memory pool, since we do not delete any memory blocks,
  126163             :  * but delete the valid objects.  
  126164             :  */
  126165             : void
  126166           0 : SgOmpTargetEnterDataStatement::clearMemoryPool( )
  126167             :    {
  126168             :   // printf ("Inside of SgOmpTargetEnterDataStatement::clearMemoryPool() \n");
  126169             : 
  126170           0 :      SgOmpTargetEnterDataStatement* pointer = NULL, *tempPointer = NULL;
  126171           0 :      std::vector < unsigned char* > :: const_iterator block;
  126172           0 :      if ( SgOmpTargetEnterDataStatement::pools.empty() == false )
  126173             :         {
  126174           0 :           block = SgOmpTargetEnterDataStatement::pools.begin() ;
  126175           0 :           SgOmpTargetEnterDataStatement::next_node = (SgOmpTargetEnterDataStatement*) (*block);
  126176             : 
  126177           0 :           while ( block != SgOmpTargetEnterDataStatement::pools.end() )
  126178             :              {
  126179           0 :                pointer = (SgOmpTargetEnterDataStatement*) (*block);
  126180           0 :                if ( tempPointer != NULL )
  126181             :                   {
  126182           0 :                     tempPointer->set_freepointer(pointer);
  126183             :                   }
  126184           0 :                for (unsigned i = 0; i < SgOmpTargetEnterDataStatement::pool_size - 1; ++i)
  126185             :                   {
  126186           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  126187             :                   }
  126188           0 :                 pointer[SgOmpTargetEnterDataStatement::pool_size-1].set_freepointer(NULL);
  126189           0 :                 tempPointer = &(pointer[SgOmpTargetEnterDataStatement::pool_size-1]);
  126190           0 :                 ++block;
  126191             :              }
  126192             :         }
  126193           0 :    }
  126194             : 
  126195           5 : void SgOmpTargetEnterDataStatement::deleteMemoryPool() {
  126196           5 :   for (auto p: SgOmpTargetEnterDataStatement::pools) {
  126197           0 :     ROSE_FREE(p);
  126198             :   }
  126199           5 :   SgOmpTargetEnterDataStatement::next_node = nullptr;
  126200           5 :   SgOmpTargetEnterDataStatement::pools.clear();
  126201           5 : }
  126202             : 
  126203             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  126204             : //                 reading multiple binary files to for a single AST.
  126205             : /////////// new version ////////////////////////////////
  126206             : //############################################################################
  126207             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  126208             : void
  126209           2 : SgOmpTargetEnterDataStatement::extendMemoryPoolForFileIO( )
  126210             :   {
  126211           2 :     size_t blockIndex = SgOmpTargetEnterDataStatement::pools.size();
  126212           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetEnterDataStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetEnterDataStatement);
  126213             : 
  126214           2 :     while ( (blockIndex * SgOmpTargetEnterDataStatement::pool_size) < newPoolSize)
  126215             :       {
  126216             : #if ROSE_ALLOC_TRACE
  126217             :         if (blockIndex > 0) {
  126218             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetEnterDataStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetEnterDataStatement) = %" PRIuPTR " SgOmpTargetEnterDataStatement::pool_size = %d \n",
  126219             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetEnterDataStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetEnterDataStatement),SgOmpTargetEnterDataStatement::pool_size);
  126220             :         }
  126221             : #endif
  126222             : 
  126223           0 :         SgOmpTargetEnterDataStatement * pointer = (SgOmpTargetEnterDataStatement*) ROSE_MALLOC ( SgOmpTargetEnterDataStatement::pool_size * sizeof(SgOmpTargetEnterDataStatement) );
  126224           0 :         assert( pointer != NULL );
  126225             : #if ROSE_ALLOC_MEMSET == 1
  126226             :         memset(pointer, 0x00, SgOmpTargetEnterDataStatement::pool_size * sizeof(SgOmpTargetEnterDataStatement));
  126227             : #elif ROSE_ALLOC_MEMSET == 2
  126228             :         memset(pointer, 0xCC, SgOmpTargetEnterDataStatement::pool_size * sizeof(SgOmpTargetEnterDataStatement));
  126229             : #endif
  126230           0 :         SgOmpTargetEnterDataStatement::pools.push_back( (unsigned char*)(pointer) );
  126231           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetEnterDataStatement::pool_size * sizeof(SgOmpTargetEnterDataStatement), V_SgOmpTargetEnterDataStatement ) );
  126232             : 
  126233           0 :         if ( SgOmpTargetEnterDataStatement::next_node != NULL ) {
  126234           0 :           if ( blockIndex > 0 ) {
  126235           0 :             SgOmpTargetEnterDataStatement * blkptr = (SgOmpTargetEnterDataStatement*)(SgOmpTargetEnterDataStatement::pools[blockIndex-1]);
  126236           0 :             blkptr[ SgOmpTargetEnterDataStatement::pool_size - 1 ].set_freepointer(pointer);
  126237             :           }
  126238             :         } else {
  126239           0 :           SgOmpTargetEnterDataStatement::next_node = pointer;
  126240             :         }
  126241             : 
  126242           0 :         for (unsigned i = 0; i < SgOmpTargetEnterDataStatement::pool_size-1; ++i)
  126243             :            {
  126244           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  126245             :            }
  126246           0 :         pointer[ SgOmpTargetEnterDataStatement::pool_size -1 ].set_freepointer(NULL);
  126247             : 
  126248           0 :         blockIndex++;
  126249             :       }
  126250           2 :   }
  126251             : 
  126252             : //############################################################################
  126253             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  126254             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  126255             :  * not compressed. However, that stuff is not yet implemented! 
  126256             :  */
  126257             : unsigned long
  126258           0 : SgOmpTargetEnterDataStatement::getNumberOfLastValidPointer()
  126259             :    {
  126260           0 :       SgOmpTargetEnterDataStatement* testPointer = (SgOmpTargetEnterDataStatement*)(SgOmpTargetEnterDataStatement::pools.back());
  126261           0 :       unsigned long localIndex = SgOmpTargetEnterDataStatement::pool_size - 1;
  126262           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  126263             :          {
  126264           0 :            localIndex--;
  126265             :          }
  126266           0 :       return (localIndex + SgOmpTargetEnterDataStatement::pool_size * (SgOmpTargetEnterDataStatement::pools.size()-1));
  126267             :    }
  126268             : 
  126269             : //############################################################################
  126270             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  126271             :  * memory pool and initializes the data member in class SgOmpTargetEnterDataStatementStroageClass
  126272             :  * from its counterpart of SgOmpTargetEnterDataStatement. The return value is just for checking, 
  126273             :  * that the whole StorageClassArray is initialized!
  126274             :  */
  126275             : unsigned long
  126276           0 : SgOmpTargetEnterDataStatement::initializeStorageClassArray( SgOmpTargetEnterDataStatementStorageClass *storageArray )
  126277             :    {
  126278           0 :      unsigned long storageCounter = 0;
  126279           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetEnterDataStatement::pools.begin();
  126280           0 :      SgOmpTargetEnterDataStatement* pointer = NULL;
  126281           0 :      while ( block != SgOmpTargetEnterDataStatement::pools.end() ) {
  126282           0 :           pointer = (SgOmpTargetEnterDataStatement*) (*block);
  126283           0 :           for ( unsigned i = 0; i < SgOmpTargetEnterDataStatement::pool_size; ++i ) {
  126284           0 :                if ( pointer->get_freepointer() != NULL ) {
  126285           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  126286           0 :                  storageArray++;
  126287           0 :                  storageCounter++;
  126288             :                }
  126289           0 :                pointer++;
  126290             :              }
  126291           0 :            block++;
  126292             :         }
  126293           0 :      return storageCounter;
  126294             :    }
  126295             : 
  126296             : /* #line 126297 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  126297             : 
  126298             : 
  126299             : 
  126300             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  126301             : 
  126302             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  126303             : 
  126304             : //############################################################################
  126305             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetExitDataStatement that takes its 
  126306             :  * corresponding StorageClass as parameter
  126307             :  */
  126308           0 : SgOmpTargetExitDataStatement :: SgOmpTargetExitDataStatement ( const SgOmpTargetExitDataStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  126309             :    {
  126310             : 
  126311             : 
  126312             : /* #line 126313 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  126313             : 
  126314           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  126315             : 
  126316             : 
  126317             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  126318             : 
  126319             : 
  126320           0 :    }
  126321             : 
  126322             : //############################################################################
  126323             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  126324             :  * within the working AST. 
  126325             :  */
  126326           0 : SgOmpTargetExitDataStatement * SgOmpTargetExitDataStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  126327           0 :      SgOmpTargetExitDataStatement* returnPointer = NULL;
  126328           0 :      if ( globalIndex != 0 )
  126329             :         {
  126330             : 
  126331             : #if FILE_IO_EXTRA_CHECK
  126332           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetExitDataStatement ) ) <= globalIndex ) ;
  126333           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetExitDataStatement + 1 ) ) );
  126334             : #endif
  126335           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetExitDataStatement )  
  126336           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetExitDataStatement );
  126337           0 :           unsigned long positionInPool = localIndex % SgOmpTargetExitDataStatement::pool_size;
  126338           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetExitDataStatement::pool_size;
  126339             : 
  126340             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  126341             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  126342             : 
  126343           0 :           returnPointer = &( ( (SgOmpTargetExitDataStatement*)(SgOmpTargetExitDataStatement::pools[memoryBlock]) ) [positionInPool]) ;
  126344             : 
  126345           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  126346             :         }
  126347           0 :      return returnPointer ;
  126348             :    }
  126349             : 
  126350             : //############################################################################
  126351             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  126352             :   for the AST with the index astIndex
  126353             : */
  126354           0 : SgOmpTargetExitDataStatement * SgOmpTargetExitDataStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  126355           0 :      SgOmpTargetExitDataStatement* returnPointer = NULL;
  126356           0 :      if ( globalIndex != 0 )
  126357             :         {
  126358             : 
  126359             : #if FILE_IO_EXTRA_CHECK
  126360           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetExitDataStatement ) ) <= globalIndex ) ;
  126361           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetExitDataStatement + 1 ) ) );
  126362             : #endif
  126363           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetExitDataStatement )
  126364           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetExitDataStatement );
  126365           0 :           unsigned long positionInPool = localIndex % SgOmpTargetExitDataStatement::pool_size ;
  126366           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetExitDataStatement::pool_size ;
  126367             : 
  126368             : #if FILE_IO_EXTRA_CHECK
  126369             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  126370             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  126371             : #endif
  126372             : 
  126373           0 :           returnPointer = &( ( (SgOmpTargetExitDataStatement*)(SgOmpTargetExitDataStatement::pools[memoryBlock]) ) [positionInPool]) ;
  126374             : 
  126375             : #if FILE_IO_EXTRA_CHECK
  126376           0 :           assert ( returnPointer != NULL ) ;
  126377             : #endif
  126378             :         }
  126379           0 :      return returnPointer ;
  126380             :    }
  126381             : 
  126382             : //############################################################################
  126383             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  126384             :  * pool size! We set for every valid object in the memory pool the freepointer
  126385             :  * to the global index and increase the global index afterwards. For all the 
  126386             :  * invalid objects (means address ranges within the memory pool that were not
  126387             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  126388             :  * distinguish valid from invalid objects! 
  126389             :  */
  126390             : unsigned long
  126391           5 : SgOmpTargetExitDataStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  126392             :    {
  126393           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  126394           5 :      SgOmpTargetExitDataStatement* pointer = NULL;
  126395           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  126396           5 :      std::vector < unsigned char* > :: const_iterator block;
  126397           5 :      for ( block = SgOmpTargetExitDataStatement::pools.begin(); block != SgOmpTargetExitDataStatement::pools.end() ; ++block )
  126398             :         {
  126399           0 :           pointer = (SgOmpTargetExitDataStatement*)(*block);
  126400           0 :           for (unsigned i = 0; i < SgOmpTargetExitDataStatement::pool_size; ++i )
  126401             :              {
  126402             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  126403             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  126404             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  126405             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  126406             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  126407             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  126408             :             // properly; so this will have to be checked next.
  126409             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  126410             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  126411           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  126412             :                   {
  126413           0 :                     pointer[i].set_freepointer((SgOmpTargetExitDataStatement*)(globalIndex));
  126414           0 :                     globalIndex++;
  126415             :                   }
  126416             :                else
  126417             :                   {
  126418           0 :                     pointer[i].set_freepointer(NULL);
  126419             :                   }
  126420             :               }
  126421             :         }
  126422           5 :      return globalIndex;
  126423             :    }
  126424             : 
  126425             : //############################################################################
  126426             : // JH (01/14/2006)
  126427             : void
  126428           5 : SgOmpTargetExitDataStatement::resetValidFreepointers( )
  126429             :    {
  126430           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  126431           5 :      SgOmpTargetExitDataStatement* pointer = NULL;
  126432           5 :      std::vector < unsigned char* > :: const_iterator block;
  126433           5 :      SgOmpTargetExitDataStatement* pointerOfLinkedList = NULL;
  126434           5 :      for ( block = SgOmpTargetExitDataStatement::pools.begin(); block != SgOmpTargetExitDataStatement::pools.end() ; ++block )
  126435             :         {
  126436           0 :           pointer = (SgOmpTargetExitDataStatement*)(*block);
  126437           0 :           for (unsigned i = 0; i < SgOmpTargetExitDataStatement::pool_size; ++i )
  126438             :              {
  126439             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  126440             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  126441             :             // memory blocks!.
  126442           0 :                if ( pointer[i].get_freepointer() != NULL )
  126443             :                   {
  126444           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  126445             :                   }
  126446             :                else
  126447             :                   {
  126448           0 :                     if ( pointerOfLinkedList == NULL )
  126449             :                        {
  126450           0 :                          SgOmpTargetExitDataStatement::next_node = &(pointer[i]);
  126451             :                        }
  126452             :                     else
  126453             :                        {
  126454             :                       // printf ("In SgOmpTargetExitDataStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  126455           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  126456             :                        }
  126457             :                     pointerOfLinkedList = &(pointer[i]);
  126458             :                   }
  126459             :               }
  126460             :         }
  126461             : 
  126462           5 :      if ( pointerOfLinkedList != NULL )
  126463             :         {
  126464             :        // printf ("In SgOmpTargetExitDataStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  126465           0 :           pointerOfLinkedList->set_freepointer(NULL);
  126466             :        // DQ (6/6/2010): Temporary debugging...
  126467             :        //   ROSE_ASSERT(false);
  126468             :         }
  126469             : 
  126470           5 :      return ;
  126471             :    }
  126472             : 
  126473             : //############################################################################
  126474             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  126475             :  * within the memory pool and resets the freepointers, in order to achieve a 
  126476             :  * linked list, that has no jumps and starts at the beginning! This function 
  126477             :  * does not extend the memory pool, since we do not delete any memory blocks,
  126478             :  * but delete the valid objects.  
  126479             :  */
  126480             : void
  126481           0 : SgOmpTargetExitDataStatement::clearMemoryPool( )
  126482             :    {
  126483             :   // printf ("Inside of SgOmpTargetExitDataStatement::clearMemoryPool() \n");
  126484             : 
  126485           0 :      SgOmpTargetExitDataStatement* pointer = NULL, *tempPointer = NULL;
  126486           0 :      std::vector < unsigned char* > :: const_iterator block;
  126487           0 :      if ( SgOmpTargetExitDataStatement::pools.empty() == false )
  126488             :         {
  126489           0 :           block = SgOmpTargetExitDataStatement::pools.begin() ;
  126490           0 :           SgOmpTargetExitDataStatement::next_node = (SgOmpTargetExitDataStatement*) (*block);
  126491             : 
  126492           0 :           while ( block != SgOmpTargetExitDataStatement::pools.end() )
  126493             :              {
  126494           0 :                pointer = (SgOmpTargetExitDataStatement*) (*block);
  126495           0 :                if ( tempPointer != NULL )
  126496             :                   {
  126497           0 :                     tempPointer->set_freepointer(pointer);
  126498             :                   }
  126499           0 :                for (unsigned i = 0; i < SgOmpTargetExitDataStatement::pool_size - 1; ++i)
  126500             :                   {
  126501           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  126502             :                   }
  126503           0 :                 pointer[SgOmpTargetExitDataStatement::pool_size-1].set_freepointer(NULL);
  126504           0 :                 tempPointer = &(pointer[SgOmpTargetExitDataStatement::pool_size-1]);
  126505           0 :                 ++block;
  126506             :              }
  126507             :         }
  126508           0 :    }
  126509             : 
  126510           5 : void SgOmpTargetExitDataStatement::deleteMemoryPool() {
  126511           5 :   for (auto p: SgOmpTargetExitDataStatement::pools) {
  126512           0 :     ROSE_FREE(p);
  126513             :   }
  126514           5 :   SgOmpTargetExitDataStatement::next_node = nullptr;
  126515           5 :   SgOmpTargetExitDataStatement::pools.clear();
  126516           5 : }
  126517             : 
  126518             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  126519             : //                 reading multiple binary files to for a single AST.
  126520             : /////////// new version ////////////////////////////////
  126521             : //############################################################################
  126522             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  126523             : void
  126524           2 : SgOmpTargetExitDataStatement::extendMemoryPoolForFileIO( )
  126525             :   {
  126526           2 :     size_t blockIndex = SgOmpTargetExitDataStatement::pools.size();
  126527           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetExitDataStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetExitDataStatement);
  126528             : 
  126529           2 :     while ( (blockIndex * SgOmpTargetExitDataStatement::pool_size) < newPoolSize)
  126530             :       {
  126531             : #if ROSE_ALLOC_TRACE
  126532             :         if (blockIndex > 0) {
  126533             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetExitDataStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetExitDataStatement) = %" PRIuPTR " SgOmpTargetExitDataStatement::pool_size = %d \n",
  126534             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetExitDataStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetExitDataStatement),SgOmpTargetExitDataStatement::pool_size);
  126535             :         }
  126536             : #endif
  126537             : 
  126538           0 :         SgOmpTargetExitDataStatement * pointer = (SgOmpTargetExitDataStatement*) ROSE_MALLOC ( SgOmpTargetExitDataStatement::pool_size * sizeof(SgOmpTargetExitDataStatement) );
  126539           0 :         assert( pointer != NULL );
  126540             : #if ROSE_ALLOC_MEMSET == 1
  126541             :         memset(pointer, 0x00, SgOmpTargetExitDataStatement::pool_size * sizeof(SgOmpTargetExitDataStatement));
  126542             : #elif ROSE_ALLOC_MEMSET == 2
  126543             :         memset(pointer, 0xCC, SgOmpTargetExitDataStatement::pool_size * sizeof(SgOmpTargetExitDataStatement));
  126544             : #endif
  126545           0 :         SgOmpTargetExitDataStatement::pools.push_back( (unsigned char*)(pointer) );
  126546           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetExitDataStatement::pool_size * sizeof(SgOmpTargetExitDataStatement), V_SgOmpTargetExitDataStatement ) );
  126547             : 
  126548           0 :         if ( SgOmpTargetExitDataStatement::next_node != NULL ) {
  126549           0 :           if ( blockIndex > 0 ) {
  126550           0 :             SgOmpTargetExitDataStatement * blkptr = (SgOmpTargetExitDataStatement*)(SgOmpTargetExitDataStatement::pools[blockIndex-1]);
  126551           0 :             blkptr[ SgOmpTargetExitDataStatement::pool_size - 1 ].set_freepointer(pointer);
  126552             :           }
  126553             :         } else {
  126554           0 :           SgOmpTargetExitDataStatement::next_node = pointer;
  126555             :         }
  126556             : 
  126557           0 :         for (unsigned i = 0; i < SgOmpTargetExitDataStatement::pool_size-1; ++i)
  126558             :            {
  126559           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  126560             :            }
  126561           0 :         pointer[ SgOmpTargetExitDataStatement::pool_size -1 ].set_freepointer(NULL);
  126562             : 
  126563           0 :         blockIndex++;
  126564             :       }
  126565           2 :   }
  126566             : 
  126567             : //############################################################################
  126568             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  126569             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  126570             :  * not compressed. However, that stuff is not yet implemented! 
  126571             :  */
  126572             : unsigned long
  126573           0 : SgOmpTargetExitDataStatement::getNumberOfLastValidPointer()
  126574             :    {
  126575           0 :       SgOmpTargetExitDataStatement* testPointer = (SgOmpTargetExitDataStatement*)(SgOmpTargetExitDataStatement::pools.back());
  126576           0 :       unsigned long localIndex = SgOmpTargetExitDataStatement::pool_size - 1;
  126577           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  126578             :          {
  126579           0 :            localIndex--;
  126580             :          }
  126581           0 :       return (localIndex + SgOmpTargetExitDataStatement::pool_size * (SgOmpTargetExitDataStatement::pools.size()-1));
  126582             :    }
  126583             : 
  126584             : //############################################################################
  126585             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  126586             :  * memory pool and initializes the data member in class SgOmpTargetExitDataStatementStroageClass
  126587             :  * from its counterpart of SgOmpTargetExitDataStatement. The return value is just for checking, 
  126588             :  * that the whole StorageClassArray is initialized!
  126589             :  */
  126590             : unsigned long
  126591           0 : SgOmpTargetExitDataStatement::initializeStorageClassArray( SgOmpTargetExitDataStatementStorageClass *storageArray )
  126592             :    {
  126593           0 :      unsigned long storageCounter = 0;
  126594           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetExitDataStatement::pools.begin();
  126595           0 :      SgOmpTargetExitDataStatement* pointer = NULL;
  126596           0 :      while ( block != SgOmpTargetExitDataStatement::pools.end() ) {
  126597           0 :           pointer = (SgOmpTargetExitDataStatement*) (*block);
  126598           0 :           for ( unsigned i = 0; i < SgOmpTargetExitDataStatement::pool_size; ++i ) {
  126599           0 :                if ( pointer->get_freepointer() != NULL ) {
  126600           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  126601           0 :                  storageArray++;
  126602           0 :                  storageCounter++;
  126603             :                }
  126604           0 :                pointer++;
  126605             :              }
  126606           0 :            block++;
  126607             :         }
  126608           0 :      return storageCounter;
  126609             :    }
  126610             : 
  126611             : /* #line 126612 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  126612             : 
  126613             : 
  126614             : 
  126615             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  126616             : 
  126617             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  126618             : 
  126619             : //############################################################################
  126620             : /* JH (02/02/2006) Constructor of the IR node SgOmpParallelMasterStatement that takes its 
  126621             :  * corresponding StorageClass as parameter
  126622             :  */
  126623           0 : SgOmpParallelMasterStatement :: SgOmpParallelMasterStatement ( const SgOmpParallelMasterStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  126624             :    {
  126625             : 
  126626             : 
  126627             : /* #line 126628 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  126628             : 
  126629           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  126630             : 
  126631             : 
  126632             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  126633             : 
  126634             : 
  126635           0 :    }
  126636             : 
  126637             : //############################################################################
  126638             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  126639             :  * within the working AST. 
  126640             :  */
  126641           0 : SgOmpParallelMasterStatement * SgOmpParallelMasterStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  126642           0 :      SgOmpParallelMasterStatement* returnPointer = NULL;
  126643           0 :      if ( globalIndex != 0 )
  126644             :         {
  126645             : 
  126646             : #if FILE_IO_EXTRA_CHECK
  126647           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpParallelMasterStatement ) ) <= globalIndex ) ;
  126648           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelMasterStatement + 1 ) ) );
  126649             : #endif
  126650           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelMasterStatement )  
  126651           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpParallelMasterStatement );
  126652           0 :           unsigned long positionInPool = localIndex % SgOmpParallelMasterStatement::pool_size;
  126653           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelMasterStatement::pool_size;
  126654             : 
  126655             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  126656             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  126657             : 
  126658           0 :           returnPointer = &( ( (SgOmpParallelMasterStatement*)(SgOmpParallelMasterStatement::pools[memoryBlock]) ) [positionInPool]) ;
  126659             : 
  126660           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  126661             :         }
  126662           0 :      return returnPointer ;
  126663             :    }
  126664             : 
  126665             : //############################################################################
  126666             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  126667             :   for the AST with the index astIndex
  126668             : */
  126669           0 : SgOmpParallelMasterStatement * SgOmpParallelMasterStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  126670           0 :      SgOmpParallelMasterStatement* returnPointer = NULL;
  126671           0 :      if ( globalIndex != 0 )
  126672             :         {
  126673             : 
  126674             : #if FILE_IO_EXTRA_CHECK
  126675           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpParallelMasterStatement ) ) <= globalIndex ) ;
  126676           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelMasterStatement + 1 ) ) );
  126677             : #endif
  126678           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelMasterStatement )
  126679           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpParallelMasterStatement );
  126680           0 :           unsigned long positionInPool = localIndex % SgOmpParallelMasterStatement::pool_size ;
  126681           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelMasterStatement::pool_size ;
  126682             : 
  126683             : #if FILE_IO_EXTRA_CHECK
  126684             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  126685             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  126686             : #endif
  126687             : 
  126688           0 :           returnPointer = &( ( (SgOmpParallelMasterStatement*)(SgOmpParallelMasterStatement::pools[memoryBlock]) ) [positionInPool]) ;
  126689             : 
  126690             : #if FILE_IO_EXTRA_CHECK
  126691           0 :           assert ( returnPointer != NULL ) ;
  126692             : #endif
  126693             :         }
  126694           0 :      return returnPointer ;
  126695             :    }
  126696             : 
  126697             : //############################################################################
  126698             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  126699             :  * pool size! We set for every valid object in the memory pool the freepointer
  126700             :  * to the global index and increase the global index afterwards. For all the 
  126701             :  * invalid objects (means address ranges within the memory pool that were not
  126702             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  126703             :  * distinguish valid from invalid objects! 
  126704             :  */
  126705             : unsigned long
  126706           5 : SgOmpParallelMasterStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  126707             :    {
  126708           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  126709           5 :      SgOmpParallelMasterStatement* pointer = NULL;
  126710           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  126711           5 :      std::vector < unsigned char* > :: const_iterator block;
  126712           5 :      for ( block = SgOmpParallelMasterStatement::pools.begin(); block != SgOmpParallelMasterStatement::pools.end() ; ++block )
  126713             :         {
  126714           0 :           pointer = (SgOmpParallelMasterStatement*)(*block);
  126715           0 :           for (unsigned i = 0; i < SgOmpParallelMasterStatement::pool_size; ++i )
  126716             :              {
  126717             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  126718             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  126719             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  126720             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  126721             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  126722             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  126723             :             // properly; so this will have to be checked next.
  126724             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  126725             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  126726           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  126727             :                   {
  126728           0 :                     pointer[i].set_freepointer((SgOmpParallelMasterStatement*)(globalIndex));
  126729           0 :                     globalIndex++;
  126730             :                   }
  126731             :                else
  126732             :                   {
  126733           0 :                     pointer[i].set_freepointer(NULL);
  126734             :                   }
  126735             :               }
  126736             :         }
  126737           5 :      return globalIndex;
  126738             :    }
  126739             : 
  126740             : //############################################################################
  126741             : // JH (01/14/2006)
  126742             : void
  126743           5 : SgOmpParallelMasterStatement::resetValidFreepointers( )
  126744             :    {
  126745           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  126746           5 :      SgOmpParallelMasterStatement* pointer = NULL;
  126747           5 :      std::vector < unsigned char* > :: const_iterator block;
  126748           5 :      SgOmpParallelMasterStatement* pointerOfLinkedList = NULL;
  126749           5 :      for ( block = SgOmpParallelMasterStatement::pools.begin(); block != SgOmpParallelMasterStatement::pools.end() ; ++block )
  126750             :         {
  126751           0 :           pointer = (SgOmpParallelMasterStatement*)(*block);
  126752           0 :           for (unsigned i = 0; i < SgOmpParallelMasterStatement::pool_size; ++i )
  126753             :              {
  126754             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  126755             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  126756             :             // memory blocks!.
  126757           0 :                if ( pointer[i].get_freepointer() != NULL )
  126758             :                   {
  126759           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  126760             :                   }
  126761             :                else
  126762             :                   {
  126763           0 :                     if ( pointerOfLinkedList == NULL )
  126764             :                        {
  126765           0 :                          SgOmpParallelMasterStatement::next_node = &(pointer[i]);
  126766             :                        }
  126767             :                     else
  126768             :                        {
  126769             :                       // printf ("In SgOmpParallelMasterStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  126770           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  126771             :                        }
  126772             :                     pointerOfLinkedList = &(pointer[i]);
  126773             :                   }
  126774             :               }
  126775             :         }
  126776             : 
  126777           5 :      if ( pointerOfLinkedList != NULL )
  126778             :         {
  126779             :        // printf ("In SgOmpParallelMasterStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  126780           0 :           pointerOfLinkedList->set_freepointer(NULL);
  126781             :        // DQ (6/6/2010): Temporary debugging...
  126782             :        //   ROSE_ASSERT(false);
  126783             :         }
  126784             : 
  126785           5 :      return ;
  126786             :    }
  126787             : 
  126788             : //############################################################################
  126789             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  126790             :  * within the memory pool and resets the freepointers, in order to achieve a 
  126791             :  * linked list, that has no jumps and starts at the beginning! This function 
  126792             :  * does not extend the memory pool, since we do not delete any memory blocks,
  126793             :  * but delete the valid objects.  
  126794             :  */
  126795             : void
  126796           0 : SgOmpParallelMasterStatement::clearMemoryPool( )
  126797             :    {
  126798             :   // printf ("Inside of SgOmpParallelMasterStatement::clearMemoryPool() \n");
  126799             : 
  126800           0 :      SgOmpParallelMasterStatement* pointer = NULL, *tempPointer = NULL;
  126801           0 :      std::vector < unsigned char* > :: const_iterator block;
  126802           0 :      if ( SgOmpParallelMasterStatement::pools.empty() == false )
  126803             :         {
  126804           0 :           block = SgOmpParallelMasterStatement::pools.begin() ;
  126805           0 :           SgOmpParallelMasterStatement::next_node = (SgOmpParallelMasterStatement*) (*block);
  126806             : 
  126807           0 :           while ( block != SgOmpParallelMasterStatement::pools.end() )
  126808             :              {
  126809           0 :                pointer = (SgOmpParallelMasterStatement*) (*block);
  126810           0 :                if ( tempPointer != NULL )
  126811             :                   {
  126812           0 :                     tempPointer->set_freepointer(pointer);
  126813             :                   }
  126814           0 :                for (unsigned i = 0; i < SgOmpParallelMasterStatement::pool_size - 1; ++i)
  126815             :                   {
  126816           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  126817             :                   }
  126818           0 :                 pointer[SgOmpParallelMasterStatement::pool_size-1].set_freepointer(NULL);
  126819           0 :                 tempPointer = &(pointer[SgOmpParallelMasterStatement::pool_size-1]);
  126820           0 :                 ++block;
  126821             :              }
  126822             :         }
  126823           0 :    }
  126824             : 
  126825           5 : void SgOmpParallelMasterStatement::deleteMemoryPool() {
  126826           5 :   for (auto p: SgOmpParallelMasterStatement::pools) {
  126827           0 :     ROSE_FREE(p);
  126828             :   }
  126829           5 :   SgOmpParallelMasterStatement::next_node = nullptr;
  126830           5 :   SgOmpParallelMasterStatement::pools.clear();
  126831           5 : }
  126832             : 
  126833             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  126834             : //                 reading multiple binary files to for a single AST.
  126835             : /////////// new version ////////////////////////////////
  126836             : //############################################################################
  126837             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  126838             : void
  126839           2 : SgOmpParallelMasterStatement::extendMemoryPoolForFileIO( )
  126840             :   {
  126841           2 :     size_t blockIndex = SgOmpParallelMasterStatement::pools.size();
  126842           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterStatement);
  126843             : 
  126844           2 :     while ( (blockIndex * SgOmpParallelMasterStatement::pool_size) < newPoolSize)
  126845             :       {
  126846             : #if ROSE_ALLOC_TRACE
  126847             :         if (blockIndex > 0) {
  126848             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterStatement) = %" PRIuPTR " SgOmpParallelMasterStatement::pool_size = %d \n",
  126849             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterStatement),SgOmpParallelMasterStatement::pool_size);
  126850             :         }
  126851             : #endif
  126852             : 
  126853           0 :         SgOmpParallelMasterStatement * pointer = (SgOmpParallelMasterStatement*) ROSE_MALLOC ( SgOmpParallelMasterStatement::pool_size * sizeof(SgOmpParallelMasterStatement) );
  126854           0 :         assert( pointer != NULL );
  126855             : #if ROSE_ALLOC_MEMSET == 1
  126856             :         memset(pointer, 0x00, SgOmpParallelMasterStatement::pool_size * sizeof(SgOmpParallelMasterStatement));
  126857             : #elif ROSE_ALLOC_MEMSET == 2
  126858             :         memset(pointer, 0xCC, SgOmpParallelMasterStatement::pool_size * sizeof(SgOmpParallelMasterStatement));
  126859             : #endif
  126860           0 :         SgOmpParallelMasterStatement::pools.push_back( (unsigned char*)(pointer) );
  126861           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpParallelMasterStatement::pool_size * sizeof(SgOmpParallelMasterStatement), V_SgOmpParallelMasterStatement ) );
  126862             : 
  126863           0 :         if ( SgOmpParallelMasterStatement::next_node != NULL ) {
  126864           0 :           if ( blockIndex > 0 ) {
  126865           0 :             SgOmpParallelMasterStatement * blkptr = (SgOmpParallelMasterStatement*)(SgOmpParallelMasterStatement::pools[blockIndex-1]);
  126866           0 :             blkptr[ SgOmpParallelMasterStatement::pool_size - 1 ].set_freepointer(pointer);
  126867             :           }
  126868             :         } else {
  126869           0 :           SgOmpParallelMasterStatement::next_node = pointer;
  126870             :         }
  126871             : 
  126872           0 :         for (unsigned i = 0; i < SgOmpParallelMasterStatement::pool_size-1; ++i)
  126873             :            {
  126874           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  126875             :            }
  126876           0 :         pointer[ SgOmpParallelMasterStatement::pool_size -1 ].set_freepointer(NULL);
  126877             : 
  126878           0 :         blockIndex++;
  126879             :       }
  126880           2 :   }
  126881             : 
  126882             : //############################################################################
  126883             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  126884             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  126885             :  * not compressed. However, that stuff is not yet implemented! 
  126886             :  */
  126887             : unsigned long
  126888           0 : SgOmpParallelMasterStatement::getNumberOfLastValidPointer()
  126889             :    {
  126890           0 :       SgOmpParallelMasterStatement* testPointer = (SgOmpParallelMasterStatement*)(SgOmpParallelMasterStatement::pools.back());
  126891           0 :       unsigned long localIndex = SgOmpParallelMasterStatement::pool_size - 1;
  126892           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  126893             :          {
  126894           0 :            localIndex--;
  126895             :          }
  126896           0 :       return (localIndex + SgOmpParallelMasterStatement::pool_size * (SgOmpParallelMasterStatement::pools.size()-1));
  126897             :    }
  126898             : 
  126899             : //############################################################################
  126900             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  126901             :  * memory pool and initializes the data member in class SgOmpParallelMasterStatementStroageClass
  126902             :  * from its counterpart of SgOmpParallelMasterStatement. The return value is just for checking, 
  126903             :  * that the whole StorageClassArray is initialized!
  126904             :  */
  126905             : unsigned long
  126906           0 : SgOmpParallelMasterStatement::initializeStorageClassArray( SgOmpParallelMasterStatementStorageClass *storageArray )
  126907             :    {
  126908           0 :      unsigned long storageCounter = 0;
  126909           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpParallelMasterStatement::pools.begin();
  126910           0 :      SgOmpParallelMasterStatement* pointer = NULL;
  126911           0 :      while ( block != SgOmpParallelMasterStatement::pools.end() ) {
  126912           0 :           pointer = (SgOmpParallelMasterStatement*) (*block);
  126913           0 :           for ( unsigned i = 0; i < SgOmpParallelMasterStatement::pool_size; ++i ) {
  126914           0 :                if ( pointer->get_freepointer() != NULL ) {
  126915           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  126916           0 :                  storageArray++;
  126917           0 :                  storageCounter++;
  126918             :                }
  126919           0 :                pointer++;
  126920             :              }
  126921           0 :            block++;
  126922             :         }
  126923           0 :      return storageCounter;
  126924             :    }
  126925             : 
  126926             : /* #line 126927 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  126927             : 
  126928             : 
  126929             : 
  126930             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  126931             : 
  126932             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  126933             : 
  126934             : //############################################################################
  126935             : /* JH (02/02/2006) Constructor of the IR node SgOmpMasterTaskloopStatement that takes its 
  126936             :  * corresponding StorageClass as parameter
  126937             :  */
  126938           0 : SgOmpMasterTaskloopStatement :: SgOmpMasterTaskloopStatement ( const SgOmpMasterTaskloopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  126939             :    {
  126940             : 
  126941             : 
  126942             : /* #line 126943 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  126943             : 
  126944           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  126945             : 
  126946             : 
  126947             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  126948             : 
  126949             : 
  126950           0 :    }
  126951             : 
  126952             : //############################################################################
  126953             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  126954             :  * within the working AST. 
  126955             :  */
  126956           0 : SgOmpMasterTaskloopStatement * SgOmpMasterTaskloopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  126957           0 :      SgOmpMasterTaskloopStatement* returnPointer = NULL;
  126958           0 :      if ( globalIndex != 0 )
  126959             :         {
  126960             : 
  126961             : #if FILE_IO_EXTRA_CHECK
  126962           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpMasterTaskloopStatement ) ) <= globalIndex ) ;
  126963           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMasterTaskloopStatement + 1 ) ) );
  126964             : #endif
  126965           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMasterTaskloopStatement )  
  126966           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpMasterTaskloopStatement );
  126967           0 :           unsigned long positionInPool = localIndex % SgOmpMasterTaskloopStatement::pool_size;
  126968           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMasterTaskloopStatement::pool_size;
  126969             : 
  126970             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  126971             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  126972             : 
  126973           0 :           returnPointer = &( ( (SgOmpMasterTaskloopStatement*)(SgOmpMasterTaskloopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  126974             : 
  126975           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  126976             :         }
  126977           0 :      return returnPointer ;
  126978             :    }
  126979             : 
  126980             : //############################################################################
  126981             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  126982             :   for the AST with the index astIndex
  126983             : */
  126984           0 : SgOmpMasterTaskloopStatement * SgOmpMasterTaskloopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  126985           0 :      SgOmpMasterTaskloopStatement* returnPointer = NULL;
  126986           0 :      if ( globalIndex != 0 )
  126987             :         {
  126988             : 
  126989             : #if FILE_IO_EXTRA_CHECK
  126990           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpMasterTaskloopStatement ) ) <= globalIndex ) ;
  126991           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMasterTaskloopStatement + 1 ) ) );
  126992             : #endif
  126993           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMasterTaskloopStatement )
  126994           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpMasterTaskloopStatement );
  126995           0 :           unsigned long positionInPool = localIndex % SgOmpMasterTaskloopStatement::pool_size ;
  126996           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMasterTaskloopStatement::pool_size ;
  126997             : 
  126998             : #if FILE_IO_EXTRA_CHECK
  126999             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  127000             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  127001             : #endif
  127002             : 
  127003           0 :           returnPointer = &( ( (SgOmpMasterTaskloopStatement*)(SgOmpMasterTaskloopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  127004             : 
  127005             : #if FILE_IO_EXTRA_CHECK
  127006           0 :           assert ( returnPointer != NULL ) ;
  127007             : #endif
  127008             :         }
  127009           0 :      return returnPointer ;
  127010             :    }
  127011             : 
  127012             : //############################################################################
  127013             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  127014             :  * pool size! We set for every valid object in the memory pool the freepointer
  127015             :  * to the global index and increase the global index afterwards. For all the 
  127016             :  * invalid objects (means address ranges within the memory pool that were not
  127017             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  127018             :  * distinguish valid from invalid objects! 
  127019             :  */
  127020             : unsigned long
  127021           5 : SgOmpMasterTaskloopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  127022             :    {
  127023           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  127024           5 :      SgOmpMasterTaskloopStatement* pointer = NULL;
  127025           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  127026           5 :      std::vector < unsigned char* > :: const_iterator block;
  127027           5 :      for ( block = SgOmpMasterTaskloopStatement::pools.begin(); block != SgOmpMasterTaskloopStatement::pools.end() ; ++block )
  127028             :         {
  127029           0 :           pointer = (SgOmpMasterTaskloopStatement*)(*block);
  127030           0 :           for (unsigned i = 0; i < SgOmpMasterTaskloopStatement::pool_size; ++i )
  127031             :              {
  127032             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  127033             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  127034             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  127035             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  127036             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  127037             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  127038             :             // properly; so this will have to be checked next.
  127039             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  127040             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  127041           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  127042             :                   {
  127043           0 :                     pointer[i].set_freepointer((SgOmpMasterTaskloopStatement*)(globalIndex));
  127044           0 :                     globalIndex++;
  127045             :                   }
  127046             :                else
  127047             :                   {
  127048           0 :                     pointer[i].set_freepointer(NULL);
  127049             :                   }
  127050             :               }
  127051             :         }
  127052           5 :      return globalIndex;
  127053             :    }
  127054             : 
  127055             : //############################################################################
  127056             : // JH (01/14/2006)
  127057             : void
  127058           5 : SgOmpMasterTaskloopStatement::resetValidFreepointers( )
  127059             :    {
  127060           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  127061           5 :      SgOmpMasterTaskloopStatement* pointer = NULL;
  127062           5 :      std::vector < unsigned char* > :: const_iterator block;
  127063           5 :      SgOmpMasterTaskloopStatement* pointerOfLinkedList = NULL;
  127064           5 :      for ( block = SgOmpMasterTaskloopStatement::pools.begin(); block != SgOmpMasterTaskloopStatement::pools.end() ; ++block )
  127065             :         {
  127066           0 :           pointer = (SgOmpMasterTaskloopStatement*)(*block);
  127067           0 :           for (unsigned i = 0; i < SgOmpMasterTaskloopStatement::pool_size; ++i )
  127068             :              {
  127069             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  127070             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  127071             :             // memory blocks!.
  127072           0 :                if ( pointer[i].get_freepointer() != NULL )
  127073             :                   {
  127074           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  127075             :                   }
  127076             :                else
  127077             :                   {
  127078           0 :                     if ( pointerOfLinkedList == NULL )
  127079             :                        {
  127080           0 :                          SgOmpMasterTaskloopStatement::next_node = &(pointer[i]);
  127081             :                        }
  127082             :                     else
  127083             :                        {
  127084             :                       // printf ("In SgOmpMasterTaskloopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  127085           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  127086             :                        }
  127087             :                     pointerOfLinkedList = &(pointer[i]);
  127088             :                   }
  127089             :               }
  127090             :         }
  127091             : 
  127092           5 :      if ( pointerOfLinkedList != NULL )
  127093             :         {
  127094             :        // printf ("In SgOmpMasterTaskloopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  127095           0 :           pointerOfLinkedList->set_freepointer(NULL);
  127096             :        // DQ (6/6/2010): Temporary debugging...
  127097             :        //   ROSE_ASSERT(false);
  127098             :         }
  127099             : 
  127100           5 :      return ;
  127101             :    }
  127102             : 
  127103             : //############################################################################
  127104             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  127105             :  * within the memory pool and resets the freepointers, in order to achieve a 
  127106             :  * linked list, that has no jumps and starts at the beginning! This function 
  127107             :  * does not extend the memory pool, since we do not delete any memory blocks,
  127108             :  * but delete the valid objects.  
  127109             :  */
  127110             : void
  127111           0 : SgOmpMasterTaskloopStatement::clearMemoryPool( )
  127112             :    {
  127113             :   // printf ("Inside of SgOmpMasterTaskloopStatement::clearMemoryPool() \n");
  127114             : 
  127115           0 :      SgOmpMasterTaskloopStatement* pointer = NULL, *tempPointer = NULL;
  127116           0 :      std::vector < unsigned char* > :: const_iterator block;
  127117           0 :      if ( SgOmpMasterTaskloopStatement::pools.empty() == false )
  127118             :         {
  127119           0 :           block = SgOmpMasterTaskloopStatement::pools.begin() ;
  127120           0 :           SgOmpMasterTaskloopStatement::next_node = (SgOmpMasterTaskloopStatement*) (*block);
  127121             : 
  127122           0 :           while ( block != SgOmpMasterTaskloopStatement::pools.end() )
  127123             :              {
  127124           0 :                pointer = (SgOmpMasterTaskloopStatement*) (*block);
  127125           0 :                if ( tempPointer != NULL )
  127126             :                   {
  127127           0 :                     tempPointer->set_freepointer(pointer);
  127128             :                   }
  127129           0 :                for (unsigned i = 0; i < SgOmpMasterTaskloopStatement::pool_size - 1; ++i)
  127130             :                   {
  127131           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  127132             :                   }
  127133           0 :                 pointer[SgOmpMasterTaskloopStatement::pool_size-1].set_freepointer(NULL);
  127134           0 :                 tempPointer = &(pointer[SgOmpMasterTaskloopStatement::pool_size-1]);
  127135           0 :                 ++block;
  127136             :              }
  127137             :         }
  127138           0 :    }
  127139             : 
  127140           5 : void SgOmpMasterTaskloopStatement::deleteMemoryPool() {
  127141           5 :   for (auto p: SgOmpMasterTaskloopStatement::pools) {
  127142           0 :     ROSE_FREE(p);
  127143             :   }
  127144           5 :   SgOmpMasterTaskloopStatement::next_node = nullptr;
  127145           5 :   SgOmpMasterTaskloopStatement::pools.clear();
  127146           5 : }
  127147             : 
  127148             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  127149             : //                 reading multiple binary files to for a single AST.
  127150             : /////////// new version ////////////////////////////////
  127151             : //############################################################################
  127152             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  127153             : void
  127154           2 : SgOmpMasterTaskloopStatement::extendMemoryPoolForFileIO( )
  127155             :   {
  127156           2 :     size_t blockIndex = SgOmpMasterTaskloopStatement::pools.size();
  127157           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterTaskloopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterTaskloopStatement);
  127158             : 
  127159           2 :     while ( (blockIndex * SgOmpMasterTaskloopStatement::pool_size) < newPoolSize)
  127160             :       {
  127161             : #if ROSE_ALLOC_TRACE
  127162             :         if (blockIndex > 0) {
  127163             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterTaskloopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterTaskloopStatement) = %" PRIuPTR " SgOmpMasterTaskloopStatement::pool_size = %d \n",
  127164             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterTaskloopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterTaskloopStatement),SgOmpMasterTaskloopStatement::pool_size);
  127165             :         }
  127166             : #endif
  127167             : 
  127168           0 :         SgOmpMasterTaskloopStatement * pointer = (SgOmpMasterTaskloopStatement*) ROSE_MALLOC ( SgOmpMasterTaskloopStatement::pool_size * sizeof(SgOmpMasterTaskloopStatement) );
  127169           0 :         assert( pointer != NULL );
  127170             : #if ROSE_ALLOC_MEMSET == 1
  127171             :         memset(pointer, 0x00, SgOmpMasterTaskloopStatement::pool_size * sizeof(SgOmpMasterTaskloopStatement));
  127172             : #elif ROSE_ALLOC_MEMSET == 2
  127173             :         memset(pointer, 0xCC, SgOmpMasterTaskloopStatement::pool_size * sizeof(SgOmpMasterTaskloopStatement));
  127174             : #endif
  127175           0 :         SgOmpMasterTaskloopStatement::pools.push_back( (unsigned char*)(pointer) );
  127176           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpMasterTaskloopStatement::pool_size * sizeof(SgOmpMasterTaskloopStatement), V_SgOmpMasterTaskloopStatement ) );
  127177             : 
  127178           0 :         if ( SgOmpMasterTaskloopStatement::next_node != NULL ) {
  127179           0 :           if ( blockIndex > 0 ) {
  127180           0 :             SgOmpMasterTaskloopStatement * blkptr = (SgOmpMasterTaskloopStatement*)(SgOmpMasterTaskloopStatement::pools[blockIndex-1]);
  127181           0 :             blkptr[ SgOmpMasterTaskloopStatement::pool_size - 1 ].set_freepointer(pointer);
  127182             :           }
  127183             :         } else {
  127184           0 :           SgOmpMasterTaskloopStatement::next_node = pointer;
  127185             :         }
  127186             : 
  127187           0 :         for (unsigned i = 0; i < SgOmpMasterTaskloopStatement::pool_size-1; ++i)
  127188             :            {
  127189           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  127190             :            }
  127191           0 :         pointer[ SgOmpMasterTaskloopStatement::pool_size -1 ].set_freepointer(NULL);
  127192             : 
  127193           0 :         blockIndex++;
  127194             :       }
  127195           2 :   }
  127196             : 
  127197             : //############################################################################
  127198             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  127199             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  127200             :  * not compressed. However, that stuff is not yet implemented! 
  127201             :  */
  127202             : unsigned long
  127203           0 : SgOmpMasterTaskloopStatement::getNumberOfLastValidPointer()
  127204             :    {
  127205           0 :       SgOmpMasterTaskloopStatement* testPointer = (SgOmpMasterTaskloopStatement*)(SgOmpMasterTaskloopStatement::pools.back());
  127206           0 :       unsigned long localIndex = SgOmpMasterTaskloopStatement::pool_size - 1;
  127207           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  127208             :          {
  127209           0 :            localIndex--;
  127210             :          }
  127211           0 :       return (localIndex + SgOmpMasterTaskloopStatement::pool_size * (SgOmpMasterTaskloopStatement::pools.size()-1));
  127212             :    }
  127213             : 
  127214             : //############################################################################
  127215             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  127216             :  * memory pool and initializes the data member in class SgOmpMasterTaskloopStatementStroageClass
  127217             :  * from its counterpart of SgOmpMasterTaskloopStatement. The return value is just for checking, 
  127218             :  * that the whole StorageClassArray is initialized!
  127219             :  */
  127220             : unsigned long
  127221           0 : SgOmpMasterTaskloopStatement::initializeStorageClassArray( SgOmpMasterTaskloopStatementStorageClass *storageArray )
  127222             :    {
  127223           0 :      unsigned long storageCounter = 0;
  127224           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpMasterTaskloopStatement::pools.begin();
  127225           0 :      SgOmpMasterTaskloopStatement* pointer = NULL;
  127226           0 :      while ( block != SgOmpMasterTaskloopStatement::pools.end() ) {
  127227           0 :           pointer = (SgOmpMasterTaskloopStatement*) (*block);
  127228           0 :           for ( unsigned i = 0; i < SgOmpMasterTaskloopStatement::pool_size; ++i ) {
  127229           0 :                if ( pointer->get_freepointer() != NULL ) {
  127230           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  127231           0 :                  storageArray++;
  127232           0 :                  storageCounter++;
  127233             :                }
  127234           0 :                pointer++;
  127235             :              }
  127236           0 :            block++;
  127237             :         }
  127238           0 :      return storageCounter;
  127239             :    }
  127240             : 
  127241             : /* #line 127242 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  127242             : 
  127243             : 
  127244             : 
  127245             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  127246             : 
  127247             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  127248             : 
  127249             : //############################################################################
  127250             : /* JH (02/02/2006) Constructor of the IR node SgOmpTaskStatement that takes its 
  127251             :  * corresponding StorageClass as parameter
  127252             :  */
  127253           0 : SgOmpTaskStatement :: SgOmpTaskStatement ( const SgOmpTaskStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  127254             :    {
  127255             : 
  127256             : 
  127257             : /* #line 127258 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  127258             : 
  127259           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  127260             : 
  127261             : 
  127262             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  127263             : 
  127264             : 
  127265           0 :    }
  127266             : 
  127267             : //############################################################################
  127268             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  127269             :  * within the working AST. 
  127270             :  */
  127271           0 : SgOmpTaskStatement * SgOmpTaskStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  127272           0 :      SgOmpTaskStatement* returnPointer = NULL;
  127273           0 :      if ( globalIndex != 0 )
  127274             :         {
  127275             : 
  127276             : #if FILE_IO_EXTRA_CHECK
  127277           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTaskStatement ) ) <= globalIndex ) ;
  127278           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskStatement + 1 ) ) );
  127279             : #endif
  127280           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskStatement )  
  127281           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTaskStatement );
  127282           0 :           unsigned long positionInPool = localIndex % SgOmpTaskStatement::pool_size;
  127283           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskStatement::pool_size;
  127284             : 
  127285             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  127286             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  127287             : 
  127288           0 :           returnPointer = &( ( (SgOmpTaskStatement*)(SgOmpTaskStatement::pools[memoryBlock]) ) [positionInPool]) ;
  127289             : 
  127290           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  127291             :         }
  127292           0 :      return returnPointer ;
  127293             :    }
  127294             : 
  127295             : //############################################################################
  127296             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  127297             :   for the AST with the index astIndex
  127298             : */
  127299           0 : SgOmpTaskStatement * SgOmpTaskStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  127300           0 :      SgOmpTaskStatement* returnPointer = NULL;
  127301           0 :      if ( globalIndex != 0 )
  127302             :         {
  127303             : 
  127304             : #if FILE_IO_EXTRA_CHECK
  127305           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTaskStatement ) ) <= globalIndex ) ;
  127306           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskStatement + 1 ) ) );
  127307             : #endif
  127308           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskStatement )
  127309           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTaskStatement );
  127310           0 :           unsigned long positionInPool = localIndex % SgOmpTaskStatement::pool_size ;
  127311           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskStatement::pool_size ;
  127312             : 
  127313             : #if FILE_IO_EXTRA_CHECK
  127314             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  127315             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  127316             : #endif
  127317             : 
  127318           0 :           returnPointer = &( ( (SgOmpTaskStatement*)(SgOmpTaskStatement::pools[memoryBlock]) ) [positionInPool]) ;
  127319             : 
  127320             : #if FILE_IO_EXTRA_CHECK
  127321           0 :           assert ( returnPointer != NULL ) ;
  127322             : #endif
  127323             :         }
  127324           0 :      return returnPointer ;
  127325             :    }
  127326             : 
  127327             : //############################################################################
  127328             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  127329             :  * pool size! We set for every valid object in the memory pool the freepointer
  127330             :  * to the global index and increase the global index afterwards. For all the 
  127331             :  * invalid objects (means address ranges within the memory pool that were not
  127332             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  127333             :  * distinguish valid from invalid objects! 
  127334             :  */
  127335             : unsigned long
  127336           5 : SgOmpTaskStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  127337             :    {
  127338           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  127339           5 :      SgOmpTaskStatement* pointer = NULL;
  127340           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  127341           5 :      std::vector < unsigned char* > :: const_iterator block;
  127342           5 :      for ( block = SgOmpTaskStatement::pools.begin(); block != SgOmpTaskStatement::pools.end() ; ++block )
  127343             :         {
  127344           0 :           pointer = (SgOmpTaskStatement*)(*block);
  127345           0 :           for (unsigned i = 0; i < SgOmpTaskStatement::pool_size; ++i )
  127346             :              {
  127347             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  127348             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  127349             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  127350             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  127351             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  127352             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  127353             :             // properly; so this will have to be checked next.
  127354             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  127355             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  127356           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  127357             :                   {
  127358           0 :                     pointer[i].set_freepointer((SgOmpTaskStatement*)(globalIndex));
  127359           0 :                     globalIndex++;
  127360             :                   }
  127361             :                else
  127362             :                   {
  127363           0 :                     pointer[i].set_freepointer(NULL);
  127364             :                   }
  127365             :               }
  127366             :         }
  127367           5 :      return globalIndex;
  127368             :    }
  127369             : 
  127370             : //############################################################################
  127371             : // JH (01/14/2006)
  127372             : void
  127373           5 : SgOmpTaskStatement::resetValidFreepointers( )
  127374             :    {
  127375           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  127376           5 :      SgOmpTaskStatement* pointer = NULL;
  127377           5 :      std::vector < unsigned char* > :: const_iterator block;
  127378           5 :      SgOmpTaskStatement* pointerOfLinkedList = NULL;
  127379           5 :      for ( block = SgOmpTaskStatement::pools.begin(); block != SgOmpTaskStatement::pools.end() ; ++block )
  127380             :         {
  127381           0 :           pointer = (SgOmpTaskStatement*)(*block);
  127382           0 :           for (unsigned i = 0; i < SgOmpTaskStatement::pool_size; ++i )
  127383             :              {
  127384             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  127385             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  127386             :             // memory blocks!.
  127387           0 :                if ( pointer[i].get_freepointer() != NULL )
  127388             :                   {
  127389           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  127390             :                   }
  127391             :                else
  127392             :                   {
  127393           0 :                     if ( pointerOfLinkedList == NULL )
  127394             :                        {
  127395           0 :                          SgOmpTaskStatement::next_node = &(pointer[i]);
  127396             :                        }
  127397             :                     else
  127398             :                        {
  127399             :                       // printf ("In SgOmpTaskStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  127400           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  127401             :                        }
  127402             :                     pointerOfLinkedList = &(pointer[i]);
  127403             :                   }
  127404             :               }
  127405             :         }
  127406             : 
  127407           5 :      if ( pointerOfLinkedList != NULL )
  127408             :         {
  127409             :        // printf ("In SgOmpTaskStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  127410           0 :           pointerOfLinkedList->set_freepointer(NULL);
  127411             :        // DQ (6/6/2010): Temporary debugging...
  127412             :        //   ROSE_ASSERT(false);
  127413             :         }
  127414             : 
  127415           5 :      return ;
  127416             :    }
  127417             : 
  127418             : //############################################################################
  127419             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  127420             :  * within the memory pool and resets the freepointers, in order to achieve a 
  127421             :  * linked list, that has no jumps and starts at the beginning! This function 
  127422             :  * does not extend the memory pool, since we do not delete any memory blocks,
  127423             :  * but delete the valid objects.  
  127424             :  */
  127425             : void
  127426           0 : SgOmpTaskStatement::clearMemoryPool( )
  127427             :    {
  127428             :   // printf ("Inside of SgOmpTaskStatement::clearMemoryPool() \n");
  127429             : 
  127430           0 :      SgOmpTaskStatement* pointer = NULL, *tempPointer = NULL;
  127431           0 :      std::vector < unsigned char* > :: const_iterator block;
  127432           0 :      if ( SgOmpTaskStatement::pools.empty() == false )
  127433             :         {
  127434           0 :           block = SgOmpTaskStatement::pools.begin() ;
  127435           0 :           SgOmpTaskStatement::next_node = (SgOmpTaskStatement*) (*block);
  127436             : 
  127437           0 :           while ( block != SgOmpTaskStatement::pools.end() )
  127438             :              {
  127439           0 :                pointer = (SgOmpTaskStatement*) (*block);
  127440           0 :                if ( tempPointer != NULL )
  127441             :                   {
  127442           0 :                     tempPointer->set_freepointer(pointer);
  127443             :                   }
  127444           0 :                for (unsigned i = 0; i < SgOmpTaskStatement::pool_size - 1; ++i)
  127445             :                   {
  127446           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  127447             :                   }
  127448           0 :                 pointer[SgOmpTaskStatement::pool_size-1].set_freepointer(NULL);
  127449           0 :                 tempPointer = &(pointer[SgOmpTaskStatement::pool_size-1]);
  127450           0 :                 ++block;
  127451             :              }
  127452             :         }
  127453           0 :    }
  127454             : 
  127455           5 : void SgOmpTaskStatement::deleteMemoryPool() {
  127456           5 :   for (auto p: SgOmpTaskStatement::pools) {
  127457           0 :     ROSE_FREE(p);
  127458             :   }
  127459           5 :   SgOmpTaskStatement::next_node = nullptr;
  127460           5 :   SgOmpTaskStatement::pools.clear();
  127461           5 : }
  127462             : 
  127463             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  127464             : //                 reading multiple binary files to for a single AST.
  127465             : /////////// new version ////////////////////////////////
  127466             : //############################################################################
  127467             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  127468             : void
  127469           2 : SgOmpTaskStatement::extendMemoryPoolForFileIO( )
  127470             :   {
  127471           2 :     size_t blockIndex = SgOmpTaskStatement::pools.size();
  127472           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskStatement);
  127473             : 
  127474           2 :     while ( (blockIndex * SgOmpTaskStatement::pool_size) < newPoolSize)
  127475             :       {
  127476             : #if ROSE_ALLOC_TRACE
  127477             :         if (blockIndex > 0) {
  127478             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskStatement) = %" PRIuPTR " SgOmpTaskStatement::pool_size = %d \n",
  127479             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskStatement),SgOmpTaskStatement::pool_size);
  127480             :         }
  127481             : #endif
  127482             : 
  127483           0 :         SgOmpTaskStatement * pointer = (SgOmpTaskStatement*) ROSE_MALLOC ( SgOmpTaskStatement::pool_size * sizeof(SgOmpTaskStatement) );
  127484           0 :         assert( pointer != NULL );
  127485             : #if ROSE_ALLOC_MEMSET == 1
  127486             :         memset(pointer, 0x00, SgOmpTaskStatement::pool_size * sizeof(SgOmpTaskStatement));
  127487             : #elif ROSE_ALLOC_MEMSET == 2
  127488             :         memset(pointer, 0xCC, SgOmpTaskStatement::pool_size * sizeof(SgOmpTaskStatement));
  127489             : #endif
  127490           0 :         SgOmpTaskStatement::pools.push_back( (unsigned char*)(pointer) );
  127491           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTaskStatement::pool_size * sizeof(SgOmpTaskStatement), V_SgOmpTaskStatement ) );
  127492             : 
  127493           0 :         if ( SgOmpTaskStatement::next_node != NULL ) {
  127494           0 :           if ( blockIndex > 0 ) {
  127495           0 :             SgOmpTaskStatement * blkptr = (SgOmpTaskStatement*)(SgOmpTaskStatement::pools[blockIndex-1]);
  127496           0 :             blkptr[ SgOmpTaskStatement::pool_size - 1 ].set_freepointer(pointer);
  127497             :           }
  127498             :         } else {
  127499           0 :           SgOmpTaskStatement::next_node = pointer;
  127500             :         }
  127501             : 
  127502           0 :         for (unsigned i = 0; i < SgOmpTaskStatement::pool_size-1; ++i)
  127503             :            {
  127504           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  127505             :            }
  127506           0 :         pointer[ SgOmpTaskStatement::pool_size -1 ].set_freepointer(NULL);
  127507             : 
  127508           0 :         blockIndex++;
  127509             :       }
  127510           2 :   }
  127511             : 
  127512             : //############################################################################
  127513             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  127514             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  127515             :  * not compressed. However, that stuff is not yet implemented! 
  127516             :  */
  127517             : unsigned long
  127518           0 : SgOmpTaskStatement::getNumberOfLastValidPointer()
  127519             :    {
  127520           0 :       SgOmpTaskStatement* testPointer = (SgOmpTaskStatement*)(SgOmpTaskStatement::pools.back());
  127521           0 :       unsigned long localIndex = SgOmpTaskStatement::pool_size - 1;
  127522           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  127523             :          {
  127524           0 :            localIndex--;
  127525             :          }
  127526           0 :       return (localIndex + SgOmpTaskStatement::pool_size * (SgOmpTaskStatement::pools.size()-1));
  127527             :    }
  127528             : 
  127529             : //############################################################################
  127530             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  127531             :  * memory pool and initializes the data member in class SgOmpTaskStatementStroageClass
  127532             :  * from its counterpart of SgOmpTaskStatement. The return value is just for checking, 
  127533             :  * that the whole StorageClassArray is initialized!
  127534             :  */
  127535             : unsigned long
  127536           0 : SgOmpTaskStatement::initializeStorageClassArray( SgOmpTaskStatementStorageClass *storageArray )
  127537             :    {
  127538           0 :      unsigned long storageCounter = 0;
  127539           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTaskStatement::pools.begin();
  127540           0 :      SgOmpTaskStatement* pointer = NULL;
  127541           0 :      while ( block != SgOmpTaskStatement::pools.end() ) {
  127542           0 :           pointer = (SgOmpTaskStatement*) (*block);
  127543           0 :           for ( unsigned i = 0; i < SgOmpTaskStatement::pool_size; ++i ) {
  127544           0 :                if ( pointer->get_freepointer() != NULL ) {
  127545           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  127546           0 :                  storageArray++;
  127547           0 :                  storageCounter++;
  127548             :                }
  127549           0 :                pointer++;
  127550             :              }
  127551           0 :            block++;
  127552             :         }
  127553           0 :      return storageCounter;
  127554             :    }
  127555             : 
  127556             : /* #line 127557 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  127557             : 
  127558             : 
  127559             : 
  127560             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  127561             : 
  127562             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  127563             : 
  127564             : //############################################################################
  127565             : /* JH (02/02/2006) Constructor of the IR node SgOmpDoStatement that takes its 
  127566             :  * corresponding StorageClass as parameter
  127567             :  */
  127568           0 : SgOmpDoStatement :: SgOmpDoStatement ( const SgOmpDoStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  127569             :    {
  127570             : 
  127571             : 
  127572             : /* #line 127573 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  127573             : 
  127574           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  127575             : 
  127576             : 
  127577             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  127578             : 
  127579             : 
  127580           0 :    }
  127581             : 
  127582             : //############################################################################
  127583             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  127584             :  * within the working AST. 
  127585             :  */
  127586           0 : SgOmpDoStatement * SgOmpDoStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  127587           0 :      SgOmpDoStatement* returnPointer = NULL;
  127588           0 :      if ( globalIndex != 0 )
  127589             :         {
  127590             : 
  127591             : #if FILE_IO_EXTRA_CHECK
  127592           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDoStatement ) ) <= globalIndex ) ;
  127593           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDoStatement + 1 ) ) );
  127594             : #endif
  127595           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDoStatement )  
  127596           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDoStatement );
  127597           0 :           unsigned long positionInPool = localIndex % SgOmpDoStatement::pool_size;
  127598           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDoStatement::pool_size;
  127599             : 
  127600             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  127601             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  127602             : 
  127603           0 :           returnPointer = &( ( (SgOmpDoStatement*)(SgOmpDoStatement::pools[memoryBlock]) ) [positionInPool]) ;
  127604             : 
  127605           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  127606             :         }
  127607           0 :      return returnPointer ;
  127608             :    }
  127609             : 
  127610             : //############################################################################
  127611             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  127612             :   for the AST with the index astIndex
  127613             : */
  127614           0 : SgOmpDoStatement * SgOmpDoStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  127615           0 :      SgOmpDoStatement* returnPointer = NULL;
  127616           0 :      if ( globalIndex != 0 )
  127617             :         {
  127618             : 
  127619             : #if FILE_IO_EXTRA_CHECK
  127620           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDoStatement ) ) <= globalIndex ) ;
  127621           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDoStatement + 1 ) ) );
  127622             : #endif
  127623           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDoStatement )
  127624           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDoStatement );
  127625           0 :           unsigned long positionInPool = localIndex % SgOmpDoStatement::pool_size ;
  127626           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDoStatement::pool_size ;
  127627             : 
  127628             : #if FILE_IO_EXTRA_CHECK
  127629             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  127630             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  127631             : #endif
  127632             : 
  127633           0 :           returnPointer = &( ( (SgOmpDoStatement*)(SgOmpDoStatement::pools[memoryBlock]) ) [positionInPool]) ;
  127634             : 
  127635             : #if FILE_IO_EXTRA_CHECK
  127636           0 :           assert ( returnPointer != NULL ) ;
  127637             : #endif
  127638             :         }
  127639           0 :      return returnPointer ;
  127640             :    }
  127641             : 
  127642             : //############################################################################
  127643             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  127644             :  * pool size! We set for every valid object in the memory pool the freepointer
  127645             :  * to the global index and increase the global index afterwards. For all the 
  127646             :  * invalid objects (means address ranges within the memory pool that were not
  127647             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  127648             :  * distinguish valid from invalid objects! 
  127649             :  */
  127650             : unsigned long
  127651           5 : SgOmpDoStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  127652             :    {
  127653           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  127654           5 :      SgOmpDoStatement* pointer = NULL;
  127655           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  127656           5 :      std::vector < unsigned char* > :: const_iterator block;
  127657           5 :      for ( block = SgOmpDoStatement::pools.begin(); block != SgOmpDoStatement::pools.end() ; ++block )
  127658             :         {
  127659           0 :           pointer = (SgOmpDoStatement*)(*block);
  127660           0 :           for (unsigned i = 0; i < SgOmpDoStatement::pool_size; ++i )
  127661             :              {
  127662             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  127663             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  127664             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  127665             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  127666             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  127667             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  127668             :             // properly; so this will have to be checked next.
  127669             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  127670             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  127671           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  127672             :                   {
  127673           0 :                     pointer[i].set_freepointer((SgOmpDoStatement*)(globalIndex));
  127674           0 :                     globalIndex++;
  127675             :                   }
  127676             :                else
  127677             :                   {
  127678           0 :                     pointer[i].set_freepointer(NULL);
  127679             :                   }
  127680             :               }
  127681             :         }
  127682           5 :      return globalIndex;
  127683             :    }
  127684             : 
  127685             : //############################################################################
  127686             : // JH (01/14/2006)
  127687             : void
  127688           5 : SgOmpDoStatement::resetValidFreepointers( )
  127689             :    {
  127690           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  127691           5 :      SgOmpDoStatement* pointer = NULL;
  127692           5 :      std::vector < unsigned char* > :: const_iterator block;
  127693           5 :      SgOmpDoStatement* pointerOfLinkedList = NULL;
  127694           5 :      for ( block = SgOmpDoStatement::pools.begin(); block != SgOmpDoStatement::pools.end() ; ++block )
  127695             :         {
  127696           0 :           pointer = (SgOmpDoStatement*)(*block);
  127697           0 :           for (unsigned i = 0; i < SgOmpDoStatement::pool_size; ++i )
  127698             :              {
  127699             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  127700             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  127701             :             // memory blocks!.
  127702           0 :                if ( pointer[i].get_freepointer() != NULL )
  127703             :                   {
  127704           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  127705             :                   }
  127706             :                else
  127707             :                   {
  127708           0 :                     if ( pointerOfLinkedList == NULL )
  127709             :                        {
  127710           0 :                          SgOmpDoStatement::next_node = &(pointer[i]);
  127711             :                        }
  127712             :                     else
  127713             :                        {
  127714             :                       // printf ("In SgOmpDoStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  127715           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  127716             :                        }
  127717             :                     pointerOfLinkedList = &(pointer[i]);
  127718             :                   }
  127719             :               }
  127720             :         }
  127721             : 
  127722           5 :      if ( pointerOfLinkedList != NULL )
  127723             :         {
  127724             :        // printf ("In SgOmpDoStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  127725           0 :           pointerOfLinkedList->set_freepointer(NULL);
  127726             :        // DQ (6/6/2010): Temporary debugging...
  127727             :        //   ROSE_ASSERT(false);
  127728             :         }
  127729             : 
  127730           5 :      return ;
  127731             :    }
  127732             : 
  127733             : //############################################################################
  127734             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  127735             :  * within the memory pool and resets the freepointers, in order to achieve a 
  127736             :  * linked list, that has no jumps and starts at the beginning! This function 
  127737             :  * does not extend the memory pool, since we do not delete any memory blocks,
  127738             :  * but delete the valid objects.  
  127739             :  */
  127740             : void
  127741           0 : SgOmpDoStatement::clearMemoryPool( )
  127742             :    {
  127743             :   // printf ("Inside of SgOmpDoStatement::clearMemoryPool() \n");
  127744             : 
  127745           0 :      SgOmpDoStatement* pointer = NULL, *tempPointer = NULL;
  127746           0 :      std::vector < unsigned char* > :: const_iterator block;
  127747           0 :      if ( SgOmpDoStatement::pools.empty() == false )
  127748             :         {
  127749           0 :           block = SgOmpDoStatement::pools.begin() ;
  127750           0 :           SgOmpDoStatement::next_node = (SgOmpDoStatement*) (*block);
  127751             : 
  127752           0 :           while ( block != SgOmpDoStatement::pools.end() )
  127753             :              {
  127754           0 :                pointer = (SgOmpDoStatement*) (*block);
  127755           0 :                if ( tempPointer != NULL )
  127756             :                   {
  127757           0 :                     tempPointer->set_freepointer(pointer);
  127758             :                   }
  127759           0 :                for (unsigned i = 0; i < SgOmpDoStatement::pool_size - 1; ++i)
  127760             :                   {
  127761           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  127762             :                   }
  127763           0 :                 pointer[SgOmpDoStatement::pool_size-1].set_freepointer(NULL);
  127764           0 :                 tempPointer = &(pointer[SgOmpDoStatement::pool_size-1]);
  127765           0 :                 ++block;
  127766             :              }
  127767             :         }
  127768           0 :    }
  127769             : 
  127770           5 : void SgOmpDoStatement::deleteMemoryPool() {
  127771           5 :   for (auto p: SgOmpDoStatement::pools) {
  127772           0 :     ROSE_FREE(p);
  127773             :   }
  127774           5 :   SgOmpDoStatement::next_node = nullptr;
  127775           5 :   SgOmpDoStatement::pools.clear();
  127776           5 : }
  127777             : 
  127778             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  127779             : //                 reading multiple binary files to for a single AST.
  127780             : /////////// new version ////////////////////////////////
  127781             : //############################################################################
  127782             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  127783             : void
  127784           2 : SgOmpDoStatement::extendMemoryPoolForFileIO( )
  127785             :   {
  127786           2 :     size_t blockIndex = SgOmpDoStatement::pools.size();
  127787           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDoStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDoStatement);
  127788             : 
  127789           2 :     while ( (blockIndex * SgOmpDoStatement::pool_size) < newPoolSize)
  127790             :       {
  127791             : #if ROSE_ALLOC_TRACE
  127792             :         if (blockIndex > 0) {
  127793             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDoStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDoStatement) = %" PRIuPTR " SgOmpDoStatement::pool_size = %d \n",
  127794             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDoStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDoStatement),SgOmpDoStatement::pool_size);
  127795             :         }
  127796             : #endif
  127797             : 
  127798           0 :         SgOmpDoStatement * pointer = (SgOmpDoStatement*) ROSE_MALLOC ( SgOmpDoStatement::pool_size * sizeof(SgOmpDoStatement) );
  127799           0 :         assert( pointer != NULL );
  127800             : #if ROSE_ALLOC_MEMSET == 1
  127801             :         memset(pointer, 0x00, SgOmpDoStatement::pool_size * sizeof(SgOmpDoStatement));
  127802             : #elif ROSE_ALLOC_MEMSET == 2
  127803             :         memset(pointer, 0xCC, SgOmpDoStatement::pool_size * sizeof(SgOmpDoStatement));
  127804             : #endif
  127805           0 :         SgOmpDoStatement::pools.push_back( (unsigned char*)(pointer) );
  127806           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDoStatement::pool_size * sizeof(SgOmpDoStatement), V_SgOmpDoStatement ) );
  127807             : 
  127808           0 :         if ( SgOmpDoStatement::next_node != NULL ) {
  127809           0 :           if ( blockIndex > 0 ) {
  127810           0 :             SgOmpDoStatement * blkptr = (SgOmpDoStatement*)(SgOmpDoStatement::pools[blockIndex-1]);
  127811           0 :             blkptr[ SgOmpDoStatement::pool_size - 1 ].set_freepointer(pointer);
  127812             :           }
  127813             :         } else {
  127814           0 :           SgOmpDoStatement::next_node = pointer;
  127815             :         }
  127816             : 
  127817           0 :         for (unsigned i = 0; i < SgOmpDoStatement::pool_size-1; ++i)
  127818             :            {
  127819           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  127820             :            }
  127821           0 :         pointer[ SgOmpDoStatement::pool_size -1 ].set_freepointer(NULL);
  127822             : 
  127823           0 :         blockIndex++;
  127824             :       }
  127825           2 :   }
  127826             : 
  127827             : //############################################################################
  127828             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  127829             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  127830             :  * not compressed. However, that stuff is not yet implemented! 
  127831             :  */
  127832             : unsigned long
  127833           0 : SgOmpDoStatement::getNumberOfLastValidPointer()
  127834             :    {
  127835           0 :       SgOmpDoStatement* testPointer = (SgOmpDoStatement*)(SgOmpDoStatement::pools.back());
  127836           0 :       unsigned long localIndex = SgOmpDoStatement::pool_size - 1;
  127837           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  127838             :          {
  127839           0 :            localIndex--;
  127840             :          }
  127841           0 :       return (localIndex + SgOmpDoStatement::pool_size * (SgOmpDoStatement::pools.size()-1));
  127842             :    }
  127843             : 
  127844             : //############################################################################
  127845             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  127846             :  * memory pool and initializes the data member in class SgOmpDoStatementStroageClass
  127847             :  * from its counterpart of SgOmpDoStatement. The return value is just for checking, 
  127848             :  * that the whole StorageClassArray is initialized!
  127849             :  */
  127850             : unsigned long
  127851           0 : SgOmpDoStatement::initializeStorageClassArray( SgOmpDoStatementStorageClass *storageArray )
  127852             :    {
  127853           0 :      unsigned long storageCounter = 0;
  127854           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDoStatement::pools.begin();
  127855           0 :      SgOmpDoStatement* pointer = NULL;
  127856           0 :      while ( block != SgOmpDoStatement::pools.end() ) {
  127857           0 :           pointer = (SgOmpDoStatement*) (*block);
  127858           0 :           for ( unsigned i = 0; i < SgOmpDoStatement::pool_size; ++i ) {
  127859           0 :                if ( pointer->get_freepointer() != NULL ) {
  127860           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  127861           0 :                  storageArray++;
  127862           0 :                  storageCounter++;
  127863             :                }
  127864           0 :                pointer++;
  127865             :              }
  127866           0 :            block++;
  127867             :         }
  127868           0 :      return storageCounter;
  127869             :    }
  127870             : 
  127871             : /* #line 127872 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  127872             : 
  127873             : 
  127874             : 
  127875             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  127876             : 
  127877             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  127878             : 
  127879             : //############################################################################
  127880             : /* JH (02/02/2006) Constructor of the IR node SgOmpSectionsStatement that takes its 
  127881             :  * corresponding StorageClass as parameter
  127882             :  */
  127883           0 : SgOmpSectionsStatement :: SgOmpSectionsStatement ( const SgOmpSectionsStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  127884             :    {
  127885             : 
  127886             : 
  127887             : /* #line 127888 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  127888             : 
  127889           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  127890             : 
  127891             : 
  127892             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  127893             : 
  127894             : 
  127895           0 :    }
  127896             : 
  127897             : //############################################################################
  127898             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  127899             :  * within the working AST. 
  127900             :  */
  127901           0 : SgOmpSectionsStatement * SgOmpSectionsStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  127902           0 :      SgOmpSectionsStatement* returnPointer = NULL;
  127903           0 :      if ( globalIndex != 0 )
  127904             :         {
  127905             : 
  127906             : #if FILE_IO_EXTRA_CHECK
  127907           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpSectionsStatement ) ) <= globalIndex ) ;
  127908           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSectionsStatement + 1 ) ) );
  127909             : #endif
  127910           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpSectionsStatement )  
  127911           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpSectionsStatement );
  127912           0 :           unsigned long positionInPool = localIndex % SgOmpSectionsStatement::pool_size;
  127913           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSectionsStatement::pool_size;
  127914             : 
  127915             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  127916             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  127917             : 
  127918           0 :           returnPointer = &( ( (SgOmpSectionsStatement*)(SgOmpSectionsStatement::pools[memoryBlock]) ) [positionInPool]) ;
  127919             : 
  127920           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  127921             :         }
  127922           0 :      return returnPointer ;
  127923             :    }
  127924             : 
  127925             : //############################################################################
  127926             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  127927             :   for the AST with the index astIndex
  127928             : */
  127929           0 : SgOmpSectionsStatement * SgOmpSectionsStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  127930           0 :      SgOmpSectionsStatement* returnPointer = NULL;
  127931           0 :      if ( globalIndex != 0 )
  127932             :         {
  127933             : 
  127934             : #if FILE_IO_EXTRA_CHECK
  127935           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpSectionsStatement ) ) <= globalIndex ) ;
  127936           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSectionsStatement + 1 ) ) );
  127937             : #endif
  127938           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpSectionsStatement )
  127939           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpSectionsStatement );
  127940           0 :           unsigned long positionInPool = localIndex % SgOmpSectionsStatement::pool_size ;
  127941           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpSectionsStatement::pool_size ;
  127942             : 
  127943             : #if FILE_IO_EXTRA_CHECK
  127944             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  127945             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  127946             : #endif
  127947             : 
  127948           0 :           returnPointer = &( ( (SgOmpSectionsStatement*)(SgOmpSectionsStatement::pools[memoryBlock]) ) [positionInPool]) ;
  127949             : 
  127950             : #if FILE_IO_EXTRA_CHECK
  127951           0 :           assert ( returnPointer != NULL ) ;
  127952             : #endif
  127953             :         }
  127954           0 :      return returnPointer ;
  127955             :    }
  127956             : 
  127957             : //############################################################################
  127958             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  127959             :  * pool size! We set for every valid object in the memory pool the freepointer
  127960             :  * to the global index and increase the global index afterwards. For all the 
  127961             :  * invalid objects (means address ranges within the memory pool that were not
  127962             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  127963             :  * distinguish valid from invalid objects! 
  127964             :  */
  127965             : unsigned long
  127966           5 : SgOmpSectionsStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  127967             :    {
  127968           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  127969           5 :      SgOmpSectionsStatement* pointer = NULL;
  127970           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  127971           5 :      std::vector < unsigned char* > :: const_iterator block;
  127972           5 :      for ( block = SgOmpSectionsStatement::pools.begin(); block != SgOmpSectionsStatement::pools.end() ; ++block )
  127973             :         {
  127974           0 :           pointer = (SgOmpSectionsStatement*)(*block);
  127975           0 :           for (unsigned i = 0; i < SgOmpSectionsStatement::pool_size; ++i )
  127976             :              {
  127977             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  127978             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  127979             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  127980             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  127981             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  127982             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  127983             :             // properly; so this will have to be checked next.
  127984             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  127985             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  127986           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  127987             :                   {
  127988           0 :                     pointer[i].set_freepointer((SgOmpSectionsStatement*)(globalIndex));
  127989           0 :                     globalIndex++;
  127990             :                   }
  127991             :                else
  127992             :                   {
  127993           0 :                     pointer[i].set_freepointer(NULL);
  127994             :                   }
  127995             :               }
  127996             :         }
  127997           5 :      return globalIndex;
  127998             :    }
  127999             : 
  128000             : //############################################################################
  128001             : // JH (01/14/2006)
  128002             : void
  128003           5 : SgOmpSectionsStatement::resetValidFreepointers( )
  128004             :    {
  128005           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  128006           5 :      SgOmpSectionsStatement* pointer = NULL;
  128007           5 :      std::vector < unsigned char* > :: const_iterator block;
  128008           5 :      SgOmpSectionsStatement* pointerOfLinkedList = NULL;
  128009           5 :      for ( block = SgOmpSectionsStatement::pools.begin(); block != SgOmpSectionsStatement::pools.end() ; ++block )
  128010             :         {
  128011           0 :           pointer = (SgOmpSectionsStatement*)(*block);
  128012           0 :           for (unsigned i = 0; i < SgOmpSectionsStatement::pool_size; ++i )
  128013             :              {
  128014             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  128015             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  128016             :             // memory blocks!.
  128017           0 :                if ( pointer[i].get_freepointer() != NULL )
  128018             :                   {
  128019           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  128020             :                   }
  128021             :                else
  128022             :                   {
  128023           0 :                     if ( pointerOfLinkedList == NULL )
  128024             :                        {
  128025           0 :                          SgOmpSectionsStatement::next_node = &(pointer[i]);
  128026             :                        }
  128027             :                     else
  128028             :                        {
  128029             :                       // printf ("In SgOmpSectionsStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  128030           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  128031             :                        }
  128032             :                     pointerOfLinkedList = &(pointer[i]);
  128033             :                   }
  128034             :               }
  128035             :         }
  128036             : 
  128037           5 :      if ( pointerOfLinkedList != NULL )
  128038             :         {
  128039             :        // printf ("In SgOmpSectionsStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  128040           0 :           pointerOfLinkedList->set_freepointer(NULL);
  128041             :        // DQ (6/6/2010): Temporary debugging...
  128042             :        //   ROSE_ASSERT(false);
  128043             :         }
  128044             : 
  128045           5 :      return ;
  128046             :    }
  128047             : 
  128048             : //############################################################################
  128049             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  128050             :  * within the memory pool and resets the freepointers, in order to achieve a 
  128051             :  * linked list, that has no jumps and starts at the beginning! This function 
  128052             :  * does not extend the memory pool, since we do not delete any memory blocks,
  128053             :  * but delete the valid objects.  
  128054             :  */
  128055             : void
  128056           0 : SgOmpSectionsStatement::clearMemoryPool( )
  128057             :    {
  128058             :   // printf ("Inside of SgOmpSectionsStatement::clearMemoryPool() \n");
  128059             : 
  128060           0 :      SgOmpSectionsStatement* pointer = NULL, *tempPointer = NULL;
  128061           0 :      std::vector < unsigned char* > :: const_iterator block;
  128062           0 :      if ( SgOmpSectionsStatement::pools.empty() == false )
  128063             :         {
  128064           0 :           block = SgOmpSectionsStatement::pools.begin() ;
  128065           0 :           SgOmpSectionsStatement::next_node = (SgOmpSectionsStatement*) (*block);
  128066             : 
  128067           0 :           while ( block != SgOmpSectionsStatement::pools.end() )
  128068             :              {
  128069           0 :                pointer = (SgOmpSectionsStatement*) (*block);
  128070           0 :                if ( tempPointer != NULL )
  128071             :                   {
  128072           0 :                     tempPointer->set_freepointer(pointer);
  128073             :                   }
  128074           0 :                for (unsigned i = 0; i < SgOmpSectionsStatement::pool_size - 1; ++i)
  128075             :                   {
  128076           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  128077             :                   }
  128078           0 :                 pointer[SgOmpSectionsStatement::pool_size-1].set_freepointer(NULL);
  128079           0 :                 tempPointer = &(pointer[SgOmpSectionsStatement::pool_size-1]);
  128080           0 :                 ++block;
  128081             :              }
  128082             :         }
  128083           0 :    }
  128084             : 
  128085           5 : void SgOmpSectionsStatement::deleteMemoryPool() {
  128086           5 :   for (auto p: SgOmpSectionsStatement::pools) {
  128087           0 :     ROSE_FREE(p);
  128088             :   }
  128089           5 :   SgOmpSectionsStatement::next_node = nullptr;
  128090           5 :   SgOmpSectionsStatement::pools.clear();
  128091           5 : }
  128092             : 
  128093             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  128094             : //                 reading multiple binary files to for a single AST.
  128095             : /////////// new version ////////////////////////////////
  128096             : //############################################################################
  128097             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  128098             : void
  128099           2 : SgOmpSectionsStatement::extendMemoryPoolForFileIO( )
  128100             :   {
  128101           2 :     size_t blockIndex = SgOmpSectionsStatement::pools.size();
  128102           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionsStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionsStatement);
  128103             : 
  128104           2 :     while ( (blockIndex * SgOmpSectionsStatement::pool_size) < newPoolSize)
  128105             :       {
  128106             : #if ROSE_ALLOC_TRACE
  128107             :         if (blockIndex > 0) {
  128108             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionsStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionsStatement) = %" PRIuPTR " SgOmpSectionsStatement::pool_size = %d \n",
  128109             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpSectionsStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpSectionsStatement),SgOmpSectionsStatement::pool_size);
  128110             :         }
  128111             : #endif
  128112             : 
  128113           0 :         SgOmpSectionsStatement * pointer = (SgOmpSectionsStatement*) ROSE_MALLOC ( SgOmpSectionsStatement::pool_size * sizeof(SgOmpSectionsStatement) );
  128114           0 :         assert( pointer != NULL );
  128115             : #if ROSE_ALLOC_MEMSET == 1
  128116             :         memset(pointer, 0x00, SgOmpSectionsStatement::pool_size * sizeof(SgOmpSectionsStatement));
  128117             : #elif ROSE_ALLOC_MEMSET == 2
  128118             :         memset(pointer, 0xCC, SgOmpSectionsStatement::pool_size * sizeof(SgOmpSectionsStatement));
  128119             : #endif
  128120           0 :         SgOmpSectionsStatement::pools.push_back( (unsigned char*)(pointer) );
  128121           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpSectionsStatement::pool_size * sizeof(SgOmpSectionsStatement), V_SgOmpSectionsStatement ) );
  128122             : 
  128123           0 :         if ( SgOmpSectionsStatement::next_node != NULL ) {
  128124           0 :           if ( blockIndex > 0 ) {
  128125           0 :             SgOmpSectionsStatement * blkptr = (SgOmpSectionsStatement*)(SgOmpSectionsStatement::pools[blockIndex-1]);
  128126           0 :             blkptr[ SgOmpSectionsStatement::pool_size - 1 ].set_freepointer(pointer);
  128127             :           }
  128128             :         } else {
  128129           0 :           SgOmpSectionsStatement::next_node = pointer;
  128130             :         }
  128131             : 
  128132           0 :         for (unsigned i = 0; i < SgOmpSectionsStatement::pool_size-1; ++i)
  128133             :            {
  128134           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  128135             :            }
  128136           0 :         pointer[ SgOmpSectionsStatement::pool_size -1 ].set_freepointer(NULL);
  128137             : 
  128138           0 :         blockIndex++;
  128139             :       }
  128140           2 :   }
  128141             : 
  128142             : //############################################################################
  128143             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  128144             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  128145             :  * not compressed. However, that stuff is not yet implemented! 
  128146             :  */
  128147             : unsigned long
  128148           0 : SgOmpSectionsStatement::getNumberOfLastValidPointer()
  128149             :    {
  128150           0 :       SgOmpSectionsStatement* testPointer = (SgOmpSectionsStatement*)(SgOmpSectionsStatement::pools.back());
  128151           0 :       unsigned long localIndex = SgOmpSectionsStatement::pool_size - 1;
  128152           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  128153             :          {
  128154           0 :            localIndex--;
  128155             :          }
  128156           0 :       return (localIndex + SgOmpSectionsStatement::pool_size * (SgOmpSectionsStatement::pools.size()-1));
  128157             :    }
  128158             : 
  128159             : //############################################################################
  128160             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  128161             :  * memory pool and initializes the data member in class SgOmpSectionsStatementStroageClass
  128162             :  * from its counterpart of SgOmpSectionsStatement. The return value is just for checking, 
  128163             :  * that the whole StorageClassArray is initialized!
  128164             :  */
  128165             : unsigned long
  128166           0 : SgOmpSectionsStatement::initializeStorageClassArray( SgOmpSectionsStatementStorageClass *storageArray )
  128167             :    {
  128168           0 :      unsigned long storageCounter = 0;
  128169           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpSectionsStatement::pools.begin();
  128170           0 :      SgOmpSectionsStatement* pointer = NULL;
  128171           0 :      while ( block != SgOmpSectionsStatement::pools.end() ) {
  128172           0 :           pointer = (SgOmpSectionsStatement*) (*block);
  128173           0 :           for ( unsigned i = 0; i < SgOmpSectionsStatement::pool_size; ++i ) {
  128174           0 :                if ( pointer->get_freepointer() != NULL ) {
  128175           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  128176           0 :                  storageArray++;
  128177           0 :                  storageCounter++;
  128178             :                }
  128179           0 :                pointer++;
  128180             :              }
  128181           0 :            block++;
  128182             :         }
  128183           0 :      return storageCounter;
  128184             :    }
  128185             : 
  128186             : /* #line 128187 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  128187             : 
  128188             : 
  128189             : 
  128190             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  128191             : 
  128192             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  128193             : 
  128194             : //############################################################################
  128195             : /* JH (02/02/2006) Constructor of the IR node SgUpirTaskStatement that takes its 
  128196             :  * corresponding StorageClass as parameter
  128197             :  */
  128198           0 : SgUpirTaskStatement :: SgUpirTaskStatement ( const SgUpirTaskStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  128199             :    {
  128200             : 
  128201             : 
  128202             : /* #line 128203 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  128203             : 
  128204           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  128205             : 
  128206             : 
  128207             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  128208             : 
  128209             : 
  128210           0 :    }
  128211             : 
  128212             : //############################################################################
  128213             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  128214             :  * within the working AST. 
  128215             :  */
  128216           0 : SgUpirTaskStatement * SgUpirTaskStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  128217           0 :      SgUpirTaskStatement* returnPointer = NULL;
  128218           0 :      if ( globalIndex != 0 )
  128219             :         {
  128220             : 
  128221             : #if FILE_IO_EXTRA_CHECK
  128222           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirTaskStatement ) ) <= globalIndex ) ;
  128223           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirTaskStatement + 1 ) ) );
  128224             : #endif
  128225           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirTaskStatement )  
  128226           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirTaskStatement );
  128227           0 :           unsigned long positionInPool = localIndex % SgUpirTaskStatement::pool_size;
  128228           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirTaskStatement::pool_size;
  128229             : 
  128230             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  128231             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  128232             : 
  128233           0 :           returnPointer = &( ( (SgUpirTaskStatement*)(SgUpirTaskStatement::pools[memoryBlock]) ) [positionInPool]) ;
  128234             : 
  128235           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  128236             :         }
  128237           0 :      return returnPointer ;
  128238             :    }
  128239             : 
  128240             : //############################################################################
  128241             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  128242             :   for the AST with the index astIndex
  128243             : */
  128244           0 : SgUpirTaskStatement * SgUpirTaskStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  128245           0 :      SgUpirTaskStatement* returnPointer = NULL;
  128246           0 :      if ( globalIndex != 0 )
  128247             :         {
  128248             : 
  128249             : #if FILE_IO_EXTRA_CHECK
  128250           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirTaskStatement ) ) <= globalIndex ) ;
  128251           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirTaskStatement + 1 ) ) );
  128252             : #endif
  128253           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirTaskStatement )
  128254           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirTaskStatement );
  128255           0 :           unsigned long positionInPool = localIndex % SgUpirTaskStatement::pool_size ;
  128256           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirTaskStatement::pool_size ;
  128257             : 
  128258             : #if FILE_IO_EXTRA_CHECK
  128259             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  128260             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  128261             : #endif
  128262             : 
  128263           0 :           returnPointer = &( ( (SgUpirTaskStatement*)(SgUpirTaskStatement::pools[memoryBlock]) ) [positionInPool]) ;
  128264             : 
  128265             : #if FILE_IO_EXTRA_CHECK
  128266           0 :           assert ( returnPointer != NULL ) ;
  128267             : #endif
  128268             :         }
  128269           0 :      return returnPointer ;
  128270             :    }
  128271             : 
  128272             : //############################################################################
  128273             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  128274             :  * pool size! We set for every valid object in the memory pool the freepointer
  128275             :  * to the global index and increase the global index afterwards. For all the 
  128276             :  * invalid objects (means address ranges within the memory pool that were not
  128277             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  128278             :  * distinguish valid from invalid objects! 
  128279             :  */
  128280             : unsigned long
  128281           5 : SgUpirTaskStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  128282             :    {
  128283           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  128284           5 :      SgUpirTaskStatement* pointer = NULL;
  128285           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  128286           5 :      std::vector < unsigned char* > :: const_iterator block;
  128287           5 :      for ( block = SgUpirTaskStatement::pools.begin(); block != SgUpirTaskStatement::pools.end() ; ++block )
  128288             :         {
  128289           0 :           pointer = (SgUpirTaskStatement*)(*block);
  128290           0 :           for (unsigned i = 0; i < SgUpirTaskStatement::pool_size; ++i )
  128291             :              {
  128292             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  128293             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  128294             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  128295             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  128296             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  128297             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  128298             :             // properly; so this will have to be checked next.
  128299             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  128300             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  128301           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  128302             :                   {
  128303           0 :                     pointer[i].set_freepointer((SgUpirTaskStatement*)(globalIndex));
  128304           0 :                     globalIndex++;
  128305             :                   }
  128306             :                else
  128307             :                   {
  128308           0 :                     pointer[i].set_freepointer(NULL);
  128309             :                   }
  128310             :               }
  128311             :         }
  128312           5 :      return globalIndex;
  128313             :    }
  128314             : 
  128315             : //############################################################################
  128316             : // JH (01/14/2006)
  128317             : void
  128318           5 : SgUpirTaskStatement::resetValidFreepointers( )
  128319             :    {
  128320           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  128321           5 :      SgUpirTaskStatement* pointer = NULL;
  128322           5 :      std::vector < unsigned char* > :: const_iterator block;
  128323           5 :      SgUpirTaskStatement* pointerOfLinkedList = NULL;
  128324           5 :      for ( block = SgUpirTaskStatement::pools.begin(); block != SgUpirTaskStatement::pools.end() ; ++block )
  128325             :         {
  128326           0 :           pointer = (SgUpirTaskStatement*)(*block);
  128327           0 :           for (unsigned i = 0; i < SgUpirTaskStatement::pool_size; ++i )
  128328             :              {
  128329             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  128330             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  128331             :             // memory blocks!.
  128332           0 :                if ( pointer[i].get_freepointer() != NULL )
  128333             :                   {
  128334           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  128335             :                   }
  128336             :                else
  128337             :                   {
  128338           0 :                     if ( pointerOfLinkedList == NULL )
  128339             :                        {
  128340           0 :                          SgUpirTaskStatement::next_node = &(pointer[i]);
  128341             :                        }
  128342             :                     else
  128343             :                        {
  128344             :                       // printf ("In SgUpirTaskStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  128345           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  128346             :                        }
  128347             :                     pointerOfLinkedList = &(pointer[i]);
  128348             :                   }
  128349             :               }
  128350             :         }
  128351             : 
  128352           5 :      if ( pointerOfLinkedList != NULL )
  128353             :         {
  128354             :        // printf ("In SgUpirTaskStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  128355           0 :           pointerOfLinkedList->set_freepointer(NULL);
  128356             :        // DQ (6/6/2010): Temporary debugging...
  128357             :        //   ROSE_ASSERT(false);
  128358             :         }
  128359             : 
  128360           5 :      return ;
  128361             :    }
  128362             : 
  128363             : //############################################################################
  128364             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  128365             :  * within the memory pool and resets the freepointers, in order to achieve a 
  128366             :  * linked list, that has no jumps and starts at the beginning! This function 
  128367             :  * does not extend the memory pool, since we do not delete any memory blocks,
  128368             :  * but delete the valid objects.  
  128369             :  */
  128370             : void
  128371           0 : SgUpirTaskStatement::clearMemoryPool( )
  128372             :    {
  128373             :   // printf ("Inside of SgUpirTaskStatement::clearMemoryPool() \n");
  128374             : 
  128375           0 :      SgUpirTaskStatement* pointer = NULL, *tempPointer = NULL;
  128376           0 :      std::vector < unsigned char* > :: const_iterator block;
  128377           0 :      if ( SgUpirTaskStatement::pools.empty() == false )
  128378             :         {
  128379           0 :           block = SgUpirTaskStatement::pools.begin() ;
  128380           0 :           SgUpirTaskStatement::next_node = (SgUpirTaskStatement*) (*block);
  128381             : 
  128382           0 :           while ( block != SgUpirTaskStatement::pools.end() )
  128383             :              {
  128384           0 :                pointer = (SgUpirTaskStatement*) (*block);
  128385           0 :                if ( tempPointer != NULL )
  128386             :                   {
  128387           0 :                     tempPointer->set_freepointer(pointer);
  128388             :                   }
  128389           0 :                for (unsigned i = 0; i < SgUpirTaskStatement::pool_size - 1; ++i)
  128390             :                   {
  128391           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  128392             :                   }
  128393           0 :                 pointer[SgUpirTaskStatement::pool_size-1].set_freepointer(NULL);
  128394           0 :                 tempPointer = &(pointer[SgUpirTaskStatement::pool_size-1]);
  128395           0 :                 ++block;
  128396             :              }
  128397             :         }
  128398           0 :    }
  128399             : 
  128400           5 : void SgUpirTaskStatement::deleteMemoryPool() {
  128401           5 :   for (auto p: SgUpirTaskStatement::pools) {
  128402           0 :     ROSE_FREE(p);
  128403             :   }
  128404           5 :   SgUpirTaskStatement::next_node = nullptr;
  128405           5 :   SgUpirTaskStatement::pools.clear();
  128406           5 : }
  128407             : 
  128408             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  128409             : //                 reading multiple binary files to for a single AST.
  128410             : /////////// new version ////////////////////////////////
  128411             : //############################################################################
  128412             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  128413             : void
  128414           2 : SgUpirTaskStatement::extendMemoryPoolForFileIO( )
  128415             :   {
  128416           2 :     size_t blockIndex = SgUpirTaskStatement::pools.size();
  128417           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirTaskStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirTaskStatement);
  128418             : 
  128419           2 :     while ( (blockIndex * SgUpirTaskStatement::pool_size) < newPoolSize)
  128420             :       {
  128421             : #if ROSE_ALLOC_TRACE
  128422             :         if (blockIndex > 0) {
  128423             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirTaskStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirTaskStatement) = %" PRIuPTR " SgUpirTaskStatement::pool_size = %d \n",
  128424             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirTaskStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirTaskStatement),SgUpirTaskStatement::pool_size);
  128425             :         }
  128426             : #endif
  128427             : 
  128428           0 :         SgUpirTaskStatement * pointer = (SgUpirTaskStatement*) ROSE_MALLOC ( SgUpirTaskStatement::pool_size * sizeof(SgUpirTaskStatement) );
  128429           0 :         assert( pointer != NULL );
  128430             : #if ROSE_ALLOC_MEMSET == 1
  128431             :         memset(pointer, 0x00, SgUpirTaskStatement::pool_size * sizeof(SgUpirTaskStatement));
  128432             : #elif ROSE_ALLOC_MEMSET == 2
  128433             :         memset(pointer, 0xCC, SgUpirTaskStatement::pool_size * sizeof(SgUpirTaskStatement));
  128434             : #endif
  128435           0 :         SgUpirTaskStatement::pools.push_back( (unsigned char*)(pointer) );
  128436           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirTaskStatement::pool_size * sizeof(SgUpirTaskStatement), V_SgUpirTaskStatement ) );
  128437             : 
  128438           0 :         if ( SgUpirTaskStatement::next_node != NULL ) {
  128439           0 :           if ( blockIndex > 0 ) {
  128440           0 :             SgUpirTaskStatement * blkptr = (SgUpirTaskStatement*)(SgUpirTaskStatement::pools[blockIndex-1]);
  128441           0 :             blkptr[ SgUpirTaskStatement::pool_size - 1 ].set_freepointer(pointer);
  128442             :           }
  128443             :         } else {
  128444           0 :           SgUpirTaskStatement::next_node = pointer;
  128445             :         }
  128446             : 
  128447           0 :         for (unsigned i = 0; i < SgUpirTaskStatement::pool_size-1; ++i)
  128448             :            {
  128449           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  128450             :            }
  128451           0 :         pointer[ SgUpirTaskStatement::pool_size -1 ].set_freepointer(NULL);
  128452             : 
  128453           0 :         blockIndex++;
  128454             :       }
  128455           2 :   }
  128456             : 
  128457             : //############################################################################
  128458             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  128459             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  128460             :  * not compressed. However, that stuff is not yet implemented! 
  128461             :  */
  128462             : unsigned long
  128463           0 : SgUpirTaskStatement::getNumberOfLastValidPointer()
  128464             :    {
  128465           0 :       SgUpirTaskStatement* testPointer = (SgUpirTaskStatement*)(SgUpirTaskStatement::pools.back());
  128466           0 :       unsigned long localIndex = SgUpirTaskStatement::pool_size - 1;
  128467           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  128468             :          {
  128469           0 :            localIndex--;
  128470             :          }
  128471           0 :       return (localIndex + SgUpirTaskStatement::pool_size * (SgUpirTaskStatement::pools.size()-1));
  128472             :    }
  128473             : 
  128474             : //############################################################################
  128475             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  128476             :  * memory pool and initializes the data member in class SgUpirTaskStatementStroageClass
  128477             :  * from its counterpart of SgUpirTaskStatement. The return value is just for checking, 
  128478             :  * that the whole StorageClassArray is initialized!
  128479             :  */
  128480             : unsigned long
  128481           0 : SgUpirTaskStatement::initializeStorageClassArray( SgUpirTaskStatementStorageClass *storageArray )
  128482             :    {
  128483           0 :      unsigned long storageCounter = 0;
  128484           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirTaskStatement::pools.begin();
  128485           0 :      SgUpirTaskStatement* pointer = NULL;
  128486           0 :      while ( block != SgUpirTaskStatement::pools.end() ) {
  128487           0 :           pointer = (SgUpirTaskStatement*) (*block);
  128488           0 :           for ( unsigned i = 0; i < SgUpirTaskStatement::pool_size; ++i ) {
  128489           0 :                if ( pointer->get_freepointer() != NULL ) {
  128490           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  128491           0 :                  storageArray++;
  128492           0 :                  storageCounter++;
  128493             :                }
  128494           0 :                pointer++;
  128495             :              }
  128496           0 :            block++;
  128497             :         }
  128498           0 :      return storageCounter;
  128499             :    }
  128500             : 
  128501             : /* #line 128502 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  128502             : 
  128503             : 
  128504             : 
  128505             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  128506             : 
  128507             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  128508             : 
  128509             : //############################################################################
  128510             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetDataStatement that takes its 
  128511             :  * corresponding StorageClass as parameter
  128512             :  */
  128513           0 : SgOmpTargetDataStatement :: SgOmpTargetDataStatement ( const SgOmpTargetDataStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  128514             :    {
  128515             : 
  128516             : 
  128517             : /* #line 128518 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  128518             : 
  128519           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  128520             : 
  128521             : 
  128522             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  128523             : 
  128524             : 
  128525           0 :    }
  128526             : 
  128527             : //############################################################################
  128528             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  128529             :  * within the working AST. 
  128530             :  */
  128531           0 : SgOmpTargetDataStatement * SgOmpTargetDataStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  128532           0 :      SgOmpTargetDataStatement* returnPointer = NULL;
  128533           0 :      if ( globalIndex != 0 )
  128534             :         {
  128535             : 
  128536             : #if FILE_IO_EXTRA_CHECK
  128537           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetDataStatement ) ) <= globalIndex ) ;
  128538           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetDataStatement + 1 ) ) );
  128539             : #endif
  128540           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetDataStatement )  
  128541           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetDataStatement );
  128542           0 :           unsigned long positionInPool = localIndex % SgOmpTargetDataStatement::pool_size;
  128543           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetDataStatement::pool_size;
  128544             : 
  128545             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  128546             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  128547             : 
  128548           0 :           returnPointer = &( ( (SgOmpTargetDataStatement*)(SgOmpTargetDataStatement::pools[memoryBlock]) ) [positionInPool]) ;
  128549             : 
  128550           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  128551             :         }
  128552           0 :      return returnPointer ;
  128553             :    }
  128554             : 
  128555             : //############################################################################
  128556             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  128557             :   for the AST with the index astIndex
  128558             : */
  128559           0 : SgOmpTargetDataStatement * SgOmpTargetDataStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  128560           0 :      SgOmpTargetDataStatement* returnPointer = NULL;
  128561           0 :      if ( globalIndex != 0 )
  128562             :         {
  128563             : 
  128564             : #if FILE_IO_EXTRA_CHECK
  128565           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetDataStatement ) ) <= globalIndex ) ;
  128566           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetDataStatement + 1 ) ) );
  128567             : #endif
  128568           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetDataStatement )
  128569           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetDataStatement );
  128570           0 :           unsigned long positionInPool = localIndex % SgOmpTargetDataStatement::pool_size ;
  128571           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetDataStatement::pool_size ;
  128572             : 
  128573             : #if FILE_IO_EXTRA_CHECK
  128574             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  128575             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  128576             : #endif
  128577             : 
  128578           0 :           returnPointer = &( ( (SgOmpTargetDataStatement*)(SgOmpTargetDataStatement::pools[memoryBlock]) ) [positionInPool]) ;
  128579             : 
  128580             : #if FILE_IO_EXTRA_CHECK
  128581           0 :           assert ( returnPointer != NULL ) ;
  128582             : #endif
  128583             :         }
  128584           0 :      return returnPointer ;
  128585             :    }
  128586             : 
  128587             : //############################################################################
  128588             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  128589             :  * pool size! We set for every valid object in the memory pool the freepointer
  128590             :  * to the global index and increase the global index afterwards. For all the 
  128591             :  * invalid objects (means address ranges within the memory pool that were not
  128592             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  128593             :  * distinguish valid from invalid objects! 
  128594             :  */
  128595             : unsigned long
  128596           5 : SgOmpTargetDataStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  128597             :    {
  128598           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  128599           5 :      SgOmpTargetDataStatement* pointer = NULL;
  128600           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  128601           5 :      std::vector < unsigned char* > :: const_iterator block;
  128602           5 :      for ( block = SgOmpTargetDataStatement::pools.begin(); block != SgOmpTargetDataStatement::pools.end() ; ++block )
  128603             :         {
  128604           0 :           pointer = (SgOmpTargetDataStatement*)(*block);
  128605           0 :           for (unsigned i = 0; i < SgOmpTargetDataStatement::pool_size; ++i )
  128606             :              {
  128607             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  128608             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  128609             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  128610             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  128611             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  128612             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  128613             :             // properly; so this will have to be checked next.
  128614             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  128615             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  128616           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  128617             :                   {
  128618           0 :                     pointer[i].set_freepointer((SgOmpTargetDataStatement*)(globalIndex));
  128619           0 :                     globalIndex++;
  128620             :                   }
  128621             :                else
  128622             :                   {
  128623           0 :                     pointer[i].set_freepointer(NULL);
  128624             :                   }
  128625             :               }
  128626             :         }
  128627           5 :      return globalIndex;
  128628             :    }
  128629             : 
  128630             : //############################################################################
  128631             : // JH (01/14/2006)
  128632             : void
  128633           5 : SgOmpTargetDataStatement::resetValidFreepointers( )
  128634             :    {
  128635           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  128636           5 :      SgOmpTargetDataStatement* pointer = NULL;
  128637           5 :      std::vector < unsigned char* > :: const_iterator block;
  128638           5 :      SgOmpTargetDataStatement* pointerOfLinkedList = NULL;
  128639           5 :      for ( block = SgOmpTargetDataStatement::pools.begin(); block != SgOmpTargetDataStatement::pools.end() ; ++block )
  128640             :         {
  128641           0 :           pointer = (SgOmpTargetDataStatement*)(*block);
  128642           0 :           for (unsigned i = 0; i < SgOmpTargetDataStatement::pool_size; ++i )
  128643             :              {
  128644             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  128645             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  128646             :             // memory blocks!.
  128647           0 :                if ( pointer[i].get_freepointer() != NULL )
  128648             :                   {
  128649           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  128650             :                   }
  128651             :                else
  128652             :                   {
  128653           0 :                     if ( pointerOfLinkedList == NULL )
  128654             :                        {
  128655           0 :                          SgOmpTargetDataStatement::next_node = &(pointer[i]);
  128656             :                        }
  128657             :                     else
  128658             :                        {
  128659             :                       // printf ("In SgOmpTargetDataStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  128660           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  128661             :                        }
  128662             :                     pointerOfLinkedList = &(pointer[i]);
  128663             :                   }
  128664             :               }
  128665             :         }
  128666             : 
  128667           5 :      if ( pointerOfLinkedList != NULL )
  128668             :         {
  128669             :        // printf ("In SgOmpTargetDataStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  128670           0 :           pointerOfLinkedList->set_freepointer(NULL);
  128671             :        // DQ (6/6/2010): Temporary debugging...
  128672             :        //   ROSE_ASSERT(false);
  128673             :         }
  128674             : 
  128675           5 :      return ;
  128676             :    }
  128677             : 
  128678             : //############################################################################
  128679             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  128680             :  * within the memory pool and resets the freepointers, in order to achieve a 
  128681             :  * linked list, that has no jumps and starts at the beginning! This function 
  128682             :  * does not extend the memory pool, since we do not delete any memory blocks,
  128683             :  * but delete the valid objects.  
  128684             :  */
  128685             : void
  128686           0 : SgOmpTargetDataStatement::clearMemoryPool( )
  128687             :    {
  128688             :   // printf ("Inside of SgOmpTargetDataStatement::clearMemoryPool() \n");
  128689             : 
  128690           0 :      SgOmpTargetDataStatement* pointer = NULL, *tempPointer = NULL;
  128691           0 :      std::vector < unsigned char* > :: const_iterator block;
  128692           0 :      if ( SgOmpTargetDataStatement::pools.empty() == false )
  128693             :         {
  128694           0 :           block = SgOmpTargetDataStatement::pools.begin() ;
  128695           0 :           SgOmpTargetDataStatement::next_node = (SgOmpTargetDataStatement*) (*block);
  128696             : 
  128697           0 :           while ( block != SgOmpTargetDataStatement::pools.end() )
  128698             :              {
  128699           0 :                pointer = (SgOmpTargetDataStatement*) (*block);
  128700           0 :                if ( tempPointer != NULL )
  128701             :                   {
  128702           0 :                     tempPointer->set_freepointer(pointer);
  128703             :                   }
  128704           0 :                for (unsigned i = 0; i < SgOmpTargetDataStatement::pool_size - 1; ++i)
  128705             :                   {
  128706           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  128707             :                   }
  128708           0 :                 pointer[SgOmpTargetDataStatement::pool_size-1].set_freepointer(NULL);
  128709           0 :                 tempPointer = &(pointer[SgOmpTargetDataStatement::pool_size-1]);
  128710           0 :                 ++block;
  128711             :              }
  128712             :         }
  128713           0 :    }
  128714             : 
  128715           5 : void SgOmpTargetDataStatement::deleteMemoryPool() {
  128716           5 :   for (auto p: SgOmpTargetDataStatement::pools) {
  128717           0 :     ROSE_FREE(p);
  128718             :   }
  128719           5 :   SgOmpTargetDataStatement::next_node = nullptr;
  128720           5 :   SgOmpTargetDataStatement::pools.clear();
  128721           5 : }
  128722             : 
  128723             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  128724             : //                 reading multiple binary files to for a single AST.
  128725             : /////////// new version ////////////////////////////////
  128726             : //############################################################################
  128727             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  128728             : void
  128729           2 : SgOmpTargetDataStatement::extendMemoryPoolForFileIO( )
  128730             :   {
  128731           2 :     size_t blockIndex = SgOmpTargetDataStatement::pools.size();
  128732           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetDataStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetDataStatement);
  128733             : 
  128734           2 :     while ( (blockIndex * SgOmpTargetDataStatement::pool_size) < newPoolSize)
  128735             :       {
  128736             : #if ROSE_ALLOC_TRACE
  128737             :         if (blockIndex > 0) {
  128738             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetDataStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetDataStatement) = %" PRIuPTR " SgOmpTargetDataStatement::pool_size = %d \n",
  128739             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetDataStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetDataStatement),SgOmpTargetDataStatement::pool_size);
  128740             :         }
  128741             : #endif
  128742             : 
  128743           0 :         SgOmpTargetDataStatement * pointer = (SgOmpTargetDataStatement*) ROSE_MALLOC ( SgOmpTargetDataStatement::pool_size * sizeof(SgOmpTargetDataStatement) );
  128744           0 :         assert( pointer != NULL );
  128745             : #if ROSE_ALLOC_MEMSET == 1
  128746             :         memset(pointer, 0x00, SgOmpTargetDataStatement::pool_size * sizeof(SgOmpTargetDataStatement));
  128747             : #elif ROSE_ALLOC_MEMSET == 2
  128748             :         memset(pointer, 0xCC, SgOmpTargetDataStatement::pool_size * sizeof(SgOmpTargetDataStatement));
  128749             : #endif
  128750           0 :         SgOmpTargetDataStatement::pools.push_back( (unsigned char*)(pointer) );
  128751           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetDataStatement::pool_size * sizeof(SgOmpTargetDataStatement), V_SgOmpTargetDataStatement ) );
  128752             : 
  128753           0 :         if ( SgOmpTargetDataStatement::next_node != NULL ) {
  128754           0 :           if ( blockIndex > 0 ) {
  128755           0 :             SgOmpTargetDataStatement * blkptr = (SgOmpTargetDataStatement*)(SgOmpTargetDataStatement::pools[blockIndex-1]);
  128756           0 :             blkptr[ SgOmpTargetDataStatement::pool_size - 1 ].set_freepointer(pointer);
  128757             :           }
  128758             :         } else {
  128759           0 :           SgOmpTargetDataStatement::next_node = pointer;
  128760             :         }
  128761             : 
  128762           0 :         for (unsigned i = 0; i < SgOmpTargetDataStatement::pool_size-1; ++i)
  128763             :            {
  128764           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  128765             :            }
  128766           0 :         pointer[ SgOmpTargetDataStatement::pool_size -1 ].set_freepointer(NULL);
  128767             : 
  128768           0 :         blockIndex++;
  128769             :       }
  128770           2 :   }
  128771             : 
  128772             : //############################################################################
  128773             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  128774             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  128775             :  * not compressed. However, that stuff is not yet implemented! 
  128776             :  */
  128777             : unsigned long
  128778           0 : SgOmpTargetDataStatement::getNumberOfLastValidPointer()
  128779             :    {
  128780           0 :       SgOmpTargetDataStatement* testPointer = (SgOmpTargetDataStatement*)(SgOmpTargetDataStatement::pools.back());
  128781           0 :       unsigned long localIndex = SgOmpTargetDataStatement::pool_size - 1;
  128782           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  128783             :          {
  128784           0 :            localIndex--;
  128785             :          }
  128786           0 :       return (localIndex + SgOmpTargetDataStatement::pool_size * (SgOmpTargetDataStatement::pools.size()-1));
  128787             :    }
  128788             : 
  128789             : //############################################################################
  128790             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  128791             :  * memory pool and initializes the data member in class SgOmpTargetDataStatementStroageClass
  128792             :  * from its counterpart of SgOmpTargetDataStatement. The return value is just for checking, 
  128793             :  * that the whole StorageClassArray is initialized!
  128794             :  */
  128795             : unsigned long
  128796           0 : SgOmpTargetDataStatement::initializeStorageClassArray( SgOmpTargetDataStatementStorageClass *storageArray )
  128797             :    {
  128798           0 :      unsigned long storageCounter = 0;
  128799           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetDataStatement::pools.begin();
  128800           0 :      SgOmpTargetDataStatement* pointer = NULL;
  128801           0 :      while ( block != SgOmpTargetDataStatement::pools.end() ) {
  128802           0 :           pointer = (SgOmpTargetDataStatement*) (*block);
  128803           0 :           for ( unsigned i = 0; i < SgOmpTargetDataStatement::pool_size; ++i ) {
  128804           0 :                if ( pointer->get_freepointer() != NULL ) {
  128805           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  128806           0 :                  storageArray++;
  128807           0 :                  storageCounter++;
  128808             :                }
  128809           0 :                pointer++;
  128810             :              }
  128811           0 :            block++;
  128812             :         }
  128813           0 :      return storageCounter;
  128814             :    }
  128815             : 
  128816             : /* #line 128817 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  128817             : 
  128818             : 
  128819             : 
  128820             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  128821             : 
  128822             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  128823             : 
  128824             : //############################################################################
  128825             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetParallelForStatement that takes its 
  128826             :  * corresponding StorageClass as parameter
  128827             :  */
  128828           0 : SgOmpTargetParallelForStatement :: SgOmpTargetParallelForStatement ( const SgOmpTargetParallelForStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  128829             :    {
  128830             : 
  128831             : 
  128832             : /* #line 128833 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  128833             : 
  128834           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  128835             : 
  128836             : 
  128837             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  128838             : 
  128839             : 
  128840           0 :    }
  128841             : 
  128842             : //############################################################################
  128843             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  128844             :  * within the working AST. 
  128845             :  */
  128846           0 : SgOmpTargetParallelForStatement * SgOmpTargetParallelForStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  128847           0 :      SgOmpTargetParallelForStatement* returnPointer = NULL;
  128848           0 :      if ( globalIndex != 0 )
  128849             :         {
  128850             : 
  128851             : #if FILE_IO_EXTRA_CHECK
  128852           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetParallelForStatement ) ) <= globalIndex ) ;
  128853           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetParallelForStatement + 1 ) ) );
  128854             : #endif
  128855           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetParallelForStatement )  
  128856           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetParallelForStatement );
  128857           0 :           unsigned long positionInPool = localIndex % SgOmpTargetParallelForStatement::pool_size;
  128858           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetParallelForStatement::pool_size;
  128859             : 
  128860             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  128861             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  128862             : 
  128863           0 :           returnPointer = &( ( (SgOmpTargetParallelForStatement*)(SgOmpTargetParallelForStatement::pools[memoryBlock]) ) [positionInPool]) ;
  128864             : 
  128865           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  128866             :         }
  128867           0 :      return returnPointer ;
  128868             :    }
  128869             : 
  128870             : //############################################################################
  128871             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  128872             :   for the AST with the index astIndex
  128873             : */
  128874           0 : SgOmpTargetParallelForStatement * SgOmpTargetParallelForStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  128875           0 :      SgOmpTargetParallelForStatement* returnPointer = NULL;
  128876           0 :      if ( globalIndex != 0 )
  128877             :         {
  128878             : 
  128879             : #if FILE_IO_EXTRA_CHECK
  128880           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetParallelForStatement ) ) <= globalIndex ) ;
  128881           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetParallelForStatement + 1 ) ) );
  128882             : #endif
  128883           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetParallelForStatement )
  128884           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetParallelForStatement );
  128885           0 :           unsigned long positionInPool = localIndex % SgOmpTargetParallelForStatement::pool_size ;
  128886           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetParallelForStatement::pool_size ;
  128887             : 
  128888             : #if FILE_IO_EXTRA_CHECK
  128889             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  128890             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  128891             : #endif
  128892             : 
  128893           0 :           returnPointer = &( ( (SgOmpTargetParallelForStatement*)(SgOmpTargetParallelForStatement::pools[memoryBlock]) ) [positionInPool]) ;
  128894             : 
  128895             : #if FILE_IO_EXTRA_CHECK
  128896           0 :           assert ( returnPointer != NULL ) ;
  128897             : #endif
  128898             :         }
  128899           0 :      return returnPointer ;
  128900             :    }
  128901             : 
  128902             : //############################################################################
  128903             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  128904             :  * pool size! We set for every valid object in the memory pool the freepointer
  128905             :  * to the global index and increase the global index afterwards. For all the 
  128906             :  * invalid objects (means address ranges within the memory pool that were not
  128907             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  128908             :  * distinguish valid from invalid objects! 
  128909             :  */
  128910             : unsigned long
  128911           5 : SgOmpTargetParallelForStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  128912             :    {
  128913           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  128914           5 :      SgOmpTargetParallelForStatement* pointer = NULL;
  128915           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  128916           5 :      std::vector < unsigned char* > :: const_iterator block;
  128917           5 :      for ( block = SgOmpTargetParallelForStatement::pools.begin(); block != SgOmpTargetParallelForStatement::pools.end() ; ++block )
  128918             :         {
  128919           0 :           pointer = (SgOmpTargetParallelForStatement*)(*block);
  128920           0 :           for (unsigned i = 0; i < SgOmpTargetParallelForStatement::pool_size; ++i )
  128921             :              {
  128922             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  128923             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  128924             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  128925             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  128926             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  128927             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  128928             :             // properly; so this will have to be checked next.
  128929             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  128930             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  128931           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  128932             :                   {
  128933           0 :                     pointer[i].set_freepointer((SgOmpTargetParallelForStatement*)(globalIndex));
  128934           0 :                     globalIndex++;
  128935             :                   }
  128936             :                else
  128937             :                   {
  128938           0 :                     pointer[i].set_freepointer(NULL);
  128939             :                   }
  128940             :               }
  128941             :         }
  128942           5 :      return globalIndex;
  128943             :    }
  128944             : 
  128945             : //############################################################################
  128946             : // JH (01/14/2006)
  128947             : void
  128948           5 : SgOmpTargetParallelForStatement::resetValidFreepointers( )
  128949             :    {
  128950           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  128951           5 :      SgOmpTargetParallelForStatement* pointer = NULL;
  128952           5 :      std::vector < unsigned char* > :: const_iterator block;
  128953           5 :      SgOmpTargetParallelForStatement* pointerOfLinkedList = NULL;
  128954           5 :      for ( block = SgOmpTargetParallelForStatement::pools.begin(); block != SgOmpTargetParallelForStatement::pools.end() ; ++block )
  128955             :         {
  128956           0 :           pointer = (SgOmpTargetParallelForStatement*)(*block);
  128957           0 :           for (unsigned i = 0; i < SgOmpTargetParallelForStatement::pool_size; ++i )
  128958             :              {
  128959             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  128960             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  128961             :             // memory blocks!.
  128962           0 :                if ( pointer[i].get_freepointer() != NULL )
  128963             :                   {
  128964           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  128965             :                   }
  128966             :                else
  128967             :                   {
  128968           0 :                     if ( pointerOfLinkedList == NULL )
  128969             :                        {
  128970           0 :                          SgOmpTargetParallelForStatement::next_node = &(pointer[i]);
  128971             :                        }
  128972             :                     else
  128973             :                        {
  128974             :                       // printf ("In SgOmpTargetParallelForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  128975           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  128976             :                        }
  128977             :                     pointerOfLinkedList = &(pointer[i]);
  128978             :                   }
  128979             :               }
  128980             :         }
  128981             : 
  128982           5 :      if ( pointerOfLinkedList != NULL )
  128983             :         {
  128984             :        // printf ("In SgOmpTargetParallelForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  128985           0 :           pointerOfLinkedList->set_freepointer(NULL);
  128986             :        // DQ (6/6/2010): Temporary debugging...
  128987             :        //   ROSE_ASSERT(false);
  128988             :         }
  128989             : 
  128990           5 :      return ;
  128991             :    }
  128992             : 
  128993             : //############################################################################
  128994             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  128995             :  * within the memory pool and resets the freepointers, in order to achieve a 
  128996             :  * linked list, that has no jumps and starts at the beginning! This function 
  128997             :  * does not extend the memory pool, since we do not delete any memory blocks,
  128998             :  * but delete the valid objects.  
  128999             :  */
  129000             : void
  129001           0 : SgOmpTargetParallelForStatement::clearMemoryPool( )
  129002             :    {
  129003             :   // printf ("Inside of SgOmpTargetParallelForStatement::clearMemoryPool() \n");
  129004             : 
  129005           0 :      SgOmpTargetParallelForStatement* pointer = NULL, *tempPointer = NULL;
  129006           0 :      std::vector < unsigned char* > :: const_iterator block;
  129007           0 :      if ( SgOmpTargetParallelForStatement::pools.empty() == false )
  129008             :         {
  129009           0 :           block = SgOmpTargetParallelForStatement::pools.begin() ;
  129010           0 :           SgOmpTargetParallelForStatement::next_node = (SgOmpTargetParallelForStatement*) (*block);
  129011             : 
  129012           0 :           while ( block != SgOmpTargetParallelForStatement::pools.end() )
  129013             :              {
  129014           0 :                pointer = (SgOmpTargetParallelForStatement*) (*block);
  129015           0 :                if ( tempPointer != NULL )
  129016             :                   {
  129017           0 :                     tempPointer->set_freepointer(pointer);
  129018             :                   }
  129019           0 :                for (unsigned i = 0; i < SgOmpTargetParallelForStatement::pool_size - 1; ++i)
  129020             :                   {
  129021           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  129022             :                   }
  129023           0 :                 pointer[SgOmpTargetParallelForStatement::pool_size-1].set_freepointer(NULL);
  129024           0 :                 tempPointer = &(pointer[SgOmpTargetParallelForStatement::pool_size-1]);
  129025           0 :                 ++block;
  129026             :              }
  129027             :         }
  129028           0 :    }
  129029             : 
  129030           5 : void SgOmpTargetParallelForStatement::deleteMemoryPool() {
  129031           5 :   for (auto p: SgOmpTargetParallelForStatement::pools) {
  129032           0 :     ROSE_FREE(p);
  129033             :   }
  129034           5 :   SgOmpTargetParallelForStatement::next_node = nullptr;
  129035           5 :   SgOmpTargetParallelForStatement::pools.clear();
  129036           5 : }
  129037             : 
  129038             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  129039             : //                 reading multiple binary files to for a single AST.
  129040             : /////////// new version ////////////////////////////////
  129041             : //############################################################################
  129042             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  129043             : void
  129044           2 : SgOmpTargetParallelForStatement::extendMemoryPoolForFileIO( )
  129045             :   {
  129046           2 :     size_t blockIndex = SgOmpTargetParallelForStatement::pools.size();
  129047           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelForStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelForStatement);
  129048             : 
  129049           2 :     while ( (blockIndex * SgOmpTargetParallelForStatement::pool_size) < newPoolSize)
  129050             :       {
  129051             : #if ROSE_ALLOC_TRACE
  129052             :         if (blockIndex > 0) {
  129053             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelForStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelForStatement) = %" PRIuPTR " SgOmpTargetParallelForStatement::pool_size = %d \n",
  129054             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelForStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelForStatement),SgOmpTargetParallelForStatement::pool_size);
  129055             :         }
  129056             : #endif
  129057             : 
  129058           0 :         SgOmpTargetParallelForStatement * pointer = (SgOmpTargetParallelForStatement*) ROSE_MALLOC ( SgOmpTargetParallelForStatement::pool_size * sizeof(SgOmpTargetParallelForStatement) );
  129059           0 :         assert( pointer != NULL );
  129060             : #if ROSE_ALLOC_MEMSET == 1
  129061             :         memset(pointer, 0x00, SgOmpTargetParallelForStatement::pool_size * sizeof(SgOmpTargetParallelForStatement));
  129062             : #elif ROSE_ALLOC_MEMSET == 2
  129063             :         memset(pointer, 0xCC, SgOmpTargetParallelForStatement::pool_size * sizeof(SgOmpTargetParallelForStatement));
  129064             : #endif
  129065           0 :         SgOmpTargetParallelForStatement::pools.push_back( (unsigned char*)(pointer) );
  129066           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetParallelForStatement::pool_size * sizeof(SgOmpTargetParallelForStatement), V_SgOmpTargetParallelForStatement ) );
  129067             : 
  129068           0 :         if ( SgOmpTargetParallelForStatement::next_node != NULL ) {
  129069           0 :           if ( blockIndex > 0 ) {
  129070           0 :             SgOmpTargetParallelForStatement * blkptr = (SgOmpTargetParallelForStatement*)(SgOmpTargetParallelForStatement::pools[blockIndex-1]);
  129071           0 :             blkptr[ SgOmpTargetParallelForStatement::pool_size - 1 ].set_freepointer(pointer);
  129072             :           }
  129073             :         } else {
  129074           0 :           SgOmpTargetParallelForStatement::next_node = pointer;
  129075             :         }
  129076             : 
  129077           0 :         for (unsigned i = 0; i < SgOmpTargetParallelForStatement::pool_size-1; ++i)
  129078             :            {
  129079           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  129080             :            }
  129081           0 :         pointer[ SgOmpTargetParallelForStatement::pool_size -1 ].set_freepointer(NULL);
  129082             : 
  129083           0 :         blockIndex++;
  129084             :       }
  129085           2 :   }
  129086             : 
  129087             : //############################################################################
  129088             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  129089             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  129090             :  * not compressed. However, that stuff is not yet implemented! 
  129091             :  */
  129092             : unsigned long
  129093           0 : SgOmpTargetParallelForStatement::getNumberOfLastValidPointer()
  129094             :    {
  129095           0 :       SgOmpTargetParallelForStatement* testPointer = (SgOmpTargetParallelForStatement*)(SgOmpTargetParallelForStatement::pools.back());
  129096           0 :       unsigned long localIndex = SgOmpTargetParallelForStatement::pool_size - 1;
  129097           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  129098             :          {
  129099           0 :            localIndex--;
  129100             :          }
  129101           0 :       return (localIndex + SgOmpTargetParallelForStatement::pool_size * (SgOmpTargetParallelForStatement::pools.size()-1));
  129102             :    }
  129103             : 
  129104             : //############################################################################
  129105             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  129106             :  * memory pool and initializes the data member in class SgOmpTargetParallelForStatementStroageClass
  129107             :  * from its counterpart of SgOmpTargetParallelForStatement. The return value is just for checking, 
  129108             :  * that the whole StorageClassArray is initialized!
  129109             :  */
  129110             : unsigned long
  129111           0 : SgOmpTargetParallelForStatement::initializeStorageClassArray( SgOmpTargetParallelForStatementStorageClass *storageArray )
  129112             :    {
  129113           0 :      unsigned long storageCounter = 0;
  129114           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetParallelForStatement::pools.begin();
  129115           0 :      SgOmpTargetParallelForStatement* pointer = NULL;
  129116           0 :      while ( block != SgOmpTargetParallelForStatement::pools.end() ) {
  129117           0 :           pointer = (SgOmpTargetParallelForStatement*) (*block);
  129118           0 :           for ( unsigned i = 0; i < SgOmpTargetParallelForStatement::pool_size; ++i ) {
  129119           0 :                if ( pointer->get_freepointer() != NULL ) {
  129120           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  129121           0 :                  storageArray++;
  129122           0 :                  storageCounter++;
  129123             :                }
  129124           0 :                pointer++;
  129125             :              }
  129126           0 :            block++;
  129127             :         }
  129128           0 :      return storageCounter;
  129129             :    }
  129130             : 
  129131             : /* #line 129132 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  129132             : 
  129133             : 
  129134             : 
  129135             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  129136             : 
  129137             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  129138             : 
  129139             : //############################################################################
  129140             : /* JH (02/02/2006) Constructor of the IR node SgOmpParallelLoopStatement that takes its 
  129141             :  * corresponding StorageClass as parameter
  129142             :  */
  129143           0 : SgOmpParallelLoopStatement :: SgOmpParallelLoopStatement ( const SgOmpParallelLoopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  129144             :    {
  129145             : 
  129146             : 
  129147             : /* #line 129148 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  129148             : 
  129149           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  129150             : 
  129151             : 
  129152             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  129153             : 
  129154             : 
  129155           0 :    }
  129156             : 
  129157             : //############################################################################
  129158             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  129159             :  * within the working AST. 
  129160             :  */
  129161           0 : SgOmpParallelLoopStatement * SgOmpParallelLoopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  129162           0 :      SgOmpParallelLoopStatement* returnPointer = NULL;
  129163           0 :      if ( globalIndex != 0 )
  129164             :         {
  129165             : 
  129166             : #if FILE_IO_EXTRA_CHECK
  129167           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpParallelLoopStatement ) ) <= globalIndex ) ;
  129168           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelLoopStatement + 1 ) ) );
  129169             : #endif
  129170           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelLoopStatement )  
  129171           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpParallelLoopStatement );
  129172           0 :           unsigned long positionInPool = localIndex % SgOmpParallelLoopStatement::pool_size;
  129173           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelLoopStatement::pool_size;
  129174             : 
  129175             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  129176             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  129177             : 
  129178           0 :           returnPointer = &( ( (SgOmpParallelLoopStatement*)(SgOmpParallelLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  129179             : 
  129180           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  129181             :         }
  129182           0 :      return returnPointer ;
  129183             :    }
  129184             : 
  129185             : //############################################################################
  129186             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  129187             :   for the AST with the index astIndex
  129188             : */
  129189           0 : SgOmpParallelLoopStatement * SgOmpParallelLoopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  129190           0 :      SgOmpParallelLoopStatement* returnPointer = NULL;
  129191           0 :      if ( globalIndex != 0 )
  129192             :         {
  129193             : 
  129194             : #if FILE_IO_EXTRA_CHECK
  129195           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpParallelLoopStatement ) ) <= globalIndex ) ;
  129196           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelLoopStatement + 1 ) ) );
  129197             : #endif
  129198           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelLoopStatement )
  129199           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpParallelLoopStatement );
  129200           0 :           unsigned long positionInPool = localIndex % SgOmpParallelLoopStatement::pool_size ;
  129201           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelLoopStatement::pool_size ;
  129202             : 
  129203             : #if FILE_IO_EXTRA_CHECK
  129204             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  129205             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  129206             : #endif
  129207             : 
  129208           0 :           returnPointer = &( ( (SgOmpParallelLoopStatement*)(SgOmpParallelLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  129209             : 
  129210             : #if FILE_IO_EXTRA_CHECK
  129211           0 :           assert ( returnPointer != NULL ) ;
  129212             : #endif
  129213             :         }
  129214           0 :      return returnPointer ;
  129215             :    }
  129216             : 
  129217             : //############################################################################
  129218             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  129219             :  * pool size! We set for every valid object in the memory pool the freepointer
  129220             :  * to the global index and increase the global index afterwards. For all the 
  129221             :  * invalid objects (means address ranges within the memory pool that were not
  129222             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  129223             :  * distinguish valid from invalid objects! 
  129224             :  */
  129225             : unsigned long
  129226           5 : SgOmpParallelLoopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  129227             :    {
  129228           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  129229           5 :      SgOmpParallelLoopStatement* pointer = NULL;
  129230           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  129231           5 :      std::vector < unsigned char* > :: const_iterator block;
  129232           5 :      for ( block = SgOmpParallelLoopStatement::pools.begin(); block != SgOmpParallelLoopStatement::pools.end() ; ++block )
  129233             :         {
  129234           0 :           pointer = (SgOmpParallelLoopStatement*)(*block);
  129235           0 :           for (unsigned i = 0; i < SgOmpParallelLoopStatement::pool_size; ++i )
  129236             :              {
  129237             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  129238             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  129239             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  129240             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  129241             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  129242             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  129243             :             // properly; so this will have to be checked next.
  129244             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  129245             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  129246           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  129247             :                   {
  129248           0 :                     pointer[i].set_freepointer((SgOmpParallelLoopStatement*)(globalIndex));
  129249           0 :                     globalIndex++;
  129250             :                   }
  129251             :                else
  129252             :                   {
  129253           0 :                     pointer[i].set_freepointer(NULL);
  129254             :                   }
  129255             :               }
  129256             :         }
  129257           5 :      return globalIndex;
  129258             :    }
  129259             : 
  129260             : //############################################################################
  129261             : // JH (01/14/2006)
  129262             : void
  129263           5 : SgOmpParallelLoopStatement::resetValidFreepointers( )
  129264             :    {
  129265           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  129266           5 :      SgOmpParallelLoopStatement* pointer = NULL;
  129267           5 :      std::vector < unsigned char* > :: const_iterator block;
  129268           5 :      SgOmpParallelLoopStatement* pointerOfLinkedList = NULL;
  129269           5 :      for ( block = SgOmpParallelLoopStatement::pools.begin(); block != SgOmpParallelLoopStatement::pools.end() ; ++block )
  129270             :         {
  129271           0 :           pointer = (SgOmpParallelLoopStatement*)(*block);
  129272           0 :           for (unsigned i = 0; i < SgOmpParallelLoopStatement::pool_size; ++i )
  129273             :              {
  129274             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  129275             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  129276             :             // memory blocks!.
  129277           0 :                if ( pointer[i].get_freepointer() != NULL )
  129278             :                   {
  129279           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  129280             :                   }
  129281             :                else
  129282             :                   {
  129283           0 :                     if ( pointerOfLinkedList == NULL )
  129284             :                        {
  129285           0 :                          SgOmpParallelLoopStatement::next_node = &(pointer[i]);
  129286             :                        }
  129287             :                     else
  129288             :                        {
  129289             :                       // printf ("In SgOmpParallelLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  129290           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  129291             :                        }
  129292             :                     pointerOfLinkedList = &(pointer[i]);
  129293             :                   }
  129294             :               }
  129295             :         }
  129296             : 
  129297           5 :      if ( pointerOfLinkedList != NULL )
  129298             :         {
  129299             :        // printf ("In SgOmpParallelLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  129300           0 :           pointerOfLinkedList->set_freepointer(NULL);
  129301             :        // DQ (6/6/2010): Temporary debugging...
  129302             :        //   ROSE_ASSERT(false);
  129303             :         }
  129304             : 
  129305           5 :      return ;
  129306             :    }
  129307             : 
  129308             : //############################################################################
  129309             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  129310             :  * within the memory pool and resets the freepointers, in order to achieve a 
  129311             :  * linked list, that has no jumps and starts at the beginning! This function 
  129312             :  * does not extend the memory pool, since we do not delete any memory blocks,
  129313             :  * but delete the valid objects.  
  129314             :  */
  129315             : void
  129316           0 : SgOmpParallelLoopStatement::clearMemoryPool( )
  129317             :    {
  129318             :   // printf ("Inside of SgOmpParallelLoopStatement::clearMemoryPool() \n");
  129319             : 
  129320           0 :      SgOmpParallelLoopStatement* pointer = NULL, *tempPointer = NULL;
  129321           0 :      std::vector < unsigned char* > :: const_iterator block;
  129322           0 :      if ( SgOmpParallelLoopStatement::pools.empty() == false )
  129323             :         {
  129324           0 :           block = SgOmpParallelLoopStatement::pools.begin() ;
  129325           0 :           SgOmpParallelLoopStatement::next_node = (SgOmpParallelLoopStatement*) (*block);
  129326             : 
  129327           0 :           while ( block != SgOmpParallelLoopStatement::pools.end() )
  129328             :              {
  129329           0 :                pointer = (SgOmpParallelLoopStatement*) (*block);
  129330           0 :                if ( tempPointer != NULL )
  129331             :                   {
  129332           0 :                     tempPointer->set_freepointer(pointer);
  129333             :                   }
  129334           0 :                for (unsigned i = 0; i < SgOmpParallelLoopStatement::pool_size - 1; ++i)
  129335             :                   {
  129336           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  129337             :                   }
  129338           0 :                 pointer[SgOmpParallelLoopStatement::pool_size-1].set_freepointer(NULL);
  129339           0 :                 tempPointer = &(pointer[SgOmpParallelLoopStatement::pool_size-1]);
  129340           0 :                 ++block;
  129341             :              }
  129342             :         }
  129343           0 :    }
  129344             : 
  129345           5 : void SgOmpParallelLoopStatement::deleteMemoryPool() {
  129346           5 :   for (auto p: SgOmpParallelLoopStatement::pools) {
  129347           0 :     ROSE_FREE(p);
  129348             :   }
  129349           5 :   SgOmpParallelLoopStatement::next_node = nullptr;
  129350           5 :   SgOmpParallelLoopStatement::pools.clear();
  129351           5 : }
  129352             : 
  129353             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  129354             : //                 reading multiple binary files to for a single AST.
  129355             : /////////// new version ////////////////////////////////
  129356             : //############################################################################
  129357             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  129358             : void
  129359           2 : SgOmpParallelLoopStatement::extendMemoryPoolForFileIO( )
  129360             :   {
  129361           2 :     size_t blockIndex = SgOmpParallelLoopStatement::pools.size();
  129362           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelLoopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelLoopStatement);
  129363             : 
  129364           2 :     while ( (blockIndex * SgOmpParallelLoopStatement::pool_size) < newPoolSize)
  129365             :       {
  129366             : #if ROSE_ALLOC_TRACE
  129367             :         if (blockIndex > 0) {
  129368             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelLoopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelLoopStatement) = %" PRIuPTR " SgOmpParallelLoopStatement::pool_size = %d \n",
  129369             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelLoopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelLoopStatement),SgOmpParallelLoopStatement::pool_size);
  129370             :         }
  129371             : #endif
  129372             : 
  129373           0 :         SgOmpParallelLoopStatement * pointer = (SgOmpParallelLoopStatement*) ROSE_MALLOC ( SgOmpParallelLoopStatement::pool_size * sizeof(SgOmpParallelLoopStatement) );
  129374           0 :         assert( pointer != NULL );
  129375             : #if ROSE_ALLOC_MEMSET == 1
  129376             :         memset(pointer, 0x00, SgOmpParallelLoopStatement::pool_size * sizeof(SgOmpParallelLoopStatement));
  129377             : #elif ROSE_ALLOC_MEMSET == 2
  129378             :         memset(pointer, 0xCC, SgOmpParallelLoopStatement::pool_size * sizeof(SgOmpParallelLoopStatement));
  129379             : #endif
  129380           0 :         SgOmpParallelLoopStatement::pools.push_back( (unsigned char*)(pointer) );
  129381           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpParallelLoopStatement::pool_size * sizeof(SgOmpParallelLoopStatement), V_SgOmpParallelLoopStatement ) );
  129382             : 
  129383           0 :         if ( SgOmpParallelLoopStatement::next_node != NULL ) {
  129384           0 :           if ( blockIndex > 0 ) {
  129385           0 :             SgOmpParallelLoopStatement * blkptr = (SgOmpParallelLoopStatement*)(SgOmpParallelLoopStatement::pools[blockIndex-1]);
  129386           0 :             blkptr[ SgOmpParallelLoopStatement::pool_size - 1 ].set_freepointer(pointer);
  129387             :           }
  129388             :         } else {
  129389           0 :           SgOmpParallelLoopStatement::next_node = pointer;
  129390             :         }
  129391             : 
  129392           0 :         for (unsigned i = 0; i < SgOmpParallelLoopStatement::pool_size-1; ++i)
  129393             :            {
  129394           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  129395             :            }
  129396           0 :         pointer[ SgOmpParallelLoopStatement::pool_size -1 ].set_freepointer(NULL);
  129397             : 
  129398           0 :         blockIndex++;
  129399             :       }
  129400           2 :   }
  129401             : 
  129402             : //############################################################################
  129403             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  129404             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  129405             :  * not compressed. However, that stuff is not yet implemented! 
  129406             :  */
  129407             : unsigned long
  129408           0 : SgOmpParallelLoopStatement::getNumberOfLastValidPointer()
  129409             :    {
  129410           0 :       SgOmpParallelLoopStatement* testPointer = (SgOmpParallelLoopStatement*)(SgOmpParallelLoopStatement::pools.back());
  129411           0 :       unsigned long localIndex = SgOmpParallelLoopStatement::pool_size - 1;
  129412           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  129413             :          {
  129414           0 :            localIndex--;
  129415             :          }
  129416           0 :       return (localIndex + SgOmpParallelLoopStatement::pool_size * (SgOmpParallelLoopStatement::pools.size()-1));
  129417             :    }
  129418             : 
  129419             : //############################################################################
  129420             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  129421             :  * memory pool and initializes the data member in class SgOmpParallelLoopStatementStroageClass
  129422             :  * from its counterpart of SgOmpParallelLoopStatement. The return value is just for checking, 
  129423             :  * that the whole StorageClassArray is initialized!
  129424             :  */
  129425             : unsigned long
  129426           0 : SgOmpParallelLoopStatement::initializeStorageClassArray( SgOmpParallelLoopStatementStorageClass *storageArray )
  129427             :    {
  129428           0 :      unsigned long storageCounter = 0;
  129429           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpParallelLoopStatement::pools.begin();
  129430           0 :      SgOmpParallelLoopStatement* pointer = NULL;
  129431           0 :      while ( block != SgOmpParallelLoopStatement::pools.end() ) {
  129432           0 :           pointer = (SgOmpParallelLoopStatement*) (*block);
  129433           0 :           for ( unsigned i = 0; i < SgOmpParallelLoopStatement::pool_size; ++i ) {
  129434           0 :                if ( pointer->get_freepointer() != NULL ) {
  129435           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  129436           0 :                  storageArray++;
  129437           0 :                  storageCounter++;
  129438             :                }
  129439           0 :                pointer++;
  129440             :              }
  129441           0 :            block++;
  129442             :         }
  129443           0 :      return storageCounter;
  129444             :    }
  129445             : 
  129446             : /* #line 129447 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  129447             : 
  129448             : 
  129449             : 
  129450             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  129451             : 
  129452             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  129453             : 
  129454             : //############################################################################
  129455             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetParallelStatement that takes its 
  129456             :  * corresponding StorageClass as parameter
  129457             :  */
  129458           0 : SgOmpTargetParallelStatement :: SgOmpTargetParallelStatement ( const SgOmpTargetParallelStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  129459             :    {
  129460             : 
  129461             : 
  129462             : /* #line 129463 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  129463             : 
  129464           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  129465             : 
  129466             : 
  129467             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  129468             : 
  129469             : 
  129470           0 :    }
  129471             : 
  129472             : //############################################################################
  129473             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  129474             :  * within the working AST. 
  129475             :  */
  129476           0 : SgOmpTargetParallelStatement * SgOmpTargetParallelStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  129477           0 :      SgOmpTargetParallelStatement* returnPointer = NULL;
  129478           0 :      if ( globalIndex != 0 )
  129479             :         {
  129480             : 
  129481             : #if FILE_IO_EXTRA_CHECK
  129482           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetParallelStatement ) ) <= globalIndex ) ;
  129483           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetParallelStatement + 1 ) ) );
  129484             : #endif
  129485           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetParallelStatement )  
  129486           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetParallelStatement );
  129487           0 :           unsigned long positionInPool = localIndex % SgOmpTargetParallelStatement::pool_size;
  129488           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetParallelStatement::pool_size;
  129489             : 
  129490             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  129491             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  129492             : 
  129493           0 :           returnPointer = &( ( (SgOmpTargetParallelStatement*)(SgOmpTargetParallelStatement::pools[memoryBlock]) ) [positionInPool]) ;
  129494             : 
  129495           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  129496             :         }
  129497           0 :      return returnPointer ;
  129498             :    }
  129499             : 
  129500             : //############################################################################
  129501             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  129502             :   for the AST with the index astIndex
  129503             : */
  129504           0 : SgOmpTargetParallelStatement * SgOmpTargetParallelStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  129505           0 :      SgOmpTargetParallelStatement* returnPointer = NULL;
  129506           0 :      if ( globalIndex != 0 )
  129507             :         {
  129508             : 
  129509             : #if FILE_IO_EXTRA_CHECK
  129510           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetParallelStatement ) ) <= globalIndex ) ;
  129511           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetParallelStatement + 1 ) ) );
  129512             : #endif
  129513           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetParallelStatement )
  129514           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetParallelStatement );
  129515           0 :           unsigned long positionInPool = localIndex % SgOmpTargetParallelStatement::pool_size ;
  129516           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetParallelStatement::pool_size ;
  129517             : 
  129518             : #if FILE_IO_EXTRA_CHECK
  129519             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  129520             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  129521             : #endif
  129522             : 
  129523           0 :           returnPointer = &( ( (SgOmpTargetParallelStatement*)(SgOmpTargetParallelStatement::pools[memoryBlock]) ) [positionInPool]) ;
  129524             : 
  129525             : #if FILE_IO_EXTRA_CHECK
  129526           0 :           assert ( returnPointer != NULL ) ;
  129527             : #endif
  129528             :         }
  129529           0 :      return returnPointer ;
  129530             :    }
  129531             : 
  129532             : //############################################################################
  129533             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  129534             :  * pool size! We set for every valid object in the memory pool the freepointer
  129535             :  * to the global index and increase the global index afterwards. For all the 
  129536             :  * invalid objects (means address ranges within the memory pool that were not
  129537             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  129538             :  * distinguish valid from invalid objects! 
  129539             :  */
  129540             : unsigned long
  129541           5 : SgOmpTargetParallelStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  129542             :    {
  129543           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  129544           5 :      SgOmpTargetParallelStatement* pointer = NULL;
  129545           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  129546           5 :      std::vector < unsigned char* > :: const_iterator block;
  129547           5 :      for ( block = SgOmpTargetParallelStatement::pools.begin(); block != SgOmpTargetParallelStatement::pools.end() ; ++block )
  129548             :         {
  129549           0 :           pointer = (SgOmpTargetParallelStatement*)(*block);
  129550           0 :           for (unsigned i = 0; i < SgOmpTargetParallelStatement::pool_size; ++i )
  129551             :              {
  129552             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  129553             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  129554             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  129555             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  129556             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  129557             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  129558             :             // properly; so this will have to be checked next.
  129559             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  129560             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  129561           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  129562             :                   {
  129563           0 :                     pointer[i].set_freepointer((SgOmpTargetParallelStatement*)(globalIndex));
  129564           0 :                     globalIndex++;
  129565             :                   }
  129566             :                else
  129567             :                   {
  129568           0 :                     pointer[i].set_freepointer(NULL);
  129569             :                   }
  129570             :               }
  129571             :         }
  129572           5 :      return globalIndex;
  129573             :    }
  129574             : 
  129575             : //############################################################################
  129576             : // JH (01/14/2006)
  129577             : void
  129578           5 : SgOmpTargetParallelStatement::resetValidFreepointers( )
  129579             :    {
  129580           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  129581           5 :      SgOmpTargetParallelStatement* pointer = NULL;
  129582           5 :      std::vector < unsigned char* > :: const_iterator block;
  129583           5 :      SgOmpTargetParallelStatement* pointerOfLinkedList = NULL;
  129584           5 :      for ( block = SgOmpTargetParallelStatement::pools.begin(); block != SgOmpTargetParallelStatement::pools.end() ; ++block )
  129585             :         {
  129586           0 :           pointer = (SgOmpTargetParallelStatement*)(*block);
  129587           0 :           for (unsigned i = 0; i < SgOmpTargetParallelStatement::pool_size; ++i )
  129588             :              {
  129589             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  129590             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  129591             :             // memory blocks!.
  129592           0 :                if ( pointer[i].get_freepointer() != NULL )
  129593             :                   {
  129594           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  129595             :                   }
  129596             :                else
  129597             :                   {
  129598           0 :                     if ( pointerOfLinkedList == NULL )
  129599             :                        {
  129600           0 :                          SgOmpTargetParallelStatement::next_node = &(pointer[i]);
  129601             :                        }
  129602             :                     else
  129603             :                        {
  129604             :                       // printf ("In SgOmpTargetParallelStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  129605           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  129606             :                        }
  129607             :                     pointerOfLinkedList = &(pointer[i]);
  129608             :                   }
  129609             :               }
  129610             :         }
  129611             : 
  129612           5 :      if ( pointerOfLinkedList != NULL )
  129613             :         {
  129614             :        // printf ("In SgOmpTargetParallelStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  129615           0 :           pointerOfLinkedList->set_freepointer(NULL);
  129616             :        // DQ (6/6/2010): Temporary debugging...
  129617             :        //   ROSE_ASSERT(false);
  129618             :         }
  129619             : 
  129620           5 :      return ;
  129621             :    }
  129622             : 
  129623             : //############################################################################
  129624             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  129625             :  * within the memory pool and resets the freepointers, in order to achieve a 
  129626             :  * linked list, that has no jumps and starts at the beginning! This function 
  129627             :  * does not extend the memory pool, since we do not delete any memory blocks,
  129628             :  * but delete the valid objects.  
  129629             :  */
  129630             : void
  129631           0 : SgOmpTargetParallelStatement::clearMemoryPool( )
  129632             :    {
  129633             :   // printf ("Inside of SgOmpTargetParallelStatement::clearMemoryPool() \n");
  129634             : 
  129635           0 :      SgOmpTargetParallelStatement* pointer = NULL, *tempPointer = NULL;
  129636           0 :      std::vector < unsigned char* > :: const_iterator block;
  129637           0 :      if ( SgOmpTargetParallelStatement::pools.empty() == false )
  129638             :         {
  129639           0 :           block = SgOmpTargetParallelStatement::pools.begin() ;
  129640           0 :           SgOmpTargetParallelStatement::next_node = (SgOmpTargetParallelStatement*) (*block);
  129641             : 
  129642           0 :           while ( block != SgOmpTargetParallelStatement::pools.end() )
  129643             :              {
  129644           0 :                pointer = (SgOmpTargetParallelStatement*) (*block);
  129645           0 :                if ( tempPointer != NULL )
  129646             :                   {
  129647           0 :                     tempPointer->set_freepointer(pointer);
  129648             :                   }
  129649           0 :                for (unsigned i = 0; i < SgOmpTargetParallelStatement::pool_size - 1; ++i)
  129650             :                   {
  129651           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  129652             :                   }
  129653           0 :                 pointer[SgOmpTargetParallelStatement::pool_size-1].set_freepointer(NULL);
  129654           0 :                 tempPointer = &(pointer[SgOmpTargetParallelStatement::pool_size-1]);
  129655           0 :                 ++block;
  129656             :              }
  129657             :         }
  129658           0 :    }
  129659             : 
  129660           5 : void SgOmpTargetParallelStatement::deleteMemoryPool() {
  129661           5 :   for (auto p: SgOmpTargetParallelStatement::pools) {
  129662           0 :     ROSE_FREE(p);
  129663             :   }
  129664           5 :   SgOmpTargetParallelStatement::next_node = nullptr;
  129665           5 :   SgOmpTargetParallelStatement::pools.clear();
  129666           5 : }
  129667             : 
  129668             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  129669             : //                 reading multiple binary files to for a single AST.
  129670             : /////////// new version ////////////////////////////////
  129671             : //############################################################################
  129672             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  129673             : void
  129674           2 : SgOmpTargetParallelStatement::extendMemoryPoolForFileIO( )
  129675             :   {
  129676           2 :     size_t blockIndex = SgOmpTargetParallelStatement::pools.size();
  129677           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelStatement);
  129678             : 
  129679           2 :     while ( (blockIndex * SgOmpTargetParallelStatement::pool_size) < newPoolSize)
  129680             :       {
  129681             : #if ROSE_ALLOC_TRACE
  129682             :         if (blockIndex > 0) {
  129683             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelStatement) = %" PRIuPTR " SgOmpTargetParallelStatement::pool_size = %d \n",
  129684             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelStatement),SgOmpTargetParallelStatement::pool_size);
  129685             :         }
  129686             : #endif
  129687             : 
  129688           0 :         SgOmpTargetParallelStatement * pointer = (SgOmpTargetParallelStatement*) ROSE_MALLOC ( SgOmpTargetParallelStatement::pool_size * sizeof(SgOmpTargetParallelStatement) );
  129689           0 :         assert( pointer != NULL );
  129690             : #if ROSE_ALLOC_MEMSET == 1
  129691             :         memset(pointer, 0x00, SgOmpTargetParallelStatement::pool_size * sizeof(SgOmpTargetParallelStatement));
  129692             : #elif ROSE_ALLOC_MEMSET == 2
  129693             :         memset(pointer, 0xCC, SgOmpTargetParallelStatement::pool_size * sizeof(SgOmpTargetParallelStatement));
  129694             : #endif
  129695           0 :         SgOmpTargetParallelStatement::pools.push_back( (unsigned char*)(pointer) );
  129696           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetParallelStatement::pool_size * sizeof(SgOmpTargetParallelStatement), V_SgOmpTargetParallelStatement ) );
  129697             : 
  129698           0 :         if ( SgOmpTargetParallelStatement::next_node != NULL ) {
  129699           0 :           if ( blockIndex > 0 ) {
  129700           0 :             SgOmpTargetParallelStatement * blkptr = (SgOmpTargetParallelStatement*)(SgOmpTargetParallelStatement::pools[blockIndex-1]);
  129701           0 :             blkptr[ SgOmpTargetParallelStatement::pool_size - 1 ].set_freepointer(pointer);
  129702             :           }
  129703             :         } else {
  129704           0 :           SgOmpTargetParallelStatement::next_node = pointer;
  129705             :         }
  129706             : 
  129707           0 :         for (unsigned i = 0; i < SgOmpTargetParallelStatement::pool_size-1; ++i)
  129708             :            {
  129709           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  129710             :            }
  129711           0 :         pointer[ SgOmpTargetParallelStatement::pool_size -1 ].set_freepointer(NULL);
  129712             : 
  129713           0 :         blockIndex++;
  129714             :       }
  129715           2 :   }
  129716             : 
  129717             : //############################################################################
  129718             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  129719             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  129720             :  * not compressed. However, that stuff is not yet implemented! 
  129721             :  */
  129722             : unsigned long
  129723           0 : SgOmpTargetParallelStatement::getNumberOfLastValidPointer()
  129724             :    {
  129725           0 :       SgOmpTargetParallelStatement* testPointer = (SgOmpTargetParallelStatement*)(SgOmpTargetParallelStatement::pools.back());
  129726           0 :       unsigned long localIndex = SgOmpTargetParallelStatement::pool_size - 1;
  129727           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  129728             :          {
  129729           0 :            localIndex--;
  129730             :          }
  129731           0 :       return (localIndex + SgOmpTargetParallelStatement::pool_size * (SgOmpTargetParallelStatement::pools.size()-1));
  129732             :    }
  129733             : 
  129734             : //############################################################################
  129735             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  129736             :  * memory pool and initializes the data member in class SgOmpTargetParallelStatementStroageClass
  129737             :  * from its counterpart of SgOmpTargetParallelStatement. The return value is just for checking, 
  129738             :  * that the whole StorageClassArray is initialized!
  129739             :  */
  129740             : unsigned long
  129741           0 : SgOmpTargetParallelStatement::initializeStorageClassArray( SgOmpTargetParallelStatementStorageClass *storageArray )
  129742             :    {
  129743           0 :      unsigned long storageCounter = 0;
  129744           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetParallelStatement::pools.begin();
  129745           0 :      SgOmpTargetParallelStatement* pointer = NULL;
  129746           0 :      while ( block != SgOmpTargetParallelStatement::pools.end() ) {
  129747           0 :           pointer = (SgOmpTargetParallelStatement*) (*block);
  129748           0 :           for ( unsigned i = 0; i < SgOmpTargetParallelStatement::pool_size; ++i ) {
  129749           0 :                if ( pointer->get_freepointer() != NULL ) {
  129750           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  129751           0 :                  storageArray++;
  129752           0 :                  storageCounter++;
  129753             :                }
  129754           0 :                pointer++;
  129755             :              }
  129756           0 :            block++;
  129757             :         }
  129758           0 :      return storageCounter;
  129759             :    }
  129760             : 
  129761             : /* #line 129762 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  129762             : 
  129763             : 
  129764             : 
  129765             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  129766             : 
  129767             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  129768             : 
  129769             : //############################################################################
  129770             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetParallelForSimdStatement that takes its 
  129771             :  * corresponding StorageClass as parameter
  129772             :  */
  129773           0 : SgOmpTargetParallelForSimdStatement :: SgOmpTargetParallelForSimdStatement ( const SgOmpTargetParallelForSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  129774             :    {
  129775             : 
  129776             : 
  129777             : /* #line 129778 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  129778             : 
  129779           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  129780             : 
  129781             : 
  129782             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  129783             : 
  129784             : 
  129785           0 :    }
  129786             : 
  129787             : //############################################################################
  129788             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  129789             :  * within the working AST. 
  129790             :  */
  129791           0 : SgOmpTargetParallelForSimdStatement * SgOmpTargetParallelForSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  129792           0 :      SgOmpTargetParallelForSimdStatement* returnPointer = NULL;
  129793           0 :      if ( globalIndex != 0 )
  129794             :         {
  129795             : 
  129796             : #if FILE_IO_EXTRA_CHECK
  129797           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetParallelForSimdStatement ) ) <= globalIndex ) ;
  129798           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetParallelForSimdStatement + 1 ) ) );
  129799             : #endif
  129800           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetParallelForSimdStatement )  
  129801           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetParallelForSimdStatement );
  129802           0 :           unsigned long positionInPool = localIndex % SgOmpTargetParallelForSimdStatement::pool_size;
  129803           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetParallelForSimdStatement::pool_size;
  129804             : 
  129805             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  129806             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  129807             : 
  129808           0 :           returnPointer = &( ( (SgOmpTargetParallelForSimdStatement*)(SgOmpTargetParallelForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  129809             : 
  129810           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  129811             :         }
  129812           0 :      return returnPointer ;
  129813             :    }
  129814             : 
  129815             : //############################################################################
  129816             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  129817             :   for the AST with the index astIndex
  129818             : */
  129819           0 : SgOmpTargetParallelForSimdStatement * SgOmpTargetParallelForSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  129820           0 :      SgOmpTargetParallelForSimdStatement* returnPointer = NULL;
  129821           0 :      if ( globalIndex != 0 )
  129822             :         {
  129823             : 
  129824             : #if FILE_IO_EXTRA_CHECK
  129825           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetParallelForSimdStatement ) ) <= globalIndex ) ;
  129826           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetParallelForSimdStatement + 1 ) ) );
  129827             : #endif
  129828           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetParallelForSimdStatement )
  129829           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetParallelForSimdStatement );
  129830           0 :           unsigned long positionInPool = localIndex % SgOmpTargetParallelForSimdStatement::pool_size ;
  129831           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetParallelForSimdStatement::pool_size ;
  129832             : 
  129833             : #if FILE_IO_EXTRA_CHECK
  129834             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  129835             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  129836             : #endif
  129837             : 
  129838           0 :           returnPointer = &( ( (SgOmpTargetParallelForSimdStatement*)(SgOmpTargetParallelForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  129839             : 
  129840             : #if FILE_IO_EXTRA_CHECK
  129841           0 :           assert ( returnPointer != NULL ) ;
  129842             : #endif
  129843             :         }
  129844           0 :      return returnPointer ;
  129845             :    }
  129846             : 
  129847             : //############################################################################
  129848             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  129849             :  * pool size! We set for every valid object in the memory pool the freepointer
  129850             :  * to the global index and increase the global index afterwards. For all the 
  129851             :  * invalid objects (means address ranges within the memory pool that were not
  129852             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  129853             :  * distinguish valid from invalid objects! 
  129854             :  */
  129855             : unsigned long
  129856           5 : SgOmpTargetParallelForSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  129857             :    {
  129858           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  129859           5 :      SgOmpTargetParallelForSimdStatement* pointer = NULL;
  129860           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  129861           5 :      std::vector < unsigned char* > :: const_iterator block;
  129862           5 :      for ( block = SgOmpTargetParallelForSimdStatement::pools.begin(); block != SgOmpTargetParallelForSimdStatement::pools.end() ; ++block )
  129863             :         {
  129864           0 :           pointer = (SgOmpTargetParallelForSimdStatement*)(*block);
  129865           0 :           for (unsigned i = 0; i < SgOmpTargetParallelForSimdStatement::pool_size; ++i )
  129866             :              {
  129867             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  129868             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  129869             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  129870             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  129871             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  129872             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  129873             :             // properly; so this will have to be checked next.
  129874             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  129875             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  129876           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  129877             :                   {
  129878           0 :                     pointer[i].set_freepointer((SgOmpTargetParallelForSimdStatement*)(globalIndex));
  129879           0 :                     globalIndex++;
  129880             :                   }
  129881             :                else
  129882             :                   {
  129883           0 :                     pointer[i].set_freepointer(NULL);
  129884             :                   }
  129885             :               }
  129886             :         }
  129887           5 :      return globalIndex;
  129888             :    }
  129889             : 
  129890             : //############################################################################
  129891             : // JH (01/14/2006)
  129892             : void
  129893           5 : SgOmpTargetParallelForSimdStatement::resetValidFreepointers( )
  129894             :    {
  129895           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  129896           5 :      SgOmpTargetParallelForSimdStatement* pointer = NULL;
  129897           5 :      std::vector < unsigned char* > :: const_iterator block;
  129898           5 :      SgOmpTargetParallelForSimdStatement* pointerOfLinkedList = NULL;
  129899           5 :      for ( block = SgOmpTargetParallelForSimdStatement::pools.begin(); block != SgOmpTargetParallelForSimdStatement::pools.end() ; ++block )
  129900             :         {
  129901           0 :           pointer = (SgOmpTargetParallelForSimdStatement*)(*block);
  129902           0 :           for (unsigned i = 0; i < SgOmpTargetParallelForSimdStatement::pool_size; ++i )
  129903             :              {
  129904             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  129905             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  129906             :             // memory blocks!.
  129907           0 :                if ( pointer[i].get_freepointer() != NULL )
  129908             :                   {
  129909           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  129910             :                   }
  129911             :                else
  129912             :                   {
  129913           0 :                     if ( pointerOfLinkedList == NULL )
  129914             :                        {
  129915           0 :                          SgOmpTargetParallelForSimdStatement::next_node = &(pointer[i]);
  129916             :                        }
  129917             :                     else
  129918             :                        {
  129919             :                       // printf ("In SgOmpTargetParallelForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  129920           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  129921             :                        }
  129922             :                     pointerOfLinkedList = &(pointer[i]);
  129923             :                   }
  129924             :               }
  129925             :         }
  129926             : 
  129927           5 :      if ( pointerOfLinkedList != NULL )
  129928             :         {
  129929             :        // printf ("In SgOmpTargetParallelForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  129930           0 :           pointerOfLinkedList->set_freepointer(NULL);
  129931             :        // DQ (6/6/2010): Temporary debugging...
  129932             :        //   ROSE_ASSERT(false);
  129933             :         }
  129934             : 
  129935           5 :      return ;
  129936             :    }
  129937             : 
  129938             : //############################################################################
  129939             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  129940             :  * within the memory pool and resets the freepointers, in order to achieve a 
  129941             :  * linked list, that has no jumps and starts at the beginning! This function 
  129942             :  * does not extend the memory pool, since we do not delete any memory blocks,
  129943             :  * but delete the valid objects.  
  129944             :  */
  129945             : void
  129946           0 : SgOmpTargetParallelForSimdStatement::clearMemoryPool( )
  129947             :    {
  129948             :   // printf ("Inside of SgOmpTargetParallelForSimdStatement::clearMemoryPool() \n");
  129949             : 
  129950           0 :      SgOmpTargetParallelForSimdStatement* pointer = NULL, *tempPointer = NULL;
  129951           0 :      std::vector < unsigned char* > :: const_iterator block;
  129952           0 :      if ( SgOmpTargetParallelForSimdStatement::pools.empty() == false )
  129953             :         {
  129954           0 :           block = SgOmpTargetParallelForSimdStatement::pools.begin() ;
  129955           0 :           SgOmpTargetParallelForSimdStatement::next_node = (SgOmpTargetParallelForSimdStatement*) (*block);
  129956             : 
  129957           0 :           while ( block != SgOmpTargetParallelForSimdStatement::pools.end() )
  129958             :              {
  129959           0 :                pointer = (SgOmpTargetParallelForSimdStatement*) (*block);
  129960           0 :                if ( tempPointer != NULL )
  129961             :                   {
  129962           0 :                     tempPointer->set_freepointer(pointer);
  129963             :                   }
  129964           0 :                for (unsigned i = 0; i < SgOmpTargetParallelForSimdStatement::pool_size - 1; ++i)
  129965             :                   {
  129966           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  129967             :                   }
  129968           0 :                 pointer[SgOmpTargetParallelForSimdStatement::pool_size-1].set_freepointer(NULL);
  129969           0 :                 tempPointer = &(pointer[SgOmpTargetParallelForSimdStatement::pool_size-1]);
  129970           0 :                 ++block;
  129971             :              }
  129972             :         }
  129973           0 :    }
  129974             : 
  129975           5 : void SgOmpTargetParallelForSimdStatement::deleteMemoryPool() {
  129976           5 :   for (auto p: SgOmpTargetParallelForSimdStatement::pools) {
  129977           0 :     ROSE_FREE(p);
  129978             :   }
  129979           5 :   SgOmpTargetParallelForSimdStatement::next_node = nullptr;
  129980           5 :   SgOmpTargetParallelForSimdStatement::pools.clear();
  129981           5 : }
  129982             : 
  129983             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  129984             : //                 reading multiple binary files to for a single AST.
  129985             : /////////// new version ////////////////////////////////
  129986             : //############################################################################
  129987             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  129988             : void
  129989           2 : SgOmpTargetParallelForSimdStatement::extendMemoryPoolForFileIO( )
  129990             :   {
  129991           2 :     size_t blockIndex = SgOmpTargetParallelForSimdStatement::pools.size();
  129992           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelForSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelForSimdStatement);
  129993             : 
  129994           2 :     while ( (blockIndex * SgOmpTargetParallelForSimdStatement::pool_size) < newPoolSize)
  129995             :       {
  129996             : #if ROSE_ALLOC_TRACE
  129997             :         if (blockIndex > 0) {
  129998             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelForSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelForSimdStatement) = %" PRIuPTR " SgOmpTargetParallelForSimdStatement::pool_size = %d \n",
  129999             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelForSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelForSimdStatement),SgOmpTargetParallelForSimdStatement::pool_size);
  130000             :         }
  130001             : #endif
  130002             : 
  130003           0 :         SgOmpTargetParallelForSimdStatement * pointer = (SgOmpTargetParallelForSimdStatement*) ROSE_MALLOC ( SgOmpTargetParallelForSimdStatement::pool_size * sizeof(SgOmpTargetParallelForSimdStatement) );
  130004           0 :         assert( pointer != NULL );
  130005             : #if ROSE_ALLOC_MEMSET == 1
  130006             :         memset(pointer, 0x00, SgOmpTargetParallelForSimdStatement::pool_size * sizeof(SgOmpTargetParallelForSimdStatement));
  130007             : #elif ROSE_ALLOC_MEMSET == 2
  130008             :         memset(pointer, 0xCC, SgOmpTargetParallelForSimdStatement::pool_size * sizeof(SgOmpTargetParallelForSimdStatement));
  130009             : #endif
  130010           0 :         SgOmpTargetParallelForSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  130011           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetParallelForSimdStatement::pool_size * sizeof(SgOmpTargetParallelForSimdStatement), V_SgOmpTargetParallelForSimdStatement ) );
  130012             : 
  130013           0 :         if ( SgOmpTargetParallelForSimdStatement::next_node != NULL ) {
  130014           0 :           if ( blockIndex > 0 ) {
  130015           0 :             SgOmpTargetParallelForSimdStatement * blkptr = (SgOmpTargetParallelForSimdStatement*)(SgOmpTargetParallelForSimdStatement::pools[blockIndex-1]);
  130016           0 :             blkptr[ SgOmpTargetParallelForSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  130017             :           }
  130018             :         } else {
  130019           0 :           SgOmpTargetParallelForSimdStatement::next_node = pointer;
  130020             :         }
  130021             : 
  130022           0 :         for (unsigned i = 0; i < SgOmpTargetParallelForSimdStatement::pool_size-1; ++i)
  130023             :            {
  130024           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  130025             :            }
  130026           0 :         pointer[ SgOmpTargetParallelForSimdStatement::pool_size -1 ].set_freepointer(NULL);
  130027             : 
  130028           0 :         blockIndex++;
  130029             :       }
  130030           2 :   }
  130031             : 
  130032             : //############################################################################
  130033             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  130034             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  130035             :  * not compressed. However, that stuff is not yet implemented! 
  130036             :  */
  130037             : unsigned long
  130038           0 : SgOmpTargetParallelForSimdStatement::getNumberOfLastValidPointer()
  130039             :    {
  130040           0 :       SgOmpTargetParallelForSimdStatement* testPointer = (SgOmpTargetParallelForSimdStatement*)(SgOmpTargetParallelForSimdStatement::pools.back());
  130041           0 :       unsigned long localIndex = SgOmpTargetParallelForSimdStatement::pool_size - 1;
  130042           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  130043             :          {
  130044           0 :            localIndex--;
  130045             :          }
  130046           0 :       return (localIndex + SgOmpTargetParallelForSimdStatement::pool_size * (SgOmpTargetParallelForSimdStatement::pools.size()-1));
  130047             :    }
  130048             : 
  130049             : //############################################################################
  130050             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  130051             :  * memory pool and initializes the data member in class SgOmpTargetParallelForSimdStatementStroageClass
  130052             :  * from its counterpart of SgOmpTargetParallelForSimdStatement. The return value is just for checking, 
  130053             :  * that the whole StorageClassArray is initialized!
  130054             :  */
  130055             : unsigned long
  130056           0 : SgOmpTargetParallelForSimdStatement::initializeStorageClassArray( SgOmpTargetParallelForSimdStatementStorageClass *storageArray )
  130057             :    {
  130058           0 :      unsigned long storageCounter = 0;
  130059           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetParallelForSimdStatement::pools.begin();
  130060           0 :      SgOmpTargetParallelForSimdStatement* pointer = NULL;
  130061           0 :      while ( block != SgOmpTargetParallelForSimdStatement::pools.end() ) {
  130062           0 :           pointer = (SgOmpTargetParallelForSimdStatement*) (*block);
  130063           0 :           for ( unsigned i = 0; i < SgOmpTargetParallelForSimdStatement::pool_size; ++i ) {
  130064           0 :                if ( pointer->get_freepointer() != NULL ) {
  130065           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  130066           0 :                  storageArray++;
  130067           0 :                  storageCounter++;
  130068             :                }
  130069           0 :                pointer++;
  130070             :              }
  130071           0 :            block++;
  130072             :         }
  130073           0 :      return storageCounter;
  130074             :    }
  130075             : 
  130076             : /* #line 130077 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  130077             : 
  130078             : 
  130079             : 
  130080             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  130081             : 
  130082             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  130083             : 
  130084             : //############################################################################
  130085             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetParallelLoopStatement that takes its 
  130086             :  * corresponding StorageClass as parameter
  130087             :  */
  130088           0 : SgOmpTargetParallelLoopStatement :: SgOmpTargetParallelLoopStatement ( const SgOmpTargetParallelLoopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  130089             :    {
  130090             : 
  130091             : 
  130092             : /* #line 130093 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  130093             : 
  130094           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  130095             : 
  130096             : 
  130097             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  130098             : 
  130099             : 
  130100           0 :    }
  130101             : 
  130102             : //############################################################################
  130103             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  130104             :  * within the working AST. 
  130105             :  */
  130106           0 : SgOmpTargetParallelLoopStatement * SgOmpTargetParallelLoopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  130107           0 :      SgOmpTargetParallelLoopStatement* returnPointer = NULL;
  130108           0 :      if ( globalIndex != 0 )
  130109             :         {
  130110             : 
  130111             : #if FILE_IO_EXTRA_CHECK
  130112           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetParallelLoopStatement ) ) <= globalIndex ) ;
  130113           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetParallelLoopStatement + 1 ) ) );
  130114             : #endif
  130115           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetParallelLoopStatement )  
  130116           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetParallelLoopStatement );
  130117           0 :           unsigned long positionInPool = localIndex % SgOmpTargetParallelLoopStatement::pool_size;
  130118           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetParallelLoopStatement::pool_size;
  130119             : 
  130120             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  130121             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  130122             : 
  130123           0 :           returnPointer = &( ( (SgOmpTargetParallelLoopStatement*)(SgOmpTargetParallelLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  130124             : 
  130125           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  130126             :         }
  130127           0 :      return returnPointer ;
  130128             :    }
  130129             : 
  130130             : //############################################################################
  130131             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  130132             :   for the AST with the index astIndex
  130133             : */
  130134           0 : SgOmpTargetParallelLoopStatement * SgOmpTargetParallelLoopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  130135           0 :      SgOmpTargetParallelLoopStatement* returnPointer = NULL;
  130136           0 :      if ( globalIndex != 0 )
  130137             :         {
  130138             : 
  130139             : #if FILE_IO_EXTRA_CHECK
  130140           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetParallelLoopStatement ) ) <= globalIndex ) ;
  130141           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetParallelLoopStatement + 1 ) ) );
  130142             : #endif
  130143           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetParallelLoopStatement )
  130144           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetParallelLoopStatement );
  130145           0 :           unsigned long positionInPool = localIndex % SgOmpTargetParallelLoopStatement::pool_size ;
  130146           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetParallelLoopStatement::pool_size ;
  130147             : 
  130148             : #if FILE_IO_EXTRA_CHECK
  130149             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  130150             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  130151             : #endif
  130152             : 
  130153           0 :           returnPointer = &( ( (SgOmpTargetParallelLoopStatement*)(SgOmpTargetParallelLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  130154             : 
  130155             : #if FILE_IO_EXTRA_CHECK
  130156           0 :           assert ( returnPointer != NULL ) ;
  130157             : #endif
  130158             :         }
  130159           0 :      return returnPointer ;
  130160             :    }
  130161             : 
  130162             : //############################################################################
  130163             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  130164             :  * pool size! We set for every valid object in the memory pool the freepointer
  130165             :  * to the global index and increase the global index afterwards. For all the 
  130166             :  * invalid objects (means address ranges within the memory pool that were not
  130167             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  130168             :  * distinguish valid from invalid objects! 
  130169             :  */
  130170             : unsigned long
  130171           5 : SgOmpTargetParallelLoopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  130172             :    {
  130173           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  130174           5 :      SgOmpTargetParallelLoopStatement* pointer = NULL;
  130175           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  130176           5 :      std::vector < unsigned char* > :: const_iterator block;
  130177           5 :      for ( block = SgOmpTargetParallelLoopStatement::pools.begin(); block != SgOmpTargetParallelLoopStatement::pools.end() ; ++block )
  130178             :         {
  130179           0 :           pointer = (SgOmpTargetParallelLoopStatement*)(*block);
  130180           0 :           for (unsigned i = 0; i < SgOmpTargetParallelLoopStatement::pool_size; ++i )
  130181             :              {
  130182             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  130183             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  130184             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  130185             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  130186             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  130187             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  130188             :             // properly; so this will have to be checked next.
  130189             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  130190             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  130191           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  130192             :                   {
  130193           0 :                     pointer[i].set_freepointer((SgOmpTargetParallelLoopStatement*)(globalIndex));
  130194           0 :                     globalIndex++;
  130195             :                   }
  130196             :                else
  130197             :                   {
  130198           0 :                     pointer[i].set_freepointer(NULL);
  130199             :                   }
  130200             :               }
  130201             :         }
  130202           5 :      return globalIndex;
  130203             :    }
  130204             : 
  130205             : //############################################################################
  130206             : // JH (01/14/2006)
  130207             : void
  130208           5 : SgOmpTargetParallelLoopStatement::resetValidFreepointers( )
  130209             :    {
  130210           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  130211           5 :      SgOmpTargetParallelLoopStatement* pointer = NULL;
  130212           5 :      std::vector < unsigned char* > :: const_iterator block;
  130213           5 :      SgOmpTargetParallelLoopStatement* pointerOfLinkedList = NULL;
  130214           5 :      for ( block = SgOmpTargetParallelLoopStatement::pools.begin(); block != SgOmpTargetParallelLoopStatement::pools.end() ; ++block )
  130215             :         {
  130216           0 :           pointer = (SgOmpTargetParallelLoopStatement*)(*block);
  130217           0 :           for (unsigned i = 0; i < SgOmpTargetParallelLoopStatement::pool_size; ++i )
  130218             :              {
  130219             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  130220             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  130221             :             // memory blocks!.
  130222           0 :                if ( pointer[i].get_freepointer() != NULL )
  130223             :                   {
  130224           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  130225             :                   }
  130226             :                else
  130227             :                   {
  130228           0 :                     if ( pointerOfLinkedList == NULL )
  130229             :                        {
  130230           0 :                          SgOmpTargetParallelLoopStatement::next_node = &(pointer[i]);
  130231             :                        }
  130232             :                     else
  130233             :                        {
  130234             :                       // printf ("In SgOmpTargetParallelLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  130235           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  130236             :                        }
  130237             :                     pointerOfLinkedList = &(pointer[i]);
  130238             :                   }
  130239             :               }
  130240             :         }
  130241             : 
  130242           5 :      if ( pointerOfLinkedList != NULL )
  130243             :         {
  130244             :        // printf ("In SgOmpTargetParallelLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  130245           0 :           pointerOfLinkedList->set_freepointer(NULL);
  130246             :        // DQ (6/6/2010): Temporary debugging...
  130247             :        //   ROSE_ASSERT(false);
  130248             :         }
  130249             : 
  130250           5 :      return ;
  130251             :    }
  130252             : 
  130253             : //############################################################################
  130254             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  130255             :  * within the memory pool and resets the freepointers, in order to achieve a 
  130256             :  * linked list, that has no jumps and starts at the beginning! This function 
  130257             :  * does not extend the memory pool, since we do not delete any memory blocks,
  130258             :  * but delete the valid objects.  
  130259             :  */
  130260             : void
  130261           0 : SgOmpTargetParallelLoopStatement::clearMemoryPool( )
  130262             :    {
  130263             :   // printf ("Inside of SgOmpTargetParallelLoopStatement::clearMemoryPool() \n");
  130264             : 
  130265           0 :      SgOmpTargetParallelLoopStatement* pointer = NULL, *tempPointer = NULL;
  130266           0 :      std::vector < unsigned char* > :: const_iterator block;
  130267           0 :      if ( SgOmpTargetParallelLoopStatement::pools.empty() == false )
  130268             :         {
  130269           0 :           block = SgOmpTargetParallelLoopStatement::pools.begin() ;
  130270           0 :           SgOmpTargetParallelLoopStatement::next_node = (SgOmpTargetParallelLoopStatement*) (*block);
  130271             : 
  130272           0 :           while ( block != SgOmpTargetParallelLoopStatement::pools.end() )
  130273             :              {
  130274           0 :                pointer = (SgOmpTargetParallelLoopStatement*) (*block);
  130275           0 :                if ( tempPointer != NULL )
  130276             :                   {
  130277           0 :                     tempPointer->set_freepointer(pointer);
  130278             :                   }
  130279           0 :                for (unsigned i = 0; i < SgOmpTargetParallelLoopStatement::pool_size - 1; ++i)
  130280             :                   {
  130281           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  130282             :                   }
  130283           0 :                 pointer[SgOmpTargetParallelLoopStatement::pool_size-1].set_freepointer(NULL);
  130284           0 :                 tempPointer = &(pointer[SgOmpTargetParallelLoopStatement::pool_size-1]);
  130285           0 :                 ++block;
  130286             :              }
  130287             :         }
  130288           0 :    }
  130289             : 
  130290           5 : void SgOmpTargetParallelLoopStatement::deleteMemoryPool() {
  130291           5 :   for (auto p: SgOmpTargetParallelLoopStatement::pools) {
  130292           0 :     ROSE_FREE(p);
  130293             :   }
  130294           5 :   SgOmpTargetParallelLoopStatement::next_node = nullptr;
  130295           5 :   SgOmpTargetParallelLoopStatement::pools.clear();
  130296           5 : }
  130297             : 
  130298             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  130299             : //                 reading multiple binary files to for a single AST.
  130300             : /////////// new version ////////////////////////////////
  130301             : //############################################################################
  130302             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  130303             : void
  130304           2 : SgOmpTargetParallelLoopStatement::extendMemoryPoolForFileIO( )
  130305             :   {
  130306           2 :     size_t blockIndex = SgOmpTargetParallelLoopStatement::pools.size();
  130307           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelLoopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelLoopStatement);
  130308             : 
  130309           2 :     while ( (blockIndex * SgOmpTargetParallelLoopStatement::pool_size) < newPoolSize)
  130310             :       {
  130311             : #if ROSE_ALLOC_TRACE
  130312             :         if (blockIndex > 0) {
  130313             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelLoopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelLoopStatement) = %" PRIuPTR " SgOmpTargetParallelLoopStatement::pool_size = %d \n",
  130314             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetParallelLoopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetParallelLoopStatement),SgOmpTargetParallelLoopStatement::pool_size);
  130315             :         }
  130316             : #endif
  130317             : 
  130318           0 :         SgOmpTargetParallelLoopStatement * pointer = (SgOmpTargetParallelLoopStatement*) ROSE_MALLOC ( SgOmpTargetParallelLoopStatement::pool_size * sizeof(SgOmpTargetParallelLoopStatement) );
  130319           0 :         assert( pointer != NULL );
  130320             : #if ROSE_ALLOC_MEMSET == 1
  130321             :         memset(pointer, 0x00, SgOmpTargetParallelLoopStatement::pool_size * sizeof(SgOmpTargetParallelLoopStatement));
  130322             : #elif ROSE_ALLOC_MEMSET == 2
  130323             :         memset(pointer, 0xCC, SgOmpTargetParallelLoopStatement::pool_size * sizeof(SgOmpTargetParallelLoopStatement));
  130324             : #endif
  130325           0 :         SgOmpTargetParallelLoopStatement::pools.push_back( (unsigned char*)(pointer) );
  130326           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetParallelLoopStatement::pool_size * sizeof(SgOmpTargetParallelLoopStatement), V_SgOmpTargetParallelLoopStatement ) );
  130327             : 
  130328           0 :         if ( SgOmpTargetParallelLoopStatement::next_node != NULL ) {
  130329           0 :           if ( blockIndex > 0 ) {
  130330           0 :             SgOmpTargetParallelLoopStatement * blkptr = (SgOmpTargetParallelLoopStatement*)(SgOmpTargetParallelLoopStatement::pools[blockIndex-1]);
  130331           0 :             blkptr[ SgOmpTargetParallelLoopStatement::pool_size - 1 ].set_freepointer(pointer);
  130332             :           }
  130333             :         } else {
  130334           0 :           SgOmpTargetParallelLoopStatement::next_node = pointer;
  130335             :         }
  130336             : 
  130337           0 :         for (unsigned i = 0; i < SgOmpTargetParallelLoopStatement::pool_size-1; ++i)
  130338             :            {
  130339           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  130340             :            }
  130341           0 :         pointer[ SgOmpTargetParallelLoopStatement::pool_size -1 ].set_freepointer(NULL);
  130342             : 
  130343           0 :         blockIndex++;
  130344             :       }
  130345           2 :   }
  130346             : 
  130347             : //############################################################################
  130348             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  130349             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  130350             :  * not compressed. However, that stuff is not yet implemented! 
  130351             :  */
  130352             : unsigned long
  130353           0 : SgOmpTargetParallelLoopStatement::getNumberOfLastValidPointer()
  130354             :    {
  130355           0 :       SgOmpTargetParallelLoopStatement* testPointer = (SgOmpTargetParallelLoopStatement*)(SgOmpTargetParallelLoopStatement::pools.back());
  130356           0 :       unsigned long localIndex = SgOmpTargetParallelLoopStatement::pool_size - 1;
  130357           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  130358             :          {
  130359           0 :            localIndex--;
  130360             :          }
  130361           0 :       return (localIndex + SgOmpTargetParallelLoopStatement::pool_size * (SgOmpTargetParallelLoopStatement::pools.size()-1));
  130362             :    }
  130363             : 
  130364             : //############################################################################
  130365             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  130366             :  * memory pool and initializes the data member in class SgOmpTargetParallelLoopStatementStroageClass
  130367             :  * from its counterpart of SgOmpTargetParallelLoopStatement. The return value is just for checking, 
  130368             :  * that the whole StorageClassArray is initialized!
  130369             :  */
  130370             : unsigned long
  130371           0 : SgOmpTargetParallelLoopStatement::initializeStorageClassArray( SgOmpTargetParallelLoopStatementStorageClass *storageArray )
  130372             :    {
  130373           0 :      unsigned long storageCounter = 0;
  130374           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetParallelLoopStatement::pools.begin();
  130375           0 :      SgOmpTargetParallelLoopStatement* pointer = NULL;
  130376           0 :      while ( block != SgOmpTargetParallelLoopStatement::pools.end() ) {
  130377           0 :           pointer = (SgOmpTargetParallelLoopStatement*) (*block);
  130378           0 :           for ( unsigned i = 0; i < SgOmpTargetParallelLoopStatement::pool_size; ++i ) {
  130379           0 :                if ( pointer->get_freepointer() != NULL ) {
  130380           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  130381           0 :                  storageArray++;
  130382           0 :                  storageCounter++;
  130383             :                }
  130384           0 :                pointer++;
  130385             :              }
  130386           0 :            block++;
  130387             :         }
  130388           0 :      return storageCounter;
  130389             :    }
  130390             : 
  130391             : /* #line 130392 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  130392             : 
  130393             : 
  130394             : 
  130395             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  130396             : 
  130397             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  130398             : 
  130399             : //############################################################################
  130400             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetSimdStatement that takes its 
  130401             :  * corresponding StorageClass as parameter
  130402             :  */
  130403           0 : SgOmpTargetSimdStatement :: SgOmpTargetSimdStatement ( const SgOmpTargetSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  130404             :    {
  130405             : 
  130406             : 
  130407             : /* #line 130408 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  130408             : 
  130409           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  130410             : 
  130411             : 
  130412             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  130413             : 
  130414             : 
  130415           0 :    }
  130416             : 
  130417             : //############################################################################
  130418             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  130419             :  * within the working AST. 
  130420             :  */
  130421           0 : SgOmpTargetSimdStatement * SgOmpTargetSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  130422           0 :      SgOmpTargetSimdStatement* returnPointer = NULL;
  130423           0 :      if ( globalIndex != 0 )
  130424             :         {
  130425             : 
  130426             : #if FILE_IO_EXTRA_CHECK
  130427           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetSimdStatement ) ) <= globalIndex ) ;
  130428           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetSimdStatement + 1 ) ) );
  130429             : #endif
  130430           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetSimdStatement )  
  130431           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetSimdStatement );
  130432           0 :           unsigned long positionInPool = localIndex % SgOmpTargetSimdStatement::pool_size;
  130433           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetSimdStatement::pool_size;
  130434             : 
  130435             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  130436             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  130437             : 
  130438           0 :           returnPointer = &( ( (SgOmpTargetSimdStatement*)(SgOmpTargetSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  130439             : 
  130440           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  130441             :         }
  130442           0 :      return returnPointer ;
  130443             :    }
  130444             : 
  130445             : //############################################################################
  130446             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  130447             :   for the AST with the index astIndex
  130448             : */
  130449           0 : SgOmpTargetSimdStatement * SgOmpTargetSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  130450           0 :      SgOmpTargetSimdStatement* returnPointer = NULL;
  130451           0 :      if ( globalIndex != 0 )
  130452             :         {
  130453             : 
  130454             : #if FILE_IO_EXTRA_CHECK
  130455           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetSimdStatement ) ) <= globalIndex ) ;
  130456           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetSimdStatement + 1 ) ) );
  130457             : #endif
  130458           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetSimdStatement )
  130459           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetSimdStatement );
  130460           0 :           unsigned long positionInPool = localIndex % SgOmpTargetSimdStatement::pool_size ;
  130461           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetSimdStatement::pool_size ;
  130462             : 
  130463             : #if FILE_IO_EXTRA_CHECK
  130464             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  130465             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  130466             : #endif
  130467             : 
  130468           0 :           returnPointer = &( ( (SgOmpTargetSimdStatement*)(SgOmpTargetSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  130469             : 
  130470             : #if FILE_IO_EXTRA_CHECK
  130471           0 :           assert ( returnPointer != NULL ) ;
  130472             : #endif
  130473             :         }
  130474           0 :      return returnPointer ;
  130475             :    }
  130476             : 
  130477             : //############################################################################
  130478             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  130479             :  * pool size! We set for every valid object in the memory pool the freepointer
  130480             :  * to the global index and increase the global index afterwards. For all the 
  130481             :  * invalid objects (means address ranges within the memory pool that were not
  130482             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  130483             :  * distinguish valid from invalid objects! 
  130484             :  */
  130485             : unsigned long
  130486           5 : SgOmpTargetSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  130487             :    {
  130488           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  130489           5 :      SgOmpTargetSimdStatement* pointer = NULL;
  130490           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  130491           5 :      std::vector < unsigned char* > :: const_iterator block;
  130492           5 :      for ( block = SgOmpTargetSimdStatement::pools.begin(); block != SgOmpTargetSimdStatement::pools.end() ; ++block )
  130493             :         {
  130494           0 :           pointer = (SgOmpTargetSimdStatement*)(*block);
  130495           0 :           for (unsigned i = 0; i < SgOmpTargetSimdStatement::pool_size; ++i )
  130496             :              {
  130497             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  130498             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  130499             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  130500             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  130501             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  130502             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  130503             :             // properly; so this will have to be checked next.
  130504             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  130505             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  130506           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  130507             :                   {
  130508           0 :                     pointer[i].set_freepointer((SgOmpTargetSimdStatement*)(globalIndex));
  130509           0 :                     globalIndex++;
  130510             :                   }
  130511             :                else
  130512             :                   {
  130513           0 :                     pointer[i].set_freepointer(NULL);
  130514             :                   }
  130515             :               }
  130516             :         }
  130517           5 :      return globalIndex;
  130518             :    }
  130519             : 
  130520             : //############################################################################
  130521             : // JH (01/14/2006)
  130522             : void
  130523           5 : SgOmpTargetSimdStatement::resetValidFreepointers( )
  130524             :    {
  130525           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  130526           5 :      SgOmpTargetSimdStatement* pointer = NULL;
  130527           5 :      std::vector < unsigned char* > :: const_iterator block;
  130528           5 :      SgOmpTargetSimdStatement* pointerOfLinkedList = NULL;
  130529           5 :      for ( block = SgOmpTargetSimdStatement::pools.begin(); block != SgOmpTargetSimdStatement::pools.end() ; ++block )
  130530             :         {
  130531           0 :           pointer = (SgOmpTargetSimdStatement*)(*block);
  130532           0 :           for (unsigned i = 0; i < SgOmpTargetSimdStatement::pool_size; ++i )
  130533             :              {
  130534             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  130535             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  130536             :             // memory blocks!.
  130537           0 :                if ( pointer[i].get_freepointer() != NULL )
  130538             :                   {
  130539           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  130540             :                   }
  130541             :                else
  130542             :                   {
  130543           0 :                     if ( pointerOfLinkedList == NULL )
  130544             :                        {
  130545           0 :                          SgOmpTargetSimdStatement::next_node = &(pointer[i]);
  130546             :                        }
  130547             :                     else
  130548             :                        {
  130549             :                       // printf ("In SgOmpTargetSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  130550           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  130551             :                        }
  130552             :                     pointerOfLinkedList = &(pointer[i]);
  130553             :                   }
  130554             :               }
  130555             :         }
  130556             : 
  130557           5 :      if ( pointerOfLinkedList != NULL )
  130558             :         {
  130559             :        // printf ("In SgOmpTargetSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  130560           0 :           pointerOfLinkedList->set_freepointer(NULL);
  130561             :        // DQ (6/6/2010): Temporary debugging...
  130562             :        //   ROSE_ASSERT(false);
  130563             :         }
  130564             : 
  130565           5 :      return ;
  130566             :    }
  130567             : 
  130568             : //############################################################################
  130569             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  130570             :  * within the memory pool and resets the freepointers, in order to achieve a 
  130571             :  * linked list, that has no jumps and starts at the beginning! This function 
  130572             :  * does not extend the memory pool, since we do not delete any memory blocks,
  130573             :  * but delete the valid objects.  
  130574             :  */
  130575             : void
  130576           0 : SgOmpTargetSimdStatement::clearMemoryPool( )
  130577             :    {
  130578             :   // printf ("Inside of SgOmpTargetSimdStatement::clearMemoryPool() \n");
  130579             : 
  130580           0 :      SgOmpTargetSimdStatement* pointer = NULL, *tempPointer = NULL;
  130581           0 :      std::vector < unsigned char* > :: const_iterator block;
  130582           0 :      if ( SgOmpTargetSimdStatement::pools.empty() == false )
  130583             :         {
  130584           0 :           block = SgOmpTargetSimdStatement::pools.begin() ;
  130585           0 :           SgOmpTargetSimdStatement::next_node = (SgOmpTargetSimdStatement*) (*block);
  130586             : 
  130587           0 :           while ( block != SgOmpTargetSimdStatement::pools.end() )
  130588             :              {
  130589           0 :                pointer = (SgOmpTargetSimdStatement*) (*block);
  130590           0 :                if ( tempPointer != NULL )
  130591             :                   {
  130592           0 :                     tempPointer->set_freepointer(pointer);
  130593             :                   }
  130594           0 :                for (unsigned i = 0; i < SgOmpTargetSimdStatement::pool_size - 1; ++i)
  130595             :                   {
  130596           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  130597             :                   }
  130598           0 :                 pointer[SgOmpTargetSimdStatement::pool_size-1].set_freepointer(NULL);
  130599           0 :                 tempPointer = &(pointer[SgOmpTargetSimdStatement::pool_size-1]);
  130600           0 :                 ++block;
  130601             :              }
  130602             :         }
  130603           0 :    }
  130604             : 
  130605           5 : void SgOmpTargetSimdStatement::deleteMemoryPool() {
  130606           5 :   for (auto p: SgOmpTargetSimdStatement::pools) {
  130607           0 :     ROSE_FREE(p);
  130608             :   }
  130609           5 :   SgOmpTargetSimdStatement::next_node = nullptr;
  130610           5 :   SgOmpTargetSimdStatement::pools.clear();
  130611           5 : }
  130612             : 
  130613             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  130614             : //                 reading multiple binary files to for a single AST.
  130615             : /////////// new version ////////////////////////////////
  130616             : //############################################################################
  130617             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  130618             : void
  130619           2 : SgOmpTargetSimdStatement::extendMemoryPoolForFileIO( )
  130620             :   {
  130621           2 :     size_t blockIndex = SgOmpTargetSimdStatement::pools.size();
  130622           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetSimdStatement);
  130623             : 
  130624           2 :     while ( (blockIndex * SgOmpTargetSimdStatement::pool_size) < newPoolSize)
  130625             :       {
  130626             : #if ROSE_ALLOC_TRACE
  130627             :         if (blockIndex > 0) {
  130628             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetSimdStatement) = %" PRIuPTR " SgOmpTargetSimdStatement::pool_size = %d \n",
  130629             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetSimdStatement),SgOmpTargetSimdStatement::pool_size);
  130630             :         }
  130631             : #endif
  130632             : 
  130633           0 :         SgOmpTargetSimdStatement * pointer = (SgOmpTargetSimdStatement*) ROSE_MALLOC ( SgOmpTargetSimdStatement::pool_size * sizeof(SgOmpTargetSimdStatement) );
  130634           0 :         assert( pointer != NULL );
  130635             : #if ROSE_ALLOC_MEMSET == 1
  130636             :         memset(pointer, 0x00, SgOmpTargetSimdStatement::pool_size * sizeof(SgOmpTargetSimdStatement));
  130637             : #elif ROSE_ALLOC_MEMSET == 2
  130638             :         memset(pointer, 0xCC, SgOmpTargetSimdStatement::pool_size * sizeof(SgOmpTargetSimdStatement));
  130639             : #endif
  130640           0 :         SgOmpTargetSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  130641           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetSimdStatement::pool_size * sizeof(SgOmpTargetSimdStatement), V_SgOmpTargetSimdStatement ) );
  130642             : 
  130643           0 :         if ( SgOmpTargetSimdStatement::next_node != NULL ) {
  130644           0 :           if ( blockIndex > 0 ) {
  130645           0 :             SgOmpTargetSimdStatement * blkptr = (SgOmpTargetSimdStatement*)(SgOmpTargetSimdStatement::pools[blockIndex-1]);
  130646           0 :             blkptr[ SgOmpTargetSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  130647             :           }
  130648             :         } else {
  130649           0 :           SgOmpTargetSimdStatement::next_node = pointer;
  130650             :         }
  130651             : 
  130652           0 :         for (unsigned i = 0; i < SgOmpTargetSimdStatement::pool_size-1; ++i)
  130653             :            {
  130654           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  130655             :            }
  130656           0 :         pointer[ SgOmpTargetSimdStatement::pool_size -1 ].set_freepointer(NULL);
  130657             : 
  130658           0 :         blockIndex++;
  130659             :       }
  130660           2 :   }
  130661             : 
  130662             : //############################################################################
  130663             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  130664             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  130665             :  * not compressed. However, that stuff is not yet implemented! 
  130666             :  */
  130667             : unsigned long
  130668           0 : SgOmpTargetSimdStatement::getNumberOfLastValidPointer()
  130669             :    {
  130670           0 :       SgOmpTargetSimdStatement* testPointer = (SgOmpTargetSimdStatement*)(SgOmpTargetSimdStatement::pools.back());
  130671           0 :       unsigned long localIndex = SgOmpTargetSimdStatement::pool_size - 1;
  130672           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  130673             :          {
  130674           0 :            localIndex--;
  130675             :          }
  130676           0 :       return (localIndex + SgOmpTargetSimdStatement::pool_size * (SgOmpTargetSimdStatement::pools.size()-1));
  130677             :    }
  130678             : 
  130679             : //############################################################################
  130680             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  130681             :  * memory pool and initializes the data member in class SgOmpTargetSimdStatementStroageClass
  130682             :  * from its counterpart of SgOmpTargetSimdStatement. The return value is just for checking, 
  130683             :  * that the whole StorageClassArray is initialized!
  130684             :  */
  130685             : unsigned long
  130686           0 : SgOmpTargetSimdStatement::initializeStorageClassArray( SgOmpTargetSimdStatementStorageClass *storageArray )
  130687             :    {
  130688           0 :      unsigned long storageCounter = 0;
  130689           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetSimdStatement::pools.begin();
  130690           0 :      SgOmpTargetSimdStatement* pointer = NULL;
  130691           0 :      while ( block != SgOmpTargetSimdStatement::pools.end() ) {
  130692           0 :           pointer = (SgOmpTargetSimdStatement*) (*block);
  130693           0 :           for ( unsigned i = 0; i < SgOmpTargetSimdStatement::pool_size; ++i ) {
  130694           0 :                if ( pointer->get_freepointer() != NULL ) {
  130695           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  130696           0 :                  storageArray++;
  130697           0 :                  storageCounter++;
  130698             :                }
  130699           0 :                pointer++;
  130700             :              }
  130701           0 :            block++;
  130702             :         }
  130703           0 :      return storageCounter;
  130704             :    }
  130705             : 
  130706             : /* #line 130707 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  130707             : 
  130708             : 
  130709             : 
  130710             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  130711             : 
  130712             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  130713             : 
  130714             : //############################################################################
  130715             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetTeamsStatement that takes its 
  130716             :  * corresponding StorageClass as parameter
  130717             :  */
  130718           0 : SgOmpTargetTeamsStatement :: SgOmpTargetTeamsStatement ( const SgOmpTargetTeamsStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  130719             :    {
  130720             : 
  130721             : 
  130722             : /* #line 130723 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  130723             : 
  130724           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  130725             : 
  130726             : 
  130727             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  130728             : 
  130729             : 
  130730           0 :    }
  130731             : 
  130732             : //############################################################################
  130733             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  130734             :  * within the working AST. 
  130735             :  */
  130736           0 : SgOmpTargetTeamsStatement * SgOmpTargetTeamsStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  130737           0 :      SgOmpTargetTeamsStatement* returnPointer = NULL;
  130738           0 :      if ( globalIndex != 0 )
  130739             :         {
  130740             : 
  130741             : #if FILE_IO_EXTRA_CHECK
  130742           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetTeamsStatement ) ) <= globalIndex ) ;
  130743           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsStatement + 1 ) ) );
  130744             : #endif
  130745           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsStatement )  
  130746           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetTeamsStatement );
  130747           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsStatement::pool_size;
  130748           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsStatement::pool_size;
  130749             : 
  130750             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  130751             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  130752             : 
  130753           0 :           returnPointer = &( ( (SgOmpTargetTeamsStatement*)(SgOmpTargetTeamsStatement::pools[memoryBlock]) ) [positionInPool]) ;
  130754             : 
  130755           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  130756             :         }
  130757           0 :      return returnPointer ;
  130758             :    }
  130759             : 
  130760             : //############################################################################
  130761             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  130762             :   for the AST with the index astIndex
  130763             : */
  130764           0 : SgOmpTargetTeamsStatement * SgOmpTargetTeamsStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  130765           0 :      SgOmpTargetTeamsStatement* returnPointer = NULL;
  130766           0 :      if ( globalIndex != 0 )
  130767             :         {
  130768             : 
  130769             : #if FILE_IO_EXTRA_CHECK
  130770           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetTeamsStatement ) ) <= globalIndex ) ;
  130771           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsStatement + 1 ) ) );
  130772             : #endif
  130773           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsStatement )
  130774           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetTeamsStatement );
  130775           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsStatement::pool_size ;
  130776           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsStatement::pool_size ;
  130777             : 
  130778             : #if FILE_IO_EXTRA_CHECK
  130779             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  130780             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  130781             : #endif
  130782             : 
  130783           0 :           returnPointer = &( ( (SgOmpTargetTeamsStatement*)(SgOmpTargetTeamsStatement::pools[memoryBlock]) ) [positionInPool]) ;
  130784             : 
  130785             : #if FILE_IO_EXTRA_CHECK
  130786           0 :           assert ( returnPointer != NULL ) ;
  130787             : #endif
  130788             :         }
  130789           0 :      return returnPointer ;
  130790             :    }
  130791             : 
  130792             : //############################################################################
  130793             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  130794             :  * pool size! We set for every valid object in the memory pool the freepointer
  130795             :  * to the global index and increase the global index afterwards. For all the 
  130796             :  * invalid objects (means address ranges within the memory pool that were not
  130797             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  130798             :  * distinguish valid from invalid objects! 
  130799             :  */
  130800             : unsigned long
  130801           5 : SgOmpTargetTeamsStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  130802             :    {
  130803           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  130804           5 :      SgOmpTargetTeamsStatement* pointer = NULL;
  130805           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  130806           5 :      std::vector < unsigned char* > :: const_iterator block;
  130807           5 :      for ( block = SgOmpTargetTeamsStatement::pools.begin(); block != SgOmpTargetTeamsStatement::pools.end() ; ++block )
  130808             :         {
  130809           0 :           pointer = (SgOmpTargetTeamsStatement*)(*block);
  130810           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsStatement::pool_size; ++i )
  130811             :              {
  130812             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  130813             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  130814             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  130815             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  130816             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  130817             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  130818             :             // properly; so this will have to be checked next.
  130819             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  130820             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  130821           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  130822             :                   {
  130823           0 :                     pointer[i].set_freepointer((SgOmpTargetTeamsStatement*)(globalIndex));
  130824           0 :                     globalIndex++;
  130825             :                   }
  130826             :                else
  130827             :                   {
  130828           0 :                     pointer[i].set_freepointer(NULL);
  130829             :                   }
  130830             :               }
  130831             :         }
  130832           5 :      return globalIndex;
  130833             :    }
  130834             : 
  130835             : //############################################################################
  130836             : // JH (01/14/2006)
  130837             : void
  130838           5 : SgOmpTargetTeamsStatement::resetValidFreepointers( )
  130839             :    {
  130840           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  130841           5 :      SgOmpTargetTeamsStatement* pointer = NULL;
  130842           5 :      std::vector < unsigned char* > :: const_iterator block;
  130843           5 :      SgOmpTargetTeamsStatement* pointerOfLinkedList = NULL;
  130844           5 :      for ( block = SgOmpTargetTeamsStatement::pools.begin(); block != SgOmpTargetTeamsStatement::pools.end() ; ++block )
  130845             :         {
  130846           0 :           pointer = (SgOmpTargetTeamsStatement*)(*block);
  130847           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsStatement::pool_size; ++i )
  130848             :              {
  130849             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  130850             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  130851             :             // memory blocks!.
  130852           0 :                if ( pointer[i].get_freepointer() != NULL )
  130853             :                   {
  130854           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  130855             :                   }
  130856             :                else
  130857             :                   {
  130858           0 :                     if ( pointerOfLinkedList == NULL )
  130859             :                        {
  130860           0 :                          SgOmpTargetTeamsStatement::next_node = &(pointer[i]);
  130861             :                        }
  130862             :                     else
  130863             :                        {
  130864             :                       // printf ("In SgOmpTargetTeamsStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  130865           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  130866             :                        }
  130867             :                     pointerOfLinkedList = &(pointer[i]);
  130868             :                   }
  130869             :               }
  130870             :         }
  130871             : 
  130872           5 :      if ( pointerOfLinkedList != NULL )
  130873             :         {
  130874             :        // printf ("In SgOmpTargetTeamsStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  130875           0 :           pointerOfLinkedList->set_freepointer(NULL);
  130876             :        // DQ (6/6/2010): Temporary debugging...
  130877             :        //   ROSE_ASSERT(false);
  130878             :         }
  130879             : 
  130880           5 :      return ;
  130881             :    }
  130882             : 
  130883             : //############################################################################
  130884             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  130885             :  * within the memory pool and resets the freepointers, in order to achieve a 
  130886             :  * linked list, that has no jumps and starts at the beginning! This function 
  130887             :  * does not extend the memory pool, since we do not delete any memory blocks,
  130888             :  * but delete the valid objects.  
  130889             :  */
  130890             : void
  130891           0 : SgOmpTargetTeamsStatement::clearMemoryPool( )
  130892             :    {
  130893             :   // printf ("Inside of SgOmpTargetTeamsStatement::clearMemoryPool() \n");
  130894             : 
  130895           0 :      SgOmpTargetTeamsStatement* pointer = NULL, *tempPointer = NULL;
  130896           0 :      std::vector < unsigned char* > :: const_iterator block;
  130897           0 :      if ( SgOmpTargetTeamsStatement::pools.empty() == false )
  130898             :         {
  130899           0 :           block = SgOmpTargetTeamsStatement::pools.begin() ;
  130900           0 :           SgOmpTargetTeamsStatement::next_node = (SgOmpTargetTeamsStatement*) (*block);
  130901             : 
  130902           0 :           while ( block != SgOmpTargetTeamsStatement::pools.end() )
  130903             :              {
  130904           0 :                pointer = (SgOmpTargetTeamsStatement*) (*block);
  130905           0 :                if ( tempPointer != NULL )
  130906             :                   {
  130907           0 :                     tempPointer->set_freepointer(pointer);
  130908             :                   }
  130909           0 :                for (unsigned i = 0; i < SgOmpTargetTeamsStatement::pool_size - 1; ++i)
  130910             :                   {
  130911           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  130912             :                   }
  130913           0 :                 pointer[SgOmpTargetTeamsStatement::pool_size-1].set_freepointer(NULL);
  130914           0 :                 tempPointer = &(pointer[SgOmpTargetTeamsStatement::pool_size-1]);
  130915           0 :                 ++block;
  130916             :              }
  130917             :         }
  130918           0 :    }
  130919             : 
  130920           5 : void SgOmpTargetTeamsStatement::deleteMemoryPool() {
  130921           5 :   for (auto p: SgOmpTargetTeamsStatement::pools) {
  130922           0 :     ROSE_FREE(p);
  130923             :   }
  130924           5 :   SgOmpTargetTeamsStatement::next_node = nullptr;
  130925           5 :   SgOmpTargetTeamsStatement::pools.clear();
  130926           5 : }
  130927             : 
  130928             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  130929             : //                 reading multiple binary files to for a single AST.
  130930             : /////////// new version ////////////////////////////////
  130931             : //############################################################################
  130932             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  130933             : void
  130934           2 : SgOmpTargetTeamsStatement::extendMemoryPoolForFileIO( )
  130935             :   {
  130936           2 :     size_t blockIndex = SgOmpTargetTeamsStatement::pools.size();
  130937           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsStatement);
  130938             : 
  130939           2 :     while ( (blockIndex * SgOmpTargetTeamsStatement::pool_size) < newPoolSize)
  130940             :       {
  130941             : #if ROSE_ALLOC_TRACE
  130942             :         if (blockIndex > 0) {
  130943             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsStatement) = %" PRIuPTR " SgOmpTargetTeamsStatement::pool_size = %d \n",
  130944             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsStatement),SgOmpTargetTeamsStatement::pool_size);
  130945             :         }
  130946             : #endif
  130947             : 
  130948           0 :         SgOmpTargetTeamsStatement * pointer = (SgOmpTargetTeamsStatement*) ROSE_MALLOC ( SgOmpTargetTeamsStatement::pool_size * sizeof(SgOmpTargetTeamsStatement) );
  130949           0 :         assert( pointer != NULL );
  130950             : #if ROSE_ALLOC_MEMSET == 1
  130951             :         memset(pointer, 0x00, SgOmpTargetTeamsStatement::pool_size * sizeof(SgOmpTargetTeamsStatement));
  130952             : #elif ROSE_ALLOC_MEMSET == 2
  130953             :         memset(pointer, 0xCC, SgOmpTargetTeamsStatement::pool_size * sizeof(SgOmpTargetTeamsStatement));
  130954             : #endif
  130955           0 :         SgOmpTargetTeamsStatement::pools.push_back( (unsigned char*)(pointer) );
  130956           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetTeamsStatement::pool_size * sizeof(SgOmpTargetTeamsStatement), V_SgOmpTargetTeamsStatement ) );
  130957             : 
  130958           0 :         if ( SgOmpTargetTeamsStatement::next_node != NULL ) {
  130959           0 :           if ( blockIndex > 0 ) {
  130960           0 :             SgOmpTargetTeamsStatement * blkptr = (SgOmpTargetTeamsStatement*)(SgOmpTargetTeamsStatement::pools[blockIndex-1]);
  130961           0 :             blkptr[ SgOmpTargetTeamsStatement::pool_size - 1 ].set_freepointer(pointer);
  130962             :           }
  130963             :         } else {
  130964           0 :           SgOmpTargetTeamsStatement::next_node = pointer;
  130965             :         }
  130966             : 
  130967           0 :         for (unsigned i = 0; i < SgOmpTargetTeamsStatement::pool_size-1; ++i)
  130968             :            {
  130969           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  130970             :            }
  130971           0 :         pointer[ SgOmpTargetTeamsStatement::pool_size -1 ].set_freepointer(NULL);
  130972             : 
  130973           0 :         blockIndex++;
  130974             :       }
  130975           2 :   }
  130976             : 
  130977             : //############################################################################
  130978             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  130979             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  130980             :  * not compressed. However, that stuff is not yet implemented! 
  130981             :  */
  130982             : unsigned long
  130983           0 : SgOmpTargetTeamsStatement::getNumberOfLastValidPointer()
  130984             :    {
  130985           0 :       SgOmpTargetTeamsStatement* testPointer = (SgOmpTargetTeamsStatement*)(SgOmpTargetTeamsStatement::pools.back());
  130986           0 :       unsigned long localIndex = SgOmpTargetTeamsStatement::pool_size - 1;
  130987           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  130988             :          {
  130989           0 :            localIndex--;
  130990             :          }
  130991           0 :       return (localIndex + SgOmpTargetTeamsStatement::pool_size * (SgOmpTargetTeamsStatement::pools.size()-1));
  130992             :    }
  130993             : 
  130994             : //############################################################################
  130995             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  130996             :  * memory pool and initializes the data member in class SgOmpTargetTeamsStatementStroageClass
  130997             :  * from its counterpart of SgOmpTargetTeamsStatement. The return value is just for checking, 
  130998             :  * that the whole StorageClassArray is initialized!
  130999             :  */
  131000             : unsigned long
  131001           0 : SgOmpTargetTeamsStatement::initializeStorageClassArray( SgOmpTargetTeamsStatementStorageClass *storageArray )
  131002             :    {
  131003           0 :      unsigned long storageCounter = 0;
  131004           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetTeamsStatement::pools.begin();
  131005           0 :      SgOmpTargetTeamsStatement* pointer = NULL;
  131006           0 :      while ( block != SgOmpTargetTeamsStatement::pools.end() ) {
  131007           0 :           pointer = (SgOmpTargetTeamsStatement*) (*block);
  131008           0 :           for ( unsigned i = 0; i < SgOmpTargetTeamsStatement::pool_size; ++i ) {
  131009           0 :                if ( pointer->get_freepointer() != NULL ) {
  131010           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  131011           0 :                  storageArray++;
  131012           0 :                  storageCounter++;
  131013             :                }
  131014           0 :                pointer++;
  131015             :              }
  131016           0 :            block++;
  131017             :         }
  131018           0 :      return storageCounter;
  131019             :    }
  131020             : 
  131021             : /* #line 131022 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  131022             : 
  131023             : 
  131024             : 
  131025             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  131026             : 
  131027             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  131028             : 
  131029             : //############################################################################
  131030             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetTeamsDistributeStatement that takes its 
  131031             :  * corresponding StorageClass as parameter
  131032             :  */
  131033           0 : SgOmpTargetTeamsDistributeStatement :: SgOmpTargetTeamsDistributeStatement ( const SgOmpTargetTeamsDistributeStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  131034             :    {
  131035             : 
  131036             : 
  131037             : /* #line 131038 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  131038             : 
  131039           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  131040             : 
  131041             : 
  131042             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  131043             : 
  131044             : 
  131045           0 :    }
  131046             : 
  131047             : //############################################################################
  131048             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  131049             :  * within the working AST. 
  131050             :  */
  131051           0 : SgOmpTargetTeamsDistributeStatement * SgOmpTargetTeamsDistributeStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  131052           0 :      SgOmpTargetTeamsDistributeStatement* returnPointer = NULL;
  131053           0 :      if ( globalIndex != 0 )
  131054             :         {
  131055             : 
  131056             : #if FILE_IO_EXTRA_CHECK
  131057           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetTeamsDistributeStatement ) ) <= globalIndex ) ;
  131058           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsDistributeStatement + 1 ) ) );
  131059             : #endif
  131060           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsDistributeStatement )  
  131061           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetTeamsDistributeStatement );
  131062           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsDistributeStatement::pool_size;
  131063           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsDistributeStatement::pool_size;
  131064             : 
  131065             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  131066             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  131067             : 
  131068           0 :           returnPointer = &( ( (SgOmpTargetTeamsDistributeStatement*)(SgOmpTargetTeamsDistributeStatement::pools[memoryBlock]) ) [positionInPool]) ;
  131069             : 
  131070           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  131071             :         }
  131072           0 :      return returnPointer ;
  131073             :    }
  131074             : 
  131075             : //############################################################################
  131076             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  131077             :   for the AST with the index astIndex
  131078             : */
  131079           0 : SgOmpTargetTeamsDistributeStatement * SgOmpTargetTeamsDistributeStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  131080           0 :      SgOmpTargetTeamsDistributeStatement* returnPointer = NULL;
  131081           0 :      if ( globalIndex != 0 )
  131082             :         {
  131083             : 
  131084             : #if FILE_IO_EXTRA_CHECK
  131085           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetTeamsDistributeStatement ) ) <= globalIndex ) ;
  131086           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsDistributeStatement + 1 ) ) );
  131087             : #endif
  131088           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsDistributeStatement )
  131089           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetTeamsDistributeStatement );
  131090           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsDistributeStatement::pool_size ;
  131091           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsDistributeStatement::pool_size ;
  131092             : 
  131093             : #if FILE_IO_EXTRA_CHECK
  131094             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  131095             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  131096             : #endif
  131097             : 
  131098           0 :           returnPointer = &( ( (SgOmpTargetTeamsDistributeStatement*)(SgOmpTargetTeamsDistributeStatement::pools[memoryBlock]) ) [positionInPool]) ;
  131099             : 
  131100             : #if FILE_IO_EXTRA_CHECK
  131101           0 :           assert ( returnPointer != NULL ) ;
  131102             : #endif
  131103             :         }
  131104           0 :      return returnPointer ;
  131105             :    }
  131106             : 
  131107             : //############################################################################
  131108             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  131109             :  * pool size! We set for every valid object in the memory pool the freepointer
  131110             :  * to the global index and increase the global index afterwards. For all the 
  131111             :  * invalid objects (means address ranges within the memory pool that were not
  131112             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  131113             :  * distinguish valid from invalid objects! 
  131114             :  */
  131115             : unsigned long
  131116           5 : SgOmpTargetTeamsDistributeStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  131117             :    {
  131118           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  131119           5 :      SgOmpTargetTeamsDistributeStatement* pointer = NULL;
  131120           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  131121           5 :      std::vector < unsigned char* > :: const_iterator block;
  131122           5 :      for ( block = SgOmpTargetTeamsDistributeStatement::pools.begin(); block != SgOmpTargetTeamsDistributeStatement::pools.end() ; ++block )
  131123             :         {
  131124           0 :           pointer = (SgOmpTargetTeamsDistributeStatement*)(*block);
  131125           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsDistributeStatement::pool_size; ++i )
  131126             :              {
  131127             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  131128             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  131129             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  131130             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  131131             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  131132             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  131133             :             // properly; so this will have to be checked next.
  131134             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  131135             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  131136           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  131137             :                   {
  131138           0 :                     pointer[i].set_freepointer((SgOmpTargetTeamsDistributeStatement*)(globalIndex));
  131139           0 :                     globalIndex++;
  131140             :                   }
  131141             :                else
  131142             :                   {
  131143           0 :                     pointer[i].set_freepointer(NULL);
  131144             :                   }
  131145             :               }
  131146             :         }
  131147           5 :      return globalIndex;
  131148             :    }
  131149             : 
  131150             : //############################################################################
  131151             : // JH (01/14/2006)
  131152             : void
  131153           5 : SgOmpTargetTeamsDistributeStatement::resetValidFreepointers( )
  131154             :    {
  131155           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  131156           5 :      SgOmpTargetTeamsDistributeStatement* pointer = NULL;
  131157           5 :      std::vector < unsigned char* > :: const_iterator block;
  131158           5 :      SgOmpTargetTeamsDistributeStatement* pointerOfLinkedList = NULL;
  131159           5 :      for ( block = SgOmpTargetTeamsDistributeStatement::pools.begin(); block != SgOmpTargetTeamsDistributeStatement::pools.end() ; ++block )
  131160             :         {
  131161           0 :           pointer = (SgOmpTargetTeamsDistributeStatement*)(*block);
  131162           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsDistributeStatement::pool_size; ++i )
  131163             :              {
  131164             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  131165             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  131166             :             // memory blocks!.
  131167           0 :                if ( pointer[i].get_freepointer() != NULL )
  131168             :                   {
  131169           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  131170             :                   }
  131171             :                else
  131172             :                   {
  131173           0 :                     if ( pointerOfLinkedList == NULL )
  131174             :                        {
  131175           0 :                          SgOmpTargetTeamsDistributeStatement::next_node = &(pointer[i]);
  131176             :                        }
  131177             :                     else
  131178             :                        {
  131179             :                       // printf ("In SgOmpTargetTeamsDistributeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  131180           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  131181             :                        }
  131182             :                     pointerOfLinkedList = &(pointer[i]);
  131183             :                   }
  131184             :               }
  131185             :         }
  131186             : 
  131187           5 :      if ( pointerOfLinkedList != NULL )
  131188             :         {
  131189             :        // printf ("In SgOmpTargetTeamsDistributeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  131190           0 :           pointerOfLinkedList->set_freepointer(NULL);
  131191             :        // DQ (6/6/2010): Temporary debugging...
  131192             :        //   ROSE_ASSERT(false);
  131193             :         }
  131194             : 
  131195           5 :      return ;
  131196             :    }
  131197             : 
  131198             : //############################################################################
  131199             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  131200             :  * within the memory pool and resets the freepointers, in order to achieve a 
  131201             :  * linked list, that has no jumps and starts at the beginning! This function 
  131202             :  * does not extend the memory pool, since we do not delete any memory blocks,
  131203             :  * but delete the valid objects.  
  131204             :  */
  131205             : void
  131206           0 : SgOmpTargetTeamsDistributeStatement::clearMemoryPool( )
  131207             :    {
  131208             :   // printf ("Inside of SgOmpTargetTeamsDistributeStatement::clearMemoryPool() \n");
  131209             : 
  131210           0 :      SgOmpTargetTeamsDistributeStatement* pointer = NULL, *tempPointer = NULL;
  131211           0 :      std::vector < unsigned char* > :: const_iterator block;
  131212           0 :      if ( SgOmpTargetTeamsDistributeStatement::pools.empty() == false )
  131213             :         {
  131214           0 :           block = SgOmpTargetTeamsDistributeStatement::pools.begin() ;
  131215           0 :           SgOmpTargetTeamsDistributeStatement::next_node = (SgOmpTargetTeamsDistributeStatement*) (*block);
  131216             : 
  131217           0 :           while ( block != SgOmpTargetTeamsDistributeStatement::pools.end() )
  131218             :              {
  131219           0 :                pointer = (SgOmpTargetTeamsDistributeStatement*) (*block);
  131220           0 :                if ( tempPointer != NULL )
  131221             :                   {
  131222           0 :                     tempPointer->set_freepointer(pointer);
  131223             :                   }
  131224           0 :                for (unsigned i = 0; i < SgOmpTargetTeamsDistributeStatement::pool_size - 1; ++i)
  131225             :                   {
  131226           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  131227             :                   }
  131228           0 :                 pointer[SgOmpTargetTeamsDistributeStatement::pool_size-1].set_freepointer(NULL);
  131229           0 :                 tempPointer = &(pointer[SgOmpTargetTeamsDistributeStatement::pool_size-1]);
  131230           0 :                 ++block;
  131231             :              }
  131232             :         }
  131233           0 :    }
  131234             : 
  131235           5 : void SgOmpTargetTeamsDistributeStatement::deleteMemoryPool() {
  131236           5 :   for (auto p: SgOmpTargetTeamsDistributeStatement::pools) {
  131237           0 :     ROSE_FREE(p);
  131238             :   }
  131239           5 :   SgOmpTargetTeamsDistributeStatement::next_node = nullptr;
  131240           5 :   SgOmpTargetTeamsDistributeStatement::pools.clear();
  131241           5 : }
  131242             : 
  131243             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  131244             : //                 reading multiple binary files to for a single AST.
  131245             : /////////// new version ////////////////////////////////
  131246             : //############################################################################
  131247             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  131248             : void
  131249           2 : SgOmpTargetTeamsDistributeStatement::extendMemoryPoolForFileIO( )
  131250             :   {
  131251           2 :     size_t blockIndex = SgOmpTargetTeamsDistributeStatement::pools.size();
  131252           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeStatement);
  131253             : 
  131254           2 :     while ( (blockIndex * SgOmpTargetTeamsDistributeStatement::pool_size) < newPoolSize)
  131255             :       {
  131256             : #if ROSE_ALLOC_TRACE
  131257             :         if (blockIndex > 0) {
  131258             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeStatement) = %" PRIuPTR " SgOmpTargetTeamsDistributeStatement::pool_size = %d \n",
  131259             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeStatement),SgOmpTargetTeamsDistributeStatement::pool_size);
  131260             :         }
  131261             : #endif
  131262             : 
  131263           0 :         SgOmpTargetTeamsDistributeStatement * pointer = (SgOmpTargetTeamsDistributeStatement*) ROSE_MALLOC ( SgOmpTargetTeamsDistributeStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeStatement) );
  131264           0 :         assert( pointer != NULL );
  131265             : #if ROSE_ALLOC_MEMSET == 1
  131266             :         memset(pointer, 0x00, SgOmpTargetTeamsDistributeStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeStatement));
  131267             : #elif ROSE_ALLOC_MEMSET == 2
  131268             :         memset(pointer, 0xCC, SgOmpTargetTeamsDistributeStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeStatement));
  131269             : #endif
  131270           0 :         SgOmpTargetTeamsDistributeStatement::pools.push_back( (unsigned char*)(pointer) );
  131271           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetTeamsDistributeStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeStatement), V_SgOmpTargetTeamsDistributeStatement ) );
  131272             : 
  131273           0 :         if ( SgOmpTargetTeamsDistributeStatement::next_node != NULL ) {
  131274           0 :           if ( blockIndex > 0 ) {
  131275           0 :             SgOmpTargetTeamsDistributeStatement * blkptr = (SgOmpTargetTeamsDistributeStatement*)(SgOmpTargetTeamsDistributeStatement::pools[blockIndex-1]);
  131276           0 :             blkptr[ SgOmpTargetTeamsDistributeStatement::pool_size - 1 ].set_freepointer(pointer);
  131277             :           }
  131278             :         } else {
  131279           0 :           SgOmpTargetTeamsDistributeStatement::next_node = pointer;
  131280             :         }
  131281             : 
  131282           0 :         for (unsigned i = 0; i < SgOmpTargetTeamsDistributeStatement::pool_size-1; ++i)
  131283             :            {
  131284           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  131285             :            }
  131286           0 :         pointer[ SgOmpTargetTeamsDistributeStatement::pool_size -1 ].set_freepointer(NULL);
  131287             : 
  131288           0 :         blockIndex++;
  131289             :       }
  131290           2 :   }
  131291             : 
  131292             : //############################################################################
  131293             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  131294             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  131295             :  * not compressed. However, that stuff is not yet implemented! 
  131296             :  */
  131297             : unsigned long
  131298           0 : SgOmpTargetTeamsDistributeStatement::getNumberOfLastValidPointer()
  131299             :    {
  131300           0 :       SgOmpTargetTeamsDistributeStatement* testPointer = (SgOmpTargetTeamsDistributeStatement*)(SgOmpTargetTeamsDistributeStatement::pools.back());
  131301           0 :       unsigned long localIndex = SgOmpTargetTeamsDistributeStatement::pool_size - 1;
  131302           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  131303             :          {
  131304           0 :            localIndex--;
  131305             :          }
  131306           0 :       return (localIndex + SgOmpTargetTeamsDistributeStatement::pool_size * (SgOmpTargetTeamsDistributeStatement::pools.size()-1));
  131307             :    }
  131308             : 
  131309             : //############################################################################
  131310             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  131311             :  * memory pool and initializes the data member in class SgOmpTargetTeamsDistributeStatementStroageClass
  131312             :  * from its counterpart of SgOmpTargetTeamsDistributeStatement. The return value is just for checking, 
  131313             :  * that the whole StorageClassArray is initialized!
  131314             :  */
  131315             : unsigned long
  131316           0 : SgOmpTargetTeamsDistributeStatement::initializeStorageClassArray( SgOmpTargetTeamsDistributeStatementStorageClass *storageArray )
  131317             :    {
  131318           0 :      unsigned long storageCounter = 0;
  131319           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetTeamsDistributeStatement::pools.begin();
  131320           0 :      SgOmpTargetTeamsDistributeStatement* pointer = NULL;
  131321           0 :      while ( block != SgOmpTargetTeamsDistributeStatement::pools.end() ) {
  131322           0 :           pointer = (SgOmpTargetTeamsDistributeStatement*) (*block);
  131323           0 :           for ( unsigned i = 0; i < SgOmpTargetTeamsDistributeStatement::pool_size; ++i ) {
  131324           0 :                if ( pointer->get_freepointer() != NULL ) {
  131325           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  131326           0 :                  storageArray++;
  131327           0 :                  storageCounter++;
  131328             :                }
  131329           0 :                pointer++;
  131330             :              }
  131331           0 :            block++;
  131332             :         }
  131333           0 :      return storageCounter;
  131334             :    }
  131335             : 
  131336             : /* #line 131337 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  131337             : 
  131338             : 
  131339             : 
  131340             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  131341             : 
  131342             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  131343             : 
  131344             : //############################################################################
  131345             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetTeamsDistributeSimdStatement that takes its 
  131346             :  * corresponding StorageClass as parameter
  131347             :  */
  131348           0 : SgOmpTargetTeamsDistributeSimdStatement :: SgOmpTargetTeamsDistributeSimdStatement ( const SgOmpTargetTeamsDistributeSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  131349             :    {
  131350             : 
  131351             : 
  131352             : /* #line 131353 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  131353             : 
  131354           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  131355             : 
  131356             : 
  131357             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  131358             : 
  131359             : 
  131360           0 :    }
  131361             : 
  131362             : //############################################################################
  131363             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  131364             :  * within the working AST. 
  131365             :  */
  131366           0 : SgOmpTargetTeamsDistributeSimdStatement * SgOmpTargetTeamsDistributeSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  131367           0 :      SgOmpTargetTeamsDistributeSimdStatement* returnPointer = NULL;
  131368           0 :      if ( globalIndex != 0 )
  131369             :         {
  131370             : 
  131371             : #if FILE_IO_EXTRA_CHECK
  131372           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetTeamsDistributeSimdStatement ) ) <= globalIndex ) ;
  131373           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsDistributeSimdStatement + 1 ) ) );
  131374             : #endif
  131375           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsDistributeSimdStatement )  
  131376           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetTeamsDistributeSimdStatement );
  131377           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsDistributeSimdStatement::pool_size;
  131378           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsDistributeSimdStatement::pool_size;
  131379             : 
  131380             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  131381             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  131382             : 
  131383           0 :           returnPointer = &( ( (SgOmpTargetTeamsDistributeSimdStatement*)(SgOmpTargetTeamsDistributeSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  131384             : 
  131385           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  131386             :         }
  131387           0 :      return returnPointer ;
  131388             :    }
  131389             : 
  131390             : //############################################################################
  131391             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  131392             :   for the AST with the index astIndex
  131393             : */
  131394           0 : SgOmpTargetTeamsDistributeSimdStatement * SgOmpTargetTeamsDistributeSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  131395           0 :      SgOmpTargetTeamsDistributeSimdStatement* returnPointer = NULL;
  131396           0 :      if ( globalIndex != 0 )
  131397             :         {
  131398             : 
  131399             : #if FILE_IO_EXTRA_CHECK
  131400           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetTeamsDistributeSimdStatement ) ) <= globalIndex ) ;
  131401           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsDistributeSimdStatement + 1 ) ) );
  131402             : #endif
  131403           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsDistributeSimdStatement )
  131404           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetTeamsDistributeSimdStatement );
  131405           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsDistributeSimdStatement::pool_size ;
  131406           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsDistributeSimdStatement::pool_size ;
  131407             : 
  131408             : #if FILE_IO_EXTRA_CHECK
  131409             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  131410             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  131411             : #endif
  131412             : 
  131413           0 :           returnPointer = &( ( (SgOmpTargetTeamsDistributeSimdStatement*)(SgOmpTargetTeamsDistributeSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  131414             : 
  131415             : #if FILE_IO_EXTRA_CHECK
  131416           0 :           assert ( returnPointer != NULL ) ;
  131417             : #endif
  131418             :         }
  131419           0 :      return returnPointer ;
  131420             :    }
  131421             : 
  131422             : //############################################################################
  131423             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  131424             :  * pool size! We set for every valid object in the memory pool the freepointer
  131425             :  * to the global index and increase the global index afterwards. For all the 
  131426             :  * invalid objects (means address ranges within the memory pool that were not
  131427             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  131428             :  * distinguish valid from invalid objects! 
  131429             :  */
  131430             : unsigned long
  131431           5 : SgOmpTargetTeamsDistributeSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  131432             :    {
  131433           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  131434           5 :      SgOmpTargetTeamsDistributeSimdStatement* pointer = NULL;
  131435           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  131436           5 :      std::vector < unsigned char* > :: const_iterator block;
  131437           5 :      for ( block = SgOmpTargetTeamsDistributeSimdStatement::pools.begin(); block != SgOmpTargetTeamsDistributeSimdStatement::pools.end() ; ++block )
  131438             :         {
  131439           0 :           pointer = (SgOmpTargetTeamsDistributeSimdStatement*)(*block);
  131440           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsDistributeSimdStatement::pool_size; ++i )
  131441             :              {
  131442             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  131443             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  131444             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  131445             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  131446             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  131447             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  131448             :             // properly; so this will have to be checked next.
  131449             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  131450             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  131451           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  131452             :                   {
  131453           0 :                     pointer[i].set_freepointer((SgOmpTargetTeamsDistributeSimdStatement*)(globalIndex));
  131454           0 :                     globalIndex++;
  131455             :                   }
  131456             :                else
  131457             :                   {
  131458           0 :                     pointer[i].set_freepointer(NULL);
  131459             :                   }
  131460             :               }
  131461             :         }
  131462           5 :      return globalIndex;
  131463             :    }
  131464             : 
  131465             : //############################################################################
  131466             : // JH (01/14/2006)
  131467             : void
  131468           5 : SgOmpTargetTeamsDistributeSimdStatement::resetValidFreepointers( )
  131469             :    {
  131470           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  131471           5 :      SgOmpTargetTeamsDistributeSimdStatement* pointer = NULL;
  131472           5 :      std::vector < unsigned char* > :: const_iterator block;
  131473           5 :      SgOmpTargetTeamsDistributeSimdStatement* pointerOfLinkedList = NULL;
  131474           5 :      for ( block = SgOmpTargetTeamsDistributeSimdStatement::pools.begin(); block != SgOmpTargetTeamsDistributeSimdStatement::pools.end() ; ++block )
  131475             :         {
  131476           0 :           pointer = (SgOmpTargetTeamsDistributeSimdStatement*)(*block);
  131477           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsDistributeSimdStatement::pool_size; ++i )
  131478             :              {
  131479             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  131480             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  131481             :             // memory blocks!.
  131482           0 :                if ( pointer[i].get_freepointer() != NULL )
  131483             :                   {
  131484           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  131485             :                   }
  131486             :                else
  131487             :                   {
  131488           0 :                     if ( pointerOfLinkedList == NULL )
  131489             :                        {
  131490           0 :                          SgOmpTargetTeamsDistributeSimdStatement::next_node = &(pointer[i]);
  131491             :                        }
  131492             :                     else
  131493             :                        {
  131494             :                       // printf ("In SgOmpTargetTeamsDistributeSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  131495           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  131496             :                        }
  131497             :                     pointerOfLinkedList = &(pointer[i]);
  131498             :                   }
  131499             :               }
  131500             :         }
  131501             : 
  131502           5 :      if ( pointerOfLinkedList != NULL )
  131503             :         {
  131504             :        // printf ("In SgOmpTargetTeamsDistributeSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  131505           0 :           pointerOfLinkedList->set_freepointer(NULL);
  131506             :        // DQ (6/6/2010): Temporary debugging...
  131507             :        //   ROSE_ASSERT(false);
  131508             :         }
  131509             : 
  131510           5 :      return ;
  131511             :    }
  131512             : 
  131513             : //############################################################################
  131514             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  131515             :  * within the memory pool and resets the freepointers, in order to achieve a 
  131516             :  * linked list, that has no jumps and starts at the beginning! This function 
  131517             :  * does not extend the memory pool, since we do not delete any memory blocks,
  131518             :  * but delete the valid objects.  
  131519             :  */
  131520             : void
  131521           0 : SgOmpTargetTeamsDistributeSimdStatement::clearMemoryPool( )
  131522             :    {
  131523             :   // printf ("Inside of SgOmpTargetTeamsDistributeSimdStatement::clearMemoryPool() \n");
  131524             : 
  131525           0 :      SgOmpTargetTeamsDistributeSimdStatement* pointer = NULL, *tempPointer = NULL;
  131526           0 :      std::vector < unsigned char* > :: const_iterator block;
  131527           0 :      if ( SgOmpTargetTeamsDistributeSimdStatement::pools.empty() == false )
  131528             :         {
  131529           0 :           block = SgOmpTargetTeamsDistributeSimdStatement::pools.begin() ;
  131530           0 :           SgOmpTargetTeamsDistributeSimdStatement::next_node = (SgOmpTargetTeamsDistributeSimdStatement*) (*block);
  131531             : 
  131532           0 :           while ( block != SgOmpTargetTeamsDistributeSimdStatement::pools.end() )
  131533             :              {
  131534           0 :                pointer = (SgOmpTargetTeamsDistributeSimdStatement*) (*block);
  131535           0 :                if ( tempPointer != NULL )
  131536             :                   {
  131537           0 :                     tempPointer->set_freepointer(pointer);
  131538             :                   }
  131539           0 :                for (unsigned i = 0; i < SgOmpTargetTeamsDistributeSimdStatement::pool_size - 1; ++i)
  131540             :                   {
  131541           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  131542             :                   }
  131543           0 :                 pointer[SgOmpTargetTeamsDistributeSimdStatement::pool_size-1].set_freepointer(NULL);
  131544           0 :                 tempPointer = &(pointer[SgOmpTargetTeamsDistributeSimdStatement::pool_size-1]);
  131545           0 :                 ++block;
  131546             :              }
  131547             :         }
  131548           0 :    }
  131549             : 
  131550           5 : void SgOmpTargetTeamsDistributeSimdStatement::deleteMemoryPool() {
  131551           5 :   for (auto p: SgOmpTargetTeamsDistributeSimdStatement::pools) {
  131552           0 :     ROSE_FREE(p);
  131553             :   }
  131554           5 :   SgOmpTargetTeamsDistributeSimdStatement::next_node = nullptr;
  131555           5 :   SgOmpTargetTeamsDistributeSimdStatement::pools.clear();
  131556           5 : }
  131557             : 
  131558             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  131559             : //                 reading multiple binary files to for a single AST.
  131560             : /////////// new version ////////////////////////////////
  131561             : //############################################################################
  131562             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  131563             : void
  131564           2 : SgOmpTargetTeamsDistributeSimdStatement::extendMemoryPoolForFileIO( )
  131565             :   {
  131566           2 :     size_t blockIndex = SgOmpTargetTeamsDistributeSimdStatement::pools.size();
  131567           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeSimdStatement);
  131568             : 
  131569           2 :     while ( (blockIndex * SgOmpTargetTeamsDistributeSimdStatement::pool_size) < newPoolSize)
  131570             :       {
  131571             : #if ROSE_ALLOC_TRACE
  131572             :         if (blockIndex > 0) {
  131573             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeSimdStatement) = %" PRIuPTR " SgOmpTargetTeamsDistributeSimdStatement::pool_size = %d \n",
  131574             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeSimdStatement),SgOmpTargetTeamsDistributeSimdStatement::pool_size);
  131575             :         }
  131576             : #endif
  131577             : 
  131578           0 :         SgOmpTargetTeamsDistributeSimdStatement * pointer = (SgOmpTargetTeamsDistributeSimdStatement*) ROSE_MALLOC ( SgOmpTargetTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeSimdStatement) );
  131579           0 :         assert( pointer != NULL );
  131580             : #if ROSE_ALLOC_MEMSET == 1
  131581             :         memset(pointer, 0x00, SgOmpTargetTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeSimdStatement));
  131582             : #elif ROSE_ALLOC_MEMSET == 2
  131583             :         memset(pointer, 0xCC, SgOmpTargetTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeSimdStatement));
  131584             : #endif
  131585           0 :         SgOmpTargetTeamsDistributeSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  131586           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeSimdStatement), V_SgOmpTargetTeamsDistributeSimdStatement ) );
  131587             : 
  131588           0 :         if ( SgOmpTargetTeamsDistributeSimdStatement::next_node != NULL ) {
  131589           0 :           if ( blockIndex > 0 ) {
  131590           0 :             SgOmpTargetTeamsDistributeSimdStatement * blkptr = (SgOmpTargetTeamsDistributeSimdStatement*)(SgOmpTargetTeamsDistributeSimdStatement::pools[blockIndex-1]);
  131591           0 :             blkptr[ SgOmpTargetTeamsDistributeSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  131592             :           }
  131593             :         } else {
  131594           0 :           SgOmpTargetTeamsDistributeSimdStatement::next_node = pointer;
  131595             :         }
  131596             : 
  131597           0 :         for (unsigned i = 0; i < SgOmpTargetTeamsDistributeSimdStatement::pool_size-1; ++i)
  131598             :            {
  131599           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  131600             :            }
  131601           0 :         pointer[ SgOmpTargetTeamsDistributeSimdStatement::pool_size -1 ].set_freepointer(NULL);
  131602             : 
  131603           0 :         blockIndex++;
  131604             :       }
  131605           2 :   }
  131606             : 
  131607             : //############################################################################
  131608             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  131609             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  131610             :  * not compressed. However, that stuff is not yet implemented! 
  131611             :  */
  131612             : unsigned long
  131613           0 : SgOmpTargetTeamsDistributeSimdStatement::getNumberOfLastValidPointer()
  131614             :    {
  131615           0 :       SgOmpTargetTeamsDistributeSimdStatement* testPointer = (SgOmpTargetTeamsDistributeSimdStatement*)(SgOmpTargetTeamsDistributeSimdStatement::pools.back());
  131616           0 :       unsigned long localIndex = SgOmpTargetTeamsDistributeSimdStatement::pool_size - 1;
  131617           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  131618             :          {
  131619           0 :            localIndex--;
  131620             :          }
  131621           0 :       return (localIndex + SgOmpTargetTeamsDistributeSimdStatement::pool_size * (SgOmpTargetTeamsDistributeSimdStatement::pools.size()-1));
  131622             :    }
  131623             : 
  131624             : //############################################################################
  131625             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  131626             :  * memory pool and initializes the data member in class SgOmpTargetTeamsDistributeSimdStatementStroageClass
  131627             :  * from its counterpart of SgOmpTargetTeamsDistributeSimdStatement. The return value is just for checking, 
  131628             :  * that the whole StorageClassArray is initialized!
  131629             :  */
  131630             : unsigned long
  131631           0 : SgOmpTargetTeamsDistributeSimdStatement::initializeStorageClassArray( SgOmpTargetTeamsDistributeSimdStatementStorageClass *storageArray )
  131632             :    {
  131633           0 :      unsigned long storageCounter = 0;
  131634           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetTeamsDistributeSimdStatement::pools.begin();
  131635           0 :      SgOmpTargetTeamsDistributeSimdStatement* pointer = NULL;
  131636           0 :      while ( block != SgOmpTargetTeamsDistributeSimdStatement::pools.end() ) {
  131637           0 :           pointer = (SgOmpTargetTeamsDistributeSimdStatement*) (*block);
  131638           0 :           for ( unsigned i = 0; i < SgOmpTargetTeamsDistributeSimdStatement::pool_size; ++i ) {
  131639           0 :                if ( pointer->get_freepointer() != NULL ) {
  131640           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  131641           0 :                  storageArray++;
  131642           0 :                  storageCounter++;
  131643             :                }
  131644           0 :                pointer++;
  131645             :              }
  131646           0 :            block++;
  131647             :         }
  131648           0 :      return storageCounter;
  131649             :    }
  131650             : 
  131651             : /* #line 131652 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  131652             : 
  131653             : 
  131654             : 
  131655             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  131656             : 
  131657             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  131658             : 
  131659             : //############################################################################
  131660             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetTeamsLoopStatement that takes its 
  131661             :  * corresponding StorageClass as parameter
  131662             :  */
  131663           0 : SgOmpTargetTeamsLoopStatement :: SgOmpTargetTeamsLoopStatement ( const SgOmpTargetTeamsLoopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  131664             :    {
  131665             : 
  131666             : 
  131667             : /* #line 131668 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  131668             : 
  131669           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  131670             : 
  131671             : 
  131672             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  131673             : 
  131674             : 
  131675           0 :    }
  131676             : 
  131677             : //############################################################################
  131678             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  131679             :  * within the working AST. 
  131680             :  */
  131681           0 : SgOmpTargetTeamsLoopStatement * SgOmpTargetTeamsLoopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  131682           0 :      SgOmpTargetTeamsLoopStatement* returnPointer = NULL;
  131683           0 :      if ( globalIndex != 0 )
  131684             :         {
  131685             : 
  131686             : #if FILE_IO_EXTRA_CHECK
  131687           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetTeamsLoopStatement ) ) <= globalIndex ) ;
  131688           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsLoopStatement + 1 ) ) );
  131689             : #endif
  131690           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsLoopStatement )  
  131691           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetTeamsLoopStatement );
  131692           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsLoopStatement::pool_size;
  131693           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsLoopStatement::pool_size;
  131694             : 
  131695             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  131696             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  131697             : 
  131698           0 :           returnPointer = &( ( (SgOmpTargetTeamsLoopStatement*)(SgOmpTargetTeamsLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  131699             : 
  131700           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  131701             :         }
  131702           0 :      return returnPointer ;
  131703             :    }
  131704             : 
  131705             : //############################################################################
  131706             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  131707             :   for the AST with the index astIndex
  131708             : */
  131709           0 : SgOmpTargetTeamsLoopStatement * SgOmpTargetTeamsLoopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  131710           0 :      SgOmpTargetTeamsLoopStatement* returnPointer = NULL;
  131711           0 :      if ( globalIndex != 0 )
  131712             :         {
  131713             : 
  131714             : #if FILE_IO_EXTRA_CHECK
  131715           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetTeamsLoopStatement ) ) <= globalIndex ) ;
  131716           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsLoopStatement + 1 ) ) );
  131717             : #endif
  131718           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsLoopStatement )
  131719           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetTeamsLoopStatement );
  131720           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsLoopStatement::pool_size ;
  131721           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsLoopStatement::pool_size ;
  131722             : 
  131723             : #if FILE_IO_EXTRA_CHECK
  131724             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  131725             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  131726             : #endif
  131727             : 
  131728           0 :           returnPointer = &( ( (SgOmpTargetTeamsLoopStatement*)(SgOmpTargetTeamsLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  131729             : 
  131730             : #if FILE_IO_EXTRA_CHECK
  131731           0 :           assert ( returnPointer != NULL ) ;
  131732             : #endif
  131733             :         }
  131734           0 :      return returnPointer ;
  131735             :    }
  131736             : 
  131737             : //############################################################################
  131738             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  131739             :  * pool size! We set for every valid object in the memory pool the freepointer
  131740             :  * to the global index and increase the global index afterwards. For all the 
  131741             :  * invalid objects (means address ranges within the memory pool that were not
  131742             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  131743             :  * distinguish valid from invalid objects! 
  131744             :  */
  131745             : unsigned long
  131746           5 : SgOmpTargetTeamsLoopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  131747             :    {
  131748           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  131749           5 :      SgOmpTargetTeamsLoopStatement* pointer = NULL;
  131750           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  131751           5 :      std::vector < unsigned char* > :: const_iterator block;
  131752           5 :      for ( block = SgOmpTargetTeamsLoopStatement::pools.begin(); block != SgOmpTargetTeamsLoopStatement::pools.end() ; ++block )
  131753             :         {
  131754           0 :           pointer = (SgOmpTargetTeamsLoopStatement*)(*block);
  131755           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsLoopStatement::pool_size; ++i )
  131756             :              {
  131757             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  131758             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  131759             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  131760             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  131761             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  131762             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  131763             :             // properly; so this will have to be checked next.
  131764             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  131765             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  131766           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  131767             :                   {
  131768           0 :                     pointer[i].set_freepointer((SgOmpTargetTeamsLoopStatement*)(globalIndex));
  131769           0 :                     globalIndex++;
  131770             :                   }
  131771             :                else
  131772             :                   {
  131773           0 :                     pointer[i].set_freepointer(NULL);
  131774             :                   }
  131775             :               }
  131776             :         }
  131777           5 :      return globalIndex;
  131778             :    }
  131779             : 
  131780             : //############################################################################
  131781             : // JH (01/14/2006)
  131782             : void
  131783           5 : SgOmpTargetTeamsLoopStatement::resetValidFreepointers( )
  131784             :    {
  131785           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  131786           5 :      SgOmpTargetTeamsLoopStatement* pointer = NULL;
  131787           5 :      std::vector < unsigned char* > :: const_iterator block;
  131788           5 :      SgOmpTargetTeamsLoopStatement* pointerOfLinkedList = NULL;
  131789           5 :      for ( block = SgOmpTargetTeamsLoopStatement::pools.begin(); block != SgOmpTargetTeamsLoopStatement::pools.end() ; ++block )
  131790             :         {
  131791           0 :           pointer = (SgOmpTargetTeamsLoopStatement*)(*block);
  131792           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsLoopStatement::pool_size; ++i )
  131793             :              {
  131794             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  131795             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  131796             :             // memory blocks!.
  131797           0 :                if ( pointer[i].get_freepointer() != NULL )
  131798             :                   {
  131799           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  131800             :                   }
  131801             :                else
  131802             :                   {
  131803           0 :                     if ( pointerOfLinkedList == NULL )
  131804             :                        {
  131805           0 :                          SgOmpTargetTeamsLoopStatement::next_node = &(pointer[i]);
  131806             :                        }
  131807             :                     else
  131808             :                        {
  131809             :                       // printf ("In SgOmpTargetTeamsLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  131810           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  131811             :                        }
  131812             :                     pointerOfLinkedList = &(pointer[i]);
  131813             :                   }
  131814             :               }
  131815             :         }
  131816             : 
  131817           5 :      if ( pointerOfLinkedList != NULL )
  131818             :         {
  131819             :        // printf ("In SgOmpTargetTeamsLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  131820           0 :           pointerOfLinkedList->set_freepointer(NULL);
  131821             :        // DQ (6/6/2010): Temporary debugging...
  131822             :        //   ROSE_ASSERT(false);
  131823             :         }
  131824             : 
  131825           5 :      return ;
  131826             :    }
  131827             : 
  131828             : //############################################################################
  131829             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  131830             :  * within the memory pool and resets the freepointers, in order to achieve a 
  131831             :  * linked list, that has no jumps and starts at the beginning! This function 
  131832             :  * does not extend the memory pool, since we do not delete any memory blocks,
  131833             :  * but delete the valid objects.  
  131834             :  */
  131835             : void
  131836           0 : SgOmpTargetTeamsLoopStatement::clearMemoryPool( )
  131837             :    {
  131838             :   // printf ("Inside of SgOmpTargetTeamsLoopStatement::clearMemoryPool() \n");
  131839             : 
  131840           0 :      SgOmpTargetTeamsLoopStatement* pointer = NULL, *tempPointer = NULL;
  131841           0 :      std::vector < unsigned char* > :: const_iterator block;
  131842           0 :      if ( SgOmpTargetTeamsLoopStatement::pools.empty() == false )
  131843             :         {
  131844           0 :           block = SgOmpTargetTeamsLoopStatement::pools.begin() ;
  131845           0 :           SgOmpTargetTeamsLoopStatement::next_node = (SgOmpTargetTeamsLoopStatement*) (*block);
  131846             : 
  131847           0 :           while ( block != SgOmpTargetTeamsLoopStatement::pools.end() )
  131848             :              {
  131849           0 :                pointer = (SgOmpTargetTeamsLoopStatement*) (*block);
  131850           0 :                if ( tempPointer != NULL )
  131851             :                   {
  131852           0 :                     tempPointer->set_freepointer(pointer);
  131853             :                   }
  131854           0 :                for (unsigned i = 0; i < SgOmpTargetTeamsLoopStatement::pool_size - 1; ++i)
  131855             :                   {
  131856           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  131857             :                   }
  131858           0 :                 pointer[SgOmpTargetTeamsLoopStatement::pool_size-1].set_freepointer(NULL);
  131859           0 :                 tempPointer = &(pointer[SgOmpTargetTeamsLoopStatement::pool_size-1]);
  131860           0 :                 ++block;
  131861             :              }
  131862             :         }
  131863           0 :    }
  131864             : 
  131865           5 : void SgOmpTargetTeamsLoopStatement::deleteMemoryPool() {
  131866           5 :   for (auto p: SgOmpTargetTeamsLoopStatement::pools) {
  131867           0 :     ROSE_FREE(p);
  131868             :   }
  131869           5 :   SgOmpTargetTeamsLoopStatement::next_node = nullptr;
  131870           5 :   SgOmpTargetTeamsLoopStatement::pools.clear();
  131871           5 : }
  131872             : 
  131873             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  131874             : //                 reading multiple binary files to for a single AST.
  131875             : /////////// new version ////////////////////////////////
  131876             : //############################################################################
  131877             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  131878             : void
  131879           2 : SgOmpTargetTeamsLoopStatement::extendMemoryPoolForFileIO( )
  131880             :   {
  131881           2 :     size_t blockIndex = SgOmpTargetTeamsLoopStatement::pools.size();
  131882           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsLoopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsLoopStatement);
  131883             : 
  131884           2 :     while ( (blockIndex * SgOmpTargetTeamsLoopStatement::pool_size) < newPoolSize)
  131885             :       {
  131886             : #if ROSE_ALLOC_TRACE
  131887             :         if (blockIndex > 0) {
  131888             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsLoopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsLoopStatement) = %" PRIuPTR " SgOmpTargetTeamsLoopStatement::pool_size = %d \n",
  131889             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsLoopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsLoopStatement),SgOmpTargetTeamsLoopStatement::pool_size);
  131890             :         }
  131891             : #endif
  131892             : 
  131893           0 :         SgOmpTargetTeamsLoopStatement * pointer = (SgOmpTargetTeamsLoopStatement*) ROSE_MALLOC ( SgOmpTargetTeamsLoopStatement::pool_size * sizeof(SgOmpTargetTeamsLoopStatement) );
  131894           0 :         assert( pointer != NULL );
  131895             : #if ROSE_ALLOC_MEMSET == 1
  131896             :         memset(pointer, 0x00, SgOmpTargetTeamsLoopStatement::pool_size * sizeof(SgOmpTargetTeamsLoopStatement));
  131897             : #elif ROSE_ALLOC_MEMSET == 2
  131898             :         memset(pointer, 0xCC, SgOmpTargetTeamsLoopStatement::pool_size * sizeof(SgOmpTargetTeamsLoopStatement));
  131899             : #endif
  131900           0 :         SgOmpTargetTeamsLoopStatement::pools.push_back( (unsigned char*)(pointer) );
  131901           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetTeamsLoopStatement::pool_size * sizeof(SgOmpTargetTeamsLoopStatement), V_SgOmpTargetTeamsLoopStatement ) );
  131902             : 
  131903           0 :         if ( SgOmpTargetTeamsLoopStatement::next_node != NULL ) {
  131904           0 :           if ( blockIndex > 0 ) {
  131905           0 :             SgOmpTargetTeamsLoopStatement * blkptr = (SgOmpTargetTeamsLoopStatement*)(SgOmpTargetTeamsLoopStatement::pools[blockIndex-1]);
  131906           0 :             blkptr[ SgOmpTargetTeamsLoopStatement::pool_size - 1 ].set_freepointer(pointer);
  131907             :           }
  131908             :         } else {
  131909           0 :           SgOmpTargetTeamsLoopStatement::next_node = pointer;
  131910             :         }
  131911             : 
  131912           0 :         for (unsigned i = 0; i < SgOmpTargetTeamsLoopStatement::pool_size-1; ++i)
  131913             :            {
  131914           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  131915             :            }
  131916           0 :         pointer[ SgOmpTargetTeamsLoopStatement::pool_size -1 ].set_freepointer(NULL);
  131917             : 
  131918           0 :         blockIndex++;
  131919             :       }
  131920           2 :   }
  131921             : 
  131922             : //############################################################################
  131923             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  131924             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  131925             :  * not compressed. However, that stuff is not yet implemented! 
  131926             :  */
  131927             : unsigned long
  131928           0 : SgOmpTargetTeamsLoopStatement::getNumberOfLastValidPointer()
  131929             :    {
  131930           0 :       SgOmpTargetTeamsLoopStatement* testPointer = (SgOmpTargetTeamsLoopStatement*)(SgOmpTargetTeamsLoopStatement::pools.back());
  131931           0 :       unsigned long localIndex = SgOmpTargetTeamsLoopStatement::pool_size - 1;
  131932           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  131933             :          {
  131934           0 :            localIndex--;
  131935             :          }
  131936           0 :       return (localIndex + SgOmpTargetTeamsLoopStatement::pool_size * (SgOmpTargetTeamsLoopStatement::pools.size()-1));
  131937             :    }
  131938             : 
  131939             : //############################################################################
  131940             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  131941             :  * memory pool and initializes the data member in class SgOmpTargetTeamsLoopStatementStroageClass
  131942             :  * from its counterpart of SgOmpTargetTeamsLoopStatement. The return value is just for checking, 
  131943             :  * that the whole StorageClassArray is initialized!
  131944             :  */
  131945             : unsigned long
  131946           0 : SgOmpTargetTeamsLoopStatement::initializeStorageClassArray( SgOmpTargetTeamsLoopStatementStorageClass *storageArray )
  131947             :    {
  131948           0 :      unsigned long storageCounter = 0;
  131949           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetTeamsLoopStatement::pools.begin();
  131950           0 :      SgOmpTargetTeamsLoopStatement* pointer = NULL;
  131951           0 :      while ( block != SgOmpTargetTeamsLoopStatement::pools.end() ) {
  131952           0 :           pointer = (SgOmpTargetTeamsLoopStatement*) (*block);
  131953           0 :           for ( unsigned i = 0; i < SgOmpTargetTeamsLoopStatement::pool_size; ++i ) {
  131954           0 :                if ( pointer->get_freepointer() != NULL ) {
  131955           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  131956           0 :                  storageArray++;
  131957           0 :                  storageCounter++;
  131958             :                }
  131959           0 :                pointer++;
  131960             :              }
  131961           0 :            block++;
  131962             :         }
  131963           0 :      return storageCounter;
  131964             :    }
  131965             : 
  131966             : /* #line 131967 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  131967             : 
  131968             : 
  131969             : 
  131970             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  131971             : 
  131972             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  131973             : 
  131974             : //############################################################################
  131975             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetTeamsDistributeParallelForStatement that takes its 
  131976             :  * corresponding StorageClass as parameter
  131977             :  */
  131978           0 : SgOmpTargetTeamsDistributeParallelForStatement :: SgOmpTargetTeamsDistributeParallelForStatement ( const SgOmpTargetTeamsDistributeParallelForStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  131979             :    {
  131980             : 
  131981             : 
  131982             : /* #line 131983 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  131983             : 
  131984           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  131985             : 
  131986             : 
  131987             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  131988             : 
  131989             : 
  131990           0 :    }
  131991             : 
  131992             : //############################################################################
  131993             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  131994             :  * within the working AST. 
  131995             :  */
  131996           0 : SgOmpTargetTeamsDistributeParallelForStatement * SgOmpTargetTeamsDistributeParallelForStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  131997           0 :      SgOmpTargetTeamsDistributeParallelForStatement* returnPointer = NULL;
  131998           0 :      if ( globalIndex != 0 )
  131999             :         {
  132000             : 
  132001             : #if FILE_IO_EXTRA_CHECK
  132002           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetTeamsDistributeParallelForStatement ) ) <= globalIndex ) ;
  132003           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsDistributeParallelForStatement + 1 ) ) );
  132004             : #endif
  132005           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsDistributeParallelForStatement )  
  132006           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetTeamsDistributeParallelForStatement );
  132007           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsDistributeParallelForStatement::pool_size;
  132008           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsDistributeParallelForStatement::pool_size;
  132009             : 
  132010             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  132011             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  132012             : 
  132013           0 :           returnPointer = &( ( (SgOmpTargetTeamsDistributeParallelForStatement*)(SgOmpTargetTeamsDistributeParallelForStatement::pools[memoryBlock]) ) [positionInPool]) ;
  132014             : 
  132015           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  132016             :         }
  132017           0 :      return returnPointer ;
  132018             :    }
  132019             : 
  132020             : //############################################################################
  132021             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  132022             :   for the AST with the index astIndex
  132023             : */
  132024           0 : SgOmpTargetTeamsDistributeParallelForStatement * SgOmpTargetTeamsDistributeParallelForStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  132025           0 :      SgOmpTargetTeamsDistributeParallelForStatement* returnPointer = NULL;
  132026           0 :      if ( globalIndex != 0 )
  132027             :         {
  132028             : 
  132029             : #if FILE_IO_EXTRA_CHECK
  132030           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetTeamsDistributeParallelForStatement ) ) <= globalIndex ) ;
  132031           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsDistributeParallelForStatement + 1 ) ) );
  132032             : #endif
  132033           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsDistributeParallelForStatement )
  132034           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetTeamsDistributeParallelForStatement );
  132035           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsDistributeParallelForStatement::pool_size ;
  132036           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsDistributeParallelForStatement::pool_size ;
  132037             : 
  132038             : #if FILE_IO_EXTRA_CHECK
  132039             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  132040             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  132041             : #endif
  132042             : 
  132043           0 :           returnPointer = &( ( (SgOmpTargetTeamsDistributeParallelForStatement*)(SgOmpTargetTeamsDistributeParallelForStatement::pools[memoryBlock]) ) [positionInPool]) ;
  132044             : 
  132045             : #if FILE_IO_EXTRA_CHECK
  132046           0 :           assert ( returnPointer != NULL ) ;
  132047             : #endif
  132048             :         }
  132049           0 :      return returnPointer ;
  132050             :    }
  132051             : 
  132052             : //############################################################################
  132053             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  132054             :  * pool size! We set for every valid object in the memory pool the freepointer
  132055             :  * to the global index and increase the global index afterwards. For all the 
  132056             :  * invalid objects (means address ranges within the memory pool that were not
  132057             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  132058             :  * distinguish valid from invalid objects! 
  132059             :  */
  132060             : unsigned long
  132061           5 : SgOmpTargetTeamsDistributeParallelForStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  132062             :    {
  132063           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  132064           5 :      SgOmpTargetTeamsDistributeParallelForStatement* pointer = NULL;
  132065           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  132066           5 :      std::vector < unsigned char* > :: const_iterator block;
  132067           5 :      for ( block = SgOmpTargetTeamsDistributeParallelForStatement::pools.begin(); block != SgOmpTargetTeamsDistributeParallelForStatement::pools.end() ; ++block )
  132068             :         {
  132069           0 :           pointer = (SgOmpTargetTeamsDistributeParallelForStatement*)(*block);
  132070           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForStatement::pool_size; ++i )
  132071             :              {
  132072             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  132073             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  132074             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  132075             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  132076             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  132077             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  132078             :             // properly; so this will have to be checked next.
  132079             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  132080             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  132081           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  132082             :                   {
  132083           0 :                     pointer[i].set_freepointer((SgOmpTargetTeamsDistributeParallelForStatement*)(globalIndex));
  132084           0 :                     globalIndex++;
  132085             :                   }
  132086             :                else
  132087             :                   {
  132088           0 :                     pointer[i].set_freepointer(NULL);
  132089             :                   }
  132090             :               }
  132091             :         }
  132092           5 :      return globalIndex;
  132093             :    }
  132094             : 
  132095             : //############################################################################
  132096             : // JH (01/14/2006)
  132097             : void
  132098           5 : SgOmpTargetTeamsDistributeParallelForStatement::resetValidFreepointers( )
  132099             :    {
  132100           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  132101           5 :      SgOmpTargetTeamsDistributeParallelForStatement* pointer = NULL;
  132102           5 :      std::vector < unsigned char* > :: const_iterator block;
  132103           5 :      SgOmpTargetTeamsDistributeParallelForStatement* pointerOfLinkedList = NULL;
  132104           5 :      for ( block = SgOmpTargetTeamsDistributeParallelForStatement::pools.begin(); block != SgOmpTargetTeamsDistributeParallelForStatement::pools.end() ; ++block )
  132105             :         {
  132106           0 :           pointer = (SgOmpTargetTeamsDistributeParallelForStatement*)(*block);
  132107           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForStatement::pool_size; ++i )
  132108             :              {
  132109             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  132110             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  132111             :             // memory blocks!.
  132112           0 :                if ( pointer[i].get_freepointer() != NULL )
  132113             :                   {
  132114           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  132115             :                   }
  132116             :                else
  132117             :                   {
  132118           0 :                     if ( pointerOfLinkedList == NULL )
  132119             :                        {
  132120           0 :                          SgOmpTargetTeamsDistributeParallelForStatement::next_node = &(pointer[i]);
  132121             :                        }
  132122             :                     else
  132123             :                        {
  132124             :                       // printf ("In SgOmpTargetTeamsDistributeParallelForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  132125           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  132126             :                        }
  132127             :                     pointerOfLinkedList = &(pointer[i]);
  132128             :                   }
  132129             :               }
  132130             :         }
  132131             : 
  132132           5 :      if ( pointerOfLinkedList != NULL )
  132133             :         {
  132134             :        // printf ("In SgOmpTargetTeamsDistributeParallelForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  132135           0 :           pointerOfLinkedList->set_freepointer(NULL);
  132136             :        // DQ (6/6/2010): Temporary debugging...
  132137             :        //   ROSE_ASSERT(false);
  132138             :         }
  132139             : 
  132140           5 :      return ;
  132141             :    }
  132142             : 
  132143             : //############################################################################
  132144             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  132145             :  * within the memory pool and resets the freepointers, in order to achieve a 
  132146             :  * linked list, that has no jumps and starts at the beginning! This function 
  132147             :  * does not extend the memory pool, since we do not delete any memory blocks,
  132148             :  * but delete the valid objects.  
  132149             :  */
  132150             : void
  132151           0 : SgOmpTargetTeamsDistributeParallelForStatement::clearMemoryPool( )
  132152             :    {
  132153             :   // printf ("Inside of SgOmpTargetTeamsDistributeParallelForStatement::clearMemoryPool() \n");
  132154             : 
  132155           0 :      SgOmpTargetTeamsDistributeParallelForStatement* pointer = NULL, *tempPointer = NULL;
  132156           0 :      std::vector < unsigned char* > :: const_iterator block;
  132157           0 :      if ( SgOmpTargetTeamsDistributeParallelForStatement::pools.empty() == false )
  132158             :         {
  132159           0 :           block = SgOmpTargetTeamsDistributeParallelForStatement::pools.begin() ;
  132160           0 :           SgOmpTargetTeamsDistributeParallelForStatement::next_node = (SgOmpTargetTeamsDistributeParallelForStatement*) (*block);
  132161             : 
  132162           0 :           while ( block != SgOmpTargetTeamsDistributeParallelForStatement::pools.end() )
  132163             :              {
  132164           0 :                pointer = (SgOmpTargetTeamsDistributeParallelForStatement*) (*block);
  132165           0 :                if ( tempPointer != NULL )
  132166             :                   {
  132167           0 :                     tempPointer->set_freepointer(pointer);
  132168             :                   }
  132169           0 :                for (unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForStatement::pool_size - 1; ++i)
  132170             :                   {
  132171           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  132172             :                   }
  132173           0 :                 pointer[SgOmpTargetTeamsDistributeParallelForStatement::pool_size-1].set_freepointer(NULL);
  132174           0 :                 tempPointer = &(pointer[SgOmpTargetTeamsDistributeParallelForStatement::pool_size-1]);
  132175           0 :                 ++block;
  132176             :              }
  132177             :         }
  132178           0 :    }
  132179             : 
  132180           5 : void SgOmpTargetTeamsDistributeParallelForStatement::deleteMemoryPool() {
  132181           5 :   for (auto p: SgOmpTargetTeamsDistributeParallelForStatement::pools) {
  132182           0 :     ROSE_FREE(p);
  132183             :   }
  132184           5 :   SgOmpTargetTeamsDistributeParallelForStatement::next_node = nullptr;
  132185           5 :   SgOmpTargetTeamsDistributeParallelForStatement::pools.clear();
  132186           5 : }
  132187             : 
  132188             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  132189             : //                 reading multiple binary files to for a single AST.
  132190             : /////////// new version ////////////////////////////////
  132191             : //############################################################################
  132192             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  132193             : void
  132194           2 : SgOmpTargetTeamsDistributeParallelForStatement::extendMemoryPoolForFileIO( )
  132195             :   {
  132196           2 :     size_t blockIndex = SgOmpTargetTeamsDistributeParallelForStatement::pools.size();
  132197           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeParallelForStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeParallelForStatement);
  132198             : 
  132199           2 :     while ( (blockIndex * SgOmpTargetTeamsDistributeParallelForStatement::pool_size) < newPoolSize)
  132200             :       {
  132201             : #if ROSE_ALLOC_TRACE
  132202             :         if (blockIndex > 0) {
  132203             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeParallelForStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeParallelForStatement) = %" PRIuPTR " SgOmpTargetTeamsDistributeParallelForStatement::pool_size = %d \n",
  132204             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeParallelForStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeParallelForStatement),SgOmpTargetTeamsDistributeParallelForStatement::pool_size);
  132205             :         }
  132206             : #endif
  132207             : 
  132208           0 :         SgOmpTargetTeamsDistributeParallelForStatement * pointer = (SgOmpTargetTeamsDistributeParallelForStatement*) ROSE_MALLOC ( SgOmpTargetTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForStatement) );
  132209           0 :         assert( pointer != NULL );
  132210             : #if ROSE_ALLOC_MEMSET == 1
  132211             :         memset(pointer, 0x00, SgOmpTargetTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForStatement));
  132212             : #elif ROSE_ALLOC_MEMSET == 2
  132213             :         memset(pointer, 0xCC, SgOmpTargetTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForStatement));
  132214             : #endif
  132215           0 :         SgOmpTargetTeamsDistributeParallelForStatement::pools.push_back( (unsigned char*)(pointer) );
  132216           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForStatement), V_SgOmpTargetTeamsDistributeParallelForStatement ) );
  132217             : 
  132218           0 :         if ( SgOmpTargetTeamsDistributeParallelForStatement::next_node != NULL ) {
  132219           0 :           if ( blockIndex > 0 ) {
  132220           0 :             SgOmpTargetTeamsDistributeParallelForStatement * blkptr = (SgOmpTargetTeamsDistributeParallelForStatement*)(SgOmpTargetTeamsDistributeParallelForStatement::pools[blockIndex-1]);
  132221           0 :             blkptr[ SgOmpTargetTeamsDistributeParallelForStatement::pool_size - 1 ].set_freepointer(pointer);
  132222             :           }
  132223             :         } else {
  132224           0 :           SgOmpTargetTeamsDistributeParallelForStatement::next_node = pointer;
  132225             :         }
  132226             : 
  132227           0 :         for (unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForStatement::pool_size-1; ++i)
  132228             :            {
  132229           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  132230             :            }
  132231           0 :         pointer[ SgOmpTargetTeamsDistributeParallelForStatement::pool_size -1 ].set_freepointer(NULL);
  132232             : 
  132233           0 :         blockIndex++;
  132234             :       }
  132235           2 :   }
  132236             : 
  132237             : //############################################################################
  132238             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  132239             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  132240             :  * not compressed. However, that stuff is not yet implemented! 
  132241             :  */
  132242             : unsigned long
  132243           0 : SgOmpTargetTeamsDistributeParallelForStatement::getNumberOfLastValidPointer()
  132244             :    {
  132245           0 :       SgOmpTargetTeamsDistributeParallelForStatement* testPointer = (SgOmpTargetTeamsDistributeParallelForStatement*)(SgOmpTargetTeamsDistributeParallelForStatement::pools.back());
  132246           0 :       unsigned long localIndex = SgOmpTargetTeamsDistributeParallelForStatement::pool_size - 1;
  132247           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  132248             :          {
  132249           0 :            localIndex--;
  132250             :          }
  132251           0 :       return (localIndex + SgOmpTargetTeamsDistributeParallelForStatement::pool_size * (SgOmpTargetTeamsDistributeParallelForStatement::pools.size()-1));
  132252             :    }
  132253             : 
  132254             : //############################################################################
  132255             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  132256             :  * memory pool and initializes the data member in class SgOmpTargetTeamsDistributeParallelForStatementStroageClass
  132257             :  * from its counterpart of SgOmpTargetTeamsDistributeParallelForStatement. The return value is just for checking, 
  132258             :  * that the whole StorageClassArray is initialized!
  132259             :  */
  132260             : unsigned long
  132261           0 : SgOmpTargetTeamsDistributeParallelForStatement::initializeStorageClassArray( SgOmpTargetTeamsDistributeParallelForStatementStorageClass *storageArray )
  132262             :    {
  132263           0 :      unsigned long storageCounter = 0;
  132264           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetTeamsDistributeParallelForStatement::pools.begin();
  132265           0 :      SgOmpTargetTeamsDistributeParallelForStatement* pointer = NULL;
  132266           0 :      while ( block != SgOmpTargetTeamsDistributeParallelForStatement::pools.end() ) {
  132267           0 :           pointer = (SgOmpTargetTeamsDistributeParallelForStatement*) (*block);
  132268           0 :           for ( unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForStatement::pool_size; ++i ) {
  132269           0 :                if ( pointer->get_freepointer() != NULL ) {
  132270           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  132271           0 :                  storageArray++;
  132272           0 :                  storageCounter++;
  132273             :                }
  132274           0 :                pointer++;
  132275             :              }
  132276           0 :            block++;
  132277             :         }
  132278           0 :      return storageCounter;
  132279             :    }
  132280             : 
  132281             : /* #line 132282 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  132282             : 
  132283             : 
  132284             : 
  132285             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  132286             : 
  132287             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  132288             : 
  132289             : //############################################################################
  132290             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetTeamsDistributeParallelForSimdStatement that takes its 
  132291             :  * corresponding StorageClass as parameter
  132292             :  */
  132293           0 : SgOmpTargetTeamsDistributeParallelForSimdStatement :: SgOmpTargetTeamsDistributeParallelForSimdStatement ( const SgOmpTargetTeamsDistributeParallelForSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  132294             :    {
  132295             : 
  132296             : 
  132297             : /* #line 132298 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  132298             : 
  132299           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  132300             : 
  132301             : 
  132302             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  132303             : 
  132304             : 
  132305           0 :    }
  132306             : 
  132307             : //############################################################################
  132308             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  132309             :  * within the working AST. 
  132310             :  */
  132311           0 : SgOmpTargetTeamsDistributeParallelForSimdStatement * SgOmpTargetTeamsDistributeParallelForSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  132312           0 :      SgOmpTargetTeamsDistributeParallelForSimdStatement* returnPointer = NULL;
  132313           0 :      if ( globalIndex != 0 )
  132314             :         {
  132315             : 
  132316             : #if FILE_IO_EXTRA_CHECK
  132317           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetTeamsDistributeParallelForSimdStatement ) ) <= globalIndex ) ;
  132318           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsDistributeParallelForSimdStatement + 1 ) ) );
  132319             : #endif
  132320           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetTeamsDistributeParallelForSimdStatement )  
  132321           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetTeamsDistributeParallelForSimdStatement );
  132322           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size;
  132323           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size;
  132324             : 
  132325             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  132326             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  132327             : 
  132328           0 :           returnPointer = &( ( (SgOmpTargetTeamsDistributeParallelForSimdStatement*)(SgOmpTargetTeamsDistributeParallelForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  132329             : 
  132330           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  132331             :         }
  132332           0 :      return returnPointer ;
  132333             :    }
  132334             : 
  132335             : //############################################################################
  132336             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  132337             :   for the AST with the index astIndex
  132338             : */
  132339           0 : SgOmpTargetTeamsDistributeParallelForSimdStatement * SgOmpTargetTeamsDistributeParallelForSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  132340           0 :      SgOmpTargetTeamsDistributeParallelForSimdStatement* returnPointer = NULL;
  132341           0 :      if ( globalIndex != 0 )
  132342             :         {
  132343             : 
  132344             : #if FILE_IO_EXTRA_CHECK
  132345           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetTeamsDistributeParallelForSimdStatement ) ) <= globalIndex ) ;
  132346           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsDistributeParallelForSimdStatement + 1 ) ) );
  132347             : #endif
  132348           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetTeamsDistributeParallelForSimdStatement )
  132349           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetTeamsDistributeParallelForSimdStatement );
  132350           0 :           unsigned long positionInPool = localIndex % SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size ;
  132351           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size ;
  132352             : 
  132353             : #if FILE_IO_EXTRA_CHECK
  132354             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  132355             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  132356             : #endif
  132357             : 
  132358           0 :           returnPointer = &( ( (SgOmpTargetTeamsDistributeParallelForSimdStatement*)(SgOmpTargetTeamsDistributeParallelForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  132359             : 
  132360             : #if FILE_IO_EXTRA_CHECK
  132361           0 :           assert ( returnPointer != NULL ) ;
  132362             : #endif
  132363             :         }
  132364           0 :      return returnPointer ;
  132365             :    }
  132366             : 
  132367             : //############################################################################
  132368             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  132369             :  * pool size! We set for every valid object in the memory pool the freepointer
  132370             :  * to the global index and increase the global index afterwards. For all the 
  132371             :  * invalid objects (means address ranges within the memory pool that were not
  132372             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  132373             :  * distinguish valid from invalid objects! 
  132374             :  */
  132375             : unsigned long
  132376           5 : SgOmpTargetTeamsDistributeParallelForSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  132377             :    {
  132378           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  132379           5 :      SgOmpTargetTeamsDistributeParallelForSimdStatement* pointer = NULL;
  132380           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  132381           5 :      std::vector < unsigned char* > :: const_iterator block;
  132382           5 :      for ( block = SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.begin(); block != SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.end() ; ++block )
  132383             :         {
  132384           0 :           pointer = (SgOmpTargetTeamsDistributeParallelForSimdStatement*)(*block);
  132385           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size; ++i )
  132386             :              {
  132387             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  132388             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  132389             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  132390             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  132391             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  132392             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  132393             :             // properly; so this will have to be checked next.
  132394             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  132395             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  132396           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  132397             :                   {
  132398           0 :                     pointer[i].set_freepointer((SgOmpTargetTeamsDistributeParallelForSimdStatement*)(globalIndex));
  132399           0 :                     globalIndex++;
  132400             :                   }
  132401             :                else
  132402             :                   {
  132403           0 :                     pointer[i].set_freepointer(NULL);
  132404             :                   }
  132405             :               }
  132406             :         }
  132407           5 :      return globalIndex;
  132408             :    }
  132409             : 
  132410             : //############################################################################
  132411             : // JH (01/14/2006)
  132412             : void
  132413           5 : SgOmpTargetTeamsDistributeParallelForSimdStatement::resetValidFreepointers( )
  132414             :    {
  132415           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  132416           5 :      SgOmpTargetTeamsDistributeParallelForSimdStatement* pointer = NULL;
  132417           5 :      std::vector < unsigned char* > :: const_iterator block;
  132418           5 :      SgOmpTargetTeamsDistributeParallelForSimdStatement* pointerOfLinkedList = NULL;
  132419           5 :      for ( block = SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.begin(); block != SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.end() ; ++block )
  132420             :         {
  132421           0 :           pointer = (SgOmpTargetTeamsDistributeParallelForSimdStatement*)(*block);
  132422           0 :           for (unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size; ++i )
  132423             :              {
  132424             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  132425             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  132426             :             // memory blocks!.
  132427           0 :                if ( pointer[i].get_freepointer() != NULL )
  132428             :                   {
  132429           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  132430             :                   }
  132431             :                else
  132432             :                   {
  132433           0 :                     if ( pointerOfLinkedList == NULL )
  132434             :                        {
  132435           0 :                          SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node = &(pointer[i]);
  132436             :                        }
  132437             :                     else
  132438             :                        {
  132439             :                       // printf ("In SgOmpTargetTeamsDistributeParallelForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  132440           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  132441             :                        }
  132442             :                     pointerOfLinkedList = &(pointer[i]);
  132443             :                   }
  132444             :               }
  132445             :         }
  132446             : 
  132447           5 :      if ( pointerOfLinkedList != NULL )
  132448             :         {
  132449             :        // printf ("In SgOmpTargetTeamsDistributeParallelForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  132450           0 :           pointerOfLinkedList->set_freepointer(NULL);
  132451             :        // DQ (6/6/2010): Temporary debugging...
  132452             :        //   ROSE_ASSERT(false);
  132453             :         }
  132454             : 
  132455           5 :      return ;
  132456             :    }
  132457             : 
  132458             : //############################################################################
  132459             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  132460             :  * within the memory pool and resets the freepointers, in order to achieve a 
  132461             :  * linked list, that has no jumps and starts at the beginning! This function 
  132462             :  * does not extend the memory pool, since we do not delete any memory blocks,
  132463             :  * but delete the valid objects.  
  132464             :  */
  132465             : void
  132466           0 : SgOmpTargetTeamsDistributeParallelForSimdStatement::clearMemoryPool( )
  132467             :    {
  132468             :   // printf ("Inside of SgOmpTargetTeamsDistributeParallelForSimdStatement::clearMemoryPool() \n");
  132469             : 
  132470           0 :      SgOmpTargetTeamsDistributeParallelForSimdStatement* pointer = NULL, *tempPointer = NULL;
  132471           0 :      std::vector < unsigned char* > :: const_iterator block;
  132472           0 :      if ( SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.empty() == false )
  132473             :         {
  132474           0 :           block = SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.begin() ;
  132475           0 :           SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node = (SgOmpTargetTeamsDistributeParallelForSimdStatement*) (*block);
  132476             : 
  132477           0 :           while ( block != SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.end() )
  132478             :              {
  132479           0 :                pointer = (SgOmpTargetTeamsDistributeParallelForSimdStatement*) (*block);
  132480           0 :                if ( tempPointer != NULL )
  132481             :                   {
  132482           0 :                     tempPointer->set_freepointer(pointer);
  132483             :                   }
  132484           0 :                for (unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size - 1; ++i)
  132485             :                   {
  132486           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  132487             :                   }
  132488           0 :                 pointer[SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size-1].set_freepointer(NULL);
  132489           0 :                 tempPointer = &(pointer[SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size-1]);
  132490           0 :                 ++block;
  132491             :              }
  132492             :         }
  132493           0 :    }
  132494             : 
  132495           5 : void SgOmpTargetTeamsDistributeParallelForSimdStatement::deleteMemoryPool() {
  132496           5 :   for (auto p: SgOmpTargetTeamsDistributeParallelForSimdStatement::pools) {
  132497           0 :     ROSE_FREE(p);
  132498             :   }
  132499           5 :   SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node = nullptr;
  132500           5 :   SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.clear();
  132501           5 : }
  132502             : 
  132503             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  132504             : //                 reading multiple binary files to for a single AST.
  132505             : /////////// new version ////////////////////////////////
  132506             : //############################################################################
  132507             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  132508             : void
  132509           2 : SgOmpTargetTeamsDistributeParallelForSimdStatement::extendMemoryPoolForFileIO( )
  132510             :   {
  132511           2 :     size_t blockIndex = SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.size();
  132512           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeParallelForSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeParallelForSimdStatement);
  132513             : 
  132514           2 :     while ( (blockIndex * SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size) < newPoolSize)
  132515             :       {
  132516             : #if ROSE_ALLOC_TRACE
  132517             :         if (blockIndex > 0) {
  132518             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeParallelForSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeParallelForSimdStatement) = %" PRIuPTR " SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size = %d \n",
  132519             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetTeamsDistributeParallelForSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetTeamsDistributeParallelForSimdStatement),SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size);
  132520             :         }
  132521             : #endif
  132522             : 
  132523           0 :         SgOmpTargetTeamsDistributeParallelForSimdStatement * pointer = (SgOmpTargetTeamsDistributeParallelForSimdStatement*) ROSE_MALLOC ( SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement) );
  132524           0 :         assert( pointer != NULL );
  132525             : #if ROSE_ALLOC_MEMSET == 1
  132526             :         memset(pointer, 0x00, SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement));
  132527             : #elif ROSE_ALLOC_MEMSET == 2
  132528             :         memset(pointer, 0xCC, SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement));
  132529             : #endif
  132530           0 :         SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  132531           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement), V_SgOmpTargetTeamsDistributeParallelForSimdStatement ) );
  132532             : 
  132533           0 :         if ( SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node != NULL ) {
  132534           0 :           if ( blockIndex > 0 ) {
  132535           0 :             SgOmpTargetTeamsDistributeParallelForSimdStatement * blkptr = (SgOmpTargetTeamsDistributeParallelForSimdStatement*)(SgOmpTargetTeamsDistributeParallelForSimdStatement::pools[blockIndex-1]);
  132536           0 :             blkptr[ SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  132537             :           }
  132538             :         } else {
  132539           0 :           SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node = pointer;
  132540             :         }
  132541             : 
  132542           0 :         for (unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size-1; ++i)
  132543             :            {
  132544           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  132545             :            }
  132546           0 :         pointer[ SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size -1 ].set_freepointer(NULL);
  132547             : 
  132548           0 :         blockIndex++;
  132549             :       }
  132550           2 :   }
  132551             : 
  132552             : //############################################################################
  132553             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  132554             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  132555             :  * not compressed. However, that stuff is not yet implemented! 
  132556             :  */
  132557             : unsigned long
  132558           0 : SgOmpTargetTeamsDistributeParallelForSimdStatement::getNumberOfLastValidPointer()
  132559             :    {
  132560           0 :       SgOmpTargetTeamsDistributeParallelForSimdStatement* testPointer = (SgOmpTargetTeamsDistributeParallelForSimdStatement*)(SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.back());
  132561           0 :       unsigned long localIndex = SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size - 1;
  132562           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  132563             :          {
  132564           0 :            localIndex--;
  132565             :          }
  132566           0 :       return (localIndex + SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * (SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.size()-1));
  132567             :    }
  132568             : 
  132569             : //############################################################################
  132570             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  132571             :  * memory pool and initializes the data member in class SgOmpTargetTeamsDistributeParallelForSimdStatementStroageClass
  132572             :  * from its counterpart of SgOmpTargetTeamsDistributeParallelForSimdStatement. The return value is just for checking, 
  132573             :  * that the whole StorageClassArray is initialized!
  132574             :  */
  132575             : unsigned long
  132576           0 : SgOmpTargetTeamsDistributeParallelForSimdStatement::initializeStorageClassArray( SgOmpTargetTeamsDistributeParallelForSimdStatementStorageClass *storageArray )
  132577             :    {
  132578           0 :      unsigned long storageCounter = 0;
  132579           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.begin();
  132580           0 :      SgOmpTargetTeamsDistributeParallelForSimdStatement* pointer = NULL;
  132581           0 :      while ( block != SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.end() ) {
  132582           0 :           pointer = (SgOmpTargetTeamsDistributeParallelForSimdStatement*) (*block);
  132583           0 :           for ( unsigned i = 0; i < SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size; ++i ) {
  132584           0 :                if ( pointer->get_freepointer() != NULL ) {
  132585           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  132586           0 :                  storageArray++;
  132587           0 :                  storageCounter++;
  132588             :                }
  132589           0 :                pointer++;
  132590             :              }
  132591           0 :            block++;
  132592             :         }
  132593           0 :      return storageCounter;
  132594             :    }
  132595             : 
  132596             : /* #line 132597 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  132597             : 
  132598             : 
  132599             : 
  132600             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  132601             : 
  132602             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  132603             : 
  132604             : //############################################################################
  132605             : /* JH (02/02/2006) Constructor of the IR node SgOmpDistributeSimdStatement that takes its 
  132606             :  * corresponding StorageClass as parameter
  132607             :  */
  132608           0 : SgOmpDistributeSimdStatement :: SgOmpDistributeSimdStatement ( const SgOmpDistributeSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  132609             :    {
  132610             : 
  132611             : 
  132612             : /* #line 132613 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  132613             : 
  132614           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  132615             : 
  132616             : 
  132617             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  132618             : 
  132619             : 
  132620           0 :    }
  132621             : 
  132622             : //############################################################################
  132623             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  132624             :  * within the working AST. 
  132625             :  */
  132626           0 : SgOmpDistributeSimdStatement * SgOmpDistributeSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  132627           0 :      SgOmpDistributeSimdStatement* returnPointer = NULL;
  132628           0 :      if ( globalIndex != 0 )
  132629             :         {
  132630             : 
  132631             : #if FILE_IO_EXTRA_CHECK
  132632           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDistributeSimdStatement ) ) <= globalIndex ) ;
  132633           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistributeSimdStatement + 1 ) ) );
  132634             : #endif
  132635           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistributeSimdStatement )  
  132636           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDistributeSimdStatement );
  132637           0 :           unsigned long positionInPool = localIndex % SgOmpDistributeSimdStatement::pool_size;
  132638           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistributeSimdStatement::pool_size;
  132639             : 
  132640             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  132641             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  132642             : 
  132643           0 :           returnPointer = &( ( (SgOmpDistributeSimdStatement*)(SgOmpDistributeSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  132644             : 
  132645           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  132646             :         }
  132647           0 :      return returnPointer ;
  132648             :    }
  132649             : 
  132650             : //############################################################################
  132651             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  132652             :   for the AST with the index astIndex
  132653             : */
  132654           0 : SgOmpDistributeSimdStatement * SgOmpDistributeSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  132655           0 :      SgOmpDistributeSimdStatement* returnPointer = NULL;
  132656           0 :      if ( globalIndex != 0 )
  132657             :         {
  132658             : 
  132659             : #if FILE_IO_EXTRA_CHECK
  132660           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDistributeSimdStatement ) ) <= globalIndex ) ;
  132661           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistributeSimdStatement + 1 ) ) );
  132662             : #endif
  132663           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistributeSimdStatement )
  132664           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDistributeSimdStatement );
  132665           0 :           unsigned long positionInPool = localIndex % SgOmpDistributeSimdStatement::pool_size ;
  132666           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistributeSimdStatement::pool_size ;
  132667             : 
  132668             : #if FILE_IO_EXTRA_CHECK
  132669             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  132670             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  132671             : #endif
  132672             : 
  132673           0 :           returnPointer = &( ( (SgOmpDistributeSimdStatement*)(SgOmpDistributeSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  132674             : 
  132675             : #if FILE_IO_EXTRA_CHECK
  132676           0 :           assert ( returnPointer != NULL ) ;
  132677             : #endif
  132678             :         }
  132679           0 :      return returnPointer ;
  132680             :    }
  132681             : 
  132682             : //############################################################################
  132683             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  132684             :  * pool size! We set for every valid object in the memory pool the freepointer
  132685             :  * to the global index and increase the global index afterwards. For all the 
  132686             :  * invalid objects (means address ranges within the memory pool that were not
  132687             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  132688             :  * distinguish valid from invalid objects! 
  132689             :  */
  132690             : unsigned long
  132691           5 : SgOmpDistributeSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  132692             :    {
  132693           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  132694           5 :      SgOmpDistributeSimdStatement* pointer = NULL;
  132695           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  132696           5 :      std::vector < unsigned char* > :: const_iterator block;
  132697           5 :      for ( block = SgOmpDistributeSimdStatement::pools.begin(); block != SgOmpDistributeSimdStatement::pools.end() ; ++block )
  132698             :         {
  132699           0 :           pointer = (SgOmpDistributeSimdStatement*)(*block);
  132700           0 :           for (unsigned i = 0; i < SgOmpDistributeSimdStatement::pool_size; ++i )
  132701             :              {
  132702             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  132703             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  132704             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  132705             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  132706             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  132707             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  132708             :             // properly; so this will have to be checked next.
  132709             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  132710             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  132711           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  132712             :                   {
  132713           0 :                     pointer[i].set_freepointer((SgOmpDistributeSimdStatement*)(globalIndex));
  132714           0 :                     globalIndex++;
  132715             :                   }
  132716             :                else
  132717             :                   {
  132718           0 :                     pointer[i].set_freepointer(NULL);
  132719             :                   }
  132720             :               }
  132721             :         }
  132722           5 :      return globalIndex;
  132723             :    }
  132724             : 
  132725             : //############################################################################
  132726             : // JH (01/14/2006)
  132727             : void
  132728           5 : SgOmpDistributeSimdStatement::resetValidFreepointers( )
  132729             :    {
  132730           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  132731           5 :      SgOmpDistributeSimdStatement* pointer = NULL;
  132732           5 :      std::vector < unsigned char* > :: const_iterator block;
  132733           5 :      SgOmpDistributeSimdStatement* pointerOfLinkedList = NULL;
  132734           5 :      for ( block = SgOmpDistributeSimdStatement::pools.begin(); block != SgOmpDistributeSimdStatement::pools.end() ; ++block )
  132735             :         {
  132736           0 :           pointer = (SgOmpDistributeSimdStatement*)(*block);
  132737           0 :           for (unsigned i = 0; i < SgOmpDistributeSimdStatement::pool_size; ++i )
  132738             :              {
  132739             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  132740             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  132741             :             // memory blocks!.
  132742           0 :                if ( pointer[i].get_freepointer() != NULL )
  132743             :                   {
  132744           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  132745             :                   }
  132746             :                else
  132747             :                   {
  132748           0 :                     if ( pointerOfLinkedList == NULL )
  132749             :                        {
  132750           0 :                          SgOmpDistributeSimdStatement::next_node = &(pointer[i]);
  132751             :                        }
  132752             :                     else
  132753             :                        {
  132754             :                       // printf ("In SgOmpDistributeSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  132755           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  132756             :                        }
  132757             :                     pointerOfLinkedList = &(pointer[i]);
  132758             :                   }
  132759             :               }
  132760             :         }
  132761             : 
  132762           5 :      if ( pointerOfLinkedList != NULL )
  132763             :         {
  132764             :        // printf ("In SgOmpDistributeSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  132765           0 :           pointerOfLinkedList->set_freepointer(NULL);
  132766             :        // DQ (6/6/2010): Temporary debugging...
  132767             :        //   ROSE_ASSERT(false);
  132768             :         }
  132769             : 
  132770           5 :      return ;
  132771             :    }
  132772             : 
  132773             : //############################################################################
  132774             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  132775             :  * within the memory pool and resets the freepointers, in order to achieve a 
  132776             :  * linked list, that has no jumps and starts at the beginning! This function 
  132777             :  * does not extend the memory pool, since we do not delete any memory blocks,
  132778             :  * but delete the valid objects.  
  132779             :  */
  132780             : void
  132781           0 : SgOmpDistributeSimdStatement::clearMemoryPool( )
  132782             :    {
  132783             :   // printf ("Inside of SgOmpDistributeSimdStatement::clearMemoryPool() \n");
  132784             : 
  132785           0 :      SgOmpDistributeSimdStatement* pointer = NULL, *tempPointer = NULL;
  132786           0 :      std::vector < unsigned char* > :: const_iterator block;
  132787           0 :      if ( SgOmpDistributeSimdStatement::pools.empty() == false )
  132788             :         {
  132789           0 :           block = SgOmpDistributeSimdStatement::pools.begin() ;
  132790           0 :           SgOmpDistributeSimdStatement::next_node = (SgOmpDistributeSimdStatement*) (*block);
  132791             : 
  132792           0 :           while ( block != SgOmpDistributeSimdStatement::pools.end() )
  132793             :              {
  132794           0 :                pointer = (SgOmpDistributeSimdStatement*) (*block);
  132795           0 :                if ( tempPointer != NULL )
  132796             :                   {
  132797           0 :                     tempPointer->set_freepointer(pointer);
  132798             :                   }
  132799           0 :                for (unsigned i = 0; i < SgOmpDistributeSimdStatement::pool_size - 1; ++i)
  132800             :                   {
  132801           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  132802             :                   }
  132803           0 :                 pointer[SgOmpDistributeSimdStatement::pool_size-1].set_freepointer(NULL);
  132804           0 :                 tempPointer = &(pointer[SgOmpDistributeSimdStatement::pool_size-1]);
  132805           0 :                 ++block;
  132806             :              }
  132807             :         }
  132808           0 :    }
  132809             : 
  132810           5 : void SgOmpDistributeSimdStatement::deleteMemoryPool() {
  132811           5 :   for (auto p: SgOmpDistributeSimdStatement::pools) {
  132812           0 :     ROSE_FREE(p);
  132813             :   }
  132814           5 :   SgOmpDistributeSimdStatement::next_node = nullptr;
  132815           5 :   SgOmpDistributeSimdStatement::pools.clear();
  132816           5 : }
  132817             : 
  132818             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  132819             : //                 reading multiple binary files to for a single AST.
  132820             : /////////// new version ////////////////////////////////
  132821             : //############################################################################
  132822             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  132823             : void
  132824           2 : SgOmpDistributeSimdStatement::extendMemoryPoolForFileIO( )
  132825             :   {
  132826           2 :     size_t blockIndex = SgOmpDistributeSimdStatement::pools.size();
  132827           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeSimdStatement);
  132828             : 
  132829           2 :     while ( (blockIndex * SgOmpDistributeSimdStatement::pool_size) < newPoolSize)
  132830             :       {
  132831             : #if ROSE_ALLOC_TRACE
  132832             :         if (blockIndex > 0) {
  132833             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeSimdStatement) = %" PRIuPTR " SgOmpDistributeSimdStatement::pool_size = %d \n",
  132834             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeSimdStatement),SgOmpDistributeSimdStatement::pool_size);
  132835             :         }
  132836             : #endif
  132837             : 
  132838           0 :         SgOmpDistributeSimdStatement * pointer = (SgOmpDistributeSimdStatement*) ROSE_MALLOC ( SgOmpDistributeSimdStatement::pool_size * sizeof(SgOmpDistributeSimdStatement) );
  132839           0 :         assert( pointer != NULL );
  132840             : #if ROSE_ALLOC_MEMSET == 1
  132841             :         memset(pointer, 0x00, SgOmpDistributeSimdStatement::pool_size * sizeof(SgOmpDistributeSimdStatement));
  132842             : #elif ROSE_ALLOC_MEMSET == 2
  132843             :         memset(pointer, 0xCC, SgOmpDistributeSimdStatement::pool_size * sizeof(SgOmpDistributeSimdStatement));
  132844             : #endif
  132845           0 :         SgOmpDistributeSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  132846           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDistributeSimdStatement::pool_size * sizeof(SgOmpDistributeSimdStatement), V_SgOmpDistributeSimdStatement ) );
  132847             : 
  132848           0 :         if ( SgOmpDistributeSimdStatement::next_node != NULL ) {
  132849           0 :           if ( blockIndex > 0 ) {
  132850           0 :             SgOmpDistributeSimdStatement * blkptr = (SgOmpDistributeSimdStatement*)(SgOmpDistributeSimdStatement::pools[blockIndex-1]);
  132851           0 :             blkptr[ SgOmpDistributeSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  132852             :           }
  132853             :         } else {
  132854           0 :           SgOmpDistributeSimdStatement::next_node = pointer;
  132855             :         }
  132856             : 
  132857           0 :         for (unsigned i = 0; i < SgOmpDistributeSimdStatement::pool_size-1; ++i)
  132858             :            {
  132859           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  132860             :            }
  132861           0 :         pointer[ SgOmpDistributeSimdStatement::pool_size -1 ].set_freepointer(NULL);
  132862             : 
  132863           0 :         blockIndex++;
  132864             :       }
  132865           2 :   }
  132866             : 
  132867             : //############################################################################
  132868             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  132869             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  132870             :  * not compressed. However, that stuff is not yet implemented! 
  132871             :  */
  132872             : unsigned long
  132873           0 : SgOmpDistributeSimdStatement::getNumberOfLastValidPointer()
  132874             :    {
  132875           0 :       SgOmpDistributeSimdStatement* testPointer = (SgOmpDistributeSimdStatement*)(SgOmpDistributeSimdStatement::pools.back());
  132876           0 :       unsigned long localIndex = SgOmpDistributeSimdStatement::pool_size - 1;
  132877           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  132878             :          {
  132879           0 :            localIndex--;
  132880             :          }
  132881           0 :       return (localIndex + SgOmpDistributeSimdStatement::pool_size * (SgOmpDistributeSimdStatement::pools.size()-1));
  132882             :    }
  132883             : 
  132884             : //############################################################################
  132885             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  132886             :  * memory pool and initializes the data member in class SgOmpDistributeSimdStatementStroageClass
  132887             :  * from its counterpart of SgOmpDistributeSimdStatement. The return value is just for checking, 
  132888             :  * that the whole StorageClassArray is initialized!
  132889             :  */
  132890             : unsigned long
  132891           0 : SgOmpDistributeSimdStatement::initializeStorageClassArray( SgOmpDistributeSimdStatementStorageClass *storageArray )
  132892             :    {
  132893           0 :      unsigned long storageCounter = 0;
  132894           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDistributeSimdStatement::pools.begin();
  132895           0 :      SgOmpDistributeSimdStatement* pointer = NULL;
  132896           0 :      while ( block != SgOmpDistributeSimdStatement::pools.end() ) {
  132897           0 :           pointer = (SgOmpDistributeSimdStatement*) (*block);
  132898           0 :           for ( unsigned i = 0; i < SgOmpDistributeSimdStatement::pool_size; ++i ) {
  132899           0 :                if ( pointer->get_freepointer() != NULL ) {
  132900           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  132901           0 :                  storageArray++;
  132902           0 :                  storageCounter++;
  132903             :                }
  132904           0 :                pointer++;
  132905             :              }
  132906           0 :            block++;
  132907             :         }
  132908           0 :      return storageCounter;
  132909             :    }
  132910             : 
  132911             : /* #line 132912 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  132912             : 
  132913             : 
  132914             : 
  132915             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  132916             : 
  132917             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  132918             : 
  132919             : //############################################################################
  132920             : /* JH (02/02/2006) Constructor of the IR node SgOmpDistributeParallelForStatement that takes its 
  132921             :  * corresponding StorageClass as parameter
  132922             :  */
  132923           0 : SgOmpDistributeParallelForStatement :: SgOmpDistributeParallelForStatement ( const SgOmpDistributeParallelForStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  132924             :    {
  132925             : 
  132926             : 
  132927             : /* #line 132928 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  132928             : 
  132929           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  132930             : 
  132931             : 
  132932             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  132933             : 
  132934             : 
  132935           0 :    }
  132936             : 
  132937             : //############################################################################
  132938             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  132939             :  * within the working AST. 
  132940             :  */
  132941           0 : SgOmpDistributeParallelForStatement * SgOmpDistributeParallelForStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  132942           0 :      SgOmpDistributeParallelForStatement* returnPointer = NULL;
  132943           0 :      if ( globalIndex != 0 )
  132944             :         {
  132945             : 
  132946             : #if FILE_IO_EXTRA_CHECK
  132947           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDistributeParallelForStatement ) ) <= globalIndex ) ;
  132948           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistributeParallelForStatement + 1 ) ) );
  132949             : #endif
  132950           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistributeParallelForStatement )  
  132951           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDistributeParallelForStatement );
  132952           0 :           unsigned long positionInPool = localIndex % SgOmpDistributeParallelForStatement::pool_size;
  132953           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistributeParallelForStatement::pool_size;
  132954             : 
  132955             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  132956             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  132957             : 
  132958           0 :           returnPointer = &( ( (SgOmpDistributeParallelForStatement*)(SgOmpDistributeParallelForStatement::pools[memoryBlock]) ) [positionInPool]) ;
  132959             : 
  132960           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  132961             :         }
  132962           0 :      return returnPointer ;
  132963             :    }
  132964             : 
  132965             : //############################################################################
  132966             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  132967             :   for the AST with the index astIndex
  132968             : */
  132969           0 : SgOmpDistributeParallelForStatement * SgOmpDistributeParallelForStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  132970           0 :      SgOmpDistributeParallelForStatement* returnPointer = NULL;
  132971           0 :      if ( globalIndex != 0 )
  132972             :         {
  132973             : 
  132974             : #if FILE_IO_EXTRA_CHECK
  132975           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDistributeParallelForStatement ) ) <= globalIndex ) ;
  132976           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistributeParallelForStatement + 1 ) ) );
  132977             : #endif
  132978           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistributeParallelForStatement )
  132979           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDistributeParallelForStatement );
  132980           0 :           unsigned long positionInPool = localIndex % SgOmpDistributeParallelForStatement::pool_size ;
  132981           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistributeParallelForStatement::pool_size ;
  132982             : 
  132983             : #if FILE_IO_EXTRA_CHECK
  132984             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  132985             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  132986             : #endif
  132987             : 
  132988           0 :           returnPointer = &( ( (SgOmpDistributeParallelForStatement*)(SgOmpDistributeParallelForStatement::pools[memoryBlock]) ) [positionInPool]) ;
  132989             : 
  132990             : #if FILE_IO_EXTRA_CHECK
  132991           0 :           assert ( returnPointer != NULL ) ;
  132992             : #endif
  132993             :         }
  132994           0 :      return returnPointer ;
  132995             :    }
  132996             : 
  132997             : //############################################################################
  132998             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  132999             :  * pool size! We set for every valid object in the memory pool the freepointer
  133000             :  * to the global index and increase the global index afterwards. For all the 
  133001             :  * invalid objects (means address ranges within the memory pool that were not
  133002             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  133003             :  * distinguish valid from invalid objects! 
  133004             :  */
  133005             : unsigned long
  133006           5 : SgOmpDistributeParallelForStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  133007             :    {
  133008           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  133009           5 :      SgOmpDistributeParallelForStatement* pointer = NULL;
  133010           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  133011           5 :      std::vector < unsigned char* > :: const_iterator block;
  133012           5 :      for ( block = SgOmpDistributeParallelForStatement::pools.begin(); block != SgOmpDistributeParallelForStatement::pools.end() ; ++block )
  133013             :         {
  133014           0 :           pointer = (SgOmpDistributeParallelForStatement*)(*block);
  133015           0 :           for (unsigned i = 0; i < SgOmpDistributeParallelForStatement::pool_size; ++i )
  133016             :              {
  133017             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  133018             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  133019             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  133020             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  133021             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  133022             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  133023             :             // properly; so this will have to be checked next.
  133024             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  133025             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  133026           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  133027             :                   {
  133028           0 :                     pointer[i].set_freepointer((SgOmpDistributeParallelForStatement*)(globalIndex));
  133029           0 :                     globalIndex++;
  133030             :                   }
  133031             :                else
  133032             :                   {
  133033           0 :                     pointer[i].set_freepointer(NULL);
  133034             :                   }
  133035             :               }
  133036             :         }
  133037           5 :      return globalIndex;
  133038             :    }
  133039             : 
  133040             : //############################################################################
  133041             : // JH (01/14/2006)
  133042             : void
  133043           5 : SgOmpDistributeParallelForStatement::resetValidFreepointers( )
  133044             :    {
  133045           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  133046           5 :      SgOmpDistributeParallelForStatement* pointer = NULL;
  133047           5 :      std::vector < unsigned char* > :: const_iterator block;
  133048           5 :      SgOmpDistributeParallelForStatement* pointerOfLinkedList = NULL;
  133049           5 :      for ( block = SgOmpDistributeParallelForStatement::pools.begin(); block != SgOmpDistributeParallelForStatement::pools.end() ; ++block )
  133050             :         {
  133051           0 :           pointer = (SgOmpDistributeParallelForStatement*)(*block);
  133052           0 :           for (unsigned i = 0; i < SgOmpDistributeParallelForStatement::pool_size; ++i )
  133053             :              {
  133054             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  133055             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  133056             :             // memory blocks!.
  133057           0 :                if ( pointer[i].get_freepointer() != NULL )
  133058             :                   {
  133059           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  133060             :                   }
  133061             :                else
  133062             :                   {
  133063           0 :                     if ( pointerOfLinkedList == NULL )
  133064             :                        {
  133065           0 :                          SgOmpDistributeParallelForStatement::next_node = &(pointer[i]);
  133066             :                        }
  133067             :                     else
  133068             :                        {
  133069             :                       // printf ("In SgOmpDistributeParallelForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  133070           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  133071             :                        }
  133072             :                     pointerOfLinkedList = &(pointer[i]);
  133073             :                   }
  133074             :               }
  133075             :         }
  133076             : 
  133077           5 :      if ( pointerOfLinkedList != NULL )
  133078             :         {
  133079             :        // printf ("In SgOmpDistributeParallelForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  133080           0 :           pointerOfLinkedList->set_freepointer(NULL);
  133081             :        // DQ (6/6/2010): Temporary debugging...
  133082             :        //   ROSE_ASSERT(false);
  133083             :         }
  133084             : 
  133085           5 :      return ;
  133086             :    }
  133087             : 
  133088             : //############################################################################
  133089             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  133090             :  * within the memory pool and resets the freepointers, in order to achieve a 
  133091             :  * linked list, that has no jumps and starts at the beginning! This function 
  133092             :  * does not extend the memory pool, since we do not delete any memory blocks,
  133093             :  * but delete the valid objects.  
  133094             :  */
  133095             : void
  133096           0 : SgOmpDistributeParallelForStatement::clearMemoryPool( )
  133097             :    {
  133098             :   // printf ("Inside of SgOmpDistributeParallelForStatement::clearMemoryPool() \n");
  133099             : 
  133100           0 :      SgOmpDistributeParallelForStatement* pointer = NULL, *tempPointer = NULL;
  133101           0 :      std::vector < unsigned char* > :: const_iterator block;
  133102           0 :      if ( SgOmpDistributeParallelForStatement::pools.empty() == false )
  133103             :         {
  133104           0 :           block = SgOmpDistributeParallelForStatement::pools.begin() ;
  133105           0 :           SgOmpDistributeParallelForStatement::next_node = (SgOmpDistributeParallelForStatement*) (*block);
  133106             : 
  133107           0 :           while ( block != SgOmpDistributeParallelForStatement::pools.end() )
  133108             :              {
  133109           0 :                pointer = (SgOmpDistributeParallelForStatement*) (*block);
  133110           0 :                if ( tempPointer != NULL )
  133111             :                   {
  133112           0 :                     tempPointer->set_freepointer(pointer);
  133113             :                   }
  133114           0 :                for (unsigned i = 0; i < SgOmpDistributeParallelForStatement::pool_size - 1; ++i)
  133115             :                   {
  133116           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  133117             :                   }
  133118           0 :                 pointer[SgOmpDistributeParallelForStatement::pool_size-1].set_freepointer(NULL);
  133119           0 :                 tempPointer = &(pointer[SgOmpDistributeParallelForStatement::pool_size-1]);
  133120           0 :                 ++block;
  133121             :              }
  133122             :         }
  133123           0 :    }
  133124             : 
  133125           5 : void SgOmpDistributeParallelForStatement::deleteMemoryPool() {
  133126           5 :   for (auto p: SgOmpDistributeParallelForStatement::pools) {
  133127           0 :     ROSE_FREE(p);
  133128             :   }
  133129           5 :   SgOmpDistributeParallelForStatement::next_node = nullptr;
  133130           5 :   SgOmpDistributeParallelForStatement::pools.clear();
  133131           5 : }
  133132             : 
  133133             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  133134             : //                 reading multiple binary files to for a single AST.
  133135             : /////////// new version ////////////////////////////////
  133136             : //############################################################################
  133137             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  133138             : void
  133139           2 : SgOmpDistributeParallelForStatement::extendMemoryPoolForFileIO( )
  133140             :   {
  133141           2 :     size_t blockIndex = SgOmpDistributeParallelForStatement::pools.size();
  133142           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeParallelForStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeParallelForStatement);
  133143             : 
  133144           2 :     while ( (blockIndex * SgOmpDistributeParallelForStatement::pool_size) < newPoolSize)
  133145             :       {
  133146             : #if ROSE_ALLOC_TRACE
  133147             :         if (blockIndex > 0) {
  133148             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeParallelForStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeParallelForStatement) = %" PRIuPTR " SgOmpDistributeParallelForStatement::pool_size = %d \n",
  133149             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeParallelForStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeParallelForStatement),SgOmpDistributeParallelForStatement::pool_size);
  133150             :         }
  133151             : #endif
  133152             : 
  133153           0 :         SgOmpDistributeParallelForStatement * pointer = (SgOmpDistributeParallelForStatement*) ROSE_MALLOC ( SgOmpDistributeParallelForStatement::pool_size * sizeof(SgOmpDistributeParallelForStatement) );
  133154           0 :         assert( pointer != NULL );
  133155             : #if ROSE_ALLOC_MEMSET == 1
  133156             :         memset(pointer, 0x00, SgOmpDistributeParallelForStatement::pool_size * sizeof(SgOmpDistributeParallelForStatement));
  133157             : #elif ROSE_ALLOC_MEMSET == 2
  133158             :         memset(pointer, 0xCC, SgOmpDistributeParallelForStatement::pool_size * sizeof(SgOmpDistributeParallelForStatement));
  133159             : #endif
  133160           0 :         SgOmpDistributeParallelForStatement::pools.push_back( (unsigned char*)(pointer) );
  133161           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDistributeParallelForStatement::pool_size * sizeof(SgOmpDistributeParallelForStatement), V_SgOmpDistributeParallelForStatement ) );
  133162             : 
  133163           0 :         if ( SgOmpDistributeParallelForStatement::next_node != NULL ) {
  133164           0 :           if ( blockIndex > 0 ) {
  133165           0 :             SgOmpDistributeParallelForStatement * blkptr = (SgOmpDistributeParallelForStatement*)(SgOmpDistributeParallelForStatement::pools[blockIndex-1]);
  133166           0 :             blkptr[ SgOmpDistributeParallelForStatement::pool_size - 1 ].set_freepointer(pointer);
  133167             :           }
  133168             :         } else {
  133169           0 :           SgOmpDistributeParallelForStatement::next_node = pointer;
  133170             :         }
  133171             : 
  133172           0 :         for (unsigned i = 0; i < SgOmpDistributeParallelForStatement::pool_size-1; ++i)
  133173             :            {
  133174           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  133175             :            }
  133176           0 :         pointer[ SgOmpDistributeParallelForStatement::pool_size -1 ].set_freepointer(NULL);
  133177             : 
  133178           0 :         blockIndex++;
  133179             :       }
  133180           2 :   }
  133181             : 
  133182             : //############################################################################
  133183             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  133184             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  133185             :  * not compressed. However, that stuff is not yet implemented! 
  133186             :  */
  133187             : unsigned long
  133188           0 : SgOmpDistributeParallelForStatement::getNumberOfLastValidPointer()
  133189             :    {
  133190           0 :       SgOmpDistributeParallelForStatement* testPointer = (SgOmpDistributeParallelForStatement*)(SgOmpDistributeParallelForStatement::pools.back());
  133191           0 :       unsigned long localIndex = SgOmpDistributeParallelForStatement::pool_size - 1;
  133192           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  133193             :          {
  133194           0 :            localIndex--;
  133195             :          }
  133196           0 :       return (localIndex + SgOmpDistributeParallelForStatement::pool_size * (SgOmpDistributeParallelForStatement::pools.size()-1));
  133197             :    }
  133198             : 
  133199             : //############################################################################
  133200             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  133201             :  * memory pool and initializes the data member in class SgOmpDistributeParallelForStatementStroageClass
  133202             :  * from its counterpart of SgOmpDistributeParallelForStatement. The return value is just for checking, 
  133203             :  * that the whole StorageClassArray is initialized!
  133204             :  */
  133205             : unsigned long
  133206           0 : SgOmpDistributeParallelForStatement::initializeStorageClassArray( SgOmpDistributeParallelForStatementStorageClass *storageArray )
  133207             :    {
  133208           0 :      unsigned long storageCounter = 0;
  133209           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDistributeParallelForStatement::pools.begin();
  133210           0 :      SgOmpDistributeParallelForStatement* pointer = NULL;
  133211           0 :      while ( block != SgOmpDistributeParallelForStatement::pools.end() ) {
  133212           0 :           pointer = (SgOmpDistributeParallelForStatement*) (*block);
  133213           0 :           for ( unsigned i = 0; i < SgOmpDistributeParallelForStatement::pool_size; ++i ) {
  133214           0 :                if ( pointer->get_freepointer() != NULL ) {
  133215           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  133216           0 :                  storageArray++;
  133217           0 :                  storageCounter++;
  133218             :                }
  133219           0 :                pointer++;
  133220             :              }
  133221           0 :            block++;
  133222             :         }
  133223           0 :      return storageCounter;
  133224             :    }
  133225             : 
  133226             : /* #line 133227 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  133227             : 
  133228             : 
  133229             : 
  133230             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  133231             : 
  133232             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  133233             : 
  133234             : //############################################################################
  133235             : /* JH (02/02/2006) Constructor of the IR node SgOmpDistributeParallelForSimdStatement that takes its 
  133236             :  * corresponding StorageClass as parameter
  133237             :  */
  133238           0 : SgOmpDistributeParallelForSimdStatement :: SgOmpDistributeParallelForSimdStatement ( const SgOmpDistributeParallelForSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  133239             :    {
  133240             : 
  133241             : 
  133242             : /* #line 133243 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  133243             : 
  133244           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  133245             : 
  133246             : 
  133247             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  133248             : 
  133249             : 
  133250           0 :    }
  133251             : 
  133252             : //############################################################################
  133253             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  133254             :  * within the working AST. 
  133255             :  */
  133256           0 : SgOmpDistributeParallelForSimdStatement * SgOmpDistributeParallelForSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  133257           0 :      SgOmpDistributeParallelForSimdStatement* returnPointer = NULL;
  133258           0 :      if ( globalIndex != 0 )
  133259             :         {
  133260             : 
  133261             : #if FILE_IO_EXTRA_CHECK
  133262           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDistributeParallelForSimdStatement ) ) <= globalIndex ) ;
  133263           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistributeParallelForSimdStatement + 1 ) ) );
  133264             : #endif
  133265           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistributeParallelForSimdStatement )  
  133266           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDistributeParallelForSimdStatement );
  133267           0 :           unsigned long positionInPool = localIndex % SgOmpDistributeParallelForSimdStatement::pool_size;
  133268           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistributeParallelForSimdStatement::pool_size;
  133269             : 
  133270             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  133271             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  133272             : 
  133273           0 :           returnPointer = &( ( (SgOmpDistributeParallelForSimdStatement*)(SgOmpDistributeParallelForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  133274             : 
  133275           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  133276             :         }
  133277           0 :      return returnPointer ;
  133278             :    }
  133279             : 
  133280             : //############################################################################
  133281             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  133282             :   for the AST with the index astIndex
  133283             : */
  133284           0 : SgOmpDistributeParallelForSimdStatement * SgOmpDistributeParallelForSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  133285           0 :      SgOmpDistributeParallelForSimdStatement* returnPointer = NULL;
  133286           0 :      if ( globalIndex != 0 )
  133287             :         {
  133288             : 
  133289             : #if FILE_IO_EXTRA_CHECK
  133290           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDistributeParallelForSimdStatement ) ) <= globalIndex ) ;
  133291           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistributeParallelForSimdStatement + 1 ) ) );
  133292             : #endif
  133293           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistributeParallelForSimdStatement )
  133294           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDistributeParallelForSimdStatement );
  133295           0 :           unsigned long positionInPool = localIndex % SgOmpDistributeParallelForSimdStatement::pool_size ;
  133296           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistributeParallelForSimdStatement::pool_size ;
  133297             : 
  133298             : #if FILE_IO_EXTRA_CHECK
  133299             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  133300             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  133301             : #endif
  133302             : 
  133303           0 :           returnPointer = &( ( (SgOmpDistributeParallelForSimdStatement*)(SgOmpDistributeParallelForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  133304             : 
  133305             : #if FILE_IO_EXTRA_CHECK
  133306           0 :           assert ( returnPointer != NULL ) ;
  133307             : #endif
  133308             :         }
  133309           0 :      return returnPointer ;
  133310             :    }
  133311             : 
  133312             : //############################################################################
  133313             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  133314             :  * pool size! We set for every valid object in the memory pool the freepointer
  133315             :  * to the global index and increase the global index afterwards. For all the 
  133316             :  * invalid objects (means address ranges within the memory pool that were not
  133317             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  133318             :  * distinguish valid from invalid objects! 
  133319             :  */
  133320             : unsigned long
  133321           5 : SgOmpDistributeParallelForSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  133322             :    {
  133323           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  133324           5 :      SgOmpDistributeParallelForSimdStatement* pointer = NULL;
  133325           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  133326           5 :      std::vector < unsigned char* > :: const_iterator block;
  133327           5 :      for ( block = SgOmpDistributeParallelForSimdStatement::pools.begin(); block != SgOmpDistributeParallelForSimdStatement::pools.end() ; ++block )
  133328             :         {
  133329           0 :           pointer = (SgOmpDistributeParallelForSimdStatement*)(*block);
  133330           0 :           for (unsigned i = 0; i < SgOmpDistributeParallelForSimdStatement::pool_size; ++i )
  133331             :              {
  133332             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  133333             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  133334             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  133335             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  133336             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  133337             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  133338             :             // properly; so this will have to be checked next.
  133339             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  133340             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  133341           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  133342             :                   {
  133343           0 :                     pointer[i].set_freepointer((SgOmpDistributeParallelForSimdStatement*)(globalIndex));
  133344           0 :                     globalIndex++;
  133345             :                   }
  133346             :                else
  133347             :                   {
  133348           0 :                     pointer[i].set_freepointer(NULL);
  133349             :                   }
  133350             :               }
  133351             :         }
  133352           5 :      return globalIndex;
  133353             :    }
  133354             : 
  133355             : //############################################################################
  133356             : // JH (01/14/2006)
  133357             : void
  133358           5 : SgOmpDistributeParallelForSimdStatement::resetValidFreepointers( )
  133359             :    {
  133360           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  133361           5 :      SgOmpDistributeParallelForSimdStatement* pointer = NULL;
  133362           5 :      std::vector < unsigned char* > :: const_iterator block;
  133363           5 :      SgOmpDistributeParallelForSimdStatement* pointerOfLinkedList = NULL;
  133364           5 :      for ( block = SgOmpDistributeParallelForSimdStatement::pools.begin(); block != SgOmpDistributeParallelForSimdStatement::pools.end() ; ++block )
  133365             :         {
  133366           0 :           pointer = (SgOmpDistributeParallelForSimdStatement*)(*block);
  133367           0 :           for (unsigned i = 0; i < SgOmpDistributeParallelForSimdStatement::pool_size; ++i )
  133368             :              {
  133369             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  133370             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  133371             :             // memory blocks!.
  133372           0 :                if ( pointer[i].get_freepointer() != NULL )
  133373             :                   {
  133374           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  133375             :                   }
  133376             :                else
  133377             :                   {
  133378           0 :                     if ( pointerOfLinkedList == NULL )
  133379             :                        {
  133380           0 :                          SgOmpDistributeParallelForSimdStatement::next_node = &(pointer[i]);
  133381             :                        }
  133382             :                     else
  133383             :                        {
  133384             :                       // printf ("In SgOmpDistributeParallelForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  133385           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  133386             :                        }
  133387             :                     pointerOfLinkedList = &(pointer[i]);
  133388             :                   }
  133389             :               }
  133390             :         }
  133391             : 
  133392           5 :      if ( pointerOfLinkedList != NULL )
  133393             :         {
  133394             :        // printf ("In SgOmpDistributeParallelForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  133395           0 :           pointerOfLinkedList->set_freepointer(NULL);
  133396             :        // DQ (6/6/2010): Temporary debugging...
  133397             :        //   ROSE_ASSERT(false);
  133398             :         }
  133399             : 
  133400           5 :      return ;
  133401             :    }
  133402             : 
  133403             : //############################################################################
  133404             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  133405             :  * within the memory pool and resets the freepointers, in order to achieve a 
  133406             :  * linked list, that has no jumps and starts at the beginning! This function 
  133407             :  * does not extend the memory pool, since we do not delete any memory blocks,
  133408             :  * but delete the valid objects.  
  133409             :  */
  133410             : void
  133411           0 : SgOmpDistributeParallelForSimdStatement::clearMemoryPool( )
  133412             :    {
  133413             :   // printf ("Inside of SgOmpDistributeParallelForSimdStatement::clearMemoryPool() \n");
  133414             : 
  133415           0 :      SgOmpDistributeParallelForSimdStatement* pointer = NULL, *tempPointer = NULL;
  133416           0 :      std::vector < unsigned char* > :: const_iterator block;
  133417           0 :      if ( SgOmpDistributeParallelForSimdStatement::pools.empty() == false )
  133418             :         {
  133419           0 :           block = SgOmpDistributeParallelForSimdStatement::pools.begin() ;
  133420           0 :           SgOmpDistributeParallelForSimdStatement::next_node = (SgOmpDistributeParallelForSimdStatement*) (*block);
  133421             : 
  133422           0 :           while ( block != SgOmpDistributeParallelForSimdStatement::pools.end() )
  133423             :              {
  133424           0 :                pointer = (SgOmpDistributeParallelForSimdStatement*) (*block);
  133425           0 :                if ( tempPointer != NULL )
  133426             :                   {
  133427           0 :                     tempPointer->set_freepointer(pointer);
  133428             :                   }
  133429           0 :                for (unsigned i = 0; i < SgOmpDistributeParallelForSimdStatement::pool_size - 1; ++i)
  133430             :                   {
  133431           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  133432             :                   }
  133433           0 :                 pointer[SgOmpDistributeParallelForSimdStatement::pool_size-1].set_freepointer(NULL);
  133434           0 :                 tempPointer = &(pointer[SgOmpDistributeParallelForSimdStatement::pool_size-1]);
  133435           0 :                 ++block;
  133436             :              }
  133437             :         }
  133438           0 :    }
  133439             : 
  133440           5 : void SgOmpDistributeParallelForSimdStatement::deleteMemoryPool() {
  133441           5 :   for (auto p: SgOmpDistributeParallelForSimdStatement::pools) {
  133442           0 :     ROSE_FREE(p);
  133443             :   }
  133444           5 :   SgOmpDistributeParallelForSimdStatement::next_node = nullptr;
  133445           5 :   SgOmpDistributeParallelForSimdStatement::pools.clear();
  133446           5 : }
  133447             : 
  133448             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  133449             : //                 reading multiple binary files to for a single AST.
  133450             : /////////// new version ////////////////////////////////
  133451             : //############################################################################
  133452             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  133453             : void
  133454           2 : SgOmpDistributeParallelForSimdStatement::extendMemoryPoolForFileIO( )
  133455             :   {
  133456           2 :     size_t blockIndex = SgOmpDistributeParallelForSimdStatement::pools.size();
  133457           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeParallelForSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeParallelForSimdStatement);
  133458             : 
  133459           2 :     while ( (blockIndex * SgOmpDistributeParallelForSimdStatement::pool_size) < newPoolSize)
  133460             :       {
  133461             : #if ROSE_ALLOC_TRACE
  133462             :         if (blockIndex > 0) {
  133463             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeParallelForSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeParallelForSimdStatement) = %" PRIuPTR " SgOmpDistributeParallelForSimdStatement::pool_size = %d \n",
  133464             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeParallelForSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeParallelForSimdStatement),SgOmpDistributeParallelForSimdStatement::pool_size);
  133465             :         }
  133466             : #endif
  133467             : 
  133468           0 :         SgOmpDistributeParallelForSimdStatement * pointer = (SgOmpDistributeParallelForSimdStatement*) ROSE_MALLOC ( SgOmpDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpDistributeParallelForSimdStatement) );
  133469           0 :         assert( pointer != NULL );
  133470             : #if ROSE_ALLOC_MEMSET == 1
  133471             :         memset(pointer, 0x00, SgOmpDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpDistributeParallelForSimdStatement));
  133472             : #elif ROSE_ALLOC_MEMSET == 2
  133473             :         memset(pointer, 0xCC, SgOmpDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpDistributeParallelForSimdStatement));
  133474             : #endif
  133475           0 :         SgOmpDistributeParallelForSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  133476           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpDistributeParallelForSimdStatement), V_SgOmpDistributeParallelForSimdStatement ) );
  133477             : 
  133478           0 :         if ( SgOmpDistributeParallelForSimdStatement::next_node != NULL ) {
  133479           0 :           if ( blockIndex > 0 ) {
  133480           0 :             SgOmpDistributeParallelForSimdStatement * blkptr = (SgOmpDistributeParallelForSimdStatement*)(SgOmpDistributeParallelForSimdStatement::pools[blockIndex-1]);
  133481           0 :             blkptr[ SgOmpDistributeParallelForSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  133482             :           }
  133483             :         } else {
  133484           0 :           SgOmpDistributeParallelForSimdStatement::next_node = pointer;
  133485             :         }
  133486             : 
  133487           0 :         for (unsigned i = 0; i < SgOmpDistributeParallelForSimdStatement::pool_size-1; ++i)
  133488             :            {
  133489           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  133490             :            }
  133491           0 :         pointer[ SgOmpDistributeParallelForSimdStatement::pool_size -1 ].set_freepointer(NULL);
  133492             : 
  133493           0 :         blockIndex++;
  133494             :       }
  133495           2 :   }
  133496             : 
  133497             : //############################################################################
  133498             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  133499             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  133500             :  * not compressed. However, that stuff is not yet implemented! 
  133501             :  */
  133502             : unsigned long
  133503           0 : SgOmpDistributeParallelForSimdStatement::getNumberOfLastValidPointer()
  133504             :    {
  133505           0 :       SgOmpDistributeParallelForSimdStatement* testPointer = (SgOmpDistributeParallelForSimdStatement*)(SgOmpDistributeParallelForSimdStatement::pools.back());
  133506           0 :       unsigned long localIndex = SgOmpDistributeParallelForSimdStatement::pool_size - 1;
  133507           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  133508             :          {
  133509           0 :            localIndex--;
  133510             :          }
  133511           0 :       return (localIndex + SgOmpDistributeParallelForSimdStatement::pool_size * (SgOmpDistributeParallelForSimdStatement::pools.size()-1));
  133512             :    }
  133513             : 
  133514             : //############################################################################
  133515             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  133516             :  * memory pool and initializes the data member in class SgOmpDistributeParallelForSimdStatementStroageClass
  133517             :  * from its counterpart of SgOmpDistributeParallelForSimdStatement. The return value is just for checking, 
  133518             :  * that the whole StorageClassArray is initialized!
  133519             :  */
  133520             : unsigned long
  133521           0 : SgOmpDistributeParallelForSimdStatement::initializeStorageClassArray( SgOmpDistributeParallelForSimdStatementStorageClass *storageArray )
  133522             :    {
  133523           0 :      unsigned long storageCounter = 0;
  133524           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDistributeParallelForSimdStatement::pools.begin();
  133525           0 :      SgOmpDistributeParallelForSimdStatement* pointer = NULL;
  133526           0 :      while ( block != SgOmpDistributeParallelForSimdStatement::pools.end() ) {
  133527           0 :           pointer = (SgOmpDistributeParallelForSimdStatement*) (*block);
  133528           0 :           for ( unsigned i = 0; i < SgOmpDistributeParallelForSimdStatement::pool_size; ++i ) {
  133529           0 :                if ( pointer->get_freepointer() != NULL ) {
  133530           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  133531           0 :                  storageArray++;
  133532           0 :                  storageCounter++;
  133533             :                }
  133534           0 :                pointer++;
  133535             :              }
  133536           0 :            block++;
  133537             :         }
  133538           0 :      return storageCounter;
  133539             :    }
  133540             : 
  133541             : /* #line 133542 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  133542             : 
  133543             : 
  133544             : 
  133545             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  133546             : 
  133547             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  133548             : 
  133549             : //############################################################################
  133550             : /* JH (02/02/2006) Constructor of the IR node SgOmpTaskloopSimdStatement that takes its 
  133551             :  * corresponding StorageClass as parameter
  133552             :  */
  133553           0 : SgOmpTaskloopSimdStatement :: SgOmpTaskloopSimdStatement ( const SgOmpTaskloopSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  133554             :    {
  133555             : 
  133556             : 
  133557             : /* #line 133558 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  133558             : 
  133559           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  133560             : 
  133561             : 
  133562             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  133563             : 
  133564             : 
  133565           0 :    }
  133566             : 
  133567             : //############################################################################
  133568             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  133569             :  * within the working AST. 
  133570             :  */
  133571           0 : SgOmpTaskloopSimdStatement * SgOmpTaskloopSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  133572           0 :      SgOmpTaskloopSimdStatement* returnPointer = NULL;
  133573           0 :      if ( globalIndex != 0 )
  133574             :         {
  133575             : 
  133576             : #if FILE_IO_EXTRA_CHECK
  133577           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTaskloopSimdStatement ) ) <= globalIndex ) ;
  133578           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskloopSimdStatement + 1 ) ) );
  133579             : #endif
  133580           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTaskloopSimdStatement )  
  133581           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTaskloopSimdStatement );
  133582           0 :           unsigned long positionInPool = localIndex % SgOmpTaskloopSimdStatement::pool_size;
  133583           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskloopSimdStatement::pool_size;
  133584             : 
  133585             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  133586             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  133587             : 
  133588           0 :           returnPointer = &( ( (SgOmpTaskloopSimdStatement*)(SgOmpTaskloopSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  133589             : 
  133590           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  133591             :         }
  133592           0 :      return returnPointer ;
  133593             :    }
  133594             : 
  133595             : //############################################################################
  133596             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  133597             :   for the AST with the index astIndex
  133598             : */
  133599           0 : SgOmpTaskloopSimdStatement * SgOmpTaskloopSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  133600           0 :      SgOmpTaskloopSimdStatement* returnPointer = NULL;
  133601           0 :      if ( globalIndex != 0 )
  133602             :         {
  133603             : 
  133604             : #if FILE_IO_EXTRA_CHECK
  133605           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTaskloopSimdStatement ) ) <= globalIndex ) ;
  133606           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskloopSimdStatement + 1 ) ) );
  133607             : #endif
  133608           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTaskloopSimdStatement )
  133609           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTaskloopSimdStatement );
  133610           0 :           unsigned long positionInPool = localIndex % SgOmpTaskloopSimdStatement::pool_size ;
  133611           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTaskloopSimdStatement::pool_size ;
  133612             : 
  133613             : #if FILE_IO_EXTRA_CHECK
  133614             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  133615             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  133616             : #endif
  133617             : 
  133618           0 :           returnPointer = &( ( (SgOmpTaskloopSimdStatement*)(SgOmpTaskloopSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  133619             : 
  133620             : #if FILE_IO_EXTRA_CHECK
  133621           0 :           assert ( returnPointer != NULL ) ;
  133622             : #endif
  133623             :         }
  133624           0 :      return returnPointer ;
  133625             :    }
  133626             : 
  133627             : //############################################################################
  133628             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  133629             :  * pool size! We set for every valid object in the memory pool the freepointer
  133630             :  * to the global index and increase the global index afterwards. For all the 
  133631             :  * invalid objects (means address ranges within the memory pool that were not
  133632             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  133633             :  * distinguish valid from invalid objects! 
  133634             :  */
  133635             : unsigned long
  133636           5 : SgOmpTaskloopSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  133637             :    {
  133638           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  133639           5 :      SgOmpTaskloopSimdStatement* pointer = NULL;
  133640           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  133641           5 :      std::vector < unsigned char* > :: const_iterator block;
  133642           5 :      for ( block = SgOmpTaskloopSimdStatement::pools.begin(); block != SgOmpTaskloopSimdStatement::pools.end() ; ++block )
  133643             :         {
  133644           0 :           pointer = (SgOmpTaskloopSimdStatement*)(*block);
  133645           0 :           for (unsigned i = 0; i < SgOmpTaskloopSimdStatement::pool_size; ++i )
  133646             :              {
  133647             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  133648             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  133649             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  133650             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  133651             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  133652             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  133653             :             // properly; so this will have to be checked next.
  133654             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  133655             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  133656           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  133657             :                   {
  133658           0 :                     pointer[i].set_freepointer((SgOmpTaskloopSimdStatement*)(globalIndex));
  133659           0 :                     globalIndex++;
  133660             :                   }
  133661             :                else
  133662             :                   {
  133663           0 :                     pointer[i].set_freepointer(NULL);
  133664             :                   }
  133665             :               }
  133666             :         }
  133667           5 :      return globalIndex;
  133668             :    }
  133669             : 
  133670             : //############################################################################
  133671             : // JH (01/14/2006)
  133672             : void
  133673           5 : SgOmpTaskloopSimdStatement::resetValidFreepointers( )
  133674             :    {
  133675           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  133676           5 :      SgOmpTaskloopSimdStatement* pointer = NULL;
  133677           5 :      std::vector < unsigned char* > :: const_iterator block;
  133678           5 :      SgOmpTaskloopSimdStatement* pointerOfLinkedList = NULL;
  133679           5 :      for ( block = SgOmpTaskloopSimdStatement::pools.begin(); block != SgOmpTaskloopSimdStatement::pools.end() ; ++block )
  133680             :         {
  133681           0 :           pointer = (SgOmpTaskloopSimdStatement*)(*block);
  133682           0 :           for (unsigned i = 0; i < SgOmpTaskloopSimdStatement::pool_size; ++i )
  133683             :              {
  133684             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  133685             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  133686             :             // memory blocks!.
  133687           0 :                if ( pointer[i].get_freepointer() != NULL )
  133688             :                   {
  133689           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  133690             :                   }
  133691             :                else
  133692             :                   {
  133693           0 :                     if ( pointerOfLinkedList == NULL )
  133694             :                        {
  133695           0 :                          SgOmpTaskloopSimdStatement::next_node = &(pointer[i]);
  133696             :                        }
  133697             :                     else
  133698             :                        {
  133699             :                       // printf ("In SgOmpTaskloopSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  133700           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  133701             :                        }
  133702             :                     pointerOfLinkedList = &(pointer[i]);
  133703             :                   }
  133704             :               }
  133705             :         }
  133706             : 
  133707           5 :      if ( pointerOfLinkedList != NULL )
  133708             :         {
  133709             :        // printf ("In SgOmpTaskloopSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  133710           0 :           pointerOfLinkedList->set_freepointer(NULL);
  133711             :        // DQ (6/6/2010): Temporary debugging...
  133712             :        //   ROSE_ASSERT(false);
  133713             :         }
  133714             : 
  133715           5 :      return ;
  133716             :    }
  133717             : 
  133718             : //############################################################################
  133719             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  133720             :  * within the memory pool and resets the freepointers, in order to achieve a 
  133721             :  * linked list, that has no jumps and starts at the beginning! This function 
  133722             :  * does not extend the memory pool, since we do not delete any memory blocks,
  133723             :  * but delete the valid objects.  
  133724             :  */
  133725             : void
  133726           0 : SgOmpTaskloopSimdStatement::clearMemoryPool( )
  133727             :    {
  133728             :   // printf ("Inside of SgOmpTaskloopSimdStatement::clearMemoryPool() \n");
  133729             : 
  133730           0 :      SgOmpTaskloopSimdStatement* pointer = NULL, *tempPointer = NULL;
  133731           0 :      std::vector < unsigned char* > :: const_iterator block;
  133732           0 :      if ( SgOmpTaskloopSimdStatement::pools.empty() == false )
  133733             :         {
  133734           0 :           block = SgOmpTaskloopSimdStatement::pools.begin() ;
  133735           0 :           SgOmpTaskloopSimdStatement::next_node = (SgOmpTaskloopSimdStatement*) (*block);
  133736             : 
  133737           0 :           while ( block != SgOmpTaskloopSimdStatement::pools.end() )
  133738             :              {
  133739           0 :                pointer = (SgOmpTaskloopSimdStatement*) (*block);
  133740           0 :                if ( tempPointer != NULL )
  133741             :                   {
  133742           0 :                     tempPointer->set_freepointer(pointer);
  133743             :                   }
  133744           0 :                for (unsigned i = 0; i < SgOmpTaskloopSimdStatement::pool_size - 1; ++i)
  133745             :                   {
  133746           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  133747             :                   }
  133748           0 :                 pointer[SgOmpTaskloopSimdStatement::pool_size-1].set_freepointer(NULL);
  133749           0 :                 tempPointer = &(pointer[SgOmpTaskloopSimdStatement::pool_size-1]);
  133750           0 :                 ++block;
  133751             :              }
  133752             :         }
  133753           0 :    }
  133754             : 
  133755           5 : void SgOmpTaskloopSimdStatement::deleteMemoryPool() {
  133756           5 :   for (auto p: SgOmpTaskloopSimdStatement::pools) {
  133757           0 :     ROSE_FREE(p);
  133758             :   }
  133759           5 :   SgOmpTaskloopSimdStatement::next_node = nullptr;
  133760           5 :   SgOmpTaskloopSimdStatement::pools.clear();
  133761           5 : }
  133762             : 
  133763             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  133764             : //                 reading multiple binary files to for a single AST.
  133765             : /////////// new version ////////////////////////////////
  133766             : //############################################################################
  133767             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  133768             : void
  133769           2 : SgOmpTaskloopSimdStatement::extendMemoryPoolForFileIO( )
  133770             :   {
  133771           2 :     size_t blockIndex = SgOmpTaskloopSimdStatement::pools.size();
  133772           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskloopSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskloopSimdStatement);
  133773             : 
  133774           2 :     while ( (blockIndex * SgOmpTaskloopSimdStatement::pool_size) < newPoolSize)
  133775             :       {
  133776             : #if ROSE_ALLOC_TRACE
  133777             :         if (blockIndex > 0) {
  133778             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskloopSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskloopSimdStatement) = %" PRIuPTR " SgOmpTaskloopSimdStatement::pool_size = %d \n",
  133779             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTaskloopSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTaskloopSimdStatement),SgOmpTaskloopSimdStatement::pool_size);
  133780             :         }
  133781             : #endif
  133782             : 
  133783           0 :         SgOmpTaskloopSimdStatement * pointer = (SgOmpTaskloopSimdStatement*) ROSE_MALLOC ( SgOmpTaskloopSimdStatement::pool_size * sizeof(SgOmpTaskloopSimdStatement) );
  133784           0 :         assert( pointer != NULL );
  133785             : #if ROSE_ALLOC_MEMSET == 1
  133786             :         memset(pointer, 0x00, SgOmpTaskloopSimdStatement::pool_size * sizeof(SgOmpTaskloopSimdStatement));
  133787             : #elif ROSE_ALLOC_MEMSET == 2
  133788             :         memset(pointer, 0xCC, SgOmpTaskloopSimdStatement::pool_size * sizeof(SgOmpTaskloopSimdStatement));
  133789             : #endif
  133790           0 :         SgOmpTaskloopSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  133791           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTaskloopSimdStatement::pool_size * sizeof(SgOmpTaskloopSimdStatement), V_SgOmpTaskloopSimdStatement ) );
  133792             : 
  133793           0 :         if ( SgOmpTaskloopSimdStatement::next_node != NULL ) {
  133794           0 :           if ( blockIndex > 0 ) {
  133795           0 :             SgOmpTaskloopSimdStatement * blkptr = (SgOmpTaskloopSimdStatement*)(SgOmpTaskloopSimdStatement::pools[blockIndex-1]);
  133796           0 :             blkptr[ SgOmpTaskloopSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  133797             :           }
  133798             :         } else {
  133799           0 :           SgOmpTaskloopSimdStatement::next_node = pointer;
  133800             :         }
  133801             : 
  133802           0 :         for (unsigned i = 0; i < SgOmpTaskloopSimdStatement::pool_size-1; ++i)
  133803             :            {
  133804           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  133805             :            }
  133806           0 :         pointer[ SgOmpTaskloopSimdStatement::pool_size -1 ].set_freepointer(NULL);
  133807             : 
  133808           0 :         blockIndex++;
  133809             :       }
  133810           2 :   }
  133811             : 
  133812             : //############################################################################
  133813             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  133814             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  133815             :  * not compressed. However, that stuff is not yet implemented! 
  133816             :  */
  133817             : unsigned long
  133818           0 : SgOmpTaskloopSimdStatement::getNumberOfLastValidPointer()
  133819             :    {
  133820           0 :       SgOmpTaskloopSimdStatement* testPointer = (SgOmpTaskloopSimdStatement*)(SgOmpTaskloopSimdStatement::pools.back());
  133821           0 :       unsigned long localIndex = SgOmpTaskloopSimdStatement::pool_size - 1;
  133822           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  133823             :          {
  133824           0 :            localIndex--;
  133825             :          }
  133826           0 :       return (localIndex + SgOmpTaskloopSimdStatement::pool_size * (SgOmpTaskloopSimdStatement::pools.size()-1));
  133827             :    }
  133828             : 
  133829             : //############################################################################
  133830             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  133831             :  * memory pool and initializes the data member in class SgOmpTaskloopSimdStatementStroageClass
  133832             :  * from its counterpart of SgOmpTaskloopSimdStatement. The return value is just for checking, 
  133833             :  * that the whole StorageClassArray is initialized!
  133834             :  */
  133835             : unsigned long
  133836           0 : SgOmpTaskloopSimdStatement::initializeStorageClassArray( SgOmpTaskloopSimdStatementStorageClass *storageArray )
  133837             :    {
  133838           0 :      unsigned long storageCounter = 0;
  133839           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTaskloopSimdStatement::pools.begin();
  133840           0 :      SgOmpTaskloopSimdStatement* pointer = NULL;
  133841           0 :      while ( block != SgOmpTaskloopSimdStatement::pools.end() ) {
  133842           0 :           pointer = (SgOmpTaskloopSimdStatement*) (*block);
  133843           0 :           for ( unsigned i = 0; i < SgOmpTaskloopSimdStatement::pool_size; ++i ) {
  133844           0 :                if ( pointer->get_freepointer() != NULL ) {
  133845           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  133846           0 :                  storageArray++;
  133847           0 :                  storageCounter++;
  133848             :                }
  133849           0 :                pointer++;
  133850             :              }
  133851           0 :            block++;
  133852             :         }
  133853           0 :      return storageCounter;
  133854             :    }
  133855             : 
  133856             : /* #line 133857 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  133857             : 
  133858             : 
  133859             : 
  133860             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  133861             : 
  133862             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  133863             : 
  133864             : //############################################################################
  133865             : /* JH (02/02/2006) Constructor of the IR node SgOmpMasterTaskloopSimdStatement that takes its 
  133866             :  * corresponding StorageClass as parameter
  133867             :  */
  133868           0 : SgOmpMasterTaskloopSimdStatement :: SgOmpMasterTaskloopSimdStatement ( const SgOmpMasterTaskloopSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  133869             :    {
  133870             : 
  133871             : 
  133872             : /* #line 133873 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  133873             : 
  133874           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  133875             : 
  133876             : 
  133877             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  133878             : 
  133879             : 
  133880           0 :    }
  133881             : 
  133882             : //############################################################################
  133883             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  133884             :  * within the working AST. 
  133885             :  */
  133886           0 : SgOmpMasterTaskloopSimdStatement * SgOmpMasterTaskloopSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  133887           0 :      SgOmpMasterTaskloopSimdStatement* returnPointer = NULL;
  133888           0 :      if ( globalIndex != 0 )
  133889             :         {
  133890             : 
  133891             : #if FILE_IO_EXTRA_CHECK
  133892           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpMasterTaskloopSimdStatement ) ) <= globalIndex ) ;
  133893           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMasterTaskloopSimdStatement + 1 ) ) );
  133894             : #endif
  133895           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpMasterTaskloopSimdStatement )  
  133896           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpMasterTaskloopSimdStatement );
  133897           0 :           unsigned long positionInPool = localIndex % SgOmpMasterTaskloopSimdStatement::pool_size;
  133898           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMasterTaskloopSimdStatement::pool_size;
  133899             : 
  133900             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  133901             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  133902             : 
  133903           0 :           returnPointer = &( ( (SgOmpMasterTaskloopSimdStatement*)(SgOmpMasterTaskloopSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  133904             : 
  133905           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  133906             :         }
  133907           0 :      return returnPointer ;
  133908             :    }
  133909             : 
  133910             : //############################################################################
  133911             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  133912             :   for the AST with the index astIndex
  133913             : */
  133914           0 : SgOmpMasterTaskloopSimdStatement * SgOmpMasterTaskloopSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  133915           0 :      SgOmpMasterTaskloopSimdStatement* returnPointer = NULL;
  133916           0 :      if ( globalIndex != 0 )
  133917             :         {
  133918             : 
  133919             : #if FILE_IO_EXTRA_CHECK
  133920           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpMasterTaskloopSimdStatement ) ) <= globalIndex ) ;
  133921           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMasterTaskloopSimdStatement + 1 ) ) );
  133922             : #endif
  133923           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpMasterTaskloopSimdStatement )
  133924           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpMasterTaskloopSimdStatement );
  133925           0 :           unsigned long positionInPool = localIndex % SgOmpMasterTaskloopSimdStatement::pool_size ;
  133926           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpMasterTaskloopSimdStatement::pool_size ;
  133927             : 
  133928             : #if FILE_IO_EXTRA_CHECK
  133929             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  133930             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  133931             : #endif
  133932             : 
  133933           0 :           returnPointer = &( ( (SgOmpMasterTaskloopSimdStatement*)(SgOmpMasterTaskloopSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  133934             : 
  133935             : #if FILE_IO_EXTRA_CHECK
  133936           0 :           assert ( returnPointer != NULL ) ;
  133937             : #endif
  133938             :         }
  133939           0 :      return returnPointer ;
  133940             :    }
  133941             : 
  133942             : //############################################################################
  133943             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  133944             :  * pool size! We set for every valid object in the memory pool the freepointer
  133945             :  * to the global index and increase the global index afterwards. For all the 
  133946             :  * invalid objects (means address ranges within the memory pool that were not
  133947             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  133948             :  * distinguish valid from invalid objects! 
  133949             :  */
  133950             : unsigned long
  133951           5 : SgOmpMasterTaskloopSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  133952             :    {
  133953           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  133954           5 :      SgOmpMasterTaskloopSimdStatement* pointer = NULL;
  133955           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  133956           5 :      std::vector < unsigned char* > :: const_iterator block;
  133957           5 :      for ( block = SgOmpMasterTaskloopSimdStatement::pools.begin(); block != SgOmpMasterTaskloopSimdStatement::pools.end() ; ++block )
  133958             :         {
  133959           0 :           pointer = (SgOmpMasterTaskloopSimdStatement*)(*block);
  133960           0 :           for (unsigned i = 0; i < SgOmpMasterTaskloopSimdStatement::pool_size; ++i )
  133961             :              {
  133962             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  133963             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  133964             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  133965             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  133966             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  133967             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  133968             :             // properly; so this will have to be checked next.
  133969             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  133970             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  133971           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  133972             :                   {
  133973           0 :                     pointer[i].set_freepointer((SgOmpMasterTaskloopSimdStatement*)(globalIndex));
  133974           0 :                     globalIndex++;
  133975             :                   }
  133976             :                else
  133977             :                   {
  133978           0 :                     pointer[i].set_freepointer(NULL);
  133979             :                   }
  133980             :               }
  133981             :         }
  133982           5 :      return globalIndex;
  133983             :    }
  133984             : 
  133985             : //############################################################################
  133986             : // JH (01/14/2006)
  133987             : void
  133988           5 : SgOmpMasterTaskloopSimdStatement::resetValidFreepointers( )
  133989             :    {
  133990           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  133991           5 :      SgOmpMasterTaskloopSimdStatement* pointer = NULL;
  133992           5 :      std::vector < unsigned char* > :: const_iterator block;
  133993           5 :      SgOmpMasterTaskloopSimdStatement* pointerOfLinkedList = NULL;
  133994           5 :      for ( block = SgOmpMasterTaskloopSimdStatement::pools.begin(); block != SgOmpMasterTaskloopSimdStatement::pools.end() ; ++block )
  133995             :         {
  133996           0 :           pointer = (SgOmpMasterTaskloopSimdStatement*)(*block);
  133997           0 :           for (unsigned i = 0; i < SgOmpMasterTaskloopSimdStatement::pool_size; ++i )
  133998             :              {
  133999             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  134000             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  134001             :             // memory blocks!.
  134002           0 :                if ( pointer[i].get_freepointer() != NULL )
  134003             :                   {
  134004           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  134005             :                   }
  134006             :                else
  134007             :                   {
  134008           0 :                     if ( pointerOfLinkedList == NULL )
  134009             :                        {
  134010           0 :                          SgOmpMasterTaskloopSimdStatement::next_node = &(pointer[i]);
  134011             :                        }
  134012             :                     else
  134013             :                        {
  134014             :                       // printf ("In SgOmpMasterTaskloopSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  134015           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  134016             :                        }
  134017             :                     pointerOfLinkedList = &(pointer[i]);
  134018             :                   }
  134019             :               }
  134020             :         }
  134021             : 
  134022           5 :      if ( pointerOfLinkedList != NULL )
  134023             :         {
  134024             :        // printf ("In SgOmpMasterTaskloopSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  134025           0 :           pointerOfLinkedList->set_freepointer(NULL);
  134026             :        // DQ (6/6/2010): Temporary debugging...
  134027             :        //   ROSE_ASSERT(false);
  134028             :         }
  134029             : 
  134030           5 :      return ;
  134031             :    }
  134032             : 
  134033             : //############################################################################
  134034             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  134035             :  * within the memory pool and resets the freepointers, in order to achieve a 
  134036             :  * linked list, that has no jumps and starts at the beginning! This function 
  134037             :  * does not extend the memory pool, since we do not delete any memory blocks,
  134038             :  * but delete the valid objects.  
  134039             :  */
  134040             : void
  134041           0 : SgOmpMasterTaskloopSimdStatement::clearMemoryPool( )
  134042             :    {
  134043             :   // printf ("Inside of SgOmpMasterTaskloopSimdStatement::clearMemoryPool() \n");
  134044             : 
  134045           0 :      SgOmpMasterTaskloopSimdStatement* pointer = NULL, *tempPointer = NULL;
  134046           0 :      std::vector < unsigned char* > :: const_iterator block;
  134047           0 :      if ( SgOmpMasterTaskloopSimdStatement::pools.empty() == false )
  134048             :         {
  134049           0 :           block = SgOmpMasterTaskloopSimdStatement::pools.begin() ;
  134050           0 :           SgOmpMasterTaskloopSimdStatement::next_node = (SgOmpMasterTaskloopSimdStatement*) (*block);
  134051             : 
  134052           0 :           while ( block != SgOmpMasterTaskloopSimdStatement::pools.end() )
  134053             :              {
  134054           0 :                pointer = (SgOmpMasterTaskloopSimdStatement*) (*block);
  134055           0 :                if ( tempPointer != NULL )
  134056             :                   {
  134057           0 :                     tempPointer->set_freepointer(pointer);
  134058             :                   }
  134059           0 :                for (unsigned i = 0; i < SgOmpMasterTaskloopSimdStatement::pool_size - 1; ++i)
  134060             :                   {
  134061           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  134062             :                   }
  134063           0 :                 pointer[SgOmpMasterTaskloopSimdStatement::pool_size-1].set_freepointer(NULL);
  134064           0 :                 tempPointer = &(pointer[SgOmpMasterTaskloopSimdStatement::pool_size-1]);
  134065           0 :                 ++block;
  134066             :              }
  134067             :         }
  134068           0 :    }
  134069             : 
  134070           5 : void SgOmpMasterTaskloopSimdStatement::deleteMemoryPool() {
  134071           5 :   for (auto p: SgOmpMasterTaskloopSimdStatement::pools) {
  134072           0 :     ROSE_FREE(p);
  134073             :   }
  134074           5 :   SgOmpMasterTaskloopSimdStatement::next_node = nullptr;
  134075           5 :   SgOmpMasterTaskloopSimdStatement::pools.clear();
  134076           5 : }
  134077             : 
  134078             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  134079             : //                 reading multiple binary files to for a single AST.
  134080             : /////////// new version ////////////////////////////////
  134081             : //############################################################################
  134082             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  134083             : void
  134084           2 : SgOmpMasterTaskloopSimdStatement::extendMemoryPoolForFileIO( )
  134085             :   {
  134086           2 :     size_t blockIndex = SgOmpMasterTaskloopSimdStatement::pools.size();
  134087           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterTaskloopSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterTaskloopSimdStatement);
  134088             : 
  134089           2 :     while ( (blockIndex * SgOmpMasterTaskloopSimdStatement::pool_size) < newPoolSize)
  134090             :       {
  134091             : #if ROSE_ALLOC_TRACE
  134092             :         if (blockIndex > 0) {
  134093             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterTaskloopSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterTaskloopSimdStatement) = %" PRIuPTR " SgOmpMasterTaskloopSimdStatement::pool_size = %d \n",
  134094             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpMasterTaskloopSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpMasterTaskloopSimdStatement),SgOmpMasterTaskloopSimdStatement::pool_size);
  134095             :         }
  134096             : #endif
  134097             : 
  134098           0 :         SgOmpMasterTaskloopSimdStatement * pointer = (SgOmpMasterTaskloopSimdStatement*) ROSE_MALLOC ( SgOmpMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpMasterTaskloopSimdStatement) );
  134099           0 :         assert( pointer != NULL );
  134100             : #if ROSE_ALLOC_MEMSET == 1
  134101             :         memset(pointer, 0x00, SgOmpMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpMasterTaskloopSimdStatement));
  134102             : #elif ROSE_ALLOC_MEMSET == 2
  134103             :         memset(pointer, 0xCC, SgOmpMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpMasterTaskloopSimdStatement));
  134104             : #endif
  134105           0 :         SgOmpMasterTaskloopSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  134106           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpMasterTaskloopSimdStatement), V_SgOmpMasterTaskloopSimdStatement ) );
  134107             : 
  134108           0 :         if ( SgOmpMasterTaskloopSimdStatement::next_node != NULL ) {
  134109           0 :           if ( blockIndex > 0 ) {
  134110           0 :             SgOmpMasterTaskloopSimdStatement * blkptr = (SgOmpMasterTaskloopSimdStatement*)(SgOmpMasterTaskloopSimdStatement::pools[blockIndex-1]);
  134111           0 :             blkptr[ SgOmpMasterTaskloopSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  134112             :           }
  134113             :         } else {
  134114           0 :           SgOmpMasterTaskloopSimdStatement::next_node = pointer;
  134115             :         }
  134116             : 
  134117           0 :         for (unsigned i = 0; i < SgOmpMasterTaskloopSimdStatement::pool_size-1; ++i)
  134118             :            {
  134119           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  134120             :            }
  134121           0 :         pointer[ SgOmpMasterTaskloopSimdStatement::pool_size -1 ].set_freepointer(NULL);
  134122             : 
  134123           0 :         blockIndex++;
  134124             :       }
  134125           2 :   }
  134126             : 
  134127             : //############################################################################
  134128             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  134129             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  134130             :  * not compressed. However, that stuff is not yet implemented! 
  134131             :  */
  134132             : unsigned long
  134133           0 : SgOmpMasterTaskloopSimdStatement::getNumberOfLastValidPointer()
  134134             :    {
  134135           0 :       SgOmpMasterTaskloopSimdStatement* testPointer = (SgOmpMasterTaskloopSimdStatement*)(SgOmpMasterTaskloopSimdStatement::pools.back());
  134136           0 :       unsigned long localIndex = SgOmpMasterTaskloopSimdStatement::pool_size - 1;
  134137           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  134138             :          {
  134139           0 :            localIndex--;
  134140             :          }
  134141           0 :       return (localIndex + SgOmpMasterTaskloopSimdStatement::pool_size * (SgOmpMasterTaskloopSimdStatement::pools.size()-1));
  134142             :    }
  134143             : 
  134144             : //############################################################################
  134145             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  134146             :  * memory pool and initializes the data member in class SgOmpMasterTaskloopSimdStatementStroageClass
  134147             :  * from its counterpart of SgOmpMasterTaskloopSimdStatement. The return value is just for checking, 
  134148             :  * that the whole StorageClassArray is initialized!
  134149             :  */
  134150             : unsigned long
  134151           0 : SgOmpMasterTaskloopSimdStatement::initializeStorageClassArray( SgOmpMasterTaskloopSimdStatementStorageClass *storageArray )
  134152             :    {
  134153           0 :      unsigned long storageCounter = 0;
  134154           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpMasterTaskloopSimdStatement::pools.begin();
  134155           0 :      SgOmpMasterTaskloopSimdStatement* pointer = NULL;
  134156           0 :      while ( block != SgOmpMasterTaskloopSimdStatement::pools.end() ) {
  134157           0 :           pointer = (SgOmpMasterTaskloopSimdStatement*) (*block);
  134158           0 :           for ( unsigned i = 0; i < SgOmpMasterTaskloopSimdStatement::pool_size; ++i ) {
  134159           0 :                if ( pointer->get_freepointer() != NULL ) {
  134160           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  134161           0 :                  storageArray++;
  134162           0 :                  storageCounter++;
  134163             :                }
  134164           0 :                pointer++;
  134165             :              }
  134166           0 :            block++;
  134167             :         }
  134168           0 :      return storageCounter;
  134169             :    }
  134170             : 
  134171             : /* #line 134172 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  134172             : 
  134173             : 
  134174             : 
  134175             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  134176             : 
  134177             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  134178             : 
  134179             : //############################################################################
  134180             : /* JH (02/02/2006) Constructor of the IR node SgOmpParallelMasterTaskloopStatement that takes its 
  134181             :  * corresponding StorageClass as parameter
  134182             :  */
  134183           0 : SgOmpParallelMasterTaskloopStatement :: SgOmpParallelMasterTaskloopStatement ( const SgOmpParallelMasterTaskloopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  134184             :    {
  134185             : 
  134186             : 
  134187             : /* #line 134188 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  134188             : 
  134189           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  134190             : 
  134191             : 
  134192             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  134193             : 
  134194             : 
  134195           0 :    }
  134196             : 
  134197             : //############################################################################
  134198             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  134199             :  * within the working AST. 
  134200             :  */
  134201           0 : SgOmpParallelMasterTaskloopStatement * SgOmpParallelMasterTaskloopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  134202           0 :      SgOmpParallelMasterTaskloopStatement* returnPointer = NULL;
  134203           0 :      if ( globalIndex != 0 )
  134204             :         {
  134205             : 
  134206             : #if FILE_IO_EXTRA_CHECK
  134207           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpParallelMasterTaskloopStatement ) ) <= globalIndex ) ;
  134208           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelMasterTaskloopStatement + 1 ) ) );
  134209             : #endif
  134210           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelMasterTaskloopStatement )  
  134211           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpParallelMasterTaskloopStatement );
  134212           0 :           unsigned long positionInPool = localIndex % SgOmpParallelMasterTaskloopStatement::pool_size;
  134213           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelMasterTaskloopStatement::pool_size;
  134214             : 
  134215             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  134216             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  134217             : 
  134218           0 :           returnPointer = &( ( (SgOmpParallelMasterTaskloopStatement*)(SgOmpParallelMasterTaskloopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  134219             : 
  134220           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  134221             :         }
  134222           0 :      return returnPointer ;
  134223             :    }
  134224             : 
  134225             : //############################################################################
  134226             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  134227             :   for the AST with the index astIndex
  134228             : */
  134229           0 : SgOmpParallelMasterTaskloopStatement * SgOmpParallelMasterTaskloopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  134230           0 :      SgOmpParallelMasterTaskloopStatement* returnPointer = NULL;
  134231           0 :      if ( globalIndex != 0 )
  134232             :         {
  134233             : 
  134234             : #if FILE_IO_EXTRA_CHECK
  134235           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpParallelMasterTaskloopStatement ) ) <= globalIndex ) ;
  134236           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelMasterTaskloopStatement + 1 ) ) );
  134237             : #endif
  134238           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelMasterTaskloopStatement )
  134239           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpParallelMasterTaskloopStatement );
  134240           0 :           unsigned long positionInPool = localIndex % SgOmpParallelMasterTaskloopStatement::pool_size ;
  134241           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelMasterTaskloopStatement::pool_size ;
  134242             : 
  134243             : #if FILE_IO_EXTRA_CHECK
  134244             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  134245             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  134246             : #endif
  134247             : 
  134248           0 :           returnPointer = &( ( (SgOmpParallelMasterTaskloopStatement*)(SgOmpParallelMasterTaskloopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  134249             : 
  134250             : #if FILE_IO_EXTRA_CHECK
  134251           0 :           assert ( returnPointer != NULL ) ;
  134252             : #endif
  134253             :         }
  134254           0 :      return returnPointer ;
  134255             :    }
  134256             : 
  134257             : //############################################################################
  134258             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  134259             :  * pool size! We set for every valid object in the memory pool the freepointer
  134260             :  * to the global index and increase the global index afterwards. For all the 
  134261             :  * invalid objects (means address ranges within the memory pool that were not
  134262             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  134263             :  * distinguish valid from invalid objects! 
  134264             :  */
  134265             : unsigned long
  134266           5 : SgOmpParallelMasterTaskloopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  134267             :    {
  134268           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  134269           5 :      SgOmpParallelMasterTaskloopStatement* pointer = NULL;
  134270           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  134271           5 :      std::vector < unsigned char* > :: const_iterator block;
  134272           5 :      for ( block = SgOmpParallelMasterTaskloopStatement::pools.begin(); block != SgOmpParallelMasterTaskloopStatement::pools.end() ; ++block )
  134273             :         {
  134274           0 :           pointer = (SgOmpParallelMasterTaskloopStatement*)(*block);
  134275           0 :           for (unsigned i = 0; i < SgOmpParallelMasterTaskloopStatement::pool_size; ++i )
  134276             :              {
  134277             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  134278             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  134279             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  134280             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  134281             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  134282             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  134283             :             // properly; so this will have to be checked next.
  134284             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  134285             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  134286           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  134287             :                   {
  134288           0 :                     pointer[i].set_freepointer((SgOmpParallelMasterTaskloopStatement*)(globalIndex));
  134289           0 :                     globalIndex++;
  134290             :                   }
  134291             :                else
  134292             :                   {
  134293           0 :                     pointer[i].set_freepointer(NULL);
  134294             :                   }
  134295             :               }
  134296             :         }
  134297           5 :      return globalIndex;
  134298             :    }
  134299             : 
  134300             : //############################################################################
  134301             : // JH (01/14/2006)
  134302             : void
  134303           5 : SgOmpParallelMasterTaskloopStatement::resetValidFreepointers( )
  134304             :    {
  134305           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  134306           5 :      SgOmpParallelMasterTaskloopStatement* pointer = NULL;
  134307           5 :      std::vector < unsigned char* > :: const_iterator block;
  134308           5 :      SgOmpParallelMasterTaskloopStatement* pointerOfLinkedList = NULL;
  134309           5 :      for ( block = SgOmpParallelMasterTaskloopStatement::pools.begin(); block != SgOmpParallelMasterTaskloopStatement::pools.end() ; ++block )
  134310             :         {
  134311           0 :           pointer = (SgOmpParallelMasterTaskloopStatement*)(*block);
  134312           0 :           for (unsigned i = 0; i < SgOmpParallelMasterTaskloopStatement::pool_size; ++i )
  134313             :              {
  134314             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  134315             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  134316             :             // memory blocks!.
  134317           0 :                if ( pointer[i].get_freepointer() != NULL )
  134318             :                   {
  134319           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  134320             :                   }
  134321             :                else
  134322             :                   {
  134323           0 :                     if ( pointerOfLinkedList == NULL )
  134324             :                        {
  134325           0 :                          SgOmpParallelMasterTaskloopStatement::next_node = &(pointer[i]);
  134326             :                        }
  134327             :                     else
  134328             :                        {
  134329             :                       // printf ("In SgOmpParallelMasterTaskloopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  134330           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  134331             :                        }
  134332             :                     pointerOfLinkedList = &(pointer[i]);
  134333             :                   }
  134334             :               }
  134335             :         }
  134336             : 
  134337           5 :      if ( pointerOfLinkedList != NULL )
  134338             :         {
  134339             :        // printf ("In SgOmpParallelMasterTaskloopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  134340           0 :           pointerOfLinkedList->set_freepointer(NULL);
  134341             :        // DQ (6/6/2010): Temporary debugging...
  134342             :        //   ROSE_ASSERT(false);
  134343             :         }
  134344             : 
  134345           5 :      return ;
  134346             :    }
  134347             : 
  134348             : //############################################################################
  134349             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  134350             :  * within the memory pool and resets the freepointers, in order to achieve a 
  134351             :  * linked list, that has no jumps and starts at the beginning! This function 
  134352             :  * does not extend the memory pool, since we do not delete any memory blocks,
  134353             :  * but delete the valid objects.  
  134354             :  */
  134355             : void
  134356           0 : SgOmpParallelMasterTaskloopStatement::clearMemoryPool( )
  134357             :    {
  134358             :   // printf ("Inside of SgOmpParallelMasterTaskloopStatement::clearMemoryPool() \n");
  134359             : 
  134360           0 :      SgOmpParallelMasterTaskloopStatement* pointer = NULL, *tempPointer = NULL;
  134361           0 :      std::vector < unsigned char* > :: const_iterator block;
  134362           0 :      if ( SgOmpParallelMasterTaskloopStatement::pools.empty() == false )
  134363             :         {
  134364           0 :           block = SgOmpParallelMasterTaskloopStatement::pools.begin() ;
  134365           0 :           SgOmpParallelMasterTaskloopStatement::next_node = (SgOmpParallelMasterTaskloopStatement*) (*block);
  134366             : 
  134367           0 :           while ( block != SgOmpParallelMasterTaskloopStatement::pools.end() )
  134368             :              {
  134369           0 :                pointer = (SgOmpParallelMasterTaskloopStatement*) (*block);
  134370           0 :                if ( tempPointer != NULL )
  134371             :                   {
  134372           0 :                     tempPointer->set_freepointer(pointer);
  134373             :                   }
  134374           0 :                for (unsigned i = 0; i < SgOmpParallelMasterTaskloopStatement::pool_size - 1; ++i)
  134375             :                   {
  134376           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  134377             :                   }
  134378           0 :                 pointer[SgOmpParallelMasterTaskloopStatement::pool_size-1].set_freepointer(NULL);
  134379           0 :                 tempPointer = &(pointer[SgOmpParallelMasterTaskloopStatement::pool_size-1]);
  134380           0 :                 ++block;
  134381             :              }
  134382             :         }
  134383           0 :    }
  134384             : 
  134385           5 : void SgOmpParallelMasterTaskloopStatement::deleteMemoryPool() {
  134386           5 :   for (auto p: SgOmpParallelMasterTaskloopStatement::pools) {
  134387           0 :     ROSE_FREE(p);
  134388             :   }
  134389           5 :   SgOmpParallelMasterTaskloopStatement::next_node = nullptr;
  134390           5 :   SgOmpParallelMasterTaskloopStatement::pools.clear();
  134391           5 : }
  134392             : 
  134393             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  134394             : //                 reading multiple binary files to for a single AST.
  134395             : /////////// new version ////////////////////////////////
  134396             : //############################################################################
  134397             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  134398             : void
  134399           2 : SgOmpParallelMasterTaskloopStatement::extendMemoryPoolForFileIO( )
  134400             :   {
  134401           2 :     size_t blockIndex = SgOmpParallelMasterTaskloopStatement::pools.size();
  134402           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterTaskloopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterTaskloopStatement);
  134403             : 
  134404           2 :     while ( (blockIndex * SgOmpParallelMasterTaskloopStatement::pool_size) < newPoolSize)
  134405             :       {
  134406             : #if ROSE_ALLOC_TRACE
  134407             :         if (blockIndex > 0) {
  134408             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterTaskloopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterTaskloopStatement) = %" PRIuPTR " SgOmpParallelMasterTaskloopStatement::pool_size = %d \n",
  134409             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterTaskloopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterTaskloopStatement),SgOmpParallelMasterTaskloopStatement::pool_size);
  134410             :         }
  134411             : #endif
  134412             : 
  134413           0 :         SgOmpParallelMasterTaskloopStatement * pointer = (SgOmpParallelMasterTaskloopStatement*) ROSE_MALLOC ( SgOmpParallelMasterTaskloopStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopStatement) );
  134414           0 :         assert( pointer != NULL );
  134415             : #if ROSE_ALLOC_MEMSET == 1
  134416             :         memset(pointer, 0x00, SgOmpParallelMasterTaskloopStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopStatement));
  134417             : #elif ROSE_ALLOC_MEMSET == 2
  134418             :         memset(pointer, 0xCC, SgOmpParallelMasterTaskloopStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopStatement));
  134419             : #endif
  134420           0 :         SgOmpParallelMasterTaskloopStatement::pools.push_back( (unsigned char*)(pointer) );
  134421           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpParallelMasterTaskloopStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopStatement), V_SgOmpParallelMasterTaskloopStatement ) );
  134422             : 
  134423           0 :         if ( SgOmpParallelMasterTaskloopStatement::next_node != NULL ) {
  134424           0 :           if ( blockIndex > 0 ) {
  134425           0 :             SgOmpParallelMasterTaskloopStatement * blkptr = (SgOmpParallelMasterTaskloopStatement*)(SgOmpParallelMasterTaskloopStatement::pools[blockIndex-1]);
  134426           0 :             blkptr[ SgOmpParallelMasterTaskloopStatement::pool_size - 1 ].set_freepointer(pointer);
  134427             :           }
  134428             :         } else {
  134429           0 :           SgOmpParallelMasterTaskloopStatement::next_node = pointer;
  134430             :         }
  134431             : 
  134432           0 :         for (unsigned i = 0; i < SgOmpParallelMasterTaskloopStatement::pool_size-1; ++i)
  134433             :            {
  134434           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  134435             :            }
  134436           0 :         pointer[ SgOmpParallelMasterTaskloopStatement::pool_size -1 ].set_freepointer(NULL);
  134437             : 
  134438           0 :         blockIndex++;
  134439             :       }
  134440           2 :   }
  134441             : 
  134442             : //############################################################################
  134443             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  134444             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  134445             :  * not compressed. However, that stuff is not yet implemented! 
  134446             :  */
  134447             : unsigned long
  134448           0 : SgOmpParallelMasterTaskloopStatement::getNumberOfLastValidPointer()
  134449             :    {
  134450           0 :       SgOmpParallelMasterTaskloopStatement* testPointer = (SgOmpParallelMasterTaskloopStatement*)(SgOmpParallelMasterTaskloopStatement::pools.back());
  134451           0 :       unsigned long localIndex = SgOmpParallelMasterTaskloopStatement::pool_size - 1;
  134452           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  134453             :          {
  134454           0 :            localIndex--;
  134455             :          }
  134456           0 :       return (localIndex + SgOmpParallelMasterTaskloopStatement::pool_size * (SgOmpParallelMasterTaskloopStatement::pools.size()-1));
  134457             :    }
  134458             : 
  134459             : //############################################################################
  134460             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  134461             :  * memory pool and initializes the data member in class SgOmpParallelMasterTaskloopStatementStroageClass
  134462             :  * from its counterpart of SgOmpParallelMasterTaskloopStatement. The return value is just for checking, 
  134463             :  * that the whole StorageClassArray is initialized!
  134464             :  */
  134465             : unsigned long
  134466           0 : SgOmpParallelMasterTaskloopStatement::initializeStorageClassArray( SgOmpParallelMasterTaskloopStatementStorageClass *storageArray )
  134467             :    {
  134468           0 :      unsigned long storageCounter = 0;
  134469           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpParallelMasterTaskloopStatement::pools.begin();
  134470           0 :      SgOmpParallelMasterTaskloopStatement* pointer = NULL;
  134471           0 :      while ( block != SgOmpParallelMasterTaskloopStatement::pools.end() ) {
  134472           0 :           pointer = (SgOmpParallelMasterTaskloopStatement*) (*block);
  134473           0 :           for ( unsigned i = 0; i < SgOmpParallelMasterTaskloopStatement::pool_size; ++i ) {
  134474           0 :                if ( pointer->get_freepointer() != NULL ) {
  134475           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  134476           0 :                  storageArray++;
  134477           0 :                  storageCounter++;
  134478             :                }
  134479           0 :                pointer++;
  134480             :              }
  134481           0 :            block++;
  134482             :         }
  134483           0 :      return storageCounter;
  134484             :    }
  134485             : 
  134486             : /* #line 134487 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  134487             : 
  134488             : 
  134489             : 
  134490             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  134491             : 
  134492             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  134493             : 
  134494             : //############################################################################
  134495             : /* JH (02/02/2006) Constructor of the IR node SgOmpParallelMasterTaskloopSimdStatement that takes its 
  134496             :  * corresponding StorageClass as parameter
  134497             :  */
  134498           0 : SgOmpParallelMasterTaskloopSimdStatement :: SgOmpParallelMasterTaskloopSimdStatement ( const SgOmpParallelMasterTaskloopSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  134499             :    {
  134500             : 
  134501             : 
  134502             : /* #line 134503 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  134503             : 
  134504           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  134505             : 
  134506             : 
  134507             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  134508             : 
  134509             : 
  134510           0 :    }
  134511             : 
  134512             : //############################################################################
  134513             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  134514             :  * within the working AST. 
  134515             :  */
  134516           0 : SgOmpParallelMasterTaskloopSimdStatement * SgOmpParallelMasterTaskloopSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  134517           0 :      SgOmpParallelMasterTaskloopSimdStatement* returnPointer = NULL;
  134518           0 :      if ( globalIndex != 0 )
  134519             :         {
  134520             : 
  134521             : #if FILE_IO_EXTRA_CHECK
  134522           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpParallelMasterTaskloopSimdStatement ) ) <= globalIndex ) ;
  134523           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelMasterTaskloopSimdStatement + 1 ) ) );
  134524             : #endif
  134525           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpParallelMasterTaskloopSimdStatement )  
  134526           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpParallelMasterTaskloopSimdStatement );
  134527           0 :           unsigned long positionInPool = localIndex % SgOmpParallelMasterTaskloopSimdStatement::pool_size;
  134528           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelMasterTaskloopSimdStatement::pool_size;
  134529             : 
  134530             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  134531             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  134532             : 
  134533           0 :           returnPointer = &( ( (SgOmpParallelMasterTaskloopSimdStatement*)(SgOmpParallelMasterTaskloopSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  134534             : 
  134535           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  134536             :         }
  134537           0 :      return returnPointer ;
  134538             :    }
  134539             : 
  134540             : //############################################################################
  134541             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  134542             :   for the AST with the index astIndex
  134543             : */
  134544           0 : SgOmpParallelMasterTaskloopSimdStatement * SgOmpParallelMasterTaskloopSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  134545           0 :      SgOmpParallelMasterTaskloopSimdStatement* returnPointer = NULL;
  134546           0 :      if ( globalIndex != 0 )
  134547             :         {
  134548             : 
  134549             : #if FILE_IO_EXTRA_CHECK
  134550           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpParallelMasterTaskloopSimdStatement ) ) <= globalIndex ) ;
  134551           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelMasterTaskloopSimdStatement + 1 ) ) );
  134552             : #endif
  134553           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpParallelMasterTaskloopSimdStatement )
  134554           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpParallelMasterTaskloopSimdStatement );
  134555           0 :           unsigned long positionInPool = localIndex % SgOmpParallelMasterTaskloopSimdStatement::pool_size ;
  134556           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpParallelMasterTaskloopSimdStatement::pool_size ;
  134557             : 
  134558             : #if FILE_IO_EXTRA_CHECK
  134559             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  134560             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  134561             : #endif
  134562             : 
  134563           0 :           returnPointer = &( ( (SgOmpParallelMasterTaskloopSimdStatement*)(SgOmpParallelMasterTaskloopSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  134564             : 
  134565             : #if FILE_IO_EXTRA_CHECK
  134566           0 :           assert ( returnPointer != NULL ) ;
  134567             : #endif
  134568             :         }
  134569           0 :      return returnPointer ;
  134570             :    }
  134571             : 
  134572             : //############################################################################
  134573             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  134574             :  * pool size! We set for every valid object in the memory pool the freepointer
  134575             :  * to the global index and increase the global index afterwards. For all the 
  134576             :  * invalid objects (means address ranges within the memory pool that were not
  134577             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  134578             :  * distinguish valid from invalid objects! 
  134579             :  */
  134580             : unsigned long
  134581           5 : SgOmpParallelMasterTaskloopSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  134582             :    {
  134583           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  134584           5 :      SgOmpParallelMasterTaskloopSimdStatement* pointer = NULL;
  134585           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  134586           5 :      std::vector < unsigned char* > :: const_iterator block;
  134587           5 :      for ( block = SgOmpParallelMasterTaskloopSimdStatement::pools.begin(); block != SgOmpParallelMasterTaskloopSimdStatement::pools.end() ; ++block )
  134588             :         {
  134589           0 :           pointer = (SgOmpParallelMasterTaskloopSimdStatement*)(*block);
  134590           0 :           for (unsigned i = 0; i < SgOmpParallelMasterTaskloopSimdStatement::pool_size; ++i )
  134591             :              {
  134592             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  134593             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  134594             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  134595             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  134596             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  134597             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  134598             :             // properly; so this will have to be checked next.
  134599             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  134600             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  134601           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  134602             :                   {
  134603           0 :                     pointer[i].set_freepointer((SgOmpParallelMasterTaskloopSimdStatement*)(globalIndex));
  134604           0 :                     globalIndex++;
  134605             :                   }
  134606             :                else
  134607             :                   {
  134608           0 :                     pointer[i].set_freepointer(NULL);
  134609             :                   }
  134610             :               }
  134611             :         }
  134612           5 :      return globalIndex;
  134613             :    }
  134614             : 
  134615             : //############################################################################
  134616             : // JH (01/14/2006)
  134617             : void
  134618           5 : SgOmpParallelMasterTaskloopSimdStatement::resetValidFreepointers( )
  134619             :    {
  134620           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  134621           5 :      SgOmpParallelMasterTaskloopSimdStatement* pointer = NULL;
  134622           5 :      std::vector < unsigned char* > :: const_iterator block;
  134623           5 :      SgOmpParallelMasterTaskloopSimdStatement* pointerOfLinkedList = NULL;
  134624           5 :      for ( block = SgOmpParallelMasterTaskloopSimdStatement::pools.begin(); block != SgOmpParallelMasterTaskloopSimdStatement::pools.end() ; ++block )
  134625             :         {
  134626           0 :           pointer = (SgOmpParallelMasterTaskloopSimdStatement*)(*block);
  134627           0 :           for (unsigned i = 0; i < SgOmpParallelMasterTaskloopSimdStatement::pool_size; ++i )
  134628             :              {
  134629             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  134630             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  134631             :             // memory blocks!.
  134632           0 :                if ( pointer[i].get_freepointer() != NULL )
  134633             :                   {
  134634           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  134635             :                   }
  134636             :                else
  134637             :                   {
  134638           0 :                     if ( pointerOfLinkedList == NULL )
  134639             :                        {
  134640           0 :                          SgOmpParallelMasterTaskloopSimdStatement::next_node = &(pointer[i]);
  134641             :                        }
  134642             :                     else
  134643             :                        {
  134644             :                       // printf ("In SgOmpParallelMasterTaskloopSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  134645           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  134646             :                        }
  134647             :                     pointerOfLinkedList = &(pointer[i]);
  134648             :                   }
  134649             :               }
  134650             :         }
  134651             : 
  134652           5 :      if ( pointerOfLinkedList != NULL )
  134653             :         {
  134654             :        // printf ("In SgOmpParallelMasterTaskloopSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  134655           0 :           pointerOfLinkedList->set_freepointer(NULL);
  134656             :        // DQ (6/6/2010): Temporary debugging...
  134657             :        //   ROSE_ASSERT(false);
  134658             :         }
  134659             : 
  134660           5 :      return ;
  134661             :    }
  134662             : 
  134663             : //############################################################################
  134664             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  134665             :  * within the memory pool and resets the freepointers, in order to achieve a 
  134666             :  * linked list, that has no jumps and starts at the beginning! This function 
  134667             :  * does not extend the memory pool, since we do not delete any memory blocks,
  134668             :  * but delete the valid objects.  
  134669             :  */
  134670             : void
  134671           0 : SgOmpParallelMasterTaskloopSimdStatement::clearMemoryPool( )
  134672             :    {
  134673             :   // printf ("Inside of SgOmpParallelMasterTaskloopSimdStatement::clearMemoryPool() \n");
  134674             : 
  134675           0 :      SgOmpParallelMasterTaskloopSimdStatement* pointer = NULL, *tempPointer = NULL;
  134676           0 :      std::vector < unsigned char* > :: const_iterator block;
  134677           0 :      if ( SgOmpParallelMasterTaskloopSimdStatement::pools.empty() == false )
  134678             :         {
  134679           0 :           block = SgOmpParallelMasterTaskloopSimdStatement::pools.begin() ;
  134680           0 :           SgOmpParallelMasterTaskloopSimdStatement::next_node = (SgOmpParallelMasterTaskloopSimdStatement*) (*block);
  134681             : 
  134682           0 :           while ( block != SgOmpParallelMasterTaskloopSimdStatement::pools.end() )
  134683             :              {
  134684           0 :                pointer = (SgOmpParallelMasterTaskloopSimdStatement*) (*block);
  134685           0 :                if ( tempPointer != NULL )
  134686             :                   {
  134687           0 :                     tempPointer->set_freepointer(pointer);
  134688             :                   }
  134689           0 :                for (unsigned i = 0; i < SgOmpParallelMasterTaskloopSimdStatement::pool_size - 1; ++i)
  134690             :                   {
  134691           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  134692             :                   }
  134693           0 :                 pointer[SgOmpParallelMasterTaskloopSimdStatement::pool_size-1].set_freepointer(NULL);
  134694           0 :                 tempPointer = &(pointer[SgOmpParallelMasterTaskloopSimdStatement::pool_size-1]);
  134695           0 :                 ++block;
  134696             :              }
  134697             :         }
  134698           0 :    }
  134699             : 
  134700           5 : void SgOmpParallelMasterTaskloopSimdStatement::deleteMemoryPool() {
  134701           5 :   for (auto p: SgOmpParallelMasterTaskloopSimdStatement::pools) {
  134702           0 :     ROSE_FREE(p);
  134703             :   }
  134704           5 :   SgOmpParallelMasterTaskloopSimdStatement::next_node = nullptr;
  134705           5 :   SgOmpParallelMasterTaskloopSimdStatement::pools.clear();
  134706           5 : }
  134707             : 
  134708             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  134709             : //                 reading multiple binary files to for a single AST.
  134710             : /////////// new version ////////////////////////////////
  134711             : //############################################################################
  134712             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  134713             : void
  134714           2 : SgOmpParallelMasterTaskloopSimdStatement::extendMemoryPoolForFileIO( )
  134715             :   {
  134716           2 :     size_t blockIndex = SgOmpParallelMasterTaskloopSimdStatement::pools.size();
  134717           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterTaskloopSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterTaskloopSimdStatement);
  134718             : 
  134719           2 :     while ( (blockIndex * SgOmpParallelMasterTaskloopSimdStatement::pool_size) < newPoolSize)
  134720             :       {
  134721             : #if ROSE_ALLOC_TRACE
  134722             :         if (blockIndex > 0) {
  134723             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterTaskloopSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterTaskloopSimdStatement) = %" PRIuPTR " SgOmpParallelMasterTaskloopSimdStatement::pool_size = %d \n",
  134724             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpParallelMasterTaskloopSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpParallelMasterTaskloopSimdStatement),SgOmpParallelMasterTaskloopSimdStatement::pool_size);
  134725             :         }
  134726             : #endif
  134727             : 
  134728           0 :         SgOmpParallelMasterTaskloopSimdStatement * pointer = (SgOmpParallelMasterTaskloopSimdStatement*) ROSE_MALLOC ( SgOmpParallelMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopSimdStatement) );
  134729           0 :         assert( pointer != NULL );
  134730             : #if ROSE_ALLOC_MEMSET == 1
  134731             :         memset(pointer, 0x00, SgOmpParallelMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopSimdStatement));
  134732             : #elif ROSE_ALLOC_MEMSET == 2
  134733             :         memset(pointer, 0xCC, SgOmpParallelMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopSimdStatement));
  134734             : #endif
  134735           0 :         SgOmpParallelMasterTaskloopSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  134736           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpParallelMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopSimdStatement), V_SgOmpParallelMasterTaskloopSimdStatement ) );
  134737             : 
  134738           0 :         if ( SgOmpParallelMasterTaskloopSimdStatement::next_node != NULL ) {
  134739           0 :           if ( blockIndex > 0 ) {
  134740           0 :             SgOmpParallelMasterTaskloopSimdStatement * blkptr = (SgOmpParallelMasterTaskloopSimdStatement*)(SgOmpParallelMasterTaskloopSimdStatement::pools[blockIndex-1]);
  134741           0 :             blkptr[ SgOmpParallelMasterTaskloopSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  134742             :           }
  134743             :         } else {
  134744           0 :           SgOmpParallelMasterTaskloopSimdStatement::next_node = pointer;
  134745             :         }
  134746             : 
  134747           0 :         for (unsigned i = 0; i < SgOmpParallelMasterTaskloopSimdStatement::pool_size-1; ++i)
  134748             :            {
  134749           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  134750             :            }
  134751           0 :         pointer[ SgOmpParallelMasterTaskloopSimdStatement::pool_size -1 ].set_freepointer(NULL);
  134752             : 
  134753           0 :         blockIndex++;
  134754             :       }
  134755           2 :   }
  134756             : 
  134757             : //############################################################################
  134758             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  134759             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  134760             :  * not compressed. However, that stuff is not yet implemented! 
  134761             :  */
  134762             : unsigned long
  134763           0 : SgOmpParallelMasterTaskloopSimdStatement::getNumberOfLastValidPointer()
  134764             :    {
  134765           0 :       SgOmpParallelMasterTaskloopSimdStatement* testPointer = (SgOmpParallelMasterTaskloopSimdStatement*)(SgOmpParallelMasterTaskloopSimdStatement::pools.back());
  134766           0 :       unsigned long localIndex = SgOmpParallelMasterTaskloopSimdStatement::pool_size - 1;
  134767           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  134768             :          {
  134769           0 :            localIndex--;
  134770             :          }
  134771           0 :       return (localIndex + SgOmpParallelMasterTaskloopSimdStatement::pool_size * (SgOmpParallelMasterTaskloopSimdStatement::pools.size()-1));
  134772             :    }
  134773             : 
  134774             : //############################################################################
  134775             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  134776             :  * memory pool and initializes the data member in class SgOmpParallelMasterTaskloopSimdStatementStroageClass
  134777             :  * from its counterpart of SgOmpParallelMasterTaskloopSimdStatement. The return value is just for checking, 
  134778             :  * that the whole StorageClassArray is initialized!
  134779             :  */
  134780             : unsigned long
  134781           0 : SgOmpParallelMasterTaskloopSimdStatement::initializeStorageClassArray( SgOmpParallelMasterTaskloopSimdStatementStorageClass *storageArray )
  134782             :    {
  134783           0 :      unsigned long storageCounter = 0;
  134784           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpParallelMasterTaskloopSimdStatement::pools.begin();
  134785           0 :      SgOmpParallelMasterTaskloopSimdStatement* pointer = NULL;
  134786           0 :      while ( block != SgOmpParallelMasterTaskloopSimdStatement::pools.end() ) {
  134787           0 :           pointer = (SgOmpParallelMasterTaskloopSimdStatement*) (*block);
  134788           0 :           for ( unsigned i = 0; i < SgOmpParallelMasterTaskloopSimdStatement::pool_size; ++i ) {
  134789           0 :                if ( pointer->get_freepointer() != NULL ) {
  134790           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  134791           0 :                  storageArray++;
  134792           0 :                  storageCounter++;
  134793             :                }
  134794           0 :                pointer++;
  134795             :              }
  134796           0 :            block++;
  134797             :         }
  134798           0 :      return storageCounter;
  134799             :    }
  134800             : 
  134801             : /* #line 134802 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  134802             : 
  134803             : 
  134804             : 
  134805             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  134806             : 
  134807             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  134808             : 
  134809             : //############################################################################
  134810             : /* JH (02/02/2006) Constructor of the IR node SgOmpTeamsDistributeStatement that takes its 
  134811             :  * corresponding StorageClass as parameter
  134812             :  */
  134813           0 : SgOmpTeamsDistributeStatement :: SgOmpTeamsDistributeStatement ( const SgOmpTeamsDistributeStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  134814             :    {
  134815             : 
  134816             : 
  134817             : /* #line 134818 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  134818             : 
  134819           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  134820             : 
  134821             : 
  134822             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  134823             : 
  134824             : 
  134825           0 :    }
  134826             : 
  134827             : //############################################################################
  134828             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  134829             :  * within the working AST. 
  134830             :  */
  134831           0 : SgOmpTeamsDistributeStatement * SgOmpTeamsDistributeStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  134832           0 :      SgOmpTeamsDistributeStatement* returnPointer = NULL;
  134833           0 :      if ( globalIndex != 0 )
  134834             :         {
  134835             : 
  134836             : #if FILE_IO_EXTRA_CHECK
  134837           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTeamsDistributeStatement ) ) <= globalIndex ) ;
  134838           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsDistributeStatement + 1 ) ) );
  134839             : #endif
  134840           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsDistributeStatement )  
  134841           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTeamsDistributeStatement );
  134842           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsDistributeStatement::pool_size;
  134843           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsDistributeStatement::pool_size;
  134844             : 
  134845             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  134846             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  134847             : 
  134848           0 :           returnPointer = &( ( (SgOmpTeamsDistributeStatement*)(SgOmpTeamsDistributeStatement::pools[memoryBlock]) ) [positionInPool]) ;
  134849             : 
  134850           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  134851             :         }
  134852           0 :      return returnPointer ;
  134853             :    }
  134854             : 
  134855             : //############################################################################
  134856             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  134857             :   for the AST with the index astIndex
  134858             : */
  134859           0 : SgOmpTeamsDistributeStatement * SgOmpTeamsDistributeStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  134860           0 :      SgOmpTeamsDistributeStatement* returnPointer = NULL;
  134861           0 :      if ( globalIndex != 0 )
  134862             :         {
  134863             : 
  134864             : #if FILE_IO_EXTRA_CHECK
  134865           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTeamsDistributeStatement ) ) <= globalIndex ) ;
  134866           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsDistributeStatement + 1 ) ) );
  134867             : #endif
  134868           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsDistributeStatement )
  134869           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTeamsDistributeStatement );
  134870           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsDistributeStatement::pool_size ;
  134871           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsDistributeStatement::pool_size ;
  134872             : 
  134873             : #if FILE_IO_EXTRA_CHECK
  134874             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  134875             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  134876             : #endif
  134877             : 
  134878           0 :           returnPointer = &( ( (SgOmpTeamsDistributeStatement*)(SgOmpTeamsDistributeStatement::pools[memoryBlock]) ) [positionInPool]) ;
  134879             : 
  134880             : #if FILE_IO_EXTRA_CHECK
  134881           0 :           assert ( returnPointer != NULL ) ;
  134882             : #endif
  134883             :         }
  134884           0 :      return returnPointer ;
  134885             :    }
  134886             : 
  134887             : //############################################################################
  134888             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  134889             :  * pool size! We set for every valid object in the memory pool the freepointer
  134890             :  * to the global index and increase the global index afterwards. For all the 
  134891             :  * invalid objects (means address ranges within the memory pool that were not
  134892             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  134893             :  * distinguish valid from invalid objects! 
  134894             :  */
  134895             : unsigned long
  134896           5 : SgOmpTeamsDistributeStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  134897             :    {
  134898           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  134899           5 :      SgOmpTeamsDistributeStatement* pointer = NULL;
  134900           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  134901           5 :      std::vector < unsigned char* > :: const_iterator block;
  134902           5 :      for ( block = SgOmpTeamsDistributeStatement::pools.begin(); block != SgOmpTeamsDistributeStatement::pools.end() ; ++block )
  134903             :         {
  134904           0 :           pointer = (SgOmpTeamsDistributeStatement*)(*block);
  134905           0 :           for (unsigned i = 0; i < SgOmpTeamsDistributeStatement::pool_size; ++i )
  134906             :              {
  134907             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  134908             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  134909             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  134910             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  134911             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  134912             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  134913             :             // properly; so this will have to be checked next.
  134914             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  134915             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  134916           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  134917             :                   {
  134918           0 :                     pointer[i].set_freepointer((SgOmpTeamsDistributeStatement*)(globalIndex));
  134919           0 :                     globalIndex++;
  134920             :                   }
  134921             :                else
  134922             :                   {
  134923           0 :                     pointer[i].set_freepointer(NULL);
  134924             :                   }
  134925             :               }
  134926             :         }
  134927           5 :      return globalIndex;
  134928             :    }
  134929             : 
  134930             : //############################################################################
  134931             : // JH (01/14/2006)
  134932             : void
  134933           5 : SgOmpTeamsDistributeStatement::resetValidFreepointers( )
  134934             :    {
  134935           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  134936           5 :      SgOmpTeamsDistributeStatement* pointer = NULL;
  134937           5 :      std::vector < unsigned char* > :: const_iterator block;
  134938           5 :      SgOmpTeamsDistributeStatement* pointerOfLinkedList = NULL;
  134939           5 :      for ( block = SgOmpTeamsDistributeStatement::pools.begin(); block != SgOmpTeamsDistributeStatement::pools.end() ; ++block )
  134940             :         {
  134941           0 :           pointer = (SgOmpTeamsDistributeStatement*)(*block);
  134942           0 :           for (unsigned i = 0; i < SgOmpTeamsDistributeStatement::pool_size; ++i )
  134943             :              {
  134944             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  134945             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  134946             :             // memory blocks!.
  134947           0 :                if ( pointer[i].get_freepointer() != NULL )
  134948             :                   {
  134949           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  134950             :                   }
  134951             :                else
  134952             :                   {
  134953           0 :                     if ( pointerOfLinkedList == NULL )
  134954             :                        {
  134955           0 :                          SgOmpTeamsDistributeStatement::next_node = &(pointer[i]);
  134956             :                        }
  134957             :                     else
  134958             :                        {
  134959             :                       // printf ("In SgOmpTeamsDistributeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  134960           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  134961             :                        }
  134962             :                     pointerOfLinkedList = &(pointer[i]);
  134963             :                   }
  134964             :               }
  134965             :         }
  134966             : 
  134967           5 :      if ( pointerOfLinkedList != NULL )
  134968             :         {
  134969             :        // printf ("In SgOmpTeamsDistributeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  134970           0 :           pointerOfLinkedList->set_freepointer(NULL);
  134971             :        // DQ (6/6/2010): Temporary debugging...
  134972             :        //   ROSE_ASSERT(false);
  134973             :         }
  134974             : 
  134975           5 :      return ;
  134976             :    }
  134977             : 
  134978             : //############################################################################
  134979             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  134980             :  * within the memory pool and resets the freepointers, in order to achieve a 
  134981             :  * linked list, that has no jumps and starts at the beginning! This function 
  134982             :  * does not extend the memory pool, since we do not delete any memory blocks,
  134983             :  * but delete the valid objects.  
  134984             :  */
  134985             : void
  134986           0 : SgOmpTeamsDistributeStatement::clearMemoryPool( )
  134987             :    {
  134988             :   // printf ("Inside of SgOmpTeamsDistributeStatement::clearMemoryPool() \n");
  134989             : 
  134990           0 :      SgOmpTeamsDistributeStatement* pointer = NULL, *tempPointer = NULL;
  134991           0 :      std::vector < unsigned char* > :: const_iterator block;
  134992           0 :      if ( SgOmpTeamsDistributeStatement::pools.empty() == false )
  134993             :         {
  134994           0 :           block = SgOmpTeamsDistributeStatement::pools.begin() ;
  134995           0 :           SgOmpTeamsDistributeStatement::next_node = (SgOmpTeamsDistributeStatement*) (*block);
  134996             : 
  134997           0 :           while ( block != SgOmpTeamsDistributeStatement::pools.end() )
  134998             :              {
  134999           0 :                pointer = (SgOmpTeamsDistributeStatement*) (*block);
  135000           0 :                if ( tempPointer != NULL )
  135001             :                   {
  135002           0 :                     tempPointer->set_freepointer(pointer);
  135003             :                   }
  135004           0 :                for (unsigned i = 0; i < SgOmpTeamsDistributeStatement::pool_size - 1; ++i)
  135005             :                   {
  135006           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  135007             :                   }
  135008           0 :                 pointer[SgOmpTeamsDistributeStatement::pool_size-1].set_freepointer(NULL);
  135009           0 :                 tempPointer = &(pointer[SgOmpTeamsDistributeStatement::pool_size-1]);
  135010           0 :                 ++block;
  135011             :              }
  135012             :         }
  135013           0 :    }
  135014             : 
  135015           5 : void SgOmpTeamsDistributeStatement::deleteMemoryPool() {
  135016           5 :   for (auto p: SgOmpTeamsDistributeStatement::pools) {
  135017           0 :     ROSE_FREE(p);
  135018             :   }
  135019           5 :   SgOmpTeamsDistributeStatement::next_node = nullptr;
  135020           5 :   SgOmpTeamsDistributeStatement::pools.clear();
  135021           5 : }
  135022             : 
  135023             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  135024             : //                 reading multiple binary files to for a single AST.
  135025             : /////////// new version ////////////////////////////////
  135026             : //############################################################################
  135027             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  135028             : void
  135029           2 : SgOmpTeamsDistributeStatement::extendMemoryPoolForFileIO( )
  135030             :   {
  135031           2 :     size_t blockIndex = SgOmpTeamsDistributeStatement::pools.size();
  135032           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeStatement);
  135033             : 
  135034           2 :     while ( (blockIndex * SgOmpTeamsDistributeStatement::pool_size) < newPoolSize)
  135035             :       {
  135036             : #if ROSE_ALLOC_TRACE
  135037             :         if (blockIndex > 0) {
  135038             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeStatement) = %" PRIuPTR " SgOmpTeamsDistributeStatement::pool_size = %d \n",
  135039             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeStatement),SgOmpTeamsDistributeStatement::pool_size);
  135040             :         }
  135041             : #endif
  135042             : 
  135043           0 :         SgOmpTeamsDistributeStatement * pointer = (SgOmpTeamsDistributeStatement*) ROSE_MALLOC ( SgOmpTeamsDistributeStatement::pool_size * sizeof(SgOmpTeamsDistributeStatement) );
  135044           0 :         assert( pointer != NULL );
  135045             : #if ROSE_ALLOC_MEMSET == 1
  135046             :         memset(pointer, 0x00, SgOmpTeamsDistributeStatement::pool_size * sizeof(SgOmpTeamsDistributeStatement));
  135047             : #elif ROSE_ALLOC_MEMSET == 2
  135048             :         memset(pointer, 0xCC, SgOmpTeamsDistributeStatement::pool_size * sizeof(SgOmpTeamsDistributeStatement));
  135049             : #endif
  135050           0 :         SgOmpTeamsDistributeStatement::pools.push_back( (unsigned char*)(pointer) );
  135051           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTeamsDistributeStatement::pool_size * sizeof(SgOmpTeamsDistributeStatement), V_SgOmpTeamsDistributeStatement ) );
  135052             : 
  135053           0 :         if ( SgOmpTeamsDistributeStatement::next_node != NULL ) {
  135054           0 :           if ( blockIndex > 0 ) {
  135055           0 :             SgOmpTeamsDistributeStatement * blkptr = (SgOmpTeamsDistributeStatement*)(SgOmpTeamsDistributeStatement::pools[blockIndex-1]);
  135056           0 :             blkptr[ SgOmpTeamsDistributeStatement::pool_size - 1 ].set_freepointer(pointer);
  135057             :           }
  135058             :         } else {
  135059           0 :           SgOmpTeamsDistributeStatement::next_node = pointer;
  135060             :         }
  135061             : 
  135062           0 :         for (unsigned i = 0; i < SgOmpTeamsDistributeStatement::pool_size-1; ++i)
  135063             :            {
  135064           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  135065             :            }
  135066           0 :         pointer[ SgOmpTeamsDistributeStatement::pool_size -1 ].set_freepointer(NULL);
  135067             : 
  135068           0 :         blockIndex++;
  135069             :       }
  135070           2 :   }
  135071             : 
  135072             : //############################################################################
  135073             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  135074             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  135075             :  * not compressed. However, that stuff is not yet implemented! 
  135076             :  */
  135077             : unsigned long
  135078           0 : SgOmpTeamsDistributeStatement::getNumberOfLastValidPointer()
  135079             :    {
  135080           0 :       SgOmpTeamsDistributeStatement* testPointer = (SgOmpTeamsDistributeStatement*)(SgOmpTeamsDistributeStatement::pools.back());
  135081           0 :       unsigned long localIndex = SgOmpTeamsDistributeStatement::pool_size - 1;
  135082           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  135083             :          {
  135084           0 :            localIndex--;
  135085             :          }
  135086           0 :       return (localIndex + SgOmpTeamsDistributeStatement::pool_size * (SgOmpTeamsDistributeStatement::pools.size()-1));
  135087             :    }
  135088             : 
  135089             : //############################################################################
  135090             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  135091             :  * memory pool and initializes the data member in class SgOmpTeamsDistributeStatementStroageClass
  135092             :  * from its counterpart of SgOmpTeamsDistributeStatement. The return value is just for checking, 
  135093             :  * that the whole StorageClassArray is initialized!
  135094             :  */
  135095             : unsigned long
  135096           0 : SgOmpTeamsDistributeStatement::initializeStorageClassArray( SgOmpTeamsDistributeStatementStorageClass *storageArray )
  135097             :    {
  135098           0 :      unsigned long storageCounter = 0;
  135099           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTeamsDistributeStatement::pools.begin();
  135100           0 :      SgOmpTeamsDistributeStatement* pointer = NULL;
  135101           0 :      while ( block != SgOmpTeamsDistributeStatement::pools.end() ) {
  135102           0 :           pointer = (SgOmpTeamsDistributeStatement*) (*block);
  135103           0 :           for ( unsigned i = 0; i < SgOmpTeamsDistributeStatement::pool_size; ++i ) {
  135104           0 :                if ( pointer->get_freepointer() != NULL ) {
  135105           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  135106           0 :                  storageArray++;
  135107           0 :                  storageCounter++;
  135108             :                }
  135109           0 :                pointer++;
  135110             :              }
  135111           0 :            block++;
  135112             :         }
  135113           0 :      return storageCounter;
  135114             :    }
  135115             : 
  135116             : /* #line 135117 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  135117             : 
  135118             : 
  135119             : 
  135120             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  135121             : 
  135122             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  135123             : 
  135124             : //############################################################################
  135125             : /* JH (02/02/2006) Constructor of the IR node SgOmpTeamsDistributeSimdStatement that takes its 
  135126             :  * corresponding StorageClass as parameter
  135127             :  */
  135128           0 : SgOmpTeamsDistributeSimdStatement :: SgOmpTeamsDistributeSimdStatement ( const SgOmpTeamsDistributeSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  135129             :    {
  135130             : 
  135131             : 
  135132             : /* #line 135133 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  135133             : 
  135134           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  135135             : 
  135136             : 
  135137             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  135138             : 
  135139             : 
  135140           0 :    }
  135141             : 
  135142             : //############################################################################
  135143             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  135144             :  * within the working AST. 
  135145             :  */
  135146           0 : SgOmpTeamsDistributeSimdStatement * SgOmpTeamsDistributeSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  135147           0 :      SgOmpTeamsDistributeSimdStatement* returnPointer = NULL;
  135148           0 :      if ( globalIndex != 0 )
  135149             :         {
  135150             : 
  135151             : #if FILE_IO_EXTRA_CHECK
  135152           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTeamsDistributeSimdStatement ) ) <= globalIndex ) ;
  135153           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsDistributeSimdStatement + 1 ) ) );
  135154             : #endif
  135155           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsDistributeSimdStatement )  
  135156           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTeamsDistributeSimdStatement );
  135157           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsDistributeSimdStatement::pool_size;
  135158           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsDistributeSimdStatement::pool_size;
  135159             : 
  135160             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  135161             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  135162             : 
  135163           0 :           returnPointer = &( ( (SgOmpTeamsDistributeSimdStatement*)(SgOmpTeamsDistributeSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  135164             : 
  135165           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  135166             :         }
  135167           0 :      return returnPointer ;
  135168             :    }
  135169             : 
  135170             : //############################################################################
  135171             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  135172             :   for the AST with the index astIndex
  135173             : */
  135174           0 : SgOmpTeamsDistributeSimdStatement * SgOmpTeamsDistributeSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  135175           0 :      SgOmpTeamsDistributeSimdStatement* returnPointer = NULL;
  135176           0 :      if ( globalIndex != 0 )
  135177             :         {
  135178             : 
  135179             : #if FILE_IO_EXTRA_CHECK
  135180           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTeamsDistributeSimdStatement ) ) <= globalIndex ) ;
  135181           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsDistributeSimdStatement + 1 ) ) );
  135182             : #endif
  135183           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsDistributeSimdStatement )
  135184           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTeamsDistributeSimdStatement );
  135185           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsDistributeSimdStatement::pool_size ;
  135186           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsDistributeSimdStatement::pool_size ;
  135187             : 
  135188             : #if FILE_IO_EXTRA_CHECK
  135189             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  135190             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  135191             : #endif
  135192             : 
  135193           0 :           returnPointer = &( ( (SgOmpTeamsDistributeSimdStatement*)(SgOmpTeamsDistributeSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  135194             : 
  135195             : #if FILE_IO_EXTRA_CHECK
  135196           0 :           assert ( returnPointer != NULL ) ;
  135197             : #endif
  135198             :         }
  135199           0 :      return returnPointer ;
  135200             :    }
  135201             : 
  135202             : //############################################################################
  135203             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  135204             :  * pool size! We set for every valid object in the memory pool the freepointer
  135205             :  * to the global index and increase the global index afterwards. For all the 
  135206             :  * invalid objects (means address ranges within the memory pool that were not
  135207             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  135208             :  * distinguish valid from invalid objects! 
  135209             :  */
  135210             : unsigned long
  135211           5 : SgOmpTeamsDistributeSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  135212             :    {
  135213           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  135214           5 :      SgOmpTeamsDistributeSimdStatement* pointer = NULL;
  135215           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  135216           5 :      std::vector < unsigned char* > :: const_iterator block;
  135217           5 :      for ( block = SgOmpTeamsDistributeSimdStatement::pools.begin(); block != SgOmpTeamsDistributeSimdStatement::pools.end() ; ++block )
  135218             :         {
  135219           0 :           pointer = (SgOmpTeamsDistributeSimdStatement*)(*block);
  135220           0 :           for (unsigned i = 0; i < SgOmpTeamsDistributeSimdStatement::pool_size; ++i )
  135221             :              {
  135222             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  135223             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  135224             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  135225             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  135226             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  135227             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  135228             :             // properly; so this will have to be checked next.
  135229             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  135230             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  135231           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  135232             :                   {
  135233           0 :                     pointer[i].set_freepointer((SgOmpTeamsDistributeSimdStatement*)(globalIndex));
  135234           0 :                     globalIndex++;
  135235             :                   }
  135236             :                else
  135237             :                   {
  135238           0 :                     pointer[i].set_freepointer(NULL);
  135239             :                   }
  135240             :               }
  135241             :         }
  135242           5 :      return globalIndex;
  135243             :    }
  135244             : 
  135245             : //############################################################################
  135246             : // JH (01/14/2006)
  135247             : void
  135248           5 : SgOmpTeamsDistributeSimdStatement::resetValidFreepointers( )
  135249             :    {
  135250           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  135251           5 :      SgOmpTeamsDistributeSimdStatement* pointer = NULL;
  135252           5 :      std::vector < unsigned char* > :: const_iterator block;
  135253           5 :      SgOmpTeamsDistributeSimdStatement* pointerOfLinkedList = NULL;
  135254           5 :      for ( block = SgOmpTeamsDistributeSimdStatement::pools.begin(); block != SgOmpTeamsDistributeSimdStatement::pools.end() ; ++block )
  135255             :         {
  135256           0 :           pointer = (SgOmpTeamsDistributeSimdStatement*)(*block);
  135257           0 :           for (unsigned i = 0; i < SgOmpTeamsDistributeSimdStatement::pool_size; ++i )
  135258             :              {
  135259             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  135260             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  135261             :             // memory blocks!.
  135262           0 :                if ( pointer[i].get_freepointer() != NULL )
  135263             :                   {
  135264           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  135265             :                   }
  135266             :                else
  135267             :                   {
  135268           0 :                     if ( pointerOfLinkedList == NULL )
  135269             :                        {
  135270           0 :                          SgOmpTeamsDistributeSimdStatement::next_node = &(pointer[i]);
  135271             :                        }
  135272             :                     else
  135273             :                        {
  135274             :                       // printf ("In SgOmpTeamsDistributeSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  135275           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  135276             :                        }
  135277             :                     pointerOfLinkedList = &(pointer[i]);
  135278             :                   }
  135279             :               }
  135280             :         }
  135281             : 
  135282           5 :      if ( pointerOfLinkedList != NULL )
  135283             :         {
  135284             :        // printf ("In SgOmpTeamsDistributeSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  135285           0 :           pointerOfLinkedList->set_freepointer(NULL);
  135286             :        // DQ (6/6/2010): Temporary debugging...
  135287             :        //   ROSE_ASSERT(false);
  135288             :         }
  135289             : 
  135290           5 :      return ;
  135291             :    }
  135292             : 
  135293             : //############################################################################
  135294             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  135295             :  * within the memory pool and resets the freepointers, in order to achieve a 
  135296             :  * linked list, that has no jumps and starts at the beginning! This function 
  135297             :  * does not extend the memory pool, since we do not delete any memory blocks,
  135298             :  * but delete the valid objects.  
  135299             :  */
  135300             : void
  135301           0 : SgOmpTeamsDistributeSimdStatement::clearMemoryPool( )
  135302             :    {
  135303             :   // printf ("Inside of SgOmpTeamsDistributeSimdStatement::clearMemoryPool() \n");
  135304             : 
  135305           0 :      SgOmpTeamsDistributeSimdStatement* pointer = NULL, *tempPointer = NULL;
  135306           0 :      std::vector < unsigned char* > :: const_iterator block;
  135307           0 :      if ( SgOmpTeamsDistributeSimdStatement::pools.empty() == false )
  135308             :         {
  135309           0 :           block = SgOmpTeamsDistributeSimdStatement::pools.begin() ;
  135310           0 :           SgOmpTeamsDistributeSimdStatement::next_node = (SgOmpTeamsDistributeSimdStatement*) (*block);
  135311             : 
  135312           0 :           while ( block != SgOmpTeamsDistributeSimdStatement::pools.end() )
  135313             :              {
  135314           0 :                pointer = (SgOmpTeamsDistributeSimdStatement*) (*block);
  135315           0 :                if ( tempPointer != NULL )
  135316             :                   {
  135317           0 :                     tempPointer->set_freepointer(pointer);
  135318             :                   }
  135319           0 :                for (unsigned i = 0; i < SgOmpTeamsDistributeSimdStatement::pool_size - 1; ++i)
  135320             :                   {
  135321           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  135322             :                   }
  135323           0 :                 pointer[SgOmpTeamsDistributeSimdStatement::pool_size-1].set_freepointer(NULL);
  135324           0 :                 tempPointer = &(pointer[SgOmpTeamsDistributeSimdStatement::pool_size-1]);
  135325           0 :                 ++block;
  135326             :              }
  135327             :         }
  135328           0 :    }
  135329             : 
  135330           5 : void SgOmpTeamsDistributeSimdStatement::deleteMemoryPool() {
  135331           5 :   for (auto p: SgOmpTeamsDistributeSimdStatement::pools) {
  135332           0 :     ROSE_FREE(p);
  135333             :   }
  135334           5 :   SgOmpTeamsDistributeSimdStatement::next_node = nullptr;
  135335           5 :   SgOmpTeamsDistributeSimdStatement::pools.clear();
  135336           5 : }
  135337             : 
  135338             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  135339             : //                 reading multiple binary files to for a single AST.
  135340             : /////////// new version ////////////////////////////////
  135341             : //############################################################################
  135342             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  135343             : void
  135344           2 : SgOmpTeamsDistributeSimdStatement::extendMemoryPoolForFileIO( )
  135345             :   {
  135346           2 :     size_t blockIndex = SgOmpTeamsDistributeSimdStatement::pools.size();
  135347           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeSimdStatement);
  135348             : 
  135349           2 :     while ( (blockIndex * SgOmpTeamsDistributeSimdStatement::pool_size) < newPoolSize)
  135350             :       {
  135351             : #if ROSE_ALLOC_TRACE
  135352             :         if (blockIndex > 0) {
  135353             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeSimdStatement) = %" PRIuPTR " SgOmpTeamsDistributeSimdStatement::pool_size = %d \n",
  135354             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeSimdStatement),SgOmpTeamsDistributeSimdStatement::pool_size);
  135355             :         }
  135356             : #endif
  135357             : 
  135358           0 :         SgOmpTeamsDistributeSimdStatement * pointer = (SgOmpTeamsDistributeSimdStatement*) ROSE_MALLOC ( SgOmpTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeSimdStatement) );
  135359           0 :         assert( pointer != NULL );
  135360             : #if ROSE_ALLOC_MEMSET == 1
  135361             :         memset(pointer, 0x00, SgOmpTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeSimdStatement));
  135362             : #elif ROSE_ALLOC_MEMSET == 2
  135363             :         memset(pointer, 0xCC, SgOmpTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeSimdStatement));
  135364             : #endif
  135365           0 :         SgOmpTeamsDistributeSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  135366           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeSimdStatement), V_SgOmpTeamsDistributeSimdStatement ) );
  135367             : 
  135368           0 :         if ( SgOmpTeamsDistributeSimdStatement::next_node != NULL ) {
  135369           0 :           if ( blockIndex > 0 ) {
  135370           0 :             SgOmpTeamsDistributeSimdStatement * blkptr = (SgOmpTeamsDistributeSimdStatement*)(SgOmpTeamsDistributeSimdStatement::pools[blockIndex-1]);
  135371           0 :             blkptr[ SgOmpTeamsDistributeSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  135372             :           }
  135373             :         } else {
  135374           0 :           SgOmpTeamsDistributeSimdStatement::next_node = pointer;
  135375             :         }
  135376             : 
  135377           0 :         for (unsigned i = 0; i < SgOmpTeamsDistributeSimdStatement::pool_size-1; ++i)
  135378             :            {
  135379           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  135380             :            }
  135381           0 :         pointer[ SgOmpTeamsDistributeSimdStatement::pool_size -1 ].set_freepointer(NULL);
  135382             : 
  135383           0 :         blockIndex++;
  135384             :       }
  135385           2 :   }
  135386             : 
  135387             : //############################################################################
  135388             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  135389             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  135390             :  * not compressed. However, that stuff is not yet implemented! 
  135391             :  */
  135392             : unsigned long
  135393           0 : SgOmpTeamsDistributeSimdStatement::getNumberOfLastValidPointer()
  135394             :    {
  135395           0 :       SgOmpTeamsDistributeSimdStatement* testPointer = (SgOmpTeamsDistributeSimdStatement*)(SgOmpTeamsDistributeSimdStatement::pools.back());
  135396           0 :       unsigned long localIndex = SgOmpTeamsDistributeSimdStatement::pool_size - 1;
  135397           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  135398             :          {
  135399           0 :            localIndex--;
  135400             :          }
  135401           0 :       return (localIndex + SgOmpTeamsDistributeSimdStatement::pool_size * (SgOmpTeamsDistributeSimdStatement::pools.size()-1));
  135402             :    }
  135403             : 
  135404             : //############################################################################
  135405             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  135406             :  * memory pool and initializes the data member in class SgOmpTeamsDistributeSimdStatementStroageClass
  135407             :  * from its counterpart of SgOmpTeamsDistributeSimdStatement. The return value is just for checking, 
  135408             :  * that the whole StorageClassArray is initialized!
  135409             :  */
  135410             : unsigned long
  135411           0 : SgOmpTeamsDistributeSimdStatement::initializeStorageClassArray( SgOmpTeamsDistributeSimdStatementStorageClass *storageArray )
  135412             :    {
  135413           0 :      unsigned long storageCounter = 0;
  135414           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTeamsDistributeSimdStatement::pools.begin();
  135415           0 :      SgOmpTeamsDistributeSimdStatement* pointer = NULL;
  135416           0 :      while ( block != SgOmpTeamsDistributeSimdStatement::pools.end() ) {
  135417           0 :           pointer = (SgOmpTeamsDistributeSimdStatement*) (*block);
  135418           0 :           for ( unsigned i = 0; i < SgOmpTeamsDistributeSimdStatement::pool_size; ++i ) {
  135419           0 :                if ( pointer->get_freepointer() != NULL ) {
  135420           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  135421           0 :                  storageArray++;
  135422           0 :                  storageCounter++;
  135423             :                }
  135424           0 :                pointer++;
  135425             :              }
  135426           0 :            block++;
  135427             :         }
  135428           0 :      return storageCounter;
  135429             :    }
  135430             : 
  135431             : /* #line 135432 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  135432             : 
  135433             : 
  135434             : 
  135435             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  135436             : 
  135437             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  135438             : 
  135439             : //############################################################################
  135440             : /* JH (02/02/2006) Constructor of the IR node SgOmpTeamsDistributeParallelForStatement that takes its 
  135441             :  * corresponding StorageClass as parameter
  135442             :  */
  135443           0 : SgOmpTeamsDistributeParallelForStatement :: SgOmpTeamsDistributeParallelForStatement ( const SgOmpTeamsDistributeParallelForStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  135444             :    {
  135445             : 
  135446             : 
  135447             : /* #line 135448 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  135448             : 
  135449           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  135450             : 
  135451             : 
  135452             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  135453             : 
  135454             : 
  135455           0 :    }
  135456             : 
  135457             : //############################################################################
  135458             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  135459             :  * within the working AST. 
  135460             :  */
  135461           0 : SgOmpTeamsDistributeParallelForStatement * SgOmpTeamsDistributeParallelForStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  135462           0 :      SgOmpTeamsDistributeParallelForStatement* returnPointer = NULL;
  135463           0 :      if ( globalIndex != 0 )
  135464             :         {
  135465             : 
  135466             : #if FILE_IO_EXTRA_CHECK
  135467           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTeamsDistributeParallelForStatement ) ) <= globalIndex ) ;
  135468           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsDistributeParallelForStatement + 1 ) ) );
  135469             : #endif
  135470           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsDistributeParallelForStatement )  
  135471           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTeamsDistributeParallelForStatement );
  135472           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsDistributeParallelForStatement::pool_size;
  135473           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsDistributeParallelForStatement::pool_size;
  135474             : 
  135475             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  135476             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  135477             : 
  135478           0 :           returnPointer = &( ( (SgOmpTeamsDistributeParallelForStatement*)(SgOmpTeamsDistributeParallelForStatement::pools[memoryBlock]) ) [positionInPool]) ;
  135479             : 
  135480           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  135481             :         }
  135482           0 :      return returnPointer ;
  135483             :    }
  135484             : 
  135485             : //############################################################################
  135486             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  135487             :   for the AST with the index astIndex
  135488             : */
  135489           0 : SgOmpTeamsDistributeParallelForStatement * SgOmpTeamsDistributeParallelForStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  135490           0 :      SgOmpTeamsDistributeParallelForStatement* returnPointer = NULL;
  135491           0 :      if ( globalIndex != 0 )
  135492             :         {
  135493             : 
  135494             : #if FILE_IO_EXTRA_CHECK
  135495           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTeamsDistributeParallelForStatement ) ) <= globalIndex ) ;
  135496           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsDistributeParallelForStatement + 1 ) ) );
  135497             : #endif
  135498           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsDistributeParallelForStatement )
  135499           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTeamsDistributeParallelForStatement );
  135500           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsDistributeParallelForStatement::pool_size ;
  135501           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsDistributeParallelForStatement::pool_size ;
  135502             : 
  135503             : #if FILE_IO_EXTRA_CHECK
  135504             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  135505             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  135506             : #endif
  135507             : 
  135508           0 :           returnPointer = &( ( (SgOmpTeamsDistributeParallelForStatement*)(SgOmpTeamsDistributeParallelForStatement::pools[memoryBlock]) ) [positionInPool]) ;
  135509             : 
  135510             : #if FILE_IO_EXTRA_CHECK
  135511           0 :           assert ( returnPointer != NULL ) ;
  135512             : #endif
  135513             :         }
  135514           0 :      return returnPointer ;
  135515             :    }
  135516             : 
  135517             : //############################################################################
  135518             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  135519             :  * pool size! We set for every valid object in the memory pool the freepointer
  135520             :  * to the global index and increase the global index afterwards. For all the 
  135521             :  * invalid objects (means address ranges within the memory pool that were not
  135522             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  135523             :  * distinguish valid from invalid objects! 
  135524             :  */
  135525             : unsigned long
  135526           5 : SgOmpTeamsDistributeParallelForStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  135527             :    {
  135528           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  135529           5 :      SgOmpTeamsDistributeParallelForStatement* pointer = NULL;
  135530           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  135531           5 :      std::vector < unsigned char* > :: const_iterator block;
  135532           5 :      for ( block = SgOmpTeamsDistributeParallelForStatement::pools.begin(); block != SgOmpTeamsDistributeParallelForStatement::pools.end() ; ++block )
  135533             :         {
  135534           0 :           pointer = (SgOmpTeamsDistributeParallelForStatement*)(*block);
  135535           0 :           for (unsigned i = 0; i < SgOmpTeamsDistributeParallelForStatement::pool_size; ++i )
  135536             :              {
  135537             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  135538             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  135539             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  135540             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  135541             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  135542             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  135543             :             // properly; so this will have to be checked next.
  135544             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  135545             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  135546           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  135547             :                   {
  135548           0 :                     pointer[i].set_freepointer((SgOmpTeamsDistributeParallelForStatement*)(globalIndex));
  135549           0 :                     globalIndex++;
  135550             :                   }
  135551             :                else
  135552             :                   {
  135553           0 :                     pointer[i].set_freepointer(NULL);
  135554             :                   }
  135555             :               }
  135556             :         }
  135557           5 :      return globalIndex;
  135558             :    }
  135559             : 
  135560             : //############################################################################
  135561             : // JH (01/14/2006)
  135562             : void
  135563           5 : SgOmpTeamsDistributeParallelForStatement::resetValidFreepointers( )
  135564             :    {
  135565           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  135566           5 :      SgOmpTeamsDistributeParallelForStatement* pointer = NULL;
  135567           5 :      std::vector < unsigned char* > :: const_iterator block;
  135568           5 :      SgOmpTeamsDistributeParallelForStatement* pointerOfLinkedList = NULL;
  135569           5 :      for ( block = SgOmpTeamsDistributeParallelForStatement::pools.begin(); block != SgOmpTeamsDistributeParallelForStatement::pools.end() ; ++block )
  135570             :         {
  135571           0 :           pointer = (SgOmpTeamsDistributeParallelForStatement*)(*block);
  135572           0 :           for (unsigned i = 0; i < SgOmpTeamsDistributeParallelForStatement::pool_size; ++i )
  135573             :              {
  135574             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  135575             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  135576             :             // memory blocks!.
  135577           0 :                if ( pointer[i].get_freepointer() != NULL )
  135578             :                   {
  135579           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  135580             :                   }
  135581             :                else
  135582             :                   {
  135583           0 :                     if ( pointerOfLinkedList == NULL )
  135584             :                        {
  135585           0 :                          SgOmpTeamsDistributeParallelForStatement::next_node = &(pointer[i]);
  135586             :                        }
  135587             :                     else
  135588             :                        {
  135589             :                       // printf ("In SgOmpTeamsDistributeParallelForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  135590           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  135591             :                        }
  135592             :                     pointerOfLinkedList = &(pointer[i]);
  135593             :                   }
  135594             :               }
  135595             :         }
  135596             : 
  135597           5 :      if ( pointerOfLinkedList != NULL )
  135598             :         {
  135599             :        // printf ("In SgOmpTeamsDistributeParallelForStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  135600           0 :           pointerOfLinkedList->set_freepointer(NULL);
  135601             :        // DQ (6/6/2010): Temporary debugging...
  135602             :        //   ROSE_ASSERT(false);
  135603             :         }
  135604             : 
  135605           5 :      return ;
  135606             :    }
  135607             : 
  135608             : //############################################################################
  135609             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  135610             :  * within the memory pool and resets the freepointers, in order to achieve a 
  135611             :  * linked list, that has no jumps and starts at the beginning! This function 
  135612             :  * does not extend the memory pool, since we do not delete any memory blocks,
  135613             :  * but delete the valid objects.  
  135614             :  */
  135615             : void
  135616           0 : SgOmpTeamsDistributeParallelForStatement::clearMemoryPool( )
  135617             :    {
  135618             :   // printf ("Inside of SgOmpTeamsDistributeParallelForStatement::clearMemoryPool() \n");
  135619             : 
  135620           0 :      SgOmpTeamsDistributeParallelForStatement* pointer = NULL, *tempPointer = NULL;
  135621           0 :      std::vector < unsigned char* > :: const_iterator block;
  135622           0 :      if ( SgOmpTeamsDistributeParallelForStatement::pools.empty() == false )
  135623             :         {
  135624           0 :           block = SgOmpTeamsDistributeParallelForStatement::pools.begin() ;
  135625           0 :           SgOmpTeamsDistributeParallelForStatement::next_node = (SgOmpTeamsDistributeParallelForStatement*) (*block);
  135626             : 
  135627           0 :           while ( block != SgOmpTeamsDistributeParallelForStatement::pools.end() )
  135628             :              {
  135629           0 :                pointer = (SgOmpTeamsDistributeParallelForStatement*) (*block);
  135630           0 :                if ( tempPointer != NULL )
  135631             :                   {
  135632           0 :                     tempPointer->set_freepointer(pointer);
  135633             :                   }
  135634           0 :                for (unsigned i = 0; i < SgOmpTeamsDistributeParallelForStatement::pool_size - 1; ++i)
  135635             :                   {
  135636           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  135637             :                   }
  135638           0 :                 pointer[SgOmpTeamsDistributeParallelForStatement::pool_size-1].set_freepointer(NULL);
  135639           0 :                 tempPointer = &(pointer[SgOmpTeamsDistributeParallelForStatement::pool_size-1]);
  135640           0 :                 ++block;
  135641             :              }
  135642             :         }
  135643           0 :    }
  135644             : 
  135645           5 : void SgOmpTeamsDistributeParallelForStatement::deleteMemoryPool() {
  135646           5 :   for (auto p: SgOmpTeamsDistributeParallelForStatement::pools) {
  135647           0 :     ROSE_FREE(p);
  135648             :   }
  135649           5 :   SgOmpTeamsDistributeParallelForStatement::next_node = nullptr;
  135650           5 :   SgOmpTeamsDistributeParallelForStatement::pools.clear();
  135651           5 : }
  135652             : 
  135653             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  135654             : //                 reading multiple binary files to for a single AST.
  135655             : /////////// new version ////////////////////////////////
  135656             : //############################################################################
  135657             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  135658             : void
  135659           2 : SgOmpTeamsDistributeParallelForStatement::extendMemoryPoolForFileIO( )
  135660             :   {
  135661           2 :     size_t blockIndex = SgOmpTeamsDistributeParallelForStatement::pools.size();
  135662           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeParallelForStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeParallelForStatement);
  135663             : 
  135664           2 :     while ( (blockIndex * SgOmpTeamsDistributeParallelForStatement::pool_size) < newPoolSize)
  135665             :       {
  135666             : #if ROSE_ALLOC_TRACE
  135667             :         if (blockIndex > 0) {
  135668             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeParallelForStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeParallelForStatement) = %" PRIuPTR " SgOmpTeamsDistributeParallelForStatement::pool_size = %d \n",
  135669             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeParallelForStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeParallelForStatement),SgOmpTeamsDistributeParallelForStatement::pool_size);
  135670             :         }
  135671             : #endif
  135672             : 
  135673           0 :         SgOmpTeamsDistributeParallelForStatement * pointer = (SgOmpTeamsDistributeParallelForStatement*) ROSE_MALLOC ( SgOmpTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForStatement) );
  135674           0 :         assert( pointer != NULL );
  135675             : #if ROSE_ALLOC_MEMSET == 1
  135676             :         memset(pointer, 0x00, SgOmpTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForStatement));
  135677             : #elif ROSE_ALLOC_MEMSET == 2
  135678             :         memset(pointer, 0xCC, SgOmpTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForStatement));
  135679             : #endif
  135680           0 :         SgOmpTeamsDistributeParallelForStatement::pools.push_back( (unsigned char*)(pointer) );
  135681           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForStatement), V_SgOmpTeamsDistributeParallelForStatement ) );
  135682             : 
  135683           0 :         if ( SgOmpTeamsDistributeParallelForStatement::next_node != NULL ) {
  135684           0 :           if ( blockIndex > 0 ) {
  135685           0 :             SgOmpTeamsDistributeParallelForStatement * blkptr = (SgOmpTeamsDistributeParallelForStatement*)(SgOmpTeamsDistributeParallelForStatement::pools[blockIndex-1]);
  135686           0 :             blkptr[ SgOmpTeamsDistributeParallelForStatement::pool_size - 1 ].set_freepointer(pointer);
  135687             :           }
  135688             :         } else {
  135689           0 :           SgOmpTeamsDistributeParallelForStatement::next_node = pointer;
  135690             :         }
  135691             : 
  135692           0 :         for (unsigned i = 0; i < SgOmpTeamsDistributeParallelForStatement::pool_size-1; ++i)
  135693             :            {
  135694           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  135695             :            }
  135696           0 :         pointer[ SgOmpTeamsDistributeParallelForStatement::pool_size -1 ].set_freepointer(NULL);
  135697             : 
  135698           0 :         blockIndex++;
  135699             :       }
  135700           2 :   }
  135701             : 
  135702             : //############################################################################
  135703             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  135704             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  135705             :  * not compressed. However, that stuff is not yet implemented! 
  135706             :  */
  135707             : unsigned long
  135708           0 : SgOmpTeamsDistributeParallelForStatement::getNumberOfLastValidPointer()
  135709             :    {
  135710           0 :       SgOmpTeamsDistributeParallelForStatement* testPointer = (SgOmpTeamsDistributeParallelForStatement*)(SgOmpTeamsDistributeParallelForStatement::pools.back());
  135711           0 :       unsigned long localIndex = SgOmpTeamsDistributeParallelForStatement::pool_size - 1;
  135712           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  135713             :          {
  135714           0 :            localIndex--;
  135715             :          }
  135716           0 :       return (localIndex + SgOmpTeamsDistributeParallelForStatement::pool_size * (SgOmpTeamsDistributeParallelForStatement::pools.size()-1));
  135717             :    }
  135718             : 
  135719             : //############################################################################
  135720             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  135721             :  * memory pool and initializes the data member in class SgOmpTeamsDistributeParallelForStatementStroageClass
  135722             :  * from its counterpart of SgOmpTeamsDistributeParallelForStatement. The return value is just for checking, 
  135723             :  * that the whole StorageClassArray is initialized!
  135724             :  */
  135725             : unsigned long
  135726           0 : SgOmpTeamsDistributeParallelForStatement::initializeStorageClassArray( SgOmpTeamsDistributeParallelForStatementStorageClass *storageArray )
  135727             :    {
  135728           0 :      unsigned long storageCounter = 0;
  135729           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTeamsDistributeParallelForStatement::pools.begin();
  135730           0 :      SgOmpTeamsDistributeParallelForStatement* pointer = NULL;
  135731           0 :      while ( block != SgOmpTeamsDistributeParallelForStatement::pools.end() ) {
  135732           0 :           pointer = (SgOmpTeamsDistributeParallelForStatement*) (*block);
  135733           0 :           for ( unsigned i = 0; i < SgOmpTeamsDistributeParallelForStatement::pool_size; ++i ) {
  135734           0 :                if ( pointer->get_freepointer() != NULL ) {
  135735           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  135736           0 :                  storageArray++;
  135737           0 :                  storageCounter++;
  135738             :                }
  135739           0 :                pointer++;
  135740             :              }
  135741           0 :            block++;
  135742             :         }
  135743           0 :      return storageCounter;
  135744             :    }
  135745             : 
  135746             : /* #line 135747 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  135747             : 
  135748             : 
  135749             : 
  135750             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  135751             : 
  135752             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  135753             : 
  135754             : //############################################################################
  135755             : /* JH (02/02/2006) Constructor of the IR node SgOmpTeamsDistributeParallelForSimdStatement that takes its 
  135756             :  * corresponding StorageClass as parameter
  135757             :  */
  135758           0 : SgOmpTeamsDistributeParallelForSimdStatement :: SgOmpTeamsDistributeParallelForSimdStatement ( const SgOmpTeamsDistributeParallelForSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  135759             :    {
  135760             : 
  135761             : 
  135762             : /* #line 135763 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  135763             : 
  135764           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  135765             : 
  135766             : 
  135767             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  135768             : 
  135769             : 
  135770           0 :    }
  135771             : 
  135772             : //############################################################################
  135773             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  135774             :  * within the working AST. 
  135775             :  */
  135776           0 : SgOmpTeamsDistributeParallelForSimdStatement * SgOmpTeamsDistributeParallelForSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  135777           0 :      SgOmpTeamsDistributeParallelForSimdStatement* returnPointer = NULL;
  135778           0 :      if ( globalIndex != 0 )
  135779             :         {
  135780             : 
  135781             : #if FILE_IO_EXTRA_CHECK
  135782           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTeamsDistributeParallelForSimdStatement ) ) <= globalIndex ) ;
  135783           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsDistributeParallelForSimdStatement + 1 ) ) );
  135784             : #endif
  135785           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsDistributeParallelForSimdStatement )  
  135786           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTeamsDistributeParallelForSimdStatement );
  135787           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsDistributeParallelForSimdStatement::pool_size;
  135788           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsDistributeParallelForSimdStatement::pool_size;
  135789             : 
  135790             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  135791             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  135792             : 
  135793           0 :           returnPointer = &( ( (SgOmpTeamsDistributeParallelForSimdStatement*)(SgOmpTeamsDistributeParallelForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  135794             : 
  135795           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  135796             :         }
  135797           0 :      return returnPointer ;
  135798             :    }
  135799             : 
  135800             : //############################################################################
  135801             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  135802             :   for the AST with the index astIndex
  135803             : */
  135804           0 : SgOmpTeamsDistributeParallelForSimdStatement * SgOmpTeamsDistributeParallelForSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  135805           0 :      SgOmpTeamsDistributeParallelForSimdStatement* returnPointer = NULL;
  135806           0 :      if ( globalIndex != 0 )
  135807             :         {
  135808             : 
  135809             : #if FILE_IO_EXTRA_CHECK
  135810           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTeamsDistributeParallelForSimdStatement ) ) <= globalIndex ) ;
  135811           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsDistributeParallelForSimdStatement + 1 ) ) );
  135812             : #endif
  135813           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsDistributeParallelForSimdStatement )
  135814           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTeamsDistributeParallelForSimdStatement );
  135815           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsDistributeParallelForSimdStatement::pool_size ;
  135816           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsDistributeParallelForSimdStatement::pool_size ;
  135817             : 
  135818             : #if FILE_IO_EXTRA_CHECK
  135819             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  135820             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  135821             : #endif
  135822             : 
  135823           0 :           returnPointer = &( ( (SgOmpTeamsDistributeParallelForSimdStatement*)(SgOmpTeamsDistributeParallelForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  135824             : 
  135825             : #if FILE_IO_EXTRA_CHECK
  135826           0 :           assert ( returnPointer != NULL ) ;
  135827             : #endif
  135828             :         }
  135829           0 :      return returnPointer ;
  135830             :    }
  135831             : 
  135832             : //############################################################################
  135833             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  135834             :  * pool size! We set for every valid object in the memory pool the freepointer
  135835             :  * to the global index and increase the global index afterwards. For all the 
  135836             :  * invalid objects (means address ranges within the memory pool that were not
  135837             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  135838             :  * distinguish valid from invalid objects! 
  135839             :  */
  135840             : unsigned long
  135841           5 : SgOmpTeamsDistributeParallelForSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  135842             :    {
  135843           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  135844           5 :      SgOmpTeamsDistributeParallelForSimdStatement* pointer = NULL;
  135845           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  135846           5 :      std::vector < unsigned char* > :: const_iterator block;
  135847           5 :      for ( block = SgOmpTeamsDistributeParallelForSimdStatement::pools.begin(); block != SgOmpTeamsDistributeParallelForSimdStatement::pools.end() ; ++block )
  135848             :         {
  135849           0 :           pointer = (SgOmpTeamsDistributeParallelForSimdStatement*)(*block);
  135850           0 :           for (unsigned i = 0; i < SgOmpTeamsDistributeParallelForSimdStatement::pool_size; ++i )
  135851             :              {
  135852             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  135853             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  135854             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  135855             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  135856             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  135857             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  135858             :             // properly; so this will have to be checked next.
  135859             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  135860             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  135861           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  135862             :                   {
  135863           0 :                     pointer[i].set_freepointer((SgOmpTeamsDistributeParallelForSimdStatement*)(globalIndex));
  135864           0 :                     globalIndex++;
  135865             :                   }
  135866             :                else
  135867             :                   {
  135868           0 :                     pointer[i].set_freepointer(NULL);
  135869             :                   }
  135870             :               }
  135871             :         }
  135872           5 :      return globalIndex;
  135873             :    }
  135874             : 
  135875             : //############################################################################
  135876             : // JH (01/14/2006)
  135877             : void
  135878           5 : SgOmpTeamsDistributeParallelForSimdStatement::resetValidFreepointers( )
  135879             :    {
  135880           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  135881           5 :      SgOmpTeamsDistributeParallelForSimdStatement* pointer = NULL;
  135882           5 :      std::vector < unsigned char* > :: const_iterator block;
  135883           5 :      SgOmpTeamsDistributeParallelForSimdStatement* pointerOfLinkedList = NULL;
  135884           5 :      for ( block = SgOmpTeamsDistributeParallelForSimdStatement::pools.begin(); block != SgOmpTeamsDistributeParallelForSimdStatement::pools.end() ; ++block )
  135885             :         {
  135886           0 :           pointer = (SgOmpTeamsDistributeParallelForSimdStatement*)(*block);
  135887           0 :           for (unsigned i = 0; i < SgOmpTeamsDistributeParallelForSimdStatement::pool_size; ++i )
  135888             :              {
  135889             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  135890             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  135891             :             // memory blocks!.
  135892           0 :                if ( pointer[i].get_freepointer() != NULL )
  135893             :                   {
  135894           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  135895             :                   }
  135896             :                else
  135897             :                   {
  135898           0 :                     if ( pointerOfLinkedList == NULL )
  135899             :                        {
  135900           0 :                          SgOmpTeamsDistributeParallelForSimdStatement::next_node = &(pointer[i]);
  135901             :                        }
  135902             :                     else
  135903             :                        {
  135904             :                       // printf ("In SgOmpTeamsDistributeParallelForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  135905           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  135906             :                        }
  135907             :                     pointerOfLinkedList = &(pointer[i]);
  135908             :                   }
  135909             :               }
  135910             :         }
  135911             : 
  135912           5 :      if ( pointerOfLinkedList != NULL )
  135913             :         {
  135914             :        // printf ("In SgOmpTeamsDistributeParallelForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  135915           0 :           pointerOfLinkedList->set_freepointer(NULL);
  135916             :        // DQ (6/6/2010): Temporary debugging...
  135917             :        //   ROSE_ASSERT(false);
  135918             :         }
  135919             : 
  135920           5 :      return ;
  135921             :    }
  135922             : 
  135923             : //############################################################################
  135924             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  135925             :  * within the memory pool and resets the freepointers, in order to achieve a 
  135926             :  * linked list, that has no jumps and starts at the beginning! This function 
  135927             :  * does not extend the memory pool, since we do not delete any memory blocks,
  135928             :  * but delete the valid objects.  
  135929             :  */
  135930             : void
  135931           0 : SgOmpTeamsDistributeParallelForSimdStatement::clearMemoryPool( )
  135932             :    {
  135933             :   // printf ("Inside of SgOmpTeamsDistributeParallelForSimdStatement::clearMemoryPool() \n");
  135934             : 
  135935           0 :      SgOmpTeamsDistributeParallelForSimdStatement* pointer = NULL, *tempPointer = NULL;
  135936           0 :      std::vector < unsigned char* > :: const_iterator block;
  135937           0 :      if ( SgOmpTeamsDistributeParallelForSimdStatement::pools.empty() == false )
  135938             :         {
  135939           0 :           block = SgOmpTeamsDistributeParallelForSimdStatement::pools.begin() ;
  135940           0 :           SgOmpTeamsDistributeParallelForSimdStatement::next_node = (SgOmpTeamsDistributeParallelForSimdStatement*) (*block);
  135941             : 
  135942           0 :           while ( block != SgOmpTeamsDistributeParallelForSimdStatement::pools.end() )
  135943             :              {
  135944           0 :                pointer = (SgOmpTeamsDistributeParallelForSimdStatement*) (*block);
  135945           0 :                if ( tempPointer != NULL )
  135946             :                   {
  135947           0 :                     tempPointer->set_freepointer(pointer);
  135948             :                   }
  135949           0 :                for (unsigned i = 0; i < SgOmpTeamsDistributeParallelForSimdStatement::pool_size - 1; ++i)
  135950             :                   {
  135951           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  135952             :                   }
  135953           0 :                 pointer[SgOmpTeamsDistributeParallelForSimdStatement::pool_size-1].set_freepointer(NULL);
  135954           0 :                 tempPointer = &(pointer[SgOmpTeamsDistributeParallelForSimdStatement::pool_size-1]);
  135955           0 :                 ++block;
  135956             :              }
  135957             :         }
  135958           0 :    }
  135959             : 
  135960           5 : void SgOmpTeamsDistributeParallelForSimdStatement::deleteMemoryPool() {
  135961           5 :   for (auto p: SgOmpTeamsDistributeParallelForSimdStatement::pools) {
  135962           0 :     ROSE_FREE(p);
  135963             :   }
  135964           5 :   SgOmpTeamsDistributeParallelForSimdStatement::next_node = nullptr;
  135965           5 :   SgOmpTeamsDistributeParallelForSimdStatement::pools.clear();
  135966           5 : }
  135967             : 
  135968             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  135969             : //                 reading multiple binary files to for a single AST.
  135970             : /////////// new version ////////////////////////////////
  135971             : //############################################################################
  135972             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  135973             : void
  135974           2 : SgOmpTeamsDistributeParallelForSimdStatement::extendMemoryPoolForFileIO( )
  135975             :   {
  135976           2 :     size_t blockIndex = SgOmpTeamsDistributeParallelForSimdStatement::pools.size();
  135977           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeParallelForSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeParallelForSimdStatement);
  135978             : 
  135979           2 :     while ( (blockIndex * SgOmpTeamsDistributeParallelForSimdStatement::pool_size) < newPoolSize)
  135980             :       {
  135981             : #if ROSE_ALLOC_TRACE
  135982             :         if (blockIndex > 0) {
  135983             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeParallelForSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeParallelForSimdStatement) = %" PRIuPTR " SgOmpTeamsDistributeParallelForSimdStatement::pool_size = %d \n",
  135984             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsDistributeParallelForSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsDistributeParallelForSimdStatement),SgOmpTeamsDistributeParallelForSimdStatement::pool_size);
  135985             :         }
  135986             : #endif
  135987             : 
  135988           0 :         SgOmpTeamsDistributeParallelForSimdStatement * pointer = (SgOmpTeamsDistributeParallelForSimdStatement*) ROSE_MALLOC ( SgOmpTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForSimdStatement) );
  135989           0 :         assert( pointer != NULL );
  135990             : #if ROSE_ALLOC_MEMSET == 1
  135991             :         memset(pointer, 0x00, SgOmpTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForSimdStatement));
  135992             : #elif ROSE_ALLOC_MEMSET == 2
  135993             :         memset(pointer, 0xCC, SgOmpTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForSimdStatement));
  135994             : #endif
  135995           0 :         SgOmpTeamsDistributeParallelForSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  135996           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForSimdStatement), V_SgOmpTeamsDistributeParallelForSimdStatement ) );
  135997             : 
  135998           0 :         if ( SgOmpTeamsDistributeParallelForSimdStatement::next_node != NULL ) {
  135999           0 :           if ( blockIndex > 0 ) {
  136000           0 :             SgOmpTeamsDistributeParallelForSimdStatement * blkptr = (SgOmpTeamsDistributeParallelForSimdStatement*)(SgOmpTeamsDistributeParallelForSimdStatement::pools[blockIndex-1]);
  136001           0 :             blkptr[ SgOmpTeamsDistributeParallelForSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  136002             :           }
  136003             :         } else {
  136004           0 :           SgOmpTeamsDistributeParallelForSimdStatement::next_node = pointer;
  136005             :         }
  136006             : 
  136007           0 :         for (unsigned i = 0; i < SgOmpTeamsDistributeParallelForSimdStatement::pool_size-1; ++i)
  136008             :            {
  136009           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  136010             :            }
  136011           0 :         pointer[ SgOmpTeamsDistributeParallelForSimdStatement::pool_size -1 ].set_freepointer(NULL);
  136012             : 
  136013           0 :         blockIndex++;
  136014             :       }
  136015           2 :   }
  136016             : 
  136017             : //############################################################################
  136018             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  136019             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  136020             :  * not compressed. However, that stuff is not yet implemented! 
  136021             :  */
  136022             : unsigned long
  136023           0 : SgOmpTeamsDistributeParallelForSimdStatement::getNumberOfLastValidPointer()
  136024             :    {
  136025           0 :       SgOmpTeamsDistributeParallelForSimdStatement* testPointer = (SgOmpTeamsDistributeParallelForSimdStatement*)(SgOmpTeamsDistributeParallelForSimdStatement::pools.back());
  136026           0 :       unsigned long localIndex = SgOmpTeamsDistributeParallelForSimdStatement::pool_size - 1;
  136027           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  136028             :          {
  136029           0 :            localIndex--;
  136030             :          }
  136031           0 :       return (localIndex + SgOmpTeamsDistributeParallelForSimdStatement::pool_size * (SgOmpTeamsDistributeParallelForSimdStatement::pools.size()-1));
  136032             :    }
  136033             : 
  136034             : //############################################################################
  136035             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  136036             :  * memory pool and initializes the data member in class SgOmpTeamsDistributeParallelForSimdStatementStroageClass
  136037             :  * from its counterpart of SgOmpTeamsDistributeParallelForSimdStatement. The return value is just for checking, 
  136038             :  * that the whole StorageClassArray is initialized!
  136039             :  */
  136040             : unsigned long
  136041           0 : SgOmpTeamsDistributeParallelForSimdStatement::initializeStorageClassArray( SgOmpTeamsDistributeParallelForSimdStatementStorageClass *storageArray )
  136042             :    {
  136043           0 :      unsigned long storageCounter = 0;
  136044           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTeamsDistributeParallelForSimdStatement::pools.begin();
  136045           0 :      SgOmpTeamsDistributeParallelForSimdStatement* pointer = NULL;
  136046           0 :      while ( block != SgOmpTeamsDistributeParallelForSimdStatement::pools.end() ) {
  136047           0 :           pointer = (SgOmpTeamsDistributeParallelForSimdStatement*) (*block);
  136048           0 :           for ( unsigned i = 0; i < SgOmpTeamsDistributeParallelForSimdStatement::pool_size; ++i ) {
  136049           0 :                if ( pointer->get_freepointer() != NULL ) {
  136050           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  136051           0 :                  storageArray++;
  136052           0 :                  storageCounter++;
  136053             :                }
  136054           0 :                pointer++;
  136055             :              }
  136056           0 :            block++;
  136057             :         }
  136058           0 :      return storageCounter;
  136059             :    }
  136060             : 
  136061             : /* #line 136062 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  136062             : 
  136063             : 
  136064             : 
  136065             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  136066             : 
  136067             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  136068             : 
  136069             : //############################################################################
  136070             : /* JH (02/02/2006) Constructor of the IR node SgOmpTeamsLoopStatement that takes its 
  136071             :  * corresponding StorageClass as parameter
  136072             :  */
  136073           0 : SgOmpTeamsLoopStatement :: SgOmpTeamsLoopStatement ( const SgOmpTeamsLoopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  136074             :    {
  136075             : 
  136076             : 
  136077             : /* #line 136078 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  136078             : 
  136079           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  136080             : 
  136081             : 
  136082             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  136083             : 
  136084             : 
  136085           0 :    }
  136086             : 
  136087             : //############################################################################
  136088             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  136089             :  * within the working AST. 
  136090             :  */
  136091           0 : SgOmpTeamsLoopStatement * SgOmpTeamsLoopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  136092           0 :      SgOmpTeamsLoopStatement* returnPointer = NULL;
  136093           0 :      if ( globalIndex != 0 )
  136094             :         {
  136095             : 
  136096             : #if FILE_IO_EXTRA_CHECK
  136097           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTeamsLoopStatement ) ) <= globalIndex ) ;
  136098           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsLoopStatement + 1 ) ) );
  136099             : #endif
  136100           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTeamsLoopStatement )  
  136101           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTeamsLoopStatement );
  136102           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsLoopStatement::pool_size;
  136103           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsLoopStatement::pool_size;
  136104             : 
  136105             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  136106             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  136107             : 
  136108           0 :           returnPointer = &( ( (SgOmpTeamsLoopStatement*)(SgOmpTeamsLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  136109             : 
  136110           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  136111             :         }
  136112           0 :      return returnPointer ;
  136113             :    }
  136114             : 
  136115             : //############################################################################
  136116             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  136117             :   for the AST with the index astIndex
  136118             : */
  136119           0 : SgOmpTeamsLoopStatement * SgOmpTeamsLoopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  136120           0 :      SgOmpTeamsLoopStatement* returnPointer = NULL;
  136121           0 :      if ( globalIndex != 0 )
  136122             :         {
  136123             : 
  136124             : #if FILE_IO_EXTRA_CHECK
  136125           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTeamsLoopStatement ) ) <= globalIndex ) ;
  136126           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsLoopStatement + 1 ) ) );
  136127             : #endif
  136128           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTeamsLoopStatement )
  136129           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTeamsLoopStatement );
  136130           0 :           unsigned long positionInPool = localIndex % SgOmpTeamsLoopStatement::pool_size ;
  136131           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTeamsLoopStatement::pool_size ;
  136132             : 
  136133             : #if FILE_IO_EXTRA_CHECK
  136134             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  136135             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  136136             : #endif
  136137             : 
  136138           0 :           returnPointer = &( ( (SgOmpTeamsLoopStatement*)(SgOmpTeamsLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  136139             : 
  136140             : #if FILE_IO_EXTRA_CHECK
  136141           0 :           assert ( returnPointer != NULL ) ;
  136142             : #endif
  136143             :         }
  136144           0 :      return returnPointer ;
  136145             :    }
  136146             : 
  136147             : //############################################################################
  136148             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  136149             :  * pool size! We set for every valid object in the memory pool the freepointer
  136150             :  * to the global index and increase the global index afterwards. For all the 
  136151             :  * invalid objects (means address ranges within the memory pool that were not
  136152             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  136153             :  * distinguish valid from invalid objects! 
  136154             :  */
  136155             : unsigned long
  136156           5 : SgOmpTeamsLoopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  136157             :    {
  136158           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  136159           5 :      SgOmpTeamsLoopStatement* pointer = NULL;
  136160           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  136161           5 :      std::vector < unsigned char* > :: const_iterator block;
  136162           5 :      for ( block = SgOmpTeamsLoopStatement::pools.begin(); block != SgOmpTeamsLoopStatement::pools.end() ; ++block )
  136163             :         {
  136164           0 :           pointer = (SgOmpTeamsLoopStatement*)(*block);
  136165           0 :           for (unsigned i = 0; i < SgOmpTeamsLoopStatement::pool_size; ++i )
  136166             :              {
  136167             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  136168             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  136169             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  136170             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  136171             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  136172             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  136173             :             // properly; so this will have to be checked next.
  136174             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  136175             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  136176           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  136177             :                   {
  136178           0 :                     pointer[i].set_freepointer((SgOmpTeamsLoopStatement*)(globalIndex));
  136179           0 :                     globalIndex++;
  136180             :                   }
  136181             :                else
  136182             :                   {
  136183           0 :                     pointer[i].set_freepointer(NULL);
  136184             :                   }
  136185             :               }
  136186             :         }
  136187           5 :      return globalIndex;
  136188             :    }
  136189             : 
  136190             : //############################################################################
  136191             : // JH (01/14/2006)
  136192             : void
  136193           5 : SgOmpTeamsLoopStatement::resetValidFreepointers( )
  136194             :    {
  136195           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  136196           5 :      SgOmpTeamsLoopStatement* pointer = NULL;
  136197           5 :      std::vector < unsigned char* > :: const_iterator block;
  136198           5 :      SgOmpTeamsLoopStatement* pointerOfLinkedList = NULL;
  136199           5 :      for ( block = SgOmpTeamsLoopStatement::pools.begin(); block != SgOmpTeamsLoopStatement::pools.end() ; ++block )
  136200             :         {
  136201           0 :           pointer = (SgOmpTeamsLoopStatement*)(*block);
  136202           0 :           for (unsigned i = 0; i < SgOmpTeamsLoopStatement::pool_size; ++i )
  136203             :              {
  136204             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  136205             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  136206             :             // memory blocks!.
  136207           0 :                if ( pointer[i].get_freepointer() != NULL )
  136208             :                   {
  136209           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  136210             :                   }
  136211             :                else
  136212             :                   {
  136213           0 :                     if ( pointerOfLinkedList == NULL )
  136214             :                        {
  136215           0 :                          SgOmpTeamsLoopStatement::next_node = &(pointer[i]);
  136216             :                        }
  136217             :                     else
  136218             :                        {
  136219             :                       // printf ("In SgOmpTeamsLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  136220           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  136221             :                        }
  136222             :                     pointerOfLinkedList = &(pointer[i]);
  136223             :                   }
  136224             :               }
  136225             :         }
  136226             : 
  136227           5 :      if ( pointerOfLinkedList != NULL )
  136228             :         {
  136229             :        // printf ("In SgOmpTeamsLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  136230           0 :           pointerOfLinkedList->set_freepointer(NULL);
  136231             :        // DQ (6/6/2010): Temporary debugging...
  136232             :        //   ROSE_ASSERT(false);
  136233             :         }
  136234             : 
  136235           5 :      return ;
  136236             :    }
  136237             : 
  136238             : //############################################################################
  136239             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  136240             :  * within the memory pool and resets the freepointers, in order to achieve a 
  136241             :  * linked list, that has no jumps and starts at the beginning! This function 
  136242             :  * does not extend the memory pool, since we do not delete any memory blocks,
  136243             :  * but delete the valid objects.  
  136244             :  */
  136245             : void
  136246           0 : SgOmpTeamsLoopStatement::clearMemoryPool( )
  136247             :    {
  136248             :   // printf ("Inside of SgOmpTeamsLoopStatement::clearMemoryPool() \n");
  136249             : 
  136250           0 :      SgOmpTeamsLoopStatement* pointer = NULL, *tempPointer = NULL;
  136251           0 :      std::vector < unsigned char* > :: const_iterator block;
  136252           0 :      if ( SgOmpTeamsLoopStatement::pools.empty() == false )
  136253             :         {
  136254           0 :           block = SgOmpTeamsLoopStatement::pools.begin() ;
  136255           0 :           SgOmpTeamsLoopStatement::next_node = (SgOmpTeamsLoopStatement*) (*block);
  136256             : 
  136257           0 :           while ( block != SgOmpTeamsLoopStatement::pools.end() )
  136258             :              {
  136259           0 :                pointer = (SgOmpTeamsLoopStatement*) (*block);
  136260           0 :                if ( tempPointer != NULL )
  136261             :                   {
  136262           0 :                     tempPointer->set_freepointer(pointer);
  136263             :                   }
  136264           0 :                for (unsigned i = 0; i < SgOmpTeamsLoopStatement::pool_size - 1; ++i)
  136265             :                   {
  136266           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  136267             :                   }
  136268           0 :                 pointer[SgOmpTeamsLoopStatement::pool_size-1].set_freepointer(NULL);
  136269           0 :                 tempPointer = &(pointer[SgOmpTeamsLoopStatement::pool_size-1]);
  136270           0 :                 ++block;
  136271             :              }
  136272             :         }
  136273           0 :    }
  136274             : 
  136275           5 : void SgOmpTeamsLoopStatement::deleteMemoryPool() {
  136276           5 :   for (auto p: SgOmpTeamsLoopStatement::pools) {
  136277           0 :     ROSE_FREE(p);
  136278             :   }
  136279           5 :   SgOmpTeamsLoopStatement::next_node = nullptr;
  136280           5 :   SgOmpTeamsLoopStatement::pools.clear();
  136281           5 : }
  136282             : 
  136283             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  136284             : //                 reading multiple binary files to for a single AST.
  136285             : /////////// new version ////////////////////////////////
  136286             : //############################################################################
  136287             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  136288             : void
  136289           2 : SgOmpTeamsLoopStatement::extendMemoryPoolForFileIO( )
  136290             :   {
  136291           2 :     size_t blockIndex = SgOmpTeamsLoopStatement::pools.size();
  136292           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsLoopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsLoopStatement);
  136293             : 
  136294           2 :     while ( (blockIndex * SgOmpTeamsLoopStatement::pool_size) < newPoolSize)
  136295             :       {
  136296             : #if ROSE_ALLOC_TRACE
  136297             :         if (blockIndex > 0) {
  136298             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsLoopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsLoopStatement) = %" PRIuPTR " SgOmpTeamsLoopStatement::pool_size = %d \n",
  136299             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTeamsLoopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTeamsLoopStatement),SgOmpTeamsLoopStatement::pool_size);
  136300             :         }
  136301             : #endif
  136302             : 
  136303           0 :         SgOmpTeamsLoopStatement * pointer = (SgOmpTeamsLoopStatement*) ROSE_MALLOC ( SgOmpTeamsLoopStatement::pool_size * sizeof(SgOmpTeamsLoopStatement) );
  136304           0 :         assert( pointer != NULL );
  136305             : #if ROSE_ALLOC_MEMSET == 1
  136306             :         memset(pointer, 0x00, SgOmpTeamsLoopStatement::pool_size * sizeof(SgOmpTeamsLoopStatement));
  136307             : #elif ROSE_ALLOC_MEMSET == 2
  136308             :         memset(pointer, 0xCC, SgOmpTeamsLoopStatement::pool_size * sizeof(SgOmpTeamsLoopStatement));
  136309             : #endif
  136310           0 :         SgOmpTeamsLoopStatement::pools.push_back( (unsigned char*)(pointer) );
  136311           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTeamsLoopStatement::pool_size * sizeof(SgOmpTeamsLoopStatement), V_SgOmpTeamsLoopStatement ) );
  136312             : 
  136313           0 :         if ( SgOmpTeamsLoopStatement::next_node != NULL ) {
  136314           0 :           if ( blockIndex > 0 ) {
  136315           0 :             SgOmpTeamsLoopStatement * blkptr = (SgOmpTeamsLoopStatement*)(SgOmpTeamsLoopStatement::pools[blockIndex-1]);
  136316           0 :             blkptr[ SgOmpTeamsLoopStatement::pool_size - 1 ].set_freepointer(pointer);
  136317             :           }
  136318             :         } else {
  136319           0 :           SgOmpTeamsLoopStatement::next_node = pointer;
  136320             :         }
  136321             : 
  136322           0 :         for (unsigned i = 0; i < SgOmpTeamsLoopStatement::pool_size-1; ++i)
  136323             :            {
  136324           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  136325             :            }
  136326           0 :         pointer[ SgOmpTeamsLoopStatement::pool_size -1 ].set_freepointer(NULL);
  136327             : 
  136328           0 :         blockIndex++;
  136329             :       }
  136330           2 :   }
  136331             : 
  136332             : //############################################################################
  136333             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  136334             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  136335             :  * not compressed. However, that stuff is not yet implemented! 
  136336             :  */
  136337             : unsigned long
  136338           0 : SgOmpTeamsLoopStatement::getNumberOfLastValidPointer()
  136339             :    {
  136340           0 :       SgOmpTeamsLoopStatement* testPointer = (SgOmpTeamsLoopStatement*)(SgOmpTeamsLoopStatement::pools.back());
  136341           0 :       unsigned long localIndex = SgOmpTeamsLoopStatement::pool_size - 1;
  136342           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  136343             :          {
  136344           0 :            localIndex--;
  136345             :          }
  136346           0 :       return (localIndex + SgOmpTeamsLoopStatement::pool_size * (SgOmpTeamsLoopStatement::pools.size()-1));
  136347             :    }
  136348             : 
  136349             : //############################################################################
  136350             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  136351             :  * memory pool and initializes the data member in class SgOmpTeamsLoopStatementStroageClass
  136352             :  * from its counterpart of SgOmpTeamsLoopStatement. The return value is just for checking, 
  136353             :  * that the whole StorageClassArray is initialized!
  136354             :  */
  136355             : unsigned long
  136356           0 : SgOmpTeamsLoopStatement::initializeStorageClassArray( SgOmpTeamsLoopStatementStorageClass *storageArray )
  136357             :    {
  136358           0 :      unsigned long storageCounter = 0;
  136359           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTeamsLoopStatement::pools.begin();
  136360           0 :      SgOmpTeamsLoopStatement* pointer = NULL;
  136361           0 :      while ( block != SgOmpTeamsLoopStatement::pools.end() ) {
  136362           0 :           pointer = (SgOmpTeamsLoopStatement*) (*block);
  136363           0 :           for ( unsigned i = 0; i < SgOmpTeamsLoopStatement::pool_size; ++i ) {
  136364           0 :                if ( pointer->get_freepointer() != NULL ) {
  136365           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  136366           0 :                  storageArray++;
  136367           0 :                  storageCounter++;
  136368             :                }
  136369           0 :                pointer++;
  136370             :              }
  136371           0 :            block++;
  136372             :         }
  136373           0 :      return storageCounter;
  136374             :    }
  136375             : 
  136376             : /* #line 136377 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  136377             : 
  136378             : 
  136379             : 
  136380             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  136381             : 
  136382             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  136383             : 
  136384             : //############################################################################
  136385             : /* JH (02/02/2006) Constructor of the IR node SgOmpForSimdStatement that takes its 
  136386             :  * corresponding StorageClass as parameter
  136387             :  */
  136388           0 : SgOmpForSimdStatement :: SgOmpForSimdStatement ( const SgOmpForSimdStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  136389             :    {
  136390             : 
  136391             : 
  136392             : /* #line 136393 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  136393             : 
  136394           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  136395             : 
  136396             : 
  136397             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  136398             : 
  136399             : 
  136400           0 :    }
  136401             : 
  136402             : //############################################################################
  136403             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  136404             :  * within the working AST. 
  136405             :  */
  136406           0 : SgOmpForSimdStatement * SgOmpForSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  136407           0 :      SgOmpForSimdStatement* returnPointer = NULL;
  136408           0 :      if ( globalIndex != 0 )
  136409             :         {
  136410             : 
  136411             : #if FILE_IO_EXTRA_CHECK
  136412           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpForSimdStatement ) ) <= globalIndex ) ;
  136413           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpForSimdStatement + 1 ) ) );
  136414             : #endif
  136415           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpForSimdStatement )  
  136416           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpForSimdStatement );
  136417           0 :           unsigned long positionInPool = localIndex % SgOmpForSimdStatement::pool_size;
  136418           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpForSimdStatement::pool_size;
  136419             : 
  136420             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  136421             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  136422             : 
  136423           0 :           returnPointer = &( ( (SgOmpForSimdStatement*)(SgOmpForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  136424             : 
  136425           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  136426             :         }
  136427           0 :      return returnPointer ;
  136428             :    }
  136429             : 
  136430             : //############################################################################
  136431             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  136432             :   for the AST with the index astIndex
  136433             : */
  136434           0 : SgOmpForSimdStatement * SgOmpForSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  136435           0 :      SgOmpForSimdStatement* returnPointer = NULL;
  136436           0 :      if ( globalIndex != 0 )
  136437             :         {
  136438             : 
  136439             : #if FILE_IO_EXTRA_CHECK
  136440           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpForSimdStatement ) ) <= globalIndex ) ;
  136441           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpForSimdStatement + 1 ) ) );
  136442             : #endif
  136443           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpForSimdStatement )
  136444           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpForSimdStatement );
  136445           0 :           unsigned long positionInPool = localIndex % SgOmpForSimdStatement::pool_size ;
  136446           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpForSimdStatement::pool_size ;
  136447             : 
  136448             : #if FILE_IO_EXTRA_CHECK
  136449             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  136450             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  136451             : #endif
  136452             : 
  136453           0 :           returnPointer = &( ( (SgOmpForSimdStatement*)(SgOmpForSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  136454             : 
  136455             : #if FILE_IO_EXTRA_CHECK
  136456           0 :           assert ( returnPointer != NULL ) ;
  136457             : #endif
  136458             :         }
  136459           0 :      return returnPointer ;
  136460             :    }
  136461             : 
  136462             : //############################################################################
  136463             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  136464             :  * pool size! We set for every valid object in the memory pool the freepointer
  136465             :  * to the global index and increase the global index afterwards. For all the 
  136466             :  * invalid objects (means address ranges within the memory pool that were not
  136467             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  136468             :  * distinguish valid from invalid objects! 
  136469             :  */
  136470             : unsigned long
  136471           5 : SgOmpForSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  136472             :    {
  136473           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  136474           5 :      SgOmpForSimdStatement* pointer = NULL;
  136475           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  136476           5 :      std::vector < unsigned char* > :: const_iterator block;
  136477           5 :      for ( block = SgOmpForSimdStatement::pools.begin(); block != SgOmpForSimdStatement::pools.end() ; ++block )
  136478             :         {
  136479           0 :           pointer = (SgOmpForSimdStatement*)(*block);
  136480           0 :           for (unsigned i = 0; i < SgOmpForSimdStatement::pool_size; ++i )
  136481             :              {
  136482             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  136483             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  136484             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  136485             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  136486             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  136487             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  136488             :             // properly; so this will have to be checked next.
  136489             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  136490             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  136491           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  136492             :                   {
  136493           0 :                     pointer[i].set_freepointer((SgOmpForSimdStatement*)(globalIndex));
  136494           0 :                     globalIndex++;
  136495             :                   }
  136496             :                else
  136497             :                   {
  136498           0 :                     pointer[i].set_freepointer(NULL);
  136499             :                   }
  136500             :               }
  136501             :         }
  136502           5 :      return globalIndex;
  136503             :    }
  136504             : 
  136505             : //############################################################################
  136506             : // JH (01/14/2006)
  136507             : void
  136508           5 : SgOmpForSimdStatement::resetValidFreepointers( )
  136509             :    {
  136510           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  136511           5 :      SgOmpForSimdStatement* pointer = NULL;
  136512           5 :      std::vector < unsigned char* > :: const_iterator block;
  136513           5 :      SgOmpForSimdStatement* pointerOfLinkedList = NULL;
  136514           5 :      for ( block = SgOmpForSimdStatement::pools.begin(); block != SgOmpForSimdStatement::pools.end() ; ++block )
  136515             :         {
  136516           0 :           pointer = (SgOmpForSimdStatement*)(*block);
  136517           0 :           for (unsigned i = 0; i < SgOmpForSimdStatement::pool_size; ++i )
  136518             :              {
  136519             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  136520             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  136521             :             // memory blocks!.
  136522           0 :                if ( pointer[i].get_freepointer() != NULL )
  136523             :                   {
  136524           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  136525             :                   }
  136526             :                else
  136527             :                   {
  136528           0 :                     if ( pointerOfLinkedList == NULL )
  136529             :                        {
  136530           0 :                          SgOmpForSimdStatement::next_node = &(pointer[i]);
  136531             :                        }
  136532             :                     else
  136533             :                        {
  136534             :                       // printf ("In SgOmpForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  136535           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  136536             :                        }
  136537             :                     pointerOfLinkedList = &(pointer[i]);
  136538             :                   }
  136539             :               }
  136540             :         }
  136541             : 
  136542           5 :      if ( pointerOfLinkedList != NULL )
  136543             :         {
  136544             :        // printf ("In SgOmpForSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  136545           0 :           pointerOfLinkedList->set_freepointer(NULL);
  136546             :        // DQ (6/6/2010): Temporary debugging...
  136547             :        //   ROSE_ASSERT(false);
  136548             :         }
  136549             : 
  136550           5 :      return ;
  136551             :    }
  136552             : 
  136553             : //############################################################################
  136554             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  136555             :  * within the memory pool and resets the freepointers, in order to achieve a 
  136556             :  * linked list, that has no jumps and starts at the beginning! This function 
  136557             :  * does not extend the memory pool, since we do not delete any memory blocks,
  136558             :  * but delete the valid objects.  
  136559             :  */
  136560             : void
  136561           0 : SgOmpForSimdStatement::clearMemoryPool( )
  136562             :    {
  136563             :   // printf ("Inside of SgOmpForSimdStatement::clearMemoryPool() \n");
  136564             : 
  136565           0 :      SgOmpForSimdStatement* pointer = NULL, *tempPointer = NULL;
  136566           0 :      std::vector < unsigned char* > :: const_iterator block;
  136567           0 :      if ( SgOmpForSimdStatement::pools.empty() == false )
  136568             :         {
  136569           0 :           block = SgOmpForSimdStatement::pools.begin() ;
  136570           0 :           SgOmpForSimdStatement::next_node = (SgOmpForSimdStatement*) (*block);
  136571             : 
  136572           0 :           while ( block != SgOmpForSimdStatement::pools.end() )
  136573             :              {
  136574           0 :                pointer = (SgOmpForSimdStatement*) (*block);
  136575           0 :                if ( tempPointer != NULL )
  136576             :                   {
  136577           0 :                     tempPointer->set_freepointer(pointer);
  136578             :                   }
  136579           0 :                for (unsigned i = 0; i < SgOmpForSimdStatement::pool_size - 1; ++i)
  136580             :                   {
  136581           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  136582             :                   }
  136583           0 :                 pointer[SgOmpForSimdStatement::pool_size-1].set_freepointer(NULL);
  136584           0 :                 tempPointer = &(pointer[SgOmpForSimdStatement::pool_size-1]);
  136585           0 :                 ++block;
  136586             :              }
  136587             :         }
  136588           0 :    }
  136589             : 
  136590           5 : void SgOmpForSimdStatement::deleteMemoryPool() {
  136591           5 :   for (auto p: SgOmpForSimdStatement::pools) {
  136592           0 :     ROSE_FREE(p);
  136593             :   }
  136594           5 :   SgOmpForSimdStatement::next_node = nullptr;
  136595           5 :   SgOmpForSimdStatement::pools.clear();
  136596           5 : }
  136597             : 
  136598             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  136599             : //                 reading multiple binary files to for a single AST.
  136600             : /////////// new version ////////////////////////////////
  136601             : //############################################################################
  136602             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  136603             : void
  136604           2 : SgOmpForSimdStatement::extendMemoryPoolForFileIO( )
  136605             :   {
  136606           2 :     size_t blockIndex = SgOmpForSimdStatement::pools.size();
  136607           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpForSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpForSimdStatement);
  136608             : 
  136609           2 :     while ( (blockIndex * SgOmpForSimdStatement::pool_size) < newPoolSize)
  136610             :       {
  136611             : #if ROSE_ALLOC_TRACE
  136612             :         if (blockIndex > 0) {
  136613             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpForSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpForSimdStatement) = %" PRIuPTR " SgOmpForSimdStatement::pool_size = %d \n",
  136614             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpForSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpForSimdStatement),SgOmpForSimdStatement::pool_size);
  136615             :         }
  136616             : #endif
  136617             : 
  136618           0 :         SgOmpForSimdStatement * pointer = (SgOmpForSimdStatement*) ROSE_MALLOC ( SgOmpForSimdStatement::pool_size * sizeof(SgOmpForSimdStatement) );
  136619           0 :         assert( pointer != NULL );
  136620             : #if ROSE_ALLOC_MEMSET == 1
  136621             :         memset(pointer, 0x00, SgOmpForSimdStatement::pool_size * sizeof(SgOmpForSimdStatement));
  136622             : #elif ROSE_ALLOC_MEMSET == 2
  136623             :         memset(pointer, 0xCC, SgOmpForSimdStatement::pool_size * sizeof(SgOmpForSimdStatement));
  136624             : #endif
  136625           0 :         SgOmpForSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  136626           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpForSimdStatement::pool_size * sizeof(SgOmpForSimdStatement), V_SgOmpForSimdStatement ) );
  136627             : 
  136628           0 :         if ( SgOmpForSimdStatement::next_node != NULL ) {
  136629           0 :           if ( blockIndex > 0 ) {
  136630           0 :             SgOmpForSimdStatement * blkptr = (SgOmpForSimdStatement*)(SgOmpForSimdStatement::pools[blockIndex-1]);
  136631           0 :             blkptr[ SgOmpForSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  136632             :           }
  136633             :         } else {
  136634           0 :           SgOmpForSimdStatement::next_node = pointer;
  136635             :         }
  136636             : 
  136637           0 :         for (unsigned i = 0; i < SgOmpForSimdStatement::pool_size-1; ++i)
  136638             :            {
  136639           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  136640             :            }
  136641           0 :         pointer[ SgOmpForSimdStatement::pool_size -1 ].set_freepointer(NULL);
  136642             : 
  136643           0 :         blockIndex++;
  136644             :       }
  136645           2 :   }
  136646             : 
  136647             : //############################################################################
  136648             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  136649             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  136650             :  * not compressed. However, that stuff is not yet implemented! 
  136651             :  */
  136652             : unsigned long
  136653           0 : SgOmpForSimdStatement::getNumberOfLastValidPointer()
  136654             :    {
  136655           0 :       SgOmpForSimdStatement* testPointer = (SgOmpForSimdStatement*)(SgOmpForSimdStatement::pools.back());
  136656           0 :       unsigned long localIndex = SgOmpForSimdStatement::pool_size - 1;
  136657           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  136658             :          {
  136659           0 :            localIndex--;
  136660             :          }
  136661           0 :       return (localIndex + SgOmpForSimdStatement::pool_size * (SgOmpForSimdStatement::pools.size()-1));
  136662             :    }
  136663             : 
  136664             : //############################################################################
  136665             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  136666             :  * memory pool and initializes the data member in class SgOmpForSimdStatementStroageClass
  136667             :  * from its counterpart of SgOmpForSimdStatement. The return value is just for checking, 
  136668             :  * that the whole StorageClassArray is initialized!
  136669             :  */
  136670             : unsigned long
  136671           0 : SgOmpForSimdStatement::initializeStorageClassArray( SgOmpForSimdStatementStorageClass *storageArray )
  136672             :    {
  136673           0 :      unsigned long storageCounter = 0;
  136674           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpForSimdStatement::pools.begin();
  136675           0 :      SgOmpForSimdStatement* pointer = NULL;
  136676           0 :      while ( block != SgOmpForSimdStatement::pools.end() ) {
  136677           0 :           pointer = (SgOmpForSimdStatement*) (*block);
  136678           0 :           for ( unsigned i = 0; i < SgOmpForSimdStatement::pool_size; ++i ) {
  136679           0 :                if ( pointer->get_freepointer() != NULL ) {
  136680           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  136681           0 :                  storageArray++;
  136682           0 :                  storageCounter++;
  136683             :                }
  136684           0 :                pointer++;
  136685             :              }
  136686           0 :            block++;
  136687             :         }
  136688           0 :      return storageCounter;
  136689             :    }
  136690             : 
  136691             : /* #line 136692 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  136692             : 
  136693             : 
  136694             : 
  136695             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  136696             : 
  136697             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  136698             : 
  136699             : //############################################################################
  136700             : /* JH (02/02/2006) Constructor of the IR node SgOmpCriticalStatement that takes its 
  136701             :  * corresponding StorageClass as parameter
  136702             :  */
  136703           0 : SgOmpCriticalStatement :: SgOmpCriticalStatement ( const SgOmpCriticalStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  136704             :    {
  136705             : 
  136706             : 
  136707             : /* #line 136708 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  136708             : 
  136709           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  136710           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
  136711             : 
  136712             : 
  136713             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  136714             : 
  136715             : 
  136716           0 :    }
  136717             : 
  136718             : //############################################################################
  136719             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  136720             :  * within the working AST. 
  136721             :  */
  136722           0 : SgOmpCriticalStatement * SgOmpCriticalStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  136723           0 :      SgOmpCriticalStatement* returnPointer = NULL;
  136724           0 :      if ( globalIndex != 0 )
  136725             :         {
  136726             : 
  136727             : #if FILE_IO_EXTRA_CHECK
  136728           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpCriticalStatement ) ) <= globalIndex ) ;
  136729           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCriticalStatement + 1 ) ) );
  136730             : #endif
  136731           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCriticalStatement )  
  136732           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpCriticalStatement );
  136733           0 :           unsigned long positionInPool = localIndex % SgOmpCriticalStatement::pool_size;
  136734           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCriticalStatement::pool_size;
  136735             : 
  136736             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  136737             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  136738             : 
  136739           0 :           returnPointer = &( ( (SgOmpCriticalStatement*)(SgOmpCriticalStatement::pools[memoryBlock]) ) [positionInPool]) ;
  136740             : 
  136741           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  136742             :         }
  136743           0 :      return returnPointer ;
  136744             :    }
  136745             : 
  136746             : //############################################################################
  136747             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  136748             :   for the AST with the index astIndex
  136749             : */
  136750           0 : SgOmpCriticalStatement * SgOmpCriticalStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  136751           0 :      SgOmpCriticalStatement* returnPointer = NULL;
  136752           0 :      if ( globalIndex != 0 )
  136753             :         {
  136754             : 
  136755             : #if FILE_IO_EXTRA_CHECK
  136756           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpCriticalStatement ) ) <= globalIndex ) ;
  136757           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCriticalStatement + 1 ) ) );
  136758             : #endif
  136759           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCriticalStatement )
  136760           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpCriticalStatement );
  136761           0 :           unsigned long positionInPool = localIndex % SgOmpCriticalStatement::pool_size ;
  136762           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCriticalStatement::pool_size ;
  136763             : 
  136764             : #if FILE_IO_EXTRA_CHECK
  136765             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  136766             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  136767             : #endif
  136768             : 
  136769           0 :           returnPointer = &( ( (SgOmpCriticalStatement*)(SgOmpCriticalStatement::pools[memoryBlock]) ) [positionInPool]) ;
  136770             : 
  136771             : #if FILE_IO_EXTRA_CHECK
  136772           0 :           assert ( returnPointer != NULL ) ;
  136773             : #endif
  136774             :         }
  136775           0 :      return returnPointer ;
  136776             :    }
  136777             : 
  136778             : //############################################################################
  136779             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  136780             :  * pool size! We set for every valid object in the memory pool the freepointer
  136781             :  * to the global index and increase the global index afterwards. For all the 
  136782             :  * invalid objects (means address ranges within the memory pool that were not
  136783             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  136784             :  * distinguish valid from invalid objects! 
  136785             :  */
  136786             : unsigned long
  136787           5 : SgOmpCriticalStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  136788             :    {
  136789           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  136790           5 :      SgOmpCriticalStatement* pointer = NULL;
  136791           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  136792           5 :      std::vector < unsigned char* > :: const_iterator block;
  136793           5 :      for ( block = SgOmpCriticalStatement::pools.begin(); block != SgOmpCriticalStatement::pools.end() ; ++block )
  136794             :         {
  136795           0 :           pointer = (SgOmpCriticalStatement*)(*block);
  136796           0 :           for (unsigned i = 0; i < SgOmpCriticalStatement::pool_size; ++i )
  136797             :              {
  136798             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  136799             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  136800             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  136801             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  136802             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  136803             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  136804             :             // properly; so this will have to be checked next.
  136805             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  136806             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  136807           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  136808             :                   {
  136809           0 :                     pointer[i].set_freepointer((SgOmpCriticalStatement*)(globalIndex));
  136810           0 :                     globalIndex++;
  136811             :                   }
  136812             :                else
  136813             :                   {
  136814           0 :                     pointer[i].set_freepointer(NULL);
  136815             :                   }
  136816             :               }
  136817             :         }
  136818           5 :      return globalIndex;
  136819             :    }
  136820             : 
  136821             : //############################################################################
  136822             : // JH (01/14/2006)
  136823             : void
  136824           5 : SgOmpCriticalStatement::resetValidFreepointers( )
  136825             :    {
  136826           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  136827           5 :      SgOmpCriticalStatement* pointer = NULL;
  136828           5 :      std::vector < unsigned char* > :: const_iterator block;
  136829           5 :      SgOmpCriticalStatement* pointerOfLinkedList = NULL;
  136830           5 :      for ( block = SgOmpCriticalStatement::pools.begin(); block != SgOmpCriticalStatement::pools.end() ; ++block )
  136831             :         {
  136832           0 :           pointer = (SgOmpCriticalStatement*)(*block);
  136833           0 :           for (unsigned i = 0; i < SgOmpCriticalStatement::pool_size; ++i )
  136834             :              {
  136835             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  136836             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  136837             :             // memory blocks!.
  136838           0 :                if ( pointer[i].get_freepointer() != NULL )
  136839             :                   {
  136840           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  136841             :                   }
  136842             :                else
  136843             :                   {
  136844           0 :                     if ( pointerOfLinkedList == NULL )
  136845             :                        {
  136846           0 :                          SgOmpCriticalStatement::next_node = &(pointer[i]);
  136847             :                        }
  136848             :                     else
  136849             :                        {
  136850             :                       // printf ("In SgOmpCriticalStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  136851           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  136852             :                        }
  136853             :                     pointerOfLinkedList = &(pointer[i]);
  136854             :                   }
  136855             :               }
  136856             :         }
  136857             : 
  136858           5 :      if ( pointerOfLinkedList != NULL )
  136859             :         {
  136860             :        // printf ("In SgOmpCriticalStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  136861           0 :           pointerOfLinkedList->set_freepointer(NULL);
  136862             :        // DQ (6/6/2010): Temporary debugging...
  136863             :        //   ROSE_ASSERT(false);
  136864             :         }
  136865             : 
  136866           5 :      return ;
  136867             :    }
  136868             : 
  136869             : //############################################################################
  136870             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  136871             :  * within the memory pool and resets the freepointers, in order to achieve a 
  136872             :  * linked list, that has no jumps and starts at the beginning! This function 
  136873             :  * does not extend the memory pool, since we do not delete any memory blocks,
  136874             :  * but delete the valid objects.  
  136875             :  */
  136876             : void
  136877           0 : SgOmpCriticalStatement::clearMemoryPool( )
  136878             :    {
  136879             :   // printf ("Inside of SgOmpCriticalStatement::clearMemoryPool() \n");
  136880             : 
  136881           0 :      SgOmpCriticalStatement* pointer = NULL, *tempPointer = NULL;
  136882           0 :      std::vector < unsigned char* > :: const_iterator block;
  136883           0 :      if ( SgOmpCriticalStatement::pools.empty() == false )
  136884             :         {
  136885           0 :           block = SgOmpCriticalStatement::pools.begin() ;
  136886           0 :           SgOmpCriticalStatement::next_node = (SgOmpCriticalStatement*) (*block);
  136887             : 
  136888           0 :           while ( block != SgOmpCriticalStatement::pools.end() )
  136889             :              {
  136890           0 :                pointer = (SgOmpCriticalStatement*) (*block);
  136891           0 :                if ( tempPointer != NULL )
  136892             :                   {
  136893           0 :                     tempPointer->set_freepointer(pointer);
  136894             :                   }
  136895           0 :                for (unsigned i = 0; i < SgOmpCriticalStatement::pool_size - 1; ++i)
  136896             :                   {
  136897           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  136898             :                   }
  136899           0 :                 pointer[SgOmpCriticalStatement::pool_size-1].set_freepointer(NULL);
  136900           0 :                 tempPointer = &(pointer[SgOmpCriticalStatement::pool_size-1]);
  136901           0 :                 ++block;
  136902             :              }
  136903             :         }
  136904           0 :    }
  136905             : 
  136906           5 : void SgOmpCriticalStatement::deleteMemoryPool() {
  136907           5 :   for (auto p: SgOmpCriticalStatement::pools) {
  136908           0 :     ROSE_FREE(p);
  136909             :   }
  136910           5 :   SgOmpCriticalStatement::next_node = nullptr;
  136911           5 :   SgOmpCriticalStatement::pools.clear();
  136912           5 : }
  136913             : 
  136914             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  136915             : //                 reading multiple binary files to for a single AST.
  136916             : /////////// new version ////////////////////////////////
  136917             : //############################################################################
  136918             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  136919             : void
  136920           2 : SgOmpCriticalStatement::extendMemoryPoolForFileIO( )
  136921             :   {
  136922           2 :     size_t blockIndex = SgOmpCriticalStatement::pools.size();
  136923           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCriticalStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCriticalStatement);
  136924             : 
  136925           2 :     while ( (blockIndex * SgOmpCriticalStatement::pool_size) < newPoolSize)
  136926             :       {
  136927             : #if ROSE_ALLOC_TRACE
  136928             :         if (blockIndex > 0) {
  136929             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCriticalStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCriticalStatement) = %" PRIuPTR " SgOmpCriticalStatement::pool_size = %d \n",
  136930             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCriticalStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCriticalStatement),SgOmpCriticalStatement::pool_size);
  136931             :         }
  136932             : #endif
  136933             : 
  136934           0 :         SgOmpCriticalStatement * pointer = (SgOmpCriticalStatement*) ROSE_MALLOC ( SgOmpCriticalStatement::pool_size * sizeof(SgOmpCriticalStatement) );
  136935           0 :         assert( pointer != NULL );
  136936             : #if ROSE_ALLOC_MEMSET == 1
  136937             :         memset(pointer, 0x00, SgOmpCriticalStatement::pool_size * sizeof(SgOmpCriticalStatement));
  136938             : #elif ROSE_ALLOC_MEMSET == 2
  136939             :         memset(pointer, 0xCC, SgOmpCriticalStatement::pool_size * sizeof(SgOmpCriticalStatement));
  136940             : #endif
  136941           0 :         SgOmpCriticalStatement::pools.push_back( (unsigned char*)(pointer) );
  136942           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpCriticalStatement::pool_size * sizeof(SgOmpCriticalStatement), V_SgOmpCriticalStatement ) );
  136943             : 
  136944           0 :         if ( SgOmpCriticalStatement::next_node != NULL ) {
  136945           0 :           if ( blockIndex > 0 ) {
  136946           0 :             SgOmpCriticalStatement * blkptr = (SgOmpCriticalStatement*)(SgOmpCriticalStatement::pools[blockIndex-1]);
  136947           0 :             blkptr[ SgOmpCriticalStatement::pool_size - 1 ].set_freepointer(pointer);
  136948             :           }
  136949             :         } else {
  136950           0 :           SgOmpCriticalStatement::next_node = pointer;
  136951             :         }
  136952             : 
  136953           0 :         for (unsigned i = 0; i < SgOmpCriticalStatement::pool_size-1; ++i)
  136954             :            {
  136955           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  136956             :            }
  136957           0 :         pointer[ SgOmpCriticalStatement::pool_size -1 ].set_freepointer(NULL);
  136958             : 
  136959           0 :         blockIndex++;
  136960             :       }
  136961           2 :   }
  136962             : 
  136963             : //############################################################################
  136964             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  136965             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  136966             :  * not compressed. However, that stuff is not yet implemented! 
  136967             :  */
  136968             : unsigned long
  136969           0 : SgOmpCriticalStatement::getNumberOfLastValidPointer()
  136970             :    {
  136971           0 :       SgOmpCriticalStatement* testPointer = (SgOmpCriticalStatement*)(SgOmpCriticalStatement::pools.back());
  136972           0 :       unsigned long localIndex = SgOmpCriticalStatement::pool_size - 1;
  136973           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  136974             :          {
  136975           0 :            localIndex--;
  136976             :          }
  136977           0 :       return (localIndex + SgOmpCriticalStatement::pool_size * (SgOmpCriticalStatement::pools.size()-1));
  136978             :    }
  136979             : 
  136980             : //############################################################################
  136981             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  136982             :  * memory pool and initializes the data member in class SgOmpCriticalStatementStroageClass
  136983             :  * from its counterpart of SgOmpCriticalStatement. The return value is just for checking, 
  136984             :  * that the whole StorageClassArray is initialized!
  136985             :  */
  136986             : unsigned long
  136987           0 : SgOmpCriticalStatement::initializeStorageClassArray( SgOmpCriticalStatementStorageClass *storageArray )
  136988             :    {
  136989           0 :      unsigned long storageCounter = 0;
  136990           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpCriticalStatement::pools.begin();
  136991           0 :      SgOmpCriticalStatement* pointer = NULL;
  136992           0 :      while ( block != SgOmpCriticalStatement::pools.end() ) {
  136993           0 :           pointer = (SgOmpCriticalStatement*) (*block);
  136994           0 :           for ( unsigned i = 0; i < SgOmpCriticalStatement::pool_size; ++i ) {
  136995           0 :                if ( pointer->get_freepointer() != NULL ) {
  136996           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  136997           0 :                  storageArray++;
  136998           0 :                  storageCounter++;
  136999             :                }
  137000           0 :                pointer++;
  137001             :              }
  137002           0 :            block++;
  137003             :         }
  137004           0 :      return storageCounter;
  137005             :    }
  137006             : 
  137007             : /* #line 137008 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  137008             : 
  137009             : 
  137010             : 
  137011             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  137012             : 
  137013             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  137014             : 
  137015             : //############################################################################
  137016             : /* JH (02/02/2006) Constructor of the IR node SgOmpDistributeStatement that takes its 
  137017             :  * corresponding StorageClass as parameter
  137018             :  */
  137019           0 : SgOmpDistributeStatement :: SgOmpDistributeStatement ( const SgOmpDistributeStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  137020             :    {
  137021             : 
  137022             : 
  137023             : /* #line 137024 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  137024             : 
  137025           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  137026             : 
  137027             : 
  137028             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  137029             : 
  137030             : 
  137031           0 :    }
  137032             : 
  137033             : //############################################################################
  137034             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  137035             :  * within the working AST. 
  137036             :  */
  137037           0 : SgOmpDistributeStatement * SgOmpDistributeStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  137038           0 :      SgOmpDistributeStatement* returnPointer = NULL;
  137039           0 :      if ( globalIndex != 0 )
  137040             :         {
  137041             : 
  137042             : #if FILE_IO_EXTRA_CHECK
  137043           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDistributeStatement ) ) <= globalIndex ) ;
  137044           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistributeStatement + 1 ) ) );
  137045             : #endif
  137046           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDistributeStatement )  
  137047           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDistributeStatement );
  137048           0 :           unsigned long positionInPool = localIndex % SgOmpDistributeStatement::pool_size;
  137049           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistributeStatement::pool_size;
  137050             : 
  137051             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  137052             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  137053             : 
  137054           0 :           returnPointer = &( ( (SgOmpDistributeStatement*)(SgOmpDistributeStatement::pools[memoryBlock]) ) [positionInPool]) ;
  137055             : 
  137056           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  137057             :         }
  137058           0 :      return returnPointer ;
  137059             :    }
  137060             : 
  137061             : //############################################################################
  137062             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  137063             :   for the AST with the index astIndex
  137064             : */
  137065           0 : SgOmpDistributeStatement * SgOmpDistributeStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  137066           0 :      SgOmpDistributeStatement* returnPointer = NULL;
  137067           0 :      if ( globalIndex != 0 )
  137068             :         {
  137069             : 
  137070             : #if FILE_IO_EXTRA_CHECK
  137071           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDistributeStatement ) ) <= globalIndex ) ;
  137072           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistributeStatement + 1 ) ) );
  137073             : #endif
  137074           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDistributeStatement )
  137075           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDistributeStatement );
  137076           0 :           unsigned long positionInPool = localIndex % SgOmpDistributeStatement::pool_size ;
  137077           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDistributeStatement::pool_size ;
  137078             : 
  137079             : #if FILE_IO_EXTRA_CHECK
  137080             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  137081             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  137082             : #endif
  137083             : 
  137084           0 :           returnPointer = &( ( (SgOmpDistributeStatement*)(SgOmpDistributeStatement::pools[memoryBlock]) ) [positionInPool]) ;
  137085             : 
  137086             : #if FILE_IO_EXTRA_CHECK
  137087           0 :           assert ( returnPointer != NULL ) ;
  137088             : #endif
  137089             :         }
  137090           0 :      return returnPointer ;
  137091             :    }
  137092             : 
  137093             : //############################################################################
  137094             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  137095             :  * pool size! We set for every valid object in the memory pool the freepointer
  137096             :  * to the global index and increase the global index afterwards. For all the 
  137097             :  * invalid objects (means address ranges within the memory pool that were not
  137098             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  137099             :  * distinguish valid from invalid objects! 
  137100             :  */
  137101             : unsigned long
  137102           5 : SgOmpDistributeStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  137103             :    {
  137104           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  137105           5 :      SgOmpDistributeStatement* pointer = NULL;
  137106           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  137107           5 :      std::vector < unsigned char* > :: const_iterator block;
  137108           5 :      for ( block = SgOmpDistributeStatement::pools.begin(); block != SgOmpDistributeStatement::pools.end() ; ++block )
  137109             :         {
  137110           0 :           pointer = (SgOmpDistributeStatement*)(*block);
  137111           0 :           for (unsigned i = 0; i < SgOmpDistributeStatement::pool_size; ++i )
  137112             :              {
  137113             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  137114             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  137115             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  137116             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  137117             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  137118             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  137119             :             // properly; so this will have to be checked next.
  137120             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  137121             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  137122           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  137123             :                   {
  137124           0 :                     pointer[i].set_freepointer((SgOmpDistributeStatement*)(globalIndex));
  137125           0 :                     globalIndex++;
  137126             :                   }
  137127             :                else
  137128             :                   {
  137129           0 :                     pointer[i].set_freepointer(NULL);
  137130             :                   }
  137131             :               }
  137132             :         }
  137133           5 :      return globalIndex;
  137134             :    }
  137135             : 
  137136             : //############################################################################
  137137             : // JH (01/14/2006)
  137138             : void
  137139           5 : SgOmpDistributeStatement::resetValidFreepointers( )
  137140             :    {
  137141           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  137142           5 :      SgOmpDistributeStatement* pointer = NULL;
  137143           5 :      std::vector < unsigned char* > :: const_iterator block;
  137144           5 :      SgOmpDistributeStatement* pointerOfLinkedList = NULL;
  137145           5 :      for ( block = SgOmpDistributeStatement::pools.begin(); block != SgOmpDistributeStatement::pools.end() ; ++block )
  137146             :         {
  137147           0 :           pointer = (SgOmpDistributeStatement*)(*block);
  137148           0 :           for (unsigned i = 0; i < SgOmpDistributeStatement::pool_size; ++i )
  137149             :              {
  137150             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  137151             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  137152             :             // memory blocks!.
  137153           0 :                if ( pointer[i].get_freepointer() != NULL )
  137154             :                   {
  137155           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  137156             :                   }
  137157             :                else
  137158             :                   {
  137159           0 :                     if ( pointerOfLinkedList == NULL )
  137160             :                        {
  137161           0 :                          SgOmpDistributeStatement::next_node = &(pointer[i]);
  137162             :                        }
  137163             :                     else
  137164             :                        {
  137165             :                       // printf ("In SgOmpDistributeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  137166           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  137167             :                        }
  137168             :                     pointerOfLinkedList = &(pointer[i]);
  137169             :                   }
  137170             :               }
  137171             :         }
  137172             : 
  137173           5 :      if ( pointerOfLinkedList != NULL )
  137174             :         {
  137175             :        // printf ("In SgOmpDistributeStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  137176           0 :           pointerOfLinkedList->set_freepointer(NULL);
  137177             :        // DQ (6/6/2010): Temporary debugging...
  137178             :        //   ROSE_ASSERT(false);
  137179             :         }
  137180             : 
  137181           5 :      return ;
  137182             :    }
  137183             : 
  137184             : //############################################################################
  137185             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  137186             :  * within the memory pool and resets the freepointers, in order to achieve a 
  137187             :  * linked list, that has no jumps and starts at the beginning! This function 
  137188             :  * does not extend the memory pool, since we do not delete any memory blocks,
  137189             :  * but delete the valid objects.  
  137190             :  */
  137191             : void
  137192           0 : SgOmpDistributeStatement::clearMemoryPool( )
  137193             :    {
  137194             :   // printf ("Inside of SgOmpDistributeStatement::clearMemoryPool() \n");
  137195             : 
  137196           0 :      SgOmpDistributeStatement* pointer = NULL, *tempPointer = NULL;
  137197           0 :      std::vector < unsigned char* > :: const_iterator block;
  137198           0 :      if ( SgOmpDistributeStatement::pools.empty() == false )
  137199             :         {
  137200           0 :           block = SgOmpDistributeStatement::pools.begin() ;
  137201           0 :           SgOmpDistributeStatement::next_node = (SgOmpDistributeStatement*) (*block);
  137202             : 
  137203           0 :           while ( block != SgOmpDistributeStatement::pools.end() )
  137204             :              {
  137205           0 :                pointer = (SgOmpDistributeStatement*) (*block);
  137206           0 :                if ( tempPointer != NULL )
  137207             :                   {
  137208           0 :                     tempPointer->set_freepointer(pointer);
  137209             :                   }
  137210           0 :                for (unsigned i = 0; i < SgOmpDistributeStatement::pool_size - 1; ++i)
  137211             :                   {
  137212           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  137213             :                   }
  137214           0 :                 pointer[SgOmpDistributeStatement::pool_size-1].set_freepointer(NULL);
  137215           0 :                 tempPointer = &(pointer[SgOmpDistributeStatement::pool_size-1]);
  137216           0 :                 ++block;
  137217             :              }
  137218             :         }
  137219           0 :    }
  137220             : 
  137221           5 : void SgOmpDistributeStatement::deleteMemoryPool() {
  137222           5 :   for (auto p: SgOmpDistributeStatement::pools) {
  137223           0 :     ROSE_FREE(p);
  137224             :   }
  137225           5 :   SgOmpDistributeStatement::next_node = nullptr;
  137226           5 :   SgOmpDistributeStatement::pools.clear();
  137227           5 : }
  137228             : 
  137229             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  137230             : //                 reading multiple binary files to for a single AST.
  137231             : /////////// new version ////////////////////////////////
  137232             : //############################################################################
  137233             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  137234             : void
  137235           2 : SgOmpDistributeStatement::extendMemoryPoolForFileIO( )
  137236             :   {
  137237           2 :     size_t blockIndex = SgOmpDistributeStatement::pools.size();
  137238           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeStatement);
  137239             : 
  137240           2 :     while ( (blockIndex * SgOmpDistributeStatement::pool_size) < newPoolSize)
  137241             :       {
  137242             : #if ROSE_ALLOC_TRACE
  137243             :         if (blockIndex > 0) {
  137244             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeStatement) = %" PRIuPTR " SgOmpDistributeStatement::pool_size = %d \n",
  137245             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDistributeStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDistributeStatement),SgOmpDistributeStatement::pool_size);
  137246             :         }
  137247             : #endif
  137248             : 
  137249           0 :         SgOmpDistributeStatement * pointer = (SgOmpDistributeStatement*) ROSE_MALLOC ( SgOmpDistributeStatement::pool_size * sizeof(SgOmpDistributeStatement) );
  137250           0 :         assert( pointer != NULL );
  137251             : #if ROSE_ALLOC_MEMSET == 1
  137252             :         memset(pointer, 0x00, SgOmpDistributeStatement::pool_size * sizeof(SgOmpDistributeStatement));
  137253             : #elif ROSE_ALLOC_MEMSET == 2
  137254             :         memset(pointer, 0xCC, SgOmpDistributeStatement::pool_size * sizeof(SgOmpDistributeStatement));
  137255             : #endif
  137256           0 :         SgOmpDistributeStatement::pools.push_back( (unsigned char*)(pointer) );
  137257           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDistributeStatement::pool_size * sizeof(SgOmpDistributeStatement), V_SgOmpDistributeStatement ) );
  137258             : 
  137259           0 :         if ( SgOmpDistributeStatement::next_node != NULL ) {
  137260           0 :           if ( blockIndex > 0 ) {
  137261           0 :             SgOmpDistributeStatement * blkptr = (SgOmpDistributeStatement*)(SgOmpDistributeStatement::pools[blockIndex-1]);
  137262           0 :             blkptr[ SgOmpDistributeStatement::pool_size - 1 ].set_freepointer(pointer);
  137263             :           }
  137264             :         } else {
  137265           0 :           SgOmpDistributeStatement::next_node = pointer;
  137266             :         }
  137267             : 
  137268           0 :         for (unsigned i = 0; i < SgOmpDistributeStatement::pool_size-1; ++i)
  137269             :            {
  137270           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  137271             :            }
  137272           0 :         pointer[ SgOmpDistributeStatement::pool_size -1 ].set_freepointer(NULL);
  137273             : 
  137274           0 :         blockIndex++;
  137275             :       }
  137276           2 :   }
  137277             : 
  137278             : //############################################################################
  137279             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  137280             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  137281             :  * not compressed. However, that stuff is not yet implemented! 
  137282             :  */
  137283             : unsigned long
  137284           0 : SgOmpDistributeStatement::getNumberOfLastValidPointer()
  137285             :    {
  137286           0 :       SgOmpDistributeStatement* testPointer = (SgOmpDistributeStatement*)(SgOmpDistributeStatement::pools.back());
  137287           0 :       unsigned long localIndex = SgOmpDistributeStatement::pool_size - 1;
  137288           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  137289             :          {
  137290           0 :            localIndex--;
  137291             :          }
  137292           0 :       return (localIndex + SgOmpDistributeStatement::pool_size * (SgOmpDistributeStatement::pools.size()-1));
  137293             :    }
  137294             : 
  137295             : //############################################################################
  137296             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  137297             :  * memory pool and initializes the data member in class SgOmpDistributeStatementStroageClass
  137298             :  * from its counterpart of SgOmpDistributeStatement. The return value is just for checking, 
  137299             :  * that the whole StorageClassArray is initialized!
  137300             :  */
  137301             : unsigned long
  137302           0 : SgOmpDistributeStatement::initializeStorageClassArray( SgOmpDistributeStatementStorageClass *storageArray )
  137303             :    {
  137304           0 :      unsigned long storageCounter = 0;
  137305           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDistributeStatement::pools.begin();
  137306           0 :      SgOmpDistributeStatement* pointer = NULL;
  137307           0 :      while ( block != SgOmpDistributeStatement::pools.end() ) {
  137308           0 :           pointer = (SgOmpDistributeStatement*) (*block);
  137309           0 :           for ( unsigned i = 0; i < SgOmpDistributeStatement::pool_size; ++i ) {
  137310           0 :                if ( pointer->get_freepointer() != NULL ) {
  137311           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  137312           0 :                  storageArray++;
  137313           0 :                  storageCounter++;
  137314             :                }
  137315           0 :                pointer++;
  137316             :              }
  137317           0 :            block++;
  137318             :         }
  137319           0 :      return storageCounter;
  137320             :    }
  137321             : 
  137322             : /* #line 137323 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  137323             : 
  137324             : 
  137325             : 
  137326             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  137327             : 
  137328             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  137329             : 
  137330             : //############################################################################
  137331             : /* JH (02/02/2006) Constructor of the IR node SgOmpUnrollStatement that takes its 
  137332             :  * corresponding StorageClass as parameter
  137333             :  */
  137334           0 : SgOmpUnrollStatement :: SgOmpUnrollStatement ( const SgOmpUnrollStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  137335             :    {
  137336             : 
  137337             : 
  137338             : /* #line 137339 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  137339             : 
  137340           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  137341             : 
  137342             : 
  137343             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  137344             : 
  137345             : 
  137346           0 :    }
  137347             : 
  137348             : //############################################################################
  137349             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  137350             :  * within the working AST. 
  137351             :  */
  137352           0 : SgOmpUnrollStatement * SgOmpUnrollStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  137353           0 :      SgOmpUnrollStatement* returnPointer = NULL;
  137354           0 :      if ( globalIndex != 0 )
  137355             :         {
  137356             : 
  137357             : #if FILE_IO_EXTRA_CHECK
  137358           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpUnrollStatement ) ) <= globalIndex ) ;
  137359           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUnrollStatement + 1 ) ) );
  137360             : #endif
  137361           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpUnrollStatement )  
  137362           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpUnrollStatement );
  137363           0 :           unsigned long positionInPool = localIndex % SgOmpUnrollStatement::pool_size;
  137364           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUnrollStatement::pool_size;
  137365             : 
  137366             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  137367             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  137368             : 
  137369           0 :           returnPointer = &( ( (SgOmpUnrollStatement*)(SgOmpUnrollStatement::pools[memoryBlock]) ) [positionInPool]) ;
  137370             : 
  137371           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  137372             :         }
  137373           0 :      return returnPointer ;
  137374             :    }
  137375             : 
  137376             : //############################################################################
  137377             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  137378             :   for the AST with the index astIndex
  137379             : */
  137380           0 : SgOmpUnrollStatement * SgOmpUnrollStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  137381           0 :      SgOmpUnrollStatement* returnPointer = NULL;
  137382           0 :      if ( globalIndex != 0 )
  137383             :         {
  137384             : 
  137385             : #if FILE_IO_EXTRA_CHECK
  137386           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpUnrollStatement ) ) <= globalIndex ) ;
  137387           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUnrollStatement + 1 ) ) );
  137388             : #endif
  137389           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpUnrollStatement )
  137390           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpUnrollStatement );
  137391           0 :           unsigned long positionInPool = localIndex % SgOmpUnrollStatement::pool_size ;
  137392           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpUnrollStatement::pool_size ;
  137393             : 
  137394             : #if FILE_IO_EXTRA_CHECK
  137395             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  137396             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  137397             : #endif
  137398             : 
  137399           0 :           returnPointer = &( ( (SgOmpUnrollStatement*)(SgOmpUnrollStatement::pools[memoryBlock]) ) [positionInPool]) ;
  137400             : 
  137401             : #if FILE_IO_EXTRA_CHECK
  137402           0 :           assert ( returnPointer != NULL ) ;
  137403             : #endif
  137404             :         }
  137405           0 :      return returnPointer ;
  137406             :    }
  137407             : 
  137408             : //############################################################################
  137409             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  137410             :  * pool size! We set for every valid object in the memory pool the freepointer
  137411             :  * to the global index and increase the global index afterwards. For all the 
  137412             :  * invalid objects (means address ranges within the memory pool that were not
  137413             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  137414             :  * distinguish valid from invalid objects! 
  137415             :  */
  137416             : unsigned long
  137417           5 : SgOmpUnrollStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  137418             :    {
  137419           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  137420           5 :      SgOmpUnrollStatement* pointer = NULL;
  137421           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  137422           5 :      std::vector < unsigned char* > :: const_iterator block;
  137423           5 :      for ( block = SgOmpUnrollStatement::pools.begin(); block != SgOmpUnrollStatement::pools.end() ; ++block )
  137424             :         {
  137425           0 :           pointer = (SgOmpUnrollStatement*)(*block);
  137426           0 :           for (unsigned i = 0; i < SgOmpUnrollStatement::pool_size; ++i )
  137427             :              {
  137428             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  137429             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  137430             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  137431             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  137432             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  137433             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  137434             :             // properly; so this will have to be checked next.
  137435             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  137436             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  137437           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  137438             :                   {
  137439           0 :                     pointer[i].set_freepointer((SgOmpUnrollStatement*)(globalIndex));
  137440           0 :                     globalIndex++;
  137441             :                   }
  137442             :                else
  137443             :                   {
  137444           0 :                     pointer[i].set_freepointer(NULL);
  137445             :                   }
  137446             :               }
  137447             :         }
  137448           5 :      return globalIndex;
  137449             :    }
  137450             : 
  137451             : //############################################################################
  137452             : // JH (01/14/2006)
  137453             : void
  137454           5 : SgOmpUnrollStatement::resetValidFreepointers( )
  137455             :    {
  137456           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  137457           5 :      SgOmpUnrollStatement* pointer = NULL;
  137458           5 :      std::vector < unsigned char* > :: const_iterator block;
  137459           5 :      SgOmpUnrollStatement* pointerOfLinkedList = NULL;
  137460           5 :      for ( block = SgOmpUnrollStatement::pools.begin(); block != SgOmpUnrollStatement::pools.end() ; ++block )
  137461             :         {
  137462           0 :           pointer = (SgOmpUnrollStatement*)(*block);
  137463           0 :           for (unsigned i = 0; i < SgOmpUnrollStatement::pool_size; ++i )
  137464             :              {
  137465             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  137466             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  137467             :             // memory blocks!.
  137468           0 :                if ( pointer[i].get_freepointer() != NULL )
  137469             :                   {
  137470           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  137471             :                   }
  137472             :                else
  137473             :                   {
  137474           0 :                     if ( pointerOfLinkedList == NULL )
  137475             :                        {
  137476           0 :                          SgOmpUnrollStatement::next_node = &(pointer[i]);
  137477             :                        }
  137478             :                     else
  137479             :                        {
  137480             :                       // printf ("In SgOmpUnrollStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  137481           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  137482             :                        }
  137483             :                     pointerOfLinkedList = &(pointer[i]);
  137484             :                   }
  137485             :               }
  137486             :         }
  137487             : 
  137488           5 :      if ( pointerOfLinkedList != NULL )
  137489             :         {
  137490             :        // printf ("In SgOmpUnrollStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  137491           0 :           pointerOfLinkedList->set_freepointer(NULL);
  137492             :        // DQ (6/6/2010): Temporary debugging...
  137493             :        //   ROSE_ASSERT(false);
  137494             :         }
  137495             : 
  137496           5 :      return ;
  137497             :    }
  137498             : 
  137499             : //############################################################################
  137500             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  137501             :  * within the memory pool and resets the freepointers, in order to achieve a 
  137502             :  * linked list, that has no jumps and starts at the beginning! This function 
  137503             :  * does not extend the memory pool, since we do not delete any memory blocks,
  137504             :  * but delete the valid objects.  
  137505             :  */
  137506             : void
  137507           0 : SgOmpUnrollStatement::clearMemoryPool( )
  137508             :    {
  137509             :   // printf ("Inside of SgOmpUnrollStatement::clearMemoryPool() \n");
  137510             : 
  137511           0 :      SgOmpUnrollStatement* pointer = NULL, *tempPointer = NULL;
  137512           0 :      std::vector < unsigned char* > :: const_iterator block;
  137513           0 :      if ( SgOmpUnrollStatement::pools.empty() == false )
  137514             :         {
  137515           0 :           block = SgOmpUnrollStatement::pools.begin() ;
  137516           0 :           SgOmpUnrollStatement::next_node = (SgOmpUnrollStatement*) (*block);
  137517             : 
  137518           0 :           while ( block != SgOmpUnrollStatement::pools.end() )
  137519             :              {
  137520           0 :                pointer = (SgOmpUnrollStatement*) (*block);
  137521           0 :                if ( tempPointer != NULL )
  137522             :                   {
  137523           0 :                     tempPointer->set_freepointer(pointer);
  137524             :                   }
  137525           0 :                for (unsigned i = 0; i < SgOmpUnrollStatement::pool_size - 1; ++i)
  137526             :                   {
  137527           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  137528             :                   }
  137529           0 :                 pointer[SgOmpUnrollStatement::pool_size-1].set_freepointer(NULL);
  137530           0 :                 tempPointer = &(pointer[SgOmpUnrollStatement::pool_size-1]);
  137531           0 :                 ++block;
  137532             :              }
  137533             :         }
  137534           0 :    }
  137535             : 
  137536           5 : void SgOmpUnrollStatement::deleteMemoryPool() {
  137537           5 :   for (auto p: SgOmpUnrollStatement::pools) {
  137538           0 :     ROSE_FREE(p);
  137539             :   }
  137540           5 :   SgOmpUnrollStatement::next_node = nullptr;
  137541           5 :   SgOmpUnrollStatement::pools.clear();
  137542           5 : }
  137543             : 
  137544             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  137545             : //                 reading multiple binary files to for a single AST.
  137546             : /////////// new version ////////////////////////////////
  137547             : //############################################################################
  137548             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  137549             : void
  137550           2 : SgOmpUnrollStatement::extendMemoryPoolForFileIO( )
  137551             :   {
  137552           2 :     size_t blockIndex = SgOmpUnrollStatement::pools.size();
  137553           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnrollStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnrollStatement);
  137554             : 
  137555           2 :     while ( (blockIndex * SgOmpUnrollStatement::pool_size) < newPoolSize)
  137556             :       {
  137557             : #if ROSE_ALLOC_TRACE
  137558             :         if (blockIndex > 0) {
  137559             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnrollStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnrollStatement) = %" PRIuPTR " SgOmpUnrollStatement::pool_size = %d \n",
  137560             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpUnrollStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpUnrollStatement),SgOmpUnrollStatement::pool_size);
  137561             :         }
  137562             : #endif
  137563             : 
  137564           0 :         SgOmpUnrollStatement * pointer = (SgOmpUnrollStatement*) ROSE_MALLOC ( SgOmpUnrollStatement::pool_size * sizeof(SgOmpUnrollStatement) );
  137565           0 :         assert( pointer != NULL );
  137566             : #if ROSE_ALLOC_MEMSET == 1
  137567             :         memset(pointer, 0x00, SgOmpUnrollStatement::pool_size * sizeof(SgOmpUnrollStatement));
  137568             : #elif ROSE_ALLOC_MEMSET == 2
  137569             :         memset(pointer, 0xCC, SgOmpUnrollStatement::pool_size * sizeof(SgOmpUnrollStatement));
  137570             : #endif
  137571           0 :         SgOmpUnrollStatement::pools.push_back( (unsigned char*)(pointer) );
  137572           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpUnrollStatement::pool_size * sizeof(SgOmpUnrollStatement), V_SgOmpUnrollStatement ) );
  137573             : 
  137574           0 :         if ( SgOmpUnrollStatement::next_node != NULL ) {
  137575           0 :           if ( blockIndex > 0 ) {
  137576           0 :             SgOmpUnrollStatement * blkptr = (SgOmpUnrollStatement*)(SgOmpUnrollStatement::pools[blockIndex-1]);
  137577           0 :             blkptr[ SgOmpUnrollStatement::pool_size - 1 ].set_freepointer(pointer);
  137578             :           }
  137579             :         } else {
  137580           0 :           SgOmpUnrollStatement::next_node = pointer;
  137581             :         }
  137582             : 
  137583           0 :         for (unsigned i = 0; i < SgOmpUnrollStatement::pool_size-1; ++i)
  137584             :            {
  137585           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  137586             :            }
  137587           0 :         pointer[ SgOmpUnrollStatement::pool_size -1 ].set_freepointer(NULL);
  137588             : 
  137589           0 :         blockIndex++;
  137590             :       }
  137591           2 :   }
  137592             : 
  137593             : //############################################################################
  137594             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  137595             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  137596             :  * not compressed. However, that stuff is not yet implemented! 
  137597             :  */
  137598             : unsigned long
  137599           0 : SgOmpUnrollStatement::getNumberOfLastValidPointer()
  137600             :    {
  137601           0 :       SgOmpUnrollStatement* testPointer = (SgOmpUnrollStatement*)(SgOmpUnrollStatement::pools.back());
  137602           0 :       unsigned long localIndex = SgOmpUnrollStatement::pool_size - 1;
  137603           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  137604             :          {
  137605           0 :            localIndex--;
  137606             :          }
  137607           0 :       return (localIndex + SgOmpUnrollStatement::pool_size * (SgOmpUnrollStatement::pools.size()-1));
  137608             :    }
  137609             : 
  137610             : //############################################################################
  137611             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  137612             :  * memory pool and initializes the data member in class SgOmpUnrollStatementStroageClass
  137613             :  * from its counterpart of SgOmpUnrollStatement. The return value is just for checking, 
  137614             :  * that the whole StorageClassArray is initialized!
  137615             :  */
  137616             : unsigned long
  137617           0 : SgOmpUnrollStatement::initializeStorageClassArray( SgOmpUnrollStatementStorageClass *storageArray )
  137618             :    {
  137619           0 :      unsigned long storageCounter = 0;
  137620           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpUnrollStatement::pools.begin();
  137621           0 :      SgOmpUnrollStatement* pointer = NULL;
  137622           0 :      while ( block != SgOmpUnrollStatement::pools.end() ) {
  137623           0 :           pointer = (SgOmpUnrollStatement*) (*block);
  137624           0 :           for ( unsigned i = 0; i < SgOmpUnrollStatement::pool_size; ++i ) {
  137625           0 :                if ( pointer->get_freepointer() != NULL ) {
  137626           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  137627           0 :                  storageArray++;
  137628           0 :                  storageCounter++;
  137629             :                }
  137630           0 :                pointer++;
  137631             :              }
  137632           0 :            block++;
  137633             :         }
  137634           0 :      return storageCounter;
  137635             :    }
  137636             : 
  137637             : /* #line 137638 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  137638             : 
  137639             : 
  137640             : 
  137641             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  137642             : 
  137643             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  137644             : 
  137645             : //############################################################################
  137646             : /* JH (02/02/2006) Constructor of the IR node SgOmpTileStatement that takes its 
  137647             :  * corresponding StorageClass as parameter
  137648             :  */
  137649           0 : SgOmpTileStatement :: SgOmpTileStatement ( const SgOmpTileStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  137650             :    {
  137651             : 
  137652             : 
  137653             : /* #line 137654 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  137654             : 
  137655           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  137656             : 
  137657             : 
  137658             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  137659             : 
  137660             : 
  137661           0 :    }
  137662             : 
  137663             : //############################################################################
  137664             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  137665             :  * within the working AST. 
  137666             :  */
  137667           0 : SgOmpTileStatement * SgOmpTileStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  137668           0 :      SgOmpTileStatement* returnPointer = NULL;
  137669           0 :      if ( globalIndex != 0 )
  137670             :         {
  137671             : 
  137672             : #if FILE_IO_EXTRA_CHECK
  137673           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTileStatement ) ) <= globalIndex ) ;
  137674           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTileStatement + 1 ) ) );
  137675             : #endif
  137676           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTileStatement )  
  137677           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTileStatement );
  137678           0 :           unsigned long positionInPool = localIndex % SgOmpTileStatement::pool_size;
  137679           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTileStatement::pool_size;
  137680             : 
  137681             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  137682             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  137683             : 
  137684           0 :           returnPointer = &( ( (SgOmpTileStatement*)(SgOmpTileStatement::pools[memoryBlock]) ) [positionInPool]) ;
  137685             : 
  137686           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  137687             :         }
  137688           0 :      return returnPointer ;
  137689             :    }
  137690             : 
  137691             : //############################################################################
  137692             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  137693             :   for the AST with the index astIndex
  137694             : */
  137695           0 : SgOmpTileStatement * SgOmpTileStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  137696           0 :      SgOmpTileStatement* returnPointer = NULL;
  137697           0 :      if ( globalIndex != 0 )
  137698             :         {
  137699             : 
  137700             : #if FILE_IO_EXTRA_CHECK
  137701           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTileStatement ) ) <= globalIndex ) ;
  137702           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTileStatement + 1 ) ) );
  137703             : #endif
  137704           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTileStatement )
  137705           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTileStatement );
  137706           0 :           unsigned long positionInPool = localIndex % SgOmpTileStatement::pool_size ;
  137707           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTileStatement::pool_size ;
  137708             : 
  137709             : #if FILE_IO_EXTRA_CHECK
  137710             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  137711             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  137712             : #endif
  137713             : 
  137714           0 :           returnPointer = &( ( (SgOmpTileStatement*)(SgOmpTileStatement::pools[memoryBlock]) ) [positionInPool]) ;
  137715             : 
  137716             : #if FILE_IO_EXTRA_CHECK
  137717           0 :           assert ( returnPointer != NULL ) ;
  137718             : #endif
  137719             :         }
  137720           0 :      return returnPointer ;
  137721             :    }
  137722             : 
  137723             : //############################################################################
  137724             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  137725             :  * pool size! We set for every valid object in the memory pool the freepointer
  137726             :  * to the global index and increase the global index afterwards. For all the 
  137727             :  * invalid objects (means address ranges within the memory pool that were not
  137728             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  137729             :  * distinguish valid from invalid objects! 
  137730             :  */
  137731             : unsigned long
  137732           5 : SgOmpTileStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  137733             :    {
  137734           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  137735           5 :      SgOmpTileStatement* pointer = NULL;
  137736           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  137737           5 :      std::vector < unsigned char* > :: const_iterator block;
  137738           5 :      for ( block = SgOmpTileStatement::pools.begin(); block != SgOmpTileStatement::pools.end() ; ++block )
  137739             :         {
  137740           0 :           pointer = (SgOmpTileStatement*)(*block);
  137741           0 :           for (unsigned i = 0; i < SgOmpTileStatement::pool_size; ++i )
  137742             :              {
  137743             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  137744             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  137745             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  137746             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  137747             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  137748             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  137749             :             // properly; so this will have to be checked next.
  137750             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  137751             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  137752           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  137753             :                   {
  137754           0 :                     pointer[i].set_freepointer((SgOmpTileStatement*)(globalIndex));
  137755           0 :                     globalIndex++;
  137756             :                   }
  137757             :                else
  137758             :                   {
  137759           0 :                     pointer[i].set_freepointer(NULL);
  137760             :                   }
  137761             :               }
  137762             :         }
  137763           5 :      return globalIndex;
  137764             :    }
  137765             : 
  137766             : //############################################################################
  137767             : // JH (01/14/2006)
  137768             : void
  137769           5 : SgOmpTileStatement::resetValidFreepointers( )
  137770             :    {
  137771           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  137772           5 :      SgOmpTileStatement* pointer = NULL;
  137773           5 :      std::vector < unsigned char* > :: const_iterator block;
  137774           5 :      SgOmpTileStatement* pointerOfLinkedList = NULL;
  137775           5 :      for ( block = SgOmpTileStatement::pools.begin(); block != SgOmpTileStatement::pools.end() ; ++block )
  137776             :         {
  137777           0 :           pointer = (SgOmpTileStatement*)(*block);
  137778           0 :           for (unsigned i = 0; i < SgOmpTileStatement::pool_size; ++i )
  137779             :              {
  137780             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  137781             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  137782             :             // memory blocks!.
  137783           0 :                if ( pointer[i].get_freepointer() != NULL )
  137784             :                   {
  137785           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  137786             :                   }
  137787             :                else
  137788             :                   {
  137789           0 :                     if ( pointerOfLinkedList == NULL )
  137790             :                        {
  137791           0 :                          SgOmpTileStatement::next_node = &(pointer[i]);
  137792             :                        }
  137793             :                     else
  137794             :                        {
  137795             :                       // printf ("In SgOmpTileStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  137796           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  137797             :                        }
  137798             :                     pointerOfLinkedList = &(pointer[i]);
  137799             :                   }
  137800             :               }
  137801             :         }
  137802             : 
  137803           5 :      if ( pointerOfLinkedList != NULL )
  137804             :         {
  137805             :        // printf ("In SgOmpTileStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  137806           0 :           pointerOfLinkedList->set_freepointer(NULL);
  137807             :        // DQ (6/6/2010): Temporary debugging...
  137808             :        //   ROSE_ASSERT(false);
  137809             :         }
  137810             : 
  137811           5 :      return ;
  137812             :    }
  137813             : 
  137814             : //############################################################################
  137815             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  137816             :  * within the memory pool and resets the freepointers, in order to achieve a 
  137817             :  * linked list, that has no jumps and starts at the beginning! This function 
  137818             :  * does not extend the memory pool, since we do not delete any memory blocks,
  137819             :  * but delete the valid objects.  
  137820             :  */
  137821             : void
  137822           0 : SgOmpTileStatement::clearMemoryPool( )
  137823             :    {
  137824             :   // printf ("Inside of SgOmpTileStatement::clearMemoryPool() \n");
  137825             : 
  137826           0 :      SgOmpTileStatement* pointer = NULL, *tempPointer = NULL;
  137827           0 :      std::vector < unsigned char* > :: const_iterator block;
  137828           0 :      if ( SgOmpTileStatement::pools.empty() == false )
  137829             :         {
  137830           0 :           block = SgOmpTileStatement::pools.begin() ;
  137831           0 :           SgOmpTileStatement::next_node = (SgOmpTileStatement*) (*block);
  137832             : 
  137833           0 :           while ( block != SgOmpTileStatement::pools.end() )
  137834             :              {
  137835           0 :                pointer = (SgOmpTileStatement*) (*block);
  137836           0 :                if ( tempPointer != NULL )
  137837             :                   {
  137838           0 :                     tempPointer->set_freepointer(pointer);
  137839             :                   }
  137840           0 :                for (unsigned i = 0; i < SgOmpTileStatement::pool_size - 1; ++i)
  137841             :                   {
  137842           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  137843             :                   }
  137844           0 :                 pointer[SgOmpTileStatement::pool_size-1].set_freepointer(NULL);
  137845           0 :                 tempPointer = &(pointer[SgOmpTileStatement::pool_size-1]);
  137846           0 :                 ++block;
  137847             :              }
  137848             :         }
  137849           0 :    }
  137850             : 
  137851           5 : void SgOmpTileStatement::deleteMemoryPool() {
  137852           5 :   for (auto p: SgOmpTileStatement::pools) {
  137853           0 :     ROSE_FREE(p);
  137854             :   }
  137855           5 :   SgOmpTileStatement::next_node = nullptr;
  137856           5 :   SgOmpTileStatement::pools.clear();
  137857           5 : }
  137858             : 
  137859             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  137860             : //                 reading multiple binary files to for a single AST.
  137861             : /////////// new version ////////////////////////////////
  137862             : //############################################################################
  137863             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  137864             : void
  137865           2 : SgOmpTileStatement::extendMemoryPoolForFileIO( )
  137866             :   {
  137867           2 :     size_t blockIndex = SgOmpTileStatement::pools.size();
  137868           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTileStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTileStatement);
  137869             : 
  137870           2 :     while ( (blockIndex * SgOmpTileStatement::pool_size) < newPoolSize)
  137871             :       {
  137872             : #if ROSE_ALLOC_TRACE
  137873             :         if (blockIndex > 0) {
  137874             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTileStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTileStatement) = %" PRIuPTR " SgOmpTileStatement::pool_size = %d \n",
  137875             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTileStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTileStatement),SgOmpTileStatement::pool_size);
  137876             :         }
  137877             : #endif
  137878             : 
  137879           0 :         SgOmpTileStatement * pointer = (SgOmpTileStatement*) ROSE_MALLOC ( SgOmpTileStatement::pool_size * sizeof(SgOmpTileStatement) );
  137880           0 :         assert( pointer != NULL );
  137881             : #if ROSE_ALLOC_MEMSET == 1
  137882             :         memset(pointer, 0x00, SgOmpTileStatement::pool_size * sizeof(SgOmpTileStatement));
  137883             : #elif ROSE_ALLOC_MEMSET == 2
  137884             :         memset(pointer, 0xCC, SgOmpTileStatement::pool_size * sizeof(SgOmpTileStatement));
  137885             : #endif
  137886           0 :         SgOmpTileStatement::pools.push_back( (unsigned char*)(pointer) );
  137887           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTileStatement::pool_size * sizeof(SgOmpTileStatement), V_SgOmpTileStatement ) );
  137888             : 
  137889           0 :         if ( SgOmpTileStatement::next_node != NULL ) {
  137890           0 :           if ( blockIndex > 0 ) {
  137891           0 :             SgOmpTileStatement * blkptr = (SgOmpTileStatement*)(SgOmpTileStatement::pools[blockIndex-1]);
  137892           0 :             blkptr[ SgOmpTileStatement::pool_size - 1 ].set_freepointer(pointer);
  137893             :           }
  137894             :         } else {
  137895           0 :           SgOmpTileStatement::next_node = pointer;
  137896             :         }
  137897             : 
  137898           0 :         for (unsigned i = 0; i < SgOmpTileStatement::pool_size-1; ++i)
  137899             :            {
  137900           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  137901             :            }
  137902           0 :         pointer[ SgOmpTileStatement::pool_size -1 ].set_freepointer(NULL);
  137903             : 
  137904           0 :         blockIndex++;
  137905             :       }
  137906           2 :   }
  137907             : 
  137908             : //############################################################################
  137909             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  137910             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  137911             :  * not compressed. However, that stuff is not yet implemented! 
  137912             :  */
  137913             : unsigned long
  137914           0 : SgOmpTileStatement::getNumberOfLastValidPointer()
  137915             :    {
  137916           0 :       SgOmpTileStatement* testPointer = (SgOmpTileStatement*)(SgOmpTileStatement::pools.back());
  137917           0 :       unsigned long localIndex = SgOmpTileStatement::pool_size - 1;
  137918           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  137919             :          {
  137920           0 :            localIndex--;
  137921             :          }
  137922           0 :       return (localIndex + SgOmpTileStatement::pool_size * (SgOmpTileStatement::pools.size()-1));
  137923             :    }
  137924             : 
  137925             : //############################################################################
  137926             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  137927             :  * memory pool and initializes the data member in class SgOmpTileStatementStroageClass
  137928             :  * from its counterpart of SgOmpTileStatement. The return value is just for checking, 
  137929             :  * that the whole StorageClassArray is initialized!
  137930             :  */
  137931             : unsigned long
  137932           0 : SgOmpTileStatement::initializeStorageClassArray( SgOmpTileStatementStorageClass *storageArray )
  137933             :    {
  137934           0 :      unsigned long storageCounter = 0;
  137935           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTileStatement::pools.begin();
  137936           0 :      SgOmpTileStatement* pointer = NULL;
  137937           0 :      while ( block != SgOmpTileStatement::pools.end() ) {
  137938           0 :           pointer = (SgOmpTileStatement*) (*block);
  137939           0 :           for ( unsigned i = 0; i < SgOmpTileStatement::pool_size; ++i ) {
  137940           0 :                if ( pointer->get_freepointer() != NULL ) {
  137941           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  137942           0 :                  storageArray++;
  137943           0 :                  storageCounter++;
  137944             :                }
  137945           0 :                pointer++;
  137946             :              }
  137947           0 :            block++;
  137948             :         }
  137949           0 :      return storageCounter;
  137950             :    }
  137951             : 
  137952             : /* #line 137953 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  137953             : 
  137954             : 
  137955             : 
  137956             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  137957             : 
  137958             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  137959             : 
  137960             : //############################################################################
  137961             : /* JH (02/02/2006) Constructor of the IR node SgUpirLoopStatement that takes its 
  137962             :  * corresponding StorageClass as parameter
  137963             :  */
  137964           0 : SgUpirLoopStatement :: SgUpirLoopStatement ( const SgUpirLoopStatementStorageClass& storageSource )   : SgUpirFieldBodyStatement (storageSource)
  137965             :    {
  137966             : 
  137967             : 
  137968             : /* #line 137969 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  137969             : 
  137970           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  137971           0 :      p_induction =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_induction) );
  137972           0 :      p_lower_bound =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lower_bound) );
  137973           0 :      p_upper_bound =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_upper_bound) );
  137974           0 :      p_step =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_step) );
  137975           0 :      p_incremental = storageSource.storageOf_incremental ;
  137976             : 
  137977             : 
  137978             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  137979             : 
  137980             : 
  137981           0 :    }
  137982             : 
  137983             : //############################################################################
  137984             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  137985             :  * within the working AST. 
  137986             :  */
  137987           0 : SgUpirLoopStatement * SgUpirLoopStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  137988           0 :      SgUpirLoopStatement* returnPointer = NULL;
  137989           0 :      if ( globalIndex != 0 )
  137990             :         {
  137991             : 
  137992             : #if FILE_IO_EXTRA_CHECK
  137993           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirLoopStatement ) ) <= globalIndex ) ;
  137994           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirLoopStatement + 1 ) ) );
  137995             : #endif
  137996           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirLoopStatement )  
  137997           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirLoopStatement );
  137998           0 :           unsigned long positionInPool = localIndex % SgUpirLoopStatement::pool_size;
  137999           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirLoopStatement::pool_size;
  138000             : 
  138001             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  138002             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  138003             : 
  138004           0 :           returnPointer = &( ( (SgUpirLoopStatement*)(SgUpirLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  138005             : 
  138006           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  138007             :         }
  138008           0 :      return returnPointer ;
  138009             :    }
  138010             : 
  138011             : //############################################################################
  138012             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  138013             :   for the AST with the index astIndex
  138014             : */
  138015           0 : SgUpirLoopStatement * SgUpirLoopStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  138016           0 :      SgUpirLoopStatement* returnPointer = NULL;
  138017           0 :      if ( globalIndex != 0 )
  138018             :         {
  138019             : 
  138020             : #if FILE_IO_EXTRA_CHECK
  138021           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirLoopStatement ) ) <= globalIndex ) ;
  138022           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirLoopStatement + 1 ) ) );
  138023             : #endif
  138024           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirLoopStatement )
  138025           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirLoopStatement );
  138026           0 :           unsigned long positionInPool = localIndex % SgUpirLoopStatement::pool_size ;
  138027           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirLoopStatement::pool_size ;
  138028             : 
  138029             : #if FILE_IO_EXTRA_CHECK
  138030             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  138031             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  138032             : #endif
  138033             : 
  138034           0 :           returnPointer = &( ( (SgUpirLoopStatement*)(SgUpirLoopStatement::pools[memoryBlock]) ) [positionInPool]) ;
  138035             : 
  138036             : #if FILE_IO_EXTRA_CHECK
  138037           0 :           assert ( returnPointer != NULL ) ;
  138038             : #endif
  138039             :         }
  138040           0 :      return returnPointer ;
  138041             :    }
  138042             : 
  138043             : //############################################################################
  138044             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  138045             :  * pool size! We set for every valid object in the memory pool the freepointer
  138046             :  * to the global index and increase the global index afterwards. For all the 
  138047             :  * invalid objects (means address ranges within the memory pool that were not
  138048             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  138049             :  * distinguish valid from invalid objects! 
  138050             :  */
  138051             : unsigned long
  138052           5 : SgUpirLoopStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  138053             :    {
  138054           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  138055           5 :      SgUpirLoopStatement* pointer = NULL;
  138056           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  138057           5 :      std::vector < unsigned char* > :: const_iterator block;
  138058           5 :      for ( block = SgUpirLoopStatement::pools.begin(); block != SgUpirLoopStatement::pools.end() ; ++block )
  138059             :         {
  138060           0 :           pointer = (SgUpirLoopStatement*)(*block);
  138061           0 :           for (unsigned i = 0; i < SgUpirLoopStatement::pool_size; ++i )
  138062             :              {
  138063             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  138064             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  138065             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  138066             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  138067             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  138068             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  138069             :             // properly; so this will have to be checked next.
  138070             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  138071             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  138072           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  138073             :                   {
  138074           0 :                     pointer[i].set_freepointer((SgUpirLoopStatement*)(globalIndex));
  138075           0 :                     globalIndex++;
  138076             :                   }
  138077             :                else
  138078             :                   {
  138079           0 :                     pointer[i].set_freepointer(NULL);
  138080             :                   }
  138081             :               }
  138082             :         }
  138083           5 :      return globalIndex;
  138084             :    }
  138085             : 
  138086             : //############################################################################
  138087             : // JH (01/14/2006)
  138088             : void
  138089           5 : SgUpirLoopStatement::resetValidFreepointers( )
  138090             :    {
  138091           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  138092           5 :      SgUpirLoopStatement* pointer = NULL;
  138093           5 :      std::vector < unsigned char* > :: const_iterator block;
  138094           5 :      SgUpirLoopStatement* pointerOfLinkedList = NULL;
  138095           5 :      for ( block = SgUpirLoopStatement::pools.begin(); block != SgUpirLoopStatement::pools.end() ; ++block )
  138096             :         {
  138097           0 :           pointer = (SgUpirLoopStatement*)(*block);
  138098           0 :           for (unsigned i = 0; i < SgUpirLoopStatement::pool_size; ++i )
  138099             :              {
  138100             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  138101             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  138102             :             // memory blocks!.
  138103           0 :                if ( pointer[i].get_freepointer() != NULL )
  138104             :                   {
  138105           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  138106             :                   }
  138107             :                else
  138108             :                   {
  138109           0 :                     if ( pointerOfLinkedList == NULL )
  138110             :                        {
  138111           0 :                          SgUpirLoopStatement::next_node = &(pointer[i]);
  138112             :                        }
  138113             :                     else
  138114             :                        {
  138115             :                       // printf ("In SgUpirLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  138116           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  138117             :                        }
  138118             :                     pointerOfLinkedList = &(pointer[i]);
  138119             :                   }
  138120             :               }
  138121             :         }
  138122             : 
  138123           5 :      if ( pointerOfLinkedList != NULL )
  138124             :         {
  138125             :        // printf ("In SgUpirLoopStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  138126           0 :           pointerOfLinkedList->set_freepointer(NULL);
  138127             :        // DQ (6/6/2010): Temporary debugging...
  138128             :        //   ROSE_ASSERT(false);
  138129             :         }
  138130             : 
  138131           5 :      return ;
  138132             :    }
  138133             : 
  138134             : //############################################################################
  138135             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  138136             :  * within the memory pool and resets the freepointers, in order to achieve a 
  138137             :  * linked list, that has no jumps and starts at the beginning! This function 
  138138             :  * does not extend the memory pool, since we do not delete any memory blocks,
  138139             :  * but delete the valid objects.  
  138140             :  */
  138141             : void
  138142           0 : SgUpirLoopStatement::clearMemoryPool( )
  138143             :    {
  138144             :   // printf ("Inside of SgUpirLoopStatement::clearMemoryPool() \n");
  138145             : 
  138146           0 :      SgUpirLoopStatement* pointer = NULL, *tempPointer = NULL;
  138147           0 :      std::vector < unsigned char* > :: const_iterator block;
  138148           0 :      if ( SgUpirLoopStatement::pools.empty() == false )
  138149             :         {
  138150           0 :           block = SgUpirLoopStatement::pools.begin() ;
  138151           0 :           SgUpirLoopStatement::next_node = (SgUpirLoopStatement*) (*block);
  138152             : 
  138153           0 :           while ( block != SgUpirLoopStatement::pools.end() )
  138154             :              {
  138155           0 :                pointer = (SgUpirLoopStatement*) (*block);
  138156           0 :                if ( tempPointer != NULL )
  138157             :                   {
  138158           0 :                     tempPointer->set_freepointer(pointer);
  138159             :                   }
  138160           0 :                for (unsigned i = 0; i < SgUpirLoopStatement::pool_size - 1; ++i)
  138161             :                   {
  138162           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  138163             :                   }
  138164           0 :                 pointer[SgUpirLoopStatement::pool_size-1].set_freepointer(NULL);
  138165           0 :                 tempPointer = &(pointer[SgUpirLoopStatement::pool_size-1]);
  138166           0 :                 ++block;
  138167             :              }
  138168             :         }
  138169           0 :    }
  138170             : 
  138171           5 : void SgUpirLoopStatement::deleteMemoryPool() {
  138172           5 :   for (auto p: SgUpirLoopStatement::pools) {
  138173           0 :     ROSE_FREE(p);
  138174             :   }
  138175           5 :   SgUpirLoopStatement::next_node = nullptr;
  138176           5 :   SgUpirLoopStatement::pools.clear();
  138177           5 : }
  138178             : 
  138179             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  138180             : //                 reading multiple binary files to for a single AST.
  138181             : /////////// new version ////////////////////////////////
  138182             : //############################################################################
  138183             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  138184             : void
  138185           2 : SgUpirLoopStatement::extendMemoryPoolForFileIO( )
  138186             :   {
  138187           2 :     size_t blockIndex = SgUpirLoopStatement::pools.size();
  138188           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirLoopStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirLoopStatement);
  138189             : 
  138190           2 :     while ( (blockIndex * SgUpirLoopStatement::pool_size) < newPoolSize)
  138191             :       {
  138192             : #if ROSE_ALLOC_TRACE
  138193             :         if (blockIndex > 0) {
  138194             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirLoopStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirLoopStatement) = %" PRIuPTR " SgUpirLoopStatement::pool_size = %d \n",
  138195             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirLoopStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirLoopStatement),SgUpirLoopStatement::pool_size);
  138196             :         }
  138197             : #endif
  138198             : 
  138199           0 :         SgUpirLoopStatement * pointer = (SgUpirLoopStatement*) ROSE_MALLOC ( SgUpirLoopStatement::pool_size * sizeof(SgUpirLoopStatement) );
  138200           0 :         assert( pointer != NULL );
  138201             : #if ROSE_ALLOC_MEMSET == 1
  138202             :         memset(pointer, 0x00, SgUpirLoopStatement::pool_size * sizeof(SgUpirLoopStatement));
  138203             : #elif ROSE_ALLOC_MEMSET == 2
  138204             :         memset(pointer, 0xCC, SgUpirLoopStatement::pool_size * sizeof(SgUpirLoopStatement));
  138205             : #endif
  138206           0 :         SgUpirLoopStatement::pools.push_back( (unsigned char*)(pointer) );
  138207           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirLoopStatement::pool_size * sizeof(SgUpirLoopStatement), V_SgUpirLoopStatement ) );
  138208             : 
  138209           0 :         if ( SgUpirLoopStatement::next_node != NULL ) {
  138210           0 :           if ( blockIndex > 0 ) {
  138211           0 :             SgUpirLoopStatement * blkptr = (SgUpirLoopStatement*)(SgUpirLoopStatement::pools[blockIndex-1]);
  138212           0 :             blkptr[ SgUpirLoopStatement::pool_size - 1 ].set_freepointer(pointer);
  138213             :           }
  138214             :         } else {
  138215           0 :           SgUpirLoopStatement::next_node = pointer;
  138216             :         }
  138217             : 
  138218           0 :         for (unsigned i = 0; i < SgUpirLoopStatement::pool_size-1; ++i)
  138219             :            {
  138220           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  138221             :            }
  138222           0 :         pointer[ SgUpirLoopStatement::pool_size -1 ].set_freepointer(NULL);
  138223             : 
  138224           0 :         blockIndex++;
  138225             :       }
  138226           2 :   }
  138227             : 
  138228             : //############################################################################
  138229             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  138230             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  138231             :  * not compressed. However, that stuff is not yet implemented! 
  138232             :  */
  138233             : unsigned long
  138234           0 : SgUpirLoopStatement::getNumberOfLastValidPointer()
  138235             :    {
  138236           0 :       SgUpirLoopStatement* testPointer = (SgUpirLoopStatement*)(SgUpirLoopStatement::pools.back());
  138237           0 :       unsigned long localIndex = SgUpirLoopStatement::pool_size - 1;
  138238           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  138239             :          {
  138240           0 :            localIndex--;
  138241             :          }
  138242           0 :       return (localIndex + SgUpirLoopStatement::pool_size * (SgUpirLoopStatement::pools.size()-1));
  138243             :    }
  138244             : 
  138245             : //############################################################################
  138246             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  138247             :  * memory pool and initializes the data member in class SgUpirLoopStatementStroageClass
  138248             :  * from its counterpart of SgUpirLoopStatement. The return value is just for checking, 
  138249             :  * that the whole StorageClassArray is initialized!
  138250             :  */
  138251             : unsigned long
  138252           0 : SgUpirLoopStatement::initializeStorageClassArray( SgUpirLoopStatementStorageClass *storageArray )
  138253             :    {
  138254           0 :      unsigned long storageCounter = 0;
  138255           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirLoopStatement::pools.begin();
  138256           0 :      SgUpirLoopStatement* pointer = NULL;
  138257           0 :      while ( block != SgUpirLoopStatement::pools.end() ) {
  138258           0 :           pointer = (SgUpirLoopStatement*) (*block);
  138259           0 :           for ( unsigned i = 0; i < SgUpirLoopStatement::pool_size; ++i ) {
  138260           0 :                if ( pointer->get_freepointer() != NULL ) {
  138261           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  138262           0 :                  storageArray++;
  138263           0 :                  storageCounter++;
  138264             :                }
  138265           0 :                pointer++;
  138266             :              }
  138267           0 :            block++;
  138268             :         }
  138269           0 :      return storageCounter;
  138270             :    }
  138271             : 
  138272             : /* #line 138273 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  138273             : 
  138274             : 
  138275             : 
  138276             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  138277             : 
  138278             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  138279             : 
  138280             : //############################################################################
  138281             : /* JH (02/02/2006) Constructor of the IR node SgUpirFieldStatement that takes its 
  138282             :  * corresponding StorageClass as parameter
  138283             :  */
  138284           0 : SgUpirFieldStatement :: SgUpirFieldStatement ( const SgUpirFieldStatementStorageClass& storageSource )   : SgUpirBaseStatement (storageSource)
  138285             :    {
  138286             : 
  138287             : 
  138288             : /* #line 138289 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  138289             : 
  138290           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  138291           0 :      p_clauses = storageSource.storageOf_clauses.rebuildDataStoredInEasyStorageClass() ;
  138292           0 :      SgOmpClausePtrList::iterator i_clauses = p_clauses.begin() ; 
  138293           0 :      for ( ; i_clauses != p_clauses.end(); ++i_clauses ) 
  138294             :         {
  138295           0 :           (*i_clauses) = (SgOmpClausePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_clauses) ) );
  138296             :         }
  138297             : 
  138298             : 
  138299             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  138300             : 
  138301             : 
  138302           0 :    }
  138303             : 
  138304             : //############################################################################
  138305             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  138306             :  * within the working AST. 
  138307             :  */
  138308           0 : SgUpirFieldStatement * SgUpirFieldStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  138309           0 :      SgUpirFieldStatement* returnPointer = NULL;
  138310           0 :      if ( globalIndex != 0 )
  138311             :         {
  138312             : 
  138313             : #if FILE_IO_EXTRA_CHECK
  138314           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirFieldStatement ) ) <= globalIndex ) ;
  138315           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirFieldStatement + 1 ) ) );
  138316             : #endif
  138317           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirFieldStatement )  
  138318           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirFieldStatement );
  138319           0 :           unsigned long positionInPool = localIndex % SgUpirFieldStatement::pool_size;
  138320           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirFieldStatement::pool_size;
  138321             : 
  138322             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  138323             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  138324             : 
  138325           0 :           returnPointer = &( ( (SgUpirFieldStatement*)(SgUpirFieldStatement::pools[memoryBlock]) ) [positionInPool]) ;
  138326             : 
  138327           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  138328             :         }
  138329           0 :      return returnPointer ;
  138330             :    }
  138331             : 
  138332             : //############################################################################
  138333             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  138334             :   for the AST with the index astIndex
  138335             : */
  138336           0 : SgUpirFieldStatement * SgUpirFieldStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  138337           0 :      SgUpirFieldStatement* returnPointer = NULL;
  138338           0 :      if ( globalIndex != 0 )
  138339             :         {
  138340             : 
  138341             : #if FILE_IO_EXTRA_CHECK
  138342           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirFieldStatement ) ) <= globalIndex ) ;
  138343           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirFieldStatement + 1 ) ) );
  138344             : #endif
  138345           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirFieldStatement )
  138346           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirFieldStatement );
  138347           0 :           unsigned long positionInPool = localIndex % SgUpirFieldStatement::pool_size ;
  138348           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirFieldStatement::pool_size ;
  138349             : 
  138350             : #if FILE_IO_EXTRA_CHECK
  138351             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  138352             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  138353             : #endif
  138354             : 
  138355           0 :           returnPointer = &( ( (SgUpirFieldStatement*)(SgUpirFieldStatement::pools[memoryBlock]) ) [positionInPool]) ;
  138356             : 
  138357             : #if FILE_IO_EXTRA_CHECK
  138358           0 :           assert ( returnPointer != NULL ) ;
  138359             : #endif
  138360             :         }
  138361           0 :      return returnPointer ;
  138362             :    }
  138363             : 
  138364             : //############################################################################
  138365             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  138366             :  * pool size! We set for every valid object in the memory pool the freepointer
  138367             :  * to the global index and increase the global index afterwards. For all the 
  138368             :  * invalid objects (means address ranges within the memory pool that were not
  138369             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  138370             :  * distinguish valid from invalid objects! 
  138371             :  */
  138372             : unsigned long
  138373           5 : SgUpirFieldStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  138374             :    {
  138375           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  138376           5 :      SgUpirFieldStatement* pointer = NULL;
  138377           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  138378           5 :      std::vector < unsigned char* > :: const_iterator block;
  138379           5 :      for ( block = SgUpirFieldStatement::pools.begin(); block != SgUpirFieldStatement::pools.end() ; ++block )
  138380             :         {
  138381           0 :           pointer = (SgUpirFieldStatement*)(*block);
  138382           0 :           for (unsigned i = 0; i < SgUpirFieldStatement::pool_size; ++i )
  138383             :              {
  138384             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  138385             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  138386             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  138387             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  138388             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  138389             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  138390             :             // properly; so this will have to be checked next.
  138391             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  138392             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  138393           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  138394             :                   {
  138395           0 :                     pointer[i].set_freepointer((SgUpirFieldStatement*)(globalIndex));
  138396           0 :                     globalIndex++;
  138397             :                   }
  138398             :                else
  138399             :                   {
  138400           0 :                     pointer[i].set_freepointer(NULL);
  138401             :                   }
  138402             :               }
  138403             :         }
  138404           5 :      return globalIndex;
  138405             :    }
  138406             : 
  138407             : //############################################################################
  138408             : // JH (01/14/2006)
  138409             : void
  138410           5 : SgUpirFieldStatement::resetValidFreepointers( )
  138411             :    {
  138412           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  138413           5 :      SgUpirFieldStatement* pointer = NULL;
  138414           5 :      std::vector < unsigned char* > :: const_iterator block;
  138415           5 :      SgUpirFieldStatement* pointerOfLinkedList = NULL;
  138416           5 :      for ( block = SgUpirFieldStatement::pools.begin(); block != SgUpirFieldStatement::pools.end() ; ++block )
  138417             :         {
  138418           0 :           pointer = (SgUpirFieldStatement*)(*block);
  138419           0 :           for (unsigned i = 0; i < SgUpirFieldStatement::pool_size; ++i )
  138420             :              {
  138421             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  138422             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  138423             :             // memory blocks!.
  138424           0 :                if ( pointer[i].get_freepointer() != NULL )
  138425             :                   {
  138426           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  138427             :                   }
  138428             :                else
  138429             :                   {
  138430           0 :                     if ( pointerOfLinkedList == NULL )
  138431             :                        {
  138432           0 :                          SgUpirFieldStatement::next_node = &(pointer[i]);
  138433             :                        }
  138434             :                     else
  138435             :                        {
  138436             :                       // printf ("In SgUpirFieldStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  138437           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  138438             :                        }
  138439             :                     pointerOfLinkedList = &(pointer[i]);
  138440             :                   }
  138441             :               }
  138442             :         }
  138443             : 
  138444           5 :      if ( pointerOfLinkedList != NULL )
  138445             :         {
  138446             :        // printf ("In SgUpirFieldStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  138447           0 :           pointerOfLinkedList->set_freepointer(NULL);
  138448             :        // DQ (6/6/2010): Temporary debugging...
  138449             :        //   ROSE_ASSERT(false);
  138450             :         }
  138451             : 
  138452           5 :      return ;
  138453             :    }
  138454             : 
  138455             : //############################################################################
  138456             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  138457             :  * within the memory pool and resets the freepointers, in order to achieve a 
  138458             :  * linked list, that has no jumps and starts at the beginning! This function 
  138459             :  * does not extend the memory pool, since we do not delete any memory blocks,
  138460             :  * but delete the valid objects.  
  138461             :  */
  138462             : void
  138463           0 : SgUpirFieldStatement::clearMemoryPool( )
  138464             :    {
  138465             :   // printf ("Inside of SgUpirFieldStatement::clearMemoryPool() \n");
  138466             : 
  138467           0 :      SgUpirFieldStatement* pointer = NULL, *tempPointer = NULL;
  138468           0 :      std::vector < unsigned char* > :: const_iterator block;
  138469           0 :      if ( SgUpirFieldStatement::pools.empty() == false )
  138470             :         {
  138471           0 :           block = SgUpirFieldStatement::pools.begin() ;
  138472           0 :           SgUpirFieldStatement::next_node = (SgUpirFieldStatement*) (*block);
  138473             : 
  138474           0 :           while ( block != SgUpirFieldStatement::pools.end() )
  138475             :              {
  138476           0 :                pointer = (SgUpirFieldStatement*) (*block);
  138477           0 :                if ( tempPointer != NULL )
  138478             :                   {
  138479           0 :                     tempPointer->set_freepointer(pointer);
  138480             :                   }
  138481           0 :                for (unsigned i = 0; i < SgUpirFieldStatement::pool_size - 1; ++i)
  138482             :                   {
  138483           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  138484             :                   }
  138485           0 :                 pointer[SgUpirFieldStatement::pool_size-1].set_freepointer(NULL);
  138486           0 :                 tempPointer = &(pointer[SgUpirFieldStatement::pool_size-1]);
  138487           0 :                 ++block;
  138488             :              }
  138489             :         }
  138490           0 :    }
  138491             : 
  138492           5 : void SgUpirFieldStatement::deleteMemoryPool() {
  138493           5 :   for (auto p: SgUpirFieldStatement::pools) {
  138494           0 :     ROSE_FREE(p);
  138495             :   }
  138496           5 :   SgUpirFieldStatement::next_node = nullptr;
  138497           5 :   SgUpirFieldStatement::pools.clear();
  138498           5 : }
  138499             : 
  138500             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  138501             : //                 reading multiple binary files to for a single AST.
  138502             : /////////// new version ////////////////////////////////
  138503             : //############################################################################
  138504             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  138505             : void
  138506           2 : SgUpirFieldStatement::extendMemoryPoolForFileIO( )
  138507             :   {
  138508           2 :     size_t blockIndex = SgUpirFieldStatement::pools.size();
  138509           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirFieldStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirFieldStatement);
  138510             : 
  138511           2 :     while ( (blockIndex * SgUpirFieldStatement::pool_size) < newPoolSize)
  138512             :       {
  138513             : #if ROSE_ALLOC_TRACE
  138514             :         if (blockIndex > 0) {
  138515             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirFieldStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirFieldStatement) = %" PRIuPTR " SgUpirFieldStatement::pool_size = %d \n",
  138516             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirFieldStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirFieldStatement),SgUpirFieldStatement::pool_size);
  138517             :         }
  138518             : #endif
  138519             : 
  138520           0 :         SgUpirFieldStatement * pointer = (SgUpirFieldStatement*) ROSE_MALLOC ( SgUpirFieldStatement::pool_size * sizeof(SgUpirFieldStatement) );
  138521           0 :         assert( pointer != NULL );
  138522             : #if ROSE_ALLOC_MEMSET == 1
  138523             :         memset(pointer, 0x00, SgUpirFieldStatement::pool_size * sizeof(SgUpirFieldStatement));
  138524             : #elif ROSE_ALLOC_MEMSET == 2
  138525             :         memset(pointer, 0xCC, SgUpirFieldStatement::pool_size * sizeof(SgUpirFieldStatement));
  138526             : #endif
  138527           0 :         SgUpirFieldStatement::pools.push_back( (unsigned char*)(pointer) );
  138528           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirFieldStatement::pool_size * sizeof(SgUpirFieldStatement), V_SgUpirFieldStatement ) );
  138529             : 
  138530           0 :         if ( SgUpirFieldStatement::next_node != NULL ) {
  138531           0 :           if ( blockIndex > 0 ) {
  138532           0 :             SgUpirFieldStatement * blkptr = (SgUpirFieldStatement*)(SgUpirFieldStatement::pools[blockIndex-1]);
  138533           0 :             blkptr[ SgUpirFieldStatement::pool_size - 1 ].set_freepointer(pointer);
  138534             :           }
  138535             :         } else {
  138536           0 :           SgUpirFieldStatement::next_node = pointer;
  138537             :         }
  138538             : 
  138539           0 :         for (unsigned i = 0; i < SgUpirFieldStatement::pool_size-1; ++i)
  138540             :            {
  138541           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  138542             :            }
  138543           0 :         pointer[ SgUpirFieldStatement::pool_size -1 ].set_freepointer(NULL);
  138544             : 
  138545           0 :         blockIndex++;
  138546             :       }
  138547           2 :   }
  138548             : 
  138549             : //############################################################################
  138550             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  138551             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  138552             :  * not compressed. However, that stuff is not yet implemented! 
  138553             :  */
  138554             : unsigned long
  138555           0 : SgUpirFieldStatement::getNumberOfLastValidPointer()
  138556             :    {
  138557           0 :       SgUpirFieldStatement* testPointer = (SgUpirFieldStatement*)(SgUpirFieldStatement::pools.back());
  138558           0 :       unsigned long localIndex = SgUpirFieldStatement::pool_size - 1;
  138559           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  138560             :          {
  138561           0 :            localIndex--;
  138562             :          }
  138563           0 :       return (localIndex + SgUpirFieldStatement::pool_size * (SgUpirFieldStatement::pools.size()-1));
  138564             :    }
  138565             : 
  138566             : //############################################################################
  138567             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  138568             :  * memory pool and initializes the data member in class SgUpirFieldStatementStroageClass
  138569             :  * from its counterpart of SgUpirFieldStatement. The return value is just for checking, 
  138570             :  * that the whole StorageClassArray is initialized!
  138571             :  */
  138572             : unsigned long
  138573           0 : SgUpirFieldStatement::initializeStorageClassArray( SgUpirFieldStatementStorageClass *storageArray )
  138574             :    {
  138575           0 :      unsigned long storageCounter = 0;
  138576           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirFieldStatement::pools.begin();
  138577           0 :      SgUpirFieldStatement* pointer = NULL;
  138578           0 :      while ( block != SgUpirFieldStatement::pools.end() ) {
  138579           0 :           pointer = (SgUpirFieldStatement*) (*block);
  138580           0 :           for ( unsigned i = 0; i < SgUpirFieldStatement::pool_size; ++i ) {
  138581           0 :                if ( pointer->get_freepointer() != NULL ) {
  138582           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  138583           0 :                  storageArray++;
  138584           0 :                  storageCounter++;
  138585             :                }
  138586           0 :                pointer++;
  138587             :              }
  138588           0 :            block++;
  138589             :         }
  138590           0 :      return storageCounter;
  138591             :    }
  138592             : 
  138593             : /* #line 138594 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  138594             : 
  138595             : 
  138596             : 
  138597             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  138598             : 
  138599             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  138600             : 
  138601             : //############################################################################
  138602             : /* JH (02/02/2006) Constructor of the IR node SgOmpCancelStatement that takes its 
  138603             :  * corresponding StorageClass as parameter
  138604             :  */
  138605           0 : SgOmpCancelStatement :: SgOmpCancelStatement ( const SgOmpCancelStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  138606             :    {
  138607             : 
  138608             : 
  138609             : /* #line 138610 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  138610             : 
  138611           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  138612             : 
  138613             : 
  138614             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  138615             : 
  138616             : 
  138617           0 :    }
  138618             : 
  138619             : //############################################################################
  138620             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  138621             :  * within the working AST. 
  138622             :  */
  138623           0 : SgOmpCancelStatement * SgOmpCancelStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  138624           0 :      SgOmpCancelStatement* returnPointer = NULL;
  138625           0 :      if ( globalIndex != 0 )
  138626             :         {
  138627             : 
  138628             : #if FILE_IO_EXTRA_CHECK
  138629           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpCancelStatement ) ) <= globalIndex ) ;
  138630           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCancelStatement + 1 ) ) );
  138631             : #endif
  138632           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCancelStatement )  
  138633           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpCancelStatement );
  138634           0 :           unsigned long positionInPool = localIndex % SgOmpCancelStatement::pool_size;
  138635           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCancelStatement::pool_size;
  138636             : 
  138637             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  138638             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  138639             : 
  138640           0 :           returnPointer = &( ( (SgOmpCancelStatement*)(SgOmpCancelStatement::pools[memoryBlock]) ) [positionInPool]) ;
  138641             : 
  138642           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  138643             :         }
  138644           0 :      return returnPointer ;
  138645             :    }
  138646             : 
  138647             : //############################################################################
  138648             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  138649             :   for the AST with the index astIndex
  138650             : */
  138651           0 : SgOmpCancelStatement * SgOmpCancelStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  138652           0 :      SgOmpCancelStatement* returnPointer = NULL;
  138653           0 :      if ( globalIndex != 0 )
  138654             :         {
  138655             : 
  138656             : #if FILE_IO_EXTRA_CHECK
  138657           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpCancelStatement ) ) <= globalIndex ) ;
  138658           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCancelStatement + 1 ) ) );
  138659             : #endif
  138660           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCancelStatement )
  138661           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpCancelStatement );
  138662           0 :           unsigned long positionInPool = localIndex % SgOmpCancelStatement::pool_size ;
  138663           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCancelStatement::pool_size ;
  138664             : 
  138665             : #if FILE_IO_EXTRA_CHECK
  138666             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  138667             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  138668             : #endif
  138669             : 
  138670           0 :           returnPointer = &( ( (SgOmpCancelStatement*)(SgOmpCancelStatement::pools[memoryBlock]) ) [positionInPool]) ;
  138671             : 
  138672             : #if FILE_IO_EXTRA_CHECK
  138673           0 :           assert ( returnPointer != NULL ) ;
  138674             : #endif
  138675             :         }
  138676           0 :      return returnPointer ;
  138677             :    }
  138678             : 
  138679             : //############################################################################
  138680             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  138681             :  * pool size! We set for every valid object in the memory pool the freepointer
  138682             :  * to the global index and increase the global index afterwards. For all the 
  138683             :  * invalid objects (means address ranges within the memory pool that were not
  138684             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  138685             :  * distinguish valid from invalid objects! 
  138686             :  */
  138687             : unsigned long
  138688           5 : SgOmpCancelStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  138689             :    {
  138690           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  138691           5 :      SgOmpCancelStatement* pointer = NULL;
  138692           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  138693           5 :      std::vector < unsigned char* > :: const_iterator block;
  138694           5 :      for ( block = SgOmpCancelStatement::pools.begin(); block != SgOmpCancelStatement::pools.end() ; ++block )
  138695             :         {
  138696           0 :           pointer = (SgOmpCancelStatement*)(*block);
  138697           0 :           for (unsigned i = 0; i < SgOmpCancelStatement::pool_size; ++i )
  138698             :              {
  138699             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  138700             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  138701             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  138702             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  138703             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  138704             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  138705             :             // properly; so this will have to be checked next.
  138706             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  138707             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  138708           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  138709             :                   {
  138710           0 :                     pointer[i].set_freepointer((SgOmpCancelStatement*)(globalIndex));
  138711           0 :                     globalIndex++;
  138712             :                   }
  138713             :                else
  138714             :                   {
  138715           0 :                     pointer[i].set_freepointer(NULL);
  138716             :                   }
  138717             :               }
  138718             :         }
  138719           5 :      return globalIndex;
  138720             :    }
  138721             : 
  138722             : //############################################################################
  138723             : // JH (01/14/2006)
  138724             : void
  138725           5 : SgOmpCancelStatement::resetValidFreepointers( )
  138726             :    {
  138727           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  138728           5 :      SgOmpCancelStatement* pointer = NULL;
  138729           5 :      std::vector < unsigned char* > :: const_iterator block;
  138730           5 :      SgOmpCancelStatement* pointerOfLinkedList = NULL;
  138731           5 :      for ( block = SgOmpCancelStatement::pools.begin(); block != SgOmpCancelStatement::pools.end() ; ++block )
  138732             :         {
  138733           0 :           pointer = (SgOmpCancelStatement*)(*block);
  138734           0 :           for (unsigned i = 0; i < SgOmpCancelStatement::pool_size; ++i )
  138735             :              {
  138736             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  138737             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  138738             :             // memory blocks!.
  138739           0 :                if ( pointer[i].get_freepointer() != NULL )
  138740             :                   {
  138741           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  138742             :                   }
  138743             :                else
  138744             :                   {
  138745           0 :                     if ( pointerOfLinkedList == NULL )
  138746             :                        {
  138747           0 :                          SgOmpCancelStatement::next_node = &(pointer[i]);
  138748             :                        }
  138749             :                     else
  138750             :                        {
  138751             :                       // printf ("In SgOmpCancelStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  138752           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  138753             :                        }
  138754             :                     pointerOfLinkedList = &(pointer[i]);
  138755             :                   }
  138756             :               }
  138757             :         }
  138758             : 
  138759           5 :      if ( pointerOfLinkedList != NULL )
  138760             :         {
  138761             :        // printf ("In SgOmpCancelStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  138762           0 :           pointerOfLinkedList->set_freepointer(NULL);
  138763             :        // DQ (6/6/2010): Temporary debugging...
  138764             :        //   ROSE_ASSERT(false);
  138765             :         }
  138766             : 
  138767           5 :      return ;
  138768             :    }
  138769             : 
  138770             : //############################################################################
  138771             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  138772             :  * within the memory pool and resets the freepointers, in order to achieve a 
  138773             :  * linked list, that has no jumps and starts at the beginning! This function 
  138774             :  * does not extend the memory pool, since we do not delete any memory blocks,
  138775             :  * but delete the valid objects.  
  138776             :  */
  138777             : void
  138778           0 : SgOmpCancelStatement::clearMemoryPool( )
  138779             :    {
  138780             :   // printf ("Inside of SgOmpCancelStatement::clearMemoryPool() \n");
  138781             : 
  138782           0 :      SgOmpCancelStatement* pointer = NULL, *tempPointer = NULL;
  138783           0 :      std::vector < unsigned char* > :: const_iterator block;
  138784           0 :      if ( SgOmpCancelStatement::pools.empty() == false )
  138785             :         {
  138786           0 :           block = SgOmpCancelStatement::pools.begin() ;
  138787           0 :           SgOmpCancelStatement::next_node = (SgOmpCancelStatement*) (*block);
  138788             : 
  138789           0 :           while ( block != SgOmpCancelStatement::pools.end() )
  138790             :              {
  138791           0 :                pointer = (SgOmpCancelStatement*) (*block);
  138792           0 :                if ( tempPointer != NULL )
  138793             :                   {
  138794           0 :                     tempPointer->set_freepointer(pointer);
  138795             :                   }
  138796           0 :                for (unsigned i = 0; i < SgOmpCancelStatement::pool_size - 1; ++i)
  138797             :                   {
  138798           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  138799             :                   }
  138800           0 :                 pointer[SgOmpCancelStatement::pool_size-1].set_freepointer(NULL);
  138801           0 :                 tempPointer = &(pointer[SgOmpCancelStatement::pool_size-1]);
  138802           0 :                 ++block;
  138803             :              }
  138804             :         }
  138805           0 :    }
  138806             : 
  138807           5 : void SgOmpCancelStatement::deleteMemoryPool() {
  138808           5 :   for (auto p: SgOmpCancelStatement::pools) {
  138809           0 :     ROSE_FREE(p);
  138810             :   }
  138811           5 :   SgOmpCancelStatement::next_node = nullptr;
  138812           5 :   SgOmpCancelStatement::pools.clear();
  138813           5 : }
  138814             : 
  138815             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  138816             : //                 reading multiple binary files to for a single AST.
  138817             : /////////// new version ////////////////////////////////
  138818             : //############################################################################
  138819             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  138820             : void
  138821           2 : SgOmpCancelStatement::extendMemoryPoolForFileIO( )
  138822             :   {
  138823           2 :     size_t blockIndex = SgOmpCancelStatement::pools.size();
  138824           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCancelStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCancelStatement);
  138825             : 
  138826           2 :     while ( (blockIndex * SgOmpCancelStatement::pool_size) < newPoolSize)
  138827             :       {
  138828             : #if ROSE_ALLOC_TRACE
  138829             :         if (blockIndex > 0) {
  138830             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCancelStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCancelStatement) = %" PRIuPTR " SgOmpCancelStatement::pool_size = %d \n",
  138831             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCancelStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCancelStatement),SgOmpCancelStatement::pool_size);
  138832             :         }
  138833             : #endif
  138834             : 
  138835           0 :         SgOmpCancelStatement * pointer = (SgOmpCancelStatement*) ROSE_MALLOC ( SgOmpCancelStatement::pool_size * sizeof(SgOmpCancelStatement) );
  138836           0 :         assert( pointer != NULL );
  138837             : #if ROSE_ALLOC_MEMSET == 1
  138838             :         memset(pointer, 0x00, SgOmpCancelStatement::pool_size * sizeof(SgOmpCancelStatement));
  138839             : #elif ROSE_ALLOC_MEMSET == 2
  138840             :         memset(pointer, 0xCC, SgOmpCancelStatement::pool_size * sizeof(SgOmpCancelStatement));
  138841             : #endif
  138842           0 :         SgOmpCancelStatement::pools.push_back( (unsigned char*)(pointer) );
  138843           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpCancelStatement::pool_size * sizeof(SgOmpCancelStatement), V_SgOmpCancelStatement ) );
  138844             : 
  138845           0 :         if ( SgOmpCancelStatement::next_node != NULL ) {
  138846           0 :           if ( blockIndex > 0 ) {
  138847           0 :             SgOmpCancelStatement * blkptr = (SgOmpCancelStatement*)(SgOmpCancelStatement::pools[blockIndex-1]);
  138848           0 :             blkptr[ SgOmpCancelStatement::pool_size - 1 ].set_freepointer(pointer);
  138849             :           }
  138850             :         } else {
  138851           0 :           SgOmpCancelStatement::next_node = pointer;
  138852             :         }
  138853             : 
  138854           0 :         for (unsigned i = 0; i < SgOmpCancelStatement::pool_size-1; ++i)
  138855             :            {
  138856           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  138857             :            }
  138858           0 :         pointer[ SgOmpCancelStatement::pool_size -1 ].set_freepointer(NULL);
  138859             : 
  138860           0 :         blockIndex++;
  138861             :       }
  138862           2 :   }
  138863             : 
  138864             : //############################################################################
  138865             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  138866             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  138867             :  * not compressed. However, that stuff is not yet implemented! 
  138868             :  */
  138869             : unsigned long
  138870           0 : SgOmpCancelStatement::getNumberOfLastValidPointer()
  138871             :    {
  138872           0 :       SgOmpCancelStatement* testPointer = (SgOmpCancelStatement*)(SgOmpCancelStatement::pools.back());
  138873           0 :       unsigned long localIndex = SgOmpCancelStatement::pool_size - 1;
  138874           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  138875             :          {
  138876           0 :            localIndex--;
  138877             :          }
  138878           0 :       return (localIndex + SgOmpCancelStatement::pool_size * (SgOmpCancelStatement::pools.size()-1));
  138879             :    }
  138880             : 
  138881             : //############################################################################
  138882             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  138883             :  * memory pool and initializes the data member in class SgOmpCancelStatementStroageClass
  138884             :  * from its counterpart of SgOmpCancelStatement. The return value is just for checking, 
  138885             :  * that the whole StorageClassArray is initialized!
  138886             :  */
  138887             : unsigned long
  138888           0 : SgOmpCancelStatement::initializeStorageClassArray( SgOmpCancelStatementStorageClass *storageArray )
  138889             :    {
  138890           0 :      unsigned long storageCounter = 0;
  138891           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpCancelStatement::pools.begin();
  138892           0 :      SgOmpCancelStatement* pointer = NULL;
  138893           0 :      while ( block != SgOmpCancelStatement::pools.end() ) {
  138894           0 :           pointer = (SgOmpCancelStatement*) (*block);
  138895           0 :           for ( unsigned i = 0; i < SgOmpCancelStatement::pool_size; ++i ) {
  138896           0 :                if ( pointer->get_freepointer() != NULL ) {
  138897           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  138898           0 :                  storageArray++;
  138899           0 :                  storageCounter++;
  138900             :                }
  138901           0 :                pointer++;
  138902             :              }
  138903           0 :            block++;
  138904             :         }
  138905           0 :      return storageCounter;
  138906             :    }
  138907             : 
  138908             : /* #line 138909 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  138909             : 
  138910             : 
  138911             : 
  138912             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  138913             : 
  138914             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  138915             : 
  138916             : //############################################################################
  138917             : /* JH (02/02/2006) Constructor of the IR node SgOmpCancellationPointStatement that takes its 
  138918             :  * corresponding StorageClass as parameter
  138919             :  */
  138920           0 : SgOmpCancellationPointStatement :: SgOmpCancellationPointStatement ( const SgOmpCancellationPointStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  138921             :    {
  138922             : 
  138923             : 
  138924             : /* #line 138925 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  138925             : 
  138926           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  138927             : 
  138928             : 
  138929             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  138930             : 
  138931             : 
  138932           0 :    }
  138933             : 
  138934             : //############################################################################
  138935             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  138936             :  * within the working AST. 
  138937             :  */
  138938           0 : SgOmpCancellationPointStatement * SgOmpCancellationPointStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  138939           0 :      SgOmpCancellationPointStatement* returnPointer = NULL;
  138940           0 :      if ( globalIndex != 0 )
  138941             :         {
  138942             : 
  138943             : #if FILE_IO_EXTRA_CHECK
  138944           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpCancellationPointStatement ) ) <= globalIndex ) ;
  138945           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCancellationPointStatement + 1 ) ) );
  138946             : #endif
  138947           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpCancellationPointStatement )  
  138948           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpCancellationPointStatement );
  138949           0 :           unsigned long positionInPool = localIndex % SgOmpCancellationPointStatement::pool_size;
  138950           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCancellationPointStatement::pool_size;
  138951             : 
  138952             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  138953             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  138954             : 
  138955           0 :           returnPointer = &( ( (SgOmpCancellationPointStatement*)(SgOmpCancellationPointStatement::pools[memoryBlock]) ) [positionInPool]) ;
  138956             : 
  138957           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  138958             :         }
  138959           0 :      return returnPointer ;
  138960             :    }
  138961             : 
  138962             : //############################################################################
  138963             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  138964             :   for the AST with the index astIndex
  138965             : */
  138966           0 : SgOmpCancellationPointStatement * SgOmpCancellationPointStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  138967           0 :      SgOmpCancellationPointStatement* returnPointer = NULL;
  138968           0 :      if ( globalIndex != 0 )
  138969             :         {
  138970             : 
  138971             : #if FILE_IO_EXTRA_CHECK
  138972           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpCancellationPointStatement ) ) <= globalIndex ) ;
  138973           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCancellationPointStatement + 1 ) ) );
  138974             : #endif
  138975           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpCancellationPointStatement )
  138976           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpCancellationPointStatement );
  138977           0 :           unsigned long positionInPool = localIndex % SgOmpCancellationPointStatement::pool_size ;
  138978           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpCancellationPointStatement::pool_size ;
  138979             : 
  138980             : #if FILE_IO_EXTRA_CHECK
  138981             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  138982             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  138983             : #endif
  138984             : 
  138985           0 :           returnPointer = &( ( (SgOmpCancellationPointStatement*)(SgOmpCancellationPointStatement::pools[memoryBlock]) ) [positionInPool]) ;
  138986             : 
  138987             : #if FILE_IO_EXTRA_CHECK
  138988           0 :           assert ( returnPointer != NULL ) ;
  138989             : #endif
  138990             :         }
  138991           0 :      return returnPointer ;
  138992             :    }
  138993             : 
  138994             : //############################################################################
  138995             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  138996             :  * pool size! We set for every valid object in the memory pool the freepointer
  138997             :  * to the global index and increase the global index afterwards. For all the 
  138998             :  * invalid objects (means address ranges within the memory pool that were not
  138999             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  139000             :  * distinguish valid from invalid objects! 
  139001             :  */
  139002             : unsigned long
  139003           5 : SgOmpCancellationPointStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  139004             :    {
  139005           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  139006           5 :      SgOmpCancellationPointStatement* pointer = NULL;
  139007           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  139008           5 :      std::vector < unsigned char* > :: const_iterator block;
  139009           5 :      for ( block = SgOmpCancellationPointStatement::pools.begin(); block != SgOmpCancellationPointStatement::pools.end() ; ++block )
  139010             :         {
  139011           0 :           pointer = (SgOmpCancellationPointStatement*)(*block);
  139012           0 :           for (unsigned i = 0; i < SgOmpCancellationPointStatement::pool_size; ++i )
  139013             :              {
  139014             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  139015             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  139016             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  139017             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  139018             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  139019             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  139020             :             // properly; so this will have to be checked next.
  139021             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  139022             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  139023           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  139024             :                   {
  139025           0 :                     pointer[i].set_freepointer((SgOmpCancellationPointStatement*)(globalIndex));
  139026           0 :                     globalIndex++;
  139027             :                   }
  139028             :                else
  139029             :                   {
  139030           0 :                     pointer[i].set_freepointer(NULL);
  139031             :                   }
  139032             :               }
  139033             :         }
  139034           5 :      return globalIndex;
  139035             :    }
  139036             : 
  139037             : //############################################################################
  139038             : // JH (01/14/2006)
  139039             : void
  139040           5 : SgOmpCancellationPointStatement::resetValidFreepointers( )
  139041             :    {
  139042           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  139043           5 :      SgOmpCancellationPointStatement* pointer = NULL;
  139044           5 :      std::vector < unsigned char* > :: const_iterator block;
  139045           5 :      SgOmpCancellationPointStatement* pointerOfLinkedList = NULL;
  139046           5 :      for ( block = SgOmpCancellationPointStatement::pools.begin(); block != SgOmpCancellationPointStatement::pools.end() ; ++block )
  139047             :         {
  139048           0 :           pointer = (SgOmpCancellationPointStatement*)(*block);
  139049           0 :           for (unsigned i = 0; i < SgOmpCancellationPointStatement::pool_size; ++i )
  139050             :              {
  139051             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  139052             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  139053             :             // memory blocks!.
  139054           0 :                if ( pointer[i].get_freepointer() != NULL )
  139055             :                   {
  139056           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  139057             :                   }
  139058             :                else
  139059             :                   {
  139060           0 :                     if ( pointerOfLinkedList == NULL )
  139061             :                        {
  139062           0 :                          SgOmpCancellationPointStatement::next_node = &(pointer[i]);
  139063             :                        }
  139064             :                     else
  139065             :                        {
  139066             :                       // printf ("In SgOmpCancellationPointStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  139067           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  139068             :                        }
  139069             :                     pointerOfLinkedList = &(pointer[i]);
  139070             :                   }
  139071             :               }
  139072             :         }
  139073             : 
  139074           5 :      if ( pointerOfLinkedList != NULL )
  139075             :         {
  139076             :        // printf ("In SgOmpCancellationPointStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  139077           0 :           pointerOfLinkedList->set_freepointer(NULL);
  139078             :        // DQ (6/6/2010): Temporary debugging...
  139079             :        //   ROSE_ASSERT(false);
  139080             :         }
  139081             : 
  139082           5 :      return ;
  139083             :    }
  139084             : 
  139085             : //############################################################################
  139086             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  139087             :  * within the memory pool and resets the freepointers, in order to achieve a 
  139088             :  * linked list, that has no jumps and starts at the beginning! This function 
  139089             :  * does not extend the memory pool, since we do not delete any memory blocks,
  139090             :  * but delete the valid objects.  
  139091             :  */
  139092             : void
  139093           0 : SgOmpCancellationPointStatement::clearMemoryPool( )
  139094             :    {
  139095             :   // printf ("Inside of SgOmpCancellationPointStatement::clearMemoryPool() \n");
  139096             : 
  139097           0 :      SgOmpCancellationPointStatement* pointer = NULL, *tempPointer = NULL;
  139098           0 :      std::vector < unsigned char* > :: const_iterator block;
  139099           0 :      if ( SgOmpCancellationPointStatement::pools.empty() == false )
  139100             :         {
  139101           0 :           block = SgOmpCancellationPointStatement::pools.begin() ;
  139102           0 :           SgOmpCancellationPointStatement::next_node = (SgOmpCancellationPointStatement*) (*block);
  139103             : 
  139104           0 :           while ( block != SgOmpCancellationPointStatement::pools.end() )
  139105             :              {
  139106           0 :                pointer = (SgOmpCancellationPointStatement*) (*block);
  139107           0 :                if ( tempPointer != NULL )
  139108             :                   {
  139109           0 :                     tempPointer->set_freepointer(pointer);
  139110             :                   }
  139111           0 :                for (unsigned i = 0; i < SgOmpCancellationPointStatement::pool_size - 1; ++i)
  139112             :                   {
  139113           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  139114             :                   }
  139115           0 :                 pointer[SgOmpCancellationPointStatement::pool_size-1].set_freepointer(NULL);
  139116           0 :                 tempPointer = &(pointer[SgOmpCancellationPointStatement::pool_size-1]);
  139117           0 :                 ++block;
  139118             :              }
  139119             :         }
  139120           0 :    }
  139121             : 
  139122           5 : void SgOmpCancellationPointStatement::deleteMemoryPool() {
  139123           5 :   for (auto p: SgOmpCancellationPointStatement::pools) {
  139124           0 :     ROSE_FREE(p);
  139125             :   }
  139126           5 :   SgOmpCancellationPointStatement::next_node = nullptr;
  139127           5 :   SgOmpCancellationPointStatement::pools.clear();
  139128           5 : }
  139129             : 
  139130             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  139131             : //                 reading multiple binary files to for a single AST.
  139132             : /////////// new version ////////////////////////////////
  139133             : //############################################################################
  139134             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  139135             : void
  139136           2 : SgOmpCancellationPointStatement::extendMemoryPoolForFileIO( )
  139137             :   {
  139138           2 :     size_t blockIndex = SgOmpCancellationPointStatement::pools.size();
  139139           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCancellationPointStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCancellationPointStatement);
  139140             : 
  139141           2 :     while ( (blockIndex * SgOmpCancellationPointStatement::pool_size) < newPoolSize)
  139142             :       {
  139143             : #if ROSE_ALLOC_TRACE
  139144             :         if (blockIndex > 0) {
  139145             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCancellationPointStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCancellationPointStatement) = %" PRIuPTR " SgOmpCancellationPointStatement::pool_size = %d \n",
  139146             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpCancellationPointStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpCancellationPointStatement),SgOmpCancellationPointStatement::pool_size);
  139147             :         }
  139148             : #endif
  139149             : 
  139150           0 :         SgOmpCancellationPointStatement * pointer = (SgOmpCancellationPointStatement*) ROSE_MALLOC ( SgOmpCancellationPointStatement::pool_size * sizeof(SgOmpCancellationPointStatement) );
  139151           0 :         assert( pointer != NULL );
  139152             : #if ROSE_ALLOC_MEMSET == 1
  139153             :         memset(pointer, 0x00, SgOmpCancellationPointStatement::pool_size * sizeof(SgOmpCancellationPointStatement));
  139154             : #elif ROSE_ALLOC_MEMSET == 2
  139155             :         memset(pointer, 0xCC, SgOmpCancellationPointStatement::pool_size * sizeof(SgOmpCancellationPointStatement));
  139156             : #endif
  139157           0 :         SgOmpCancellationPointStatement::pools.push_back( (unsigned char*)(pointer) );
  139158           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpCancellationPointStatement::pool_size * sizeof(SgOmpCancellationPointStatement), V_SgOmpCancellationPointStatement ) );
  139159             : 
  139160           0 :         if ( SgOmpCancellationPointStatement::next_node != NULL ) {
  139161           0 :           if ( blockIndex > 0 ) {
  139162           0 :             SgOmpCancellationPointStatement * blkptr = (SgOmpCancellationPointStatement*)(SgOmpCancellationPointStatement::pools[blockIndex-1]);
  139163           0 :             blkptr[ SgOmpCancellationPointStatement::pool_size - 1 ].set_freepointer(pointer);
  139164             :           }
  139165             :         } else {
  139166           0 :           SgOmpCancellationPointStatement::next_node = pointer;
  139167             :         }
  139168             : 
  139169           0 :         for (unsigned i = 0; i < SgOmpCancellationPointStatement::pool_size-1; ++i)
  139170             :            {
  139171           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  139172             :            }
  139173           0 :         pointer[ SgOmpCancellationPointStatement::pool_size -1 ].set_freepointer(NULL);
  139174             : 
  139175           0 :         blockIndex++;
  139176             :       }
  139177           2 :   }
  139178             : 
  139179             : //############################################################################
  139180             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  139181             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  139182             :  * not compressed. However, that stuff is not yet implemented! 
  139183             :  */
  139184             : unsigned long
  139185           0 : SgOmpCancellationPointStatement::getNumberOfLastValidPointer()
  139186             :    {
  139187           0 :       SgOmpCancellationPointStatement* testPointer = (SgOmpCancellationPointStatement*)(SgOmpCancellationPointStatement::pools.back());
  139188           0 :       unsigned long localIndex = SgOmpCancellationPointStatement::pool_size - 1;
  139189           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  139190             :          {
  139191           0 :            localIndex--;
  139192             :          }
  139193           0 :       return (localIndex + SgOmpCancellationPointStatement::pool_size * (SgOmpCancellationPointStatement::pools.size()-1));
  139194             :    }
  139195             : 
  139196             : //############################################################################
  139197             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  139198             :  * memory pool and initializes the data member in class SgOmpCancellationPointStatementStroageClass
  139199             :  * from its counterpart of SgOmpCancellationPointStatement. The return value is just for checking, 
  139200             :  * that the whole StorageClassArray is initialized!
  139201             :  */
  139202             : unsigned long
  139203           0 : SgOmpCancellationPointStatement::initializeStorageClassArray( SgOmpCancellationPointStatementStorageClass *storageArray )
  139204             :    {
  139205           0 :      unsigned long storageCounter = 0;
  139206           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpCancellationPointStatement::pools.begin();
  139207           0 :      SgOmpCancellationPointStatement* pointer = NULL;
  139208           0 :      while ( block != SgOmpCancellationPointStatement::pools.end() ) {
  139209           0 :           pointer = (SgOmpCancellationPointStatement*) (*block);
  139210           0 :           for ( unsigned i = 0; i < SgOmpCancellationPointStatement::pool_size; ++i ) {
  139211           0 :                if ( pointer->get_freepointer() != NULL ) {
  139212           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  139213           0 :                  storageArray++;
  139214           0 :                  storageCounter++;
  139215             :                }
  139216           0 :                pointer++;
  139217             :              }
  139218           0 :            block++;
  139219             :         }
  139220           0 :      return storageCounter;
  139221             :    }
  139222             : 
  139223             : /* #line 139224 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  139224             : 
  139225             : 
  139226             : 
  139227             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  139228             : 
  139229             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  139230             : 
  139231             : //############################################################################
  139232             : /* JH (02/02/2006) Constructor of the IR node SgOmpTargetUpdateStatement that takes its 
  139233             :  * corresponding StorageClass as parameter
  139234             :  */
  139235           0 : SgOmpTargetUpdateStatement :: SgOmpTargetUpdateStatement ( const SgOmpTargetUpdateStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  139236             :    {
  139237             : 
  139238             : 
  139239             : /* #line 139240 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  139240             : 
  139241           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  139242             : 
  139243             : 
  139244             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  139245             : 
  139246             : 
  139247           0 :    }
  139248             : 
  139249             : //############################################################################
  139250             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  139251             :  * within the working AST. 
  139252             :  */
  139253           0 : SgOmpTargetUpdateStatement * SgOmpTargetUpdateStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  139254           0 :      SgOmpTargetUpdateStatement* returnPointer = NULL;
  139255           0 :      if ( globalIndex != 0 )
  139256             :         {
  139257             : 
  139258             : #if FILE_IO_EXTRA_CHECK
  139259           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpTargetUpdateStatement ) ) <= globalIndex ) ;
  139260           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetUpdateStatement + 1 ) ) );
  139261             : #endif
  139262           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpTargetUpdateStatement )  
  139263           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpTargetUpdateStatement );
  139264           0 :           unsigned long positionInPool = localIndex % SgOmpTargetUpdateStatement::pool_size;
  139265           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetUpdateStatement::pool_size;
  139266             : 
  139267             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  139268             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  139269             : 
  139270           0 :           returnPointer = &( ( (SgOmpTargetUpdateStatement*)(SgOmpTargetUpdateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  139271             : 
  139272           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  139273             :         }
  139274           0 :      return returnPointer ;
  139275             :    }
  139276             : 
  139277             : //############################################################################
  139278             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  139279             :   for the AST with the index astIndex
  139280             : */
  139281           0 : SgOmpTargetUpdateStatement * SgOmpTargetUpdateStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  139282           0 :      SgOmpTargetUpdateStatement* returnPointer = NULL;
  139283           0 :      if ( globalIndex != 0 )
  139284             :         {
  139285             : 
  139286             : #if FILE_IO_EXTRA_CHECK
  139287           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpTargetUpdateStatement ) ) <= globalIndex ) ;
  139288           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetUpdateStatement + 1 ) ) );
  139289             : #endif
  139290           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpTargetUpdateStatement )
  139291           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpTargetUpdateStatement );
  139292           0 :           unsigned long positionInPool = localIndex % SgOmpTargetUpdateStatement::pool_size ;
  139293           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpTargetUpdateStatement::pool_size ;
  139294             : 
  139295             : #if FILE_IO_EXTRA_CHECK
  139296             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  139297             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  139298             : #endif
  139299             : 
  139300           0 :           returnPointer = &( ( (SgOmpTargetUpdateStatement*)(SgOmpTargetUpdateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  139301             : 
  139302             : #if FILE_IO_EXTRA_CHECK
  139303           0 :           assert ( returnPointer != NULL ) ;
  139304             : #endif
  139305             :         }
  139306           0 :      return returnPointer ;
  139307             :    }
  139308             : 
  139309             : //############################################################################
  139310             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  139311             :  * pool size! We set for every valid object in the memory pool the freepointer
  139312             :  * to the global index and increase the global index afterwards. For all the 
  139313             :  * invalid objects (means address ranges within the memory pool that were not
  139314             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  139315             :  * distinguish valid from invalid objects! 
  139316             :  */
  139317             : unsigned long
  139318           5 : SgOmpTargetUpdateStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  139319             :    {
  139320           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  139321           5 :      SgOmpTargetUpdateStatement* pointer = NULL;
  139322           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  139323           5 :      std::vector < unsigned char* > :: const_iterator block;
  139324           5 :      for ( block = SgOmpTargetUpdateStatement::pools.begin(); block != SgOmpTargetUpdateStatement::pools.end() ; ++block )
  139325             :         {
  139326           0 :           pointer = (SgOmpTargetUpdateStatement*)(*block);
  139327           0 :           for (unsigned i = 0; i < SgOmpTargetUpdateStatement::pool_size; ++i )
  139328             :              {
  139329             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  139330             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  139331             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  139332             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  139333             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  139334             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  139335             :             // properly; so this will have to be checked next.
  139336             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  139337             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  139338           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  139339             :                   {
  139340           0 :                     pointer[i].set_freepointer((SgOmpTargetUpdateStatement*)(globalIndex));
  139341           0 :                     globalIndex++;
  139342             :                   }
  139343             :                else
  139344             :                   {
  139345           0 :                     pointer[i].set_freepointer(NULL);
  139346             :                   }
  139347             :               }
  139348             :         }
  139349           5 :      return globalIndex;
  139350             :    }
  139351             : 
  139352             : //############################################################################
  139353             : // JH (01/14/2006)
  139354             : void
  139355           5 : SgOmpTargetUpdateStatement::resetValidFreepointers( )
  139356             :    {
  139357           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  139358           5 :      SgOmpTargetUpdateStatement* pointer = NULL;
  139359           5 :      std::vector < unsigned char* > :: const_iterator block;
  139360           5 :      SgOmpTargetUpdateStatement* pointerOfLinkedList = NULL;
  139361           5 :      for ( block = SgOmpTargetUpdateStatement::pools.begin(); block != SgOmpTargetUpdateStatement::pools.end() ; ++block )
  139362             :         {
  139363           0 :           pointer = (SgOmpTargetUpdateStatement*)(*block);
  139364           0 :           for (unsigned i = 0; i < SgOmpTargetUpdateStatement::pool_size; ++i )
  139365             :              {
  139366             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  139367             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  139368             :             // memory blocks!.
  139369           0 :                if ( pointer[i].get_freepointer() != NULL )
  139370             :                   {
  139371           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  139372             :                   }
  139373             :                else
  139374             :                   {
  139375           0 :                     if ( pointerOfLinkedList == NULL )
  139376             :                        {
  139377           0 :                          SgOmpTargetUpdateStatement::next_node = &(pointer[i]);
  139378             :                        }
  139379             :                     else
  139380             :                        {
  139381             :                       // printf ("In SgOmpTargetUpdateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  139382           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  139383             :                        }
  139384             :                     pointerOfLinkedList = &(pointer[i]);
  139385             :                   }
  139386             :               }
  139387             :         }
  139388             : 
  139389           5 :      if ( pointerOfLinkedList != NULL )
  139390             :         {
  139391             :        // printf ("In SgOmpTargetUpdateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  139392           0 :           pointerOfLinkedList->set_freepointer(NULL);
  139393             :        // DQ (6/6/2010): Temporary debugging...
  139394             :        //   ROSE_ASSERT(false);
  139395             :         }
  139396             : 
  139397           5 :      return ;
  139398             :    }
  139399             : 
  139400             : //############################################################################
  139401             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  139402             :  * within the memory pool and resets the freepointers, in order to achieve a 
  139403             :  * linked list, that has no jumps and starts at the beginning! This function 
  139404             :  * does not extend the memory pool, since we do not delete any memory blocks,
  139405             :  * but delete the valid objects.  
  139406             :  */
  139407             : void
  139408           0 : SgOmpTargetUpdateStatement::clearMemoryPool( )
  139409             :    {
  139410             :   // printf ("Inside of SgOmpTargetUpdateStatement::clearMemoryPool() \n");
  139411             : 
  139412           0 :      SgOmpTargetUpdateStatement* pointer = NULL, *tempPointer = NULL;
  139413           0 :      std::vector < unsigned char* > :: const_iterator block;
  139414           0 :      if ( SgOmpTargetUpdateStatement::pools.empty() == false )
  139415             :         {
  139416           0 :           block = SgOmpTargetUpdateStatement::pools.begin() ;
  139417           0 :           SgOmpTargetUpdateStatement::next_node = (SgOmpTargetUpdateStatement*) (*block);
  139418             : 
  139419           0 :           while ( block != SgOmpTargetUpdateStatement::pools.end() )
  139420             :              {
  139421           0 :                pointer = (SgOmpTargetUpdateStatement*) (*block);
  139422           0 :                if ( tempPointer != NULL )
  139423             :                   {
  139424           0 :                     tempPointer->set_freepointer(pointer);
  139425             :                   }
  139426           0 :                for (unsigned i = 0; i < SgOmpTargetUpdateStatement::pool_size - 1; ++i)
  139427             :                   {
  139428           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  139429             :                   }
  139430           0 :                 pointer[SgOmpTargetUpdateStatement::pool_size-1].set_freepointer(NULL);
  139431           0 :                 tempPointer = &(pointer[SgOmpTargetUpdateStatement::pool_size-1]);
  139432           0 :                 ++block;
  139433             :              }
  139434             :         }
  139435           0 :    }
  139436             : 
  139437           5 : void SgOmpTargetUpdateStatement::deleteMemoryPool() {
  139438           5 :   for (auto p: SgOmpTargetUpdateStatement::pools) {
  139439           0 :     ROSE_FREE(p);
  139440             :   }
  139441           5 :   SgOmpTargetUpdateStatement::next_node = nullptr;
  139442           5 :   SgOmpTargetUpdateStatement::pools.clear();
  139443           5 : }
  139444             : 
  139445             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  139446             : //                 reading multiple binary files to for a single AST.
  139447             : /////////// new version ////////////////////////////////
  139448             : //############################################################################
  139449             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  139450             : void
  139451           2 : SgOmpTargetUpdateStatement::extendMemoryPoolForFileIO( )
  139452             :   {
  139453           2 :     size_t blockIndex = SgOmpTargetUpdateStatement::pools.size();
  139454           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetUpdateStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetUpdateStatement);
  139455             : 
  139456           2 :     while ( (blockIndex * SgOmpTargetUpdateStatement::pool_size) < newPoolSize)
  139457             :       {
  139458             : #if ROSE_ALLOC_TRACE
  139459             :         if (blockIndex > 0) {
  139460             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetUpdateStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetUpdateStatement) = %" PRIuPTR " SgOmpTargetUpdateStatement::pool_size = %d \n",
  139461             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpTargetUpdateStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpTargetUpdateStatement),SgOmpTargetUpdateStatement::pool_size);
  139462             :         }
  139463             : #endif
  139464             : 
  139465           0 :         SgOmpTargetUpdateStatement * pointer = (SgOmpTargetUpdateStatement*) ROSE_MALLOC ( SgOmpTargetUpdateStatement::pool_size * sizeof(SgOmpTargetUpdateStatement) );
  139466           0 :         assert( pointer != NULL );
  139467             : #if ROSE_ALLOC_MEMSET == 1
  139468             :         memset(pointer, 0x00, SgOmpTargetUpdateStatement::pool_size * sizeof(SgOmpTargetUpdateStatement));
  139469             : #elif ROSE_ALLOC_MEMSET == 2
  139470             :         memset(pointer, 0xCC, SgOmpTargetUpdateStatement::pool_size * sizeof(SgOmpTargetUpdateStatement));
  139471             : #endif
  139472           0 :         SgOmpTargetUpdateStatement::pools.push_back( (unsigned char*)(pointer) );
  139473           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpTargetUpdateStatement::pool_size * sizeof(SgOmpTargetUpdateStatement), V_SgOmpTargetUpdateStatement ) );
  139474             : 
  139475           0 :         if ( SgOmpTargetUpdateStatement::next_node != NULL ) {
  139476           0 :           if ( blockIndex > 0 ) {
  139477           0 :             SgOmpTargetUpdateStatement * blkptr = (SgOmpTargetUpdateStatement*)(SgOmpTargetUpdateStatement::pools[blockIndex-1]);
  139478           0 :             blkptr[ SgOmpTargetUpdateStatement::pool_size - 1 ].set_freepointer(pointer);
  139479             :           }
  139480             :         } else {
  139481           0 :           SgOmpTargetUpdateStatement::next_node = pointer;
  139482             :         }
  139483             : 
  139484           0 :         for (unsigned i = 0; i < SgOmpTargetUpdateStatement::pool_size-1; ++i)
  139485             :            {
  139486           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  139487             :            }
  139488           0 :         pointer[ SgOmpTargetUpdateStatement::pool_size -1 ].set_freepointer(NULL);
  139489             : 
  139490           0 :         blockIndex++;
  139491             :       }
  139492           2 :   }
  139493             : 
  139494             : //############################################################################
  139495             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  139496             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  139497             :  * not compressed. However, that stuff is not yet implemented! 
  139498             :  */
  139499             : unsigned long
  139500           0 : SgOmpTargetUpdateStatement::getNumberOfLastValidPointer()
  139501             :    {
  139502           0 :       SgOmpTargetUpdateStatement* testPointer = (SgOmpTargetUpdateStatement*)(SgOmpTargetUpdateStatement::pools.back());
  139503           0 :       unsigned long localIndex = SgOmpTargetUpdateStatement::pool_size - 1;
  139504           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  139505             :          {
  139506           0 :            localIndex--;
  139507             :          }
  139508           0 :       return (localIndex + SgOmpTargetUpdateStatement::pool_size * (SgOmpTargetUpdateStatement::pools.size()-1));
  139509             :    }
  139510             : 
  139511             : //############################################################################
  139512             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  139513             :  * memory pool and initializes the data member in class SgOmpTargetUpdateStatementStroageClass
  139514             :  * from its counterpart of SgOmpTargetUpdateStatement. The return value is just for checking, 
  139515             :  * that the whole StorageClassArray is initialized!
  139516             :  */
  139517             : unsigned long
  139518           0 : SgOmpTargetUpdateStatement::initializeStorageClassArray( SgOmpTargetUpdateStatementStorageClass *storageArray )
  139519             :    {
  139520           0 :      unsigned long storageCounter = 0;
  139521           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpTargetUpdateStatement::pools.begin();
  139522           0 :      SgOmpTargetUpdateStatement* pointer = NULL;
  139523           0 :      while ( block != SgOmpTargetUpdateStatement::pools.end() ) {
  139524           0 :           pointer = (SgOmpTargetUpdateStatement*) (*block);
  139525           0 :           for ( unsigned i = 0; i < SgOmpTargetUpdateStatement::pool_size; ++i ) {
  139526           0 :                if ( pointer->get_freepointer() != NULL ) {
  139527           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  139528           0 :                  storageArray++;
  139529           0 :                  storageCounter++;
  139530             :                }
  139531           0 :                pointer++;
  139532             :              }
  139533           0 :            block++;
  139534             :         }
  139535           0 :      return storageCounter;
  139536             :    }
  139537             : 
  139538             : /* #line 139539 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  139539             : 
  139540             : 
  139541             : 
  139542             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  139543             : 
  139544             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  139545             : 
  139546             : //############################################################################
  139547             : /* JH (02/02/2006) Constructor of the IR node SgOmpFlushStatement that takes its 
  139548             :  * corresponding StorageClass as parameter
  139549             :  */
  139550           0 : SgOmpFlushStatement :: SgOmpFlushStatement ( const SgOmpFlushStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  139551             :    {
  139552             : 
  139553             : 
  139554             : /* #line 139555 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  139555             : 
  139556           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  139557           0 :      p_variables = storageSource.storageOf_variables.rebuildDataStoredInEasyStorageClass() ;
  139558           0 :      SgVarRefExpPtrList::iterator i_variables = p_variables.begin() ; 
  139559           0 :      for ( ; i_variables != p_variables.end(); ++i_variables ) 
  139560             :         {
  139561           0 :           (*i_variables) = (SgVarRefExpPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_variables) ) );
  139562             :         }
  139563             : 
  139564             : 
  139565             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  139566             : 
  139567             : 
  139568           0 :    }
  139569             : 
  139570             : //############################################################################
  139571             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  139572             :  * within the working AST. 
  139573             :  */
  139574           0 : SgOmpFlushStatement * SgOmpFlushStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  139575           0 :      SgOmpFlushStatement* returnPointer = NULL;
  139576           0 :      if ( globalIndex != 0 )
  139577             :         {
  139578             : 
  139579             : #if FILE_IO_EXTRA_CHECK
  139580           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpFlushStatement ) ) <= globalIndex ) ;
  139581           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFlushStatement + 1 ) ) );
  139582             : #endif
  139583           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpFlushStatement )  
  139584           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpFlushStatement );
  139585           0 :           unsigned long positionInPool = localIndex % SgOmpFlushStatement::pool_size;
  139586           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFlushStatement::pool_size;
  139587             : 
  139588             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  139589             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  139590             : 
  139591           0 :           returnPointer = &( ( (SgOmpFlushStatement*)(SgOmpFlushStatement::pools[memoryBlock]) ) [positionInPool]) ;
  139592             : 
  139593           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  139594             :         }
  139595           0 :      return returnPointer ;
  139596             :    }
  139597             : 
  139598             : //############################################################################
  139599             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  139600             :   for the AST with the index astIndex
  139601             : */
  139602           0 : SgOmpFlushStatement * SgOmpFlushStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  139603           0 :      SgOmpFlushStatement* returnPointer = NULL;
  139604           0 :      if ( globalIndex != 0 )
  139605             :         {
  139606             : 
  139607             : #if FILE_IO_EXTRA_CHECK
  139608           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpFlushStatement ) ) <= globalIndex ) ;
  139609           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFlushStatement + 1 ) ) );
  139610             : #endif
  139611           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpFlushStatement )
  139612           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpFlushStatement );
  139613           0 :           unsigned long positionInPool = localIndex % SgOmpFlushStatement::pool_size ;
  139614           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpFlushStatement::pool_size ;
  139615             : 
  139616             : #if FILE_IO_EXTRA_CHECK
  139617             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  139618             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  139619             : #endif
  139620             : 
  139621           0 :           returnPointer = &( ( (SgOmpFlushStatement*)(SgOmpFlushStatement::pools[memoryBlock]) ) [positionInPool]) ;
  139622             : 
  139623             : #if FILE_IO_EXTRA_CHECK
  139624           0 :           assert ( returnPointer != NULL ) ;
  139625             : #endif
  139626             :         }
  139627           0 :      return returnPointer ;
  139628             :    }
  139629             : 
  139630             : //############################################################################
  139631             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  139632             :  * pool size! We set for every valid object in the memory pool the freepointer
  139633             :  * to the global index and increase the global index afterwards. For all the 
  139634             :  * invalid objects (means address ranges within the memory pool that were not
  139635             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  139636             :  * distinguish valid from invalid objects! 
  139637             :  */
  139638             : unsigned long
  139639           5 : SgOmpFlushStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  139640             :    {
  139641           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  139642           5 :      SgOmpFlushStatement* pointer = NULL;
  139643           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  139644           5 :      std::vector < unsigned char* > :: const_iterator block;
  139645           5 :      for ( block = SgOmpFlushStatement::pools.begin(); block != SgOmpFlushStatement::pools.end() ; ++block )
  139646             :         {
  139647           0 :           pointer = (SgOmpFlushStatement*)(*block);
  139648           0 :           for (unsigned i = 0; i < SgOmpFlushStatement::pool_size; ++i )
  139649             :              {
  139650             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  139651             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  139652             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  139653             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  139654             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  139655             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  139656             :             // properly; so this will have to be checked next.
  139657             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  139658             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  139659           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  139660             :                   {
  139661           0 :                     pointer[i].set_freepointer((SgOmpFlushStatement*)(globalIndex));
  139662           0 :                     globalIndex++;
  139663             :                   }
  139664             :                else
  139665             :                   {
  139666           0 :                     pointer[i].set_freepointer(NULL);
  139667             :                   }
  139668             :               }
  139669             :         }
  139670           5 :      return globalIndex;
  139671             :    }
  139672             : 
  139673             : //############################################################################
  139674             : // JH (01/14/2006)
  139675             : void
  139676           5 : SgOmpFlushStatement::resetValidFreepointers( )
  139677             :    {
  139678           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  139679           5 :      SgOmpFlushStatement* pointer = NULL;
  139680           5 :      std::vector < unsigned char* > :: const_iterator block;
  139681           5 :      SgOmpFlushStatement* pointerOfLinkedList = NULL;
  139682           5 :      for ( block = SgOmpFlushStatement::pools.begin(); block != SgOmpFlushStatement::pools.end() ; ++block )
  139683             :         {
  139684           0 :           pointer = (SgOmpFlushStatement*)(*block);
  139685           0 :           for (unsigned i = 0; i < SgOmpFlushStatement::pool_size; ++i )
  139686             :              {
  139687             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  139688             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  139689             :             // memory blocks!.
  139690           0 :                if ( pointer[i].get_freepointer() != NULL )
  139691             :                   {
  139692           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  139693             :                   }
  139694             :                else
  139695             :                   {
  139696           0 :                     if ( pointerOfLinkedList == NULL )
  139697             :                        {
  139698           0 :                          SgOmpFlushStatement::next_node = &(pointer[i]);
  139699             :                        }
  139700             :                     else
  139701             :                        {
  139702             :                       // printf ("In SgOmpFlushStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  139703           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  139704             :                        }
  139705             :                     pointerOfLinkedList = &(pointer[i]);
  139706             :                   }
  139707             :               }
  139708             :         }
  139709             : 
  139710           5 :      if ( pointerOfLinkedList != NULL )
  139711             :         {
  139712             :        // printf ("In SgOmpFlushStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  139713           0 :           pointerOfLinkedList->set_freepointer(NULL);
  139714             :        // DQ (6/6/2010): Temporary debugging...
  139715             :        //   ROSE_ASSERT(false);
  139716             :         }
  139717             : 
  139718           5 :      return ;
  139719             :    }
  139720             : 
  139721             : //############################################################################
  139722             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  139723             :  * within the memory pool and resets the freepointers, in order to achieve a 
  139724             :  * linked list, that has no jumps and starts at the beginning! This function 
  139725             :  * does not extend the memory pool, since we do not delete any memory blocks,
  139726             :  * but delete the valid objects.  
  139727             :  */
  139728             : void
  139729           0 : SgOmpFlushStatement::clearMemoryPool( )
  139730             :    {
  139731             :   // printf ("Inside of SgOmpFlushStatement::clearMemoryPool() \n");
  139732             : 
  139733           0 :      SgOmpFlushStatement* pointer = NULL, *tempPointer = NULL;
  139734           0 :      std::vector < unsigned char* > :: const_iterator block;
  139735           0 :      if ( SgOmpFlushStatement::pools.empty() == false )
  139736             :         {
  139737           0 :           block = SgOmpFlushStatement::pools.begin() ;
  139738           0 :           SgOmpFlushStatement::next_node = (SgOmpFlushStatement*) (*block);
  139739             : 
  139740           0 :           while ( block != SgOmpFlushStatement::pools.end() )
  139741             :              {
  139742           0 :                pointer = (SgOmpFlushStatement*) (*block);
  139743           0 :                if ( tempPointer != NULL )
  139744             :                   {
  139745           0 :                     tempPointer->set_freepointer(pointer);
  139746             :                   }
  139747           0 :                for (unsigned i = 0; i < SgOmpFlushStatement::pool_size - 1; ++i)
  139748             :                   {
  139749           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  139750             :                   }
  139751           0 :                 pointer[SgOmpFlushStatement::pool_size-1].set_freepointer(NULL);
  139752           0 :                 tempPointer = &(pointer[SgOmpFlushStatement::pool_size-1]);
  139753           0 :                 ++block;
  139754             :              }
  139755             :         }
  139756           0 :    }
  139757             : 
  139758           5 : void SgOmpFlushStatement::deleteMemoryPool() {
  139759           5 :   for (auto p: SgOmpFlushStatement::pools) {
  139760           0 :     ROSE_FREE(p);
  139761             :   }
  139762           5 :   SgOmpFlushStatement::next_node = nullptr;
  139763           5 :   SgOmpFlushStatement::pools.clear();
  139764           5 : }
  139765             : 
  139766             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  139767             : //                 reading multiple binary files to for a single AST.
  139768             : /////////// new version ////////////////////////////////
  139769             : //############################################################################
  139770             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  139771             : void
  139772           2 : SgOmpFlushStatement::extendMemoryPoolForFileIO( )
  139773             :   {
  139774           2 :     size_t blockIndex = SgOmpFlushStatement::pools.size();
  139775           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFlushStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFlushStatement);
  139776             : 
  139777           2 :     while ( (blockIndex * SgOmpFlushStatement::pool_size) < newPoolSize)
  139778             :       {
  139779             : #if ROSE_ALLOC_TRACE
  139780             :         if (blockIndex > 0) {
  139781             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFlushStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFlushStatement) = %" PRIuPTR " SgOmpFlushStatement::pool_size = %d \n",
  139782             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpFlushStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpFlushStatement),SgOmpFlushStatement::pool_size);
  139783             :         }
  139784             : #endif
  139785             : 
  139786           0 :         SgOmpFlushStatement * pointer = (SgOmpFlushStatement*) ROSE_MALLOC ( SgOmpFlushStatement::pool_size * sizeof(SgOmpFlushStatement) );
  139787           0 :         assert( pointer != NULL );
  139788             : #if ROSE_ALLOC_MEMSET == 1
  139789             :         memset(pointer, 0x00, SgOmpFlushStatement::pool_size * sizeof(SgOmpFlushStatement));
  139790             : #elif ROSE_ALLOC_MEMSET == 2
  139791             :         memset(pointer, 0xCC, SgOmpFlushStatement::pool_size * sizeof(SgOmpFlushStatement));
  139792             : #endif
  139793           0 :         SgOmpFlushStatement::pools.push_back( (unsigned char*)(pointer) );
  139794           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpFlushStatement::pool_size * sizeof(SgOmpFlushStatement), V_SgOmpFlushStatement ) );
  139795             : 
  139796           0 :         if ( SgOmpFlushStatement::next_node != NULL ) {
  139797           0 :           if ( blockIndex > 0 ) {
  139798           0 :             SgOmpFlushStatement * blkptr = (SgOmpFlushStatement*)(SgOmpFlushStatement::pools[blockIndex-1]);
  139799           0 :             blkptr[ SgOmpFlushStatement::pool_size - 1 ].set_freepointer(pointer);
  139800             :           }
  139801             :         } else {
  139802           0 :           SgOmpFlushStatement::next_node = pointer;
  139803             :         }
  139804             : 
  139805           0 :         for (unsigned i = 0; i < SgOmpFlushStatement::pool_size-1; ++i)
  139806             :            {
  139807           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  139808             :            }
  139809           0 :         pointer[ SgOmpFlushStatement::pool_size -1 ].set_freepointer(NULL);
  139810             : 
  139811           0 :         blockIndex++;
  139812             :       }
  139813           2 :   }
  139814             : 
  139815             : //############################################################################
  139816             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  139817             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  139818             :  * not compressed. However, that stuff is not yet implemented! 
  139819             :  */
  139820             : unsigned long
  139821           0 : SgOmpFlushStatement::getNumberOfLastValidPointer()
  139822             :    {
  139823           0 :       SgOmpFlushStatement* testPointer = (SgOmpFlushStatement*)(SgOmpFlushStatement::pools.back());
  139824           0 :       unsigned long localIndex = SgOmpFlushStatement::pool_size - 1;
  139825           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  139826             :          {
  139827           0 :            localIndex--;
  139828             :          }
  139829           0 :       return (localIndex + SgOmpFlushStatement::pool_size * (SgOmpFlushStatement::pools.size()-1));
  139830             :    }
  139831             : 
  139832             : //############################################################################
  139833             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  139834             :  * memory pool and initializes the data member in class SgOmpFlushStatementStroageClass
  139835             :  * from its counterpart of SgOmpFlushStatement. The return value is just for checking, 
  139836             :  * that the whole StorageClassArray is initialized!
  139837             :  */
  139838             : unsigned long
  139839           0 : SgOmpFlushStatement::initializeStorageClassArray( SgOmpFlushStatementStorageClass *storageArray )
  139840             :    {
  139841           0 :      unsigned long storageCounter = 0;
  139842           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpFlushStatement::pools.begin();
  139843           0 :      SgOmpFlushStatement* pointer = NULL;
  139844           0 :      while ( block != SgOmpFlushStatement::pools.end() ) {
  139845           0 :           pointer = (SgOmpFlushStatement*) (*block);
  139846           0 :           for ( unsigned i = 0; i < SgOmpFlushStatement::pool_size; ++i ) {
  139847           0 :                if ( pointer->get_freepointer() != NULL ) {
  139848           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  139849           0 :                  storageArray++;
  139850           0 :                  storageCounter++;
  139851             :                }
  139852           0 :                pointer++;
  139853             :              }
  139854           0 :            block++;
  139855             :         }
  139856           0 :      return storageCounter;
  139857             :    }
  139858             : 
  139859             : /* #line 139860 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  139860             : 
  139861             : 
  139862             : 
  139863             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  139864             : 
  139865             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  139866             : 
  139867             : //############################################################################
  139868             : /* JH (02/02/2006) Constructor of the IR node SgOmpAllocateStatement that takes its 
  139869             :  * corresponding StorageClass as parameter
  139870             :  */
  139871           0 : SgOmpAllocateStatement :: SgOmpAllocateStatement ( const SgOmpAllocateStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  139872             :    {
  139873             : 
  139874             : 
  139875             : /* #line 139876 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  139876             : 
  139877           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  139878           0 :      p_variables = storageSource.storageOf_variables.rebuildDataStoredInEasyStorageClass() ;
  139879           0 :      SgVarRefExpPtrList::iterator i_variables = p_variables.begin() ; 
  139880           0 :      for ( ; i_variables != p_variables.end(); ++i_variables ) 
  139881             :         {
  139882           0 :           (*i_variables) = (SgVarRefExpPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_variables) ) );
  139883             :         }
  139884             : 
  139885             : 
  139886             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  139887             : 
  139888             : 
  139889           0 :    }
  139890             : 
  139891             : //############################################################################
  139892             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  139893             :  * within the working AST. 
  139894             :  */
  139895           0 : SgOmpAllocateStatement * SgOmpAllocateStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  139896           0 :      SgOmpAllocateStatement* returnPointer = NULL;
  139897           0 :      if ( globalIndex != 0 )
  139898             :         {
  139899             : 
  139900             : #if FILE_IO_EXTRA_CHECK
  139901           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpAllocateStatement ) ) <= globalIndex ) ;
  139902           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAllocateStatement + 1 ) ) );
  139903             : #endif
  139904           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpAllocateStatement )  
  139905           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpAllocateStatement );
  139906           0 :           unsigned long positionInPool = localIndex % SgOmpAllocateStatement::pool_size;
  139907           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAllocateStatement::pool_size;
  139908             : 
  139909             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  139910             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  139911             : 
  139912           0 :           returnPointer = &( ( (SgOmpAllocateStatement*)(SgOmpAllocateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  139913             : 
  139914           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  139915             :         }
  139916           0 :      return returnPointer ;
  139917             :    }
  139918             : 
  139919             : //############################################################################
  139920             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  139921             :   for the AST with the index astIndex
  139922             : */
  139923           0 : SgOmpAllocateStatement * SgOmpAllocateStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  139924           0 :      SgOmpAllocateStatement* returnPointer = NULL;
  139925           0 :      if ( globalIndex != 0 )
  139926             :         {
  139927             : 
  139928             : #if FILE_IO_EXTRA_CHECK
  139929           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpAllocateStatement ) ) <= globalIndex ) ;
  139930           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAllocateStatement + 1 ) ) );
  139931             : #endif
  139932           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpAllocateStatement )
  139933           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpAllocateStatement );
  139934           0 :           unsigned long positionInPool = localIndex % SgOmpAllocateStatement::pool_size ;
  139935           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpAllocateStatement::pool_size ;
  139936             : 
  139937             : #if FILE_IO_EXTRA_CHECK
  139938             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  139939             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  139940             : #endif
  139941             : 
  139942           0 :           returnPointer = &( ( (SgOmpAllocateStatement*)(SgOmpAllocateStatement::pools[memoryBlock]) ) [positionInPool]) ;
  139943             : 
  139944             : #if FILE_IO_EXTRA_CHECK
  139945           0 :           assert ( returnPointer != NULL ) ;
  139946             : #endif
  139947             :         }
  139948           0 :      return returnPointer ;
  139949             :    }
  139950             : 
  139951             : //############################################################################
  139952             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  139953             :  * pool size! We set for every valid object in the memory pool the freepointer
  139954             :  * to the global index and increase the global index afterwards. For all the 
  139955             :  * invalid objects (means address ranges within the memory pool that were not
  139956             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  139957             :  * distinguish valid from invalid objects! 
  139958             :  */
  139959             : unsigned long
  139960           5 : SgOmpAllocateStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  139961             :    {
  139962           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  139963           5 :      SgOmpAllocateStatement* pointer = NULL;
  139964           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  139965           5 :      std::vector < unsigned char* > :: const_iterator block;
  139966           5 :      for ( block = SgOmpAllocateStatement::pools.begin(); block != SgOmpAllocateStatement::pools.end() ; ++block )
  139967             :         {
  139968           0 :           pointer = (SgOmpAllocateStatement*)(*block);
  139969           0 :           for (unsigned i = 0; i < SgOmpAllocateStatement::pool_size; ++i )
  139970             :              {
  139971             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  139972             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  139973             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  139974             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  139975             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  139976             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  139977             :             // properly; so this will have to be checked next.
  139978             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  139979             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  139980           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  139981             :                   {
  139982           0 :                     pointer[i].set_freepointer((SgOmpAllocateStatement*)(globalIndex));
  139983           0 :                     globalIndex++;
  139984             :                   }
  139985             :                else
  139986             :                   {
  139987           0 :                     pointer[i].set_freepointer(NULL);
  139988             :                   }
  139989             :               }
  139990             :         }
  139991           5 :      return globalIndex;
  139992             :    }
  139993             : 
  139994             : //############################################################################
  139995             : // JH (01/14/2006)
  139996             : void
  139997           5 : SgOmpAllocateStatement::resetValidFreepointers( )
  139998             :    {
  139999           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  140000           5 :      SgOmpAllocateStatement* pointer = NULL;
  140001           5 :      std::vector < unsigned char* > :: const_iterator block;
  140002           5 :      SgOmpAllocateStatement* pointerOfLinkedList = NULL;
  140003           5 :      for ( block = SgOmpAllocateStatement::pools.begin(); block != SgOmpAllocateStatement::pools.end() ; ++block )
  140004             :         {
  140005           0 :           pointer = (SgOmpAllocateStatement*)(*block);
  140006           0 :           for (unsigned i = 0; i < SgOmpAllocateStatement::pool_size; ++i )
  140007             :              {
  140008             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  140009             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  140010             :             // memory blocks!.
  140011           0 :                if ( pointer[i].get_freepointer() != NULL )
  140012             :                   {
  140013           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  140014             :                   }
  140015             :                else
  140016             :                   {
  140017           0 :                     if ( pointerOfLinkedList == NULL )
  140018             :                        {
  140019           0 :                          SgOmpAllocateStatement::next_node = &(pointer[i]);
  140020             :                        }
  140021             :                     else
  140022             :                        {
  140023             :                       // printf ("In SgOmpAllocateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  140024           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  140025             :                        }
  140026             :                     pointerOfLinkedList = &(pointer[i]);
  140027             :                   }
  140028             :               }
  140029             :         }
  140030             : 
  140031           5 :      if ( pointerOfLinkedList != NULL )
  140032             :         {
  140033             :        // printf ("In SgOmpAllocateStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  140034           0 :           pointerOfLinkedList->set_freepointer(NULL);
  140035             :        // DQ (6/6/2010): Temporary debugging...
  140036             :        //   ROSE_ASSERT(false);
  140037             :         }
  140038             : 
  140039           5 :      return ;
  140040             :    }
  140041             : 
  140042             : //############################################################################
  140043             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  140044             :  * within the memory pool and resets the freepointers, in order to achieve a 
  140045             :  * linked list, that has no jumps and starts at the beginning! This function 
  140046             :  * does not extend the memory pool, since we do not delete any memory blocks,
  140047             :  * but delete the valid objects.  
  140048             :  */
  140049             : void
  140050           0 : SgOmpAllocateStatement::clearMemoryPool( )
  140051             :    {
  140052             :   // printf ("Inside of SgOmpAllocateStatement::clearMemoryPool() \n");
  140053             : 
  140054           0 :      SgOmpAllocateStatement* pointer = NULL, *tempPointer = NULL;
  140055           0 :      std::vector < unsigned char* > :: const_iterator block;
  140056           0 :      if ( SgOmpAllocateStatement::pools.empty() == false )
  140057             :         {
  140058           0 :           block = SgOmpAllocateStatement::pools.begin() ;
  140059           0 :           SgOmpAllocateStatement::next_node = (SgOmpAllocateStatement*) (*block);
  140060             : 
  140061           0 :           while ( block != SgOmpAllocateStatement::pools.end() )
  140062             :              {
  140063           0 :                pointer = (SgOmpAllocateStatement*) (*block);
  140064           0 :                if ( tempPointer != NULL )
  140065             :                   {
  140066           0 :                     tempPointer->set_freepointer(pointer);
  140067             :                   }
  140068           0 :                for (unsigned i = 0; i < SgOmpAllocateStatement::pool_size - 1; ++i)
  140069             :                   {
  140070           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  140071             :                   }
  140072           0 :                 pointer[SgOmpAllocateStatement::pool_size-1].set_freepointer(NULL);
  140073           0 :                 tempPointer = &(pointer[SgOmpAllocateStatement::pool_size-1]);
  140074           0 :                 ++block;
  140075             :              }
  140076             :         }
  140077           0 :    }
  140078             : 
  140079           5 : void SgOmpAllocateStatement::deleteMemoryPool() {
  140080           5 :   for (auto p: SgOmpAllocateStatement::pools) {
  140081           0 :     ROSE_FREE(p);
  140082             :   }
  140083           5 :   SgOmpAllocateStatement::next_node = nullptr;
  140084           5 :   SgOmpAllocateStatement::pools.clear();
  140085           5 : }
  140086             : 
  140087             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  140088             : //                 reading multiple binary files to for a single AST.
  140089             : /////////// new version ////////////////////////////////
  140090             : //############################################################################
  140091             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  140092             : void
  140093           2 : SgOmpAllocateStatement::extendMemoryPoolForFileIO( )
  140094             :   {
  140095           2 :     size_t blockIndex = SgOmpAllocateStatement::pools.size();
  140096           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocateStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocateStatement);
  140097             : 
  140098           2 :     while ( (blockIndex * SgOmpAllocateStatement::pool_size) < newPoolSize)
  140099             :       {
  140100             : #if ROSE_ALLOC_TRACE
  140101             :         if (blockIndex > 0) {
  140102             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocateStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocateStatement) = %" PRIuPTR " SgOmpAllocateStatement::pool_size = %d \n",
  140103             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpAllocateStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpAllocateStatement),SgOmpAllocateStatement::pool_size);
  140104             :         }
  140105             : #endif
  140106             : 
  140107           0 :         SgOmpAllocateStatement * pointer = (SgOmpAllocateStatement*) ROSE_MALLOC ( SgOmpAllocateStatement::pool_size * sizeof(SgOmpAllocateStatement) );
  140108           0 :         assert( pointer != NULL );
  140109             : #if ROSE_ALLOC_MEMSET == 1
  140110             :         memset(pointer, 0x00, SgOmpAllocateStatement::pool_size * sizeof(SgOmpAllocateStatement));
  140111             : #elif ROSE_ALLOC_MEMSET == 2
  140112             :         memset(pointer, 0xCC, SgOmpAllocateStatement::pool_size * sizeof(SgOmpAllocateStatement));
  140113             : #endif
  140114           0 :         SgOmpAllocateStatement::pools.push_back( (unsigned char*)(pointer) );
  140115           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpAllocateStatement::pool_size * sizeof(SgOmpAllocateStatement), V_SgOmpAllocateStatement ) );
  140116             : 
  140117           0 :         if ( SgOmpAllocateStatement::next_node != NULL ) {
  140118           0 :           if ( blockIndex > 0 ) {
  140119           0 :             SgOmpAllocateStatement * blkptr = (SgOmpAllocateStatement*)(SgOmpAllocateStatement::pools[blockIndex-1]);
  140120           0 :             blkptr[ SgOmpAllocateStatement::pool_size - 1 ].set_freepointer(pointer);
  140121             :           }
  140122             :         } else {
  140123           0 :           SgOmpAllocateStatement::next_node = pointer;
  140124             :         }
  140125             : 
  140126           0 :         for (unsigned i = 0; i < SgOmpAllocateStatement::pool_size-1; ++i)
  140127             :            {
  140128           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  140129             :            }
  140130           0 :         pointer[ SgOmpAllocateStatement::pool_size -1 ].set_freepointer(NULL);
  140131             : 
  140132           0 :         blockIndex++;
  140133             :       }
  140134           2 :   }
  140135             : 
  140136             : //############################################################################
  140137             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  140138             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  140139             :  * not compressed. However, that stuff is not yet implemented! 
  140140             :  */
  140141             : unsigned long
  140142           0 : SgOmpAllocateStatement::getNumberOfLastValidPointer()
  140143             :    {
  140144           0 :       SgOmpAllocateStatement* testPointer = (SgOmpAllocateStatement*)(SgOmpAllocateStatement::pools.back());
  140145           0 :       unsigned long localIndex = SgOmpAllocateStatement::pool_size - 1;
  140146           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  140147             :          {
  140148           0 :            localIndex--;
  140149             :          }
  140150           0 :       return (localIndex + SgOmpAllocateStatement::pool_size * (SgOmpAllocateStatement::pools.size()-1));
  140151             :    }
  140152             : 
  140153             : //############################################################################
  140154             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  140155             :  * memory pool and initializes the data member in class SgOmpAllocateStatementStroageClass
  140156             :  * from its counterpart of SgOmpAllocateStatement. The return value is just for checking, 
  140157             :  * that the whole StorageClassArray is initialized!
  140158             :  */
  140159             : unsigned long
  140160           0 : SgOmpAllocateStatement::initializeStorageClassArray( SgOmpAllocateStatementStorageClass *storageArray )
  140161             :    {
  140162           0 :      unsigned long storageCounter = 0;
  140163           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpAllocateStatement::pools.begin();
  140164           0 :      SgOmpAllocateStatement* pointer = NULL;
  140165           0 :      while ( block != SgOmpAllocateStatement::pools.end() ) {
  140166           0 :           pointer = (SgOmpAllocateStatement*) (*block);
  140167           0 :           for ( unsigned i = 0; i < SgOmpAllocateStatement::pool_size; ++i ) {
  140168           0 :                if ( pointer->get_freepointer() != NULL ) {
  140169           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  140170           0 :                  storageArray++;
  140171           0 :                  storageCounter++;
  140172             :                }
  140173           0 :                pointer++;
  140174             :              }
  140175           0 :            block++;
  140176             :         }
  140177           0 :      return storageCounter;
  140178             :    }
  140179             : 
  140180             : /* #line 140181 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  140181             : 
  140182             : 
  140183             : 
  140184             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  140185             : 
  140186             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  140187             : 
  140188             : //############################################################################
  140189             : /* JH (02/02/2006) Constructor of the IR node SgOmpOrderedDependStatement that takes its 
  140190             :  * corresponding StorageClass as parameter
  140191             :  */
  140192           0 : SgOmpOrderedDependStatement :: SgOmpOrderedDependStatement ( const SgOmpOrderedDependStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  140193             :    {
  140194             : 
  140195             : 
  140196             : /* #line 140197 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  140197             : 
  140198           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  140199             : 
  140200             : 
  140201             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  140202             : 
  140203             : 
  140204           0 :    }
  140205             : 
  140206             : //############################################################################
  140207             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  140208             :  * within the working AST. 
  140209             :  */
  140210           0 : SgOmpOrderedDependStatement * SgOmpOrderedDependStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  140211           0 :      SgOmpOrderedDependStatement* returnPointer = NULL;
  140212           0 :      if ( globalIndex != 0 )
  140213             :         {
  140214             : 
  140215             : #if FILE_IO_EXTRA_CHECK
  140216           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpOrderedDependStatement ) ) <= globalIndex ) ;
  140217           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpOrderedDependStatement + 1 ) ) );
  140218             : #endif
  140219           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpOrderedDependStatement )  
  140220           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpOrderedDependStatement );
  140221           0 :           unsigned long positionInPool = localIndex % SgOmpOrderedDependStatement::pool_size;
  140222           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpOrderedDependStatement::pool_size;
  140223             : 
  140224             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  140225             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  140226             : 
  140227           0 :           returnPointer = &( ( (SgOmpOrderedDependStatement*)(SgOmpOrderedDependStatement::pools[memoryBlock]) ) [positionInPool]) ;
  140228             : 
  140229           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  140230             :         }
  140231           0 :      return returnPointer ;
  140232             :    }
  140233             : 
  140234             : //############################################################################
  140235             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  140236             :   for the AST with the index astIndex
  140237             : */
  140238           0 : SgOmpOrderedDependStatement * SgOmpOrderedDependStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  140239           0 :      SgOmpOrderedDependStatement* returnPointer = NULL;
  140240           0 :      if ( globalIndex != 0 )
  140241             :         {
  140242             : 
  140243             : #if FILE_IO_EXTRA_CHECK
  140244           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpOrderedDependStatement ) ) <= globalIndex ) ;
  140245           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpOrderedDependStatement + 1 ) ) );
  140246             : #endif
  140247           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpOrderedDependStatement )
  140248           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpOrderedDependStatement );
  140249           0 :           unsigned long positionInPool = localIndex % SgOmpOrderedDependStatement::pool_size ;
  140250           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpOrderedDependStatement::pool_size ;
  140251             : 
  140252             : #if FILE_IO_EXTRA_CHECK
  140253             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  140254             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  140255             : #endif
  140256             : 
  140257           0 :           returnPointer = &( ( (SgOmpOrderedDependStatement*)(SgOmpOrderedDependStatement::pools[memoryBlock]) ) [positionInPool]) ;
  140258             : 
  140259             : #if FILE_IO_EXTRA_CHECK
  140260           0 :           assert ( returnPointer != NULL ) ;
  140261             : #endif
  140262             :         }
  140263           0 :      return returnPointer ;
  140264             :    }
  140265             : 
  140266             : //############################################################################
  140267             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  140268             :  * pool size! We set for every valid object in the memory pool the freepointer
  140269             :  * to the global index and increase the global index afterwards. For all the 
  140270             :  * invalid objects (means address ranges within the memory pool that were not
  140271             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  140272             :  * distinguish valid from invalid objects! 
  140273             :  */
  140274             : unsigned long
  140275           5 : SgOmpOrderedDependStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  140276             :    {
  140277           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  140278           5 :      SgOmpOrderedDependStatement* pointer = NULL;
  140279           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  140280           5 :      std::vector < unsigned char* > :: const_iterator block;
  140281           5 :      for ( block = SgOmpOrderedDependStatement::pools.begin(); block != SgOmpOrderedDependStatement::pools.end() ; ++block )
  140282             :         {
  140283           0 :           pointer = (SgOmpOrderedDependStatement*)(*block);
  140284           0 :           for (unsigned i = 0; i < SgOmpOrderedDependStatement::pool_size; ++i )
  140285             :              {
  140286             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  140287             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  140288             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  140289             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  140290             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  140291             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  140292             :             // properly; so this will have to be checked next.
  140293             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  140294             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  140295           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  140296             :                   {
  140297           0 :                     pointer[i].set_freepointer((SgOmpOrderedDependStatement*)(globalIndex));
  140298           0 :                     globalIndex++;
  140299             :                   }
  140300             :                else
  140301             :                   {
  140302           0 :                     pointer[i].set_freepointer(NULL);
  140303             :                   }
  140304             :               }
  140305             :         }
  140306           5 :      return globalIndex;
  140307             :    }
  140308             : 
  140309             : //############################################################################
  140310             : // JH (01/14/2006)
  140311             : void
  140312           5 : SgOmpOrderedDependStatement::resetValidFreepointers( )
  140313             :    {
  140314           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  140315           5 :      SgOmpOrderedDependStatement* pointer = NULL;
  140316           5 :      std::vector < unsigned char* > :: const_iterator block;
  140317           5 :      SgOmpOrderedDependStatement* pointerOfLinkedList = NULL;
  140318           5 :      for ( block = SgOmpOrderedDependStatement::pools.begin(); block != SgOmpOrderedDependStatement::pools.end() ; ++block )
  140319             :         {
  140320           0 :           pointer = (SgOmpOrderedDependStatement*)(*block);
  140321           0 :           for (unsigned i = 0; i < SgOmpOrderedDependStatement::pool_size; ++i )
  140322             :              {
  140323             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  140324             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  140325             :             // memory blocks!.
  140326           0 :                if ( pointer[i].get_freepointer() != NULL )
  140327             :                   {
  140328           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  140329             :                   }
  140330             :                else
  140331             :                   {
  140332           0 :                     if ( pointerOfLinkedList == NULL )
  140333             :                        {
  140334           0 :                          SgOmpOrderedDependStatement::next_node = &(pointer[i]);
  140335             :                        }
  140336             :                     else
  140337             :                        {
  140338             :                       // printf ("In SgOmpOrderedDependStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  140339           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  140340             :                        }
  140341             :                     pointerOfLinkedList = &(pointer[i]);
  140342             :                   }
  140343             :               }
  140344             :         }
  140345             : 
  140346           5 :      if ( pointerOfLinkedList != NULL )
  140347             :         {
  140348             :        // printf ("In SgOmpOrderedDependStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  140349           0 :           pointerOfLinkedList->set_freepointer(NULL);
  140350             :        // DQ (6/6/2010): Temporary debugging...
  140351             :        //   ROSE_ASSERT(false);
  140352             :         }
  140353             : 
  140354           5 :      return ;
  140355             :    }
  140356             : 
  140357             : //############################################################################
  140358             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  140359             :  * within the memory pool and resets the freepointers, in order to achieve a 
  140360             :  * linked list, that has no jumps and starts at the beginning! This function 
  140361             :  * does not extend the memory pool, since we do not delete any memory blocks,
  140362             :  * but delete the valid objects.  
  140363             :  */
  140364             : void
  140365           0 : SgOmpOrderedDependStatement::clearMemoryPool( )
  140366             :    {
  140367             :   // printf ("Inside of SgOmpOrderedDependStatement::clearMemoryPool() \n");
  140368             : 
  140369           0 :      SgOmpOrderedDependStatement* pointer = NULL, *tempPointer = NULL;
  140370           0 :      std::vector < unsigned char* > :: const_iterator block;
  140371           0 :      if ( SgOmpOrderedDependStatement::pools.empty() == false )
  140372             :         {
  140373           0 :           block = SgOmpOrderedDependStatement::pools.begin() ;
  140374           0 :           SgOmpOrderedDependStatement::next_node = (SgOmpOrderedDependStatement*) (*block);
  140375             : 
  140376           0 :           while ( block != SgOmpOrderedDependStatement::pools.end() )
  140377             :              {
  140378           0 :                pointer = (SgOmpOrderedDependStatement*) (*block);
  140379           0 :                if ( tempPointer != NULL )
  140380             :                   {
  140381           0 :                     tempPointer->set_freepointer(pointer);
  140382             :                   }
  140383           0 :                for (unsigned i = 0; i < SgOmpOrderedDependStatement::pool_size - 1; ++i)
  140384             :                   {
  140385           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  140386             :                   }
  140387           0 :                 pointer[SgOmpOrderedDependStatement::pool_size-1].set_freepointer(NULL);
  140388           0 :                 tempPointer = &(pointer[SgOmpOrderedDependStatement::pool_size-1]);
  140389           0 :                 ++block;
  140390             :              }
  140391             :         }
  140392           0 :    }
  140393             : 
  140394           5 : void SgOmpOrderedDependStatement::deleteMemoryPool() {
  140395           5 :   for (auto p: SgOmpOrderedDependStatement::pools) {
  140396           0 :     ROSE_FREE(p);
  140397             :   }
  140398           5 :   SgOmpOrderedDependStatement::next_node = nullptr;
  140399           5 :   SgOmpOrderedDependStatement::pools.clear();
  140400           5 : }
  140401             : 
  140402             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  140403             : //                 reading multiple binary files to for a single AST.
  140404             : /////////// new version ////////////////////////////////
  140405             : //############################################################################
  140406             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  140407             : void
  140408           2 : SgOmpOrderedDependStatement::extendMemoryPoolForFileIO( )
  140409             :   {
  140410           2 :     size_t blockIndex = SgOmpOrderedDependStatement::pools.size();
  140411           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedDependStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedDependStatement);
  140412             : 
  140413           2 :     while ( (blockIndex * SgOmpOrderedDependStatement::pool_size) < newPoolSize)
  140414             :       {
  140415             : #if ROSE_ALLOC_TRACE
  140416             :         if (blockIndex > 0) {
  140417             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedDependStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedDependStatement) = %" PRIuPTR " SgOmpOrderedDependStatement::pool_size = %d \n",
  140418             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpOrderedDependStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpOrderedDependStatement),SgOmpOrderedDependStatement::pool_size);
  140419             :         }
  140420             : #endif
  140421             : 
  140422           0 :         SgOmpOrderedDependStatement * pointer = (SgOmpOrderedDependStatement*) ROSE_MALLOC ( SgOmpOrderedDependStatement::pool_size * sizeof(SgOmpOrderedDependStatement) );
  140423           0 :         assert( pointer != NULL );
  140424             : #if ROSE_ALLOC_MEMSET == 1
  140425             :         memset(pointer, 0x00, SgOmpOrderedDependStatement::pool_size * sizeof(SgOmpOrderedDependStatement));
  140426             : #elif ROSE_ALLOC_MEMSET == 2
  140427             :         memset(pointer, 0xCC, SgOmpOrderedDependStatement::pool_size * sizeof(SgOmpOrderedDependStatement));
  140428             : #endif
  140429           0 :         SgOmpOrderedDependStatement::pools.push_back( (unsigned char*)(pointer) );
  140430           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpOrderedDependStatement::pool_size * sizeof(SgOmpOrderedDependStatement), V_SgOmpOrderedDependStatement ) );
  140431             : 
  140432           0 :         if ( SgOmpOrderedDependStatement::next_node != NULL ) {
  140433           0 :           if ( blockIndex > 0 ) {
  140434           0 :             SgOmpOrderedDependStatement * blkptr = (SgOmpOrderedDependStatement*)(SgOmpOrderedDependStatement::pools[blockIndex-1]);
  140435           0 :             blkptr[ SgOmpOrderedDependStatement::pool_size - 1 ].set_freepointer(pointer);
  140436             :           }
  140437             :         } else {
  140438           0 :           SgOmpOrderedDependStatement::next_node = pointer;
  140439             :         }
  140440             : 
  140441           0 :         for (unsigned i = 0; i < SgOmpOrderedDependStatement::pool_size-1; ++i)
  140442             :            {
  140443           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  140444             :            }
  140445           0 :         pointer[ SgOmpOrderedDependStatement::pool_size -1 ].set_freepointer(NULL);
  140446             : 
  140447           0 :         blockIndex++;
  140448             :       }
  140449           2 :   }
  140450             : 
  140451             : //############################################################################
  140452             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  140453             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  140454             :  * not compressed. However, that stuff is not yet implemented! 
  140455             :  */
  140456             : unsigned long
  140457           0 : SgOmpOrderedDependStatement::getNumberOfLastValidPointer()
  140458             :    {
  140459           0 :       SgOmpOrderedDependStatement* testPointer = (SgOmpOrderedDependStatement*)(SgOmpOrderedDependStatement::pools.back());
  140460           0 :       unsigned long localIndex = SgOmpOrderedDependStatement::pool_size - 1;
  140461           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  140462             :          {
  140463           0 :            localIndex--;
  140464             :          }
  140465           0 :       return (localIndex + SgOmpOrderedDependStatement::pool_size * (SgOmpOrderedDependStatement::pools.size()-1));
  140466             :    }
  140467             : 
  140468             : //############################################################################
  140469             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  140470             :  * memory pool and initializes the data member in class SgOmpOrderedDependStatementStroageClass
  140471             :  * from its counterpart of SgOmpOrderedDependStatement. The return value is just for checking, 
  140472             :  * that the whole StorageClassArray is initialized!
  140473             :  */
  140474             : unsigned long
  140475           0 : SgOmpOrderedDependStatement::initializeStorageClassArray( SgOmpOrderedDependStatementStorageClass *storageArray )
  140476             :    {
  140477           0 :      unsigned long storageCounter = 0;
  140478           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpOrderedDependStatement::pools.begin();
  140479           0 :      SgOmpOrderedDependStatement* pointer = NULL;
  140480           0 :      while ( block != SgOmpOrderedDependStatement::pools.end() ) {
  140481           0 :           pointer = (SgOmpOrderedDependStatement*) (*block);
  140482           0 :           for ( unsigned i = 0; i < SgOmpOrderedDependStatement::pool_size; ++i ) {
  140483           0 :                if ( pointer->get_freepointer() != NULL ) {
  140484           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  140485           0 :                  storageArray++;
  140486           0 :                  storageCounter++;
  140487             :                }
  140488           0 :                pointer++;
  140489             :              }
  140490           0 :            block++;
  140491             :         }
  140492           0 :      return storageCounter;
  140493             :    }
  140494             : 
  140495             : /* #line 140496 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  140496             : 
  140497             : 
  140498             : 
  140499             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  140500             : 
  140501             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  140502             : 
  140503             : //############################################################################
  140504             : /* JH (02/02/2006) Constructor of the IR node SgUpirSyncStatement that takes its 
  140505             :  * corresponding StorageClass as parameter
  140506             :  */
  140507           0 : SgUpirSyncStatement :: SgUpirSyncStatement ( const SgUpirSyncStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  140508             :    {
  140509             : 
  140510             : 
  140511             : /* #line 140512 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  140512             : 
  140513           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  140514             : 
  140515             : 
  140516             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  140517             : 
  140518             : 
  140519           0 :    }
  140520             : 
  140521             : //############################################################################
  140522             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  140523             :  * within the working AST. 
  140524             :  */
  140525           0 : SgUpirSyncStatement * SgUpirSyncStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  140526           0 :      SgUpirSyncStatement* returnPointer = NULL;
  140527           0 :      if ( globalIndex != 0 )
  140528             :         {
  140529             : 
  140530             : #if FILE_IO_EXTRA_CHECK
  140531           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirSyncStatement ) ) <= globalIndex ) ;
  140532           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirSyncStatement + 1 ) ) );
  140533             : #endif
  140534           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirSyncStatement )  
  140535           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirSyncStatement );
  140536           0 :           unsigned long positionInPool = localIndex % SgUpirSyncStatement::pool_size;
  140537           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirSyncStatement::pool_size;
  140538             : 
  140539             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  140540             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  140541             : 
  140542           0 :           returnPointer = &( ( (SgUpirSyncStatement*)(SgUpirSyncStatement::pools[memoryBlock]) ) [positionInPool]) ;
  140543             : 
  140544           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  140545             :         }
  140546           0 :      return returnPointer ;
  140547             :    }
  140548             : 
  140549             : //############################################################################
  140550             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  140551             :   for the AST with the index astIndex
  140552             : */
  140553           0 : SgUpirSyncStatement * SgUpirSyncStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  140554           0 :      SgUpirSyncStatement* returnPointer = NULL;
  140555           0 :      if ( globalIndex != 0 )
  140556             :         {
  140557             : 
  140558             : #if FILE_IO_EXTRA_CHECK
  140559           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirSyncStatement ) ) <= globalIndex ) ;
  140560           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirSyncStatement + 1 ) ) );
  140561             : #endif
  140562           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirSyncStatement )
  140563           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirSyncStatement );
  140564           0 :           unsigned long positionInPool = localIndex % SgUpirSyncStatement::pool_size ;
  140565           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirSyncStatement::pool_size ;
  140566             : 
  140567             : #if FILE_IO_EXTRA_CHECK
  140568             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  140569             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  140570             : #endif
  140571             : 
  140572           0 :           returnPointer = &( ( (SgUpirSyncStatement*)(SgUpirSyncStatement::pools[memoryBlock]) ) [positionInPool]) ;
  140573             : 
  140574             : #if FILE_IO_EXTRA_CHECK
  140575           0 :           assert ( returnPointer != NULL ) ;
  140576             : #endif
  140577             :         }
  140578           0 :      return returnPointer ;
  140579             :    }
  140580             : 
  140581             : //############################################################################
  140582             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  140583             :  * pool size! We set for every valid object in the memory pool the freepointer
  140584             :  * to the global index and increase the global index afterwards. For all the 
  140585             :  * invalid objects (means address ranges within the memory pool that were not
  140586             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  140587             :  * distinguish valid from invalid objects! 
  140588             :  */
  140589             : unsigned long
  140590           5 : SgUpirSyncStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  140591             :    {
  140592           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  140593           5 :      SgUpirSyncStatement* pointer = NULL;
  140594           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  140595           5 :      std::vector < unsigned char* > :: const_iterator block;
  140596           5 :      for ( block = SgUpirSyncStatement::pools.begin(); block != SgUpirSyncStatement::pools.end() ; ++block )
  140597             :         {
  140598           0 :           pointer = (SgUpirSyncStatement*)(*block);
  140599           0 :           for (unsigned i = 0; i < SgUpirSyncStatement::pool_size; ++i )
  140600             :              {
  140601             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  140602             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  140603             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  140604             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  140605             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  140606             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  140607             :             // properly; so this will have to be checked next.
  140608             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  140609             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  140610           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  140611             :                   {
  140612           0 :                     pointer[i].set_freepointer((SgUpirSyncStatement*)(globalIndex));
  140613           0 :                     globalIndex++;
  140614             :                   }
  140615             :                else
  140616             :                   {
  140617           0 :                     pointer[i].set_freepointer(NULL);
  140618             :                   }
  140619             :               }
  140620             :         }
  140621           5 :      return globalIndex;
  140622             :    }
  140623             : 
  140624             : //############################################################################
  140625             : // JH (01/14/2006)
  140626             : void
  140627           5 : SgUpirSyncStatement::resetValidFreepointers( )
  140628             :    {
  140629           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  140630           5 :      SgUpirSyncStatement* pointer = NULL;
  140631           5 :      std::vector < unsigned char* > :: const_iterator block;
  140632           5 :      SgUpirSyncStatement* pointerOfLinkedList = NULL;
  140633           5 :      for ( block = SgUpirSyncStatement::pools.begin(); block != SgUpirSyncStatement::pools.end() ; ++block )
  140634             :         {
  140635           0 :           pointer = (SgUpirSyncStatement*)(*block);
  140636           0 :           for (unsigned i = 0; i < SgUpirSyncStatement::pool_size; ++i )
  140637             :              {
  140638             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  140639             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  140640             :             // memory blocks!.
  140641           0 :                if ( pointer[i].get_freepointer() != NULL )
  140642             :                   {
  140643           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  140644             :                   }
  140645             :                else
  140646             :                   {
  140647           0 :                     if ( pointerOfLinkedList == NULL )
  140648             :                        {
  140649           0 :                          SgUpirSyncStatement::next_node = &(pointer[i]);
  140650             :                        }
  140651             :                     else
  140652             :                        {
  140653             :                       // printf ("In SgUpirSyncStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  140654           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  140655             :                        }
  140656             :                     pointerOfLinkedList = &(pointer[i]);
  140657             :                   }
  140658             :               }
  140659             :         }
  140660             : 
  140661           5 :      if ( pointerOfLinkedList != NULL )
  140662             :         {
  140663             :        // printf ("In SgUpirSyncStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  140664           0 :           pointerOfLinkedList->set_freepointer(NULL);
  140665             :        // DQ (6/6/2010): Temporary debugging...
  140666             :        //   ROSE_ASSERT(false);
  140667             :         }
  140668             : 
  140669           5 :      return ;
  140670             :    }
  140671             : 
  140672             : //############################################################################
  140673             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  140674             :  * within the memory pool and resets the freepointers, in order to achieve a 
  140675             :  * linked list, that has no jumps and starts at the beginning! This function 
  140676             :  * does not extend the memory pool, since we do not delete any memory blocks,
  140677             :  * but delete the valid objects.  
  140678             :  */
  140679             : void
  140680           0 : SgUpirSyncStatement::clearMemoryPool( )
  140681             :    {
  140682             :   // printf ("Inside of SgUpirSyncStatement::clearMemoryPool() \n");
  140683             : 
  140684           0 :      SgUpirSyncStatement* pointer = NULL, *tempPointer = NULL;
  140685           0 :      std::vector < unsigned char* > :: const_iterator block;
  140686           0 :      if ( SgUpirSyncStatement::pools.empty() == false )
  140687             :         {
  140688           0 :           block = SgUpirSyncStatement::pools.begin() ;
  140689           0 :           SgUpirSyncStatement::next_node = (SgUpirSyncStatement*) (*block);
  140690             : 
  140691           0 :           while ( block != SgUpirSyncStatement::pools.end() )
  140692             :              {
  140693           0 :                pointer = (SgUpirSyncStatement*) (*block);
  140694           0 :                if ( tempPointer != NULL )
  140695             :                   {
  140696           0 :                     tempPointer->set_freepointer(pointer);
  140697             :                   }
  140698           0 :                for (unsigned i = 0; i < SgUpirSyncStatement::pool_size - 1; ++i)
  140699             :                   {
  140700           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  140701             :                   }
  140702           0 :                 pointer[SgUpirSyncStatement::pool_size-1].set_freepointer(NULL);
  140703           0 :                 tempPointer = &(pointer[SgUpirSyncStatement::pool_size-1]);
  140704           0 :                 ++block;
  140705             :              }
  140706             :         }
  140707           0 :    }
  140708             : 
  140709           5 : void SgUpirSyncStatement::deleteMemoryPool() {
  140710           5 :   for (auto p: SgUpirSyncStatement::pools) {
  140711           0 :     ROSE_FREE(p);
  140712             :   }
  140713           5 :   SgUpirSyncStatement::next_node = nullptr;
  140714           5 :   SgUpirSyncStatement::pools.clear();
  140715           5 : }
  140716             : 
  140717             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  140718             : //                 reading multiple binary files to for a single AST.
  140719             : /////////// new version ////////////////////////////////
  140720             : //############################################################################
  140721             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  140722             : void
  140723           2 : SgUpirSyncStatement::extendMemoryPoolForFileIO( )
  140724             :   {
  140725           2 :     size_t blockIndex = SgUpirSyncStatement::pools.size();
  140726           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSyncStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSyncStatement);
  140727             : 
  140728           2 :     while ( (blockIndex * SgUpirSyncStatement::pool_size) < newPoolSize)
  140729             :       {
  140730             : #if ROSE_ALLOC_TRACE
  140731             :         if (blockIndex > 0) {
  140732             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSyncStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSyncStatement) = %" PRIuPTR " SgUpirSyncStatement::pool_size = %d \n",
  140733             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSyncStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSyncStatement),SgUpirSyncStatement::pool_size);
  140734             :         }
  140735             : #endif
  140736             : 
  140737           0 :         SgUpirSyncStatement * pointer = (SgUpirSyncStatement*) ROSE_MALLOC ( SgUpirSyncStatement::pool_size * sizeof(SgUpirSyncStatement) );
  140738           0 :         assert( pointer != NULL );
  140739             : #if ROSE_ALLOC_MEMSET == 1
  140740             :         memset(pointer, 0x00, SgUpirSyncStatement::pool_size * sizeof(SgUpirSyncStatement));
  140741             : #elif ROSE_ALLOC_MEMSET == 2
  140742             :         memset(pointer, 0xCC, SgUpirSyncStatement::pool_size * sizeof(SgUpirSyncStatement));
  140743             : #endif
  140744           0 :         SgUpirSyncStatement::pools.push_back( (unsigned char*)(pointer) );
  140745           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirSyncStatement::pool_size * sizeof(SgUpirSyncStatement), V_SgUpirSyncStatement ) );
  140746             : 
  140747           0 :         if ( SgUpirSyncStatement::next_node != NULL ) {
  140748           0 :           if ( blockIndex > 0 ) {
  140749           0 :             SgUpirSyncStatement * blkptr = (SgUpirSyncStatement*)(SgUpirSyncStatement::pools[blockIndex-1]);
  140750           0 :             blkptr[ SgUpirSyncStatement::pool_size - 1 ].set_freepointer(pointer);
  140751             :           }
  140752             :         } else {
  140753           0 :           SgUpirSyncStatement::next_node = pointer;
  140754             :         }
  140755             : 
  140756           0 :         for (unsigned i = 0; i < SgUpirSyncStatement::pool_size-1; ++i)
  140757             :            {
  140758           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  140759             :            }
  140760           0 :         pointer[ SgUpirSyncStatement::pool_size -1 ].set_freepointer(NULL);
  140761             : 
  140762           0 :         blockIndex++;
  140763             :       }
  140764           2 :   }
  140765             : 
  140766             : //############################################################################
  140767             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  140768             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  140769             :  * not compressed. However, that stuff is not yet implemented! 
  140770             :  */
  140771             : unsigned long
  140772           0 : SgUpirSyncStatement::getNumberOfLastValidPointer()
  140773             :    {
  140774           0 :       SgUpirSyncStatement* testPointer = (SgUpirSyncStatement*)(SgUpirSyncStatement::pools.back());
  140775           0 :       unsigned long localIndex = SgUpirSyncStatement::pool_size - 1;
  140776           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  140777             :          {
  140778           0 :            localIndex--;
  140779             :          }
  140780           0 :       return (localIndex + SgUpirSyncStatement::pool_size * (SgUpirSyncStatement::pools.size()-1));
  140781             :    }
  140782             : 
  140783             : //############################################################################
  140784             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  140785             :  * memory pool and initializes the data member in class SgUpirSyncStatementStroageClass
  140786             :  * from its counterpart of SgUpirSyncStatement. The return value is just for checking, 
  140787             :  * that the whole StorageClassArray is initialized!
  140788             :  */
  140789             : unsigned long
  140790           0 : SgUpirSyncStatement::initializeStorageClassArray( SgUpirSyncStatementStorageClass *storageArray )
  140791             :    {
  140792           0 :      unsigned long storageCounter = 0;
  140793           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirSyncStatement::pools.begin();
  140794           0 :      SgUpirSyncStatement* pointer = NULL;
  140795           0 :      while ( block != SgUpirSyncStatement::pools.end() ) {
  140796           0 :           pointer = (SgUpirSyncStatement*) (*block);
  140797           0 :           for ( unsigned i = 0; i < SgUpirSyncStatement::pool_size; ++i ) {
  140798           0 :                if ( pointer->get_freepointer() != NULL ) {
  140799           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  140800           0 :                  storageArray++;
  140801           0 :                  storageCounter++;
  140802             :                }
  140803           0 :                pointer++;
  140804             :              }
  140805           0 :            block++;
  140806             :         }
  140807           0 :      return storageCounter;
  140808             :    }
  140809             : 
  140810             : /* #line 140811 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  140811             : 
  140812             : 
  140813             : 
  140814             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  140815             : 
  140816             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  140817             : 
  140818             : //############################################################################
  140819             : /* JH (02/02/2006) Constructor of the IR node SgUpirLoopParallelStatement that takes its 
  140820             :  * corresponding StorageClass as parameter
  140821             :  */
  140822           0 : SgUpirLoopParallelStatement :: SgUpirLoopParallelStatement ( const SgUpirLoopParallelStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  140823             :    {
  140824             : 
  140825             : 
  140826             : /* #line 140827 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  140827             : 
  140828           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  140829           0 :      p_worksharing =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_worksharing) );
  140830           0 :      p_simd =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_simd) );
  140831           0 :      p_taskloop =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_taskloop) );
  140832           0 :      p_loop =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_loop) );
  140833             : 
  140834             : 
  140835             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  140836             : 
  140837             : 
  140838           0 :    }
  140839             : 
  140840             : //############################################################################
  140841             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  140842             :  * within the working AST. 
  140843             :  */
  140844           0 : SgUpirLoopParallelStatement * SgUpirLoopParallelStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  140845           0 :      SgUpirLoopParallelStatement* returnPointer = NULL;
  140846           0 :      if ( globalIndex != 0 )
  140847             :         {
  140848             : 
  140849             : #if FILE_IO_EXTRA_CHECK
  140850           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirLoopParallelStatement ) ) <= globalIndex ) ;
  140851           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirLoopParallelStatement + 1 ) ) );
  140852             : #endif
  140853           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirLoopParallelStatement )  
  140854           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirLoopParallelStatement );
  140855           0 :           unsigned long positionInPool = localIndex % SgUpirLoopParallelStatement::pool_size;
  140856           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirLoopParallelStatement::pool_size;
  140857             : 
  140858             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  140859             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  140860             : 
  140861           0 :           returnPointer = &( ( (SgUpirLoopParallelStatement*)(SgUpirLoopParallelStatement::pools[memoryBlock]) ) [positionInPool]) ;
  140862             : 
  140863           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  140864             :         }
  140865           0 :      return returnPointer ;
  140866             :    }
  140867             : 
  140868             : //############################################################################
  140869             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  140870             :   for the AST with the index astIndex
  140871             : */
  140872           0 : SgUpirLoopParallelStatement * SgUpirLoopParallelStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  140873           0 :      SgUpirLoopParallelStatement* returnPointer = NULL;
  140874           0 :      if ( globalIndex != 0 )
  140875             :         {
  140876             : 
  140877             : #if FILE_IO_EXTRA_CHECK
  140878           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirLoopParallelStatement ) ) <= globalIndex ) ;
  140879           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirLoopParallelStatement + 1 ) ) );
  140880             : #endif
  140881           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirLoopParallelStatement )
  140882           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirLoopParallelStatement );
  140883           0 :           unsigned long positionInPool = localIndex % SgUpirLoopParallelStatement::pool_size ;
  140884           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirLoopParallelStatement::pool_size ;
  140885             : 
  140886             : #if FILE_IO_EXTRA_CHECK
  140887             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  140888             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  140889             : #endif
  140890             : 
  140891           0 :           returnPointer = &( ( (SgUpirLoopParallelStatement*)(SgUpirLoopParallelStatement::pools[memoryBlock]) ) [positionInPool]) ;
  140892             : 
  140893             : #if FILE_IO_EXTRA_CHECK
  140894           0 :           assert ( returnPointer != NULL ) ;
  140895             : #endif
  140896             :         }
  140897           0 :      return returnPointer ;
  140898             :    }
  140899             : 
  140900             : //############################################################################
  140901             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  140902             :  * pool size! We set for every valid object in the memory pool the freepointer
  140903             :  * to the global index and increase the global index afterwards. For all the 
  140904             :  * invalid objects (means address ranges within the memory pool that were not
  140905             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  140906             :  * distinguish valid from invalid objects! 
  140907             :  */
  140908             : unsigned long
  140909           5 : SgUpirLoopParallelStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  140910             :    {
  140911           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  140912           5 :      SgUpirLoopParallelStatement* pointer = NULL;
  140913           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  140914           5 :      std::vector < unsigned char* > :: const_iterator block;
  140915           5 :      for ( block = SgUpirLoopParallelStatement::pools.begin(); block != SgUpirLoopParallelStatement::pools.end() ; ++block )
  140916             :         {
  140917           0 :           pointer = (SgUpirLoopParallelStatement*)(*block);
  140918           0 :           for (unsigned i = 0; i < SgUpirLoopParallelStatement::pool_size; ++i )
  140919             :              {
  140920             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  140921             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  140922             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  140923             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  140924             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  140925             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  140926             :             // properly; so this will have to be checked next.
  140927             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  140928             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  140929           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  140930             :                   {
  140931           0 :                     pointer[i].set_freepointer((SgUpirLoopParallelStatement*)(globalIndex));
  140932           0 :                     globalIndex++;
  140933             :                   }
  140934             :                else
  140935             :                   {
  140936           0 :                     pointer[i].set_freepointer(NULL);
  140937             :                   }
  140938             :               }
  140939             :         }
  140940           5 :      return globalIndex;
  140941             :    }
  140942             : 
  140943             : //############################################################################
  140944             : // JH (01/14/2006)
  140945             : void
  140946           5 : SgUpirLoopParallelStatement::resetValidFreepointers( )
  140947             :    {
  140948           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  140949           5 :      SgUpirLoopParallelStatement* pointer = NULL;
  140950           5 :      std::vector < unsigned char* > :: const_iterator block;
  140951           5 :      SgUpirLoopParallelStatement* pointerOfLinkedList = NULL;
  140952           5 :      for ( block = SgUpirLoopParallelStatement::pools.begin(); block != SgUpirLoopParallelStatement::pools.end() ; ++block )
  140953             :         {
  140954           0 :           pointer = (SgUpirLoopParallelStatement*)(*block);
  140955           0 :           for (unsigned i = 0; i < SgUpirLoopParallelStatement::pool_size; ++i )
  140956             :              {
  140957             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  140958             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  140959             :             // memory blocks!.
  140960           0 :                if ( pointer[i].get_freepointer() != NULL )
  140961             :                   {
  140962           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  140963             :                   }
  140964             :                else
  140965             :                   {
  140966           0 :                     if ( pointerOfLinkedList == NULL )
  140967             :                        {
  140968           0 :                          SgUpirLoopParallelStatement::next_node = &(pointer[i]);
  140969             :                        }
  140970             :                     else
  140971             :                        {
  140972             :                       // printf ("In SgUpirLoopParallelStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  140973           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  140974             :                        }
  140975             :                     pointerOfLinkedList = &(pointer[i]);
  140976             :                   }
  140977             :               }
  140978             :         }
  140979             : 
  140980           5 :      if ( pointerOfLinkedList != NULL )
  140981             :         {
  140982             :        // printf ("In SgUpirLoopParallelStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  140983           0 :           pointerOfLinkedList->set_freepointer(NULL);
  140984             :        // DQ (6/6/2010): Temporary debugging...
  140985             :        //   ROSE_ASSERT(false);
  140986             :         }
  140987             : 
  140988           5 :      return ;
  140989             :    }
  140990             : 
  140991             : //############################################################################
  140992             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  140993             :  * within the memory pool and resets the freepointers, in order to achieve a 
  140994             :  * linked list, that has no jumps and starts at the beginning! This function 
  140995             :  * does not extend the memory pool, since we do not delete any memory blocks,
  140996             :  * but delete the valid objects.  
  140997             :  */
  140998             : void
  140999           0 : SgUpirLoopParallelStatement::clearMemoryPool( )
  141000             :    {
  141001             :   // printf ("Inside of SgUpirLoopParallelStatement::clearMemoryPool() \n");
  141002             : 
  141003           0 :      SgUpirLoopParallelStatement* pointer = NULL, *tempPointer = NULL;
  141004           0 :      std::vector < unsigned char* > :: const_iterator block;
  141005           0 :      if ( SgUpirLoopParallelStatement::pools.empty() == false )
  141006             :         {
  141007           0 :           block = SgUpirLoopParallelStatement::pools.begin() ;
  141008           0 :           SgUpirLoopParallelStatement::next_node = (SgUpirLoopParallelStatement*) (*block);
  141009             : 
  141010           0 :           while ( block != SgUpirLoopParallelStatement::pools.end() )
  141011             :              {
  141012           0 :                pointer = (SgUpirLoopParallelStatement*) (*block);
  141013           0 :                if ( tempPointer != NULL )
  141014             :                   {
  141015           0 :                     tempPointer->set_freepointer(pointer);
  141016             :                   }
  141017           0 :                for (unsigned i = 0; i < SgUpirLoopParallelStatement::pool_size - 1; ++i)
  141018             :                   {
  141019           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  141020             :                   }
  141021           0 :                 pointer[SgUpirLoopParallelStatement::pool_size-1].set_freepointer(NULL);
  141022           0 :                 tempPointer = &(pointer[SgUpirLoopParallelStatement::pool_size-1]);
  141023           0 :                 ++block;
  141024             :              }
  141025             :         }
  141026           0 :    }
  141027             : 
  141028           5 : void SgUpirLoopParallelStatement::deleteMemoryPool() {
  141029           5 :   for (auto p: SgUpirLoopParallelStatement::pools) {
  141030           0 :     ROSE_FREE(p);
  141031             :   }
  141032           5 :   SgUpirLoopParallelStatement::next_node = nullptr;
  141033           5 :   SgUpirLoopParallelStatement::pools.clear();
  141034           5 : }
  141035             : 
  141036             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  141037             : //                 reading multiple binary files to for a single AST.
  141038             : /////////// new version ////////////////////////////////
  141039             : //############################################################################
  141040             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  141041             : void
  141042           2 : SgUpirLoopParallelStatement::extendMemoryPoolForFileIO( )
  141043             :   {
  141044           2 :     size_t blockIndex = SgUpirLoopParallelStatement::pools.size();
  141045           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirLoopParallelStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirLoopParallelStatement);
  141046             : 
  141047           2 :     while ( (blockIndex * SgUpirLoopParallelStatement::pool_size) < newPoolSize)
  141048             :       {
  141049             : #if ROSE_ALLOC_TRACE
  141050             :         if (blockIndex > 0) {
  141051             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirLoopParallelStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirLoopParallelStatement) = %" PRIuPTR " SgUpirLoopParallelStatement::pool_size = %d \n",
  141052             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirLoopParallelStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirLoopParallelStatement),SgUpirLoopParallelStatement::pool_size);
  141053             :         }
  141054             : #endif
  141055             : 
  141056           0 :         SgUpirLoopParallelStatement * pointer = (SgUpirLoopParallelStatement*) ROSE_MALLOC ( SgUpirLoopParallelStatement::pool_size * sizeof(SgUpirLoopParallelStatement) );
  141057           0 :         assert( pointer != NULL );
  141058             : #if ROSE_ALLOC_MEMSET == 1
  141059             :         memset(pointer, 0x00, SgUpirLoopParallelStatement::pool_size * sizeof(SgUpirLoopParallelStatement));
  141060             : #elif ROSE_ALLOC_MEMSET == 2
  141061             :         memset(pointer, 0xCC, SgUpirLoopParallelStatement::pool_size * sizeof(SgUpirLoopParallelStatement));
  141062             : #endif
  141063           0 :         SgUpirLoopParallelStatement::pools.push_back( (unsigned char*)(pointer) );
  141064           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirLoopParallelStatement::pool_size * sizeof(SgUpirLoopParallelStatement), V_SgUpirLoopParallelStatement ) );
  141065             : 
  141066           0 :         if ( SgUpirLoopParallelStatement::next_node != NULL ) {
  141067           0 :           if ( blockIndex > 0 ) {
  141068           0 :             SgUpirLoopParallelStatement * blkptr = (SgUpirLoopParallelStatement*)(SgUpirLoopParallelStatement::pools[blockIndex-1]);
  141069           0 :             blkptr[ SgUpirLoopParallelStatement::pool_size - 1 ].set_freepointer(pointer);
  141070             :           }
  141071             :         } else {
  141072           0 :           SgUpirLoopParallelStatement::next_node = pointer;
  141073             :         }
  141074             : 
  141075           0 :         for (unsigned i = 0; i < SgUpirLoopParallelStatement::pool_size-1; ++i)
  141076             :            {
  141077           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  141078             :            }
  141079           0 :         pointer[ SgUpirLoopParallelStatement::pool_size -1 ].set_freepointer(NULL);
  141080             : 
  141081           0 :         blockIndex++;
  141082             :       }
  141083           2 :   }
  141084             : 
  141085             : //############################################################################
  141086             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  141087             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  141088             :  * not compressed. However, that stuff is not yet implemented! 
  141089             :  */
  141090             : unsigned long
  141091           0 : SgUpirLoopParallelStatement::getNumberOfLastValidPointer()
  141092             :    {
  141093           0 :       SgUpirLoopParallelStatement* testPointer = (SgUpirLoopParallelStatement*)(SgUpirLoopParallelStatement::pools.back());
  141094           0 :       unsigned long localIndex = SgUpirLoopParallelStatement::pool_size - 1;
  141095           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  141096             :          {
  141097           0 :            localIndex--;
  141098             :          }
  141099           0 :       return (localIndex + SgUpirLoopParallelStatement::pool_size * (SgUpirLoopParallelStatement::pools.size()-1));
  141100             :    }
  141101             : 
  141102             : //############################################################################
  141103             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  141104             :  * memory pool and initializes the data member in class SgUpirLoopParallelStatementStroageClass
  141105             :  * from its counterpart of SgUpirLoopParallelStatement. The return value is just for checking, 
  141106             :  * that the whole StorageClassArray is initialized!
  141107             :  */
  141108             : unsigned long
  141109           0 : SgUpirLoopParallelStatement::initializeStorageClassArray( SgUpirLoopParallelStatementStorageClass *storageArray )
  141110             :    {
  141111           0 :      unsigned long storageCounter = 0;
  141112           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirLoopParallelStatement::pools.begin();
  141113           0 :      SgUpirLoopParallelStatement* pointer = NULL;
  141114           0 :      while ( block != SgUpirLoopParallelStatement::pools.end() ) {
  141115           0 :           pointer = (SgUpirLoopParallelStatement*) (*block);
  141116           0 :           for ( unsigned i = 0; i < SgUpirLoopParallelStatement::pool_size; ++i ) {
  141117           0 :                if ( pointer->get_freepointer() != NULL ) {
  141118           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  141119           0 :                  storageArray++;
  141120           0 :                  storageCounter++;
  141121             :                }
  141122           0 :                pointer++;
  141123             :              }
  141124           0 :            block++;
  141125             :         }
  141126           0 :      return storageCounter;
  141127             :    }
  141128             : 
  141129             : /* #line 141130 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  141130             : 
  141131             : 
  141132             : 
  141133             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  141134             : 
  141135             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  141136             : 
  141137             : //############################################################################
  141138             : /* JH (02/02/2006) Constructor of the IR node SgUpirWorksharingStatement that takes its 
  141139             :  * corresponding StorageClass as parameter
  141140             :  */
  141141           0 : SgUpirWorksharingStatement :: SgUpirWorksharingStatement ( const SgUpirWorksharingStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  141142             :    {
  141143             : 
  141144             : 
  141145             : /* #line 141146 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  141146             : 
  141147           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  141148             : 
  141149             : 
  141150             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  141151             : 
  141152             : 
  141153           0 :    }
  141154             : 
  141155             : //############################################################################
  141156             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  141157             :  * within the working AST. 
  141158             :  */
  141159           0 : SgUpirWorksharingStatement * SgUpirWorksharingStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  141160           0 :      SgUpirWorksharingStatement* returnPointer = NULL;
  141161           0 :      if ( globalIndex != 0 )
  141162             :         {
  141163             : 
  141164             : #if FILE_IO_EXTRA_CHECK
  141165           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirWorksharingStatement ) ) <= globalIndex ) ;
  141166           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirWorksharingStatement + 1 ) ) );
  141167             : #endif
  141168           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirWorksharingStatement )  
  141169           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirWorksharingStatement );
  141170           0 :           unsigned long positionInPool = localIndex % SgUpirWorksharingStatement::pool_size;
  141171           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirWorksharingStatement::pool_size;
  141172             : 
  141173             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  141174             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  141175             : 
  141176           0 :           returnPointer = &( ( (SgUpirWorksharingStatement*)(SgUpirWorksharingStatement::pools[memoryBlock]) ) [positionInPool]) ;
  141177             : 
  141178           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  141179             :         }
  141180           0 :      return returnPointer ;
  141181             :    }
  141182             : 
  141183             : //############################################################################
  141184             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  141185             :   for the AST with the index astIndex
  141186             : */
  141187           0 : SgUpirWorksharingStatement * SgUpirWorksharingStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  141188           0 :      SgUpirWorksharingStatement* returnPointer = NULL;
  141189           0 :      if ( globalIndex != 0 )
  141190             :         {
  141191             : 
  141192             : #if FILE_IO_EXTRA_CHECK
  141193           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirWorksharingStatement ) ) <= globalIndex ) ;
  141194           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirWorksharingStatement + 1 ) ) );
  141195             : #endif
  141196           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirWorksharingStatement )
  141197           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirWorksharingStatement );
  141198           0 :           unsigned long positionInPool = localIndex % SgUpirWorksharingStatement::pool_size ;
  141199           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirWorksharingStatement::pool_size ;
  141200             : 
  141201             : #if FILE_IO_EXTRA_CHECK
  141202             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  141203             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  141204             : #endif
  141205             : 
  141206           0 :           returnPointer = &( ( (SgUpirWorksharingStatement*)(SgUpirWorksharingStatement::pools[memoryBlock]) ) [positionInPool]) ;
  141207             : 
  141208             : #if FILE_IO_EXTRA_CHECK
  141209           0 :           assert ( returnPointer != NULL ) ;
  141210             : #endif
  141211             :         }
  141212           0 :      return returnPointer ;
  141213             :    }
  141214             : 
  141215             : //############################################################################
  141216             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  141217             :  * pool size! We set for every valid object in the memory pool the freepointer
  141218             :  * to the global index and increase the global index afterwards. For all the 
  141219             :  * invalid objects (means address ranges within the memory pool that were not
  141220             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  141221             :  * distinguish valid from invalid objects! 
  141222             :  */
  141223             : unsigned long
  141224           5 : SgUpirWorksharingStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  141225             :    {
  141226           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  141227           5 :      SgUpirWorksharingStatement* pointer = NULL;
  141228           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  141229           5 :      std::vector < unsigned char* > :: const_iterator block;
  141230           5 :      for ( block = SgUpirWorksharingStatement::pools.begin(); block != SgUpirWorksharingStatement::pools.end() ; ++block )
  141231             :         {
  141232           0 :           pointer = (SgUpirWorksharingStatement*)(*block);
  141233           0 :           for (unsigned i = 0; i < SgUpirWorksharingStatement::pool_size; ++i )
  141234             :              {
  141235             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  141236             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  141237             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  141238             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  141239             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  141240             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  141241             :             // properly; so this will have to be checked next.
  141242             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  141243             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  141244           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  141245             :                   {
  141246           0 :                     pointer[i].set_freepointer((SgUpirWorksharingStatement*)(globalIndex));
  141247           0 :                     globalIndex++;
  141248             :                   }
  141249             :                else
  141250             :                   {
  141251           0 :                     pointer[i].set_freepointer(NULL);
  141252             :                   }
  141253             :               }
  141254             :         }
  141255           5 :      return globalIndex;
  141256             :    }
  141257             : 
  141258             : //############################################################################
  141259             : // JH (01/14/2006)
  141260             : void
  141261           5 : SgUpirWorksharingStatement::resetValidFreepointers( )
  141262             :    {
  141263           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  141264           5 :      SgUpirWorksharingStatement* pointer = NULL;
  141265           5 :      std::vector < unsigned char* > :: const_iterator block;
  141266           5 :      SgUpirWorksharingStatement* pointerOfLinkedList = NULL;
  141267           5 :      for ( block = SgUpirWorksharingStatement::pools.begin(); block != SgUpirWorksharingStatement::pools.end() ; ++block )
  141268             :         {
  141269           0 :           pointer = (SgUpirWorksharingStatement*)(*block);
  141270           0 :           for (unsigned i = 0; i < SgUpirWorksharingStatement::pool_size; ++i )
  141271             :              {
  141272             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  141273             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  141274             :             // memory blocks!.
  141275           0 :                if ( pointer[i].get_freepointer() != NULL )
  141276             :                   {
  141277           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  141278             :                   }
  141279             :                else
  141280             :                   {
  141281           0 :                     if ( pointerOfLinkedList == NULL )
  141282             :                        {
  141283           0 :                          SgUpirWorksharingStatement::next_node = &(pointer[i]);
  141284             :                        }
  141285             :                     else
  141286             :                        {
  141287             :                       // printf ("In SgUpirWorksharingStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  141288           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  141289             :                        }
  141290             :                     pointerOfLinkedList = &(pointer[i]);
  141291             :                   }
  141292             :               }
  141293             :         }
  141294             : 
  141295           5 :      if ( pointerOfLinkedList != NULL )
  141296             :         {
  141297             :        // printf ("In SgUpirWorksharingStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  141298           0 :           pointerOfLinkedList->set_freepointer(NULL);
  141299             :        // DQ (6/6/2010): Temporary debugging...
  141300             :        //   ROSE_ASSERT(false);
  141301             :         }
  141302             : 
  141303           5 :      return ;
  141304             :    }
  141305             : 
  141306             : //############################################################################
  141307             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  141308             :  * within the memory pool and resets the freepointers, in order to achieve a 
  141309             :  * linked list, that has no jumps and starts at the beginning! This function 
  141310             :  * does not extend the memory pool, since we do not delete any memory blocks,
  141311             :  * but delete the valid objects.  
  141312             :  */
  141313             : void
  141314           0 : SgUpirWorksharingStatement::clearMemoryPool( )
  141315             :    {
  141316             :   // printf ("Inside of SgUpirWorksharingStatement::clearMemoryPool() \n");
  141317             : 
  141318           0 :      SgUpirWorksharingStatement* pointer = NULL, *tempPointer = NULL;
  141319           0 :      std::vector < unsigned char* > :: const_iterator block;
  141320           0 :      if ( SgUpirWorksharingStatement::pools.empty() == false )
  141321             :         {
  141322           0 :           block = SgUpirWorksharingStatement::pools.begin() ;
  141323           0 :           SgUpirWorksharingStatement::next_node = (SgUpirWorksharingStatement*) (*block);
  141324             : 
  141325           0 :           while ( block != SgUpirWorksharingStatement::pools.end() )
  141326             :              {
  141327           0 :                pointer = (SgUpirWorksharingStatement*) (*block);
  141328           0 :                if ( tempPointer != NULL )
  141329             :                   {
  141330           0 :                     tempPointer->set_freepointer(pointer);
  141331             :                   }
  141332           0 :                for (unsigned i = 0; i < SgUpirWorksharingStatement::pool_size - 1; ++i)
  141333             :                   {
  141334           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  141335             :                   }
  141336           0 :                 pointer[SgUpirWorksharingStatement::pool_size-1].set_freepointer(NULL);
  141337           0 :                 tempPointer = &(pointer[SgUpirWorksharingStatement::pool_size-1]);
  141338           0 :                 ++block;
  141339             :              }
  141340             :         }
  141341           0 :    }
  141342             : 
  141343           5 : void SgUpirWorksharingStatement::deleteMemoryPool() {
  141344           5 :   for (auto p: SgUpirWorksharingStatement::pools) {
  141345           0 :     ROSE_FREE(p);
  141346             :   }
  141347           5 :   SgUpirWorksharingStatement::next_node = nullptr;
  141348           5 :   SgUpirWorksharingStatement::pools.clear();
  141349           5 : }
  141350             : 
  141351             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  141352             : //                 reading multiple binary files to for a single AST.
  141353             : /////////// new version ////////////////////////////////
  141354             : //############################################################################
  141355             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  141356             : void
  141357           2 : SgUpirWorksharingStatement::extendMemoryPoolForFileIO( )
  141358             :   {
  141359           2 :     size_t blockIndex = SgUpirWorksharingStatement::pools.size();
  141360           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirWorksharingStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirWorksharingStatement);
  141361             : 
  141362           2 :     while ( (blockIndex * SgUpirWorksharingStatement::pool_size) < newPoolSize)
  141363             :       {
  141364             : #if ROSE_ALLOC_TRACE
  141365             :         if (blockIndex > 0) {
  141366             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirWorksharingStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirWorksharingStatement) = %" PRIuPTR " SgUpirWorksharingStatement::pool_size = %d \n",
  141367             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirWorksharingStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirWorksharingStatement),SgUpirWorksharingStatement::pool_size);
  141368             :         }
  141369             : #endif
  141370             : 
  141371           0 :         SgUpirWorksharingStatement * pointer = (SgUpirWorksharingStatement*) ROSE_MALLOC ( SgUpirWorksharingStatement::pool_size * sizeof(SgUpirWorksharingStatement) );
  141372           0 :         assert( pointer != NULL );
  141373             : #if ROSE_ALLOC_MEMSET == 1
  141374             :         memset(pointer, 0x00, SgUpirWorksharingStatement::pool_size * sizeof(SgUpirWorksharingStatement));
  141375             : #elif ROSE_ALLOC_MEMSET == 2
  141376             :         memset(pointer, 0xCC, SgUpirWorksharingStatement::pool_size * sizeof(SgUpirWorksharingStatement));
  141377             : #endif
  141378           0 :         SgUpirWorksharingStatement::pools.push_back( (unsigned char*)(pointer) );
  141379           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirWorksharingStatement::pool_size * sizeof(SgUpirWorksharingStatement), V_SgUpirWorksharingStatement ) );
  141380             : 
  141381           0 :         if ( SgUpirWorksharingStatement::next_node != NULL ) {
  141382           0 :           if ( blockIndex > 0 ) {
  141383           0 :             SgUpirWorksharingStatement * blkptr = (SgUpirWorksharingStatement*)(SgUpirWorksharingStatement::pools[blockIndex-1]);
  141384           0 :             blkptr[ SgUpirWorksharingStatement::pool_size - 1 ].set_freepointer(pointer);
  141385             :           }
  141386             :         } else {
  141387           0 :           SgUpirWorksharingStatement::next_node = pointer;
  141388             :         }
  141389             : 
  141390           0 :         for (unsigned i = 0; i < SgUpirWorksharingStatement::pool_size-1; ++i)
  141391             :            {
  141392           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  141393             :            }
  141394           0 :         pointer[ SgUpirWorksharingStatement::pool_size -1 ].set_freepointer(NULL);
  141395             : 
  141396           0 :         blockIndex++;
  141397             :       }
  141398           2 :   }
  141399             : 
  141400             : //############################################################################
  141401             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  141402             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  141403             :  * not compressed. However, that stuff is not yet implemented! 
  141404             :  */
  141405             : unsigned long
  141406           0 : SgUpirWorksharingStatement::getNumberOfLastValidPointer()
  141407             :    {
  141408           0 :       SgUpirWorksharingStatement* testPointer = (SgUpirWorksharingStatement*)(SgUpirWorksharingStatement::pools.back());
  141409           0 :       unsigned long localIndex = SgUpirWorksharingStatement::pool_size - 1;
  141410           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  141411             :          {
  141412           0 :            localIndex--;
  141413             :          }
  141414           0 :       return (localIndex + SgUpirWorksharingStatement::pool_size * (SgUpirWorksharingStatement::pools.size()-1));
  141415             :    }
  141416             : 
  141417             : //############################################################################
  141418             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  141419             :  * memory pool and initializes the data member in class SgUpirWorksharingStatementStroageClass
  141420             :  * from its counterpart of SgUpirWorksharingStatement. The return value is just for checking, 
  141421             :  * that the whole StorageClassArray is initialized!
  141422             :  */
  141423             : unsigned long
  141424           0 : SgUpirWorksharingStatement::initializeStorageClassArray( SgUpirWorksharingStatementStorageClass *storageArray )
  141425             :    {
  141426           0 :      unsigned long storageCounter = 0;
  141427           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirWorksharingStatement::pools.begin();
  141428           0 :      SgUpirWorksharingStatement* pointer = NULL;
  141429           0 :      while ( block != SgUpirWorksharingStatement::pools.end() ) {
  141430           0 :           pointer = (SgUpirWorksharingStatement*) (*block);
  141431           0 :           for ( unsigned i = 0; i < SgUpirWorksharingStatement::pool_size; ++i ) {
  141432           0 :                if ( pointer->get_freepointer() != NULL ) {
  141433           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  141434           0 :                  storageArray++;
  141435           0 :                  storageCounter++;
  141436             :                }
  141437           0 :                pointer++;
  141438             :              }
  141439           0 :            block++;
  141440             :         }
  141441           0 :      return storageCounter;
  141442             :    }
  141443             : 
  141444             : /* #line 141445 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  141445             : 
  141446             : 
  141447             : 
  141448             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  141449             : 
  141450             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  141451             : 
  141452             : //############################################################################
  141453             : /* JH (02/02/2006) Constructor of the IR node SgUpirSimdStatement that takes its 
  141454             :  * corresponding StorageClass as parameter
  141455             :  */
  141456           0 : SgUpirSimdStatement :: SgUpirSimdStatement ( const SgUpirSimdStatementStorageClass& storageSource )   : SgUpirFieldStatement (storageSource)
  141457             :    {
  141458             : 
  141459             : 
  141460             : /* #line 141461 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  141461             : 
  141462           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  141463             : 
  141464             : 
  141465             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  141466             : 
  141467             : 
  141468           0 :    }
  141469             : 
  141470             : //############################################################################
  141471             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  141472             :  * within the working AST. 
  141473             :  */
  141474           0 : SgUpirSimdStatement * SgUpirSimdStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  141475           0 :      SgUpirSimdStatement* returnPointer = NULL;
  141476           0 :      if ( globalIndex != 0 )
  141477             :         {
  141478             : 
  141479             : #if FILE_IO_EXTRA_CHECK
  141480           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpirSimdStatement ) ) <= globalIndex ) ;
  141481           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirSimdStatement + 1 ) ) );
  141482             : #endif
  141483           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpirSimdStatement )  
  141484           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpirSimdStatement );
  141485           0 :           unsigned long positionInPool = localIndex % SgUpirSimdStatement::pool_size;
  141486           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirSimdStatement::pool_size;
  141487             : 
  141488             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  141489             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  141490             : 
  141491           0 :           returnPointer = &( ( (SgUpirSimdStatement*)(SgUpirSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  141492             : 
  141493           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  141494             :         }
  141495           0 :      return returnPointer ;
  141496             :    }
  141497             : 
  141498             : //############################################################################
  141499             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  141500             :   for the AST with the index astIndex
  141501             : */
  141502           0 : SgUpirSimdStatement * SgUpirSimdStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  141503           0 :      SgUpirSimdStatement* returnPointer = NULL;
  141504           0 :      if ( globalIndex != 0 )
  141505             :         {
  141506             : 
  141507             : #if FILE_IO_EXTRA_CHECK
  141508           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpirSimdStatement ) ) <= globalIndex ) ;
  141509           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirSimdStatement + 1 ) ) );
  141510             : #endif
  141511           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpirSimdStatement )
  141512           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpirSimdStatement );
  141513           0 :           unsigned long positionInPool = localIndex % SgUpirSimdStatement::pool_size ;
  141514           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpirSimdStatement::pool_size ;
  141515             : 
  141516             : #if FILE_IO_EXTRA_CHECK
  141517             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  141518             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  141519             : #endif
  141520             : 
  141521           0 :           returnPointer = &( ( (SgUpirSimdStatement*)(SgUpirSimdStatement::pools[memoryBlock]) ) [positionInPool]) ;
  141522             : 
  141523             : #if FILE_IO_EXTRA_CHECK
  141524           0 :           assert ( returnPointer != NULL ) ;
  141525             : #endif
  141526             :         }
  141527           0 :      return returnPointer ;
  141528             :    }
  141529             : 
  141530             : //############################################################################
  141531             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  141532             :  * pool size! We set for every valid object in the memory pool the freepointer
  141533             :  * to the global index and increase the global index afterwards. For all the 
  141534             :  * invalid objects (means address ranges within the memory pool that were not
  141535             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  141536             :  * distinguish valid from invalid objects! 
  141537             :  */
  141538             : unsigned long
  141539           5 : SgUpirSimdStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  141540             :    {
  141541           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  141542           5 :      SgUpirSimdStatement* pointer = NULL;
  141543           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  141544           5 :      std::vector < unsigned char* > :: const_iterator block;
  141545           5 :      for ( block = SgUpirSimdStatement::pools.begin(); block != SgUpirSimdStatement::pools.end() ; ++block )
  141546             :         {
  141547           0 :           pointer = (SgUpirSimdStatement*)(*block);
  141548           0 :           for (unsigned i = 0; i < SgUpirSimdStatement::pool_size; ++i )
  141549             :              {
  141550             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  141551             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  141552             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  141553             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  141554             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  141555             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  141556             :             // properly; so this will have to be checked next.
  141557             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  141558             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  141559           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  141560             :                   {
  141561           0 :                     pointer[i].set_freepointer((SgUpirSimdStatement*)(globalIndex));
  141562           0 :                     globalIndex++;
  141563             :                   }
  141564             :                else
  141565             :                   {
  141566           0 :                     pointer[i].set_freepointer(NULL);
  141567             :                   }
  141568             :               }
  141569             :         }
  141570           5 :      return globalIndex;
  141571             :    }
  141572             : 
  141573             : //############################################################################
  141574             : // JH (01/14/2006)
  141575             : void
  141576           5 : SgUpirSimdStatement::resetValidFreepointers( )
  141577             :    {
  141578           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  141579           5 :      SgUpirSimdStatement* pointer = NULL;
  141580           5 :      std::vector < unsigned char* > :: const_iterator block;
  141581           5 :      SgUpirSimdStatement* pointerOfLinkedList = NULL;
  141582           5 :      for ( block = SgUpirSimdStatement::pools.begin(); block != SgUpirSimdStatement::pools.end() ; ++block )
  141583             :         {
  141584           0 :           pointer = (SgUpirSimdStatement*)(*block);
  141585           0 :           for (unsigned i = 0; i < SgUpirSimdStatement::pool_size; ++i )
  141586             :              {
  141587             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  141588             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  141589             :             // memory blocks!.
  141590           0 :                if ( pointer[i].get_freepointer() != NULL )
  141591             :                   {
  141592           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  141593             :                   }
  141594             :                else
  141595             :                   {
  141596           0 :                     if ( pointerOfLinkedList == NULL )
  141597             :                        {
  141598           0 :                          SgUpirSimdStatement::next_node = &(pointer[i]);
  141599             :                        }
  141600             :                     else
  141601             :                        {
  141602             :                       // printf ("In SgUpirSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  141603           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  141604             :                        }
  141605             :                     pointerOfLinkedList = &(pointer[i]);
  141606             :                   }
  141607             :               }
  141608             :         }
  141609             : 
  141610           5 :      if ( pointerOfLinkedList != NULL )
  141611             :         {
  141612             :        // printf ("In SgUpirSimdStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  141613           0 :           pointerOfLinkedList->set_freepointer(NULL);
  141614             :        // DQ (6/6/2010): Temporary debugging...
  141615             :        //   ROSE_ASSERT(false);
  141616             :         }
  141617             : 
  141618           5 :      return ;
  141619             :    }
  141620             : 
  141621             : //############################################################################
  141622             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  141623             :  * within the memory pool and resets the freepointers, in order to achieve a 
  141624             :  * linked list, that has no jumps and starts at the beginning! This function 
  141625             :  * does not extend the memory pool, since we do not delete any memory blocks,
  141626             :  * but delete the valid objects.  
  141627             :  */
  141628             : void
  141629           0 : SgUpirSimdStatement::clearMemoryPool( )
  141630             :    {
  141631             :   // printf ("Inside of SgUpirSimdStatement::clearMemoryPool() \n");
  141632             : 
  141633           0 :      SgUpirSimdStatement* pointer = NULL, *tempPointer = NULL;
  141634           0 :      std::vector < unsigned char* > :: const_iterator block;
  141635           0 :      if ( SgUpirSimdStatement::pools.empty() == false )
  141636             :         {
  141637           0 :           block = SgUpirSimdStatement::pools.begin() ;
  141638           0 :           SgUpirSimdStatement::next_node = (SgUpirSimdStatement*) (*block);
  141639             : 
  141640           0 :           while ( block != SgUpirSimdStatement::pools.end() )
  141641             :              {
  141642           0 :                pointer = (SgUpirSimdStatement*) (*block);
  141643           0 :                if ( tempPointer != NULL )
  141644             :                   {
  141645           0 :                     tempPointer->set_freepointer(pointer);
  141646             :                   }
  141647           0 :                for (unsigned i = 0; i < SgUpirSimdStatement::pool_size - 1; ++i)
  141648             :                   {
  141649           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  141650             :                   }
  141651           0 :                 pointer[SgUpirSimdStatement::pool_size-1].set_freepointer(NULL);
  141652           0 :                 tempPointer = &(pointer[SgUpirSimdStatement::pool_size-1]);
  141653           0 :                 ++block;
  141654             :              }
  141655             :         }
  141656           0 :    }
  141657             : 
  141658           5 : void SgUpirSimdStatement::deleteMemoryPool() {
  141659           5 :   for (auto p: SgUpirSimdStatement::pools) {
  141660           0 :     ROSE_FREE(p);
  141661             :   }
  141662           5 :   SgUpirSimdStatement::next_node = nullptr;
  141663           5 :   SgUpirSimdStatement::pools.clear();
  141664           5 : }
  141665             : 
  141666             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  141667             : //                 reading multiple binary files to for a single AST.
  141668             : /////////// new version ////////////////////////////////
  141669             : //############################################################################
  141670             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  141671             : void
  141672           2 : SgUpirSimdStatement::extendMemoryPoolForFileIO( )
  141673             :   {
  141674           2 :     size_t blockIndex = SgUpirSimdStatement::pools.size();
  141675           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSimdStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSimdStatement);
  141676             : 
  141677           2 :     while ( (blockIndex * SgUpirSimdStatement::pool_size) < newPoolSize)
  141678             :       {
  141679             : #if ROSE_ALLOC_TRACE
  141680             :         if (blockIndex > 0) {
  141681             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSimdStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSimdStatement) = %" PRIuPTR " SgUpirSimdStatement::pool_size = %d \n",
  141682             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpirSimdStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpirSimdStatement),SgUpirSimdStatement::pool_size);
  141683             :         }
  141684             : #endif
  141685             : 
  141686           0 :         SgUpirSimdStatement * pointer = (SgUpirSimdStatement*) ROSE_MALLOC ( SgUpirSimdStatement::pool_size * sizeof(SgUpirSimdStatement) );
  141687           0 :         assert( pointer != NULL );
  141688             : #if ROSE_ALLOC_MEMSET == 1
  141689             :         memset(pointer, 0x00, SgUpirSimdStatement::pool_size * sizeof(SgUpirSimdStatement));
  141690             : #elif ROSE_ALLOC_MEMSET == 2
  141691             :         memset(pointer, 0xCC, SgUpirSimdStatement::pool_size * sizeof(SgUpirSimdStatement));
  141692             : #endif
  141693           0 :         SgUpirSimdStatement::pools.push_back( (unsigned char*)(pointer) );
  141694           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpirSimdStatement::pool_size * sizeof(SgUpirSimdStatement), V_SgUpirSimdStatement ) );
  141695             : 
  141696           0 :         if ( SgUpirSimdStatement::next_node != NULL ) {
  141697           0 :           if ( blockIndex > 0 ) {
  141698           0 :             SgUpirSimdStatement * blkptr = (SgUpirSimdStatement*)(SgUpirSimdStatement::pools[blockIndex-1]);
  141699           0 :             blkptr[ SgUpirSimdStatement::pool_size - 1 ].set_freepointer(pointer);
  141700             :           }
  141701             :         } else {
  141702           0 :           SgUpirSimdStatement::next_node = pointer;
  141703             :         }
  141704             : 
  141705           0 :         for (unsigned i = 0; i < SgUpirSimdStatement::pool_size-1; ++i)
  141706             :            {
  141707           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  141708             :            }
  141709           0 :         pointer[ SgUpirSimdStatement::pool_size -1 ].set_freepointer(NULL);
  141710             : 
  141711           0 :         blockIndex++;
  141712             :       }
  141713           2 :   }
  141714             : 
  141715             : //############################################################################
  141716             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  141717             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  141718             :  * not compressed. However, that stuff is not yet implemented! 
  141719             :  */
  141720             : unsigned long
  141721           0 : SgUpirSimdStatement::getNumberOfLastValidPointer()
  141722             :    {
  141723           0 :       SgUpirSimdStatement* testPointer = (SgUpirSimdStatement*)(SgUpirSimdStatement::pools.back());
  141724           0 :       unsigned long localIndex = SgUpirSimdStatement::pool_size - 1;
  141725           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  141726             :          {
  141727           0 :            localIndex--;
  141728             :          }
  141729           0 :       return (localIndex + SgUpirSimdStatement::pool_size * (SgUpirSimdStatement::pools.size()-1));
  141730             :    }
  141731             : 
  141732             : //############################################################################
  141733             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  141734             :  * memory pool and initializes the data member in class SgUpirSimdStatementStroageClass
  141735             :  * from its counterpart of SgUpirSimdStatement. The return value is just for checking, 
  141736             :  * that the whole StorageClassArray is initialized!
  141737             :  */
  141738             : unsigned long
  141739           0 : SgUpirSimdStatement::initializeStorageClassArray( SgUpirSimdStatementStorageClass *storageArray )
  141740             :    {
  141741           0 :      unsigned long storageCounter = 0;
  141742           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpirSimdStatement::pools.begin();
  141743           0 :      SgUpirSimdStatement* pointer = NULL;
  141744           0 :      while ( block != SgUpirSimdStatement::pools.end() ) {
  141745           0 :           pointer = (SgUpirSimdStatement*) (*block);
  141746           0 :           for ( unsigned i = 0; i < SgUpirSimdStatement::pool_size; ++i ) {
  141747           0 :                if ( pointer->get_freepointer() != NULL ) {
  141748           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  141749           0 :                  storageArray++;
  141750           0 :                  storageCounter++;
  141751             :                }
  141752           0 :                pointer++;
  141753             :              }
  141754           0 :            block++;
  141755             :         }
  141756           0 :      return storageCounter;
  141757             :    }
  141758             : 
  141759             : /* #line 141760 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  141760             : 
  141761             : 
  141762             : 
  141763             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  141764             : 
  141765             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  141766             : 
  141767             : //############################################################################
  141768             : /* JH (02/02/2006) Constructor of the IR node SgOmpDeclareMapperStatement that takes its 
  141769             :  * corresponding StorageClass as parameter
  141770             :  */
  141771           0 : SgOmpDeclareMapperStatement :: SgOmpDeclareMapperStatement ( const SgOmpDeclareMapperStatementStorageClass& storageSource )   : SgUpirBaseStatement (storageSource)
  141772             :    {
  141773             : 
  141774             : 
  141775             : /* #line 141776 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  141776             : 
  141777           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  141778             : 
  141779             : 
  141780             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  141781             : 
  141782             : 
  141783           0 :    }
  141784             : 
  141785             : //############################################################################
  141786             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  141787             :  * within the working AST. 
  141788             :  */
  141789           0 : SgOmpDeclareMapperStatement * SgOmpDeclareMapperStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  141790           0 :      SgOmpDeclareMapperStatement* returnPointer = NULL;
  141791           0 :      if ( globalIndex != 0 )
  141792             :         {
  141793             : 
  141794             : #if FILE_IO_EXTRA_CHECK
  141795           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOmpDeclareMapperStatement ) ) <= globalIndex ) ;
  141796           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDeclareMapperStatement + 1 ) ) );
  141797             : #endif
  141798           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOmpDeclareMapperStatement )  
  141799           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOmpDeclareMapperStatement );
  141800           0 :           unsigned long positionInPool = localIndex % SgOmpDeclareMapperStatement::pool_size;
  141801           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDeclareMapperStatement::pool_size;
  141802             : 
  141803             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  141804             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  141805             : 
  141806           0 :           returnPointer = &( ( (SgOmpDeclareMapperStatement*)(SgOmpDeclareMapperStatement::pools[memoryBlock]) ) [positionInPool]) ;
  141807             : 
  141808           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  141809             :         }
  141810           0 :      return returnPointer ;
  141811             :    }
  141812             : 
  141813             : //############################################################################
  141814             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  141815             :   for the AST with the index astIndex
  141816             : */
  141817           0 : SgOmpDeclareMapperStatement * SgOmpDeclareMapperStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  141818           0 :      SgOmpDeclareMapperStatement* returnPointer = NULL;
  141819           0 :      if ( globalIndex != 0 )
  141820             :         {
  141821             : 
  141822             : #if FILE_IO_EXTRA_CHECK
  141823           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOmpDeclareMapperStatement ) ) <= globalIndex ) ;
  141824           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDeclareMapperStatement + 1 ) ) );
  141825             : #endif
  141826           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOmpDeclareMapperStatement )
  141827           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOmpDeclareMapperStatement );
  141828           0 :           unsigned long positionInPool = localIndex % SgOmpDeclareMapperStatement::pool_size ;
  141829           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOmpDeclareMapperStatement::pool_size ;
  141830             : 
  141831             : #if FILE_IO_EXTRA_CHECK
  141832             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  141833             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  141834             : #endif
  141835             : 
  141836           0 :           returnPointer = &( ( (SgOmpDeclareMapperStatement*)(SgOmpDeclareMapperStatement::pools[memoryBlock]) ) [positionInPool]) ;
  141837             : 
  141838             : #if FILE_IO_EXTRA_CHECK
  141839           0 :           assert ( returnPointer != NULL ) ;
  141840             : #endif
  141841             :         }
  141842           0 :      return returnPointer ;
  141843             :    }
  141844             : 
  141845             : //############################################################################
  141846             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  141847             :  * pool size! We set for every valid object in the memory pool the freepointer
  141848             :  * to the global index and increase the global index afterwards. For all the 
  141849             :  * invalid objects (means address ranges within the memory pool that were not
  141850             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  141851             :  * distinguish valid from invalid objects! 
  141852             :  */
  141853             : unsigned long
  141854           5 : SgOmpDeclareMapperStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  141855             :    {
  141856           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  141857           5 :      SgOmpDeclareMapperStatement* pointer = NULL;
  141858           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  141859           5 :      std::vector < unsigned char* > :: const_iterator block;
  141860           5 :      for ( block = SgOmpDeclareMapperStatement::pools.begin(); block != SgOmpDeclareMapperStatement::pools.end() ; ++block )
  141861             :         {
  141862           0 :           pointer = (SgOmpDeclareMapperStatement*)(*block);
  141863           0 :           for (unsigned i = 0; i < SgOmpDeclareMapperStatement::pool_size; ++i )
  141864             :              {
  141865             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  141866             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  141867             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  141868             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  141869             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  141870             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  141871             :             // properly; so this will have to be checked next.
  141872             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  141873             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  141874           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  141875             :                   {
  141876           0 :                     pointer[i].set_freepointer((SgOmpDeclareMapperStatement*)(globalIndex));
  141877           0 :                     globalIndex++;
  141878             :                   }
  141879             :                else
  141880             :                   {
  141881           0 :                     pointer[i].set_freepointer(NULL);
  141882             :                   }
  141883             :               }
  141884             :         }
  141885           5 :      return globalIndex;
  141886             :    }
  141887             : 
  141888             : //############################################################################
  141889             : // JH (01/14/2006)
  141890             : void
  141891           5 : SgOmpDeclareMapperStatement::resetValidFreepointers( )
  141892             :    {
  141893           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  141894           5 :      SgOmpDeclareMapperStatement* pointer = NULL;
  141895           5 :      std::vector < unsigned char* > :: const_iterator block;
  141896           5 :      SgOmpDeclareMapperStatement* pointerOfLinkedList = NULL;
  141897           5 :      for ( block = SgOmpDeclareMapperStatement::pools.begin(); block != SgOmpDeclareMapperStatement::pools.end() ; ++block )
  141898             :         {
  141899           0 :           pointer = (SgOmpDeclareMapperStatement*)(*block);
  141900           0 :           for (unsigned i = 0; i < SgOmpDeclareMapperStatement::pool_size; ++i )
  141901             :              {
  141902             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  141903             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  141904             :             // memory blocks!.
  141905           0 :                if ( pointer[i].get_freepointer() != NULL )
  141906             :                   {
  141907           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  141908             :                   }
  141909             :                else
  141910             :                   {
  141911           0 :                     if ( pointerOfLinkedList == NULL )
  141912             :                        {
  141913           0 :                          SgOmpDeclareMapperStatement::next_node = &(pointer[i]);
  141914             :                        }
  141915             :                     else
  141916             :                        {
  141917             :                       // printf ("In SgOmpDeclareMapperStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  141918           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  141919             :                        }
  141920             :                     pointerOfLinkedList = &(pointer[i]);
  141921             :                   }
  141922             :               }
  141923             :         }
  141924             : 
  141925           5 :      if ( pointerOfLinkedList != NULL )
  141926             :         {
  141927             :        // printf ("In SgOmpDeclareMapperStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  141928           0 :           pointerOfLinkedList->set_freepointer(NULL);
  141929             :        // DQ (6/6/2010): Temporary debugging...
  141930             :        //   ROSE_ASSERT(false);
  141931             :         }
  141932             : 
  141933           5 :      return ;
  141934             :    }
  141935             : 
  141936             : //############################################################################
  141937             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  141938             :  * within the memory pool and resets the freepointers, in order to achieve a 
  141939             :  * linked list, that has no jumps and starts at the beginning! This function 
  141940             :  * does not extend the memory pool, since we do not delete any memory blocks,
  141941             :  * but delete the valid objects.  
  141942             :  */
  141943             : void
  141944           0 : SgOmpDeclareMapperStatement::clearMemoryPool( )
  141945             :    {
  141946             :   // printf ("Inside of SgOmpDeclareMapperStatement::clearMemoryPool() \n");
  141947             : 
  141948           0 :      SgOmpDeclareMapperStatement* pointer = NULL, *tempPointer = NULL;
  141949           0 :      std::vector < unsigned char* > :: const_iterator block;
  141950           0 :      if ( SgOmpDeclareMapperStatement::pools.empty() == false )
  141951             :         {
  141952           0 :           block = SgOmpDeclareMapperStatement::pools.begin() ;
  141953           0 :           SgOmpDeclareMapperStatement::next_node = (SgOmpDeclareMapperStatement*) (*block);
  141954             : 
  141955           0 :           while ( block != SgOmpDeclareMapperStatement::pools.end() )
  141956             :              {
  141957           0 :                pointer = (SgOmpDeclareMapperStatement*) (*block);
  141958           0 :                if ( tempPointer != NULL )
  141959             :                   {
  141960           0 :                     tempPointer->set_freepointer(pointer);
  141961             :                   }
  141962           0 :                for (unsigned i = 0; i < SgOmpDeclareMapperStatement::pool_size - 1; ++i)
  141963             :                   {
  141964           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  141965             :                   }
  141966           0 :                 pointer[SgOmpDeclareMapperStatement::pool_size-1].set_freepointer(NULL);
  141967           0 :                 tempPointer = &(pointer[SgOmpDeclareMapperStatement::pool_size-1]);
  141968           0 :                 ++block;
  141969             :              }
  141970             :         }
  141971           0 :    }
  141972             : 
  141973           5 : void SgOmpDeclareMapperStatement::deleteMemoryPool() {
  141974           5 :   for (auto p: SgOmpDeclareMapperStatement::pools) {
  141975           0 :     ROSE_FREE(p);
  141976             :   }
  141977           5 :   SgOmpDeclareMapperStatement::next_node = nullptr;
  141978           5 :   SgOmpDeclareMapperStatement::pools.clear();
  141979           5 : }
  141980             : 
  141981             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  141982             : //                 reading multiple binary files to for a single AST.
  141983             : /////////// new version ////////////////////////////////
  141984             : //############################################################################
  141985             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  141986             : void
  141987           2 : SgOmpDeclareMapperStatement::extendMemoryPoolForFileIO( )
  141988             :   {
  141989           2 :     size_t blockIndex = SgOmpDeclareMapperStatement::pools.size();
  141990           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeclareMapperStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeclareMapperStatement);
  141991             : 
  141992           2 :     while ( (blockIndex * SgOmpDeclareMapperStatement::pool_size) < newPoolSize)
  141993             :       {
  141994             : #if ROSE_ALLOC_TRACE
  141995             :         if (blockIndex > 0) {
  141996             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeclareMapperStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeclareMapperStatement) = %" PRIuPTR " SgOmpDeclareMapperStatement::pool_size = %d \n",
  141997             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOmpDeclareMapperStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOmpDeclareMapperStatement),SgOmpDeclareMapperStatement::pool_size);
  141998             :         }
  141999             : #endif
  142000             : 
  142001           0 :         SgOmpDeclareMapperStatement * pointer = (SgOmpDeclareMapperStatement*) ROSE_MALLOC ( SgOmpDeclareMapperStatement::pool_size * sizeof(SgOmpDeclareMapperStatement) );
  142002           0 :         assert( pointer != NULL );
  142003             : #if ROSE_ALLOC_MEMSET == 1
  142004             :         memset(pointer, 0x00, SgOmpDeclareMapperStatement::pool_size * sizeof(SgOmpDeclareMapperStatement));
  142005             : #elif ROSE_ALLOC_MEMSET == 2
  142006             :         memset(pointer, 0xCC, SgOmpDeclareMapperStatement::pool_size * sizeof(SgOmpDeclareMapperStatement));
  142007             : #endif
  142008           0 :         SgOmpDeclareMapperStatement::pools.push_back( (unsigned char*)(pointer) );
  142009           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOmpDeclareMapperStatement::pool_size * sizeof(SgOmpDeclareMapperStatement), V_SgOmpDeclareMapperStatement ) );
  142010             : 
  142011           0 :         if ( SgOmpDeclareMapperStatement::next_node != NULL ) {
  142012           0 :           if ( blockIndex > 0 ) {
  142013           0 :             SgOmpDeclareMapperStatement * blkptr = (SgOmpDeclareMapperStatement*)(SgOmpDeclareMapperStatement::pools[blockIndex-1]);
  142014           0 :             blkptr[ SgOmpDeclareMapperStatement::pool_size - 1 ].set_freepointer(pointer);
  142015             :           }
  142016             :         } else {
  142017           0 :           SgOmpDeclareMapperStatement::next_node = pointer;
  142018             :         }
  142019             : 
  142020           0 :         for (unsigned i = 0; i < SgOmpDeclareMapperStatement::pool_size-1; ++i)
  142021             :            {
  142022           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  142023             :            }
  142024           0 :         pointer[ SgOmpDeclareMapperStatement::pool_size -1 ].set_freepointer(NULL);
  142025             : 
  142026           0 :         blockIndex++;
  142027             :       }
  142028           2 :   }
  142029             : 
  142030             : //############################################################################
  142031             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  142032             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  142033             :  * not compressed. However, that stuff is not yet implemented! 
  142034             :  */
  142035             : unsigned long
  142036           0 : SgOmpDeclareMapperStatement::getNumberOfLastValidPointer()
  142037             :    {
  142038           0 :       SgOmpDeclareMapperStatement* testPointer = (SgOmpDeclareMapperStatement*)(SgOmpDeclareMapperStatement::pools.back());
  142039           0 :       unsigned long localIndex = SgOmpDeclareMapperStatement::pool_size - 1;
  142040           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  142041             :          {
  142042           0 :            localIndex--;
  142043             :          }
  142044           0 :       return (localIndex + SgOmpDeclareMapperStatement::pool_size * (SgOmpDeclareMapperStatement::pools.size()-1));
  142045             :    }
  142046             : 
  142047             : //############################################################################
  142048             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  142049             :  * memory pool and initializes the data member in class SgOmpDeclareMapperStatementStroageClass
  142050             :  * from its counterpart of SgOmpDeclareMapperStatement. The return value is just for checking, 
  142051             :  * that the whole StorageClassArray is initialized!
  142052             :  */
  142053             : unsigned long
  142054           0 : SgOmpDeclareMapperStatement::initializeStorageClassArray( SgOmpDeclareMapperStatementStorageClass *storageArray )
  142055             :    {
  142056           0 :      unsigned long storageCounter = 0;
  142057           0 :      std::vector < unsigned char* > :: const_iterator block = SgOmpDeclareMapperStatement::pools.begin();
  142058           0 :      SgOmpDeclareMapperStatement* pointer = NULL;
  142059           0 :      while ( block != SgOmpDeclareMapperStatement::pools.end() ) {
  142060           0 :           pointer = (SgOmpDeclareMapperStatement*) (*block);
  142061           0 :           for ( unsigned i = 0; i < SgOmpDeclareMapperStatement::pool_size; ++i ) {
  142062           0 :                if ( pointer->get_freepointer() != NULL ) {
  142063           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  142064           0 :                  storageArray++;
  142065           0 :                  storageCounter++;
  142066             :                }
  142067           0 :                pointer++;
  142068             :              }
  142069           0 :            block++;
  142070             :         }
  142071           0 :      return storageCounter;
  142072             :    }
  142073             : 
  142074             : /* #line 142075 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  142075             : 
  142076             : 
  142077             : 
  142078             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  142079             : 
  142080             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  142081             : 
  142082             : //############################################################################
  142083             : /* JH (02/02/2006) Constructor of the IR node SgSequenceStatement that takes its 
  142084             :  * corresponding StorageClass as parameter
  142085             :  */
  142086           0 : SgSequenceStatement :: SgSequenceStatement ( const SgSequenceStatementStorageClass& storageSource )   : SgStatement (storageSource)
  142087             :    {
  142088             : 
  142089             : 
  142090             : /* #line 142091 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  142091             : 
  142092           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  142093             : 
  142094             : 
  142095             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  142096             : 
  142097             : 
  142098           0 :    }
  142099             : 
  142100             : //############################################################################
  142101             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  142102             :  * within the working AST. 
  142103             :  */
  142104           0 : SgSequenceStatement * SgSequenceStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  142105           0 :      SgSequenceStatement* returnPointer = NULL;
  142106           0 :      if ( globalIndex != 0 )
  142107             :         {
  142108             : 
  142109             : #if FILE_IO_EXTRA_CHECK
  142110           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSequenceStatement ) ) <= globalIndex ) ;
  142111           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSequenceStatement + 1 ) ) );
  142112             : #endif
  142113           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSequenceStatement )  
  142114           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSequenceStatement );
  142115           0 :           unsigned long positionInPool = localIndex % SgSequenceStatement::pool_size;
  142116           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSequenceStatement::pool_size;
  142117             : 
  142118             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  142119             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  142120             : 
  142121           0 :           returnPointer = &( ( (SgSequenceStatement*)(SgSequenceStatement::pools[memoryBlock]) ) [positionInPool]) ;
  142122             : 
  142123           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  142124             :         }
  142125           0 :      return returnPointer ;
  142126             :    }
  142127             : 
  142128             : //############################################################################
  142129             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  142130             :   for the AST with the index astIndex
  142131             : */
  142132           0 : SgSequenceStatement * SgSequenceStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  142133           0 :      SgSequenceStatement* returnPointer = NULL;
  142134           0 :      if ( globalIndex != 0 )
  142135             :         {
  142136             : 
  142137             : #if FILE_IO_EXTRA_CHECK
  142138           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSequenceStatement ) ) <= globalIndex ) ;
  142139           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSequenceStatement + 1 ) ) );
  142140             : #endif
  142141           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSequenceStatement )
  142142           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSequenceStatement );
  142143           0 :           unsigned long positionInPool = localIndex % SgSequenceStatement::pool_size ;
  142144           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSequenceStatement::pool_size ;
  142145             : 
  142146             : #if FILE_IO_EXTRA_CHECK
  142147             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  142148             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  142149             : #endif
  142150             : 
  142151           0 :           returnPointer = &( ( (SgSequenceStatement*)(SgSequenceStatement::pools[memoryBlock]) ) [positionInPool]) ;
  142152             : 
  142153             : #if FILE_IO_EXTRA_CHECK
  142154           0 :           assert ( returnPointer != NULL ) ;
  142155             : #endif
  142156             :         }
  142157           0 :      return returnPointer ;
  142158             :    }
  142159             : 
  142160             : //############################################################################
  142161             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  142162             :  * pool size! We set for every valid object in the memory pool the freepointer
  142163             :  * to the global index and increase the global index afterwards. For all the 
  142164             :  * invalid objects (means address ranges within the memory pool that were not
  142165             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  142166             :  * distinguish valid from invalid objects! 
  142167             :  */
  142168             : unsigned long
  142169           5 : SgSequenceStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  142170             :    {
  142171           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  142172           5 :      SgSequenceStatement* pointer = NULL;
  142173           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  142174           5 :      std::vector < unsigned char* > :: const_iterator block;
  142175           5 :      for ( block = SgSequenceStatement::pools.begin(); block != SgSequenceStatement::pools.end() ; ++block )
  142176             :         {
  142177           0 :           pointer = (SgSequenceStatement*)(*block);
  142178           0 :           for (unsigned i = 0; i < SgSequenceStatement::pool_size; ++i )
  142179             :              {
  142180             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  142181             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  142182             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  142183             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  142184             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  142185             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  142186             :             // properly; so this will have to be checked next.
  142187             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  142188             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  142189           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  142190             :                   {
  142191           0 :                     pointer[i].set_freepointer((SgSequenceStatement*)(globalIndex));
  142192           0 :                     globalIndex++;
  142193             :                   }
  142194             :                else
  142195             :                   {
  142196           0 :                     pointer[i].set_freepointer(NULL);
  142197             :                   }
  142198             :               }
  142199             :         }
  142200           5 :      return globalIndex;
  142201             :    }
  142202             : 
  142203             : //############################################################################
  142204             : // JH (01/14/2006)
  142205             : void
  142206           5 : SgSequenceStatement::resetValidFreepointers( )
  142207             :    {
  142208           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  142209           5 :      SgSequenceStatement* pointer = NULL;
  142210           5 :      std::vector < unsigned char* > :: const_iterator block;
  142211           5 :      SgSequenceStatement* pointerOfLinkedList = NULL;
  142212           5 :      for ( block = SgSequenceStatement::pools.begin(); block != SgSequenceStatement::pools.end() ; ++block )
  142213             :         {
  142214           0 :           pointer = (SgSequenceStatement*)(*block);
  142215           0 :           for (unsigned i = 0; i < SgSequenceStatement::pool_size; ++i )
  142216             :              {
  142217             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  142218             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  142219             :             // memory blocks!.
  142220           0 :                if ( pointer[i].get_freepointer() != NULL )
  142221             :                   {
  142222           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  142223             :                   }
  142224             :                else
  142225             :                   {
  142226           0 :                     if ( pointerOfLinkedList == NULL )
  142227             :                        {
  142228           0 :                          SgSequenceStatement::next_node = &(pointer[i]);
  142229             :                        }
  142230             :                     else
  142231             :                        {
  142232             :                       // printf ("In SgSequenceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  142233           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  142234             :                        }
  142235             :                     pointerOfLinkedList = &(pointer[i]);
  142236             :                   }
  142237             :               }
  142238             :         }
  142239             : 
  142240           5 :      if ( pointerOfLinkedList != NULL )
  142241             :         {
  142242             :        // printf ("In SgSequenceStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  142243           0 :           pointerOfLinkedList->set_freepointer(NULL);
  142244             :        // DQ (6/6/2010): Temporary debugging...
  142245             :        //   ROSE_ASSERT(false);
  142246             :         }
  142247             : 
  142248           5 :      return ;
  142249             :    }
  142250             : 
  142251             : //############################################################################
  142252             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  142253             :  * within the memory pool and resets the freepointers, in order to achieve a 
  142254             :  * linked list, that has no jumps and starts at the beginning! This function 
  142255             :  * does not extend the memory pool, since we do not delete any memory blocks,
  142256             :  * but delete the valid objects.  
  142257             :  */
  142258             : void
  142259           0 : SgSequenceStatement::clearMemoryPool( )
  142260             :    {
  142261             :   // printf ("Inside of SgSequenceStatement::clearMemoryPool() \n");
  142262             : 
  142263           0 :      SgSequenceStatement* pointer = NULL, *tempPointer = NULL;
  142264           0 :      std::vector < unsigned char* > :: const_iterator block;
  142265           0 :      if ( SgSequenceStatement::pools.empty() == false )
  142266             :         {
  142267           0 :           block = SgSequenceStatement::pools.begin() ;
  142268           0 :           SgSequenceStatement::next_node = (SgSequenceStatement*) (*block);
  142269             : 
  142270           0 :           while ( block != SgSequenceStatement::pools.end() )
  142271             :              {
  142272           0 :                pointer = (SgSequenceStatement*) (*block);
  142273           0 :                if ( tempPointer != NULL )
  142274             :                   {
  142275           0 :                     tempPointer->set_freepointer(pointer);
  142276             :                   }
  142277           0 :                for (unsigned i = 0; i < SgSequenceStatement::pool_size - 1; ++i)
  142278             :                   {
  142279           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  142280             :                   }
  142281           0 :                 pointer[SgSequenceStatement::pool_size-1].set_freepointer(NULL);
  142282           0 :                 tempPointer = &(pointer[SgSequenceStatement::pool_size-1]);
  142283           0 :                 ++block;
  142284             :              }
  142285             :         }
  142286           0 :    }
  142287             : 
  142288           5 : void SgSequenceStatement::deleteMemoryPool() {
  142289           5 :   for (auto p: SgSequenceStatement::pools) {
  142290           0 :     ROSE_FREE(p);
  142291             :   }
  142292           5 :   SgSequenceStatement::next_node = nullptr;
  142293           5 :   SgSequenceStatement::pools.clear();
  142294           5 : }
  142295             : 
  142296             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  142297             : //                 reading multiple binary files to for a single AST.
  142298             : /////////// new version ////////////////////////////////
  142299             : //############################################################################
  142300             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  142301             : void
  142302           2 : SgSequenceStatement::extendMemoryPoolForFileIO( )
  142303             :   {
  142304           2 :     size_t blockIndex = SgSequenceStatement::pools.size();
  142305           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSequenceStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSequenceStatement);
  142306             : 
  142307           2 :     while ( (blockIndex * SgSequenceStatement::pool_size) < newPoolSize)
  142308             :       {
  142309             : #if ROSE_ALLOC_TRACE
  142310             :         if (blockIndex > 0) {
  142311             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSequenceStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSequenceStatement) = %" PRIuPTR " SgSequenceStatement::pool_size = %d \n",
  142312             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSequenceStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSequenceStatement),SgSequenceStatement::pool_size);
  142313             :         }
  142314             : #endif
  142315             : 
  142316           0 :         SgSequenceStatement * pointer = (SgSequenceStatement*) ROSE_MALLOC ( SgSequenceStatement::pool_size * sizeof(SgSequenceStatement) );
  142317           0 :         assert( pointer != NULL );
  142318             : #if ROSE_ALLOC_MEMSET == 1
  142319             :         memset(pointer, 0x00, SgSequenceStatement::pool_size * sizeof(SgSequenceStatement));
  142320             : #elif ROSE_ALLOC_MEMSET == 2
  142321             :         memset(pointer, 0xCC, SgSequenceStatement::pool_size * sizeof(SgSequenceStatement));
  142322             : #endif
  142323           0 :         SgSequenceStatement::pools.push_back( (unsigned char*)(pointer) );
  142324           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSequenceStatement::pool_size * sizeof(SgSequenceStatement), V_SgSequenceStatement ) );
  142325             : 
  142326           0 :         if ( SgSequenceStatement::next_node != NULL ) {
  142327           0 :           if ( blockIndex > 0 ) {
  142328           0 :             SgSequenceStatement * blkptr = (SgSequenceStatement*)(SgSequenceStatement::pools[blockIndex-1]);
  142329           0 :             blkptr[ SgSequenceStatement::pool_size - 1 ].set_freepointer(pointer);
  142330             :           }
  142331             :         } else {
  142332           0 :           SgSequenceStatement::next_node = pointer;
  142333             :         }
  142334             : 
  142335           0 :         for (unsigned i = 0; i < SgSequenceStatement::pool_size-1; ++i)
  142336             :            {
  142337           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  142338             :            }
  142339           0 :         pointer[ SgSequenceStatement::pool_size -1 ].set_freepointer(NULL);
  142340             : 
  142341           0 :         blockIndex++;
  142342             :       }
  142343           2 :   }
  142344             : 
  142345             : //############################################################################
  142346             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  142347             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  142348             :  * not compressed. However, that stuff is not yet implemented! 
  142349             :  */
  142350             : unsigned long
  142351           0 : SgSequenceStatement::getNumberOfLastValidPointer()
  142352             :    {
  142353           0 :       SgSequenceStatement* testPointer = (SgSequenceStatement*)(SgSequenceStatement::pools.back());
  142354           0 :       unsigned long localIndex = SgSequenceStatement::pool_size - 1;
  142355           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  142356             :          {
  142357           0 :            localIndex--;
  142358             :          }
  142359           0 :       return (localIndex + SgSequenceStatement::pool_size * (SgSequenceStatement::pools.size()-1));
  142360             :    }
  142361             : 
  142362             : //############################################################################
  142363             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  142364             :  * memory pool and initializes the data member in class SgSequenceStatementStroageClass
  142365             :  * from its counterpart of SgSequenceStatement. The return value is just for checking, 
  142366             :  * that the whole StorageClassArray is initialized!
  142367             :  */
  142368             : unsigned long
  142369           0 : SgSequenceStatement::initializeStorageClassArray( SgSequenceStatementStorageClass *storageArray )
  142370             :    {
  142371           0 :      unsigned long storageCounter = 0;
  142372           0 :      std::vector < unsigned char* > :: const_iterator block = SgSequenceStatement::pools.begin();
  142373           0 :      SgSequenceStatement* pointer = NULL;
  142374           0 :      while ( block != SgSequenceStatement::pools.end() ) {
  142375           0 :           pointer = (SgSequenceStatement*) (*block);
  142376           0 :           for ( unsigned i = 0; i < SgSequenceStatement::pool_size; ++i ) {
  142377           0 :                if ( pointer->get_freepointer() != NULL ) {
  142378           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  142379           0 :                  storageArray++;
  142380           0 :                  storageCounter++;
  142381             :                }
  142382           0 :                pointer++;
  142383             :              }
  142384           0 :            block++;
  142385             :         }
  142386           0 :      return storageCounter;
  142387             :    }
  142388             : 
  142389             : /* #line 142390 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  142390             : 
  142391             : 
  142392             : 
  142393             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  142394             : 
  142395             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  142396             : 
  142397             : //############################################################################
  142398             : /* JH (02/02/2006) Constructor of the IR node SgWithStatement that takes its 
  142399             :  * corresponding StorageClass as parameter
  142400             :  */
  142401           0 : SgWithStatement :: SgWithStatement ( const SgWithStatementStorageClass& storageSource )   : SgStatement (storageSource)
  142402             :    {
  142403             : 
  142404             : 
  142405             : /* #line 142406 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  142406             : 
  142407           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  142408           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  142409           0 :      p_body =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_body) );
  142410             : 
  142411             : 
  142412             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  142413             : 
  142414             : 
  142415           0 :    }
  142416             : 
  142417             : //############################################################################
  142418             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  142419             :  * within the working AST. 
  142420             :  */
  142421           0 : SgWithStatement * SgWithStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  142422           0 :      SgWithStatement* returnPointer = NULL;
  142423           0 :      if ( globalIndex != 0 )
  142424             :         {
  142425             : 
  142426             : #if FILE_IO_EXTRA_CHECK
  142427           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgWithStatement ) ) <= globalIndex ) ;
  142428           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWithStatement + 1 ) ) );
  142429             : #endif
  142430           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWithStatement )  
  142431           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgWithStatement );
  142432           0 :           unsigned long positionInPool = localIndex % SgWithStatement::pool_size;
  142433           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWithStatement::pool_size;
  142434             : 
  142435             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  142436             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  142437             : 
  142438           0 :           returnPointer = &( ( (SgWithStatement*)(SgWithStatement::pools[memoryBlock]) ) [positionInPool]) ;
  142439             : 
  142440           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  142441             :         }
  142442           0 :      return returnPointer ;
  142443             :    }
  142444             : 
  142445             : //############################################################################
  142446             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  142447             :   for the AST with the index astIndex
  142448             : */
  142449           0 : SgWithStatement * SgWithStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  142450           0 :      SgWithStatement* returnPointer = NULL;
  142451           0 :      if ( globalIndex != 0 )
  142452             :         {
  142453             : 
  142454             : #if FILE_IO_EXTRA_CHECK
  142455           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgWithStatement ) ) <= globalIndex ) ;
  142456           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWithStatement + 1 ) ) );
  142457             : #endif
  142458           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWithStatement )
  142459           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgWithStatement );
  142460           0 :           unsigned long positionInPool = localIndex % SgWithStatement::pool_size ;
  142461           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWithStatement::pool_size ;
  142462             : 
  142463             : #if FILE_IO_EXTRA_CHECK
  142464             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  142465             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  142466             : #endif
  142467             : 
  142468           0 :           returnPointer = &( ( (SgWithStatement*)(SgWithStatement::pools[memoryBlock]) ) [positionInPool]) ;
  142469             : 
  142470             : #if FILE_IO_EXTRA_CHECK
  142471           0 :           assert ( returnPointer != NULL ) ;
  142472             : #endif
  142473             :         }
  142474           0 :      return returnPointer ;
  142475             :    }
  142476             : 
  142477             : //############################################################################
  142478             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  142479             :  * pool size! We set for every valid object in the memory pool the freepointer
  142480             :  * to the global index and increase the global index afterwards. For all the 
  142481             :  * invalid objects (means address ranges within the memory pool that were not
  142482             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  142483             :  * distinguish valid from invalid objects! 
  142484             :  */
  142485             : unsigned long
  142486           5 : SgWithStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  142487             :    {
  142488           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  142489           5 :      SgWithStatement* pointer = NULL;
  142490           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  142491           5 :      std::vector < unsigned char* > :: const_iterator block;
  142492           5 :      for ( block = SgWithStatement::pools.begin(); block != SgWithStatement::pools.end() ; ++block )
  142493             :         {
  142494           0 :           pointer = (SgWithStatement*)(*block);
  142495           0 :           for (unsigned i = 0; i < SgWithStatement::pool_size; ++i )
  142496             :              {
  142497             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  142498             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  142499             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  142500             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  142501             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  142502             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  142503             :             // properly; so this will have to be checked next.
  142504             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  142505             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  142506           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  142507             :                   {
  142508           0 :                     pointer[i].set_freepointer((SgWithStatement*)(globalIndex));
  142509           0 :                     globalIndex++;
  142510             :                   }
  142511             :                else
  142512             :                   {
  142513           0 :                     pointer[i].set_freepointer(NULL);
  142514             :                   }
  142515             :               }
  142516             :         }
  142517           5 :      return globalIndex;
  142518             :    }
  142519             : 
  142520             : //############################################################################
  142521             : // JH (01/14/2006)
  142522             : void
  142523           5 : SgWithStatement::resetValidFreepointers( )
  142524             :    {
  142525           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  142526           5 :      SgWithStatement* pointer = NULL;
  142527           5 :      std::vector < unsigned char* > :: const_iterator block;
  142528           5 :      SgWithStatement* pointerOfLinkedList = NULL;
  142529           5 :      for ( block = SgWithStatement::pools.begin(); block != SgWithStatement::pools.end() ; ++block )
  142530             :         {
  142531           0 :           pointer = (SgWithStatement*)(*block);
  142532           0 :           for (unsigned i = 0; i < SgWithStatement::pool_size; ++i )
  142533             :              {
  142534             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  142535             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  142536             :             // memory blocks!.
  142537           0 :                if ( pointer[i].get_freepointer() != NULL )
  142538             :                   {
  142539           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  142540             :                   }
  142541             :                else
  142542             :                   {
  142543           0 :                     if ( pointerOfLinkedList == NULL )
  142544             :                        {
  142545           0 :                          SgWithStatement::next_node = &(pointer[i]);
  142546             :                        }
  142547             :                     else
  142548             :                        {
  142549             :                       // printf ("In SgWithStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  142550           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  142551             :                        }
  142552             :                     pointerOfLinkedList = &(pointer[i]);
  142553             :                   }
  142554             :               }
  142555             :         }
  142556             : 
  142557           5 :      if ( pointerOfLinkedList != NULL )
  142558             :         {
  142559             :        // printf ("In SgWithStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  142560           0 :           pointerOfLinkedList->set_freepointer(NULL);
  142561             :        // DQ (6/6/2010): Temporary debugging...
  142562             :        //   ROSE_ASSERT(false);
  142563             :         }
  142564             : 
  142565           5 :      return ;
  142566             :    }
  142567             : 
  142568             : //############################################################################
  142569             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  142570             :  * within the memory pool and resets the freepointers, in order to achieve a 
  142571             :  * linked list, that has no jumps and starts at the beginning! This function 
  142572             :  * does not extend the memory pool, since we do not delete any memory blocks,
  142573             :  * but delete the valid objects.  
  142574             :  */
  142575             : void
  142576           0 : SgWithStatement::clearMemoryPool( )
  142577             :    {
  142578             :   // printf ("Inside of SgWithStatement::clearMemoryPool() \n");
  142579             : 
  142580           0 :      SgWithStatement* pointer = NULL, *tempPointer = NULL;
  142581           0 :      std::vector < unsigned char* > :: const_iterator block;
  142582           0 :      if ( SgWithStatement::pools.empty() == false )
  142583             :         {
  142584           0 :           block = SgWithStatement::pools.begin() ;
  142585           0 :           SgWithStatement::next_node = (SgWithStatement*) (*block);
  142586             : 
  142587           0 :           while ( block != SgWithStatement::pools.end() )
  142588             :              {
  142589           0 :                pointer = (SgWithStatement*) (*block);
  142590           0 :                if ( tempPointer != NULL )
  142591             :                   {
  142592           0 :                     tempPointer->set_freepointer(pointer);
  142593             :                   }
  142594           0 :                for (unsigned i = 0; i < SgWithStatement::pool_size - 1; ++i)
  142595             :                   {
  142596           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  142597             :                   }
  142598           0 :                 pointer[SgWithStatement::pool_size-1].set_freepointer(NULL);
  142599           0 :                 tempPointer = &(pointer[SgWithStatement::pool_size-1]);
  142600           0 :                 ++block;
  142601             :              }
  142602             :         }
  142603           0 :    }
  142604             : 
  142605           5 : void SgWithStatement::deleteMemoryPool() {
  142606           5 :   for (auto p: SgWithStatement::pools) {
  142607           0 :     ROSE_FREE(p);
  142608             :   }
  142609           5 :   SgWithStatement::next_node = nullptr;
  142610           5 :   SgWithStatement::pools.clear();
  142611           5 : }
  142612             : 
  142613             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  142614             : //                 reading multiple binary files to for a single AST.
  142615             : /////////// new version ////////////////////////////////
  142616             : //############################################################################
  142617             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  142618             : void
  142619           2 : SgWithStatement::extendMemoryPoolForFileIO( )
  142620             :   {
  142621           2 :     size_t blockIndex = SgWithStatement::pools.size();
  142622           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgWithStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgWithStatement);
  142623             : 
  142624           2 :     while ( (blockIndex * SgWithStatement::pool_size) < newPoolSize)
  142625             :       {
  142626             : #if ROSE_ALLOC_TRACE
  142627             :         if (blockIndex > 0) {
  142628             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgWithStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgWithStatement) = %" PRIuPTR " SgWithStatement::pool_size = %d \n",
  142629             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgWithStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgWithStatement),SgWithStatement::pool_size);
  142630             :         }
  142631             : #endif
  142632             : 
  142633           0 :         SgWithStatement * pointer = (SgWithStatement*) ROSE_MALLOC ( SgWithStatement::pool_size * sizeof(SgWithStatement) );
  142634           0 :         assert( pointer != NULL );
  142635             : #if ROSE_ALLOC_MEMSET == 1
  142636             :         memset(pointer, 0x00, SgWithStatement::pool_size * sizeof(SgWithStatement));
  142637             : #elif ROSE_ALLOC_MEMSET == 2
  142638             :         memset(pointer, 0xCC, SgWithStatement::pool_size * sizeof(SgWithStatement));
  142639             : #endif
  142640           0 :         SgWithStatement::pools.push_back( (unsigned char*)(pointer) );
  142641           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgWithStatement::pool_size * sizeof(SgWithStatement), V_SgWithStatement ) );
  142642             : 
  142643           0 :         if ( SgWithStatement::next_node != NULL ) {
  142644           0 :           if ( blockIndex > 0 ) {
  142645           0 :             SgWithStatement * blkptr = (SgWithStatement*)(SgWithStatement::pools[blockIndex-1]);
  142646           0 :             blkptr[ SgWithStatement::pool_size - 1 ].set_freepointer(pointer);
  142647             :           }
  142648             :         } else {
  142649           0 :           SgWithStatement::next_node = pointer;
  142650             :         }
  142651             : 
  142652           0 :         for (unsigned i = 0; i < SgWithStatement::pool_size-1; ++i)
  142653             :            {
  142654           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  142655             :            }
  142656           0 :         pointer[ SgWithStatement::pool_size -1 ].set_freepointer(NULL);
  142657             : 
  142658           0 :         blockIndex++;
  142659             :       }
  142660           2 :   }
  142661             : 
  142662             : //############################################################################
  142663             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  142664             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  142665             :  * not compressed. However, that stuff is not yet implemented! 
  142666             :  */
  142667             : unsigned long
  142668           0 : SgWithStatement::getNumberOfLastValidPointer()
  142669             :    {
  142670           0 :       SgWithStatement* testPointer = (SgWithStatement*)(SgWithStatement::pools.back());
  142671           0 :       unsigned long localIndex = SgWithStatement::pool_size - 1;
  142672           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  142673             :          {
  142674           0 :            localIndex--;
  142675             :          }
  142676           0 :       return (localIndex + SgWithStatement::pool_size * (SgWithStatement::pools.size()-1));
  142677             :    }
  142678             : 
  142679             : //############################################################################
  142680             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  142681             :  * memory pool and initializes the data member in class SgWithStatementStroageClass
  142682             :  * from its counterpart of SgWithStatement. The return value is just for checking, 
  142683             :  * that the whole StorageClassArray is initialized!
  142684             :  */
  142685             : unsigned long
  142686           0 : SgWithStatement::initializeStorageClassArray( SgWithStatementStorageClass *storageArray )
  142687             :    {
  142688           0 :      unsigned long storageCounter = 0;
  142689           0 :      std::vector < unsigned char* > :: const_iterator block = SgWithStatement::pools.begin();
  142690           0 :      SgWithStatement* pointer = NULL;
  142691           0 :      while ( block != SgWithStatement::pools.end() ) {
  142692           0 :           pointer = (SgWithStatement*) (*block);
  142693           0 :           for ( unsigned i = 0; i < SgWithStatement::pool_size; ++i ) {
  142694           0 :                if ( pointer->get_freepointer() != NULL ) {
  142695           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  142696           0 :                  storageArray++;
  142697           0 :                  storageCounter++;
  142698             :                }
  142699           0 :                pointer++;
  142700             :              }
  142701           0 :            block++;
  142702             :         }
  142703           0 :      return storageCounter;
  142704             :    }
  142705             : 
  142706             : /* #line 142707 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  142707             : 
  142708             : 
  142709             : 
  142710             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  142711             : 
  142712             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  142713             : 
  142714             : //############################################################################
  142715             : /* JH (02/02/2006) Constructor of the IR node SgPassStatement that takes its 
  142716             :  * corresponding StorageClass as parameter
  142717             :  */
  142718           0 : SgPassStatement :: SgPassStatement ( const SgPassStatementStorageClass& storageSource )   : SgStatement (storageSource)
  142719             :    {
  142720             : 
  142721             : 
  142722             : /* #line 142723 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  142723             : 
  142724           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  142725             : 
  142726             : 
  142727             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  142728             : 
  142729             : 
  142730           0 :    }
  142731             : 
  142732             : //############################################################################
  142733             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  142734             :  * within the working AST. 
  142735             :  */
  142736           0 : SgPassStatement * SgPassStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  142737           0 :      SgPassStatement* returnPointer = NULL;
  142738           0 :      if ( globalIndex != 0 )
  142739             :         {
  142740             : 
  142741             : #if FILE_IO_EXTRA_CHECK
  142742           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPassStatement ) ) <= globalIndex ) ;
  142743           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPassStatement + 1 ) ) );
  142744             : #endif
  142745           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPassStatement )  
  142746           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPassStatement );
  142747           0 :           unsigned long positionInPool = localIndex % SgPassStatement::pool_size;
  142748           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPassStatement::pool_size;
  142749             : 
  142750             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  142751             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  142752             : 
  142753           0 :           returnPointer = &( ( (SgPassStatement*)(SgPassStatement::pools[memoryBlock]) ) [positionInPool]) ;
  142754             : 
  142755           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  142756             :         }
  142757           0 :      return returnPointer ;
  142758             :    }
  142759             : 
  142760             : //############################################################################
  142761             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  142762             :   for the AST with the index astIndex
  142763             : */
  142764           0 : SgPassStatement * SgPassStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  142765           0 :      SgPassStatement* returnPointer = NULL;
  142766           0 :      if ( globalIndex != 0 )
  142767             :         {
  142768             : 
  142769             : #if FILE_IO_EXTRA_CHECK
  142770           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPassStatement ) ) <= globalIndex ) ;
  142771           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPassStatement + 1 ) ) );
  142772             : #endif
  142773           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPassStatement )
  142774           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPassStatement );
  142775           0 :           unsigned long positionInPool = localIndex % SgPassStatement::pool_size ;
  142776           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPassStatement::pool_size ;
  142777             : 
  142778             : #if FILE_IO_EXTRA_CHECK
  142779             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  142780             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  142781             : #endif
  142782             : 
  142783           0 :           returnPointer = &( ( (SgPassStatement*)(SgPassStatement::pools[memoryBlock]) ) [positionInPool]) ;
  142784             : 
  142785             : #if FILE_IO_EXTRA_CHECK
  142786           0 :           assert ( returnPointer != NULL ) ;
  142787             : #endif
  142788             :         }
  142789           0 :      return returnPointer ;
  142790             :    }
  142791             : 
  142792             : //############################################################################
  142793             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  142794             :  * pool size! We set for every valid object in the memory pool the freepointer
  142795             :  * to the global index and increase the global index afterwards. For all the 
  142796             :  * invalid objects (means address ranges within the memory pool that were not
  142797             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  142798             :  * distinguish valid from invalid objects! 
  142799             :  */
  142800             : unsigned long
  142801           5 : SgPassStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  142802             :    {
  142803           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  142804           5 :      SgPassStatement* pointer = NULL;
  142805           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  142806           5 :      std::vector < unsigned char* > :: const_iterator block;
  142807           5 :      for ( block = SgPassStatement::pools.begin(); block != SgPassStatement::pools.end() ; ++block )
  142808             :         {
  142809           0 :           pointer = (SgPassStatement*)(*block);
  142810           0 :           for (unsigned i = 0; i < SgPassStatement::pool_size; ++i )
  142811             :              {
  142812             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  142813             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  142814             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  142815             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  142816             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  142817             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  142818             :             // properly; so this will have to be checked next.
  142819             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  142820             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  142821           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  142822             :                   {
  142823           0 :                     pointer[i].set_freepointer((SgPassStatement*)(globalIndex));
  142824           0 :                     globalIndex++;
  142825             :                   }
  142826             :                else
  142827             :                   {
  142828           0 :                     pointer[i].set_freepointer(NULL);
  142829             :                   }
  142830             :               }
  142831             :         }
  142832           5 :      return globalIndex;
  142833             :    }
  142834             : 
  142835             : //############################################################################
  142836             : // JH (01/14/2006)
  142837             : void
  142838           5 : SgPassStatement::resetValidFreepointers( )
  142839             :    {
  142840           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  142841           5 :      SgPassStatement* pointer = NULL;
  142842           5 :      std::vector < unsigned char* > :: const_iterator block;
  142843           5 :      SgPassStatement* pointerOfLinkedList = NULL;
  142844           5 :      for ( block = SgPassStatement::pools.begin(); block != SgPassStatement::pools.end() ; ++block )
  142845             :         {
  142846           0 :           pointer = (SgPassStatement*)(*block);
  142847           0 :           for (unsigned i = 0; i < SgPassStatement::pool_size; ++i )
  142848             :              {
  142849             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  142850             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  142851             :             // memory blocks!.
  142852           0 :                if ( pointer[i].get_freepointer() != NULL )
  142853             :                   {
  142854           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  142855             :                   }
  142856             :                else
  142857             :                   {
  142858           0 :                     if ( pointerOfLinkedList == NULL )
  142859             :                        {
  142860           0 :                          SgPassStatement::next_node = &(pointer[i]);
  142861             :                        }
  142862             :                     else
  142863             :                        {
  142864             :                       // printf ("In SgPassStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  142865           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  142866             :                        }
  142867             :                     pointerOfLinkedList = &(pointer[i]);
  142868             :                   }
  142869             :               }
  142870             :         }
  142871             : 
  142872           5 :      if ( pointerOfLinkedList != NULL )
  142873             :         {
  142874             :        // printf ("In SgPassStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  142875           0 :           pointerOfLinkedList->set_freepointer(NULL);
  142876             :        // DQ (6/6/2010): Temporary debugging...
  142877             :        //   ROSE_ASSERT(false);
  142878             :         }
  142879             : 
  142880           5 :      return ;
  142881             :    }
  142882             : 
  142883             : //############################################################################
  142884             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  142885             :  * within the memory pool and resets the freepointers, in order to achieve a 
  142886             :  * linked list, that has no jumps and starts at the beginning! This function 
  142887             :  * does not extend the memory pool, since we do not delete any memory blocks,
  142888             :  * but delete the valid objects.  
  142889             :  */
  142890             : void
  142891           0 : SgPassStatement::clearMemoryPool( )
  142892             :    {
  142893             :   // printf ("Inside of SgPassStatement::clearMemoryPool() \n");
  142894             : 
  142895           0 :      SgPassStatement* pointer = NULL, *tempPointer = NULL;
  142896           0 :      std::vector < unsigned char* > :: const_iterator block;
  142897           0 :      if ( SgPassStatement::pools.empty() == false )
  142898             :         {
  142899           0 :           block = SgPassStatement::pools.begin() ;
  142900           0 :           SgPassStatement::next_node = (SgPassStatement*) (*block);
  142901             : 
  142902           0 :           while ( block != SgPassStatement::pools.end() )
  142903             :              {
  142904           0 :                pointer = (SgPassStatement*) (*block);
  142905           0 :                if ( tempPointer != NULL )
  142906             :                   {
  142907           0 :                     tempPointer->set_freepointer(pointer);
  142908             :                   }
  142909           0 :                for (unsigned i = 0; i < SgPassStatement::pool_size - 1; ++i)
  142910             :                   {
  142911           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  142912             :                   }
  142913           0 :                 pointer[SgPassStatement::pool_size-1].set_freepointer(NULL);
  142914           0 :                 tempPointer = &(pointer[SgPassStatement::pool_size-1]);
  142915           0 :                 ++block;
  142916             :              }
  142917             :         }
  142918           0 :    }
  142919             : 
  142920           5 : void SgPassStatement::deleteMemoryPool() {
  142921           5 :   for (auto p: SgPassStatement::pools) {
  142922           0 :     ROSE_FREE(p);
  142923             :   }
  142924           5 :   SgPassStatement::next_node = nullptr;
  142925           5 :   SgPassStatement::pools.clear();
  142926           5 : }
  142927             : 
  142928             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  142929             : //                 reading multiple binary files to for a single AST.
  142930             : /////////// new version ////////////////////////////////
  142931             : //############################################################################
  142932             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  142933             : void
  142934           2 : SgPassStatement::extendMemoryPoolForFileIO( )
  142935             :   {
  142936           2 :     size_t blockIndex = SgPassStatement::pools.size();
  142937           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPassStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPassStatement);
  142938             : 
  142939           2 :     while ( (blockIndex * SgPassStatement::pool_size) < newPoolSize)
  142940             :       {
  142941             : #if ROSE_ALLOC_TRACE
  142942             :         if (blockIndex > 0) {
  142943             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPassStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPassStatement) = %" PRIuPTR " SgPassStatement::pool_size = %d \n",
  142944             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPassStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPassStatement),SgPassStatement::pool_size);
  142945             :         }
  142946             : #endif
  142947             : 
  142948           0 :         SgPassStatement * pointer = (SgPassStatement*) ROSE_MALLOC ( SgPassStatement::pool_size * sizeof(SgPassStatement) );
  142949           0 :         assert( pointer != NULL );
  142950             : #if ROSE_ALLOC_MEMSET == 1
  142951             :         memset(pointer, 0x00, SgPassStatement::pool_size * sizeof(SgPassStatement));
  142952             : #elif ROSE_ALLOC_MEMSET == 2
  142953             :         memset(pointer, 0xCC, SgPassStatement::pool_size * sizeof(SgPassStatement));
  142954             : #endif
  142955           0 :         SgPassStatement::pools.push_back( (unsigned char*)(pointer) );
  142956           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPassStatement::pool_size * sizeof(SgPassStatement), V_SgPassStatement ) );
  142957             : 
  142958           0 :         if ( SgPassStatement::next_node != NULL ) {
  142959           0 :           if ( blockIndex > 0 ) {
  142960           0 :             SgPassStatement * blkptr = (SgPassStatement*)(SgPassStatement::pools[blockIndex-1]);
  142961           0 :             blkptr[ SgPassStatement::pool_size - 1 ].set_freepointer(pointer);
  142962             :           }
  142963             :         } else {
  142964           0 :           SgPassStatement::next_node = pointer;
  142965             :         }
  142966             : 
  142967           0 :         for (unsigned i = 0; i < SgPassStatement::pool_size-1; ++i)
  142968             :            {
  142969           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  142970             :            }
  142971           0 :         pointer[ SgPassStatement::pool_size -1 ].set_freepointer(NULL);
  142972             : 
  142973           0 :         blockIndex++;
  142974             :       }
  142975           2 :   }
  142976             : 
  142977             : //############################################################################
  142978             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  142979             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  142980             :  * not compressed. However, that stuff is not yet implemented! 
  142981             :  */
  142982             : unsigned long
  142983           0 : SgPassStatement::getNumberOfLastValidPointer()
  142984             :    {
  142985           0 :       SgPassStatement* testPointer = (SgPassStatement*)(SgPassStatement::pools.back());
  142986           0 :       unsigned long localIndex = SgPassStatement::pool_size - 1;
  142987           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  142988             :          {
  142989           0 :            localIndex--;
  142990             :          }
  142991           0 :       return (localIndex + SgPassStatement::pool_size * (SgPassStatement::pools.size()-1));
  142992             :    }
  142993             : 
  142994             : //############################################################################
  142995             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  142996             :  * memory pool and initializes the data member in class SgPassStatementStroageClass
  142997             :  * from its counterpart of SgPassStatement. The return value is just for checking, 
  142998             :  * that the whole StorageClassArray is initialized!
  142999             :  */
  143000             : unsigned long
  143001           0 : SgPassStatement::initializeStorageClassArray( SgPassStatementStorageClass *storageArray )
  143002             :    {
  143003           0 :      unsigned long storageCounter = 0;
  143004           0 :      std::vector < unsigned char* > :: const_iterator block = SgPassStatement::pools.begin();
  143005           0 :      SgPassStatement* pointer = NULL;
  143006           0 :      while ( block != SgPassStatement::pools.end() ) {
  143007           0 :           pointer = (SgPassStatement*) (*block);
  143008           0 :           for ( unsigned i = 0; i < SgPassStatement::pool_size; ++i ) {
  143009           0 :                if ( pointer->get_freepointer() != NULL ) {
  143010           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  143011           0 :                  storageArray++;
  143012           0 :                  storageCounter++;
  143013             :                }
  143014           0 :                pointer++;
  143015             :              }
  143016           0 :            block++;
  143017             :         }
  143018           0 :      return storageCounter;
  143019             :    }
  143020             : 
  143021             : /* #line 143022 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  143022             : 
  143023             : 
  143024             : 
  143025             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  143026             : 
  143027             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  143028             : 
  143029             : //############################################################################
  143030             : /* JH (02/02/2006) Constructor of the IR node SgAssertStmt that takes its 
  143031             :  * corresponding StorageClass as parameter
  143032             :  */
  143033           0 : SgAssertStmt :: SgAssertStmt ( const SgAssertStmtStorageClass& storageSource )   : SgStatement (storageSource)
  143034             :    {
  143035             : 
  143036             : 
  143037             : /* #line 143038 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  143038             : 
  143039           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  143040           0 :      p_test =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_test) );
  143041           0 :      p_exception_argument =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_exception_argument) );
  143042             : 
  143043             : 
  143044             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  143045             : 
  143046             : 
  143047           0 :    }
  143048             : 
  143049             : //############################################################################
  143050             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  143051             :  * within the working AST. 
  143052             :  */
  143053           0 : SgAssertStmt * SgAssertStmt::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  143054           0 :      SgAssertStmt* returnPointer = NULL;
  143055           0 :      if ( globalIndex != 0 )
  143056             :         {
  143057             : 
  143058             : #if FILE_IO_EXTRA_CHECK
  143059           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAssertStmt ) ) <= globalIndex ) ;
  143060           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssertStmt + 1 ) ) );
  143061             : #endif
  143062           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssertStmt )  
  143063           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAssertStmt );
  143064           0 :           unsigned long positionInPool = localIndex % SgAssertStmt::pool_size;
  143065           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssertStmt::pool_size;
  143066             : 
  143067             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  143068             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  143069             : 
  143070           0 :           returnPointer = &( ( (SgAssertStmt*)(SgAssertStmt::pools[memoryBlock]) ) [positionInPool]) ;
  143071             : 
  143072           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  143073             :         }
  143074           0 :      return returnPointer ;
  143075             :    }
  143076             : 
  143077             : //############################################################################
  143078             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  143079             :   for the AST with the index astIndex
  143080             : */
  143081           0 : SgAssertStmt * SgAssertStmt::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  143082           0 :      SgAssertStmt* returnPointer = NULL;
  143083           0 :      if ( globalIndex != 0 )
  143084             :         {
  143085             : 
  143086             : #if FILE_IO_EXTRA_CHECK
  143087           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAssertStmt ) ) <= globalIndex ) ;
  143088           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssertStmt + 1 ) ) );
  143089             : #endif
  143090           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssertStmt )
  143091           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAssertStmt );
  143092           0 :           unsigned long positionInPool = localIndex % SgAssertStmt::pool_size ;
  143093           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssertStmt::pool_size ;
  143094             : 
  143095             : #if FILE_IO_EXTRA_CHECK
  143096             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  143097             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  143098             : #endif
  143099             : 
  143100           0 :           returnPointer = &( ( (SgAssertStmt*)(SgAssertStmt::pools[memoryBlock]) ) [positionInPool]) ;
  143101             : 
  143102             : #if FILE_IO_EXTRA_CHECK
  143103           0 :           assert ( returnPointer != NULL ) ;
  143104             : #endif
  143105             :         }
  143106           0 :      return returnPointer ;
  143107             :    }
  143108             : 
  143109             : //############################################################################
  143110             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  143111             :  * pool size! We set for every valid object in the memory pool the freepointer
  143112             :  * to the global index and increase the global index afterwards. For all the 
  143113             :  * invalid objects (means address ranges within the memory pool that were not
  143114             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  143115             :  * distinguish valid from invalid objects! 
  143116             :  */
  143117             : unsigned long
  143118           5 : SgAssertStmt::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  143119             :    {
  143120           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  143121           5 :      SgAssertStmt* pointer = NULL;
  143122           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  143123           5 :      std::vector < unsigned char* > :: const_iterator block;
  143124           5 :      for ( block = SgAssertStmt::pools.begin(); block != SgAssertStmt::pools.end() ; ++block )
  143125             :         {
  143126           0 :           pointer = (SgAssertStmt*)(*block);
  143127           0 :           for (unsigned i = 0; i < SgAssertStmt::pool_size; ++i )
  143128             :              {
  143129             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  143130             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  143131             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  143132             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  143133             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  143134             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  143135             :             // properly; so this will have to be checked next.
  143136             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  143137             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  143138           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  143139             :                   {
  143140           0 :                     pointer[i].set_freepointer((SgAssertStmt*)(globalIndex));
  143141           0 :                     globalIndex++;
  143142             :                   }
  143143             :                else
  143144             :                   {
  143145           0 :                     pointer[i].set_freepointer(NULL);
  143146             :                   }
  143147             :               }
  143148             :         }
  143149           5 :      return globalIndex;
  143150             :    }
  143151             : 
  143152             : //############################################################################
  143153             : // JH (01/14/2006)
  143154             : void
  143155           5 : SgAssertStmt::resetValidFreepointers( )
  143156             :    {
  143157           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  143158           5 :      SgAssertStmt* pointer = NULL;
  143159           5 :      std::vector < unsigned char* > :: const_iterator block;
  143160           5 :      SgAssertStmt* pointerOfLinkedList = NULL;
  143161           5 :      for ( block = SgAssertStmt::pools.begin(); block != SgAssertStmt::pools.end() ; ++block )
  143162             :         {
  143163           0 :           pointer = (SgAssertStmt*)(*block);
  143164           0 :           for (unsigned i = 0; i < SgAssertStmt::pool_size; ++i )
  143165             :              {
  143166             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  143167             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  143168             :             // memory blocks!.
  143169           0 :                if ( pointer[i].get_freepointer() != NULL )
  143170             :                   {
  143171           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  143172             :                   }
  143173             :                else
  143174             :                   {
  143175           0 :                     if ( pointerOfLinkedList == NULL )
  143176             :                        {
  143177           0 :                          SgAssertStmt::next_node = &(pointer[i]);
  143178             :                        }
  143179             :                     else
  143180             :                        {
  143181             :                       // printf ("In SgAssertStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  143182           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  143183             :                        }
  143184             :                     pointerOfLinkedList = &(pointer[i]);
  143185             :                   }
  143186             :               }
  143187             :         }
  143188             : 
  143189           5 :      if ( pointerOfLinkedList != NULL )
  143190             :         {
  143191             :        // printf ("In SgAssertStmt::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  143192           0 :           pointerOfLinkedList->set_freepointer(NULL);
  143193             :        // DQ (6/6/2010): Temporary debugging...
  143194             :        //   ROSE_ASSERT(false);
  143195             :         }
  143196             : 
  143197           5 :      return ;
  143198             :    }
  143199             : 
  143200             : //############################################################################
  143201             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  143202             :  * within the memory pool and resets the freepointers, in order to achieve a 
  143203             :  * linked list, that has no jumps and starts at the beginning! This function 
  143204             :  * does not extend the memory pool, since we do not delete any memory blocks,
  143205             :  * but delete the valid objects.  
  143206             :  */
  143207             : void
  143208           0 : SgAssertStmt::clearMemoryPool( )
  143209             :    {
  143210             :   // printf ("Inside of SgAssertStmt::clearMemoryPool() \n");
  143211             : 
  143212           0 :      SgAssertStmt* pointer = NULL, *tempPointer = NULL;
  143213           0 :      std::vector < unsigned char* > :: const_iterator block;
  143214           0 :      if ( SgAssertStmt::pools.empty() == false )
  143215             :         {
  143216           0 :           block = SgAssertStmt::pools.begin() ;
  143217           0 :           SgAssertStmt::next_node = (SgAssertStmt*) (*block);
  143218             : 
  143219           0 :           while ( block != SgAssertStmt::pools.end() )
  143220             :              {
  143221           0 :                pointer = (SgAssertStmt*) (*block);
  143222           0 :                if ( tempPointer != NULL )
  143223             :                   {
  143224           0 :                     tempPointer->set_freepointer(pointer);
  143225             :                   }
  143226           0 :                for (unsigned i = 0; i < SgAssertStmt::pool_size - 1; ++i)
  143227             :                   {
  143228           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  143229             :                   }
  143230           0 :                 pointer[SgAssertStmt::pool_size-1].set_freepointer(NULL);
  143231           0 :                 tempPointer = &(pointer[SgAssertStmt::pool_size-1]);
  143232           0 :                 ++block;
  143233             :              }
  143234             :         }
  143235           0 :    }
  143236             : 
  143237           5 : void SgAssertStmt::deleteMemoryPool() {
  143238           5 :   for (auto p: SgAssertStmt::pools) {
  143239           0 :     ROSE_FREE(p);
  143240             :   }
  143241           5 :   SgAssertStmt::next_node = nullptr;
  143242           5 :   SgAssertStmt::pools.clear();
  143243           5 : }
  143244             : 
  143245             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  143246             : //                 reading multiple binary files to for a single AST.
  143247             : /////////// new version ////////////////////////////////
  143248             : //############################################################################
  143249             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  143250             : void
  143251           2 : SgAssertStmt::extendMemoryPoolForFileIO( )
  143252             :   {
  143253           2 :     size_t blockIndex = SgAssertStmt::pools.size();
  143254           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAssertStmt) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssertStmt);
  143255             : 
  143256           2 :     while ( (blockIndex * SgAssertStmt::pool_size) < newPoolSize)
  143257             :       {
  143258             : #if ROSE_ALLOC_TRACE
  143259             :         if (blockIndex > 0) {
  143260             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAssertStmt) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssertStmt) = %" PRIuPTR " SgAssertStmt::pool_size = %d \n",
  143261             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAssertStmt),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssertStmt),SgAssertStmt::pool_size);
  143262             :         }
  143263             : #endif
  143264             : 
  143265           0 :         SgAssertStmt * pointer = (SgAssertStmt*) ROSE_MALLOC ( SgAssertStmt::pool_size * sizeof(SgAssertStmt) );
  143266           0 :         assert( pointer != NULL );
  143267             : #if ROSE_ALLOC_MEMSET == 1
  143268             :         memset(pointer, 0x00, SgAssertStmt::pool_size * sizeof(SgAssertStmt));
  143269             : #elif ROSE_ALLOC_MEMSET == 2
  143270             :         memset(pointer, 0xCC, SgAssertStmt::pool_size * sizeof(SgAssertStmt));
  143271             : #endif
  143272           0 :         SgAssertStmt::pools.push_back( (unsigned char*)(pointer) );
  143273           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAssertStmt::pool_size * sizeof(SgAssertStmt), V_SgAssertStmt ) );
  143274             : 
  143275           0 :         if ( SgAssertStmt::next_node != NULL ) {
  143276           0 :           if ( blockIndex > 0 ) {
  143277           0 :             SgAssertStmt * blkptr = (SgAssertStmt*)(SgAssertStmt::pools[blockIndex-1]);
  143278           0 :             blkptr[ SgAssertStmt::pool_size - 1 ].set_freepointer(pointer);
  143279             :           }
  143280             :         } else {
  143281           0 :           SgAssertStmt::next_node = pointer;
  143282             :         }
  143283             : 
  143284           0 :         for (unsigned i = 0; i < SgAssertStmt::pool_size-1; ++i)
  143285             :            {
  143286           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  143287             :            }
  143288           0 :         pointer[ SgAssertStmt::pool_size -1 ].set_freepointer(NULL);
  143289             : 
  143290           0 :         blockIndex++;
  143291             :       }
  143292           2 :   }
  143293             : 
  143294             : //############################################################################
  143295             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  143296             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  143297             :  * not compressed. However, that stuff is not yet implemented! 
  143298             :  */
  143299             : unsigned long
  143300           0 : SgAssertStmt::getNumberOfLastValidPointer()
  143301             :    {
  143302           0 :       SgAssertStmt* testPointer = (SgAssertStmt*)(SgAssertStmt::pools.back());
  143303           0 :       unsigned long localIndex = SgAssertStmt::pool_size - 1;
  143304           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  143305             :          {
  143306           0 :            localIndex--;
  143307             :          }
  143308           0 :       return (localIndex + SgAssertStmt::pool_size * (SgAssertStmt::pools.size()-1));
  143309             :    }
  143310             : 
  143311             : //############################################################################
  143312             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  143313             :  * memory pool and initializes the data member in class SgAssertStmtStroageClass
  143314             :  * from its counterpart of SgAssertStmt. The return value is just for checking, 
  143315             :  * that the whole StorageClassArray is initialized!
  143316             :  */
  143317             : unsigned long
  143318           0 : SgAssertStmt::initializeStorageClassArray( SgAssertStmtStorageClass *storageArray )
  143319             :    {
  143320           0 :      unsigned long storageCounter = 0;
  143321           0 :      std::vector < unsigned char* > :: const_iterator block = SgAssertStmt::pools.begin();
  143322           0 :      SgAssertStmt* pointer = NULL;
  143323           0 :      while ( block != SgAssertStmt::pools.end() ) {
  143324           0 :           pointer = (SgAssertStmt*) (*block);
  143325           0 :           for ( unsigned i = 0; i < SgAssertStmt::pool_size; ++i ) {
  143326           0 :                if ( pointer->get_freepointer() != NULL ) {
  143327           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  143328           0 :                  storageArray++;
  143329           0 :                  storageCounter++;
  143330             :                }
  143331           0 :                pointer++;
  143332             :              }
  143333           0 :            block++;
  143334             :         }
  143335           0 :      return storageCounter;
  143336             :    }
  143337             : 
  143338             : /* #line 143339 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  143339             : 
  143340             : 
  143341             : 
  143342             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  143343             : 
  143344             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  143345             : 
  143346             : //############################################################################
  143347             : /* JH (02/02/2006) Constructor of the IR node SgExecStatement that takes its 
  143348             :  * corresponding StorageClass as parameter
  143349             :  */
  143350           0 : SgExecStatement :: SgExecStatement ( const SgExecStatementStorageClass& storageSource )   : SgStatement (storageSource)
  143351             :    {
  143352             : 
  143353             : 
  143354             : /* #line 143355 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  143355             : 
  143356           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  143357           0 :      p_executable =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_executable) );
  143358           0 :      p_globals =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_globals) );
  143359           0 :      p_locals =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_locals) );
  143360             : 
  143361             : 
  143362             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  143363             : 
  143364             : 
  143365           0 :    }
  143366             : 
  143367             : //############################################################################
  143368             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  143369             :  * within the working AST. 
  143370             :  */
  143371           0 : SgExecStatement * SgExecStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  143372           0 :      SgExecStatement* returnPointer = NULL;
  143373           0 :      if ( globalIndex != 0 )
  143374             :         {
  143375             : 
  143376             : #if FILE_IO_EXTRA_CHECK
  143377           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgExecStatement ) ) <= globalIndex ) ;
  143378           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExecStatement + 1 ) ) );
  143379             : #endif
  143380           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExecStatement )  
  143381           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgExecStatement );
  143382           0 :           unsigned long positionInPool = localIndex % SgExecStatement::pool_size;
  143383           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExecStatement::pool_size;
  143384             : 
  143385             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  143386             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  143387             : 
  143388           0 :           returnPointer = &( ( (SgExecStatement*)(SgExecStatement::pools[memoryBlock]) ) [positionInPool]) ;
  143389             : 
  143390           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  143391             :         }
  143392           0 :      return returnPointer ;
  143393             :    }
  143394             : 
  143395             : //############################################################################
  143396             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  143397             :   for the AST with the index astIndex
  143398             : */
  143399           0 : SgExecStatement * SgExecStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  143400           0 :      SgExecStatement* returnPointer = NULL;
  143401           0 :      if ( globalIndex != 0 )
  143402             :         {
  143403             : 
  143404             : #if FILE_IO_EXTRA_CHECK
  143405           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgExecStatement ) ) <= globalIndex ) ;
  143406           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExecStatement + 1 ) ) );
  143407             : #endif
  143408           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExecStatement )
  143409           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgExecStatement );
  143410           0 :           unsigned long positionInPool = localIndex % SgExecStatement::pool_size ;
  143411           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExecStatement::pool_size ;
  143412             : 
  143413             : #if FILE_IO_EXTRA_CHECK
  143414             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  143415             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  143416             : #endif
  143417             : 
  143418           0 :           returnPointer = &( ( (SgExecStatement*)(SgExecStatement::pools[memoryBlock]) ) [positionInPool]) ;
  143419             : 
  143420             : #if FILE_IO_EXTRA_CHECK
  143421           0 :           assert ( returnPointer != NULL ) ;
  143422             : #endif
  143423             :         }
  143424           0 :      return returnPointer ;
  143425             :    }
  143426             : 
  143427             : //############################################################################
  143428             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  143429             :  * pool size! We set for every valid object in the memory pool the freepointer
  143430             :  * to the global index and increase the global index afterwards. For all the 
  143431             :  * invalid objects (means address ranges within the memory pool that were not
  143432             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  143433             :  * distinguish valid from invalid objects! 
  143434             :  */
  143435             : unsigned long
  143436           5 : SgExecStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  143437             :    {
  143438           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  143439           5 :      SgExecStatement* pointer = NULL;
  143440           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  143441           5 :      std::vector < unsigned char* > :: const_iterator block;
  143442           5 :      for ( block = SgExecStatement::pools.begin(); block != SgExecStatement::pools.end() ; ++block )
  143443             :         {
  143444           0 :           pointer = (SgExecStatement*)(*block);
  143445           0 :           for (unsigned i = 0; i < SgExecStatement::pool_size; ++i )
  143446             :              {
  143447             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  143448             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  143449             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  143450             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  143451             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  143452             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  143453             :             // properly; so this will have to be checked next.
  143454             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  143455             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  143456           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  143457             :                   {
  143458           0 :                     pointer[i].set_freepointer((SgExecStatement*)(globalIndex));
  143459           0 :                     globalIndex++;
  143460             :                   }
  143461             :                else
  143462             :                   {
  143463           0 :                     pointer[i].set_freepointer(NULL);
  143464             :                   }
  143465             :               }
  143466             :         }
  143467           5 :      return globalIndex;
  143468             :    }
  143469             : 
  143470             : //############################################################################
  143471             : // JH (01/14/2006)
  143472             : void
  143473           5 : SgExecStatement::resetValidFreepointers( )
  143474             :    {
  143475           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  143476           5 :      SgExecStatement* pointer = NULL;
  143477           5 :      std::vector < unsigned char* > :: const_iterator block;
  143478           5 :      SgExecStatement* pointerOfLinkedList = NULL;
  143479           5 :      for ( block = SgExecStatement::pools.begin(); block != SgExecStatement::pools.end() ; ++block )
  143480             :         {
  143481           0 :           pointer = (SgExecStatement*)(*block);
  143482           0 :           for (unsigned i = 0; i < SgExecStatement::pool_size; ++i )
  143483             :              {
  143484             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  143485             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  143486             :             // memory blocks!.
  143487           0 :                if ( pointer[i].get_freepointer() != NULL )
  143488             :                   {
  143489           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  143490             :                   }
  143491             :                else
  143492             :                   {
  143493           0 :                     if ( pointerOfLinkedList == NULL )
  143494             :                        {
  143495           0 :                          SgExecStatement::next_node = &(pointer[i]);
  143496             :                        }
  143497             :                     else
  143498             :                        {
  143499             :                       // printf ("In SgExecStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  143500           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  143501             :                        }
  143502             :                     pointerOfLinkedList = &(pointer[i]);
  143503             :                   }
  143504             :               }
  143505             :         }
  143506             : 
  143507           5 :      if ( pointerOfLinkedList != NULL )
  143508             :         {
  143509             :        // printf ("In SgExecStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  143510           0 :           pointerOfLinkedList->set_freepointer(NULL);
  143511             :        // DQ (6/6/2010): Temporary debugging...
  143512             :        //   ROSE_ASSERT(false);
  143513             :         }
  143514             : 
  143515           5 :      return ;
  143516             :    }
  143517             : 
  143518             : //############################################################################
  143519             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  143520             :  * within the memory pool and resets the freepointers, in order to achieve a 
  143521             :  * linked list, that has no jumps and starts at the beginning! This function 
  143522             :  * does not extend the memory pool, since we do not delete any memory blocks,
  143523             :  * but delete the valid objects.  
  143524             :  */
  143525             : void
  143526           0 : SgExecStatement::clearMemoryPool( )
  143527             :    {
  143528             :   // printf ("Inside of SgExecStatement::clearMemoryPool() \n");
  143529             : 
  143530           0 :      SgExecStatement* pointer = NULL, *tempPointer = NULL;
  143531           0 :      std::vector < unsigned char* > :: const_iterator block;
  143532           0 :      if ( SgExecStatement::pools.empty() == false )
  143533             :         {
  143534           0 :           block = SgExecStatement::pools.begin() ;
  143535           0 :           SgExecStatement::next_node = (SgExecStatement*) (*block);
  143536             : 
  143537           0 :           while ( block != SgExecStatement::pools.end() )
  143538             :              {
  143539           0 :                pointer = (SgExecStatement*) (*block);
  143540           0 :                if ( tempPointer != NULL )
  143541             :                   {
  143542           0 :                     tempPointer->set_freepointer(pointer);
  143543             :                   }
  143544           0 :                for (unsigned i = 0; i < SgExecStatement::pool_size - 1; ++i)
  143545             :                   {
  143546           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  143547             :                   }
  143548           0 :                 pointer[SgExecStatement::pool_size-1].set_freepointer(NULL);
  143549           0 :                 tempPointer = &(pointer[SgExecStatement::pool_size-1]);
  143550           0 :                 ++block;
  143551             :              }
  143552             :         }
  143553           0 :    }
  143554             : 
  143555           5 : void SgExecStatement::deleteMemoryPool() {
  143556           5 :   for (auto p: SgExecStatement::pools) {
  143557           0 :     ROSE_FREE(p);
  143558             :   }
  143559           5 :   SgExecStatement::next_node = nullptr;
  143560           5 :   SgExecStatement::pools.clear();
  143561           5 : }
  143562             : 
  143563             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  143564             : //                 reading multiple binary files to for a single AST.
  143565             : /////////// new version ////////////////////////////////
  143566             : //############################################################################
  143567             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  143568             : void
  143569           2 : SgExecStatement::extendMemoryPoolForFileIO( )
  143570             :   {
  143571           2 :     size_t blockIndex = SgExecStatement::pools.size();
  143572           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgExecStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgExecStatement);
  143573             : 
  143574           2 :     while ( (blockIndex * SgExecStatement::pool_size) < newPoolSize)
  143575             :       {
  143576             : #if ROSE_ALLOC_TRACE
  143577             :         if (blockIndex > 0) {
  143578             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgExecStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgExecStatement) = %" PRIuPTR " SgExecStatement::pool_size = %d \n",
  143579             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgExecStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgExecStatement),SgExecStatement::pool_size);
  143580             :         }
  143581             : #endif
  143582             : 
  143583           0 :         SgExecStatement * pointer = (SgExecStatement*) ROSE_MALLOC ( SgExecStatement::pool_size * sizeof(SgExecStatement) );
  143584           0 :         assert( pointer != NULL );
  143585             : #if ROSE_ALLOC_MEMSET == 1
  143586             :         memset(pointer, 0x00, SgExecStatement::pool_size * sizeof(SgExecStatement));
  143587             : #elif ROSE_ALLOC_MEMSET == 2
  143588             :         memset(pointer, 0xCC, SgExecStatement::pool_size * sizeof(SgExecStatement));
  143589             : #endif
  143590           0 :         SgExecStatement::pools.push_back( (unsigned char*)(pointer) );
  143591           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgExecStatement::pool_size * sizeof(SgExecStatement), V_SgExecStatement ) );
  143592             : 
  143593           0 :         if ( SgExecStatement::next_node != NULL ) {
  143594           0 :           if ( blockIndex > 0 ) {
  143595           0 :             SgExecStatement * blkptr = (SgExecStatement*)(SgExecStatement::pools[blockIndex-1]);
  143596           0 :             blkptr[ SgExecStatement::pool_size - 1 ].set_freepointer(pointer);
  143597             :           }
  143598             :         } else {
  143599           0 :           SgExecStatement::next_node = pointer;
  143600             :         }
  143601             : 
  143602           0 :         for (unsigned i = 0; i < SgExecStatement::pool_size-1; ++i)
  143603             :            {
  143604           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  143605             :            }
  143606           0 :         pointer[ SgExecStatement::pool_size -1 ].set_freepointer(NULL);
  143607             : 
  143608           0 :         blockIndex++;
  143609             :       }
  143610           2 :   }
  143611             : 
  143612             : //############################################################################
  143613             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  143614             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  143615             :  * not compressed. However, that stuff is not yet implemented! 
  143616             :  */
  143617             : unsigned long
  143618           0 : SgExecStatement::getNumberOfLastValidPointer()
  143619             :    {
  143620           0 :       SgExecStatement* testPointer = (SgExecStatement*)(SgExecStatement::pools.back());
  143621           0 :       unsigned long localIndex = SgExecStatement::pool_size - 1;
  143622           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  143623             :          {
  143624           0 :            localIndex--;
  143625             :          }
  143626           0 :       return (localIndex + SgExecStatement::pool_size * (SgExecStatement::pools.size()-1));
  143627             :    }
  143628             : 
  143629             : //############################################################################
  143630             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  143631             :  * memory pool and initializes the data member in class SgExecStatementStroageClass
  143632             :  * from its counterpart of SgExecStatement. The return value is just for checking, 
  143633             :  * that the whole StorageClassArray is initialized!
  143634             :  */
  143635             : unsigned long
  143636           0 : SgExecStatement::initializeStorageClassArray( SgExecStatementStorageClass *storageArray )
  143637             :    {
  143638           0 :      unsigned long storageCounter = 0;
  143639           0 :      std::vector < unsigned char* > :: const_iterator block = SgExecStatement::pools.begin();
  143640           0 :      SgExecStatement* pointer = NULL;
  143641           0 :      while ( block != SgExecStatement::pools.end() ) {
  143642           0 :           pointer = (SgExecStatement*) (*block);
  143643           0 :           for ( unsigned i = 0; i < SgExecStatement::pool_size; ++i ) {
  143644           0 :                if ( pointer->get_freepointer() != NULL ) {
  143645           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  143646           0 :                  storageArray++;
  143647           0 :                  storageCounter++;
  143648             :                }
  143649           0 :                pointer++;
  143650             :              }
  143651           0 :            block++;
  143652             :         }
  143653           0 :      return storageCounter;
  143654             :    }
  143655             : 
  143656             : /* #line 143657 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  143657             : 
  143658             : 
  143659             : 
  143660             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  143661             : 
  143662             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  143663             : 
  143664             : //############################################################################
  143665             : /* JH (02/02/2006) Constructor of the IR node SgImageControlStatement that takes its 
  143666             :  * corresponding StorageClass as parameter
  143667             :  */
  143668           0 : SgImageControlStatement :: SgImageControlStatement ( const SgImageControlStatementStorageClass& storageSource )   : SgStatement (storageSource)
  143669             :    {
  143670             : 
  143671             : 
  143672             : /* #line 143673 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  143673             : 
  143674           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  143675           0 :      p_image_control_statement = storageSource.storageOf_image_control_statement ;
  143676           0 :      p_stat =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_stat) );
  143677           0 :      p_err_msg =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_err_msg) );
  143678           0 :      p_acquired_lock =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_acquired_lock) );
  143679             : 
  143680             : 
  143681             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  143682             : 
  143683             : 
  143684           0 :    }
  143685             : 
  143686             : //############################################################################
  143687             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  143688             :  * within the working AST. 
  143689             :  */
  143690           0 : SgImageControlStatement * SgImageControlStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  143691           0 :      SgImageControlStatement* returnPointer = NULL;
  143692           0 :      if ( globalIndex != 0 )
  143693             :         {
  143694             : 
  143695             : #if FILE_IO_EXTRA_CHECK
  143696           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgImageControlStatement ) ) <= globalIndex ) ;
  143697           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImageControlStatement + 1 ) ) );
  143698             : #endif
  143699           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImageControlStatement )  
  143700           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgImageControlStatement );
  143701           0 :           unsigned long positionInPool = localIndex % SgImageControlStatement::pool_size;
  143702           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImageControlStatement::pool_size;
  143703             : 
  143704             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  143705             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  143706             : 
  143707           0 :           returnPointer = &( ( (SgImageControlStatement*)(SgImageControlStatement::pools[memoryBlock]) ) [positionInPool]) ;
  143708             : 
  143709           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  143710             :         }
  143711           0 :      return returnPointer ;
  143712             :    }
  143713             : 
  143714             : //############################################################################
  143715             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  143716             :   for the AST with the index astIndex
  143717             : */
  143718           0 : SgImageControlStatement * SgImageControlStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  143719           0 :      SgImageControlStatement* returnPointer = NULL;
  143720           0 :      if ( globalIndex != 0 )
  143721             :         {
  143722             : 
  143723             : #if FILE_IO_EXTRA_CHECK
  143724           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgImageControlStatement ) ) <= globalIndex ) ;
  143725           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImageControlStatement + 1 ) ) );
  143726             : #endif
  143727           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImageControlStatement )
  143728           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgImageControlStatement );
  143729           0 :           unsigned long positionInPool = localIndex % SgImageControlStatement::pool_size ;
  143730           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImageControlStatement::pool_size ;
  143731             : 
  143732             : #if FILE_IO_EXTRA_CHECK
  143733             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  143734             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  143735             : #endif
  143736             : 
  143737           0 :           returnPointer = &( ( (SgImageControlStatement*)(SgImageControlStatement::pools[memoryBlock]) ) [positionInPool]) ;
  143738             : 
  143739             : #if FILE_IO_EXTRA_CHECK
  143740           0 :           assert ( returnPointer != NULL ) ;
  143741             : #endif
  143742             :         }
  143743           0 :      return returnPointer ;
  143744             :    }
  143745             : 
  143746             : //############################################################################
  143747             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  143748             :  * pool size! We set for every valid object in the memory pool the freepointer
  143749             :  * to the global index and increase the global index afterwards. For all the 
  143750             :  * invalid objects (means address ranges within the memory pool that were not
  143751             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  143752             :  * distinguish valid from invalid objects! 
  143753             :  */
  143754             : unsigned long
  143755           5 : SgImageControlStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  143756             :    {
  143757           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  143758           5 :      SgImageControlStatement* pointer = NULL;
  143759           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  143760           5 :      std::vector < unsigned char* > :: const_iterator block;
  143761           5 :      for ( block = SgImageControlStatement::pools.begin(); block != SgImageControlStatement::pools.end() ; ++block )
  143762             :         {
  143763           0 :           pointer = (SgImageControlStatement*)(*block);
  143764           0 :           for (unsigned i = 0; i < SgImageControlStatement::pool_size; ++i )
  143765             :              {
  143766             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  143767             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  143768             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  143769             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  143770             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  143771             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  143772             :             // properly; so this will have to be checked next.
  143773             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  143774             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  143775           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  143776             :                   {
  143777           0 :                     pointer[i].set_freepointer((SgImageControlStatement*)(globalIndex));
  143778           0 :                     globalIndex++;
  143779             :                   }
  143780             :                else
  143781             :                   {
  143782           0 :                     pointer[i].set_freepointer(NULL);
  143783             :                   }
  143784             :               }
  143785             :         }
  143786           5 :      return globalIndex;
  143787             :    }
  143788             : 
  143789             : //############################################################################
  143790             : // JH (01/14/2006)
  143791             : void
  143792           5 : SgImageControlStatement::resetValidFreepointers( )
  143793             :    {
  143794           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  143795           5 :      SgImageControlStatement* pointer = NULL;
  143796           5 :      std::vector < unsigned char* > :: const_iterator block;
  143797           5 :      SgImageControlStatement* pointerOfLinkedList = NULL;
  143798           5 :      for ( block = SgImageControlStatement::pools.begin(); block != SgImageControlStatement::pools.end() ; ++block )
  143799             :         {
  143800           0 :           pointer = (SgImageControlStatement*)(*block);
  143801           0 :           for (unsigned i = 0; i < SgImageControlStatement::pool_size; ++i )
  143802             :              {
  143803             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  143804             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  143805             :             // memory blocks!.
  143806           0 :                if ( pointer[i].get_freepointer() != NULL )
  143807             :                   {
  143808           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  143809             :                   }
  143810             :                else
  143811             :                   {
  143812           0 :                     if ( pointerOfLinkedList == NULL )
  143813             :                        {
  143814           0 :                          SgImageControlStatement::next_node = &(pointer[i]);
  143815             :                        }
  143816             :                     else
  143817             :                        {
  143818             :                       // printf ("In SgImageControlStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  143819           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  143820             :                        }
  143821             :                     pointerOfLinkedList = &(pointer[i]);
  143822             :                   }
  143823             :               }
  143824             :         }
  143825             : 
  143826           5 :      if ( pointerOfLinkedList != NULL )
  143827             :         {
  143828             :        // printf ("In SgImageControlStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  143829           0 :           pointerOfLinkedList->set_freepointer(NULL);
  143830             :        // DQ (6/6/2010): Temporary debugging...
  143831             :        //   ROSE_ASSERT(false);
  143832             :         }
  143833             : 
  143834           5 :      return ;
  143835             :    }
  143836             : 
  143837             : //############################################################################
  143838             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  143839             :  * within the memory pool and resets the freepointers, in order to achieve a 
  143840             :  * linked list, that has no jumps and starts at the beginning! This function 
  143841             :  * does not extend the memory pool, since we do not delete any memory blocks,
  143842             :  * but delete the valid objects.  
  143843             :  */
  143844             : void
  143845           0 : SgImageControlStatement::clearMemoryPool( )
  143846             :    {
  143847             :   // printf ("Inside of SgImageControlStatement::clearMemoryPool() \n");
  143848             : 
  143849           0 :      SgImageControlStatement* pointer = NULL, *tempPointer = NULL;
  143850           0 :      std::vector < unsigned char* > :: const_iterator block;
  143851           0 :      if ( SgImageControlStatement::pools.empty() == false )
  143852             :         {
  143853           0 :           block = SgImageControlStatement::pools.begin() ;
  143854           0 :           SgImageControlStatement::next_node = (SgImageControlStatement*) (*block);
  143855             : 
  143856           0 :           while ( block != SgImageControlStatement::pools.end() )
  143857             :              {
  143858           0 :                pointer = (SgImageControlStatement*) (*block);
  143859           0 :                if ( tempPointer != NULL )
  143860             :                   {
  143861           0 :                     tempPointer->set_freepointer(pointer);
  143862             :                   }
  143863           0 :                for (unsigned i = 0; i < SgImageControlStatement::pool_size - 1; ++i)
  143864             :                   {
  143865           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  143866             :                   }
  143867           0 :                 pointer[SgImageControlStatement::pool_size-1].set_freepointer(NULL);
  143868           0 :                 tempPointer = &(pointer[SgImageControlStatement::pool_size-1]);
  143869           0 :                 ++block;
  143870             :              }
  143871             :         }
  143872           0 :    }
  143873             : 
  143874           5 : void SgImageControlStatement::deleteMemoryPool() {
  143875           5 :   for (auto p: SgImageControlStatement::pools) {
  143876           0 :     ROSE_FREE(p);
  143877             :   }
  143878           5 :   SgImageControlStatement::next_node = nullptr;
  143879           5 :   SgImageControlStatement::pools.clear();
  143880           5 : }
  143881             : 
  143882             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  143883             : //                 reading multiple binary files to for a single AST.
  143884             : /////////// new version ////////////////////////////////
  143885             : //############################################################################
  143886             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  143887             : void
  143888           2 : SgImageControlStatement::extendMemoryPoolForFileIO( )
  143889             :   {
  143890           2 :     size_t blockIndex = SgImageControlStatement::pools.size();
  143891           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgImageControlStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgImageControlStatement);
  143892             : 
  143893           2 :     while ( (blockIndex * SgImageControlStatement::pool_size) < newPoolSize)
  143894             :       {
  143895             : #if ROSE_ALLOC_TRACE
  143896             :         if (blockIndex > 0) {
  143897             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgImageControlStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgImageControlStatement) = %" PRIuPTR " SgImageControlStatement::pool_size = %d \n",
  143898             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgImageControlStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgImageControlStatement),SgImageControlStatement::pool_size);
  143899             :         }
  143900             : #endif
  143901             : 
  143902           0 :         SgImageControlStatement * pointer = (SgImageControlStatement*) ROSE_MALLOC ( SgImageControlStatement::pool_size * sizeof(SgImageControlStatement) );
  143903           0 :         assert( pointer != NULL );
  143904             : #if ROSE_ALLOC_MEMSET == 1
  143905             :         memset(pointer, 0x00, SgImageControlStatement::pool_size * sizeof(SgImageControlStatement));
  143906             : #elif ROSE_ALLOC_MEMSET == 2
  143907             :         memset(pointer, 0xCC, SgImageControlStatement::pool_size * sizeof(SgImageControlStatement));
  143908             : #endif
  143909           0 :         SgImageControlStatement::pools.push_back( (unsigned char*)(pointer) );
  143910           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgImageControlStatement::pool_size * sizeof(SgImageControlStatement), V_SgImageControlStatement ) );
  143911             : 
  143912           0 :         if ( SgImageControlStatement::next_node != NULL ) {
  143913           0 :           if ( blockIndex > 0 ) {
  143914           0 :             SgImageControlStatement * blkptr = (SgImageControlStatement*)(SgImageControlStatement::pools[blockIndex-1]);
  143915           0 :             blkptr[ SgImageControlStatement::pool_size - 1 ].set_freepointer(pointer);
  143916             :           }
  143917             :         } else {
  143918           0 :           SgImageControlStatement::next_node = pointer;
  143919             :         }
  143920             : 
  143921           0 :         for (unsigned i = 0; i < SgImageControlStatement::pool_size-1; ++i)
  143922             :            {
  143923           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  143924             :            }
  143925           0 :         pointer[ SgImageControlStatement::pool_size -1 ].set_freepointer(NULL);
  143926             : 
  143927           0 :         blockIndex++;
  143928             :       }
  143929           2 :   }
  143930             : 
  143931             : //############################################################################
  143932             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  143933             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  143934             :  * not compressed. However, that stuff is not yet implemented! 
  143935             :  */
  143936             : unsigned long
  143937           0 : SgImageControlStatement::getNumberOfLastValidPointer()
  143938             :    {
  143939           0 :       SgImageControlStatement* testPointer = (SgImageControlStatement*)(SgImageControlStatement::pools.back());
  143940           0 :       unsigned long localIndex = SgImageControlStatement::pool_size - 1;
  143941           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  143942             :          {
  143943           0 :            localIndex--;
  143944             :          }
  143945           0 :       return (localIndex + SgImageControlStatement::pool_size * (SgImageControlStatement::pools.size()-1));
  143946             :    }
  143947             : 
  143948             : //############################################################################
  143949             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  143950             :  * memory pool and initializes the data member in class SgImageControlStatementStroageClass
  143951             :  * from its counterpart of SgImageControlStatement. The return value is just for checking, 
  143952             :  * that the whole StorageClassArray is initialized!
  143953             :  */
  143954             : unsigned long
  143955           0 : SgImageControlStatement::initializeStorageClassArray( SgImageControlStatementStorageClass *storageArray )
  143956             :    {
  143957           0 :      unsigned long storageCounter = 0;
  143958           0 :      std::vector < unsigned char* > :: const_iterator block = SgImageControlStatement::pools.begin();
  143959           0 :      SgImageControlStatement* pointer = NULL;
  143960           0 :      while ( block != SgImageControlStatement::pools.end() ) {
  143961           0 :           pointer = (SgImageControlStatement*) (*block);
  143962           0 :           for ( unsigned i = 0; i < SgImageControlStatement::pool_size; ++i ) {
  143963           0 :                if ( pointer->get_freepointer() != NULL ) {
  143964           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  143965           0 :                  storageArray++;
  143966           0 :                  storageCounter++;
  143967             :                }
  143968           0 :                pointer++;
  143969             :              }
  143970           0 :            block++;
  143971             :         }
  143972           0 :      return storageCounter;
  143973             :    }
  143974             : 
  143975             : /* #line 143976 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  143976             : 
  143977             : 
  143978             : 
  143979             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  143980             : 
  143981             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  143982             : 
  143983             : //############################################################################
  143984             : /* JH (02/02/2006) Constructor of the IR node SgSyncAllStatement that takes its 
  143985             :  * corresponding StorageClass as parameter
  143986             :  */
  143987           0 : SgSyncAllStatement :: SgSyncAllStatement ( const SgSyncAllStatementStorageClass& storageSource )   : SgImageControlStatement (storageSource)
  143988             :    {
  143989             : 
  143990             : 
  143991             : /* #line 143992 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  143992             : 
  143993           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  143994             : 
  143995             : 
  143996             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  143997             : 
  143998             : 
  143999           0 :    }
  144000             : 
  144001             : //############################################################################
  144002             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  144003             :  * within the working AST. 
  144004             :  */
  144005           0 : SgSyncAllStatement * SgSyncAllStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  144006           0 :      SgSyncAllStatement* returnPointer = NULL;
  144007           0 :      if ( globalIndex != 0 )
  144008             :         {
  144009             : 
  144010             : #if FILE_IO_EXTRA_CHECK
  144011           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSyncAllStatement ) ) <= globalIndex ) ;
  144012           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSyncAllStatement + 1 ) ) );
  144013             : #endif
  144014           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSyncAllStatement )  
  144015           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSyncAllStatement );
  144016           0 :           unsigned long positionInPool = localIndex % SgSyncAllStatement::pool_size;
  144017           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSyncAllStatement::pool_size;
  144018             : 
  144019             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  144020             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  144021             : 
  144022           0 :           returnPointer = &( ( (SgSyncAllStatement*)(SgSyncAllStatement::pools[memoryBlock]) ) [positionInPool]) ;
  144023             : 
  144024           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  144025             :         }
  144026           0 :      return returnPointer ;
  144027             :    }
  144028             : 
  144029             : //############################################################################
  144030             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  144031             :   for the AST with the index astIndex
  144032             : */
  144033           0 : SgSyncAllStatement * SgSyncAllStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  144034           0 :      SgSyncAllStatement* returnPointer = NULL;
  144035           0 :      if ( globalIndex != 0 )
  144036             :         {
  144037             : 
  144038             : #if FILE_IO_EXTRA_CHECK
  144039           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSyncAllStatement ) ) <= globalIndex ) ;
  144040           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSyncAllStatement + 1 ) ) );
  144041             : #endif
  144042           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSyncAllStatement )
  144043           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSyncAllStatement );
  144044           0 :           unsigned long positionInPool = localIndex % SgSyncAllStatement::pool_size ;
  144045           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSyncAllStatement::pool_size ;
  144046             : 
  144047             : #if FILE_IO_EXTRA_CHECK
  144048             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  144049             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  144050             : #endif
  144051             : 
  144052           0 :           returnPointer = &( ( (SgSyncAllStatement*)(SgSyncAllStatement::pools[memoryBlock]) ) [positionInPool]) ;
  144053             : 
  144054             : #if FILE_IO_EXTRA_CHECK
  144055           0 :           assert ( returnPointer != NULL ) ;
  144056             : #endif
  144057             :         }
  144058           0 :      return returnPointer ;
  144059             :    }
  144060             : 
  144061             : //############################################################################
  144062             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  144063             :  * pool size! We set for every valid object in the memory pool the freepointer
  144064             :  * to the global index and increase the global index afterwards. For all the 
  144065             :  * invalid objects (means address ranges within the memory pool that were not
  144066             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  144067             :  * distinguish valid from invalid objects! 
  144068             :  */
  144069             : unsigned long
  144070           5 : SgSyncAllStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  144071             :    {
  144072           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  144073           5 :      SgSyncAllStatement* pointer = NULL;
  144074           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  144075           5 :      std::vector < unsigned char* > :: const_iterator block;
  144076           5 :      for ( block = SgSyncAllStatement::pools.begin(); block != SgSyncAllStatement::pools.end() ; ++block )
  144077             :         {
  144078           0 :           pointer = (SgSyncAllStatement*)(*block);
  144079           0 :           for (unsigned i = 0; i < SgSyncAllStatement::pool_size; ++i )
  144080             :              {
  144081             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  144082             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  144083             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  144084             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  144085             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  144086             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  144087             :             // properly; so this will have to be checked next.
  144088             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  144089             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  144090           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  144091             :                   {
  144092           0 :                     pointer[i].set_freepointer((SgSyncAllStatement*)(globalIndex));
  144093           0 :                     globalIndex++;
  144094             :                   }
  144095             :                else
  144096             :                   {
  144097           0 :                     pointer[i].set_freepointer(NULL);
  144098             :                   }
  144099             :               }
  144100             :         }
  144101           5 :      return globalIndex;
  144102             :    }
  144103             : 
  144104             : //############################################################################
  144105             : // JH (01/14/2006)
  144106             : void
  144107           5 : SgSyncAllStatement::resetValidFreepointers( )
  144108             :    {
  144109           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  144110           5 :      SgSyncAllStatement* pointer = NULL;
  144111           5 :      std::vector < unsigned char* > :: const_iterator block;
  144112           5 :      SgSyncAllStatement* pointerOfLinkedList = NULL;
  144113           5 :      for ( block = SgSyncAllStatement::pools.begin(); block != SgSyncAllStatement::pools.end() ; ++block )
  144114             :         {
  144115           0 :           pointer = (SgSyncAllStatement*)(*block);
  144116           0 :           for (unsigned i = 0; i < SgSyncAllStatement::pool_size; ++i )
  144117             :              {
  144118             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  144119             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  144120             :             // memory blocks!.
  144121           0 :                if ( pointer[i].get_freepointer() != NULL )
  144122             :                   {
  144123           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  144124             :                   }
  144125             :                else
  144126             :                   {
  144127           0 :                     if ( pointerOfLinkedList == NULL )
  144128             :                        {
  144129           0 :                          SgSyncAllStatement::next_node = &(pointer[i]);
  144130             :                        }
  144131             :                     else
  144132             :                        {
  144133             :                       // printf ("In SgSyncAllStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  144134           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  144135             :                        }
  144136             :                     pointerOfLinkedList = &(pointer[i]);
  144137             :                   }
  144138             :               }
  144139             :         }
  144140             : 
  144141           5 :      if ( pointerOfLinkedList != NULL )
  144142             :         {
  144143             :        // printf ("In SgSyncAllStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  144144           0 :           pointerOfLinkedList->set_freepointer(NULL);
  144145             :        // DQ (6/6/2010): Temporary debugging...
  144146             :        //   ROSE_ASSERT(false);
  144147             :         }
  144148             : 
  144149           5 :      return ;
  144150             :    }
  144151             : 
  144152             : //############################################################################
  144153             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  144154             :  * within the memory pool and resets the freepointers, in order to achieve a 
  144155             :  * linked list, that has no jumps and starts at the beginning! This function 
  144156             :  * does not extend the memory pool, since we do not delete any memory blocks,
  144157             :  * but delete the valid objects.  
  144158             :  */
  144159             : void
  144160           0 : SgSyncAllStatement::clearMemoryPool( )
  144161             :    {
  144162             :   // printf ("Inside of SgSyncAllStatement::clearMemoryPool() \n");
  144163             : 
  144164           0 :      SgSyncAllStatement* pointer = NULL, *tempPointer = NULL;
  144165           0 :      std::vector < unsigned char* > :: const_iterator block;
  144166           0 :      if ( SgSyncAllStatement::pools.empty() == false )
  144167             :         {
  144168           0 :           block = SgSyncAllStatement::pools.begin() ;
  144169           0 :           SgSyncAllStatement::next_node = (SgSyncAllStatement*) (*block);
  144170             : 
  144171           0 :           while ( block != SgSyncAllStatement::pools.end() )
  144172             :              {
  144173           0 :                pointer = (SgSyncAllStatement*) (*block);
  144174           0 :                if ( tempPointer != NULL )
  144175             :                   {
  144176           0 :                     tempPointer->set_freepointer(pointer);
  144177             :                   }
  144178           0 :                for (unsigned i = 0; i < SgSyncAllStatement::pool_size - 1; ++i)
  144179             :                   {
  144180           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  144181             :                   }
  144182           0 :                 pointer[SgSyncAllStatement::pool_size-1].set_freepointer(NULL);
  144183           0 :                 tempPointer = &(pointer[SgSyncAllStatement::pool_size-1]);
  144184           0 :                 ++block;
  144185             :              }
  144186             :         }
  144187           0 :    }
  144188             : 
  144189           5 : void SgSyncAllStatement::deleteMemoryPool() {
  144190           5 :   for (auto p: SgSyncAllStatement::pools) {
  144191           0 :     ROSE_FREE(p);
  144192             :   }
  144193           5 :   SgSyncAllStatement::next_node = nullptr;
  144194           5 :   SgSyncAllStatement::pools.clear();
  144195           5 : }
  144196             : 
  144197             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  144198             : //                 reading multiple binary files to for a single AST.
  144199             : /////////// new version ////////////////////////////////
  144200             : //############################################################################
  144201             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  144202             : void
  144203           2 : SgSyncAllStatement::extendMemoryPoolForFileIO( )
  144204             :   {
  144205           2 :     size_t blockIndex = SgSyncAllStatement::pools.size();
  144206           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncAllStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncAllStatement);
  144207             : 
  144208           2 :     while ( (blockIndex * SgSyncAllStatement::pool_size) < newPoolSize)
  144209             :       {
  144210             : #if ROSE_ALLOC_TRACE
  144211             :         if (blockIndex > 0) {
  144212             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncAllStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncAllStatement) = %" PRIuPTR " SgSyncAllStatement::pool_size = %d \n",
  144213             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncAllStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncAllStatement),SgSyncAllStatement::pool_size);
  144214             :         }
  144215             : #endif
  144216             : 
  144217           0 :         SgSyncAllStatement * pointer = (SgSyncAllStatement*) ROSE_MALLOC ( SgSyncAllStatement::pool_size * sizeof(SgSyncAllStatement) );
  144218           0 :         assert( pointer != NULL );
  144219             : #if ROSE_ALLOC_MEMSET == 1
  144220             :         memset(pointer, 0x00, SgSyncAllStatement::pool_size * sizeof(SgSyncAllStatement));
  144221             : #elif ROSE_ALLOC_MEMSET == 2
  144222             :         memset(pointer, 0xCC, SgSyncAllStatement::pool_size * sizeof(SgSyncAllStatement));
  144223             : #endif
  144224           0 :         SgSyncAllStatement::pools.push_back( (unsigned char*)(pointer) );
  144225           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSyncAllStatement::pool_size * sizeof(SgSyncAllStatement), V_SgSyncAllStatement ) );
  144226             : 
  144227           0 :         if ( SgSyncAllStatement::next_node != NULL ) {
  144228           0 :           if ( blockIndex > 0 ) {
  144229           0 :             SgSyncAllStatement * blkptr = (SgSyncAllStatement*)(SgSyncAllStatement::pools[blockIndex-1]);
  144230           0 :             blkptr[ SgSyncAllStatement::pool_size - 1 ].set_freepointer(pointer);
  144231             :           }
  144232             :         } else {
  144233           0 :           SgSyncAllStatement::next_node = pointer;
  144234             :         }
  144235             : 
  144236           0 :         for (unsigned i = 0; i < SgSyncAllStatement::pool_size-1; ++i)
  144237             :            {
  144238           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  144239             :            }
  144240           0 :         pointer[ SgSyncAllStatement::pool_size -1 ].set_freepointer(NULL);
  144241             : 
  144242           0 :         blockIndex++;
  144243             :       }
  144244           2 :   }
  144245             : 
  144246             : //############################################################################
  144247             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  144248             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  144249             :  * not compressed. However, that stuff is not yet implemented! 
  144250             :  */
  144251             : unsigned long
  144252           0 : SgSyncAllStatement::getNumberOfLastValidPointer()
  144253             :    {
  144254           0 :       SgSyncAllStatement* testPointer = (SgSyncAllStatement*)(SgSyncAllStatement::pools.back());
  144255           0 :       unsigned long localIndex = SgSyncAllStatement::pool_size - 1;
  144256           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  144257             :          {
  144258           0 :            localIndex--;
  144259             :          }
  144260           0 :       return (localIndex + SgSyncAllStatement::pool_size * (SgSyncAllStatement::pools.size()-1));
  144261             :    }
  144262             : 
  144263             : //############################################################################
  144264             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  144265             :  * memory pool and initializes the data member in class SgSyncAllStatementStroageClass
  144266             :  * from its counterpart of SgSyncAllStatement. The return value is just for checking, 
  144267             :  * that the whole StorageClassArray is initialized!
  144268             :  */
  144269             : unsigned long
  144270           0 : SgSyncAllStatement::initializeStorageClassArray( SgSyncAllStatementStorageClass *storageArray )
  144271             :    {
  144272           0 :      unsigned long storageCounter = 0;
  144273           0 :      std::vector < unsigned char* > :: const_iterator block = SgSyncAllStatement::pools.begin();
  144274           0 :      SgSyncAllStatement* pointer = NULL;
  144275           0 :      while ( block != SgSyncAllStatement::pools.end() ) {
  144276           0 :           pointer = (SgSyncAllStatement*) (*block);
  144277           0 :           for ( unsigned i = 0; i < SgSyncAllStatement::pool_size; ++i ) {
  144278           0 :                if ( pointer->get_freepointer() != NULL ) {
  144279           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  144280           0 :                  storageArray++;
  144281           0 :                  storageCounter++;
  144282             :                }
  144283           0 :                pointer++;
  144284             :              }
  144285           0 :            block++;
  144286             :         }
  144287           0 :      return storageCounter;
  144288             :    }
  144289             : 
  144290             : /* #line 144291 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  144291             : 
  144292             : 
  144293             : 
  144294             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  144295             : 
  144296             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  144297             : 
  144298             : //############################################################################
  144299             : /* JH (02/02/2006) Constructor of the IR node SgSyncImagesStatement that takes its 
  144300             :  * corresponding StorageClass as parameter
  144301             :  */
  144302           0 : SgSyncImagesStatement :: SgSyncImagesStatement ( const SgSyncImagesStatementStorageClass& storageSource )   : SgImageControlStatement (storageSource)
  144303             :    {
  144304             : 
  144305             : 
  144306             : /* #line 144307 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  144307             : 
  144308           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  144309           0 :      p_image_set =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_image_set) );
  144310             : 
  144311             : 
  144312             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  144313             : 
  144314             : 
  144315           0 :    }
  144316             : 
  144317             : //############################################################################
  144318             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  144319             :  * within the working AST. 
  144320             :  */
  144321           0 : SgSyncImagesStatement * SgSyncImagesStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  144322           0 :      SgSyncImagesStatement* returnPointer = NULL;
  144323           0 :      if ( globalIndex != 0 )
  144324             :         {
  144325             : 
  144326             : #if FILE_IO_EXTRA_CHECK
  144327           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSyncImagesStatement ) ) <= globalIndex ) ;
  144328           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSyncImagesStatement + 1 ) ) );
  144329             : #endif
  144330           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSyncImagesStatement )  
  144331           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSyncImagesStatement );
  144332           0 :           unsigned long positionInPool = localIndex % SgSyncImagesStatement::pool_size;
  144333           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSyncImagesStatement::pool_size;
  144334             : 
  144335             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  144336             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  144337             : 
  144338           0 :           returnPointer = &( ( (SgSyncImagesStatement*)(SgSyncImagesStatement::pools[memoryBlock]) ) [positionInPool]) ;
  144339             : 
  144340           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  144341             :         }
  144342           0 :      return returnPointer ;
  144343             :    }
  144344             : 
  144345             : //############################################################################
  144346             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  144347             :   for the AST with the index astIndex
  144348             : */
  144349           0 : SgSyncImagesStatement * SgSyncImagesStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  144350           0 :      SgSyncImagesStatement* returnPointer = NULL;
  144351           0 :      if ( globalIndex != 0 )
  144352             :         {
  144353             : 
  144354             : #if FILE_IO_EXTRA_CHECK
  144355           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSyncImagesStatement ) ) <= globalIndex ) ;
  144356           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSyncImagesStatement + 1 ) ) );
  144357             : #endif
  144358           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSyncImagesStatement )
  144359           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSyncImagesStatement );
  144360           0 :           unsigned long positionInPool = localIndex % SgSyncImagesStatement::pool_size ;
  144361           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSyncImagesStatement::pool_size ;
  144362             : 
  144363             : #if FILE_IO_EXTRA_CHECK
  144364             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  144365             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  144366             : #endif
  144367             : 
  144368           0 :           returnPointer = &( ( (SgSyncImagesStatement*)(SgSyncImagesStatement::pools[memoryBlock]) ) [positionInPool]) ;
  144369             : 
  144370             : #if FILE_IO_EXTRA_CHECK
  144371           0 :           assert ( returnPointer != NULL ) ;
  144372             : #endif
  144373             :         }
  144374           0 :      return returnPointer ;
  144375             :    }
  144376             : 
  144377             : //############################################################################
  144378             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  144379             :  * pool size! We set for every valid object in the memory pool the freepointer
  144380             :  * to the global index and increase the global index afterwards. For all the 
  144381             :  * invalid objects (means address ranges within the memory pool that were not
  144382             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  144383             :  * distinguish valid from invalid objects! 
  144384             :  */
  144385             : unsigned long
  144386           5 : SgSyncImagesStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  144387             :    {
  144388           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  144389           5 :      SgSyncImagesStatement* pointer = NULL;
  144390           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  144391           5 :      std::vector < unsigned char* > :: const_iterator block;
  144392           5 :      for ( block = SgSyncImagesStatement::pools.begin(); block != SgSyncImagesStatement::pools.end() ; ++block )
  144393             :         {
  144394           0 :           pointer = (SgSyncImagesStatement*)(*block);
  144395           0 :           for (unsigned i = 0; i < SgSyncImagesStatement::pool_size; ++i )
  144396             :              {
  144397             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  144398             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  144399             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  144400             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  144401             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  144402             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  144403             :             // properly; so this will have to be checked next.
  144404             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  144405             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  144406           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  144407             :                   {
  144408           0 :                     pointer[i].set_freepointer((SgSyncImagesStatement*)(globalIndex));
  144409           0 :                     globalIndex++;
  144410             :                   }
  144411             :                else
  144412             :                   {
  144413           0 :                     pointer[i].set_freepointer(NULL);
  144414             :                   }
  144415             :               }
  144416             :         }
  144417           5 :      return globalIndex;
  144418             :    }
  144419             : 
  144420             : //############################################################################
  144421             : // JH (01/14/2006)
  144422             : void
  144423           5 : SgSyncImagesStatement::resetValidFreepointers( )
  144424             :    {
  144425           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  144426           5 :      SgSyncImagesStatement* pointer = NULL;
  144427           5 :      std::vector < unsigned char* > :: const_iterator block;
  144428           5 :      SgSyncImagesStatement* pointerOfLinkedList = NULL;
  144429           5 :      for ( block = SgSyncImagesStatement::pools.begin(); block != SgSyncImagesStatement::pools.end() ; ++block )
  144430             :         {
  144431           0 :           pointer = (SgSyncImagesStatement*)(*block);
  144432           0 :           for (unsigned i = 0; i < SgSyncImagesStatement::pool_size; ++i )
  144433             :              {
  144434             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  144435             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  144436             :             // memory blocks!.
  144437           0 :                if ( pointer[i].get_freepointer() != NULL )
  144438             :                   {
  144439           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  144440             :                   }
  144441             :                else
  144442             :                   {
  144443           0 :                     if ( pointerOfLinkedList == NULL )
  144444             :                        {
  144445           0 :                          SgSyncImagesStatement::next_node = &(pointer[i]);
  144446             :                        }
  144447             :                     else
  144448             :                        {
  144449             :                       // printf ("In SgSyncImagesStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  144450           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  144451             :                        }
  144452             :                     pointerOfLinkedList = &(pointer[i]);
  144453             :                   }
  144454             :               }
  144455             :         }
  144456             : 
  144457           5 :      if ( pointerOfLinkedList != NULL )
  144458             :         {
  144459             :        // printf ("In SgSyncImagesStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  144460           0 :           pointerOfLinkedList->set_freepointer(NULL);
  144461             :        // DQ (6/6/2010): Temporary debugging...
  144462             :        //   ROSE_ASSERT(false);
  144463             :         }
  144464             : 
  144465           5 :      return ;
  144466             :    }
  144467             : 
  144468             : //############################################################################
  144469             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  144470             :  * within the memory pool and resets the freepointers, in order to achieve a 
  144471             :  * linked list, that has no jumps and starts at the beginning! This function 
  144472             :  * does not extend the memory pool, since we do not delete any memory blocks,
  144473             :  * but delete the valid objects.  
  144474             :  */
  144475             : void
  144476           0 : SgSyncImagesStatement::clearMemoryPool( )
  144477             :    {
  144478             :   // printf ("Inside of SgSyncImagesStatement::clearMemoryPool() \n");
  144479             : 
  144480           0 :      SgSyncImagesStatement* pointer = NULL, *tempPointer = NULL;
  144481           0 :      std::vector < unsigned char* > :: const_iterator block;
  144482           0 :      if ( SgSyncImagesStatement::pools.empty() == false )
  144483             :         {
  144484           0 :           block = SgSyncImagesStatement::pools.begin() ;
  144485           0 :           SgSyncImagesStatement::next_node = (SgSyncImagesStatement*) (*block);
  144486             : 
  144487           0 :           while ( block != SgSyncImagesStatement::pools.end() )
  144488             :              {
  144489           0 :                pointer = (SgSyncImagesStatement*) (*block);
  144490           0 :                if ( tempPointer != NULL )
  144491             :                   {
  144492           0 :                     tempPointer->set_freepointer(pointer);
  144493             :                   }
  144494           0 :                for (unsigned i = 0; i < SgSyncImagesStatement::pool_size - 1; ++i)
  144495             :                   {
  144496           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  144497             :                   }
  144498           0 :                 pointer[SgSyncImagesStatement::pool_size-1].set_freepointer(NULL);
  144499           0 :                 tempPointer = &(pointer[SgSyncImagesStatement::pool_size-1]);
  144500           0 :                 ++block;
  144501             :              }
  144502             :         }
  144503           0 :    }
  144504             : 
  144505           5 : void SgSyncImagesStatement::deleteMemoryPool() {
  144506           5 :   for (auto p: SgSyncImagesStatement::pools) {
  144507           0 :     ROSE_FREE(p);
  144508             :   }
  144509           5 :   SgSyncImagesStatement::next_node = nullptr;
  144510           5 :   SgSyncImagesStatement::pools.clear();
  144511           5 : }
  144512             : 
  144513             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  144514             : //                 reading multiple binary files to for a single AST.
  144515             : /////////// new version ////////////////////////////////
  144516             : //############################################################################
  144517             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  144518             : void
  144519           2 : SgSyncImagesStatement::extendMemoryPoolForFileIO( )
  144520             :   {
  144521           2 :     size_t blockIndex = SgSyncImagesStatement::pools.size();
  144522           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncImagesStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncImagesStatement);
  144523             : 
  144524           2 :     while ( (blockIndex * SgSyncImagesStatement::pool_size) < newPoolSize)
  144525             :       {
  144526             : #if ROSE_ALLOC_TRACE
  144527             :         if (blockIndex > 0) {
  144528             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncImagesStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncImagesStatement) = %" PRIuPTR " SgSyncImagesStatement::pool_size = %d \n",
  144529             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncImagesStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncImagesStatement),SgSyncImagesStatement::pool_size);
  144530             :         }
  144531             : #endif
  144532             : 
  144533           0 :         SgSyncImagesStatement * pointer = (SgSyncImagesStatement*) ROSE_MALLOC ( SgSyncImagesStatement::pool_size * sizeof(SgSyncImagesStatement) );
  144534           0 :         assert( pointer != NULL );
  144535             : #if ROSE_ALLOC_MEMSET == 1
  144536             :         memset(pointer, 0x00, SgSyncImagesStatement::pool_size * sizeof(SgSyncImagesStatement));
  144537             : #elif ROSE_ALLOC_MEMSET == 2
  144538             :         memset(pointer, 0xCC, SgSyncImagesStatement::pool_size * sizeof(SgSyncImagesStatement));
  144539             : #endif
  144540           0 :         SgSyncImagesStatement::pools.push_back( (unsigned char*)(pointer) );
  144541           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSyncImagesStatement::pool_size * sizeof(SgSyncImagesStatement), V_SgSyncImagesStatement ) );
  144542             : 
  144543           0 :         if ( SgSyncImagesStatement::next_node != NULL ) {
  144544           0 :           if ( blockIndex > 0 ) {
  144545           0 :             SgSyncImagesStatement * blkptr = (SgSyncImagesStatement*)(SgSyncImagesStatement::pools[blockIndex-1]);
  144546           0 :             blkptr[ SgSyncImagesStatement::pool_size - 1 ].set_freepointer(pointer);
  144547             :           }
  144548             :         } else {
  144549           0 :           SgSyncImagesStatement::next_node = pointer;
  144550             :         }
  144551             : 
  144552           0 :         for (unsigned i = 0; i < SgSyncImagesStatement::pool_size-1; ++i)
  144553             :            {
  144554           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  144555             :            }
  144556           0 :         pointer[ SgSyncImagesStatement::pool_size -1 ].set_freepointer(NULL);
  144557             : 
  144558           0 :         blockIndex++;
  144559             :       }
  144560           2 :   }
  144561             : 
  144562             : //############################################################################
  144563             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  144564             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  144565             :  * not compressed. However, that stuff is not yet implemented! 
  144566             :  */
  144567             : unsigned long
  144568           0 : SgSyncImagesStatement::getNumberOfLastValidPointer()
  144569             :    {
  144570           0 :       SgSyncImagesStatement* testPointer = (SgSyncImagesStatement*)(SgSyncImagesStatement::pools.back());
  144571           0 :       unsigned long localIndex = SgSyncImagesStatement::pool_size - 1;
  144572           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  144573             :          {
  144574           0 :            localIndex--;
  144575             :          }
  144576           0 :       return (localIndex + SgSyncImagesStatement::pool_size * (SgSyncImagesStatement::pools.size()-1));
  144577             :    }
  144578             : 
  144579             : //############################################################################
  144580             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  144581             :  * memory pool and initializes the data member in class SgSyncImagesStatementStroageClass
  144582             :  * from its counterpart of SgSyncImagesStatement. The return value is just for checking, 
  144583             :  * that the whole StorageClassArray is initialized!
  144584             :  */
  144585             : unsigned long
  144586           0 : SgSyncImagesStatement::initializeStorageClassArray( SgSyncImagesStatementStorageClass *storageArray )
  144587             :    {
  144588           0 :      unsigned long storageCounter = 0;
  144589           0 :      std::vector < unsigned char* > :: const_iterator block = SgSyncImagesStatement::pools.begin();
  144590           0 :      SgSyncImagesStatement* pointer = NULL;
  144591           0 :      while ( block != SgSyncImagesStatement::pools.end() ) {
  144592           0 :           pointer = (SgSyncImagesStatement*) (*block);
  144593           0 :           for ( unsigned i = 0; i < SgSyncImagesStatement::pool_size; ++i ) {
  144594           0 :                if ( pointer->get_freepointer() != NULL ) {
  144595           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  144596           0 :                  storageArray++;
  144597           0 :                  storageCounter++;
  144598             :                }
  144599           0 :                pointer++;
  144600             :              }
  144601           0 :            block++;
  144602             :         }
  144603           0 :      return storageCounter;
  144604             :    }
  144605             : 
  144606             : /* #line 144607 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  144607             : 
  144608             : 
  144609             : 
  144610             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  144611             : 
  144612             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  144613             : 
  144614             : //############################################################################
  144615             : /* JH (02/02/2006) Constructor of the IR node SgSyncMemoryStatement that takes its 
  144616             :  * corresponding StorageClass as parameter
  144617             :  */
  144618           0 : SgSyncMemoryStatement :: SgSyncMemoryStatement ( const SgSyncMemoryStatementStorageClass& storageSource )   : SgImageControlStatement (storageSource)
  144619             :    {
  144620             : 
  144621             : 
  144622             : /* #line 144623 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  144623             : 
  144624           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  144625             : 
  144626             : 
  144627             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  144628             : 
  144629             : 
  144630           0 :    }
  144631             : 
  144632             : //############################################################################
  144633             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  144634             :  * within the working AST. 
  144635             :  */
  144636           0 : SgSyncMemoryStatement * SgSyncMemoryStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  144637           0 :      SgSyncMemoryStatement* returnPointer = NULL;
  144638           0 :      if ( globalIndex != 0 )
  144639             :         {
  144640             : 
  144641             : #if FILE_IO_EXTRA_CHECK
  144642           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSyncMemoryStatement ) ) <= globalIndex ) ;
  144643           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSyncMemoryStatement + 1 ) ) );
  144644             : #endif
  144645           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSyncMemoryStatement )  
  144646           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSyncMemoryStatement );
  144647           0 :           unsigned long positionInPool = localIndex % SgSyncMemoryStatement::pool_size;
  144648           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSyncMemoryStatement::pool_size;
  144649             : 
  144650             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  144651             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  144652             : 
  144653           0 :           returnPointer = &( ( (SgSyncMemoryStatement*)(SgSyncMemoryStatement::pools[memoryBlock]) ) [positionInPool]) ;
  144654             : 
  144655           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  144656             :         }
  144657           0 :      return returnPointer ;
  144658             :    }
  144659             : 
  144660             : //############################################################################
  144661             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  144662             :   for the AST with the index astIndex
  144663             : */
  144664           0 : SgSyncMemoryStatement * SgSyncMemoryStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  144665           0 :      SgSyncMemoryStatement* returnPointer = NULL;
  144666           0 :      if ( globalIndex != 0 )
  144667             :         {
  144668             : 
  144669             : #if FILE_IO_EXTRA_CHECK
  144670           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSyncMemoryStatement ) ) <= globalIndex ) ;
  144671           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSyncMemoryStatement + 1 ) ) );
  144672             : #endif
  144673           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSyncMemoryStatement )
  144674           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSyncMemoryStatement );
  144675           0 :           unsigned long positionInPool = localIndex % SgSyncMemoryStatement::pool_size ;
  144676           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSyncMemoryStatement::pool_size ;
  144677             : 
  144678             : #if FILE_IO_EXTRA_CHECK
  144679             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  144680             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  144681             : #endif
  144682             : 
  144683           0 :           returnPointer = &( ( (SgSyncMemoryStatement*)(SgSyncMemoryStatement::pools[memoryBlock]) ) [positionInPool]) ;
  144684             : 
  144685             : #if FILE_IO_EXTRA_CHECK
  144686           0 :           assert ( returnPointer != NULL ) ;
  144687             : #endif
  144688             :         }
  144689           0 :      return returnPointer ;
  144690             :    }
  144691             : 
  144692             : //############################################################################
  144693             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  144694             :  * pool size! We set for every valid object in the memory pool the freepointer
  144695             :  * to the global index and increase the global index afterwards. For all the 
  144696             :  * invalid objects (means address ranges within the memory pool that were not
  144697             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  144698             :  * distinguish valid from invalid objects! 
  144699             :  */
  144700             : unsigned long
  144701           5 : SgSyncMemoryStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  144702             :    {
  144703           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  144704           5 :      SgSyncMemoryStatement* pointer = NULL;
  144705           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  144706           5 :      std::vector < unsigned char* > :: const_iterator block;
  144707           5 :      for ( block = SgSyncMemoryStatement::pools.begin(); block != SgSyncMemoryStatement::pools.end() ; ++block )
  144708             :         {
  144709           0 :           pointer = (SgSyncMemoryStatement*)(*block);
  144710           0 :           for (unsigned i = 0; i < SgSyncMemoryStatement::pool_size; ++i )
  144711             :              {
  144712             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  144713             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  144714             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  144715             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  144716             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  144717             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  144718             :             // properly; so this will have to be checked next.
  144719             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  144720             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  144721           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  144722             :                   {
  144723           0 :                     pointer[i].set_freepointer((SgSyncMemoryStatement*)(globalIndex));
  144724           0 :                     globalIndex++;
  144725             :                   }
  144726             :                else
  144727             :                   {
  144728           0 :                     pointer[i].set_freepointer(NULL);
  144729             :                   }
  144730             :               }
  144731             :         }
  144732           5 :      return globalIndex;
  144733             :    }
  144734             : 
  144735             : //############################################################################
  144736             : // JH (01/14/2006)
  144737             : void
  144738           5 : SgSyncMemoryStatement::resetValidFreepointers( )
  144739             :    {
  144740           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  144741           5 :      SgSyncMemoryStatement* pointer = NULL;
  144742           5 :      std::vector < unsigned char* > :: const_iterator block;
  144743           5 :      SgSyncMemoryStatement* pointerOfLinkedList = NULL;
  144744           5 :      for ( block = SgSyncMemoryStatement::pools.begin(); block != SgSyncMemoryStatement::pools.end() ; ++block )
  144745             :         {
  144746           0 :           pointer = (SgSyncMemoryStatement*)(*block);
  144747           0 :           for (unsigned i = 0; i < SgSyncMemoryStatement::pool_size; ++i )
  144748             :              {
  144749             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  144750             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  144751             :             // memory blocks!.
  144752           0 :                if ( pointer[i].get_freepointer() != NULL )
  144753             :                   {
  144754           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  144755             :                   }
  144756             :                else
  144757             :                   {
  144758           0 :                     if ( pointerOfLinkedList == NULL )
  144759             :                        {
  144760           0 :                          SgSyncMemoryStatement::next_node = &(pointer[i]);
  144761             :                        }
  144762             :                     else
  144763             :                        {
  144764             :                       // printf ("In SgSyncMemoryStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  144765           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  144766             :                        }
  144767             :                     pointerOfLinkedList = &(pointer[i]);
  144768             :                   }
  144769             :               }
  144770             :         }
  144771             : 
  144772           5 :      if ( pointerOfLinkedList != NULL )
  144773             :         {
  144774             :        // printf ("In SgSyncMemoryStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  144775           0 :           pointerOfLinkedList->set_freepointer(NULL);
  144776             :        // DQ (6/6/2010): Temporary debugging...
  144777             :        //   ROSE_ASSERT(false);
  144778             :         }
  144779             : 
  144780           5 :      return ;
  144781             :    }
  144782             : 
  144783             : //############################################################################
  144784             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  144785             :  * within the memory pool and resets the freepointers, in order to achieve a 
  144786             :  * linked list, that has no jumps and starts at the beginning! This function 
  144787             :  * does not extend the memory pool, since we do not delete any memory blocks,
  144788             :  * but delete the valid objects.  
  144789             :  */
  144790             : void
  144791           0 : SgSyncMemoryStatement::clearMemoryPool( )
  144792             :    {
  144793             :   // printf ("Inside of SgSyncMemoryStatement::clearMemoryPool() \n");
  144794             : 
  144795           0 :      SgSyncMemoryStatement* pointer = NULL, *tempPointer = NULL;
  144796           0 :      std::vector < unsigned char* > :: const_iterator block;
  144797           0 :      if ( SgSyncMemoryStatement::pools.empty() == false )
  144798             :         {
  144799           0 :           block = SgSyncMemoryStatement::pools.begin() ;
  144800           0 :           SgSyncMemoryStatement::next_node = (SgSyncMemoryStatement*) (*block);
  144801             : 
  144802           0 :           while ( block != SgSyncMemoryStatement::pools.end() )
  144803             :              {
  144804           0 :                pointer = (SgSyncMemoryStatement*) (*block);
  144805           0 :                if ( tempPointer != NULL )
  144806             :                   {
  144807           0 :                     tempPointer->set_freepointer(pointer);
  144808             :                   }
  144809           0 :                for (unsigned i = 0; i < SgSyncMemoryStatement::pool_size - 1; ++i)
  144810             :                   {
  144811           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  144812             :                   }
  144813           0 :                 pointer[SgSyncMemoryStatement::pool_size-1].set_freepointer(NULL);
  144814           0 :                 tempPointer = &(pointer[SgSyncMemoryStatement::pool_size-1]);
  144815           0 :                 ++block;
  144816             :              }
  144817             :         }
  144818           0 :    }
  144819             : 
  144820           5 : void SgSyncMemoryStatement::deleteMemoryPool() {
  144821           5 :   for (auto p: SgSyncMemoryStatement::pools) {
  144822           0 :     ROSE_FREE(p);
  144823             :   }
  144824           5 :   SgSyncMemoryStatement::next_node = nullptr;
  144825           5 :   SgSyncMemoryStatement::pools.clear();
  144826           5 : }
  144827             : 
  144828             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  144829             : //                 reading multiple binary files to for a single AST.
  144830             : /////////// new version ////////////////////////////////
  144831             : //############################################################################
  144832             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  144833             : void
  144834           2 : SgSyncMemoryStatement::extendMemoryPoolForFileIO( )
  144835             :   {
  144836           2 :     size_t blockIndex = SgSyncMemoryStatement::pools.size();
  144837           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncMemoryStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncMemoryStatement);
  144838             : 
  144839           2 :     while ( (blockIndex * SgSyncMemoryStatement::pool_size) < newPoolSize)
  144840             :       {
  144841             : #if ROSE_ALLOC_TRACE
  144842             :         if (blockIndex > 0) {
  144843             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncMemoryStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncMemoryStatement) = %" PRIuPTR " SgSyncMemoryStatement::pool_size = %d \n",
  144844             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncMemoryStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncMemoryStatement),SgSyncMemoryStatement::pool_size);
  144845             :         }
  144846             : #endif
  144847             : 
  144848           0 :         SgSyncMemoryStatement * pointer = (SgSyncMemoryStatement*) ROSE_MALLOC ( SgSyncMemoryStatement::pool_size * sizeof(SgSyncMemoryStatement) );
  144849           0 :         assert( pointer != NULL );
  144850             : #if ROSE_ALLOC_MEMSET == 1
  144851             :         memset(pointer, 0x00, SgSyncMemoryStatement::pool_size * sizeof(SgSyncMemoryStatement));
  144852             : #elif ROSE_ALLOC_MEMSET == 2
  144853             :         memset(pointer, 0xCC, SgSyncMemoryStatement::pool_size * sizeof(SgSyncMemoryStatement));
  144854             : #endif
  144855           0 :         SgSyncMemoryStatement::pools.push_back( (unsigned char*)(pointer) );
  144856           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSyncMemoryStatement::pool_size * sizeof(SgSyncMemoryStatement), V_SgSyncMemoryStatement ) );
  144857             : 
  144858           0 :         if ( SgSyncMemoryStatement::next_node != NULL ) {
  144859           0 :           if ( blockIndex > 0 ) {
  144860           0 :             SgSyncMemoryStatement * blkptr = (SgSyncMemoryStatement*)(SgSyncMemoryStatement::pools[blockIndex-1]);
  144861           0 :             blkptr[ SgSyncMemoryStatement::pool_size - 1 ].set_freepointer(pointer);
  144862             :           }
  144863             :         } else {
  144864           0 :           SgSyncMemoryStatement::next_node = pointer;
  144865             :         }
  144866             : 
  144867           0 :         for (unsigned i = 0; i < SgSyncMemoryStatement::pool_size-1; ++i)
  144868             :            {
  144869           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  144870             :            }
  144871           0 :         pointer[ SgSyncMemoryStatement::pool_size -1 ].set_freepointer(NULL);
  144872             : 
  144873           0 :         blockIndex++;
  144874             :       }
  144875           2 :   }
  144876             : 
  144877             : //############################################################################
  144878             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  144879             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  144880             :  * not compressed. However, that stuff is not yet implemented! 
  144881             :  */
  144882             : unsigned long
  144883           0 : SgSyncMemoryStatement::getNumberOfLastValidPointer()
  144884             :    {
  144885           0 :       SgSyncMemoryStatement* testPointer = (SgSyncMemoryStatement*)(SgSyncMemoryStatement::pools.back());
  144886           0 :       unsigned long localIndex = SgSyncMemoryStatement::pool_size - 1;
  144887           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  144888             :          {
  144889           0 :            localIndex--;
  144890             :          }
  144891           0 :       return (localIndex + SgSyncMemoryStatement::pool_size * (SgSyncMemoryStatement::pools.size()-1));
  144892             :    }
  144893             : 
  144894             : //############################################################################
  144895             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  144896             :  * memory pool and initializes the data member in class SgSyncMemoryStatementStroageClass
  144897             :  * from its counterpart of SgSyncMemoryStatement. The return value is just for checking, 
  144898             :  * that the whole StorageClassArray is initialized!
  144899             :  */
  144900             : unsigned long
  144901           0 : SgSyncMemoryStatement::initializeStorageClassArray( SgSyncMemoryStatementStorageClass *storageArray )
  144902             :    {
  144903           0 :      unsigned long storageCounter = 0;
  144904           0 :      std::vector < unsigned char* > :: const_iterator block = SgSyncMemoryStatement::pools.begin();
  144905           0 :      SgSyncMemoryStatement* pointer = NULL;
  144906           0 :      while ( block != SgSyncMemoryStatement::pools.end() ) {
  144907           0 :           pointer = (SgSyncMemoryStatement*) (*block);
  144908           0 :           for ( unsigned i = 0; i < SgSyncMemoryStatement::pool_size; ++i ) {
  144909           0 :                if ( pointer->get_freepointer() != NULL ) {
  144910           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  144911           0 :                  storageArray++;
  144912           0 :                  storageCounter++;
  144913             :                }
  144914           0 :                pointer++;
  144915             :              }
  144916           0 :            block++;
  144917             :         }
  144918           0 :      return storageCounter;
  144919             :    }
  144920             : 
  144921             : /* #line 144922 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  144922             : 
  144923             : 
  144924             : 
  144925             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  144926             : 
  144927             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  144928             : 
  144929             : //############################################################################
  144930             : /* JH (02/02/2006) Constructor of the IR node SgSyncTeamStatement that takes its 
  144931             :  * corresponding StorageClass as parameter
  144932             :  */
  144933           0 : SgSyncTeamStatement :: SgSyncTeamStatement ( const SgSyncTeamStatementStorageClass& storageSource )   : SgImageControlStatement (storageSource)
  144934             :    {
  144935             : 
  144936             : 
  144937             : /* #line 144938 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  144938             : 
  144939           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  144940           0 :      p_team_value =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_team_value) );
  144941             : 
  144942             : 
  144943             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  144944             : 
  144945             : 
  144946           0 :    }
  144947             : 
  144948             : //############################################################################
  144949             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  144950             :  * within the working AST. 
  144951             :  */
  144952           0 : SgSyncTeamStatement * SgSyncTeamStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  144953           0 :      SgSyncTeamStatement* returnPointer = NULL;
  144954           0 :      if ( globalIndex != 0 )
  144955             :         {
  144956             : 
  144957             : #if FILE_IO_EXTRA_CHECK
  144958           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSyncTeamStatement ) ) <= globalIndex ) ;
  144959           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSyncTeamStatement + 1 ) ) );
  144960             : #endif
  144961           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSyncTeamStatement )  
  144962           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSyncTeamStatement );
  144963           0 :           unsigned long positionInPool = localIndex % SgSyncTeamStatement::pool_size;
  144964           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSyncTeamStatement::pool_size;
  144965             : 
  144966             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  144967             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  144968             : 
  144969           0 :           returnPointer = &( ( (SgSyncTeamStatement*)(SgSyncTeamStatement::pools[memoryBlock]) ) [positionInPool]) ;
  144970             : 
  144971           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  144972             :         }
  144973           0 :      return returnPointer ;
  144974             :    }
  144975             : 
  144976             : //############################################################################
  144977             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  144978             :   for the AST with the index astIndex
  144979             : */
  144980           0 : SgSyncTeamStatement * SgSyncTeamStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  144981           0 :      SgSyncTeamStatement* returnPointer = NULL;
  144982           0 :      if ( globalIndex != 0 )
  144983             :         {
  144984             : 
  144985             : #if FILE_IO_EXTRA_CHECK
  144986           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSyncTeamStatement ) ) <= globalIndex ) ;
  144987           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSyncTeamStatement + 1 ) ) );
  144988             : #endif
  144989           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSyncTeamStatement )
  144990           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSyncTeamStatement );
  144991           0 :           unsigned long positionInPool = localIndex % SgSyncTeamStatement::pool_size ;
  144992           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSyncTeamStatement::pool_size ;
  144993             : 
  144994             : #if FILE_IO_EXTRA_CHECK
  144995             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  144996             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  144997             : #endif
  144998             : 
  144999           0 :           returnPointer = &( ( (SgSyncTeamStatement*)(SgSyncTeamStatement::pools[memoryBlock]) ) [positionInPool]) ;
  145000             : 
  145001             : #if FILE_IO_EXTRA_CHECK
  145002           0 :           assert ( returnPointer != NULL ) ;
  145003             : #endif
  145004             :         }
  145005           0 :      return returnPointer ;
  145006             :    }
  145007             : 
  145008             : //############################################################################
  145009             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  145010             :  * pool size! We set for every valid object in the memory pool the freepointer
  145011             :  * to the global index and increase the global index afterwards. For all the 
  145012             :  * invalid objects (means address ranges within the memory pool that were not
  145013             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  145014             :  * distinguish valid from invalid objects! 
  145015             :  */
  145016             : unsigned long
  145017           5 : SgSyncTeamStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  145018             :    {
  145019           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  145020           5 :      SgSyncTeamStatement* pointer = NULL;
  145021           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  145022           5 :      std::vector < unsigned char* > :: const_iterator block;
  145023           5 :      for ( block = SgSyncTeamStatement::pools.begin(); block != SgSyncTeamStatement::pools.end() ; ++block )
  145024             :         {
  145025           0 :           pointer = (SgSyncTeamStatement*)(*block);
  145026           0 :           for (unsigned i = 0; i < SgSyncTeamStatement::pool_size; ++i )
  145027             :              {
  145028             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  145029             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  145030             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  145031             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  145032             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  145033             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  145034             :             // properly; so this will have to be checked next.
  145035             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  145036             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  145037           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  145038             :                   {
  145039           0 :                     pointer[i].set_freepointer((SgSyncTeamStatement*)(globalIndex));
  145040           0 :                     globalIndex++;
  145041             :                   }
  145042             :                else
  145043             :                   {
  145044           0 :                     pointer[i].set_freepointer(NULL);
  145045             :                   }
  145046             :               }
  145047             :         }
  145048           5 :      return globalIndex;
  145049             :    }
  145050             : 
  145051             : //############################################################################
  145052             : // JH (01/14/2006)
  145053             : void
  145054           5 : SgSyncTeamStatement::resetValidFreepointers( )
  145055             :    {
  145056           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  145057           5 :      SgSyncTeamStatement* pointer = NULL;
  145058           5 :      std::vector < unsigned char* > :: const_iterator block;
  145059           5 :      SgSyncTeamStatement* pointerOfLinkedList = NULL;
  145060           5 :      for ( block = SgSyncTeamStatement::pools.begin(); block != SgSyncTeamStatement::pools.end() ; ++block )
  145061             :         {
  145062           0 :           pointer = (SgSyncTeamStatement*)(*block);
  145063           0 :           for (unsigned i = 0; i < SgSyncTeamStatement::pool_size; ++i )
  145064             :              {
  145065             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  145066             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  145067             :             // memory blocks!.
  145068           0 :                if ( pointer[i].get_freepointer() != NULL )
  145069             :                   {
  145070           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  145071             :                   }
  145072             :                else
  145073             :                   {
  145074           0 :                     if ( pointerOfLinkedList == NULL )
  145075             :                        {
  145076           0 :                          SgSyncTeamStatement::next_node = &(pointer[i]);
  145077             :                        }
  145078             :                     else
  145079             :                        {
  145080             :                       // printf ("In SgSyncTeamStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  145081           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  145082             :                        }
  145083             :                     pointerOfLinkedList = &(pointer[i]);
  145084             :                   }
  145085             :               }
  145086             :         }
  145087             : 
  145088           5 :      if ( pointerOfLinkedList != NULL )
  145089             :         {
  145090             :        // printf ("In SgSyncTeamStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  145091           0 :           pointerOfLinkedList->set_freepointer(NULL);
  145092             :        // DQ (6/6/2010): Temporary debugging...
  145093             :        //   ROSE_ASSERT(false);
  145094             :         }
  145095             : 
  145096           5 :      return ;
  145097             :    }
  145098             : 
  145099             : //############################################################################
  145100             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  145101             :  * within the memory pool and resets the freepointers, in order to achieve a 
  145102             :  * linked list, that has no jumps and starts at the beginning! This function 
  145103             :  * does not extend the memory pool, since we do not delete any memory blocks,
  145104             :  * but delete the valid objects.  
  145105             :  */
  145106             : void
  145107           0 : SgSyncTeamStatement::clearMemoryPool( )
  145108             :    {
  145109             :   // printf ("Inside of SgSyncTeamStatement::clearMemoryPool() \n");
  145110             : 
  145111           0 :      SgSyncTeamStatement* pointer = NULL, *tempPointer = NULL;
  145112           0 :      std::vector < unsigned char* > :: const_iterator block;
  145113           0 :      if ( SgSyncTeamStatement::pools.empty() == false )
  145114             :         {
  145115           0 :           block = SgSyncTeamStatement::pools.begin() ;
  145116           0 :           SgSyncTeamStatement::next_node = (SgSyncTeamStatement*) (*block);
  145117             : 
  145118           0 :           while ( block != SgSyncTeamStatement::pools.end() )
  145119             :              {
  145120           0 :                pointer = (SgSyncTeamStatement*) (*block);
  145121           0 :                if ( tempPointer != NULL )
  145122             :                   {
  145123           0 :                     tempPointer->set_freepointer(pointer);
  145124             :                   }
  145125           0 :                for (unsigned i = 0; i < SgSyncTeamStatement::pool_size - 1; ++i)
  145126             :                   {
  145127           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  145128             :                   }
  145129           0 :                 pointer[SgSyncTeamStatement::pool_size-1].set_freepointer(NULL);
  145130           0 :                 tempPointer = &(pointer[SgSyncTeamStatement::pool_size-1]);
  145131           0 :                 ++block;
  145132             :              }
  145133             :         }
  145134           0 :    }
  145135             : 
  145136           5 : void SgSyncTeamStatement::deleteMemoryPool() {
  145137           5 :   for (auto p: SgSyncTeamStatement::pools) {
  145138           0 :     ROSE_FREE(p);
  145139             :   }
  145140           5 :   SgSyncTeamStatement::next_node = nullptr;
  145141           5 :   SgSyncTeamStatement::pools.clear();
  145142           5 : }
  145143             : 
  145144             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  145145             : //                 reading multiple binary files to for a single AST.
  145146             : /////////// new version ////////////////////////////////
  145147             : //############################################################################
  145148             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  145149             : void
  145150           2 : SgSyncTeamStatement::extendMemoryPoolForFileIO( )
  145151             :   {
  145152           2 :     size_t blockIndex = SgSyncTeamStatement::pools.size();
  145153           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncTeamStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncTeamStatement);
  145154             : 
  145155           2 :     while ( (blockIndex * SgSyncTeamStatement::pool_size) < newPoolSize)
  145156             :       {
  145157             : #if ROSE_ALLOC_TRACE
  145158             :         if (blockIndex > 0) {
  145159             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncTeamStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncTeamStatement) = %" PRIuPTR " SgSyncTeamStatement::pool_size = %d \n",
  145160             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSyncTeamStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSyncTeamStatement),SgSyncTeamStatement::pool_size);
  145161             :         }
  145162             : #endif
  145163             : 
  145164           0 :         SgSyncTeamStatement * pointer = (SgSyncTeamStatement*) ROSE_MALLOC ( SgSyncTeamStatement::pool_size * sizeof(SgSyncTeamStatement) );
  145165           0 :         assert( pointer != NULL );
  145166             : #if ROSE_ALLOC_MEMSET == 1
  145167             :         memset(pointer, 0x00, SgSyncTeamStatement::pool_size * sizeof(SgSyncTeamStatement));
  145168             : #elif ROSE_ALLOC_MEMSET == 2
  145169             :         memset(pointer, 0xCC, SgSyncTeamStatement::pool_size * sizeof(SgSyncTeamStatement));
  145170             : #endif
  145171           0 :         SgSyncTeamStatement::pools.push_back( (unsigned char*)(pointer) );
  145172           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSyncTeamStatement::pool_size * sizeof(SgSyncTeamStatement), V_SgSyncTeamStatement ) );
  145173             : 
  145174           0 :         if ( SgSyncTeamStatement::next_node != NULL ) {
  145175           0 :           if ( blockIndex > 0 ) {
  145176           0 :             SgSyncTeamStatement * blkptr = (SgSyncTeamStatement*)(SgSyncTeamStatement::pools[blockIndex-1]);
  145177           0 :             blkptr[ SgSyncTeamStatement::pool_size - 1 ].set_freepointer(pointer);
  145178             :           }
  145179             :         } else {
  145180           0 :           SgSyncTeamStatement::next_node = pointer;
  145181             :         }
  145182             : 
  145183           0 :         for (unsigned i = 0; i < SgSyncTeamStatement::pool_size-1; ++i)
  145184             :            {
  145185           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  145186             :            }
  145187           0 :         pointer[ SgSyncTeamStatement::pool_size -1 ].set_freepointer(NULL);
  145188             : 
  145189           0 :         blockIndex++;
  145190             :       }
  145191           2 :   }
  145192             : 
  145193             : //############################################################################
  145194             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  145195             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  145196             :  * not compressed. However, that stuff is not yet implemented! 
  145197             :  */
  145198             : unsigned long
  145199           0 : SgSyncTeamStatement::getNumberOfLastValidPointer()
  145200             :    {
  145201           0 :       SgSyncTeamStatement* testPointer = (SgSyncTeamStatement*)(SgSyncTeamStatement::pools.back());
  145202           0 :       unsigned long localIndex = SgSyncTeamStatement::pool_size - 1;
  145203           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  145204             :          {
  145205           0 :            localIndex--;
  145206             :          }
  145207           0 :       return (localIndex + SgSyncTeamStatement::pool_size * (SgSyncTeamStatement::pools.size()-1));
  145208             :    }
  145209             : 
  145210             : //############################################################################
  145211             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  145212             :  * memory pool and initializes the data member in class SgSyncTeamStatementStroageClass
  145213             :  * from its counterpart of SgSyncTeamStatement. The return value is just for checking, 
  145214             :  * that the whole StorageClassArray is initialized!
  145215             :  */
  145216             : unsigned long
  145217           0 : SgSyncTeamStatement::initializeStorageClassArray( SgSyncTeamStatementStorageClass *storageArray )
  145218             :    {
  145219           0 :      unsigned long storageCounter = 0;
  145220           0 :      std::vector < unsigned char* > :: const_iterator block = SgSyncTeamStatement::pools.begin();
  145221           0 :      SgSyncTeamStatement* pointer = NULL;
  145222           0 :      while ( block != SgSyncTeamStatement::pools.end() ) {
  145223           0 :           pointer = (SgSyncTeamStatement*) (*block);
  145224           0 :           for ( unsigned i = 0; i < SgSyncTeamStatement::pool_size; ++i ) {
  145225           0 :                if ( pointer->get_freepointer() != NULL ) {
  145226           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  145227           0 :                  storageArray++;
  145228           0 :                  storageCounter++;
  145229             :                }
  145230           0 :                pointer++;
  145231             :              }
  145232           0 :            block++;
  145233             :         }
  145234           0 :      return storageCounter;
  145235             :    }
  145236             : 
  145237             : /* #line 145238 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  145238             : 
  145239             : 
  145240             : 
  145241             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  145242             : 
  145243             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  145244             : 
  145245             : //############################################################################
  145246             : /* JH (02/02/2006) Constructor of the IR node SgLockStatement that takes its 
  145247             :  * corresponding StorageClass as parameter
  145248             :  */
  145249           0 : SgLockStatement :: SgLockStatement ( const SgLockStatementStorageClass& storageSource )   : SgImageControlStatement (storageSource)
  145250             :    {
  145251             : 
  145252             : 
  145253             : /* #line 145254 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  145254             : 
  145255           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  145256           0 :      p_lock_variable =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lock_variable) );
  145257             : 
  145258             : 
  145259             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  145260             : 
  145261             : 
  145262           0 :    }
  145263             : 
  145264             : //############################################################################
  145265             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  145266             :  * within the working AST. 
  145267             :  */
  145268           0 : SgLockStatement * SgLockStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  145269           0 :      SgLockStatement* returnPointer = NULL;
  145270           0 :      if ( globalIndex != 0 )
  145271             :         {
  145272             : 
  145273             : #if FILE_IO_EXTRA_CHECK
  145274           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLockStatement ) ) <= globalIndex ) ;
  145275           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLockStatement + 1 ) ) );
  145276             : #endif
  145277           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLockStatement )  
  145278           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLockStatement );
  145279           0 :           unsigned long positionInPool = localIndex % SgLockStatement::pool_size;
  145280           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLockStatement::pool_size;
  145281             : 
  145282             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  145283             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  145284             : 
  145285           0 :           returnPointer = &( ( (SgLockStatement*)(SgLockStatement::pools[memoryBlock]) ) [positionInPool]) ;
  145286             : 
  145287           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  145288             :         }
  145289           0 :      return returnPointer ;
  145290             :    }
  145291             : 
  145292             : //############################################################################
  145293             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  145294             :   for the AST with the index astIndex
  145295             : */
  145296           0 : SgLockStatement * SgLockStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  145297           0 :      SgLockStatement* returnPointer = NULL;
  145298           0 :      if ( globalIndex != 0 )
  145299             :         {
  145300             : 
  145301             : #if FILE_IO_EXTRA_CHECK
  145302           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLockStatement ) ) <= globalIndex ) ;
  145303           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLockStatement + 1 ) ) );
  145304             : #endif
  145305           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLockStatement )
  145306           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLockStatement );
  145307           0 :           unsigned long positionInPool = localIndex % SgLockStatement::pool_size ;
  145308           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLockStatement::pool_size ;
  145309             : 
  145310             : #if FILE_IO_EXTRA_CHECK
  145311             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  145312             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  145313             : #endif
  145314             : 
  145315           0 :           returnPointer = &( ( (SgLockStatement*)(SgLockStatement::pools[memoryBlock]) ) [positionInPool]) ;
  145316             : 
  145317             : #if FILE_IO_EXTRA_CHECK
  145318           0 :           assert ( returnPointer != NULL ) ;
  145319             : #endif
  145320             :         }
  145321           0 :      return returnPointer ;
  145322             :    }
  145323             : 
  145324             : //############################################################################
  145325             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  145326             :  * pool size! We set for every valid object in the memory pool the freepointer
  145327             :  * to the global index and increase the global index afterwards. For all the 
  145328             :  * invalid objects (means address ranges within the memory pool that were not
  145329             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  145330             :  * distinguish valid from invalid objects! 
  145331             :  */
  145332             : unsigned long
  145333           5 : SgLockStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  145334             :    {
  145335           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  145336           5 :      SgLockStatement* pointer = NULL;
  145337           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  145338           5 :      std::vector < unsigned char* > :: const_iterator block;
  145339           5 :      for ( block = SgLockStatement::pools.begin(); block != SgLockStatement::pools.end() ; ++block )
  145340             :         {
  145341           0 :           pointer = (SgLockStatement*)(*block);
  145342           0 :           for (unsigned i = 0; i < SgLockStatement::pool_size; ++i )
  145343             :              {
  145344             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  145345             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  145346             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  145347             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  145348             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  145349             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  145350             :             // properly; so this will have to be checked next.
  145351             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  145352             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  145353           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  145354             :                   {
  145355           0 :                     pointer[i].set_freepointer((SgLockStatement*)(globalIndex));
  145356           0 :                     globalIndex++;
  145357             :                   }
  145358             :                else
  145359             :                   {
  145360           0 :                     pointer[i].set_freepointer(NULL);
  145361             :                   }
  145362             :               }
  145363             :         }
  145364           5 :      return globalIndex;
  145365             :    }
  145366             : 
  145367             : //############################################################################
  145368             : // JH (01/14/2006)
  145369             : void
  145370           5 : SgLockStatement::resetValidFreepointers( )
  145371             :    {
  145372           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  145373           5 :      SgLockStatement* pointer = NULL;
  145374           5 :      std::vector < unsigned char* > :: const_iterator block;
  145375           5 :      SgLockStatement* pointerOfLinkedList = NULL;
  145376           5 :      for ( block = SgLockStatement::pools.begin(); block != SgLockStatement::pools.end() ; ++block )
  145377             :         {
  145378           0 :           pointer = (SgLockStatement*)(*block);
  145379           0 :           for (unsigned i = 0; i < SgLockStatement::pool_size; ++i )
  145380             :              {
  145381             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  145382             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  145383             :             // memory blocks!.
  145384           0 :                if ( pointer[i].get_freepointer() != NULL )
  145385             :                   {
  145386           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  145387             :                   }
  145388             :                else
  145389             :                   {
  145390           0 :                     if ( pointerOfLinkedList == NULL )
  145391             :                        {
  145392           0 :                          SgLockStatement::next_node = &(pointer[i]);
  145393             :                        }
  145394             :                     else
  145395             :                        {
  145396             :                       // printf ("In SgLockStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  145397           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  145398             :                        }
  145399             :                     pointerOfLinkedList = &(pointer[i]);
  145400             :                   }
  145401             :               }
  145402             :         }
  145403             : 
  145404           5 :      if ( pointerOfLinkedList != NULL )
  145405             :         {
  145406             :        // printf ("In SgLockStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  145407           0 :           pointerOfLinkedList->set_freepointer(NULL);
  145408             :        // DQ (6/6/2010): Temporary debugging...
  145409             :        //   ROSE_ASSERT(false);
  145410             :         }
  145411             : 
  145412           5 :      return ;
  145413             :    }
  145414             : 
  145415             : //############################################################################
  145416             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  145417             :  * within the memory pool and resets the freepointers, in order to achieve a 
  145418             :  * linked list, that has no jumps and starts at the beginning! This function 
  145419             :  * does not extend the memory pool, since we do not delete any memory blocks,
  145420             :  * but delete the valid objects.  
  145421             :  */
  145422             : void
  145423           0 : SgLockStatement::clearMemoryPool( )
  145424             :    {
  145425             :   // printf ("Inside of SgLockStatement::clearMemoryPool() \n");
  145426             : 
  145427           0 :      SgLockStatement* pointer = NULL, *tempPointer = NULL;
  145428           0 :      std::vector < unsigned char* > :: const_iterator block;
  145429           0 :      if ( SgLockStatement::pools.empty() == false )
  145430             :         {
  145431           0 :           block = SgLockStatement::pools.begin() ;
  145432           0 :           SgLockStatement::next_node = (SgLockStatement*) (*block);
  145433             : 
  145434           0 :           while ( block != SgLockStatement::pools.end() )
  145435             :              {
  145436           0 :                pointer = (SgLockStatement*) (*block);
  145437           0 :                if ( tempPointer != NULL )
  145438             :                   {
  145439           0 :                     tempPointer->set_freepointer(pointer);
  145440             :                   }
  145441           0 :                for (unsigned i = 0; i < SgLockStatement::pool_size - 1; ++i)
  145442             :                   {
  145443           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  145444             :                   }
  145445           0 :                 pointer[SgLockStatement::pool_size-1].set_freepointer(NULL);
  145446           0 :                 tempPointer = &(pointer[SgLockStatement::pool_size-1]);
  145447           0 :                 ++block;
  145448             :              }
  145449             :         }
  145450           0 :    }
  145451             : 
  145452           5 : void SgLockStatement::deleteMemoryPool() {
  145453           5 :   for (auto p: SgLockStatement::pools) {
  145454           0 :     ROSE_FREE(p);
  145455             :   }
  145456           5 :   SgLockStatement::next_node = nullptr;
  145457           5 :   SgLockStatement::pools.clear();
  145458           5 : }
  145459             : 
  145460             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  145461             : //                 reading multiple binary files to for a single AST.
  145462             : /////////// new version ////////////////////////////////
  145463             : //############################################################################
  145464             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  145465             : void
  145466           2 : SgLockStatement::extendMemoryPoolForFileIO( )
  145467             :   {
  145468           2 :     size_t blockIndex = SgLockStatement::pools.size();
  145469           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLockStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLockStatement);
  145470             : 
  145471           2 :     while ( (blockIndex * SgLockStatement::pool_size) < newPoolSize)
  145472             :       {
  145473             : #if ROSE_ALLOC_TRACE
  145474             :         if (blockIndex > 0) {
  145475             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLockStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLockStatement) = %" PRIuPTR " SgLockStatement::pool_size = %d \n",
  145476             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLockStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLockStatement),SgLockStatement::pool_size);
  145477             :         }
  145478             : #endif
  145479             : 
  145480           0 :         SgLockStatement * pointer = (SgLockStatement*) ROSE_MALLOC ( SgLockStatement::pool_size * sizeof(SgLockStatement) );
  145481           0 :         assert( pointer != NULL );
  145482             : #if ROSE_ALLOC_MEMSET == 1
  145483             :         memset(pointer, 0x00, SgLockStatement::pool_size * sizeof(SgLockStatement));
  145484             : #elif ROSE_ALLOC_MEMSET == 2
  145485             :         memset(pointer, 0xCC, SgLockStatement::pool_size * sizeof(SgLockStatement));
  145486             : #endif
  145487           0 :         SgLockStatement::pools.push_back( (unsigned char*)(pointer) );
  145488           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLockStatement::pool_size * sizeof(SgLockStatement), V_SgLockStatement ) );
  145489             : 
  145490           0 :         if ( SgLockStatement::next_node != NULL ) {
  145491           0 :           if ( blockIndex > 0 ) {
  145492           0 :             SgLockStatement * blkptr = (SgLockStatement*)(SgLockStatement::pools[blockIndex-1]);
  145493           0 :             blkptr[ SgLockStatement::pool_size - 1 ].set_freepointer(pointer);
  145494             :           }
  145495             :         } else {
  145496           0 :           SgLockStatement::next_node = pointer;
  145497             :         }
  145498             : 
  145499           0 :         for (unsigned i = 0; i < SgLockStatement::pool_size-1; ++i)
  145500             :            {
  145501           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  145502             :            }
  145503           0 :         pointer[ SgLockStatement::pool_size -1 ].set_freepointer(NULL);
  145504             : 
  145505           0 :         blockIndex++;
  145506             :       }
  145507           2 :   }
  145508             : 
  145509             : //############################################################################
  145510             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  145511             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  145512             :  * not compressed. However, that stuff is not yet implemented! 
  145513             :  */
  145514             : unsigned long
  145515           0 : SgLockStatement::getNumberOfLastValidPointer()
  145516             :    {
  145517           0 :       SgLockStatement* testPointer = (SgLockStatement*)(SgLockStatement::pools.back());
  145518           0 :       unsigned long localIndex = SgLockStatement::pool_size - 1;
  145519           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  145520             :          {
  145521           0 :            localIndex--;
  145522             :          }
  145523           0 :       return (localIndex + SgLockStatement::pool_size * (SgLockStatement::pools.size()-1));
  145524             :    }
  145525             : 
  145526             : //############################################################################
  145527             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  145528             :  * memory pool and initializes the data member in class SgLockStatementStroageClass
  145529             :  * from its counterpart of SgLockStatement. The return value is just for checking, 
  145530             :  * that the whole StorageClassArray is initialized!
  145531             :  */
  145532             : unsigned long
  145533           0 : SgLockStatement::initializeStorageClassArray( SgLockStatementStorageClass *storageArray )
  145534             :    {
  145535           0 :      unsigned long storageCounter = 0;
  145536           0 :      std::vector < unsigned char* > :: const_iterator block = SgLockStatement::pools.begin();
  145537           0 :      SgLockStatement* pointer = NULL;
  145538           0 :      while ( block != SgLockStatement::pools.end() ) {
  145539           0 :           pointer = (SgLockStatement*) (*block);
  145540           0 :           for ( unsigned i = 0; i < SgLockStatement::pool_size; ++i ) {
  145541           0 :                if ( pointer->get_freepointer() != NULL ) {
  145542           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  145543           0 :                  storageArray++;
  145544           0 :                  storageCounter++;
  145545             :                }
  145546           0 :                pointer++;
  145547             :              }
  145548           0 :            block++;
  145549             :         }
  145550           0 :      return storageCounter;
  145551             :    }
  145552             : 
  145553             : /* #line 145554 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  145554             : 
  145555             : 
  145556             : 
  145557             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  145558             : 
  145559             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  145560             : 
  145561             : //############################################################################
  145562             : /* JH (02/02/2006) Constructor of the IR node SgUnlockStatement that takes its 
  145563             :  * corresponding StorageClass as parameter
  145564             :  */
  145565           0 : SgUnlockStatement :: SgUnlockStatement ( const SgUnlockStatementStorageClass& storageSource )   : SgImageControlStatement (storageSource)
  145566             :    {
  145567             : 
  145568             : 
  145569             : /* #line 145570 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  145570             : 
  145571           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  145572           0 :      p_lock_variable =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lock_variable) );
  145573             : 
  145574             : 
  145575             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  145576             : 
  145577             : 
  145578           0 :    }
  145579             : 
  145580             : //############################################################################
  145581             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  145582             :  * within the working AST. 
  145583             :  */
  145584           0 : SgUnlockStatement * SgUnlockStatement::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  145585           0 :      SgUnlockStatement* returnPointer = NULL;
  145586           0 :      if ( globalIndex != 0 )
  145587             :         {
  145588             : 
  145589             : #if FILE_IO_EXTRA_CHECK
  145590           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnlockStatement ) ) <= globalIndex ) ;
  145591           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnlockStatement + 1 ) ) );
  145592             : #endif
  145593           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnlockStatement )  
  145594           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnlockStatement );
  145595           0 :           unsigned long positionInPool = localIndex % SgUnlockStatement::pool_size;
  145596           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnlockStatement::pool_size;
  145597             : 
  145598             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  145599             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  145600             : 
  145601           0 :           returnPointer = &( ( (SgUnlockStatement*)(SgUnlockStatement::pools[memoryBlock]) ) [positionInPool]) ;
  145602             : 
  145603           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  145604             :         }
  145605           0 :      return returnPointer ;
  145606             :    }
  145607             : 
  145608             : //############################################################################
  145609             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  145610             :   for the AST with the index astIndex
  145611             : */
  145612           0 : SgUnlockStatement * SgUnlockStatement::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  145613           0 :      SgUnlockStatement* returnPointer = NULL;
  145614           0 :      if ( globalIndex != 0 )
  145615             :         {
  145616             : 
  145617             : #if FILE_IO_EXTRA_CHECK
  145618           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnlockStatement ) ) <= globalIndex ) ;
  145619           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnlockStatement + 1 ) ) );
  145620             : #endif
  145621           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnlockStatement )
  145622           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnlockStatement );
  145623           0 :           unsigned long positionInPool = localIndex % SgUnlockStatement::pool_size ;
  145624           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnlockStatement::pool_size ;
  145625             : 
  145626             : #if FILE_IO_EXTRA_CHECK
  145627             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  145628             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  145629             : #endif
  145630             : 
  145631           0 :           returnPointer = &( ( (SgUnlockStatement*)(SgUnlockStatement::pools[memoryBlock]) ) [positionInPool]) ;
  145632             : 
  145633             : #if FILE_IO_EXTRA_CHECK
  145634           0 :           assert ( returnPointer != NULL ) ;
  145635             : #endif
  145636             :         }
  145637           0 :      return returnPointer ;
  145638             :    }
  145639             : 
  145640             : //############################################################################
  145641             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  145642             :  * pool size! We set for every valid object in the memory pool the freepointer
  145643             :  * to the global index and increase the global index afterwards. For all the 
  145644             :  * invalid objects (means address ranges within the memory pool that were not
  145645             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  145646             :  * distinguish valid from invalid objects! 
  145647             :  */
  145648             : unsigned long
  145649           5 : SgUnlockStatement::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  145650             :    {
  145651           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  145652           5 :      SgUnlockStatement* pointer = NULL;
  145653           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  145654           5 :      std::vector < unsigned char* > :: const_iterator block;
  145655           5 :      for ( block = SgUnlockStatement::pools.begin(); block != SgUnlockStatement::pools.end() ; ++block )
  145656             :         {
  145657           0 :           pointer = (SgUnlockStatement*)(*block);
  145658           0 :           for (unsigned i = 0; i < SgUnlockStatement::pool_size; ++i )
  145659             :              {
  145660             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  145661             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  145662             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  145663             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  145664             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  145665             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  145666             :             // properly; so this will have to be checked next.
  145667             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  145668             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  145669           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  145670             :                   {
  145671           0 :                     pointer[i].set_freepointer((SgUnlockStatement*)(globalIndex));
  145672           0 :                     globalIndex++;
  145673             :                   }
  145674             :                else
  145675             :                   {
  145676           0 :                     pointer[i].set_freepointer(NULL);
  145677             :                   }
  145678             :               }
  145679             :         }
  145680           5 :      return globalIndex;
  145681             :    }
  145682             : 
  145683             : //############################################################################
  145684             : // JH (01/14/2006)
  145685             : void
  145686           5 : SgUnlockStatement::resetValidFreepointers( )
  145687             :    {
  145688           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  145689           5 :      SgUnlockStatement* pointer = NULL;
  145690           5 :      std::vector < unsigned char* > :: const_iterator block;
  145691           5 :      SgUnlockStatement* pointerOfLinkedList = NULL;
  145692           5 :      for ( block = SgUnlockStatement::pools.begin(); block != SgUnlockStatement::pools.end() ; ++block )
  145693             :         {
  145694           0 :           pointer = (SgUnlockStatement*)(*block);
  145695           0 :           for (unsigned i = 0; i < SgUnlockStatement::pool_size; ++i )
  145696             :              {
  145697             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  145698             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  145699             :             // memory blocks!.
  145700           0 :                if ( pointer[i].get_freepointer() != NULL )
  145701             :                   {
  145702           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  145703             :                   }
  145704             :                else
  145705             :                   {
  145706           0 :                     if ( pointerOfLinkedList == NULL )
  145707             :                        {
  145708           0 :                          SgUnlockStatement::next_node = &(pointer[i]);
  145709             :                        }
  145710             :                     else
  145711             :                        {
  145712             :                       // printf ("In SgUnlockStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  145713           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  145714             :                        }
  145715             :                     pointerOfLinkedList = &(pointer[i]);
  145716             :                   }
  145717             :               }
  145718             :         }
  145719             : 
  145720           5 :      if ( pointerOfLinkedList != NULL )
  145721             :         {
  145722             :        // printf ("In SgUnlockStatement::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  145723           0 :           pointerOfLinkedList->set_freepointer(NULL);
  145724             :        // DQ (6/6/2010): Temporary debugging...
  145725             :        //   ROSE_ASSERT(false);
  145726             :         }
  145727             : 
  145728           5 :      return ;
  145729             :    }
  145730             : 
  145731             : //############################################################################
  145732             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  145733             :  * within the memory pool and resets the freepointers, in order to achieve a 
  145734             :  * linked list, that has no jumps and starts at the beginning! This function 
  145735             :  * does not extend the memory pool, since we do not delete any memory blocks,
  145736             :  * but delete the valid objects.  
  145737             :  */
  145738             : void
  145739           0 : SgUnlockStatement::clearMemoryPool( )
  145740             :    {
  145741             :   // printf ("Inside of SgUnlockStatement::clearMemoryPool() \n");
  145742             : 
  145743           0 :      SgUnlockStatement* pointer = NULL, *tempPointer = NULL;
  145744           0 :      std::vector < unsigned char* > :: const_iterator block;
  145745           0 :      if ( SgUnlockStatement::pools.empty() == false )
  145746             :         {
  145747           0 :           block = SgUnlockStatement::pools.begin() ;
  145748           0 :           SgUnlockStatement::next_node = (SgUnlockStatement*) (*block);
  145749             : 
  145750           0 :           while ( block != SgUnlockStatement::pools.end() )
  145751             :              {
  145752           0 :                pointer = (SgUnlockStatement*) (*block);
  145753           0 :                if ( tempPointer != NULL )
  145754             :                   {
  145755           0 :                     tempPointer->set_freepointer(pointer);
  145756             :                   }
  145757           0 :                for (unsigned i = 0; i < SgUnlockStatement::pool_size - 1; ++i)
  145758             :                   {
  145759           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  145760             :                   }
  145761           0 :                 pointer[SgUnlockStatement::pool_size-1].set_freepointer(NULL);
  145762           0 :                 tempPointer = &(pointer[SgUnlockStatement::pool_size-1]);
  145763           0 :                 ++block;
  145764             :              }
  145765             :         }
  145766           0 :    }
  145767             : 
  145768           5 : void SgUnlockStatement::deleteMemoryPool() {
  145769           5 :   for (auto p: SgUnlockStatement::pools) {
  145770           0 :     ROSE_FREE(p);
  145771             :   }
  145772           5 :   SgUnlockStatement::next_node = nullptr;
  145773           5 :   SgUnlockStatement::pools.clear();
  145774           5 : }
  145775             : 
  145776             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  145777             : //                 reading multiple binary files to for a single AST.
  145778             : /////////// new version ////////////////////////////////
  145779             : //############################################################################
  145780             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  145781             : void
  145782           2 : SgUnlockStatement::extendMemoryPoolForFileIO( )
  145783             :   {
  145784           2 :     size_t blockIndex = SgUnlockStatement::pools.size();
  145785           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnlockStatement) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnlockStatement);
  145786             : 
  145787           2 :     while ( (blockIndex * SgUnlockStatement::pool_size) < newPoolSize)
  145788             :       {
  145789             : #if ROSE_ALLOC_TRACE
  145790             :         if (blockIndex > 0) {
  145791             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnlockStatement) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnlockStatement) = %" PRIuPTR " SgUnlockStatement::pool_size = %d \n",
  145792             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnlockStatement),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnlockStatement),SgUnlockStatement::pool_size);
  145793             :         }
  145794             : #endif
  145795             : 
  145796           0 :         SgUnlockStatement * pointer = (SgUnlockStatement*) ROSE_MALLOC ( SgUnlockStatement::pool_size * sizeof(SgUnlockStatement) );
  145797           0 :         assert( pointer != NULL );
  145798             : #if ROSE_ALLOC_MEMSET == 1
  145799             :         memset(pointer, 0x00, SgUnlockStatement::pool_size * sizeof(SgUnlockStatement));
  145800             : #elif ROSE_ALLOC_MEMSET == 2
  145801             :         memset(pointer, 0xCC, SgUnlockStatement::pool_size * sizeof(SgUnlockStatement));
  145802             : #endif
  145803           0 :         SgUnlockStatement::pools.push_back( (unsigned char*)(pointer) );
  145804           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnlockStatement::pool_size * sizeof(SgUnlockStatement), V_SgUnlockStatement ) );
  145805             : 
  145806           0 :         if ( SgUnlockStatement::next_node != NULL ) {
  145807           0 :           if ( blockIndex > 0 ) {
  145808           0 :             SgUnlockStatement * blkptr = (SgUnlockStatement*)(SgUnlockStatement::pools[blockIndex-1]);
  145809           0 :             blkptr[ SgUnlockStatement::pool_size - 1 ].set_freepointer(pointer);
  145810             :           }
  145811             :         } else {
  145812           0 :           SgUnlockStatement::next_node = pointer;
  145813             :         }
  145814             : 
  145815           0 :         for (unsigned i = 0; i < SgUnlockStatement::pool_size-1; ++i)
  145816             :            {
  145817           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  145818             :            }
  145819           0 :         pointer[ SgUnlockStatement::pool_size -1 ].set_freepointer(NULL);
  145820             : 
  145821           0 :         blockIndex++;
  145822             :       }
  145823           2 :   }
  145824             : 
  145825             : //############################################################################
  145826             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  145827             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  145828             :  * not compressed. However, that stuff is not yet implemented! 
  145829             :  */
  145830             : unsigned long
  145831           0 : SgUnlockStatement::getNumberOfLastValidPointer()
  145832             :    {
  145833           0 :       SgUnlockStatement* testPointer = (SgUnlockStatement*)(SgUnlockStatement::pools.back());
  145834           0 :       unsigned long localIndex = SgUnlockStatement::pool_size - 1;
  145835           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  145836             :          {
  145837           0 :            localIndex--;
  145838             :          }
  145839           0 :       return (localIndex + SgUnlockStatement::pool_size * (SgUnlockStatement::pools.size()-1));
  145840             :    }
  145841             : 
  145842             : //############################################################################
  145843             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  145844             :  * memory pool and initializes the data member in class SgUnlockStatementStroageClass
  145845             :  * from its counterpart of SgUnlockStatement. The return value is just for checking, 
  145846             :  * that the whole StorageClassArray is initialized!
  145847             :  */
  145848             : unsigned long
  145849           0 : SgUnlockStatement::initializeStorageClassArray( SgUnlockStatementStorageClass *storageArray )
  145850             :    {
  145851           0 :      unsigned long storageCounter = 0;
  145852           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnlockStatement::pools.begin();
  145853           0 :      SgUnlockStatement* pointer = NULL;
  145854           0 :      while ( block != SgUnlockStatement::pools.end() ) {
  145855           0 :           pointer = (SgUnlockStatement*) (*block);
  145856           0 :           for ( unsigned i = 0; i < SgUnlockStatement::pool_size; ++i ) {
  145857           0 :                if ( pointer->get_freepointer() != NULL ) {
  145858           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  145859           0 :                  storageArray++;
  145860           0 :                  storageCounter++;
  145861             :                }
  145862           0 :                pointer++;
  145863             :              }
  145864           0 :            block++;
  145865             :         }
  145866           0 :      return storageCounter;
  145867             :    }
  145868             : 
  145869             : /* #line 145870 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  145870             : 
  145871             : 
  145872             : 
  145873             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  145874             : 
  145875             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  145876             : 
  145877             : //############################################################################
  145878             : /* JH (02/02/2006) Constructor of the IR node SgExpression that takes its 
  145879             :  * corresponding StorageClass as parameter
  145880             :  */
  145881       29895 : SgExpression :: SgExpression ( const SgExpressionStorageClass& storageSource )   : SgLocatedNode (storageSource)
  145882             :    {
  145883             : 
  145884             : 
  145885             : /* #line 145886 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  145886             : 
  145887       29895 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  145888       29895 :      p_need_paren = storageSource.storageOf_need_paren ;
  145889       29895 :      p_lvalue = storageSource.storageOf_lvalue ;
  145890       29895 :      p_global_qualified_name = storageSource.storageOf_global_qualified_name ;
  145891       29895 :      p_operatorPosition =  (Sg_File_Info*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operatorPosition) );
  145892             : 
  145893             : 
  145894             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  145895             : 
  145896             : 
  145897       29895 :    }
  145898             : 
  145899             : //############################################################################
  145900             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  145901             :  * within the working AST. 
  145902             :  */
  145903           0 : SgExpression * SgExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  145904           0 :      SgExpression* returnPointer = NULL;
  145905           0 :      if ( globalIndex != 0 )
  145906             :         {
  145907             : 
  145908             : #if FILE_IO_EXTRA_CHECK
  145909           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgExpression ) ) <= globalIndex ) ;
  145910           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExpression + 1 ) ) );
  145911             : #endif
  145912           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExpression )  
  145913           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgExpression );
  145914           0 :           unsigned long positionInPool = localIndex % SgExpression::pool_size;
  145915           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExpression::pool_size;
  145916             : 
  145917             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  145918             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  145919             : 
  145920           0 :           returnPointer = &( ( (SgExpression*)(SgExpression::pools[memoryBlock]) ) [positionInPool]) ;
  145921             : 
  145922           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  145923             :         }
  145924           0 :      return returnPointer ;
  145925             :    }
  145926             : 
  145927             : //############################################################################
  145928             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  145929             :   for the AST with the index astIndex
  145930             : */
  145931           0 : SgExpression * SgExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  145932           0 :      SgExpression* returnPointer = NULL;
  145933           0 :      if ( globalIndex != 0 )
  145934             :         {
  145935             : 
  145936             : #if FILE_IO_EXTRA_CHECK
  145937           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgExpression ) ) <= globalIndex ) ;
  145938           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExpression + 1 ) ) );
  145939             : #endif
  145940           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExpression )
  145941           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgExpression );
  145942           0 :           unsigned long positionInPool = localIndex % SgExpression::pool_size ;
  145943           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExpression::pool_size ;
  145944             : 
  145945             : #if FILE_IO_EXTRA_CHECK
  145946             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  145947             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  145948             : #endif
  145949             : 
  145950           0 :           returnPointer = &( ( (SgExpression*)(SgExpression::pools[memoryBlock]) ) [positionInPool]) ;
  145951             : 
  145952             : #if FILE_IO_EXTRA_CHECK
  145953           0 :           assert ( returnPointer != NULL ) ;
  145954             : #endif
  145955             :         }
  145956           0 :      return returnPointer ;
  145957             :    }
  145958             : 
  145959             : //############################################################################
  145960             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  145961             :  * pool size! We set for every valid object in the memory pool the freepointer
  145962             :  * to the global index and increase the global index afterwards. For all the 
  145963             :  * invalid objects (means address ranges within the memory pool that were not
  145964             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  145965             :  * distinguish valid from invalid objects! 
  145966             :  */
  145967             : unsigned long
  145968           5 : SgExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  145969             :    {
  145970           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  145971           5 :      SgExpression* pointer = NULL;
  145972           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  145973           5 :      std::vector < unsigned char* > :: const_iterator block;
  145974           5 :      for ( block = SgExpression::pools.begin(); block != SgExpression::pools.end() ; ++block )
  145975             :         {
  145976           0 :           pointer = (SgExpression*)(*block);
  145977           0 :           for (unsigned i = 0; i < SgExpression::pool_size; ++i )
  145978             :              {
  145979             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  145980             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  145981             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  145982             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  145983             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  145984             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  145985             :             // properly; so this will have to be checked next.
  145986             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  145987             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  145988           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  145989             :                   {
  145990           0 :                     pointer[i].set_freepointer((SgExpression*)(globalIndex));
  145991           0 :                     globalIndex++;
  145992             :                   }
  145993             :                else
  145994             :                   {
  145995           0 :                     pointer[i].set_freepointer(NULL);
  145996             :                   }
  145997             :               }
  145998             :         }
  145999           5 :      return globalIndex;
  146000             :    }
  146001             : 
  146002             : //############################################################################
  146003             : // JH (01/14/2006)
  146004             : void
  146005           5 : SgExpression::resetValidFreepointers( )
  146006             :    {
  146007           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  146008           5 :      SgExpression* pointer = NULL;
  146009           5 :      std::vector < unsigned char* > :: const_iterator block;
  146010           5 :      SgExpression* pointerOfLinkedList = NULL;
  146011           5 :      for ( block = SgExpression::pools.begin(); block != SgExpression::pools.end() ; ++block )
  146012             :         {
  146013           0 :           pointer = (SgExpression*)(*block);
  146014           0 :           for (unsigned i = 0; i < SgExpression::pool_size; ++i )
  146015             :              {
  146016             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  146017             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  146018             :             // memory blocks!.
  146019           0 :                if ( pointer[i].get_freepointer() != NULL )
  146020             :                   {
  146021           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  146022             :                   }
  146023             :                else
  146024             :                   {
  146025           0 :                     if ( pointerOfLinkedList == NULL )
  146026             :                        {
  146027           0 :                          SgExpression::next_node = &(pointer[i]);
  146028             :                        }
  146029             :                     else
  146030             :                        {
  146031             :                       // printf ("In SgExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  146032           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  146033             :                        }
  146034             :                     pointerOfLinkedList = &(pointer[i]);
  146035             :                   }
  146036             :               }
  146037             :         }
  146038             : 
  146039           5 :      if ( pointerOfLinkedList != NULL )
  146040             :         {
  146041             :        // printf ("In SgExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  146042           0 :           pointerOfLinkedList->set_freepointer(NULL);
  146043             :        // DQ (6/6/2010): Temporary debugging...
  146044             :        //   ROSE_ASSERT(false);
  146045             :         }
  146046             : 
  146047           5 :      return ;
  146048             :    }
  146049             : 
  146050             : //############################################################################
  146051             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  146052             :  * within the memory pool and resets the freepointers, in order to achieve a 
  146053             :  * linked list, that has no jumps and starts at the beginning! This function 
  146054             :  * does not extend the memory pool, since we do not delete any memory blocks,
  146055             :  * but delete the valid objects.  
  146056             :  */
  146057             : void
  146058           0 : SgExpression::clearMemoryPool( )
  146059             :    {
  146060             :   // printf ("Inside of SgExpression::clearMemoryPool() \n");
  146061             : 
  146062           0 :      SgExpression* pointer = NULL, *tempPointer = NULL;
  146063           0 :      std::vector < unsigned char* > :: const_iterator block;
  146064           0 :      if ( SgExpression::pools.empty() == false )
  146065             :         {
  146066           0 :           block = SgExpression::pools.begin() ;
  146067           0 :           SgExpression::next_node = (SgExpression*) (*block);
  146068             : 
  146069           0 :           while ( block != SgExpression::pools.end() )
  146070             :              {
  146071           0 :                pointer = (SgExpression*) (*block);
  146072           0 :                if ( tempPointer != NULL )
  146073             :                   {
  146074           0 :                     tempPointer->set_freepointer(pointer);
  146075             :                   }
  146076           0 :                for (unsigned i = 0; i < SgExpression::pool_size - 1; ++i)
  146077             :                   {
  146078           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  146079             :                   }
  146080           0 :                 pointer[SgExpression::pool_size-1].set_freepointer(NULL);
  146081           0 :                 tempPointer = &(pointer[SgExpression::pool_size-1]);
  146082           0 :                 ++block;
  146083             :              }
  146084             :         }
  146085           0 :    }
  146086             : 
  146087           5 : void SgExpression::deleteMemoryPool() {
  146088           5 :   for (auto p: SgExpression::pools) {
  146089           0 :     ROSE_FREE(p);
  146090             :   }
  146091           5 :   SgExpression::next_node = nullptr;
  146092           5 :   SgExpression::pools.clear();
  146093           5 : }
  146094             : 
  146095             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  146096             : //                 reading multiple binary files to for a single AST.
  146097             : /////////// new version ////////////////////////////////
  146098             : //############################################################################
  146099             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  146100             : void
  146101           2 : SgExpression::extendMemoryPoolForFileIO( )
  146102             :   {
  146103           2 :     size_t blockIndex = SgExpression::pools.size();
  146104           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpression);
  146105             : 
  146106           2 :     while ( (blockIndex * SgExpression::pool_size) < newPoolSize)
  146107             :       {
  146108             : #if ROSE_ALLOC_TRACE
  146109             :         if (blockIndex > 0) {
  146110             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpression) = %" PRIuPTR " SgExpression::pool_size = %d \n",
  146111             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpression),SgExpression::pool_size);
  146112             :         }
  146113             : #endif
  146114             : 
  146115           0 :         SgExpression * pointer = (SgExpression*) ROSE_MALLOC ( SgExpression::pool_size * sizeof(SgExpression) );
  146116           0 :         assert( pointer != NULL );
  146117             : #if ROSE_ALLOC_MEMSET == 1
  146118             :         memset(pointer, 0x00, SgExpression::pool_size * sizeof(SgExpression));
  146119             : #elif ROSE_ALLOC_MEMSET == 2
  146120             :         memset(pointer, 0xCC, SgExpression::pool_size * sizeof(SgExpression));
  146121             : #endif
  146122           0 :         SgExpression::pools.push_back( (unsigned char*)(pointer) );
  146123           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgExpression::pool_size * sizeof(SgExpression), V_SgExpression ) );
  146124             : 
  146125           0 :         if ( SgExpression::next_node != NULL ) {
  146126           0 :           if ( blockIndex > 0 ) {
  146127           0 :             SgExpression * blkptr = (SgExpression*)(SgExpression::pools[blockIndex-1]);
  146128           0 :             blkptr[ SgExpression::pool_size - 1 ].set_freepointer(pointer);
  146129             :           }
  146130             :         } else {
  146131           0 :           SgExpression::next_node = pointer;
  146132             :         }
  146133             : 
  146134           0 :         for (unsigned i = 0; i < SgExpression::pool_size-1; ++i)
  146135             :            {
  146136           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  146137             :            }
  146138           0 :         pointer[ SgExpression::pool_size -1 ].set_freepointer(NULL);
  146139             : 
  146140           0 :         blockIndex++;
  146141             :       }
  146142           2 :   }
  146143             : 
  146144             : //############################################################################
  146145             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  146146             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  146147             :  * not compressed. However, that stuff is not yet implemented! 
  146148             :  */
  146149             : unsigned long
  146150           0 : SgExpression::getNumberOfLastValidPointer()
  146151             :    {
  146152           0 :       SgExpression* testPointer = (SgExpression*)(SgExpression::pools.back());
  146153           0 :       unsigned long localIndex = SgExpression::pool_size - 1;
  146154           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  146155             :          {
  146156           0 :            localIndex--;
  146157             :          }
  146158           0 :       return (localIndex + SgExpression::pool_size * (SgExpression::pools.size()-1));
  146159             :    }
  146160             : 
  146161             : //############################################################################
  146162             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  146163             :  * memory pool and initializes the data member in class SgExpressionStroageClass
  146164             :  * from its counterpart of SgExpression. The return value is just for checking, 
  146165             :  * that the whole StorageClassArray is initialized!
  146166             :  */
  146167             : unsigned long
  146168           0 : SgExpression::initializeStorageClassArray( SgExpressionStorageClass *storageArray )
  146169             :    {
  146170           0 :      unsigned long storageCounter = 0;
  146171           0 :      std::vector < unsigned char* > :: const_iterator block = SgExpression::pools.begin();
  146172           0 :      SgExpression* pointer = NULL;
  146173           0 :      while ( block != SgExpression::pools.end() ) {
  146174           0 :           pointer = (SgExpression*) (*block);
  146175           0 :           for ( unsigned i = 0; i < SgExpression::pool_size; ++i ) {
  146176           0 :                if ( pointer->get_freepointer() != NULL ) {
  146177           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  146178           0 :                  storageArray++;
  146179           0 :                  storageCounter++;
  146180             :                }
  146181           0 :                pointer++;
  146182             :              }
  146183           0 :            block++;
  146184             :         }
  146185           0 :      return storageCounter;
  146186             :    }
  146187             : 
  146188             : /* #line 146189 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  146189             : 
  146190             : 
  146191             : 
  146192             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  146193             : 
  146194             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  146195             : 
  146196             : //############################################################################
  146197             : /* JH (02/02/2006) Constructor of the IR node SgUnaryOp that takes its 
  146198             :  * corresponding StorageClass as parameter
  146199             :  */
  146200        3248 : SgUnaryOp :: SgUnaryOp ( const SgUnaryOpStorageClass& storageSource )   : SgExpression (storageSource)
  146201             :    {
  146202             : 
  146203             : 
  146204             : /* #line 146205 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  146205             : 
  146206        3248 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  146207        3248 :      p_operand_i =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_i) );
  146208        3248 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  146209        3248 :      p_mode = storageSource.storageOf_mode ;
  146210             : 
  146211             : 
  146212             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  146213             : 
  146214             : 
  146215        3248 :    }
  146216             : 
  146217             : //############################################################################
  146218             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  146219             :  * within the working AST. 
  146220             :  */
  146221           0 : SgUnaryOp * SgUnaryOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  146222           0 :      SgUnaryOp* returnPointer = NULL;
  146223           0 :      if ( globalIndex != 0 )
  146224             :         {
  146225             : 
  146226             : #if FILE_IO_EXTRA_CHECK
  146227           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnaryOp ) ) <= globalIndex ) ;
  146228           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnaryOp + 1 ) ) );
  146229             : #endif
  146230           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnaryOp )  
  146231           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnaryOp );
  146232           0 :           unsigned long positionInPool = localIndex % SgUnaryOp::pool_size;
  146233           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnaryOp::pool_size;
  146234             : 
  146235             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  146236             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  146237             : 
  146238           0 :           returnPointer = &( ( (SgUnaryOp*)(SgUnaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  146239             : 
  146240           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  146241             :         }
  146242           0 :      return returnPointer ;
  146243             :    }
  146244             : 
  146245             : //############################################################################
  146246             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  146247             :   for the AST with the index astIndex
  146248             : */
  146249           0 : SgUnaryOp * SgUnaryOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  146250           0 :      SgUnaryOp* returnPointer = NULL;
  146251           0 :      if ( globalIndex != 0 )
  146252             :         {
  146253             : 
  146254             : #if FILE_IO_EXTRA_CHECK
  146255           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnaryOp ) ) <= globalIndex ) ;
  146256           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnaryOp + 1 ) ) );
  146257             : #endif
  146258           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnaryOp )
  146259           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnaryOp );
  146260           0 :           unsigned long positionInPool = localIndex % SgUnaryOp::pool_size ;
  146261           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnaryOp::pool_size ;
  146262             : 
  146263             : #if FILE_IO_EXTRA_CHECK
  146264             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  146265             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  146266             : #endif
  146267             : 
  146268           0 :           returnPointer = &( ( (SgUnaryOp*)(SgUnaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  146269             : 
  146270             : #if FILE_IO_EXTRA_CHECK
  146271           0 :           assert ( returnPointer != NULL ) ;
  146272             : #endif
  146273             :         }
  146274           0 :      return returnPointer ;
  146275             :    }
  146276             : 
  146277             : //############################################################################
  146278             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  146279             :  * pool size! We set for every valid object in the memory pool the freepointer
  146280             :  * to the global index and increase the global index afterwards. For all the 
  146281             :  * invalid objects (means address ranges within the memory pool that were not
  146282             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  146283             :  * distinguish valid from invalid objects! 
  146284             :  */
  146285             : unsigned long
  146286           5 : SgUnaryOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  146287             :    {
  146288           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  146289           5 :      SgUnaryOp* pointer = NULL;
  146290           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  146291           5 :      std::vector < unsigned char* > :: const_iterator block;
  146292           5 :      for ( block = SgUnaryOp::pools.begin(); block != SgUnaryOp::pools.end() ; ++block )
  146293             :         {
  146294           0 :           pointer = (SgUnaryOp*)(*block);
  146295           0 :           for (unsigned i = 0; i < SgUnaryOp::pool_size; ++i )
  146296             :              {
  146297             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  146298             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  146299             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  146300             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  146301             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  146302             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  146303             :             // properly; so this will have to be checked next.
  146304             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  146305             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  146306           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  146307             :                   {
  146308           0 :                     pointer[i].set_freepointer((SgUnaryOp*)(globalIndex));
  146309           0 :                     globalIndex++;
  146310             :                   }
  146311             :                else
  146312             :                   {
  146313           0 :                     pointer[i].set_freepointer(NULL);
  146314             :                   }
  146315             :               }
  146316             :         }
  146317           5 :      return globalIndex;
  146318             :    }
  146319             : 
  146320             : //############################################################################
  146321             : // JH (01/14/2006)
  146322             : void
  146323           5 : SgUnaryOp::resetValidFreepointers( )
  146324             :    {
  146325           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  146326           5 :      SgUnaryOp* pointer = NULL;
  146327           5 :      std::vector < unsigned char* > :: const_iterator block;
  146328           5 :      SgUnaryOp* pointerOfLinkedList = NULL;
  146329           5 :      for ( block = SgUnaryOp::pools.begin(); block != SgUnaryOp::pools.end() ; ++block )
  146330             :         {
  146331           0 :           pointer = (SgUnaryOp*)(*block);
  146332           0 :           for (unsigned i = 0; i < SgUnaryOp::pool_size; ++i )
  146333             :              {
  146334             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  146335             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  146336             :             // memory blocks!.
  146337           0 :                if ( pointer[i].get_freepointer() != NULL )
  146338             :                   {
  146339           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  146340             :                   }
  146341             :                else
  146342             :                   {
  146343           0 :                     if ( pointerOfLinkedList == NULL )
  146344             :                        {
  146345           0 :                          SgUnaryOp::next_node = &(pointer[i]);
  146346             :                        }
  146347             :                     else
  146348             :                        {
  146349             :                       // printf ("In SgUnaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  146350           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  146351             :                        }
  146352             :                     pointerOfLinkedList = &(pointer[i]);
  146353             :                   }
  146354             :               }
  146355             :         }
  146356             : 
  146357           5 :      if ( pointerOfLinkedList != NULL )
  146358             :         {
  146359             :        // printf ("In SgUnaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  146360           0 :           pointerOfLinkedList->set_freepointer(NULL);
  146361             :        // DQ (6/6/2010): Temporary debugging...
  146362             :        //   ROSE_ASSERT(false);
  146363             :         }
  146364             : 
  146365           5 :      return ;
  146366             :    }
  146367             : 
  146368             : //############################################################################
  146369             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  146370             :  * within the memory pool and resets the freepointers, in order to achieve a 
  146371             :  * linked list, that has no jumps and starts at the beginning! This function 
  146372             :  * does not extend the memory pool, since we do not delete any memory blocks,
  146373             :  * but delete the valid objects.  
  146374             :  */
  146375             : void
  146376           0 : SgUnaryOp::clearMemoryPool( )
  146377             :    {
  146378             :   // printf ("Inside of SgUnaryOp::clearMemoryPool() \n");
  146379             : 
  146380           0 :      SgUnaryOp* pointer = NULL, *tempPointer = NULL;
  146381           0 :      std::vector < unsigned char* > :: const_iterator block;
  146382           0 :      if ( SgUnaryOp::pools.empty() == false )
  146383             :         {
  146384           0 :           block = SgUnaryOp::pools.begin() ;
  146385           0 :           SgUnaryOp::next_node = (SgUnaryOp*) (*block);
  146386             : 
  146387           0 :           while ( block != SgUnaryOp::pools.end() )
  146388             :              {
  146389           0 :                pointer = (SgUnaryOp*) (*block);
  146390           0 :                if ( tempPointer != NULL )
  146391             :                   {
  146392           0 :                     tempPointer->set_freepointer(pointer);
  146393             :                   }
  146394           0 :                for (unsigned i = 0; i < SgUnaryOp::pool_size - 1; ++i)
  146395             :                   {
  146396           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  146397             :                   }
  146398           0 :                 pointer[SgUnaryOp::pool_size-1].set_freepointer(NULL);
  146399           0 :                 tempPointer = &(pointer[SgUnaryOp::pool_size-1]);
  146400           0 :                 ++block;
  146401             :              }
  146402             :         }
  146403           0 :    }
  146404             : 
  146405           5 : void SgUnaryOp::deleteMemoryPool() {
  146406           5 :   for (auto p: SgUnaryOp::pools) {
  146407           0 :     ROSE_FREE(p);
  146408             :   }
  146409           5 :   SgUnaryOp::next_node = nullptr;
  146410           5 :   SgUnaryOp::pools.clear();
  146411           5 : }
  146412             : 
  146413             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  146414             : //                 reading multiple binary files to for a single AST.
  146415             : /////////// new version ////////////////////////////////
  146416             : //############################################################################
  146417             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  146418             : void
  146419           2 : SgUnaryOp::extendMemoryPoolForFileIO( )
  146420             :   {
  146421           2 :     size_t blockIndex = SgUnaryOp::pools.size();
  146422           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnaryOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnaryOp);
  146423             : 
  146424           2 :     while ( (blockIndex * SgUnaryOp::pool_size) < newPoolSize)
  146425             :       {
  146426             : #if ROSE_ALLOC_TRACE
  146427             :         if (blockIndex > 0) {
  146428             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnaryOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnaryOp) = %" PRIuPTR " SgUnaryOp::pool_size = %d \n",
  146429             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnaryOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnaryOp),SgUnaryOp::pool_size);
  146430             :         }
  146431             : #endif
  146432             : 
  146433           0 :         SgUnaryOp * pointer = (SgUnaryOp*) ROSE_MALLOC ( SgUnaryOp::pool_size * sizeof(SgUnaryOp) );
  146434           0 :         assert( pointer != NULL );
  146435             : #if ROSE_ALLOC_MEMSET == 1
  146436             :         memset(pointer, 0x00, SgUnaryOp::pool_size * sizeof(SgUnaryOp));
  146437             : #elif ROSE_ALLOC_MEMSET == 2
  146438             :         memset(pointer, 0xCC, SgUnaryOp::pool_size * sizeof(SgUnaryOp));
  146439             : #endif
  146440           0 :         SgUnaryOp::pools.push_back( (unsigned char*)(pointer) );
  146441           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnaryOp::pool_size * sizeof(SgUnaryOp), V_SgUnaryOp ) );
  146442             : 
  146443           0 :         if ( SgUnaryOp::next_node != NULL ) {
  146444           0 :           if ( blockIndex > 0 ) {
  146445           0 :             SgUnaryOp * blkptr = (SgUnaryOp*)(SgUnaryOp::pools[blockIndex-1]);
  146446           0 :             blkptr[ SgUnaryOp::pool_size - 1 ].set_freepointer(pointer);
  146447             :           }
  146448             :         } else {
  146449           0 :           SgUnaryOp::next_node = pointer;
  146450             :         }
  146451             : 
  146452           0 :         for (unsigned i = 0; i < SgUnaryOp::pool_size-1; ++i)
  146453             :            {
  146454           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  146455             :            }
  146456           0 :         pointer[ SgUnaryOp::pool_size -1 ].set_freepointer(NULL);
  146457             : 
  146458           0 :         blockIndex++;
  146459             :       }
  146460           2 :   }
  146461             : 
  146462             : //############################################################################
  146463             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  146464             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  146465             :  * not compressed. However, that stuff is not yet implemented! 
  146466             :  */
  146467             : unsigned long
  146468           0 : SgUnaryOp::getNumberOfLastValidPointer()
  146469             :    {
  146470           0 :       SgUnaryOp* testPointer = (SgUnaryOp*)(SgUnaryOp::pools.back());
  146471           0 :       unsigned long localIndex = SgUnaryOp::pool_size - 1;
  146472           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  146473             :          {
  146474           0 :            localIndex--;
  146475             :          }
  146476           0 :       return (localIndex + SgUnaryOp::pool_size * (SgUnaryOp::pools.size()-1));
  146477             :    }
  146478             : 
  146479             : //############################################################################
  146480             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  146481             :  * memory pool and initializes the data member in class SgUnaryOpStroageClass
  146482             :  * from its counterpart of SgUnaryOp. The return value is just for checking, 
  146483             :  * that the whole StorageClassArray is initialized!
  146484             :  */
  146485             : unsigned long
  146486           0 : SgUnaryOp::initializeStorageClassArray( SgUnaryOpStorageClass *storageArray )
  146487             :    {
  146488           0 :      unsigned long storageCounter = 0;
  146489           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnaryOp::pools.begin();
  146490           0 :      SgUnaryOp* pointer = NULL;
  146491           0 :      while ( block != SgUnaryOp::pools.end() ) {
  146492           0 :           pointer = (SgUnaryOp*) (*block);
  146493           0 :           for ( unsigned i = 0; i < SgUnaryOp::pool_size; ++i ) {
  146494           0 :                if ( pointer->get_freepointer() != NULL ) {
  146495           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  146496           0 :                  storageArray++;
  146497           0 :                  storageCounter++;
  146498             :                }
  146499           0 :                pointer++;
  146500             :              }
  146501           0 :            block++;
  146502             :         }
  146503           0 :      return storageCounter;
  146504             :    }
  146505             : 
  146506             : /* #line 146507 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  146507             : 
  146508             : 
  146509             : 
  146510             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  146511             : 
  146512             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  146513             : 
  146514             : //############################################################################
  146515             : /* JH (02/02/2006) Constructor of the IR node SgExpressionRoot that takes its 
  146516             :  * corresponding StorageClass as parameter
  146517             :  */
  146518           0 : SgExpressionRoot :: SgExpressionRoot ( const SgExpressionRootStorageClass& storageSource )   : SgUnaryOp (storageSource)
  146519             :    {
  146520             : 
  146521             : 
  146522             : /* #line 146523 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  146523             : 
  146524           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  146525             : 
  146526             : 
  146527             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  146528             : 
  146529             : 
  146530           0 :    }
  146531             : 
  146532             : //############################################################################
  146533             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  146534             :  * within the working AST. 
  146535             :  */
  146536           0 : SgExpressionRoot * SgExpressionRoot::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  146537           0 :      SgExpressionRoot* returnPointer = NULL;
  146538           0 :      if ( globalIndex != 0 )
  146539             :         {
  146540             : 
  146541             : #if FILE_IO_EXTRA_CHECK
  146542           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgExpressionRoot ) ) <= globalIndex ) ;
  146543           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExpressionRoot + 1 ) ) );
  146544             : #endif
  146545           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExpressionRoot )  
  146546           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgExpressionRoot );
  146547           0 :           unsigned long positionInPool = localIndex % SgExpressionRoot::pool_size;
  146548           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExpressionRoot::pool_size;
  146549             : 
  146550             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  146551             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  146552             : 
  146553           0 :           returnPointer = &( ( (SgExpressionRoot*)(SgExpressionRoot::pools[memoryBlock]) ) [positionInPool]) ;
  146554             : 
  146555           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  146556             :         }
  146557           0 :      return returnPointer ;
  146558             :    }
  146559             : 
  146560             : //############################################################################
  146561             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  146562             :   for the AST with the index astIndex
  146563             : */
  146564           0 : SgExpressionRoot * SgExpressionRoot::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  146565           0 :      SgExpressionRoot* returnPointer = NULL;
  146566           0 :      if ( globalIndex != 0 )
  146567             :         {
  146568             : 
  146569             : #if FILE_IO_EXTRA_CHECK
  146570           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgExpressionRoot ) ) <= globalIndex ) ;
  146571           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExpressionRoot + 1 ) ) );
  146572             : #endif
  146573           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExpressionRoot )
  146574           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgExpressionRoot );
  146575           0 :           unsigned long positionInPool = localIndex % SgExpressionRoot::pool_size ;
  146576           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExpressionRoot::pool_size ;
  146577             : 
  146578             : #if FILE_IO_EXTRA_CHECK
  146579             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  146580             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  146581             : #endif
  146582             : 
  146583           0 :           returnPointer = &( ( (SgExpressionRoot*)(SgExpressionRoot::pools[memoryBlock]) ) [positionInPool]) ;
  146584             : 
  146585             : #if FILE_IO_EXTRA_CHECK
  146586           0 :           assert ( returnPointer != NULL ) ;
  146587             : #endif
  146588             :         }
  146589           0 :      return returnPointer ;
  146590             :    }
  146591             : 
  146592             : //############################################################################
  146593             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  146594             :  * pool size! We set for every valid object in the memory pool the freepointer
  146595             :  * to the global index and increase the global index afterwards. For all the 
  146596             :  * invalid objects (means address ranges within the memory pool that were not
  146597             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  146598             :  * distinguish valid from invalid objects! 
  146599             :  */
  146600             : unsigned long
  146601           5 : SgExpressionRoot::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  146602             :    {
  146603           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  146604           5 :      SgExpressionRoot* pointer = NULL;
  146605           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  146606           5 :      std::vector < unsigned char* > :: const_iterator block;
  146607           5 :      for ( block = SgExpressionRoot::pools.begin(); block != SgExpressionRoot::pools.end() ; ++block )
  146608             :         {
  146609           0 :           pointer = (SgExpressionRoot*)(*block);
  146610           0 :           for (unsigned i = 0; i < SgExpressionRoot::pool_size; ++i )
  146611             :              {
  146612             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  146613             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  146614             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  146615             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  146616             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  146617             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  146618             :             // properly; so this will have to be checked next.
  146619             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  146620             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  146621           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  146622             :                   {
  146623           0 :                     pointer[i].set_freepointer((SgExpressionRoot*)(globalIndex));
  146624           0 :                     globalIndex++;
  146625             :                   }
  146626             :                else
  146627             :                   {
  146628           0 :                     pointer[i].set_freepointer(NULL);
  146629             :                   }
  146630             :               }
  146631             :         }
  146632           5 :      return globalIndex;
  146633             :    }
  146634             : 
  146635             : //############################################################################
  146636             : // JH (01/14/2006)
  146637             : void
  146638           5 : SgExpressionRoot::resetValidFreepointers( )
  146639             :    {
  146640           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  146641           5 :      SgExpressionRoot* pointer = NULL;
  146642           5 :      std::vector < unsigned char* > :: const_iterator block;
  146643           5 :      SgExpressionRoot* pointerOfLinkedList = NULL;
  146644           5 :      for ( block = SgExpressionRoot::pools.begin(); block != SgExpressionRoot::pools.end() ; ++block )
  146645             :         {
  146646           0 :           pointer = (SgExpressionRoot*)(*block);
  146647           0 :           for (unsigned i = 0; i < SgExpressionRoot::pool_size; ++i )
  146648             :              {
  146649             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  146650             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  146651             :             // memory blocks!.
  146652           0 :                if ( pointer[i].get_freepointer() != NULL )
  146653             :                   {
  146654           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  146655             :                   }
  146656             :                else
  146657             :                   {
  146658           0 :                     if ( pointerOfLinkedList == NULL )
  146659             :                        {
  146660           0 :                          SgExpressionRoot::next_node = &(pointer[i]);
  146661             :                        }
  146662             :                     else
  146663             :                        {
  146664             :                       // printf ("In SgExpressionRoot::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  146665           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  146666             :                        }
  146667             :                     pointerOfLinkedList = &(pointer[i]);
  146668             :                   }
  146669             :               }
  146670             :         }
  146671             : 
  146672           5 :      if ( pointerOfLinkedList != NULL )
  146673             :         {
  146674             :        // printf ("In SgExpressionRoot::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  146675           0 :           pointerOfLinkedList->set_freepointer(NULL);
  146676             :        // DQ (6/6/2010): Temporary debugging...
  146677             :        //   ROSE_ASSERT(false);
  146678             :         }
  146679             : 
  146680           5 :      return ;
  146681             :    }
  146682             : 
  146683             : //############################################################################
  146684             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  146685             :  * within the memory pool and resets the freepointers, in order to achieve a 
  146686             :  * linked list, that has no jumps and starts at the beginning! This function 
  146687             :  * does not extend the memory pool, since we do not delete any memory blocks,
  146688             :  * but delete the valid objects.  
  146689             :  */
  146690             : void
  146691           0 : SgExpressionRoot::clearMemoryPool( )
  146692             :    {
  146693             :   // printf ("Inside of SgExpressionRoot::clearMemoryPool() \n");
  146694             : 
  146695           0 :      SgExpressionRoot* pointer = NULL, *tempPointer = NULL;
  146696           0 :      std::vector < unsigned char* > :: const_iterator block;
  146697           0 :      if ( SgExpressionRoot::pools.empty() == false )
  146698             :         {
  146699           0 :           block = SgExpressionRoot::pools.begin() ;
  146700           0 :           SgExpressionRoot::next_node = (SgExpressionRoot*) (*block);
  146701             : 
  146702           0 :           while ( block != SgExpressionRoot::pools.end() )
  146703             :              {
  146704           0 :                pointer = (SgExpressionRoot*) (*block);
  146705           0 :                if ( tempPointer != NULL )
  146706             :                   {
  146707           0 :                     tempPointer->set_freepointer(pointer);
  146708             :                   }
  146709           0 :                for (unsigned i = 0; i < SgExpressionRoot::pool_size - 1; ++i)
  146710             :                   {
  146711           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  146712             :                   }
  146713           0 :                 pointer[SgExpressionRoot::pool_size-1].set_freepointer(NULL);
  146714           0 :                 tempPointer = &(pointer[SgExpressionRoot::pool_size-1]);
  146715           0 :                 ++block;
  146716             :              }
  146717             :         }
  146718           0 :    }
  146719             : 
  146720           5 : void SgExpressionRoot::deleteMemoryPool() {
  146721           5 :   for (auto p: SgExpressionRoot::pools) {
  146722           0 :     ROSE_FREE(p);
  146723             :   }
  146724           5 :   SgExpressionRoot::next_node = nullptr;
  146725           5 :   SgExpressionRoot::pools.clear();
  146726           5 : }
  146727             : 
  146728             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  146729             : //                 reading multiple binary files to for a single AST.
  146730             : /////////// new version ////////////////////////////////
  146731             : //############################################################################
  146732             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  146733             : void
  146734           2 : SgExpressionRoot::extendMemoryPoolForFileIO( )
  146735             :   {
  146736           2 :     size_t blockIndex = SgExpressionRoot::pools.size();
  146737           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgExpressionRoot) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpressionRoot);
  146738             : 
  146739           2 :     while ( (blockIndex * SgExpressionRoot::pool_size) < newPoolSize)
  146740             :       {
  146741             : #if ROSE_ALLOC_TRACE
  146742             :         if (blockIndex > 0) {
  146743             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgExpressionRoot) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpressionRoot) = %" PRIuPTR " SgExpressionRoot::pool_size = %d \n",
  146744             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgExpressionRoot),AST_FILE_IO::getPoolSizeOfNewAst(V_SgExpressionRoot),SgExpressionRoot::pool_size);
  146745             :         }
  146746             : #endif
  146747             : 
  146748           0 :         SgExpressionRoot * pointer = (SgExpressionRoot*) ROSE_MALLOC ( SgExpressionRoot::pool_size * sizeof(SgExpressionRoot) );
  146749           0 :         assert( pointer != NULL );
  146750             : #if ROSE_ALLOC_MEMSET == 1
  146751             :         memset(pointer, 0x00, SgExpressionRoot::pool_size * sizeof(SgExpressionRoot));
  146752             : #elif ROSE_ALLOC_MEMSET == 2
  146753             :         memset(pointer, 0xCC, SgExpressionRoot::pool_size * sizeof(SgExpressionRoot));
  146754             : #endif
  146755           0 :         SgExpressionRoot::pools.push_back( (unsigned char*)(pointer) );
  146756           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgExpressionRoot::pool_size * sizeof(SgExpressionRoot), V_SgExpressionRoot ) );
  146757             : 
  146758           0 :         if ( SgExpressionRoot::next_node != NULL ) {
  146759           0 :           if ( blockIndex > 0 ) {
  146760           0 :             SgExpressionRoot * blkptr = (SgExpressionRoot*)(SgExpressionRoot::pools[blockIndex-1]);
  146761           0 :             blkptr[ SgExpressionRoot::pool_size - 1 ].set_freepointer(pointer);
  146762             :           }
  146763             :         } else {
  146764           0 :           SgExpressionRoot::next_node = pointer;
  146765             :         }
  146766             : 
  146767           0 :         for (unsigned i = 0; i < SgExpressionRoot::pool_size-1; ++i)
  146768             :            {
  146769           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  146770             :            }
  146771           0 :         pointer[ SgExpressionRoot::pool_size -1 ].set_freepointer(NULL);
  146772             : 
  146773           0 :         blockIndex++;
  146774             :       }
  146775           2 :   }
  146776             : 
  146777             : //############################################################################
  146778             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  146779             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  146780             :  * not compressed. However, that stuff is not yet implemented! 
  146781             :  */
  146782             : unsigned long
  146783           0 : SgExpressionRoot::getNumberOfLastValidPointer()
  146784             :    {
  146785           0 :       SgExpressionRoot* testPointer = (SgExpressionRoot*)(SgExpressionRoot::pools.back());
  146786           0 :       unsigned long localIndex = SgExpressionRoot::pool_size - 1;
  146787           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  146788             :          {
  146789           0 :            localIndex--;
  146790             :          }
  146791           0 :       return (localIndex + SgExpressionRoot::pool_size * (SgExpressionRoot::pools.size()-1));
  146792             :    }
  146793             : 
  146794             : //############################################################################
  146795             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  146796             :  * memory pool and initializes the data member in class SgExpressionRootStroageClass
  146797             :  * from its counterpart of SgExpressionRoot. The return value is just for checking, 
  146798             :  * that the whole StorageClassArray is initialized!
  146799             :  */
  146800             : unsigned long
  146801           0 : SgExpressionRoot::initializeStorageClassArray( SgExpressionRootStorageClass *storageArray )
  146802             :    {
  146803           0 :      unsigned long storageCounter = 0;
  146804           0 :      std::vector < unsigned char* > :: const_iterator block = SgExpressionRoot::pools.begin();
  146805           0 :      SgExpressionRoot* pointer = NULL;
  146806           0 :      while ( block != SgExpressionRoot::pools.end() ) {
  146807           0 :           pointer = (SgExpressionRoot*) (*block);
  146808           0 :           for ( unsigned i = 0; i < SgExpressionRoot::pool_size; ++i ) {
  146809           0 :                if ( pointer->get_freepointer() != NULL ) {
  146810           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  146811           0 :                  storageArray++;
  146812           0 :                  storageCounter++;
  146813             :                }
  146814           0 :                pointer++;
  146815             :              }
  146816           0 :            block++;
  146817             :         }
  146818           0 :      return storageCounter;
  146819             :    }
  146820             : 
  146821             : /* #line 146822 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  146822             : 
  146823             : 
  146824             : 
  146825             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  146826             : 
  146827             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  146828             : 
  146829             : //############################################################################
  146830             : /* JH (02/02/2006) Constructor of the IR node SgMinusOp that takes its 
  146831             :  * corresponding StorageClass as parameter
  146832             :  */
  146833          57 : SgMinusOp :: SgMinusOp ( const SgMinusOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  146834             :    {
  146835             : 
  146836             : 
  146837             : /* #line 146838 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  146838             : 
  146839          57 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  146840             : 
  146841             : 
  146842             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  146843             : 
  146844             : 
  146845          57 :    }
  146846             : 
  146847             : //############################################################################
  146848             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  146849             :  * within the working AST. 
  146850             :  */
  146851         285 : SgMinusOp * SgMinusOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  146852         285 :      SgMinusOp* returnPointer = NULL;
  146853         285 :      if ( globalIndex != 0 )
  146854             :         {
  146855             : 
  146856             : #if FILE_IO_EXTRA_CHECK
  146857         285 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMinusOp ) ) <= globalIndex ) ;
  146858         285 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMinusOp + 1 ) ) );
  146859             : #endif
  146860         285 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMinusOp )  
  146861         285 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMinusOp );
  146862         285 :           unsigned long positionInPool = localIndex % SgMinusOp::pool_size;
  146863         285 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMinusOp::pool_size;
  146864             : 
  146865             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  146866             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  146867             : 
  146868         285 :           returnPointer = &( ( (SgMinusOp*)(SgMinusOp::pools[memoryBlock]) ) [positionInPool]) ;
  146869             : 
  146870         285 :           ROSE_ASSERT( returnPointer != NULL ) ;
  146871             :         }
  146872         285 :      return returnPointer ;
  146873             :    }
  146874             : 
  146875             : //############################################################################
  146876             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  146877             :   for the AST with the index astIndex
  146878             : */
  146879           0 : SgMinusOp * SgMinusOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  146880           0 :      SgMinusOp* returnPointer = NULL;
  146881           0 :      if ( globalIndex != 0 )
  146882             :         {
  146883             : 
  146884             : #if FILE_IO_EXTRA_CHECK
  146885           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMinusOp ) ) <= globalIndex ) ;
  146886           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMinusOp + 1 ) ) );
  146887             : #endif
  146888           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMinusOp )
  146889           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMinusOp );
  146890           0 :           unsigned long positionInPool = localIndex % SgMinusOp::pool_size ;
  146891           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMinusOp::pool_size ;
  146892             : 
  146893             : #if FILE_IO_EXTRA_CHECK
  146894             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  146895             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  146896             : #endif
  146897             : 
  146898           0 :           returnPointer = &( ( (SgMinusOp*)(SgMinusOp::pools[memoryBlock]) ) [positionInPool]) ;
  146899             : 
  146900             : #if FILE_IO_EXTRA_CHECK
  146901           0 :           assert ( returnPointer != NULL ) ;
  146902             : #endif
  146903             :         }
  146904           0 :      return returnPointer ;
  146905             :    }
  146906             : 
  146907             : //############################################################################
  146908             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  146909             :  * pool size! We set for every valid object in the memory pool the freepointer
  146910             :  * to the global index and increase the global index afterwards. For all the 
  146911             :  * invalid objects (means address ranges within the memory pool that were not
  146912             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  146913             :  * distinguish valid from invalid objects! 
  146914             :  */
  146915             : unsigned long
  146916           5 : SgMinusOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  146917             :    {
  146918           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  146919           5 :      SgMinusOp* pointer = NULL;
  146920           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  146921           5 :      std::vector < unsigned char* > :: const_iterator block;
  146922           6 :      for ( block = SgMinusOp::pools.begin(); block != SgMinusOp::pools.end() ; ++block )
  146923             :         {
  146924           1 :           pointer = (SgMinusOp*)(*block);
  146925        2001 :           for (unsigned i = 0; i < SgMinusOp::pool_size; ++i )
  146926             :              {
  146927             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  146928             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  146929             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  146930             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  146931             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  146932             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  146933             :             // properly; so this will have to be checked next.
  146934             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  146935             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  146936        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  146937             :                   {
  146938          57 :                     pointer[i].set_freepointer((SgMinusOp*)(globalIndex));
  146939          57 :                     globalIndex++;
  146940             :                   }
  146941             :                else
  146942             :                   {
  146943        1943 :                     pointer[i].set_freepointer(NULL);
  146944             :                   }
  146945             :               }
  146946             :         }
  146947           5 :      return globalIndex;
  146948             :    }
  146949             : 
  146950             : //############################################################################
  146951             : // JH (01/14/2006)
  146952             : void
  146953           5 : SgMinusOp::resetValidFreepointers( )
  146954             :    {
  146955           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  146956           5 :      SgMinusOp* pointer = NULL;
  146957           5 :      std::vector < unsigned char* > :: const_iterator block;
  146958           5 :      SgMinusOp* pointerOfLinkedList = NULL;
  146959           6 :      for ( block = SgMinusOp::pools.begin(); block != SgMinusOp::pools.end() ; ++block )
  146960             :         {
  146961           1 :           pointer = (SgMinusOp*)(*block);
  146962        2001 :           for (unsigned i = 0; i < SgMinusOp::pool_size; ++i )
  146963             :              {
  146964             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  146965             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  146966             :             // memory blocks!.
  146967        2000 :                if ( pointer[i].get_freepointer() != NULL )
  146968             :                   {
  146969          57 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  146970             :                   }
  146971             :                else
  146972             :                   {
  146973        1943 :                     if ( pointerOfLinkedList == NULL )
  146974             :                        {
  146975           1 :                          SgMinusOp::next_node = &(pointer[i]);
  146976             :                        }
  146977             :                     else
  146978             :                        {
  146979             :                       // printf ("In SgMinusOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  146980        1942 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  146981             :                        }
  146982             :                     pointerOfLinkedList = &(pointer[i]);
  146983             :                   }
  146984             :               }
  146985             :         }
  146986             : 
  146987           5 :      if ( pointerOfLinkedList != NULL )
  146988             :         {
  146989             :        // printf ("In SgMinusOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  146990           1 :           pointerOfLinkedList->set_freepointer(NULL);
  146991             :        // DQ (6/6/2010): Temporary debugging...
  146992             :        //   ROSE_ASSERT(false);
  146993             :         }
  146994             : 
  146995           5 :      return ;
  146996             :    }
  146997             : 
  146998             : //############################################################################
  146999             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  147000             :  * within the memory pool and resets the freepointers, in order to achieve a 
  147001             :  * linked list, that has no jumps and starts at the beginning! This function 
  147002             :  * does not extend the memory pool, since we do not delete any memory blocks,
  147003             :  * but delete the valid objects.  
  147004             :  */
  147005             : void
  147006           0 : SgMinusOp::clearMemoryPool( )
  147007             :    {
  147008             :   // printf ("Inside of SgMinusOp::clearMemoryPool() \n");
  147009             : 
  147010           0 :      SgMinusOp* pointer = NULL, *tempPointer = NULL;
  147011           0 :      std::vector < unsigned char* > :: const_iterator block;
  147012           0 :      if ( SgMinusOp::pools.empty() == false )
  147013             :         {
  147014           0 :           block = SgMinusOp::pools.begin() ;
  147015           0 :           SgMinusOp::next_node = (SgMinusOp*) (*block);
  147016             : 
  147017           0 :           while ( block != SgMinusOp::pools.end() )
  147018             :              {
  147019           0 :                pointer = (SgMinusOp*) (*block);
  147020           0 :                if ( tempPointer != NULL )
  147021             :                   {
  147022           0 :                     tempPointer->set_freepointer(pointer);
  147023             :                   }
  147024           0 :                for (unsigned i = 0; i < SgMinusOp::pool_size - 1; ++i)
  147025             :                   {
  147026           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  147027             :                   }
  147028           0 :                 pointer[SgMinusOp::pool_size-1].set_freepointer(NULL);
  147029           0 :                 tempPointer = &(pointer[SgMinusOp::pool_size-1]);
  147030           0 :                 ++block;
  147031             :              }
  147032             :         }
  147033           0 :    }
  147034             : 
  147035           5 : void SgMinusOp::deleteMemoryPool() {
  147036           7 :   for (auto p: SgMinusOp::pools) {
  147037           2 :     ROSE_FREE(p);
  147038             :   }
  147039           5 :   SgMinusOp::next_node = nullptr;
  147040           5 :   SgMinusOp::pools.clear();
  147041           5 : }
  147042             : 
  147043             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  147044             : //                 reading multiple binary files to for a single AST.
  147045             : /////////// new version ////////////////////////////////
  147046             : //############################################################################
  147047             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  147048             : void
  147049           2 : SgMinusOp::extendMemoryPoolForFileIO( )
  147050             :   {
  147051           2 :     size_t blockIndex = SgMinusOp::pools.size();
  147052           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusOp);
  147053             : 
  147054           3 :     while ( (blockIndex * SgMinusOp::pool_size) < newPoolSize)
  147055             :       {
  147056             : #if ROSE_ALLOC_TRACE
  147057             :         if (blockIndex > 0) {
  147058             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusOp) = %" PRIuPTR " SgMinusOp::pool_size = %d \n",
  147059             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusOp),SgMinusOp::pool_size);
  147060             :         }
  147061             : #endif
  147062             : 
  147063           1 :         SgMinusOp * pointer = (SgMinusOp*) ROSE_MALLOC ( SgMinusOp::pool_size * sizeof(SgMinusOp) );
  147064           1 :         assert( pointer != NULL );
  147065             : #if ROSE_ALLOC_MEMSET == 1
  147066             :         memset(pointer, 0x00, SgMinusOp::pool_size * sizeof(SgMinusOp));
  147067             : #elif ROSE_ALLOC_MEMSET == 2
  147068             :         memset(pointer, 0xCC, SgMinusOp::pool_size * sizeof(SgMinusOp));
  147069             : #endif
  147070           1 :         SgMinusOp::pools.push_back( (unsigned char*)(pointer) );
  147071           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMinusOp::pool_size * sizeof(SgMinusOp), V_SgMinusOp ) );
  147072             : 
  147073           1 :         if ( SgMinusOp::next_node != NULL ) {
  147074           0 :           if ( blockIndex > 0 ) {
  147075           0 :             SgMinusOp * blkptr = (SgMinusOp*)(SgMinusOp::pools[blockIndex-1]);
  147076           0 :             blkptr[ SgMinusOp::pool_size - 1 ].set_freepointer(pointer);
  147077             :           }
  147078             :         } else {
  147079           1 :           SgMinusOp::next_node = pointer;
  147080             :         }
  147081             : 
  147082        2000 :         for (unsigned i = 0; i < SgMinusOp::pool_size-1; ++i)
  147083             :            {
  147084        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  147085             :            }
  147086           1 :         pointer[ SgMinusOp::pool_size -1 ].set_freepointer(NULL);
  147087             : 
  147088           1 :         blockIndex++;
  147089             :       }
  147090           2 :   }
  147091             : 
  147092             : //############################################################################
  147093             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  147094             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  147095             :  * not compressed. However, that stuff is not yet implemented! 
  147096             :  */
  147097             : unsigned long
  147098           0 : SgMinusOp::getNumberOfLastValidPointer()
  147099             :    {
  147100           0 :       SgMinusOp* testPointer = (SgMinusOp*)(SgMinusOp::pools.back());
  147101           0 :       unsigned long localIndex = SgMinusOp::pool_size - 1;
  147102           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  147103             :          {
  147104           0 :            localIndex--;
  147105             :          }
  147106           0 :       return (localIndex + SgMinusOp::pool_size * (SgMinusOp::pools.size()-1));
  147107             :    }
  147108             : 
  147109             : //############################################################################
  147110             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  147111             :  * memory pool and initializes the data member in class SgMinusOpStroageClass
  147112             :  * from its counterpart of SgMinusOp. The return value is just for checking, 
  147113             :  * that the whole StorageClassArray is initialized!
  147114             :  */
  147115             : unsigned long
  147116           1 : SgMinusOp::initializeStorageClassArray( SgMinusOpStorageClass *storageArray )
  147117             :    {
  147118           1 :      unsigned long storageCounter = 0;
  147119           1 :      std::vector < unsigned char* > :: const_iterator block = SgMinusOp::pools.begin();
  147120           1 :      SgMinusOp* pointer = NULL;
  147121           2 :      while ( block != SgMinusOp::pools.end() ) {
  147122           1 :           pointer = (SgMinusOp*) (*block);
  147123        2001 :           for ( unsigned i = 0; i < SgMinusOp::pool_size; ++i ) {
  147124        2000 :                if ( pointer->get_freepointer() != NULL ) {
  147125          57 :                  storageArray->pickOutIRNodeData (pointer) ;
  147126          57 :                  storageArray++;
  147127          57 :                  storageCounter++;
  147128             :                }
  147129        2000 :                pointer++;
  147130             :              }
  147131           1 :            block++;
  147132             :         }
  147133           1 :      return storageCounter;
  147134             :    }
  147135             : 
  147136             : /* #line 147137 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  147137             : 
  147138             : 
  147139             : 
  147140             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  147141             : 
  147142             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  147143             : 
  147144             : //############################################################################
  147145             : /* JH (02/02/2006) Constructor of the IR node SgUnaryAddOp that takes its 
  147146             :  * corresponding StorageClass as parameter
  147147             :  */
  147148           0 : SgUnaryAddOp :: SgUnaryAddOp ( const SgUnaryAddOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  147149             :    {
  147150             : 
  147151             : 
  147152             : /* #line 147153 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  147153             : 
  147154           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  147155             : 
  147156             : 
  147157             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  147158             : 
  147159             : 
  147160           0 :    }
  147161             : 
  147162             : //############################################################################
  147163             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  147164             :  * within the working AST. 
  147165             :  */
  147166           0 : SgUnaryAddOp * SgUnaryAddOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  147167           0 :      SgUnaryAddOp* returnPointer = NULL;
  147168           0 :      if ( globalIndex != 0 )
  147169             :         {
  147170             : 
  147171             : #if FILE_IO_EXTRA_CHECK
  147172           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnaryAddOp ) ) <= globalIndex ) ;
  147173           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnaryAddOp + 1 ) ) );
  147174             : #endif
  147175           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnaryAddOp )  
  147176           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnaryAddOp );
  147177           0 :           unsigned long positionInPool = localIndex % SgUnaryAddOp::pool_size;
  147178           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnaryAddOp::pool_size;
  147179             : 
  147180             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  147181             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  147182             : 
  147183           0 :           returnPointer = &( ( (SgUnaryAddOp*)(SgUnaryAddOp::pools[memoryBlock]) ) [positionInPool]) ;
  147184             : 
  147185           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  147186             :         }
  147187           0 :      return returnPointer ;
  147188             :    }
  147189             : 
  147190             : //############################################################################
  147191             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  147192             :   for the AST with the index astIndex
  147193             : */
  147194           0 : SgUnaryAddOp * SgUnaryAddOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  147195           0 :      SgUnaryAddOp* returnPointer = NULL;
  147196           0 :      if ( globalIndex != 0 )
  147197             :         {
  147198             : 
  147199             : #if FILE_IO_EXTRA_CHECK
  147200           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnaryAddOp ) ) <= globalIndex ) ;
  147201           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnaryAddOp + 1 ) ) );
  147202             : #endif
  147203           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnaryAddOp )
  147204           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnaryAddOp );
  147205           0 :           unsigned long positionInPool = localIndex % SgUnaryAddOp::pool_size ;
  147206           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnaryAddOp::pool_size ;
  147207             : 
  147208             : #if FILE_IO_EXTRA_CHECK
  147209             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  147210             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  147211             : #endif
  147212             : 
  147213           0 :           returnPointer = &( ( (SgUnaryAddOp*)(SgUnaryAddOp::pools[memoryBlock]) ) [positionInPool]) ;
  147214             : 
  147215             : #if FILE_IO_EXTRA_CHECK
  147216           0 :           assert ( returnPointer != NULL ) ;
  147217             : #endif
  147218             :         }
  147219           0 :      return returnPointer ;
  147220             :    }
  147221             : 
  147222             : //############################################################################
  147223             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  147224             :  * pool size! We set for every valid object in the memory pool the freepointer
  147225             :  * to the global index and increase the global index afterwards. For all the 
  147226             :  * invalid objects (means address ranges within the memory pool that were not
  147227             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  147228             :  * distinguish valid from invalid objects! 
  147229             :  */
  147230             : unsigned long
  147231           5 : SgUnaryAddOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  147232             :    {
  147233           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  147234           5 :      SgUnaryAddOp* pointer = NULL;
  147235           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  147236           5 :      std::vector < unsigned char* > :: const_iterator block;
  147237           5 :      for ( block = SgUnaryAddOp::pools.begin(); block != SgUnaryAddOp::pools.end() ; ++block )
  147238             :         {
  147239           0 :           pointer = (SgUnaryAddOp*)(*block);
  147240           0 :           for (unsigned i = 0; i < SgUnaryAddOp::pool_size; ++i )
  147241             :              {
  147242             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  147243             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  147244             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  147245             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  147246             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  147247             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  147248             :             // properly; so this will have to be checked next.
  147249             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  147250             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  147251           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  147252             :                   {
  147253           0 :                     pointer[i].set_freepointer((SgUnaryAddOp*)(globalIndex));
  147254           0 :                     globalIndex++;
  147255             :                   }
  147256             :                else
  147257             :                   {
  147258           0 :                     pointer[i].set_freepointer(NULL);
  147259             :                   }
  147260             :               }
  147261             :         }
  147262           5 :      return globalIndex;
  147263             :    }
  147264             : 
  147265             : //############################################################################
  147266             : // JH (01/14/2006)
  147267             : void
  147268           5 : SgUnaryAddOp::resetValidFreepointers( )
  147269             :    {
  147270           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  147271           5 :      SgUnaryAddOp* pointer = NULL;
  147272           5 :      std::vector < unsigned char* > :: const_iterator block;
  147273           5 :      SgUnaryAddOp* pointerOfLinkedList = NULL;
  147274           5 :      for ( block = SgUnaryAddOp::pools.begin(); block != SgUnaryAddOp::pools.end() ; ++block )
  147275             :         {
  147276           0 :           pointer = (SgUnaryAddOp*)(*block);
  147277           0 :           for (unsigned i = 0; i < SgUnaryAddOp::pool_size; ++i )
  147278             :              {
  147279             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  147280             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  147281             :             // memory blocks!.
  147282           0 :                if ( pointer[i].get_freepointer() != NULL )
  147283             :                   {
  147284           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  147285             :                   }
  147286             :                else
  147287             :                   {
  147288           0 :                     if ( pointerOfLinkedList == NULL )
  147289             :                        {
  147290           0 :                          SgUnaryAddOp::next_node = &(pointer[i]);
  147291             :                        }
  147292             :                     else
  147293             :                        {
  147294             :                       // printf ("In SgUnaryAddOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  147295           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  147296             :                        }
  147297             :                     pointerOfLinkedList = &(pointer[i]);
  147298             :                   }
  147299             :               }
  147300             :         }
  147301             : 
  147302           5 :      if ( pointerOfLinkedList != NULL )
  147303             :         {
  147304             :        // printf ("In SgUnaryAddOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  147305           0 :           pointerOfLinkedList->set_freepointer(NULL);
  147306             :        // DQ (6/6/2010): Temporary debugging...
  147307             :        //   ROSE_ASSERT(false);
  147308             :         }
  147309             : 
  147310           5 :      return ;
  147311             :    }
  147312             : 
  147313             : //############################################################################
  147314             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  147315             :  * within the memory pool and resets the freepointers, in order to achieve a 
  147316             :  * linked list, that has no jumps and starts at the beginning! This function 
  147317             :  * does not extend the memory pool, since we do not delete any memory blocks,
  147318             :  * but delete the valid objects.  
  147319             :  */
  147320             : void
  147321           0 : SgUnaryAddOp::clearMemoryPool( )
  147322             :    {
  147323             :   // printf ("Inside of SgUnaryAddOp::clearMemoryPool() \n");
  147324             : 
  147325           0 :      SgUnaryAddOp* pointer = NULL, *tempPointer = NULL;
  147326           0 :      std::vector < unsigned char* > :: const_iterator block;
  147327           0 :      if ( SgUnaryAddOp::pools.empty() == false )
  147328             :         {
  147329           0 :           block = SgUnaryAddOp::pools.begin() ;
  147330           0 :           SgUnaryAddOp::next_node = (SgUnaryAddOp*) (*block);
  147331             : 
  147332           0 :           while ( block != SgUnaryAddOp::pools.end() )
  147333             :              {
  147334           0 :                pointer = (SgUnaryAddOp*) (*block);
  147335           0 :                if ( tempPointer != NULL )
  147336             :                   {
  147337           0 :                     tempPointer->set_freepointer(pointer);
  147338             :                   }
  147339           0 :                for (unsigned i = 0; i < SgUnaryAddOp::pool_size - 1; ++i)
  147340             :                   {
  147341           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  147342             :                   }
  147343           0 :                 pointer[SgUnaryAddOp::pool_size-1].set_freepointer(NULL);
  147344           0 :                 tempPointer = &(pointer[SgUnaryAddOp::pool_size-1]);
  147345           0 :                 ++block;
  147346             :              }
  147347             :         }
  147348           0 :    }
  147349             : 
  147350           5 : void SgUnaryAddOp::deleteMemoryPool() {
  147351           5 :   for (auto p: SgUnaryAddOp::pools) {
  147352           0 :     ROSE_FREE(p);
  147353             :   }
  147354           5 :   SgUnaryAddOp::next_node = nullptr;
  147355           5 :   SgUnaryAddOp::pools.clear();
  147356           5 : }
  147357             : 
  147358             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  147359             : //                 reading multiple binary files to for a single AST.
  147360             : /////////// new version ////////////////////////////////
  147361             : //############################################################################
  147362             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  147363             : void
  147364           2 : SgUnaryAddOp::extendMemoryPoolForFileIO( )
  147365             :   {
  147366           2 :     size_t blockIndex = SgUnaryAddOp::pools.size();
  147367           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnaryAddOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnaryAddOp);
  147368             : 
  147369           2 :     while ( (blockIndex * SgUnaryAddOp::pool_size) < newPoolSize)
  147370             :       {
  147371             : #if ROSE_ALLOC_TRACE
  147372             :         if (blockIndex > 0) {
  147373             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnaryAddOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnaryAddOp) = %" PRIuPTR " SgUnaryAddOp::pool_size = %d \n",
  147374             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnaryAddOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnaryAddOp),SgUnaryAddOp::pool_size);
  147375             :         }
  147376             : #endif
  147377             : 
  147378           0 :         SgUnaryAddOp * pointer = (SgUnaryAddOp*) ROSE_MALLOC ( SgUnaryAddOp::pool_size * sizeof(SgUnaryAddOp) );
  147379           0 :         assert( pointer != NULL );
  147380             : #if ROSE_ALLOC_MEMSET == 1
  147381             :         memset(pointer, 0x00, SgUnaryAddOp::pool_size * sizeof(SgUnaryAddOp));
  147382             : #elif ROSE_ALLOC_MEMSET == 2
  147383             :         memset(pointer, 0xCC, SgUnaryAddOp::pool_size * sizeof(SgUnaryAddOp));
  147384             : #endif
  147385           0 :         SgUnaryAddOp::pools.push_back( (unsigned char*)(pointer) );
  147386           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnaryAddOp::pool_size * sizeof(SgUnaryAddOp), V_SgUnaryAddOp ) );
  147387             : 
  147388           0 :         if ( SgUnaryAddOp::next_node != NULL ) {
  147389           0 :           if ( blockIndex > 0 ) {
  147390           0 :             SgUnaryAddOp * blkptr = (SgUnaryAddOp*)(SgUnaryAddOp::pools[blockIndex-1]);
  147391           0 :             blkptr[ SgUnaryAddOp::pool_size - 1 ].set_freepointer(pointer);
  147392             :           }
  147393             :         } else {
  147394           0 :           SgUnaryAddOp::next_node = pointer;
  147395             :         }
  147396             : 
  147397           0 :         for (unsigned i = 0; i < SgUnaryAddOp::pool_size-1; ++i)
  147398             :            {
  147399           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  147400             :            }
  147401           0 :         pointer[ SgUnaryAddOp::pool_size -1 ].set_freepointer(NULL);
  147402             : 
  147403           0 :         blockIndex++;
  147404             :       }
  147405           2 :   }
  147406             : 
  147407             : //############################################################################
  147408             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  147409             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  147410             :  * not compressed. However, that stuff is not yet implemented! 
  147411             :  */
  147412             : unsigned long
  147413           0 : SgUnaryAddOp::getNumberOfLastValidPointer()
  147414             :    {
  147415           0 :       SgUnaryAddOp* testPointer = (SgUnaryAddOp*)(SgUnaryAddOp::pools.back());
  147416           0 :       unsigned long localIndex = SgUnaryAddOp::pool_size - 1;
  147417           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  147418             :          {
  147419           0 :            localIndex--;
  147420             :          }
  147421           0 :       return (localIndex + SgUnaryAddOp::pool_size * (SgUnaryAddOp::pools.size()-1));
  147422             :    }
  147423             : 
  147424             : //############################################################################
  147425             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  147426             :  * memory pool and initializes the data member in class SgUnaryAddOpStroageClass
  147427             :  * from its counterpart of SgUnaryAddOp. The return value is just for checking, 
  147428             :  * that the whole StorageClassArray is initialized!
  147429             :  */
  147430             : unsigned long
  147431           0 : SgUnaryAddOp::initializeStorageClassArray( SgUnaryAddOpStorageClass *storageArray )
  147432             :    {
  147433           0 :      unsigned long storageCounter = 0;
  147434           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnaryAddOp::pools.begin();
  147435           0 :      SgUnaryAddOp* pointer = NULL;
  147436           0 :      while ( block != SgUnaryAddOp::pools.end() ) {
  147437           0 :           pointer = (SgUnaryAddOp*) (*block);
  147438           0 :           for ( unsigned i = 0; i < SgUnaryAddOp::pool_size; ++i ) {
  147439           0 :                if ( pointer->get_freepointer() != NULL ) {
  147440           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  147441           0 :                  storageArray++;
  147442           0 :                  storageCounter++;
  147443             :                }
  147444           0 :                pointer++;
  147445             :              }
  147446           0 :            block++;
  147447             :         }
  147448           0 :      return storageCounter;
  147449             :    }
  147450             : 
  147451             : /* #line 147452 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  147452             : 
  147453             : 
  147454             : 
  147455             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  147456             : 
  147457             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  147458             : 
  147459             : //############################################################################
  147460             : /* JH (02/02/2006) Constructor of the IR node SgNotOp that takes its 
  147461             :  * corresponding StorageClass as parameter
  147462             :  */
  147463         220 : SgNotOp :: SgNotOp ( const SgNotOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  147464             :    {
  147465             : 
  147466             : 
  147467             : /* #line 147468 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  147468             : 
  147469         220 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  147470             : 
  147471             : 
  147472             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  147473             : 
  147474             : 
  147475         220 :    }
  147476             : 
  147477             : //############################################################################
  147478             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  147479             :  * within the working AST. 
  147480             :  */
  147481        1100 : SgNotOp * SgNotOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  147482        1100 :      SgNotOp* returnPointer = NULL;
  147483        1100 :      if ( globalIndex != 0 )
  147484             :         {
  147485             : 
  147486             : #if FILE_IO_EXTRA_CHECK
  147487        1100 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNotOp ) ) <= globalIndex ) ;
  147488        1100 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNotOp + 1 ) ) );
  147489             : #endif
  147490        1100 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNotOp )  
  147491        1100 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNotOp );
  147492        1100 :           unsigned long positionInPool = localIndex % SgNotOp::pool_size;
  147493        1100 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNotOp::pool_size;
  147494             : 
  147495             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  147496             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  147497             : 
  147498        1100 :           returnPointer = &( ( (SgNotOp*)(SgNotOp::pools[memoryBlock]) ) [positionInPool]) ;
  147499             : 
  147500        1100 :           ROSE_ASSERT( returnPointer != NULL ) ;
  147501             :         }
  147502        1100 :      return returnPointer ;
  147503             :    }
  147504             : 
  147505             : //############################################################################
  147506             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  147507             :   for the AST with the index astIndex
  147508             : */
  147509           0 : SgNotOp * SgNotOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  147510           0 :      SgNotOp* returnPointer = NULL;
  147511           0 :      if ( globalIndex != 0 )
  147512             :         {
  147513             : 
  147514             : #if FILE_IO_EXTRA_CHECK
  147515           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNotOp ) ) <= globalIndex ) ;
  147516           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNotOp + 1 ) ) );
  147517             : #endif
  147518           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNotOp )
  147519           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNotOp );
  147520           0 :           unsigned long positionInPool = localIndex % SgNotOp::pool_size ;
  147521           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNotOp::pool_size ;
  147522             : 
  147523             : #if FILE_IO_EXTRA_CHECK
  147524             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  147525             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  147526             : #endif
  147527             : 
  147528           0 :           returnPointer = &( ( (SgNotOp*)(SgNotOp::pools[memoryBlock]) ) [positionInPool]) ;
  147529             : 
  147530             : #if FILE_IO_EXTRA_CHECK
  147531           0 :           assert ( returnPointer != NULL ) ;
  147532             : #endif
  147533             :         }
  147534           0 :      return returnPointer ;
  147535             :    }
  147536             : 
  147537             : //############################################################################
  147538             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  147539             :  * pool size! We set for every valid object in the memory pool the freepointer
  147540             :  * to the global index and increase the global index afterwards. For all the 
  147541             :  * invalid objects (means address ranges within the memory pool that were not
  147542             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  147543             :  * distinguish valid from invalid objects! 
  147544             :  */
  147545             : unsigned long
  147546           5 : SgNotOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  147547             :    {
  147548           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  147549           5 :      SgNotOp* pointer = NULL;
  147550           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  147551           5 :      std::vector < unsigned char* > :: const_iterator block;
  147552           6 :      for ( block = SgNotOp::pools.begin(); block != SgNotOp::pools.end() ; ++block )
  147553             :         {
  147554           1 :           pointer = (SgNotOp*)(*block);
  147555        2001 :           for (unsigned i = 0; i < SgNotOp::pool_size; ++i )
  147556             :              {
  147557             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  147558             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  147559             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  147560             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  147561             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  147562             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  147563             :             // properly; so this will have to be checked next.
  147564             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  147565             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  147566        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  147567             :                   {
  147568         220 :                     pointer[i].set_freepointer((SgNotOp*)(globalIndex));
  147569         220 :                     globalIndex++;
  147570             :                   }
  147571             :                else
  147572             :                   {
  147573        1780 :                     pointer[i].set_freepointer(NULL);
  147574             :                   }
  147575             :               }
  147576             :         }
  147577           5 :      return globalIndex;
  147578             :    }
  147579             : 
  147580             : //############################################################################
  147581             : // JH (01/14/2006)
  147582             : void
  147583           5 : SgNotOp::resetValidFreepointers( )
  147584             :    {
  147585           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  147586           5 :      SgNotOp* pointer = NULL;
  147587           5 :      std::vector < unsigned char* > :: const_iterator block;
  147588           5 :      SgNotOp* pointerOfLinkedList = NULL;
  147589           6 :      for ( block = SgNotOp::pools.begin(); block != SgNotOp::pools.end() ; ++block )
  147590             :         {
  147591           1 :           pointer = (SgNotOp*)(*block);
  147592        2001 :           for (unsigned i = 0; i < SgNotOp::pool_size; ++i )
  147593             :              {
  147594             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  147595             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  147596             :             // memory blocks!.
  147597        2000 :                if ( pointer[i].get_freepointer() != NULL )
  147598             :                   {
  147599         220 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  147600             :                   }
  147601             :                else
  147602             :                   {
  147603        1780 :                     if ( pointerOfLinkedList == NULL )
  147604             :                        {
  147605           1 :                          SgNotOp::next_node = &(pointer[i]);
  147606             :                        }
  147607             :                     else
  147608             :                        {
  147609             :                       // printf ("In SgNotOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  147610        1779 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  147611             :                        }
  147612             :                     pointerOfLinkedList = &(pointer[i]);
  147613             :                   }
  147614             :               }
  147615             :         }
  147616             : 
  147617           5 :      if ( pointerOfLinkedList != NULL )
  147618             :         {
  147619             :        // printf ("In SgNotOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  147620           1 :           pointerOfLinkedList->set_freepointer(NULL);
  147621             :        // DQ (6/6/2010): Temporary debugging...
  147622             :        //   ROSE_ASSERT(false);
  147623             :         }
  147624             : 
  147625           5 :      return ;
  147626             :    }
  147627             : 
  147628             : //############################################################################
  147629             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  147630             :  * within the memory pool and resets the freepointers, in order to achieve a 
  147631             :  * linked list, that has no jumps and starts at the beginning! This function 
  147632             :  * does not extend the memory pool, since we do not delete any memory blocks,
  147633             :  * but delete the valid objects.  
  147634             :  */
  147635             : void
  147636           0 : SgNotOp::clearMemoryPool( )
  147637             :    {
  147638             :   // printf ("Inside of SgNotOp::clearMemoryPool() \n");
  147639             : 
  147640           0 :      SgNotOp* pointer = NULL, *tempPointer = NULL;
  147641           0 :      std::vector < unsigned char* > :: const_iterator block;
  147642           0 :      if ( SgNotOp::pools.empty() == false )
  147643             :         {
  147644           0 :           block = SgNotOp::pools.begin() ;
  147645           0 :           SgNotOp::next_node = (SgNotOp*) (*block);
  147646             : 
  147647           0 :           while ( block != SgNotOp::pools.end() )
  147648             :              {
  147649           0 :                pointer = (SgNotOp*) (*block);
  147650           0 :                if ( tempPointer != NULL )
  147651             :                   {
  147652           0 :                     tempPointer->set_freepointer(pointer);
  147653             :                   }
  147654           0 :                for (unsigned i = 0; i < SgNotOp::pool_size - 1; ++i)
  147655             :                   {
  147656           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  147657             :                   }
  147658           0 :                 pointer[SgNotOp::pool_size-1].set_freepointer(NULL);
  147659           0 :                 tempPointer = &(pointer[SgNotOp::pool_size-1]);
  147660           0 :                 ++block;
  147661             :              }
  147662             :         }
  147663           0 :    }
  147664             : 
  147665           5 : void SgNotOp::deleteMemoryPool() {
  147666           7 :   for (auto p: SgNotOp::pools) {
  147667           2 :     ROSE_FREE(p);
  147668             :   }
  147669           5 :   SgNotOp::next_node = nullptr;
  147670           5 :   SgNotOp::pools.clear();
  147671           5 : }
  147672             : 
  147673             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  147674             : //                 reading multiple binary files to for a single AST.
  147675             : /////////// new version ////////////////////////////////
  147676             : //############################################################################
  147677             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  147678             : void
  147679           2 : SgNotOp::extendMemoryPoolForFileIO( )
  147680             :   {
  147681           2 :     size_t blockIndex = SgNotOp::pools.size();
  147682           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNotOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNotOp);
  147683             : 
  147684           3 :     while ( (blockIndex * SgNotOp::pool_size) < newPoolSize)
  147685             :       {
  147686             : #if ROSE_ALLOC_TRACE
  147687             :         if (blockIndex > 0) {
  147688             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNotOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNotOp) = %" PRIuPTR " SgNotOp::pool_size = %d \n",
  147689             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNotOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNotOp),SgNotOp::pool_size);
  147690             :         }
  147691             : #endif
  147692             : 
  147693           1 :         SgNotOp * pointer = (SgNotOp*) ROSE_MALLOC ( SgNotOp::pool_size * sizeof(SgNotOp) );
  147694           1 :         assert( pointer != NULL );
  147695             : #if ROSE_ALLOC_MEMSET == 1
  147696             :         memset(pointer, 0x00, SgNotOp::pool_size * sizeof(SgNotOp));
  147697             : #elif ROSE_ALLOC_MEMSET == 2
  147698             :         memset(pointer, 0xCC, SgNotOp::pool_size * sizeof(SgNotOp));
  147699             : #endif
  147700           1 :         SgNotOp::pools.push_back( (unsigned char*)(pointer) );
  147701           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNotOp::pool_size * sizeof(SgNotOp), V_SgNotOp ) );
  147702             : 
  147703           1 :         if ( SgNotOp::next_node != NULL ) {
  147704           0 :           if ( blockIndex > 0 ) {
  147705           0 :             SgNotOp * blkptr = (SgNotOp*)(SgNotOp::pools[blockIndex-1]);
  147706           0 :             blkptr[ SgNotOp::pool_size - 1 ].set_freepointer(pointer);
  147707             :           }
  147708             :         } else {
  147709           1 :           SgNotOp::next_node = pointer;
  147710             :         }
  147711             : 
  147712        2000 :         for (unsigned i = 0; i < SgNotOp::pool_size-1; ++i)
  147713             :            {
  147714        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  147715             :            }
  147716           1 :         pointer[ SgNotOp::pool_size -1 ].set_freepointer(NULL);
  147717             : 
  147718           1 :         blockIndex++;
  147719             :       }
  147720           2 :   }
  147721             : 
  147722             : //############################################################################
  147723             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  147724             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  147725             :  * not compressed. However, that stuff is not yet implemented! 
  147726             :  */
  147727             : unsigned long
  147728           0 : SgNotOp::getNumberOfLastValidPointer()
  147729             :    {
  147730           0 :       SgNotOp* testPointer = (SgNotOp*)(SgNotOp::pools.back());
  147731           0 :       unsigned long localIndex = SgNotOp::pool_size - 1;
  147732           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  147733             :          {
  147734           0 :            localIndex--;
  147735             :          }
  147736           0 :       return (localIndex + SgNotOp::pool_size * (SgNotOp::pools.size()-1));
  147737             :    }
  147738             : 
  147739             : //############################################################################
  147740             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  147741             :  * memory pool and initializes the data member in class SgNotOpStroageClass
  147742             :  * from its counterpart of SgNotOp. The return value is just for checking, 
  147743             :  * that the whole StorageClassArray is initialized!
  147744             :  */
  147745             : unsigned long
  147746           1 : SgNotOp::initializeStorageClassArray( SgNotOpStorageClass *storageArray )
  147747             :    {
  147748           1 :      unsigned long storageCounter = 0;
  147749           1 :      std::vector < unsigned char* > :: const_iterator block = SgNotOp::pools.begin();
  147750           1 :      SgNotOp* pointer = NULL;
  147751           2 :      while ( block != SgNotOp::pools.end() ) {
  147752           1 :           pointer = (SgNotOp*) (*block);
  147753        2001 :           for ( unsigned i = 0; i < SgNotOp::pool_size; ++i ) {
  147754        2000 :                if ( pointer->get_freepointer() != NULL ) {
  147755         220 :                  storageArray->pickOutIRNodeData (pointer) ;
  147756         220 :                  storageArray++;
  147757         220 :                  storageCounter++;
  147758             :                }
  147759        2000 :                pointer++;
  147760             :              }
  147761           1 :            block++;
  147762             :         }
  147763           1 :      return storageCounter;
  147764             :    }
  147765             : 
  147766             : /* #line 147767 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  147767             : 
  147768             : 
  147769             : 
  147770             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  147771             : 
  147772             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  147773             : 
  147774             : //############################################################################
  147775             : /* JH (02/02/2006) Constructor of the IR node SgPointerDerefExp that takes its 
  147776             :  * corresponding StorageClass as parameter
  147777             :  */
  147778         384 : SgPointerDerefExp :: SgPointerDerefExp ( const SgPointerDerefExpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  147779             :    {
  147780             : 
  147781             : 
  147782             : /* #line 147783 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  147783             : 
  147784         384 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  147785             : 
  147786             : 
  147787             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  147788             : 
  147789             : 
  147790         384 :    }
  147791             : 
  147792             : //############################################################################
  147793             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  147794             :  * within the working AST. 
  147795             :  */
  147796        1920 : SgPointerDerefExp * SgPointerDerefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  147797        1920 :      SgPointerDerefExp* returnPointer = NULL;
  147798        1920 :      if ( globalIndex != 0 )
  147799             :         {
  147800             : 
  147801             : #if FILE_IO_EXTRA_CHECK
  147802        1920 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPointerDerefExp ) ) <= globalIndex ) ;
  147803        1920 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPointerDerefExp + 1 ) ) );
  147804             : #endif
  147805        1920 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPointerDerefExp )  
  147806        1920 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPointerDerefExp );
  147807        1920 :           unsigned long positionInPool = localIndex % SgPointerDerefExp::pool_size;
  147808        1920 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPointerDerefExp::pool_size;
  147809             : 
  147810             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  147811             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  147812             : 
  147813        1920 :           returnPointer = &( ( (SgPointerDerefExp*)(SgPointerDerefExp::pools[memoryBlock]) ) [positionInPool]) ;
  147814             : 
  147815        1920 :           ROSE_ASSERT( returnPointer != NULL ) ;
  147816             :         }
  147817        1920 :      return returnPointer ;
  147818             :    }
  147819             : 
  147820             : //############################################################################
  147821             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  147822             :   for the AST with the index astIndex
  147823             : */
  147824           0 : SgPointerDerefExp * SgPointerDerefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  147825           0 :      SgPointerDerefExp* returnPointer = NULL;
  147826           0 :      if ( globalIndex != 0 )
  147827             :         {
  147828             : 
  147829             : #if FILE_IO_EXTRA_CHECK
  147830           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPointerDerefExp ) ) <= globalIndex ) ;
  147831           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPointerDerefExp + 1 ) ) );
  147832             : #endif
  147833           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPointerDerefExp )
  147834           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPointerDerefExp );
  147835           0 :           unsigned long positionInPool = localIndex % SgPointerDerefExp::pool_size ;
  147836           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPointerDerefExp::pool_size ;
  147837             : 
  147838             : #if FILE_IO_EXTRA_CHECK
  147839             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  147840             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  147841             : #endif
  147842             : 
  147843           0 :           returnPointer = &( ( (SgPointerDerefExp*)(SgPointerDerefExp::pools[memoryBlock]) ) [positionInPool]) ;
  147844             : 
  147845             : #if FILE_IO_EXTRA_CHECK
  147846           0 :           assert ( returnPointer != NULL ) ;
  147847             : #endif
  147848             :         }
  147849           0 :      return returnPointer ;
  147850             :    }
  147851             : 
  147852             : //############################################################################
  147853             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  147854             :  * pool size! We set for every valid object in the memory pool the freepointer
  147855             :  * to the global index and increase the global index afterwards. For all the 
  147856             :  * invalid objects (means address ranges within the memory pool that were not
  147857             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  147858             :  * distinguish valid from invalid objects! 
  147859             :  */
  147860             : unsigned long
  147861           5 : SgPointerDerefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  147862             :    {
  147863           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  147864           5 :      SgPointerDerefExp* pointer = NULL;
  147865           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  147866           5 :      std::vector < unsigned char* > :: const_iterator block;
  147867           6 :      for ( block = SgPointerDerefExp::pools.begin(); block != SgPointerDerefExp::pools.end() ; ++block )
  147868             :         {
  147869           1 :           pointer = (SgPointerDerefExp*)(*block);
  147870        2001 :           for (unsigned i = 0; i < SgPointerDerefExp::pool_size; ++i )
  147871             :              {
  147872             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  147873             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  147874             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  147875             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  147876             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  147877             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  147878             :             // properly; so this will have to be checked next.
  147879             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  147880             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  147881        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  147882             :                   {
  147883         384 :                     pointer[i].set_freepointer((SgPointerDerefExp*)(globalIndex));
  147884         384 :                     globalIndex++;
  147885             :                   }
  147886             :                else
  147887             :                   {
  147888        1616 :                     pointer[i].set_freepointer(NULL);
  147889             :                   }
  147890             :               }
  147891             :         }
  147892           5 :      return globalIndex;
  147893             :    }
  147894             : 
  147895             : //############################################################################
  147896             : // JH (01/14/2006)
  147897             : void
  147898           5 : SgPointerDerefExp::resetValidFreepointers( )
  147899             :    {
  147900           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  147901           5 :      SgPointerDerefExp* pointer = NULL;
  147902           5 :      std::vector < unsigned char* > :: const_iterator block;
  147903           5 :      SgPointerDerefExp* pointerOfLinkedList = NULL;
  147904           6 :      for ( block = SgPointerDerefExp::pools.begin(); block != SgPointerDerefExp::pools.end() ; ++block )
  147905             :         {
  147906           1 :           pointer = (SgPointerDerefExp*)(*block);
  147907        2001 :           for (unsigned i = 0; i < SgPointerDerefExp::pool_size; ++i )
  147908             :              {
  147909             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  147910             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  147911             :             // memory blocks!.
  147912        2000 :                if ( pointer[i].get_freepointer() != NULL )
  147913             :                   {
  147914         384 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  147915             :                   }
  147916             :                else
  147917             :                   {
  147918        1616 :                     if ( pointerOfLinkedList == NULL )
  147919             :                        {
  147920           1 :                          SgPointerDerefExp::next_node = &(pointer[i]);
  147921             :                        }
  147922             :                     else
  147923             :                        {
  147924             :                       // printf ("In SgPointerDerefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  147925        1615 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  147926             :                        }
  147927             :                     pointerOfLinkedList = &(pointer[i]);
  147928             :                   }
  147929             :               }
  147930             :         }
  147931             : 
  147932           5 :      if ( pointerOfLinkedList != NULL )
  147933             :         {
  147934             :        // printf ("In SgPointerDerefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  147935           1 :           pointerOfLinkedList->set_freepointer(NULL);
  147936             :        // DQ (6/6/2010): Temporary debugging...
  147937             :        //   ROSE_ASSERT(false);
  147938             :         }
  147939             : 
  147940           5 :      return ;
  147941             :    }
  147942             : 
  147943             : //############################################################################
  147944             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  147945             :  * within the memory pool and resets the freepointers, in order to achieve a 
  147946             :  * linked list, that has no jumps and starts at the beginning! This function 
  147947             :  * does not extend the memory pool, since we do not delete any memory blocks,
  147948             :  * but delete the valid objects.  
  147949             :  */
  147950             : void
  147951           0 : SgPointerDerefExp::clearMemoryPool( )
  147952             :    {
  147953             :   // printf ("Inside of SgPointerDerefExp::clearMemoryPool() \n");
  147954             : 
  147955           0 :      SgPointerDerefExp* pointer = NULL, *tempPointer = NULL;
  147956           0 :      std::vector < unsigned char* > :: const_iterator block;
  147957           0 :      if ( SgPointerDerefExp::pools.empty() == false )
  147958             :         {
  147959           0 :           block = SgPointerDerefExp::pools.begin() ;
  147960           0 :           SgPointerDerefExp::next_node = (SgPointerDerefExp*) (*block);
  147961             : 
  147962           0 :           while ( block != SgPointerDerefExp::pools.end() )
  147963             :              {
  147964           0 :                pointer = (SgPointerDerefExp*) (*block);
  147965           0 :                if ( tempPointer != NULL )
  147966             :                   {
  147967           0 :                     tempPointer->set_freepointer(pointer);
  147968             :                   }
  147969           0 :                for (unsigned i = 0; i < SgPointerDerefExp::pool_size - 1; ++i)
  147970             :                   {
  147971           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  147972             :                   }
  147973           0 :                 pointer[SgPointerDerefExp::pool_size-1].set_freepointer(NULL);
  147974           0 :                 tempPointer = &(pointer[SgPointerDerefExp::pool_size-1]);
  147975           0 :                 ++block;
  147976             :              }
  147977             :         }
  147978           0 :    }
  147979             : 
  147980           5 : void SgPointerDerefExp::deleteMemoryPool() {
  147981           7 :   for (auto p: SgPointerDerefExp::pools) {
  147982           2 :     ROSE_FREE(p);
  147983             :   }
  147984           5 :   SgPointerDerefExp::next_node = nullptr;
  147985           5 :   SgPointerDerefExp::pools.clear();
  147986           5 : }
  147987             : 
  147988             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  147989             : //                 reading multiple binary files to for a single AST.
  147990             : /////////// new version ////////////////////////////////
  147991             : //############################################################################
  147992             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  147993             : void
  147994           2 : SgPointerDerefExp::extendMemoryPoolForFileIO( )
  147995             :   {
  147996           2 :     size_t blockIndex = SgPointerDerefExp::pools.size();
  147997           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerDerefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerDerefExp);
  147998             : 
  147999           3 :     while ( (blockIndex * SgPointerDerefExp::pool_size) < newPoolSize)
  148000             :       {
  148001             : #if ROSE_ALLOC_TRACE
  148002             :         if (blockIndex > 0) {
  148003             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerDerefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerDerefExp) = %" PRIuPTR " SgPointerDerefExp::pool_size = %d \n",
  148004             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerDerefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerDerefExp),SgPointerDerefExp::pool_size);
  148005             :         }
  148006             : #endif
  148007             : 
  148008           1 :         SgPointerDerefExp * pointer = (SgPointerDerefExp*) ROSE_MALLOC ( SgPointerDerefExp::pool_size * sizeof(SgPointerDerefExp) );
  148009           1 :         assert( pointer != NULL );
  148010             : #if ROSE_ALLOC_MEMSET == 1
  148011             :         memset(pointer, 0x00, SgPointerDerefExp::pool_size * sizeof(SgPointerDerefExp));
  148012             : #elif ROSE_ALLOC_MEMSET == 2
  148013             :         memset(pointer, 0xCC, SgPointerDerefExp::pool_size * sizeof(SgPointerDerefExp));
  148014             : #endif
  148015           1 :         SgPointerDerefExp::pools.push_back( (unsigned char*)(pointer) );
  148016           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPointerDerefExp::pool_size * sizeof(SgPointerDerefExp), V_SgPointerDerefExp ) );
  148017             : 
  148018           1 :         if ( SgPointerDerefExp::next_node != NULL ) {
  148019           0 :           if ( blockIndex > 0 ) {
  148020           0 :             SgPointerDerefExp * blkptr = (SgPointerDerefExp*)(SgPointerDerefExp::pools[blockIndex-1]);
  148021           0 :             blkptr[ SgPointerDerefExp::pool_size - 1 ].set_freepointer(pointer);
  148022             :           }
  148023             :         } else {
  148024           1 :           SgPointerDerefExp::next_node = pointer;
  148025             :         }
  148026             : 
  148027        2000 :         for (unsigned i = 0; i < SgPointerDerefExp::pool_size-1; ++i)
  148028             :            {
  148029        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  148030             :            }
  148031           1 :         pointer[ SgPointerDerefExp::pool_size -1 ].set_freepointer(NULL);
  148032             : 
  148033           1 :         blockIndex++;
  148034             :       }
  148035           2 :   }
  148036             : 
  148037             : //############################################################################
  148038             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  148039             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  148040             :  * not compressed. However, that stuff is not yet implemented! 
  148041             :  */
  148042             : unsigned long
  148043           0 : SgPointerDerefExp::getNumberOfLastValidPointer()
  148044             :    {
  148045           0 :       SgPointerDerefExp* testPointer = (SgPointerDerefExp*)(SgPointerDerefExp::pools.back());
  148046           0 :       unsigned long localIndex = SgPointerDerefExp::pool_size - 1;
  148047           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  148048             :          {
  148049           0 :            localIndex--;
  148050             :          }
  148051           0 :       return (localIndex + SgPointerDerefExp::pool_size * (SgPointerDerefExp::pools.size()-1));
  148052             :    }
  148053             : 
  148054             : //############################################################################
  148055             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  148056             :  * memory pool and initializes the data member in class SgPointerDerefExpStroageClass
  148057             :  * from its counterpart of SgPointerDerefExp. The return value is just for checking, 
  148058             :  * that the whole StorageClassArray is initialized!
  148059             :  */
  148060             : unsigned long
  148061           1 : SgPointerDerefExp::initializeStorageClassArray( SgPointerDerefExpStorageClass *storageArray )
  148062             :    {
  148063           1 :      unsigned long storageCounter = 0;
  148064           1 :      std::vector < unsigned char* > :: const_iterator block = SgPointerDerefExp::pools.begin();
  148065           1 :      SgPointerDerefExp* pointer = NULL;
  148066           2 :      while ( block != SgPointerDerefExp::pools.end() ) {
  148067           1 :           pointer = (SgPointerDerefExp*) (*block);
  148068        2001 :           for ( unsigned i = 0; i < SgPointerDerefExp::pool_size; ++i ) {
  148069        2000 :                if ( pointer->get_freepointer() != NULL ) {
  148070         384 :                  storageArray->pickOutIRNodeData (pointer) ;
  148071         384 :                  storageArray++;
  148072         384 :                  storageCounter++;
  148073             :                }
  148074        2000 :                pointer++;
  148075             :              }
  148076           1 :            block++;
  148077             :         }
  148078           1 :      return storageCounter;
  148079             :    }
  148080             : 
  148081             : /* #line 148082 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  148082             : 
  148083             : 
  148084             : 
  148085             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  148086             : 
  148087             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  148088             : 
  148089             : //############################################################################
  148090             : /* JH (02/02/2006) Constructor of the IR node SgAddressOfOp that takes its 
  148091             :  * corresponding StorageClass as parameter
  148092             :  */
  148093          84 : SgAddressOfOp :: SgAddressOfOp ( const SgAddressOfOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  148094             :    {
  148095             : 
  148096             : 
  148097             : /* #line 148098 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  148098             : 
  148099          84 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  148100          84 :      p_originalExpressionTree =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_originalExpressionTree) );
  148101             : 
  148102             : 
  148103             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  148104             : 
  148105             : 
  148106          84 :    }
  148107             : 
  148108             : //############################################################################
  148109             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  148110             :  * within the working AST. 
  148111             :  */
  148112         420 : SgAddressOfOp * SgAddressOfOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  148113         420 :      SgAddressOfOp* returnPointer = NULL;
  148114         420 :      if ( globalIndex != 0 )
  148115             :         {
  148116             : 
  148117             : #if FILE_IO_EXTRA_CHECK
  148118         420 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAddressOfOp ) ) <= globalIndex ) ;
  148119         420 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAddressOfOp + 1 ) ) );
  148120             : #endif
  148121         420 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAddressOfOp )  
  148122         420 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAddressOfOp );
  148123         420 :           unsigned long positionInPool = localIndex % SgAddressOfOp::pool_size;
  148124         420 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAddressOfOp::pool_size;
  148125             : 
  148126             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  148127             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  148128             : 
  148129         420 :           returnPointer = &( ( (SgAddressOfOp*)(SgAddressOfOp::pools[memoryBlock]) ) [positionInPool]) ;
  148130             : 
  148131         420 :           ROSE_ASSERT( returnPointer != NULL ) ;
  148132             :         }
  148133         420 :      return returnPointer ;
  148134             :    }
  148135             : 
  148136             : //############################################################################
  148137             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  148138             :   for the AST with the index astIndex
  148139             : */
  148140           0 : SgAddressOfOp * SgAddressOfOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  148141           0 :      SgAddressOfOp* returnPointer = NULL;
  148142           0 :      if ( globalIndex != 0 )
  148143             :         {
  148144             : 
  148145             : #if FILE_IO_EXTRA_CHECK
  148146           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAddressOfOp ) ) <= globalIndex ) ;
  148147           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAddressOfOp + 1 ) ) );
  148148             : #endif
  148149           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAddressOfOp )
  148150           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAddressOfOp );
  148151           0 :           unsigned long positionInPool = localIndex % SgAddressOfOp::pool_size ;
  148152           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAddressOfOp::pool_size ;
  148153             : 
  148154             : #if FILE_IO_EXTRA_CHECK
  148155             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  148156             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  148157             : #endif
  148158             : 
  148159           0 :           returnPointer = &( ( (SgAddressOfOp*)(SgAddressOfOp::pools[memoryBlock]) ) [positionInPool]) ;
  148160             : 
  148161             : #if FILE_IO_EXTRA_CHECK
  148162           0 :           assert ( returnPointer != NULL ) ;
  148163             : #endif
  148164             :         }
  148165           0 :      return returnPointer ;
  148166             :    }
  148167             : 
  148168             : //############################################################################
  148169             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  148170             :  * pool size! We set for every valid object in the memory pool the freepointer
  148171             :  * to the global index and increase the global index afterwards. For all the 
  148172             :  * invalid objects (means address ranges within the memory pool that were not
  148173             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  148174             :  * distinguish valid from invalid objects! 
  148175             :  */
  148176             : unsigned long
  148177           5 : SgAddressOfOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  148178             :    {
  148179           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  148180           5 :      SgAddressOfOp* pointer = NULL;
  148181           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  148182           5 :      std::vector < unsigned char* > :: const_iterator block;
  148183           6 :      for ( block = SgAddressOfOp::pools.begin(); block != SgAddressOfOp::pools.end() ; ++block )
  148184             :         {
  148185           1 :           pointer = (SgAddressOfOp*)(*block);
  148186        2001 :           for (unsigned i = 0; i < SgAddressOfOp::pool_size; ++i )
  148187             :              {
  148188             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  148189             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  148190             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  148191             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  148192             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  148193             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  148194             :             // properly; so this will have to be checked next.
  148195             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  148196             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  148197        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  148198             :                   {
  148199          84 :                     pointer[i].set_freepointer((SgAddressOfOp*)(globalIndex));
  148200          84 :                     globalIndex++;
  148201             :                   }
  148202             :                else
  148203             :                   {
  148204        1916 :                     pointer[i].set_freepointer(NULL);
  148205             :                   }
  148206             :               }
  148207             :         }
  148208           5 :      return globalIndex;
  148209             :    }
  148210             : 
  148211             : //############################################################################
  148212             : // JH (01/14/2006)
  148213             : void
  148214           5 : SgAddressOfOp::resetValidFreepointers( )
  148215             :    {
  148216           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  148217           5 :      SgAddressOfOp* pointer = NULL;
  148218           5 :      std::vector < unsigned char* > :: const_iterator block;
  148219           5 :      SgAddressOfOp* pointerOfLinkedList = NULL;
  148220           6 :      for ( block = SgAddressOfOp::pools.begin(); block != SgAddressOfOp::pools.end() ; ++block )
  148221             :         {
  148222           1 :           pointer = (SgAddressOfOp*)(*block);
  148223        2001 :           for (unsigned i = 0; i < SgAddressOfOp::pool_size; ++i )
  148224             :              {
  148225             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  148226             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  148227             :             // memory blocks!.
  148228        2000 :                if ( pointer[i].get_freepointer() != NULL )
  148229             :                   {
  148230          84 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  148231             :                   }
  148232             :                else
  148233             :                   {
  148234        1916 :                     if ( pointerOfLinkedList == NULL )
  148235             :                        {
  148236           1 :                          SgAddressOfOp::next_node = &(pointer[i]);
  148237             :                        }
  148238             :                     else
  148239             :                        {
  148240             :                       // printf ("In SgAddressOfOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  148241        1915 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  148242             :                        }
  148243             :                     pointerOfLinkedList = &(pointer[i]);
  148244             :                   }
  148245             :               }
  148246             :         }
  148247             : 
  148248           5 :      if ( pointerOfLinkedList != NULL )
  148249             :         {
  148250             :        // printf ("In SgAddressOfOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  148251           1 :           pointerOfLinkedList->set_freepointer(NULL);
  148252             :        // DQ (6/6/2010): Temporary debugging...
  148253             :        //   ROSE_ASSERT(false);
  148254             :         }
  148255             : 
  148256           5 :      return ;
  148257             :    }
  148258             : 
  148259             : //############################################################################
  148260             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  148261             :  * within the memory pool and resets the freepointers, in order to achieve a 
  148262             :  * linked list, that has no jumps and starts at the beginning! This function 
  148263             :  * does not extend the memory pool, since we do not delete any memory blocks,
  148264             :  * but delete the valid objects.  
  148265             :  */
  148266             : void
  148267           0 : SgAddressOfOp::clearMemoryPool( )
  148268             :    {
  148269             :   // printf ("Inside of SgAddressOfOp::clearMemoryPool() \n");
  148270             : 
  148271           0 :      SgAddressOfOp* pointer = NULL, *tempPointer = NULL;
  148272           0 :      std::vector < unsigned char* > :: const_iterator block;
  148273           0 :      if ( SgAddressOfOp::pools.empty() == false )
  148274             :         {
  148275           0 :           block = SgAddressOfOp::pools.begin() ;
  148276           0 :           SgAddressOfOp::next_node = (SgAddressOfOp*) (*block);
  148277             : 
  148278           0 :           while ( block != SgAddressOfOp::pools.end() )
  148279             :              {
  148280           0 :                pointer = (SgAddressOfOp*) (*block);
  148281           0 :                if ( tempPointer != NULL )
  148282             :                   {
  148283           0 :                     tempPointer->set_freepointer(pointer);
  148284             :                   }
  148285           0 :                for (unsigned i = 0; i < SgAddressOfOp::pool_size - 1; ++i)
  148286             :                   {
  148287           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  148288             :                   }
  148289           0 :                 pointer[SgAddressOfOp::pool_size-1].set_freepointer(NULL);
  148290           0 :                 tempPointer = &(pointer[SgAddressOfOp::pool_size-1]);
  148291           0 :                 ++block;
  148292             :              }
  148293             :         }
  148294           0 :    }
  148295             : 
  148296           5 : void SgAddressOfOp::deleteMemoryPool() {
  148297           7 :   for (auto p: SgAddressOfOp::pools) {
  148298           2 :     ROSE_FREE(p);
  148299             :   }
  148300           5 :   SgAddressOfOp::next_node = nullptr;
  148301           5 :   SgAddressOfOp::pools.clear();
  148302           5 : }
  148303             : 
  148304             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  148305             : //                 reading multiple binary files to for a single AST.
  148306             : /////////// new version ////////////////////////////////
  148307             : //############################################################################
  148308             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  148309             : void
  148310           2 : SgAddressOfOp::extendMemoryPoolForFileIO( )
  148311             :   {
  148312           2 :     size_t blockIndex = SgAddressOfOp::pools.size();
  148313           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAddressOfOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAddressOfOp);
  148314             : 
  148315           3 :     while ( (blockIndex * SgAddressOfOp::pool_size) < newPoolSize)
  148316             :       {
  148317             : #if ROSE_ALLOC_TRACE
  148318             :         if (blockIndex > 0) {
  148319             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAddressOfOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAddressOfOp) = %" PRIuPTR " SgAddressOfOp::pool_size = %d \n",
  148320             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAddressOfOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAddressOfOp),SgAddressOfOp::pool_size);
  148321             :         }
  148322             : #endif
  148323             : 
  148324           1 :         SgAddressOfOp * pointer = (SgAddressOfOp*) ROSE_MALLOC ( SgAddressOfOp::pool_size * sizeof(SgAddressOfOp) );
  148325           1 :         assert( pointer != NULL );
  148326             : #if ROSE_ALLOC_MEMSET == 1
  148327             :         memset(pointer, 0x00, SgAddressOfOp::pool_size * sizeof(SgAddressOfOp));
  148328             : #elif ROSE_ALLOC_MEMSET == 2
  148329             :         memset(pointer, 0xCC, SgAddressOfOp::pool_size * sizeof(SgAddressOfOp));
  148330             : #endif
  148331           1 :         SgAddressOfOp::pools.push_back( (unsigned char*)(pointer) );
  148332           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAddressOfOp::pool_size * sizeof(SgAddressOfOp), V_SgAddressOfOp ) );
  148333             : 
  148334           1 :         if ( SgAddressOfOp::next_node != NULL ) {
  148335           0 :           if ( blockIndex > 0 ) {
  148336           0 :             SgAddressOfOp * blkptr = (SgAddressOfOp*)(SgAddressOfOp::pools[blockIndex-1]);
  148337           0 :             blkptr[ SgAddressOfOp::pool_size - 1 ].set_freepointer(pointer);
  148338             :           }
  148339             :         } else {
  148340           1 :           SgAddressOfOp::next_node = pointer;
  148341             :         }
  148342             : 
  148343        2000 :         for (unsigned i = 0; i < SgAddressOfOp::pool_size-1; ++i)
  148344             :            {
  148345        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  148346             :            }
  148347           1 :         pointer[ SgAddressOfOp::pool_size -1 ].set_freepointer(NULL);
  148348             : 
  148349           1 :         blockIndex++;
  148350             :       }
  148351           2 :   }
  148352             : 
  148353             : //############################################################################
  148354             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  148355             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  148356             :  * not compressed. However, that stuff is not yet implemented! 
  148357             :  */
  148358             : unsigned long
  148359           0 : SgAddressOfOp::getNumberOfLastValidPointer()
  148360             :    {
  148361           0 :       SgAddressOfOp* testPointer = (SgAddressOfOp*)(SgAddressOfOp::pools.back());
  148362           0 :       unsigned long localIndex = SgAddressOfOp::pool_size - 1;
  148363           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  148364             :          {
  148365           0 :            localIndex--;
  148366             :          }
  148367           0 :       return (localIndex + SgAddressOfOp::pool_size * (SgAddressOfOp::pools.size()-1));
  148368             :    }
  148369             : 
  148370             : //############################################################################
  148371             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  148372             :  * memory pool and initializes the data member in class SgAddressOfOpStroageClass
  148373             :  * from its counterpart of SgAddressOfOp. The return value is just for checking, 
  148374             :  * that the whole StorageClassArray is initialized!
  148375             :  */
  148376             : unsigned long
  148377           1 : SgAddressOfOp::initializeStorageClassArray( SgAddressOfOpStorageClass *storageArray )
  148378             :    {
  148379           1 :      unsigned long storageCounter = 0;
  148380           1 :      std::vector < unsigned char* > :: const_iterator block = SgAddressOfOp::pools.begin();
  148381           1 :      SgAddressOfOp* pointer = NULL;
  148382           2 :      while ( block != SgAddressOfOp::pools.end() ) {
  148383           1 :           pointer = (SgAddressOfOp*) (*block);
  148384        2001 :           for ( unsigned i = 0; i < SgAddressOfOp::pool_size; ++i ) {
  148385        2000 :                if ( pointer->get_freepointer() != NULL ) {
  148386          84 :                  storageArray->pickOutIRNodeData (pointer) ;
  148387          84 :                  storageArray++;
  148388          84 :                  storageCounter++;
  148389             :                }
  148390        2000 :                pointer++;
  148391             :              }
  148392           1 :            block++;
  148393             :         }
  148394           1 :      return storageCounter;
  148395             :    }
  148396             : 
  148397             : /* #line 148398 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  148398             : 
  148399             : 
  148400             : 
  148401             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  148402             : 
  148403             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  148404             : 
  148405             : //############################################################################
  148406             : /* JH (02/02/2006) Constructor of the IR node SgMinusMinusOp that takes its 
  148407             :  * corresponding StorageClass as parameter
  148408             :  */
  148409          48 : SgMinusMinusOp :: SgMinusMinusOp ( const SgMinusMinusOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  148410             :    {
  148411             : 
  148412             : 
  148413             : /* #line 148414 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  148414             : 
  148415          48 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  148416             : 
  148417             : 
  148418             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  148419             : 
  148420             : 
  148421          48 :    }
  148422             : 
  148423             : //############################################################################
  148424             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  148425             :  * within the working AST. 
  148426             :  */
  148427         240 : SgMinusMinusOp * SgMinusMinusOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  148428         240 :      SgMinusMinusOp* returnPointer = NULL;
  148429         240 :      if ( globalIndex != 0 )
  148430             :         {
  148431             : 
  148432             : #if FILE_IO_EXTRA_CHECK
  148433         240 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMinusMinusOp ) ) <= globalIndex ) ;
  148434         240 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMinusMinusOp + 1 ) ) );
  148435             : #endif
  148436         240 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMinusMinusOp )  
  148437         240 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMinusMinusOp );
  148438         240 :           unsigned long positionInPool = localIndex % SgMinusMinusOp::pool_size;
  148439         240 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMinusMinusOp::pool_size;
  148440             : 
  148441             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  148442             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  148443             : 
  148444         240 :           returnPointer = &( ( (SgMinusMinusOp*)(SgMinusMinusOp::pools[memoryBlock]) ) [positionInPool]) ;
  148445             : 
  148446         240 :           ROSE_ASSERT( returnPointer != NULL ) ;
  148447             :         }
  148448         240 :      return returnPointer ;
  148449             :    }
  148450             : 
  148451             : //############################################################################
  148452             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  148453             :   for the AST with the index astIndex
  148454             : */
  148455           0 : SgMinusMinusOp * SgMinusMinusOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  148456           0 :      SgMinusMinusOp* returnPointer = NULL;
  148457           0 :      if ( globalIndex != 0 )
  148458             :         {
  148459             : 
  148460             : #if FILE_IO_EXTRA_CHECK
  148461           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMinusMinusOp ) ) <= globalIndex ) ;
  148462           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMinusMinusOp + 1 ) ) );
  148463             : #endif
  148464           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMinusMinusOp )
  148465           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMinusMinusOp );
  148466           0 :           unsigned long positionInPool = localIndex % SgMinusMinusOp::pool_size ;
  148467           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMinusMinusOp::pool_size ;
  148468             : 
  148469             : #if FILE_IO_EXTRA_CHECK
  148470             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  148471             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  148472             : #endif
  148473             : 
  148474           0 :           returnPointer = &( ( (SgMinusMinusOp*)(SgMinusMinusOp::pools[memoryBlock]) ) [positionInPool]) ;
  148475             : 
  148476             : #if FILE_IO_EXTRA_CHECK
  148477           0 :           assert ( returnPointer != NULL ) ;
  148478             : #endif
  148479             :         }
  148480           0 :      return returnPointer ;
  148481             :    }
  148482             : 
  148483             : //############################################################################
  148484             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  148485             :  * pool size! We set for every valid object in the memory pool the freepointer
  148486             :  * to the global index and increase the global index afterwards. For all the 
  148487             :  * invalid objects (means address ranges within the memory pool that were not
  148488             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  148489             :  * distinguish valid from invalid objects! 
  148490             :  */
  148491             : unsigned long
  148492           5 : SgMinusMinusOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  148493             :    {
  148494           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  148495           5 :      SgMinusMinusOp* pointer = NULL;
  148496           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  148497           5 :      std::vector < unsigned char* > :: const_iterator block;
  148498           6 :      for ( block = SgMinusMinusOp::pools.begin(); block != SgMinusMinusOp::pools.end() ; ++block )
  148499             :         {
  148500           1 :           pointer = (SgMinusMinusOp*)(*block);
  148501        2001 :           for (unsigned i = 0; i < SgMinusMinusOp::pool_size; ++i )
  148502             :              {
  148503             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  148504             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  148505             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  148506             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  148507             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  148508             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  148509             :             // properly; so this will have to be checked next.
  148510             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  148511             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  148512        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  148513             :                   {
  148514          48 :                     pointer[i].set_freepointer((SgMinusMinusOp*)(globalIndex));
  148515          48 :                     globalIndex++;
  148516             :                   }
  148517             :                else
  148518             :                   {
  148519        1952 :                     pointer[i].set_freepointer(NULL);
  148520             :                   }
  148521             :               }
  148522             :         }
  148523           5 :      return globalIndex;
  148524             :    }
  148525             : 
  148526             : //############################################################################
  148527             : // JH (01/14/2006)
  148528             : void
  148529           5 : SgMinusMinusOp::resetValidFreepointers( )
  148530             :    {
  148531           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  148532           5 :      SgMinusMinusOp* pointer = NULL;
  148533           5 :      std::vector < unsigned char* > :: const_iterator block;
  148534           5 :      SgMinusMinusOp* pointerOfLinkedList = NULL;
  148535           6 :      for ( block = SgMinusMinusOp::pools.begin(); block != SgMinusMinusOp::pools.end() ; ++block )
  148536             :         {
  148537           1 :           pointer = (SgMinusMinusOp*)(*block);
  148538        2001 :           for (unsigned i = 0; i < SgMinusMinusOp::pool_size; ++i )
  148539             :              {
  148540             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  148541             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  148542             :             // memory blocks!.
  148543        2000 :                if ( pointer[i].get_freepointer() != NULL )
  148544             :                   {
  148545          48 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  148546             :                   }
  148547             :                else
  148548             :                   {
  148549        1952 :                     if ( pointerOfLinkedList == NULL )
  148550             :                        {
  148551           1 :                          SgMinusMinusOp::next_node = &(pointer[i]);
  148552             :                        }
  148553             :                     else
  148554             :                        {
  148555             :                       // printf ("In SgMinusMinusOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  148556        1951 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  148557             :                        }
  148558             :                     pointerOfLinkedList = &(pointer[i]);
  148559             :                   }
  148560             :               }
  148561             :         }
  148562             : 
  148563           5 :      if ( pointerOfLinkedList != NULL )
  148564             :         {
  148565             :        // printf ("In SgMinusMinusOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  148566           1 :           pointerOfLinkedList->set_freepointer(NULL);
  148567             :        // DQ (6/6/2010): Temporary debugging...
  148568             :        //   ROSE_ASSERT(false);
  148569             :         }
  148570             : 
  148571           5 :      return ;
  148572             :    }
  148573             : 
  148574             : //############################################################################
  148575             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  148576             :  * within the memory pool and resets the freepointers, in order to achieve a 
  148577             :  * linked list, that has no jumps and starts at the beginning! This function 
  148578             :  * does not extend the memory pool, since we do not delete any memory blocks,
  148579             :  * but delete the valid objects.  
  148580             :  */
  148581             : void
  148582           0 : SgMinusMinusOp::clearMemoryPool( )
  148583             :    {
  148584             :   // printf ("Inside of SgMinusMinusOp::clearMemoryPool() \n");
  148585             : 
  148586           0 :      SgMinusMinusOp* pointer = NULL, *tempPointer = NULL;
  148587           0 :      std::vector < unsigned char* > :: const_iterator block;
  148588           0 :      if ( SgMinusMinusOp::pools.empty() == false )
  148589             :         {
  148590           0 :           block = SgMinusMinusOp::pools.begin() ;
  148591           0 :           SgMinusMinusOp::next_node = (SgMinusMinusOp*) (*block);
  148592             : 
  148593           0 :           while ( block != SgMinusMinusOp::pools.end() )
  148594             :              {
  148595           0 :                pointer = (SgMinusMinusOp*) (*block);
  148596           0 :                if ( tempPointer != NULL )
  148597             :                   {
  148598           0 :                     tempPointer->set_freepointer(pointer);
  148599             :                   }
  148600           0 :                for (unsigned i = 0; i < SgMinusMinusOp::pool_size - 1; ++i)
  148601             :                   {
  148602           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  148603             :                   }
  148604           0 :                 pointer[SgMinusMinusOp::pool_size-1].set_freepointer(NULL);
  148605           0 :                 tempPointer = &(pointer[SgMinusMinusOp::pool_size-1]);
  148606           0 :                 ++block;
  148607             :              }
  148608             :         }
  148609           0 :    }
  148610             : 
  148611           5 : void SgMinusMinusOp::deleteMemoryPool() {
  148612           7 :   for (auto p: SgMinusMinusOp::pools) {
  148613           2 :     ROSE_FREE(p);
  148614             :   }
  148615           5 :   SgMinusMinusOp::next_node = nullptr;
  148616           5 :   SgMinusMinusOp::pools.clear();
  148617           5 : }
  148618             : 
  148619             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  148620             : //                 reading multiple binary files to for a single AST.
  148621             : /////////// new version ////////////////////////////////
  148622             : //############################################################################
  148623             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  148624             : void
  148625           2 : SgMinusMinusOp::extendMemoryPoolForFileIO( )
  148626             :   {
  148627           2 :     size_t blockIndex = SgMinusMinusOp::pools.size();
  148628           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusMinusOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusMinusOp);
  148629             : 
  148630           3 :     while ( (blockIndex * SgMinusMinusOp::pool_size) < newPoolSize)
  148631             :       {
  148632             : #if ROSE_ALLOC_TRACE
  148633             :         if (blockIndex > 0) {
  148634             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusMinusOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusMinusOp) = %" PRIuPTR " SgMinusMinusOp::pool_size = %d \n",
  148635             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusMinusOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusMinusOp),SgMinusMinusOp::pool_size);
  148636             :         }
  148637             : #endif
  148638             : 
  148639           1 :         SgMinusMinusOp * pointer = (SgMinusMinusOp*) ROSE_MALLOC ( SgMinusMinusOp::pool_size * sizeof(SgMinusMinusOp) );
  148640           1 :         assert( pointer != NULL );
  148641             : #if ROSE_ALLOC_MEMSET == 1
  148642             :         memset(pointer, 0x00, SgMinusMinusOp::pool_size * sizeof(SgMinusMinusOp));
  148643             : #elif ROSE_ALLOC_MEMSET == 2
  148644             :         memset(pointer, 0xCC, SgMinusMinusOp::pool_size * sizeof(SgMinusMinusOp));
  148645             : #endif
  148646           1 :         SgMinusMinusOp::pools.push_back( (unsigned char*)(pointer) );
  148647           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMinusMinusOp::pool_size * sizeof(SgMinusMinusOp), V_SgMinusMinusOp ) );
  148648             : 
  148649           1 :         if ( SgMinusMinusOp::next_node != NULL ) {
  148650           0 :           if ( blockIndex > 0 ) {
  148651           0 :             SgMinusMinusOp * blkptr = (SgMinusMinusOp*)(SgMinusMinusOp::pools[blockIndex-1]);
  148652           0 :             blkptr[ SgMinusMinusOp::pool_size - 1 ].set_freepointer(pointer);
  148653             :           }
  148654             :         } else {
  148655           1 :           SgMinusMinusOp::next_node = pointer;
  148656             :         }
  148657             : 
  148658        2000 :         for (unsigned i = 0; i < SgMinusMinusOp::pool_size-1; ++i)
  148659             :            {
  148660        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  148661             :            }
  148662           1 :         pointer[ SgMinusMinusOp::pool_size -1 ].set_freepointer(NULL);
  148663             : 
  148664           1 :         blockIndex++;
  148665             :       }
  148666           2 :   }
  148667             : 
  148668             : //############################################################################
  148669             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  148670             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  148671             :  * not compressed. However, that stuff is not yet implemented! 
  148672             :  */
  148673             : unsigned long
  148674           0 : SgMinusMinusOp::getNumberOfLastValidPointer()
  148675             :    {
  148676           0 :       SgMinusMinusOp* testPointer = (SgMinusMinusOp*)(SgMinusMinusOp::pools.back());
  148677           0 :       unsigned long localIndex = SgMinusMinusOp::pool_size - 1;
  148678           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  148679             :          {
  148680           0 :            localIndex--;
  148681             :          }
  148682           0 :       return (localIndex + SgMinusMinusOp::pool_size * (SgMinusMinusOp::pools.size()-1));
  148683             :    }
  148684             : 
  148685             : //############################################################################
  148686             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  148687             :  * memory pool and initializes the data member in class SgMinusMinusOpStroageClass
  148688             :  * from its counterpart of SgMinusMinusOp. The return value is just for checking, 
  148689             :  * that the whole StorageClassArray is initialized!
  148690             :  */
  148691             : unsigned long
  148692           1 : SgMinusMinusOp::initializeStorageClassArray( SgMinusMinusOpStorageClass *storageArray )
  148693             :    {
  148694           1 :      unsigned long storageCounter = 0;
  148695           1 :      std::vector < unsigned char* > :: const_iterator block = SgMinusMinusOp::pools.begin();
  148696           1 :      SgMinusMinusOp* pointer = NULL;
  148697           2 :      while ( block != SgMinusMinusOp::pools.end() ) {
  148698           1 :           pointer = (SgMinusMinusOp*) (*block);
  148699        2001 :           for ( unsigned i = 0; i < SgMinusMinusOp::pool_size; ++i ) {
  148700        2000 :                if ( pointer->get_freepointer() != NULL ) {
  148701          48 :                  storageArray->pickOutIRNodeData (pointer) ;
  148702          48 :                  storageArray++;
  148703          48 :                  storageCounter++;
  148704             :                }
  148705        2000 :                pointer++;
  148706             :              }
  148707           1 :            block++;
  148708             :         }
  148709           1 :      return storageCounter;
  148710             :    }
  148711             : 
  148712             : /* #line 148713 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  148713             : 
  148714             : 
  148715             : 
  148716             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  148717             : 
  148718             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  148719             : 
  148720             : //############################################################################
  148721             : /* JH (02/02/2006) Constructor of the IR node SgPlusPlusOp that takes its 
  148722             :  * corresponding StorageClass as parameter
  148723             :  */
  148724         131 : SgPlusPlusOp :: SgPlusPlusOp ( const SgPlusPlusOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  148725             :    {
  148726             : 
  148727             : 
  148728             : /* #line 148729 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  148729             : 
  148730         131 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  148731             : 
  148732             : 
  148733             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  148734             : 
  148735             : 
  148736         131 :    }
  148737             : 
  148738             : //############################################################################
  148739             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  148740             :  * within the working AST. 
  148741             :  */
  148742         655 : SgPlusPlusOp * SgPlusPlusOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  148743         655 :      SgPlusPlusOp* returnPointer = NULL;
  148744         655 :      if ( globalIndex != 0 )
  148745             :         {
  148746             : 
  148747             : #if FILE_IO_EXTRA_CHECK
  148748         655 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPlusPlusOp ) ) <= globalIndex ) ;
  148749         655 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPlusPlusOp + 1 ) ) );
  148750             : #endif
  148751         655 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPlusPlusOp )  
  148752         655 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPlusPlusOp );
  148753         655 :           unsigned long positionInPool = localIndex % SgPlusPlusOp::pool_size;
  148754         655 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPlusPlusOp::pool_size;
  148755             : 
  148756             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  148757             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  148758             : 
  148759         655 :           returnPointer = &( ( (SgPlusPlusOp*)(SgPlusPlusOp::pools[memoryBlock]) ) [positionInPool]) ;
  148760             : 
  148761         655 :           ROSE_ASSERT( returnPointer != NULL ) ;
  148762             :         }
  148763         655 :      return returnPointer ;
  148764             :    }
  148765             : 
  148766             : //############################################################################
  148767             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  148768             :   for the AST with the index astIndex
  148769             : */
  148770           0 : SgPlusPlusOp * SgPlusPlusOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  148771           0 :      SgPlusPlusOp* returnPointer = NULL;
  148772           0 :      if ( globalIndex != 0 )
  148773             :         {
  148774             : 
  148775             : #if FILE_IO_EXTRA_CHECK
  148776           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPlusPlusOp ) ) <= globalIndex ) ;
  148777           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPlusPlusOp + 1 ) ) );
  148778             : #endif
  148779           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPlusPlusOp )
  148780           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPlusPlusOp );
  148781           0 :           unsigned long positionInPool = localIndex % SgPlusPlusOp::pool_size ;
  148782           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPlusPlusOp::pool_size ;
  148783             : 
  148784             : #if FILE_IO_EXTRA_CHECK
  148785             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  148786             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  148787             : #endif
  148788             : 
  148789           0 :           returnPointer = &( ( (SgPlusPlusOp*)(SgPlusPlusOp::pools[memoryBlock]) ) [positionInPool]) ;
  148790             : 
  148791             : #if FILE_IO_EXTRA_CHECK
  148792           0 :           assert ( returnPointer != NULL ) ;
  148793             : #endif
  148794             :         }
  148795           0 :      return returnPointer ;
  148796             :    }
  148797             : 
  148798             : //############################################################################
  148799             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  148800             :  * pool size! We set for every valid object in the memory pool the freepointer
  148801             :  * to the global index and increase the global index afterwards. For all the 
  148802             :  * invalid objects (means address ranges within the memory pool that were not
  148803             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  148804             :  * distinguish valid from invalid objects! 
  148805             :  */
  148806             : unsigned long
  148807           5 : SgPlusPlusOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  148808             :    {
  148809           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  148810           5 :      SgPlusPlusOp* pointer = NULL;
  148811           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  148812           5 :      std::vector < unsigned char* > :: const_iterator block;
  148813           6 :      for ( block = SgPlusPlusOp::pools.begin(); block != SgPlusPlusOp::pools.end() ; ++block )
  148814             :         {
  148815           1 :           pointer = (SgPlusPlusOp*)(*block);
  148816        2001 :           for (unsigned i = 0; i < SgPlusPlusOp::pool_size; ++i )
  148817             :              {
  148818             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  148819             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  148820             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  148821             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  148822             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  148823             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  148824             :             // properly; so this will have to be checked next.
  148825             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  148826             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  148827        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  148828             :                   {
  148829         131 :                     pointer[i].set_freepointer((SgPlusPlusOp*)(globalIndex));
  148830         131 :                     globalIndex++;
  148831             :                   }
  148832             :                else
  148833             :                   {
  148834        1869 :                     pointer[i].set_freepointer(NULL);
  148835             :                   }
  148836             :               }
  148837             :         }
  148838           5 :      return globalIndex;
  148839             :    }
  148840             : 
  148841             : //############################################################################
  148842             : // JH (01/14/2006)
  148843             : void
  148844           5 : SgPlusPlusOp::resetValidFreepointers( )
  148845             :    {
  148846           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  148847           5 :      SgPlusPlusOp* pointer = NULL;
  148848           5 :      std::vector < unsigned char* > :: const_iterator block;
  148849           5 :      SgPlusPlusOp* pointerOfLinkedList = NULL;
  148850           6 :      for ( block = SgPlusPlusOp::pools.begin(); block != SgPlusPlusOp::pools.end() ; ++block )
  148851             :         {
  148852           1 :           pointer = (SgPlusPlusOp*)(*block);
  148853        2001 :           for (unsigned i = 0; i < SgPlusPlusOp::pool_size; ++i )
  148854             :              {
  148855             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  148856             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  148857             :             // memory blocks!.
  148858        2000 :                if ( pointer[i].get_freepointer() != NULL )
  148859             :                   {
  148860         131 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  148861             :                   }
  148862             :                else
  148863             :                   {
  148864        1869 :                     if ( pointerOfLinkedList == NULL )
  148865             :                        {
  148866           1 :                          SgPlusPlusOp::next_node = &(pointer[i]);
  148867             :                        }
  148868             :                     else
  148869             :                        {
  148870             :                       // printf ("In SgPlusPlusOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  148871        1868 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  148872             :                        }
  148873             :                     pointerOfLinkedList = &(pointer[i]);
  148874             :                   }
  148875             :               }
  148876             :         }
  148877             : 
  148878           5 :      if ( pointerOfLinkedList != NULL )
  148879             :         {
  148880             :        // printf ("In SgPlusPlusOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  148881           1 :           pointerOfLinkedList->set_freepointer(NULL);
  148882             :        // DQ (6/6/2010): Temporary debugging...
  148883             :        //   ROSE_ASSERT(false);
  148884             :         }
  148885             : 
  148886           5 :      return ;
  148887             :    }
  148888             : 
  148889             : //############################################################################
  148890             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  148891             :  * within the memory pool and resets the freepointers, in order to achieve a 
  148892             :  * linked list, that has no jumps and starts at the beginning! This function 
  148893             :  * does not extend the memory pool, since we do not delete any memory blocks,
  148894             :  * but delete the valid objects.  
  148895             :  */
  148896             : void
  148897           0 : SgPlusPlusOp::clearMemoryPool( )
  148898             :    {
  148899             :   // printf ("Inside of SgPlusPlusOp::clearMemoryPool() \n");
  148900             : 
  148901           0 :      SgPlusPlusOp* pointer = NULL, *tempPointer = NULL;
  148902           0 :      std::vector < unsigned char* > :: const_iterator block;
  148903           0 :      if ( SgPlusPlusOp::pools.empty() == false )
  148904             :         {
  148905           0 :           block = SgPlusPlusOp::pools.begin() ;
  148906           0 :           SgPlusPlusOp::next_node = (SgPlusPlusOp*) (*block);
  148907             : 
  148908           0 :           while ( block != SgPlusPlusOp::pools.end() )
  148909             :              {
  148910           0 :                pointer = (SgPlusPlusOp*) (*block);
  148911           0 :                if ( tempPointer != NULL )
  148912             :                   {
  148913           0 :                     tempPointer->set_freepointer(pointer);
  148914             :                   }
  148915           0 :                for (unsigned i = 0; i < SgPlusPlusOp::pool_size - 1; ++i)
  148916             :                   {
  148917           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  148918             :                   }
  148919           0 :                 pointer[SgPlusPlusOp::pool_size-1].set_freepointer(NULL);
  148920           0 :                 tempPointer = &(pointer[SgPlusPlusOp::pool_size-1]);
  148921           0 :                 ++block;
  148922             :              }
  148923             :         }
  148924           0 :    }
  148925             : 
  148926           5 : void SgPlusPlusOp::deleteMemoryPool() {
  148927           7 :   for (auto p: SgPlusPlusOp::pools) {
  148928           2 :     ROSE_FREE(p);
  148929             :   }
  148930           5 :   SgPlusPlusOp::next_node = nullptr;
  148931           5 :   SgPlusPlusOp::pools.clear();
  148932           5 : }
  148933             : 
  148934             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  148935             : //                 reading multiple binary files to for a single AST.
  148936             : /////////// new version ////////////////////////////////
  148937             : //############################################################################
  148938             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  148939             : void
  148940           2 : SgPlusPlusOp::extendMemoryPoolForFileIO( )
  148941             :   {
  148942           2 :     size_t blockIndex = SgPlusPlusOp::pools.size();
  148943           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPlusPlusOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPlusPlusOp);
  148944             : 
  148945           3 :     while ( (blockIndex * SgPlusPlusOp::pool_size) < newPoolSize)
  148946             :       {
  148947             : #if ROSE_ALLOC_TRACE
  148948             :         if (blockIndex > 0) {
  148949             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPlusPlusOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPlusPlusOp) = %" PRIuPTR " SgPlusPlusOp::pool_size = %d \n",
  148950             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPlusPlusOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPlusPlusOp),SgPlusPlusOp::pool_size);
  148951             :         }
  148952             : #endif
  148953             : 
  148954           1 :         SgPlusPlusOp * pointer = (SgPlusPlusOp*) ROSE_MALLOC ( SgPlusPlusOp::pool_size * sizeof(SgPlusPlusOp) );
  148955           1 :         assert( pointer != NULL );
  148956             : #if ROSE_ALLOC_MEMSET == 1
  148957             :         memset(pointer, 0x00, SgPlusPlusOp::pool_size * sizeof(SgPlusPlusOp));
  148958             : #elif ROSE_ALLOC_MEMSET == 2
  148959             :         memset(pointer, 0xCC, SgPlusPlusOp::pool_size * sizeof(SgPlusPlusOp));
  148960             : #endif
  148961           1 :         SgPlusPlusOp::pools.push_back( (unsigned char*)(pointer) );
  148962           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPlusPlusOp::pool_size * sizeof(SgPlusPlusOp), V_SgPlusPlusOp ) );
  148963             : 
  148964           1 :         if ( SgPlusPlusOp::next_node != NULL ) {
  148965           0 :           if ( blockIndex > 0 ) {
  148966           0 :             SgPlusPlusOp * blkptr = (SgPlusPlusOp*)(SgPlusPlusOp::pools[blockIndex-1]);
  148967           0 :             blkptr[ SgPlusPlusOp::pool_size - 1 ].set_freepointer(pointer);
  148968             :           }
  148969             :         } else {
  148970           1 :           SgPlusPlusOp::next_node = pointer;
  148971             :         }
  148972             : 
  148973        2000 :         for (unsigned i = 0; i < SgPlusPlusOp::pool_size-1; ++i)
  148974             :            {
  148975        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  148976             :            }
  148977           1 :         pointer[ SgPlusPlusOp::pool_size -1 ].set_freepointer(NULL);
  148978             : 
  148979           1 :         blockIndex++;
  148980             :       }
  148981           2 :   }
  148982             : 
  148983             : //############################################################################
  148984             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  148985             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  148986             :  * not compressed. However, that stuff is not yet implemented! 
  148987             :  */
  148988             : unsigned long
  148989           0 : SgPlusPlusOp::getNumberOfLastValidPointer()
  148990             :    {
  148991           0 :       SgPlusPlusOp* testPointer = (SgPlusPlusOp*)(SgPlusPlusOp::pools.back());
  148992           0 :       unsigned long localIndex = SgPlusPlusOp::pool_size - 1;
  148993           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  148994             :          {
  148995           0 :            localIndex--;
  148996             :          }
  148997           0 :       return (localIndex + SgPlusPlusOp::pool_size * (SgPlusPlusOp::pools.size()-1));
  148998             :    }
  148999             : 
  149000             : //############################################################################
  149001             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  149002             :  * memory pool and initializes the data member in class SgPlusPlusOpStroageClass
  149003             :  * from its counterpart of SgPlusPlusOp. The return value is just for checking, 
  149004             :  * that the whole StorageClassArray is initialized!
  149005             :  */
  149006             : unsigned long
  149007           1 : SgPlusPlusOp::initializeStorageClassArray( SgPlusPlusOpStorageClass *storageArray )
  149008             :    {
  149009           1 :      unsigned long storageCounter = 0;
  149010           1 :      std::vector < unsigned char* > :: const_iterator block = SgPlusPlusOp::pools.begin();
  149011           1 :      SgPlusPlusOp* pointer = NULL;
  149012           2 :      while ( block != SgPlusPlusOp::pools.end() ) {
  149013           1 :           pointer = (SgPlusPlusOp*) (*block);
  149014        2001 :           for ( unsigned i = 0; i < SgPlusPlusOp::pool_size; ++i ) {
  149015        2000 :                if ( pointer->get_freepointer() != NULL ) {
  149016         131 :                  storageArray->pickOutIRNodeData (pointer) ;
  149017         131 :                  storageArray++;
  149018         131 :                  storageCounter++;
  149019             :                }
  149020        2000 :                pointer++;
  149021             :              }
  149022           1 :            block++;
  149023             :         }
  149024           1 :      return storageCounter;
  149025             :    }
  149026             : 
  149027             : /* #line 149028 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  149028             : 
  149029             : 
  149030             : 
  149031             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  149032             : 
  149033             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  149034             : 
  149035             : //############################################################################
  149036             : /* JH (02/02/2006) Constructor of the IR node SgBitComplementOp that takes its 
  149037             :  * corresponding StorageClass as parameter
  149038             :  */
  149039          11 : SgBitComplementOp :: SgBitComplementOp ( const SgBitComplementOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  149040             :    {
  149041             : 
  149042             : 
  149043             : /* #line 149044 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  149044             : 
  149045          11 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  149046             : 
  149047             : 
  149048             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  149049             : 
  149050             : 
  149051          11 :    }
  149052             : 
  149053             : //############################################################################
  149054             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  149055             :  * within the working AST. 
  149056             :  */
  149057          55 : SgBitComplementOp * SgBitComplementOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  149058          55 :      SgBitComplementOp* returnPointer = NULL;
  149059          55 :      if ( globalIndex != 0 )
  149060             :         {
  149061             : 
  149062             : #if FILE_IO_EXTRA_CHECK
  149063          55 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBitComplementOp ) ) <= globalIndex ) ;
  149064          55 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitComplementOp + 1 ) ) );
  149065             : #endif
  149066          55 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitComplementOp )  
  149067          55 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBitComplementOp );
  149068          55 :           unsigned long positionInPool = localIndex % SgBitComplementOp::pool_size;
  149069          55 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitComplementOp::pool_size;
  149070             : 
  149071             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  149072             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  149073             : 
  149074          55 :           returnPointer = &( ( (SgBitComplementOp*)(SgBitComplementOp::pools[memoryBlock]) ) [positionInPool]) ;
  149075             : 
  149076          55 :           ROSE_ASSERT( returnPointer != NULL ) ;
  149077             :         }
  149078          55 :      return returnPointer ;
  149079             :    }
  149080             : 
  149081             : //############################################################################
  149082             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  149083             :   for the AST with the index astIndex
  149084             : */
  149085           0 : SgBitComplementOp * SgBitComplementOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  149086           0 :      SgBitComplementOp* returnPointer = NULL;
  149087           0 :      if ( globalIndex != 0 )
  149088             :         {
  149089             : 
  149090             : #if FILE_IO_EXTRA_CHECK
  149091           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBitComplementOp ) ) <= globalIndex ) ;
  149092           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitComplementOp + 1 ) ) );
  149093             : #endif
  149094           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitComplementOp )
  149095           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBitComplementOp );
  149096           0 :           unsigned long positionInPool = localIndex % SgBitComplementOp::pool_size ;
  149097           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitComplementOp::pool_size ;
  149098             : 
  149099             : #if FILE_IO_EXTRA_CHECK
  149100             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  149101             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  149102             : #endif
  149103             : 
  149104           0 :           returnPointer = &( ( (SgBitComplementOp*)(SgBitComplementOp::pools[memoryBlock]) ) [positionInPool]) ;
  149105             : 
  149106             : #if FILE_IO_EXTRA_CHECK
  149107           0 :           assert ( returnPointer != NULL ) ;
  149108             : #endif
  149109             :         }
  149110           0 :      return returnPointer ;
  149111             :    }
  149112             : 
  149113             : //############################################################################
  149114             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  149115             :  * pool size! We set for every valid object in the memory pool the freepointer
  149116             :  * to the global index and increase the global index afterwards. For all the 
  149117             :  * invalid objects (means address ranges within the memory pool that were not
  149118             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  149119             :  * distinguish valid from invalid objects! 
  149120             :  */
  149121             : unsigned long
  149122           5 : SgBitComplementOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  149123             :    {
  149124           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  149125           5 :      SgBitComplementOp* pointer = NULL;
  149126           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  149127           5 :      std::vector < unsigned char* > :: const_iterator block;
  149128           6 :      for ( block = SgBitComplementOp::pools.begin(); block != SgBitComplementOp::pools.end() ; ++block )
  149129             :         {
  149130           1 :           pointer = (SgBitComplementOp*)(*block);
  149131        2001 :           for (unsigned i = 0; i < SgBitComplementOp::pool_size; ++i )
  149132             :              {
  149133             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  149134             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  149135             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  149136             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  149137             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  149138             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  149139             :             // properly; so this will have to be checked next.
  149140             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  149141             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  149142        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  149143             :                   {
  149144          11 :                     pointer[i].set_freepointer((SgBitComplementOp*)(globalIndex));
  149145          11 :                     globalIndex++;
  149146             :                   }
  149147             :                else
  149148             :                   {
  149149        1989 :                     pointer[i].set_freepointer(NULL);
  149150             :                   }
  149151             :               }
  149152             :         }
  149153           5 :      return globalIndex;
  149154             :    }
  149155             : 
  149156             : //############################################################################
  149157             : // JH (01/14/2006)
  149158             : void
  149159           5 : SgBitComplementOp::resetValidFreepointers( )
  149160             :    {
  149161           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  149162           5 :      SgBitComplementOp* pointer = NULL;
  149163           5 :      std::vector < unsigned char* > :: const_iterator block;
  149164           5 :      SgBitComplementOp* pointerOfLinkedList = NULL;
  149165           6 :      for ( block = SgBitComplementOp::pools.begin(); block != SgBitComplementOp::pools.end() ; ++block )
  149166             :         {
  149167           1 :           pointer = (SgBitComplementOp*)(*block);
  149168        2001 :           for (unsigned i = 0; i < SgBitComplementOp::pool_size; ++i )
  149169             :              {
  149170             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  149171             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  149172             :             // memory blocks!.
  149173        2000 :                if ( pointer[i].get_freepointer() != NULL )
  149174             :                   {
  149175          11 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  149176             :                   }
  149177             :                else
  149178             :                   {
  149179        1989 :                     if ( pointerOfLinkedList == NULL )
  149180             :                        {
  149181           1 :                          SgBitComplementOp::next_node = &(pointer[i]);
  149182             :                        }
  149183             :                     else
  149184             :                        {
  149185             :                       // printf ("In SgBitComplementOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  149186        1988 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  149187             :                        }
  149188             :                     pointerOfLinkedList = &(pointer[i]);
  149189             :                   }
  149190             :               }
  149191             :         }
  149192             : 
  149193           5 :      if ( pointerOfLinkedList != NULL )
  149194             :         {
  149195             :        // printf ("In SgBitComplementOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  149196           1 :           pointerOfLinkedList->set_freepointer(NULL);
  149197             :        // DQ (6/6/2010): Temporary debugging...
  149198             :        //   ROSE_ASSERT(false);
  149199             :         }
  149200             : 
  149201           5 :      return ;
  149202             :    }
  149203             : 
  149204             : //############################################################################
  149205             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  149206             :  * within the memory pool and resets the freepointers, in order to achieve a 
  149207             :  * linked list, that has no jumps and starts at the beginning! This function 
  149208             :  * does not extend the memory pool, since we do not delete any memory blocks,
  149209             :  * but delete the valid objects.  
  149210             :  */
  149211             : void
  149212           0 : SgBitComplementOp::clearMemoryPool( )
  149213             :    {
  149214             :   // printf ("Inside of SgBitComplementOp::clearMemoryPool() \n");
  149215             : 
  149216           0 :      SgBitComplementOp* pointer = NULL, *tempPointer = NULL;
  149217           0 :      std::vector < unsigned char* > :: const_iterator block;
  149218           0 :      if ( SgBitComplementOp::pools.empty() == false )
  149219             :         {
  149220           0 :           block = SgBitComplementOp::pools.begin() ;
  149221           0 :           SgBitComplementOp::next_node = (SgBitComplementOp*) (*block);
  149222             : 
  149223           0 :           while ( block != SgBitComplementOp::pools.end() )
  149224             :              {
  149225           0 :                pointer = (SgBitComplementOp*) (*block);
  149226           0 :                if ( tempPointer != NULL )
  149227             :                   {
  149228           0 :                     tempPointer->set_freepointer(pointer);
  149229             :                   }
  149230           0 :                for (unsigned i = 0; i < SgBitComplementOp::pool_size - 1; ++i)
  149231             :                   {
  149232           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  149233             :                   }
  149234           0 :                 pointer[SgBitComplementOp::pool_size-1].set_freepointer(NULL);
  149235           0 :                 tempPointer = &(pointer[SgBitComplementOp::pool_size-1]);
  149236           0 :                 ++block;
  149237             :              }
  149238             :         }
  149239           0 :    }
  149240             : 
  149241           5 : void SgBitComplementOp::deleteMemoryPool() {
  149242           7 :   for (auto p: SgBitComplementOp::pools) {
  149243           2 :     ROSE_FREE(p);
  149244             :   }
  149245           5 :   SgBitComplementOp::next_node = nullptr;
  149246           5 :   SgBitComplementOp::pools.clear();
  149247           5 : }
  149248             : 
  149249             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  149250             : //                 reading multiple binary files to for a single AST.
  149251             : /////////// new version ////////////////////////////////
  149252             : //############################################################################
  149253             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  149254             : void
  149255           2 : SgBitComplementOp::extendMemoryPoolForFileIO( )
  149256             :   {
  149257           2 :     size_t blockIndex = SgBitComplementOp::pools.size();
  149258           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBitComplementOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitComplementOp);
  149259             : 
  149260           3 :     while ( (blockIndex * SgBitComplementOp::pool_size) < newPoolSize)
  149261             :       {
  149262             : #if ROSE_ALLOC_TRACE
  149263             :         if (blockIndex > 0) {
  149264             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBitComplementOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitComplementOp) = %" PRIuPTR " SgBitComplementOp::pool_size = %d \n",
  149265             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBitComplementOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitComplementOp),SgBitComplementOp::pool_size);
  149266             :         }
  149267             : #endif
  149268             : 
  149269           1 :         SgBitComplementOp * pointer = (SgBitComplementOp*) ROSE_MALLOC ( SgBitComplementOp::pool_size * sizeof(SgBitComplementOp) );
  149270           1 :         assert( pointer != NULL );
  149271             : #if ROSE_ALLOC_MEMSET == 1
  149272             :         memset(pointer, 0x00, SgBitComplementOp::pool_size * sizeof(SgBitComplementOp));
  149273             : #elif ROSE_ALLOC_MEMSET == 2
  149274             :         memset(pointer, 0xCC, SgBitComplementOp::pool_size * sizeof(SgBitComplementOp));
  149275             : #endif
  149276           1 :         SgBitComplementOp::pools.push_back( (unsigned char*)(pointer) );
  149277           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBitComplementOp::pool_size * sizeof(SgBitComplementOp), V_SgBitComplementOp ) );
  149278             : 
  149279           1 :         if ( SgBitComplementOp::next_node != NULL ) {
  149280           0 :           if ( blockIndex > 0 ) {
  149281           0 :             SgBitComplementOp * blkptr = (SgBitComplementOp*)(SgBitComplementOp::pools[blockIndex-1]);
  149282           0 :             blkptr[ SgBitComplementOp::pool_size - 1 ].set_freepointer(pointer);
  149283             :           }
  149284             :         } else {
  149285           1 :           SgBitComplementOp::next_node = pointer;
  149286             :         }
  149287             : 
  149288        2000 :         for (unsigned i = 0; i < SgBitComplementOp::pool_size-1; ++i)
  149289             :            {
  149290        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  149291             :            }
  149292           1 :         pointer[ SgBitComplementOp::pool_size -1 ].set_freepointer(NULL);
  149293             : 
  149294           1 :         blockIndex++;
  149295             :       }
  149296           2 :   }
  149297             : 
  149298             : //############################################################################
  149299             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  149300             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  149301             :  * not compressed. However, that stuff is not yet implemented! 
  149302             :  */
  149303             : unsigned long
  149304           0 : SgBitComplementOp::getNumberOfLastValidPointer()
  149305             :    {
  149306           0 :       SgBitComplementOp* testPointer = (SgBitComplementOp*)(SgBitComplementOp::pools.back());
  149307           0 :       unsigned long localIndex = SgBitComplementOp::pool_size - 1;
  149308           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  149309             :          {
  149310           0 :            localIndex--;
  149311             :          }
  149312           0 :       return (localIndex + SgBitComplementOp::pool_size * (SgBitComplementOp::pools.size()-1));
  149313             :    }
  149314             : 
  149315             : //############################################################################
  149316             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  149317             :  * memory pool and initializes the data member in class SgBitComplementOpStroageClass
  149318             :  * from its counterpart of SgBitComplementOp. The return value is just for checking, 
  149319             :  * that the whole StorageClassArray is initialized!
  149320             :  */
  149321             : unsigned long
  149322           1 : SgBitComplementOp::initializeStorageClassArray( SgBitComplementOpStorageClass *storageArray )
  149323             :    {
  149324           1 :      unsigned long storageCounter = 0;
  149325           1 :      std::vector < unsigned char* > :: const_iterator block = SgBitComplementOp::pools.begin();
  149326           1 :      SgBitComplementOp* pointer = NULL;
  149327           2 :      while ( block != SgBitComplementOp::pools.end() ) {
  149328           1 :           pointer = (SgBitComplementOp*) (*block);
  149329        2001 :           for ( unsigned i = 0; i < SgBitComplementOp::pool_size; ++i ) {
  149330        2000 :                if ( pointer->get_freepointer() != NULL ) {
  149331          11 :                  storageArray->pickOutIRNodeData (pointer) ;
  149332          11 :                  storageArray++;
  149333          11 :                  storageCounter++;
  149334             :                }
  149335        2000 :                pointer++;
  149336             :              }
  149337           1 :            block++;
  149338             :         }
  149339           1 :      return storageCounter;
  149340             :    }
  149341             : 
  149342             : /* #line 149343 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  149343             : 
  149344             : 
  149345             : 
  149346             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  149347             : 
  149348             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  149349             : 
  149350             : //############################################################################
  149351             : /* JH (02/02/2006) Constructor of the IR node SgCastExp that takes its 
  149352             :  * corresponding StorageClass as parameter
  149353             :  */
  149354        2261 : SgCastExp :: SgCastExp ( const SgCastExpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  149355             :    {
  149356             : 
  149357             : 
  149358             : /* #line 149359 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  149359             : 
  149360        2261 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  149361        2261 :      p_cast_type = storageSource.storageOf_cast_type ;
  149362        2261 :      p_originalExpressionTree =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_originalExpressionTree) );
  149363        2261 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  149364        2261 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  149365        2261 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  149366        2261 :      p_castContainsBaseTypeDefiningDeclaration = storageSource.storageOf_castContainsBaseTypeDefiningDeclaration ;
  149367        2261 :      p_name_qualification_for_pointer_to_member_class_length = storageSource.storageOf_name_qualification_for_pointer_to_member_class_length ;
  149368        2261 :      p_type_elaboration_for_pointer_to_member_class_required = storageSource.storageOf_type_elaboration_for_pointer_to_member_class_required ;
  149369        2261 :      p_global_qualification_for_pointer_to_member_class_required = storageSource.storageOf_global_qualification_for_pointer_to_member_class_required ;
  149370             : 
  149371             : 
  149372             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  149373             : 
  149374             : 
  149375        2261 :    }
  149376             : 
  149377             : //############################################################################
  149378             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  149379             :  * within the working AST. 
  149380             :  */
  149381       11305 : SgCastExp * SgCastExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  149382       11305 :      SgCastExp* returnPointer = NULL;
  149383       11305 :      if ( globalIndex != 0 )
  149384             :         {
  149385             : 
  149386             : #if FILE_IO_EXTRA_CHECK
  149387       11305 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCastExp ) ) <= globalIndex ) ;
  149388       11305 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCastExp + 1 ) ) );
  149389             : #endif
  149390       11305 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCastExp )  
  149391       11305 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCastExp );
  149392       11305 :           unsigned long positionInPool = localIndex % SgCastExp::pool_size;
  149393       11305 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCastExp::pool_size;
  149394             : 
  149395             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  149396             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  149397             : 
  149398       11305 :           returnPointer = &( ( (SgCastExp*)(SgCastExp::pools[memoryBlock]) ) [positionInPool]) ;
  149399             : 
  149400       11305 :           ROSE_ASSERT( returnPointer != NULL ) ;
  149401             :         }
  149402       11305 :      return returnPointer ;
  149403             :    }
  149404             : 
  149405             : //############################################################################
  149406             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  149407             :   for the AST with the index astIndex
  149408             : */
  149409           0 : SgCastExp * SgCastExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  149410           0 :      SgCastExp* returnPointer = NULL;
  149411           0 :      if ( globalIndex != 0 )
  149412             :         {
  149413             : 
  149414             : #if FILE_IO_EXTRA_CHECK
  149415           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCastExp ) ) <= globalIndex ) ;
  149416           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCastExp + 1 ) ) );
  149417             : #endif
  149418           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCastExp )
  149419           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCastExp );
  149420           0 :           unsigned long positionInPool = localIndex % SgCastExp::pool_size ;
  149421           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCastExp::pool_size ;
  149422             : 
  149423             : #if FILE_IO_EXTRA_CHECK
  149424             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  149425             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  149426             : #endif
  149427             : 
  149428           0 :           returnPointer = &( ( (SgCastExp*)(SgCastExp::pools[memoryBlock]) ) [positionInPool]) ;
  149429             : 
  149430             : #if FILE_IO_EXTRA_CHECK
  149431           0 :           assert ( returnPointer != NULL ) ;
  149432             : #endif
  149433             :         }
  149434           0 :      return returnPointer ;
  149435             :    }
  149436             : 
  149437             : //############################################################################
  149438             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  149439             :  * pool size! We set for every valid object in the memory pool the freepointer
  149440             :  * to the global index and increase the global index afterwards. For all the 
  149441             :  * invalid objects (means address ranges within the memory pool that were not
  149442             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  149443             :  * distinguish valid from invalid objects! 
  149444             :  */
  149445             : unsigned long
  149446           5 : SgCastExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  149447             :    {
  149448           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  149449           5 :      SgCastExp* pointer = NULL;
  149450           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  149451           5 :      std::vector < unsigned char* > :: const_iterator block;
  149452           8 :      for ( block = SgCastExp::pools.begin(); block != SgCastExp::pools.end() ; ++block )
  149453             :         {
  149454           3 :           pointer = (SgCastExp*)(*block);
  149455        6003 :           for (unsigned i = 0; i < SgCastExp::pool_size; ++i )
  149456             :              {
  149457             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  149458             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  149459             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  149460             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  149461             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  149462             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  149463             :             // properly; so this will have to be checked next.
  149464             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  149465             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  149466        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  149467             :                   {
  149468        2261 :                     pointer[i].set_freepointer((SgCastExp*)(globalIndex));
  149469        2261 :                     globalIndex++;
  149470             :                   }
  149471             :                else
  149472             :                   {
  149473        3739 :                     pointer[i].set_freepointer(NULL);
  149474             :                   }
  149475             :               }
  149476             :         }
  149477           5 :      return globalIndex;
  149478             :    }
  149479             : 
  149480             : //############################################################################
  149481             : // JH (01/14/2006)
  149482             : void
  149483           5 : SgCastExp::resetValidFreepointers( )
  149484             :    {
  149485           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  149486           5 :      SgCastExp* pointer = NULL;
  149487           5 :      std::vector < unsigned char* > :: const_iterator block;
  149488           5 :      SgCastExp* pointerOfLinkedList = NULL;
  149489           8 :      for ( block = SgCastExp::pools.begin(); block != SgCastExp::pools.end() ; ++block )
  149490             :         {
  149491           3 :           pointer = (SgCastExp*)(*block);
  149492        6003 :           for (unsigned i = 0; i < SgCastExp::pool_size; ++i )
  149493             :              {
  149494             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  149495             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  149496             :             // memory blocks!.
  149497        6000 :                if ( pointer[i].get_freepointer() != NULL )
  149498             :                   {
  149499        2261 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  149500             :                   }
  149501             :                else
  149502             :                   {
  149503        3739 :                     if ( pointerOfLinkedList == NULL )
  149504             :                        {
  149505           2 :                          SgCastExp::next_node = &(pointer[i]);
  149506             :                        }
  149507             :                     else
  149508             :                        {
  149509             :                       // printf ("In SgCastExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  149510        3737 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  149511             :                        }
  149512             :                     pointerOfLinkedList = &(pointer[i]);
  149513             :                   }
  149514             :               }
  149515             :         }
  149516             : 
  149517           5 :      if ( pointerOfLinkedList != NULL )
  149518             :         {
  149519             :        // printf ("In SgCastExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  149520           2 :           pointerOfLinkedList->set_freepointer(NULL);
  149521             :        // DQ (6/6/2010): Temporary debugging...
  149522             :        //   ROSE_ASSERT(false);
  149523             :         }
  149524             : 
  149525           5 :      return ;
  149526             :    }
  149527             : 
  149528             : //############################################################################
  149529             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  149530             :  * within the memory pool and resets the freepointers, in order to achieve a 
  149531             :  * linked list, that has no jumps and starts at the beginning! This function 
  149532             :  * does not extend the memory pool, since we do not delete any memory blocks,
  149533             :  * but delete the valid objects.  
  149534             :  */
  149535             : void
  149536           0 : SgCastExp::clearMemoryPool( )
  149537             :    {
  149538             :   // printf ("Inside of SgCastExp::clearMemoryPool() \n");
  149539             : 
  149540           0 :      SgCastExp* pointer = NULL, *tempPointer = NULL;
  149541           0 :      std::vector < unsigned char* > :: const_iterator block;
  149542           0 :      if ( SgCastExp::pools.empty() == false )
  149543             :         {
  149544           0 :           block = SgCastExp::pools.begin() ;
  149545           0 :           SgCastExp::next_node = (SgCastExp*) (*block);
  149546             : 
  149547           0 :           while ( block != SgCastExp::pools.end() )
  149548             :              {
  149549           0 :                pointer = (SgCastExp*) (*block);
  149550           0 :                if ( tempPointer != NULL )
  149551             :                   {
  149552           0 :                     tempPointer->set_freepointer(pointer);
  149553             :                   }
  149554           0 :                for (unsigned i = 0; i < SgCastExp::pool_size - 1; ++i)
  149555             :                   {
  149556           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  149557             :                   }
  149558           0 :                 pointer[SgCastExp::pool_size-1].set_freepointer(NULL);
  149559           0 :                 tempPointer = &(pointer[SgCastExp::pool_size-1]);
  149560           0 :                 ++block;
  149561             :              }
  149562             :         }
  149563           0 :    }
  149564             : 
  149565           5 : void SgCastExp::deleteMemoryPool() {
  149566          11 :   for (auto p: SgCastExp::pools) {
  149567           6 :     ROSE_FREE(p);
  149568             :   }
  149569           5 :   SgCastExp::next_node = nullptr;
  149570           5 :   SgCastExp::pools.clear();
  149571           5 : }
  149572             : 
  149573             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  149574             : //                 reading multiple binary files to for a single AST.
  149575             : /////////// new version ////////////////////////////////
  149576             : //############################################################################
  149577             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  149578             : void
  149579           2 : SgCastExp::extendMemoryPoolForFileIO( )
  149580             :   {
  149581           2 :     size_t blockIndex = SgCastExp::pools.size();
  149582           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCastExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCastExp);
  149583             : 
  149584           5 :     while ( (blockIndex * SgCastExp::pool_size) < newPoolSize)
  149585             :       {
  149586             : #if ROSE_ALLOC_TRACE
  149587             :         if (blockIndex > 0) {
  149588             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCastExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCastExp) = %" PRIuPTR " SgCastExp::pool_size = %d \n",
  149589             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCastExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCastExp),SgCastExp::pool_size);
  149590             :         }
  149591             : #endif
  149592             : 
  149593           3 :         SgCastExp * pointer = (SgCastExp*) ROSE_MALLOC ( SgCastExp::pool_size * sizeof(SgCastExp) );
  149594           3 :         assert( pointer != NULL );
  149595             : #if ROSE_ALLOC_MEMSET == 1
  149596             :         memset(pointer, 0x00, SgCastExp::pool_size * sizeof(SgCastExp));
  149597             : #elif ROSE_ALLOC_MEMSET == 2
  149598             :         memset(pointer, 0xCC, SgCastExp::pool_size * sizeof(SgCastExp));
  149599             : #endif
  149600           3 :         SgCastExp::pools.push_back( (unsigned char*)(pointer) );
  149601           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCastExp::pool_size * sizeof(SgCastExp), V_SgCastExp ) );
  149602             : 
  149603           3 :         if ( SgCastExp::next_node != NULL ) {
  149604           1 :           if ( blockIndex > 0 ) {
  149605           1 :             SgCastExp * blkptr = (SgCastExp*)(SgCastExp::pools[blockIndex-1]);
  149606           1 :             blkptr[ SgCastExp::pool_size - 1 ].set_freepointer(pointer);
  149607             :           }
  149608             :         } else {
  149609           2 :           SgCastExp::next_node = pointer;
  149610             :         }
  149611             : 
  149612        6000 :         for (unsigned i = 0; i < SgCastExp::pool_size-1; ++i)
  149613             :            {
  149614        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  149615             :            }
  149616           3 :         pointer[ SgCastExp::pool_size -1 ].set_freepointer(NULL);
  149617             : 
  149618           3 :         blockIndex++;
  149619             :       }
  149620           2 :   }
  149621             : 
  149622             : //############################################################################
  149623             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  149624             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  149625             :  * not compressed. However, that stuff is not yet implemented! 
  149626             :  */
  149627             : unsigned long
  149628           0 : SgCastExp::getNumberOfLastValidPointer()
  149629             :    {
  149630           0 :       SgCastExp* testPointer = (SgCastExp*)(SgCastExp::pools.back());
  149631           0 :       unsigned long localIndex = SgCastExp::pool_size - 1;
  149632           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  149633             :          {
  149634           0 :            localIndex--;
  149635             :          }
  149636           0 :       return (localIndex + SgCastExp::pool_size * (SgCastExp::pools.size()-1));
  149637             :    }
  149638             : 
  149639             : //############################################################################
  149640             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  149641             :  * memory pool and initializes the data member in class SgCastExpStroageClass
  149642             :  * from its counterpart of SgCastExp. The return value is just for checking, 
  149643             :  * that the whole StorageClassArray is initialized!
  149644             :  */
  149645             : unsigned long
  149646           2 : SgCastExp::initializeStorageClassArray( SgCastExpStorageClass *storageArray )
  149647             :    {
  149648           2 :      unsigned long storageCounter = 0;
  149649           2 :      std::vector < unsigned char* > :: const_iterator block = SgCastExp::pools.begin();
  149650           2 :      SgCastExp* pointer = NULL;
  149651           5 :      while ( block != SgCastExp::pools.end() ) {
  149652           3 :           pointer = (SgCastExp*) (*block);
  149653        6003 :           for ( unsigned i = 0; i < SgCastExp::pool_size; ++i ) {
  149654        6000 :                if ( pointer->get_freepointer() != NULL ) {
  149655        2261 :                  storageArray->pickOutIRNodeData (pointer) ;
  149656        2261 :                  storageArray++;
  149657        2261 :                  storageCounter++;
  149658             :                }
  149659        6000 :                pointer++;
  149660             :              }
  149661           3 :            block++;
  149662             :         }
  149663           2 :      return storageCounter;
  149664             :    }
  149665             : 
  149666             : /* #line 149667 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  149667             : 
  149668             : 
  149669             : 
  149670             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  149671             : 
  149672             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  149673             : 
  149674             : //############################################################################
  149675             : /* JH (02/02/2006) Constructor of the IR node SgThrowOp that takes its 
  149676             :  * corresponding StorageClass as parameter
  149677             :  */
  149678          52 : SgThrowOp :: SgThrowOp ( const SgThrowOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  149679             :    {
  149680             : 
  149681             : 
  149682             : /* #line 149683 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  149683             : 
  149684          52 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  149685          52 :      p_throwKind = storageSource.storageOf_throwKind ;
  149686             : 
  149687             : 
  149688             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  149689             : 
  149690             : 
  149691          52 :    }
  149692             : 
  149693             : //############################################################################
  149694             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  149695             :  * within the working AST. 
  149696             :  */
  149697         210 : SgThrowOp * SgThrowOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  149698         210 :      SgThrowOp* returnPointer = NULL;
  149699         210 :      if ( globalIndex != 0 )
  149700             :         {
  149701             : 
  149702             : #if FILE_IO_EXTRA_CHECK
  149703         210 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgThrowOp ) ) <= globalIndex ) ;
  149704         210 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgThrowOp + 1 ) ) );
  149705             : #endif
  149706         210 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgThrowOp )  
  149707         210 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgThrowOp );
  149708         210 :           unsigned long positionInPool = localIndex % SgThrowOp::pool_size;
  149709         210 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgThrowOp::pool_size;
  149710             : 
  149711             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  149712             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  149713             : 
  149714         210 :           returnPointer = &( ( (SgThrowOp*)(SgThrowOp::pools[memoryBlock]) ) [positionInPool]) ;
  149715             : 
  149716         210 :           ROSE_ASSERT( returnPointer != NULL ) ;
  149717             :         }
  149718         210 :      return returnPointer ;
  149719             :    }
  149720             : 
  149721             : //############################################################################
  149722             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  149723             :   for the AST with the index astIndex
  149724             : */
  149725           0 : SgThrowOp * SgThrowOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  149726           0 :      SgThrowOp* returnPointer = NULL;
  149727           0 :      if ( globalIndex != 0 )
  149728             :         {
  149729             : 
  149730             : #if FILE_IO_EXTRA_CHECK
  149731           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgThrowOp ) ) <= globalIndex ) ;
  149732           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgThrowOp + 1 ) ) );
  149733             : #endif
  149734           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgThrowOp )
  149735           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgThrowOp );
  149736           0 :           unsigned long positionInPool = localIndex % SgThrowOp::pool_size ;
  149737           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgThrowOp::pool_size ;
  149738             : 
  149739             : #if FILE_IO_EXTRA_CHECK
  149740             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  149741             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  149742             : #endif
  149743             : 
  149744           0 :           returnPointer = &( ( (SgThrowOp*)(SgThrowOp::pools[memoryBlock]) ) [positionInPool]) ;
  149745             : 
  149746             : #if FILE_IO_EXTRA_CHECK
  149747           0 :           assert ( returnPointer != NULL ) ;
  149748             : #endif
  149749             :         }
  149750           0 :      return returnPointer ;
  149751             :    }
  149752             : 
  149753             : //############################################################################
  149754             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  149755             :  * pool size! We set for every valid object in the memory pool the freepointer
  149756             :  * to the global index and increase the global index afterwards. For all the 
  149757             :  * invalid objects (means address ranges within the memory pool that were not
  149758             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  149759             :  * distinguish valid from invalid objects! 
  149760             :  */
  149761             : unsigned long
  149762           5 : SgThrowOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  149763             :    {
  149764           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  149765           5 :      SgThrowOp* pointer = NULL;
  149766           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  149767           5 :      std::vector < unsigned char* > :: const_iterator block;
  149768           6 :      for ( block = SgThrowOp::pools.begin(); block != SgThrowOp::pools.end() ; ++block )
  149769             :         {
  149770           1 :           pointer = (SgThrowOp*)(*block);
  149771        2001 :           for (unsigned i = 0; i < SgThrowOp::pool_size; ++i )
  149772             :              {
  149773             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  149774             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  149775             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  149776             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  149777             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  149778             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  149779             :             // properly; so this will have to be checked next.
  149780             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  149781             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  149782        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  149783             :                   {
  149784          52 :                     pointer[i].set_freepointer((SgThrowOp*)(globalIndex));
  149785          52 :                     globalIndex++;
  149786             :                   }
  149787             :                else
  149788             :                   {
  149789        1948 :                     pointer[i].set_freepointer(NULL);
  149790             :                   }
  149791             :               }
  149792             :         }
  149793           5 :      return globalIndex;
  149794             :    }
  149795             : 
  149796             : //############################################################################
  149797             : // JH (01/14/2006)
  149798             : void
  149799           5 : SgThrowOp::resetValidFreepointers( )
  149800             :    {
  149801           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  149802           5 :      SgThrowOp* pointer = NULL;
  149803           5 :      std::vector < unsigned char* > :: const_iterator block;
  149804           5 :      SgThrowOp* pointerOfLinkedList = NULL;
  149805           6 :      for ( block = SgThrowOp::pools.begin(); block != SgThrowOp::pools.end() ; ++block )
  149806             :         {
  149807           1 :           pointer = (SgThrowOp*)(*block);
  149808        2001 :           for (unsigned i = 0; i < SgThrowOp::pool_size; ++i )
  149809             :              {
  149810             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  149811             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  149812             :             // memory blocks!.
  149813        2000 :                if ( pointer[i].get_freepointer() != NULL )
  149814             :                   {
  149815          52 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  149816             :                   }
  149817             :                else
  149818             :                   {
  149819        1948 :                     if ( pointerOfLinkedList == NULL )
  149820             :                        {
  149821           1 :                          SgThrowOp::next_node = &(pointer[i]);
  149822             :                        }
  149823             :                     else
  149824             :                        {
  149825             :                       // printf ("In SgThrowOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  149826        1947 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  149827             :                        }
  149828             :                     pointerOfLinkedList = &(pointer[i]);
  149829             :                   }
  149830             :               }
  149831             :         }
  149832             : 
  149833           5 :      if ( pointerOfLinkedList != NULL )
  149834             :         {
  149835             :        // printf ("In SgThrowOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  149836           1 :           pointerOfLinkedList->set_freepointer(NULL);
  149837             :        // DQ (6/6/2010): Temporary debugging...
  149838             :        //   ROSE_ASSERT(false);
  149839             :         }
  149840             : 
  149841           5 :      return ;
  149842             :    }
  149843             : 
  149844             : //############################################################################
  149845             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  149846             :  * within the memory pool and resets the freepointers, in order to achieve a 
  149847             :  * linked list, that has no jumps and starts at the beginning! This function 
  149848             :  * does not extend the memory pool, since we do not delete any memory blocks,
  149849             :  * but delete the valid objects.  
  149850             :  */
  149851             : void
  149852           0 : SgThrowOp::clearMemoryPool( )
  149853             :    {
  149854             :   // printf ("Inside of SgThrowOp::clearMemoryPool() \n");
  149855             : 
  149856           0 :      SgThrowOp* pointer = NULL, *tempPointer = NULL;
  149857           0 :      std::vector < unsigned char* > :: const_iterator block;
  149858           0 :      if ( SgThrowOp::pools.empty() == false )
  149859             :         {
  149860           0 :           block = SgThrowOp::pools.begin() ;
  149861           0 :           SgThrowOp::next_node = (SgThrowOp*) (*block);
  149862             : 
  149863           0 :           while ( block != SgThrowOp::pools.end() )
  149864             :              {
  149865           0 :                pointer = (SgThrowOp*) (*block);
  149866           0 :                if ( tempPointer != NULL )
  149867             :                   {
  149868           0 :                     tempPointer->set_freepointer(pointer);
  149869             :                   }
  149870           0 :                for (unsigned i = 0; i < SgThrowOp::pool_size - 1; ++i)
  149871             :                   {
  149872           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  149873             :                   }
  149874           0 :                 pointer[SgThrowOp::pool_size-1].set_freepointer(NULL);
  149875           0 :                 tempPointer = &(pointer[SgThrowOp::pool_size-1]);
  149876           0 :                 ++block;
  149877             :              }
  149878             :         }
  149879           0 :    }
  149880             : 
  149881           5 : void SgThrowOp::deleteMemoryPool() {
  149882           7 :   for (auto p: SgThrowOp::pools) {
  149883           2 :     ROSE_FREE(p);
  149884             :   }
  149885           5 :   SgThrowOp::next_node = nullptr;
  149886           5 :   SgThrowOp::pools.clear();
  149887           5 : }
  149888             : 
  149889             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  149890             : //                 reading multiple binary files to for a single AST.
  149891             : /////////// new version ////////////////////////////////
  149892             : //############################################################################
  149893             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  149894             : void
  149895           2 : SgThrowOp::extendMemoryPoolForFileIO( )
  149896             :   {
  149897           2 :     size_t blockIndex = SgThrowOp::pools.size();
  149898           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgThrowOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgThrowOp);
  149899             : 
  149900           3 :     while ( (blockIndex * SgThrowOp::pool_size) < newPoolSize)
  149901             :       {
  149902             : #if ROSE_ALLOC_TRACE
  149903             :         if (blockIndex > 0) {
  149904             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgThrowOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgThrowOp) = %" PRIuPTR " SgThrowOp::pool_size = %d \n",
  149905             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgThrowOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgThrowOp),SgThrowOp::pool_size);
  149906             :         }
  149907             : #endif
  149908             : 
  149909           1 :         SgThrowOp * pointer = (SgThrowOp*) ROSE_MALLOC ( SgThrowOp::pool_size * sizeof(SgThrowOp) );
  149910           1 :         assert( pointer != NULL );
  149911             : #if ROSE_ALLOC_MEMSET == 1
  149912             :         memset(pointer, 0x00, SgThrowOp::pool_size * sizeof(SgThrowOp));
  149913             : #elif ROSE_ALLOC_MEMSET == 2
  149914             :         memset(pointer, 0xCC, SgThrowOp::pool_size * sizeof(SgThrowOp));
  149915             : #endif
  149916           1 :         SgThrowOp::pools.push_back( (unsigned char*)(pointer) );
  149917           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgThrowOp::pool_size * sizeof(SgThrowOp), V_SgThrowOp ) );
  149918             : 
  149919           1 :         if ( SgThrowOp::next_node != NULL ) {
  149920           0 :           if ( blockIndex > 0 ) {
  149921           0 :             SgThrowOp * blkptr = (SgThrowOp*)(SgThrowOp::pools[blockIndex-1]);
  149922           0 :             blkptr[ SgThrowOp::pool_size - 1 ].set_freepointer(pointer);
  149923             :           }
  149924             :         } else {
  149925           1 :           SgThrowOp::next_node = pointer;
  149926             :         }
  149927             : 
  149928        2000 :         for (unsigned i = 0; i < SgThrowOp::pool_size-1; ++i)
  149929             :            {
  149930        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  149931             :            }
  149932           1 :         pointer[ SgThrowOp::pool_size -1 ].set_freepointer(NULL);
  149933             : 
  149934           1 :         blockIndex++;
  149935             :       }
  149936           2 :   }
  149937             : 
  149938             : //############################################################################
  149939             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  149940             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  149941             :  * not compressed. However, that stuff is not yet implemented! 
  149942             :  */
  149943             : unsigned long
  149944           0 : SgThrowOp::getNumberOfLastValidPointer()
  149945             :    {
  149946           0 :       SgThrowOp* testPointer = (SgThrowOp*)(SgThrowOp::pools.back());
  149947           0 :       unsigned long localIndex = SgThrowOp::pool_size - 1;
  149948           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  149949             :          {
  149950           0 :            localIndex--;
  149951             :          }
  149952           0 :       return (localIndex + SgThrowOp::pool_size * (SgThrowOp::pools.size()-1));
  149953             :    }
  149954             : 
  149955             : //############################################################################
  149956             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  149957             :  * memory pool and initializes the data member in class SgThrowOpStroageClass
  149958             :  * from its counterpart of SgThrowOp. The return value is just for checking, 
  149959             :  * that the whole StorageClassArray is initialized!
  149960             :  */
  149961             : unsigned long
  149962           1 : SgThrowOp::initializeStorageClassArray( SgThrowOpStorageClass *storageArray )
  149963             :    {
  149964           1 :      unsigned long storageCounter = 0;
  149965           1 :      std::vector < unsigned char* > :: const_iterator block = SgThrowOp::pools.begin();
  149966           1 :      SgThrowOp* pointer = NULL;
  149967           2 :      while ( block != SgThrowOp::pools.end() ) {
  149968           1 :           pointer = (SgThrowOp*) (*block);
  149969        2001 :           for ( unsigned i = 0; i < SgThrowOp::pool_size; ++i ) {
  149970        2000 :                if ( pointer->get_freepointer() != NULL ) {
  149971          52 :                  storageArray->pickOutIRNodeData (pointer) ;
  149972          52 :                  storageArray++;
  149973          52 :                  storageCounter++;
  149974             :                }
  149975        2000 :                pointer++;
  149976             :              }
  149977           1 :            block++;
  149978             :         }
  149979           1 :      return storageCounter;
  149980             :    }
  149981             : 
  149982             : /* #line 149983 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  149983             : 
  149984             : 
  149985             : 
  149986             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  149987             : 
  149988             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  149989             : 
  149990             : //############################################################################
  149991             : /* JH (02/02/2006) Constructor of the IR node SgRealPartOp that takes its 
  149992             :  * corresponding StorageClass as parameter
  149993             :  */
  149994           0 : SgRealPartOp :: SgRealPartOp ( const SgRealPartOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  149995             :    {
  149996             : 
  149997             : 
  149998             : /* #line 149999 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  149999             : 
  150000           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  150001             : 
  150002             : 
  150003             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  150004             : 
  150005             : 
  150006           0 :    }
  150007             : 
  150008             : //############################################################################
  150009             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  150010             :  * within the working AST. 
  150011             :  */
  150012           0 : SgRealPartOp * SgRealPartOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  150013           0 :      SgRealPartOp* returnPointer = NULL;
  150014           0 :      if ( globalIndex != 0 )
  150015             :         {
  150016             : 
  150017             : #if FILE_IO_EXTRA_CHECK
  150018           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRealPartOp ) ) <= globalIndex ) ;
  150019           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRealPartOp + 1 ) ) );
  150020             : #endif
  150021           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRealPartOp )  
  150022           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRealPartOp );
  150023           0 :           unsigned long positionInPool = localIndex % SgRealPartOp::pool_size;
  150024           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRealPartOp::pool_size;
  150025             : 
  150026             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  150027             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  150028             : 
  150029           0 :           returnPointer = &( ( (SgRealPartOp*)(SgRealPartOp::pools[memoryBlock]) ) [positionInPool]) ;
  150030             : 
  150031           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  150032             :         }
  150033           0 :      return returnPointer ;
  150034             :    }
  150035             : 
  150036             : //############################################################################
  150037             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  150038             :   for the AST with the index astIndex
  150039             : */
  150040           0 : SgRealPartOp * SgRealPartOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  150041           0 :      SgRealPartOp* returnPointer = NULL;
  150042           0 :      if ( globalIndex != 0 )
  150043             :         {
  150044             : 
  150045             : #if FILE_IO_EXTRA_CHECK
  150046           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRealPartOp ) ) <= globalIndex ) ;
  150047           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRealPartOp + 1 ) ) );
  150048             : #endif
  150049           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRealPartOp )
  150050           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRealPartOp );
  150051           0 :           unsigned long positionInPool = localIndex % SgRealPartOp::pool_size ;
  150052           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRealPartOp::pool_size ;
  150053             : 
  150054             : #if FILE_IO_EXTRA_CHECK
  150055             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  150056             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  150057             : #endif
  150058             : 
  150059           0 :           returnPointer = &( ( (SgRealPartOp*)(SgRealPartOp::pools[memoryBlock]) ) [positionInPool]) ;
  150060             : 
  150061             : #if FILE_IO_EXTRA_CHECK
  150062           0 :           assert ( returnPointer != NULL ) ;
  150063             : #endif
  150064             :         }
  150065           0 :      return returnPointer ;
  150066             :    }
  150067             : 
  150068             : //############################################################################
  150069             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  150070             :  * pool size! We set for every valid object in the memory pool the freepointer
  150071             :  * to the global index and increase the global index afterwards. For all the 
  150072             :  * invalid objects (means address ranges within the memory pool that were not
  150073             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  150074             :  * distinguish valid from invalid objects! 
  150075             :  */
  150076             : unsigned long
  150077           5 : SgRealPartOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  150078             :    {
  150079           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  150080           5 :      SgRealPartOp* pointer = NULL;
  150081           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  150082           5 :      std::vector < unsigned char* > :: const_iterator block;
  150083           5 :      for ( block = SgRealPartOp::pools.begin(); block != SgRealPartOp::pools.end() ; ++block )
  150084             :         {
  150085           0 :           pointer = (SgRealPartOp*)(*block);
  150086           0 :           for (unsigned i = 0; i < SgRealPartOp::pool_size; ++i )
  150087             :              {
  150088             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  150089             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  150090             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  150091             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  150092             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  150093             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  150094             :             // properly; so this will have to be checked next.
  150095             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  150096             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  150097           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  150098             :                   {
  150099           0 :                     pointer[i].set_freepointer((SgRealPartOp*)(globalIndex));
  150100           0 :                     globalIndex++;
  150101             :                   }
  150102             :                else
  150103             :                   {
  150104           0 :                     pointer[i].set_freepointer(NULL);
  150105             :                   }
  150106             :               }
  150107             :         }
  150108           5 :      return globalIndex;
  150109             :    }
  150110             : 
  150111             : //############################################################################
  150112             : // JH (01/14/2006)
  150113             : void
  150114           5 : SgRealPartOp::resetValidFreepointers( )
  150115             :    {
  150116           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  150117           5 :      SgRealPartOp* pointer = NULL;
  150118           5 :      std::vector < unsigned char* > :: const_iterator block;
  150119           5 :      SgRealPartOp* pointerOfLinkedList = NULL;
  150120           5 :      for ( block = SgRealPartOp::pools.begin(); block != SgRealPartOp::pools.end() ; ++block )
  150121             :         {
  150122           0 :           pointer = (SgRealPartOp*)(*block);
  150123           0 :           for (unsigned i = 0; i < SgRealPartOp::pool_size; ++i )
  150124             :              {
  150125             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  150126             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  150127             :             // memory blocks!.
  150128           0 :                if ( pointer[i].get_freepointer() != NULL )
  150129             :                   {
  150130           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  150131             :                   }
  150132             :                else
  150133             :                   {
  150134           0 :                     if ( pointerOfLinkedList == NULL )
  150135             :                        {
  150136           0 :                          SgRealPartOp::next_node = &(pointer[i]);
  150137             :                        }
  150138             :                     else
  150139             :                        {
  150140             :                       // printf ("In SgRealPartOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  150141           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  150142             :                        }
  150143             :                     pointerOfLinkedList = &(pointer[i]);
  150144             :                   }
  150145             :               }
  150146             :         }
  150147             : 
  150148           5 :      if ( pointerOfLinkedList != NULL )
  150149             :         {
  150150             :        // printf ("In SgRealPartOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  150151           0 :           pointerOfLinkedList->set_freepointer(NULL);
  150152             :        // DQ (6/6/2010): Temporary debugging...
  150153             :        //   ROSE_ASSERT(false);
  150154             :         }
  150155             : 
  150156           5 :      return ;
  150157             :    }
  150158             : 
  150159             : //############################################################################
  150160             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  150161             :  * within the memory pool and resets the freepointers, in order to achieve a 
  150162             :  * linked list, that has no jumps and starts at the beginning! This function 
  150163             :  * does not extend the memory pool, since we do not delete any memory blocks,
  150164             :  * but delete the valid objects.  
  150165             :  */
  150166             : void
  150167           0 : SgRealPartOp::clearMemoryPool( )
  150168             :    {
  150169             :   // printf ("Inside of SgRealPartOp::clearMemoryPool() \n");
  150170             : 
  150171           0 :      SgRealPartOp* pointer = NULL, *tempPointer = NULL;
  150172           0 :      std::vector < unsigned char* > :: const_iterator block;
  150173           0 :      if ( SgRealPartOp::pools.empty() == false )
  150174             :         {
  150175           0 :           block = SgRealPartOp::pools.begin() ;
  150176           0 :           SgRealPartOp::next_node = (SgRealPartOp*) (*block);
  150177             : 
  150178           0 :           while ( block != SgRealPartOp::pools.end() )
  150179             :              {
  150180           0 :                pointer = (SgRealPartOp*) (*block);
  150181           0 :                if ( tempPointer != NULL )
  150182             :                   {
  150183           0 :                     tempPointer->set_freepointer(pointer);
  150184             :                   }
  150185           0 :                for (unsigned i = 0; i < SgRealPartOp::pool_size - 1; ++i)
  150186             :                   {
  150187           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  150188             :                   }
  150189           0 :                 pointer[SgRealPartOp::pool_size-1].set_freepointer(NULL);
  150190           0 :                 tempPointer = &(pointer[SgRealPartOp::pool_size-1]);
  150191           0 :                 ++block;
  150192             :              }
  150193             :         }
  150194           0 :    }
  150195             : 
  150196           5 : void SgRealPartOp::deleteMemoryPool() {
  150197           5 :   for (auto p: SgRealPartOp::pools) {
  150198           0 :     ROSE_FREE(p);
  150199             :   }
  150200           5 :   SgRealPartOp::next_node = nullptr;
  150201           5 :   SgRealPartOp::pools.clear();
  150202           5 : }
  150203             : 
  150204             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  150205             : //                 reading multiple binary files to for a single AST.
  150206             : /////////// new version ////////////////////////////////
  150207             : //############################################################################
  150208             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  150209             : void
  150210           2 : SgRealPartOp::extendMemoryPoolForFileIO( )
  150211             :   {
  150212           2 :     size_t blockIndex = SgRealPartOp::pools.size();
  150213           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRealPartOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRealPartOp);
  150214             : 
  150215           2 :     while ( (blockIndex * SgRealPartOp::pool_size) < newPoolSize)
  150216             :       {
  150217             : #if ROSE_ALLOC_TRACE
  150218             :         if (blockIndex > 0) {
  150219             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRealPartOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRealPartOp) = %" PRIuPTR " SgRealPartOp::pool_size = %d \n",
  150220             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRealPartOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRealPartOp),SgRealPartOp::pool_size);
  150221             :         }
  150222             : #endif
  150223             : 
  150224           0 :         SgRealPartOp * pointer = (SgRealPartOp*) ROSE_MALLOC ( SgRealPartOp::pool_size * sizeof(SgRealPartOp) );
  150225           0 :         assert( pointer != NULL );
  150226             : #if ROSE_ALLOC_MEMSET == 1
  150227             :         memset(pointer, 0x00, SgRealPartOp::pool_size * sizeof(SgRealPartOp));
  150228             : #elif ROSE_ALLOC_MEMSET == 2
  150229             :         memset(pointer, 0xCC, SgRealPartOp::pool_size * sizeof(SgRealPartOp));
  150230             : #endif
  150231           0 :         SgRealPartOp::pools.push_back( (unsigned char*)(pointer) );
  150232           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRealPartOp::pool_size * sizeof(SgRealPartOp), V_SgRealPartOp ) );
  150233             : 
  150234           0 :         if ( SgRealPartOp::next_node != NULL ) {
  150235           0 :           if ( blockIndex > 0 ) {
  150236           0 :             SgRealPartOp * blkptr = (SgRealPartOp*)(SgRealPartOp::pools[blockIndex-1]);
  150237           0 :             blkptr[ SgRealPartOp::pool_size - 1 ].set_freepointer(pointer);
  150238             :           }
  150239             :         } else {
  150240           0 :           SgRealPartOp::next_node = pointer;
  150241             :         }
  150242             : 
  150243           0 :         for (unsigned i = 0; i < SgRealPartOp::pool_size-1; ++i)
  150244             :            {
  150245           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  150246             :            }
  150247           0 :         pointer[ SgRealPartOp::pool_size -1 ].set_freepointer(NULL);
  150248             : 
  150249           0 :         blockIndex++;
  150250             :       }
  150251           2 :   }
  150252             : 
  150253             : //############################################################################
  150254             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  150255             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  150256             :  * not compressed. However, that stuff is not yet implemented! 
  150257             :  */
  150258             : unsigned long
  150259           0 : SgRealPartOp::getNumberOfLastValidPointer()
  150260             :    {
  150261           0 :       SgRealPartOp* testPointer = (SgRealPartOp*)(SgRealPartOp::pools.back());
  150262           0 :       unsigned long localIndex = SgRealPartOp::pool_size - 1;
  150263           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  150264             :          {
  150265           0 :            localIndex--;
  150266             :          }
  150267           0 :       return (localIndex + SgRealPartOp::pool_size * (SgRealPartOp::pools.size()-1));
  150268             :    }
  150269             : 
  150270             : //############################################################################
  150271             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  150272             :  * memory pool and initializes the data member in class SgRealPartOpStroageClass
  150273             :  * from its counterpart of SgRealPartOp. The return value is just for checking, 
  150274             :  * that the whole StorageClassArray is initialized!
  150275             :  */
  150276             : unsigned long
  150277           0 : SgRealPartOp::initializeStorageClassArray( SgRealPartOpStorageClass *storageArray )
  150278             :    {
  150279           0 :      unsigned long storageCounter = 0;
  150280           0 :      std::vector < unsigned char* > :: const_iterator block = SgRealPartOp::pools.begin();
  150281           0 :      SgRealPartOp* pointer = NULL;
  150282           0 :      while ( block != SgRealPartOp::pools.end() ) {
  150283           0 :           pointer = (SgRealPartOp*) (*block);
  150284           0 :           for ( unsigned i = 0; i < SgRealPartOp::pool_size; ++i ) {
  150285           0 :                if ( pointer->get_freepointer() != NULL ) {
  150286           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  150287           0 :                  storageArray++;
  150288           0 :                  storageCounter++;
  150289             :                }
  150290           0 :                pointer++;
  150291             :              }
  150292           0 :            block++;
  150293             :         }
  150294           0 :      return storageCounter;
  150295             :    }
  150296             : 
  150297             : /* #line 150298 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  150298             : 
  150299             : 
  150300             : 
  150301             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  150302             : 
  150303             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  150304             : 
  150305             : //############################################################################
  150306             : /* JH (02/02/2006) Constructor of the IR node SgImagPartOp that takes its 
  150307             :  * corresponding StorageClass as parameter
  150308             :  */
  150309           0 : SgImagPartOp :: SgImagPartOp ( const SgImagPartOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  150310             :    {
  150311             : 
  150312             : 
  150313             : /* #line 150314 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  150314             : 
  150315           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  150316             : 
  150317             : 
  150318             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  150319             : 
  150320             : 
  150321           0 :    }
  150322             : 
  150323             : //############################################################################
  150324             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  150325             :  * within the working AST. 
  150326             :  */
  150327           0 : SgImagPartOp * SgImagPartOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  150328           0 :      SgImagPartOp* returnPointer = NULL;
  150329           0 :      if ( globalIndex != 0 )
  150330             :         {
  150331             : 
  150332             : #if FILE_IO_EXTRA_CHECK
  150333           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgImagPartOp ) ) <= globalIndex ) ;
  150334           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImagPartOp + 1 ) ) );
  150335             : #endif
  150336           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImagPartOp )  
  150337           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgImagPartOp );
  150338           0 :           unsigned long positionInPool = localIndex % SgImagPartOp::pool_size;
  150339           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImagPartOp::pool_size;
  150340             : 
  150341             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  150342             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  150343             : 
  150344           0 :           returnPointer = &( ( (SgImagPartOp*)(SgImagPartOp::pools[memoryBlock]) ) [positionInPool]) ;
  150345             : 
  150346           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  150347             :         }
  150348           0 :      return returnPointer ;
  150349             :    }
  150350             : 
  150351             : //############################################################################
  150352             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  150353             :   for the AST with the index astIndex
  150354             : */
  150355           0 : SgImagPartOp * SgImagPartOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  150356           0 :      SgImagPartOp* returnPointer = NULL;
  150357           0 :      if ( globalIndex != 0 )
  150358             :         {
  150359             : 
  150360             : #if FILE_IO_EXTRA_CHECK
  150361           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgImagPartOp ) ) <= globalIndex ) ;
  150362           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImagPartOp + 1 ) ) );
  150363             : #endif
  150364           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImagPartOp )
  150365           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgImagPartOp );
  150366           0 :           unsigned long positionInPool = localIndex % SgImagPartOp::pool_size ;
  150367           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImagPartOp::pool_size ;
  150368             : 
  150369             : #if FILE_IO_EXTRA_CHECK
  150370             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  150371             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  150372             : #endif
  150373             : 
  150374           0 :           returnPointer = &( ( (SgImagPartOp*)(SgImagPartOp::pools[memoryBlock]) ) [positionInPool]) ;
  150375             : 
  150376             : #if FILE_IO_EXTRA_CHECK
  150377           0 :           assert ( returnPointer != NULL ) ;
  150378             : #endif
  150379             :         }
  150380           0 :      return returnPointer ;
  150381             :    }
  150382             : 
  150383             : //############################################################################
  150384             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  150385             :  * pool size! We set for every valid object in the memory pool the freepointer
  150386             :  * to the global index and increase the global index afterwards. For all the 
  150387             :  * invalid objects (means address ranges within the memory pool that were not
  150388             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  150389             :  * distinguish valid from invalid objects! 
  150390             :  */
  150391             : unsigned long
  150392           5 : SgImagPartOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  150393             :    {
  150394           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  150395           5 :      SgImagPartOp* pointer = NULL;
  150396           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  150397           5 :      std::vector < unsigned char* > :: const_iterator block;
  150398           5 :      for ( block = SgImagPartOp::pools.begin(); block != SgImagPartOp::pools.end() ; ++block )
  150399             :         {
  150400           0 :           pointer = (SgImagPartOp*)(*block);
  150401           0 :           for (unsigned i = 0; i < SgImagPartOp::pool_size; ++i )
  150402             :              {
  150403             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  150404             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  150405             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  150406             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  150407             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  150408             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  150409             :             // properly; so this will have to be checked next.
  150410             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  150411             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  150412           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  150413             :                   {
  150414           0 :                     pointer[i].set_freepointer((SgImagPartOp*)(globalIndex));
  150415           0 :                     globalIndex++;
  150416             :                   }
  150417             :                else
  150418             :                   {
  150419           0 :                     pointer[i].set_freepointer(NULL);
  150420             :                   }
  150421             :               }
  150422             :         }
  150423           5 :      return globalIndex;
  150424             :    }
  150425             : 
  150426             : //############################################################################
  150427             : // JH (01/14/2006)
  150428             : void
  150429           5 : SgImagPartOp::resetValidFreepointers( )
  150430             :    {
  150431           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  150432           5 :      SgImagPartOp* pointer = NULL;
  150433           5 :      std::vector < unsigned char* > :: const_iterator block;
  150434           5 :      SgImagPartOp* pointerOfLinkedList = NULL;
  150435           5 :      for ( block = SgImagPartOp::pools.begin(); block != SgImagPartOp::pools.end() ; ++block )
  150436             :         {
  150437           0 :           pointer = (SgImagPartOp*)(*block);
  150438           0 :           for (unsigned i = 0; i < SgImagPartOp::pool_size; ++i )
  150439             :              {
  150440             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  150441             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  150442             :             // memory blocks!.
  150443           0 :                if ( pointer[i].get_freepointer() != NULL )
  150444             :                   {
  150445           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  150446             :                   }
  150447             :                else
  150448             :                   {
  150449           0 :                     if ( pointerOfLinkedList == NULL )
  150450             :                        {
  150451           0 :                          SgImagPartOp::next_node = &(pointer[i]);
  150452             :                        }
  150453             :                     else
  150454             :                        {
  150455             :                       // printf ("In SgImagPartOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  150456           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  150457             :                        }
  150458             :                     pointerOfLinkedList = &(pointer[i]);
  150459             :                   }
  150460             :               }
  150461             :         }
  150462             : 
  150463           5 :      if ( pointerOfLinkedList != NULL )
  150464             :         {
  150465             :        // printf ("In SgImagPartOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  150466           0 :           pointerOfLinkedList->set_freepointer(NULL);
  150467             :        // DQ (6/6/2010): Temporary debugging...
  150468             :        //   ROSE_ASSERT(false);
  150469             :         }
  150470             : 
  150471           5 :      return ;
  150472             :    }
  150473             : 
  150474             : //############################################################################
  150475             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  150476             :  * within the memory pool and resets the freepointers, in order to achieve a 
  150477             :  * linked list, that has no jumps and starts at the beginning! This function 
  150478             :  * does not extend the memory pool, since we do not delete any memory blocks,
  150479             :  * but delete the valid objects.  
  150480             :  */
  150481             : void
  150482           0 : SgImagPartOp::clearMemoryPool( )
  150483             :    {
  150484             :   // printf ("Inside of SgImagPartOp::clearMemoryPool() \n");
  150485             : 
  150486           0 :      SgImagPartOp* pointer = NULL, *tempPointer = NULL;
  150487           0 :      std::vector < unsigned char* > :: const_iterator block;
  150488           0 :      if ( SgImagPartOp::pools.empty() == false )
  150489             :         {
  150490           0 :           block = SgImagPartOp::pools.begin() ;
  150491           0 :           SgImagPartOp::next_node = (SgImagPartOp*) (*block);
  150492             : 
  150493           0 :           while ( block != SgImagPartOp::pools.end() )
  150494             :              {
  150495           0 :                pointer = (SgImagPartOp*) (*block);
  150496           0 :                if ( tempPointer != NULL )
  150497             :                   {
  150498           0 :                     tempPointer->set_freepointer(pointer);
  150499             :                   }
  150500           0 :                for (unsigned i = 0; i < SgImagPartOp::pool_size - 1; ++i)
  150501             :                   {
  150502           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  150503             :                   }
  150504           0 :                 pointer[SgImagPartOp::pool_size-1].set_freepointer(NULL);
  150505           0 :                 tempPointer = &(pointer[SgImagPartOp::pool_size-1]);
  150506           0 :                 ++block;
  150507             :              }
  150508             :         }
  150509           0 :    }
  150510             : 
  150511           5 : void SgImagPartOp::deleteMemoryPool() {
  150512           5 :   for (auto p: SgImagPartOp::pools) {
  150513           0 :     ROSE_FREE(p);
  150514             :   }
  150515           5 :   SgImagPartOp::next_node = nullptr;
  150516           5 :   SgImagPartOp::pools.clear();
  150517           5 : }
  150518             : 
  150519             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  150520             : //                 reading multiple binary files to for a single AST.
  150521             : /////////// new version ////////////////////////////////
  150522             : //############################################################################
  150523             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  150524             : void
  150525           2 : SgImagPartOp::extendMemoryPoolForFileIO( )
  150526             :   {
  150527           2 :     size_t blockIndex = SgImagPartOp::pools.size();
  150528           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgImagPartOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgImagPartOp);
  150529             : 
  150530           2 :     while ( (blockIndex * SgImagPartOp::pool_size) < newPoolSize)
  150531             :       {
  150532             : #if ROSE_ALLOC_TRACE
  150533             :         if (blockIndex > 0) {
  150534             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgImagPartOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgImagPartOp) = %" PRIuPTR " SgImagPartOp::pool_size = %d \n",
  150535             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgImagPartOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgImagPartOp),SgImagPartOp::pool_size);
  150536             :         }
  150537             : #endif
  150538             : 
  150539           0 :         SgImagPartOp * pointer = (SgImagPartOp*) ROSE_MALLOC ( SgImagPartOp::pool_size * sizeof(SgImagPartOp) );
  150540           0 :         assert( pointer != NULL );
  150541             : #if ROSE_ALLOC_MEMSET == 1
  150542             :         memset(pointer, 0x00, SgImagPartOp::pool_size * sizeof(SgImagPartOp));
  150543             : #elif ROSE_ALLOC_MEMSET == 2
  150544             :         memset(pointer, 0xCC, SgImagPartOp::pool_size * sizeof(SgImagPartOp));
  150545             : #endif
  150546           0 :         SgImagPartOp::pools.push_back( (unsigned char*)(pointer) );
  150547           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgImagPartOp::pool_size * sizeof(SgImagPartOp), V_SgImagPartOp ) );
  150548             : 
  150549           0 :         if ( SgImagPartOp::next_node != NULL ) {
  150550           0 :           if ( blockIndex > 0 ) {
  150551           0 :             SgImagPartOp * blkptr = (SgImagPartOp*)(SgImagPartOp::pools[blockIndex-1]);
  150552           0 :             blkptr[ SgImagPartOp::pool_size - 1 ].set_freepointer(pointer);
  150553             :           }
  150554             :         } else {
  150555           0 :           SgImagPartOp::next_node = pointer;
  150556             :         }
  150557             : 
  150558           0 :         for (unsigned i = 0; i < SgImagPartOp::pool_size-1; ++i)
  150559             :            {
  150560           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  150561             :            }
  150562           0 :         pointer[ SgImagPartOp::pool_size -1 ].set_freepointer(NULL);
  150563             : 
  150564           0 :         blockIndex++;
  150565             :       }
  150566           2 :   }
  150567             : 
  150568             : //############################################################################
  150569             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  150570             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  150571             :  * not compressed. However, that stuff is not yet implemented! 
  150572             :  */
  150573             : unsigned long
  150574           0 : SgImagPartOp::getNumberOfLastValidPointer()
  150575             :    {
  150576           0 :       SgImagPartOp* testPointer = (SgImagPartOp*)(SgImagPartOp::pools.back());
  150577           0 :       unsigned long localIndex = SgImagPartOp::pool_size - 1;
  150578           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  150579             :          {
  150580           0 :            localIndex--;
  150581             :          }
  150582           0 :       return (localIndex + SgImagPartOp::pool_size * (SgImagPartOp::pools.size()-1));
  150583             :    }
  150584             : 
  150585             : //############################################################################
  150586             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  150587             :  * memory pool and initializes the data member in class SgImagPartOpStroageClass
  150588             :  * from its counterpart of SgImagPartOp. The return value is just for checking, 
  150589             :  * that the whole StorageClassArray is initialized!
  150590             :  */
  150591             : unsigned long
  150592           0 : SgImagPartOp::initializeStorageClassArray( SgImagPartOpStorageClass *storageArray )
  150593             :    {
  150594           0 :      unsigned long storageCounter = 0;
  150595           0 :      std::vector < unsigned char* > :: const_iterator block = SgImagPartOp::pools.begin();
  150596           0 :      SgImagPartOp* pointer = NULL;
  150597           0 :      while ( block != SgImagPartOp::pools.end() ) {
  150598           0 :           pointer = (SgImagPartOp*) (*block);
  150599           0 :           for ( unsigned i = 0; i < SgImagPartOp::pool_size; ++i ) {
  150600           0 :                if ( pointer->get_freepointer() != NULL ) {
  150601           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  150602           0 :                  storageArray++;
  150603           0 :                  storageCounter++;
  150604             :                }
  150605           0 :                pointer++;
  150606             :              }
  150607           0 :            block++;
  150608             :         }
  150609           0 :      return storageCounter;
  150610             :    }
  150611             : 
  150612             : /* #line 150613 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  150613             : 
  150614             : 
  150615             : 
  150616             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  150617             : 
  150618             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  150619             : 
  150620             : //############################################################################
  150621             : /* JH (02/02/2006) Constructor of the IR node SgConjugateOp that takes its 
  150622             :  * corresponding StorageClass as parameter
  150623             :  */
  150624           0 : SgConjugateOp :: SgConjugateOp ( const SgConjugateOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  150625             :    {
  150626             : 
  150627             : 
  150628             : /* #line 150629 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  150629             : 
  150630           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  150631             : 
  150632             : 
  150633             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  150634             : 
  150635             : 
  150636           0 :    }
  150637             : 
  150638             : //############################################################################
  150639             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  150640             :  * within the working AST. 
  150641             :  */
  150642           0 : SgConjugateOp * SgConjugateOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  150643           0 :      SgConjugateOp* returnPointer = NULL;
  150644           0 :      if ( globalIndex != 0 )
  150645             :         {
  150646             : 
  150647             : #if FILE_IO_EXTRA_CHECK
  150648           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgConjugateOp ) ) <= globalIndex ) ;
  150649           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConjugateOp + 1 ) ) );
  150650             : #endif
  150651           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConjugateOp )  
  150652           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgConjugateOp );
  150653           0 :           unsigned long positionInPool = localIndex % SgConjugateOp::pool_size;
  150654           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConjugateOp::pool_size;
  150655             : 
  150656             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  150657             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  150658             : 
  150659           0 :           returnPointer = &( ( (SgConjugateOp*)(SgConjugateOp::pools[memoryBlock]) ) [positionInPool]) ;
  150660             : 
  150661           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  150662             :         }
  150663           0 :      return returnPointer ;
  150664             :    }
  150665             : 
  150666             : //############################################################################
  150667             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  150668             :   for the AST with the index astIndex
  150669             : */
  150670           0 : SgConjugateOp * SgConjugateOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  150671           0 :      SgConjugateOp* returnPointer = NULL;
  150672           0 :      if ( globalIndex != 0 )
  150673             :         {
  150674             : 
  150675             : #if FILE_IO_EXTRA_CHECK
  150676           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgConjugateOp ) ) <= globalIndex ) ;
  150677           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConjugateOp + 1 ) ) );
  150678             : #endif
  150679           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConjugateOp )
  150680           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgConjugateOp );
  150681           0 :           unsigned long positionInPool = localIndex % SgConjugateOp::pool_size ;
  150682           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConjugateOp::pool_size ;
  150683             : 
  150684             : #if FILE_IO_EXTRA_CHECK
  150685             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  150686             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  150687             : #endif
  150688             : 
  150689           0 :           returnPointer = &( ( (SgConjugateOp*)(SgConjugateOp::pools[memoryBlock]) ) [positionInPool]) ;
  150690             : 
  150691             : #if FILE_IO_EXTRA_CHECK
  150692           0 :           assert ( returnPointer != NULL ) ;
  150693             : #endif
  150694             :         }
  150695           0 :      return returnPointer ;
  150696             :    }
  150697             : 
  150698             : //############################################################################
  150699             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  150700             :  * pool size! We set for every valid object in the memory pool the freepointer
  150701             :  * to the global index and increase the global index afterwards. For all the 
  150702             :  * invalid objects (means address ranges within the memory pool that were not
  150703             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  150704             :  * distinguish valid from invalid objects! 
  150705             :  */
  150706             : unsigned long
  150707           5 : SgConjugateOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  150708             :    {
  150709           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  150710           5 :      SgConjugateOp* pointer = NULL;
  150711           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  150712           5 :      std::vector < unsigned char* > :: const_iterator block;
  150713           5 :      for ( block = SgConjugateOp::pools.begin(); block != SgConjugateOp::pools.end() ; ++block )
  150714             :         {
  150715           0 :           pointer = (SgConjugateOp*)(*block);
  150716           0 :           for (unsigned i = 0; i < SgConjugateOp::pool_size; ++i )
  150717             :              {
  150718             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  150719             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  150720             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  150721             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  150722             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  150723             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  150724             :             // properly; so this will have to be checked next.
  150725             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  150726             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  150727           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  150728             :                   {
  150729           0 :                     pointer[i].set_freepointer((SgConjugateOp*)(globalIndex));
  150730           0 :                     globalIndex++;
  150731             :                   }
  150732             :                else
  150733             :                   {
  150734           0 :                     pointer[i].set_freepointer(NULL);
  150735             :                   }
  150736             :               }
  150737             :         }
  150738           5 :      return globalIndex;
  150739             :    }
  150740             : 
  150741             : //############################################################################
  150742             : // JH (01/14/2006)
  150743             : void
  150744           5 : SgConjugateOp::resetValidFreepointers( )
  150745             :    {
  150746           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  150747           5 :      SgConjugateOp* pointer = NULL;
  150748           5 :      std::vector < unsigned char* > :: const_iterator block;
  150749           5 :      SgConjugateOp* pointerOfLinkedList = NULL;
  150750           5 :      for ( block = SgConjugateOp::pools.begin(); block != SgConjugateOp::pools.end() ; ++block )
  150751             :         {
  150752           0 :           pointer = (SgConjugateOp*)(*block);
  150753           0 :           for (unsigned i = 0; i < SgConjugateOp::pool_size; ++i )
  150754             :              {
  150755             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  150756             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  150757             :             // memory blocks!.
  150758           0 :                if ( pointer[i].get_freepointer() != NULL )
  150759             :                   {
  150760           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  150761             :                   }
  150762             :                else
  150763             :                   {
  150764           0 :                     if ( pointerOfLinkedList == NULL )
  150765             :                        {
  150766           0 :                          SgConjugateOp::next_node = &(pointer[i]);
  150767             :                        }
  150768             :                     else
  150769             :                        {
  150770             :                       // printf ("In SgConjugateOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  150771           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  150772             :                        }
  150773             :                     pointerOfLinkedList = &(pointer[i]);
  150774             :                   }
  150775             :               }
  150776             :         }
  150777             : 
  150778           5 :      if ( pointerOfLinkedList != NULL )
  150779             :         {
  150780             :        // printf ("In SgConjugateOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  150781           0 :           pointerOfLinkedList->set_freepointer(NULL);
  150782             :        // DQ (6/6/2010): Temporary debugging...
  150783             :        //   ROSE_ASSERT(false);
  150784             :         }
  150785             : 
  150786           5 :      return ;
  150787             :    }
  150788             : 
  150789             : //############################################################################
  150790             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  150791             :  * within the memory pool and resets the freepointers, in order to achieve a 
  150792             :  * linked list, that has no jumps and starts at the beginning! This function 
  150793             :  * does not extend the memory pool, since we do not delete any memory blocks,
  150794             :  * but delete the valid objects.  
  150795             :  */
  150796             : void
  150797           0 : SgConjugateOp::clearMemoryPool( )
  150798             :    {
  150799             :   // printf ("Inside of SgConjugateOp::clearMemoryPool() \n");
  150800             : 
  150801           0 :      SgConjugateOp* pointer = NULL, *tempPointer = NULL;
  150802           0 :      std::vector < unsigned char* > :: const_iterator block;
  150803           0 :      if ( SgConjugateOp::pools.empty() == false )
  150804             :         {
  150805           0 :           block = SgConjugateOp::pools.begin() ;
  150806           0 :           SgConjugateOp::next_node = (SgConjugateOp*) (*block);
  150807             : 
  150808           0 :           while ( block != SgConjugateOp::pools.end() )
  150809             :              {
  150810           0 :                pointer = (SgConjugateOp*) (*block);
  150811           0 :                if ( tempPointer != NULL )
  150812             :                   {
  150813           0 :                     tempPointer->set_freepointer(pointer);
  150814             :                   }
  150815           0 :                for (unsigned i = 0; i < SgConjugateOp::pool_size - 1; ++i)
  150816             :                   {
  150817           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  150818             :                   }
  150819           0 :                 pointer[SgConjugateOp::pool_size-1].set_freepointer(NULL);
  150820           0 :                 tempPointer = &(pointer[SgConjugateOp::pool_size-1]);
  150821           0 :                 ++block;
  150822             :              }
  150823             :         }
  150824           0 :    }
  150825             : 
  150826           5 : void SgConjugateOp::deleteMemoryPool() {
  150827           5 :   for (auto p: SgConjugateOp::pools) {
  150828           0 :     ROSE_FREE(p);
  150829             :   }
  150830           5 :   SgConjugateOp::next_node = nullptr;
  150831           5 :   SgConjugateOp::pools.clear();
  150832           5 : }
  150833             : 
  150834             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  150835             : //                 reading multiple binary files to for a single AST.
  150836             : /////////// new version ////////////////////////////////
  150837             : //############################################################################
  150838             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  150839             : void
  150840           2 : SgConjugateOp::extendMemoryPoolForFileIO( )
  150841             :   {
  150842           2 :     size_t blockIndex = SgConjugateOp::pools.size();
  150843           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgConjugateOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgConjugateOp);
  150844             : 
  150845           2 :     while ( (blockIndex * SgConjugateOp::pool_size) < newPoolSize)
  150846             :       {
  150847             : #if ROSE_ALLOC_TRACE
  150848             :         if (blockIndex > 0) {
  150849             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgConjugateOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgConjugateOp) = %" PRIuPTR " SgConjugateOp::pool_size = %d \n",
  150850             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgConjugateOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgConjugateOp),SgConjugateOp::pool_size);
  150851             :         }
  150852             : #endif
  150853             : 
  150854           0 :         SgConjugateOp * pointer = (SgConjugateOp*) ROSE_MALLOC ( SgConjugateOp::pool_size * sizeof(SgConjugateOp) );
  150855           0 :         assert( pointer != NULL );
  150856             : #if ROSE_ALLOC_MEMSET == 1
  150857             :         memset(pointer, 0x00, SgConjugateOp::pool_size * sizeof(SgConjugateOp));
  150858             : #elif ROSE_ALLOC_MEMSET == 2
  150859             :         memset(pointer, 0xCC, SgConjugateOp::pool_size * sizeof(SgConjugateOp));
  150860             : #endif
  150861           0 :         SgConjugateOp::pools.push_back( (unsigned char*)(pointer) );
  150862           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgConjugateOp::pool_size * sizeof(SgConjugateOp), V_SgConjugateOp ) );
  150863             : 
  150864           0 :         if ( SgConjugateOp::next_node != NULL ) {
  150865           0 :           if ( blockIndex > 0 ) {
  150866           0 :             SgConjugateOp * blkptr = (SgConjugateOp*)(SgConjugateOp::pools[blockIndex-1]);
  150867           0 :             blkptr[ SgConjugateOp::pool_size - 1 ].set_freepointer(pointer);
  150868             :           }
  150869             :         } else {
  150870           0 :           SgConjugateOp::next_node = pointer;
  150871             :         }
  150872             : 
  150873           0 :         for (unsigned i = 0; i < SgConjugateOp::pool_size-1; ++i)
  150874             :            {
  150875           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  150876             :            }
  150877           0 :         pointer[ SgConjugateOp::pool_size -1 ].set_freepointer(NULL);
  150878             : 
  150879           0 :         blockIndex++;
  150880             :       }
  150881           2 :   }
  150882             : 
  150883             : //############################################################################
  150884             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  150885             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  150886             :  * not compressed. However, that stuff is not yet implemented! 
  150887             :  */
  150888             : unsigned long
  150889           0 : SgConjugateOp::getNumberOfLastValidPointer()
  150890             :    {
  150891           0 :       SgConjugateOp* testPointer = (SgConjugateOp*)(SgConjugateOp::pools.back());
  150892           0 :       unsigned long localIndex = SgConjugateOp::pool_size - 1;
  150893           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  150894             :          {
  150895           0 :            localIndex--;
  150896             :          }
  150897           0 :       return (localIndex + SgConjugateOp::pool_size * (SgConjugateOp::pools.size()-1));
  150898             :    }
  150899             : 
  150900             : //############################################################################
  150901             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  150902             :  * memory pool and initializes the data member in class SgConjugateOpStroageClass
  150903             :  * from its counterpart of SgConjugateOp. The return value is just for checking, 
  150904             :  * that the whole StorageClassArray is initialized!
  150905             :  */
  150906             : unsigned long
  150907           0 : SgConjugateOp::initializeStorageClassArray( SgConjugateOpStorageClass *storageArray )
  150908             :    {
  150909           0 :      unsigned long storageCounter = 0;
  150910           0 :      std::vector < unsigned char* > :: const_iterator block = SgConjugateOp::pools.begin();
  150911           0 :      SgConjugateOp* pointer = NULL;
  150912           0 :      while ( block != SgConjugateOp::pools.end() ) {
  150913           0 :           pointer = (SgConjugateOp*) (*block);
  150914           0 :           for ( unsigned i = 0; i < SgConjugateOp::pool_size; ++i ) {
  150915           0 :                if ( pointer->get_freepointer() != NULL ) {
  150916           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  150917           0 :                  storageArray++;
  150918           0 :                  storageCounter++;
  150919             :                }
  150920           0 :                pointer++;
  150921             :              }
  150922           0 :            block++;
  150923             :         }
  150924           0 :      return storageCounter;
  150925             :    }
  150926             : 
  150927             : /* #line 150928 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  150928             : 
  150929             : 
  150930             : 
  150931             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  150932             : 
  150933             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  150934             : 
  150935             : //############################################################################
  150936             : /* JH (02/02/2006) Constructor of the IR node SgUserDefinedUnaryOp that takes its 
  150937             :  * corresponding StorageClass as parameter
  150938             :  */
  150939           0 : SgUserDefinedUnaryOp :: SgUserDefinedUnaryOp ( const SgUserDefinedUnaryOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  150940             :    {
  150941             : 
  150942             : 
  150943             : /* #line 150944 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  150944             : 
  150945           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  150946           0 :      p_operator_name = SgName ( storageSource.storageOf_operator_name ) ;
  150947           0 :      p_symbol =  (SgFunctionSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol) );
  150948             : 
  150949             : 
  150950             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  150951             : 
  150952             : 
  150953           0 :    }
  150954             : 
  150955             : //############################################################################
  150956             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  150957             :  * within the working AST. 
  150958             :  */
  150959           0 : SgUserDefinedUnaryOp * SgUserDefinedUnaryOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  150960           0 :      SgUserDefinedUnaryOp* returnPointer = NULL;
  150961           0 :      if ( globalIndex != 0 )
  150962             :         {
  150963             : 
  150964             : #if FILE_IO_EXTRA_CHECK
  150965           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUserDefinedUnaryOp ) ) <= globalIndex ) ;
  150966           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUserDefinedUnaryOp + 1 ) ) );
  150967             : #endif
  150968           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUserDefinedUnaryOp )  
  150969           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUserDefinedUnaryOp );
  150970           0 :           unsigned long positionInPool = localIndex % SgUserDefinedUnaryOp::pool_size;
  150971           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUserDefinedUnaryOp::pool_size;
  150972             : 
  150973             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  150974             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  150975             : 
  150976           0 :           returnPointer = &( ( (SgUserDefinedUnaryOp*)(SgUserDefinedUnaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  150977             : 
  150978           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  150979             :         }
  150980           0 :      return returnPointer ;
  150981             :    }
  150982             : 
  150983             : //############################################################################
  150984             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  150985             :   for the AST with the index astIndex
  150986             : */
  150987           0 : SgUserDefinedUnaryOp * SgUserDefinedUnaryOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  150988           0 :      SgUserDefinedUnaryOp* returnPointer = NULL;
  150989           0 :      if ( globalIndex != 0 )
  150990             :         {
  150991             : 
  150992             : #if FILE_IO_EXTRA_CHECK
  150993           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUserDefinedUnaryOp ) ) <= globalIndex ) ;
  150994           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUserDefinedUnaryOp + 1 ) ) );
  150995             : #endif
  150996           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUserDefinedUnaryOp )
  150997           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUserDefinedUnaryOp );
  150998           0 :           unsigned long positionInPool = localIndex % SgUserDefinedUnaryOp::pool_size ;
  150999           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUserDefinedUnaryOp::pool_size ;
  151000             : 
  151001             : #if FILE_IO_EXTRA_CHECK
  151002             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  151003             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  151004             : #endif
  151005             : 
  151006           0 :           returnPointer = &( ( (SgUserDefinedUnaryOp*)(SgUserDefinedUnaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  151007             : 
  151008             : #if FILE_IO_EXTRA_CHECK
  151009           0 :           assert ( returnPointer != NULL ) ;
  151010             : #endif
  151011             :         }
  151012           0 :      return returnPointer ;
  151013             :    }
  151014             : 
  151015             : //############################################################################
  151016             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  151017             :  * pool size! We set for every valid object in the memory pool the freepointer
  151018             :  * to the global index and increase the global index afterwards. For all the 
  151019             :  * invalid objects (means address ranges within the memory pool that were not
  151020             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  151021             :  * distinguish valid from invalid objects! 
  151022             :  */
  151023             : unsigned long
  151024           5 : SgUserDefinedUnaryOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  151025             :    {
  151026           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  151027           5 :      SgUserDefinedUnaryOp* pointer = NULL;
  151028           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  151029           5 :      std::vector < unsigned char* > :: const_iterator block;
  151030           5 :      for ( block = SgUserDefinedUnaryOp::pools.begin(); block != SgUserDefinedUnaryOp::pools.end() ; ++block )
  151031             :         {
  151032           0 :           pointer = (SgUserDefinedUnaryOp*)(*block);
  151033           0 :           for (unsigned i = 0; i < SgUserDefinedUnaryOp::pool_size; ++i )
  151034             :              {
  151035             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  151036             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  151037             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  151038             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  151039             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  151040             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  151041             :             // properly; so this will have to be checked next.
  151042             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  151043             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  151044           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  151045             :                   {
  151046           0 :                     pointer[i].set_freepointer((SgUserDefinedUnaryOp*)(globalIndex));
  151047           0 :                     globalIndex++;
  151048             :                   }
  151049             :                else
  151050             :                   {
  151051           0 :                     pointer[i].set_freepointer(NULL);
  151052             :                   }
  151053             :               }
  151054             :         }
  151055           5 :      return globalIndex;
  151056             :    }
  151057             : 
  151058             : //############################################################################
  151059             : // JH (01/14/2006)
  151060             : void
  151061           5 : SgUserDefinedUnaryOp::resetValidFreepointers( )
  151062             :    {
  151063           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  151064           5 :      SgUserDefinedUnaryOp* pointer = NULL;
  151065           5 :      std::vector < unsigned char* > :: const_iterator block;
  151066           5 :      SgUserDefinedUnaryOp* pointerOfLinkedList = NULL;
  151067           5 :      for ( block = SgUserDefinedUnaryOp::pools.begin(); block != SgUserDefinedUnaryOp::pools.end() ; ++block )
  151068             :         {
  151069           0 :           pointer = (SgUserDefinedUnaryOp*)(*block);
  151070           0 :           for (unsigned i = 0; i < SgUserDefinedUnaryOp::pool_size; ++i )
  151071             :              {
  151072             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  151073             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  151074             :             // memory blocks!.
  151075           0 :                if ( pointer[i].get_freepointer() != NULL )
  151076             :                   {
  151077           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  151078             :                   }
  151079             :                else
  151080             :                   {
  151081           0 :                     if ( pointerOfLinkedList == NULL )
  151082             :                        {
  151083           0 :                          SgUserDefinedUnaryOp::next_node = &(pointer[i]);
  151084             :                        }
  151085             :                     else
  151086             :                        {
  151087             :                       // printf ("In SgUserDefinedUnaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  151088           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  151089             :                        }
  151090             :                     pointerOfLinkedList = &(pointer[i]);
  151091             :                   }
  151092             :               }
  151093             :         }
  151094             : 
  151095           5 :      if ( pointerOfLinkedList != NULL )
  151096             :         {
  151097             :        // printf ("In SgUserDefinedUnaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  151098           0 :           pointerOfLinkedList->set_freepointer(NULL);
  151099             :        // DQ (6/6/2010): Temporary debugging...
  151100             :        //   ROSE_ASSERT(false);
  151101             :         }
  151102             : 
  151103           5 :      return ;
  151104             :    }
  151105             : 
  151106             : //############################################################################
  151107             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  151108             :  * within the memory pool and resets the freepointers, in order to achieve a 
  151109             :  * linked list, that has no jumps and starts at the beginning! This function 
  151110             :  * does not extend the memory pool, since we do not delete any memory blocks,
  151111             :  * but delete the valid objects.  
  151112             :  */
  151113             : void
  151114           0 : SgUserDefinedUnaryOp::clearMemoryPool( )
  151115             :    {
  151116             :   // printf ("Inside of SgUserDefinedUnaryOp::clearMemoryPool() \n");
  151117             : 
  151118           0 :      SgUserDefinedUnaryOp* pointer = NULL, *tempPointer = NULL;
  151119           0 :      std::vector < unsigned char* > :: const_iterator block;
  151120           0 :      if ( SgUserDefinedUnaryOp::pools.empty() == false )
  151121             :         {
  151122           0 :           block = SgUserDefinedUnaryOp::pools.begin() ;
  151123           0 :           SgUserDefinedUnaryOp::next_node = (SgUserDefinedUnaryOp*) (*block);
  151124             : 
  151125           0 :           while ( block != SgUserDefinedUnaryOp::pools.end() )
  151126             :              {
  151127           0 :                pointer = (SgUserDefinedUnaryOp*) (*block);
  151128           0 :                if ( tempPointer != NULL )
  151129             :                   {
  151130           0 :                     tempPointer->set_freepointer(pointer);
  151131             :                   }
  151132           0 :                for (unsigned i = 0; i < SgUserDefinedUnaryOp::pool_size - 1; ++i)
  151133             :                   {
  151134           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  151135             :                   }
  151136           0 :                 pointer[SgUserDefinedUnaryOp::pool_size-1].set_freepointer(NULL);
  151137           0 :                 tempPointer = &(pointer[SgUserDefinedUnaryOp::pool_size-1]);
  151138           0 :                 ++block;
  151139             :              }
  151140             :         }
  151141           0 :    }
  151142             : 
  151143           5 : void SgUserDefinedUnaryOp::deleteMemoryPool() {
  151144           5 :   for (auto p: SgUserDefinedUnaryOp::pools) {
  151145           0 :     ROSE_FREE(p);
  151146             :   }
  151147           5 :   SgUserDefinedUnaryOp::next_node = nullptr;
  151148           5 :   SgUserDefinedUnaryOp::pools.clear();
  151149           5 : }
  151150             : 
  151151             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  151152             : //                 reading multiple binary files to for a single AST.
  151153             : /////////// new version ////////////////////////////////
  151154             : //############################################################################
  151155             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  151156             : void
  151157           2 : SgUserDefinedUnaryOp::extendMemoryPoolForFileIO( )
  151158             :   {
  151159           2 :     size_t blockIndex = SgUserDefinedUnaryOp::pools.size();
  151160           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUserDefinedUnaryOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUserDefinedUnaryOp);
  151161             : 
  151162           2 :     while ( (blockIndex * SgUserDefinedUnaryOp::pool_size) < newPoolSize)
  151163             :       {
  151164             : #if ROSE_ALLOC_TRACE
  151165             :         if (blockIndex > 0) {
  151166             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUserDefinedUnaryOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUserDefinedUnaryOp) = %" PRIuPTR " SgUserDefinedUnaryOp::pool_size = %d \n",
  151167             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUserDefinedUnaryOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUserDefinedUnaryOp),SgUserDefinedUnaryOp::pool_size);
  151168             :         }
  151169             : #endif
  151170             : 
  151171           0 :         SgUserDefinedUnaryOp * pointer = (SgUserDefinedUnaryOp*) ROSE_MALLOC ( SgUserDefinedUnaryOp::pool_size * sizeof(SgUserDefinedUnaryOp) );
  151172           0 :         assert( pointer != NULL );
  151173             : #if ROSE_ALLOC_MEMSET == 1
  151174             :         memset(pointer, 0x00, SgUserDefinedUnaryOp::pool_size * sizeof(SgUserDefinedUnaryOp));
  151175             : #elif ROSE_ALLOC_MEMSET == 2
  151176             :         memset(pointer, 0xCC, SgUserDefinedUnaryOp::pool_size * sizeof(SgUserDefinedUnaryOp));
  151177             : #endif
  151178           0 :         SgUserDefinedUnaryOp::pools.push_back( (unsigned char*)(pointer) );
  151179           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUserDefinedUnaryOp::pool_size * sizeof(SgUserDefinedUnaryOp), V_SgUserDefinedUnaryOp ) );
  151180             : 
  151181           0 :         if ( SgUserDefinedUnaryOp::next_node != NULL ) {
  151182           0 :           if ( blockIndex > 0 ) {
  151183           0 :             SgUserDefinedUnaryOp * blkptr = (SgUserDefinedUnaryOp*)(SgUserDefinedUnaryOp::pools[blockIndex-1]);
  151184           0 :             blkptr[ SgUserDefinedUnaryOp::pool_size - 1 ].set_freepointer(pointer);
  151185             :           }
  151186             :         } else {
  151187           0 :           SgUserDefinedUnaryOp::next_node = pointer;
  151188             :         }
  151189             : 
  151190           0 :         for (unsigned i = 0; i < SgUserDefinedUnaryOp::pool_size-1; ++i)
  151191             :            {
  151192           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  151193             :            }
  151194           0 :         pointer[ SgUserDefinedUnaryOp::pool_size -1 ].set_freepointer(NULL);
  151195             : 
  151196           0 :         blockIndex++;
  151197             :       }
  151198           2 :   }
  151199             : 
  151200             : //############################################################################
  151201             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  151202             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  151203             :  * not compressed. However, that stuff is not yet implemented! 
  151204             :  */
  151205             : unsigned long
  151206           0 : SgUserDefinedUnaryOp::getNumberOfLastValidPointer()
  151207             :    {
  151208           0 :       SgUserDefinedUnaryOp* testPointer = (SgUserDefinedUnaryOp*)(SgUserDefinedUnaryOp::pools.back());
  151209           0 :       unsigned long localIndex = SgUserDefinedUnaryOp::pool_size - 1;
  151210           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  151211             :          {
  151212           0 :            localIndex--;
  151213             :          }
  151214           0 :       return (localIndex + SgUserDefinedUnaryOp::pool_size * (SgUserDefinedUnaryOp::pools.size()-1));
  151215             :    }
  151216             : 
  151217             : //############################################################################
  151218             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  151219             :  * memory pool and initializes the data member in class SgUserDefinedUnaryOpStroageClass
  151220             :  * from its counterpart of SgUserDefinedUnaryOp. The return value is just for checking, 
  151221             :  * that the whole StorageClassArray is initialized!
  151222             :  */
  151223             : unsigned long
  151224           0 : SgUserDefinedUnaryOp::initializeStorageClassArray( SgUserDefinedUnaryOpStorageClass *storageArray )
  151225             :    {
  151226           0 :      unsigned long storageCounter = 0;
  151227           0 :      std::vector < unsigned char* > :: const_iterator block = SgUserDefinedUnaryOp::pools.begin();
  151228           0 :      SgUserDefinedUnaryOp* pointer = NULL;
  151229           0 :      while ( block != SgUserDefinedUnaryOp::pools.end() ) {
  151230           0 :           pointer = (SgUserDefinedUnaryOp*) (*block);
  151231           0 :           for ( unsigned i = 0; i < SgUserDefinedUnaryOp::pool_size; ++i ) {
  151232           0 :                if ( pointer->get_freepointer() != NULL ) {
  151233           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  151234           0 :                  storageArray++;
  151235           0 :                  storageCounter++;
  151236             :                }
  151237           0 :                pointer++;
  151238             :              }
  151239           0 :            block++;
  151240             :         }
  151241           0 :      return storageCounter;
  151242             :    }
  151243             : 
  151244             : /* #line 151245 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  151245             : 
  151246             : 
  151247             : 
  151248             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  151249             : 
  151250             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  151251             : 
  151252             : //############################################################################
  151253             : /* JH (02/02/2006) Constructor of the IR node SgMatrixTransposeOp that takes its 
  151254             :  * corresponding StorageClass as parameter
  151255             :  */
  151256           0 : SgMatrixTransposeOp :: SgMatrixTransposeOp ( const SgMatrixTransposeOpStorageClass& storageSource )   : SgUnaryOp (storageSource)
  151257             :    {
  151258             : 
  151259             : 
  151260             : /* #line 151261 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  151261             : 
  151262           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  151263           0 :      p_is_conjugate = storageSource.storageOf_is_conjugate ;
  151264             : 
  151265             : 
  151266             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  151267             : 
  151268             : 
  151269           0 :    }
  151270             : 
  151271             : //############################################################################
  151272             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  151273             :  * within the working AST. 
  151274             :  */
  151275           0 : SgMatrixTransposeOp * SgMatrixTransposeOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  151276           0 :      SgMatrixTransposeOp* returnPointer = NULL;
  151277           0 :      if ( globalIndex != 0 )
  151278             :         {
  151279             : 
  151280             : #if FILE_IO_EXTRA_CHECK
  151281           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMatrixTransposeOp ) ) <= globalIndex ) ;
  151282           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMatrixTransposeOp + 1 ) ) );
  151283             : #endif
  151284           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMatrixTransposeOp )  
  151285           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMatrixTransposeOp );
  151286           0 :           unsigned long positionInPool = localIndex % SgMatrixTransposeOp::pool_size;
  151287           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMatrixTransposeOp::pool_size;
  151288             : 
  151289             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  151290             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  151291             : 
  151292           0 :           returnPointer = &( ( (SgMatrixTransposeOp*)(SgMatrixTransposeOp::pools[memoryBlock]) ) [positionInPool]) ;
  151293             : 
  151294           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  151295             :         }
  151296           0 :      return returnPointer ;
  151297             :    }
  151298             : 
  151299             : //############################################################################
  151300             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  151301             :   for the AST with the index astIndex
  151302             : */
  151303           0 : SgMatrixTransposeOp * SgMatrixTransposeOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  151304           0 :      SgMatrixTransposeOp* returnPointer = NULL;
  151305           0 :      if ( globalIndex != 0 )
  151306             :         {
  151307             : 
  151308             : #if FILE_IO_EXTRA_CHECK
  151309           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMatrixTransposeOp ) ) <= globalIndex ) ;
  151310           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMatrixTransposeOp + 1 ) ) );
  151311             : #endif
  151312           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMatrixTransposeOp )
  151313           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMatrixTransposeOp );
  151314           0 :           unsigned long positionInPool = localIndex % SgMatrixTransposeOp::pool_size ;
  151315           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMatrixTransposeOp::pool_size ;
  151316             : 
  151317             : #if FILE_IO_EXTRA_CHECK
  151318             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  151319             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  151320             : #endif
  151321             : 
  151322           0 :           returnPointer = &( ( (SgMatrixTransposeOp*)(SgMatrixTransposeOp::pools[memoryBlock]) ) [positionInPool]) ;
  151323             : 
  151324             : #if FILE_IO_EXTRA_CHECK
  151325           0 :           assert ( returnPointer != NULL ) ;
  151326             : #endif
  151327             :         }
  151328           0 :      return returnPointer ;
  151329             :    }
  151330             : 
  151331             : //############################################################################
  151332             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  151333             :  * pool size! We set for every valid object in the memory pool the freepointer
  151334             :  * to the global index and increase the global index afterwards. For all the 
  151335             :  * invalid objects (means address ranges within the memory pool that were not
  151336             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  151337             :  * distinguish valid from invalid objects! 
  151338             :  */
  151339             : unsigned long
  151340           5 : SgMatrixTransposeOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  151341             :    {
  151342           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  151343           5 :      SgMatrixTransposeOp* pointer = NULL;
  151344           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  151345           5 :      std::vector < unsigned char* > :: const_iterator block;
  151346           5 :      for ( block = SgMatrixTransposeOp::pools.begin(); block != SgMatrixTransposeOp::pools.end() ; ++block )
  151347             :         {
  151348           0 :           pointer = (SgMatrixTransposeOp*)(*block);
  151349           0 :           for (unsigned i = 0; i < SgMatrixTransposeOp::pool_size; ++i )
  151350             :              {
  151351             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  151352             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  151353             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  151354             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  151355             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  151356             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  151357             :             // properly; so this will have to be checked next.
  151358             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  151359             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  151360           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  151361             :                   {
  151362           0 :                     pointer[i].set_freepointer((SgMatrixTransposeOp*)(globalIndex));
  151363           0 :                     globalIndex++;
  151364             :                   }
  151365             :                else
  151366             :                   {
  151367           0 :                     pointer[i].set_freepointer(NULL);
  151368             :                   }
  151369             :               }
  151370             :         }
  151371           5 :      return globalIndex;
  151372             :    }
  151373             : 
  151374             : //############################################################################
  151375             : // JH (01/14/2006)
  151376             : void
  151377           5 : SgMatrixTransposeOp::resetValidFreepointers( )
  151378             :    {
  151379           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  151380           5 :      SgMatrixTransposeOp* pointer = NULL;
  151381           5 :      std::vector < unsigned char* > :: const_iterator block;
  151382           5 :      SgMatrixTransposeOp* pointerOfLinkedList = NULL;
  151383           5 :      for ( block = SgMatrixTransposeOp::pools.begin(); block != SgMatrixTransposeOp::pools.end() ; ++block )
  151384             :         {
  151385           0 :           pointer = (SgMatrixTransposeOp*)(*block);
  151386           0 :           for (unsigned i = 0; i < SgMatrixTransposeOp::pool_size; ++i )
  151387             :              {
  151388             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  151389             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  151390             :             // memory blocks!.
  151391           0 :                if ( pointer[i].get_freepointer() != NULL )
  151392             :                   {
  151393           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  151394             :                   }
  151395             :                else
  151396             :                   {
  151397           0 :                     if ( pointerOfLinkedList == NULL )
  151398             :                        {
  151399           0 :                          SgMatrixTransposeOp::next_node = &(pointer[i]);
  151400             :                        }
  151401             :                     else
  151402             :                        {
  151403             :                       // printf ("In SgMatrixTransposeOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  151404           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  151405             :                        }
  151406             :                     pointerOfLinkedList = &(pointer[i]);
  151407             :                   }
  151408             :               }
  151409             :         }
  151410             : 
  151411           5 :      if ( pointerOfLinkedList != NULL )
  151412             :         {
  151413             :        // printf ("In SgMatrixTransposeOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  151414           0 :           pointerOfLinkedList->set_freepointer(NULL);
  151415             :        // DQ (6/6/2010): Temporary debugging...
  151416             :        //   ROSE_ASSERT(false);
  151417             :         }
  151418             : 
  151419           5 :      return ;
  151420             :    }
  151421             : 
  151422             : //############################################################################
  151423             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  151424             :  * within the memory pool and resets the freepointers, in order to achieve a 
  151425             :  * linked list, that has no jumps and starts at the beginning! This function 
  151426             :  * does not extend the memory pool, since we do not delete any memory blocks,
  151427             :  * but delete the valid objects.  
  151428             :  */
  151429             : void
  151430           0 : SgMatrixTransposeOp::clearMemoryPool( )
  151431             :    {
  151432             :   // printf ("Inside of SgMatrixTransposeOp::clearMemoryPool() \n");
  151433             : 
  151434           0 :      SgMatrixTransposeOp* pointer = NULL, *tempPointer = NULL;
  151435           0 :      std::vector < unsigned char* > :: const_iterator block;
  151436           0 :      if ( SgMatrixTransposeOp::pools.empty() == false )
  151437             :         {
  151438           0 :           block = SgMatrixTransposeOp::pools.begin() ;
  151439           0 :           SgMatrixTransposeOp::next_node = (SgMatrixTransposeOp*) (*block);
  151440             : 
  151441           0 :           while ( block != SgMatrixTransposeOp::pools.end() )
  151442             :              {
  151443           0 :                pointer = (SgMatrixTransposeOp*) (*block);
  151444           0 :                if ( tempPointer != NULL )
  151445             :                   {
  151446           0 :                     tempPointer->set_freepointer(pointer);
  151447             :                   }
  151448           0 :                for (unsigned i = 0; i < SgMatrixTransposeOp::pool_size - 1; ++i)
  151449             :                   {
  151450           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  151451             :                   }
  151452           0 :                 pointer[SgMatrixTransposeOp::pool_size-1].set_freepointer(NULL);
  151453           0 :                 tempPointer = &(pointer[SgMatrixTransposeOp::pool_size-1]);
  151454           0 :                 ++block;
  151455             :              }
  151456             :         }
  151457           0 :    }
  151458             : 
  151459           5 : void SgMatrixTransposeOp::deleteMemoryPool() {
  151460           5 :   for (auto p: SgMatrixTransposeOp::pools) {
  151461           0 :     ROSE_FREE(p);
  151462             :   }
  151463           5 :   SgMatrixTransposeOp::next_node = nullptr;
  151464           5 :   SgMatrixTransposeOp::pools.clear();
  151465           5 : }
  151466             : 
  151467             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  151468             : //                 reading multiple binary files to for a single AST.
  151469             : /////////// new version ////////////////////////////////
  151470             : //############################################################################
  151471             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  151472             : void
  151473           2 : SgMatrixTransposeOp::extendMemoryPoolForFileIO( )
  151474             :   {
  151475           2 :     size_t blockIndex = SgMatrixTransposeOp::pools.size();
  151476           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMatrixTransposeOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMatrixTransposeOp);
  151477             : 
  151478           2 :     while ( (blockIndex * SgMatrixTransposeOp::pool_size) < newPoolSize)
  151479             :       {
  151480             : #if ROSE_ALLOC_TRACE
  151481             :         if (blockIndex > 0) {
  151482             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMatrixTransposeOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMatrixTransposeOp) = %" PRIuPTR " SgMatrixTransposeOp::pool_size = %d \n",
  151483             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMatrixTransposeOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMatrixTransposeOp),SgMatrixTransposeOp::pool_size);
  151484             :         }
  151485             : #endif
  151486             : 
  151487           0 :         SgMatrixTransposeOp * pointer = (SgMatrixTransposeOp*) ROSE_MALLOC ( SgMatrixTransposeOp::pool_size * sizeof(SgMatrixTransposeOp) );
  151488           0 :         assert( pointer != NULL );
  151489             : #if ROSE_ALLOC_MEMSET == 1
  151490             :         memset(pointer, 0x00, SgMatrixTransposeOp::pool_size * sizeof(SgMatrixTransposeOp));
  151491             : #elif ROSE_ALLOC_MEMSET == 2
  151492             :         memset(pointer, 0xCC, SgMatrixTransposeOp::pool_size * sizeof(SgMatrixTransposeOp));
  151493             : #endif
  151494           0 :         SgMatrixTransposeOp::pools.push_back( (unsigned char*)(pointer) );
  151495           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMatrixTransposeOp::pool_size * sizeof(SgMatrixTransposeOp), V_SgMatrixTransposeOp ) );
  151496             : 
  151497           0 :         if ( SgMatrixTransposeOp::next_node != NULL ) {
  151498           0 :           if ( blockIndex > 0 ) {
  151499           0 :             SgMatrixTransposeOp * blkptr = (SgMatrixTransposeOp*)(SgMatrixTransposeOp::pools[blockIndex-1]);
  151500           0 :             blkptr[ SgMatrixTransposeOp::pool_size - 1 ].set_freepointer(pointer);
  151501             :           }
  151502             :         } else {
  151503           0 :           SgMatrixTransposeOp::next_node = pointer;
  151504             :         }
  151505             : 
  151506           0 :         for (unsigned i = 0; i < SgMatrixTransposeOp::pool_size-1; ++i)
  151507             :            {
  151508           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  151509             :            }
  151510           0 :         pointer[ SgMatrixTransposeOp::pool_size -1 ].set_freepointer(NULL);
  151511             : 
  151512           0 :         blockIndex++;
  151513             :       }
  151514           2 :   }
  151515             : 
  151516             : //############################################################################
  151517             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  151518             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  151519             :  * not compressed. However, that stuff is not yet implemented! 
  151520             :  */
  151521             : unsigned long
  151522           0 : SgMatrixTransposeOp::getNumberOfLastValidPointer()
  151523             :    {
  151524           0 :       SgMatrixTransposeOp* testPointer = (SgMatrixTransposeOp*)(SgMatrixTransposeOp::pools.back());
  151525           0 :       unsigned long localIndex = SgMatrixTransposeOp::pool_size - 1;
  151526           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  151527             :          {
  151528           0 :            localIndex--;
  151529             :          }
  151530           0 :       return (localIndex + SgMatrixTransposeOp::pool_size * (SgMatrixTransposeOp::pools.size()-1));
  151531             :    }
  151532             : 
  151533             : //############################################################################
  151534             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  151535             :  * memory pool and initializes the data member in class SgMatrixTransposeOpStroageClass
  151536             :  * from its counterpart of SgMatrixTransposeOp. The return value is just for checking, 
  151537             :  * that the whole StorageClassArray is initialized!
  151538             :  */
  151539             : unsigned long
  151540           0 : SgMatrixTransposeOp::initializeStorageClassArray( SgMatrixTransposeOpStorageClass *storageArray )
  151541             :    {
  151542           0 :      unsigned long storageCounter = 0;
  151543           0 :      std::vector < unsigned char* > :: const_iterator block = SgMatrixTransposeOp::pools.begin();
  151544           0 :      SgMatrixTransposeOp* pointer = NULL;
  151545           0 :      while ( block != SgMatrixTransposeOp::pools.end() ) {
  151546           0 :           pointer = (SgMatrixTransposeOp*) (*block);
  151547           0 :           for ( unsigned i = 0; i < SgMatrixTransposeOp::pool_size; ++i ) {
  151548           0 :                if ( pointer->get_freepointer() != NULL ) {
  151549           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  151550           0 :                  storageArray++;
  151551           0 :                  storageCounter++;
  151552             :                }
  151553           0 :                pointer++;
  151554             :              }
  151555           0 :            block++;
  151556             :         }
  151557           0 :      return storageCounter;
  151558             :    }
  151559             : 
  151560             : /* #line 151561 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  151561             : 
  151562             : 
  151563             : 
  151564             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  151565             : 
  151566             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  151567             : 
  151568             : //############################################################################
  151569             : /* JH (02/02/2006) Constructor of the IR node SgBinaryOp that takes its 
  151570             :  * corresponding StorageClass as parameter
  151571             :  */
  151572        4222 : SgBinaryOp :: SgBinaryOp ( const SgBinaryOpStorageClass& storageSource )   : SgExpression (storageSource)
  151573             :    {
  151574             : 
  151575             : 
  151576             : /* #line 151577 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  151577             : 
  151578        4222 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  151579        4222 :      p_lhs_operand_i =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lhs_operand_i) );
  151580        4222 :      p_rhs_operand_i =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_rhs_operand_i) );
  151581        4222 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  151582        4222 :      p_originalExpressionTree =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_originalExpressionTree) );
  151583             : 
  151584             : 
  151585             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  151586             : 
  151587             : 
  151588        4222 :    }
  151589             : 
  151590             : //############################################################################
  151591             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  151592             :  * within the working AST. 
  151593             :  */
  151594           0 : SgBinaryOp * SgBinaryOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  151595           0 :      SgBinaryOp* returnPointer = NULL;
  151596           0 :      if ( globalIndex != 0 )
  151597             :         {
  151598             : 
  151599             : #if FILE_IO_EXTRA_CHECK
  151600           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBinaryOp ) ) <= globalIndex ) ;
  151601           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBinaryOp + 1 ) ) );
  151602             : #endif
  151603           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBinaryOp )  
  151604           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBinaryOp );
  151605           0 :           unsigned long positionInPool = localIndex % SgBinaryOp::pool_size;
  151606           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBinaryOp::pool_size;
  151607             : 
  151608             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  151609             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  151610             : 
  151611           0 :           returnPointer = &( ( (SgBinaryOp*)(SgBinaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  151612             : 
  151613           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  151614             :         }
  151615           0 :      return returnPointer ;
  151616             :    }
  151617             : 
  151618             : //############################################################################
  151619             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  151620             :   for the AST with the index astIndex
  151621             : */
  151622           0 : SgBinaryOp * SgBinaryOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  151623           0 :      SgBinaryOp* returnPointer = NULL;
  151624           0 :      if ( globalIndex != 0 )
  151625             :         {
  151626             : 
  151627             : #if FILE_IO_EXTRA_CHECK
  151628           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBinaryOp ) ) <= globalIndex ) ;
  151629           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBinaryOp + 1 ) ) );
  151630             : #endif
  151631           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBinaryOp )
  151632           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBinaryOp );
  151633           0 :           unsigned long positionInPool = localIndex % SgBinaryOp::pool_size ;
  151634           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBinaryOp::pool_size ;
  151635             : 
  151636             : #if FILE_IO_EXTRA_CHECK
  151637             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  151638             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  151639             : #endif
  151640             : 
  151641           0 :           returnPointer = &( ( (SgBinaryOp*)(SgBinaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  151642             : 
  151643             : #if FILE_IO_EXTRA_CHECK
  151644           0 :           assert ( returnPointer != NULL ) ;
  151645             : #endif
  151646             :         }
  151647           0 :      return returnPointer ;
  151648             :    }
  151649             : 
  151650             : //############################################################################
  151651             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  151652             :  * pool size! We set for every valid object in the memory pool the freepointer
  151653             :  * to the global index and increase the global index afterwards. For all the 
  151654             :  * invalid objects (means address ranges within the memory pool that were not
  151655             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  151656             :  * distinguish valid from invalid objects! 
  151657             :  */
  151658             : unsigned long
  151659           5 : SgBinaryOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  151660             :    {
  151661           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  151662           5 :      SgBinaryOp* pointer = NULL;
  151663           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  151664           5 :      std::vector < unsigned char* > :: const_iterator block;
  151665           5 :      for ( block = SgBinaryOp::pools.begin(); block != SgBinaryOp::pools.end() ; ++block )
  151666             :         {
  151667           0 :           pointer = (SgBinaryOp*)(*block);
  151668           0 :           for (unsigned i = 0; i < SgBinaryOp::pool_size; ++i )
  151669             :              {
  151670             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  151671             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  151672             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  151673             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  151674             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  151675             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  151676             :             // properly; so this will have to be checked next.
  151677             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  151678             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  151679           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  151680             :                   {
  151681           0 :                     pointer[i].set_freepointer((SgBinaryOp*)(globalIndex));
  151682           0 :                     globalIndex++;
  151683             :                   }
  151684             :                else
  151685             :                   {
  151686           0 :                     pointer[i].set_freepointer(NULL);
  151687             :                   }
  151688             :               }
  151689             :         }
  151690           5 :      return globalIndex;
  151691             :    }
  151692             : 
  151693             : //############################################################################
  151694             : // JH (01/14/2006)
  151695             : void
  151696           5 : SgBinaryOp::resetValidFreepointers( )
  151697             :    {
  151698           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  151699           5 :      SgBinaryOp* pointer = NULL;
  151700           5 :      std::vector < unsigned char* > :: const_iterator block;
  151701           5 :      SgBinaryOp* pointerOfLinkedList = NULL;
  151702           5 :      for ( block = SgBinaryOp::pools.begin(); block != SgBinaryOp::pools.end() ; ++block )
  151703             :         {
  151704           0 :           pointer = (SgBinaryOp*)(*block);
  151705           0 :           for (unsigned i = 0; i < SgBinaryOp::pool_size; ++i )
  151706             :              {
  151707             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  151708             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  151709             :             // memory blocks!.
  151710           0 :                if ( pointer[i].get_freepointer() != NULL )
  151711             :                   {
  151712           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  151713             :                   }
  151714             :                else
  151715             :                   {
  151716           0 :                     if ( pointerOfLinkedList == NULL )
  151717             :                        {
  151718           0 :                          SgBinaryOp::next_node = &(pointer[i]);
  151719             :                        }
  151720             :                     else
  151721             :                        {
  151722             :                       // printf ("In SgBinaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  151723           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  151724             :                        }
  151725             :                     pointerOfLinkedList = &(pointer[i]);
  151726             :                   }
  151727             :               }
  151728             :         }
  151729             : 
  151730           5 :      if ( pointerOfLinkedList != NULL )
  151731             :         {
  151732             :        // printf ("In SgBinaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  151733           0 :           pointerOfLinkedList->set_freepointer(NULL);
  151734             :        // DQ (6/6/2010): Temporary debugging...
  151735             :        //   ROSE_ASSERT(false);
  151736             :         }
  151737             : 
  151738           5 :      return ;
  151739             :    }
  151740             : 
  151741             : //############################################################################
  151742             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  151743             :  * within the memory pool and resets the freepointers, in order to achieve a 
  151744             :  * linked list, that has no jumps and starts at the beginning! This function 
  151745             :  * does not extend the memory pool, since we do not delete any memory blocks,
  151746             :  * but delete the valid objects.  
  151747             :  */
  151748             : void
  151749           0 : SgBinaryOp::clearMemoryPool( )
  151750             :    {
  151751             :   // printf ("Inside of SgBinaryOp::clearMemoryPool() \n");
  151752             : 
  151753           0 :      SgBinaryOp* pointer = NULL, *tempPointer = NULL;
  151754           0 :      std::vector < unsigned char* > :: const_iterator block;
  151755           0 :      if ( SgBinaryOp::pools.empty() == false )
  151756             :         {
  151757           0 :           block = SgBinaryOp::pools.begin() ;
  151758           0 :           SgBinaryOp::next_node = (SgBinaryOp*) (*block);
  151759             : 
  151760           0 :           while ( block != SgBinaryOp::pools.end() )
  151761             :              {
  151762           0 :                pointer = (SgBinaryOp*) (*block);
  151763           0 :                if ( tempPointer != NULL )
  151764             :                   {
  151765           0 :                     tempPointer->set_freepointer(pointer);
  151766             :                   }
  151767           0 :                for (unsigned i = 0; i < SgBinaryOp::pool_size - 1; ++i)
  151768             :                   {
  151769           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  151770             :                   }
  151771           0 :                 pointer[SgBinaryOp::pool_size-1].set_freepointer(NULL);
  151772           0 :                 tempPointer = &(pointer[SgBinaryOp::pool_size-1]);
  151773           0 :                 ++block;
  151774             :              }
  151775             :         }
  151776           0 :    }
  151777             : 
  151778           5 : void SgBinaryOp::deleteMemoryPool() {
  151779           5 :   for (auto p: SgBinaryOp::pools) {
  151780           0 :     ROSE_FREE(p);
  151781             :   }
  151782           5 :   SgBinaryOp::next_node = nullptr;
  151783           5 :   SgBinaryOp::pools.clear();
  151784           5 : }
  151785             : 
  151786             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  151787             : //                 reading multiple binary files to for a single AST.
  151788             : /////////// new version ////////////////////////////////
  151789             : //############################################################################
  151790             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  151791             : void
  151792           2 : SgBinaryOp::extendMemoryPoolForFileIO( )
  151793             :   {
  151794           2 :     size_t blockIndex = SgBinaryOp::pools.size();
  151795           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBinaryOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBinaryOp);
  151796             : 
  151797           2 :     while ( (blockIndex * SgBinaryOp::pool_size) < newPoolSize)
  151798             :       {
  151799             : #if ROSE_ALLOC_TRACE
  151800             :         if (blockIndex > 0) {
  151801             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBinaryOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBinaryOp) = %" PRIuPTR " SgBinaryOp::pool_size = %d \n",
  151802             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBinaryOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBinaryOp),SgBinaryOp::pool_size);
  151803             :         }
  151804             : #endif
  151805             : 
  151806           0 :         SgBinaryOp * pointer = (SgBinaryOp*) ROSE_MALLOC ( SgBinaryOp::pool_size * sizeof(SgBinaryOp) );
  151807           0 :         assert( pointer != NULL );
  151808             : #if ROSE_ALLOC_MEMSET == 1
  151809             :         memset(pointer, 0x00, SgBinaryOp::pool_size * sizeof(SgBinaryOp));
  151810             : #elif ROSE_ALLOC_MEMSET == 2
  151811             :         memset(pointer, 0xCC, SgBinaryOp::pool_size * sizeof(SgBinaryOp));
  151812             : #endif
  151813           0 :         SgBinaryOp::pools.push_back( (unsigned char*)(pointer) );
  151814           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBinaryOp::pool_size * sizeof(SgBinaryOp), V_SgBinaryOp ) );
  151815             : 
  151816           0 :         if ( SgBinaryOp::next_node != NULL ) {
  151817           0 :           if ( blockIndex > 0 ) {
  151818           0 :             SgBinaryOp * blkptr = (SgBinaryOp*)(SgBinaryOp::pools[blockIndex-1]);
  151819           0 :             blkptr[ SgBinaryOp::pool_size - 1 ].set_freepointer(pointer);
  151820             :           }
  151821             :         } else {
  151822           0 :           SgBinaryOp::next_node = pointer;
  151823             :         }
  151824             : 
  151825           0 :         for (unsigned i = 0; i < SgBinaryOp::pool_size-1; ++i)
  151826             :            {
  151827           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  151828             :            }
  151829           0 :         pointer[ SgBinaryOp::pool_size -1 ].set_freepointer(NULL);
  151830             : 
  151831           0 :         blockIndex++;
  151832             :       }
  151833           2 :   }
  151834             : 
  151835             : //############################################################################
  151836             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  151837             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  151838             :  * not compressed. However, that stuff is not yet implemented! 
  151839             :  */
  151840             : unsigned long
  151841           0 : SgBinaryOp::getNumberOfLastValidPointer()
  151842             :    {
  151843           0 :       SgBinaryOp* testPointer = (SgBinaryOp*)(SgBinaryOp::pools.back());
  151844           0 :       unsigned long localIndex = SgBinaryOp::pool_size - 1;
  151845           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  151846             :          {
  151847           0 :            localIndex--;
  151848             :          }
  151849           0 :       return (localIndex + SgBinaryOp::pool_size * (SgBinaryOp::pools.size()-1));
  151850             :    }
  151851             : 
  151852             : //############################################################################
  151853             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  151854             :  * memory pool and initializes the data member in class SgBinaryOpStroageClass
  151855             :  * from its counterpart of SgBinaryOp. The return value is just for checking, 
  151856             :  * that the whole StorageClassArray is initialized!
  151857             :  */
  151858             : unsigned long
  151859           0 : SgBinaryOp::initializeStorageClassArray( SgBinaryOpStorageClass *storageArray )
  151860             :    {
  151861           0 :      unsigned long storageCounter = 0;
  151862           0 :      std::vector < unsigned char* > :: const_iterator block = SgBinaryOp::pools.begin();
  151863           0 :      SgBinaryOp* pointer = NULL;
  151864           0 :      while ( block != SgBinaryOp::pools.end() ) {
  151865           0 :           pointer = (SgBinaryOp*) (*block);
  151866           0 :           for ( unsigned i = 0; i < SgBinaryOp::pool_size; ++i ) {
  151867           0 :                if ( pointer->get_freepointer() != NULL ) {
  151868           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  151869           0 :                  storageArray++;
  151870           0 :                  storageCounter++;
  151871             :                }
  151872           0 :                pointer++;
  151873             :              }
  151874           0 :            block++;
  151875             :         }
  151876           0 :      return storageCounter;
  151877             :    }
  151878             : 
  151879             : /* #line 151880 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  151880             : 
  151881             : 
  151882             : 
  151883             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  151884             : 
  151885             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  151886             : 
  151887             : //############################################################################
  151888             : /* JH (02/02/2006) Constructor of the IR node SgArrowExp that takes its 
  151889             :  * corresponding StorageClass as parameter
  151890             :  */
  151891        1254 : SgArrowExp :: SgArrowExp ( const SgArrowExpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  151892             :    {
  151893             : 
  151894             : 
  151895             : /* #line 151896 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  151896             : 
  151897        1254 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  151898             : 
  151899             : 
  151900             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  151901             : 
  151902             : 
  151903        1254 :    }
  151904             : 
  151905             : //############################################################################
  151906             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  151907             :  * within the working AST. 
  151908             :  */
  151909        7524 : SgArrowExp * SgArrowExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  151910        7524 :      SgArrowExp* returnPointer = NULL;
  151911        7524 :      if ( globalIndex != 0 )
  151912             :         {
  151913             : 
  151914             : #if FILE_IO_EXTRA_CHECK
  151915        7524 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgArrowExp ) ) <= globalIndex ) ;
  151916        7524 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgArrowExp + 1 ) ) );
  151917             : #endif
  151918        7524 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgArrowExp )  
  151919        7524 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgArrowExp );
  151920        7524 :           unsigned long positionInPool = localIndex % SgArrowExp::pool_size;
  151921        7524 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgArrowExp::pool_size;
  151922             : 
  151923             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  151924             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  151925             : 
  151926        7524 :           returnPointer = &( ( (SgArrowExp*)(SgArrowExp::pools[memoryBlock]) ) [positionInPool]) ;
  151927             : 
  151928        7524 :           ROSE_ASSERT( returnPointer != NULL ) ;
  151929             :         }
  151930        7524 :      return returnPointer ;
  151931             :    }
  151932             : 
  151933             : //############################################################################
  151934             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  151935             :   for the AST with the index astIndex
  151936             : */
  151937           0 : SgArrowExp * SgArrowExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  151938           0 :      SgArrowExp* returnPointer = NULL;
  151939           0 :      if ( globalIndex != 0 )
  151940             :         {
  151941             : 
  151942             : #if FILE_IO_EXTRA_CHECK
  151943           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgArrowExp ) ) <= globalIndex ) ;
  151944           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgArrowExp + 1 ) ) );
  151945             : #endif
  151946           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgArrowExp )
  151947           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgArrowExp );
  151948           0 :           unsigned long positionInPool = localIndex % SgArrowExp::pool_size ;
  151949           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgArrowExp::pool_size ;
  151950             : 
  151951             : #if FILE_IO_EXTRA_CHECK
  151952             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  151953             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  151954             : #endif
  151955             : 
  151956           0 :           returnPointer = &( ( (SgArrowExp*)(SgArrowExp::pools[memoryBlock]) ) [positionInPool]) ;
  151957             : 
  151958             : #if FILE_IO_EXTRA_CHECK
  151959           0 :           assert ( returnPointer != NULL ) ;
  151960             : #endif
  151961             :         }
  151962           0 :      return returnPointer ;
  151963             :    }
  151964             : 
  151965             : //############################################################################
  151966             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  151967             :  * pool size! We set for every valid object in the memory pool the freepointer
  151968             :  * to the global index and increase the global index afterwards. For all the 
  151969             :  * invalid objects (means address ranges within the memory pool that were not
  151970             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  151971             :  * distinguish valid from invalid objects! 
  151972             :  */
  151973             : unsigned long
  151974           5 : SgArrowExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  151975             :    {
  151976           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  151977           5 :      SgArrowExp* pointer = NULL;
  151978           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  151979           5 :      std::vector < unsigned char* > :: const_iterator block;
  151980           6 :      for ( block = SgArrowExp::pools.begin(); block != SgArrowExp::pools.end() ; ++block )
  151981             :         {
  151982           1 :           pointer = (SgArrowExp*)(*block);
  151983        2001 :           for (unsigned i = 0; i < SgArrowExp::pool_size; ++i )
  151984             :              {
  151985             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  151986             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  151987             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  151988             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  151989             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  151990             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  151991             :             // properly; so this will have to be checked next.
  151992             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  151993             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  151994        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  151995             :                   {
  151996        1254 :                     pointer[i].set_freepointer((SgArrowExp*)(globalIndex));
  151997        1254 :                     globalIndex++;
  151998             :                   }
  151999             :                else
  152000             :                   {
  152001         746 :                     pointer[i].set_freepointer(NULL);
  152002             :                   }
  152003             :               }
  152004             :         }
  152005           5 :      return globalIndex;
  152006             :    }
  152007             : 
  152008             : //############################################################################
  152009             : // JH (01/14/2006)
  152010             : void
  152011           5 : SgArrowExp::resetValidFreepointers( )
  152012             :    {
  152013           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  152014           5 :      SgArrowExp* pointer = NULL;
  152015           5 :      std::vector < unsigned char* > :: const_iterator block;
  152016           5 :      SgArrowExp* pointerOfLinkedList = NULL;
  152017           6 :      for ( block = SgArrowExp::pools.begin(); block != SgArrowExp::pools.end() ; ++block )
  152018             :         {
  152019           1 :           pointer = (SgArrowExp*)(*block);
  152020        2001 :           for (unsigned i = 0; i < SgArrowExp::pool_size; ++i )
  152021             :              {
  152022             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  152023             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  152024             :             // memory blocks!.
  152025        2000 :                if ( pointer[i].get_freepointer() != NULL )
  152026             :                   {
  152027        1254 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  152028             :                   }
  152029             :                else
  152030             :                   {
  152031         746 :                     if ( pointerOfLinkedList == NULL )
  152032             :                        {
  152033           1 :                          SgArrowExp::next_node = &(pointer[i]);
  152034             :                        }
  152035             :                     else
  152036             :                        {
  152037             :                       // printf ("In SgArrowExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  152038         745 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  152039             :                        }
  152040             :                     pointerOfLinkedList = &(pointer[i]);
  152041             :                   }
  152042             :               }
  152043             :         }
  152044             : 
  152045           5 :      if ( pointerOfLinkedList != NULL )
  152046             :         {
  152047             :        // printf ("In SgArrowExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  152048           1 :           pointerOfLinkedList->set_freepointer(NULL);
  152049             :        // DQ (6/6/2010): Temporary debugging...
  152050             :        //   ROSE_ASSERT(false);
  152051             :         }
  152052             : 
  152053           5 :      return ;
  152054             :    }
  152055             : 
  152056             : //############################################################################
  152057             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  152058             :  * within the memory pool and resets the freepointers, in order to achieve a 
  152059             :  * linked list, that has no jumps and starts at the beginning! This function 
  152060             :  * does not extend the memory pool, since we do not delete any memory blocks,
  152061             :  * but delete the valid objects.  
  152062             :  */
  152063             : void
  152064           0 : SgArrowExp::clearMemoryPool( )
  152065             :    {
  152066             :   // printf ("Inside of SgArrowExp::clearMemoryPool() \n");
  152067             : 
  152068           0 :      SgArrowExp* pointer = NULL, *tempPointer = NULL;
  152069           0 :      std::vector < unsigned char* > :: const_iterator block;
  152070           0 :      if ( SgArrowExp::pools.empty() == false )
  152071             :         {
  152072           0 :           block = SgArrowExp::pools.begin() ;
  152073           0 :           SgArrowExp::next_node = (SgArrowExp*) (*block);
  152074             : 
  152075           0 :           while ( block != SgArrowExp::pools.end() )
  152076             :              {
  152077           0 :                pointer = (SgArrowExp*) (*block);
  152078           0 :                if ( tempPointer != NULL )
  152079             :                   {
  152080           0 :                     tempPointer->set_freepointer(pointer);
  152081             :                   }
  152082           0 :                for (unsigned i = 0; i < SgArrowExp::pool_size - 1; ++i)
  152083             :                   {
  152084           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  152085             :                   }
  152086           0 :                 pointer[SgArrowExp::pool_size-1].set_freepointer(NULL);
  152087           0 :                 tempPointer = &(pointer[SgArrowExp::pool_size-1]);
  152088           0 :                 ++block;
  152089             :              }
  152090             :         }
  152091           0 :    }
  152092             : 
  152093           5 : void SgArrowExp::deleteMemoryPool() {
  152094           7 :   for (auto p: SgArrowExp::pools) {
  152095           2 :     ROSE_FREE(p);
  152096             :   }
  152097           5 :   SgArrowExp::next_node = nullptr;
  152098           5 :   SgArrowExp::pools.clear();
  152099           5 : }
  152100             : 
  152101             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  152102             : //                 reading multiple binary files to for a single AST.
  152103             : /////////// new version ////////////////////////////////
  152104             : //############################################################################
  152105             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  152106             : void
  152107           2 : SgArrowExp::extendMemoryPoolForFileIO( )
  152108             :   {
  152109           2 :     size_t blockIndex = SgArrowExp::pools.size();
  152110           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgArrowExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrowExp);
  152111             : 
  152112           3 :     while ( (blockIndex * SgArrowExp::pool_size) < newPoolSize)
  152113             :       {
  152114             : #if ROSE_ALLOC_TRACE
  152115             :         if (blockIndex > 0) {
  152116             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgArrowExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrowExp) = %" PRIuPTR " SgArrowExp::pool_size = %d \n",
  152117             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgArrowExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrowExp),SgArrowExp::pool_size);
  152118             :         }
  152119             : #endif
  152120             : 
  152121           1 :         SgArrowExp * pointer = (SgArrowExp*) ROSE_MALLOC ( SgArrowExp::pool_size * sizeof(SgArrowExp) );
  152122           1 :         assert( pointer != NULL );
  152123             : #if ROSE_ALLOC_MEMSET == 1
  152124             :         memset(pointer, 0x00, SgArrowExp::pool_size * sizeof(SgArrowExp));
  152125             : #elif ROSE_ALLOC_MEMSET == 2
  152126             :         memset(pointer, 0xCC, SgArrowExp::pool_size * sizeof(SgArrowExp));
  152127             : #endif
  152128           1 :         SgArrowExp::pools.push_back( (unsigned char*)(pointer) );
  152129           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgArrowExp::pool_size * sizeof(SgArrowExp), V_SgArrowExp ) );
  152130             : 
  152131           1 :         if ( SgArrowExp::next_node != NULL ) {
  152132           0 :           if ( blockIndex > 0 ) {
  152133           0 :             SgArrowExp * blkptr = (SgArrowExp*)(SgArrowExp::pools[blockIndex-1]);
  152134           0 :             blkptr[ SgArrowExp::pool_size - 1 ].set_freepointer(pointer);
  152135             :           }
  152136             :         } else {
  152137           1 :           SgArrowExp::next_node = pointer;
  152138             :         }
  152139             : 
  152140        2000 :         for (unsigned i = 0; i < SgArrowExp::pool_size-1; ++i)
  152141             :            {
  152142        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  152143             :            }
  152144           1 :         pointer[ SgArrowExp::pool_size -1 ].set_freepointer(NULL);
  152145             : 
  152146           1 :         blockIndex++;
  152147             :       }
  152148           2 :   }
  152149             : 
  152150             : //############################################################################
  152151             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  152152             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  152153             :  * not compressed. However, that stuff is not yet implemented! 
  152154             :  */
  152155             : unsigned long
  152156           0 : SgArrowExp::getNumberOfLastValidPointer()
  152157             :    {
  152158           0 :       SgArrowExp* testPointer = (SgArrowExp*)(SgArrowExp::pools.back());
  152159           0 :       unsigned long localIndex = SgArrowExp::pool_size - 1;
  152160           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  152161             :          {
  152162           0 :            localIndex--;
  152163             :          }
  152164           0 :       return (localIndex + SgArrowExp::pool_size * (SgArrowExp::pools.size()-1));
  152165             :    }
  152166             : 
  152167             : //############################################################################
  152168             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  152169             :  * memory pool and initializes the data member in class SgArrowExpStroageClass
  152170             :  * from its counterpart of SgArrowExp. The return value is just for checking, 
  152171             :  * that the whole StorageClassArray is initialized!
  152172             :  */
  152173             : unsigned long
  152174           1 : SgArrowExp::initializeStorageClassArray( SgArrowExpStorageClass *storageArray )
  152175             :    {
  152176           1 :      unsigned long storageCounter = 0;
  152177           1 :      std::vector < unsigned char* > :: const_iterator block = SgArrowExp::pools.begin();
  152178           1 :      SgArrowExp* pointer = NULL;
  152179           2 :      while ( block != SgArrowExp::pools.end() ) {
  152180           1 :           pointer = (SgArrowExp*) (*block);
  152181        2001 :           for ( unsigned i = 0; i < SgArrowExp::pool_size; ++i ) {
  152182        2000 :                if ( pointer->get_freepointer() != NULL ) {
  152183        1254 :                  storageArray->pickOutIRNodeData (pointer) ;
  152184        1254 :                  storageArray++;
  152185        1254 :                  storageCounter++;
  152186             :                }
  152187        2000 :                pointer++;
  152188             :              }
  152189           1 :            block++;
  152190             :         }
  152191           1 :      return storageCounter;
  152192             :    }
  152193             : 
  152194             : /* #line 152195 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  152195             : 
  152196             : 
  152197             : 
  152198             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  152199             : 
  152200             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  152201             : 
  152202             : //############################################################################
  152203             : /* JH (02/02/2006) Constructor of the IR node SgDotExp that takes its 
  152204             :  * corresponding StorageClass as parameter
  152205             :  */
  152206         816 : SgDotExp :: SgDotExp ( const SgDotExpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  152207             :    {
  152208             : 
  152209             : 
  152210             : /* #line 152211 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  152211             : 
  152212         816 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  152213             : 
  152214             : 
  152215             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  152216             : 
  152217             : 
  152218         816 :    }
  152219             : 
  152220             : //############################################################################
  152221             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  152222             :  * within the working AST. 
  152223             :  */
  152224        4896 : SgDotExp * SgDotExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  152225        4896 :      SgDotExp* returnPointer = NULL;
  152226        4896 :      if ( globalIndex != 0 )
  152227             :         {
  152228             : 
  152229             : #if FILE_IO_EXTRA_CHECK
  152230        4896 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDotExp ) ) <= globalIndex ) ;
  152231        4896 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDotExp + 1 ) ) );
  152232             : #endif
  152233        4896 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDotExp )  
  152234        4896 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDotExp );
  152235        4896 :           unsigned long positionInPool = localIndex % SgDotExp::pool_size;
  152236        4896 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDotExp::pool_size;
  152237             : 
  152238             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  152239             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  152240             : 
  152241        4896 :           returnPointer = &( ( (SgDotExp*)(SgDotExp::pools[memoryBlock]) ) [positionInPool]) ;
  152242             : 
  152243        4896 :           ROSE_ASSERT( returnPointer != NULL ) ;
  152244             :         }
  152245        4896 :      return returnPointer ;
  152246             :    }
  152247             : 
  152248             : //############################################################################
  152249             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  152250             :   for the AST with the index astIndex
  152251             : */
  152252           0 : SgDotExp * SgDotExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  152253           0 :      SgDotExp* returnPointer = NULL;
  152254           0 :      if ( globalIndex != 0 )
  152255             :         {
  152256             : 
  152257             : #if FILE_IO_EXTRA_CHECK
  152258           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDotExp ) ) <= globalIndex ) ;
  152259           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDotExp + 1 ) ) );
  152260             : #endif
  152261           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDotExp )
  152262           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDotExp );
  152263           0 :           unsigned long positionInPool = localIndex % SgDotExp::pool_size ;
  152264           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDotExp::pool_size ;
  152265             : 
  152266             : #if FILE_IO_EXTRA_CHECK
  152267             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  152268             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  152269             : #endif
  152270             : 
  152271           0 :           returnPointer = &( ( (SgDotExp*)(SgDotExp::pools[memoryBlock]) ) [positionInPool]) ;
  152272             : 
  152273             : #if FILE_IO_EXTRA_CHECK
  152274           0 :           assert ( returnPointer != NULL ) ;
  152275             : #endif
  152276             :         }
  152277           0 :      return returnPointer ;
  152278             :    }
  152279             : 
  152280             : //############################################################################
  152281             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  152282             :  * pool size! We set for every valid object in the memory pool the freepointer
  152283             :  * to the global index and increase the global index afterwards. For all the 
  152284             :  * invalid objects (means address ranges within the memory pool that were not
  152285             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  152286             :  * distinguish valid from invalid objects! 
  152287             :  */
  152288             : unsigned long
  152289           5 : SgDotExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  152290             :    {
  152291           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  152292           5 :      SgDotExp* pointer = NULL;
  152293           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  152294           5 :      std::vector < unsigned char* > :: const_iterator block;
  152295           6 :      for ( block = SgDotExp::pools.begin(); block != SgDotExp::pools.end() ; ++block )
  152296             :         {
  152297           1 :           pointer = (SgDotExp*)(*block);
  152298        2001 :           for (unsigned i = 0; i < SgDotExp::pool_size; ++i )
  152299             :              {
  152300             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  152301             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  152302             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  152303             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  152304             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  152305             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  152306             :             // properly; so this will have to be checked next.
  152307             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  152308             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  152309        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  152310             :                   {
  152311         816 :                     pointer[i].set_freepointer((SgDotExp*)(globalIndex));
  152312         816 :                     globalIndex++;
  152313             :                   }
  152314             :                else
  152315             :                   {
  152316        1184 :                     pointer[i].set_freepointer(NULL);
  152317             :                   }
  152318             :               }
  152319             :         }
  152320           5 :      return globalIndex;
  152321             :    }
  152322             : 
  152323             : //############################################################################
  152324             : // JH (01/14/2006)
  152325             : void
  152326           5 : SgDotExp::resetValidFreepointers( )
  152327             :    {
  152328           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  152329           5 :      SgDotExp* pointer = NULL;
  152330           5 :      std::vector < unsigned char* > :: const_iterator block;
  152331           5 :      SgDotExp* pointerOfLinkedList = NULL;
  152332           6 :      for ( block = SgDotExp::pools.begin(); block != SgDotExp::pools.end() ; ++block )
  152333             :         {
  152334           1 :           pointer = (SgDotExp*)(*block);
  152335        2001 :           for (unsigned i = 0; i < SgDotExp::pool_size; ++i )
  152336             :              {
  152337             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  152338             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  152339             :             // memory blocks!.
  152340        2000 :                if ( pointer[i].get_freepointer() != NULL )
  152341             :                   {
  152342         816 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  152343             :                   }
  152344             :                else
  152345             :                   {
  152346        1184 :                     if ( pointerOfLinkedList == NULL )
  152347             :                        {
  152348           1 :                          SgDotExp::next_node = &(pointer[i]);
  152349             :                        }
  152350             :                     else
  152351             :                        {
  152352             :                       // printf ("In SgDotExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  152353        1183 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  152354             :                        }
  152355             :                     pointerOfLinkedList = &(pointer[i]);
  152356             :                   }
  152357             :               }
  152358             :         }
  152359             : 
  152360           5 :      if ( pointerOfLinkedList != NULL )
  152361             :         {
  152362             :        // printf ("In SgDotExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  152363           1 :           pointerOfLinkedList->set_freepointer(NULL);
  152364             :        // DQ (6/6/2010): Temporary debugging...
  152365             :        //   ROSE_ASSERT(false);
  152366             :         }
  152367             : 
  152368           5 :      return ;
  152369             :    }
  152370             : 
  152371             : //############################################################################
  152372             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  152373             :  * within the memory pool and resets the freepointers, in order to achieve a 
  152374             :  * linked list, that has no jumps and starts at the beginning! This function 
  152375             :  * does not extend the memory pool, since we do not delete any memory blocks,
  152376             :  * but delete the valid objects.  
  152377             :  */
  152378             : void
  152379           0 : SgDotExp::clearMemoryPool( )
  152380             :    {
  152381             :   // printf ("Inside of SgDotExp::clearMemoryPool() \n");
  152382             : 
  152383           0 :      SgDotExp* pointer = NULL, *tempPointer = NULL;
  152384           0 :      std::vector < unsigned char* > :: const_iterator block;
  152385           0 :      if ( SgDotExp::pools.empty() == false )
  152386             :         {
  152387           0 :           block = SgDotExp::pools.begin() ;
  152388           0 :           SgDotExp::next_node = (SgDotExp*) (*block);
  152389             : 
  152390           0 :           while ( block != SgDotExp::pools.end() )
  152391             :              {
  152392           0 :                pointer = (SgDotExp*) (*block);
  152393           0 :                if ( tempPointer != NULL )
  152394             :                   {
  152395           0 :                     tempPointer->set_freepointer(pointer);
  152396             :                   }
  152397           0 :                for (unsigned i = 0; i < SgDotExp::pool_size - 1; ++i)
  152398             :                   {
  152399           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  152400             :                   }
  152401           0 :                 pointer[SgDotExp::pool_size-1].set_freepointer(NULL);
  152402           0 :                 tempPointer = &(pointer[SgDotExp::pool_size-1]);
  152403           0 :                 ++block;
  152404             :              }
  152405             :         }
  152406           0 :    }
  152407             : 
  152408           5 : void SgDotExp::deleteMemoryPool() {
  152409           7 :   for (auto p: SgDotExp::pools) {
  152410           2 :     ROSE_FREE(p);
  152411             :   }
  152412           5 :   SgDotExp::next_node = nullptr;
  152413           5 :   SgDotExp::pools.clear();
  152414           5 : }
  152415             : 
  152416             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  152417             : //                 reading multiple binary files to for a single AST.
  152418             : /////////// new version ////////////////////////////////
  152419             : //############################################################################
  152420             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  152421             : void
  152422           2 : SgDotExp::extendMemoryPoolForFileIO( )
  152423             :   {
  152424           2 :     size_t blockIndex = SgDotExp::pools.size();
  152425           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDotExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDotExp);
  152426             : 
  152427           3 :     while ( (blockIndex * SgDotExp::pool_size) < newPoolSize)
  152428             :       {
  152429             : #if ROSE_ALLOC_TRACE
  152430             :         if (blockIndex > 0) {
  152431             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDotExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDotExp) = %" PRIuPTR " SgDotExp::pool_size = %d \n",
  152432             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDotExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDotExp),SgDotExp::pool_size);
  152433             :         }
  152434             : #endif
  152435             : 
  152436           1 :         SgDotExp * pointer = (SgDotExp*) ROSE_MALLOC ( SgDotExp::pool_size * sizeof(SgDotExp) );
  152437           1 :         assert( pointer != NULL );
  152438             : #if ROSE_ALLOC_MEMSET == 1
  152439             :         memset(pointer, 0x00, SgDotExp::pool_size * sizeof(SgDotExp));
  152440             : #elif ROSE_ALLOC_MEMSET == 2
  152441             :         memset(pointer, 0xCC, SgDotExp::pool_size * sizeof(SgDotExp));
  152442             : #endif
  152443           1 :         SgDotExp::pools.push_back( (unsigned char*)(pointer) );
  152444           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDotExp::pool_size * sizeof(SgDotExp), V_SgDotExp ) );
  152445             : 
  152446           1 :         if ( SgDotExp::next_node != NULL ) {
  152447           0 :           if ( blockIndex > 0 ) {
  152448           0 :             SgDotExp * blkptr = (SgDotExp*)(SgDotExp::pools[blockIndex-1]);
  152449           0 :             blkptr[ SgDotExp::pool_size - 1 ].set_freepointer(pointer);
  152450             :           }
  152451             :         } else {
  152452           1 :           SgDotExp::next_node = pointer;
  152453             :         }
  152454             : 
  152455        2000 :         for (unsigned i = 0; i < SgDotExp::pool_size-1; ++i)
  152456             :            {
  152457        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  152458             :            }
  152459           1 :         pointer[ SgDotExp::pool_size -1 ].set_freepointer(NULL);
  152460             : 
  152461           1 :         blockIndex++;
  152462             :       }
  152463           2 :   }
  152464             : 
  152465             : //############################################################################
  152466             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  152467             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  152468             :  * not compressed. However, that stuff is not yet implemented! 
  152469             :  */
  152470             : unsigned long
  152471           0 : SgDotExp::getNumberOfLastValidPointer()
  152472             :    {
  152473           0 :       SgDotExp* testPointer = (SgDotExp*)(SgDotExp::pools.back());
  152474           0 :       unsigned long localIndex = SgDotExp::pool_size - 1;
  152475           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  152476             :          {
  152477           0 :            localIndex--;
  152478             :          }
  152479           0 :       return (localIndex + SgDotExp::pool_size * (SgDotExp::pools.size()-1));
  152480             :    }
  152481             : 
  152482             : //############################################################################
  152483             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  152484             :  * memory pool and initializes the data member in class SgDotExpStroageClass
  152485             :  * from its counterpart of SgDotExp. The return value is just for checking, 
  152486             :  * that the whole StorageClassArray is initialized!
  152487             :  */
  152488             : unsigned long
  152489           1 : SgDotExp::initializeStorageClassArray( SgDotExpStorageClass *storageArray )
  152490             :    {
  152491           1 :      unsigned long storageCounter = 0;
  152492           1 :      std::vector < unsigned char* > :: const_iterator block = SgDotExp::pools.begin();
  152493           1 :      SgDotExp* pointer = NULL;
  152494           2 :      while ( block != SgDotExp::pools.end() ) {
  152495           1 :           pointer = (SgDotExp*) (*block);
  152496        2001 :           for ( unsigned i = 0; i < SgDotExp::pool_size; ++i ) {
  152497        2000 :                if ( pointer->get_freepointer() != NULL ) {
  152498         816 :                  storageArray->pickOutIRNodeData (pointer) ;
  152499         816 :                  storageArray++;
  152500         816 :                  storageCounter++;
  152501             :                }
  152502        2000 :                pointer++;
  152503             :              }
  152504           1 :            block++;
  152505             :         }
  152506           1 :      return storageCounter;
  152507             :    }
  152508             : 
  152509             : /* #line 152510 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  152510             : 
  152511             : 
  152512             : 
  152513             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  152514             : 
  152515             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  152516             : 
  152517             : //############################################################################
  152518             : /* JH (02/02/2006) Constructor of the IR node SgDotStarOp that takes its 
  152519             :  * corresponding StorageClass as parameter
  152520             :  */
  152521          12 : SgDotStarOp :: SgDotStarOp ( const SgDotStarOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  152522             :    {
  152523             : 
  152524             : 
  152525             : /* #line 152526 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  152526             : 
  152527          12 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  152528             : 
  152529             : 
  152530             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  152531             : 
  152532             : 
  152533          12 :    }
  152534             : 
  152535             : //############################################################################
  152536             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  152537             :  * within the working AST. 
  152538             :  */
  152539          72 : SgDotStarOp * SgDotStarOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  152540          72 :      SgDotStarOp* returnPointer = NULL;
  152541          72 :      if ( globalIndex != 0 )
  152542             :         {
  152543             : 
  152544             : #if FILE_IO_EXTRA_CHECK
  152545          72 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDotStarOp ) ) <= globalIndex ) ;
  152546          72 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDotStarOp + 1 ) ) );
  152547             : #endif
  152548          72 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDotStarOp )  
  152549          72 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDotStarOp );
  152550          72 :           unsigned long positionInPool = localIndex % SgDotStarOp::pool_size;
  152551          72 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDotStarOp::pool_size;
  152552             : 
  152553             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  152554             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  152555             : 
  152556          72 :           returnPointer = &( ( (SgDotStarOp*)(SgDotStarOp::pools[memoryBlock]) ) [positionInPool]) ;
  152557             : 
  152558          72 :           ROSE_ASSERT( returnPointer != NULL ) ;
  152559             :         }
  152560          72 :      return returnPointer ;
  152561             :    }
  152562             : 
  152563             : //############################################################################
  152564             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  152565             :   for the AST with the index astIndex
  152566             : */
  152567           0 : SgDotStarOp * SgDotStarOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  152568           0 :      SgDotStarOp* returnPointer = NULL;
  152569           0 :      if ( globalIndex != 0 )
  152570             :         {
  152571             : 
  152572             : #if FILE_IO_EXTRA_CHECK
  152573           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDotStarOp ) ) <= globalIndex ) ;
  152574           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDotStarOp + 1 ) ) );
  152575             : #endif
  152576           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDotStarOp )
  152577           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDotStarOp );
  152578           0 :           unsigned long positionInPool = localIndex % SgDotStarOp::pool_size ;
  152579           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDotStarOp::pool_size ;
  152580             : 
  152581             : #if FILE_IO_EXTRA_CHECK
  152582             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  152583             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  152584             : #endif
  152585             : 
  152586           0 :           returnPointer = &( ( (SgDotStarOp*)(SgDotStarOp::pools[memoryBlock]) ) [positionInPool]) ;
  152587             : 
  152588             : #if FILE_IO_EXTRA_CHECK
  152589           0 :           assert ( returnPointer != NULL ) ;
  152590             : #endif
  152591             :         }
  152592           0 :      return returnPointer ;
  152593             :    }
  152594             : 
  152595             : //############################################################################
  152596             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  152597             :  * pool size! We set for every valid object in the memory pool the freepointer
  152598             :  * to the global index and increase the global index afterwards. For all the 
  152599             :  * invalid objects (means address ranges within the memory pool that were not
  152600             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  152601             :  * distinguish valid from invalid objects! 
  152602             :  */
  152603             : unsigned long
  152604           5 : SgDotStarOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  152605             :    {
  152606           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  152607           5 :      SgDotStarOp* pointer = NULL;
  152608           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  152609           5 :      std::vector < unsigned char* > :: const_iterator block;
  152610           6 :      for ( block = SgDotStarOp::pools.begin(); block != SgDotStarOp::pools.end() ; ++block )
  152611             :         {
  152612           1 :           pointer = (SgDotStarOp*)(*block);
  152613        2001 :           for (unsigned i = 0; i < SgDotStarOp::pool_size; ++i )
  152614             :              {
  152615             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  152616             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  152617             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  152618             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  152619             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  152620             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  152621             :             // properly; so this will have to be checked next.
  152622             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  152623             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  152624        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  152625             :                   {
  152626          12 :                     pointer[i].set_freepointer((SgDotStarOp*)(globalIndex));
  152627          12 :                     globalIndex++;
  152628             :                   }
  152629             :                else
  152630             :                   {
  152631        1988 :                     pointer[i].set_freepointer(NULL);
  152632             :                   }
  152633             :               }
  152634             :         }
  152635           5 :      return globalIndex;
  152636             :    }
  152637             : 
  152638             : //############################################################################
  152639             : // JH (01/14/2006)
  152640             : void
  152641           5 : SgDotStarOp::resetValidFreepointers( )
  152642             :    {
  152643           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  152644           5 :      SgDotStarOp* pointer = NULL;
  152645           5 :      std::vector < unsigned char* > :: const_iterator block;
  152646           5 :      SgDotStarOp* pointerOfLinkedList = NULL;
  152647           6 :      for ( block = SgDotStarOp::pools.begin(); block != SgDotStarOp::pools.end() ; ++block )
  152648             :         {
  152649           1 :           pointer = (SgDotStarOp*)(*block);
  152650        2001 :           for (unsigned i = 0; i < SgDotStarOp::pool_size; ++i )
  152651             :              {
  152652             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  152653             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  152654             :             // memory blocks!.
  152655        2000 :                if ( pointer[i].get_freepointer() != NULL )
  152656             :                   {
  152657          12 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  152658             :                   }
  152659             :                else
  152660             :                   {
  152661        1988 :                     if ( pointerOfLinkedList == NULL )
  152662             :                        {
  152663           1 :                          SgDotStarOp::next_node = &(pointer[i]);
  152664             :                        }
  152665             :                     else
  152666             :                        {
  152667             :                       // printf ("In SgDotStarOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  152668        1987 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  152669             :                        }
  152670             :                     pointerOfLinkedList = &(pointer[i]);
  152671             :                   }
  152672             :               }
  152673             :         }
  152674             : 
  152675           5 :      if ( pointerOfLinkedList != NULL )
  152676             :         {
  152677             :        // printf ("In SgDotStarOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  152678           1 :           pointerOfLinkedList->set_freepointer(NULL);
  152679             :        // DQ (6/6/2010): Temporary debugging...
  152680             :        //   ROSE_ASSERT(false);
  152681             :         }
  152682             : 
  152683           5 :      return ;
  152684             :    }
  152685             : 
  152686             : //############################################################################
  152687             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  152688             :  * within the memory pool and resets the freepointers, in order to achieve a 
  152689             :  * linked list, that has no jumps and starts at the beginning! This function 
  152690             :  * does not extend the memory pool, since we do not delete any memory blocks,
  152691             :  * but delete the valid objects.  
  152692             :  */
  152693             : void
  152694           0 : SgDotStarOp::clearMemoryPool( )
  152695             :    {
  152696             :   // printf ("Inside of SgDotStarOp::clearMemoryPool() \n");
  152697             : 
  152698           0 :      SgDotStarOp* pointer = NULL, *tempPointer = NULL;
  152699           0 :      std::vector < unsigned char* > :: const_iterator block;
  152700           0 :      if ( SgDotStarOp::pools.empty() == false )
  152701             :         {
  152702           0 :           block = SgDotStarOp::pools.begin() ;
  152703           0 :           SgDotStarOp::next_node = (SgDotStarOp*) (*block);
  152704             : 
  152705           0 :           while ( block != SgDotStarOp::pools.end() )
  152706             :              {
  152707           0 :                pointer = (SgDotStarOp*) (*block);
  152708           0 :                if ( tempPointer != NULL )
  152709             :                   {
  152710           0 :                     tempPointer->set_freepointer(pointer);
  152711             :                   }
  152712           0 :                for (unsigned i = 0; i < SgDotStarOp::pool_size - 1; ++i)
  152713             :                   {
  152714           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  152715             :                   }
  152716           0 :                 pointer[SgDotStarOp::pool_size-1].set_freepointer(NULL);
  152717           0 :                 tempPointer = &(pointer[SgDotStarOp::pool_size-1]);
  152718           0 :                 ++block;
  152719             :              }
  152720             :         }
  152721           0 :    }
  152722             : 
  152723           5 : void SgDotStarOp::deleteMemoryPool() {
  152724           7 :   for (auto p: SgDotStarOp::pools) {
  152725           2 :     ROSE_FREE(p);
  152726             :   }
  152727           5 :   SgDotStarOp::next_node = nullptr;
  152728           5 :   SgDotStarOp::pools.clear();
  152729           5 : }
  152730             : 
  152731             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  152732             : //                 reading multiple binary files to for a single AST.
  152733             : /////////// new version ////////////////////////////////
  152734             : //############################################################################
  152735             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  152736             : void
  152737           2 : SgDotStarOp::extendMemoryPoolForFileIO( )
  152738             :   {
  152739           2 :     size_t blockIndex = SgDotStarOp::pools.size();
  152740           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDotStarOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDotStarOp);
  152741             : 
  152742           3 :     while ( (blockIndex * SgDotStarOp::pool_size) < newPoolSize)
  152743             :       {
  152744             : #if ROSE_ALLOC_TRACE
  152745             :         if (blockIndex > 0) {
  152746             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDotStarOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDotStarOp) = %" PRIuPTR " SgDotStarOp::pool_size = %d \n",
  152747             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDotStarOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDotStarOp),SgDotStarOp::pool_size);
  152748             :         }
  152749             : #endif
  152750             : 
  152751           1 :         SgDotStarOp * pointer = (SgDotStarOp*) ROSE_MALLOC ( SgDotStarOp::pool_size * sizeof(SgDotStarOp) );
  152752           1 :         assert( pointer != NULL );
  152753             : #if ROSE_ALLOC_MEMSET == 1
  152754             :         memset(pointer, 0x00, SgDotStarOp::pool_size * sizeof(SgDotStarOp));
  152755             : #elif ROSE_ALLOC_MEMSET == 2
  152756             :         memset(pointer, 0xCC, SgDotStarOp::pool_size * sizeof(SgDotStarOp));
  152757             : #endif
  152758           1 :         SgDotStarOp::pools.push_back( (unsigned char*)(pointer) );
  152759           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDotStarOp::pool_size * sizeof(SgDotStarOp), V_SgDotStarOp ) );
  152760             : 
  152761           1 :         if ( SgDotStarOp::next_node != NULL ) {
  152762           0 :           if ( blockIndex > 0 ) {
  152763           0 :             SgDotStarOp * blkptr = (SgDotStarOp*)(SgDotStarOp::pools[blockIndex-1]);
  152764           0 :             blkptr[ SgDotStarOp::pool_size - 1 ].set_freepointer(pointer);
  152765             :           }
  152766             :         } else {
  152767           1 :           SgDotStarOp::next_node = pointer;
  152768             :         }
  152769             : 
  152770        2000 :         for (unsigned i = 0; i < SgDotStarOp::pool_size-1; ++i)
  152771             :            {
  152772        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  152773             :            }
  152774           1 :         pointer[ SgDotStarOp::pool_size -1 ].set_freepointer(NULL);
  152775             : 
  152776           1 :         blockIndex++;
  152777             :       }
  152778           2 :   }
  152779             : 
  152780             : //############################################################################
  152781             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  152782             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  152783             :  * not compressed. However, that stuff is not yet implemented! 
  152784             :  */
  152785             : unsigned long
  152786           0 : SgDotStarOp::getNumberOfLastValidPointer()
  152787             :    {
  152788           0 :       SgDotStarOp* testPointer = (SgDotStarOp*)(SgDotStarOp::pools.back());
  152789           0 :       unsigned long localIndex = SgDotStarOp::pool_size - 1;
  152790           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  152791             :          {
  152792           0 :            localIndex--;
  152793             :          }
  152794           0 :       return (localIndex + SgDotStarOp::pool_size * (SgDotStarOp::pools.size()-1));
  152795             :    }
  152796             : 
  152797             : //############################################################################
  152798             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  152799             :  * memory pool and initializes the data member in class SgDotStarOpStroageClass
  152800             :  * from its counterpart of SgDotStarOp. The return value is just for checking, 
  152801             :  * that the whole StorageClassArray is initialized!
  152802             :  */
  152803             : unsigned long
  152804           1 : SgDotStarOp::initializeStorageClassArray( SgDotStarOpStorageClass *storageArray )
  152805             :    {
  152806           1 :      unsigned long storageCounter = 0;
  152807           1 :      std::vector < unsigned char* > :: const_iterator block = SgDotStarOp::pools.begin();
  152808           1 :      SgDotStarOp* pointer = NULL;
  152809           2 :      while ( block != SgDotStarOp::pools.end() ) {
  152810           1 :           pointer = (SgDotStarOp*) (*block);
  152811        2001 :           for ( unsigned i = 0; i < SgDotStarOp::pool_size; ++i ) {
  152812        2000 :                if ( pointer->get_freepointer() != NULL ) {
  152813          12 :                  storageArray->pickOutIRNodeData (pointer) ;
  152814          12 :                  storageArray++;
  152815          12 :                  storageCounter++;
  152816             :                }
  152817        2000 :                pointer++;
  152818             :              }
  152819           1 :            block++;
  152820             :         }
  152821           1 :      return storageCounter;
  152822             :    }
  152823             : 
  152824             : /* #line 152825 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  152825             : 
  152826             : 
  152827             : 
  152828             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  152829             : 
  152830             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  152831             : 
  152832             : //############################################################################
  152833             : /* JH (02/02/2006) Constructor of the IR node SgArrowStarOp that takes its 
  152834             :  * corresponding StorageClass as parameter
  152835             :  */
  152836           4 : SgArrowStarOp :: SgArrowStarOp ( const SgArrowStarOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  152837             :    {
  152838             : 
  152839             : 
  152840             : /* #line 152841 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  152841             : 
  152842           4 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  152843             : 
  152844             : 
  152845             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  152846             : 
  152847             : 
  152848           4 :    }
  152849             : 
  152850             : //############################################################################
  152851             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  152852             :  * within the working AST. 
  152853             :  */
  152854          24 : SgArrowStarOp * SgArrowStarOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  152855          24 :      SgArrowStarOp* returnPointer = NULL;
  152856          24 :      if ( globalIndex != 0 )
  152857             :         {
  152858             : 
  152859             : #if FILE_IO_EXTRA_CHECK
  152860          24 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgArrowStarOp ) ) <= globalIndex ) ;
  152861          24 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgArrowStarOp + 1 ) ) );
  152862             : #endif
  152863          24 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgArrowStarOp )  
  152864          24 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgArrowStarOp );
  152865          24 :           unsigned long positionInPool = localIndex % SgArrowStarOp::pool_size;
  152866          24 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgArrowStarOp::pool_size;
  152867             : 
  152868             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  152869             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  152870             : 
  152871          24 :           returnPointer = &( ( (SgArrowStarOp*)(SgArrowStarOp::pools[memoryBlock]) ) [positionInPool]) ;
  152872             : 
  152873          24 :           ROSE_ASSERT( returnPointer != NULL ) ;
  152874             :         }
  152875          24 :      return returnPointer ;
  152876             :    }
  152877             : 
  152878             : //############################################################################
  152879             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  152880             :   for the AST with the index astIndex
  152881             : */
  152882           0 : SgArrowStarOp * SgArrowStarOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  152883           0 :      SgArrowStarOp* returnPointer = NULL;
  152884           0 :      if ( globalIndex != 0 )
  152885             :         {
  152886             : 
  152887             : #if FILE_IO_EXTRA_CHECK
  152888           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgArrowStarOp ) ) <= globalIndex ) ;
  152889           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgArrowStarOp + 1 ) ) );
  152890             : #endif
  152891           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgArrowStarOp )
  152892           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgArrowStarOp );
  152893           0 :           unsigned long positionInPool = localIndex % SgArrowStarOp::pool_size ;
  152894           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgArrowStarOp::pool_size ;
  152895             : 
  152896             : #if FILE_IO_EXTRA_CHECK
  152897             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  152898             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  152899             : #endif
  152900             : 
  152901           0 :           returnPointer = &( ( (SgArrowStarOp*)(SgArrowStarOp::pools[memoryBlock]) ) [positionInPool]) ;
  152902             : 
  152903             : #if FILE_IO_EXTRA_CHECK
  152904           0 :           assert ( returnPointer != NULL ) ;
  152905             : #endif
  152906             :         }
  152907           0 :      return returnPointer ;
  152908             :    }
  152909             : 
  152910             : //############################################################################
  152911             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  152912             :  * pool size! We set for every valid object in the memory pool the freepointer
  152913             :  * to the global index and increase the global index afterwards. For all the 
  152914             :  * invalid objects (means address ranges within the memory pool that were not
  152915             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  152916             :  * distinguish valid from invalid objects! 
  152917             :  */
  152918             : unsigned long
  152919           5 : SgArrowStarOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  152920             :    {
  152921           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  152922           5 :      SgArrowStarOp* pointer = NULL;
  152923           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  152924           5 :      std::vector < unsigned char* > :: const_iterator block;
  152925           6 :      for ( block = SgArrowStarOp::pools.begin(); block != SgArrowStarOp::pools.end() ; ++block )
  152926             :         {
  152927           1 :           pointer = (SgArrowStarOp*)(*block);
  152928        2001 :           for (unsigned i = 0; i < SgArrowStarOp::pool_size; ++i )
  152929             :              {
  152930             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  152931             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  152932             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  152933             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  152934             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  152935             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  152936             :             // properly; so this will have to be checked next.
  152937             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  152938             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  152939        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  152940             :                   {
  152941           4 :                     pointer[i].set_freepointer((SgArrowStarOp*)(globalIndex));
  152942           4 :                     globalIndex++;
  152943             :                   }
  152944             :                else
  152945             :                   {
  152946        1996 :                     pointer[i].set_freepointer(NULL);
  152947             :                   }
  152948             :               }
  152949             :         }
  152950           5 :      return globalIndex;
  152951             :    }
  152952             : 
  152953             : //############################################################################
  152954             : // JH (01/14/2006)
  152955             : void
  152956           5 : SgArrowStarOp::resetValidFreepointers( )
  152957             :    {
  152958           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  152959           5 :      SgArrowStarOp* pointer = NULL;
  152960           5 :      std::vector < unsigned char* > :: const_iterator block;
  152961           5 :      SgArrowStarOp* pointerOfLinkedList = NULL;
  152962           6 :      for ( block = SgArrowStarOp::pools.begin(); block != SgArrowStarOp::pools.end() ; ++block )
  152963             :         {
  152964           1 :           pointer = (SgArrowStarOp*)(*block);
  152965        2001 :           for (unsigned i = 0; i < SgArrowStarOp::pool_size; ++i )
  152966             :              {
  152967             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  152968             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  152969             :             // memory blocks!.
  152970        2000 :                if ( pointer[i].get_freepointer() != NULL )
  152971             :                   {
  152972           4 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  152973             :                   }
  152974             :                else
  152975             :                   {
  152976        1996 :                     if ( pointerOfLinkedList == NULL )
  152977             :                        {
  152978           1 :                          SgArrowStarOp::next_node = &(pointer[i]);
  152979             :                        }
  152980             :                     else
  152981             :                        {
  152982             :                       // printf ("In SgArrowStarOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  152983        1995 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  152984             :                        }
  152985             :                     pointerOfLinkedList = &(pointer[i]);
  152986             :                   }
  152987             :               }
  152988             :         }
  152989             : 
  152990           5 :      if ( pointerOfLinkedList != NULL )
  152991             :         {
  152992             :        // printf ("In SgArrowStarOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  152993           1 :           pointerOfLinkedList->set_freepointer(NULL);
  152994             :        // DQ (6/6/2010): Temporary debugging...
  152995             :        //   ROSE_ASSERT(false);
  152996             :         }
  152997             : 
  152998           5 :      return ;
  152999             :    }
  153000             : 
  153001             : //############################################################################
  153002             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  153003             :  * within the memory pool and resets the freepointers, in order to achieve a 
  153004             :  * linked list, that has no jumps and starts at the beginning! This function 
  153005             :  * does not extend the memory pool, since we do not delete any memory blocks,
  153006             :  * but delete the valid objects.  
  153007             :  */
  153008             : void
  153009           0 : SgArrowStarOp::clearMemoryPool( )
  153010             :    {
  153011             :   // printf ("Inside of SgArrowStarOp::clearMemoryPool() \n");
  153012             : 
  153013           0 :      SgArrowStarOp* pointer = NULL, *tempPointer = NULL;
  153014           0 :      std::vector < unsigned char* > :: const_iterator block;
  153015           0 :      if ( SgArrowStarOp::pools.empty() == false )
  153016             :         {
  153017           0 :           block = SgArrowStarOp::pools.begin() ;
  153018           0 :           SgArrowStarOp::next_node = (SgArrowStarOp*) (*block);
  153019             : 
  153020           0 :           while ( block != SgArrowStarOp::pools.end() )
  153021             :              {
  153022           0 :                pointer = (SgArrowStarOp*) (*block);
  153023           0 :                if ( tempPointer != NULL )
  153024             :                   {
  153025           0 :                     tempPointer->set_freepointer(pointer);
  153026             :                   }
  153027           0 :                for (unsigned i = 0; i < SgArrowStarOp::pool_size - 1; ++i)
  153028             :                   {
  153029           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  153030             :                   }
  153031           0 :                 pointer[SgArrowStarOp::pool_size-1].set_freepointer(NULL);
  153032           0 :                 tempPointer = &(pointer[SgArrowStarOp::pool_size-1]);
  153033           0 :                 ++block;
  153034             :              }
  153035             :         }
  153036           0 :    }
  153037             : 
  153038           5 : void SgArrowStarOp::deleteMemoryPool() {
  153039           7 :   for (auto p: SgArrowStarOp::pools) {
  153040           2 :     ROSE_FREE(p);
  153041             :   }
  153042           5 :   SgArrowStarOp::next_node = nullptr;
  153043           5 :   SgArrowStarOp::pools.clear();
  153044           5 : }
  153045             : 
  153046             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  153047             : //                 reading multiple binary files to for a single AST.
  153048             : /////////// new version ////////////////////////////////
  153049             : //############################################################################
  153050             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  153051             : void
  153052           2 : SgArrowStarOp::extendMemoryPoolForFileIO( )
  153053             :   {
  153054           2 :     size_t blockIndex = SgArrowStarOp::pools.size();
  153055           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgArrowStarOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrowStarOp);
  153056             : 
  153057           3 :     while ( (blockIndex * SgArrowStarOp::pool_size) < newPoolSize)
  153058             :       {
  153059             : #if ROSE_ALLOC_TRACE
  153060             :         if (blockIndex > 0) {
  153061             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgArrowStarOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrowStarOp) = %" PRIuPTR " SgArrowStarOp::pool_size = %d \n",
  153062             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgArrowStarOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgArrowStarOp),SgArrowStarOp::pool_size);
  153063             :         }
  153064             : #endif
  153065             : 
  153066           1 :         SgArrowStarOp * pointer = (SgArrowStarOp*) ROSE_MALLOC ( SgArrowStarOp::pool_size * sizeof(SgArrowStarOp) );
  153067           1 :         assert( pointer != NULL );
  153068             : #if ROSE_ALLOC_MEMSET == 1
  153069             :         memset(pointer, 0x00, SgArrowStarOp::pool_size * sizeof(SgArrowStarOp));
  153070             : #elif ROSE_ALLOC_MEMSET == 2
  153071             :         memset(pointer, 0xCC, SgArrowStarOp::pool_size * sizeof(SgArrowStarOp));
  153072             : #endif
  153073           1 :         SgArrowStarOp::pools.push_back( (unsigned char*)(pointer) );
  153074           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgArrowStarOp::pool_size * sizeof(SgArrowStarOp), V_SgArrowStarOp ) );
  153075             : 
  153076           1 :         if ( SgArrowStarOp::next_node != NULL ) {
  153077           0 :           if ( blockIndex > 0 ) {
  153078           0 :             SgArrowStarOp * blkptr = (SgArrowStarOp*)(SgArrowStarOp::pools[blockIndex-1]);
  153079           0 :             blkptr[ SgArrowStarOp::pool_size - 1 ].set_freepointer(pointer);
  153080             :           }
  153081             :         } else {
  153082           1 :           SgArrowStarOp::next_node = pointer;
  153083             :         }
  153084             : 
  153085        2000 :         for (unsigned i = 0; i < SgArrowStarOp::pool_size-1; ++i)
  153086             :            {
  153087        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  153088             :            }
  153089           1 :         pointer[ SgArrowStarOp::pool_size -1 ].set_freepointer(NULL);
  153090             : 
  153091           1 :         blockIndex++;
  153092             :       }
  153093           2 :   }
  153094             : 
  153095             : //############################################################################
  153096             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  153097             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  153098             :  * not compressed. However, that stuff is not yet implemented! 
  153099             :  */
  153100             : unsigned long
  153101           0 : SgArrowStarOp::getNumberOfLastValidPointer()
  153102             :    {
  153103           0 :       SgArrowStarOp* testPointer = (SgArrowStarOp*)(SgArrowStarOp::pools.back());
  153104           0 :       unsigned long localIndex = SgArrowStarOp::pool_size - 1;
  153105           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  153106             :          {
  153107           0 :            localIndex--;
  153108             :          }
  153109           0 :       return (localIndex + SgArrowStarOp::pool_size * (SgArrowStarOp::pools.size()-1));
  153110             :    }
  153111             : 
  153112             : //############################################################################
  153113             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  153114             :  * memory pool and initializes the data member in class SgArrowStarOpStroageClass
  153115             :  * from its counterpart of SgArrowStarOp. The return value is just for checking, 
  153116             :  * that the whole StorageClassArray is initialized!
  153117             :  */
  153118             : unsigned long
  153119           1 : SgArrowStarOp::initializeStorageClassArray( SgArrowStarOpStorageClass *storageArray )
  153120             :    {
  153121           1 :      unsigned long storageCounter = 0;
  153122           1 :      std::vector < unsigned char* > :: const_iterator block = SgArrowStarOp::pools.begin();
  153123           1 :      SgArrowStarOp* pointer = NULL;
  153124           2 :      while ( block != SgArrowStarOp::pools.end() ) {
  153125           1 :           pointer = (SgArrowStarOp*) (*block);
  153126        2001 :           for ( unsigned i = 0; i < SgArrowStarOp::pool_size; ++i ) {
  153127        2000 :                if ( pointer->get_freepointer() != NULL ) {
  153128           4 :                  storageArray->pickOutIRNodeData (pointer) ;
  153129           4 :                  storageArray++;
  153130           4 :                  storageCounter++;
  153131             :                }
  153132        2000 :                pointer++;
  153133             :              }
  153134           1 :            block++;
  153135             :         }
  153136           1 :      return storageCounter;
  153137             :    }
  153138             : 
  153139             : /* #line 153140 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  153140             : 
  153141             : 
  153142             : 
  153143             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  153144             : 
  153145             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  153146             : 
  153147             : //############################################################################
  153148             : /* JH (02/02/2006) Constructor of the IR node SgEqualityOp that takes its 
  153149             :  * corresponding StorageClass as parameter
  153150             :  */
  153151         250 : SgEqualityOp :: SgEqualityOp ( const SgEqualityOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  153152             :    {
  153153             : 
  153154             : 
  153155             : /* #line 153156 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  153156             : 
  153157         250 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  153158             : 
  153159             : 
  153160             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  153161             : 
  153162             : 
  153163         250 :    }
  153164             : 
  153165             : //############################################################################
  153166             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  153167             :  * within the working AST. 
  153168             :  */
  153169        1500 : SgEqualityOp * SgEqualityOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  153170        1500 :      SgEqualityOp* returnPointer = NULL;
  153171        1500 :      if ( globalIndex != 0 )
  153172             :         {
  153173             : 
  153174             : #if FILE_IO_EXTRA_CHECK
  153175        1500 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEqualityOp ) ) <= globalIndex ) ;
  153176        1500 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEqualityOp + 1 ) ) );
  153177             : #endif
  153178        1500 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEqualityOp )  
  153179        1500 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEqualityOp );
  153180        1500 :           unsigned long positionInPool = localIndex % SgEqualityOp::pool_size;
  153181        1500 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEqualityOp::pool_size;
  153182             : 
  153183             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  153184             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  153185             : 
  153186        1500 :           returnPointer = &( ( (SgEqualityOp*)(SgEqualityOp::pools[memoryBlock]) ) [positionInPool]) ;
  153187             : 
  153188        1500 :           ROSE_ASSERT( returnPointer != NULL ) ;
  153189             :         }
  153190        1500 :      return returnPointer ;
  153191             :    }
  153192             : 
  153193             : //############################################################################
  153194             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  153195             :   for the AST with the index astIndex
  153196             : */
  153197           0 : SgEqualityOp * SgEqualityOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  153198           0 :      SgEqualityOp* returnPointer = NULL;
  153199           0 :      if ( globalIndex != 0 )
  153200             :         {
  153201             : 
  153202             : #if FILE_IO_EXTRA_CHECK
  153203           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEqualityOp ) ) <= globalIndex ) ;
  153204           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEqualityOp + 1 ) ) );
  153205             : #endif
  153206           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEqualityOp )
  153207           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEqualityOp );
  153208           0 :           unsigned long positionInPool = localIndex % SgEqualityOp::pool_size ;
  153209           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEqualityOp::pool_size ;
  153210             : 
  153211             : #if FILE_IO_EXTRA_CHECK
  153212             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  153213             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  153214             : #endif
  153215             : 
  153216           0 :           returnPointer = &( ( (SgEqualityOp*)(SgEqualityOp::pools[memoryBlock]) ) [positionInPool]) ;
  153217             : 
  153218             : #if FILE_IO_EXTRA_CHECK
  153219           0 :           assert ( returnPointer != NULL ) ;
  153220             : #endif
  153221             :         }
  153222           0 :      return returnPointer ;
  153223             :    }
  153224             : 
  153225             : //############################################################################
  153226             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  153227             :  * pool size! We set for every valid object in the memory pool the freepointer
  153228             :  * to the global index and increase the global index afterwards. For all the 
  153229             :  * invalid objects (means address ranges within the memory pool that were not
  153230             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  153231             :  * distinguish valid from invalid objects! 
  153232             :  */
  153233             : unsigned long
  153234           5 : SgEqualityOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  153235             :    {
  153236           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  153237           5 :      SgEqualityOp* pointer = NULL;
  153238           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  153239           5 :      std::vector < unsigned char* > :: const_iterator block;
  153240           6 :      for ( block = SgEqualityOp::pools.begin(); block != SgEqualityOp::pools.end() ; ++block )
  153241             :         {
  153242           1 :           pointer = (SgEqualityOp*)(*block);
  153243        2001 :           for (unsigned i = 0; i < SgEqualityOp::pool_size; ++i )
  153244             :              {
  153245             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  153246             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  153247             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  153248             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  153249             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  153250             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  153251             :             // properly; so this will have to be checked next.
  153252             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  153253             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  153254        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  153255             :                   {
  153256         250 :                     pointer[i].set_freepointer((SgEqualityOp*)(globalIndex));
  153257         250 :                     globalIndex++;
  153258             :                   }
  153259             :                else
  153260             :                   {
  153261        1750 :                     pointer[i].set_freepointer(NULL);
  153262             :                   }
  153263             :               }
  153264             :         }
  153265           5 :      return globalIndex;
  153266             :    }
  153267             : 
  153268             : //############################################################################
  153269             : // JH (01/14/2006)
  153270             : void
  153271           5 : SgEqualityOp::resetValidFreepointers( )
  153272             :    {
  153273           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  153274           5 :      SgEqualityOp* pointer = NULL;
  153275           5 :      std::vector < unsigned char* > :: const_iterator block;
  153276           5 :      SgEqualityOp* pointerOfLinkedList = NULL;
  153277           6 :      for ( block = SgEqualityOp::pools.begin(); block != SgEqualityOp::pools.end() ; ++block )
  153278             :         {
  153279           1 :           pointer = (SgEqualityOp*)(*block);
  153280        2001 :           for (unsigned i = 0; i < SgEqualityOp::pool_size; ++i )
  153281             :              {
  153282             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  153283             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  153284             :             // memory blocks!.
  153285        2000 :                if ( pointer[i].get_freepointer() != NULL )
  153286             :                   {
  153287         250 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  153288             :                   }
  153289             :                else
  153290             :                   {
  153291        1750 :                     if ( pointerOfLinkedList == NULL )
  153292             :                        {
  153293           1 :                          SgEqualityOp::next_node = &(pointer[i]);
  153294             :                        }
  153295             :                     else
  153296             :                        {
  153297             :                       // printf ("In SgEqualityOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  153298        1749 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  153299             :                        }
  153300             :                     pointerOfLinkedList = &(pointer[i]);
  153301             :                   }
  153302             :               }
  153303             :         }
  153304             : 
  153305           5 :      if ( pointerOfLinkedList != NULL )
  153306             :         {
  153307             :        // printf ("In SgEqualityOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  153308           1 :           pointerOfLinkedList->set_freepointer(NULL);
  153309             :        // DQ (6/6/2010): Temporary debugging...
  153310             :        //   ROSE_ASSERT(false);
  153311             :         }
  153312             : 
  153313           5 :      return ;
  153314             :    }
  153315             : 
  153316             : //############################################################################
  153317             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  153318             :  * within the memory pool and resets the freepointers, in order to achieve a 
  153319             :  * linked list, that has no jumps and starts at the beginning! This function 
  153320             :  * does not extend the memory pool, since we do not delete any memory blocks,
  153321             :  * but delete the valid objects.  
  153322             :  */
  153323             : void
  153324           0 : SgEqualityOp::clearMemoryPool( )
  153325             :    {
  153326             :   // printf ("Inside of SgEqualityOp::clearMemoryPool() \n");
  153327             : 
  153328           0 :      SgEqualityOp* pointer = NULL, *tempPointer = NULL;
  153329           0 :      std::vector < unsigned char* > :: const_iterator block;
  153330           0 :      if ( SgEqualityOp::pools.empty() == false )
  153331             :         {
  153332           0 :           block = SgEqualityOp::pools.begin() ;
  153333           0 :           SgEqualityOp::next_node = (SgEqualityOp*) (*block);
  153334             : 
  153335           0 :           while ( block != SgEqualityOp::pools.end() )
  153336             :              {
  153337           0 :                pointer = (SgEqualityOp*) (*block);
  153338           0 :                if ( tempPointer != NULL )
  153339             :                   {
  153340           0 :                     tempPointer->set_freepointer(pointer);
  153341             :                   }
  153342           0 :                for (unsigned i = 0; i < SgEqualityOp::pool_size - 1; ++i)
  153343             :                   {
  153344           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  153345             :                   }
  153346           0 :                 pointer[SgEqualityOp::pool_size-1].set_freepointer(NULL);
  153347           0 :                 tempPointer = &(pointer[SgEqualityOp::pool_size-1]);
  153348           0 :                 ++block;
  153349             :              }
  153350             :         }
  153351           0 :    }
  153352             : 
  153353           5 : void SgEqualityOp::deleteMemoryPool() {
  153354           7 :   for (auto p: SgEqualityOp::pools) {
  153355           2 :     ROSE_FREE(p);
  153356             :   }
  153357           5 :   SgEqualityOp::next_node = nullptr;
  153358           5 :   SgEqualityOp::pools.clear();
  153359           5 : }
  153360             : 
  153361             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  153362             : //                 reading multiple binary files to for a single AST.
  153363             : /////////// new version ////////////////////////////////
  153364             : //############################################################################
  153365             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  153366             : void
  153367           2 : SgEqualityOp::extendMemoryPoolForFileIO( )
  153368             :   {
  153369           2 :     size_t blockIndex = SgEqualityOp::pools.size();
  153370           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEqualityOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEqualityOp);
  153371             : 
  153372           3 :     while ( (blockIndex * SgEqualityOp::pool_size) < newPoolSize)
  153373             :       {
  153374             : #if ROSE_ALLOC_TRACE
  153375             :         if (blockIndex > 0) {
  153376             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEqualityOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEqualityOp) = %" PRIuPTR " SgEqualityOp::pool_size = %d \n",
  153377             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEqualityOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEqualityOp),SgEqualityOp::pool_size);
  153378             :         }
  153379             : #endif
  153380             : 
  153381           1 :         SgEqualityOp * pointer = (SgEqualityOp*) ROSE_MALLOC ( SgEqualityOp::pool_size * sizeof(SgEqualityOp) );
  153382           1 :         assert( pointer != NULL );
  153383             : #if ROSE_ALLOC_MEMSET == 1
  153384             :         memset(pointer, 0x00, SgEqualityOp::pool_size * sizeof(SgEqualityOp));
  153385             : #elif ROSE_ALLOC_MEMSET == 2
  153386             :         memset(pointer, 0xCC, SgEqualityOp::pool_size * sizeof(SgEqualityOp));
  153387             : #endif
  153388           1 :         SgEqualityOp::pools.push_back( (unsigned char*)(pointer) );
  153389           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEqualityOp::pool_size * sizeof(SgEqualityOp), V_SgEqualityOp ) );
  153390             : 
  153391           1 :         if ( SgEqualityOp::next_node != NULL ) {
  153392           0 :           if ( blockIndex > 0 ) {
  153393           0 :             SgEqualityOp * blkptr = (SgEqualityOp*)(SgEqualityOp::pools[blockIndex-1]);
  153394           0 :             blkptr[ SgEqualityOp::pool_size - 1 ].set_freepointer(pointer);
  153395             :           }
  153396             :         } else {
  153397           1 :           SgEqualityOp::next_node = pointer;
  153398             :         }
  153399             : 
  153400        2000 :         for (unsigned i = 0; i < SgEqualityOp::pool_size-1; ++i)
  153401             :            {
  153402        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  153403             :            }
  153404           1 :         pointer[ SgEqualityOp::pool_size -1 ].set_freepointer(NULL);
  153405             : 
  153406           1 :         blockIndex++;
  153407             :       }
  153408           2 :   }
  153409             : 
  153410             : //############################################################################
  153411             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  153412             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  153413             :  * not compressed. However, that stuff is not yet implemented! 
  153414             :  */
  153415             : unsigned long
  153416           0 : SgEqualityOp::getNumberOfLastValidPointer()
  153417             :    {
  153418           0 :       SgEqualityOp* testPointer = (SgEqualityOp*)(SgEqualityOp::pools.back());
  153419           0 :       unsigned long localIndex = SgEqualityOp::pool_size - 1;
  153420           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  153421             :          {
  153422           0 :            localIndex--;
  153423             :          }
  153424           0 :       return (localIndex + SgEqualityOp::pool_size * (SgEqualityOp::pools.size()-1));
  153425             :    }
  153426             : 
  153427             : //############################################################################
  153428             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  153429             :  * memory pool and initializes the data member in class SgEqualityOpStroageClass
  153430             :  * from its counterpart of SgEqualityOp. The return value is just for checking, 
  153431             :  * that the whole StorageClassArray is initialized!
  153432             :  */
  153433             : unsigned long
  153434           1 : SgEqualityOp::initializeStorageClassArray( SgEqualityOpStorageClass *storageArray )
  153435             :    {
  153436           1 :      unsigned long storageCounter = 0;
  153437           1 :      std::vector < unsigned char* > :: const_iterator block = SgEqualityOp::pools.begin();
  153438           1 :      SgEqualityOp* pointer = NULL;
  153439           2 :      while ( block != SgEqualityOp::pools.end() ) {
  153440           1 :           pointer = (SgEqualityOp*) (*block);
  153441        2001 :           for ( unsigned i = 0; i < SgEqualityOp::pool_size; ++i ) {
  153442        2000 :                if ( pointer->get_freepointer() != NULL ) {
  153443         250 :                  storageArray->pickOutIRNodeData (pointer) ;
  153444         250 :                  storageArray++;
  153445         250 :                  storageCounter++;
  153446             :                }
  153447        2000 :                pointer++;
  153448             :              }
  153449           1 :            block++;
  153450             :         }
  153451           1 :      return storageCounter;
  153452             :    }
  153453             : 
  153454             : /* #line 153455 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  153455             : 
  153456             : 
  153457             : 
  153458             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  153459             : 
  153460             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  153461             : 
  153462             : //############################################################################
  153463             : /* JH (02/02/2006) Constructor of the IR node SgLessThanOp that takes its 
  153464             :  * corresponding StorageClass as parameter
  153465             :  */
  153466         136 : SgLessThanOp :: SgLessThanOp ( const SgLessThanOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  153467             :    {
  153468             : 
  153469             : 
  153470             : /* #line 153471 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  153471             : 
  153472         136 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  153473             : 
  153474             : 
  153475             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  153476             : 
  153477             : 
  153478         136 :    }
  153479             : 
  153480             : //############################################################################
  153481             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  153482             :  * within the working AST. 
  153483             :  */
  153484         816 : SgLessThanOp * SgLessThanOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  153485         816 :      SgLessThanOp* returnPointer = NULL;
  153486         816 :      if ( globalIndex != 0 )
  153487             :         {
  153488             : 
  153489             : #if FILE_IO_EXTRA_CHECK
  153490         816 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLessThanOp ) ) <= globalIndex ) ;
  153491         816 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLessThanOp + 1 ) ) );
  153492             : #endif
  153493         816 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLessThanOp )  
  153494         816 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLessThanOp );
  153495         816 :           unsigned long positionInPool = localIndex % SgLessThanOp::pool_size;
  153496         816 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLessThanOp::pool_size;
  153497             : 
  153498             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  153499             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  153500             : 
  153501         816 :           returnPointer = &( ( (SgLessThanOp*)(SgLessThanOp::pools[memoryBlock]) ) [positionInPool]) ;
  153502             : 
  153503         816 :           ROSE_ASSERT( returnPointer != NULL ) ;
  153504             :         }
  153505         816 :      return returnPointer ;
  153506             :    }
  153507             : 
  153508             : //############################################################################
  153509             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  153510             :   for the AST with the index astIndex
  153511             : */
  153512           0 : SgLessThanOp * SgLessThanOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  153513           0 :      SgLessThanOp* returnPointer = NULL;
  153514           0 :      if ( globalIndex != 0 )
  153515             :         {
  153516             : 
  153517             : #if FILE_IO_EXTRA_CHECK
  153518           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLessThanOp ) ) <= globalIndex ) ;
  153519           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLessThanOp + 1 ) ) );
  153520             : #endif
  153521           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLessThanOp )
  153522           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLessThanOp );
  153523           0 :           unsigned long positionInPool = localIndex % SgLessThanOp::pool_size ;
  153524           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLessThanOp::pool_size ;
  153525             : 
  153526             : #if FILE_IO_EXTRA_CHECK
  153527             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  153528             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  153529             : #endif
  153530             : 
  153531           0 :           returnPointer = &( ( (SgLessThanOp*)(SgLessThanOp::pools[memoryBlock]) ) [positionInPool]) ;
  153532             : 
  153533             : #if FILE_IO_EXTRA_CHECK
  153534           0 :           assert ( returnPointer != NULL ) ;
  153535             : #endif
  153536             :         }
  153537           0 :      return returnPointer ;
  153538             :    }
  153539             : 
  153540             : //############################################################################
  153541             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  153542             :  * pool size! We set for every valid object in the memory pool the freepointer
  153543             :  * to the global index and increase the global index afterwards. For all the 
  153544             :  * invalid objects (means address ranges within the memory pool that were not
  153545             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  153546             :  * distinguish valid from invalid objects! 
  153547             :  */
  153548             : unsigned long
  153549           5 : SgLessThanOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  153550             :    {
  153551           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  153552           5 :      SgLessThanOp* pointer = NULL;
  153553           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  153554           5 :      std::vector < unsigned char* > :: const_iterator block;
  153555           6 :      for ( block = SgLessThanOp::pools.begin(); block != SgLessThanOp::pools.end() ; ++block )
  153556             :         {
  153557           1 :           pointer = (SgLessThanOp*)(*block);
  153558        2001 :           for (unsigned i = 0; i < SgLessThanOp::pool_size; ++i )
  153559             :              {
  153560             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  153561             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  153562             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  153563             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  153564             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  153565             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  153566             :             // properly; so this will have to be checked next.
  153567             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  153568             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  153569        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  153570             :                   {
  153571         136 :                     pointer[i].set_freepointer((SgLessThanOp*)(globalIndex));
  153572         136 :                     globalIndex++;
  153573             :                   }
  153574             :                else
  153575             :                   {
  153576        1864 :                     pointer[i].set_freepointer(NULL);
  153577             :                   }
  153578             :               }
  153579             :         }
  153580           5 :      return globalIndex;
  153581             :    }
  153582             : 
  153583             : //############################################################################
  153584             : // JH (01/14/2006)
  153585             : void
  153586           5 : SgLessThanOp::resetValidFreepointers( )
  153587             :    {
  153588           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  153589           5 :      SgLessThanOp* pointer = NULL;
  153590           5 :      std::vector < unsigned char* > :: const_iterator block;
  153591           5 :      SgLessThanOp* pointerOfLinkedList = NULL;
  153592           6 :      for ( block = SgLessThanOp::pools.begin(); block != SgLessThanOp::pools.end() ; ++block )
  153593             :         {
  153594           1 :           pointer = (SgLessThanOp*)(*block);
  153595        2001 :           for (unsigned i = 0; i < SgLessThanOp::pool_size; ++i )
  153596             :              {
  153597             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  153598             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  153599             :             // memory blocks!.
  153600        2000 :                if ( pointer[i].get_freepointer() != NULL )
  153601             :                   {
  153602         136 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  153603             :                   }
  153604             :                else
  153605             :                   {
  153606        1864 :                     if ( pointerOfLinkedList == NULL )
  153607             :                        {
  153608           1 :                          SgLessThanOp::next_node = &(pointer[i]);
  153609             :                        }
  153610             :                     else
  153611             :                        {
  153612             :                       // printf ("In SgLessThanOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  153613        1863 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  153614             :                        }
  153615             :                     pointerOfLinkedList = &(pointer[i]);
  153616             :                   }
  153617             :               }
  153618             :         }
  153619             : 
  153620           5 :      if ( pointerOfLinkedList != NULL )
  153621             :         {
  153622             :        // printf ("In SgLessThanOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  153623           1 :           pointerOfLinkedList->set_freepointer(NULL);
  153624             :        // DQ (6/6/2010): Temporary debugging...
  153625             :        //   ROSE_ASSERT(false);
  153626             :         }
  153627             : 
  153628           5 :      return ;
  153629             :    }
  153630             : 
  153631             : //############################################################################
  153632             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  153633             :  * within the memory pool and resets the freepointers, in order to achieve a 
  153634             :  * linked list, that has no jumps and starts at the beginning! This function 
  153635             :  * does not extend the memory pool, since we do not delete any memory blocks,
  153636             :  * but delete the valid objects.  
  153637             :  */
  153638             : void
  153639           0 : SgLessThanOp::clearMemoryPool( )
  153640             :    {
  153641             :   // printf ("Inside of SgLessThanOp::clearMemoryPool() \n");
  153642             : 
  153643           0 :      SgLessThanOp* pointer = NULL, *tempPointer = NULL;
  153644           0 :      std::vector < unsigned char* > :: const_iterator block;
  153645           0 :      if ( SgLessThanOp::pools.empty() == false )
  153646             :         {
  153647           0 :           block = SgLessThanOp::pools.begin() ;
  153648           0 :           SgLessThanOp::next_node = (SgLessThanOp*) (*block);
  153649             : 
  153650           0 :           while ( block != SgLessThanOp::pools.end() )
  153651             :              {
  153652           0 :                pointer = (SgLessThanOp*) (*block);
  153653           0 :                if ( tempPointer != NULL )
  153654             :                   {
  153655           0 :                     tempPointer->set_freepointer(pointer);
  153656             :                   }
  153657           0 :                for (unsigned i = 0; i < SgLessThanOp::pool_size - 1; ++i)
  153658             :                   {
  153659           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  153660             :                   }
  153661           0 :                 pointer[SgLessThanOp::pool_size-1].set_freepointer(NULL);
  153662           0 :                 tempPointer = &(pointer[SgLessThanOp::pool_size-1]);
  153663           0 :                 ++block;
  153664             :              }
  153665             :         }
  153666           0 :    }
  153667             : 
  153668           5 : void SgLessThanOp::deleteMemoryPool() {
  153669           7 :   for (auto p: SgLessThanOp::pools) {
  153670           2 :     ROSE_FREE(p);
  153671             :   }
  153672           5 :   SgLessThanOp::next_node = nullptr;
  153673           5 :   SgLessThanOp::pools.clear();
  153674           5 : }
  153675             : 
  153676             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  153677             : //                 reading multiple binary files to for a single AST.
  153678             : /////////// new version ////////////////////////////////
  153679             : //############################################################################
  153680             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  153681             : void
  153682           2 : SgLessThanOp::extendMemoryPoolForFileIO( )
  153683             :   {
  153684           2 :     size_t blockIndex = SgLessThanOp::pools.size();
  153685           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLessThanOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLessThanOp);
  153686             : 
  153687           3 :     while ( (blockIndex * SgLessThanOp::pool_size) < newPoolSize)
  153688             :       {
  153689             : #if ROSE_ALLOC_TRACE
  153690             :         if (blockIndex > 0) {
  153691             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLessThanOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLessThanOp) = %" PRIuPTR " SgLessThanOp::pool_size = %d \n",
  153692             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLessThanOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLessThanOp),SgLessThanOp::pool_size);
  153693             :         }
  153694             : #endif
  153695             : 
  153696           1 :         SgLessThanOp * pointer = (SgLessThanOp*) ROSE_MALLOC ( SgLessThanOp::pool_size * sizeof(SgLessThanOp) );
  153697           1 :         assert( pointer != NULL );
  153698             : #if ROSE_ALLOC_MEMSET == 1
  153699             :         memset(pointer, 0x00, SgLessThanOp::pool_size * sizeof(SgLessThanOp));
  153700             : #elif ROSE_ALLOC_MEMSET == 2
  153701             :         memset(pointer, 0xCC, SgLessThanOp::pool_size * sizeof(SgLessThanOp));
  153702             : #endif
  153703           1 :         SgLessThanOp::pools.push_back( (unsigned char*)(pointer) );
  153704           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLessThanOp::pool_size * sizeof(SgLessThanOp), V_SgLessThanOp ) );
  153705             : 
  153706           1 :         if ( SgLessThanOp::next_node != NULL ) {
  153707           0 :           if ( blockIndex > 0 ) {
  153708           0 :             SgLessThanOp * blkptr = (SgLessThanOp*)(SgLessThanOp::pools[blockIndex-1]);
  153709           0 :             blkptr[ SgLessThanOp::pool_size - 1 ].set_freepointer(pointer);
  153710             :           }
  153711             :         } else {
  153712           1 :           SgLessThanOp::next_node = pointer;
  153713             :         }
  153714             : 
  153715        2000 :         for (unsigned i = 0; i < SgLessThanOp::pool_size-1; ++i)
  153716             :            {
  153717        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  153718             :            }
  153719           1 :         pointer[ SgLessThanOp::pool_size -1 ].set_freepointer(NULL);
  153720             : 
  153721           1 :         blockIndex++;
  153722             :       }
  153723           2 :   }
  153724             : 
  153725             : //############################################################################
  153726             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  153727             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  153728             :  * not compressed. However, that stuff is not yet implemented! 
  153729             :  */
  153730             : unsigned long
  153731           0 : SgLessThanOp::getNumberOfLastValidPointer()
  153732             :    {
  153733           0 :       SgLessThanOp* testPointer = (SgLessThanOp*)(SgLessThanOp::pools.back());
  153734           0 :       unsigned long localIndex = SgLessThanOp::pool_size - 1;
  153735           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  153736             :          {
  153737           0 :            localIndex--;
  153738             :          }
  153739           0 :       return (localIndex + SgLessThanOp::pool_size * (SgLessThanOp::pools.size()-1));
  153740             :    }
  153741             : 
  153742             : //############################################################################
  153743             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  153744             :  * memory pool and initializes the data member in class SgLessThanOpStroageClass
  153745             :  * from its counterpart of SgLessThanOp. The return value is just for checking, 
  153746             :  * that the whole StorageClassArray is initialized!
  153747             :  */
  153748             : unsigned long
  153749           1 : SgLessThanOp::initializeStorageClassArray( SgLessThanOpStorageClass *storageArray )
  153750             :    {
  153751           1 :      unsigned long storageCounter = 0;
  153752           1 :      std::vector < unsigned char* > :: const_iterator block = SgLessThanOp::pools.begin();
  153753           1 :      SgLessThanOp* pointer = NULL;
  153754           2 :      while ( block != SgLessThanOp::pools.end() ) {
  153755           1 :           pointer = (SgLessThanOp*) (*block);
  153756        2001 :           for ( unsigned i = 0; i < SgLessThanOp::pool_size; ++i ) {
  153757        2000 :                if ( pointer->get_freepointer() != NULL ) {
  153758         136 :                  storageArray->pickOutIRNodeData (pointer) ;
  153759         136 :                  storageArray++;
  153760         136 :                  storageCounter++;
  153761             :                }
  153762        2000 :                pointer++;
  153763             :              }
  153764           1 :            block++;
  153765             :         }
  153766           1 :      return storageCounter;
  153767             :    }
  153768             : 
  153769             : /* #line 153770 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  153770             : 
  153771             : 
  153772             : 
  153773             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  153774             : 
  153775             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  153776             : 
  153777             : //############################################################################
  153778             : /* JH (02/02/2006) Constructor of the IR node SgGreaterThanOp that takes its 
  153779             :  * corresponding StorageClass as parameter
  153780             :  */
  153781         108 : SgGreaterThanOp :: SgGreaterThanOp ( const SgGreaterThanOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  153782             :    {
  153783             : 
  153784             : 
  153785             : /* #line 153786 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  153786             : 
  153787         108 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  153788             : 
  153789             : 
  153790             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  153791             : 
  153792             : 
  153793         108 :    }
  153794             : 
  153795             : //############################################################################
  153796             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  153797             :  * within the working AST. 
  153798             :  */
  153799         648 : SgGreaterThanOp * SgGreaterThanOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  153800         648 :      SgGreaterThanOp* returnPointer = NULL;
  153801         648 :      if ( globalIndex != 0 )
  153802             :         {
  153803             : 
  153804             : #if FILE_IO_EXTRA_CHECK
  153805         648 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGreaterThanOp ) ) <= globalIndex ) ;
  153806         648 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGreaterThanOp + 1 ) ) );
  153807             : #endif
  153808         648 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGreaterThanOp )  
  153809         648 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGreaterThanOp );
  153810         648 :           unsigned long positionInPool = localIndex % SgGreaterThanOp::pool_size;
  153811         648 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGreaterThanOp::pool_size;
  153812             : 
  153813             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  153814             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  153815             : 
  153816         648 :           returnPointer = &( ( (SgGreaterThanOp*)(SgGreaterThanOp::pools[memoryBlock]) ) [positionInPool]) ;
  153817             : 
  153818         648 :           ROSE_ASSERT( returnPointer != NULL ) ;
  153819             :         }
  153820         648 :      return returnPointer ;
  153821             :    }
  153822             : 
  153823             : //############################################################################
  153824             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  153825             :   for the AST with the index astIndex
  153826             : */
  153827           0 : SgGreaterThanOp * SgGreaterThanOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  153828           0 :      SgGreaterThanOp* returnPointer = NULL;
  153829           0 :      if ( globalIndex != 0 )
  153830             :         {
  153831             : 
  153832             : #if FILE_IO_EXTRA_CHECK
  153833           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGreaterThanOp ) ) <= globalIndex ) ;
  153834           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGreaterThanOp + 1 ) ) );
  153835             : #endif
  153836           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGreaterThanOp )
  153837           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGreaterThanOp );
  153838           0 :           unsigned long positionInPool = localIndex % SgGreaterThanOp::pool_size ;
  153839           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGreaterThanOp::pool_size ;
  153840             : 
  153841             : #if FILE_IO_EXTRA_CHECK
  153842             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  153843             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  153844             : #endif
  153845             : 
  153846           0 :           returnPointer = &( ( (SgGreaterThanOp*)(SgGreaterThanOp::pools[memoryBlock]) ) [positionInPool]) ;
  153847             : 
  153848             : #if FILE_IO_EXTRA_CHECK
  153849           0 :           assert ( returnPointer != NULL ) ;
  153850             : #endif
  153851             :         }
  153852           0 :      return returnPointer ;
  153853             :    }
  153854             : 
  153855             : //############################################################################
  153856             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  153857             :  * pool size! We set for every valid object in the memory pool the freepointer
  153858             :  * to the global index and increase the global index afterwards. For all the 
  153859             :  * invalid objects (means address ranges within the memory pool that were not
  153860             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  153861             :  * distinguish valid from invalid objects! 
  153862             :  */
  153863             : unsigned long
  153864           5 : SgGreaterThanOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  153865             :    {
  153866           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  153867           5 :      SgGreaterThanOp* pointer = NULL;
  153868           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  153869           5 :      std::vector < unsigned char* > :: const_iterator block;
  153870           6 :      for ( block = SgGreaterThanOp::pools.begin(); block != SgGreaterThanOp::pools.end() ; ++block )
  153871             :         {
  153872           1 :           pointer = (SgGreaterThanOp*)(*block);
  153873        2001 :           for (unsigned i = 0; i < SgGreaterThanOp::pool_size; ++i )
  153874             :              {
  153875             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  153876             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  153877             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  153878             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  153879             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  153880             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  153881             :             // properly; so this will have to be checked next.
  153882             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  153883             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  153884        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  153885             :                   {
  153886         108 :                     pointer[i].set_freepointer((SgGreaterThanOp*)(globalIndex));
  153887         108 :                     globalIndex++;
  153888             :                   }
  153889             :                else
  153890             :                   {
  153891        1892 :                     pointer[i].set_freepointer(NULL);
  153892             :                   }
  153893             :               }
  153894             :         }
  153895           5 :      return globalIndex;
  153896             :    }
  153897             : 
  153898             : //############################################################################
  153899             : // JH (01/14/2006)
  153900             : void
  153901           5 : SgGreaterThanOp::resetValidFreepointers( )
  153902             :    {
  153903           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  153904           5 :      SgGreaterThanOp* pointer = NULL;
  153905           5 :      std::vector < unsigned char* > :: const_iterator block;
  153906           5 :      SgGreaterThanOp* pointerOfLinkedList = NULL;
  153907           6 :      for ( block = SgGreaterThanOp::pools.begin(); block != SgGreaterThanOp::pools.end() ; ++block )
  153908             :         {
  153909           1 :           pointer = (SgGreaterThanOp*)(*block);
  153910        2001 :           for (unsigned i = 0; i < SgGreaterThanOp::pool_size; ++i )
  153911             :              {
  153912             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  153913             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  153914             :             // memory blocks!.
  153915        2000 :                if ( pointer[i].get_freepointer() != NULL )
  153916             :                   {
  153917         108 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  153918             :                   }
  153919             :                else
  153920             :                   {
  153921        1892 :                     if ( pointerOfLinkedList == NULL )
  153922             :                        {
  153923           1 :                          SgGreaterThanOp::next_node = &(pointer[i]);
  153924             :                        }
  153925             :                     else
  153926             :                        {
  153927             :                       // printf ("In SgGreaterThanOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  153928        1891 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  153929             :                        }
  153930             :                     pointerOfLinkedList = &(pointer[i]);
  153931             :                   }
  153932             :               }
  153933             :         }
  153934             : 
  153935           5 :      if ( pointerOfLinkedList != NULL )
  153936             :         {
  153937             :        // printf ("In SgGreaterThanOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  153938           1 :           pointerOfLinkedList->set_freepointer(NULL);
  153939             :        // DQ (6/6/2010): Temporary debugging...
  153940             :        //   ROSE_ASSERT(false);
  153941             :         }
  153942             : 
  153943           5 :      return ;
  153944             :    }
  153945             : 
  153946             : //############################################################################
  153947             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  153948             :  * within the memory pool and resets the freepointers, in order to achieve a 
  153949             :  * linked list, that has no jumps and starts at the beginning! This function 
  153950             :  * does not extend the memory pool, since we do not delete any memory blocks,
  153951             :  * but delete the valid objects.  
  153952             :  */
  153953             : void
  153954           0 : SgGreaterThanOp::clearMemoryPool( )
  153955             :    {
  153956             :   // printf ("Inside of SgGreaterThanOp::clearMemoryPool() \n");
  153957             : 
  153958           0 :      SgGreaterThanOp* pointer = NULL, *tempPointer = NULL;
  153959           0 :      std::vector < unsigned char* > :: const_iterator block;
  153960           0 :      if ( SgGreaterThanOp::pools.empty() == false )
  153961             :         {
  153962           0 :           block = SgGreaterThanOp::pools.begin() ;
  153963           0 :           SgGreaterThanOp::next_node = (SgGreaterThanOp*) (*block);
  153964             : 
  153965           0 :           while ( block != SgGreaterThanOp::pools.end() )
  153966             :              {
  153967           0 :                pointer = (SgGreaterThanOp*) (*block);
  153968           0 :                if ( tempPointer != NULL )
  153969             :                   {
  153970           0 :                     tempPointer->set_freepointer(pointer);
  153971             :                   }
  153972           0 :                for (unsigned i = 0; i < SgGreaterThanOp::pool_size - 1; ++i)
  153973             :                   {
  153974           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  153975             :                   }
  153976           0 :                 pointer[SgGreaterThanOp::pool_size-1].set_freepointer(NULL);
  153977           0 :                 tempPointer = &(pointer[SgGreaterThanOp::pool_size-1]);
  153978           0 :                 ++block;
  153979             :              }
  153980             :         }
  153981           0 :    }
  153982             : 
  153983           5 : void SgGreaterThanOp::deleteMemoryPool() {
  153984           7 :   for (auto p: SgGreaterThanOp::pools) {
  153985           2 :     ROSE_FREE(p);
  153986             :   }
  153987           5 :   SgGreaterThanOp::next_node = nullptr;
  153988           5 :   SgGreaterThanOp::pools.clear();
  153989           5 : }
  153990             : 
  153991             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  153992             : //                 reading multiple binary files to for a single AST.
  153993             : /////////// new version ////////////////////////////////
  153994             : //############################################################################
  153995             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  153996             : void
  153997           2 : SgGreaterThanOp::extendMemoryPoolForFileIO( )
  153998             :   {
  153999           2 :     size_t blockIndex = SgGreaterThanOp::pools.size();
  154000           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGreaterThanOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGreaterThanOp);
  154001             : 
  154002           3 :     while ( (blockIndex * SgGreaterThanOp::pool_size) < newPoolSize)
  154003             :       {
  154004             : #if ROSE_ALLOC_TRACE
  154005             :         if (blockIndex > 0) {
  154006             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGreaterThanOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGreaterThanOp) = %" PRIuPTR " SgGreaterThanOp::pool_size = %d \n",
  154007             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGreaterThanOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGreaterThanOp),SgGreaterThanOp::pool_size);
  154008             :         }
  154009             : #endif
  154010             : 
  154011           1 :         SgGreaterThanOp * pointer = (SgGreaterThanOp*) ROSE_MALLOC ( SgGreaterThanOp::pool_size * sizeof(SgGreaterThanOp) );
  154012           1 :         assert( pointer != NULL );
  154013             : #if ROSE_ALLOC_MEMSET == 1
  154014             :         memset(pointer, 0x00, SgGreaterThanOp::pool_size * sizeof(SgGreaterThanOp));
  154015             : #elif ROSE_ALLOC_MEMSET == 2
  154016             :         memset(pointer, 0xCC, SgGreaterThanOp::pool_size * sizeof(SgGreaterThanOp));
  154017             : #endif
  154018           1 :         SgGreaterThanOp::pools.push_back( (unsigned char*)(pointer) );
  154019           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGreaterThanOp::pool_size * sizeof(SgGreaterThanOp), V_SgGreaterThanOp ) );
  154020             : 
  154021           1 :         if ( SgGreaterThanOp::next_node != NULL ) {
  154022           0 :           if ( blockIndex > 0 ) {
  154023           0 :             SgGreaterThanOp * blkptr = (SgGreaterThanOp*)(SgGreaterThanOp::pools[blockIndex-1]);
  154024           0 :             blkptr[ SgGreaterThanOp::pool_size - 1 ].set_freepointer(pointer);
  154025             :           }
  154026             :         } else {
  154027           1 :           SgGreaterThanOp::next_node = pointer;
  154028             :         }
  154029             : 
  154030        2000 :         for (unsigned i = 0; i < SgGreaterThanOp::pool_size-1; ++i)
  154031             :            {
  154032        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  154033             :            }
  154034           1 :         pointer[ SgGreaterThanOp::pool_size -1 ].set_freepointer(NULL);
  154035             : 
  154036           1 :         blockIndex++;
  154037             :       }
  154038           2 :   }
  154039             : 
  154040             : //############################################################################
  154041             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  154042             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  154043             :  * not compressed. However, that stuff is not yet implemented! 
  154044             :  */
  154045             : unsigned long
  154046           0 : SgGreaterThanOp::getNumberOfLastValidPointer()
  154047             :    {
  154048           0 :       SgGreaterThanOp* testPointer = (SgGreaterThanOp*)(SgGreaterThanOp::pools.back());
  154049           0 :       unsigned long localIndex = SgGreaterThanOp::pool_size - 1;
  154050           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  154051             :          {
  154052           0 :            localIndex--;
  154053             :          }
  154054           0 :       return (localIndex + SgGreaterThanOp::pool_size * (SgGreaterThanOp::pools.size()-1));
  154055             :    }
  154056             : 
  154057             : //############################################################################
  154058             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  154059             :  * memory pool and initializes the data member in class SgGreaterThanOpStroageClass
  154060             :  * from its counterpart of SgGreaterThanOp. The return value is just for checking, 
  154061             :  * that the whole StorageClassArray is initialized!
  154062             :  */
  154063             : unsigned long
  154064           1 : SgGreaterThanOp::initializeStorageClassArray( SgGreaterThanOpStorageClass *storageArray )
  154065             :    {
  154066           1 :      unsigned long storageCounter = 0;
  154067           1 :      std::vector < unsigned char* > :: const_iterator block = SgGreaterThanOp::pools.begin();
  154068           1 :      SgGreaterThanOp* pointer = NULL;
  154069           2 :      while ( block != SgGreaterThanOp::pools.end() ) {
  154070           1 :           pointer = (SgGreaterThanOp*) (*block);
  154071        2001 :           for ( unsigned i = 0; i < SgGreaterThanOp::pool_size; ++i ) {
  154072        2000 :                if ( pointer->get_freepointer() != NULL ) {
  154073         108 :                  storageArray->pickOutIRNodeData (pointer) ;
  154074         108 :                  storageArray++;
  154075         108 :                  storageCounter++;
  154076             :                }
  154077        2000 :                pointer++;
  154078             :              }
  154079           1 :            block++;
  154080             :         }
  154081           1 :      return storageCounter;
  154082             :    }
  154083             : 
  154084             : /* #line 154085 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  154085             : 
  154086             : 
  154087             : 
  154088             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  154089             : 
  154090             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  154091             : 
  154092             : //############################################################################
  154093             : /* JH (02/02/2006) Constructor of the IR node SgNotEqualOp that takes its 
  154094             :  * corresponding StorageClass as parameter
  154095             :  */
  154096          95 : SgNotEqualOp :: SgNotEqualOp ( const SgNotEqualOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  154097             :    {
  154098             : 
  154099             : 
  154100             : /* #line 154101 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  154101             : 
  154102          95 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  154103             : 
  154104             : 
  154105             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  154106             : 
  154107             : 
  154108          95 :    }
  154109             : 
  154110             : //############################################################################
  154111             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  154112             :  * within the working AST. 
  154113             :  */
  154114         570 : SgNotEqualOp * SgNotEqualOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  154115         570 :      SgNotEqualOp* returnPointer = NULL;
  154116         570 :      if ( globalIndex != 0 )
  154117             :         {
  154118             : 
  154119             : #if FILE_IO_EXTRA_CHECK
  154120         570 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNotEqualOp ) ) <= globalIndex ) ;
  154121         570 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNotEqualOp + 1 ) ) );
  154122             : #endif
  154123         570 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNotEqualOp )  
  154124         570 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNotEqualOp );
  154125         570 :           unsigned long positionInPool = localIndex % SgNotEqualOp::pool_size;
  154126         570 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNotEqualOp::pool_size;
  154127             : 
  154128             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  154129             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  154130             : 
  154131         570 :           returnPointer = &( ( (SgNotEqualOp*)(SgNotEqualOp::pools[memoryBlock]) ) [positionInPool]) ;
  154132             : 
  154133         570 :           ROSE_ASSERT( returnPointer != NULL ) ;
  154134             :         }
  154135         570 :      return returnPointer ;
  154136             :    }
  154137             : 
  154138             : //############################################################################
  154139             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  154140             :   for the AST with the index astIndex
  154141             : */
  154142           0 : SgNotEqualOp * SgNotEqualOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  154143           0 :      SgNotEqualOp* returnPointer = NULL;
  154144           0 :      if ( globalIndex != 0 )
  154145             :         {
  154146             : 
  154147             : #if FILE_IO_EXTRA_CHECK
  154148           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNotEqualOp ) ) <= globalIndex ) ;
  154149           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNotEqualOp + 1 ) ) );
  154150             : #endif
  154151           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNotEqualOp )
  154152           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNotEqualOp );
  154153           0 :           unsigned long positionInPool = localIndex % SgNotEqualOp::pool_size ;
  154154           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNotEqualOp::pool_size ;
  154155             : 
  154156             : #if FILE_IO_EXTRA_CHECK
  154157             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  154158             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  154159             : #endif
  154160             : 
  154161           0 :           returnPointer = &( ( (SgNotEqualOp*)(SgNotEqualOp::pools[memoryBlock]) ) [positionInPool]) ;
  154162             : 
  154163             : #if FILE_IO_EXTRA_CHECK
  154164           0 :           assert ( returnPointer != NULL ) ;
  154165             : #endif
  154166             :         }
  154167           0 :      return returnPointer ;
  154168             :    }
  154169             : 
  154170             : //############################################################################
  154171             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  154172             :  * pool size! We set for every valid object in the memory pool the freepointer
  154173             :  * to the global index and increase the global index afterwards. For all the 
  154174             :  * invalid objects (means address ranges within the memory pool that were not
  154175             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  154176             :  * distinguish valid from invalid objects! 
  154177             :  */
  154178             : unsigned long
  154179           5 : SgNotEqualOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  154180             :    {
  154181           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  154182           5 :      SgNotEqualOp* pointer = NULL;
  154183           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  154184           5 :      std::vector < unsigned char* > :: const_iterator block;
  154185           6 :      for ( block = SgNotEqualOp::pools.begin(); block != SgNotEqualOp::pools.end() ; ++block )
  154186             :         {
  154187           1 :           pointer = (SgNotEqualOp*)(*block);
  154188        2001 :           for (unsigned i = 0; i < SgNotEqualOp::pool_size; ++i )
  154189             :              {
  154190             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  154191             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  154192             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  154193             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  154194             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  154195             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  154196             :             // properly; so this will have to be checked next.
  154197             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  154198             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  154199        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  154200             :                   {
  154201          95 :                     pointer[i].set_freepointer((SgNotEqualOp*)(globalIndex));
  154202          95 :                     globalIndex++;
  154203             :                   }
  154204             :                else
  154205             :                   {
  154206        1905 :                     pointer[i].set_freepointer(NULL);
  154207             :                   }
  154208             :               }
  154209             :         }
  154210           5 :      return globalIndex;
  154211             :    }
  154212             : 
  154213             : //############################################################################
  154214             : // JH (01/14/2006)
  154215             : void
  154216           5 : SgNotEqualOp::resetValidFreepointers( )
  154217             :    {
  154218           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  154219           5 :      SgNotEqualOp* pointer = NULL;
  154220           5 :      std::vector < unsigned char* > :: const_iterator block;
  154221           5 :      SgNotEqualOp* pointerOfLinkedList = NULL;
  154222           6 :      for ( block = SgNotEqualOp::pools.begin(); block != SgNotEqualOp::pools.end() ; ++block )
  154223             :         {
  154224           1 :           pointer = (SgNotEqualOp*)(*block);
  154225        2001 :           for (unsigned i = 0; i < SgNotEqualOp::pool_size; ++i )
  154226             :              {
  154227             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  154228             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  154229             :             // memory blocks!.
  154230        2000 :                if ( pointer[i].get_freepointer() != NULL )
  154231             :                   {
  154232          95 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  154233             :                   }
  154234             :                else
  154235             :                   {
  154236        1905 :                     if ( pointerOfLinkedList == NULL )
  154237             :                        {
  154238           1 :                          SgNotEqualOp::next_node = &(pointer[i]);
  154239             :                        }
  154240             :                     else
  154241             :                        {
  154242             :                       // printf ("In SgNotEqualOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  154243        1904 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  154244             :                        }
  154245             :                     pointerOfLinkedList = &(pointer[i]);
  154246             :                   }
  154247             :               }
  154248             :         }
  154249             : 
  154250           5 :      if ( pointerOfLinkedList != NULL )
  154251             :         {
  154252             :        // printf ("In SgNotEqualOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  154253           1 :           pointerOfLinkedList->set_freepointer(NULL);
  154254             :        // DQ (6/6/2010): Temporary debugging...
  154255             :        //   ROSE_ASSERT(false);
  154256             :         }
  154257             : 
  154258           5 :      return ;
  154259             :    }
  154260             : 
  154261             : //############################################################################
  154262             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  154263             :  * within the memory pool and resets the freepointers, in order to achieve a 
  154264             :  * linked list, that has no jumps and starts at the beginning! This function 
  154265             :  * does not extend the memory pool, since we do not delete any memory blocks,
  154266             :  * but delete the valid objects.  
  154267             :  */
  154268             : void
  154269           0 : SgNotEqualOp::clearMemoryPool( )
  154270             :    {
  154271             :   // printf ("Inside of SgNotEqualOp::clearMemoryPool() \n");
  154272             : 
  154273           0 :      SgNotEqualOp* pointer = NULL, *tempPointer = NULL;
  154274           0 :      std::vector < unsigned char* > :: const_iterator block;
  154275           0 :      if ( SgNotEqualOp::pools.empty() == false )
  154276             :         {
  154277           0 :           block = SgNotEqualOp::pools.begin() ;
  154278           0 :           SgNotEqualOp::next_node = (SgNotEqualOp*) (*block);
  154279             : 
  154280           0 :           while ( block != SgNotEqualOp::pools.end() )
  154281             :              {
  154282           0 :                pointer = (SgNotEqualOp*) (*block);
  154283           0 :                if ( tempPointer != NULL )
  154284             :                   {
  154285           0 :                     tempPointer->set_freepointer(pointer);
  154286             :                   }
  154287           0 :                for (unsigned i = 0; i < SgNotEqualOp::pool_size - 1; ++i)
  154288             :                   {
  154289           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  154290             :                   }
  154291           0 :                 pointer[SgNotEqualOp::pool_size-1].set_freepointer(NULL);
  154292           0 :                 tempPointer = &(pointer[SgNotEqualOp::pool_size-1]);
  154293           0 :                 ++block;
  154294             :              }
  154295             :         }
  154296           0 :    }
  154297             : 
  154298           5 : void SgNotEqualOp::deleteMemoryPool() {
  154299           7 :   for (auto p: SgNotEqualOp::pools) {
  154300           2 :     ROSE_FREE(p);
  154301             :   }
  154302           5 :   SgNotEqualOp::next_node = nullptr;
  154303           5 :   SgNotEqualOp::pools.clear();
  154304           5 : }
  154305             : 
  154306             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  154307             : //                 reading multiple binary files to for a single AST.
  154308             : /////////// new version ////////////////////////////////
  154309             : //############################################################################
  154310             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  154311             : void
  154312           2 : SgNotEqualOp::extendMemoryPoolForFileIO( )
  154313             :   {
  154314           2 :     size_t blockIndex = SgNotEqualOp::pools.size();
  154315           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNotEqualOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNotEqualOp);
  154316             : 
  154317           3 :     while ( (blockIndex * SgNotEqualOp::pool_size) < newPoolSize)
  154318             :       {
  154319             : #if ROSE_ALLOC_TRACE
  154320             :         if (blockIndex > 0) {
  154321             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNotEqualOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNotEqualOp) = %" PRIuPTR " SgNotEqualOp::pool_size = %d \n",
  154322             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNotEqualOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNotEqualOp),SgNotEqualOp::pool_size);
  154323             :         }
  154324             : #endif
  154325             : 
  154326           1 :         SgNotEqualOp * pointer = (SgNotEqualOp*) ROSE_MALLOC ( SgNotEqualOp::pool_size * sizeof(SgNotEqualOp) );
  154327           1 :         assert( pointer != NULL );
  154328             : #if ROSE_ALLOC_MEMSET == 1
  154329             :         memset(pointer, 0x00, SgNotEqualOp::pool_size * sizeof(SgNotEqualOp));
  154330             : #elif ROSE_ALLOC_MEMSET == 2
  154331             :         memset(pointer, 0xCC, SgNotEqualOp::pool_size * sizeof(SgNotEqualOp));
  154332             : #endif
  154333           1 :         SgNotEqualOp::pools.push_back( (unsigned char*)(pointer) );
  154334           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNotEqualOp::pool_size * sizeof(SgNotEqualOp), V_SgNotEqualOp ) );
  154335             : 
  154336           1 :         if ( SgNotEqualOp::next_node != NULL ) {
  154337           0 :           if ( blockIndex > 0 ) {
  154338           0 :             SgNotEqualOp * blkptr = (SgNotEqualOp*)(SgNotEqualOp::pools[blockIndex-1]);
  154339           0 :             blkptr[ SgNotEqualOp::pool_size - 1 ].set_freepointer(pointer);
  154340             :           }
  154341             :         } else {
  154342           1 :           SgNotEqualOp::next_node = pointer;
  154343             :         }
  154344             : 
  154345        2000 :         for (unsigned i = 0; i < SgNotEqualOp::pool_size-1; ++i)
  154346             :            {
  154347        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  154348             :            }
  154349           1 :         pointer[ SgNotEqualOp::pool_size -1 ].set_freepointer(NULL);
  154350             : 
  154351           1 :         blockIndex++;
  154352             :       }
  154353           2 :   }
  154354             : 
  154355             : //############################################################################
  154356             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  154357             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  154358             :  * not compressed. However, that stuff is not yet implemented! 
  154359             :  */
  154360             : unsigned long
  154361           0 : SgNotEqualOp::getNumberOfLastValidPointer()
  154362             :    {
  154363           0 :       SgNotEqualOp* testPointer = (SgNotEqualOp*)(SgNotEqualOp::pools.back());
  154364           0 :       unsigned long localIndex = SgNotEqualOp::pool_size - 1;
  154365           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  154366             :          {
  154367           0 :            localIndex--;
  154368             :          }
  154369           0 :       return (localIndex + SgNotEqualOp::pool_size * (SgNotEqualOp::pools.size()-1));
  154370             :    }
  154371             : 
  154372             : //############################################################################
  154373             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  154374             :  * memory pool and initializes the data member in class SgNotEqualOpStroageClass
  154375             :  * from its counterpart of SgNotEqualOp. The return value is just for checking, 
  154376             :  * that the whole StorageClassArray is initialized!
  154377             :  */
  154378             : unsigned long
  154379           1 : SgNotEqualOp::initializeStorageClassArray( SgNotEqualOpStorageClass *storageArray )
  154380             :    {
  154381           1 :      unsigned long storageCounter = 0;
  154382           1 :      std::vector < unsigned char* > :: const_iterator block = SgNotEqualOp::pools.begin();
  154383           1 :      SgNotEqualOp* pointer = NULL;
  154384           2 :      while ( block != SgNotEqualOp::pools.end() ) {
  154385           1 :           pointer = (SgNotEqualOp*) (*block);
  154386        2001 :           for ( unsigned i = 0; i < SgNotEqualOp::pool_size; ++i ) {
  154387        2000 :                if ( pointer->get_freepointer() != NULL ) {
  154388          95 :                  storageArray->pickOutIRNodeData (pointer) ;
  154389          95 :                  storageArray++;
  154390          95 :                  storageCounter++;
  154391             :                }
  154392        2000 :                pointer++;
  154393             :              }
  154394           1 :            block++;
  154395             :         }
  154396           1 :      return storageCounter;
  154397             :    }
  154398             : 
  154399             : /* #line 154400 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  154400             : 
  154401             : 
  154402             : 
  154403             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  154404             : 
  154405             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  154406             : 
  154407             : //############################################################################
  154408             : /* JH (02/02/2006) Constructor of the IR node SgLessOrEqualOp that takes its 
  154409             :  * corresponding StorageClass as parameter
  154410             :  */
  154411          31 : SgLessOrEqualOp :: SgLessOrEqualOp ( const SgLessOrEqualOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  154412             :    {
  154413             : 
  154414             : 
  154415             : /* #line 154416 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  154416             : 
  154417          31 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  154418             : 
  154419             : 
  154420             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  154421             : 
  154422             : 
  154423          31 :    }
  154424             : 
  154425             : //############################################################################
  154426             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  154427             :  * within the working AST. 
  154428             :  */
  154429         186 : SgLessOrEqualOp * SgLessOrEqualOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  154430         186 :      SgLessOrEqualOp* returnPointer = NULL;
  154431         186 :      if ( globalIndex != 0 )
  154432             :         {
  154433             : 
  154434             : #if FILE_IO_EXTRA_CHECK
  154435         186 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLessOrEqualOp ) ) <= globalIndex ) ;
  154436         186 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLessOrEqualOp + 1 ) ) );
  154437             : #endif
  154438         186 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLessOrEqualOp )  
  154439         186 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLessOrEqualOp );
  154440         186 :           unsigned long positionInPool = localIndex % SgLessOrEqualOp::pool_size;
  154441         186 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLessOrEqualOp::pool_size;
  154442             : 
  154443             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  154444             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  154445             : 
  154446         186 :           returnPointer = &( ( (SgLessOrEqualOp*)(SgLessOrEqualOp::pools[memoryBlock]) ) [positionInPool]) ;
  154447             : 
  154448         186 :           ROSE_ASSERT( returnPointer != NULL ) ;
  154449             :         }
  154450         186 :      return returnPointer ;
  154451             :    }
  154452             : 
  154453             : //############################################################################
  154454             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  154455             :   for the AST with the index astIndex
  154456             : */
  154457           0 : SgLessOrEqualOp * SgLessOrEqualOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  154458           0 :      SgLessOrEqualOp* returnPointer = NULL;
  154459           0 :      if ( globalIndex != 0 )
  154460             :         {
  154461             : 
  154462             : #if FILE_IO_EXTRA_CHECK
  154463           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLessOrEqualOp ) ) <= globalIndex ) ;
  154464           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLessOrEqualOp + 1 ) ) );
  154465             : #endif
  154466           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLessOrEqualOp )
  154467           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLessOrEqualOp );
  154468           0 :           unsigned long positionInPool = localIndex % SgLessOrEqualOp::pool_size ;
  154469           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLessOrEqualOp::pool_size ;
  154470             : 
  154471             : #if FILE_IO_EXTRA_CHECK
  154472             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  154473             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  154474             : #endif
  154475             : 
  154476           0 :           returnPointer = &( ( (SgLessOrEqualOp*)(SgLessOrEqualOp::pools[memoryBlock]) ) [positionInPool]) ;
  154477             : 
  154478             : #if FILE_IO_EXTRA_CHECK
  154479           0 :           assert ( returnPointer != NULL ) ;
  154480             : #endif
  154481             :         }
  154482           0 :      return returnPointer ;
  154483             :    }
  154484             : 
  154485             : //############################################################################
  154486             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  154487             :  * pool size! We set for every valid object in the memory pool the freepointer
  154488             :  * to the global index and increase the global index afterwards. For all the 
  154489             :  * invalid objects (means address ranges within the memory pool that were not
  154490             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  154491             :  * distinguish valid from invalid objects! 
  154492             :  */
  154493             : unsigned long
  154494           5 : SgLessOrEqualOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  154495             :    {
  154496           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  154497           5 :      SgLessOrEqualOp* pointer = NULL;
  154498           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  154499           5 :      std::vector < unsigned char* > :: const_iterator block;
  154500           6 :      for ( block = SgLessOrEqualOp::pools.begin(); block != SgLessOrEqualOp::pools.end() ; ++block )
  154501             :         {
  154502           1 :           pointer = (SgLessOrEqualOp*)(*block);
  154503        2001 :           for (unsigned i = 0; i < SgLessOrEqualOp::pool_size; ++i )
  154504             :              {
  154505             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  154506             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  154507             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  154508             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  154509             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  154510             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  154511             :             // properly; so this will have to be checked next.
  154512             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  154513             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  154514        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  154515             :                   {
  154516          31 :                     pointer[i].set_freepointer((SgLessOrEqualOp*)(globalIndex));
  154517          31 :                     globalIndex++;
  154518             :                   }
  154519             :                else
  154520             :                   {
  154521        1969 :                     pointer[i].set_freepointer(NULL);
  154522             :                   }
  154523             :               }
  154524             :         }
  154525           5 :      return globalIndex;
  154526             :    }
  154527             : 
  154528             : //############################################################################
  154529             : // JH (01/14/2006)
  154530             : void
  154531           5 : SgLessOrEqualOp::resetValidFreepointers( )
  154532             :    {
  154533           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  154534           5 :      SgLessOrEqualOp* pointer = NULL;
  154535           5 :      std::vector < unsigned char* > :: const_iterator block;
  154536           5 :      SgLessOrEqualOp* pointerOfLinkedList = NULL;
  154537           6 :      for ( block = SgLessOrEqualOp::pools.begin(); block != SgLessOrEqualOp::pools.end() ; ++block )
  154538             :         {
  154539           1 :           pointer = (SgLessOrEqualOp*)(*block);
  154540        2001 :           for (unsigned i = 0; i < SgLessOrEqualOp::pool_size; ++i )
  154541             :              {
  154542             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  154543             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  154544             :             // memory blocks!.
  154545        2000 :                if ( pointer[i].get_freepointer() != NULL )
  154546             :                   {
  154547          31 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  154548             :                   }
  154549             :                else
  154550             :                   {
  154551        1969 :                     if ( pointerOfLinkedList == NULL )
  154552             :                        {
  154553           1 :                          SgLessOrEqualOp::next_node = &(pointer[i]);
  154554             :                        }
  154555             :                     else
  154556             :                        {
  154557             :                       // printf ("In SgLessOrEqualOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  154558        1968 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  154559             :                        }
  154560             :                     pointerOfLinkedList = &(pointer[i]);
  154561             :                   }
  154562             :               }
  154563             :         }
  154564             : 
  154565           5 :      if ( pointerOfLinkedList != NULL )
  154566             :         {
  154567             :        // printf ("In SgLessOrEqualOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  154568           1 :           pointerOfLinkedList->set_freepointer(NULL);
  154569             :        // DQ (6/6/2010): Temporary debugging...
  154570             :        //   ROSE_ASSERT(false);
  154571             :         }
  154572             : 
  154573           5 :      return ;
  154574             :    }
  154575             : 
  154576             : //############################################################################
  154577             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  154578             :  * within the memory pool and resets the freepointers, in order to achieve a 
  154579             :  * linked list, that has no jumps and starts at the beginning! This function 
  154580             :  * does not extend the memory pool, since we do not delete any memory blocks,
  154581             :  * but delete the valid objects.  
  154582             :  */
  154583             : void
  154584           0 : SgLessOrEqualOp::clearMemoryPool( )
  154585             :    {
  154586             :   // printf ("Inside of SgLessOrEqualOp::clearMemoryPool() \n");
  154587             : 
  154588           0 :      SgLessOrEqualOp* pointer = NULL, *tempPointer = NULL;
  154589           0 :      std::vector < unsigned char* > :: const_iterator block;
  154590           0 :      if ( SgLessOrEqualOp::pools.empty() == false )
  154591             :         {
  154592           0 :           block = SgLessOrEqualOp::pools.begin() ;
  154593           0 :           SgLessOrEqualOp::next_node = (SgLessOrEqualOp*) (*block);
  154594             : 
  154595           0 :           while ( block != SgLessOrEqualOp::pools.end() )
  154596             :              {
  154597           0 :                pointer = (SgLessOrEqualOp*) (*block);
  154598           0 :                if ( tempPointer != NULL )
  154599             :                   {
  154600           0 :                     tempPointer->set_freepointer(pointer);
  154601             :                   }
  154602           0 :                for (unsigned i = 0; i < SgLessOrEqualOp::pool_size - 1; ++i)
  154603             :                   {
  154604           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  154605             :                   }
  154606           0 :                 pointer[SgLessOrEqualOp::pool_size-1].set_freepointer(NULL);
  154607           0 :                 tempPointer = &(pointer[SgLessOrEqualOp::pool_size-1]);
  154608           0 :                 ++block;
  154609             :              }
  154610             :         }
  154611           0 :    }
  154612             : 
  154613           5 : void SgLessOrEqualOp::deleteMemoryPool() {
  154614           7 :   for (auto p: SgLessOrEqualOp::pools) {
  154615           2 :     ROSE_FREE(p);
  154616             :   }
  154617           5 :   SgLessOrEqualOp::next_node = nullptr;
  154618           5 :   SgLessOrEqualOp::pools.clear();
  154619           5 : }
  154620             : 
  154621             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  154622             : //                 reading multiple binary files to for a single AST.
  154623             : /////////// new version ////////////////////////////////
  154624             : //############################################################################
  154625             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  154626             : void
  154627           2 : SgLessOrEqualOp::extendMemoryPoolForFileIO( )
  154628             :   {
  154629           2 :     size_t blockIndex = SgLessOrEqualOp::pools.size();
  154630           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLessOrEqualOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLessOrEqualOp);
  154631             : 
  154632           3 :     while ( (blockIndex * SgLessOrEqualOp::pool_size) < newPoolSize)
  154633             :       {
  154634             : #if ROSE_ALLOC_TRACE
  154635             :         if (blockIndex > 0) {
  154636             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLessOrEqualOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLessOrEqualOp) = %" PRIuPTR " SgLessOrEqualOp::pool_size = %d \n",
  154637             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLessOrEqualOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLessOrEqualOp),SgLessOrEqualOp::pool_size);
  154638             :         }
  154639             : #endif
  154640             : 
  154641           1 :         SgLessOrEqualOp * pointer = (SgLessOrEqualOp*) ROSE_MALLOC ( SgLessOrEqualOp::pool_size * sizeof(SgLessOrEqualOp) );
  154642           1 :         assert( pointer != NULL );
  154643             : #if ROSE_ALLOC_MEMSET == 1
  154644             :         memset(pointer, 0x00, SgLessOrEqualOp::pool_size * sizeof(SgLessOrEqualOp));
  154645             : #elif ROSE_ALLOC_MEMSET == 2
  154646             :         memset(pointer, 0xCC, SgLessOrEqualOp::pool_size * sizeof(SgLessOrEqualOp));
  154647             : #endif
  154648           1 :         SgLessOrEqualOp::pools.push_back( (unsigned char*)(pointer) );
  154649           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLessOrEqualOp::pool_size * sizeof(SgLessOrEqualOp), V_SgLessOrEqualOp ) );
  154650             : 
  154651           1 :         if ( SgLessOrEqualOp::next_node != NULL ) {
  154652           0 :           if ( blockIndex > 0 ) {
  154653           0 :             SgLessOrEqualOp * blkptr = (SgLessOrEqualOp*)(SgLessOrEqualOp::pools[blockIndex-1]);
  154654           0 :             blkptr[ SgLessOrEqualOp::pool_size - 1 ].set_freepointer(pointer);
  154655             :           }
  154656             :         } else {
  154657           1 :           SgLessOrEqualOp::next_node = pointer;
  154658             :         }
  154659             : 
  154660        2000 :         for (unsigned i = 0; i < SgLessOrEqualOp::pool_size-1; ++i)
  154661             :            {
  154662        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  154663             :            }
  154664           1 :         pointer[ SgLessOrEqualOp::pool_size -1 ].set_freepointer(NULL);
  154665             : 
  154666           1 :         blockIndex++;
  154667             :       }
  154668           2 :   }
  154669             : 
  154670             : //############################################################################
  154671             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  154672             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  154673             :  * not compressed. However, that stuff is not yet implemented! 
  154674             :  */
  154675             : unsigned long
  154676           0 : SgLessOrEqualOp::getNumberOfLastValidPointer()
  154677             :    {
  154678           0 :       SgLessOrEqualOp* testPointer = (SgLessOrEqualOp*)(SgLessOrEqualOp::pools.back());
  154679           0 :       unsigned long localIndex = SgLessOrEqualOp::pool_size - 1;
  154680           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  154681             :          {
  154682           0 :            localIndex--;
  154683             :          }
  154684           0 :       return (localIndex + SgLessOrEqualOp::pool_size * (SgLessOrEqualOp::pools.size()-1));
  154685             :    }
  154686             : 
  154687             : //############################################################################
  154688             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  154689             :  * memory pool and initializes the data member in class SgLessOrEqualOpStroageClass
  154690             :  * from its counterpart of SgLessOrEqualOp. The return value is just for checking, 
  154691             :  * that the whole StorageClassArray is initialized!
  154692             :  */
  154693             : unsigned long
  154694           1 : SgLessOrEqualOp::initializeStorageClassArray( SgLessOrEqualOpStorageClass *storageArray )
  154695             :    {
  154696           1 :      unsigned long storageCounter = 0;
  154697           1 :      std::vector < unsigned char* > :: const_iterator block = SgLessOrEqualOp::pools.begin();
  154698           1 :      SgLessOrEqualOp* pointer = NULL;
  154699           2 :      while ( block != SgLessOrEqualOp::pools.end() ) {
  154700           1 :           pointer = (SgLessOrEqualOp*) (*block);
  154701        2001 :           for ( unsigned i = 0; i < SgLessOrEqualOp::pool_size; ++i ) {
  154702        2000 :                if ( pointer->get_freepointer() != NULL ) {
  154703          31 :                  storageArray->pickOutIRNodeData (pointer) ;
  154704          31 :                  storageArray++;
  154705          31 :                  storageCounter++;
  154706             :                }
  154707        2000 :                pointer++;
  154708             :              }
  154709           1 :            block++;
  154710             :         }
  154711           1 :      return storageCounter;
  154712             :    }
  154713             : 
  154714             : /* #line 154715 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  154715             : 
  154716             : 
  154717             : 
  154718             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  154719             : 
  154720             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  154721             : 
  154722             : //############################################################################
  154723             : /* JH (02/02/2006) Constructor of the IR node SgGreaterOrEqualOp that takes its 
  154724             :  * corresponding StorageClass as parameter
  154725             :  */
  154726          28 : SgGreaterOrEqualOp :: SgGreaterOrEqualOp ( const SgGreaterOrEqualOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  154727             :    {
  154728             : 
  154729             : 
  154730             : /* #line 154731 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  154731             : 
  154732          28 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  154733             : 
  154734             : 
  154735             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  154736             : 
  154737             : 
  154738          28 :    }
  154739             : 
  154740             : //############################################################################
  154741             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  154742             :  * within the working AST. 
  154743             :  */
  154744         168 : SgGreaterOrEqualOp * SgGreaterOrEqualOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  154745         168 :      SgGreaterOrEqualOp* returnPointer = NULL;
  154746         168 :      if ( globalIndex != 0 )
  154747             :         {
  154748             : 
  154749             : #if FILE_IO_EXTRA_CHECK
  154750         168 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgGreaterOrEqualOp ) ) <= globalIndex ) ;
  154751         168 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGreaterOrEqualOp + 1 ) ) );
  154752             : #endif
  154753         168 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgGreaterOrEqualOp )  
  154754         168 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgGreaterOrEqualOp );
  154755         168 :           unsigned long positionInPool = localIndex % SgGreaterOrEqualOp::pool_size;
  154756         168 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGreaterOrEqualOp::pool_size;
  154757             : 
  154758             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  154759             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  154760             : 
  154761         168 :           returnPointer = &( ( (SgGreaterOrEqualOp*)(SgGreaterOrEqualOp::pools[memoryBlock]) ) [positionInPool]) ;
  154762             : 
  154763         168 :           ROSE_ASSERT( returnPointer != NULL ) ;
  154764             :         }
  154765         168 :      return returnPointer ;
  154766             :    }
  154767             : 
  154768             : //############################################################################
  154769             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  154770             :   for the AST with the index astIndex
  154771             : */
  154772           0 : SgGreaterOrEqualOp * SgGreaterOrEqualOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  154773           0 :      SgGreaterOrEqualOp* returnPointer = NULL;
  154774           0 :      if ( globalIndex != 0 )
  154775             :         {
  154776             : 
  154777             : #if FILE_IO_EXTRA_CHECK
  154778           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgGreaterOrEqualOp ) ) <= globalIndex ) ;
  154779           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGreaterOrEqualOp + 1 ) ) );
  154780             : #endif
  154781           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgGreaterOrEqualOp )
  154782           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgGreaterOrEqualOp );
  154783           0 :           unsigned long positionInPool = localIndex % SgGreaterOrEqualOp::pool_size ;
  154784           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgGreaterOrEqualOp::pool_size ;
  154785             : 
  154786             : #if FILE_IO_EXTRA_CHECK
  154787             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  154788             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  154789             : #endif
  154790             : 
  154791           0 :           returnPointer = &( ( (SgGreaterOrEqualOp*)(SgGreaterOrEqualOp::pools[memoryBlock]) ) [positionInPool]) ;
  154792             : 
  154793             : #if FILE_IO_EXTRA_CHECK
  154794           0 :           assert ( returnPointer != NULL ) ;
  154795             : #endif
  154796             :         }
  154797           0 :      return returnPointer ;
  154798             :    }
  154799             : 
  154800             : //############################################################################
  154801             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  154802             :  * pool size! We set for every valid object in the memory pool the freepointer
  154803             :  * to the global index and increase the global index afterwards. For all the 
  154804             :  * invalid objects (means address ranges within the memory pool that were not
  154805             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  154806             :  * distinguish valid from invalid objects! 
  154807             :  */
  154808             : unsigned long
  154809           5 : SgGreaterOrEqualOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  154810             :    {
  154811           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  154812           5 :      SgGreaterOrEqualOp* pointer = NULL;
  154813           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  154814           5 :      std::vector < unsigned char* > :: const_iterator block;
  154815           6 :      for ( block = SgGreaterOrEqualOp::pools.begin(); block != SgGreaterOrEqualOp::pools.end() ; ++block )
  154816             :         {
  154817           1 :           pointer = (SgGreaterOrEqualOp*)(*block);
  154818        2001 :           for (unsigned i = 0; i < SgGreaterOrEqualOp::pool_size; ++i )
  154819             :              {
  154820             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  154821             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  154822             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  154823             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  154824             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  154825             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  154826             :             // properly; so this will have to be checked next.
  154827             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  154828             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  154829        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  154830             :                   {
  154831          28 :                     pointer[i].set_freepointer((SgGreaterOrEqualOp*)(globalIndex));
  154832          28 :                     globalIndex++;
  154833             :                   }
  154834             :                else
  154835             :                   {
  154836        1972 :                     pointer[i].set_freepointer(NULL);
  154837             :                   }
  154838             :               }
  154839             :         }
  154840           5 :      return globalIndex;
  154841             :    }
  154842             : 
  154843             : //############################################################################
  154844             : // JH (01/14/2006)
  154845             : void
  154846           5 : SgGreaterOrEqualOp::resetValidFreepointers( )
  154847             :    {
  154848           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  154849           5 :      SgGreaterOrEqualOp* pointer = NULL;
  154850           5 :      std::vector < unsigned char* > :: const_iterator block;
  154851           5 :      SgGreaterOrEqualOp* pointerOfLinkedList = NULL;
  154852           6 :      for ( block = SgGreaterOrEqualOp::pools.begin(); block != SgGreaterOrEqualOp::pools.end() ; ++block )
  154853             :         {
  154854           1 :           pointer = (SgGreaterOrEqualOp*)(*block);
  154855        2001 :           for (unsigned i = 0; i < SgGreaterOrEqualOp::pool_size; ++i )
  154856             :              {
  154857             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  154858             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  154859             :             // memory blocks!.
  154860        2000 :                if ( pointer[i].get_freepointer() != NULL )
  154861             :                   {
  154862          28 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  154863             :                   }
  154864             :                else
  154865             :                   {
  154866        1972 :                     if ( pointerOfLinkedList == NULL )
  154867             :                        {
  154868           1 :                          SgGreaterOrEqualOp::next_node = &(pointer[i]);
  154869             :                        }
  154870             :                     else
  154871             :                        {
  154872             :                       // printf ("In SgGreaterOrEqualOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  154873        1971 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  154874             :                        }
  154875             :                     pointerOfLinkedList = &(pointer[i]);
  154876             :                   }
  154877             :               }
  154878             :         }
  154879             : 
  154880           5 :      if ( pointerOfLinkedList != NULL )
  154881             :         {
  154882             :        // printf ("In SgGreaterOrEqualOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  154883           1 :           pointerOfLinkedList->set_freepointer(NULL);
  154884             :        // DQ (6/6/2010): Temporary debugging...
  154885             :        //   ROSE_ASSERT(false);
  154886             :         }
  154887             : 
  154888           5 :      return ;
  154889             :    }
  154890             : 
  154891             : //############################################################################
  154892             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  154893             :  * within the memory pool and resets the freepointers, in order to achieve a 
  154894             :  * linked list, that has no jumps and starts at the beginning! This function 
  154895             :  * does not extend the memory pool, since we do not delete any memory blocks,
  154896             :  * but delete the valid objects.  
  154897             :  */
  154898             : void
  154899           0 : SgGreaterOrEqualOp::clearMemoryPool( )
  154900             :    {
  154901             :   // printf ("Inside of SgGreaterOrEqualOp::clearMemoryPool() \n");
  154902             : 
  154903           0 :      SgGreaterOrEqualOp* pointer = NULL, *tempPointer = NULL;
  154904           0 :      std::vector < unsigned char* > :: const_iterator block;
  154905           0 :      if ( SgGreaterOrEqualOp::pools.empty() == false )
  154906             :         {
  154907           0 :           block = SgGreaterOrEqualOp::pools.begin() ;
  154908           0 :           SgGreaterOrEqualOp::next_node = (SgGreaterOrEqualOp*) (*block);
  154909             : 
  154910           0 :           while ( block != SgGreaterOrEqualOp::pools.end() )
  154911             :              {
  154912           0 :                pointer = (SgGreaterOrEqualOp*) (*block);
  154913           0 :                if ( tempPointer != NULL )
  154914             :                   {
  154915           0 :                     tempPointer->set_freepointer(pointer);
  154916             :                   }
  154917           0 :                for (unsigned i = 0; i < SgGreaterOrEqualOp::pool_size - 1; ++i)
  154918             :                   {
  154919           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  154920             :                   }
  154921           0 :                 pointer[SgGreaterOrEqualOp::pool_size-1].set_freepointer(NULL);
  154922           0 :                 tempPointer = &(pointer[SgGreaterOrEqualOp::pool_size-1]);
  154923           0 :                 ++block;
  154924             :              }
  154925             :         }
  154926           0 :    }
  154927             : 
  154928           5 : void SgGreaterOrEqualOp::deleteMemoryPool() {
  154929           7 :   for (auto p: SgGreaterOrEqualOp::pools) {
  154930           2 :     ROSE_FREE(p);
  154931             :   }
  154932           5 :   SgGreaterOrEqualOp::next_node = nullptr;
  154933           5 :   SgGreaterOrEqualOp::pools.clear();
  154934           5 : }
  154935             : 
  154936             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  154937             : //                 reading multiple binary files to for a single AST.
  154938             : /////////// new version ////////////////////////////////
  154939             : //############################################################################
  154940             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  154941             : void
  154942           2 : SgGreaterOrEqualOp::extendMemoryPoolForFileIO( )
  154943             :   {
  154944           2 :     size_t blockIndex = SgGreaterOrEqualOp::pools.size();
  154945           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgGreaterOrEqualOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgGreaterOrEqualOp);
  154946             : 
  154947           3 :     while ( (blockIndex * SgGreaterOrEqualOp::pool_size) < newPoolSize)
  154948             :       {
  154949             : #if ROSE_ALLOC_TRACE
  154950             :         if (blockIndex > 0) {
  154951             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgGreaterOrEqualOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgGreaterOrEqualOp) = %" PRIuPTR " SgGreaterOrEqualOp::pool_size = %d \n",
  154952             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgGreaterOrEqualOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgGreaterOrEqualOp),SgGreaterOrEqualOp::pool_size);
  154953             :         }
  154954             : #endif
  154955             : 
  154956           1 :         SgGreaterOrEqualOp * pointer = (SgGreaterOrEqualOp*) ROSE_MALLOC ( SgGreaterOrEqualOp::pool_size * sizeof(SgGreaterOrEqualOp) );
  154957           1 :         assert( pointer != NULL );
  154958             : #if ROSE_ALLOC_MEMSET == 1
  154959             :         memset(pointer, 0x00, SgGreaterOrEqualOp::pool_size * sizeof(SgGreaterOrEqualOp));
  154960             : #elif ROSE_ALLOC_MEMSET == 2
  154961             :         memset(pointer, 0xCC, SgGreaterOrEqualOp::pool_size * sizeof(SgGreaterOrEqualOp));
  154962             : #endif
  154963           1 :         SgGreaterOrEqualOp::pools.push_back( (unsigned char*)(pointer) );
  154964           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgGreaterOrEqualOp::pool_size * sizeof(SgGreaterOrEqualOp), V_SgGreaterOrEqualOp ) );
  154965             : 
  154966           1 :         if ( SgGreaterOrEqualOp::next_node != NULL ) {
  154967           0 :           if ( blockIndex > 0 ) {
  154968           0 :             SgGreaterOrEqualOp * blkptr = (SgGreaterOrEqualOp*)(SgGreaterOrEqualOp::pools[blockIndex-1]);
  154969           0 :             blkptr[ SgGreaterOrEqualOp::pool_size - 1 ].set_freepointer(pointer);
  154970             :           }
  154971             :         } else {
  154972           1 :           SgGreaterOrEqualOp::next_node = pointer;
  154973             :         }
  154974             : 
  154975        2000 :         for (unsigned i = 0; i < SgGreaterOrEqualOp::pool_size-1; ++i)
  154976             :            {
  154977        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  154978             :            }
  154979           1 :         pointer[ SgGreaterOrEqualOp::pool_size -1 ].set_freepointer(NULL);
  154980             : 
  154981           1 :         blockIndex++;
  154982             :       }
  154983           2 :   }
  154984             : 
  154985             : //############################################################################
  154986             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  154987             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  154988             :  * not compressed. However, that stuff is not yet implemented! 
  154989             :  */
  154990             : unsigned long
  154991           0 : SgGreaterOrEqualOp::getNumberOfLastValidPointer()
  154992             :    {
  154993           0 :       SgGreaterOrEqualOp* testPointer = (SgGreaterOrEqualOp*)(SgGreaterOrEqualOp::pools.back());
  154994           0 :       unsigned long localIndex = SgGreaterOrEqualOp::pool_size - 1;
  154995           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  154996             :          {
  154997           0 :            localIndex--;
  154998             :          }
  154999           0 :       return (localIndex + SgGreaterOrEqualOp::pool_size * (SgGreaterOrEqualOp::pools.size()-1));
  155000             :    }
  155001             : 
  155002             : //############################################################################
  155003             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  155004             :  * memory pool and initializes the data member in class SgGreaterOrEqualOpStroageClass
  155005             :  * from its counterpart of SgGreaterOrEqualOp. The return value is just for checking, 
  155006             :  * that the whole StorageClassArray is initialized!
  155007             :  */
  155008             : unsigned long
  155009           1 : SgGreaterOrEqualOp::initializeStorageClassArray( SgGreaterOrEqualOpStorageClass *storageArray )
  155010             :    {
  155011           1 :      unsigned long storageCounter = 0;
  155012           1 :      std::vector < unsigned char* > :: const_iterator block = SgGreaterOrEqualOp::pools.begin();
  155013           1 :      SgGreaterOrEqualOp* pointer = NULL;
  155014           2 :      while ( block != SgGreaterOrEqualOp::pools.end() ) {
  155015           1 :           pointer = (SgGreaterOrEqualOp*) (*block);
  155016        2001 :           for ( unsigned i = 0; i < SgGreaterOrEqualOp::pool_size; ++i ) {
  155017        2000 :                if ( pointer->get_freepointer() != NULL ) {
  155018          28 :                  storageArray->pickOutIRNodeData (pointer) ;
  155019          28 :                  storageArray++;
  155020          28 :                  storageCounter++;
  155021             :                }
  155022        2000 :                pointer++;
  155023             :              }
  155024           1 :            block++;
  155025             :         }
  155026           1 :      return storageCounter;
  155027             :    }
  155028             : 
  155029             : /* #line 155030 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  155030             : 
  155031             : 
  155032             : 
  155033             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  155034             : 
  155035             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  155036             : 
  155037             : //############################################################################
  155038             : /* JH (02/02/2006) Constructor of the IR node SgAddOp that takes its 
  155039             :  * corresponding StorageClass as parameter
  155040             :  */
  155041         190 : SgAddOp :: SgAddOp ( const SgAddOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  155042             :    {
  155043             : 
  155044             : 
  155045             : /* #line 155046 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  155046             : 
  155047         190 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  155048             : 
  155049             : 
  155050             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  155051             : 
  155052             : 
  155053         190 :    }
  155054             : 
  155055             : //############################################################################
  155056             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  155057             :  * within the working AST. 
  155058             :  */
  155059        1140 : SgAddOp * SgAddOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  155060        1140 :      SgAddOp* returnPointer = NULL;
  155061        1140 :      if ( globalIndex != 0 )
  155062             :         {
  155063             : 
  155064             : #if FILE_IO_EXTRA_CHECK
  155065        1140 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAddOp ) ) <= globalIndex ) ;
  155066        1140 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAddOp + 1 ) ) );
  155067             : #endif
  155068        1140 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAddOp )  
  155069        1140 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAddOp );
  155070        1140 :           unsigned long positionInPool = localIndex % SgAddOp::pool_size;
  155071        1140 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAddOp::pool_size;
  155072             : 
  155073             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  155074             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  155075             : 
  155076        1140 :           returnPointer = &( ( (SgAddOp*)(SgAddOp::pools[memoryBlock]) ) [positionInPool]) ;
  155077             : 
  155078        1140 :           ROSE_ASSERT( returnPointer != NULL ) ;
  155079             :         }
  155080        1140 :      return returnPointer ;
  155081             :    }
  155082             : 
  155083             : //############################################################################
  155084             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  155085             :   for the AST with the index astIndex
  155086             : */
  155087           0 : SgAddOp * SgAddOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  155088           0 :      SgAddOp* returnPointer = NULL;
  155089           0 :      if ( globalIndex != 0 )
  155090             :         {
  155091             : 
  155092             : #if FILE_IO_EXTRA_CHECK
  155093           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAddOp ) ) <= globalIndex ) ;
  155094           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAddOp + 1 ) ) );
  155095             : #endif
  155096           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAddOp )
  155097           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAddOp );
  155098           0 :           unsigned long positionInPool = localIndex % SgAddOp::pool_size ;
  155099           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAddOp::pool_size ;
  155100             : 
  155101             : #if FILE_IO_EXTRA_CHECK
  155102             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  155103             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  155104             : #endif
  155105             : 
  155106           0 :           returnPointer = &( ( (SgAddOp*)(SgAddOp::pools[memoryBlock]) ) [positionInPool]) ;
  155107             : 
  155108             : #if FILE_IO_EXTRA_CHECK
  155109           0 :           assert ( returnPointer != NULL ) ;
  155110             : #endif
  155111             :         }
  155112           0 :      return returnPointer ;
  155113             :    }
  155114             : 
  155115             : //############################################################################
  155116             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  155117             :  * pool size! We set for every valid object in the memory pool the freepointer
  155118             :  * to the global index and increase the global index afterwards. For all the 
  155119             :  * invalid objects (means address ranges within the memory pool that were not
  155120             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  155121             :  * distinguish valid from invalid objects! 
  155122             :  */
  155123             : unsigned long
  155124           5 : SgAddOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  155125             :    {
  155126           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  155127           5 :      SgAddOp* pointer = NULL;
  155128           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  155129           5 :      std::vector < unsigned char* > :: const_iterator block;
  155130           6 :      for ( block = SgAddOp::pools.begin(); block != SgAddOp::pools.end() ; ++block )
  155131             :         {
  155132           1 :           pointer = (SgAddOp*)(*block);
  155133        2001 :           for (unsigned i = 0; i < SgAddOp::pool_size; ++i )
  155134             :              {
  155135             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  155136             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  155137             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  155138             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  155139             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  155140             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  155141             :             // properly; so this will have to be checked next.
  155142             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  155143             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  155144        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  155145             :                   {
  155146         190 :                     pointer[i].set_freepointer((SgAddOp*)(globalIndex));
  155147         190 :                     globalIndex++;
  155148             :                   }
  155149             :                else
  155150             :                   {
  155151        1810 :                     pointer[i].set_freepointer(NULL);
  155152             :                   }
  155153             :               }
  155154             :         }
  155155           5 :      return globalIndex;
  155156             :    }
  155157             : 
  155158             : //############################################################################
  155159             : // JH (01/14/2006)
  155160             : void
  155161           5 : SgAddOp::resetValidFreepointers( )
  155162             :    {
  155163           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  155164           5 :      SgAddOp* pointer = NULL;
  155165           5 :      std::vector < unsigned char* > :: const_iterator block;
  155166           5 :      SgAddOp* pointerOfLinkedList = NULL;
  155167           6 :      for ( block = SgAddOp::pools.begin(); block != SgAddOp::pools.end() ; ++block )
  155168             :         {
  155169           1 :           pointer = (SgAddOp*)(*block);
  155170        2001 :           for (unsigned i = 0; i < SgAddOp::pool_size; ++i )
  155171             :              {
  155172             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  155173             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  155174             :             // memory blocks!.
  155175        2000 :                if ( pointer[i].get_freepointer() != NULL )
  155176             :                   {
  155177         190 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  155178             :                   }
  155179             :                else
  155180             :                   {
  155181        1810 :                     if ( pointerOfLinkedList == NULL )
  155182             :                        {
  155183           1 :                          SgAddOp::next_node = &(pointer[i]);
  155184             :                        }
  155185             :                     else
  155186             :                        {
  155187             :                       // printf ("In SgAddOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  155188        1809 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  155189             :                        }
  155190             :                     pointerOfLinkedList = &(pointer[i]);
  155191             :                   }
  155192             :               }
  155193             :         }
  155194             : 
  155195           5 :      if ( pointerOfLinkedList != NULL )
  155196             :         {
  155197             :        // printf ("In SgAddOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  155198           1 :           pointerOfLinkedList->set_freepointer(NULL);
  155199             :        // DQ (6/6/2010): Temporary debugging...
  155200             :        //   ROSE_ASSERT(false);
  155201             :         }
  155202             : 
  155203           5 :      return ;
  155204             :    }
  155205             : 
  155206             : //############################################################################
  155207             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  155208             :  * within the memory pool and resets the freepointers, in order to achieve a 
  155209             :  * linked list, that has no jumps and starts at the beginning! This function 
  155210             :  * does not extend the memory pool, since we do not delete any memory blocks,
  155211             :  * but delete the valid objects.  
  155212             :  */
  155213             : void
  155214           0 : SgAddOp::clearMemoryPool( )
  155215             :    {
  155216             :   // printf ("Inside of SgAddOp::clearMemoryPool() \n");
  155217             : 
  155218           0 :      SgAddOp* pointer = NULL, *tempPointer = NULL;
  155219           0 :      std::vector < unsigned char* > :: const_iterator block;
  155220           0 :      if ( SgAddOp::pools.empty() == false )
  155221             :         {
  155222           0 :           block = SgAddOp::pools.begin() ;
  155223           0 :           SgAddOp::next_node = (SgAddOp*) (*block);
  155224             : 
  155225           0 :           while ( block != SgAddOp::pools.end() )
  155226             :              {
  155227           0 :                pointer = (SgAddOp*) (*block);
  155228           0 :                if ( tempPointer != NULL )
  155229             :                   {
  155230           0 :                     tempPointer->set_freepointer(pointer);
  155231             :                   }
  155232           0 :                for (unsigned i = 0; i < SgAddOp::pool_size - 1; ++i)
  155233             :                   {
  155234           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  155235             :                   }
  155236           0 :                 pointer[SgAddOp::pool_size-1].set_freepointer(NULL);
  155237           0 :                 tempPointer = &(pointer[SgAddOp::pool_size-1]);
  155238           0 :                 ++block;
  155239             :              }
  155240             :         }
  155241           0 :    }
  155242             : 
  155243           5 : void SgAddOp::deleteMemoryPool() {
  155244           7 :   for (auto p: SgAddOp::pools) {
  155245           2 :     ROSE_FREE(p);
  155246             :   }
  155247           5 :   SgAddOp::next_node = nullptr;
  155248           5 :   SgAddOp::pools.clear();
  155249           5 : }
  155250             : 
  155251             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  155252             : //                 reading multiple binary files to for a single AST.
  155253             : /////////// new version ////////////////////////////////
  155254             : //############################################################################
  155255             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  155256             : void
  155257           2 : SgAddOp::extendMemoryPoolForFileIO( )
  155258             :   {
  155259           2 :     size_t blockIndex = SgAddOp::pools.size();
  155260           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAddOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAddOp);
  155261             : 
  155262           3 :     while ( (blockIndex * SgAddOp::pool_size) < newPoolSize)
  155263             :       {
  155264             : #if ROSE_ALLOC_TRACE
  155265             :         if (blockIndex > 0) {
  155266             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAddOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAddOp) = %" PRIuPTR " SgAddOp::pool_size = %d \n",
  155267             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAddOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAddOp),SgAddOp::pool_size);
  155268             :         }
  155269             : #endif
  155270             : 
  155271           1 :         SgAddOp * pointer = (SgAddOp*) ROSE_MALLOC ( SgAddOp::pool_size * sizeof(SgAddOp) );
  155272           1 :         assert( pointer != NULL );
  155273             : #if ROSE_ALLOC_MEMSET == 1
  155274             :         memset(pointer, 0x00, SgAddOp::pool_size * sizeof(SgAddOp));
  155275             : #elif ROSE_ALLOC_MEMSET == 2
  155276             :         memset(pointer, 0xCC, SgAddOp::pool_size * sizeof(SgAddOp));
  155277             : #endif
  155278           1 :         SgAddOp::pools.push_back( (unsigned char*)(pointer) );
  155279           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAddOp::pool_size * sizeof(SgAddOp), V_SgAddOp ) );
  155280             : 
  155281           1 :         if ( SgAddOp::next_node != NULL ) {
  155282           0 :           if ( blockIndex > 0 ) {
  155283           0 :             SgAddOp * blkptr = (SgAddOp*)(SgAddOp::pools[blockIndex-1]);
  155284           0 :             blkptr[ SgAddOp::pool_size - 1 ].set_freepointer(pointer);
  155285             :           }
  155286             :         } else {
  155287           1 :           SgAddOp::next_node = pointer;
  155288             :         }
  155289             : 
  155290        2000 :         for (unsigned i = 0; i < SgAddOp::pool_size-1; ++i)
  155291             :            {
  155292        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  155293             :            }
  155294           1 :         pointer[ SgAddOp::pool_size -1 ].set_freepointer(NULL);
  155295             : 
  155296           1 :         blockIndex++;
  155297             :       }
  155298           2 :   }
  155299             : 
  155300             : //############################################################################
  155301             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  155302             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  155303             :  * not compressed. However, that stuff is not yet implemented! 
  155304             :  */
  155305             : unsigned long
  155306           0 : SgAddOp::getNumberOfLastValidPointer()
  155307             :    {
  155308           0 :       SgAddOp* testPointer = (SgAddOp*)(SgAddOp::pools.back());
  155309           0 :       unsigned long localIndex = SgAddOp::pool_size - 1;
  155310           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  155311             :          {
  155312           0 :            localIndex--;
  155313             :          }
  155314           0 :       return (localIndex + SgAddOp::pool_size * (SgAddOp::pools.size()-1));
  155315             :    }
  155316             : 
  155317             : //############################################################################
  155318             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  155319             :  * memory pool and initializes the data member in class SgAddOpStroageClass
  155320             :  * from its counterpart of SgAddOp. The return value is just for checking, 
  155321             :  * that the whole StorageClassArray is initialized!
  155322             :  */
  155323             : unsigned long
  155324           1 : SgAddOp::initializeStorageClassArray( SgAddOpStorageClass *storageArray )
  155325             :    {
  155326           1 :      unsigned long storageCounter = 0;
  155327           1 :      std::vector < unsigned char* > :: const_iterator block = SgAddOp::pools.begin();
  155328           1 :      SgAddOp* pointer = NULL;
  155329           2 :      while ( block != SgAddOp::pools.end() ) {
  155330           1 :           pointer = (SgAddOp*) (*block);
  155331        2001 :           for ( unsigned i = 0; i < SgAddOp::pool_size; ++i ) {
  155332        2000 :                if ( pointer->get_freepointer() != NULL ) {
  155333         190 :                  storageArray->pickOutIRNodeData (pointer) ;
  155334         190 :                  storageArray++;
  155335         190 :                  storageCounter++;
  155336             :                }
  155337        2000 :                pointer++;
  155338             :              }
  155339           1 :            block++;
  155340             :         }
  155341           1 :      return storageCounter;
  155342             :    }
  155343             : 
  155344             : /* #line 155345 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  155345             : 
  155346             : 
  155347             : 
  155348             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  155349             : 
  155350             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  155351             : 
  155352             : //############################################################################
  155353             : /* JH (02/02/2006) Constructor of the IR node SgSubtractOp that takes its 
  155354             :  * corresponding StorageClass as parameter
  155355             :  */
  155356         211 : SgSubtractOp :: SgSubtractOp ( const SgSubtractOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  155357             :    {
  155358             : 
  155359             : 
  155360             : /* #line 155361 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  155361             : 
  155362         211 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  155363             : 
  155364             : 
  155365             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  155366             : 
  155367             : 
  155368         211 :    }
  155369             : 
  155370             : //############################################################################
  155371             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  155372             :  * within the working AST. 
  155373             :  */
  155374        1266 : SgSubtractOp * SgSubtractOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  155375        1266 :      SgSubtractOp* returnPointer = NULL;
  155376        1266 :      if ( globalIndex != 0 )
  155377             :         {
  155378             : 
  155379             : #if FILE_IO_EXTRA_CHECK
  155380        1266 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSubtractOp ) ) <= globalIndex ) ;
  155381        1266 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSubtractOp + 1 ) ) );
  155382             : #endif
  155383        1266 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSubtractOp )  
  155384        1266 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSubtractOp );
  155385        1266 :           unsigned long positionInPool = localIndex % SgSubtractOp::pool_size;
  155386        1266 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSubtractOp::pool_size;
  155387             : 
  155388             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  155389             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  155390             : 
  155391        1266 :           returnPointer = &( ( (SgSubtractOp*)(SgSubtractOp::pools[memoryBlock]) ) [positionInPool]) ;
  155392             : 
  155393        1266 :           ROSE_ASSERT( returnPointer != NULL ) ;
  155394             :         }
  155395        1266 :      return returnPointer ;
  155396             :    }
  155397             : 
  155398             : //############################################################################
  155399             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  155400             :   for the AST with the index astIndex
  155401             : */
  155402           0 : SgSubtractOp * SgSubtractOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  155403           0 :      SgSubtractOp* returnPointer = NULL;
  155404           0 :      if ( globalIndex != 0 )
  155405             :         {
  155406             : 
  155407             : #if FILE_IO_EXTRA_CHECK
  155408           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSubtractOp ) ) <= globalIndex ) ;
  155409           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSubtractOp + 1 ) ) );
  155410             : #endif
  155411           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSubtractOp )
  155412           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSubtractOp );
  155413           0 :           unsigned long positionInPool = localIndex % SgSubtractOp::pool_size ;
  155414           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSubtractOp::pool_size ;
  155415             : 
  155416             : #if FILE_IO_EXTRA_CHECK
  155417             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  155418             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  155419             : #endif
  155420             : 
  155421           0 :           returnPointer = &( ( (SgSubtractOp*)(SgSubtractOp::pools[memoryBlock]) ) [positionInPool]) ;
  155422             : 
  155423             : #if FILE_IO_EXTRA_CHECK
  155424           0 :           assert ( returnPointer != NULL ) ;
  155425             : #endif
  155426             :         }
  155427           0 :      return returnPointer ;
  155428             :    }
  155429             : 
  155430             : //############################################################################
  155431             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  155432             :  * pool size! We set for every valid object in the memory pool the freepointer
  155433             :  * to the global index and increase the global index afterwards. For all the 
  155434             :  * invalid objects (means address ranges within the memory pool that were not
  155435             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  155436             :  * distinguish valid from invalid objects! 
  155437             :  */
  155438             : unsigned long
  155439           5 : SgSubtractOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  155440             :    {
  155441           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  155442           5 :      SgSubtractOp* pointer = NULL;
  155443           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  155444           5 :      std::vector < unsigned char* > :: const_iterator block;
  155445           7 :      for ( block = SgSubtractOp::pools.begin(); block != SgSubtractOp::pools.end() ; ++block )
  155446             :         {
  155447           2 :           pointer = (SgSubtractOp*)(*block);
  155448        4002 :           for (unsigned i = 0; i < SgSubtractOp::pool_size; ++i )
  155449             :              {
  155450             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  155451             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  155452             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  155453             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  155454             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  155455             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  155456             :             // properly; so this will have to be checked next.
  155457             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  155458             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  155459        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  155460             :                   {
  155461         211 :                     pointer[i].set_freepointer((SgSubtractOp*)(globalIndex));
  155462         211 :                     globalIndex++;
  155463             :                   }
  155464             :                else
  155465             :                   {
  155466        3789 :                     pointer[i].set_freepointer(NULL);
  155467             :                   }
  155468             :               }
  155469             :         }
  155470           5 :      return globalIndex;
  155471             :    }
  155472             : 
  155473             : //############################################################################
  155474             : // JH (01/14/2006)
  155475             : void
  155476           5 : SgSubtractOp::resetValidFreepointers( )
  155477             :    {
  155478           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  155479           5 :      SgSubtractOp* pointer = NULL;
  155480           5 :      std::vector < unsigned char* > :: const_iterator block;
  155481           5 :      SgSubtractOp* pointerOfLinkedList = NULL;
  155482           7 :      for ( block = SgSubtractOp::pools.begin(); block != SgSubtractOp::pools.end() ; ++block )
  155483             :         {
  155484           2 :           pointer = (SgSubtractOp*)(*block);
  155485        4002 :           for (unsigned i = 0; i < SgSubtractOp::pool_size; ++i )
  155486             :              {
  155487             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  155488             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  155489             :             // memory blocks!.
  155490        4000 :                if ( pointer[i].get_freepointer() != NULL )
  155491             :                   {
  155492         211 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  155493             :                   }
  155494             :                else
  155495             :                   {
  155496        3789 :                     if ( pointerOfLinkedList == NULL )
  155497             :                        {
  155498           2 :                          SgSubtractOp::next_node = &(pointer[i]);
  155499             :                        }
  155500             :                     else
  155501             :                        {
  155502             :                       // printf ("In SgSubtractOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  155503        3787 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  155504             :                        }
  155505             :                     pointerOfLinkedList = &(pointer[i]);
  155506             :                   }
  155507             :               }
  155508             :         }
  155509             : 
  155510           5 :      if ( pointerOfLinkedList != NULL )
  155511             :         {
  155512             :        // printf ("In SgSubtractOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  155513           2 :           pointerOfLinkedList->set_freepointer(NULL);
  155514             :        // DQ (6/6/2010): Temporary debugging...
  155515             :        //   ROSE_ASSERT(false);
  155516             :         }
  155517             : 
  155518           5 :      return ;
  155519             :    }
  155520             : 
  155521             : //############################################################################
  155522             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  155523             :  * within the memory pool and resets the freepointers, in order to achieve a 
  155524             :  * linked list, that has no jumps and starts at the beginning! This function 
  155525             :  * does not extend the memory pool, since we do not delete any memory blocks,
  155526             :  * but delete the valid objects.  
  155527             :  */
  155528             : void
  155529           0 : SgSubtractOp::clearMemoryPool( )
  155530             :    {
  155531             :   // printf ("Inside of SgSubtractOp::clearMemoryPool() \n");
  155532             : 
  155533           0 :      SgSubtractOp* pointer = NULL, *tempPointer = NULL;
  155534           0 :      std::vector < unsigned char* > :: const_iterator block;
  155535           0 :      if ( SgSubtractOp::pools.empty() == false )
  155536             :         {
  155537           0 :           block = SgSubtractOp::pools.begin() ;
  155538           0 :           SgSubtractOp::next_node = (SgSubtractOp*) (*block);
  155539             : 
  155540           0 :           while ( block != SgSubtractOp::pools.end() )
  155541             :              {
  155542           0 :                pointer = (SgSubtractOp*) (*block);
  155543           0 :                if ( tempPointer != NULL )
  155544             :                   {
  155545           0 :                     tempPointer->set_freepointer(pointer);
  155546             :                   }
  155547           0 :                for (unsigned i = 0; i < SgSubtractOp::pool_size - 1; ++i)
  155548             :                   {
  155549           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  155550             :                   }
  155551           0 :                 pointer[SgSubtractOp::pool_size-1].set_freepointer(NULL);
  155552           0 :                 tempPointer = &(pointer[SgSubtractOp::pool_size-1]);
  155553           0 :                 ++block;
  155554             :              }
  155555             :         }
  155556           0 :    }
  155557             : 
  155558           5 : void SgSubtractOp::deleteMemoryPool() {
  155559           9 :   for (auto p: SgSubtractOp::pools) {
  155560           4 :     ROSE_FREE(p);
  155561             :   }
  155562           5 :   SgSubtractOp::next_node = nullptr;
  155563           5 :   SgSubtractOp::pools.clear();
  155564           5 : }
  155565             : 
  155566             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  155567             : //                 reading multiple binary files to for a single AST.
  155568             : /////////// new version ////////////////////////////////
  155569             : //############################################################################
  155570             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  155571             : void
  155572           2 : SgSubtractOp::extendMemoryPoolForFileIO( )
  155573             :   {
  155574           2 :     size_t blockIndex = SgSubtractOp::pools.size();
  155575           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSubtractOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSubtractOp);
  155576             : 
  155577           4 :     while ( (blockIndex * SgSubtractOp::pool_size) < newPoolSize)
  155578             :       {
  155579             : #if ROSE_ALLOC_TRACE
  155580             :         if (blockIndex > 0) {
  155581             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSubtractOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSubtractOp) = %" PRIuPTR " SgSubtractOp::pool_size = %d \n",
  155582             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSubtractOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSubtractOp),SgSubtractOp::pool_size);
  155583             :         }
  155584             : #endif
  155585             : 
  155586           2 :         SgSubtractOp * pointer = (SgSubtractOp*) ROSE_MALLOC ( SgSubtractOp::pool_size * sizeof(SgSubtractOp) );
  155587           2 :         assert( pointer != NULL );
  155588             : #if ROSE_ALLOC_MEMSET == 1
  155589             :         memset(pointer, 0x00, SgSubtractOp::pool_size * sizeof(SgSubtractOp));
  155590             : #elif ROSE_ALLOC_MEMSET == 2
  155591             :         memset(pointer, 0xCC, SgSubtractOp::pool_size * sizeof(SgSubtractOp));
  155592             : #endif
  155593           2 :         SgSubtractOp::pools.push_back( (unsigned char*)(pointer) );
  155594           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSubtractOp::pool_size * sizeof(SgSubtractOp), V_SgSubtractOp ) );
  155595             : 
  155596           2 :         if ( SgSubtractOp::next_node != NULL ) {
  155597           0 :           if ( blockIndex > 0 ) {
  155598           0 :             SgSubtractOp * blkptr = (SgSubtractOp*)(SgSubtractOp::pools[blockIndex-1]);
  155599           0 :             blkptr[ SgSubtractOp::pool_size - 1 ].set_freepointer(pointer);
  155600             :           }
  155601             :         } else {
  155602           2 :           SgSubtractOp::next_node = pointer;
  155603             :         }
  155604             : 
  155605        4000 :         for (unsigned i = 0; i < SgSubtractOp::pool_size-1; ++i)
  155606             :            {
  155607        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  155608             :            }
  155609           2 :         pointer[ SgSubtractOp::pool_size -1 ].set_freepointer(NULL);
  155610             : 
  155611           2 :         blockIndex++;
  155612             :       }
  155613           2 :   }
  155614             : 
  155615             : //############################################################################
  155616             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  155617             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  155618             :  * not compressed. However, that stuff is not yet implemented! 
  155619             :  */
  155620             : unsigned long
  155621           0 : SgSubtractOp::getNumberOfLastValidPointer()
  155622             :    {
  155623           0 :       SgSubtractOp* testPointer = (SgSubtractOp*)(SgSubtractOp::pools.back());
  155624           0 :       unsigned long localIndex = SgSubtractOp::pool_size - 1;
  155625           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  155626             :          {
  155627           0 :            localIndex--;
  155628             :          }
  155629           0 :       return (localIndex + SgSubtractOp::pool_size * (SgSubtractOp::pools.size()-1));
  155630             :    }
  155631             : 
  155632             : //############################################################################
  155633             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  155634             :  * memory pool and initializes the data member in class SgSubtractOpStroageClass
  155635             :  * from its counterpart of SgSubtractOp. The return value is just for checking, 
  155636             :  * that the whole StorageClassArray is initialized!
  155637             :  */
  155638             : unsigned long
  155639           2 : SgSubtractOp::initializeStorageClassArray( SgSubtractOpStorageClass *storageArray )
  155640             :    {
  155641           2 :      unsigned long storageCounter = 0;
  155642           2 :      std::vector < unsigned char* > :: const_iterator block = SgSubtractOp::pools.begin();
  155643           2 :      SgSubtractOp* pointer = NULL;
  155644           4 :      while ( block != SgSubtractOp::pools.end() ) {
  155645           2 :           pointer = (SgSubtractOp*) (*block);
  155646        4002 :           for ( unsigned i = 0; i < SgSubtractOp::pool_size; ++i ) {
  155647        4000 :                if ( pointer->get_freepointer() != NULL ) {
  155648         211 :                  storageArray->pickOutIRNodeData (pointer) ;
  155649         211 :                  storageArray++;
  155650         211 :                  storageCounter++;
  155651             :                }
  155652        4000 :                pointer++;
  155653             :              }
  155654           2 :            block++;
  155655             :         }
  155656           2 :      return storageCounter;
  155657             :    }
  155658             : 
  155659             : /* #line 155660 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  155660             : 
  155661             : 
  155662             : 
  155663             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  155664             : 
  155665             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  155666             : 
  155667             : //############################################################################
  155668             : /* JH (02/02/2006) Constructor of the IR node SgMultiplyOp that takes its 
  155669             :  * corresponding StorageClass as parameter
  155670             :  */
  155671          65 : SgMultiplyOp :: SgMultiplyOp ( const SgMultiplyOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  155672             :    {
  155673             : 
  155674             : 
  155675             : /* #line 155676 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  155676             : 
  155677          65 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  155678             : 
  155679             : 
  155680             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  155681             : 
  155682             : 
  155683          65 :    }
  155684             : 
  155685             : //############################################################################
  155686             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  155687             :  * within the working AST. 
  155688             :  */
  155689         390 : SgMultiplyOp * SgMultiplyOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  155690         390 :      SgMultiplyOp* returnPointer = NULL;
  155691         390 :      if ( globalIndex != 0 )
  155692             :         {
  155693             : 
  155694             : #if FILE_IO_EXTRA_CHECK
  155695         390 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMultiplyOp ) ) <= globalIndex ) ;
  155696         390 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMultiplyOp + 1 ) ) );
  155697             : #endif
  155698         390 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMultiplyOp )  
  155699         390 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMultiplyOp );
  155700         390 :           unsigned long positionInPool = localIndex % SgMultiplyOp::pool_size;
  155701         390 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMultiplyOp::pool_size;
  155702             : 
  155703             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  155704             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  155705             : 
  155706         390 :           returnPointer = &( ( (SgMultiplyOp*)(SgMultiplyOp::pools[memoryBlock]) ) [positionInPool]) ;
  155707             : 
  155708         390 :           ROSE_ASSERT( returnPointer != NULL ) ;
  155709             :         }
  155710         390 :      return returnPointer ;
  155711             :    }
  155712             : 
  155713             : //############################################################################
  155714             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  155715             :   for the AST with the index astIndex
  155716             : */
  155717           0 : SgMultiplyOp * SgMultiplyOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  155718           0 :      SgMultiplyOp* returnPointer = NULL;
  155719           0 :      if ( globalIndex != 0 )
  155720             :         {
  155721             : 
  155722             : #if FILE_IO_EXTRA_CHECK
  155723           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMultiplyOp ) ) <= globalIndex ) ;
  155724           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMultiplyOp + 1 ) ) );
  155725             : #endif
  155726           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMultiplyOp )
  155727           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMultiplyOp );
  155728           0 :           unsigned long positionInPool = localIndex % SgMultiplyOp::pool_size ;
  155729           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMultiplyOp::pool_size ;
  155730             : 
  155731             : #if FILE_IO_EXTRA_CHECK
  155732             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  155733             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  155734             : #endif
  155735             : 
  155736           0 :           returnPointer = &( ( (SgMultiplyOp*)(SgMultiplyOp::pools[memoryBlock]) ) [positionInPool]) ;
  155737             : 
  155738             : #if FILE_IO_EXTRA_CHECK
  155739           0 :           assert ( returnPointer != NULL ) ;
  155740             : #endif
  155741             :         }
  155742           0 :      return returnPointer ;
  155743             :    }
  155744             : 
  155745             : //############################################################################
  155746             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  155747             :  * pool size! We set for every valid object in the memory pool the freepointer
  155748             :  * to the global index and increase the global index afterwards. For all the 
  155749             :  * invalid objects (means address ranges within the memory pool that were not
  155750             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  155751             :  * distinguish valid from invalid objects! 
  155752             :  */
  155753             : unsigned long
  155754           5 : SgMultiplyOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  155755             :    {
  155756           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  155757           5 :      SgMultiplyOp* pointer = NULL;
  155758           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  155759           5 :      std::vector < unsigned char* > :: const_iterator block;
  155760           7 :      for ( block = SgMultiplyOp::pools.begin(); block != SgMultiplyOp::pools.end() ; ++block )
  155761             :         {
  155762           2 :           pointer = (SgMultiplyOp*)(*block);
  155763        4002 :           for (unsigned i = 0; i < SgMultiplyOp::pool_size; ++i )
  155764             :              {
  155765             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  155766             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  155767             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  155768             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  155769             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  155770             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  155771             :             // properly; so this will have to be checked next.
  155772             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  155773             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  155774        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  155775             :                   {
  155776          65 :                     pointer[i].set_freepointer((SgMultiplyOp*)(globalIndex));
  155777          65 :                     globalIndex++;
  155778             :                   }
  155779             :                else
  155780             :                   {
  155781        3935 :                     pointer[i].set_freepointer(NULL);
  155782             :                   }
  155783             :               }
  155784             :         }
  155785           5 :      return globalIndex;
  155786             :    }
  155787             : 
  155788             : //############################################################################
  155789             : // JH (01/14/2006)
  155790             : void
  155791           5 : SgMultiplyOp::resetValidFreepointers( )
  155792             :    {
  155793           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  155794           5 :      SgMultiplyOp* pointer = NULL;
  155795           5 :      std::vector < unsigned char* > :: const_iterator block;
  155796           5 :      SgMultiplyOp* pointerOfLinkedList = NULL;
  155797           7 :      for ( block = SgMultiplyOp::pools.begin(); block != SgMultiplyOp::pools.end() ; ++block )
  155798             :         {
  155799           2 :           pointer = (SgMultiplyOp*)(*block);
  155800        4002 :           for (unsigned i = 0; i < SgMultiplyOp::pool_size; ++i )
  155801             :              {
  155802             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  155803             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  155804             :             // memory blocks!.
  155805        4000 :                if ( pointer[i].get_freepointer() != NULL )
  155806             :                   {
  155807          65 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  155808             :                   }
  155809             :                else
  155810             :                   {
  155811        3935 :                     if ( pointerOfLinkedList == NULL )
  155812             :                        {
  155813           2 :                          SgMultiplyOp::next_node = &(pointer[i]);
  155814             :                        }
  155815             :                     else
  155816             :                        {
  155817             :                       // printf ("In SgMultiplyOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  155818        3933 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  155819             :                        }
  155820             :                     pointerOfLinkedList = &(pointer[i]);
  155821             :                   }
  155822             :               }
  155823             :         }
  155824             : 
  155825           5 :      if ( pointerOfLinkedList != NULL )
  155826             :         {
  155827             :        // printf ("In SgMultiplyOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  155828           2 :           pointerOfLinkedList->set_freepointer(NULL);
  155829             :        // DQ (6/6/2010): Temporary debugging...
  155830             :        //   ROSE_ASSERT(false);
  155831             :         }
  155832             : 
  155833           5 :      return ;
  155834             :    }
  155835             : 
  155836             : //############################################################################
  155837             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  155838             :  * within the memory pool and resets the freepointers, in order to achieve a 
  155839             :  * linked list, that has no jumps and starts at the beginning! This function 
  155840             :  * does not extend the memory pool, since we do not delete any memory blocks,
  155841             :  * but delete the valid objects.  
  155842             :  */
  155843             : void
  155844           0 : SgMultiplyOp::clearMemoryPool( )
  155845             :    {
  155846             :   // printf ("Inside of SgMultiplyOp::clearMemoryPool() \n");
  155847             : 
  155848           0 :      SgMultiplyOp* pointer = NULL, *tempPointer = NULL;
  155849           0 :      std::vector < unsigned char* > :: const_iterator block;
  155850           0 :      if ( SgMultiplyOp::pools.empty() == false )
  155851             :         {
  155852           0 :           block = SgMultiplyOp::pools.begin() ;
  155853           0 :           SgMultiplyOp::next_node = (SgMultiplyOp*) (*block);
  155854             : 
  155855           0 :           while ( block != SgMultiplyOp::pools.end() )
  155856             :              {
  155857           0 :                pointer = (SgMultiplyOp*) (*block);
  155858           0 :                if ( tempPointer != NULL )
  155859             :                   {
  155860           0 :                     tempPointer->set_freepointer(pointer);
  155861             :                   }
  155862           0 :                for (unsigned i = 0; i < SgMultiplyOp::pool_size - 1; ++i)
  155863             :                   {
  155864           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  155865             :                   }
  155866           0 :                 pointer[SgMultiplyOp::pool_size-1].set_freepointer(NULL);
  155867           0 :                 tempPointer = &(pointer[SgMultiplyOp::pool_size-1]);
  155868           0 :                 ++block;
  155869             :              }
  155870             :         }
  155871           0 :    }
  155872             : 
  155873           5 : void SgMultiplyOp::deleteMemoryPool() {
  155874           9 :   for (auto p: SgMultiplyOp::pools) {
  155875           4 :     ROSE_FREE(p);
  155876             :   }
  155877           5 :   SgMultiplyOp::next_node = nullptr;
  155878           5 :   SgMultiplyOp::pools.clear();
  155879           5 : }
  155880             : 
  155881             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  155882             : //                 reading multiple binary files to for a single AST.
  155883             : /////////// new version ////////////////////////////////
  155884             : //############################################################################
  155885             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  155886             : void
  155887           2 : SgMultiplyOp::extendMemoryPoolForFileIO( )
  155888             :   {
  155889           2 :     size_t blockIndex = SgMultiplyOp::pools.size();
  155890           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMultiplyOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMultiplyOp);
  155891             : 
  155892           4 :     while ( (blockIndex * SgMultiplyOp::pool_size) < newPoolSize)
  155893             :       {
  155894             : #if ROSE_ALLOC_TRACE
  155895             :         if (blockIndex > 0) {
  155896             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMultiplyOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMultiplyOp) = %" PRIuPTR " SgMultiplyOp::pool_size = %d \n",
  155897             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMultiplyOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMultiplyOp),SgMultiplyOp::pool_size);
  155898             :         }
  155899             : #endif
  155900             : 
  155901           2 :         SgMultiplyOp * pointer = (SgMultiplyOp*) ROSE_MALLOC ( SgMultiplyOp::pool_size * sizeof(SgMultiplyOp) );
  155902           2 :         assert( pointer != NULL );
  155903             : #if ROSE_ALLOC_MEMSET == 1
  155904             :         memset(pointer, 0x00, SgMultiplyOp::pool_size * sizeof(SgMultiplyOp));
  155905             : #elif ROSE_ALLOC_MEMSET == 2
  155906             :         memset(pointer, 0xCC, SgMultiplyOp::pool_size * sizeof(SgMultiplyOp));
  155907             : #endif
  155908           2 :         SgMultiplyOp::pools.push_back( (unsigned char*)(pointer) );
  155909           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMultiplyOp::pool_size * sizeof(SgMultiplyOp), V_SgMultiplyOp ) );
  155910             : 
  155911           2 :         if ( SgMultiplyOp::next_node != NULL ) {
  155912           0 :           if ( blockIndex > 0 ) {
  155913           0 :             SgMultiplyOp * blkptr = (SgMultiplyOp*)(SgMultiplyOp::pools[blockIndex-1]);
  155914           0 :             blkptr[ SgMultiplyOp::pool_size - 1 ].set_freepointer(pointer);
  155915             :           }
  155916             :         } else {
  155917           2 :           SgMultiplyOp::next_node = pointer;
  155918             :         }
  155919             : 
  155920        4000 :         for (unsigned i = 0; i < SgMultiplyOp::pool_size-1; ++i)
  155921             :            {
  155922        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  155923             :            }
  155924           2 :         pointer[ SgMultiplyOp::pool_size -1 ].set_freepointer(NULL);
  155925             : 
  155926           2 :         blockIndex++;
  155927             :       }
  155928           2 :   }
  155929             : 
  155930             : //############################################################################
  155931             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  155932             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  155933             :  * not compressed. However, that stuff is not yet implemented! 
  155934             :  */
  155935             : unsigned long
  155936           0 : SgMultiplyOp::getNumberOfLastValidPointer()
  155937             :    {
  155938           0 :       SgMultiplyOp* testPointer = (SgMultiplyOp*)(SgMultiplyOp::pools.back());
  155939           0 :       unsigned long localIndex = SgMultiplyOp::pool_size - 1;
  155940           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  155941             :          {
  155942           0 :            localIndex--;
  155943             :          }
  155944           0 :       return (localIndex + SgMultiplyOp::pool_size * (SgMultiplyOp::pools.size()-1));
  155945             :    }
  155946             : 
  155947             : //############################################################################
  155948             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  155949             :  * memory pool and initializes the data member in class SgMultiplyOpStroageClass
  155950             :  * from its counterpart of SgMultiplyOp. The return value is just for checking, 
  155951             :  * that the whole StorageClassArray is initialized!
  155952             :  */
  155953             : unsigned long
  155954           2 : SgMultiplyOp::initializeStorageClassArray( SgMultiplyOpStorageClass *storageArray )
  155955             :    {
  155956           2 :      unsigned long storageCounter = 0;
  155957           2 :      std::vector < unsigned char* > :: const_iterator block = SgMultiplyOp::pools.begin();
  155958           2 :      SgMultiplyOp* pointer = NULL;
  155959           4 :      while ( block != SgMultiplyOp::pools.end() ) {
  155960           2 :           pointer = (SgMultiplyOp*) (*block);
  155961        4002 :           for ( unsigned i = 0; i < SgMultiplyOp::pool_size; ++i ) {
  155962        4000 :                if ( pointer->get_freepointer() != NULL ) {
  155963          65 :                  storageArray->pickOutIRNodeData (pointer) ;
  155964          65 :                  storageArray++;
  155965          65 :                  storageCounter++;
  155966             :                }
  155967        4000 :                pointer++;
  155968             :              }
  155969           2 :            block++;
  155970             :         }
  155971           2 :      return storageCounter;
  155972             :    }
  155973             : 
  155974             : /* #line 155975 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  155975             : 
  155976             : 
  155977             : 
  155978             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  155979             : 
  155980             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  155981             : 
  155982             : //############################################################################
  155983             : /* JH (02/02/2006) Constructor of the IR node SgDivideOp that takes its 
  155984             :  * corresponding StorageClass as parameter
  155985             :  */
  155986          37 : SgDivideOp :: SgDivideOp ( const SgDivideOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  155987             :    {
  155988             : 
  155989             : 
  155990             : /* #line 155991 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  155991             : 
  155992          37 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  155993             : 
  155994             : 
  155995             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  155996             : 
  155997             : 
  155998          37 :    }
  155999             : 
  156000             : //############################################################################
  156001             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  156002             :  * within the working AST. 
  156003             :  */
  156004         222 : SgDivideOp * SgDivideOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  156005         222 :      SgDivideOp* returnPointer = NULL;
  156006         222 :      if ( globalIndex != 0 )
  156007             :         {
  156008             : 
  156009             : #if FILE_IO_EXTRA_CHECK
  156010         222 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDivideOp ) ) <= globalIndex ) ;
  156011         222 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDivideOp + 1 ) ) );
  156012             : #endif
  156013         222 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDivideOp )  
  156014         222 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDivideOp );
  156015         222 :           unsigned long positionInPool = localIndex % SgDivideOp::pool_size;
  156016         222 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDivideOp::pool_size;
  156017             : 
  156018             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  156019             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  156020             : 
  156021         222 :           returnPointer = &( ( (SgDivideOp*)(SgDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  156022             : 
  156023         222 :           ROSE_ASSERT( returnPointer != NULL ) ;
  156024             :         }
  156025         222 :      return returnPointer ;
  156026             :    }
  156027             : 
  156028             : //############################################################################
  156029             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  156030             :   for the AST with the index astIndex
  156031             : */
  156032           0 : SgDivideOp * SgDivideOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  156033           0 :      SgDivideOp* returnPointer = NULL;
  156034           0 :      if ( globalIndex != 0 )
  156035             :         {
  156036             : 
  156037             : #if FILE_IO_EXTRA_CHECK
  156038           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDivideOp ) ) <= globalIndex ) ;
  156039           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDivideOp + 1 ) ) );
  156040             : #endif
  156041           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDivideOp )
  156042           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDivideOp );
  156043           0 :           unsigned long positionInPool = localIndex % SgDivideOp::pool_size ;
  156044           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDivideOp::pool_size ;
  156045             : 
  156046             : #if FILE_IO_EXTRA_CHECK
  156047             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  156048             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  156049             : #endif
  156050             : 
  156051           0 :           returnPointer = &( ( (SgDivideOp*)(SgDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  156052             : 
  156053             : #if FILE_IO_EXTRA_CHECK
  156054           0 :           assert ( returnPointer != NULL ) ;
  156055             : #endif
  156056             :         }
  156057           0 :      return returnPointer ;
  156058             :    }
  156059             : 
  156060             : //############################################################################
  156061             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  156062             :  * pool size! We set for every valid object in the memory pool the freepointer
  156063             :  * to the global index and increase the global index afterwards. For all the 
  156064             :  * invalid objects (means address ranges within the memory pool that were not
  156065             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  156066             :  * distinguish valid from invalid objects! 
  156067             :  */
  156068             : unsigned long
  156069           5 : SgDivideOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  156070             :    {
  156071           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  156072           5 :      SgDivideOp* pointer = NULL;
  156073           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  156074           5 :      std::vector < unsigned char* > :: const_iterator block;
  156075           6 :      for ( block = SgDivideOp::pools.begin(); block != SgDivideOp::pools.end() ; ++block )
  156076             :         {
  156077           1 :           pointer = (SgDivideOp*)(*block);
  156078        2001 :           for (unsigned i = 0; i < SgDivideOp::pool_size; ++i )
  156079             :              {
  156080             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  156081             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  156082             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  156083             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  156084             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  156085             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  156086             :             // properly; so this will have to be checked next.
  156087             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  156088             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  156089        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  156090             :                   {
  156091          37 :                     pointer[i].set_freepointer((SgDivideOp*)(globalIndex));
  156092          37 :                     globalIndex++;
  156093             :                   }
  156094             :                else
  156095             :                   {
  156096        1963 :                     pointer[i].set_freepointer(NULL);
  156097             :                   }
  156098             :               }
  156099             :         }
  156100           5 :      return globalIndex;
  156101             :    }
  156102             : 
  156103             : //############################################################################
  156104             : // JH (01/14/2006)
  156105             : void
  156106           5 : SgDivideOp::resetValidFreepointers( )
  156107             :    {
  156108           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  156109           5 :      SgDivideOp* pointer = NULL;
  156110           5 :      std::vector < unsigned char* > :: const_iterator block;
  156111           5 :      SgDivideOp* pointerOfLinkedList = NULL;
  156112           6 :      for ( block = SgDivideOp::pools.begin(); block != SgDivideOp::pools.end() ; ++block )
  156113             :         {
  156114           1 :           pointer = (SgDivideOp*)(*block);
  156115        2001 :           for (unsigned i = 0; i < SgDivideOp::pool_size; ++i )
  156116             :              {
  156117             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  156118             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  156119             :             // memory blocks!.
  156120        2000 :                if ( pointer[i].get_freepointer() != NULL )
  156121             :                   {
  156122          37 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  156123             :                   }
  156124             :                else
  156125             :                   {
  156126        1963 :                     if ( pointerOfLinkedList == NULL )
  156127             :                        {
  156128           1 :                          SgDivideOp::next_node = &(pointer[i]);
  156129             :                        }
  156130             :                     else
  156131             :                        {
  156132             :                       // printf ("In SgDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  156133        1962 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  156134             :                        }
  156135             :                     pointerOfLinkedList = &(pointer[i]);
  156136             :                   }
  156137             :               }
  156138             :         }
  156139             : 
  156140           5 :      if ( pointerOfLinkedList != NULL )
  156141             :         {
  156142             :        // printf ("In SgDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  156143           1 :           pointerOfLinkedList->set_freepointer(NULL);
  156144             :        // DQ (6/6/2010): Temporary debugging...
  156145             :        //   ROSE_ASSERT(false);
  156146             :         }
  156147             : 
  156148           5 :      return ;
  156149             :    }
  156150             : 
  156151             : //############################################################################
  156152             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  156153             :  * within the memory pool and resets the freepointers, in order to achieve a 
  156154             :  * linked list, that has no jumps and starts at the beginning! This function 
  156155             :  * does not extend the memory pool, since we do not delete any memory blocks,
  156156             :  * but delete the valid objects.  
  156157             :  */
  156158             : void
  156159           0 : SgDivideOp::clearMemoryPool( )
  156160             :    {
  156161             :   // printf ("Inside of SgDivideOp::clearMemoryPool() \n");
  156162             : 
  156163           0 :      SgDivideOp* pointer = NULL, *tempPointer = NULL;
  156164           0 :      std::vector < unsigned char* > :: const_iterator block;
  156165           0 :      if ( SgDivideOp::pools.empty() == false )
  156166             :         {
  156167           0 :           block = SgDivideOp::pools.begin() ;
  156168           0 :           SgDivideOp::next_node = (SgDivideOp*) (*block);
  156169             : 
  156170           0 :           while ( block != SgDivideOp::pools.end() )
  156171             :              {
  156172           0 :                pointer = (SgDivideOp*) (*block);
  156173           0 :                if ( tempPointer != NULL )
  156174             :                   {
  156175           0 :                     tempPointer->set_freepointer(pointer);
  156176             :                   }
  156177           0 :                for (unsigned i = 0; i < SgDivideOp::pool_size - 1; ++i)
  156178             :                   {
  156179           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  156180             :                   }
  156181           0 :                 pointer[SgDivideOp::pool_size-1].set_freepointer(NULL);
  156182           0 :                 tempPointer = &(pointer[SgDivideOp::pool_size-1]);
  156183           0 :                 ++block;
  156184             :              }
  156185             :         }
  156186           0 :    }
  156187             : 
  156188           5 : void SgDivideOp::deleteMemoryPool() {
  156189           7 :   for (auto p: SgDivideOp::pools) {
  156190           2 :     ROSE_FREE(p);
  156191             :   }
  156192           5 :   SgDivideOp::next_node = nullptr;
  156193           5 :   SgDivideOp::pools.clear();
  156194           5 : }
  156195             : 
  156196             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  156197             : //                 reading multiple binary files to for a single AST.
  156198             : /////////// new version ////////////////////////////////
  156199             : //############################################################################
  156200             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  156201             : void
  156202           2 : SgDivideOp::extendMemoryPoolForFileIO( )
  156203             :   {
  156204           2 :     size_t blockIndex = SgDivideOp::pools.size();
  156205           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDivideOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDivideOp);
  156206             : 
  156207           3 :     while ( (blockIndex * SgDivideOp::pool_size) < newPoolSize)
  156208             :       {
  156209             : #if ROSE_ALLOC_TRACE
  156210             :         if (blockIndex > 0) {
  156211             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDivideOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDivideOp) = %" PRIuPTR " SgDivideOp::pool_size = %d \n",
  156212             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDivideOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDivideOp),SgDivideOp::pool_size);
  156213             :         }
  156214             : #endif
  156215             : 
  156216           1 :         SgDivideOp * pointer = (SgDivideOp*) ROSE_MALLOC ( SgDivideOp::pool_size * sizeof(SgDivideOp) );
  156217           1 :         assert( pointer != NULL );
  156218             : #if ROSE_ALLOC_MEMSET == 1
  156219             :         memset(pointer, 0x00, SgDivideOp::pool_size * sizeof(SgDivideOp));
  156220             : #elif ROSE_ALLOC_MEMSET == 2
  156221             :         memset(pointer, 0xCC, SgDivideOp::pool_size * sizeof(SgDivideOp));
  156222             : #endif
  156223           1 :         SgDivideOp::pools.push_back( (unsigned char*)(pointer) );
  156224           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDivideOp::pool_size * sizeof(SgDivideOp), V_SgDivideOp ) );
  156225             : 
  156226           1 :         if ( SgDivideOp::next_node != NULL ) {
  156227           0 :           if ( blockIndex > 0 ) {
  156228           0 :             SgDivideOp * blkptr = (SgDivideOp*)(SgDivideOp::pools[blockIndex-1]);
  156229           0 :             blkptr[ SgDivideOp::pool_size - 1 ].set_freepointer(pointer);
  156230             :           }
  156231             :         } else {
  156232           1 :           SgDivideOp::next_node = pointer;
  156233             :         }
  156234             : 
  156235        2000 :         for (unsigned i = 0; i < SgDivideOp::pool_size-1; ++i)
  156236             :            {
  156237        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  156238             :            }
  156239           1 :         pointer[ SgDivideOp::pool_size -1 ].set_freepointer(NULL);
  156240             : 
  156241           1 :         blockIndex++;
  156242             :       }
  156243           2 :   }
  156244             : 
  156245             : //############################################################################
  156246             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  156247             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  156248             :  * not compressed. However, that stuff is not yet implemented! 
  156249             :  */
  156250             : unsigned long
  156251           0 : SgDivideOp::getNumberOfLastValidPointer()
  156252             :    {
  156253           0 :       SgDivideOp* testPointer = (SgDivideOp*)(SgDivideOp::pools.back());
  156254           0 :       unsigned long localIndex = SgDivideOp::pool_size - 1;
  156255           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  156256             :          {
  156257           0 :            localIndex--;
  156258             :          }
  156259           0 :       return (localIndex + SgDivideOp::pool_size * (SgDivideOp::pools.size()-1));
  156260             :    }
  156261             : 
  156262             : //############################################################################
  156263             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  156264             :  * memory pool and initializes the data member in class SgDivideOpStroageClass
  156265             :  * from its counterpart of SgDivideOp. The return value is just for checking, 
  156266             :  * that the whole StorageClassArray is initialized!
  156267             :  */
  156268             : unsigned long
  156269           1 : SgDivideOp::initializeStorageClassArray( SgDivideOpStorageClass *storageArray )
  156270             :    {
  156271           1 :      unsigned long storageCounter = 0;
  156272           1 :      std::vector < unsigned char* > :: const_iterator block = SgDivideOp::pools.begin();
  156273           1 :      SgDivideOp* pointer = NULL;
  156274           2 :      while ( block != SgDivideOp::pools.end() ) {
  156275           1 :           pointer = (SgDivideOp*) (*block);
  156276        2001 :           for ( unsigned i = 0; i < SgDivideOp::pool_size; ++i ) {
  156277        2000 :                if ( pointer->get_freepointer() != NULL ) {
  156278          37 :                  storageArray->pickOutIRNodeData (pointer) ;
  156279          37 :                  storageArray++;
  156280          37 :                  storageCounter++;
  156281             :                }
  156282        2000 :                pointer++;
  156283             :              }
  156284           1 :            block++;
  156285             :         }
  156286           1 :      return storageCounter;
  156287             :    }
  156288             : 
  156289             : /* #line 156290 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  156290             : 
  156291             : 
  156292             : 
  156293             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  156294             : 
  156295             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  156296             : 
  156297             : //############################################################################
  156298             : /* JH (02/02/2006) Constructor of the IR node SgIntegerDivideOp that takes its 
  156299             :  * corresponding StorageClass as parameter
  156300             :  */
  156301           0 : SgIntegerDivideOp :: SgIntegerDivideOp ( const SgIntegerDivideOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  156302             :    {
  156303             : 
  156304             : 
  156305             : /* #line 156306 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  156306             : 
  156307           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  156308             : 
  156309             : 
  156310             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  156311             : 
  156312             : 
  156313           0 :    }
  156314             : 
  156315             : //############################################################################
  156316             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  156317             :  * within the working AST. 
  156318             :  */
  156319           0 : SgIntegerDivideOp * SgIntegerDivideOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  156320           0 :      SgIntegerDivideOp* returnPointer = NULL;
  156321           0 :      if ( globalIndex != 0 )
  156322             :         {
  156323             : 
  156324             : #if FILE_IO_EXTRA_CHECK
  156325           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIntegerDivideOp ) ) <= globalIndex ) ;
  156326           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntegerDivideOp + 1 ) ) );
  156327             : #endif
  156328           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntegerDivideOp )  
  156329           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIntegerDivideOp );
  156330           0 :           unsigned long positionInPool = localIndex % SgIntegerDivideOp::pool_size;
  156331           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntegerDivideOp::pool_size;
  156332             : 
  156333             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  156334             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  156335             : 
  156336           0 :           returnPointer = &( ( (SgIntegerDivideOp*)(SgIntegerDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  156337             : 
  156338           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  156339             :         }
  156340           0 :      return returnPointer ;
  156341             :    }
  156342             : 
  156343             : //############################################################################
  156344             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  156345             :   for the AST with the index astIndex
  156346             : */
  156347           0 : SgIntegerDivideOp * SgIntegerDivideOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  156348           0 :      SgIntegerDivideOp* returnPointer = NULL;
  156349           0 :      if ( globalIndex != 0 )
  156350             :         {
  156351             : 
  156352             : #if FILE_IO_EXTRA_CHECK
  156353           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIntegerDivideOp ) ) <= globalIndex ) ;
  156354           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntegerDivideOp + 1 ) ) );
  156355             : #endif
  156356           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntegerDivideOp )
  156357           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIntegerDivideOp );
  156358           0 :           unsigned long positionInPool = localIndex % SgIntegerDivideOp::pool_size ;
  156359           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntegerDivideOp::pool_size ;
  156360             : 
  156361             : #if FILE_IO_EXTRA_CHECK
  156362             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  156363             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  156364             : #endif
  156365             : 
  156366           0 :           returnPointer = &( ( (SgIntegerDivideOp*)(SgIntegerDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  156367             : 
  156368             : #if FILE_IO_EXTRA_CHECK
  156369           0 :           assert ( returnPointer != NULL ) ;
  156370             : #endif
  156371             :         }
  156372           0 :      return returnPointer ;
  156373             :    }
  156374             : 
  156375             : //############################################################################
  156376             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  156377             :  * pool size! We set for every valid object in the memory pool the freepointer
  156378             :  * to the global index and increase the global index afterwards. For all the 
  156379             :  * invalid objects (means address ranges within the memory pool that were not
  156380             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  156381             :  * distinguish valid from invalid objects! 
  156382             :  */
  156383             : unsigned long
  156384           5 : SgIntegerDivideOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  156385             :    {
  156386           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  156387           5 :      SgIntegerDivideOp* pointer = NULL;
  156388           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  156389           5 :      std::vector < unsigned char* > :: const_iterator block;
  156390           5 :      for ( block = SgIntegerDivideOp::pools.begin(); block != SgIntegerDivideOp::pools.end() ; ++block )
  156391             :         {
  156392           0 :           pointer = (SgIntegerDivideOp*)(*block);
  156393           0 :           for (unsigned i = 0; i < SgIntegerDivideOp::pool_size; ++i )
  156394             :              {
  156395             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  156396             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  156397             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  156398             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  156399             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  156400             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  156401             :             // properly; so this will have to be checked next.
  156402             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  156403             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  156404           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  156405             :                   {
  156406           0 :                     pointer[i].set_freepointer((SgIntegerDivideOp*)(globalIndex));
  156407           0 :                     globalIndex++;
  156408             :                   }
  156409             :                else
  156410             :                   {
  156411           0 :                     pointer[i].set_freepointer(NULL);
  156412             :                   }
  156413             :               }
  156414             :         }
  156415           5 :      return globalIndex;
  156416             :    }
  156417             : 
  156418             : //############################################################################
  156419             : // JH (01/14/2006)
  156420             : void
  156421           5 : SgIntegerDivideOp::resetValidFreepointers( )
  156422             :    {
  156423           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  156424           5 :      SgIntegerDivideOp* pointer = NULL;
  156425           5 :      std::vector < unsigned char* > :: const_iterator block;
  156426           5 :      SgIntegerDivideOp* pointerOfLinkedList = NULL;
  156427           5 :      for ( block = SgIntegerDivideOp::pools.begin(); block != SgIntegerDivideOp::pools.end() ; ++block )
  156428             :         {
  156429           0 :           pointer = (SgIntegerDivideOp*)(*block);
  156430           0 :           for (unsigned i = 0; i < SgIntegerDivideOp::pool_size; ++i )
  156431             :              {
  156432             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  156433             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  156434             :             // memory blocks!.
  156435           0 :                if ( pointer[i].get_freepointer() != NULL )
  156436             :                   {
  156437           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  156438             :                   }
  156439             :                else
  156440             :                   {
  156441           0 :                     if ( pointerOfLinkedList == NULL )
  156442             :                        {
  156443           0 :                          SgIntegerDivideOp::next_node = &(pointer[i]);
  156444             :                        }
  156445             :                     else
  156446             :                        {
  156447             :                       // printf ("In SgIntegerDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  156448           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  156449             :                        }
  156450             :                     pointerOfLinkedList = &(pointer[i]);
  156451             :                   }
  156452             :               }
  156453             :         }
  156454             : 
  156455           5 :      if ( pointerOfLinkedList != NULL )
  156456             :         {
  156457             :        // printf ("In SgIntegerDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  156458           0 :           pointerOfLinkedList->set_freepointer(NULL);
  156459             :        // DQ (6/6/2010): Temporary debugging...
  156460             :        //   ROSE_ASSERT(false);
  156461             :         }
  156462             : 
  156463           5 :      return ;
  156464             :    }
  156465             : 
  156466             : //############################################################################
  156467             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  156468             :  * within the memory pool and resets the freepointers, in order to achieve a 
  156469             :  * linked list, that has no jumps and starts at the beginning! This function 
  156470             :  * does not extend the memory pool, since we do not delete any memory blocks,
  156471             :  * but delete the valid objects.  
  156472             :  */
  156473             : void
  156474           0 : SgIntegerDivideOp::clearMemoryPool( )
  156475             :    {
  156476             :   // printf ("Inside of SgIntegerDivideOp::clearMemoryPool() \n");
  156477             : 
  156478           0 :      SgIntegerDivideOp* pointer = NULL, *tempPointer = NULL;
  156479           0 :      std::vector < unsigned char* > :: const_iterator block;
  156480           0 :      if ( SgIntegerDivideOp::pools.empty() == false )
  156481             :         {
  156482           0 :           block = SgIntegerDivideOp::pools.begin() ;
  156483           0 :           SgIntegerDivideOp::next_node = (SgIntegerDivideOp*) (*block);
  156484             : 
  156485           0 :           while ( block != SgIntegerDivideOp::pools.end() )
  156486             :              {
  156487           0 :                pointer = (SgIntegerDivideOp*) (*block);
  156488           0 :                if ( tempPointer != NULL )
  156489             :                   {
  156490           0 :                     tempPointer->set_freepointer(pointer);
  156491             :                   }
  156492           0 :                for (unsigned i = 0; i < SgIntegerDivideOp::pool_size - 1; ++i)
  156493             :                   {
  156494           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  156495             :                   }
  156496           0 :                 pointer[SgIntegerDivideOp::pool_size-1].set_freepointer(NULL);
  156497           0 :                 tempPointer = &(pointer[SgIntegerDivideOp::pool_size-1]);
  156498           0 :                 ++block;
  156499             :              }
  156500             :         }
  156501           0 :    }
  156502             : 
  156503           5 : void SgIntegerDivideOp::deleteMemoryPool() {
  156504           5 :   for (auto p: SgIntegerDivideOp::pools) {
  156505           0 :     ROSE_FREE(p);
  156506             :   }
  156507           5 :   SgIntegerDivideOp::next_node = nullptr;
  156508           5 :   SgIntegerDivideOp::pools.clear();
  156509           5 : }
  156510             : 
  156511             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  156512             : //                 reading multiple binary files to for a single AST.
  156513             : /////////// new version ////////////////////////////////
  156514             : //############################################################################
  156515             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  156516             : void
  156517           2 : SgIntegerDivideOp::extendMemoryPoolForFileIO( )
  156518             :   {
  156519           2 :     size_t blockIndex = SgIntegerDivideOp::pools.size();
  156520           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIntegerDivideOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntegerDivideOp);
  156521             : 
  156522           2 :     while ( (blockIndex * SgIntegerDivideOp::pool_size) < newPoolSize)
  156523             :       {
  156524             : #if ROSE_ALLOC_TRACE
  156525             :         if (blockIndex > 0) {
  156526             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIntegerDivideOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntegerDivideOp) = %" PRIuPTR " SgIntegerDivideOp::pool_size = %d \n",
  156527             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIntegerDivideOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntegerDivideOp),SgIntegerDivideOp::pool_size);
  156528             :         }
  156529             : #endif
  156530             : 
  156531           0 :         SgIntegerDivideOp * pointer = (SgIntegerDivideOp*) ROSE_MALLOC ( SgIntegerDivideOp::pool_size * sizeof(SgIntegerDivideOp) );
  156532           0 :         assert( pointer != NULL );
  156533             : #if ROSE_ALLOC_MEMSET == 1
  156534             :         memset(pointer, 0x00, SgIntegerDivideOp::pool_size * sizeof(SgIntegerDivideOp));
  156535             : #elif ROSE_ALLOC_MEMSET == 2
  156536             :         memset(pointer, 0xCC, SgIntegerDivideOp::pool_size * sizeof(SgIntegerDivideOp));
  156537             : #endif
  156538           0 :         SgIntegerDivideOp::pools.push_back( (unsigned char*)(pointer) );
  156539           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIntegerDivideOp::pool_size * sizeof(SgIntegerDivideOp), V_SgIntegerDivideOp ) );
  156540             : 
  156541           0 :         if ( SgIntegerDivideOp::next_node != NULL ) {
  156542           0 :           if ( blockIndex > 0 ) {
  156543           0 :             SgIntegerDivideOp * blkptr = (SgIntegerDivideOp*)(SgIntegerDivideOp::pools[blockIndex-1]);
  156544           0 :             blkptr[ SgIntegerDivideOp::pool_size - 1 ].set_freepointer(pointer);
  156545             :           }
  156546             :         } else {
  156547           0 :           SgIntegerDivideOp::next_node = pointer;
  156548             :         }
  156549             : 
  156550           0 :         for (unsigned i = 0; i < SgIntegerDivideOp::pool_size-1; ++i)
  156551             :            {
  156552           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  156553             :            }
  156554           0 :         pointer[ SgIntegerDivideOp::pool_size -1 ].set_freepointer(NULL);
  156555             : 
  156556           0 :         blockIndex++;
  156557             :       }
  156558           2 :   }
  156559             : 
  156560             : //############################################################################
  156561             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  156562             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  156563             :  * not compressed. However, that stuff is not yet implemented! 
  156564             :  */
  156565             : unsigned long
  156566           0 : SgIntegerDivideOp::getNumberOfLastValidPointer()
  156567             :    {
  156568           0 :       SgIntegerDivideOp* testPointer = (SgIntegerDivideOp*)(SgIntegerDivideOp::pools.back());
  156569           0 :       unsigned long localIndex = SgIntegerDivideOp::pool_size - 1;
  156570           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  156571             :          {
  156572           0 :            localIndex--;
  156573             :          }
  156574           0 :       return (localIndex + SgIntegerDivideOp::pool_size * (SgIntegerDivideOp::pools.size()-1));
  156575             :    }
  156576             : 
  156577             : //############################################################################
  156578             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  156579             :  * memory pool and initializes the data member in class SgIntegerDivideOpStroageClass
  156580             :  * from its counterpart of SgIntegerDivideOp. The return value is just for checking, 
  156581             :  * that the whole StorageClassArray is initialized!
  156582             :  */
  156583             : unsigned long
  156584           0 : SgIntegerDivideOp::initializeStorageClassArray( SgIntegerDivideOpStorageClass *storageArray )
  156585             :    {
  156586           0 :      unsigned long storageCounter = 0;
  156587           0 :      std::vector < unsigned char* > :: const_iterator block = SgIntegerDivideOp::pools.begin();
  156588           0 :      SgIntegerDivideOp* pointer = NULL;
  156589           0 :      while ( block != SgIntegerDivideOp::pools.end() ) {
  156590           0 :           pointer = (SgIntegerDivideOp*) (*block);
  156591           0 :           for ( unsigned i = 0; i < SgIntegerDivideOp::pool_size; ++i ) {
  156592           0 :                if ( pointer->get_freepointer() != NULL ) {
  156593           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  156594           0 :                  storageArray++;
  156595           0 :                  storageCounter++;
  156596             :                }
  156597           0 :                pointer++;
  156598             :              }
  156599           0 :            block++;
  156600             :         }
  156601           0 :      return storageCounter;
  156602             :    }
  156603             : 
  156604             : /* #line 156605 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  156605             : 
  156606             : 
  156607             : 
  156608             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  156609             : 
  156610             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  156611             : 
  156612             : //############################################################################
  156613             : /* JH (02/02/2006) Constructor of the IR node SgModOp that takes its 
  156614             :  * corresponding StorageClass as parameter
  156615             :  */
  156616           5 : SgModOp :: SgModOp ( const SgModOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  156617             :    {
  156618             : 
  156619             : 
  156620             : /* #line 156621 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  156621             : 
  156622           5 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  156623             : 
  156624             : 
  156625             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  156626             : 
  156627             : 
  156628           5 :    }
  156629             : 
  156630             : //############################################################################
  156631             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  156632             :  * within the working AST. 
  156633             :  */
  156634          30 : SgModOp * SgModOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  156635          30 :      SgModOp* returnPointer = NULL;
  156636          30 :      if ( globalIndex != 0 )
  156637             :         {
  156638             : 
  156639             : #if FILE_IO_EXTRA_CHECK
  156640          30 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgModOp ) ) <= globalIndex ) ;
  156641          30 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModOp + 1 ) ) );
  156642             : #endif
  156643          30 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModOp )  
  156644          30 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgModOp );
  156645          30 :           unsigned long positionInPool = localIndex % SgModOp::pool_size;
  156646          30 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModOp::pool_size;
  156647             : 
  156648             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  156649             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  156650             : 
  156651          30 :           returnPointer = &( ( (SgModOp*)(SgModOp::pools[memoryBlock]) ) [positionInPool]) ;
  156652             : 
  156653          30 :           ROSE_ASSERT( returnPointer != NULL ) ;
  156654             :         }
  156655          30 :      return returnPointer ;
  156656             :    }
  156657             : 
  156658             : //############################################################################
  156659             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  156660             :   for the AST with the index astIndex
  156661             : */
  156662           0 : SgModOp * SgModOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  156663           0 :      SgModOp* returnPointer = NULL;
  156664           0 :      if ( globalIndex != 0 )
  156665             :         {
  156666             : 
  156667             : #if FILE_IO_EXTRA_CHECK
  156668           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgModOp ) ) <= globalIndex ) ;
  156669           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModOp + 1 ) ) );
  156670             : #endif
  156671           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModOp )
  156672           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgModOp );
  156673           0 :           unsigned long positionInPool = localIndex % SgModOp::pool_size ;
  156674           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModOp::pool_size ;
  156675             : 
  156676             : #if FILE_IO_EXTRA_CHECK
  156677             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  156678             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  156679             : #endif
  156680             : 
  156681           0 :           returnPointer = &( ( (SgModOp*)(SgModOp::pools[memoryBlock]) ) [positionInPool]) ;
  156682             : 
  156683             : #if FILE_IO_EXTRA_CHECK
  156684           0 :           assert ( returnPointer != NULL ) ;
  156685             : #endif
  156686             :         }
  156687           0 :      return returnPointer ;
  156688             :    }
  156689             : 
  156690             : //############################################################################
  156691             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  156692             :  * pool size! We set for every valid object in the memory pool the freepointer
  156693             :  * to the global index and increase the global index afterwards. For all the 
  156694             :  * invalid objects (means address ranges within the memory pool that were not
  156695             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  156696             :  * distinguish valid from invalid objects! 
  156697             :  */
  156698             : unsigned long
  156699           5 : SgModOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  156700             :    {
  156701           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  156702           5 :      SgModOp* pointer = NULL;
  156703           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  156704           5 :      std::vector < unsigned char* > :: const_iterator block;
  156705           6 :      for ( block = SgModOp::pools.begin(); block != SgModOp::pools.end() ; ++block )
  156706             :         {
  156707           1 :           pointer = (SgModOp*)(*block);
  156708        2001 :           for (unsigned i = 0; i < SgModOp::pool_size; ++i )
  156709             :              {
  156710             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  156711             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  156712             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  156713             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  156714             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  156715             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  156716             :             // properly; so this will have to be checked next.
  156717             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  156718             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  156719        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  156720             :                   {
  156721           5 :                     pointer[i].set_freepointer((SgModOp*)(globalIndex));
  156722           5 :                     globalIndex++;
  156723             :                   }
  156724             :                else
  156725             :                   {
  156726        1995 :                     pointer[i].set_freepointer(NULL);
  156727             :                   }
  156728             :               }
  156729             :         }
  156730           5 :      return globalIndex;
  156731             :    }
  156732             : 
  156733             : //############################################################################
  156734             : // JH (01/14/2006)
  156735             : void
  156736           5 : SgModOp::resetValidFreepointers( )
  156737             :    {
  156738           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  156739           5 :      SgModOp* pointer = NULL;
  156740           5 :      std::vector < unsigned char* > :: const_iterator block;
  156741           5 :      SgModOp* pointerOfLinkedList = NULL;
  156742           6 :      for ( block = SgModOp::pools.begin(); block != SgModOp::pools.end() ; ++block )
  156743             :         {
  156744           1 :           pointer = (SgModOp*)(*block);
  156745        2001 :           for (unsigned i = 0; i < SgModOp::pool_size; ++i )
  156746             :              {
  156747             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  156748             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  156749             :             // memory blocks!.
  156750        2000 :                if ( pointer[i].get_freepointer() != NULL )
  156751             :                   {
  156752           5 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  156753             :                   }
  156754             :                else
  156755             :                   {
  156756        1995 :                     if ( pointerOfLinkedList == NULL )
  156757             :                        {
  156758           1 :                          SgModOp::next_node = &(pointer[i]);
  156759             :                        }
  156760             :                     else
  156761             :                        {
  156762             :                       // printf ("In SgModOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  156763        1994 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  156764             :                        }
  156765             :                     pointerOfLinkedList = &(pointer[i]);
  156766             :                   }
  156767             :               }
  156768             :         }
  156769             : 
  156770           5 :      if ( pointerOfLinkedList != NULL )
  156771             :         {
  156772             :        // printf ("In SgModOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  156773           1 :           pointerOfLinkedList->set_freepointer(NULL);
  156774             :        // DQ (6/6/2010): Temporary debugging...
  156775             :        //   ROSE_ASSERT(false);
  156776             :         }
  156777             : 
  156778           5 :      return ;
  156779             :    }
  156780             : 
  156781             : //############################################################################
  156782             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  156783             :  * within the memory pool and resets the freepointers, in order to achieve a 
  156784             :  * linked list, that has no jumps and starts at the beginning! This function 
  156785             :  * does not extend the memory pool, since we do not delete any memory blocks,
  156786             :  * but delete the valid objects.  
  156787             :  */
  156788             : void
  156789           0 : SgModOp::clearMemoryPool( )
  156790             :    {
  156791             :   // printf ("Inside of SgModOp::clearMemoryPool() \n");
  156792             : 
  156793           0 :      SgModOp* pointer = NULL, *tempPointer = NULL;
  156794           0 :      std::vector < unsigned char* > :: const_iterator block;
  156795           0 :      if ( SgModOp::pools.empty() == false )
  156796             :         {
  156797           0 :           block = SgModOp::pools.begin() ;
  156798           0 :           SgModOp::next_node = (SgModOp*) (*block);
  156799             : 
  156800           0 :           while ( block != SgModOp::pools.end() )
  156801             :              {
  156802           0 :                pointer = (SgModOp*) (*block);
  156803           0 :                if ( tempPointer != NULL )
  156804             :                   {
  156805           0 :                     tempPointer->set_freepointer(pointer);
  156806             :                   }
  156807           0 :                for (unsigned i = 0; i < SgModOp::pool_size - 1; ++i)
  156808             :                   {
  156809           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  156810             :                   }
  156811           0 :                 pointer[SgModOp::pool_size-1].set_freepointer(NULL);
  156812           0 :                 tempPointer = &(pointer[SgModOp::pool_size-1]);
  156813           0 :                 ++block;
  156814             :              }
  156815             :         }
  156816           0 :    }
  156817             : 
  156818           5 : void SgModOp::deleteMemoryPool() {
  156819           7 :   for (auto p: SgModOp::pools) {
  156820           2 :     ROSE_FREE(p);
  156821             :   }
  156822           5 :   SgModOp::next_node = nullptr;
  156823           5 :   SgModOp::pools.clear();
  156824           5 : }
  156825             : 
  156826             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  156827             : //                 reading multiple binary files to for a single AST.
  156828             : /////////// new version ////////////////////////////////
  156829             : //############################################################################
  156830             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  156831             : void
  156832           2 : SgModOp::extendMemoryPoolForFileIO( )
  156833             :   {
  156834           2 :     size_t blockIndex = SgModOp::pools.size();
  156835           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgModOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgModOp);
  156836             : 
  156837           3 :     while ( (blockIndex * SgModOp::pool_size) < newPoolSize)
  156838             :       {
  156839             : #if ROSE_ALLOC_TRACE
  156840             :         if (blockIndex > 0) {
  156841             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgModOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgModOp) = %" PRIuPTR " SgModOp::pool_size = %d \n",
  156842             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgModOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgModOp),SgModOp::pool_size);
  156843             :         }
  156844             : #endif
  156845             : 
  156846           1 :         SgModOp * pointer = (SgModOp*) ROSE_MALLOC ( SgModOp::pool_size * sizeof(SgModOp) );
  156847           1 :         assert( pointer != NULL );
  156848             : #if ROSE_ALLOC_MEMSET == 1
  156849             :         memset(pointer, 0x00, SgModOp::pool_size * sizeof(SgModOp));
  156850             : #elif ROSE_ALLOC_MEMSET == 2
  156851             :         memset(pointer, 0xCC, SgModOp::pool_size * sizeof(SgModOp));
  156852             : #endif
  156853           1 :         SgModOp::pools.push_back( (unsigned char*)(pointer) );
  156854           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgModOp::pool_size * sizeof(SgModOp), V_SgModOp ) );
  156855             : 
  156856           1 :         if ( SgModOp::next_node != NULL ) {
  156857           0 :           if ( blockIndex > 0 ) {
  156858           0 :             SgModOp * blkptr = (SgModOp*)(SgModOp::pools[blockIndex-1]);
  156859           0 :             blkptr[ SgModOp::pool_size - 1 ].set_freepointer(pointer);
  156860             :           }
  156861             :         } else {
  156862           1 :           SgModOp::next_node = pointer;
  156863             :         }
  156864             : 
  156865        2000 :         for (unsigned i = 0; i < SgModOp::pool_size-1; ++i)
  156866             :            {
  156867        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  156868             :            }
  156869           1 :         pointer[ SgModOp::pool_size -1 ].set_freepointer(NULL);
  156870             : 
  156871           1 :         blockIndex++;
  156872             :       }
  156873           2 :   }
  156874             : 
  156875             : //############################################################################
  156876             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  156877             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  156878             :  * not compressed. However, that stuff is not yet implemented! 
  156879             :  */
  156880             : unsigned long
  156881           0 : SgModOp::getNumberOfLastValidPointer()
  156882             :    {
  156883           0 :       SgModOp* testPointer = (SgModOp*)(SgModOp::pools.back());
  156884           0 :       unsigned long localIndex = SgModOp::pool_size - 1;
  156885           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  156886             :          {
  156887           0 :            localIndex--;
  156888             :          }
  156889           0 :       return (localIndex + SgModOp::pool_size * (SgModOp::pools.size()-1));
  156890             :    }
  156891             : 
  156892             : //############################################################################
  156893             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  156894             :  * memory pool and initializes the data member in class SgModOpStroageClass
  156895             :  * from its counterpart of SgModOp. The return value is just for checking, 
  156896             :  * that the whole StorageClassArray is initialized!
  156897             :  */
  156898             : unsigned long
  156899           1 : SgModOp::initializeStorageClassArray( SgModOpStorageClass *storageArray )
  156900             :    {
  156901           1 :      unsigned long storageCounter = 0;
  156902           1 :      std::vector < unsigned char* > :: const_iterator block = SgModOp::pools.begin();
  156903           1 :      SgModOp* pointer = NULL;
  156904           2 :      while ( block != SgModOp::pools.end() ) {
  156905           1 :           pointer = (SgModOp*) (*block);
  156906        2001 :           for ( unsigned i = 0; i < SgModOp::pool_size; ++i ) {
  156907        2000 :                if ( pointer->get_freepointer() != NULL ) {
  156908           5 :                  storageArray->pickOutIRNodeData (pointer) ;
  156909           5 :                  storageArray++;
  156910           5 :                  storageCounter++;
  156911             :                }
  156912        2000 :                pointer++;
  156913             :              }
  156914           1 :            block++;
  156915             :         }
  156916           1 :      return storageCounter;
  156917             :    }
  156918             : 
  156919             : /* #line 156920 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  156920             : 
  156921             : 
  156922             : 
  156923             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  156924             : 
  156925             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  156926             : 
  156927             : //############################################################################
  156928             : /* JH (02/02/2006) Constructor of the IR node SgAndOp that takes its 
  156929             :  * corresponding StorageClass as parameter
  156930             :  */
  156931         173 : SgAndOp :: SgAndOp ( const SgAndOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  156932             :    {
  156933             : 
  156934             : 
  156935             : /* #line 156936 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  156936             : 
  156937         173 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  156938             : 
  156939             : 
  156940             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  156941             : 
  156942             : 
  156943         173 :    }
  156944             : 
  156945             : //############################################################################
  156946             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  156947             :  * within the working AST. 
  156948             :  */
  156949        1038 : SgAndOp * SgAndOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  156950        1038 :      SgAndOp* returnPointer = NULL;
  156951        1038 :      if ( globalIndex != 0 )
  156952             :         {
  156953             : 
  156954             : #if FILE_IO_EXTRA_CHECK
  156955        1038 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAndOp ) ) <= globalIndex ) ;
  156956        1038 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAndOp + 1 ) ) );
  156957             : #endif
  156958        1038 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAndOp )  
  156959        1038 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAndOp );
  156960        1038 :           unsigned long positionInPool = localIndex % SgAndOp::pool_size;
  156961        1038 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAndOp::pool_size;
  156962             : 
  156963             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  156964             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  156965             : 
  156966        1038 :           returnPointer = &( ( (SgAndOp*)(SgAndOp::pools[memoryBlock]) ) [positionInPool]) ;
  156967             : 
  156968        1038 :           ROSE_ASSERT( returnPointer != NULL ) ;
  156969             :         }
  156970        1038 :      return returnPointer ;
  156971             :    }
  156972             : 
  156973             : //############################################################################
  156974             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  156975             :   for the AST with the index astIndex
  156976             : */
  156977           0 : SgAndOp * SgAndOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  156978           0 :      SgAndOp* returnPointer = NULL;
  156979           0 :      if ( globalIndex != 0 )
  156980             :         {
  156981             : 
  156982             : #if FILE_IO_EXTRA_CHECK
  156983           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAndOp ) ) <= globalIndex ) ;
  156984           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAndOp + 1 ) ) );
  156985             : #endif
  156986           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAndOp )
  156987           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAndOp );
  156988           0 :           unsigned long positionInPool = localIndex % SgAndOp::pool_size ;
  156989           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAndOp::pool_size ;
  156990             : 
  156991             : #if FILE_IO_EXTRA_CHECK
  156992             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  156993             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  156994             : #endif
  156995             : 
  156996           0 :           returnPointer = &( ( (SgAndOp*)(SgAndOp::pools[memoryBlock]) ) [positionInPool]) ;
  156997             : 
  156998             : #if FILE_IO_EXTRA_CHECK
  156999           0 :           assert ( returnPointer != NULL ) ;
  157000             : #endif
  157001             :         }
  157002           0 :      return returnPointer ;
  157003             :    }
  157004             : 
  157005             : //############################################################################
  157006             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  157007             :  * pool size! We set for every valid object in the memory pool the freepointer
  157008             :  * to the global index and increase the global index afterwards. For all the 
  157009             :  * invalid objects (means address ranges within the memory pool that were not
  157010             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  157011             :  * distinguish valid from invalid objects! 
  157012             :  */
  157013             : unsigned long
  157014           5 : SgAndOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  157015             :    {
  157016           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  157017           5 :      SgAndOp* pointer = NULL;
  157018           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  157019           5 :      std::vector < unsigned char* > :: const_iterator block;
  157020           6 :      for ( block = SgAndOp::pools.begin(); block != SgAndOp::pools.end() ; ++block )
  157021             :         {
  157022           1 :           pointer = (SgAndOp*)(*block);
  157023        2001 :           for (unsigned i = 0; i < SgAndOp::pool_size; ++i )
  157024             :              {
  157025             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  157026             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  157027             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  157028             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  157029             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  157030             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  157031             :             // properly; so this will have to be checked next.
  157032             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  157033             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  157034        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  157035             :                   {
  157036         173 :                     pointer[i].set_freepointer((SgAndOp*)(globalIndex));
  157037         173 :                     globalIndex++;
  157038             :                   }
  157039             :                else
  157040             :                   {
  157041        1827 :                     pointer[i].set_freepointer(NULL);
  157042             :                   }
  157043             :               }
  157044             :         }
  157045           5 :      return globalIndex;
  157046             :    }
  157047             : 
  157048             : //############################################################################
  157049             : // JH (01/14/2006)
  157050             : void
  157051           5 : SgAndOp::resetValidFreepointers( )
  157052             :    {
  157053           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  157054           5 :      SgAndOp* pointer = NULL;
  157055           5 :      std::vector < unsigned char* > :: const_iterator block;
  157056           5 :      SgAndOp* pointerOfLinkedList = NULL;
  157057           6 :      for ( block = SgAndOp::pools.begin(); block != SgAndOp::pools.end() ; ++block )
  157058             :         {
  157059           1 :           pointer = (SgAndOp*)(*block);
  157060        2001 :           for (unsigned i = 0; i < SgAndOp::pool_size; ++i )
  157061             :              {
  157062             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  157063             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  157064             :             // memory blocks!.
  157065        2000 :                if ( pointer[i].get_freepointer() != NULL )
  157066             :                   {
  157067         173 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  157068             :                   }
  157069             :                else
  157070             :                   {
  157071        1827 :                     if ( pointerOfLinkedList == NULL )
  157072             :                        {
  157073           1 :                          SgAndOp::next_node = &(pointer[i]);
  157074             :                        }
  157075             :                     else
  157076             :                        {
  157077             :                       // printf ("In SgAndOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  157078        1826 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  157079             :                        }
  157080             :                     pointerOfLinkedList = &(pointer[i]);
  157081             :                   }
  157082             :               }
  157083             :         }
  157084             : 
  157085           5 :      if ( pointerOfLinkedList != NULL )
  157086             :         {
  157087             :        // printf ("In SgAndOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  157088           1 :           pointerOfLinkedList->set_freepointer(NULL);
  157089             :        // DQ (6/6/2010): Temporary debugging...
  157090             :        //   ROSE_ASSERT(false);
  157091             :         }
  157092             : 
  157093           5 :      return ;
  157094             :    }
  157095             : 
  157096             : //############################################################################
  157097             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  157098             :  * within the memory pool and resets the freepointers, in order to achieve a 
  157099             :  * linked list, that has no jumps and starts at the beginning! This function 
  157100             :  * does not extend the memory pool, since we do not delete any memory blocks,
  157101             :  * but delete the valid objects.  
  157102             :  */
  157103             : void
  157104           0 : SgAndOp::clearMemoryPool( )
  157105             :    {
  157106             :   // printf ("Inside of SgAndOp::clearMemoryPool() \n");
  157107             : 
  157108           0 :      SgAndOp* pointer = NULL, *tempPointer = NULL;
  157109           0 :      std::vector < unsigned char* > :: const_iterator block;
  157110           0 :      if ( SgAndOp::pools.empty() == false )
  157111             :         {
  157112           0 :           block = SgAndOp::pools.begin() ;
  157113           0 :           SgAndOp::next_node = (SgAndOp*) (*block);
  157114             : 
  157115           0 :           while ( block != SgAndOp::pools.end() )
  157116             :              {
  157117           0 :                pointer = (SgAndOp*) (*block);
  157118           0 :                if ( tempPointer != NULL )
  157119             :                   {
  157120           0 :                     tempPointer->set_freepointer(pointer);
  157121             :                   }
  157122           0 :                for (unsigned i = 0; i < SgAndOp::pool_size - 1; ++i)
  157123             :                   {
  157124           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  157125             :                   }
  157126           0 :                 pointer[SgAndOp::pool_size-1].set_freepointer(NULL);
  157127           0 :                 tempPointer = &(pointer[SgAndOp::pool_size-1]);
  157128           0 :                 ++block;
  157129             :              }
  157130             :         }
  157131           0 :    }
  157132             : 
  157133           5 : void SgAndOp::deleteMemoryPool() {
  157134           7 :   for (auto p: SgAndOp::pools) {
  157135           2 :     ROSE_FREE(p);
  157136             :   }
  157137           5 :   SgAndOp::next_node = nullptr;
  157138           5 :   SgAndOp::pools.clear();
  157139           5 : }
  157140             : 
  157141             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  157142             : //                 reading multiple binary files to for a single AST.
  157143             : /////////// new version ////////////////////////////////
  157144             : //############################################################################
  157145             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  157146             : void
  157147           2 : SgAndOp::extendMemoryPoolForFileIO( )
  157148             :   {
  157149           2 :     size_t blockIndex = SgAndOp::pools.size();
  157150           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAndOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAndOp);
  157151             : 
  157152           3 :     while ( (blockIndex * SgAndOp::pool_size) < newPoolSize)
  157153             :       {
  157154             : #if ROSE_ALLOC_TRACE
  157155             :         if (blockIndex > 0) {
  157156             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAndOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAndOp) = %" PRIuPTR " SgAndOp::pool_size = %d \n",
  157157             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAndOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAndOp),SgAndOp::pool_size);
  157158             :         }
  157159             : #endif
  157160             : 
  157161           1 :         SgAndOp * pointer = (SgAndOp*) ROSE_MALLOC ( SgAndOp::pool_size * sizeof(SgAndOp) );
  157162           1 :         assert( pointer != NULL );
  157163             : #if ROSE_ALLOC_MEMSET == 1
  157164             :         memset(pointer, 0x00, SgAndOp::pool_size * sizeof(SgAndOp));
  157165             : #elif ROSE_ALLOC_MEMSET == 2
  157166             :         memset(pointer, 0xCC, SgAndOp::pool_size * sizeof(SgAndOp));
  157167             : #endif
  157168           1 :         SgAndOp::pools.push_back( (unsigned char*)(pointer) );
  157169           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAndOp::pool_size * sizeof(SgAndOp), V_SgAndOp ) );
  157170             : 
  157171           1 :         if ( SgAndOp::next_node != NULL ) {
  157172           0 :           if ( blockIndex > 0 ) {
  157173           0 :             SgAndOp * blkptr = (SgAndOp*)(SgAndOp::pools[blockIndex-1]);
  157174           0 :             blkptr[ SgAndOp::pool_size - 1 ].set_freepointer(pointer);
  157175             :           }
  157176             :         } else {
  157177           1 :           SgAndOp::next_node = pointer;
  157178             :         }
  157179             : 
  157180        2000 :         for (unsigned i = 0; i < SgAndOp::pool_size-1; ++i)
  157181             :            {
  157182        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  157183             :            }
  157184           1 :         pointer[ SgAndOp::pool_size -1 ].set_freepointer(NULL);
  157185             : 
  157186           1 :         blockIndex++;
  157187             :       }
  157188           2 :   }
  157189             : 
  157190             : //############################################################################
  157191             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  157192             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  157193             :  * not compressed. However, that stuff is not yet implemented! 
  157194             :  */
  157195             : unsigned long
  157196           0 : SgAndOp::getNumberOfLastValidPointer()
  157197             :    {
  157198           0 :       SgAndOp* testPointer = (SgAndOp*)(SgAndOp::pools.back());
  157199           0 :       unsigned long localIndex = SgAndOp::pool_size - 1;
  157200           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  157201             :          {
  157202           0 :            localIndex--;
  157203             :          }
  157204           0 :       return (localIndex + SgAndOp::pool_size * (SgAndOp::pools.size()-1));
  157205             :    }
  157206             : 
  157207             : //############################################################################
  157208             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  157209             :  * memory pool and initializes the data member in class SgAndOpStroageClass
  157210             :  * from its counterpart of SgAndOp. The return value is just for checking, 
  157211             :  * that the whole StorageClassArray is initialized!
  157212             :  */
  157213             : unsigned long
  157214           1 : SgAndOp::initializeStorageClassArray( SgAndOpStorageClass *storageArray )
  157215             :    {
  157216           1 :      unsigned long storageCounter = 0;
  157217           1 :      std::vector < unsigned char* > :: const_iterator block = SgAndOp::pools.begin();
  157218           1 :      SgAndOp* pointer = NULL;
  157219           2 :      while ( block != SgAndOp::pools.end() ) {
  157220           1 :           pointer = (SgAndOp*) (*block);
  157221        2001 :           for ( unsigned i = 0; i < SgAndOp::pool_size; ++i ) {
  157222        2000 :                if ( pointer->get_freepointer() != NULL ) {
  157223         173 :                  storageArray->pickOutIRNodeData (pointer) ;
  157224         173 :                  storageArray++;
  157225         173 :                  storageCounter++;
  157226             :                }
  157227        2000 :                pointer++;
  157228             :              }
  157229           1 :            block++;
  157230             :         }
  157231           1 :      return storageCounter;
  157232             :    }
  157233             : 
  157234             : /* #line 157235 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  157235             : 
  157236             : 
  157237             : 
  157238             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  157239             : 
  157240             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  157241             : 
  157242             : //############################################################################
  157243             : /* JH (02/02/2006) Constructor of the IR node SgOrOp that takes its 
  157244             :  * corresponding StorageClass as parameter
  157245             :  */
  157246          83 : SgOrOp :: SgOrOp ( const SgOrOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  157247             :    {
  157248             : 
  157249             : 
  157250             : /* #line 157251 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  157251             : 
  157252          83 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  157253             : 
  157254             : 
  157255             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  157256             : 
  157257             : 
  157258          83 :    }
  157259             : 
  157260             : //############################################################################
  157261             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  157262             :  * within the working AST. 
  157263             :  */
  157264         498 : SgOrOp * SgOrOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  157265         498 :      SgOrOp* returnPointer = NULL;
  157266         498 :      if ( globalIndex != 0 )
  157267             :         {
  157268             : 
  157269             : #if FILE_IO_EXTRA_CHECK
  157270         498 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgOrOp ) ) <= globalIndex ) ;
  157271         498 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOrOp + 1 ) ) );
  157272             : #endif
  157273         498 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgOrOp )  
  157274         498 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgOrOp );
  157275         498 :           unsigned long positionInPool = localIndex % SgOrOp::pool_size;
  157276         498 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOrOp::pool_size;
  157277             : 
  157278             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  157279             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  157280             : 
  157281         498 :           returnPointer = &( ( (SgOrOp*)(SgOrOp::pools[memoryBlock]) ) [positionInPool]) ;
  157282             : 
  157283         498 :           ROSE_ASSERT( returnPointer != NULL ) ;
  157284             :         }
  157285         498 :      return returnPointer ;
  157286             :    }
  157287             : 
  157288             : //############################################################################
  157289             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  157290             :   for the AST with the index astIndex
  157291             : */
  157292           0 : SgOrOp * SgOrOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  157293           0 :      SgOrOp* returnPointer = NULL;
  157294           0 :      if ( globalIndex != 0 )
  157295             :         {
  157296             : 
  157297             : #if FILE_IO_EXTRA_CHECK
  157298           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgOrOp ) ) <= globalIndex ) ;
  157299           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOrOp + 1 ) ) );
  157300             : #endif
  157301           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgOrOp )
  157302           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgOrOp );
  157303           0 :           unsigned long positionInPool = localIndex % SgOrOp::pool_size ;
  157304           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgOrOp::pool_size ;
  157305             : 
  157306             : #if FILE_IO_EXTRA_CHECK
  157307             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  157308             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  157309             : #endif
  157310             : 
  157311           0 :           returnPointer = &( ( (SgOrOp*)(SgOrOp::pools[memoryBlock]) ) [positionInPool]) ;
  157312             : 
  157313             : #if FILE_IO_EXTRA_CHECK
  157314           0 :           assert ( returnPointer != NULL ) ;
  157315             : #endif
  157316             :         }
  157317           0 :      return returnPointer ;
  157318             :    }
  157319             : 
  157320             : //############################################################################
  157321             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  157322             :  * pool size! We set for every valid object in the memory pool the freepointer
  157323             :  * to the global index and increase the global index afterwards. For all the 
  157324             :  * invalid objects (means address ranges within the memory pool that were not
  157325             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  157326             :  * distinguish valid from invalid objects! 
  157327             :  */
  157328             : unsigned long
  157329           5 : SgOrOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  157330             :    {
  157331           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  157332           5 :      SgOrOp* pointer = NULL;
  157333           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  157334           5 :      std::vector < unsigned char* > :: const_iterator block;
  157335           6 :      for ( block = SgOrOp::pools.begin(); block != SgOrOp::pools.end() ; ++block )
  157336             :         {
  157337           1 :           pointer = (SgOrOp*)(*block);
  157338        2001 :           for (unsigned i = 0; i < SgOrOp::pool_size; ++i )
  157339             :              {
  157340             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  157341             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  157342             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  157343             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  157344             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  157345             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  157346             :             // properly; so this will have to be checked next.
  157347             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  157348             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  157349        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  157350             :                   {
  157351          83 :                     pointer[i].set_freepointer((SgOrOp*)(globalIndex));
  157352          83 :                     globalIndex++;
  157353             :                   }
  157354             :                else
  157355             :                   {
  157356        1917 :                     pointer[i].set_freepointer(NULL);
  157357             :                   }
  157358             :               }
  157359             :         }
  157360           5 :      return globalIndex;
  157361             :    }
  157362             : 
  157363             : //############################################################################
  157364             : // JH (01/14/2006)
  157365             : void
  157366           5 : SgOrOp::resetValidFreepointers( )
  157367             :    {
  157368           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  157369           5 :      SgOrOp* pointer = NULL;
  157370           5 :      std::vector < unsigned char* > :: const_iterator block;
  157371           5 :      SgOrOp* pointerOfLinkedList = NULL;
  157372           6 :      for ( block = SgOrOp::pools.begin(); block != SgOrOp::pools.end() ; ++block )
  157373             :         {
  157374           1 :           pointer = (SgOrOp*)(*block);
  157375        2001 :           for (unsigned i = 0; i < SgOrOp::pool_size; ++i )
  157376             :              {
  157377             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  157378             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  157379             :             // memory blocks!.
  157380        2000 :                if ( pointer[i].get_freepointer() != NULL )
  157381             :                   {
  157382          83 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  157383             :                   }
  157384             :                else
  157385             :                   {
  157386        1917 :                     if ( pointerOfLinkedList == NULL )
  157387             :                        {
  157388           1 :                          SgOrOp::next_node = &(pointer[i]);
  157389             :                        }
  157390             :                     else
  157391             :                        {
  157392             :                       // printf ("In SgOrOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  157393        1916 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  157394             :                        }
  157395             :                     pointerOfLinkedList = &(pointer[i]);
  157396             :                   }
  157397             :               }
  157398             :         }
  157399             : 
  157400           5 :      if ( pointerOfLinkedList != NULL )
  157401             :         {
  157402             :        // printf ("In SgOrOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  157403           1 :           pointerOfLinkedList->set_freepointer(NULL);
  157404             :        // DQ (6/6/2010): Temporary debugging...
  157405             :        //   ROSE_ASSERT(false);
  157406             :         }
  157407             : 
  157408           5 :      return ;
  157409             :    }
  157410             : 
  157411             : //############################################################################
  157412             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  157413             :  * within the memory pool and resets the freepointers, in order to achieve a 
  157414             :  * linked list, that has no jumps and starts at the beginning! This function 
  157415             :  * does not extend the memory pool, since we do not delete any memory blocks,
  157416             :  * but delete the valid objects.  
  157417             :  */
  157418             : void
  157419           0 : SgOrOp::clearMemoryPool( )
  157420             :    {
  157421             :   // printf ("Inside of SgOrOp::clearMemoryPool() \n");
  157422             : 
  157423           0 :      SgOrOp* pointer = NULL, *tempPointer = NULL;
  157424           0 :      std::vector < unsigned char* > :: const_iterator block;
  157425           0 :      if ( SgOrOp::pools.empty() == false )
  157426             :         {
  157427           0 :           block = SgOrOp::pools.begin() ;
  157428           0 :           SgOrOp::next_node = (SgOrOp*) (*block);
  157429             : 
  157430           0 :           while ( block != SgOrOp::pools.end() )
  157431             :              {
  157432           0 :                pointer = (SgOrOp*) (*block);
  157433           0 :                if ( tempPointer != NULL )
  157434             :                   {
  157435           0 :                     tempPointer->set_freepointer(pointer);
  157436             :                   }
  157437           0 :                for (unsigned i = 0; i < SgOrOp::pool_size - 1; ++i)
  157438             :                   {
  157439           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  157440             :                   }
  157441           0 :                 pointer[SgOrOp::pool_size-1].set_freepointer(NULL);
  157442           0 :                 tempPointer = &(pointer[SgOrOp::pool_size-1]);
  157443           0 :                 ++block;
  157444             :              }
  157445             :         }
  157446           0 :    }
  157447             : 
  157448           5 : void SgOrOp::deleteMemoryPool() {
  157449           7 :   for (auto p: SgOrOp::pools) {
  157450           2 :     ROSE_FREE(p);
  157451             :   }
  157452           5 :   SgOrOp::next_node = nullptr;
  157453           5 :   SgOrOp::pools.clear();
  157454           5 : }
  157455             : 
  157456             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  157457             : //                 reading multiple binary files to for a single AST.
  157458             : /////////// new version ////////////////////////////////
  157459             : //############################################################################
  157460             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  157461             : void
  157462           2 : SgOrOp::extendMemoryPoolForFileIO( )
  157463             :   {
  157464           2 :     size_t blockIndex = SgOrOp::pools.size();
  157465           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgOrOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgOrOp);
  157466             : 
  157467           3 :     while ( (blockIndex * SgOrOp::pool_size) < newPoolSize)
  157468             :       {
  157469             : #if ROSE_ALLOC_TRACE
  157470             :         if (blockIndex > 0) {
  157471             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgOrOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgOrOp) = %" PRIuPTR " SgOrOp::pool_size = %d \n",
  157472             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgOrOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgOrOp),SgOrOp::pool_size);
  157473             :         }
  157474             : #endif
  157475             : 
  157476           1 :         SgOrOp * pointer = (SgOrOp*) ROSE_MALLOC ( SgOrOp::pool_size * sizeof(SgOrOp) );
  157477           1 :         assert( pointer != NULL );
  157478             : #if ROSE_ALLOC_MEMSET == 1
  157479             :         memset(pointer, 0x00, SgOrOp::pool_size * sizeof(SgOrOp));
  157480             : #elif ROSE_ALLOC_MEMSET == 2
  157481             :         memset(pointer, 0xCC, SgOrOp::pool_size * sizeof(SgOrOp));
  157482             : #endif
  157483           1 :         SgOrOp::pools.push_back( (unsigned char*)(pointer) );
  157484           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgOrOp::pool_size * sizeof(SgOrOp), V_SgOrOp ) );
  157485             : 
  157486           1 :         if ( SgOrOp::next_node != NULL ) {
  157487           0 :           if ( blockIndex > 0 ) {
  157488           0 :             SgOrOp * blkptr = (SgOrOp*)(SgOrOp::pools[blockIndex-1]);
  157489           0 :             blkptr[ SgOrOp::pool_size - 1 ].set_freepointer(pointer);
  157490             :           }
  157491             :         } else {
  157492           1 :           SgOrOp::next_node = pointer;
  157493             :         }
  157494             : 
  157495        2000 :         for (unsigned i = 0; i < SgOrOp::pool_size-1; ++i)
  157496             :            {
  157497        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  157498             :            }
  157499           1 :         pointer[ SgOrOp::pool_size -1 ].set_freepointer(NULL);
  157500             : 
  157501           1 :         blockIndex++;
  157502             :       }
  157503           2 :   }
  157504             : 
  157505             : //############################################################################
  157506             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  157507             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  157508             :  * not compressed. However, that stuff is not yet implemented! 
  157509             :  */
  157510             : unsigned long
  157511           0 : SgOrOp::getNumberOfLastValidPointer()
  157512             :    {
  157513           0 :       SgOrOp* testPointer = (SgOrOp*)(SgOrOp::pools.back());
  157514           0 :       unsigned long localIndex = SgOrOp::pool_size - 1;
  157515           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  157516             :          {
  157517           0 :            localIndex--;
  157518             :          }
  157519           0 :       return (localIndex + SgOrOp::pool_size * (SgOrOp::pools.size()-1));
  157520             :    }
  157521             : 
  157522             : //############################################################################
  157523             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  157524             :  * memory pool and initializes the data member in class SgOrOpStroageClass
  157525             :  * from its counterpart of SgOrOp. The return value is just for checking, 
  157526             :  * that the whole StorageClassArray is initialized!
  157527             :  */
  157528             : unsigned long
  157529           1 : SgOrOp::initializeStorageClassArray( SgOrOpStorageClass *storageArray )
  157530             :    {
  157531           1 :      unsigned long storageCounter = 0;
  157532           1 :      std::vector < unsigned char* > :: const_iterator block = SgOrOp::pools.begin();
  157533           1 :      SgOrOp* pointer = NULL;
  157534           2 :      while ( block != SgOrOp::pools.end() ) {
  157535           1 :           pointer = (SgOrOp*) (*block);
  157536        2001 :           for ( unsigned i = 0; i < SgOrOp::pool_size; ++i ) {
  157537        2000 :                if ( pointer->get_freepointer() != NULL ) {
  157538          83 :                  storageArray->pickOutIRNodeData (pointer) ;
  157539          83 :                  storageArray++;
  157540          83 :                  storageCounter++;
  157541             :                }
  157542        2000 :                pointer++;
  157543             :              }
  157544           1 :            block++;
  157545             :         }
  157546           1 :      return storageCounter;
  157547             :    }
  157548             : 
  157549             : /* #line 157550 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  157550             : 
  157551             : 
  157552             : 
  157553             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  157554             : 
  157555             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  157556             : 
  157557             : //############################################################################
  157558             : /* JH (02/02/2006) Constructor of the IR node SgBitXorOp that takes its 
  157559             :  * corresponding StorageClass as parameter
  157560             :  */
  157561           6 : SgBitXorOp :: SgBitXorOp ( const SgBitXorOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  157562             :    {
  157563             : 
  157564             : 
  157565             : /* #line 157566 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  157566             : 
  157567           6 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  157568             : 
  157569             : 
  157570             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  157571             : 
  157572             : 
  157573           6 :    }
  157574             : 
  157575             : //############################################################################
  157576             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  157577             :  * within the working AST. 
  157578             :  */
  157579          36 : SgBitXorOp * SgBitXorOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  157580          36 :      SgBitXorOp* returnPointer = NULL;
  157581          36 :      if ( globalIndex != 0 )
  157582             :         {
  157583             : 
  157584             : #if FILE_IO_EXTRA_CHECK
  157585          36 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBitXorOp ) ) <= globalIndex ) ;
  157586          36 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitXorOp + 1 ) ) );
  157587             : #endif
  157588          36 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitXorOp )  
  157589          36 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBitXorOp );
  157590          36 :           unsigned long positionInPool = localIndex % SgBitXorOp::pool_size;
  157591          36 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitXorOp::pool_size;
  157592             : 
  157593             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  157594             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  157595             : 
  157596          36 :           returnPointer = &( ( (SgBitXorOp*)(SgBitXorOp::pools[memoryBlock]) ) [positionInPool]) ;
  157597             : 
  157598          36 :           ROSE_ASSERT( returnPointer != NULL ) ;
  157599             :         }
  157600          36 :      return returnPointer ;
  157601             :    }
  157602             : 
  157603             : //############################################################################
  157604             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  157605             :   for the AST with the index astIndex
  157606             : */
  157607           0 : SgBitXorOp * SgBitXorOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  157608           0 :      SgBitXorOp* returnPointer = NULL;
  157609           0 :      if ( globalIndex != 0 )
  157610             :         {
  157611             : 
  157612             : #if FILE_IO_EXTRA_CHECK
  157613           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBitXorOp ) ) <= globalIndex ) ;
  157614           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitXorOp + 1 ) ) );
  157615             : #endif
  157616           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitXorOp )
  157617           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBitXorOp );
  157618           0 :           unsigned long positionInPool = localIndex % SgBitXorOp::pool_size ;
  157619           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitXorOp::pool_size ;
  157620             : 
  157621             : #if FILE_IO_EXTRA_CHECK
  157622             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  157623             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  157624             : #endif
  157625             : 
  157626           0 :           returnPointer = &( ( (SgBitXorOp*)(SgBitXorOp::pools[memoryBlock]) ) [positionInPool]) ;
  157627             : 
  157628             : #if FILE_IO_EXTRA_CHECK
  157629           0 :           assert ( returnPointer != NULL ) ;
  157630             : #endif
  157631             :         }
  157632           0 :      return returnPointer ;
  157633             :    }
  157634             : 
  157635             : //############################################################################
  157636             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  157637             :  * pool size! We set for every valid object in the memory pool the freepointer
  157638             :  * to the global index and increase the global index afterwards. For all the 
  157639             :  * invalid objects (means address ranges within the memory pool that were not
  157640             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  157641             :  * distinguish valid from invalid objects! 
  157642             :  */
  157643             : unsigned long
  157644           5 : SgBitXorOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  157645             :    {
  157646           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  157647           5 :      SgBitXorOp* pointer = NULL;
  157648           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  157649           5 :      std::vector < unsigned char* > :: const_iterator block;
  157650           6 :      for ( block = SgBitXorOp::pools.begin(); block != SgBitXorOp::pools.end() ; ++block )
  157651             :         {
  157652           1 :           pointer = (SgBitXorOp*)(*block);
  157653        2001 :           for (unsigned i = 0; i < SgBitXorOp::pool_size; ++i )
  157654             :              {
  157655             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  157656             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  157657             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  157658             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  157659             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  157660             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  157661             :             // properly; so this will have to be checked next.
  157662             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  157663             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  157664        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  157665             :                   {
  157666           6 :                     pointer[i].set_freepointer((SgBitXorOp*)(globalIndex));
  157667           6 :                     globalIndex++;
  157668             :                   }
  157669             :                else
  157670             :                   {
  157671        1994 :                     pointer[i].set_freepointer(NULL);
  157672             :                   }
  157673             :               }
  157674             :         }
  157675           5 :      return globalIndex;
  157676             :    }
  157677             : 
  157678             : //############################################################################
  157679             : // JH (01/14/2006)
  157680             : void
  157681           5 : SgBitXorOp::resetValidFreepointers( )
  157682             :    {
  157683           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  157684           5 :      SgBitXorOp* pointer = NULL;
  157685           5 :      std::vector < unsigned char* > :: const_iterator block;
  157686           5 :      SgBitXorOp* pointerOfLinkedList = NULL;
  157687           6 :      for ( block = SgBitXorOp::pools.begin(); block != SgBitXorOp::pools.end() ; ++block )
  157688             :         {
  157689           1 :           pointer = (SgBitXorOp*)(*block);
  157690        2001 :           for (unsigned i = 0; i < SgBitXorOp::pool_size; ++i )
  157691             :              {
  157692             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  157693             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  157694             :             // memory blocks!.
  157695        2000 :                if ( pointer[i].get_freepointer() != NULL )
  157696             :                   {
  157697           6 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  157698             :                   }
  157699             :                else
  157700             :                   {
  157701        1994 :                     if ( pointerOfLinkedList == NULL )
  157702             :                        {
  157703           1 :                          SgBitXorOp::next_node = &(pointer[i]);
  157704             :                        }
  157705             :                     else
  157706             :                        {
  157707             :                       // printf ("In SgBitXorOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  157708        1993 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  157709             :                        }
  157710             :                     pointerOfLinkedList = &(pointer[i]);
  157711             :                   }
  157712             :               }
  157713             :         }
  157714             : 
  157715           5 :      if ( pointerOfLinkedList != NULL )
  157716             :         {
  157717             :        // printf ("In SgBitXorOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  157718           1 :           pointerOfLinkedList->set_freepointer(NULL);
  157719             :        // DQ (6/6/2010): Temporary debugging...
  157720             :        //   ROSE_ASSERT(false);
  157721             :         }
  157722             : 
  157723           5 :      return ;
  157724             :    }
  157725             : 
  157726             : //############################################################################
  157727             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  157728             :  * within the memory pool and resets the freepointers, in order to achieve a 
  157729             :  * linked list, that has no jumps and starts at the beginning! This function 
  157730             :  * does not extend the memory pool, since we do not delete any memory blocks,
  157731             :  * but delete the valid objects.  
  157732             :  */
  157733             : void
  157734           0 : SgBitXorOp::clearMemoryPool( )
  157735             :    {
  157736             :   // printf ("Inside of SgBitXorOp::clearMemoryPool() \n");
  157737             : 
  157738           0 :      SgBitXorOp* pointer = NULL, *tempPointer = NULL;
  157739           0 :      std::vector < unsigned char* > :: const_iterator block;
  157740           0 :      if ( SgBitXorOp::pools.empty() == false )
  157741             :         {
  157742           0 :           block = SgBitXorOp::pools.begin() ;
  157743           0 :           SgBitXorOp::next_node = (SgBitXorOp*) (*block);
  157744             : 
  157745           0 :           while ( block != SgBitXorOp::pools.end() )
  157746             :              {
  157747           0 :                pointer = (SgBitXorOp*) (*block);
  157748           0 :                if ( tempPointer != NULL )
  157749             :                   {
  157750           0 :                     tempPointer->set_freepointer(pointer);
  157751             :                   }
  157752           0 :                for (unsigned i = 0; i < SgBitXorOp::pool_size - 1; ++i)
  157753             :                   {
  157754           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  157755             :                   }
  157756           0 :                 pointer[SgBitXorOp::pool_size-1].set_freepointer(NULL);
  157757           0 :                 tempPointer = &(pointer[SgBitXorOp::pool_size-1]);
  157758           0 :                 ++block;
  157759             :              }
  157760             :         }
  157761           0 :    }
  157762             : 
  157763           5 : void SgBitXorOp::deleteMemoryPool() {
  157764           7 :   for (auto p: SgBitXorOp::pools) {
  157765           2 :     ROSE_FREE(p);
  157766             :   }
  157767           5 :   SgBitXorOp::next_node = nullptr;
  157768           5 :   SgBitXorOp::pools.clear();
  157769           5 : }
  157770             : 
  157771             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  157772             : //                 reading multiple binary files to for a single AST.
  157773             : /////////// new version ////////////////////////////////
  157774             : //############################################################################
  157775             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  157776             : void
  157777           2 : SgBitXorOp::extendMemoryPoolForFileIO( )
  157778             :   {
  157779           2 :     size_t blockIndex = SgBitXorOp::pools.size();
  157780           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBitXorOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitXorOp);
  157781             : 
  157782           3 :     while ( (blockIndex * SgBitXorOp::pool_size) < newPoolSize)
  157783             :       {
  157784             : #if ROSE_ALLOC_TRACE
  157785             :         if (blockIndex > 0) {
  157786             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBitXorOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitXorOp) = %" PRIuPTR " SgBitXorOp::pool_size = %d \n",
  157787             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBitXorOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitXorOp),SgBitXorOp::pool_size);
  157788             :         }
  157789             : #endif
  157790             : 
  157791           1 :         SgBitXorOp * pointer = (SgBitXorOp*) ROSE_MALLOC ( SgBitXorOp::pool_size * sizeof(SgBitXorOp) );
  157792           1 :         assert( pointer != NULL );
  157793             : #if ROSE_ALLOC_MEMSET == 1
  157794             :         memset(pointer, 0x00, SgBitXorOp::pool_size * sizeof(SgBitXorOp));
  157795             : #elif ROSE_ALLOC_MEMSET == 2
  157796             :         memset(pointer, 0xCC, SgBitXorOp::pool_size * sizeof(SgBitXorOp));
  157797             : #endif
  157798           1 :         SgBitXorOp::pools.push_back( (unsigned char*)(pointer) );
  157799           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBitXorOp::pool_size * sizeof(SgBitXorOp), V_SgBitXorOp ) );
  157800             : 
  157801           1 :         if ( SgBitXorOp::next_node != NULL ) {
  157802           0 :           if ( blockIndex > 0 ) {
  157803           0 :             SgBitXorOp * blkptr = (SgBitXorOp*)(SgBitXorOp::pools[blockIndex-1]);
  157804           0 :             blkptr[ SgBitXorOp::pool_size - 1 ].set_freepointer(pointer);
  157805             :           }
  157806             :         } else {
  157807           1 :           SgBitXorOp::next_node = pointer;
  157808             :         }
  157809             : 
  157810        2000 :         for (unsigned i = 0; i < SgBitXorOp::pool_size-1; ++i)
  157811             :            {
  157812        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  157813             :            }
  157814           1 :         pointer[ SgBitXorOp::pool_size -1 ].set_freepointer(NULL);
  157815             : 
  157816           1 :         blockIndex++;
  157817             :       }
  157818           2 :   }
  157819             : 
  157820             : //############################################################################
  157821             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  157822             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  157823             :  * not compressed. However, that stuff is not yet implemented! 
  157824             :  */
  157825             : unsigned long
  157826           0 : SgBitXorOp::getNumberOfLastValidPointer()
  157827             :    {
  157828           0 :       SgBitXorOp* testPointer = (SgBitXorOp*)(SgBitXorOp::pools.back());
  157829           0 :       unsigned long localIndex = SgBitXorOp::pool_size - 1;
  157830           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  157831             :          {
  157832           0 :            localIndex--;
  157833             :          }
  157834           0 :       return (localIndex + SgBitXorOp::pool_size * (SgBitXorOp::pools.size()-1));
  157835             :    }
  157836             : 
  157837             : //############################################################################
  157838             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  157839             :  * memory pool and initializes the data member in class SgBitXorOpStroageClass
  157840             :  * from its counterpart of SgBitXorOp. The return value is just for checking, 
  157841             :  * that the whole StorageClassArray is initialized!
  157842             :  */
  157843             : unsigned long
  157844           1 : SgBitXorOp::initializeStorageClassArray( SgBitXorOpStorageClass *storageArray )
  157845             :    {
  157846           1 :      unsigned long storageCounter = 0;
  157847           1 :      std::vector < unsigned char* > :: const_iterator block = SgBitXorOp::pools.begin();
  157848           1 :      SgBitXorOp* pointer = NULL;
  157849           2 :      while ( block != SgBitXorOp::pools.end() ) {
  157850           1 :           pointer = (SgBitXorOp*) (*block);
  157851        2001 :           for ( unsigned i = 0; i < SgBitXorOp::pool_size; ++i ) {
  157852        2000 :                if ( pointer->get_freepointer() != NULL ) {
  157853           6 :                  storageArray->pickOutIRNodeData (pointer) ;
  157854           6 :                  storageArray++;
  157855           6 :                  storageCounter++;
  157856             :                }
  157857        2000 :                pointer++;
  157858             :              }
  157859           1 :            block++;
  157860             :         }
  157861           1 :      return storageCounter;
  157862             :    }
  157863             : 
  157864             : /* #line 157865 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  157865             : 
  157866             : 
  157867             : 
  157868             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  157869             : 
  157870             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  157871             : 
  157872             : //############################################################################
  157873             : /* JH (02/02/2006) Constructor of the IR node SgBitAndOp that takes its 
  157874             :  * corresponding StorageClass as parameter
  157875             :  */
  157876          20 : SgBitAndOp :: SgBitAndOp ( const SgBitAndOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  157877             :    {
  157878             : 
  157879             : 
  157880             : /* #line 157881 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  157881             : 
  157882          20 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  157883             : 
  157884             : 
  157885             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  157886             : 
  157887             : 
  157888          20 :    }
  157889             : 
  157890             : //############################################################################
  157891             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  157892             :  * within the working AST. 
  157893             :  */
  157894         120 : SgBitAndOp * SgBitAndOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  157895         120 :      SgBitAndOp* returnPointer = NULL;
  157896         120 :      if ( globalIndex != 0 )
  157897             :         {
  157898             : 
  157899             : #if FILE_IO_EXTRA_CHECK
  157900         120 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBitAndOp ) ) <= globalIndex ) ;
  157901         120 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitAndOp + 1 ) ) );
  157902             : #endif
  157903         120 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitAndOp )  
  157904         120 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBitAndOp );
  157905         120 :           unsigned long positionInPool = localIndex % SgBitAndOp::pool_size;
  157906         120 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitAndOp::pool_size;
  157907             : 
  157908             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  157909             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  157910             : 
  157911         120 :           returnPointer = &( ( (SgBitAndOp*)(SgBitAndOp::pools[memoryBlock]) ) [positionInPool]) ;
  157912             : 
  157913         120 :           ROSE_ASSERT( returnPointer != NULL ) ;
  157914             :         }
  157915         120 :      return returnPointer ;
  157916             :    }
  157917             : 
  157918             : //############################################################################
  157919             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  157920             :   for the AST with the index astIndex
  157921             : */
  157922           0 : SgBitAndOp * SgBitAndOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  157923           0 :      SgBitAndOp* returnPointer = NULL;
  157924           0 :      if ( globalIndex != 0 )
  157925             :         {
  157926             : 
  157927             : #if FILE_IO_EXTRA_CHECK
  157928           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBitAndOp ) ) <= globalIndex ) ;
  157929           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitAndOp + 1 ) ) );
  157930             : #endif
  157931           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitAndOp )
  157932           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBitAndOp );
  157933           0 :           unsigned long positionInPool = localIndex % SgBitAndOp::pool_size ;
  157934           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitAndOp::pool_size ;
  157935             : 
  157936             : #if FILE_IO_EXTRA_CHECK
  157937             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  157938             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  157939             : #endif
  157940             : 
  157941           0 :           returnPointer = &( ( (SgBitAndOp*)(SgBitAndOp::pools[memoryBlock]) ) [positionInPool]) ;
  157942             : 
  157943             : #if FILE_IO_EXTRA_CHECK
  157944           0 :           assert ( returnPointer != NULL ) ;
  157945             : #endif
  157946             :         }
  157947           0 :      return returnPointer ;
  157948             :    }
  157949             : 
  157950             : //############################################################################
  157951             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  157952             :  * pool size! We set for every valid object in the memory pool the freepointer
  157953             :  * to the global index and increase the global index afterwards. For all the 
  157954             :  * invalid objects (means address ranges within the memory pool that were not
  157955             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  157956             :  * distinguish valid from invalid objects! 
  157957             :  */
  157958             : unsigned long
  157959           5 : SgBitAndOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  157960             :    {
  157961           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  157962           5 :      SgBitAndOp* pointer = NULL;
  157963           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  157964           5 :      std::vector < unsigned char* > :: const_iterator block;
  157965           6 :      for ( block = SgBitAndOp::pools.begin(); block != SgBitAndOp::pools.end() ; ++block )
  157966             :         {
  157967           1 :           pointer = (SgBitAndOp*)(*block);
  157968        2001 :           for (unsigned i = 0; i < SgBitAndOp::pool_size; ++i )
  157969             :              {
  157970             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  157971             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  157972             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  157973             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  157974             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  157975             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  157976             :             // properly; so this will have to be checked next.
  157977             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  157978             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  157979        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  157980             :                   {
  157981          20 :                     pointer[i].set_freepointer((SgBitAndOp*)(globalIndex));
  157982          20 :                     globalIndex++;
  157983             :                   }
  157984             :                else
  157985             :                   {
  157986        1980 :                     pointer[i].set_freepointer(NULL);
  157987             :                   }
  157988             :               }
  157989             :         }
  157990           5 :      return globalIndex;
  157991             :    }
  157992             : 
  157993             : //############################################################################
  157994             : // JH (01/14/2006)
  157995             : void
  157996           5 : SgBitAndOp::resetValidFreepointers( )
  157997             :    {
  157998           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  157999           5 :      SgBitAndOp* pointer = NULL;
  158000           5 :      std::vector < unsigned char* > :: const_iterator block;
  158001           5 :      SgBitAndOp* pointerOfLinkedList = NULL;
  158002           6 :      for ( block = SgBitAndOp::pools.begin(); block != SgBitAndOp::pools.end() ; ++block )
  158003             :         {
  158004           1 :           pointer = (SgBitAndOp*)(*block);
  158005        2001 :           for (unsigned i = 0; i < SgBitAndOp::pool_size; ++i )
  158006             :              {
  158007             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  158008             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  158009             :             // memory blocks!.
  158010        2000 :                if ( pointer[i].get_freepointer() != NULL )
  158011             :                   {
  158012          20 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  158013             :                   }
  158014             :                else
  158015             :                   {
  158016        1980 :                     if ( pointerOfLinkedList == NULL )
  158017             :                        {
  158018           1 :                          SgBitAndOp::next_node = &(pointer[i]);
  158019             :                        }
  158020             :                     else
  158021             :                        {
  158022             :                       // printf ("In SgBitAndOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  158023        1979 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  158024             :                        }
  158025             :                     pointerOfLinkedList = &(pointer[i]);
  158026             :                   }
  158027             :               }
  158028             :         }
  158029             : 
  158030           5 :      if ( pointerOfLinkedList != NULL )
  158031             :         {
  158032             :        // printf ("In SgBitAndOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  158033           1 :           pointerOfLinkedList->set_freepointer(NULL);
  158034             :        // DQ (6/6/2010): Temporary debugging...
  158035             :        //   ROSE_ASSERT(false);
  158036             :         }
  158037             : 
  158038           5 :      return ;
  158039             :    }
  158040             : 
  158041             : //############################################################################
  158042             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  158043             :  * within the memory pool and resets the freepointers, in order to achieve a 
  158044             :  * linked list, that has no jumps and starts at the beginning! This function 
  158045             :  * does not extend the memory pool, since we do not delete any memory blocks,
  158046             :  * but delete the valid objects.  
  158047             :  */
  158048             : void
  158049           0 : SgBitAndOp::clearMemoryPool( )
  158050             :    {
  158051             :   // printf ("Inside of SgBitAndOp::clearMemoryPool() \n");
  158052             : 
  158053           0 :      SgBitAndOp* pointer = NULL, *tempPointer = NULL;
  158054           0 :      std::vector < unsigned char* > :: const_iterator block;
  158055           0 :      if ( SgBitAndOp::pools.empty() == false )
  158056             :         {
  158057           0 :           block = SgBitAndOp::pools.begin() ;
  158058           0 :           SgBitAndOp::next_node = (SgBitAndOp*) (*block);
  158059             : 
  158060           0 :           while ( block != SgBitAndOp::pools.end() )
  158061             :              {
  158062           0 :                pointer = (SgBitAndOp*) (*block);
  158063           0 :                if ( tempPointer != NULL )
  158064             :                   {
  158065           0 :                     tempPointer->set_freepointer(pointer);
  158066             :                   }
  158067           0 :                for (unsigned i = 0; i < SgBitAndOp::pool_size - 1; ++i)
  158068             :                   {
  158069           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  158070             :                   }
  158071           0 :                 pointer[SgBitAndOp::pool_size-1].set_freepointer(NULL);
  158072           0 :                 tempPointer = &(pointer[SgBitAndOp::pool_size-1]);
  158073           0 :                 ++block;
  158074             :              }
  158075             :         }
  158076           0 :    }
  158077             : 
  158078           5 : void SgBitAndOp::deleteMemoryPool() {
  158079           7 :   for (auto p: SgBitAndOp::pools) {
  158080           2 :     ROSE_FREE(p);
  158081             :   }
  158082           5 :   SgBitAndOp::next_node = nullptr;
  158083           5 :   SgBitAndOp::pools.clear();
  158084           5 : }
  158085             : 
  158086             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  158087             : //                 reading multiple binary files to for a single AST.
  158088             : /////////// new version ////////////////////////////////
  158089             : //############################################################################
  158090             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  158091             : void
  158092           2 : SgBitAndOp::extendMemoryPoolForFileIO( )
  158093             :   {
  158094           2 :     size_t blockIndex = SgBitAndOp::pools.size();
  158095           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBitAndOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitAndOp);
  158096             : 
  158097           3 :     while ( (blockIndex * SgBitAndOp::pool_size) < newPoolSize)
  158098             :       {
  158099             : #if ROSE_ALLOC_TRACE
  158100             :         if (blockIndex > 0) {
  158101             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBitAndOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitAndOp) = %" PRIuPTR " SgBitAndOp::pool_size = %d \n",
  158102             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBitAndOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitAndOp),SgBitAndOp::pool_size);
  158103             :         }
  158104             : #endif
  158105             : 
  158106           1 :         SgBitAndOp * pointer = (SgBitAndOp*) ROSE_MALLOC ( SgBitAndOp::pool_size * sizeof(SgBitAndOp) );
  158107           1 :         assert( pointer != NULL );
  158108             : #if ROSE_ALLOC_MEMSET == 1
  158109             :         memset(pointer, 0x00, SgBitAndOp::pool_size * sizeof(SgBitAndOp));
  158110             : #elif ROSE_ALLOC_MEMSET == 2
  158111             :         memset(pointer, 0xCC, SgBitAndOp::pool_size * sizeof(SgBitAndOp));
  158112             : #endif
  158113           1 :         SgBitAndOp::pools.push_back( (unsigned char*)(pointer) );
  158114           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBitAndOp::pool_size * sizeof(SgBitAndOp), V_SgBitAndOp ) );
  158115             : 
  158116           1 :         if ( SgBitAndOp::next_node != NULL ) {
  158117           0 :           if ( blockIndex > 0 ) {
  158118           0 :             SgBitAndOp * blkptr = (SgBitAndOp*)(SgBitAndOp::pools[blockIndex-1]);
  158119           0 :             blkptr[ SgBitAndOp::pool_size - 1 ].set_freepointer(pointer);
  158120             :           }
  158121             :         } else {
  158122           1 :           SgBitAndOp::next_node = pointer;
  158123             :         }
  158124             : 
  158125        2000 :         for (unsigned i = 0; i < SgBitAndOp::pool_size-1; ++i)
  158126             :            {
  158127        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  158128             :            }
  158129           1 :         pointer[ SgBitAndOp::pool_size -1 ].set_freepointer(NULL);
  158130             : 
  158131           1 :         blockIndex++;
  158132             :       }
  158133           2 :   }
  158134             : 
  158135             : //############################################################################
  158136             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  158137             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  158138             :  * not compressed. However, that stuff is not yet implemented! 
  158139             :  */
  158140             : unsigned long
  158141           0 : SgBitAndOp::getNumberOfLastValidPointer()
  158142             :    {
  158143           0 :       SgBitAndOp* testPointer = (SgBitAndOp*)(SgBitAndOp::pools.back());
  158144           0 :       unsigned long localIndex = SgBitAndOp::pool_size - 1;
  158145           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  158146             :          {
  158147           0 :            localIndex--;
  158148             :          }
  158149           0 :       return (localIndex + SgBitAndOp::pool_size * (SgBitAndOp::pools.size()-1));
  158150             :    }
  158151             : 
  158152             : //############################################################################
  158153             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  158154             :  * memory pool and initializes the data member in class SgBitAndOpStroageClass
  158155             :  * from its counterpart of SgBitAndOp. The return value is just for checking, 
  158156             :  * that the whole StorageClassArray is initialized!
  158157             :  */
  158158             : unsigned long
  158159           1 : SgBitAndOp::initializeStorageClassArray( SgBitAndOpStorageClass *storageArray )
  158160             :    {
  158161           1 :      unsigned long storageCounter = 0;
  158162           1 :      std::vector < unsigned char* > :: const_iterator block = SgBitAndOp::pools.begin();
  158163           1 :      SgBitAndOp* pointer = NULL;
  158164           2 :      while ( block != SgBitAndOp::pools.end() ) {
  158165           1 :           pointer = (SgBitAndOp*) (*block);
  158166        2001 :           for ( unsigned i = 0; i < SgBitAndOp::pool_size; ++i ) {
  158167        2000 :                if ( pointer->get_freepointer() != NULL ) {
  158168          20 :                  storageArray->pickOutIRNodeData (pointer) ;
  158169          20 :                  storageArray++;
  158170          20 :                  storageCounter++;
  158171             :                }
  158172        2000 :                pointer++;
  158173             :              }
  158174           1 :            block++;
  158175             :         }
  158176           1 :      return storageCounter;
  158177             :    }
  158178             : 
  158179             : /* #line 158180 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  158180             : 
  158181             : 
  158182             : 
  158183             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  158184             : 
  158185             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  158186             : 
  158187             : //############################################################################
  158188             : /* JH (02/02/2006) Constructor of the IR node SgBitOrOp that takes its 
  158189             :  * corresponding StorageClass as parameter
  158190             :  */
  158191          15 : SgBitOrOp :: SgBitOrOp ( const SgBitOrOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  158192             :    {
  158193             : 
  158194             : 
  158195             : /* #line 158196 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  158196             : 
  158197          15 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  158198             : 
  158199             : 
  158200             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  158201             : 
  158202             : 
  158203          15 :    }
  158204             : 
  158205             : //############################################################################
  158206             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  158207             :  * within the working AST. 
  158208             :  */
  158209          90 : SgBitOrOp * SgBitOrOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  158210          90 :      SgBitOrOp* returnPointer = NULL;
  158211          90 :      if ( globalIndex != 0 )
  158212             :         {
  158213             : 
  158214             : #if FILE_IO_EXTRA_CHECK
  158215          90 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBitOrOp ) ) <= globalIndex ) ;
  158216          90 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitOrOp + 1 ) ) );
  158217             : #endif
  158218          90 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitOrOp )  
  158219          90 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBitOrOp );
  158220          90 :           unsigned long positionInPool = localIndex % SgBitOrOp::pool_size;
  158221          90 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitOrOp::pool_size;
  158222             : 
  158223             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  158224             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  158225             : 
  158226          90 :           returnPointer = &( ( (SgBitOrOp*)(SgBitOrOp::pools[memoryBlock]) ) [positionInPool]) ;
  158227             : 
  158228          90 :           ROSE_ASSERT( returnPointer != NULL ) ;
  158229             :         }
  158230          90 :      return returnPointer ;
  158231             :    }
  158232             : 
  158233             : //############################################################################
  158234             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  158235             :   for the AST with the index astIndex
  158236             : */
  158237           0 : SgBitOrOp * SgBitOrOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  158238           0 :      SgBitOrOp* returnPointer = NULL;
  158239           0 :      if ( globalIndex != 0 )
  158240             :         {
  158241             : 
  158242             : #if FILE_IO_EXTRA_CHECK
  158243           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBitOrOp ) ) <= globalIndex ) ;
  158244           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitOrOp + 1 ) ) );
  158245             : #endif
  158246           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitOrOp )
  158247           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBitOrOp );
  158248           0 :           unsigned long positionInPool = localIndex % SgBitOrOp::pool_size ;
  158249           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitOrOp::pool_size ;
  158250             : 
  158251             : #if FILE_IO_EXTRA_CHECK
  158252             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  158253             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  158254             : #endif
  158255             : 
  158256           0 :           returnPointer = &( ( (SgBitOrOp*)(SgBitOrOp::pools[memoryBlock]) ) [positionInPool]) ;
  158257             : 
  158258             : #if FILE_IO_EXTRA_CHECK
  158259           0 :           assert ( returnPointer != NULL ) ;
  158260             : #endif
  158261             :         }
  158262           0 :      return returnPointer ;
  158263             :    }
  158264             : 
  158265             : //############################################################################
  158266             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  158267             :  * pool size! We set for every valid object in the memory pool the freepointer
  158268             :  * to the global index and increase the global index afterwards. For all the 
  158269             :  * invalid objects (means address ranges within the memory pool that were not
  158270             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  158271             :  * distinguish valid from invalid objects! 
  158272             :  */
  158273             : unsigned long
  158274           5 : SgBitOrOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  158275             :    {
  158276           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  158277           5 :      SgBitOrOp* pointer = NULL;
  158278           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  158279           5 :      std::vector < unsigned char* > :: const_iterator block;
  158280           6 :      for ( block = SgBitOrOp::pools.begin(); block != SgBitOrOp::pools.end() ; ++block )
  158281             :         {
  158282           1 :           pointer = (SgBitOrOp*)(*block);
  158283        2001 :           for (unsigned i = 0; i < SgBitOrOp::pool_size; ++i )
  158284             :              {
  158285             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  158286             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  158287             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  158288             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  158289             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  158290             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  158291             :             // properly; so this will have to be checked next.
  158292             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  158293             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  158294        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  158295             :                   {
  158296          15 :                     pointer[i].set_freepointer((SgBitOrOp*)(globalIndex));
  158297          15 :                     globalIndex++;
  158298             :                   }
  158299             :                else
  158300             :                   {
  158301        1985 :                     pointer[i].set_freepointer(NULL);
  158302             :                   }
  158303             :               }
  158304             :         }
  158305           5 :      return globalIndex;
  158306             :    }
  158307             : 
  158308             : //############################################################################
  158309             : // JH (01/14/2006)
  158310             : void
  158311           5 : SgBitOrOp::resetValidFreepointers( )
  158312             :    {
  158313           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  158314           5 :      SgBitOrOp* pointer = NULL;
  158315           5 :      std::vector < unsigned char* > :: const_iterator block;
  158316           5 :      SgBitOrOp* pointerOfLinkedList = NULL;
  158317           6 :      for ( block = SgBitOrOp::pools.begin(); block != SgBitOrOp::pools.end() ; ++block )
  158318             :         {
  158319           1 :           pointer = (SgBitOrOp*)(*block);
  158320        2001 :           for (unsigned i = 0; i < SgBitOrOp::pool_size; ++i )
  158321             :              {
  158322             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  158323             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  158324             :             // memory blocks!.
  158325        2000 :                if ( pointer[i].get_freepointer() != NULL )
  158326             :                   {
  158327          15 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  158328             :                   }
  158329             :                else
  158330             :                   {
  158331        1985 :                     if ( pointerOfLinkedList == NULL )
  158332             :                        {
  158333           1 :                          SgBitOrOp::next_node = &(pointer[i]);
  158334             :                        }
  158335             :                     else
  158336             :                        {
  158337             :                       // printf ("In SgBitOrOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  158338        1984 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  158339             :                        }
  158340             :                     pointerOfLinkedList = &(pointer[i]);
  158341             :                   }
  158342             :               }
  158343             :         }
  158344             : 
  158345           5 :      if ( pointerOfLinkedList != NULL )
  158346             :         {
  158347             :        // printf ("In SgBitOrOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  158348           1 :           pointerOfLinkedList->set_freepointer(NULL);
  158349             :        // DQ (6/6/2010): Temporary debugging...
  158350             :        //   ROSE_ASSERT(false);
  158351             :         }
  158352             : 
  158353           5 :      return ;
  158354             :    }
  158355             : 
  158356             : //############################################################################
  158357             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  158358             :  * within the memory pool and resets the freepointers, in order to achieve a 
  158359             :  * linked list, that has no jumps and starts at the beginning! This function 
  158360             :  * does not extend the memory pool, since we do not delete any memory blocks,
  158361             :  * but delete the valid objects.  
  158362             :  */
  158363             : void
  158364           0 : SgBitOrOp::clearMemoryPool( )
  158365             :    {
  158366             :   // printf ("Inside of SgBitOrOp::clearMemoryPool() \n");
  158367             : 
  158368           0 :      SgBitOrOp* pointer = NULL, *tempPointer = NULL;
  158369           0 :      std::vector < unsigned char* > :: const_iterator block;
  158370           0 :      if ( SgBitOrOp::pools.empty() == false )
  158371             :         {
  158372           0 :           block = SgBitOrOp::pools.begin() ;
  158373           0 :           SgBitOrOp::next_node = (SgBitOrOp*) (*block);
  158374             : 
  158375           0 :           while ( block != SgBitOrOp::pools.end() )
  158376             :              {
  158377           0 :                pointer = (SgBitOrOp*) (*block);
  158378           0 :                if ( tempPointer != NULL )
  158379             :                   {
  158380           0 :                     tempPointer->set_freepointer(pointer);
  158381             :                   }
  158382           0 :                for (unsigned i = 0; i < SgBitOrOp::pool_size - 1; ++i)
  158383             :                   {
  158384           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  158385             :                   }
  158386           0 :                 pointer[SgBitOrOp::pool_size-1].set_freepointer(NULL);
  158387           0 :                 tempPointer = &(pointer[SgBitOrOp::pool_size-1]);
  158388           0 :                 ++block;
  158389             :              }
  158390             :         }
  158391           0 :    }
  158392             : 
  158393           5 : void SgBitOrOp::deleteMemoryPool() {
  158394           7 :   for (auto p: SgBitOrOp::pools) {
  158395           2 :     ROSE_FREE(p);
  158396             :   }
  158397           5 :   SgBitOrOp::next_node = nullptr;
  158398           5 :   SgBitOrOp::pools.clear();
  158399           5 : }
  158400             : 
  158401             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  158402             : //                 reading multiple binary files to for a single AST.
  158403             : /////////// new version ////////////////////////////////
  158404             : //############################################################################
  158405             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  158406             : void
  158407           2 : SgBitOrOp::extendMemoryPoolForFileIO( )
  158408             :   {
  158409           2 :     size_t blockIndex = SgBitOrOp::pools.size();
  158410           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBitOrOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitOrOp);
  158411             : 
  158412           3 :     while ( (blockIndex * SgBitOrOp::pool_size) < newPoolSize)
  158413             :       {
  158414             : #if ROSE_ALLOC_TRACE
  158415             :         if (blockIndex > 0) {
  158416             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBitOrOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitOrOp) = %" PRIuPTR " SgBitOrOp::pool_size = %d \n",
  158417             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBitOrOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitOrOp),SgBitOrOp::pool_size);
  158418             :         }
  158419             : #endif
  158420             : 
  158421           1 :         SgBitOrOp * pointer = (SgBitOrOp*) ROSE_MALLOC ( SgBitOrOp::pool_size * sizeof(SgBitOrOp) );
  158422           1 :         assert( pointer != NULL );
  158423             : #if ROSE_ALLOC_MEMSET == 1
  158424             :         memset(pointer, 0x00, SgBitOrOp::pool_size * sizeof(SgBitOrOp));
  158425             : #elif ROSE_ALLOC_MEMSET == 2
  158426             :         memset(pointer, 0xCC, SgBitOrOp::pool_size * sizeof(SgBitOrOp));
  158427             : #endif
  158428           1 :         SgBitOrOp::pools.push_back( (unsigned char*)(pointer) );
  158429           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBitOrOp::pool_size * sizeof(SgBitOrOp), V_SgBitOrOp ) );
  158430             : 
  158431           1 :         if ( SgBitOrOp::next_node != NULL ) {
  158432           0 :           if ( blockIndex > 0 ) {
  158433           0 :             SgBitOrOp * blkptr = (SgBitOrOp*)(SgBitOrOp::pools[blockIndex-1]);
  158434           0 :             blkptr[ SgBitOrOp::pool_size - 1 ].set_freepointer(pointer);
  158435             :           }
  158436             :         } else {
  158437           1 :           SgBitOrOp::next_node = pointer;
  158438             :         }
  158439             : 
  158440        2000 :         for (unsigned i = 0; i < SgBitOrOp::pool_size-1; ++i)
  158441             :            {
  158442        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  158443             :            }
  158444           1 :         pointer[ SgBitOrOp::pool_size -1 ].set_freepointer(NULL);
  158445             : 
  158446           1 :         blockIndex++;
  158447             :       }
  158448           2 :   }
  158449             : 
  158450             : //############################################################################
  158451             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  158452             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  158453             :  * not compressed. However, that stuff is not yet implemented! 
  158454             :  */
  158455             : unsigned long
  158456           0 : SgBitOrOp::getNumberOfLastValidPointer()
  158457             :    {
  158458           0 :       SgBitOrOp* testPointer = (SgBitOrOp*)(SgBitOrOp::pools.back());
  158459           0 :       unsigned long localIndex = SgBitOrOp::pool_size - 1;
  158460           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  158461             :          {
  158462           0 :            localIndex--;
  158463             :          }
  158464           0 :       return (localIndex + SgBitOrOp::pool_size * (SgBitOrOp::pools.size()-1));
  158465             :    }
  158466             : 
  158467             : //############################################################################
  158468             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  158469             :  * memory pool and initializes the data member in class SgBitOrOpStroageClass
  158470             :  * from its counterpart of SgBitOrOp. The return value is just for checking, 
  158471             :  * that the whole StorageClassArray is initialized!
  158472             :  */
  158473             : unsigned long
  158474           1 : SgBitOrOp::initializeStorageClassArray( SgBitOrOpStorageClass *storageArray )
  158475             :    {
  158476           1 :      unsigned long storageCounter = 0;
  158477           1 :      std::vector < unsigned char* > :: const_iterator block = SgBitOrOp::pools.begin();
  158478           1 :      SgBitOrOp* pointer = NULL;
  158479           2 :      while ( block != SgBitOrOp::pools.end() ) {
  158480           1 :           pointer = (SgBitOrOp*) (*block);
  158481        2001 :           for ( unsigned i = 0; i < SgBitOrOp::pool_size; ++i ) {
  158482        2000 :                if ( pointer->get_freepointer() != NULL ) {
  158483          15 :                  storageArray->pickOutIRNodeData (pointer) ;
  158484          15 :                  storageArray++;
  158485          15 :                  storageCounter++;
  158486             :                }
  158487        2000 :                pointer++;
  158488             :              }
  158489           1 :            block++;
  158490             :         }
  158491           1 :      return storageCounter;
  158492             :    }
  158493             : 
  158494             : /* #line 158495 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  158495             : 
  158496             : 
  158497             : 
  158498             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  158499             : 
  158500             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  158501             : 
  158502             : //############################################################################
  158503             : /* JH (02/02/2006) Constructor of the IR node SgBitEqvOp that takes its 
  158504             :  * corresponding StorageClass as parameter
  158505             :  */
  158506           0 : SgBitEqvOp :: SgBitEqvOp ( const SgBitEqvOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  158507             :    {
  158508             : 
  158509             : 
  158510             : /* #line 158511 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  158511             : 
  158512           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  158513             : 
  158514             : 
  158515             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  158516             : 
  158517             : 
  158518           0 :    }
  158519             : 
  158520             : //############################################################################
  158521             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  158522             :  * within the working AST. 
  158523             :  */
  158524           0 : SgBitEqvOp * SgBitEqvOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  158525           0 :      SgBitEqvOp* returnPointer = NULL;
  158526           0 :      if ( globalIndex != 0 )
  158527             :         {
  158528             : 
  158529             : #if FILE_IO_EXTRA_CHECK
  158530           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBitEqvOp ) ) <= globalIndex ) ;
  158531           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitEqvOp + 1 ) ) );
  158532             : #endif
  158533           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBitEqvOp )  
  158534           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBitEqvOp );
  158535           0 :           unsigned long positionInPool = localIndex % SgBitEqvOp::pool_size;
  158536           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitEqvOp::pool_size;
  158537             : 
  158538             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  158539             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  158540             : 
  158541           0 :           returnPointer = &( ( (SgBitEqvOp*)(SgBitEqvOp::pools[memoryBlock]) ) [positionInPool]) ;
  158542             : 
  158543           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  158544             :         }
  158545           0 :      return returnPointer ;
  158546             :    }
  158547             : 
  158548             : //############################################################################
  158549             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  158550             :   for the AST with the index astIndex
  158551             : */
  158552           0 : SgBitEqvOp * SgBitEqvOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  158553           0 :      SgBitEqvOp* returnPointer = NULL;
  158554           0 :      if ( globalIndex != 0 )
  158555             :         {
  158556             : 
  158557             : #if FILE_IO_EXTRA_CHECK
  158558           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBitEqvOp ) ) <= globalIndex ) ;
  158559           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitEqvOp + 1 ) ) );
  158560             : #endif
  158561           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBitEqvOp )
  158562           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBitEqvOp );
  158563           0 :           unsigned long positionInPool = localIndex % SgBitEqvOp::pool_size ;
  158564           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBitEqvOp::pool_size ;
  158565             : 
  158566             : #if FILE_IO_EXTRA_CHECK
  158567             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  158568             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  158569             : #endif
  158570             : 
  158571           0 :           returnPointer = &( ( (SgBitEqvOp*)(SgBitEqvOp::pools[memoryBlock]) ) [positionInPool]) ;
  158572             : 
  158573             : #if FILE_IO_EXTRA_CHECK
  158574           0 :           assert ( returnPointer != NULL ) ;
  158575             : #endif
  158576             :         }
  158577           0 :      return returnPointer ;
  158578             :    }
  158579             : 
  158580             : //############################################################################
  158581             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  158582             :  * pool size! We set for every valid object in the memory pool the freepointer
  158583             :  * to the global index and increase the global index afterwards. For all the 
  158584             :  * invalid objects (means address ranges within the memory pool that were not
  158585             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  158586             :  * distinguish valid from invalid objects! 
  158587             :  */
  158588             : unsigned long
  158589           5 : SgBitEqvOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  158590             :    {
  158591           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  158592           5 :      SgBitEqvOp* pointer = NULL;
  158593           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  158594           5 :      std::vector < unsigned char* > :: const_iterator block;
  158595           5 :      for ( block = SgBitEqvOp::pools.begin(); block != SgBitEqvOp::pools.end() ; ++block )
  158596             :         {
  158597           0 :           pointer = (SgBitEqvOp*)(*block);
  158598           0 :           for (unsigned i = 0; i < SgBitEqvOp::pool_size; ++i )
  158599             :              {
  158600             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  158601             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  158602             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  158603             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  158604             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  158605             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  158606             :             // properly; so this will have to be checked next.
  158607             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  158608             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  158609           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  158610             :                   {
  158611           0 :                     pointer[i].set_freepointer((SgBitEqvOp*)(globalIndex));
  158612           0 :                     globalIndex++;
  158613             :                   }
  158614             :                else
  158615             :                   {
  158616           0 :                     pointer[i].set_freepointer(NULL);
  158617             :                   }
  158618             :               }
  158619             :         }
  158620           5 :      return globalIndex;
  158621             :    }
  158622             : 
  158623             : //############################################################################
  158624             : // JH (01/14/2006)
  158625             : void
  158626           5 : SgBitEqvOp::resetValidFreepointers( )
  158627             :    {
  158628           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  158629           5 :      SgBitEqvOp* pointer = NULL;
  158630           5 :      std::vector < unsigned char* > :: const_iterator block;
  158631           5 :      SgBitEqvOp* pointerOfLinkedList = NULL;
  158632           5 :      for ( block = SgBitEqvOp::pools.begin(); block != SgBitEqvOp::pools.end() ; ++block )
  158633             :         {
  158634           0 :           pointer = (SgBitEqvOp*)(*block);
  158635           0 :           for (unsigned i = 0; i < SgBitEqvOp::pool_size; ++i )
  158636             :              {
  158637             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  158638             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  158639             :             // memory blocks!.
  158640           0 :                if ( pointer[i].get_freepointer() != NULL )
  158641             :                   {
  158642           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  158643             :                   }
  158644             :                else
  158645             :                   {
  158646           0 :                     if ( pointerOfLinkedList == NULL )
  158647             :                        {
  158648           0 :                          SgBitEqvOp::next_node = &(pointer[i]);
  158649             :                        }
  158650             :                     else
  158651             :                        {
  158652             :                       // printf ("In SgBitEqvOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  158653           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  158654             :                        }
  158655             :                     pointerOfLinkedList = &(pointer[i]);
  158656             :                   }
  158657             :               }
  158658             :         }
  158659             : 
  158660           5 :      if ( pointerOfLinkedList != NULL )
  158661             :         {
  158662             :        // printf ("In SgBitEqvOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  158663           0 :           pointerOfLinkedList->set_freepointer(NULL);
  158664             :        // DQ (6/6/2010): Temporary debugging...
  158665             :        //   ROSE_ASSERT(false);
  158666             :         }
  158667             : 
  158668           5 :      return ;
  158669             :    }
  158670             : 
  158671             : //############################################################################
  158672             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  158673             :  * within the memory pool and resets the freepointers, in order to achieve a 
  158674             :  * linked list, that has no jumps and starts at the beginning! This function 
  158675             :  * does not extend the memory pool, since we do not delete any memory blocks,
  158676             :  * but delete the valid objects.  
  158677             :  */
  158678             : void
  158679           0 : SgBitEqvOp::clearMemoryPool( )
  158680             :    {
  158681             :   // printf ("Inside of SgBitEqvOp::clearMemoryPool() \n");
  158682             : 
  158683           0 :      SgBitEqvOp* pointer = NULL, *tempPointer = NULL;
  158684           0 :      std::vector < unsigned char* > :: const_iterator block;
  158685           0 :      if ( SgBitEqvOp::pools.empty() == false )
  158686             :         {
  158687           0 :           block = SgBitEqvOp::pools.begin() ;
  158688           0 :           SgBitEqvOp::next_node = (SgBitEqvOp*) (*block);
  158689             : 
  158690           0 :           while ( block != SgBitEqvOp::pools.end() )
  158691             :              {
  158692           0 :                pointer = (SgBitEqvOp*) (*block);
  158693           0 :                if ( tempPointer != NULL )
  158694             :                   {
  158695           0 :                     tempPointer->set_freepointer(pointer);
  158696             :                   }
  158697           0 :                for (unsigned i = 0; i < SgBitEqvOp::pool_size - 1; ++i)
  158698             :                   {
  158699           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  158700             :                   }
  158701           0 :                 pointer[SgBitEqvOp::pool_size-1].set_freepointer(NULL);
  158702           0 :                 tempPointer = &(pointer[SgBitEqvOp::pool_size-1]);
  158703           0 :                 ++block;
  158704             :              }
  158705             :         }
  158706           0 :    }
  158707             : 
  158708           5 : void SgBitEqvOp::deleteMemoryPool() {
  158709           5 :   for (auto p: SgBitEqvOp::pools) {
  158710           0 :     ROSE_FREE(p);
  158711             :   }
  158712           5 :   SgBitEqvOp::next_node = nullptr;
  158713           5 :   SgBitEqvOp::pools.clear();
  158714           5 : }
  158715             : 
  158716             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  158717             : //                 reading multiple binary files to for a single AST.
  158718             : /////////// new version ////////////////////////////////
  158719             : //############################################################################
  158720             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  158721             : void
  158722           2 : SgBitEqvOp::extendMemoryPoolForFileIO( )
  158723             :   {
  158724           2 :     size_t blockIndex = SgBitEqvOp::pools.size();
  158725           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBitEqvOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitEqvOp);
  158726             : 
  158727           2 :     while ( (blockIndex * SgBitEqvOp::pool_size) < newPoolSize)
  158728             :       {
  158729             : #if ROSE_ALLOC_TRACE
  158730             :         if (blockIndex > 0) {
  158731             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBitEqvOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitEqvOp) = %" PRIuPTR " SgBitEqvOp::pool_size = %d \n",
  158732             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBitEqvOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBitEqvOp),SgBitEqvOp::pool_size);
  158733             :         }
  158734             : #endif
  158735             : 
  158736           0 :         SgBitEqvOp * pointer = (SgBitEqvOp*) ROSE_MALLOC ( SgBitEqvOp::pool_size * sizeof(SgBitEqvOp) );
  158737           0 :         assert( pointer != NULL );
  158738             : #if ROSE_ALLOC_MEMSET == 1
  158739             :         memset(pointer, 0x00, SgBitEqvOp::pool_size * sizeof(SgBitEqvOp));
  158740             : #elif ROSE_ALLOC_MEMSET == 2
  158741             :         memset(pointer, 0xCC, SgBitEqvOp::pool_size * sizeof(SgBitEqvOp));
  158742             : #endif
  158743           0 :         SgBitEqvOp::pools.push_back( (unsigned char*)(pointer) );
  158744           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBitEqvOp::pool_size * sizeof(SgBitEqvOp), V_SgBitEqvOp ) );
  158745             : 
  158746           0 :         if ( SgBitEqvOp::next_node != NULL ) {
  158747           0 :           if ( blockIndex > 0 ) {
  158748           0 :             SgBitEqvOp * blkptr = (SgBitEqvOp*)(SgBitEqvOp::pools[blockIndex-1]);
  158749           0 :             blkptr[ SgBitEqvOp::pool_size - 1 ].set_freepointer(pointer);
  158750             :           }
  158751             :         } else {
  158752           0 :           SgBitEqvOp::next_node = pointer;
  158753             :         }
  158754             : 
  158755           0 :         for (unsigned i = 0; i < SgBitEqvOp::pool_size-1; ++i)
  158756             :            {
  158757           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  158758             :            }
  158759           0 :         pointer[ SgBitEqvOp::pool_size -1 ].set_freepointer(NULL);
  158760             : 
  158761           0 :         blockIndex++;
  158762             :       }
  158763           2 :   }
  158764             : 
  158765             : //############################################################################
  158766             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  158767             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  158768             :  * not compressed. However, that stuff is not yet implemented! 
  158769             :  */
  158770             : unsigned long
  158771           0 : SgBitEqvOp::getNumberOfLastValidPointer()
  158772             :    {
  158773           0 :       SgBitEqvOp* testPointer = (SgBitEqvOp*)(SgBitEqvOp::pools.back());
  158774           0 :       unsigned long localIndex = SgBitEqvOp::pool_size - 1;
  158775           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  158776             :          {
  158777           0 :            localIndex--;
  158778             :          }
  158779           0 :       return (localIndex + SgBitEqvOp::pool_size * (SgBitEqvOp::pools.size()-1));
  158780             :    }
  158781             : 
  158782             : //############################################################################
  158783             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  158784             :  * memory pool and initializes the data member in class SgBitEqvOpStroageClass
  158785             :  * from its counterpart of SgBitEqvOp. The return value is just for checking, 
  158786             :  * that the whole StorageClassArray is initialized!
  158787             :  */
  158788             : unsigned long
  158789           0 : SgBitEqvOp::initializeStorageClassArray( SgBitEqvOpStorageClass *storageArray )
  158790             :    {
  158791           0 :      unsigned long storageCounter = 0;
  158792           0 :      std::vector < unsigned char* > :: const_iterator block = SgBitEqvOp::pools.begin();
  158793           0 :      SgBitEqvOp* pointer = NULL;
  158794           0 :      while ( block != SgBitEqvOp::pools.end() ) {
  158795           0 :           pointer = (SgBitEqvOp*) (*block);
  158796           0 :           for ( unsigned i = 0; i < SgBitEqvOp::pool_size; ++i ) {
  158797           0 :                if ( pointer->get_freepointer() != NULL ) {
  158798           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  158799           0 :                  storageArray++;
  158800           0 :                  storageCounter++;
  158801             :                }
  158802           0 :                pointer++;
  158803             :              }
  158804           0 :            block++;
  158805             :         }
  158806           0 :      return storageCounter;
  158807             :    }
  158808             : 
  158809             : /* #line 158810 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  158810             : 
  158811             : 
  158812             : 
  158813             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  158814             : 
  158815             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  158816             : 
  158817             : //############################################################################
  158818             : /* JH (02/02/2006) Constructor of the IR node SgCommaOpExp that takes its 
  158819             :  * corresponding StorageClass as parameter
  158820             :  */
  158821          16 : SgCommaOpExp :: SgCommaOpExp ( const SgCommaOpExpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  158822             :    {
  158823             : 
  158824             : 
  158825             : /* #line 158826 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  158826             : 
  158827          16 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  158828             : 
  158829             : 
  158830             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  158831             : 
  158832             : 
  158833          16 :    }
  158834             : 
  158835             : //############################################################################
  158836             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  158837             :  * within the working AST. 
  158838             :  */
  158839          96 : SgCommaOpExp * SgCommaOpExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  158840          96 :      SgCommaOpExp* returnPointer = NULL;
  158841          96 :      if ( globalIndex != 0 )
  158842             :         {
  158843             : 
  158844             : #if FILE_IO_EXTRA_CHECK
  158845          96 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCommaOpExp ) ) <= globalIndex ) ;
  158846          96 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCommaOpExp + 1 ) ) );
  158847             : #endif
  158848          96 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCommaOpExp )  
  158849          96 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCommaOpExp );
  158850          96 :           unsigned long positionInPool = localIndex % SgCommaOpExp::pool_size;
  158851          96 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCommaOpExp::pool_size;
  158852             : 
  158853             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  158854             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  158855             : 
  158856          96 :           returnPointer = &( ( (SgCommaOpExp*)(SgCommaOpExp::pools[memoryBlock]) ) [positionInPool]) ;
  158857             : 
  158858          96 :           ROSE_ASSERT( returnPointer != NULL ) ;
  158859             :         }
  158860          96 :      return returnPointer ;
  158861             :    }
  158862             : 
  158863             : //############################################################################
  158864             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  158865             :   for the AST with the index astIndex
  158866             : */
  158867           0 : SgCommaOpExp * SgCommaOpExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  158868           0 :      SgCommaOpExp* returnPointer = NULL;
  158869           0 :      if ( globalIndex != 0 )
  158870             :         {
  158871             : 
  158872             : #if FILE_IO_EXTRA_CHECK
  158873           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCommaOpExp ) ) <= globalIndex ) ;
  158874           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCommaOpExp + 1 ) ) );
  158875             : #endif
  158876           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCommaOpExp )
  158877           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCommaOpExp );
  158878           0 :           unsigned long positionInPool = localIndex % SgCommaOpExp::pool_size ;
  158879           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCommaOpExp::pool_size ;
  158880             : 
  158881             : #if FILE_IO_EXTRA_CHECK
  158882             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  158883             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  158884             : #endif
  158885             : 
  158886           0 :           returnPointer = &( ( (SgCommaOpExp*)(SgCommaOpExp::pools[memoryBlock]) ) [positionInPool]) ;
  158887             : 
  158888             : #if FILE_IO_EXTRA_CHECK
  158889           0 :           assert ( returnPointer != NULL ) ;
  158890             : #endif
  158891             :         }
  158892           0 :      return returnPointer ;
  158893             :    }
  158894             : 
  158895             : //############################################################################
  158896             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  158897             :  * pool size! We set for every valid object in the memory pool the freepointer
  158898             :  * to the global index and increase the global index afterwards. For all the 
  158899             :  * invalid objects (means address ranges within the memory pool that were not
  158900             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  158901             :  * distinguish valid from invalid objects! 
  158902             :  */
  158903             : unsigned long
  158904           5 : SgCommaOpExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  158905             :    {
  158906           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  158907           5 :      SgCommaOpExp* pointer = NULL;
  158908           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  158909           5 :      std::vector < unsigned char* > :: const_iterator block;
  158910           6 :      for ( block = SgCommaOpExp::pools.begin(); block != SgCommaOpExp::pools.end() ; ++block )
  158911             :         {
  158912           1 :           pointer = (SgCommaOpExp*)(*block);
  158913        2001 :           for (unsigned i = 0; i < SgCommaOpExp::pool_size; ++i )
  158914             :              {
  158915             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  158916             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  158917             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  158918             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  158919             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  158920             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  158921             :             // properly; so this will have to be checked next.
  158922             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  158923             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  158924        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  158925             :                   {
  158926          16 :                     pointer[i].set_freepointer((SgCommaOpExp*)(globalIndex));
  158927          16 :                     globalIndex++;
  158928             :                   }
  158929             :                else
  158930             :                   {
  158931        1984 :                     pointer[i].set_freepointer(NULL);
  158932             :                   }
  158933             :               }
  158934             :         }
  158935           5 :      return globalIndex;
  158936             :    }
  158937             : 
  158938             : //############################################################################
  158939             : // JH (01/14/2006)
  158940             : void
  158941           5 : SgCommaOpExp::resetValidFreepointers( )
  158942             :    {
  158943           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  158944           5 :      SgCommaOpExp* pointer = NULL;
  158945           5 :      std::vector < unsigned char* > :: const_iterator block;
  158946           5 :      SgCommaOpExp* pointerOfLinkedList = NULL;
  158947           6 :      for ( block = SgCommaOpExp::pools.begin(); block != SgCommaOpExp::pools.end() ; ++block )
  158948             :         {
  158949           1 :           pointer = (SgCommaOpExp*)(*block);
  158950        2001 :           for (unsigned i = 0; i < SgCommaOpExp::pool_size; ++i )
  158951             :              {
  158952             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  158953             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  158954             :             // memory blocks!.
  158955        2000 :                if ( pointer[i].get_freepointer() != NULL )
  158956             :                   {
  158957          16 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  158958             :                   }
  158959             :                else
  158960             :                   {
  158961        1984 :                     if ( pointerOfLinkedList == NULL )
  158962             :                        {
  158963           1 :                          SgCommaOpExp::next_node = &(pointer[i]);
  158964             :                        }
  158965             :                     else
  158966             :                        {
  158967             :                       // printf ("In SgCommaOpExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  158968        1983 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  158969             :                        }
  158970             :                     pointerOfLinkedList = &(pointer[i]);
  158971             :                   }
  158972             :               }
  158973             :         }
  158974             : 
  158975           5 :      if ( pointerOfLinkedList != NULL )
  158976             :         {
  158977             :        // printf ("In SgCommaOpExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  158978           1 :           pointerOfLinkedList->set_freepointer(NULL);
  158979             :        // DQ (6/6/2010): Temporary debugging...
  158980             :        //   ROSE_ASSERT(false);
  158981             :         }
  158982             : 
  158983           5 :      return ;
  158984             :    }
  158985             : 
  158986             : //############################################################################
  158987             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  158988             :  * within the memory pool and resets the freepointers, in order to achieve a 
  158989             :  * linked list, that has no jumps and starts at the beginning! This function 
  158990             :  * does not extend the memory pool, since we do not delete any memory blocks,
  158991             :  * but delete the valid objects.  
  158992             :  */
  158993             : void
  158994           0 : SgCommaOpExp::clearMemoryPool( )
  158995             :    {
  158996             :   // printf ("Inside of SgCommaOpExp::clearMemoryPool() \n");
  158997             : 
  158998           0 :      SgCommaOpExp* pointer = NULL, *tempPointer = NULL;
  158999           0 :      std::vector < unsigned char* > :: const_iterator block;
  159000           0 :      if ( SgCommaOpExp::pools.empty() == false )
  159001             :         {
  159002           0 :           block = SgCommaOpExp::pools.begin() ;
  159003           0 :           SgCommaOpExp::next_node = (SgCommaOpExp*) (*block);
  159004             : 
  159005           0 :           while ( block != SgCommaOpExp::pools.end() )
  159006             :              {
  159007           0 :                pointer = (SgCommaOpExp*) (*block);
  159008           0 :                if ( tempPointer != NULL )
  159009             :                   {
  159010           0 :                     tempPointer->set_freepointer(pointer);
  159011             :                   }
  159012           0 :                for (unsigned i = 0; i < SgCommaOpExp::pool_size - 1; ++i)
  159013             :                   {
  159014           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  159015             :                   }
  159016           0 :                 pointer[SgCommaOpExp::pool_size-1].set_freepointer(NULL);
  159017           0 :                 tempPointer = &(pointer[SgCommaOpExp::pool_size-1]);
  159018           0 :                 ++block;
  159019             :              }
  159020             :         }
  159021           0 :    }
  159022             : 
  159023           5 : void SgCommaOpExp::deleteMemoryPool() {
  159024           7 :   for (auto p: SgCommaOpExp::pools) {
  159025           2 :     ROSE_FREE(p);
  159026             :   }
  159027           5 :   SgCommaOpExp::next_node = nullptr;
  159028           5 :   SgCommaOpExp::pools.clear();
  159029           5 : }
  159030             : 
  159031             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  159032             : //                 reading multiple binary files to for a single AST.
  159033             : /////////// new version ////////////////////////////////
  159034             : //############################################################################
  159035             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  159036             : void
  159037           2 : SgCommaOpExp::extendMemoryPoolForFileIO( )
  159038             :   {
  159039           2 :     size_t blockIndex = SgCommaOpExp::pools.size();
  159040           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCommaOpExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommaOpExp);
  159041             : 
  159042           3 :     while ( (blockIndex * SgCommaOpExp::pool_size) < newPoolSize)
  159043             :       {
  159044             : #if ROSE_ALLOC_TRACE
  159045             :         if (blockIndex > 0) {
  159046             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCommaOpExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommaOpExp) = %" PRIuPTR " SgCommaOpExp::pool_size = %d \n",
  159047             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCommaOpExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommaOpExp),SgCommaOpExp::pool_size);
  159048             :         }
  159049             : #endif
  159050             : 
  159051           1 :         SgCommaOpExp * pointer = (SgCommaOpExp*) ROSE_MALLOC ( SgCommaOpExp::pool_size * sizeof(SgCommaOpExp) );
  159052           1 :         assert( pointer != NULL );
  159053             : #if ROSE_ALLOC_MEMSET == 1
  159054             :         memset(pointer, 0x00, SgCommaOpExp::pool_size * sizeof(SgCommaOpExp));
  159055             : #elif ROSE_ALLOC_MEMSET == 2
  159056             :         memset(pointer, 0xCC, SgCommaOpExp::pool_size * sizeof(SgCommaOpExp));
  159057             : #endif
  159058           1 :         SgCommaOpExp::pools.push_back( (unsigned char*)(pointer) );
  159059           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCommaOpExp::pool_size * sizeof(SgCommaOpExp), V_SgCommaOpExp ) );
  159060             : 
  159061           1 :         if ( SgCommaOpExp::next_node != NULL ) {
  159062           0 :           if ( blockIndex > 0 ) {
  159063           0 :             SgCommaOpExp * blkptr = (SgCommaOpExp*)(SgCommaOpExp::pools[blockIndex-1]);
  159064           0 :             blkptr[ SgCommaOpExp::pool_size - 1 ].set_freepointer(pointer);
  159065             :           }
  159066             :         } else {
  159067           1 :           SgCommaOpExp::next_node = pointer;
  159068             :         }
  159069             : 
  159070        2000 :         for (unsigned i = 0; i < SgCommaOpExp::pool_size-1; ++i)
  159071             :            {
  159072        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  159073             :            }
  159074           1 :         pointer[ SgCommaOpExp::pool_size -1 ].set_freepointer(NULL);
  159075             : 
  159076           1 :         blockIndex++;
  159077             :       }
  159078           2 :   }
  159079             : 
  159080             : //############################################################################
  159081             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  159082             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  159083             :  * not compressed. However, that stuff is not yet implemented! 
  159084             :  */
  159085             : unsigned long
  159086           0 : SgCommaOpExp::getNumberOfLastValidPointer()
  159087             :    {
  159088           0 :       SgCommaOpExp* testPointer = (SgCommaOpExp*)(SgCommaOpExp::pools.back());
  159089           0 :       unsigned long localIndex = SgCommaOpExp::pool_size - 1;
  159090           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  159091             :          {
  159092           0 :            localIndex--;
  159093             :          }
  159094           0 :       return (localIndex + SgCommaOpExp::pool_size * (SgCommaOpExp::pools.size()-1));
  159095             :    }
  159096             : 
  159097             : //############################################################################
  159098             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  159099             :  * memory pool and initializes the data member in class SgCommaOpExpStroageClass
  159100             :  * from its counterpart of SgCommaOpExp. The return value is just for checking, 
  159101             :  * that the whole StorageClassArray is initialized!
  159102             :  */
  159103             : unsigned long
  159104           1 : SgCommaOpExp::initializeStorageClassArray( SgCommaOpExpStorageClass *storageArray )
  159105             :    {
  159106           1 :      unsigned long storageCounter = 0;
  159107           1 :      std::vector < unsigned char* > :: const_iterator block = SgCommaOpExp::pools.begin();
  159108           1 :      SgCommaOpExp* pointer = NULL;
  159109           2 :      while ( block != SgCommaOpExp::pools.end() ) {
  159110           1 :           pointer = (SgCommaOpExp*) (*block);
  159111        2001 :           for ( unsigned i = 0; i < SgCommaOpExp::pool_size; ++i ) {
  159112        2000 :                if ( pointer->get_freepointer() != NULL ) {
  159113          16 :                  storageArray->pickOutIRNodeData (pointer) ;
  159114          16 :                  storageArray++;
  159115          16 :                  storageCounter++;
  159116             :                }
  159117        2000 :                pointer++;
  159118             :              }
  159119           1 :            block++;
  159120             :         }
  159121           1 :      return storageCounter;
  159122             :    }
  159123             : 
  159124             : /* #line 159125 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  159125             : 
  159126             : 
  159127             : 
  159128             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  159129             : 
  159130             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  159131             : 
  159132             : //############################################################################
  159133             : /* JH (02/02/2006) Constructor of the IR node SgLshiftOp that takes its 
  159134             :  * corresponding StorageClass as parameter
  159135             :  */
  159136          27 : SgLshiftOp :: SgLshiftOp ( const SgLshiftOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  159137             :    {
  159138             : 
  159139             : 
  159140             : /* #line 159141 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  159141             : 
  159142          27 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  159143             : 
  159144             : 
  159145             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  159146             : 
  159147             : 
  159148          27 :    }
  159149             : 
  159150             : //############################################################################
  159151             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  159152             :  * within the working AST. 
  159153             :  */
  159154         162 : SgLshiftOp * SgLshiftOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  159155         162 :      SgLshiftOp* returnPointer = NULL;
  159156         162 :      if ( globalIndex != 0 )
  159157             :         {
  159158             : 
  159159             : #if FILE_IO_EXTRA_CHECK
  159160         162 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLshiftOp ) ) <= globalIndex ) ;
  159161         162 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLshiftOp + 1 ) ) );
  159162             : #endif
  159163         162 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLshiftOp )  
  159164         162 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLshiftOp );
  159165         162 :           unsigned long positionInPool = localIndex % SgLshiftOp::pool_size;
  159166         162 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLshiftOp::pool_size;
  159167             : 
  159168             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  159169             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  159170             : 
  159171         162 :           returnPointer = &( ( (SgLshiftOp*)(SgLshiftOp::pools[memoryBlock]) ) [positionInPool]) ;
  159172             : 
  159173         162 :           ROSE_ASSERT( returnPointer != NULL ) ;
  159174             :         }
  159175         162 :      return returnPointer ;
  159176             :    }
  159177             : 
  159178             : //############################################################################
  159179             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  159180             :   for the AST with the index astIndex
  159181             : */
  159182           0 : SgLshiftOp * SgLshiftOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  159183           0 :      SgLshiftOp* returnPointer = NULL;
  159184           0 :      if ( globalIndex != 0 )
  159185             :         {
  159186             : 
  159187             : #if FILE_IO_EXTRA_CHECK
  159188           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLshiftOp ) ) <= globalIndex ) ;
  159189           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLshiftOp + 1 ) ) );
  159190             : #endif
  159191           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLshiftOp )
  159192           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLshiftOp );
  159193           0 :           unsigned long positionInPool = localIndex % SgLshiftOp::pool_size ;
  159194           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLshiftOp::pool_size ;
  159195             : 
  159196             : #if FILE_IO_EXTRA_CHECK
  159197             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  159198             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  159199             : #endif
  159200             : 
  159201           0 :           returnPointer = &( ( (SgLshiftOp*)(SgLshiftOp::pools[memoryBlock]) ) [positionInPool]) ;
  159202             : 
  159203             : #if FILE_IO_EXTRA_CHECK
  159204           0 :           assert ( returnPointer != NULL ) ;
  159205             : #endif
  159206             :         }
  159207           0 :      return returnPointer ;
  159208             :    }
  159209             : 
  159210             : //############################################################################
  159211             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  159212             :  * pool size! We set for every valid object in the memory pool the freepointer
  159213             :  * to the global index and increase the global index afterwards. For all the 
  159214             :  * invalid objects (means address ranges within the memory pool that were not
  159215             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  159216             :  * distinguish valid from invalid objects! 
  159217             :  */
  159218             : unsigned long
  159219           5 : SgLshiftOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  159220             :    {
  159221           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  159222           5 :      SgLshiftOp* pointer = NULL;
  159223           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  159224           5 :      std::vector < unsigned char* > :: const_iterator block;
  159225           6 :      for ( block = SgLshiftOp::pools.begin(); block != SgLshiftOp::pools.end() ; ++block )
  159226             :         {
  159227           1 :           pointer = (SgLshiftOp*)(*block);
  159228        2001 :           for (unsigned i = 0; i < SgLshiftOp::pool_size; ++i )
  159229             :              {
  159230             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  159231             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  159232             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  159233             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  159234             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  159235             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  159236             :             // properly; so this will have to be checked next.
  159237             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  159238             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  159239        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  159240             :                   {
  159241          27 :                     pointer[i].set_freepointer((SgLshiftOp*)(globalIndex));
  159242          27 :                     globalIndex++;
  159243             :                   }
  159244             :                else
  159245             :                   {
  159246        1973 :                     pointer[i].set_freepointer(NULL);
  159247             :                   }
  159248             :               }
  159249             :         }
  159250           5 :      return globalIndex;
  159251             :    }
  159252             : 
  159253             : //############################################################################
  159254             : // JH (01/14/2006)
  159255             : void
  159256           5 : SgLshiftOp::resetValidFreepointers( )
  159257             :    {
  159258           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  159259           5 :      SgLshiftOp* pointer = NULL;
  159260           5 :      std::vector < unsigned char* > :: const_iterator block;
  159261           5 :      SgLshiftOp* pointerOfLinkedList = NULL;
  159262           6 :      for ( block = SgLshiftOp::pools.begin(); block != SgLshiftOp::pools.end() ; ++block )
  159263             :         {
  159264           1 :           pointer = (SgLshiftOp*)(*block);
  159265        2001 :           for (unsigned i = 0; i < SgLshiftOp::pool_size; ++i )
  159266             :              {
  159267             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  159268             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  159269             :             // memory blocks!.
  159270        2000 :                if ( pointer[i].get_freepointer() != NULL )
  159271             :                   {
  159272          27 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  159273             :                   }
  159274             :                else
  159275             :                   {
  159276        1973 :                     if ( pointerOfLinkedList == NULL )
  159277             :                        {
  159278           1 :                          SgLshiftOp::next_node = &(pointer[i]);
  159279             :                        }
  159280             :                     else
  159281             :                        {
  159282             :                       // printf ("In SgLshiftOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  159283        1972 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  159284             :                        }
  159285             :                     pointerOfLinkedList = &(pointer[i]);
  159286             :                   }
  159287             :               }
  159288             :         }
  159289             : 
  159290           5 :      if ( pointerOfLinkedList != NULL )
  159291             :         {
  159292             :        // printf ("In SgLshiftOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  159293           1 :           pointerOfLinkedList->set_freepointer(NULL);
  159294             :        // DQ (6/6/2010): Temporary debugging...
  159295             :        //   ROSE_ASSERT(false);
  159296             :         }
  159297             : 
  159298           5 :      return ;
  159299             :    }
  159300             : 
  159301             : //############################################################################
  159302             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  159303             :  * within the memory pool and resets the freepointers, in order to achieve a 
  159304             :  * linked list, that has no jumps and starts at the beginning! This function 
  159305             :  * does not extend the memory pool, since we do not delete any memory blocks,
  159306             :  * but delete the valid objects.  
  159307             :  */
  159308             : void
  159309           0 : SgLshiftOp::clearMemoryPool( )
  159310             :    {
  159311             :   // printf ("Inside of SgLshiftOp::clearMemoryPool() \n");
  159312             : 
  159313           0 :      SgLshiftOp* pointer = NULL, *tempPointer = NULL;
  159314           0 :      std::vector < unsigned char* > :: const_iterator block;
  159315           0 :      if ( SgLshiftOp::pools.empty() == false )
  159316             :         {
  159317           0 :           block = SgLshiftOp::pools.begin() ;
  159318           0 :           SgLshiftOp::next_node = (SgLshiftOp*) (*block);
  159319             : 
  159320           0 :           while ( block != SgLshiftOp::pools.end() )
  159321             :              {
  159322           0 :                pointer = (SgLshiftOp*) (*block);
  159323           0 :                if ( tempPointer != NULL )
  159324             :                   {
  159325           0 :                     tempPointer->set_freepointer(pointer);
  159326             :                   }
  159327           0 :                for (unsigned i = 0; i < SgLshiftOp::pool_size - 1; ++i)
  159328             :                   {
  159329           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  159330             :                   }
  159331           0 :                 pointer[SgLshiftOp::pool_size-1].set_freepointer(NULL);
  159332           0 :                 tempPointer = &(pointer[SgLshiftOp::pool_size-1]);
  159333           0 :                 ++block;
  159334             :              }
  159335             :         }
  159336           0 :    }
  159337             : 
  159338           5 : void SgLshiftOp::deleteMemoryPool() {
  159339           7 :   for (auto p: SgLshiftOp::pools) {
  159340           2 :     ROSE_FREE(p);
  159341             :   }
  159342           5 :   SgLshiftOp::next_node = nullptr;
  159343           5 :   SgLshiftOp::pools.clear();
  159344           5 : }
  159345             : 
  159346             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  159347             : //                 reading multiple binary files to for a single AST.
  159348             : /////////// new version ////////////////////////////////
  159349             : //############################################################################
  159350             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  159351             : void
  159352           2 : SgLshiftOp::extendMemoryPoolForFileIO( )
  159353             :   {
  159354           2 :     size_t blockIndex = SgLshiftOp::pools.size();
  159355           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLshiftOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLshiftOp);
  159356             : 
  159357           3 :     while ( (blockIndex * SgLshiftOp::pool_size) < newPoolSize)
  159358             :       {
  159359             : #if ROSE_ALLOC_TRACE
  159360             :         if (blockIndex > 0) {
  159361             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLshiftOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLshiftOp) = %" PRIuPTR " SgLshiftOp::pool_size = %d \n",
  159362             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLshiftOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLshiftOp),SgLshiftOp::pool_size);
  159363             :         }
  159364             : #endif
  159365             : 
  159366           1 :         SgLshiftOp * pointer = (SgLshiftOp*) ROSE_MALLOC ( SgLshiftOp::pool_size * sizeof(SgLshiftOp) );
  159367           1 :         assert( pointer != NULL );
  159368             : #if ROSE_ALLOC_MEMSET == 1
  159369             :         memset(pointer, 0x00, SgLshiftOp::pool_size * sizeof(SgLshiftOp));
  159370             : #elif ROSE_ALLOC_MEMSET == 2
  159371             :         memset(pointer, 0xCC, SgLshiftOp::pool_size * sizeof(SgLshiftOp));
  159372             : #endif
  159373           1 :         SgLshiftOp::pools.push_back( (unsigned char*)(pointer) );
  159374           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLshiftOp::pool_size * sizeof(SgLshiftOp), V_SgLshiftOp ) );
  159375             : 
  159376           1 :         if ( SgLshiftOp::next_node != NULL ) {
  159377           0 :           if ( blockIndex > 0 ) {
  159378           0 :             SgLshiftOp * blkptr = (SgLshiftOp*)(SgLshiftOp::pools[blockIndex-1]);
  159379           0 :             blkptr[ SgLshiftOp::pool_size - 1 ].set_freepointer(pointer);
  159380             :           }
  159381             :         } else {
  159382           1 :           SgLshiftOp::next_node = pointer;
  159383             :         }
  159384             : 
  159385        2000 :         for (unsigned i = 0; i < SgLshiftOp::pool_size-1; ++i)
  159386             :            {
  159387        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  159388             :            }
  159389           1 :         pointer[ SgLshiftOp::pool_size -1 ].set_freepointer(NULL);
  159390             : 
  159391           1 :         blockIndex++;
  159392             :       }
  159393           2 :   }
  159394             : 
  159395             : //############################################################################
  159396             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  159397             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  159398             :  * not compressed. However, that stuff is not yet implemented! 
  159399             :  */
  159400             : unsigned long
  159401           0 : SgLshiftOp::getNumberOfLastValidPointer()
  159402             :    {
  159403           0 :       SgLshiftOp* testPointer = (SgLshiftOp*)(SgLshiftOp::pools.back());
  159404           0 :       unsigned long localIndex = SgLshiftOp::pool_size - 1;
  159405           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  159406             :          {
  159407           0 :            localIndex--;
  159408             :          }
  159409           0 :       return (localIndex + SgLshiftOp::pool_size * (SgLshiftOp::pools.size()-1));
  159410             :    }
  159411             : 
  159412             : //############################################################################
  159413             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  159414             :  * memory pool and initializes the data member in class SgLshiftOpStroageClass
  159415             :  * from its counterpart of SgLshiftOp. The return value is just for checking, 
  159416             :  * that the whole StorageClassArray is initialized!
  159417             :  */
  159418             : unsigned long
  159419           1 : SgLshiftOp::initializeStorageClassArray( SgLshiftOpStorageClass *storageArray )
  159420             :    {
  159421           1 :      unsigned long storageCounter = 0;
  159422           1 :      std::vector < unsigned char* > :: const_iterator block = SgLshiftOp::pools.begin();
  159423           1 :      SgLshiftOp* pointer = NULL;
  159424           2 :      while ( block != SgLshiftOp::pools.end() ) {
  159425           1 :           pointer = (SgLshiftOp*) (*block);
  159426        2001 :           for ( unsigned i = 0; i < SgLshiftOp::pool_size; ++i ) {
  159427        2000 :                if ( pointer->get_freepointer() != NULL ) {
  159428          27 :                  storageArray->pickOutIRNodeData (pointer) ;
  159429          27 :                  storageArray++;
  159430          27 :                  storageCounter++;
  159431             :                }
  159432        2000 :                pointer++;
  159433             :              }
  159434           1 :            block++;
  159435             :         }
  159436           1 :      return storageCounter;
  159437             :    }
  159438             : 
  159439             : /* #line 159440 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  159440             : 
  159441             : 
  159442             : 
  159443             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  159444             : 
  159445             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  159446             : 
  159447             : //############################################################################
  159448             : /* JH (02/02/2006) Constructor of the IR node SgRshiftOp that takes its 
  159449             :  * corresponding StorageClass as parameter
  159450             :  */
  159451           8 : SgRshiftOp :: SgRshiftOp ( const SgRshiftOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  159452             :    {
  159453             : 
  159454             : 
  159455             : /* #line 159456 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  159456             : 
  159457           8 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  159458             : 
  159459             : 
  159460             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  159461             : 
  159462             : 
  159463           8 :    }
  159464             : 
  159465             : //############################################################################
  159466             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  159467             :  * within the working AST. 
  159468             :  */
  159469          48 : SgRshiftOp * SgRshiftOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  159470          48 :      SgRshiftOp* returnPointer = NULL;
  159471          48 :      if ( globalIndex != 0 )
  159472             :         {
  159473             : 
  159474             : #if FILE_IO_EXTRA_CHECK
  159475          48 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRshiftOp ) ) <= globalIndex ) ;
  159476          48 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRshiftOp + 1 ) ) );
  159477             : #endif
  159478          48 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRshiftOp )  
  159479          48 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRshiftOp );
  159480          48 :           unsigned long positionInPool = localIndex % SgRshiftOp::pool_size;
  159481          48 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRshiftOp::pool_size;
  159482             : 
  159483             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  159484             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  159485             : 
  159486          48 :           returnPointer = &( ( (SgRshiftOp*)(SgRshiftOp::pools[memoryBlock]) ) [positionInPool]) ;
  159487             : 
  159488          48 :           ROSE_ASSERT( returnPointer != NULL ) ;
  159489             :         }
  159490          48 :      return returnPointer ;
  159491             :    }
  159492             : 
  159493             : //############################################################################
  159494             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  159495             :   for the AST with the index astIndex
  159496             : */
  159497           0 : SgRshiftOp * SgRshiftOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  159498           0 :      SgRshiftOp* returnPointer = NULL;
  159499           0 :      if ( globalIndex != 0 )
  159500             :         {
  159501             : 
  159502             : #if FILE_IO_EXTRA_CHECK
  159503           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRshiftOp ) ) <= globalIndex ) ;
  159504           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRshiftOp + 1 ) ) );
  159505             : #endif
  159506           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRshiftOp )
  159507           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRshiftOp );
  159508           0 :           unsigned long positionInPool = localIndex % SgRshiftOp::pool_size ;
  159509           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRshiftOp::pool_size ;
  159510             : 
  159511             : #if FILE_IO_EXTRA_CHECK
  159512             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  159513             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  159514             : #endif
  159515             : 
  159516           0 :           returnPointer = &( ( (SgRshiftOp*)(SgRshiftOp::pools[memoryBlock]) ) [positionInPool]) ;
  159517             : 
  159518             : #if FILE_IO_EXTRA_CHECK
  159519           0 :           assert ( returnPointer != NULL ) ;
  159520             : #endif
  159521             :         }
  159522           0 :      return returnPointer ;
  159523             :    }
  159524             : 
  159525             : //############################################################################
  159526             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  159527             :  * pool size! We set for every valid object in the memory pool the freepointer
  159528             :  * to the global index and increase the global index afterwards. For all the 
  159529             :  * invalid objects (means address ranges within the memory pool that were not
  159530             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  159531             :  * distinguish valid from invalid objects! 
  159532             :  */
  159533             : unsigned long
  159534           5 : SgRshiftOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  159535             :    {
  159536           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  159537           5 :      SgRshiftOp* pointer = NULL;
  159538           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  159539           5 :      std::vector < unsigned char* > :: const_iterator block;
  159540           6 :      for ( block = SgRshiftOp::pools.begin(); block != SgRshiftOp::pools.end() ; ++block )
  159541             :         {
  159542           1 :           pointer = (SgRshiftOp*)(*block);
  159543        2001 :           for (unsigned i = 0; i < SgRshiftOp::pool_size; ++i )
  159544             :              {
  159545             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  159546             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  159547             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  159548             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  159549             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  159550             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  159551             :             // properly; so this will have to be checked next.
  159552             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  159553             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  159554        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  159555             :                   {
  159556           8 :                     pointer[i].set_freepointer((SgRshiftOp*)(globalIndex));
  159557           8 :                     globalIndex++;
  159558             :                   }
  159559             :                else
  159560             :                   {
  159561        1992 :                     pointer[i].set_freepointer(NULL);
  159562             :                   }
  159563             :               }
  159564             :         }
  159565           5 :      return globalIndex;
  159566             :    }
  159567             : 
  159568             : //############################################################################
  159569             : // JH (01/14/2006)
  159570             : void
  159571           5 : SgRshiftOp::resetValidFreepointers( )
  159572             :    {
  159573           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  159574           5 :      SgRshiftOp* pointer = NULL;
  159575           5 :      std::vector < unsigned char* > :: const_iterator block;
  159576           5 :      SgRshiftOp* pointerOfLinkedList = NULL;
  159577           6 :      for ( block = SgRshiftOp::pools.begin(); block != SgRshiftOp::pools.end() ; ++block )
  159578             :         {
  159579           1 :           pointer = (SgRshiftOp*)(*block);
  159580        2001 :           for (unsigned i = 0; i < SgRshiftOp::pool_size; ++i )
  159581             :              {
  159582             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  159583             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  159584             :             // memory blocks!.
  159585        2000 :                if ( pointer[i].get_freepointer() != NULL )
  159586             :                   {
  159587           8 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  159588             :                   }
  159589             :                else
  159590             :                   {
  159591        1992 :                     if ( pointerOfLinkedList == NULL )
  159592             :                        {
  159593           1 :                          SgRshiftOp::next_node = &(pointer[i]);
  159594             :                        }
  159595             :                     else
  159596             :                        {
  159597             :                       // printf ("In SgRshiftOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  159598        1991 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  159599             :                        }
  159600             :                     pointerOfLinkedList = &(pointer[i]);
  159601             :                   }
  159602             :               }
  159603             :         }
  159604             : 
  159605           5 :      if ( pointerOfLinkedList != NULL )
  159606             :         {
  159607             :        // printf ("In SgRshiftOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  159608           1 :           pointerOfLinkedList->set_freepointer(NULL);
  159609             :        // DQ (6/6/2010): Temporary debugging...
  159610             :        //   ROSE_ASSERT(false);
  159611             :         }
  159612             : 
  159613           5 :      return ;
  159614             :    }
  159615             : 
  159616             : //############################################################################
  159617             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  159618             :  * within the memory pool and resets the freepointers, in order to achieve a 
  159619             :  * linked list, that has no jumps and starts at the beginning! This function 
  159620             :  * does not extend the memory pool, since we do not delete any memory blocks,
  159621             :  * but delete the valid objects.  
  159622             :  */
  159623             : void
  159624           0 : SgRshiftOp::clearMemoryPool( )
  159625             :    {
  159626             :   // printf ("Inside of SgRshiftOp::clearMemoryPool() \n");
  159627             : 
  159628           0 :      SgRshiftOp* pointer = NULL, *tempPointer = NULL;
  159629           0 :      std::vector < unsigned char* > :: const_iterator block;
  159630           0 :      if ( SgRshiftOp::pools.empty() == false )
  159631             :         {
  159632           0 :           block = SgRshiftOp::pools.begin() ;
  159633           0 :           SgRshiftOp::next_node = (SgRshiftOp*) (*block);
  159634             : 
  159635           0 :           while ( block != SgRshiftOp::pools.end() )
  159636             :              {
  159637           0 :                pointer = (SgRshiftOp*) (*block);
  159638           0 :                if ( tempPointer != NULL )
  159639             :                   {
  159640           0 :                     tempPointer->set_freepointer(pointer);
  159641             :                   }
  159642           0 :                for (unsigned i = 0; i < SgRshiftOp::pool_size - 1; ++i)
  159643             :                   {
  159644           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  159645             :                   }
  159646           0 :                 pointer[SgRshiftOp::pool_size-1].set_freepointer(NULL);
  159647           0 :                 tempPointer = &(pointer[SgRshiftOp::pool_size-1]);
  159648           0 :                 ++block;
  159649             :              }
  159650             :         }
  159651           0 :    }
  159652             : 
  159653           5 : void SgRshiftOp::deleteMemoryPool() {
  159654           7 :   for (auto p: SgRshiftOp::pools) {
  159655           2 :     ROSE_FREE(p);
  159656             :   }
  159657           5 :   SgRshiftOp::next_node = nullptr;
  159658           5 :   SgRshiftOp::pools.clear();
  159659           5 : }
  159660             : 
  159661             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  159662             : //                 reading multiple binary files to for a single AST.
  159663             : /////////// new version ////////////////////////////////
  159664             : //############################################################################
  159665             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  159666             : void
  159667           2 : SgRshiftOp::extendMemoryPoolForFileIO( )
  159668             :   {
  159669           2 :     size_t blockIndex = SgRshiftOp::pools.size();
  159670           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRshiftOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRshiftOp);
  159671             : 
  159672           3 :     while ( (blockIndex * SgRshiftOp::pool_size) < newPoolSize)
  159673             :       {
  159674             : #if ROSE_ALLOC_TRACE
  159675             :         if (blockIndex > 0) {
  159676             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRshiftOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRshiftOp) = %" PRIuPTR " SgRshiftOp::pool_size = %d \n",
  159677             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRshiftOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRshiftOp),SgRshiftOp::pool_size);
  159678             :         }
  159679             : #endif
  159680             : 
  159681           1 :         SgRshiftOp * pointer = (SgRshiftOp*) ROSE_MALLOC ( SgRshiftOp::pool_size * sizeof(SgRshiftOp) );
  159682           1 :         assert( pointer != NULL );
  159683             : #if ROSE_ALLOC_MEMSET == 1
  159684             :         memset(pointer, 0x00, SgRshiftOp::pool_size * sizeof(SgRshiftOp));
  159685             : #elif ROSE_ALLOC_MEMSET == 2
  159686             :         memset(pointer, 0xCC, SgRshiftOp::pool_size * sizeof(SgRshiftOp));
  159687             : #endif
  159688           1 :         SgRshiftOp::pools.push_back( (unsigned char*)(pointer) );
  159689           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRshiftOp::pool_size * sizeof(SgRshiftOp), V_SgRshiftOp ) );
  159690             : 
  159691           1 :         if ( SgRshiftOp::next_node != NULL ) {
  159692           0 :           if ( blockIndex > 0 ) {
  159693           0 :             SgRshiftOp * blkptr = (SgRshiftOp*)(SgRshiftOp::pools[blockIndex-1]);
  159694           0 :             blkptr[ SgRshiftOp::pool_size - 1 ].set_freepointer(pointer);
  159695             :           }
  159696             :         } else {
  159697           1 :           SgRshiftOp::next_node = pointer;
  159698             :         }
  159699             : 
  159700        2000 :         for (unsigned i = 0; i < SgRshiftOp::pool_size-1; ++i)
  159701             :            {
  159702        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  159703             :            }
  159704           1 :         pointer[ SgRshiftOp::pool_size -1 ].set_freepointer(NULL);
  159705             : 
  159706           1 :         blockIndex++;
  159707             :       }
  159708           2 :   }
  159709             : 
  159710             : //############################################################################
  159711             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  159712             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  159713             :  * not compressed. However, that stuff is not yet implemented! 
  159714             :  */
  159715             : unsigned long
  159716           0 : SgRshiftOp::getNumberOfLastValidPointer()
  159717             :    {
  159718           0 :       SgRshiftOp* testPointer = (SgRshiftOp*)(SgRshiftOp::pools.back());
  159719           0 :       unsigned long localIndex = SgRshiftOp::pool_size - 1;
  159720           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  159721             :          {
  159722           0 :            localIndex--;
  159723             :          }
  159724           0 :       return (localIndex + SgRshiftOp::pool_size * (SgRshiftOp::pools.size()-1));
  159725             :    }
  159726             : 
  159727             : //############################################################################
  159728             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  159729             :  * memory pool and initializes the data member in class SgRshiftOpStroageClass
  159730             :  * from its counterpart of SgRshiftOp. The return value is just for checking, 
  159731             :  * that the whole StorageClassArray is initialized!
  159732             :  */
  159733             : unsigned long
  159734           1 : SgRshiftOp::initializeStorageClassArray( SgRshiftOpStorageClass *storageArray )
  159735             :    {
  159736           1 :      unsigned long storageCounter = 0;
  159737           1 :      std::vector < unsigned char* > :: const_iterator block = SgRshiftOp::pools.begin();
  159738           1 :      SgRshiftOp* pointer = NULL;
  159739           2 :      while ( block != SgRshiftOp::pools.end() ) {
  159740           1 :           pointer = (SgRshiftOp*) (*block);
  159741        2001 :           for ( unsigned i = 0; i < SgRshiftOp::pool_size; ++i ) {
  159742        2000 :                if ( pointer->get_freepointer() != NULL ) {
  159743           8 :                  storageArray->pickOutIRNodeData (pointer) ;
  159744           8 :                  storageArray++;
  159745           8 :                  storageCounter++;
  159746             :                }
  159747        2000 :                pointer++;
  159748             :              }
  159749           1 :            block++;
  159750             :         }
  159751           1 :      return storageCounter;
  159752             :    }
  159753             : 
  159754             : /* #line 159755 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  159755             : 
  159756             : 
  159757             : 
  159758             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  159759             : 
  159760             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  159761             : 
  159762             : //############################################################################
  159763             : /* JH (02/02/2006) Constructor of the IR node SgPntrArrRefExp that takes its 
  159764             :  * corresponding StorageClass as parameter
  159765             :  */
  159766         126 : SgPntrArrRefExp :: SgPntrArrRefExp ( const SgPntrArrRefExpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  159767             :    {
  159768             : 
  159769             : 
  159770             : /* #line 159771 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  159771             : 
  159772         126 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  159773             : 
  159774             : 
  159775             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  159776             : 
  159777             : 
  159778         126 :    }
  159779             : 
  159780             : //############################################################################
  159781             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  159782             :  * within the working AST. 
  159783             :  */
  159784         756 : SgPntrArrRefExp * SgPntrArrRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  159785         756 :      SgPntrArrRefExp* returnPointer = NULL;
  159786         756 :      if ( globalIndex != 0 )
  159787             :         {
  159788             : 
  159789             : #if FILE_IO_EXTRA_CHECK
  159790         756 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPntrArrRefExp ) ) <= globalIndex ) ;
  159791         756 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPntrArrRefExp + 1 ) ) );
  159792             : #endif
  159793         756 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPntrArrRefExp )  
  159794         756 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPntrArrRefExp );
  159795         756 :           unsigned long positionInPool = localIndex % SgPntrArrRefExp::pool_size;
  159796         756 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPntrArrRefExp::pool_size;
  159797             : 
  159798             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  159799             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  159800             : 
  159801         756 :           returnPointer = &( ( (SgPntrArrRefExp*)(SgPntrArrRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  159802             : 
  159803         756 :           ROSE_ASSERT( returnPointer != NULL ) ;
  159804             :         }
  159805         756 :      return returnPointer ;
  159806             :    }
  159807             : 
  159808             : //############################################################################
  159809             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  159810             :   for the AST with the index astIndex
  159811             : */
  159812           0 : SgPntrArrRefExp * SgPntrArrRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  159813           0 :      SgPntrArrRefExp* returnPointer = NULL;
  159814           0 :      if ( globalIndex != 0 )
  159815             :         {
  159816             : 
  159817             : #if FILE_IO_EXTRA_CHECK
  159818           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPntrArrRefExp ) ) <= globalIndex ) ;
  159819           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPntrArrRefExp + 1 ) ) );
  159820             : #endif
  159821           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPntrArrRefExp )
  159822           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPntrArrRefExp );
  159823           0 :           unsigned long positionInPool = localIndex % SgPntrArrRefExp::pool_size ;
  159824           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPntrArrRefExp::pool_size ;
  159825             : 
  159826             : #if FILE_IO_EXTRA_CHECK
  159827             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  159828             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  159829             : #endif
  159830             : 
  159831           0 :           returnPointer = &( ( (SgPntrArrRefExp*)(SgPntrArrRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  159832             : 
  159833             : #if FILE_IO_EXTRA_CHECK
  159834           0 :           assert ( returnPointer != NULL ) ;
  159835             : #endif
  159836             :         }
  159837           0 :      return returnPointer ;
  159838             :    }
  159839             : 
  159840             : //############################################################################
  159841             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  159842             :  * pool size! We set for every valid object in the memory pool the freepointer
  159843             :  * to the global index and increase the global index afterwards. For all the 
  159844             :  * invalid objects (means address ranges within the memory pool that were not
  159845             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  159846             :  * distinguish valid from invalid objects! 
  159847             :  */
  159848             : unsigned long
  159849           5 : SgPntrArrRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  159850             :    {
  159851           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  159852           5 :      SgPntrArrRefExp* pointer = NULL;
  159853           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  159854           5 :      std::vector < unsigned char* > :: const_iterator block;
  159855           6 :      for ( block = SgPntrArrRefExp::pools.begin(); block != SgPntrArrRefExp::pools.end() ; ++block )
  159856             :         {
  159857           1 :           pointer = (SgPntrArrRefExp*)(*block);
  159858        2001 :           for (unsigned i = 0; i < SgPntrArrRefExp::pool_size; ++i )
  159859             :              {
  159860             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  159861             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  159862             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  159863             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  159864             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  159865             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  159866             :             // properly; so this will have to be checked next.
  159867             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  159868             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  159869        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  159870             :                   {
  159871         126 :                     pointer[i].set_freepointer((SgPntrArrRefExp*)(globalIndex));
  159872         126 :                     globalIndex++;
  159873             :                   }
  159874             :                else
  159875             :                   {
  159876        1874 :                     pointer[i].set_freepointer(NULL);
  159877             :                   }
  159878             :               }
  159879             :         }
  159880           5 :      return globalIndex;
  159881             :    }
  159882             : 
  159883             : //############################################################################
  159884             : // JH (01/14/2006)
  159885             : void
  159886           5 : SgPntrArrRefExp::resetValidFreepointers( )
  159887             :    {
  159888           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  159889           5 :      SgPntrArrRefExp* pointer = NULL;
  159890           5 :      std::vector < unsigned char* > :: const_iterator block;
  159891           5 :      SgPntrArrRefExp* pointerOfLinkedList = NULL;
  159892           6 :      for ( block = SgPntrArrRefExp::pools.begin(); block != SgPntrArrRefExp::pools.end() ; ++block )
  159893             :         {
  159894           1 :           pointer = (SgPntrArrRefExp*)(*block);
  159895        2001 :           for (unsigned i = 0; i < SgPntrArrRefExp::pool_size; ++i )
  159896             :              {
  159897             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  159898             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  159899             :             // memory blocks!.
  159900        2000 :                if ( pointer[i].get_freepointer() != NULL )
  159901             :                   {
  159902         126 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  159903             :                   }
  159904             :                else
  159905             :                   {
  159906        1874 :                     if ( pointerOfLinkedList == NULL )
  159907             :                        {
  159908           1 :                          SgPntrArrRefExp::next_node = &(pointer[i]);
  159909             :                        }
  159910             :                     else
  159911             :                        {
  159912             :                       // printf ("In SgPntrArrRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  159913        1873 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  159914             :                        }
  159915             :                     pointerOfLinkedList = &(pointer[i]);
  159916             :                   }
  159917             :               }
  159918             :         }
  159919             : 
  159920           5 :      if ( pointerOfLinkedList != NULL )
  159921             :         {
  159922             :        // printf ("In SgPntrArrRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  159923           1 :           pointerOfLinkedList->set_freepointer(NULL);
  159924             :        // DQ (6/6/2010): Temporary debugging...
  159925             :        //   ROSE_ASSERT(false);
  159926             :         }
  159927             : 
  159928           5 :      return ;
  159929             :    }
  159930             : 
  159931             : //############################################################################
  159932             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  159933             :  * within the memory pool and resets the freepointers, in order to achieve a 
  159934             :  * linked list, that has no jumps and starts at the beginning! This function 
  159935             :  * does not extend the memory pool, since we do not delete any memory blocks,
  159936             :  * but delete the valid objects.  
  159937             :  */
  159938             : void
  159939           0 : SgPntrArrRefExp::clearMemoryPool( )
  159940             :    {
  159941             :   // printf ("Inside of SgPntrArrRefExp::clearMemoryPool() \n");
  159942             : 
  159943           0 :      SgPntrArrRefExp* pointer = NULL, *tempPointer = NULL;
  159944           0 :      std::vector < unsigned char* > :: const_iterator block;
  159945           0 :      if ( SgPntrArrRefExp::pools.empty() == false )
  159946             :         {
  159947           0 :           block = SgPntrArrRefExp::pools.begin() ;
  159948           0 :           SgPntrArrRefExp::next_node = (SgPntrArrRefExp*) (*block);
  159949             : 
  159950           0 :           while ( block != SgPntrArrRefExp::pools.end() )
  159951             :              {
  159952           0 :                pointer = (SgPntrArrRefExp*) (*block);
  159953           0 :                if ( tempPointer != NULL )
  159954             :                   {
  159955           0 :                     tempPointer->set_freepointer(pointer);
  159956             :                   }
  159957           0 :                for (unsigned i = 0; i < SgPntrArrRefExp::pool_size - 1; ++i)
  159958             :                   {
  159959           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  159960             :                   }
  159961           0 :                 pointer[SgPntrArrRefExp::pool_size-1].set_freepointer(NULL);
  159962           0 :                 tempPointer = &(pointer[SgPntrArrRefExp::pool_size-1]);
  159963           0 :                 ++block;
  159964             :              }
  159965             :         }
  159966           0 :    }
  159967             : 
  159968           5 : void SgPntrArrRefExp::deleteMemoryPool() {
  159969           7 :   for (auto p: SgPntrArrRefExp::pools) {
  159970           2 :     ROSE_FREE(p);
  159971             :   }
  159972           5 :   SgPntrArrRefExp::next_node = nullptr;
  159973           5 :   SgPntrArrRefExp::pools.clear();
  159974           5 : }
  159975             : 
  159976             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  159977             : //                 reading multiple binary files to for a single AST.
  159978             : /////////// new version ////////////////////////////////
  159979             : //############################################################################
  159980             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  159981             : void
  159982           2 : SgPntrArrRefExp::extendMemoryPoolForFileIO( )
  159983             :   {
  159984           2 :     size_t blockIndex = SgPntrArrRefExp::pools.size();
  159985           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPntrArrRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPntrArrRefExp);
  159986             : 
  159987           3 :     while ( (blockIndex * SgPntrArrRefExp::pool_size) < newPoolSize)
  159988             :       {
  159989             : #if ROSE_ALLOC_TRACE
  159990             :         if (blockIndex > 0) {
  159991             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPntrArrRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPntrArrRefExp) = %" PRIuPTR " SgPntrArrRefExp::pool_size = %d \n",
  159992             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPntrArrRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPntrArrRefExp),SgPntrArrRefExp::pool_size);
  159993             :         }
  159994             : #endif
  159995             : 
  159996           1 :         SgPntrArrRefExp * pointer = (SgPntrArrRefExp*) ROSE_MALLOC ( SgPntrArrRefExp::pool_size * sizeof(SgPntrArrRefExp) );
  159997           1 :         assert( pointer != NULL );
  159998             : #if ROSE_ALLOC_MEMSET == 1
  159999             :         memset(pointer, 0x00, SgPntrArrRefExp::pool_size * sizeof(SgPntrArrRefExp));
  160000             : #elif ROSE_ALLOC_MEMSET == 2
  160001             :         memset(pointer, 0xCC, SgPntrArrRefExp::pool_size * sizeof(SgPntrArrRefExp));
  160002             : #endif
  160003           1 :         SgPntrArrRefExp::pools.push_back( (unsigned char*)(pointer) );
  160004           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPntrArrRefExp::pool_size * sizeof(SgPntrArrRefExp), V_SgPntrArrRefExp ) );
  160005             : 
  160006           1 :         if ( SgPntrArrRefExp::next_node != NULL ) {
  160007           0 :           if ( blockIndex > 0 ) {
  160008           0 :             SgPntrArrRefExp * blkptr = (SgPntrArrRefExp*)(SgPntrArrRefExp::pools[blockIndex-1]);
  160009           0 :             blkptr[ SgPntrArrRefExp::pool_size - 1 ].set_freepointer(pointer);
  160010             :           }
  160011             :         } else {
  160012           1 :           SgPntrArrRefExp::next_node = pointer;
  160013             :         }
  160014             : 
  160015        2000 :         for (unsigned i = 0; i < SgPntrArrRefExp::pool_size-1; ++i)
  160016             :            {
  160017        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  160018             :            }
  160019           1 :         pointer[ SgPntrArrRefExp::pool_size -1 ].set_freepointer(NULL);
  160020             : 
  160021           1 :         blockIndex++;
  160022             :       }
  160023           2 :   }
  160024             : 
  160025             : //############################################################################
  160026             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  160027             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  160028             :  * not compressed. However, that stuff is not yet implemented! 
  160029             :  */
  160030             : unsigned long
  160031           0 : SgPntrArrRefExp::getNumberOfLastValidPointer()
  160032             :    {
  160033           0 :       SgPntrArrRefExp* testPointer = (SgPntrArrRefExp*)(SgPntrArrRefExp::pools.back());
  160034           0 :       unsigned long localIndex = SgPntrArrRefExp::pool_size - 1;
  160035           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  160036             :          {
  160037           0 :            localIndex--;
  160038             :          }
  160039           0 :       return (localIndex + SgPntrArrRefExp::pool_size * (SgPntrArrRefExp::pools.size()-1));
  160040             :    }
  160041             : 
  160042             : //############################################################################
  160043             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  160044             :  * memory pool and initializes the data member in class SgPntrArrRefExpStroageClass
  160045             :  * from its counterpart of SgPntrArrRefExp. The return value is just for checking, 
  160046             :  * that the whole StorageClassArray is initialized!
  160047             :  */
  160048             : unsigned long
  160049           1 : SgPntrArrRefExp::initializeStorageClassArray( SgPntrArrRefExpStorageClass *storageArray )
  160050             :    {
  160051           1 :      unsigned long storageCounter = 0;
  160052           1 :      std::vector < unsigned char* > :: const_iterator block = SgPntrArrRefExp::pools.begin();
  160053           1 :      SgPntrArrRefExp* pointer = NULL;
  160054           2 :      while ( block != SgPntrArrRefExp::pools.end() ) {
  160055           1 :           pointer = (SgPntrArrRefExp*) (*block);
  160056        2001 :           for ( unsigned i = 0; i < SgPntrArrRefExp::pool_size; ++i ) {
  160057        2000 :                if ( pointer->get_freepointer() != NULL ) {
  160058         126 :                  storageArray->pickOutIRNodeData (pointer) ;
  160059         126 :                  storageArray++;
  160060         126 :                  storageCounter++;
  160061             :                }
  160062        2000 :                pointer++;
  160063             :              }
  160064           1 :            block++;
  160065             :         }
  160066           1 :      return storageCounter;
  160067             :    }
  160068             : 
  160069             : /* #line 160070 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  160070             : 
  160071             : 
  160072             : 
  160073             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  160074             : 
  160075             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  160076             : 
  160077             : //############################################################################
  160078             : /* JH (02/02/2006) Constructor of the IR node SgScopeOp that takes its 
  160079             :  * corresponding StorageClass as parameter
  160080             :  */
  160081           0 : SgScopeOp :: SgScopeOp ( const SgScopeOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  160082             :    {
  160083             : 
  160084             : 
  160085             : /* #line 160086 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  160086             : 
  160087           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  160088             : 
  160089             : 
  160090             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  160091             : 
  160092             : 
  160093           0 :    }
  160094             : 
  160095             : //############################################################################
  160096             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  160097             :  * within the working AST. 
  160098             :  */
  160099           0 : SgScopeOp * SgScopeOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  160100           0 :      SgScopeOp* returnPointer = NULL;
  160101           0 :      if ( globalIndex != 0 )
  160102             :         {
  160103             : 
  160104             : #if FILE_IO_EXTRA_CHECK
  160105           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgScopeOp ) ) <= globalIndex ) ;
  160106           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgScopeOp + 1 ) ) );
  160107             : #endif
  160108           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgScopeOp )  
  160109           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgScopeOp );
  160110           0 :           unsigned long positionInPool = localIndex % SgScopeOp::pool_size;
  160111           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgScopeOp::pool_size;
  160112             : 
  160113             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  160114             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  160115             : 
  160116           0 :           returnPointer = &( ( (SgScopeOp*)(SgScopeOp::pools[memoryBlock]) ) [positionInPool]) ;
  160117             : 
  160118           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  160119             :         }
  160120           0 :      return returnPointer ;
  160121             :    }
  160122             : 
  160123             : //############################################################################
  160124             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  160125             :   for the AST with the index astIndex
  160126             : */
  160127           0 : SgScopeOp * SgScopeOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  160128           0 :      SgScopeOp* returnPointer = NULL;
  160129           0 :      if ( globalIndex != 0 )
  160130             :         {
  160131             : 
  160132             : #if FILE_IO_EXTRA_CHECK
  160133           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgScopeOp ) ) <= globalIndex ) ;
  160134           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgScopeOp + 1 ) ) );
  160135             : #endif
  160136           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgScopeOp )
  160137           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgScopeOp );
  160138           0 :           unsigned long positionInPool = localIndex % SgScopeOp::pool_size ;
  160139           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgScopeOp::pool_size ;
  160140             : 
  160141             : #if FILE_IO_EXTRA_CHECK
  160142             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  160143             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  160144             : #endif
  160145             : 
  160146           0 :           returnPointer = &( ( (SgScopeOp*)(SgScopeOp::pools[memoryBlock]) ) [positionInPool]) ;
  160147             : 
  160148             : #if FILE_IO_EXTRA_CHECK
  160149           0 :           assert ( returnPointer != NULL ) ;
  160150             : #endif
  160151             :         }
  160152           0 :      return returnPointer ;
  160153             :    }
  160154             : 
  160155             : //############################################################################
  160156             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  160157             :  * pool size! We set for every valid object in the memory pool the freepointer
  160158             :  * to the global index and increase the global index afterwards. For all the 
  160159             :  * invalid objects (means address ranges within the memory pool that were not
  160160             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  160161             :  * distinguish valid from invalid objects! 
  160162             :  */
  160163             : unsigned long
  160164           5 : SgScopeOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  160165             :    {
  160166           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  160167           5 :      SgScopeOp* pointer = NULL;
  160168           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  160169           5 :      std::vector < unsigned char* > :: const_iterator block;
  160170           5 :      for ( block = SgScopeOp::pools.begin(); block != SgScopeOp::pools.end() ; ++block )
  160171             :         {
  160172           0 :           pointer = (SgScopeOp*)(*block);
  160173           0 :           for (unsigned i = 0; i < SgScopeOp::pool_size; ++i )
  160174             :              {
  160175             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  160176             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  160177             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  160178             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  160179             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  160180             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  160181             :             // properly; so this will have to be checked next.
  160182             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  160183             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  160184           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  160185             :                   {
  160186           0 :                     pointer[i].set_freepointer((SgScopeOp*)(globalIndex));
  160187           0 :                     globalIndex++;
  160188             :                   }
  160189             :                else
  160190             :                   {
  160191           0 :                     pointer[i].set_freepointer(NULL);
  160192             :                   }
  160193             :               }
  160194             :         }
  160195           5 :      return globalIndex;
  160196             :    }
  160197             : 
  160198             : //############################################################################
  160199             : // JH (01/14/2006)
  160200             : void
  160201           5 : SgScopeOp::resetValidFreepointers( )
  160202             :    {
  160203           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  160204           5 :      SgScopeOp* pointer = NULL;
  160205           5 :      std::vector < unsigned char* > :: const_iterator block;
  160206           5 :      SgScopeOp* pointerOfLinkedList = NULL;
  160207           5 :      for ( block = SgScopeOp::pools.begin(); block != SgScopeOp::pools.end() ; ++block )
  160208             :         {
  160209           0 :           pointer = (SgScopeOp*)(*block);
  160210           0 :           for (unsigned i = 0; i < SgScopeOp::pool_size; ++i )
  160211             :              {
  160212             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  160213             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  160214             :             // memory blocks!.
  160215           0 :                if ( pointer[i].get_freepointer() != NULL )
  160216             :                   {
  160217           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  160218             :                   }
  160219             :                else
  160220             :                   {
  160221           0 :                     if ( pointerOfLinkedList == NULL )
  160222             :                        {
  160223           0 :                          SgScopeOp::next_node = &(pointer[i]);
  160224             :                        }
  160225             :                     else
  160226             :                        {
  160227             :                       // printf ("In SgScopeOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  160228           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  160229             :                        }
  160230             :                     pointerOfLinkedList = &(pointer[i]);
  160231             :                   }
  160232             :               }
  160233             :         }
  160234             : 
  160235           5 :      if ( pointerOfLinkedList != NULL )
  160236             :         {
  160237             :        // printf ("In SgScopeOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  160238           0 :           pointerOfLinkedList->set_freepointer(NULL);
  160239             :        // DQ (6/6/2010): Temporary debugging...
  160240             :        //   ROSE_ASSERT(false);
  160241             :         }
  160242             : 
  160243           5 :      return ;
  160244             :    }
  160245             : 
  160246             : //############################################################################
  160247             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  160248             :  * within the memory pool and resets the freepointers, in order to achieve a 
  160249             :  * linked list, that has no jumps and starts at the beginning! This function 
  160250             :  * does not extend the memory pool, since we do not delete any memory blocks,
  160251             :  * but delete the valid objects.  
  160252             :  */
  160253             : void
  160254           0 : SgScopeOp::clearMemoryPool( )
  160255             :    {
  160256             :   // printf ("Inside of SgScopeOp::clearMemoryPool() \n");
  160257             : 
  160258           0 :      SgScopeOp* pointer = NULL, *tempPointer = NULL;
  160259           0 :      std::vector < unsigned char* > :: const_iterator block;
  160260           0 :      if ( SgScopeOp::pools.empty() == false )
  160261             :         {
  160262           0 :           block = SgScopeOp::pools.begin() ;
  160263           0 :           SgScopeOp::next_node = (SgScopeOp*) (*block);
  160264             : 
  160265           0 :           while ( block != SgScopeOp::pools.end() )
  160266             :              {
  160267           0 :                pointer = (SgScopeOp*) (*block);
  160268           0 :                if ( tempPointer != NULL )
  160269             :                   {
  160270           0 :                     tempPointer->set_freepointer(pointer);
  160271             :                   }
  160272           0 :                for (unsigned i = 0; i < SgScopeOp::pool_size - 1; ++i)
  160273             :                   {
  160274           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  160275             :                   }
  160276           0 :                 pointer[SgScopeOp::pool_size-1].set_freepointer(NULL);
  160277           0 :                 tempPointer = &(pointer[SgScopeOp::pool_size-1]);
  160278           0 :                 ++block;
  160279             :              }
  160280             :         }
  160281           0 :    }
  160282             : 
  160283           5 : void SgScopeOp::deleteMemoryPool() {
  160284           5 :   for (auto p: SgScopeOp::pools) {
  160285           0 :     ROSE_FREE(p);
  160286             :   }
  160287           5 :   SgScopeOp::next_node = nullptr;
  160288           5 :   SgScopeOp::pools.clear();
  160289           5 : }
  160290             : 
  160291             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  160292             : //                 reading multiple binary files to for a single AST.
  160293             : /////////// new version ////////////////////////////////
  160294             : //############################################################################
  160295             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  160296             : void
  160297           2 : SgScopeOp::extendMemoryPoolForFileIO( )
  160298             :   {
  160299           2 :     size_t blockIndex = SgScopeOp::pools.size();
  160300           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgScopeOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgScopeOp);
  160301             : 
  160302           2 :     while ( (blockIndex * SgScopeOp::pool_size) < newPoolSize)
  160303             :       {
  160304             : #if ROSE_ALLOC_TRACE
  160305             :         if (blockIndex > 0) {
  160306             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgScopeOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgScopeOp) = %" PRIuPTR " SgScopeOp::pool_size = %d \n",
  160307             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgScopeOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgScopeOp),SgScopeOp::pool_size);
  160308             :         }
  160309             : #endif
  160310             : 
  160311           0 :         SgScopeOp * pointer = (SgScopeOp*) ROSE_MALLOC ( SgScopeOp::pool_size * sizeof(SgScopeOp) );
  160312           0 :         assert( pointer != NULL );
  160313             : #if ROSE_ALLOC_MEMSET == 1
  160314             :         memset(pointer, 0x00, SgScopeOp::pool_size * sizeof(SgScopeOp));
  160315             : #elif ROSE_ALLOC_MEMSET == 2
  160316             :         memset(pointer, 0xCC, SgScopeOp::pool_size * sizeof(SgScopeOp));
  160317             : #endif
  160318           0 :         SgScopeOp::pools.push_back( (unsigned char*)(pointer) );
  160319           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgScopeOp::pool_size * sizeof(SgScopeOp), V_SgScopeOp ) );
  160320             : 
  160321           0 :         if ( SgScopeOp::next_node != NULL ) {
  160322           0 :           if ( blockIndex > 0 ) {
  160323           0 :             SgScopeOp * blkptr = (SgScopeOp*)(SgScopeOp::pools[blockIndex-1]);
  160324           0 :             blkptr[ SgScopeOp::pool_size - 1 ].set_freepointer(pointer);
  160325             :           }
  160326             :         } else {
  160327           0 :           SgScopeOp::next_node = pointer;
  160328             :         }
  160329             : 
  160330           0 :         for (unsigned i = 0; i < SgScopeOp::pool_size-1; ++i)
  160331             :            {
  160332           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  160333             :            }
  160334           0 :         pointer[ SgScopeOp::pool_size -1 ].set_freepointer(NULL);
  160335             : 
  160336           0 :         blockIndex++;
  160337             :       }
  160338           2 :   }
  160339             : 
  160340             : //############################################################################
  160341             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  160342             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  160343             :  * not compressed. However, that stuff is not yet implemented! 
  160344             :  */
  160345             : unsigned long
  160346           0 : SgScopeOp::getNumberOfLastValidPointer()
  160347             :    {
  160348           0 :       SgScopeOp* testPointer = (SgScopeOp*)(SgScopeOp::pools.back());
  160349           0 :       unsigned long localIndex = SgScopeOp::pool_size - 1;
  160350           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  160351             :          {
  160352           0 :            localIndex--;
  160353             :          }
  160354           0 :       return (localIndex + SgScopeOp::pool_size * (SgScopeOp::pools.size()-1));
  160355             :    }
  160356             : 
  160357             : //############################################################################
  160358             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  160359             :  * memory pool and initializes the data member in class SgScopeOpStroageClass
  160360             :  * from its counterpart of SgScopeOp. The return value is just for checking, 
  160361             :  * that the whole StorageClassArray is initialized!
  160362             :  */
  160363             : unsigned long
  160364           0 : SgScopeOp::initializeStorageClassArray( SgScopeOpStorageClass *storageArray )
  160365             :    {
  160366           0 :      unsigned long storageCounter = 0;
  160367           0 :      std::vector < unsigned char* > :: const_iterator block = SgScopeOp::pools.begin();
  160368           0 :      SgScopeOp* pointer = NULL;
  160369           0 :      while ( block != SgScopeOp::pools.end() ) {
  160370           0 :           pointer = (SgScopeOp*) (*block);
  160371           0 :           for ( unsigned i = 0; i < SgScopeOp::pool_size; ++i ) {
  160372           0 :                if ( pointer->get_freepointer() != NULL ) {
  160373           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  160374           0 :                  storageArray++;
  160375           0 :                  storageCounter++;
  160376             :                }
  160377           0 :                pointer++;
  160378             :              }
  160379           0 :            block++;
  160380             :         }
  160381           0 :      return storageCounter;
  160382             :    }
  160383             : 
  160384             : /* #line 160385 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  160385             : 
  160386             : 
  160387             : 
  160388             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  160389             : 
  160390             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  160391             : 
  160392             : //############################################################################
  160393             : /* JH (02/02/2006) Constructor of the IR node SgAssignOp that takes its 
  160394             :  * corresponding StorageClass as parameter
  160395             :  */
  160396         455 : SgAssignOp :: SgAssignOp ( const SgAssignOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  160397             :    {
  160398             : 
  160399             : 
  160400             : /* #line 160401 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  160401             : 
  160402         455 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  160403             : 
  160404             : 
  160405             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  160406             : 
  160407             : 
  160408         455 :    }
  160409             : 
  160410             : //############################################################################
  160411             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  160412             :  * within the working AST. 
  160413             :  */
  160414        2730 : SgAssignOp * SgAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  160415        2730 :      SgAssignOp* returnPointer = NULL;
  160416        2730 :      if ( globalIndex != 0 )
  160417             :         {
  160418             : 
  160419             : #if FILE_IO_EXTRA_CHECK
  160420        2730 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAssignOp ) ) <= globalIndex ) ;
  160421        2730 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssignOp + 1 ) ) );
  160422             : #endif
  160423        2730 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssignOp )  
  160424        2730 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAssignOp );
  160425        2730 :           unsigned long positionInPool = localIndex % SgAssignOp::pool_size;
  160426        2730 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssignOp::pool_size;
  160427             : 
  160428             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  160429             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  160430             : 
  160431        2730 :           returnPointer = &( ( (SgAssignOp*)(SgAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  160432             : 
  160433        2730 :           ROSE_ASSERT( returnPointer != NULL ) ;
  160434             :         }
  160435        2730 :      return returnPointer ;
  160436             :    }
  160437             : 
  160438             : //############################################################################
  160439             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  160440             :   for the AST with the index astIndex
  160441             : */
  160442           0 : SgAssignOp * SgAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  160443           0 :      SgAssignOp* returnPointer = NULL;
  160444           0 :      if ( globalIndex != 0 )
  160445             :         {
  160446             : 
  160447             : #if FILE_IO_EXTRA_CHECK
  160448           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAssignOp ) ) <= globalIndex ) ;
  160449           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssignOp + 1 ) ) );
  160450             : #endif
  160451           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssignOp )
  160452           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAssignOp );
  160453           0 :           unsigned long positionInPool = localIndex % SgAssignOp::pool_size ;
  160454           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssignOp::pool_size ;
  160455             : 
  160456             : #if FILE_IO_EXTRA_CHECK
  160457             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  160458             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  160459             : #endif
  160460             : 
  160461           0 :           returnPointer = &( ( (SgAssignOp*)(SgAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  160462             : 
  160463             : #if FILE_IO_EXTRA_CHECK
  160464           0 :           assert ( returnPointer != NULL ) ;
  160465             : #endif
  160466             :         }
  160467           0 :      return returnPointer ;
  160468             :    }
  160469             : 
  160470             : //############################################################################
  160471             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  160472             :  * pool size! We set for every valid object in the memory pool the freepointer
  160473             :  * to the global index and increase the global index afterwards. For all the 
  160474             :  * invalid objects (means address ranges within the memory pool that were not
  160475             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  160476             :  * distinguish valid from invalid objects! 
  160477             :  */
  160478             : unsigned long
  160479           5 : SgAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  160480             :    {
  160481           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  160482           5 :      SgAssignOp* pointer = NULL;
  160483           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  160484           5 :      std::vector < unsigned char* > :: const_iterator block;
  160485           6 :      for ( block = SgAssignOp::pools.begin(); block != SgAssignOp::pools.end() ; ++block )
  160486             :         {
  160487           1 :           pointer = (SgAssignOp*)(*block);
  160488        2001 :           for (unsigned i = 0; i < SgAssignOp::pool_size; ++i )
  160489             :              {
  160490             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  160491             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  160492             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  160493             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  160494             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  160495             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  160496             :             // properly; so this will have to be checked next.
  160497             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  160498             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  160499        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  160500             :                   {
  160501         455 :                     pointer[i].set_freepointer((SgAssignOp*)(globalIndex));
  160502         455 :                     globalIndex++;
  160503             :                   }
  160504             :                else
  160505             :                   {
  160506        1545 :                     pointer[i].set_freepointer(NULL);
  160507             :                   }
  160508             :               }
  160509             :         }
  160510           5 :      return globalIndex;
  160511             :    }
  160512             : 
  160513             : //############################################################################
  160514             : // JH (01/14/2006)
  160515             : void
  160516           5 : SgAssignOp::resetValidFreepointers( )
  160517             :    {
  160518           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  160519           5 :      SgAssignOp* pointer = NULL;
  160520           5 :      std::vector < unsigned char* > :: const_iterator block;
  160521           5 :      SgAssignOp* pointerOfLinkedList = NULL;
  160522           6 :      for ( block = SgAssignOp::pools.begin(); block != SgAssignOp::pools.end() ; ++block )
  160523             :         {
  160524           1 :           pointer = (SgAssignOp*)(*block);
  160525        2001 :           for (unsigned i = 0; i < SgAssignOp::pool_size; ++i )
  160526             :              {
  160527             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  160528             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  160529             :             // memory blocks!.
  160530        2000 :                if ( pointer[i].get_freepointer() != NULL )
  160531             :                   {
  160532         455 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  160533             :                   }
  160534             :                else
  160535             :                   {
  160536        1545 :                     if ( pointerOfLinkedList == NULL )
  160537             :                        {
  160538           1 :                          SgAssignOp::next_node = &(pointer[i]);
  160539             :                        }
  160540             :                     else
  160541             :                        {
  160542             :                       // printf ("In SgAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  160543        1544 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  160544             :                        }
  160545             :                     pointerOfLinkedList = &(pointer[i]);
  160546             :                   }
  160547             :               }
  160548             :         }
  160549             : 
  160550           5 :      if ( pointerOfLinkedList != NULL )
  160551             :         {
  160552             :        // printf ("In SgAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  160553           1 :           pointerOfLinkedList->set_freepointer(NULL);
  160554             :        // DQ (6/6/2010): Temporary debugging...
  160555             :        //   ROSE_ASSERT(false);
  160556             :         }
  160557             : 
  160558           5 :      return ;
  160559             :    }
  160560             : 
  160561             : //############################################################################
  160562             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  160563             :  * within the memory pool and resets the freepointers, in order to achieve a 
  160564             :  * linked list, that has no jumps and starts at the beginning! This function 
  160565             :  * does not extend the memory pool, since we do not delete any memory blocks,
  160566             :  * but delete the valid objects.  
  160567             :  */
  160568             : void
  160569           0 : SgAssignOp::clearMemoryPool( )
  160570             :    {
  160571             :   // printf ("Inside of SgAssignOp::clearMemoryPool() \n");
  160572             : 
  160573           0 :      SgAssignOp* pointer = NULL, *tempPointer = NULL;
  160574           0 :      std::vector < unsigned char* > :: const_iterator block;
  160575           0 :      if ( SgAssignOp::pools.empty() == false )
  160576             :         {
  160577           0 :           block = SgAssignOp::pools.begin() ;
  160578           0 :           SgAssignOp::next_node = (SgAssignOp*) (*block);
  160579             : 
  160580           0 :           while ( block != SgAssignOp::pools.end() )
  160581             :              {
  160582           0 :                pointer = (SgAssignOp*) (*block);
  160583           0 :                if ( tempPointer != NULL )
  160584             :                   {
  160585           0 :                     tempPointer->set_freepointer(pointer);
  160586             :                   }
  160587           0 :                for (unsigned i = 0; i < SgAssignOp::pool_size - 1; ++i)
  160588             :                   {
  160589           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  160590             :                   }
  160591           0 :                 pointer[SgAssignOp::pool_size-1].set_freepointer(NULL);
  160592           0 :                 tempPointer = &(pointer[SgAssignOp::pool_size-1]);
  160593           0 :                 ++block;
  160594             :              }
  160595             :         }
  160596           0 :    }
  160597             : 
  160598           5 : void SgAssignOp::deleteMemoryPool() {
  160599           7 :   for (auto p: SgAssignOp::pools) {
  160600           2 :     ROSE_FREE(p);
  160601             :   }
  160602           5 :   SgAssignOp::next_node = nullptr;
  160603           5 :   SgAssignOp::pools.clear();
  160604           5 : }
  160605             : 
  160606             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  160607             : //                 reading multiple binary files to for a single AST.
  160608             : /////////// new version ////////////////////////////////
  160609             : //############################################################################
  160610             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  160611             : void
  160612           2 : SgAssignOp::extendMemoryPoolForFileIO( )
  160613             :   {
  160614           2 :     size_t blockIndex = SgAssignOp::pools.size();
  160615           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignOp);
  160616             : 
  160617           3 :     while ( (blockIndex * SgAssignOp::pool_size) < newPoolSize)
  160618             :       {
  160619             : #if ROSE_ALLOC_TRACE
  160620             :         if (blockIndex > 0) {
  160621             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignOp) = %" PRIuPTR " SgAssignOp::pool_size = %d \n",
  160622             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignOp),SgAssignOp::pool_size);
  160623             :         }
  160624             : #endif
  160625             : 
  160626           1 :         SgAssignOp * pointer = (SgAssignOp*) ROSE_MALLOC ( SgAssignOp::pool_size * sizeof(SgAssignOp) );
  160627           1 :         assert( pointer != NULL );
  160628             : #if ROSE_ALLOC_MEMSET == 1
  160629             :         memset(pointer, 0x00, SgAssignOp::pool_size * sizeof(SgAssignOp));
  160630             : #elif ROSE_ALLOC_MEMSET == 2
  160631             :         memset(pointer, 0xCC, SgAssignOp::pool_size * sizeof(SgAssignOp));
  160632             : #endif
  160633           1 :         SgAssignOp::pools.push_back( (unsigned char*)(pointer) );
  160634           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAssignOp::pool_size * sizeof(SgAssignOp), V_SgAssignOp ) );
  160635             : 
  160636           1 :         if ( SgAssignOp::next_node != NULL ) {
  160637           0 :           if ( blockIndex > 0 ) {
  160638           0 :             SgAssignOp * blkptr = (SgAssignOp*)(SgAssignOp::pools[blockIndex-1]);
  160639           0 :             blkptr[ SgAssignOp::pool_size - 1 ].set_freepointer(pointer);
  160640             :           }
  160641             :         } else {
  160642           1 :           SgAssignOp::next_node = pointer;
  160643             :         }
  160644             : 
  160645        2000 :         for (unsigned i = 0; i < SgAssignOp::pool_size-1; ++i)
  160646             :            {
  160647        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  160648             :            }
  160649           1 :         pointer[ SgAssignOp::pool_size -1 ].set_freepointer(NULL);
  160650             : 
  160651           1 :         blockIndex++;
  160652             :       }
  160653           2 :   }
  160654             : 
  160655             : //############################################################################
  160656             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  160657             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  160658             :  * not compressed. However, that stuff is not yet implemented! 
  160659             :  */
  160660             : unsigned long
  160661           0 : SgAssignOp::getNumberOfLastValidPointer()
  160662             :    {
  160663           0 :       SgAssignOp* testPointer = (SgAssignOp*)(SgAssignOp::pools.back());
  160664           0 :       unsigned long localIndex = SgAssignOp::pool_size - 1;
  160665           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  160666             :          {
  160667           0 :            localIndex--;
  160668             :          }
  160669           0 :       return (localIndex + SgAssignOp::pool_size * (SgAssignOp::pools.size()-1));
  160670             :    }
  160671             : 
  160672             : //############################################################################
  160673             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  160674             :  * memory pool and initializes the data member in class SgAssignOpStroageClass
  160675             :  * from its counterpart of SgAssignOp. The return value is just for checking, 
  160676             :  * that the whole StorageClassArray is initialized!
  160677             :  */
  160678             : unsigned long
  160679           1 : SgAssignOp::initializeStorageClassArray( SgAssignOpStorageClass *storageArray )
  160680             :    {
  160681           1 :      unsigned long storageCounter = 0;
  160682           1 :      std::vector < unsigned char* > :: const_iterator block = SgAssignOp::pools.begin();
  160683           1 :      SgAssignOp* pointer = NULL;
  160684           2 :      while ( block != SgAssignOp::pools.end() ) {
  160685           1 :           pointer = (SgAssignOp*) (*block);
  160686        2001 :           for ( unsigned i = 0; i < SgAssignOp::pool_size; ++i ) {
  160687        2000 :                if ( pointer->get_freepointer() != NULL ) {
  160688         455 :                  storageArray->pickOutIRNodeData (pointer) ;
  160689         455 :                  storageArray++;
  160690         455 :                  storageCounter++;
  160691             :                }
  160692        2000 :                pointer++;
  160693             :              }
  160694           1 :            block++;
  160695             :         }
  160696           1 :      return storageCounter;
  160697             :    }
  160698             : 
  160699             : /* #line 160700 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  160700             : 
  160701             : 
  160702             : 
  160703             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  160704             : 
  160705             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  160706             : 
  160707             : //############################################################################
  160708             : /* JH (02/02/2006) Constructor of the IR node SgExponentiationOp that takes its 
  160709             :  * corresponding StorageClass as parameter
  160710             :  */
  160711           0 : SgExponentiationOp :: SgExponentiationOp ( const SgExponentiationOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  160712             :    {
  160713             : 
  160714             : 
  160715             : /* #line 160716 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  160716             : 
  160717           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  160718             : 
  160719             : 
  160720             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  160721             : 
  160722             : 
  160723           0 :    }
  160724             : 
  160725             : //############################################################################
  160726             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  160727             :  * within the working AST. 
  160728             :  */
  160729           0 : SgExponentiationOp * SgExponentiationOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  160730           0 :      SgExponentiationOp* returnPointer = NULL;
  160731           0 :      if ( globalIndex != 0 )
  160732             :         {
  160733             : 
  160734             : #if FILE_IO_EXTRA_CHECK
  160735           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgExponentiationOp ) ) <= globalIndex ) ;
  160736           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExponentiationOp + 1 ) ) );
  160737             : #endif
  160738           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExponentiationOp )  
  160739           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgExponentiationOp );
  160740           0 :           unsigned long positionInPool = localIndex % SgExponentiationOp::pool_size;
  160741           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExponentiationOp::pool_size;
  160742             : 
  160743             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  160744             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  160745             : 
  160746           0 :           returnPointer = &( ( (SgExponentiationOp*)(SgExponentiationOp::pools[memoryBlock]) ) [positionInPool]) ;
  160747             : 
  160748           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  160749             :         }
  160750           0 :      return returnPointer ;
  160751             :    }
  160752             : 
  160753             : //############################################################################
  160754             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  160755             :   for the AST with the index astIndex
  160756             : */
  160757           0 : SgExponentiationOp * SgExponentiationOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  160758           0 :      SgExponentiationOp* returnPointer = NULL;
  160759           0 :      if ( globalIndex != 0 )
  160760             :         {
  160761             : 
  160762             : #if FILE_IO_EXTRA_CHECK
  160763           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgExponentiationOp ) ) <= globalIndex ) ;
  160764           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExponentiationOp + 1 ) ) );
  160765             : #endif
  160766           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExponentiationOp )
  160767           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgExponentiationOp );
  160768           0 :           unsigned long positionInPool = localIndex % SgExponentiationOp::pool_size ;
  160769           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExponentiationOp::pool_size ;
  160770             : 
  160771             : #if FILE_IO_EXTRA_CHECK
  160772             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  160773             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  160774             : #endif
  160775             : 
  160776           0 :           returnPointer = &( ( (SgExponentiationOp*)(SgExponentiationOp::pools[memoryBlock]) ) [positionInPool]) ;
  160777             : 
  160778             : #if FILE_IO_EXTRA_CHECK
  160779           0 :           assert ( returnPointer != NULL ) ;
  160780             : #endif
  160781             :         }
  160782           0 :      return returnPointer ;
  160783             :    }
  160784             : 
  160785             : //############################################################################
  160786             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  160787             :  * pool size! We set for every valid object in the memory pool the freepointer
  160788             :  * to the global index and increase the global index afterwards. For all the 
  160789             :  * invalid objects (means address ranges within the memory pool that were not
  160790             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  160791             :  * distinguish valid from invalid objects! 
  160792             :  */
  160793             : unsigned long
  160794           5 : SgExponentiationOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  160795             :    {
  160796           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  160797           5 :      SgExponentiationOp* pointer = NULL;
  160798           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  160799           5 :      std::vector < unsigned char* > :: const_iterator block;
  160800           5 :      for ( block = SgExponentiationOp::pools.begin(); block != SgExponentiationOp::pools.end() ; ++block )
  160801             :         {
  160802           0 :           pointer = (SgExponentiationOp*)(*block);
  160803           0 :           for (unsigned i = 0; i < SgExponentiationOp::pool_size; ++i )
  160804             :              {
  160805             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  160806             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  160807             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  160808             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  160809             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  160810             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  160811             :             // properly; so this will have to be checked next.
  160812             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  160813             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  160814           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  160815             :                   {
  160816           0 :                     pointer[i].set_freepointer((SgExponentiationOp*)(globalIndex));
  160817           0 :                     globalIndex++;
  160818             :                   }
  160819             :                else
  160820             :                   {
  160821           0 :                     pointer[i].set_freepointer(NULL);
  160822             :                   }
  160823             :               }
  160824             :         }
  160825           5 :      return globalIndex;
  160826             :    }
  160827             : 
  160828             : //############################################################################
  160829             : // JH (01/14/2006)
  160830             : void
  160831           5 : SgExponentiationOp::resetValidFreepointers( )
  160832             :    {
  160833           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  160834           5 :      SgExponentiationOp* pointer = NULL;
  160835           5 :      std::vector < unsigned char* > :: const_iterator block;
  160836           5 :      SgExponentiationOp* pointerOfLinkedList = NULL;
  160837           5 :      for ( block = SgExponentiationOp::pools.begin(); block != SgExponentiationOp::pools.end() ; ++block )
  160838             :         {
  160839           0 :           pointer = (SgExponentiationOp*)(*block);
  160840           0 :           for (unsigned i = 0; i < SgExponentiationOp::pool_size; ++i )
  160841             :              {
  160842             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  160843             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  160844             :             // memory blocks!.
  160845           0 :                if ( pointer[i].get_freepointer() != NULL )
  160846             :                   {
  160847           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  160848             :                   }
  160849             :                else
  160850             :                   {
  160851           0 :                     if ( pointerOfLinkedList == NULL )
  160852             :                        {
  160853           0 :                          SgExponentiationOp::next_node = &(pointer[i]);
  160854             :                        }
  160855             :                     else
  160856             :                        {
  160857             :                       // printf ("In SgExponentiationOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  160858           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  160859             :                        }
  160860             :                     pointerOfLinkedList = &(pointer[i]);
  160861             :                   }
  160862             :               }
  160863             :         }
  160864             : 
  160865           5 :      if ( pointerOfLinkedList != NULL )
  160866             :         {
  160867             :        // printf ("In SgExponentiationOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  160868           0 :           pointerOfLinkedList->set_freepointer(NULL);
  160869             :        // DQ (6/6/2010): Temporary debugging...
  160870             :        //   ROSE_ASSERT(false);
  160871             :         }
  160872             : 
  160873           5 :      return ;
  160874             :    }
  160875             : 
  160876             : //############################################################################
  160877             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  160878             :  * within the memory pool and resets the freepointers, in order to achieve a 
  160879             :  * linked list, that has no jumps and starts at the beginning! This function 
  160880             :  * does not extend the memory pool, since we do not delete any memory blocks,
  160881             :  * but delete the valid objects.  
  160882             :  */
  160883             : void
  160884           0 : SgExponentiationOp::clearMemoryPool( )
  160885             :    {
  160886             :   // printf ("Inside of SgExponentiationOp::clearMemoryPool() \n");
  160887             : 
  160888           0 :      SgExponentiationOp* pointer = NULL, *tempPointer = NULL;
  160889           0 :      std::vector < unsigned char* > :: const_iterator block;
  160890           0 :      if ( SgExponentiationOp::pools.empty() == false )
  160891             :         {
  160892           0 :           block = SgExponentiationOp::pools.begin() ;
  160893           0 :           SgExponentiationOp::next_node = (SgExponentiationOp*) (*block);
  160894             : 
  160895           0 :           while ( block != SgExponentiationOp::pools.end() )
  160896             :              {
  160897           0 :                pointer = (SgExponentiationOp*) (*block);
  160898           0 :                if ( tempPointer != NULL )
  160899             :                   {
  160900           0 :                     tempPointer->set_freepointer(pointer);
  160901             :                   }
  160902           0 :                for (unsigned i = 0; i < SgExponentiationOp::pool_size - 1; ++i)
  160903             :                   {
  160904           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  160905             :                   }
  160906           0 :                 pointer[SgExponentiationOp::pool_size-1].set_freepointer(NULL);
  160907           0 :                 tempPointer = &(pointer[SgExponentiationOp::pool_size-1]);
  160908           0 :                 ++block;
  160909             :              }
  160910             :         }
  160911           0 :    }
  160912             : 
  160913           5 : void SgExponentiationOp::deleteMemoryPool() {
  160914           5 :   for (auto p: SgExponentiationOp::pools) {
  160915           0 :     ROSE_FREE(p);
  160916             :   }
  160917           5 :   SgExponentiationOp::next_node = nullptr;
  160918           5 :   SgExponentiationOp::pools.clear();
  160919           5 : }
  160920             : 
  160921             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  160922             : //                 reading multiple binary files to for a single AST.
  160923             : /////////// new version ////////////////////////////////
  160924             : //############################################################################
  160925             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  160926             : void
  160927           2 : SgExponentiationOp::extendMemoryPoolForFileIO( )
  160928             :   {
  160929           2 :     size_t blockIndex = SgExponentiationOp::pools.size();
  160930           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgExponentiationOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgExponentiationOp);
  160931             : 
  160932           2 :     while ( (blockIndex * SgExponentiationOp::pool_size) < newPoolSize)
  160933             :       {
  160934             : #if ROSE_ALLOC_TRACE
  160935             :         if (blockIndex > 0) {
  160936             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgExponentiationOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgExponentiationOp) = %" PRIuPTR " SgExponentiationOp::pool_size = %d \n",
  160937             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgExponentiationOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgExponentiationOp),SgExponentiationOp::pool_size);
  160938             :         }
  160939             : #endif
  160940             : 
  160941           0 :         SgExponentiationOp * pointer = (SgExponentiationOp*) ROSE_MALLOC ( SgExponentiationOp::pool_size * sizeof(SgExponentiationOp) );
  160942           0 :         assert( pointer != NULL );
  160943             : #if ROSE_ALLOC_MEMSET == 1
  160944             :         memset(pointer, 0x00, SgExponentiationOp::pool_size * sizeof(SgExponentiationOp));
  160945             : #elif ROSE_ALLOC_MEMSET == 2
  160946             :         memset(pointer, 0xCC, SgExponentiationOp::pool_size * sizeof(SgExponentiationOp));
  160947             : #endif
  160948           0 :         SgExponentiationOp::pools.push_back( (unsigned char*)(pointer) );
  160949           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgExponentiationOp::pool_size * sizeof(SgExponentiationOp), V_SgExponentiationOp ) );
  160950             : 
  160951           0 :         if ( SgExponentiationOp::next_node != NULL ) {
  160952           0 :           if ( blockIndex > 0 ) {
  160953           0 :             SgExponentiationOp * blkptr = (SgExponentiationOp*)(SgExponentiationOp::pools[blockIndex-1]);
  160954           0 :             blkptr[ SgExponentiationOp::pool_size - 1 ].set_freepointer(pointer);
  160955             :           }
  160956             :         } else {
  160957           0 :           SgExponentiationOp::next_node = pointer;
  160958             :         }
  160959             : 
  160960           0 :         for (unsigned i = 0; i < SgExponentiationOp::pool_size-1; ++i)
  160961             :            {
  160962           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  160963             :            }
  160964           0 :         pointer[ SgExponentiationOp::pool_size -1 ].set_freepointer(NULL);
  160965             : 
  160966           0 :         blockIndex++;
  160967             :       }
  160968           2 :   }
  160969             : 
  160970             : //############################################################################
  160971             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  160972             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  160973             :  * not compressed. However, that stuff is not yet implemented! 
  160974             :  */
  160975             : unsigned long
  160976           0 : SgExponentiationOp::getNumberOfLastValidPointer()
  160977             :    {
  160978           0 :       SgExponentiationOp* testPointer = (SgExponentiationOp*)(SgExponentiationOp::pools.back());
  160979           0 :       unsigned long localIndex = SgExponentiationOp::pool_size - 1;
  160980           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  160981             :          {
  160982           0 :            localIndex--;
  160983             :          }
  160984           0 :       return (localIndex + SgExponentiationOp::pool_size * (SgExponentiationOp::pools.size()-1));
  160985             :    }
  160986             : 
  160987             : //############################################################################
  160988             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  160989             :  * memory pool and initializes the data member in class SgExponentiationOpStroageClass
  160990             :  * from its counterpart of SgExponentiationOp. The return value is just for checking, 
  160991             :  * that the whole StorageClassArray is initialized!
  160992             :  */
  160993             : unsigned long
  160994           0 : SgExponentiationOp::initializeStorageClassArray( SgExponentiationOpStorageClass *storageArray )
  160995             :    {
  160996           0 :      unsigned long storageCounter = 0;
  160997           0 :      std::vector < unsigned char* > :: const_iterator block = SgExponentiationOp::pools.begin();
  160998           0 :      SgExponentiationOp* pointer = NULL;
  160999           0 :      while ( block != SgExponentiationOp::pools.end() ) {
  161000           0 :           pointer = (SgExponentiationOp*) (*block);
  161001           0 :           for ( unsigned i = 0; i < SgExponentiationOp::pool_size; ++i ) {
  161002           0 :                if ( pointer->get_freepointer() != NULL ) {
  161003           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  161004           0 :                  storageArray++;
  161005           0 :                  storageCounter++;
  161006             :                }
  161007           0 :                pointer++;
  161008             :              }
  161009           0 :            block++;
  161010             :         }
  161011           0 :      return storageCounter;
  161012             :    }
  161013             : 
  161014             : /* #line 161015 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  161015             : 
  161016             : 
  161017             : 
  161018             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  161019             : 
  161020             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  161021             : 
  161022             : //############################################################################
  161023             : /* JH (02/02/2006) Constructor of the IR node SgConcatenationOp that takes its 
  161024             :  * corresponding StorageClass as parameter
  161025             :  */
  161026           0 : SgConcatenationOp :: SgConcatenationOp ( const SgConcatenationOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  161027             :    {
  161028             : 
  161029             : 
  161030             : /* #line 161031 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  161031             : 
  161032           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  161033             : 
  161034             : 
  161035             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  161036             : 
  161037             : 
  161038           0 :    }
  161039             : 
  161040             : //############################################################################
  161041             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  161042             :  * within the working AST. 
  161043             :  */
  161044           0 : SgConcatenationOp * SgConcatenationOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  161045           0 :      SgConcatenationOp* returnPointer = NULL;
  161046           0 :      if ( globalIndex != 0 )
  161047             :         {
  161048             : 
  161049             : #if FILE_IO_EXTRA_CHECK
  161050           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgConcatenationOp ) ) <= globalIndex ) ;
  161051           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConcatenationOp + 1 ) ) );
  161052             : #endif
  161053           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConcatenationOp )  
  161054           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgConcatenationOp );
  161055           0 :           unsigned long positionInPool = localIndex % SgConcatenationOp::pool_size;
  161056           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConcatenationOp::pool_size;
  161057             : 
  161058             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  161059             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  161060             : 
  161061           0 :           returnPointer = &( ( (SgConcatenationOp*)(SgConcatenationOp::pools[memoryBlock]) ) [positionInPool]) ;
  161062             : 
  161063           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  161064             :         }
  161065           0 :      return returnPointer ;
  161066             :    }
  161067             : 
  161068             : //############################################################################
  161069             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  161070             :   for the AST with the index astIndex
  161071             : */
  161072           0 : SgConcatenationOp * SgConcatenationOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  161073           0 :      SgConcatenationOp* returnPointer = NULL;
  161074           0 :      if ( globalIndex != 0 )
  161075             :         {
  161076             : 
  161077             : #if FILE_IO_EXTRA_CHECK
  161078           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgConcatenationOp ) ) <= globalIndex ) ;
  161079           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConcatenationOp + 1 ) ) );
  161080             : #endif
  161081           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConcatenationOp )
  161082           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgConcatenationOp );
  161083           0 :           unsigned long positionInPool = localIndex % SgConcatenationOp::pool_size ;
  161084           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConcatenationOp::pool_size ;
  161085             : 
  161086             : #if FILE_IO_EXTRA_CHECK
  161087             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  161088             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  161089             : #endif
  161090             : 
  161091           0 :           returnPointer = &( ( (SgConcatenationOp*)(SgConcatenationOp::pools[memoryBlock]) ) [positionInPool]) ;
  161092             : 
  161093             : #if FILE_IO_EXTRA_CHECK
  161094           0 :           assert ( returnPointer != NULL ) ;
  161095             : #endif
  161096             :         }
  161097           0 :      return returnPointer ;
  161098             :    }
  161099             : 
  161100             : //############################################################################
  161101             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  161102             :  * pool size! We set for every valid object in the memory pool the freepointer
  161103             :  * to the global index and increase the global index afterwards. For all the 
  161104             :  * invalid objects (means address ranges within the memory pool that were not
  161105             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  161106             :  * distinguish valid from invalid objects! 
  161107             :  */
  161108             : unsigned long
  161109           5 : SgConcatenationOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  161110             :    {
  161111           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  161112           5 :      SgConcatenationOp* pointer = NULL;
  161113           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  161114           5 :      std::vector < unsigned char* > :: const_iterator block;
  161115           5 :      for ( block = SgConcatenationOp::pools.begin(); block != SgConcatenationOp::pools.end() ; ++block )
  161116             :         {
  161117           0 :           pointer = (SgConcatenationOp*)(*block);
  161118           0 :           for (unsigned i = 0; i < SgConcatenationOp::pool_size; ++i )
  161119             :              {
  161120             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  161121             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  161122             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  161123             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  161124             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  161125             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  161126             :             // properly; so this will have to be checked next.
  161127             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  161128             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  161129           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  161130             :                   {
  161131           0 :                     pointer[i].set_freepointer((SgConcatenationOp*)(globalIndex));
  161132           0 :                     globalIndex++;
  161133             :                   }
  161134             :                else
  161135             :                   {
  161136           0 :                     pointer[i].set_freepointer(NULL);
  161137             :                   }
  161138             :               }
  161139             :         }
  161140           5 :      return globalIndex;
  161141             :    }
  161142             : 
  161143             : //############################################################################
  161144             : // JH (01/14/2006)
  161145             : void
  161146           5 : SgConcatenationOp::resetValidFreepointers( )
  161147             :    {
  161148           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  161149           5 :      SgConcatenationOp* pointer = NULL;
  161150           5 :      std::vector < unsigned char* > :: const_iterator block;
  161151           5 :      SgConcatenationOp* pointerOfLinkedList = NULL;
  161152           5 :      for ( block = SgConcatenationOp::pools.begin(); block != SgConcatenationOp::pools.end() ; ++block )
  161153             :         {
  161154           0 :           pointer = (SgConcatenationOp*)(*block);
  161155           0 :           for (unsigned i = 0; i < SgConcatenationOp::pool_size; ++i )
  161156             :              {
  161157             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  161158             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  161159             :             // memory blocks!.
  161160           0 :                if ( pointer[i].get_freepointer() != NULL )
  161161             :                   {
  161162           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  161163             :                   }
  161164             :                else
  161165             :                   {
  161166           0 :                     if ( pointerOfLinkedList == NULL )
  161167             :                        {
  161168           0 :                          SgConcatenationOp::next_node = &(pointer[i]);
  161169             :                        }
  161170             :                     else
  161171             :                        {
  161172             :                       // printf ("In SgConcatenationOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  161173           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  161174             :                        }
  161175             :                     pointerOfLinkedList = &(pointer[i]);
  161176             :                   }
  161177             :               }
  161178             :         }
  161179             : 
  161180           5 :      if ( pointerOfLinkedList != NULL )
  161181             :         {
  161182             :        // printf ("In SgConcatenationOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  161183           0 :           pointerOfLinkedList->set_freepointer(NULL);
  161184             :        // DQ (6/6/2010): Temporary debugging...
  161185             :        //   ROSE_ASSERT(false);
  161186             :         }
  161187             : 
  161188           5 :      return ;
  161189             :    }
  161190             : 
  161191             : //############################################################################
  161192             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  161193             :  * within the memory pool and resets the freepointers, in order to achieve a 
  161194             :  * linked list, that has no jumps and starts at the beginning! This function 
  161195             :  * does not extend the memory pool, since we do not delete any memory blocks,
  161196             :  * but delete the valid objects.  
  161197             :  */
  161198             : void
  161199           0 : SgConcatenationOp::clearMemoryPool( )
  161200             :    {
  161201             :   // printf ("Inside of SgConcatenationOp::clearMemoryPool() \n");
  161202             : 
  161203           0 :      SgConcatenationOp* pointer = NULL, *tempPointer = NULL;
  161204           0 :      std::vector < unsigned char* > :: const_iterator block;
  161205           0 :      if ( SgConcatenationOp::pools.empty() == false )
  161206             :         {
  161207           0 :           block = SgConcatenationOp::pools.begin() ;
  161208           0 :           SgConcatenationOp::next_node = (SgConcatenationOp*) (*block);
  161209             : 
  161210           0 :           while ( block != SgConcatenationOp::pools.end() )
  161211             :              {
  161212           0 :                pointer = (SgConcatenationOp*) (*block);
  161213           0 :                if ( tempPointer != NULL )
  161214             :                   {
  161215           0 :                     tempPointer->set_freepointer(pointer);
  161216             :                   }
  161217           0 :                for (unsigned i = 0; i < SgConcatenationOp::pool_size - 1; ++i)
  161218             :                   {
  161219           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  161220             :                   }
  161221           0 :                 pointer[SgConcatenationOp::pool_size-1].set_freepointer(NULL);
  161222           0 :                 tempPointer = &(pointer[SgConcatenationOp::pool_size-1]);
  161223           0 :                 ++block;
  161224             :              }
  161225             :         }
  161226           0 :    }
  161227             : 
  161228           5 : void SgConcatenationOp::deleteMemoryPool() {
  161229           5 :   for (auto p: SgConcatenationOp::pools) {
  161230           0 :     ROSE_FREE(p);
  161231             :   }
  161232           5 :   SgConcatenationOp::next_node = nullptr;
  161233           5 :   SgConcatenationOp::pools.clear();
  161234           5 : }
  161235             : 
  161236             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  161237             : //                 reading multiple binary files to for a single AST.
  161238             : /////////// new version ////////////////////////////////
  161239             : //############################################################################
  161240             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  161241             : void
  161242           2 : SgConcatenationOp::extendMemoryPoolForFileIO( )
  161243             :   {
  161244           2 :     size_t blockIndex = SgConcatenationOp::pools.size();
  161245           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgConcatenationOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgConcatenationOp);
  161246             : 
  161247           2 :     while ( (blockIndex * SgConcatenationOp::pool_size) < newPoolSize)
  161248             :       {
  161249             : #if ROSE_ALLOC_TRACE
  161250             :         if (blockIndex > 0) {
  161251             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgConcatenationOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgConcatenationOp) = %" PRIuPTR " SgConcatenationOp::pool_size = %d \n",
  161252             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgConcatenationOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgConcatenationOp),SgConcatenationOp::pool_size);
  161253             :         }
  161254             : #endif
  161255             : 
  161256           0 :         SgConcatenationOp * pointer = (SgConcatenationOp*) ROSE_MALLOC ( SgConcatenationOp::pool_size * sizeof(SgConcatenationOp) );
  161257           0 :         assert( pointer != NULL );
  161258             : #if ROSE_ALLOC_MEMSET == 1
  161259             :         memset(pointer, 0x00, SgConcatenationOp::pool_size * sizeof(SgConcatenationOp));
  161260             : #elif ROSE_ALLOC_MEMSET == 2
  161261             :         memset(pointer, 0xCC, SgConcatenationOp::pool_size * sizeof(SgConcatenationOp));
  161262             : #endif
  161263           0 :         SgConcatenationOp::pools.push_back( (unsigned char*)(pointer) );
  161264           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgConcatenationOp::pool_size * sizeof(SgConcatenationOp), V_SgConcatenationOp ) );
  161265             : 
  161266           0 :         if ( SgConcatenationOp::next_node != NULL ) {
  161267           0 :           if ( blockIndex > 0 ) {
  161268           0 :             SgConcatenationOp * blkptr = (SgConcatenationOp*)(SgConcatenationOp::pools[blockIndex-1]);
  161269           0 :             blkptr[ SgConcatenationOp::pool_size - 1 ].set_freepointer(pointer);
  161270             :           }
  161271             :         } else {
  161272           0 :           SgConcatenationOp::next_node = pointer;
  161273             :         }
  161274             : 
  161275           0 :         for (unsigned i = 0; i < SgConcatenationOp::pool_size-1; ++i)
  161276             :            {
  161277           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  161278             :            }
  161279           0 :         pointer[ SgConcatenationOp::pool_size -1 ].set_freepointer(NULL);
  161280             : 
  161281           0 :         blockIndex++;
  161282             :       }
  161283           2 :   }
  161284             : 
  161285             : //############################################################################
  161286             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  161287             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  161288             :  * not compressed. However, that stuff is not yet implemented! 
  161289             :  */
  161290             : unsigned long
  161291           0 : SgConcatenationOp::getNumberOfLastValidPointer()
  161292             :    {
  161293           0 :       SgConcatenationOp* testPointer = (SgConcatenationOp*)(SgConcatenationOp::pools.back());
  161294           0 :       unsigned long localIndex = SgConcatenationOp::pool_size - 1;
  161295           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  161296             :          {
  161297           0 :            localIndex--;
  161298             :          }
  161299           0 :       return (localIndex + SgConcatenationOp::pool_size * (SgConcatenationOp::pools.size()-1));
  161300             :    }
  161301             : 
  161302             : //############################################################################
  161303             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  161304             :  * memory pool and initializes the data member in class SgConcatenationOpStroageClass
  161305             :  * from its counterpart of SgConcatenationOp. The return value is just for checking, 
  161306             :  * that the whole StorageClassArray is initialized!
  161307             :  */
  161308             : unsigned long
  161309           0 : SgConcatenationOp::initializeStorageClassArray( SgConcatenationOpStorageClass *storageArray )
  161310             :    {
  161311           0 :      unsigned long storageCounter = 0;
  161312           0 :      std::vector < unsigned char* > :: const_iterator block = SgConcatenationOp::pools.begin();
  161313           0 :      SgConcatenationOp* pointer = NULL;
  161314           0 :      while ( block != SgConcatenationOp::pools.end() ) {
  161315           0 :           pointer = (SgConcatenationOp*) (*block);
  161316           0 :           for ( unsigned i = 0; i < SgConcatenationOp::pool_size; ++i ) {
  161317           0 :                if ( pointer->get_freepointer() != NULL ) {
  161318           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  161319           0 :                  storageArray++;
  161320           0 :                  storageCounter++;
  161321             :                }
  161322           0 :                pointer++;
  161323             :              }
  161324           0 :            block++;
  161325             :         }
  161326           0 :      return storageCounter;
  161327             :    }
  161328             : 
  161329             : /* #line 161330 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  161330             : 
  161331             : 
  161332             : 
  161333             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  161334             : 
  161335             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  161336             : 
  161337             : //############################################################################
  161338             : /* JH (02/02/2006) Constructor of the IR node SgPointerAssignOp that takes its 
  161339             :  * corresponding StorageClass as parameter
  161340             :  */
  161341           0 : SgPointerAssignOp :: SgPointerAssignOp ( const SgPointerAssignOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  161342             :    {
  161343             : 
  161344             : 
  161345             : /* #line 161346 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  161346             : 
  161347           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  161348             : 
  161349             : 
  161350             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  161351             : 
  161352             : 
  161353           0 :    }
  161354             : 
  161355             : //############################################################################
  161356             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  161357             :  * within the working AST. 
  161358             :  */
  161359           0 : SgPointerAssignOp * SgPointerAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  161360           0 :      SgPointerAssignOp* returnPointer = NULL;
  161361           0 :      if ( globalIndex != 0 )
  161362             :         {
  161363             : 
  161364             : #if FILE_IO_EXTRA_CHECK
  161365           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPointerAssignOp ) ) <= globalIndex ) ;
  161366           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPointerAssignOp + 1 ) ) );
  161367             : #endif
  161368           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPointerAssignOp )  
  161369           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPointerAssignOp );
  161370           0 :           unsigned long positionInPool = localIndex % SgPointerAssignOp::pool_size;
  161371           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPointerAssignOp::pool_size;
  161372             : 
  161373             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  161374             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  161375             : 
  161376           0 :           returnPointer = &( ( (SgPointerAssignOp*)(SgPointerAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  161377             : 
  161378           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  161379             :         }
  161380           0 :      return returnPointer ;
  161381             :    }
  161382             : 
  161383             : //############################################################################
  161384             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  161385             :   for the AST with the index astIndex
  161386             : */
  161387           0 : SgPointerAssignOp * SgPointerAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  161388           0 :      SgPointerAssignOp* returnPointer = NULL;
  161389           0 :      if ( globalIndex != 0 )
  161390             :         {
  161391             : 
  161392             : #if FILE_IO_EXTRA_CHECK
  161393           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPointerAssignOp ) ) <= globalIndex ) ;
  161394           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPointerAssignOp + 1 ) ) );
  161395             : #endif
  161396           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPointerAssignOp )
  161397           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPointerAssignOp );
  161398           0 :           unsigned long positionInPool = localIndex % SgPointerAssignOp::pool_size ;
  161399           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPointerAssignOp::pool_size ;
  161400             : 
  161401             : #if FILE_IO_EXTRA_CHECK
  161402             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  161403             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  161404             : #endif
  161405             : 
  161406           0 :           returnPointer = &( ( (SgPointerAssignOp*)(SgPointerAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  161407             : 
  161408             : #if FILE_IO_EXTRA_CHECK
  161409           0 :           assert ( returnPointer != NULL ) ;
  161410             : #endif
  161411             :         }
  161412           0 :      return returnPointer ;
  161413             :    }
  161414             : 
  161415             : //############################################################################
  161416             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  161417             :  * pool size! We set for every valid object in the memory pool the freepointer
  161418             :  * to the global index and increase the global index afterwards. For all the 
  161419             :  * invalid objects (means address ranges within the memory pool that were not
  161420             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  161421             :  * distinguish valid from invalid objects! 
  161422             :  */
  161423             : unsigned long
  161424           5 : SgPointerAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  161425             :    {
  161426           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  161427           5 :      SgPointerAssignOp* pointer = NULL;
  161428           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  161429           5 :      std::vector < unsigned char* > :: const_iterator block;
  161430           5 :      for ( block = SgPointerAssignOp::pools.begin(); block != SgPointerAssignOp::pools.end() ; ++block )
  161431             :         {
  161432           0 :           pointer = (SgPointerAssignOp*)(*block);
  161433           0 :           for (unsigned i = 0; i < SgPointerAssignOp::pool_size; ++i )
  161434             :              {
  161435             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  161436             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  161437             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  161438             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  161439             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  161440             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  161441             :             // properly; so this will have to be checked next.
  161442             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  161443             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  161444           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  161445             :                   {
  161446           0 :                     pointer[i].set_freepointer((SgPointerAssignOp*)(globalIndex));
  161447           0 :                     globalIndex++;
  161448             :                   }
  161449             :                else
  161450             :                   {
  161451           0 :                     pointer[i].set_freepointer(NULL);
  161452             :                   }
  161453             :               }
  161454             :         }
  161455           5 :      return globalIndex;
  161456             :    }
  161457             : 
  161458             : //############################################################################
  161459             : // JH (01/14/2006)
  161460             : void
  161461           5 : SgPointerAssignOp::resetValidFreepointers( )
  161462             :    {
  161463           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  161464           5 :      SgPointerAssignOp* pointer = NULL;
  161465           5 :      std::vector < unsigned char* > :: const_iterator block;
  161466           5 :      SgPointerAssignOp* pointerOfLinkedList = NULL;
  161467           5 :      for ( block = SgPointerAssignOp::pools.begin(); block != SgPointerAssignOp::pools.end() ; ++block )
  161468             :         {
  161469           0 :           pointer = (SgPointerAssignOp*)(*block);
  161470           0 :           for (unsigned i = 0; i < SgPointerAssignOp::pool_size; ++i )
  161471             :              {
  161472             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  161473             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  161474             :             // memory blocks!.
  161475           0 :                if ( pointer[i].get_freepointer() != NULL )
  161476             :                   {
  161477           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  161478             :                   }
  161479             :                else
  161480             :                   {
  161481           0 :                     if ( pointerOfLinkedList == NULL )
  161482             :                        {
  161483           0 :                          SgPointerAssignOp::next_node = &(pointer[i]);
  161484             :                        }
  161485             :                     else
  161486             :                        {
  161487             :                       // printf ("In SgPointerAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  161488           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  161489             :                        }
  161490             :                     pointerOfLinkedList = &(pointer[i]);
  161491             :                   }
  161492             :               }
  161493             :         }
  161494             : 
  161495           5 :      if ( pointerOfLinkedList != NULL )
  161496             :         {
  161497             :        // printf ("In SgPointerAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  161498           0 :           pointerOfLinkedList->set_freepointer(NULL);
  161499             :        // DQ (6/6/2010): Temporary debugging...
  161500             :        //   ROSE_ASSERT(false);
  161501             :         }
  161502             : 
  161503           5 :      return ;
  161504             :    }
  161505             : 
  161506             : //############################################################################
  161507             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  161508             :  * within the memory pool and resets the freepointers, in order to achieve a 
  161509             :  * linked list, that has no jumps and starts at the beginning! This function 
  161510             :  * does not extend the memory pool, since we do not delete any memory blocks,
  161511             :  * but delete the valid objects.  
  161512             :  */
  161513             : void
  161514           0 : SgPointerAssignOp::clearMemoryPool( )
  161515             :    {
  161516             :   // printf ("Inside of SgPointerAssignOp::clearMemoryPool() \n");
  161517             : 
  161518           0 :      SgPointerAssignOp* pointer = NULL, *tempPointer = NULL;
  161519           0 :      std::vector < unsigned char* > :: const_iterator block;
  161520           0 :      if ( SgPointerAssignOp::pools.empty() == false )
  161521             :         {
  161522           0 :           block = SgPointerAssignOp::pools.begin() ;
  161523           0 :           SgPointerAssignOp::next_node = (SgPointerAssignOp*) (*block);
  161524             : 
  161525           0 :           while ( block != SgPointerAssignOp::pools.end() )
  161526             :              {
  161527           0 :                pointer = (SgPointerAssignOp*) (*block);
  161528           0 :                if ( tempPointer != NULL )
  161529             :                   {
  161530           0 :                     tempPointer->set_freepointer(pointer);
  161531             :                   }
  161532           0 :                for (unsigned i = 0; i < SgPointerAssignOp::pool_size - 1; ++i)
  161533             :                   {
  161534           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  161535             :                   }
  161536           0 :                 pointer[SgPointerAssignOp::pool_size-1].set_freepointer(NULL);
  161537           0 :                 tempPointer = &(pointer[SgPointerAssignOp::pool_size-1]);
  161538           0 :                 ++block;
  161539             :              }
  161540             :         }
  161541           0 :    }
  161542             : 
  161543           5 : void SgPointerAssignOp::deleteMemoryPool() {
  161544           5 :   for (auto p: SgPointerAssignOp::pools) {
  161545           0 :     ROSE_FREE(p);
  161546             :   }
  161547           5 :   SgPointerAssignOp::next_node = nullptr;
  161548           5 :   SgPointerAssignOp::pools.clear();
  161549           5 : }
  161550             : 
  161551             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  161552             : //                 reading multiple binary files to for a single AST.
  161553             : /////////// new version ////////////////////////////////
  161554             : //############################################################################
  161555             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  161556             : void
  161557           2 : SgPointerAssignOp::extendMemoryPoolForFileIO( )
  161558             :   {
  161559           2 :     size_t blockIndex = SgPointerAssignOp::pools.size();
  161560           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerAssignOp);
  161561             : 
  161562           2 :     while ( (blockIndex * SgPointerAssignOp::pool_size) < newPoolSize)
  161563             :       {
  161564             : #if ROSE_ALLOC_TRACE
  161565             :         if (blockIndex > 0) {
  161566             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerAssignOp) = %" PRIuPTR " SgPointerAssignOp::pool_size = %d \n",
  161567             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPointerAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPointerAssignOp),SgPointerAssignOp::pool_size);
  161568             :         }
  161569             : #endif
  161570             : 
  161571           0 :         SgPointerAssignOp * pointer = (SgPointerAssignOp*) ROSE_MALLOC ( SgPointerAssignOp::pool_size * sizeof(SgPointerAssignOp) );
  161572           0 :         assert( pointer != NULL );
  161573             : #if ROSE_ALLOC_MEMSET == 1
  161574             :         memset(pointer, 0x00, SgPointerAssignOp::pool_size * sizeof(SgPointerAssignOp));
  161575             : #elif ROSE_ALLOC_MEMSET == 2
  161576             :         memset(pointer, 0xCC, SgPointerAssignOp::pool_size * sizeof(SgPointerAssignOp));
  161577             : #endif
  161578           0 :         SgPointerAssignOp::pools.push_back( (unsigned char*)(pointer) );
  161579           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPointerAssignOp::pool_size * sizeof(SgPointerAssignOp), V_SgPointerAssignOp ) );
  161580             : 
  161581           0 :         if ( SgPointerAssignOp::next_node != NULL ) {
  161582           0 :           if ( blockIndex > 0 ) {
  161583           0 :             SgPointerAssignOp * blkptr = (SgPointerAssignOp*)(SgPointerAssignOp::pools[blockIndex-1]);
  161584           0 :             blkptr[ SgPointerAssignOp::pool_size - 1 ].set_freepointer(pointer);
  161585             :           }
  161586             :         } else {
  161587           0 :           SgPointerAssignOp::next_node = pointer;
  161588             :         }
  161589             : 
  161590           0 :         for (unsigned i = 0; i < SgPointerAssignOp::pool_size-1; ++i)
  161591             :            {
  161592           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  161593             :            }
  161594           0 :         pointer[ SgPointerAssignOp::pool_size -1 ].set_freepointer(NULL);
  161595             : 
  161596           0 :         blockIndex++;
  161597             :       }
  161598           2 :   }
  161599             : 
  161600             : //############################################################################
  161601             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  161602             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  161603             :  * not compressed. However, that stuff is not yet implemented! 
  161604             :  */
  161605             : unsigned long
  161606           0 : SgPointerAssignOp::getNumberOfLastValidPointer()
  161607             :    {
  161608           0 :       SgPointerAssignOp* testPointer = (SgPointerAssignOp*)(SgPointerAssignOp::pools.back());
  161609           0 :       unsigned long localIndex = SgPointerAssignOp::pool_size - 1;
  161610           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  161611             :          {
  161612           0 :            localIndex--;
  161613             :          }
  161614           0 :       return (localIndex + SgPointerAssignOp::pool_size * (SgPointerAssignOp::pools.size()-1));
  161615             :    }
  161616             : 
  161617             : //############################################################################
  161618             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  161619             :  * memory pool and initializes the data member in class SgPointerAssignOpStroageClass
  161620             :  * from its counterpart of SgPointerAssignOp. The return value is just for checking, 
  161621             :  * that the whole StorageClassArray is initialized!
  161622             :  */
  161623             : unsigned long
  161624           0 : SgPointerAssignOp::initializeStorageClassArray( SgPointerAssignOpStorageClass *storageArray )
  161625             :    {
  161626           0 :      unsigned long storageCounter = 0;
  161627           0 :      std::vector < unsigned char* > :: const_iterator block = SgPointerAssignOp::pools.begin();
  161628           0 :      SgPointerAssignOp* pointer = NULL;
  161629           0 :      while ( block != SgPointerAssignOp::pools.end() ) {
  161630           0 :           pointer = (SgPointerAssignOp*) (*block);
  161631           0 :           for ( unsigned i = 0; i < SgPointerAssignOp::pool_size; ++i ) {
  161632           0 :                if ( pointer->get_freepointer() != NULL ) {
  161633           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  161634           0 :                  storageArray++;
  161635           0 :                  storageCounter++;
  161636             :                }
  161637           0 :                pointer++;
  161638             :              }
  161639           0 :            block++;
  161640             :         }
  161641           0 :      return storageCounter;
  161642             :    }
  161643             : 
  161644             : /* #line 161645 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  161645             : 
  161646             : 
  161647             : 
  161648             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  161649             : 
  161650             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  161651             : 
  161652             : //############################################################################
  161653             : /* JH (02/02/2006) Constructor of the IR node SgUserDefinedBinaryOp that takes its 
  161654             :  * corresponding StorageClass as parameter
  161655             :  */
  161656           0 : SgUserDefinedBinaryOp :: SgUserDefinedBinaryOp ( const SgUserDefinedBinaryOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  161657             :    {
  161658             : 
  161659             : 
  161660             : /* #line 161661 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  161661             : 
  161662           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  161663           0 :      p_operator_name = SgName ( storageSource.storageOf_operator_name ) ;
  161664           0 :      p_symbol =  (SgFunctionSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol) );
  161665             : 
  161666             : 
  161667             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  161668             : 
  161669             : 
  161670           0 :    }
  161671             : 
  161672             : //############################################################################
  161673             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  161674             :  * within the working AST. 
  161675             :  */
  161676           0 : SgUserDefinedBinaryOp * SgUserDefinedBinaryOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  161677           0 :      SgUserDefinedBinaryOp* returnPointer = NULL;
  161678           0 :      if ( globalIndex != 0 )
  161679             :         {
  161680             : 
  161681             : #if FILE_IO_EXTRA_CHECK
  161682           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUserDefinedBinaryOp ) ) <= globalIndex ) ;
  161683           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUserDefinedBinaryOp + 1 ) ) );
  161684             : #endif
  161685           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUserDefinedBinaryOp )  
  161686           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUserDefinedBinaryOp );
  161687           0 :           unsigned long positionInPool = localIndex % SgUserDefinedBinaryOp::pool_size;
  161688           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUserDefinedBinaryOp::pool_size;
  161689             : 
  161690             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  161691             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  161692             : 
  161693           0 :           returnPointer = &( ( (SgUserDefinedBinaryOp*)(SgUserDefinedBinaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  161694             : 
  161695           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  161696             :         }
  161697           0 :      return returnPointer ;
  161698             :    }
  161699             : 
  161700             : //############################################################################
  161701             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  161702             :   for the AST with the index astIndex
  161703             : */
  161704           0 : SgUserDefinedBinaryOp * SgUserDefinedBinaryOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  161705           0 :      SgUserDefinedBinaryOp* returnPointer = NULL;
  161706           0 :      if ( globalIndex != 0 )
  161707             :         {
  161708             : 
  161709             : #if FILE_IO_EXTRA_CHECK
  161710           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUserDefinedBinaryOp ) ) <= globalIndex ) ;
  161711           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUserDefinedBinaryOp + 1 ) ) );
  161712             : #endif
  161713           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUserDefinedBinaryOp )
  161714           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUserDefinedBinaryOp );
  161715           0 :           unsigned long positionInPool = localIndex % SgUserDefinedBinaryOp::pool_size ;
  161716           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUserDefinedBinaryOp::pool_size ;
  161717             : 
  161718             : #if FILE_IO_EXTRA_CHECK
  161719             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  161720             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  161721             : #endif
  161722             : 
  161723           0 :           returnPointer = &( ( (SgUserDefinedBinaryOp*)(SgUserDefinedBinaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  161724             : 
  161725             : #if FILE_IO_EXTRA_CHECK
  161726           0 :           assert ( returnPointer != NULL ) ;
  161727             : #endif
  161728             :         }
  161729           0 :      return returnPointer ;
  161730             :    }
  161731             : 
  161732             : //############################################################################
  161733             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  161734             :  * pool size! We set for every valid object in the memory pool the freepointer
  161735             :  * to the global index and increase the global index afterwards. For all the 
  161736             :  * invalid objects (means address ranges within the memory pool that were not
  161737             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  161738             :  * distinguish valid from invalid objects! 
  161739             :  */
  161740             : unsigned long
  161741           5 : SgUserDefinedBinaryOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  161742             :    {
  161743           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  161744           5 :      SgUserDefinedBinaryOp* pointer = NULL;
  161745           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  161746           5 :      std::vector < unsigned char* > :: const_iterator block;
  161747           5 :      for ( block = SgUserDefinedBinaryOp::pools.begin(); block != SgUserDefinedBinaryOp::pools.end() ; ++block )
  161748             :         {
  161749           0 :           pointer = (SgUserDefinedBinaryOp*)(*block);
  161750           0 :           for (unsigned i = 0; i < SgUserDefinedBinaryOp::pool_size; ++i )
  161751             :              {
  161752             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  161753             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  161754             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  161755             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  161756             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  161757             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  161758             :             // properly; so this will have to be checked next.
  161759             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  161760             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  161761           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  161762             :                   {
  161763           0 :                     pointer[i].set_freepointer((SgUserDefinedBinaryOp*)(globalIndex));
  161764           0 :                     globalIndex++;
  161765             :                   }
  161766             :                else
  161767             :                   {
  161768           0 :                     pointer[i].set_freepointer(NULL);
  161769             :                   }
  161770             :               }
  161771             :         }
  161772           5 :      return globalIndex;
  161773             :    }
  161774             : 
  161775             : //############################################################################
  161776             : // JH (01/14/2006)
  161777             : void
  161778           5 : SgUserDefinedBinaryOp::resetValidFreepointers( )
  161779             :    {
  161780           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  161781           5 :      SgUserDefinedBinaryOp* pointer = NULL;
  161782           5 :      std::vector < unsigned char* > :: const_iterator block;
  161783           5 :      SgUserDefinedBinaryOp* pointerOfLinkedList = NULL;
  161784           5 :      for ( block = SgUserDefinedBinaryOp::pools.begin(); block != SgUserDefinedBinaryOp::pools.end() ; ++block )
  161785             :         {
  161786           0 :           pointer = (SgUserDefinedBinaryOp*)(*block);
  161787           0 :           for (unsigned i = 0; i < SgUserDefinedBinaryOp::pool_size; ++i )
  161788             :              {
  161789             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  161790             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  161791             :             // memory blocks!.
  161792           0 :                if ( pointer[i].get_freepointer() != NULL )
  161793             :                   {
  161794           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  161795             :                   }
  161796             :                else
  161797             :                   {
  161798           0 :                     if ( pointerOfLinkedList == NULL )
  161799             :                        {
  161800           0 :                          SgUserDefinedBinaryOp::next_node = &(pointer[i]);
  161801             :                        }
  161802             :                     else
  161803             :                        {
  161804             :                       // printf ("In SgUserDefinedBinaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  161805           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  161806             :                        }
  161807             :                     pointerOfLinkedList = &(pointer[i]);
  161808             :                   }
  161809             :               }
  161810             :         }
  161811             : 
  161812           5 :      if ( pointerOfLinkedList != NULL )
  161813             :         {
  161814             :        // printf ("In SgUserDefinedBinaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  161815           0 :           pointerOfLinkedList->set_freepointer(NULL);
  161816             :        // DQ (6/6/2010): Temporary debugging...
  161817             :        //   ROSE_ASSERT(false);
  161818             :         }
  161819             : 
  161820           5 :      return ;
  161821             :    }
  161822             : 
  161823             : //############################################################################
  161824             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  161825             :  * within the memory pool and resets the freepointers, in order to achieve a 
  161826             :  * linked list, that has no jumps and starts at the beginning! This function 
  161827             :  * does not extend the memory pool, since we do not delete any memory blocks,
  161828             :  * but delete the valid objects.  
  161829             :  */
  161830             : void
  161831           0 : SgUserDefinedBinaryOp::clearMemoryPool( )
  161832             :    {
  161833             :   // printf ("Inside of SgUserDefinedBinaryOp::clearMemoryPool() \n");
  161834             : 
  161835           0 :      SgUserDefinedBinaryOp* pointer = NULL, *tempPointer = NULL;
  161836           0 :      std::vector < unsigned char* > :: const_iterator block;
  161837           0 :      if ( SgUserDefinedBinaryOp::pools.empty() == false )
  161838             :         {
  161839           0 :           block = SgUserDefinedBinaryOp::pools.begin() ;
  161840           0 :           SgUserDefinedBinaryOp::next_node = (SgUserDefinedBinaryOp*) (*block);
  161841             : 
  161842           0 :           while ( block != SgUserDefinedBinaryOp::pools.end() )
  161843             :              {
  161844           0 :                pointer = (SgUserDefinedBinaryOp*) (*block);
  161845           0 :                if ( tempPointer != NULL )
  161846             :                   {
  161847           0 :                     tempPointer->set_freepointer(pointer);
  161848             :                   }
  161849           0 :                for (unsigned i = 0; i < SgUserDefinedBinaryOp::pool_size - 1; ++i)
  161850             :                   {
  161851           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  161852             :                   }
  161853           0 :                 pointer[SgUserDefinedBinaryOp::pool_size-1].set_freepointer(NULL);
  161854           0 :                 tempPointer = &(pointer[SgUserDefinedBinaryOp::pool_size-1]);
  161855           0 :                 ++block;
  161856             :              }
  161857             :         }
  161858           0 :    }
  161859             : 
  161860           5 : void SgUserDefinedBinaryOp::deleteMemoryPool() {
  161861           5 :   for (auto p: SgUserDefinedBinaryOp::pools) {
  161862           0 :     ROSE_FREE(p);
  161863             :   }
  161864           5 :   SgUserDefinedBinaryOp::next_node = nullptr;
  161865           5 :   SgUserDefinedBinaryOp::pools.clear();
  161866           5 : }
  161867             : 
  161868             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  161869             : //                 reading multiple binary files to for a single AST.
  161870             : /////////// new version ////////////////////////////////
  161871             : //############################################################################
  161872             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  161873             : void
  161874           2 : SgUserDefinedBinaryOp::extendMemoryPoolForFileIO( )
  161875             :   {
  161876           2 :     size_t blockIndex = SgUserDefinedBinaryOp::pools.size();
  161877           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUserDefinedBinaryOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUserDefinedBinaryOp);
  161878             : 
  161879           2 :     while ( (blockIndex * SgUserDefinedBinaryOp::pool_size) < newPoolSize)
  161880             :       {
  161881             : #if ROSE_ALLOC_TRACE
  161882             :         if (blockIndex > 0) {
  161883             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUserDefinedBinaryOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUserDefinedBinaryOp) = %" PRIuPTR " SgUserDefinedBinaryOp::pool_size = %d \n",
  161884             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUserDefinedBinaryOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUserDefinedBinaryOp),SgUserDefinedBinaryOp::pool_size);
  161885             :         }
  161886             : #endif
  161887             : 
  161888           0 :         SgUserDefinedBinaryOp * pointer = (SgUserDefinedBinaryOp*) ROSE_MALLOC ( SgUserDefinedBinaryOp::pool_size * sizeof(SgUserDefinedBinaryOp) );
  161889           0 :         assert( pointer != NULL );
  161890             : #if ROSE_ALLOC_MEMSET == 1
  161891             :         memset(pointer, 0x00, SgUserDefinedBinaryOp::pool_size * sizeof(SgUserDefinedBinaryOp));
  161892             : #elif ROSE_ALLOC_MEMSET == 2
  161893             :         memset(pointer, 0xCC, SgUserDefinedBinaryOp::pool_size * sizeof(SgUserDefinedBinaryOp));
  161894             : #endif
  161895           0 :         SgUserDefinedBinaryOp::pools.push_back( (unsigned char*)(pointer) );
  161896           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUserDefinedBinaryOp::pool_size * sizeof(SgUserDefinedBinaryOp), V_SgUserDefinedBinaryOp ) );
  161897             : 
  161898           0 :         if ( SgUserDefinedBinaryOp::next_node != NULL ) {
  161899           0 :           if ( blockIndex > 0 ) {
  161900           0 :             SgUserDefinedBinaryOp * blkptr = (SgUserDefinedBinaryOp*)(SgUserDefinedBinaryOp::pools[blockIndex-1]);
  161901           0 :             blkptr[ SgUserDefinedBinaryOp::pool_size - 1 ].set_freepointer(pointer);
  161902             :           }
  161903             :         } else {
  161904           0 :           SgUserDefinedBinaryOp::next_node = pointer;
  161905             :         }
  161906             : 
  161907           0 :         for (unsigned i = 0; i < SgUserDefinedBinaryOp::pool_size-1; ++i)
  161908             :            {
  161909           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  161910             :            }
  161911           0 :         pointer[ SgUserDefinedBinaryOp::pool_size -1 ].set_freepointer(NULL);
  161912             : 
  161913           0 :         blockIndex++;
  161914             :       }
  161915           2 :   }
  161916             : 
  161917             : //############################################################################
  161918             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  161919             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  161920             :  * not compressed. However, that stuff is not yet implemented! 
  161921             :  */
  161922             : unsigned long
  161923           0 : SgUserDefinedBinaryOp::getNumberOfLastValidPointer()
  161924             :    {
  161925           0 :       SgUserDefinedBinaryOp* testPointer = (SgUserDefinedBinaryOp*)(SgUserDefinedBinaryOp::pools.back());
  161926           0 :       unsigned long localIndex = SgUserDefinedBinaryOp::pool_size - 1;
  161927           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  161928             :          {
  161929           0 :            localIndex--;
  161930             :          }
  161931           0 :       return (localIndex + SgUserDefinedBinaryOp::pool_size * (SgUserDefinedBinaryOp::pools.size()-1));
  161932             :    }
  161933             : 
  161934             : //############################################################################
  161935             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  161936             :  * memory pool and initializes the data member in class SgUserDefinedBinaryOpStroageClass
  161937             :  * from its counterpart of SgUserDefinedBinaryOp. The return value is just for checking, 
  161938             :  * that the whole StorageClassArray is initialized!
  161939             :  */
  161940             : unsigned long
  161941           0 : SgUserDefinedBinaryOp::initializeStorageClassArray( SgUserDefinedBinaryOpStorageClass *storageArray )
  161942             :    {
  161943           0 :      unsigned long storageCounter = 0;
  161944           0 :      std::vector < unsigned char* > :: const_iterator block = SgUserDefinedBinaryOp::pools.begin();
  161945           0 :      SgUserDefinedBinaryOp* pointer = NULL;
  161946           0 :      while ( block != SgUserDefinedBinaryOp::pools.end() ) {
  161947           0 :           pointer = (SgUserDefinedBinaryOp*) (*block);
  161948           0 :           for ( unsigned i = 0; i < SgUserDefinedBinaryOp::pool_size; ++i ) {
  161949           0 :                if ( pointer->get_freepointer() != NULL ) {
  161950           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  161951           0 :                  storageArray++;
  161952           0 :                  storageCounter++;
  161953             :                }
  161954           0 :                pointer++;
  161955             :              }
  161956           0 :            block++;
  161957             :         }
  161958           0 :      return storageCounter;
  161959             :    }
  161960             : 
  161961             : /* #line 161962 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  161962             : 
  161963             : 
  161964             : 
  161965             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  161966             : 
  161967             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  161968             : 
  161969             : //############################################################################
  161970             : /* JH (02/02/2006) Constructor of the IR node SgCompoundAssignOp that takes its 
  161971             :  * corresponding StorageClass as parameter
  161972             :  */
  161973          51 : SgCompoundAssignOp :: SgCompoundAssignOp ( const SgCompoundAssignOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  161974             :    {
  161975             : 
  161976             : 
  161977             : /* #line 161978 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  161978             : 
  161979          51 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  161980             : 
  161981             : 
  161982             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  161983             : 
  161984             : 
  161985          51 :    }
  161986             : 
  161987             : //############################################################################
  161988             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  161989             :  * within the working AST. 
  161990             :  */
  161991           0 : SgCompoundAssignOp * SgCompoundAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  161992           0 :      SgCompoundAssignOp* returnPointer = NULL;
  161993           0 :      if ( globalIndex != 0 )
  161994             :         {
  161995             : 
  161996             : #if FILE_IO_EXTRA_CHECK
  161997           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCompoundAssignOp ) ) <= globalIndex ) ;
  161998           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCompoundAssignOp + 1 ) ) );
  161999             : #endif
  162000           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCompoundAssignOp )  
  162001           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCompoundAssignOp );
  162002           0 :           unsigned long positionInPool = localIndex % SgCompoundAssignOp::pool_size;
  162003           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCompoundAssignOp::pool_size;
  162004             : 
  162005             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  162006             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  162007             : 
  162008           0 :           returnPointer = &( ( (SgCompoundAssignOp*)(SgCompoundAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  162009             : 
  162010           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  162011             :         }
  162012           0 :      return returnPointer ;
  162013             :    }
  162014             : 
  162015             : //############################################################################
  162016             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  162017             :   for the AST with the index astIndex
  162018             : */
  162019           0 : SgCompoundAssignOp * SgCompoundAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  162020           0 :      SgCompoundAssignOp* returnPointer = NULL;
  162021           0 :      if ( globalIndex != 0 )
  162022             :         {
  162023             : 
  162024             : #if FILE_IO_EXTRA_CHECK
  162025           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCompoundAssignOp ) ) <= globalIndex ) ;
  162026           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCompoundAssignOp + 1 ) ) );
  162027             : #endif
  162028           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCompoundAssignOp )
  162029           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCompoundAssignOp );
  162030           0 :           unsigned long positionInPool = localIndex % SgCompoundAssignOp::pool_size ;
  162031           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCompoundAssignOp::pool_size ;
  162032             : 
  162033             : #if FILE_IO_EXTRA_CHECK
  162034             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  162035             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  162036             : #endif
  162037             : 
  162038           0 :           returnPointer = &( ( (SgCompoundAssignOp*)(SgCompoundAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  162039             : 
  162040             : #if FILE_IO_EXTRA_CHECK
  162041           0 :           assert ( returnPointer != NULL ) ;
  162042             : #endif
  162043             :         }
  162044           0 :      return returnPointer ;
  162045             :    }
  162046             : 
  162047             : //############################################################################
  162048             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  162049             :  * pool size! We set for every valid object in the memory pool the freepointer
  162050             :  * to the global index and increase the global index afterwards. For all the 
  162051             :  * invalid objects (means address ranges within the memory pool that were not
  162052             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  162053             :  * distinguish valid from invalid objects! 
  162054             :  */
  162055             : unsigned long
  162056           5 : SgCompoundAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  162057             :    {
  162058           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  162059           5 :      SgCompoundAssignOp* pointer = NULL;
  162060           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  162061           5 :      std::vector < unsigned char* > :: const_iterator block;
  162062           5 :      for ( block = SgCompoundAssignOp::pools.begin(); block != SgCompoundAssignOp::pools.end() ; ++block )
  162063             :         {
  162064           0 :           pointer = (SgCompoundAssignOp*)(*block);
  162065           0 :           for (unsigned i = 0; i < SgCompoundAssignOp::pool_size; ++i )
  162066             :              {
  162067             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  162068             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  162069             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  162070             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  162071             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  162072             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  162073             :             // properly; so this will have to be checked next.
  162074             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  162075             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  162076           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  162077             :                   {
  162078           0 :                     pointer[i].set_freepointer((SgCompoundAssignOp*)(globalIndex));
  162079           0 :                     globalIndex++;
  162080             :                   }
  162081             :                else
  162082             :                   {
  162083           0 :                     pointer[i].set_freepointer(NULL);
  162084             :                   }
  162085             :               }
  162086             :         }
  162087           5 :      return globalIndex;
  162088             :    }
  162089             : 
  162090             : //############################################################################
  162091             : // JH (01/14/2006)
  162092             : void
  162093           5 : SgCompoundAssignOp::resetValidFreepointers( )
  162094             :    {
  162095           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  162096           5 :      SgCompoundAssignOp* pointer = NULL;
  162097           5 :      std::vector < unsigned char* > :: const_iterator block;
  162098           5 :      SgCompoundAssignOp* pointerOfLinkedList = NULL;
  162099           5 :      for ( block = SgCompoundAssignOp::pools.begin(); block != SgCompoundAssignOp::pools.end() ; ++block )
  162100             :         {
  162101           0 :           pointer = (SgCompoundAssignOp*)(*block);
  162102           0 :           for (unsigned i = 0; i < SgCompoundAssignOp::pool_size; ++i )
  162103             :              {
  162104             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  162105             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  162106             :             // memory blocks!.
  162107           0 :                if ( pointer[i].get_freepointer() != NULL )
  162108             :                   {
  162109           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  162110             :                   }
  162111             :                else
  162112             :                   {
  162113           0 :                     if ( pointerOfLinkedList == NULL )
  162114             :                        {
  162115           0 :                          SgCompoundAssignOp::next_node = &(pointer[i]);
  162116             :                        }
  162117             :                     else
  162118             :                        {
  162119             :                       // printf ("In SgCompoundAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  162120           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  162121             :                        }
  162122             :                     pointerOfLinkedList = &(pointer[i]);
  162123             :                   }
  162124             :               }
  162125             :         }
  162126             : 
  162127           5 :      if ( pointerOfLinkedList != NULL )
  162128             :         {
  162129             :        // printf ("In SgCompoundAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  162130           0 :           pointerOfLinkedList->set_freepointer(NULL);
  162131             :        // DQ (6/6/2010): Temporary debugging...
  162132             :        //   ROSE_ASSERT(false);
  162133             :         }
  162134             : 
  162135           5 :      return ;
  162136             :    }
  162137             : 
  162138             : //############################################################################
  162139             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  162140             :  * within the memory pool and resets the freepointers, in order to achieve a 
  162141             :  * linked list, that has no jumps and starts at the beginning! This function 
  162142             :  * does not extend the memory pool, since we do not delete any memory blocks,
  162143             :  * but delete the valid objects.  
  162144             :  */
  162145             : void
  162146           0 : SgCompoundAssignOp::clearMemoryPool( )
  162147             :    {
  162148             :   // printf ("Inside of SgCompoundAssignOp::clearMemoryPool() \n");
  162149             : 
  162150           0 :      SgCompoundAssignOp* pointer = NULL, *tempPointer = NULL;
  162151           0 :      std::vector < unsigned char* > :: const_iterator block;
  162152           0 :      if ( SgCompoundAssignOp::pools.empty() == false )
  162153             :         {
  162154           0 :           block = SgCompoundAssignOp::pools.begin() ;
  162155           0 :           SgCompoundAssignOp::next_node = (SgCompoundAssignOp*) (*block);
  162156             : 
  162157           0 :           while ( block != SgCompoundAssignOp::pools.end() )
  162158             :              {
  162159           0 :                pointer = (SgCompoundAssignOp*) (*block);
  162160           0 :                if ( tempPointer != NULL )
  162161             :                   {
  162162           0 :                     tempPointer->set_freepointer(pointer);
  162163             :                   }
  162164           0 :                for (unsigned i = 0; i < SgCompoundAssignOp::pool_size - 1; ++i)
  162165             :                   {
  162166           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  162167             :                   }
  162168           0 :                 pointer[SgCompoundAssignOp::pool_size-1].set_freepointer(NULL);
  162169           0 :                 tempPointer = &(pointer[SgCompoundAssignOp::pool_size-1]);
  162170           0 :                 ++block;
  162171             :              }
  162172             :         }
  162173           0 :    }
  162174             : 
  162175           5 : void SgCompoundAssignOp::deleteMemoryPool() {
  162176           5 :   for (auto p: SgCompoundAssignOp::pools) {
  162177           0 :     ROSE_FREE(p);
  162178             :   }
  162179           5 :   SgCompoundAssignOp::next_node = nullptr;
  162180           5 :   SgCompoundAssignOp::pools.clear();
  162181           5 : }
  162182             : 
  162183             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  162184             : //                 reading multiple binary files to for a single AST.
  162185             : /////////// new version ////////////////////////////////
  162186             : //############################################################################
  162187             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  162188             : void
  162189           2 : SgCompoundAssignOp::extendMemoryPoolForFileIO( )
  162190             :   {
  162191           2 :     size_t blockIndex = SgCompoundAssignOp::pools.size();
  162192           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundAssignOp);
  162193             : 
  162194           2 :     while ( (blockIndex * SgCompoundAssignOp::pool_size) < newPoolSize)
  162195             :       {
  162196             : #if ROSE_ALLOC_TRACE
  162197             :         if (blockIndex > 0) {
  162198             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundAssignOp) = %" PRIuPTR " SgCompoundAssignOp::pool_size = %d \n",
  162199             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundAssignOp),SgCompoundAssignOp::pool_size);
  162200             :         }
  162201             : #endif
  162202             : 
  162203           0 :         SgCompoundAssignOp * pointer = (SgCompoundAssignOp*) ROSE_MALLOC ( SgCompoundAssignOp::pool_size * sizeof(SgCompoundAssignOp) );
  162204           0 :         assert( pointer != NULL );
  162205             : #if ROSE_ALLOC_MEMSET == 1
  162206             :         memset(pointer, 0x00, SgCompoundAssignOp::pool_size * sizeof(SgCompoundAssignOp));
  162207             : #elif ROSE_ALLOC_MEMSET == 2
  162208             :         memset(pointer, 0xCC, SgCompoundAssignOp::pool_size * sizeof(SgCompoundAssignOp));
  162209             : #endif
  162210           0 :         SgCompoundAssignOp::pools.push_back( (unsigned char*)(pointer) );
  162211           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCompoundAssignOp::pool_size * sizeof(SgCompoundAssignOp), V_SgCompoundAssignOp ) );
  162212             : 
  162213           0 :         if ( SgCompoundAssignOp::next_node != NULL ) {
  162214           0 :           if ( blockIndex > 0 ) {
  162215           0 :             SgCompoundAssignOp * blkptr = (SgCompoundAssignOp*)(SgCompoundAssignOp::pools[blockIndex-1]);
  162216           0 :             blkptr[ SgCompoundAssignOp::pool_size - 1 ].set_freepointer(pointer);
  162217             :           }
  162218             :         } else {
  162219           0 :           SgCompoundAssignOp::next_node = pointer;
  162220             :         }
  162221             : 
  162222           0 :         for (unsigned i = 0; i < SgCompoundAssignOp::pool_size-1; ++i)
  162223             :            {
  162224           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  162225             :            }
  162226           0 :         pointer[ SgCompoundAssignOp::pool_size -1 ].set_freepointer(NULL);
  162227             : 
  162228           0 :         blockIndex++;
  162229             :       }
  162230           2 :   }
  162231             : 
  162232             : //############################################################################
  162233             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  162234             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  162235             :  * not compressed. However, that stuff is not yet implemented! 
  162236             :  */
  162237             : unsigned long
  162238           0 : SgCompoundAssignOp::getNumberOfLastValidPointer()
  162239             :    {
  162240           0 :       SgCompoundAssignOp* testPointer = (SgCompoundAssignOp*)(SgCompoundAssignOp::pools.back());
  162241           0 :       unsigned long localIndex = SgCompoundAssignOp::pool_size - 1;
  162242           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  162243             :          {
  162244           0 :            localIndex--;
  162245             :          }
  162246           0 :       return (localIndex + SgCompoundAssignOp::pool_size * (SgCompoundAssignOp::pools.size()-1));
  162247             :    }
  162248             : 
  162249             : //############################################################################
  162250             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  162251             :  * memory pool and initializes the data member in class SgCompoundAssignOpStroageClass
  162252             :  * from its counterpart of SgCompoundAssignOp. The return value is just for checking, 
  162253             :  * that the whole StorageClassArray is initialized!
  162254             :  */
  162255             : unsigned long
  162256           0 : SgCompoundAssignOp::initializeStorageClassArray( SgCompoundAssignOpStorageClass *storageArray )
  162257             :    {
  162258           0 :      unsigned long storageCounter = 0;
  162259           0 :      std::vector < unsigned char* > :: const_iterator block = SgCompoundAssignOp::pools.begin();
  162260           0 :      SgCompoundAssignOp* pointer = NULL;
  162261           0 :      while ( block != SgCompoundAssignOp::pools.end() ) {
  162262           0 :           pointer = (SgCompoundAssignOp*) (*block);
  162263           0 :           for ( unsigned i = 0; i < SgCompoundAssignOp::pool_size; ++i ) {
  162264           0 :                if ( pointer->get_freepointer() != NULL ) {
  162265           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  162266           0 :                  storageArray++;
  162267           0 :                  storageCounter++;
  162268             :                }
  162269           0 :                pointer++;
  162270             :              }
  162271           0 :            block++;
  162272             :         }
  162273           0 :      return storageCounter;
  162274             :    }
  162275             : 
  162276             : /* #line 162277 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  162277             : 
  162278             : 
  162279             : 
  162280             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  162281             : 
  162282             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  162283             : 
  162284             : //############################################################################
  162285             : /* JH (02/02/2006) Constructor of the IR node SgPlusAssignOp that takes its 
  162286             :  * corresponding StorageClass as parameter
  162287             :  */
  162288          29 : SgPlusAssignOp :: SgPlusAssignOp ( const SgPlusAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  162289             :    {
  162290             : 
  162291             : 
  162292             : /* #line 162293 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  162293             : 
  162294          29 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  162295             : 
  162296             : 
  162297             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  162298             : 
  162299             : 
  162300          29 :    }
  162301             : 
  162302             : //############################################################################
  162303             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  162304             :  * within the working AST. 
  162305             :  */
  162306         174 : SgPlusAssignOp * SgPlusAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  162307         174 :      SgPlusAssignOp* returnPointer = NULL;
  162308         174 :      if ( globalIndex != 0 )
  162309             :         {
  162310             : 
  162311             : #if FILE_IO_EXTRA_CHECK
  162312         174 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPlusAssignOp ) ) <= globalIndex ) ;
  162313         174 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPlusAssignOp + 1 ) ) );
  162314             : #endif
  162315         174 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPlusAssignOp )  
  162316         174 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPlusAssignOp );
  162317         174 :           unsigned long positionInPool = localIndex % SgPlusAssignOp::pool_size;
  162318         174 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPlusAssignOp::pool_size;
  162319             : 
  162320             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  162321             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  162322             : 
  162323         174 :           returnPointer = &( ( (SgPlusAssignOp*)(SgPlusAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  162324             : 
  162325         174 :           ROSE_ASSERT( returnPointer != NULL ) ;
  162326             :         }
  162327         174 :      return returnPointer ;
  162328             :    }
  162329             : 
  162330             : //############################################################################
  162331             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  162332             :   for the AST with the index astIndex
  162333             : */
  162334           0 : SgPlusAssignOp * SgPlusAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  162335           0 :      SgPlusAssignOp* returnPointer = NULL;
  162336           0 :      if ( globalIndex != 0 )
  162337             :         {
  162338             : 
  162339             : #if FILE_IO_EXTRA_CHECK
  162340           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPlusAssignOp ) ) <= globalIndex ) ;
  162341           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPlusAssignOp + 1 ) ) );
  162342             : #endif
  162343           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPlusAssignOp )
  162344           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPlusAssignOp );
  162345           0 :           unsigned long positionInPool = localIndex % SgPlusAssignOp::pool_size ;
  162346           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPlusAssignOp::pool_size ;
  162347             : 
  162348             : #if FILE_IO_EXTRA_CHECK
  162349             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  162350             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  162351             : #endif
  162352             : 
  162353           0 :           returnPointer = &( ( (SgPlusAssignOp*)(SgPlusAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  162354             : 
  162355             : #if FILE_IO_EXTRA_CHECK
  162356           0 :           assert ( returnPointer != NULL ) ;
  162357             : #endif
  162358             :         }
  162359           0 :      return returnPointer ;
  162360             :    }
  162361             : 
  162362             : //############################################################################
  162363             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  162364             :  * pool size! We set for every valid object in the memory pool the freepointer
  162365             :  * to the global index and increase the global index afterwards. For all the 
  162366             :  * invalid objects (means address ranges within the memory pool that were not
  162367             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  162368             :  * distinguish valid from invalid objects! 
  162369             :  */
  162370             : unsigned long
  162371           5 : SgPlusAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  162372             :    {
  162373           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  162374           5 :      SgPlusAssignOp* pointer = NULL;
  162375           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  162376           5 :      std::vector < unsigned char* > :: const_iterator block;
  162377           6 :      for ( block = SgPlusAssignOp::pools.begin(); block != SgPlusAssignOp::pools.end() ; ++block )
  162378             :         {
  162379           1 :           pointer = (SgPlusAssignOp*)(*block);
  162380        2001 :           for (unsigned i = 0; i < SgPlusAssignOp::pool_size; ++i )
  162381             :              {
  162382             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  162383             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  162384             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  162385             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  162386             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  162387             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  162388             :             // properly; so this will have to be checked next.
  162389             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  162390             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  162391        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  162392             :                   {
  162393          29 :                     pointer[i].set_freepointer((SgPlusAssignOp*)(globalIndex));
  162394          29 :                     globalIndex++;
  162395             :                   }
  162396             :                else
  162397             :                   {
  162398        1971 :                     pointer[i].set_freepointer(NULL);
  162399             :                   }
  162400             :               }
  162401             :         }
  162402           5 :      return globalIndex;
  162403             :    }
  162404             : 
  162405             : //############################################################################
  162406             : // JH (01/14/2006)
  162407             : void
  162408           5 : SgPlusAssignOp::resetValidFreepointers( )
  162409             :    {
  162410           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  162411           5 :      SgPlusAssignOp* pointer = NULL;
  162412           5 :      std::vector < unsigned char* > :: const_iterator block;
  162413           5 :      SgPlusAssignOp* pointerOfLinkedList = NULL;
  162414           6 :      for ( block = SgPlusAssignOp::pools.begin(); block != SgPlusAssignOp::pools.end() ; ++block )
  162415             :         {
  162416           1 :           pointer = (SgPlusAssignOp*)(*block);
  162417        2001 :           for (unsigned i = 0; i < SgPlusAssignOp::pool_size; ++i )
  162418             :              {
  162419             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  162420             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  162421             :             // memory blocks!.
  162422        2000 :                if ( pointer[i].get_freepointer() != NULL )
  162423             :                   {
  162424          29 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  162425             :                   }
  162426             :                else
  162427             :                   {
  162428        1971 :                     if ( pointerOfLinkedList == NULL )
  162429             :                        {
  162430           1 :                          SgPlusAssignOp::next_node = &(pointer[i]);
  162431             :                        }
  162432             :                     else
  162433             :                        {
  162434             :                       // printf ("In SgPlusAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  162435        1970 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  162436             :                        }
  162437             :                     pointerOfLinkedList = &(pointer[i]);
  162438             :                   }
  162439             :               }
  162440             :         }
  162441             : 
  162442           5 :      if ( pointerOfLinkedList != NULL )
  162443             :         {
  162444             :        // printf ("In SgPlusAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  162445           1 :           pointerOfLinkedList->set_freepointer(NULL);
  162446             :        // DQ (6/6/2010): Temporary debugging...
  162447             :        //   ROSE_ASSERT(false);
  162448             :         }
  162449             : 
  162450           5 :      return ;
  162451             :    }
  162452             : 
  162453             : //############################################################################
  162454             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  162455             :  * within the memory pool and resets the freepointers, in order to achieve a 
  162456             :  * linked list, that has no jumps and starts at the beginning! This function 
  162457             :  * does not extend the memory pool, since we do not delete any memory blocks,
  162458             :  * but delete the valid objects.  
  162459             :  */
  162460             : void
  162461           0 : SgPlusAssignOp::clearMemoryPool( )
  162462             :    {
  162463             :   // printf ("Inside of SgPlusAssignOp::clearMemoryPool() \n");
  162464             : 
  162465           0 :      SgPlusAssignOp* pointer = NULL, *tempPointer = NULL;
  162466           0 :      std::vector < unsigned char* > :: const_iterator block;
  162467           0 :      if ( SgPlusAssignOp::pools.empty() == false )
  162468             :         {
  162469           0 :           block = SgPlusAssignOp::pools.begin() ;
  162470           0 :           SgPlusAssignOp::next_node = (SgPlusAssignOp*) (*block);
  162471             : 
  162472           0 :           while ( block != SgPlusAssignOp::pools.end() )
  162473             :              {
  162474           0 :                pointer = (SgPlusAssignOp*) (*block);
  162475           0 :                if ( tempPointer != NULL )
  162476             :                   {
  162477           0 :                     tempPointer->set_freepointer(pointer);
  162478             :                   }
  162479           0 :                for (unsigned i = 0; i < SgPlusAssignOp::pool_size - 1; ++i)
  162480             :                   {
  162481           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  162482             :                   }
  162483           0 :                 pointer[SgPlusAssignOp::pool_size-1].set_freepointer(NULL);
  162484           0 :                 tempPointer = &(pointer[SgPlusAssignOp::pool_size-1]);
  162485           0 :                 ++block;
  162486             :              }
  162487             :         }
  162488           0 :    }
  162489             : 
  162490           5 : void SgPlusAssignOp::deleteMemoryPool() {
  162491           7 :   for (auto p: SgPlusAssignOp::pools) {
  162492           2 :     ROSE_FREE(p);
  162493             :   }
  162494           5 :   SgPlusAssignOp::next_node = nullptr;
  162495           5 :   SgPlusAssignOp::pools.clear();
  162496           5 : }
  162497             : 
  162498             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  162499             : //                 reading multiple binary files to for a single AST.
  162500             : /////////// new version ////////////////////////////////
  162501             : //############################################################################
  162502             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  162503             : void
  162504           2 : SgPlusAssignOp::extendMemoryPoolForFileIO( )
  162505             :   {
  162506           2 :     size_t blockIndex = SgPlusAssignOp::pools.size();
  162507           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPlusAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPlusAssignOp);
  162508             : 
  162509           3 :     while ( (blockIndex * SgPlusAssignOp::pool_size) < newPoolSize)
  162510             :       {
  162511             : #if ROSE_ALLOC_TRACE
  162512             :         if (blockIndex > 0) {
  162513             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPlusAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPlusAssignOp) = %" PRIuPTR " SgPlusAssignOp::pool_size = %d \n",
  162514             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPlusAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPlusAssignOp),SgPlusAssignOp::pool_size);
  162515             :         }
  162516             : #endif
  162517             : 
  162518           1 :         SgPlusAssignOp * pointer = (SgPlusAssignOp*) ROSE_MALLOC ( SgPlusAssignOp::pool_size * sizeof(SgPlusAssignOp) );
  162519           1 :         assert( pointer != NULL );
  162520             : #if ROSE_ALLOC_MEMSET == 1
  162521             :         memset(pointer, 0x00, SgPlusAssignOp::pool_size * sizeof(SgPlusAssignOp));
  162522             : #elif ROSE_ALLOC_MEMSET == 2
  162523             :         memset(pointer, 0xCC, SgPlusAssignOp::pool_size * sizeof(SgPlusAssignOp));
  162524             : #endif
  162525           1 :         SgPlusAssignOp::pools.push_back( (unsigned char*)(pointer) );
  162526           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPlusAssignOp::pool_size * sizeof(SgPlusAssignOp), V_SgPlusAssignOp ) );
  162527             : 
  162528           1 :         if ( SgPlusAssignOp::next_node != NULL ) {
  162529           0 :           if ( blockIndex > 0 ) {
  162530           0 :             SgPlusAssignOp * blkptr = (SgPlusAssignOp*)(SgPlusAssignOp::pools[blockIndex-1]);
  162531           0 :             blkptr[ SgPlusAssignOp::pool_size - 1 ].set_freepointer(pointer);
  162532             :           }
  162533             :         } else {
  162534           1 :           SgPlusAssignOp::next_node = pointer;
  162535             :         }
  162536             : 
  162537        2000 :         for (unsigned i = 0; i < SgPlusAssignOp::pool_size-1; ++i)
  162538             :            {
  162539        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  162540             :            }
  162541           1 :         pointer[ SgPlusAssignOp::pool_size -1 ].set_freepointer(NULL);
  162542             : 
  162543           1 :         blockIndex++;
  162544             :       }
  162545           2 :   }
  162546             : 
  162547             : //############################################################################
  162548             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  162549             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  162550             :  * not compressed. However, that stuff is not yet implemented! 
  162551             :  */
  162552             : unsigned long
  162553           0 : SgPlusAssignOp::getNumberOfLastValidPointer()
  162554             :    {
  162555           0 :       SgPlusAssignOp* testPointer = (SgPlusAssignOp*)(SgPlusAssignOp::pools.back());
  162556           0 :       unsigned long localIndex = SgPlusAssignOp::pool_size - 1;
  162557           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  162558             :          {
  162559           0 :            localIndex--;
  162560             :          }
  162561           0 :       return (localIndex + SgPlusAssignOp::pool_size * (SgPlusAssignOp::pools.size()-1));
  162562             :    }
  162563             : 
  162564             : //############################################################################
  162565             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  162566             :  * memory pool and initializes the data member in class SgPlusAssignOpStroageClass
  162567             :  * from its counterpart of SgPlusAssignOp. The return value is just for checking, 
  162568             :  * that the whole StorageClassArray is initialized!
  162569             :  */
  162570             : unsigned long
  162571           1 : SgPlusAssignOp::initializeStorageClassArray( SgPlusAssignOpStorageClass *storageArray )
  162572             :    {
  162573           1 :      unsigned long storageCounter = 0;
  162574           1 :      std::vector < unsigned char* > :: const_iterator block = SgPlusAssignOp::pools.begin();
  162575           1 :      SgPlusAssignOp* pointer = NULL;
  162576           2 :      while ( block != SgPlusAssignOp::pools.end() ) {
  162577           1 :           pointer = (SgPlusAssignOp*) (*block);
  162578        2001 :           for ( unsigned i = 0; i < SgPlusAssignOp::pool_size; ++i ) {
  162579        2000 :                if ( pointer->get_freepointer() != NULL ) {
  162580          29 :                  storageArray->pickOutIRNodeData (pointer) ;
  162581          29 :                  storageArray++;
  162582          29 :                  storageCounter++;
  162583             :                }
  162584        2000 :                pointer++;
  162585             :              }
  162586           1 :            block++;
  162587             :         }
  162588           1 :      return storageCounter;
  162589             :    }
  162590             : 
  162591             : /* #line 162592 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  162592             : 
  162593             : 
  162594             : 
  162595             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  162596             : 
  162597             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  162598             : 
  162599             : //############################################################################
  162600             : /* JH (02/02/2006) Constructor of the IR node SgMinusAssignOp that takes its 
  162601             :  * corresponding StorageClass as parameter
  162602             :  */
  162603          10 : SgMinusAssignOp :: SgMinusAssignOp ( const SgMinusAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  162604             :    {
  162605             : 
  162606             : 
  162607             : /* #line 162608 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  162608             : 
  162609          10 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  162610             : 
  162611             : 
  162612             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  162613             : 
  162614             : 
  162615          10 :    }
  162616             : 
  162617             : //############################################################################
  162618             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  162619             :  * within the working AST. 
  162620             :  */
  162621          60 : SgMinusAssignOp * SgMinusAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  162622          60 :      SgMinusAssignOp* returnPointer = NULL;
  162623          60 :      if ( globalIndex != 0 )
  162624             :         {
  162625             : 
  162626             : #if FILE_IO_EXTRA_CHECK
  162627          60 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMinusAssignOp ) ) <= globalIndex ) ;
  162628          60 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMinusAssignOp + 1 ) ) );
  162629             : #endif
  162630          60 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMinusAssignOp )  
  162631          60 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMinusAssignOp );
  162632          60 :           unsigned long positionInPool = localIndex % SgMinusAssignOp::pool_size;
  162633          60 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMinusAssignOp::pool_size;
  162634             : 
  162635             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  162636             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  162637             : 
  162638          60 :           returnPointer = &( ( (SgMinusAssignOp*)(SgMinusAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  162639             : 
  162640          60 :           ROSE_ASSERT( returnPointer != NULL ) ;
  162641             :         }
  162642          60 :      return returnPointer ;
  162643             :    }
  162644             : 
  162645             : //############################################################################
  162646             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  162647             :   for the AST with the index astIndex
  162648             : */
  162649           0 : SgMinusAssignOp * SgMinusAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  162650           0 :      SgMinusAssignOp* returnPointer = NULL;
  162651           0 :      if ( globalIndex != 0 )
  162652             :         {
  162653             : 
  162654             : #if FILE_IO_EXTRA_CHECK
  162655           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMinusAssignOp ) ) <= globalIndex ) ;
  162656           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMinusAssignOp + 1 ) ) );
  162657             : #endif
  162658           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMinusAssignOp )
  162659           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMinusAssignOp );
  162660           0 :           unsigned long positionInPool = localIndex % SgMinusAssignOp::pool_size ;
  162661           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMinusAssignOp::pool_size ;
  162662             : 
  162663             : #if FILE_IO_EXTRA_CHECK
  162664             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  162665             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  162666             : #endif
  162667             : 
  162668           0 :           returnPointer = &( ( (SgMinusAssignOp*)(SgMinusAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  162669             : 
  162670             : #if FILE_IO_EXTRA_CHECK
  162671           0 :           assert ( returnPointer != NULL ) ;
  162672             : #endif
  162673             :         }
  162674           0 :      return returnPointer ;
  162675             :    }
  162676             : 
  162677             : //############################################################################
  162678             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  162679             :  * pool size! We set for every valid object in the memory pool the freepointer
  162680             :  * to the global index and increase the global index afterwards. For all the 
  162681             :  * invalid objects (means address ranges within the memory pool that were not
  162682             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  162683             :  * distinguish valid from invalid objects! 
  162684             :  */
  162685             : unsigned long
  162686           5 : SgMinusAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  162687             :    {
  162688           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  162689           5 :      SgMinusAssignOp* pointer = NULL;
  162690           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  162691           5 :      std::vector < unsigned char* > :: const_iterator block;
  162692           6 :      for ( block = SgMinusAssignOp::pools.begin(); block != SgMinusAssignOp::pools.end() ; ++block )
  162693             :         {
  162694           1 :           pointer = (SgMinusAssignOp*)(*block);
  162695        2001 :           for (unsigned i = 0; i < SgMinusAssignOp::pool_size; ++i )
  162696             :              {
  162697             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  162698             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  162699             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  162700             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  162701             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  162702             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  162703             :             // properly; so this will have to be checked next.
  162704             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  162705             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  162706        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  162707             :                   {
  162708          10 :                     pointer[i].set_freepointer((SgMinusAssignOp*)(globalIndex));
  162709          10 :                     globalIndex++;
  162710             :                   }
  162711             :                else
  162712             :                   {
  162713        1990 :                     pointer[i].set_freepointer(NULL);
  162714             :                   }
  162715             :               }
  162716             :         }
  162717           5 :      return globalIndex;
  162718             :    }
  162719             : 
  162720             : //############################################################################
  162721             : // JH (01/14/2006)
  162722             : void
  162723           5 : SgMinusAssignOp::resetValidFreepointers( )
  162724             :    {
  162725           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  162726           5 :      SgMinusAssignOp* pointer = NULL;
  162727           5 :      std::vector < unsigned char* > :: const_iterator block;
  162728           5 :      SgMinusAssignOp* pointerOfLinkedList = NULL;
  162729           6 :      for ( block = SgMinusAssignOp::pools.begin(); block != SgMinusAssignOp::pools.end() ; ++block )
  162730             :         {
  162731           1 :           pointer = (SgMinusAssignOp*)(*block);
  162732        2001 :           for (unsigned i = 0; i < SgMinusAssignOp::pool_size; ++i )
  162733             :              {
  162734             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  162735             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  162736             :             // memory blocks!.
  162737        2000 :                if ( pointer[i].get_freepointer() != NULL )
  162738             :                   {
  162739          10 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  162740             :                   }
  162741             :                else
  162742             :                   {
  162743        1990 :                     if ( pointerOfLinkedList == NULL )
  162744             :                        {
  162745           1 :                          SgMinusAssignOp::next_node = &(pointer[i]);
  162746             :                        }
  162747             :                     else
  162748             :                        {
  162749             :                       // printf ("In SgMinusAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  162750        1989 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  162751             :                        }
  162752             :                     pointerOfLinkedList = &(pointer[i]);
  162753             :                   }
  162754             :               }
  162755             :         }
  162756             : 
  162757           5 :      if ( pointerOfLinkedList != NULL )
  162758             :         {
  162759             :        // printf ("In SgMinusAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  162760           1 :           pointerOfLinkedList->set_freepointer(NULL);
  162761             :        // DQ (6/6/2010): Temporary debugging...
  162762             :        //   ROSE_ASSERT(false);
  162763             :         }
  162764             : 
  162765           5 :      return ;
  162766             :    }
  162767             : 
  162768             : //############################################################################
  162769             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  162770             :  * within the memory pool and resets the freepointers, in order to achieve a 
  162771             :  * linked list, that has no jumps and starts at the beginning! This function 
  162772             :  * does not extend the memory pool, since we do not delete any memory blocks,
  162773             :  * but delete the valid objects.  
  162774             :  */
  162775             : void
  162776           0 : SgMinusAssignOp::clearMemoryPool( )
  162777             :    {
  162778             :   // printf ("Inside of SgMinusAssignOp::clearMemoryPool() \n");
  162779             : 
  162780           0 :      SgMinusAssignOp* pointer = NULL, *tempPointer = NULL;
  162781           0 :      std::vector < unsigned char* > :: const_iterator block;
  162782           0 :      if ( SgMinusAssignOp::pools.empty() == false )
  162783             :         {
  162784           0 :           block = SgMinusAssignOp::pools.begin() ;
  162785           0 :           SgMinusAssignOp::next_node = (SgMinusAssignOp*) (*block);
  162786             : 
  162787           0 :           while ( block != SgMinusAssignOp::pools.end() )
  162788             :              {
  162789           0 :                pointer = (SgMinusAssignOp*) (*block);
  162790           0 :                if ( tempPointer != NULL )
  162791             :                   {
  162792           0 :                     tempPointer->set_freepointer(pointer);
  162793             :                   }
  162794           0 :                for (unsigned i = 0; i < SgMinusAssignOp::pool_size - 1; ++i)
  162795             :                   {
  162796           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  162797             :                   }
  162798           0 :                 pointer[SgMinusAssignOp::pool_size-1].set_freepointer(NULL);
  162799           0 :                 tempPointer = &(pointer[SgMinusAssignOp::pool_size-1]);
  162800           0 :                 ++block;
  162801             :              }
  162802             :         }
  162803           0 :    }
  162804             : 
  162805           5 : void SgMinusAssignOp::deleteMemoryPool() {
  162806           7 :   for (auto p: SgMinusAssignOp::pools) {
  162807           2 :     ROSE_FREE(p);
  162808             :   }
  162809           5 :   SgMinusAssignOp::next_node = nullptr;
  162810           5 :   SgMinusAssignOp::pools.clear();
  162811           5 : }
  162812             : 
  162813             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  162814             : //                 reading multiple binary files to for a single AST.
  162815             : /////////// new version ////////////////////////////////
  162816             : //############################################################################
  162817             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  162818             : void
  162819           2 : SgMinusAssignOp::extendMemoryPoolForFileIO( )
  162820             :   {
  162821           2 :     size_t blockIndex = SgMinusAssignOp::pools.size();
  162822           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusAssignOp);
  162823             : 
  162824           3 :     while ( (blockIndex * SgMinusAssignOp::pool_size) < newPoolSize)
  162825             :       {
  162826             : #if ROSE_ALLOC_TRACE
  162827             :         if (blockIndex > 0) {
  162828             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusAssignOp) = %" PRIuPTR " SgMinusAssignOp::pool_size = %d \n",
  162829             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMinusAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMinusAssignOp),SgMinusAssignOp::pool_size);
  162830             :         }
  162831             : #endif
  162832             : 
  162833           1 :         SgMinusAssignOp * pointer = (SgMinusAssignOp*) ROSE_MALLOC ( SgMinusAssignOp::pool_size * sizeof(SgMinusAssignOp) );
  162834           1 :         assert( pointer != NULL );
  162835             : #if ROSE_ALLOC_MEMSET == 1
  162836             :         memset(pointer, 0x00, SgMinusAssignOp::pool_size * sizeof(SgMinusAssignOp));
  162837             : #elif ROSE_ALLOC_MEMSET == 2
  162838             :         memset(pointer, 0xCC, SgMinusAssignOp::pool_size * sizeof(SgMinusAssignOp));
  162839             : #endif
  162840           1 :         SgMinusAssignOp::pools.push_back( (unsigned char*)(pointer) );
  162841           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMinusAssignOp::pool_size * sizeof(SgMinusAssignOp), V_SgMinusAssignOp ) );
  162842             : 
  162843           1 :         if ( SgMinusAssignOp::next_node != NULL ) {
  162844           0 :           if ( blockIndex > 0 ) {
  162845           0 :             SgMinusAssignOp * blkptr = (SgMinusAssignOp*)(SgMinusAssignOp::pools[blockIndex-1]);
  162846           0 :             blkptr[ SgMinusAssignOp::pool_size - 1 ].set_freepointer(pointer);
  162847             :           }
  162848             :         } else {
  162849           1 :           SgMinusAssignOp::next_node = pointer;
  162850             :         }
  162851             : 
  162852        2000 :         for (unsigned i = 0; i < SgMinusAssignOp::pool_size-1; ++i)
  162853             :            {
  162854        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  162855             :            }
  162856           1 :         pointer[ SgMinusAssignOp::pool_size -1 ].set_freepointer(NULL);
  162857             : 
  162858           1 :         blockIndex++;
  162859             :       }
  162860           2 :   }
  162861             : 
  162862             : //############################################################################
  162863             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  162864             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  162865             :  * not compressed. However, that stuff is not yet implemented! 
  162866             :  */
  162867             : unsigned long
  162868           0 : SgMinusAssignOp::getNumberOfLastValidPointer()
  162869             :    {
  162870           0 :       SgMinusAssignOp* testPointer = (SgMinusAssignOp*)(SgMinusAssignOp::pools.back());
  162871           0 :       unsigned long localIndex = SgMinusAssignOp::pool_size - 1;
  162872           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  162873             :          {
  162874           0 :            localIndex--;
  162875             :          }
  162876           0 :       return (localIndex + SgMinusAssignOp::pool_size * (SgMinusAssignOp::pools.size()-1));
  162877             :    }
  162878             : 
  162879             : //############################################################################
  162880             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  162881             :  * memory pool and initializes the data member in class SgMinusAssignOpStroageClass
  162882             :  * from its counterpart of SgMinusAssignOp. The return value is just for checking, 
  162883             :  * that the whole StorageClassArray is initialized!
  162884             :  */
  162885             : unsigned long
  162886           1 : SgMinusAssignOp::initializeStorageClassArray( SgMinusAssignOpStorageClass *storageArray )
  162887             :    {
  162888           1 :      unsigned long storageCounter = 0;
  162889           1 :      std::vector < unsigned char* > :: const_iterator block = SgMinusAssignOp::pools.begin();
  162890           1 :      SgMinusAssignOp* pointer = NULL;
  162891           2 :      while ( block != SgMinusAssignOp::pools.end() ) {
  162892           1 :           pointer = (SgMinusAssignOp*) (*block);
  162893        2001 :           for ( unsigned i = 0; i < SgMinusAssignOp::pool_size; ++i ) {
  162894        2000 :                if ( pointer->get_freepointer() != NULL ) {
  162895          10 :                  storageArray->pickOutIRNodeData (pointer) ;
  162896          10 :                  storageArray++;
  162897          10 :                  storageCounter++;
  162898             :                }
  162899        2000 :                pointer++;
  162900             :              }
  162901           1 :            block++;
  162902             :         }
  162903           1 :      return storageCounter;
  162904             :    }
  162905             : 
  162906             : /* #line 162907 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  162907             : 
  162908             : 
  162909             : 
  162910             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  162911             : 
  162912             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  162913             : 
  162914             : //############################################################################
  162915             : /* JH (02/02/2006) Constructor of the IR node SgAndAssignOp that takes its 
  162916             :  * corresponding StorageClass as parameter
  162917             :  */
  162918           0 : SgAndAssignOp :: SgAndAssignOp ( const SgAndAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  162919             :    {
  162920             : 
  162921             : 
  162922             : /* #line 162923 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  162923             : 
  162924           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  162925             : 
  162926             : 
  162927             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  162928             : 
  162929             : 
  162930           0 :    }
  162931             : 
  162932             : //############################################################################
  162933             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  162934             :  * within the working AST. 
  162935             :  */
  162936           0 : SgAndAssignOp * SgAndAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  162937           0 :      SgAndAssignOp* returnPointer = NULL;
  162938           0 :      if ( globalIndex != 0 )
  162939             :         {
  162940             : 
  162941             : #if FILE_IO_EXTRA_CHECK
  162942           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAndAssignOp ) ) <= globalIndex ) ;
  162943           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAndAssignOp + 1 ) ) );
  162944             : #endif
  162945           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAndAssignOp )  
  162946           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAndAssignOp );
  162947           0 :           unsigned long positionInPool = localIndex % SgAndAssignOp::pool_size;
  162948           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAndAssignOp::pool_size;
  162949             : 
  162950             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  162951             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  162952             : 
  162953           0 :           returnPointer = &( ( (SgAndAssignOp*)(SgAndAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  162954             : 
  162955           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  162956             :         }
  162957           0 :      return returnPointer ;
  162958             :    }
  162959             : 
  162960             : //############################################################################
  162961             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  162962             :   for the AST with the index astIndex
  162963             : */
  162964           0 : SgAndAssignOp * SgAndAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  162965           0 :      SgAndAssignOp* returnPointer = NULL;
  162966           0 :      if ( globalIndex != 0 )
  162967             :         {
  162968             : 
  162969             : #if FILE_IO_EXTRA_CHECK
  162970           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAndAssignOp ) ) <= globalIndex ) ;
  162971           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAndAssignOp + 1 ) ) );
  162972             : #endif
  162973           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAndAssignOp )
  162974           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAndAssignOp );
  162975           0 :           unsigned long positionInPool = localIndex % SgAndAssignOp::pool_size ;
  162976           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAndAssignOp::pool_size ;
  162977             : 
  162978             : #if FILE_IO_EXTRA_CHECK
  162979             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  162980             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  162981             : #endif
  162982             : 
  162983           0 :           returnPointer = &( ( (SgAndAssignOp*)(SgAndAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  162984             : 
  162985             : #if FILE_IO_EXTRA_CHECK
  162986           0 :           assert ( returnPointer != NULL ) ;
  162987             : #endif
  162988             :         }
  162989           0 :      return returnPointer ;
  162990             :    }
  162991             : 
  162992             : //############################################################################
  162993             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  162994             :  * pool size! We set for every valid object in the memory pool the freepointer
  162995             :  * to the global index and increase the global index afterwards. For all the 
  162996             :  * invalid objects (means address ranges within the memory pool that were not
  162997             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  162998             :  * distinguish valid from invalid objects! 
  162999             :  */
  163000             : unsigned long
  163001           5 : SgAndAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  163002             :    {
  163003           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  163004           5 :      SgAndAssignOp* pointer = NULL;
  163005           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  163006           5 :      std::vector < unsigned char* > :: const_iterator block;
  163007           5 :      for ( block = SgAndAssignOp::pools.begin(); block != SgAndAssignOp::pools.end() ; ++block )
  163008             :         {
  163009           0 :           pointer = (SgAndAssignOp*)(*block);
  163010           0 :           for (unsigned i = 0; i < SgAndAssignOp::pool_size; ++i )
  163011             :              {
  163012             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  163013             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  163014             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  163015             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  163016             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  163017             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  163018             :             // properly; so this will have to be checked next.
  163019             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  163020             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  163021           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  163022             :                   {
  163023           0 :                     pointer[i].set_freepointer((SgAndAssignOp*)(globalIndex));
  163024           0 :                     globalIndex++;
  163025             :                   }
  163026             :                else
  163027             :                   {
  163028           0 :                     pointer[i].set_freepointer(NULL);
  163029             :                   }
  163030             :               }
  163031             :         }
  163032           5 :      return globalIndex;
  163033             :    }
  163034             : 
  163035             : //############################################################################
  163036             : // JH (01/14/2006)
  163037             : void
  163038           5 : SgAndAssignOp::resetValidFreepointers( )
  163039             :    {
  163040           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  163041           5 :      SgAndAssignOp* pointer = NULL;
  163042           5 :      std::vector < unsigned char* > :: const_iterator block;
  163043           5 :      SgAndAssignOp* pointerOfLinkedList = NULL;
  163044           5 :      for ( block = SgAndAssignOp::pools.begin(); block != SgAndAssignOp::pools.end() ; ++block )
  163045             :         {
  163046           0 :           pointer = (SgAndAssignOp*)(*block);
  163047           0 :           for (unsigned i = 0; i < SgAndAssignOp::pool_size; ++i )
  163048             :              {
  163049             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  163050             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  163051             :             // memory blocks!.
  163052           0 :                if ( pointer[i].get_freepointer() != NULL )
  163053             :                   {
  163054           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  163055             :                   }
  163056             :                else
  163057             :                   {
  163058           0 :                     if ( pointerOfLinkedList == NULL )
  163059             :                        {
  163060           0 :                          SgAndAssignOp::next_node = &(pointer[i]);
  163061             :                        }
  163062             :                     else
  163063             :                        {
  163064             :                       // printf ("In SgAndAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  163065           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  163066             :                        }
  163067             :                     pointerOfLinkedList = &(pointer[i]);
  163068             :                   }
  163069             :               }
  163070             :         }
  163071             : 
  163072           5 :      if ( pointerOfLinkedList != NULL )
  163073             :         {
  163074             :        // printf ("In SgAndAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  163075           0 :           pointerOfLinkedList->set_freepointer(NULL);
  163076             :        // DQ (6/6/2010): Temporary debugging...
  163077             :        //   ROSE_ASSERT(false);
  163078             :         }
  163079             : 
  163080           5 :      return ;
  163081             :    }
  163082             : 
  163083             : //############################################################################
  163084             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  163085             :  * within the memory pool and resets the freepointers, in order to achieve a 
  163086             :  * linked list, that has no jumps and starts at the beginning! This function 
  163087             :  * does not extend the memory pool, since we do not delete any memory blocks,
  163088             :  * but delete the valid objects.  
  163089             :  */
  163090             : void
  163091           0 : SgAndAssignOp::clearMemoryPool( )
  163092             :    {
  163093             :   // printf ("Inside of SgAndAssignOp::clearMemoryPool() \n");
  163094             : 
  163095           0 :      SgAndAssignOp* pointer = NULL, *tempPointer = NULL;
  163096           0 :      std::vector < unsigned char* > :: const_iterator block;
  163097           0 :      if ( SgAndAssignOp::pools.empty() == false )
  163098             :         {
  163099           0 :           block = SgAndAssignOp::pools.begin() ;
  163100           0 :           SgAndAssignOp::next_node = (SgAndAssignOp*) (*block);
  163101             : 
  163102           0 :           while ( block != SgAndAssignOp::pools.end() )
  163103             :              {
  163104           0 :                pointer = (SgAndAssignOp*) (*block);
  163105           0 :                if ( tempPointer != NULL )
  163106             :                   {
  163107           0 :                     tempPointer->set_freepointer(pointer);
  163108             :                   }
  163109           0 :                for (unsigned i = 0; i < SgAndAssignOp::pool_size - 1; ++i)
  163110             :                   {
  163111           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  163112             :                   }
  163113           0 :                 pointer[SgAndAssignOp::pool_size-1].set_freepointer(NULL);
  163114           0 :                 tempPointer = &(pointer[SgAndAssignOp::pool_size-1]);
  163115           0 :                 ++block;
  163116             :              }
  163117             :         }
  163118           0 :    }
  163119             : 
  163120           5 : void SgAndAssignOp::deleteMemoryPool() {
  163121           5 :   for (auto p: SgAndAssignOp::pools) {
  163122           0 :     ROSE_FREE(p);
  163123             :   }
  163124           5 :   SgAndAssignOp::next_node = nullptr;
  163125           5 :   SgAndAssignOp::pools.clear();
  163126           5 : }
  163127             : 
  163128             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  163129             : //                 reading multiple binary files to for a single AST.
  163130             : /////////// new version ////////////////////////////////
  163131             : //############################################################################
  163132             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  163133             : void
  163134           2 : SgAndAssignOp::extendMemoryPoolForFileIO( )
  163135             :   {
  163136           2 :     size_t blockIndex = SgAndAssignOp::pools.size();
  163137           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAndAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAndAssignOp);
  163138             : 
  163139           2 :     while ( (blockIndex * SgAndAssignOp::pool_size) < newPoolSize)
  163140             :       {
  163141             : #if ROSE_ALLOC_TRACE
  163142             :         if (blockIndex > 0) {
  163143             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAndAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAndAssignOp) = %" PRIuPTR " SgAndAssignOp::pool_size = %d \n",
  163144             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAndAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAndAssignOp),SgAndAssignOp::pool_size);
  163145             :         }
  163146             : #endif
  163147             : 
  163148           0 :         SgAndAssignOp * pointer = (SgAndAssignOp*) ROSE_MALLOC ( SgAndAssignOp::pool_size * sizeof(SgAndAssignOp) );
  163149           0 :         assert( pointer != NULL );
  163150             : #if ROSE_ALLOC_MEMSET == 1
  163151             :         memset(pointer, 0x00, SgAndAssignOp::pool_size * sizeof(SgAndAssignOp));
  163152             : #elif ROSE_ALLOC_MEMSET == 2
  163153             :         memset(pointer, 0xCC, SgAndAssignOp::pool_size * sizeof(SgAndAssignOp));
  163154             : #endif
  163155           0 :         SgAndAssignOp::pools.push_back( (unsigned char*)(pointer) );
  163156           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAndAssignOp::pool_size * sizeof(SgAndAssignOp), V_SgAndAssignOp ) );
  163157             : 
  163158           0 :         if ( SgAndAssignOp::next_node != NULL ) {
  163159           0 :           if ( blockIndex > 0 ) {
  163160           0 :             SgAndAssignOp * blkptr = (SgAndAssignOp*)(SgAndAssignOp::pools[blockIndex-1]);
  163161           0 :             blkptr[ SgAndAssignOp::pool_size - 1 ].set_freepointer(pointer);
  163162             :           }
  163163             :         } else {
  163164           0 :           SgAndAssignOp::next_node = pointer;
  163165             :         }
  163166             : 
  163167           0 :         for (unsigned i = 0; i < SgAndAssignOp::pool_size-1; ++i)
  163168             :            {
  163169           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  163170             :            }
  163171           0 :         pointer[ SgAndAssignOp::pool_size -1 ].set_freepointer(NULL);
  163172             : 
  163173           0 :         blockIndex++;
  163174             :       }
  163175           2 :   }
  163176             : 
  163177             : //############################################################################
  163178             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  163179             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  163180             :  * not compressed. However, that stuff is not yet implemented! 
  163181             :  */
  163182             : unsigned long
  163183           0 : SgAndAssignOp::getNumberOfLastValidPointer()
  163184             :    {
  163185           0 :       SgAndAssignOp* testPointer = (SgAndAssignOp*)(SgAndAssignOp::pools.back());
  163186           0 :       unsigned long localIndex = SgAndAssignOp::pool_size - 1;
  163187           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  163188             :          {
  163189           0 :            localIndex--;
  163190             :          }
  163191           0 :       return (localIndex + SgAndAssignOp::pool_size * (SgAndAssignOp::pools.size()-1));
  163192             :    }
  163193             : 
  163194             : //############################################################################
  163195             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  163196             :  * memory pool and initializes the data member in class SgAndAssignOpStroageClass
  163197             :  * from its counterpart of SgAndAssignOp. The return value is just for checking, 
  163198             :  * that the whole StorageClassArray is initialized!
  163199             :  */
  163200             : unsigned long
  163201           0 : SgAndAssignOp::initializeStorageClassArray( SgAndAssignOpStorageClass *storageArray )
  163202             :    {
  163203           0 :      unsigned long storageCounter = 0;
  163204           0 :      std::vector < unsigned char* > :: const_iterator block = SgAndAssignOp::pools.begin();
  163205           0 :      SgAndAssignOp* pointer = NULL;
  163206           0 :      while ( block != SgAndAssignOp::pools.end() ) {
  163207           0 :           pointer = (SgAndAssignOp*) (*block);
  163208           0 :           for ( unsigned i = 0; i < SgAndAssignOp::pool_size; ++i ) {
  163209           0 :                if ( pointer->get_freepointer() != NULL ) {
  163210           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  163211           0 :                  storageArray++;
  163212           0 :                  storageCounter++;
  163213             :                }
  163214           0 :                pointer++;
  163215             :              }
  163216           0 :            block++;
  163217             :         }
  163218           0 :      return storageCounter;
  163219             :    }
  163220             : 
  163221             : /* #line 163222 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  163222             : 
  163223             : 
  163224             : 
  163225             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  163226             : 
  163227             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  163228             : 
  163229             : //############################################################################
  163230             : /* JH (02/02/2006) Constructor of the IR node SgIorAssignOp that takes its 
  163231             :  * corresponding StorageClass as parameter
  163232             :  */
  163233           7 : SgIorAssignOp :: SgIorAssignOp ( const SgIorAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  163234             :    {
  163235             : 
  163236             : 
  163237             : /* #line 163238 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  163238             : 
  163239           7 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  163240             : 
  163241             : 
  163242             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  163243             : 
  163244             : 
  163245           7 :    }
  163246             : 
  163247             : //############################################################################
  163248             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  163249             :  * within the working AST. 
  163250             :  */
  163251          42 : SgIorAssignOp * SgIorAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  163252          42 :      SgIorAssignOp* returnPointer = NULL;
  163253          42 :      if ( globalIndex != 0 )
  163254             :         {
  163255             : 
  163256             : #if FILE_IO_EXTRA_CHECK
  163257          42 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIorAssignOp ) ) <= globalIndex ) ;
  163258          42 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIorAssignOp + 1 ) ) );
  163259             : #endif
  163260          42 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIorAssignOp )  
  163261          42 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIorAssignOp );
  163262          42 :           unsigned long positionInPool = localIndex % SgIorAssignOp::pool_size;
  163263          42 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIorAssignOp::pool_size;
  163264             : 
  163265             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  163266             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  163267             : 
  163268          42 :           returnPointer = &( ( (SgIorAssignOp*)(SgIorAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  163269             : 
  163270          42 :           ROSE_ASSERT( returnPointer != NULL ) ;
  163271             :         }
  163272          42 :      return returnPointer ;
  163273             :    }
  163274             : 
  163275             : //############################################################################
  163276             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  163277             :   for the AST with the index astIndex
  163278             : */
  163279           0 : SgIorAssignOp * SgIorAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  163280           0 :      SgIorAssignOp* returnPointer = NULL;
  163281           0 :      if ( globalIndex != 0 )
  163282             :         {
  163283             : 
  163284             : #if FILE_IO_EXTRA_CHECK
  163285           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIorAssignOp ) ) <= globalIndex ) ;
  163286           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIorAssignOp + 1 ) ) );
  163287             : #endif
  163288           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIorAssignOp )
  163289           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIorAssignOp );
  163290           0 :           unsigned long positionInPool = localIndex % SgIorAssignOp::pool_size ;
  163291           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIorAssignOp::pool_size ;
  163292             : 
  163293             : #if FILE_IO_EXTRA_CHECK
  163294             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  163295             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  163296             : #endif
  163297             : 
  163298           0 :           returnPointer = &( ( (SgIorAssignOp*)(SgIorAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  163299             : 
  163300             : #if FILE_IO_EXTRA_CHECK
  163301           0 :           assert ( returnPointer != NULL ) ;
  163302             : #endif
  163303             :         }
  163304           0 :      return returnPointer ;
  163305             :    }
  163306             : 
  163307             : //############################################################################
  163308             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  163309             :  * pool size! We set for every valid object in the memory pool the freepointer
  163310             :  * to the global index and increase the global index afterwards. For all the 
  163311             :  * invalid objects (means address ranges within the memory pool that were not
  163312             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  163313             :  * distinguish valid from invalid objects! 
  163314             :  */
  163315             : unsigned long
  163316           5 : SgIorAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  163317             :    {
  163318           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  163319           5 :      SgIorAssignOp* pointer = NULL;
  163320           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  163321           5 :      std::vector < unsigned char* > :: const_iterator block;
  163322           6 :      for ( block = SgIorAssignOp::pools.begin(); block != SgIorAssignOp::pools.end() ; ++block )
  163323             :         {
  163324           1 :           pointer = (SgIorAssignOp*)(*block);
  163325        2001 :           for (unsigned i = 0; i < SgIorAssignOp::pool_size; ++i )
  163326             :              {
  163327             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  163328             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  163329             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  163330             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  163331             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  163332             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  163333             :             // properly; so this will have to be checked next.
  163334             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  163335             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  163336        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  163337             :                   {
  163338           7 :                     pointer[i].set_freepointer((SgIorAssignOp*)(globalIndex));
  163339           7 :                     globalIndex++;
  163340             :                   }
  163341             :                else
  163342             :                   {
  163343        1993 :                     pointer[i].set_freepointer(NULL);
  163344             :                   }
  163345             :               }
  163346             :         }
  163347           5 :      return globalIndex;
  163348             :    }
  163349             : 
  163350             : //############################################################################
  163351             : // JH (01/14/2006)
  163352             : void
  163353           5 : SgIorAssignOp::resetValidFreepointers( )
  163354             :    {
  163355           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  163356           5 :      SgIorAssignOp* pointer = NULL;
  163357           5 :      std::vector < unsigned char* > :: const_iterator block;
  163358           5 :      SgIorAssignOp* pointerOfLinkedList = NULL;
  163359           6 :      for ( block = SgIorAssignOp::pools.begin(); block != SgIorAssignOp::pools.end() ; ++block )
  163360             :         {
  163361           1 :           pointer = (SgIorAssignOp*)(*block);
  163362        2001 :           for (unsigned i = 0; i < SgIorAssignOp::pool_size; ++i )
  163363             :              {
  163364             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  163365             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  163366             :             // memory blocks!.
  163367        2000 :                if ( pointer[i].get_freepointer() != NULL )
  163368             :                   {
  163369           7 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  163370             :                   }
  163371             :                else
  163372             :                   {
  163373        1993 :                     if ( pointerOfLinkedList == NULL )
  163374             :                        {
  163375           1 :                          SgIorAssignOp::next_node = &(pointer[i]);
  163376             :                        }
  163377             :                     else
  163378             :                        {
  163379             :                       // printf ("In SgIorAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  163380        1992 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  163381             :                        }
  163382             :                     pointerOfLinkedList = &(pointer[i]);
  163383             :                   }
  163384             :               }
  163385             :         }
  163386             : 
  163387           5 :      if ( pointerOfLinkedList != NULL )
  163388             :         {
  163389             :        // printf ("In SgIorAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  163390           1 :           pointerOfLinkedList->set_freepointer(NULL);
  163391             :        // DQ (6/6/2010): Temporary debugging...
  163392             :        //   ROSE_ASSERT(false);
  163393             :         }
  163394             : 
  163395           5 :      return ;
  163396             :    }
  163397             : 
  163398             : //############################################################################
  163399             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  163400             :  * within the memory pool and resets the freepointers, in order to achieve a 
  163401             :  * linked list, that has no jumps and starts at the beginning! This function 
  163402             :  * does not extend the memory pool, since we do not delete any memory blocks,
  163403             :  * but delete the valid objects.  
  163404             :  */
  163405             : void
  163406           0 : SgIorAssignOp::clearMemoryPool( )
  163407             :    {
  163408             :   // printf ("Inside of SgIorAssignOp::clearMemoryPool() \n");
  163409             : 
  163410           0 :      SgIorAssignOp* pointer = NULL, *tempPointer = NULL;
  163411           0 :      std::vector < unsigned char* > :: const_iterator block;
  163412           0 :      if ( SgIorAssignOp::pools.empty() == false )
  163413             :         {
  163414           0 :           block = SgIorAssignOp::pools.begin() ;
  163415           0 :           SgIorAssignOp::next_node = (SgIorAssignOp*) (*block);
  163416             : 
  163417           0 :           while ( block != SgIorAssignOp::pools.end() )
  163418             :              {
  163419           0 :                pointer = (SgIorAssignOp*) (*block);
  163420           0 :                if ( tempPointer != NULL )
  163421             :                   {
  163422           0 :                     tempPointer->set_freepointer(pointer);
  163423             :                   }
  163424           0 :                for (unsigned i = 0; i < SgIorAssignOp::pool_size - 1; ++i)
  163425             :                   {
  163426           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  163427             :                   }
  163428           0 :                 pointer[SgIorAssignOp::pool_size-1].set_freepointer(NULL);
  163429           0 :                 tempPointer = &(pointer[SgIorAssignOp::pool_size-1]);
  163430           0 :                 ++block;
  163431             :              }
  163432             :         }
  163433           0 :    }
  163434             : 
  163435           5 : void SgIorAssignOp::deleteMemoryPool() {
  163436           7 :   for (auto p: SgIorAssignOp::pools) {
  163437           2 :     ROSE_FREE(p);
  163438             :   }
  163439           5 :   SgIorAssignOp::next_node = nullptr;
  163440           5 :   SgIorAssignOp::pools.clear();
  163441           5 : }
  163442             : 
  163443             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  163444             : //                 reading multiple binary files to for a single AST.
  163445             : /////////// new version ////////////////////////////////
  163446             : //############################################################################
  163447             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  163448             : void
  163449           2 : SgIorAssignOp::extendMemoryPoolForFileIO( )
  163450             :   {
  163451           2 :     size_t blockIndex = SgIorAssignOp::pools.size();
  163452           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIorAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIorAssignOp);
  163453             : 
  163454           3 :     while ( (blockIndex * SgIorAssignOp::pool_size) < newPoolSize)
  163455             :       {
  163456             : #if ROSE_ALLOC_TRACE
  163457             :         if (blockIndex > 0) {
  163458             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIorAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIorAssignOp) = %" PRIuPTR " SgIorAssignOp::pool_size = %d \n",
  163459             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIorAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIorAssignOp),SgIorAssignOp::pool_size);
  163460             :         }
  163461             : #endif
  163462             : 
  163463           1 :         SgIorAssignOp * pointer = (SgIorAssignOp*) ROSE_MALLOC ( SgIorAssignOp::pool_size * sizeof(SgIorAssignOp) );
  163464           1 :         assert( pointer != NULL );
  163465             : #if ROSE_ALLOC_MEMSET == 1
  163466             :         memset(pointer, 0x00, SgIorAssignOp::pool_size * sizeof(SgIorAssignOp));
  163467             : #elif ROSE_ALLOC_MEMSET == 2
  163468             :         memset(pointer, 0xCC, SgIorAssignOp::pool_size * sizeof(SgIorAssignOp));
  163469             : #endif
  163470           1 :         SgIorAssignOp::pools.push_back( (unsigned char*)(pointer) );
  163471           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIorAssignOp::pool_size * sizeof(SgIorAssignOp), V_SgIorAssignOp ) );
  163472             : 
  163473           1 :         if ( SgIorAssignOp::next_node != NULL ) {
  163474           0 :           if ( blockIndex > 0 ) {
  163475           0 :             SgIorAssignOp * blkptr = (SgIorAssignOp*)(SgIorAssignOp::pools[blockIndex-1]);
  163476           0 :             blkptr[ SgIorAssignOp::pool_size - 1 ].set_freepointer(pointer);
  163477             :           }
  163478             :         } else {
  163479           1 :           SgIorAssignOp::next_node = pointer;
  163480             :         }
  163481             : 
  163482        2000 :         for (unsigned i = 0; i < SgIorAssignOp::pool_size-1; ++i)
  163483             :            {
  163484        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  163485             :            }
  163486           1 :         pointer[ SgIorAssignOp::pool_size -1 ].set_freepointer(NULL);
  163487             : 
  163488           1 :         blockIndex++;
  163489             :       }
  163490           2 :   }
  163491             : 
  163492             : //############################################################################
  163493             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  163494             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  163495             :  * not compressed. However, that stuff is not yet implemented! 
  163496             :  */
  163497             : unsigned long
  163498           0 : SgIorAssignOp::getNumberOfLastValidPointer()
  163499             :    {
  163500           0 :       SgIorAssignOp* testPointer = (SgIorAssignOp*)(SgIorAssignOp::pools.back());
  163501           0 :       unsigned long localIndex = SgIorAssignOp::pool_size - 1;
  163502           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  163503             :          {
  163504           0 :            localIndex--;
  163505             :          }
  163506           0 :       return (localIndex + SgIorAssignOp::pool_size * (SgIorAssignOp::pools.size()-1));
  163507             :    }
  163508             : 
  163509             : //############################################################################
  163510             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  163511             :  * memory pool and initializes the data member in class SgIorAssignOpStroageClass
  163512             :  * from its counterpart of SgIorAssignOp. The return value is just for checking, 
  163513             :  * that the whole StorageClassArray is initialized!
  163514             :  */
  163515             : unsigned long
  163516           1 : SgIorAssignOp::initializeStorageClassArray( SgIorAssignOpStorageClass *storageArray )
  163517             :    {
  163518           1 :      unsigned long storageCounter = 0;
  163519           1 :      std::vector < unsigned char* > :: const_iterator block = SgIorAssignOp::pools.begin();
  163520           1 :      SgIorAssignOp* pointer = NULL;
  163521           2 :      while ( block != SgIorAssignOp::pools.end() ) {
  163522           1 :           pointer = (SgIorAssignOp*) (*block);
  163523        2001 :           for ( unsigned i = 0; i < SgIorAssignOp::pool_size; ++i ) {
  163524        2000 :                if ( pointer->get_freepointer() != NULL ) {
  163525           7 :                  storageArray->pickOutIRNodeData (pointer) ;
  163526           7 :                  storageArray++;
  163527           7 :                  storageCounter++;
  163528             :                }
  163529        2000 :                pointer++;
  163530             :              }
  163531           1 :            block++;
  163532             :         }
  163533           1 :      return storageCounter;
  163534             :    }
  163535             : 
  163536             : /* #line 163537 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  163537             : 
  163538             : 
  163539             : 
  163540             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  163541             : 
  163542             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  163543             : 
  163544             : //############################################################################
  163545             : /* JH (02/02/2006) Constructor of the IR node SgMultAssignOp that takes its 
  163546             :  * corresponding StorageClass as parameter
  163547             :  */
  163548           2 : SgMultAssignOp :: SgMultAssignOp ( const SgMultAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  163549             :    {
  163550             : 
  163551             : 
  163552             : /* #line 163553 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  163553             : 
  163554           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  163555             : 
  163556             : 
  163557             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  163558             : 
  163559             : 
  163560           2 :    }
  163561             : 
  163562             : //############################################################################
  163563             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  163564             :  * within the working AST. 
  163565             :  */
  163566          12 : SgMultAssignOp * SgMultAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  163567          12 :      SgMultAssignOp* returnPointer = NULL;
  163568          12 :      if ( globalIndex != 0 )
  163569             :         {
  163570             : 
  163571             : #if FILE_IO_EXTRA_CHECK
  163572          12 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMultAssignOp ) ) <= globalIndex ) ;
  163573          12 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMultAssignOp + 1 ) ) );
  163574             : #endif
  163575          12 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMultAssignOp )  
  163576          12 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMultAssignOp );
  163577          12 :           unsigned long positionInPool = localIndex % SgMultAssignOp::pool_size;
  163578          12 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMultAssignOp::pool_size;
  163579             : 
  163580             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  163581             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  163582             : 
  163583          12 :           returnPointer = &( ( (SgMultAssignOp*)(SgMultAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  163584             : 
  163585          12 :           ROSE_ASSERT( returnPointer != NULL ) ;
  163586             :         }
  163587          12 :      return returnPointer ;
  163588             :    }
  163589             : 
  163590             : //############################################################################
  163591             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  163592             :   for the AST with the index astIndex
  163593             : */
  163594           0 : SgMultAssignOp * SgMultAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  163595           0 :      SgMultAssignOp* returnPointer = NULL;
  163596           0 :      if ( globalIndex != 0 )
  163597             :         {
  163598             : 
  163599             : #if FILE_IO_EXTRA_CHECK
  163600           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMultAssignOp ) ) <= globalIndex ) ;
  163601           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMultAssignOp + 1 ) ) );
  163602             : #endif
  163603           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMultAssignOp )
  163604           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMultAssignOp );
  163605           0 :           unsigned long positionInPool = localIndex % SgMultAssignOp::pool_size ;
  163606           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMultAssignOp::pool_size ;
  163607             : 
  163608             : #if FILE_IO_EXTRA_CHECK
  163609             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  163610             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  163611             : #endif
  163612             : 
  163613           0 :           returnPointer = &( ( (SgMultAssignOp*)(SgMultAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  163614             : 
  163615             : #if FILE_IO_EXTRA_CHECK
  163616           0 :           assert ( returnPointer != NULL ) ;
  163617             : #endif
  163618             :         }
  163619           0 :      return returnPointer ;
  163620             :    }
  163621             : 
  163622             : //############################################################################
  163623             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  163624             :  * pool size! We set for every valid object in the memory pool the freepointer
  163625             :  * to the global index and increase the global index afterwards. For all the 
  163626             :  * invalid objects (means address ranges within the memory pool that were not
  163627             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  163628             :  * distinguish valid from invalid objects! 
  163629             :  */
  163630             : unsigned long
  163631           5 : SgMultAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  163632             :    {
  163633           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  163634           5 :      SgMultAssignOp* pointer = NULL;
  163635           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  163636           5 :      std::vector < unsigned char* > :: const_iterator block;
  163637           6 :      for ( block = SgMultAssignOp::pools.begin(); block != SgMultAssignOp::pools.end() ; ++block )
  163638             :         {
  163639           1 :           pointer = (SgMultAssignOp*)(*block);
  163640        2001 :           for (unsigned i = 0; i < SgMultAssignOp::pool_size; ++i )
  163641             :              {
  163642             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  163643             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  163644             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  163645             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  163646             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  163647             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  163648             :             // properly; so this will have to be checked next.
  163649             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  163650             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  163651        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  163652             :                   {
  163653           2 :                     pointer[i].set_freepointer((SgMultAssignOp*)(globalIndex));
  163654           2 :                     globalIndex++;
  163655             :                   }
  163656             :                else
  163657             :                   {
  163658        1998 :                     pointer[i].set_freepointer(NULL);
  163659             :                   }
  163660             :               }
  163661             :         }
  163662           5 :      return globalIndex;
  163663             :    }
  163664             : 
  163665             : //############################################################################
  163666             : // JH (01/14/2006)
  163667             : void
  163668           5 : SgMultAssignOp::resetValidFreepointers( )
  163669             :    {
  163670           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  163671           5 :      SgMultAssignOp* pointer = NULL;
  163672           5 :      std::vector < unsigned char* > :: const_iterator block;
  163673           5 :      SgMultAssignOp* pointerOfLinkedList = NULL;
  163674           6 :      for ( block = SgMultAssignOp::pools.begin(); block != SgMultAssignOp::pools.end() ; ++block )
  163675             :         {
  163676           1 :           pointer = (SgMultAssignOp*)(*block);
  163677        2001 :           for (unsigned i = 0; i < SgMultAssignOp::pool_size; ++i )
  163678             :              {
  163679             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  163680             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  163681             :             // memory blocks!.
  163682        2000 :                if ( pointer[i].get_freepointer() != NULL )
  163683             :                   {
  163684           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  163685             :                   }
  163686             :                else
  163687             :                   {
  163688        1998 :                     if ( pointerOfLinkedList == NULL )
  163689             :                        {
  163690           1 :                          SgMultAssignOp::next_node = &(pointer[i]);
  163691             :                        }
  163692             :                     else
  163693             :                        {
  163694             :                       // printf ("In SgMultAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  163695        1997 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  163696             :                        }
  163697             :                     pointerOfLinkedList = &(pointer[i]);
  163698             :                   }
  163699             :               }
  163700             :         }
  163701             : 
  163702           5 :      if ( pointerOfLinkedList != NULL )
  163703             :         {
  163704             :        // printf ("In SgMultAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  163705           1 :           pointerOfLinkedList->set_freepointer(NULL);
  163706             :        // DQ (6/6/2010): Temporary debugging...
  163707             :        //   ROSE_ASSERT(false);
  163708             :         }
  163709             : 
  163710           5 :      return ;
  163711             :    }
  163712             : 
  163713             : //############################################################################
  163714             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  163715             :  * within the memory pool and resets the freepointers, in order to achieve a 
  163716             :  * linked list, that has no jumps and starts at the beginning! This function 
  163717             :  * does not extend the memory pool, since we do not delete any memory blocks,
  163718             :  * but delete the valid objects.  
  163719             :  */
  163720             : void
  163721           0 : SgMultAssignOp::clearMemoryPool( )
  163722             :    {
  163723             :   // printf ("Inside of SgMultAssignOp::clearMemoryPool() \n");
  163724             : 
  163725           0 :      SgMultAssignOp* pointer = NULL, *tempPointer = NULL;
  163726           0 :      std::vector < unsigned char* > :: const_iterator block;
  163727           0 :      if ( SgMultAssignOp::pools.empty() == false )
  163728             :         {
  163729           0 :           block = SgMultAssignOp::pools.begin() ;
  163730           0 :           SgMultAssignOp::next_node = (SgMultAssignOp*) (*block);
  163731             : 
  163732           0 :           while ( block != SgMultAssignOp::pools.end() )
  163733             :              {
  163734           0 :                pointer = (SgMultAssignOp*) (*block);
  163735           0 :                if ( tempPointer != NULL )
  163736             :                   {
  163737           0 :                     tempPointer->set_freepointer(pointer);
  163738             :                   }
  163739           0 :                for (unsigned i = 0; i < SgMultAssignOp::pool_size - 1; ++i)
  163740             :                   {
  163741           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  163742             :                   }
  163743           0 :                 pointer[SgMultAssignOp::pool_size-1].set_freepointer(NULL);
  163744           0 :                 tempPointer = &(pointer[SgMultAssignOp::pool_size-1]);
  163745           0 :                 ++block;
  163746             :              }
  163747             :         }
  163748           0 :    }
  163749             : 
  163750           5 : void SgMultAssignOp::deleteMemoryPool() {
  163751           7 :   for (auto p: SgMultAssignOp::pools) {
  163752           2 :     ROSE_FREE(p);
  163753             :   }
  163754           5 :   SgMultAssignOp::next_node = nullptr;
  163755           5 :   SgMultAssignOp::pools.clear();
  163756           5 : }
  163757             : 
  163758             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  163759             : //                 reading multiple binary files to for a single AST.
  163760             : /////////// new version ////////////////////////////////
  163761             : //############################################################################
  163762             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  163763             : void
  163764           2 : SgMultAssignOp::extendMemoryPoolForFileIO( )
  163765             :   {
  163766           2 :     size_t blockIndex = SgMultAssignOp::pools.size();
  163767           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMultAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMultAssignOp);
  163768             : 
  163769           3 :     while ( (blockIndex * SgMultAssignOp::pool_size) < newPoolSize)
  163770             :       {
  163771             : #if ROSE_ALLOC_TRACE
  163772             :         if (blockIndex > 0) {
  163773             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMultAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMultAssignOp) = %" PRIuPTR " SgMultAssignOp::pool_size = %d \n",
  163774             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMultAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMultAssignOp),SgMultAssignOp::pool_size);
  163775             :         }
  163776             : #endif
  163777             : 
  163778           1 :         SgMultAssignOp * pointer = (SgMultAssignOp*) ROSE_MALLOC ( SgMultAssignOp::pool_size * sizeof(SgMultAssignOp) );
  163779           1 :         assert( pointer != NULL );
  163780             : #if ROSE_ALLOC_MEMSET == 1
  163781             :         memset(pointer, 0x00, SgMultAssignOp::pool_size * sizeof(SgMultAssignOp));
  163782             : #elif ROSE_ALLOC_MEMSET == 2
  163783             :         memset(pointer, 0xCC, SgMultAssignOp::pool_size * sizeof(SgMultAssignOp));
  163784             : #endif
  163785           1 :         SgMultAssignOp::pools.push_back( (unsigned char*)(pointer) );
  163786           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMultAssignOp::pool_size * sizeof(SgMultAssignOp), V_SgMultAssignOp ) );
  163787             : 
  163788           1 :         if ( SgMultAssignOp::next_node != NULL ) {
  163789           0 :           if ( blockIndex > 0 ) {
  163790           0 :             SgMultAssignOp * blkptr = (SgMultAssignOp*)(SgMultAssignOp::pools[blockIndex-1]);
  163791           0 :             blkptr[ SgMultAssignOp::pool_size - 1 ].set_freepointer(pointer);
  163792             :           }
  163793             :         } else {
  163794           1 :           SgMultAssignOp::next_node = pointer;
  163795             :         }
  163796             : 
  163797        2000 :         for (unsigned i = 0; i < SgMultAssignOp::pool_size-1; ++i)
  163798             :            {
  163799        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  163800             :            }
  163801           1 :         pointer[ SgMultAssignOp::pool_size -1 ].set_freepointer(NULL);
  163802             : 
  163803           1 :         blockIndex++;
  163804             :       }
  163805           2 :   }
  163806             : 
  163807             : //############################################################################
  163808             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  163809             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  163810             :  * not compressed. However, that stuff is not yet implemented! 
  163811             :  */
  163812             : unsigned long
  163813           0 : SgMultAssignOp::getNumberOfLastValidPointer()
  163814             :    {
  163815           0 :       SgMultAssignOp* testPointer = (SgMultAssignOp*)(SgMultAssignOp::pools.back());
  163816           0 :       unsigned long localIndex = SgMultAssignOp::pool_size - 1;
  163817           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  163818             :          {
  163819           0 :            localIndex--;
  163820             :          }
  163821           0 :       return (localIndex + SgMultAssignOp::pool_size * (SgMultAssignOp::pools.size()-1));
  163822             :    }
  163823             : 
  163824             : //############################################################################
  163825             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  163826             :  * memory pool and initializes the data member in class SgMultAssignOpStroageClass
  163827             :  * from its counterpart of SgMultAssignOp. The return value is just for checking, 
  163828             :  * that the whole StorageClassArray is initialized!
  163829             :  */
  163830             : unsigned long
  163831           1 : SgMultAssignOp::initializeStorageClassArray( SgMultAssignOpStorageClass *storageArray )
  163832             :    {
  163833           1 :      unsigned long storageCounter = 0;
  163834           1 :      std::vector < unsigned char* > :: const_iterator block = SgMultAssignOp::pools.begin();
  163835           1 :      SgMultAssignOp* pointer = NULL;
  163836           2 :      while ( block != SgMultAssignOp::pools.end() ) {
  163837           1 :           pointer = (SgMultAssignOp*) (*block);
  163838        2001 :           for ( unsigned i = 0; i < SgMultAssignOp::pool_size; ++i ) {
  163839        2000 :                if ( pointer->get_freepointer() != NULL ) {
  163840           2 :                  storageArray->pickOutIRNodeData (pointer) ;
  163841           2 :                  storageArray++;
  163842           2 :                  storageCounter++;
  163843             :                }
  163844        2000 :                pointer++;
  163845             :              }
  163846           1 :            block++;
  163847             :         }
  163848           1 :      return storageCounter;
  163849             :    }
  163850             : 
  163851             : /* #line 163852 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  163852             : 
  163853             : 
  163854             : 
  163855             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  163856             : 
  163857             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  163858             : 
  163859             : //############################################################################
  163860             : /* JH (02/02/2006) Constructor of the IR node SgDivAssignOp that takes its 
  163861             :  * corresponding StorageClass as parameter
  163862             :  */
  163863           1 : SgDivAssignOp :: SgDivAssignOp ( const SgDivAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  163864             :    {
  163865             : 
  163866             : 
  163867             : /* #line 163868 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  163868             : 
  163869           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  163870             : 
  163871             : 
  163872             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  163873             : 
  163874             : 
  163875           1 :    }
  163876             : 
  163877             : //############################################################################
  163878             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  163879             :  * within the working AST. 
  163880             :  */
  163881           6 : SgDivAssignOp * SgDivAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  163882           6 :      SgDivAssignOp* returnPointer = NULL;
  163883           6 :      if ( globalIndex != 0 )
  163884             :         {
  163885             : 
  163886             : #if FILE_IO_EXTRA_CHECK
  163887           6 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDivAssignOp ) ) <= globalIndex ) ;
  163888           6 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDivAssignOp + 1 ) ) );
  163889             : #endif
  163890           6 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDivAssignOp )  
  163891           6 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDivAssignOp );
  163892           6 :           unsigned long positionInPool = localIndex % SgDivAssignOp::pool_size;
  163893           6 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDivAssignOp::pool_size;
  163894             : 
  163895             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  163896             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  163897             : 
  163898           6 :           returnPointer = &( ( (SgDivAssignOp*)(SgDivAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  163899             : 
  163900           6 :           ROSE_ASSERT( returnPointer != NULL ) ;
  163901             :         }
  163902           6 :      return returnPointer ;
  163903             :    }
  163904             : 
  163905             : //############################################################################
  163906             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  163907             :   for the AST with the index astIndex
  163908             : */
  163909           0 : SgDivAssignOp * SgDivAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  163910           0 :      SgDivAssignOp* returnPointer = NULL;
  163911           0 :      if ( globalIndex != 0 )
  163912             :         {
  163913             : 
  163914             : #if FILE_IO_EXTRA_CHECK
  163915           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDivAssignOp ) ) <= globalIndex ) ;
  163916           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDivAssignOp + 1 ) ) );
  163917             : #endif
  163918           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDivAssignOp )
  163919           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDivAssignOp );
  163920           0 :           unsigned long positionInPool = localIndex % SgDivAssignOp::pool_size ;
  163921           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDivAssignOp::pool_size ;
  163922             : 
  163923             : #if FILE_IO_EXTRA_CHECK
  163924             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  163925             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  163926             : #endif
  163927             : 
  163928           0 :           returnPointer = &( ( (SgDivAssignOp*)(SgDivAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  163929             : 
  163930             : #if FILE_IO_EXTRA_CHECK
  163931           0 :           assert ( returnPointer != NULL ) ;
  163932             : #endif
  163933             :         }
  163934           0 :      return returnPointer ;
  163935             :    }
  163936             : 
  163937             : //############################################################################
  163938             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  163939             :  * pool size! We set for every valid object in the memory pool the freepointer
  163940             :  * to the global index and increase the global index afterwards. For all the 
  163941             :  * invalid objects (means address ranges within the memory pool that were not
  163942             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  163943             :  * distinguish valid from invalid objects! 
  163944             :  */
  163945             : unsigned long
  163946           5 : SgDivAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  163947             :    {
  163948           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  163949           5 :      SgDivAssignOp* pointer = NULL;
  163950           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  163951           5 :      std::vector < unsigned char* > :: const_iterator block;
  163952           6 :      for ( block = SgDivAssignOp::pools.begin(); block != SgDivAssignOp::pools.end() ; ++block )
  163953             :         {
  163954           1 :           pointer = (SgDivAssignOp*)(*block);
  163955        2001 :           for (unsigned i = 0; i < SgDivAssignOp::pool_size; ++i )
  163956             :              {
  163957             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  163958             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  163959             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  163960             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  163961             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  163962             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  163963             :             // properly; so this will have to be checked next.
  163964             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  163965             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  163966        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  163967             :                   {
  163968           1 :                     pointer[i].set_freepointer((SgDivAssignOp*)(globalIndex));
  163969           1 :                     globalIndex++;
  163970             :                   }
  163971             :                else
  163972             :                   {
  163973        1999 :                     pointer[i].set_freepointer(NULL);
  163974             :                   }
  163975             :               }
  163976             :         }
  163977           5 :      return globalIndex;
  163978             :    }
  163979             : 
  163980             : //############################################################################
  163981             : // JH (01/14/2006)
  163982             : void
  163983           5 : SgDivAssignOp::resetValidFreepointers( )
  163984             :    {
  163985           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  163986           5 :      SgDivAssignOp* pointer = NULL;
  163987           5 :      std::vector < unsigned char* > :: const_iterator block;
  163988           5 :      SgDivAssignOp* pointerOfLinkedList = NULL;
  163989           6 :      for ( block = SgDivAssignOp::pools.begin(); block != SgDivAssignOp::pools.end() ; ++block )
  163990             :         {
  163991           1 :           pointer = (SgDivAssignOp*)(*block);
  163992        2001 :           for (unsigned i = 0; i < SgDivAssignOp::pool_size; ++i )
  163993             :              {
  163994             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  163995             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  163996             :             // memory blocks!.
  163997        2000 :                if ( pointer[i].get_freepointer() != NULL )
  163998             :                   {
  163999           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  164000             :                   }
  164001             :                else
  164002             :                   {
  164003        1999 :                     if ( pointerOfLinkedList == NULL )
  164004             :                        {
  164005           1 :                          SgDivAssignOp::next_node = &(pointer[i]);
  164006             :                        }
  164007             :                     else
  164008             :                        {
  164009             :                       // printf ("In SgDivAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  164010        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  164011             :                        }
  164012             :                     pointerOfLinkedList = &(pointer[i]);
  164013             :                   }
  164014             :               }
  164015             :         }
  164016             : 
  164017           5 :      if ( pointerOfLinkedList != NULL )
  164018             :         {
  164019             :        // printf ("In SgDivAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  164020           1 :           pointerOfLinkedList->set_freepointer(NULL);
  164021             :        // DQ (6/6/2010): Temporary debugging...
  164022             :        //   ROSE_ASSERT(false);
  164023             :         }
  164024             : 
  164025           5 :      return ;
  164026             :    }
  164027             : 
  164028             : //############################################################################
  164029             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  164030             :  * within the memory pool and resets the freepointers, in order to achieve a 
  164031             :  * linked list, that has no jumps and starts at the beginning! This function 
  164032             :  * does not extend the memory pool, since we do not delete any memory blocks,
  164033             :  * but delete the valid objects.  
  164034             :  */
  164035             : void
  164036           0 : SgDivAssignOp::clearMemoryPool( )
  164037             :    {
  164038             :   // printf ("Inside of SgDivAssignOp::clearMemoryPool() \n");
  164039             : 
  164040           0 :      SgDivAssignOp* pointer = NULL, *tempPointer = NULL;
  164041           0 :      std::vector < unsigned char* > :: const_iterator block;
  164042           0 :      if ( SgDivAssignOp::pools.empty() == false )
  164043             :         {
  164044           0 :           block = SgDivAssignOp::pools.begin() ;
  164045           0 :           SgDivAssignOp::next_node = (SgDivAssignOp*) (*block);
  164046             : 
  164047           0 :           while ( block != SgDivAssignOp::pools.end() )
  164048             :              {
  164049           0 :                pointer = (SgDivAssignOp*) (*block);
  164050           0 :                if ( tempPointer != NULL )
  164051             :                   {
  164052           0 :                     tempPointer->set_freepointer(pointer);
  164053             :                   }
  164054           0 :                for (unsigned i = 0; i < SgDivAssignOp::pool_size - 1; ++i)
  164055             :                   {
  164056           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  164057             :                   }
  164058           0 :                 pointer[SgDivAssignOp::pool_size-1].set_freepointer(NULL);
  164059           0 :                 tempPointer = &(pointer[SgDivAssignOp::pool_size-1]);
  164060           0 :                 ++block;
  164061             :              }
  164062             :         }
  164063           0 :    }
  164064             : 
  164065           5 : void SgDivAssignOp::deleteMemoryPool() {
  164066           7 :   for (auto p: SgDivAssignOp::pools) {
  164067           2 :     ROSE_FREE(p);
  164068             :   }
  164069           5 :   SgDivAssignOp::next_node = nullptr;
  164070           5 :   SgDivAssignOp::pools.clear();
  164071           5 : }
  164072             : 
  164073             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  164074             : //                 reading multiple binary files to for a single AST.
  164075             : /////////// new version ////////////////////////////////
  164076             : //############################################################################
  164077             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  164078             : void
  164079           2 : SgDivAssignOp::extendMemoryPoolForFileIO( )
  164080             :   {
  164081           2 :     size_t blockIndex = SgDivAssignOp::pools.size();
  164082           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDivAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDivAssignOp);
  164083             : 
  164084           3 :     while ( (blockIndex * SgDivAssignOp::pool_size) < newPoolSize)
  164085             :       {
  164086             : #if ROSE_ALLOC_TRACE
  164087             :         if (blockIndex > 0) {
  164088             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDivAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDivAssignOp) = %" PRIuPTR " SgDivAssignOp::pool_size = %d \n",
  164089             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDivAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDivAssignOp),SgDivAssignOp::pool_size);
  164090             :         }
  164091             : #endif
  164092             : 
  164093           1 :         SgDivAssignOp * pointer = (SgDivAssignOp*) ROSE_MALLOC ( SgDivAssignOp::pool_size * sizeof(SgDivAssignOp) );
  164094           1 :         assert( pointer != NULL );
  164095             : #if ROSE_ALLOC_MEMSET == 1
  164096             :         memset(pointer, 0x00, SgDivAssignOp::pool_size * sizeof(SgDivAssignOp));
  164097             : #elif ROSE_ALLOC_MEMSET == 2
  164098             :         memset(pointer, 0xCC, SgDivAssignOp::pool_size * sizeof(SgDivAssignOp));
  164099             : #endif
  164100           1 :         SgDivAssignOp::pools.push_back( (unsigned char*)(pointer) );
  164101           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDivAssignOp::pool_size * sizeof(SgDivAssignOp), V_SgDivAssignOp ) );
  164102             : 
  164103           1 :         if ( SgDivAssignOp::next_node != NULL ) {
  164104           0 :           if ( blockIndex > 0 ) {
  164105           0 :             SgDivAssignOp * blkptr = (SgDivAssignOp*)(SgDivAssignOp::pools[blockIndex-1]);
  164106           0 :             blkptr[ SgDivAssignOp::pool_size - 1 ].set_freepointer(pointer);
  164107             :           }
  164108             :         } else {
  164109           1 :           SgDivAssignOp::next_node = pointer;
  164110             :         }
  164111             : 
  164112        2000 :         for (unsigned i = 0; i < SgDivAssignOp::pool_size-1; ++i)
  164113             :            {
  164114        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  164115             :            }
  164116           1 :         pointer[ SgDivAssignOp::pool_size -1 ].set_freepointer(NULL);
  164117             : 
  164118           1 :         blockIndex++;
  164119             :       }
  164120           2 :   }
  164121             : 
  164122             : //############################################################################
  164123             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  164124             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  164125             :  * not compressed. However, that stuff is not yet implemented! 
  164126             :  */
  164127             : unsigned long
  164128           0 : SgDivAssignOp::getNumberOfLastValidPointer()
  164129             :    {
  164130           0 :       SgDivAssignOp* testPointer = (SgDivAssignOp*)(SgDivAssignOp::pools.back());
  164131           0 :       unsigned long localIndex = SgDivAssignOp::pool_size - 1;
  164132           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  164133             :          {
  164134           0 :            localIndex--;
  164135             :          }
  164136           0 :       return (localIndex + SgDivAssignOp::pool_size * (SgDivAssignOp::pools.size()-1));
  164137             :    }
  164138             : 
  164139             : //############################################################################
  164140             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  164141             :  * memory pool and initializes the data member in class SgDivAssignOpStroageClass
  164142             :  * from its counterpart of SgDivAssignOp. The return value is just for checking, 
  164143             :  * that the whole StorageClassArray is initialized!
  164144             :  */
  164145             : unsigned long
  164146           1 : SgDivAssignOp::initializeStorageClassArray( SgDivAssignOpStorageClass *storageArray )
  164147             :    {
  164148           1 :      unsigned long storageCounter = 0;
  164149           1 :      std::vector < unsigned char* > :: const_iterator block = SgDivAssignOp::pools.begin();
  164150           1 :      SgDivAssignOp* pointer = NULL;
  164151           2 :      while ( block != SgDivAssignOp::pools.end() ) {
  164152           1 :           pointer = (SgDivAssignOp*) (*block);
  164153        2001 :           for ( unsigned i = 0; i < SgDivAssignOp::pool_size; ++i ) {
  164154        2000 :                if ( pointer->get_freepointer() != NULL ) {
  164155           1 :                  storageArray->pickOutIRNodeData (pointer) ;
  164156           1 :                  storageArray++;
  164157           1 :                  storageCounter++;
  164158             :                }
  164159        2000 :                pointer++;
  164160             :              }
  164161           1 :            block++;
  164162             :         }
  164163           1 :      return storageCounter;
  164164             :    }
  164165             : 
  164166             : /* #line 164167 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  164167             : 
  164168             : 
  164169             : 
  164170             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  164171             : 
  164172             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  164173             : 
  164174             : //############################################################################
  164175             : /* JH (02/02/2006) Constructor of the IR node SgModAssignOp that takes its 
  164176             :  * corresponding StorageClass as parameter
  164177             :  */
  164178           0 : SgModAssignOp :: SgModAssignOp ( const SgModAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  164179             :    {
  164180             : 
  164181             : 
  164182             : /* #line 164183 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  164183             : 
  164184           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  164185             : 
  164186             : 
  164187             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  164188             : 
  164189             : 
  164190           0 :    }
  164191             : 
  164192             : //############################################################################
  164193             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  164194             :  * within the working AST. 
  164195             :  */
  164196           0 : SgModAssignOp * SgModAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  164197           0 :      SgModAssignOp* returnPointer = NULL;
  164198           0 :      if ( globalIndex != 0 )
  164199             :         {
  164200             : 
  164201             : #if FILE_IO_EXTRA_CHECK
  164202           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgModAssignOp ) ) <= globalIndex ) ;
  164203           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModAssignOp + 1 ) ) );
  164204             : #endif
  164205           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModAssignOp )  
  164206           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgModAssignOp );
  164207           0 :           unsigned long positionInPool = localIndex % SgModAssignOp::pool_size;
  164208           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModAssignOp::pool_size;
  164209             : 
  164210             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  164211             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  164212             : 
  164213           0 :           returnPointer = &( ( (SgModAssignOp*)(SgModAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  164214             : 
  164215           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  164216             :         }
  164217           0 :      return returnPointer ;
  164218             :    }
  164219             : 
  164220             : //############################################################################
  164221             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  164222             :   for the AST with the index astIndex
  164223             : */
  164224           0 : SgModAssignOp * SgModAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  164225           0 :      SgModAssignOp* returnPointer = NULL;
  164226           0 :      if ( globalIndex != 0 )
  164227             :         {
  164228             : 
  164229             : #if FILE_IO_EXTRA_CHECK
  164230           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgModAssignOp ) ) <= globalIndex ) ;
  164231           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModAssignOp + 1 ) ) );
  164232             : #endif
  164233           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModAssignOp )
  164234           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgModAssignOp );
  164235           0 :           unsigned long positionInPool = localIndex % SgModAssignOp::pool_size ;
  164236           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModAssignOp::pool_size ;
  164237             : 
  164238             : #if FILE_IO_EXTRA_CHECK
  164239             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  164240             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  164241             : #endif
  164242             : 
  164243           0 :           returnPointer = &( ( (SgModAssignOp*)(SgModAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  164244             : 
  164245             : #if FILE_IO_EXTRA_CHECK
  164246           0 :           assert ( returnPointer != NULL ) ;
  164247             : #endif
  164248             :         }
  164249           0 :      return returnPointer ;
  164250             :    }
  164251             : 
  164252             : //############################################################################
  164253             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  164254             :  * pool size! We set for every valid object in the memory pool the freepointer
  164255             :  * to the global index and increase the global index afterwards. For all the 
  164256             :  * invalid objects (means address ranges within the memory pool that were not
  164257             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  164258             :  * distinguish valid from invalid objects! 
  164259             :  */
  164260             : unsigned long
  164261           5 : SgModAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  164262             :    {
  164263           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  164264           5 :      SgModAssignOp* pointer = NULL;
  164265           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  164266           5 :      std::vector < unsigned char* > :: const_iterator block;
  164267           5 :      for ( block = SgModAssignOp::pools.begin(); block != SgModAssignOp::pools.end() ; ++block )
  164268             :         {
  164269           0 :           pointer = (SgModAssignOp*)(*block);
  164270           0 :           for (unsigned i = 0; i < SgModAssignOp::pool_size; ++i )
  164271             :              {
  164272             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  164273             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  164274             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  164275             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  164276             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  164277             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  164278             :             // properly; so this will have to be checked next.
  164279             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  164280             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  164281           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  164282             :                   {
  164283           0 :                     pointer[i].set_freepointer((SgModAssignOp*)(globalIndex));
  164284           0 :                     globalIndex++;
  164285             :                   }
  164286             :                else
  164287             :                   {
  164288           0 :                     pointer[i].set_freepointer(NULL);
  164289             :                   }
  164290             :               }
  164291             :         }
  164292           5 :      return globalIndex;
  164293             :    }
  164294             : 
  164295             : //############################################################################
  164296             : // JH (01/14/2006)
  164297             : void
  164298           5 : SgModAssignOp::resetValidFreepointers( )
  164299             :    {
  164300           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  164301           5 :      SgModAssignOp* pointer = NULL;
  164302           5 :      std::vector < unsigned char* > :: const_iterator block;
  164303           5 :      SgModAssignOp* pointerOfLinkedList = NULL;
  164304           5 :      for ( block = SgModAssignOp::pools.begin(); block != SgModAssignOp::pools.end() ; ++block )
  164305             :         {
  164306           0 :           pointer = (SgModAssignOp*)(*block);
  164307           0 :           for (unsigned i = 0; i < SgModAssignOp::pool_size; ++i )
  164308             :              {
  164309             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  164310             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  164311             :             // memory blocks!.
  164312           0 :                if ( pointer[i].get_freepointer() != NULL )
  164313             :                   {
  164314           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  164315             :                   }
  164316             :                else
  164317             :                   {
  164318           0 :                     if ( pointerOfLinkedList == NULL )
  164319             :                        {
  164320           0 :                          SgModAssignOp::next_node = &(pointer[i]);
  164321             :                        }
  164322             :                     else
  164323             :                        {
  164324             :                       // printf ("In SgModAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  164325           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  164326             :                        }
  164327             :                     pointerOfLinkedList = &(pointer[i]);
  164328             :                   }
  164329             :               }
  164330             :         }
  164331             : 
  164332           5 :      if ( pointerOfLinkedList != NULL )
  164333             :         {
  164334             :        // printf ("In SgModAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  164335           0 :           pointerOfLinkedList->set_freepointer(NULL);
  164336             :        // DQ (6/6/2010): Temporary debugging...
  164337             :        //   ROSE_ASSERT(false);
  164338             :         }
  164339             : 
  164340           5 :      return ;
  164341             :    }
  164342             : 
  164343             : //############################################################################
  164344             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  164345             :  * within the memory pool and resets the freepointers, in order to achieve a 
  164346             :  * linked list, that has no jumps and starts at the beginning! This function 
  164347             :  * does not extend the memory pool, since we do not delete any memory blocks,
  164348             :  * but delete the valid objects.  
  164349             :  */
  164350             : void
  164351           0 : SgModAssignOp::clearMemoryPool( )
  164352             :    {
  164353             :   // printf ("Inside of SgModAssignOp::clearMemoryPool() \n");
  164354             : 
  164355           0 :      SgModAssignOp* pointer = NULL, *tempPointer = NULL;
  164356           0 :      std::vector < unsigned char* > :: const_iterator block;
  164357           0 :      if ( SgModAssignOp::pools.empty() == false )
  164358             :         {
  164359           0 :           block = SgModAssignOp::pools.begin() ;
  164360           0 :           SgModAssignOp::next_node = (SgModAssignOp*) (*block);
  164361             : 
  164362           0 :           while ( block != SgModAssignOp::pools.end() )
  164363             :              {
  164364           0 :                pointer = (SgModAssignOp*) (*block);
  164365           0 :                if ( tempPointer != NULL )
  164366             :                   {
  164367           0 :                     tempPointer->set_freepointer(pointer);
  164368             :                   }
  164369           0 :                for (unsigned i = 0; i < SgModAssignOp::pool_size - 1; ++i)
  164370             :                   {
  164371           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  164372             :                   }
  164373           0 :                 pointer[SgModAssignOp::pool_size-1].set_freepointer(NULL);
  164374           0 :                 tempPointer = &(pointer[SgModAssignOp::pool_size-1]);
  164375           0 :                 ++block;
  164376             :              }
  164377             :         }
  164378           0 :    }
  164379             : 
  164380           5 : void SgModAssignOp::deleteMemoryPool() {
  164381           5 :   for (auto p: SgModAssignOp::pools) {
  164382           0 :     ROSE_FREE(p);
  164383             :   }
  164384           5 :   SgModAssignOp::next_node = nullptr;
  164385           5 :   SgModAssignOp::pools.clear();
  164386           5 : }
  164387             : 
  164388             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  164389             : //                 reading multiple binary files to for a single AST.
  164390             : /////////// new version ////////////////////////////////
  164391             : //############################################################################
  164392             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  164393             : void
  164394           2 : SgModAssignOp::extendMemoryPoolForFileIO( )
  164395             :   {
  164396           2 :     size_t blockIndex = SgModAssignOp::pools.size();
  164397           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgModAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgModAssignOp);
  164398             : 
  164399           2 :     while ( (blockIndex * SgModAssignOp::pool_size) < newPoolSize)
  164400             :       {
  164401             : #if ROSE_ALLOC_TRACE
  164402             :         if (blockIndex > 0) {
  164403             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgModAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgModAssignOp) = %" PRIuPTR " SgModAssignOp::pool_size = %d \n",
  164404             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgModAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgModAssignOp),SgModAssignOp::pool_size);
  164405             :         }
  164406             : #endif
  164407             : 
  164408           0 :         SgModAssignOp * pointer = (SgModAssignOp*) ROSE_MALLOC ( SgModAssignOp::pool_size * sizeof(SgModAssignOp) );
  164409           0 :         assert( pointer != NULL );
  164410             : #if ROSE_ALLOC_MEMSET == 1
  164411             :         memset(pointer, 0x00, SgModAssignOp::pool_size * sizeof(SgModAssignOp));
  164412             : #elif ROSE_ALLOC_MEMSET == 2
  164413             :         memset(pointer, 0xCC, SgModAssignOp::pool_size * sizeof(SgModAssignOp));
  164414             : #endif
  164415           0 :         SgModAssignOp::pools.push_back( (unsigned char*)(pointer) );
  164416           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgModAssignOp::pool_size * sizeof(SgModAssignOp), V_SgModAssignOp ) );
  164417             : 
  164418           0 :         if ( SgModAssignOp::next_node != NULL ) {
  164419           0 :           if ( blockIndex > 0 ) {
  164420           0 :             SgModAssignOp * blkptr = (SgModAssignOp*)(SgModAssignOp::pools[blockIndex-1]);
  164421           0 :             blkptr[ SgModAssignOp::pool_size - 1 ].set_freepointer(pointer);
  164422             :           }
  164423             :         } else {
  164424           0 :           SgModAssignOp::next_node = pointer;
  164425             :         }
  164426             : 
  164427           0 :         for (unsigned i = 0; i < SgModAssignOp::pool_size-1; ++i)
  164428             :            {
  164429           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  164430             :            }
  164431           0 :         pointer[ SgModAssignOp::pool_size -1 ].set_freepointer(NULL);
  164432             : 
  164433           0 :         blockIndex++;
  164434             :       }
  164435           2 :   }
  164436             : 
  164437             : //############################################################################
  164438             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  164439             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  164440             :  * not compressed. However, that stuff is not yet implemented! 
  164441             :  */
  164442             : unsigned long
  164443           0 : SgModAssignOp::getNumberOfLastValidPointer()
  164444             :    {
  164445           0 :       SgModAssignOp* testPointer = (SgModAssignOp*)(SgModAssignOp::pools.back());
  164446           0 :       unsigned long localIndex = SgModAssignOp::pool_size - 1;
  164447           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  164448             :          {
  164449           0 :            localIndex--;
  164450             :          }
  164451           0 :       return (localIndex + SgModAssignOp::pool_size * (SgModAssignOp::pools.size()-1));
  164452             :    }
  164453             : 
  164454             : //############################################################################
  164455             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  164456             :  * memory pool and initializes the data member in class SgModAssignOpStroageClass
  164457             :  * from its counterpart of SgModAssignOp. The return value is just for checking, 
  164458             :  * that the whole StorageClassArray is initialized!
  164459             :  */
  164460             : unsigned long
  164461           0 : SgModAssignOp::initializeStorageClassArray( SgModAssignOpStorageClass *storageArray )
  164462             :    {
  164463           0 :      unsigned long storageCounter = 0;
  164464           0 :      std::vector < unsigned char* > :: const_iterator block = SgModAssignOp::pools.begin();
  164465           0 :      SgModAssignOp* pointer = NULL;
  164466           0 :      while ( block != SgModAssignOp::pools.end() ) {
  164467           0 :           pointer = (SgModAssignOp*) (*block);
  164468           0 :           for ( unsigned i = 0; i < SgModAssignOp::pool_size; ++i ) {
  164469           0 :                if ( pointer->get_freepointer() != NULL ) {
  164470           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  164471           0 :                  storageArray++;
  164472           0 :                  storageCounter++;
  164473             :                }
  164474           0 :                pointer++;
  164475             :              }
  164476           0 :            block++;
  164477             :         }
  164478           0 :      return storageCounter;
  164479             :    }
  164480             : 
  164481             : /* #line 164482 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  164482             : 
  164483             : 
  164484             : 
  164485             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  164486             : 
  164487             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  164488             : 
  164489             : //############################################################################
  164490             : /* JH (02/02/2006) Constructor of the IR node SgXorAssignOp that takes its 
  164491             :  * corresponding StorageClass as parameter
  164492             :  */
  164493           0 : SgXorAssignOp :: SgXorAssignOp ( const SgXorAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  164494             :    {
  164495             : 
  164496             : 
  164497             : /* #line 164498 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  164498             : 
  164499           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  164500             : 
  164501             : 
  164502             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  164503             : 
  164504             : 
  164505           0 :    }
  164506             : 
  164507             : //############################################################################
  164508             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  164509             :  * within the working AST. 
  164510             :  */
  164511           0 : SgXorAssignOp * SgXorAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  164512           0 :      SgXorAssignOp* returnPointer = NULL;
  164513           0 :      if ( globalIndex != 0 )
  164514             :         {
  164515             : 
  164516             : #if FILE_IO_EXTRA_CHECK
  164517           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgXorAssignOp ) ) <= globalIndex ) ;
  164518           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgXorAssignOp + 1 ) ) );
  164519             : #endif
  164520           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgXorAssignOp )  
  164521           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgXorAssignOp );
  164522           0 :           unsigned long positionInPool = localIndex % SgXorAssignOp::pool_size;
  164523           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgXorAssignOp::pool_size;
  164524             : 
  164525             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  164526             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  164527             : 
  164528           0 :           returnPointer = &( ( (SgXorAssignOp*)(SgXorAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  164529             : 
  164530           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  164531             :         }
  164532           0 :      return returnPointer ;
  164533             :    }
  164534             : 
  164535             : //############################################################################
  164536             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  164537             :   for the AST with the index astIndex
  164538             : */
  164539           0 : SgXorAssignOp * SgXorAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  164540           0 :      SgXorAssignOp* returnPointer = NULL;
  164541           0 :      if ( globalIndex != 0 )
  164542             :         {
  164543             : 
  164544             : #if FILE_IO_EXTRA_CHECK
  164545           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgXorAssignOp ) ) <= globalIndex ) ;
  164546           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgXorAssignOp + 1 ) ) );
  164547             : #endif
  164548           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgXorAssignOp )
  164549           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgXorAssignOp );
  164550           0 :           unsigned long positionInPool = localIndex % SgXorAssignOp::pool_size ;
  164551           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgXorAssignOp::pool_size ;
  164552             : 
  164553             : #if FILE_IO_EXTRA_CHECK
  164554             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  164555             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  164556             : #endif
  164557             : 
  164558           0 :           returnPointer = &( ( (SgXorAssignOp*)(SgXorAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  164559             : 
  164560             : #if FILE_IO_EXTRA_CHECK
  164561           0 :           assert ( returnPointer != NULL ) ;
  164562             : #endif
  164563             :         }
  164564           0 :      return returnPointer ;
  164565             :    }
  164566             : 
  164567             : //############################################################################
  164568             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  164569             :  * pool size! We set for every valid object in the memory pool the freepointer
  164570             :  * to the global index and increase the global index afterwards. For all the 
  164571             :  * invalid objects (means address ranges within the memory pool that were not
  164572             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  164573             :  * distinguish valid from invalid objects! 
  164574             :  */
  164575             : unsigned long
  164576           5 : SgXorAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  164577             :    {
  164578           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  164579           5 :      SgXorAssignOp* pointer = NULL;
  164580           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  164581           5 :      std::vector < unsigned char* > :: const_iterator block;
  164582           5 :      for ( block = SgXorAssignOp::pools.begin(); block != SgXorAssignOp::pools.end() ; ++block )
  164583             :         {
  164584           0 :           pointer = (SgXorAssignOp*)(*block);
  164585           0 :           for (unsigned i = 0; i < SgXorAssignOp::pool_size; ++i )
  164586             :              {
  164587             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  164588             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  164589             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  164590             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  164591             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  164592             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  164593             :             // properly; so this will have to be checked next.
  164594             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  164595             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  164596           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  164597             :                   {
  164598           0 :                     pointer[i].set_freepointer((SgXorAssignOp*)(globalIndex));
  164599           0 :                     globalIndex++;
  164600             :                   }
  164601             :                else
  164602             :                   {
  164603           0 :                     pointer[i].set_freepointer(NULL);
  164604             :                   }
  164605             :               }
  164606             :         }
  164607           5 :      return globalIndex;
  164608             :    }
  164609             : 
  164610             : //############################################################################
  164611             : // JH (01/14/2006)
  164612             : void
  164613           5 : SgXorAssignOp::resetValidFreepointers( )
  164614             :    {
  164615           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  164616           5 :      SgXorAssignOp* pointer = NULL;
  164617           5 :      std::vector < unsigned char* > :: const_iterator block;
  164618           5 :      SgXorAssignOp* pointerOfLinkedList = NULL;
  164619           5 :      for ( block = SgXorAssignOp::pools.begin(); block != SgXorAssignOp::pools.end() ; ++block )
  164620             :         {
  164621           0 :           pointer = (SgXorAssignOp*)(*block);
  164622           0 :           for (unsigned i = 0; i < SgXorAssignOp::pool_size; ++i )
  164623             :              {
  164624             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  164625             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  164626             :             // memory blocks!.
  164627           0 :                if ( pointer[i].get_freepointer() != NULL )
  164628             :                   {
  164629           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  164630             :                   }
  164631             :                else
  164632             :                   {
  164633           0 :                     if ( pointerOfLinkedList == NULL )
  164634             :                        {
  164635           0 :                          SgXorAssignOp::next_node = &(pointer[i]);
  164636             :                        }
  164637             :                     else
  164638             :                        {
  164639             :                       // printf ("In SgXorAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  164640           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  164641             :                        }
  164642             :                     pointerOfLinkedList = &(pointer[i]);
  164643             :                   }
  164644             :               }
  164645             :         }
  164646             : 
  164647           5 :      if ( pointerOfLinkedList != NULL )
  164648             :         {
  164649             :        // printf ("In SgXorAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  164650           0 :           pointerOfLinkedList->set_freepointer(NULL);
  164651             :        // DQ (6/6/2010): Temporary debugging...
  164652             :        //   ROSE_ASSERT(false);
  164653             :         }
  164654             : 
  164655           5 :      return ;
  164656             :    }
  164657             : 
  164658             : //############################################################################
  164659             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  164660             :  * within the memory pool and resets the freepointers, in order to achieve a 
  164661             :  * linked list, that has no jumps and starts at the beginning! This function 
  164662             :  * does not extend the memory pool, since we do not delete any memory blocks,
  164663             :  * but delete the valid objects.  
  164664             :  */
  164665             : void
  164666           0 : SgXorAssignOp::clearMemoryPool( )
  164667             :    {
  164668             :   // printf ("Inside of SgXorAssignOp::clearMemoryPool() \n");
  164669             : 
  164670           0 :      SgXorAssignOp* pointer = NULL, *tempPointer = NULL;
  164671           0 :      std::vector < unsigned char* > :: const_iterator block;
  164672           0 :      if ( SgXorAssignOp::pools.empty() == false )
  164673             :         {
  164674           0 :           block = SgXorAssignOp::pools.begin() ;
  164675           0 :           SgXorAssignOp::next_node = (SgXorAssignOp*) (*block);
  164676             : 
  164677           0 :           while ( block != SgXorAssignOp::pools.end() )
  164678             :              {
  164679           0 :                pointer = (SgXorAssignOp*) (*block);
  164680           0 :                if ( tempPointer != NULL )
  164681             :                   {
  164682           0 :                     tempPointer->set_freepointer(pointer);
  164683             :                   }
  164684           0 :                for (unsigned i = 0; i < SgXorAssignOp::pool_size - 1; ++i)
  164685             :                   {
  164686           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  164687             :                   }
  164688           0 :                 pointer[SgXorAssignOp::pool_size-1].set_freepointer(NULL);
  164689           0 :                 tempPointer = &(pointer[SgXorAssignOp::pool_size-1]);
  164690           0 :                 ++block;
  164691             :              }
  164692             :         }
  164693           0 :    }
  164694             : 
  164695           5 : void SgXorAssignOp::deleteMemoryPool() {
  164696           5 :   for (auto p: SgXorAssignOp::pools) {
  164697           0 :     ROSE_FREE(p);
  164698             :   }
  164699           5 :   SgXorAssignOp::next_node = nullptr;
  164700           5 :   SgXorAssignOp::pools.clear();
  164701           5 : }
  164702             : 
  164703             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  164704             : //                 reading multiple binary files to for a single AST.
  164705             : /////////// new version ////////////////////////////////
  164706             : //############################################################################
  164707             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  164708             : void
  164709           2 : SgXorAssignOp::extendMemoryPoolForFileIO( )
  164710             :   {
  164711           2 :     size_t blockIndex = SgXorAssignOp::pools.size();
  164712           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgXorAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgXorAssignOp);
  164713             : 
  164714           2 :     while ( (blockIndex * SgXorAssignOp::pool_size) < newPoolSize)
  164715             :       {
  164716             : #if ROSE_ALLOC_TRACE
  164717             :         if (blockIndex > 0) {
  164718             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgXorAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgXorAssignOp) = %" PRIuPTR " SgXorAssignOp::pool_size = %d \n",
  164719             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgXorAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgXorAssignOp),SgXorAssignOp::pool_size);
  164720             :         }
  164721             : #endif
  164722             : 
  164723           0 :         SgXorAssignOp * pointer = (SgXorAssignOp*) ROSE_MALLOC ( SgXorAssignOp::pool_size * sizeof(SgXorAssignOp) );
  164724           0 :         assert( pointer != NULL );
  164725             : #if ROSE_ALLOC_MEMSET == 1
  164726             :         memset(pointer, 0x00, SgXorAssignOp::pool_size * sizeof(SgXorAssignOp));
  164727             : #elif ROSE_ALLOC_MEMSET == 2
  164728             :         memset(pointer, 0xCC, SgXorAssignOp::pool_size * sizeof(SgXorAssignOp));
  164729             : #endif
  164730           0 :         SgXorAssignOp::pools.push_back( (unsigned char*)(pointer) );
  164731           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgXorAssignOp::pool_size * sizeof(SgXorAssignOp), V_SgXorAssignOp ) );
  164732             : 
  164733           0 :         if ( SgXorAssignOp::next_node != NULL ) {
  164734           0 :           if ( blockIndex > 0 ) {
  164735           0 :             SgXorAssignOp * blkptr = (SgXorAssignOp*)(SgXorAssignOp::pools[blockIndex-1]);
  164736           0 :             blkptr[ SgXorAssignOp::pool_size - 1 ].set_freepointer(pointer);
  164737             :           }
  164738             :         } else {
  164739           0 :           SgXorAssignOp::next_node = pointer;
  164740             :         }
  164741             : 
  164742           0 :         for (unsigned i = 0; i < SgXorAssignOp::pool_size-1; ++i)
  164743             :            {
  164744           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  164745             :            }
  164746           0 :         pointer[ SgXorAssignOp::pool_size -1 ].set_freepointer(NULL);
  164747             : 
  164748           0 :         blockIndex++;
  164749             :       }
  164750           2 :   }
  164751             : 
  164752             : //############################################################################
  164753             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  164754             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  164755             :  * not compressed. However, that stuff is not yet implemented! 
  164756             :  */
  164757             : unsigned long
  164758           0 : SgXorAssignOp::getNumberOfLastValidPointer()
  164759             :    {
  164760           0 :       SgXorAssignOp* testPointer = (SgXorAssignOp*)(SgXorAssignOp::pools.back());
  164761           0 :       unsigned long localIndex = SgXorAssignOp::pool_size - 1;
  164762           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  164763             :          {
  164764           0 :            localIndex--;
  164765             :          }
  164766           0 :       return (localIndex + SgXorAssignOp::pool_size * (SgXorAssignOp::pools.size()-1));
  164767             :    }
  164768             : 
  164769             : //############################################################################
  164770             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  164771             :  * memory pool and initializes the data member in class SgXorAssignOpStroageClass
  164772             :  * from its counterpart of SgXorAssignOp. The return value is just for checking, 
  164773             :  * that the whole StorageClassArray is initialized!
  164774             :  */
  164775             : unsigned long
  164776           0 : SgXorAssignOp::initializeStorageClassArray( SgXorAssignOpStorageClass *storageArray )
  164777             :    {
  164778           0 :      unsigned long storageCounter = 0;
  164779           0 :      std::vector < unsigned char* > :: const_iterator block = SgXorAssignOp::pools.begin();
  164780           0 :      SgXorAssignOp* pointer = NULL;
  164781           0 :      while ( block != SgXorAssignOp::pools.end() ) {
  164782           0 :           pointer = (SgXorAssignOp*) (*block);
  164783           0 :           for ( unsigned i = 0; i < SgXorAssignOp::pool_size; ++i ) {
  164784           0 :                if ( pointer->get_freepointer() != NULL ) {
  164785           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  164786           0 :                  storageArray++;
  164787           0 :                  storageCounter++;
  164788             :                }
  164789           0 :                pointer++;
  164790             :              }
  164791           0 :            block++;
  164792             :         }
  164793           0 :      return storageCounter;
  164794             :    }
  164795             : 
  164796             : /* #line 164797 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  164797             : 
  164798             : 
  164799             : 
  164800             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  164801             : 
  164802             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  164803             : 
  164804             : //############################################################################
  164805             : /* JH (02/02/2006) Constructor of the IR node SgLshiftAssignOp that takes its 
  164806             :  * corresponding StorageClass as parameter
  164807             :  */
  164808           0 : SgLshiftAssignOp :: SgLshiftAssignOp ( const SgLshiftAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  164809             :    {
  164810             : 
  164811             : 
  164812             : /* #line 164813 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  164813             : 
  164814           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  164815             : 
  164816             : 
  164817             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  164818             : 
  164819             : 
  164820           0 :    }
  164821             : 
  164822             : //############################################################################
  164823             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  164824             :  * within the working AST. 
  164825             :  */
  164826           0 : SgLshiftAssignOp * SgLshiftAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  164827           0 :      SgLshiftAssignOp* returnPointer = NULL;
  164828           0 :      if ( globalIndex != 0 )
  164829             :         {
  164830             : 
  164831             : #if FILE_IO_EXTRA_CHECK
  164832           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLshiftAssignOp ) ) <= globalIndex ) ;
  164833           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLshiftAssignOp + 1 ) ) );
  164834             : #endif
  164835           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLshiftAssignOp )  
  164836           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLshiftAssignOp );
  164837           0 :           unsigned long positionInPool = localIndex % SgLshiftAssignOp::pool_size;
  164838           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLshiftAssignOp::pool_size;
  164839             : 
  164840             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  164841             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  164842             : 
  164843           0 :           returnPointer = &( ( (SgLshiftAssignOp*)(SgLshiftAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  164844             : 
  164845           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  164846             :         }
  164847           0 :      return returnPointer ;
  164848             :    }
  164849             : 
  164850             : //############################################################################
  164851             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  164852             :   for the AST with the index astIndex
  164853             : */
  164854           0 : SgLshiftAssignOp * SgLshiftAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  164855           0 :      SgLshiftAssignOp* returnPointer = NULL;
  164856           0 :      if ( globalIndex != 0 )
  164857             :         {
  164858             : 
  164859             : #if FILE_IO_EXTRA_CHECK
  164860           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLshiftAssignOp ) ) <= globalIndex ) ;
  164861           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLshiftAssignOp + 1 ) ) );
  164862             : #endif
  164863           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLshiftAssignOp )
  164864           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLshiftAssignOp );
  164865           0 :           unsigned long positionInPool = localIndex % SgLshiftAssignOp::pool_size ;
  164866           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLshiftAssignOp::pool_size ;
  164867             : 
  164868             : #if FILE_IO_EXTRA_CHECK
  164869             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  164870             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  164871             : #endif
  164872             : 
  164873           0 :           returnPointer = &( ( (SgLshiftAssignOp*)(SgLshiftAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  164874             : 
  164875             : #if FILE_IO_EXTRA_CHECK
  164876           0 :           assert ( returnPointer != NULL ) ;
  164877             : #endif
  164878             :         }
  164879           0 :      return returnPointer ;
  164880             :    }
  164881             : 
  164882             : //############################################################################
  164883             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  164884             :  * pool size! We set for every valid object in the memory pool the freepointer
  164885             :  * to the global index and increase the global index afterwards. For all the 
  164886             :  * invalid objects (means address ranges within the memory pool that were not
  164887             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  164888             :  * distinguish valid from invalid objects! 
  164889             :  */
  164890             : unsigned long
  164891           5 : SgLshiftAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  164892             :    {
  164893           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  164894           5 :      SgLshiftAssignOp* pointer = NULL;
  164895           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  164896           5 :      std::vector < unsigned char* > :: const_iterator block;
  164897           5 :      for ( block = SgLshiftAssignOp::pools.begin(); block != SgLshiftAssignOp::pools.end() ; ++block )
  164898             :         {
  164899           0 :           pointer = (SgLshiftAssignOp*)(*block);
  164900           0 :           for (unsigned i = 0; i < SgLshiftAssignOp::pool_size; ++i )
  164901             :              {
  164902             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  164903             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  164904             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  164905             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  164906             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  164907             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  164908             :             // properly; so this will have to be checked next.
  164909             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  164910             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  164911           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  164912             :                   {
  164913           0 :                     pointer[i].set_freepointer((SgLshiftAssignOp*)(globalIndex));
  164914           0 :                     globalIndex++;
  164915             :                   }
  164916             :                else
  164917             :                   {
  164918           0 :                     pointer[i].set_freepointer(NULL);
  164919             :                   }
  164920             :               }
  164921             :         }
  164922           5 :      return globalIndex;
  164923             :    }
  164924             : 
  164925             : //############################################################################
  164926             : // JH (01/14/2006)
  164927             : void
  164928           5 : SgLshiftAssignOp::resetValidFreepointers( )
  164929             :    {
  164930           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  164931           5 :      SgLshiftAssignOp* pointer = NULL;
  164932           5 :      std::vector < unsigned char* > :: const_iterator block;
  164933           5 :      SgLshiftAssignOp* pointerOfLinkedList = NULL;
  164934           5 :      for ( block = SgLshiftAssignOp::pools.begin(); block != SgLshiftAssignOp::pools.end() ; ++block )
  164935             :         {
  164936           0 :           pointer = (SgLshiftAssignOp*)(*block);
  164937           0 :           for (unsigned i = 0; i < SgLshiftAssignOp::pool_size; ++i )
  164938             :              {
  164939             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  164940             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  164941             :             // memory blocks!.
  164942           0 :                if ( pointer[i].get_freepointer() != NULL )
  164943             :                   {
  164944           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  164945             :                   }
  164946             :                else
  164947             :                   {
  164948           0 :                     if ( pointerOfLinkedList == NULL )
  164949             :                        {
  164950           0 :                          SgLshiftAssignOp::next_node = &(pointer[i]);
  164951             :                        }
  164952             :                     else
  164953             :                        {
  164954             :                       // printf ("In SgLshiftAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  164955           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  164956             :                        }
  164957             :                     pointerOfLinkedList = &(pointer[i]);
  164958             :                   }
  164959             :               }
  164960             :         }
  164961             : 
  164962           5 :      if ( pointerOfLinkedList != NULL )
  164963             :         {
  164964             :        // printf ("In SgLshiftAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  164965           0 :           pointerOfLinkedList->set_freepointer(NULL);
  164966             :        // DQ (6/6/2010): Temporary debugging...
  164967             :        //   ROSE_ASSERT(false);
  164968             :         }
  164969             : 
  164970           5 :      return ;
  164971             :    }
  164972             : 
  164973             : //############################################################################
  164974             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  164975             :  * within the memory pool and resets the freepointers, in order to achieve a 
  164976             :  * linked list, that has no jumps and starts at the beginning! This function 
  164977             :  * does not extend the memory pool, since we do not delete any memory blocks,
  164978             :  * but delete the valid objects.  
  164979             :  */
  164980             : void
  164981           0 : SgLshiftAssignOp::clearMemoryPool( )
  164982             :    {
  164983             :   // printf ("Inside of SgLshiftAssignOp::clearMemoryPool() \n");
  164984             : 
  164985           0 :      SgLshiftAssignOp* pointer = NULL, *tempPointer = NULL;
  164986           0 :      std::vector < unsigned char* > :: const_iterator block;
  164987           0 :      if ( SgLshiftAssignOp::pools.empty() == false )
  164988             :         {
  164989           0 :           block = SgLshiftAssignOp::pools.begin() ;
  164990           0 :           SgLshiftAssignOp::next_node = (SgLshiftAssignOp*) (*block);
  164991             : 
  164992           0 :           while ( block != SgLshiftAssignOp::pools.end() )
  164993             :              {
  164994           0 :                pointer = (SgLshiftAssignOp*) (*block);
  164995           0 :                if ( tempPointer != NULL )
  164996             :                   {
  164997           0 :                     tempPointer->set_freepointer(pointer);
  164998             :                   }
  164999           0 :                for (unsigned i = 0; i < SgLshiftAssignOp::pool_size - 1; ++i)
  165000             :                   {
  165001           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  165002             :                   }
  165003           0 :                 pointer[SgLshiftAssignOp::pool_size-1].set_freepointer(NULL);
  165004           0 :                 tempPointer = &(pointer[SgLshiftAssignOp::pool_size-1]);
  165005           0 :                 ++block;
  165006             :              }
  165007             :         }
  165008           0 :    }
  165009             : 
  165010           5 : void SgLshiftAssignOp::deleteMemoryPool() {
  165011           5 :   for (auto p: SgLshiftAssignOp::pools) {
  165012           0 :     ROSE_FREE(p);
  165013             :   }
  165014           5 :   SgLshiftAssignOp::next_node = nullptr;
  165015           5 :   SgLshiftAssignOp::pools.clear();
  165016           5 : }
  165017             : 
  165018             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  165019             : //                 reading multiple binary files to for a single AST.
  165020             : /////////// new version ////////////////////////////////
  165021             : //############################################################################
  165022             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  165023             : void
  165024           2 : SgLshiftAssignOp::extendMemoryPoolForFileIO( )
  165025             :   {
  165026           2 :     size_t blockIndex = SgLshiftAssignOp::pools.size();
  165027           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLshiftAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLshiftAssignOp);
  165028             : 
  165029           2 :     while ( (blockIndex * SgLshiftAssignOp::pool_size) < newPoolSize)
  165030             :       {
  165031             : #if ROSE_ALLOC_TRACE
  165032             :         if (blockIndex > 0) {
  165033             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLshiftAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLshiftAssignOp) = %" PRIuPTR " SgLshiftAssignOp::pool_size = %d \n",
  165034             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLshiftAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLshiftAssignOp),SgLshiftAssignOp::pool_size);
  165035             :         }
  165036             : #endif
  165037             : 
  165038           0 :         SgLshiftAssignOp * pointer = (SgLshiftAssignOp*) ROSE_MALLOC ( SgLshiftAssignOp::pool_size * sizeof(SgLshiftAssignOp) );
  165039           0 :         assert( pointer != NULL );
  165040             : #if ROSE_ALLOC_MEMSET == 1
  165041             :         memset(pointer, 0x00, SgLshiftAssignOp::pool_size * sizeof(SgLshiftAssignOp));
  165042             : #elif ROSE_ALLOC_MEMSET == 2
  165043             :         memset(pointer, 0xCC, SgLshiftAssignOp::pool_size * sizeof(SgLshiftAssignOp));
  165044             : #endif
  165045           0 :         SgLshiftAssignOp::pools.push_back( (unsigned char*)(pointer) );
  165046           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLshiftAssignOp::pool_size * sizeof(SgLshiftAssignOp), V_SgLshiftAssignOp ) );
  165047             : 
  165048           0 :         if ( SgLshiftAssignOp::next_node != NULL ) {
  165049           0 :           if ( blockIndex > 0 ) {
  165050           0 :             SgLshiftAssignOp * blkptr = (SgLshiftAssignOp*)(SgLshiftAssignOp::pools[blockIndex-1]);
  165051           0 :             blkptr[ SgLshiftAssignOp::pool_size - 1 ].set_freepointer(pointer);
  165052             :           }
  165053             :         } else {
  165054           0 :           SgLshiftAssignOp::next_node = pointer;
  165055             :         }
  165056             : 
  165057           0 :         for (unsigned i = 0; i < SgLshiftAssignOp::pool_size-1; ++i)
  165058             :            {
  165059           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  165060             :            }
  165061           0 :         pointer[ SgLshiftAssignOp::pool_size -1 ].set_freepointer(NULL);
  165062             : 
  165063           0 :         blockIndex++;
  165064             :       }
  165065           2 :   }
  165066             : 
  165067             : //############################################################################
  165068             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  165069             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  165070             :  * not compressed. However, that stuff is not yet implemented! 
  165071             :  */
  165072             : unsigned long
  165073           0 : SgLshiftAssignOp::getNumberOfLastValidPointer()
  165074             :    {
  165075           0 :       SgLshiftAssignOp* testPointer = (SgLshiftAssignOp*)(SgLshiftAssignOp::pools.back());
  165076           0 :       unsigned long localIndex = SgLshiftAssignOp::pool_size - 1;
  165077           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  165078             :          {
  165079           0 :            localIndex--;
  165080             :          }
  165081           0 :       return (localIndex + SgLshiftAssignOp::pool_size * (SgLshiftAssignOp::pools.size()-1));
  165082             :    }
  165083             : 
  165084             : //############################################################################
  165085             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  165086             :  * memory pool and initializes the data member in class SgLshiftAssignOpStroageClass
  165087             :  * from its counterpart of SgLshiftAssignOp. The return value is just for checking, 
  165088             :  * that the whole StorageClassArray is initialized!
  165089             :  */
  165090             : unsigned long
  165091           0 : SgLshiftAssignOp::initializeStorageClassArray( SgLshiftAssignOpStorageClass *storageArray )
  165092             :    {
  165093           0 :      unsigned long storageCounter = 0;
  165094           0 :      std::vector < unsigned char* > :: const_iterator block = SgLshiftAssignOp::pools.begin();
  165095           0 :      SgLshiftAssignOp* pointer = NULL;
  165096           0 :      while ( block != SgLshiftAssignOp::pools.end() ) {
  165097           0 :           pointer = (SgLshiftAssignOp*) (*block);
  165098           0 :           for ( unsigned i = 0; i < SgLshiftAssignOp::pool_size; ++i ) {
  165099           0 :                if ( pointer->get_freepointer() != NULL ) {
  165100           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  165101           0 :                  storageArray++;
  165102           0 :                  storageCounter++;
  165103             :                }
  165104           0 :                pointer++;
  165105             :              }
  165106           0 :            block++;
  165107             :         }
  165108           0 :      return storageCounter;
  165109             :    }
  165110             : 
  165111             : /* #line 165112 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  165112             : 
  165113             : 
  165114             : 
  165115             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  165116             : 
  165117             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  165118             : 
  165119             : //############################################################################
  165120             : /* JH (02/02/2006) Constructor of the IR node SgRshiftAssignOp that takes its 
  165121             :  * corresponding StorageClass as parameter
  165122             :  */
  165123           2 : SgRshiftAssignOp :: SgRshiftAssignOp ( const SgRshiftAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  165124             :    {
  165125             : 
  165126             : 
  165127             : /* #line 165128 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  165128             : 
  165129           2 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  165130             : 
  165131             : 
  165132             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  165133             : 
  165134             : 
  165135           2 :    }
  165136             : 
  165137             : //############################################################################
  165138             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  165139             :  * within the working AST. 
  165140             :  */
  165141          12 : SgRshiftAssignOp * SgRshiftAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  165142          12 :      SgRshiftAssignOp* returnPointer = NULL;
  165143          12 :      if ( globalIndex != 0 )
  165144             :         {
  165145             : 
  165146             : #if FILE_IO_EXTRA_CHECK
  165147          12 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRshiftAssignOp ) ) <= globalIndex ) ;
  165148          12 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRshiftAssignOp + 1 ) ) );
  165149             : #endif
  165150          12 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRshiftAssignOp )  
  165151          12 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRshiftAssignOp );
  165152          12 :           unsigned long positionInPool = localIndex % SgRshiftAssignOp::pool_size;
  165153          12 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRshiftAssignOp::pool_size;
  165154             : 
  165155             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  165156             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  165157             : 
  165158          12 :           returnPointer = &( ( (SgRshiftAssignOp*)(SgRshiftAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  165159             : 
  165160          12 :           ROSE_ASSERT( returnPointer != NULL ) ;
  165161             :         }
  165162          12 :      return returnPointer ;
  165163             :    }
  165164             : 
  165165             : //############################################################################
  165166             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  165167             :   for the AST with the index astIndex
  165168             : */
  165169           0 : SgRshiftAssignOp * SgRshiftAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  165170           0 :      SgRshiftAssignOp* returnPointer = NULL;
  165171           0 :      if ( globalIndex != 0 )
  165172             :         {
  165173             : 
  165174             : #if FILE_IO_EXTRA_CHECK
  165175           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRshiftAssignOp ) ) <= globalIndex ) ;
  165176           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRshiftAssignOp + 1 ) ) );
  165177             : #endif
  165178           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRshiftAssignOp )
  165179           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRshiftAssignOp );
  165180           0 :           unsigned long positionInPool = localIndex % SgRshiftAssignOp::pool_size ;
  165181           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRshiftAssignOp::pool_size ;
  165182             : 
  165183             : #if FILE_IO_EXTRA_CHECK
  165184             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  165185             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  165186             : #endif
  165187             : 
  165188           0 :           returnPointer = &( ( (SgRshiftAssignOp*)(SgRshiftAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  165189             : 
  165190             : #if FILE_IO_EXTRA_CHECK
  165191           0 :           assert ( returnPointer != NULL ) ;
  165192             : #endif
  165193             :         }
  165194           0 :      return returnPointer ;
  165195             :    }
  165196             : 
  165197             : //############################################################################
  165198             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  165199             :  * pool size! We set for every valid object in the memory pool the freepointer
  165200             :  * to the global index and increase the global index afterwards. For all the 
  165201             :  * invalid objects (means address ranges within the memory pool that were not
  165202             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  165203             :  * distinguish valid from invalid objects! 
  165204             :  */
  165205             : unsigned long
  165206           5 : SgRshiftAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  165207             :    {
  165208           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  165209           5 :      SgRshiftAssignOp* pointer = NULL;
  165210           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  165211           5 :      std::vector < unsigned char* > :: const_iterator block;
  165212           6 :      for ( block = SgRshiftAssignOp::pools.begin(); block != SgRshiftAssignOp::pools.end() ; ++block )
  165213             :         {
  165214           1 :           pointer = (SgRshiftAssignOp*)(*block);
  165215        2001 :           for (unsigned i = 0; i < SgRshiftAssignOp::pool_size; ++i )
  165216             :              {
  165217             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  165218             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  165219             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  165220             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  165221             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  165222             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  165223             :             // properly; so this will have to be checked next.
  165224             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  165225             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  165226        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  165227             :                   {
  165228           2 :                     pointer[i].set_freepointer((SgRshiftAssignOp*)(globalIndex));
  165229           2 :                     globalIndex++;
  165230             :                   }
  165231             :                else
  165232             :                   {
  165233        1998 :                     pointer[i].set_freepointer(NULL);
  165234             :                   }
  165235             :               }
  165236             :         }
  165237           5 :      return globalIndex;
  165238             :    }
  165239             : 
  165240             : //############################################################################
  165241             : // JH (01/14/2006)
  165242             : void
  165243           5 : SgRshiftAssignOp::resetValidFreepointers( )
  165244             :    {
  165245           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  165246           5 :      SgRshiftAssignOp* pointer = NULL;
  165247           5 :      std::vector < unsigned char* > :: const_iterator block;
  165248           5 :      SgRshiftAssignOp* pointerOfLinkedList = NULL;
  165249           6 :      for ( block = SgRshiftAssignOp::pools.begin(); block != SgRshiftAssignOp::pools.end() ; ++block )
  165250             :         {
  165251           1 :           pointer = (SgRshiftAssignOp*)(*block);
  165252        2001 :           for (unsigned i = 0; i < SgRshiftAssignOp::pool_size; ++i )
  165253             :              {
  165254             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  165255             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  165256             :             // memory blocks!.
  165257        2000 :                if ( pointer[i].get_freepointer() != NULL )
  165258             :                   {
  165259           2 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  165260             :                   }
  165261             :                else
  165262             :                   {
  165263        1998 :                     if ( pointerOfLinkedList == NULL )
  165264             :                        {
  165265           1 :                          SgRshiftAssignOp::next_node = &(pointer[i]);
  165266             :                        }
  165267             :                     else
  165268             :                        {
  165269             :                       // printf ("In SgRshiftAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  165270        1997 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  165271             :                        }
  165272             :                     pointerOfLinkedList = &(pointer[i]);
  165273             :                   }
  165274             :               }
  165275             :         }
  165276             : 
  165277           5 :      if ( pointerOfLinkedList != NULL )
  165278             :         {
  165279             :        // printf ("In SgRshiftAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  165280           1 :           pointerOfLinkedList->set_freepointer(NULL);
  165281             :        // DQ (6/6/2010): Temporary debugging...
  165282             :        //   ROSE_ASSERT(false);
  165283             :         }
  165284             : 
  165285           5 :      return ;
  165286             :    }
  165287             : 
  165288             : //############################################################################
  165289             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  165290             :  * within the memory pool and resets the freepointers, in order to achieve a 
  165291             :  * linked list, that has no jumps and starts at the beginning! This function 
  165292             :  * does not extend the memory pool, since we do not delete any memory blocks,
  165293             :  * but delete the valid objects.  
  165294             :  */
  165295             : void
  165296           0 : SgRshiftAssignOp::clearMemoryPool( )
  165297             :    {
  165298             :   // printf ("Inside of SgRshiftAssignOp::clearMemoryPool() \n");
  165299             : 
  165300           0 :      SgRshiftAssignOp* pointer = NULL, *tempPointer = NULL;
  165301           0 :      std::vector < unsigned char* > :: const_iterator block;
  165302           0 :      if ( SgRshiftAssignOp::pools.empty() == false )
  165303             :         {
  165304           0 :           block = SgRshiftAssignOp::pools.begin() ;
  165305           0 :           SgRshiftAssignOp::next_node = (SgRshiftAssignOp*) (*block);
  165306             : 
  165307           0 :           while ( block != SgRshiftAssignOp::pools.end() )
  165308             :              {
  165309           0 :                pointer = (SgRshiftAssignOp*) (*block);
  165310           0 :                if ( tempPointer != NULL )
  165311             :                   {
  165312           0 :                     tempPointer->set_freepointer(pointer);
  165313             :                   }
  165314           0 :                for (unsigned i = 0; i < SgRshiftAssignOp::pool_size - 1; ++i)
  165315             :                   {
  165316           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  165317             :                   }
  165318           0 :                 pointer[SgRshiftAssignOp::pool_size-1].set_freepointer(NULL);
  165319           0 :                 tempPointer = &(pointer[SgRshiftAssignOp::pool_size-1]);
  165320           0 :                 ++block;
  165321             :              }
  165322             :         }
  165323           0 :    }
  165324             : 
  165325           5 : void SgRshiftAssignOp::deleteMemoryPool() {
  165326           7 :   for (auto p: SgRshiftAssignOp::pools) {
  165327           2 :     ROSE_FREE(p);
  165328             :   }
  165329           5 :   SgRshiftAssignOp::next_node = nullptr;
  165330           5 :   SgRshiftAssignOp::pools.clear();
  165331           5 : }
  165332             : 
  165333             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  165334             : //                 reading multiple binary files to for a single AST.
  165335             : /////////// new version ////////////////////////////////
  165336             : //############################################################################
  165337             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  165338             : void
  165339           2 : SgRshiftAssignOp::extendMemoryPoolForFileIO( )
  165340             :   {
  165341           2 :     size_t blockIndex = SgRshiftAssignOp::pools.size();
  165342           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRshiftAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRshiftAssignOp);
  165343             : 
  165344           3 :     while ( (blockIndex * SgRshiftAssignOp::pool_size) < newPoolSize)
  165345             :       {
  165346             : #if ROSE_ALLOC_TRACE
  165347             :         if (blockIndex > 0) {
  165348             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRshiftAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRshiftAssignOp) = %" PRIuPTR " SgRshiftAssignOp::pool_size = %d \n",
  165349             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRshiftAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRshiftAssignOp),SgRshiftAssignOp::pool_size);
  165350             :         }
  165351             : #endif
  165352             : 
  165353           1 :         SgRshiftAssignOp * pointer = (SgRshiftAssignOp*) ROSE_MALLOC ( SgRshiftAssignOp::pool_size * sizeof(SgRshiftAssignOp) );
  165354           1 :         assert( pointer != NULL );
  165355             : #if ROSE_ALLOC_MEMSET == 1
  165356             :         memset(pointer, 0x00, SgRshiftAssignOp::pool_size * sizeof(SgRshiftAssignOp));
  165357             : #elif ROSE_ALLOC_MEMSET == 2
  165358             :         memset(pointer, 0xCC, SgRshiftAssignOp::pool_size * sizeof(SgRshiftAssignOp));
  165359             : #endif
  165360           1 :         SgRshiftAssignOp::pools.push_back( (unsigned char*)(pointer) );
  165361           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRshiftAssignOp::pool_size * sizeof(SgRshiftAssignOp), V_SgRshiftAssignOp ) );
  165362             : 
  165363           1 :         if ( SgRshiftAssignOp::next_node != NULL ) {
  165364           0 :           if ( blockIndex > 0 ) {
  165365           0 :             SgRshiftAssignOp * blkptr = (SgRshiftAssignOp*)(SgRshiftAssignOp::pools[blockIndex-1]);
  165366           0 :             blkptr[ SgRshiftAssignOp::pool_size - 1 ].set_freepointer(pointer);
  165367             :           }
  165368             :         } else {
  165369           1 :           SgRshiftAssignOp::next_node = pointer;
  165370             :         }
  165371             : 
  165372        2000 :         for (unsigned i = 0; i < SgRshiftAssignOp::pool_size-1; ++i)
  165373             :            {
  165374        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  165375             :            }
  165376           1 :         pointer[ SgRshiftAssignOp::pool_size -1 ].set_freepointer(NULL);
  165377             : 
  165378           1 :         blockIndex++;
  165379             :       }
  165380           2 :   }
  165381             : 
  165382             : //############################################################################
  165383             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  165384             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  165385             :  * not compressed. However, that stuff is not yet implemented! 
  165386             :  */
  165387             : unsigned long
  165388           0 : SgRshiftAssignOp::getNumberOfLastValidPointer()
  165389             :    {
  165390           0 :       SgRshiftAssignOp* testPointer = (SgRshiftAssignOp*)(SgRshiftAssignOp::pools.back());
  165391           0 :       unsigned long localIndex = SgRshiftAssignOp::pool_size - 1;
  165392           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  165393             :          {
  165394           0 :            localIndex--;
  165395             :          }
  165396           0 :       return (localIndex + SgRshiftAssignOp::pool_size * (SgRshiftAssignOp::pools.size()-1));
  165397             :    }
  165398             : 
  165399             : //############################################################################
  165400             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  165401             :  * memory pool and initializes the data member in class SgRshiftAssignOpStroageClass
  165402             :  * from its counterpart of SgRshiftAssignOp. The return value is just for checking, 
  165403             :  * that the whole StorageClassArray is initialized!
  165404             :  */
  165405             : unsigned long
  165406           1 : SgRshiftAssignOp::initializeStorageClassArray( SgRshiftAssignOpStorageClass *storageArray )
  165407             :    {
  165408           1 :      unsigned long storageCounter = 0;
  165409           1 :      std::vector < unsigned char* > :: const_iterator block = SgRshiftAssignOp::pools.begin();
  165410           1 :      SgRshiftAssignOp* pointer = NULL;
  165411           2 :      while ( block != SgRshiftAssignOp::pools.end() ) {
  165412           1 :           pointer = (SgRshiftAssignOp*) (*block);
  165413        2001 :           for ( unsigned i = 0; i < SgRshiftAssignOp::pool_size; ++i ) {
  165414        2000 :                if ( pointer->get_freepointer() != NULL ) {
  165415           2 :                  storageArray->pickOutIRNodeData (pointer) ;
  165416           2 :                  storageArray++;
  165417           2 :                  storageCounter++;
  165418             :                }
  165419        2000 :                pointer++;
  165420             :              }
  165421           1 :            block++;
  165422             :         }
  165423           1 :      return storageCounter;
  165424             :    }
  165425             : 
  165426             : /* #line 165427 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  165427             : 
  165428             : 
  165429             : 
  165430             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  165431             : 
  165432             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  165433             : 
  165434             : //############################################################################
  165435             : /* JH (02/02/2006) Constructor of the IR node SgIntegerDivideAssignOp that takes its 
  165436             :  * corresponding StorageClass as parameter
  165437             :  */
  165438           0 : SgIntegerDivideAssignOp :: SgIntegerDivideAssignOp ( const SgIntegerDivideAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  165439             :    {
  165440             : 
  165441             : 
  165442             : /* #line 165443 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  165443             : 
  165444           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  165445             : 
  165446             : 
  165447             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  165448             : 
  165449             : 
  165450           0 :    }
  165451             : 
  165452             : //############################################################################
  165453             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  165454             :  * within the working AST. 
  165455             :  */
  165456           0 : SgIntegerDivideAssignOp * SgIntegerDivideAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  165457           0 :      SgIntegerDivideAssignOp* returnPointer = NULL;
  165458           0 :      if ( globalIndex != 0 )
  165459             :         {
  165460             : 
  165461             : #if FILE_IO_EXTRA_CHECK
  165462           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIntegerDivideAssignOp ) ) <= globalIndex ) ;
  165463           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntegerDivideAssignOp + 1 ) ) );
  165464             : #endif
  165465           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntegerDivideAssignOp )  
  165466           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIntegerDivideAssignOp );
  165467           0 :           unsigned long positionInPool = localIndex % SgIntegerDivideAssignOp::pool_size;
  165468           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntegerDivideAssignOp::pool_size;
  165469             : 
  165470             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  165471             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  165472             : 
  165473           0 :           returnPointer = &( ( (SgIntegerDivideAssignOp*)(SgIntegerDivideAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  165474             : 
  165475           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  165476             :         }
  165477           0 :      return returnPointer ;
  165478             :    }
  165479             : 
  165480             : //############################################################################
  165481             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  165482             :   for the AST with the index astIndex
  165483             : */
  165484           0 : SgIntegerDivideAssignOp * SgIntegerDivideAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  165485           0 :      SgIntegerDivideAssignOp* returnPointer = NULL;
  165486           0 :      if ( globalIndex != 0 )
  165487             :         {
  165488             : 
  165489             : #if FILE_IO_EXTRA_CHECK
  165490           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIntegerDivideAssignOp ) ) <= globalIndex ) ;
  165491           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntegerDivideAssignOp + 1 ) ) );
  165492             : #endif
  165493           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntegerDivideAssignOp )
  165494           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIntegerDivideAssignOp );
  165495           0 :           unsigned long positionInPool = localIndex % SgIntegerDivideAssignOp::pool_size ;
  165496           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntegerDivideAssignOp::pool_size ;
  165497             : 
  165498             : #if FILE_IO_EXTRA_CHECK
  165499             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  165500             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  165501             : #endif
  165502             : 
  165503           0 :           returnPointer = &( ( (SgIntegerDivideAssignOp*)(SgIntegerDivideAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  165504             : 
  165505             : #if FILE_IO_EXTRA_CHECK
  165506           0 :           assert ( returnPointer != NULL ) ;
  165507             : #endif
  165508             :         }
  165509           0 :      return returnPointer ;
  165510             :    }
  165511             : 
  165512             : //############################################################################
  165513             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  165514             :  * pool size! We set for every valid object in the memory pool the freepointer
  165515             :  * to the global index and increase the global index afterwards. For all the 
  165516             :  * invalid objects (means address ranges within the memory pool that were not
  165517             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  165518             :  * distinguish valid from invalid objects! 
  165519             :  */
  165520             : unsigned long
  165521           5 : SgIntegerDivideAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  165522             :    {
  165523           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  165524           5 :      SgIntegerDivideAssignOp* pointer = NULL;
  165525           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  165526           5 :      std::vector < unsigned char* > :: const_iterator block;
  165527           5 :      for ( block = SgIntegerDivideAssignOp::pools.begin(); block != SgIntegerDivideAssignOp::pools.end() ; ++block )
  165528             :         {
  165529           0 :           pointer = (SgIntegerDivideAssignOp*)(*block);
  165530           0 :           for (unsigned i = 0; i < SgIntegerDivideAssignOp::pool_size; ++i )
  165531             :              {
  165532             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  165533             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  165534             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  165535             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  165536             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  165537             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  165538             :             // properly; so this will have to be checked next.
  165539             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  165540             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  165541           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  165542             :                   {
  165543           0 :                     pointer[i].set_freepointer((SgIntegerDivideAssignOp*)(globalIndex));
  165544           0 :                     globalIndex++;
  165545             :                   }
  165546             :                else
  165547             :                   {
  165548           0 :                     pointer[i].set_freepointer(NULL);
  165549             :                   }
  165550             :               }
  165551             :         }
  165552           5 :      return globalIndex;
  165553             :    }
  165554             : 
  165555             : //############################################################################
  165556             : // JH (01/14/2006)
  165557             : void
  165558           5 : SgIntegerDivideAssignOp::resetValidFreepointers( )
  165559             :    {
  165560           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  165561           5 :      SgIntegerDivideAssignOp* pointer = NULL;
  165562           5 :      std::vector < unsigned char* > :: const_iterator block;
  165563           5 :      SgIntegerDivideAssignOp* pointerOfLinkedList = NULL;
  165564           5 :      for ( block = SgIntegerDivideAssignOp::pools.begin(); block != SgIntegerDivideAssignOp::pools.end() ; ++block )
  165565             :         {
  165566           0 :           pointer = (SgIntegerDivideAssignOp*)(*block);
  165567           0 :           for (unsigned i = 0; i < SgIntegerDivideAssignOp::pool_size; ++i )
  165568             :              {
  165569             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  165570             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  165571             :             // memory blocks!.
  165572           0 :                if ( pointer[i].get_freepointer() != NULL )
  165573             :                   {
  165574           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  165575             :                   }
  165576             :                else
  165577             :                   {
  165578           0 :                     if ( pointerOfLinkedList == NULL )
  165579             :                        {
  165580           0 :                          SgIntegerDivideAssignOp::next_node = &(pointer[i]);
  165581             :                        }
  165582             :                     else
  165583             :                        {
  165584             :                       // printf ("In SgIntegerDivideAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  165585           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  165586             :                        }
  165587             :                     pointerOfLinkedList = &(pointer[i]);
  165588             :                   }
  165589             :               }
  165590             :         }
  165591             : 
  165592           5 :      if ( pointerOfLinkedList != NULL )
  165593             :         {
  165594             :        // printf ("In SgIntegerDivideAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  165595           0 :           pointerOfLinkedList->set_freepointer(NULL);
  165596             :        // DQ (6/6/2010): Temporary debugging...
  165597             :        //   ROSE_ASSERT(false);
  165598             :         }
  165599             : 
  165600           5 :      return ;
  165601             :    }
  165602             : 
  165603             : //############################################################################
  165604             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  165605             :  * within the memory pool and resets the freepointers, in order to achieve a 
  165606             :  * linked list, that has no jumps and starts at the beginning! This function 
  165607             :  * does not extend the memory pool, since we do not delete any memory blocks,
  165608             :  * but delete the valid objects.  
  165609             :  */
  165610             : void
  165611           0 : SgIntegerDivideAssignOp::clearMemoryPool( )
  165612             :    {
  165613             :   // printf ("Inside of SgIntegerDivideAssignOp::clearMemoryPool() \n");
  165614             : 
  165615           0 :      SgIntegerDivideAssignOp* pointer = NULL, *tempPointer = NULL;
  165616           0 :      std::vector < unsigned char* > :: const_iterator block;
  165617           0 :      if ( SgIntegerDivideAssignOp::pools.empty() == false )
  165618             :         {
  165619           0 :           block = SgIntegerDivideAssignOp::pools.begin() ;
  165620           0 :           SgIntegerDivideAssignOp::next_node = (SgIntegerDivideAssignOp*) (*block);
  165621             : 
  165622           0 :           while ( block != SgIntegerDivideAssignOp::pools.end() )
  165623             :              {
  165624           0 :                pointer = (SgIntegerDivideAssignOp*) (*block);
  165625           0 :                if ( tempPointer != NULL )
  165626             :                   {
  165627           0 :                     tempPointer->set_freepointer(pointer);
  165628             :                   }
  165629           0 :                for (unsigned i = 0; i < SgIntegerDivideAssignOp::pool_size - 1; ++i)
  165630             :                   {
  165631           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  165632             :                   }
  165633           0 :                 pointer[SgIntegerDivideAssignOp::pool_size-1].set_freepointer(NULL);
  165634           0 :                 tempPointer = &(pointer[SgIntegerDivideAssignOp::pool_size-1]);
  165635           0 :                 ++block;
  165636             :              }
  165637             :         }
  165638           0 :    }
  165639             : 
  165640           5 : void SgIntegerDivideAssignOp::deleteMemoryPool() {
  165641           5 :   for (auto p: SgIntegerDivideAssignOp::pools) {
  165642           0 :     ROSE_FREE(p);
  165643             :   }
  165644           5 :   SgIntegerDivideAssignOp::next_node = nullptr;
  165645           5 :   SgIntegerDivideAssignOp::pools.clear();
  165646           5 : }
  165647             : 
  165648             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  165649             : //                 reading multiple binary files to for a single AST.
  165650             : /////////// new version ////////////////////////////////
  165651             : //############################################################################
  165652             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  165653             : void
  165654           2 : SgIntegerDivideAssignOp::extendMemoryPoolForFileIO( )
  165655             :   {
  165656           2 :     size_t blockIndex = SgIntegerDivideAssignOp::pools.size();
  165657           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIntegerDivideAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntegerDivideAssignOp);
  165658             : 
  165659           2 :     while ( (blockIndex * SgIntegerDivideAssignOp::pool_size) < newPoolSize)
  165660             :       {
  165661             : #if ROSE_ALLOC_TRACE
  165662             :         if (blockIndex > 0) {
  165663             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIntegerDivideAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntegerDivideAssignOp) = %" PRIuPTR " SgIntegerDivideAssignOp::pool_size = %d \n",
  165664             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIntegerDivideAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntegerDivideAssignOp),SgIntegerDivideAssignOp::pool_size);
  165665             :         }
  165666             : #endif
  165667             : 
  165668           0 :         SgIntegerDivideAssignOp * pointer = (SgIntegerDivideAssignOp*) ROSE_MALLOC ( SgIntegerDivideAssignOp::pool_size * sizeof(SgIntegerDivideAssignOp) );
  165669           0 :         assert( pointer != NULL );
  165670             : #if ROSE_ALLOC_MEMSET == 1
  165671             :         memset(pointer, 0x00, SgIntegerDivideAssignOp::pool_size * sizeof(SgIntegerDivideAssignOp));
  165672             : #elif ROSE_ALLOC_MEMSET == 2
  165673             :         memset(pointer, 0xCC, SgIntegerDivideAssignOp::pool_size * sizeof(SgIntegerDivideAssignOp));
  165674             : #endif
  165675           0 :         SgIntegerDivideAssignOp::pools.push_back( (unsigned char*)(pointer) );
  165676           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIntegerDivideAssignOp::pool_size * sizeof(SgIntegerDivideAssignOp), V_SgIntegerDivideAssignOp ) );
  165677             : 
  165678           0 :         if ( SgIntegerDivideAssignOp::next_node != NULL ) {
  165679           0 :           if ( blockIndex > 0 ) {
  165680           0 :             SgIntegerDivideAssignOp * blkptr = (SgIntegerDivideAssignOp*)(SgIntegerDivideAssignOp::pools[blockIndex-1]);
  165681           0 :             blkptr[ SgIntegerDivideAssignOp::pool_size - 1 ].set_freepointer(pointer);
  165682             :           }
  165683             :         } else {
  165684           0 :           SgIntegerDivideAssignOp::next_node = pointer;
  165685             :         }
  165686             : 
  165687           0 :         for (unsigned i = 0; i < SgIntegerDivideAssignOp::pool_size-1; ++i)
  165688             :            {
  165689           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  165690             :            }
  165691           0 :         pointer[ SgIntegerDivideAssignOp::pool_size -1 ].set_freepointer(NULL);
  165692             : 
  165693           0 :         blockIndex++;
  165694             :       }
  165695           2 :   }
  165696             : 
  165697             : //############################################################################
  165698             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  165699             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  165700             :  * not compressed. However, that stuff is not yet implemented! 
  165701             :  */
  165702             : unsigned long
  165703           0 : SgIntegerDivideAssignOp::getNumberOfLastValidPointer()
  165704             :    {
  165705           0 :       SgIntegerDivideAssignOp* testPointer = (SgIntegerDivideAssignOp*)(SgIntegerDivideAssignOp::pools.back());
  165706           0 :       unsigned long localIndex = SgIntegerDivideAssignOp::pool_size - 1;
  165707           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  165708             :          {
  165709           0 :            localIndex--;
  165710             :          }
  165711           0 :       return (localIndex + SgIntegerDivideAssignOp::pool_size * (SgIntegerDivideAssignOp::pools.size()-1));
  165712             :    }
  165713             : 
  165714             : //############################################################################
  165715             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  165716             :  * memory pool and initializes the data member in class SgIntegerDivideAssignOpStroageClass
  165717             :  * from its counterpart of SgIntegerDivideAssignOp. The return value is just for checking, 
  165718             :  * that the whole StorageClassArray is initialized!
  165719             :  */
  165720             : unsigned long
  165721           0 : SgIntegerDivideAssignOp::initializeStorageClassArray( SgIntegerDivideAssignOpStorageClass *storageArray )
  165722             :    {
  165723           0 :      unsigned long storageCounter = 0;
  165724           0 :      std::vector < unsigned char* > :: const_iterator block = SgIntegerDivideAssignOp::pools.begin();
  165725           0 :      SgIntegerDivideAssignOp* pointer = NULL;
  165726           0 :      while ( block != SgIntegerDivideAssignOp::pools.end() ) {
  165727           0 :           pointer = (SgIntegerDivideAssignOp*) (*block);
  165728           0 :           for ( unsigned i = 0; i < SgIntegerDivideAssignOp::pool_size; ++i ) {
  165729           0 :                if ( pointer->get_freepointer() != NULL ) {
  165730           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  165731           0 :                  storageArray++;
  165732           0 :                  storageCounter++;
  165733             :                }
  165734           0 :                pointer++;
  165735             :              }
  165736           0 :            block++;
  165737             :         }
  165738           0 :      return storageCounter;
  165739             :    }
  165740             : 
  165741             : /* #line 165742 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  165742             : 
  165743             : 
  165744             : 
  165745             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  165746             : 
  165747             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  165748             : 
  165749             : //############################################################################
  165750             : /* JH (02/02/2006) Constructor of the IR node SgExponentiationAssignOp that takes its 
  165751             :  * corresponding StorageClass as parameter
  165752             :  */
  165753           0 : SgExponentiationAssignOp :: SgExponentiationAssignOp ( const SgExponentiationAssignOpStorageClass& storageSource )   : SgCompoundAssignOp (storageSource)
  165754             :    {
  165755             : 
  165756             : 
  165757             : /* #line 165758 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  165758             : 
  165759           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  165760             : 
  165761             : 
  165762             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  165763             : 
  165764             : 
  165765           0 :    }
  165766             : 
  165767             : //############################################################################
  165768             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  165769             :  * within the working AST. 
  165770             :  */
  165771           0 : SgExponentiationAssignOp * SgExponentiationAssignOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  165772           0 :      SgExponentiationAssignOp* returnPointer = NULL;
  165773           0 :      if ( globalIndex != 0 )
  165774             :         {
  165775             : 
  165776             : #if FILE_IO_EXTRA_CHECK
  165777           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgExponentiationAssignOp ) ) <= globalIndex ) ;
  165778           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExponentiationAssignOp + 1 ) ) );
  165779             : #endif
  165780           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExponentiationAssignOp )  
  165781           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgExponentiationAssignOp );
  165782           0 :           unsigned long positionInPool = localIndex % SgExponentiationAssignOp::pool_size;
  165783           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExponentiationAssignOp::pool_size;
  165784             : 
  165785             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  165786             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  165787             : 
  165788           0 :           returnPointer = &( ( (SgExponentiationAssignOp*)(SgExponentiationAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  165789             : 
  165790           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  165791             :         }
  165792           0 :      return returnPointer ;
  165793             :    }
  165794             : 
  165795             : //############################################################################
  165796             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  165797             :   for the AST with the index astIndex
  165798             : */
  165799           0 : SgExponentiationAssignOp * SgExponentiationAssignOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  165800           0 :      SgExponentiationAssignOp* returnPointer = NULL;
  165801           0 :      if ( globalIndex != 0 )
  165802             :         {
  165803             : 
  165804             : #if FILE_IO_EXTRA_CHECK
  165805           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgExponentiationAssignOp ) ) <= globalIndex ) ;
  165806           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExponentiationAssignOp + 1 ) ) );
  165807             : #endif
  165808           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExponentiationAssignOp )
  165809           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgExponentiationAssignOp );
  165810           0 :           unsigned long positionInPool = localIndex % SgExponentiationAssignOp::pool_size ;
  165811           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExponentiationAssignOp::pool_size ;
  165812             : 
  165813             : #if FILE_IO_EXTRA_CHECK
  165814             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  165815             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  165816             : #endif
  165817             : 
  165818           0 :           returnPointer = &( ( (SgExponentiationAssignOp*)(SgExponentiationAssignOp::pools[memoryBlock]) ) [positionInPool]) ;
  165819             : 
  165820             : #if FILE_IO_EXTRA_CHECK
  165821           0 :           assert ( returnPointer != NULL ) ;
  165822             : #endif
  165823             :         }
  165824           0 :      return returnPointer ;
  165825             :    }
  165826             : 
  165827             : //############################################################################
  165828             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  165829             :  * pool size! We set for every valid object in the memory pool the freepointer
  165830             :  * to the global index and increase the global index afterwards. For all the 
  165831             :  * invalid objects (means address ranges within the memory pool that were not
  165832             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  165833             :  * distinguish valid from invalid objects! 
  165834             :  */
  165835             : unsigned long
  165836           5 : SgExponentiationAssignOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  165837             :    {
  165838           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  165839           5 :      SgExponentiationAssignOp* pointer = NULL;
  165840           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  165841           5 :      std::vector < unsigned char* > :: const_iterator block;
  165842           5 :      for ( block = SgExponentiationAssignOp::pools.begin(); block != SgExponentiationAssignOp::pools.end() ; ++block )
  165843             :         {
  165844           0 :           pointer = (SgExponentiationAssignOp*)(*block);
  165845           0 :           for (unsigned i = 0; i < SgExponentiationAssignOp::pool_size; ++i )
  165846             :              {
  165847             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  165848             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  165849             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  165850             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  165851             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  165852             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  165853             :             // properly; so this will have to be checked next.
  165854             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  165855             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  165856           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  165857             :                   {
  165858           0 :                     pointer[i].set_freepointer((SgExponentiationAssignOp*)(globalIndex));
  165859           0 :                     globalIndex++;
  165860             :                   }
  165861             :                else
  165862             :                   {
  165863           0 :                     pointer[i].set_freepointer(NULL);
  165864             :                   }
  165865             :               }
  165866             :         }
  165867           5 :      return globalIndex;
  165868             :    }
  165869             : 
  165870             : //############################################################################
  165871             : // JH (01/14/2006)
  165872             : void
  165873           5 : SgExponentiationAssignOp::resetValidFreepointers( )
  165874             :    {
  165875           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  165876           5 :      SgExponentiationAssignOp* pointer = NULL;
  165877           5 :      std::vector < unsigned char* > :: const_iterator block;
  165878           5 :      SgExponentiationAssignOp* pointerOfLinkedList = NULL;
  165879           5 :      for ( block = SgExponentiationAssignOp::pools.begin(); block != SgExponentiationAssignOp::pools.end() ; ++block )
  165880             :         {
  165881           0 :           pointer = (SgExponentiationAssignOp*)(*block);
  165882           0 :           for (unsigned i = 0; i < SgExponentiationAssignOp::pool_size; ++i )
  165883             :              {
  165884             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  165885             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  165886             :             // memory blocks!.
  165887           0 :                if ( pointer[i].get_freepointer() != NULL )
  165888             :                   {
  165889           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  165890             :                   }
  165891             :                else
  165892             :                   {
  165893           0 :                     if ( pointerOfLinkedList == NULL )
  165894             :                        {
  165895           0 :                          SgExponentiationAssignOp::next_node = &(pointer[i]);
  165896             :                        }
  165897             :                     else
  165898             :                        {
  165899             :                       // printf ("In SgExponentiationAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  165900           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  165901             :                        }
  165902             :                     pointerOfLinkedList = &(pointer[i]);
  165903             :                   }
  165904             :               }
  165905             :         }
  165906             : 
  165907           5 :      if ( pointerOfLinkedList != NULL )
  165908             :         {
  165909             :        // printf ("In SgExponentiationAssignOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  165910           0 :           pointerOfLinkedList->set_freepointer(NULL);
  165911             :        // DQ (6/6/2010): Temporary debugging...
  165912             :        //   ROSE_ASSERT(false);
  165913             :         }
  165914             : 
  165915           5 :      return ;
  165916             :    }
  165917             : 
  165918             : //############################################################################
  165919             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  165920             :  * within the memory pool and resets the freepointers, in order to achieve a 
  165921             :  * linked list, that has no jumps and starts at the beginning! This function 
  165922             :  * does not extend the memory pool, since we do not delete any memory blocks,
  165923             :  * but delete the valid objects.  
  165924             :  */
  165925             : void
  165926           0 : SgExponentiationAssignOp::clearMemoryPool( )
  165927             :    {
  165928             :   // printf ("Inside of SgExponentiationAssignOp::clearMemoryPool() \n");
  165929             : 
  165930           0 :      SgExponentiationAssignOp* pointer = NULL, *tempPointer = NULL;
  165931           0 :      std::vector < unsigned char* > :: const_iterator block;
  165932           0 :      if ( SgExponentiationAssignOp::pools.empty() == false )
  165933             :         {
  165934           0 :           block = SgExponentiationAssignOp::pools.begin() ;
  165935           0 :           SgExponentiationAssignOp::next_node = (SgExponentiationAssignOp*) (*block);
  165936             : 
  165937           0 :           while ( block != SgExponentiationAssignOp::pools.end() )
  165938             :              {
  165939           0 :                pointer = (SgExponentiationAssignOp*) (*block);
  165940           0 :                if ( tempPointer != NULL )
  165941             :                   {
  165942           0 :                     tempPointer->set_freepointer(pointer);
  165943             :                   }
  165944           0 :                for (unsigned i = 0; i < SgExponentiationAssignOp::pool_size - 1; ++i)
  165945             :                   {
  165946           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  165947             :                   }
  165948           0 :                 pointer[SgExponentiationAssignOp::pool_size-1].set_freepointer(NULL);
  165949           0 :                 tempPointer = &(pointer[SgExponentiationAssignOp::pool_size-1]);
  165950           0 :                 ++block;
  165951             :              }
  165952             :         }
  165953           0 :    }
  165954             : 
  165955           5 : void SgExponentiationAssignOp::deleteMemoryPool() {
  165956           5 :   for (auto p: SgExponentiationAssignOp::pools) {
  165957           0 :     ROSE_FREE(p);
  165958             :   }
  165959           5 :   SgExponentiationAssignOp::next_node = nullptr;
  165960           5 :   SgExponentiationAssignOp::pools.clear();
  165961           5 : }
  165962             : 
  165963             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  165964             : //                 reading multiple binary files to for a single AST.
  165965             : /////////// new version ////////////////////////////////
  165966             : //############################################################################
  165967             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  165968             : void
  165969           2 : SgExponentiationAssignOp::extendMemoryPoolForFileIO( )
  165970             :   {
  165971           2 :     size_t blockIndex = SgExponentiationAssignOp::pools.size();
  165972           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgExponentiationAssignOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgExponentiationAssignOp);
  165973             : 
  165974           2 :     while ( (blockIndex * SgExponentiationAssignOp::pool_size) < newPoolSize)
  165975             :       {
  165976             : #if ROSE_ALLOC_TRACE
  165977             :         if (blockIndex > 0) {
  165978             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgExponentiationAssignOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgExponentiationAssignOp) = %" PRIuPTR " SgExponentiationAssignOp::pool_size = %d \n",
  165979             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgExponentiationAssignOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgExponentiationAssignOp),SgExponentiationAssignOp::pool_size);
  165980             :         }
  165981             : #endif
  165982             : 
  165983           0 :         SgExponentiationAssignOp * pointer = (SgExponentiationAssignOp*) ROSE_MALLOC ( SgExponentiationAssignOp::pool_size * sizeof(SgExponentiationAssignOp) );
  165984           0 :         assert( pointer != NULL );
  165985             : #if ROSE_ALLOC_MEMSET == 1
  165986             :         memset(pointer, 0x00, SgExponentiationAssignOp::pool_size * sizeof(SgExponentiationAssignOp));
  165987             : #elif ROSE_ALLOC_MEMSET == 2
  165988             :         memset(pointer, 0xCC, SgExponentiationAssignOp::pool_size * sizeof(SgExponentiationAssignOp));
  165989             : #endif
  165990           0 :         SgExponentiationAssignOp::pools.push_back( (unsigned char*)(pointer) );
  165991           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgExponentiationAssignOp::pool_size * sizeof(SgExponentiationAssignOp), V_SgExponentiationAssignOp ) );
  165992             : 
  165993           0 :         if ( SgExponentiationAssignOp::next_node != NULL ) {
  165994           0 :           if ( blockIndex > 0 ) {
  165995           0 :             SgExponentiationAssignOp * blkptr = (SgExponentiationAssignOp*)(SgExponentiationAssignOp::pools[blockIndex-1]);
  165996           0 :             blkptr[ SgExponentiationAssignOp::pool_size - 1 ].set_freepointer(pointer);
  165997             :           }
  165998             :         } else {
  165999           0 :           SgExponentiationAssignOp::next_node = pointer;
  166000             :         }
  166001             : 
  166002           0 :         for (unsigned i = 0; i < SgExponentiationAssignOp::pool_size-1; ++i)
  166003             :            {
  166004           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  166005             :            }
  166006           0 :         pointer[ SgExponentiationAssignOp::pool_size -1 ].set_freepointer(NULL);
  166007             : 
  166008           0 :         blockIndex++;
  166009             :       }
  166010           2 :   }
  166011             : 
  166012             : //############################################################################
  166013             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  166014             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  166015             :  * not compressed. However, that stuff is not yet implemented! 
  166016             :  */
  166017             : unsigned long
  166018           0 : SgExponentiationAssignOp::getNumberOfLastValidPointer()
  166019             :    {
  166020           0 :       SgExponentiationAssignOp* testPointer = (SgExponentiationAssignOp*)(SgExponentiationAssignOp::pools.back());
  166021           0 :       unsigned long localIndex = SgExponentiationAssignOp::pool_size - 1;
  166022           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  166023             :          {
  166024           0 :            localIndex--;
  166025             :          }
  166026           0 :       return (localIndex + SgExponentiationAssignOp::pool_size * (SgExponentiationAssignOp::pools.size()-1));
  166027             :    }
  166028             : 
  166029             : //############################################################################
  166030             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  166031             :  * memory pool and initializes the data member in class SgExponentiationAssignOpStroageClass
  166032             :  * from its counterpart of SgExponentiationAssignOp. The return value is just for checking, 
  166033             :  * that the whole StorageClassArray is initialized!
  166034             :  */
  166035             : unsigned long
  166036           0 : SgExponentiationAssignOp::initializeStorageClassArray( SgExponentiationAssignOpStorageClass *storageArray )
  166037             :    {
  166038           0 :      unsigned long storageCounter = 0;
  166039           0 :      std::vector < unsigned char* > :: const_iterator block = SgExponentiationAssignOp::pools.begin();
  166040           0 :      SgExponentiationAssignOp* pointer = NULL;
  166041           0 :      while ( block != SgExponentiationAssignOp::pools.end() ) {
  166042           0 :           pointer = (SgExponentiationAssignOp*) (*block);
  166043           0 :           for ( unsigned i = 0; i < SgExponentiationAssignOp::pool_size; ++i ) {
  166044           0 :                if ( pointer->get_freepointer() != NULL ) {
  166045           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  166046           0 :                  storageArray++;
  166047           0 :                  storageCounter++;
  166048             :                }
  166049           0 :                pointer++;
  166050             :              }
  166051           0 :            block++;
  166052             :         }
  166053           0 :      return storageCounter;
  166054             :    }
  166055             : 
  166056             : /* #line 166057 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  166057             : 
  166058             : 
  166059             : 
  166060             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  166061             : 
  166062             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  166063             : 
  166064             : //############################################################################
  166065             : /* JH (02/02/2006) Constructor of the IR node SgMembershipOp that takes its 
  166066             :  * corresponding StorageClass as parameter
  166067             :  */
  166068           0 : SgMembershipOp :: SgMembershipOp ( const SgMembershipOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  166069             :    {
  166070             : 
  166071             : 
  166072             : /* #line 166073 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  166073             : 
  166074           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  166075             : 
  166076             : 
  166077             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  166078             : 
  166079             : 
  166080           0 :    }
  166081             : 
  166082             : //############################################################################
  166083             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  166084             :  * within the working AST. 
  166085             :  */
  166086           0 : SgMembershipOp * SgMembershipOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  166087           0 :      SgMembershipOp* returnPointer = NULL;
  166088           0 :      if ( globalIndex != 0 )
  166089             :         {
  166090             : 
  166091             : #if FILE_IO_EXTRA_CHECK
  166092           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMembershipOp ) ) <= globalIndex ) ;
  166093           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMembershipOp + 1 ) ) );
  166094             : #endif
  166095           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMembershipOp )  
  166096           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMembershipOp );
  166097           0 :           unsigned long positionInPool = localIndex % SgMembershipOp::pool_size;
  166098           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMembershipOp::pool_size;
  166099             : 
  166100             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  166101             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  166102             : 
  166103           0 :           returnPointer = &( ( (SgMembershipOp*)(SgMembershipOp::pools[memoryBlock]) ) [positionInPool]) ;
  166104             : 
  166105           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  166106             :         }
  166107           0 :      return returnPointer ;
  166108             :    }
  166109             : 
  166110             : //############################################################################
  166111             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  166112             :   for the AST with the index astIndex
  166113             : */
  166114           0 : SgMembershipOp * SgMembershipOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  166115           0 :      SgMembershipOp* returnPointer = NULL;
  166116           0 :      if ( globalIndex != 0 )
  166117             :         {
  166118             : 
  166119             : #if FILE_IO_EXTRA_CHECK
  166120           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMembershipOp ) ) <= globalIndex ) ;
  166121           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMembershipOp + 1 ) ) );
  166122             : #endif
  166123           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMembershipOp )
  166124           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMembershipOp );
  166125           0 :           unsigned long positionInPool = localIndex % SgMembershipOp::pool_size ;
  166126           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMembershipOp::pool_size ;
  166127             : 
  166128             : #if FILE_IO_EXTRA_CHECK
  166129             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  166130             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  166131             : #endif
  166132             : 
  166133           0 :           returnPointer = &( ( (SgMembershipOp*)(SgMembershipOp::pools[memoryBlock]) ) [positionInPool]) ;
  166134             : 
  166135             : #if FILE_IO_EXTRA_CHECK
  166136           0 :           assert ( returnPointer != NULL ) ;
  166137             : #endif
  166138             :         }
  166139           0 :      return returnPointer ;
  166140             :    }
  166141             : 
  166142             : //############################################################################
  166143             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  166144             :  * pool size! We set for every valid object in the memory pool the freepointer
  166145             :  * to the global index and increase the global index afterwards. For all the 
  166146             :  * invalid objects (means address ranges within the memory pool that were not
  166147             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  166148             :  * distinguish valid from invalid objects! 
  166149             :  */
  166150             : unsigned long
  166151           5 : SgMembershipOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  166152             :    {
  166153           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  166154           5 :      SgMembershipOp* pointer = NULL;
  166155           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  166156           5 :      std::vector < unsigned char* > :: const_iterator block;
  166157           5 :      for ( block = SgMembershipOp::pools.begin(); block != SgMembershipOp::pools.end() ; ++block )
  166158             :         {
  166159           0 :           pointer = (SgMembershipOp*)(*block);
  166160           0 :           for (unsigned i = 0; i < SgMembershipOp::pool_size; ++i )
  166161             :              {
  166162             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  166163             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  166164             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  166165             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  166166             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  166167             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  166168             :             // properly; so this will have to be checked next.
  166169             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  166170             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  166171           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  166172             :                   {
  166173           0 :                     pointer[i].set_freepointer((SgMembershipOp*)(globalIndex));
  166174           0 :                     globalIndex++;
  166175             :                   }
  166176             :                else
  166177             :                   {
  166178           0 :                     pointer[i].set_freepointer(NULL);
  166179             :                   }
  166180             :               }
  166181             :         }
  166182           5 :      return globalIndex;
  166183             :    }
  166184             : 
  166185             : //############################################################################
  166186             : // JH (01/14/2006)
  166187             : void
  166188           5 : SgMembershipOp::resetValidFreepointers( )
  166189             :    {
  166190           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  166191           5 :      SgMembershipOp* pointer = NULL;
  166192           5 :      std::vector < unsigned char* > :: const_iterator block;
  166193           5 :      SgMembershipOp* pointerOfLinkedList = NULL;
  166194           5 :      for ( block = SgMembershipOp::pools.begin(); block != SgMembershipOp::pools.end() ; ++block )
  166195             :         {
  166196           0 :           pointer = (SgMembershipOp*)(*block);
  166197           0 :           for (unsigned i = 0; i < SgMembershipOp::pool_size; ++i )
  166198             :              {
  166199             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  166200             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  166201             :             // memory blocks!.
  166202           0 :                if ( pointer[i].get_freepointer() != NULL )
  166203             :                   {
  166204           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  166205             :                   }
  166206             :                else
  166207             :                   {
  166208           0 :                     if ( pointerOfLinkedList == NULL )
  166209             :                        {
  166210           0 :                          SgMembershipOp::next_node = &(pointer[i]);
  166211             :                        }
  166212             :                     else
  166213             :                        {
  166214             :                       // printf ("In SgMembershipOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  166215           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  166216             :                        }
  166217             :                     pointerOfLinkedList = &(pointer[i]);
  166218             :                   }
  166219             :               }
  166220             :         }
  166221             : 
  166222           5 :      if ( pointerOfLinkedList != NULL )
  166223             :         {
  166224             :        // printf ("In SgMembershipOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  166225           0 :           pointerOfLinkedList->set_freepointer(NULL);
  166226             :        // DQ (6/6/2010): Temporary debugging...
  166227             :        //   ROSE_ASSERT(false);
  166228             :         }
  166229             : 
  166230           5 :      return ;
  166231             :    }
  166232             : 
  166233             : //############################################################################
  166234             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  166235             :  * within the memory pool and resets the freepointers, in order to achieve a 
  166236             :  * linked list, that has no jumps and starts at the beginning! This function 
  166237             :  * does not extend the memory pool, since we do not delete any memory blocks,
  166238             :  * but delete the valid objects.  
  166239             :  */
  166240             : void
  166241           0 : SgMembershipOp::clearMemoryPool( )
  166242             :    {
  166243             :   // printf ("Inside of SgMembershipOp::clearMemoryPool() \n");
  166244             : 
  166245           0 :      SgMembershipOp* pointer = NULL, *tempPointer = NULL;
  166246           0 :      std::vector < unsigned char* > :: const_iterator block;
  166247           0 :      if ( SgMembershipOp::pools.empty() == false )
  166248             :         {
  166249           0 :           block = SgMembershipOp::pools.begin() ;
  166250           0 :           SgMembershipOp::next_node = (SgMembershipOp*) (*block);
  166251             : 
  166252           0 :           while ( block != SgMembershipOp::pools.end() )
  166253             :              {
  166254           0 :                pointer = (SgMembershipOp*) (*block);
  166255           0 :                if ( tempPointer != NULL )
  166256             :                   {
  166257           0 :                     tempPointer->set_freepointer(pointer);
  166258             :                   }
  166259           0 :                for (unsigned i = 0; i < SgMembershipOp::pool_size - 1; ++i)
  166260             :                   {
  166261           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  166262             :                   }
  166263           0 :                 pointer[SgMembershipOp::pool_size-1].set_freepointer(NULL);
  166264           0 :                 tempPointer = &(pointer[SgMembershipOp::pool_size-1]);
  166265           0 :                 ++block;
  166266             :              }
  166267             :         }
  166268           0 :    }
  166269             : 
  166270           5 : void SgMembershipOp::deleteMemoryPool() {
  166271           5 :   for (auto p: SgMembershipOp::pools) {
  166272           0 :     ROSE_FREE(p);
  166273             :   }
  166274           5 :   SgMembershipOp::next_node = nullptr;
  166275           5 :   SgMembershipOp::pools.clear();
  166276           5 : }
  166277             : 
  166278             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  166279             : //                 reading multiple binary files to for a single AST.
  166280             : /////////// new version ////////////////////////////////
  166281             : //############################################################################
  166282             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  166283             : void
  166284           2 : SgMembershipOp::extendMemoryPoolForFileIO( )
  166285             :   {
  166286           2 :     size_t blockIndex = SgMembershipOp::pools.size();
  166287           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMembershipOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMembershipOp);
  166288             : 
  166289           2 :     while ( (blockIndex * SgMembershipOp::pool_size) < newPoolSize)
  166290             :       {
  166291             : #if ROSE_ALLOC_TRACE
  166292             :         if (blockIndex > 0) {
  166293             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMembershipOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMembershipOp) = %" PRIuPTR " SgMembershipOp::pool_size = %d \n",
  166294             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMembershipOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMembershipOp),SgMembershipOp::pool_size);
  166295             :         }
  166296             : #endif
  166297             : 
  166298           0 :         SgMembershipOp * pointer = (SgMembershipOp*) ROSE_MALLOC ( SgMembershipOp::pool_size * sizeof(SgMembershipOp) );
  166299           0 :         assert( pointer != NULL );
  166300             : #if ROSE_ALLOC_MEMSET == 1
  166301             :         memset(pointer, 0x00, SgMembershipOp::pool_size * sizeof(SgMembershipOp));
  166302             : #elif ROSE_ALLOC_MEMSET == 2
  166303             :         memset(pointer, 0xCC, SgMembershipOp::pool_size * sizeof(SgMembershipOp));
  166304             : #endif
  166305           0 :         SgMembershipOp::pools.push_back( (unsigned char*)(pointer) );
  166306           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMembershipOp::pool_size * sizeof(SgMembershipOp), V_SgMembershipOp ) );
  166307             : 
  166308           0 :         if ( SgMembershipOp::next_node != NULL ) {
  166309           0 :           if ( blockIndex > 0 ) {
  166310           0 :             SgMembershipOp * blkptr = (SgMembershipOp*)(SgMembershipOp::pools[blockIndex-1]);
  166311           0 :             blkptr[ SgMembershipOp::pool_size - 1 ].set_freepointer(pointer);
  166312             :           }
  166313             :         } else {
  166314           0 :           SgMembershipOp::next_node = pointer;
  166315             :         }
  166316             : 
  166317           0 :         for (unsigned i = 0; i < SgMembershipOp::pool_size-1; ++i)
  166318             :            {
  166319           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  166320             :            }
  166321           0 :         pointer[ SgMembershipOp::pool_size -1 ].set_freepointer(NULL);
  166322             : 
  166323           0 :         blockIndex++;
  166324             :       }
  166325           2 :   }
  166326             : 
  166327             : //############################################################################
  166328             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  166329             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  166330             :  * not compressed. However, that stuff is not yet implemented! 
  166331             :  */
  166332             : unsigned long
  166333           0 : SgMembershipOp::getNumberOfLastValidPointer()
  166334             :    {
  166335           0 :       SgMembershipOp* testPointer = (SgMembershipOp*)(SgMembershipOp::pools.back());
  166336           0 :       unsigned long localIndex = SgMembershipOp::pool_size - 1;
  166337           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  166338             :          {
  166339           0 :            localIndex--;
  166340             :          }
  166341           0 :       return (localIndex + SgMembershipOp::pool_size * (SgMembershipOp::pools.size()-1));
  166342             :    }
  166343             : 
  166344             : //############################################################################
  166345             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  166346             :  * memory pool and initializes the data member in class SgMembershipOpStroageClass
  166347             :  * from its counterpart of SgMembershipOp. The return value is just for checking, 
  166348             :  * that the whole StorageClassArray is initialized!
  166349             :  */
  166350             : unsigned long
  166351           0 : SgMembershipOp::initializeStorageClassArray( SgMembershipOpStorageClass *storageArray )
  166352             :    {
  166353           0 :      unsigned long storageCounter = 0;
  166354           0 :      std::vector < unsigned char* > :: const_iterator block = SgMembershipOp::pools.begin();
  166355           0 :      SgMembershipOp* pointer = NULL;
  166356           0 :      while ( block != SgMembershipOp::pools.end() ) {
  166357           0 :           pointer = (SgMembershipOp*) (*block);
  166358           0 :           for ( unsigned i = 0; i < SgMembershipOp::pool_size; ++i ) {
  166359           0 :                if ( pointer->get_freepointer() != NULL ) {
  166360           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  166361           0 :                  storageArray++;
  166362           0 :                  storageCounter++;
  166363             :                }
  166364           0 :                pointer++;
  166365             :              }
  166366           0 :            block++;
  166367             :         }
  166368           0 :      return storageCounter;
  166369             :    }
  166370             : 
  166371             : /* #line 166372 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  166372             : 
  166373             : 
  166374             : 
  166375             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  166376             : 
  166377             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  166378             : 
  166379             : //############################################################################
  166380             : /* JH (02/02/2006) Constructor of the IR node SgSpaceshipOp that takes its 
  166381             :  * corresponding StorageClass as parameter
  166382             :  */
  166383           0 : SgSpaceshipOp :: SgSpaceshipOp ( const SgSpaceshipOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  166384             :    {
  166385             : 
  166386             : 
  166387             : /* #line 166388 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  166388             : 
  166389           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  166390             : 
  166391             : 
  166392             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  166393             : 
  166394             : 
  166395           0 :    }
  166396             : 
  166397             : //############################################################################
  166398             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  166399             :  * within the working AST. 
  166400             :  */
  166401           0 : SgSpaceshipOp * SgSpaceshipOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  166402           0 :      SgSpaceshipOp* returnPointer = NULL;
  166403           0 :      if ( globalIndex != 0 )
  166404             :         {
  166405             : 
  166406             : #if FILE_IO_EXTRA_CHECK
  166407           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSpaceshipOp ) ) <= globalIndex ) ;
  166408           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSpaceshipOp + 1 ) ) );
  166409             : #endif
  166410           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSpaceshipOp )  
  166411           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSpaceshipOp );
  166412           0 :           unsigned long positionInPool = localIndex % SgSpaceshipOp::pool_size;
  166413           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSpaceshipOp::pool_size;
  166414             : 
  166415             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  166416             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  166417             : 
  166418           0 :           returnPointer = &( ( (SgSpaceshipOp*)(SgSpaceshipOp::pools[memoryBlock]) ) [positionInPool]) ;
  166419             : 
  166420           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  166421             :         }
  166422           0 :      return returnPointer ;
  166423             :    }
  166424             : 
  166425             : //############################################################################
  166426             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  166427             :   for the AST with the index astIndex
  166428             : */
  166429           0 : SgSpaceshipOp * SgSpaceshipOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  166430           0 :      SgSpaceshipOp* returnPointer = NULL;
  166431           0 :      if ( globalIndex != 0 )
  166432             :         {
  166433             : 
  166434             : #if FILE_IO_EXTRA_CHECK
  166435           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSpaceshipOp ) ) <= globalIndex ) ;
  166436           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSpaceshipOp + 1 ) ) );
  166437             : #endif
  166438           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSpaceshipOp )
  166439           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSpaceshipOp );
  166440           0 :           unsigned long positionInPool = localIndex % SgSpaceshipOp::pool_size ;
  166441           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSpaceshipOp::pool_size ;
  166442             : 
  166443             : #if FILE_IO_EXTRA_CHECK
  166444             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  166445             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  166446             : #endif
  166447             : 
  166448           0 :           returnPointer = &( ( (SgSpaceshipOp*)(SgSpaceshipOp::pools[memoryBlock]) ) [positionInPool]) ;
  166449             : 
  166450             : #if FILE_IO_EXTRA_CHECK
  166451           0 :           assert ( returnPointer != NULL ) ;
  166452             : #endif
  166453             :         }
  166454           0 :      return returnPointer ;
  166455             :    }
  166456             : 
  166457             : //############################################################################
  166458             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  166459             :  * pool size! We set for every valid object in the memory pool the freepointer
  166460             :  * to the global index and increase the global index afterwards. For all the 
  166461             :  * invalid objects (means address ranges within the memory pool that were not
  166462             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  166463             :  * distinguish valid from invalid objects! 
  166464             :  */
  166465             : unsigned long
  166466           5 : SgSpaceshipOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  166467             :    {
  166468           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  166469           5 :      SgSpaceshipOp* pointer = NULL;
  166470           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  166471           5 :      std::vector < unsigned char* > :: const_iterator block;
  166472           5 :      for ( block = SgSpaceshipOp::pools.begin(); block != SgSpaceshipOp::pools.end() ; ++block )
  166473             :         {
  166474           0 :           pointer = (SgSpaceshipOp*)(*block);
  166475           0 :           for (unsigned i = 0; i < SgSpaceshipOp::pool_size; ++i )
  166476             :              {
  166477             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  166478             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  166479             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  166480             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  166481             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  166482             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  166483             :             // properly; so this will have to be checked next.
  166484             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  166485             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  166486           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  166487             :                   {
  166488           0 :                     pointer[i].set_freepointer((SgSpaceshipOp*)(globalIndex));
  166489           0 :                     globalIndex++;
  166490             :                   }
  166491             :                else
  166492             :                   {
  166493           0 :                     pointer[i].set_freepointer(NULL);
  166494             :                   }
  166495             :               }
  166496             :         }
  166497           5 :      return globalIndex;
  166498             :    }
  166499             : 
  166500             : //############################################################################
  166501             : // JH (01/14/2006)
  166502             : void
  166503           5 : SgSpaceshipOp::resetValidFreepointers( )
  166504             :    {
  166505           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  166506           5 :      SgSpaceshipOp* pointer = NULL;
  166507           5 :      std::vector < unsigned char* > :: const_iterator block;
  166508           5 :      SgSpaceshipOp* pointerOfLinkedList = NULL;
  166509           5 :      for ( block = SgSpaceshipOp::pools.begin(); block != SgSpaceshipOp::pools.end() ; ++block )
  166510             :         {
  166511           0 :           pointer = (SgSpaceshipOp*)(*block);
  166512           0 :           for (unsigned i = 0; i < SgSpaceshipOp::pool_size; ++i )
  166513             :              {
  166514             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  166515             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  166516             :             // memory blocks!.
  166517           0 :                if ( pointer[i].get_freepointer() != NULL )
  166518             :                   {
  166519           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  166520             :                   }
  166521             :                else
  166522             :                   {
  166523           0 :                     if ( pointerOfLinkedList == NULL )
  166524             :                        {
  166525           0 :                          SgSpaceshipOp::next_node = &(pointer[i]);
  166526             :                        }
  166527             :                     else
  166528             :                        {
  166529             :                       // printf ("In SgSpaceshipOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  166530           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  166531             :                        }
  166532             :                     pointerOfLinkedList = &(pointer[i]);
  166533             :                   }
  166534             :               }
  166535             :         }
  166536             : 
  166537           5 :      if ( pointerOfLinkedList != NULL )
  166538             :         {
  166539             :        // printf ("In SgSpaceshipOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  166540           0 :           pointerOfLinkedList->set_freepointer(NULL);
  166541             :        // DQ (6/6/2010): Temporary debugging...
  166542             :        //   ROSE_ASSERT(false);
  166543             :         }
  166544             : 
  166545           5 :      return ;
  166546             :    }
  166547             : 
  166548             : //############################################################################
  166549             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  166550             :  * within the memory pool and resets the freepointers, in order to achieve a 
  166551             :  * linked list, that has no jumps and starts at the beginning! This function 
  166552             :  * does not extend the memory pool, since we do not delete any memory blocks,
  166553             :  * but delete the valid objects.  
  166554             :  */
  166555             : void
  166556           0 : SgSpaceshipOp::clearMemoryPool( )
  166557             :    {
  166558             :   // printf ("Inside of SgSpaceshipOp::clearMemoryPool() \n");
  166559             : 
  166560           0 :      SgSpaceshipOp* pointer = NULL, *tempPointer = NULL;
  166561           0 :      std::vector < unsigned char* > :: const_iterator block;
  166562           0 :      if ( SgSpaceshipOp::pools.empty() == false )
  166563             :         {
  166564           0 :           block = SgSpaceshipOp::pools.begin() ;
  166565           0 :           SgSpaceshipOp::next_node = (SgSpaceshipOp*) (*block);
  166566             : 
  166567           0 :           while ( block != SgSpaceshipOp::pools.end() )
  166568             :              {
  166569           0 :                pointer = (SgSpaceshipOp*) (*block);
  166570           0 :                if ( tempPointer != NULL )
  166571             :                   {
  166572           0 :                     tempPointer->set_freepointer(pointer);
  166573             :                   }
  166574           0 :                for (unsigned i = 0; i < SgSpaceshipOp::pool_size - 1; ++i)
  166575             :                   {
  166576           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  166577             :                   }
  166578           0 :                 pointer[SgSpaceshipOp::pool_size-1].set_freepointer(NULL);
  166579           0 :                 tempPointer = &(pointer[SgSpaceshipOp::pool_size-1]);
  166580           0 :                 ++block;
  166581             :              }
  166582             :         }
  166583           0 :    }
  166584             : 
  166585           5 : void SgSpaceshipOp::deleteMemoryPool() {
  166586           5 :   for (auto p: SgSpaceshipOp::pools) {
  166587           0 :     ROSE_FREE(p);
  166588             :   }
  166589           5 :   SgSpaceshipOp::next_node = nullptr;
  166590           5 :   SgSpaceshipOp::pools.clear();
  166591           5 : }
  166592             : 
  166593             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  166594             : //                 reading multiple binary files to for a single AST.
  166595             : /////////// new version ////////////////////////////////
  166596             : //############################################################################
  166597             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  166598             : void
  166599           2 : SgSpaceshipOp::extendMemoryPoolForFileIO( )
  166600             :   {
  166601           2 :     size_t blockIndex = SgSpaceshipOp::pools.size();
  166602           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSpaceshipOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpaceshipOp);
  166603             : 
  166604           2 :     while ( (blockIndex * SgSpaceshipOp::pool_size) < newPoolSize)
  166605             :       {
  166606             : #if ROSE_ALLOC_TRACE
  166607             :         if (blockIndex > 0) {
  166608             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSpaceshipOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpaceshipOp) = %" PRIuPTR " SgSpaceshipOp::pool_size = %d \n",
  166609             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSpaceshipOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSpaceshipOp),SgSpaceshipOp::pool_size);
  166610             :         }
  166611             : #endif
  166612             : 
  166613           0 :         SgSpaceshipOp * pointer = (SgSpaceshipOp*) ROSE_MALLOC ( SgSpaceshipOp::pool_size * sizeof(SgSpaceshipOp) );
  166614           0 :         assert( pointer != NULL );
  166615             : #if ROSE_ALLOC_MEMSET == 1
  166616             :         memset(pointer, 0x00, SgSpaceshipOp::pool_size * sizeof(SgSpaceshipOp));
  166617             : #elif ROSE_ALLOC_MEMSET == 2
  166618             :         memset(pointer, 0xCC, SgSpaceshipOp::pool_size * sizeof(SgSpaceshipOp));
  166619             : #endif
  166620           0 :         SgSpaceshipOp::pools.push_back( (unsigned char*)(pointer) );
  166621           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSpaceshipOp::pool_size * sizeof(SgSpaceshipOp), V_SgSpaceshipOp ) );
  166622             : 
  166623           0 :         if ( SgSpaceshipOp::next_node != NULL ) {
  166624           0 :           if ( blockIndex > 0 ) {
  166625           0 :             SgSpaceshipOp * blkptr = (SgSpaceshipOp*)(SgSpaceshipOp::pools[blockIndex-1]);
  166626           0 :             blkptr[ SgSpaceshipOp::pool_size - 1 ].set_freepointer(pointer);
  166627             :           }
  166628             :         } else {
  166629           0 :           SgSpaceshipOp::next_node = pointer;
  166630             :         }
  166631             : 
  166632           0 :         for (unsigned i = 0; i < SgSpaceshipOp::pool_size-1; ++i)
  166633             :            {
  166634           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  166635             :            }
  166636           0 :         pointer[ SgSpaceshipOp::pool_size -1 ].set_freepointer(NULL);
  166637             : 
  166638           0 :         blockIndex++;
  166639             :       }
  166640           2 :   }
  166641             : 
  166642             : //############################################################################
  166643             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  166644             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  166645             :  * not compressed. However, that stuff is not yet implemented! 
  166646             :  */
  166647             : unsigned long
  166648           0 : SgSpaceshipOp::getNumberOfLastValidPointer()
  166649             :    {
  166650           0 :       SgSpaceshipOp* testPointer = (SgSpaceshipOp*)(SgSpaceshipOp::pools.back());
  166651           0 :       unsigned long localIndex = SgSpaceshipOp::pool_size - 1;
  166652           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  166653             :          {
  166654           0 :            localIndex--;
  166655             :          }
  166656           0 :       return (localIndex + SgSpaceshipOp::pool_size * (SgSpaceshipOp::pools.size()-1));
  166657             :    }
  166658             : 
  166659             : //############################################################################
  166660             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  166661             :  * memory pool and initializes the data member in class SgSpaceshipOpStroageClass
  166662             :  * from its counterpart of SgSpaceshipOp. The return value is just for checking, 
  166663             :  * that the whole StorageClassArray is initialized!
  166664             :  */
  166665             : unsigned long
  166666           0 : SgSpaceshipOp::initializeStorageClassArray( SgSpaceshipOpStorageClass *storageArray )
  166667             :    {
  166668           0 :      unsigned long storageCounter = 0;
  166669           0 :      std::vector < unsigned char* > :: const_iterator block = SgSpaceshipOp::pools.begin();
  166670           0 :      SgSpaceshipOp* pointer = NULL;
  166671           0 :      while ( block != SgSpaceshipOp::pools.end() ) {
  166672           0 :           pointer = (SgSpaceshipOp*) (*block);
  166673           0 :           for ( unsigned i = 0; i < SgSpaceshipOp::pool_size; ++i ) {
  166674           0 :                if ( pointer->get_freepointer() != NULL ) {
  166675           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  166676           0 :                  storageArray++;
  166677           0 :                  storageCounter++;
  166678             :                }
  166679           0 :                pointer++;
  166680             :              }
  166681           0 :            block++;
  166682             :         }
  166683           0 :      return storageCounter;
  166684             :    }
  166685             : 
  166686             : /* #line 166687 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  166687             : 
  166688             : 
  166689             : 
  166690             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  166691             : 
  166692             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  166693             : 
  166694             : //############################################################################
  166695             : /* JH (02/02/2006) Constructor of the IR node SgNonMembershipOp that takes its 
  166696             :  * corresponding StorageClass as parameter
  166697             :  */
  166698           0 : SgNonMembershipOp :: SgNonMembershipOp ( const SgNonMembershipOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  166699             :    {
  166700             : 
  166701             : 
  166702             : /* #line 166703 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  166703             : 
  166704           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  166705             : 
  166706             : 
  166707             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  166708             : 
  166709             : 
  166710           0 :    }
  166711             : 
  166712             : //############################################################################
  166713             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  166714             :  * within the working AST. 
  166715             :  */
  166716           0 : SgNonMembershipOp * SgNonMembershipOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  166717           0 :      SgNonMembershipOp* returnPointer = NULL;
  166718           0 :      if ( globalIndex != 0 )
  166719             :         {
  166720             : 
  166721             : #if FILE_IO_EXTRA_CHECK
  166722           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNonMembershipOp ) ) <= globalIndex ) ;
  166723           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonMembershipOp + 1 ) ) );
  166724             : #endif
  166725           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonMembershipOp )  
  166726           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNonMembershipOp );
  166727           0 :           unsigned long positionInPool = localIndex % SgNonMembershipOp::pool_size;
  166728           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonMembershipOp::pool_size;
  166729             : 
  166730             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  166731             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  166732             : 
  166733           0 :           returnPointer = &( ( (SgNonMembershipOp*)(SgNonMembershipOp::pools[memoryBlock]) ) [positionInPool]) ;
  166734             : 
  166735           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  166736             :         }
  166737           0 :      return returnPointer ;
  166738             :    }
  166739             : 
  166740             : //############################################################################
  166741             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  166742             :   for the AST with the index astIndex
  166743             : */
  166744           0 : SgNonMembershipOp * SgNonMembershipOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  166745           0 :      SgNonMembershipOp* returnPointer = NULL;
  166746           0 :      if ( globalIndex != 0 )
  166747             :         {
  166748             : 
  166749             : #if FILE_IO_EXTRA_CHECK
  166750           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNonMembershipOp ) ) <= globalIndex ) ;
  166751           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonMembershipOp + 1 ) ) );
  166752             : #endif
  166753           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonMembershipOp )
  166754           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNonMembershipOp );
  166755           0 :           unsigned long positionInPool = localIndex % SgNonMembershipOp::pool_size ;
  166756           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonMembershipOp::pool_size ;
  166757             : 
  166758             : #if FILE_IO_EXTRA_CHECK
  166759             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  166760             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  166761             : #endif
  166762             : 
  166763           0 :           returnPointer = &( ( (SgNonMembershipOp*)(SgNonMembershipOp::pools[memoryBlock]) ) [positionInPool]) ;
  166764             : 
  166765             : #if FILE_IO_EXTRA_CHECK
  166766           0 :           assert ( returnPointer != NULL ) ;
  166767             : #endif
  166768             :         }
  166769           0 :      return returnPointer ;
  166770             :    }
  166771             : 
  166772             : //############################################################################
  166773             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  166774             :  * pool size! We set for every valid object in the memory pool the freepointer
  166775             :  * to the global index and increase the global index afterwards. For all the 
  166776             :  * invalid objects (means address ranges within the memory pool that were not
  166777             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  166778             :  * distinguish valid from invalid objects! 
  166779             :  */
  166780             : unsigned long
  166781           5 : SgNonMembershipOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  166782             :    {
  166783           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  166784           5 :      SgNonMembershipOp* pointer = NULL;
  166785           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  166786           5 :      std::vector < unsigned char* > :: const_iterator block;
  166787           5 :      for ( block = SgNonMembershipOp::pools.begin(); block != SgNonMembershipOp::pools.end() ; ++block )
  166788             :         {
  166789           0 :           pointer = (SgNonMembershipOp*)(*block);
  166790           0 :           for (unsigned i = 0; i < SgNonMembershipOp::pool_size; ++i )
  166791             :              {
  166792             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  166793             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  166794             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  166795             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  166796             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  166797             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  166798             :             // properly; so this will have to be checked next.
  166799             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  166800             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  166801           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  166802             :                   {
  166803           0 :                     pointer[i].set_freepointer((SgNonMembershipOp*)(globalIndex));
  166804           0 :                     globalIndex++;
  166805             :                   }
  166806             :                else
  166807             :                   {
  166808           0 :                     pointer[i].set_freepointer(NULL);
  166809             :                   }
  166810             :               }
  166811             :         }
  166812           5 :      return globalIndex;
  166813             :    }
  166814             : 
  166815             : //############################################################################
  166816             : // JH (01/14/2006)
  166817             : void
  166818           5 : SgNonMembershipOp::resetValidFreepointers( )
  166819             :    {
  166820           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  166821           5 :      SgNonMembershipOp* pointer = NULL;
  166822           5 :      std::vector < unsigned char* > :: const_iterator block;
  166823           5 :      SgNonMembershipOp* pointerOfLinkedList = NULL;
  166824           5 :      for ( block = SgNonMembershipOp::pools.begin(); block != SgNonMembershipOp::pools.end() ; ++block )
  166825             :         {
  166826           0 :           pointer = (SgNonMembershipOp*)(*block);
  166827           0 :           for (unsigned i = 0; i < SgNonMembershipOp::pool_size; ++i )
  166828             :              {
  166829             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  166830             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  166831             :             // memory blocks!.
  166832           0 :                if ( pointer[i].get_freepointer() != NULL )
  166833             :                   {
  166834           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  166835             :                   }
  166836             :                else
  166837             :                   {
  166838           0 :                     if ( pointerOfLinkedList == NULL )
  166839             :                        {
  166840           0 :                          SgNonMembershipOp::next_node = &(pointer[i]);
  166841             :                        }
  166842             :                     else
  166843             :                        {
  166844             :                       // printf ("In SgNonMembershipOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  166845           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  166846             :                        }
  166847             :                     pointerOfLinkedList = &(pointer[i]);
  166848             :                   }
  166849             :               }
  166850             :         }
  166851             : 
  166852           5 :      if ( pointerOfLinkedList != NULL )
  166853             :         {
  166854             :        // printf ("In SgNonMembershipOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  166855           0 :           pointerOfLinkedList->set_freepointer(NULL);
  166856             :        // DQ (6/6/2010): Temporary debugging...
  166857             :        //   ROSE_ASSERT(false);
  166858             :         }
  166859             : 
  166860           5 :      return ;
  166861             :    }
  166862             : 
  166863             : //############################################################################
  166864             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  166865             :  * within the memory pool and resets the freepointers, in order to achieve a 
  166866             :  * linked list, that has no jumps and starts at the beginning! This function 
  166867             :  * does not extend the memory pool, since we do not delete any memory blocks,
  166868             :  * but delete the valid objects.  
  166869             :  */
  166870             : void
  166871           0 : SgNonMembershipOp::clearMemoryPool( )
  166872             :    {
  166873             :   // printf ("Inside of SgNonMembershipOp::clearMemoryPool() \n");
  166874             : 
  166875           0 :      SgNonMembershipOp* pointer = NULL, *tempPointer = NULL;
  166876           0 :      std::vector < unsigned char* > :: const_iterator block;
  166877           0 :      if ( SgNonMembershipOp::pools.empty() == false )
  166878             :         {
  166879           0 :           block = SgNonMembershipOp::pools.begin() ;
  166880           0 :           SgNonMembershipOp::next_node = (SgNonMembershipOp*) (*block);
  166881             : 
  166882           0 :           while ( block != SgNonMembershipOp::pools.end() )
  166883             :              {
  166884           0 :                pointer = (SgNonMembershipOp*) (*block);
  166885           0 :                if ( tempPointer != NULL )
  166886             :                   {
  166887           0 :                     tempPointer->set_freepointer(pointer);
  166888             :                   }
  166889           0 :                for (unsigned i = 0; i < SgNonMembershipOp::pool_size - 1; ++i)
  166890             :                   {
  166891           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  166892             :                   }
  166893           0 :                 pointer[SgNonMembershipOp::pool_size-1].set_freepointer(NULL);
  166894           0 :                 tempPointer = &(pointer[SgNonMembershipOp::pool_size-1]);
  166895           0 :                 ++block;
  166896             :              }
  166897             :         }
  166898           0 :    }
  166899             : 
  166900           5 : void SgNonMembershipOp::deleteMemoryPool() {
  166901           5 :   for (auto p: SgNonMembershipOp::pools) {
  166902           0 :     ROSE_FREE(p);
  166903             :   }
  166904           5 :   SgNonMembershipOp::next_node = nullptr;
  166905           5 :   SgNonMembershipOp::pools.clear();
  166906           5 : }
  166907             : 
  166908             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  166909             : //                 reading multiple binary files to for a single AST.
  166910             : /////////// new version ////////////////////////////////
  166911             : //############################################################################
  166912             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  166913             : void
  166914           2 : SgNonMembershipOp::extendMemoryPoolForFileIO( )
  166915             :   {
  166916           2 :     size_t blockIndex = SgNonMembershipOp::pools.size();
  166917           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNonMembershipOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonMembershipOp);
  166918             : 
  166919           2 :     while ( (blockIndex * SgNonMembershipOp::pool_size) < newPoolSize)
  166920             :       {
  166921             : #if ROSE_ALLOC_TRACE
  166922             :         if (blockIndex > 0) {
  166923             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNonMembershipOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonMembershipOp) = %" PRIuPTR " SgNonMembershipOp::pool_size = %d \n",
  166924             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNonMembershipOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonMembershipOp),SgNonMembershipOp::pool_size);
  166925             :         }
  166926             : #endif
  166927             : 
  166928           0 :         SgNonMembershipOp * pointer = (SgNonMembershipOp*) ROSE_MALLOC ( SgNonMembershipOp::pool_size * sizeof(SgNonMembershipOp) );
  166929           0 :         assert( pointer != NULL );
  166930             : #if ROSE_ALLOC_MEMSET == 1
  166931             :         memset(pointer, 0x00, SgNonMembershipOp::pool_size * sizeof(SgNonMembershipOp));
  166932             : #elif ROSE_ALLOC_MEMSET == 2
  166933             :         memset(pointer, 0xCC, SgNonMembershipOp::pool_size * sizeof(SgNonMembershipOp));
  166934             : #endif
  166935           0 :         SgNonMembershipOp::pools.push_back( (unsigned char*)(pointer) );
  166936           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNonMembershipOp::pool_size * sizeof(SgNonMembershipOp), V_SgNonMembershipOp ) );
  166937             : 
  166938           0 :         if ( SgNonMembershipOp::next_node != NULL ) {
  166939           0 :           if ( blockIndex > 0 ) {
  166940           0 :             SgNonMembershipOp * blkptr = (SgNonMembershipOp*)(SgNonMembershipOp::pools[blockIndex-1]);
  166941           0 :             blkptr[ SgNonMembershipOp::pool_size - 1 ].set_freepointer(pointer);
  166942             :           }
  166943             :         } else {
  166944           0 :           SgNonMembershipOp::next_node = pointer;
  166945             :         }
  166946             : 
  166947           0 :         for (unsigned i = 0; i < SgNonMembershipOp::pool_size-1; ++i)
  166948             :            {
  166949           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  166950             :            }
  166951           0 :         pointer[ SgNonMembershipOp::pool_size -1 ].set_freepointer(NULL);
  166952             : 
  166953           0 :         blockIndex++;
  166954             :       }
  166955           2 :   }
  166956             : 
  166957             : //############################################################################
  166958             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  166959             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  166960             :  * not compressed. However, that stuff is not yet implemented! 
  166961             :  */
  166962             : unsigned long
  166963           0 : SgNonMembershipOp::getNumberOfLastValidPointer()
  166964             :    {
  166965           0 :       SgNonMembershipOp* testPointer = (SgNonMembershipOp*)(SgNonMembershipOp::pools.back());
  166966           0 :       unsigned long localIndex = SgNonMembershipOp::pool_size - 1;
  166967           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  166968             :          {
  166969           0 :            localIndex--;
  166970             :          }
  166971           0 :       return (localIndex + SgNonMembershipOp::pool_size * (SgNonMembershipOp::pools.size()-1));
  166972             :    }
  166973             : 
  166974             : //############################################################################
  166975             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  166976             :  * memory pool and initializes the data member in class SgNonMembershipOpStroageClass
  166977             :  * from its counterpart of SgNonMembershipOp. The return value is just for checking, 
  166978             :  * that the whole StorageClassArray is initialized!
  166979             :  */
  166980             : unsigned long
  166981           0 : SgNonMembershipOp::initializeStorageClassArray( SgNonMembershipOpStorageClass *storageArray )
  166982             :    {
  166983           0 :      unsigned long storageCounter = 0;
  166984           0 :      std::vector < unsigned char* > :: const_iterator block = SgNonMembershipOp::pools.begin();
  166985           0 :      SgNonMembershipOp* pointer = NULL;
  166986           0 :      while ( block != SgNonMembershipOp::pools.end() ) {
  166987           0 :           pointer = (SgNonMembershipOp*) (*block);
  166988           0 :           for ( unsigned i = 0; i < SgNonMembershipOp::pool_size; ++i ) {
  166989           0 :                if ( pointer->get_freepointer() != NULL ) {
  166990           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  166991           0 :                  storageArray++;
  166992           0 :                  storageCounter++;
  166993             :                }
  166994           0 :                pointer++;
  166995             :              }
  166996           0 :            block++;
  166997             :         }
  166998           0 :      return storageCounter;
  166999             :    }
  167000             : 
  167001             : /* #line 167002 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  167002             : 
  167003             : 
  167004             : 
  167005             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  167006             : 
  167007             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  167008             : 
  167009             : //############################################################################
  167010             : /* JH (02/02/2006) Constructor of the IR node SgIsOp that takes its 
  167011             :  * corresponding StorageClass as parameter
  167012             :  */
  167013           0 : SgIsOp :: SgIsOp ( const SgIsOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  167014             :    {
  167015             : 
  167016             : 
  167017             : /* #line 167018 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  167018             : 
  167019           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  167020             : 
  167021             : 
  167022             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  167023             : 
  167024             : 
  167025           0 :    }
  167026             : 
  167027             : //############################################################################
  167028             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  167029             :  * within the working AST. 
  167030             :  */
  167031           0 : SgIsOp * SgIsOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  167032           0 :      SgIsOp* returnPointer = NULL;
  167033           0 :      if ( globalIndex != 0 )
  167034             :         {
  167035             : 
  167036             : #if FILE_IO_EXTRA_CHECK
  167037           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIsOp ) ) <= globalIndex ) ;
  167038           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIsOp + 1 ) ) );
  167039             : #endif
  167040           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIsOp )  
  167041           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIsOp );
  167042           0 :           unsigned long positionInPool = localIndex % SgIsOp::pool_size;
  167043           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIsOp::pool_size;
  167044             : 
  167045             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  167046             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  167047             : 
  167048           0 :           returnPointer = &( ( (SgIsOp*)(SgIsOp::pools[memoryBlock]) ) [positionInPool]) ;
  167049             : 
  167050           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  167051             :         }
  167052           0 :      return returnPointer ;
  167053             :    }
  167054             : 
  167055             : //############################################################################
  167056             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  167057             :   for the AST with the index astIndex
  167058             : */
  167059           0 : SgIsOp * SgIsOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  167060           0 :      SgIsOp* returnPointer = NULL;
  167061           0 :      if ( globalIndex != 0 )
  167062             :         {
  167063             : 
  167064             : #if FILE_IO_EXTRA_CHECK
  167065           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIsOp ) ) <= globalIndex ) ;
  167066           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIsOp + 1 ) ) );
  167067             : #endif
  167068           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIsOp )
  167069           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIsOp );
  167070           0 :           unsigned long positionInPool = localIndex % SgIsOp::pool_size ;
  167071           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIsOp::pool_size ;
  167072             : 
  167073             : #if FILE_IO_EXTRA_CHECK
  167074             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  167075             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  167076             : #endif
  167077             : 
  167078           0 :           returnPointer = &( ( (SgIsOp*)(SgIsOp::pools[memoryBlock]) ) [positionInPool]) ;
  167079             : 
  167080             : #if FILE_IO_EXTRA_CHECK
  167081           0 :           assert ( returnPointer != NULL ) ;
  167082             : #endif
  167083             :         }
  167084           0 :      return returnPointer ;
  167085             :    }
  167086             : 
  167087             : //############################################################################
  167088             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  167089             :  * pool size! We set for every valid object in the memory pool the freepointer
  167090             :  * to the global index and increase the global index afterwards. For all the 
  167091             :  * invalid objects (means address ranges within the memory pool that were not
  167092             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  167093             :  * distinguish valid from invalid objects! 
  167094             :  */
  167095             : unsigned long
  167096           5 : SgIsOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  167097             :    {
  167098           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  167099           5 :      SgIsOp* pointer = NULL;
  167100           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  167101           5 :      std::vector < unsigned char* > :: const_iterator block;
  167102           5 :      for ( block = SgIsOp::pools.begin(); block != SgIsOp::pools.end() ; ++block )
  167103             :         {
  167104           0 :           pointer = (SgIsOp*)(*block);
  167105           0 :           for (unsigned i = 0; i < SgIsOp::pool_size; ++i )
  167106             :              {
  167107             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  167108             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  167109             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  167110             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  167111             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  167112             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  167113             :             // properly; so this will have to be checked next.
  167114             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  167115             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  167116           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  167117             :                   {
  167118           0 :                     pointer[i].set_freepointer((SgIsOp*)(globalIndex));
  167119           0 :                     globalIndex++;
  167120             :                   }
  167121             :                else
  167122             :                   {
  167123           0 :                     pointer[i].set_freepointer(NULL);
  167124             :                   }
  167125             :               }
  167126             :         }
  167127           5 :      return globalIndex;
  167128             :    }
  167129             : 
  167130             : //############################################################################
  167131             : // JH (01/14/2006)
  167132             : void
  167133           5 : SgIsOp::resetValidFreepointers( )
  167134             :    {
  167135           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  167136           5 :      SgIsOp* pointer = NULL;
  167137           5 :      std::vector < unsigned char* > :: const_iterator block;
  167138           5 :      SgIsOp* pointerOfLinkedList = NULL;
  167139           5 :      for ( block = SgIsOp::pools.begin(); block != SgIsOp::pools.end() ; ++block )
  167140             :         {
  167141           0 :           pointer = (SgIsOp*)(*block);
  167142           0 :           for (unsigned i = 0; i < SgIsOp::pool_size; ++i )
  167143             :              {
  167144             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  167145             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  167146             :             // memory blocks!.
  167147           0 :                if ( pointer[i].get_freepointer() != NULL )
  167148             :                   {
  167149           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  167150             :                   }
  167151             :                else
  167152             :                   {
  167153           0 :                     if ( pointerOfLinkedList == NULL )
  167154             :                        {
  167155           0 :                          SgIsOp::next_node = &(pointer[i]);
  167156             :                        }
  167157             :                     else
  167158             :                        {
  167159             :                       // printf ("In SgIsOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  167160           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  167161             :                        }
  167162             :                     pointerOfLinkedList = &(pointer[i]);
  167163             :                   }
  167164             :               }
  167165             :         }
  167166             : 
  167167           5 :      if ( pointerOfLinkedList != NULL )
  167168             :         {
  167169             :        // printf ("In SgIsOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  167170           0 :           pointerOfLinkedList->set_freepointer(NULL);
  167171             :        // DQ (6/6/2010): Temporary debugging...
  167172             :        //   ROSE_ASSERT(false);
  167173             :         }
  167174             : 
  167175           5 :      return ;
  167176             :    }
  167177             : 
  167178             : //############################################################################
  167179             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  167180             :  * within the memory pool and resets the freepointers, in order to achieve a 
  167181             :  * linked list, that has no jumps and starts at the beginning! This function 
  167182             :  * does not extend the memory pool, since we do not delete any memory blocks,
  167183             :  * but delete the valid objects.  
  167184             :  */
  167185             : void
  167186           0 : SgIsOp::clearMemoryPool( )
  167187             :    {
  167188             :   // printf ("Inside of SgIsOp::clearMemoryPool() \n");
  167189             : 
  167190           0 :      SgIsOp* pointer = NULL, *tempPointer = NULL;
  167191           0 :      std::vector < unsigned char* > :: const_iterator block;
  167192           0 :      if ( SgIsOp::pools.empty() == false )
  167193             :         {
  167194           0 :           block = SgIsOp::pools.begin() ;
  167195           0 :           SgIsOp::next_node = (SgIsOp*) (*block);
  167196             : 
  167197           0 :           while ( block != SgIsOp::pools.end() )
  167198             :              {
  167199           0 :                pointer = (SgIsOp*) (*block);
  167200           0 :                if ( tempPointer != NULL )
  167201             :                   {
  167202           0 :                     tempPointer->set_freepointer(pointer);
  167203             :                   }
  167204           0 :                for (unsigned i = 0; i < SgIsOp::pool_size - 1; ++i)
  167205             :                   {
  167206           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  167207             :                   }
  167208           0 :                 pointer[SgIsOp::pool_size-1].set_freepointer(NULL);
  167209           0 :                 tempPointer = &(pointer[SgIsOp::pool_size-1]);
  167210           0 :                 ++block;
  167211             :              }
  167212             :         }
  167213           0 :    }
  167214             : 
  167215           5 : void SgIsOp::deleteMemoryPool() {
  167216           5 :   for (auto p: SgIsOp::pools) {
  167217           0 :     ROSE_FREE(p);
  167218             :   }
  167219           5 :   SgIsOp::next_node = nullptr;
  167220           5 :   SgIsOp::pools.clear();
  167221           5 : }
  167222             : 
  167223             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  167224             : //                 reading multiple binary files to for a single AST.
  167225             : /////////// new version ////////////////////////////////
  167226             : //############################################################################
  167227             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  167228             : void
  167229           2 : SgIsOp::extendMemoryPoolForFileIO( )
  167230             :   {
  167231           2 :     size_t blockIndex = SgIsOp::pools.size();
  167232           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIsOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIsOp);
  167233             : 
  167234           2 :     while ( (blockIndex * SgIsOp::pool_size) < newPoolSize)
  167235             :       {
  167236             : #if ROSE_ALLOC_TRACE
  167237             :         if (blockIndex > 0) {
  167238             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIsOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIsOp) = %" PRIuPTR " SgIsOp::pool_size = %d \n",
  167239             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIsOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIsOp),SgIsOp::pool_size);
  167240             :         }
  167241             : #endif
  167242             : 
  167243           0 :         SgIsOp * pointer = (SgIsOp*) ROSE_MALLOC ( SgIsOp::pool_size * sizeof(SgIsOp) );
  167244           0 :         assert( pointer != NULL );
  167245             : #if ROSE_ALLOC_MEMSET == 1
  167246             :         memset(pointer, 0x00, SgIsOp::pool_size * sizeof(SgIsOp));
  167247             : #elif ROSE_ALLOC_MEMSET == 2
  167248             :         memset(pointer, 0xCC, SgIsOp::pool_size * sizeof(SgIsOp));
  167249             : #endif
  167250           0 :         SgIsOp::pools.push_back( (unsigned char*)(pointer) );
  167251           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIsOp::pool_size * sizeof(SgIsOp), V_SgIsOp ) );
  167252             : 
  167253           0 :         if ( SgIsOp::next_node != NULL ) {
  167254           0 :           if ( blockIndex > 0 ) {
  167255           0 :             SgIsOp * blkptr = (SgIsOp*)(SgIsOp::pools[blockIndex-1]);
  167256           0 :             blkptr[ SgIsOp::pool_size - 1 ].set_freepointer(pointer);
  167257             :           }
  167258             :         } else {
  167259           0 :           SgIsOp::next_node = pointer;
  167260             :         }
  167261             : 
  167262           0 :         for (unsigned i = 0; i < SgIsOp::pool_size-1; ++i)
  167263             :            {
  167264           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  167265             :            }
  167266           0 :         pointer[ SgIsOp::pool_size -1 ].set_freepointer(NULL);
  167267             : 
  167268           0 :         blockIndex++;
  167269             :       }
  167270           2 :   }
  167271             : 
  167272             : //############################################################################
  167273             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  167274             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  167275             :  * not compressed. However, that stuff is not yet implemented! 
  167276             :  */
  167277             : unsigned long
  167278           0 : SgIsOp::getNumberOfLastValidPointer()
  167279             :    {
  167280           0 :       SgIsOp* testPointer = (SgIsOp*)(SgIsOp::pools.back());
  167281           0 :       unsigned long localIndex = SgIsOp::pool_size - 1;
  167282           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  167283             :          {
  167284           0 :            localIndex--;
  167285             :          }
  167286           0 :       return (localIndex + SgIsOp::pool_size * (SgIsOp::pools.size()-1));
  167287             :    }
  167288             : 
  167289             : //############################################################################
  167290             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  167291             :  * memory pool and initializes the data member in class SgIsOpStroageClass
  167292             :  * from its counterpart of SgIsOp. The return value is just for checking, 
  167293             :  * that the whole StorageClassArray is initialized!
  167294             :  */
  167295             : unsigned long
  167296           0 : SgIsOp::initializeStorageClassArray( SgIsOpStorageClass *storageArray )
  167297             :    {
  167298           0 :      unsigned long storageCounter = 0;
  167299           0 :      std::vector < unsigned char* > :: const_iterator block = SgIsOp::pools.begin();
  167300           0 :      SgIsOp* pointer = NULL;
  167301           0 :      while ( block != SgIsOp::pools.end() ) {
  167302           0 :           pointer = (SgIsOp*) (*block);
  167303           0 :           for ( unsigned i = 0; i < SgIsOp::pool_size; ++i ) {
  167304           0 :                if ( pointer->get_freepointer() != NULL ) {
  167305           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  167306           0 :                  storageArray++;
  167307           0 :                  storageCounter++;
  167308             :                }
  167309           0 :                pointer++;
  167310             :              }
  167311           0 :            block++;
  167312             :         }
  167313           0 :      return storageCounter;
  167314             :    }
  167315             : 
  167316             : /* #line 167317 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  167317             : 
  167318             : 
  167319             : 
  167320             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  167321             : 
  167322             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  167323             : 
  167324             : //############################################################################
  167325             : /* JH (02/02/2006) Constructor of the IR node SgIsNotOp that takes its 
  167326             :  * corresponding StorageClass as parameter
  167327             :  */
  167328           0 : SgIsNotOp :: SgIsNotOp ( const SgIsNotOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  167329             :    {
  167330             : 
  167331             : 
  167332             : /* #line 167333 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  167333             : 
  167334           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  167335             : 
  167336             : 
  167337             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  167338             : 
  167339             : 
  167340           0 :    }
  167341             : 
  167342             : //############################################################################
  167343             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  167344             :  * within the working AST. 
  167345             :  */
  167346           0 : SgIsNotOp * SgIsNotOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  167347           0 :      SgIsNotOp* returnPointer = NULL;
  167348           0 :      if ( globalIndex != 0 )
  167349             :         {
  167350             : 
  167351             : #if FILE_IO_EXTRA_CHECK
  167352           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIsNotOp ) ) <= globalIndex ) ;
  167353           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIsNotOp + 1 ) ) );
  167354             : #endif
  167355           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIsNotOp )  
  167356           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIsNotOp );
  167357           0 :           unsigned long positionInPool = localIndex % SgIsNotOp::pool_size;
  167358           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIsNotOp::pool_size;
  167359             : 
  167360             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  167361             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  167362             : 
  167363           0 :           returnPointer = &( ( (SgIsNotOp*)(SgIsNotOp::pools[memoryBlock]) ) [positionInPool]) ;
  167364             : 
  167365           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  167366             :         }
  167367           0 :      return returnPointer ;
  167368             :    }
  167369             : 
  167370             : //############################################################################
  167371             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  167372             :   for the AST with the index astIndex
  167373             : */
  167374           0 : SgIsNotOp * SgIsNotOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  167375           0 :      SgIsNotOp* returnPointer = NULL;
  167376           0 :      if ( globalIndex != 0 )
  167377             :         {
  167378             : 
  167379             : #if FILE_IO_EXTRA_CHECK
  167380           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIsNotOp ) ) <= globalIndex ) ;
  167381           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIsNotOp + 1 ) ) );
  167382             : #endif
  167383           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIsNotOp )
  167384           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIsNotOp );
  167385           0 :           unsigned long positionInPool = localIndex % SgIsNotOp::pool_size ;
  167386           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIsNotOp::pool_size ;
  167387             : 
  167388             : #if FILE_IO_EXTRA_CHECK
  167389             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  167390             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  167391             : #endif
  167392             : 
  167393           0 :           returnPointer = &( ( (SgIsNotOp*)(SgIsNotOp::pools[memoryBlock]) ) [positionInPool]) ;
  167394             : 
  167395             : #if FILE_IO_EXTRA_CHECK
  167396           0 :           assert ( returnPointer != NULL ) ;
  167397             : #endif
  167398             :         }
  167399           0 :      return returnPointer ;
  167400             :    }
  167401             : 
  167402             : //############################################################################
  167403             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  167404             :  * pool size! We set for every valid object in the memory pool the freepointer
  167405             :  * to the global index and increase the global index afterwards. For all the 
  167406             :  * invalid objects (means address ranges within the memory pool that were not
  167407             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  167408             :  * distinguish valid from invalid objects! 
  167409             :  */
  167410             : unsigned long
  167411           5 : SgIsNotOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  167412             :    {
  167413           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  167414           5 :      SgIsNotOp* pointer = NULL;
  167415           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  167416           5 :      std::vector < unsigned char* > :: const_iterator block;
  167417           5 :      for ( block = SgIsNotOp::pools.begin(); block != SgIsNotOp::pools.end() ; ++block )
  167418             :         {
  167419           0 :           pointer = (SgIsNotOp*)(*block);
  167420           0 :           for (unsigned i = 0; i < SgIsNotOp::pool_size; ++i )
  167421             :              {
  167422             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  167423             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  167424             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  167425             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  167426             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  167427             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  167428             :             // properly; so this will have to be checked next.
  167429             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  167430             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  167431           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  167432             :                   {
  167433           0 :                     pointer[i].set_freepointer((SgIsNotOp*)(globalIndex));
  167434           0 :                     globalIndex++;
  167435             :                   }
  167436             :                else
  167437             :                   {
  167438           0 :                     pointer[i].set_freepointer(NULL);
  167439             :                   }
  167440             :               }
  167441             :         }
  167442           5 :      return globalIndex;
  167443             :    }
  167444             : 
  167445             : //############################################################################
  167446             : // JH (01/14/2006)
  167447             : void
  167448           5 : SgIsNotOp::resetValidFreepointers( )
  167449             :    {
  167450           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  167451           5 :      SgIsNotOp* pointer = NULL;
  167452           5 :      std::vector < unsigned char* > :: const_iterator block;
  167453           5 :      SgIsNotOp* pointerOfLinkedList = NULL;
  167454           5 :      for ( block = SgIsNotOp::pools.begin(); block != SgIsNotOp::pools.end() ; ++block )
  167455             :         {
  167456           0 :           pointer = (SgIsNotOp*)(*block);
  167457           0 :           for (unsigned i = 0; i < SgIsNotOp::pool_size; ++i )
  167458             :              {
  167459             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  167460             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  167461             :             // memory blocks!.
  167462           0 :                if ( pointer[i].get_freepointer() != NULL )
  167463             :                   {
  167464           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  167465             :                   }
  167466             :                else
  167467             :                   {
  167468           0 :                     if ( pointerOfLinkedList == NULL )
  167469             :                        {
  167470           0 :                          SgIsNotOp::next_node = &(pointer[i]);
  167471             :                        }
  167472             :                     else
  167473             :                        {
  167474             :                       // printf ("In SgIsNotOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  167475           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  167476             :                        }
  167477             :                     pointerOfLinkedList = &(pointer[i]);
  167478             :                   }
  167479             :               }
  167480             :         }
  167481             : 
  167482           5 :      if ( pointerOfLinkedList != NULL )
  167483             :         {
  167484             :        // printf ("In SgIsNotOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  167485           0 :           pointerOfLinkedList->set_freepointer(NULL);
  167486             :        // DQ (6/6/2010): Temporary debugging...
  167487             :        //   ROSE_ASSERT(false);
  167488             :         }
  167489             : 
  167490           5 :      return ;
  167491             :    }
  167492             : 
  167493             : //############################################################################
  167494             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  167495             :  * within the memory pool and resets the freepointers, in order to achieve a 
  167496             :  * linked list, that has no jumps and starts at the beginning! This function 
  167497             :  * does not extend the memory pool, since we do not delete any memory blocks,
  167498             :  * but delete the valid objects.  
  167499             :  */
  167500             : void
  167501           0 : SgIsNotOp::clearMemoryPool( )
  167502             :    {
  167503             :   // printf ("Inside of SgIsNotOp::clearMemoryPool() \n");
  167504             : 
  167505           0 :      SgIsNotOp* pointer = NULL, *tempPointer = NULL;
  167506           0 :      std::vector < unsigned char* > :: const_iterator block;
  167507           0 :      if ( SgIsNotOp::pools.empty() == false )
  167508             :         {
  167509           0 :           block = SgIsNotOp::pools.begin() ;
  167510           0 :           SgIsNotOp::next_node = (SgIsNotOp*) (*block);
  167511             : 
  167512           0 :           while ( block != SgIsNotOp::pools.end() )
  167513             :              {
  167514           0 :                pointer = (SgIsNotOp*) (*block);
  167515           0 :                if ( tempPointer != NULL )
  167516             :                   {
  167517           0 :                     tempPointer->set_freepointer(pointer);
  167518             :                   }
  167519           0 :                for (unsigned i = 0; i < SgIsNotOp::pool_size - 1; ++i)
  167520             :                   {
  167521           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  167522             :                   }
  167523           0 :                 pointer[SgIsNotOp::pool_size-1].set_freepointer(NULL);
  167524           0 :                 tempPointer = &(pointer[SgIsNotOp::pool_size-1]);
  167525           0 :                 ++block;
  167526             :              }
  167527             :         }
  167528           0 :    }
  167529             : 
  167530           5 : void SgIsNotOp::deleteMemoryPool() {
  167531           5 :   for (auto p: SgIsNotOp::pools) {
  167532           0 :     ROSE_FREE(p);
  167533             :   }
  167534           5 :   SgIsNotOp::next_node = nullptr;
  167535           5 :   SgIsNotOp::pools.clear();
  167536           5 : }
  167537             : 
  167538             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  167539             : //                 reading multiple binary files to for a single AST.
  167540             : /////////// new version ////////////////////////////////
  167541             : //############################################################################
  167542             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  167543             : void
  167544           2 : SgIsNotOp::extendMemoryPoolForFileIO( )
  167545             :   {
  167546           2 :     size_t blockIndex = SgIsNotOp::pools.size();
  167547           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIsNotOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIsNotOp);
  167548             : 
  167549           2 :     while ( (blockIndex * SgIsNotOp::pool_size) < newPoolSize)
  167550             :       {
  167551             : #if ROSE_ALLOC_TRACE
  167552             :         if (blockIndex > 0) {
  167553             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIsNotOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIsNotOp) = %" PRIuPTR " SgIsNotOp::pool_size = %d \n",
  167554             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIsNotOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIsNotOp),SgIsNotOp::pool_size);
  167555             :         }
  167556             : #endif
  167557             : 
  167558           0 :         SgIsNotOp * pointer = (SgIsNotOp*) ROSE_MALLOC ( SgIsNotOp::pool_size * sizeof(SgIsNotOp) );
  167559           0 :         assert( pointer != NULL );
  167560             : #if ROSE_ALLOC_MEMSET == 1
  167561             :         memset(pointer, 0x00, SgIsNotOp::pool_size * sizeof(SgIsNotOp));
  167562             : #elif ROSE_ALLOC_MEMSET == 2
  167563             :         memset(pointer, 0xCC, SgIsNotOp::pool_size * sizeof(SgIsNotOp));
  167564             : #endif
  167565           0 :         SgIsNotOp::pools.push_back( (unsigned char*)(pointer) );
  167566           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIsNotOp::pool_size * sizeof(SgIsNotOp), V_SgIsNotOp ) );
  167567             : 
  167568           0 :         if ( SgIsNotOp::next_node != NULL ) {
  167569           0 :           if ( blockIndex > 0 ) {
  167570           0 :             SgIsNotOp * blkptr = (SgIsNotOp*)(SgIsNotOp::pools[blockIndex-1]);
  167571           0 :             blkptr[ SgIsNotOp::pool_size - 1 ].set_freepointer(pointer);
  167572             :           }
  167573             :         } else {
  167574           0 :           SgIsNotOp::next_node = pointer;
  167575             :         }
  167576             : 
  167577           0 :         for (unsigned i = 0; i < SgIsNotOp::pool_size-1; ++i)
  167578             :            {
  167579           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  167580             :            }
  167581           0 :         pointer[ SgIsNotOp::pool_size -1 ].set_freepointer(NULL);
  167582             : 
  167583           0 :         blockIndex++;
  167584             :       }
  167585           2 :   }
  167586             : 
  167587             : //############################################################################
  167588             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  167589             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  167590             :  * not compressed. However, that stuff is not yet implemented! 
  167591             :  */
  167592             : unsigned long
  167593           0 : SgIsNotOp::getNumberOfLastValidPointer()
  167594             :    {
  167595           0 :       SgIsNotOp* testPointer = (SgIsNotOp*)(SgIsNotOp::pools.back());
  167596           0 :       unsigned long localIndex = SgIsNotOp::pool_size - 1;
  167597           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  167598             :          {
  167599           0 :            localIndex--;
  167600             :          }
  167601           0 :       return (localIndex + SgIsNotOp::pool_size * (SgIsNotOp::pools.size()-1));
  167602             :    }
  167603             : 
  167604             : //############################################################################
  167605             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  167606             :  * memory pool and initializes the data member in class SgIsNotOpStroageClass
  167607             :  * from its counterpart of SgIsNotOp. The return value is just for checking, 
  167608             :  * that the whole StorageClassArray is initialized!
  167609             :  */
  167610             : unsigned long
  167611           0 : SgIsNotOp::initializeStorageClassArray( SgIsNotOpStorageClass *storageArray )
  167612             :    {
  167613           0 :      unsigned long storageCounter = 0;
  167614           0 :      std::vector < unsigned char* > :: const_iterator block = SgIsNotOp::pools.begin();
  167615           0 :      SgIsNotOp* pointer = NULL;
  167616           0 :      while ( block != SgIsNotOp::pools.end() ) {
  167617           0 :           pointer = (SgIsNotOp*) (*block);
  167618           0 :           for ( unsigned i = 0; i < SgIsNotOp::pool_size; ++i ) {
  167619           0 :                if ( pointer->get_freepointer() != NULL ) {
  167620           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  167621           0 :                  storageArray++;
  167622           0 :                  storageCounter++;
  167623             :                }
  167624           0 :                pointer++;
  167625             :              }
  167626           0 :            block++;
  167627             :         }
  167628           0 :      return storageCounter;
  167629             :    }
  167630             : 
  167631             : /* #line 167632 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  167632             : 
  167633             : 
  167634             : 
  167635             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  167636             : 
  167637             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  167638             : 
  167639             : //############################################################################
  167640             : /* JH (02/02/2006) Constructor of the IR node SgElementwiseOp that takes its 
  167641             :  * corresponding StorageClass as parameter
  167642             :  */
  167643           0 : SgElementwiseOp :: SgElementwiseOp ( const SgElementwiseOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  167644             :    {
  167645             : 
  167646             : 
  167647             : /* #line 167648 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  167648             : 
  167649           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  167650             : 
  167651             : 
  167652             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  167653             : 
  167654             : 
  167655           0 :    }
  167656             : 
  167657             : //############################################################################
  167658             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  167659             :  * within the working AST. 
  167660             :  */
  167661           0 : SgElementwiseOp * SgElementwiseOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  167662           0 :      SgElementwiseOp* returnPointer = NULL;
  167663           0 :      if ( globalIndex != 0 )
  167664             :         {
  167665             : 
  167666             : #if FILE_IO_EXTRA_CHECK
  167667           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElementwiseOp ) ) <= globalIndex ) ;
  167668           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseOp + 1 ) ) );
  167669             : #endif
  167670           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseOp )  
  167671           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElementwiseOp );
  167672           0 :           unsigned long positionInPool = localIndex % SgElementwiseOp::pool_size;
  167673           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseOp::pool_size;
  167674             : 
  167675             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  167676             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  167677             : 
  167678           0 :           returnPointer = &( ( (SgElementwiseOp*)(SgElementwiseOp::pools[memoryBlock]) ) [positionInPool]) ;
  167679             : 
  167680           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  167681             :         }
  167682           0 :      return returnPointer ;
  167683             :    }
  167684             : 
  167685             : //############################################################################
  167686             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  167687             :   for the AST with the index astIndex
  167688             : */
  167689           0 : SgElementwiseOp * SgElementwiseOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  167690           0 :      SgElementwiseOp* returnPointer = NULL;
  167691           0 :      if ( globalIndex != 0 )
  167692             :         {
  167693             : 
  167694             : #if FILE_IO_EXTRA_CHECK
  167695           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElementwiseOp ) ) <= globalIndex ) ;
  167696           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseOp + 1 ) ) );
  167697             : #endif
  167698           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseOp )
  167699           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElementwiseOp );
  167700           0 :           unsigned long positionInPool = localIndex % SgElementwiseOp::pool_size ;
  167701           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseOp::pool_size ;
  167702             : 
  167703             : #if FILE_IO_EXTRA_CHECK
  167704             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  167705             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  167706             : #endif
  167707             : 
  167708           0 :           returnPointer = &( ( (SgElementwiseOp*)(SgElementwiseOp::pools[memoryBlock]) ) [positionInPool]) ;
  167709             : 
  167710             : #if FILE_IO_EXTRA_CHECK
  167711           0 :           assert ( returnPointer != NULL ) ;
  167712             : #endif
  167713             :         }
  167714           0 :      return returnPointer ;
  167715             :    }
  167716             : 
  167717             : //############################################################################
  167718             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  167719             :  * pool size! We set for every valid object in the memory pool the freepointer
  167720             :  * to the global index and increase the global index afterwards. For all the 
  167721             :  * invalid objects (means address ranges within the memory pool that were not
  167722             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  167723             :  * distinguish valid from invalid objects! 
  167724             :  */
  167725             : unsigned long
  167726           5 : SgElementwiseOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  167727             :    {
  167728           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  167729           5 :      SgElementwiseOp* pointer = NULL;
  167730           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  167731           5 :      std::vector < unsigned char* > :: const_iterator block;
  167732           5 :      for ( block = SgElementwiseOp::pools.begin(); block != SgElementwiseOp::pools.end() ; ++block )
  167733             :         {
  167734           0 :           pointer = (SgElementwiseOp*)(*block);
  167735           0 :           for (unsigned i = 0; i < SgElementwiseOp::pool_size; ++i )
  167736             :              {
  167737             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  167738             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  167739             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  167740             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  167741             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  167742             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  167743             :             // properly; so this will have to be checked next.
  167744             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  167745             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  167746           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  167747             :                   {
  167748           0 :                     pointer[i].set_freepointer((SgElementwiseOp*)(globalIndex));
  167749           0 :                     globalIndex++;
  167750             :                   }
  167751             :                else
  167752             :                   {
  167753           0 :                     pointer[i].set_freepointer(NULL);
  167754             :                   }
  167755             :               }
  167756             :         }
  167757           5 :      return globalIndex;
  167758             :    }
  167759             : 
  167760             : //############################################################################
  167761             : // JH (01/14/2006)
  167762             : void
  167763           5 : SgElementwiseOp::resetValidFreepointers( )
  167764             :    {
  167765           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  167766           5 :      SgElementwiseOp* pointer = NULL;
  167767           5 :      std::vector < unsigned char* > :: const_iterator block;
  167768           5 :      SgElementwiseOp* pointerOfLinkedList = NULL;
  167769           5 :      for ( block = SgElementwiseOp::pools.begin(); block != SgElementwiseOp::pools.end() ; ++block )
  167770             :         {
  167771           0 :           pointer = (SgElementwiseOp*)(*block);
  167772           0 :           for (unsigned i = 0; i < SgElementwiseOp::pool_size; ++i )
  167773             :              {
  167774             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  167775             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  167776             :             // memory blocks!.
  167777           0 :                if ( pointer[i].get_freepointer() != NULL )
  167778             :                   {
  167779           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  167780             :                   }
  167781             :                else
  167782             :                   {
  167783           0 :                     if ( pointerOfLinkedList == NULL )
  167784             :                        {
  167785           0 :                          SgElementwiseOp::next_node = &(pointer[i]);
  167786             :                        }
  167787             :                     else
  167788             :                        {
  167789             :                       // printf ("In SgElementwiseOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  167790           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  167791             :                        }
  167792             :                     pointerOfLinkedList = &(pointer[i]);
  167793             :                   }
  167794             :               }
  167795             :         }
  167796             : 
  167797           5 :      if ( pointerOfLinkedList != NULL )
  167798             :         {
  167799             :        // printf ("In SgElementwiseOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  167800           0 :           pointerOfLinkedList->set_freepointer(NULL);
  167801             :        // DQ (6/6/2010): Temporary debugging...
  167802             :        //   ROSE_ASSERT(false);
  167803             :         }
  167804             : 
  167805           5 :      return ;
  167806             :    }
  167807             : 
  167808             : //############################################################################
  167809             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  167810             :  * within the memory pool and resets the freepointers, in order to achieve a 
  167811             :  * linked list, that has no jumps and starts at the beginning! This function 
  167812             :  * does not extend the memory pool, since we do not delete any memory blocks,
  167813             :  * but delete the valid objects.  
  167814             :  */
  167815             : void
  167816           0 : SgElementwiseOp::clearMemoryPool( )
  167817             :    {
  167818             :   // printf ("Inside of SgElementwiseOp::clearMemoryPool() \n");
  167819             : 
  167820           0 :      SgElementwiseOp* pointer = NULL, *tempPointer = NULL;
  167821           0 :      std::vector < unsigned char* > :: const_iterator block;
  167822           0 :      if ( SgElementwiseOp::pools.empty() == false )
  167823             :         {
  167824           0 :           block = SgElementwiseOp::pools.begin() ;
  167825           0 :           SgElementwiseOp::next_node = (SgElementwiseOp*) (*block);
  167826             : 
  167827           0 :           while ( block != SgElementwiseOp::pools.end() )
  167828             :              {
  167829           0 :                pointer = (SgElementwiseOp*) (*block);
  167830           0 :                if ( tempPointer != NULL )
  167831             :                   {
  167832           0 :                     tempPointer->set_freepointer(pointer);
  167833             :                   }
  167834           0 :                for (unsigned i = 0; i < SgElementwiseOp::pool_size - 1; ++i)
  167835             :                   {
  167836           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  167837             :                   }
  167838           0 :                 pointer[SgElementwiseOp::pool_size-1].set_freepointer(NULL);
  167839           0 :                 tempPointer = &(pointer[SgElementwiseOp::pool_size-1]);
  167840           0 :                 ++block;
  167841             :              }
  167842             :         }
  167843           0 :    }
  167844             : 
  167845           5 : void SgElementwiseOp::deleteMemoryPool() {
  167846           5 :   for (auto p: SgElementwiseOp::pools) {
  167847           0 :     ROSE_FREE(p);
  167848             :   }
  167849           5 :   SgElementwiseOp::next_node = nullptr;
  167850           5 :   SgElementwiseOp::pools.clear();
  167851           5 : }
  167852             : 
  167853             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  167854             : //                 reading multiple binary files to for a single AST.
  167855             : /////////// new version ////////////////////////////////
  167856             : //############################################################################
  167857             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  167858             : void
  167859           2 : SgElementwiseOp::extendMemoryPoolForFileIO( )
  167860             :   {
  167861           2 :     size_t blockIndex = SgElementwiseOp::pools.size();
  167862           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseOp);
  167863             : 
  167864           2 :     while ( (blockIndex * SgElementwiseOp::pool_size) < newPoolSize)
  167865             :       {
  167866             : #if ROSE_ALLOC_TRACE
  167867             :         if (blockIndex > 0) {
  167868             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseOp) = %" PRIuPTR " SgElementwiseOp::pool_size = %d \n",
  167869             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseOp),SgElementwiseOp::pool_size);
  167870             :         }
  167871             : #endif
  167872             : 
  167873           0 :         SgElementwiseOp * pointer = (SgElementwiseOp*) ROSE_MALLOC ( SgElementwiseOp::pool_size * sizeof(SgElementwiseOp) );
  167874           0 :         assert( pointer != NULL );
  167875             : #if ROSE_ALLOC_MEMSET == 1
  167876             :         memset(pointer, 0x00, SgElementwiseOp::pool_size * sizeof(SgElementwiseOp));
  167877             : #elif ROSE_ALLOC_MEMSET == 2
  167878             :         memset(pointer, 0xCC, SgElementwiseOp::pool_size * sizeof(SgElementwiseOp));
  167879             : #endif
  167880           0 :         SgElementwiseOp::pools.push_back( (unsigned char*)(pointer) );
  167881           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElementwiseOp::pool_size * sizeof(SgElementwiseOp), V_SgElementwiseOp ) );
  167882             : 
  167883           0 :         if ( SgElementwiseOp::next_node != NULL ) {
  167884           0 :           if ( blockIndex > 0 ) {
  167885           0 :             SgElementwiseOp * blkptr = (SgElementwiseOp*)(SgElementwiseOp::pools[blockIndex-1]);
  167886           0 :             blkptr[ SgElementwiseOp::pool_size - 1 ].set_freepointer(pointer);
  167887             :           }
  167888             :         } else {
  167889           0 :           SgElementwiseOp::next_node = pointer;
  167890             :         }
  167891             : 
  167892           0 :         for (unsigned i = 0; i < SgElementwiseOp::pool_size-1; ++i)
  167893             :            {
  167894           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  167895             :            }
  167896           0 :         pointer[ SgElementwiseOp::pool_size -1 ].set_freepointer(NULL);
  167897             : 
  167898           0 :         blockIndex++;
  167899             :       }
  167900           2 :   }
  167901             : 
  167902             : //############################################################################
  167903             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  167904             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  167905             :  * not compressed. However, that stuff is not yet implemented! 
  167906             :  */
  167907             : unsigned long
  167908           0 : SgElementwiseOp::getNumberOfLastValidPointer()
  167909             :    {
  167910           0 :       SgElementwiseOp* testPointer = (SgElementwiseOp*)(SgElementwiseOp::pools.back());
  167911           0 :       unsigned long localIndex = SgElementwiseOp::pool_size - 1;
  167912           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  167913             :          {
  167914           0 :            localIndex--;
  167915             :          }
  167916           0 :       return (localIndex + SgElementwiseOp::pool_size * (SgElementwiseOp::pools.size()-1));
  167917             :    }
  167918             : 
  167919             : //############################################################################
  167920             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  167921             :  * memory pool and initializes the data member in class SgElementwiseOpStroageClass
  167922             :  * from its counterpart of SgElementwiseOp. The return value is just for checking, 
  167923             :  * that the whole StorageClassArray is initialized!
  167924             :  */
  167925             : unsigned long
  167926           0 : SgElementwiseOp::initializeStorageClassArray( SgElementwiseOpStorageClass *storageArray )
  167927             :    {
  167928           0 :      unsigned long storageCounter = 0;
  167929           0 :      std::vector < unsigned char* > :: const_iterator block = SgElementwiseOp::pools.begin();
  167930           0 :      SgElementwiseOp* pointer = NULL;
  167931           0 :      while ( block != SgElementwiseOp::pools.end() ) {
  167932           0 :           pointer = (SgElementwiseOp*) (*block);
  167933           0 :           for ( unsigned i = 0; i < SgElementwiseOp::pool_size; ++i ) {
  167934           0 :                if ( pointer->get_freepointer() != NULL ) {
  167935           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  167936           0 :                  storageArray++;
  167937           0 :                  storageCounter++;
  167938             :                }
  167939           0 :                pointer++;
  167940             :              }
  167941           0 :            block++;
  167942             :         }
  167943           0 :      return storageCounter;
  167944             :    }
  167945             : 
  167946             : /* #line 167947 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  167947             : 
  167948             : 
  167949             : 
  167950             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  167951             : 
  167952             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  167953             : 
  167954             : //############################################################################
  167955             : /* JH (02/02/2006) Constructor of the IR node SgElementwiseMultiplyOp that takes its 
  167956             :  * corresponding StorageClass as parameter
  167957             :  */
  167958           0 : SgElementwiseMultiplyOp :: SgElementwiseMultiplyOp ( const SgElementwiseMultiplyOpStorageClass& storageSource )   : SgElementwiseOp (storageSource)
  167959             :    {
  167960             : 
  167961             : 
  167962             : /* #line 167963 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  167963             : 
  167964           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  167965             : 
  167966             : 
  167967             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  167968             : 
  167969             : 
  167970           0 :    }
  167971             : 
  167972             : //############################################################################
  167973             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  167974             :  * within the working AST. 
  167975             :  */
  167976           0 : SgElementwiseMultiplyOp * SgElementwiseMultiplyOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  167977           0 :      SgElementwiseMultiplyOp* returnPointer = NULL;
  167978           0 :      if ( globalIndex != 0 )
  167979             :         {
  167980             : 
  167981             : #if FILE_IO_EXTRA_CHECK
  167982           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElementwiseMultiplyOp ) ) <= globalIndex ) ;
  167983           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseMultiplyOp + 1 ) ) );
  167984             : #endif
  167985           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseMultiplyOp )  
  167986           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElementwiseMultiplyOp );
  167987           0 :           unsigned long positionInPool = localIndex % SgElementwiseMultiplyOp::pool_size;
  167988           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseMultiplyOp::pool_size;
  167989             : 
  167990             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  167991             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  167992             : 
  167993           0 :           returnPointer = &( ( (SgElementwiseMultiplyOp*)(SgElementwiseMultiplyOp::pools[memoryBlock]) ) [positionInPool]) ;
  167994             : 
  167995           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  167996             :         }
  167997           0 :      return returnPointer ;
  167998             :    }
  167999             : 
  168000             : //############################################################################
  168001             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  168002             :   for the AST with the index astIndex
  168003             : */
  168004           0 : SgElementwiseMultiplyOp * SgElementwiseMultiplyOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  168005           0 :      SgElementwiseMultiplyOp* returnPointer = NULL;
  168006           0 :      if ( globalIndex != 0 )
  168007             :         {
  168008             : 
  168009             : #if FILE_IO_EXTRA_CHECK
  168010           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElementwiseMultiplyOp ) ) <= globalIndex ) ;
  168011           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseMultiplyOp + 1 ) ) );
  168012             : #endif
  168013           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseMultiplyOp )
  168014           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElementwiseMultiplyOp );
  168015           0 :           unsigned long positionInPool = localIndex % SgElementwiseMultiplyOp::pool_size ;
  168016           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseMultiplyOp::pool_size ;
  168017             : 
  168018             : #if FILE_IO_EXTRA_CHECK
  168019             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  168020             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  168021             : #endif
  168022             : 
  168023           0 :           returnPointer = &( ( (SgElementwiseMultiplyOp*)(SgElementwiseMultiplyOp::pools[memoryBlock]) ) [positionInPool]) ;
  168024             : 
  168025             : #if FILE_IO_EXTRA_CHECK
  168026           0 :           assert ( returnPointer != NULL ) ;
  168027             : #endif
  168028             :         }
  168029           0 :      return returnPointer ;
  168030             :    }
  168031             : 
  168032             : //############################################################################
  168033             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  168034             :  * pool size! We set for every valid object in the memory pool the freepointer
  168035             :  * to the global index and increase the global index afterwards. For all the 
  168036             :  * invalid objects (means address ranges within the memory pool that were not
  168037             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  168038             :  * distinguish valid from invalid objects! 
  168039             :  */
  168040             : unsigned long
  168041           5 : SgElementwiseMultiplyOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  168042             :    {
  168043           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  168044           5 :      SgElementwiseMultiplyOp* pointer = NULL;
  168045           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  168046           5 :      std::vector < unsigned char* > :: const_iterator block;
  168047           5 :      for ( block = SgElementwiseMultiplyOp::pools.begin(); block != SgElementwiseMultiplyOp::pools.end() ; ++block )
  168048             :         {
  168049           0 :           pointer = (SgElementwiseMultiplyOp*)(*block);
  168050           0 :           for (unsigned i = 0; i < SgElementwiseMultiplyOp::pool_size; ++i )
  168051             :              {
  168052             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  168053             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  168054             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  168055             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  168056             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  168057             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  168058             :             // properly; so this will have to be checked next.
  168059             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  168060             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  168061           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  168062             :                   {
  168063           0 :                     pointer[i].set_freepointer((SgElementwiseMultiplyOp*)(globalIndex));
  168064           0 :                     globalIndex++;
  168065             :                   }
  168066             :                else
  168067             :                   {
  168068           0 :                     pointer[i].set_freepointer(NULL);
  168069             :                   }
  168070             :               }
  168071             :         }
  168072           5 :      return globalIndex;
  168073             :    }
  168074             : 
  168075             : //############################################################################
  168076             : // JH (01/14/2006)
  168077             : void
  168078           5 : SgElementwiseMultiplyOp::resetValidFreepointers( )
  168079             :    {
  168080           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  168081           5 :      SgElementwiseMultiplyOp* pointer = NULL;
  168082           5 :      std::vector < unsigned char* > :: const_iterator block;
  168083           5 :      SgElementwiseMultiplyOp* pointerOfLinkedList = NULL;
  168084           5 :      for ( block = SgElementwiseMultiplyOp::pools.begin(); block != SgElementwiseMultiplyOp::pools.end() ; ++block )
  168085             :         {
  168086           0 :           pointer = (SgElementwiseMultiplyOp*)(*block);
  168087           0 :           for (unsigned i = 0; i < SgElementwiseMultiplyOp::pool_size; ++i )
  168088             :              {
  168089             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  168090             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  168091             :             // memory blocks!.
  168092           0 :                if ( pointer[i].get_freepointer() != NULL )
  168093             :                   {
  168094           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  168095             :                   }
  168096             :                else
  168097             :                   {
  168098           0 :                     if ( pointerOfLinkedList == NULL )
  168099             :                        {
  168100           0 :                          SgElementwiseMultiplyOp::next_node = &(pointer[i]);
  168101             :                        }
  168102             :                     else
  168103             :                        {
  168104             :                       // printf ("In SgElementwiseMultiplyOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  168105           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  168106             :                        }
  168107             :                     pointerOfLinkedList = &(pointer[i]);
  168108             :                   }
  168109             :               }
  168110             :         }
  168111             : 
  168112           5 :      if ( pointerOfLinkedList != NULL )
  168113             :         {
  168114             :        // printf ("In SgElementwiseMultiplyOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  168115           0 :           pointerOfLinkedList->set_freepointer(NULL);
  168116             :        // DQ (6/6/2010): Temporary debugging...
  168117             :        //   ROSE_ASSERT(false);
  168118             :         }
  168119             : 
  168120           5 :      return ;
  168121             :    }
  168122             : 
  168123             : //############################################################################
  168124             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  168125             :  * within the memory pool and resets the freepointers, in order to achieve a 
  168126             :  * linked list, that has no jumps and starts at the beginning! This function 
  168127             :  * does not extend the memory pool, since we do not delete any memory blocks,
  168128             :  * but delete the valid objects.  
  168129             :  */
  168130             : void
  168131           0 : SgElementwiseMultiplyOp::clearMemoryPool( )
  168132             :    {
  168133             :   // printf ("Inside of SgElementwiseMultiplyOp::clearMemoryPool() \n");
  168134             : 
  168135           0 :      SgElementwiseMultiplyOp* pointer = NULL, *tempPointer = NULL;
  168136           0 :      std::vector < unsigned char* > :: const_iterator block;
  168137           0 :      if ( SgElementwiseMultiplyOp::pools.empty() == false )
  168138             :         {
  168139           0 :           block = SgElementwiseMultiplyOp::pools.begin() ;
  168140           0 :           SgElementwiseMultiplyOp::next_node = (SgElementwiseMultiplyOp*) (*block);
  168141             : 
  168142           0 :           while ( block != SgElementwiseMultiplyOp::pools.end() )
  168143             :              {
  168144           0 :                pointer = (SgElementwiseMultiplyOp*) (*block);
  168145           0 :                if ( tempPointer != NULL )
  168146             :                   {
  168147           0 :                     tempPointer->set_freepointer(pointer);
  168148             :                   }
  168149           0 :                for (unsigned i = 0; i < SgElementwiseMultiplyOp::pool_size - 1; ++i)
  168150             :                   {
  168151           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  168152             :                   }
  168153           0 :                 pointer[SgElementwiseMultiplyOp::pool_size-1].set_freepointer(NULL);
  168154           0 :                 tempPointer = &(pointer[SgElementwiseMultiplyOp::pool_size-1]);
  168155           0 :                 ++block;
  168156             :              }
  168157             :         }
  168158           0 :    }
  168159             : 
  168160           5 : void SgElementwiseMultiplyOp::deleteMemoryPool() {
  168161           5 :   for (auto p: SgElementwiseMultiplyOp::pools) {
  168162           0 :     ROSE_FREE(p);
  168163             :   }
  168164           5 :   SgElementwiseMultiplyOp::next_node = nullptr;
  168165           5 :   SgElementwiseMultiplyOp::pools.clear();
  168166           5 : }
  168167             : 
  168168             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  168169             : //                 reading multiple binary files to for a single AST.
  168170             : /////////// new version ////////////////////////////////
  168171             : //############################################################################
  168172             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  168173             : void
  168174           2 : SgElementwiseMultiplyOp::extendMemoryPoolForFileIO( )
  168175             :   {
  168176           2 :     size_t blockIndex = SgElementwiseMultiplyOp::pools.size();
  168177           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseMultiplyOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseMultiplyOp);
  168178             : 
  168179           2 :     while ( (blockIndex * SgElementwiseMultiplyOp::pool_size) < newPoolSize)
  168180             :       {
  168181             : #if ROSE_ALLOC_TRACE
  168182             :         if (blockIndex > 0) {
  168183             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseMultiplyOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseMultiplyOp) = %" PRIuPTR " SgElementwiseMultiplyOp::pool_size = %d \n",
  168184             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseMultiplyOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseMultiplyOp),SgElementwiseMultiplyOp::pool_size);
  168185             :         }
  168186             : #endif
  168187             : 
  168188           0 :         SgElementwiseMultiplyOp * pointer = (SgElementwiseMultiplyOp*) ROSE_MALLOC ( SgElementwiseMultiplyOp::pool_size * sizeof(SgElementwiseMultiplyOp) );
  168189           0 :         assert( pointer != NULL );
  168190             : #if ROSE_ALLOC_MEMSET == 1
  168191             :         memset(pointer, 0x00, SgElementwiseMultiplyOp::pool_size * sizeof(SgElementwiseMultiplyOp));
  168192             : #elif ROSE_ALLOC_MEMSET == 2
  168193             :         memset(pointer, 0xCC, SgElementwiseMultiplyOp::pool_size * sizeof(SgElementwiseMultiplyOp));
  168194             : #endif
  168195           0 :         SgElementwiseMultiplyOp::pools.push_back( (unsigned char*)(pointer) );
  168196           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElementwiseMultiplyOp::pool_size * sizeof(SgElementwiseMultiplyOp), V_SgElementwiseMultiplyOp ) );
  168197             : 
  168198           0 :         if ( SgElementwiseMultiplyOp::next_node != NULL ) {
  168199           0 :           if ( blockIndex > 0 ) {
  168200           0 :             SgElementwiseMultiplyOp * blkptr = (SgElementwiseMultiplyOp*)(SgElementwiseMultiplyOp::pools[blockIndex-1]);
  168201           0 :             blkptr[ SgElementwiseMultiplyOp::pool_size - 1 ].set_freepointer(pointer);
  168202             :           }
  168203             :         } else {
  168204           0 :           SgElementwiseMultiplyOp::next_node = pointer;
  168205             :         }
  168206             : 
  168207           0 :         for (unsigned i = 0; i < SgElementwiseMultiplyOp::pool_size-1; ++i)
  168208             :            {
  168209           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  168210             :            }
  168211           0 :         pointer[ SgElementwiseMultiplyOp::pool_size -1 ].set_freepointer(NULL);
  168212             : 
  168213           0 :         blockIndex++;
  168214             :       }
  168215           2 :   }
  168216             : 
  168217             : //############################################################################
  168218             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  168219             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  168220             :  * not compressed. However, that stuff is not yet implemented! 
  168221             :  */
  168222             : unsigned long
  168223           0 : SgElementwiseMultiplyOp::getNumberOfLastValidPointer()
  168224             :    {
  168225           0 :       SgElementwiseMultiplyOp* testPointer = (SgElementwiseMultiplyOp*)(SgElementwiseMultiplyOp::pools.back());
  168226           0 :       unsigned long localIndex = SgElementwiseMultiplyOp::pool_size - 1;
  168227           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  168228             :          {
  168229           0 :            localIndex--;
  168230             :          }
  168231           0 :       return (localIndex + SgElementwiseMultiplyOp::pool_size * (SgElementwiseMultiplyOp::pools.size()-1));
  168232             :    }
  168233             : 
  168234             : //############################################################################
  168235             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  168236             :  * memory pool and initializes the data member in class SgElementwiseMultiplyOpStroageClass
  168237             :  * from its counterpart of SgElementwiseMultiplyOp. The return value is just for checking, 
  168238             :  * that the whole StorageClassArray is initialized!
  168239             :  */
  168240             : unsigned long
  168241           0 : SgElementwiseMultiplyOp::initializeStorageClassArray( SgElementwiseMultiplyOpStorageClass *storageArray )
  168242             :    {
  168243           0 :      unsigned long storageCounter = 0;
  168244           0 :      std::vector < unsigned char* > :: const_iterator block = SgElementwiseMultiplyOp::pools.begin();
  168245           0 :      SgElementwiseMultiplyOp* pointer = NULL;
  168246           0 :      while ( block != SgElementwiseMultiplyOp::pools.end() ) {
  168247           0 :           pointer = (SgElementwiseMultiplyOp*) (*block);
  168248           0 :           for ( unsigned i = 0; i < SgElementwiseMultiplyOp::pool_size; ++i ) {
  168249           0 :                if ( pointer->get_freepointer() != NULL ) {
  168250           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  168251           0 :                  storageArray++;
  168252           0 :                  storageCounter++;
  168253             :                }
  168254           0 :                pointer++;
  168255             :              }
  168256           0 :            block++;
  168257             :         }
  168258           0 :      return storageCounter;
  168259             :    }
  168260             : 
  168261             : /* #line 168262 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  168262             : 
  168263             : 
  168264             : 
  168265             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  168266             : 
  168267             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  168268             : 
  168269             : //############################################################################
  168270             : /* JH (02/02/2006) Constructor of the IR node SgElementwisePowerOp that takes its 
  168271             :  * corresponding StorageClass as parameter
  168272             :  */
  168273           0 : SgElementwisePowerOp :: SgElementwisePowerOp ( const SgElementwisePowerOpStorageClass& storageSource )   : SgElementwiseOp (storageSource)
  168274             :    {
  168275             : 
  168276             : 
  168277             : /* #line 168278 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  168278             : 
  168279           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  168280             : 
  168281             : 
  168282             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  168283             : 
  168284             : 
  168285           0 :    }
  168286             : 
  168287             : //############################################################################
  168288             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  168289             :  * within the working AST. 
  168290             :  */
  168291           0 : SgElementwisePowerOp * SgElementwisePowerOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  168292           0 :      SgElementwisePowerOp* returnPointer = NULL;
  168293           0 :      if ( globalIndex != 0 )
  168294             :         {
  168295             : 
  168296             : #if FILE_IO_EXTRA_CHECK
  168297           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElementwisePowerOp ) ) <= globalIndex ) ;
  168298           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwisePowerOp + 1 ) ) );
  168299             : #endif
  168300           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwisePowerOp )  
  168301           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElementwisePowerOp );
  168302           0 :           unsigned long positionInPool = localIndex % SgElementwisePowerOp::pool_size;
  168303           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwisePowerOp::pool_size;
  168304             : 
  168305             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  168306             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  168307             : 
  168308           0 :           returnPointer = &( ( (SgElementwisePowerOp*)(SgElementwisePowerOp::pools[memoryBlock]) ) [positionInPool]) ;
  168309             : 
  168310           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  168311             :         }
  168312           0 :      return returnPointer ;
  168313             :    }
  168314             : 
  168315             : //############################################################################
  168316             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  168317             :   for the AST with the index astIndex
  168318             : */
  168319           0 : SgElementwisePowerOp * SgElementwisePowerOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  168320           0 :      SgElementwisePowerOp* returnPointer = NULL;
  168321           0 :      if ( globalIndex != 0 )
  168322             :         {
  168323             : 
  168324             : #if FILE_IO_EXTRA_CHECK
  168325           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElementwisePowerOp ) ) <= globalIndex ) ;
  168326           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwisePowerOp + 1 ) ) );
  168327             : #endif
  168328           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwisePowerOp )
  168329           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElementwisePowerOp );
  168330           0 :           unsigned long positionInPool = localIndex % SgElementwisePowerOp::pool_size ;
  168331           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwisePowerOp::pool_size ;
  168332             : 
  168333             : #if FILE_IO_EXTRA_CHECK
  168334             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  168335             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  168336             : #endif
  168337             : 
  168338           0 :           returnPointer = &( ( (SgElementwisePowerOp*)(SgElementwisePowerOp::pools[memoryBlock]) ) [positionInPool]) ;
  168339             : 
  168340             : #if FILE_IO_EXTRA_CHECK
  168341           0 :           assert ( returnPointer != NULL ) ;
  168342             : #endif
  168343             :         }
  168344           0 :      return returnPointer ;
  168345             :    }
  168346             : 
  168347             : //############################################################################
  168348             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  168349             :  * pool size! We set for every valid object in the memory pool the freepointer
  168350             :  * to the global index and increase the global index afterwards. For all the 
  168351             :  * invalid objects (means address ranges within the memory pool that were not
  168352             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  168353             :  * distinguish valid from invalid objects! 
  168354             :  */
  168355             : unsigned long
  168356           5 : SgElementwisePowerOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  168357             :    {
  168358           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  168359           5 :      SgElementwisePowerOp* pointer = NULL;
  168360           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  168361           5 :      std::vector < unsigned char* > :: const_iterator block;
  168362           5 :      for ( block = SgElementwisePowerOp::pools.begin(); block != SgElementwisePowerOp::pools.end() ; ++block )
  168363             :         {
  168364           0 :           pointer = (SgElementwisePowerOp*)(*block);
  168365           0 :           for (unsigned i = 0; i < SgElementwisePowerOp::pool_size; ++i )
  168366             :              {
  168367             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  168368             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  168369             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  168370             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  168371             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  168372             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  168373             :             // properly; so this will have to be checked next.
  168374             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  168375             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  168376           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  168377             :                   {
  168378           0 :                     pointer[i].set_freepointer((SgElementwisePowerOp*)(globalIndex));
  168379           0 :                     globalIndex++;
  168380             :                   }
  168381             :                else
  168382             :                   {
  168383           0 :                     pointer[i].set_freepointer(NULL);
  168384             :                   }
  168385             :               }
  168386             :         }
  168387           5 :      return globalIndex;
  168388             :    }
  168389             : 
  168390             : //############################################################################
  168391             : // JH (01/14/2006)
  168392             : void
  168393           5 : SgElementwisePowerOp::resetValidFreepointers( )
  168394             :    {
  168395           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  168396           5 :      SgElementwisePowerOp* pointer = NULL;
  168397           5 :      std::vector < unsigned char* > :: const_iterator block;
  168398           5 :      SgElementwisePowerOp* pointerOfLinkedList = NULL;
  168399           5 :      for ( block = SgElementwisePowerOp::pools.begin(); block != SgElementwisePowerOp::pools.end() ; ++block )
  168400             :         {
  168401           0 :           pointer = (SgElementwisePowerOp*)(*block);
  168402           0 :           for (unsigned i = 0; i < SgElementwisePowerOp::pool_size; ++i )
  168403             :              {
  168404             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  168405             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  168406             :             // memory blocks!.
  168407           0 :                if ( pointer[i].get_freepointer() != NULL )
  168408             :                   {
  168409           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  168410             :                   }
  168411             :                else
  168412             :                   {
  168413           0 :                     if ( pointerOfLinkedList == NULL )
  168414             :                        {
  168415           0 :                          SgElementwisePowerOp::next_node = &(pointer[i]);
  168416             :                        }
  168417             :                     else
  168418             :                        {
  168419             :                       // printf ("In SgElementwisePowerOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  168420           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  168421             :                        }
  168422             :                     pointerOfLinkedList = &(pointer[i]);
  168423             :                   }
  168424             :               }
  168425             :         }
  168426             : 
  168427           5 :      if ( pointerOfLinkedList != NULL )
  168428             :         {
  168429             :        // printf ("In SgElementwisePowerOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  168430           0 :           pointerOfLinkedList->set_freepointer(NULL);
  168431             :        // DQ (6/6/2010): Temporary debugging...
  168432             :        //   ROSE_ASSERT(false);
  168433             :         }
  168434             : 
  168435           5 :      return ;
  168436             :    }
  168437             : 
  168438             : //############################################################################
  168439             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  168440             :  * within the memory pool and resets the freepointers, in order to achieve a 
  168441             :  * linked list, that has no jumps and starts at the beginning! This function 
  168442             :  * does not extend the memory pool, since we do not delete any memory blocks,
  168443             :  * but delete the valid objects.  
  168444             :  */
  168445             : void
  168446           0 : SgElementwisePowerOp::clearMemoryPool( )
  168447             :    {
  168448             :   // printf ("Inside of SgElementwisePowerOp::clearMemoryPool() \n");
  168449             : 
  168450           0 :      SgElementwisePowerOp* pointer = NULL, *tempPointer = NULL;
  168451           0 :      std::vector < unsigned char* > :: const_iterator block;
  168452           0 :      if ( SgElementwisePowerOp::pools.empty() == false )
  168453             :         {
  168454           0 :           block = SgElementwisePowerOp::pools.begin() ;
  168455           0 :           SgElementwisePowerOp::next_node = (SgElementwisePowerOp*) (*block);
  168456             : 
  168457           0 :           while ( block != SgElementwisePowerOp::pools.end() )
  168458             :              {
  168459           0 :                pointer = (SgElementwisePowerOp*) (*block);
  168460           0 :                if ( tempPointer != NULL )
  168461             :                   {
  168462           0 :                     tempPointer->set_freepointer(pointer);
  168463             :                   }
  168464           0 :                for (unsigned i = 0; i < SgElementwisePowerOp::pool_size - 1; ++i)
  168465             :                   {
  168466           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  168467             :                   }
  168468           0 :                 pointer[SgElementwisePowerOp::pool_size-1].set_freepointer(NULL);
  168469           0 :                 tempPointer = &(pointer[SgElementwisePowerOp::pool_size-1]);
  168470           0 :                 ++block;
  168471             :              }
  168472             :         }
  168473           0 :    }
  168474             : 
  168475           5 : void SgElementwisePowerOp::deleteMemoryPool() {
  168476           5 :   for (auto p: SgElementwisePowerOp::pools) {
  168477           0 :     ROSE_FREE(p);
  168478             :   }
  168479           5 :   SgElementwisePowerOp::next_node = nullptr;
  168480           5 :   SgElementwisePowerOp::pools.clear();
  168481           5 : }
  168482             : 
  168483             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  168484             : //                 reading multiple binary files to for a single AST.
  168485             : /////////// new version ////////////////////////////////
  168486             : //############################################################################
  168487             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  168488             : void
  168489           2 : SgElementwisePowerOp::extendMemoryPoolForFileIO( )
  168490             :   {
  168491           2 :     size_t blockIndex = SgElementwisePowerOp::pools.size();
  168492           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwisePowerOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwisePowerOp);
  168493             : 
  168494           2 :     while ( (blockIndex * SgElementwisePowerOp::pool_size) < newPoolSize)
  168495             :       {
  168496             : #if ROSE_ALLOC_TRACE
  168497             :         if (blockIndex > 0) {
  168498             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwisePowerOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwisePowerOp) = %" PRIuPTR " SgElementwisePowerOp::pool_size = %d \n",
  168499             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwisePowerOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwisePowerOp),SgElementwisePowerOp::pool_size);
  168500             :         }
  168501             : #endif
  168502             : 
  168503           0 :         SgElementwisePowerOp * pointer = (SgElementwisePowerOp*) ROSE_MALLOC ( SgElementwisePowerOp::pool_size * sizeof(SgElementwisePowerOp) );
  168504           0 :         assert( pointer != NULL );
  168505             : #if ROSE_ALLOC_MEMSET == 1
  168506             :         memset(pointer, 0x00, SgElementwisePowerOp::pool_size * sizeof(SgElementwisePowerOp));
  168507             : #elif ROSE_ALLOC_MEMSET == 2
  168508             :         memset(pointer, 0xCC, SgElementwisePowerOp::pool_size * sizeof(SgElementwisePowerOp));
  168509             : #endif
  168510           0 :         SgElementwisePowerOp::pools.push_back( (unsigned char*)(pointer) );
  168511           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElementwisePowerOp::pool_size * sizeof(SgElementwisePowerOp), V_SgElementwisePowerOp ) );
  168512             : 
  168513           0 :         if ( SgElementwisePowerOp::next_node != NULL ) {
  168514           0 :           if ( blockIndex > 0 ) {
  168515           0 :             SgElementwisePowerOp * blkptr = (SgElementwisePowerOp*)(SgElementwisePowerOp::pools[blockIndex-1]);
  168516           0 :             blkptr[ SgElementwisePowerOp::pool_size - 1 ].set_freepointer(pointer);
  168517             :           }
  168518             :         } else {
  168519           0 :           SgElementwisePowerOp::next_node = pointer;
  168520             :         }
  168521             : 
  168522           0 :         for (unsigned i = 0; i < SgElementwisePowerOp::pool_size-1; ++i)
  168523             :            {
  168524           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  168525             :            }
  168526           0 :         pointer[ SgElementwisePowerOp::pool_size -1 ].set_freepointer(NULL);
  168527             : 
  168528           0 :         blockIndex++;
  168529             :       }
  168530           2 :   }
  168531             : 
  168532             : //############################################################################
  168533             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  168534             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  168535             :  * not compressed. However, that stuff is not yet implemented! 
  168536             :  */
  168537             : unsigned long
  168538           0 : SgElementwisePowerOp::getNumberOfLastValidPointer()
  168539             :    {
  168540           0 :       SgElementwisePowerOp* testPointer = (SgElementwisePowerOp*)(SgElementwisePowerOp::pools.back());
  168541           0 :       unsigned long localIndex = SgElementwisePowerOp::pool_size - 1;
  168542           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  168543             :          {
  168544           0 :            localIndex--;
  168545             :          }
  168546           0 :       return (localIndex + SgElementwisePowerOp::pool_size * (SgElementwisePowerOp::pools.size()-1));
  168547             :    }
  168548             : 
  168549             : //############################################################################
  168550             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  168551             :  * memory pool and initializes the data member in class SgElementwisePowerOpStroageClass
  168552             :  * from its counterpart of SgElementwisePowerOp. The return value is just for checking, 
  168553             :  * that the whole StorageClassArray is initialized!
  168554             :  */
  168555             : unsigned long
  168556           0 : SgElementwisePowerOp::initializeStorageClassArray( SgElementwisePowerOpStorageClass *storageArray )
  168557             :    {
  168558           0 :      unsigned long storageCounter = 0;
  168559           0 :      std::vector < unsigned char* > :: const_iterator block = SgElementwisePowerOp::pools.begin();
  168560           0 :      SgElementwisePowerOp* pointer = NULL;
  168561           0 :      while ( block != SgElementwisePowerOp::pools.end() ) {
  168562           0 :           pointer = (SgElementwisePowerOp*) (*block);
  168563           0 :           for ( unsigned i = 0; i < SgElementwisePowerOp::pool_size; ++i ) {
  168564           0 :                if ( pointer->get_freepointer() != NULL ) {
  168565           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  168566           0 :                  storageArray++;
  168567           0 :                  storageCounter++;
  168568             :                }
  168569           0 :                pointer++;
  168570             :              }
  168571           0 :            block++;
  168572             :         }
  168573           0 :      return storageCounter;
  168574             :    }
  168575             : 
  168576             : /* #line 168577 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  168577             : 
  168578             : 
  168579             : 
  168580             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  168581             : 
  168582             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  168583             : 
  168584             : //############################################################################
  168585             : /* JH (02/02/2006) Constructor of the IR node SgElementwiseLeftDivideOp that takes its 
  168586             :  * corresponding StorageClass as parameter
  168587             :  */
  168588           0 : SgElementwiseLeftDivideOp :: SgElementwiseLeftDivideOp ( const SgElementwiseLeftDivideOpStorageClass& storageSource )   : SgElementwiseOp (storageSource)
  168589             :    {
  168590             : 
  168591             : 
  168592             : /* #line 168593 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  168593             : 
  168594           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  168595             : 
  168596             : 
  168597             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  168598             : 
  168599             : 
  168600           0 :    }
  168601             : 
  168602             : //############################################################################
  168603             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  168604             :  * within the working AST. 
  168605             :  */
  168606           0 : SgElementwiseLeftDivideOp * SgElementwiseLeftDivideOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  168607           0 :      SgElementwiseLeftDivideOp* returnPointer = NULL;
  168608           0 :      if ( globalIndex != 0 )
  168609             :         {
  168610             : 
  168611             : #if FILE_IO_EXTRA_CHECK
  168612           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElementwiseLeftDivideOp ) ) <= globalIndex ) ;
  168613           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseLeftDivideOp + 1 ) ) );
  168614             : #endif
  168615           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseLeftDivideOp )  
  168616           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElementwiseLeftDivideOp );
  168617           0 :           unsigned long positionInPool = localIndex % SgElementwiseLeftDivideOp::pool_size;
  168618           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseLeftDivideOp::pool_size;
  168619             : 
  168620             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  168621             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  168622             : 
  168623           0 :           returnPointer = &( ( (SgElementwiseLeftDivideOp*)(SgElementwiseLeftDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  168624             : 
  168625           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  168626             :         }
  168627           0 :      return returnPointer ;
  168628             :    }
  168629             : 
  168630             : //############################################################################
  168631             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  168632             :   for the AST with the index astIndex
  168633             : */
  168634           0 : SgElementwiseLeftDivideOp * SgElementwiseLeftDivideOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  168635           0 :      SgElementwiseLeftDivideOp* returnPointer = NULL;
  168636           0 :      if ( globalIndex != 0 )
  168637             :         {
  168638             : 
  168639             : #if FILE_IO_EXTRA_CHECK
  168640           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElementwiseLeftDivideOp ) ) <= globalIndex ) ;
  168641           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseLeftDivideOp + 1 ) ) );
  168642             : #endif
  168643           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseLeftDivideOp )
  168644           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElementwiseLeftDivideOp );
  168645           0 :           unsigned long positionInPool = localIndex % SgElementwiseLeftDivideOp::pool_size ;
  168646           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseLeftDivideOp::pool_size ;
  168647             : 
  168648             : #if FILE_IO_EXTRA_CHECK
  168649             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  168650             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  168651             : #endif
  168652             : 
  168653           0 :           returnPointer = &( ( (SgElementwiseLeftDivideOp*)(SgElementwiseLeftDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  168654             : 
  168655             : #if FILE_IO_EXTRA_CHECK
  168656           0 :           assert ( returnPointer != NULL ) ;
  168657             : #endif
  168658             :         }
  168659           0 :      return returnPointer ;
  168660             :    }
  168661             : 
  168662             : //############################################################################
  168663             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  168664             :  * pool size! We set for every valid object in the memory pool the freepointer
  168665             :  * to the global index and increase the global index afterwards. For all the 
  168666             :  * invalid objects (means address ranges within the memory pool that were not
  168667             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  168668             :  * distinguish valid from invalid objects! 
  168669             :  */
  168670             : unsigned long
  168671           5 : SgElementwiseLeftDivideOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  168672             :    {
  168673           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  168674           5 :      SgElementwiseLeftDivideOp* pointer = NULL;
  168675           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  168676           5 :      std::vector < unsigned char* > :: const_iterator block;
  168677           5 :      for ( block = SgElementwiseLeftDivideOp::pools.begin(); block != SgElementwiseLeftDivideOp::pools.end() ; ++block )
  168678             :         {
  168679           0 :           pointer = (SgElementwiseLeftDivideOp*)(*block);
  168680           0 :           for (unsigned i = 0; i < SgElementwiseLeftDivideOp::pool_size; ++i )
  168681             :              {
  168682             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  168683             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  168684             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  168685             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  168686             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  168687             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  168688             :             // properly; so this will have to be checked next.
  168689             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  168690             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  168691           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  168692             :                   {
  168693           0 :                     pointer[i].set_freepointer((SgElementwiseLeftDivideOp*)(globalIndex));
  168694           0 :                     globalIndex++;
  168695             :                   }
  168696             :                else
  168697             :                   {
  168698           0 :                     pointer[i].set_freepointer(NULL);
  168699             :                   }
  168700             :               }
  168701             :         }
  168702           5 :      return globalIndex;
  168703             :    }
  168704             : 
  168705             : //############################################################################
  168706             : // JH (01/14/2006)
  168707             : void
  168708           5 : SgElementwiseLeftDivideOp::resetValidFreepointers( )
  168709             :    {
  168710           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  168711           5 :      SgElementwiseLeftDivideOp* pointer = NULL;
  168712           5 :      std::vector < unsigned char* > :: const_iterator block;
  168713           5 :      SgElementwiseLeftDivideOp* pointerOfLinkedList = NULL;
  168714           5 :      for ( block = SgElementwiseLeftDivideOp::pools.begin(); block != SgElementwiseLeftDivideOp::pools.end() ; ++block )
  168715             :         {
  168716           0 :           pointer = (SgElementwiseLeftDivideOp*)(*block);
  168717           0 :           for (unsigned i = 0; i < SgElementwiseLeftDivideOp::pool_size; ++i )
  168718             :              {
  168719             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  168720             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  168721             :             // memory blocks!.
  168722           0 :                if ( pointer[i].get_freepointer() != NULL )
  168723             :                   {
  168724           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  168725             :                   }
  168726             :                else
  168727             :                   {
  168728           0 :                     if ( pointerOfLinkedList == NULL )
  168729             :                        {
  168730           0 :                          SgElementwiseLeftDivideOp::next_node = &(pointer[i]);
  168731             :                        }
  168732             :                     else
  168733             :                        {
  168734             :                       // printf ("In SgElementwiseLeftDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  168735           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  168736             :                        }
  168737             :                     pointerOfLinkedList = &(pointer[i]);
  168738             :                   }
  168739             :               }
  168740             :         }
  168741             : 
  168742           5 :      if ( pointerOfLinkedList != NULL )
  168743             :         {
  168744             :        // printf ("In SgElementwiseLeftDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  168745           0 :           pointerOfLinkedList->set_freepointer(NULL);
  168746             :        // DQ (6/6/2010): Temporary debugging...
  168747             :        //   ROSE_ASSERT(false);
  168748             :         }
  168749             : 
  168750           5 :      return ;
  168751             :    }
  168752             : 
  168753             : //############################################################################
  168754             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  168755             :  * within the memory pool and resets the freepointers, in order to achieve a 
  168756             :  * linked list, that has no jumps and starts at the beginning! This function 
  168757             :  * does not extend the memory pool, since we do not delete any memory blocks,
  168758             :  * but delete the valid objects.  
  168759             :  */
  168760             : void
  168761           0 : SgElementwiseLeftDivideOp::clearMemoryPool( )
  168762             :    {
  168763             :   // printf ("Inside of SgElementwiseLeftDivideOp::clearMemoryPool() \n");
  168764             : 
  168765           0 :      SgElementwiseLeftDivideOp* pointer = NULL, *tempPointer = NULL;
  168766           0 :      std::vector < unsigned char* > :: const_iterator block;
  168767           0 :      if ( SgElementwiseLeftDivideOp::pools.empty() == false )
  168768             :         {
  168769           0 :           block = SgElementwiseLeftDivideOp::pools.begin() ;
  168770           0 :           SgElementwiseLeftDivideOp::next_node = (SgElementwiseLeftDivideOp*) (*block);
  168771             : 
  168772           0 :           while ( block != SgElementwiseLeftDivideOp::pools.end() )
  168773             :              {
  168774           0 :                pointer = (SgElementwiseLeftDivideOp*) (*block);
  168775           0 :                if ( tempPointer != NULL )
  168776             :                   {
  168777           0 :                     tempPointer->set_freepointer(pointer);
  168778             :                   }
  168779           0 :                for (unsigned i = 0; i < SgElementwiseLeftDivideOp::pool_size - 1; ++i)
  168780             :                   {
  168781           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  168782             :                   }
  168783           0 :                 pointer[SgElementwiseLeftDivideOp::pool_size-1].set_freepointer(NULL);
  168784           0 :                 tempPointer = &(pointer[SgElementwiseLeftDivideOp::pool_size-1]);
  168785           0 :                 ++block;
  168786             :              }
  168787             :         }
  168788           0 :    }
  168789             : 
  168790           5 : void SgElementwiseLeftDivideOp::deleteMemoryPool() {
  168791           5 :   for (auto p: SgElementwiseLeftDivideOp::pools) {
  168792           0 :     ROSE_FREE(p);
  168793             :   }
  168794           5 :   SgElementwiseLeftDivideOp::next_node = nullptr;
  168795           5 :   SgElementwiseLeftDivideOp::pools.clear();
  168796           5 : }
  168797             : 
  168798             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  168799             : //                 reading multiple binary files to for a single AST.
  168800             : /////////// new version ////////////////////////////////
  168801             : //############################################################################
  168802             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  168803             : void
  168804           2 : SgElementwiseLeftDivideOp::extendMemoryPoolForFileIO( )
  168805             :   {
  168806           2 :     size_t blockIndex = SgElementwiseLeftDivideOp::pools.size();
  168807           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseLeftDivideOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseLeftDivideOp);
  168808             : 
  168809           2 :     while ( (blockIndex * SgElementwiseLeftDivideOp::pool_size) < newPoolSize)
  168810             :       {
  168811             : #if ROSE_ALLOC_TRACE
  168812             :         if (blockIndex > 0) {
  168813             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseLeftDivideOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseLeftDivideOp) = %" PRIuPTR " SgElementwiseLeftDivideOp::pool_size = %d \n",
  168814             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseLeftDivideOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseLeftDivideOp),SgElementwiseLeftDivideOp::pool_size);
  168815             :         }
  168816             : #endif
  168817             : 
  168818           0 :         SgElementwiseLeftDivideOp * pointer = (SgElementwiseLeftDivideOp*) ROSE_MALLOC ( SgElementwiseLeftDivideOp::pool_size * sizeof(SgElementwiseLeftDivideOp) );
  168819           0 :         assert( pointer != NULL );
  168820             : #if ROSE_ALLOC_MEMSET == 1
  168821             :         memset(pointer, 0x00, SgElementwiseLeftDivideOp::pool_size * sizeof(SgElementwiseLeftDivideOp));
  168822             : #elif ROSE_ALLOC_MEMSET == 2
  168823             :         memset(pointer, 0xCC, SgElementwiseLeftDivideOp::pool_size * sizeof(SgElementwiseLeftDivideOp));
  168824             : #endif
  168825           0 :         SgElementwiseLeftDivideOp::pools.push_back( (unsigned char*)(pointer) );
  168826           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElementwiseLeftDivideOp::pool_size * sizeof(SgElementwiseLeftDivideOp), V_SgElementwiseLeftDivideOp ) );
  168827             : 
  168828           0 :         if ( SgElementwiseLeftDivideOp::next_node != NULL ) {
  168829           0 :           if ( blockIndex > 0 ) {
  168830           0 :             SgElementwiseLeftDivideOp * blkptr = (SgElementwiseLeftDivideOp*)(SgElementwiseLeftDivideOp::pools[blockIndex-1]);
  168831           0 :             blkptr[ SgElementwiseLeftDivideOp::pool_size - 1 ].set_freepointer(pointer);
  168832             :           }
  168833             :         } else {
  168834           0 :           SgElementwiseLeftDivideOp::next_node = pointer;
  168835             :         }
  168836             : 
  168837           0 :         for (unsigned i = 0; i < SgElementwiseLeftDivideOp::pool_size-1; ++i)
  168838             :            {
  168839           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  168840             :            }
  168841           0 :         pointer[ SgElementwiseLeftDivideOp::pool_size -1 ].set_freepointer(NULL);
  168842             : 
  168843           0 :         blockIndex++;
  168844             :       }
  168845           2 :   }
  168846             : 
  168847             : //############################################################################
  168848             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  168849             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  168850             :  * not compressed. However, that stuff is not yet implemented! 
  168851             :  */
  168852             : unsigned long
  168853           0 : SgElementwiseLeftDivideOp::getNumberOfLastValidPointer()
  168854             :    {
  168855           0 :       SgElementwiseLeftDivideOp* testPointer = (SgElementwiseLeftDivideOp*)(SgElementwiseLeftDivideOp::pools.back());
  168856           0 :       unsigned long localIndex = SgElementwiseLeftDivideOp::pool_size - 1;
  168857           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  168858             :          {
  168859           0 :            localIndex--;
  168860             :          }
  168861           0 :       return (localIndex + SgElementwiseLeftDivideOp::pool_size * (SgElementwiseLeftDivideOp::pools.size()-1));
  168862             :    }
  168863             : 
  168864             : //############################################################################
  168865             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  168866             :  * memory pool and initializes the data member in class SgElementwiseLeftDivideOpStroageClass
  168867             :  * from its counterpart of SgElementwiseLeftDivideOp. The return value is just for checking, 
  168868             :  * that the whole StorageClassArray is initialized!
  168869             :  */
  168870             : unsigned long
  168871           0 : SgElementwiseLeftDivideOp::initializeStorageClassArray( SgElementwiseLeftDivideOpStorageClass *storageArray )
  168872             :    {
  168873           0 :      unsigned long storageCounter = 0;
  168874           0 :      std::vector < unsigned char* > :: const_iterator block = SgElementwiseLeftDivideOp::pools.begin();
  168875           0 :      SgElementwiseLeftDivideOp* pointer = NULL;
  168876           0 :      while ( block != SgElementwiseLeftDivideOp::pools.end() ) {
  168877           0 :           pointer = (SgElementwiseLeftDivideOp*) (*block);
  168878           0 :           for ( unsigned i = 0; i < SgElementwiseLeftDivideOp::pool_size; ++i ) {
  168879           0 :                if ( pointer->get_freepointer() != NULL ) {
  168880           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  168881           0 :                  storageArray++;
  168882           0 :                  storageCounter++;
  168883             :                }
  168884           0 :                pointer++;
  168885             :              }
  168886           0 :            block++;
  168887             :         }
  168888           0 :      return storageCounter;
  168889             :    }
  168890             : 
  168891             : /* #line 168892 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  168892             : 
  168893             : 
  168894             : 
  168895             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  168896             : 
  168897             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  168898             : 
  168899             : //############################################################################
  168900             : /* JH (02/02/2006) Constructor of the IR node SgElementwiseDivideOp that takes its 
  168901             :  * corresponding StorageClass as parameter
  168902             :  */
  168903           0 : SgElementwiseDivideOp :: SgElementwiseDivideOp ( const SgElementwiseDivideOpStorageClass& storageSource )   : SgElementwiseOp (storageSource)
  168904             :    {
  168905             : 
  168906             : 
  168907             : /* #line 168908 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  168908             : 
  168909           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  168910             : 
  168911             : 
  168912             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  168913             : 
  168914             : 
  168915           0 :    }
  168916             : 
  168917             : //############################################################################
  168918             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  168919             :  * within the working AST. 
  168920             :  */
  168921           0 : SgElementwiseDivideOp * SgElementwiseDivideOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  168922           0 :      SgElementwiseDivideOp* returnPointer = NULL;
  168923           0 :      if ( globalIndex != 0 )
  168924             :         {
  168925             : 
  168926             : #if FILE_IO_EXTRA_CHECK
  168927           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElementwiseDivideOp ) ) <= globalIndex ) ;
  168928           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseDivideOp + 1 ) ) );
  168929             : #endif
  168930           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseDivideOp )  
  168931           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElementwiseDivideOp );
  168932           0 :           unsigned long positionInPool = localIndex % SgElementwiseDivideOp::pool_size;
  168933           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseDivideOp::pool_size;
  168934             : 
  168935             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  168936             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  168937             : 
  168938           0 :           returnPointer = &( ( (SgElementwiseDivideOp*)(SgElementwiseDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  168939             : 
  168940           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  168941             :         }
  168942           0 :      return returnPointer ;
  168943             :    }
  168944             : 
  168945             : //############################################################################
  168946             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  168947             :   for the AST with the index astIndex
  168948             : */
  168949           0 : SgElementwiseDivideOp * SgElementwiseDivideOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  168950           0 :      SgElementwiseDivideOp* returnPointer = NULL;
  168951           0 :      if ( globalIndex != 0 )
  168952             :         {
  168953             : 
  168954             : #if FILE_IO_EXTRA_CHECK
  168955           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElementwiseDivideOp ) ) <= globalIndex ) ;
  168956           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseDivideOp + 1 ) ) );
  168957             : #endif
  168958           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseDivideOp )
  168959           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElementwiseDivideOp );
  168960           0 :           unsigned long positionInPool = localIndex % SgElementwiseDivideOp::pool_size ;
  168961           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseDivideOp::pool_size ;
  168962             : 
  168963             : #if FILE_IO_EXTRA_CHECK
  168964             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  168965             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  168966             : #endif
  168967             : 
  168968           0 :           returnPointer = &( ( (SgElementwiseDivideOp*)(SgElementwiseDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  168969             : 
  168970             : #if FILE_IO_EXTRA_CHECK
  168971           0 :           assert ( returnPointer != NULL ) ;
  168972             : #endif
  168973             :         }
  168974           0 :      return returnPointer ;
  168975             :    }
  168976             : 
  168977             : //############################################################################
  168978             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  168979             :  * pool size! We set for every valid object in the memory pool the freepointer
  168980             :  * to the global index and increase the global index afterwards. For all the 
  168981             :  * invalid objects (means address ranges within the memory pool that were not
  168982             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  168983             :  * distinguish valid from invalid objects! 
  168984             :  */
  168985             : unsigned long
  168986           5 : SgElementwiseDivideOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  168987             :    {
  168988           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  168989           5 :      SgElementwiseDivideOp* pointer = NULL;
  168990           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  168991           5 :      std::vector < unsigned char* > :: const_iterator block;
  168992           5 :      for ( block = SgElementwiseDivideOp::pools.begin(); block != SgElementwiseDivideOp::pools.end() ; ++block )
  168993             :         {
  168994           0 :           pointer = (SgElementwiseDivideOp*)(*block);
  168995           0 :           for (unsigned i = 0; i < SgElementwiseDivideOp::pool_size; ++i )
  168996             :              {
  168997             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  168998             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  168999             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  169000             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  169001             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  169002             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  169003             :             // properly; so this will have to be checked next.
  169004             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  169005             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  169006           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  169007             :                   {
  169008           0 :                     pointer[i].set_freepointer((SgElementwiseDivideOp*)(globalIndex));
  169009           0 :                     globalIndex++;
  169010             :                   }
  169011             :                else
  169012             :                   {
  169013           0 :                     pointer[i].set_freepointer(NULL);
  169014             :                   }
  169015             :               }
  169016             :         }
  169017           5 :      return globalIndex;
  169018             :    }
  169019             : 
  169020             : //############################################################################
  169021             : // JH (01/14/2006)
  169022             : void
  169023           5 : SgElementwiseDivideOp::resetValidFreepointers( )
  169024             :    {
  169025           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  169026           5 :      SgElementwiseDivideOp* pointer = NULL;
  169027           5 :      std::vector < unsigned char* > :: const_iterator block;
  169028           5 :      SgElementwiseDivideOp* pointerOfLinkedList = NULL;
  169029           5 :      for ( block = SgElementwiseDivideOp::pools.begin(); block != SgElementwiseDivideOp::pools.end() ; ++block )
  169030             :         {
  169031           0 :           pointer = (SgElementwiseDivideOp*)(*block);
  169032           0 :           for (unsigned i = 0; i < SgElementwiseDivideOp::pool_size; ++i )
  169033             :              {
  169034             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  169035             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  169036             :             // memory blocks!.
  169037           0 :                if ( pointer[i].get_freepointer() != NULL )
  169038             :                   {
  169039           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  169040             :                   }
  169041             :                else
  169042             :                   {
  169043           0 :                     if ( pointerOfLinkedList == NULL )
  169044             :                        {
  169045           0 :                          SgElementwiseDivideOp::next_node = &(pointer[i]);
  169046             :                        }
  169047             :                     else
  169048             :                        {
  169049             :                       // printf ("In SgElementwiseDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  169050           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  169051             :                        }
  169052             :                     pointerOfLinkedList = &(pointer[i]);
  169053             :                   }
  169054             :               }
  169055             :         }
  169056             : 
  169057           5 :      if ( pointerOfLinkedList != NULL )
  169058             :         {
  169059             :        // printf ("In SgElementwiseDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  169060           0 :           pointerOfLinkedList->set_freepointer(NULL);
  169061             :        // DQ (6/6/2010): Temporary debugging...
  169062             :        //   ROSE_ASSERT(false);
  169063             :         }
  169064             : 
  169065           5 :      return ;
  169066             :    }
  169067             : 
  169068             : //############################################################################
  169069             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  169070             :  * within the memory pool and resets the freepointers, in order to achieve a 
  169071             :  * linked list, that has no jumps and starts at the beginning! This function 
  169072             :  * does not extend the memory pool, since we do not delete any memory blocks,
  169073             :  * but delete the valid objects.  
  169074             :  */
  169075             : void
  169076           0 : SgElementwiseDivideOp::clearMemoryPool( )
  169077             :    {
  169078             :   // printf ("Inside of SgElementwiseDivideOp::clearMemoryPool() \n");
  169079             : 
  169080           0 :      SgElementwiseDivideOp* pointer = NULL, *tempPointer = NULL;
  169081           0 :      std::vector < unsigned char* > :: const_iterator block;
  169082           0 :      if ( SgElementwiseDivideOp::pools.empty() == false )
  169083             :         {
  169084           0 :           block = SgElementwiseDivideOp::pools.begin() ;
  169085           0 :           SgElementwiseDivideOp::next_node = (SgElementwiseDivideOp*) (*block);
  169086             : 
  169087           0 :           while ( block != SgElementwiseDivideOp::pools.end() )
  169088             :              {
  169089           0 :                pointer = (SgElementwiseDivideOp*) (*block);
  169090           0 :                if ( tempPointer != NULL )
  169091             :                   {
  169092           0 :                     tempPointer->set_freepointer(pointer);
  169093             :                   }
  169094           0 :                for (unsigned i = 0; i < SgElementwiseDivideOp::pool_size - 1; ++i)
  169095             :                   {
  169096           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  169097             :                   }
  169098           0 :                 pointer[SgElementwiseDivideOp::pool_size-1].set_freepointer(NULL);
  169099           0 :                 tempPointer = &(pointer[SgElementwiseDivideOp::pool_size-1]);
  169100           0 :                 ++block;
  169101             :              }
  169102             :         }
  169103           0 :    }
  169104             : 
  169105           5 : void SgElementwiseDivideOp::deleteMemoryPool() {
  169106           5 :   for (auto p: SgElementwiseDivideOp::pools) {
  169107           0 :     ROSE_FREE(p);
  169108             :   }
  169109           5 :   SgElementwiseDivideOp::next_node = nullptr;
  169110           5 :   SgElementwiseDivideOp::pools.clear();
  169111           5 : }
  169112             : 
  169113             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  169114             : //                 reading multiple binary files to for a single AST.
  169115             : /////////// new version ////////////////////////////////
  169116             : //############################################################################
  169117             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  169118             : void
  169119           2 : SgElementwiseDivideOp::extendMemoryPoolForFileIO( )
  169120             :   {
  169121           2 :     size_t blockIndex = SgElementwiseDivideOp::pools.size();
  169122           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseDivideOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseDivideOp);
  169123             : 
  169124           2 :     while ( (blockIndex * SgElementwiseDivideOp::pool_size) < newPoolSize)
  169125             :       {
  169126             : #if ROSE_ALLOC_TRACE
  169127             :         if (blockIndex > 0) {
  169128             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseDivideOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseDivideOp) = %" PRIuPTR " SgElementwiseDivideOp::pool_size = %d \n",
  169129             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseDivideOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseDivideOp),SgElementwiseDivideOp::pool_size);
  169130             :         }
  169131             : #endif
  169132             : 
  169133           0 :         SgElementwiseDivideOp * pointer = (SgElementwiseDivideOp*) ROSE_MALLOC ( SgElementwiseDivideOp::pool_size * sizeof(SgElementwiseDivideOp) );
  169134           0 :         assert( pointer != NULL );
  169135             : #if ROSE_ALLOC_MEMSET == 1
  169136             :         memset(pointer, 0x00, SgElementwiseDivideOp::pool_size * sizeof(SgElementwiseDivideOp));
  169137             : #elif ROSE_ALLOC_MEMSET == 2
  169138             :         memset(pointer, 0xCC, SgElementwiseDivideOp::pool_size * sizeof(SgElementwiseDivideOp));
  169139             : #endif
  169140           0 :         SgElementwiseDivideOp::pools.push_back( (unsigned char*)(pointer) );
  169141           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElementwiseDivideOp::pool_size * sizeof(SgElementwiseDivideOp), V_SgElementwiseDivideOp ) );
  169142             : 
  169143           0 :         if ( SgElementwiseDivideOp::next_node != NULL ) {
  169144           0 :           if ( blockIndex > 0 ) {
  169145           0 :             SgElementwiseDivideOp * blkptr = (SgElementwiseDivideOp*)(SgElementwiseDivideOp::pools[blockIndex-1]);
  169146           0 :             blkptr[ SgElementwiseDivideOp::pool_size - 1 ].set_freepointer(pointer);
  169147             :           }
  169148             :         } else {
  169149           0 :           SgElementwiseDivideOp::next_node = pointer;
  169150             :         }
  169151             : 
  169152           0 :         for (unsigned i = 0; i < SgElementwiseDivideOp::pool_size-1; ++i)
  169153             :            {
  169154           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  169155             :            }
  169156           0 :         pointer[ SgElementwiseDivideOp::pool_size -1 ].set_freepointer(NULL);
  169157             : 
  169158           0 :         blockIndex++;
  169159             :       }
  169160           2 :   }
  169161             : 
  169162             : //############################################################################
  169163             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  169164             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  169165             :  * not compressed. However, that stuff is not yet implemented! 
  169166             :  */
  169167             : unsigned long
  169168           0 : SgElementwiseDivideOp::getNumberOfLastValidPointer()
  169169             :    {
  169170           0 :       SgElementwiseDivideOp* testPointer = (SgElementwiseDivideOp*)(SgElementwiseDivideOp::pools.back());
  169171           0 :       unsigned long localIndex = SgElementwiseDivideOp::pool_size - 1;
  169172           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  169173             :          {
  169174           0 :            localIndex--;
  169175             :          }
  169176           0 :       return (localIndex + SgElementwiseDivideOp::pool_size * (SgElementwiseDivideOp::pools.size()-1));
  169177             :    }
  169178             : 
  169179             : //############################################################################
  169180             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  169181             :  * memory pool and initializes the data member in class SgElementwiseDivideOpStroageClass
  169182             :  * from its counterpart of SgElementwiseDivideOp. The return value is just for checking, 
  169183             :  * that the whole StorageClassArray is initialized!
  169184             :  */
  169185             : unsigned long
  169186           0 : SgElementwiseDivideOp::initializeStorageClassArray( SgElementwiseDivideOpStorageClass *storageArray )
  169187             :    {
  169188           0 :      unsigned long storageCounter = 0;
  169189           0 :      std::vector < unsigned char* > :: const_iterator block = SgElementwiseDivideOp::pools.begin();
  169190           0 :      SgElementwiseDivideOp* pointer = NULL;
  169191           0 :      while ( block != SgElementwiseDivideOp::pools.end() ) {
  169192           0 :           pointer = (SgElementwiseDivideOp*) (*block);
  169193           0 :           for ( unsigned i = 0; i < SgElementwiseDivideOp::pool_size; ++i ) {
  169194           0 :                if ( pointer->get_freepointer() != NULL ) {
  169195           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  169196           0 :                  storageArray++;
  169197           0 :                  storageCounter++;
  169198             :                }
  169199           0 :                pointer++;
  169200             :              }
  169201           0 :            block++;
  169202             :         }
  169203           0 :      return storageCounter;
  169204             :    }
  169205             : 
  169206             : /* #line 169207 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  169207             : 
  169208             : 
  169209             : 
  169210             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  169211             : 
  169212             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  169213             : 
  169214             : //############################################################################
  169215             : /* JH (02/02/2006) Constructor of the IR node SgElementwiseAddOp that takes its 
  169216             :  * corresponding StorageClass as parameter
  169217             :  */
  169218           0 : SgElementwiseAddOp :: SgElementwiseAddOp ( const SgElementwiseAddOpStorageClass& storageSource )   : SgElementwiseOp (storageSource)
  169219             :    {
  169220             : 
  169221             : 
  169222             : /* #line 169223 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  169223             : 
  169224           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  169225             : 
  169226             : 
  169227             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  169228             : 
  169229             : 
  169230           0 :    }
  169231             : 
  169232             : //############################################################################
  169233             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  169234             :  * within the working AST. 
  169235             :  */
  169236           0 : SgElementwiseAddOp * SgElementwiseAddOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  169237           0 :      SgElementwiseAddOp* returnPointer = NULL;
  169238           0 :      if ( globalIndex != 0 )
  169239             :         {
  169240             : 
  169241             : #if FILE_IO_EXTRA_CHECK
  169242           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElementwiseAddOp ) ) <= globalIndex ) ;
  169243           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseAddOp + 1 ) ) );
  169244             : #endif
  169245           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseAddOp )  
  169246           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElementwiseAddOp );
  169247           0 :           unsigned long positionInPool = localIndex % SgElementwiseAddOp::pool_size;
  169248           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseAddOp::pool_size;
  169249             : 
  169250             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  169251             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  169252             : 
  169253           0 :           returnPointer = &( ( (SgElementwiseAddOp*)(SgElementwiseAddOp::pools[memoryBlock]) ) [positionInPool]) ;
  169254             : 
  169255           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  169256             :         }
  169257           0 :      return returnPointer ;
  169258             :    }
  169259             : 
  169260             : //############################################################################
  169261             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  169262             :   for the AST with the index astIndex
  169263             : */
  169264           0 : SgElementwiseAddOp * SgElementwiseAddOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  169265           0 :      SgElementwiseAddOp* returnPointer = NULL;
  169266           0 :      if ( globalIndex != 0 )
  169267             :         {
  169268             : 
  169269             : #if FILE_IO_EXTRA_CHECK
  169270           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElementwiseAddOp ) ) <= globalIndex ) ;
  169271           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseAddOp + 1 ) ) );
  169272             : #endif
  169273           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseAddOp )
  169274           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElementwiseAddOp );
  169275           0 :           unsigned long positionInPool = localIndex % SgElementwiseAddOp::pool_size ;
  169276           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseAddOp::pool_size ;
  169277             : 
  169278             : #if FILE_IO_EXTRA_CHECK
  169279             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  169280             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  169281             : #endif
  169282             : 
  169283           0 :           returnPointer = &( ( (SgElementwiseAddOp*)(SgElementwiseAddOp::pools[memoryBlock]) ) [positionInPool]) ;
  169284             : 
  169285             : #if FILE_IO_EXTRA_CHECK
  169286           0 :           assert ( returnPointer != NULL ) ;
  169287             : #endif
  169288             :         }
  169289           0 :      return returnPointer ;
  169290             :    }
  169291             : 
  169292             : //############################################################################
  169293             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  169294             :  * pool size! We set for every valid object in the memory pool the freepointer
  169295             :  * to the global index and increase the global index afterwards. For all the 
  169296             :  * invalid objects (means address ranges within the memory pool that were not
  169297             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  169298             :  * distinguish valid from invalid objects! 
  169299             :  */
  169300             : unsigned long
  169301           5 : SgElementwiseAddOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  169302             :    {
  169303           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  169304           5 :      SgElementwiseAddOp* pointer = NULL;
  169305           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  169306           5 :      std::vector < unsigned char* > :: const_iterator block;
  169307           5 :      for ( block = SgElementwiseAddOp::pools.begin(); block != SgElementwiseAddOp::pools.end() ; ++block )
  169308             :         {
  169309           0 :           pointer = (SgElementwiseAddOp*)(*block);
  169310           0 :           for (unsigned i = 0; i < SgElementwiseAddOp::pool_size; ++i )
  169311             :              {
  169312             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  169313             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  169314             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  169315             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  169316             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  169317             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  169318             :             // properly; so this will have to be checked next.
  169319             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  169320             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  169321           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  169322             :                   {
  169323           0 :                     pointer[i].set_freepointer((SgElementwiseAddOp*)(globalIndex));
  169324           0 :                     globalIndex++;
  169325             :                   }
  169326             :                else
  169327             :                   {
  169328           0 :                     pointer[i].set_freepointer(NULL);
  169329             :                   }
  169330             :               }
  169331             :         }
  169332           5 :      return globalIndex;
  169333             :    }
  169334             : 
  169335             : //############################################################################
  169336             : // JH (01/14/2006)
  169337             : void
  169338           5 : SgElementwiseAddOp::resetValidFreepointers( )
  169339             :    {
  169340           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  169341           5 :      SgElementwiseAddOp* pointer = NULL;
  169342           5 :      std::vector < unsigned char* > :: const_iterator block;
  169343           5 :      SgElementwiseAddOp* pointerOfLinkedList = NULL;
  169344           5 :      for ( block = SgElementwiseAddOp::pools.begin(); block != SgElementwiseAddOp::pools.end() ; ++block )
  169345             :         {
  169346           0 :           pointer = (SgElementwiseAddOp*)(*block);
  169347           0 :           for (unsigned i = 0; i < SgElementwiseAddOp::pool_size; ++i )
  169348             :              {
  169349             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  169350             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  169351             :             // memory blocks!.
  169352           0 :                if ( pointer[i].get_freepointer() != NULL )
  169353             :                   {
  169354           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  169355             :                   }
  169356             :                else
  169357             :                   {
  169358           0 :                     if ( pointerOfLinkedList == NULL )
  169359             :                        {
  169360           0 :                          SgElementwiseAddOp::next_node = &(pointer[i]);
  169361             :                        }
  169362             :                     else
  169363             :                        {
  169364             :                       // printf ("In SgElementwiseAddOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  169365           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  169366             :                        }
  169367             :                     pointerOfLinkedList = &(pointer[i]);
  169368             :                   }
  169369             :               }
  169370             :         }
  169371             : 
  169372           5 :      if ( pointerOfLinkedList != NULL )
  169373             :         {
  169374             :        // printf ("In SgElementwiseAddOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  169375           0 :           pointerOfLinkedList->set_freepointer(NULL);
  169376             :        // DQ (6/6/2010): Temporary debugging...
  169377             :        //   ROSE_ASSERT(false);
  169378             :         }
  169379             : 
  169380           5 :      return ;
  169381             :    }
  169382             : 
  169383             : //############################################################################
  169384             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  169385             :  * within the memory pool and resets the freepointers, in order to achieve a 
  169386             :  * linked list, that has no jumps and starts at the beginning! This function 
  169387             :  * does not extend the memory pool, since we do not delete any memory blocks,
  169388             :  * but delete the valid objects.  
  169389             :  */
  169390             : void
  169391           0 : SgElementwiseAddOp::clearMemoryPool( )
  169392             :    {
  169393             :   // printf ("Inside of SgElementwiseAddOp::clearMemoryPool() \n");
  169394             : 
  169395           0 :      SgElementwiseAddOp* pointer = NULL, *tempPointer = NULL;
  169396           0 :      std::vector < unsigned char* > :: const_iterator block;
  169397           0 :      if ( SgElementwiseAddOp::pools.empty() == false )
  169398             :         {
  169399           0 :           block = SgElementwiseAddOp::pools.begin() ;
  169400           0 :           SgElementwiseAddOp::next_node = (SgElementwiseAddOp*) (*block);
  169401             : 
  169402           0 :           while ( block != SgElementwiseAddOp::pools.end() )
  169403             :              {
  169404           0 :                pointer = (SgElementwiseAddOp*) (*block);
  169405           0 :                if ( tempPointer != NULL )
  169406             :                   {
  169407           0 :                     tempPointer->set_freepointer(pointer);
  169408             :                   }
  169409           0 :                for (unsigned i = 0; i < SgElementwiseAddOp::pool_size - 1; ++i)
  169410             :                   {
  169411           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  169412             :                   }
  169413           0 :                 pointer[SgElementwiseAddOp::pool_size-1].set_freepointer(NULL);
  169414           0 :                 tempPointer = &(pointer[SgElementwiseAddOp::pool_size-1]);
  169415           0 :                 ++block;
  169416             :              }
  169417             :         }
  169418           0 :    }
  169419             : 
  169420           5 : void SgElementwiseAddOp::deleteMemoryPool() {
  169421           5 :   for (auto p: SgElementwiseAddOp::pools) {
  169422           0 :     ROSE_FREE(p);
  169423             :   }
  169424           5 :   SgElementwiseAddOp::next_node = nullptr;
  169425           5 :   SgElementwiseAddOp::pools.clear();
  169426           5 : }
  169427             : 
  169428             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  169429             : //                 reading multiple binary files to for a single AST.
  169430             : /////////// new version ////////////////////////////////
  169431             : //############################################################################
  169432             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  169433             : void
  169434           2 : SgElementwiseAddOp::extendMemoryPoolForFileIO( )
  169435             :   {
  169436           2 :     size_t blockIndex = SgElementwiseAddOp::pools.size();
  169437           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseAddOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseAddOp);
  169438             : 
  169439           2 :     while ( (blockIndex * SgElementwiseAddOp::pool_size) < newPoolSize)
  169440             :       {
  169441             : #if ROSE_ALLOC_TRACE
  169442             :         if (blockIndex > 0) {
  169443             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseAddOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseAddOp) = %" PRIuPTR " SgElementwiseAddOp::pool_size = %d \n",
  169444             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseAddOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseAddOp),SgElementwiseAddOp::pool_size);
  169445             :         }
  169446             : #endif
  169447             : 
  169448           0 :         SgElementwiseAddOp * pointer = (SgElementwiseAddOp*) ROSE_MALLOC ( SgElementwiseAddOp::pool_size * sizeof(SgElementwiseAddOp) );
  169449           0 :         assert( pointer != NULL );
  169450             : #if ROSE_ALLOC_MEMSET == 1
  169451             :         memset(pointer, 0x00, SgElementwiseAddOp::pool_size * sizeof(SgElementwiseAddOp));
  169452             : #elif ROSE_ALLOC_MEMSET == 2
  169453             :         memset(pointer, 0xCC, SgElementwiseAddOp::pool_size * sizeof(SgElementwiseAddOp));
  169454             : #endif
  169455           0 :         SgElementwiseAddOp::pools.push_back( (unsigned char*)(pointer) );
  169456           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElementwiseAddOp::pool_size * sizeof(SgElementwiseAddOp), V_SgElementwiseAddOp ) );
  169457             : 
  169458           0 :         if ( SgElementwiseAddOp::next_node != NULL ) {
  169459           0 :           if ( blockIndex > 0 ) {
  169460           0 :             SgElementwiseAddOp * blkptr = (SgElementwiseAddOp*)(SgElementwiseAddOp::pools[blockIndex-1]);
  169461           0 :             blkptr[ SgElementwiseAddOp::pool_size - 1 ].set_freepointer(pointer);
  169462             :           }
  169463             :         } else {
  169464           0 :           SgElementwiseAddOp::next_node = pointer;
  169465             :         }
  169466             : 
  169467           0 :         for (unsigned i = 0; i < SgElementwiseAddOp::pool_size-1; ++i)
  169468             :            {
  169469           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  169470             :            }
  169471           0 :         pointer[ SgElementwiseAddOp::pool_size -1 ].set_freepointer(NULL);
  169472             : 
  169473           0 :         blockIndex++;
  169474             :       }
  169475           2 :   }
  169476             : 
  169477             : //############################################################################
  169478             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  169479             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  169480             :  * not compressed. However, that stuff is not yet implemented! 
  169481             :  */
  169482             : unsigned long
  169483           0 : SgElementwiseAddOp::getNumberOfLastValidPointer()
  169484             :    {
  169485           0 :       SgElementwiseAddOp* testPointer = (SgElementwiseAddOp*)(SgElementwiseAddOp::pools.back());
  169486           0 :       unsigned long localIndex = SgElementwiseAddOp::pool_size - 1;
  169487           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  169488             :          {
  169489           0 :            localIndex--;
  169490             :          }
  169491           0 :       return (localIndex + SgElementwiseAddOp::pool_size * (SgElementwiseAddOp::pools.size()-1));
  169492             :    }
  169493             : 
  169494             : //############################################################################
  169495             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  169496             :  * memory pool and initializes the data member in class SgElementwiseAddOpStroageClass
  169497             :  * from its counterpart of SgElementwiseAddOp. The return value is just for checking, 
  169498             :  * that the whole StorageClassArray is initialized!
  169499             :  */
  169500             : unsigned long
  169501           0 : SgElementwiseAddOp::initializeStorageClassArray( SgElementwiseAddOpStorageClass *storageArray )
  169502             :    {
  169503           0 :      unsigned long storageCounter = 0;
  169504           0 :      std::vector < unsigned char* > :: const_iterator block = SgElementwiseAddOp::pools.begin();
  169505           0 :      SgElementwiseAddOp* pointer = NULL;
  169506           0 :      while ( block != SgElementwiseAddOp::pools.end() ) {
  169507           0 :           pointer = (SgElementwiseAddOp*) (*block);
  169508           0 :           for ( unsigned i = 0; i < SgElementwiseAddOp::pool_size; ++i ) {
  169509           0 :                if ( pointer->get_freepointer() != NULL ) {
  169510           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  169511           0 :                  storageArray++;
  169512           0 :                  storageCounter++;
  169513             :                }
  169514           0 :                pointer++;
  169515             :              }
  169516           0 :            block++;
  169517             :         }
  169518           0 :      return storageCounter;
  169519             :    }
  169520             : 
  169521             : /* #line 169522 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  169522             : 
  169523             : 
  169524             : 
  169525             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  169526             : 
  169527             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  169528             : 
  169529             : //############################################################################
  169530             : /* JH (02/02/2006) Constructor of the IR node SgElementwiseSubtractOp that takes its 
  169531             :  * corresponding StorageClass as parameter
  169532             :  */
  169533           0 : SgElementwiseSubtractOp :: SgElementwiseSubtractOp ( const SgElementwiseSubtractOpStorageClass& storageSource )   : SgElementwiseOp (storageSource)
  169534             :    {
  169535             : 
  169536             : 
  169537             : /* #line 169538 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  169538             : 
  169539           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  169540             : 
  169541             : 
  169542             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  169543             : 
  169544             : 
  169545           0 :    }
  169546             : 
  169547             : //############################################################################
  169548             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  169549             :  * within the working AST. 
  169550             :  */
  169551           0 : SgElementwiseSubtractOp * SgElementwiseSubtractOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  169552           0 :      SgElementwiseSubtractOp* returnPointer = NULL;
  169553           0 :      if ( globalIndex != 0 )
  169554             :         {
  169555             : 
  169556             : #if FILE_IO_EXTRA_CHECK
  169557           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgElementwiseSubtractOp ) ) <= globalIndex ) ;
  169558           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseSubtractOp + 1 ) ) );
  169559             : #endif
  169560           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgElementwiseSubtractOp )  
  169561           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgElementwiseSubtractOp );
  169562           0 :           unsigned long positionInPool = localIndex % SgElementwiseSubtractOp::pool_size;
  169563           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseSubtractOp::pool_size;
  169564             : 
  169565             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  169566             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  169567             : 
  169568           0 :           returnPointer = &( ( (SgElementwiseSubtractOp*)(SgElementwiseSubtractOp::pools[memoryBlock]) ) [positionInPool]) ;
  169569             : 
  169570           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  169571             :         }
  169572           0 :      return returnPointer ;
  169573             :    }
  169574             : 
  169575             : //############################################################################
  169576             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  169577             :   for the AST with the index astIndex
  169578             : */
  169579           0 : SgElementwiseSubtractOp * SgElementwiseSubtractOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  169580           0 :      SgElementwiseSubtractOp* returnPointer = NULL;
  169581           0 :      if ( globalIndex != 0 )
  169582             :         {
  169583             : 
  169584             : #if FILE_IO_EXTRA_CHECK
  169585           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgElementwiseSubtractOp ) ) <= globalIndex ) ;
  169586           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseSubtractOp + 1 ) ) );
  169587             : #endif
  169588           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgElementwiseSubtractOp )
  169589           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgElementwiseSubtractOp );
  169590           0 :           unsigned long positionInPool = localIndex % SgElementwiseSubtractOp::pool_size ;
  169591           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgElementwiseSubtractOp::pool_size ;
  169592             : 
  169593             : #if FILE_IO_EXTRA_CHECK
  169594             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  169595             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  169596             : #endif
  169597             : 
  169598           0 :           returnPointer = &( ( (SgElementwiseSubtractOp*)(SgElementwiseSubtractOp::pools[memoryBlock]) ) [positionInPool]) ;
  169599             : 
  169600             : #if FILE_IO_EXTRA_CHECK
  169601           0 :           assert ( returnPointer != NULL ) ;
  169602             : #endif
  169603             :         }
  169604           0 :      return returnPointer ;
  169605             :    }
  169606             : 
  169607             : //############################################################################
  169608             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  169609             :  * pool size! We set for every valid object in the memory pool the freepointer
  169610             :  * to the global index and increase the global index afterwards. For all the 
  169611             :  * invalid objects (means address ranges within the memory pool that were not
  169612             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  169613             :  * distinguish valid from invalid objects! 
  169614             :  */
  169615             : unsigned long
  169616           5 : SgElementwiseSubtractOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  169617             :    {
  169618           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  169619           5 :      SgElementwiseSubtractOp* pointer = NULL;
  169620           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  169621           5 :      std::vector < unsigned char* > :: const_iterator block;
  169622           5 :      for ( block = SgElementwiseSubtractOp::pools.begin(); block != SgElementwiseSubtractOp::pools.end() ; ++block )
  169623             :         {
  169624           0 :           pointer = (SgElementwiseSubtractOp*)(*block);
  169625           0 :           for (unsigned i = 0; i < SgElementwiseSubtractOp::pool_size; ++i )
  169626             :              {
  169627             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  169628             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  169629             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  169630             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  169631             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  169632             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  169633             :             // properly; so this will have to be checked next.
  169634             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  169635             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  169636           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  169637             :                   {
  169638           0 :                     pointer[i].set_freepointer((SgElementwiseSubtractOp*)(globalIndex));
  169639           0 :                     globalIndex++;
  169640             :                   }
  169641             :                else
  169642             :                   {
  169643           0 :                     pointer[i].set_freepointer(NULL);
  169644             :                   }
  169645             :               }
  169646             :         }
  169647           5 :      return globalIndex;
  169648             :    }
  169649             : 
  169650             : //############################################################################
  169651             : // JH (01/14/2006)
  169652             : void
  169653           5 : SgElementwiseSubtractOp::resetValidFreepointers( )
  169654             :    {
  169655           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  169656           5 :      SgElementwiseSubtractOp* pointer = NULL;
  169657           5 :      std::vector < unsigned char* > :: const_iterator block;
  169658           5 :      SgElementwiseSubtractOp* pointerOfLinkedList = NULL;
  169659           5 :      for ( block = SgElementwiseSubtractOp::pools.begin(); block != SgElementwiseSubtractOp::pools.end() ; ++block )
  169660             :         {
  169661           0 :           pointer = (SgElementwiseSubtractOp*)(*block);
  169662           0 :           for (unsigned i = 0; i < SgElementwiseSubtractOp::pool_size; ++i )
  169663             :              {
  169664             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  169665             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  169666             :             // memory blocks!.
  169667           0 :                if ( pointer[i].get_freepointer() != NULL )
  169668             :                   {
  169669           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  169670             :                   }
  169671             :                else
  169672             :                   {
  169673           0 :                     if ( pointerOfLinkedList == NULL )
  169674             :                        {
  169675           0 :                          SgElementwiseSubtractOp::next_node = &(pointer[i]);
  169676             :                        }
  169677             :                     else
  169678             :                        {
  169679             :                       // printf ("In SgElementwiseSubtractOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  169680           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  169681             :                        }
  169682             :                     pointerOfLinkedList = &(pointer[i]);
  169683             :                   }
  169684             :               }
  169685             :         }
  169686             : 
  169687           5 :      if ( pointerOfLinkedList != NULL )
  169688             :         {
  169689             :        // printf ("In SgElementwiseSubtractOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  169690           0 :           pointerOfLinkedList->set_freepointer(NULL);
  169691             :        // DQ (6/6/2010): Temporary debugging...
  169692             :        //   ROSE_ASSERT(false);
  169693             :         }
  169694             : 
  169695           5 :      return ;
  169696             :    }
  169697             : 
  169698             : //############################################################################
  169699             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  169700             :  * within the memory pool and resets the freepointers, in order to achieve a 
  169701             :  * linked list, that has no jumps and starts at the beginning! This function 
  169702             :  * does not extend the memory pool, since we do not delete any memory blocks,
  169703             :  * but delete the valid objects.  
  169704             :  */
  169705             : void
  169706           0 : SgElementwiseSubtractOp::clearMemoryPool( )
  169707             :    {
  169708             :   // printf ("Inside of SgElementwiseSubtractOp::clearMemoryPool() \n");
  169709             : 
  169710           0 :      SgElementwiseSubtractOp* pointer = NULL, *tempPointer = NULL;
  169711           0 :      std::vector < unsigned char* > :: const_iterator block;
  169712           0 :      if ( SgElementwiseSubtractOp::pools.empty() == false )
  169713             :         {
  169714           0 :           block = SgElementwiseSubtractOp::pools.begin() ;
  169715           0 :           SgElementwiseSubtractOp::next_node = (SgElementwiseSubtractOp*) (*block);
  169716             : 
  169717           0 :           while ( block != SgElementwiseSubtractOp::pools.end() )
  169718             :              {
  169719           0 :                pointer = (SgElementwiseSubtractOp*) (*block);
  169720           0 :                if ( tempPointer != NULL )
  169721             :                   {
  169722           0 :                     tempPointer->set_freepointer(pointer);
  169723             :                   }
  169724           0 :                for (unsigned i = 0; i < SgElementwiseSubtractOp::pool_size - 1; ++i)
  169725             :                   {
  169726           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  169727             :                   }
  169728           0 :                 pointer[SgElementwiseSubtractOp::pool_size-1].set_freepointer(NULL);
  169729           0 :                 tempPointer = &(pointer[SgElementwiseSubtractOp::pool_size-1]);
  169730           0 :                 ++block;
  169731             :              }
  169732             :         }
  169733           0 :    }
  169734             : 
  169735           5 : void SgElementwiseSubtractOp::deleteMemoryPool() {
  169736           5 :   for (auto p: SgElementwiseSubtractOp::pools) {
  169737           0 :     ROSE_FREE(p);
  169738             :   }
  169739           5 :   SgElementwiseSubtractOp::next_node = nullptr;
  169740           5 :   SgElementwiseSubtractOp::pools.clear();
  169741           5 : }
  169742             : 
  169743             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  169744             : //                 reading multiple binary files to for a single AST.
  169745             : /////////// new version ////////////////////////////////
  169746             : //############################################################################
  169747             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  169748             : void
  169749           2 : SgElementwiseSubtractOp::extendMemoryPoolForFileIO( )
  169750             :   {
  169751           2 :     size_t blockIndex = SgElementwiseSubtractOp::pools.size();
  169752           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseSubtractOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseSubtractOp);
  169753             : 
  169754           2 :     while ( (blockIndex * SgElementwiseSubtractOp::pool_size) < newPoolSize)
  169755             :       {
  169756             : #if ROSE_ALLOC_TRACE
  169757             :         if (blockIndex > 0) {
  169758             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseSubtractOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseSubtractOp) = %" PRIuPTR " SgElementwiseSubtractOp::pool_size = %d \n",
  169759             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgElementwiseSubtractOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgElementwiseSubtractOp),SgElementwiseSubtractOp::pool_size);
  169760             :         }
  169761             : #endif
  169762             : 
  169763           0 :         SgElementwiseSubtractOp * pointer = (SgElementwiseSubtractOp*) ROSE_MALLOC ( SgElementwiseSubtractOp::pool_size * sizeof(SgElementwiseSubtractOp) );
  169764           0 :         assert( pointer != NULL );
  169765             : #if ROSE_ALLOC_MEMSET == 1
  169766             :         memset(pointer, 0x00, SgElementwiseSubtractOp::pool_size * sizeof(SgElementwiseSubtractOp));
  169767             : #elif ROSE_ALLOC_MEMSET == 2
  169768             :         memset(pointer, 0xCC, SgElementwiseSubtractOp::pool_size * sizeof(SgElementwiseSubtractOp));
  169769             : #endif
  169770           0 :         SgElementwiseSubtractOp::pools.push_back( (unsigned char*)(pointer) );
  169771           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgElementwiseSubtractOp::pool_size * sizeof(SgElementwiseSubtractOp), V_SgElementwiseSubtractOp ) );
  169772             : 
  169773           0 :         if ( SgElementwiseSubtractOp::next_node != NULL ) {
  169774           0 :           if ( blockIndex > 0 ) {
  169775           0 :             SgElementwiseSubtractOp * blkptr = (SgElementwiseSubtractOp*)(SgElementwiseSubtractOp::pools[blockIndex-1]);
  169776           0 :             blkptr[ SgElementwiseSubtractOp::pool_size - 1 ].set_freepointer(pointer);
  169777             :           }
  169778             :         } else {
  169779           0 :           SgElementwiseSubtractOp::next_node = pointer;
  169780             :         }
  169781             : 
  169782           0 :         for (unsigned i = 0; i < SgElementwiseSubtractOp::pool_size-1; ++i)
  169783             :            {
  169784           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  169785             :            }
  169786           0 :         pointer[ SgElementwiseSubtractOp::pool_size -1 ].set_freepointer(NULL);
  169787             : 
  169788           0 :         blockIndex++;
  169789             :       }
  169790           2 :   }
  169791             : 
  169792             : //############################################################################
  169793             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  169794             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  169795             :  * not compressed. However, that stuff is not yet implemented! 
  169796             :  */
  169797             : unsigned long
  169798           0 : SgElementwiseSubtractOp::getNumberOfLastValidPointer()
  169799             :    {
  169800           0 :       SgElementwiseSubtractOp* testPointer = (SgElementwiseSubtractOp*)(SgElementwiseSubtractOp::pools.back());
  169801           0 :       unsigned long localIndex = SgElementwiseSubtractOp::pool_size - 1;
  169802           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  169803             :          {
  169804           0 :            localIndex--;
  169805             :          }
  169806           0 :       return (localIndex + SgElementwiseSubtractOp::pool_size * (SgElementwiseSubtractOp::pools.size()-1));
  169807             :    }
  169808             : 
  169809             : //############################################################################
  169810             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  169811             :  * memory pool and initializes the data member in class SgElementwiseSubtractOpStroageClass
  169812             :  * from its counterpart of SgElementwiseSubtractOp. The return value is just for checking, 
  169813             :  * that the whole StorageClassArray is initialized!
  169814             :  */
  169815             : unsigned long
  169816           0 : SgElementwiseSubtractOp::initializeStorageClassArray( SgElementwiseSubtractOpStorageClass *storageArray )
  169817             :    {
  169818           0 :      unsigned long storageCounter = 0;
  169819           0 :      std::vector < unsigned char* > :: const_iterator block = SgElementwiseSubtractOp::pools.begin();
  169820           0 :      SgElementwiseSubtractOp* pointer = NULL;
  169821           0 :      while ( block != SgElementwiseSubtractOp::pools.end() ) {
  169822           0 :           pointer = (SgElementwiseSubtractOp*) (*block);
  169823           0 :           for ( unsigned i = 0; i < SgElementwiseSubtractOp::pool_size; ++i ) {
  169824           0 :                if ( pointer->get_freepointer() != NULL ) {
  169825           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  169826           0 :                  storageArray++;
  169827           0 :                  storageCounter++;
  169828             :                }
  169829           0 :                pointer++;
  169830             :              }
  169831           0 :            block++;
  169832             :         }
  169833           0 :      return storageCounter;
  169834             :    }
  169835             : 
  169836             : /* #line 169837 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  169837             : 
  169838             : 
  169839             : 
  169840             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  169841             : 
  169842             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  169843             : 
  169844             : //############################################################################
  169845             : /* JH (02/02/2006) Constructor of the IR node SgPowerOp that takes its 
  169846             :  * corresponding StorageClass as parameter
  169847             :  */
  169848           0 : SgPowerOp :: SgPowerOp ( const SgPowerOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  169849             :    {
  169850             : 
  169851             : 
  169852             : /* #line 169853 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  169853             : 
  169854           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  169855             : 
  169856             : 
  169857             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  169858             : 
  169859             : 
  169860           0 :    }
  169861             : 
  169862             : //############################################################################
  169863             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  169864             :  * within the working AST. 
  169865             :  */
  169866           0 : SgPowerOp * SgPowerOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  169867           0 :      SgPowerOp* returnPointer = NULL;
  169868           0 :      if ( globalIndex != 0 )
  169869             :         {
  169870             : 
  169871             : #if FILE_IO_EXTRA_CHECK
  169872           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPowerOp ) ) <= globalIndex ) ;
  169873           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPowerOp + 1 ) ) );
  169874             : #endif
  169875           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPowerOp )  
  169876           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPowerOp );
  169877           0 :           unsigned long positionInPool = localIndex % SgPowerOp::pool_size;
  169878           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPowerOp::pool_size;
  169879             : 
  169880             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  169881             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  169882             : 
  169883           0 :           returnPointer = &( ( (SgPowerOp*)(SgPowerOp::pools[memoryBlock]) ) [positionInPool]) ;
  169884             : 
  169885           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  169886             :         }
  169887           0 :      return returnPointer ;
  169888             :    }
  169889             : 
  169890             : //############################################################################
  169891             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  169892             :   for the AST with the index astIndex
  169893             : */
  169894           0 : SgPowerOp * SgPowerOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  169895           0 :      SgPowerOp* returnPointer = NULL;
  169896           0 :      if ( globalIndex != 0 )
  169897             :         {
  169898             : 
  169899             : #if FILE_IO_EXTRA_CHECK
  169900           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPowerOp ) ) <= globalIndex ) ;
  169901           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPowerOp + 1 ) ) );
  169902             : #endif
  169903           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPowerOp )
  169904           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPowerOp );
  169905           0 :           unsigned long positionInPool = localIndex % SgPowerOp::pool_size ;
  169906           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPowerOp::pool_size ;
  169907             : 
  169908             : #if FILE_IO_EXTRA_CHECK
  169909             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  169910             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  169911             : #endif
  169912             : 
  169913           0 :           returnPointer = &( ( (SgPowerOp*)(SgPowerOp::pools[memoryBlock]) ) [positionInPool]) ;
  169914             : 
  169915             : #if FILE_IO_EXTRA_CHECK
  169916           0 :           assert ( returnPointer != NULL ) ;
  169917             : #endif
  169918             :         }
  169919           0 :      return returnPointer ;
  169920             :    }
  169921             : 
  169922             : //############################################################################
  169923             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  169924             :  * pool size! We set for every valid object in the memory pool the freepointer
  169925             :  * to the global index and increase the global index afterwards. For all the 
  169926             :  * invalid objects (means address ranges within the memory pool that were not
  169927             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  169928             :  * distinguish valid from invalid objects! 
  169929             :  */
  169930             : unsigned long
  169931           5 : SgPowerOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  169932             :    {
  169933           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  169934           5 :      SgPowerOp* pointer = NULL;
  169935           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  169936           5 :      std::vector < unsigned char* > :: const_iterator block;
  169937           5 :      for ( block = SgPowerOp::pools.begin(); block != SgPowerOp::pools.end() ; ++block )
  169938             :         {
  169939           0 :           pointer = (SgPowerOp*)(*block);
  169940           0 :           for (unsigned i = 0; i < SgPowerOp::pool_size; ++i )
  169941             :              {
  169942             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  169943             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  169944             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  169945             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  169946             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  169947             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  169948             :             // properly; so this will have to be checked next.
  169949             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  169950             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  169951           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  169952             :                   {
  169953           0 :                     pointer[i].set_freepointer((SgPowerOp*)(globalIndex));
  169954           0 :                     globalIndex++;
  169955             :                   }
  169956             :                else
  169957             :                   {
  169958           0 :                     pointer[i].set_freepointer(NULL);
  169959             :                   }
  169960             :               }
  169961             :         }
  169962           5 :      return globalIndex;
  169963             :    }
  169964             : 
  169965             : //############################################################################
  169966             : // JH (01/14/2006)
  169967             : void
  169968           5 : SgPowerOp::resetValidFreepointers( )
  169969             :    {
  169970           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  169971           5 :      SgPowerOp* pointer = NULL;
  169972           5 :      std::vector < unsigned char* > :: const_iterator block;
  169973           5 :      SgPowerOp* pointerOfLinkedList = NULL;
  169974           5 :      for ( block = SgPowerOp::pools.begin(); block != SgPowerOp::pools.end() ; ++block )
  169975             :         {
  169976           0 :           pointer = (SgPowerOp*)(*block);
  169977           0 :           for (unsigned i = 0; i < SgPowerOp::pool_size; ++i )
  169978             :              {
  169979             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  169980             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  169981             :             // memory blocks!.
  169982           0 :                if ( pointer[i].get_freepointer() != NULL )
  169983             :                   {
  169984           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  169985             :                   }
  169986             :                else
  169987             :                   {
  169988           0 :                     if ( pointerOfLinkedList == NULL )
  169989             :                        {
  169990           0 :                          SgPowerOp::next_node = &(pointer[i]);
  169991             :                        }
  169992             :                     else
  169993             :                        {
  169994             :                       // printf ("In SgPowerOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  169995           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  169996             :                        }
  169997             :                     pointerOfLinkedList = &(pointer[i]);
  169998             :                   }
  169999             :               }
  170000             :         }
  170001             : 
  170002           5 :      if ( pointerOfLinkedList != NULL )
  170003             :         {
  170004             :        // printf ("In SgPowerOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  170005           0 :           pointerOfLinkedList->set_freepointer(NULL);
  170006             :        // DQ (6/6/2010): Temporary debugging...
  170007             :        //   ROSE_ASSERT(false);
  170008             :         }
  170009             : 
  170010           5 :      return ;
  170011             :    }
  170012             : 
  170013             : //############################################################################
  170014             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  170015             :  * within the memory pool and resets the freepointers, in order to achieve a 
  170016             :  * linked list, that has no jumps and starts at the beginning! This function 
  170017             :  * does not extend the memory pool, since we do not delete any memory blocks,
  170018             :  * but delete the valid objects.  
  170019             :  */
  170020             : void
  170021           0 : SgPowerOp::clearMemoryPool( )
  170022             :    {
  170023             :   // printf ("Inside of SgPowerOp::clearMemoryPool() \n");
  170024             : 
  170025           0 :      SgPowerOp* pointer = NULL, *tempPointer = NULL;
  170026           0 :      std::vector < unsigned char* > :: const_iterator block;
  170027           0 :      if ( SgPowerOp::pools.empty() == false )
  170028             :         {
  170029           0 :           block = SgPowerOp::pools.begin() ;
  170030           0 :           SgPowerOp::next_node = (SgPowerOp*) (*block);
  170031             : 
  170032           0 :           while ( block != SgPowerOp::pools.end() )
  170033             :              {
  170034           0 :                pointer = (SgPowerOp*) (*block);
  170035           0 :                if ( tempPointer != NULL )
  170036             :                   {
  170037           0 :                     tempPointer->set_freepointer(pointer);
  170038             :                   }
  170039           0 :                for (unsigned i = 0; i < SgPowerOp::pool_size - 1; ++i)
  170040             :                   {
  170041           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  170042             :                   }
  170043           0 :                 pointer[SgPowerOp::pool_size-1].set_freepointer(NULL);
  170044           0 :                 tempPointer = &(pointer[SgPowerOp::pool_size-1]);
  170045           0 :                 ++block;
  170046             :              }
  170047             :         }
  170048           0 :    }
  170049             : 
  170050           5 : void SgPowerOp::deleteMemoryPool() {
  170051           5 :   for (auto p: SgPowerOp::pools) {
  170052           0 :     ROSE_FREE(p);
  170053             :   }
  170054           5 :   SgPowerOp::next_node = nullptr;
  170055           5 :   SgPowerOp::pools.clear();
  170056           5 : }
  170057             : 
  170058             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  170059             : //                 reading multiple binary files to for a single AST.
  170060             : /////////// new version ////////////////////////////////
  170061             : //############################################################################
  170062             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  170063             : void
  170064           2 : SgPowerOp::extendMemoryPoolForFileIO( )
  170065             :   {
  170066           2 :     size_t blockIndex = SgPowerOp::pools.size();
  170067           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPowerOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPowerOp);
  170068             : 
  170069           2 :     while ( (blockIndex * SgPowerOp::pool_size) < newPoolSize)
  170070             :       {
  170071             : #if ROSE_ALLOC_TRACE
  170072             :         if (blockIndex > 0) {
  170073             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPowerOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPowerOp) = %" PRIuPTR " SgPowerOp::pool_size = %d \n",
  170074             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPowerOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPowerOp),SgPowerOp::pool_size);
  170075             :         }
  170076             : #endif
  170077             : 
  170078           0 :         SgPowerOp * pointer = (SgPowerOp*) ROSE_MALLOC ( SgPowerOp::pool_size * sizeof(SgPowerOp) );
  170079           0 :         assert( pointer != NULL );
  170080             : #if ROSE_ALLOC_MEMSET == 1
  170081             :         memset(pointer, 0x00, SgPowerOp::pool_size * sizeof(SgPowerOp));
  170082             : #elif ROSE_ALLOC_MEMSET == 2
  170083             :         memset(pointer, 0xCC, SgPowerOp::pool_size * sizeof(SgPowerOp));
  170084             : #endif
  170085           0 :         SgPowerOp::pools.push_back( (unsigned char*)(pointer) );
  170086           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPowerOp::pool_size * sizeof(SgPowerOp), V_SgPowerOp ) );
  170087             : 
  170088           0 :         if ( SgPowerOp::next_node != NULL ) {
  170089           0 :           if ( blockIndex > 0 ) {
  170090           0 :             SgPowerOp * blkptr = (SgPowerOp*)(SgPowerOp::pools[blockIndex-1]);
  170091           0 :             blkptr[ SgPowerOp::pool_size - 1 ].set_freepointer(pointer);
  170092             :           }
  170093             :         } else {
  170094           0 :           SgPowerOp::next_node = pointer;
  170095             :         }
  170096             : 
  170097           0 :         for (unsigned i = 0; i < SgPowerOp::pool_size-1; ++i)
  170098             :            {
  170099           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  170100             :            }
  170101           0 :         pointer[ SgPowerOp::pool_size -1 ].set_freepointer(NULL);
  170102             : 
  170103           0 :         blockIndex++;
  170104             :       }
  170105           2 :   }
  170106             : 
  170107             : //############################################################################
  170108             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  170109             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  170110             :  * not compressed. However, that stuff is not yet implemented! 
  170111             :  */
  170112             : unsigned long
  170113           0 : SgPowerOp::getNumberOfLastValidPointer()
  170114             :    {
  170115           0 :       SgPowerOp* testPointer = (SgPowerOp*)(SgPowerOp::pools.back());
  170116           0 :       unsigned long localIndex = SgPowerOp::pool_size - 1;
  170117           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  170118             :          {
  170119           0 :            localIndex--;
  170120             :          }
  170121           0 :       return (localIndex + SgPowerOp::pool_size * (SgPowerOp::pools.size()-1));
  170122             :    }
  170123             : 
  170124             : //############################################################################
  170125             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  170126             :  * memory pool and initializes the data member in class SgPowerOpStroageClass
  170127             :  * from its counterpart of SgPowerOp. The return value is just for checking, 
  170128             :  * that the whole StorageClassArray is initialized!
  170129             :  */
  170130             : unsigned long
  170131           0 : SgPowerOp::initializeStorageClassArray( SgPowerOpStorageClass *storageArray )
  170132             :    {
  170133           0 :      unsigned long storageCounter = 0;
  170134           0 :      std::vector < unsigned char* > :: const_iterator block = SgPowerOp::pools.begin();
  170135           0 :      SgPowerOp* pointer = NULL;
  170136           0 :      while ( block != SgPowerOp::pools.end() ) {
  170137           0 :           pointer = (SgPowerOp*) (*block);
  170138           0 :           for ( unsigned i = 0; i < SgPowerOp::pool_size; ++i ) {
  170139           0 :                if ( pointer->get_freepointer() != NULL ) {
  170140           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  170141           0 :                  storageArray++;
  170142           0 :                  storageCounter++;
  170143             :                }
  170144           0 :                pointer++;
  170145             :              }
  170146           0 :            block++;
  170147             :         }
  170148           0 :      return storageCounter;
  170149             :    }
  170150             : 
  170151             : /* #line 170152 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  170152             : 
  170153             : 
  170154             : 
  170155             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  170156             : 
  170157             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  170158             : 
  170159             : //############################################################################
  170160             : /* JH (02/02/2006) Constructor of the IR node SgLeftDivideOp that takes its 
  170161             :  * corresponding StorageClass as parameter
  170162             :  */
  170163           0 : SgLeftDivideOp :: SgLeftDivideOp ( const SgLeftDivideOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  170164             :    {
  170165             : 
  170166             : 
  170167             : /* #line 170168 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  170168             : 
  170169           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  170170             : 
  170171             : 
  170172             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  170173             : 
  170174             : 
  170175           0 :    }
  170176             : 
  170177             : //############################################################################
  170178             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  170179             :  * within the working AST. 
  170180             :  */
  170181           0 : SgLeftDivideOp * SgLeftDivideOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  170182           0 :      SgLeftDivideOp* returnPointer = NULL;
  170183           0 :      if ( globalIndex != 0 )
  170184             :         {
  170185             : 
  170186             : #if FILE_IO_EXTRA_CHECK
  170187           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLeftDivideOp ) ) <= globalIndex ) ;
  170188           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLeftDivideOp + 1 ) ) );
  170189             : #endif
  170190           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLeftDivideOp )  
  170191           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLeftDivideOp );
  170192           0 :           unsigned long positionInPool = localIndex % SgLeftDivideOp::pool_size;
  170193           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLeftDivideOp::pool_size;
  170194             : 
  170195             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  170196             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  170197             : 
  170198           0 :           returnPointer = &( ( (SgLeftDivideOp*)(SgLeftDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  170199             : 
  170200           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  170201             :         }
  170202           0 :      return returnPointer ;
  170203             :    }
  170204             : 
  170205             : //############################################################################
  170206             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  170207             :   for the AST with the index astIndex
  170208             : */
  170209           0 : SgLeftDivideOp * SgLeftDivideOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  170210           0 :      SgLeftDivideOp* returnPointer = NULL;
  170211           0 :      if ( globalIndex != 0 )
  170212             :         {
  170213             : 
  170214             : #if FILE_IO_EXTRA_CHECK
  170215           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLeftDivideOp ) ) <= globalIndex ) ;
  170216           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLeftDivideOp + 1 ) ) );
  170217             : #endif
  170218           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLeftDivideOp )
  170219           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLeftDivideOp );
  170220           0 :           unsigned long positionInPool = localIndex % SgLeftDivideOp::pool_size ;
  170221           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLeftDivideOp::pool_size ;
  170222             : 
  170223             : #if FILE_IO_EXTRA_CHECK
  170224             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  170225             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  170226             : #endif
  170227             : 
  170228           0 :           returnPointer = &( ( (SgLeftDivideOp*)(SgLeftDivideOp::pools[memoryBlock]) ) [positionInPool]) ;
  170229             : 
  170230             : #if FILE_IO_EXTRA_CHECK
  170231           0 :           assert ( returnPointer != NULL ) ;
  170232             : #endif
  170233             :         }
  170234           0 :      return returnPointer ;
  170235             :    }
  170236             : 
  170237             : //############################################################################
  170238             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  170239             :  * pool size! We set for every valid object in the memory pool the freepointer
  170240             :  * to the global index and increase the global index afterwards. For all the 
  170241             :  * invalid objects (means address ranges within the memory pool that were not
  170242             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  170243             :  * distinguish valid from invalid objects! 
  170244             :  */
  170245             : unsigned long
  170246           5 : SgLeftDivideOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  170247             :    {
  170248           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  170249           5 :      SgLeftDivideOp* pointer = NULL;
  170250           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  170251           5 :      std::vector < unsigned char* > :: const_iterator block;
  170252           5 :      for ( block = SgLeftDivideOp::pools.begin(); block != SgLeftDivideOp::pools.end() ; ++block )
  170253             :         {
  170254           0 :           pointer = (SgLeftDivideOp*)(*block);
  170255           0 :           for (unsigned i = 0; i < SgLeftDivideOp::pool_size; ++i )
  170256             :              {
  170257             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  170258             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  170259             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  170260             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  170261             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  170262             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  170263             :             // properly; so this will have to be checked next.
  170264             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  170265             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  170266           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  170267             :                   {
  170268           0 :                     pointer[i].set_freepointer((SgLeftDivideOp*)(globalIndex));
  170269           0 :                     globalIndex++;
  170270             :                   }
  170271             :                else
  170272             :                   {
  170273           0 :                     pointer[i].set_freepointer(NULL);
  170274             :                   }
  170275             :               }
  170276             :         }
  170277           5 :      return globalIndex;
  170278             :    }
  170279             : 
  170280             : //############################################################################
  170281             : // JH (01/14/2006)
  170282             : void
  170283           5 : SgLeftDivideOp::resetValidFreepointers( )
  170284             :    {
  170285           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  170286           5 :      SgLeftDivideOp* pointer = NULL;
  170287           5 :      std::vector < unsigned char* > :: const_iterator block;
  170288           5 :      SgLeftDivideOp* pointerOfLinkedList = NULL;
  170289           5 :      for ( block = SgLeftDivideOp::pools.begin(); block != SgLeftDivideOp::pools.end() ; ++block )
  170290             :         {
  170291           0 :           pointer = (SgLeftDivideOp*)(*block);
  170292           0 :           for (unsigned i = 0; i < SgLeftDivideOp::pool_size; ++i )
  170293             :              {
  170294             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  170295             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  170296             :             // memory blocks!.
  170297           0 :                if ( pointer[i].get_freepointer() != NULL )
  170298             :                   {
  170299           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  170300             :                   }
  170301             :                else
  170302             :                   {
  170303           0 :                     if ( pointerOfLinkedList == NULL )
  170304             :                        {
  170305           0 :                          SgLeftDivideOp::next_node = &(pointer[i]);
  170306             :                        }
  170307             :                     else
  170308             :                        {
  170309             :                       // printf ("In SgLeftDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  170310           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  170311             :                        }
  170312             :                     pointerOfLinkedList = &(pointer[i]);
  170313             :                   }
  170314             :               }
  170315             :         }
  170316             : 
  170317           5 :      if ( pointerOfLinkedList != NULL )
  170318             :         {
  170319             :        // printf ("In SgLeftDivideOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  170320           0 :           pointerOfLinkedList->set_freepointer(NULL);
  170321             :        // DQ (6/6/2010): Temporary debugging...
  170322             :        //   ROSE_ASSERT(false);
  170323             :         }
  170324             : 
  170325           5 :      return ;
  170326             :    }
  170327             : 
  170328             : //############################################################################
  170329             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  170330             :  * within the memory pool and resets the freepointers, in order to achieve a 
  170331             :  * linked list, that has no jumps and starts at the beginning! This function 
  170332             :  * does not extend the memory pool, since we do not delete any memory blocks,
  170333             :  * but delete the valid objects.  
  170334             :  */
  170335             : void
  170336           0 : SgLeftDivideOp::clearMemoryPool( )
  170337             :    {
  170338             :   // printf ("Inside of SgLeftDivideOp::clearMemoryPool() \n");
  170339             : 
  170340           0 :      SgLeftDivideOp* pointer = NULL, *tempPointer = NULL;
  170341           0 :      std::vector < unsigned char* > :: const_iterator block;
  170342           0 :      if ( SgLeftDivideOp::pools.empty() == false )
  170343             :         {
  170344           0 :           block = SgLeftDivideOp::pools.begin() ;
  170345           0 :           SgLeftDivideOp::next_node = (SgLeftDivideOp*) (*block);
  170346             : 
  170347           0 :           while ( block != SgLeftDivideOp::pools.end() )
  170348             :              {
  170349           0 :                pointer = (SgLeftDivideOp*) (*block);
  170350           0 :                if ( tempPointer != NULL )
  170351             :                   {
  170352           0 :                     tempPointer->set_freepointer(pointer);
  170353             :                   }
  170354           0 :                for (unsigned i = 0; i < SgLeftDivideOp::pool_size - 1; ++i)
  170355             :                   {
  170356           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  170357             :                   }
  170358           0 :                 pointer[SgLeftDivideOp::pool_size-1].set_freepointer(NULL);
  170359           0 :                 tempPointer = &(pointer[SgLeftDivideOp::pool_size-1]);
  170360           0 :                 ++block;
  170361             :              }
  170362             :         }
  170363           0 :    }
  170364             : 
  170365           5 : void SgLeftDivideOp::deleteMemoryPool() {
  170366           5 :   for (auto p: SgLeftDivideOp::pools) {
  170367           0 :     ROSE_FREE(p);
  170368             :   }
  170369           5 :   SgLeftDivideOp::next_node = nullptr;
  170370           5 :   SgLeftDivideOp::pools.clear();
  170371           5 : }
  170372             : 
  170373             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  170374             : //                 reading multiple binary files to for a single AST.
  170375             : /////////// new version ////////////////////////////////
  170376             : //############################################################################
  170377             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  170378             : void
  170379           2 : SgLeftDivideOp::extendMemoryPoolForFileIO( )
  170380             :   {
  170381           2 :     size_t blockIndex = SgLeftDivideOp::pools.size();
  170382           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLeftDivideOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLeftDivideOp);
  170383             : 
  170384           2 :     while ( (blockIndex * SgLeftDivideOp::pool_size) < newPoolSize)
  170385             :       {
  170386             : #if ROSE_ALLOC_TRACE
  170387             :         if (blockIndex > 0) {
  170388             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLeftDivideOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLeftDivideOp) = %" PRIuPTR " SgLeftDivideOp::pool_size = %d \n",
  170389             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLeftDivideOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLeftDivideOp),SgLeftDivideOp::pool_size);
  170390             :         }
  170391             : #endif
  170392             : 
  170393           0 :         SgLeftDivideOp * pointer = (SgLeftDivideOp*) ROSE_MALLOC ( SgLeftDivideOp::pool_size * sizeof(SgLeftDivideOp) );
  170394           0 :         assert( pointer != NULL );
  170395             : #if ROSE_ALLOC_MEMSET == 1
  170396             :         memset(pointer, 0x00, SgLeftDivideOp::pool_size * sizeof(SgLeftDivideOp));
  170397             : #elif ROSE_ALLOC_MEMSET == 2
  170398             :         memset(pointer, 0xCC, SgLeftDivideOp::pool_size * sizeof(SgLeftDivideOp));
  170399             : #endif
  170400           0 :         SgLeftDivideOp::pools.push_back( (unsigned char*)(pointer) );
  170401           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLeftDivideOp::pool_size * sizeof(SgLeftDivideOp), V_SgLeftDivideOp ) );
  170402             : 
  170403           0 :         if ( SgLeftDivideOp::next_node != NULL ) {
  170404           0 :           if ( blockIndex > 0 ) {
  170405           0 :             SgLeftDivideOp * blkptr = (SgLeftDivideOp*)(SgLeftDivideOp::pools[blockIndex-1]);
  170406           0 :             blkptr[ SgLeftDivideOp::pool_size - 1 ].set_freepointer(pointer);
  170407             :           }
  170408             :         } else {
  170409           0 :           SgLeftDivideOp::next_node = pointer;
  170410             :         }
  170411             : 
  170412           0 :         for (unsigned i = 0; i < SgLeftDivideOp::pool_size-1; ++i)
  170413             :            {
  170414           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  170415             :            }
  170416           0 :         pointer[ SgLeftDivideOp::pool_size -1 ].set_freepointer(NULL);
  170417             : 
  170418           0 :         blockIndex++;
  170419             :       }
  170420           2 :   }
  170421             : 
  170422             : //############################################################################
  170423             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  170424             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  170425             :  * not compressed. However, that stuff is not yet implemented! 
  170426             :  */
  170427             : unsigned long
  170428           0 : SgLeftDivideOp::getNumberOfLastValidPointer()
  170429             :    {
  170430           0 :       SgLeftDivideOp* testPointer = (SgLeftDivideOp*)(SgLeftDivideOp::pools.back());
  170431           0 :       unsigned long localIndex = SgLeftDivideOp::pool_size - 1;
  170432           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  170433             :          {
  170434           0 :            localIndex--;
  170435             :          }
  170436           0 :       return (localIndex + SgLeftDivideOp::pool_size * (SgLeftDivideOp::pools.size()-1));
  170437             :    }
  170438             : 
  170439             : //############################################################################
  170440             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  170441             :  * memory pool and initializes the data member in class SgLeftDivideOpStroageClass
  170442             :  * from its counterpart of SgLeftDivideOp. The return value is just for checking, 
  170443             :  * that the whole StorageClassArray is initialized!
  170444             :  */
  170445             : unsigned long
  170446           0 : SgLeftDivideOp::initializeStorageClassArray( SgLeftDivideOpStorageClass *storageArray )
  170447             :    {
  170448           0 :      unsigned long storageCounter = 0;
  170449           0 :      std::vector < unsigned char* > :: const_iterator block = SgLeftDivideOp::pools.begin();
  170450           0 :      SgLeftDivideOp* pointer = NULL;
  170451           0 :      while ( block != SgLeftDivideOp::pools.end() ) {
  170452           0 :           pointer = (SgLeftDivideOp*) (*block);
  170453           0 :           for ( unsigned i = 0; i < SgLeftDivideOp::pool_size; ++i ) {
  170454           0 :                if ( pointer->get_freepointer() != NULL ) {
  170455           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  170456           0 :                  storageArray++;
  170457           0 :                  storageCounter++;
  170458             :                }
  170459           0 :                pointer++;
  170460             :              }
  170461           0 :            block++;
  170462             :         }
  170463           0 :      return storageCounter;
  170464             :    }
  170465             : 
  170466             : /* #line 170467 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  170467             : 
  170468             : 
  170469             : 
  170470             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  170471             : 
  170472             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  170473             : 
  170474             : //############################################################################
  170475             : /* JH (02/02/2006) Constructor of the IR node SgSIMDBinaryOp that takes its 
  170476             :  * corresponding StorageClass as parameter
  170477             :  */
  170478           0 : SgSIMDBinaryOp :: SgSIMDBinaryOp ( const SgSIMDBinaryOpStorageClass& storageSource )   : SgBinaryOp (storageSource)
  170479             :    {
  170480             : 
  170481             : 
  170482             : /* #line 170483 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  170483             : 
  170484           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  170485             : 
  170486             : 
  170487             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  170488             : 
  170489             : 
  170490           0 :    }
  170491             : 
  170492             : //############################################################################
  170493             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  170494             :  * within the working AST. 
  170495             :  */
  170496           0 : SgSIMDBinaryOp * SgSIMDBinaryOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  170497           0 :      SgSIMDBinaryOp* returnPointer = NULL;
  170498           0 :      if ( globalIndex != 0 )
  170499             :         {
  170500             : 
  170501             : #if FILE_IO_EXTRA_CHECK
  170502           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDBinaryOp ) ) <= globalIndex ) ;
  170503           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDBinaryOp + 1 ) ) );
  170504             : #endif
  170505           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDBinaryOp )  
  170506           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDBinaryOp );
  170507           0 :           unsigned long positionInPool = localIndex % SgSIMDBinaryOp::pool_size;
  170508           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDBinaryOp::pool_size;
  170509             : 
  170510             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  170511             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  170512             : 
  170513           0 :           returnPointer = &( ( (SgSIMDBinaryOp*)(SgSIMDBinaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  170514             : 
  170515           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  170516             :         }
  170517           0 :      return returnPointer ;
  170518             :    }
  170519             : 
  170520             : //############################################################################
  170521             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  170522             :   for the AST with the index astIndex
  170523             : */
  170524           0 : SgSIMDBinaryOp * SgSIMDBinaryOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  170525           0 :      SgSIMDBinaryOp* returnPointer = NULL;
  170526           0 :      if ( globalIndex != 0 )
  170527             :         {
  170528             : 
  170529             : #if FILE_IO_EXTRA_CHECK
  170530           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDBinaryOp ) ) <= globalIndex ) ;
  170531           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDBinaryOp + 1 ) ) );
  170532             : #endif
  170533           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDBinaryOp )
  170534           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDBinaryOp );
  170535           0 :           unsigned long positionInPool = localIndex % SgSIMDBinaryOp::pool_size ;
  170536           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDBinaryOp::pool_size ;
  170537             : 
  170538             : #if FILE_IO_EXTRA_CHECK
  170539             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  170540             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  170541             : #endif
  170542             : 
  170543           0 :           returnPointer = &( ( (SgSIMDBinaryOp*)(SgSIMDBinaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  170544             : 
  170545             : #if FILE_IO_EXTRA_CHECK
  170546           0 :           assert ( returnPointer != NULL ) ;
  170547             : #endif
  170548             :         }
  170549           0 :      return returnPointer ;
  170550             :    }
  170551             : 
  170552             : //############################################################################
  170553             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  170554             :  * pool size! We set for every valid object in the memory pool the freepointer
  170555             :  * to the global index and increase the global index afterwards. For all the 
  170556             :  * invalid objects (means address ranges within the memory pool that were not
  170557             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  170558             :  * distinguish valid from invalid objects! 
  170559             :  */
  170560             : unsigned long
  170561           5 : SgSIMDBinaryOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  170562             :    {
  170563           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  170564           5 :      SgSIMDBinaryOp* pointer = NULL;
  170565           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  170566           5 :      std::vector < unsigned char* > :: const_iterator block;
  170567           5 :      for ( block = SgSIMDBinaryOp::pools.begin(); block != SgSIMDBinaryOp::pools.end() ; ++block )
  170568             :         {
  170569           0 :           pointer = (SgSIMDBinaryOp*)(*block);
  170570           0 :           for (unsigned i = 0; i < SgSIMDBinaryOp::pool_size; ++i )
  170571             :              {
  170572             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  170573             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  170574             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  170575             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  170576             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  170577             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  170578             :             // properly; so this will have to be checked next.
  170579             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  170580             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  170581           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  170582             :                   {
  170583           0 :                     pointer[i].set_freepointer((SgSIMDBinaryOp*)(globalIndex));
  170584           0 :                     globalIndex++;
  170585             :                   }
  170586             :                else
  170587             :                   {
  170588           0 :                     pointer[i].set_freepointer(NULL);
  170589             :                   }
  170590             :               }
  170591             :         }
  170592           5 :      return globalIndex;
  170593             :    }
  170594             : 
  170595             : //############################################################################
  170596             : // JH (01/14/2006)
  170597             : void
  170598           5 : SgSIMDBinaryOp::resetValidFreepointers( )
  170599             :    {
  170600           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  170601           5 :      SgSIMDBinaryOp* pointer = NULL;
  170602           5 :      std::vector < unsigned char* > :: const_iterator block;
  170603           5 :      SgSIMDBinaryOp* pointerOfLinkedList = NULL;
  170604           5 :      for ( block = SgSIMDBinaryOp::pools.begin(); block != SgSIMDBinaryOp::pools.end() ; ++block )
  170605             :         {
  170606           0 :           pointer = (SgSIMDBinaryOp*)(*block);
  170607           0 :           for (unsigned i = 0; i < SgSIMDBinaryOp::pool_size; ++i )
  170608             :              {
  170609             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  170610             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  170611             :             // memory blocks!.
  170612           0 :                if ( pointer[i].get_freepointer() != NULL )
  170613             :                   {
  170614           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  170615             :                   }
  170616             :                else
  170617             :                   {
  170618           0 :                     if ( pointerOfLinkedList == NULL )
  170619             :                        {
  170620           0 :                          SgSIMDBinaryOp::next_node = &(pointer[i]);
  170621             :                        }
  170622             :                     else
  170623             :                        {
  170624             :                       // printf ("In SgSIMDBinaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  170625           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  170626             :                        }
  170627             :                     pointerOfLinkedList = &(pointer[i]);
  170628             :                   }
  170629             :               }
  170630             :         }
  170631             : 
  170632           5 :      if ( pointerOfLinkedList != NULL )
  170633             :         {
  170634             :        // printf ("In SgSIMDBinaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  170635           0 :           pointerOfLinkedList->set_freepointer(NULL);
  170636             :        // DQ (6/6/2010): Temporary debugging...
  170637             :        //   ROSE_ASSERT(false);
  170638             :         }
  170639             : 
  170640           5 :      return ;
  170641             :    }
  170642             : 
  170643             : //############################################################################
  170644             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  170645             :  * within the memory pool and resets the freepointers, in order to achieve a 
  170646             :  * linked list, that has no jumps and starts at the beginning! This function 
  170647             :  * does not extend the memory pool, since we do not delete any memory blocks,
  170648             :  * but delete the valid objects.  
  170649             :  */
  170650             : void
  170651           0 : SgSIMDBinaryOp::clearMemoryPool( )
  170652             :    {
  170653             :   // printf ("Inside of SgSIMDBinaryOp::clearMemoryPool() \n");
  170654             : 
  170655           0 :      SgSIMDBinaryOp* pointer = NULL, *tempPointer = NULL;
  170656           0 :      std::vector < unsigned char* > :: const_iterator block;
  170657           0 :      if ( SgSIMDBinaryOp::pools.empty() == false )
  170658             :         {
  170659           0 :           block = SgSIMDBinaryOp::pools.begin() ;
  170660           0 :           SgSIMDBinaryOp::next_node = (SgSIMDBinaryOp*) (*block);
  170661             : 
  170662           0 :           while ( block != SgSIMDBinaryOp::pools.end() )
  170663             :              {
  170664           0 :                pointer = (SgSIMDBinaryOp*) (*block);
  170665           0 :                if ( tempPointer != NULL )
  170666             :                   {
  170667           0 :                     tempPointer->set_freepointer(pointer);
  170668             :                   }
  170669           0 :                for (unsigned i = 0; i < SgSIMDBinaryOp::pool_size - 1; ++i)
  170670             :                   {
  170671           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  170672             :                   }
  170673           0 :                 pointer[SgSIMDBinaryOp::pool_size-1].set_freepointer(NULL);
  170674           0 :                 tempPointer = &(pointer[SgSIMDBinaryOp::pool_size-1]);
  170675           0 :                 ++block;
  170676             :              }
  170677             :         }
  170678           0 :    }
  170679             : 
  170680           5 : void SgSIMDBinaryOp::deleteMemoryPool() {
  170681           5 :   for (auto p: SgSIMDBinaryOp::pools) {
  170682           0 :     ROSE_FREE(p);
  170683             :   }
  170684           5 :   SgSIMDBinaryOp::next_node = nullptr;
  170685           5 :   SgSIMDBinaryOp::pools.clear();
  170686           5 : }
  170687             : 
  170688             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  170689             : //                 reading multiple binary files to for a single AST.
  170690             : /////////// new version ////////////////////////////////
  170691             : //############################################################################
  170692             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  170693             : void
  170694           2 : SgSIMDBinaryOp::extendMemoryPoolForFileIO( )
  170695             :   {
  170696           2 :     size_t blockIndex = SgSIMDBinaryOp::pools.size();
  170697           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDBinaryOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDBinaryOp);
  170698             : 
  170699           2 :     while ( (blockIndex * SgSIMDBinaryOp::pool_size) < newPoolSize)
  170700             :       {
  170701             : #if ROSE_ALLOC_TRACE
  170702             :         if (blockIndex > 0) {
  170703             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDBinaryOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDBinaryOp) = %" PRIuPTR " SgSIMDBinaryOp::pool_size = %d \n",
  170704             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDBinaryOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDBinaryOp),SgSIMDBinaryOp::pool_size);
  170705             :         }
  170706             : #endif
  170707             : 
  170708           0 :         SgSIMDBinaryOp * pointer = (SgSIMDBinaryOp*) ROSE_MALLOC ( SgSIMDBinaryOp::pool_size * sizeof(SgSIMDBinaryOp) );
  170709           0 :         assert( pointer != NULL );
  170710             : #if ROSE_ALLOC_MEMSET == 1
  170711             :         memset(pointer, 0x00, SgSIMDBinaryOp::pool_size * sizeof(SgSIMDBinaryOp));
  170712             : #elif ROSE_ALLOC_MEMSET == 2
  170713             :         memset(pointer, 0xCC, SgSIMDBinaryOp::pool_size * sizeof(SgSIMDBinaryOp));
  170714             : #endif
  170715           0 :         SgSIMDBinaryOp::pools.push_back( (unsigned char*)(pointer) );
  170716           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDBinaryOp::pool_size * sizeof(SgSIMDBinaryOp), V_SgSIMDBinaryOp ) );
  170717             : 
  170718           0 :         if ( SgSIMDBinaryOp::next_node != NULL ) {
  170719           0 :           if ( blockIndex > 0 ) {
  170720           0 :             SgSIMDBinaryOp * blkptr = (SgSIMDBinaryOp*)(SgSIMDBinaryOp::pools[blockIndex-1]);
  170721           0 :             blkptr[ SgSIMDBinaryOp::pool_size - 1 ].set_freepointer(pointer);
  170722             :           }
  170723             :         } else {
  170724           0 :           SgSIMDBinaryOp::next_node = pointer;
  170725             :         }
  170726             : 
  170727           0 :         for (unsigned i = 0; i < SgSIMDBinaryOp::pool_size-1; ++i)
  170728             :            {
  170729           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  170730             :            }
  170731           0 :         pointer[ SgSIMDBinaryOp::pool_size -1 ].set_freepointer(NULL);
  170732             : 
  170733           0 :         blockIndex++;
  170734             :       }
  170735           2 :   }
  170736             : 
  170737             : //############################################################################
  170738             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  170739             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  170740             :  * not compressed. However, that stuff is not yet implemented! 
  170741             :  */
  170742             : unsigned long
  170743           0 : SgSIMDBinaryOp::getNumberOfLastValidPointer()
  170744             :    {
  170745           0 :       SgSIMDBinaryOp* testPointer = (SgSIMDBinaryOp*)(SgSIMDBinaryOp::pools.back());
  170746           0 :       unsigned long localIndex = SgSIMDBinaryOp::pool_size - 1;
  170747           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  170748             :          {
  170749           0 :            localIndex--;
  170750             :          }
  170751           0 :       return (localIndex + SgSIMDBinaryOp::pool_size * (SgSIMDBinaryOp::pools.size()-1));
  170752             :    }
  170753             : 
  170754             : //############################################################################
  170755             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  170756             :  * memory pool and initializes the data member in class SgSIMDBinaryOpStroageClass
  170757             :  * from its counterpart of SgSIMDBinaryOp. The return value is just for checking, 
  170758             :  * that the whole StorageClassArray is initialized!
  170759             :  */
  170760             : unsigned long
  170761           0 : SgSIMDBinaryOp::initializeStorageClassArray( SgSIMDBinaryOpStorageClass *storageArray )
  170762             :    {
  170763           0 :      unsigned long storageCounter = 0;
  170764           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDBinaryOp::pools.begin();
  170765           0 :      SgSIMDBinaryOp* pointer = NULL;
  170766           0 :      while ( block != SgSIMDBinaryOp::pools.end() ) {
  170767           0 :           pointer = (SgSIMDBinaryOp*) (*block);
  170768           0 :           for ( unsigned i = 0; i < SgSIMDBinaryOp::pool_size; ++i ) {
  170769           0 :                if ( pointer->get_freepointer() != NULL ) {
  170770           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  170771           0 :                  storageArray++;
  170772           0 :                  storageCounter++;
  170773             :                }
  170774           0 :                pointer++;
  170775             :              }
  170776           0 :            block++;
  170777             :         }
  170778           0 :      return storageCounter;
  170779             :    }
  170780             : 
  170781             : /* #line 170782 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  170782             : 
  170783             : 
  170784             : 
  170785             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  170786             : 
  170787             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  170788             : 
  170789             : //############################################################################
  170790             : /* JH (02/02/2006) Constructor of the IR node SgSIMDAddOp that takes its 
  170791             :  * corresponding StorageClass as parameter
  170792             :  */
  170793           0 : SgSIMDAddOp :: SgSIMDAddOp ( const SgSIMDAddOpStorageClass& storageSource )   : SgSIMDBinaryOp (storageSource)
  170794             :    {
  170795             : 
  170796             : 
  170797             : /* #line 170798 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  170798             : 
  170799           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  170800             : 
  170801             : 
  170802             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  170803             : 
  170804             : 
  170805           0 :    }
  170806             : 
  170807             : //############################################################################
  170808             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  170809             :  * within the working AST. 
  170810             :  */
  170811           0 : SgSIMDAddOp * SgSIMDAddOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  170812           0 :      SgSIMDAddOp* returnPointer = NULL;
  170813           0 :      if ( globalIndex != 0 )
  170814             :         {
  170815             : 
  170816             : #if FILE_IO_EXTRA_CHECK
  170817           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDAddOp ) ) <= globalIndex ) ;
  170818           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDAddOp + 1 ) ) );
  170819             : #endif
  170820           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDAddOp )  
  170821           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDAddOp );
  170822           0 :           unsigned long positionInPool = localIndex % SgSIMDAddOp::pool_size;
  170823           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDAddOp::pool_size;
  170824             : 
  170825             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  170826             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  170827             : 
  170828           0 :           returnPointer = &( ( (SgSIMDAddOp*)(SgSIMDAddOp::pools[memoryBlock]) ) [positionInPool]) ;
  170829             : 
  170830           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  170831             :         }
  170832           0 :      return returnPointer ;
  170833             :    }
  170834             : 
  170835             : //############################################################################
  170836             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  170837             :   for the AST with the index astIndex
  170838             : */
  170839           0 : SgSIMDAddOp * SgSIMDAddOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  170840           0 :      SgSIMDAddOp* returnPointer = NULL;
  170841           0 :      if ( globalIndex != 0 )
  170842             :         {
  170843             : 
  170844             : #if FILE_IO_EXTRA_CHECK
  170845           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDAddOp ) ) <= globalIndex ) ;
  170846           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDAddOp + 1 ) ) );
  170847             : #endif
  170848           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDAddOp )
  170849           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDAddOp );
  170850           0 :           unsigned long positionInPool = localIndex % SgSIMDAddOp::pool_size ;
  170851           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDAddOp::pool_size ;
  170852             : 
  170853             : #if FILE_IO_EXTRA_CHECK
  170854             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  170855             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  170856             : #endif
  170857             : 
  170858           0 :           returnPointer = &( ( (SgSIMDAddOp*)(SgSIMDAddOp::pools[memoryBlock]) ) [positionInPool]) ;
  170859             : 
  170860             : #if FILE_IO_EXTRA_CHECK
  170861           0 :           assert ( returnPointer != NULL ) ;
  170862             : #endif
  170863             :         }
  170864           0 :      return returnPointer ;
  170865             :    }
  170866             : 
  170867             : //############################################################################
  170868             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  170869             :  * pool size! We set for every valid object in the memory pool the freepointer
  170870             :  * to the global index and increase the global index afterwards. For all the 
  170871             :  * invalid objects (means address ranges within the memory pool that were not
  170872             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  170873             :  * distinguish valid from invalid objects! 
  170874             :  */
  170875             : unsigned long
  170876           5 : SgSIMDAddOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  170877             :    {
  170878           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  170879           5 :      SgSIMDAddOp* pointer = NULL;
  170880           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  170881           5 :      std::vector < unsigned char* > :: const_iterator block;
  170882           5 :      for ( block = SgSIMDAddOp::pools.begin(); block != SgSIMDAddOp::pools.end() ; ++block )
  170883             :         {
  170884           0 :           pointer = (SgSIMDAddOp*)(*block);
  170885           0 :           for (unsigned i = 0; i < SgSIMDAddOp::pool_size; ++i )
  170886             :              {
  170887             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  170888             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  170889             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  170890             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  170891             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  170892             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  170893             :             // properly; so this will have to be checked next.
  170894             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  170895             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  170896           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  170897             :                   {
  170898           0 :                     pointer[i].set_freepointer((SgSIMDAddOp*)(globalIndex));
  170899           0 :                     globalIndex++;
  170900             :                   }
  170901             :                else
  170902             :                   {
  170903           0 :                     pointer[i].set_freepointer(NULL);
  170904             :                   }
  170905             :               }
  170906             :         }
  170907           5 :      return globalIndex;
  170908             :    }
  170909             : 
  170910             : //############################################################################
  170911             : // JH (01/14/2006)
  170912             : void
  170913           5 : SgSIMDAddOp::resetValidFreepointers( )
  170914             :    {
  170915           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  170916           5 :      SgSIMDAddOp* pointer = NULL;
  170917           5 :      std::vector < unsigned char* > :: const_iterator block;
  170918           5 :      SgSIMDAddOp* pointerOfLinkedList = NULL;
  170919           5 :      for ( block = SgSIMDAddOp::pools.begin(); block != SgSIMDAddOp::pools.end() ; ++block )
  170920             :         {
  170921           0 :           pointer = (SgSIMDAddOp*)(*block);
  170922           0 :           for (unsigned i = 0; i < SgSIMDAddOp::pool_size; ++i )
  170923             :              {
  170924             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  170925             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  170926             :             // memory blocks!.
  170927           0 :                if ( pointer[i].get_freepointer() != NULL )
  170928             :                   {
  170929           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  170930             :                   }
  170931             :                else
  170932             :                   {
  170933           0 :                     if ( pointerOfLinkedList == NULL )
  170934             :                        {
  170935           0 :                          SgSIMDAddOp::next_node = &(pointer[i]);
  170936             :                        }
  170937             :                     else
  170938             :                        {
  170939             :                       // printf ("In SgSIMDAddOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  170940           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  170941             :                        }
  170942             :                     pointerOfLinkedList = &(pointer[i]);
  170943             :                   }
  170944             :               }
  170945             :         }
  170946             : 
  170947           5 :      if ( pointerOfLinkedList != NULL )
  170948             :         {
  170949             :        // printf ("In SgSIMDAddOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  170950           0 :           pointerOfLinkedList->set_freepointer(NULL);
  170951             :        // DQ (6/6/2010): Temporary debugging...
  170952             :        //   ROSE_ASSERT(false);
  170953             :         }
  170954             : 
  170955           5 :      return ;
  170956             :    }
  170957             : 
  170958             : //############################################################################
  170959             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  170960             :  * within the memory pool and resets the freepointers, in order to achieve a 
  170961             :  * linked list, that has no jumps and starts at the beginning! This function 
  170962             :  * does not extend the memory pool, since we do not delete any memory blocks,
  170963             :  * but delete the valid objects.  
  170964             :  */
  170965             : void
  170966           0 : SgSIMDAddOp::clearMemoryPool( )
  170967             :    {
  170968             :   // printf ("Inside of SgSIMDAddOp::clearMemoryPool() \n");
  170969             : 
  170970           0 :      SgSIMDAddOp* pointer = NULL, *tempPointer = NULL;
  170971           0 :      std::vector < unsigned char* > :: const_iterator block;
  170972           0 :      if ( SgSIMDAddOp::pools.empty() == false )
  170973             :         {
  170974           0 :           block = SgSIMDAddOp::pools.begin() ;
  170975           0 :           SgSIMDAddOp::next_node = (SgSIMDAddOp*) (*block);
  170976             : 
  170977           0 :           while ( block != SgSIMDAddOp::pools.end() )
  170978             :              {
  170979           0 :                pointer = (SgSIMDAddOp*) (*block);
  170980           0 :                if ( tempPointer != NULL )
  170981             :                   {
  170982           0 :                     tempPointer->set_freepointer(pointer);
  170983             :                   }
  170984           0 :                for (unsigned i = 0; i < SgSIMDAddOp::pool_size - 1; ++i)
  170985             :                   {
  170986           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  170987             :                   }
  170988           0 :                 pointer[SgSIMDAddOp::pool_size-1].set_freepointer(NULL);
  170989           0 :                 tempPointer = &(pointer[SgSIMDAddOp::pool_size-1]);
  170990           0 :                 ++block;
  170991             :              }
  170992             :         }
  170993           0 :    }
  170994             : 
  170995           5 : void SgSIMDAddOp::deleteMemoryPool() {
  170996           5 :   for (auto p: SgSIMDAddOp::pools) {
  170997           0 :     ROSE_FREE(p);
  170998             :   }
  170999           5 :   SgSIMDAddOp::next_node = nullptr;
  171000           5 :   SgSIMDAddOp::pools.clear();
  171001           5 : }
  171002             : 
  171003             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  171004             : //                 reading multiple binary files to for a single AST.
  171005             : /////////// new version ////////////////////////////////
  171006             : //############################################################################
  171007             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  171008             : void
  171009           2 : SgSIMDAddOp::extendMemoryPoolForFileIO( )
  171010             :   {
  171011           2 :     size_t blockIndex = SgSIMDAddOp::pools.size();
  171012           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDAddOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDAddOp);
  171013             : 
  171014           2 :     while ( (blockIndex * SgSIMDAddOp::pool_size) < newPoolSize)
  171015             :       {
  171016             : #if ROSE_ALLOC_TRACE
  171017             :         if (blockIndex > 0) {
  171018             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDAddOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDAddOp) = %" PRIuPTR " SgSIMDAddOp::pool_size = %d \n",
  171019             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDAddOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDAddOp),SgSIMDAddOp::pool_size);
  171020             :         }
  171021             : #endif
  171022             : 
  171023           0 :         SgSIMDAddOp * pointer = (SgSIMDAddOp*) ROSE_MALLOC ( SgSIMDAddOp::pool_size * sizeof(SgSIMDAddOp) );
  171024           0 :         assert( pointer != NULL );
  171025             : #if ROSE_ALLOC_MEMSET == 1
  171026             :         memset(pointer, 0x00, SgSIMDAddOp::pool_size * sizeof(SgSIMDAddOp));
  171027             : #elif ROSE_ALLOC_MEMSET == 2
  171028             :         memset(pointer, 0xCC, SgSIMDAddOp::pool_size * sizeof(SgSIMDAddOp));
  171029             : #endif
  171030           0 :         SgSIMDAddOp::pools.push_back( (unsigned char*)(pointer) );
  171031           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDAddOp::pool_size * sizeof(SgSIMDAddOp), V_SgSIMDAddOp ) );
  171032             : 
  171033           0 :         if ( SgSIMDAddOp::next_node != NULL ) {
  171034           0 :           if ( blockIndex > 0 ) {
  171035           0 :             SgSIMDAddOp * blkptr = (SgSIMDAddOp*)(SgSIMDAddOp::pools[blockIndex-1]);
  171036           0 :             blkptr[ SgSIMDAddOp::pool_size - 1 ].set_freepointer(pointer);
  171037             :           }
  171038             :         } else {
  171039           0 :           SgSIMDAddOp::next_node = pointer;
  171040             :         }
  171041             : 
  171042           0 :         for (unsigned i = 0; i < SgSIMDAddOp::pool_size-1; ++i)
  171043             :            {
  171044           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  171045             :            }
  171046           0 :         pointer[ SgSIMDAddOp::pool_size -1 ].set_freepointer(NULL);
  171047             : 
  171048           0 :         blockIndex++;
  171049             :       }
  171050           2 :   }
  171051             : 
  171052             : //############################################################################
  171053             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  171054             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  171055             :  * not compressed. However, that stuff is not yet implemented! 
  171056             :  */
  171057             : unsigned long
  171058           0 : SgSIMDAddOp::getNumberOfLastValidPointer()
  171059             :    {
  171060           0 :       SgSIMDAddOp* testPointer = (SgSIMDAddOp*)(SgSIMDAddOp::pools.back());
  171061           0 :       unsigned long localIndex = SgSIMDAddOp::pool_size - 1;
  171062           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  171063             :          {
  171064           0 :            localIndex--;
  171065             :          }
  171066           0 :       return (localIndex + SgSIMDAddOp::pool_size * (SgSIMDAddOp::pools.size()-1));
  171067             :    }
  171068             : 
  171069             : //############################################################################
  171070             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  171071             :  * memory pool and initializes the data member in class SgSIMDAddOpStroageClass
  171072             :  * from its counterpart of SgSIMDAddOp. The return value is just for checking, 
  171073             :  * that the whole StorageClassArray is initialized!
  171074             :  */
  171075             : unsigned long
  171076           0 : SgSIMDAddOp::initializeStorageClassArray( SgSIMDAddOpStorageClass *storageArray )
  171077             :    {
  171078           0 :      unsigned long storageCounter = 0;
  171079           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDAddOp::pools.begin();
  171080           0 :      SgSIMDAddOp* pointer = NULL;
  171081           0 :      while ( block != SgSIMDAddOp::pools.end() ) {
  171082           0 :           pointer = (SgSIMDAddOp*) (*block);
  171083           0 :           for ( unsigned i = 0; i < SgSIMDAddOp::pool_size; ++i ) {
  171084           0 :                if ( pointer->get_freepointer() != NULL ) {
  171085           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  171086           0 :                  storageArray++;
  171087           0 :                  storageCounter++;
  171088             :                }
  171089           0 :                pointer++;
  171090             :              }
  171091           0 :            block++;
  171092             :         }
  171093           0 :      return storageCounter;
  171094             :    }
  171095             : 
  171096             : /* #line 171097 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  171097             : 
  171098             : 
  171099             : 
  171100             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  171101             : 
  171102             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  171103             : 
  171104             : //############################################################################
  171105             : /* JH (02/02/2006) Constructor of the IR node SgSIMDSubOp that takes its 
  171106             :  * corresponding StorageClass as parameter
  171107             :  */
  171108           0 : SgSIMDSubOp :: SgSIMDSubOp ( const SgSIMDSubOpStorageClass& storageSource )   : SgSIMDBinaryOp (storageSource)
  171109             :    {
  171110             : 
  171111             : 
  171112             : /* #line 171113 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  171113             : 
  171114           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  171115             : 
  171116             : 
  171117             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  171118             : 
  171119             : 
  171120           0 :    }
  171121             : 
  171122             : //############################################################################
  171123             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  171124             :  * within the working AST. 
  171125             :  */
  171126           0 : SgSIMDSubOp * SgSIMDSubOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  171127           0 :      SgSIMDSubOp* returnPointer = NULL;
  171128           0 :      if ( globalIndex != 0 )
  171129             :         {
  171130             : 
  171131             : #if FILE_IO_EXTRA_CHECK
  171132           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDSubOp ) ) <= globalIndex ) ;
  171133           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDSubOp + 1 ) ) );
  171134             : #endif
  171135           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDSubOp )  
  171136           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDSubOp );
  171137           0 :           unsigned long positionInPool = localIndex % SgSIMDSubOp::pool_size;
  171138           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDSubOp::pool_size;
  171139             : 
  171140             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  171141             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  171142             : 
  171143           0 :           returnPointer = &( ( (SgSIMDSubOp*)(SgSIMDSubOp::pools[memoryBlock]) ) [positionInPool]) ;
  171144             : 
  171145           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  171146             :         }
  171147           0 :      return returnPointer ;
  171148             :    }
  171149             : 
  171150             : //############################################################################
  171151             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  171152             :   for the AST with the index astIndex
  171153             : */
  171154           0 : SgSIMDSubOp * SgSIMDSubOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  171155           0 :      SgSIMDSubOp* returnPointer = NULL;
  171156           0 :      if ( globalIndex != 0 )
  171157             :         {
  171158             : 
  171159             : #if FILE_IO_EXTRA_CHECK
  171160           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDSubOp ) ) <= globalIndex ) ;
  171161           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDSubOp + 1 ) ) );
  171162             : #endif
  171163           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDSubOp )
  171164           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDSubOp );
  171165           0 :           unsigned long positionInPool = localIndex % SgSIMDSubOp::pool_size ;
  171166           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDSubOp::pool_size ;
  171167             : 
  171168             : #if FILE_IO_EXTRA_CHECK
  171169             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  171170             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  171171             : #endif
  171172             : 
  171173           0 :           returnPointer = &( ( (SgSIMDSubOp*)(SgSIMDSubOp::pools[memoryBlock]) ) [positionInPool]) ;
  171174             : 
  171175             : #if FILE_IO_EXTRA_CHECK
  171176           0 :           assert ( returnPointer != NULL ) ;
  171177             : #endif
  171178             :         }
  171179           0 :      return returnPointer ;
  171180             :    }
  171181             : 
  171182             : //############################################################################
  171183             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  171184             :  * pool size! We set for every valid object in the memory pool the freepointer
  171185             :  * to the global index and increase the global index afterwards. For all the 
  171186             :  * invalid objects (means address ranges within the memory pool that were not
  171187             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  171188             :  * distinguish valid from invalid objects! 
  171189             :  */
  171190             : unsigned long
  171191           5 : SgSIMDSubOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  171192             :    {
  171193           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  171194           5 :      SgSIMDSubOp* pointer = NULL;
  171195           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  171196           5 :      std::vector < unsigned char* > :: const_iterator block;
  171197           5 :      for ( block = SgSIMDSubOp::pools.begin(); block != SgSIMDSubOp::pools.end() ; ++block )
  171198             :         {
  171199           0 :           pointer = (SgSIMDSubOp*)(*block);
  171200           0 :           for (unsigned i = 0; i < SgSIMDSubOp::pool_size; ++i )
  171201             :              {
  171202             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  171203             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  171204             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  171205             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  171206             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  171207             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  171208             :             // properly; so this will have to be checked next.
  171209             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  171210             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  171211           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  171212             :                   {
  171213           0 :                     pointer[i].set_freepointer((SgSIMDSubOp*)(globalIndex));
  171214           0 :                     globalIndex++;
  171215             :                   }
  171216             :                else
  171217             :                   {
  171218           0 :                     pointer[i].set_freepointer(NULL);
  171219             :                   }
  171220             :               }
  171221             :         }
  171222           5 :      return globalIndex;
  171223             :    }
  171224             : 
  171225             : //############################################################################
  171226             : // JH (01/14/2006)
  171227             : void
  171228           5 : SgSIMDSubOp::resetValidFreepointers( )
  171229             :    {
  171230           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  171231           5 :      SgSIMDSubOp* pointer = NULL;
  171232           5 :      std::vector < unsigned char* > :: const_iterator block;
  171233           5 :      SgSIMDSubOp* pointerOfLinkedList = NULL;
  171234           5 :      for ( block = SgSIMDSubOp::pools.begin(); block != SgSIMDSubOp::pools.end() ; ++block )
  171235             :         {
  171236           0 :           pointer = (SgSIMDSubOp*)(*block);
  171237           0 :           for (unsigned i = 0; i < SgSIMDSubOp::pool_size; ++i )
  171238             :              {
  171239             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  171240             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  171241             :             // memory blocks!.
  171242           0 :                if ( pointer[i].get_freepointer() != NULL )
  171243             :                   {
  171244           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  171245             :                   }
  171246             :                else
  171247             :                   {
  171248           0 :                     if ( pointerOfLinkedList == NULL )
  171249             :                        {
  171250           0 :                          SgSIMDSubOp::next_node = &(pointer[i]);
  171251             :                        }
  171252             :                     else
  171253             :                        {
  171254             :                       // printf ("In SgSIMDSubOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  171255           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  171256             :                        }
  171257             :                     pointerOfLinkedList = &(pointer[i]);
  171258             :                   }
  171259             :               }
  171260             :         }
  171261             : 
  171262           5 :      if ( pointerOfLinkedList != NULL )
  171263             :         {
  171264             :        // printf ("In SgSIMDSubOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  171265           0 :           pointerOfLinkedList->set_freepointer(NULL);
  171266             :        // DQ (6/6/2010): Temporary debugging...
  171267             :        //   ROSE_ASSERT(false);
  171268             :         }
  171269             : 
  171270           5 :      return ;
  171271             :    }
  171272             : 
  171273             : //############################################################################
  171274             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  171275             :  * within the memory pool and resets the freepointers, in order to achieve a 
  171276             :  * linked list, that has no jumps and starts at the beginning! This function 
  171277             :  * does not extend the memory pool, since we do not delete any memory blocks,
  171278             :  * but delete the valid objects.  
  171279             :  */
  171280             : void
  171281           0 : SgSIMDSubOp::clearMemoryPool( )
  171282             :    {
  171283             :   // printf ("Inside of SgSIMDSubOp::clearMemoryPool() \n");
  171284             : 
  171285           0 :      SgSIMDSubOp* pointer = NULL, *tempPointer = NULL;
  171286           0 :      std::vector < unsigned char* > :: const_iterator block;
  171287           0 :      if ( SgSIMDSubOp::pools.empty() == false )
  171288             :         {
  171289           0 :           block = SgSIMDSubOp::pools.begin() ;
  171290           0 :           SgSIMDSubOp::next_node = (SgSIMDSubOp*) (*block);
  171291             : 
  171292           0 :           while ( block != SgSIMDSubOp::pools.end() )
  171293             :              {
  171294           0 :                pointer = (SgSIMDSubOp*) (*block);
  171295           0 :                if ( tempPointer != NULL )
  171296             :                   {
  171297           0 :                     tempPointer->set_freepointer(pointer);
  171298             :                   }
  171299           0 :                for (unsigned i = 0; i < SgSIMDSubOp::pool_size - 1; ++i)
  171300             :                   {
  171301           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  171302             :                   }
  171303           0 :                 pointer[SgSIMDSubOp::pool_size-1].set_freepointer(NULL);
  171304           0 :                 tempPointer = &(pointer[SgSIMDSubOp::pool_size-1]);
  171305           0 :                 ++block;
  171306             :              }
  171307             :         }
  171308           0 :    }
  171309             : 
  171310           5 : void SgSIMDSubOp::deleteMemoryPool() {
  171311           5 :   for (auto p: SgSIMDSubOp::pools) {
  171312           0 :     ROSE_FREE(p);
  171313             :   }
  171314           5 :   SgSIMDSubOp::next_node = nullptr;
  171315           5 :   SgSIMDSubOp::pools.clear();
  171316           5 : }
  171317             : 
  171318             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  171319             : //                 reading multiple binary files to for a single AST.
  171320             : /////////// new version ////////////////////////////////
  171321             : //############################################################################
  171322             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  171323             : void
  171324           2 : SgSIMDSubOp::extendMemoryPoolForFileIO( )
  171325             :   {
  171326           2 :     size_t blockIndex = SgSIMDSubOp::pools.size();
  171327           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDSubOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDSubOp);
  171328             : 
  171329           2 :     while ( (blockIndex * SgSIMDSubOp::pool_size) < newPoolSize)
  171330             :       {
  171331             : #if ROSE_ALLOC_TRACE
  171332             :         if (blockIndex > 0) {
  171333             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDSubOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDSubOp) = %" PRIuPTR " SgSIMDSubOp::pool_size = %d \n",
  171334             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDSubOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDSubOp),SgSIMDSubOp::pool_size);
  171335             :         }
  171336             : #endif
  171337             : 
  171338           0 :         SgSIMDSubOp * pointer = (SgSIMDSubOp*) ROSE_MALLOC ( SgSIMDSubOp::pool_size * sizeof(SgSIMDSubOp) );
  171339           0 :         assert( pointer != NULL );
  171340             : #if ROSE_ALLOC_MEMSET == 1
  171341             :         memset(pointer, 0x00, SgSIMDSubOp::pool_size * sizeof(SgSIMDSubOp));
  171342             : #elif ROSE_ALLOC_MEMSET == 2
  171343             :         memset(pointer, 0xCC, SgSIMDSubOp::pool_size * sizeof(SgSIMDSubOp));
  171344             : #endif
  171345           0 :         SgSIMDSubOp::pools.push_back( (unsigned char*)(pointer) );
  171346           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDSubOp::pool_size * sizeof(SgSIMDSubOp), V_SgSIMDSubOp ) );
  171347             : 
  171348           0 :         if ( SgSIMDSubOp::next_node != NULL ) {
  171349           0 :           if ( blockIndex > 0 ) {
  171350           0 :             SgSIMDSubOp * blkptr = (SgSIMDSubOp*)(SgSIMDSubOp::pools[blockIndex-1]);
  171351           0 :             blkptr[ SgSIMDSubOp::pool_size - 1 ].set_freepointer(pointer);
  171352             :           }
  171353             :         } else {
  171354           0 :           SgSIMDSubOp::next_node = pointer;
  171355             :         }
  171356             : 
  171357           0 :         for (unsigned i = 0; i < SgSIMDSubOp::pool_size-1; ++i)
  171358             :            {
  171359           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  171360             :            }
  171361           0 :         pointer[ SgSIMDSubOp::pool_size -1 ].set_freepointer(NULL);
  171362             : 
  171363           0 :         blockIndex++;
  171364             :       }
  171365           2 :   }
  171366             : 
  171367             : //############################################################################
  171368             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  171369             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  171370             :  * not compressed. However, that stuff is not yet implemented! 
  171371             :  */
  171372             : unsigned long
  171373           0 : SgSIMDSubOp::getNumberOfLastValidPointer()
  171374             :    {
  171375           0 :       SgSIMDSubOp* testPointer = (SgSIMDSubOp*)(SgSIMDSubOp::pools.back());
  171376           0 :       unsigned long localIndex = SgSIMDSubOp::pool_size - 1;
  171377           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  171378             :          {
  171379           0 :            localIndex--;
  171380             :          }
  171381           0 :       return (localIndex + SgSIMDSubOp::pool_size * (SgSIMDSubOp::pools.size()-1));
  171382             :    }
  171383             : 
  171384             : //############################################################################
  171385             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  171386             :  * memory pool and initializes the data member in class SgSIMDSubOpStroageClass
  171387             :  * from its counterpart of SgSIMDSubOp. The return value is just for checking, 
  171388             :  * that the whole StorageClassArray is initialized!
  171389             :  */
  171390             : unsigned long
  171391           0 : SgSIMDSubOp::initializeStorageClassArray( SgSIMDSubOpStorageClass *storageArray )
  171392             :    {
  171393           0 :      unsigned long storageCounter = 0;
  171394           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDSubOp::pools.begin();
  171395           0 :      SgSIMDSubOp* pointer = NULL;
  171396           0 :      while ( block != SgSIMDSubOp::pools.end() ) {
  171397           0 :           pointer = (SgSIMDSubOp*) (*block);
  171398           0 :           for ( unsigned i = 0; i < SgSIMDSubOp::pool_size; ++i ) {
  171399           0 :                if ( pointer->get_freepointer() != NULL ) {
  171400           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  171401           0 :                  storageArray++;
  171402           0 :                  storageCounter++;
  171403             :                }
  171404           0 :                pointer++;
  171405             :              }
  171406           0 :            block++;
  171407             :         }
  171408           0 :      return storageCounter;
  171409             :    }
  171410             : 
  171411             : /* #line 171412 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  171412             : 
  171413             : 
  171414             : 
  171415             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  171416             : 
  171417             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  171418             : 
  171419             : //############################################################################
  171420             : /* JH (02/02/2006) Constructor of the IR node SgSIMDMulOp that takes its 
  171421             :  * corresponding StorageClass as parameter
  171422             :  */
  171423           0 : SgSIMDMulOp :: SgSIMDMulOp ( const SgSIMDMulOpStorageClass& storageSource )   : SgSIMDBinaryOp (storageSource)
  171424             :    {
  171425             : 
  171426             : 
  171427             : /* #line 171428 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  171428             : 
  171429           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  171430             : 
  171431             : 
  171432             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  171433             : 
  171434             : 
  171435           0 :    }
  171436             : 
  171437             : //############################################################################
  171438             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  171439             :  * within the working AST. 
  171440             :  */
  171441           0 : SgSIMDMulOp * SgSIMDMulOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  171442           0 :      SgSIMDMulOp* returnPointer = NULL;
  171443           0 :      if ( globalIndex != 0 )
  171444             :         {
  171445             : 
  171446             : #if FILE_IO_EXTRA_CHECK
  171447           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDMulOp ) ) <= globalIndex ) ;
  171448           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDMulOp + 1 ) ) );
  171449             : #endif
  171450           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDMulOp )  
  171451           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDMulOp );
  171452           0 :           unsigned long positionInPool = localIndex % SgSIMDMulOp::pool_size;
  171453           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDMulOp::pool_size;
  171454             : 
  171455             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  171456             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  171457             : 
  171458           0 :           returnPointer = &( ( (SgSIMDMulOp*)(SgSIMDMulOp::pools[memoryBlock]) ) [positionInPool]) ;
  171459             : 
  171460           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  171461             :         }
  171462           0 :      return returnPointer ;
  171463             :    }
  171464             : 
  171465             : //############################################################################
  171466             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  171467             :   for the AST with the index astIndex
  171468             : */
  171469           0 : SgSIMDMulOp * SgSIMDMulOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  171470           0 :      SgSIMDMulOp* returnPointer = NULL;
  171471           0 :      if ( globalIndex != 0 )
  171472             :         {
  171473             : 
  171474             : #if FILE_IO_EXTRA_CHECK
  171475           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDMulOp ) ) <= globalIndex ) ;
  171476           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDMulOp + 1 ) ) );
  171477             : #endif
  171478           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDMulOp )
  171479           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDMulOp );
  171480           0 :           unsigned long positionInPool = localIndex % SgSIMDMulOp::pool_size ;
  171481           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDMulOp::pool_size ;
  171482             : 
  171483             : #if FILE_IO_EXTRA_CHECK
  171484             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  171485             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  171486             : #endif
  171487             : 
  171488           0 :           returnPointer = &( ( (SgSIMDMulOp*)(SgSIMDMulOp::pools[memoryBlock]) ) [positionInPool]) ;
  171489             : 
  171490             : #if FILE_IO_EXTRA_CHECK
  171491           0 :           assert ( returnPointer != NULL ) ;
  171492             : #endif
  171493             :         }
  171494           0 :      return returnPointer ;
  171495             :    }
  171496             : 
  171497             : //############################################################################
  171498             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  171499             :  * pool size! We set for every valid object in the memory pool the freepointer
  171500             :  * to the global index and increase the global index afterwards. For all the 
  171501             :  * invalid objects (means address ranges within the memory pool that were not
  171502             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  171503             :  * distinguish valid from invalid objects! 
  171504             :  */
  171505             : unsigned long
  171506           5 : SgSIMDMulOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  171507             :    {
  171508           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  171509           5 :      SgSIMDMulOp* pointer = NULL;
  171510           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  171511           5 :      std::vector < unsigned char* > :: const_iterator block;
  171512           5 :      for ( block = SgSIMDMulOp::pools.begin(); block != SgSIMDMulOp::pools.end() ; ++block )
  171513             :         {
  171514           0 :           pointer = (SgSIMDMulOp*)(*block);
  171515           0 :           for (unsigned i = 0; i < SgSIMDMulOp::pool_size; ++i )
  171516             :              {
  171517             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  171518             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  171519             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  171520             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  171521             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  171522             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  171523             :             // properly; so this will have to be checked next.
  171524             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  171525             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  171526           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  171527             :                   {
  171528           0 :                     pointer[i].set_freepointer((SgSIMDMulOp*)(globalIndex));
  171529           0 :                     globalIndex++;
  171530             :                   }
  171531             :                else
  171532             :                   {
  171533           0 :                     pointer[i].set_freepointer(NULL);
  171534             :                   }
  171535             :               }
  171536             :         }
  171537           5 :      return globalIndex;
  171538             :    }
  171539             : 
  171540             : //############################################################################
  171541             : // JH (01/14/2006)
  171542             : void
  171543           5 : SgSIMDMulOp::resetValidFreepointers( )
  171544             :    {
  171545           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  171546           5 :      SgSIMDMulOp* pointer = NULL;
  171547           5 :      std::vector < unsigned char* > :: const_iterator block;
  171548           5 :      SgSIMDMulOp* pointerOfLinkedList = NULL;
  171549           5 :      for ( block = SgSIMDMulOp::pools.begin(); block != SgSIMDMulOp::pools.end() ; ++block )
  171550             :         {
  171551           0 :           pointer = (SgSIMDMulOp*)(*block);
  171552           0 :           for (unsigned i = 0; i < SgSIMDMulOp::pool_size; ++i )
  171553             :              {
  171554             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  171555             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  171556             :             // memory blocks!.
  171557           0 :                if ( pointer[i].get_freepointer() != NULL )
  171558             :                   {
  171559           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  171560             :                   }
  171561             :                else
  171562             :                   {
  171563           0 :                     if ( pointerOfLinkedList == NULL )
  171564             :                        {
  171565           0 :                          SgSIMDMulOp::next_node = &(pointer[i]);
  171566             :                        }
  171567             :                     else
  171568             :                        {
  171569             :                       // printf ("In SgSIMDMulOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  171570           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  171571             :                        }
  171572             :                     pointerOfLinkedList = &(pointer[i]);
  171573             :                   }
  171574             :               }
  171575             :         }
  171576             : 
  171577           5 :      if ( pointerOfLinkedList != NULL )
  171578             :         {
  171579             :        // printf ("In SgSIMDMulOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  171580           0 :           pointerOfLinkedList->set_freepointer(NULL);
  171581             :        // DQ (6/6/2010): Temporary debugging...
  171582             :        //   ROSE_ASSERT(false);
  171583             :         }
  171584             : 
  171585           5 :      return ;
  171586             :    }
  171587             : 
  171588             : //############################################################################
  171589             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  171590             :  * within the memory pool and resets the freepointers, in order to achieve a 
  171591             :  * linked list, that has no jumps and starts at the beginning! This function 
  171592             :  * does not extend the memory pool, since we do not delete any memory blocks,
  171593             :  * but delete the valid objects.  
  171594             :  */
  171595             : void
  171596           0 : SgSIMDMulOp::clearMemoryPool( )
  171597             :    {
  171598             :   // printf ("Inside of SgSIMDMulOp::clearMemoryPool() \n");
  171599             : 
  171600           0 :      SgSIMDMulOp* pointer = NULL, *tempPointer = NULL;
  171601           0 :      std::vector < unsigned char* > :: const_iterator block;
  171602           0 :      if ( SgSIMDMulOp::pools.empty() == false )
  171603             :         {
  171604           0 :           block = SgSIMDMulOp::pools.begin() ;
  171605           0 :           SgSIMDMulOp::next_node = (SgSIMDMulOp*) (*block);
  171606             : 
  171607           0 :           while ( block != SgSIMDMulOp::pools.end() )
  171608             :              {
  171609           0 :                pointer = (SgSIMDMulOp*) (*block);
  171610           0 :                if ( tempPointer != NULL )
  171611             :                   {
  171612           0 :                     tempPointer->set_freepointer(pointer);
  171613             :                   }
  171614           0 :                for (unsigned i = 0; i < SgSIMDMulOp::pool_size - 1; ++i)
  171615             :                   {
  171616           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  171617             :                   }
  171618           0 :                 pointer[SgSIMDMulOp::pool_size-1].set_freepointer(NULL);
  171619           0 :                 tempPointer = &(pointer[SgSIMDMulOp::pool_size-1]);
  171620           0 :                 ++block;
  171621             :              }
  171622             :         }
  171623           0 :    }
  171624             : 
  171625           5 : void SgSIMDMulOp::deleteMemoryPool() {
  171626           5 :   for (auto p: SgSIMDMulOp::pools) {
  171627           0 :     ROSE_FREE(p);
  171628             :   }
  171629           5 :   SgSIMDMulOp::next_node = nullptr;
  171630           5 :   SgSIMDMulOp::pools.clear();
  171631           5 : }
  171632             : 
  171633             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  171634             : //                 reading multiple binary files to for a single AST.
  171635             : /////////// new version ////////////////////////////////
  171636             : //############################################################################
  171637             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  171638             : void
  171639           2 : SgSIMDMulOp::extendMemoryPoolForFileIO( )
  171640             :   {
  171641           2 :     size_t blockIndex = SgSIMDMulOp::pools.size();
  171642           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDMulOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDMulOp);
  171643             : 
  171644           2 :     while ( (blockIndex * SgSIMDMulOp::pool_size) < newPoolSize)
  171645             :       {
  171646             : #if ROSE_ALLOC_TRACE
  171647             :         if (blockIndex > 0) {
  171648             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDMulOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDMulOp) = %" PRIuPTR " SgSIMDMulOp::pool_size = %d \n",
  171649             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDMulOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDMulOp),SgSIMDMulOp::pool_size);
  171650             :         }
  171651             : #endif
  171652             : 
  171653           0 :         SgSIMDMulOp * pointer = (SgSIMDMulOp*) ROSE_MALLOC ( SgSIMDMulOp::pool_size * sizeof(SgSIMDMulOp) );
  171654           0 :         assert( pointer != NULL );
  171655             : #if ROSE_ALLOC_MEMSET == 1
  171656             :         memset(pointer, 0x00, SgSIMDMulOp::pool_size * sizeof(SgSIMDMulOp));
  171657             : #elif ROSE_ALLOC_MEMSET == 2
  171658             :         memset(pointer, 0xCC, SgSIMDMulOp::pool_size * sizeof(SgSIMDMulOp));
  171659             : #endif
  171660           0 :         SgSIMDMulOp::pools.push_back( (unsigned char*)(pointer) );
  171661           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDMulOp::pool_size * sizeof(SgSIMDMulOp), V_SgSIMDMulOp ) );
  171662             : 
  171663           0 :         if ( SgSIMDMulOp::next_node != NULL ) {
  171664           0 :           if ( blockIndex > 0 ) {
  171665           0 :             SgSIMDMulOp * blkptr = (SgSIMDMulOp*)(SgSIMDMulOp::pools[blockIndex-1]);
  171666           0 :             blkptr[ SgSIMDMulOp::pool_size - 1 ].set_freepointer(pointer);
  171667             :           }
  171668             :         } else {
  171669           0 :           SgSIMDMulOp::next_node = pointer;
  171670             :         }
  171671             : 
  171672           0 :         for (unsigned i = 0; i < SgSIMDMulOp::pool_size-1; ++i)
  171673             :            {
  171674           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  171675             :            }
  171676           0 :         pointer[ SgSIMDMulOp::pool_size -1 ].set_freepointer(NULL);
  171677             : 
  171678           0 :         blockIndex++;
  171679             :       }
  171680           2 :   }
  171681             : 
  171682             : //############################################################################
  171683             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  171684             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  171685             :  * not compressed. However, that stuff is not yet implemented! 
  171686             :  */
  171687             : unsigned long
  171688           0 : SgSIMDMulOp::getNumberOfLastValidPointer()
  171689             :    {
  171690           0 :       SgSIMDMulOp* testPointer = (SgSIMDMulOp*)(SgSIMDMulOp::pools.back());
  171691           0 :       unsigned long localIndex = SgSIMDMulOp::pool_size - 1;
  171692           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  171693             :          {
  171694           0 :            localIndex--;
  171695             :          }
  171696           0 :       return (localIndex + SgSIMDMulOp::pool_size * (SgSIMDMulOp::pools.size()-1));
  171697             :    }
  171698             : 
  171699             : //############################################################################
  171700             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  171701             :  * memory pool and initializes the data member in class SgSIMDMulOpStroageClass
  171702             :  * from its counterpart of SgSIMDMulOp. The return value is just for checking, 
  171703             :  * that the whole StorageClassArray is initialized!
  171704             :  */
  171705             : unsigned long
  171706           0 : SgSIMDMulOp::initializeStorageClassArray( SgSIMDMulOpStorageClass *storageArray )
  171707             :    {
  171708           0 :      unsigned long storageCounter = 0;
  171709           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDMulOp::pools.begin();
  171710           0 :      SgSIMDMulOp* pointer = NULL;
  171711           0 :      while ( block != SgSIMDMulOp::pools.end() ) {
  171712           0 :           pointer = (SgSIMDMulOp*) (*block);
  171713           0 :           for ( unsigned i = 0; i < SgSIMDMulOp::pool_size; ++i ) {
  171714           0 :                if ( pointer->get_freepointer() != NULL ) {
  171715           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  171716           0 :                  storageArray++;
  171717           0 :                  storageCounter++;
  171718             :                }
  171719           0 :                pointer++;
  171720             :              }
  171721           0 :            block++;
  171722             :         }
  171723           0 :      return storageCounter;
  171724             :    }
  171725             : 
  171726             : /* #line 171727 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  171727             : 
  171728             : 
  171729             : 
  171730             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  171731             : 
  171732             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  171733             : 
  171734             : //############################################################################
  171735             : /* JH (02/02/2006) Constructor of the IR node SgSIMDDivOp that takes its 
  171736             :  * corresponding StorageClass as parameter
  171737             :  */
  171738           0 : SgSIMDDivOp :: SgSIMDDivOp ( const SgSIMDDivOpStorageClass& storageSource )   : SgSIMDBinaryOp (storageSource)
  171739             :    {
  171740             : 
  171741             : 
  171742             : /* #line 171743 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  171743             : 
  171744           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  171745             : 
  171746             : 
  171747             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  171748             : 
  171749             : 
  171750           0 :    }
  171751             : 
  171752             : //############################################################################
  171753             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  171754             :  * within the working AST. 
  171755             :  */
  171756           0 : SgSIMDDivOp * SgSIMDDivOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  171757           0 :      SgSIMDDivOp* returnPointer = NULL;
  171758           0 :      if ( globalIndex != 0 )
  171759             :         {
  171760             : 
  171761             : #if FILE_IO_EXTRA_CHECK
  171762           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDDivOp ) ) <= globalIndex ) ;
  171763           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDDivOp + 1 ) ) );
  171764             : #endif
  171765           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDDivOp )  
  171766           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDDivOp );
  171767           0 :           unsigned long positionInPool = localIndex % SgSIMDDivOp::pool_size;
  171768           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDDivOp::pool_size;
  171769             : 
  171770             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  171771             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  171772             : 
  171773           0 :           returnPointer = &( ( (SgSIMDDivOp*)(SgSIMDDivOp::pools[memoryBlock]) ) [positionInPool]) ;
  171774             : 
  171775           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  171776             :         }
  171777           0 :      return returnPointer ;
  171778             :    }
  171779             : 
  171780             : //############################################################################
  171781             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  171782             :   for the AST with the index astIndex
  171783             : */
  171784           0 : SgSIMDDivOp * SgSIMDDivOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  171785           0 :      SgSIMDDivOp* returnPointer = NULL;
  171786           0 :      if ( globalIndex != 0 )
  171787             :         {
  171788             : 
  171789             : #if FILE_IO_EXTRA_CHECK
  171790           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDDivOp ) ) <= globalIndex ) ;
  171791           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDDivOp + 1 ) ) );
  171792             : #endif
  171793           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDDivOp )
  171794           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDDivOp );
  171795           0 :           unsigned long positionInPool = localIndex % SgSIMDDivOp::pool_size ;
  171796           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDDivOp::pool_size ;
  171797             : 
  171798             : #if FILE_IO_EXTRA_CHECK
  171799             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  171800             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  171801             : #endif
  171802             : 
  171803           0 :           returnPointer = &( ( (SgSIMDDivOp*)(SgSIMDDivOp::pools[memoryBlock]) ) [positionInPool]) ;
  171804             : 
  171805             : #if FILE_IO_EXTRA_CHECK
  171806           0 :           assert ( returnPointer != NULL ) ;
  171807             : #endif
  171808             :         }
  171809           0 :      return returnPointer ;
  171810             :    }
  171811             : 
  171812             : //############################################################################
  171813             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  171814             :  * pool size! We set for every valid object in the memory pool the freepointer
  171815             :  * to the global index and increase the global index afterwards. For all the 
  171816             :  * invalid objects (means address ranges within the memory pool that were not
  171817             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  171818             :  * distinguish valid from invalid objects! 
  171819             :  */
  171820             : unsigned long
  171821           5 : SgSIMDDivOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  171822             :    {
  171823           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  171824           5 :      SgSIMDDivOp* pointer = NULL;
  171825           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  171826           5 :      std::vector < unsigned char* > :: const_iterator block;
  171827           5 :      for ( block = SgSIMDDivOp::pools.begin(); block != SgSIMDDivOp::pools.end() ; ++block )
  171828             :         {
  171829           0 :           pointer = (SgSIMDDivOp*)(*block);
  171830           0 :           for (unsigned i = 0; i < SgSIMDDivOp::pool_size; ++i )
  171831             :              {
  171832             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  171833             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  171834             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  171835             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  171836             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  171837             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  171838             :             // properly; so this will have to be checked next.
  171839             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  171840             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  171841           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  171842             :                   {
  171843           0 :                     pointer[i].set_freepointer((SgSIMDDivOp*)(globalIndex));
  171844           0 :                     globalIndex++;
  171845             :                   }
  171846             :                else
  171847             :                   {
  171848           0 :                     pointer[i].set_freepointer(NULL);
  171849             :                   }
  171850             :               }
  171851             :         }
  171852           5 :      return globalIndex;
  171853             :    }
  171854             : 
  171855             : //############################################################################
  171856             : // JH (01/14/2006)
  171857             : void
  171858           5 : SgSIMDDivOp::resetValidFreepointers( )
  171859             :    {
  171860           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  171861           5 :      SgSIMDDivOp* pointer = NULL;
  171862           5 :      std::vector < unsigned char* > :: const_iterator block;
  171863           5 :      SgSIMDDivOp* pointerOfLinkedList = NULL;
  171864           5 :      for ( block = SgSIMDDivOp::pools.begin(); block != SgSIMDDivOp::pools.end() ; ++block )
  171865             :         {
  171866           0 :           pointer = (SgSIMDDivOp*)(*block);
  171867           0 :           for (unsigned i = 0; i < SgSIMDDivOp::pool_size; ++i )
  171868             :              {
  171869             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  171870             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  171871             :             // memory blocks!.
  171872           0 :                if ( pointer[i].get_freepointer() != NULL )
  171873             :                   {
  171874           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  171875             :                   }
  171876             :                else
  171877             :                   {
  171878           0 :                     if ( pointerOfLinkedList == NULL )
  171879             :                        {
  171880           0 :                          SgSIMDDivOp::next_node = &(pointer[i]);
  171881             :                        }
  171882             :                     else
  171883             :                        {
  171884             :                       // printf ("In SgSIMDDivOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  171885           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  171886             :                        }
  171887             :                     pointerOfLinkedList = &(pointer[i]);
  171888             :                   }
  171889             :               }
  171890             :         }
  171891             : 
  171892           5 :      if ( pointerOfLinkedList != NULL )
  171893             :         {
  171894             :        // printf ("In SgSIMDDivOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  171895           0 :           pointerOfLinkedList->set_freepointer(NULL);
  171896             :        // DQ (6/6/2010): Temporary debugging...
  171897             :        //   ROSE_ASSERT(false);
  171898             :         }
  171899             : 
  171900           5 :      return ;
  171901             :    }
  171902             : 
  171903             : //############################################################################
  171904             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  171905             :  * within the memory pool and resets the freepointers, in order to achieve a 
  171906             :  * linked list, that has no jumps and starts at the beginning! This function 
  171907             :  * does not extend the memory pool, since we do not delete any memory blocks,
  171908             :  * but delete the valid objects.  
  171909             :  */
  171910             : void
  171911           0 : SgSIMDDivOp::clearMemoryPool( )
  171912             :    {
  171913             :   // printf ("Inside of SgSIMDDivOp::clearMemoryPool() \n");
  171914             : 
  171915           0 :      SgSIMDDivOp* pointer = NULL, *tempPointer = NULL;
  171916           0 :      std::vector < unsigned char* > :: const_iterator block;
  171917           0 :      if ( SgSIMDDivOp::pools.empty() == false )
  171918             :         {
  171919           0 :           block = SgSIMDDivOp::pools.begin() ;
  171920           0 :           SgSIMDDivOp::next_node = (SgSIMDDivOp*) (*block);
  171921             : 
  171922           0 :           while ( block != SgSIMDDivOp::pools.end() )
  171923             :              {
  171924           0 :                pointer = (SgSIMDDivOp*) (*block);
  171925           0 :                if ( tempPointer != NULL )
  171926             :                   {
  171927           0 :                     tempPointer->set_freepointer(pointer);
  171928             :                   }
  171929           0 :                for (unsigned i = 0; i < SgSIMDDivOp::pool_size - 1; ++i)
  171930             :                   {
  171931           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  171932             :                   }
  171933           0 :                 pointer[SgSIMDDivOp::pool_size-1].set_freepointer(NULL);
  171934           0 :                 tempPointer = &(pointer[SgSIMDDivOp::pool_size-1]);
  171935           0 :                 ++block;
  171936             :              }
  171937             :         }
  171938           0 :    }
  171939             : 
  171940           5 : void SgSIMDDivOp::deleteMemoryPool() {
  171941           5 :   for (auto p: SgSIMDDivOp::pools) {
  171942           0 :     ROSE_FREE(p);
  171943             :   }
  171944           5 :   SgSIMDDivOp::next_node = nullptr;
  171945           5 :   SgSIMDDivOp::pools.clear();
  171946           5 : }
  171947             : 
  171948             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  171949             : //                 reading multiple binary files to for a single AST.
  171950             : /////////// new version ////////////////////////////////
  171951             : //############################################################################
  171952             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  171953             : void
  171954           2 : SgSIMDDivOp::extendMemoryPoolForFileIO( )
  171955             :   {
  171956           2 :     size_t blockIndex = SgSIMDDivOp::pools.size();
  171957           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDDivOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDDivOp);
  171958             : 
  171959           2 :     while ( (blockIndex * SgSIMDDivOp::pool_size) < newPoolSize)
  171960             :       {
  171961             : #if ROSE_ALLOC_TRACE
  171962             :         if (blockIndex > 0) {
  171963             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDDivOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDDivOp) = %" PRIuPTR " SgSIMDDivOp::pool_size = %d \n",
  171964             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDDivOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDDivOp),SgSIMDDivOp::pool_size);
  171965             :         }
  171966             : #endif
  171967             : 
  171968           0 :         SgSIMDDivOp * pointer = (SgSIMDDivOp*) ROSE_MALLOC ( SgSIMDDivOp::pool_size * sizeof(SgSIMDDivOp) );
  171969           0 :         assert( pointer != NULL );
  171970             : #if ROSE_ALLOC_MEMSET == 1
  171971             :         memset(pointer, 0x00, SgSIMDDivOp::pool_size * sizeof(SgSIMDDivOp));
  171972             : #elif ROSE_ALLOC_MEMSET == 2
  171973             :         memset(pointer, 0xCC, SgSIMDDivOp::pool_size * sizeof(SgSIMDDivOp));
  171974             : #endif
  171975           0 :         SgSIMDDivOp::pools.push_back( (unsigned char*)(pointer) );
  171976           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDDivOp::pool_size * sizeof(SgSIMDDivOp), V_SgSIMDDivOp ) );
  171977             : 
  171978           0 :         if ( SgSIMDDivOp::next_node != NULL ) {
  171979           0 :           if ( blockIndex > 0 ) {
  171980           0 :             SgSIMDDivOp * blkptr = (SgSIMDDivOp*)(SgSIMDDivOp::pools[blockIndex-1]);
  171981           0 :             blkptr[ SgSIMDDivOp::pool_size - 1 ].set_freepointer(pointer);
  171982             :           }
  171983             :         } else {
  171984           0 :           SgSIMDDivOp::next_node = pointer;
  171985             :         }
  171986             : 
  171987           0 :         for (unsigned i = 0; i < SgSIMDDivOp::pool_size-1; ++i)
  171988             :            {
  171989           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  171990             :            }
  171991           0 :         pointer[ SgSIMDDivOp::pool_size -1 ].set_freepointer(NULL);
  171992             : 
  171993           0 :         blockIndex++;
  171994             :       }
  171995           2 :   }
  171996             : 
  171997             : //############################################################################
  171998             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  171999             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  172000             :  * not compressed. However, that stuff is not yet implemented! 
  172001             :  */
  172002             : unsigned long
  172003           0 : SgSIMDDivOp::getNumberOfLastValidPointer()
  172004             :    {
  172005           0 :       SgSIMDDivOp* testPointer = (SgSIMDDivOp*)(SgSIMDDivOp::pools.back());
  172006           0 :       unsigned long localIndex = SgSIMDDivOp::pool_size - 1;
  172007           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  172008             :          {
  172009           0 :            localIndex--;
  172010             :          }
  172011           0 :       return (localIndex + SgSIMDDivOp::pool_size * (SgSIMDDivOp::pools.size()-1));
  172012             :    }
  172013             : 
  172014             : //############################################################################
  172015             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  172016             :  * memory pool and initializes the data member in class SgSIMDDivOpStroageClass
  172017             :  * from its counterpart of SgSIMDDivOp. The return value is just for checking, 
  172018             :  * that the whole StorageClassArray is initialized!
  172019             :  */
  172020             : unsigned long
  172021           0 : SgSIMDDivOp::initializeStorageClassArray( SgSIMDDivOpStorageClass *storageArray )
  172022             :    {
  172023           0 :      unsigned long storageCounter = 0;
  172024           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDDivOp::pools.begin();
  172025           0 :      SgSIMDDivOp* pointer = NULL;
  172026           0 :      while ( block != SgSIMDDivOp::pools.end() ) {
  172027           0 :           pointer = (SgSIMDDivOp*) (*block);
  172028           0 :           for ( unsigned i = 0; i < SgSIMDDivOp::pool_size; ++i ) {
  172029           0 :                if ( pointer->get_freepointer() != NULL ) {
  172030           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  172031           0 :                  storageArray++;
  172032           0 :                  storageCounter++;
  172033             :                }
  172034           0 :                pointer++;
  172035             :              }
  172036           0 :            block++;
  172037             :         }
  172038           0 :      return storageCounter;
  172039             :    }
  172040             : 
  172041             : /* #line 172042 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  172042             : 
  172043             : 
  172044             : 
  172045             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  172046             : 
  172047             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  172048             : 
  172049             : //############################################################################
  172050             : /* JH (02/02/2006) Constructor of the IR node SgSIMDFmaOp that takes its 
  172051             :  * corresponding StorageClass as parameter
  172052             :  */
  172053           0 : SgSIMDFmaOp :: SgSIMDFmaOp ( const SgSIMDFmaOpStorageClass& storageSource )   : SgSIMDBinaryOp (storageSource)
  172054             :    {
  172055             : 
  172056             : 
  172057             : /* #line 172058 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  172058             : 
  172059           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  172060             : 
  172061             : 
  172062             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  172063             : 
  172064             : 
  172065           0 :    }
  172066             : 
  172067             : //############################################################################
  172068             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  172069             :  * within the working AST. 
  172070             :  */
  172071           0 : SgSIMDFmaOp * SgSIMDFmaOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  172072           0 :      SgSIMDFmaOp* returnPointer = NULL;
  172073           0 :      if ( globalIndex != 0 )
  172074             :         {
  172075             : 
  172076             : #if FILE_IO_EXTRA_CHECK
  172077           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDFmaOp ) ) <= globalIndex ) ;
  172078           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDFmaOp + 1 ) ) );
  172079             : #endif
  172080           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDFmaOp )  
  172081           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDFmaOp );
  172082           0 :           unsigned long positionInPool = localIndex % SgSIMDFmaOp::pool_size;
  172083           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDFmaOp::pool_size;
  172084             : 
  172085             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  172086             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  172087             : 
  172088           0 :           returnPointer = &( ( (SgSIMDFmaOp*)(SgSIMDFmaOp::pools[memoryBlock]) ) [positionInPool]) ;
  172089             : 
  172090           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  172091             :         }
  172092           0 :      return returnPointer ;
  172093             :    }
  172094             : 
  172095             : //############################################################################
  172096             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  172097             :   for the AST with the index astIndex
  172098             : */
  172099           0 : SgSIMDFmaOp * SgSIMDFmaOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  172100           0 :      SgSIMDFmaOp* returnPointer = NULL;
  172101           0 :      if ( globalIndex != 0 )
  172102             :         {
  172103             : 
  172104             : #if FILE_IO_EXTRA_CHECK
  172105           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDFmaOp ) ) <= globalIndex ) ;
  172106           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDFmaOp + 1 ) ) );
  172107             : #endif
  172108           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDFmaOp )
  172109           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDFmaOp );
  172110           0 :           unsigned long positionInPool = localIndex % SgSIMDFmaOp::pool_size ;
  172111           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDFmaOp::pool_size ;
  172112             : 
  172113             : #if FILE_IO_EXTRA_CHECK
  172114             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  172115             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  172116             : #endif
  172117             : 
  172118           0 :           returnPointer = &( ( (SgSIMDFmaOp*)(SgSIMDFmaOp::pools[memoryBlock]) ) [positionInPool]) ;
  172119             : 
  172120             : #if FILE_IO_EXTRA_CHECK
  172121           0 :           assert ( returnPointer != NULL ) ;
  172122             : #endif
  172123             :         }
  172124           0 :      return returnPointer ;
  172125             :    }
  172126             : 
  172127             : //############################################################################
  172128             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  172129             :  * pool size! We set for every valid object in the memory pool the freepointer
  172130             :  * to the global index and increase the global index afterwards. For all the 
  172131             :  * invalid objects (means address ranges within the memory pool that were not
  172132             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  172133             :  * distinguish valid from invalid objects! 
  172134             :  */
  172135             : unsigned long
  172136           5 : SgSIMDFmaOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  172137             :    {
  172138           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  172139           5 :      SgSIMDFmaOp* pointer = NULL;
  172140           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  172141           5 :      std::vector < unsigned char* > :: const_iterator block;
  172142           5 :      for ( block = SgSIMDFmaOp::pools.begin(); block != SgSIMDFmaOp::pools.end() ; ++block )
  172143             :         {
  172144           0 :           pointer = (SgSIMDFmaOp*)(*block);
  172145           0 :           for (unsigned i = 0; i < SgSIMDFmaOp::pool_size; ++i )
  172146             :              {
  172147             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  172148             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  172149             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  172150             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  172151             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  172152             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  172153             :             // properly; so this will have to be checked next.
  172154             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  172155             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  172156           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  172157             :                   {
  172158           0 :                     pointer[i].set_freepointer((SgSIMDFmaOp*)(globalIndex));
  172159           0 :                     globalIndex++;
  172160             :                   }
  172161             :                else
  172162             :                   {
  172163           0 :                     pointer[i].set_freepointer(NULL);
  172164             :                   }
  172165             :               }
  172166             :         }
  172167           5 :      return globalIndex;
  172168             :    }
  172169             : 
  172170             : //############################################################################
  172171             : // JH (01/14/2006)
  172172             : void
  172173           5 : SgSIMDFmaOp::resetValidFreepointers( )
  172174             :    {
  172175           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  172176           5 :      SgSIMDFmaOp* pointer = NULL;
  172177           5 :      std::vector < unsigned char* > :: const_iterator block;
  172178           5 :      SgSIMDFmaOp* pointerOfLinkedList = NULL;
  172179           5 :      for ( block = SgSIMDFmaOp::pools.begin(); block != SgSIMDFmaOp::pools.end() ; ++block )
  172180             :         {
  172181           0 :           pointer = (SgSIMDFmaOp*)(*block);
  172182           0 :           for (unsigned i = 0; i < SgSIMDFmaOp::pool_size; ++i )
  172183             :              {
  172184             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  172185             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  172186             :             // memory blocks!.
  172187           0 :                if ( pointer[i].get_freepointer() != NULL )
  172188             :                   {
  172189           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  172190             :                   }
  172191             :                else
  172192             :                   {
  172193           0 :                     if ( pointerOfLinkedList == NULL )
  172194             :                        {
  172195           0 :                          SgSIMDFmaOp::next_node = &(pointer[i]);
  172196             :                        }
  172197             :                     else
  172198             :                        {
  172199             :                       // printf ("In SgSIMDFmaOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  172200           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  172201             :                        }
  172202             :                     pointerOfLinkedList = &(pointer[i]);
  172203             :                   }
  172204             :               }
  172205             :         }
  172206             : 
  172207           5 :      if ( pointerOfLinkedList != NULL )
  172208             :         {
  172209             :        // printf ("In SgSIMDFmaOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  172210           0 :           pointerOfLinkedList->set_freepointer(NULL);
  172211             :        // DQ (6/6/2010): Temporary debugging...
  172212             :        //   ROSE_ASSERT(false);
  172213             :         }
  172214             : 
  172215           5 :      return ;
  172216             :    }
  172217             : 
  172218             : //############################################################################
  172219             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  172220             :  * within the memory pool and resets the freepointers, in order to achieve a 
  172221             :  * linked list, that has no jumps and starts at the beginning! This function 
  172222             :  * does not extend the memory pool, since we do not delete any memory blocks,
  172223             :  * but delete the valid objects.  
  172224             :  */
  172225             : void
  172226           0 : SgSIMDFmaOp::clearMemoryPool( )
  172227             :    {
  172228             :   // printf ("Inside of SgSIMDFmaOp::clearMemoryPool() \n");
  172229             : 
  172230           0 :      SgSIMDFmaOp* pointer = NULL, *tempPointer = NULL;
  172231           0 :      std::vector < unsigned char* > :: const_iterator block;
  172232           0 :      if ( SgSIMDFmaOp::pools.empty() == false )
  172233             :         {
  172234           0 :           block = SgSIMDFmaOp::pools.begin() ;
  172235           0 :           SgSIMDFmaOp::next_node = (SgSIMDFmaOp*) (*block);
  172236             : 
  172237           0 :           while ( block != SgSIMDFmaOp::pools.end() )
  172238             :              {
  172239           0 :                pointer = (SgSIMDFmaOp*) (*block);
  172240           0 :                if ( tempPointer != NULL )
  172241             :                   {
  172242           0 :                     tempPointer->set_freepointer(pointer);
  172243             :                   }
  172244           0 :                for (unsigned i = 0; i < SgSIMDFmaOp::pool_size - 1; ++i)
  172245             :                   {
  172246           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  172247             :                   }
  172248           0 :                 pointer[SgSIMDFmaOp::pool_size-1].set_freepointer(NULL);
  172249           0 :                 tempPointer = &(pointer[SgSIMDFmaOp::pool_size-1]);
  172250           0 :                 ++block;
  172251             :              }
  172252             :         }
  172253           0 :    }
  172254             : 
  172255           5 : void SgSIMDFmaOp::deleteMemoryPool() {
  172256           5 :   for (auto p: SgSIMDFmaOp::pools) {
  172257           0 :     ROSE_FREE(p);
  172258             :   }
  172259           5 :   SgSIMDFmaOp::next_node = nullptr;
  172260           5 :   SgSIMDFmaOp::pools.clear();
  172261           5 : }
  172262             : 
  172263             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  172264             : //                 reading multiple binary files to for a single AST.
  172265             : /////////// new version ////////////////////////////////
  172266             : //############################################################################
  172267             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  172268             : void
  172269           2 : SgSIMDFmaOp::extendMemoryPoolForFileIO( )
  172270             :   {
  172271           2 :     size_t blockIndex = SgSIMDFmaOp::pools.size();
  172272           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDFmaOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDFmaOp);
  172273             : 
  172274           2 :     while ( (blockIndex * SgSIMDFmaOp::pool_size) < newPoolSize)
  172275             :       {
  172276             : #if ROSE_ALLOC_TRACE
  172277             :         if (blockIndex > 0) {
  172278             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDFmaOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDFmaOp) = %" PRIuPTR " SgSIMDFmaOp::pool_size = %d \n",
  172279             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDFmaOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDFmaOp),SgSIMDFmaOp::pool_size);
  172280             :         }
  172281             : #endif
  172282             : 
  172283           0 :         SgSIMDFmaOp * pointer = (SgSIMDFmaOp*) ROSE_MALLOC ( SgSIMDFmaOp::pool_size * sizeof(SgSIMDFmaOp) );
  172284           0 :         assert( pointer != NULL );
  172285             : #if ROSE_ALLOC_MEMSET == 1
  172286             :         memset(pointer, 0x00, SgSIMDFmaOp::pool_size * sizeof(SgSIMDFmaOp));
  172287             : #elif ROSE_ALLOC_MEMSET == 2
  172288             :         memset(pointer, 0xCC, SgSIMDFmaOp::pool_size * sizeof(SgSIMDFmaOp));
  172289             : #endif
  172290           0 :         SgSIMDFmaOp::pools.push_back( (unsigned char*)(pointer) );
  172291           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDFmaOp::pool_size * sizeof(SgSIMDFmaOp), V_SgSIMDFmaOp ) );
  172292             : 
  172293           0 :         if ( SgSIMDFmaOp::next_node != NULL ) {
  172294           0 :           if ( blockIndex > 0 ) {
  172295           0 :             SgSIMDFmaOp * blkptr = (SgSIMDFmaOp*)(SgSIMDFmaOp::pools[blockIndex-1]);
  172296           0 :             blkptr[ SgSIMDFmaOp::pool_size - 1 ].set_freepointer(pointer);
  172297             :           }
  172298             :         } else {
  172299           0 :           SgSIMDFmaOp::next_node = pointer;
  172300             :         }
  172301             : 
  172302           0 :         for (unsigned i = 0; i < SgSIMDFmaOp::pool_size-1; ++i)
  172303             :            {
  172304           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  172305             :            }
  172306           0 :         pointer[ SgSIMDFmaOp::pool_size -1 ].set_freepointer(NULL);
  172307             : 
  172308           0 :         blockIndex++;
  172309             :       }
  172310           2 :   }
  172311             : 
  172312             : //############################################################################
  172313             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  172314             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  172315             :  * not compressed. However, that stuff is not yet implemented! 
  172316             :  */
  172317             : unsigned long
  172318           0 : SgSIMDFmaOp::getNumberOfLastValidPointer()
  172319             :    {
  172320           0 :       SgSIMDFmaOp* testPointer = (SgSIMDFmaOp*)(SgSIMDFmaOp::pools.back());
  172321           0 :       unsigned long localIndex = SgSIMDFmaOp::pool_size - 1;
  172322           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  172323             :          {
  172324           0 :            localIndex--;
  172325             :          }
  172326           0 :       return (localIndex + SgSIMDFmaOp::pool_size * (SgSIMDFmaOp::pools.size()-1));
  172327             :    }
  172328             : 
  172329             : //############################################################################
  172330             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  172331             :  * memory pool and initializes the data member in class SgSIMDFmaOpStroageClass
  172332             :  * from its counterpart of SgSIMDFmaOp. The return value is just for checking, 
  172333             :  * that the whole StorageClassArray is initialized!
  172334             :  */
  172335             : unsigned long
  172336           0 : SgSIMDFmaOp::initializeStorageClassArray( SgSIMDFmaOpStorageClass *storageArray )
  172337             :    {
  172338           0 :      unsigned long storageCounter = 0;
  172339           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDFmaOp::pools.begin();
  172340           0 :      SgSIMDFmaOp* pointer = NULL;
  172341           0 :      while ( block != SgSIMDFmaOp::pools.end() ) {
  172342           0 :           pointer = (SgSIMDFmaOp*) (*block);
  172343           0 :           for ( unsigned i = 0; i < SgSIMDFmaOp::pool_size; ++i ) {
  172344           0 :                if ( pointer->get_freepointer() != NULL ) {
  172345           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  172346           0 :                  storageArray++;
  172347           0 :                  storageCounter++;
  172348             :                }
  172349           0 :                pointer++;
  172350             :              }
  172351           0 :            block++;
  172352             :         }
  172353           0 :      return storageCounter;
  172354             :    }
  172355             : 
  172356             : /* #line 172357 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  172357             : 
  172358             : 
  172359             : 
  172360             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  172361             : 
  172362             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  172363             : 
  172364             : //############################################################################
  172365             : /* JH (02/02/2006) Constructor of the IR node SgSIMDLoad that takes its 
  172366             :  * corresponding StorageClass as parameter
  172367             :  */
  172368           0 : SgSIMDLoad :: SgSIMDLoad ( const SgSIMDLoadStorageClass& storageSource )   : SgBinaryOp (storageSource)
  172369             :    {
  172370             : 
  172371             : 
  172372             : /* #line 172373 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  172373             : 
  172374           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  172375             : 
  172376             : 
  172377             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  172378             : 
  172379             : 
  172380           0 :    }
  172381             : 
  172382             : //############################################################################
  172383             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  172384             :  * within the working AST. 
  172385             :  */
  172386           0 : SgSIMDLoad * SgSIMDLoad::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  172387           0 :      SgSIMDLoad* returnPointer = NULL;
  172388           0 :      if ( globalIndex != 0 )
  172389             :         {
  172390             : 
  172391             : #if FILE_IO_EXTRA_CHECK
  172392           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDLoad ) ) <= globalIndex ) ;
  172393           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDLoad + 1 ) ) );
  172394             : #endif
  172395           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDLoad )  
  172396           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDLoad );
  172397           0 :           unsigned long positionInPool = localIndex % SgSIMDLoad::pool_size;
  172398           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDLoad::pool_size;
  172399             : 
  172400             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  172401             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  172402             : 
  172403           0 :           returnPointer = &( ( (SgSIMDLoad*)(SgSIMDLoad::pools[memoryBlock]) ) [positionInPool]) ;
  172404             : 
  172405           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  172406             :         }
  172407           0 :      return returnPointer ;
  172408             :    }
  172409             : 
  172410             : //############################################################################
  172411             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  172412             :   for the AST with the index astIndex
  172413             : */
  172414           0 : SgSIMDLoad * SgSIMDLoad::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  172415           0 :      SgSIMDLoad* returnPointer = NULL;
  172416           0 :      if ( globalIndex != 0 )
  172417             :         {
  172418             : 
  172419             : #if FILE_IO_EXTRA_CHECK
  172420           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDLoad ) ) <= globalIndex ) ;
  172421           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDLoad + 1 ) ) );
  172422             : #endif
  172423           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDLoad )
  172424           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDLoad );
  172425           0 :           unsigned long positionInPool = localIndex % SgSIMDLoad::pool_size ;
  172426           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDLoad::pool_size ;
  172427             : 
  172428             : #if FILE_IO_EXTRA_CHECK
  172429             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  172430             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  172431             : #endif
  172432             : 
  172433           0 :           returnPointer = &( ( (SgSIMDLoad*)(SgSIMDLoad::pools[memoryBlock]) ) [positionInPool]) ;
  172434             : 
  172435             : #if FILE_IO_EXTRA_CHECK
  172436           0 :           assert ( returnPointer != NULL ) ;
  172437             : #endif
  172438             :         }
  172439           0 :      return returnPointer ;
  172440             :    }
  172441             : 
  172442             : //############################################################################
  172443             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  172444             :  * pool size! We set for every valid object in the memory pool the freepointer
  172445             :  * to the global index and increase the global index afterwards. For all the 
  172446             :  * invalid objects (means address ranges within the memory pool that were not
  172447             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  172448             :  * distinguish valid from invalid objects! 
  172449             :  */
  172450             : unsigned long
  172451           5 : SgSIMDLoad::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  172452             :    {
  172453           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  172454           5 :      SgSIMDLoad* pointer = NULL;
  172455           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  172456           5 :      std::vector < unsigned char* > :: const_iterator block;
  172457           5 :      for ( block = SgSIMDLoad::pools.begin(); block != SgSIMDLoad::pools.end() ; ++block )
  172458             :         {
  172459           0 :           pointer = (SgSIMDLoad*)(*block);
  172460           0 :           for (unsigned i = 0; i < SgSIMDLoad::pool_size; ++i )
  172461             :              {
  172462             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  172463             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  172464             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  172465             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  172466             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  172467             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  172468             :             // properly; so this will have to be checked next.
  172469             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  172470             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  172471           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  172472             :                   {
  172473           0 :                     pointer[i].set_freepointer((SgSIMDLoad*)(globalIndex));
  172474           0 :                     globalIndex++;
  172475             :                   }
  172476             :                else
  172477             :                   {
  172478           0 :                     pointer[i].set_freepointer(NULL);
  172479             :                   }
  172480             :               }
  172481             :         }
  172482           5 :      return globalIndex;
  172483             :    }
  172484             : 
  172485             : //############################################################################
  172486             : // JH (01/14/2006)
  172487             : void
  172488           5 : SgSIMDLoad::resetValidFreepointers( )
  172489             :    {
  172490           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  172491           5 :      SgSIMDLoad* pointer = NULL;
  172492           5 :      std::vector < unsigned char* > :: const_iterator block;
  172493           5 :      SgSIMDLoad* pointerOfLinkedList = NULL;
  172494           5 :      for ( block = SgSIMDLoad::pools.begin(); block != SgSIMDLoad::pools.end() ; ++block )
  172495             :         {
  172496           0 :           pointer = (SgSIMDLoad*)(*block);
  172497           0 :           for (unsigned i = 0; i < SgSIMDLoad::pool_size; ++i )
  172498             :              {
  172499             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  172500             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  172501             :             // memory blocks!.
  172502           0 :                if ( pointer[i].get_freepointer() != NULL )
  172503             :                   {
  172504           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  172505             :                   }
  172506             :                else
  172507             :                   {
  172508           0 :                     if ( pointerOfLinkedList == NULL )
  172509             :                        {
  172510           0 :                          SgSIMDLoad::next_node = &(pointer[i]);
  172511             :                        }
  172512             :                     else
  172513             :                        {
  172514             :                       // printf ("In SgSIMDLoad::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  172515           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  172516             :                        }
  172517             :                     pointerOfLinkedList = &(pointer[i]);
  172518             :                   }
  172519             :               }
  172520             :         }
  172521             : 
  172522           5 :      if ( pointerOfLinkedList != NULL )
  172523             :         {
  172524             :        // printf ("In SgSIMDLoad::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  172525           0 :           pointerOfLinkedList->set_freepointer(NULL);
  172526             :        // DQ (6/6/2010): Temporary debugging...
  172527             :        //   ROSE_ASSERT(false);
  172528             :         }
  172529             : 
  172530           5 :      return ;
  172531             :    }
  172532             : 
  172533             : //############################################################################
  172534             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  172535             :  * within the memory pool and resets the freepointers, in order to achieve a 
  172536             :  * linked list, that has no jumps and starts at the beginning! This function 
  172537             :  * does not extend the memory pool, since we do not delete any memory blocks,
  172538             :  * but delete the valid objects.  
  172539             :  */
  172540             : void
  172541           0 : SgSIMDLoad::clearMemoryPool( )
  172542             :    {
  172543             :   // printf ("Inside of SgSIMDLoad::clearMemoryPool() \n");
  172544             : 
  172545           0 :      SgSIMDLoad* pointer = NULL, *tempPointer = NULL;
  172546           0 :      std::vector < unsigned char* > :: const_iterator block;
  172547           0 :      if ( SgSIMDLoad::pools.empty() == false )
  172548             :         {
  172549           0 :           block = SgSIMDLoad::pools.begin() ;
  172550           0 :           SgSIMDLoad::next_node = (SgSIMDLoad*) (*block);
  172551             : 
  172552           0 :           while ( block != SgSIMDLoad::pools.end() )
  172553             :              {
  172554           0 :                pointer = (SgSIMDLoad*) (*block);
  172555           0 :                if ( tempPointer != NULL )
  172556             :                   {
  172557           0 :                     tempPointer->set_freepointer(pointer);
  172558             :                   }
  172559           0 :                for (unsigned i = 0; i < SgSIMDLoad::pool_size - 1; ++i)
  172560             :                   {
  172561           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  172562             :                   }
  172563           0 :                 pointer[SgSIMDLoad::pool_size-1].set_freepointer(NULL);
  172564           0 :                 tempPointer = &(pointer[SgSIMDLoad::pool_size-1]);
  172565           0 :                 ++block;
  172566             :              }
  172567             :         }
  172568           0 :    }
  172569             : 
  172570           5 : void SgSIMDLoad::deleteMemoryPool() {
  172571           5 :   for (auto p: SgSIMDLoad::pools) {
  172572           0 :     ROSE_FREE(p);
  172573             :   }
  172574           5 :   SgSIMDLoad::next_node = nullptr;
  172575           5 :   SgSIMDLoad::pools.clear();
  172576           5 : }
  172577             : 
  172578             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  172579             : //                 reading multiple binary files to for a single AST.
  172580             : /////////// new version ////////////////////////////////
  172581             : //############################################################################
  172582             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  172583             : void
  172584           2 : SgSIMDLoad::extendMemoryPoolForFileIO( )
  172585             :   {
  172586           2 :     size_t blockIndex = SgSIMDLoad::pools.size();
  172587           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDLoad) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDLoad);
  172588             : 
  172589           2 :     while ( (blockIndex * SgSIMDLoad::pool_size) < newPoolSize)
  172590             :       {
  172591             : #if ROSE_ALLOC_TRACE
  172592             :         if (blockIndex > 0) {
  172593             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDLoad) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDLoad) = %" PRIuPTR " SgSIMDLoad::pool_size = %d \n",
  172594             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDLoad),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDLoad),SgSIMDLoad::pool_size);
  172595             :         }
  172596             : #endif
  172597             : 
  172598           0 :         SgSIMDLoad * pointer = (SgSIMDLoad*) ROSE_MALLOC ( SgSIMDLoad::pool_size * sizeof(SgSIMDLoad) );
  172599           0 :         assert( pointer != NULL );
  172600             : #if ROSE_ALLOC_MEMSET == 1
  172601             :         memset(pointer, 0x00, SgSIMDLoad::pool_size * sizeof(SgSIMDLoad));
  172602             : #elif ROSE_ALLOC_MEMSET == 2
  172603             :         memset(pointer, 0xCC, SgSIMDLoad::pool_size * sizeof(SgSIMDLoad));
  172604             : #endif
  172605           0 :         SgSIMDLoad::pools.push_back( (unsigned char*)(pointer) );
  172606           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDLoad::pool_size * sizeof(SgSIMDLoad), V_SgSIMDLoad ) );
  172607             : 
  172608           0 :         if ( SgSIMDLoad::next_node != NULL ) {
  172609           0 :           if ( blockIndex > 0 ) {
  172610           0 :             SgSIMDLoad * blkptr = (SgSIMDLoad*)(SgSIMDLoad::pools[blockIndex-1]);
  172611           0 :             blkptr[ SgSIMDLoad::pool_size - 1 ].set_freepointer(pointer);
  172612             :           }
  172613             :         } else {
  172614           0 :           SgSIMDLoad::next_node = pointer;
  172615             :         }
  172616             : 
  172617           0 :         for (unsigned i = 0; i < SgSIMDLoad::pool_size-1; ++i)
  172618             :            {
  172619           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  172620             :            }
  172621           0 :         pointer[ SgSIMDLoad::pool_size -1 ].set_freepointer(NULL);
  172622             : 
  172623           0 :         blockIndex++;
  172624             :       }
  172625           2 :   }
  172626             : 
  172627             : //############################################################################
  172628             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  172629             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  172630             :  * not compressed. However, that stuff is not yet implemented! 
  172631             :  */
  172632             : unsigned long
  172633           0 : SgSIMDLoad::getNumberOfLastValidPointer()
  172634             :    {
  172635           0 :       SgSIMDLoad* testPointer = (SgSIMDLoad*)(SgSIMDLoad::pools.back());
  172636           0 :       unsigned long localIndex = SgSIMDLoad::pool_size - 1;
  172637           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  172638             :          {
  172639           0 :            localIndex--;
  172640             :          }
  172641           0 :       return (localIndex + SgSIMDLoad::pool_size * (SgSIMDLoad::pools.size()-1));
  172642             :    }
  172643             : 
  172644             : //############################################################################
  172645             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  172646             :  * memory pool and initializes the data member in class SgSIMDLoadStroageClass
  172647             :  * from its counterpart of SgSIMDLoad. The return value is just for checking, 
  172648             :  * that the whole StorageClassArray is initialized!
  172649             :  */
  172650             : unsigned long
  172651           0 : SgSIMDLoad::initializeStorageClassArray( SgSIMDLoadStorageClass *storageArray )
  172652             :    {
  172653           0 :      unsigned long storageCounter = 0;
  172654           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDLoad::pools.begin();
  172655           0 :      SgSIMDLoad* pointer = NULL;
  172656           0 :      while ( block != SgSIMDLoad::pools.end() ) {
  172657           0 :           pointer = (SgSIMDLoad*) (*block);
  172658           0 :           for ( unsigned i = 0; i < SgSIMDLoad::pool_size; ++i ) {
  172659           0 :                if ( pointer->get_freepointer() != NULL ) {
  172660           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  172661           0 :                  storageArray++;
  172662           0 :                  storageCounter++;
  172663             :                }
  172664           0 :                pointer++;
  172665             :              }
  172666           0 :            block++;
  172667             :         }
  172668           0 :      return storageCounter;
  172669             :    }
  172670             : 
  172671             : /* #line 172672 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  172672             : 
  172673             : 
  172674             : 
  172675             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  172676             : 
  172677             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  172678             : 
  172679             : //############################################################################
  172680             : /* JH (02/02/2006) Constructor of the IR node SgSIMDBroadcast that takes its 
  172681             :  * corresponding StorageClass as parameter
  172682             :  */
  172683           0 : SgSIMDBroadcast :: SgSIMDBroadcast ( const SgSIMDBroadcastStorageClass& storageSource )   : SgBinaryOp (storageSource)
  172684             :    {
  172685             : 
  172686             : 
  172687             : /* #line 172688 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  172688             : 
  172689           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  172690             : 
  172691             : 
  172692             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  172693             : 
  172694             : 
  172695           0 :    }
  172696             : 
  172697             : //############################################################################
  172698             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  172699             :  * within the working AST. 
  172700             :  */
  172701           0 : SgSIMDBroadcast * SgSIMDBroadcast::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  172702           0 :      SgSIMDBroadcast* returnPointer = NULL;
  172703           0 :      if ( globalIndex != 0 )
  172704             :         {
  172705             : 
  172706             : #if FILE_IO_EXTRA_CHECK
  172707           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDBroadcast ) ) <= globalIndex ) ;
  172708           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDBroadcast + 1 ) ) );
  172709             : #endif
  172710           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDBroadcast )  
  172711           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDBroadcast );
  172712           0 :           unsigned long positionInPool = localIndex % SgSIMDBroadcast::pool_size;
  172713           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDBroadcast::pool_size;
  172714             : 
  172715             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  172716             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  172717             : 
  172718           0 :           returnPointer = &( ( (SgSIMDBroadcast*)(SgSIMDBroadcast::pools[memoryBlock]) ) [positionInPool]) ;
  172719             : 
  172720           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  172721             :         }
  172722           0 :      return returnPointer ;
  172723             :    }
  172724             : 
  172725             : //############################################################################
  172726             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  172727             :   for the AST with the index astIndex
  172728             : */
  172729           0 : SgSIMDBroadcast * SgSIMDBroadcast::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  172730           0 :      SgSIMDBroadcast* returnPointer = NULL;
  172731           0 :      if ( globalIndex != 0 )
  172732             :         {
  172733             : 
  172734             : #if FILE_IO_EXTRA_CHECK
  172735           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDBroadcast ) ) <= globalIndex ) ;
  172736           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDBroadcast + 1 ) ) );
  172737             : #endif
  172738           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDBroadcast )
  172739           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDBroadcast );
  172740           0 :           unsigned long positionInPool = localIndex % SgSIMDBroadcast::pool_size ;
  172741           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDBroadcast::pool_size ;
  172742             : 
  172743             : #if FILE_IO_EXTRA_CHECK
  172744             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  172745             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  172746             : #endif
  172747             : 
  172748           0 :           returnPointer = &( ( (SgSIMDBroadcast*)(SgSIMDBroadcast::pools[memoryBlock]) ) [positionInPool]) ;
  172749             : 
  172750             : #if FILE_IO_EXTRA_CHECK
  172751           0 :           assert ( returnPointer != NULL ) ;
  172752             : #endif
  172753             :         }
  172754           0 :      return returnPointer ;
  172755             :    }
  172756             : 
  172757             : //############################################################################
  172758             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  172759             :  * pool size! We set for every valid object in the memory pool the freepointer
  172760             :  * to the global index and increase the global index afterwards. For all the 
  172761             :  * invalid objects (means address ranges within the memory pool that were not
  172762             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  172763             :  * distinguish valid from invalid objects! 
  172764             :  */
  172765             : unsigned long
  172766           5 : SgSIMDBroadcast::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  172767             :    {
  172768           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  172769           5 :      SgSIMDBroadcast* pointer = NULL;
  172770           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  172771           5 :      std::vector < unsigned char* > :: const_iterator block;
  172772           5 :      for ( block = SgSIMDBroadcast::pools.begin(); block != SgSIMDBroadcast::pools.end() ; ++block )
  172773             :         {
  172774           0 :           pointer = (SgSIMDBroadcast*)(*block);
  172775           0 :           for (unsigned i = 0; i < SgSIMDBroadcast::pool_size; ++i )
  172776             :              {
  172777             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  172778             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  172779             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  172780             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  172781             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  172782             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  172783             :             // properly; so this will have to be checked next.
  172784             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  172785             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  172786           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  172787             :                   {
  172788           0 :                     pointer[i].set_freepointer((SgSIMDBroadcast*)(globalIndex));
  172789           0 :                     globalIndex++;
  172790             :                   }
  172791             :                else
  172792             :                   {
  172793           0 :                     pointer[i].set_freepointer(NULL);
  172794             :                   }
  172795             :               }
  172796             :         }
  172797           5 :      return globalIndex;
  172798             :    }
  172799             : 
  172800             : //############################################################################
  172801             : // JH (01/14/2006)
  172802             : void
  172803           5 : SgSIMDBroadcast::resetValidFreepointers( )
  172804             :    {
  172805           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  172806           5 :      SgSIMDBroadcast* pointer = NULL;
  172807           5 :      std::vector < unsigned char* > :: const_iterator block;
  172808           5 :      SgSIMDBroadcast* pointerOfLinkedList = NULL;
  172809           5 :      for ( block = SgSIMDBroadcast::pools.begin(); block != SgSIMDBroadcast::pools.end() ; ++block )
  172810             :         {
  172811           0 :           pointer = (SgSIMDBroadcast*)(*block);
  172812           0 :           for (unsigned i = 0; i < SgSIMDBroadcast::pool_size; ++i )
  172813             :              {
  172814             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  172815             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  172816             :             // memory blocks!.
  172817           0 :                if ( pointer[i].get_freepointer() != NULL )
  172818             :                   {
  172819           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  172820             :                   }
  172821             :                else
  172822             :                   {
  172823           0 :                     if ( pointerOfLinkedList == NULL )
  172824             :                        {
  172825           0 :                          SgSIMDBroadcast::next_node = &(pointer[i]);
  172826             :                        }
  172827             :                     else
  172828             :                        {
  172829             :                       // printf ("In SgSIMDBroadcast::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  172830           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  172831             :                        }
  172832             :                     pointerOfLinkedList = &(pointer[i]);
  172833             :                   }
  172834             :               }
  172835             :         }
  172836             : 
  172837           5 :      if ( pointerOfLinkedList != NULL )
  172838             :         {
  172839             :        // printf ("In SgSIMDBroadcast::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  172840           0 :           pointerOfLinkedList->set_freepointer(NULL);
  172841             :        // DQ (6/6/2010): Temporary debugging...
  172842             :        //   ROSE_ASSERT(false);
  172843             :         }
  172844             : 
  172845           5 :      return ;
  172846             :    }
  172847             : 
  172848             : //############################################################################
  172849             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  172850             :  * within the memory pool and resets the freepointers, in order to achieve a 
  172851             :  * linked list, that has no jumps and starts at the beginning! This function 
  172852             :  * does not extend the memory pool, since we do not delete any memory blocks,
  172853             :  * but delete the valid objects.  
  172854             :  */
  172855             : void
  172856           0 : SgSIMDBroadcast::clearMemoryPool( )
  172857             :    {
  172858             :   // printf ("Inside of SgSIMDBroadcast::clearMemoryPool() \n");
  172859             : 
  172860           0 :      SgSIMDBroadcast* pointer = NULL, *tempPointer = NULL;
  172861           0 :      std::vector < unsigned char* > :: const_iterator block;
  172862           0 :      if ( SgSIMDBroadcast::pools.empty() == false )
  172863             :         {
  172864           0 :           block = SgSIMDBroadcast::pools.begin() ;
  172865           0 :           SgSIMDBroadcast::next_node = (SgSIMDBroadcast*) (*block);
  172866             : 
  172867           0 :           while ( block != SgSIMDBroadcast::pools.end() )
  172868             :              {
  172869           0 :                pointer = (SgSIMDBroadcast*) (*block);
  172870           0 :                if ( tempPointer != NULL )
  172871             :                   {
  172872           0 :                     tempPointer->set_freepointer(pointer);
  172873             :                   }
  172874           0 :                for (unsigned i = 0; i < SgSIMDBroadcast::pool_size - 1; ++i)
  172875             :                   {
  172876           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  172877             :                   }
  172878           0 :                 pointer[SgSIMDBroadcast::pool_size-1].set_freepointer(NULL);
  172879           0 :                 tempPointer = &(pointer[SgSIMDBroadcast::pool_size-1]);
  172880           0 :                 ++block;
  172881             :              }
  172882             :         }
  172883           0 :    }
  172884             : 
  172885           5 : void SgSIMDBroadcast::deleteMemoryPool() {
  172886           5 :   for (auto p: SgSIMDBroadcast::pools) {
  172887           0 :     ROSE_FREE(p);
  172888             :   }
  172889           5 :   SgSIMDBroadcast::next_node = nullptr;
  172890           5 :   SgSIMDBroadcast::pools.clear();
  172891           5 : }
  172892             : 
  172893             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  172894             : //                 reading multiple binary files to for a single AST.
  172895             : /////////// new version ////////////////////////////////
  172896             : //############################################################################
  172897             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  172898             : void
  172899           2 : SgSIMDBroadcast::extendMemoryPoolForFileIO( )
  172900             :   {
  172901           2 :     size_t blockIndex = SgSIMDBroadcast::pools.size();
  172902           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDBroadcast) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDBroadcast);
  172903             : 
  172904           2 :     while ( (blockIndex * SgSIMDBroadcast::pool_size) < newPoolSize)
  172905             :       {
  172906             : #if ROSE_ALLOC_TRACE
  172907             :         if (blockIndex > 0) {
  172908             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDBroadcast) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDBroadcast) = %" PRIuPTR " SgSIMDBroadcast::pool_size = %d \n",
  172909             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDBroadcast),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDBroadcast),SgSIMDBroadcast::pool_size);
  172910             :         }
  172911             : #endif
  172912             : 
  172913           0 :         SgSIMDBroadcast * pointer = (SgSIMDBroadcast*) ROSE_MALLOC ( SgSIMDBroadcast::pool_size * sizeof(SgSIMDBroadcast) );
  172914           0 :         assert( pointer != NULL );
  172915             : #if ROSE_ALLOC_MEMSET == 1
  172916             :         memset(pointer, 0x00, SgSIMDBroadcast::pool_size * sizeof(SgSIMDBroadcast));
  172917             : #elif ROSE_ALLOC_MEMSET == 2
  172918             :         memset(pointer, 0xCC, SgSIMDBroadcast::pool_size * sizeof(SgSIMDBroadcast));
  172919             : #endif
  172920           0 :         SgSIMDBroadcast::pools.push_back( (unsigned char*)(pointer) );
  172921           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDBroadcast::pool_size * sizeof(SgSIMDBroadcast), V_SgSIMDBroadcast ) );
  172922             : 
  172923           0 :         if ( SgSIMDBroadcast::next_node != NULL ) {
  172924           0 :           if ( blockIndex > 0 ) {
  172925           0 :             SgSIMDBroadcast * blkptr = (SgSIMDBroadcast*)(SgSIMDBroadcast::pools[blockIndex-1]);
  172926           0 :             blkptr[ SgSIMDBroadcast::pool_size - 1 ].set_freepointer(pointer);
  172927             :           }
  172928             :         } else {
  172929           0 :           SgSIMDBroadcast::next_node = pointer;
  172930             :         }
  172931             : 
  172932           0 :         for (unsigned i = 0; i < SgSIMDBroadcast::pool_size-1; ++i)
  172933             :            {
  172934           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  172935             :            }
  172936           0 :         pointer[ SgSIMDBroadcast::pool_size -1 ].set_freepointer(NULL);
  172937             : 
  172938           0 :         blockIndex++;
  172939             :       }
  172940           2 :   }
  172941             : 
  172942             : //############################################################################
  172943             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  172944             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  172945             :  * not compressed. However, that stuff is not yet implemented! 
  172946             :  */
  172947             : unsigned long
  172948           0 : SgSIMDBroadcast::getNumberOfLastValidPointer()
  172949             :    {
  172950           0 :       SgSIMDBroadcast* testPointer = (SgSIMDBroadcast*)(SgSIMDBroadcast::pools.back());
  172951           0 :       unsigned long localIndex = SgSIMDBroadcast::pool_size - 1;
  172952           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  172953             :          {
  172954           0 :            localIndex--;
  172955             :          }
  172956           0 :       return (localIndex + SgSIMDBroadcast::pool_size * (SgSIMDBroadcast::pools.size()-1));
  172957             :    }
  172958             : 
  172959             : //############################################################################
  172960             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  172961             :  * memory pool and initializes the data member in class SgSIMDBroadcastStroageClass
  172962             :  * from its counterpart of SgSIMDBroadcast. The return value is just for checking, 
  172963             :  * that the whole StorageClassArray is initialized!
  172964             :  */
  172965             : unsigned long
  172966           0 : SgSIMDBroadcast::initializeStorageClassArray( SgSIMDBroadcastStorageClass *storageArray )
  172967             :    {
  172968           0 :      unsigned long storageCounter = 0;
  172969           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDBroadcast::pools.begin();
  172970           0 :      SgSIMDBroadcast* pointer = NULL;
  172971           0 :      while ( block != SgSIMDBroadcast::pools.end() ) {
  172972           0 :           pointer = (SgSIMDBroadcast*) (*block);
  172973           0 :           for ( unsigned i = 0; i < SgSIMDBroadcast::pool_size; ++i ) {
  172974           0 :                if ( pointer->get_freepointer() != NULL ) {
  172975           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  172976           0 :                  storageArray++;
  172977           0 :                  storageCounter++;
  172978             :                }
  172979           0 :                pointer++;
  172980             :              }
  172981           0 :            block++;
  172982             :         }
  172983           0 :      return storageCounter;
  172984             :    }
  172985             : 
  172986             : /* #line 172987 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  172987             : 
  172988             : 
  172989             : 
  172990             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  172991             : 
  172992             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  172993             : 
  172994             : //############################################################################
  172995             : /* JH (02/02/2006) Constructor of the IR node SgSIMDStore that takes its 
  172996             :  * corresponding StorageClass as parameter
  172997             :  */
  172998           0 : SgSIMDStore :: SgSIMDStore ( const SgSIMDStoreStorageClass& storageSource )   : SgBinaryOp (storageSource)
  172999             :    {
  173000             : 
  173001             : 
  173002             : /* #line 173003 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  173003             : 
  173004           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  173005             : 
  173006             : 
  173007             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  173008             : 
  173009             : 
  173010           0 :    }
  173011             : 
  173012             : //############################################################################
  173013             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  173014             :  * within the working AST. 
  173015             :  */
  173016           0 : SgSIMDStore * SgSIMDStore::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  173017           0 :      SgSIMDStore* returnPointer = NULL;
  173018           0 :      if ( globalIndex != 0 )
  173019             :         {
  173020             : 
  173021             : #if FILE_IO_EXTRA_CHECK
  173022           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDStore ) ) <= globalIndex ) ;
  173023           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDStore + 1 ) ) );
  173024             : #endif
  173025           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDStore )  
  173026           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDStore );
  173027           0 :           unsigned long positionInPool = localIndex % SgSIMDStore::pool_size;
  173028           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDStore::pool_size;
  173029             : 
  173030             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  173031             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  173032             : 
  173033           0 :           returnPointer = &( ( (SgSIMDStore*)(SgSIMDStore::pools[memoryBlock]) ) [positionInPool]) ;
  173034             : 
  173035           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  173036             :         }
  173037           0 :      return returnPointer ;
  173038             :    }
  173039             : 
  173040             : //############################################################################
  173041             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  173042             :   for the AST with the index astIndex
  173043             : */
  173044           0 : SgSIMDStore * SgSIMDStore::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  173045           0 :      SgSIMDStore* returnPointer = NULL;
  173046           0 :      if ( globalIndex != 0 )
  173047             :         {
  173048             : 
  173049             : #if FILE_IO_EXTRA_CHECK
  173050           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDStore ) ) <= globalIndex ) ;
  173051           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDStore + 1 ) ) );
  173052             : #endif
  173053           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDStore )
  173054           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDStore );
  173055           0 :           unsigned long positionInPool = localIndex % SgSIMDStore::pool_size ;
  173056           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDStore::pool_size ;
  173057             : 
  173058             : #if FILE_IO_EXTRA_CHECK
  173059             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  173060             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  173061             : #endif
  173062             : 
  173063           0 :           returnPointer = &( ( (SgSIMDStore*)(SgSIMDStore::pools[memoryBlock]) ) [positionInPool]) ;
  173064             : 
  173065             : #if FILE_IO_EXTRA_CHECK
  173066           0 :           assert ( returnPointer != NULL ) ;
  173067             : #endif
  173068             :         }
  173069           0 :      return returnPointer ;
  173070             :    }
  173071             : 
  173072             : //############################################################################
  173073             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  173074             :  * pool size! We set for every valid object in the memory pool the freepointer
  173075             :  * to the global index and increase the global index afterwards. For all the 
  173076             :  * invalid objects (means address ranges within the memory pool that were not
  173077             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  173078             :  * distinguish valid from invalid objects! 
  173079             :  */
  173080             : unsigned long
  173081           5 : SgSIMDStore::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  173082             :    {
  173083           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  173084           5 :      SgSIMDStore* pointer = NULL;
  173085           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  173086           5 :      std::vector < unsigned char* > :: const_iterator block;
  173087           5 :      for ( block = SgSIMDStore::pools.begin(); block != SgSIMDStore::pools.end() ; ++block )
  173088             :         {
  173089           0 :           pointer = (SgSIMDStore*)(*block);
  173090           0 :           for (unsigned i = 0; i < SgSIMDStore::pool_size; ++i )
  173091             :              {
  173092             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  173093             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  173094             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  173095             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  173096             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  173097             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  173098             :             // properly; so this will have to be checked next.
  173099             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  173100             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  173101           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  173102             :                   {
  173103           0 :                     pointer[i].set_freepointer((SgSIMDStore*)(globalIndex));
  173104           0 :                     globalIndex++;
  173105             :                   }
  173106             :                else
  173107             :                   {
  173108           0 :                     pointer[i].set_freepointer(NULL);
  173109             :                   }
  173110             :               }
  173111             :         }
  173112           5 :      return globalIndex;
  173113             :    }
  173114             : 
  173115             : //############################################################################
  173116             : // JH (01/14/2006)
  173117             : void
  173118           5 : SgSIMDStore::resetValidFreepointers( )
  173119             :    {
  173120           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  173121           5 :      SgSIMDStore* pointer = NULL;
  173122           5 :      std::vector < unsigned char* > :: const_iterator block;
  173123           5 :      SgSIMDStore* pointerOfLinkedList = NULL;
  173124           5 :      for ( block = SgSIMDStore::pools.begin(); block != SgSIMDStore::pools.end() ; ++block )
  173125             :         {
  173126           0 :           pointer = (SgSIMDStore*)(*block);
  173127           0 :           for (unsigned i = 0; i < SgSIMDStore::pool_size; ++i )
  173128             :              {
  173129             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  173130             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  173131             :             // memory blocks!.
  173132           0 :                if ( pointer[i].get_freepointer() != NULL )
  173133             :                   {
  173134           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  173135             :                   }
  173136             :                else
  173137             :                   {
  173138           0 :                     if ( pointerOfLinkedList == NULL )
  173139             :                        {
  173140           0 :                          SgSIMDStore::next_node = &(pointer[i]);
  173141             :                        }
  173142             :                     else
  173143             :                        {
  173144             :                       // printf ("In SgSIMDStore::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  173145           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  173146             :                        }
  173147             :                     pointerOfLinkedList = &(pointer[i]);
  173148             :                   }
  173149             :               }
  173150             :         }
  173151             : 
  173152           5 :      if ( pointerOfLinkedList != NULL )
  173153             :         {
  173154             :        // printf ("In SgSIMDStore::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  173155           0 :           pointerOfLinkedList->set_freepointer(NULL);
  173156             :        // DQ (6/6/2010): Temporary debugging...
  173157             :        //   ROSE_ASSERT(false);
  173158             :         }
  173159             : 
  173160           5 :      return ;
  173161             :    }
  173162             : 
  173163             : //############################################################################
  173164             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  173165             :  * within the memory pool and resets the freepointers, in order to achieve a 
  173166             :  * linked list, that has no jumps and starts at the beginning! This function 
  173167             :  * does not extend the memory pool, since we do not delete any memory blocks,
  173168             :  * but delete the valid objects.  
  173169             :  */
  173170             : void
  173171           0 : SgSIMDStore::clearMemoryPool( )
  173172             :    {
  173173             :   // printf ("Inside of SgSIMDStore::clearMemoryPool() \n");
  173174             : 
  173175           0 :      SgSIMDStore* pointer = NULL, *tempPointer = NULL;
  173176           0 :      std::vector < unsigned char* > :: const_iterator block;
  173177           0 :      if ( SgSIMDStore::pools.empty() == false )
  173178             :         {
  173179           0 :           block = SgSIMDStore::pools.begin() ;
  173180           0 :           SgSIMDStore::next_node = (SgSIMDStore*) (*block);
  173181             : 
  173182           0 :           while ( block != SgSIMDStore::pools.end() )
  173183             :              {
  173184           0 :                pointer = (SgSIMDStore*) (*block);
  173185           0 :                if ( tempPointer != NULL )
  173186             :                   {
  173187           0 :                     tempPointer->set_freepointer(pointer);
  173188             :                   }
  173189           0 :                for (unsigned i = 0; i < SgSIMDStore::pool_size - 1; ++i)
  173190             :                   {
  173191           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  173192             :                   }
  173193           0 :                 pointer[SgSIMDStore::pool_size-1].set_freepointer(NULL);
  173194           0 :                 tempPointer = &(pointer[SgSIMDStore::pool_size-1]);
  173195           0 :                 ++block;
  173196             :              }
  173197             :         }
  173198           0 :    }
  173199             : 
  173200           5 : void SgSIMDStore::deleteMemoryPool() {
  173201           5 :   for (auto p: SgSIMDStore::pools) {
  173202           0 :     ROSE_FREE(p);
  173203             :   }
  173204           5 :   SgSIMDStore::next_node = nullptr;
  173205           5 :   SgSIMDStore::pools.clear();
  173206           5 : }
  173207             : 
  173208             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  173209             : //                 reading multiple binary files to for a single AST.
  173210             : /////////// new version ////////////////////////////////
  173211             : //############################################################################
  173212             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  173213             : void
  173214           2 : SgSIMDStore::extendMemoryPoolForFileIO( )
  173215             :   {
  173216           2 :     size_t blockIndex = SgSIMDStore::pools.size();
  173217           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDStore) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDStore);
  173218             : 
  173219           2 :     while ( (blockIndex * SgSIMDStore::pool_size) < newPoolSize)
  173220             :       {
  173221             : #if ROSE_ALLOC_TRACE
  173222             :         if (blockIndex > 0) {
  173223             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDStore) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDStore) = %" PRIuPTR " SgSIMDStore::pool_size = %d \n",
  173224             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDStore),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDStore),SgSIMDStore::pool_size);
  173225             :         }
  173226             : #endif
  173227             : 
  173228           0 :         SgSIMDStore * pointer = (SgSIMDStore*) ROSE_MALLOC ( SgSIMDStore::pool_size * sizeof(SgSIMDStore) );
  173229           0 :         assert( pointer != NULL );
  173230             : #if ROSE_ALLOC_MEMSET == 1
  173231             :         memset(pointer, 0x00, SgSIMDStore::pool_size * sizeof(SgSIMDStore));
  173232             : #elif ROSE_ALLOC_MEMSET == 2
  173233             :         memset(pointer, 0xCC, SgSIMDStore::pool_size * sizeof(SgSIMDStore));
  173234             : #endif
  173235           0 :         SgSIMDStore::pools.push_back( (unsigned char*)(pointer) );
  173236           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDStore::pool_size * sizeof(SgSIMDStore), V_SgSIMDStore ) );
  173237             : 
  173238           0 :         if ( SgSIMDStore::next_node != NULL ) {
  173239           0 :           if ( blockIndex > 0 ) {
  173240           0 :             SgSIMDStore * blkptr = (SgSIMDStore*)(SgSIMDStore::pools[blockIndex-1]);
  173241           0 :             blkptr[ SgSIMDStore::pool_size - 1 ].set_freepointer(pointer);
  173242             :           }
  173243             :         } else {
  173244           0 :           SgSIMDStore::next_node = pointer;
  173245             :         }
  173246             : 
  173247           0 :         for (unsigned i = 0; i < SgSIMDStore::pool_size-1; ++i)
  173248             :            {
  173249           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  173250             :            }
  173251           0 :         pointer[ SgSIMDStore::pool_size -1 ].set_freepointer(NULL);
  173252             : 
  173253           0 :         blockIndex++;
  173254             :       }
  173255           2 :   }
  173256             : 
  173257             : //############################################################################
  173258             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  173259             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  173260             :  * not compressed. However, that stuff is not yet implemented! 
  173261             :  */
  173262             : unsigned long
  173263           0 : SgSIMDStore::getNumberOfLastValidPointer()
  173264             :    {
  173265           0 :       SgSIMDStore* testPointer = (SgSIMDStore*)(SgSIMDStore::pools.back());
  173266           0 :       unsigned long localIndex = SgSIMDStore::pool_size - 1;
  173267           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  173268             :          {
  173269           0 :            localIndex--;
  173270             :          }
  173271           0 :       return (localIndex + SgSIMDStore::pool_size * (SgSIMDStore::pools.size()-1));
  173272             :    }
  173273             : 
  173274             : //############################################################################
  173275             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  173276             :  * memory pool and initializes the data member in class SgSIMDStoreStroageClass
  173277             :  * from its counterpart of SgSIMDStore. The return value is just for checking, 
  173278             :  * that the whole StorageClassArray is initialized!
  173279             :  */
  173280             : unsigned long
  173281           0 : SgSIMDStore::initializeStorageClassArray( SgSIMDStoreStorageClass *storageArray )
  173282             :    {
  173283           0 :      unsigned long storageCounter = 0;
  173284           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDStore::pools.begin();
  173285           0 :      SgSIMDStore* pointer = NULL;
  173286           0 :      while ( block != SgSIMDStore::pools.end() ) {
  173287           0 :           pointer = (SgSIMDStore*) (*block);
  173288           0 :           for ( unsigned i = 0; i < SgSIMDStore::pool_size; ++i ) {
  173289           0 :                if ( pointer->get_freepointer() != NULL ) {
  173290           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  173291           0 :                  storageArray++;
  173292           0 :                  storageCounter++;
  173293             :                }
  173294           0 :                pointer++;
  173295             :              }
  173296           0 :            block++;
  173297             :         }
  173298           0 :      return storageCounter;
  173299             :    }
  173300             : 
  173301             : /* #line 173302 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  173302             : 
  173303             : 
  173304             : 
  173305             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  173306             : 
  173307             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  173308             : 
  173309             : //############################################################################
  173310             : /* JH (02/02/2006) Constructor of the IR node SgSIMDPartialStore that takes its 
  173311             :  * corresponding StorageClass as parameter
  173312             :  */
  173313           0 : SgSIMDPartialStore :: SgSIMDPartialStore ( const SgSIMDPartialStoreStorageClass& storageSource )   : SgBinaryOp (storageSource)
  173314             :    {
  173315             : 
  173316             : 
  173317             : /* #line 173318 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  173318             : 
  173319           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  173320             : 
  173321             : 
  173322             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  173323             : 
  173324             : 
  173325           0 :    }
  173326             : 
  173327             : //############################################################################
  173328             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  173329             :  * within the working AST. 
  173330             :  */
  173331           0 : SgSIMDPartialStore * SgSIMDPartialStore::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  173332           0 :      SgSIMDPartialStore* returnPointer = NULL;
  173333           0 :      if ( globalIndex != 0 )
  173334             :         {
  173335             : 
  173336             : #if FILE_IO_EXTRA_CHECK
  173337           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDPartialStore ) ) <= globalIndex ) ;
  173338           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDPartialStore + 1 ) ) );
  173339             : #endif
  173340           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDPartialStore )  
  173341           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDPartialStore );
  173342           0 :           unsigned long positionInPool = localIndex % SgSIMDPartialStore::pool_size;
  173343           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDPartialStore::pool_size;
  173344             : 
  173345             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  173346             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  173347             : 
  173348           0 :           returnPointer = &( ( (SgSIMDPartialStore*)(SgSIMDPartialStore::pools[memoryBlock]) ) [positionInPool]) ;
  173349             : 
  173350           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  173351             :         }
  173352           0 :      return returnPointer ;
  173353             :    }
  173354             : 
  173355             : //############################################################################
  173356             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  173357             :   for the AST with the index astIndex
  173358             : */
  173359           0 : SgSIMDPartialStore * SgSIMDPartialStore::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  173360           0 :      SgSIMDPartialStore* returnPointer = NULL;
  173361           0 :      if ( globalIndex != 0 )
  173362             :         {
  173363             : 
  173364             : #if FILE_IO_EXTRA_CHECK
  173365           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDPartialStore ) ) <= globalIndex ) ;
  173366           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDPartialStore + 1 ) ) );
  173367             : #endif
  173368           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDPartialStore )
  173369           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDPartialStore );
  173370           0 :           unsigned long positionInPool = localIndex % SgSIMDPartialStore::pool_size ;
  173371           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDPartialStore::pool_size ;
  173372             : 
  173373             : #if FILE_IO_EXTRA_CHECK
  173374             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  173375             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  173376             : #endif
  173377             : 
  173378           0 :           returnPointer = &( ( (SgSIMDPartialStore*)(SgSIMDPartialStore::pools[memoryBlock]) ) [positionInPool]) ;
  173379             : 
  173380             : #if FILE_IO_EXTRA_CHECK
  173381           0 :           assert ( returnPointer != NULL ) ;
  173382             : #endif
  173383             :         }
  173384           0 :      return returnPointer ;
  173385             :    }
  173386             : 
  173387             : //############################################################################
  173388             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  173389             :  * pool size! We set for every valid object in the memory pool the freepointer
  173390             :  * to the global index and increase the global index afterwards. For all the 
  173391             :  * invalid objects (means address ranges within the memory pool that were not
  173392             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  173393             :  * distinguish valid from invalid objects! 
  173394             :  */
  173395             : unsigned long
  173396           5 : SgSIMDPartialStore::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  173397             :    {
  173398           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  173399           5 :      SgSIMDPartialStore* pointer = NULL;
  173400           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  173401           5 :      std::vector < unsigned char* > :: const_iterator block;
  173402           5 :      for ( block = SgSIMDPartialStore::pools.begin(); block != SgSIMDPartialStore::pools.end() ; ++block )
  173403             :         {
  173404           0 :           pointer = (SgSIMDPartialStore*)(*block);
  173405           0 :           for (unsigned i = 0; i < SgSIMDPartialStore::pool_size; ++i )
  173406             :              {
  173407             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  173408             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  173409             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  173410             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  173411             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  173412             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  173413             :             // properly; so this will have to be checked next.
  173414             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  173415             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  173416           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  173417             :                   {
  173418           0 :                     pointer[i].set_freepointer((SgSIMDPartialStore*)(globalIndex));
  173419           0 :                     globalIndex++;
  173420             :                   }
  173421             :                else
  173422             :                   {
  173423           0 :                     pointer[i].set_freepointer(NULL);
  173424             :                   }
  173425             :               }
  173426             :         }
  173427           5 :      return globalIndex;
  173428             :    }
  173429             : 
  173430             : //############################################################################
  173431             : // JH (01/14/2006)
  173432             : void
  173433           5 : SgSIMDPartialStore::resetValidFreepointers( )
  173434             :    {
  173435           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  173436           5 :      SgSIMDPartialStore* pointer = NULL;
  173437           5 :      std::vector < unsigned char* > :: const_iterator block;
  173438           5 :      SgSIMDPartialStore* pointerOfLinkedList = NULL;
  173439           5 :      for ( block = SgSIMDPartialStore::pools.begin(); block != SgSIMDPartialStore::pools.end() ; ++block )
  173440             :         {
  173441           0 :           pointer = (SgSIMDPartialStore*)(*block);
  173442           0 :           for (unsigned i = 0; i < SgSIMDPartialStore::pool_size; ++i )
  173443             :              {
  173444             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  173445             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  173446             :             // memory blocks!.
  173447           0 :                if ( pointer[i].get_freepointer() != NULL )
  173448             :                   {
  173449           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  173450             :                   }
  173451             :                else
  173452             :                   {
  173453           0 :                     if ( pointerOfLinkedList == NULL )
  173454             :                        {
  173455           0 :                          SgSIMDPartialStore::next_node = &(pointer[i]);
  173456             :                        }
  173457             :                     else
  173458             :                        {
  173459             :                       // printf ("In SgSIMDPartialStore::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  173460           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  173461             :                        }
  173462             :                     pointerOfLinkedList = &(pointer[i]);
  173463             :                   }
  173464             :               }
  173465             :         }
  173466             : 
  173467           5 :      if ( pointerOfLinkedList != NULL )
  173468             :         {
  173469             :        // printf ("In SgSIMDPartialStore::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  173470           0 :           pointerOfLinkedList->set_freepointer(NULL);
  173471             :        // DQ (6/6/2010): Temporary debugging...
  173472             :        //   ROSE_ASSERT(false);
  173473             :         }
  173474             : 
  173475           5 :      return ;
  173476             :    }
  173477             : 
  173478             : //############################################################################
  173479             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  173480             :  * within the memory pool and resets the freepointers, in order to achieve a 
  173481             :  * linked list, that has no jumps and starts at the beginning! This function 
  173482             :  * does not extend the memory pool, since we do not delete any memory blocks,
  173483             :  * but delete the valid objects.  
  173484             :  */
  173485             : void
  173486           0 : SgSIMDPartialStore::clearMemoryPool( )
  173487             :    {
  173488             :   // printf ("Inside of SgSIMDPartialStore::clearMemoryPool() \n");
  173489             : 
  173490           0 :      SgSIMDPartialStore* pointer = NULL, *tempPointer = NULL;
  173491           0 :      std::vector < unsigned char* > :: const_iterator block;
  173492           0 :      if ( SgSIMDPartialStore::pools.empty() == false )
  173493             :         {
  173494           0 :           block = SgSIMDPartialStore::pools.begin() ;
  173495           0 :           SgSIMDPartialStore::next_node = (SgSIMDPartialStore*) (*block);
  173496             : 
  173497           0 :           while ( block != SgSIMDPartialStore::pools.end() )
  173498             :              {
  173499           0 :                pointer = (SgSIMDPartialStore*) (*block);
  173500           0 :                if ( tempPointer != NULL )
  173501             :                   {
  173502           0 :                     tempPointer->set_freepointer(pointer);
  173503             :                   }
  173504           0 :                for (unsigned i = 0; i < SgSIMDPartialStore::pool_size - 1; ++i)
  173505             :                   {
  173506           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  173507             :                   }
  173508           0 :                 pointer[SgSIMDPartialStore::pool_size-1].set_freepointer(NULL);
  173509           0 :                 tempPointer = &(pointer[SgSIMDPartialStore::pool_size-1]);
  173510           0 :                 ++block;
  173511             :              }
  173512             :         }
  173513           0 :    }
  173514             : 
  173515           5 : void SgSIMDPartialStore::deleteMemoryPool() {
  173516           5 :   for (auto p: SgSIMDPartialStore::pools) {
  173517           0 :     ROSE_FREE(p);
  173518             :   }
  173519           5 :   SgSIMDPartialStore::next_node = nullptr;
  173520           5 :   SgSIMDPartialStore::pools.clear();
  173521           5 : }
  173522             : 
  173523             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  173524             : //                 reading multiple binary files to for a single AST.
  173525             : /////////// new version ////////////////////////////////
  173526             : //############################################################################
  173527             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  173528             : void
  173529           2 : SgSIMDPartialStore::extendMemoryPoolForFileIO( )
  173530             :   {
  173531           2 :     size_t blockIndex = SgSIMDPartialStore::pools.size();
  173532           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDPartialStore) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDPartialStore);
  173533             : 
  173534           2 :     while ( (blockIndex * SgSIMDPartialStore::pool_size) < newPoolSize)
  173535             :       {
  173536             : #if ROSE_ALLOC_TRACE
  173537             :         if (blockIndex > 0) {
  173538             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDPartialStore) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDPartialStore) = %" PRIuPTR " SgSIMDPartialStore::pool_size = %d \n",
  173539             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDPartialStore),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDPartialStore),SgSIMDPartialStore::pool_size);
  173540             :         }
  173541             : #endif
  173542             : 
  173543           0 :         SgSIMDPartialStore * pointer = (SgSIMDPartialStore*) ROSE_MALLOC ( SgSIMDPartialStore::pool_size * sizeof(SgSIMDPartialStore) );
  173544           0 :         assert( pointer != NULL );
  173545             : #if ROSE_ALLOC_MEMSET == 1
  173546             :         memset(pointer, 0x00, SgSIMDPartialStore::pool_size * sizeof(SgSIMDPartialStore));
  173547             : #elif ROSE_ALLOC_MEMSET == 2
  173548             :         memset(pointer, 0xCC, SgSIMDPartialStore::pool_size * sizeof(SgSIMDPartialStore));
  173549             : #endif
  173550           0 :         SgSIMDPartialStore::pools.push_back( (unsigned char*)(pointer) );
  173551           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDPartialStore::pool_size * sizeof(SgSIMDPartialStore), V_SgSIMDPartialStore ) );
  173552             : 
  173553           0 :         if ( SgSIMDPartialStore::next_node != NULL ) {
  173554           0 :           if ( blockIndex > 0 ) {
  173555           0 :             SgSIMDPartialStore * blkptr = (SgSIMDPartialStore*)(SgSIMDPartialStore::pools[blockIndex-1]);
  173556           0 :             blkptr[ SgSIMDPartialStore::pool_size - 1 ].set_freepointer(pointer);
  173557             :           }
  173558             :         } else {
  173559           0 :           SgSIMDPartialStore::next_node = pointer;
  173560             :         }
  173561             : 
  173562           0 :         for (unsigned i = 0; i < SgSIMDPartialStore::pool_size-1; ++i)
  173563             :            {
  173564           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  173565             :            }
  173566           0 :         pointer[ SgSIMDPartialStore::pool_size -1 ].set_freepointer(NULL);
  173567             : 
  173568           0 :         blockIndex++;
  173569             :       }
  173570           2 :   }
  173571             : 
  173572             : //############################################################################
  173573             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  173574             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  173575             :  * not compressed. However, that stuff is not yet implemented! 
  173576             :  */
  173577             : unsigned long
  173578           0 : SgSIMDPartialStore::getNumberOfLastValidPointer()
  173579             :    {
  173580           0 :       SgSIMDPartialStore* testPointer = (SgSIMDPartialStore*)(SgSIMDPartialStore::pools.back());
  173581           0 :       unsigned long localIndex = SgSIMDPartialStore::pool_size - 1;
  173582           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  173583             :          {
  173584           0 :            localIndex--;
  173585             :          }
  173586           0 :       return (localIndex + SgSIMDPartialStore::pool_size * (SgSIMDPartialStore::pools.size()-1));
  173587             :    }
  173588             : 
  173589             : //############################################################################
  173590             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  173591             :  * memory pool and initializes the data member in class SgSIMDPartialStoreStroageClass
  173592             :  * from its counterpart of SgSIMDPartialStore. The return value is just for checking, 
  173593             :  * that the whole StorageClassArray is initialized!
  173594             :  */
  173595             : unsigned long
  173596           0 : SgSIMDPartialStore::initializeStorageClassArray( SgSIMDPartialStoreStorageClass *storageArray )
  173597             :    {
  173598           0 :      unsigned long storageCounter = 0;
  173599           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDPartialStore::pools.begin();
  173600           0 :      SgSIMDPartialStore* pointer = NULL;
  173601           0 :      while ( block != SgSIMDPartialStore::pools.end() ) {
  173602           0 :           pointer = (SgSIMDPartialStore*) (*block);
  173603           0 :           for ( unsigned i = 0; i < SgSIMDPartialStore::pool_size; ++i ) {
  173604           0 :                if ( pointer->get_freepointer() != NULL ) {
  173605           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  173606           0 :                  storageArray++;
  173607           0 :                  storageCounter++;
  173608             :                }
  173609           0 :                pointer++;
  173610             :              }
  173611           0 :            block++;
  173612             :         }
  173613           0 :      return storageCounter;
  173614             :    }
  173615             : 
  173616             : /* #line 173617 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  173617             : 
  173618             : 
  173619             : 
  173620             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  173621             : 
  173622             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  173623             : 
  173624             : //############################################################################
  173625             : /* JH (02/02/2006) Constructor of the IR node SgSIMDScalarStore that takes its 
  173626             :  * corresponding StorageClass as parameter
  173627             :  */
  173628           0 : SgSIMDScalarStore :: SgSIMDScalarStore ( const SgSIMDScalarStoreStorageClass& storageSource )   : SgBinaryOp (storageSource)
  173629             :    {
  173630             : 
  173631             : 
  173632             : /* #line 173633 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  173633             : 
  173634           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  173635             : 
  173636             : 
  173637             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  173638             : 
  173639             : 
  173640           0 :    }
  173641             : 
  173642             : //############################################################################
  173643             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  173644             :  * within the working AST. 
  173645             :  */
  173646           0 : SgSIMDScalarStore * SgSIMDScalarStore::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  173647           0 :      SgSIMDScalarStore* returnPointer = NULL;
  173648           0 :      if ( globalIndex != 0 )
  173649             :         {
  173650             : 
  173651             : #if FILE_IO_EXTRA_CHECK
  173652           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDScalarStore ) ) <= globalIndex ) ;
  173653           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDScalarStore + 1 ) ) );
  173654             : #endif
  173655           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDScalarStore )  
  173656           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDScalarStore );
  173657           0 :           unsigned long positionInPool = localIndex % SgSIMDScalarStore::pool_size;
  173658           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDScalarStore::pool_size;
  173659             : 
  173660             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  173661             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  173662             : 
  173663           0 :           returnPointer = &( ( (SgSIMDScalarStore*)(SgSIMDScalarStore::pools[memoryBlock]) ) [positionInPool]) ;
  173664             : 
  173665           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  173666             :         }
  173667           0 :      return returnPointer ;
  173668             :    }
  173669             : 
  173670             : //############################################################################
  173671             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  173672             :   for the AST with the index astIndex
  173673             : */
  173674           0 : SgSIMDScalarStore * SgSIMDScalarStore::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  173675           0 :      SgSIMDScalarStore* returnPointer = NULL;
  173676           0 :      if ( globalIndex != 0 )
  173677             :         {
  173678             : 
  173679             : #if FILE_IO_EXTRA_CHECK
  173680           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDScalarStore ) ) <= globalIndex ) ;
  173681           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDScalarStore + 1 ) ) );
  173682             : #endif
  173683           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDScalarStore )
  173684           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDScalarStore );
  173685           0 :           unsigned long positionInPool = localIndex % SgSIMDScalarStore::pool_size ;
  173686           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDScalarStore::pool_size ;
  173687             : 
  173688             : #if FILE_IO_EXTRA_CHECK
  173689             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  173690             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  173691             : #endif
  173692             : 
  173693           0 :           returnPointer = &( ( (SgSIMDScalarStore*)(SgSIMDScalarStore::pools[memoryBlock]) ) [positionInPool]) ;
  173694             : 
  173695             : #if FILE_IO_EXTRA_CHECK
  173696           0 :           assert ( returnPointer != NULL ) ;
  173697             : #endif
  173698             :         }
  173699           0 :      return returnPointer ;
  173700             :    }
  173701             : 
  173702             : //############################################################################
  173703             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  173704             :  * pool size! We set for every valid object in the memory pool the freepointer
  173705             :  * to the global index and increase the global index afterwards. For all the 
  173706             :  * invalid objects (means address ranges within the memory pool that were not
  173707             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  173708             :  * distinguish valid from invalid objects! 
  173709             :  */
  173710             : unsigned long
  173711           5 : SgSIMDScalarStore::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  173712             :    {
  173713           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  173714           5 :      SgSIMDScalarStore* pointer = NULL;
  173715           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  173716           5 :      std::vector < unsigned char* > :: const_iterator block;
  173717           5 :      for ( block = SgSIMDScalarStore::pools.begin(); block != SgSIMDScalarStore::pools.end() ; ++block )
  173718             :         {
  173719           0 :           pointer = (SgSIMDScalarStore*)(*block);
  173720           0 :           for (unsigned i = 0; i < SgSIMDScalarStore::pool_size; ++i )
  173721             :              {
  173722             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  173723             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  173724             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  173725             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  173726             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  173727             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  173728             :             // properly; so this will have to be checked next.
  173729             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  173730             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  173731           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  173732             :                   {
  173733           0 :                     pointer[i].set_freepointer((SgSIMDScalarStore*)(globalIndex));
  173734           0 :                     globalIndex++;
  173735             :                   }
  173736             :                else
  173737             :                   {
  173738           0 :                     pointer[i].set_freepointer(NULL);
  173739             :                   }
  173740             :               }
  173741             :         }
  173742           5 :      return globalIndex;
  173743             :    }
  173744             : 
  173745             : //############################################################################
  173746             : // JH (01/14/2006)
  173747             : void
  173748           5 : SgSIMDScalarStore::resetValidFreepointers( )
  173749             :    {
  173750           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  173751           5 :      SgSIMDScalarStore* pointer = NULL;
  173752           5 :      std::vector < unsigned char* > :: const_iterator block;
  173753           5 :      SgSIMDScalarStore* pointerOfLinkedList = NULL;
  173754           5 :      for ( block = SgSIMDScalarStore::pools.begin(); block != SgSIMDScalarStore::pools.end() ; ++block )
  173755             :         {
  173756           0 :           pointer = (SgSIMDScalarStore*)(*block);
  173757           0 :           for (unsigned i = 0; i < SgSIMDScalarStore::pool_size; ++i )
  173758             :              {
  173759             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  173760             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  173761             :             // memory blocks!.
  173762           0 :                if ( pointer[i].get_freepointer() != NULL )
  173763             :                   {
  173764           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  173765             :                   }
  173766             :                else
  173767             :                   {
  173768           0 :                     if ( pointerOfLinkedList == NULL )
  173769             :                        {
  173770           0 :                          SgSIMDScalarStore::next_node = &(pointer[i]);
  173771             :                        }
  173772             :                     else
  173773             :                        {
  173774             :                       // printf ("In SgSIMDScalarStore::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  173775           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  173776             :                        }
  173777             :                     pointerOfLinkedList = &(pointer[i]);
  173778             :                   }
  173779             :               }
  173780             :         }
  173781             : 
  173782           5 :      if ( pointerOfLinkedList != NULL )
  173783             :         {
  173784             :        // printf ("In SgSIMDScalarStore::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  173785           0 :           pointerOfLinkedList->set_freepointer(NULL);
  173786             :        // DQ (6/6/2010): Temporary debugging...
  173787             :        //   ROSE_ASSERT(false);
  173788             :         }
  173789             : 
  173790           5 :      return ;
  173791             :    }
  173792             : 
  173793             : //############################################################################
  173794             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  173795             :  * within the memory pool and resets the freepointers, in order to achieve a 
  173796             :  * linked list, that has no jumps and starts at the beginning! This function 
  173797             :  * does not extend the memory pool, since we do not delete any memory blocks,
  173798             :  * but delete the valid objects.  
  173799             :  */
  173800             : void
  173801           0 : SgSIMDScalarStore::clearMemoryPool( )
  173802             :    {
  173803             :   // printf ("Inside of SgSIMDScalarStore::clearMemoryPool() \n");
  173804             : 
  173805           0 :      SgSIMDScalarStore* pointer = NULL, *tempPointer = NULL;
  173806           0 :      std::vector < unsigned char* > :: const_iterator block;
  173807           0 :      if ( SgSIMDScalarStore::pools.empty() == false )
  173808             :         {
  173809           0 :           block = SgSIMDScalarStore::pools.begin() ;
  173810           0 :           SgSIMDScalarStore::next_node = (SgSIMDScalarStore*) (*block);
  173811             : 
  173812           0 :           while ( block != SgSIMDScalarStore::pools.end() )
  173813             :              {
  173814           0 :                pointer = (SgSIMDScalarStore*) (*block);
  173815           0 :                if ( tempPointer != NULL )
  173816             :                   {
  173817           0 :                     tempPointer->set_freepointer(pointer);
  173818             :                   }
  173819           0 :                for (unsigned i = 0; i < SgSIMDScalarStore::pool_size - 1; ++i)
  173820             :                   {
  173821           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  173822             :                   }
  173823           0 :                 pointer[SgSIMDScalarStore::pool_size-1].set_freepointer(NULL);
  173824           0 :                 tempPointer = &(pointer[SgSIMDScalarStore::pool_size-1]);
  173825           0 :                 ++block;
  173826             :              }
  173827             :         }
  173828           0 :    }
  173829             : 
  173830           5 : void SgSIMDScalarStore::deleteMemoryPool() {
  173831           5 :   for (auto p: SgSIMDScalarStore::pools) {
  173832           0 :     ROSE_FREE(p);
  173833             :   }
  173834           5 :   SgSIMDScalarStore::next_node = nullptr;
  173835           5 :   SgSIMDScalarStore::pools.clear();
  173836           5 : }
  173837             : 
  173838             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  173839             : //                 reading multiple binary files to for a single AST.
  173840             : /////////// new version ////////////////////////////////
  173841             : //############################################################################
  173842             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  173843             : void
  173844           2 : SgSIMDScalarStore::extendMemoryPoolForFileIO( )
  173845             :   {
  173846           2 :     size_t blockIndex = SgSIMDScalarStore::pools.size();
  173847           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDScalarStore) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDScalarStore);
  173848             : 
  173849           2 :     while ( (blockIndex * SgSIMDScalarStore::pool_size) < newPoolSize)
  173850             :       {
  173851             : #if ROSE_ALLOC_TRACE
  173852             :         if (blockIndex > 0) {
  173853             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDScalarStore) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDScalarStore) = %" PRIuPTR " SgSIMDScalarStore::pool_size = %d \n",
  173854             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDScalarStore),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDScalarStore),SgSIMDScalarStore::pool_size);
  173855             :         }
  173856             : #endif
  173857             : 
  173858           0 :         SgSIMDScalarStore * pointer = (SgSIMDScalarStore*) ROSE_MALLOC ( SgSIMDScalarStore::pool_size * sizeof(SgSIMDScalarStore) );
  173859           0 :         assert( pointer != NULL );
  173860             : #if ROSE_ALLOC_MEMSET == 1
  173861             :         memset(pointer, 0x00, SgSIMDScalarStore::pool_size * sizeof(SgSIMDScalarStore));
  173862             : #elif ROSE_ALLOC_MEMSET == 2
  173863             :         memset(pointer, 0xCC, SgSIMDScalarStore::pool_size * sizeof(SgSIMDScalarStore));
  173864             : #endif
  173865           0 :         SgSIMDScalarStore::pools.push_back( (unsigned char*)(pointer) );
  173866           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDScalarStore::pool_size * sizeof(SgSIMDScalarStore), V_SgSIMDScalarStore ) );
  173867             : 
  173868           0 :         if ( SgSIMDScalarStore::next_node != NULL ) {
  173869           0 :           if ( blockIndex > 0 ) {
  173870           0 :             SgSIMDScalarStore * blkptr = (SgSIMDScalarStore*)(SgSIMDScalarStore::pools[blockIndex-1]);
  173871           0 :             blkptr[ SgSIMDScalarStore::pool_size - 1 ].set_freepointer(pointer);
  173872             :           }
  173873             :         } else {
  173874           0 :           SgSIMDScalarStore::next_node = pointer;
  173875             :         }
  173876             : 
  173877           0 :         for (unsigned i = 0; i < SgSIMDScalarStore::pool_size-1; ++i)
  173878             :            {
  173879           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  173880             :            }
  173881           0 :         pointer[ SgSIMDScalarStore::pool_size -1 ].set_freepointer(NULL);
  173882             : 
  173883           0 :         blockIndex++;
  173884             :       }
  173885           2 :   }
  173886             : 
  173887             : //############################################################################
  173888             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  173889             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  173890             :  * not compressed. However, that stuff is not yet implemented! 
  173891             :  */
  173892             : unsigned long
  173893           0 : SgSIMDScalarStore::getNumberOfLastValidPointer()
  173894             :    {
  173895           0 :       SgSIMDScalarStore* testPointer = (SgSIMDScalarStore*)(SgSIMDScalarStore::pools.back());
  173896           0 :       unsigned long localIndex = SgSIMDScalarStore::pool_size - 1;
  173897           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  173898             :          {
  173899           0 :            localIndex--;
  173900             :          }
  173901           0 :       return (localIndex + SgSIMDScalarStore::pool_size * (SgSIMDScalarStore::pools.size()-1));
  173902             :    }
  173903             : 
  173904             : //############################################################################
  173905             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  173906             :  * memory pool and initializes the data member in class SgSIMDScalarStoreStroageClass
  173907             :  * from its counterpart of SgSIMDScalarStore. The return value is just for checking, 
  173908             :  * that the whole StorageClassArray is initialized!
  173909             :  */
  173910             : unsigned long
  173911           0 : SgSIMDScalarStore::initializeStorageClassArray( SgSIMDScalarStoreStorageClass *storageArray )
  173912             :    {
  173913           0 :      unsigned long storageCounter = 0;
  173914           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDScalarStore::pools.begin();
  173915           0 :      SgSIMDScalarStore* pointer = NULL;
  173916           0 :      while ( block != SgSIMDScalarStore::pools.end() ) {
  173917           0 :           pointer = (SgSIMDScalarStore*) (*block);
  173918           0 :           for ( unsigned i = 0; i < SgSIMDScalarStore::pool_size; ++i ) {
  173919           0 :                if ( pointer->get_freepointer() != NULL ) {
  173920           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  173921           0 :                  storageArray++;
  173922           0 :                  storageCounter++;
  173923             :                }
  173924           0 :                pointer++;
  173925             :              }
  173926           0 :            block++;
  173927             :         }
  173928           0 :      return storageCounter;
  173929             :    }
  173930             : 
  173931             : /* #line 173932 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  173932             : 
  173933             : 
  173934             : 
  173935             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  173936             : 
  173937             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  173938             : 
  173939             : //############################################################################
  173940             : /* JH (02/02/2006) Constructor of the IR node SgSIMDGather that takes its 
  173941             :  * corresponding StorageClass as parameter
  173942             :  */
  173943           0 : SgSIMDGather :: SgSIMDGather ( const SgSIMDGatherStorageClass& storageSource )   : SgBinaryOp (storageSource)
  173944             :    {
  173945             : 
  173946             : 
  173947             : /* #line 173948 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  173948             : 
  173949           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  173950             : 
  173951             : 
  173952             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  173953             : 
  173954             : 
  173955           0 :    }
  173956             : 
  173957             : //############################################################################
  173958             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  173959             :  * within the working AST. 
  173960             :  */
  173961           0 : SgSIMDGather * SgSIMDGather::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  173962           0 :      SgSIMDGather* returnPointer = NULL;
  173963           0 :      if ( globalIndex != 0 )
  173964             :         {
  173965             : 
  173966             : #if FILE_IO_EXTRA_CHECK
  173967           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDGather ) ) <= globalIndex ) ;
  173968           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDGather + 1 ) ) );
  173969             : #endif
  173970           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDGather )  
  173971           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDGather );
  173972           0 :           unsigned long positionInPool = localIndex % SgSIMDGather::pool_size;
  173973           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDGather::pool_size;
  173974             : 
  173975             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  173976             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  173977             : 
  173978           0 :           returnPointer = &( ( (SgSIMDGather*)(SgSIMDGather::pools[memoryBlock]) ) [positionInPool]) ;
  173979             : 
  173980           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  173981             :         }
  173982           0 :      return returnPointer ;
  173983             :    }
  173984             : 
  173985             : //############################################################################
  173986             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  173987             :   for the AST with the index astIndex
  173988             : */
  173989           0 : SgSIMDGather * SgSIMDGather::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  173990           0 :      SgSIMDGather* returnPointer = NULL;
  173991           0 :      if ( globalIndex != 0 )
  173992             :         {
  173993             : 
  173994             : #if FILE_IO_EXTRA_CHECK
  173995           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDGather ) ) <= globalIndex ) ;
  173996           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDGather + 1 ) ) );
  173997             : #endif
  173998           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDGather )
  173999           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDGather );
  174000           0 :           unsigned long positionInPool = localIndex % SgSIMDGather::pool_size ;
  174001           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDGather::pool_size ;
  174002             : 
  174003             : #if FILE_IO_EXTRA_CHECK
  174004             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  174005             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  174006             : #endif
  174007             : 
  174008           0 :           returnPointer = &( ( (SgSIMDGather*)(SgSIMDGather::pools[memoryBlock]) ) [positionInPool]) ;
  174009             : 
  174010             : #if FILE_IO_EXTRA_CHECK
  174011           0 :           assert ( returnPointer != NULL ) ;
  174012             : #endif
  174013             :         }
  174014           0 :      return returnPointer ;
  174015             :    }
  174016             : 
  174017             : //############################################################################
  174018             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  174019             :  * pool size! We set for every valid object in the memory pool the freepointer
  174020             :  * to the global index and increase the global index afterwards. For all the 
  174021             :  * invalid objects (means address ranges within the memory pool that were not
  174022             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  174023             :  * distinguish valid from invalid objects! 
  174024             :  */
  174025             : unsigned long
  174026           5 : SgSIMDGather::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  174027             :    {
  174028           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  174029           5 :      SgSIMDGather* pointer = NULL;
  174030           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  174031           5 :      std::vector < unsigned char* > :: const_iterator block;
  174032           5 :      for ( block = SgSIMDGather::pools.begin(); block != SgSIMDGather::pools.end() ; ++block )
  174033             :         {
  174034           0 :           pointer = (SgSIMDGather*)(*block);
  174035           0 :           for (unsigned i = 0; i < SgSIMDGather::pool_size; ++i )
  174036             :              {
  174037             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  174038             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  174039             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  174040             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  174041             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  174042             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  174043             :             // properly; so this will have to be checked next.
  174044             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  174045             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  174046           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  174047             :                   {
  174048           0 :                     pointer[i].set_freepointer((SgSIMDGather*)(globalIndex));
  174049           0 :                     globalIndex++;
  174050             :                   }
  174051             :                else
  174052             :                   {
  174053           0 :                     pointer[i].set_freepointer(NULL);
  174054             :                   }
  174055             :               }
  174056             :         }
  174057           5 :      return globalIndex;
  174058             :    }
  174059             : 
  174060             : //############################################################################
  174061             : // JH (01/14/2006)
  174062             : void
  174063           5 : SgSIMDGather::resetValidFreepointers( )
  174064             :    {
  174065           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  174066           5 :      SgSIMDGather* pointer = NULL;
  174067           5 :      std::vector < unsigned char* > :: const_iterator block;
  174068           5 :      SgSIMDGather* pointerOfLinkedList = NULL;
  174069           5 :      for ( block = SgSIMDGather::pools.begin(); block != SgSIMDGather::pools.end() ; ++block )
  174070             :         {
  174071           0 :           pointer = (SgSIMDGather*)(*block);
  174072           0 :           for (unsigned i = 0; i < SgSIMDGather::pool_size; ++i )
  174073             :              {
  174074             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  174075             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  174076             :             // memory blocks!.
  174077           0 :                if ( pointer[i].get_freepointer() != NULL )
  174078             :                   {
  174079           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  174080             :                   }
  174081             :                else
  174082             :                   {
  174083           0 :                     if ( pointerOfLinkedList == NULL )
  174084             :                        {
  174085           0 :                          SgSIMDGather::next_node = &(pointer[i]);
  174086             :                        }
  174087             :                     else
  174088             :                        {
  174089             :                       // printf ("In SgSIMDGather::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  174090           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  174091             :                        }
  174092             :                     pointerOfLinkedList = &(pointer[i]);
  174093             :                   }
  174094             :               }
  174095             :         }
  174096             : 
  174097           5 :      if ( pointerOfLinkedList != NULL )
  174098             :         {
  174099             :        // printf ("In SgSIMDGather::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  174100           0 :           pointerOfLinkedList->set_freepointer(NULL);
  174101             :        // DQ (6/6/2010): Temporary debugging...
  174102             :        //   ROSE_ASSERT(false);
  174103             :         }
  174104             : 
  174105           5 :      return ;
  174106             :    }
  174107             : 
  174108             : //############################################################################
  174109             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  174110             :  * within the memory pool and resets the freepointers, in order to achieve a 
  174111             :  * linked list, that has no jumps and starts at the beginning! This function 
  174112             :  * does not extend the memory pool, since we do not delete any memory blocks,
  174113             :  * but delete the valid objects.  
  174114             :  */
  174115             : void
  174116           0 : SgSIMDGather::clearMemoryPool( )
  174117             :    {
  174118             :   // printf ("Inside of SgSIMDGather::clearMemoryPool() \n");
  174119             : 
  174120           0 :      SgSIMDGather* pointer = NULL, *tempPointer = NULL;
  174121           0 :      std::vector < unsigned char* > :: const_iterator block;
  174122           0 :      if ( SgSIMDGather::pools.empty() == false )
  174123             :         {
  174124           0 :           block = SgSIMDGather::pools.begin() ;
  174125           0 :           SgSIMDGather::next_node = (SgSIMDGather*) (*block);
  174126             : 
  174127           0 :           while ( block != SgSIMDGather::pools.end() )
  174128             :              {
  174129           0 :                pointer = (SgSIMDGather*) (*block);
  174130           0 :                if ( tempPointer != NULL )
  174131             :                   {
  174132           0 :                     tempPointer->set_freepointer(pointer);
  174133             :                   }
  174134           0 :                for (unsigned i = 0; i < SgSIMDGather::pool_size - 1; ++i)
  174135             :                   {
  174136           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  174137             :                   }
  174138           0 :                 pointer[SgSIMDGather::pool_size-1].set_freepointer(NULL);
  174139           0 :                 tempPointer = &(pointer[SgSIMDGather::pool_size-1]);
  174140           0 :                 ++block;
  174141             :              }
  174142             :         }
  174143           0 :    }
  174144             : 
  174145           5 : void SgSIMDGather::deleteMemoryPool() {
  174146           5 :   for (auto p: SgSIMDGather::pools) {
  174147           0 :     ROSE_FREE(p);
  174148             :   }
  174149           5 :   SgSIMDGather::next_node = nullptr;
  174150           5 :   SgSIMDGather::pools.clear();
  174151           5 : }
  174152             : 
  174153             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  174154             : //                 reading multiple binary files to for a single AST.
  174155             : /////////// new version ////////////////////////////////
  174156             : //############################################################################
  174157             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  174158             : void
  174159           2 : SgSIMDGather::extendMemoryPoolForFileIO( )
  174160             :   {
  174161           2 :     size_t blockIndex = SgSIMDGather::pools.size();
  174162           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDGather) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDGather);
  174163             : 
  174164           2 :     while ( (blockIndex * SgSIMDGather::pool_size) < newPoolSize)
  174165             :       {
  174166             : #if ROSE_ALLOC_TRACE
  174167             :         if (blockIndex > 0) {
  174168             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDGather) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDGather) = %" PRIuPTR " SgSIMDGather::pool_size = %d \n",
  174169             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDGather),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDGather),SgSIMDGather::pool_size);
  174170             :         }
  174171             : #endif
  174172             : 
  174173           0 :         SgSIMDGather * pointer = (SgSIMDGather*) ROSE_MALLOC ( SgSIMDGather::pool_size * sizeof(SgSIMDGather) );
  174174           0 :         assert( pointer != NULL );
  174175             : #if ROSE_ALLOC_MEMSET == 1
  174176             :         memset(pointer, 0x00, SgSIMDGather::pool_size * sizeof(SgSIMDGather));
  174177             : #elif ROSE_ALLOC_MEMSET == 2
  174178             :         memset(pointer, 0xCC, SgSIMDGather::pool_size * sizeof(SgSIMDGather));
  174179             : #endif
  174180           0 :         SgSIMDGather::pools.push_back( (unsigned char*)(pointer) );
  174181           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDGather::pool_size * sizeof(SgSIMDGather), V_SgSIMDGather ) );
  174182             : 
  174183           0 :         if ( SgSIMDGather::next_node != NULL ) {
  174184           0 :           if ( blockIndex > 0 ) {
  174185           0 :             SgSIMDGather * blkptr = (SgSIMDGather*)(SgSIMDGather::pools[blockIndex-1]);
  174186           0 :             blkptr[ SgSIMDGather::pool_size - 1 ].set_freepointer(pointer);
  174187             :           }
  174188             :         } else {
  174189           0 :           SgSIMDGather::next_node = pointer;
  174190             :         }
  174191             : 
  174192           0 :         for (unsigned i = 0; i < SgSIMDGather::pool_size-1; ++i)
  174193             :            {
  174194           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  174195             :            }
  174196           0 :         pointer[ SgSIMDGather::pool_size -1 ].set_freepointer(NULL);
  174197             : 
  174198           0 :         blockIndex++;
  174199             :       }
  174200           2 :   }
  174201             : 
  174202             : //############################################################################
  174203             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  174204             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  174205             :  * not compressed. However, that stuff is not yet implemented! 
  174206             :  */
  174207             : unsigned long
  174208           0 : SgSIMDGather::getNumberOfLastValidPointer()
  174209             :    {
  174210           0 :       SgSIMDGather* testPointer = (SgSIMDGather*)(SgSIMDGather::pools.back());
  174211           0 :       unsigned long localIndex = SgSIMDGather::pool_size - 1;
  174212           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  174213             :          {
  174214           0 :            localIndex--;
  174215             :          }
  174216           0 :       return (localIndex + SgSIMDGather::pool_size * (SgSIMDGather::pools.size()-1));
  174217             :    }
  174218             : 
  174219             : //############################################################################
  174220             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  174221             :  * memory pool and initializes the data member in class SgSIMDGatherStroageClass
  174222             :  * from its counterpart of SgSIMDGather. The return value is just for checking, 
  174223             :  * that the whole StorageClassArray is initialized!
  174224             :  */
  174225             : unsigned long
  174226           0 : SgSIMDGather::initializeStorageClassArray( SgSIMDGatherStorageClass *storageArray )
  174227             :    {
  174228           0 :      unsigned long storageCounter = 0;
  174229           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDGather::pools.begin();
  174230           0 :      SgSIMDGather* pointer = NULL;
  174231           0 :      while ( block != SgSIMDGather::pools.end() ) {
  174232           0 :           pointer = (SgSIMDGather*) (*block);
  174233           0 :           for ( unsigned i = 0; i < SgSIMDGather::pool_size; ++i ) {
  174234           0 :                if ( pointer->get_freepointer() != NULL ) {
  174235           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  174236           0 :                  storageArray++;
  174237           0 :                  storageCounter++;
  174238             :                }
  174239           0 :                pointer++;
  174240             :              }
  174241           0 :            block++;
  174242             :         }
  174243           0 :      return storageCounter;
  174244             :    }
  174245             : 
  174246             : /* #line 174247 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  174247             : 
  174248             : 
  174249             : 
  174250             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  174251             : 
  174252             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  174253             : 
  174254             : //############################################################################
  174255             : /* JH (02/02/2006) Constructor of the IR node SgSIMDExplicitGather that takes its 
  174256             :  * corresponding StorageClass as parameter
  174257             :  */
  174258           0 : SgSIMDExplicitGather :: SgSIMDExplicitGather ( const SgSIMDExplicitGatherStorageClass& storageSource )   : SgBinaryOp (storageSource)
  174259             :    {
  174260             : 
  174261             : 
  174262             : /* #line 174263 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  174263             : 
  174264           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  174265             : 
  174266             : 
  174267             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  174268             : 
  174269             : 
  174270           0 :    }
  174271             : 
  174272             : //############################################################################
  174273             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  174274             :  * within the working AST. 
  174275             :  */
  174276           0 : SgSIMDExplicitGather * SgSIMDExplicitGather::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  174277           0 :      SgSIMDExplicitGather* returnPointer = NULL;
  174278           0 :      if ( globalIndex != 0 )
  174279             :         {
  174280             : 
  174281             : #if FILE_IO_EXTRA_CHECK
  174282           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDExplicitGather ) ) <= globalIndex ) ;
  174283           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDExplicitGather + 1 ) ) );
  174284             : #endif
  174285           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDExplicitGather )  
  174286           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDExplicitGather );
  174287           0 :           unsigned long positionInPool = localIndex % SgSIMDExplicitGather::pool_size;
  174288           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDExplicitGather::pool_size;
  174289             : 
  174290             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  174291             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  174292             : 
  174293           0 :           returnPointer = &( ( (SgSIMDExplicitGather*)(SgSIMDExplicitGather::pools[memoryBlock]) ) [positionInPool]) ;
  174294             : 
  174295           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  174296             :         }
  174297           0 :      return returnPointer ;
  174298             :    }
  174299             : 
  174300             : //############################################################################
  174301             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  174302             :   for the AST with the index astIndex
  174303             : */
  174304           0 : SgSIMDExplicitGather * SgSIMDExplicitGather::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  174305           0 :      SgSIMDExplicitGather* returnPointer = NULL;
  174306           0 :      if ( globalIndex != 0 )
  174307             :         {
  174308             : 
  174309             : #if FILE_IO_EXTRA_CHECK
  174310           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDExplicitGather ) ) <= globalIndex ) ;
  174311           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDExplicitGather + 1 ) ) );
  174312             : #endif
  174313           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDExplicitGather )
  174314           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDExplicitGather );
  174315           0 :           unsigned long positionInPool = localIndex % SgSIMDExplicitGather::pool_size ;
  174316           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDExplicitGather::pool_size ;
  174317             : 
  174318             : #if FILE_IO_EXTRA_CHECK
  174319             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  174320             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  174321             : #endif
  174322             : 
  174323           0 :           returnPointer = &( ( (SgSIMDExplicitGather*)(SgSIMDExplicitGather::pools[memoryBlock]) ) [positionInPool]) ;
  174324             : 
  174325             : #if FILE_IO_EXTRA_CHECK
  174326           0 :           assert ( returnPointer != NULL ) ;
  174327             : #endif
  174328             :         }
  174329           0 :      return returnPointer ;
  174330             :    }
  174331             : 
  174332             : //############################################################################
  174333             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  174334             :  * pool size! We set for every valid object in the memory pool the freepointer
  174335             :  * to the global index and increase the global index afterwards. For all the 
  174336             :  * invalid objects (means address ranges within the memory pool that were not
  174337             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  174338             :  * distinguish valid from invalid objects! 
  174339             :  */
  174340             : unsigned long
  174341           5 : SgSIMDExplicitGather::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  174342             :    {
  174343           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  174344           5 :      SgSIMDExplicitGather* pointer = NULL;
  174345           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  174346           5 :      std::vector < unsigned char* > :: const_iterator block;
  174347           5 :      for ( block = SgSIMDExplicitGather::pools.begin(); block != SgSIMDExplicitGather::pools.end() ; ++block )
  174348             :         {
  174349           0 :           pointer = (SgSIMDExplicitGather*)(*block);
  174350           0 :           for (unsigned i = 0; i < SgSIMDExplicitGather::pool_size; ++i )
  174351             :              {
  174352             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  174353             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  174354             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  174355             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  174356             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  174357             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  174358             :             // properly; so this will have to be checked next.
  174359             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  174360             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  174361           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  174362             :                   {
  174363           0 :                     pointer[i].set_freepointer((SgSIMDExplicitGather*)(globalIndex));
  174364           0 :                     globalIndex++;
  174365             :                   }
  174366             :                else
  174367             :                   {
  174368           0 :                     pointer[i].set_freepointer(NULL);
  174369             :                   }
  174370             :               }
  174371             :         }
  174372           5 :      return globalIndex;
  174373             :    }
  174374             : 
  174375             : //############################################################################
  174376             : // JH (01/14/2006)
  174377             : void
  174378           5 : SgSIMDExplicitGather::resetValidFreepointers( )
  174379             :    {
  174380           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  174381           5 :      SgSIMDExplicitGather* pointer = NULL;
  174382           5 :      std::vector < unsigned char* > :: const_iterator block;
  174383           5 :      SgSIMDExplicitGather* pointerOfLinkedList = NULL;
  174384           5 :      for ( block = SgSIMDExplicitGather::pools.begin(); block != SgSIMDExplicitGather::pools.end() ; ++block )
  174385             :         {
  174386           0 :           pointer = (SgSIMDExplicitGather*)(*block);
  174387           0 :           for (unsigned i = 0; i < SgSIMDExplicitGather::pool_size; ++i )
  174388             :              {
  174389             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  174390             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  174391             :             // memory blocks!.
  174392           0 :                if ( pointer[i].get_freepointer() != NULL )
  174393             :                   {
  174394           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  174395             :                   }
  174396             :                else
  174397             :                   {
  174398           0 :                     if ( pointerOfLinkedList == NULL )
  174399             :                        {
  174400           0 :                          SgSIMDExplicitGather::next_node = &(pointer[i]);
  174401             :                        }
  174402             :                     else
  174403             :                        {
  174404             :                       // printf ("In SgSIMDExplicitGather::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  174405           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  174406             :                        }
  174407             :                     pointerOfLinkedList = &(pointer[i]);
  174408             :                   }
  174409             :               }
  174410             :         }
  174411             : 
  174412           5 :      if ( pointerOfLinkedList != NULL )
  174413             :         {
  174414             :        // printf ("In SgSIMDExplicitGather::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  174415           0 :           pointerOfLinkedList->set_freepointer(NULL);
  174416             :        // DQ (6/6/2010): Temporary debugging...
  174417             :        //   ROSE_ASSERT(false);
  174418             :         }
  174419             : 
  174420           5 :      return ;
  174421             :    }
  174422             : 
  174423             : //############################################################################
  174424             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  174425             :  * within the memory pool and resets the freepointers, in order to achieve a 
  174426             :  * linked list, that has no jumps and starts at the beginning! This function 
  174427             :  * does not extend the memory pool, since we do not delete any memory blocks,
  174428             :  * but delete the valid objects.  
  174429             :  */
  174430             : void
  174431           0 : SgSIMDExplicitGather::clearMemoryPool( )
  174432             :    {
  174433             :   // printf ("Inside of SgSIMDExplicitGather::clearMemoryPool() \n");
  174434             : 
  174435           0 :      SgSIMDExplicitGather* pointer = NULL, *tempPointer = NULL;
  174436           0 :      std::vector < unsigned char* > :: const_iterator block;
  174437           0 :      if ( SgSIMDExplicitGather::pools.empty() == false )
  174438             :         {
  174439           0 :           block = SgSIMDExplicitGather::pools.begin() ;
  174440           0 :           SgSIMDExplicitGather::next_node = (SgSIMDExplicitGather*) (*block);
  174441             : 
  174442           0 :           while ( block != SgSIMDExplicitGather::pools.end() )
  174443             :              {
  174444           0 :                pointer = (SgSIMDExplicitGather*) (*block);
  174445           0 :                if ( tempPointer != NULL )
  174446             :                   {
  174447           0 :                     tempPointer->set_freepointer(pointer);
  174448             :                   }
  174449           0 :                for (unsigned i = 0; i < SgSIMDExplicitGather::pool_size - 1; ++i)
  174450             :                   {
  174451           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  174452             :                   }
  174453           0 :                 pointer[SgSIMDExplicitGather::pool_size-1].set_freepointer(NULL);
  174454           0 :                 tempPointer = &(pointer[SgSIMDExplicitGather::pool_size-1]);
  174455           0 :                 ++block;
  174456             :              }
  174457             :         }
  174458           0 :    }
  174459             : 
  174460           5 : void SgSIMDExplicitGather::deleteMemoryPool() {
  174461           5 :   for (auto p: SgSIMDExplicitGather::pools) {
  174462           0 :     ROSE_FREE(p);
  174463             :   }
  174464           5 :   SgSIMDExplicitGather::next_node = nullptr;
  174465           5 :   SgSIMDExplicitGather::pools.clear();
  174466           5 : }
  174467             : 
  174468             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  174469             : //                 reading multiple binary files to for a single AST.
  174470             : /////////// new version ////////////////////////////////
  174471             : //############################################################################
  174472             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  174473             : void
  174474           2 : SgSIMDExplicitGather::extendMemoryPoolForFileIO( )
  174475             :   {
  174476           2 :     size_t blockIndex = SgSIMDExplicitGather::pools.size();
  174477           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDExplicitGather) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDExplicitGather);
  174478             : 
  174479           2 :     while ( (blockIndex * SgSIMDExplicitGather::pool_size) < newPoolSize)
  174480             :       {
  174481             : #if ROSE_ALLOC_TRACE
  174482             :         if (blockIndex > 0) {
  174483             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDExplicitGather) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDExplicitGather) = %" PRIuPTR " SgSIMDExplicitGather::pool_size = %d \n",
  174484             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDExplicitGather),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDExplicitGather),SgSIMDExplicitGather::pool_size);
  174485             :         }
  174486             : #endif
  174487             : 
  174488           0 :         SgSIMDExplicitGather * pointer = (SgSIMDExplicitGather*) ROSE_MALLOC ( SgSIMDExplicitGather::pool_size * sizeof(SgSIMDExplicitGather) );
  174489           0 :         assert( pointer != NULL );
  174490             : #if ROSE_ALLOC_MEMSET == 1
  174491             :         memset(pointer, 0x00, SgSIMDExplicitGather::pool_size * sizeof(SgSIMDExplicitGather));
  174492             : #elif ROSE_ALLOC_MEMSET == 2
  174493             :         memset(pointer, 0xCC, SgSIMDExplicitGather::pool_size * sizeof(SgSIMDExplicitGather));
  174494             : #endif
  174495           0 :         SgSIMDExplicitGather::pools.push_back( (unsigned char*)(pointer) );
  174496           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDExplicitGather::pool_size * sizeof(SgSIMDExplicitGather), V_SgSIMDExplicitGather ) );
  174497             : 
  174498           0 :         if ( SgSIMDExplicitGather::next_node != NULL ) {
  174499           0 :           if ( blockIndex > 0 ) {
  174500           0 :             SgSIMDExplicitGather * blkptr = (SgSIMDExplicitGather*)(SgSIMDExplicitGather::pools[blockIndex-1]);
  174501           0 :             blkptr[ SgSIMDExplicitGather::pool_size - 1 ].set_freepointer(pointer);
  174502             :           }
  174503             :         } else {
  174504           0 :           SgSIMDExplicitGather::next_node = pointer;
  174505             :         }
  174506             : 
  174507           0 :         for (unsigned i = 0; i < SgSIMDExplicitGather::pool_size-1; ++i)
  174508             :            {
  174509           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  174510             :            }
  174511           0 :         pointer[ SgSIMDExplicitGather::pool_size -1 ].set_freepointer(NULL);
  174512             : 
  174513           0 :         blockIndex++;
  174514             :       }
  174515           2 :   }
  174516             : 
  174517             : //############################################################################
  174518             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  174519             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  174520             :  * not compressed. However, that stuff is not yet implemented! 
  174521             :  */
  174522             : unsigned long
  174523           0 : SgSIMDExplicitGather::getNumberOfLastValidPointer()
  174524             :    {
  174525           0 :       SgSIMDExplicitGather* testPointer = (SgSIMDExplicitGather*)(SgSIMDExplicitGather::pools.back());
  174526           0 :       unsigned long localIndex = SgSIMDExplicitGather::pool_size - 1;
  174527           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  174528             :          {
  174529           0 :            localIndex--;
  174530             :          }
  174531           0 :       return (localIndex + SgSIMDExplicitGather::pool_size * (SgSIMDExplicitGather::pools.size()-1));
  174532             :    }
  174533             : 
  174534             : //############################################################################
  174535             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  174536             :  * memory pool and initializes the data member in class SgSIMDExplicitGatherStroageClass
  174537             :  * from its counterpart of SgSIMDExplicitGather. The return value is just for checking, 
  174538             :  * that the whole StorageClassArray is initialized!
  174539             :  */
  174540             : unsigned long
  174541           0 : SgSIMDExplicitGather::initializeStorageClassArray( SgSIMDExplicitGatherStorageClass *storageArray )
  174542             :    {
  174543           0 :      unsigned long storageCounter = 0;
  174544           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDExplicitGather::pools.begin();
  174545           0 :      SgSIMDExplicitGather* pointer = NULL;
  174546           0 :      while ( block != SgSIMDExplicitGather::pools.end() ) {
  174547           0 :           pointer = (SgSIMDExplicitGather*) (*block);
  174548           0 :           for ( unsigned i = 0; i < SgSIMDExplicitGather::pool_size; ++i ) {
  174549           0 :                if ( pointer->get_freepointer() != NULL ) {
  174550           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  174551           0 :                  storageArray++;
  174552           0 :                  storageCounter++;
  174553             :                }
  174554           0 :                pointer++;
  174555             :              }
  174556           0 :            block++;
  174557             :         }
  174558           0 :      return storageCounter;
  174559             :    }
  174560             : 
  174561             : /* #line 174562 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  174562             : 
  174563             : 
  174564             : 
  174565             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  174566             : 
  174567             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  174568             : 
  174569             : //############################################################################
  174570             : /* JH (02/02/2006) Constructor of the IR node SgSIMDScatter that takes its 
  174571             :  * corresponding StorageClass as parameter
  174572             :  */
  174573           0 : SgSIMDScatter :: SgSIMDScatter ( const SgSIMDScatterStorageClass& storageSource )   : SgBinaryOp (storageSource)
  174574             :    {
  174575             : 
  174576             : 
  174577             : /* #line 174578 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  174578             : 
  174579           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  174580             : 
  174581             : 
  174582             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  174583             : 
  174584             : 
  174585           0 :    }
  174586             : 
  174587             : //############################################################################
  174588             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  174589             :  * within the working AST. 
  174590             :  */
  174591           0 : SgSIMDScatter * SgSIMDScatter::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  174592           0 :      SgSIMDScatter* returnPointer = NULL;
  174593           0 :      if ( globalIndex != 0 )
  174594             :         {
  174595             : 
  174596             : #if FILE_IO_EXTRA_CHECK
  174597           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSIMDScatter ) ) <= globalIndex ) ;
  174598           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDScatter + 1 ) ) );
  174599             : #endif
  174600           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSIMDScatter )  
  174601           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSIMDScatter );
  174602           0 :           unsigned long positionInPool = localIndex % SgSIMDScatter::pool_size;
  174603           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDScatter::pool_size;
  174604             : 
  174605             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  174606             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  174607             : 
  174608           0 :           returnPointer = &( ( (SgSIMDScatter*)(SgSIMDScatter::pools[memoryBlock]) ) [positionInPool]) ;
  174609             : 
  174610           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  174611             :         }
  174612           0 :      return returnPointer ;
  174613             :    }
  174614             : 
  174615             : //############################################################################
  174616             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  174617             :   for the AST with the index astIndex
  174618             : */
  174619           0 : SgSIMDScatter * SgSIMDScatter::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  174620           0 :      SgSIMDScatter* returnPointer = NULL;
  174621           0 :      if ( globalIndex != 0 )
  174622             :         {
  174623             : 
  174624             : #if FILE_IO_EXTRA_CHECK
  174625           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSIMDScatter ) ) <= globalIndex ) ;
  174626           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDScatter + 1 ) ) );
  174627             : #endif
  174628           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSIMDScatter )
  174629           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSIMDScatter );
  174630           0 :           unsigned long positionInPool = localIndex % SgSIMDScatter::pool_size ;
  174631           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSIMDScatter::pool_size ;
  174632             : 
  174633             : #if FILE_IO_EXTRA_CHECK
  174634             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  174635             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  174636             : #endif
  174637             : 
  174638           0 :           returnPointer = &( ( (SgSIMDScatter*)(SgSIMDScatter::pools[memoryBlock]) ) [positionInPool]) ;
  174639             : 
  174640             : #if FILE_IO_EXTRA_CHECK
  174641           0 :           assert ( returnPointer != NULL ) ;
  174642             : #endif
  174643             :         }
  174644           0 :      return returnPointer ;
  174645             :    }
  174646             : 
  174647             : //############################################################################
  174648             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  174649             :  * pool size! We set for every valid object in the memory pool the freepointer
  174650             :  * to the global index and increase the global index afterwards. For all the 
  174651             :  * invalid objects (means address ranges within the memory pool that were not
  174652             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  174653             :  * distinguish valid from invalid objects! 
  174654             :  */
  174655             : unsigned long
  174656           5 : SgSIMDScatter::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  174657             :    {
  174658           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  174659           5 :      SgSIMDScatter* pointer = NULL;
  174660           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  174661           5 :      std::vector < unsigned char* > :: const_iterator block;
  174662           5 :      for ( block = SgSIMDScatter::pools.begin(); block != SgSIMDScatter::pools.end() ; ++block )
  174663             :         {
  174664           0 :           pointer = (SgSIMDScatter*)(*block);
  174665           0 :           for (unsigned i = 0; i < SgSIMDScatter::pool_size; ++i )
  174666             :              {
  174667             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  174668             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  174669             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  174670             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  174671             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  174672             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  174673             :             // properly; so this will have to be checked next.
  174674             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  174675             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  174676           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  174677             :                   {
  174678           0 :                     pointer[i].set_freepointer((SgSIMDScatter*)(globalIndex));
  174679           0 :                     globalIndex++;
  174680             :                   }
  174681             :                else
  174682             :                   {
  174683           0 :                     pointer[i].set_freepointer(NULL);
  174684             :                   }
  174685             :               }
  174686             :         }
  174687           5 :      return globalIndex;
  174688             :    }
  174689             : 
  174690             : //############################################################################
  174691             : // JH (01/14/2006)
  174692             : void
  174693           5 : SgSIMDScatter::resetValidFreepointers( )
  174694             :    {
  174695           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  174696           5 :      SgSIMDScatter* pointer = NULL;
  174697           5 :      std::vector < unsigned char* > :: const_iterator block;
  174698           5 :      SgSIMDScatter* pointerOfLinkedList = NULL;
  174699           5 :      for ( block = SgSIMDScatter::pools.begin(); block != SgSIMDScatter::pools.end() ; ++block )
  174700             :         {
  174701           0 :           pointer = (SgSIMDScatter*)(*block);
  174702           0 :           for (unsigned i = 0; i < SgSIMDScatter::pool_size; ++i )
  174703             :              {
  174704             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  174705             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  174706             :             // memory blocks!.
  174707           0 :                if ( pointer[i].get_freepointer() != NULL )
  174708             :                   {
  174709           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  174710             :                   }
  174711             :                else
  174712             :                   {
  174713           0 :                     if ( pointerOfLinkedList == NULL )
  174714             :                        {
  174715           0 :                          SgSIMDScatter::next_node = &(pointer[i]);
  174716             :                        }
  174717             :                     else
  174718             :                        {
  174719             :                       // printf ("In SgSIMDScatter::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  174720           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  174721             :                        }
  174722             :                     pointerOfLinkedList = &(pointer[i]);
  174723             :                   }
  174724             :               }
  174725             :         }
  174726             : 
  174727           5 :      if ( pointerOfLinkedList != NULL )
  174728             :         {
  174729             :        // printf ("In SgSIMDScatter::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  174730           0 :           pointerOfLinkedList->set_freepointer(NULL);
  174731             :        // DQ (6/6/2010): Temporary debugging...
  174732             :        //   ROSE_ASSERT(false);
  174733             :         }
  174734             : 
  174735           5 :      return ;
  174736             :    }
  174737             : 
  174738             : //############################################################################
  174739             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  174740             :  * within the memory pool and resets the freepointers, in order to achieve a 
  174741             :  * linked list, that has no jumps and starts at the beginning! This function 
  174742             :  * does not extend the memory pool, since we do not delete any memory blocks,
  174743             :  * but delete the valid objects.  
  174744             :  */
  174745             : void
  174746           0 : SgSIMDScatter::clearMemoryPool( )
  174747             :    {
  174748             :   // printf ("Inside of SgSIMDScatter::clearMemoryPool() \n");
  174749             : 
  174750           0 :      SgSIMDScatter* pointer = NULL, *tempPointer = NULL;
  174751           0 :      std::vector < unsigned char* > :: const_iterator block;
  174752           0 :      if ( SgSIMDScatter::pools.empty() == false )
  174753             :         {
  174754           0 :           block = SgSIMDScatter::pools.begin() ;
  174755           0 :           SgSIMDScatter::next_node = (SgSIMDScatter*) (*block);
  174756             : 
  174757           0 :           while ( block != SgSIMDScatter::pools.end() )
  174758             :              {
  174759           0 :                pointer = (SgSIMDScatter*) (*block);
  174760           0 :                if ( tempPointer != NULL )
  174761             :                   {
  174762           0 :                     tempPointer->set_freepointer(pointer);
  174763             :                   }
  174764           0 :                for (unsigned i = 0; i < SgSIMDScatter::pool_size - 1; ++i)
  174765             :                   {
  174766           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  174767             :                   }
  174768           0 :                 pointer[SgSIMDScatter::pool_size-1].set_freepointer(NULL);
  174769           0 :                 tempPointer = &(pointer[SgSIMDScatter::pool_size-1]);
  174770           0 :                 ++block;
  174771             :              }
  174772             :         }
  174773           0 :    }
  174774             : 
  174775           5 : void SgSIMDScatter::deleteMemoryPool() {
  174776           5 :   for (auto p: SgSIMDScatter::pools) {
  174777           0 :     ROSE_FREE(p);
  174778             :   }
  174779           5 :   SgSIMDScatter::next_node = nullptr;
  174780           5 :   SgSIMDScatter::pools.clear();
  174781           5 : }
  174782             : 
  174783             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  174784             : //                 reading multiple binary files to for a single AST.
  174785             : /////////// new version ////////////////////////////////
  174786             : //############################################################################
  174787             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  174788             : void
  174789           2 : SgSIMDScatter::extendMemoryPoolForFileIO( )
  174790             :   {
  174791           2 :     size_t blockIndex = SgSIMDScatter::pools.size();
  174792           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDScatter) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDScatter);
  174793             : 
  174794           2 :     while ( (blockIndex * SgSIMDScatter::pool_size) < newPoolSize)
  174795             :       {
  174796             : #if ROSE_ALLOC_TRACE
  174797             :         if (blockIndex > 0) {
  174798             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDScatter) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDScatter) = %" PRIuPTR " SgSIMDScatter::pool_size = %d \n",
  174799             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSIMDScatter),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSIMDScatter),SgSIMDScatter::pool_size);
  174800             :         }
  174801             : #endif
  174802             : 
  174803           0 :         SgSIMDScatter * pointer = (SgSIMDScatter*) ROSE_MALLOC ( SgSIMDScatter::pool_size * sizeof(SgSIMDScatter) );
  174804           0 :         assert( pointer != NULL );
  174805             : #if ROSE_ALLOC_MEMSET == 1
  174806             :         memset(pointer, 0x00, SgSIMDScatter::pool_size * sizeof(SgSIMDScatter));
  174807             : #elif ROSE_ALLOC_MEMSET == 2
  174808             :         memset(pointer, 0xCC, SgSIMDScatter::pool_size * sizeof(SgSIMDScatter));
  174809             : #endif
  174810           0 :         SgSIMDScatter::pools.push_back( (unsigned char*)(pointer) );
  174811           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSIMDScatter::pool_size * sizeof(SgSIMDScatter), V_SgSIMDScatter ) );
  174812             : 
  174813           0 :         if ( SgSIMDScatter::next_node != NULL ) {
  174814           0 :           if ( blockIndex > 0 ) {
  174815           0 :             SgSIMDScatter * blkptr = (SgSIMDScatter*)(SgSIMDScatter::pools[blockIndex-1]);
  174816           0 :             blkptr[ SgSIMDScatter::pool_size - 1 ].set_freepointer(pointer);
  174817             :           }
  174818             :         } else {
  174819           0 :           SgSIMDScatter::next_node = pointer;
  174820             :         }
  174821             : 
  174822           0 :         for (unsigned i = 0; i < SgSIMDScatter::pool_size-1; ++i)
  174823             :            {
  174824           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  174825             :            }
  174826           0 :         pointer[ SgSIMDScatter::pool_size -1 ].set_freepointer(NULL);
  174827             : 
  174828           0 :         blockIndex++;
  174829             :       }
  174830           2 :   }
  174831             : 
  174832             : //############################################################################
  174833             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  174834             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  174835             :  * not compressed. However, that stuff is not yet implemented! 
  174836             :  */
  174837             : unsigned long
  174838           0 : SgSIMDScatter::getNumberOfLastValidPointer()
  174839             :    {
  174840           0 :       SgSIMDScatter* testPointer = (SgSIMDScatter*)(SgSIMDScatter::pools.back());
  174841           0 :       unsigned long localIndex = SgSIMDScatter::pool_size - 1;
  174842           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  174843             :          {
  174844           0 :            localIndex--;
  174845             :          }
  174846           0 :       return (localIndex + SgSIMDScatter::pool_size * (SgSIMDScatter::pools.size()-1));
  174847             :    }
  174848             : 
  174849             : //############################################################################
  174850             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  174851             :  * memory pool and initializes the data member in class SgSIMDScatterStroageClass
  174852             :  * from its counterpart of SgSIMDScatter. The return value is just for checking, 
  174853             :  * that the whole StorageClassArray is initialized!
  174854             :  */
  174855             : unsigned long
  174856           0 : SgSIMDScatter::initializeStorageClassArray( SgSIMDScatterStorageClass *storageArray )
  174857             :    {
  174858           0 :      unsigned long storageCounter = 0;
  174859           0 :      std::vector < unsigned char* > :: const_iterator block = SgSIMDScatter::pools.begin();
  174860           0 :      SgSIMDScatter* pointer = NULL;
  174861           0 :      while ( block != SgSIMDScatter::pools.end() ) {
  174862           0 :           pointer = (SgSIMDScatter*) (*block);
  174863           0 :           for ( unsigned i = 0; i < SgSIMDScatter::pool_size; ++i ) {
  174864           0 :                if ( pointer->get_freepointer() != NULL ) {
  174865           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  174866           0 :                  storageArray++;
  174867           0 :                  storageCounter++;
  174868             :                }
  174869           0 :                pointer++;
  174870             :              }
  174871           0 :            block++;
  174872             :         }
  174873           0 :      return storageCounter;
  174874             :    }
  174875             : 
  174876             : /* #line 174877 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  174877             : 
  174878             : 
  174879             : 
  174880             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  174881             : 
  174882             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  174883             : 
  174884             : //############################################################################
  174885             : /* JH (02/02/2006) Constructor of the IR node SgExprListExp that takes its 
  174886             :  * corresponding StorageClass as parameter
  174887             :  */
  174888        3691 : SgExprListExp :: SgExprListExp ( const SgExprListExpStorageClass& storageSource )   : SgExpression (storageSource)
  174889             :    {
  174890             : 
  174891             : 
  174892             : /* #line 174893 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  174893             : 
  174894        3691 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  174895        3691 :      p_expressions = storageSource.storageOf_expressions.rebuildDataStoredInEasyStorageClass() ;
  174896        3691 :      SgExpressionPtrList::iterator i_expressions = p_expressions.begin() ; 
  174897        7725 :      for ( ; i_expressions != p_expressions.end(); ++i_expressions ) 
  174898             :         {
  174899        4034 :           (*i_expressions) = (SgExpressionPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_expressions) ) );
  174900             :         }
  174901             : 
  174902             : 
  174903             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  174904             : 
  174905             : 
  174906        3691 :    }
  174907             : 
  174908             : //############################################################################
  174909             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  174910             :  * within the working AST. 
  174911             :  */
  174912       18798 : SgExprListExp * SgExprListExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  174913       18798 :      SgExprListExp* returnPointer = NULL;
  174914       18798 :      if ( globalIndex != 0 )
  174915             :         {
  174916             : 
  174917             : #if FILE_IO_EXTRA_CHECK
  174918       18798 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgExprListExp ) ) <= globalIndex ) ;
  174919       18798 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExprListExp + 1 ) ) );
  174920             : #endif
  174921       18798 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgExprListExp )  
  174922       18798 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgExprListExp );
  174923       18798 :           unsigned long positionInPool = localIndex % SgExprListExp::pool_size;
  174924       18798 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExprListExp::pool_size;
  174925             : 
  174926             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  174927             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  174928             : 
  174929       18798 :           returnPointer = &( ( (SgExprListExp*)(SgExprListExp::pools[memoryBlock]) ) [positionInPool]) ;
  174930             : 
  174931       18798 :           ROSE_ASSERT( returnPointer != NULL ) ;
  174932             :         }
  174933       18798 :      return returnPointer ;
  174934             :    }
  174935             : 
  174936             : //############################################################################
  174937             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  174938             :   for the AST with the index astIndex
  174939             : */
  174940           0 : SgExprListExp * SgExprListExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  174941           0 :      SgExprListExp* returnPointer = NULL;
  174942           0 :      if ( globalIndex != 0 )
  174943             :         {
  174944             : 
  174945             : #if FILE_IO_EXTRA_CHECK
  174946           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgExprListExp ) ) <= globalIndex ) ;
  174947           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExprListExp + 1 ) ) );
  174948             : #endif
  174949           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgExprListExp )
  174950           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgExprListExp );
  174951           0 :           unsigned long positionInPool = localIndex % SgExprListExp::pool_size ;
  174952           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgExprListExp::pool_size ;
  174953             : 
  174954             : #if FILE_IO_EXTRA_CHECK
  174955             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  174956             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  174957             : #endif
  174958             : 
  174959           0 :           returnPointer = &( ( (SgExprListExp*)(SgExprListExp::pools[memoryBlock]) ) [positionInPool]) ;
  174960             : 
  174961             : #if FILE_IO_EXTRA_CHECK
  174962           0 :           assert ( returnPointer != NULL ) ;
  174963             : #endif
  174964             :         }
  174965           0 :      return returnPointer ;
  174966             :    }
  174967             : 
  174968             : //############################################################################
  174969             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  174970             :  * pool size! We set for every valid object in the memory pool the freepointer
  174971             :  * to the global index and increase the global index afterwards. For all the 
  174972             :  * invalid objects (means address ranges within the memory pool that were not
  174973             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  174974             :  * distinguish valid from invalid objects! 
  174975             :  */
  174976             : unsigned long
  174977           5 : SgExprListExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  174978             :    {
  174979           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  174980           5 :      SgExprListExp* pointer = NULL;
  174981           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  174982           5 :      std::vector < unsigned char* > :: const_iterator block;
  174983           9 :      for ( block = SgExprListExp::pools.begin(); block != SgExprListExp::pools.end() ; ++block )
  174984             :         {
  174985           4 :           pointer = (SgExprListExp*)(*block);
  174986        8004 :           for (unsigned i = 0; i < SgExprListExp::pool_size; ++i )
  174987             :              {
  174988             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  174989             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  174990             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  174991             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  174992             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  174993             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  174994             :             // properly; so this will have to be checked next.
  174995             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  174996             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  174997        8000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  174998             :                   {
  174999        3692 :                     pointer[i].set_freepointer((SgExprListExp*)(globalIndex));
  175000        3692 :                     globalIndex++;
  175001             :                   }
  175002             :                else
  175003             :                   {
  175004        4308 :                     pointer[i].set_freepointer(NULL);
  175005             :                   }
  175006             :               }
  175007             :         }
  175008           5 :      return globalIndex;
  175009             :    }
  175010             : 
  175011             : //############################################################################
  175012             : // JH (01/14/2006)
  175013             : void
  175014           5 : SgExprListExp::resetValidFreepointers( )
  175015             :    {
  175016           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  175017           5 :      SgExprListExp* pointer = NULL;
  175018           5 :      std::vector < unsigned char* > :: const_iterator block;
  175019           5 :      SgExprListExp* pointerOfLinkedList = NULL;
  175020           9 :      for ( block = SgExprListExp::pools.begin(); block != SgExprListExp::pools.end() ; ++block )
  175021             :         {
  175022           4 :           pointer = (SgExprListExp*)(*block);
  175023        8004 :           for (unsigned i = 0; i < SgExprListExp::pool_size; ++i )
  175024             :              {
  175025             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  175026             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  175027             :             // memory blocks!.
  175028        8000 :                if ( pointer[i].get_freepointer() != NULL )
  175029             :                   {
  175030        3692 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  175031             :                   }
  175032             :                else
  175033             :                   {
  175034        4308 :                     if ( pointerOfLinkedList == NULL )
  175035             :                        {
  175036           3 :                          SgExprListExp::next_node = &(pointer[i]);
  175037             :                        }
  175038             :                     else
  175039             :                        {
  175040             :                       // printf ("In SgExprListExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  175041        4305 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  175042             :                        }
  175043             :                     pointerOfLinkedList = &(pointer[i]);
  175044             :                   }
  175045             :               }
  175046             :         }
  175047             : 
  175048           5 :      if ( pointerOfLinkedList != NULL )
  175049             :         {
  175050             :        // printf ("In SgExprListExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  175051           3 :           pointerOfLinkedList->set_freepointer(NULL);
  175052             :        // DQ (6/6/2010): Temporary debugging...
  175053             :        //   ROSE_ASSERT(false);
  175054             :         }
  175055             : 
  175056           5 :      return ;
  175057             :    }
  175058             : 
  175059             : //############################################################################
  175060             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  175061             :  * within the memory pool and resets the freepointers, in order to achieve a 
  175062             :  * linked list, that has no jumps and starts at the beginning! This function 
  175063             :  * does not extend the memory pool, since we do not delete any memory blocks,
  175064             :  * but delete the valid objects.  
  175065             :  */
  175066             : void
  175067           0 : SgExprListExp::clearMemoryPool( )
  175068             :    {
  175069             :   // printf ("Inside of SgExprListExp::clearMemoryPool() \n");
  175070             : 
  175071           0 :      SgExprListExp* pointer = NULL, *tempPointer = NULL;
  175072           0 :      std::vector < unsigned char* > :: const_iterator block;
  175073           0 :      if ( SgExprListExp::pools.empty() == false )
  175074             :         {
  175075           0 :           block = SgExprListExp::pools.begin() ;
  175076           0 :           SgExprListExp::next_node = (SgExprListExp*) (*block);
  175077             : 
  175078           0 :           while ( block != SgExprListExp::pools.end() )
  175079             :              {
  175080           0 :                pointer = (SgExprListExp*) (*block);
  175081           0 :                if ( tempPointer != NULL )
  175082             :                   {
  175083           0 :                     tempPointer->set_freepointer(pointer);
  175084             :                   }
  175085           0 :                for (unsigned i = 0; i < SgExprListExp::pool_size - 1; ++i)
  175086             :                   {
  175087           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  175088             :                   }
  175089           0 :                 pointer[SgExprListExp::pool_size-1].set_freepointer(NULL);
  175090           0 :                 tempPointer = &(pointer[SgExprListExp::pool_size-1]);
  175091           0 :                 ++block;
  175092             :              }
  175093             :         }
  175094           0 :    }
  175095             : 
  175096           5 : void SgExprListExp::deleteMemoryPool() {
  175097          12 :   for (auto p: SgExprListExp::pools) {
  175098           7 :     ROSE_FREE(p);
  175099             :   }
  175100           5 :   SgExprListExp::next_node = nullptr;
  175101           5 :   SgExprListExp::pools.clear();
  175102           5 : }
  175103             : 
  175104             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  175105             : //                 reading multiple binary files to for a single AST.
  175106             : /////////// new version ////////////////////////////////
  175107             : //############################################################################
  175108             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  175109             : void
  175110           2 : SgExprListExp::extendMemoryPoolForFileIO( )
  175111             :   {
  175112           2 :     size_t blockIndex = SgExprListExp::pools.size();
  175113           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgExprListExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgExprListExp);
  175114             : 
  175115           5 :     while ( (blockIndex * SgExprListExp::pool_size) < newPoolSize)
  175116             :       {
  175117             : #if ROSE_ALLOC_TRACE
  175118             :         if (blockIndex > 0) {
  175119             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgExprListExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgExprListExp) = %" PRIuPTR " SgExprListExp::pool_size = %d \n",
  175120             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgExprListExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgExprListExp),SgExprListExp::pool_size);
  175121             :         }
  175122             : #endif
  175123             : 
  175124           3 :         SgExprListExp * pointer = (SgExprListExp*) ROSE_MALLOC ( SgExprListExp::pool_size * sizeof(SgExprListExp) );
  175125           3 :         assert( pointer != NULL );
  175126             : #if ROSE_ALLOC_MEMSET == 1
  175127             :         memset(pointer, 0x00, SgExprListExp::pool_size * sizeof(SgExprListExp));
  175128             : #elif ROSE_ALLOC_MEMSET == 2
  175129             :         memset(pointer, 0xCC, SgExprListExp::pool_size * sizeof(SgExprListExp));
  175130             : #endif
  175131           3 :         SgExprListExp::pools.push_back( (unsigned char*)(pointer) );
  175132           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgExprListExp::pool_size * sizeof(SgExprListExp), V_SgExprListExp ) );
  175133             : 
  175134           3 :         if ( SgExprListExp::next_node != NULL ) {
  175135           1 :           if ( blockIndex > 0 ) {
  175136           1 :             SgExprListExp * blkptr = (SgExprListExp*)(SgExprListExp::pools[blockIndex-1]);
  175137           1 :             blkptr[ SgExprListExp::pool_size - 1 ].set_freepointer(pointer);
  175138             :           }
  175139             :         } else {
  175140           2 :           SgExprListExp::next_node = pointer;
  175141             :         }
  175142             : 
  175143        6000 :         for (unsigned i = 0; i < SgExprListExp::pool_size-1; ++i)
  175144             :            {
  175145        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  175146             :            }
  175147           3 :         pointer[ SgExprListExp::pool_size -1 ].set_freepointer(NULL);
  175148             : 
  175149           3 :         blockIndex++;
  175150             :       }
  175151           2 :   }
  175152             : 
  175153             : //############################################################################
  175154             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  175155             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  175156             :  * not compressed. However, that stuff is not yet implemented! 
  175157             :  */
  175158             : unsigned long
  175159           0 : SgExprListExp::getNumberOfLastValidPointer()
  175160             :    {
  175161           0 :       SgExprListExp* testPointer = (SgExprListExp*)(SgExprListExp::pools.back());
  175162           0 :       unsigned long localIndex = SgExprListExp::pool_size - 1;
  175163           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  175164             :          {
  175165           0 :            localIndex--;
  175166             :          }
  175167           0 :       return (localIndex + SgExprListExp::pool_size * (SgExprListExp::pools.size()-1));
  175168             :    }
  175169             : 
  175170             : //############################################################################
  175171             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  175172             :  * memory pool and initializes the data member in class SgExprListExpStroageClass
  175173             :  * from its counterpart of SgExprListExp. The return value is just for checking, 
  175174             :  * that the whole StorageClassArray is initialized!
  175175             :  */
  175176             : unsigned long
  175177           3 : SgExprListExp::initializeStorageClassArray( SgExprListExpStorageClass *storageArray )
  175178             :    {
  175179           3 :      unsigned long storageCounter = 0;
  175180           3 :      std::vector < unsigned char* > :: const_iterator block = SgExprListExp::pools.begin();
  175181           3 :      SgExprListExp* pointer = NULL;
  175182           7 :      while ( block != SgExprListExp::pools.end() ) {
  175183           4 :           pointer = (SgExprListExp*) (*block);
  175184        8004 :           for ( unsigned i = 0; i < SgExprListExp::pool_size; ++i ) {
  175185        8000 :                if ( pointer->get_freepointer() != NULL ) {
  175186        3692 :                  storageArray->pickOutIRNodeData (pointer) ;
  175187        3692 :                  storageArray++;
  175188        3692 :                  storageCounter++;
  175189             :                }
  175190        8000 :                pointer++;
  175191             :              }
  175192           4 :            block++;
  175193             :         }
  175194           3 :      return storageCounter;
  175195             :    }
  175196             : 
  175197             : /* #line 175198 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  175198             : 
  175199             : 
  175200             : 
  175201             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  175202             : 
  175203             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  175204             : 
  175205             : //############################################################################
  175206             : /* JH (02/02/2006) Constructor of the IR node SgListExp that takes its 
  175207             :  * corresponding StorageClass as parameter
  175208             :  */
  175209           0 : SgListExp :: SgListExp ( const SgListExpStorageClass& storageSource )   : SgExprListExp (storageSource)
  175210             :    {
  175211             : 
  175212             : 
  175213             : /* #line 175214 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  175214             : 
  175215           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  175216             : 
  175217             : 
  175218             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  175219             : 
  175220             : 
  175221           0 :    }
  175222             : 
  175223             : //############################################################################
  175224             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  175225             :  * within the working AST. 
  175226             :  */
  175227           0 : SgListExp * SgListExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  175228           0 :      SgListExp* returnPointer = NULL;
  175229           0 :      if ( globalIndex != 0 )
  175230             :         {
  175231             : 
  175232             : #if FILE_IO_EXTRA_CHECK
  175233           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgListExp ) ) <= globalIndex ) ;
  175234           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgListExp + 1 ) ) );
  175235             : #endif
  175236           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgListExp )  
  175237           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgListExp );
  175238           0 :           unsigned long positionInPool = localIndex % SgListExp::pool_size;
  175239           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgListExp::pool_size;
  175240             : 
  175241             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  175242             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  175243             : 
  175244           0 :           returnPointer = &( ( (SgListExp*)(SgListExp::pools[memoryBlock]) ) [positionInPool]) ;
  175245             : 
  175246           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  175247             :         }
  175248           0 :      return returnPointer ;
  175249             :    }
  175250             : 
  175251             : //############################################################################
  175252             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  175253             :   for the AST with the index astIndex
  175254             : */
  175255           0 : SgListExp * SgListExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  175256           0 :      SgListExp* returnPointer = NULL;
  175257           0 :      if ( globalIndex != 0 )
  175258             :         {
  175259             : 
  175260             : #if FILE_IO_EXTRA_CHECK
  175261           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgListExp ) ) <= globalIndex ) ;
  175262           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgListExp + 1 ) ) );
  175263             : #endif
  175264           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgListExp )
  175265           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgListExp );
  175266           0 :           unsigned long positionInPool = localIndex % SgListExp::pool_size ;
  175267           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgListExp::pool_size ;
  175268             : 
  175269             : #if FILE_IO_EXTRA_CHECK
  175270             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  175271             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  175272             : #endif
  175273             : 
  175274           0 :           returnPointer = &( ( (SgListExp*)(SgListExp::pools[memoryBlock]) ) [positionInPool]) ;
  175275             : 
  175276             : #if FILE_IO_EXTRA_CHECK
  175277           0 :           assert ( returnPointer != NULL ) ;
  175278             : #endif
  175279             :         }
  175280           0 :      return returnPointer ;
  175281             :    }
  175282             : 
  175283             : //############################################################################
  175284             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  175285             :  * pool size! We set for every valid object in the memory pool the freepointer
  175286             :  * to the global index and increase the global index afterwards. For all the 
  175287             :  * invalid objects (means address ranges within the memory pool that were not
  175288             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  175289             :  * distinguish valid from invalid objects! 
  175290             :  */
  175291             : unsigned long
  175292           5 : SgListExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  175293             :    {
  175294           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  175295           5 :      SgListExp* pointer = NULL;
  175296           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  175297           5 :      std::vector < unsigned char* > :: const_iterator block;
  175298           5 :      for ( block = SgListExp::pools.begin(); block != SgListExp::pools.end() ; ++block )
  175299             :         {
  175300           0 :           pointer = (SgListExp*)(*block);
  175301           0 :           for (unsigned i = 0; i < SgListExp::pool_size; ++i )
  175302             :              {
  175303             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  175304             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  175305             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  175306             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  175307             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  175308             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  175309             :             // properly; so this will have to be checked next.
  175310             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  175311             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  175312           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  175313             :                   {
  175314           0 :                     pointer[i].set_freepointer((SgListExp*)(globalIndex));
  175315           0 :                     globalIndex++;
  175316             :                   }
  175317             :                else
  175318             :                   {
  175319           0 :                     pointer[i].set_freepointer(NULL);
  175320             :                   }
  175321             :               }
  175322             :         }
  175323           5 :      return globalIndex;
  175324             :    }
  175325             : 
  175326             : //############################################################################
  175327             : // JH (01/14/2006)
  175328             : void
  175329           5 : SgListExp::resetValidFreepointers( )
  175330             :    {
  175331           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  175332           5 :      SgListExp* pointer = NULL;
  175333           5 :      std::vector < unsigned char* > :: const_iterator block;
  175334           5 :      SgListExp* pointerOfLinkedList = NULL;
  175335           5 :      for ( block = SgListExp::pools.begin(); block != SgListExp::pools.end() ; ++block )
  175336             :         {
  175337           0 :           pointer = (SgListExp*)(*block);
  175338           0 :           for (unsigned i = 0; i < SgListExp::pool_size; ++i )
  175339             :              {
  175340             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  175341             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  175342             :             // memory blocks!.
  175343           0 :                if ( pointer[i].get_freepointer() != NULL )
  175344             :                   {
  175345           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  175346             :                   }
  175347             :                else
  175348             :                   {
  175349           0 :                     if ( pointerOfLinkedList == NULL )
  175350             :                        {
  175351           0 :                          SgListExp::next_node = &(pointer[i]);
  175352             :                        }
  175353             :                     else
  175354             :                        {
  175355             :                       // printf ("In SgListExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  175356           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  175357             :                        }
  175358             :                     pointerOfLinkedList = &(pointer[i]);
  175359             :                   }
  175360             :               }
  175361             :         }
  175362             : 
  175363           5 :      if ( pointerOfLinkedList != NULL )
  175364             :         {
  175365             :        // printf ("In SgListExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  175366           0 :           pointerOfLinkedList->set_freepointer(NULL);
  175367             :        // DQ (6/6/2010): Temporary debugging...
  175368             :        //   ROSE_ASSERT(false);
  175369             :         }
  175370             : 
  175371           5 :      return ;
  175372             :    }
  175373             : 
  175374             : //############################################################################
  175375             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  175376             :  * within the memory pool and resets the freepointers, in order to achieve a 
  175377             :  * linked list, that has no jumps and starts at the beginning! This function 
  175378             :  * does not extend the memory pool, since we do not delete any memory blocks,
  175379             :  * but delete the valid objects.  
  175380             :  */
  175381             : void
  175382           0 : SgListExp::clearMemoryPool( )
  175383             :    {
  175384             :   // printf ("Inside of SgListExp::clearMemoryPool() \n");
  175385             : 
  175386           0 :      SgListExp* pointer = NULL, *tempPointer = NULL;
  175387           0 :      std::vector < unsigned char* > :: const_iterator block;
  175388           0 :      if ( SgListExp::pools.empty() == false )
  175389             :         {
  175390           0 :           block = SgListExp::pools.begin() ;
  175391           0 :           SgListExp::next_node = (SgListExp*) (*block);
  175392             : 
  175393           0 :           while ( block != SgListExp::pools.end() )
  175394             :              {
  175395           0 :                pointer = (SgListExp*) (*block);
  175396           0 :                if ( tempPointer != NULL )
  175397             :                   {
  175398           0 :                     tempPointer->set_freepointer(pointer);
  175399             :                   }
  175400           0 :                for (unsigned i = 0; i < SgListExp::pool_size - 1; ++i)
  175401             :                   {
  175402           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  175403             :                   }
  175404           0 :                 pointer[SgListExp::pool_size-1].set_freepointer(NULL);
  175405           0 :                 tempPointer = &(pointer[SgListExp::pool_size-1]);
  175406           0 :                 ++block;
  175407             :              }
  175408             :         }
  175409           0 :    }
  175410             : 
  175411           5 : void SgListExp::deleteMemoryPool() {
  175412           5 :   for (auto p: SgListExp::pools) {
  175413           0 :     ROSE_FREE(p);
  175414             :   }
  175415           5 :   SgListExp::next_node = nullptr;
  175416           5 :   SgListExp::pools.clear();
  175417           5 : }
  175418             : 
  175419             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  175420             : //                 reading multiple binary files to for a single AST.
  175421             : /////////// new version ////////////////////////////////
  175422             : //############################################################################
  175423             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  175424             : void
  175425           2 : SgListExp::extendMemoryPoolForFileIO( )
  175426             :   {
  175427           2 :     size_t blockIndex = SgListExp::pools.size();
  175428           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgListExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgListExp);
  175429             : 
  175430           2 :     while ( (blockIndex * SgListExp::pool_size) < newPoolSize)
  175431             :       {
  175432             : #if ROSE_ALLOC_TRACE
  175433             :         if (blockIndex > 0) {
  175434             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgListExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgListExp) = %" PRIuPTR " SgListExp::pool_size = %d \n",
  175435             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgListExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgListExp),SgListExp::pool_size);
  175436             :         }
  175437             : #endif
  175438             : 
  175439           0 :         SgListExp * pointer = (SgListExp*) ROSE_MALLOC ( SgListExp::pool_size * sizeof(SgListExp) );
  175440           0 :         assert( pointer != NULL );
  175441             : #if ROSE_ALLOC_MEMSET == 1
  175442             :         memset(pointer, 0x00, SgListExp::pool_size * sizeof(SgListExp));
  175443             : #elif ROSE_ALLOC_MEMSET == 2
  175444             :         memset(pointer, 0xCC, SgListExp::pool_size * sizeof(SgListExp));
  175445             : #endif
  175446           0 :         SgListExp::pools.push_back( (unsigned char*)(pointer) );
  175447           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgListExp::pool_size * sizeof(SgListExp), V_SgListExp ) );
  175448             : 
  175449           0 :         if ( SgListExp::next_node != NULL ) {
  175450           0 :           if ( blockIndex > 0 ) {
  175451           0 :             SgListExp * blkptr = (SgListExp*)(SgListExp::pools[blockIndex-1]);
  175452           0 :             blkptr[ SgListExp::pool_size - 1 ].set_freepointer(pointer);
  175453             :           }
  175454             :         } else {
  175455           0 :           SgListExp::next_node = pointer;
  175456             :         }
  175457             : 
  175458           0 :         for (unsigned i = 0; i < SgListExp::pool_size-1; ++i)
  175459             :            {
  175460           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  175461             :            }
  175462           0 :         pointer[ SgListExp::pool_size -1 ].set_freepointer(NULL);
  175463             : 
  175464           0 :         blockIndex++;
  175465             :       }
  175466           2 :   }
  175467             : 
  175468             : //############################################################################
  175469             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  175470             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  175471             :  * not compressed. However, that stuff is not yet implemented! 
  175472             :  */
  175473             : unsigned long
  175474           0 : SgListExp::getNumberOfLastValidPointer()
  175475             :    {
  175476           0 :       SgListExp* testPointer = (SgListExp*)(SgListExp::pools.back());
  175477           0 :       unsigned long localIndex = SgListExp::pool_size - 1;
  175478           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  175479             :          {
  175480           0 :            localIndex--;
  175481             :          }
  175482           0 :       return (localIndex + SgListExp::pool_size * (SgListExp::pools.size()-1));
  175483             :    }
  175484             : 
  175485             : //############################################################################
  175486             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  175487             :  * memory pool and initializes the data member in class SgListExpStroageClass
  175488             :  * from its counterpart of SgListExp. The return value is just for checking, 
  175489             :  * that the whole StorageClassArray is initialized!
  175490             :  */
  175491             : unsigned long
  175492           0 : SgListExp::initializeStorageClassArray( SgListExpStorageClass *storageArray )
  175493             :    {
  175494           0 :      unsigned long storageCounter = 0;
  175495           0 :      std::vector < unsigned char* > :: const_iterator block = SgListExp::pools.begin();
  175496           0 :      SgListExp* pointer = NULL;
  175497           0 :      while ( block != SgListExp::pools.end() ) {
  175498           0 :           pointer = (SgListExp*) (*block);
  175499           0 :           for ( unsigned i = 0; i < SgListExp::pool_size; ++i ) {
  175500           0 :                if ( pointer->get_freepointer() != NULL ) {
  175501           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  175502           0 :                  storageArray++;
  175503           0 :                  storageCounter++;
  175504             :                }
  175505           0 :                pointer++;
  175506             :              }
  175507           0 :            block++;
  175508             :         }
  175509           0 :      return storageCounter;
  175510             :    }
  175511             : 
  175512             : /* #line 175513 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  175513             : 
  175514             : 
  175515             : 
  175516             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  175517             : 
  175518             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  175519             : 
  175520             : //############################################################################
  175521             : /* JH (02/02/2006) Constructor of the IR node SgTupleExp that takes its 
  175522             :  * corresponding StorageClass as parameter
  175523             :  */
  175524           0 : SgTupleExp :: SgTupleExp ( const SgTupleExpStorageClass& storageSource )   : SgExprListExp (storageSource)
  175525             :    {
  175526             : 
  175527             : 
  175528             : /* #line 175529 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  175529             : 
  175530           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  175531             : 
  175532             : 
  175533             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  175534             : 
  175535             : 
  175536           0 :    }
  175537             : 
  175538             : //############################################################################
  175539             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  175540             :  * within the working AST. 
  175541             :  */
  175542           0 : SgTupleExp * SgTupleExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  175543           0 :      SgTupleExp* returnPointer = NULL;
  175544           0 :      if ( globalIndex != 0 )
  175545             :         {
  175546             : 
  175547             : #if FILE_IO_EXTRA_CHECK
  175548           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTupleExp ) ) <= globalIndex ) ;
  175549           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTupleExp + 1 ) ) );
  175550             : #endif
  175551           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTupleExp )  
  175552           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTupleExp );
  175553           0 :           unsigned long positionInPool = localIndex % SgTupleExp::pool_size;
  175554           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTupleExp::pool_size;
  175555             : 
  175556             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  175557             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  175558             : 
  175559           0 :           returnPointer = &( ( (SgTupleExp*)(SgTupleExp::pools[memoryBlock]) ) [positionInPool]) ;
  175560             : 
  175561           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  175562             :         }
  175563           0 :      return returnPointer ;
  175564             :    }
  175565             : 
  175566             : //############################################################################
  175567             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  175568             :   for the AST with the index astIndex
  175569             : */
  175570           0 : SgTupleExp * SgTupleExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  175571           0 :      SgTupleExp* returnPointer = NULL;
  175572           0 :      if ( globalIndex != 0 )
  175573             :         {
  175574             : 
  175575             : #if FILE_IO_EXTRA_CHECK
  175576           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTupleExp ) ) <= globalIndex ) ;
  175577           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTupleExp + 1 ) ) );
  175578             : #endif
  175579           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTupleExp )
  175580           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTupleExp );
  175581           0 :           unsigned long positionInPool = localIndex % SgTupleExp::pool_size ;
  175582           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTupleExp::pool_size ;
  175583             : 
  175584             : #if FILE_IO_EXTRA_CHECK
  175585             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  175586             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  175587             : #endif
  175588             : 
  175589           0 :           returnPointer = &( ( (SgTupleExp*)(SgTupleExp::pools[memoryBlock]) ) [positionInPool]) ;
  175590             : 
  175591             : #if FILE_IO_EXTRA_CHECK
  175592           0 :           assert ( returnPointer != NULL ) ;
  175593             : #endif
  175594             :         }
  175595           0 :      return returnPointer ;
  175596             :    }
  175597             : 
  175598             : //############################################################################
  175599             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  175600             :  * pool size! We set for every valid object in the memory pool the freepointer
  175601             :  * to the global index and increase the global index afterwards. For all the 
  175602             :  * invalid objects (means address ranges within the memory pool that were not
  175603             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  175604             :  * distinguish valid from invalid objects! 
  175605             :  */
  175606             : unsigned long
  175607           5 : SgTupleExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  175608             :    {
  175609           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  175610           5 :      SgTupleExp* pointer = NULL;
  175611           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  175612           5 :      std::vector < unsigned char* > :: const_iterator block;
  175613           5 :      for ( block = SgTupleExp::pools.begin(); block != SgTupleExp::pools.end() ; ++block )
  175614             :         {
  175615           0 :           pointer = (SgTupleExp*)(*block);
  175616           0 :           for (unsigned i = 0; i < SgTupleExp::pool_size; ++i )
  175617             :              {
  175618             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  175619             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  175620             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  175621             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  175622             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  175623             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  175624             :             // properly; so this will have to be checked next.
  175625             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  175626             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  175627           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  175628             :                   {
  175629           0 :                     pointer[i].set_freepointer((SgTupleExp*)(globalIndex));
  175630           0 :                     globalIndex++;
  175631             :                   }
  175632             :                else
  175633             :                   {
  175634           0 :                     pointer[i].set_freepointer(NULL);
  175635             :                   }
  175636             :               }
  175637             :         }
  175638           5 :      return globalIndex;
  175639             :    }
  175640             : 
  175641             : //############################################################################
  175642             : // JH (01/14/2006)
  175643             : void
  175644           5 : SgTupleExp::resetValidFreepointers( )
  175645             :    {
  175646           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  175647           5 :      SgTupleExp* pointer = NULL;
  175648           5 :      std::vector < unsigned char* > :: const_iterator block;
  175649           5 :      SgTupleExp* pointerOfLinkedList = NULL;
  175650           5 :      for ( block = SgTupleExp::pools.begin(); block != SgTupleExp::pools.end() ; ++block )
  175651             :         {
  175652           0 :           pointer = (SgTupleExp*)(*block);
  175653           0 :           for (unsigned i = 0; i < SgTupleExp::pool_size; ++i )
  175654             :              {
  175655             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  175656             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  175657             :             // memory blocks!.
  175658           0 :                if ( pointer[i].get_freepointer() != NULL )
  175659             :                   {
  175660           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  175661             :                   }
  175662             :                else
  175663             :                   {
  175664           0 :                     if ( pointerOfLinkedList == NULL )
  175665             :                        {
  175666           0 :                          SgTupleExp::next_node = &(pointer[i]);
  175667             :                        }
  175668             :                     else
  175669             :                        {
  175670             :                       // printf ("In SgTupleExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  175671           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  175672             :                        }
  175673             :                     pointerOfLinkedList = &(pointer[i]);
  175674             :                   }
  175675             :               }
  175676             :         }
  175677             : 
  175678           5 :      if ( pointerOfLinkedList != NULL )
  175679             :         {
  175680             :        // printf ("In SgTupleExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  175681           0 :           pointerOfLinkedList->set_freepointer(NULL);
  175682             :        // DQ (6/6/2010): Temporary debugging...
  175683             :        //   ROSE_ASSERT(false);
  175684             :         }
  175685             : 
  175686           5 :      return ;
  175687             :    }
  175688             : 
  175689             : //############################################################################
  175690             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  175691             :  * within the memory pool and resets the freepointers, in order to achieve a 
  175692             :  * linked list, that has no jumps and starts at the beginning! This function 
  175693             :  * does not extend the memory pool, since we do not delete any memory blocks,
  175694             :  * but delete the valid objects.  
  175695             :  */
  175696             : void
  175697           0 : SgTupleExp::clearMemoryPool( )
  175698             :    {
  175699             :   // printf ("Inside of SgTupleExp::clearMemoryPool() \n");
  175700             : 
  175701           0 :      SgTupleExp* pointer = NULL, *tempPointer = NULL;
  175702           0 :      std::vector < unsigned char* > :: const_iterator block;
  175703           0 :      if ( SgTupleExp::pools.empty() == false )
  175704             :         {
  175705           0 :           block = SgTupleExp::pools.begin() ;
  175706           0 :           SgTupleExp::next_node = (SgTupleExp*) (*block);
  175707             : 
  175708           0 :           while ( block != SgTupleExp::pools.end() )
  175709             :              {
  175710           0 :                pointer = (SgTupleExp*) (*block);
  175711           0 :                if ( tempPointer != NULL )
  175712             :                   {
  175713           0 :                     tempPointer->set_freepointer(pointer);
  175714             :                   }
  175715           0 :                for (unsigned i = 0; i < SgTupleExp::pool_size - 1; ++i)
  175716             :                   {
  175717           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  175718             :                   }
  175719           0 :                 pointer[SgTupleExp::pool_size-1].set_freepointer(NULL);
  175720           0 :                 tempPointer = &(pointer[SgTupleExp::pool_size-1]);
  175721           0 :                 ++block;
  175722             :              }
  175723             :         }
  175724           0 :    }
  175725             : 
  175726           5 : void SgTupleExp::deleteMemoryPool() {
  175727           5 :   for (auto p: SgTupleExp::pools) {
  175728           0 :     ROSE_FREE(p);
  175729             :   }
  175730           5 :   SgTupleExp::next_node = nullptr;
  175731           5 :   SgTupleExp::pools.clear();
  175732           5 : }
  175733             : 
  175734             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  175735             : //                 reading multiple binary files to for a single AST.
  175736             : /////////// new version ////////////////////////////////
  175737             : //############################################################################
  175738             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  175739             : void
  175740           2 : SgTupleExp::extendMemoryPoolForFileIO( )
  175741             :   {
  175742           2 :     size_t blockIndex = SgTupleExp::pools.size();
  175743           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTupleExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTupleExp);
  175744             : 
  175745           2 :     while ( (blockIndex * SgTupleExp::pool_size) < newPoolSize)
  175746             :       {
  175747             : #if ROSE_ALLOC_TRACE
  175748             :         if (blockIndex > 0) {
  175749             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTupleExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTupleExp) = %" PRIuPTR " SgTupleExp::pool_size = %d \n",
  175750             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTupleExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTupleExp),SgTupleExp::pool_size);
  175751             :         }
  175752             : #endif
  175753             : 
  175754           0 :         SgTupleExp * pointer = (SgTupleExp*) ROSE_MALLOC ( SgTupleExp::pool_size * sizeof(SgTupleExp) );
  175755           0 :         assert( pointer != NULL );
  175756             : #if ROSE_ALLOC_MEMSET == 1
  175757             :         memset(pointer, 0x00, SgTupleExp::pool_size * sizeof(SgTupleExp));
  175758             : #elif ROSE_ALLOC_MEMSET == 2
  175759             :         memset(pointer, 0xCC, SgTupleExp::pool_size * sizeof(SgTupleExp));
  175760             : #endif
  175761           0 :         SgTupleExp::pools.push_back( (unsigned char*)(pointer) );
  175762           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTupleExp::pool_size * sizeof(SgTupleExp), V_SgTupleExp ) );
  175763             : 
  175764           0 :         if ( SgTupleExp::next_node != NULL ) {
  175765           0 :           if ( blockIndex > 0 ) {
  175766           0 :             SgTupleExp * blkptr = (SgTupleExp*)(SgTupleExp::pools[blockIndex-1]);
  175767           0 :             blkptr[ SgTupleExp::pool_size - 1 ].set_freepointer(pointer);
  175768             :           }
  175769             :         } else {
  175770           0 :           SgTupleExp::next_node = pointer;
  175771             :         }
  175772             : 
  175773           0 :         for (unsigned i = 0; i < SgTupleExp::pool_size-1; ++i)
  175774             :            {
  175775           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  175776             :            }
  175777           0 :         pointer[ SgTupleExp::pool_size -1 ].set_freepointer(NULL);
  175778             : 
  175779           0 :         blockIndex++;
  175780             :       }
  175781           2 :   }
  175782             : 
  175783             : //############################################################################
  175784             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  175785             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  175786             :  * not compressed. However, that stuff is not yet implemented! 
  175787             :  */
  175788             : unsigned long
  175789           0 : SgTupleExp::getNumberOfLastValidPointer()
  175790             :    {
  175791           0 :       SgTupleExp* testPointer = (SgTupleExp*)(SgTupleExp::pools.back());
  175792           0 :       unsigned long localIndex = SgTupleExp::pool_size - 1;
  175793           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  175794             :          {
  175795           0 :            localIndex--;
  175796             :          }
  175797           0 :       return (localIndex + SgTupleExp::pool_size * (SgTupleExp::pools.size()-1));
  175798             :    }
  175799             : 
  175800             : //############################################################################
  175801             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  175802             :  * memory pool and initializes the data member in class SgTupleExpStroageClass
  175803             :  * from its counterpart of SgTupleExp. The return value is just for checking, 
  175804             :  * that the whole StorageClassArray is initialized!
  175805             :  */
  175806             : unsigned long
  175807           0 : SgTupleExp::initializeStorageClassArray( SgTupleExpStorageClass *storageArray )
  175808             :    {
  175809           0 :      unsigned long storageCounter = 0;
  175810           0 :      std::vector < unsigned char* > :: const_iterator block = SgTupleExp::pools.begin();
  175811           0 :      SgTupleExp* pointer = NULL;
  175812           0 :      while ( block != SgTupleExp::pools.end() ) {
  175813           0 :           pointer = (SgTupleExp*) (*block);
  175814           0 :           for ( unsigned i = 0; i < SgTupleExp::pool_size; ++i ) {
  175815           0 :                if ( pointer->get_freepointer() != NULL ) {
  175816           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  175817           0 :                  storageArray++;
  175818           0 :                  storageCounter++;
  175819             :                }
  175820           0 :                pointer++;
  175821             :              }
  175822           0 :            block++;
  175823             :         }
  175824           0 :      return storageCounter;
  175825             :    }
  175826             : 
  175827             : /* #line 175828 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  175828             : 
  175829             : 
  175830             : 
  175831             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  175832             : 
  175833             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  175834             : 
  175835             : //############################################################################
  175836             : /* JH (02/02/2006) Constructor of the IR node SgMatrixExp that takes its 
  175837             :  * corresponding StorageClass as parameter
  175838             :  */
  175839           0 : SgMatrixExp :: SgMatrixExp ( const SgMatrixExpStorageClass& storageSource )   : SgExprListExp (storageSource)
  175840             :    {
  175841             : 
  175842             : 
  175843             : /* #line 175844 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  175844             : 
  175845           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  175846             : 
  175847             : 
  175848             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  175849             : 
  175850             : 
  175851           0 :    }
  175852             : 
  175853             : //############################################################################
  175854             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  175855             :  * within the working AST. 
  175856             :  */
  175857           0 : SgMatrixExp * SgMatrixExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  175858           0 :      SgMatrixExp* returnPointer = NULL;
  175859           0 :      if ( globalIndex != 0 )
  175860             :         {
  175861             : 
  175862             : #if FILE_IO_EXTRA_CHECK
  175863           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMatrixExp ) ) <= globalIndex ) ;
  175864           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMatrixExp + 1 ) ) );
  175865             : #endif
  175866           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMatrixExp )  
  175867           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMatrixExp );
  175868           0 :           unsigned long positionInPool = localIndex % SgMatrixExp::pool_size;
  175869           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMatrixExp::pool_size;
  175870             : 
  175871             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  175872             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  175873             : 
  175874           0 :           returnPointer = &( ( (SgMatrixExp*)(SgMatrixExp::pools[memoryBlock]) ) [positionInPool]) ;
  175875             : 
  175876           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  175877             :         }
  175878           0 :      return returnPointer ;
  175879             :    }
  175880             : 
  175881             : //############################################################################
  175882             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  175883             :   for the AST with the index astIndex
  175884             : */
  175885           0 : SgMatrixExp * SgMatrixExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  175886           0 :      SgMatrixExp* returnPointer = NULL;
  175887           0 :      if ( globalIndex != 0 )
  175888             :         {
  175889             : 
  175890             : #if FILE_IO_EXTRA_CHECK
  175891           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMatrixExp ) ) <= globalIndex ) ;
  175892           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMatrixExp + 1 ) ) );
  175893             : #endif
  175894           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMatrixExp )
  175895           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMatrixExp );
  175896           0 :           unsigned long positionInPool = localIndex % SgMatrixExp::pool_size ;
  175897           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMatrixExp::pool_size ;
  175898             : 
  175899             : #if FILE_IO_EXTRA_CHECK
  175900             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  175901             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  175902             : #endif
  175903             : 
  175904           0 :           returnPointer = &( ( (SgMatrixExp*)(SgMatrixExp::pools[memoryBlock]) ) [positionInPool]) ;
  175905             : 
  175906             : #if FILE_IO_EXTRA_CHECK
  175907           0 :           assert ( returnPointer != NULL ) ;
  175908             : #endif
  175909             :         }
  175910           0 :      return returnPointer ;
  175911             :    }
  175912             : 
  175913             : //############################################################################
  175914             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  175915             :  * pool size! We set for every valid object in the memory pool the freepointer
  175916             :  * to the global index and increase the global index afterwards. For all the 
  175917             :  * invalid objects (means address ranges within the memory pool that were not
  175918             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  175919             :  * distinguish valid from invalid objects! 
  175920             :  */
  175921             : unsigned long
  175922           5 : SgMatrixExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  175923             :    {
  175924           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  175925           5 :      SgMatrixExp* pointer = NULL;
  175926           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  175927           5 :      std::vector < unsigned char* > :: const_iterator block;
  175928           5 :      for ( block = SgMatrixExp::pools.begin(); block != SgMatrixExp::pools.end() ; ++block )
  175929             :         {
  175930           0 :           pointer = (SgMatrixExp*)(*block);
  175931           0 :           for (unsigned i = 0; i < SgMatrixExp::pool_size; ++i )
  175932             :              {
  175933             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  175934             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  175935             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  175936             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  175937             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  175938             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  175939             :             // properly; so this will have to be checked next.
  175940             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  175941             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  175942           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  175943             :                   {
  175944           0 :                     pointer[i].set_freepointer((SgMatrixExp*)(globalIndex));
  175945           0 :                     globalIndex++;
  175946             :                   }
  175947             :                else
  175948             :                   {
  175949           0 :                     pointer[i].set_freepointer(NULL);
  175950             :                   }
  175951             :               }
  175952             :         }
  175953           5 :      return globalIndex;
  175954             :    }
  175955             : 
  175956             : //############################################################################
  175957             : // JH (01/14/2006)
  175958             : void
  175959           5 : SgMatrixExp::resetValidFreepointers( )
  175960             :    {
  175961           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  175962           5 :      SgMatrixExp* pointer = NULL;
  175963           5 :      std::vector < unsigned char* > :: const_iterator block;
  175964           5 :      SgMatrixExp* pointerOfLinkedList = NULL;
  175965           5 :      for ( block = SgMatrixExp::pools.begin(); block != SgMatrixExp::pools.end() ; ++block )
  175966             :         {
  175967           0 :           pointer = (SgMatrixExp*)(*block);
  175968           0 :           for (unsigned i = 0; i < SgMatrixExp::pool_size; ++i )
  175969             :              {
  175970             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  175971             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  175972             :             // memory blocks!.
  175973           0 :                if ( pointer[i].get_freepointer() != NULL )
  175974             :                   {
  175975           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  175976             :                   }
  175977             :                else
  175978             :                   {
  175979           0 :                     if ( pointerOfLinkedList == NULL )
  175980             :                        {
  175981           0 :                          SgMatrixExp::next_node = &(pointer[i]);
  175982             :                        }
  175983             :                     else
  175984             :                        {
  175985             :                       // printf ("In SgMatrixExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  175986           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  175987             :                        }
  175988             :                     pointerOfLinkedList = &(pointer[i]);
  175989             :                   }
  175990             :               }
  175991             :         }
  175992             : 
  175993           5 :      if ( pointerOfLinkedList != NULL )
  175994             :         {
  175995             :        // printf ("In SgMatrixExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  175996           0 :           pointerOfLinkedList->set_freepointer(NULL);
  175997             :        // DQ (6/6/2010): Temporary debugging...
  175998             :        //   ROSE_ASSERT(false);
  175999             :         }
  176000             : 
  176001           5 :      return ;
  176002             :    }
  176003             : 
  176004             : //############################################################################
  176005             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  176006             :  * within the memory pool and resets the freepointers, in order to achieve a 
  176007             :  * linked list, that has no jumps and starts at the beginning! This function 
  176008             :  * does not extend the memory pool, since we do not delete any memory blocks,
  176009             :  * but delete the valid objects.  
  176010             :  */
  176011             : void
  176012           0 : SgMatrixExp::clearMemoryPool( )
  176013             :    {
  176014             :   // printf ("Inside of SgMatrixExp::clearMemoryPool() \n");
  176015             : 
  176016           0 :      SgMatrixExp* pointer = NULL, *tempPointer = NULL;
  176017           0 :      std::vector < unsigned char* > :: const_iterator block;
  176018           0 :      if ( SgMatrixExp::pools.empty() == false )
  176019             :         {
  176020           0 :           block = SgMatrixExp::pools.begin() ;
  176021           0 :           SgMatrixExp::next_node = (SgMatrixExp*) (*block);
  176022             : 
  176023           0 :           while ( block != SgMatrixExp::pools.end() )
  176024             :              {
  176025           0 :                pointer = (SgMatrixExp*) (*block);
  176026           0 :                if ( tempPointer != NULL )
  176027             :                   {
  176028           0 :                     tempPointer->set_freepointer(pointer);
  176029             :                   }
  176030           0 :                for (unsigned i = 0; i < SgMatrixExp::pool_size - 1; ++i)
  176031             :                   {
  176032           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  176033             :                   }
  176034           0 :                 pointer[SgMatrixExp::pool_size-1].set_freepointer(NULL);
  176035           0 :                 tempPointer = &(pointer[SgMatrixExp::pool_size-1]);
  176036           0 :                 ++block;
  176037             :              }
  176038             :         }
  176039           0 :    }
  176040             : 
  176041           5 : void SgMatrixExp::deleteMemoryPool() {
  176042           5 :   for (auto p: SgMatrixExp::pools) {
  176043           0 :     ROSE_FREE(p);
  176044             :   }
  176045           5 :   SgMatrixExp::next_node = nullptr;
  176046           5 :   SgMatrixExp::pools.clear();
  176047           5 : }
  176048             : 
  176049             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  176050             : //                 reading multiple binary files to for a single AST.
  176051             : /////////// new version ////////////////////////////////
  176052             : //############################################################################
  176053             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  176054             : void
  176055           2 : SgMatrixExp::extendMemoryPoolForFileIO( )
  176056             :   {
  176057           2 :     size_t blockIndex = SgMatrixExp::pools.size();
  176058           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMatrixExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMatrixExp);
  176059             : 
  176060           2 :     while ( (blockIndex * SgMatrixExp::pool_size) < newPoolSize)
  176061             :       {
  176062             : #if ROSE_ALLOC_TRACE
  176063             :         if (blockIndex > 0) {
  176064             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMatrixExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMatrixExp) = %" PRIuPTR " SgMatrixExp::pool_size = %d \n",
  176065             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMatrixExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMatrixExp),SgMatrixExp::pool_size);
  176066             :         }
  176067             : #endif
  176068             : 
  176069           0 :         SgMatrixExp * pointer = (SgMatrixExp*) ROSE_MALLOC ( SgMatrixExp::pool_size * sizeof(SgMatrixExp) );
  176070           0 :         assert( pointer != NULL );
  176071             : #if ROSE_ALLOC_MEMSET == 1
  176072             :         memset(pointer, 0x00, SgMatrixExp::pool_size * sizeof(SgMatrixExp));
  176073             : #elif ROSE_ALLOC_MEMSET == 2
  176074             :         memset(pointer, 0xCC, SgMatrixExp::pool_size * sizeof(SgMatrixExp));
  176075             : #endif
  176076           0 :         SgMatrixExp::pools.push_back( (unsigned char*)(pointer) );
  176077           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMatrixExp::pool_size * sizeof(SgMatrixExp), V_SgMatrixExp ) );
  176078             : 
  176079           0 :         if ( SgMatrixExp::next_node != NULL ) {
  176080           0 :           if ( blockIndex > 0 ) {
  176081           0 :             SgMatrixExp * blkptr = (SgMatrixExp*)(SgMatrixExp::pools[blockIndex-1]);
  176082           0 :             blkptr[ SgMatrixExp::pool_size - 1 ].set_freepointer(pointer);
  176083             :           }
  176084             :         } else {
  176085           0 :           SgMatrixExp::next_node = pointer;
  176086             :         }
  176087             : 
  176088           0 :         for (unsigned i = 0; i < SgMatrixExp::pool_size-1; ++i)
  176089             :            {
  176090           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  176091             :            }
  176092           0 :         pointer[ SgMatrixExp::pool_size -1 ].set_freepointer(NULL);
  176093             : 
  176094           0 :         blockIndex++;
  176095             :       }
  176096           2 :   }
  176097             : 
  176098             : //############################################################################
  176099             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  176100             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  176101             :  * not compressed. However, that stuff is not yet implemented! 
  176102             :  */
  176103             : unsigned long
  176104           0 : SgMatrixExp::getNumberOfLastValidPointer()
  176105             :    {
  176106           0 :       SgMatrixExp* testPointer = (SgMatrixExp*)(SgMatrixExp::pools.back());
  176107           0 :       unsigned long localIndex = SgMatrixExp::pool_size - 1;
  176108           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  176109             :          {
  176110           0 :            localIndex--;
  176111             :          }
  176112           0 :       return (localIndex + SgMatrixExp::pool_size * (SgMatrixExp::pools.size()-1));
  176113             :    }
  176114             : 
  176115             : //############################################################################
  176116             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  176117             :  * memory pool and initializes the data member in class SgMatrixExpStroageClass
  176118             :  * from its counterpart of SgMatrixExp. The return value is just for checking, 
  176119             :  * that the whole StorageClassArray is initialized!
  176120             :  */
  176121             : unsigned long
  176122           0 : SgMatrixExp::initializeStorageClassArray( SgMatrixExpStorageClass *storageArray )
  176123             :    {
  176124           0 :      unsigned long storageCounter = 0;
  176125           0 :      std::vector < unsigned char* > :: const_iterator block = SgMatrixExp::pools.begin();
  176126           0 :      SgMatrixExp* pointer = NULL;
  176127           0 :      while ( block != SgMatrixExp::pools.end() ) {
  176128           0 :           pointer = (SgMatrixExp*) (*block);
  176129           0 :           for ( unsigned i = 0; i < SgMatrixExp::pool_size; ++i ) {
  176130           0 :                if ( pointer->get_freepointer() != NULL ) {
  176131           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  176132           0 :                  storageArray++;
  176133           0 :                  storageCounter++;
  176134             :                }
  176135           0 :                pointer++;
  176136             :              }
  176137           0 :            block++;
  176138             :         }
  176139           0 :      return storageCounter;
  176140             :    }
  176141             : 
  176142             : /* #line 176143 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  176143             : 
  176144             : 
  176145             : 
  176146             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  176147             : 
  176148             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  176149             : 
  176150             : //############################################################################
  176151             : /* JH (02/02/2006) Constructor of the IR node SgVarRefExp that takes its 
  176152             :  * corresponding StorageClass as parameter
  176153             :  */
  176154        6511 : SgVarRefExp :: SgVarRefExp ( const SgVarRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  176155             :    {
  176156             : 
  176157             : 
  176158             : /* #line 176159 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  176159             : 
  176160        6511 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  176161        6511 :      p_symbol =  (SgVariableSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol) );
  176162        6511 :      p_originalExpressionTree =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_originalExpressionTree) );
  176163        6511 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  176164        6511 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  176165        6511 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  176166             : 
  176167             : 
  176168             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  176169             : 
  176170             : 
  176171        6511 :    }
  176172             : 
  176173             : //############################################################################
  176174             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  176175             :  * within the working AST. 
  176176             :  */
  176177       26044 : SgVarRefExp * SgVarRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  176178       26044 :      SgVarRefExp* returnPointer = NULL;
  176179       26044 :      if ( globalIndex != 0 )
  176180             :         {
  176181             : 
  176182             : #if FILE_IO_EXTRA_CHECK
  176183       26044 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVarRefExp ) ) <= globalIndex ) ;
  176184       26044 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarRefExp + 1 ) ) );
  176185             : #endif
  176186       26044 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarRefExp )  
  176187       26044 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVarRefExp );
  176188       26044 :           unsigned long positionInPool = localIndex % SgVarRefExp::pool_size;
  176189       26044 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarRefExp::pool_size;
  176190             : 
  176191             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  176192             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  176193             : 
  176194       26044 :           returnPointer = &( ( (SgVarRefExp*)(SgVarRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  176195             : 
  176196       26044 :           ROSE_ASSERT( returnPointer != NULL ) ;
  176197             :         }
  176198       26044 :      return returnPointer ;
  176199             :    }
  176200             : 
  176201             : //############################################################################
  176202             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  176203             :   for the AST with the index astIndex
  176204             : */
  176205           0 : SgVarRefExp * SgVarRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  176206           0 :      SgVarRefExp* returnPointer = NULL;
  176207           0 :      if ( globalIndex != 0 )
  176208             :         {
  176209             : 
  176210             : #if FILE_IO_EXTRA_CHECK
  176211           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVarRefExp ) ) <= globalIndex ) ;
  176212           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarRefExp + 1 ) ) );
  176213             : #endif
  176214           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarRefExp )
  176215           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVarRefExp );
  176216           0 :           unsigned long positionInPool = localIndex % SgVarRefExp::pool_size ;
  176217           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarRefExp::pool_size ;
  176218             : 
  176219             : #if FILE_IO_EXTRA_CHECK
  176220             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  176221             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  176222             : #endif
  176223             : 
  176224           0 :           returnPointer = &( ( (SgVarRefExp*)(SgVarRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  176225             : 
  176226             : #if FILE_IO_EXTRA_CHECK
  176227           0 :           assert ( returnPointer != NULL ) ;
  176228             : #endif
  176229             :         }
  176230           0 :      return returnPointer ;
  176231             :    }
  176232             : 
  176233             : //############################################################################
  176234             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  176235             :  * pool size! We set for every valid object in the memory pool the freepointer
  176236             :  * to the global index and increase the global index afterwards. For all the 
  176237             :  * invalid objects (means address ranges within the memory pool that were not
  176238             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  176239             :  * distinguish valid from invalid objects! 
  176240             :  */
  176241             : unsigned long
  176242           5 : SgVarRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  176243             :    {
  176244           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  176245           5 :      SgVarRefExp* pointer = NULL;
  176246           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  176247           5 :      std::vector < unsigned char* > :: const_iterator block;
  176248           9 :      for ( block = SgVarRefExp::pools.begin(); block != SgVarRefExp::pools.end() ; ++block )
  176249             :         {
  176250           4 :           pointer = (SgVarRefExp*)(*block);
  176251        8004 :           for (unsigned i = 0; i < SgVarRefExp::pool_size; ++i )
  176252             :              {
  176253             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  176254             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  176255             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  176256             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  176257             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  176258             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  176259             :             // properly; so this will have to be checked next.
  176260             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  176261             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  176262        8000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  176263             :                   {
  176264        6511 :                     pointer[i].set_freepointer((SgVarRefExp*)(globalIndex));
  176265        6511 :                     globalIndex++;
  176266             :                   }
  176267             :                else
  176268             :                   {
  176269        1489 :                     pointer[i].set_freepointer(NULL);
  176270             :                   }
  176271             :               }
  176272             :         }
  176273           5 :      return globalIndex;
  176274             :    }
  176275             : 
  176276             : //############################################################################
  176277             : // JH (01/14/2006)
  176278             : void
  176279           5 : SgVarRefExp::resetValidFreepointers( )
  176280             :    {
  176281           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  176282           5 :      SgVarRefExp* pointer = NULL;
  176283           5 :      std::vector < unsigned char* > :: const_iterator block;
  176284           5 :      SgVarRefExp* pointerOfLinkedList = NULL;
  176285           9 :      for ( block = SgVarRefExp::pools.begin(); block != SgVarRefExp::pools.end() ; ++block )
  176286             :         {
  176287           4 :           pointer = (SgVarRefExp*)(*block);
  176288        8004 :           for (unsigned i = 0; i < SgVarRefExp::pool_size; ++i )
  176289             :              {
  176290             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  176291             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  176292             :             // memory blocks!.
  176293        8000 :                if ( pointer[i].get_freepointer() != NULL )
  176294             :                   {
  176295        6511 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  176296             :                   }
  176297             :                else
  176298             :                   {
  176299        1489 :                     if ( pointerOfLinkedList == NULL )
  176300             :                        {
  176301           1 :                          SgVarRefExp::next_node = &(pointer[i]);
  176302             :                        }
  176303             :                     else
  176304             :                        {
  176305             :                       // printf ("In SgVarRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  176306        1488 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  176307             :                        }
  176308             :                     pointerOfLinkedList = &(pointer[i]);
  176309             :                   }
  176310             :               }
  176311             :         }
  176312             : 
  176313           5 :      if ( pointerOfLinkedList != NULL )
  176314             :         {
  176315             :        // printf ("In SgVarRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  176316           1 :           pointerOfLinkedList->set_freepointer(NULL);
  176317             :        // DQ (6/6/2010): Temporary debugging...
  176318             :        //   ROSE_ASSERT(false);
  176319             :         }
  176320             : 
  176321           5 :      return ;
  176322             :    }
  176323             : 
  176324             : //############################################################################
  176325             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  176326             :  * within the memory pool and resets the freepointers, in order to achieve a 
  176327             :  * linked list, that has no jumps and starts at the beginning! This function 
  176328             :  * does not extend the memory pool, since we do not delete any memory blocks,
  176329             :  * but delete the valid objects.  
  176330             :  */
  176331             : void
  176332           0 : SgVarRefExp::clearMemoryPool( )
  176333             :    {
  176334             :   // printf ("Inside of SgVarRefExp::clearMemoryPool() \n");
  176335             : 
  176336           0 :      SgVarRefExp* pointer = NULL, *tempPointer = NULL;
  176337           0 :      std::vector < unsigned char* > :: const_iterator block;
  176338           0 :      if ( SgVarRefExp::pools.empty() == false )
  176339             :         {
  176340           0 :           block = SgVarRefExp::pools.begin() ;
  176341           0 :           SgVarRefExp::next_node = (SgVarRefExp*) (*block);
  176342             : 
  176343           0 :           while ( block != SgVarRefExp::pools.end() )
  176344             :              {
  176345           0 :                pointer = (SgVarRefExp*) (*block);
  176346           0 :                if ( tempPointer != NULL )
  176347             :                   {
  176348           0 :                     tempPointer->set_freepointer(pointer);
  176349             :                   }
  176350           0 :                for (unsigned i = 0; i < SgVarRefExp::pool_size - 1; ++i)
  176351             :                   {
  176352           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  176353             :                   }
  176354           0 :                 pointer[SgVarRefExp::pool_size-1].set_freepointer(NULL);
  176355           0 :                 tempPointer = &(pointer[SgVarRefExp::pool_size-1]);
  176356           0 :                 ++block;
  176357             :              }
  176358             :         }
  176359           0 :    }
  176360             : 
  176361           5 : void SgVarRefExp::deleteMemoryPool() {
  176362          13 :   for (auto p: SgVarRefExp::pools) {
  176363           8 :     ROSE_FREE(p);
  176364             :   }
  176365           5 :   SgVarRefExp::next_node = nullptr;
  176366           5 :   SgVarRefExp::pools.clear();
  176367           5 : }
  176368             : 
  176369             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  176370             : //                 reading multiple binary files to for a single AST.
  176371             : /////////// new version ////////////////////////////////
  176372             : //############################################################################
  176373             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  176374             : void
  176375           2 : SgVarRefExp::extendMemoryPoolForFileIO( )
  176376             :   {
  176377           2 :     size_t blockIndex = SgVarRefExp::pools.size();
  176378           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVarRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarRefExp);
  176379             : 
  176380           6 :     while ( (blockIndex * SgVarRefExp::pool_size) < newPoolSize)
  176381             :       {
  176382             : #if ROSE_ALLOC_TRACE
  176383             :         if (blockIndex > 0) {
  176384             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVarRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarRefExp) = %" PRIuPTR " SgVarRefExp::pool_size = %d \n",
  176385             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVarRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarRefExp),SgVarRefExp::pool_size);
  176386             :         }
  176387             : #endif
  176388             : 
  176389           4 :         SgVarRefExp * pointer = (SgVarRefExp*) ROSE_MALLOC ( SgVarRefExp::pool_size * sizeof(SgVarRefExp) );
  176390           4 :         assert( pointer != NULL );
  176391             : #if ROSE_ALLOC_MEMSET == 1
  176392             :         memset(pointer, 0x00, SgVarRefExp::pool_size * sizeof(SgVarRefExp));
  176393             : #elif ROSE_ALLOC_MEMSET == 2
  176394             :         memset(pointer, 0xCC, SgVarRefExp::pool_size * sizeof(SgVarRefExp));
  176395             : #endif
  176396           4 :         SgVarRefExp::pools.push_back( (unsigned char*)(pointer) );
  176397           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVarRefExp::pool_size * sizeof(SgVarRefExp), V_SgVarRefExp ) );
  176398             : 
  176399           4 :         if ( SgVarRefExp::next_node != NULL ) {
  176400           3 :           if ( blockIndex > 0 ) {
  176401           3 :             SgVarRefExp * blkptr = (SgVarRefExp*)(SgVarRefExp::pools[blockIndex-1]);
  176402           3 :             blkptr[ SgVarRefExp::pool_size - 1 ].set_freepointer(pointer);
  176403             :           }
  176404             :         } else {
  176405           1 :           SgVarRefExp::next_node = pointer;
  176406             :         }
  176407             : 
  176408        8000 :         for (unsigned i = 0; i < SgVarRefExp::pool_size-1; ++i)
  176409             :            {
  176410        7996 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  176411             :            }
  176412           4 :         pointer[ SgVarRefExp::pool_size -1 ].set_freepointer(NULL);
  176413             : 
  176414           4 :         blockIndex++;
  176415             :       }
  176416           2 :   }
  176417             : 
  176418             : //############################################################################
  176419             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  176420             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  176421             :  * not compressed. However, that stuff is not yet implemented! 
  176422             :  */
  176423             : unsigned long
  176424           0 : SgVarRefExp::getNumberOfLastValidPointer()
  176425             :    {
  176426           0 :       SgVarRefExp* testPointer = (SgVarRefExp*)(SgVarRefExp::pools.back());
  176427           0 :       unsigned long localIndex = SgVarRefExp::pool_size - 1;
  176428           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  176429             :          {
  176430           0 :            localIndex--;
  176431             :          }
  176432           0 :       return (localIndex + SgVarRefExp::pool_size * (SgVarRefExp::pools.size()-1));
  176433             :    }
  176434             : 
  176435             : //############################################################################
  176436             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  176437             :  * memory pool and initializes the data member in class SgVarRefExpStroageClass
  176438             :  * from its counterpart of SgVarRefExp. The return value is just for checking, 
  176439             :  * that the whole StorageClassArray is initialized!
  176440             :  */
  176441             : unsigned long
  176442           1 : SgVarRefExp::initializeStorageClassArray( SgVarRefExpStorageClass *storageArray )
  176443             :    {
  176444           1 :      unsigned long storageCounter = 0;
  176445           1 :      std::vector < unsigned char* > :: const_iterator block = SgVarRefExp::pools.begin();
  176446           1 :      SgVarRefExp* pointer = NULL;
  176447           5 :      while ( block != SgVarRefExp::pools.end() ) {
  176448           4 :           pointer = (SgVarRefExp*) (*block);
  176449        8004 :           for ( unsigned i = 0; i < SgVarRefExp::pool_size; ++i ) {
  176450        8000 :                if ( pointer->get_freepointer() != NULL ) {
  176451        6511 :                  storageArray->pickOutIRNodeData (pointer) ;
  176452        6511 :                  storageArray++;
  176453        6511 :                  storageCounter++;
  176454             :                }
  176455        8000 :                pointer++;
  176456             :              }
  176457           4 :            block++;
  176458             :         }
  176459           1 :      return storageCounter;
  176460             :    }
  176461             : 
  176462             : /* #line 176463 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  176463             : 
  176464             : 
  176465             : 
  176466             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  176467             : 
  176468             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  176469             : 
  176470             : //############################################################################
  176471             : /* JH (02/02/2006) Constructor of the IR node SgClassNameRefExp that takes its 
  176472             :  * corresponding StorageClass as parameter
  176473             :  */
  176474           0 : SgClassNameRefExp :: SgClassNameRefExp ( const SgClassNameRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  176475             :    {
  176476             : 
  176477             : 
  176478             : /* #line 176479 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  176479             : 
  176480           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  176481           0 :      p_symbol =  (SgClassSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol) );
  176482             : 
  176483             : 
  176484             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  176485             : 
  176486             : 
  176487           0 :    }
  176488             : 
  176489             : //############################################################################
  176490             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  176491             :  * within the working AST. 
  176492             :  */
  176493           0 : SgClassNameRefExp * SgClassNameRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  176494           0 :      SgClassNameRefExp* returnPointer = NULL;
  176495           0 :      if ( globalIndex != 0 )
  176496             :         {
  176497             : 
  176498             : #if FILE_IO_EXTRA_CHECK
  176499           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClassNameRefExp ) ) <= globalIndex ) ;
  176500           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassNameRefExp + 1 ) ) );
  176501             : #endif
  176502           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassNameRefExp )  
  176503           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClassNameRefExp );
  176504           0 :           unsigned long positionInPool = localIndex % SgClassNameRefExp::pool_size;
  176505           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassNameRefExp::pool_size;
  176506             : 
  176507             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  176508             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  176509             : 
  176510           0 :           returnPointer = &( ( (SgClassNameRefExp*)(SgClassNameRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  176511             : 
  176512           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  176513             :         }
  176514           0 :      return returnPointer ;
  176515             :    }
  176516             : 
  176517             : //############################################################################
  176518             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  176519             :   for the AST with the index astIndex
  176520             : */
  176521           0 : SgClassNameRefExp * SgClassNameRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  176522           0 :      SgClassNameRefExp* returnPointer = NULL;
  176523           0 :      if ( globalIndex != 0 )
  176524             :         {
  176525             : 
  176526             : #if FILE_IO_EXTRA_CHECK
  176527           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClassNameRefExp ) ) <= globalIndex ) ;
  176528           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassNameRefExp + 1 ) ) );
  176529             : #endif
  176530           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassNameRefExp )
  176531           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClassNameRefExp );
  176532           0 :           unsigned long positionInPool = localIndex % SgClassNameRefExp::pool_size ;
  176533           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassNameRefExp::pool_size ;
  176534             : 
  176535             : #if FILE_IO_EXTRA_CHECK
  176536             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  176537             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  176538             : #endif
  176539             : 
  176540           0 :           returnPointer = &( ( (SgClassNameRefExp*)(SgClassNameRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  176541             : 
  176542             : #if FILE_IO_EXTRA_CHECK
  176543           0 :           assert ( returnPointer != NULL ) ;
  176544             : #endif
  176545             :         }
  176546           0 :      return returnPointer ;
  176547             :    }
  176548             : 
  176549             : //############################################################################
  176550             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  176551             :  * pool size! We set for every valid object in the memory pool the freepointer
  176552             :  * to the global index and increase the global index afterwards. For all the 
  176553             :  * invalid objects (means address ranges within the memory pool that were not
  176554             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  176555             :  * distinguish valid from invalid objects! 
  176556             :  */
  176557             : unsigned long
  176558           5 : SgClassNameRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  176559             :    {
  176560           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  176561           5 :      SgClassNameRefExp* pointer = NULL;
  176562           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  176563           5 :      std::vector < unsigned char* > :: const_iterator block;
  176564           5 :      for ( block = SgClassNameRefExp::pools.begin(); block != SgClassNameRefExp::pools.end() ; ++block )
  176565             :         {
  176566           0 :           pointer = (SgClassNameRefExp*)(*block);
  176567           0 :           for (unsigned i = 0; i < SgClassNameRefExp::pool_size; ++i )
  176568             :              {
  176569             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  176570             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  176571             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  176572             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  176573             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  176574             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  176575             :             // properly; so this will have to be checked next.
  176576             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  176577             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  176578           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  176579             :                   {
  176580           0 :                     pointer[i].set_freepointer((SgClassNameRefExp*)(globalIndex));
  176581           0 :                     globalIndex++;
  176582             :                   }
  176583             :                else
  176584             :                   {
  176585           0 :                     pointer[i].set_freepointer(NULL);
  176586             :                   }
  176587             :               }
  176588             :         }
  176589           5 :      return globalIndex;
  176590             :    }
  176591             : 
  176592             : //############################################################################
  176593             : // JH (01/14/2006)
  176594             : void
  176595           5 : SgClassNameRefExp::resetValidFreepointers( )
  176596             :    {
  176597           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  176598           5 :      SgClassNameRefExp* pointer = NULL;
  176599           5 :      std::vector < unsigned char* > :: const_iterator block;
  176600           5 :      SgClassNameRefExp* pointerOfLinkedList = NULL;
  176601           5 :      for ( block = SgClassNameRefExp::pools.begin(); block != SgClassNameRefExp::pools.end() ; ++block )
  176602             :         {
  176603           0 :           pointer = (SgClassNameRefExp*)(*block);
  176604           0 :           for (unsigned i = 0; i < SgClassNameRefExp::pool_size; ++i )
  176605             :              {
  176606             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  176607             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  176608             :             // memory blocks!.
  176609           0 :                if ( pointer[i].get_freepointer() != NULL )
  176610             :                   {
  176611           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  176612             :                   }
  176613             :                else
  176614             :                   {
  176615           0 :                     if ( pointerOfLinkedList == NULL )
  176616             :                        {
  176617           0 :                          SgClassNameRefExp::next_node = &(pointer[i]);
  176618             :                        }
  176619             :                     else
  176620             :                        {
  176621             :                       // printf ("In SgClassNameRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  176622           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  176623             :                        }
  176624             :                     pointerOfLinkedList = &(pointer[i]);
  176625             :                   }
  176626             :               }
  176627             :         }
  176628             : 
  176629           5 :      if ( pointerOfLinkedList != NULL )
  176630             :         {
  176631             :        // printf ("In SgClassNameRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  176632           0 :           pointerOfLinkedList->set_freepointer(NULL);
  176633             :        // DQ (6/6/2010): Temporary debugging...
  176634             :        //   ROSE_ASSERT(false);
  176635             :         }
  176636             : 
  176637           5 :      return ;
  176638             :    }
  176639             : 
  176640             : //############################################################################
  176641             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  176642             :  * within the memory pool and resets the freepointers, in order to achieve a 
  176643             :  * linked list, that has no jumps and starts at the beginning! This function 
  176644             :  * does not extend the memory pool, since we do not delete any memory blocks,
  176645             :  * but delete the valid objects.  
  176646             :  */
  176647             : void
  176648           0 : SgClassNameRefExp::clearMemoryPool( )
  176649             :    {
  176650             :   // printf ("Inside of SgClassNameRefExp::clearMemoryPool() \n");
  176651             : 
  176652           0 :      SgClassNameRefExp* pointer = NULL, *tempPointer = NULL;
  176653           0 :      std::vector < unsigned char* > :: const_iterator block;
  176654           0 :      if ( SgClassNameRefExp::pools.empty() == false )
  176655             :         {
  176656           0 :           block = SgClassNameRefExp::pools.begin() ;
  176657           0 :           SgClassNameRefExp::next_node = (SgClassNameRefExp*) (*block);
  176658             : 
  176659           0 :           while ( block != SgClassNameRefExp::pools.end() )
  176660             :              {
  176661           0 :                pointer = (SgClassNameRefExp*) (*block);
  176662           0 :                if ( tempPointer != NULL )
  176663             :                   {
  176664           0 :                     tempPointer->set_freepointer(pointer);
  176665             :                   }
  176666           0 :                for (unsigned i = 0; i < SgClassNameRefExp::pool_size - 1; ++i)
  176667             :                   {
  176668           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  176669             :                   }
  176670           0 :                 pointer[SgClassNameRefExp::pool_size-1].set_freepointer(NULL);
  176671           0 :                 tempPointer = &(pointer[SgClassNameRefExp::pool_size-1]);
  176672           0 :                 ++block;
  176673             :              }
  176674             :         }
  176675           0 :    }
  176676             : 
  176677           5 : void SgClassNameRefExp::deleteMemoryPool() {
  176678           5 :   for (auto p: SgClassNameRefExp::pools) {
  176679           0 :     ROSE_FREE(p);
  176680             :   }
  176681           5 :   SgClassNameRefExp::next_node = nullptr;
  176682           5 :   SgClassNameRefExp::pools.clear();
  176683           5 : }
  176684             : 
  176685             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  176686             : //                 reading multiple binary files to for a single AST.
  176687             : /////////// new version ////////////////////////////////
  176688             : //############################################################################
  176689             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  176690             : void
  176691           2 : SgClassNameRefExp::extendMemoryPoolForFileIO( )
  176692             :   {
  176693           2 :     size_t blockIndex = SgClassNameRefExp::pools.size();
  176694           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClassNameRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassNameRefExp);
  176695             : 
  176696           2 :     while ( (blockIndex * SgClassNameRefExp::pool_size) < newPoolSize)
  176697             :       {
  176698             : #if ROSE_ALLOC_TRACE
  176699             :         if (blockIndex > 0) {
  176700             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClassNameRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassNameRefExp) = %" PRIuPTR " SgClassNameRefExp::pool_size = %d \n",
  176701             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClassNameRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassNameRefExp),SgClassNameRefExp::pool_size);
  176702             :         }
  176703             : #endif
  176704             : 
  176705           0 :         SgClassNameRefExp * pointer = (SgClassNameRefExp*) ROSE_MALLOC ( SgClassNameRefExp::pool_size * sizeof(SgClassNameRefExp) );
  176706           0 :         assert( pointer != NULL );
  176707             : #if ROSE_ALLOC_MEMSET == 1
  176708             :         memset(pointer, 0x00, SgClassNameRefExp::pool_size * sizeof(SgClassNameRefExp));
  176709             : #elif ROSE_ALLOC_MEMSET == 2
  176710             :         memset(pointer, 0xCC, SgClassNameRefExp::pool_size * sizeof(SgClassNameRefExp));
  176711             : #endif
  176712           0 :         SgClassNameRefExp::pools.push_back( (unsigned char*)(pointer) );
  176713           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClassNameRefExp::pool_size * sizeof(SgClassNameRefExp), V_SgClassNameRefExp ) );
  176714             : 
  176715           0 :         if ( SgClassNameRefExp::next_node != NULL ) {
  176716           0 :           if ( blockIndex > 0 ) {
  176717           0 :             SgClassNameRefExp * blkptr = (SgClassNameRefExp*)(SgClassNameRefExp::pools[blockIndex-1]);
  176718           0 :             blkptr[ SgClassNameRefExp::pool_size - 1 ].set_freepointer(pointer);
  176719             :           }
  176720             :         } else {
  176721           0 :           SgClassNameRefExp::next_node = pointer;
  176722             :         }
  176723             : 
  176724           0 :         for (unsigned i = 0; i < SgClassNameRefExp::pool_size-1; ++i)
  176725             :            {
  176726           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  176727             :            }
  176728           0 :         pointer[ SgClassNameRefExp::pool_size -1 ].set_freepointer(NULL);
  176729             : 
  176730           0 :         blockIndex++;
  176731             :       }
  176732           2 :   }
  176733             : 
  176734             : //############################################################################
  176735             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  176736             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  176737             :  * not compressed. However, that stuff is not yet implemented! 
  176738             :  */
  176739             : unsigned long
  176740           0 : SgClassNameRefExp::getNumberOfLastValidPointer()
  176741             :    {
  176742           0 :       SgClassNameRefExp* testPointer = (SgClassNameRefExp*)(SgClassNameRefExp::pools.back());
  176743           0 :       unsigned long localIndex = SgClassNameRefExp::pool_size - 1;
  176744           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  176745             :          {
  176746           0 :            localIndex--;
  176747             :          }
  176748           0 :       return (localIndex + SgClassNameRefExp::pool_size * (SgClassNameRefExp::pools.size()-1));
  176749             :    }
  176750             : 
  176751             : //############################################################################
  176752             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  176753             :  * memory pool and initializes the data member in class SgClassNameRefExpStroageClass
  176754             :  * from its counterpart of SgClassNameRefExp. The return value is just for checking, 
  176755             :  * that the whole StorageClassArray is initialized!
  176756             :  */
  176757             : unsigned long
  176758           0 : SgClassNameRefExp::initializeStorageClassArray( SgClassNameRefExpStorageClass *storageArray )
  176759             :    {
  176760           0 :      unsigned long storageCounter = 0;
  176761           0 :      std::vector < unsigned char* > :: const_iterator block = SgClassNameRefExp::pools.begin();
  176762           0 :      SgClassNameRefExp* pointer = NULL;
  176763           0 :      while ( block != SgClassNameRefExp::pools.end() ) {
  176764           0 :           pointer = (SgClassNameRefExp*) (*block);
  176765           0 :           for ( unsigned i = 0; i < SgClassNameRefExp::pool_size; ++i ) {
  176766           0 :                if ( pointer->get_freepointer() != NULL ) {
  176767           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  176768           0 :                  storageArray++;
  176769           0 :                  storageCounter++;
  176770             :                }
  176771           0 :                pointer++;
  176772             :              }
  176773           0 :            block++;
  176774             :         }
  176775           0 :      return storageCounter;
  176776             :    }
  176777             : 
  176778             : /* #line 176779 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  176779             : 
  176780             : 
  176781             : 
  176782             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  176783             : 
  176784             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  176785             : 
  176786             : //############################################################################
  176787             : /* JH (02/02/2006) Constructor of the IR node SgFunctionRefExp that takes its 
  176788             :  * corresponding StorageClass as parameter
  176789             :  */
  176790         608 : SgFunctionRefExp :: SgFunctionRefExp ( const SgFunctionRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  176791             :    {
  176792             : 
  176793             : 
  176794             : /* #line 176795 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  176795             : 
  176796         608 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  176797         608 :      p_symbol_i =  (SgFunctionSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol_i) );
  176798         608 :      p_function_type =  (SgFunctionType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_function_type) );
  176799         608 :      p_originalExpressionTree =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_originalExpressionTree) );
  176800         608 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  176801         608 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  176802         608 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  176803             : 
  176804             : 
  176805             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  176806             : 
  176807             : 
  176808         608 :    }
  176809             : 
  176810             : //############################################################################
  176811             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  176812             :  * within the working AST. 
  176813             :  */
  176814        2432 : SgFunctionRefExp * SgFunctionRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  176815        2432 :      SgFunctionRefExp* returnPointer = NULL;
  176816        2432 :      if ( globalIndex != 0 )
  176817             :         {
  176818             : 
  176819             : #if FILE_IO_EXTRA_CHECK
  176820        2432 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionRefExp ) ) <= globalIndex ) ;
  176821        2432 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionRefExp + 1 ) ) );
  176822             : #endif
  176823        2432 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionRefExp )  
  176824        2432 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionRefExp );
  176825        2432 :           unsigned long positionInPool = localIndex % SgFunctionRefExp::pool_size;
  176826        2432 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionRefExp::pool_size;
  176827             : 
  176828             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  176829             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  176830             : 
  176831        2432 :           returnPointer = &( ( (SgFunctionRefExp*)(SgFunctionRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  176832             : 
  176833        2432 :           ROSE_ASSERT( returnPointer != NULL ) ;
  176834             :         }
  176835        2432 :      return returnPointer ;
  176836             :    }
  176837             : 
  176838             : //############################################################################
  176839             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  176840             :   for the AST with the index astIndex
  176841             : */
  176842           0 : SgFunctionRefExp * SgFunctionRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  176843           0 :      SgFunctionRefExp* returnPointer = NULL;
  176844           0 :      if ( globalIndex != 0 )
  176845             :         {
  176846             : 
  176847             : #if FILE_IO_EXTRA_CHECK
  176848           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionRefExp ) ) <= globalIndex ) ;
  176849           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionRefExp + 1 ) ) );
  176850             : #endif
  176851           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionRefExp )
  176852           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionRefExp );
  176853           0 :           unsigned long positionInPool = localIndex % SgFunctionRefExp::pool_size ;
  176854           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionRefExp::pool_size ;
  176855             : 
  176856             : #if FILE_IO_EXTRA_CHECK
  176857             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  176858             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  176859             : #endif
  176860             : 
  176861           0 :           returnPointer = &( ( (SgFunctionRefExp*)(SgFunctionRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  176862             : 
  176863             : #if FILE_IO_EXTRA_CHECK
  176864           0 :           assert ( returnPointer != NULL ) ;
  176865             : #endif
  176866             :         }
  176867           0 :      return returnPointer ;
  176868             :    }
  176869             : 
  176870             : //############################################################################
  176871             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  176872             :  * pool size! We set for every valid object in the memory pool the freepointer
  176873             :  * to the global index and increase the global index afterwards. For all the 
  176874             :  * invalid objects (means address ranges within the memory pool that were not
  176875             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  176876             :  * distinguish valid from invalid objects! 
  176877             :  */
  176878             : unsigned long
  176879           5 : SgFunctionRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  176880             :    {
  176881           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  176882           5 :      SgFunctionRefExp* pointer = NULL;
  176883           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  176884           5 :      std::vector < unsigned char* > :: const_iterator block;
  176885           7 :      for ( block = SgFunctionRefExp::pools.begin(); block != SgFunctionRefExp::pools.end() ; ++block )
  176886             :         {
  176887           2 :           pointer = (SgFunctionRefExp*)(*block);
  176888        4002 :           for (unsigned i = 0; i < SgFunctionRefExp::pool_size; ++i )
  176889             :              {
  176890             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  176891             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  176892             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  176893             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  176894             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  176895             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  176896             :             // properly; so this will have to be checked next.
  176897             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  176898             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  176899        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  176900             :                   {
  176901         608 :                     pointer[i].set_freepointer((SgFunctionRefExp*)(globalIndex));
  176902         608 :                     globalIndex++;
  176903             :                   }
  176904             :                else
  176905             :                   {
  176906        3392 :                     pointer[i].set_freepointer(NULL);
  176907             :                   }
  176908             :               }
  176909             :         }
  176910           5 :      return globalIndex;
  176911             :    }
  176912             : 
  176913             : //############################################################################
  176914             : // JH (01/14/2006)
  176915             : void
  176916           5 : SgFunctionRefExp::resetValidFreepointers( )
  176917             :    {
  176918           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  176919           5 :      SgFunctionRefExp* pointer = NULL;
  176920           5 :      std::vector < unsigned char* > :: const_iterator block;
  176921           5 :      SgFunctionRefExp* pointerOfLinkedList = NULL;
  176922           7 :      for ( block = SgFunctionRefExp::pools.begin(); block != SgFunctionRefExp::pools.end() ; ++block )
  176923             :         {
  176924           2 :           pointer = (SgFunctionRefExp*)(*block);
  176925        4002 :           for (unsigned i = 0; i < SgFunctionRefExp::pool_size; ++i )
  176926             :              {
  176927             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  176928             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  176929             :             // memory blocks!.
  176930        4000 :                if ( pointer[i].get_freepointer() != NULL )
  176931             :                   {
  176932         608 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  176933             :                   }
  176934             :                else
  176935             :                   {
  176936        3392 :                     if ( pointerOfLinkedList == NULL )
  176937             :                        {
  176938           2 :                          SgFunctionRefExp::next_node = &(pointer[i]);
  176939             :                        }
  176940             :                     else
  176941             :                        {
  176942             :                       // printf ("In SgFunctionRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  176943        3390 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  176944             :                        }
  176945             :                     pointerOfLinkedList = &(pointer[i]);
  176946             :                   }
  176947             :               }
  176948             :         }
  176949             : 
  176950           5 :      if ( pointerOfLinkedList != NULL )
  176951             :         {
  176952             :        // printf ("In SgFunctionRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  176953           2 :           pointerOfLinkedList->set_freepointer(NULL);
  176954             :        // DQ (6/6/2010): Temporary debugging...
  176955             :        //   ROSE_ASSERT(false);
  176956             :         }
  176957             : 
  176958           5 :      return ;
  176959             :    }
  176960             : 
  176961             : //############################################################################
  176962             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  176963             :  * within the memory pool and resets the freepointers, in order to achieve a 
  176964             :  * linked list, that has no jumps and starts at the beginning! This function 
  176965             :  * does not extend the memory pool, since we do not delete any memory blocks,
  176966             :  * but delete the valid objects.  
  176967             :  */
  176968             : void
  176969           0 : SgFunctionRefExp::clearMemoryPool( )
  176970             :    {
  176971             :   // printf ("Inside of SgFunctionRefExp::clearMemoryPool() \n");
  176972             : 
  176973           0 :      SgFunctionRefExp* pointer = NULL, *tempPointer = NULL;
  176974           0 :      std::vector < unsigned char* > :: const_iterator block;
  176975           0 :      if ( SgFunctionRefExp::pools.empty() == false )
  176976             :         {
  176977           0 :           block = SgFunctionRefExp::pools.begin() ;
  176978           0 :           SgFunctionRefExp::next_node = (SgFunctionRefExp*) (*block);
  176979             : 
  176980           0 :           while ( block != SgFunctionRefExp::pools.end() )
  176981             :              {
  176982           0 :                pointer = (SgFunctionRefExp*) (*block);
  176983           0 :                if ( tempPointer != NULL )
  176984             :                   {
  176985           0 :                     tempPointer->set_freepointer(pointer);
  176986             :                   }
  176987           0 :                for (unsigned i = 0; i < SgFunctionRefExp::pool_size - 1; ++i)
  176988             :                   {
  176989           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  176990             :                   }
  176991           0 :                 pointer[SgFunctionRefExp::pool_size-1].set_freepointer(NULL);
  176992           0 :                 tempPointer = &(pointer[SgFunctionRefExp::pool_size-1]);
  176993           0 :                 ++block;
  176994             :              }
  176995             :         }
  176996           0 :    }
  176997             : 
  176998           5 : void SgFunctionRefExp::deleteMemoryPool() {
  176999           9 :   for (auto p: SgFunctionRefExp::pools) {
  177000           4 :     ROSE_FREE(p);
  177001             :   }
  177002           5 :   SgFunctionRefExp::next_node = nullptr;
  177003           5 :   SgFunctionRefExp::pools.clear();
  177004           5 : }
  177005             : 
  177006             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  177007             : //                 reading multiple binary files to for a single AST.
  177008             : /////////// new version ////////////////////////////////
  177009             : //############################################################################
  177010             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  177011             : void
  177012           2 : SgFunctionRefExp::extendMemoryPoolForFileIO( )
  177013             :   {
  177014           2 :     size_t blockIndex = SgFunctionRefExp::pools.size();
  177015           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionRefExp);
  177016             : 
  177017           4 :     while ( (blockIndex * SgFunctionRefExp::pool_size) < newPoolSize)
  177018             :       {
  177019             : #if ROSE_ALLOC_TRACE
  177020             :         if (blockIndex > 0) {
  177021             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionRefExp) = %" PRIuPTR " SgFunctionRefExp::pool_size = %d \n",
  177022             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionRefExp),SgFunctionRefExp::pool_size);
  177023             :         }
  177024             : #endif
  177025             : 
  177026           2 :         SgFunctionRefExp * pointer = (SgFunctionRefExp*) ROSE_MALLOC ( SgFunctionRefExp::pool_size * sizeof(SgFunctionRefExp) );
  177027           2 :         assert( pointer != NULL );
  177028             : #if ROSE_ALLOC_MEMSET == 1
  177029             :         memset(pointer, 0x00, SgFunctionRefExp::pool_size * sizeof(SgFunctionRefExp));
  177030             : #elif ROSE_ALLOC_MEMSET == 2
  177031             :         memset(pointer, 0xCC, SgFunctionRefExp::pool_size * sizeof(SgFunctionRefExp));
  177032             : #endif
  177033           2 :         SgFunctionRefExp::pools.push_back( (unsigned char*)(pointer) );
  177034           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionRefExp::pool_size * sizeof(SgFunctionRefExp), V_SgFunctionRefExp ) );
  177035             : 
  177036           2 :         if ( SgFunctionRefExp::next_node != NULL ) {
  177037           0 :           if ( blockIndex > 0 ) {
  177038           0 :             SgFunctionRefExp * blkptr = (SgFunctionRefExp*)(SgFunctionRefExp::pools[blockIndex-1]);
  177039           0 :             blkptr[ SgFunctionRefExp::pool_size - 1 ].set_freepointer(pointer);
  177040             :           }
  177041             :         } else {
  177042           2 :           SgFunctionRefExp::next_node = pointer;
  177043             :         }
  177044             : 
  177045        4000 :         for (unsigned i = 0; i < SgFunctionRefExp::pool_size-1; ++i)
  177046             :            {
  177047        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  177048             :            }
  177049           2 :         pointer[ SgFunctionRefExp::pool_size -1 ].set_freepointer(NULL);
  177050             : 
  177051           2 :         blockIndex++;
  177052             :       }
  177053           2 :   }
  177054             : 
  177055             : //############################################################################
  177056             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  177057             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  177058             :  * not compressed. However, that stuff is not yet implemented! 
  177059             :  */
  177060             : unsigned long
  177061           0 : SgFunctionRefExp::getNumberOfLastValidPointer()
  177062             :    {
  177063           0 :       SgFunctionRefExp* testPointer = (SgFunctionRefExp*)(SgFunctionRefExp::pools.back());
  177064           0 :       unsigned long localIndex = SgFunctionRefExp::pool_size - 1;
  177065           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  177066             :          {
  177067           0 :            localIndex--;
  177068             :          }
  177069           0 :       return (localIndex + SgFunctionRefExp::pool_size * (SgFunctionRefExp::pools.size()-1));
  177070             :    }
  177071             : 
  177072             : //############################################################################
  177073             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  177074             :  * memory pool and initializes the data member in class SgFunctionRefExpStroageClass
  177075             :  * from its counterpart of SgFunctionRefExp. The return value is just for checking, 
  177076             :  * that the whole StorageClassArray is initialized!
  177077             :  */
  177078             : unsigned long
  177079           2 : SgFunctionRefExp::initializeStorageClassArray( SgFunctionRefExpStorageClass *storageArray )
  177080             :    {
  177081           2 :      unsigned long storageCounter = 0;
  177082           2 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionRefExp::pools.begin();
  177083           2 :      SgFunctionRefExp* pointer = NULL;
  177084           4 :      while ( block != SgFunctionRefExp::pools.end() ) {
  177085           2 :           pointer = (SgFunctionRefExp*) (*block);
  177086        4002 :           for ( unsigned i = 0; i < SgFunctionRefExp::pool_size; ++i ) {
  177087        4000 :                if ( pointer->get_freepointer() != NULL ) {
  177088         608 :                  storageArray->pickOutIRNodeData (pointer) ;
  177089         608 :                  storageArray++;
  177090         608 :                  storageCounter++;
  177091             :                }
  177092        4000 :                pointer++;
  177093             :              }
  177094           2 :            block++;
  177095             :         }
  177096           2 :      return storageCounter;
  177097             :    }
  177098             : 
  177099             : /* #line 177100 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  177100             : 
  177101             : 
  177102             : 
  177103             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  177104             : 
  177105             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  177106             : 
  177107             : //############################################################################
  177108             : /* JH (02/02/2006) Constructor of the IR node SgMemberFunctionRefExp that takes its 
  177109             :  * corresponding StorageClass as parameter
  177110             :  */
  177111         540 : SgMemberFunctionRefExp :: SgMemberFunctionRefExp ( const SgMemberFunctionRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  177112             :    {
  177113             : 
  177114             : 
  177115             : /* #line 177116 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  177116             : 
  177117         540 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  177118         540 :      p_symbol_i =  (SgMemberFunctionSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol_i) );
  177119         540 :      p_virtual_call = storageSource.storageOf_virtual_call ;
  177120         540 :      p_function_type =  (SgFunctionType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_function_type) );
  177121         540 :      p_need_qualifier = storageSource.storageOf_need_qualifier ;
  177122         540 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  177123         540 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  177124         540 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  177125             : 
  177126             : 
  177127             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  177128             : 
  177129             : 
  177130         540 :    }
  177131             : 
  177132             : //############################################################################
  177133             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  177134             :  * within the working AST. 
  177135             :  */
  177136        2160 : SgMemberFunctionRefExp * SgMemberFunctionRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  177137        2160 :      SgMemberFunctionRefExp* returnPointer = NULL;
  177138        2160 :      if ( globalIndex != 0 )
  177139             :         {
  177140             : 
  177141             : #if FILE_IO_EXTRA_CHECK
  177142        2160 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMemberFunctionRefExp ) ) <= globalIndex ) ;
  177143        2160 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMemberFunctionRefExp + 1 ) ) );
  177144             : #endif
  177145        2160 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMemberFunctionRefExp )  
  177146        2160 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMemberFunctionRefExp );
  177147        2160 :           unsigned long positionInPool = localIndex % SgMemberFunctionRefExp::pool_size;
  177148        2160 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMemberFunctionRefExp::pool_size;
  177149             : 
  177150             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  177151             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  177152             : 
  177153        2160 :           returnPointer = &( ( (SgMemberFunctionRefExp*)(SgMemberFunctionRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  177154             : 
  177155        2160 :           ROSE_ASSERT( returnPointer != NULL ) ;
  177156             :         }
  177157        2160 :      return returnPointer ;
  177158             :    }
  177159             : 
  177160             : //############################################################################
  177161             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  177162             :   for the AST with the index astIndex
  177163             : */
  177164           0 : SgMemberFunctionRefExp * SgMemberFunctionRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  177165           0 :      SgMemberFunctionRefExp* returnPointer = NULL;
  177166           0 :      if ( globalIndex != 0 )
  177167             :         {
  177168             : 
  177169             : #if FILE_IO_EXTRA_CHECK
  177170           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMemberFunctionRefExp ) ) <= globalIndex ) ;
  177171           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMemberFunctionRefExp + 1 ) ) );
  177172             : #endif
  177173           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMemberFunctionRefExp )
  177174           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMemberFunctionRefExp );
  177175           0 :           unsigned long positionInPool = localIndex % SgMemberFunctionRefExp::pool_size ;
  177176           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMemberFunctionRefExp::pool_size ;
  177177             : 
  177178             : #if FILE_IO_EXTRA_CHECK
  177179             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  177180             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  177181             : #endif
  177182             : 
  177183           0 :           returnPointer = &( ( (SgMemberFunctionRefExp*)(SgMemberFunctionRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  177184             : 
  177185             : #if FILE_IO_EXTRA_CHECK
  177186           0 :           assert ( returnPointer != NULL ) ;
  177187             : #endif
  177188             :         }
  177189           0 :      return returnPointer ;
  177190             :    }
  177191             : 
  177192             : //############################################################################
  177193             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  177194             :  * pool size! We set for every valid object in the memory pool the freepointer
  177195             :  * to the global index and increase the global index afterwards. For all the 
  177196             :  * invalid objects (means address ranges within the memory pool that were not
  177197             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  177198             :  * distinguish valid from invalid objects! 
  177199             :  */
  177200             : unsigned long
  177201           5 : SgMemberFunctionRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  177202             :    {
  177203           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  177204           5 :      SgMemberFunctionRefExp* pointer = NULL;
  177205           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  177206           5 :      std::vector < unsigned char* > :: const_iterator block;
  177207           6 :      for ( block = SgMemberFunctionRefExp::pools.begin(); block != SgMemberFunctionRefExp::pools.end() ; ++block )
  177208             :         {
  177209           1 :           pointer = (SgMemberFunctionRefExp*)(*block);
  177210        2001 :           for (unsigned i = 0; i < SgMemberFunctionRefExp::pool_size; ++i )
  177211             :              {
  177212             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  177213             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  177214             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  177215             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  177216             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  177217             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  177218             :             // properly; so this will have to be checked next.
  177219             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  177220             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  177221        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  177222             :                   {
  177223         540 :                     pointer[i].set_freepointer((SgMemberFunctionRefExp*)(globalIndex));
  177224         540 :                     globalIndex++;
  177225             :                   }
  177226             :                else
  177227             :                   {
  177228        1460 :                     pointer[i].set_freepointer(NULL);
  177229             :                   }
  177230             :               }
  177231             :         }
  177232           5 :      return globalIndex;
  177233             :    }
  177234             : 
  177235             : //############################################################################
  177236             : // JH (01/14/2006)
  177237             : void
  177238           5 : SgMemberFunctionRefExp::resetValidFreepointers( )
  177239             :    {
  177240           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  177241           5 :      SgMemberFunctionRefExp* pointer = NULL;
  177242           5 :      std::vector < unsigned char* > :: const_iterator block;
  177243           5 :      SgMemberFunctionRefExp* pointerOfLinkedList = NULL;
  177244           6 :      for ( block = SgMemberFunctionRefExp::pools.begin(); block != SgMemberFunctionRefExp::pools.end() ; ++block )
  177245             :         {
  177246           1 :           pointer = (SgMemberFunctionRefExp*)(*block);
  177247        2001 :           for (unsigned i = 0; i < SgMemberFunctionRefExp::pool_size; ++i )
  177248             :              {
  177249             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  177250             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  177251             :             // memory blocks!.
  177252        2000 :                if ( pointer[i].get_freepointer() != NULL )
  177253             :                   {
  177254         540 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  177255             :                   }
  177256             :                else
  177257             :                   {
  177258        1460 :                     if ( pointerOfLinkedList == NULL )
  177259             :                        {
  177260           1 :                          SgMemberFunctionRefExp::next_node = &(pointer[i]);
  177261             :                        }
  177262             :                     else
  177263             :                        {
  177264             :                       // printf ("In SgMemberFunctionRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  177265        1459 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  177266             :                        }
  177267             :                     pointerOfLinkedList = &(pointer[i]);
  177268             :                   }
  177269             :               }
  177270             :         }
  177271             : 
  177272           5 :      if ( pointerOfLinkedList != NULL )
  177273             :         {
  177274             :        // printf ("In SgMemberFunctionRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  177275           1 :           pointerOfLinkedList->set_freepointer(NULL);
  177276             :        // DQ (6/6/2010): Temporary debugging...
  177277             :        //   ROSE_ASSERT(false);
  177278             :         }
  177279             : 
  177280           5 :      return ;
  177281             :    }
  177282             : 
  177283             : //############################################################################
  177284             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  177285             :  * within the memory pool and resets the freepointers, in order to achieve a 
  177286             :  * linked list, that has no jumps and starts at the beginning! This function 
  177287             :  * does not extend the memory pool, since we do not delete any memory blocks,
  177288             :  * but delete the valid objects.  
  177289             :  */
  177290             : void
  177291           0 : SgMemberFunctionRefExp::clearMemoryPool( )
  177292             :    {
  177293             :   // printf ("Inside of SgMemberFunctionRefExp::clearMemoryPool() \n");
  177294             : 
  177295           0 :      SgMemberFunctionRefExp* pointer = NULL, *tempPointer = NULL;
  177296           0 :      std::vector < unsigned char* > :: const_iterator block;
  177297           0 :      if ( SgMemberFunctionRefExp::pools.empty() == false )
  177298             :         {
  177299           0 :           block = SgMemberFunctionRefExp::pools.begin() ;
  177300           0 :           SgMemberFunctionRefExp::next_node = (SgMemberFunctionRefExp*) (*block);
  177301             : 
  177302           0 :           while ( block != SgMemberFunctionRefExp::pools.end() )
  177303             :              {
  177304           0 :                pointer = (SgMemberFunctionRefExp*) (*block);
  177305           0 :                if ( tempPointer != NULL )
  177306             :                   {
  177307           0 :                     tempPointer->set_freepointer(pointer);
  177308             :                   }
  177309           0 :                for (unsigned i = 0; i < SgMemberFunctionRefExp::pool_size - 1; ++i)
  177310             :                   {
  177311           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  177312             :                   }
  177313           0 :                 pointer[SgMemberFunctionRefExp::pool_size-1].set_freepointer(NULL);
  177314           0 :                 tempPointer = &(pointer[SgMemberFunctionRefExp::pool_size-1]);
  177315           0 :                 ++block;
  177316             :              }
  177317             :         }
  177318           0 :    }
  177319             : 
  177320           5 : void SgMemberFunctionRefExp::deleteMemoryPool() {
  177321           7 :   for (auto p: SgMemberFunctionRefExp::pools) {
  177322           2 :     ROSE_FREE(p);
  177323             :   }
  177324           5 :   SgMemberFunctionRefExp::next_node = nullptr;
  177325           5 :   SgMemberFunctionRefExp::pools.clear();
  177326           5 : }
  177327             : 
  177328             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  177329             : //                 reading multiple binary files to for a single AST.
  177330             : /////////// new version ////////////////////////////////
  177331             : //############################################################################
  177332             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  177333             : void
  177334           2 : SgMemberFunctionRefExp::extendMemoryPoolForFileIO( )
  177335             :   {
  177336           2 :     size_t blockIndex = SgMemberFunctionRefExp::pools.size();
  177337           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionRefExp);
  177338             : 
  177339           3 :     while ( (blockIndex * SgMemberFunctionRefExp::pool_size) < newPoolSize)
  177340             :       {
  177341             : #if ROSE_ALLOC_TRACE
  177342             :         if (blockIndex > 0) {
  177343             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionRefExp) = %" PRIuPTR " SgMemberFunctionRefExp::pool_size = %d \n",
  177344             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionRefExp),SgMemberFunctionRefExp::pool_size);
  177345             :         }
  177346             : #endif
  177347             : 
  177348           1 :         SgMemberFunctionRefExp * pointer = (SgMemberFunctionRefExp*) ROSE_MALLOC ( SgMemberFunctionRefExp::pool_size * sizeof(SgMemberFunctionRefExp) );
  177349           1 :         assert( pointer != NULL );
  177350             : #if ROSE_ALLOC_MEMSET == 1
  177351             :         memset(pointer, 0x00, SgMemberFunctionRefExp::pool_size * sizeof(SgMemberFunctionRefExp));
  177352             : #elif ROSE_ALLOC_MEMSET == 2
  177353             :         memset(pointer, 0xCC, SgMemberFunctionRefExp::pool_size * sizeof(SgMemberFunctionRefExp));
  177354             : #endif
  177355           1 :         SgMemberFunctionRefExp::pools.push_back( (unsigned char*)(pointer) );
  177356           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMemberFunctionRefExp::pool_size * sizeof(SgMemberFunctionRefExp), V_SgMemberFunctionRefExp ) );
  177357             : 
  177358           1 :         if ( SgMemberFunctionRefExp::next_node != NULL ) {
  177359           0 :           if ( blockIndex > 0 ) {
  177360           0 :             SgMemberFunctionRefExp * blkptr = (SgMemberFunctionRefExp*)(SgMemberFunctionRefExp::pools[blockIndex-1]);
  177361           0 :             blkptr[ SgMemberFunctionRefExp::pool_size - 1 ].set_freepointer(pointer);
  177362             :           }
  177363             :         } else {
  177364           1 :           SgMemberFunctionRefExp::next_node = pointer;
  177365             :         }
  177366             : 
  177367        2000 :         for (unsigned i = 0; i < SgMemberFunctionRefExp::pool_size-1; ++i)
  177368             :            {
  177369        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  177370             :            }
  177371           1 :         pointer[ SgMemberFunctionRefExp::pool_size -1 ].set_freepointer(NULL);
  177372             : 
  177373           1 :         blockIndex++;
  177374             :       }
  177375           2 :   }
  177376             : 
  177377             : //############################################################################
  177378             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  177379             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  177380             :  * not compressed. However, that stuff is not yet implemented! 
  177381             :  */
  177382             : unsigned long
  177383           0 : SgMemberFunctionRefExp::getNumberOfLastValidPointer()
  177384             :    {
  177385           0 :       SgMemberFunctionRefExp* testPointer = (SgMemberFunctionRefExp*)(SgMemberFunctionRefExp::pools.back());
  177386           0 :       unsigned long localIndex = SgMemberFunctionRefExp::pool_size - 1;
  177387           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  177388             :          {
  177389           0 :            localIndex--;
  177390             :          }
  177391           0 :       return (localIndex + SgMemberFunctionRefExp::pool_size * (SgMemberFunctionRefExp::pools.size()-1));
  177392             :    }
  177393             : 
  177394             : //############################################################################
  177395             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  177396             :  * memory pool and initializes the data member in class SgMemberFunctionRefExpStroageClass
  177397             :  * from its counterpart of SgMemberFunctionRefExp. The return value is just for checking, 
  177398             :  * that the whole StorageClassArray is initialized!
  177399             :  */
  177400             : unsigned long
  177401           1 : SgMemberFunctionRefExp::initializeStorageClassArray( SgMemberFunctionRefExpStorageClass *storageArray )
  177402             :    {
  177403           1 :      unsigned long storageCounter = 0;
  177404           1 :      std::vector < unsigned char* > :: const_iterator block = SgMemberFunctionRefExp::pools.begin();
  177405           1 :      SgMemberFunctionRefExp* pointer = NULL;
  177406           2 :      while ( block != SgMemberFunctionRefExp::pools.end() ) {
  177407           1 :           pointer = (SgMemberFunctionRefExp*) (*block);
  177408        2001 :           for ( unsigned i = 0; i < SgMemberFunctionRefExp::pool_size; ++i ) {
  177409        2000 :                if ( pointer->get_freepointer() != NULL ) {
  177410         540 :                  storageArray->pickOutIRNodeData (pointer) ;
  177411         540 :                  storageArray++;
  177412         540 :                  storageCounter++;
  177413             :                }
  177414        2000 :                pointer++;
  177415             :              }
  177416           1 :            block++;
  177417             :         }
  177418           1 :      return storageCounter;
  177419             :    }
  177420             : 
  177421             : /* #line 177422 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  177422             : 
  177423             : 
  177424             : 
  177425             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  177426             : 
  177427             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  177428             : 
  177429             : //############################################################################
  177430             : /* JH (02/02/2006) Constructor of the IR node SgValueExp that takes its 
  177431             :  * corresponding StorageClass as parameter
  177432             :  */
  177433        2050 : SgValueExp :: SgValueExp ( const SgValueExpStorageClass& storageSource )   : SgExpression (storageSource)
  177434             :    {
  177435             : 
  177436             : 
  177437             : /* #line 177438 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  177438             : 
  177439        2050 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  177440        2050 :      p_originalExpressionTree =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_originalExpressionTree) );
  177441             : 
  177442             : 
  177443             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  177444             : 
  177445             : 
  177446        2050 :    }
  177447             : 
  177448             : //############################################################################
  177449             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  177450             :  * within the working AST. 
  177451             :  */
  177452           0 : SgValueExp * SgValueExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  177453           0 :      SgValueExp* returnPointer = NULL;
  177454           0 :      if ( globalIndex != 0 )
  177455             :         {
  177456             : 
  177457             : #if FILE_IO_EXTRA_CHECK
  177458           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgValueExp ) ) <= globalIndex ) ;
  177459           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgValueExp + 1 ) ) );
  177460             : #endif
  177461           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgValueExp )  
  177462           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgValueExp );
  177463           0 :           unsigned long positionInPool = localIndex % SgValueExp::pool_size;
  177464           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgValueExp::pool_size;
  177465             : 
  177466             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  177467             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  177468             : 
  177469           0 :           returnPointer = &( ( (SgValueExp*)(SgValueExp::pools[memoryBlock]) ) [positionInPool]) ;
  177470             : 
  177471           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  177472             :         }
  177473           0 :      return returnPointer ;
  177474             :    }
  177475             : 
  177476             : //############################################################################
  177477             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  177478             :   for the AST with the index astIndex
  177479             : */
  177480           0 : SgValueExp * SgValueExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  177481           0 :      SgValueExp* returnPointer = NULL;
  177482           0 :      if ( globalIndex != 0 )
  177483             :         {
  177484             : 
  177485             : #if FILE_IO_EXTRA_CHECK
  177486           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgValueExp ) ) <= globalIndex ) ;
  177487           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgValueExp + 1 ) ) );
  177488             : #endif
  177489           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgValueExp )
  177490           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgValueExp );
  177491           0 :           unsigned long positionInPool = localIndex % SgValueExp::pool_size ;
  177492           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgValueExp::pool_size ;
  177493             : 
  177494             : #if FILE_IO_EXTRA_CHECK
  177495             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  177496             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  177497             : #endif
  177498             : 
  177499           0 :           returnPointer = &( ( (SgValueExp*)(SgValueExp::pools[memoryBlock]) ) [positionInPool]) ;
  177500             : 
  177501             : #if FILE_IO_EXTRA_CHECK
  177502           0 :           assert ( returnPointer != NULL ) ;
  177503             : #endif
  177504             :         }
  177505           0 :      return returnPointer ;
  177506             :    }
  177507             : 
  177508             : //############################################################################
  177509             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  177510             :  * pool size! We set for every valid object in the memory pool the freepointer
  177511             :  * to the global index and increase the global index afterwards. For all the 
  177512             :  * invalid objects (means address ranges within the memory pool that were not
  177513             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  177514             :  * distinguish valid from invalid objects! 
  177515             :  */
  177516             : unsigned long
  177517           5 : SgValueExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  177518             :    {
  177519           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  177520           5 :      SgValueExp* pointer = NULL;
  177521           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  177522           5 :      std::vector < unsigned char* > :: const_iterator block;
  177523           5 :      for ( block = SgValueExp::pools.begin(); block != SgValueExp::pools.end() ; ++block )
  177524             :         {
  177525           0 :           pointer = (SgValueExp*)(*block);
  177526           0 :           for (unsigned i = 0; i < SgValueExp::pool_size; ++i )
  177527             :              {
  177528             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  177529             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  177530             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  177531             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  177532             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  177533             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  177534             :             // properly; so this will have to be checked next.
  177535             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  177536             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  177537           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  177538             :                   {
  177539           0 :                     pointer[i].set_freepointer((SgValueExp*)(globalIndex));
  177540           0 :                     globalIndex++;
  177541             :                   }
  177542             :                else
  177543             :                   {
  177544           0 :                     pointer[i].set_freepointer(NULL);
  177545             :                   }
  177546             :               }
  177547             :         }
  177548           5 :      return globalIndex;
  177549             :    }
  177550             : 
  177551             : //############################################################################
  177552             : // JH (01/14/2006)
  177553             : void
  177554           5 : SgValueExp::resetValidFreepointers( )
  177555             :    {
  177556           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  177557           5 :      SgValueExp* pointer = NULL;
  177558           5 :      std::vector < unsigned char* > :: const_iterator block;
  177559           5 :      SgValueExp* pointerOfLinkedList = NULL;
  177560           5 :      for ( block = SgValueExp::pools.begin(); block != SgValueExp::pools.end() ; ++block )
  177561             :         {
  177562           0 :           pointer = (SgValueExp*)(*block);
  177563           0 :           for (unsigned i = 0; i < SgValueExp::pool_size; ++i )
  177564             :              {
  177565             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  177566             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  177567             :             // memory blocks!.
  177568           0 :                if ( pointer[i].get_freepointer() != NULL )
  177569             :                   {
  177570           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  177571             :                   }
  177572             :                else
  177573             :                   {
  177574           0 :                     if ( pointerOfLinkedList == NULL )
  177575             :                        {
  177576           0 :                          SgValueExp::next_node = &(pointer[i]);
  177577             :                        }
  177578             :                     else
  177579             :                        {
  177580             :                       // printf ("In SgValueExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  177581           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  177582             :                        }
  177583             :                     pointerOfLinkedList = &(pointer[i]);
  177584             :                   }
  177585             :               }
  177586             :         }
  177587             : 
  177588           5 :      if ( pointerOfLinkedList != NULL )
  177589             :         {
  177590             :        // printf ("In SgValueExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  177591           0 :           pointerOfLinkedList->set_freepointer(NULL);
  177592             :        // DQ (6/6/2010): Temporary debugging...
  177593             :        //   ROSE_ASSERT(false);
  177594             :         }
  177595             : 
  177596           5 :      return ;
  177597             :    }
  177598             : 
  177599             : //############################################################################
  177600             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  177601             :  * within the memory pool and resets the freepointers, in order to achieve a 
  177602             :  * linked list, that has no jumps and starts at the beginning! This function 
  177603             :  * does not extend the memory pool, since we do not delete any memory blocks,
  177604             :  * but delete the valid objects.  
  177605             :  */
  177606             : void
  177607           0 : SgValueExp::clearMemoryPool( )
  177608             :    {
  177609             :   // printf ("Inside of SgValueExp::clearMemoryPool() \n");
  177610             : 
  177611           0 :      SgValueExp* pointer = NULL, *tempPointer = NULL;
  177612           0 :      std::vector < unsigned char* > :: const_iterator block;
  177613           0 :      if ( SgValueExp::pools.empty() == false )
  177614             :         {
  177615           0 :           block = SgValueExp::pools.begin() ;
  177616           0 :           SgValueExp::next_node = (SgValueExp*) (*block);
  177617             : 
  177618           0 :           while ( block != SgValueExp::pools.end() )
  177619             :              {
  177620           0 :                pointer = (SgValueExp*) (*block);
  177621           0 :                if ( tempPointer != NULL )
  177622             :                   {
  177623           0 :                     tempPointer->set_freepointer(pointer);
  177624             :                   }
  177625           0 :                for (unsigned i = 0; i < SgValueExp::pool_size - 1; ++i)
  177626             :                   {
  177627           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  177628             :                   }
  177629           0 :                 pointer[SgValueExp::pool_size-1].set_freepointer(NULL);
  177630           0 :                 tempPointer = &(pointer[SgValueExp::pool_size-1]);
  177631           0 :                 ++block;
  177632             :              }
  177633             :         }
  177634           0 :    }
  177635             : 
  177636           5 : void SgValueExp::deleteMemoryPool() {
  177637           5 :   for (auto p: SgValueExp::pools) {
  177638           0 :     ROSE_FREE(p);
  177639             :   }
  177640           5 :   SgValueExp::next_node = nullptr;
  177641           5 :   SgValueExp::pools.clear();
  177642           5 : }
  177643             : 
  177644             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  177645             : //                 reading multiple binary files to for a single AST.
  177646             : /////////// new version ////////////////////////////////
  177647             : //############################################################################
  177648             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  177649             : void
  177650           2 : SgValueExp::extendMemoryPoolForFileIO( )
  177651             :   {
  177652           2 :     size_t blockIndex = SgValueExp::pools.size();
  177653           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgValueExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgValueExp);
  177654             : 
  177655           2 :     while ( (blockIndex * SgValueExp::pool_size) < newPoolSize)
  177656             :       {
  177657             : #if ROSE_ALLOC_TRACE
  177658             :         if (blockIndex > 0) {
  177659             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgValueExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgValueExp) = %" PRIuPTR " SgValueExp::pool_size = %d \n",
  177660             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgValueExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgValueExp),SgValueExp::pool_size);
  177661             :         }
  177662             : #endif
  177663             : 
  177664           0 :         SgValueExp * pointer = (SgValueExp*) ROSE_MALLOC ( SgValueExp::pool_size * sizeof(SgValueExp) );
  177665           0 :         assert( pointer != NULL );
  177666             : #if ROSE_ALLOC_MEMSET == 1
  177667             :         memset(pointer, 0x00, SgValueExp::pool_size * sizeof(SgValueExp));
  177668             : #elif ROSE_ALLOC_MEMSET == 2
  177669             :         memset(pointer, 0xCC, SgValueExp::pool_size * sizeof(SgValueExp));
  177670             : #endif
  177671           0 :         SgValueExp::pools.push_back( (unsigned char*)(pointer) );
  177672           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgValueExp::pool_size * sizeof(SgValueExp), V_SgValueExp ) );
  177673             : 
  177674           0 :         if ( SgValueExp::next_node != NULL ) {
  177675           0 :           if ( blockIndex > 0 ) {
  177676           0 :             SgValueExp * blkptr = (SgValueExp*)(SgValueExp::pools[blockIndex-1]);
  177677           0 :             blkptr[ SgValueExp::pool_size - 1 ].set_freepointer(pointer);
  177678             :           }
  177679             :         } else {
  177680           0 :           SgValueExp::next_node = pointer;
  177681             :         }
  177682             : 
  177683           0 :         for (unsigned i = 0; i < SgValueExp::pool_size-1; ++i)
  177684             :            {
  177685           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  177686             :            }
  177687           0 :         pointer[ SgValueExp::pool_size -1 ].set_freepointer(NULL);
  177688             : 
  177689           0 :         blockIndex++;
  177690             :       }
  177691           2 :   }
  177692             : 
  177693             : //############################################################################
  177694             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  177695             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  177696             :  * not compressed. However, that stuff is not yet implemented! 
  177697             :  */
  177698             : unsigned long
  177699           0 : SgValueExp::getNumberOfLastValidPointer()
  177700             :    {
  177701           0 :       SgValueExp* testPointer = (SgValueExp*)(SgValueExp::pools.back());
  177702           0 :       unsigned long localIndex = SgValueExp::pool_size - 1;
  177703           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  177704             :          {
  177705           0 :            localIndex--;
  177706             :          }
  177707           0 :       return (localIndex + SgValueExp::pool_size * (SgValueExp::pools.size()-1));
  177708             :    }
  177709             : 
  177710             : //############################################################################
  177711             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  177712             :  * memory pool and initializes the data member in class SgValueExpStroageClass
  177713             :  * from its counterpart of SgValueExp. The return value is just for checking, 
  177714             :  * that the whole StorageClassArray is initialized!
  177715             :  */
  177716             : unsigned long
  177717           0 : SgValueExp::initializeStorageClassArray( SgValueExpStorageClass *storageArray )
  177718             :    {
  177719           0 :      unsigned long storageCounter = 0;
  177720           0 :      std::vector < unsigned char* > :: const_iterator block = SgValueExp::pools.begin();
  177721           0 :      SgValueExp* pointer = NULL;
  177722           0 :      while ( block != SgValueExp::pools.end() ) {
  177723           0 :           pointer = (SgValueExp*) (*block);
  177724           0 :           for ( unsigned i = 0; i < SgValueExp::pool_size; ++i ) {
  177725           0 :                if ( pointer->get_freepointer() != NULL ) {
  177726           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  177727           0 :                  storageArray++;
  177728           0 :                  storageCounter++;
  177729             :                }
  177730           0 :                pointer++;
  177731             :              }
  177732           0 :            block++;
  177733             :         }
  177734           0 :      return storageCounter;
  177735             :    }
  177736             : 
  177737             : /* #line 177738 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  177738             : 
  177739             : 
  177740             : 
  177741             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  177742             : 
  177743             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  177744             : 
  177745             : //############################################################################
  177746             : /* JH (02/02/2006) Constructor of the IR node SgBoolValExp that takes its 
  177747             :  * corresponding StorageClass as parameter
  177748             :  */
  177749         398 : SgBoolValExp :: SgBoolValExp ( const SgBoolValExpStorageClass& storageSource )   : SgValueExp (storageSource)
  177750             :    {
  177751             : 
  177752             : 
  177753             : /* #line 177754 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  177754             : 
  177755         398 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  177756         398 :      p_value = storageSource.storageOf_value ;
  177757             : 
  177758             : 
  177759             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  177760             : 
  177761             : 
  177762         398 :    }
  177763             : 
  177764             : //############################################################################
  177765             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  177766             :  * within the working AST. 
  177767             :  */
  177768        1684 : SgBoolValExp * SgBoolValExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  177769        1684 :      SgBoolValExp* returnPointer = NULL;
  177770        1684 :      if ( globalIndex != 0 )
  177771             :         {
  177772             : 
  177773             : #if FILE_IO_EXTRA_CHECK
  177774        1684 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBoolValExp ) ) <= globalIndex ) ;
  177775        1684 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBoolValExp + 1 ) ) );
  177776             : #endif
  177777        1684 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBoolValExp )  
  177778        1684 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBoolValExp );
  177779        1684 :           unsigned long positionInPool = localIndex % SgBoolValExp::pool_size;
  177780        1684 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBoolValExp::pool_size;
  177781             : 
  177782             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  177783             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  177784             : 
  177785        1684 :           returnPointer = &( ( (SgBoolValExp*)(SgBoolValExp::pools[memoryBlock]) ) [positionInPool]) ;
  177786             : 
  177787        1684 :           ROSE_ASSERT( returnPointer != NULL ) ;
  177788             :         }
  177789        1684 :      return returnPointer ;
  177790             :    }
  177791             : 
  177792             : //############################################################################
  177793             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  177794             :   for the AST with the index astIndex
  177795             : */
  177796           0 : SgBoolValExp * SgBoolValExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  177797           0 :      SgBoolValExp* returnPointer = NULL;
  177798           0 :      if ( globalIndex != 0 )
  177799             :         {
  177800             : 
  177801             : #if FILE_IO_EXTRA_CHECK
  177802           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBoolValExp ) ) <= globalIndex ) ;
  177803           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBoolValExp + 1 ) ) );
  177804             : #endif
  177805           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBoolValExp )
  177806           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBoolValExp );
  177807           0 :           unsigned long positionInPool = localIndex % SgBoolValExp::pool_size ;
  177808           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBoolValExp::pool_size ;
  177809             : 
  177810             : #if FILE_IO_EXTRA_CHECK
  177811             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  177812             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  177813             : #endif
  177814             : 
  177815           0 :           returnPointer = &( ( (SgBoolValExp*)(SgBoolValExp::pools[memoryBlock]) ) [positionInPool]) ;
  177816             : 
  177817             : #if FILE_IO_EXTRA_CHECK
  177818           0 :           assert ( returnPointer != NULL ) ;
  177819             : #endif
  177820             :         }
  177821           0 :      return returnPointer ;
  177822             :    }
  177823             : 
  177824             : //############################################################################
  177825             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  177826             :  * pool size! We set for every valid object in the memory pool the freepointer
  177827             :  * to the global index and increase the global index afterwards. For all the 
  177828             :  * invalid objects (means address ranges within the memory pool that were not
  177829             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  177830             :  * distinguish valid from invalid objects! 
  177831             :  */
  177832             : unsigned long
  177833           5 : SgBoolValExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  177834             :    {
  177835           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  177836           5 :      SgBoolValExp* pointer = NULL;
  177837           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  177838           5 :      std::vector < unsigned char* > :: const_iterator block;
  177839           6 :      for ( block = SgBoolValExp::pools.begin(); block != SgBoolValExp::pools.end() ; ++block )
  177840             :         {
  177841           1 :           pointer = (SgBoolValExp*)(*block);
  177842        2001 :           for (unsigned i = 0; i < SgBoolValExp::pool_size; ++i )
  177843             :              {
  177844             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  177845             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  177846             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  177847             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  177848             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  177849             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  177850             :             // properly; so this will have to be checked next.
  177851             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  177852             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  177853        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  177854             :                   {
  177855         398 :                     pointer[i].set_freepointer((SgBoolValExp*)(globalIndex));
  177856         398 :                     globalIndex++;
  177857             :                   }
  177858             :                else
  177859             :                   {
  177860        1602 :                     pointer[i].set_freepointer(NULL);
  177861             :                   }
  177862             :               }
  177863             :         }
  177864           5 :      return globalIndex;
  177865             :    }
  177866             : 
  177867             : //############################################################################
  177868             : // JH (01/14/2006)
  177869             : void
  177870           5 : SgBoolValExp::resetValidFreepointers( )
  177871             :    {
  177872           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  177873           5 :      SgBoolValExp* pointer = NULL;
  177874           5 :      std::vector < unsigned char* > :: const_iterator block;
  177875           5 :      SgBoolValExp* pointerOfLinkedList = NULL;
  177876           6 :      for ( block = SgBoolValExp::pools.begin(); block != SgBoolValExp::pools.end() ; ++block )
  177877             :         {
  177878           1 :           pointer = (SgBoolValExp*)(*block);
  177879        2001 :           for (unsigned i = 0; i < SgBoolValExp::pool_size; ++i )
  177880             :              {
  177881             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  177882             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  177883             :             // memory blocks!.
  177884        2000 :                if ( pointer[i].get_freepointer() != NULL )
  177885             :                   {
  177886         398 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  177887             :                   }
  177888             :                else
  177889             :                   {
  177890        1602 :                     if ( pointerOfLinkedList == NULL )
  177891             :                        {
  177892           1 :                          SgBoolValExp::next_node = &(pointer[i]);
  177893             :                        }
  177894             :                     else
  177895             :                        {
  177896             :                       // printf ("In SgBoolValExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  177897        1601 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  177898             :                        }
  177899             :                     pointerOfLinkedList = &(pointer[i]);
  177900             :                   }
  177901             :               }
  177902             :         }
  177903             : 
  177904           5 :      if ( pointerOfLinkedList != NULL )
  177905             :         {
  177906             :        // printf ("In SgBoolValExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  177907           1 :           pointerOfLinkedList->set_freepointer(NULL);
  177908             :        // DQ (6/6/2010): Temporary debugging...
  177909             :        //   ROSE_ASSERT(false);
  177910             :         }
  177911             : 
  177912           5 :      return ;
  177913             :    }
  177914             : 
  177915             : //############################################################################
  177916             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  177917             :  * within the memory pool and resets the freepointers, in order to achieve a 
  177918             :  * linked list, that has no jumps and starts at the beginning! This function 
  177919             :  * does not extend the memory pool, since we do not delete any memory blocks,
  177920             :  * but delete the valid objects.  
  177921             :  */
  177922             : void
  177923           0 : SgBoolValExp::clearMemoryPool( )
  177924             :    {
  177925             :   // printf ("Inside of SgBoolValExp::clearMemoryPool() \n");
  177926             : 
  177927           0 :      SgBoolValExp* pointer = NULL, *tempPointer = NULL;
  177928           0 :      std::vector < unsigned char* > :: const_iterator block;
  177929           0 :      if ( SgBoolValExp::pools.empty() == false )
  177930             :         {
  177931           0 :           block = SgBoolValExp::pools.begin() ;
  177932           0 :           SgBoolValExp::next_node = (SgBoolValExp*) (*block);
  177933             : 
  177934           0 :           while ( block != SgBoolValExp::pools.end() )
  177935             :              {
  177936           0 :                pointer = (SgBoolValExp*) (*block);
  177937           0 :                if ( tempPointer != NULL )
  177938             :                   {
  177939           0 :                     tempPointer->set_freepointer(pointer);
  177940             :                   }
  177941           0 :                for (unsigned i = 0; i < SgBoolValExp::pool_size - 1; ++i)
  177942             :                   {
  177943           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  177944             :                   }
  177945           0 :                 pointer[SgBoolValExp::pool_size-1].set_freepointer(NULL);
  177946           0 :                 tempPointer = &(pointer[SgBoolValExp::pool_size-1]);
  177947           0 :                 ++block;
  177948             :              }
  177949             :         }
  177950           0 :    }
  177951             : 
  177952           5 : void SgBoolValExp::deleteMemoryPool() {
  177953           7 :   for (auto p: SgBoolValExp::pools) {
  177954           2 :     ROSE_FREE(p);
  177955             :   }
  177956           5 :   SgBoolValExp::next_node = nullptr;
  177957           5 :   SgBoolValExp::pools.clear();
  177958           5 : }
  177959             : 
  177960             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  177961             : //                 reading multiple binary files to for a single AST.
  177962             : /////////// new version ////////////////////////////////
  177963             : //############################################################################
  177964             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  177965             : void
  177966           2 : SgBoolValExp::extendMemoryPoolForFileIO( )
  177967             :   {
  177968           2 :     size_t blockIndex = SgBoolValExp::pools.size();
  177969           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBoolValExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBoolValExp);
  177970             : 
  177971           3 :     while ( (blockIndex * SgBoolValExp::pool_size) < newPoolSize)
  177972             :       {
  177973             : #if ROSE_ALLOC_TRACE
  177974             :         if (blockIndex > 0) {
  177975             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBoolValExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBoolValExp) = %" PRIuPTR " SgBoolValExp::pool_size = %d \n",
  177976             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBoolValExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBoolValExp),SgBoolValExp::pool_size);
  177977             :         }
  177978             : #endif
  177979             : 
  177980           1 :         SgBoolValExp * pointer = (SgBoolValExp*) ROSE_MALLOC ( SgBoolValExp::pool_size * sizeof(SgBoolValExp) );
  177981           1 :         assert( pointer != NULL );
  177982             : #if ROSE_ALLOC_MEMSET == 1
  177983             :         memset(pointer, 0x00, SgBoolValExp::pool_size * sizeof(SgBoolValExp));
  177984             : #elif ROSE_ALLOC_MEMSET == 2
  177985             :         memset(pointer, 0xCC, SgBoolValExp::pool_size * sizeof(SgBoolValExp));
  177986             : #endif
  177987           1 :         SgBoolValExp::pools.push_back( (unsigned char*)(pointer) );
  177988           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBoolValExp::pool_size * sizeof(SgBoolValExp), V_SgBoolValExp ) );
  177989             : 
  177990           1 :         if ( SgBoolValExp::next_node != NULL ) {
  177991           0 :           if ( blockIndex > 0 ) {
  177992           0 :             SgBoolValExp * blkptr = (SgBoolValExp*)(SgBoolValExp::pools[blockIndex-1]);
  177993           0 :             blkptr[ SgBoolValExp::pool_size - 1 ].set_freepointer(pointer);
  177994             :           }
  177995             :         } else {
  177996           1 :           SgBoolValExp::next_node = pointer;
  177997             :         }
  177998             : 
  177999        2000 :         for (unsigned i = 0; i < SgBoolValExp::pool_size-1; ++i)
  178000             :            {
  178001        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  178002             :            }
  178003           1 :         pointer[ SgBoolValExp::pool_size -1 ].set_freepointer(NULL);
  178004             : 
  178005           1 :         blockIndex++;
  178006             :       }
  178007           2 :   }
  178008             : 
  178009             : //############################################################################
  178010             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  178011             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  178012             :  * not compressed. However, that stuff is not yet implemented! 
  178013             :  */
  178014             : unsigned long
  178015           0 : SgBoolValExp::getNumberOfLastValidPointer()
  178016             :    {
  178017           0 :       SgBoolValExp* testPointer = (SgBoolValExp*)(SgBoolValExp::pools.back());
  178018           0 :       unsigned long localIndex = SgBoolValExp::pool_size - 1;
  178019           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  178020             :          {
  178021           0 :            localIndex--;
  178022             :          }
  178023           0 :       return (localIndex + SgBoolValExp::pool_size * (SgBoolValExp::pools.size()-1));
  178024             :    }
  178025             : 
  178026             : //############################################################################
  178027             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  178028             :  * memory pool and initializes the data member in class SgBoolValExpStroageClass
  178029             :  * from its counterpart of SgBoolValExp. The return value is just for checking, 
  178030             :  * that the whole StorageClassArray is initialized!
  178031             :  */
  178032             : unsigned long
  178033           1 : SgBoolValExp::initializeStorageClassArray( SgBoolValExpStorageClass *storageArray )
  178034             :    {
  178035           1 :      unsigned long storageCounter = 0;
  178036           1 :      std::vector < unsigned char* > :: const_iterator block = SgBoolValExp::pools.begin();
  178037           1 :      SgBoolValExp* pointer = NULL;
  178038           2 :      while ( block != SgBoolValExp::pools.end() ) {
  178039           1 :           pointer = (SgBoolValExp*) (*block);
  178040        2001 :           for ( unsigned i = 0; i < SgBoolValExp::pool_size; ++i ) {
  178041        2000 :                if ( pointer->get_freepointer() != NULL ) {
  178042         398 :                  storageArray->pickOutIRNodeData (pointer) ;
  178043         398 :                  storageArray++;
  178044         398 :                  storageCounter++;
  178045             :                }
  178046        2000 :                pointer++;
  178047             :              }
  178048           1 :            block++;
  178049             :         }
  178050           1 :      return storageCounter;
  178051             :    }
  178052             : 
  178053             : /* #line 178054 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  178054             : 
  178055             : 
  178056             : 
  178057             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  178058             : 
  178059             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  178060             : 
  178061             : //############################################################################
  178062             : /* JH (02/02/2006) Constructor of the IR node SgStringVal that takes its 
  178063             :  * corresponding StorageClass as parameter
  178064             :  */
  178065          82 : SgStringVal :: SgStringVal ( const SgStringValStorageClass& storageSource )   : SgValueExp (storageSource)
  178066             :    {
  178067             : 
  178068             : 
  178069             : /* #line 178070 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  178070             : 
  178071          82 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  178072          82 :      p_value = storageSource.storageOf_value.rebuildDataStoredInEasyStorageClass() ;
  178073          82 :      p_wcharString = storageSource.storageOf_wcharString ;
  178074          82 :      p_stringDelimiter = storageSource.storageOf_stringDelimiter ;
  178075          82 :      p_is16bitString = storageSource.storageOf_is16bitString ;
  178076          82 :      p_is32bitString = storageSource.storageOf_is32bitString ;
  178077          82 :      p_isRawString = storageSource.storageOf_isRawString ;
  178078          82 :      p_raw_string_value = storageSource.storageOf_raw_string_value.rebuildDataStoredInEasyStorageClass() ;
  178079             : 
  178080             : 
  178081             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  178082             : 
  178083             : 
  178084          82 :    }
  178085             : 
  178086             : //############################################################################
  178087             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  178088             :  * within the working AST. 
  178089             :  */
  178090         328 : SgStringVal * SgStringVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  178091         328 :      SgStringVal* returnPointer = NULL;
  178092         328 :      if ( globalIndex != 0 )
  178093             :         {
  178094             : 
  178095             : #if FILE_IO_EXTRA_CHECK
  178096         328 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStringVal ) ) <= globalIndex ) ;
  178097         328 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStringVal + 1 ) ) );
  178098             : #endif
  178099         328 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStringVal )  
  178100         328 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStringVal );
  178101         328 :           unsigned long positionInPool = localIndex % SgStringVal::pool_size;
  178102         328 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStringVal::pool_size;
  178103             : 
  178104             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  178105             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  178106             : 
  178107         328 :           returnPointer = &( ( (SgStringVal*)(SgStringVal::pools[memoryBlock]) ) [positionInPool]) ;
  178108             : 
  178109         328 :           ROSE_ASSERT( returnPointer != NULL ) ;
  178110             :         }
  178111         328 :      return returnPointer ;
  178112             :    }
  178113             : 
  178114             : //############################################################################
  178115             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  178116             :   for the AST with the index astIndex
  178117             : */
  178118           0 : SgStringVal * SgStringVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  178119           0 :      SgStringVal* returnPointer = NULL;
  178120           0 :      if ( globalIndex != 0 )
  178121             :         {
  178122             : 
  178123             : #if FILE_IO_EXTRA_CHECK
  178124           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStringVal ) ) <= globalIndex ) ;
  178125           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStringVal + 1 ) ) );
  178126             : #endif
  178127           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStringVal )
  178128           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStringVal );
  178129           0 :           unsigned long positionInPool = localIndex % SgStringVal::pool_size ;
  178130           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStringVal::pool_size ;
  178131             : 
  178132             : #if FILE_IO_EXTRA_CHECK
  178133             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  178134             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  178135             : #endif
  178136             : 
  178137           0 :           returnPointer = &( ( (SgStringVal*)(SgStringVal::pools[memoryBlock]) ) [positionInPool]) ;
  178138             : 
  178139             : #if FILE_IO_EXTRA_CHECK
  178140           0 :           assert ( returnPointer != NULL ) ;
  178141             : #endif
  178142             :         }
  178143           0 :      return returnPointer ;
  178144             :    }
  178145             : 
  178146             : //############################################################################
  178147             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  178148             :  * pool size! We set for every valid object in the memory pool the freepointer
  178149             :  * to the global index and increase the global index afterwards. For all the 
  178150             :  * invalid objects (means address ranges within the memory pool that were not
  178151             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  178152             :  * distinguish valid from invalid objects! 
  178153             :  */
  178154             : unsigned long
  178155           5 : SgStringVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  178156             :    {
  178157           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  178158           5 :      SgStringVal* pointer = NULL;
  178159           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  178160           5 :      std::vector < unsigned char* > :: const_iterator block;
  178161           8 :      for ( block = SgStringVal::pools.begin(); block != SgStringVal::pools.end() ; ++block )
  178162             :         {
  178163           3 :           pointer = (SgStringVal*)(*block);
  178164        6003 :           for (unsigned i = 0; i < SgStringVal::pool_size; ++i )
  178165             :              {
  178166             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  178167             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  178168             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  178169             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  178170             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  178171             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  178172             :             // properly; so this will have to be checked next.
  178173             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  178174             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  178175        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  178176             :                   {
  178177          83 :                     pointer[i].set_freepointer((SgStringVal*)(globalIndex));
  178178          83 :                     globalIndex++;
  178179             :                   }
  178180             :                else
  178181             :                   {
  178182        5917 :                     pointer[i].set_freepointer(NULL);
  178183             :                   }
  178184             :               }
  178185             :         }
  178186           5 :      return globalIndex;
  178187             :    }
  178188             : 
  178189             : //############################################################################
  178190             : // JH (01/14/2006)
  178191             : void
  178192           5 : SgStringVal::resetValidFreepointers( )
  178193             :    {
  178194           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  178195           5 :      SgStringVal* pointer = NULL;
  178196           5 :      std::vector < unsigned char* > :: const_iterator block;
  178197           5 :      SgStringVal* pointerOfLinkedList = NULL;
  178198           8 :      for ( block = SgStringVal::pools.begin(); block != SgStringVal::pools.end() ; ++block )
  178199             :         {
  178200           3 :           pointer = (SgStringVal*)(*block);
  178201        6003 :           for (unsigned i = 0; i < SgStringVal::pool_size; ++i )
  178202             :              {
  178203             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  178204             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  178205             :             // memory blocks!.
  178206        6000 :                if ( pointer[i].get_freepointer() != NULL )
  178207             :                   {
  178208          83 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  178209             :                   }
  178210             :                else
  178211             :                   {
  178212        5917 :                     if ( pointerOfLinkedList == NULL )
  178213             :                        {
  178214           3 :                          SgStringVal::next_node = &(pointer[i]);
  178215             :                        }
  178216             :                     else
  178217             :                        {
  178218             :                       // printf ("In SgStringVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  178219        5914 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  178220             :                        }
  178221             :                     pointerOfLinkedList = &(pointer[i]);
  178222             :                   }
  178223             :               }
  178224             :         }
  178225             : 
  178226           5 :      if ( pointerOfLinkedList != NULL )
  178227             :         {
  178228             :        // printf ("In SgStringVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  178229           3 :           pointerOfLinkedList->set_freepointer(NULL);
  178230             :        // DQ (6/6/2010): Temporary debugging...
  178231             :        //   ROSE_ASSERT(false);
  178232             :         }
  178233             : 
  178234           5 :      return ;
  178235             :    }
  178236             : 
  178237             : //############################################################################
  178238             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  178239             :  * within the memory pool and resets the freepointers, in order to achieve a 
  178240             :  * linked list, that has no jumps and starts at the beginning! This function 
  178241             :  * does not extend the memory pool, since we do not delete any memory blocks,
  178242             :  * but delete the valid objects.  
  178243             :  */
  178244             : void
  178245           0 : SgStringVal::clearMemoryPool( )
  178246             :    {
  178247             :   // printf ("Inside of SgStringVal::clearMemoryPool() \n");
  178248             : 
  178249           0 :      SgStringVal* pointer = NULL, *tempPointer = NULL;
  178250           0 :      std::vector < unsigned char* > :: const_iterator block;
  178251           0 :      if ( SgStringVal::pools.empty() == false )
  178252             :         {
  178253           0 :           block = SgStringVal::pools.begin() ;
  178254           0 :           SgStringVal::next_node = (SgStringVal*) (*block);
  178255             : 
  178256           0 :           while ( block != SgStringVal::pools.end() )
  178257             :              {
  178258           0 :                pointer = (SgStringVal*) (*block);
  178259           0 :                if ( tempPointer != NULL )
  178260             :                   {
  178261           0 :                     tempPointer->set_freepointer(pointer);
  178262             :                   }
  178263           0 :                for (unsigned i = 0; i < SgStringVal::pool_size - 1; ++i)
  178264             :                   {
  178265           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  178266             :                   }
  178267           0 :                 pointer[SgStringVal::pool_size-1].set_freepointer(NULL);
  178268           0 :                 tempPointer = &(pointer[SgStringVal::pool_size-1]);
  178269           0 :                 ++block;
  178270             :              }
  178271             :         }
  178272           0 :    }
  178273             : 
  178274           5 : void SgStringVal::deleteMemoryPool() {
  178275          10 :   for (auto p: SgStringVal::pools) {
  178276           5 :     ROSE_FREE(p);
  178277             :   }
  178278           5 :   SgStringVal::next_node = nullptr;
  178279           5 :   SgStringVal::pools.clear();
  178280           5 : }
  178281             : 
  178282             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  178283             : //                 reading multiple binary files to for a single AST.
  178284             : /////////// new version ////////////////////////////////
  178285             : //############################################################################
  178286             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  178287             : void
  178288           2 : SgStringVal::extendMemoryPoolForFileIO( )
  178289             :   {
  178290           2 :     size_t blockIndex = SgStringVal::pools.size();
  178291           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStringVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringVal);
  178292             : 
  178293           4 :     while ( (blockIndex * SgStringVal::pool_size) < newPoolSize)
  178294             :       {
  178295             : #if ROSE_ALLOC_TRACE
  178296             :         if (blockIndex > 0) {
  178297             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStringVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringVal) = %" PRIuPTR " SgStringVal::pool_size = %d \n",
  178298             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStringVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringVal),SgStringVal::pool_size);
  178299             :         }
  178300             : #endif
  178301             : 
  178302           2 :         SgStringVal * pointer = (SgStringVal*) ROSE_MALLOC ( SgStringVal::pool_size * sizeof(SgStringVal) );
  178303           2 :         assert( pointer != NULL );
  178304             : #if ROSE_ALLOC_MEMSET == 1
  178305             :         memset(pointer, 0x00, SgStringVal::pool_size * sizeof(SgStringVal));
  178306             : #elif ROSE_ALLOC_MEMSET == 2
  178307             :         memset(pointer, 0xCC, SgStringVal::pool_size * sizeof(SgStringVal));
  178308             : #endif
  178309           2 :         SgStringVal::pools.push_back( (unsigned char*)(pointer) );
  178310           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStringVal::pool_size * sizeof(SgStringVal), V_SgStringVal ) );
  178311             : 
  178312           2 :         if ( SgStringVal::next_node != NULL ) {
  178313           0 :           if ( blockIndex > 0 ) {
  178314           0 :             SgStringVal * blkptr = (SgStringVal*)(SgStringVal::pools[blockIndex-1]);
  178315           0 :             blkptr[ SgStringVal::pool_size - 1 ].set_freepointer(pointer);
  178316             :           }
  178317             :         } else {
  178318           2 :           SgStringVal::next_node = pointer;
  178319             :         }
  178320             : 
  178321        4000 :         for (unsigned i = 0; i < SgStringVal::pool_size-1; ++i)
  178322             :            {
  178323        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  178324             :            }
  178325           2 :         pointer[ SgStringVal::pool_size -1 ].set_freepointer(NULL);
  178326             : 
  178327           2 :         blockIndex++;
  178328             :       }
  178329           2 :   }
  178330             : 
  178331             : //############################################################################
  178332             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  178333             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  178334             :  * not compressed. However, that stuff is not yet implemented! 
  178335             :  */
  178336             : unsigned long
  178337           0 : SgStringVal::getNumberOfLastValidPointer()
  178338             :    {
  178339           0 :       SgStringVal* testPointer = (SgStringVal*)(SgStringVal::pools.back());
  178340           0 :       unsigned long localIndex = SgStringVal::pool_size - 1;
  178341           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  178342             :          {
  178343           0 :            localIndex--;
  178344             :          }
  178345           0 :       return (localIndex + SgStringVal::pool_size * (SgStringVal::pools.size()-1));
  178346             :    }
  178347             : 
  178348             : //############################################################################
  178349             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  178350             :  * memory pool and initializes the data member in class SgStringValStroageClass
  178351             :  * from its counterpart of SgStringVal. The return value is just for checking, 
  178352             :  * that the whole StorageClassArray is initialized!
  178353             :  */
  178354             : unsigned long
  178355           3 : SgStringVal::initializeStorageClassArray( SgStringValStorageClass *storageArray )
  178356             :    {
  178357           3 :      unsigned long storageCounter = 0;
  178358           3 :      std::vector < unsigned char* > :: const_iterator block = SgStringVal::pools.begin();
  178359           3 :      SgStringVal* pointer = NULL;
  178360           6 :      while ( block != SgStringVal::pools.end() ) {
  178361           3 :           pointer = (SgStringVal*) (*block);
  178362        6003 :           for ( unsigned i = 0; i < SgStringVal::pool_size; ++i ) {
  178363        6000 :                if ( pointer->get_freepointer() != NULL ) {
  178364          83 :                  storageArray->pickOutIRNodeData (pointer) ;
  178365          83 :                  storageArray++;
  178366          83 :                  storageCounter++;
  178367             :                }
  178368        6000 :                pointer++;
  178369             :              }
  178370           3 :            block++;
  178371             :         }
  178372           3 :      return storageCounter;
  178373             :    }
  178374             : 
  178375             : /* #line 178376 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  178376             : 
  178377             : 
  178378             : 
  178379             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  178380             : 
  178381             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  178382             : 
  178383             : //############################################################################
  178384             : /* JH (02/02/2006) Constructor of the IR node SgShortVal that takes its 
  178385             :  * corresponding StorageClass as parameter
  178386             :  */
  178387           0 : SgShortVal :: SgShortVal ( const SgShortValStorageClass& storageSource )   : SgValueExp (storageSource)
  178388             :    {
  178389             : 
  178390             : 
  178391             : /* #line 178392 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  178392             : 
  178393           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  178394           0 :      p_value = storageSource.storageOf_value ;
  178395           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  178396             : 
  178397             : 
  178398             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  178399             : 
  178400             : 
  178401           0 :    }
  178402             : 
  178403             : //############################################################################
  178404             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  178405             :  * within the working AST. 
  178406             :  */
  178407           0 : SgShortVal * SgShortVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  178408           0 :      SgShortVal* returnPointer = NULL;
  178409           0 :      if ( globalIndex != 0 )
  178410             :         {
  178411             : 
  178412             : #if FILE_IO_EXTRA_CHECK
  178413           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgShortVal ) ) <= globalIndex ) ;
  178414           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgShortVal + 1 ) ) );
  178415             : #endif
  178416           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgShortVal )  
  178417           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgShortVal );
  178418           0 :           unsigned long positionInPool = localIndex % SgShortVal::pool_size;
  178419           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgShortVal::pool_size;
  178420             : 
  178421             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  178422             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  178423             : 
  178424           0 :           returnPointer = &( ( (SgShortVal*)(SgShortVal::pools[memoryBlock]) ) [positionInPool]) ;
  178425             : 
  178426           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  178427             :         }
  178428           0 :      return returnPointer ;
  178429             :    }
  178430             : 
  178431             : //############################################################################
  178432             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  178433             :   for the AST with the index astIndex
  178434             : */
  178435           0 : SgShortVal * SgShortVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  178436           0 :      SgShortVal* returnPointer = NULL;
  178437           0 :      if ( globalIndex != 0 )
  178438             :         {
  178439             : 
  178440             : #if FILE_IO_EXTRA_CHECK
  178441           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgShortVal ) ) <= globalIndex ) ;
  178442           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgShortVal + 1 ) ) );
  178443             : #endif
  178444           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgShortVal )
  178445           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgShortVal );
  178446           0 :           unsigned long positionInPool = localIndex % SgShortVal::pool_size ;
  178447           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgShortVal::pool_size ;
  178448             : 
  178449             : #if FILE_IO_EXTRA_CHECK
  178450             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  178451             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  178452             : #endif
  178453             : 
  178454           0 :           returnPointer = &( ( (SgShortVal*)(SgShortVal::pools[memoryBlock]) ) [positionInPool]) ;
  178455             : 
  178456             : #if FILE_IO_EXTRA_CHECK
  178457           0 :           assert ( returnPointer != NULL ) ;
  178458             : #endif
  178459             :         }
  178460           0 :      return returnPointer ;
  178461             :    }
  178462             : 
  178463             : //############################################################################
  178464             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  178465             :  * pool size! We set for every valid object in the memory pool the freepointer
  178466             :  * to the global index and increase the global index afterwards. For all the 
  178467             :  * invalid objects (means address ranges within the memory pool that were not
  178468             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  178469             :  * distinguish valid from invalid objects! 
  178470             :  */
  178471             : unsigned long
  178472           5 : SgShortVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  178473             :    {
  178474           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  178475           5 :      SgShortVal* pointer = NULL;
  178476           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  178477           5 :      std::vector < unsigned char* > :: const_iterator block;
  178478           6 :      for ( block = SgShortVal::pools.begin(); block != SgShortVal::pools.end() ; ++block )
  178479             :         {
  178480           1 :           pointer = (SgShortVal*)(*block);
  178481        2001 :           for (unsigned i = 0; i < SgShortVal::pool_size; ++i )
  178482             :              {
  178483             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  178484             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  178485             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  178486             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  178487             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  178488             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  178489             :             // properly; so this will have to be checked next.
  178490             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  178491             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  178492        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  178493             :                   {
  178494           0 :                     pointer[i].set_freepointer((SgShortVal*)(globalIndex));
  178495           0 :                     globalIndex++;
  178496             :                   }
  178497             :                else
  178498             :                   {
  178499        2000 :                     pointer[i].set_freepointer(NULL);
  178500             :                   }
  178501             :               }
  178502             :         }
  178503           5 :      return globalIndex;
  178504             :    }
  178505             : 
  178506             : //############################################################################
  178507             : // JH (01/14/2006)
  178508             : void
  178509           5 : SgShortVal::resetValidFreepointers( )
  178510             :    {
  178511           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  178512           5 :      SgShortVal* pointer = NULL;
  178513           5 :      std::vector < unsigned char* > :: const_iterator block;
  178514           5 :      SgShortVal* pointerOfLinkedList = NULL;
  178515           6 :      for ( block = SgShortVal::pools.begin(); block != SgShortVal::pools.end() ; ++block )
  178516             :         {
  178517           1 :           pointer = (SgShortVal*)(*block);
  178518        2001 :           for (unsigned i = 0; i < SgShortVal::pool_size; ++i )
  178519             :              {
  178520             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  178521             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  178522             :             // memory blocks!.
  178523        2000 :                if ( pointer[i].get_freepointer() != NULL )
  178524             :                   {
  178525           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  178526             :                   }
  178527             :                else
  178528             :                   {
  178529        2000 :                     if ( pointerOfLinkedList == NULL )
  178530             :                        {
  178531           1 :                          SgShortVal::next_node = &(pointer[i]);
  178532             :                        }
  178533             :                     else
  178534             :                        {
  178535             :                       // printf ("In SgShortVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  178536        1999 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  178537             :                        }
  178538             :                     pointerOfLinkedList = &(pointer[i]);
  178539             :                   }
  178540             :               }
  178541             :         }
  178542             : 
  178543           5 :      if ( pointerOfLinkedList != NULL )
  178544             :         {
  178545             :        // printf ("In SgShortVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  178546           1 :           pointerOfLinkedList->set_freepointer(NULL);
  178547             :        // DQ (6/6/2010): Temporary debugging...
  178548             :        //   ROSE_ASSERT(false);
  178549             :         }
  178550             : 
  178551           5 :      return ;
  178552             :    }
  178553             : 
  178554             : //############################################################################
  178555             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  178556             :  * within the memory pool and resets the freepointers, in order to achieve a 
  178557             :  * linked list, that has no jumps and starts at the beginning! This function 
  178558             :  * does not extend the memory pool, since we do not delete any memory blocks,
  178559             :  * but delete the valid objects.  
  178560             :  */
  178561             : void
  178562           0 : SgShortVal::clearMemoryPool( )
  178563             :    {
  178564             :   // printf ("Inside of SgShortVal::clearMemoryPool() \n");
  178565             : 
  178566           0 :      SgShortVal* pointer = NULL, *tempPointer = NULL;
  178567           0 :      std::vector < unsigned char* > :: const_iterator block;
  178568           0 :      if ( SgShortVal::pools.empty() == false )
  178569             :         {
  178570           0 :           block = SgShortVal::pools.begin() ;
  178571           0 :           SgShortVal::next_node = (SgShortVal*) (*block);
  178572             : 
  178573           0 :           while ( block != SgShortVal::pools.end() )
  178574             :              {
  178575           0 :                pointer = (SgShortVal*) (*block);
  178576           0 :                if ( tempPointer != NULL )
  178577             :                   {
  178578           0 :                     tempPointer->set_freepointer(pointer);
  178579             :                   }
  178580           0 :                for (unsigned i = 0; i < SgShortVal::pool_size - 1; ++i)
  178581             :                   {
  178582           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  178583             :                   }
  178584           0 :                 pointer[SgShortVal::pool_size-1].set_freepointer(NULL);
  178585           0 :                 tempPointer = &(pointer[SgShortVal::pool_size-1]);
  178586           0 :                 ++block;
  178587             :              }
  178588             :         }
  178589           0 :    }
  178590             : 
  178591           5 : void SgShortVal::deleteMemoryPool() {
  178592           6 :   for (auto p: SgShortVal::pools) {
  178593           1 :     ROSE_FREE(p);
  178594             :   }
  178595           5 :   SgShortVal::next_node = nullptr;
  178596           5 :   SgShortVal::pools.clear();
  178597           5 : }
  178598             : 
  178599             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  178600             : //                 reading multiple binary files to for a single AST.
  178601             : /////////// new version ////////////////////////////////
  178602             : //############################################################################
  178603             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  178604             : void
  178605           2 : SgShortVal::extendMemoryPoolForFileIO( )
  178606             :   {
  178607           2 :     size_t blockIndex = SgShortVal::pools.size();
  178608           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgShortVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgShortVal);
  178609             : 
  178610           2 :     while ( (blockIndex * SgShortVal::pool_size) < newPoolSize)
  178611             :       {
  178612             : #if ROSE_ALLOC_TRACE
  178613             :         if (blockIndex > 0) {
  178614             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgShortVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgShortVal) = %" PRIuPTR " SgShortVal::pool_size = %d \n",
  178615             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgShortVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgShortVal),SgShortVal::pool_size);
  178616             :         }
  178617             : #endif
  178618             : 
  178619           0 :         SgShortVal * pointer = (SgShortVal*) ROSE_MALLOC ( SgShortVal::pool_size * sizeof(SgShortVal) );
  178620           0 :         assert( pointer != NULL );
  178621             : #if ROSE_ALLOC_MEMSET == 1
  178622             :         memset(pointer, 0x00, SgShortVal::pool_size * sizeof(SgShortVal));
  178623             : #elif ROSE_ALLOC_MEMSET == 2
  178624             :         memset(pointer, 0xCC, SgShortVal::pool_size * sizeof(SgShortVal));
  178625             : #endif
  178626           0 :         SgShortVal::pools.push_back( (unsigned char*)(pointer) );
  178627           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgShortVal::pool_size * sizeof(SgShortVal), V_SgShortVal ) );
  178628             : 
  178629           0 :         if ( SgShortVal::next_node != NULL ) {
  178630           0 :           if ( blockIndex > 0 ) {
  178631           0 :             SgShortVal * blkptr = (SgShortVal*)(SgShortVal::pools[blockIndex-1]);
  178632           0 :             blkptr[ SgShortVal::pool_size - 1 ].set_freepointer(pointer);
  178633             :           }
  178634             :         } else {
  178635           0 :           SgShortVal::next_node = pointer;
  178636             :         }
  178637             : 
  178638           0 :         for (unsigned i = 0; i < SgShortVal::pool_size-1; ++i)
  178639             :            {
  178640           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  178641             :            }
  178642           0 :         pointer[ SgShortVal::pool_size -1 ].set_freepointer(NULL);
  178643             : 
  178644           0 :         blockIndex++;
  178645             :       }
  178646           2 :   }
  178647             : 
  178648             : //############################################################################
  178649             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  178650             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  178651             :  * not compressed. However, that stuff is not yet implemented! 
  178652             :  */
  178653             : unsigned long
  178654           0 : SgShortVal::getNumberOfLastValidPointer()
  178655             :    {
  178656           0 :       SgShortVal* testPointer = (SgShortVal*)(SgShortVal::pools.back());
  178657           0 :       unsigned long localIndex = SgShortVal::pool_size - 1;
  178658           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  178659             :          {
  178660           0 :            localIndex--;
  178661             :          }
  178662           0 :       return (localIndex + SgShortVal::pool_size * (SgShortVal::pools.size()-1));
  178663             :    }
  178664             : 
  178665             : //############################################################################
  178666             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  178667             :  * memory pool and initializes the data member in class SgShortValStroageClass
  178668             :  * from its counterpart of SgShortVal. The return value is just for checking, 
  178669             :  * that the whole StorageClassArray is initialized!
  178670             :  */
  178671             : unsigned long
  178672           0 : SgShortVal::initializeStorageClassArray( SgShortValStorageClass *storageArray )
  178673             :    {
  178674           0 :      unsigned long storageCounter = 0;
  178675           0 :      std::vector < unsigned char* > :: const_iterator block = SgShortVal::pools.begin();
  178676           0 :      SgShortVal* pointer = NULL;
  178677           0 :      while ( block != SgShortVal::pools.end() ) {
  178678           0 :           pointer = (SgShortVal*) (*block);
  178679           0 :           for ( unsigned i = 0; i < SgShortVal::pool_size; ++i ) {
  178680           0 :                if ( pointer->get_freepointer() != NULL ) {
  178681           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  178682           0 :                  storageArray++;
  178683           0 :                  storageCounter++;
  178684             :                }
  178685           0 :                pointer++;
  178686             :              }
  178687           0 :            block++;
  178688             :         }
  178689           0 :      return storageCounter;
  178690             :    }
  178691             : 
  178692             : /* #line 178693 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  178693             : 
  178694             : 
  178695             : 
  178696             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  178697             : 
  178698             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  178699             : 
  178700             : //############################################################################
  178701             : /* JH (02/02/2006) Constructor of the IR node SgCharVal that takes its 
  178702             :  * corresponding StorageClass as parameter
  178703             :  */
  178704          47 : SgCharVal :: SgCharVal ( const SgCharValStorageClass& storageSource )   : SgValueExp (storageSource)
  178705             :    {
  178706             : 
  178707             : 
  178708             : /* #line 178709 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  178709             : 
  178710          47 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  178711          47 :      p_value = storageSource.storageOf_value ;
  178712          47 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  178713             : 
  178714             : 
  178715             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  178716             : 
  178717             : 
  178718          47 :    }
  178719             : 
  178720             : //############################################################################
  178721             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  178722             :  * within the working AST. 
  178723             :  */
  178724         188 : SgCharVal * SgCharVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  178725         188 :      SgCharVal* returnPointer = NULL;
  178726         188 :      if ( globalIndex != 0 )
  178727             :         {
  178728             : 
  178729             : #if FILE_IO_EXTRA_CHECK
  178730         188 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCharVal ) ) <= globalIndex ) ;
  178731         188 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCharVal + 1 ) ) );
  178732             : #endif
  178733         188 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCharVal )  
  178734         188 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCharVal );
  178735         188 :           unsigned long positionInPool = localIndex % SgCharVal::pool_size;
  178736         188 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCharVal::pool_size;
  178737             : 
  178738             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  178739             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  178740             : 
  178741         188 :           returnPointer = &( ( (SgCharVal*)(SgCharVal::pools[memoryBlock]) ) [positionInPool]) ;
  178742             : 
  178743         188 :           ROSE_ASSERT( returnPointer != NULL ) ;
  178744             :         }
  178745         188 :      return returnPointer ;
  178746             :    }
  178747             : 
  178748             : //############################################################################
  178749             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  178750             :   for the AST with the index astIndex
  178751             : */
  178752           0 : SgCharVal * SgCharVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  178753           0 :      SgCharVal* returnPointer = NULL;
  178754           0 :      if ( globalIndex != 0 )
  178755             :         {
  178756             : 
  178757             : #if FILE_IO_EXTRA_CHECK
  178758           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCharVal ) ) <= globalIndex ) ;
  178759           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCharVal + 1 ) ) );
  178760             : #endif
  178761           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCharVal )
  178762           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCharVal );
  178763           0 :           unsigned long positionInPool = localIndex % SgCharVal::pool_size ;
  178764           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCharVal::pool_size ;
  178765             : 
  178766             : #if FILE_IO_EXTRA_CHECK
  178767             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  178768             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  178769             : #endif
  178770             : 
  178771           0 :           returnPointer = &( ( (SgCharVal*)(SgCharVal::pools[memoryBlock]) ) [positionInPool]) ;
  178772             : 
  178773             : #if FILE_IO_EXTRA_CHECK
  178774           0 :           assert ( returnPointer != NULL ) ;
  178775             : #endif
  178776             :         }
  178777           0 :      return returnPointer ;
  178778             :    }
  178779             : 
  178780             : //############################################################################
  178781             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  178782             :  * pool size! We set for every valid object in the memory pool the freepointer
  178783             :  * to the global index and increase the global index afterwards. For all the 
  178784             :  * invalid objects (means address ranges within the memory pool that were not
  178785             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  178786             :  * distinguish valid from invalid objects! 
  178787             :  */
  178788             : unsigned long
  178789           5 : SgCharVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  178790             :    {
  178791           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  178792           5 :      SgCharVal* pointer = NULL;
  178793           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  178794           5 :      std::vector < unsigned char* > :: const_iterator block;
  178795           6 :      for ( block = SgCharVal::pools.begin(); block != SgCharVal::pools.end() ; ++block )
  178796             :         {
  178797           1 :           pointer = (SgCharVal*)(*block);
  178798        2001 :           for (unsigned i = 0; i < SgCharVal::pool_size; ++i )
  178799             :              {
  178800             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  178801             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  178802             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  178803             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  178804             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  178805             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  178806             :             // properly; so this will have to be checked next.
  178807             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  178808             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  178809        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  178810             :                   {
  178811          47 :                     pointer[i].set_freepointer((SgCharVal*)(globalIndex));
  178812          47 :                     globalIndex++;
  178813             :                   }
  178814             :                else
  178815             :                   {
  178816        1953 :                     pointer[i].set_freepointer(NULL);
  178817             :                   }
  178818             :               }
  178819             :         }
  178820           5 :      return globalIndex;
  178821             :    }
  178822             : 
  178823             : //############################################################################
  178824             : // JH (01/14/2006)
  178825             : void
  178826           5 : SgCharVal::resetValidFreepointers( )
  178827             :    {
  178828           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  178829           5 :      SgCharVal* pointer = NULL;
  178830           5 :      std::vector < unsigned char* > :: const_iterator block;
  178831           5 :      SgCharVal* pointerOfLinkedList = NULL;
  178832           6 :      for ( block = SgCharVal::pools.begin(); block != SgCharVal::pools.end() ; ++block )
  178833             :         {
  178834           1 :           pointer = (SgCharVal*)(*block);
  178835        2001 :           for (unsigned i = 0; i < SgCharVal::pool_size; ++i )
  178836             :              {
  178837             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  178838             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  178839             :             // memory blocks!.
  178840        2000 :                if ( pointer[i].get_freepointer() != NULL )
  178841             :                   {
  178842          47 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  178843             :                   }
  178844             :                else
  178845             :                   {
  178846        1953 :                     if ( pointerOfLinkedList == NULL )
  178847             :                        {
  178848           1 :                          SgCharVal::next_node = &(pointer[i]);
  178849             :                        }
  178850             :                     else
  178851             :                        {
  178852             :                       // printf ("In SgCharVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  178853        1952 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  178854             :                        }
  178855             :                     pointerOfLinkedList = &(pointer[i]);
  178856             :                   }
  178857             :               }
  178858             :         }
  178859             : 
  178860           5 :      if ( pointerOfLinkedList != NULL )
  178861             :         {
  178862             :        // printf ("In SgCharVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  178863           1 :           pointerOfLinkedList->set_freepointer(NULL);
  178864             :        // DQ (6/6/2010): Temporary debugging...
  178865             :        //   ROSE_ASSERT(false);
  178866             :         }
  178867             : 
  178868           5 :      return ;
  178869             :    }
  178870             : 
  178871             : //############################################################################
  178872             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  178873             :  * within the memory pool and resets the freepointers, in order to achieve a 
  178874             :  * linked list, that has no jumps and starts at the beginning! This function 
  178875             :  * does not extend the memory pool, since we do not delete any memory blocks,
  178876             :  * but delete the valid objects.  
  178877             :  */
  178878             : void
  178879           0 : SgCharVal::clearMemoryPool( )
  178880             :    {
  178881             :   // printf ("Inside of SgCharVal::clearMemoryPool() \n");
  178882             : 
  178883           0 :      SgCharVal* pointer = NULL, *tempPointer = NULL;
  178884           0 :      std::vector < unsigned char* > :: const_iterator block;
  178885           0 :      if ( SgCharVal::pools.empty() == false )
  178886             :         {
  178887           0 :           block = SgCharVal::pools.begin() ;
  178888           0 :           SgCharVal::next_node = (SgCharVal*) (*block);
  178889             : 
  178890           0 :           while ( block != SgCharVal::pools.end() )
  178891             :              {
  178892           0 :                pointer = (SgCharVal*) (*block);
  178893           0 :                if ( tempPointer != NULL )
  178894             :                   {
  178895           0 :                     tempPointer->set_freepointer(pointer);
  178896             :                   }
  178897           0 :                for (unsigned i = 0; i < SgCharVal::pool_size - 1; ++i)
  178898             :                   {
  178899           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  178900             :                   }
  178901           0 :                 pointer[SgCharVal::pool_size-1].set_freepointer(NULL);
  178902           0 :                 tempPointer = &(pointer[SgCharVal::pool_size-1]);
  178903           0 :                 ++block;
  178904             :              }
  178905             :         }
  178906           0 :    }
  178907             : 
  178908           5 : void SgCharVal::deleteMemoryPool() {
  178909           7 :   for (auto p: SgCharVal::pools) {
  178910           2 :     ROSE_FREE(p);
  178911             :   }
  178912           5 :   SgCharVal::next_node = nullptr;
  178913           5 :   SgCharVal::pools.clear();
  178914           5 : }
  178915             : 
  178916             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  178917             : //                 reading multiple binary files to for a single AST.
  178918             : /////////// new version ////////////////////////////////
  178919             : //############################################################################
  178920             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  178921             : void
  178922           2 : SgCharVal::extendMemoryPoolForFileIO( )
  178923             :   {
  178924           2 :     size_t blockIndex = SgCharVal::pools.size();
  178925           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCharVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCharVal);
  178926             : 
  178927           3 :     while ( (blockIndex * SgCharVal::pool_size) < newPoolSize)
  178928             :       {
  178929             : #if ROSE_ALLOC_TRACE
  178930             :         if (blockIndex > 0) {
  178931             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCharVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCharVal) = %" PRIuPTR " SgCharVal::pool_size = %d \n",
  178932             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCharVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCharVal),SgCharVal::pool_size);
  178933             :         }
  178934             : #endif
  178935             : 
  178936           1 :         SgCharVal * pointer = (SgCharVal*) ROSE_MALLOC ( SgCharVal::pool_size * sizeof(SgCharVal) );
  178937           1 :         assert( pointer != NULL );
  178938             : #if ROSE_ALLOC_MEMSET == 1
  178939             :         memset(pointer, 0x00, SgCharVal::pool_size * sizeof(SgCharVal));
  178940             : #elif ROSE_ALLOC_MEMSET == 2
  178941             :         memset(pointer, 0xCC, SgCharVal::pool_size * sizeof(SgCharVal));
  178942             : #endif
  178943           1 :         SgCharVal::pools.push_back( (unsigned char*)(pointer) );
  178944           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCharVal::pool_size * sizeof(SgCharVal), V_SgCharVal ) );
  178945             : 
  178946           1 :         if ( SgCharVal::next_node != NULL ) {
  178947           0 :           if ( blockIndex > 0 ) {
  178948           0 :             SgCharVal * blkptr = (SgCharVal*)(SgCharVal::pools[blockIndex-1]);
  178949           0 :             blkptr[ SgCharVal::pool_size - 1 ].set_freepointer(pointer);
  178950             :           }
  178951             :         } else {
  178952           1 :           SgCharVal::next_node = pointer;
  178953             :         }
  178954             : 
  178955        2000 :         for (unsigned i = 0; i < SgCharVal::pool_size-1; ++i)
  178956             :            {
  178957        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  178958             :            }
  178959           1 :         pointer[ SgCharVal::pool_size -1 ].set_freepointer(NULL);
  178960             : 
  178961           1 :         blockIndex++;
  178962             :       }
  178963           2 :   }
  178964             : 
  178965             : //############################################################################
  178966             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  178967             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  178968             :  * not compressed. However, that stuff is not yet implemented! 
  178969             :  */
  178970             : unsigned long
  178971           0 : SgCharVal::getNumberOfLastValidPointer()
  178972             :    {
  178973           0 :       SgCharVal* testPointer = (SgCharVal*)(SgCharVal::pools.back());
  178974           0 :       unsigned long localIndex = SgCharVal::pool_size - 1;
  178975           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  178976             :          {
  178977           0 :            localIndex--;
  178978             :          }
  178979           0 :       return (localIndex + SgCharVal::pool_size * (SgCharVal::pools.size()-1));
  178980             :    }
  178981             : 
  178982             : //############################################################################
  178983             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  178984             :  * memory pool and initializes the data member in class SgCharValStroageClass
  178985             :  * from its counterpart of SgCharVal. The return value is just for checking, 
  178986             :  * that the whole StorageClassArray is initialized!
  178987             :  */
  178988             : unsigned long
  178989           1 : SgCharVal::initializeStorageClassArray( SgCharValStorageClass *storageArray )
  178990             :    {
  178991           1 :      unsigned long storageCounter = 0;
  178992           1 :      std::vector < unsigned char* > :: const_iterator block = SgCharVal::pools.begin();
  178993           1 :      SgCharVal* pointer = NULL;
  178994           2 :      while ( block != SgCharVal::pools.end() ) {
  178995           1 :           pointer = (SgCharVal*) (*block);
  178996        2001 :           for ( unsigned i = 0; i < SgCharVal::pool_size; ++i ) {
  178997        2000 :                if ( pointer->get_freepointer() != NULL ) {
  178998          47 :                  storageArray->pickOutIRNodeData (pointer) ;
  178999          47 :                  storageArray++;
  179000          47 :                  storageCounter++;
  179001             :                }
  179002        2000 :                pointer++;
  179003             :              }
  179004           1 :            block++;
  179005             :         }
  179006           1 :      return storageCounter;
  179007             :    }
  179008             : 
  179009             : /* #line 179010 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  179010             : 
  179011             : 
  179012             : 
  179013             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  179014             : 
  179015             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  179016             : 
  179017             : //############################################################################
  179018             : /* JH (02/02/2006) Constructor of the IR node SgUnsignedCharVal that takes its 
  179019             :  * corresponding StorageClass as parameter
  179020             :  */
  179021           0 : SgUnsignedCharVal :: SgUnsignedCharVal ( const SgUnsignedCharValStorageClass& storageSource )   : SgValueExp (storageSource)
  179022             :    {
  179023             : 
  179024             : 
  179025             : /* #line 179026 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  179026             : 
  179027           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  179028           0 :      p_value = storageSource.storageOf_value ;
  179029           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  179030             : 
  179031             : 
  179032             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  179033             : 
  179034             : 
  179035           0 :    }
  179036             : 
  179037             : //############################################################################
  179038             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  179039             :  * within the working AST. 
  179040             :  */
  179041           0 : SgUnsignedCharVal * SgUnsignedCharVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  179042           0 :      SgUnsignedCharVal* returnPointer = NULL;
  179043           0 :      if ( globalIndex != 0 )
  179044             :         {
  179045             : 
  179046             : #if FILE_IO_EXTRA_CHECK
  179047           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnsignedCharVal ) ) <= globalIndex ) ;
  179048           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedCharVal + 1 ) ) );
  179049             : #endif
  179050           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedCharVal )  
  179051           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnsignedCharVal );
  179052           0 :           unsigned long positionInPool = localIndex % SgUnsignedCharVal::pool_size;
  179053           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedCharVal::pool_size;
  179054             : 
  179055             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  179056             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  179057             : 
  179058           0 :           returnPointer = &( ( (SgUnsignedCharVal*)(SgUnsignedCharVal::pools[memoryBlock]) ) [positionInPool]) ;
  179059             : 
  179060           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  179061             :         }
  179062           0 :      return returnPointer ;
  179063             :    }
  179064             : 
  179065             : //############################################################################
  179066             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  179067             :   for the AST with the index astIndex
  179068             : */
  179069           0 : SgUnsignedCharVal * SgUnsignedCharVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  179070           0 :      SgUnsignedCharVal* returnPointer = NULL;
  179071           0 :      if ( globalIndex != 0 )
  179072             :         {
  179073             : 
  179074             : #if FILE_IO_EXTRA_CHECK
  179075           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnsignedCharVal ) ) <= globalIndex ) ;
  179076           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedCharVal + 1 ) ) );
  179077             : #endif
  179078           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedCharVal )
  179079           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnsignedCharVal );
  179080           0 :           unsigned long positionInPool = localIndex % SgUnsignedCharVal::pool_size ;
  179081           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedCharVal::pool_size ;
  179082             : 
  179083             : #if FILE_IO_EXTRA_CHECK
  179084             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  179085             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  179086             : #endif
  179087             : 
  179088           0 :           returnPointer = &( ( (SgUnsignedCharVal*)(SgUnsignedCharVal::pools[memoryBlock]) ) [positionInPool]) ;
  179089             : 
  179090             : #if FILE_IO_EXTRA_CHECK
  179091           0 :           assert ( returnPointer != NULL ) ;
  179092             : #endif
  179093             :         }
  179094           0 :      return returnPointer ;
  179095             :    }
  179096             : 
  179097             : //############################################################################
  179098             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  179099             :  * pool size! We set for every valid object in the memory pool the freepointer
  179100             :  * to the global index and increase the global index afterwards. For all the 
  179101             :  * invalid objects (means address ranges within the memory pool that were not
  179102             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  179103             :  * distinguish valid from invalid objects! 
  179104             :  */
  179105             : unsigned long
  179106           5 : SgUnsignedCharVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  179107             :    {
  179108           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  179109           5 :      SgUnsignedCharVal* pointer = NULL;
  179110           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  179111           5 :      std::vector < unsigned char* > :: const_iterator block;
  179112           5 :      for ( block = SgUnsignedCharVal::pools.begin(); block != SgUnsignedCharVal::pools.end() ; ++block )
  179113             :         {
  179114           0 :           pointer = (SgUnsignedCharVal*)(*block);
  179115           0 :           for (unsigned i = 0; i < SgUnsignedCharVal::pool_size; ++i )
  179116             :              {
  179117             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  179118             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  179119             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  179120             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  179121             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  179122             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  179123             :             // properly; so this will have to be checked next.
  179124             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  179125             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  179126           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  179127             :                   {
  179128           0 :                     pointer[i].set_freepointer((SgUnsignedCharVal*)(globalIndex));
  179129           0 :                     globalIndex++;
  179130             :                   }
  179131             :                else
  179132             :                   {
  179133           0 :                     pointer[i].set_freepointer(NULL);
  179134             :                   }
  179135             :               }
  179136             :         }
  179137           5 :      return globalIndex;
  179138             :    }
  179139             : 
  179140             : //############################################################################
  179141             : // JH (01/14/2006)
  179142             : void
  179143           5 : SgUnsignedCharVal::resetValidFreepointers( )
  179144             :    {
  179145           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  179146           5 :      SgUnsignedCharVal* pointer = NULL;
  179147           5 :      std::vector < unsigned char* > :: const_iterator block;
  179148           5 :      SgUnsignedCharVal* pointerOfLinkedList = NULL;
  179149           5 :      for ( block = SgUnsignedCharVal::pools.begin(); block != SgUnsignedCharVal::pools.end() ; ++block )
  179150             :         {
  179151           0 :           pointer = (SgUnsignedCharVal*)(*block);
  179152           0 :           for (unsigned i = 0; i < SgUnsignedCharVal::pool_size; ++i )
  179153             :              {
  179154             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  179155             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  179156             :             // memory blocks!.
  179157           0 :                if ( pointer[i].get_freepointer() != NULL )
  179158             :                   {
  179159           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  179160             :                   }
  179161             :                else
  179162             :                   {
  179163           0 :                     if ( pointerOfLinkedList == NULL )
  179164             :                        {
  179165           0 :                          SgUnsignedCharVal::next_node = &(pointer[i]);
  179166             :                        }
  179167             :                     else
  179168             :                        {
  179169             :                       // printf ("In SgUnsignedCharVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  179170           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  179171             :                        }
  179172             :                     pointerOfLinkedList = &(pointer[i]);
  179173             :                   }
  179174             :               }
  179175             :         }
  179176             : 
  179177           5 :      if ( pointerOfLinkedList != NULL )
  179178             :         {
  179179             :        // printf ("In SgUnsignedCharVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  179180           0 :           pointerOfLinkedList->set_freepointer(NULL);
  179181             :        // DQ (6/6/2010): Temporary debugging...
  179182             :        //   ROSE_ASSERT(false);
  179183             :         }
  179184             : 
  179185           5 :      return ;
  179186             :    }
  179187             : 
  179188             : //############################################################################
  179189             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  179190             :  * within the memory pool and resets the freepointers, in order to achieve a 
  179191             :  * linked list, that has no jumps and starts at the beginning! This function 
  179192             :  * does not extend the memory pool, since we do not delete any memory blocks,
  179193             :  * but delete the valid objects.  
  179194             :  */
  179195             : void
  179196           0 : SgUnsignedCharVal::clearMemoryPool( )
  179197             :    {
  179198             :   // printf ("Inside of SgUnsignedCharVal::clearMemoryPool() \n");
  179199             : 
  179200           0 :      SgUnsignedCharVal* pointer = NULL, *tempPointer = NULL;
  179201           0 :      std::vector < unsigned char* > :: const_iterator block;
  179202           0 :      if ( SgUnsignedCharVal::pools.empty() == false )
  179203             :         {
  179204           0 :           block = SgUnsignedCharVal::pools.begin() ;
  179205           0 :           SgUnsignedCharVal::next_node = (SgUnsignedCharVal*) (*block);
  179206             : 
  179207           0 :           while ( block != SgUnsignedCharVal::pools.end() )
  179208             :              {
  179209           0 :                pointer = (SgUnsignedCharVal*) (*block);
  179210           0 :                if ( tempPointer != NULL )
  179211             :                   {
  179212           0 :                     tempPointer->set_freepointer(pointer);
  179213             :                   }
  179214           0 :                for (unsigned i = 0; i < SgUnsignedCharVal::pool_size - 1; ++i)
  179215             :                   {
  179216           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  179217             :                   }
  179218           0 :                 pointer[SgUnsignedCharVal::pool_size-1].set_freepointer(NULL);
  179219           0 :                 tempPointer = &(pointer[SgUnsignedCharVal::pool_size-1]);
  179220           0 :                 ++block;
  179221             :              }
  179222             :         }
  179223           0 :    }
  179224             : 
  179225           5 : void SgUnsignedCharVal::deleteMemoryPool() {
  179226           5 :   for (auto p: SgUnsignedCharVal::pools) {
  179227           0 :     ROSE_FREE(p);
  179228             :   }
  179229           5 :   SgUnsignedCharVal::next_node = nullptr;
  179230           5 :   SgUnsignedCharVal::pools.clear();
  179231           5 : }
  179232             : 
  179233             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  179234             : //                 reading multiple binary files to for a single AST.
  179235             : /////////// new version ////////////////////////////////
  179236             : //############################################################################
  179237             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  179238             : void
  179239           2 : SgUnsignedCharVal::extendMemoryPoolForFileIO( )
  179240             :   {
  179241           2 :     size_t blockIndex = SgUnsignedCharVal::pools.size();
  179242           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedCharVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedCharVal);
  179243             : 
  179244           2 :     while ( (blockIndex * SgUnsignedCharVal::pool_size) < newPoolSize)
  179245             :       {
  179246             : #if ROSE_ALLOC_TRACE
  179247             :         if (blockIndex > 0) {
  179248             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedCharVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedCharVal) = %" PRIuPTR " SgUnsignedCharVal::pool_size = %d \n",
  179249             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedCharVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedCharVal),SgUnsignedCharVal::pool_size);
  179250             :         }
  179251             : #endif
  179252             : 
  179253           0 :         SgUnsignedCharVal * pointer = (SgUnsignedCharVal*) ROSE_MALLOC ( SgUnsignedCharVal::pool_size * sizeof(SgUnsignedCharVal) );
  179254           0 :         assert( pointer != NULL );
  179255             : #if ROSE_ALLOC_MEMSET == 1
  179256             :         memset(pointer, 0x00, SgUnsignedCharVal::pool_size * sizeof(SgUnsignedCharVal));
  179257             : #elif ROSE_ALLOC_MEMSET == 2
  179258             :         memset(pointer, 0xCC, SgUnsignedCharVal::pool_size * sizeof(SgUnsignedCharVal));
  179259             : #endif
  179260           0 :         SgUnsignedCharVal::pools.push_back( (unsigned char*)(pointer) );
  179261           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnsignedCharVal::pool_size * sizeof(SgUnsignedCharVal), V_SgUnsignedCharVal ) );
  179262             : 
  179263           0 :         if ( SgUnsignedCharVal::next_node != NULL ) {
  179264           0 :           if ( blockIndex > 0 ) {
  179265           0 :             SgUnsignedCharVal * blkptr = (SgUnsignedCharVal*)(SgUnsignedCharVal::pools[blockIndex-1]);
  179266           0 :             blkptr[ SgUnsignedCharVal::pool_size - 1 ].set_freepointer(pointer);
  179267             :           }
  179268             :         } else {
  179269           0 :           SgUnsignedCharVal::next_node = pointer;
  179270             :         }
  179271             : 
  179272           0 :         for (unsigned i = 0; i < SgUnsignedCharVal::pool_size-1; ++i)
  179273             :            {
  179274           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  179275             :            }
  179276           0 :         pointer[ SgUnsignedCharVal::pool_size -1 ].set_freepointer(NULL);
  179277             : 
  179278           0 :         blockIndex++;
  179279             :       }
  179280           2 :   }
  179281             : 
  179282             : //############################################################################
  179283             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  179284             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  179285             :  * not compressed. However, that stuff is not yet implemented! 
  179286             :  */
  179287             : unsigned long
  179288           0 : SgUnsignedCharVal::getNumberOfLastValidPointer()
  179289             :    {
  179290           0 :       SgUnsignedCharVal* testPointer = (SgUnsignedCharVal*)(SgUnsignedCharVal::pools.back());
  179291           0 :       unsigned long localIndex = SgUnsignedCharVal::pool_size - 1;
  179292           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  179293             :          {
  179294           0 :            localIndex--;
  179295             :          }
  179296           0 :       return (localIndex + SgUnsignedCharVal::pool_size * (SgUnsignedCharVal::pools.size()-1));
  179297             :    }
  179298             : 
  179299             : //############################################################################
  179300             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  179301             :  * memory pool and initializes the data member in class SgUnsignedCharValStroageClass
  179302             :  * from its counterpart of SgUnsignedCharVal. The return value is just for checking, 
  179303             :  * that the whole StorageClassArray is initialized!
  179304             :  */
  179305             : unsigned long
  179306           0 : SgUnsignedCharVal::initializeStorageClassArray( SgUnsignedCharValStorageClass *storageArray )
  179307             :    {
  179308           0 :      unsigned long storageCounter = 0;
  179309           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnsignedCharVal::pools.begin();
  179310           0 :      SgUnsignedCharVal* pointer = NULL;
  179311           0 :      while ( block != SgUnsignedCharVal::pools.end() ) {
  179312           0 :           pointer = (SgUnsignedCharVal*) (*block);
  179313           0 :           for ( unsigned i = 0; i < SgUnsignedCharVal::pool_size; ++i ) {
  179314           0 :                if ( pointer->get_freepointer() != NULL ) {
  179315           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  179316           0 :                  storageArray++;
  179317           0 :                  storageCounter++;
  179318             :                }
  179319           0 :                pointer++;
  179320             :              }
  179321           0 :            block++;
  179322             :         }
  179323           0 :      return storageCounter;
  179324             :    }
  179325             : 
  179326             : /* #line 179327 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  179327             : 
  179328             : 
  179329             : 
  179330             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  179331             : 
  179332             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  179333             : 
  179334             : //############################################################################
  179335             : /* JH (02/02/2006) Constructor of the IR node SgWcharVal that takes its 
  179336             :  * corresponding StorageClass as parameter
  179337             :  */
  179338           0 : SgWcharVal :: SgWcharVal ( const SgWcharValStorageClass& storageSource )   : SgValueExp (storageSource)
  179339             :    {
  179340             : 
  179341             : 
  179342             : /* #line 179343 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  179343             : 
  179344           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  179345           0 :      p_valueUL = storageSource.storageOf_valueUL ;
  179346           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  179347             : 
  179348             : 
  179349             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  179350             : 
  179351             : 
  179352           0 :    }
  179353             : 
  179354             : //############################################################################
  179355             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  179356             :  * within the working AST. 
  179357             :  */
  179358           0 : SgWcharVal * SgWcharVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  179359           0 :      SgWcharVal* returnPointer = NULL;
  179360           0 :      if ( globalIndex != 0 )
  179361             :         {
  179362             : 
  179363             : #if FILE_IO_EXTRA_CHECK
  179364           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgWcharVal ) ) <= globalIndex ) ;
  179365           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWcharVal + 1 ) ) );
  179366             : #endif
  179367           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgWcharVal )  
  179368           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgWcharVal );
  179369           0 :           unsigned long positionInPool = localIndex % SgWcharVal::pool_size;
  179370           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWcharVal::pool_size;
  179371             : 
  179372             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  179373             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  179374             : 
  179375           0 :           returnPointer = &( ( (SgWcharVal*)(SgWcharVal::pools[memoryBlock]) ) [positionInPool]) ;
  179376             : 
  179377           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  179378             :         }
  179379           0 :      return returnPointer ;
  179380             :    }
  179381             : 
  179382             : //############################################################################
  179383             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  179384             :   for the AST with the index astIndex
  179385             : */
  179386           0 : SgWcharVal * SgWcharVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  179387           0 :      SgWcharVal* returnPointer = NULL;
  179388           0 :      if ( globalIndex != 0 )
  179389             :         {
  179390             : 
  179391             : #if FILE_IO_EXTRA_CHECK
  179392           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgWcharVal ) ) <= globalIndex ) ;
  179393           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWcharVal + 1 ) ) );
  179394             : #endif
  179395           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgWcharVal )
  179396           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgWcharVal );
  179397           0 :           unsigned long positionInPool = localIndex % SgWcharVal::pool_size ;
  179398           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgWcharVal::pool_size ;
  179399             : 
  179400             : #if FILE_IO_EXTRA_CHECK
  179401             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  179402             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  179403             : #endif
  179404             : 
  179405           0 :           returnPointer = &( ( (SgWcharVal*)(SgWcharVal::pools[memoryBlock]) ) [positionInPool]) ;
  179406             : 
  179407             : #if FILE_IO_EXTRA_CHECK
  179408           0 :           assert ( returnPointer != NULL ) ;
  179409             : #endif
  179410             :         }
  179411           0 :      return returnPointer ;
  179412             :    }
  179413             : 
  179414             : //############################################################################
  179415             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  179416             :  * pool size! We set for every valid object in the memory pool the freepointer
  179417             :  * to the global index and increase the global index afterwards. For all the 
  179418             :  * invalid objects (means address ranges within the memory pool that were not
  179419             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  179420             :  * distinguish valid from invalid objects! 
  179421             :  */
  179422             : unsigned long
  179423           5 : SgWcharVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  179424             :    {
  179425           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  179426           5 :      SgWcharVal* pointer = NULL;
  179427           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  179428           5 :      std::vector < unsigned char* > :: const_iterator block;
  179429           6 :      for ( block = SgWcharVal::pools.begin(); block != SgWcharVal::pools.end() ; ++block )
  179430             :         {
  179431           1 :           pointer = (SgWcharVal*)(*block);
  179432        2001 :           for (unsigned i = 0; i < SgWcharVal::pool_size; ++i )
  179433             :              {
  179434             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  179435             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  179436             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  179437             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  179438             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  179439             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  179440             :             // properly; so this will have to be checked next.
  179441             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  179442             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  179443        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  179444             :                   {
  179445           0 :                     pointer[i].set_freepointer((SgWcharVal*)(globalIndex));
  179446           0 :                     globalIndex++;
  179447             :                   }
  179448             :                else
  179449             :                   {
  179450        2000 :                     pointer[i].set_freepointer(NULL);
  179451             :                   }
  179452             :               }
  179453             :         }
  179454           5 :      return globalIndex;
  179455             :    }
  179456             : 
  179457             : //############################################################################
  179458             : // JH (01/14/2006)
  179459             : void
  179460           5 : SgWcharVal::resetValidFreepointers( )
  179461             :    {
  179462           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  179463           5 :      SgWcharVal* pointer = NULL;
  179464           5 :      std::vector < unsigned char* > :: const_iterator block;
  179465           5 :      SgWcharVal* pointerOfLinkedList = NULL;
  179466           6 :      for ( block = SgWcharVal::pools.begin(); block != SgWcharVal::pools.end() ; ++block )
  179467             :         {
  179468           1 :           pointer = (SgWcharVal*)(*block);
  179469        2001 :           for (unsigned i = 0; i < SgWcharVal::pool_size; ++i )
  179470             :              {
  179471             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  179472             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  179473             :             // memory blocks!.
  179474        2000 :                if ( pointer[i].get_freepointer() != NULL )
  179475             :                   {
  179476           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  179477             :                   }
  179478             :                else
  179479             :                   {
  179480        2000 :                     if ( pointerOfLinkedList == NULL )
  179481             :                        {
  179482           1 :                          SgWcharVal::next_node = &(pointer[i]);
  179483             :                        }
  179484             :                     else
  179485             :                        {
  179486             :                       // printf ("In SgWcharVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  179487        1999 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  179488             :                        }
  179489             :                     pointerOfLinkedList = &(pointer[i]);
  179490             :                   }
  179491             :               }
  179492             :         }
  179493             : 
  179494           5 :      if ( pointerOfLinkedList != NULL )
  179495             :         {
  179496             :        // printf ("In SgWcharVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  179497           1 :           pointerOfLinkedList->set_freepointer(NULL);
  179498             :        // DQ (6/6/2010): Temporary debugging...
  179499             :        //   ROSE_ASSERT(false);
  179500             :         }
  179501             : 
  179502           5 :      return ;
  179503             :    }
  179504             : 
  179505             : //############################################################################
  179506             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  179507             :  * within the memory pool and resets the freepointers, in order to achieve a 
  179508             :  * linked list, that has no jumps and starts at the beginning! This function 
  179509             :  * does not extend the memory pool, since we do not delete any memory blocks,
  179510             :  * but delete the valid objects.  
  179511             :  */
  179512             : void
  179513           0 : SgWcharVal::clearMemoryPool( )
  179514             :    {
  179515             :   // printf ("Inside of SgWcharVal::clearMemoryPool() \n");
  179516             : 
  179517           0 :      SgWcharVal* pointer = NULL, *tempPointer = NULL;
  179518           0 :      std::vector < unsigned char* > :: const_iterator block;
  179519           0 :      if ( SgWcharVal::pools.empty() == false )
  179520             :         {
  179521           0 :           block = SgWcharVal::pools.begin() ;
  179522           0 :           SgWcharVal::next_node = (SgWcharVal*) (*block);
  179523             : 
  179524           0 :           while ( block != SgWcharVal::pools.end() )
  179525             :              {
  179526           0 :                pointer = (SgWcharVal*) (*block);
  179527           0 :                if ( tempPointer != NULL )
  179528             :                   {
  179529           0 :                     tempPointer->set_freepointer(pointer);
  179530             :                   }
  179531           0 :                for (unsigned i = 0; i < SgWcharVal::pool_size - 1; ++i)
  179532             :                   {
  179533           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  179534             :                   }
  179535           0 :                 pointer[SgWcharVal::pool_size-1].set_freepointer(NULL);
  179536           0 :                 tempPointer = &(pointer[SgWcharVal::pool_size-1]);
  179537           0 :                 ++block;
  179538             :              }
  179539             :         }
  179540           0 :    }
  179541             : 
  179542           5 : void SgWcharVal::deleteMemoryPool() {
  179543           6 :   for (auto p: SgWcharVal::pools) {
  179544           1 :     ROSE_FREE(p);
  179545             :   }
  179546           5 :   SgWcharVal::next_node = nullptr;
  179547           5 :   SgWcharVal::pools.clear();
  179548           5 : }
  179549             : 
  179550             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  179551             : //                 reading multiple binary files to for a single AST.
  179552             : /////////// new version ////////////////////////////////
  179553             : //############################################################################
  179554             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  179555             : void
  179556           2 : SgWcharVal::extendMemoryPoolForFileIO( )
  179557             :   {
  179558           2 :     size_t blockIndex = SgWcharVal::pools.size();
  179559           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgWcharVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgWcharVal);
  179560             : 
  179561           2 :     while ( (blockIndex * SgWcharVal::pool_size) < newPoolSize)
  179562             :       {
  179563             : #if ROSE_ALLOC_TRACE
  179564             :         if (blockIndex > 0) {
  179565             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgWcharVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgWcharVal) = %" PRIuPTR " SgWcharVal::pool_size = %d \n",
  179566             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgWcharVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgWcharVal),SgWcharVal::pool_size);
  179567             :         }
  179568             : #endif
  179569             : 
  179570           0 :         SgWcharVal * pointer = (SgWcharVal*) ROSE_MALLOC ( SgWcharVal::pool_size * sizeof(SgWcharVal) );
  179571           0 :         assert( pointer != NULL );
  179572             : #if ROSE_ALLOC_MEMSET == 1
  179573             :         memset(pointer, 0x00, SgWcharVal::pool_size * sizeof(SgWcharVal));
  179574             : #elif ROSE_ALLOC_MEMSET == 2
  179575             :         memset(pointer, 0xCC, SgWcharVal::pool_size * sizeof(SgWcharVal));
  179576             : #endif
  179577           0 :         SgWcharVal::pools.push_back( (unsigned char*)(pointer) );
  179578           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgWcharVal::pool_size * sizeof(SgWcharVal), V_SgWcharVal ) );
  179579             : 
  179580           0 :         if ( SgWcharVal::next_node != NULL ) {
  179581           0 :           if ( blockIndex > 0 ) {
  179582           0 :             SgWcharVal * blkptr = (SgWcharVal*)(SgWcharVal::pools[blockIndex-1]);
  179583           0 :             blkptr[ SgWcharVal::pool_size - 1 ].set_freepointer(pointer);
  179584             :           }
  179585             :         } else {
  179586           0 :           SgWcharVal::next_node = pointer;
  179587             :         }
  179588             : 
  179589           0 :         for (unsigned i = 0; i < SgWcharVal::pool_size-1; ++i)
  179590             :            {
  179591           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  179592             :            }
  179593           0 :         pointer[ SgWcharVal::pool_size -1 ].set_freepointer(NULL);
  179594             : 
  179595           0 :         blockIndex++;
  179596             :       }
  179597           2 :   }
  179598             : 
  179599             : //############################################################################
  179600             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  179601             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  179602             :  * not compressed. However, that stuff is not yet implemented! 
  179603             :  */
  179604             : unsigned long
  179605           0 : SgWcharVal::getNumberOfLastValidPointer()
  179606             :    {
  179607           0 :       SgWcharVal* testPointer = (SgWcharVal*)(SgWcharVal::pools.back());
  179608           0 :       unsigned long localIndex = SgWcharVal::pool_size - 1;
  179609           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  179610             :          {
  179611           0 :            localIndex--;
  179612             :          }
  179613           0 :       return (localIndex + SgWcharVal::pool_size * (SgWcharVal::pools.size()-1));
  179614             :    }
  179615             : 
  179616             : //############################################################################
  179617             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  179618             :  * memory pool and initializes the data member in class SgWcharValStroageClass
  179619             :  * from its counterpart of SgWcharVal. The return value is just for checking, 
  179620             :  * that the whole StorageClassArray is initialized!
  179621             :  */
  179622             : unsigned long
  179623           0 : SgWcharVal::initializeStorageClassArray( SgWcharValStorageClass *storageArray )
  179624             :    {
  179625           0 :      unsigned long storageCounter = 0;
  179626           0 :      std::vector < unsigned char* > :: const_iterator block = SgWcharVal::pools.begin();
  179627           0 :      SgWcharVal* pointer = NULL;
  179628           0 :      while ( block != SgWcharVal::pools.end() ) {
  179629           0 :           pointer = (SgWcharVal*) (*block);
  179630           0 :           for ( unsigned i = 0; i < SgWcharVal::pool_size; ++i ) {
  179631           0 :                if ( pointer->get_freepointer() != NULL ) {
  179632           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  179633           0 :                  storageArray++;
  179634           0 :                  storageCounter++;
  179635             :                }
  179636           0 :                pointer++;
  179637             :              }
  179638           0 :            block++;
  179639             :         }
  179640           0 :      return storageCounter;
  179641             :    }
  179642             : 
  179643             : /* #line 179644 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  179644             : 
  179645             : 
  179646             : 
  179647             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  179648             : 
  179649             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  179650             : 
  179651             : //############################################################################
  179652             : /* JH (02/02/2006) Constructor of the IR node SgUnsignedShortVal that takes its 
  179653             :  * corresponding StorageClass as parameter
  179654             :  */
  179655           0 : SgUnsignedShortVal :: SgUnsignedShortVal ( const SgUnsignedShortValStorageClass& storageSource )   : SgValueExp (storageSource)
  179656             :    {
  179657             : 
  179658             : 
  179659             : /* #line 179660 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  179660             : 
  179661           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  179662           0 :      p_value = storageSource.storageOf_value ;
  179663           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  179664             : 
  179665             : 
  179666             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  179667             : 
  179668             : 
  179669           0 :    }
  179670             : 
  179671             : //############################################################################
  179672             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  179673             :  * within the working AST. 
  179674             :  */
  179675           0 : SgUnsignedShortVal * SgUnsignedShortVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  179676           0 :      SgUnsignedShortVal* returnPointer = NULL;
  179677           0 :      if ( globalIndex != 0 )
  179678             :         {
  179679             : 
  179680             : #if FILE_IO_EXTRA_CHECK
  179681           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnsignedShortVal ) ) <= globalIndex ) ;
  179682           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedShortVal + 1 ) ) );
  179683             : #endif
  179684           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedShortVal )  
  179685           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnsignedShortVal );
  179686           0 :           unsigned long positionInPool = localIndex % SgUnsignedShortVal::pool_size;
  179687           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedShortVal::pool_size;
  179688             : 
  179689             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  179690             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  179691             : 
  179692           0 :           returnPointer = &( ( (SgUnsignedShortVal*)(SgUnsignedShortVal::pools[memoryBlock]) ) [positionInPool]) ;
  179693             : 
  179694           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  179695             :         }
  179696           0 :      return returnPointer ;
  179697             :    }
  179698             : 
  179699             : //############################################################################
  179700             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  179701             :   for the AST with the index astIndex
  179702             : */
  179703           0 : SgUnsignedShortVal * SgUnsignedShortVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  179704           0 :      SgUnsignedShortVal* returnPointer = NULL;
  179705           0 :      if ( globalIndex != 0 )
  179706             :         {
  179707             : 
  179708             : #if FILE_IO_EXTRA_CHECK
  179709           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnsignedShortVal ) ) <= globalIndex ) ;
  179710           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedShortVal + 1 ) ) );
  179711             : #endif
  179712           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedShortVal )
  179713           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnsignedShortVal );
  179714           0 :           unsigned long positionInPool = localIndex % SgUnsignedShortVal::pool_size ;
  179715           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedShortVal::pool_size ;
  179716             : 
  179717             : #if FILE_IO_EXTRA_CHECK
  179718             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  179719             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  179720             : #endif
  179721             : 
  179722           0 :           returnPointer = &( ( (SgUnsignedShortVal*)(SgUnsignedShortVal::pools[memoryBlock]) ) [positionInPool]) ;
  179723             : 
  179724             : #if FILE_IO_EXTRA_CHECK
  179725           0 :           assert ( returnPointer != NULL ) ;
  179726             : #endif
  179727             :         }
  179728           0 :      return returnPointer ;
  179729             :    }
  179730             : 
  179731             : //############################################################################
  179732             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  179733             :  * pool size! We set for every valid object in the memory pool the freepointer
  179734             :  * to the global index and increase the global index afterwards. For all the 
  179735             :  * invalid objects (means address ranges within the memory pool that were not
  179736             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  179737             :  * distinguish valid from invalid objects! 
  179738             :  */
  179739             : unsigned long
  179740           5 : SgUnsignedShortVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  179741             :    {
  179742           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  179743           5 :      SgUnsignedShortVal* pointer = NULL;
  179744           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  179745           5 :      std::vector < unsigned char* > :: const_iterator block;
  179746           6 :      for ( block = SgUnsignedShortVal::pools.begin(); block != SgUnsignedShortVal::pools.end() ; ++block )
  179747             :         {
  179748           1 :           pointer = (SgUnsignedShortVal*)(*block);
  179749        2001 :           for (unsigned i = 0; i < SgUnsignedShortVal::pool_size; ++i )
  179750             :              {
  179751             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  179752             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  179753             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  179754             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  179755             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  179756             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  179757             :             // properly; so this will have to be checked next.
  179758             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  179759             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  179760        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  179761             :                   {
  179762           0 :                     pointer[i].set_freepointer((SgUnsignedShortVal*)(globalIndex));
  179763           0 :                     globalIndex++;
  179764             :                   }
  179765             :                else
  179766             :                   {
  179767        2000 :                     pointer[i].set_freepointer(NULL);
  179768             :                   }
  179769             :               }
  179770             :         }
  179771           5 :      return globalIndex;
  179772             :    }
  179773             : 
  179774             : //############################################################################
  179775             : // JH (01/14/2006)
  179776             : void
  179777           5 : SgUnsignedShortVal::resetValidFreepointers( )
  179778             :    {
  179779           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  179780           5 :      SgUnsignedShortVal* pointer = NULL;
  179781           5 :      std::vector < unsigned char* > :: const_iterator block;
  179782           5 :      SgUnsignedShortVal* pointerOfLinkedList = NULL;
  179783           6 :      for ( block = SgUnsignedShortVal::pools.begin(); block != SgUnsignedShortVal::pools.end() ; ++block )
  179784             :         {
  179785           1 :           pointer = (SgUnsignedShortVal*)(*block);
  179786        2001 :           for (unsigned i = 0; i < SgUnsignedShortVal::pool_size; ++i )
  179787             :              {
  179788             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  179789             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  179790             :             // memory blocks!.
  179791        2000 :                if ( pointer[i].get_freepointer() != NULL )
  179792             :                   {
  179793           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  179794             :                   }
  179795             :                else
  179796             :                   {
  179797        2000 :                     if ( pointerOfLinkedList == NULL )
  179798             :                        {
  179799           1 :                          SgUnsignedShortVal::next_node = &(pointer[i]);
  179800             :                        }
  179801             :                     else
  179802             :                        {
  179803             :                       // printf ("In SgUnsignedShortVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  179804        1999 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  179805             :                        }
  179806             :                     pointerOfLinkedList = &(pointer[i]);
  179807             :                   }
  179808             :               }
  179809             :         }
  179810             : 
  179811           5 :      if ( pointerOfLinkedList != NULL )
  179812             :         {
  179813             :        // printf ("In SgUnsignedShortVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  179814           1 :           pointerOfLinkedList->set_freepointer(NULL);
  179815             :        // DQ (6/6/2010): Temporary debugging...
  179816             :        //   ROSE_ASSERT(false);
  179817             :         }
  179818             : 
  179819           5 :      return ;
  179820             :    }
  179821             : 
  179822             : //############################################################################
  179823             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  179824             :  * within the memory pool and resets the freepointers, in order to achieve a 
  179825             :  * linked list, that has no jumps and starts at the beginning! This function 
  179826             :  * does not extend the memory pool, since we do not delete any memory blocks,
  179827             :  * but delete the valid objects.  
  179828             :  */
  179829             : void
  179830           0 : SgUnsignedShortVal::clearMemoryPool( )
  179831             :    {
  179832             :   // printf ("Inside of SgUnsignedShortVal::clearMemoryPool() \n");
  179833             : 
  179834           0 :      SgUnsignedShortVal* pointer = NULL, *tempPointer = NULL;
  179835           0 :      std::vector < unsigned char* > :: const_iterator block;
  179836           0 :      if ( SgUnsignedShortVal::pools.empty() == false )
  179837             :         {
  179838           0 :           block = SgUnsignedShortVal::pools.begin() ;
  179839           0 :           SgUnsignedShortVal::next_node = (SgUnsignedShortVal*) (*block);
  179840             : 
  179841           0 :           while ( block != SgUnsignedShortVal::pools.end() )
  179842             :              {
  179843           0 :                pointer = (SgUnsignedShortVal*) (*block);
  179844           0 :                if ( tempPointer != NULL )
  179845             :                   {
  179846           0 :                     tempPointer->set_freepointer(pointer);
  179847             :                   }
  179848           0 :                for (unsigned i = 0; i < SgUnsignedShortVal::pool_size - 1; ++i)
  179849             :                   {
  179850           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  179851             :                   }
  179852           0 :                 pointer[SgUnsignedShortVal::pool_size-1].set_freepointer(NULL);
  179853           0 :                 tempPointer = &(pointer[SgUnsignedShortVal::pool_size-1]);
  179854           0 :                 ++block;
  179855             :              }
  179856             :         }
  179857           0 :    }
  179858             : 
  179859           5 : void SgUnsignedShortVal::deleteMemoryPool() {
  179860           6 :   for (auto p: SgUnsignedShortVal::pools) {
  179861           1 :     ROSE_FREE(p);
  179862             :   }
  179863           5 :   SgUnsignedShortVal::next_node = nullptr;
  179864           5 :   SgUnsignedShortVal::pools.clear();
  179865           5 : }
  179866             : 
  179867             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  179868             : //                 reading multiple binary files to for a single AST.
  179869             : /////////// new version ////////////////////////////////
  179870             : //############################################################################
  179871             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  179872             : void
  179873           2 : SgUnsignedShortVal::extendMemoryPoolForFileIO( )
  179874             :   {
  179875           2 :     size_t blockIndex = SgUnsignedShortVal::pools.size();
  179876           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedShortVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedShortVal);
  179877             : 
  179878           2 :     while ( (blockIndex * SgUnsignedShortVal::pool_size) < newPoolSize)
  179879             :       {
  179880             : #if ROSE_ALLOC_TRACE
  179881             :         if (blockIndex > 0) {
  179882             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedShortVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedShortVal) = %" PRIuPTR " SgUnsignedShortVal::pool_size = %d \n",
  179883             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedShortVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedShortVal),SgUnsignedShortVal::pool_size);
  179884             :         }
  179885             : #endif
  179886             : 
  179887           0 :         SgUnsignedShortVal * pointer = (SgUnsignedShortVal*) ROSE_MALLOC ( SgUnsignedShortVal::pool_size * sizeof(SgUnsignedShortVal) );
  179888           0 :         assert( pointer != NULL );
  179889             : #if ROSE_ALLOC_MEMSET == 1
  179890             :         memset(pointer, 0x00, SgUnsignedShortVal::pool_size * sizeof(SgUnsignedShortVal));
  179891             : #elif ROSE_ALLOC_MEMSET == 2
  179892             :         memset(pointer, 0xCC, SgUnsignedShortVal::pool_size * sizeof(SgUnsignedShortVal));
  179893             : #endif
  179894           0 :         SgUnsignedShortVal::pools.push_back( (unsigned char*)(pointer) );
  179895           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnsignedShortVal::pool_size * sizeof(SgUnsignedShortVal), V_SgUnsignedShortVal ) );
  179896             : 
  179897           0 :         if ( SgUnsignedShortVal::next_node != NULL ) {
  179898           0 :           if ( blockIndex > 0 ) {
  179899           0 :             SgUnsignedShortVal * blkptr = (SgUnsignedShortVal*)(SgUnsignedShortVal::pools[blockIndex-1]);
  179900           0 :             blkptr[ SgUnsignedShortVal::pool_size - 1 ].set_freepointer(pointer);
  179901             :           }
  179902             :         } else {
  179903           0 :           SgUnsignedShortVal::next_node = pointer;
  179904             :         }
  179905             : 
  179906           0 :         for (unsigned i = 0; i < SgUnsignedShortVal::pool_size-1; ++i)
  179907             :            {
  179908           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  179909             :            }
  179910           0 :         pointer[ SgUnsignedShortVal::pool_size -1 ].set_freepointer(NULL);
  179911             : 
  179912           0 :         blockIndex++;
  179913             :       }
  179914           2 :   }
  179915             : 
  179916             : //############################################################################
  179917             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  179918             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  179919             :  * not compressed. However, that stuff is not yet implemented! 
  179920             :  */
  179921             : unsigned long
  179922           0 : SgUnsignedShortVal::getNumberOfLastValidPointer()
  179923             :    {
  179924           0 :       SgUnsignedShortVal* testPointer = (SgUnsignedShortVal*)(SgUnsignedShortVal::pools.back());
  179925           0 :       unsigned long localIndex = SgUnsignedShortVal::pool_size - 1;
  179926           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  179927             :          {
  179928           0 :            localIndex--;
  179929             :          }
  179930           0 :       return (localIndex + SgUnsignedShortVal::pool_size * (SgUnsignedShortVal::pools.size()-1));
  179931             :    }
  179932             : 
  179933             : //############################################################################
  179934             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  179935             :  * memory pool and initializes the data member in class SgUnsignedShortValStroageClass
  179936             :  * from its counterpart of SgUnsignedShortVal. The return value is just for checking, 
  179937             :  * that the whole StorageClassArray is initialized!
  179938             :  */
  179939             : unsigned long
  179940           0 : SgUnsignedShortVal::initializeStorageClassArray( SgUnsignedShortValStorageClass *storageArray )
  179941             :    {
  179942           0 :      unsigned long storageCounter = 0;
  179943           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnsignedShortVal::pools.begin();
  179944           0 :      SgUnsignedShortVal* pointer = NULL;
  179945           0 :      while ( block != SgUnsignedShortVal::pools.end() ) {
  179946           0 :           pointer = (SgUnsignedShortVal*) (*block);
  179947           0 :           for ( unsigned i = 0; i < SgUnsignedShortVal::pool_size; ++i ) {
  179948           0 :                if ( pointer->get_freepointer() != NULL ) {
  179949           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  179950           0 :                  storageArray++;
  179951           0 :                  storageCounter++;
  179952             :                }
  179953           0 :                pointer++;
  179954             :              }
  179955           0 :            block++;
  179956             :         }
  179957           0 :      return storageCounter;
  179958             :    }
  179959             : 
  179960             : /* #line 179961 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  179961             : 
  179962             : 
  179963             : 
  179964             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  179965             : 
  179966             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  179967             : 
  179968             : //############################################################################
  179969             : /* JH (02/02/2006) Constructor of the IR node SgIntVal that takes its 
  179970             :  * corresponding StorageClass as parameter
  179971             :  */
  179972         925 : SgIntVal :: SgIntVal ( const SgIntValStorageClass& storageSource )   : SgValueExp (storageSource)
  179973             :    {
  179974             : 
  179975             : 
  179976             : /* #line 179977 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  179977             : 
  179978         925 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  179979         925 :      p_value = storageSource.storageOf_value ;
  179980         925 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  179981             : 
  179982             : 
  179983             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  179984             : 
  179985             : 
  179986         925 :    }
  179987             : 
  179988             : //############################################################################
  179989             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  179990             :  * within the working AST. 
  179991             :  */
  179992        3700 : SgIntVal * SgIntVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  179993        3700 :      SgIntVal* returnPointer = NULL;
  179994        3700 :      if ( globalIndex != 0 )
  179995             :         {
  179996             : 
  179997             : #if FILE_IO_EXTRA_CHECK
  179998        3700 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIntVal ) ) <= globalIndex ) ;
  179999        3700 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntVal + 1 ) ) );
  180000             : #endif
  180001        3700 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntVal )  
  180002        3700 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIntVal );
  180003        3700 :           unsigned long positionInPool = localIndex % SgIntVal::pool_size;
  180004        3700 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntVal::pool_size;
  180005             : 
  180006             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  180007             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  180008             : 
  180009        3700 :           returnPointer = &( ( (SgIntVal*)(SgIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  180010             : 
  180011        3700 :           ROSE_ASSERT( returnPointer != NULL ) ;
  180012             :         }
  180013        3700 :      return returnPointer ;
  180014             :    }
  180015             : 
  180016             : //############################################################################
  180017             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  180018             :   for the AST with the index astIndex
  180019             : */
  180020           0 : SgIntVal * SgIntVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  180021           0 :      SgIntVal* returnPointer = NULL;
  180022           0 :      if ( globalIndex != 0 )
  180023             :         {
  180024             : 
  180025             : #if FILE_IO_EXTRA_CHECK
  180026           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIntVal ) ) <= globalIndex ) ;
  180027           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntVal + 1 ) ) );
  180028             : #endif
  180029           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntVal )
  180030           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIntVal );
  180031           0 :           unsigned long positionInPool = localIndex % SgIntVal::pool_size ;
  180032           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntVal::pool_size ;
  180033             : 
  180034             : #if FILE_IO_EXTRA_CHECK
  180035             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  180036             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  180037             : #endif
  180038             : 
  180039           0 :           returnPointer = &( ( (SgIntVal*)(SgIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  180040             : 
  180041             : #if FILE_IO_EXTRA_CHECK
  180042           0 :           assert ( returnPointer != NULL ) ;
  180043             : #endif
  180044             :         }
  180045           0 :      return returnPointer ;
  180046             :    }
  180047             : 
  180048             : //############################################################################
  180049             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  180050             :  * pool size! We set for every valid object in the memory pool the freepointer
  180051             :  * to the global index and increase the global index afterwards. For all the 
  180052             :  * invalid objects (means address ranges within the memory pool that were not
  180053             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  180054             :  * distinguish valid from invalid objects! 
  180055             :  */
  180056             : unsigned long
  180057           5 : SgIntVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  180058             :    {
  180059           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  180060           5 :      SgIntVal* pointer = NULL;
  180061           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  180062           5 :      std::vector < unsigned char* > :: const_iterator block;
  180063           8 :      for ( block = SgIntVal::pools.begin(); block != SgIntVal::pools.end() ; ++block )
  180064             :         {
  180065           3 :           pointer = (SgIntVal*)(*block);
  180066        6003 :           for (unsigned i = 0; i < SgIntVal::pool_size; ++i )
  180067             :              {
  180068             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  180069             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  180070             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  180071             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  180072             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  180073             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  180074             :             // properly; so this will have to be checked next.
  180075             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  180076             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  180077        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  180078             :                   {
  180079         925 :                     pointer[i].set_freepointer((SgIntVal*)(globalIndex));
  180080         925 :                     globalIndex++;
  180081             :                   }
  180082             :                else
  180083             :                   {
  180084        5075 :                     pointer[i].set_freepointer(NULL);
  180085             :                   }
  180086             :               }
  180087             :         }
  180088           5 :      return globalIndex;
  180089             :    }
  180090             : 
  180091             : //############################################################################
  180092             : // JH (01/14/2006)
  180093             : void
  180094           5 : SgIntVal::resetValidFreepointers( )
  180095             :    {
  180096           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  180097           5 :      SgIntVal* pointer = NULL;
  180098           5 :      std::vector < unsigned char* > :: const_iterator block;
  180099           5 :      SgIntVal* pointerOfLinkedList = NULL;
  180100           8 :      for ( block = SgIntVal::pools.begin(); block != SgIntVal::pools.end() ; ++block )
  180101             :         {
  180102           3 :           pointer = (SgIntVal*)(*block);
  180103        6003 :           for (unsigned i = 0; i < SgIntVal::pool_size; ++i )
  180104             :              {
  180105             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  180106             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  180107             :             // memory blocks!.
  180108        6000 :                if ( pointer[i].get_freepointer() != NULL )
  180109             :                   {
  180110         925 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  180111             :                   }
  180112             :                else
  180113             :                   {
  180114        5075 :                     if ( pointerOfLinkedList == NULL )
  180115             :                        {
  180116           2 :                          SgIntVal::next_node = &(pointer[i]);
  180117             :                        }
  180118             :                     else
  180119             :                        {
  180120             :                       // printf ("In SgIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  180121        5073 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  180122             :                        }
  180123             :                     pointerOfLinkedList = &(pointer[i]);
  180124             :                   }
  180125             :               }
  180126             :         }
  180127             : 
  180128           5 :      if ( pointerOfLinkedList != NULL )
  180129             :         {
  180130             :        // printf ("In SgIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  180131           2 :           pointerOfLinkedList->set_freepointer(NULL);
  180132             :        // DQ (6/6/2010): Temporary debugging...
  180133             :        //   ROSE_ASSERT(false);
  180134             :         }
  180135             : 
  180136           5 :      return ;
  180137             :    }
  180138             : 
  180139             : //############################################################################
  180140             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  180141             :  * within the memory pool and resets the freepointers, in order to achieve a 
  180142             :  * linked list, that has no jumps and starts at the beginning! This function 
  180143             :  * does not extend the memory pool, since we do not delete any memory blocks,
  180144             :  * but delete the valid objects.  
  180145             :  */
  180146             : void
  180147           0 : SgIntVal::clearMemoryPool( )
  180148             :    {
  180149             :   // printf ("Inside of SgIntVal::clearMemoryPool() \n");
  180150             : 
  180151           0 :      SgIntVal* pointer = NULL, *tempPointer = NULL;
  180152           0 :      std::vector < unsigned char* > :: const_iterator block;
  180153           0 :      if ( SgIntVal::pools.empty() == false )
  180154             :         {
  180155           0 :           block = SgIntVal::pools.begin() ;
  180156           0 :           SgIntVal::next_node = (SgIntVal*) (*block);
  180157             : 
  180158           0 :           while ( block != SgIntVal::pools.end() )
  180159             :              {
  180160           0 :                pointer = (SgIntVal*) (*block);
  180161           0 :                if ( tempPointer != NULL )
  180162             :                   {
  180163           0 :                     tempPointer->set_freepointer(pointer);
  180164             :                   }
  180165           0 :                for (unsigned i = 0; i < SgIntVal::pool_size - 1; ++i)
  180166             :                   {
  180167           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  180168             :                   }
  180169           0 :                 pointer[SgIntVal::pool_size-1].set_freepointer(NULL);
  180170           0 :                 tempPointer = &(pointer[SgIntVal::pool_size-1]);
  180171           0 :                 ++block;
  180172             :              }
  180173             :         }
  180174           0 :    }
  180175             : 
  180176           5 : void SgIntVal::deleteMemoryPool() {
  180177          10 :   for (auto p: SgIntVal::pools) {
  180178           5 :     ROSE_FREE(p);
  180179             :   }
  180180           5 :   SgIntVal::next_node = nullptr;
  180181           5 :   SgIntVal::pools.clear();
  180182           5 : }
  180183             : 
  180184             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  180185             : //                 reading multiple binary files to for a single AST.
  180186             : /////////// new version ////////////////////////////////
  180187             : //############################################################################
  180188             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  180189             : void
  180190           2 : SgIntVal::extendMemoryPoolForFileIO( )
  180191             :   {
  180192           2 :     size_t blockIndex = SgIntVal::pools.size();
  180193           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIntVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntVal);
  180194             : 
  180195           4 :     while ( (blockIndex * SgIntVal::pool_size) < newPoolSize)
  180196             :       {
  180197             : #if ROSE_ALLOC_TRACE
  180198             :         if (blockIndex > 0) {
  180199             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIntVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntVal) = %" PRIuPTR " SgIntVal::pool_size = %d \n",
  180200             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIntVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntVal),SgIntVal::pool_size);
  180201             :         }
  180202             : #endif
  180203             : 
  180204           2 :         SgIntVal * pointer = (SgIntVal*) ROSE_MALLOC ( SgIntVal::pool_size * sizeof(SgIntVal) );
  180205           2 :         assert( pointer != NULL );
  180206             : #if ROSE_ALLOC_MEMSET == 1
  180207             :         memset(pointer, 0x00, SgIntVal::pool_size * sizeof(SgIntVal));
  180208             : #elif ROSE_ALLOC_MEMSET == 2
  180209             :         memset(pointer, 0xCC, SgIntVal::pool_size * sizeof(SgIntVal));
  180210             : #endif
  180211           2 :         SgIntVal::pools.push_back( (unsigned char*)(pointer) );
  180212           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIntVal::pool_size * sizeof(SgIntVal), V_SgIntVal ) );
  180213             : 
  180214           2 :         if ( SgIntVal::next_node != NULL ) {
  180215           0 :           if ( blockIndex > 0 ) {
  180216           0 :             SgIntVal * blkptr = (SgIntVal*)(SgIntVal::pools[blockIndex-1]);
  180217           0 :             blkptr[ SgIntVal::pool_size - 1 ].set_freepointer(pointer);
  180218             :           }
  180219             :         } else {
  180220           2 :           SgIntVal::next_node = pointer;
  180221             :         }
  180222             : 
  180223        4000 :         for (unsigned i = 0; i < SgIntVal::pool_size-1; ++i)
  180224             :            {
  180225        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  180226             :            }
  180227           2 :         pointer[ SgIntVal::pool_size -1 ].set_freepointer(NULL);
  180228             : 
  180229           2 :         blockIndex++;
  180230             :       }
  180231           2 :   }
  180232             : 
  180233             : //############################################################################
  180234             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  180235             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  180236             :  * not compressed. However, that stuff is not yet implemented! 
  180237             :  */
  180238             : unsigned long
  180239           0 : SgIntVal::getNumberOfLastValidPointer()
  180240             :    {
  180241           0 :       SgIntVal* testPointer = (SgIntVal*)(SgIntVal::pools.back());
  180242           0 :       unsigned long localIndex = SgIntVal::pool_size - 1;
  180243           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  180244             :          {
  180245           0 :            localIndex--;
  180246             :          }
  180247           0 :       return (localIndex + SgIntVal::pool_size * (SgIntVal::pools.size()-1));
  180248             :    }
  180249             : 
  180250             : //############################################################################
  180251             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  180252             :  * memory pool and initializes the data member in class SgIntValStroageClass
  180253             :  * from its counterpart of SgIntVal. The return value is just for checking, 
  180254             :  * that the whole StorageClassArray is initialized!
  180255             :  */
  180256             : unsigned long
  180257           2 : SgIntVal::initializeStorageClassArray( SgIntValStorageClass *storageArray )
  180258             :    {
  180259           2 :      unsigned long storageCounter = 0;
  180260           2 :      std::vector < unsigned char* > :: const_iterator block = SgIntVal::pools.begin();
  180261           2 :      SgIntVal* pointer = NULL;
  180262           5 :      while ( block != SgIntVal::pools.end() ) {
  180263           3 :           pointer = (SgIntVal*) (*block);
  180264        6003 :           for ( unsigned i = 0; i < SgIntVal::pool_size; ++i ) {
  180265        6000 :                if ( pointer->get_freepointer() != NULL ) {
  180266         925 :                  storageArray->pickOutIRNodeData (pointer) ;
  180267         925 :                  storageArray++;
  180268         925 :                  storageCounter++;
  180269             :                }
  180270        6000 :                pointer++;
  180271             :              }
  180272           3 :            block++;
  180273             :         }
  180274           2 :      return storageCounter;
  180275             :    }
  180276             : 
  180277             : /* #line 180278 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  180278             : 
  180279             : 
  180280             : 
  180281             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  180282             : 
  180283             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  180284             : 
  180285             : //############################################################################
  180286             : /* JH (02/02/2006) Constructor of the IR node SgEnumVal that takes its 
  180287             :  * corresponding StorageClass as parameter
  180288             :  */
  180289         550 : SgEnumVal :: SgEnumVal ( const SgEnumValStorageClass& storageSource )   : SgValueExp (storageSource)
  180290             :    {
  180291             : 
  180292             : 
  180293             : /* #line 180294 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  180294             : 
  180295         550 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  180296         550 :      p_value = storageSource.storageOf_value ;
  180297         550 :      p_declaration =  (SgEnumDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  180298         550 :      p_name = SgName ( storageSource.storageOf_name ) ;
  180299         550 :      p_requiresNameQualification = storageSource.storageOf_requiresNameQualification ;
  180300         550 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  180301         550 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  180302         550 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  180303             : 
  180304             : 
  180305             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  180306             : 
  180307             : 
  180308         550 :    }
  180309             : 
  180310             : //############################################################################
  180311             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  180312             :  * within the working AST. 
  180313             :  */
  180314        2200 : SgEnumVal * SgEnumVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  180315        2200 :      SgEnumVal* returnPointer = NULL;
  180316        2200 :      if ( globalIndex != 0 )
  180317             :         {
  180318             : 
  180319             : #if FILE_IO_EXTRA_CHECK
  180320        2200 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEnumVal ) ) <= globalIndex ) ;
  180321        2200 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumVal + 1 ) ) );
  180322             : #endif
  180323        2200 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumVal )  
  180324        2200 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEnumVal );
  180325        2200 :           unsigned long positionInPool = localIndex % SgEnumVal::pool_size;
  180326        2200 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumVal::pool_size;
  180327             : 
  180328             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  180329             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  180330             : 
  180331        2200 :           returnPointer = &( ( (SgEnumVal*)(SgEnumVal::pools[memoryBlock]) ) [positionInPool]) ;
  180332             : 
  180333        2200 :           ROSE_ASSERT( returnPointer != NULL ) ;
  180334             :         }
  180335        2200 :      return returnPointer ;
  180336             :    }
  180337             : 
  180338             : //############################################################################
  180339             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  180340             :   for the AST with the index astIndex
  180341             : */
  180342           0 : SgEnumVal * SgEnumVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  180343           0 :      SgEnumVal* returnPointer = NULL;
  180344           0 :      if ( globalIndex != 0 )
  180345             :         {
  180346             : 
  180347             : #if FILE_IO_EXTRA_CHECK
  180348           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEnumVal ) ) <= globalIndex ) ;
  180349           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumVal + 1 ) ) );
  180350             : #endif
  180351           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumVal )
  180352           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEnumVal );
  180353           0 :           unsigned long positionInPool = localIndex % SgEnumVal::pool_size ;
  180354           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumVal::pool_size ;
  180355             : 
  180356             : #if FILE_IO_EXTRA_CHECK
  180357             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  180358             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  180359             : #endif
  180360             : 
  180361           0 :           returnPointer = &( ( (SgEnumVal*)(SgEnumVal::pools[memoryBlock]) ) [positionInPool]) ;
  180362             : 
  180363             : #if FILE_IO_EXTRA_CHECK
  180364           0 :           assert ( returnPointer != NULL ) ;
  180365             : #endif
  180366             :         }
  180367           0 :      return returnPointer ;
  180368             :    }
  180369             : 
  180370             : //############################################################################
  180371             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  180372             :  * pool size! We set for every valid object in the memory pool the freepointer
  180373             :  * to the global index and increase the global index afterwards. For all the 
  180374             :  * invalid objects (means address ranges within the memory pool that were not
  180375             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  180376             :  * distinguish valid from invalid objects! 
  180377             :  */
  180378             : unsigned long
  180379           5 : SgEnumVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  180380             :    {
  180381           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  180382           5 :      SgEnumVal* pointer = NULL;
  180383           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  180384           5 :      std::vector < unsigned char* > :: const_iterator block;
  180385           6 :      for ( block = SgEnumVal::pools.begin(); block != SgEnumVal::pools.end() ; ++block )
  180386             :         {
  180387           1 :           pointer = (SgEnumVal*)(*block);
  180388        2001 :           for (unsigned i = 0; i < SgEnumVal::pool_size; ++i )
  180389             :              {
  180390             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  180391             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  180392             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  180393             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  180394             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  180395             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  180396             :             // properly; so this will have to be checked next.
  180397             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  180398             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  180399        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  180400             :                   {
  180401         550 :                     pointer[i].set_freepointer((SgEnumVal*)(globalIndex));
  180402         550 :                     globalIndex++;
  180403             :                   }
  180404             :                else
  180405             :                   {
  180406        1450 :                     pointer[i].set_freepointer(NULL);
  180407             :                   }
  180408             :               }
  180409             :         }
  180410           5 :      return globalIndex;
  180411             :    }
  180412             : 
  180413             : //############################################################################
  180414             : // JH (01/14/2006)
  180415             : void
  180416           5 : SgEnumVal::resetValidFreepointers( )
  180417             :    {
  180418           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  180419           5 :      SgEnumVal* pointer = NULL;
  180420           5 :      std::vector < unsigned char* > :: const_iterator block;
  180421           5 :      SgEnumVal* pointerOfLinkedList = NULL;
  180422           6 :      for ( block = SgEnumVal::pools.begin(); block != SgEnumVal::pools.end() ; ++block )
  180423             :         {
  180424           1 :           pointer = (SgEnumVal*)(*block);
  180425        2001 :           for (unsigned i = 0; i < SgEnumVal::pool_size; ++i )
  180426             :              {
  180427             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  180428             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  180429             :             // memory blocks!.
  180430        2000 :                if ( pointer[i].get_freepointer() != NULL )
  180431             :                   {
  180432         550 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  180433             :                   }
  180434             :                else
  180435             :                   {
  180436        1450 :                     if ( pointerOfLinkedList == NULL )
  180437             :                        {
  180438           1 :                          SgEnumVal::next_node = &(pointer[i]);
  180439             :                        }
  180440             :                     else
  180441             :                        {
  180442             :                       // printf ("In SgEnumVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  180443        1449 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  180444             :                        }
  180445             :                     pointerOfLinkedList = &(pointer[i]);
  180446             :                   }
  180447             :               }
  180448             :         }
  180449             : 
  180450           5 :      if ( pointerOfLinkedList != NULL )
  180451             :         {
  180452             :        // printf ("In SgEnumVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  180453           1 :           pointerOfLinkedList->set_freepointer(NULL);
  180454             :        // DQ (6/6/2010): Temporary debugging...
  180455             :        //   ROSE_ASSERT(false);
  180456             :         }
  180457             : 
  180458           5 :      return ;
  180459             :    }
  180460             : 
  180461             : //############################################################################
  180462             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  180463             :  * within the memory pool and resets the freepointers, in order to achieve a 
  180464             :  * linked list, that has no jumps and starts at the beginning! This function 
  180465             :  * does not extend the memory pool, since we do not delete any memory blocks,
  180466             :  * but delete the valid objects.  
  180467             :  */
  180468             : void
  180469           0 : SgEnumVal::clearMemoryPool( )
  180470             :    {
  180471             :   // printf ("Inside of SgEnumVal::clearMemoryPool() \n");
  180472             : 
  180473           0 :      SgEnumVal* pointer = NULL, *tempPointer = NULL;
  180474           0 :      std::vector < unsigned char* > :: const_iterator block;
  180475           0 :      if ( SgEnumVal::pools.empty() == false )
  180476             :         {
  180477           0 :           block = SgEnumVal::pools.begin() ;
  180478           0 :           SgEnumVal::next_node = (SgEnumVal*) (*block);
  180479             : 
  180480           0 :           while ( block != SgEnumVal::pools.end() )
  180481             :              {
  180482           0 :                pointer = (SgEnumVal*) (*block);
  180483           0 :                if ( tempPointer != NULL )
  180484             :                   {
  180485           0 :                     tempPointer->set_freepointer(pointer);
  180486             :                   }
  180487           0 :                for (unsigned i = 0; i < SgEnumVal::pool_size - 1; ++i)
  180488             :                   {
  180489           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  180490             :                   }
  180491           0 :                 pointer[SgEnumVal::pool_size-1].set_freepointer(NULL);
  180492           0 :                 tempPointer = &(pointer[SgEnumVal::pool_size-1]);
  180493           0 :                 ++block;
  180494             :              }
  180495             :         }
  180496           0 :    }
  180497             : 
  180498           5 : void SgEnumVal::deleteMemoryPool() {
  180499           7 :   for (auto p: SgEnumVal::pools) {
  180500           2 :     ROSE_FREE(p);
  180501             :   }
  180502           5 :   SgEnumVal::next_node = nullptr;
  180503           5 :   SgEnumVal::pools.clear();
  180504           5 : }
  180505             : 
  180506             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  180507             : //                 reading multiple binary files to for a single AST.
  180508             : /////////// new version ////////////////////////////////
  180509             : //############################################################################
  180510             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  180511             : void
  180512           2 : SgEnumVal::extendMemoryPoolForFileIO( )
  180513             :   {
  180514           2 :     size_t blockIndex = SgEnumVal::pools.size();
  180515           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumVal);
  180516             : 
  180517           3 :     while ( (blockIndex * SgEnumVal::pool_size) < newPoolSize)
  180518             :       {
  180519             : #if ROSE_ALLOC_TRACE
  180520             :         if (blockIndex > 0) {
  180521             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumVal) = %" PRIuPTR " SgEnumVal::pool_size = %d \n",
  180522             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumVal),SgEnumVal::pool_size);
  180523             :         }
  180524             : #endif
  180525             : 
  180526           1 :         SgEnumVal * pointer = (SgEnumVal*) ROSE_MALLOC ( SgEnumVal::pool_size * sizeof(SgEnumVal) );
  180527           1 :         assert( pointer != NULL );
  180528             : #if ROSE_ALLOC_MEMSET == 1
  180529             :         memset(pointer, 0x00, SgEnumVal::pool_size * sizeof(SgEnumVal));
  180530             : #elif ROSE_ALLOC_MEMSET == 2
  180531             :         memset(pointer, 0xCC, SgEnumVal::pool_size * sizeof(SgEnumVal));
  180532             : #endif
  180533           1 :         SgEnumVal::pools.push_back( (unsigned char*)(pointer) );
  180534           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEnumVal::pool_size * sizeof(SgEnumVal), V_SgEnumVal ) );
  180535             : 
  180536           1 :         if ( SgEnumVal::next_node != NULL ) {
  180537           0 :           if ( blockIndex > 0 ) {
  180538           0 :             SgEnumVal * blkptr = (SgEnumVal*)(SgEnumVal::pools[blockIndex-1]);
  180539           0 :             blkptr[ SgEnumVal::pool_size - 1 ].set_freepointer(pointer);
  180540             :           }
  180541             :         } else {
  180542           1 :           SgEnumVal::next_node = pointer;
  180543             :         }
  180544             : 
  180545        2000 :         for (unsigned i = 0; i < SgEnumVal::pool_size-1; ++i)
  180546             :            {
  180547        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  180548             :            }
  180549           1 :         pointer[ SgEnumVal::pool_size -1 ].set_freepointer(NULL);
  180550             : 
  180551           1 :         blockIndex++;
  180552             :       }
  180553           2 :   }
  180554             : 
  180555             : //############################################################################
  180556             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  180557             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  180558             :  * not compressed. However, that stuff is not yet implemented! 
  180559             :  */
  180560             : unsigned long
  180561           0 : SgEnumVal::getNumberOfLastValidPointer()
  180562             :    {
  180563           0 :       SgEnumVal* testPointer = (SgEnumVal*)(SgEnumVal::pools.back());
  180564           0 :       unsigned long localIndex = SgEnumVal::pool_size - 1;
  180565           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  180566             :          {
  180567           0 :            localIndex--;
  180568             :          }
  180569           0 :       return (localIndex + SgEnumVal::pool_size * (SgEnumVal::pools.size()-1));
  180570             :    }
  180571             : 
  180572             : //############################################################################
  180573             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  180574             :  * memory pool and initializes the data member in class SgEnumValStroageClass
  180575             :  * from its counterpart of SgEnumVal. The return value is just for checking, 
  180576             :  * that the whole StorageClassArray is initialized!
  180577             :  */
  180578             : unsigned long
  180579           1 : SgEnumVal::initializeStorageClassArray( SgEnumValStorageClass *storageArray )
  180580             :    {
  180581           1 :      unsigned long storageCounter = 0;
  180582           1 :      std::vector < unsigned char* > :: const_iterator block = SgEnumVal::pools.begin();
  180583           1 :      SgEnumVal* pointer = NULL;
  180584           2 :      while ( block != SgEnumVal::pools.end() ) {
  180585           1 :           pointer = (SgEnumVal*) (*block);
  180586        2001 :           for ( unsigned i = 0; i < SgEnumVal::pool_size; ++i ) {
  180587        2000 :                if ( pointer->get_freepointer() != NULL ) {
  180588         550 :                  storageArray->pickOutIRNodeData (pointer) ;
  180589         550 :                  storageArray++;
  180590         550 :                  storageCounter++;
  180591             :                }
  180592        2000 :                pointer++;
  180593             :              }
  180594           1 :            block++;
  180595             :         }
  180596           1 :      return storageCounter;
  180597             :    }
  180598             : 
  180599             : /* #line 180600 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  180600             : 
  180601             : 
  180602             : 
  180603             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  180604             : 
  180605             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  180606             : 
  180607             : //############################################################################
  180608             : /* JH (02/02/2006) Constructor of the IR node SgUnsignedIntVal that takes its 
  180609             :  * corresponding StorageClass as parameter
  180610             :  */
  180611           8 : SgUnsignedIntVal :: SgUnsignedIntVal ( const SgUnsignedIntValStorageClass& storageSource )   : SgValueExp (storageSource)
  180612             :    {
  180613             : 
  180614             : 
  180615             : /* #line 180616 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  180616             : 
  180617           8 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  180618           8 :      p_value = storageSource.storageOf_value ;
  180619           8 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  180620             : 
  180621             : 
  180622             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  180623             : 
  180624             : 
  180625           8 :    }
  180626             : 
  180627             : //############################################################################
  180628             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  180629             :  * within the working AST. 
  180630             :  */
  180631          32 : SgUnsignedIntVal * SgUnsignedIntVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  180632          32 :      SgUnsignedIntVal* returnPointer = NULL;
  180633          32 :      if ( globalIndex != 0 )
  180634             :         {
  180635             : 
  180636             : #if FILE_IO_EXTRA_CHECK
  180637          32 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnsignedIntVal ) ) <= globalIndex ) ;
  180638          32 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedIntVal + 1 ) ) );
  180639             : #endif
  180640          32 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedIntVal )  
  180641          32 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnsignedIntVal );
  180642          32 :           unsigned long positionInPool = localIndex % SgUnsignedIntVal::pool_size;
  180643          32 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedIntVal::pool_size;
  180644             : 
  180645             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  180646             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  180647             : 
  180648          32 :           returnPointer = &( ( (SgUnsignedIntVal*)(SgUnsignedIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  180649             : 
  180650          32 :           ROSE_ASSERT( returnPointer != NULL ) ;
  180651             :         }
  180652          32 :      return returnPointer ;
  180653             :    }
  180654             : 
  180655             : //############################################################################
  180656             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  180657             :   for the AST with the index astIndex
  180658             : */
  180659           0 : SgUnsignedIntVal * SgUnsignedIntVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  180660           0 :      SgUnsignedIntVal* returnPointer = NULL;
  180661           0 :      if ( globalIndex != 0 )
  180662             :         {
  180663             : 
  180664             : #if FILE_IO_EXTRA_CHECK
  180665           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnsignedIntVal ) ) <= globalIndex ) ;
  180666           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedIntVal + 1 ) ) );
  180667             : #endif
  180668           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedIntVal )
  180669           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnsignedIntVal );
  180670           0 :           unsigned long positionInPool = localIndex % SgUnsignedIntVal::pool_size ;
  180671           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedIntVal::pool_size ;
  180672             : 
  180673             : #if FILE_IO_EXTRA_CHECK
  180674             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  180675             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  180676             : #endif
  180677             : 
  180678           0 :           returnPointer = &( ( (SgUnsignedIntVal*)(SgUnsignedIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  180679             : 
  180680             : #if FILE_IO_EXTRA_CHECK
  180681           0 :           assert ( returnPointer != NULL ) ;
  180682             : #endif
  180683             :         }
  180684           0 :      return returnPointer ;
  180685             :    }
  180686             : 
  180687             : //############################################################################
  180688             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  180689             :  * pool size! We set for every valid object in the memory pool the freepointer
  180690             :  * to the global index and increase the global index afterwards. For all the 
  180691             :  * invalid objects (means address ranges within the memory pool that were not
  180692             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  180693             :  * distinguish valid from invalid objects! 
  180694             :  */
  180695             : unsigned long
  180696           5 : SgUnsignedIntVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  180697             :    {
  180698           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  180699           5 :      SgUnsignedIntVal* pointer = NULL;
  180700           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  180701           5 :      std::vector < unsigned char* > :: const_iterator block;
  180702           6 :      for ( block = SgUnsignedIntVal::pools.begin(); block != SgUnsignedIntVal::pools.end() ; ++block )
  180703             :         {
  180704           1 :           pointer = (SgUnsignedIntVal*)(*block);
  180705        2001 :           for (unsigned i = 0; i < SgUnsignedIntVal::pool_size; ++i )
  180706             :              {
  180707             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  180708             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  180709             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  180710             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  180711             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  180712             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  180713             :             // properly; so this will have to be checked next.
  180714             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  180715             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  180716        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  180717             :                   {
  180718           8 :                     pointer[i].set_freepointer((SgUnsignedIntVal*)(globalIndex));
  180719           8 :                     globalIndex++;
  180720             :                   }
  180721             :                else
  180722             :                   {
  180723        1992 :                     pointer[i].set_freepointer(NULL);
  180724             :                   }
  180725             :               }
  180726             :         }
  180727           5 :      return globalIndex;
  180728             :    }
  180729             : 
  180730             : //############################################################################
  180731             : // JH (01/14/2006)
  180732             : void
  180733           5 : SgUnsignedIntVal::resetValidFreepointers( )
  180734             :    {
  180735           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  180736           5 :      SgUnsignedIntVal* pointer = NULL;
  180737           5 :      std::vector < unsigned char* > :: const_iterator block;
  180738           5 :      SgUnsignedIntVal* pointerOfLinkedList = NULL;
  180739           6 :      for ( block = SgUnsignedIntVal::pools.begin(); block != SgUnsignedIntVal::pools.end() ; ++block )
  180740             :         {
  180741           1 :           pointer = (SgUnsignedIntVal*)(*block);
  180742        2001 :           for (unsigned i = 0; i < SgUnsignedIntVal::pool_size; ++i )
  180743             :              {
  180744             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  180745             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  180746             :             // memory blocks!.
  180747        2000 :                if ( pointer[i].get_freepointer() != NULL )
  180748             :                   {
  180749           8 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  180750             :                   }
  180751             :                else
  180752             :                   {
  180753        1992 :                     if ( pointerOfLinkedList == NULL )
  180754             :                        {
  180755           1 :                          SgUnsignedIntVal::next_node = &(pointer[i]);
  180756             :                        }
  180757             :                     else
  180758             :                        {
  180759             :                       // printf ("In SgUnsignedIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  180760        1991 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  180761             :                        }
  180762             :                     pointerOfLinkedList = &(pointer[i]);
  180763             :                   }
  180764             :               }
  180765             :         }
  180766             : 
  180767           5 :      if ( pointerOfLinkedList != NULL )
  180768             :         {
  180769             :        // printf ("In SgUnsignedIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  180770           1 :           pointerOfLinkedList->set_freepointer(NULL);
  180771             :        // DQ (6/6/2010): Temporary debugging...
  180772             :        //   ROSE_ASSERT(false);
  180773             :         }
  180774             : 
  180775           5 :      return ;
  180776             :    }
  180777             : 
  180778             : //############################################################################
  180779             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  180780             :  * within the memory pool and resets the freepointers, in order to achieve a 
  180781             :  * linked list, that has no jumps and starts at the beginning! This function 
  180782             :  * does not extend the memory pool, since we do not delete any memory blocks,
  180783             :  * but delete the valid objects.  
  180784             :  */
  180785             : void
  180786           0 : SgUnsignedIntVal::clearMemoryPool( )
  180787             :    {
  180788             :   // printf ("Inside of SgUnsignedIntVal::clearMemoryPool() \n");
  180789             : 
  180790           0 :      SgUnsignedIntVal* pointer = NULL, *tempPointer = NULL;
  180791           0 :      std::vector < unsigned char* > :: const_iterator block;
  180792           0 :      if ( SgUnsignedIntVal::pools.empty() == false )
  180793             :         {
  180794           0 :           block = SgUnsignedIntVal::pools.begin() ;
  180795           0 :           SgUnsignedIntVal::next_node = (SgUnsignedIntVal*) (*block);
  180796             : 
  180797           0 :           while ( block != SgUnsignedIntVal::pools.end() )
  180798             :              {
  180799           0 :                pointer = (SgUnsignedIntVal*) (*block);
  180800           0 :                if ( tempPointer != NULL )
  180801             :                   {
  180802           0 :                     tempPointer->set_freepointer(pointer);
  180803             :                   }
  180804           0 :                for (unsigned i = 0; i < SgUnsignedIntVal::pool_size - 1; ++i)
  180805             :                   {
  180806           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  180807             :                   }
  180808           0 :                 pointer[SgUnsignedIntVal::pool_size-1].set_freepointer(NULL);
  180809           0 :                 tempPointer = &(pointer[SgUnsignedIntVal::pool_size-1]);
  180810           0 :                 ++block;
  180811             :              }
  180812             :         }
  180813           0 :    }
  180814             : 
  180815           5 : void SgUnsignedIntVal::deleteMemoryPool() {
  180816           7 :   for (auto p: SgUnsignedIntVal::pools) {
  180817           2 :     ROSE_FREE(p);
  180818             :   }
  180819           5 :   SgUnsignedIntVal::next_node = nullptr;
  180820           5 :   SgUnsignedIntVal::pools.clear();
  180821           5 : }
  180822             : 
  180823             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  180824             : //                 reading multiple binary files to for a single AST.
  180825             : /////////// new version ////////////////////////////////
  180826             : //############################################################################
  180827             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  180828             : void
  180829           2 : SgUnsignedIntVal::extendMemoryPoolForFileIO( )
  180830             :   {
  180831           2 :     size_t blockIndex = SgUnsignedIntVal::pools.size();
  180832           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedIntVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedIntVal);
  180833             : 
  180834           3 :     while ( (blockIndex * SgUnsignedIntVal::pool_size) < newPoolSize)
  180835             :       {
  180836             : #if ROSE_ALLOC_TRACE
  180837             :         if (blockIndex > 0) {
  180838             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedIntVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedIntVal) = %" PRIuPTR " SgUnsignedIntVal::pool_size = %d \n",
  180839             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedIntVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedIntVal),SgUnsignedIntVal::pool_size);
  180840             :         }
  180841             : #endif
  180842             : 
  180843           1 :         SgUnsignedIntVal * pointer = (SgUnsignedIntVal*) ROSE_MALLOC ( SgUnsignedIntVal::pool_size * sizeof(SgUnsignedIntVal) );
  180844           1 :         assert( pointer != NULL );
  180845             : #if ROSE_ALLOC_MEMSET == 1
  180846             :         memset(pointer, 0x00, SgUnsignedIntVal::pool_size * sizeof(SgUnsignedIntVal));
  180847             : #elif ROSE_ALLOC_MEMSET == 2
  180848             :         memset(pointer, 0xCC, SgUnsignedIntVal::pool_size * sizeof(SgUnsignedIntVal));
  180849             : #endif
  180850           1 :         SgUnsignedIntVal::pools.push_back( (unsigned char*)(pointer) );
  180851           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnsignedIntVal::pool_size * sizeof(SgUnsignedIntVal), V_SgUnsignedIntVal ) );
  180852             : 
  180853           1 :         if ( SgUnsignedIntVal::next_node != NULL ) {
  180854           0 :           if ( blockIndex > 0 ) {
  180855           0 :             SgUnsignedIntVal * blkptr = (SgUnsignedIntVal*)(SgUnsignedIntVal::pools[blockIndex-1]);
  180856           0 :             blkptr[ SgUnsignedIntVal::pool_size - 1 ].set_freepointer(pointer);
  180857             :           }
  180858             :         } else {
  180859           1 :           SgUnsignedIntVal::next_node = pointer;
  180860             :         }
  180861             : 
  180862        2000 :         for (unsigned i = 0; i < SgUnsignedIntVal::pool_size-1; ++i)
  180863             :            {
  180864        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  180865             :            }
  180866           1 :         pointer[ SgUnsignedIntVal::pool_size -1 ].set_freepointer(NULL);
  180867             : 
  180868           1 :         blockIndex++;
  180869             :       }
  180870           2 :   }
  180871             : 
  180872             : //############################################################################
  180873             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  180874             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  180875             :  * not compressed. However, that stuff is not yet implemented! 
  180876             :  */
  180877             : unsigned long
  180878           0 : SgUnsignedIntVal::getNumberOfLastValidPointer()
  180879             :    {
  180880           0 :       SgUnsignedIntVal* testPointer = (SgUnsignedIntVal*)(SgUnsignedIntVal::pools.back());
  180881           0 :       unsigned long localIndex = SgUnsignedIntVal::pool_size - 1;
  180882           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  180883             :          {
  180884           0 :            localIndex--;
  180885             :          }
  180886           0 :       return (localIndex + SgUnsignedIntVal::pool_size * (SgUnsignedIntVal::pools.size()-1));
  180887             :    }
  180888             : 
  180889             : //############################################################################
  180890             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  180891             :  * memory pool and initializes the data member in class SgUnsignedIntValStroageClass
  180892             :  * from its counterpart of SgUnsignedIntVal. The return value is just for checking, 
  180893             :  * that the whole StorageClassArray is initialized!
  180894             :  */
  180895             : unsigned long
  180896           1 : SgUnsignedIntVal::initializeStorageClassArray( SgUnsignedIntValStorageClass *storageArray )
  180897             :    {
  180898           1 :      unsigned long storageCounter = 0;
  180899           1 :      std::vector < unsigned char* > :: const_iterator block = SgUnsignedIntVal::pools.begin();
  180900           1 :      SgUnsignedIntVal* pointer = NULL;
  180901           2 :      while ( block != SgUnsignedIntVal::pools.end() ) {
  180902           1 :           pointer = (SgUnsignedIntVal*) (*block);
  180903        2001 :           for ( unsigned i = 0; i < SgUnsignedIntVal::pool_size; ++i ) {
  180904        2000 :                if ( pointer->get_freepointer() != NULL ) {
  180905           8 :                  storageArray->pickOutIRNodeData (pointer) ;
  180906           8 :                  storageArray++;
  180907           8 :                  storageCounter++;
  180908             :                }
  180909        2000 :                pointer++;
  180910             :              }
  180911           1 :            block++;
  180912             :         }
  180913           1 :      return storageCounter;
  180914             :    }
  180915             : 
  180916             : /* #line 180917 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  180917             : 
  180918             : 
  180919             : 
  180920             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  180921             : 
  180922             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  180923             : 
  180924             : //############################################################################
  180925             : /* JH (02/02/2006) Constructor of the IR node SgLongIntVal that takes its 
  180926             :  * corresponding StorageClass as parameter
  180927             :  */
  180928          13 : SgLongIntVal :: SgLongIntVal ( const SgLongIntValStorageClass& storageSource )   : SgValueExp (storageSource)
  180929             :    {
  180930             : 
  180931             : 
  180932             : /* #line 180933 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  180933             : 
  180934          13 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  180935          13 :      p_value = storageSource.storageOf_value ;
  180936          13 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  180937             : 
  180938             : 
  180939             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  180940             : 
  180941             : 
  180942          13 :    }
  180943             : 
  180944             : //############################################################################
  180945             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  180946             :  * within the working AST. 
  180947             :  */
  180948          52 : SgLongIntVal * SgLongIntVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  180949          52 :      SgLongIntVal* returnPointer = NULL;
  180950          52 :      if ( globalIndex != 0 )
  180951             :         {
  180952             : 
  180953             : #if FILE_IO_EXTRA_CHECK
  180954          52 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLongIntVal ) ) <= globalIndex ) ;
  180955          52 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLongIntVal + 1 ) ) );
  180956             : #endif
  180957          52 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLongIntVal )  
  180958          52 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLongIntVal );
  180959          52 :           unsigned long positionInPool = localIndex % SgLongIntVal::pool_size;
  180960          52 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLongIntVal::pool_size;
  180961             : 
  180962             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  180963             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  180964             : 
  180965          52 :           returnPointer = &( ( (SgLongIntVal*)(SgLongIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  180966             : 
  180967          52 :           ROSE_ASSERT( returnPointer != NULL ) ;
  180968             :         }
  180969          52 :      return returnPointer ;
  180970             :    }
  180971             : 
  180972             : //############################################################################
  180973             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  180974             :   for the AST with the index astIndex
  180975             : */
  180976           0 : SgLongIntVal * SgLongIntVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  180977           0 :      SgLongIntVal* returnPointer = NULL;
  180978           0 :      if ( globalIndex != 0 )
  180979             :         {
  180980             : 
  180981             : #if FILE_IO_EXTRA_CHECK
  180982           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLongIntVal ) ) <= globalIndex ) ;
  180983           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLongIntVal + 1 ) ) );
  180984             : #endif
  180985           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLongIntVal )
  180986           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLongIntVal );
  180987           0 :           unsigned long positionInPool = localIndex % SgLongIntVal::pool_size ;
  180988           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLongIntVal::pool_size ;
  180989             : 
  180990             : #if FILE_IO_EXTRA_CHECK
  180991             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  180992             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  180993             : #endif
  180994             : 
  180995           0 :           returnPointer = &( ( (SgLongIntVal*)(SgLongIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  180996             : 
  180997             : #if FILE_IO_EXTRA_CHECK
  180998           0 :           assert ( returnPointer != NULL ) ;
  180999             : #endif
  181000             :         }
  181001           0 :      return returnPointer ;
  181002             :    }
  181003             : 
  181004             : //############################################################################
  181005             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  181006             :  * pool size! We set for every valid object in the memory pool the freepointer
  181007             :  * to the global index and increase the global index afterwards. For all the 
  181008             :  * invalid objects (means address ranges within the memory pool that were not
  181009             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  181010             :  * distinguish valid from invalid objects! 
  181011             :  */
  181012             : unsigned long
  181013           5 : SgLongIntVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  181014             :    {
  181015           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  181016           5 :      SgLongIntVal* pointer = NULL;
  181017           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  181018           5 :      std::vector < unsigned char* > :: const_iterator block;
  181019           6 :      for ( block = SgLongIntVal::pools.begin(); block != SgLongIntVal::pools.end() ; ++block )
  181020             :         {
  181021           1 :           pointer = (SgLongIntVal*)(*block);
  181022        2001 :           for (unsigned i = 0; i < SgLongIntVal::pool_size; ++i )
  181023             :              {
  181024             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  181025             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  181026             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  181027             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  181028             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  181029             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  181030             :             // properly; so this will have to be checked next.
  181031             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  181032             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  181033        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  181034             :                   {
  181035          13 :                     pointer[i].set_freepointer((SgLongIntVal*)(globalIndex));
  181036          13 :                     globalIndex++;
  181037             :                   }
  181038             :                else
  181039             :                   {
  181040        1987 :                     pointer[i].set_freepointer(NULL);
  181041             :                   }
  181042             :               }
  181043             :         }
  181044           5 :      return globalIndex;
  181045             :    }
  181046             : 
  181047             : //############################################################################
  181048             : // JH (01/14/2006)
  181049             : void
  181050           5 : SgLongIntVal::resetValidFreepointers( )
  181051             :    {
  181052           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  181053           5 :      SgLongIntVal* pointer = NULL;
  181054           5 :      std::vector < unsigned char* > :: const_iterator block;
  181055           5 :      SgLongIntVal* pointerOfLinkedList = NULL;
  181056           6 :      for ( block = SgLongIntVal::pools.begin(); block != SgLongIntVal::pools.end() ; ++block )
  181057             :         {
  181058           1 :           pointer = (SgLongIntVal*)(*block);
  181059        2001 :           for (unsigned i = 0; i < SgLongIntVal::pool_size; ++i )
  181060             :              {
  181061             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  181062             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  181063             :             // memory blocks!.
  181064        2000 :                if ( pointer[i].get_freepointer() != NULL )
  181065             :                   {
  181066          13 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  181067             :                   }
  181068             :                else
  181069             :                   {
  181070        1987 :                     if ( pointerOfLinkedList == NULL )
  181071             :                        {
  181072           1 :                          SgLongIntVal::next_node = &(pointer[i]);
  181073             :                        }
  181074             :                     else
  181075             :                        {
  181076             :                       // printf ("In SgLongIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  181077        1986 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  181078             :                        }
  181079             :                     pointerOfLinkedList = &(pointer[i]);
  181080             :                   }
  181081             :               }
  181082             :         }
  181083             : 
  181084           5 :      if ( pointerOfLinkedList != NULL )
  181085             :         {
  181086             :        // printf ("In SgLongIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  181087           1 :           pointerOfLinkedList->set_freepointer(NULL);
  181088             :        // DQ (6/6/2010): Temporary debugging...
  181089             :        //   ROSE_ASSERT(false);
  181090             :         }
  181091             : 
  181092           5 :      return ;
  181093             :    }
  181094             : 
  181095             : //############################################################################
  181096             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  181097             :  * within the memory pool and resets the freepointers, in order to achieve a 
  181098             :  * linked list, that has no jumps and starts at the beginning! This function 
  181099             :  * does not extend the memory pool, since we do not delete any memory blocks,
  181100             :  * but delete the valid objects.  
  181101             :  */
  181102             : void
  181103           0 : SgLongIntVal::clearMemoryPool( )
  181104             :    {
  181105             :   // printf ("Inside of SgLongIntVal::clearMemoryPool() \n");
  181106             : 
  181107           0 :      SgLongIntVal* pointer = NULL, *tempPointer = NULL;
  181108           0 :      std::vector < unsigned char* > :: const_iterator block;
  181109           0 :      if ( SgLongIntVal::pools.empty() == false )
  181110             :         {
  181111           0 :           block = SgLongIntVal::pools.begin() ;
  181112           0 :           SgLongIntVal::next_node = (SgLongIntVal*) (*block);
  181113             : 
  181114           0 :           while ( block != SgLongIntVal::pools.end() )
  181115             :              {
  181116           0 :                pointer = (SgLongIntVal*) (*block);
  181117           0 :                if ( tempPointer != NULL )
  181118             :                   {
  181119           0 :                     tempPointer->set_freepointer(pointer);
  181120             :                   }
  181121           0 :                for (unsigned i = 0; i < SgLongIntVal::pool_size - 1; ++i)
  181122             :                   {
  181123           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  181124             :                   }
  181125           0 :                 pointer[SgLongIntVal::pool_size-1].set_freepointer(NULL);
  181126           0 :                 tempPointer = &(pointer[SgLongIntVal::pool_size-1]);
  181127           0 :                 ++block;
  181128             :              }
  181129             :         }
  181130           0 :    }
  181131             : 
  181132           5 : void SgLongIntVal::deleteMemoryPool() {
  181133           7 :   for (auto p: SgLongIntVal::pools) {
  181134           2 :     ROSE_FREE(p);
  181135             :   }
  181136           5 :   SgLongIntVal::next_node = nullptr;
  181137           5 :   SgLongIntVal::pools.clear();
  181138           5 : }
  181139             : 
  181140             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  181141             : //                 reading multiple binary files to for a single AST.
  181142             : /////////// new version ////////////////////////////////
  181143             : //############################################################################
  181144             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  181145             : void
  181146           2 : SgLongIntVal::extendMemoryPoolForFileIO( )
  181147             :   {
  181148           2 :     size_t blockIndex = SgLongIntVal::pools.size();
  181149           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLongIntVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongIntVal);
  181150             : 
  181151           3 :     while ( (blockIndex * SgLongIntVal::pool_size) < newPoolSize)
  181152             :       {
  181153             : #if ROSE_ALLOC_TRACE
  181154             :         if (blockIndex > 0) {
  181155             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLongIntVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongIntVal) = %" PRIuPTR " SgLongIntVal::pool_size = %d \n",
  181156             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLongIntVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongIntVal),SgLongIntVal::pool_size);
  181157             :         }
  181158             : #endif
  181159             : 
  181160           1 :         SgLongIntVal * pointer = (SgLongIntVal*) ROSE_MALLOC ( SgLongIntVal::pool_size * sizeof(SgLongIntVal) );
  181161           1 :         assert( pointer != NULL );
  181162             : #if ROSE_ALLOC_MEMSET == 1
  181163             :         memset(pointer, 0x00, SgLongIntVal::pool_size * sizeof(SgLongIntVal));
  181164             : #elif ROSE_ALLOC_MEMSET == 2
  181165             :         memset(pointer, 0xCC, SgLongIntVal::pool_size * sizeof(SgLongIntVal));
  181166             : #endif
  181167           1 :         SgLongIntVal::pools.push_back( (unsigned char*)(pointer) );
  181168           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLongIntVal::pool_size * sizeof(SgLongIntVal), V_SgLongIntVal ) );
  181169             : 
  181170           1 :         if ( SgLongIntVal::next_node != NULL ) {
  181171           0 :           if ( blockIndex > 0 ) {
  181172           0 :             SgLongIntVal * blkptr = (SgLongIntVal*)(SgLongIntVal::pools[blockIndex-1]);
  181173           0 :             blkptr[ SgLongIntVal::pool_size - 1 ].set_freepointer(pointer);
  181174             :           }
  181175             :         } else {
  181176           1 :           SgLongIntVal::next_node = pointer;
  181177             :         }
  181178             : 
  181179        2000 :         for (unsigned i = 0; i < SgLongIntVal::pool_size-1; ++i)
  181180             :            {
  181181        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  181182             :            }
  181183           1 :         pointer[ SgLongIntVal::pool_size -1 ].set_freepointer(NULL);
  181184             : 
  181185           1 :         blockIndex++;
  181186             :       }
  181187           2 :   }
  181188             : 
  181189             : //############################################################################
  181190             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  181191             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  181192             :  * not compressed. However, that stuff is not yet implemented! 
  181193             :  */
  181194             : unsigned long
  181195           0 : SgLongIntVal::getNumberOfLastValidPointer()
  181196             :    {
  181197           0 :       SgLongIntVal* testPointer = (SgLongIntVal*)(SgLongIntVal::pools.back());
  181198           0 :       unsigned long localIndex = SgLongIntVal::pool_size - 1;
  181199           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  181200             :          {
  181201           0 :            localIndex--;
  181202             :          }
  181203           0 :       return (localIndex + SgLongIntVal::pool_size * (SgLongIntVal::pools.size()-1));
  181204             :    }
  181205             : 
  181206             : //############################################################################
  181207             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  181208             :  * memory pool and initializes the data member in class SgLongIntValStroageClass
  181209             :  * from its counterpart of SgLongIntVal. The return value is just for checking, 
  181210             :  * that the whole StorageClassArray is initialized!
  181211             :  */
  181212             : unsigned long
  181213           1 : SgLongIntVal::initializeStorageClassArray( SgLongIntValStorageClass *storageArray )
  181214             :    {
  181215           1 :      unsigned long storageCounter = 0;
  181216           1 :      std::vector < unsigned char* > :: const_iterator block = SgLongIntVal::pools.begin();
  181217           1 :      SgLongIntVal* pointer = NULL;
  181218           2 :      while ( block != SgLongIntVal::pools.end() ) {
  181219           1 :           pointer = (SgLongIntVal*) (*block);
  181220        2001 :           for ( unsigned i = 0; i < SgLongIntVal::pool_size; ++i ) {
  181221        2000 :                if ( pointer->get_freepointer() != NULL ) {
  181222          13 :                  storageArray->pickOutIRNodeData (pointer) ;
  181223          13 :                  storageArray++;
  181224          13 :                  storageCounter++;
  181225             :                }
  181226        2000 :                pointer++;
  181227             :              }
  181228           1 :            block++;
  181229             :         }
  181230           1 :      return storageCounter;
  181231             :    }
  181232             : 
  181233             : /* #line 181234 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  181234             : 
  181235             : 
  181236             : 
  181237             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  181238             : 
  181239             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  181240             : 
  181241             : //############################################################################
  181242             : /* JH (02/02/2006) Constructor of the IR node SgLongLongIntVal that takes its 
  181243             :  * corresponding StorageClass as parameter
  181244             :  */
  181245           0 : SgLongLongIntVal :: SgLongLongIntVal ( const SgLongLongIntValStorageClass& storageSource )   : SgValueExp (storageSource)
  181246             :    {
  181247             : 
  181248             : 
  181249             : /* #line 181250 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  181250             : 
  181251           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  181252           0 :      p_value = storageSource.storageOf_value ;
  181253           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  181254             : 
  181255             : 
  181256             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  181257             : 
  181258             : 
  181259           0 :    }
  181260             : 
  181261             : //############################################################################
  181262             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  181263             :  * within the working AST. 
  181264             :  */
  181265           0 : SgLongLongIntVal * SgLongLongIntVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  181266           0 :      SgLongLongIntVal* returnPointer = NULL;
  181267           0 :      if ( globalIndex != 0 )
  181268             :         {
  181269             : 
  181270             : #if FILE_IO_EXTRA_CHECK
  181271           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLongLongIntVal ) ) <= globalIndex ) ;
  181272           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLongLongIntVal + 1 ) ) );
  181273             : #endif
  181274           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLongLongIntVal )  
  181275           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLongLongIntVal );
  181276           0 :           unsigned long positionInPool = localIndex % SgLongLongIntVal::pool_size;
  181277           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLongLongIntVal::pool_size;
  181278             : 
  181279             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  181280             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  181281             : 
  181282           0 :           returnPointer = &( ( (SgLongLongIntVal*)(SgLongLongIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  181283             : 
  181284           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  181285             :         }
  181286           0 :      return returnPointer ;
  181287             :    }
  181288             : 
  181289             : //############################################################################
  181290             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  181291             :   for the AST with the index astIndex
  181292             : */
  181293           0 : SgLongLongIntVal * SgLongLongIntVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  181294           0 :      SgLongLongIntVal* returnPointer = NULL;
  181295           0 :      if ( globalIndex != 0 )
  181296             :         {
  181297             : 
  181298             : #if FILE_IO_EXTRA_CHECK
  181299           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLongLongIntVal ) ) <= globalIndex ) ;
  181300           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLongLongIntVal + 1 ) ) );
  181301             : #endif
  181302           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLongLongIntVal )
  181303           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLongLongIntVal );
  181304           0 :           unsigned long positionInPool = localIndex % SgLongLongIntVal::pool_size ;
  181305           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLongLongIntVal::pool_size ;
  181306             : 
  181307             : #if FILE_IO_EXTRA_CHECK
  181308             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  181309             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  181310             : #endif
  181311             : 
  181312           0 :           returnPointer = &( ( (SgLongLongIntVal*)(SgLongLongIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  181313             : 
  181314             : #if FILE_IO_EXTRA_CHECK
  181315           0 :           assert ( returnPointer != NULL ) ;
  181316             : #endif
  181317             :         }
  181318           0 :      return returnPointer ;
  181319             :    }
  181320             : 
  181321             : //############################################################################
  181322             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  181323             :  * pool size! We set for every valid object in the memory pool the freepointer
  181324             :  * to the global index and increase the global index afterwards. For all the 
  181325             :  * invalid objects (means address ranges within the memory pool that were not
  181326             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  181327             :  * distinguish valid from invalid objects! 
  181328             :  */
  181329             : unsigned long
  181330           5 : SgLongLongIntVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  181331             :    {
  181332           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  181333           5 :      SgLongLongIntVal* pointer = NULL;
  181334           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  181335           5 :      std::vector < unsigned char* > :: const_iterator block;
  181336           6 :      for ( block = SgLongLongIntVal::pools.begin(); block != SgLongLongIntVal::pools.end() ; ++block )
  181337             :         {
  181338           1 :           pointer = (SgLongLongIntVal*)(*block);
  181339        2001 :           for (unsigned i = 0; i < SgLongLongIntVal::pool_size; ++i )
  181340             :              {
  181341             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  181342             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  181343             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  181344             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  181345             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  181346             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  181347             :             // properly; so this will have to be checked next.
  181348             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  181349             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  181350        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  181351             :                   {
  181352           0 :                     pointer[i].set_freepointer((SgLongLongIntVal*)(globalIndex));
  181353           0 :                     globalIndex++;
  181354             :                   }
  181355             :                else
  181356             :                   {
  181357        2000 :                     pointer[i].set_freepointer(NULL);
  181358             :                   }
  181359             :               }
  181360             :         }
  181361           5 :      return globalIndex;
  181362             :    }
  181363             : 
  181364             : //############################################################################
  181365             : // JH (01/14/2006)
  181366             : void
  181367           5 : SgLongLongIntVal::resetValidFreepointers( )
  181368             :    {
  181369           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  181370           5 :      SgLongLongIntVal* pointer = NULL;
  181371           5 :      std::vector < unsigned char* > :: const_iterator block;
  181372           5 :      SgLongLongIntVal* pointerOfLinkedList = NULL;
  181373           6 :      for ( block = SgLongLongIntVal::pools.begin(); block != SgLongLongIntVal::pools.end() ; ++block )
  181374             :         {
  181375           1 :           pointer = (SgLongLongIntVal*)(*block);
  181376        2001 :           for (unsigned i = 0; i < SgLongLongIntVal::pool_size; ++i )
  181377             :              {
  181378             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  181379             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  181380             :             // memory blocks!.
  181381        2000 :                if ( pointer[i].get_freepointer() != NULL )
  181382             :                   {
  181383           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  181384             :                   }
  181385             :                else
  181386             :                   {
  181387        2000 :                     if ( pointerOfLinkedList == NULL )
  181388             :                        {
  181389           1 :                          SgLongLongIntVal::next_node = &(pointer[i]);
  181390             :                        }
  181391             :                     else
  181392             :                        {
  181393             :                       // printf ("In SgLongLongIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  181394        1999 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  181395             :                        }
  181396             :                     pointerOfLinkedList = &(pointer[i]);
  181397             :                   }
  181398             :               }
  181399             :         }
  181400             : 
  181401           5 :      if ( pointerOfLinkedList != NULL )
  181402             :         {
  181403             :        // printf ("In SgLongLongIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  181404           1 :           pointerOfLinkedList->set_freepointer(NULL);
  181405             :        // DQ (6/6/2010): Temporary debugging...
  181406             :        //   ROSE_ASSERT(false);
  181407             :         }
  181408             : 
  181409           5 :      return ;
  181410             :    }
  181411             : 
  181412             : //############################################################################
  181413             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  181414             :  * within the memory pool and resets the freepointers, in order to achieve a 
  181415             :  * linked list, that has no jumps and starts at the beginning! This function 
  181416             :  * does not extend the memory pool, since we do not delete any memory blocks,
  181417             :  * but delete the valid objects.  
  181418             :  */
  181419             : void
  181420           0 : SgLongLongIntVal::clearMemoryPool( )
  181421             :    {
  181422             :   // printf ("Inside of SgLongLongIntVal::clearMemoryPool() \n");
  181423             : 
  181424           0 :      SgLongLongIntVal* pointer = NULL, *tempPointer = NULL;
  181425           0 :      std::vector < unsigned char* > :: const_iterator block;
  181426           0 :      if ( SgLongLongIntVal::pools.empty() == false )
  181427             :         {
  181428           0 :           block = SgLongLongIntVal::pools.begin() ;
  181429           0 :           SgLongLongIntVal::next_node = (SgLongLongIntVal*) (*block);
  181430             : 
  181431           0 :           while ( block != SgLongLongIntVal::pools.end() )
  181432             :              {
  181433           0 :                pointer = (SgLongLongIntVal*) (*block);
  181434           0 :                if ( tempPointer != NULL )
  181435             :                   {
  181436           0 :                     tempPointer->set_freepointer(pointer);
  181437             :                   }
  181438           0 :                for (unsigned i = 0; i < SgLongLongIntVal::pool_size - 1; ++i)
  181439             :                   {
  181440           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  181441             :                   }
  181442           0 :                 pointer[SgLongLongIntVal::pool_size-1].set_freepointer(NULL);
  181443           0 :                 tempPointer = &(pointer[SgLongLongIntVal::pool_size-1]);
  181444           0 :                 ++block;
  181445             :              }
  181446             :         }
  181447           0 :    }
  181448             : 
  181449           5 : void SgLongLongIntVal::deleteMemoryPool() {
  181450           6 :   for (auto p: SgLongLongIntVal::pools) {
  181451           1 :     ROSE_FREE(p);
  181452             :   }
  181453           5 :   SgLongLongIntVal::next_node = nullptr;
  181454           5 :   SgLongLongIntVal::pools.clear();
  181455           5 : }
  181456             : 
  181457             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  181458             : //                 reading multiple binary files to for a single AST.
  181459             : /////////// new version ////////////////////////////////
  181460             : //############################################################################
  181461             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  181462             : void
  181463           2 : SgLongLongIntVal::extendMemoryPoolForFileIO( )
  181464             :   {
  181465           2 :     size_t blockIndex = SgLongLongIntVal::pools.size();
  181466           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLongLongIntVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongLongIntVal);
  181467             : 
  181468           2 :     while ( (blockIndex * SgLongLongIntVal::pool_size) < newPoolSize)
  181469             :       {
  181470             : #if ROSE_ALLOC_TRACE
  181471             :         if (blockIndex > 0) {
  181472             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLongLongIntVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongLongIntVal) = %" PRIuPTR " SgLongLongIntVal::pool_size = %d \n",
  181473             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLongLongIntVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongLongIntVal),SgLongLongIntVal::pool_size);
  181474             :         }
  181475             : #endif
  181476             : 
  181477           0 :         SgLongLongIntVal * pointer = (SgLongLongIntVal*) ROSE_MALLOC ( SgLongLongIntVal::pool_size * sizeof(SgLongLongIntVal) );
  181478           0 :         assert( pointer != NULL );
  181479             : #if ROSE_ALLOC_MEMSET == 1
  181480             :         memset(pointer, 0x00, SgLongLongIntVal::pool_size * sizeof(SgLongLongIntVal));
  181481             : #elif ROSE_ALLOC_MEMSET == 2
  181482             :         memset(pointer, 0xCC, SgLongLongIntVal::pool_size * sizeof(SgLongLongIntVal));
  181483             : #endif
  181484           0 :         SgLongLongIntVal::pools.push_back( (unsigned char*)(pointer) );
  181485           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLongLongIntVal::pool_size * sizeof(SgLongLongIntVal), V_SgLongLongIntVal ) );
  181486             : 
  181487           0 :         if ( SgLongLongIntVal::next_node != NULL ) {
  181488           0 :           if ( blockIndex > 0 ) {
  181489           0 :             SgLongLongIntVal * blkptr = (SgLongLongIntVal*)(SgLongLongIntVal::pools[blockIndex-1]);
  181490           0 :             blkptr[ SgLongLongIntVal::pool_size - 1 ].set_freepointer(pointer);
  181491             :           }
  181492             :         } else {
  181493           0 :           SgLongLongIntVal::next_node = pointer;
  181494             :         }
  181495             : 
  181496           0 :         for (unsigned i = 0; i < SgLongLongIntVal::pool_size-1; ++i)
  181497             :            {
  181498           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  181499             :            }
  181500           0 :         pointer[ SgLongLongIntVal::pool_size -1 ].set_freepointer(NULL);
  181501             : 
  181502           0 :         blockIndex++;
  181503             :       }
  181504           2 :   }
  181505             : 
  181506             : //############################################################################
  181507             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  181508             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  181509             :  * not compressed. However, that stuff is not yet implemented! 
  181510             :  */
  181511             : unsigned long
  181512           0 : SgLongLongIntVal::getNumberOfLastValidPointer()
  181513             :    {
  181514           0 :       SgLongLongIntVal* testPointer = (SgLongLongIntVal*)(SgLongLongIntVal::pools.back());
  181515           0 :       unsigned long localIndex = SgLongLongIntVal::pool_size - 1;
  181516           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  181517             :          {
  181518           0 :            localIndex--;
  181519             :          }
  181520           0 :       return (localIndex + SgLongLongIntVal::pool_size * (SgLongLongIntVal::pools.size()-1));
  181521             :    }
  181522             : 
  181523             : //############################################################################
  181524             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  181525             :  * memory pool and initializes the data member in class SgLongLongIntValStroageClass
  181526             :  * from its counterpart of SgLongLongIntVal. The return value is just for checking, 
  181527             :  * that the whole StorageClassArray is initialized!
  181528             :  */
  181529             : unsigned long
  181530           0 : SgLongLongIntVal::initializeStorageClassArray( SgLongLongIntValStorageClass *storageArray )
  181531             :    {
  181532           0 :      unsigned long storageCounter = 0;
  181533           0 :      std::vector < unsigned char* > :: const_iterator block = SgLongLongIntVal::pools.begin();
  181534           0 :      SgLongLongIntVal* pointer = NULL;
  181535           0 :      while ( block != SgLongLongIntVal::pools.end() ) {
  181536           0 :           pointer = (SgLongLongIntVal*) (*block);
  181537           0 :           for ( unsigned i = 0; i < SgLongLongIntVal::pool_size; ++i ) {
  181538           0 :                if ( pointer->get_freepointer() != NULL ) {
  181539           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  181540           0 :                  storageArray++;
  181541           0 :                  storageCounter++;
  181542             :                }
  181543           0 :                pointer++;
  181544             :              }
  181545           0 :            block++;
  181546             :         }
  181547           0 :      return storageCounter;
  181548             :    }
  181549             : 
  181550             : /* #line 181551 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  181551             : 
  181552             : 
  181553             : 
  181554             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  181555             : 
  181556             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  181557             : 
  181558             : //############################################################################
  181559             : /* JH (02/02/2006) Constructor of the IR node SgUnsignedLongLongIntVal that takes its 
  181560             :  * corresponding StorageClass as parameter
  181561             :  */
  181562           0 : SgUnsignedLongLongIntVal :: SgUnsignedLongLongIntVal ( const SgUnsignedLongLongIntValStorageClass& storageSource )   : SgValueExp (storageSource)
  181563             :    {
  181564             : 
  181565             : 
  181566             : /* #line 181567 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  181567             : 
  181568           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  181569           0 :      p_value = storageSource.storageOf_value ;
  181570           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  181571             : 
  181572             : 
  181573             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  181574             : 
  181575             : 
  181576           0 :    }
  181577             : 
  181578             : //############################################################################
  181579             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  181580             :  * within the working AST. 
  181581             :  */
  181582           0 : SgUnsignedLongLongIntVal * SgUnsignedLongLongIntVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  181583           0 :      SgUnsignedLongLongIntVal* returnPointer = NULL;
  181584           0 :      if ( globalIndex != 0 )
  181585             :         {
  181586             : 
  181587             : #if FILE_IO_EXTRA_CHECK
  181588           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnsignedLongLongIntVal ) ) <= globalIndex ) ;
  181589           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedLongLongIntVal + 1 ) ) );
  181590             : #endif
  181591           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedLongLongIntVal )  
  181592           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnsignedLongLongIntVal );
  181593           0 :           unsigned long positionInPool = localIndex % SgUnsignedLongLongIntVal::pool_size;
  181594           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedLongLongIntVal::pool_size;
  181595             : 
  181596             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  181597             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  181598             : 
  181599           0 :           returnPointer = &( ( (SgUnsignedLongLongIntVal*)(SgUnsignedLongLongIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  181600             : 
  181601           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  181602             :         }
  181603           0 :      return returnPointer ;
  181604             :    }
  181605             : 
  181606             : //############################################################################
  181607             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  181608             :   for the AST with the index astIndex
  181609             : */
  181610           0 : SgUnsignedLongLongIntVal * SgUnsignedLongLongIntVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  181611           0 :      SgUnsignedLongLongIntVal* returnPointer = NULL;
  181612           0 :      if ( globalIndex != 0 )
  181613             :         {
  181614             : 
  181615             : #if FILE_IO_EXTRA_CHECK
  181616           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnsignedLongLongIntVal ) ) <= globalIndex ) ;
  181617           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedLongLongIntVal + 1 ) ) );
  181618             : #endif
  181619           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedLongLongIntVal )
  181620           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnsignedLongLongIntVal );
  181621           0 :           unsigned long positionInPool = localIndex % SgUnsignedLongLongIntVal::pool_size ;
  181622           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedLongLongIntVal::pool_size ;
  181623             : 
  181624             : #if FILE_IO_EXTRA_CHECK
  181625             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  181626             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  181627             : #endif
  181628             : 
  181629           0 :           returnPointer = &( ( (SgUnsignedLongLongIntVal*)(SgUnsignedLongLongIntVal::pools[memoryBlock]) ) [positionInPool]) ;
  181630             : 
  181631             : #if FILE_IO_EXTRA_CHECK
  181632           0 :           assert ( returnPointer != NULL ) ;
  181633             : #endif
  181634             :         }
  181635           0 :      return returnPointer ;
  181636             :    }
  181637             : 
  181638             : //############################################################################
  181639             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  181640             :  * pool size! We set for every valid object in the memory pool the freepointer
  181641             :  * to the global index and increase the global index afterwards. For all the 
  181642             :  * invalid objects (means address ranges within the memory pool that were not
  181643             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  181644             :  * distinguish valid from invalid objects! 
  181645             :  */
  181646             : unsigned long
  181647           5 : SgUnsignedLongLongIntVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  181648             :    {
  181649           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  181650           5 :      SgUnsignedLongLongIntVal* pointer = NULL;
  181651           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  181652           5 :      std::vector < unsigned char* > :: const_iterator block;
  181653           6 :      for ( block = SgUnsignedLongLongIntVal::pools.begin(); block != SgUnsignedLongLongIntVal::pools.end() ; ++block )
  181654             :         {
  181655           1 :           pointer = (SgUnsignedLongLongIntVal*)(*block);
  181656        2001 :           for (unsigned i = 0; i < SgUnsignedLongLongIntVal::pool_size; ++i )
  181657             :              {
  181658             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  181659             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  181660             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  181661             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  181662             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  181663             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  181664             :             // properly; so this will have to be checked next.
  181665             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  181666             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  181667        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  181668             :                   {
  181669           0 :                     pointer[i].set_freepointer((SgUnsignedLongLongIntVal*)(globalIndex));
  181670           0 :                     globalIndex++;
  181671             :                   }
  181672             :                else
  181673             :                   {
  181674        2000 :                     pointer[i].set_freepointer(NULL);
  181675             :                   }
  181676             :               }
  181677             :         }
  181678           5 :      return globalIndex;
  181679             :    }
  181680             : 
  181681             : //############################################################################
  181682             : // JH (01/14/2006)
  181683             : void
  181684           5 : SgUnsignedLongLongIntVal::resetValidFreepointers( )
  181685             :    {
  181686           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  181687           5 :      SgUnsignedLongLongIntVal* pointer = NULL;
  181688           5 :      std::vector < unsigned char* > :: const_iterator block;
  181689           5 :      SgUnsignedLongLongIntVal* pointerOfLinkedList = NULL;
  181690           6 :      for ( block = SgUnsignedLongLongIntVal::pools.begin(); block != SgUnsignedLongLongIntVal::pools.end() ; ++block )
  181691             :         {
  181692           1 :           pointer = (SgUnsignedLongLongIntVal*)(*block);
  181693        2001 :           for (unsigned i = 0; i < SgUnsignedLongLongIntVal::pool_size; ++i )
  181694             :              {
  181695             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  181696             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  181697             :             // memory blocks!.
  181698        2000 :                if ( pointer[i].get_freepointer() != NULL )
  181699             :                   {
  181700           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  181701             :                   }
  181702             :                else
  181703             :                   {
  181704        2000 :                     if ( pointerOfLinkedList == NULL )
  181705             :                        {
  181706           1 :                          SgUnsignedLongLongIntVal::next_node = &(pointer[i]);
  181707             :                        }
  181708             :                     else
  181709             :                        {
  181710             :                       // printf ("In SgUnsignedLongLongIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  181711        1999 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  181712             :                        }
  181713             :                     pointerOfLinkedList = &(pointer[i]);
  181714             :                   }
  181715             :               }
  181716             :         }
  181717             : 
  181718           5 :      if ( pointerOfLinkedList != NULL )
  181719             :         {
  181720             :        // printf ("In SgUnsignedLongLongIntVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  181721           1 :           pointerOfLinkedList->set_freepointer(NULL);
  181722             :        // DQ (6/6/2010): Temporary debugging...
  181723             :        //   ROSE_ASSERT(false);
  181724             :         }
  181725             : 
  181726           5 :      return ;
  181727             :    }
  181728             : 
  181729             : //############################################################################
  181730             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  181731             :  * within the memory pool and resets the freepointers, in order to achieve a 
  181732             :  * linked list, that has no jumps and starts at the beginning! This function 
  181733             :  * does not extend the memory pool, since we do not delete any memory blocks,
  181734             :  * but delete the valid objects.  
  181735             :  */
  181736             : void
  181737           0 : SgUnsignedLongLongIntVal::clearMemoryPool( )
  181738             :    {
  181739             :   // printf ("Inside of SgUnsignedLongLongIntVal::clearMemoryPool() \n");
  181740             : 
  181741           0 :      SgUnsignedLongLongIntVal* pointer = NULL, *tempPointer = NULL;
  181742           0 :      std::vector < unsigned char* > :: const_iterator block;
  181743           0 :      if ( SgUnsignedLongLongIntVal::pools.empty() == false )
  181744             :         {
  181745           0 :           block = SgUnsignedLongLongIntVal::pools.begin() ;
  181746           0 :           SgUnsignedLongLongIntVal::next_node = (SgUnsignedLongLongIntVal*) (*block);
  181747             : 
  181748           0 :           while ( block != SgUnsignedLongLongIntVal::pools.end() )
  181749             :              {
  181750           0 :                pointer = (SgUnsignedLongLongIntVal*) (*block);
  181751           0 :                if ( tempPointer != NULL )
  181752             :                   {
  181753           0 :                     tempPointer->set_freepointer(pointer);
  181754             :                   }
  181755           0 :                for (unsigned i = 0; i < SgUnsignedLongLongIntVal::pool_size - 1; ++i)
  181756             :                   {
  181757           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  181758             :                   }
  181759           0 :                 pointer[SgUnsignedLongLongIntVal::pool_size-1].set_freepointer(NULL);
  181760           0 :                 tempPointer = &(pointer[SgUnsignedLongLongIntVal::pool_size-1]);
  181761           0 :                 ++block;
  181762             :              }
  181763             :         }
  181764           0 :    }
  181765             : 
  181766           5 : void SgUnsignedLongLongIntVal::deleteMemoryPool() {
  181767           6 :   for (auto p: SgUnsignedLongLongIntVal::pools) {
  181768           1 :     ROSE_FREE(p);
  181769             :   }
  181770           5 :   SgUnsignedLongLongIntVal::next_node = nullptr;
  181771           5 :   SgUnsignedLongLongIntVal::pools.clear();
  181772           5 : }
  181773             : 
  181774             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  181775             : //                 reading multiple binary files to for a single AST.
  181776             : /////////// new version ////////////////////////////////
  181777             : //############################################################################
  181778             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  181779             : void
  181780           2 : SgUnsignedLongLongIntVal::extendMemoryPoolForFileIO( )
  181781             :   {
  181782           2 :     size_t blockIndex = SgUnsignedLongLongIntVal::pools.size();
  181783           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedLongLongIntVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedLongLongIntVal);
  181784             : 
  181785           2 :     while ( (blockIndex * SgUnsignedLongLongIntVal::pool_size) < newPoolSize)
  181786             :       {
  181787             : #if ROSE_ALLOC_TRACE
  181788             :         if (blockIndex > 0) {
  181789             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedLongLongIntVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedLongLongIntVal) = %" PRIuPTR " SgUnsignedLongLongIntVal::pool_size = %d \n",
  181790             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedLongLongIntVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedLongLongIntVal),SgUnsignedLongLongIntVal::pool_size);
  181791             :         }
  181792             : #endif
  181793             : 
  181794           0 :         SgUnsignedLongLongIntVal * pointer = (SgUnsignedLongLongIntVal*) ROSE_MALLOC ( SgUnsignedLongLongIntVal::pool_size * sizeof(SgUnsignedLongLongIntVal) );
  181795           0 :         assert( pointer != NULL );
  181796             : #if ROSE_ALLOC_MEMSET == 1
  181797             :         memset(pointer, 0x00, SgUnsignedLongLongIntVal::pool_size * sizeof(SgUnsignedLongLongIntVal));
  181798             : #elif ROSE_ALLOC_MEMSET == 2
  181799             :         memset(pointer, 0xCC, SgUnsignedLongLongIntVal::pool_size * sizeof(SgUnsignedLongLongIntVal));
  181800             : #endif
  181801           0 :         SgUnsignedLongLongIntVal::pools.push_back( (unsigned char*)(pointer) );
  181802           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnsignedLongLongIntVal::pool_size * sizeof(SgUnsignedLongLongIntVal), V_SgUnsignedLongLongIntVal ) );
  181803             : 
  181804           0 :         if ( SgUnsignedLongLongIntVal::next_node != NULL ) {
  181805           0 :           if ( blockIndex > 0 ) {
  181806           0 :             SgUnsignedLongLongIntVal * blkptr = (SgUnsignedLongLongIntVal*)(SgUnsignedLongLongIntVal::pools[blockIndex-1]);
  181807           0 :             blkptr[ SgUnsignedLongLongIntVal::pool_size - 1 ].set_freepointer(pointer);
  181808             :           }
  181809             :         } else {
  181810           0 :           SgUnsignedLongLongIntVal::next_node = pointer;
  181811             :         }
  181812             : 
  181813           0 :         for (unsigned i = 0; i < SgUnsignedLongLongIntVal::pool_size-1; ++i)
  181814             :            {
  181815           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  181816             :            }
  181817           0 :         pointer[ SgUnsignedLongLongIntVal::pool_size -1 ].set_freepointer(NULL);
  181818             : 
  181819           0 :         blockIndex++;
  181820             :       }
  181821           2 :   }
  181822             : 
  181823             : //############################################################################
  181824             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  181825             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  181826             :  * not compressed. However, that stuff is not yet implemented! 
  181827             :  */
  181828             : unsigned long
  181829           0 : SgUnsignedLongLongIntVal::getNumberOfLastValidPointer()
  181830             :    {
  181831           0 :       SgUnsignedLongLongIntVal* testPointer = (SgUnsignedLongLongIntVal*)(SgUnsignedLongLongIntVal::pools.back());
  181832           0 :       unsigned long localIndex = SgUnsignedLongLongIntVal::pool_size - 1;
  181833           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  181834             :          {
  181835           0 :            localIndex--;
  181836             :          }
  181837           0 :       return (localIndex + SgUnsignedLongLongIntVal::pool_size * (SgUnsignedLongLongIntVal::pools.size()-1));
  181838             :    }
  181839             : 
  181840             : //############################################################################
  181841             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  181842             :  * memory pool and initializes the data member in class SgUnsignedLongLongIntValStroageClass
  181843             :  * from its counterpart of SgUnsignedLongLongIntVal. The return value is just for checking, 
  181844             :  * that the whole StorageClassArray is initialized!
  181845             :  */
  181846             : unsigned long
  181847           0 : SgUnsignedLongLongIntVal::initializeStorageClassArray( SgUnsignedLongLongIntValStorageClass *storageArray )
  181848             :    {
  181849           0 :      unsigned long storageCounter = 0;
  181850           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnsignedLongLongIntVal::pools.begin();
  181851           0 :      SgUnsignedLongLongIntVal* pointer = NULL;
  181852           0 :      while ( block != SgUnsignedLongLongIntVal::pools.end() ) {
  181853           0 :           pointer = (SgUnsignedLongLongIntVal*) (*block);
  181854           0 :           for ( unsigned i = 0; i < SgUnsignedLongLongIntVal::pool_size; ++i ) {
  181855           0 :                if ( pointer->get_freepointer() != NULL ) {
  181856           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  181857           0 :                  storageArray++;
  181858           0 :                  storageCounter++;
  181859             :                }
  181860           0 :                pointer++;
  181861             :              }
  181862           0 :            block++;
  181863             :         }
  181864           0 :      return storageCounter;
  181865             :    }
  181866             : 
  181867             : /* #line 181868 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  181868             : 
  181869             : 
  181870             : 
  181871             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  181872             : 
  181873             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  181874             : 
  181875             : //############################################################################
  181876             : /* JH (02/02/2006) Constructor of the IR node SgUnsignedLongVal that takes its 
  181877             :  * corresponding StorageClass as parameter
  181878             :  */
  181879          19 : SgUnsignedLongVal :: SgUnsignedLongVal ( const SgUnsignedLongValStorageClass& storageSource )   : SgValueExp (storageSource)
  181880             :    {
  181881             : 
  181882             : 
  181883             : /* #line 181884 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  181884             : 
  181885          19 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  181886          19 :      p_value = storageSource.storageOf_value ;
  181887          19 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  181888             : 
  181889             : 
  181890             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  181891             : 
  181892             : 
  181893          19 :    }
  181894             : 
  181895             : //############################################################################
  181896             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  181897             :  * within the working AST. 
  181898             :  */
  181899          87 : SgUnsignedLongVal * SgUnsignedLongVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  181900          87 :      SgUnsignedLongVal* returnPointer = NULL;
  181901          87 :      if ( globalIndex != 0 )
  181902             :         {
  181903             : 
  181904             : #if FILE_IO_EXTRA_CHECK
  181905          87 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnsignedLongVal ) ) <= globalIndex ) ;
  181906          87 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedLongVal + 1 ) ) );
  181907             : #endif
  181908          87 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnsignedLongVal )  
  181909          87 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnsignedLongVal );
  181910          87 :           unsigned long positionInPool = localIndex % SgUnsignedLongVal::pool_size;
  181911          87 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedLongVal::pool_size;
  181912             : 
  181913             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  181914             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  181915             : 
  181916          87 :           returnPointer = &( ( (SgUnsignedLongVal*)(SgUnsignedLongVal::pools[memoryBlock]) ) [positionInPool]) ;
  181917             : 
  181918          87 :           ROSE_ASSERT( returnPointer != NULL ) ;
  181919             :         }
  181920          87 :      return returnPointer ;
  181921             :    }
  181922             : 
  181923             : //############################################################################
  181924             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  181925             :   for the AST with the index astIndex
  181926             : */
  181927           0 : SgUnsignedLongVal * SgUnsignedLongVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  181928           0 :      SgUnsignedLongVal* returnPointer = NULL;
  181929           0 :      if ( globalIndex != 0 )
  181930             :         {
  181931             : 
  181932             : #if FILE_IO_EXTRA_CHECK
  181933           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnsignedLongVal ) ) <= globalIndex ) ;
  181934           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedLongVal + 1 ) ) );
  181935             : #endif
  181936           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnsignedLongVal )
  181937           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnsignedLongVal );
  181938           0 :           unsigned long positionInPool = localIndex % SgUnsignedLongVal::pool_size ;
  181939           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnsignedLongVal::pool_size ;
  181940             : 
  181941             : #if FILE_IO_EXTRA_CHECK
  181942             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  181943             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  181944             : #endif
  181945             : 
  181946           0 :           returnPointer = &( ( (SgUnsignedLongVal*)(SgUnsignedLongVal::pools[memoryBlock]) ) [positionInPool]) ;
  181947             : 
  181948             : #if FILE_IO_EXTRA_CHECK
  181949           0 :           assert ( returnPointer != NULL ) ;
  181950             : #endif
  181951             :         }
  181952           0 :      return returnPointer ;
  181953             :    }
  181954             : 
  181955             : //############################################################################
  181956             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  181957             :  * pool size! We set for every valid object in the memory pool the freepointer
  181958             :  * to the global index and increase the global index afterwards. For all the 
  181959             :  * invalid objects (means address ranges within the memory pool that were not
  181960             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  181961             :  * distinguish valid from invalid objects! 
  181962             :  */
  181963             : unsigned long
  181964           5 : SgUnsignedLongVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  181965             :    {
  181966           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  181967           5 :      SgUnsignedLongVal* pointer = NULL;
  181968           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  181969           5 :      std::vector < unsigned char* > :: const_iterator block;
  181970           7 :      for ( block = SgUnsignedLongVal::pools.begin(); block != SgUnsignedLongVal::pools.end() ; ++block )
  181971             :         {
  181972           2 :           pointer = (SgUnsignedLongVal*)(*block);
  181973        4002 :           for (unsigned i = 0; i < SgUnsignedLongVal::pool_size; ++i )
  181974             :              {
  181975             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  181976             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  181977             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  181978             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  181979             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  181980             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  181981             :             // properly; so this will have to be checked next.
  181982             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  181983             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  181984        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  181985             :                   {
  181986          19 :                     pointer[i].set_freepointer((SgUnsignedLongVal*)(globalIndex));
  181987          19 :                     globalIndex++;
  181988             :                   }
  181989             :                else
  181990             :                   {
  181991        3981 :                     pointer[i].set_freepointer(NULL);
  181992             :                   }
  181993             :               }
  181994             :         }
  181995           5 :      return globalIndex;
  181996             :    }
  181997             : 
  181998             : //############################################################################
  181999             : // JH (01/14/2006)
  182000             : void
  182001           5 : SgUnsignedLongVal::resetValidFreepointers( )
  182002             :    {
  182003           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  182004           5 :      SgUnsignedLongVal* pointer = NULL;
  182005           5 :      std::vector < unsigned char* > :: const_iterator block;
  182006           5 :      SgUnsignedLongVal* pointerOfLinkedList = NULL;
  182007           7 :      for ( block = SgUnsignedLongVal::pools.begin(); block != SgUnsignedLongVal::pools.end() ; ++block )
  182008             :         {
  182009           2 :           pointer = (SgUnsignedLongVal*)(*block);
  182010        4002 :           for (unsigned i = 0; i < SgUnsignedLongVal::pool_size; ++i )
  182011             :              {
  182012             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  182013             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  182014             :             // memory blocks!.
  182015        4000 :                if ( pointer[i].get_freepointer() != NULL )
  182016             :                   {
  182017          19 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  182018             :                   }
  182019             :                else
  182020             :                   {
  182021        3981 :                     if ( pointerOfLinkedList == NULL )
  182022             :                        {
  182023           2 :                          SgUnsignedLongVal::next_node = &(pointer[i]);
  182024             :                        }
  182025             :                     else
  182026             :                        {
  182027             :                       // printf ("In SgUnsignedLongVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  182028        3979 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  182029             :                        }
  182030             :                     pointerOfLinkedList = &(pointer[i]);
  182031             :                   }
  182032             :               }
  182033             :         }
  182034             : 
  182035           5 :      if ( pointerOfLinkedList != NULL )
  182036             :         {
  182037             :        // printf ("In SgUnsignedLongVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  182038           2 :           pointerOfLinkedList->set_freepointer(NULL);
  182039             :        // DQ (6/6/2010): Temporary debugging...
  182040             :        //   ROSE_ASSERT(false);
  182041             :         }
  182042             : 
  182043           5 :      return ;
  182044             :    }
  182045             : 
  182046             : //############################################################################
  182047             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  182048             :  * within the memory pool and resets the freepointers, in order to achieve a 
  182049             :  * linked list, that has no jumps and starts at the beginning! This function 
  182050             :  * does not extend the memory pool, since we do not delete any memory blocks,
  182051             :  * but delete the valid objects.  
  182052             :  */
  182053             : void
  182054           0 : SgUnsignedLongVal::clearMemoryPool( )
  182055             :    {
  182056             :   // printf ("Inside of SgUnsignedLongVal::clearMemoryPool() \n");
  182057             : 
  182058           0 :      SgUnsignedLongVal* pointer = NULL, *tempPointer = NULL;
  182059           0 :      std::vector < unsigned char* > :: const_iterator block;
  182060           0 :      if ( SgUnsignedLongVal::pools.empty() == false )
  182061             :         {
  182062           0 :           block = SgUnsignedLongVal::pools.begin() ;
  182063           0 :           SgUnsignedLongVal::next_node = (SgUnsignedLongVal*) (*block);
  182064             : 
  182065           0 :           while ( block != SgUnsignedLongVal::pools.end() )
  182066             :              {
  182067           0 :                pointer = (SgUnsignedLongVal*) (*block);
  182068           0 :                if ( tempPointer != NULL )
  182069             :                   {
  182070           0 :                     tempPointer->set_freepointer(pointer);
  182071             :                   }
  182072           0 :                for (unsigned i = 0; i < SgUnsignedLongVal::pool_size - 1; ++i)
  182073             :                   {
  182074           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  182075             :                   }
  182076           0 :                 pointer[SgUnsignedLongVal::pool_size-1].set_freepointer(NULL);
  182077           0 :                 tempPointer = &(pointer[SgUnsignedLongVal::pool_size-1]);
  182078           0 :                 ++block;
  182079             :              }
  182080             :         }
  182081           0 :    }
  182082             : 
  182083           5 : void SgUnsignedLongVal::deleteMemoryPool() {
  182084           8 :   for (auto p: SgUnsignedLongVal::pools) {
  182085           3 :     ROSE_FREE(p);
  182086             :   }
  182087           5 :   SgUnsignedLongVal::next_node = nullptr;
  182088           5 :   SgUnsignedLongVal::pools.clear();
  182089           5 : }
  182090             : 
  182091             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  182092             : //                 reading multiple binary files to for a single AST.
  182093             : /////////// new version ////////////////////////////////
  182094             : //############################################################################
  182095             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  182096             : void
  182097           2 : SgUnsignedLongVal::extendMemoryPoolForFileIO( )
  182098             :   {
  182099           2 :     size_t blockIndex = SgUnsignedLongVal::pools.size();
  182100           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedLongVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedLongVal);
  182101             : 
  182102           3 :     while ( (blockIndex * SgUnsignedLongVal::pool_size) < newPoolSize)
  182103             :       {
  182104             : #if ROSE_ALLOC_TRACE
  182105             :         if (blockIndex > 0) {
  182106             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedLongVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedLongVal) = %" PRIuPTR " SgUnsignedLongVal::pool_size = %d \n",
  182107             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnsignedLongVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnsignedLongVal),SgUnsignedLongVal::pool_size);
  182108             :         }
  182109             : #endif
  182110             : 
  182111           1 :         SgUnsignedLongVal * pointer = (SgUnsignedLongVal*) ROSE_MALLOC ( SgUnsignedLongVal::pool_size * sizeof(SgUnsignedLongVal) );
  182112           1 :         assert( pointer != NULL );
  182113             : #if ROSE_ALLOC_MEMSET == 1
  182114             :         memset(pointer, 0x00, SgUnsignedLongVal::pool_size * sizeof(SgUnsignedLongVal));
  182115             : #elif ROSE_ALLOC_MEMSET == 2
  182116             :         memset(pointer, 0xCC, SgUnsignedLongVal::pool_size * sizeof(SgUnsignedLongVal));
  182117             : #endif
  182118           1 :         SgUnsignedLongVal::pools.push_back( (unsigned char*)(pointer) );
  182119           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnsignedLongVal::pool_size * sizeof(SgUnsignedLongVal), V_SgUnsignedLongVal ) );
  182120             : 
  182121           1 :         if ( SgUnsignedLongVal::next_node != NULL ) {
  182122           0 :           if ( blockIndex > 0 ) {
  182123           0 :             SgUnsignedLongVal * blkptr = (SgUnsignedLongVal*)(SgUnsignedLongVal::pools[blockIndex-1]);
  182124           0 :             blkptr[ SgUnsignedLongVal::pool_size - 1 ].set_freepointer(pointer);
  182125             :           }
  182126             :         } else {
  182127           1 :           SgUnsignedLongVal::next_node = pointer;
  182128             :         }
  182129             : 
  182130        2000 :         for (unsigned i = 0; i < SgUnsignedLongVal::pool_size-1; ++i)
  182131             :            {
  182132        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  182133             :            }
  182134           1 :         pointer[ SgUnsignedLongVal::pool_size -1 ].set_freepointer(NULL);
  182135             : 
  182136           1 :         blockIndex++;
  182137             :       }
  182138           2 :   }
  182139             : 
  182140             : //############################################################################
  182141             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  182142             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  182143             :  * not compressed. However, that stuff is not yet implemented! 
  182144             :  */
  182145             : unsigned long
  182146           0 : SgUnsignedLongVal::getNumberOfLastValidPointer()
  182147             :    {
  182148           0 :       SgUnsignedLongVal* testPointer = (SgUnsignedLongVal*)(SgUnsignedLongVal::pools.back());
  182149           0 :       unsigned long localIndex = SgUnsignedLongVal::pool_size - 1;
  182150           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  182151             :          {
  182152           0 :            localIndex--;
  182153             :          }
  182154           0 :       return (localIndex + SgUnsignedLongVal::pool_size * (SgUnsignedLongVal::pools.size()-1));
  182155             :    }
  182156             : 
  182157             : //############################################################################
  182158             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  182159             :  * memory pool and initializes the data member in class SgUnsignedLongValStroageClass
  182160             :  * from its counterpart of SgUnsignedLongVal. The return value is just for checking, 
  182161             :  * that the whole StorageClassArray is initialized!
  182162             :  */
  182163             : unsigned long
  182164           1 : SgUnsignedLongVal::initializeStorageClassArray( SgUnsignedLongValStorageClass *storageArray )
  182165             :    {
  182166           1 :      unsigned long storageCounter = 0;
  182167           1 :      std::vector < unsigned char* > :: const_iterator block = SgUnsignedLongVal::pools.begin();
  182168           1 :      SgUnsignedLongVal* pointer = NULL;
  182169           2 :      while ( block != SgUnsignedLongVal::pools.end() ) {
  182170           1 :           pointer = (SgUnsignedLongVal*) (*block);
  182171        2001 :           for ( unsigned i = 0; i < SgUnsignedLongVal::pool_size; ++i ) {
  182172        2000 :                if ( pointer->get_freepointer() != NULL ) {
  182173          19 :                  storageArray->pickOutIRNodeData (pointer) ;
  182174          19 :                  storageArray++;
  182175          19 :                  storageCounter++;
  182176             :                }
  182177        2000 :                pointer++;
  182178             :              }
  182179           1 :            block++;
  182180             :         }
  182181           1 :      return storageCounter;
  182182             :    }
  182183             : 
  182184             : /* #line 182185 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  182185             : 
  182186             : 
  182187             : 
  182188             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  182189             : 
  182190             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  182191             : 
  182192             : //############################################################################
  182193             : /* JH (02/02/2006) Constructor of the IR node SgFloatVal that takes its 
  182194             :  * corresponding StorageClass as parameter
  182195             :  */
  182196           1 : SgFloatVal :: SgFloatVal ( const SgFloatValStorageClass& storageSource )   : SgValueExp (storageSource)
  182197             :    {
  182198             : 
  182199             : 
  182200             : /* #line 182201 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  182201             : 
  182202           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  182203           1 :      p_value = storageSource.storageOf_value ;
  182204           1 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  182205             : 
  182206             : 
  182207             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  182208             : 
  182209             : 
  182210           1 :    }
  182211             : 
  182212             : //############################################################################
  182213             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  182214             :  * within the working AST. 
  182215             :  */
  182216           4 : SgFloatVal * SgFloatVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  182217           4 :      SgFloatVal* returnPointer = NULL;
  182218           4 :      if ( globalIndex != 0 )
  182219             :         {
  182220             : 
  182221             : #if FILE_IO_EXTRA_CHECK
  182222           4 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFloatVal ) ) <= globalIndex ) ;
  182223           4 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFloatVal + 1 ) ) );
  182224             : #endif
  182225           4 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFloatVal )  
  182226           4 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFloatVal );
  182227           4 :           unsigned long positionInPool = localIndex % SgFloatVal::pool_size;
  182228           4 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFloatVal::pool_size;
  182229             : 
  182230             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  182231             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  182232             : 
  182233           4 :           returnPointer = &( ( (SgFloatVal*)(SgFloatVal::pools[memoryBlock]) ) [positionInPool]) ;
  182234             : 
  182235           4 :           ROSE_ASSERT( returnPointer != NULL ) ;
  182236             :         }
  182237           4 :      return returnPointer ;
  182238             :    }
  182239             : 
  182240             : //############################################################################
  182241             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  182242             :   for the AST with the index astIndex
  182243             : */
  182244           0 : SgFloatVal * SgFloatVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  182245           0 :      SgFloatVal* returnPointer = NULL;
  182246           0 :      if ( globalIndex != 0 )
  182247             :         {
  182248             : 
  182249             : #if FILE_IO_EXTRA_CHECK
  182250           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFloatVal ) ) <= globalIndex ) ;
  182251           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFloatVal + 1 ) ) );
  182252             : #endif
  182253           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFloatVal )
  182254           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFloatVal );
  182255           0 :           unsigned long positionInPool = localIndex % SgFloatVal::pool_size ;
  182256           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFloatVal::pool_size ;
  182257             : 
  182258             : #if FILE_IO_EXTRA_CHECK
  182259             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  182260             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  182261             : #endif
  182262             : 
  182263           0 :           returnPointer = &( ( (SgFloatVal*)(SgFloatVal::pools[memoryBlock]) ) [positionInPool]) ;
  182264             : 
  182265             : #if FILE_IO_EXTRA_CHECK
  182266           0 :           assert ( returnPointer != NULL ) ;
  182267             : #endif
  182268             :         }
  182269           0 :      return returnPointer ;
  182270             :    }
  182271             : 
  182272             : //############################################################################
  182273             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  182274             :  * pool size! We set for every valid object in the memory pool the freepointer
  182275             :  * to the global index and increase the global index afterwards. For all the 
  182276             :  * invalid objects (means address ranges within the memory pool that were not
  182277             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  182278             :  * distinguish valid from invalid objects! 
  182279             :  */
  182280             : unsigned long
  182281           5 : SgFloatVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  182282             :    {
  182283           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  182284           5 :      SgFloatVal* pointer = NULL;
  182285           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  182286           5 :      std::vector < unsigned char* > :: const_iterator block;
  182287           6 :      for ( block = SgFloatVal::pools.begin(); block != SgFloatVal::pools.end() ; ++block )
  182288             :         {
  182289           1 :           pointer = (SgFloatVal*)(*block);
  182290        2001 :           for (unsigned i = 0; i < SgFloatVal::pool_size; ++i )
  182291             :              {
  182292             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  182293             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  182294             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  182295             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  182296             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  182297             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  182298             :             // properly; so this will have to be checked next.
  182299             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  182300             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  182301        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  182302             :                   {
  182303           1 :                     pointer[i].set_freepointer((SgFloatVal*)(globalIndex));
  182304           1 :                     globalIndex++;
  182305             :                   }
  182306             :                else
  182307             :                   {
  182308        1999 :                     pointer[i].set_freepointer(NULL);
  182309             :                   }
  182310             :               }
  182311             :         }
  182312           5 :      return globalIndex;
  182313             :    }
  182314             : 
  182315             : //############################################################################
  182316             : // JH (01/14/2006)
  182317             : void
  182318           5 : SgFloatVal::resetValidFreepointers( )
  182319             :    {
  182320           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  182321           5 :      SgFloatVal* pointer = NULL;
  182322           5 :      std::vector < unsigned char* > :: const_iterator block;
  182323           5 :      SgFloatVal* pointerOfLinkedList = NULL;
  182324           6 :      for ( block = SgFloatVal::pools.begin(); block != SgFloatVal::pools.end() ; ++block )
  182325             :         {
  182326           1 :           pointer = (SgFloatVal*)(*block);
  182327        2001 :           for (unsigned i = 0; i < SgFloatVal::pool_size; ++i )
  182328             :              {
  182329             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  182330             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  182331             :             // memory blocks!.
  182332        2000 :                if ( pointer[i].get_freepointer() != NULL )
  182333             :                   {
  182334           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  182335             :                   }
  182336             :                else
  182337             :                   {
  182338        1999 :                     if ( pointerOfLinkedList == NULL )
  182339             :                        {
  182340           1 :                          SgFloatVal::next_node = &(pointer[i]);
  182341             :                        }
  182342             :                     else
  182343             :                        {
  182344             :                       // printf ("In SgFloatVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  182345        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  182346             :                        }
  182347             :                     pointerOfLinkedList = &(pointer[i]);
  182348             :                   }
  182349             :               }
  182350             :         }
  182351             : 
  182352           5 :      if ( pointerOfLinkedList != NULL )
  182353             :         {
  182354             :        // printf ("In SgFloatVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  182355           1 :           pointerOfLinkedList->set_freepointer(NULL);
  182356             :        // DQ (6/6/2010): Temporary debugging...
  182357             :        //   ROSE_ASSERT(false);
  182358             :         }
  182359             : 
  182360           5 :      return ;
  182361             :    }
  182362             : 
  182363             : //############################################################################
  182364             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  182365             :  * within the memory pool and resets the freepointers, in order to achieve a 
  182366             :  * linked list, that has no jumps and starts at the beginning! This function 
  182367             :  * does not extend the memory pool, since we do not delete any memory blocks,
  182368             :  * but delete the valid objects.  
  182369             :  */
  182370             : void
  182371           0 : SgFloatVal::clearMemoryPool( )
  182372             :    {
  182373             :   // printf ("Inside of SgFloatVal::clearMemoryPool() \n");
  182374             : 
  182375           0 :      SgFloatVal* pointer = NULL, *tempPointer = NULL;
  182376           0 :      std::vector < unsigned char* > :: const_iterator block;
  182377           0 :      if ( SgFloatVal::pools.empty() == false )
  182378             :         {
  182379           0 :           block = SgFloatVal::pools.begin() ;
  182380           0 :           SgFloatVal::next_node = (SgFloatVal*) (*block);
  182381             : 
  182382           0 :           while ( block != SgFloatVal::pools.end() )
  182383             :              {
  182384           0 :                pointer = (SgFloatVal*) (*block);
  182385           0 :                if ( tempPointer != NULL )
  182386             :                   {
  182387           0 :                     tempPointer->set_freepointer(pointer);
  182388             :                   }
  182389           0 :                for (unsigned i = 0; i < SgFloatVal::pool_size - 1; ++i)
  182390             :                   {
  182391           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  182392             :                   }
  182393           0 :                 pointer[SgFloatVal::pool_size-1].set_freepointer(NULL);
  182394           0 :                 tempPointer = &(pointer[SgFloatVal::pool_size-1]);
  182395           0 :                 ++block;
  182396             :              }
  182397             :         }
  182398           0 :    }
  182399             : 
  182400           5 : void SgFloatVal::deleteMemoryPool() {
  182401           7 :   for (auto p: SgFloatVal::pools) {
  182402           2 :     ROSE_FREE(p);
  182403             :   }
  182404           5 :   SgFloatVal::next_node = nullptr;
  182405           5 :   SgFloatVal::pools.clear();
  182406           5 : }
  182407             : 
  182408             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  182409             : //                 reading multiple binary files to for a single AST.
  182410             : /////////// new version ////////////////////////////////
  182411             : //############################################################################
  182412             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  182413             : void
  182414           2 : SgFloatVal::extendMemoryPoolForFileIO( )
  182415             :   {
  182416           2 :     size_t blockIndex = SgFloatVal::pools.size();
  182417           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFloatVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloatVal);
  182418             : 
  182419           3 :     while ( (blockIndex * SgFloatVal::pool_size) < newPoolSize)
  182420             :       {
  182421             : #if ROSE_ALLOC_TRACE
  182422             :         if (blockIndex > 0) {
  182423             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFloatVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloatVal) = %" PRIuPTR " SgFloatVal::pool_size = %d \n",
  182424             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFloatVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloatVal),SgFloatVal::pool_size);
  182425             :         }
  182426             : #endif
  182427             : 
  182428           1 :         SgFloatVal * pointer = (SgFloatVal*) ROSE_MALLOC ( SgFloatVal::pool_size * sizeof(SgFloatVal) );
  182429           1 :         assert( pointer != NULL );
  182430             : #if ROSE_ALLOC_MEMSET == 1
  182431             :         memset(pointer, 0x00, SgFloatVal::pool_size * sizeof(SgFloatVal));
  182432             : #elif ROSE_ALLOC_MEMSET == 2
  182433             :         memset(pointer, 0xCC, SgFloatVal::pool_size * sizeof(SgFloatVal));
  182434             : #endif
  182435           1 :         SgFloatVal::pools.push_back( (unsigned char*)(pointer) );
  182436           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFloatVal::pool_size * sizeof(SgFloatVal), V_SgFloatVal ) );
  182437             : 
  182438           1 :         if ( SgFloatVal::next_node != NULL ) {
  182439           0 :           if ( blockIndex > 0 ) {
  182440           0 :             SgFloatVal * blkptr = (SgFloatVal*)(SgFloatVal::pools[blockIndex-1]);
  182441           0 :             blkptr[ SgFloatVal::pool_size - 1 ].set_freepointer(pointer);
  182442             :           }
  182443             :         } else {
  182444           1 :           SgFloatVal::next_node = pointer;
  182445             :         }
  182446             : 
  182447        2000 :         for (unsigned i = 0; i < SgFloatVal::pool_size-1; ++i)
  182448             :            {
  182449        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  182450             :            }
  182451           1 :         pointer[ SgFloatVal::pool_size -1 ].set_freepointer(NULL);
  182452             : 
  182453           1 :         blockIndex++;
  182454             :       }
  182455           2 :   }
  182456             : 
  182457             : //############################################################################
  182458             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  182459             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  182460             :  * not compressed. However, that stuff is not yet implemented! 
  182461             :  */
  182462             : unsigned long
  182463           0 : SgFloatVal::getNumberOfLastValidPointer()
  182464             :    {
  182465           0 :       SgFloatVal* testPointer = (SgFloatVal*)(SgFloatVal::pools.back());
  182466           0 :       unsigned long localIndex = SgFloatVal::pool_size - 1;
  182467           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  182468             :          {
  182469           0 :            localIndex--;
  182470             :          }
  182471           0 :       return (localIndex + SgFloatVal::pool_size * (SgFloatVal::pools.size()-1));
  182472             :    }
  182473             : 
  182474             : //############################################################################
  182475             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  182476             :  * memory pool and initializes the data member in class SgFloatValStroageClass
  182477             :  * from its counterpart of SgFloatVal. The return value is just for checking, 
  182478             :  * that the whole StorageClassArray is initialized!
  182479             :  */
  182480             : unsigned long
  182481           1 : SgFloatVal::initializeStorageClassArray( SgFloatValStorageClass *storageArray )
  182482             :    {
  182483           1 :      unsigned long storageCounter = 0;
  182484           1 :      std::vector < unsigned char* > :: const_iterator block = SgFloatVal::pools.begin();
  182485           1 :      SgFloatVal* pointer = NULL;
  182486           2 :      while ( block != SgFloatVal::pools.end() ) {
  182487           1 :           pointer = (SgFloatVal*) (*block);
  182488        2001 :           for ( unsigned i = 0; i < SgFloatVal::pool_size; ++i ) {
  182489        2000 :                if ( pointer->get_freepointer() != NULL ) {
  182490           1 :                  storageArray->pickOutIRNodeData (pointer) ;
  182491           1 :                  storageArray++;
  182492           1 :                  storageCounter++;
  182493             :                }
  182494        2000 :                pointer++;
  182495             :              }
  182496           1 :            block++;
  182497             :         }
  182498           1 :      return storageCounter;
  182499             :    }
  182500             : 
  182501             : /* #line 182502 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  182502             : 
  182503             : 
  182504             : 
  182505             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  182506             : 
  182507             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  182508             : 
  182509             : //############################################################################
  182510             : /* JH (02/02/2006) Constructor of the IR node SgDoubleVal that takes its 
  182511             :  * corresponding StorageClass as parameter
  182512             :  */
  182513           1 : SgDoubleVal :: SgDoubleVal ( const SgDoubleValStorageClass& storageSource )   : SgValueExp (storageSource)
  182514             :    {
  182515             : 
  182516             : 
  182517             : /* #line 182518 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  182518             : 
  182519           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  182520           1 :      p_value = storageSource.storageOf_value ;
  182521           1 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  182522             : 
  182523             : 
  182524             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  182525             : 
  182526             : 
  182527           1 :    }
  182528             : 
  182529             : //############################################################################
  182530             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  182531             :  * within the working AST. 
  182532             :  */
  182533           4 : SgDoubleVal * SgDoubleVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  182534           4 :      SgDoubleVal* returnPointer = NULL;
  182535           4 :      if ( globalIndex != 0 )
  182536             :         {
  182537             : 
  182538             : #if FILE_IO_EXTRA_CHECK
  182539           4 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDoubleVal ) ) <= globalIndex ) ;
  182540           4 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDoubleVal + 1 ) ) );
  182541             : #endif
  182542           4 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDoubleVal )  
  182543           4 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDoubleVal );
  182544           4 :           unsigned long positionInPool = localIndex % SgDoubleVal::pool_size;
  182545           4 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDoubleVal::pool_size;
  182546             : 
  182547             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  182548             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  182549             : 
  182550           4 :           returnPointer = &( ( (SgDoubleVal*)(SgDoubleVal::pools[memoryBlock]) ) [positionInPool]) ;
  182551             : 
  182552           4 :           ROSE_ASSERT( returnPointer != NULL ) ;
  182553             :         }
  182554           4 :      return returnPointer ;
  182555             :    }
  182556             : 
  182557             : //############################################################################
  182558             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  182559             :   for the AST with the index astIndex
  182560             : */
  182561           0 : SgDoubleVal * SgDoubleVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  182562           0 :      SgDoubleVal* returnPointer = NULL;
  182563           0 :      if ( globalIndex != 0 )
  182564             :         {
  182565             : 
  182566             : #if FILE_IO_EXTRA_CHECK
  182567           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDoubleVal ) ) <= globalIndex ) ;
  182568           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDoubleVal + 1 ) ) );
  182569             : #endif
  182570           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDoubleVal )
  182571           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDoubleVal );
  182572           0 :           unsigned long positionInPool = localIndex % SgDoubleVal::pool_size ;
  182573           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDoubleVal::pool_size ;
  182574             : 
  182575             : #if FILE_IO_EXTRA_CHECK
  182576             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  182577             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  182578             : #endif
  182579             : 
  182580           0 :           returnPointer = &( ( (SgDoubleVal*)(SgDoubleVal::pools[memoryBlock]) ) [positionInPool]) ;
  182581             : 
  182582             : #if FILE_IO_EXTRA_CHECK
  182583           0 :           assert ( returnPointer != NULL ) ;
  182584             : #endif
  182585             :         }
  182586           0 :      return returnPointer ;
  182587             :    }
  182588             : 
  182589             : //############################################################################
  182590             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  182591             :  * pool size! We set for every valid object in the memory pool the freepointer
  182592             :  * to the global index and increase the global index afterwards. For all the 
  182593             :  * invalid objects (means address ranges within the memory pool that were not
  182594             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  182595             :  * distinguish valid from invalid objects! 
  182596             :  */
  182597             : unsigned long
  182598           5 : SgDoubleVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  182599             :    {
  182600           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  182601           5 :      SgDoubleVal* pointer = NULL;
  182602           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  182603           5 :      std::vector < unsigned char* > :: const_iterator block;
  182604           6 :      for ( block = SgDoubleVal::pools.begin(); block != SgDoubleVal::pools.end() ; ++block )
  182605             :         {
  182606           1 :           pointer = (SgDoubleVal*)(*block);
  182607        2001 :           for (unsigned i = 0; i < SgDoubleVal::pool_size; ++i )
  182608             :              {
  182609             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  182610             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  182611             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  182612             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  182613             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  182614             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  182615             :             // properly; so this will have to be checked next.
  182616             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  182617             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  182618        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  182619             :                   {
  182620           1 :                     pointer[i].set_freepointer((SgDoubleVal*)(globalIndex));
  182621           1 :                     globalIndex++;
  182622             :                   }
  182623             :                else
  182624             :                   {
  182625        1999 :                     pointer[i].set_freepointer(NULL);
  182626             :                   }
  182627             :               }
  182628             :         }
  182629           5 :      return globalIndex;
  182630             :    }
  182631             : 
  182632             : //############################################################################
  182633             : // JH (01/14/2006)
  182634             : void
  182635           5 : SgDoubleVal::resetValidFreepointers( )
  182636             :    {
  182637           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  182638           5 :      SgDoubleVal* pointer = NULL;
  182639           5 :      std::vector < unsigned char* > :: const_iterator block;
  182640           5 :      SgDoubleVal* pointerOfLinkedList = NULL;
  182641           6 :      for ( block = SgDoubleVal::pools.begin(); block != SgDoubleVal::pools.end() ; ++block )
  182642             :         {
  182643           1 :           pointer = (SgDoubleVal*)(*block);
  182644        2001 :           for (unsigned i = 0; i < SgDoubleVal::pool_size; ++i )
  182645             :              {
  182646             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  182647             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  182648             :             // memory blocks!.
  182649        2000 :                if ( pointer[i].get_freepointer() != NULL )
  182650             :                   {
  182651           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  182652             :                   }
  182653             :                else
  182654             :                   {
  182655        1999 :                     if ( pointerOfLinkedList == NULL )
  182656             :                        {
  182657           1 :                          SgDoubleVal::next_node = &(pointer[i]);
  182658             :                        }
  182659             :                     else
  182660             :                        {
  182661             :                       // printf ("In SgDoubleVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  182662        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  182663             :                        }
  182664             :                     pointerOfLinkedList = &(pointer[i]);
  182665             :                   }
  182666             :               }
  182667             :         }
  182668             : 
  182669           5 :      if ( pointerOfLinkedList != NULL )
  182670             :         {
  182671             :        // printf ("In SgDoubleVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  182672           1 :           pointerOfLinkedList->set_freepointer(NULL);
  182673             :        // DQ (6/6/2010): Temporary debugging...
  182674             :        //   ROSE_ASSERT(false);
  182675             :         }
  182676             : 
  182677           5 :      return ;
  182678             :    }
  182679             : 
  182680             : //############################################################################
  182681             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  182682             :  * within the memory pool and resets the freepointers, in order to achieve a 
  182683             :  * linked list, that has no jumps and starts at the beginning! This function 
  182684             :  * does not extend the memory pool, since we do not delete any memory blocks,
  182685             :  * but delete the valid objects.  
  182686             :  */
  182687             : void
  182688           0 : SgDoubleVal::clearMemoryPool( )
  182689             :    {
  182690             :   // printf ("Inside of SgDoubleVal::clearMemoryPool() \n");
  182691             : 
  182692           0 :      SgDoubleVal* pointer = NULL, *tempPointer = NULL;
  182693           0 :      std::vector < unsigned char* > :: const_iterator block;
  182694           0 :      if ( SgDoubleVal::pools.empty() == false )
  182695             :         {
  182696           0 :           block = SgDoubleVal::pools.begin() ;
  182697           0 :           SgDoubleVal::next_node = (SgDoubleVal*) (*block);
  182698             : 
  182699           0 :           while ( block != SgDoubleVal::pools.end() )
  182700             :              {
  182701           0 :                pointer = (SgDoubleVal*) (*block);
  182702           0 :                if ( tempPointer != NULL )
  182703             :                   {
  182704           0 :                     tempPointer->set_freepointer(pointer);
  182705             :                   }
  182706           0 :                for (unsigned i = 0; i < SgDoubleVal::pool_size - 1; ++i)
  182707             :                   {
  182708           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  182709             :                   }
  182710           0 :                 pointer[SgDoubleVal::pool_size-1].set_freepointer(NULL);
  182711           0 :                 tempPointer = &(pointer[SgDoubleVal::pool_size-1]);
  182712           0 :                 ++block;
  182713             :              }
  182714             :         }
  182715           0 :    }
  182716             : 
  182717           5 : void SgDoubleVal::deleteMemoryPool() {
  182718           7 :   for (auto p: SgDoubleVal::pools) {
  182719           2 :     ROSE_FREE(p);
  182720             :   }
  182721           5 :   SgDoubleVal::next_node = nullptr;
  182722           5 :   SgDoubleVal::pools.clear();
  182723           5 : }
  182724             : 
  182725             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  182726             : //                 reading multiple binary files to for a single AST.
  182727             : /////////// new version ////////////////////////////////
  182728             : //############################################################################
  182729             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  182730             : void
  182731           2 : SgDoubleVal::extendMemoryPoolForFileIO( )
  182732             :   {
  182733           2 :     size_t blockIndex = SgDoubleVal::pools.size();
  182734           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDoubleVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDoubleVal);
  182735             : 
  182736           3 :     while ( (blockIndex * SgDoubleVal::pool_size) < newPoolSize)
  182737             :       {
  182738             : #if ROSE_ALLOC_TRACE
  182739             :         if (blockIndex > 0) {
  182740             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDoubleVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDoubleVal) = %" PRIuPTR " SgDoubleVal::pool_size = %d \n",
  182741             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDoubleVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDoubleVal),SgDoubleVal::pool_size);
  182742             :         }
  182743             : #endif
  182744             : 
  182745           1 :         SgDoubleVal * pointer = (SgDoubleVal*) ROSE_MALLOC ( SgDoubleVal::pool_size * sizeof(SgDoubleVal) );
  182746           1 :         assert( pointer != NULL );
  182747             : #if ROSE_ALLOC_MEMSET == 1
  182748             :         memset(pointer, 0x00, SgDoubleVal::pool_size * sizeof(SgDoubleVal));
  182749             : #elif ROSE_ALLOC_MEMSET == 2
  182750             :         memset(pointer, 0xCC, SgDoubleVal::pool_size * sizeof(SgDoubleVal));
  182751             : #endif
  182752           1 :         SgDoubleVal::pools.push_back( (unsigned char*)(pointer) );
  182753           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDoubleVal::pool_size * sizeof(SgDoubleVal), V_SgDoubleVal ) );
  182754             : 
  182755           1 :         if ( SgDoubleVal::next_node != NULL ) {
  182756           0 :           if ( blockIndex > 0 ) {
  182757           0 :             SgDoubleVal * blkptr = (SgDoubleVal*)(SgDoubleVal::pools[blockIndex-1]);
  182758           0 :             blkptr[ SgDoubleVal::pool_size - 1 ].set_freepointer(pointer);
  182759             :           }
  182760             :         } else {
  182761           1 :           SgDoubleVal::next_node = pointer;
  182762             :         }
  182763             : 
  182764        2000 :         for (unsigned i = 0; i < SgDoubleVal::pool_size-1; ++i)
  182765             :            {
  182766        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  182767             :            }
  182768           1 :         pointer[ SgDoubleVal::pool_size -1 ].set_freepointer(NULL);
  182769             : 
  182770           1 :         blockIndex++;
  182771             :       }
  182772           2 :   }
  182773             : 
  182774             : //############################################################################
  182775             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  182776             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  182777             :  * not compressed. However, that stuff is not yet implemented! 
  182778             :  */
  182779             : unsigned long
  182780           0 : SgDoubleVal::getNumberOfLastValidPointer()
  182781             :    {
  182782           0 :       SgDoubleVal* testPointer = (SgDoubleVal*)(SgDoubleVal::pools.back());
  182783           0 :       unsigned long localIndex = SgDoubleVal::pool_size - 1;
  182784           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  182785             :          {
  182786           0 :            localIndex--;
  182787             :          }
  182788           0 :       return (localIndex + SgDoubleVal::pool_size * (SgDoubleVal::pools.size()-1));
  182789             :    }
  182790             : 
  182791             : //############################################################################
  182792             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  182793             :  * memory pool and initializes the data member in class SgDoubleValStroageClass
  182794             :  * from its counterpart of SgDoubleVal. The return value is just for checking, 
  182795             :  * that the whole StorageClassArray is initialized!
  182796             :  */
  182797             : unsigned long
  182798           1 : SgDoubleVal::initializeStorageClassArray( SgDoubleValStorageClass *storageArray )
  182799             :    {
  182800           1 :      unsigned long storageCounter = 0;
  182801           1 :      std::vector < unsigned char* > :: const_iterator block = SgDoubleVal::pools.begin();
  182802           1 :      SgDoubleVal* pointer = NULL;
  182803           2 :      while ( block != SgDoubleVal::pools.end() ) {
  182804           1 :           pointer = (SgDoubleVal*) (*block);
  182805        2001 :           for ( unsigned i = 0; i < SgDoubleVal::pool_size; ++i ) {
  182806        2000 :                if ( pointer->get_freepointer() != NULL ) {
  182807           1 :                  storageArray->pickOutIRNodeData (pointer) ;
  182808           1 :                  storageArray++;
  182809           1 :                  storageCounter++;
  182810             :                }
  182811        2000 :                pointer++;
  182812             :              }
  182813           1 :            block++;
  182814             :         }
  182815           1 :      return storageCounter;
  182816             :    }
  182817             : 
  182818             : /* #line 182819 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  182819             : 
  182820             : 
  182821             : 
  182822             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  182823             : 
  182824             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  182825             : 
  182826             : //############################################################################
  182827             : /* JH (02/02/2006) Constructor of the IR node SgLongDoubleVal that takes its 
  182828             :  * corresponding StorageClass as parameter
  182829             :  */
  182830           0 : SgLongDoubleVal :: SgLongDoubleVal ( const SgLongDoubleValStorageClass& storageSource )   : SgValueExp (storageSource)
  182831             :    {
  182832             : 
  182833             : 
  182834             : /* #line 182835 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  182835             : 
  182836           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  182837           0 :      p_value = storageSource.storageOf_value ;
  182838           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  182839             : 
  182840             : 
  182841             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  182842             : 
  182843             : 
  182844           0 :    }
  182845             : 
  182846             : //############################################################################
  182847             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  182848             :  * within the working AST. 
  182849             :  */
  182850           0 : SgLongDoubleVal * SgLongDoubleVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  182851           0 :      SgLongDoubleVal* returnPointer = NULL;
  182852           0 :      if ( globalIndex != 0 )
  182853             :         {
  182854             : 
  182855             : #if FILE_IO_EXTRA_CHECK
  182856           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLongDoubleVal ) ) <= globalIndex ) ;
  182857           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLongDoubleVal + 1 ) ) );
  182858             : #endif
  182859           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLongDoubleVal )  
  182860           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLongDoubleVal );
  182861           0 :           unsigned long positionInPool = localIndex % SgLongDoubleVal::pool_size;
  182862           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLongDoubleVal::pool_size;
  182863             : 
  182864             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  182865             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  182866             : 
  182867           0 :           returnPointer = &( ( (SgLongDoubleVal*)(SgLongDoubleVal::pools[memoryBlock]) ) [positionInPool]) ;
  182868             : 
  182869           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  182870             :         }
  182871           0 :      return returnPointer ;
  182872             :    }
  182873             : 
  182874             : //############################################################################
  182875             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  182876             :   for the AST with the index astIndex
  182877             : */
  182878           0 : SgLongDoubleVal * SgLongDoubleVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  182879           0 :      SgLongDoubleVal* returnPointer = NULL;
  182880           0 :      if ( globalIndex != 0 )
  182881             :         {
  182882             : 
  182883             : #if FILE_IO_EXTRA_CHECK
  182884           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLongDoubleVal ) ) <= globalIndex ) ;
  182885           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLongDoubleVal + 1 ) ) );
  182886             : #endif
  182887           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLongDoubleVal )
  182888           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLongDoubleVal );
  182889           0 :           unsigned long positionInPool = localIndex % SgLongDoubleVal::pool_size ;
  182890           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLongDoubleVal::pool_size ;
  182891             : 
  182892             : #if FILE_IO_EXTRA_CHECK
  182893             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  182894             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  182895             : #endif
  182896             : 
  182897           0 :           returnPointer = &( ( (SgLongDoubleVal*)(SgLongDoubleVal::pools[memoryBlock]) ) [positionInPool]) ;
  182898             : 
  182899             : #if FILE_IO_EXTRA_CHECK
  182900           0 :           assert ( returnPointer != NULL ) ;
  182901             : #endif
  182902             :         }
  182903           0 :      return returnPointer ;
  182904             :    }
  182905             : 
  182906             : //############################################################################
  182907             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  182908             :  * pool size! We set for every valid object in the memory pool the freepointer
  182909             :  * to the global index and increase the global index afterwards. For all the 
  182910             :  * invalid objects (means address ranges within the memory pool that were not
  182911             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  182912             :  * distinguish valid from invalid objects! 
  182913             :  */
  182914             : unsigned long
  182915           5 : SgLongDoubleVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  182916             :    {
  182917           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  182918           5 :      SgLongDoubleVal* pointer = NULL;
  182919           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  182920           5 :      std::vector < unsigned char* > :: const_iterator block;
  182921           6 :      for ( block = SgLongDoubleVal::pools.begin(); block != SgLongDoubleVal::pools.end() ; ++block )
  182922             :         {
  182923           1 :           pointer = (SgLongDoubleVal*)(*block);
  182924        2001 :           for (unsigned i = 0; i < SgLongDoubleVal::pool_size; ++i )
  182925             :              {
  182926             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  182927             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  182928             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  182929             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  182930             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  182931             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  182932             :             // properly; so this will have to be checked next.
  182933             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  182934             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  182935        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  182936             :                   {
  182937           0 :                     pointer[i].set_freepointer((SgLongDoubleVal*)(globalIndex));
  182938           0 :                     globalIndex++;
  182939             :                   }
  182940             :                else
  182941             :                   {
  182942        2000 :                     pointer[i].set_freepointer(NULL);
  182943             :                   }
  182944             :               }
  182945             :         }
  182946           5 :      return globalIndex;
  182947             :    }
  182948             : 
  182949             : //############################################################################
  182950             : // JH (01/14/2006)
  182951             : void
  182952           5 : SgLongDoubleVal::resetValidFreepointers( )
  182953             :    {
  182954           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  182955           5 :      SgLongDoubleVal* pointer = NULL;
  182956           5 :      std::vector < unsigned char* > :: const_iterator block;
  182957           5 :      SgLongDoubleVal* pointerOfLinkedList = NULL;
  182958           6 :      for ( block = SgLongDoubleVal::pools.begin(); block != SgLongDoubleVal::pools.end() ; ++block )
  182959             :         {
  182960           1 :           pointer = (SgLongDoubleVal*)(*block);
  182961        2001 :           for (unsigned i = 0; i < SgLongDoubleVal::pool_size; ++i )
  182962             :              {
  182963             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  182964             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  182965             :             // memory blocks!.
  182966        2000 :                if ( pointer[i].get_freepointer() != NULL )
  182967             :                   {
  182968           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  182969             :                   }
  182970             :                else
  182971             :                   {
  182972        2000 :                     if ( pointerOfLinkedList == NULL )
  182973             :                        {
  182974           1 :                          SgLongDoubleVal::next_node = &(pointer[i]);
  182975             :                        }
  182976             :                     else
  182977             :                        {
  182978             :                       // printf ("In SgLongDoubleVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  182979        1999 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  182980             :                        }
  182981             :                     pointerOfLinkedList = &(pointer[i]);
  182982             :                   }
  182983             :               }
  182984             :         }
  182985             : 
  182986           5 :      if ( pointerOfLinkedList != NULL )
  182987             :         {
  182988             :        // printf ("In SgLongDoubleVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  182989           1 :           pointerOfLinkedList->set_freepointer(NULL);
  182990             :        // DQ (6/6/2010): Temporary debugging...
  182991             :        //   ROSE_ASSERT(false);
  182992             :         }
  182993             : 
  182994           5 :      return ;
  182995             :    }
  182996             : 
  182997             : //############################################################################
  182998             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  182999             :  * within the memory pool and resets the freepointers, in order to achieve a 
  183000             :  * linked list, that has no jumps and starts at the beginning! This function 
  183001             :  * does not extend the memory pool, since we do not delete any memory blocks,
  183002             :  * but delete the valid objects.  
  183003             :  */
  183004             : void
  183005           0 : SgLongDoubleVal::clearMemoryPool( )
  183006             :    {
  183007             :   // printf ("Inside of SgLongDoubleVal::clearMemoryPool() \n");
  183008             : 
  183009           0 :      SgLongDoubleVal* pointer = NULL, *tempPointer = NULL;
  183010           0 :      std::vector < unsigned char* > :: const_iterator block;
  183011           0 :      if ( SgLongDoubleVal::pools.empty() == false )
  183012             :         {
  183013           0 :           block = SgLongDoubleVal::pools.begin() ;
  183014           0 :           SgLongDoubleVal::next_node = (SgLongDoubleVal*) (*block);
  183015             : 
  183016           0 :           while ( block != SgLongDoubleVal::pools.end() )
  183017             :              {
  183018           0 :                pointer = (SgLongDoubleVal*) (*block);
  183019           0 :                if ( tempPointer != NULL )
  183020             :                   {
  183021           0 :                     tempPointer->set_freepointer(pointer);
  183022             :                   }
  183023           0 :                for (unsigned i = 0; i < SgLongDoubleVal::pool_size - 1; ++i)
  183024             :                   {
  183025           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  183026             :                   }
  183027           0 :                 pointer[SgLongDoubleVal::pool_size-1].set_freepointer(NULL);
  183028           0 :                 tempPointer = &(pointer[SgLongDoubleVal::pool_size-1]);
  183029           0 :                 ++block;
  183030             :              }
  183031             :         }
  183032           0 :    }
  183033             : 
  183034           5 : void SgLongDoubleVal::deleteMemoryPool() {
  183035           6 :   for (auto p: SgLongDoubleVal::pools) {
  183036           1 :     ROSE_FREE(p);
  183037             :   }
  183038           5 :   SgLongDoubleVal::next_node = nullptr;
  183039           5 :   SgLongDoubleVal::pools.clear();
  183040           5 : }
  183041             : 
  183042             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  183043             : //                 reading multiple binary files to for a single AST.
  183044             : /////////// new version ////////////////////////////////
  183045             : //############################################################################
  183046             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  183047             : void
  183048           2 : SgLongDoubleVal::extendMemoryPoolForFileIO( )
  183049             :   {
  183050           2 :     size_t blockIndex = SgLongDoubleVal::pools.size();
  183051           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLongDoubleVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongDoubleVal);
  183052             : 
  183053           2 :     while ( (blockIndex * SgLongDoubleVal::pool_size) < newPoolSize)
  183054             :       {
  183055             : #if ROSE_ALLOC_TRACE
  183056             :         if (blockIndex > 0) {
  183057             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLongDoubleVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongDoubleVal) = %" PRIuPTR " SgLongDoubleVal::pool_size = %d \n",
  183058             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLongDoubleVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLongDoubleVal),SgLongDoubleVal::pool_size);
  183059             :         }
  183060             : #endif
  183061             : 
  183062           0 :         SgLongDoubleVal * pointer = (SgLongDoubleVal*) ROSE_MALLOC ( SgLongDoubleVal::pool_size * sizeof(SgLongDoubleVal) );
  183063           0 :         assert( pointer != NULL );
  183064             : #if ROSE_ALLOC_MEMSET == 1
  183065             :         memset(pointer, 0x00, SgLongDoubleVal::pool_size * sizeof(SgLongDoubleVal));
  183066             : #elif ROSE_ALLOC_MEMSET == 2
  183067             :         memset(pointer, 0xCC, SgLongDoubleVal::pool_size * sizeof(SgLongDoubleVal));
  183068             : #endif
  183069           0 :         SgLongDoubleVal::pools.push_back( (unsigned char*)(pointer) );
  183070           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLongDoubleVal::pool_size * sizeof(SgLongDoubleVal), V_SgLongDoubleVal ) );
  183071             : 
  183072           0 :         if ( SgLongDoubleVal::next_node != NULL ) {
  183073           0 :           if ( blockIndex > 0 ) {
  183074           0 :             SgLongDoubleVal * blkptr = (SgLongDoubleVal*)(SgLongDoubleVal::pools[blockIndex-1]);
  183075           0 :             blkptr[ SgLongDoubleVal::pool_size - 1 ].set_freepointer(pointer);
  183076             :           }
  183077             :         } else {
  183078           0 :           SgLongDoubleVal::next_node = pointer;
  183079             :         }
  183080             : 
  183081           0 :         for (unsigned i = 0; i < SgLongDoubleVal::pool_size-1; ++i)
  183082             :            {
  183083           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  183084             :            }
  183085           0 :         pointer[ SgLongDoubleVal::pool_size -1 ].set_freepointer(NULL);
  183086             : 
  183087           0 :         blockIndex++;
  183088             :       }
  183089           2 :   }
  183090             : 
  183091             : //############################################################################
  183092             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  183093             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  183094             :  * not compressed. However, that stuff is not yet implemented! 
  183095             :  */
  183096             : unsigned long
  183097           0 : SgLongDoubleVal::getNumberOfLastValidPointer()
  183098             :    {
  183099           0 :       SgLongDoubleVal* testPointer = (SgLongDoubleVal*)(SgLongDoubleVal::pools.back());
  183100           0 :       unsigned long localIndex = SgLongDoubleVal::pool_size - 1;
  183101           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  183102             :          {
  183103           0 :            localIndex--;
  183104             :          }
  183105           0 :       return (localIndex + SgLongDoubleVal::pool_size * (SgLongDoubleVal::pools.size()-1));
  183106             :    }
  183107             : 
  183108             : //############################################################################
  183109             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  183110             :  * memory pool and initializes the data member in class SgLongDoubleValStroageClass
  183111             :  * from its counterpart of SgLongDoubleVal. The return value is just for checking, 
  183112             :  * that the whole StorageClassArray is initialized!
  183113             :  */
  183114             : unsigned long
  183115           0 : SgLongDoubleVal::initializeStorageClassArray( SgLongDoubleValStorageClass *storageArray )
  183116             :    {
  183117           0 :      unsigned long storageCounter = 0;
  183118           0 :      std::vector < unsigned char* > :: const_iterator block = SgLongDoubleVal::pools.begin();
  183119           0 :      SgLongDoubleVal* pointer = NULL;
  183120           0 :      while ( block != SgLongDoubleVal::pools.end() ) {
  183121           0 :           pointer = (SgLongDoubleVal*) (*block);
  183122           0 :           for ( unsigned i = 0; i < SgLongDoubleVal::pool_size; ++i ) {
  183123           0 :                if ( pointer->get_freepointer() != NULL ) {
  183124           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  183125           0 :                  storageArray++;
  183126           0 :                  storageCounter++;
  183127             :                }
  183128           0 :                pointer++;
  183129             :              }
  183130           0 :            block++;
  183131             :         }
  183132           0 :      return storageCounter;
  183133             :    }
  183134             : 
  183135             : /* #line 183136 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  183136             : 
  183137             : 
  183138             : 
  183139             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  183140             : 
  183141             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  183142             : 
  183143             : //############################################################################
  183144             : /* JH (02/02/2006) Constructor of the IR node SgComplexVal that takes its 
  183145             :  * corresponding StorageClass as parameter
  183146             :  */
  183147           0 : SgComplexVal :: SgComplexVal ( const SgComplexValStorageClass& storageSource )   : SgValueExp (storageSource)
  183148             :    {
  183149             : 
  183150             : 
  183151             : /* #line 183152 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  183152             : 
  183153           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  183154           0 :      p_real_value =  (SgValueExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_real_value) );
  183155           0 :      p_imaginary_value =  (SgValueExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_imaginary_value) );
  183156           0 :      p_precisionType =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_precisionType) );
  183157           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  183158             : 
  183159             : 
  183160             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  183161             : 
  183162             : 
  183163           0 :    }
  183164             : 
  183165             : //############################################################################
  183166             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  183167             :  * within the working AST. 
  183168             :  */
  183169           0 : SgComplexVal * SgComplexVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  183170           0 :      SgComplexVal* returnPointer = NULL;
  183171           0 :      if ( globalIndex != 0 )
  183172             :         {
  183173             : 
  183174             : #if FILE_IO_EXTRA_CHECK
  183175           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgComplexVal ) ) <= globalIndex ) ;
  183176           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgComplexVal + 1 ) ) );
  183177             : #endif
  183178           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgComplexVal )  
  183179           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgComplexVal );
  183180           0 :           unsigned long positionInPool = localIndex % SgComplexVal::pool_size;
  183181           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgComplexVal::pool_size;
  183182             : 
  183183             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  183184             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  183185             : 
  183186           0 :           returnPointer = &( ( (SgComplexVal*)(SgComplexVal::pools[memoryBlock]) ) [positionInPool]) ;
  183187             : 
  183188           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  183189             :         }
  183190           0 :      return returnPointer ;
  183191             :    }
  183192             : 
  183193             : //############################################################################
  183194             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  183195             :   for the AST with the index astIndex
  183196             : */
  183197           0 : SgComplexVal * SgComplexVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  183198           0 :      SgComplexVal* returnPointer = NULL;
  183199           0 :      if ( globalIndex != 0 )
  183200             :         {
  183201             : 
  183202             : #if FILE_IO_EXTRA_CHECK
  183203           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgComplexVal ) ) <= globalIndex ) ;
  183204           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgComplexVal + 1 ) ) );
  183205             : #endif
  183206           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgComplexVal )
  183207           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgComplexVal );
  183208           0 :           unsigned long positionInPool = localIndex % SgComplexVal::pool_size ;
  183209           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgComplexVal::pool_size ;
  183210             : 
  183211             : #if FILE_IO_EXTRA_CHECK
  183212             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  183213             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  183214             : #endif
  183215             : 
  183216           0 :           returnPointer = &( ( (SgComplexVal*)(SgComplexVal::pools[memoryBlock]) ) [positionInPool]) ;
  183217             : 
  183218             : #if FILE_IO_EXTRA_CHECK
  183219           0 :           assert ( returnPointer != NULL ) ;
  183220             : #endif
  183221             :         }
  183222           0 :      return returnPointer ;
  183223             :    }
  183224             : 
  183225             : //############################################################################
  183226             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  183227             :  * pool size! We set for every valid object in the memory pool the freepointer
  183228             :  * to the global index and increase the global index afterwards. For all the 
  183229             :  * invalid objects (means address ranges within the memory pool that were not
  183230             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  183231             :  * distinguish valid from invalid objects! 
  183232             :  */
  183233             : unsigned long
  183234           5 : SgComplexVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  183235             :    {
  183236           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  183237           5 :      SgComplexVal* pointer = NULL;
  183238           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  183239           5 :      std::vector < unsigned char* > :: const_iterator block;
  183240           5 :      for ( block = SgComplexVal::pools.begin(); block != SgComplexVal::pools.end() ; ++block )
  183241             :         {
  183242           0 :           pointer = (SgComplexVal*)(*block);
  183243           0 :           for (unsigned i = 0; i < SgComplexVal::pool_size; ++i )
  183244             :              {
  183245             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  183246             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  183247             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  183248             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  183249             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  183250             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  183251             :             // properly; so this will have to be checked next.
  183252             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  183253             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  183254           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  183255             :                   {
  183256           0 :                     pointer[i].set_freepointer((SgComplexVal*)(globalIndex));
  183257           0 :                     globalIndex++;
  183258             :                   }
  183259             :                else
  183260             :                   {
  183261           0 :                     pointer[i].set_freepointer(NULL);
  183262             :                   }
  183263             :               }
  183264             :         }
  183265           5 :      return globalIndex;
  183266             :    }
  183267             : 
  183268             : //############################################################################
  183269             : // JH (01/14/2006)
  183270             : void
  183271           5 : SgComplexVal::resetValidFreepointers( )
  183272             :    {
  183273           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  183274           5 :      SgComplexVal* pointer = NULL;
  183275           5 :      std::vector < unsigned char* > :: const_iterator block;
  183276           5 :      SgComplexVal* pointerOfLinkedList = NULL;
  183277           5 :      for ( block = SgComplexVal::pools.begin(); block != SgComplexVal::pools.end() ; ++block )
  183278             :         {
  183279           0 :           pointer = (SgComplexVal*)(*block);
  183280           0 :           for (unsigned i = 0; i < SgComplexVal::pool_size; ++i )
  183281             :              {
  183282             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  183283             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  183284             :             // memory blocks!.
  183285           0 :                if ( pointer[i].get_freepointer() != NULL )
  183286             :                   {
  183287           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  183288             :                   }
  183289             :                else
  183290             :                   {
  183291           0 :                     if ( pointerOfLinkedList == NULL )
  183292             :                        {
  183293           0 :                          SgComplexVal::next_node = &(pointer[i]);
  183294             :                        }
  183295             :                     else
  183296             :                        {
  183297             :                       // printf ("In SgComplexVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  183298           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  183299             :                        }
  183300             :                     pointerOfLinkedList = &(pointer[i]);
  183301             :                   }
  183302             :               }
  183303             :         }
  183304             : 
  183305           5 :      if ( pointerOfLinkedList != NULL )
  183306             :         {
  183307             :        // printf ("In SgComplexVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  183308           0 :           pointerOfLinkedList->set_freepointer(NULL);
  183309             :        // DQ (6/6/2010): Temporary debugging...
  183310             :        //   ROSE_ASSERT(false);
  183311             :         }
  183312             : 
  183313           5 :      return ;
  183314             :    }
  183315             : 
  183316             : //############################################################################
  183317             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  183318             :  * within the memory pool and resets the freepointers, in order to achieve a 
  183319             :  * linked list, that has no jumps and starts at the beginning! This function 
  183320             :  * does not extend the memory pool, since we do not delete any memory blocks,
  183321             :  * but delete the valid objects.  
  183322             :  */
  183323             : void
  183324           0 : SgComplexVal::clearMemoryPool( )
  183325             :    {
  183326             :   // printf ("Inside of SgComplexVal::clearMemoryPool() \n");
  183327             : 
  183328           0 :      SgComplexVal* pointer = NULL, *tempPointer = NULL;
  183329           0 :      std::vector < unsigned char* > :: const_iterator block;
  183330           0 :      if ( SgComplexVal::pools.empty() == false )
  183331             :         {
  183332           0 :           block = SgComplexVal::pools.begin() ;
  183333           0 :           SgComplexVal::next_node = (SgComplexVal*) (*block);
  183334             : 
  183335           0 :           while ( block != SgComplexVal::pools.end() )
  183336             :              {
  183337           0 :                pointer = (SgComplexVal*) (*block);
  183338           0 :                if ( tempPointer != NULL )
  183339             :                   {
  183340           0 :                     tempPointer->set_freepointer(pointer);
  183341             :                   }
  183342           0 :                for (unsigned i = 0; i < SgComplexVal::pool_size - 1; ++i)
  183343             :                   {
  183344           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  183345             :                   }
  183346           0 :                 pointer[SgComplexVal::pool_size-1].set_freepointer(NULL);
  183347           0 :                 tempPointer = &(pointer[SgComplexVal::pool_size-1]);
  183348           0 :                 ++block;
  183349             :              }
  183350             :         }
  183351           0 :    }
  183352             : 
  183353           5 : void SgComplexVal::deleteMemoryPool() {
  183354           5 :   for (auto p: SgComplexVal::pools) {
  183355           0 :     ROSE_FREE(p);
  183356             :   }
  183357           5 :   SgComplexVal::next_node = nullptr;
  183358           5 :   SgComplexVal::pools.clear();
  183359           5 : }
  183360             : 
  183361             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  183362             : //                 reading multiple binary files to for a single AST.
  183363             : /////////// new version ////////////////////////////////
  183364             : //############################################################################
  183365             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  183366             : void
  183367           2 : SgComplexVal::extendMemoryPoolForFileIO( )
  183368             :   {
  183369           2 :     size_t blockIndex = SgComplexVal::pools.size();
  183370           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgComplexVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgComplexVal);
  183371             : 
  183372           2 :     while ( (blockIndex * SgComplexVal::pool_size) < newPoolSize)
  183373             :       {
  183374             : #if ROSE_ALLOC_TRACE
  183375             :         if (blockIndex > 0) {
  183376             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgComplexVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgComplexVal) = %" PRIuPTR " SgComplexVal::pool_size = %d \n",
  183377             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgComplexVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgComplexVal),SgComplexVal::pool_size);
  183378             :         }
  183379             : #endif
  183380             : 
  183381           0 :         SgComplexVal * pointer = (SgComplexVal*) ROSE_MALLOC ( SgComplexVal::pool_size * sizeof(SgComplexVal) );
  183382           0 :         assert( pointer != NULL );
  183383             : #if ROSE_ALLOC_MEMSET == 1
  183384             :         memset(pointer, 0x00, SgComplexVal::pool_size * sizeof(SgComplexVal));
  183385             : #elif ROSE_ALLOC_MEMSET == 2
  183386             :         memset(pointer, 0xCC, SgComplexVal::pool_size * sizeof(SgComplexVal));
  183387             : #endif
  183388           0 :         SgComplexVal::pools.push_back( (unsigned char*)(pointer) );
  183389           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgComplexVal::pool_size * sizeof(SgComplexVal), V_SgComplexVal ) );
  183390             : 
  183391           0 :         if ( SgComplexVal::next_node != NULL ) {
  183392           0 :           if ( blockIndex > 0 ) {
  183393           0 :             SgComplexVal * blkptr = (SgComplexVal*)(SgComplexVal::pools[blockIndex-1]);
  183394           0 :             blkptr[ SgComplexVal::pool_size - 1 ].set_freepointer(pointer);
  183395             :           }
  183396             :         } else {
  183397           0 :           SgComplexVal::next_node = pointer;
  183398             :         }
  183399             : 
  183400           0 :         for (unsigned i = 0; i < SgComplexVal::pool_size-1; ++i)
  183401             :            {
  183402           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  183403             :            }
  183404           0 :         pointer[ SgComplexVal::pool_size -1 ].set_freepointer(NULL);
  183405             : 
  183406           0 :         blockIndex++;
  183407             :       }
  183408           2 :   }
  183409             : 
  183410             : //############################################################################
  183411             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  183412             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  183413             :  * not compressed. However, that stuff is not yet implemented! 
  183414             :  */
  183415             : unsigned long
  183416           0 : SgComplexVal::getNumberOfLastValidPointer()
  183417             :    {
  183418           0 :       SgComplexVal* testPointer = (SgComplexVal*)(SgComplexVal::pools.back());
  183419           0 :       unsigned long localIndex = SgComplexVal::pool_size - 1;
  183420           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  183421             :          {
  183422           0 :            localIndex--;
  183423             :          }
  183424           0 :       return (localIndex + SgComplexVal::pool_size * (SgComplexVal::pools.size()-1));
  183425             :    }
  183426             : 
  183427             : //############################################################################
  183428             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  183429             :  * memory pool and initializes the data member in class SgComplexValStroageClass
  183430             :  * from its counterpart of SgComplexVal. The return value is just for checking, 
  183431             :  * that the whole StorageClassArray is initialized!
  183432             :  */
  183433             : unsigned long
  183434           0 : SgComplexVal::initializeStorageClassArray( SgComplexValStorageClass *storageArray )
  183435             :    {
  183436           0 :      unsigned long storageCounter = 0;
  183437           0 :      std::vector < unsigned char* > :: const_iterator block = SgComplexVal::pools.begin();
  183438           0 :      SgComplexVal* pointer = NULL;
  183439           0 :      while ( block != SgComplexVal::pools.end() ) {
  183440           0 :           pointer = (SgComplexVal*) (*block);
  183441           0 :           for ( unsigned i = 0; i < SgComplexVal::pool_size; ++i ) {
  183442           0 :                if ( pointer->get_freepointer() != NULL ) {
  183443           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  183444           0 :                  storageArray++;
  183445           0 :                  storageCounter++;
  183446             :                }
  183447           0 :                pointer++;
  183448             :              }
  183449           0 :            block++;
  183450             :         }
  183451           0 :      return storageCounter;
  183452             :    }
  183453             : 
  183454             : /* #line 183455 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  183455             : 
  183456             : 
  183457             : 
  183458             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  183459             : 
  183460             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  183461             : 
  183462             : //############################################################################
  183463             : /* JH (02/02/2006) Constructor of the IR node SgUpcThreads that takes its 
  183464             :  * corresponding StorageClass as parameter
  183465             :  */
  183466           0 : SgUpcThreads :: SgUpcThreads ( const SgUpcThreadsStorageClass& storageSource )   : SgValueExp (storageSource)
  183467             :    {
  183468             : 
  183469             : 
  183470             : /* #line 183471 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  183471             : 
  183472           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  183473           0 :      p_value = storageSource.storageOf_value ;
  183474           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  183475             : 
  183476             : 
  183477             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  183478             : 
  183479             : 
  183480           0 :    }
  183481             : 
  183482             : //############################################################################
  183483             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  183484             :  * within the working AST. 
  183485             :  */
  183486           0 : SgUpcThreads * SgUpcThreads::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  183487           0 :      SgUpcThreads* returnPointer = NULL;
  183488           0 :      if ( globalIndex != 0 )
  183489             :         {
  183490             : 
  183491             : #if FILE_IO_EXTRA_CHECK
  183492           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcThreads ) ) <= globalIndex ) ;
  183493           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcThreads + 1 ) ) );
  183494             : #endif
  183495           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcThreads )  
  183496           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcThreads );
  183497           0 :           unsigned long positionInPool = localIndex % SgUpcThreads::pool_size;
  183498           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcThreads::pool_size;
  183499             : 
  183500             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  183501             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  183502             : 
  183503           0 :           returnPointer = &( ( (SgUpcThreads*)(SgUpcThreads::pools[memoryBlock]) ) [positionInPool]) ;
  183504             : 
  183505           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  183506             :         }
  183507           0 :      return returnPointer ;
  183508             :    }
  183509             : 
  183510             : //############################################################################
  183511             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  183512             :   for the AST with the index astIndex
  183513             : */
  183514           0 : SgUpcThreads * SgUpcThreads::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  183515           0 :      SgUpcThreads* returnPointer = NULL;
  183516           0 :      if ( globalIndex != 0 )
  183517             :         {
  183518             : 
  183519             : #if FILE_IO_EXTRA_CHECK
  183520           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcThreads ) ) <= globalIndex ) ;
  183521           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcThreads + 1 ) ) );
  183522             : #endif
  183523           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcThreads )
  183524           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcThreads );
  183525           0 :           unsigned long positionInPool = localIndex % SgUpcThreads::pool_size ;
  183526           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcThreads::pool_size ;
  183527             : 
  183528             : #if FILE_IO_EXTRA_CHECK
  183529             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  183530             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  183531             : #endif
  183532             : 
  183533           0 :           returnPointer = &( ( (SgUpcThreads*)(SgUpcThreads::pools[memoryBlock]) ) [positionInPool]) ;
  183534             : 
  183535             : #if FILE_IO_EXTRA_CHECK
  183536           0 :           assert ( returnPointer != NULL ) ;
  183537             : #endif
  183538             :         }
  183539           0 :      return returnPointer ;
  183540             :    }
  183541             : 
  183542             : //############################################################################
  183543             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  183544             :  * pool size! We set for every valid object in the memory pool the freepointer
  183545             :  * to the global index and increase the global index afterwards. For all the 
  183546             :  * invalid objects (means address ranges within the memory pool that were not
  183547             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  183548             :  * distinguish valid from invalid objects! 
  183549             :  */
  183550             : unsigned long
  183551           5 : SgUpcThreads::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  183552             :    {
  183553           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  183554           5 :      SgUpcThreads* pointer = NULL;
  183555           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  183556           5 :      std::vector < unsigned char* > :: const_iterator block;
  183557           5 :      for ( block = SgUpcThreads::pools.begin(); block != SgUpcThreads::pools.end() ; ++block )
  183558             :         {
  183559           0 :           pointer = (SgUpcThreads*)(*block);
  183560           0 :           for (unsigned i = 0; i < SgUpcThreads::pool_size; ++i )
  183561             :              {
  183562             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  183563             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  183564             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  183565             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  183566             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  183567             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  183568             :             // properly; so this will have to be checked next.
  183569             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  183570             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  183571           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  183572             :                   {
  183573           0 :                     pointer[i].set_freepointer((SgUpcThreads*)(globalIndex));
  183574           0 :                     globalIndex++;
  183575             :                   }
  183576             :                else
  183577             :                   {
  183578           0 :                     pointer[i].set_freepointer(NULL);
  183579             :                   }
  183580             :               }
  183581             :         }
  183582           5 :      return globalIndex;
  183583             :    }
  183584             : 
  183585             : //############################################################################
  183586             : // JH (01/14/2006)
  183587             : void
  183588           5 : SgUpcThreads::resetValidFreepointers( )
  183589             :    {
  183590           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  183591           5 :      SgUpcThreads* pointer = NULL;
  183592           5 :      std::vector < unsigned char* > :: const_iterator block;
  183593           5 :      SgUpcThreads* pointerOfLinkedList = NULL;
  183594           5 :      for ( block = SgUpcThreads::pools.begin(); block != SgUpcThreads::pools.end() ; ++block )
  183595             :         {
  183596           0 :           pointer = (SgUpcThreads*)(*block);
  183597           0 :           for (unsigned i = 0; i < SgUpcThreads::pool_size; ++i )
  183598             :              {
  183599             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  183600             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  183601             :             // memory blocks!.
  183602           0 :                if ( pointer[i].get_freepointer() != NULL )
  183603             :                   {
  183604           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  183605             :                   }
  183606             :                else
  183607             :                   {
  183608           0 :                     if ( pointerOfLinkedList == NULL )
  183609             :                        {
  183610           0 :                          SgUpcThreads::next_node = &(pointer[i]);
  183611             :                        }
  183612             :                     else
  183613             :                        {
  183614             :                       // printf ("In SgUpcThreads::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  183615           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  183616             :                        }
  183617             :                     pointerOfLinkedList = &(pointer[i]);
  183618             :                   }
  183619             :               }
  183620             :         }
  183621             : 
  183622           5 :      if ( pointerOfLinkedList != NULL )
  183623             :         {
  183624             :        // printf ("In SgUpcThreads::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  183625           0 :           pointerOfLinkedList->set_freepointer(NULL);
  183626             :        // DQ (6/6/2010): Temporary debugging...
  183627             :        //   ROSE_ASSERT(false);
  183628             :         }
  183629             : 
  183630           5 :      return ;
  183631             :    }
  183632             : 
  183633             : //############################################################################
  183634             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  183635             :  * within the memory pool and resets the freepointers, in order to achieve a 
  183636             :  * linked list, that has no jumps and starts at the beginning! This function 
  183637             :  * does not extend the memory pool, since we do not delete any memory blocks,
  183638             :  * but delete the valid objects.  
  183639             :  */
  183640             : void
  183641           0 : SgUpcThreads::clearMemoryPool( )
  183642             :    {
  183643             :   // printf ("Inside of SgUpcThreads::clearMemoryPool() \n");
  183644             : 
  183645           0 :      SgUpcThreads* pointer = NULL, *tempPointer = NULL;
  183646           0 :      std::vector < unsigned char* > :: const_iterator block;
  183647           0 :      if ( SgUpcThreads::pools.empty() == false )
  183648             :         {
  183649           0 :           block = SgUpcThreads::pools.begin() ;
  183650           0 :           SgUpcThreads::next_node = (SgUpcThreads*) (*block);
  183651             : 
  183652           0 :           while ( block != SgUpcThreads::pools.end() )
  183653             :              {
  183654           0 :                pointer = (SgUpcThreads*) (*block);
  183655           0 :                if ( tempPointer != NULL )
  183656             :                   {
  183657           0 :                     tempPointer->set_freepointer(pointer);
  183658             :                   }
  183659           0 :                for (unsigned i = 0; i < SgUpcThreads::pool_size - 1; ++i)
  183660             :                   {
  183661           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  183662             :                   }
  183663           0 :                 pointer[SgUpcThreads::pool_size-1].set_freepointer(NULL);
  183664           0 :                 tempPointer = &(pointer[SgUpcThreads::pool_size-1]);
  183665           0 :                 ++block;
  183666             :              }
  183667             :         }
  183668           0 :    }
  183669             : 
  183670           5 : void SgUpcThreads::deleteMemoryPool() {
  183671           5 :   for (auto p: SgUpcThreads::pools) {
  183672           0 :     ROSE_FREE(p);
  183673             :   }
  183674           5 :   SgUpcThreads::next_node = nullptr;
  183675           5 :   SgUpcThreads::pools.clear();
  183676           5 : }
  183677             : 
  183678             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  183679             : //                 reading multiple binary files to for a single AST.
  183680             : /////////// new version ////////////////////////////////
  183681             : //############################################################################
  183682             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  183683             : void
  183684           2 : SgUpcThreads::extendMemoryPoolForFileIO( )
  183685             :   {
  183686           2 :     size_t blockIndex = SgUpcThreads::pools.size();
  183687           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcThreads) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcThreads);
  183688             : 
  183689           2 :     while ( (blockIndex * SgUpcThreads::pool_size) < newPoolSize)
  183690             :       {
  183691             : #if ROSE_ALLOC_TRACE
  183692             :         if (blockIndex > 0) {
  183693             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcThreads) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcThreads) = %" PRIuPTR " SgUpcThreads::pool_size = %d \n",
  183694             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcThreads),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcThreads),SgUpcThreads::pool_size);
  183695             :         }
  183696             : #endif
  183697             : 
  183698           0 :         SgUpcThreads * pointer = (SgUpcThreads*) ROSE_MALLOC ( SgUpcThreads::pool_size * sizeof(SgUpcThreads) );
  183699           0 :         assert( pointer != NULL );
  183700             : #if ROSE_ALLOC_MEMSET == 1
  183701             :         memset(pointer, 0x00, SgUpcThreads::pool_size * sizeof(SgUpcThreads));
  183702             : #elif ROSE_ALLOC_MEMSET == 2
  183703             :         memset(pointer, 0xCC, SgUpcThreads::pool_size * sizeof(SgUpcThreads));
  183704             : #endif
  183705           0 :         SgUpcThreads::pools.push_back( (unsigned char*)(pointer) );
  183706           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcThreads::pool_size * sizeof(SgUpcThreads), V_SgUpcThreads ) );
  183707             : 
  183708           0 :         if ( SgUpcThreads::next_node != NULL ) {
  183709           0 :           if ( blockIndex > 0 ) {
  183710           0 :             SgUpcThreads * blkptr = (SgUpcThreads*)(SgUpcThreads::pools[blockIndex-1]);
  183711           0 :             blkptr[ SgUpcThreads::pool_size - 1 ].set_freepointer(pointer);
  183712             :           }
  183713             :         } else {
  183714           0 :           SgUpcThreads::next_node = pointer;
  183715             :         }
  183716             : 
  183717           0 :         for (unsigned i = 0; i < SgUpcThreads::pool_size-1; ++i)
  183718             :            {
  183719           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  183720             :            }
  183721           0 :         pointer[ SgUpcThreads::pool_size -1 ].set_freepointer(NULL);
  183722             : 
  183723           0 :         blockIndex++;
  183724             :       }
  183725           2 :   }
  183726             : 
  183727             : //############################################################################
  183728             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  183729             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  183730             :  * not compressed. However, that stuff is not yet implemented! 
  183731             :  */
  183732             : unsigned long
  183733           0 : SgUpcThreads::getNumberOfLastValidPointer()
  183734             :    {
  183735           0 :       SgUpcThreads* testPointer = (SgUpcThreads*)(SgUpcThreads::pools.back());
  183736           0 :       unsigned long localIndex = SgUpcThreads::pool_size - 1;
  183737           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  183738             :          {
  183739           0 :            localIndex--;
  183740             :          }
  183741           0 :       return (localIndex + SgUpcThreads::pool_size * (SgUpcThreads::pools.size()-1));
  183742             :    }
  183743             : 
  183744             : //############################################################################
  183745             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  183746             :  * memory pool and initializes the data member in class SgUpcThreadsStroageClass
  183747             :  * from its counterpart of SgUpcThreads. The return value is just for checking, 
  183748             :  * that the whole StorageClassArray is initialized!
  183749             :  */
  183750             : unsigned long
  183751           0 : SgUpcThreads::initializeStorageClassArray( SgUpcThreadsStorageClass *storageArray )
  183752             :    {
  183753           0 :      unsigned long storageCounter = 0;
  183754           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcThreads::pools.begin();
  183755           0 :      SgUpcThreads* pointer = NULL;
  183756           0 :      while ( block != SgUpcThreads::pools.end() ) {
  183757           0 :           pointer = (SgUpcThreads*) (*block);
  183758           0 :           for ( unsigned i = 0; i < SgUpcThreads::pool_size; ++i ) {
  183759           0 :                if ( pointer->get_freepointer() != NULL ) {
  183760           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  183761           0 :                  storageArray++;
  183762           0 :                  storageCounter++;
  183763             :                }
  183764           0 :                pointer++;
  183765             :              }
  183766           0 :            block++;
  183767             :         }
  183768           0 :      return storageCounter;
  183769             :    }
  183770             : 
  183771             : /* #line 183772 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  183772             : 
  183773             : 
  183774             : 
  183775             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  183776             : 
  183777             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  183778             : 
  183779             : //############################################################################
  183780             : /* JH (02/02/2006) Constructor of the IR node SgUpcMythread that takes its 
  183781             :  * corresponding StorageClass as parameter
  183782             :  */
  183783           0 : SgUpcMythread :: SgUpcMythread ( const SgUpcMythreadStorageClass& storageSource )   : SgValueExp (storageSource)
  183784             :    {
  183785             : 
  183786             : 
  183787             : /* #line 183788 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  183788             : 
  183789           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  183790           0 :      p_value = storageSource.storageOf_value ;
  183791           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  183792             : 
  183793             : 
  183794             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  183795             : 
  183796             : 
  183797           0 :    }
  183798             : 
  183799             : //############################################################################
  183800             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  183801             :  * within the working AST. 
  183802             :  */
  183803           0 : SgUpcMythread * SgUpcMythread::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  183804           0 :      SgUpcMythread* returnPointer = NULL;
  183805           0 :      if ( globalIndex != 0 )
  183806             :         {
  183807             : 
  183808             : #if FILE_IO_EXTRA_CHECK
  183809           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcMythread ) ) <= globalIndex ) ;
  183810           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcMythread + 1 ) ) );
  183811             : #endif
  183812           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcMythread )  
  183813           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcMythread );
  183814           0 :           unsigned long positionInPool = localIndex % SgUpcMythread::pool_size;
  183815           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcMythread::pool_size;
  183816             : 
  183817             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  183818             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  183819             : 
  183820           0 :           returnPointer = &( ( (SgUpcMythread*)(SgUpcMythread::pools[memoryBlock]) ) [positionInPool]) ;
  183821             : 
  183822           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  183823             :         }
  183824           0 :      return returnPointer ;
  183825             :    }
  183826             : 
  183827             : //############################################################################
  183828             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  183829             :   for the AST with the index astIndex
  183830             : */
  183831           0 : SgUpcMythread * SgUpcMythread::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  183832           0 :      SgUpcMythread* returnPointer = NULL;
  183833           0 :      if ( globalIndex != 0 )
  183834             :         {
  183835             : 
  183836             : #if FILE_IO_EXTRA_CHECK
  183837           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcMythread ) ) <= globalIndex ) ;
  183838           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcMythread + 1 ) ) );
  183839             : #endif
  183840           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcMythread )
  183841           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcMythread );
  183842           0 :           unsigned long positionInPool = localIndex % SgUpcMythread::pool_size ;
  183843           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcMythread::pool_size ;
  183844             : 
  183845             : #if FILE_IO_EXTRA_CHECK
  183846             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  183847             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  183848             : #endif
  183849             : 
  183850           0 :           returnPointer = &( ( (SgUpcMythread*)(SgUpcMythread::pools[memoryBlock]) ) [positionInPool]) ;
  183851             : 
  183852             : #if FILE_IO_EXTRA_CHECK
  183853           0 :           assert ( returnPointer != NULL ) ;
  183854             : #endif
  183855             :         }
  183856           0 :      return returnPointer ;
  183857             :    }
  183858             : 
  183859             : //############################################################################
  183860             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  183861             :  * pool size! We set for every valid object in the memory pool the freepointer
  183862             :  * to the global index and increase the global index afterwards. For all the 
  183863             :  * invalid objects (means address ranges within the memory pool that were not
  183864             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  183865             :  * distinguish valid from invalid objects! 
  183866             :  */
  183867             : unsigned long
  183868           5 : SgUpcMythread::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  183869             :    {
  183870           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  183871           5 :      SgUpcMythread* pointer = NULL;
  183872           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  183873           5 :      std::vector < unsigned char* > :: const_iterator block;
  183874           5 :      for ( block = SgUpcMythread::pools.begin(); block != SgUpcMythread::pools.end() ; ++block )
  183875             :         {
  183876           0 :           pointer = (SgUpcMythread*)(*block);
  183877           0 :           for (unsigned i = 0; i < SgUpcMythread::pool_size; ++i )
  183878             :              {
  183879             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  183880             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  183881             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  183882             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  183883             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  183884             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  183885             :             // properly; so this will have to be checked next.
  183886             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  183887             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  183888           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  183889             :                   {
  183890           0 :                     pointer[i].set_freepointer((SgUpcMythread*)(globalIndex));
  183891           0 :                     globalIndex++;
  183892             :                   }
  183893             :                else
  183894             :                   {
  183895           0 :                     pointer[i].set_freepointer(NULL);
  183896             :                   }
  183897             :               }
  183898             :         }
  183899           5 :      return globalIndex;
  183900             :    }
  183901             : 
  183902             : //############################################################################
  183903             : // JH (01/14/2006)
  183904             : void
  183905           5 : SgUpcMythread::resetValidFreepointers( )
  183906             :    {
  183907           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  183908           5 :      SgUpcMythread* pointer = NULL;
  183909           5 :      std::vector < unsigned char* > :: const_iterator block;
  183910           5 :      SgUpcMythread* pointerOfLinkedList = NULL;
  183911           5 :      for ( block = SgUpcMythread::pools.begin(); block != SgUpcMythread::pools.end() ; ++block )
  183912             :         {
  183913           0 :           pointer = (SgUpcMythread*)(*block);
  183914           0 :           for (unsigned i = 0; i < SgUpcMythread::pool_size; ++i )
  183915             :              {
  183916             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  183917             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  183918             :             // memory blocks!.
  183919           0 :                if ( pointer[i].get_freepointer() != NULL )
  183920             :                   {
  183921           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  183922             :                   }
  183923             :                else
  183924             :                   {
  183925           0 :                     if ( pointerOfLinkedList == NULL )
  183926             :                        {
  183927           0 :                          SgUpcMythread::next_node = &(pointer[i]);
  183928             :                        }
  183929             :                     else
  183930             :                        {
  183931             :                       // printf ("In SgUpcMythread::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  183932           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  183933             :                        }
  183934             :                     pointerOfLinkedList = &(pointer[i]);
  183935             :                   }
  183936             :               }
  183937             :         }
  183938             : 
  183939           5 :      if ( pointerOfLinkedList != NULL )
  183940             :         {
  183941             :        // printf ("In SgUpcMythread::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  183942           0 :           pointerOfLinkedList->set_freepointer(NULL);
  183943             :        // DQ (6/6/2010): Temporary debugging...
  183944             :        //   ROSE_ASSERT(false);
  183945             :         }
  183946             : 
  183947           5 :      return ;
  183948             :    }
  183949             : 
  183950             : //############################################################################
  183951             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  183952             :  * within the memory pool and resets the freepointers, in order to achieve a 
  183953             :  * linked list, that has no jumps and starts at the beginning! This function 
  183954             :  * does not extend the memory pool, since we do not delete any memory blocks,
  183955             :  * but delete the valid objects.  
  183956             :  */
  183957             : void
  183958           0 : SgUpcMythread::clearMemoryPool( )
  183959             :    {
  183960             :   // printf ("Inside of SgUpcMythread::clearMemoryPool() \n");
  183961             : 
  183962           0 :      SgUpcMythread* pointer = NULL, *tempPointer = NULL;
  183963           0 :      std::vector < unsigned char* > :: const_iterator block;
  183964           0 :      if ( SgUpcMythread::pools.empty() == false )
  183965             :         {
  183966           0 :           block = SgUpcMythread::pools.begin() ;
  183967           0 :           SgUpcMythread::next_node = (SgUpcMythread*) (*block);
  183968             : 
  183969           0 :           while ( block != SgUpcMythread::pools.end() )
  183970             :              {
  183971           0 :                pointer = (SgUpcMythread*) (*block);
  183972           0 :                if ( tempPointer != NULL )
  183973             :                   {
  183974           0 :                     tempPointer->set_freepointer(pointer);
  183975             :                   }
  183976           0 :                for (unsigned i = 0; i < SgUpcMythread::pool_size - 1; ++i)
  183977             :                   {
  183978           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  183979             :                   }
  183980           0 :                 pointer[SgUpcMythread::pool_size-1].set_freepointer(NULL);
  183981           0 :                 tempPointer = &(pointer[SgUpcMythread::pool_size-1]);
  183982           0 :                 ++block;
  183983             :              }
  183984             :         }
  183985           0 :    }
  183986             : 
  183987           5 : void SgUpcMythread::deleteMemoryPool() {
  183988           5 :   for (auto p: SgUpcMythread::pools) {
  183989           0 :     ROSE_FREE(p);
  183990             :   }
  183991           5 :   SgUpcMythread::next_node = nullptr;
  183992           5 :   SgUpcMythread::pools.clear();
  183993           5 : }
  183994             : 
  183995             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  183996             : //                 reading multiple binary files to for a single AST.
  183997             : /////////// new version ////////////////////////////////
  183998             : //############################################################################
  183999             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  184000             : void
  184001           2 : SgUpcMythread::extendMemoryPoolForFileIO( )
  184002             :   {
  184003           2 :     size_t blockIndex = SgUpcMythread::pools.size();
  184004           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcMythread) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcMythread);
  184005             : 
  184006           2 :     while ( (blockIndex * SgUpcMythread::pool_size) < newPoolSize)
  184007             :       {
  184008             : #if ROSE_ALLOC_TRACE
  184009             :         if (blockIndex > 0) {
  184010             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcMythread) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcMythread) = %" PRIuPTR " SgUpcMythread::pool_size = %d \n",
  184011             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcMythread),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcMythread),SgUpcMythread::pool_size);
  184012             :         }
  184013             : #endif
  184014             : 
  184015           0 :         SgUpcMythread * pointer = (SgUpcMythread*) ROSE_MALLOC ( SgUpcMythread::pool_size * sizeof(SgUpcMythread) );
  184016           0 :         assert( pointer != NULL );
  184017             : #if ROSE_ALLOC_MEMSET == 1
  184018             :         memset(pointer, 0x00, SgUpcMythread::pool_size * sizeof(SgUpcMythread));
  184019             : #elif ROSE_ALLOC_MEMSET == 2
  184020             :         memset(pointer, 0xCC, SgUpcMythread::pool_size * sizeof(SgUpcMythread));
  184021             : #endif
  184022           0 :         SgUpcMythread::pools.push_back( (unsigned char*)(pointer) );
  184023           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcMythread::pool_size * sizeof(SgUpcMythread), V_SgUpcMythread ) );
  184024             : 
  184025           0 :         if ( SgUpcMythread::next_node != NULL ) {
  184026           0 :           if ( blockIndex > 0 ) {
  184027           0 :             SgUpcMythread * blkptr = (SgUpcMythread*)(SgUpcMythread::pools[blockIndex-1]);
  184028           0 :             blkptr[ SgUpcMythread::pool_size - 1 ].set_freepointer(pointer);
  184029             :           }
  184030             :         } else {
  184031           0 :           SgUpcMythread::next_node = pointer;
  184032             :         }
  184033             : 
  184034           0 :         for (unsigned i = 0; i < SgUpcMythread::pool_size-1; ++i)
  184035             :            {
  184036           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  184037             :            }
  184038           0 :         pointer[ SgUpcMythread::pool_size -1 ].set_freepointer(NULL);
  184039             : 
  184040           0 :         blockIndex++;
  184041             :       }
  184042           2 :   }
  184043             : 
  184044             : //############################################################################
  184045             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  184046             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  184047             :  * not compressed. However, that stuff is not yet implemented! 
  184048             :  */
  184049             : unsigned long
  184050           0 : SgUpcMythread::getNumberOfLastValidPointer()
  184051             :    {
  184052           0 :       SgUpcMythread* testPointer = (SgUpcMythread*)(SgUpcMythread::pools.back());
  184053           0 :       unsigned long localIndex = SgUpcMythread::pool_size - 1;
  184054           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  184055             :          {
  184056           0 :            localIndex--;
  184057             :          }
  184058           0 :       return (localIndex + SgUpcMythread::pool_size * (SgUpcMythread::pools.size()-1));
  184059             :    }
  184060             : 
  184061             : //############################################################################
  184062             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  184063             :  * memory pool and initializes the data member in class SgUpcMythreadStroageClass
  184064             :  * from its counterpart of SgUpcMythread. The return value is just for checking, 
  184065             :  * that the whole StorageClassArray is initialized!
  184066             :  */
  184067             : unsigned long
  184068           0 : SgUpcMythread::initializeStorageClassArray( SgUpcMythreadStorageClass *storageArray )
  184069             :    {
  184070           0 :      unsigned long storageCounter = 0;
  184071           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcMythread::pools.begin();
  184072           0 :      SgUpcMythread* pointer = NULL;
  184073           0 :      while ( block != SgUpcMythread::pools.end() ) {
  184074           0 :           pointer = (SgUpcMythread*) (*block);
  184075           0 :           for ( unsigned i = 0; i < SgUpcMythread::pool_size; ++i ) {
  184076           0 :                if ( pointer->get_freepointer() != NULL ) {
  184077           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  184078           0 :                  storageArray++;
  184079           0 :                  storageCounter++;
  184080             :                }
  184081           0 :                pointer++;
  184082             :              }
  184083           0 :            block++;
  184084             :         }
  184085           0 :      return storageCounter;
  184086             :    }
  184087             : 
  184088             : /* #line 184089 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  184089             : 
  184090             : 
  184091             : 
  184092             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  184093             : 
  184094             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  184095             : 
  184096             : //############################################################################
  184097             : /* JH (02/02/2006) Constructor of the IR node SgTemplateParameterVal that takes its 
  184098             :  * corresponding StorageClass as parameter
  184099             :  */
  184100           0 : SgTemplateParameterVal :: SgTemplateParameterVal ( const SgTemplateParameterValStorageClass& storageSource )   : SgValueExp (storageSource)
  184101             :    {
  184102             : 
  184103             : 
  184104             : /* #line 184105 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  184105             : 
  184106           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  184107           0 :      p_template_parameter_position = storageSource.storageOf_template_parameter_position ;
  184108           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  184109           0 :      p_valueType =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_valueType) );
  184110             : 
  184111             : 
  184112             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  184113             : 
  184114             : 
  184115           0 :    }
  184116             : 
  184117             : //############################################################################
  184118             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  184119             :  * within the working AST. 
  184120             :  */
  184121           0 : SgTemplateParameterVal * SgTemplateParameterVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  184122           0 :      SgTemplateParameterVal* returnPointer = NULL;
  184123           0 :      if ( globalIndex != 0 )
  184124             :         {
  184125             : 
  184126             : #if FILE_IO_EXTRA_CHECK
  184127           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateParameterVal ) ) <= globalIndex ) ;
  184128           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateParameterVal + 1 ) ) );
  184129             : #endif
  184130           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateParameterVal )  
  184131           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateParameterVal );
  184132           0 :           unsigned long positionInPool = localIndex % SgTemplateParameterVal::pool_size;
  184133           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateParameterVal::pool_size;
  184134             : 
  184135             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  184136             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  184137             : 
  184138           0 :           returnPointer = &( ( (SgTemplateParameterVal*)(SgTemplateParameterVal::pools[memoryBlock]) ) [positionInPool]) ;
  184139             : 
  184140           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  184141             :         }
  184142           0 :      return returnPointer ;
  184143             :    }
  184144             : 
  184145             : //############################################################################
  184146             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  184147             :   for the AST with the index astIndex
  184148             : */
  184149           0 : SgTemplateParameterVal * SgTemplateParameterVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  184150           0 :      SgTemplateParameterVal* returnPointer = NULL;
  184151           0 :      if ( globalIndex != 0 )
  184152             :         {
  184153             : 
  184154             : #if FILE_IO_EXTRA_CHECK
  184155           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateParameterVal ) ) <= globalIndex ) ;
  184156           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateParameterVal + 1 ) ) );
  184157             : #endif
  184158           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateParameterVal )
  184159           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateParameterVal );
  184160           0 :           unsigned long positionInPool = localIndex % SgTemplateParameterVal::pool_size ;
  184161           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateParameterVal::pool_size ;
  184162             : 
  184163             : #if FILE_IO_EXTRA_CHECK
  184164             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  184165             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  184166             : #endif
  184167             : 
  184168           0 :           returnPointer = &( ( (SgTemplateParameterVal*)(SgTemplateParameterVal::pools[memoryBlock]) ) [positionInPool]) ;
  184169             : 
  184170             : #if FILE_IO_EXTRA_CHECK
  184171           0 :           assert ( returnPointer != NULL ) ;
  184172             : #endif
  184173             :         }
  184174           0 :      return returnPointer ;
  184175             :    }
  184176             : 
  184177             : //############################################################################
  184178             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  184179             :  * pool size! We set for every valid object in the memory pool the freepointer
  184180             :  * to the global index and increase the global index afterwards. For all the 
  184181             :  * invalid objects (means address ranges within the memory pool that were not
  184182             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  184183             :  * distinguish valid from invalid objects! 
  184184             :  */
  184185             : unsigned long
  184186           5 : SgTemplateParameterVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  184187             :    {
  184188           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  184189           5 :      SgTemplateParameterVal* pointer = NULL;
  184190           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  184191           5 :      std::vector < unsigned char* > :: const_iterator block;
  184192           5 :      for ( block = SgTemplateParameterVal::pools.begin(); block != SgTemplateParameterVal::pools.end() ; ++block )
  184193             :         {
  184194           0 :           pointer = (SgTemplateParameterVal*)(*block);
  184195           0 :           for (unsigned i = 0; i < SgTemplateParameterVal::pool_size; ++i )
  184196             :              {
  184197             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  184198             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  184199             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  184200             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  184201             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  184202             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  184203             :             // properly; so this will have to be checked next.
  184204             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  184205             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  184206           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  184207             :                   {
  184208           0 :                     pointer[i].set_freepointer((SgTemplateParameterVal*)(globalIndex));
  184209           0 :                     globalIndex++;
  184210             :                   }
  184211             :                else
  184212             :                   {
  184213           0 :                     pointer[i].set_freepointer(NULL);
  184214             :                   }
  184215             :               }
  184216             :         }
  184217           5 :      return globalIndex;
  184218             :    }
  184219             : 
  184220             : //############################################################################
  184221             : // JH (01/14/2006)
  184222             : void
  184223           5 : SgTemplateParameterVal::resetValidFreepointers( )
  184224             :    {
  184225           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  184226           5 :      SgTemplateParameterVal* pointer = NULL;
  184227           5 :      std::vector < unsigned char* > :: const_iterator block;
  184228           5 :      SgTemplateParameterVal* pointerOfLinkedList = NULL;
  184229           5 :      for ( block = SgTemplateParameterVal::pools.begin(); block != SgTemplateParameterVal::pools.end() ; ++block )
  184230             :         {
  184231           0 :           pointer = (SgTemplateParameterVal*)(*block);
  184232           0 :           for (unsigned i = 0; i < SgTemplateParameterVal::pool_size; ++i )
  184233             :              {
  184234             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  184235             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  184236             :             // memory blocks!.
  184237           0 :                if ( pointer[i].get_freepointer() != NULL )
  184238             :                   {
  184239           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  184240             :                   }
  184241             :                else
  184242             :                   {
  184243           0 :                     if ( pointerOfLinkedList == NULL )
  184244             :                        {
  184245           0 :                          SgTemplateParameterVal::next_node = &(pointer[i]);
  184246             :                        }
  184247             :                     else
  184248             :                        {
  184249             :                       // printf ("In SgTemplateParameterVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  184250           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  184251             :                        }
  184252             :                     pointerOfLinkedList = &(pointer[i]);
  184253             :                   }
  184254             :               }
  184255             :         }
  184256             : 
  184257           5 :      if ( pointerOfLinkedList != NULL )
  184258             :         {
  184259             :        // printf ("In SgTemplateParameterVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  184260           0 :           pointerOfLinkedList->set_freepointer(NULL);
  184261             :        // DQ (6/6/2010): Temporary debugging...
  184262             :        //   ROSE_ASSERT(false);
  184263             :         }
  184264             : 
  184265           5 :      return ;
  184266             :    }
  184267             : 
  184268             : //############################################################################
  184269             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  184270             :  * within the memory pool and resets the freepointers, in order to achieve a 
  184271             :  * linked list, that has no jumps and starts at the beginning! This function 
  184272             :  * does not extend the memory pool, since we do not delete any memory blocks,
  184273             :  * but delete the valid objects.  
  184274             :  */
  184275             : void
  184276           0 : SgTemplateParameterVal::clearMemoryPool( )
  184277             :    {
  184278             :   // printf ("Inside of SgTemplateParameterVal::clearMemoryPool() \n");
  184279             : 
  184280           0 :      SgTemplateParameterVal* pointer = NULL, *tempPointer = NULL;
  184281           0 :      std::vector < unsigned char* > :: const_iterator block;
  184282           0 :      if ( SgTemplateParameterVal::pools.empty() == false )
  184283             :         {
  184284           0 :           block = SgTemplateParameterVal::pools.begin() ;
  184285           0 :           SgTemplateParameterVal::next_node = (SgTemplateParameterVal*) (*block);
  184286             : 
  184287           0 :           while ( block != SgTemplateParameterVal::pools.end() )
  184288             :              {
  184289           0 :                pointer = (SgTemplateParameterVal*) (*block);
  184290           0 :                if ( tempPointer != NULL )
  184291             :                   {
  184292           0 :                     tempPointer->set_freepointer(pointer);
  184293             :                   }
  184294           0 :                for (unsigned i = 0; i < SgTemplateParameterVal::pool_size - 1; ++i)
  184295             :                   {
  184296           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  184297             :                   }
  184298           0 :                 pointer[SgTemplateParameterVal::pool_size-1].set_freepointer(NULL);
  184299           0 :                 tempPointer = &(pointer[SgTemplateParameterVal::pool_size-1]);
  184300           0 :                 ++block;
  184301             :              }
  184302             :         }
  184303           0 :    }
  184304             : 
  184305           5 : void SgTemplateParameterVal::deleteMemoryPool() {
  184306           5 :   for (auto p: SgTemplateParameterVal::pools) {
  184307           0 :     ROSE_FREE(p);
  184308             :   }
  184309           5 :   SgTemplateParameterVal::next_node = nullptr;
  184310           5 :   SgTemplateParameterVal::pools.clear();
  184311           5 : }
  184312             : 
  184313             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  184314             : //                 reading multiple binary files to for a single AST.
  184315             : /////////// new version ////////////////////////////////
  184316             : //############################################################################
  184317             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  184318             : void
  184319           2 : SgTemplateParameterVal::extendMemoryPoolForFileIO( )
  184320             :   {
  184321           2 :     size_t blockIndex = SgTemplateParameterVal::pools.size();
  184322           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameterVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameterVal);
  184323             : 
  184324           2 :     while ( (blockIndex * SgTemplateParameterVal::pool_size) < newPoolSize)
  184325             :       {
  184326             : #if ROSE_ALLOC_TRACE
  184327             :         if (blockIndex > 0) {
  184328             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameterVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameterVal) = %" PRIuPTR " SgTemplateParameterVal::pool_size = %d \n",
  184329             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateParameterVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateParameterVal),SgTemplateParameterVal::pool_size);
  184330             :         }
  184331             : #endif
  184332             : 
  184333           0 :         SgTemplateParameterVal * pointer = (SgTemplateParameterVal*) ROSE_MALLOC ( SgTemplateParameterVal::pool_size * sizeof(SgTemplateParameterVal) );
  184334           0 :         assert( pointer != NULL );
  184335             : #if ROSE_ALLOC_MEMSET == 1
  184336             :         memset(pointer, 0x00, SgTemplateParameterVal::pool_size * sizeof(SgTemplateParameterVal));
  184337             : #elif ROSE_ALLOC_MEMSET == 2
  184338             :         memset(pointer, 0xCC, SgTemplateParameterVal::pool_size * sizeof(SgTemplateParameterVal));
  184339             : #endif
  184340           0 :         SgTemplateParameterVal::pools.push_back( (unsigned char*)(pointer) );
  184341           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateParameterVal::pool_size * sizeof(SgTemplateParameterVal), V_SgTemplateParameterVal ) );
  184342             : 
  184343           0 :         if ( SgTemplateParameterVal::next_node != NULL ) {
  184344           0 :           if ( blockIndex > 0 ) {
  184345           0 :             SgTemplateParameterVal * blkptr = (SgTemplateParameterVal*)(SgTemplateParameterVal::pools[blockIndex-1]);
  184346           0 :             blkptr[ SgTemplateParameterVal::pool_size - 1 ].set_freepointer(pointer);
  184347             :           }
  184348             :         } else {
  184349           0 :           SgTemplateParameterVal::next_node = pointer;
  184350             :         }
  184351             : 
  184352           0 :         for (unsigned i = 0; i < SgTemplateParameterVal::pool_size-1; ++i)
  184353             :            {
  184354           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  184355             :            }
  184356           0 :         pointer[ SgTemplateParameterVal::pool_size -1 ].set_freepointer(NULL);
  184357             : 
  184358           0 :         blockIndex++;
  184359             :       }
  184360           2 :   }
  184361             : 
  184362             : //############################################################################
  184363             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  184364             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  184365             :  * not compressed. However, that stuff is not yet implemented! 
  184366             :  */
  184367             : unsigned long
  184368           0 : SgTemplateParameterVal::getNumberOfLastValidPointer()
  184369             :    {
  184370           0 :       SgTemplateParameterVal* testPointer = (SgTemplateParameterVal*)(SgTemplateParameterVal::pools.back());
  184371           0 :       unsigned long localIndex = SgTemplateParameterVal::pool_size - 1;
  184372           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  184373             :          {
  184374           0 :            localIndex--;
  184375             :          }
  184376           0 :       return (localIndex + SgTemplateParameterVal::pool_size * (SgTemplateParameterVal::pools.size()-1));
  184377             :    }
  184378             : 
  184379             : //############################################################################
  184380             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  184381             :  * memory pool and initializes the data member in class SgTemplateParameterValStroageClass
  184382             :  * from its counterpart of SgTemplateParameterVal. The return value is just for checking, 
  184383             :  * that the whole StorageClassArray is initialized!
  184384             :  */
  184385             : unsigned long
  184386           0 : SgTemplateParameterVal::initializeStorageClassArray( SgTemplateParameterValStorageClass *storageArray )
  184387             :    {
  184388           0 :      unsigned long storageCounter = 0;
  184389           0 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateParameterVal::pools.begin();
  184390           0 :      SgTemplateParameterVal* pointer = NULL;
  184391           0 :      while ( block != SgTemplateParameterVal::pools.end() ) {
  184392           0 :           pointer = (SgTemplateParameterVal*) (*block);
  184393           0 :           for ( unsigned i = 0; i < SgTemplateParameterVal::pool_size; ++i ) {
  184394           0 :                if ( pointer->get_freepointer() != NULL ) {
  184395           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  184396           0 :                  storageArray++;
  184397           0 :                  storageCounter++;
  184398             :                }
  184399           0 :                pointer++;
  184400             :              }
  184401           0 :            block++;
  184402             :         }
  184403           0 :      return storageCounter;
  184404             :    }
  184405             : 
  184406             : /* #line 184407 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  184407             : 
  184408             : 
  184409             : 
  184410             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  184411             : 
  184412             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  184413             : 
  184414             : //############################################################################
  184415             : /* JH (02/02/2006) Constructor of the IR node SgNullptrValExp that takes its 
  184416             :  * corresponding StorageClass as parameter
  184417             :  */
  184418           6 : SgNullptrValExp :: SgNullptrValExp ( const SgNullptrValExpStorageClass& storageSource )   : SgValueExp (storageSource)
  184419             :    {
  184420             : 
  184421             : 
  184422             : /* #line 184423 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  184423             : 
  184424           6 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  184425             : 
  184426             : 
  184427             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  184428             : 
  184429             : 
  184430           6 :    }
  184431             : 
  184432             : //############################################################################
  184433             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  184434             :  * within the working AST. 
  184435             :  */
  184436          22 : SgNullptrValExp * SgNullptrValExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  184437          22 :      SgNullptrValExp* returnPointer = NULL;
  184438          22 :      if ( globalIndex != 0 )
  184439             :         {
  184440             : 
  184441             : #if FILE_IO_EXTRA_CHECK
  184442          22 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNullptrValExp ) ) <= globalIndex ) ;
  184443          22 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNullptrValExp + 1 ) ) );
  184444             : #endif
  184445          22 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNullptrValExp )  
  184446          22 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNullptrValExp );
  184447          22 :           unsigned long positionInPool = localIndex % SgNullptrValExp::pool_size;
  184448          22 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNullptrValExp::pool_size;
  184449             : 
  184450             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  184451             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  184452             : 
  184453          22 :           returnPointer = &( ( (SgNullptrValExp*)(SgNullptrValExp::pools[memoryBlock]) ) [positionInPool]) ;
  184454             : 
  184455          22 :           ROSE_ASSERT( returnPointer != NULL ) ;
  184456             :         }
  184457          22 :      return returnPointer ;
  184458             :    }
  184459             : 
  184460             : //############################################################################
  184461             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  184462             :   for the AST with the index astIndex
  184463             : */
  184464           0 : SgNullptrValExp * SgNullptrValExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  184465           0 :      SgNullptrValExp* returnPointer = NULL;
  184466           0 :      if ( globalIndex != 0 )
  184467             :         {
  184468             : 
  184469             : #if FILE_IO_EXTRA_CHECK
  184470           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNullptrValExp ) ) <= globalIndex ) ;
  184471           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNullptrValExp + 1 ) ) );
  184472             : #endif
  184473           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNullptrValExp )
  184474           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNullptrValExp );
  184475           0 :           unsigned long positionInPool = localIndex % SgNullptrValExp::pool_size ;
  184476           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNullptrValExp::pool_size ;
  184477             : 
  184478             : #if FILE_IO_EXTRA_CHECK
  184479             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  184480             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  184481             : #endif
  184482             : 
  184483           0 :           returnPointer = &( ( (SgNullptrValExp*)(SgNullptrValExp::pools[memoryBlock]) ) [positionInPool]) ;
  184484             : 
  184485             : #if FILE_IO_EXTRA_CHECK
  184486           0 :           assert ( returnPointer != NULL ) ;
  184487             : #endif
  184488             :         }
  184489           0 :      return returnPointer ;
  184490             :    }
  184491             : 
  184492             : //############################################################################
  184493             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  184494             :  * pool size! We set for every valid object in the memory pool the freepointer
  184495             :  * to the global index and increase the global index afterwards. For all the 
  184496             :  * invalid objects (means address ranges within the memory pool that were not
  184497             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  184498             :  * distinguish valid from invalid objects! 
  184499             :  */
  184500             : unsigned long
  184501           5 : SgNullptrValExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  184502             :    {
  184503           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  184504           5 :      SgNullptrValExp* pointer = NULL;
  184505           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  184506           5 :      std::vector < unsigned char* > :: const_iterator block;
  184507           6 :      for ( block = SgNullptrValExp::pools.begin(); block != SgNullptrValExp::pools.end() ; ++block )
  184508             :         {
  184509           1 :           pointer = (SgNullptrValExp*)(*block);
  184510        2001 :           for (unsigned i = 0; i < SgNullptrValExp::pool_size; ++i )
  184511             :              {
  184512             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  184513             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  184514             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  184515             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  184516             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  184517             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  184518             :             // properly; so this will have to be checked next.
  184519             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  184520             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  184521        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  184522             :                   {
  184523           6 :                     pointer[i].set_freepointer((SgNullptrValExp*)(globalIndex));
  184524           6 :                     globalIndex++;
  184525             :                   }
  184526             :                else
  184527             :                   {
  184528        1994 :                     pointer[i].set_freepointer(NULL);
  184529             :                   }
  184530             :               }
  184531             :         }
  184532           5 :      return globalIndex;
  184533             :    }
  184534             : 
  184535             : //############################################################################
  184536             : // JH (01/14/2006)
  184537             : void
  184538           5 : SgNullptrValExp::resetValidFreepointers( )
  184539             :    {
  184540           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  184541           5 :      SgNullptrValExp* pointer = NULL;
  184542           5 :      std::vector < unsigned char* > :: const_iterator block;
  184543           5 :      SgNullptrValExp* pointerOfLinkedList = NULL;
  184544           6 :      for ( block = SgNullptrValExp::pools.begin(); block != SgNullptrValExp::pools.end() ; ++block )
  184545             :         {
  184546           1 :           pointer = (SgNullptrValExp*)(*block);
  184547        2001 :           for (unsigned i = 0; i < SgNullptrValExp::pool_size; ++i )
  184548             :              {
  184549             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  184550             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  184551             :             // memory blocks!.
  184552        2000 :                if ( pointer[i].get_freepointer() != NULL )
  184553             :                   {
  184554           6 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  184555             :                   }
  184556             :                else
  184557             :                   {
  184558        1994 :                     if ( pointerOfLinkedList == NULL )
  184559             :                        {
  184560           1 :                          SgNullptrValExp::next_node = &(pointer[i]);
  184561             :                        }
  184562             :                     else
  184563             :                        {
  184564             :                       // printf ("In SgNullptrValExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  184565        1993 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  184566             :                        }
  184567             :                     pointerOfLinkedList = &(pointer[i]);
  184568             :                   }
  184569             :               }
  184570             :         }
  184571             : 
  184572           5 :      if ( pointerOfLinkedList != NULL )
  184573             :         {
  184574             :        // printf ("In SgNullptrValExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  184575           1 :           pointerOfLinkedList->set_freepointer(NULL);
  184576             :        // DQ (6/6/2010): Temporary debugging...
  184577             :        //   ROSE_ASSERT(false);
  184578             :         }
  184579             : 
  184580           5 :      return ;
  184581             :    }
  184582             : 
  184583             : //############################################################################
  184584             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  184585             :  * within the memory pool and resets the freepointers, in order to achieve a 
  184586             :  * linked list, that has no jumps and starts at the beginning! This function 
  184587             :  * does not extend the memory pool, since we do not delete any memory blocks,
  184588             :  * but delete the valid objects.  
  184589             :  */
  184590             : void
  184591           0 : SgNullptrValExp::clearMemoryPool( )
  184592             :    {
  184593             :   // printf ("Inside of SgNullptrValExp::clearMemoryPool() \n");
  184594             : 
  184595           0 :      SgNullptrValExp* pointer = NULL, *tempPointer = NULL;
  184596           0 :      std::vector < unsigned char* > :: const_iterator block;
  184597           0 :      if ( SgNullptrValExp::pools.empty() == false )
  184598             :         {
  184599           0 :           block = SgNullptrValExp::pools.begin() ;
  184600           0 :           SgNullptrValExp::next_node = (SgNullptrValExp*) (*block);
  184601             : 
  184602           0 :           while ( block != SgNullptrValExp::pools.end() )
  184603             :              {
  184604           0 :                pointer = (SgNullptrValExp*) (*block);
  184605           0 :                if ( tempPointer != NULL )
  184606             :                   {
  184607           0 :                     tempPointer->set_freepointer(pointer);
  184608             :                   }
  184609           0 :                for (unsigned i = 0; i < SgNullptrValExp::pool_size - 1; ++i)
  184610             :                   {
  184611           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  184612             :                   }
  184613           0 :                 pointer[SgNullptrValExp::pool_size-1].set_freepointer(NULL);
  184614           0 :                 tempPointer = &(pointer[SgNullptrValExp::pool_size-1]);
  184615           0 :                 ++block;
  184616             :              }
  184617             :         }
  184618           0 :    }
  184619             : 
  184620           5 : void SgNullptrValExp::deleteMemoryPool() {
  184621           7 :   for (auto p: SgNullptrValExp::pools) {
  184622           2 :     ROSE_FREE(p);
  184623             :   }
  184624           5 :   SgNullptrValExp::next_node = nullptr;
  184625           5 :   SgNullptrValExp::pools.clear();
  184626           5 : }
  184627             : 
  184628             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  184629             : //                 reading multiple binary files to for a single AST.
  184630             : /////////// new version ////////////////////////////////
  184631             : //############################################################################
  184632             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  184633             : void
  184634           2 : SgNullptrValExp::extendMemoryPoolForFileIO( )
  184635             :   {
  184636           2 :     size_t blockIndex = SgNullptrValExp::pools.size();
  184637           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNullptrValExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullptrValExp);
  184638             : 
  184639           3 :     while ( (blockIndex * SgNullptrValExp::pool_size) < newPoolSize)
  184640             :       {
  184641             : #if ROSE_ALLOC_TRACE
  184642             :         if (blockIndex > 0) {
  184643             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNullptrValExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullptrValExp) = %" PRIuPTR " SgNullptrValExp::pool_size = %d \n",
  184644             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNullptrValExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullptrValExp),SgNullptrValExp::pool_size);
  184645             :         }
  184646             : #endif
  184647             : 
  184648           1 :         SgNullptrValExp * pointer = (SgNullptrValExp*) ROSE_MALLOC ( SgNullptrValExp::pool_size * sizeof(SgNullptrValExp) );
  184649           1 :         assert( pointer != NULL );
  184650             : #if ROSE_ALLOC_MEMSET == 1
  184651             :         memset(pointer, 0x00, SgNullptrValExp::pool_size * sizeof(SgNullptrValExp));
  184652             : #elif ROSE_ALLOC_MEMSET == 2
  184653             :         memset(pointer, 0xCC, SgNullptrValExp::pool_size * sizeof(SgNullptrValExp));
  184654             : #endif
  184655           1 :         SgNullptrValExp::pools.push_back( (unsigned char*)(pointer) );
  184656           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNullptrValExp::pool_size * sizeof(SgNullptrValExp), V_SgNullptrValExp ) );
  184657             : 
  184658           1 :         if ( SgNullptrValExp::next_node != NULL ) {
  184659           0 :           if ( blockIndex > 0 ) {
  184660           0 :             SgNullptrValExp * blkptr = (SgNullptrValExp*)(SgNullptrValExp::pools[blockIndex-1]);
  184661           0 :             blkptr[ SgNullptrValExp::pool_size - 1 ].set_freepointer(pointer);
  184662             :           }
  184663             :         } else {
  184664           1 :           SgNullptrValExp::next_node = pointer;
  184665             :         }
  184666             : 
  184667        2000 :         for (unsigned i = 0; i < SgNullptrValExp::pool_size-1; ++i)
  184668             :            {
  184669        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  184670             :            }
  184671           1 :         pointer[ SgNullptrValExp::pool_size -1 ].set_freepointer(NULL);
  184672             : 
  184673           1 :         blockIndex++;
  184674             :       }
  184675           2 :   }
  184676             : 
  184677             : //############################################################################
  184678             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  184679             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  184680             :  * not compressed. However, that stuff is not yet implemented! 
  184681             :  */
  184682             : unsigned long
  184683           0 : SgNullptrValExp::getNumberOfLastValidPointer()
  184684             :    {
  184685           0 :       SgNullptrValExp* testPointer = (SgNullptrValExp*)(SgNullptrValExp::pools.back());
  184686           0 :       unsigned long localIndex = SgNullptrValExp::pool_size - 1;
  184687           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  184688             :          {
  184689           0 :            localIndex--;
  184690             :          }
  184691           0 :       return (localIndex + SgNullptrValExp::pool_size * (SgNullptrValExp::pools.size()-1));
  184692             :    }
  184693             : 
  184694             : //############################################################################
  184695             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  184696             :  * memory pool and initializes the data member in class SgNullptrValExpStroageClass
  184697             :  * from its counterpart of SgNullptrValExp. The return value is just for checking, 
  184698             :  * that the whole StorageClassArray is initialized!
  184699             :  */
  184700             : unsigned long
  184701           1 : SgNullptrValExp::initializeStorageClassArray( SgNullptrValExpStorageClass *storageArray )
  184702             :    {
  184703           1 :      unsigned long storageCounter = 0;
  184704           1 :      std::vector < unsigned char* > :: const_iterator block = SgNullptrValExp::pools.begin();
  184705           1 :      SgNullptrValExp* pointer = NULL;
  184706           2 :      while ( block != SgNullptrValExp::pools.end() ) {
  184707           1 :           pointer = (SgNullptrValExp*) (*block);
  184708        2001 :           for ( unsigned i = 0; i < SgNullptrValExp::pool_size; ++i ) {
  184709        2000 :                if ( pointer->get_freepointer() != NULL ) {
  184710           6 :                  storageArray->pickOutIRNodeData (pointer) ;
  184711           6 :                  storageArray++;
  184712           6 :                  storageCounter++;
  184713             :                }
  184714        2000 :                pointer++;
  184715             :              }
  184716           1 :            block++;
  184717             :         }
  184718           1 :      return storageCounter;
  184719             :    }
  184720             : 
  184721             : /* #line 184722 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  184722             : 
  184723             : 
  184724             : 
  184725             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  184726             : 
  184727             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  184728             : 
  184729             : //############################################################################
  184730             : /* JH (02/02/2006) Constructor of the IR node SgChar16Val that takes its 
  184731             :  * corresponding StorageClass as parameter
  184732             :  */
  184733           0 : SgChar16Val :: SgChar16Val ( const SgChar16ValStorageClass& storageSource )   : SgValueExp (storageSource)
  184734             :    {
  184735             : 
  184736             : 
  184737             : /* #line 184738 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  184738             : 
  184739           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  184740           0 :      p_valueUL = storageSource.storageOf_valueUL ;
  184741           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  184742             : 
  184743             : 
  184744             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  184745             : 
  184746             : 
  184747           0 :    }
  184748             : 
  184749             : //############################################################################
  184750             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  184751             :  * within the working AST. 
  184752             :  */
  184753           0 : SgChar16Val * SgChar16Val::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  184754           0 :      SgChar16Val* returnPointer = NULL;
  184755           0 :      if ( globalIndex != 0 )
  184756             :         {
  184757             : 
  184758             : #if FILE_IO_EXTRA_CHECK
  184759           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgChar16Val ) ) <= globalIndex ) ;
  184760           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgChar16Val + 1 ) ) );
  184761             : #endif
  184762           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgChar16Val )  
  184763           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgChar16Val );
  184764           0 :           unsigned long positionInPool = localIndex % SgChar16Val::pool_size;
  184765           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgChar16Val::pool_size;
  184766             : 
  184767             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  184768             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  184769             : 
  184770           0 :           returnPointer = &( ( (SgChar16Val*)(SgChar16Val::pools[memoryBlock]) ) [positionInPool]) ;
  184771             : 
  184772           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  184773             :         }
  184774           0 :      return returnPointer ;
  184775             :    }
  184776             : 
  184777             : //############################################################################
  184778             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  184779             :   for the AST with the index astIndex
  184780             : */
  184781           0 : SgChar16Val * SgChar16Val::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  184782           0 :      SgChar16Val* returnPointer = NULL;
  184783           0 :      if ( globalIndex != 0 )
  184784             :         {
  184785             : 
  184786             : #if FILE_IO_EXTRA_CHECK
  184787           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgChar16Val ) ) <= globalIndex ) ;
  184788           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgChar16Val + 1 ) ) );
  184789             : #endif
  184790           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgChar16Val )
  184791           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgChar16Val );
  184792           0 :           unsigned long positionInPool = localIndex % SgChar16Val::pool_size ;
  184793           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgChar16Val::pool_size ;
  184794             : 
  184795             : #if FILE_IO_EXTRA_CHECK
  184796             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  184797             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  184798             : #endif
  184799             : 
  184800           0 :           returnPointer = &( ( (SgChar16Val*)(SgChar16Val::pools[memoryBlock]) ) [positionInPool]) ;
  184801             : 
  184802             : #if FILE_IO_EXTRA_CHECK
  184803           0 :           assert ( returnPointer != NULL ) ;
  184804             : #endif
  184805             :         }
  184806           0 :      return returnPointer ;
  184807             :    }
  184808             : 
  184809             : //############################################################################
  184810             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  184811             :  * pool size! We set for every valid object in the memory pool the freepointer
  184812             :  * to the global index and increase the global index afterwards. For all the 
  184813             :  * invalid objects (means address ranges within the memory pool that were not
  184814             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  184815             :  * distinguish valid from invalid objects! 
  184816             :  */
  184817             : unsigned long
  184818           5 : SgChar16Val::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  184819             :    {
  184820           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  184821           5 :      SgChar16Val* pointer = NULL;
  184822           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  184823           5 :      std::vector < unsigned char* > :: const_iterator block;
  184824           5 :      for ( block = SgChar16Val::pools.begin(); block != SgChar16Val::pools.end() ; ++block )
  184825             :         {
  184826           0 :           pointer = (SgChar16Val*)(*block);
  184827           0 :           for (unsigned i = 0; i < SgChar16Val::pool_size; ++i )
  184828             :              {
  184829             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  184830             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  184831             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  184832             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  184833             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  184834             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  184835             :             // properly; so this will have to be checked next.
  184836             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  184837             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  184838           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  184839             :                   {
  184840           0 :                     pointer[i].set_freepointer((SgChar16Val*)(globalIndex));
  184841           0 :                     globalIndex++;
  184842             :                   }
  184843             :                else
  184844             :                   {
  184845           0 :                     pointer[i].set_freepointer(NULL);
  184846             :                   }
  184847             :               }
  184848             :         }
  184849           5 :      return globalIndex;
  184850             :    }
  184851             : 
  184852             : //############################################################################
  184853             : // JH (01/14/2006)
  184854             : void
  184855           5 : SgChar16Val::resetValidFreepointers( )
  184856             :    {
  184857           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  184858           5 :      SgChar16Val* pointer = NULL;
  184859           5 :      std::vector < unsigned char* > :: const_iterator block;
  184860           5 :      SgChar16Val* pointerOfLinkedList = NULL;
  184861           5 :      for ( block = SgChar16Val::pools.begin(); block != SgChar16Val::pools.end() ; ++block )
  184862             :         {
  184863           0 :           pointer = (SgChar16Val*)(*block);
  184864           0 :           for (unsigned i = 0; i < SgChar16Val::pool_size; ++i )
  184865             :              {
  184866             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  184867             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  184868             :             // memory blocks!.
  184869           0 :                if ( pointer[i].get_freepointer() != NULL )
  184870             :                   {
  184871           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  184872             :                   }
  184873             :                else
  184874             :                   {
  184875           0 :                     if ( pointerOfLinkedList == NULL )
  184876             :                        {
  184877           0 :                          SgChar16Val::next_node = &(pointer[i]);
  184878             :                        }
  184879             :                     else
  184880             :                        {
  184881             :                       // printf ("In SgChar16Val::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  184882           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  184883             :                        }
  184884             :                     pointerOfLinkedList = &(pointer[i]);
  184885             :                   }
  184886             :               }
  184887             :         }
  184888             : 
  184889           5 :      if ( pointerOfLinkedList != NULL )
  184890             :         {
  184891             :        // printf ("In SgChar16Val::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  184892           0 :           pointerOfLinkedList->set_freepointer(NULL);
  184893             :        // DQ (6/6/2010): Temporary debugging...
  184894             :        //   ROSE_ASSERT(false);
  184895             :         }
  184896             : 
  184897           5 :      return ;
  184898             :    }
  184899             : 
  184900             : //############################################################################
  184901             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  184902             :  * within the memory pool and resets the freepointers, in order to achieve a 
  184903             :  * linked list, that has no jumps and starts at the beginning! This function 
  184904             :  * does not extend the memory pool, since we do not delete any memory blocks,
  184905             :  * but delete the valid objects.  
  184906             :  */
  184907             : void
  184908           0 : SgChar16Val::clearMemoryPool( )
  184909             :    {
  184910             :   // printf ("Inside of SgChar16Val::clearMemoryPool() \n");
  184911             : 
  184912           0 :      SgChar16Val* pointer = NULL, *tempPointer = NULL;
  184913           0 :      std::vector < unsigned char* > :: const_iterator block;
  184914           0 :      if ( SgChar16Val::pools.empty() == false )
  184915             :         {
  184916           0 :           block = SgChar16Val::pools.begin() ;
  184917           0 :           SgChar16Val::next_node = (SgChar16Val*) (*block);
  184918             : 
  184919           0 :           while ( block != SgChar16Val::pools.end() )
  184920             :              {
  184921           0 :                pointer = (SgChar16Val*) (*block);
  184922           0 :                if ( tempPointer != NULL )
  184923             :                   {
  184924           0 :                     tempPointer->set_freepointer(pointer);
  184925             :                   }
  184926           0 :                for (unsigned i = 0; i < SgChar16Val::pool_size - 1; ++i)
  184927             :                   {
  184928           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  184929             :                   }
  184930           0 :                 pointer[SgChar16Val::pool_size-1].set_freepointer(NULL);
  184931           0 :                 tempPointer = &(pointer[SgChar16Val::pool_size-1]);
  184932           0 :                 ++block;
  184933             :              }
  184934             :         }
  184935           0 :    }
  184936             : 
  184937           5 : void SgChar16Val::deleteMemoryPool() {
  184938           5 :   for (auto p: SgChar16Val::pools) {
  184939           0 :     ROSE_FREE(p);
  184940             :   }
  184941           5 :   SgChar16Val::next_node = nullptr;
  184942           5 :   SgChar16Val::pools.clear();
  184943           5 : }
  184944             : 
  184945             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  184946             : //                 reading multiple binary files to for a single AST.
  184947             : /////////// new version ////////////////////////////////
  184948             : //############################################################################
  184949             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  184950             : void
  184951           2 : SgChar16Val::extendMemoryPoolForFileIO( )
  184952             :   {
  184953           2 :     size_t blockIndex = SgChar16Val::pools.size();
  184954           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgChar16Val) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgChar16Val);
  184955             : 
  184956           2 :     while ( (blockIndex * SgChar16Val::pool_size) < newPoolSize)
  184957             :       {
  184958             : #if ROSE_ALLOC_TRACE
  184959             :         if (blockIndex > 0) {
  184960             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgChar16Val) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgChar16Val) = %" PRIuPTR " SgChar16Val::pool_size = %d \n",
  184961             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgChar16Val),AST_FILE_IO::getPoolSizeOfNewAst(V_SgChar16Val),SgChar16Val::pool_size);
  184962             :         }
  184963             : #endif
  184964             : 
  184965           0 :         SgChar16Val * pointer = (SgChar16Val*) ROSE_MALLOC ( SgChar16Val::pool_size * sizeof(SgChar16Val) );
  184966           0 :         assert( pointer != NULL );
  184967             : #if ROSE_ALLOC_MEMSET == 1
  184968             :         memset(pointer, 0x00, SgChar16Val::pool_size * sizeof(SgChar16Val));
  184969             : #elif ROSE_ALLOC_MEMSET == 2
  184970             :         memset(pointer, 0xCC, SgChar16Val::pool_size * sizeof(SgChar16Val));
  184971             : #endif
  184972           0 :         SgChar16Val::pools.push_back( (unsigned char*)(pointer) );
  184973           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgChar16Val::pool_size * sizeof(SgChar16Val), V_SgChar16Val ) );
  184974             : 
  184975           0 :         if ( SgChar16Val::next_node != NULL ) {
  184976           0 :           if ( blockIndex > 0 ) {
  184977           0 :             SgChar16Val * blkptr = (SgChar16Val*)(SgChar16Val::pools[blockIndex-1]);
  184978           0 :             blkptr[ SgChar16Val::pool_size - 1 ].set_freepointer(pointer);
  184979             :           }
  184980             :         } else {
  184981           0 :           SgChar16Val::next_node = pointer;
  184982             :         }
  184983             : 
  184984           0 :         for (unsigned i = 0; i < SgChar16Val::pool_size-1; ++i)
  184985             :            {
  184986           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  184987             :            }
  184988           0 :         pointer[ SgChar16Val::pool_size -1 ].set_freepointer(NULL);
  184989             : 
  184990           0 :         blockIndex++;
  184991             :       }
  184992           2 :   }
  184993             : 
  184994             : //############################################################################
  184995             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  184996             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  184997             :  * not compressed. However, that stuff is not yet implemented! 
  184998             :  */
  184999             : unsigned long
  185000           0 : SgChar16Val::getNumberOfLastValidPointer()
  185001             :    {
  185002           0 :       SgChar16Val* testPointer = (SgChar16Val*)(SgChar16Val::pools.back());
  185003           0 :       unsigned long localIndex = SgChar16Val::pool_size - 1;
  185004           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  185005             :          {
  185006           0 :            localIndex--;
  185007             :          }
  185008           0 :       return (localIndex + SgChar16Val::pool_size * (SgChar16Val::pools.size()-1));
  185009             :    }
  185010             : 
  185011             : //############################################################################
  185012             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  185013             :  * memory pool and initializes the data member in class SgChar16ValStroageClass
  185014             :  * from its counterpart of SgChar16Val. The return value is just for checking, 
  185015             :  * that the whole StorageClassArray is initialized!
  185016             :  */
  185017             : unsigned long
  185018           0 : SgChar16Val::initializeStorageClassArray( SgChar16ValStorageClass *storageArray )
  185019             :    {
  185020           0 :      unsigned long storageCounter = 0;
  185021           0 :      std::vector < unsigned char* > :: const_iterator block = SgChar16Val::pools.begin();
  185022           0 :      SgChar16Val* pointer = NULL;
  185023           0 :      while ( block != SgChar16Val::pools.end() ) {
  185024           0 :           pointer = (SgChar16Val*) (*block);
  185025           0 :           for ( unsigned i = 0; i < SgChar16Val::pool_size; ++i ) {
  185026           0 :                if ( pointer->get_freepointer() != NULL ) {
  185027           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  185028           0 :                  storageArray++;
  185029           0 :                  storageCounter++;
  185030             :                }
  185031           0 :                pointer++;
  185032             :              }
  185033           0 :            block++;
  185034             :         }
  185035           0 :      return storageCounter;
  185036             :    }
  185037             : 
  185038             : /* #line 185039 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  185039             : 
  185040             : 
  185041             : 
  185042             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  185043             : 
  185044             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  185045             : 
  185046             : //############################################################################
  185047             : /* JH (02/02/2006) Constructor of the IR node SgChar32Val that takes its 
  185048             :  * corresponding StorageClass as parameter
  185049             :  */
  185050           0 : SgChar32Val :: SgChar32Val ( const SgChar32ValStorageClass& storageSource )   : SgValueExp (storageSource)
  185051             :    {
  185052             : 
  185053             : 
  185054             : /* #line 185055 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  185055             : 
  185056           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  185057           0 :      p_valueUL = storageSource.storageOf_valueUL ;
  185058           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  185059             : 
  185060             : 
  185061             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  185062             : 
  185063             : 
  185064           0 :    }
  185065             : 
  185066             : //############################################################################
  185067             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  185068             :  * within the working AST. 
  185069             :  */
  185070           0 : SgChar32Val * SgChar32Val::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  185071           0 :      SgChar32Val* returnPointer = NULL;
  185072           0 :      if ( globalIndex != 0 )
  185073             :         {
  185074             : 
  185075             : #if FILE_IO_EXTRA_CHECK
  185076           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgChar32Val ) ) <= globalIndex ) ;
  185077           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgChar32Val + 1 ) ) );
  185078             : #endif
  185079           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgChar32Val )  
  185080           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgChar32Val );
  185081           0 :           unsigned long positionInPool = localIndex % SgChar32Val::pool_size;
  185082           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgChar32Val::pool_size;
  185083             : 
  185084             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  185085             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  185086             : 
  185087           0 :           returnPointer = &( ( (SgChar32Val*)(SgChar32Val::pools[memoryBlock]) ) [positionInPool]) ;
  185088             : 
  185089           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  185090             :         }
  185091           0 :      return returnPointer ;
  185092             :    }
  185093             : 
  185094             : //############################################################################
  185095             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  185096             :   for the AST with the index astIndex
  185097             : */
  185098           0 : SgChar32Val * SgChar32Val::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  185099           0 :      SgChar32Val* returnPointer = NULL;
  185100           0 :      if ( globalIndex != 0 )
  185101             :         {
  185102             : 
  185103             : #if FILE_IO_EXTRA_CHECK
  185104           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgChar32Val ) ) <= globalIndex ) ;
  185105           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgChar32Val + 1 ) ) );
  185106             : #endif
  185107           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgChar32Val )
  185108           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgChar32Val );
  185109           0 :           unsigned long positionInPool = localIndex % SgChar32Val::pool_size ;
  185110           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgChar32Val::pool_size ;
  185111             : 
  185112             : #if FILE_IO_EXTRA_CHECK
  185113             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  185114             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  185115             : #endif
  185116             : 
  185117           0 :           returnPointer = &( ( (SgChar32Val*)(SgChar32Val::pools[memoryBlock]) ) [positionInPool]) ;
  185118             : 
  185119             : #if FILE_IO_EXTRA_CHECK
  185120           0 :           assert ( returnPointer != NULL ) ;
  185121             : #endif
  185122             :         }
  185123           0 :      return returnPointer ;
  185124             :    }
  185125             : 
  185126             : //############################################################################
  185127             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  185128             :  * pool size! We set for every valid object in the memory pool the freepointer
  185129             :  * to the global index and increase the global index afterwards. For all the 
  185130             :  * invalid objects (means address ranges within the memory pool that were not
  185131             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  185132             :  * distinguish valid from invalid objects! 
  185133             :  */
  185134             : unsigned long
  185135           5 : SgChar32Val::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  185136             :    {
  185137           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  185138           5 :      SgChar32Val* pointer = NULL;
  185139           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  185140           5 :      std::vector < unsigned char* > :: const_iterator block;
  185141           5 :      for ( block = SgChar32Val::pools.begin(); block != SgChar32Val::pools.end() ; ++block )
  185142             :         {
  185143           0 :           pointer = (SgChar32Val*)(*block);
  185144           0 :           for (unsigned i = 0; i < SgChar32Val::pool_size; ++i )
  185145             :              {
  185146             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  185147             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  185148             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  185149             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  185150             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  185151             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  185152             :             // properly; so this will have to be checked next.
  185153             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  185154             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  185155           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  185156             :                   {
  185157           0 :                     pointer[i].set_freepointer((SgChar32Val*)(globalIndex));
  185158           0 :                     globalIndex++;
  185159             :                   }
  185160             :                else
  185161             :                   {
  185162           0 :                     pointer[i].set_freepointer(NULL);
  185163             :                   }
  185164             :               }
  185165             :         }
  185166           5 :      return globalIndex;
  185167             :    }
  185168             : 
  185169             : //############################################################################
  185170             : // JH (01/14/2006)
  185171             : void
  185172           5 : SgChar32Val::resetValidFreepointers( )
  185173             :    {
  185174           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  185175           5 :      SgChar32Val* pointer = NULL;
  185176           5 :      std::vector < unsigned char* > :: const_iterator block;
  185177           5 :      SgChar32Val* pointerOfLinkedList = NULL;
  185178           5 :      for ( block = SgChar32Val::pools.begin(); block != SgChar32Val::pools.end() ; ++block )
  185179             :         {
  185180           0 :           pointer = (SgChar32Val*)(*block);
  185181           0 :           for (unsigned i = 0; i < SgChar32Val::pool_size; ++i )
  185182             :              {
  185183             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  185184             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  185185             :             // memory blocks!.
  185186           0 :                if ( pointer[i].get_freepointer() != NULL )
  185187             :                   {
  185188           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  185189             :                   }
  185190             :                else
  185191             :                   {
  185192           0 :                     if ( pointerOfLinkedList == NULL )
  185193             :                        {
  185194           0 :                          SgChar32Val::next_node = &(pointer[i]);
  185195             :                        }
  185196             :                     else
  185197             :                        {
  185198             :                       // printf ("In SgChar32Val::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  185199           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  185200             :                        }
  185201             :                     pointerOfLinkedList = &(pointer[i]);
  185202             :                   }
  185203             :               }
  185204             :         }
  185205             : 
  185206           5 :      if ( pointerOfLinkedList != NULL )
  185207             :         {
  185208             :        // printf ("In SgChar32Val::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  185209           0 :           pointerOfLinkedList->set_freepointer(NULL);
  185210             :        // DQ (6/6/2010): Temporary debugging...
  185211             :        //   ROSE_ASSERT(false);
  185212             :         }
  185213             : 
  185214           5 :      return ;
  185215             :    }
  185216             : 
  185217             : //############################################################################
  185218             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  185219             :  * within the memory pool and resets the freepointers, in order to achieve a 
  185220             :  * linked list, that has no jumps and starts at the beginning! This function 
  185221             :  * does not extend the memory pool, since we do not delete any memory blocks,
  185222             :  * but delete the valid objects.  
  185223             :  */
  185224             : void
  185225           0 : SgChar32Val::clearMemoryPool( )
  185226             :    {
  185227             :   // printf ("Inside of SgChar32Val::clearMemoryPool() \n");
  185228             : 
  185229           0 :      SgChar32Val* pointer = NULL, *tempPointer = NULL;
  185230           0 :      std::vector < unsigned char* > :: const_iterator block;
  185231           0 :      if ( SgChar32Val::pools.empty() == false )
  185232             :         {
  185233           0 :           block = SgChar32Val::pools.begin() ;
  185234           0 :           SgChar32Val::next_node = (SgChar32Val*) (*block);
  185235             : 
  185236           0 :           while ( block != SgChar32Val::pools.end() )
  185237             :              {
  185238           0 :                pointer = (SgChar32Val*) (*block);
  185239           0 :                if ( tempPointer != NULL )
  185240             :                   {
  185241           0 :                     tempPointer->set_freepointer(pointer);
  185242             :                   }
  185243           0 :                for (unsigned i = 0; i < SgChar32Val::pool_size - 1; ++i)
  185244             :                   {
  185245           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  185246             :                   }
  185247           0 :                 pointer[SgChar32Val::pool_size-1].set_freepointer(NULL);
  185248           0 :                 tempPointer = &(pointer[SgChar32Val::pool_size-1]);
  185249           0 :                 ++block;
  185250             :              }
  185251             :         }
  185252           0 :    }
  185253             : 
  185254           5 : void SgChar32Val::deleteMemoryPool() {
  185255           5 :   for (auto p: SgChar32Val::pools) {
  185256           0 :     ROSE_FREE(p);
  185257             :   }
  185258           5 :   SgChar32Val::next_node = nullptr;
  185259           5 :   SgChar32Val::pools.clear();
  185260           5 : }
  185261             : 
  185262             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  185263             : //                 reading multiple binary files to for a single AST.
  185264             : /////////// new version ////////////////////////////////
  185265             : //############################################################################
  185266             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  185267             : void
  185268           2 : SgChar32Val::extendMemoryPoolForFileIO( )
  185269             :   {
  185270           2 :     size_t blockIndex = SgChar32Val::pools.size();
  185271           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgChar32Val) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgChar32Val);
  185272             : 
  185273           2 :     while ( (blockIndex * SgChar32Val::pool_size) < newPoolSize)
  185274             :       {
  185275             : #if ROSE_ALLOC_TRACE
  185276             :         if (blockIndex > 0) {
  185277             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgChar32Val) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgChar32Val) = %" PRIuPTR " SgChar32Val::pool_size = %d \n",
  185278             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgChar32Val),AST_FILE_IO::getPoolSizeOfNewAst(V_SgChar32Val),SgChar32Val::pool_size);
  185279             :         }
  185280             : #endif
  185281             : 
  185282           0 :         SgChar32Val * pointer = (SgChar32Val*) ROSE_MALLOC ( SgChar32Val::pool_size * sizeof(SgChar32Val) );
  185283           0 :         assert( pointer != NULL );
  185284             : #if ROSE_ALLOC_MEMSET == 1
  185285             :         memset(pointer, 0x00, SgChar32Val::pool_size * sizeof(SgChar32Val));
  185286             : #elif ROSE_ALLOC_MEMSET == 2
  185287             :         memset(pointer, 0xCC, SgChar32Val::pool_size * sizeof(SgChar32Val));
  185288             : #endif
  185289           0 :         SgChar32Val::pools.push_back( (unsigned char*)(pointer) );
  185290           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgChar32Val::pool_size * sizeof(SgChar32Val), V_SgChar32Val ) );
  185291             : 
  185292           0 :         if ( SgChar32Val::next_node != NULL ) {
  185293           0 :           if ( blockIndex > 0 ) {
  185294           0 :             SgChar32Val * blkptr = (SgChar32Val*)(SgChar32Val::pools[blockIndex-1]);
  185295           0 :             blkptr[ SgChar32Val::pool_size - 1 ].set_freepointer(pointer);
  185296             :           }
  185297             :         } else {
  185298           0 :           SgChar32Val::next_node = pointer;
  185299             :         }
  185300             : 
  185301           0 :         for (unsigned i = 0; i < SgChar32Val::pool_size-1; ++i)
  185302             :            {
  185303           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  185304             :            }
  185305           0 :         pointer[ SgChar32Val::pool_size -1 ].set_freepointer(NULL);
  185306             : 
  185307           0 :         blockIndex++;
  185308             :       }
  185309           2 :   }
  185310             : 
  185311             : //############################################################################
  185312             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  185313             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  185314             :  * not compressed. However, that stuff is not yet implemented! 
  185315             :  */
  185316             : unsigned long
  185317           0 : SgChar32Val::getNumberOfLastValidPointer()
  185318             :    {
  185319           0 :       SgChar32Val* testPointer = (SgChar32Val*)(SgChar32Val::pools.back());
  185320           0 :       unsigned long localIndex = SgChar32Val::pool_size - 1;
  185321           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  185322             :          {
  185323           0 :            localIndex--;
  185324             :          }
  185325           0 :       return (localIndex + SgChar32Val::pool_size * (SgChar32Val::pools.size()-1));
  185326             :    }
  185327             : 
  185328             : //############################################################################
  185329             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  185330             :  * memory pool and initializes the data member in class SgChar32ValStroageClass
  185331             :  * from its counterpart of SgChar32Val. The return value is just for checking, 
  185332             :  * that the whole StorageClassArray is initialized!
  185333             :  */
  185334             : unsigned long
  185335           0 : SgChar32Val::initializeStorageClassArray( SgChar32ValStorageClass *storageArray )
  185336             :    {
  185337           0 :      unsigned long storageCounter = 0;
  185338           0 :      std::vector < unsigned char* > :: const_iterator block = SgChar32Val::pools.begin();
  185339           0 :      SgChar32Val* pointer = NULL;
  185340           0 :      while ( block != SgChar32Val::pools.end() ) {
  185341           0 :           pointer = (SgChar32Val*) (*block);
  185342           0 :           for ( unsigned i = 0; i < SgChar32Val::pool_size; ++i ) {
  185343           0 :                if ( pointer->get_freepointer() != NULL ) {
  185344           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  185345           0 :                  storageArray++;
  185346           0 :                  storageCounter++;
  185347             :                }
  185348           0 :                pointer++;
  185349             :              }
  185350           0 :            block++;
  185351             :         }
  185352           0 :      return storageCounter;
  185353             :    }
  185354             : 
  185355             : /* #line 185356 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  185356             : 
  185357             : 
  185358             : 
  185359             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  185360             : 
  185361             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  185362             : 
  185363             : //############################################################################
  185364             : /* JH (02/02/2006) Constructor of the IR node SgFloat80Val that takes its 
  185365             :  * corresponding StorageClass as parameter
  185366             :  */
  185367           0 : SgFloat80Val :: SgFloat80Val ( const SgFloat80ValStorageClass& storageSource )   : SgValueExp (storageSource)
  185368             :    {
  185369             : 
  185370             : 
  185371             : /* #line 185372 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  185372             : 
  185373           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  185374           0 :      p_value = storageSource.storageOf_value ;
  185375           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  185376             : 
  185377             : 
  185378             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  185379             : 
  185380             : 
  185381           0 :    }
  185382             : 
  185383             : //############################################################################
  185384             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  185385             :  * within the working AST. 
  185386             :  */
  185387           0 : SgFloat80Val * SgFloat80Val::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  185388           0 :      SgFloat80Val* returnPointer = NULL;
  185389           0 :      if ( globalIndex != 0 )
  185390             :         {
  185391             : 
  185392             : #if FILE_IO_EXTRA_CHECK
  185393           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFloat80Val ) ) <= globalIndex ) ;
  185394           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFloat80Val + 1 ) ) );
  185395             : #endif
  185396           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFloat80Val )  
  185397           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFloat80Val );
  185398           0 :           unsigned long positionInPool = localIndex % SgFloat80Val::pool_size;
  185399           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFloat80Val::pool_size;
  185400             : 
  185401             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  185402             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  185403             : 
  185404           0 :           returnPointer = &( ( (SgFloat80Val*)(SgFloat80Val::pools[memoryBlock]) ) [positionInPool]) ;
  185405             : 
  185406           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  185407             :         }
  185408           0 :      return returnPointer ;
  185409             :    }
  185410             : 
  185411             : //############################################################################
  185412             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  185413             :   for the AST with the index astIndex
  185414             : */
  185415           0 : SgFloat80Val * SgFloat80Val::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  185416           0 :      SgFloat80Val* returnPointer = NULL;
  185417           0 :      if ( globalIndex != 0 )
  185418             :         {
  185419             : 
  185420             : #if FILE_IO_EXTRA_CHECK
  185421           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFloat80Val ) ) <= globalIndex ) ;
  185422           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFloat80Val + 1 ) ) );
  185423             : #endif
  185424           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFloat80Val )
  185425           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFloat80Val );
  185426           0 :           unsigned long positionInPool = localIndex % SgFloat80Val::pool_size ;
  185427           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFloat80Val::pool_size ;
  185428             : 
  185429             : #if FILE_IO_EXTRA_CHECK
  185430             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  185431             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  185432             : #endif
  185433             : 
  185434           0 :           returnPointer = &( ( (SgFloat80Val*)(SgFloat80Val::pools[memoryBlock]) ) [positionInPool]) ;
  185435             : 
  185436             : #if FILE_IO_EXTRA_CHECK
  185437           0 :           assert ( returnPointer != NULL ) ;
  185438             : #endif
  185439             :         }
  185440           0 :      return returnPointer ;
  185441             :    }
  185442             : 
  185443             : //############################################################################
  185444             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  185445             :  * pool size! We set for every valid object in the memory pool the freepointer
  185446             :  * to the global index and increase the global index afterwards. For all the 
  185447             :  * invalid objects (means address ranges within the memory pool that were not
  185448             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  185449             :  * distinguish valid from invalid objects! 
  185450             :  */
  185451             : unsigned long
  185452           5 : SgFloat80Val::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  185453             :    {
  185454           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  185455           5 :      SgFloat80Val* pointer = NULL;
  185456           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  185457           5 :      std::vector < unsigned char* > :: const_iterator block;
  185458           5 :      for ( block = SgFloat80Val::pools.begin(); block != SgFloat80Val::pools.end() ; ++block )
  185459             :         {
  185460           0 :           pointer = (SgFloat80Val*)(*block);
  185461           0 :           for (unsigned i = 0; i < SgFloat80Val::pool_size; ++i )
  185462             :              {
  185463             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  185464             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  185465             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  185466             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  185467             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  185468             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  185469             :             // properly; so this will have to be checked next.
  185470             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  185471             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  185472           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  185473             :                   {
  185474           0 :                     pointer[i].set_freepointer((SgFloat80Val*)(globalIndex));
  185475           0 :                     globalIndex++;
  185476             :                   }
  185477             :                else
  185478             :                   {
  185479           0 :                     pointer[i].set_freepointer(NULL);
  185480             :                   }
  185481             :               }
  185482             :         }
  185483           5 :      return globalIndex;
  185484             :    }
  185485             : 
  185486             : //############################################################################
  185487             : // JH (01/14/2006)
  185488             : void
  185489           5 : SgFloat80Val::resetValidFreepointers( )
  185490             :    {
  185491           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  185492           5 :      SgFloat80Val* pointer = NULL;
  185493           5 :      std::vector < unsigned char* > :: const_iterator block;
  185494           5 :      SgFloat80Val* pointerOfLinkedList = NULL;
  185495           5 :      for ( block = SgFloat80Val::pools.begin(); block != SgFloat80Val::pools.end() ; ++block )
  185496             :         {
  185497           0 :           pointer = (SgFloat80Val*)(*block);
  185498           0 :           for (unsigned i = 0; i < SgFloat80Val::pool_size; ++i )
  185499             :              {
  185500             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  185501             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  185502             :             // memory blocks!.
  185503           0 :                if ( pointer[i].get_freepointer() != NULL )
  185504             :                   {
  185505           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  185506             :                   }
  185507             :                else
  185508             :                   {
  185509           0 :                     if ( pointerOfLinkedList == NULL )
  185510             :                        {
  185511           0 :                          SgFloat80Val::next_node = &(pointer[i]);
  185512             :                        }
  185513             :                     else
  185514             :                        {
  185515             :                       // printf ("In SgFloat80Val::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  185516           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  185517             :                        }
  185518             :                     pointerOfLinkedList = &(pointer[i]);
  185519             :                   }
  185520             :               }
  185521             :         }
  185522             : 
  185523           5 :      if ( pointerOfLinkedList != NULL )
  185524             :         {
  185525             :        // printf ("In SgFloat80Val::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  185526           0 :           pointerOfLinkedList->set_freepointer(NULL);
  185527             :        // DQ (6/6/2010): Temporary debugging...
  185528             :        //   ROSE_ASSERT(false);
  185529             :         }
  185530             : 
  185531           5 :      return ;
  185532             :    }
  185533             : 
  185534             : //############################################################################
  185535             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  185536             :  * within the memory pool and resets the freepointers, in order to achieve a 
  185537             :  * linked list, that has no jumps and starts at the beginning! This function 
  185538             :  * does not extend the memory pool, since we do not delete any memory blocks,
  185539             :  * but delete the valid objects.  
  185540             :  */
  185541             : void
  185542           0 : SgFloat80Val::clearMemoryPool( )
  185543             :    {
  185544             :   // printf ("Inside of SgFloat80Val::clearMemoryPool() \n");
  185545             : 
  185546           0 :      SgFloat80Val* pointer = NULL, *tempPointer = NULL;
  185547           0 :      std::vector < unsigned char* > :: const_iterator block;
  185548           0 :      if ( SgFloat80Val::pools.empty() == false )
  185549             :         {
  185550           0 :           block = SgFloat80Val::pools.begin() ;
  185551           0 :           SgFloat80Val::next_node = (SgFloat80Val*) (*block);
  185552             : 
  185553           0 :           while ( block != SgFloat80Val::pools.end() )
  185554             :              {
  185555           0 :                pointer = (SgFloat80Val*) (*block);
  185556           0 :                if ( tempPointer != NULL )
  185557             :                   {
  185558           0 :                     tempPointer->set_freepointer(pointer);
  185559             :                   }
  185560           0 :                for (unsigned i = 0; i < SgFloat80Val::pool_size - 1; ++i)
  185561             :                   {
  185562           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  185563             :                   }
  185564           0 :                 pointer[SgFloat80Val::pool_size-1].set_freepointer(NULL);
  185565           0 :                 tempPointer = &(pointer[SgFloat80Val::pool_size-1]);
  185566           0 :                 ++block;
  185567             :              }
  185568             :         }
  185569           0 :    }
  185570             : 
  185571           5 : void SgFloat80Val::deleteMemoryPool() {
  185572           5 :   for (auto p: SgFloat80Val::pools) {
  185573           0 :     ROSE_FREE(p);
  185574             :   }
  185575           5 :   SgFloat80Val::next_node = nullptr;
  185576           5 :   SgFloat80Val::pools.clear();
  185577           5 : }
  185578             : 
  185579             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  185580             : //                 reading multiple binary files to for a single AST.
  185581             : /////////// new version ////////////////////////////////
  185582             : //############################################################################
  185583             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  185584             : void
  185585           2 : SgFloat80Val::extendMemoryPoolForFileIO( )
  185586             :   {
  185587           2 :     size_t blockIndex = SgFloat80Val::pools.size();
  185588           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFloat80Val) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloat80Val);
  185589             : 
  185590           2 :     while ( (blockIndex * SgFloat80Val::pool_size) < newPoolSize)
  185591             :       {
  185592             : #if ROSE_ALLOC_TRACE
  185593             :         if (blockIndex > 0) {
  185594             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFloat80Val) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloat80Val) = %" PRIuPTR " SgFloat80Val::pool_size = %d \n",
  185595             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFloat80Val),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloat80Val),SgFloat80Val::pool_size);
  185596             :         }
  185597             : #endif
  185598             : 
  185599           0 :         SgFloat80Val * pointer = (SgFloat80Val*) ROSE_MALLOC ( SgFloat80Val::pool_size * sizeof(SgFloat80Val) );
  185600           0 :         assert( pointer != NULL );
  185601             : #if ROSE_ALLOC_MEMSET == 1
  185602             :         memset(pointer, 0x00, SgFloat80Val::pool_size * sizeof(SgFloat80Val));
  185603             : #elif ROSE_ALLOC_MEMSET == 2
  185604             :         memset(pointer, 0xCC, SgFloat80Val::pool_size * sizeof(SgFloat80Val));
  185605             : #endif
  185606           0 :         SgFloat80Val::pools.push_back( (unsigned char*)(pointer) );
  185607           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFloat80Val::pool_size * sizeof(SgFloat80Val), V_SgFloat80Val ) );
  185608             : 
  185609           0 :         if ( SgFloat80Val::next_node != NULL ) {
  185610           0 :           if ( blockIndex > 0 ) {
  185611           0 :             SgFloat80Val * blkptr = (SgFloat80Val*)(SgFloat80Val::pools[blockIndex-1]);
  185612           0 :             blkptr[ SgFloat80Val::pool_size - 1 ].set_freepointer(pointer);
  185613             :           }
  185614             :         } else {
  185615           0 :           SgFloat80Val::next_node = pointer;
  185616             :         }
  185617             : 
  185618           0 :         for (unsigned i = 0; i < SgFloat80Val::pool_size-1; ++i)
  185619             :            {
  185620           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  185621             :            }
  185622           0 :         pointer[ SgFloat80Val::pool_size -1 ].set_freepointer(NULL);
  185623             : 
  185624           0 :         blockIndex++;
  185625             :       }
  185626           2 :   }
  185627             : 
  185628             : //############################################################################
  185629             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  185630             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  185631             :  * not compressed. However, that stuff is not yet implemented! 
  185632             :  */
  185633             : unsigned long
  185634           0 : SgFloat80Val::getNumberOfLastValidPointer()
  185635             :    {
  185636           0 :       SgFloat80Val* testPointer = (SgFloat80Val*)(SgFloat80Val::pools.back());
  185637           0 :       unsigned long localIndex = SgFloat80Val::pool_size - 1;
  185638           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  185639             :          {
  185640           0 :            localIndex--;
  185641             :          }
  185642           0 :       return (localIndex + SgFloat80Val::pool_size * (SgFloat80Val::pools.size()-1));
  185643             :    }
  185644             : 
  185645             : //############################################################################
  185646             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  185647             :  * memory pool and initializes the data member in class SgFloat80ValStroageClass
  185648             :  * from its counterpart of SgFloat80Val. The return value is just for checking, 
  185649             :  * that the whole StorageClassArray is initialized!
  185650             :  */
  185651             : unsigned long
  185652           0 : SgFloat80Val::initializeStorageClassArray( SgFloat80ValStorageClass *storageArray )
  185653             :    {
  185654           0 :      unsigned long storageCounter = 0;
  185655           0 :      std::vector < unsigned char* > :: const_iterator block = SgFloat80Val::pools.begin();
  185656           0 :      SgFloat80Val* pointer = NULL;
  185657           0 :      while ( block != SgFloat80Val::pools.end() ) {
  185658           0 :           pointer = (SgFloat80Val*) (*block);
  185659           0 :           for ( unsigned i = 0; i < SgFloat80Val::pool_size; ++i ) {
  185660           0 :                if ( pointer->get_freepointer() != NULL ) {
  185661           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  185662           0 :                  storageArray++;
  185663           0 :                  storageCounter++;
  185664             :                }
  185665           0 :                pointer++;
  185666             :              }
  185667           0 :            block++;
  185668             :         }
  185669           0 :      return storageCounter;
  185670             :    }
  185671             : 
  185672             : /* #line 185673 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  185673             : 
  185674             : 
  185675             : 
  185676             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  185677             : 
  185678             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  185679             : 
  185680             : //############################################################################
  185681             : /* JH (02/02/2006) Constructor of the IR node SgFloat128Val that takes its 
  185682             :  * corresponding StorageClass as parameter
  185683             :  */
  185684           0 : SgFloat128Val :: SgFloat128Val ( const SgFloat128ValStorageClass& storageSource )   : SgValueExp (storageSource)
  185685             :    {
  185686             : 
  185687             : 
  185688             : /* #line 185689 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  185689             : 
  185690           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  185691           0 :      p_value = storageSource.storageOf_value ;
  185692           0 :      p_valueString = storageSource.storageOf_valueString.rebuildDataStoredInEasyStorageClass() ;
  185693             : 
  185694             : 
  185695             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  185696             : 
  185697             : 
  185698           0 :    }
  185699             : 
  185700             : //############################################################################
  185701             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  185702             :  * within the working AST. 
  185703             :  */
  185704           0 : SgFloat128Val * SgFloat128Val::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  185705           0 :      SgFloat128Val* returnPointer = NULL;
  185706           0 :      if ( globalIndex != 0 )
  185707             :         {
  185708             : 
  185709             : #if FILE_IO_EXTRA_CHECK
  185710           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFloat128Val ) ) <= globalIndex ) ;
  185711           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFloat128Val + 1 ) ) );
  185712             : #endif
  185713           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFloat128Val )  
  185714           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFloat128Val );
  185715           0 :           unsigned long positionInPool = localIndex % SgFloat128Val::pool_size;
  185716           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFloat128Val::pool_size;
  185717             : 
  185718             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  185719             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  185720             : 
  185721           0 :           returnPointer = &( ( (SgFloat128Val*)(SgFloat128Val::pools[memoryBlock]) ) [positionInPool]) ;
  185722             : 
  185723           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  185724             :         }
  185725           0 :      return returnPointer ;
  185726             :    }
  185727             : 
  185728             : //############################################################################
  185729             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  185730             :   for the AST with the index astIndex
  185731             : */
  185732           0 : SgFloat128Val * SgFloat128Val::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  185733           0 :      SgFloat128Val* returnPointer = NULL;
  185734           0 :      if ( globalIndex != 0 )
  185735             :         {
  185736             : 
  185737             : #if FILE_IO_EXTRA_CHECK
  185738           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFloat128Val ) ) <= globalIndex ) ;
  185739           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFloat128Val + 1 ) ) );
  185740             : #endif
  185741           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFloat128Val )
  185742           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFloat128Val );
  185743           0 :           unsigned long positionInPool = localIndex % SgFloat128Val::pool_size ;
  185744           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFloat128Val::pool_size ;
  185745             : 
  185746             : #if FILE_IO_EXTRA_CHECK
  185747             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  185748             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  185749             : #endif
  185750             : 
  185751           0 :           returnPointer = &( ( (SgFloat128Val*)(SgFloat128Val::pools[memoryBlock]) ) [positionInPool]) ;
  185752             : 
  185753             : #if FILE_IO_EXTRA_CHECK
  185754           0 :           assert ( returnPointer != NULL ) ;
  185755             : #endif
  185756             :         }
  185757           0 :      return returnPointer ;
  185758             :    }
  185759             : 
  185760             : //############################################################################
  185761             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  185762             :  * pool size! We set for every valid object in the memory pool the freepointer
  185763             :  * to the global index and increase the global index afterwards. For all the 
  185764             :  * invalid objects (means address ranges within the memory pool that were not
  185765             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  185766             :  * distinguish valid from invalid objects! 
  185767             :  */
  185768             : unsigned long
  185769           5 : SgFloat128Val::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  185770             :    {
  185771           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  185772           5 :      SgFloat128Val* pointer = NULL;
  185773           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  185774           5 :      std::vector < unsigned char* > :: const_iterator block;
  185775           5 :      for ( block = SgFloat128Val::pools.begin(); block != SgFloat128Val::pools.end() ; ++block )
  185776             :         {
  185777           0 :           pointer = (SgFloat128Val*)(*block);
  185778           0 :           for (unsigned i = 0; i < SgFloat128Val::pool_size; ++i )
  185779             :              {
  185780             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  185781             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  185782             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  185783             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  185784             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  185785             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  185786             :             // properly; so this will have to be checked next.
  185787             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  185788             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  185789           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  185790             :                   {
  185791           0 :                     pointer[i].set_freepointer((SgFloat128Val*)(globalIndex));
  185792           0 :                     globalIndex++;
  185793             :                   }
  185794             :                else
  185795             :                   {
  185796           0 :                     pointer[i].set_freepointer(NULL);
  185797             :                   }
  185798             :               }
  185799             :         }
  185800           5 :      return globalIndex;
  185801             :    }
  185802             : 
  185803             : //############################################################################
  185804             : // JH (01/14/2006)
  185805             : void
  185806           5 : SgFloat128Val::resetValidFreepointers( )
  185807             :    {
  185808           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  185809           5 :      SgFloat128Val* pointer = NULL;
  185810           5 :      std::vector < unsigned char* > :: const_iterator block;
  185811           5 :      SgFloat128Val* pointerOfLinkedList = NULL;
  185812           5 :      for ( block = SgFloat128Val::pools.begin(); block != SgFloat128Val::pools.end() ; ++block )
  185813             :         {
  185814           0 :           pointer = (SgFloat128Val*)(*block);
  185815           0 :           for (unsigned i = 0; i < SgFloat128Val::pool_size; ++i )
  185816             :              {
  185817             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  185818             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  185819             :             // memory blocks!.
  185820           0 :                if ( pointer[i].get_freepointer() != NULL )
  185821             :                   {
  185822           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  185823             :                   }
  185824             :                else
  185825             :                   {
  185826           0 :                     if ( pointerOfLinkedList == NULL )
  185827             :                        {
  185828           0 :                          SgFloat128Val::next_node = &(pointer[i]);
  185829             :                        }
  185830             :                     else
  185831             :                        {
  185832             :                       // printf ("In SgFloat128Val::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  185833           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  185834             :                        }
  185835             :                     pointerOfLinkedList = &(pointer[i]);
  185836             :                   }
  185837             :               }
  185838             :         }
  185839             : 
  185840           5 :      if ( pointerOfLinkedList != NULL )
  185841             :         {
  185842             :        // printf ("In SgFloat128Val::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  185843           0 :           pointerOfLinkedList->set_freepointer(NULL);
  185844             :        // DQ (6/6/2010): Temporary debugging...
  185845             :        //   ROSE_ASSERT(false);
  185846             :         }
  185847             : 
  185848           5 :      return ;
  185849             :    }
  185850             : 
  185851             : //############################################################################
  185852             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  185853             :  * within the memory pool and resets the freepointers, in order to achieve a 
  185854             :  * linked list, that has no jumps and starts at the beginning! This function 
  185855             :  * does not extend the memory pool, since we do not delete any memory blocks,
  185856             :  * but delete the valid objects.  
  185857             :  */
  185858             : void
  185859           0 : SgFloat128Val::clearMemoryPool( )
  185860             :    {
  185861             :   // printf ("Inside of SgFloat128Val::clearMemoryPool() \n");
  185862             : 
  185863           0 :      SgFloat128Val* pointer = NULL, *tempPointer = NULL;
  185864           0 :      std::vector < unsigned char* > :: const_iterator block;
  185865           0 :      if ( SgFloat128Val::pools.empty() == false )
  185866             :         {
  185867           0 :           block = SgFloat128Val::pools.begin() ;
  185868           0 :           SgFloat128Val::next_node = (SgFloat128Val*) (*block);
  185869             : 
  185870           0 :           while ( block != SgFloat128Val::pools.end() )
  185871             :              {
  185872           0 :                pointer = (SgFloat128Val*) (*block);
  185873           0 :                if ( tempPointer != NULL )
  185874             :                   {
  185875           0 :                     tempPointer->set_freepointer(pointer);
  185876             :                   }
  185877           0 :                for (unsigned i = 0; i < SgFloat128Val::pool_size - 1; ++i)
  185878             :                   {
  185879           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  185880             :                   }
  185881           0 :                 pointer[SgFloat128Val::pool_size-1].set_freepointer(NULL);
  185882           0 :                 tempPointer = &(pointer[SgFloat128Val::pool_size-1]);
  185883           0 :                 ++block;
  185884             :              }
  185885             :         }
  185886           0 :    }
  185887             : 
  185888           5 : void SgFloat128Val::deleteMemoryPool() {
  185889           5 :   for (auto p: SgFloat128Val::pools) {
  185890           0 :     ROSE_FREE(p);
  185891             :   }
  185892           5 :   SgFloat128Val::next_node = nullptr;
  185893           5 :   SgFloat128Val::pools.clear();
  185894           5 : }
  185895             : 
  185896             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  185897             : //                 reading multiple binary files to for a single AST.
  185898             : /////////// new version ////////////////////////////////
  185899             : //############################################################################
  185900             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  185901             : void
  185902           2 : SgFloat128Val::extendMemoryPoolForFileIO( )
  185903             :   {
  185904           2 :     size_t blockIndex = SgFloat128Val::pools.size();
  185905           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFloat128Val) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloat128Val);
  185906             : 
  185907           2 :     while ( (blockIndex * SgFloat128Val::pool_size) < newPoolSize)
  185908             :       {
  185909             : #if ROSE_ALLOC_TRACE
  185910             :         if (blockIndex > 0) {
  185911             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFloat128Val) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloat128Val) = %" PRIuPTR " SgFloat128Val::pool_size = %d \n",
  185912             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFloat128Val),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFloat128Val),SgFloat128Val::pool_size);
  185913             :         }
  185914             : #endif
  185915             : 
  185916           0 :         SgFloat128Val * pointer = (SgFloat128Val*) ROSE_MALLOC ( SgFloat128Val::pool_size * sizeof(SgFloat128Val) );
  185917           0 :         assert( pointer != NULL );
  185918             : #if ROSE_ALLOC_MEMSET == 1
  185919             :         memset(pointer, 0x00, SgFloat128Val::pool_size * sizeof(SgFloat128Val));
  185920             : #elif ROSE_ALLOC_MEMSET == 2
  185921             :         memset(pointer, 0xCC, SgFloat128Val::pool_size * sizeof(SgFloat128Val));
  185922             : #endif
  185923           0 :         SgFloat128Val::pools.push_back( (unsigned char*)(pointer) );
  185924           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFloat128Val::pool_size * sizeof(SgFloat128Val), V_SgFloat128Val ) );
  185925             : 
  185926           0 :         if ( SgFloat128Val::next_node != NULL ) {
  185927           0 :           if ( blockIndex > 0 ) {
  185928           0 :             SgFloat128Val * blkptr = (SgFloat128Val*)(SgFloat128Val::pools[blockIndex-1]);
  185929           0 :             blkptr[ SgFloat128Val::pool_size - 1 ].set_freepointer(pointer);
  185930             :           }
  185931             :         } else {
  185932           0 :           SgFloat128Val::next_node = pointer;
  185933             :         }
  185934             : 
  185935           0 :         for (unsigned i = 0; i < SgFloat128Val::pool_size-1; ++i)
  185936             :            {
  185937           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  185938             :            }
  185939           0 :         pointer[ SgFloat128Val::pool_size -1 ].set_freepointer(NULL);
  185940             : 
  185941           0 :         blockIndex++;
  185942             :       }
  185943           2 :   }
  185944             : 
  185945             : //############################################################################
  185946             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  185947             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  185948             :  * not compressed. However, that stuff is not yet implemented! 
  185949             :  */
  185950             : unsigned long
  185951           0 : SgFloat128Val::getNumberOfLastValidPointer()
  185952             :    {
  185953           0 :       SgFloat128Val* testPointer = (SgFloat128Val*)(SgFloat128Val::pools.back());
  185954           0 :       unsigned long localIndex = SgFloat128Val::pool_size - 1;
  185955           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  185956             :          {
  185957           0 :            localIndex--;
  185958             :          }
  185959           0 :       return (localIndex + SgFloat128Val::pool_size * (SgFloat128Val::pools.size()-1));
  185960             :    }
  185961             : 
  185962             : //############################################################################
  185963             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  185964             :  * memory pool and initializes the data member in class SgFloat128ValStroageClass
  185965             :  * from its counterpart of SgFloat128Val. The return value is just for checking, 
  185966             :  * that the whole StorageClassArray is initialized!
  185967             :  */
  185968             : unsigned long
  185969           0 : SgFloat128Val::initializeStorageClassArray( SgFloat128ValStorageClass *storageArray )
  185970             :    {
  185971           0 :      unsigned long storageCounter = 0;
  185972           0 :      std::vector < unsigned char* > :: const_iterator block = SgFloat128Val::pools.begin();
  185973           0 :      SgFloat128Val* pointer = NULL;
  185974           0 :      while ( block != SgFloat128Val::pools.end() ) {
  185975           0 :           pointer = (SgFloat128Val*) (*block);
  185976           0 :           for ( unsigned i = 0; i < SgFloat128Val::pool_size; ++i ) {
  185977           0 :                if ( pointer->get_freepointer() != NULL ) {
  185978           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  185979           0 :                  storageArray++;
  185980           0 :                  storageCounter++;
  185981             :                }
  185982           0 :                pointer++;
  185983             :              }
  185984           0 :            block++;
  185985             :         }
  185986           0 :      return storageCounter;
  185987             :    }
  185988             : 
  185989             : /* #line 185990 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  185990             : 
  185991             : 
  185992             : 
  185993             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  185994             : 
  185995             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  185996             : 
  185997             : //############################################################################
  185998             : /* JH (02/02/2006) Constructor of the IR node SgVoidVal that takes its 
  185999             :  * corresponding StorageClass as parameter
  186000             :  */
  186001           0 : SgVoidVal :: SgVoidVal ( const SgVoidValStorageClass& storageSource )   : SgValueExp (storageSource)
  186002             :    {
  186003             : 
  186004             : 
  186005             : /* #line 186006 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  186006             : 
  186007           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  186008             : 
  186009             : 
  186010             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  186011             : 
  186012             : 
  186013           0 :    }
  186014             : 
  186015             : //############################################################################
  186016             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  186017             :  * within the working AST. 
  186018             :  */
  186019           0 : SgVoidVal * SgVoidVal::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  186020           0 :      SgVoidVal* returnPointer = NULL;
  186021           0 :      if ( globalIndex != 0 )
  186022             :         {
  186023             : 
  186024             : #if FILE_IO_EXTRA_CHECK
  186025           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVoidVal ) ) <= globalIndex ) ;
  186026           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVoidVal + 1 ) ) );
  186027             : #endif
  186028           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVoidVal )  
  186029           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVoidVal );
  186030           0 :           unsigned long positionInPool = localIndex % SgVoidVal::pool_size;
  186031           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVoidVal::pool_size;
  186032             : 
  186033             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  186034             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  186035             : 
  186036           0 :           returnPointer = &( ( (SgVoidVal*)(SgVoidVal::pools[memoryBlock]) ) [positionInPool]) ;
  186037             : 
  186038           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  186039             :         }
  186040           0 :      return returnPointer ;
  186041             :    }
  186042             : 
  186043             : //############################################################################
  186044             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  186045             :   for the AST with the index astIndex
  186046             : */
  186047           0 : SgVoidVal * SgVoidVal::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  186048           0 :      SgVoidVal* returnPointer = NULL;
  186049           0 :      if ( globalIndex != 0 )
  186050             :         {
  186051             : 
  186052             : #if FILE_IO_EXTRA_CHECK
  186053           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVoidVal ) ) <= globalIndex ) ;
  186054           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVoidVal + 1 ) ) );
  186055             : #endif
  186056           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVoidVal )
  186057           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVoidVal );
  186058           0 :           unsigned long positionInPool = localIndex % SgVoidVal::pool_size ;
  186059           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVoidVal::pool_size ;
  186060             : 
  186061             : #if FILE_IO_EXTRA_CHECK
  186062             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  186063             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  186064             : #endif
  186065             : 
  186066           0 :           returnPointer = &( ( (SgVoidVal*)(SgVoidVal::pools[memoryBlock]) ) [positionInPool]) ;
  186067             : 
  186068             : #if FILE_IO_EXTRA_CHECK
  186069           0 :           assert ( returnPointer != NULL ) ;
  186070             : #endif
  186071             :         }
  186072           0 :      return returnPointer ;
  186073             :    }
  186074             : 
  186075             : //############################################################################
  186076             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  186077             :  * pool size! We set for every valid object in the memory pool the freepointer
  186078             :  * to the global index and increase the global index afterwards. For all the 
  186079             :  * invalid objects (means address ranges within the memory pool that were not
  186080             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  186081             :  * distinguish valid from invalid objects! 
  186082             :  */
  186083             : unsigned long
  186084           5 : SgVoidVal::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  186085             :    {
  186086           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  186087           5 :      SgVoidVal* pointer = NULL;
  186088           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  186089           5 :      std::vector < unsigned char* > :: const_iterator block;
  186090           5 :      for ( block = SgVoidVal::pools.begin(); block != SgVoidVal::pools.end() ; ++block )
  186091             :         {
  186092           0 :           pointer = (SgVoidVal*)(*block);
  186093           0 :           for (unsigned i = 0; i < SgVoidVal::pool_size; ++i )
  186094             :              {
  186095             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  186096             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  186097             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  186098             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  186099             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  186100             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  186101             :             // properly; so this will have to be checked next.
  186102             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  186103             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  186104           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  186105             :                   {
  186106           0 :                     pointer[i].set_freepointer((SgVoidVal*)(globalIndex));
  186107           0 :                     globalIndex++;
  186108             :                   }
  186109             :                else
  186110             :                   {
  186111           0 :                     pointer[i].set_freepointer(NULL);
  186112             :                   }
  186113             :               }
  186114             :         }
  186115           5 :      return globalIndex;
  186116             :    }
  186117             : 
  186118             : //############################################################################
  186119             : // JH (01/14/2006)
  186120             : void
  186121           5 : SgVoidVal::resetValidFreepointers( )
  186122             :    {
  186123           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  186124           5 :      SgVoidVal* pointer = NULL;
  186125           5 :      std::vector < unsigned char* > :: const_iterator block;
  186126           5 :      SgVoidVal* pointerOfLinkedList = NULL;
  186127           5 :      for ( block = SgVoidVal::pools.begin(); block != SgVoidVal::pools.end() ; ++block )
  186128             :         {
  186129           0 :           pointer = (SgVoidVal*)(*block);
  186130           0 :           for (unsigned i = 0; i < SgVoidVal::pool_size; ++i )
  186131             :              {
  186132             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  186133             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  186134             :             // memory blocks!.
  186135           0 :                if ( pointer[i].get_freepointer() != NULL )
  186136             :                   {
  186137           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  186138             :                   }
  186139             :                else
  186140             :                   {
  186141           0 :                     if ( pointerOfLinkedList == NULL )
  186142             :                        {
  186143           0 :                          SgVoidVal::next_node = &(pointer[i]);
  186144             :                        }
  186145             :                     else
  186146             :                        {
  186147             :                       // printf ("In SgVoidVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  186148           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  186149             :                        }
  186150             :                     pointerOfLinkedList = &(pointer[i]);
  186151             :                   }
  186152             :               }
  186153             :         }
  186154             : 
  186155           5 :      if ( pointerOfLinkedList != NULL )
  186156             :         {
  186157             :        // printf ("In SgVoidVal::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  186158           0 :           pointerOfLinkedList->set_freepointer(NULL);
  186159             :        // DQ (6/6/2010): Temporary debugging...
  186160             :        //   ROSE_ASSERT(false);
  186161             :         }
  186162             : 
  186163           5 :      return ;
  186164             :    }
  186165             : 
  186166             : //############################################################################
  186167             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  186168             :  * within the memory pool and resets the freepointers, in order to achieve a 
  186169             :  * linked list, that has no jumps and starts at the beginning! This function 
  186170             :  * does not extend the memory pool, since we do not delete any memory blocks,
  186171             :  * but delete the valid objects.  
  186172             :  */
  186173             : void
  186174           0 : SgVoidVal::clearMemoryPool( )
  186175             :    {
  186176             :   // printf ("Inside of SgVoidVal::clearMemoryPool() \n");
  186177             : 
  186178           0 :      SgVoidVal* pointer = NULL, *tempPointer = NULL;
  186179           0 :      std::vector < unsigned char* > :: const_iterator block;
  186180           0 :      if ( SgVoidVal::pools.empty() == false )
  186181             :         {
  186182           0 :           block = SgVoidVal::pools.begin() ;
  186183           0 :           SgVoidVal::next_node = (SgVoidVal*) (*block);
  186184             : 
  186185           0 :           while ( block != SgVoidVal::pools.end() )
  186186             :              {
  186187           0 :                pointer = (SgVoidVal*) (*block);
  186188           0 :                if ( tempPointer != NULL )
  186189             :                   {
  186190           0 :                     tempPointer->set_freepointer(pointer);
  186191             :                   }
  186192           0 :                for (unsigned i = 0; i < SgVoidVal::pool_size - 1; ++i)
  186193             :                   {
  186194           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  186195             :                   }
  186196           0 :                 pointer[SgVoidVal::pool_size-1].set_freepointer(NULL);
  186197           0 :                 tempPointer = &(pointer[SgVoidVal::pool_size-1]);
  186198           0 :                 ++block;
  186199             :              }
  186200             :         }
  186201           0 :    }
  186202             : 
  186203           5 : void SgVoidVal::deleteMemoryPool() {
  186204           5 :   for (auto p: SgVoidVal::pools) {
  186205           0 :     ROSE_FREE(p);
  186206             :   }
  186207           5 :   SgVoidVal::next_node = nullptr;
  186208           5 :   SgVoidVal::pools.clear();
  186209           5 : }
  186210             : 
  186211             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  186212             : //                 reading multiple binary files to for a single AST.
  186213             : /////////// new version ////////////////////////////////
  186214             : //############################################################################
  186215             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  186216             : void
  186217           2 : SgVoidVal::extendMemoryPoolForFileIO( )
  186218             :   {
  186219           2 :     size_t blockIndex = SgVoidVal::pools.size();
  186220           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVoidVal) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVoidVal);
  186221             : 
  186222           2 :     while ( (blockIndex * SgVoidVal::pool_size) < newPoolSize)
  186223             :       {
  186224             : #if ROSE_ALLOC_TRACE
  186225             :         if (blockIndex > 0) {
  186226             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVoidVal) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVoidVal) = %" PRIuPTR " SgVoidVal::pool_size = %d \n",
  186227             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVoidVal),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVoidVal),SgVoidVal::pool_size);
  186228             :         }
  186229             : #endif
  186230             : 
  186231           0 :         SgVoidVal * pointer = (SgVoidVal*) ROSE_MALLOC ( SgVoidVal::pool_size * sizeof(SgVoidVal) );
  186232           0 :         assert( pointer != NULL );
  186233             : #if ROSE_ALLOC_MEMSET == 1
  186234             :         memset(pointer, 0x00, SgVoidVal::pool_size * sizeof(SgVoidVal));
  186235             : #elif ROSE_ALLOC_MEMSET == 2
  186236             :         memset(pointer, 0xCC, SgVoidVal::pool_size * sizeof(SgVoidVal));
  186237             : #endif
  186238           0 :         SgVoidVal::pools.push_back( (unsigned char*)(pointer) );
  186239           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVoidVal::pool_size * sizeof(SgVoidVal), V_SgVoidVal ) );
  186240             : 
  186241           0 :         if ( SgVoidVal::next_node != NULL ) {
  186242           0 :           if ( blockIndex > 0 ) {
  186243           0 :             SgVoidVal * blkptr = (SgVoidVal*)(SgVoidVal::pools[blockIndex-1]);
  186244           0 :             blkptr[ SgVoidVal::pool_size - 1 ].set_freepointer(pointer);
  186245             :           }
  186246             :         } else {
  186247           0 :           SgVoidVal::next_node = pointer;
  186248             :         }
  186249             : 
  186250           0 :         for (unsigned i = 0; i < SgVoidVal::pool_size-1; ++i)
  186251             :            {
  186252           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  186253             :            }
  186254           0 :         pointer[ SgVoidVal::pool_size -1 ].set_freepointer(NULL);
  186255             : 
  186256           0 :         blockIndex++;
  186257             :       }
  186258           2 :   }
  186259             : 
  186260             : //############################################################################
  186261             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  186262             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  186263             :  * not compressed. However, that stuff is not yet implemented! 
  186264             :  */
  186265             : unsigned long
  186266           0 : SgVoidVal::getNumberOfLastValidPointer()
  186267             :    {
  186268           0 :       SgVoidVal* testPointer = (SgVoidVal*)(SgVoidVal::pools.back());
  186269           0 :       unsigned long localIndex = SgVoidVal::pool_size - 1;
  186270           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  186271             :          {
  186272           0 :            localIndex--;
  186273             :          }
  186274           0 :       return (localIndex + SgVoidVal::pool_size * (SgVoidVal::pools.size()-1));
  186275             :    }
  186276             : 
  186277             : //############################################################################
  186278             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  186279             :  * memory pool and initializes the data member in class SgVoidValStroageClass
  186280             :  * from its counterpart of SgVoidVal. The return value is just for checking, 
  186281             :  * that the whole StorageClassArray is initialized!
  186282             :  */
  186283             : unsigned long
  186284           0 : SgVoidVal::initializeStorageClassArray( SgVoidValStorageClass *storageArray )
  186285             :    {
  186286           0 :      unsigned long storageCounter = 0;
  186287           0 :      std::vector < unsigned char* > :: const_iterator block = SgVoidVal::pools.begin();
  186288           0 :      SgVoidVal* pointer = NULL;
  186289           0 :      while ( block != SgVoidVal::pools.end() ) {
  186290           0 :           pointer = (SgVoidVal*) (*block);
  186291           0 :           for ( unsigned i = 0; i < SgVoidVal::pool_size; ++i ) {
  186292           0 :                if ( pointer->get_freepointer() != NULL ) {
  186293           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  186294           0 :                  storageArray++;
  186295           0 :                  storageCounter++;
  186296             :                }
  186297           0 :                pointer++;
  186298             :              }
  186299           0 :            block++;
  186300             :         }
  186301           0 :      return storageCounter;
  186302             :    }
  186303             : 
  186304             : /* #line 186305 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  186305             : 
  186306             : 
  186307             : 
  186308             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  186309             : 
  186310             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  186311             : 
  186312             : //############################################################################
  186313             : /* JH (02/02/2006) Constructor of the IR node SgCallExpression that takes its 
  186314             :  * corresponding StorageClass as parameter
  186315             :  */
  186316        3222 : SgCallExpression :: SgCallExpression ( const SgCallExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  186317             :    {
  186318             : 
  186319             : 
  186320             : /* #line 186321 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  186321             : 
  186322        3222 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  186323        3222 :      p_function =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_function) );
  186324        3222 :      p_args =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_args) );
  186325        3222 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  186326             : 
  186327             : 
  186328             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  186329             : 
  186330             : 
  186331        3222 :    }
  186332             : 
  186333             : //############################################################################
  186334             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  186335             :  * within the working AST. 
  186336             :  */
  186337           0 : SgCallExpression * SgCallExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  186338           0 :      SgCallExpression* returnPointer = NULL;
  186339           0 :      if ( globalIndex != 0 )
  186340             :         {
  186341             : 
  186342             : #if FILE_IO_EXTRA_CHECK
  186343           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCallExpression ) ) <= globalIndex ) ;
  186344           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCallExpression + 1 ) ) );
  186345             : #endif
  186346           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCallExpression )  
  186347           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCallExpression );
  186348           0 :           unsigned long positionInPool = localIndex % SgCallExpression::pool_size;
  186349           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCallExpression::pool_size;
  186350             : 
  186351             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  186352             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  186353             : 
  186354           0 :           returnPointer = &( ( (SgCallExpression*)(SgCallExpression::pools[memoryBlock]) ) [positionInPool]) ;
  186355             : 
  186356           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  186357             :         }
  186358           0 :      return returnPointer ;
  186359             :    }
  186360             : 
  186361             : //############################################################################
  186362             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  186363             :   for the AST with the index astIndex
  186364             : */
  186365           0 : SgCallExpression * SgCallExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  186366           0 :      SgCallExpression* returnPointer = NULL;
  186367           0 :      if ( globalIndex != 0 )
  186368             :         {
  186369             : 
  186370             : #if FILE_IO_EXTRA_CHECK
  186371           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCallExpression ) ) <= globalIndex ) ;
  186372           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCallExpression + 1 ) ) );
  186373             : #endif
  186374           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCallExpression )
  186375           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCallExpression );
  186376           0 :           unsigned long positionInPool = localIndex % SgCallExpression::pool_size ;
  186377           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCallExpression::pool_size ;
  186378             : 
  186379             : #if FILE_IO_EXTRA_CHECK
  186380             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  186381             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  186382             : #endif
  186383             : 
  186384           0 :           returnPointer = &( ( (SgCallExpression*)(SgCallExpression::pools[memoryBlock]) ) [positionInPool]) ;
  186385             : 
  186386             : #if FILE_IO_EXTRA_CHECK
  186387           0 :           assert ( returnPointer != NULL ) ;
  186388             : #endif
  186389             :         }
  186390           0 :      return returnPointer ;
  186391             :    }
  186392             : 
  186393             : //############################################################################
  186394             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  186395             :  * pool size! We set for every valid object in the memory pool the freepointer
  186396             :  * to the global index and increase the global index afterwards. For all the 
  186397             :  * invalid objects (means address ranges within the memory pool that were not
  186398             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  186399             :  * distinguish valid from invalid objects! 
  186400             :  */
  186401             : unsigned long
  186402           5 : SgCallExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  186403             :    {
  186404           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  186405           5 :      SgCallExpression* pointer = NULL;
  186406           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  186407           5 :      std::vector < unsigned char* > :: const_iterator block;
  186408           5 :      for ( block = SgCallExpression::pools.begin(); block != SgCallExpression::pools.end() ; ++block )
  186409             :         {
  186410           0 :           pointer = (SgCallExpression*)(*block);
  186411           0 :           for (unsigned i = 0; i < SgCallExpression::pool_size; ++i )
  186412             :              {
  186413             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  186414             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  186415             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  186416             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  186417             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  186418             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  186419             :             // properly; so this will have to be checked next.
  186420             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  186421             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  186422           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  186423             :                   {
  186424           0 :                     pointer[i].set_freepointer((SgCallExpression*)(globalIndex));
  186425           0 :                     globalIndex++;
  186426             :                   }
  186427             :                else
  186428             :                   {
  186429           0 :                     pointer[i].set_freepointer(NULL);
  186430             :                   }
  186431             :               }
  186432             :         }
  186433           5 :      return globalIndex;
  186434             :    }
  186435             : 
  186436             : //############################################################################
  186437             : // JH (01/14/2006)
  186438             : void
  186439           5 : SgCallExpression::resetValidFreepointers( )
  186440             :    {
  186441           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  186442           5 :      SgCallExpression* pointer = NULL;
  186443           5 :      std::vector < unsigned char* > :: const_iterator block;
  186444           5 :      SgCallExpression* pointerOfLinkedList = NULL;
  186445           5 :      for ( block = SgCallExpression::pools.begin(); block != SgCallExpression::pools.end() ; ++block )
  186446             :         {
  186447           0 :           pointer = (SgCallExpression*)(*block);
  186448           0 :           for (unsigned i = 0; i < SgCallExpression::pool_size; ++i )
  186449             :              {
  186450             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  186451             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  186452             :             // memory blocks!.
  186453           0 :                if ( pointer[i].get_freepointer() != NULL )
  186454             :                   {
  186455           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  186456             :                   }
  186457             :                else
  186458             :                   {
  186459           0 :                     if ( pointerOfLinkedList == NULL )
  186460             :                        {
  186461           0 :                          SgCallExpression::next_node = &(pointer[i]);
  186462             :                        }
  186463             :                     else
  186464             :                        {
  186465             :                       // printf ("In SgCallExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  186466           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  186467             :                        }
  186468             :                     pointerOfLinkedList = &(pointer[i]);
  186469             :                   }
  186470             :               }
  186471             :         }
  186472             : 
  186473           5 :      if ( pointerOfLinkedList != NULL )
  186474             :         {
  186475             :        // printf ("In SgCallExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  186476           0 :           pointerOfLinkedList->set_freepointer(NULL);
  186477             :        // DQ (6/6/2010): Temporary debugging...
  186478             :        //   ROSE_ASSERT(false);
  186479             :         }
  186480             : 
  186481           5 :      return ;
  186482             :    }
  186483             : 
  186484             : //############################################################################
  186485             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  186486             :  * within the memory pool and resets the freepointers, in order to achieve a 
  186487             :  * linked list, that has no jumps and starts at the beginning! This function 
  186488             :  * does not extend the memory pool, since we do not delete any memory blocks,
  186489             :  * but delete the valid objects.  
  186490             :  */
  186491             : void
  186492           0 : SgCallExpression::clearMemoryPool( )
  186493             :    {
  186494             :   // printf ("Inside of SgCallExpression::clearMemoryPool() \n");
  186495             : 
  186496           0 :      SgCallExpression* pointer = NULL, *tempPointer = NULL;
  186497           0 :      std::vector < unsigned char* > :: const_iterator block;
  186498           0 :      if ( SgCallExpression::pools.empty() == false )
  186499             :         {
  186500           0 :           block = SgCallExpression::pools.begin() ;
  186501           0 :           SgCallExpression::next_node = (SgCallExpression*) (*block);
  186502             : 
  186503           0 :           while ( block != SgCallExpression::pools.end() )
  186504             :              {
  186505           0 :                pointer = (SgCallExpression*) (*block);
  186506           0 :                if ( tempPointer != NULL )
  186507             :                   {
  186508           0 :                     tempPointer->set_freepointer(pointer);
  186509             :                   }
  186510           0 :                for (unsigned i = 0; i < SgCallExpression::pool_size - 1; ++i)
  186511             :                   {
  186512           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  186513             :                   }
  186514           0 :                 pointer[SgCallExpression::pool_size-1].set_freepointer(NULL);
  186515           0 :                 tempPointer = &(pointer[SgCallExpression::pool_size-1]);
  186516           0 :                 ++block;
  186517             :              }
  186518             :         }
  186519           0 :    }
  186520             : 
  186521           5 : void SgCallExpression::deleteMemoryPool() {
  186522           5 :   for (auto p: SgCallExpression::pools) {
  186523           0 :     ROSE_FREE(p);
  186524             :   }
  186525           5 :   SgCallExpression::next_node = nullptr;
  186526           5 :   SgCallExpression::pools.clear();
  186527           5 : }
  186528             : 
  186529             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  186530             : //                 reading multiple binary files to for a single AST.
  186531             : /////////// new version ////////////////////////////////
  186532             : //############################################################################
  186533             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  186534             : void
  186535           2 : SgCallExpression::extendMemoryPoolForFileIO( )
  186536             :   {
  186537           2 :     size_t blockIndex = SgCallExpression::pools.size();
  186538           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCallExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCallExpression);
  186539             : 
  186540           2 :     while ( (blockIndex * SgCallExpression::pool_size) < newPoolSize)
  186541             :       {
  186542             : #if ROSE_ALLOC_TRACE
  186543             :         if (blockIndex > 0) {
  186544             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCallExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCallExpression) = %" PRIuPTR " SgCallExpression::pool_size = %d \n",
  186545             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCallExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCallExpression),SgCallExpression::pool_size);
  186546             :         }
  186547             : #endif
  186548             : 
  186549           0 :         SgCallExpression * pointer = (SgCallExpression*) ROSE_MALLOC ( SgCallExpression::pool_size * sizeof(SgCallExpression) );
  186550           0 :         assert( pointer != NULL );
  186551             : #if ROSE_ALLOC_MEMSET == 1
  186552             :         memset(pointer, 0x00, SgCallExpression::pool_size * sizeof(SgCallExpression));
  186553             : #elif ROSE_ALLOC_MEMSET == 2
  186554             :         memset(pointer, 0xCC, SgCallExpression::pool_size * sizeof(SgCallExpression));
  186555             : #endif
  186556           0 :         SgCallExpression::pools.push_back( (unsigned char*)(pointer) );
  186557           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCallExpression::pool_size * sizeof(SgCallExpression), V_SgCallExpression ) );
  186558             : 
  186559           0 :         if ( SgCallExpression::next_node != NULL ) {
  186560           0 :           if ( blockIndex > 0 ) {
  186561           0 :             SgCallExpression * blkptr = (SgCallExpression*)(SgCallExpression::pools[blockIndex-1]);
  186562           0 :             blkptr[ SgCallExpression::pool_size - 1 ].set_freepointer(pointer);
  186563             :           }
  186564             :         } else {
  186565           0 :           SgCallExpression::next_node = pointer;
  186566             :         }
  186567             : 
  186568           0 :         for (unsigned i = 0; i < SgCallExpression::pool_size-1; ++i)
  186569             :            {
  186570           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  186571             :            }
  186572           0 :         pointer[ SgCallExpression::pool_size -1 ].set_freepointer(NULL);
  186573             : 
  186574           0 :         blockIndex++;
  186575             :       }
  186576           2 :   }
  186577             : 
  186578             : //############################################################################
  186579             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  186580             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  186581             :  * not compressed. However, that stuff is not yet implemented! 
  186582             :  */
  186583             : unsigned long
  186584           0 : SgCallExpression::getNumberOfLastValidPointer()
  186585             :    {
  186586           0 :       SgCallExpression* testPointer = (SgCallExpression*)(SgCallExpression::pools.back());
  186587           0 :       unsigned long localIndex = SgCallExpression::pool_size - 1;
  186588           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  186589             :          {
  186590           0 :            localIndex--;
  186591             :          }
  186592           0 :       return (localIndex + SgCallExpression::pool_size * (SgCallExpression::pools.size()-1));
  186593             :    }
  186594             : 
  186595             : //############################################################################
  186596             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  186597             :  * memory pool and initializes the data member in class SgCallExpressionStroageClass
  186598             :  * from its counterpart of SgCallExpression. The return value is just for checking, 
  186599             :  * that the whole StorageClassArray is initialized!
  186600             :  */
  186601             : unsigned long
  186602           0 : SgCallExpression::initializeStorageClassArray( SgCallExpressionStorageClass *storageArray )
  186603             :    {
  186604           0 :      unsigned long storageCounter = 0;
  186605           0 :      std::vector < unsigned char* > :: const_iterator block = SgCallExpression::pools.begin();
  186606           0 :      SgCallExpression* pointer = NULL;
  186607           0 :      while ( block != SgCallExpression::pools.end() ) {
  186608           0 :           pointer = (SgCallExpression*) (*block);
  186609           0 :           for ( unsigned i = 0; i < SgCallExpression::pool_size; ++i ) {
  186610           0 :                if ( pointer->get_freepointer() != NULL ) {
  186611           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  186612           0 :                  storageArray++;
  186613           0 :                  storageCounter++;
  186614             :                }
  186615           0 :                pointer++;
  186616             :              }
  186617           0 :            block++;
  186618             :         }
  186619           0 :      return storageCounter;
  186620             :    }
  186621             : 
  186622             : /* #line 186623 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  186623             : 
  186624             : 
  186625             : 
  186626             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  186627             : 
  186628             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  186629             : 
  186630             : //############################################################################
  186631             : /* JH (02/02/2006) Constructor of the IR node SgFunctionCallExp that takes its 
  186632             :  * corresponding StorageClass as parameter
  186633             :  */
  186634        3222 : SgFunctionCallExp :: SgFunctionCallExp ( const SgFunctionCallExpStorageClass& storageSource )   : SgCallExpression (storageSource)
  186635             :    {
  186636             : 
  186637             : 
  186638             : /* #line 186639 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  186639             : 
  186640        3222 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  186641        3222 :      p_uses_operator_syntax = storageSource.storageOf_uses_operator_syntax ;
  186642             : 
  186643             : 
  186644             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  186645             : 
  186646             : 
  186647        3222 :    }
  186648             : 
  186649             : //############################################################################
  186650             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  186651             :  * within the working AST. 
  186652             :  */
  186653       19319 : SgFunctionCallExp * SgFunctionCallExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  186654       19319 :      SgFunctionCallExp* returnPointer = NULL;
  186655       19319 :      if ( globalIndex != 0 )
  186656             :         {
  186657             : 
  186658             : #if FILE_IO_EXTRA_CHECK
  186659       19319 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionCallExp ) ) <= globalIndex ) ;
  186660       19319 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionCallExp + 1 ) ) );
  186661             : #endif
  186662       19319 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionCallExp )  
  186663       19319 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionCallExp );
  186664       19319 :           unsigned long positionInPool = localIndex % SgFunctionCallExp::pool_size;
  186665       19319 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionCallExp::pool_size;
  186666             : 
  186667             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  186668             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  186669             : 
  186670       19319 :           returnPointer = &( ( (SgFunctionCallExp*)(SgFunctionCallExp::pools[memoryBlock]) ) [positionInPool]) ;
  186671             : 
  186672       19319 :           ROSE_ASSERT( returnPointer != NULL ) ;
  186673             :         }
  186674       19319 :      return returnPointer ;
  186675             :    }
  186676             : 
  186677             : //############################################################################
  186678             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  186679             :   for the AST with the index astIndex
  186680             : */
  186681           0 : SgFunctionCallExp * SgFunctionCallExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  186682           0 :      SgFunctionCallExp* returnPointer = NULL;
  186683           0 :      if ( globalIndex != 0 )
  186684             :         {
  186685             : 
  186686             : #if FILE_IO_EXTRA_CHECK
  186687           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionCallExp ) ) <= globalIndex ) ;
  186688           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionCallExp + 1 ) ) );
  186689             : #endif
  186690           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionCallExp )
  186691           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionCallExp );
  186692           0 :           unsigned long positionInPool = localIndex % SgFunctionCallExp::pool_size ;
  186693           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionCallExp::pool_size ;
  186694             : 
  186695             : #if FILE_IO_EXTRA_CHECK
  186696             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  186697             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  186698             : #endif
  186699             : 
  186700           0 :           returnPointer = &( ( (SgFunctionCallExp*)(SgFunctionCallExp::pools[memoryBlock]) ) [positionInPool]) ;
  186701             : 
  186702             : #if FILE_IO_EXTRA_CHECK
  186703           0 :           assert ( returnPointer != NULL ) ;
  186704             : #endif
  186705             :         }
  186706           0 :      return returnPointer ;
  186707             :    }
  186708             : 
  186709             : //############################################################################
  186710             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  186711             :  * pool size! We set for every valid object in the memory pool the freepointer
  186712             :  * to the global index and increase the global index afterwards. For all the 
  186713             :  * invalid objects (means address ranges within the memory pool that were not
  186714             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  186715             :  * distinguish valid from invalid objects! 
  186716             :  */
  186717             : unsigned long
  186718           5 : SgFunctionCallExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  186719             :    {
  186720           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  186721           5 :      SgFunctionCallExp* pointer = NULL;
  186722           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  186723           5 :      std::vector < unsigned char* > :: const_iterator block;
  186724           8 :      for ( block = SgFunctionCallExp::pools.begin(); block != SgFunctionCallExp::pools.end() ; ++block )
  186725             :         {
  186726           3 :           pointer = (SgFunctionCallExp*)(*block);
  186727        6003 :           for (unsigned i = 0; i < SgFunctionCallExp::pool_size; ++i )
  186728             :              {
  186729             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  186730             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  186731             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  186732             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  186733             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  186734             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  186735             :             // properly; so this will have to be checked next.
  186736             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  186737             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  186738        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  186739             :                   {
  186740        3222 :                     pointer[i].set_freepointer((SgFunctionCallExp*)(globalIndex));
  186741        3222 :                     globalIndex++;
  186742             :                   }
  186743             :                else
  186744             :                   {
  186745        2778 :                     pointer[i].set_freepointer(NULL);
  186746             :                   }
  186747             :               }
  186748             :         }
  186749           5 :      return globalIndex;
  186750             :    }
  186751             : 
  186752             : //############################################################################
  186753             : // JH (01/14/2006)
  186754             : void
  186755           5 : SgFunctionCallExp::resetValidFreepointers( )
  186756             :    {
  186757           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  186758           5 :      SgFunctionCallExp* pointer = NULL;
  186759           5 :      std::vector < unsigned char* > :: const_iterator block;
  186760           5 :      SgFunctionCallExp* pointerOfLinkedList = NULL;
  186761           8 :      for ( block = SgFunctionCallExp::pools.begin(); block != SgFunctionCallExp::pools.end() ; ++block )
  186762             :         {
  186763           3 :           pointer = (SgFunctionCallExp*)(*block);
  186764        6003 :           for (unsigned i = 0; i < SgFunctionCallExp::pool_size; ++i )
  186765             :              {
  186766             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  186767             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  186768             :             // memory blocks!.
  186769        6000 :                if ( pointer[i].get_freepointer() != NULL )
  186770             :                   {
  186771        3222 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  186772             :                   }
  186773             :                else
  186774             :                   {
  186775        2778 :                     if ( pointerOfLinkedList == NULL )
  186776             :                        {
  186777           2 :                          SgFunctionCallExp::next_node = &(pointer[i]);
  186778             :                        }
  186779             :                     else
  186780             :                        {
  186781             :                       // printf ("In SgFunctionCallExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  186782        2776 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  186783             :                        }
  186784             :                     pointerOfLinkedList = &(pointer[i]);
  186785             :                   }
  186786             :               }
  186787             :         }
  186788             : 
  186789           5 :      if ( pointerOfLinkedList != NULL )
  186790             :         {
  186791             :        // printf ("In SgFunctionCallExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  186792           2 :           pointerOfLinkedList->set_freepointer(NULL);
  186793             :        // DQ (6/6/2010): Temporary debugging...
  186794             :        //   ROSE_ASSERT(false);
  186795             :         }
  186796             : 
  186797           5 :      return ;
  186798             :    }
  186799             : 
  186800             : //############################################################################
  186801             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  186802             :  * within the memory pool and resets the freepointers, in order to achieve a 
  186803             :  * linked list, that has no jumps and starts at the beginning! This function 
  186804             :  * does not extend the memory pool, since we do not delete any memory blocks,
  186805             :  * but delete the valid objects.  
  186806             :  */
  186807             : void
  186808           0 : SgFunctionCallExp::clearMemoryPool( )
  186809             :    {
  186810             :   // printf ("Inside of SgFunctionCallExp::clearMemoryPool() \n");
  186811             : 
  186812           0 :      SgFunctionCallExp* pointer = NULL, *tempPointer = NULL;
  186813           0 :      std::vector < unsigned char* > :: const_iterator block;
  186814           0 :      if ( SgFunctionCallExp::pools.empty() == false )
  186815             :         {
  186816           0 :           block = SgFunctionCallExp::pools.begin() ;
  186817           0 :           SgFunctionCallExp::next_node = (SgFunctionCallExp*) (*block);
  186818             : 
  186819           0 :           while ( block != SgFunctionCallExp::pools.end() )
  186820             :              {
  186821           0 :                pointer = (SgFunctionCallExp*) (*block);
  186822           0 :                if ( tempPointer != NULL )
  186823             :                   {
  186824           0 :                     tempPointer->set_freepointer(pointer);
  186825             :                   }
  186826           0 :                for (unsigned i = 0; i < SgFunctionCallExp::pool_size - 1; ++i)
  186827             :                   {
  186828           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  186829             :                   }
  186830           0 :                 pointer[SgFunctionCallExp::pool_size-1].set_freepointer(NULL);
  186831           0 :                 tempPointer = &(pointer[SgFunctionCallExp::pool_size-1]);
  186832           0 :                 ++block;
  186833             :              }
  186834             :         }
  186835           0 :    }
  186836             : 
  186837           5 : void SgFunctionCallExp::deleteMemoryPool() {
  186838          11 :   for (auto p: SgFunctionCallExp::pools) {
  186839           6 :     ROSE_FREE(p);
  186840             :   }
  186841           5 :   SgFunctionCallExp::next_node = nullptr;
  186842           5 :   SgFunctionCallExp::pools.clear();
  186843           5 : }
  186844             : 
  186845             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  186846             : //                 reading multiple binary files to for a single AST.
  186847             : /////////// new version ////////////////////////////////
  186848             : //############################################################################
  186849             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  186850             : void
  186851           2 : SgFunctionCallExp::extendMemoryPoolForFileIO( )
  186852             :   {
  186853           2 :     size_t blockIndex = SgFunctionCallExp::pools.size();
  186854           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionCallExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionCallExp);
  186855             : 
  186856           5 :     while ( (blockIndex * SgFunctionCallExp::pool_size) < newPoolSize)
  186857             :       {
  186858             : #if ROSE_ALLOC_TRACE
  186859             :         if (blockIndex > 0) {
  186860             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionCallExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionCallExp) = %" PRIuPTR " SgFunctionCallExp::pool_size = %d \n",
  186861             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionCallExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionCallExp),SgFunctionCallExp::pool_size);
  186862             :         }
  186863             : #endif
  186864             : 
  186865           3 :         SgFunctionCallExp * pointer = (SgFunctionCallExp*) ROSE_MALLOC ( SgFunctionCallExp::pool_size * sizeof(SgFunctionCallExp) );
  186866           3 :         assert( pointer != NULL );
  186867             : #if ROSE_ALLOC_MEMSET == 1
  186868             :         memset(pointer, 0x00, SgFunctionCallExp::pool_size * sizeof(SgFunctionCallExp));
  186869             : #elif ROSE_ALLOC_MEMSET == 2
  186870             :         memset(pointer, 0xCC, SgFunctionCallExp::pool_size * sizeof(SgFunctionCallExp));
  186871             : #endif
  186872           3 :         SgFunctionCallExp::pools.push_back( (unsigned char*)(pointer) );
  186873           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionCallExp::pool_size * sizeof(SgFunctionCallExp), V_SgFunctionCallExp ) );
  186874             : 
  186875           3 :         if ( SgFunctionCallExp::next_node != NULL ) {
  186876           1 :           if ( blockIndex > 0 ) {
  186877           1 :             SgFunctionCallExp * blkptr = (SgFunctionCallExp*)(SgFunctionCallExp::pools[blockIndex-1]);
  186878           1 :             blkptr[ SgFunctionCallExp::pool_size - 1 ].set_freepointer(pointer);
  186879             :           }
  186880             :         } else {
  186881           2 :           SgFunctionCallExp::next_node = pointer;
  186882             :         }
  186883             : 
  186884        6000 :         for (unsigned i = 0; i < SgFunctionCallExp::pool_size-1; ++i)
  186885             :            {
  186886        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  186887             :            }
  186888           3 :         pointer[ SgFunctionCallExp::pool_size -1 ].set_freepointer(NULL);
  186889             : 
  186890           3 :         blockIndex++;
  186891             :       }
  186892           2 :   }
  186893             : 
  186894             : //############################################################################
  186895             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  186896             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  186897             :  * not compressed. However, that stuff is not yet implemented! 
  186898             :  */
  186899             : unsigned long
  186900           0 : SgFunctionCallExp::getNumberOfLastValidPointer()
  186901             :    {
  186902           0 :       SgFunctionCallExp* testPointer = (SgFunctionCallExp*)(SgFunctionCallExp::pools.back());
  186903           0 :       unsigned long localIndex = SgFunctionCallExp::pool_size - 1;
  186904           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  186905             :          {
  186906           0 :            localIndex--;
  186907             :          }
  186908           0 :       return (localIndex + SgFunctionCallExp::pool_size * (SgFunctionCallExp::pools.size()-1));
  186909             :    }
  186910             : 
  186911             : //############################################################################
  186912             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  186913             :  * memory pool and initializes the data member in class SgFunctionCallExpStroageClass
  186914             :  * from its counterpart of SgFunctionCallExp. The return value is just for checking, 
  186915             :  * that the whole StorageClassArray is initialized!
  186916             :  */
  186917             : unsigned long
  186918           2 : SgFunctionCallExp::initializeStorageClassArray( SgFunctionCallExpStorageClass *storageArray )
  186919             :    {
  186920           2 :      unsigned long storageCounter = 0;
  186921           2 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionCallExp::pools.begin();
  186922           2 :      SgFunctionCallExp* pointer = NULL;
  186923           5 :      while ( block != SgFunctionCallExp::pools.end() ) {
  186924           3 :           pointer = (SgFunctionCallExp*) (*block);
  186925        6003 :           for ( unsigned i = 0; i < SgFunctionCallExp::pool_size; ++i ) {
  186926        6000 :                if ( pointer->get_freepointer() != NULL ) {
  186927        3222 :                  storageArray->pickOutIRNodeData (pointer) ;
  186928        3222 :                  storageArray++;
  186929        3222 :                  storageCounter++;
  186930             :                }
  186931        6000 :                pointer++;
  186932             :              }
  186933           3 :            block++;
  186934             :         }
  186935           2 :      return storageCounter;
  186936             :    }
  186937             : 
  186938             : /* #line 186939 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  186939             : 
  186940             : 
  186941             : 
  186942             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  186943             : 
  186944             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  186945             : 
  186946             : //############################################################################
  186947             : /* JH (02/02/2006) Constructor of the IR node SgCudaKernelCallExp that takes its 
  186948             :  * corresponding StorageClass as parameter
  186949             :  */
  186950           0 : SgCudaKernelCallExp :: SgCudaKernelCallExp ( const SgCudaKernelCallExpStorageClass& storageSource )   : SgFunctionCallExp (storageSource)
  186951             :    {
  186952             : 
  186953             : 
  186954             : /* #line 186955 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  186955             : 
  186956           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  186957           0 :      p_exec_config =  (SgCudaKernelExecConfig*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_exec_config) );
  186958             : 
  186959             : 
  186960             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  186961             : 
  186962             : 
  186963           0 :    }
  186964             : 
  186965             : //############################################################################
  186966             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  186967             :  * within the working AST. 
  186968             :  */
  186969           0 : SgCudaKernelCallExp * SgCudaKernelCallExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  186970           0 :      SgCudaKernelCallExp* returnPointer = NULL;
  186971           0 :      if ( globalIndex != 0 )
  186972             :         {
  186973             : 
  186974             : #if FILE_IO_EXTRA_CHECK
  186975           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCudaKernelCallExp ) ) <= globalIndex ) ;
  186976           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCudaKernelCallExp + 1 ) ) );
  186977             : #endif
  186978           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCudaKernelCallExp )  
  186979           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCudaKernelCallExp );
  186980           0 :           unsigned long positionInPool = localIndex % SgCudaKernelCallExp::pool_size;
  186981           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCudaKernelCallExp::pool_size;
  186982             : 
  186983             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  186984             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  186985             : 
  186986           0 :           returnPointer = &( ( (SgCudaKernelCallExp*)(SgCudaKernelCallExp::pools[memoryBlock]) ) [positionInPool]) ;
  186987             : 
  186988           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  186989             :         }
  186990           0 :      return returnPointer ;
  186991             :    }
  186992             : 
  186993             : //############################################################################
  186994             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  186995             :   for the AST with the index astIndex
  186996             : */
  186997           0 : SgCudaKernelCallExp * SgCudaKernelCallExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  186998           0 :      SgCudaKernelCallExp* returnPointer = NULL;
  186999           0 :      if ( globalIndex != 0 )
  187000             :         {
  187001             : 
  187002             : #if FILE_IO_EXTRA_CHECK
  187003           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCudaKernelCallExp ) ) <= globalIndex ) ;
  187004           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCudaKernelCallExp + 1 ) ) );
  187005             : #endif
  187006           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCudaKernelCallExp )
  187007           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCudaKernelCallExp );
  187008           0 :           unsigned long positionInPool = localIndex % SgCudaKernelCallExp::pool_size ;
  187009           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCudaKernelCallExp::pool_size ;
  187010             : 
  187011             : #if FILE_IO_EXTRA_CHECK
  187012             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  187013             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  187014             : #endif
  187015             : 
  187016           0 :           returnPointer = &( ( (SgCudaKernelCallExp*)(SgCudaKernelCallExp::pools[memoryBlock]) ) [positionInPool]) ;
  187017             : 
  187018             : #if FILE_IO_EXTRA_CHECK
  187019           0 :           assert ( returnPointer != NULL ) ;
  187020             : #endif
  187021             :         }
  187022           0 :      return returnPointer ;
  187023             :    }
  187024             : 
  187025             : //############################################################################
  187026             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  187027             :  * pool size! We set for every valid object in the memory pool the freepointer
  187028             :  * to the global index and increase the global index afterwards. For all the 
  187029             :  * invalid objects (means address ranges within the memory pool that were not
  187030             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  187031             :  * distinguish valid from invalid objects! 
  187032             :  */
  187033             : unsigned long
  187034           5 : SgCudaKernelCallExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  187035             :    {
  187036           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  187037           5 :      SgCudaKernelCallExp* pointer = NULL;
  187038           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  187039           5 :      std::vector < unsigned char* > :: const_iterator block;
  187040           5 :      for ( block = SgCudaKernelCallExp::pools.begin(); block != SgCudaKernelCallExp::pools.end() ; ++block )
  187041             :         {
  187042           0 :           pointer = (SgCudaKernelCallExp*)(*block);
  187043           0 :           for (unsigned i = 0; i < SgCudaKernelCallExp::pool_size; ++i )
  187044             :              {
  187045             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  187046             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  187047             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  187048             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  187049             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  187050             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  187051             :             // properly; so this will have to be checked next.
  187052             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  187053             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  187054           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  187055             :                   {
  187056           0 :                     pointer[i].set_freepointer((SgCudaKernelCallExp*)(globalIndex));
  187057           0 :                     globalIndex++;
  187058             :                   }
  187059             :                else
  187060             :                   {
  187061           0 :                     pointer[i].set_freepointer(NULL);
  187062             :                   }
  187063             :               }
  187064             :         }
  187065           5 :      return globalIndex;
  187066             :    }
  187067             : 
  187068             : //############################################################################
  187069             : // JH (01/14/2006)
  187070             : void
  187071           5 : SgCudaKernelCallExp::resetValidFreepointers( )
  187072             :    {
  187073           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  187074           5 :      SgCudaKernelCallExp* pointer = NULL;
  187075           5 :      std::vector < unsigned char* > :: const_iterator block;
  187076           5 :      SgCudaKernelCallExp* pointerOfLinkedList = NULL;
  187077           5 :      for ( block = SgCudaKernelCallExp::pools.begin(); block != SgCudaKernelCallExp::pools.end() ; ++block )
  187078             :         {
  187079           0 :           pointer = (SgCudaKernelCallExp*)(*block);
  187080           0 :           for (unsigned i = 0; i < SgCudaKernelCallExp::pool_size; ++i )
  187081             :              {
  187082             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  187083             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  187084             :             // memory blocks!.
  187085           0 :                if ( pointer[i].get_freepointer() != NULL )
  187086             :                   {
  187087           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  187088             :                   }
  187089             :                else
  187090             :                   {
  187091           0 :                     if ( pointerOfLinkedList == NULL )
  187092             :                        {
  187093           0 :                          SgCudaKernelCallExp::next_node = &(pointer[i]);
  187094             :                        }
  187095             :                     else
  187096             :                        {
  187097             :                       // printf ("In SgCudaKernelCallExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  187098           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  187099             :                        }
  187100             :                     pointerOfLinkedList = &(pointer[i]);
  187101             :                   }
  187102             :               }
  187103             :         }
  187104             : 
  187105           5 :      if ( pointerOfLinkedList != NULL )
  187106             :         {
  187107             :        // printf ("In SgCudaKernelCallExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  187108           0 :           pointerOfLinkedList->set_freepointer(NULL);
  187109             :        // DQ (6/6/2010): Temporary debugging...
  187110             :        //   ROSE_ASSERT(false);
  187111             :         }
  187112             : 
  187113           5 :      return ;
  187114             :    }
  187115             : 
  187116             : //############################################################################
  187117             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  187118             :  * within the memory pool and resets the freepointers, in order to achieve a 
  187119             :  * linked list, that has no jumps and starts at the beginning! This function 
  187120             :  * does not extend the memory pool, since we do not delete any memory blocks,
  187121             :  * but delete the valid objects.  
  187122             :  */
  187123             : void
  187124           0 : SgCudaKernelCallExp::clearMemoryPool( )
  187125             :    {
  187126             :   // printf ("Inside of SgCudaKernelCallExp::clearMemoryPool() \n");
  187127             : 
  187128           0 :      SgCudaKernelCallExp* pointer = NULL, *tempPointer = NULL;
  187129           0 :      std::vector < unsigned char* > :: const_iterator block;
  187130           0 :      if ( SgCudaKernelCallExp::pools.empty() == false )
  187131             :         {
  187132           0 :           block = SgCudaKernelCallExp::pools.begin() ;
  187133           0 :           SgCudaKernelCallExp::next_node = (SgCudaKernelCallExp*) (*block);
  187134             : 
  187135           0 :           while ( block != SgCudaKernelCallExp::pools.end() )
  187136             :              {
  187137           0 :                pointer = (SgCudaKernelCallExp*) (*block);
  187138           0 :                if ( tempPointer != NULL )
  187139             :                   {
  187140           0 :                     tempPointer->set_freepointer(pointer);
  187141             :                   }
  187142           0 :                for (unsigned i = 0; i < SgCudaKernelCallExp::pool_size - 1; ++i)
  187143             :                   {
  187144           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  187145             :                   }
  187146           0 :                 pointer[SgCudaKernelCallExp::pool_size-1].set_freepointer(NULL);
  187147           0 :                 tempPointer = &(pointer[SgCudaKernelCallExp::pool_size-1]);
  187148           0 :                 ++block;
  187149             :              }
  187150             :         }
  187151           0 :    }
  187152             : 
  187153           5 : void SgCudaKernelCallExp::deleteMemoryPool() {
  187154           5 :   for (auto p: SgCudaKernelCallExp::pools) {
  187155           0 :     ROSE_FREE(p);
  187156             :   }
  187157           5 :   SgCudaKernelCallExp::next_node = nullptr;
  187158           5 :   SgCudaKernelCallExp::pools.clear();
  187159           5 : }
  187160             : 
  187161             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  187162             : //                 reading multiple binary files to for a single AST.
  187163             : /////////// new version ////////////////////////////////
  187164             : //############################################################################
  187165             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  187166             : void
  187167           2 : SgCudaKernelCallExp::extendMemoryPoolForFileIO( )
  187168             :   {
  187169           2 :     size_t blockIndex = SgCudaKernelCallExp::pools.size();
  187170           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCudaKernelCallExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCudaKernelCallExp);
  187171             : 
  187172           2 :     while ( (blockIndex * SgCudaKernelCallExp::pool_size) < newPoolSize)
  187173             :       {
  187174             : #if ROSE_ALLOC_TRACE
  187175             :         if (blockIndex > 0) {
  187176             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCudaKernelCallExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCudaKernelCallExp) = %" PRIuPTR " SgCudaKernelCallExp::pool_size = %d \n",
  187177             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCudaKernelCallExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCudaKernelCallExp),SgCudaKernelCallExp::pool_size);
  187178             :         }
  187179             : #endif
  187180             : 
  187181           0 :         SgCudaKernelCallExp * pointer = (SgCudaKernelCallExp*) ROSE_MALLOC ( SgCudaKernelCallExp::pool_size * sizeof(SgCudaKernelCallExp) );
  187182           0 :         assert( pointer != NULL );
  187183             : #if ROSE_ALLOC_MEMSET == 1
  187184             :         memset(pointer, 0x00, SgCudaKernelCallExp::pool_size * sizeof(SgCudaKernelCallExp));
  187185             : #elif ROSE_ALLOC_MEMSET == 2
  187186             :         memset(pointer, 0xCC, SgCudaKernelCallExp::pool_size * sizeof(SgCudaKernelCallExp));
  187187             : #endif
  187188           0 :         SgCudaKernelCallExp::pools.push_back( (unsigned char*)(pointer) );
  187189           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCudaKernelCallExp::pool_size * sizeof(SgCudaKernelCallExp), V_SgCudaKernelCallExp ) );
  187190             : 
  187191           0 :         if ( SgCudaKernelCallExp::next_node != NULL ) {
  187192           0 :           if ( blockIndex > 0 ) {
  187193           0 :             SgCudaKernelCallExp * blkptr = (SgCudaKernelCallExp*)(SgCudaKernelCallExp::pools[blockIndex-1]);
  187194           0 :             blkptr[ SgCudaKernelCallExp::pool_size - 1 ].set_freepointer(pointer);
  187195             :           }
  187196             :         } else {
  187197           0 :           SgCudaKernelCallExp::next_node = pointer;
  187198             :         }
  187199             : 
  187200           0 :         for (unsigned i = 0; i < SgCudaKernelCallExp::pool_size-1; ++i)
  187201             :            {
  187202           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  187203             :            }
  187204           0 :         pointer[ SgCudaKernelCallExp::pool_size -1 ].set_freepointer(NULL);
  187205             : 
  187206           0 :         blockIndex++;
  187207             :       }
  187208           2 :   }
  187209             : 
  187210             : //############################################################################
  187211             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  187212             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  187213             :  * not compressed. However, that stuff is not yet implemented! 
  187214             :  */
  187215             : unsigned long
  187216           0 : SgCudaKernelCallExp::getNumberOfLastValidPointer()
  187217             :    {
  187218           0 :       SgCudaKernelCallExp* testPointer = (SgCudaKernelCallExp*)(SgCudaKernelCallExp::pools.back());
  187219           0 :       unsigned long localIndex = SgCudaKernelCallExp::pool_size - 1;
  187220           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  187221             :          {
  187222           0 :            localIndex--;
  187223             :          }
  187224           0 :       return (localIndex + SgCudaKernelCallExp::pool_size * (SgCudaKernelCallExp::pools.size()-1));
  187225             :    }
  187226             : 
  187227             : //############################################################################
  187228             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  187229             :  * memory pool and initializes the data member in class SgCudaKernelCallExpStroageClass
  187230             :  * from its counterpart of SgCudaKernelCallExp. The return value is just for checking, 
  187231             :  * that the whole StorageClassArray is initialized!
  187232             :  */
  187233             : unsigned long
  187234           0 : SgCudaKernelCallExp::initializeStorageClassArray( SgCudaKernelCallExpStorageClass *storageArray )
  187235             :    {
  187236           0 :      unsigned long storageCounter = 0;
  187237           0 :      std::vector < unsigned char* > :: const_iterator block = SgCudaKernelCallExp::pools.begin();
  187238           0 :      SgCudaKernelCallExp* pointer = NULL;
  187239           0 :      while ( block != SgCudaKernelCallExp::pools.end() ) {
  187240           0 :           pointer = (SgCudaKernelCallExp*) (*block);
  187241           0 :           for ( unsigned i = 0; i < SgCudaKernelCallExp::pool_size; ++i ) {
  187242           0 :                if ( pointer->get_freepointer() != NULL ) {
  187243           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  187244           0 :                  storageArray++;
  187245           0 :                  storageCounter++;
  187246             :                }
  187247           0 :                pointer++;
  187248             :              }
  187249           0 :            block++;
  187250             :         }
  187251           0 :      return storageCounter;
  187252             :    }
  187253             : 
  187254             : /* #line 187255 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  187255             : 
  187256             : 
  187257             : 
  187258             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  187259             : 
  187260             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  187261             : 
  187262             : //############################################################################
  187263             : /* JH (02/02/2006) Constructor of the IR node SgSizeOfOp that takes its 
  187264             :  * corresponding StorageClass as parameter
  187265             :  */
  187266          98 : SgSizeOfOp :: SgSizeOfOp ( const SgSizeOfOpStorageClass& storageSource )   : SgExpression (storageSource)
  187267             :    {
  187268             : 
  187269             : 
  187270             : /* #line 187271 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  187271             : 
  187272          98 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  187273          98 :      p_operand_expr =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_expr) );
  187274          98 :      p_operand_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_type) );
  187275          98 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  187276          98 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  187277          98 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  187278          98 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  187279          98 :      p_sizeOfContainsBaseTypeDefiningDeclaration = storageSource.storageOf_sizeOfContainsBaseTypeDefiningDeclaration ;
  187280          98 :      p_is_objectless_nonstatic_data_member_reference = storageSource.storageOf_is_objectless_nonstatic_data_member_reference ;
  187281          98 :      p_name_qualification_for_pointer_to_member_class_length = storageSource.storageOf_name_qualification_for_pointer_to_member_class_length ;
  187282          98 :      p_type_elaboration_for_pointer_to_member_class_required = storageSource.storageOf_type_elaboration_for_pointer_to_member_class_required ;
  187283          98 :      p_global_qualification_for_pointer_to_member_class_required = storageSource.storageOf_global_qualification_for_pointer_to_member_class_required ;
  187284             : 
  187285             : 
  187286             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  187287             : 
  187288             : 
  187289          98 :    }
  187290             : 
  187291             : //############################################################################
  187292             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  187293             :  * within the working AST. 
  187294             :  */
  187295         396 : SgSizeOfOp * SgSizeOfOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  187296         396 :      SgSizeOfOp* returnPointer = NULL;
  187297         396 :      if ( globalIndex != 0 )
  187298             :         {
  187299             : 
  187300             : #if FILE_IO_EXTRA_CHECK
  187301         396 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSizeOfOp ) ) <= globalIndex ) ;
  187302         396 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSizeOfOp + 1 ) ) );
  187303             : #endif
  187304         396 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSizeOfOp )  
  187305         396 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSizeOfOp );
  187306         396 :           unsigned long positionInPool = localIndex % SgSizeOfOp::pool_size;
  187307         396 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSizeOfOp::pool_size;
  187308             : 
  187309             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  187310             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  187311             : 
  187312         396 :           returnPointer = &( ( (SgSizeOfOp*)(SgSizeOfOp::pools[memoryBlock]) ) [positionInPool]) ;
  187313             : 
  187314         396 :           ROSE_ASSERT( returnPointer != NULL ) ;
  187315             :         }
  187316         396 :      return returnPointer ;
  187317             :    }
  187318             : 
  187319             : //############################################################################
  187320             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  187321             :   for the AST with the index astIndex
  187322             : */
  187323           0 : SgSizeOfOp * SgSizeOfOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  187324           0 :      SgSizeOfOp* returnPointer = NULL;
  187325           0 :      if ( globalIndex != 0 )
  187326             :         {
  187327             : 
  187328             : #if FILE_IO_EXTRA_CHECK
  187329           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSizeOfOp ) ) <= globalIndex ) ;
  187330           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSizeOfOp + 1 ) ) );
  187331             : #endif
  187332           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSizeOfOp )
  187333           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSizeOfOp );
  187334           0 :           unsigned long positionInPool = localIndex % SgSizeOfOp::pool_size ;
  187335           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSizeOfOp::pool_size ;
  187336             : 
  187337             : #if FILE_IO_EXTRA_CHECK
  187338             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  187339             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  187340             : #endif
  187341             : 
  187342           0 :           returnPointer = &( ( (SgSizeOfOp*)(SgSizeOfOp::pools[memoryBlock]) ) [positionInPool]) ;
  187343             : 
  187344             : #if FILE_IO_EXTRA_CHECK
  187345           0 :           assert ( returnPointer != NULL ) ;
  187346             : #endif
  187347             :         }
  187348           0 :      return returnPointer ;
  187349             :    }
  187350             : 
  187351             : //############################################################################
  187352             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  187353             :  * pool size! We set for every valid object in the memory pool the freepointer
  187354             :  * to the global index and increase the global index afterwards. For all the 
  187355             :  * invalid objects (means address ranges within the memory pool that were not
  187356             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  187357             :  * distinguish valid from invalid objects! 
  187358             :  */
  187359             : unsigned long
  187360           5 : SgSizeOfOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  187361             :    {
  187362           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  187363           5 :      SgSizeOfOp* pointer = NULL;
  187364           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  187365           5 :      std::vector < unsigned char* > :: const_iterator block;
  187366           7 :      for ( block = SgSizeOfOp::pools.begin(); block != SgSizeOfOp::pools.end() ; ++block )
  187367             :         {
  187368           2 :           pointer = (SgSizeOfOp*)(*block);
  187369        4002 :           for (unsigned i = 0; i < SgSizeOfOp::pool_size; ++i )
  187370             :              {
  187371             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  187372             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  187373             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  187374             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  187375             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  187376             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  187377             :             // properly; so this will have to be checked next.
  187378             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  187379             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  187380        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  187381             :                   {
  187382          98 :                     pointer[i].set_freepointer((SgSizeOfOp*)(globalIndex));
  187383          98 :                     globalIndex++;
  187384             :                   }
  187385             :                else
  187386             :                   {
  187387        3902 :                     pointer[i].set_freepointer(NULL);
  187388             :                   }
  187389             :               }
  187390             :         }
  187391           5 :      return globalIndex;
  187392             :    }
  187393             : 
  187394             : //############################################################################
  187395             : // JH (01/14/2006)
  187396             : void
  187397           5 : SgSizeOfOp::resetValidFreepointers( )
  187398             :    {
  187399           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  187400           5 :      SgSizeOfOp* pointer = NULL;
  187401           5 :      std::vector < unsigned char* > :: const_iterator block;
  187402           5 :      SgSizeOfOp* pointerOfLinkedList = NULL;
  187403           7 :      for ( block = SgSizeOfOp::pools.begin(); block != SgSizeOfOp::pools.end() ; ++block )
  187404             :         {
  187405           2 :           pointer = (SgSizeOfOp*)(*block);
  187406        4002 :           for (unsigned i = 0; i < SgSizeOfOp::pool_size; ++i )
  187407             :              {
  187408             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  187409             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  187410             :             // memory blocks!.
  187411        4000 :                if ( pointer[i].get_freepointer() != NULL )
  187412             :                   {
  187413          98 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  187414             :                   }
  187415             :                else
  187416             :                   {
  187417        3902 :                     if ( pointerOfLinkedList == NULL )
  187418             :                        {
  187419           2 :                          SgSizeOfOp::next_node = &(pointer[i]);
  187420             :                        }
  187421             :                     else
  187422             :                        {
  187423             :                       // printf ("In SgSizeOfOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  187424        3900 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  187425             :                        }
  187426             :                     pointerOfLinkedList = &(pointer[i]);
  187427             :                   }
  187428             :               }
  187429             :         }
  187430             : 
  187431           5 :      if ( pointerOfLinkedList != NULL )
  187432             :         {
  187433             :        // printf ("In SgSizeOfOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  187434           2 :           pointerOfLinkedList->set_freepointer(NULL);
  187435             :        // DQ (6/6/2010): Temporary debugging...
  187436             :        //   ROSE_ASSERT(false);
  187437             :         }
  187438             : 
  187439           5 :      return ;
  187440             :    }
  187441             : 
  187442             : //############################################################################
  187443             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  187444             :  * within the memory pool and resets the freepointers, in order to achieve a 
  187445             :  * linked list, that has no jumps and starts at the beginning! This function 
  187446             :  * does not extend the memory pool, since we do not delete any memory blocks,
  187447             :  * but delete the valid objects.  
  187448             :  */
  187449             : void
  187450           0 : SgSizeOfOp::clearMemoryPool( )
  187451             :    {
  187452             :   // printf ("Inside of SgSizeOfOp::clearMemoryPool() \n");
  187453             : 
  187454           0 :      SgSizeOfOp* pointer = NULL, *tempPointer = NULL;
  187455           0 :      std::vector < unsigned char* > :: const_iterator block;
  187456           0 :      if ( SgSizeOfOp::pools.empty() == false )
  187457             :         {
  187458           0 :           block = SgSizeOfOp::pools.begin() ;
  187459           0 :           SgSizeOfOp::next_node = (SgSizeOfOp*) (*block);
  187460             : 
  187461           0 :           while ( block != SgSizeOfOp::pools.end() )
  187462             :              {
  187463           0 :                pointer = (SgSizeOfOp*) (*block);
  187464           0 :                if ( tempPointer != NULL )
  187465             :                   {
  187466           0 :                     tempPointer->set_freepointer(pointer);
  187467             :                   }
  187468           0 :                for (unsigned i = 0; i < SgSizeOfOp::pool_size - 1; ++i)
  187469             :                   {
  187470           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  187471             :                   }
  187472           0 :                 pointer[SgSizeOfOp::pool_size-1].set_freepointer(NULL);
  187473           0 :                 tempPointer = &(pointer[SgSizeOfOp::pool_size-1]);
  187474           0 :                 ++block;
  187475             :              }
  187476             :         }
  187477           0 :    }
  187478             : 
  187479           5 : void SgSizeOfOp::deleteMemoryPool() {
  187480           9 :   for (auto p: SgSizeOfOp::pools) {
  187481           4 :     ROSE_FREE(p);
  187482             :   }
  187483           5 :   SgSizeOfOp::next_node = nullptr;
  187484           5 :   SgSizeOfOp::pools.clear();
  187485           5 : }
  187486             : 
  187487             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  187488             : //                 reading multiple binary files to for a single AST.
  187489             : /////////// new version ////////////////////////////////
  187490             : //############################################################################
  187491             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  187492             : void
  187493           2 : SgSizeOfOp::extendMemoryPoolForFileIO( )
  187494             :   {
  187495           2 :     size_t blockIndex = SgSizeOfOp::pools.size();
  187496           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSizeOfOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSizeOfOp);
  187497             : 
  187498           4 :     while ( (blockIndex * SgSizeOfOp::pool_size) < newPoolSize)
  187499             :       {
  187500             : #if ROSE_ALLOC_TRACE
  187501             :         if (blockIndex > 0) {
  187502             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSizeOfOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSizeOfOp) = %" PRIuPTR " SgSizeOfOp::pool_size = %d \n",
  187503             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSizeOfOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSizeOfOp),SgSizeOfOp::pool_size);
  187504             :         }
  187505             : #endif
  187506             : 
  187507           2 :         SgSizeOfOp * pointer = (SgSizeOfOp*) ROSE_MALLOC ( SgSizeOfOp::pool_size * sizeof(SgSizeOfOp) );
  187508           2 :         assert( pointer != NULL );
  187509             : #if ROSE_ALLOC_MEMSET == 1
  187510             :         memset(pointer, 0x00, SgSizeOfOp::pool_size * sizeof(SgSizeOfOp));
  187511             : #elif ROSE_ALLOC_MEMSET == 2
  187512             :         memset(pointer, 0xCC, SgSizeOfOp::pool_size * sizeof(SgSizeOfOp));
  187513             : #endif
  187514           2 :         SgSizeOfOp::pools.push_back( (unsigned char*)(pointer) );
  187515           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSizeOfOp::pool_size * sizeof(SgSizeOfOp), V_SgSizeOfOp ) );
  187516             : 
  187517           2 :         if ( SgSizeOfOp::next_node != NULL ) {
  187518           0 :           if ( blockIndex > 0 ) {
  187519           0 :             SgSizeOfOp * blkptr = (SgSizeOfOp*)(SgSizeOfOp::pools[blockIndex-1]);
  187520           0 :             blkptr[ SgSizeOfOp::pool_size - 1 ].set_freepointer(pointer);
  187521             :           }
  187522             :         } else {
  187523           2 :           SgSizeOfOp::next_node = pointer;
  187524             :         }
  187525             : 
  187526        4000 :         for (unsigned i = 0; i < SgSizeOfOp::pool_size-1; ++i)
  187527             :            {
  187528        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  187529             :            }
  187530           2 :         pointer[ SgSizeOfOp::pool_size -1 ].set_freepointer(NULL);
  187531             : 
  187532           2 :         blockIndex++;
  187533             :       }
  187534           2 :   }
  187535             : 
  187536             : //############################################################################
  187537             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  187538             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  187539             :  * not compressed. However, that stuff is not yet implemented! 
  187540             :  */
  187541             : unsigned long
  187542           0 : SgSizeOfOp::getNumberOfLastValidPointer()
  187543             :    {
  187544           0 :       SgSizeOfOp* testPointer = (SgSizeOfOp*)(SgSizeOfOp::pools.back());
  187545           0 :       unsigned long localIndex = SgSizeOfOp::pool_size - 1;
  187546           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  187547             :          {
  187548           0 :            localIndex--;
  187549             :          }
  187550           0 :       return (localIndex + SgSizeOfOp::pool_size * (SgSizeOfOp::pools.size()-1));
  187551             :    }
  187552             : 
  187553             : //############################################################################
  187554             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  187555             :  * memory pool and initializes the data member in class SgSizeOfOpStroageClass
  187556             :  * from its counterpart of SgSizeOfOp. The return value is just for checking, 
  187557             :  * that the whole StorageClassArray is initialized!
  187558             :  */
  187559             : unsigned long
  187560           2 : SgSizeOfOp::initializeStorageClassArray( SgSizeOfOpStorageClass *storageArray )
  187561             :    {
  187562           2 :      unsigned long storageCounter = 0;
  187563           2 :      std::vector < unsigned char* > :: const_iterator block = SgSizeOfOp::pools.begin();
  187564           2 :      SgSizeOfOp* pointer = NULL;
  187565           4 :      while ( block != SgSizeOfOp::pools.end() ) {
  187566           2 :           pointer = (SgSizeOfOp*) (*block);
  187567        4002 :           for ( unsigned i = 0; i < SgSizeOfOp::pool_size; ++i ) {
  187568        4000 :                if ( pointer->get_freepointer() != NULL ) {
  187569          98 :                  storageArray->pickOutIRNodeData (pointer) ;
  187570          98 :                  storageArray++;
  187571          98 :                  storageCounter++;
  187572             :                }
  187573        4000 :                pointer++;
  187574             :              }
  187575           2 :            block++;
  187576             :         }
  187577           2 :      return storageCounter;
  187578             :    }
  187579             : 
  187580             : /* #line 187581 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  187581             : 
  187582             : 
  187583             : 
  187584             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  187585             : 
  187586             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  187587             : 
  187588             : //############################################################################
  187589             : /* JH (02/02/2006) Constructor of the IR node SgUpcLocalsizeofExpression that takes its 
  187590             :  * corresponding StorageClass as parameter
  187591             :  */
  187592           0 : SgUpcLocalsizeofExpression :: SgUpcLocalsizeofExpression ( const SgUpcLocalsizeofExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  187593             :    {
  187594             : 
  187595             : 
  187596             : /* #line 187597 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  187597             : 
  187598           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  187599           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  187600           0 :      p_operand_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_type) );
  187601           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  187602             : 
  187603             : 
  187604             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  187605             : 
  187606             : 
  187607           0 :    }
  187608             : 
  187609             : //############################################################################
  187610             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  187611             :  * within the working AST. 
  187612             :  */
  187613           0 : SgUpcLocalsizeofExpression * SgUpcLocalsizeofExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  187614           0 :      SgUpcLocalsizeofExpression* returnPointer = NULL;
  187615           0 :      if ( globalIndex != 0 )
  187616             :         {
  187617             : 
  187618             : #if FILE_IO_EXTRA_CHECK
  187619           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcLocalsizeofExpression ) ) <= globalIndex ) ;
  187620           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcLocalsizeofExpression + 1 ) ) );
  187621             : #endif
  187622           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcLocalsizeofExpression )  
  187623           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcLocalsizeofExpression );
  187624           0 :           unsigned long positionInPool = localIndex % SgUpcLocalsizeofExpression::pool_size;
  187625           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcLocalsizeofExpression::pool_size;
  187626             : 
  187627             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  187628             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  187629             : 
  187630           0 :           returnPointer = &( ( (SgUpcLocalsizeofExpression*)(SgUpcLocalsizeofExpression::pools[memoryBlock]) ) [positionInPool]) ;
  187631             : 
  187632           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  187633             :         }
  187634           0 :      return returnPointer ;
  187635             :    }
  187636             : 
  187637             : //############################################################################
  187638             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  187639             :   for the AST with the index astIndex
  187640             : */
  187641           0 : SgUpcLocalsizeofExpression * SgUpcLocalsizeofExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  187642           0 :      SgUpcLocalsizeofExpression* returnPointer = NULL;
  187643           0 :      if ( globalIndex != 0 )
  187644             :         {
  187645             : 
  187646             : #if FILE_IO_EXTRA_CHECK
  187647           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcLocalsizeofExpression ) ) <= globalIndex ) ;
  187648           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcLocalsizeofExpression + 1 ) ) );
  187649             : #endif
  187650           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcLocalsizeofExpression )
  187651           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcLocalsizeofExpression );
  187652           0 :           unsigned long positionInPool = localIndex % SgUpcLocalsizeofExpression::pool_size ;
  187653           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcLocalsizeofExpression::pool_size ;
  187654             : 
  187655             : #if FILE_IO_EXTRA_CHECK
  187656             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  187657             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  187658             : #endif
  187659             : 
  187660           0 :           returnPointer = &( ( (SgUpcLocalsizeofExpression*)(SgUpcLocalsizeofExpression::pools[memoryBlock]) ) [positionInPool]) ;
  187661             : 
  187662             : #if FILE_IO_EXTRA_CHECK
  187663           0 :           assert ( returnPointer != NULL ) ;
  187664             : #endif
  187665             :         }
  187666           0 :      return returnPointer ;
  187667             :    }
  187668             : 
  187669             : //############################################################################
  187670             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  187671             :  * pool size! We set for every valid object in the memory pool the freepointer
  187672             :  * to the global index and increase the global index afterwards. For all the 
  187673             :  * invalid objects (means address ranges within the memory pool that were not
  187674             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  187675             :  * distinguish valid from invalid objects! 
  187676             :  */
  187677             : unsigned long
  187678           5 : SgUpcLocalsizeofExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  187679             :    {
  187680           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  187681           5 :      SgUpcLocalsizeofExpression* pointer = NULL;
  187682           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  187683           5 :      std::vector < unsigned char* > :: const_iterator block;
  187684           5 :      for ( block = SgUpcLocalsizeofExpression::pools.begin(); block != SgUpcLocalsizeofExpression::pools.end() ; ++block )
  187685             :         {
  187686           0 :           pointer = (SgUpcLocalsizeofExpression*)(*block);
  187687           0 :           for (unsigned i = 0; i < SgUpcLocalsizeofExpression::pool_size; ++i )
  187688             :              {
  187689             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  187690             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  187691             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  187692             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  187693             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  187694             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  187695             :             // properly; so this will have to be checked next.
  187696             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  187697             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  187698           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  187699             :                   {
  187700           0 :                     pointer[i].set_freepointer((SgUpcLocalsizeofExpression*)(globalIndex));
  187701           0 :                     globalIndex++;
  187702             :                   }
  187703             :                else
  187704             :                   {
  187705           0 :                     pointer[i].set_freepointer(NULL);
  187706             :                   }
  187707             :               }
  187708             :         }
  187709           5 :      return globalIndex;
  187710             :    }
  187711             : 
  187712             : //############################################################################
  187713             : // JH (01/14/2006)
  187714             : void
  187715           5 : SgUpcLocalsizeofExpression::resetValidFreepointers( )
  187716             :    {
  187717           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  187718           5 :      SgUpcLocalsizeofExpression* pointer = NULL;
  187719           5 :      std::vector < unsigned char* > :: const_iterator block;
  187720           5 :      SgUpcLocalsizeofExpression* pointerOfLinkedList = NULL;
  187721           5 :      for ( block = SgUpcLocalsizeofExpression::pools.begin(); block != SgUpcLocalsizeofExpression::pools.end() ; ++block )
  187722             :         {
  187723           0 :           pointer = (SgUpcLocalsizeofExpression*)(*block);
  187724           0 :           for (unsigned i = 0; i < SgUpcLocalsizeofExpression::pool_size; ++i )
  187725             :              {
  187726             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  187727             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  187728             :             // memory blocks!.
  187729           0 :                if ( pointer[i].get_freepointer() != NULL )
  187730             :                   {
  187731           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  187732             :                   }
  187733             :                else
  187734             :                   {
  187735           0 :                     if ( pointerOfLinkedList == NULL )
  187736             :                        {
  187737           0 :                          SgUpcLocalsizeofExpression::next_node = &(pointer[i]);
  187738             :                        }
  187739             :                     else
  187740             :                        {
  187741             :                       // printf ("In SgUpcLocalsizeofExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  187742           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  187743             :                        }
  187744             :                     pointerOfLinkedList = &(pointer[i]);
  187745             :                   }
  187746             :               }
  187747             :         }
  187748             : 
  187749           5 :      if ( pointerOfLinkedList != NULL )
  187750             :         {
  187751             :        // printf ("In SgUpcLocalsizeofExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  187752           0 :           pointerOfLinkedList->set_freepointer(NULL);
  187753             :        // DQ (6/6/2010): Temporary debugging...
  187754             :        //   ROSE_ASSERT(false);
  187755             :         }
  187756             : 
  187757           5 :      return ;
  187758             :    }
  187759             : 
  187760             : //############################################################################
  187761             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  187762             :  * within the memory pool and resets the freepointers, in order to achieve a 
  187763             :  * linked list, that has no jumps and starts at the beginning! This function 
  187764             :  * does not extend the memory pool, since we do not delete any memory blocks,
  187765             :  * but delete the valid objects.  
  187766             :  */
  187767             : void
  187768           0 : SgUpcLocalsizeofExpression::clearMemoryPool( )
  187769             :    {
  187770             :   // printf ("Inside of SgUpcLocalsizeofExpression::clearMemoryPool() \n");
  187771             : 
  187772           0 :      SgUpcLocalsizeofExpression* pointer = NULL, *tempPointer = NULL;
  187773           0 :      std::vector < unsigned char* > :: const_iterator block;
  187774           0 :      if ( SgUpcLocalsizeofExpression::pools.empty() == false )
  187775             :         {
  187776           0 :           block = SgUpcLocalsizeofExpression::pools.begin() ;
  187777           0 :           SgUpcLocalsizeofExpression::next_node = (SgUpcLocalsizeofExpression*) (*block);
  187778             : 
  187779           0 :           while ( block != SgUpcLocalsizeofExpression::pools.end() )
  187780             :              {
  187781           0 :                pointer = (SgUpcLocalsizeofExpression*) (*block);
  187782           0 :                if ( tempPointer != NULL )
  187783             :                   {
  187784           0 :                     tempPointer->set_freepointer(pointer);
  187785             :                   }
  187786           0 :                for (unsigned i = 0; i < SgUpcLocalsizeofExpression::pool_size - 1; ++i)
  187787             :                   {
  187788           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  187789             :                   }
  187790           0 :                 pointer[SgUpcLocalsizeofExpression::pool_size-1].set_freepointer(NULL);
  187791           0 :                 tempPointer = &(pointer[SgUpcLocalsizeofExpression::pool_size-1]);
  187792           0 :                 ++block;
  187793             :              }
  187794             :         }
  187795           0 :    }
  187796             : 
  187797           5 : void SgUpcLocalsizeofExpression::deleteMemoryPool() {
  187798           5 :   for (auto p: SgUpcLocalsizeofExpression::pools) {
  187799           0 :     ROSE_FREE(p);
  187800             :   }
  187801           5 :   SgUpcLocalsizeofExpression::next_node = nullptr;
  187802           5 :   SgUpcLocalsizeofExpression::pools.clear();
  187803           5 : }
  187804             : 
  187805             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  187806             : //                 reading multiple binary files to for a single AST.
  187807             : /////////// new version ////////////////////////////////
  187808             : //############################################################################
  187809             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  187810             : void
  187811           2 : SgUpcLocalsizeofExpression::extendMemoryPoolForFileIO( )
  187812             :   {
  187813           2 :     size_t blockIndex = SgUpcLocalsizeofExpression::pools.size();
  187814           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcLocalsizeofExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcLocalsizeofExpression);
  187815             : 
  187816           2 :     while ( (blockIndex * SgUpcLocalsizeofExpression::pool_size) < newPoolSize)
  187817             :       {
  187818             : #if ROSE_ALLOC_TRACE
  187819             :         if (blockIndex > 0) {
  187820             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcLocalsizeofExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcLocalsizeofExpression) = %" PRIuPTR " SgUpcLocalsizeofExpression::pool_size = %d \n",
  187821             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcLocalsizeofExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcLocalsizeofExpression),SgUpcLocalsizeofExpression::pool_size);
  187822             :         }
  187823             : #endif
  187824             : 
  187825           0 :         SgUpcLocalsizeofExpression * pointer = (SgUpcLocalsizeofExpression*) ROSE_MALLOC ( SgUpcLocalsizeofExpression::pool_size * sizeof(SgUpcLocalsizeofExpression) );
  187826           0 :         assert( pointer != NULL );
  187827             : #if ROSE_ALLOC_MEMSET == 1
  187828             :         memset(pointer, 0x00, SgUpcLocalsizeofExpression::pool_size * sizeof(SgUpcLocalsizeofExpression));
  187829             : #elif ROSE_ALLOC_MEMSET == 2
  187830             :         memset(pointer, 0xCC, SgUpcLocalsizeofExpression::pool_size * sizeof(SgUpcLocalsizeofExpression));
  187831             : #endif
  187832           0 :         SgUpcLocalsizeofExpression::pools.push_back( (unsigned char*)(pointer) );
  187833           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcLocalsizeofExpression::pool_size * sizeof(SgUpcLocalsizeofExpression), V_SgUpcLocalsizeofExpression ) );
  187834             : 
  187835           0 :         if ( SgUpcLocalsizeofExpression::next_node != NULL ) {
  187836           0 :           if ( blockIndex > 0 ) {
  187837           0 :             SgUpcLocalsizeofExpression * blkptr = (SgUpcLocalsizeofExpression*)(SgUpcLocalsizeofExpression::pools[blockIndex-1]);
  187838           0 :             blkptr[ SgUpcLocalsizeofExpression::pool_size - 1 ].set_freepointer(pointer);
  187839             :           }
  187840             :         } else {
  187841           0 :           SgUpcLocalsizeofExpression::next_node = pointer;
  187842             :         }
  187843             : 
  187844           0 :         for (unsigned i = 0; i < SgUpcLocalsizeofExpression::pool_size-1; ++i)
  187845             :            {
  187846           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  187847             :            }
  187848           0 :         pointer[ SgUpcLocalsizeofExpression::pool_size -1 ].set_freepointer(NULL);
  187849             : 
  187850           0 :         blockIndex++;
  187851             :       }
  187852           2 :   }
  187853             : 
  187854             : //############################################################################
  187855             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  187856             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  187857             :  * not compressed. However, that stuff is not yet implemented! 
  187858             :  */
  187859             : unsigned long
  187860           0 : SgUpcLocalsizeofExpression::getNumberOfLastValidPointer()
  187861             :    {
  187862           0 :       SgUpcLocalsizeofExpression* testPointer = (SgUpcLocalsizeofExpression*)(SgUpcLocalsizeofExpression::pools.back());
  187863           0 :       unsigned long localIndex = SgUpcLocalsizeofExpression::pool_size - 1;
  187864           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  187865             :          {
  187866           0 :            localIndex--;
  187867             :          }
  187868           0 :       return (localIndex + SgUpcLocalsizeofExpression::pool_size * (SgUpcLocalsizeofExpression::pools.size()-1));
  187869             :    }
  187870             : 
  187871             : //############################################################################
  187872             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  187873             :  * memory pool and initializes the data member in class SgUpcLocalsizeofExpressionStroageClass
  187874             :  * from its counterpart of SgUpcLocalsizeofExpression. The return value is just for checking, 
  187875             :  * that the whole StorageClassArray is initialized!
  187876             :  */
  187877             : unsigned long
  187878           0 : SgUpcLocalsizeofExpression::initializeStorageClassArray( SgUpcLocalsizeofExpressionStorageClass *storageArray )
  187879             :    {
  187880           0 :      unsigned long storageCounter = 0;
  187881           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcLocalsizeofExpression::pools.begin();
  187882           0 :      SgUpcLocalsizeofExpression* pointer = NULL;
  187883           0 :      while ( block != SgUpcLocalsizeofExpression::pools.end() ) {
  187884           0 :           pointer = (SgUpcLocalsizeofExpression*) (*block);
  187885           0 :           for ( unsigned i = 0; i < SgUpcLocalsizeofExpression::pool_size; ++i ) {
  187886           0 :                if ( pointer->get_freepointer() != NULL ) {
  187887           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  187888           0 :                  storageArray++;
  187889           0 :                  storageCounter++;
  187890             :                }
  187891           0 :                pointer++;
  187892             :              }
  187893           0 :            block++;
  187894             :         }
  187895           0 :      return storageCounter;
  187896             :    }
  187897             : 
  187898             : /* #line 187899 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  187899             : 
  187900             : 
  187901             : 
  187902             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  187903             : 
  187904             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  187905             : 
  187906             : //############################################################################
  187907             : /* JH (02/02/2006) Constructor of the IR node SgUpcBlocksizeofExpression that takes its 
  187908             :  * corresponding StorageClass as parameter
  187909             :  */
  187910           0 : SgUpcBlocksizeofExpression :: SgUpcBlocksizeofExpression ( const SgUpcBlocksizeofExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  187911             :    {
  187912             : 
  187913             : 
  187914             : /* #line 187915 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  187915             : 
  187916           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  187917           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  187918           0 :      p_operand_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_type) );
  187919           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  187920             : 
  187921             : 
  187922             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  187923             : 
  187924             : 
  187925           0 :    }
  187926             : 
  187927             : //############################################################################
  187928             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  187929             :  * within the working AST. 
  187930             :  */
  187931           0 : SgUpcBlocksizeofExpression * SgUpcBlocksizeofExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  187932           0 :      SgUpcBlocksizeofExpression* returnPointer = NULL;
  187933           0 :      if ( globalIndex != 0 )
  187934             :         {
  187935             : 
  187936             : #if FILE_IO_EXTRA_CHECK
  187937           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcBlocksizeofExpression ) ) <= globalIndex ) ;
  187938           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcBlocksizeofExpression + 1 ) ) );
  187939             : #endif
  187940           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcBlocksizeofExpression )  
  187941           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcBlocksizeofExpression );
  187942           0 :           unsigned long positionInPool = localIndex % SgUpcBlocksizeofExpression::pool_size;
  187943           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcBlocksizeofExpression::pool_size;
  187944             : 
  187945             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  187946             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  187947             : 
  187948           0 :           returnPointer = &( ( (SgUpcBlocksizeofExpression*)(SgUpcBlocksizeofExpression::pools[memoryBlock]) ) [positionInPool]) ;
  187949             : 
  187950           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  187951             :         }
  187952           0 :      return returnPointer ;
  187953             :    }
  187954             : 
  187955             : //############################################################################
  187956             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  187957             :   for the AST with the index astIndex
  187958             : */
  187959           0 : SgUpcBlocksizeofExpression * SgUpcBlocksizeofExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  187960           0 :      SgUpcBlocksizeofExpression* returnPointer = NULL;
  187961           0 :      if ( globalIndex != 0 )
  187962             :         {
  187963             : 
  187964             : #if FILE_IO_EXTRA_CHECK
  187965           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcBlocksizeofExpression ) ) <= globalIndex ) ;
  187966           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcBlocksizeofExpression + 1 ) ) );
  187967             : #endif
  187968           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcBlocksizeofExpression )
  187969           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcBlocksizeofExpression );
  187970           0 :           unsigned long positionInPool = localIndex % SgUpcBlocksizeofExpression::pool_size ;
  187971           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcBlocksizeofExpression::pool_size ;
  187972             : 
  187973             : #if FILE_IO_EXTRA_CHECK
  187974             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  187975             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  187976             : #endif
  187977             : 
  187978           0 :           returnPointer = &( ( (SgUpcBlocksizeofExpression*)(SgUpcBlocksizeofExpression::pools[memoryBlock]) ) [positionInPool]) ;
  187979             : 
  187980             : #if FILE_IO_EXTRA_CHECK
  187981           0 :           assert ( returnPointer != NULL ) ;
  187982             : #endif
  187983             :         }
  187984           0 :      return returnPointer ;
  187985             :    }
  187986             : 
  187987             : //############################################################################
  187988             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  187989             :  * pool size! We set for every valid object in the memory pool the freepointer
  187990             :  * to the global index and increase the global index afterwards. For all the 
  187991             :  * invalid objects (means address ranges within the memory pool that were not
  187992             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  187993             :  * distinguish valid from invalid objects! 
  187994             :  */
  187995             : unsigned long
  187996           5 : SgUpcBlocksizeofExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  187997             :    {
  187998           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  187999           5 :      SgUpcBlocksizeofExpression* pointer = NULL;
  188000           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  188001           5 :      std::vector < unsigned char* > :: const_iterator block;
  188002           5 :      for ( block = SgUpcBlocksizeofExpression::pools.begin(); block != SgUpcBlocksizeofExpression::pools.end() ; ++block )
  188003             :         {
  188004           0 :           pointer = (SgUpcBlocksizeofExpression*)(*block);
  188005           0 :           for (unsigned i = 0; i < SgUpcBlocksizeofExpression::pool_size; ++i )
  188006             :              {
  188007             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  188008             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  188009             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  188010             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  188011             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  188012             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  188013             :             // properly; so this will have to be checked next.
  188014             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  188015             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  188016           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  188017             :                   {
  188018           0 :                     pointer[i].set_freepointer((SgUpcBlocksizeofExpression*)(globalIndex));
  188019           0 :                     globalIndex++;
  188020             :                   }
  188021             :                else
  188022             :                   {
  188023           0 :                     pointer[i].set_freepointer(NULL);
  188024             :                   }
  188025             :               }
  188026             :         }
  188027           5 :      return globalIndex;
  188028             :    }
  188029             : 
  188030             : //############################################################################
  188031             : // JH (01/14/2006)
  188032             : void
  188033           5 : SgUpcBlocksizeofExpression::resetValidFreepointers( )
  188034             :    {
  188035           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  188036           5 :      SgUpcBlocksizeofExpression* pointer = NULL;
  188037           5 :      std::vector < unsigned char* > :: const_iterator block;
  188038           5 :      SgUpcBlocksizeofExpression* pointerOfLinkedList = NULL;
  188039           5 :      for ( block = SgUpcBlocksizeofExpression::pools.begin(); block != SgUpcBlocksizeofExpression::pools.end() ; ++block )
  188040             :         {
  188041           0 :           pointer = (SgUpcBlocksizeofExpression*)(*block);
  188042           0 :           for (unsigned i = 0; i < SgUpcBlocksizeofExpression::pool_size; ++i )
  188043             :              {
  188044             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  188045             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  188046             :             // memory blocks!.
  188047           0 :                if ( pointer[i].get_freepointer() != NULL )
  188048             :                   {
  188049           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  188050             :                   }
  188051             :                else
  188052             :                   {
  188053           0 :                     if ( pointerOfLinkedList == NULL )
  188054             :                        {
  188055           0 :                          SgUpcBlocksizeofExpression::next_node = &(pointer[i]);
  188056             :                        }
  188057             :                     else
  188058             :                        {
  188059             :                       // printf ("In SgUpcBlocksizeofExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  188060           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  188061             :                        }
  188062             :                     pointerOfLinkedList = &(pointer[i]);
  188063             :                   }
  188064             :               }
  188065             :         }
  188066             : 
  188067           5 :      if ( pointerOfLinkedList != NULL )
  188068             :         {
  188069             :        // printf ("In SgUpcBlocksizeofExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  188070           0 :           pointerOfLinkedList->set_freepointer(NULL);
  188071             :        // DQ (6/6/2010): Temporary debugging...
  188072             :        //   ROSE_ASSERT(false);
  188073             :         }
  188074             : 
  188075           5 :      return ;
  188076             :    }
  188077             : 
  188078             : //############################################################################
  188079             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  188080             :  * within the memory pool and resets the freepointers, in order to achieve a 
  188081             :  * linked list, that has no jumps and starts at the beginning! This function 
  188082             :  * does not extend the memory pool, since we do not delete any memory blocks,
  188083             :  * but delete the valid objects.  
  188084             :  */
  188085             : void
  188086           0 : SgUpcBlocksizeofExpression::clearMemoryPool( )
  188087             :    {
  188088             :   // printf ("Inside of SgUpcBlocksizeofExpression::clearMemoryPool() \n");
  188089             : 
  188090           0 :      SgUpcBlocksizeofExpression* pointer = NULL, *tempPointer = NULL;
  188091           0 :      std::vector < unsigned char* > :: const_iterator block;
  188092           0 :      if ( SgUpcBlocksizeofExpression::pools.empty() == false )
  188093             :         {
  188094           0 :           block = SgUpcBlocksizeofExpression::pools.begin() ;
  188095           0 :           SgUpcBlocksizeofExpression::next_node = (SgUpcBlocksizeofExpression*) (*block);
  188096             : 
  188097           0 :           while ( block != SgUpcBlocksizeofExpression::pools.end() )
  188098             :              {
  188099           0 :                pointer = (SgUpcBlocksizeofExpression*) (*block);
  188100           0 :                if ( tempPointer != NULL )
  188101             :                   {
  188102           0 :                     tempPointer->set_freepointer(pointer);
  188103             :                   }
  188104           0 :                for (unsigned i = 0; i < SgUpcBlocksizeofExpression::pool_size - 1; ++i)
  188105             :                   {
  188106           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  188107             :                   }
  188108           0 :                 pointer[SgUpcBlocksizeofExpression::pool_size-1].set_freepointer(NULL);
  188109           0 :                 tempPointer = &(pointer[SgUpcBlocksizeofExpression::pool_size-1]);
  188110           0 :                 ++block;
  188111             :              }
  188112             :         }
  188113           0 :    }
  188114             : 
  188115           5 : void SgUpcBlocksizeofExpression::deleteMemoryPool() {
  188116           5 :   for (auto p: SgUpcBlocksizeofExpression::pools) {
  188117           0 :     ROSE_FREE(p);
  188118             :   }
  188119           5 :   SgUpcBlocksizeofExpression::next_node = nullptr;
  188120           5 :   SgUpcBlocksizeofExpression::pools.clear();
  188121           5 : }
  188122             : 
  188123             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  188124             : //                 reading multiple binary files to for a single AST.
  188125             : /////////// new version ////////////////////////////////
  188126             : //############################################################################
  188127             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  188128             : void
  188129           2 : SgUpcBlocksizeofExpression::extendMemoryPoolForFileIO( )
  188130             :   {
  188131           2 :     size_t blockIndex = SgUpcBlocksizeofExpression::pools.size();
  188132           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcBlocksizeofExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcBlocksizeofExpression);
  188133             : 
  188134           2 :     while ( (blockIndex * SgUpcBlocksizeofExpression::pool_size) < newPoolSize)
  188135             :       {
  188136             : #if ROSE_ALLOC_TRACE
  188137             :         if (blockIndex > 0) {
  188138             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcBlocksizeofExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcBlocksizeofExpression) = %" PRIuPTR " SgUpcBlocksizeofExpression::pool_size = %d \n",
  188139             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcBlocksizeofExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcBlocksizeofExpression),SgUpcBlocksizeofExpression::pool_size);
  188140             :         }
  188141             : #endif
  188142             : 
  188143           0 :         SgUpcBlocksizeofExpression * pointer = (SgUpcBlocksizeofExpression*) ROSE_MALLOC ( SgUpcBlocksizeofExpression::pool_size * sizeof(SgUpcBlocksizeofExpression) );
  188144           0 :         assert( pointer != NULL );
  188145             : #if ROSE_ALLOC_MEMSET == 1
  188146             :         memset(pointer, 0x00, SgUpcBlocksizeofExpression::pool_size * sizeof(SgUpcBlocksizeofExpression));
  188147             : #elif ROSE_ALLOC_MEMSET == 2
  188148             :         memset(pointer, 0xCC, SgUpcBlocksizeofExpression::pool_size * sizeof(SgUpcBlocksizeofExpression));
  188149             : #endif
  188150           0 :         SgUpcBlocksizeofExpression::pools.push_back( (unsigned char*)(pointer) );
  188151           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcBlocksizeofExpression::pool_size * sizeof(SgUpcBlocksizeofExpression), V_SgUpcBlocksizeofExpression ) );
  188152             : 
  188153           0 :         if ( SgUpcBlocksizeofExpression::next_node != NULL ) {
  188154           0 :           if ( blockIndex > 0 ) {
  188155           0 :             SgUpcBlocksizeofExpression * blkptr = (SgUpcBlocksizeofExpression*)(SgUpcBlocksizeofExpression::pools[blockIndex-1]);
  188156           0 :             blkptr[ SgUpcBlocksizeofExpression::pool_size - 1 ].set_freepointer(pointer);
  188157             :           }
  188158             :         } else {
  188159           0 :           SgUpcBlocksizeofExpression::next_node = pointer;
  188160             :         }
  188161             : 
  188162           0 :         for (unsigned i = 0; i < SgUpcBlocksizeofExpression::pool_size-1; ++i)
  188163             :            {
  188164           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  188165             :            }
  188166           0 :         pointer[ SgUpcBlocksizeofExpression::pool_size -1 ].set_freepointer(NULL);
  188167             : 
  188168           0 :         blockIndex++;
  188169             :       }
  188170           2 :   }
  188171             : 
  188172             : //############################################################################
  188173             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  188174             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  188175             :  * not compressed. However, that stuff is not yet implemented! 
  188176             :  */
  188177             : unsigned long
  188178           0 : SgUpcBlocksizeofExpression::getNumberOfLastValidPointer()
  188179             :    {
  188180           0 :       SgUpcBlocksizeofExpression* testPointer = (SgUpcBlocksizeofExpression*)(SgUpcBlocksizeofExpression::pools.back());
  188181           0 :       unsigned long localIndex = SgUpcBlocksizeofExpression::pool_size - 1;
  188182           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  188183             :          {
  188184           0 :            localIndex--;
  188185             :          }
  188186           0 :       return (localIndex + SgUpcBlocksizeofExpression::pool_size * (SgUpcBlocksizeofExpression::pools.size()-1));
  188187             :    }
  188188             : 
  188189             : //############################################################################
  188190             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  188191             :  * memory pool and initializes the data member in class SgUpcBlocksizeofExpressionStroageClass
  188192             :  * from its counterpart of SgUpcBlocksizeofExpression. The return value is just for checking, 
  188193             :  * that the whole StorageClassArray is initialized!
  188194             :  */
  188195             : unsigned long
  188196           0 : SgUpcBlocksizeofExpression::initializeStorageClassArray( SgUpcBlocksizeofExpressionStorageClass *storageArray )
  188197             :    {
  188198           0 :      unsigned long storageCounter = 0;
  188199           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcBlocksizeofExpression::pools.begin();
  188200           0 :      SgUpcBlocksizeofExpression* pointer = NULL;
  188201           0 :      while ( block != SgUpcBlocksizeofExpression::pools.end() ) {
  188202           0 :           pointer = (SgUpcBlocksizeofExpression*) (*block);
  188203           0 :           for ( unsigned i = 0; i < SgUpcBlocksizeofExpression::pool_size; ++i ) {
  188204           0 :                if ( pointer->get_freepointer() != NULL ) {
  188205           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  188206           0 :                  storageArray++;
  188207           0 :                  storageCounter++;
  188208             :                }
  188209           0 :                pointer++;
  188210             :              }
  188211           0 :            block++;
  188212             :         }
  188213           0 :      return storageCounter;
  188214             :    }
  188215             : 
  188216             : /* #line 188217 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  188217             : 
  188218             : 
  188219             : 
  188220             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  188221             : 
  188222             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  188223             : 
  188224             : //############################################################################
  188225             : /* JH (02/02/2006) Constructor of the IR node SgUpcElemsizeofExpression that takes its 
  188226             :  * corresponding StorageClass as parameter
  188227             :  */
  188228           0 : SgUpcElemsizeofExpression :: SgUpcElemsizeofExpression ( const SgUpcElemsizeofExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  188229             :    {
  188230             : 
  188231             : 
  188232             : /* #line 188233 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  188233             : 
  188234           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  188235           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  188236           0 :      p_operand_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_type) );
  188237           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  188238             : 
  188239             : 
  188240             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  188241             : 
  188242             : 
  188243           0 :    }
  188244             : 
  188245             : //############################################################################
  188246             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  188247             :  * within the working AST. 
  188248             :  */
  188249           0 : SgUpcElemsizeofExpression * SgUpcElemsizeofExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  188250           0 :      SgUpcElemsizeofExpression* returnPointer = NULL;
  188251           0 :      if ( globalIndex != 0 )
  188252             :         {
  188253             : 
  188254             : #if FILE_IO_EXTRA_CHECK
  188255           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUpcElemsizeofExpression ) ) <= globalIndex ) ;
  188256           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcElemsizeofExpression + 1 ) ) );
  188257             : #endif
  188258           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUpcElemsizeofExpression )  
  188259           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUpcElemsizeofExpression );
  188260           0 :           unsigned long positionInPool = localIndex % SgUpcElemsizeofExpression::pool_size;
  188261           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcElemsizeofExpression::pool_size;
  188262             : 
  188263             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  188264             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  188265             : 
  188266           0 :           returnPointer = &( ( (SgUpcElemsizeofExpression*)(SgUpcElemsizeofExpression::pools[memoryBlock]) ) [positionInPool]) ;
  188267             : 
  188268           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  188269             :         }
  188270           0 :      return returnPointer ;
  188271             :    }
  188272             : 
  188273             : //############################################################################
  188274             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  188275             :   for the AST with the index astIndex
  188276             : */
  188277           0 : SgUpcElemsizeofExpression * SgUpcElemsizeofExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  188278           0 :      SgUpcElemsizeofExpression* returnPointer = NULL;
  188279           0 :      if ( globalIndex != 0 )
  188280             :         {
  188281             : 
  188282             : #if FILE_IO_EXTRA_CHECK
  188283           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUpcElemsizeofExpression ) ) <= globalIndex ) ;
  188284           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcElemsizeofExpression + 1 ) ) );
  188285             : #endif
  188286           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUpcElemsizeofExpression )
  188287           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUpcElemsizeofExpression );
  188288           0 :           unsigned long positionInPool = localIndex % SgUpcElemsizeofExpression::pool_size ;
  188289           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUpcElemsizeofExpression::pool_size ;
  188290             : 
  188291             : #if FILE_IO_EXTRA_CHECK
  188292             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  188293             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  188294             : #endif
  188295             : 
  188296           0 :           returnPointer = &( ( (SgUpcElemsizeofExpression*)(SgUpcElemsizeofExpression::pools[memoryBlock]) ) [positionInPool]) ;
  188297             : 
  188298             : #if FILE_IO_EXTRA_CHECK
  188299           0 :           assert ( returnPointer != NULL ) ;
  188300             : #endif
  188301             :         }
  188302           0 :      return returnPointer ;
  188303             :    }
  188304             : 
  188305             : //############################################################################
  188306             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  188307             :  * pool size! We set for every valid object in the memory pool the freepointer
  188308             :  * to the global index and increase the global index afterwards. For all the 
  188309             :  * invalid objects (means address ranges within the memory pool that were not
  188310             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  188311             :  * distinguish valid from invalid objects! 
  188312             :  */
  188313             : unsigned long
  188314           5 : SgUpcElemsizeofExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  188315             :    {
  188316           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  188317           5 :      SgUpcElemsizeofExpression* pointer = NULL;
  188318           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  188319           5 :      std::vector < unsigned char* > :: const_iterator block;
  188320           5 :      for ( block = SgUpcElemsizeofExpression::pools.begin(); block != SgUpcElemsizeofExpression::pools.end() ; ++block )
  188321             :         {
  188322           0 :           pointer = (SgUpcElemsizeofExpression*)(*block);
  188323           0 :           for (unsigned i = 0; i < SgUpcElemsizeofExpression::pool_size; ++i )
  188324             :              {
  188325             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  188326             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  188327             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  188328             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  188329             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  188330             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  188331             :             // properly; so this will have to be checked next.
  188332             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  188333             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  188334           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  188335             :                   {
  188336           0 :                     pointer[i].set_freepointer((SgUpcElemsizeofExpression*)(globalIndex));
  188337           0 :                     globalIndex++;
  188338             :                   }
  188339             :                else
  188340             :                   {
  188341           0 :                     pointer[i].set_freepointer(NULL);
  188342             :                   }
  188343             :               }
  188344             :         }
  188345           5 :      return globalIndex;
  188346             :    }
  188347             : 
  188348             : //############################################################################
  188349             : // JH (01/14/2006)
  188350             : void
  188351           5 : SgUpcElemsizeofExpression::resetValidFreepointers( )
  188352             :    {
  188353           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  188354           5 :      SgUpcElemsizeofExpression* pointer = NULL;
  188355           5 :      std::vector < unsigned char* > :: const_iterator block;
  188356           5 :      SgUpcElemsizeofExpression* pointerOfLinkedList = NULL;
  188357           5 :      for ( block = SgUpcElemsizeofExpression::pools.begin(); block != SgUpcElemsizeofExpression::pools.end() ; ++block )
  188358             :         {
  188359           0 :           pointer = (SgUpcElemsizeofExpression*)(*block);
  188360           0 :           for (unsigned i = 0; i < SgUpcElemsizeofExpression::pool_size; ++i )
  188361             :              {
  188362             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  188363             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  188364             :             // memory blocks!.
  188365           0 :                if ( pointer[i].get_freepointer() != NULL )
  188366             :                   {
  188367           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  188368             :                   }
  188369             :                else
  188370             :                   {
  188371           0 :                     if ( pointerOfLinkedList == NULL )
  188372             :                        {
  188373           0 :                          SgUpcElemsizeofExpression::next_node = &(pointer[i]);
  188374             :                        }
  188375             :                     else
  188376             :                        {
  188377             :                       // printf ("In SgUpcElemsizeofExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  188378           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  188379             :                        }
  188380             :                     pointerOfLinkedList = &(pointer[i]);
  188381             :                   }
  188382             :               }
  188383             :         }
  188384             : 
  188385           5 :      if ( pointerOfLinkedList != NULL )
  188386             :         {
  188387             :        // printf ("In SgUpcElemsizeofExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  188388           0 :           pointerOfLinkedList->set_freepointer(NULL);
  188389             :        // DQ (6/6/2010): Temporary debugging...
  188390             :        //   ROSE_ASSERT(false);
  188391             :         }
  188392             : 
  188393           5 :      return ;
  188394             :    }
  188395             : 
  188396             : //############################################################################
  188397             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  188398             :  * within the memory pool and resets the freepointers, in order to achieve a 
  188399             :  * linked list, that has no jumps and starts at the beginning! This function 
  188400             :  * does not extend the memory pool, since we do not delete any memory blocks,
  188401             :  * but delete the valid objects.  
  188402             :  */
  188403             : void
  188404           0 : SgUpcElemsizeofExpression::clearMemoryPool( )
  188405             :    {
  188406             :   // printf ("Inside of SgUpcElemsizeofExpression::clearMemoryPool() \n");
  188407             : 
  188408           0 :      SgUpcElemsizeofExpression* pointer = NULL, *tempPointer = NULL;
  188409           0 :      std::vector < unsigned char* > :: const_iterator block;
  188410           0 :      if ( SgUpcElemsizeofExpression::pools.empty() == false )
  188411             :         {
  188412           0 :           block = SgUpcElemsizeofExpression::pools.begin() ;
  188413           0 :           SgUpcElemsizeofExpression::next_node = (SgUpcElemsizeofExpression*) (*block);
  188414             : 
  188415           0 :           while ( block != SgUpcElemsizeofExpression::pools.end() )
  188416             :              {
  188417           0 :                pointer = (SgUpcElemsizeofExpression*) (*block);
  188418           0 :                if ( tempPointer != NULL )
  188419             :                   {
  188420           0 :                     tempPointer->set_freepointer(pointer);
  188421             :                   }
  188422           0 :                for (unsigned i = 0; i < SgUpcElemsizeofExpression::pool_size - 1; ++i)
  188423             :                   {
  188424           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  188425             :                   }
  188426           0 :                 pointer[SgUpcElemsizeofExpression::pool_size-1].set_freepointer(NULL);
  188427           0 :                 tempPointer = &(pointer[SgUpcElemsizeofExpression::pool_size-1]);
  188428           0 :                 ++block;
  188429             :              }
  188430             :         }
  188431           0 :    }
  188432             : 
  188433           5 : void SgUpcElemsizeofExpression::deleteMemoryPool() {
  188434           5 :   for (auto p: SgUpcElemsizeofExpression::pools) {
  188435           0 :     ROSE_FREE(p);
  188436             :   }
  188437           5 :   SgUpcElemsizeofExpression::next_node = nullptr;
  188438           5 :   SgUpcElemsizeofExpression::pools.clear();
  188439           5 : }
  188440             : 
  188441             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  188442             : //                 reading multiple binary files to for a single AST.
  188443             : /////////// new version ////////////////////////////////
  188444             : //############################################################################
  188445             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  188446             : void
  188447           2 : SgUpcElemsizeofExpression::extendMemoryPoolForFileIO( )
  188448             :   {
  188449           2 :     size_t blockIndex = SgUpcElemsizeofExpression::pools.size();
  188450           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcElemsizeofExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcElemsizeofExpression);
  188451             : 
  188452           2 :     while ( (blockIndex * SgUpcElemsizeofExpression::pool_size) < newPoolSize)
  188453             :       {
  188454             : #if ROSE_ALLOC_TRACE
  188455             :         if (blockIndex > 0) {
  188456             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcElemsizeofExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcElemsizeofExpression) = %" PRIuPTR " SgUpcElemsizeofExpression::pool_size = %d \n",
  188457             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUpcElemsizeofExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUpcElemsizeofExpression),SgUpcElemsizeofExpression::pool_size);
  188458             :         }
  188459             : #endif
  188460             : 
  188461           0 :         SgUpcElemsizeofExpression * pointer = (SgUpcElemsizeofExpression*) ROSE_MALLOC ( SgUpcElemsizeofExpression::pool_size * sizeof(SgUpcElemsizeofExpression) );
  188462           0 :         assert( pointer != NULL );
  188463             : #if ROSE_ALLOC_MEMSET == 1
  188464             :         memset(pointer, 0x00, SgUpcElemsizeofExpression::pool_size * sizeof(SgUpcElemsizeofExpression));
  188465             : #elif ROSE_ALLOC_MEMSET == 2
  188466             :         memset(pointer, 0xCC, SgUpcElemsizeofExpression::pool_size * sizeof(SgUpcElemsizeofExpression));
  188467             : #endif
  188468           0 :         SgUpcElemsizeofExpression::pools.push_back( (unsigned char*)(pointer) );
  188469           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUpcElemsizeofExpression::pool_size * sizeof(SgUpcElemsizeofExpression), V_SgUpcElemsizeofExpression ) );
  188470             : 
  188471           0 :         if ( SgUpcElemsizeofExpression::next_node != NULL ) {
  188472           0 :           if ( blockIndex > 0 ) {
  188473           0 :             SgUpcElemsizeofExpression * blkptr = (SgUpcElemsizeofExpression*)(SgUpcElemsizeofExpression::pools[blockIndex-1]);
  188474           0 :             blkptr[ SgUpcElemsizeofExpression::pool_size - 1 ].set_freepointer(pointer);
  188475             :           }
  188476             :         } else {
  188477           0 :           SgUpcElemsizeofExpression::next_node = pointer;
  188478             :         }
  188479             : 
  188480           0 :         for (unsigned i = 0; i < SgUpcElemsizeofExpression::pool_size-1; ++i)
  188481             :            {
  188482           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  188483             :            }
  188484           0 :         pointer[ SgUpcElemsizeofExpression::pool_size -1 ].set_freepointer(NULL);
  188485             : 
  188486           0 :         blockIndex++;
  188487             :       }
  188488           2 :   }
  188489             : 
  188490             : //############################################################################
  188491             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  188492             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  188493             :  * not compressed. However, that stuff is not yet implemented! 
  188494             :  */
  188495             : unsigned long
  188496           0 : SgUpcElemsizeofExpression::getNumberOfLastValidPointer()
  188497             :    {
  188498           0 :       SgUpcElemsizeofExpression* testPointer = (SgUpcElemsizeofExpression*)(SgUpcElemsizeofExpression::pools.back());
  188499           0 :       unsigned long localIndex = SgUpcElemsizeofExpression::pool_size - 1;
  188500           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  188501             :          {
  188502           0 :            localIndex--;
  188503             :          }
  188504           0 :       return (localIndex + SgUpcElemsizeofExpression::pool_size * (SgUpcElemsizeofExpression::pools.size()-1));
  188505             :    }
  188506             : 
  188507             : //############################################################################
  188508             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  188509             :  * memory pool and initializes the data member in class SgUpcElemsizeofExpressionStroageClass
  188510             :  * from its counterpart of SgUpcElemsizeofExpression. The return value is just for checking, 
  188511             :  * that the whole StorageClassArray is initialized!
  188512             :  */
  188513             : unsigned long
  188514           0 : SgUpcElemsizeofExpression::initializeStorageClassArray( SgUpcElemsizeofExpressionStorageClass *storageArray )
  188515             :    {
  188516           0 :      unsigned long storageCounter = 0;
  188517           0 :      std::vector < unsigned char* > :: const_iterator block = SgUpcElemsizeofExpression::pools.begin();
  188518           0 :      SgUpcElemsizeofExpression* pointer = NULL;
  188519           0 :      while ( block != SgUpcElemsizeofExpression::pools.end() ) {
  188520           0 :           pointer = (SgUpcElemsizeofExpression*) (*block);
  188521           0 :           for ( unsigned i = 0; i < SgUpcElemsizeofExpression::pool_size; ++i ) {
  188522           0 :                if ( pointer->get_freepointer() != NULL ) {
  188523           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  188524           0 :                  storageArray++;
  188525           0 :                  storageCounter++;
  188526             :                }
  188527           0 :                pointer++;
  188528             :              }
  188529           0 :            block++;
  188530             :         }
  188531           0 :      return storageCounter;
  188532             :    }
  188533             : 
  188534             : /* #line 188535 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  188535             : 
  188536             : 
  188537             : 
  188538             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  188539             : 
  188540             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  188541             : 
  188542             : //############################################################################
  188543             : /* JH (02/02/2006) Constructor of the IR node SgSuperExp that takes its 
  188544             :  * corresponding StorageClass as parameter
  188545             :  */
  188546           0 : SgSuperExp :: SgSuperExp ( const SgSuperExpStorageClass& storageSource )   : SgExpression (storageSource)
  188547             :    {
  188548             : 
  188549             : 
  188550             : /* #line 188551 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  188551             : 
  188552           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  188553           0 :      p_class_symbol =  (SgClassSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_class_symbol) );
  188554           0 :      p_pobj_super = storageSource.storageOf_pobj_super ;
  188555             : 
  188556             : 
  188557             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  188558             : 
  188559             : 
  188560           0 :    }
  188561             : 
  188562             : //############################################################################
  188563             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  188564             :  * within the working AST. 
  188565             :  */
  188566           0 : SgSuperExp * SgSuperExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  188567           0 :      SgSuperExp* returnPointer = NULL;
  188568           0 :      if ( globalIndex != 0 )
  188569             :         {
  188570             : 
  188571             : #if FILE_IO_EXTRA_CHECK
  188572           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSuperExp ) ) <= globalIndex ) ;
  188573           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSuperExp + 1 ) ) );
  188574             : #endif
  188575           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSuperExp )  
  188576           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSuperExp );
  188577           0 :           unsigned long positionInPool = localIndex % SgSuperExp::pool_size;
  188578           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSuperExp::pool_size;
  188579             : 
  188580             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  188581             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  188582             : 
  188583           0 :           returnPointer = &( ( (SgSuperExp*)(SgSuperExp::pools[memoryBlock]) ) [positionInPool]) ;
  188584             : 
  188585           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  188586             :         }
  188587           0 :      return returnPointer ;
  188588             :    }
  188589             : 
  188590             : //############################################################################
  188591             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  188592             :   for the AST with the index astIndex
  188593             : */
  188594           0 : SgSuperExp * SgSuperExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  188595           0 :      SgSuperExp* returnPointer = NULL;
  188596           0 :      if ( globalIndex != 0 )
  188597             :         {
  188598             : 
  188599             : #if FILE_IO_EXTRA_CHECK
  188600           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSuperExp ) ) <= globalIndex ) ;
  188601           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSuperExp + 1 ) ) );
  188602             : #endif
  188603           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSuperExp )
  188604           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSuperExp );
  188605           0 :           unsigned long positionInPool = localIndex % SgSuperExp::pool_size ;
  188606           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSuperExp::pool_size ;
  188607             : 
  188608             : #if FILE_IO_EXTRA_CHECK
  188609             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  188610             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  188611             : #endif
  188612             : 
  188613           0 :           returnPointer = &( ( (SgSuperExp*)(SgSuperExp::pools[memoryBlock]) ) [positionInPool]) ;
  188614             : 
  188615             : #if FILE_IO_EXTRA_CHECK
  188616           0 :           assert ( returnPointer != NULL ) ;
  188617             : #endif
  188618             :         }
  188619           0 :      return returnPointer ;
  188620             :    }
  188621             : 
  188622             : //############################################################################
  188623             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  188624             :  * pool size! We set for every valid object in the memory pool the freepointer
  188625             :  * to the global index and increase the global index afterwards. For all the 
  188626             :  * invalid objects (means address ranges within the memory pool that were not
  188627             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  188628             :  * distinguish valid from invalid objects! 
  188629             :  */
  188630             : unsigned long
  188631           5 : SgSuperExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  188632             :    {
  188633           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  188634           5 :      SgSuperExp* pointer = NULL;
  188635           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  188636           5 :      std::vector < unsigned char* > :: const_iterator block;
  188637           5 :      for ( block = SgSuperExp::pools.begin(); block != SgSuperExp::pools.end() ; ++block )
  188638             :         {
  188639           0 :           pointer = (SgSuperExp*)(*block);
  188640           0 :           for (unsigned i = 0; i < SgSuperExp::pool_size; ++i )
  188641             :              {
  188642             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  188643             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  188644             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  188645             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  188646             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  188647             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  188648             :             // properly; so this will have to be checked next.
  188649             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  188650             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  188651           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  188652             :                   {
  188653           0 :                     pointer[i].set_freepointer((SgSuperExp*)(globalIndex));
  188654           0 :                     globalIndex++;
  188655             :                   }
  188656             :                else
  188657             :                   {
  188658           0 :                     pointer[i].set_freepointer(NULL);
  188659             :                   }
  188660             :               }
  188661             :         }
  188662           5 :      return globalIndex;
  188663             :    }
  188664             : 
  188665             : //############################################################################
  188666             : // JH (01/14/2006)
  188667             : void
  188668           5 : SgSuperExp::resetValidFreepointers( )
  188669             :    {
  188670           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  188671           5 :      SgSuperExp* pointer = NULL;
  188672           5 :      std::vector < unsigned char* > :: const_iterator block;
  188673           5 :      SgSuperExp* pointerOfLinkedList = NULL;
  188674           5 :      for ( block = SgSuperExp::pools.begin(); block != SgSuperExp::pools.end() ; ++block )
  188675             :         {
  188676           0 :           pointer = (SgSuperExp*)(*block);
  188677           0 :           for (unsigned i = 0; i < SgSuperExp::pool_size; ++i )
  188678             :              {
  188679             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  188680             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  188681             :             // memory blocks!.
  188682           0 :                if ( pointer[i].get_freepointer() != NULL )
  188683             :                   {
  188684           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  188685             :                   }
  188686             :                else
  188687             :                   {
  188688           0 :                     if ( pointerOfLinkedList == NULL )
  188689             :                        {
  188690           0 :                          SgSuperExp::next_node = &(pointer[i]);
  188691             :                        }
  188692             :                     else
  188693             :                        {
  188694             :                       // printf ("In SgSuperExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  188695           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  188696             :                        }
  188697             :                     pointerOfLinkedList = &(pointer[i]);
  188698             :                   }
  188699             :               }
  188700             :         }
  188701             : 
  188702           5 :      if ( pointerOfLinkedList != NULL )
  188703             :         {
  188704             :        // printf ("In SgSuperExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  188705           0 :           pointerOfLinkedList->set_freepointer(NULL);
  188706             :        // DQ (6/6/2010): Temporary debugging...
  188707             :        //   ROSE_ASSERT(false);
  188708             :         }
  188709             : 
  188710           5 :      return ;
  188711             :    }
  188712             : 
  188713             : //############################################################################
  188714             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  188715             :  * within the memory pool and resets the freepointers, in order to achieve a 
  188716             :  * linked list, that has no jumps and starts at the beginning! This function 
  188717             :  * does not extend the memory pool, since we do not delete any memory blocks,
  188718             :  * but delete the valid objects.  
  188719             :  */
  188720             : void
  188721           0 : SgSuperExp::clearMemoryPool( )
  188722             :    {
  188723             :   // printf ("Inside of SgSuperExp::clearMemoryPool() \n");
  188724             : 
  188725           0 :      SgSuperExp* pointer = NULL, *tempPointer = NULL;
  188726           0 :      std::vector < unsigned char* > :: const_iterator block;
  188727           0 :      if ( SgSuperExp::pools.empty() == false )
  188728             :         {
  188729           0 :           block = SgSuperExp::pools.begin() ;
  188730           0 :           SgSuperExp::next_node = (SgSuperExp*) (*block);
  188731             : 
  188732           0 :           while ( block != SgSuperExp::pools.end() )
  188733             :              {
  188734           0 :                pointer = (SgSuperExp*) (*block);
  188735           0 :                if ( tempPointer != NULL )
  188736             :                   {
  188737           0 :                     tempPointer->set_freepointer(pointer);
  188738             :                   }
  188739           0 :                for (unsigned i = 0; i < SgSuperExp::pool_size - 1; ++i)
  188740             :                   {
  188741           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  188742             :                   }
  188743           0 :                 pointer[SgSuperExp::pool_size-1].set_freepointer(NULL);
  188744           0 :                 tempPointer = &(pointer[SgSuperExp::pool_size-1]);
  188745           0 :                 ++block;
  188746             :              }
  188747             :         }
  188748           0 :    }
  188749             : 
  188750           5 : void SgSuperExp::deleteMemoryPool() {
  188751           5 :   for (auto p: SgSuperExp::pools) {
  188752           0 :     ROSE_FREE(p);
  188753             :   }
  188754           5 :   SgSuperExp::next_node = nullptr;
  188755           5 :   SgSuperExp::pools.clear();
  188756           5 : }
  188757             : 
  188758             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  188759             : //                 reading multiple binary files to for a single AST.
  188760             : /////////// new version ////////////////////////////////
  188761             : //############################################################################
  188762             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  188763             : void
  188764           2 : SgSuperExp::extendMemoryPoolForFileIO( )
  188765             :   {
  188766           2 :     size_t blockIndex = SgSuperExp::pools.size();
  188767           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSuperExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSuperExp);
  188768             : 
  188769           2 :     while ( (blockIndex * SgSuperExp::pool_size) < newPoolSize)
  188770             :       {
  188771             : #if ROSE_ALLOC_TRACE
  188772             :         if (blockIndex > 0) {
  188773             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSuperExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSuperExp) = %" PRIuPTR " SgSuperExp::pool_size = %d \n",
  188774             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSuperExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSuperExp),SgSuperExp::pool_size);
  188775             :         }
  188776             : #endif
  188777             : 
  188778           0 :         SgSuperExp * pointer = (SgSuperExp*) ROSE_MALLOC ( SgSuperExp::pool_size * sizeof(SgSuperExp) );
  188779           0 :         assert( pointer != NULL );
  188780             : #if ROSE_ALLOC_MEMSET == 1
  188781             :         memset(pointer, 0x00, SgSuperExp::pool_size * sizeof(SgSuperExp));
  188782             : #elif ROSE_ALLOC_MEMSET == 2
  188783             :         memset(pointer, 0xCC, SgSuperExp::pool_size * sizeof(SgSuperExp));
  188784             : #endif
  188785           0 :         SgSuperExp::pools.push_back( (unsigned char*)(pointer) );
  188786           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSuperExp::pool_size * sizeof(SgSuperExp), V_SgSuperExp ) );
  188787             : 
  188788           0 :         if ( SgSuperExp::next_node != NULL ) {
  188789           0 :           if ( blockIndex > 0 ) {
  188790           0 :             SgSuperExp * blkptr = (SgSuperExp*)(SgSuperExp::pools[blockIndex-1]);
  188791           0 :             blkptr[ SgSuperExp::pool_size - 1 ].set_freepointer(pointer);
  188792             :           }
  188793             :         } else {
  188794           0 :           SgSuperExp::next_node = pointer;
  188795             :         }
  188796             : 
  188797           0 :         for (unsigned i = 0; i < SgSuperExp::pool_size-1; ++i)
  188798             :            {
  188799           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  188800             :            }
  188801           0 :         pointer[ SgSuperExp::pool_size -1 ].set_freepointer(NULL);
  188802             : 
  188803           0 :         blockIndex++;
  188804             :       }
  188805           2 :   }
  188806             : 
  188807             : //############################################################################
  188808             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  188809             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  188810             :  * not compressed. However, that stuff is not yet implemented! 
  188811             :  */
  188812             : unsigned long
  188813           0 : SgSuperExp::getNumberOfLastValidPointer()
  188814             :    {
  188815           0 :       SgSuperExp* testPointer = (SgSuperExp*)(SgSuperExp::pools.back());
  188816           0 :       unsigned long localIndex = SgSuperExp::pool_size - 1;
  188817           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  188818             :          {
  188819           0 :            localIndex--;
  188820             :          }
  188821           0 :       return (localIndex + SgSuperExp::pool_size * (SgSuperExp::pools.size()-1));
  188822             :    }
  188823             : 
  188824             : //############################################################################
  188825             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  188826             :  * memory pool and initializes the data member in class SgSuperExpStroageClass
  188827             :  * from its counterpart of SgSuperExp. The return value is just for checking, 
  188828             :  * that the whole StorageClassArray is initialized!
  188829             :  */
  188830             : unsigned long
  188831           0 : SgSuperExp::initializeStorageClassArray( SgSuperExpStorageClass *storageArray )
  188832             :    {
  188833           0 :      unsigned long storageCounter = 0;
  188834           0 :      std::vector < unsigned char* > :: const_iterator block = SgSuperExp::pools.begin();
  188835           0 :      SgSuperExp* pointer = NULL;
  188836           0 :      while ( block != SgSuperExp::pools.end() ) {
  188837           0 :           pointer = (SgSuperExp*) (*block);
  188838           0 :           for ( unsigned i = 0; i < SgSuperExp::pool_size; ++i ) {
  188839           0 :                if ( pointer->get_freepointer() != NULL ) {
  188840           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  188841           0 :                  storageArray++;
  188842           0 :                  storageCounter++;
  188843             :                }
  188844           0 :                pointer++;
  188845             :              }
  188846           0 :            block++;
  188847             :         }
  188848           0 :      return storageCounter;
  188849             :    }
  188850             : 
  188851             : /* #line 188852 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  188852             : 
  188853             : 
  188854             : 
  188855             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  188856             : 
  188857             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  188858             : 
  188859             : //############################################################################
  188860             : /* JH (02/02/2006) Constructor of the IR node SgTypeIdOp that takes its 
  188861             :  * corresponding StorageClass as parameter
  188862             :  */
  188863           1 : SgTypeIdOp :: SgTypeIdOp ( const SgTypeIdOpStorageClass& storageSource )   : SgExpression (storageSource)
  188864             :    {
  188865             : 
  188866             : 
  188867             : /* #line 188868 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  188868             : 
  188869           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  188870           1 :      p_operand_expr =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_expr) );
  188871           1 :      p_operand_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_type) );
  188872           1 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  188873           1 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  188874           1 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  188875           1 :      p_name_qualification_for_pointer_to_member_class_length = storageSource.storageOf_name_qualification_for_pointer_to_member_class_length ;
  188876           1 :      p_type_elaboration_for_pointer_to_member_class_required = storageSource.storageOf_type_elaboration_for_pointer_to_member_class_required ;
  188877           1 :      p_global_qualification_for_pointer_to_member_class_required = storageSource.storageOf_global_qualification_for_pointer_to_member_class_required ;
  188878             : 
  188879             : 
  188880             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  188881             : 
  188882             : 
  188883           1 :    }
  188884             : 
  188885             : //############################################################################
  188886             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  188887             :  * within the working AST. 
  188888             :  */
  188889           5 : SgTypeIdOp * SgTypeIdOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  188890           5 :      SgTypeIdOp* returnPointer = NULL;
  188891           5 :      if ( globalIndex != 0 )
  188892             :         {
  188893             : 
  188894             : #if FILE_IO_EXTRA_CHECK
  188895           5 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeIdOp ) ) <= globalIndex ) ;
  188896           5 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeIdOp + 1 ) ) );
  188897             : #endif
  188898           5 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeIdOp )  
  188899           5 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeIdOp );
  188900           5 :           unsigned long positionInPool = localIndex % SgTypeIdOp::pool_size;
  188901           5 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeIdOp::pool_size;
  188902             : 
  188903             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  188904             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  188905             : 
  188906           5 :           returnPointer = &( ( (SgTypeIdOp*)(SgTypeIdOp::pools[memoryBlock]) ) [positionInPool]) ;
  188907             : 
  188908           5 :           ROSE_ASSERT( returnPointer != NULL ) ;
  188909             :         }
  188910           5 :      return returnPointer ;
  188911             :    }
  188912             : 
  188913             : //############################################################################
  188914             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  188915             :   for the AST with the index astIndex
  188916             : */
  188917           0 : SgTypeIdOp * SgTypeIdOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  188918           0 :      SgTypeIdOp* returnPointer = NULL;
  188919           0 :      if ( globalIndex != 0 )
  188920             :         {
  188921             : 
  188922             : #if FILE_IO_EXTRA_CHECK
  188923           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeIdOp ) ) <= globalIndex ) ;
  188924           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeIdOp + 1 ) ) );
  188925             : #endif
  188926           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeIdOp )
  188927           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeIdOp );
  188928           0 :           unsigned long positionInPool = localIndex % SgTypeIdOp::pool_size ;
  188929           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeIdOp::pool_size ;
  188930             : 
  188931             : #if FILE_IO_EXTRA_CHECK
  188932             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  188933             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  188934             : #endif
  188935             : 
  188936           0 :           returnPointer = &( ( (SgTypeIdOp*)(SgTypeIdOp::pools[memoryBlock]) ) [positionInPool]) ;
  188937             : 
  188938             : #if FILE_IO_EXTRA_CHECK
  188939           0 :           assert ( returnPointer != NULL ) ;
  188940             : #endif
  188941             :         }
  188942           0 :      return returnPointer ;
  188943             :    }
  188944             : 
  188945             : //############################################################################
  188946             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  188947             :  * pool size! We set for every valid object in the memory pool the freepointer
  188948             :  * to the global index and increase the global index afterwards. For all the 
  188949             :  * invalid objects (means address ranges within the memory pool that were not
  188950             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  188951             :  * distinguish valid from invalid objects! 
  188952             :  */
  188953             : unsigned long
  188954           5 : SgTypeIdOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  188955             :    {
  188956           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  188957           5 :      SgTypeIdOp* pointer = NULL;
  188958           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  188959           5 :      std::vector < unsigned char* > :: const_iterator block;
  188960           6 :      for ( block = SgTypeIdOp::pools.begin(); block != SgTypeIdOp::pools.end() ; ++block )
  188961             :         {
  188962           1 :           pointer = (SgTypeIdOp*)(*block);
  188963        2001 :           for (unsigned i = 0; i < SgTypeIdOp::pool_size; ++i )
  188964             :              {
  188965             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  188966             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  188967             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  188968             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  188969             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  188970             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  188971             :             // properly; so this will have to be checked next.
  188972             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  188973             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  188974        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  188975             :                   {
  188976           1 :                     pointer[i].set_freepointer((SgTypeIdOp*)(globalIndex));
  188977           1 :                     globalIndex++;
  188978             :                   }
  188979             :                else
  188980             :                   {
  188981        1999 :                     pointer[i].set_freepointer(NULL);
  188982             :                   }
  188983             :               }
  188984             :         }
  188985           5 :      return globalIndex;
  188986             :    }
  188987             : 
  188988             : //############################################################################
  188989             : // JH (01/14/2006)
  188990             : void
  188991           5 : SgTypeIdOp::resetValidFreepointers( )
  188992             :    {
  188993           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  188994           5 :      SgTypeIdOp* pointer = NULL;
  188995           5 :      std::vector < unsigned char* > :: const_iterator block;
  188996           5 :      SgTypeIdOp* pointerOfLinkedList = NULL;
  188997           6 :      for ( block = SgTypeIdOp::pools.begin(); block != SgTypeIdOp::pools.end() ; ++block )
  188998             :         {
  188999           1 :           pointer = (SgTypeIdOp*)(*block);
  189000        2001 :           for (unsigned i = 0; i < SgTypeIdOp::pool_size; ++i )
  189001             :              {
  189002             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  189003             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  189004             :             // memory blocks!.
  189005        2000 :                if ( pointer[i].get_freepointer() != NULL )
  189006             :                   {
  189007           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  189008             :                   }
  189009             :                else
  189010             :                   {
  189011        1999 :                     if ( pointerOfLinkedList == NULL )
  189012             :                        {
  189013           1 :                          SgTypeIdOp::next_node = &(pointer[i]);
  189014             :                        }
  189015             :                     else
  189016             :                        {
  189017             :                       // printf ("In SgTypeIdOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  189018        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  189019             :                        }
  189020             :                     pointerOfLinkedList = &(pointer[i]);
  189021             :                   }
  189022             :               }
  189023             :         }
  189024             : 
  189025           5 :      if ( pointerOfLinkedList != NULL )
  189026             :         {
  189027             :        // printf ("In SgTypeIdOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  189028           1 :           pointerOfLinkedList->set_freepointer(NULL);
  189029             :        // DQ (6/6/2010): Temporary debugging...
  189030             :        //   ROSE_ASSERT(false);
  189031             :         }
  189032             : 
  189033           5 :      return ;
  189034             :    }
  189035             : 
  189036             : //############################################################################
  189037             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  189038             :  * within the memory pool and resets the freepointers, in order to achieve a 
  189039             :  * linked list, that has no jumps and starts at the beginning! This function 
  189040             :  * does not extend the memory pool, since we do not delete any memory blocks,
  189041             :  * but delete the valid objects.  
  189042             :  */
  189043             : void
  189044           0 : SgTypeIdOp::clearMemoryPool( )
  189045             :    {
  189046             :   // printf ("Inside of SgTypeIdOp::clearMemoryPool() \n");
  189047             : 
  189048           0 :      SgTypeIdOp* pointer = NULL, *tempPointer = NULL;
  189049           0 :      std::vector < unsigned char* > :: const_iterator block;
  189050           0 :      if ( SgTypeIdOp::pools.empty() == false )
  189051             :         {
  189052           0 :           block = SgTypeIdOp::pools.begin() ;
  189053           0 :           SgTypeIdOp::next_node = (SgTypeIdOp*) (*block);
  189054             : 
  189055           0 :           while ( block != SgTypeIdOp::pools.end() )
  189056             :              {
  189057           0 :                pointer = (SgTypeIdOp*) (*block);
  189058           0 :                if ( tempPointer != NULL )
  189059             :                   {
  189060           0 :                     tempPointer->set_freepointer(pointer);
  189061             :                   }
  189062           0 :                for (unsigned i = 0; i < SgTypeIdOp::pool_size - 1; ++i)
  189063             :                   {
  189064           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  189065             :                   }
  189066           0 :                 pointer[SgTypeIdOp::pool_size-1].set_freepointer(NULL);
  189067           0 :                 tempPointer = &(pointer[SgTypeIdOp::pool_size-1]);
  189068           0 :                 ++block;
  189069             :              }
  189070             :         }
  189071           0 :    }
  189072             : 
  189073           5 : void SgTypeIdOp::deleteMemoryPool() {
  189074           7 :   for (auto p: SgTypeIdOp::pools) {
  189075           2 :     ROSE_FREE(p);
  189076             :   }
  189077           5 :   SgTypeIdOp::next_node = nullptr;
  189078           5 :   SgTypeIdOp::pools.clear();
  189079           5 : }
  189080             : 
  189081             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  189082             : //                 reading multiple binary files to for a single AST.
  189083             : /////////// new version ////////////////////////////////
  189084             : //############################################################################
  189085             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  189086             : void
  189087           2 : SgTypeIdOp::extendMemoryPoolForFileIO( )
  189088             :   {
  189089           2 :     size_t blockIndex = SgTypeIdOp::pools.size();
  189090           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeIdOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeIdOp);
  189091             : 
  189092           3 :     while ( (blockIndex * SgTypeIdOp::pool_size) < newPoolSize)
  189093             :       {
  189094             : #if ROSE_ALLOC_TRACE
  189095             :         if (blockIndex > 0) {
  189096             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeIdOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeIdOp) = %" PRIuPTR " SgTypeIdOp::pool_size = %d \n",
  189097             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeIdOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeIdOp),SgTypeIdOp::pool_size);
  189098             :         }
  189099             : #endif
  189100             : 
  189101           1 :         SgTypeIdOp * pointer = (SgTypeIdOp*) ROSE_MALLOC ( SgTypeIdOp::pool_size * sizeof(SgTypeIdOp) );
  189102           1 :         assert( pointer != NULL );
  189103             : #if ROSE_ALLOC_MEMSET == 1
  189104             :         memset(pointer, 0x00, SgTypeIdOp::pool_size * sizeof(SgTypeIdOp));
  189105             : #elif ROSE_ALLOC_MEMSET == 2
  189106             :         memset(pointer, 0xCC, SgTypeIdOp::pool_size * sizeof(SgTypeIdOp));
  189107             : #endif
  189108           1 :         SgTypeIdOp::pools.push_back( (unsigned char*)(pointer) );
  189109           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeIdOp::pool_size * sizeof(SgTypeIdOp), V_SgTypeIdOp ) );
  189110             : 
  189111           1 :         if ( SgTypeIdOp::next_node != NULL ) {
  189112           0 :           if ( blockIndex > 0 ) {
  189113           0 :             SgTypeIdOp * blkptr = (SgTypeIdOp*)(SgTypeIdOp::pools[blockIndex-1]);
  189114           0 :             blkptr[ SgTypeIdOp::pool_size - 1 ].set_freepointer(pointer);
  189115             :           }
  189116             :         } else {
  189117           1 :           SgTypeIdOp::next_node = pointer;
  189118             :         }
  189119             : 
  189120        2000 :         for (unsigned i = 0; i < SgTypeIdOp::pool_size-1; ++i)
  189121             :            {
  189122        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  189123             :            }
  189124           1 :         pointer[ SgTypeIdOp::pool_size -1 ].set_freepointer(NULL);
  189125             : 
  189126           1 :         blockIndex++;
  189127             :       }
  189128           2 :   }
  189129             : 
  189130             : //############################################################################
  189131             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  189132             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  189133             :  * not compressed. However, that stuff is not yet implemented! 
  189134             :  */
  189135             : unsigned long
  189136           0 : SgTypeIdOp::getNumberOfLastValidPointer()
  189137             :    {
  189138           0 :       SgTypeIdOp* testPointer = (SgTypeIdOp*)(SgTypeIdOp::pools.back());
  189139           0 :       unsigned long localIndex = SgTypeIdOp::pool_size - 1;
  189140           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  189141             :          {
  189142           0 :            localIndex--;
  189143             :          }
  189144           0 :       return (localIndex + SgTypeIdOp::pool_size * (SgTypeIdOp::pools.size()-1));
  189145             :    }
  189146             : 
  189147             : //############################################################################
  189148             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  189149             :  * memory pool and initializes the data member in class SgTypeIdOpStroageClass
  189150             :  * from its counterpart of SgTypeIdOp. The return value is just for checking, 
  189151             :  * that the whole StorageClassArray is initialized!
  189152             :  */
  189153             : unsigned long
  189154           1 : SgTypeIdOp::initializeStorageClassArray( SgTypeIdOpStorageClass *storageArray )
  189155             :    {
  189156           1 :      unsigned long storageCounter = 0;
  189157           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeIdOp::pools.begin();
  189158           1 :      SgTypeIdOp* pointer = NULL;
  189159           2 :      while ( block != SgTypeIdOp::pools.end() ) {
  189160           1 :           pointer = (SgTypeIdOp*) (*block);
  189161        2001 :           for ( unsigned i = 0; i < SgTypeIdOp::pool_size; ++i ) {
  189162        2000 :                if ( pointer->get_freepointer() != NULL ) {
  189163           1 :                  storageArray->pickOutIRNodeData (pointer) ;
  189164           1 :                  storageArray++;
  189165           1 :                  storageCounter++;
  189166             :                }
  189167        2000 :                pointer++;
  189168             :              }
  189169           1 :            block++;
  189170             :         }
  189171           1 :      return storageCounter;
  189172             :    }
  189173             : 
  189174             : /* #line 189175 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  189175             : 
  189176             : 
  189177             : 
  189178             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  189179             : 
  189180             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  189181             : 
  189182             : //############################################################################
  189183             : /* JH (02/02/2006) Constructor of the IR node SgConditionalExp that takes its 
  189184             :  * corresponding StorageClass as parameter
  189185             :  */
  189186          71 : SgConditionalExp :: SgConditionalExp ( const SgConditionalExpStorageClass& storageSource )   : SgExpression (storageSource)
  189187             :    {
  189188             : 
  189189             : 
  189190             : /* #line 189191 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  189191             : 
  189192          71 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  189193          71 :      p_conditional_exp =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_conditional_exp) );
  189194          71 :      p_true_exp =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_true_exp) );
  189195          71 :      p_false_exp =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_false_exp) );
  189196          71 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  189197             : 
  189198             : 
  189199             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  189200             : 
  189201             : 
  189202          71 :    }
  189203             : 
  189204             : //############################################################################
  189205             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  189206             :  * within the working AST. 
  189207             :  */
  189208         497 : SgConditionalExp * SgConditionalExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  189209         497 :      SgConditionalExp* returnPointer = NULL;
  189210         497 :      if ( globalIndex != 0 )
  189211             :         {
  189212             : 
  189213             : #if FILE_IO_EXTRA_CHECK
  189214         497 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgConditionalExp ) ) <= globalIndex ) ;
  189215         497 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConditionalExp + 1 ) ) );
  189216             : #endif
  189217         497 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConditionalExp )  
  189218         497 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgConditionalExp );
  189219         497 :           unsigned long positionInPool = localIndex % SgConditionalExp::pool_size;
  189220         497 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConditionalExp::pool_size;
  189221             : 
  189222             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  189223             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  189224             : 
  189225         497 :           returnPointer = &( ( (SgConditionalExp*)(SgConditionalExp::pools[memoryBlock]) ) [positionInPool]) ;
  189226             : 
  189227         497 :           ROSE_ASSERT( returnPointer != NULL ) ;
  189228             :         }
  189229         497 :      return returnPointer ;
  189230             :    }
  189231             : 
  189232             : //############################################################################
  189233             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  189234             :   for the AST with the index astIndex
  189235             : */
  189236           0 : SgConditionalExp * SgConditionalExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  189237           0 :      SgConditionalExp* returnPointer = NULL;
  189238           0 :      if ( globalIndex != 0 )
  189239             :         {
  189240             : 
  189241             : #if FILE_IO_EXTRA_CHECK
  189242           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgConditionalExp ) ) <= globalIndex ) ;
  189243           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConditionalExp + 1 ) ) );
  189244             : #endif
  189245           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConditionalExp )
  189246           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgConditionalExp );
  189247           0 :           unsigned long positionInPool = localIndex % SgConditionalExp::pool_size ;
  189248           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConditionalExp::pool_size ;
  189249             : 
  189250             : #if FILE_IO_EXTRA_CHECK
  189251             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  189252             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  189253             : #endif
  189254             : 
  189255           0 :           returnPointer = &( ( (SgConditionalExp*)(SgConditionalExp::pools[memoryBlock]) ) [positionInPool]) ;
  189256             : 
  189257             : #if FILE_IO_EXTRA_CHECK
  189258           0 :           assert ( returnPointer != NULL ) ;
  189259             : #endif
  189260             :         }
  189261           0 :      return returnPointer ;
  189262             :    }
  189263             : 
  189264             : //############################################################################
  189265             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  189266             :  * pool size! We set for every valid object in the memory pool the freepointer
  189267             :  * to the global index and increase the global index afterwards. For all the 
  189268             :  * invalid objects (means address ranges within the memory pool that were not
  189269             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  189270             :  * distinguish valid from invalid objects! 
  189271             :  */
  189272             : unsigned long
  189273           5 : SgConditionalExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  189274             :    {
  189275           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  189276           5 :      SgConditionalExp* pointer = NULL;
  189277           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  189278           5 :      std::vector < unsigned char* > :: const_iterator block;
  189279           6 :      for ( block = SgConditionalExp::pools.begin(); block != SgConditionalExp::pools.end() ; ++block )
  189280             :         {
  189281           1 :           pointer = (SgConditionalExp*)(*block);
  189282        2001 :           for (unsigned i = 0; i < SgConditionalExp::pool_size; ++i )
  189283             :              {
  189284             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  189285             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  189286             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  189287             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  189288             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  189289             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  189290             :             // properly; so this will have to be checked next.
  189291             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  189292             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  189293        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  189294             :                   {
  189295          71 :                     pointer[i].set_freepointer((SgConditionalExp*)(globalIndex));
  189296          71 :                     globalIndex++;
  189297             :                   }
  189298             :                else
  189299             :                   {
  189300        1929 :                     pointer[i].set_freepointer(NULL);
  189301             :                   }
  189302             :               }
  189303             :         }
  189304           5 :      return globalIndex;
  189305             :    }
  189306             : 
  189307             : //############################################################################
  189308             : // JH (01/14/2006)
  189309             : void
  189310           5 : SgConditionalExp::resetValidFreepointers( )
  189311             :    {
  189312           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  189313           5 :      SgConditionalExp* pointer = NULL;
  189314           5 :      std::vector < unsigned char* > :: const_iterator block;
  189315           5 :      SgConditionalExp* pointerOfLinkedList = NULL;
  189316           6 :      for ( block = SgConditionalExp::pools.begin(); block != SgConditionalExp::pools.end() ; ++block )
  189317             :         {
  189318           1 :           pointer = (SgConditionalExp*)(*block);
  189319        2001 :           for (unsigned i = 0; i < SgConditionalExp::pool_size; ++i )
  189320             :              {
  189321             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  189322             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  189323             :             // memory blocks!.
  189324        2000 :                if ( pointer[i].get_freepointer() != NULL )
  189325             :                   {
  189326          71 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  189327             :                   }
  189328             :                else
  189329             :                   {
  189330        1929 :                     if ( pointerOfLinkedList == NULL )
  189331             :                        {
  189332           1 :                          SgConditionalExp::next_node = &(pointer[i]);
  189333             :                        }
  189334             :                     else
  189335             :                        {
  189336             :                       // printf ("In SgConditionalExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  189337        1928 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  189338             :                        }
  189339             :                     pointerOfLinkedList = &(pointer[i]);
  189340             :                   }
  189341             :               }
  189342             :         }
  189343             : 
  189344           5 :      if ( pointerOfLinkedList != NULL )
  189345             :         {
  189346             :        // printf ("In SgConditionalExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  189347           1 :           pointerOfLinkedList->set_freepointer(NULL);
  189348             :        // DQ (6/6/2010): Temporary debugging...
  189349             :        //   ROSE_ASSERT(false);
  189350             :         }
  189351             : 
  189352           5 :      return ;
  189353             :    }
  189354             : 
  189355             : //############################################################################
  189356             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  189357             :  * within the memory pool and resets the freepointers, in order to achieve a 
  189358             :  * linked list, that has no jumps and starts at the beginning! This function 
  189359             :  * does not extend the memory pool, since we do not delete any memory blocks,
  189360             :  * but delete the valid objects.  
  189361             :  */
  189362             : void
  189363           0 : SgConditionalExp::clearMemoryPool( )
  189364             :    {
  189365             :   // printf ("Inside of SgConditionalExp::clearMemoryPool() \n");
  189366             : 
  189367           0 :      SgConditionalExp* pointer = NULL, *tempPointer = NULL;
  189368           0 :      std::vector < unsigned char* > :: const_iterator block;
  189369           0 :      if ( SgConditionalExp::pools.empty() == false )
  189370             :         {
  189371           0 :           block = SgConditionalExp::pools.begin() ;
  189372           0 :           SgConditionalExp::next_node = (SgConditionalExp*) (*block);
  189373             : 
  189374           0 :           while ( block != SgConditionalExp::pools.end() )
  189375             :              {
  189376           0 :                pointer = (SgConditionalExp*) (*block);
  189377           0 :                if ( tempPointer != NULL )
  189378             :                   {
  189379           0 :                     tempPointer->set_freepointer(pointer);
  189380             :                   }
  189381           0 :                for (unsigned i = 0; i < SgConditionalExp::pool_size - 1; ++i)
  189382             :                   {
  189383           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  189384             :                   }
  189385           0 :                 pointer[SgConditionalExp::pool_size-1].set_freepointer(NULL);
  189386           0 :                 tempPointer = &(pointer[SgConditionalExp::pool_size-1]);
  189387           0 :                 ++block;
  189388             :              }
  189389             :         }
  189390           0 :    }
  189391             : 
  189392           5 : void SgConditionalExp::deleteMemoryPool() {
  189393           7 :   for (auto p: SgConditionalExp::pools) {
  189394           2 :     ROSE_FREE(p);
  189395             :   }
  189396           5 :   SgConditionalExp::next_node = nullptr;
  189397           5 :   SgConditionalExp::pools.clear();
  189398           5 : }
  189399             : 
  189400             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  189401             : //                 reading multiple binary files to for a single AST.
  189402             : /////////// new version ////////////////////////////////
  189403             : //############################################################################
  189404             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  189405             : void
  189406           2 : SgConditionalExp::extendMemoryPoolForFileIO( )
  189407             :   {
  189408           2 :     size_t blockIndex = SgConditionalExp::pools.size();
  189409           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgConditionalExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgConditionalExp);
  189410             : 
  189411           3 :     while ( (blockIndex * SgConditionalExp::pool_size) < newPoolSize)
  189412             :       {
  189413             : #if ROSE_ALLOC_TRACE
  189414             :         if (blockIndex > 0) {
  189415             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgConditionalExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgConditionalExp) = %" PRIuPTR " SgConditionalExp::pool_size = %d \n",
  189416             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgConditionalExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgConditionalExp),SgConditionalExp::pool_size);
  189417             :         }
  189418             : #endif
  189419             : 
  189420           1 :         SgConditionalExp * pointer = (SgConditionalExp*) ROSE_MALLOC ( SgConditionalExp::pool_size * sizeof(SgConditionalExp) );
  189421           1 :         assert( pointer != NULL );
  189422             : #if ROSE_ALLOC_MEMSET == 1
  189423             :         memset(pointer, 0x00, SgConditionalExp::pool_size * sizeof(SgConditionalExp));
  189424             : #elif ROSE_ALLOC_MEMSET == 2
  189425             :         memset(pointer, 0xCC, SgConditionalExp::pool_size * sizeof(SgConditionalExp));
  189426             : #endif
  189427           1 :         SgConditionalExp::pools.push_back( (unsigned char*)(pointer) );
  189428           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgConditionalExp::pool_size * sizeof(SgConditionalExp), V_SgConditionalExp ) );
  189429             : 
  189430           1 :         if ( SgConditionalExp::next_node != NULL ) {
  189431           0 :           if ( blockIndex > 0 ) {
  189432           0 :             SgConditionalExp * blkptr = (SgConditionalExp*)(SgConditionalExp::pools[blockIndex-1]);
  189433           0 :             blkptr[ SgConditionalExp::pool_size - 1 ].set_freepointer(pointer);
  189434             :           }
  189435             :         } else {
  189436           1 :           SgConditionalExp::next_node = pointer;
  189437             :         }
  189438             : 
  189439        2000 :         for (unsigned i = 0; i < SgConditionalExp::pool_size-1; ++i)
  189440             :            {
  189441        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  189442             :            }
  189443           1 :         pointer[ SgConditionalExp::pool_size -1 ].set_freepointer(NULL);
  189444             : 
  189445           1 :         blockIndex++;
  189446             :       }
  189447           2 :   }
  189448             : 
  189449             : //############################################################################
  189450             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  189451             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  189452             :  * not compressed. However, that stuff is not yet implemented! 
  189453             :  */
  189454             : unsigned long
  189455           0 : SgConditionalExp::getNumberOfLastValidPointer()
  189456             :    {
  189457           0 :       SgConditionalExp* testPointer = (SgConditionalExp*)(SgConditionalExp::pools.back());
  189458           0 :       unsigned long localIndex = SgConditionalExp::pool_size - 1;
  189459           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  189460             :          {
  189461           0 :            localIndex--;
  189462             :          }
  189463           0 :       return (localIndex + SgConditionalExp::pool_size * (SgConditionalExp::pools.size()-1));
  189464             :    }
  189465             : 
  189466             : //############################################################################
  189467             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  189468             :  * memory pool and initializes the data member in class SgConditionalExpStroageClass
  189469             :  * from its counterpart of SgConditionalExp. The return value is just for checking, 
  189470             :  * that the whole StorageClassArray is initialized!
  189471             :  */
  189472             : unsigned long
  189473           1 : SgConditionalExp::initializeStorageClassArray( SgConditionalExpStorageClass *storageArray )
  189474             :    {
  189475           1 :      unsigned long storageCounter = 0;
  189476           1 :      std::vector < unsigned char* > :: const_iterator block = SgConditionalExp::pools.begin();
  189477           1 :      SgConditionalExp* pointer = NULL;
  189478           2 :      while ( block != SgConditionalExp::pools.end() ) {
  189479           1 :           pointer = (SgConditionalExp*) (*block);
  189480        2001 :           for ( unsigned i = 0; i < SgConditionalExp::pool_size; ++i ) {
  189481        2000 :                if ( pointer->get_freepointer() != NULL ) {
  189482          71 :                  storageArray->pickOutIRNodeData (pointer) ;
  189483          71 :                  storageArray++;
  189484          71 :                  storageCounter++;
  189485             :                }
  189486        2000 :                pointer++;
  189487             :              }
  189488           1 :            block++;
  189489             :         }
  189490           1 :      return storageCounter;
  189491             :    }
  189492             : 
  189493             : /* #line 189494 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  189494             : 
  189495             : 
  189496             : 
  189497             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  189498             : 
  189499             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  189500             : 
  189501             : //############################################################################
  189502             : /* JH (02/02/2006) Constructor of the IR node SgNewExp that takes its 
  189503             :  * corresponding StorageClass as parameter
  189504             :  */
  189505          14 : SgNewExp :: SgNewExp ( const SgNewExpStorageClass& storageSource )   : SgExpression (storageSource)
  189506             :    {
  189507             : 
  189508             : 
  189509             : /* #line 189510 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  189510             : 
  189511          14 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  189512          14 :      p_specified_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_specified_type) );
  189513          14 :      p_placement_args =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_placement_args) );
  189514          14 :      p_constructor_args =  (SgConstructorInitializer*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_constructor_args) );
  189515          14 :      p_builtin_args =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_builtin_args) );
  189516          14 :      p_need_global_specifier = storageSource.storageOf_need_global_specifier ;
  189517          14 :      p_newOperatorDeclaration =  (SgFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_newOperatorDeclaration) );
  189518          14 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  189519          14 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  189520          14 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  189521          14 :      p_name_qualification_for_pointer_to_member_class_length = storageSource.storageOf_name_qualification_for_pointer_to_member_class_length ;
  189522          14 :      p_type_elaboration_for_pointer_to_member_class_required = storageSource.storageOf_type_elaboration_for_pointer_to_member_class_required ;
  189523          14 :      p_global_qualification_for_pointer_to_member_class_required = storageSource.storageOf_global_qualification_for_pointer_to_member_class_required ;
  189524             : 
  189525             : 
  189526             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  189527             : 
  189528             : 
  189529          14 :    }
  189530             : 
  189531             : //############################################################################
  189532             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  189533             :  * within the working AST. 
  189534             :  */
  189535          74 : SgNewExp * SgNewExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  189536          74 :      SgNewExp* returnPointer = NULL;
  189537          74 :      if ( globalIndex != 0 )
  189538             :         {
  189539             : 
  189540             : #if FILE_IO_EXTRA_CHECK
  189541          74 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNewExp ) ) <= globalIndex ) ;
  189542          74 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNewExp + 1 ) ) );
  189543             : #endif
  189544          74 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNewExp )  
  189545          74 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNewExp );
  189546          74 :           unsigned long positionInPool = localIndex % SgNewExp::pool_size;
  189547          74 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNewExp::pool_size;
  189548             : 
  189549             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  189550             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  189551             : 
  189552          74 :           returnPointer = &( ( (SgNewExp*)(SgNewExp::pools[memoryBlock]) ) [positionInPool]) ;
  189553             : 
  189554          74 :           ROSE_ASSERT( returnPointer != NULL ) ;
  189555             :         }
  189556          74 :      return returnPointer ;
  189557             :    }
  189558             : 
  189559             : //############################################################################
  189560             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  189561             :   for the AST with the index astIndex
  189562             : */
  189563           0 : SgNewExp * SgNewExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  189564           0 :      SgNewExp* returnPointer = NULL;
  189565           0 :      if ( globalIndex != 0 )
  189566             :         {
  189567             : 
  189568             : #if FILE_IO_EXTRA_CHECK
  189569           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNewExp ) ) <= globalIndex ) ;
  189570           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNewExp + 1 ) ) );
  189571             : #endif
  189572           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNewExp )
  189573           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNewExp );
  189574           0 :           unsigned long positionInPool = localIndex % SgNewExp::pool_size ;
  189575           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNewExp::pool_size ;
  189576             : 
  189577             : #if FILE_IO_EXTRA_CHECK
  189578             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  189579             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  189580             : #endif
  189581             : 
  189582           0 :           returnPointer = &( ( (SgNewExp*)(SgNewExp::pools[memoryBlock]) ) [positionInPool]) ;
  189583             : 
  189584             : #if FILE_IO_EXTRA_CHECK
  189585           0 :           assert ( returnPointer != NULL ) ;
  189586             : #endif
  189587             :         }
  189588           0 :      return returnPointer ;
  189589             :    }
  189590             : 
  189591             : //############################################################################
  189592             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  189593             :  * pool size! We set for every valid object in the memory pool the freepointer
  189594             :  * to the global index and increase the global index afterwards. For all the 
  189595             :  * invalid objects (means address ranges within the memory pool that were not
  189596             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  189597             :  * distinguish valid from invalid objects! 
  189598             :  */
  189599             : unsigned long
  189600           5 : SgNewExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  189601             :    {
  189602           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  189603           5 :      SgNewExp* pointer = NULL;
  189604           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  189605           5 :      std::vector < unsigned char* > :: const_iterator block;
  189606           6 :      for ( block = SgNewExp::pools.begin(); block != SgNewExp::pools.end() ; ++block )
  189607             :         {
  189608           1 :           pointer = (SgNewExp*)(*block);
  189609        2001 :           for (unsigned i = 0; i < SgNewExp::pool_size; ++i )
  189610             :              {
  189611             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  189612             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  189613             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  189614             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  189615             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  189616             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  189617             :             // properly; so this will have to be checked next.
  189618             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  189619             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  189620        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  189621             :                   {
  189622          14 :                     pointer[i].set_freepointer((SgNewExp*)(globalIndex));
  189623          14 :                     globalIndex++;
  189624             :                   }
  189625             :                else
  189626             :                   {
  189627        1986 :                     pointer[i].set_freepointer(NULL);
  189628             :                   }
  189629             :               }
  189630             :         }
  189631           5 :      return globalIndex;
  189632             :    }
  189633             : 
  189634             : //############################################################################
  189635             : // JH (01/14/2006)
  189636             : void
  189637           5 : SgNewExp::resetValidFreepointers( )
  189638             :    {
  189639           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  189640           5 :      SgNewExp* pointer = NULL;
  189641           5 :      std::vector < unsigned char* > :: const_iterator block;
  189642           5 :      SgNewExp* pointerOfLinkedList = NULL;
  189643           6 :      for ( block = SgNewExp::pools.begin(); block != SgNewExp::pools.end() ; ++block )
  189644             :         {
  189645           1 :           pointer = (SgNewExp*)(*block);
  189646        2001 :           for (unsigned i = 0; i < SgNewExp::pool_size; ++i )
  189647             :              {
  189648             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  189649             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  189650             :             // memory blocks!.
  189651        2000 :                if ( pointer[i].get_freepointer() != NULL )
  189652             :                   {
  189653          14 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  189654             :                   }
  189655             :                else
  189656             :                   {
  189657        1986 :                     if ( pointerOfLinkedList == NULL )
  189658             :                        {
  189659           1 :                          SgNewExp::next_node = &(pointer[i]);
  189660             :                        }
  189661             :                     else
  189662             :                        {
  189663             :                       // printf ("In SgNewExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  189664        1985 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  189665             :                        }
  189666             :                     pointerOfLinkedList = &(pointer[i]);
  189667             :                   }
  189668             :               }
  189669             :         }
  189670             : 
  189671           5 :      if ( pointerOfLinkedList != NULL )
  189672             :         {
  189673             :        // printf ("In SgNewExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  189674           1 :           pointerOfLinkedList->set_freepointer(NULL);
  189675             :        // DQ (6/6/2010): Temporary debugging...
  189676             :        //   ROSE_ASSERT(false);
  189677             :         }
  189678             : 
  189679           5 :      return ;
  189680             :    }
  189681             : 
  189682             : //############################################################################
  189683             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  189684             :  * within the memory pool and resets the freepointers, in order to achieve a 
  189685             :  * linked list, that has no jumps and starts at the beginning! This function 
  189686             :  * does not extend the memory pool, since we do not delete any memory blocks,
  189687             :  * but delete the valid objects.  
  189688             :  */
  189689             : void
  189690           0 : SgNewExp::clearMemoryPool( )
  189691             :    {
  189692             :   // printf ("Inside of SgNewExp::clearMemoryPool() \n");
  189693             : 
  189694           0 :      SgNewExp* pointer = NULL, *tempPointer = NULL;
  189695           0 :      std::vector < unsigned char* > :: const_iterator block;
  189696           0 :      if ( SgNewExp::pools.empty() == false )
  189697             :         {
  189698           0 :           block = SgNewExp::pools.begin() ;
  189699           0 :           SgNewExp::next_node = (SgNewExp*) (*block);
  189700             : 
  189701           0 :           while ( block != SgNewExp::pools.end() )
  189702             :              {
  189703           0 :                pointer = (SgNewExp*) (*block);
  189704           0 :                if ( tempPointer != NULL )
  189705             :                   {
  189706           0 :                     tempPointer->set_freepointer(pointer);
  189707             :                   }
  189708           0 :                for (unsigned i = 0; i < SgNewExp::pool_size - 1; ++i)
  189709             :                   {
  189710           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  189711             :                   }
  189712           0 :                 pointer[SgNewExp::pool_size-1].set_freepointer(NULL);
  189713           0 :                 tempPointer = &(pointer[SgNewExp::pool_size-1]);
  189714           0 :                 ++block;
  189715             :              }
  189716             :         }
  189717           0 :    }
  189718             : 
  189719           5 : void SgNewExp::deleteMemoryPool() {
  189720           7 :   for (auto p: SgNewExp::pools) {
  189721           2 :     ROSE_FREE(p);
  189722             :   }
  189723           5 :   SgNewExp::next_node = nullptr;
  189724           5 :   SgNewExp::pools.clear();
  189725           5 : }
  189726             : 
  189727             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  189728             : //                 reading multiple binary files to for a single AST.
  189729             : /////////// new version ////////////////////////////////
  189730             : //############################################################################
  189731             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  189732             : void
  189733           2 : SgNewExp::extendMemoryPoolForFileIO( )
  189734             :   {
  189735           2 :     size_t blockIndex = SgNewExp::pools.size();
  189736           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNewExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNewExp);
  189737             : 
  189738           3 :     while ( (blockIndex * SgNewExp::pool_size) < newPoolSize)
  189739             :       {
  189740             : #if ROSE_ALLOC_TRACE
  189741             :         if (blockIndex > 0) {
  189742             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNewExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNewExp) = %" PRIuPTR " SgNewExp::pool_size = %d \n",
  189743             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNewExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNewExp),SgNewExp::pool_size);
  189744             :         }
  189745             : #endif
  189746             : 
  189747           1 :         SgNewExp * pointer = (SgNewExp*) ROSE_MALLOC ( SgNewExp::pool_size * sizeof(SgNewExp) );
  189748           1 :         assert( pointer != NULL );
  189749             : #if ROSE_ALLOC_MEMSET == 1
  189750             :         memset(pointer, 0x00, SgNewExp::pool_size * sizeof(SgNewExp));
  189751             : #elif ROSE_ALLOC_MEMSET == 2
  189752             :         memset(pointer, 0xCC, SgNewExp::pool_size * sizeof(SgNewExp));
  189753             : #endif
  189754           1 :         SgNewExp::pools.push_back( (unsigned char*)(pointer) );
  189755           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNewExp::pool_size * sizeof(SgNewExp), V_SgNewExp ) );
  189756             : 
  189757           1 :         if ( SgNewExp::next_node != NULL ) {
  189758           0 :           if ( blockIndex > 0 ) {
  189759           0 :             SgNewExp * blkptr = (SgNewExp*)(SgNewExp::pools[blockIndex-1]);
  189760           0 :             blkptr[ SgNewExp::pool_size - 1 ].set_freepointer(pointer);
  189761             :           }
  189762             :         } else {
  189763           1 :           SgNewExp::next_node = pointer;
  189764             :         }
  189765             : 
  189766        2000 :         for (unsigned i = 0; i < SgNewExp::pool_size-1; ++i)
  189767             :            {
  189768        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  189769             :            }
  189770           1 :         pointer[ SgNewExp::pool_size -1 ].set_freepointer(NULL);
  189771             : 
  189772           1 :         blockIndex++;
  189773             :       }
  189774           2 :   }
  189775             : 
  189776             : //############################################################################
  189777             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  189778             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  189779             :  * not compressed. However, that stuff is not yet implemented! 
  189780             :  */
  189781             : unsigned long
  189782           0 : SgNewExp::getNumberOfLastValidPointer()
  189783             :    {
  189784           0 :       SgNewExp* testPointer = (SgNewExp*)(SgNewExp::pools.back());
  189785           0 :       unsigned long localIndex = SgNewExp::pool_size - 1;
  189786           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  189787             :          {
  189788           0 :            localIndex--;
  189789             :          }
  189790           0 :       return (localIndex + SgNewExp::pool_size * (SgNewExp::pools.size()-1));
  189791             :    }
  189792             : 
  189793             : //############################################################################
  189794             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  189795             :  * memory pool and initializes the data member in class SgNewExpStroageClass
  189796             :  * from its counterpart of SgNewExp. The return value is just for checking, 
  189797             :  * that the whole StorageClassArray is initialized!
  189798             :  */
  189799             : unsigned long
  189800           1 : SgNewExp::initializeStorageClassArray( SgNewExpStorageClass *storageArray )
  189801             :    {
  189802           1 :      unsigned long storageCounter = 0;
  189803           1 :      std::vector < unsigned char* > :: const_iterator block = SgNewExp::pools.begin();
  189804           1 :      SgNewExp* pointer = NULL;
  189805           2 :      while ( block != SgNewExp::pools.end() ) {
  189806           1 :           pointer = (SgNewExp*) (*block);
  189807        2001 :           for ( unsigned i = 0; i < SgNewExp::pool_size; ++i ) {
  189808        2000 :                if ( pointer->get_freepointer() != NULL ) {
  189809          14 :                  storageArray->pickOutIRNodeData (pointer) ;
  189810          14 :                  storageArray++;
  189811          14 :                  storageCounter++;
  189812             :                }
  189813        2000 :                pointer++;
  189814             :              }
  189815           1 :            block++;
  189816             :         }
  189817           1 :      return storageCounter;
  189818             :    }
  189819             : 
  189820             : /* #line 189821 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  189821             : 
  189822             : 
  189823             : 
  189824             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  189825             : 
  189826             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  189827             : 
  189828             : //############################################################################
  189829             : /* JH (02/02/2006) Constructor of the IR node SgDeleteExp that takes its 
  189830             :  * corresponding StorageClass as parameter
  189831             :  */
  189832          15 : SgDeleteExp :: SgDeleteExp ( const SgDeleteExpStorageClass& storageSource )   : SgExpression (storageSource)
  189833             :    {
  189834             : 
  189835             : 
  189836             : /* #line 189837 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  189837             : 
  189838          15 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  189839          15 :      p_variable =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_variable) );
  189840          15 :      p_is_array = storageSource.storageOf_is_array ;
  189841          15 :      p_need_global_specifier = storageSource.storageOf_need_global_specifier ;
  189842          15 :      p_deleteOperatorDeclaration =  (SgFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_deleteOperatorDeclaration) );
  189843             : 
  189844             : 
  189845             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  189846             : 
  189847             : 
  189848          15 :    }
  189849             : 
  189850             : //############################################################################
  189851             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  189852             :  * within the working AST. 
  189853             :  */
  189854          75 : SgDeleteExp * SgDeleteExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  189855          75 :      SgDeleteExp* returnPointer = NULL;
  189856          75 :      if ( globalIndex != 0 )
  189857             :         {
  189858             : 
  189859             : #if FILE_IO_EXTRA_CHECK
  189860          75 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDeleteExp ) ) <= globalIndex ) ;
  189861          75 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeleteExp + 1 ) ) );
  189862             : #endif
  189863          75 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDeleteExp )  
  189864          75 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDeleteExp );
  189865          75 :           unsigned long positionInPool = localIndex % SgDeleteExp::pool_size;
  189866          75 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeleteExp::pool_size;
  189867             : 
  189868             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  189869             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  189870             : 
  189871          75 :           returnPointer = &( ( (SgDeleteExp*)(SgDeleteExp::pools[memoryBlock]) ) [positionInPool]) ;
  189872             : 
  189873          75 :           ROSE_ASSERT( returnPointer != NULL ) ;
  189874             :         }
  189875          75 :      return returnPointer ;
  189876             :    }
  189877             : 
  189878             : //############################################################################
  189879             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  189880             :   for the AST with the index astIndex
  189881             : */
  189882           0 : SgDeleteExp * SgDeleteExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  189883           0 :      SgDeleteExp* returnPointer = NULL;
  189884           0 :      if ( globalIndex != 0 )
  189885             :         {
  189886             : 
  189887             : #if FILE_IO_EXTRA_CHECK
  189888           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDeleteExp ) ) <= globalIndex ) ;
  189889           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeleteExp + 1 ) ) );
  189890             : #endif
  189891           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDeleteExp )
  189892           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDeleteExp );
  189893           0 :           unsigned long positionInPool = localIndex % SgDeleteExp::pool_size ;
  189894           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDeleteExp::pool_size ;
  189895             : 
  189896             : #if FILE_IO_EXTRA_CHECK
  189897             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  189898             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  189899             : #endif
  189900             : 
  189901           0 :           returnPointer = &( ( (SgDeleteExp*)(SgDeleteExp::pools[memoryBlock]) ) [positionInPool]) ;
  189902             : 
  189903             : #if FILE_IO_EXTRA_CHECK
  189904           0 :           assert ( returnPointer != NULL ) ;
  189905             : #endif
  189906             :         }
  189907           0 :      return returnPointer ;
  189908             :    }
  189909             : 
  189910             : //############################################################################
  189911             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  189912             :  * pool size! We set for every valid object in the memory pool the freepointer
  189913             :  * to the global index and increase the global index afterwards. For all the 
  189914             :  * invalid objects (means address ranges within the memory pool that were not
  189915             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  189916             :  * distinguish valid from invalid objects! 
  189917             :  */
  189918             : unsigned long
  189919           5 : SgDeleteExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  189920             :    {
  189921           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  189922           5 :      SgDeleteExp* pointer = NULL;
  189923           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  189924           5 :      std::vector < unsigned char* > :: const_iterator block;
  189925           6 :      for ( block = SgDeleteExp::pools.begin(); block != SgDeleteExp::pools.end() ; ++block )
  189926             :         {
  189927           1 :           pointer = (SgDeleteExp*)(*block);
  189928        2001 :           for (unsigned i = 0; i < SgDeleteExp::pool_size; ++i )
  189929             :              {
  189930             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  189931             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  189932             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  189933             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  189934             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  189935             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  189936             :             // properly; so this will have to be checked next.
  189937             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  189938             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  189939        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  189940             :                   {
  189941          15 :                     pointer[i].set_freepointer((SgDeleteExp*)(globalIndex));
  189942          15 :                     globalIndex++;
  189943             :                   }
  189944             :                else
  189945             :                   {
  189946        1985 :                     pointer[i].set_freepointer(NULL);
  189947             :                   }
  189948             :               }
  189949             :         }
  189950           5 :      return globalIndex;
  189951             :    }
  189952             : 
  189953             : //############################################################################
  189954             : // JH (01/14/2006)
  189955             : void
  189956           5 : SgDeleteExp::resetValidFreepointers( )
  189957             :    {
  189958           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  189959           5 :      SgDeleteExp* pointer = NULL;
  189960           5 :      std::vector < unsigned char* > :: const_iterator block;
  189961           5 :      SgDeleteExp* pointerOfLinkedList = NULL;
  189962           6 :      for ( block = SgDeleteExp::pools.begin(); block != SgDeleteExp::pools.end() ; ++block )
  189963             :         {
  189964           1 :           pointer = (SgDeleteExp*)(*block);
  189965        2001 :           for (unsigned i = 0; i < SgDeleteExp::pool_size; ++i )
  189966             :              {
  189967             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  189968             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  189969             :             // memory blocks!.
  189970        2000 :                if ( pointer[i].get_freepointer() != NULL )
  189971             :                   {
  189972          15 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  189973             :                   }
  189974             :                else
  189975             :                   {
  189976        1985 :                     if ( pointerOfLinkedList == NULL )
  189977             :                        {
  189978           1 :                          SgDeleteExp::next_node = &(pointer[i]);
  189979             :                        }
  189980             :                     else
  189981             :                        {
  189982             :                       // printf ("In SgDeleteExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  189983        1984 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  189984             :                        }
  189985             :                     pointerOfLinkedList = &(pointer[i]);
  189986             :                   }
  189987             :               }
  189988             :         }
  189989             : 
  189990           5 :      if ( pointerOfLinkedList != NULL )
  189991             :         {
  189992             :        // printf ("In SgDeleteExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  189993           1 :           pointerOfLinkedList->set_freepointer(NULL);
  189994             :        // DQ (6/6/2010): Temporary debugging...
  189995             :        //   ROSE_ASSERT(false);
  189996             :         }
  189997             : 
  189998           5 :      return ;
  189999             :    }
  190000             : 
  190001             : //############################################################################
  190002             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  190003             :  * within the memory pool and resets the freepointers, in order to achieve a 
  190004             :  * linked list, that has no jumps and starts at the beginning! This function 
  190005             :  * does not extend the memory pool, since we do not delete any memory blocks,
  190006             :  * but delete the valid objects.  
  190007             :  */
  190008             : void
  190009           0 : SgDeleteExp::clearMemoryPool( )
  190010             :    {
  190011             :   // printf ("Inside of SgDeleteExp::clearMemoryPool() \n");
  190012             : 
  190013           0 :      SgDeleteExp* pointer = NULL, *tempPointer = NULL;
  190014           0 :      std::vector < unsigned char* > :: const_iterator block;
  190015           0 :      if ( SgDeleteExp::pools.empty() == false )
  190016             :         {
  190017           0 :           block = SgDeleteExp::pools.begin() ;
  190018           0 :           SgDeleteExp::next_node = (SgDeleteExp*) (*block);
  190019             : 
  190020           0 :           while ( block != SgDeleteExp::pools.end() )
  190021             :              {
  190022           0 :                pointer = (SgDeleteExp*) (*block);
  190023           0 :                if ( tempPointer != NULL )
  190024             :                   {
  190025           0 :                     tempPointer->set_freepointer(pointer);
  190026             :                   }
  190027           0 :                for (unsigned i = 0; i < SgDeleteExp::pool_size - 1; ++i)
  190028             :                   {
  190029           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  190030             :                   }
  190031           0 :                 pointer[SgDeleteExp::pool_size-1].set_freepointer(NULL);
  190032           0 :                 tempPointer = &(pointer[SgDeleteExp::pool_size-1]);
  190033           0 :                 ++block;
  190034             :              }
  190035             :         }
  190036           0 :    }
  190037             : 
  190038           5 : void SgDeleteExp::deleteMemoryPool() {
  190039           7 :   for (auto p: SgDeleteExp::pools) {
  190040           2 :     ROSE_FREE(p);
  190041             :   }
  190042           5 :   SgDeleteExp::next_node = nullptr;
  190043           5 :   SgDeleteExp::pools.clear();
  190044           5 : }
  190045             : 
  190046             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  190047             : //                 reading multiple binary files to for a single AST.
  190048             : /////////// new version ////////////////////////////////
  190049             : //############################################################################
  190050             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  190051             : void
  190052           2 : SgDeleteExp::extendMemoryPoolForFileIO( )
  190053             :   {
  190054           2 :     size_t blockIndex = SgDeleteExp::pools.size();
  190055           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDeleteExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeleteExp);
  190056             : 
  190057           3 :     while ( (blockIndex * SgDeleteExp::pool_size) < newPoolSize)
  190058             :       {
  190059             : #if ROSE_ALLOC_TRACE
  190060             :         if (blockIndex > 0) {
  190061             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDeleteExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeleteExp) = %" PRIuPTR " SgDeleteExp::pool_size = %d \n",
  190062             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDeleteExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDeleteExp),SgDeleteExp::pool_size);
  190063             :         }
  190064             : #endif
  190065             : 
  190066           1 :         SgDeleteExp * pointer = (SgDeleteExp*) ROSE_MALLOC ( SgDeleteExp::pool_size * sizeof(SgDeleteExp) );
  190067           1 :         assert( pointer != NULL );
  190068             : #if ROSE_ALLOC_MEMSET == 1
  190069             :         memset(pointer, 0x00, SgDeleteExp::pool_size * sizeof(SgDeleteExp));
  190070             : #elif ROSE_ALLOC_MEMSET == 2
  190071             :         memset(pointer, 0xCC, SgDeleteExp::pool_size * sizeof(SgDeleteExp));
  190072             : #endif
  190073           1 :         SgDeleteExp::pools.push_back( (unsigned char*)(pointer) );
  190074           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDeleteExp::pool_size * sizeof(SgDeleteExp), V_SgDeleteExp ) );
  190075             : 
  190076           1 :         if ( SgDeleteExp::next_node != NULL ) {
  190077           0 :           if ( blockIndex > 0 ) {
  190078           0 :             SgDeleteExp * blkptr = (SgDeleteExp*)(SgDeleteExp::pools[blockIndex-1]);
  190079           0 :             blkptr[ SgDeleteExp::pool_size - 1 ].set_freepointer(pointer);
  190080             :           }
  190081             :         } else {
  190082           1 :           SgDeleteExp::next_node = pointer;
  190083             :         }
  190084             : 
  190085        2000 :         for (unsigned i = 0; i < SgDeleteExp::pool_size-1; ++i)
  190086             :            {
  190087        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  190088             :            }
  190089           1 :         pointer[ SgDeleteExp::pool_size -1 ].set_freepointer(NULL);
  190090             : 
  190091           1 :         blockIndex++;
  190092             :       }
  190093           2 :   }
  190094             : 
  190095             : //############################################################################
  190096             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  190097             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  190098             :  * not compressed. However, that stuff is not yet implemented! 
  190099             :  */
  190100             : unsigned long
  190101           0 : SgDeleteExp::getNumberOfLastValidPointer()
  190102             :    {
  190103           0 :       SgDeleteExp* testPointer = (SgDeleteExp*)(SgDeleteExp::pools.back());
  190104           0 :       unsigned long localIndex = SgDeleteExp::pool_size - 1;
  190105           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  190106             :          {
  190107           0 :            localIndex--;
  190108             :          }
  190109           0 :       return (localIndex + SgDeleteExp::pool_size * (SgDeleteExp::pools.size()-1));
  190110             :    }
  190111             : 
  190112             : //############################################################################
  190113             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  190114             :  * memory pool and initializes the data member in class SgDeleteExpStroageClass
  190115             :  * from its counterpart of SgDeleteExp. The return value is just for checking, 
  190116             :  * that the whole StorageClassArray is initialized!
  190117             :  */
  190118             : unsigned long
  190119           1 : SgDeleteExp::initializeStorageClassArray( SgDeleteExpStorageClass *storageArray )
  190120             :    {
  190121           1 :      unsigned long storageCounter = 0;
  190122           1 :      std::vector < unsigned char* > :: const_iterator block = SgDeleteExp::pools.begin();
  190123           1 :      SgDeleteExp* pointer = NULL;
  190124           2 :      while ( block != SgDeleteExp::pools.end() ) {
  190125           1 :           pointer = (SgDeleteExp*) (*block);
  190126        2001 :           for ( unsigned i = 0; i < SgDeleteExp::pool_size; ++i ) {
  190127        2000 :                if ( pointer->get_freepointer() != NULL ) {
  190128          15 :                  storageArray->pickOutIRNodeData (pointer) ;
  190129          15 :                  storageArray++;
  190130          15 :                  storageCounter++;
  190131             :                }
  190132        2000 :                pointer++;
  190133             :              }
  190134           1 :            block++;
  190135             :         }
  190136           1 :      return storageCounter;
  190137             :    }
  190138             : 
  190139             : /* #line 190140 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  190140             : 
  190141             : 
  190142             : 
  190143             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  190144             : 
  190145             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  190146             : 
  190147             : //############################################################################
  190148             : /* JH (02/02/2006) Constructor of the IR node SgThisExp that takes its 
  190149             :  * corresponding StorageClass as parameter
  190150             :  */
  190151        1236 : SgThisExp :: SgThisExp ( const SgThisExpStorageClass& storageSource )   : SgExpression (storageSource)
  190152             :    {
  190153             : 
  190154             : 
  190155             : /* #line 190156 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  190156             : 
  190157        1236 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  190158        1236 :      p_class_symbol =  (SgClassSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_class_symbol) );
  190159        1236 :      p_nonreal_symbol =  (SgNonrealSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_nonreal_symbol) );
  190160        1236 :      p_pobj_this = storageSource.storageOf_pobj_this ;
  190161             : 
  190162             : 
  190163             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  190164             : 
  190165             : 
  190166        1236 :    }
  190167             : 
  190168             : //############################################################################
  190169             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  190170             :  * within the working AST. 
  190171             :  */
  190172        4944 : SgThisExp * SgThisExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  190173        4944 :      SgThisExp* returnPointer = NULL;
  190174        4944 :      if ( globalIndex != 0 )
  190175             :         {
  190176             : 
  190177             : #if FILE_IO_EXTRA_CHECK
  190178        4944 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgThisExp ) ) <= globalIndex ) ;
  190179        4944 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgThisExp + 1 ) ) );
  190180             : #endif
  190181        4944 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgThisExp )  
  190182        4944 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgThisExp );
  190183        4944 :           unsigned long positionInPool = localIndex % SgThisExp::pool_size;
  190184        4944 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgThisExp::pool_size;
  190185             : 
  190186             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  190187             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  190188             : 
  190189        4944 :           returnPointer = &( ( (SgThisExp*)(SgThisExp::pools[memoryBlock]) ) [positionInPool]) ;
  190190             : 
  190191        4944 :           ROSE_ASSERT( returnPointer != NULL ) ;
  190192             :         }
  190193        4944 :      return returnPointer ;
  190194             :    }
  190195             : 
  190196             : //############################################################################
  190197             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  190198             :   for the AST with the index astIndex
  190199             : */
  190200           0 : SgThisExp * SgThisExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  190201           0 :      SgThisExp* returnPointer = NULL;
  190202           0 :      if ( globalIndex != 0 )
  190203             :         {
  190204             : 
  190205             : #if FILE_IO_EXTRA_CHECK
  190206           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgThisExp ) ) <= globalIndex ) ;
  190207           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgThisExp + 1 ) ) );
  190208             : #endif
  190209           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgThisExp )
  190210           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgThisExp );
  190211           0 :           unsigned long positionInPool = localIndex % SgThisExp::pool_size ;
  190212           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgThisExp::pool_size ;
  190213             : 
  190214             : #if FILE_IO_EXTRA_CHECK
  190215             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  190216             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  190217             : #endif
  190218             : 
  190219           0 :           returnPointer = &( ( (SgThisExp*)(SgThisExp::pools[memoryBlock]) ) [positionInPool]) ;
  190220             : 
  190221             : #if FILE_IO_EXTRA_CHECK
  190222           0 :           assert ( returnPointer != NULL ) ;
  190223             : #endif
  190224             :         }
  190225           0 :      return returnPointer ;
  190226             :    }
  190227             : 
  190228             : //############################################################################
  190229             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  190230             :  * pool size! We set for every valid object in the memory pool the freepointer
  190231             :  * to the global index and increase the global index afterwards. For all the 
  190232             :  * invalid objects (means address ranges within the memory pool that were not
  190233             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  190234             :  * distinguish valid from invalid objects! 
  190235             :  */
  190236             : unsigned long
  190237           5 : SgThisExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  190238             :    {
  190239           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  190240           5 :      SgThisExp* pointer = NULL;
  190241           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  190242           5 :      std::vector < unsigned char* > :: const_iterator block;
  190243           6 :      for ( block = SgThisExp::pools.begin(); block != SgThisExp::pools.end() ; ++block )
  190244             :         {
  190245           1 :           pointer = (SgThisExp*)(*block);
  190246        2001 :           for (unsigned i = 0; i < SgThisExp::pool_size; ++i )
  190247             :              {
  190248             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  190249             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  190250             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  190251             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  190252             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  190253             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  190254             :             // properly; so this will have to be checked next.
  190255             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  190256             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  190257        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  190258             :                   {
  190259        1236 :                     pointer[i].set_freepointer((SgThisExp*)(globalIndex));
  190260        1236 :                     globalIndex++;
  190261             :                   }
  190262             :                else
  190263             :                   {
  190264         764 :                     pointer[i].set_freepointer(NULL);
  190265             :                   }
  190266             :               }
  190267             :         }
  190268           5 :      return globalIndex;
  190269             :    }
  190270             : 
  190271             : //############################################################################
  190272             : // JH (01/14/2006)
  190273             : void
  190274           5 : SgThisExp::resetValidFreepointers( )
  190275             :    {
  190276           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  190277           5 :      SgThisExp* pointer = NULL;
  190278           5 :      std::vector < unsigned char* > :: const_iterator block;
  190279           5 :      SgThisExp* pointerOfLinkedList = NULL;
  190280           6 :      for ( block = SgThisExp::pools.begin(); block != SgThisExp::pools.end() ; ++block )
  190281             :         {
  190282           1 :           pointer = (SgThisExp*)(*block);
  190283        2001 :           for (unsigned i = 0; i < SgThisExp::pool_size; ++i )
  190284             :              {
  190285             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  190286             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  190287             :             // memory blocks!.
  190288        2000 :                if ( pointer[i].get_freepointer() != NULL )
  190289             :                   {
  190290        1236 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  190291             :                   }
  190292             :                else
  190293             :                   {
  190294         764 :                     if ( pointerOfLinkedList == NULL )
  190295             :                        {
  190296           1 :                          SgThisExp::next_node = &(pointer[i]);
  190297             :                        }
  190298             :                     else
  190299             :                        {
  190300             :                       // printf ("In SgThisExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  190301         763 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  190302             :                        }
  190303             :                     pointerOfLinkedList = &(pointer[i]);
  190304             :                   }
  190305             :               }
  190306             :         }
  190307             : 
  190308           5 :      if ( pointerOfLinkedList != NULL )
  190309             :         {
  190310             :        // printf ("In SgThisExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  190311           1 :           pointerOfLinkedList->set_freepointer(NULL);
  190312             :        // DQ (6/6/2010): Temporary debugging...
  190313             :        //   ROSE_ASSERT(false);
  190314             :         }
  190315             : 
  190316           5 :      return ;
  190317             :    }
  190318             : 
  190319             : //############################################################################
  190320             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  190321             :  * within the memory pool and resets the freepointers, in order to achieve a 
  190322             :  * linked list, that has no jumps and starts at the beginning! This function 
  190323             :  * does not extend the memory pool, since we do not delete any memory blocks,
  190324             :  * but delete the valid objects.  
  190325             :  */
  190326             : void
  190327           0 : SgThisExp::clearMemoryPool( )
  190328             :    {
  190329             :   // printf ("Inside of SgThisExp::clearMemoryPool() \n");
  190330             : 
  190331           0 :      SgThisExp* pointer = NULL, *tempPointer = NULL;
  190332           0 :      std::vector < unsigned char* > :: const_iterator block;
  190333           0 :      if ( SgThisExp::pools.empty() == false )
  190334             :         {
  190335           0 :           block = SgThisExp::pools.begin() ;
  190336           0 :           SgThisExp::next_node = (SgThisExp*) (*block);
  190337             : 
  190338           0 :           while ( block != SgThisExp::pools.end() )
  190339             :              {
  190340           0 :                pointer = (SgThisExp*) (*block);
  190341           0 :                if ( tempPointer != NULL )
  190342             :                   {
  190343           0 :                     tempPointer->set_freepointer(pointer);
  190344             :                   }
  190345           0 :                for (unsigned i = 0; i < SgThisExp::pool_size - 1; ++i)
  190346             :                   {
  190347           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  190348             :                   }
  190349           0 :                 pointer[SgThisExp::pool_size-1].set_freepointer(NULL);
  190350           0 :                 tempPointer = &(pointer[SgThisExp::pool_size-1]);
  190351           0 :                 ++block;
  190352             :              }
  190353             :         }
  190354           0 :    }
  190355             : 
  190356           5 : void SgThisExp::deleteMemoryPool() {
  190357           7 :   for (auto p: SgThisExp::pools) {
  190358           2 :     ROSE_FREE(p);
  190359             :   }
  190360           5 :   SgThisExp::next_node = nullptr;
  190361           5 :   SgThisExp::pools.clear();
  190362           5 : }
  190363             : 
  190364             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  190365             : //                 reading multiple binary files to for a single AST.
  190366             : /////////// new version ////////////////////////////////
  190367             : //############################################################################
  190368             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  190369             : void
  190370           2 : SgThisExp::extendMemoryPoolForFileIO( )
  190371             :   {
  190372           2 :     size_t blockIndex = SgThisExp::pools.size();
  190373           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgThisExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgThisExp);
  190374             : 
  190375           3 :     while ( (blockIndex * SgThisExp::pool_size) < newPoolSize)
  190376             :       {
  190377             : #if ROSE_ALLOC_TRACE
  190378             :         if (blockIndex > 0) {
  190379             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgThisExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgThisExp) = %" PRIuPTR " SgThisExp::pool_size = %d \n",
  190380             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgThisExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgThisExp),SgThisExp::pool_size);
  190381             :         }
  190382             : #endif
  190383             : 
  190384           1 :         SgThisExp * pointer = (SgThisExp*) ROSE_MALLOC ( SgThisExp::pool_size * sizeof(SgThisExp) );
  190385           1 :         assert( pointer != NULL );
  190386             : #if ROSE_ALLOC_MEMSET == 1
  190387             :         memset(pointer, 0x00, SgThisExp::pool_size * sizeof(SgThisExp));
  190388             : #elif ROSE_ALLOC_MEMSET == 2
  190389             :         memset(pointer, 0xCC, SgThisExp::pool_size * sizeof(SgThisExp));
  190390             : #endif
  190391           1 :         SgThisExp::pools.push_back( (unsigned char*)(pointer) );
  190392           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgThisExp::pool_size * sizeof(SgThisExp), V_SgThisExp ) );
  190393             : 
  190394           1 :         if ( SgThisExp::next_node != NULL ) {
  190395           0 :           if ( blockIndex > 0 ) {
  190396           0 :             SgThisExp * blkptr = (SgThisExp*)(SgThisExp::pools[blockIndex-1]);
  190397           0 :             blkptr[ SgThisExp::pool_size - 1 ].set_freepointer(pointer);
  190398             :           }
  190399             :         } else {
  190400           1 :           SgThisExp::next_node = pointer;
  190401             :         }
  190402             : 
  190403        2000 :         for (unsigned i = 0; i < SgThisExp::pool_size-1; ++i)
  190404             :            {
  190405        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  190406             :            }
  190407           1 :         pointer[ SgThisExp::pool_size -1 ].set_freepointer(NULL);
  190408             : 
  190409           1 :         blockIndex++;
  190410             :       }
  190411           2 :   }
  190412             : 
  190413             : //############################################################################
  190414             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  190415             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  190416             :  * not compressed. However, that stuff is not yet implemented! 
  190417             :  */
  190418             : unsigned long
  190419           0 : SgThisExp::getNumberOfLastValidPointer()
  190420             :    {
  190421           0 :       SgThisExp* testPointer = (SgThisExp*)(SgThisExp::pools.back());
  190422           0 :       unsigned long localIndex = SgThisExp::pool_size - 1;
  190423           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  190424             :          {
  190425           0 :            localIndex--;
  190426             :          }
  190427           0 :       return (localIndex + SgThisExp::pool_size * (SgThisExp::pools.size()-1));
  190428             :    }
  190429             : 
  190430             : //############################################################################
  190431             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  190432             :  * memory pool and initializes the data member in class SgThisExpStroageClass
  190433             :  * from its counterpart of SgThisExp. The return value is just for checking, 
  190434             :  * that the whole StorageClassArray is initialized!
  190435             :  */
  190436             : unsigned long
  190437           1 : SgThisExp::initializeStorageClassArray( SgThisExpStorageClass *storageArray )
  190438             :    {
  190439           1 :      unsigned long storageCounter = 0;
  190440           1 :      std::vector < unsigned char* > :: const_iterator block = SgThisExp::pools.begin();
  190441           1 :      SgThisExp* pointer = NULL;
  190442           2 :      while ( block != SgThisExp::pools.end() ) {
  190443           1 :           pointer = (SgThisExp*) (*block);
  190444        2001 :           for ( unsigned i = 0; i < SgThisExp::pool_size; ++i ) {
  190445        2000 :                if ( pointer->get_freepointer() != NULL ) {
  190446        1236 :                  storageArray->pickOutIRNodeData (pointer) ;
  190447        1236 :                  storageArray++;
  190448        1236 :                  storageCounter++;
  190449             :                }
  190450        2000 :                pointer++;
  190451             :              }
  190452           1 :            block++;
  190453             :         }
  190454           1 :      return storageCounter;
  190455             :    }
  190456             : 
  190457             : /* #line 190458 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  190458             : 
  190459             : 
  190460             : 
  190461             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  190462             : 
  190463             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  190464             : 
  190465             : //############################################################################
  190466             : /* JH (02/02/2006) Constructor of the IR node SgRefExp that takes its 
  190467             :  * corresponding StorageClass as parameter
  190468             :  */
  190469           0 : SgRefExp :: SgRefExp ( const SgRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  190470             :    {
  190471             : 
  190472             : 
  190473             : /* #line 190474 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  190474             : 
  190475           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  190476           0 :      p_type_name =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type_name) );
  190477             : 
  190478             : 
  190479             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  190480             : 
  190481             : 
  190482           0 :    }
  190483             : 
  190484             : //############################################################################
  190485             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  190486             :  * within the working AST. 
  190487             :  */
  190488           0 : SgRefExp * SgRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  190489           0 :      SgRefExp* returnPointer = NULL;
  190490           0 :      if ( globalIndex != 0 )
  190491             :         {
  190492             : 
  190493             : #if FILE_IO_EXTRA_CHECK
  190494           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRefExp ) ) <= globalIndex ) ;
  190495           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRefExp + 1 ) ) );
  190496             : #endif
  190497           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRefExp )  
  190498           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRefExp );
  190499           0 :           unsigned long positionInPool = localIndex % SgRefExp::pool_size;
  190500           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRefExp::pool_size;
  190501             : 
  190502             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  190503             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  190504             : 
  190505           0 :           returnPointer = &( ( (SgRefExp*)(SgRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  190506             : 
  190507           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  190508             :         }
  190509           0 :      return returnPointer ;
  190510             :    }
  190511             : 
  190512             : //############################################################################
  190513             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  190514             :   for the AST with the index astIndex
  190515             : */
  190516           0 : SgRefExp * SgRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  190517           0 :      SgRefExp* returnPointer = NULL;
  190518           0 :      if ( globalIndex != 0 )
  190519             :         {
  190520             : 
  190521             : #if FILE_IO_EXTRA_CHECK
  190522           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRefExp ) ) <= globalIndex ) ;
  190523           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRefExp + 1 ) ) );
  190524             : #endif
  190525           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRefExp )
  190526           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRefExp );
  190527           0 :           unsigned long positionInPool = localIndex % SgRefExp::pool_size ;
  190528           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRefExp::pool_size ;
  190529             : 
  190530             : #if FILE_IO_EXTRA_CHECK
  190531             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  190532             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  190533             : #endif
  190534             : 
  190535           0 :           returnPointer = &( ( (SgRefExp*)(SgRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  190536             : 
  190537             : #if FILE_IO_EXTRA_CHECK
  190538           0 :           assert ( returnPointer != NULL ) ;
  190539             : #endif
  190540             :         }
  190541           0 :      return returnPointer ;
  190542             :    }
  190543             : 
  190544             : //############################################################################
  190545             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  190546             :  * pool size! We set for every valid object in the memory pool the freepointer
  190547             :  * to the global index and increase the global index afterwards. For all the 
  190548             :  * invalid objects (means address ranges within the memory pool that were not
  190549             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  190550             :  * distinguish valid from invalid objects! 
  190551             :  */
  190552             : unsigned long
  190553           5 : SgRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  190554             :    {
  190555           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  190556           5 :      SgRefExp* pointer = NULL;
  190557           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  190558           5 :      std::vector < unsigned char* > :: const_iterator block;
  190559           5 :      for ( block = SgRefExp::pools.begin(); block != SgRefExp::pools.end() ; ++block )
  190560             :         {
  190561           0 :           pointer = (SgRefExp*)(*block);
  190562           0 :           for (unsigned i = 0; i < SgRefExp::pool_size; ++i )
  190563             :              {
  190564             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  190565             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  190566             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  190567             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  190568             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  190569             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  190570             :             // properly; so this will have to be checked next.
  190571             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  190572             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  190573           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  190574             :                   {
  190575           0 :                     pointer[i].set_freepointer((SgRefExp*)(globalIndex));
  190576           0 :                     globalIndex++;
  190577             :                   }
  190578             :                else
  190579             :                   {
  190580           0 :                     pointer[i].set_freepointer(NULL);
  190581             :                   }
  190582             :               }
  190583             :         }
  190584           5 :      return globalIndex;
  190585             :    }
  190586             : 
  190587             : //############################################################################
  190588             : // JH (01/14/2006)
  190589             : void
  190590           5 : SgRefExp::resetValidFreepointers( )
  190591             :    {
  190592           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  190593           5 :      SgRefExp* pointer = NULL;
  190594           5 :      std::vector < unsigned char* > :: const_iterator block;
  190595           5 :      SgRefExp* pointerOfLinkedList = NULL;
  190596           5 :      for ( block = SgRefExp::pools.begin(); block != SgRefExp::pools.end() ; ++block )
  190597             :         {
  190598           0 :           pointer = (SgRefExp*)(*block);
  190599           0 :           for (unsigned i = 0; i < SgRefExp::pool_size; ++i )
  190600             :              {
  190601             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  190602             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  190603             :             // memory blocks!.
  190604           0 :                if ( pointer[i].get_freepointer() != NULL )
  190605             :                   {
  190606           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  190607             :                   }
  190608             :                else
  190609             :                   {
  190610           0 :                     if ( pointerOfLinkedList == NULL )
  190611             :                        {
  190612           0 :                          SgRefExp::next_node = &(pointer[i]);
  190613             :                        }
  190614             :                     else
  190615             :                        {
  190616             :                       // printf ("In SgRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  190617           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  190618             :                        }
  190619             :                     pointerOfLinkedList = &(pointer[i]);
  190620             :                   }
  190621             :               }
  190622             :         }
  190623             : 
  190624           5 :      if ( pointerOfLinkedList != NULL )
  190625             :         {
  190626             :        // printf ("In SgRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  190627           0 :           pointerOfLinkedList->set_freepointer(NULL);
  190628             :        // DQ (6/6/2010): Temporary debugging...
  190629             :        //   ROSE_ASSERT(false);
  190630             :         }
  190631             : 
  190632           5 :      return ;
  190633             :    }
  190634             : 
  190635             : //############################################################################
  190636             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  190637             :  * within the memory pool and resets the freepointers, in order to achieve a 
  190638             :  * linked list, that has no jumps and starts at the beginning! This function 
  190639             :  * does not extend the memory pool, since we do not delete any memory blocks,
  190640             :  * but delete the valid objects.  
  190641             :  */
  190642             : void
  190643           0 : SgRefExp::clearMemoryPool( )
  190644             :    {
  190645             :   // printf ("Inside of SgRefExp::clearMemoryPool() \n");
  190646             : 
  190647           0 :      SgRefExp* pointer = NULL, *tempPointer = NULL;
  190648           0 :      std::vector < unsigned char* > :: const_iterator block;
  190649           0 :      if ( SgRefExp::pools.empty() == false )
  190650             :         {
  190651           0 :           block = SgRefExp::pools.begin() ;
  190652           0 :           SgRefExp::next_node = (SgRefExp*) (*block);
  190653             : 
  190654           0 :           while ( block != SgRefExp::pools.end() )
  190655             :              {
  190656           0 :                pointer = (SgRefExp*) (*block);
  190657           0 :                if ( tempPointer != NULL )
  190658             :                   {
  190659           0 :                     tempPointer->set_freepointer(pointer);
  190660             :                   }
  190661           0 :                for (unsigned i = 0; i < SgRefExp::pool_size - 1; ++i)
  190662             :                   {
  190663           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  190664             :                   }
  190665           0 :                 pointer[SgRefExp::pool_size-1].set_freepointer(NULL);
  190666           0 :                 tempPointer = &(pointer[SgRefExp::pool_size-1]);
  190667           0 :                 ++block;
  190668             :              }
  190669             :         }
  190670           0 :    }
  190671             : 
  190672           5 : void SgRefExp::deleteMemoryPool() {
  190673           5 :   for (auto p: SgRefExp::pools) {
  190674           0 :     ROSE_FREE(p);
  190675             :   }
  190676           5 :   SgRefExp::next_node = nullptr;
  190677           5 :   SgRefExp::pools.clear();
  190678           5 : }
  190679             : 
  190680             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  190681             : //                 reading multiple binary files to for a single AST.
  190682             : /////////// new version ////////////////////////////////
  190683             : //############################################################################
  190684             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  190685             : void
  190686           2 : SgRefExp::extendMemoryPoolForFileIO( )
  190687             :   {
  190688           2 :     size_t blockIndex = SgRefExp::pools.size();
  190689           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRefExp);
  190690             : 
  190691           2 :     while ( (blockIndex * SgRefExp::pool_size) < newPoolSize)
  190692             :       {
  190693             : #if ROSE_ALLOC_TRACE
  190694             :         if (blockIndex > 0) {
  190695             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRefExp) = %" PRIuPTR " SgRefExp::pool_size = %d \n",
  190696             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRefExp),SgRefExp::pool_size);
  190697             :         }
  190698             : #endif
  190699             : 
  190700           0 :         SgRefExp * pointer = (SgRefExp*) ROSE_MALLOC ( SgRefExp::pool_size * sizeof(SgRefExp) );
  190701           0 :         assert( pointer != NULL );
  190702             : #if ROSE_ALLOC_MEMSET == 1
  190703             :         memset(pointer, 0x00, SgRefExp::pool_size * sizeof(SgRefExp));
  190704             : #elif ROSE_ALLOC_MEMSET == 2
  190705             :         memset(pointer, 0xCC, SgRefExp::pool_size * sizeof(SgRefExp));
  190706             : #endif
  190707           0 :         SgRefExp::pools.push_back( (unsigned char*)(pointer) );
  190708           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRefExp::pool_size * sizeof(SgRefExp), V_SgRefExp ) );
  190709             : 
  190710           0 :         if ( SgRefExp::next_node != NULL ) {
  190711           0 :           if ( blockIndex > 0 ) {
  190712           0 :             SgRefExp * blkptr = (SgRefExp*)(SgRefExp::pools[blockIndex-1]);
  190713           0 :             blkptr[ SgRefExp::pool_size - 1 ].set_freepointer(pointer);
  190714             :           }
  190715             :         } else {
  190716           0 :           SgRefExp::next_node = pointer;
  190717             :         }
  190718             : 
  190719           0 :         for (unsigned i = 0; i < SgRefExp::pool_size-1; ++i)
  190720             :            {
  190721           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  190722             :            }
  190723           0 :         pointer[ SgRefExp::pool_size -1 ].set_freepointer(NULL);
  190724             : 
  190725           0 :         blockIndex++;
  190726             :       }
  190727           2 :   }
  190728             : 
  190729             : //############################################################################
  190730             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  190731             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  190732             :  * not compressed. However, that stuff is not yet implemented! 
  190733             :  */
  190734             : unsigned long
  190735           0 : SgRefExp::getNumberOfLastValidPointer()
  190736             :    {
  190737           0 :       SgRefExp* testPointer = (SgRefExp*)(SgRefExp::pools.back());
  190738           0 :       unsigned long localIndex = SgRefExp::pool_size - 1;
  190739           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  190740             :          {
  190741           0 :            localIndex--;
  190742             :          }
  190743           0 :       return (localIndex + SgRefExp::pool_size * (SgRefExp::pools.size()-1));
  190744             :    }
  190745             : 
  190746             : //############################################################################
  190747             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  190748             :  * memory pool and initializes the data member in class SgRefExpStroageClass
  190749             :  * from its counterpart of SgRefExp. The return value is just for checking, 
  190750             :  * that the whole StorageClassArray is initialized!
  190751             :  */
  190752             : unsigned long
  190753           0 : SgRefExp::initializeStorageClassArray( SgRefExpStorageClass *storageArray )
  190754             :    {
  190755           0 :      unsigned long storageCounter = 0;
  190756           0 :      std::vector < unsigned char* > :: const_iterator block = SgRefExp::pools.begin();
  190757           0 :      SgRefExp* pointer = NULL;
  190758           0 :      while ( block != SgRefExp::pools.end() ) {
  190759           0 :           pointer = (SgRefExp*) (*block);
  190760           0 :           for ( unsigned i = 0; i < SgRefExp::pool_size; ++i ) {
  190761           0 :                if ( pointer->get_freepointer() != NULL ) {
  190762           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  190763           0 :                  storageArray++;
  190764           0 :                  storageCounter++;
  190765             :                }
  190766           0 :                pointer++;
  190767             :              }
  190768           0 :            block++;
  190769             :         }
  190770           0 :      return storageCounter;
  190771             :    }
  190772             : 
  190773             : /* #line 190774 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  190774             : 
  190775             : 
  190776             : 
  190777             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  190778             : 
  190779             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  190780             : 
  190781             : //############################################################################
  190782             : /* JH (02/02/2006) Constructor of the IR node SgInitializer that takes its 
  190783             :  * corresponding StorageClass as parameter
  190784             :  */
  190785        1658 : SgInitializer :: SgInitializer ( const SgInitializerStorageClass& storageSource )   : SgExpression (storageSource)
  190786             :    {
  190787             : 
  190788             : 
  190789             : /* #line 190790 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  190790             : 
  190791        1658 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  190792        1658 :      p_is_explicit_cast = storageSource.storageOf_is_explicit_cast ;
  190793        1658 :      p_is_braced_initialized = storageSource.storageOf_is_braced_initialized ;
  190794             : 
  190795             : 
  190796             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  190797             : 
  190798             : 
  190799        1658 :    }
  190800             : 
  190801             : //############################################################################
  190802             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  190803             :  * within the working AST. 
  190804             :  */
  190805           0 : SgInitializer * SgInitializer::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  190806           0 :      SgInitializer* returnPointer = NULL;
  190807           0 :      if ( globalIndex != 0 )
  190808             :         {
  190809             : 
  190810             : #if FILE_IO_EXTRA_CHECK
  190811           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgInitializer ) ) <= globalIndex ) ;
  190812           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInitializer + 1 ) ) );
  190813             : #endif
  190814           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInitializer )  
  190815           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgInitializer );
  190816           0 :           unsigned long positionInPool = localIndex % SgInitializer::pool_size;
  190817           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInitializer::pool_size;
  190818             : 
  190819             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  190820             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  190821             : 
  190822           0 :           returnPointer = &( ( (SgInitializer*)(SgInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  190823             : 
  190824           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  190825             :         }
  190826           0 :      return returnPointer ;
  190827             :    }
  190828             : 
  190829             : //############################################################################
  190830             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  190831             :   for the AST with the index astIndex
  190832             : */
  190833           0 : SgInitializer * SgInitializer::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  190834           0 :      SgInitializer* returnPointer = NULL;
  190835           0 :      if ( globalIndex != 0 )
  190836             :         {
  190837             : 
  190838             : #if FILE_IO_EXTRA_CHECK
  190839           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgInitializer ) ) <= globalIndex ) ;
  190840           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInitializer + 1 ) ) );
  190841             : #endif
  190842           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInitializer )
  190843           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgInitializer );
  190844           0 :           unsigned long positionInPool = localIndex % SgInitializer::pool_size ;
  190845           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInitializer::pool_size ;
  190846             : 
  190847             : #if FILE_IO_EXTRA_CHECK
  190848             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  190849             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  190850             : #endif
  190851             : 
  190852           0 :           returnPointer = &( ( (SgInitializer*)(SgInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  190853             : 
  190854             : #if FILE_IO_EXTRA_CHECK
  190855           0 :           assert ( returnPointer != NULL ) ;
  190856             : #endif
  190857             :         }
  190858           0 :      return returnPointer ;
  190859             :    }
  190860             : 
  190861             : //############################################################################
  190862             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  190863             :  * pool size! We set for every valid object in the memory pool the freepointer
  190864             :  * to the global index and increase the global index afterwards. For all the 
  190865             :  * invalid objects (means address ranges within the memory pool that were not
  190866             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  190867             :  * distinguish valid from invalid objects! 
  190868             :  */
  190869             : unsigned long
  190870           5 : SgInitializer::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  190871             :    {
  190872           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  190873           5 :      SgInitializer* pointer = NULL;
  190874           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  190875           5 :      std::vector < unsigned char* > :: const_iterator block;
  190876           5 :      for ( block = SgInitializer::pools.begin(); block != SgInitializer::pools.end() ; ++block )
  190877             :         {
  190878           0 :           pointer = (SgInitializer*)(*block);
  190879           0 :           for (unsigned i = 0; i < SgInitializer::pool_size; ++i )
  190880             :              {
  190881             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  190882             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  190883             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  190884             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  190885             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  190886             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  190887             :             // properly; so this will have to be checked next.
  190888             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  190889             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  190890           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  190891             :                   {
  190892           0 :                     pointer[i].set_freepointer((SgInitializer*)(globalIndex));
  190893           0 :                     globalIndex++;
  190894             :                   }
  190895             :                else
  190896             :                   {
  190897           0 :                     pointer[i].set_freepointer(NULL);
  190898             :                   }
  190899             :               }
  190900             :         }
  190901           5 :      return globalIndex;
  190902             :    }
  190903             : 
  190904             : //############################################################################
  190905             : // JH (01/14/2006)
  190906             : void
  190907           5 : SgInitializer::resetValidFreepointers( )
  190908             :    {
  190909           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  190910           5 :      SgInitializer* pointer = NULL;
  190911           5 :      std::vector < unsigned char* > :: const_iterator block;
  190912           5 :      SgInitializer* pointerOfLinkedList = NULL;
  190913           5 :      for ( block = SgInitializer::pools.begin(); block != SgInitializer::pools.end() ; ++block )
  190914             :         {
  190915           0 :           pointer = (SgInitializer*)(*block);
  190916           0 :           for (unsigned i = 0; i < SgInitializer::pool_size; ++i )
  190917             :              {
  190918             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  190919             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  190920             :             // memory blocks!.
  190921           0 :                if ( pointer[i].get_freepointer() != NULL )
  190922             :                   {
  190923           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  190924             :                   }
  190925             :                else
  190926             :                   {
  190927           0 :                     if ( pointerOfLinkedList == NULL )
  190928             :                        {
  190929           0 :                          SgInitializer::next_node = &(pointer[i]);
  190930             :                        }
  190931             :                     else
  190932             :                        {
  190933             :                       // printf ("In SgInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  190934           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  190935             :                        }
  190936             :                     pointerOfLinkedList = &(pointer[i]);
  190937             :                   }
  190938             :               }
  190939             :         }
  190940             : 
  190941           5 :      if ( pointerOfLinkedList != NULL )
  190942             :         {
  190943             :        // printf ("In SgInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  190944           0 :           pointerOfLinkedList->set_freepointer(NULL);
  190945             :        // DQ (6/6/2010): Temporary debugging...
  190946             :        //   ROSE_ASSERT(false);
  190947             :         }
  190948             : 
  190949           5 :      return ;
  190950             :    }
  190951             : 
  190952             : //############################################################################
  190953             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  190954             :  * within the memory pool and resets the freepointers, in order to achieve a 
  190955             :  * linked list, that has no jumps and starts at the beginning! This function 
  190956             :  * does not extend the memory pool, since we do not delete any memory blocks,
  190957             :  * but delete the valid objects.  
  190958             :  */
  190959             : void
  190960           0 : SgInitializer::clearMemoryPool( )
  190961             :    {
  190962             :   // printf ("Inside of SgInitializer::clearMemoryPool() \n");
  190963             : 
  190964           0 :      SgInitializer* pointer = NULL, *tempPointer = NULL;
  190965           0 :      std::vector < unsigned char* > :: const_iterator block;
  190966           0 :      if ( SgInitializer::pools.empty() == false )
  190967             :         {
  190968           0 :           block = SgInitializer::pools.begin() ;
  190969           0 :           SgInitializer::next_node = (SgInitializer*) (*block);
  190970             : 
  190971           0 :           while ( block != SgInitializer::pools.end() )
  190972             :              {
  190973           0 :                pointer = (SgInitializer*) (*block);
  190974           0 :                if ( tempPointer != NULL )
  190975             :                   {
  190976           0 :                     tempPointer->set_freepointer(pointer);
  190977             :                   }
  190978           0 :                for (unsigned i = 0; i < SgInitializer::pool_size - 1; ++i)
  190979             :                   {
  190980           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  190981             :                   }
  190982           0 :                 pointer[SgInitializer::pool_size-1].set_freepointer(NULL);
  190983           0 :                 tempPointer = &(pointer[SgInitializer::pool_size-1]);
  190984           0 :                 ++block;
  190985             :              }
  190986             :         }
  190987           0 :    }
  190988             : 
  190989           5 : void SgInitializer::deleteMemoryPool() {
  190990           5 :   for (auto p: SgInitializer::pools) {
  190991           0 :     ROSE_FREE(p);
  190992             :   }
  190993           5 :   SgInitializer::next_node = nullptr;
  190994           5 :   SgInitializer::pools.clear();
  190995           5 : }
  190996             : 
  190997             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  190998             : //                 reading multiple binary files to for a single AST.
  190999             : /////////// new version ////////////////////////////////
  191000             : //############################################################################
  191001             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  191002             : void
  191003           2 : SgInitializer::extendMemoryPoolForFileIO( )
  191004             :   {
  191005           2 :     size_t blockIndex = SgInitializer::pools.size();
  191006           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgInitializer) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgInitializer);
  191007             : 
  191008           2 :     while ( (blockIndex * SgInitializer::pool_size) < newPoolSize)
  191009             :       {
  191010             : #if ROSE_ALLOC_TRACE
  191011             :         if (blockIndex > 0) {
  191012             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgInitializer) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgInitializer) = %" PRIuPTR " SgInitializer::pool_size = %d \n",
  191013             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgInitializer),AST_FILE_IO::getPoolSizeOfNewAst(V_SgInitializer),SgInitializer::pool_size);
  191014             :         }
  191015             : #endif
  191016             : 
  191017           0 :         SgInitializer * pointer = (SgInitializer*) ROSE_MALLOC ( SgInitializer::pool_size * sizeof(SgInitializer) );
  191018           0 :         assert( pointer != NULL );
  191019             : #if ROSE_ALLOC_MEMSET == 1
  191020             :         memset(pointer, 0x00, SgInitializer::pool_size * sizeof(SgInitializer));
  191021             : #elif ROSE_ALLOC_MEMSET == 2
  191022             :         memset(pointer, 0xCC, SgInitializer::pool_size * sizeof(SgInitializer));
  191023             : #endif
  191024           0 :         SgInitializer::pools.push_back( (unsigned char*)(pointer) );
  191025           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgInitializer::pool_size * sizeof(SgInitializer), V_SgInitializer ) );
  191026             : 
  191027           0 :         if ( SgInitializer::next_node != NULL ) {
  191028           0 :           if ( blockIndex > 0 ) {
  191029           0 :             SgInitializer * blkptr = (SgInitializer*)(SgInitializer::pools[blockIndex-1]);
  191030           0 :             blkptr[ SgInitializer::pool_size - 1 ].set_freepointer(pointer);
  191031             :           }
  191032             :         } else {
  191033           0 :           SgInitializer::next_node = pointer;
  191034             :         }
  191035             : 
  191036           0 :         for (unsigned i = 0; i < SgInitializer::pool_size-1; ++i)
  191037             :            {
  191038           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  191039             :            }
  191040           0 :         pointer[ SgInitializer::pool_size -1 ].set_freepointer(NULL);
  191041             : 
  191042           0 :         blockIndex++;
  191043             :       }
  191044           2 :   }
  191045             : 
  191046             : //############################################################################
  191047             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  191048             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  191049             :  * not compressed. However, that stuff is not yet implemented! 
  191050             :  */
  191051             : unsigned long
  191052           0 : SgInitializer::getNumberOfLastValidPointer()
  191053             :    {
  191054           0 :       SgInitializer* testPointer = (SgInitializer*)(SgInitializer::pools.back());
  191055           0 :       unsigned long localIndex = SgInitializer::pool_size - 1;
  191056           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  191057             :          {
  191058           0 :            localIndex--;
  191059             :          }
  191060           0 :       return (localIndex + SgInitializer::pool_size * (SgInitializer::pools.size()-1));
  191061             :    }
  191062             : 
  191063             : //############################################################################
  191064             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  191065             :  * memory pool and initializes the data member in class SgInitializerStroageClass
  191066             :  * from its counterpart of SgInitializer. The return value is just for checking, 
  191067             :  * that the whole StorageClassArray is initialized!
  191068             :  */
  191069             : unsigned long
  191070           0 : SgInitializer::initializeStorageClassArray( SgInitializerStorageClass *storageArray )
  191071             :    {
  191072           0 :      unsigned long storageCounter = 0;
  191073           0 :      std::vector < unsigned char* > :: const_iterator block = SgInitializer::pools.begin();
  191074           0 :      SgInitializer* pointer = NULL;
  191075           0 :      while ( block != SgInitializer::pools.end() ) {
  191076           0 :           pointer = (SgInitializer*) (*block);
  191077           0 :           for ( unsigned i = 0; i < SgInitializer::pool_size; ++i ) {
  191078           0 :                if ( pointer->get_freepointer() != NULL ) {
  191079           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  191080           0 :                  storageArray++;
  191081           0 :                  storageCounter++;
  191082             :                }
  191083           0 :                pointer++;
  191084             :              }
  191085           0 :            block++;
  191086             :         }
  191087           0 :      return storageCounter;
  191088             :    }
  191089             : 
  191090             : /* #line 191091 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  191091             : 
  191092             : 
  191093             : 
  191094             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  191095             : 
  191096             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  191097             : 
  191098             : //############################################################################
  191099             : /* JH (02/02/2006) Constructor of the IR node SgAggregateInitializer that takes its 
  191100             :  * corresponding StorageClass as parameter
  191101             :  */
  191102           3 : SgAggregateInitializer :: SgAggregateInitializer ( const SgAggregateInitializerStorageClass& storageSource )   : SgInitializer (storageSource)
  191103             :    {
  191104             : 
  191105             : 
  191106             : /* #line 191107 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  191107             : 
  191108           3 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  191109           3 :      p_initializers =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initializers) );
  191110           3 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  191111           3 :      p_need_explicit_braces = storageSource.storageOf_need_explicit_braces ;
  191112           3 :      p_uses_compound_literal = storageSource.storageOf_uses_compound_literal ;
  191113           3 :      p_requiresGlobalNameQualificationOnType = storageSource.storageOf_requiresGlobalNameQualificationOnType ;
  191114           3 :      p_name_qualification_length_for_type = storageSource.storageOf_name_qualification_length_for_type ;
  191115           3 :      p_type_elaboration_required_for_type = storageSource.storageOf_type_elaboration_required_for_type ;
  191116           3 :      p_global_qualification_required_for_type = storageSource.storageOf_global_qualification_required_for_type ;
  191117           3 :      p_originalExpressionTree =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_originalExpressionTree) );
  191118             : 
  191119             : 
  191120             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  191121             : 
  191122             : 
  191123           3 :    }
  191124             : 
  191125             : //############################################################################
  191126             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  191127             :  * within the working AST. 
  191128             :  */
  191129          15 : SgAggregateInitializer * SgAggregateInitializer::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  191130          15 :      SgAggregateInitializer* returnPointer = NULL;
  191131          15 :      if ( globalIndex != 0 )
  191132             :         {
  191133             : 
  191134             : #if FILE_IO_EXTRA_CHECK
  191135          15 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAggregateInitializer ) ) <= globalIndex ) ;
  191136          15 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAggregateInitializer + 1 ) ) );
  191137             : #endif
  191138          15 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAggregateInitializer )  
  191139          15 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAggregateInitializer );
  191140          15 :           unsigned long positionInPool = localIndex % SgAggregateInitializer::pool_size;
  191141          15 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAggregateInitializer::pool_size;
  191142             : 
  191143             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  191144             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  191145             : 
  191146          15 :           returnPointer = &( ( (SgAggregateInitializer*)(SgAggregateInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  191147             : 
  191148          15 :           ROSE_ASSERT( returnPointer != NULL ) ;
  191149             :         }
  191150          15 :      return returnPointer ;
  191151             :    }
  191152             : 
  191153             : //############################################################################
  191154             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  191155             :   for the AST with the index astIndex
  191156             : */
  191157           0 : SgAggregateInitializer * SgAggregateInitializer::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  191158           0 :      SgAggregateInitializer* returnPointer = NULL;
  191159           0 :      if ( globalIndex != 0 )
  191160             :         {
  191161             : 
  191162             : #if FILE_IO_EXTRA_CHECK
  191163           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAggregateInitializer ) ) <= globalIndex ) ;
  191164           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAggregateInitializer + 1 ) ) );
  191165             : #endif
  191166           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAggregateInitializer )
  191167           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAggregateInitializer );
  191168           0 :           unsigned long positionInPool = localIndex % SgAggregateInitializer::pool_size ;
  191169           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAggregateInitializer::pool_size ;
  191170             : 
  191171             : #if FILE_IO_EXTRA_CHECK
  191172             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  191173             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  191174             : #endif
  191175             : 
  191176           0 :           returnPointer = &( ( (SgAggregateInitializer*)(SgAggregateInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  191177             : 
  191178             : #if FILE_IO_EXTRA_CHECK
  191179           0 :           assert ( returnPointer != NULL ) ;
  191180             : #endif
  191181             :         }
  191182           0 :      return returnPointer ;
  191183             :    }
  191184             : 
  191185             : //############################################################################
  191186             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  191187             :  * pool size! We set for every valid object in the memory pool the freepointer
  191188             :  * to the global index and increase the global index afterwards. For all the 
  191189             :  * invalid objects (means address ranges within the memory pool that were not
  191190             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  191191             :  * distinguish valid from invalid objects! 
  191192             :  */
  191193             : unsigned long
  191194           5 : SgAggregateInitializer::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  191195             :    {
  191196           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  191197           5 :      SgAggregateInitializer* pointer = NULL;
  191198           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  191199           5 :      std::vector < unsigned char* > :: const_iterator block;
  191200           6 :      for ( block = SgAggregateInitializer::pools.begin(); block != SgAggregateInitializer::pools.end() ; ++block )
  191201             :         {
  191202           1 :           pointer = (SgAggregateInitializer*)(*block);
  191203        2001 :           for (unsigned i = 0; i < SgAggregateInitializer::pool_size; ++i )
  191204             :              {
  191205             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  191206             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  191207             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  191208             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  191209             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  191210             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  191211             :             // properly; so this will have to be checked next.
  191212             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  191213             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  191214        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  191215             :                   {
  191216           3 :                     pointer[i].set_freepointer((SgAggregateInitializer*)(globalIndex));
  191217           3 :                     globalIndex++;
  191218             :                   }
  191219             :                else
  191220             :                   {
  191221        1997 :                     pointer[i].set_freepointer(NULL);
  191222             :                   }
  191223             :               }
  191224             :         }
  191225           5 :      return globalIndex;
  191226             :    }
  191227             : 
  191228             : //############################################################################
  191229             : // JH (01/14/2006)
  191230             : void
  191231           5 : SgAggregateInitializer::resetValidFreepointers( )
  191232             :    {
  191233           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  191234           5 :      SgAggregateInitializer* pointer = NULL;
  191235           5 :      std::vector < unsigned char* > :: const_iterator block;
  191236           5 :      SgAggregateInitializer* pointerOfLinkedList = NULL;
  191237           6 :      for ( block = SgAggregateInitializer::pools.begin(); block != SgAggregateInitializer::pools.end() ; ++block )
  191238             :         {
  191239           1 :           pointer = (SgAggregateInitializer*)(*block);
  191240        2001 :           for (unsigned i = 0; i < SgAggregateInitializer::pool_size; ++i )
  191241             :              {
  191242             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  191243             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  191244             :             // memory blocks!.
  191245        2000 :                if ( pointer[i].get_freepointer() != NULL )
  191246             :                   {
  191247           3 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  191248             :                   }
  191249             :                else
  191250             :                   {
  191251        1997 :                     if ( pointerOfLinkedList == NULL )
  191252             :                        {
  191253           1 :                          SgAggregateInitializer::next_node = &(pointer[i]);
  191254             :                        }
  191255             :                     else
  191256             :                        {
  191257             :                       // printf ("In SgAggregateInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  191258        1996 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  191259             :                        }
  191260             :                     pointerOfLinkedList = &(pointer[i]);
  191261             :                   }
  191262             :               }
  191263             :         }
  191264             : 
  191265           5 :      if ( pointerOfLinkedList != NULL )
  191266             :         {
  191267             :        // printf ("In SgAggregateInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  191268           1 :           pointerOfLinkedList->set_freepointer(NULL);
  191269             :        // DQ (6/6/2010): Temporary debugging...
  191270             :        //   ROSE_ASSERT(false);
  191271             :         }
  191272             : 
  191273           5 :      return ;
  191274             :    }
  191275             : 
  191276             : //############################################################################
  191277             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  191278             :  * within the memory pool and resets the freepointers, in order to achieve a 
  191279             :  * linked list, that has no jumps and starts at the beginning! This function 
  191280             :  * does not extend the memory pool, since we do not delete any memory blocks,
  191281             :  * but delete the valid objects.  
  191282             :  */
  191283             : void
  191284           0 : SgAggregateInitializer::clearMemoryPool( )
  191285             :    {
  191286             :   // printf ("Inside of SgAggregateInitializer::clearMemoryPool() \n");
  191287             : 
  191288           0 :      SgAggregateInitializer* pointer = NULL, *tempPointer = NULL;
  191289           0 :      std::vector < unsigned char* > :: const_iterator block;
  191290           0 :      if ( SgAggregateInitializer::pools.empty() == false )
  191291             :         {
  191292           0 :           block = SgAggregateInitializer::pools.begin() ;
  191293           0 :           SgAggregateInitializer::next_node = (SgAggregateInitializer*) (*block);
  191294             : 
  191295           0 :           while ( block != SgAggregateInitializer::pools.end() )
  191296             :              {
  191297           0 :                pointer = (SgAggregateInitializer*) (*block);
  191298           0 :                if ( tempPointer != NULL )
  191299             :                   {
  191300           0 :                     tempPointer->set_freepointer(pointer);
  191301             :                   }
  191302           0 :                for (unsigned i = 0; i < SgAggregateInitializer::pool_size - 1; ++i)
  191303             :                   {
  191304           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  191305             :                   }
  191306           0 :                 pointer[SgAggregateInitializer::pool_size-1].set_freepointer(NULL);
  191307           0 :                 tempPointer = &(pointer[SgAggregateInitializer::pool_size-1]);
  191308           0 :                 ++block;
  191309             :              }
  191310             :         }
  191311           0 :    }
  191312             : 
  191313           5 : void SgAggregateInitializer::deleteMemoryPool() {
  191314           7 :   for (auto p: SgAggregateInitializer::pools) {
  191315           2 :     ROSE_FREE(p);
  191316             :   }
  191317           5 :   SgAggregateInitializer::next_node = nullptr;
  191318           5 :   SgAggregateInitializer::pools.clear();
  191319           5 : }
  191320             : 
  191321             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  191322             : //                 reading multiple binary files to for a single AST.
  191323             : /////////// new version ////////////////////////////////
  191324             : //############################################################################
  191325             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  191326             : void
  191327           2 : SgAggregateInitializer::extendMemoryPoolForFileIO( )
  191328             :   {
  191329           2 :     size_t blockIndex = SgAggregateInitializer::pools.size();
  191330           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAggregateInitializer) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAggregateInitializer);
  191331             : 
  191332           3 :     while ( (blockIndex * SgAggregateInitializer::pool_size) < newPoolSize)
  191333             :       {
  191334             : #if ROSE_ALLOC_TRACE
  191335             :         if (blockIndex > 0) {
  191336             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAggregateInitializer) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAggregateInitializer) = %" PRIuPTR " SgAggregateInitializer::pool_size = %d \n",
  191337             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAggregateInitializer),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAggregateInitializer),SgAggregateInitializer::pool_size);
  191338             :         }
  191339             : #endif
  191340             : 
  191341           1 :         SgAggregateInitializer * pointer = (SgAggregateInitializer*) ROSE_MALLOC ( SgAggregateInitializer::pool_size * sizeof(SgAggregateInitializer) );
  191342           1 :         assert( pointer != NULL );
  191343             : #if ROSE_ALLOC_MEMSET == 1
  191344             :         memset(pointer, 0x00, SgAggregateInitializer::pool_size * sizeof(SgAggregateInitializer));
  191345             : #elif ROSE_ALLOC_MEMSET == 2
  191346             :         memset(pointer, 0xCC, SgAggregateInitializer::pool_size * sizeof(SgAggregateInitializer));
  191347             : #endif
  191348           1 :         SgAggregateInitializer::pools.push_back( (unsigned char*)(pointer) );
  191349           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAggregateInitializer::pool_size * sizeof(SgAggregateInitializer), V_SgAggregateInitializer ) );
  191350             : 
  191351           1 :         if ( SgAggregateInitializer::next_node != NULL ) {
  191352           0 :           if ( blockIndex > 0 ) {
  191353           0 :             SgAggregateInitializer * blkptr = (SgAggregateInitializer*)(SgAggregateInitializer::pools[blockIndex-1]);
  191354           0 :             blkptr[ SgAggregateInitializer::pool_size - 1 ].set_freepointer(pointer);
  191355             :           }
  191356             :         } else {
  191357           1 :           SgAggregateInitializer::next_node = pointer;
  191358             :         }
  191359             : 
  191360        2000 :         for (unsigned i = 0; i < SgAggregateInitializer::pool_size-1; ++i)
  191361             :            {
  191362        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  191363             :            }
  191364           1 :         pointer[ SgAggregateInitializer::pool_size -1 ].set_freepointer(NULL);
  191365             : 
  191366           1 :         blockIndex++;
  191367             :       }
  191368           2 :   }
  191369             : 
  191370             : //############################################################################
  191371             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  191372             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  191373             :  * not compressed. However, that stuff is not yet implemented! 
  191374             :  */
  191375             : unsigned long
  191376           0 : SgAggregateInitializer::getNumberOfLastValidPointer()
  191377             :    {
  191378           0 :       SgAggregateInitializer* testPointer = (SgAggregateInitializer*)(SgAggregateInitializer::pools.back());
  191379           0 :       unsigned long localIndex = SgAggregateInitializer::pool_size - 1;
  191380           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  191381             :          {
  191382           0 :            localIndex--;
  191383             :          }
  191384           0 :       return (localIndex + SgAggregateInitializer::pool_size * (SgAggregateInitializer::pools.size()-1));
  191385             :    }
  191386             : 
  191387             : //############################################################################
  191388             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  191389             :  * memory pool and initializes the data member in class SgAggregateInitializerStroageClass
  191390             :  * from its counterpart of SgAggregateInitializer. The return value is just for checking, 
  191391             :  * that the whole StorageClassArray is initialized!
  191392             :  */
  191393             : unsigned long
  191394           1 : SgAggregateInitializer::initializeStorageClassArray( SgAggregateInitializerStorageClass *storageArray )
  191395             :    {
  191396           1 :      unsigned long storageCounter = 0;
  191397           1 :      std::vector < unsigned char* > :: const_iterator block = SgAggregateInitializer::pools.begin();
  191398           1 :      SgAggregateInitializer* pointer = NULL;
  191399           2 :      while ( block != SgAggregateInitializer::pools.end() ) {
  191400           1 :           pointer = (SgAggregateInitializer*) (*block);
  191401        2001 :           for ( unsigned i = 0; i < SgAggregateInitializer::pool_size; ++i ) {
  191402        2000 :                if ( pointer->get_freepointer() != NULL ) {
  191403           3 :                  storageArray->pickOutIRNodeData (pointer) ;
  191404           3 :                  storageArray++;
  191405           3 :                  storageCounter++;
  191406             :                }
  191407        2000 :                pointer++;
  191408             :              }
  191409           1 :            block++;
  191410             :         }
  191411           1 :      return storageCounter;
  191412             :    }
  191413             : 
  191414             : /* #line 191415 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  191415             : 
  191416             : 
  191417             : 
  191418             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  191419             : 
  191420             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  191421             : 
  191422             : //############################################################################
  191423             : /* JH (02/02/2006) Constructor of the IR node SgCompoundInitializer that takes its 
  191424             :  * corresponding StorageClass as parameter
  191425             :  */
  191426           0 : SgCompoundInitializer :: SgCompoundInitializer ( const SgCompoundInitializerStorageClass& storageSource )   : SgInitializer (storageSource)
  191427             :    {
  191428             : 
  191429             : 
  191430             : /* #line 191431 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  191431             : 
  191432           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  191433           0 :      p_initializers =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initializers) );
  191434           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  191435             : 
  191436             : 
  191437             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  191438             : 
  191439             : 
  191440           0 :    }
  191441             : 
  191442             : //############################################################################
  191443             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  191444             :  * within the working AST. 
  191445             :  */
  191446           0 : SgCompoundInitializer * SgCompoundInitializer::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  191447           0 :      SgCompoundInitializer* returnPointer = NULL;
  191448           0 :      if ( globalIndex != 0 )
  191449             :         {
  191450             : 
  191451             : #if FILE_IO_EXTRA_CHECK
  191452           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCompoundInitializer ) ) <= globalIndex ) ;
  191453           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCompoundInitializer + 1 ) ) );
  191454             : #endif
  191455           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCompoundInitializer )  
  191456           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCompoundInitializer );
  191457           0 :           unsigned long positionInPool = localIndex % SgCompoundInitializer::pool_size;
  191458           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCompoundInitializer::pool_size;
  191459             : 
  191460             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  191461             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  191462             : 
  191463           0 :           returnPointer = &( ( (SgCompoundInitializer*)(SgCompoundInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  191464             : 
  191465           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  191466             :         }
  191467           0 :      return returnPointer ;
  191468             :    }
  191469             : 
  191470             : //############################################################################
  191471             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  191472             :   for the AST with the index astIndex
  191473             : */
  191474           0 : SgCompoundInitializer * SgCompoundInitializer::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  191475           0 :      SgCompoundInitializer* returnPointer = NULL;
  191476           0 :      if ( globalIndex != 0 )
  191477             :         {
  191478             : 
  191479             : #if FILE_IO_EXTRA_CHECK
  191480           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCompoundInitializer ) ) <= globalIndex ) ;
  191481           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCompoundInitializer + 1 ) ) );
  191482             : #endif
  191483           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCompoundInitializer )
  191484           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCompoundInitializer );
  191485           0 :           unsigned long positionInPool = localIndex % SgCompoundInitializer::pool_size ;
  191486           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCompoundInitializer::pool_size ;
  191487             : 
  191488             : #if FILE_IO_EXTRA_CHECK
  191489             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  191490             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  191491             : #endif
  191492             : 
  191493           0 :           returnPointer = &( ( (SgCompoundInitializer*)(SgCompoundInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  191494             : 
  191495             : #if FILE_IO_EXTRA_CHECK
  191496           0 :           assert ( returnPointer != NULL ) ;
  191497             : #endif
  191498             :         }
  191499           0 :      return returnPointer ;
  191500             :    }
  191501             : 
  191502             : //############################################################################
  191503             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  191504             :  * pool size! We set for every valid object in the memory pool the freepointer
  191505             :  * to the global index and increase the global index afterwards. For all the 
  191506             :  * invalid objects (means address ranges within the memory pool that were not
  191507             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  191508             :  * distinguish valid from invalid objects! 
  191509             :  */
  191510             : unsigned long
  191511           5 : SgCompoundInitializer::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  191512             :    {
  191513           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  191514           5 :      SgCompoundInitializer* pointer = NULL;
  191515           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  191516           5 :      std::vector < unsigned char* > :: const_iterator block;
  191517           5 :      for ( block = SgCompoundInitializer::pools.begin(); block != SgCompoundInitializer::pools.end() ; ++block )
  191518             :         {
  191519           0 :           pointer = (SgCompoundInitializer*)(*block);
  191520           0 :           for (unsigned i = 0; i < SgCompoundInitializer::pool_size; ++i )
  191521             :              {
  191522             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  191523             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  191524             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  191525             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  191526             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  191527             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  191528             :             // properly; so this will have to be checked next.
  191529             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  191530             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  191531           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  191532             :                   {
  191533           0 :                     pointer[i].set_freepointer((SgCompoundInitializer*)(globalIndex));
  191534           0 :                     globalIndex++;
  191535             :                   }
  191536             :                else
  191537             :                   {
  191538           0 :                     pointer[i].set_freepointer(NULL);
  191539             :                   }
  191540             :               }
  191541             :         }
  191542           5 :      return globalIndex;
  191543             :    }
  191544             : 
  191545             : //############################################################################
  191546             : // JH (01/14/2006)
  191547             : void
  191548           5 : SgCompoundInitializer::resetValidFreepointers( )
  191549             :    {
  191550           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  191551           5 :      SgCompoundInitializer* pointer = NULL;
  191552           5 :      std::vector < unsigned char* > :: const_iterator block;
  191553           5 :      SgCompoundInitializer* pointerOfLinkedList = NULL;
  191554           5 :      for ( block = SgCompoundInitializer::pools.begin(); block != SgCompoundInitializer::pools.end() ; ++block )
  191555             :         {
  191556           0 :           pointer = (SgCompoundInitializer*)(*block);
  191557           0 :           for (unsigned i = 0; i < SgCompoundInitializer::pool_size; ++i )
  191558             :              {
  191559             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  191560             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  191561             :             // memory blocks!.
  191562           0 :                if ( pointer[i].get_freepointer() != NULL )
  191563             :                   {
  191564           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  191565             :                   }
  191566             :                else
  191567             :                   {
  191568           0 :                     if ( pointerOfLinkedList == NULL )
  191569             :                        {
  191570           0 :                          SgCompoundInitializer::next_node = &(pointer[i]);
  191571             :                        }
  191572             :                     else
  191573             :                        {
  191574             :                       // printf ("In SgCompoundInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  191575           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  191576             :                        }
  191577             :                     pointerOfLinkedList = &(pointer[i]);
  191578             :                   }
  191579             :               }
  191580             :         }
  191581             : 
  191582           5 :      if ( pointerOfLinkedList != NULL )
  191583             :         {
  191584             :        // printf ("In SgCompoundInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  191585           0 :           pointerOfLinkedList->set_freepointer(NULL);
  191586             :        // DQ (6/6/2010): Temporary debugging...
  191587             :        //   ROSE_ASSERT(false);
  191588             :         }
  191589             : 
  191590           5 :      return ;
  191591             :    }
  191592             : 
  191593             : //############################################################################
  191594             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  191595             :  * within the memory pool and resets the freepointers, in order to achieve a 
  191596             :  * linked list, that has no jumps and starts at the beginning! This function 
  191597             :  * does not extend the memory pool, since we do not delete any memory blocks,
  191598             :  * but delete the valid objects.  
  191599             :  */
  191600             : void
  191601           0 : SgCompoundInitializer::clearMemoryPool( )
  191602             :    {
  191603             :   // printf ("Inside of SgCompoundInitializer::clearMemoryPool() \n");
  191604             : 
  191605           0 :      SgCompoundInitializer* pointer = NULL, *tempPointer = NULL;
  191606           0 :      std::vector < unsigned char* > :: const_iterator block;
  191607           0 :      if ( SgCompoundInitializer::pools.empty() == false )
  191608             :         {
  191609           0 :           block = SgCompoundInitializer::pools.begin() ;
  191610           0 :           SgCompoundInitializer::next_node = (SgCompoundInitializer*) (*block);
  191611             : 
  191612           0 :           while ( block != SgCompoundInitializer::pools.end() )
  191613             :              {
  191614           0 :                pointer = (SgCompoundInitializer*) (*block);
  191615           0 :                if ( tempPointer != NULL )
  191616             :                   {
  191617           0 :                     tempPointer->set_freepointer(pointer);
  191618             :                   }
  191619           0 :                for (unsigned i = 0; i < SgCompoundInitializer::pool_size - 1; ++i)
  191620             :                   {
  191621           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  191622             :                   }
  191623           0 :                 pointer[SgCompoundInitializer::pool_size-1].set_freepointer(NULL);
  191624           0 :                 tempPointer = &(pointer[SgCompoundInitializer::pool_size-1]);
  191625           0 :                 ++block;
  191626             :              }
  191627             :         }
  191628           0 :    }
  191629             : 
  191630           5 : void SgCompoundInitializer::deleteMemoryPool() {
  191631           5 :   for (auto p: SgCompoundInitializer::pools) {
  191632           0 :     ROSE_FREE(p);
  191633             :   }
  191634           5 :   SgCompoundInitializer::next_node = nullptr;
  191635           5 :   SgCompoundInitializer::pools.clear();
  191636           5 : }
  191637             : 
  191638             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  191639             : //                 reading multiple binary files to for a single AST.
  191640             : /////////// new version ////////////////////////////////
  191641             : //############################################################################
  191642             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  191643             : void
  191644           2 : SgCompoundInitializer::extendMemoryPoolForFileIO( )
  191645             :   {
  191646           2 :     size_t blockIndex = SgCompoundInitializer::pools.size();
  191647           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundInitializer) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundInitializer);
  191648             : 
  191649           2 :     while ( (blockIndex * SgCompoundInitializer::pool_size) < newPoolSize)
  191650             :       {
  191651             : #if ROSE_ALLOC_TRACE
  191652             :         if (blockIndex > 0) {
  191653             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundInitializer) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundInitializer) = %" PRIuPTR " SgCompoundInitializer::pool_size = %d \n",
  191654             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundInitializer),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundInitializer),SgCompoundInitializer::pool_size);
  191655             :         }
  191656             : #endif
  191657             : 
  191658           0 :         SgCompoundInitializer * pointer = (SgCompoundInitializer*) ROSE_MALLOC ( SgCompoundInitializer::pool_size * sizeof(SgCompoundInitializer) );
  191659           0 :         assert( pointer != NULL );
  191660             : #if ROSE_ALLOC_MEMSET == 1
  191661             :         memset(pointer, 0x00, SgCompoundInitializer::pool_size * sizeof(SgCompoundInitializer));
  191662             : #elif ROSE_ALLOC_MEMSET == 2
  191663             :         memset(pointer, 0xCC, SgCompoundInitializer::pool_size * sizeof(SgCompoundInitializer));
  191664             : #endif
  191665           0 :         SgCompoundInitializer::pools.push_back( (unsigned char*)(pointer) );
  191666           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCompoundInitializer::pool_size * sizeof(SgCompoundInitializer), V_SgCompoundInitializer ) );
  191667             : 
  191668           0 :         if ( SgCompoundInitializer::next_node != NULL ) {
  191669           0 :           if ( blockIndex > 0 ) {
  191670           0 :             SgCompoundInitializer * blkptr = (SgCompoundInitializer*)(SgCompoundInitializer::pools[blockIndex-1]);
  191671           0 :             blkptr[ SgCompoundInitializer::pool_size - 1 ].set_freepointer(pointer);
  191672             :           }
  191673             :         } else {
  191674           0 :           SgCompoundInitializer::next_node = pointer;
  191675             :         }
  191676             : 
  191677           0 :         for (unsigned i = 0; i < SgCompoundInitializer::pool_size-1; ++i)
  191678             :            {
  191679           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  191680             :            }
  191681           0 :         pointer[ SgCompoundInitializer::pool_size -1 ].set_freepointer(NULL);
  191682             : 
  191683           0 :         blockIndex++;
  191684             :       }
  191685           2 :   }
  191686             : 
  191687             : //############################################################################
  191688             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  191689             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  191690             :  * not compressed. However, that stuff is not yet implemented! 
  191691             :  */
  191692             : unsigned long
  191693           0 : SgCompoundInitializer::getNumberOfLastValidPointer()
  191694             :    {
  191695           0 :       SgCompoundInitializer* testPointer = (SgCompoundInitializer*)(SgCompoundInitializer::pools.back());
  191696           0 :       unsigned long localIndex = SgCompoundInitializer::pool_size - 1;
  191697           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  191698             :          {
  191699           0 :            localIndex--;
  191700             :          }
  191701           0 :       return (localIndex + SgCompoundInitializer::pool_size * (SgCompoundInitializer::pools.size()-1));
  191702             :    }
  191703             : 
  191704             : //############################################################################
  191705             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  191706             :  * memory pool and initializes the data member in class SgCompoundInitializerStroageClass
  191707             :  * from its counterpart of SgCompoundInitializer. The return value is just for checking, 
  191708             :  * that the whole StorageClassArray is initialized!
  191709             :  */
  191710             : unsigned long
  191711           0 : SgCompoundInitializer::initializeStorageClassArray( SgCompoundInitializerStorageClass *storageArray )
  191712             :    {
  191713           0 :      unsigned long storageCounter = 0;
  191714           0 :      std::vector < unsigned char* > :: const_iterator block = SgCompoundInitializer::pools.begin();
  191715           0 :      SgCompoundInitializer* pointer = NULL;
  191716           0 :      while ( block != SgCompoundInitializer::pools.end() ) {
  191717           0 :           pointer = (SgCompoundInitializer*) (*block);
  191718           0 :           for ( unsigned i = 0; i < SgCompoundInitializer::pool_size; ++i ) {
  191719           0 :                if ( pointer->get_freepointer() != NULL ) {
  191720           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  191721           0 :                  storageArray++;
  191722           0 :                  storageCounter++;
  191723             :                }
  191724           0 :                pointer++;
  191725             :              }
  191726           0 :            block++;
  191727             :         }
  191728           0 :      return storageCounter;
  191729             :    }
  191730             : 
  191731             : /* #line 191732 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  191732             : 
  191733             : 
  191734             : 
  191735             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  191736             : 
  191737             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  191738             : 
  191739             : //############################################################################
  191740             : /* JH (02/02/2006) Constructor of the IR node SgConstructorInitializer that takes its 
  191741             :  * corresponding StorageClass as parameter
  191742             :  */
  191743         461 : SgConstructorInitializer :: SgConstructorInitializer ( const SgConstructorInitializerStorageClass& storageSource )   : SgInitializer (storageSource)
  191744             :    {
  191745             : 
  191746             : 
  191747             : /* #line 191748 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  191748             : 
  191749         461 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  191750         461 :      p_declaration =  (SgMemberFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  191751         461 :      p_args =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_args) );
  191752         461 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  191753         461 :      p_need_name = storageSource.storageOf_need_name ;
  191754         461 :      p_need_qualifier = storageSource.storageOf_need_qualifier ;
  191755         461 :      p_need_parenthesis_after_name = storageSource.storageOf_need_parenthesis_after_name ;
  191756         461 :      p_associated_class_unknown = storageSource.storageOf_associated_class_unknown ;
  191757         461 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  191758         461 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  191759         461 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  191760         461 :      p_is_used_in_conditional = storageSource.storageOf_is_used_in_conditional ;
  191761             : 
  191762             : 
  191763             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  191764             : 
  191765             : 
  191766         461 :    }
  191767             : 
  191768             : //############################################################################
  191769             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  191770             :  * within the working AST. 
  191771             :  */
  191772        2305 : SgConstructorInitializer * SgConstructorInitializer::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  191773        2305 :      SgConstructorInitializer* returnPointer = NULL;
  191774        2305 :      if ( globalIndex != 0 )
  191775             :         {
  191776             : 
  191777             : #if FILE_IO_EXTRA_CHECK
  191778        2305 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgConstructorInitializer ) ) <= globalIndex ) ;
  191779        2305 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConstructorInitializer + 1 ) ) );
  191780             : #endif
  191781        2305 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgConstructorInitializer )  
  191782        2305 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgConstructorInitializer );
  191783        2305 :           unsigned long positionInPool = localIndex % SgConstructorInitializer::pool_size;
  191784        2305 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConstructorInitializer::pool_size;
  191785             : 
  191786             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  191787             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  191788             : 
  191789        2305 :           returnPointer = &( ( (SgConstructorInitializer*)(SgConstructorInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  191790             : 
  191791        2305 :           ROSE_ASSERT( returnPointer != NULL ) ;
  191792             :         }
  191793        2305 :      return returnPointer ;
  191794             :    }
  191795             : 
  191796             : //############################################################################
  191797             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  191798             :   for the AST with the index astIndex
  191799             : */
  191800           0 : SgConstructorInitializer * SgConstructorInitializer::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  191801           0 :      SgConstructorInitializer* returnPointer = NULL;
  191802           0 :      if ( globalIndex != 0 )
  191803             :         {
  191804             : 
  191805             : #if FILE_IO_EXTRA_CHECK
  191806           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgConstructorInitializer ) ) <= globalIndex ) ;
  191807           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConstructorInitializer + 1 ) ) );
  191808             : #endif
  191809           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgConstructorInitializer )
  191810           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgConstructorInitializer );
  191811           0 :           unsigned long positionInPool = localIndex % SgConstructorInitializer::pool_size ;
  191812           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgConstructorInitializer::pool_size ;
  191813             : 
  191814             : #if FILE_IO_EXTRA_CHECK
  191815             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  191816             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  191817             : #endif
  191818             : 
  191819           0 :           returnPointer = &( ( (SgConstructorInitializer*)(SgConstructorInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  191820             : 
  191821             : #if FILE_IO_EXTRA_CHECK
  191822           0 :           assert ( returnPointer != NULL ) ;
  191823             : #endif
  191824             :         }
  191825           0 :      return returnPointer ;
  191826             :    }
  191827             : 
  191828             : //############################################################################
  191829             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  191830             :  * pool size! We set for every valid object in the memory pool the freepointer
  191831             :  * to the global index and increase the global index afterwards. For all the 
  191832             :  * invalid objects (means address ranges within the memory pool that were not
  191833             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  191834             :  * distinguish valid from invalid objects! 
  191835             :  */
  191836             : unsigned long
  191837           5 : SgConstructorInitializer::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  191838             :    {
  191839           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  191840           5 :      SgConstructorInitializer* pointer = NULL;
  191841           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  191842           5 :      std::vector < unsigned char* > :: const_iterator block;
  191843           6 :      for ( block = SgConstructorInitializer::pools.begin(); block != SgConstructorInitializer::pools.end() ; ++block )
  191844             :         {
  191845           1 :           pointer = (SgConstructorInitializer*)(*block);
  191846        2001 :           for (unsigned i = 0; i < SgConstructorInitializer::pool_size; ++i )
  191847             :              {
  191848             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  191849             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  191850             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  191851             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  191852             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  191853             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  191854             :             // properly; so this will have to be checked next.
  191855             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  191856             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  191857        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  191858             :                   {
  191859         461 :                     pointer[i].set_freepointer((SgConstructorInitializer*)(globalIndex));
  191860         461 :                     globalIndex++;
  191861             :                   }
  191862             :                else
  191863             :                   {
  191864        1539 :                     pointer[i].set_freepointer(NULL);
  191865             :                   }
  191866             :               }
  191867             :         }
  191868           5 :      return globalIndex;
  191869             :    }
  191870             : 
  191871             : //############################################################################
  191872             : // JH (01/14/2006)
  191873             : void
  191874           5 : SgConstructorInitializer::resetValidFreepointers( )
  191875             :    {
  191876           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  191877           5 :      SgConstructorInitializer* pointer = NULL;
  191878           5 :      std::vector < unsigned char* > :: const_iterator block;
  191879           5 :      SgConstructorInitializer* pointerOfLinkedList = NULL;
  191880           6 :      for ( block = SgConstructorInitializer::pools.begin(); block != SgConstructorInitializer::pools.end() ; ++block )
  191881             :         {
  191882           1 :           pointer = (SgConstructorInitializer*)(*block);
  191883        2001 :           for (unsigned i = 0; i < SgConstructorInitializer::pool_size; ++i )
  191884             :              {
  191885             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  191886             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  191887             :             // memory blocks!.
  191888        2000 :                if ( pointer[i].get_freepointer() != NULL )
  191889             :                   {
  191890         461 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  191891             :                   }
  191892             :                else
  191893             :                   {
  191894        1539 :                     if ( pointerOfLinkedList == NULL )
  191895             :                        {
  191896           1 :                          SgConstructorInitializer::next_node = &(pointer[i]);
  191897             :                        }
  191898             :                     else
  191899             :                        {
  191900             :                       // printf ("In SgConstructorInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  191901        1538 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  191902             :                        }
  191903             :                     pointerOfLinkedList = &(pointer[i]);
  191904             :                   }
  191905             :               }
  191906             :         }
  191907             : 
  191908           5 :      if ( pointerOfLinkedList != NULL )
  191909             :         {
  191910             :        // printf ("In SgConstructorInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  191911           1 :           pointerOfLinkedList->set_freepointer(NULL);
  191912             :        // DQ (6/6/2010): Temporary debugging...
  191913             :        //   ROSE_ASSERT(false);
  191914             :         }
  191915             : 
  191916           5 :      return ;
  191917             :    }
  191918             : 
  191919             : //############################################################################
  191920             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  191921             :  * within the memory pool and resets the freepointers, in order to achieve a 
  191922             :  * linked list, that has no jumps and starts at the beginning! This function 
  191923             :  * does not extend the memory pool, since we do not delete any memory blocks,
  191924             :  * but delete the valid objects.  
  191925             :  */
  191926             : void
  191927           0 : SgConstructorInitializer::clearMemoryPool( )
  191928             :    {
  191929             :   // printf ("Inside of SgConstructorInitializer::clearMemoryPool() \n");
  191930             : 
  191931           0 :      SgConstructorInitializer* pointer = NULL, *tempPointer = NULL;
  191932           0 :      std::vector < unsigned char* > :: const_iterator block;
  191933           0 :      if ( SgConstructorInitializer::pools.empty() == false )
  191934             :         {
  191935           0 :           block = SgConstructorInitializer::pools.begin() ;
  191936           0 :           SgConstructorInitializer::next_node = (SgConstructorInitializer*) (*block);
  191937             : 
  191938           0 :           while ( block != SgConstructorInitializer::pools.end() )
  191939             :              {
  191940           0 :                pointer = (SgConstructorInitializer*) (*block);
  191941           0 :                if ( tempPointer != NULL )
  191942             :                   {
  191943           0 :                     tempPointer->set_freepointer(pointer);
  191944             :                   }
  191945           0 :                for (unsigned i = 0; i < SgConstructorInitializer::pool_size - 1; ++i)
  191946             :                   {
  191947           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  191948             :                   }
  191949           0 :                 pointer[SgConstructorInitializer::pool_size-1].set_freepointer(NULL);
  191950           0 :                 tempPointer = &(pointer[SgConstructorInitializer::pool_size-1]);
  191951           0 :                 ++block;
  191952             :              }
  191953             :         }
  191954           0 :    }
  191955             : 
  191956           5 : void SgConstructorInitializer::deleteMemoryPool() {
  191957           7 :   for (auto p: SgConstructorInitializer::pools) {
  191958           2 :     ROSE_FREE(p);
  191959             :   }
  191960           5 :   SgConstructorInitializer::next_node = nullptr;
  191961           5 :   SgConstructorInitializer::pools.clear();
  191962           5 : }
  191963             : 
  191964             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  191965             : //                 reading multiple binary files to for a single AST.
  191966             : /////////// new version ////////////////////////////////
  191967             : //############################################################################
  191968             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  191969             : void
  191970           2 : SgConstructorInitializer::extendMemoryPoolForFileIO( )
  191971             :   {
  191972           2 :     size_t blockIndex = SgConstructorInitializer::pools.size();
  191973           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgConstructorInitializer) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgConstructorInitializer);
  191974             : 
  191975           3 :     while ( (blockIndex * SgConstructorInitializer::pool_size) < newPoolSize)
  191976             :       {
  191977             : #if ROSE_ALLOC_TRACE
  191978             :         if (blockIndex > 0) {
  191979             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgConstructorInitializer) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgConstructorInitializer) = %" PRIuPTR " SgConstructorInitializer::pool_size = %d \n",
  191980             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgConstructorInitializer),AST_FILE_IO::getPoolSizeOfNewAst(V_SgConstructorInitializer),SgConstructorInitializer::pool_size);
  191981             :         }
  191982             : #endif
  191983             : 
  191984           1 :         SgConstructorInitializer * pointer = (SgConstructorInitializer*) ROSE_MALLOC ( SgConstructorInitializer::pool_size * sizeof(SgConstructorInitializer) );
  191985           1 :         assert( pointer != NULL );
  191986             : #if ROSE_ALLOC_MEMSET == 1
  191987             :         memset(pointer, 0x00, SgConstructorInitializer::pool_size * sizeof(SgConstructorInitializer));
  191988             : #elif ROSE_ALLOC_MEMSET == 2
  191989             :         memset(pointer, 0xCC, SgConstructorInitializer::pool_size * sizeof(SgConstructorInitializer));
  191990             : #endif
  191991           1 :         SgConstructorInitializer::pools.push_back( (unsigned char*)(pointer) );
  191992           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgConstructorInitializer::pool_size * sizeof(SgConstructorInitializer), V_SgConstructorInitializer ) );
  191993             : 
  191994           1 :         if ( SgConstructorInitializer::next_node != NULL ) {
  191995           0 :           if ( blockIndex > 0 ) {
  191996           0 :             SgConstructorInitializer * blkptr = (SgConstructorInitializer*)(SgConstructorInitializer::pools[blockIndex-1]);
  191997           0 :             blkptr[ SgConstructorInitializer::pool_size - 1 ].set_freepointer(pointer);
  191998             :           }
  191999             :         } else {
  192000           1 :           SgConstructorInitializer::next_node = pointer;
  192001             :         }
  192002             : 
  192003        2000 :         for (unsigned i = 0; i < SgConstructorInitializer::pool_size-1; ++i)
  192004             :            {
  192005        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  192006             :            }
  192007           1 :         pointer[ SgConstructorInitializer::pool_size -1 ].set_freepointer(NULL);
  192008             : 
  192009           1 :         blockIndex++;
  192010             :       }
  192011           2 :   }
  192012             : 
  192013             : //############################################################################
  192014             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  192015             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  192016             :  * not compressed. However, that stuff is not yet implemented! 
  192017             :  */
  192018             : unsigned long
  192019           0 : SgConstructorInitializer::getNumberOfLastValidPointer()
  192020             :    {
  192021           0 :       SgConstructorInitializer* testPointer = (SgConstructorInitializer*)(SgConstructorInitializer::pools.back());
  192022           0 :       unsigned long localIndex = SgConstructorInitializer::pool_size - 1;
  192023           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  192024             :          {
  192025           0 :            localIndex--;
  192026             :          }
  192027           0 :       return (localIndex + SgConstructorInitializer::pool_size * (SgConstructorInitializer::pools.size()-1));
  192028             :    }
  192029             : 
  192030             : //############################################################################
  192031             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  192032             :  * memory pool and initializes the data member in class SgConstructorInitializerStroageClass
  192033             :  * from its counterpart of SgConstructorInitializer. The return value is just for checking, 
  192034             :  * that the whole StorageClassArray is initialized!
  192035             :  */
  192036             : unsigned long
  192037           1 : SgConstructorInitializer::initializeStorageClassArray( SgConstructorInitializerStorageClass *storageArray )
  192038             :    {
  192039           1 :      unsigned long storageCounter = 0;
  192040           1 :      std::vector < unsigned char* > :: const_iterator block = SgConstructorInitializer::pools.begin();
  192041           1 :      SgConstructorInitializer* pointer = NULL;
  192042           2 :      while ( block != SgConstructorInitializer::pools.end() ) {
  192043           1 :           pointer = (SgConstructorInitializer*) (*block);
  192044        2001 :           for ( unsigned i = 0; i < SgConstructorInitializer::pool_size; ++i ) {
  192045        2000 :                if ( pointer->get_freepointer() != NULL ) {
  192046         461 :                  storageArray->pickOutIRNodeData (pointer) ;
  192047         461 :                  storageArray++;
  192048         461 :                  storageCounter++;
  192049             :                }
  192050        2000 :                pointer++;
  192051             :              }
  192052           1 :            block++;
  192053             :         }
  192054           1 :      return storageCounter;
  192055             :    }
  192056             : 
  192057             : /* #line 192058 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  192058             : 
  192059             : 
  192060             : 
  192061             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  192062             : 
  192063             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  192064             : 
  192065             : //############################################################################
  192066             : /* JH (02/02/2006) Constructor of the IR node SgAssignInitializer that takes its 
  192067             :  * corresponding StorageClass as parameter
  192068             :  */
  192069        1193 : SgAssignInitializer :: SgAssignInitializer ( const SgAssignInitializerStorageClass& storageSource )   : SgInitializer (storageSource)
  192070             :    {
  192071             : 
  192072             : 
  192073             : /* #line 192074 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  192074             : 
  192075        1193 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  192076        1193 :      p_operand_i =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_i) );
  192077        1193 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  192078             : 
  192079             : 
  192080             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  192081             : 
  192082             : 
  192083        1193 :    }
  192084             : 
  192085             : //############################################################################
  192086             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  192087             :  * within the working AST. 
  192088             :  */
  192089        5965 : SgAssignInitializer * SgAssignInitializer::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  192090        5965 :      SgAssignInitializer* returnPointer = NULL;
  192091        5965 :      if ( globalIndex != 0 )
  192092             :         {
  192093             : 
  192094             : #if FILE_IO_EXTRA_CHECK
  192095        5965 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAssignInitializer ) ) <= globalIndex ) ;
  192096        5965 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssignInitializer + 1 ) ) );
  192097             : #endif
  192098        5965 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAssignInitializer )  
  192099        5965 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAssignInitializer );
  192100        5965 :           unsigned long positionInPool = localIndex % SgAssignInitializer::pool_size;
  192101        5965 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssignInitializer::pool_size;
  192102             : 
  192103             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  192104             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  192105             : 
  192106        5965 :           returnPointer = &( ( (SgAssignInitializer*)(SgAssignInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  192107             : 
  192108        5965 :           ROSE_ASSERT( returnPointer != NULL ) ;
  192109             :         }
  192110        5965 :      return returnPointer ;
  192111             :    }
  192112             : 
  192113             : //############################################################################
  192114             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  192115             :   for the AST with the index astIndex
  192116             : */
  192117           0 : SgAssignInitializer * SgAssignInitializer::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  192118           0 :      SgAssignInitializer* returnPointer = NULL;
  192119           0 :      if ( globalIndex != 0 )
  192120             :         {
  192121             : 
  192122             : #if FILE_IO_EXTRA_CHECK
  192123           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAssignInitializer ) ) <= globalIndex ) ;
  192124           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssignInitializer + 1 ) ) );
  192125             : #endif
  192126           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAssignInitializer )
  192127           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAssignInitializer );
  192128           0 :           unsigned long positionInPool = localIndex % SgAssignInitializer::pool_size ;
  192129           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAssignInitializer::pool_size ;
  192130             : 
  192131             : #if FILE_IO_EXTRA_CHECK
  192132             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  192133             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  192134             : #endif
  192135             : 
  192136           0 :           returnPointer = &( ( (SgAssignInitializer*)(SgAssignInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  192137             : 
  192138             : #if FILE_IO_EXTRA_CHECK
  192139           0 :           assert ( returnPointer != NULL ) ;
  192140             : #endif
  192141             :         }
  192142           0 :      return returnPointer ;
  192143             :    }
  192144             : 
  192145             : //############################################################################
  192146             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  192147             :  * pool size! We set for every valid object in the memory pool the freepointer
  192148             :  * to the global index and increase the global index afterwards. For all the 
  192149             :  * invalid objects (means address ranges within the memory pool that were not
  192150             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  192151             :  * distinguish valid from invalid objects! 
  192152             :  */
  192153             : unsigned long
  192154           5 : SgAssignInitializer::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  192155             :    {
  192156           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  192157           5 :      SgAssignInitializer* pointer = NULL;
  192158           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  192159           5 :      std::vector < unsigned char* > :: const_iterator block;
  192160           6 :      for ( block = SgAssignInitializer::pools.begin(); block != SgAssignInitializer::pools.end() ; ++block )
  192161             :         {
  192162           1 :           pointer = (SgAssignInitializer*)(*block);
  192163        2001 :           for (unsigned i = 0; i < SgAssignInitializer::pool_size; ++i )
  192164             :              {
  192165             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  192166             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  192167             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  192168             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  192169             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  192170             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  192171             :             // properly; so this will have to be checked next.
  192172             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  192173             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  192174        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  192175             :                   {
  192176        1193 :                     pointer[i].set_freepointer((SgAssignInitializer*)(globalIndex));
  192177        1193 :                     globalIndex++;
  192178             :                   }
  192179             :                else
  192180             :                   {
  192181         807 :                     pointer[i].set_freepointer(NULL);
  192182             :                   }
  192183             :               }
  192184             :         }
  192185           5 :      return globalIndex;
  192186             :    }
  192187             : 
  192188             : //############################################################################
  192189             : // JH (01/14/2006)
  192190             : void
  192191           5 : SgAssignInitializer::resetValidFreepointers( )
  192192             :    {
  192193           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  192194           5 :      SgAssignInitializer* pointer = NULL;
  192195           5 :      std::vector < unsigned char* > :: const_iterator block;
  192196           5 :      SgAssignInitializer* pointerOfLinkedList = NULL;
  192197           6 :      for ( block = SgAssignInitializer::pools.begin(); block != SgAssignInitializer::pools.end() ; ++block )
  192198             :         {
  192199           1 :           pointer = (SgAssignInitializer*)(*block);
  192200        2001 :           for (unsigned i = 0; i < SgAssignInitializer::pool_size; ++i )
  192201             :              {
  192202             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  192203             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  192204             :             // memory blocks!.
  192205        2000 :                if ( pointer[i].get_freepointer() != NULL )
  192206             :                   {
  192207        1193 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  192208             :                   }
  192209             :                else
  192210             :                   {
  192211         807 :                     if ( pointerOfLinkedList == NULL )
  192212             :                        {
  192213           1 :                          SgAssignInitializer::next_node = &(pointer[i]);
  192214             :                        }
  192215             :                     else
  192216             :                        {
  192217             :                       // printf ("In SgAssignInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  192218         806 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  192219             :                        }
  192220             :                     pointerOfLinkedList = &(pointer[i]);
  192221             :                   }
  192222             :               }
  192223             :         }
  192224             : 
  192225           5 :      if ( pointerOfLinkedList != NULL )
  192226             :         {
  192227             :        // printf ("In SgAssignInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  192228           1 :           pointerOfLinkedList->set_freepointer(NULL);
  192229             :        // DQ (6/6/2010): Temporary debugging...
  192230             :        //   ROSE_ASSERT(false);
  192231             :         }
  192232             : 
  192233           5 :      return ;
  192234             :    }
  192235             : 
  192236             : //############################################################################
  192237             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  192238             :  * within the memory pool and resets the freepointers, in order to achieve a 
  192239             :  * linked list, that has no jumps and starts at the beginning! This function 
  192240             :  * does not extend the memory pool, since we do not delete any memory blocks,
  192241             :  * but delete the valid objects.  
  192242             :  */
  192243             : void
  192244           0 : SgAssignInitializer::clearMemoryPool( )
  192245             :    {
  192246             :   // printf ("Inside of SgAssignInitializer::clearMemoryPool() \n");
  192247             : 
  192248           0 :      SgAssignInitializer* pointer = NULL, *tempPointer = NULL;
  192249           0 :      std::vector < unsigned char* > :: const_iterator block;
  192250           0 :      if ( SgAssignInitializer::pools.empty() == false )
  192251             :         {
  192252           0 :           block = SgAssignInitializer::pools.begin() ;
  192253           0 :           SgAssignInitializer::next_node = (SgAssignInitializer*) (*block);
  192254             : 
  192255           0 :           while ( block != SgAssignInitializer::pools.end() )
  192256             :              {
  192257           0 :                pointer = (SgAssignInitializer*) (*block);
  192258           0 :                if ( tempPointer != NULL )
  192259             :                   {
  192260           0 :                     tempPointer->set_freepointer(pointer);
  192261             :                   }
  192262           0 :                for (unsigned i = 0; i < SgAssignInitializer::pool_size - 1; ++i)
  192263             :                   {
  192264           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  192265             :                   }
  192266           0 :                 pointer[SgAssignInitializer::pool_size-1].set_freepointer(NULL);
  192267           0 :                 tempPointer = &(pointer[SgAssignInitializer::pool_size-1]);
  192268           0 :                 ++block;
  192269             :              }
  192270             :         }
  192271           0 :    }
  192272             : 
  192273           5 : void SgAssignInitializer::deleteMemoryPool() {
  192274           7 :   for (auto p: SgAssignInitializer::pools) {
  192275           2 :     ROSE_FREE(p);
  192276             :   }
  192277           5 :   SgAssignInitializer::next_node = nullptr;
  192278           5 :   SgAssignInitializer::pools.clear();
  192279           5 : }
  192280             : 
  192281             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  192282             : //                 reading multiple binary files to for a single AST.
  192283             : /////////// new version ////////////////////////////////
  192284             : //############################################################################
  192285             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  192286             : void
  192287           2 : SgAssignInitializer::extendMemoryPoolForFileIO( )
  192288             :   {
  192289           2 :     size_t blockIndex = SgAssignInitializer::pools.size();
  192290           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignInitializer) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignInitializer);
  192291             : 
  192292           3 :     while ( (blockIndex * SgAssignInitializer::pool_size) < newPoolSize)
  192293             :       {
  192294             : #if ROSE_ALLOC_TRACE
  192295             :         if (blockIndex > 0) {
  192296             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignInitializer) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignInitializer) = %" PRIuPTR " SgAssignInitializer::pool_size = %d \n",
  192297             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAssignInitializer),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAssignInitializer),SgAssignInitializer::pool_size);
  192298             :         }
  192299             : #endif
  192300             : 
  192301           1 :         SgAssignInitializer * pointer = (SgAssignInitializer*) ROSE_MALLOC ( SgAssignInitializer::pool_size * sizeof(SgAssignInitializer) );
  192302           1 :         assert( pointer != NULL );
  192303             : #if ROSE_ALLOC_MEMSET == 1
  192304             :         memset(pointer, 0x00, SgAssignInitializer::pool_size * sizeof(SgAssignInitializer));
  192305             : #elif ROSE_ALLOC_MEMSET == 2
  192306             :         memset(pointer, 0xCC, SgAssignInitializer::pool_size * sizeof(SgAssignInitializer));
  192307             : #endif
  192308           1 :         SgAssignInitializer::pools.push_back( (unsigned char*)(pointer) );
  192309           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAssignInitializer::pool_size * sizeof(SgAssignInitializer), V_SgAssignInitializer ) );
  192310             : 
  192311           1 :         if ( SgAssignInitializer::next_node != NULL ) {
  192312           0 :           if ( blockIndex > 0 ) {
  192313           0 :             SgAssignInitializer * blkptr = (SgAssignInitializer*)(SgAssignInitializer::pools[blockIndex-1]);
  192314           0 :             blkptr[ SgAssignInitializer::pool_size - 1 ].set_freepointer(pointer);
  192315             :           }
  192316             :         } else {
  192317           1 :           SgAssignInitializer::next_node = pointer;
  192318             :         }
  192319             : 
  192320        2000 :         for (unsigned i = 0; i < SgAssignInitializer::pool_size-1; ++i)
  192321             :            {
  192322        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  192323             :            }
  192324           1 :         pointer[ SgAssignInitializer::pool_size -1 ].set_freepointer(NULL);
  192325             : 
  192326           1 :         blockIndex++;
  192327             :       }
  192328           2 :   }
  192329             : 
  192330             : //############################################################################
  192331             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  192332             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  192333             :  * not compressed. However, that stuff is not yet implemented! 
  192334             :  */
  192335             : unsigned long
  192336           0 : SgAssignInitializer::getNumberOfLastValidPointer()
  192337             :    {
  192338           0 :       SgAssignInitializer* testPointer = (SgAssignInitializer*)(SgAssignInitializer::pools.back());
  192339           0 :       unsigned long localIndex = SgAssignInitializer::pool_size - 1;
  192340           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  192341             :          {
  192342           0 :            localIndex--;
  192343             :          }
  192344           0 :       return (localIndex + SgAssignInitializer::pool_size * (SgAssignInitializer::pools.size()-1));
  192345             :    }
  192346             : 
  192347             : //############################################################################
  192348             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  192349             :  * memory pool and initializes the data member in class SgAssignInitializerStroageClass
  192350             :  * from its counterpart of SgAssignInitializer. The return value is just for checking, 
  192351             :  * that the whole StorageClassArray is initialized!
  192352             :  */
  192353             : unsigned long
  192354           1 : SgAssignInitializer::initializeStorageClassArray( SgAssignInitializerStorageClass *storageArray )
  192355             :    {
  192356           1 :      unsigned long storageCounter = 0;
  192357           1 :      std::vector < unsigned char* > :: const_iterator block = SgAssignInitializer::pools.begin();
  192358           1 :      SgAssignInitializer* pointer = NULL;
  192359           2 :      while ( block != SgAssignInitializer::pools.end() ) {
  192360           1 :           pointer = (SgAssignInitializer*) (*block);
  192361        2001 :           for ( unsigned i = 0; i < SgAssignInitializer::pool_size; ++i ) {
  192362        2000 :                if ( pointer->get_freepointer() != NULL ) {
  192363        1193 :                  storageArray->pickOutIRNodeData (pointer) ;
  192364        1193 :                  storageArray++;
  192365        1193 :                  storageCounter++;
  192366             :                }
  192367        2000 :                pointer++;
  192368             :              }
  192369           1 :            block++;
  192370             :         }
  192371           1 :      return storageCounter;
  192372             :    }
  192373             : 
  192374             : /* #line 192375 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  192375             : 
  192376             : 
  192377             : 
  192378             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  192379             : 
  192380             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  192381             : 
  192382             : //############################################################################
  192383             : /* JH (02/02/2006) Constructor of the IR node SgDesignatedInitializer that takes its 
  192384             :  * corresponding StorageClass as parameter
  192385             :  */
  192386           0 : SgDesignatedInitializer :: SgDesignatedInitializer ( const SgDesignatedInitializerStorageClass& storageSource )   : SgInitializer (storageSource)
  192387             :    {
  192388             : 
  192389             : 
  192390             : /* #line 192391 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  192391             : 
  192392           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  192393           0 :      p_designatorList =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_designatorList) );
  192394           0 :      p_memberInit =  (SgInitializer*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_memberInit) );
  192395             : 
  192396             : 
  192397             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  192398             : 
  192399             : 
  192400           0 :    }
  192401             : 
  192402             : //############################################################################
  192403             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  192404             :  * within the working AST. 
  192405             :  */
  192406           0 : SgDesignatedInitializer * SgDesignatedInitializer::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  192407           0 :      SgDesignatedInitializer* returnPointer = NULL;
  192408           0 :      if ( globalIndex != 0 )
  192409             :         {
  192410             : 
  192411             : #if FILE_IO_EXTRA_CHECK
  192412           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDesignatedInitializer ) ) <= globalIndex ) ;
  192413           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDesignatedInitializer + 1 ) ) );
  192414             : #endif
  192415           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDesignatedInitializer )  
  192416           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDesignatedInitializer );
  192417           0 :           unsigned long positionInPool = localIndex % SgDesignatedInitializer::pool_size;
  192418           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDesignatedInitializer::pool_size;
  192419             : 
  192420             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  192421             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  192422             : 
  192423           0 :           returnPointer = &( ( (SgDesignatedInitializer*)(SgDesignatedInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  192424             : 
  192425           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  192426             :         }
  192427           0 :      return returnPointer ;
  192428             :    }
  192429             : 
  192430             : //############################################################################
  192431             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  192432             :   for the AST with the index astIndex
  192433             : */
  192434           0 : SgDesignatedInitializer * SgDesignatedInitializer::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  192435           0 :      SgDesignatedInitializer* returnPointer = NULL;
  192436           0 :      if ( globalIndex != 0 )
  192437             :         {
  192438             : 
  192439             : #if FILE_IO_EXTRA_CHECK
  192440           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDesignatedInitializer ) ) <= globalIndex ) ;
  192441           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDesignatedInitializer + 1 ) ) );
  192442             : #endif
  192443           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDesignatedInitializer )
  192444           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDesignatedInitializer );
  192445           0 :           unsigned long positionInPool = localIndex % SgDesignatedInitializer::pool_size ;
  192446           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDesignatedInitializer::pool_size ;
  192447             : 
  192448             : #if FILE_IO_EXTRA_CHECK
  192449             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  192450             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  192451             : #endif
  192452             : 
  192453           0 :           returnPointer = &( ( (SgDesignatedInitializer*)(SgDesignatedInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  192454             : 
  192455             : #if FILE_IO_EXTRA_CHECK
  192456           0 :           assert ( returnPointer != NULL ) ;
  192457             : #endif
  192458             :         }
  192459           0 :      return returnPointer ;
  192460             :    }
  192461             : 
  192462             : //############################################################################
  192463             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  192464             :  * pool size! We set for every valid object in the memory pool the freepointer
  192465             :  * to the global index and increase the global index afterwards. For all the 
  192466             :  * invalid objects (means address ranges within the memory pool that were not
  192467             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  192468             :  * distinguish valid from invalid objects! 
  192469             :  */
  192470             : unsigned long
  192471           5 : SgDesignatedInitializer::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  192472             :    {
  192473           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  192474           5 :      SgDesignatedInitializer* pointer = NULL;
  192475           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  192476           5 :      std::vector < unsigned char* > :: const_iterator block;
  192477           5 :      for ( block = SgDesignatedInitializer::pools.begin(); block != SgDesignatedInitializer::pools.end() ; ++block )
  192478             :         {
  192479           0 :           pointer = (SgDesignatedInitializer*)(*block);
  192480           0 :           for (unsigned i = 0; i < SgDesignatedInitializer::pool_size; ++i )
  192481             :              {
  192482             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  192483             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  192484             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  192485             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  192486             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  192487             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  192488             :             // properly; so this will have to be checked next.
  192489             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  192490             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  192491           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  192492             :                   {
  192493           0 :                     pointer[i].set_freepointer((SgDesignatedInitializer*)(globalIndex));
  192494           0 :                     globalIndex++;
  192495             :                   }
  192496             :                else
  192497             :                   {
  192498           0 :                     pointer[i].set_freepointer(NULL);
  192499             :                   }
  192500             :               }
  192501             :         }
  192502           5 :      return globalIndex;
  192503             :    }
  192504             : 
  192505             : //############################################################################
  192506             : // JH (01/14/2006)
  192507             : void
  192508           5 : SgDesignatedInitializer::resetValidFreepointers( )
  192509             :    {
  192510           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  192511           5 :      SgDesignatedInitializer* pointer = NULL;
  192512           5 :      std::vector < unsigned char* > :: const_iterator block;
  192513           5 :      SgDesignatedInitializer* pointerOfLinkedList = NULL;
  192514           5 :      for ( block = SgDesignatedInitializer::pools.begin(); block != SgDesignatedInitializer::pools.end() ; ++block )
  192515             :         {
  192516           0 :           pointer = (SgDesignatedInitializer*)(*block);
  192517           0 :           for (unsigned i = 0; i < SgDesignatedInitializer::pool_size; ++i )
  192518             :              {
  192519             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  192520             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  192521             :             // memory blocks!.
  192522           0 :                if ( pointer[i].get_freepointer() != NULL )
  192523             :                   {
  192524           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  192525             :                   }
  192526             :                else
  192527             :                   {
  192528           0 :                     if ( pointerOfLinkedList == NULL )
  192529             :                        {
  192530           0 :                          SgDesignatedInitializer::next_node = &(pointer[i]);
  192531             :                        }
  192532             :                     else
  192533             :                        {
  192534             :                       // printf ("In SgDesignatedInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  192535           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  192536             :                        }
  192537             :                     pointerOfLinkedList = &(pointer[i]);
  192538             :                   }
  192539             :               }
  192540             :         }
  192541             : 
  192542           5 :      if ( pointerOfLinkedList != NULL )
  192543             :         {
  192544             :        // printf ("In SgDesignatedInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  192545           0 :           pointerOfLinkedList->set_freepointer(NULL);
  192546             :        // DQ (6/6/2010): Temporary debugging...
  192547             :        //   ROSE_ASSERT(false);
  192548             :         }
  192549             : 
  192550           5 :      return ;
  192551             :    }
  192552             : 
  192553             : //############################################################################
  192554             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  192555             :  * within the memory pool and resets the freepointers, in order to achieve a 
  192556             :  * linked list, that has no jumps and starts at the beginning! This function 
  192557             :  * does not extend the memory pool, since we do not delete any memory blocks,
  192558             :  * but delete the valid objects.  
  192559             :  */
  192560             : void
  192561           0 : SgDesignatedInitializer::clearMemoryPool( )
  192562             :    {
  192563             :   // printf ("Inside of SgDesignatedInitializer::clearMemoryPool() \n");
  192564             : 
  192565           0 :      SgDesignatedInitializer* pointer = NULL, *tempPointer = NULL;
  192566           0 :      std::vector < unsigned char* > :: const_iterator block;
  192567           0 :      if ( SgDesignatedInitializer::pools.empty() == false )
  192568             :         {
  192569           0 :           block = SgDesignatedInitializer::pools.begin() ;
  192570           0 :           SgDesignatedInitializer::next_node = (SgDesignatedInitializer*) (*block);
  192571             : 
  192572           0 :           while ( block != SgDesignatedInitializer::pools.end() )
  192573             :              {
  192574           0 :                pointer = (SgDesignatedInitializer*) (*block);
  192575           0 :                if ( tempPointer != NULL )
  192576             :                   {
  192577           0 :                     tempPointer->set_freepointer(pointer);
  192578             :                   }
  192579           0 :                for (unsigned i = 0; i < SgDesignatedInitializer::pool_size - 1; ++i)
  192580             :                   {
  192581           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  192582             :                   }
  192583           0 :                 pointer[SgDesignatedInitializer::pool_size-1].set_freepointer(NULL);
  192584           0 :                 tempPointer = &(pointer[SgDesignatedInitializer::pool_size-1]);
  192585           0 :                 ++block;
  192586             :              }
  192587             :         }
  192588           0 :    }
  192589             : 
  192590           5 : void SgDesignatedInitializer::deleteMemoryPool() {
  192591           5 :   for (auto p: SgDesignatedInitializer::pools) {
  192592           0 :     ROSE_FREE(p);
  192593             :   }
  192594           5 :   SgDesignatedInitializer::next_node = nullptr;
  192595           5 :   SgDesignatedInitializer::pools.clear();
  192596           5 : }
  192597             : 
  192598             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  192599             : //                 reading multiple binary files to for a single AST.
  192600             : /////////// new version ////////////////////////////////
  192601             : //############################################################################
  192602             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  192603             : void
  192604           2 : SgDesignatedInitializer::extendMemoryPoolForFileIO( )
  192605             :   {
  192606           2 :     size_t blockIndex = SgDesignatedInitializer::pools.size();
  192607           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDesignatedInitializer) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDesignatedInitializer);
  192608             : 
  192609           2 :     while ( (blockIndex * SgDesignatedInitializer::pool_size) < newPoolSize)
  192610             :       {
  192611             : #if ROSE_ALLOC_TRACE
  192612             :         if (blockIndex > 0) {
  192613             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDesignatedInitializer) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDesignatedInitializer) = %" PRIuPTR " SgDesignatedInitializer::pool_size = %d \n",
  192614             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDesignatedInitializer),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDesignatedInitializer),SgDesignatedInitializer::pool_size);
  192615             :         }
  192616             : #endif
  192617             : 
  192618           0 :         SgDesignatedInitializer * pointer = (SgDesignatedInitializer*) ROSE_MALLOC ( SgDesignatedInitializer::pool_size * sizeof(SgDesignatedInitializer) );
  192619           0 :         assert( pointer != NULL );
  192620             : #if ROSE_ALLOC_MEMSET == 1
  192621             :         memset(pointer, 0x00, SgDesignatedInitializer::pool_size * sizeof(SgDesignatedInitializer));
  192622             : #elif ROSE_ALLOC_MEMSET == 2
  192623             :         memset(pointer, 0xCC, SgDesignatedInitializer::pool_size * sizeof(SgDesignatedInitializer));
  192624             : #endif
  192625           0 :         SgDesignatedInitializer::pools.push_back( (unsigned char*)(pointer) );
  192626           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDesignatedInitializer::pool_size * sizeof(SgDesignatedInitializer), V_SgDesignatedInitializer ) );
  192627             : 
  192628           0 :         if ( SgDesignatedInitializer::next_node != NULL ) {
  192629           0 :           if ( blockIndex > 0 ) {
  192630           0 :             SgDesignatedInitializer * blkptr = (SgDesignatedInitializer*)(SgDesignatedInitializer::pools[blockIndex-1]);
  192631           0 :             blkptr[ SgDesignatedInitializer::pool_size - 1 ].set_freepointer(pointer);
  192632             :           }
  192633             :         } else {
  192634           0 :           SgDesignatedInitializer::next_node = pointer;
  192635             :         }
  192636             : 
  192637           0 :         for (unsigned i = 0; i < SgDesignatedInitializer::pool_size-1; ++i)
  192638             :            {
  192639           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  192640             :            }
  192641           0 :         pointer[ SgDesignatedInitializer::pool_size -1 ].set_freepointer(NULL);
  192642             : 
  192643           0 :         blockIndex++;
  192644             :       }
  192645           2 :   }
  192646             : 
  192647             : //############################################################################
  192648             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  192649             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  192650             :  * not compressed. However, that stuff is not yet implemented! 
  192651             :  */
  192652             : unsigned long
  192653           0 : SgDesignatedInitializer::getNumberOfLastValidPointer()
  192654             :    {
  192655           0 :       SgDesignatedInitializer* testPointer = (SgDesignatedInitializer*)(SgDesignatedInitializer::pools.back());
  192656           0 :       unsigned long localIndex = SgDesignatedInitializer::pool_size - 1;
  192657           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  192658             :          {
  192659           0 :            localIndex--;
  192660             :          }
  192661           0 :       return (localIndex + SgDesignatedInitializer::pool_size * (SgDesignatedInitializer::pools.size()-1));
  192662             :    }
  192663             : 
  192664             : //############################################################################
  192665             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  192666             :  * memory pool and initializes the data member in class SgDesignatedInitializerStroageClass
  192667             :  * from its counterpart of SgDesignatedInitializer. The return value is just for checking, 
  192668             :  * that the whole StorageClassArray is initialized!
  192669             :  */
  192670             : unsigned long
  192671           0 : SgDesignatedInitializer::initializeStorageClassArray( SgDesignatedInitializerStorageClass *storageArray )
  192672             :    {
  192673           0 :      unsigned long storageCounter = 0;
  192674           0 :      std::vector < unsigned char* > :: const_iterator block = SgDesignatedInitializer::pools.begin();
  192675           0 :      SgDesignatedInitializer* pointer = NULL;
  192676           0 :      while ( block != SgDesignatedInitializer::pools.end() ) {
  192677           0 :           pointer = (SgDesignatedInitializer*) (*block);
  192678           0 :           for ( unsigned i = 0; i < SgDesignatedInitializer::pool_size; ++i ) {
  192679           0 :                if ( pointer->get_freepointer() != NULL ) {
  192680           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  192681           0 :                  storageArray++;
  192682           0 :                  storageCounter++;
  192683             :                }
  192684           0 :                pointer++;
  192685             :              }
  192686           0 :            block++;
  192687             :         }
  192688           0 :      return storageCounter;
  192689             :    }
  192690             : 
  192691             : /* #line 192692 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  192692             : 
  192693             : 
  192694             : 
  192695             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  192696             : 
  192697             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  192698             : 
  192699             : //############################################################################
  192700             : /* JH (02/02/2006) Constructor of the IR node SgBracedInitializer that takes its 
  192701             :  * corresponding StorageClass as parameter
  192702             :  */
  192703           1 : SgBracedInitializer :: SgBracedInitializer ( const SgBracedInitializerStorageClass& storageSource )   : SgInitializer (storageSource)
  192704             :    {
  192705             : 
  192706             : 
  192707             : /* #line 192708 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  192708             : 
  192709           1 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  192710           1 :      p_initializers =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_initializers) );
  192711           1 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  192712             : 
  192713             : 
  192714             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  192715             : 
  192716             : 
  192717           1 :    }
  192718             : 
  192719             : //############################################################################
  192720             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  192721             :  * within the working AST. 
  192722             :  */
  192723           5 : SgBracedInitializer * SgBracedInitializer::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  192724           5 :      SgBracedInitializer* returnPointer = NULL;
  192725           5 :      if ( globalIndex != 0 )
  192726             :         {
  192727             : 
  192728             : #if FILE_IO_EXTRA_CHECK
  192729           5 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgBracedInitializer ) ) <= globalIndex ) ;
  192730           5 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBracedInitializer + 1 ) ) );
  192731             : #endif
  192732           5 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgBracedInitializer )  
  192733           5 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgBracedInitializer );
  192734           5 :           unsigned long positionInPool = localIndex % SgBracedInitializer::pool_size;
  192735           5 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBracedInitializer::pool_size;
  192736             : 
  192737             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  192738             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  192739             : 
  192740           5 :           returnPointer = &( ( (SgBracedInitializer*)(SgBracedInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  192741             : 
  192742           5 :           ROSE_ASSERT( returnPointer != NULL ) ;
  192743             :         }
  192744           5 :      return returnPointer ;
  192745             :    }
  192746             : 
  192747             : //############################################################################
  192748             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  192749             :   for the AST with the index astIndex
  192750             : */
  192751           0 : SgBracedInitializer * SgBracedInitializer::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  192752           0 :      SgBracedInitializer* returnPointer = NULL;
  192753           0 :      if ( globalIndex != 0 )
  192754             :         {
  192755             : 
  192756             : #if FILE_IO_EXTRA_CHECK
  192757           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgBracedInitializer ) ) <= globalIndex ) ;
  192758           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBracedInitializer + 1 ) ) );
  192759             : #endif
  192760           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgBracedInitializer )
  192761           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgBracedInitializer );
  192762           0 :           unsigned long positionInPool = localIndex % SgBracedInitializer::pool_size ;
  192763           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgBracedInitializer::pool_size ;
  192764             : 
  192765             : #if FILE_IO_EXTRA_CHECK
  192766             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  192767             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  192768             : #endif
  192769             : 
  192770           0 :           returnPointer = &( ( (SgBracedInitializer*)(SgBracedInitializer::pools[memoryBlock]) ) [positionInPool]) ;
  192771             : 
  192772             : #if FILE_IO_EXTRA_CHECK
  192773           0 :           assert ( returnPointer != NULL ) ;
  192774             : #endif
  192775             :         }
  192776           0 :      return returnPointer ;
  192777             :    }
  192778             : 
  192779             : //############################################################################
  192780             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  192781             :  * pool size! We set for every valid object in the memory pool the freepointer
  192782             :  * to the global index and increase the global index afterwards. For all the 
  192783             :  * invalid objects (means address ranges within the memory pool that were not
  192784             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  192785             :  * distinguish valid from invalid objects! 
  192786             :  */
  192787             : unsigned long
  192788           5 : SgBracedInitializer::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  192789             :    {
  192790           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  192791           5 :      SgBracedInitializer* pointer = NULL;
  192792           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  192793           5 :      std::vector < unsigned char* > :: const_iterator block;
  192794           6 :      for ( block = SgBracedInitializer::pools.begin(); block != SgBracedInitializer::pools.end() ; ++block )
  192795             :         {
  192796           1 :           pointer = (SgBracedInitializer*)(*block);
  192797        2001 :           for (unsigned i = 0; i < SgBracedInitializer::pool_size; ++i )
  192798             :              {
  192799             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  192800             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  192801             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  192802             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  192803             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  192804             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  192805             :             // properly; so this will have to be checked next.
  192806             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  192807             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  192808        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  192809             :                   {
  192810           1 :                     pointer[i].set_freepointer((SgBracedInitializer*)(globalIndex));
  192811           1 :                     globalIndex++;
  192812             :                   }
  192813             :                else
  192814             :                   {
  192815        1999 :                     pointer[i].set_freepointer(NULL);
  192816             :                   }
  192817             :               }
  192818             :         }
  192819           5 :      return globalIndex;
  192820             :    }
  192821             : 
  192822             : //############################################################################
  192823             : // JH (01/14/2006)
  192824             : void
  192825           5 : SgBracedInitializer::resetValidFreepointers( )
  192826             :    {
  192827           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  192828           5 :      SgBracedInitializer* pointer = NULL;
  192829           5 :      std::vector < unsigned char* > :: const_iterator block;
  192830           5 :      SgBracedInitializer* pointerOfLinkedList = NULL;
  192831           6 :      for ( block = SgBracedInitializer::pools.begin(); block != SgBracedInitializer::pools.end() ; ++block )
  192832             :         {
  192833           1 :           pointer = (SgBracedInitializer*)(*block);
  192834        2001 :           for (unsigned i = 0; i < SgBracedInitializer::pool_size; ++i )
  192835             :              {
  192836             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  192837             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  192838             :             // memory blocks!.
  192839        2000 :                if ( pointer[i].get_freepointer() != NULL )
  192840             :                   {
  192841           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  192842             :                   }
  192843             :                else
  192844             :                   {
  192845        1999 :                     if ( pointerOfLinkedList == NULL )
  192846             :                        {
  192847           1 :                          SgBracedInitializer::next_node = &(pointer[i]);
  192848             :                        }
  192849             :                     else
  192850             :                        {
  192851             :                       // printf ("In SgBracedInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  192852        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  192853             :                        }
  192854             :                     pointerOfLinkedList = &(pointer[i]);
  192855             :                   }
  192856             :               }
  192857             :         }
  192858             : 
  192859           5 :      if ( pointerOfLinkedList != NULL )
  192860             :         {
  192861             :        // printf ("In SgBracedInitializer::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  192862           1 :           pointerOfLinkedList->set_freepointer(NULL);
  192863             :        // DQ (6/6/2010): Temporary debugging...
  192864             :        //   ROSE_ASSERT(false);
  192865             :         }
  192866             : 
  192867           5 :      return ;
  192868             :    }
  192869             : 
  192870             : //############################################################################
  192871             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  192872             :  * within the memory pool and resets the freepointers, in order to achieve a 
  192873             :  * linked list, that has no jumps and starts at the beginning! This function 
  192874             :  * does not extend the memory pool, since we do not delete any memory blocks,
  192875             :  * but delete the valid objects.  
  192876             :  */
  192877             : void
  192878           0 : SgBracedInitializer::clearMemoryPool( )
  192879             :    {
  192880             :   // printf ("Inside of SgBracedInitializer::clearMemoryPool() \n");
  192881             : 
  192882           0 :      SgBracedInitializer* pointer = NULL, *tempPointer = NULL;
  192883           0 :      std::vector < unsigned char* > :: const_iterator block;
  192884           0 :      if ( SgBracedInitializer::pools.empty() == false )
  192885             :         {
  192886           0 :           block = SgBracedInitializer::pools.begin() ;
  192887           0 :           SgBracedInitializer::next_node = (SgBracedInitializer*) (*block);
  192888             : 
  192889           0 :           while ( block != SgBracedInitializer::pools.end() )
  192890             :              {
  192891           0 :                pointer = (SgBracedInitializer*) (*block);
  192892           0 :                if ( tempPointer != NULL )
  192893             :                   {
  192894           0 :                     tempPointer->set_freepointer(pointer);
  192895             :                   }
  192896           0 :                for (unsigned i = 0; i < SgBracedInitializer::pool_size - 1; ++i)
  192897             :                   {
  192898           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  192899             :                   }
  192900           0 :                 pointer[SgBracedInitializer::pool_size-1].set_freepointer(NULL);
  192901           0 :                 tempPointer = &(pointer[SgBracedInitializer::pool_size-1]);
  192902           0 :                 ++block;
  192903             :              }
  192904             :         }
  192905           0 :    }
  192906             : 
  192907           5 : void SgBracedInitializer::deleteMemoryPool() {
  192908           7 :   for (auto p: SgBracedInitializer::pools) {
  192909           2 :     ROSE_FREE(p);
  192910             :   }
  192911           5 :   SgBracedInitializer::next_node = nullptr;
  192912           5 :   SgBracedInitializer::pools.clear();
  192913           5 : }
  192914             : 
  192915             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  192916             : //                 reading multiple binary files to for a single AST.
  192917             : /////////// new version ////////////////////////////////
  192918             : //############################################################################
  192919             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  192920             : void
  192921           2 : SgBracedInitializer::extendMemoryPoolForFileIO( )
  192922             :   {
  192923           2 :     size_t blockIndex = SgBracedInitializer::pools.size();
  192924           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgBracedInitializer) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgBracedInitializer);
  192925             : 
  192926           3 :     while ( (blockIndex * SgBracedInitializer::pool_size) < newPoolSize)
  192927             :       {
  192928             : #if ROSE_ALLOC_TRACE
  192929             :         if (blockIndex > 0) {
  192930             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgBracedInitializer) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgBracedInitializer) = %" PRIuPTR " SgBracedInitializer::pool_size = %d \n",
  192931             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgBracedInitializer),AST_FILE_IO::getPoolSizeOfNewAst(V_SgBracedInitializer),SgBracedInitializer::pool_size);
  192932             :         }
  192933             : #endif
  192934             : 
  192935           1 :         SgBracedInitializer * pointer = (SgBracedInitializer*) ROSE_MALLOC ( SgBracedInitializer::pool_size * sizeof(SgBracedInitializer) );
  192936           1 :         assert( pointer != NULL );
  192937             : #if ROSE_ALLOC_MEMSET == 1
  192938             :         memset(pointer, 0x00, SgBracedInitializer::pool_size * sizeof(SgBracedInitializer));
  192939             : #elif ROSE_ALLOC_MEMSET == 2
  192940             :         memset(pointer, 0xCC, SgBracedInitializer::pool_size * sizeof(SgBracedInitializer));
  192941             : #endif
  192942           1 :         SgBracedInitializer::pools.push_back( (unsigned char*)(pointer) );
  192943           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgBracedInitializer::pool_size * sizeof(SgBracedInitializer), V_SgBracedInitializer ) );
  192944             : 
  192945           1 :         if ( SgBracedInitializer::next_node != NULL ) {
  192946           0 :           if ( blockIndex > 0 ) {
  192947           0 :             SgBracedInitializer * blkptr = (SgBracedInitializer*)(SgBracedInitializer::pools[blockIndex-1]);
  192948           0 :             blkptr[ SgBracedInitializer::pool_size - 1 ].set_freepointer(pointer);
  192949             :           }
  192950             :         } else {
  192951           1 :           SgBracedInitializer::next_node = pointer;
  192952             :         }
  192953             : 
  192954        2000 :         for (unsigned i = 0; i < SgBracedInitializer::pool_size-1; ++i)
  192955             :            {
  192956        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  192957             :            }
  192958           1 :         pointer[ SgBracedInitializer::pool_size -1 ].set_freepointer(NULL);
  192959             : 
  192960           1 :         blockIndex++;
  192961             :       }
  192962           2 :   }
  192963             : 
  192964             : //############################################################################
  192965             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  192966             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  192967             :  * not compressed. However, that stuff is not yet implemented! 
  192968             :  */
  192969             : unsigned long
  192970           0 : SgBracedInitializer::getNumberOfLastValidPointer()
  192971             :    {
  192972           0 :       SgBracedInitializer* testPointer = (SgBracedInitializer*)(SgBracedInitializer::pools.back());
  192973           0 :       unsigned long localIndex = SgBracedInitializer::pool_size - 1;
  192974           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  192975             :          {
  192976           0 :            localIndex--;
  192977             :          }
  192978           0 :       return (localIndex + SgBracedInitializer::pool_size * (SgBracedInitializer::pools.size()-1));
  192979             :    }
  192980             : 
  192981             : //############################################################################
  192982             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  192983             :  * memory pool and initializes the data member in class SgBracedInitializerStroageClass
  192984             :  * from its counterpart of SgBracedInitializer. The return value is just for checking, 
  192985             :  * that the whole StorageClassArray is initialized!
  192986             :  */
  192987             : unsigned long
  192988           1 : SgBracedInitializer::initializeStorageClassArray( SgBracedInitializerStorageClass *storageArray )
  192989             :    {
  192990           1 :      unsigned long storageCounter = 0;
  192991           1 :      std::vector < unsigned char* > :: const_iterator block = SgBracedInitializer::pools.begin();
  192992           1 :      SgBracedInitializer* pointer = NULL;
  192993           2 :      while ( block != SgBracedInitializer::pools.end() ) {
  192994           1 :           pointer = (SgBracedInitializer*) (*block);
  192995        2001 :           for ( unsigned i = 0; i < SgBracedInitializer::pool_size; ++i ) {
  192996        2000 :                if ( pointer->get_freepointer() != NULL ) {
  192997           1 :                  storageArray->pickOutIRNodeData (pointer) ;
  192998           1 :                  storageArray++;
  192999           1 :                  storageCounter++;
  193000             :                }
  193001        2000 :                pointer++;
  193002             :              }
  193003           1 :            block++;
  193004             :         }
  193005           1 :      return storageCounter;
  193006             :    }
  193007             : 
  193008             : /* #line 193009 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  193009             : 
  193010             : 
  193011             : 
  193012             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  193013             : 
  193014             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  193015             : 
  193016             : //############################################################################
  193017             : /* JH (02/02/2006) Constructor of the IR node SgVarArgStartOp that takes its 
  193018             :  * corresponding StorageClass as parameter
  193019             :  */
  193020           0 : SgVarArgStartOp :: SgVarArgStartOp ( const SgVarArgStartOpStorageClass& storageSource )   : SgExpression (storageSource)
  193021             :    {
  193022             : 
  193023             : 
  193024             : /* #line 193025 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  193025             : 
  193026           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  193027           0 :      p_lhs_operand =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lhs_operand) );
  193028           0 :      p_rhs_operand =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_rhs_operand) );
  193029           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  193030             : 
  193031             : 
  193032             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  193033             : 
  193034             : 
  193035           0 :    }
  193036             : 
  193037             : //############################################################################
  193038             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  193039             :  * within the working AST. 
  193040             :  */
  193041           0 : SgVarArgStartOp * SgVarArgStartOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  193042           0 :      SgVarArgStartOp* returnPointer = NULL;
  193043           0 :      if ( globalIndex != 0 )
  193044             :         {
  193045             : 
  193046             : #if FILE_IO_EXTRA_CHECK
  193047           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVarArgStartOp ) ) <= globalIndex ) ;
  193048           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgStartOp + 1 ) ) );
  193049             : #endif
  193050           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgStartOp )  
  193051           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVarArgStartOp );
  193052           0 :           unsigned long positionInPool = localIndex % SgVarArgStartOp::pool_size;
  193053           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgStartOp::pool_size;
  193054             : 
  193055             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  193056             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  193057             : 
  193058           0 :           returnPointer = &( ( (SgVarArgStartOp*)(SgVarArgStartOp::pools[memoryBlock]) ) [positionInPool]) ;
  193059             : 
  193060           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  193061             :         }
  193062           0 :      return returnPointer ;
  193063             :    }
  193064             : 
  193065             : //############################################################################
  193066             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  193067             :   for the AST with the index astIndex
  193068             : */
  193069           0 : SgVarArgStartOp * SgVarArgStartOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  193070           0 :      SgVarArgStartOp* returnPointer = NULL;
  193071           0 :      if ( globalIndex != 0 )
  193072             :         {
  193073             : 
  193074             : #if FILE_IO_EXTRA_CHECK
  193075           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVarArgStartOp ) ) <= globalIndex ) ;
  193076           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgStartOp + 1 ) ) );
  193077             : #endif
  193078           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgStartOp )
  193079           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVarArgStartOp );
  193080           0 :           unsigned long positionInPool = localIndex % SgVarArgStartOp::pool_size ;
  193081           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgStartOp::pool_size ;
  193082             : 
  193083             : #if FILE_IO_EXTRA_CHECK
  193084             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  193085             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  193086             : #endif
  193087             : 
  193088           0 :           returnPointer = &( ( (SgVarArgStartOp*)(SgVarArgStartOp::pools[memoryBlock]) ) [positionInPool]) ;
  193089             : 
  193090             : #if FILE_IO_EXTRA_CHECK
  193091           0 :           assert ( returnPointer != NULL ) ;
  193092             : #endif
  193093             :         }
  193094           0 :      return returnPointer ;
  193095             :    }
  193096             : 
  193097             : //############################################################################
  193098             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  193099             :  * pool size! We set for every valid object in the memory pool the freepointer
  193100             :  * to the global index and increase the global index afterwards. For all the 
  193101             :  * invalid objects (means address ranges within the memory pool that were not
  193102             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  193103             :  * distinguish valid from invalid objects! 
  193104             :  */
  193105             : unsigned long
  193106           5 : SgVarArgStartOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  193107             :    {
  193108           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  193109           5 :      SgVarArgStartOp* pointer = NULL;
  193110           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  193111           5 :      std::vector < unsigned char* > :: const_iterator block;
  193112           5 :      for ( block = SgVarArgStartOp::pools.begin(); block != SgVarArgStartOp::pools.end() ; ++block )
  193113             :         {
  193114           0 :           pointer = (SgVarArgStartOp*)(*block);
  193115           0 :           for (unsigned i = 0; i < SgVarArgStartOp::pool_size; ++i )
  193116             :              {
  193117             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  193118             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  193119             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  193120             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  193121             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  193122             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  193123             :             // properly; so this will have to be checked next.
  193124             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  193125             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  193126           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  193127             :                   {
  193128           0 :                     pointer[i].set_freepointer((SgVarArgStartOp*)(globalIndex));
  193129           0 :                     globalIndex++;
  193130             :                   }
  193131             :                else
  193132             :                   {
  193133           0 :                     pointer[i].set_freepointer(NULL);
  193134             :                   }
  193135             :               }
  193136             :         }
  193137           5 :      return globalIndex;
  193138             :    }
  193139             : 
  193140             : //############################################################################
  193141             : // JH (01/14/2006)
  193142             : void
  193143           5 : SgVarArgStartOp::resetValidFreepointers( )
  193144             :    {
  193145           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  193146           5 :      SgVarArgStartOp* pointer = NULL;
  193147           5 :      std::vector < unsigned char* > :: const_iterator block;
  193148           5 :      SgVarArgStartOp* pointerOfLinkedList = NULL;
  193149           5 :      for ( block = SgVarArgStartOp::pools.begin(); block != SgVarArgStartOp::pools.end() ; ++block )
  193150             :         {
  193151           0 :           pointer = (SgVarArgStartOp*)(*block);
  193152           0 :           for (unsigned i = 0; i < SgVarArgStartOp::pool_size; ++i )
  193153             :              {
  193154             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  193155             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  193156             :             // memory blocks!.
  193157           0 :                if ( pointer[i].get_freepointer() != NULL )
  193158             :                   {
  193159           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  193160             :                   }
  193161             :                else
  193162             :                   {
  193163           0 :                     if ( pointerOfLinkedList == NULL )
  193164             :                        {
  193165           0 :                          SgVarArgStartOp::next_node = &(pointer[i]);
  193166             :                        }
  193167             :                     else
  193168             :                        {
  193169             :                       // printf ("In SgVarArgStartOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  193170           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  193171             :                        }
  193172             :                     pointerOfLinkedList = &(pointer[i]);
  193173             :                   }
  193174             :               }
  193175             :         }
  193176             : 
  193177           5 :      if ( pointerOfLinkedList != NULL )
  193178             :         {
  193179             :        // printf ("In SgVarArgStartOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  193180           0 :           pointerOfLinkedList->set_freepointer(NULL);
  193181             :        // DQ (6/6/2010): Temporary debugging...
  193182             :        //   ROSE_ASSERT(false);
  193183             :         }
  193184             : 
  193185           5 :      return ;
  193186             :    }
  193187             : 
  193188             : //############################################################################
  193189             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  193190             :  * within the memory pool and resets the freepointers, in order to achieve a 
  193191             :  * linked list, that has no jumps and starts at the beginning! This function 
  193192             :  * does not extend the memory pool, since we do not delete any memory blocks,
  193193             :  * but delete the valid objects.  
  193194             :  */
  193195             : void
  193196           0 : SgVarArgStartOp::clearMemoryPool( )
  193197             :    {
  193198             :   // printf ("Inside of SgVarArgStartOp::clearMemoryPool() \n");
  193199             : 
  193200           0 :      SgVarArgStartOp* pointer = NULL, *tempPointer = NULL;
  193201           0 :      std::vector < unsigned char* > :: const_iterator block;
  193202           0 :      if ( SgVarArgStartOp::pools.empty() == false )
  193203             :         {
  193204           0 :           block = SgVarArgStartOp::pools.begin() ;
  193205           0 :           SgVarArgStartOp::next_node = (SgVarArgStartOp*) (*block);
  193206             : 
  193207           0 :           while ( block != SgVarArgStartOp::pools.end() )
  193208             :              {
  193209           0 :                pointer = (SgVarArgStartOp*) (*block);
  193210           0 :                if ( tempPointer != NULL )
  193211             :                   {
  193212           0 :                     tempPointer->set_freepointer(pointer);
  193213             :                   }
  193214           0 :                for (unsigned i = 0; i < SgVarArgStartOp::pool_size - 1; ++i)
  193215             :                   {
  193216           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  193217             :                   }
  193218           0 :                 pointer[SgVarArgStartOp::pool_size-1].set_freepointer(NULL);
  193219           0 :                 tempPointer = &(pointer[SgVarArgStartOp::pool_size-1]);
  193220           0 :                 ++block;
  193221             :              }
  193222             :         }
  193223           0 :    }
  193224             : 
  193225           5 : void SgVarArgStartOp::deleteMemoryPool() {
  193226           5 :   for (auto p: SgVarArgStartOp::pools) {
  193227           0 :     ROSE_FREE(p);
  193228             :   }
  193229           5 :   SgVarArgStartOp::next_node = nullptr;
  193230           5 :   SgVarArgStartOp::pools.clear();
  193231           5 : }
  193232             : 
  193233             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  193234             : //                 reading multiple binary files to for a single AST.
  193235             : /////////// new version ////////////////////////////////
  193236             : //############################################################################
  193237             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  193238             : void
  193239           2 : SgVarArgStartOp::extendMemoryPoolForFileIO( )
  193240             :   {
  193241           2 :     size_t blockIndex = SgVarArgStartOp::pools.size();
  193242           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgStartOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgStartOp);
  193243             : 
  193244           2 :     while ( (blockIndex * SgVarArgStartOp::pool_size) < newPoolSize)
  193245             :       {
  193246             : #if ROSE_ALLOC_TRACE
  193247             :         if (blockIndex > 0) {
  193248             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgStartOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgStartOp) = %" PRIuPTR " SgVarArgStartOp::pool_size = %d \n",
  193249             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgStartOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgStartOp),SgVarArgStartOp::pool_size);
  193250             :         }
  193251             : #endif
  193252             : 
  193253           0 :         SgVarArgStartOp * pointer = (SgVarArgStartOp*) ROSE_MALLOC ( SgVarArgStartOp::pool_size * sizeof(SgVarArgStartOp) );
  193254           0 :         assert( pointer != NULL );
  193255             : #if ROSE_ALLOC_MEMSET == 1
  193256             :         memset(pointer, 0x00, SgVarArgStartOp::pool_size * sizeof(SgVarArgStartOp));
  193257             : #elif ROSE_ALLOC_MEMSET == 2
  193258             :         memset(pointer, 0xCC, SgVarArgStartOp::pool_size * sizeof(SgVarArgStartOp));
  193259             : #endif
  193260           0 :         SgVarArgStartOp::pools.push_back( (unsigned char*)(pointer) );
  193261           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVarArgStartOp::pool_size * sizeof(SgVarArgStartOp), V_SgVarArgStartOp ) );
  193262             : 
  193263           0 :         if ( SgVarArgStartOp::next_node != NULL ) {
  193264           0 :           if ( blockIndex > 0 ) {
  193265           0 :             SgVarArgStartOp * blkptr = (SgVarArgStartOp*)(SgVarArgStartOp::pools[blockIndex-1]);
  193266           0 :             blkptr[ SgVarArgStartOp::pool_size - 1 ].set_freepointer(pointer);
  193267             :           }
  193268             :         } else {
  193269           0 :           SgVarArgStartOp::next_node = pointer;
  193270             :         }
  193271             : 
  193272           0 :         for (unsigned i = 0; i < SgVarArgStartOp::pool_size-1; ++i)
  193273             :            {
  193274           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  193275             :            }
  193276           0 :         pointer[ SgVarArgStartOp::pool_size -1 ].set_freepointer(NULL);
  193277             : 
  193278           0 :         blockIndex++;
  193279             :       }
  193280           2 :   }
  193281             : 
  193282             : //############################################################################
  193283             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  193284             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  193285             :  * not compressed. However, that stuff is not yet implemented! 
  193286             :  */
  193287             : unsigned long
  193288           0 : SgVarArgStartOp::getNumberOfLastValidPointer()
  193289             :    {
  193290           0 :       SgVarArgStartOp* testPointer = (SgVarArgStartOp*)(SgVarArgStartOp::pools.back());
  193291           0 :       unsigned long localIndex = SgVarArgStartOp::pool_size - 1;
  193292           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  193293             :          {
  193294           0 :            localIndex--;
  193295             :          }
  193296           0 :       return (localIndex + SgVarArgStartOp::pool_size * (SgVarArgStartOp::pools.size()-1));
  193297             :    }
  193298             : 
  193299             : //############################################################################
  193300             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  193301             :  * memory pool and initializes the data member in class SgVarArgStartOpStroageClass
  193302             :  * from its counterpart of SgVarArgStartOp. The return value is just for checking, 
  193303             :  * that the whole StorageClassArray is initialized!
  193304             :  */
  193305             : unsigned long
  193306           0 : SgVarArgStartOp::initializeStorageClassArray( SgVarArgStartOpStorageClass *storageArray )
  193307             :    {
  193308           0 :      unsigned long storageCounter = 0;
  193309           0 :      std::vector < unsigned char* > :: const_iterator block = SgVarArgStartOp::pools.begin();
  193310           0 :      SgVarArgStartOp* pointer = NULL;
  193311           0 :      while ( block != SgVarArgStartOp::pools.end() ) {
  193312           0 :           pointer = (SgVarArgStartOp*) (*block);
  193313           0 :           for ( unsigned i = 0; i < SgVarArgStartOp::pool_size; ++i ) {
  193314           0 :                if ( pointer->get_freepointer() != NULL ) {
  193315           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  193316           0 :                  storageArray++;
  193317           0 :                  storageCounter++;
  193318             :                }
  193319           0 :                pointer++;
  193320             :              }
  193321           0 :            block++;
  193322             :         }
  193323           0 :      return storageCounter;
  193324             :    }
  193325             : 
  193326             : /* #line 193327 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  193327             : 
  193328             : 
  193329             : 
  193330             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  193331             : 
  193332             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  193333             : 
  193334             : //############################################################################
  193335             : /* JH (02/02/2006) Constructor of the IR node SgVarArgOp that takes its 
  193336             :  * corresponding StorageClass as parameter
  193337             :  */
  193338           0 : SgVarArgOp :: SgVarArgOp ( const SgVarArgOpStorageClass& storageSource )   : SgExpression (storageSource)
  193339             :    {
  193340             : 
  193341             : 
  193342             : /* #line 193343 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  193343             : 
  193344           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  193345           0 :      p_operand_expr =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_expr) );
  193346           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  193347             : 
  193348             : 
  193349             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  193350             : 
  193351             : 
  193352           0 :    }
  193353             : 
  193354             : //############################################################################
  193355             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  193356             :  * within the working AST. 
  193357             :  */
  193358           0 : SgVarArgOp * SgVarArgOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  193359           0 :      SgVarArgOp* returnPointer = NULL;
  193360           0 :      if ( globalIndex != 0 )
  193361             :         {
  193362             : 
  193363             : #if FILE_IO_EXTRA_CHECK
  193364           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVarArgOp ) ) <= globalIndex ) ;
  193365           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgOp + 1 ) ) );
  193366             : #endif
  193367           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgOp )  
  193368           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVarArgOp );
  193369           0 :           unsigned long positionInPool = localIndex % SgVarArgOp::pool_size;
  193370           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgOp::pool_size;
  193371             : 
  193372             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  193373             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  193374             : 
  193375           0 :           returnPointer = &( ( (SgVarArgOp*)(SgVarArgOp::pools[memoryBlock]) ) [positionInPool]) ;
  193376             : 
  193377           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  193378             :         }
  193379           0 :      return returnPointer ;
  193380             :    }
  193381             : 
  193382             : //############################################################################
  193383             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  193384             :   for the AST with the index astIndex
  193385             : */
  193386           0 : SgVarArgOp * SgVarArgOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  193387           0 :      SgVarArgOp* returnPointer = NULL;
  193388           0 :      if ( globalIndex != 0 )
  193389             :         {
  193390             : 
  193391             : #if FILE_IO_EXTRA_CHECK
  193392           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVarArgOp ) ) <= globalIndex ) ;
  193393           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgOp + 1 ) ) );
  193394             : #endif
  193395           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgOp )
  193396           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVarArgOp );
  193397           0 :           unsigned long positionInPool = localIndex % SgVarArgOp::pool_size ;
  193398           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgOp::pool_size ;
  193399             : 
  193400             : #if FILE_IO_EXTRA_CHECK
  193401             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  193402             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  193403             : #endif
  193404             : 
  193405           0 :           returnPointer = &( ( (SgVarArgOp*)(SgVarArgOp::pools[memoryBlock]) ) [positionInPool]) ;
  193406             : 
  193407             : #if FILE_IO_EXTRA_CHECK
  193408           0 :           assert ( returnPointer != NULL ) ;
  193409             : #endif
  193410             :         }
  193411           0 :      return returnPointer ;
  193412             :    }
  193413             : 
  193414             : //############################################################################
  193415             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  193416             :  * pool size! We set for every valid object in the memory pool the freepointer
  193417             :  * to the global index and increase the global index afterwards. For all the 
  193418             :  * invalid objects (means address ranges within the memory pool that were not
  193419             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  193420             :  * distinguish valid from invalid objects! 
  193421             :  */
  193422             : unsigned long
  193423           5 : SgVarArgOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  193424             :    {
  193425           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  193426           5 :      SgVarArgOp* pointer = NULL;
  193427           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  193428           5 :      std::vector < unsigned char* > :: const_iterator block;
  193429           5 :      for ( block = SgVarArgOp::pools.begin(); block != SgVarArgOp::pools.end() ; ++block )
  193430             :         {
  193431           0 :           pointer = (SgVarArgOp*)(*block);
  193432           0 :           for (unsigned i = 0; i < SgVarArgOp::pool_size; ++i )
  193433             :              {
  193434             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  193435             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  193436             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  193437             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  193438             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  193439             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  193440             :             // properly; so this will have to be checked next.
  193441             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  193442             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  193443           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  193444             :                   {
  193445           0 :                     pointer[i].set_freepointer((SgVarArgOp*)(globalIndex));
  193446           0 :                     globalIndex++;
  193447             :                   }
  193448             :                else
  193449             :                   {
  193450           0 :                     pointer[i].set_freepointer(NULL);
  193451             :                   }
  193452             :               }
  193453             :         }
  193454           5 :      return globalIndex;
  193455             :    }
  193456             : 
  193457             : //############################################################################
  193458             : // JH (01/14/2006)
  193459             : void
  193460           5 : SgVarArgOp::resetValidFreepointers( )
  193461             :    {
  193462           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  193463           5 :      SgVarArgOp* pointer = NULL;
  193464           5 :      std::vector < unsigned char* > :: const_iterator block;
  193465           5 :      SgVarArgOp* pointerOfLinkedList = NULL;
  193466           5 :      for ( block = SgVarArgOp::pools.begin(); block != SgVarArgOp::pools.end() ; ++block )
  193467             :         {
  193468           0 :           pointer = (SgVarArgOp*)(*block);
  193469           0 :           for (unsigned i = 0; i < SgVarArgOp::pool_size; ++i )
  193470             :              {
  193471             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  193472             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  193473             :             // memory blocks!.
  193474           0 :                if ( pointer[i].get_freepointer() != NULL )
  193475             :                   {
  193476           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  193477             :                   }
  193478             :                else
  193479             :                   {
  193480           0 :                     if ( pointerOfLinkedList == NULL )
  193481             :                        {
  193482           0 :                          SgVarArgOp::next_node = &(pointer[i]);
  193483             :                        }
  193484             :                     else
  193485             :                        {
  193486             :                       // printf ("In SgVarArgOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  193487           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  193488             :                        }
  193489             :                     pointerOfLinkedList = &(pointer[i]);
  193490             :                   }
  193491             :               }
  193492             :         }
  193493             : 
  193494           5 :      if ( pointerOfLinkedList != NULL )
  193495             :         {
  193496             :        // printf ("In SgVarArgOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  193497           0 :           pointerOfLinkedList->set_freepointer(NULL);
  193498             :        // DQ (6/6/2010): Temporary debugging...
  193499             :        //   ROSE_ASSERT(false);
  193500             :         }
  193501             : 
  193502           5 :      return ;
  193503             :    }
  193504             : 
  193505             : //############################################################################
  193506             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  193507             :  * within the memory pool and resets the freepointers, in order to achieve a 
  193508             :  * linked list, that has no jumps and starts at the beginning! This function 
  193509             :  * does not extend the memory pool, since we do not delete any memory blocks,
  193510             :  * but delete the valid objects.  
  193511             :  */
  193512             : void
  193513           0 : SgVarArgOp::clearMemoryPool( )
  193514             :    {
  193515             :   // printf ("Inside of SgVarArgOp::clearMemoryPool() \n");
  193516             : 
  193517           0 :      SgVarArgOp* pointer = NULL, *tempPointer = NULL;
  193518           0 :      std::vector < unsigned char* > :: const_iterator block;
  193519           0 :      if ( SgVarArgOp::pools.empty() == false )
  193520             :         {
  193521           0 :           block = SgVarArgOp::pools.begin() ;
  193522           0 :           SgVarArgOp::next_node = (SgVarArgOp*) (*block);
  193523             : 
  193524           0 :           while ( block != SgVarArgOp::pools.end() )
  193525             :              {
  193526           0 :                pointer = (SgVarArgOp*) (*block);
  193527           0 :                if ( tempPointer != NULL )
  193528             :                   {
  193529           0 :                     tempPointer->set_freepointer(pointer);
  193530             :                   }
  193531           0 :                for (unsigned i = 0; i < SgVarArgOp::pool_size - 1; ++i)
  193532             :                   {
  193533           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  193534             :                   }
  193535           0 :                 pointer[SgVarArgOp::pool_size-1].set_freepointer(NULL);
  193536           0 :                 tempPointer = &(pointer[SgVarArgOp::pool_size-1]);
  193537           0 :                 ++block;
  193538             :              }
  193539             :         }
  193540           0 :    }
  193541             : 
  193542           5 : void SgVarArgOp::deleteMemoryPool() {
  193543           5 :   for (auto p: SgVarArgOp::pools) {
  193544           0 :     ROSE_FREE(p);
  193545             :   }
  193546           5 :   SgVarArgOp::next_node = nullptr;
  193547           5 :   SgVarArgOp::pools.clear();
  193548           5 : }
  193549             : 
  193550             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  193551             : //                 reading multiple binary files to for a single AST.
  193552             : /////////// new version ////////////////////////////////
  193553             : //############################################################################
  193554             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  193555             : void
  193556           2 : SgVarArgOp::extendMemoryPoolForFileIO( )
  193557             :   {
  193558           2 :     size_t blockIndex = SgVarArgOp::pools.size();
  193559           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgOp);
  193560             : 
  193561           2 :     while ( (blockIndex * SgVarArgOp::pool_size) < newPoolSize)
  193562             :       {
  193563             : #if ROSE_ALLOC_TRACE
  193564             :         if (blockIndex > 0) {
  193565             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgOp) = %" PRIuPTR " SgVarArgOp::pool_size = %d \n",
  193566             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgOp),SgVarArgOp::pool_size);
  193567             :         }
  193568             : #endif
  193569             : 
  193570           0 :         SgVarArgOp * pointer = (SgVarArgOp*) ROSE_MALLOC ( SgVarArgOp::pool_size * sizeof(SgVarArgOp) );
  193571           0 :         assert( pointer != NULL );
  193572             : #if ROSE_ALLOC_MEMSET == 1
  193573             :         memset(pointer, 0x00, SgVarArgOp::pool_size * sizeof(SgVarArgOp));
  193574             : #elif ROSE_ALLOC_MEMSET == 2
  193575             :         memset(pointer, 0xCC, SgVarArgOp::pool_size * sizeof(SgVarArgOp));
  193576             : #endif
  193577           0 :         SgVarArgOp::pools.push_back( (unsigned char*)(pointer) );
  193578           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVarArgOp::pool_size * sizeof(SgVarArgOp), V_SgVarArgOp ) );
  193579             : 
  193580           0 :         if ( SgVarArgOp::next_node != NULL ) {
  193581           0 :           if ( blockIndex > 0 ) {
  193582           0 :             SgVarArgOp * blkptr = (SgVarArgOp*)(SgVarArgOp::pools[blockIndex-1]);
  193583           0 :             blkptr[ SgVarArgOp::pool_size - 1 ].set_freepointer(pointer);
  193584             :           }
  193585             :         } else {
  193586           0 :           SgVarArgOp::next_node = pointer;
  193587             :         }
  193588             : 
  193589           0 :         for (unsigned i = 0; i < SgVarArgOp::pool_size-1; ++i)
  193590             :            {
  193591           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  193592             :            }
  193593           0 :         pointer[ SgVarArgOp::pool_size -1 ].set_freepointer(NULL);
  193594             : 
  193595           0 :         blockIndex++;
  193596             :       }
  193597           2 :   }
  193598             : 
  193599             : //############################################################################
  193600             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  193601             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  193602             :  * not compressed. However, that stuff is not yet implemented! 
  193603             :  */
  193604             : unsigned long
  193605           0 : SgVarArgOp::getNumberOfLastValidPointer()
  193606             :    {
  193607           0 :       SgVarArgOp* testPointer = (SgVarArgOp*)(SgVarArgOp::pools.back());
  193608           0 :       unsigned long localIndex = SgVarArgOp::pool_size - 1;
  193609           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  193610             :          {
  193611           0 :            localIndex--;
  193612             :          }
  193613           0 :       return (localIndex + SgVarArgOp::pool_size * (SgVarArgOp::pools.size()-1));
  193614             :    }
  193615             : 
  193616             : //############################################################################
  193617             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  193618             :  * memory pool and initializes the data member in class SgVarArgOpStroageClass
  193619             :  * from its counterpart of SgVarArgOp. The return value is just for checking, 
  193620             :  * that the whole StorageClassArray is initialized!
  193621             :  */
  193622             : unsigned long
  193623           0 : SgVarArgOp::initializeStorageClassArray( SgVarArgOpStorageClass *storageArray )
  193624             :    {
  193625           0 :      unsigned long storageCounter = 0;
  193626           0 :      std::vector < unsigned char* > :: const_iterator block = SgVarArgOp::pools.begin();
  193627           0 :      SgVarArgOp* pointer = NULL;
  193628           0 :      while ( block != SgVarArgOp::pools.end() ) {
  193629           0 :           pointer = (SgVarArgOp*) (*block);
  193630           0 :           for ( unsigned i = 0; i < SgVarArgOp::pool_size; ++i ) {
  193631           0 :                if ( pointer->get_freepointer() != NULL ) {
  193632           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  193633           0 :                  storageArray++;
  193634           0 :                  storageCounter++;
  193635             :                }
  193636           0 :                pointer++;
  193637             :              }
  193638           0 :            block++;
  193639             :         }
  193640           0 :      return storageCounter;
  193641             :    }
  193642             : 
  193643             : /* #line 193644 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  193644             : 
  193645             : 
  193646             : 
  193647             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  193648             : 
  193649             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  193650             : 
  193651             : //############################################################################
  193652             : /* JH (02/02/2006) Constructor of the IR node SgVarArgEndOp that takes its 
  193653             :  * corresponding StorageClass as parameter
  193654             :  */
  193655           0 : SgVarArgEndOp :: SgVarArgEndOp ( const SgVarArgEndOpStorageClass& storageSource )   : SgExpression (storageSource)
  193656             :    {
  193657             : 
  193658             : 
  193659             : /* #line 193660 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  193660             : 
  193661           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  193662           0 :      p_operand_expr =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_expr) );
  193663           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  193664             : 
  193665             : 
  193666             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  193667             : 
  193668             : 
  193669           0 :    }
  193670             : 
  193671             : //############################################################################
  193672             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  193673             :  * within the working AST. 
  193674             :  */
  193675           0 : SgVarArgEndOp * SgVarArgEndOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  193676           0 :      SgVarArgEndOp* returnPointer = NULL;
  193677           0 :      if ( globalIndex != 0 )
  193678             :         {
  193679             : 
  193680             : #if FILE_IO_EXTRA_CHECK
  193681           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVarArgEndOp ) ) <= globalIndex ) ;
  193682           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgEndOp + 1 ) ) );
  193683             : #endif
  193684           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgEndOp )  
  193685           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVarArgEndOp );
  193686           0 :           unsigned long positionInPool = localIndex % SgVarArgEndOp::pool_size;
  193687           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgEndOp::pool_size;
  193688             : 
  193689             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  193690             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  193691             : 
  193692           0 :           returnPointer = &( ( (SgVarArgEndOp*)(SgVarArgEndOp::pools[memoryBlock]) ) [positionInPool]) ;
  193693             : 
  193694           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  193695             :         }
  193696           0 :      return returnPointer ;
  193697             :    }
  193698             : 
  193699             : //############################################################################
  193700             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  193701             :   for the AST with the index astIndex
  193702             : */
  193703           0 : SgVarArgEndOp * SgVarArgEndOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  193704           0 :      SgVarArgEndOp* returnPointer = NULL;
  193705           0 :      if ( globalIndex != 0 )
  193706             :         {
  193707             : 
  193708             : #if FILE_IO_EXTRA_CHECK
  193709           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVarArgEndOp ) ) <= globalIndex ) ;
  193710           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgEndOp + 1 ) ) );
  193711             : #endif
  193712           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgEndOp )
  193713           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVarArgEndOp );
  193714           0 :           unsigned long positionInPool = localIndex % SgVarArgEndOp::pool_size ;
  193715           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgEndOp::pool_size ;
  193716             : 
  193717             : #if FILE_IO_EXTRA_CHECK
  193718             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  193719             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  193720             : #endif
  193721             : 
  193722           0 :           returnPointer = &( ( (SgVarArgEndOp*)(SgVarArgEndOp::pools[memoryBlock]) ) [positionInPool]) ;
  193723             : 
  193724             : #if FILE_IO_EXTRA_CHECK
  193725           0 :           assert ( returnPointer != NULL ) ;
  193726             : #endif
  193727             :         }
  193728           0 :      return returnPointer ;
  193729             :    }
  193730             : 
  193731             : //############################################################################
  193732             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  193733             :  * pool size! We set for every valid object in the memory pool the freepointer
  193734             :  * to the global index and increase the global index afterwards. For all the 
  193735             :  * invalid objects (means address ranges within the memory pool that were not
  193736             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  193737             :  * distinguish valid from invalid objects! 
  193738             :  */
  193739             : unsigned long
  193740           5 : SgVarArgEndOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  193741             :    {
  193742           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  193743           5 :      SgVarArgEndOp* pointer = NULL;
  193744           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  193745           5 :      std::vector < unsigned char* > :: const_iterator block;
  193746           5 :      for ( block = SgVarArgEndOp::pools.begin(); block != SgVarArgEndOp::pools.end() ; ++block )
  193747             :         {
  193748           0 :           pointer = (SgVarArgEndOp*)(*block);
  193749           0 :           for (unsigned i = 0; i < SgVarArgEndOp::pool_size; ++i )
  193750             :              {
  193751             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  193752             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  193753             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  193754             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  193755             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  193756             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  193757             :             // properly; so this will have to be checked next.
  193758             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  193759             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  193760           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  193761             :                   {
  193762           0 :                     pointer[i].set_freepointer((SgVarArgEndOp*)(globalIndex));
  193763           0 :                     globalIndex++;
  193764             :                   }
  193765             :                else
  193766             :                   {
  193767           0 :                     pointer[i].set_freepointer(NULL);
  193768             :                   }
  193769             :               }
  193770             :         }
  193771           5 :      return globalIndex;
  193772             :    }
  193773             : 
  193774             : //############################################################################
  193775             : // JH (01/14/2006)
  193776             : void
  193777           5 : SgVarArgEndOp::resetValidFreepointers( )
  193778             :    {
  193779           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  193780           5 :      SgVarArgEndOp* pointer = NULL;
  193781           5 :      std::vector < unsigned char* > :: const_iterator block;
  193782           5 :      SgVarArgEndOp* pointerOfLinkedList = NULL;
  193783           5 :      for ( block = SgVarArgEndOp::pools.begin(); block != SgVarArgEndOp::pools.end() ; ++block )
  193784             :         {
  193785           0 :           pointer = (SgVarArgEndOp*)(*block);
  193786           0 :           for (unsigned i = 0; i < SgVarArgEndOp::pool_size; ++i )
  193787             :              {
  193788             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  193789             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  193790             :             // memory blocks!.
  193791           0 :                if ( pointer[i].get_freepointer() != NULL )
  193792             :                   {
  193793           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  193794             :                   }
  193795             :                else
  193796             :                   {
  193797           0 :                     if ( pointerOfLinkedList == NULL )
  193798             :                        {
  193799           0 :                          SgVarArgEndOp::next_node = &(pointer[i]);
  193800             :                        }
  193801             :                     else
  193802             :                        {
  193803             :                       // printf ("In SgVarArgEndOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  193804           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  193805             :                        }
  193806             :                     pointerOfLinkedList = &(pointer[i]);
  193807             :                   }
  193808             :               }
  193809             :         }
  193810             : 
  193811           5 :      if ( pointerOfLinkedList != NULL )
  193812             :         {
  193813             :        // printf ("In SgVarArgEndOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  193814           0 :           pointerOfLinkedList->set_freepointer(NULL);
  193815             :        // DQ (6/6/2010): Temporary debugging...
  193816             :        //   ROSE_ASSERT(false);
  193817             :         }
  193818             : 
  193819           5 :      return ;
  193820             :    }
  193821             : 
  193822             : //############################################################################
  193823             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  193824             :  * within the memory pool and resets the freepointers, in order to achieve a 
  193825             :  * linked list, that has no jumps and starts at the beginning! This function 
  193826             :  * does not extend the memory pool, since we do not delete any memory blocks,
  193827             :  * but delete the valid objects.  
  193828             :  */
  193829             : void
  193830           0 : SgVarArgEndOp::clearMemoryPool( )
  193831             :    {
  193832             :   // printf ("Inside of SgVarArgEndOp::clearMemoryPool() \n");
  193833             : 
  193834           0 :      SgVarArgEndOp* pointer = NULL, *tempPointer = NULL;
  193835           0 :      std::vector < unsigned char* > :: const_iterator block;
  193836           0 :      if ( SgVarArgEndOp::pools.empty() == false )
  193837             :         {
  193838           0 :           block = SgVarArgEndOp::pools.begin() ;
  193839           0 :           SgVarArgEndOp::next_node = (SgVarArgEndOp*) (*block);
  193840             : 
  193841           0 :           while ( block != SgVarArgEndOp::pools.end() )
  193842             :              {
  193843           0 :                pointer = (SgVarArgEndOp*) (*block);
  193844           0 :                if ( tempPointer != NULL )
  193845             :                   {
  193846           0 :                     tempPointer->set_freepointer(pointer);
  193847             :                   }
  193848           0 :                for (unsigned i = 0; i < SgVarArgEndOp::pool_size - 1; ++i)
  193849             :                   {
  193850           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  193851             :                   }
  193852           0 :                 pointer[SgVarArgEndOp::pool_size-1].set_freepointer(NULL);
  193853           0 :                 tempPointer = &(pointer[SgVarArgEndOp::pool_size-1]);
  193854           0 :                 ++block;
  193855             :              }
  193856             :         }
  193857           0 :    }
  193858             : 
  193859           5 : void SgVarArgEndOp::deleteMemoryPool() {
  193860           5 :   for (auto p: SgVarArgEndOp::pools) {
  193861           0 :     ROSE_FREE(p);
  193862             :   }
  193863           5 :   SgVarArgEndOp::next_node = nullptr;
  193864           5 :   SgVarArgEndOp::pools.clear();
  193865           5 : }
  193866             : 
  193867             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  193868             : //                 reading multiple binary files to for a single AST.
  193869             : /////////// new version ////////////////////////////////
  193870             : //############################################################################
  193871             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  193872             : void
  193873           2 : SgVarArgEndOp::extendMemoryPoolForFileIO( )
  193874             :   {
  193875           2 :     size_t blockIndex = SgVarArgEndOp::pools.size();
  193876           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgEndOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgEndOp);
  193877             : 
  193878           2 :     while ( (blockIndex * SgVarArgEndOp::pool_size) < newPoolSize)
  193879             :       {
  193880             : #if ROSE_ALLOC_TRACE
  193881             :         if (blockIndex > 0) {
  193882             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgEndOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgEndOp) = %" PRIuPTR " SgVarArgEndOp::pool_size = %d \n",
  193883             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgEndOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgEndOp),SgVarArgEndOp::pool_size);
  193884             :         }
  193885             : #endif
  193886             : 
  193887           0 :         SgVarArgEndOp * pointer = (SgVarArgEndOp*) ROSE_MALLOC ( SgVarArgEndOp::pool_size * sizeof(SgVarArgEndOp) );
  193888           0 :         assert( pointer != NULL );
  193889             : #if ROSE_ALLOC_MEMSET == 1
  193890             :         memset(pointer, 0x00, SgVarArgEndOp::pool_size * sizeof(SgVarArgEndOp));
  193891             : #elif ROSE_ALLOC_MEMSET == 2
  193892             :         memset(pointer, 0xCC, SgVarArgEndOp::pool_size * sizeof(SgVarArgEndOp));
  193893             : #endif
  193894           0 :         SgVarArgEndOp::pools.push_back( (unsigned char*)(pointer) );
  193895           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVarArgEndOp::pool_size * sizeof(SgVarArgEndOp), V_SgVarArgEndOp ) );
  193896             : 
  193897           0 :         if ( SgVarArgEndOp::next_node != NULL ) {
  193898           0 :           if ( blockIndex > 0 ) {
  193899           0 :             SgVarArgEndOp * blkptr = (SgVarArgEndOp*)(SgVarArgEndOp::pools[blockIndex-1]);
  193900           0 :             blkptr[ SgVarArgEndOp::pool_size - 1 ].set_freepointer(pointer);
  193901             :           }
  193902             :         } else {
  193903           0 :           SgVarArgEndOp::next_node = pointer;
  193904             :         }
  193905             : 
  193906           0 :         for (unsigned i = 0; i < SgVarArgEndOp::pool_size-1; ++i)
  193907             :            {
  193908           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  193909             :            }
  193910           0 :         pointer[ SgVarArgEndOp::pool_size -1 ].set_freepointer(NULL);
  193911             : 
  193912           0 :         blockIndex++;
  193913             :       }
  193914           2 :   }
  193915             : 
  193916             : //############################################################################
  193917             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  193918             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  193919             :  * not compressed. However, that stuff is not yet implemented! 
  193920             :  */
  193921             : unsigned long
  193922           0 : SgVarArgEndOp::getNumberOfLastValidPointer()
  193923             :    {
  193924           0 :       SgVarArgEndOp* testPointer = (SgVarArgEndOp*)(SgVarArgEndOp::pools.back());
  193925           0 :       unsigned long localIndex = SgVarArgEndOp::pool_size - 1;
  193926           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  193927             :          {
  193928           0 :            localIndex--;
  193929             :          }
  193930           0 :       return (localIndex + SgVarArgEndOp::pool_size * (SgVarArgEndOp::pools.size()-1));
  193931             :    }
  193932             : 
  193933             : //############################################################################
  193934             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  193935             :  * memory pool and initializes the data member in class SgVarArgEndOpStroageClass
  193936             :  * from its counterpart of SgVarArgEndOp. The return value is just for checking, 
  193937             :  * that the whole StorageClassArray is initialized!
  193938             :  */
  193939             : unsigned long
  193940           0 : SgVarArgEndOp::initializeStorageClassArray( SgVarArgEndOpStorageClass *storageArray )
  193941             :    {
  193942           0 :      unsigned long storageCounter = 0;
  193943           0 :      std::vector < unsigned char* > :: const_iterator block = SgVarArgEndOp::pools.begin();
  193944           0 :      SgVarArgEndOp* pointer = NULL;
  193945           0 :      while ( block != SgVarArgEndOp::pools.end() ) {
  193946           0 :           pointer = (SgVarArgEndOp*) (*block);
  193947           0 :           for ( unsigned i = 0; i < SgVarArgEndOp::pool_size; ++i ) {
  193948           0 :                if ( pointer->get_freepointer() != NULL ) {
  193949           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  193950           0 :                  storageArray++;
  193951           0 :                  storageCounter++;
  193952             :                }
  193953           0 :                pointer++;
  193954             :              }
  193955           0 :            block++;
  193956             :         }
  193957           0 :      return storageCounter;
  193958             :    }
  193959             : 
  193960             : /* #line 193961 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  193961             : 
  193962             : 
  193963             : 
  193964             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  193965             : 
  193966             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  193967             : 
  193968             : //############################################################################
  193969             : /* JH (02/02/2006) Constructor of the IR node SgVarArgCopyOp that takes its 
  193970             :  * corresponding StorageClass as parameter
  193971             :  */
  193972           0 : SgVarArgCopyOp :: SgVarArgCopyOp ( const SgVarArgCopyOpStorageClass& storageSource )   : SgExpression (storageSource)
  193973             :    {
  193974             : 
  193975             : 
  193976             : /* #line 193977 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  193977             : 
  193978           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  193979           0 :      p_lhs_operand =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lhs_operand) );
  193980           0 :      p_rhs_operand =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_rhs_operand) );
  193981           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  193982             : 
  193983             : 
  193984             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  193985             : 
  193986             : 
  193987           0 :    }
  193988             : 
  193989             : //############################################################################
  193990             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  193991             :  * within the working AST. 
  193992             :  */
  193993           0 : SgVarArgCopyOp * SgVarArgCopyOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  193994           0 :      SgVarArgCopyOp* returnPointer = NULL;
  193995           0 :      if ( globalIndex != 0 )
  193996             :         {
  193997             : 
  193998             : #if FILE_IO_EXTRA_CHECK
  193999           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVarArgCopyOp ) ) <= globalIndex ) ;
  194000           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgCopyOp + 1 ) ) );
  194001             : #endif
  194002           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgCopyOp )  
  194003           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVarArgCopyOp );
  194004           0 :           unsigned long positionInPool = localIndex % SgVarArgCopyOp::pool_size;
  194005           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgCopyOp::pool_size;
  194006             : 
  194007             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  194008             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  194009             : 
  194010           0 :           returnPointer = &( ( (SgVarArgCopyOp*)(SgVarArgCopyOp::pools[memoryBlock]) ) [positionInPool]) ;
  194011             : 
  194012           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  194013             :         }
  194014           0 :      return returnPointer ;
  194015             :    }
  194016             : 
  194017             : //############################################################################
  194018             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  194019             :   for the AST with the index astIndex
  194020             : */
  194021           0 : SgVarArgCopyOp * SgVarArgCopyOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  194022           0 :      SgVarArgCopyOp* returnPointer = NULL;
  194023           0 :      if ( globalIndex != 0 )
  194024             :         {
  194025             : 
  194026             : #if FILE_IO_EXTRA_CHECK
  194027           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVarArgCopyOp ) ) <= globalIndex ) ;
  194028           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgCopyOp + 1 ) ) );
  194029             : #endif
  194030           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgCopyOp )
  194031           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVarArgCopyOp );
  194032           0 :           unsigned long positionInPool = localIndex % SgVarArgCopyOp::pool_size ;
  194033           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgCopyOp::pool_size ;
  194034             : 
  194035             : #if FILE_IO_EXTRA_CHECK
  194036             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  194037             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  194038             : #endif
  194039             : 
  194040           0 :           returnPointer = &( ( (SgVarArgCopyOp*)(SgVarArgCopyOp::pools[memoryBlock]) ) [positionInPool]) ;
  194041             : 
  194042             : #if FILE_IO_EXTRA_CHECK
  194043           0 :           assert ( returnPointer != NULL ) ;
  194044             : #endif
  194045             :         }
  194046           0 :      return returnPointer ;
  194047             :    }
  194048             : 
  194049             : //############################################################################
  194050             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  194051             :  * pool size! We set for every valid object in the memory pool the freepointer
  194052             :  * to the global index and increase the global index afterwards. For all the 
  194053             :  * invalid objects (means address ranges within the memory pool that were not
  194054             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  194055             :  * distinguish valid from invalid objects! 
  194056             :  */
  194057             : unsigned long
  194058           5 : SgVarArgCopyOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  194059             :    {
  194060           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  194061           5 :      SgVarArgCopyOp* pointer = NULL;
  194062           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  194063           5 :      std::vector < unsigned char* > :: const_iterator block;
  194064           5 :      for ( block = SgVarArgCopyOp::pools.begin(); block != SgVarArgCopyOp::pools.end() ; ++block )
  194065             :         {
  194066           0 :           pointer = (SgVarArgCopyOp*)(*block);
  194067           0 :           for (unsigned i = 0; i < SgVarArgCopyOp::pool_size; ++i )
  194068             :              {
  194069             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  194070             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  194071             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  194072             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  194073             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  194074             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  194075             :             // properly; so this will have to be checked next.
  194076             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  194077             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  194078           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  194079             :                   {
  194080           0 :                     pointer[i].set_freepointer((SgVarArgCopyOp*)(globalIndex));
  194081           0 :                     globalIndex++;
  194082             :                   }
  194083             :                else
  194084             :                   {
  194085           0 :                     pointer[i].set_freepointer(NULL);
  194086             :                   }
  194087             :               }
  194088             :         }
  194089           5 :      return globalIndex;
  194090             :    }
  194091             : 
  194092             : //############################################################################
  194093             : // JH (01/14/2006)
  194094             : void
  194095           5 : SgVarArgCopyOp::resetValidFreepointers( )
  194096             :    {
  194097           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  194098           5 :      SgVarArgCopyOp* pointer = NULL;
  194099           5 :      std::vector < unsigned char* > :: const_iterator block;
  194100           5 :      SgVarArgCopyOp* pointerOfLinkedList = NULL;
  194101           5 :      for ( block = SgVarArgCopyOp::pools.begin(); block != SgVarArgCopyOp::pools.end() ; ++block )
  194102             :         {
  194103           0 :           pointer = (SgVarArgCopyOp*)(*block);
  194104           0 :           for (unsigned i = 0; i < SgVarArgCopyOp::pool_size; ++i )
  194105             :              {
  194106             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  194107             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  194108             :             // memory blocks!.
  194109           0 :                if ( pointer[i].get_freepointer() != NULL )
  194110             :                   {
  194111           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  194112             :                   }
  194113             :                else
  194114             :                   {
  194115           0 :                     if ( pointerOfLinkedList == NULL )
  194116             :                        {
  194117           0 :                          SgVarArgCopyOp::next_node = &(pointer[i]);
  194118             :                        }
  194119             :                     else
  194120             :                        {
  194121             :                       // printf ("In SgVarArgCopyOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  194122           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  194123             :                        }
  194124             :                     pointerOfLinkedList = &(pointer[i]);
  194125             :                   }
  194126             :               }
  194127             :         }
  194128             : 
  194129           5 :      if ( pointerOfLinkedList != NULL )
  194130             :         {
  194131             :        // printf ("In SgVarArgCopyOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  194132           0 :           pointerOfLinkedList->set_freepointer(NULL);
  194133             :        // DQ (6/6/2010): Temporary debugging...
  194134             :        //   ROSE_ASSERT(false);
  194135             :         }
  194136             : 
  194137           5 :      return ;
  194138             :    }
  194139             : 
  194140             : //############################################################################
  194141             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  194142             :  * within the memory pool and resets the freepointers, in order to achieve a 
  194143             :  * linked list, that has no jumps and starts at the beginning! This function 
  194144             :  * does not extend the memory pool, since we do not delete any memory blocks,
  194145             :  * but delete the valid objects.  
  194146             :  */
  194147             : void
  194148           0 : SgVarArgCopyOp::clearMemoryPool( )
  194149             :    {
  194150             :   // printf ("Inside of SgVarArgCopyOp::clearMemoryPool() \n");
  194151             : 
  194152           0 :      SgVarArgCopyOp* pointer = NULL, *tempPointer = NULL;
  194153           0 :      std::vector < unsigned char* > :: const_iterator block;
  194154           0 :      if ( SgVarArgCopyOp::pools.empty() == false )
  194155             :         {
  194156           0 :           block = SgVarArgCopyOp::pools.begin() ;
  194157           0 :           SgVarArgCopyOp::next_node = (SgVarArgCopyOp*) (*block);
  194158             : 
  194159           0 :           while ( block != SgVarArgCopyOp::pools.end() )
  194160             :              {
  194161           0 :                pointer = (SgVarArgCopyOp*) (*block);
  194162           0 :                if ( tempPointer != NULL )
  194163             :                   {
  194164           0 :                     tempPointer->set_freepointer(pointer);
  194165             :                   }
  194166           0 :                for (unsigned i = 0; i < SgVarArgCopyOp::pool_size - 1; ++i)
  194167             :                   {
  194168           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  194169             :                   }
  194170           0 :                 pointer[SgVarArgCopyOp::pool_size-1].set_freepointer(NULL);
  194171           0 :                 tempPointer = &(pointer[SgVarArgCopyOp::pool_size-1]);
  194172           0 :                 ++block;
  194173             :              }
  194174             :         }
  194175           0 :    }
  194176             : 
  194177           5 : void SgVarArgCopyOp::deleteMemoryPool() {
  194178           5 :   for (auto p: SgVarArgCopyOp::pools) {
  194179           0 :     ROSE_FREE(p);
  194180             :   }
  194181           5 :   SgVarArgCopyOp::next_node = nullptr;
  194182           5 :   SgVarArgCopyOp::pools.clear();
  194183           5 : }
  194184             : 
  194185             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  194186             : //                 reading multiple binary files to for a single AST.
  194187             : /////////// new version ////////////////////////////////
  194188             : //############################################################################
  194189             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  194190             : void
  194191           2 : SgVarArgCopyOp::extendMemoryPoolForFileIO( )
  194192             :   {
  194193           2 :     size_t blockIndex = SgVarArgCopyOp::pools.size();
  194194           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgCopyOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgCopyOp);
  194195             : 
  194196           2 :     while ( (blockIndex * SgVarArgCopyOp::pool_size) < newPoolSize)
  194197             :       {
  194198             : #if ROSE_ALLOC_TRACE
  194199             :         if (blockIndex > 0) {
  194200             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgCopyOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgCopyOp) = %" PRIuPTR " SgVarArgCopyOp::pool_size = %d \n",
  194201             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgCopyOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgCopyOp),SgVarArgCopyOp::pool_size);
  194202             :         }
  194203             : #endif
  194204             : 
  194205           0 :         SgVarArgCopyOp * pointer = (SgVarArgCopyOp*) ROSE_MALLOC ( SgVarArgCopyOp::pool_size * sizeof(SgVarArgCopyOp) );
  194206           0 :         assert( pointer != NULL );
  194207             : #if ROSE_ALLOC_MEMSET == 1
  194208             :         memset(pointer, 0x00, SgVarArgCopyOp::pool_size * sizeof(SgVarArgCopyOp));
  194209             : #elif ROSE_ALLOC_MEMSET == 2
  194210             :         memset(pointer, 0xCC, SgVarArgCopyOp::pool_size * sizeof(SgVarArgCopyOp));
  194211             : #endif
  194212           0 :         SgVarArgCopyOp::pools.push_back( (unsigned char*)(pointer) );
  194213           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVarArgCopyOp::pool_size * sizeof(SgVarArgCopyOp), V_SgVarArgCopyOp ) );
  194214             : 
  194215           0 :         if ( SgVarArgCopyOp::next_node != NULL ) {
  194216           0 :           if ( blockIndex > 0 ) {
  194217           0 :             SgVarArgCopyOp * blkptr = (SgVarArgCopyOp*)(SgVarArgCopyOp::pools[blockIndex-1]);
  194218           0 :             blkptr[ SgVarArgCopyOp::pool_size - 1 ].set_freepointer(pointer);
  194219             :           }
  194220             :         } else {
  194221           0 :           SgVarArgCopyOp::next_node = pointer;
  194222             :         }
  194223             : 
  194224           0 :         for (unsigned i = 0; i < SgVarArgCopyOp::pool_size-1; ++i)
  194225             :            {
  194226           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  194227             :            }
  194228           0 :         pointer[ SgVarArgCopyOp::pool_size -1 ].set_freepointer(NULL);
  194229             : 
  194230           0 :         blockIndex++;
  194231             :       }
  194232           2 :   }
  194233             : 
  194234             : //############################################################################
  194235             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  194236             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  194237             :  * not compressed. However, that stuff is not yet implemented! 
  194238             :  */
  194239             : unsigned long
  194240           0 : SgVarArgCopyOp::getNumberOfLastValidPointer()
  194241             :    {
  194242           0 :       SgVarArgCopyOp* testPointer = (SgVarArgCopyOp*)(SgVarArgCopyOp::pools.back());
  194243           0 :       unsigned long localIndex = SgVarArgCopyOp::pool_size - 1;
  194244           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  194245             :          {
  194246           0 :            localIndex--;
  194247             :          }
  194248           0 :       return (localIndex + SgVarArgCopyOp::pool_size * (SgVarArgCopyOp::pools.size()-1));
  194249             :    }
  194250             : 
  194251             : //############################################################################
  194252             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  194253             :  * memory pool and initializes the data member in class SgVarArgCopyOpStroageClass
  194254             :  * from its counterpart of SgVarArgCopyOp. The return value is just for checking, 
  194255             :  * that the whole StorageClassArray is initialized!
  194256             :  */
  194257             : unsigned long
  194258           0 : SgVarArgCopyOp::initializeStorageClassArray( SgVarArgCopyOpStorageClass *storageArray )
  194259             :    {
  194260           0 :      unsigned long storageCounter = 0;
  194261           0 :      std::vector < unsigned char* > :: const_iterator block = SgVarArgCopyOp::pools.begin();
  194262           0 :      SgVarArgCopyOp* pointer = NULL;
  194263           0 :      while ( block != SgVarArgCopyOp::pools.end() ) {
  194264           0 :           pointer = (SgVarArgCopyOp*) (*block);
  194265           0 :           for ( unsigned i = 0; i < SgVarArgCopyOp::pool_size; ++i ) {
  194266           0 :                if ( pointer->get_freepointer() != NULL ) {
  194267           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  194268           0 :                  storageArray++;
  194269           0 :                  storageCounter++;
  194270             :                }
  194271           0 :                pointer++;
  194272             :              }
  194273           0 :            block++;
  194274             :         }
  194275           0 :      return storageCounter;
  194276             :    }
  194277             : 
  194278             : /* #line 194279 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  194279             : 
  194280             : 
  194281             : 
  194282             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  194283             : 
  194284             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  194285             : 
  194286             : //############################################################################
  194287             : /* JH (02/02/2006) Constructor of the IR node SgVarArgStartOneOperandOp that takes its 
  194288             :  * corresponding StorageClass as parameter
  194289             :  */
  194290           0 : SgVarArgStartOneOperandOp :: SgVarArgStartOneOperandOp ( const SgVarArgStartOneOperandOpStorageClass& storageSource )   : SgExpression (storageSource)
  194291             :    {
  194292             : 
  194293             : 
  194294             : /* #line 194295 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  194295             : 
  194296           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  194297           0 :      p_operand_expr =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_expr) );
  194298           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  194299             : 
  194300             : 
  194301             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  194302             : 
  194303             : 
  194304           0 :    }
  194305             : 
  194306             : //############################################################################
  194307             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  194308             :  * within the working AST. 
  194309             :  */
  194310           0 : SgVarArgStartOneOperandOp * SgVarArgStartOneOperandOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  194311           0 :      SgVarArgStartOneOperandOp* returnPointer = NULL;
  194312           0 :      if ( globalIndex != 0 )
  194313             :         {
  194314             : 
  194315             : #if FILE_IO_EXTRA_CHECK
  194316           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVarArgStartOneOperandOp ) ) <= globalIndex ) ;
  194317           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgStartOneOperandOp + 1 ) ) );
  194318             : #endif
  194319           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVarArgStartOneOperandOp )  
  194320           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVarArgStartOneOperandOp );
  194321           0 :           unsigned long positionInPool = localIndex % SgVarArgStartOneOperandOp::pool_size;
  194322           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgStartOneOperandOp::pool_size;
  194323             : 
  194324             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  194325             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  194326             : 
  194327           0 :           returnPointer = &( ( (SgVarArgStartOneOperandOp*)(SgVarArgStartOneOperandOp::pools[memoryBlock]) ) [positionInPool]) ;
  194328             : 
  194329           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  194330             :         }
  194331           0 :      return returnPointer ;
  194332             :    }
  194333             : 
  194334             : //############################################################################
  194335             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  194336             :   for the AST with the index astIndex
  194337             : */
  194338           0 : SgVarArgStartOneOperandOp * SgVarArgStartOneOperandOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  194339           0 :      SgVarArgStartOneOperandOp* returnPointer = NULL;
  194340           0 :      if ( globalIndex != 0 )
  194341             :         {
  194342             : 
  194343             : #if FILE_IO_EXTRA_CHECK
  194344           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVarArgStartOneOperandOp ) ) <= globalIndex ) ;
  194345           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgStartOneOperandOp + 1 ) ) );
  194346             : #endif
  194347           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVarArgStartOneOperandOp )
  194348           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVarArgStartOneOperandOp );
  194349           0 :           unsigned long positionInPool = localIndex % SgVarArgStartOneOperandOp::pool_size ;
  194350           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVarArgStartOneOperandOp::pool_size ;
  194351             : 
  194352             : #if FILE_IO_EXTRA_CHECK
  194353             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  194354             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  194355             : #endif
  194356             : 
  194357           0 :           returnPointer = &( ( (SgVarArgStartOneOperandOp*)(SgVarArgStartOneOperandOp::pools[memoryBlock]) ) [positionInPool]) ;
  194358             : 
  194359             : #if FILE_IO_EXTRA_CHECK
  194360           0 :           assert ( returnPointer != NULL ) ;
  194361             : #endif
  194362             :         }
  194363           0 :      return returnPointer ;
  194364             :    }
  194365             : 
  194366             : //############################################################################
  194367             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  194368             :  * pool size! We set for every valid object in the memory pool the freepointer
  194369             :  * to the global index and increase the global index afterwards. For all the 
  194370             :  * invalid objects (means address ranges within the memory pool that were not
  194371             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  194372             :  * distinguish valid from invalid objects! 
  194373             :  */
  194374             : unsigned long
  194375           5 : SgVarArgStartOneOperandOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  194376             :    {
  194377           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  194378           5 :      SgVarArgStartOneOperandOp* pointer = NULL;
  194379           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  194380           5 :      std::vector < unsigned char* > :: const_iterator block;
  194381           5 :      for ( block = SgVarArgStartOneOperandOp::pools.begin(); block != SgVarArgStartOneOperandOp::pools.end() ; ++block )
  194382             :         {
  194383           0 :           pointer = (SgVarArgStartOneOperandOp*)(*block);
  194384           0 :           for (unsigned i = 0; i < SgVarArgStartOneOperandOp::pool_size; ++i )
  194385             :              {
  194386             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  194387             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  194388             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  194389             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  194390             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  194391             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  194392             :             // properly; so this will have to be checked next.
  194393             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  194394             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  194395           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  194396             :                   {
  194397           0 :                     pointer[i].set_freepointer((SgVarArgStartOneOperandOp*)(globalIndex));
  194398           0 :                     globalIndex++;
  194399             :                   }
  194400             :                else
  194401             :                   {
  194402           0 :                     pointer[i].set_freepointer(NULL);
  194403             :                   }
  194404             :               }
  194405             :         }
  194406           5 :      return globalIndex;
  194407             :    }
  194408             : 
  194409             : //############################################################################
  194410             : // JH (01/14/2006)
  194411             : void
  194412           5 : SgVarArgStartOneOperandOp::resetValidFreepointers( )
  194413             :    {
  194414           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  194415           5 :      SgVarArgStartOneOperandOp* pointer = NULL;
  194416           5 :      std::vector < unsigned char* > :: const_iterator block;
  194417           5 :      SgVarArgStartOneOperandOp* pointerOfLinkedList = NULL;
  194418           5 :      for ( block = SgVarArgStartOneOperandOp::pools.begin(); block != SgVarArgStartOneOperandOp::pools.end() ; ++block )
  194419             :         {
  194420           0 :           pointer = (SgVarArgStartOneOperandOp*)(*block);
  194421           0 :           for (unsigned i = 0; i < SgVarArgStartOneOperandOp::pool_size; ++i )
  194422             :              {
  194423             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  194424             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  194425             :             // memory blocks!.
  194426           0 :                if ( pointer[i].get_freepointer() != NULL )
  194427             :                   {
  194428           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  194429             :                   }
  194430             :                else
  194431             :                   {
  194432           0 :                     if ( pointerOfLinkedList == NULL )
  194433             :                        {
  194434           0 :                          SgVarArgStartOneOperandOp::next_node = &(pointer[i]);
  194435             :                        }
  194436             :                     else
  194437             :                        {
  194438             :                       // printf ("In SgVarArgStartOneOperandOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  194439           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  194440             :                        }
  194441             :                     pointerOfLinkedList = &(pointer[i]);
  194442             :                   }
  194443             :               }
  194444             :         }
  194445             : 
  194446           5 :      if ( pointerOfLinkedList != NULL )
  194447             :         {
  194448             :        // printf ("In SgVarArgStartOneOperandOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  194449           0 :           pointerOfLinkedList->set_freepointer(NULL);
  194450             :        // DQ (6/6/2010): Temporary debugging...
  194451             :        //   ROSE_ASSERT(false);
  194452             :         }
  194453             : 
  194454           5 :      return ;
  194455             :    }
  194456             : 
  194457             : //############################################################################
  194458             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  194459             :  * within the memory pool and resets the freepointers, in order to achieve a 
  194460             :  * linked list, that has no jumps and starts at the beginning! This function 
  194461             :  * does not extend the memory pool, since we do not delete any memory blocks,
  194462             :  * but delete the valid objects.  
  194463             :  */
  194464             : void
  194465           0 : SgVarArgStartOneOperandOp::clearMemoryPool( )
  194466             :    {
  194467             :   // printf ("Inside of SgVarArgStartOneOperandOp::clearMemoryPool() \n");
  194468             : 
  194469           0 :      SgVarArgStartOneOperandOp* pointer = NULL, *tempPointer = NULL;
  194470           0 :      std::vector < unsigned char* > :: const_iterator block;
  194471           0 :      if ( SgVarArgStartOneOperandOp::pools.empty() == false )
  194472             :         {
  194473           0 :           block = SgVarArgStartOneOperandOp::pools.begin() ;
  194474           0 :           SgVarArgStartOneOperandOp::next_node = (SgVarArgStartOneOperandOp*) (*block);
  194475             : 
  194476           0 :           while ( block != SgVarArgStartOneOperandOp::pools.end() )
  194477             :              {
  194478           0 :                pointer = (SgVarArgStartOneOperandOp*) (*block);
  194479           0 :                if ( tempPointer != NULL )
  194480             :                   {
  194481           0 :                     tempPointer->set_freepointer(pointer);
  194482             :                   }
  194483           0 :                for (unsigned i = 0; i < SgVarArgStartOneOperandOp::pool_size - 1; ++i)
  194484             :                   {
  194485           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  194486             :                   }
  194487           0 :                 pointer[SgVarArgStartOneOperandOp::pool_size-1].set_freepointer(NULL);
  194488           0 :                 tempPointer = &(pointer[SgVarArgStartOneOperandOp::pool_size-1]);
  194489           0 :                 ++block;
  194490             :              }
  194491             :         }
  194492           0 :    }
  194493             : 
  194494           5 : void SgVarArgStartOneOperandOp::deleteMemoryPool() {
  194495           5 :   for (auto p: SgVarArgStartOneOperandOp::pools) {
  194496           0 :     ROSE_FREE(p);
  194497             :   }
  194498           5 :   SgVarArgStartOneOperandOp::next_node = nullptr;
  194499           5 :   SgVarArgStartOneOperandOp::pools.clear();
  194500           5 : }
  194501             : 
  194502             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  194503             : //                 reading multiple binary files to for a single AST.
  194504             : /////////// new version ////////////////////////////////
  194505             : //############################################################################
  194506             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  194507             : void
  194508           2 : SgVarArgStartOneOperandOp::extendMemoryPoolForFileIO( )
  194509             :   {
  194510           2 :     size_t blockIndex = SgVarArgStartOneOperandOp::pools.size();
  194511           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgStartOneOperandOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgStartOneOperandOp);
  194512             : 
  194513           2 :     while ( (blockIndex * SgVarArgStartOneOperandOp::pool_size) < newPoolSize)
  194514             :       {
  194515             : #if ROSE_ALLOC_TRACE
  194516             :         if (blockIndex > 0) {
  194517             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgStartOneOperandOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgStartOneOperandOp) = %" PRIuPTR " SgVarArgStartOneOperandOp::pool_size = %d \n",
  194518             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVarArgStartOneOperandOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVarArgStartOneOperandOp),SgVarArgStartOneOperandOp::pool_size);
  194519             :         }
  194520             : #endif
  194521             : 
  194522           0 :         SgVarArgStartOneOperandOp * pointer = (SgVarArgStartOneOperandOp*) ROSE_MALLOC ( SgVarArgStartOneOperandOp::pool_size * sizeof(SgVarArgStartOneOperandOp) );
  194523           0 :         assert( pointer != NULL );
  194524             : #if ROSE_ALLOC_MEMSET == 1
  194525             :         memset(pointer, 0x00, SgVarArgStartOneOperandOp::pool_size * sizeof(SgVarArgStartOneOperandOp));
  194526             : #elif ROSE_ALLOC_MEMSET == 2
  194527             :         memset(pointer, 0xCC, SgVarArgStartOneOperandOp::pool_size * sizeof(SgVarArgStartOneOperandOp));
  194528             : #endif
  194529           0 :         SgVarArgStartOneOperandOp::pools.push_back( (unsigned char*)(pointer) );
  194530           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVarArgStartOneOperandOp::pool_size * sizeof(SgVarArgStartOneOperandOp), V_SgVarArgStartOneOperandOp ) );
  194531             : 
  194532           0 :         if ( SgVarArgStartOneOperandOp::next_node != NULL ) {
  194533           0 :           if ( blockIndex > 0 ) {
  194534           0 :             SgVarArgStartOneOperandOp * blkptr = (SgVarArgStartOneOperandOp*)(SgVarArgStartOneOperandOp::pools[blockIndex-1]);
  194535           0 :             blkptr[ SgVarArgStartOneOperandOp::pool_size - 1 ].set_freepointer(pointer);
  194536             :           }
  194537             :         } else {
  194538           0 :           SgVarArgStartOneOperandOp::next_node = pointer;
  194539             :         }
  194540             : 
  194541           0 :         for (unsigned i = 0; i < SgVarArgStartOneOperandOp::pool_size-1; ++i)
  194542             :            {
  194543           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  194544             :            }
  194545           0 :         pointer[ SgVarArgStartOneOperandOp::pool_size -1 ].set_freepointer(NULL);
  194546             : 
  194547           0 :         blockIndex++;
  194548             :       }
  194549           2 :   }
  194550             : 
  194551             : //############################################################################
  194552             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  194553             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  194554             :  * not compressed. However, that stuff is not yet implemented! 
  194555             :  */
  194556             : unsigned long
  194557           0 : SgVarArgStartOneOperandOp::getNumberOfLastValidPointer()
  194558             :    {
  194559           0 :       SgVarArgStartOneOperandOp* testPointer = (SgVarArgStartOneOperandOp*)(SgVarArgStartOneOperandOp::pools.back());
  194560           0 :       unsigned long localIndex = SgVarArgStartOneOperandOp::pool_size - 1;
  194561           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  194562             :          {
  194563           0 :            localIndex--;
  194564             :          }
  194565           0 :       return (localIndex + SgVarArgStartOneOperandOp::pool_size * (SgVarArgStartOneOperandOp::pools.size()-1));
  194566             :    }
  194567             : 
  194568             : //############################################################################
  194569             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  194570             :  * memory pool and initializes the data member in class SgVarArgStartOneOperandOpStroageClass
  194571             :  * from its counterpart of SgVarArgStartOneOperandOp. The return value is just for checking, 
  194572             :  * that the whole StorageClassArray is initialized!
  194573             :  */
  194574             : unsigned long
  194575           0 : SgVarArgStartOneOperandOp::initializeStorageClassArray( SgVarArgStartOneOperandOpStorageClass *storageArray )
  194576             :    {
  194577           0 :      unsigned long storageCounter = 0;
  194578           0 :      std::vector < unsigned char* > :: const_iterator block = SgVarArgStartOneOperandOp::pools.begin();
  194579           0 :      SgVarArgStartOneOperandOp* pointer = NULL;
  194580           0 :      while ( block != SgVarArgStartOneOperandOp::pools.end() ) {
  194581           0 :           pointer = (SgVarArgStartOneOperandOp*) (*block);
  194582           0 :           for ( unsigned i = 0; i < SgVarArgStartOneOperandOp::pool_size; ++i ) {
  194583           0 :                if ( pointer->get_freepointer() != NULL ) {
  194584           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  194585           0 :                  storageArray++;
  194586           0 :                  storageCounter++;
  194587             :                }
  194588           0 :                pointer++;
  194589             :              }
  194590           0 :            block++;
  194591             :         }
  194592           0 :      return storageCounter;
  194593             :    }
  194594             : 
  194595             : /* #line 194596 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  194596             : 
  194597             : 
  194598             : 
  194599             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  194600             : 
  194601             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  194602             : 
  194603             : //############################################################################
  194604             : /* JH (02/02/2006) Constructor of the IR node SgNullExpression that takes its 
  194605             :  * corresponding StorageClass as parameter
  194606             :  */
  194607         121 : SgNullExpression :: SgNullExpression ( const SgNullExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  194608             :    {
  194609             : 
  194610             : 
  194611             : /* #line 194612 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  194612             : 
  194613         121 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  194614             : 
  194615             : 
  194616             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  194617             : 
  194618             : 
  194619         121 :    }
  194620             : 
  194621             : //############################################################################
  194622             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  194623             :  * within the working AST. 
  194624             :  */
  194625         484 : SgNullExpression * SgNullExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  194626         484 :      SgNullExpression* returnPointer = NULL;
  194627         484 :      if ( globalIndex != 0 )
  194628             :         {
  194629             : 
  194630             : #if FILE_IO_EXTRA_CHECK
  194631         484 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNullExpression ) ) <= globalIndex ) ;
  194632         484 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNullExpression + 1 ) ) );
  194633             : #endif
  194634         484 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNullExpression )  
  194635         484 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNullExpression );
  194636         484 :           unsigned long positionInPool = localIndex % SgNullExpression::pool_size;
  194637         484 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNullExpression::pool_size;
  194638             : 
  194639             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  194640             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  194641             : 
  194642         484 :           returnPointer = &( ( (SgNullExpression*)(SgNullExpression::pools[memoryBlock]) ) [positionInPool]) ;
  194643             : 
  194644         484 :           ROSE_ASSERT( returnPointer != NULL ) ;
  194645             :         }
  194646         484 :      return returnPointer ;
  194647             :    }
  194648             : 
  194649             : //############################################################################
  194650             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  194651             :   for the AST with the index astIndex
  194652             : */
  194653           0 : SgNullExpression * SgNullExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  194654           0 :      SgNullExpression* returnPointer = NULL;
  194655           0 :      if ( globalIndex != 0 )
  194656             :         {
  194657             : 
  194658             : #if FILE_IO_EXTRA_CHECK
  194659           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNullExpression ) ) <= globalIndex ) ;
  194660           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNullExpression + 1 ) ) );
  194661             : #endif
  194662           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNullExpression )
  194663           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNullExpression );
  194664           0 :           unsigned long positionInPool = localIndex % SgNullExpression::pool_size ;
  194665           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNullExpression::pool_size ;
  194666             : 
  194667             : #if FILE_IO_EXTRA_CHECK
  194668             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  194669             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  194670             : #endif
  194671             : 
  194672           0 :           returnPointer = &( ( (SgNullExpression*)(SgNullExpression::pools[memoryBlock]) ) [positionInPool]) ;
  194673             : 
  194674             : #if FILE_IO_EXTRA_CHECK
  194675           0 :           assert ( returnPointer != NULL ) ;
  194676             : #endif
  194677             :         }
  194678           0 :      return returnPointer ;
  194679             :    }
  194680             : 
  194681             : //############################################################################
  194682             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  194683             :  * pool size! We set for every valid object in the memory pool the freepointer
  194684             :  * to the global index and increase the global index afterwards. For all the 
  194685             :  * invalid objects (means address ranges within the memory pool that were not
  194686             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  194687             :  * distinguish valid from invalid objects! 
  194688             :  */
  194689             : unsigned long
  194690           5 : SgNullExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  194691             :    {
  194692           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  194693           5 :      SgNullExpression* pointer = NULL;
  194694           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  194695           5 :      std::vector < unsigned char* > :: const_iterator block;
  194696           7 :      for ( block = SgNullExpression::pools.begin(); block != SgNullExpression::pools.end() ; ++block )
  194697             :         {
  194698           2 :           pointer = (SgNullExpression*)(*block);
  194699        4002 :           for (unsigned i = 0; i < SgNullExpression::pool_size; ++i )
  194700             :              {
  194701             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  194702             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  194703             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  194704             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  194705             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  194706             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  194707             :             // properly; so this will have to be checked next.
  194708             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  194709             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  194710        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  194711             :                   {
  194712         121 :                     pointer[i].set_freepointer((SgNullExpression*)(globalIndex));
  194713         121 :                     globalIndex++;
  194714             :                   }
  194715             :                else
  194716             :                   {
  194717        3879 :                     pointer[i].set_freepointer(NULL);
  194718             :                   }
  194719             :               }
  194720             :         }
  194721           5 :      return globalIndex;
  194722             :    }
  194723             : 
  194724             : //############################################################################
  194725             : // JH (01/14/2006)
  194726             : void
  194727           5 : SgNullExpression::resetValidFreepointers( )
  194728             :    {
  194729           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  194730           5 :      SgNullExpression* pointer = NULL;
  194731           5 :      std::vector < unsigned char* > :: const_iterator block;
  194732           5 :      SgNullExpression* pointerOfLinkedList = NULL;
  194733           7 :      for ( block = SgNullExpression::pools.begin(); block != SgNullExpression::pools.end() ; ++block )
  194734             :         {
  194735           2 :           pointer = (SgNullExpression*)(*block);
  194736        4002 :           for (unsigned i = 0; i < SgNullExpression::pool_size; ++i )
  194737             :              {
  194738             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  194739             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  194740             :             // memory blocks!.
  194741        4000 :                if ( pointer[i].get_freepointer() != NULL )
  194742             :                   {
  194743         121 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  194744             :                   }
  194745             :                else
  194746             :                   {
  194747        3879 :                     if ( pointerOfLinkedList == NULL )
  194748             :                        {
  194749           2 :                          SgNullExpression::next_node = &(pointer[i]);
  194750             :                        }
  194751             :                     else
  194752             :                        {
  194753             :                       // printf ("In SgNullExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  194754        3877 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  194755             :                        }
  194756             :                     pointerOfLinkedList = &(pointer[i]);
  194757             :                   }
  194758             :               }
  194759             :         }
  194760             : 
  194761           5 :      if ( pointerOfLinkedList != NULL )
  194762             :         {
  194763             :        // printf ("In SgNullExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  194764           2 :           pointerOfLinkedList->set_freepointer(NULL);
  194765             :        // DQ (6/6/2010): Temporary debugging...
  194766             :        //   ROSE_ASSERT(false);
  194767             :         }
  194768             : 
  194769           5 :      return ;
  194770             :    }
  194771             : 
  194772             : //############################################################################
  194773             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  194774             :  * within the memory pool and resets the freepointers, in order to achieve a 
  194775             :  * linked list, that has no jumps and starts at the beginning! This function 
  194776             :  * does not extend the memory pool, since we do not delete any memory blocks,
  194777             :  * but delete the valid objects.  
  194778             :  */
  194779             : void
  194780           0 : SgNullExpression::clearMemoryPool( )
  194781             :    {
  194782             :   // printf ("Inside of SgNullExpression::clearMemoryPool() \n");
  194783             : 
  194784           0 :      SgNullExpression* pointer = NULL, *tempPointer = NULL;
  194785           0 :      std::vector < unsigned char* > :: const_iterator block;
  194786           0 :      if ( SgNullExpression::pools.empty() == false )
  194787             :         {
  194788           0 :           block = SgNullExpression::pools.begin() ;
  194789           0 :           SgNullExpression::next_node = (SgNullExpression*) (*block);
  194790             : 
  194791           0 :           while ( block != SgNullExpression::pools.end() )
  194792             :              {
  194793           0 :                pointer = (SgNullExpression*) (*block);
  194794           0 :                if ( tempPointer != NULL )
  194795             :                   {
  194796           0 :                     tempPointer->set_freepointer(pointer);
  194797             :                   }
  194798           0 :                for (unsigned i = 0; i < SgNullExpression::pool_size - 1; ++i)
  194799             :                   {
  194800           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  194801             :                   }
  194802           0 :                 pointer[SgNullExpression::pool_size-1].set_freepointer(NULL);
  194803           0 :                 tempPointer = &(pointer[SgNullExpression::pool_size-1]);
  194804           0 :                 ++block;
  194805             :              }
  194806             :         }
  194807           0 :    }
  194808             : 
  194809           5 : void SgNullExpression::deleteMemoryPool() {
  194810           9 :   for (auto p: SgNullExpression::pools) {
  194811           4 :     ROSE_FREE(p);
  194812             :   }
  194813           5 :   SgNullExpression::next_node = nullptr;
  194814           5 :   SgNullExpression::pools.clear();
  194815           5 : }
  194816             : 
  194817             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  194818             : //                 reading multiple binary files to for a single AST.
  194819             : /////////// new version ////////////////////////////////
  194820             : //############################################################################
  194821             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  194822             : void
  194823           2 : SgNullExpression::extendMemoryPoolForFileIO( )
  194824             :   {
  194825           2 :     size_t blockIndex = SgNullExpression::pools.size();
  194826           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNullExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullExpression);
  194827             : 
  194828           4 :     while ( (blockIndex * SgNullExpression::pool_size) < newPoolSize)
  194829             :       {
  194830             : #if ROSE_ALLOC_TRACE
  194831             :         if (blockIndex > 0) {
  194832             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNullExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullExpression) = %" PRIuPTR " SgNullExpression::pool_size = %d \n",
  194833             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNullExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNullExpression),SgNullExpression::pool_size);
  194834             :         }
  194835             : #endif
  194836             : 
  194837           2 :         SgNullExpression * pointer = (SgNullExpression*) ROSE_MALLOC ( SgNullExpression::pool_size * sizeof(SgNullExpression) );
  194838           2 :         assert( pointer != NULL );
  194839             : #if ROSE_ALLOC_MEMSET == 1
  194840             :         memset(pointer, 0x00, SgNullExpression::pool_size * sizeof(SgNullExpression));
  194841             : #elif ROSE_ALLOC_MEMSET == 2
  194842             :         memset(pointer, 0xCC, SgNullExpression::pool_size * sizeof(SgNullExpression));
  194843             : #endif
  194844           2 :         SgNullExpression::pools.push_back( (unsigned char*)(pointer) );
  194845           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNullExpression::pool_size * sizeof(SgNullExpression), V_SgNullExpression ) );
  194846             : 
  194847           2 :         if ( SgNullExpression::next_node != NULL ) {
  194848           0 :           if ( blockIndex > 0 ) {
  194849           0 :             SgNullExpression * blkptr = (SgNullExpression*)(SgNullExpression::pools[blockIndex-1]);
  194850           0 :             blkptr[ SgNullExpression::pool_size - 1 ].set_freepointer(pointer);
  194851             :           }
  194852             :         } else {
  194853           2 :           SgNullExpression::next_node = pointer;
  194854             :         }
  194855             : 
  194856        4000 :         for (unsigned i = 0; i < SgNullExpression::pool_size-1; ++i)
  194857             :            {
  194858        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  194859             :            }
  194860           2 :         pointer[ SgNullExpression::pool_size -1 ].set_freepointer(NULL);
  194861             : 
  194862           2 :         blockIndex++;
  194863             :       }
  194864           2 :   }
  194865             : 
  194866             : //############################################################################
  194867             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  194868             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  194869             :  * not compressed. However, that stuff is not yet implemented! 
  194870             :  */
  194871             : unsigned long
  194872           0 : SgNullExpression::getNumberOfLastValidPointer()
  194873             :    {
  194874           0 :       SgNullExpression* testPointer = (SgNullExpression*)(SgNullExpression::pools.back());
  194875           0 :       unsigned long localIndex = SgNullExpression::pool_size - 1;
  194876           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  194877             :          {
  194878           0 :            localIndex--;
  194879             :          }
  194880           0 :       return (localIndex + SgNullExpression::pool_size * (SgNullExpression::pools.size()-1));
  194881             :    }
  194882             : 
  194883             : //############################################################################
  194884             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  194885             :  * memory pool and initializes the data member in class SgNullExpressionStroageClass
  194886             :  * from its counterpart of SgNullExpression. The return value is just for checking, 
  194887             :  * that the whole StorageClassArray is initialized!
  194888             :  */
  194889             : unsigned long
  194890           2 : SgNullExpression::initializeStorageClassArray( SgNullExpressionStorageClass *storageArray )
  194891             :    {
  194892           2 :      unsigned long storageCounter = 0;
  194893           2 :      std::vector < unsigned char* > :: const_iterator block = SgNullExpression::pools.begin();
  194894           2 :      SgNullExpression* pointer = NULL;
  194895           4 :      while ( block != SgNullExpression::pools.end() ) {
  194896           2 :           pointer = (SgNullExpression*) (*block);
  194897        4002 :           for ( unsigned i = 0; i < SgNullExpression::pool_size; ++i ) {
  194898        4000 :                if ( pointer->get_freepointer() != NULL ) {
  194899         121 :                  storageArray->pickOutIRNodeData (pointer) ;
  194900         121 :                  storageArray++;
  194901         121 :                  storageCounter++;
  194902             :                }
  194903        4000 :                pointer++;
  194904             :              }
  194905           2 :            block++;
  194906             :         }
  194907           2 :      return storageCounter;
  194908             :    }
  194909             : 
  194910             : /* #line 194911 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  194911             : 
  194912             : 
  194913             : 
  194914             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  194915             : 
  194916             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  194917             : 
  194918             : //############################################################################
  194919             : /* JH (02/02/2006) Constructor of the IR node SgVariantExpression that takes its 
  194920             :  * corresponding StorageClass as parameter
  194921             :  */
  194922           0 : SgVariantExpression :: SgVariantExpression ( const SgVariantExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  194923             :    {
  194924             : 
  194925             : 
  194926             : /* #line 194927 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  194927             : 
  194928           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  194929             : 
  194930             : 
  194931             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  194932             : 
  194933             : 
  194934           0 :    }
  194935             : 
  194936             : //############################################################################
  194937             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  194938             :  * within the working AST. 
  194939             :  */
  194940           0 : SgVariantExpression * SgVariantExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  194941           0 :      SgVariantExpression* returnPointer = NULL;
  194942           0 :      if ( globalIndex != 0 )
  194943             :         {
  194944             : 
  194945             : #if FILE_IO_EXTRA_CHECK
  194946           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVariantExpression ) ) <= globalIndex ) ;
  194947           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariantExpression + 1 ) ) );
  194948             : #endif
  194949           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariantExpression )  
  194950           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVariantExpression );
  194951           0 :           unsigned long positionInPool = localIndex % SgVariantExpression::pool_size;
  194952           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariantExpression::pool_size;
  194953             : 
  194954             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  194955             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  194956             : 
  194957           0 :           returnPointer = &( ( (SgVariantExpression*)(SgVariantExpression::pools[memoryBlock]) ) [positionInPool]) ;
  194958             : 
  194959           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  194960             :         }
  194961           0 :      return returnPointer ;
  194962             :    }
  194963             : 
  194964             : //############################################################################
  194965             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  194966             :   for the AST with the index astIndex
  194967             : */
  194968           0 : SgVariantExpression * SgVariantExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  194969           0 :      SgVariantExpression* returnPointer = NULL;
  194970           0 :      if ( globalIndex != 0 )
  194971             :         {
  194972             : 
  194973             : #if FILE_IO_EXTRA_CHECK
  194974           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVariantExpression ) ) <= globalIndex ) ;
  194975           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariantExpression + 1 ) ) );
  194976             : #endif
  194977           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariantExpression )
  194978           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVariantExpression );
  194979           0 :           unsigned long positionInPool = localIndex % SgVariantExpression::pool_size ;
  194980           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariantExpression::pool_size ;
  194981             : 
  194982             : #if FILE_IO_EXTRA_CHECK
  194983             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  194984             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  194985             : #endif
  194986             : 
  194987           0 :           returnPointer = &( ( (SgVariantExpression*)(SgVariantExpression::pools[memoryBlock]) ) [positionInPool]) ;
  194988             : 
  194989             : #if FILE_IO_EXTRA_CHECK
  194990           0 :           assert ( returnPointer != NULL ) ;
  194991             : #endif
  194992             :         }
  194993           0 :      return returnPointer ;
  194994             :    }
  194995             : 
  194996             : //############################################################################
  194997             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  194998             :  * pool size! We set for every valid object in the memory pool the freepointer
  194999             :  * to the global index and increase the global index afterwards. For all the 
  195000             :  * invalid objects (means address ranges within the memory pool that were not
  195001             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  195002             :  * distinguish valid from invalid objects! 
  195003             :  */
  195004             : unsigned long
  195005           5 : SgVariantExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  195006             :    {
  195007           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  195008           5 :      SgVariantExpression* pointer = NULL;
  195009           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  195010           5 :      std::vector < unsigned char* > :: const_iterator block;
  195011           5 :      for ( block = SgVariantExpression::pools.begin(); block != SgVariantExpression::pools.end() ; ++block )
  195012             :         {
  195013           0 :           pointer = (SgVariantExpression*)(*block);
  195014           0 :           for (unsigned i = 0; i < SgVariantExpression::pool_size; ++i )
  195015             :              {
  195016             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  195017             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  195018             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  195019             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  195020             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  195021             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  195022             :             // properly; so this will have to be checked next.
  195023             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  195024             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  195025           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  195026             :                   {
  195027           0 :                     pointer[i].set_freepointer((SgVariantExpression*)(globalIndex));
  195028           0 :                     globalIndex++;
  195029             :                   }
  195030             :                else
  195031             :                   {
  195032           0 :                     pointer[i].set_freepointer(NULL);
  195033             :                   }
  195034             :               }
  195035             :         }
  195036           5 :      return globalIndex;
  195037             :    }
  195038             : 
  195039             : //############################################################################
  195040             : // JH (01/14/2006)
  195041             : void
  195042           5 : SgVariantExpression::resetValidFreepointers( )
  195043             :    {
  195044           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  195045           5 :      SgVariantExpression* pointer = NULL;
  195046           5 :      std::vector < unsigned char* > :: const_iterator block;
  195047           5 :      SgVariantExpression* pointerOfLinkedList = NULL;
  195048           5 :      for ( block = SgVariantExpression::pools.begin(); block != SgVariantExpression::pools.end() ; ++block )
  195049             :         {
  195050           0 :           pointer = (SgVariantExpression*)(*block);
  195051           0 :           for (unsigned i = 0; i < SgVariantExpression::pool_size; ++i )
  195052             :              {
  195053             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  195054             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  195055             :             // memory blocks!.
  195056           0 :                if ( pointer[i].get_freepointer() != NULL )
  195057             :                   {
  195058           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  195059             :                   }
  195060             :                else
  195061             :                   {
  195062           0 :                     if ( pointerOfLinkedList == NULL )
  195063             :                        {
  195064           0 :                          SgVariantExpression::next_node = &(pointer[i]);
  195065             :                        }
  195066             :                     else
  195067             :                        {
  195068             :                       // printf ("In SgVariantExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  195069           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  195070             :                        }
  195071             :                     pointerOfLinkedList = &(pointer[i]);
  195072             :                   }
  195073             :               }
  195074             :         }
  195075             : 
  195076           5 :      if ( pointerOfLinkedList != NULL )
  195077             :         {
  195078             :        // printf ("In SgVariantExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  195079           0 :           pointerOfLinkedList->set_freepointer(NULL);
  195080             :        // DQ (6/6/2010): Temporary debugging...
  195081             :        //   ROSE_ASSERT(false);
  195082             :         }
  195083             : 
  195084           5 :      return ;
  195085             :    }
  195086             : 
  195087             : //############################################################################
  195088             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  195089             :  * within the memory pool and resets the freepointers, in order to achieve a 
  195090             :  * linked list, that has no jumps and starts at the beginning! This function 
  195091             :  * does not extend the memory pool, since we do not delete any memory blocks,
  195092             :  * but delete the valid objects.  
  195093             :  */
  195094             : void
  195095           0 : SgVariantExpression::clearMemoryPool( )
  195096             :    {
  195097             :   // printf ("Inside of SgVariantExpression::clearMemoryPool() \n");
  195098             : 
  195099           0 :      SgVariantExpression* pointer = NULL, *tempPointer = NULL;
  195100           0 :      std::vector < unsigned char* > :: const_iterator block;
  195101           0 :      if ( SgVariantExpression::pools.empty() == false )
  195102             :         {
  195103           0 :           block = SgVariantExpression::pools.begin() ;
  195104           0 :           SgVariantExpression::next_node = (SgVariantExpression*) (*block);
  195105             : 
  195106           0 :           while ( block != SgVariantExpression::pools.end() )
  195107             :              {
  195108           0 :                pointer = (SgVariantExpression*) (*block);
  195109           0 :                if ( tempPointer != NULL )
  195110             :                   {
  195111           0 :                     tempPointer->set_freepointer(pointer);
  195112             :                   }
  195113           0 :                for (unsigned i = 0; i < SgVariantExpression::pool_size - 1; ++i)
  195114             :                   {
  195115           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  195116             :                   }
  195117           0 :                 pointer[SgVariantExpression::pool_size-1].set_freepointer(NULL);
  195118           0 :                 tempPointer = &(pointer[SgVariantExpression::pool_size-1]);
  195119           0 :                 ++block;
  195120             :              }
  195121             :         }
  195122           0 :    }
  195123             : 
  195124           5 : void SgVariantExpression::deleteMemoryPool() {
  195125           5 :   for (auto p: SgVariantExpression::pools) {
  195126           0 :     ROSE_FREE(p);
  195127             :   }
  195128           5 :   SgVariantExpression::next_node = nullptr;
  195129           5 :   SgVariantExpression::pools.clear();
  195130           5 : }
  195131             : 
  195132             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  195133             : //                 reading multiple binary files to for a single AST.
  195134             : /////////// new version ////////////////////////////////
  195135             : //############################################################################
  195136             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  195137             : void
  195138           2 : SgVariantExpression::extendMemoryPoolForFileIO( )
  195139             :   {
  195140           2 :     size_t blockIndex = SgVariantExpression::pools.size();
  195141           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVariantExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariantExpression);
  195142             : 
  195143           2 :     while ( (blockIndex * SgVariantExpression::pool_size) < newPoolSize)
  195144             :       {
  195145             : #if ROSE_ALLOC_TRACE
  195146             :         if (blockIndex > 0) {
  195147             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVariantExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariantExpression) = %" PRIuPTR " SgVariantExpression::pool_size = %d \n",
  195148             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVariantExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariantExpression),SgVariantExpression::pool_size);
  195149             :         }
  195150             : #endif
  195151             : 
  195152           0 :         SgVariantExpression * pointer = (SgVariantExpression*) ROSE_MALLOC ( SgVariantExpression::pool_size * sizeof(SgVariantExpression) );
  195153           0 :         assert( pointer != NULL );
  195154             : #if ROSE_ALLOC_MEMSET == 1
  195155             :         memset(pointer, 0x00, SgVariantExpression::pool_size * sizeof(SgVariantExpression));
  195156             : #elif ROSE_ALLOC_MEMSET == 2
  195157             :         memset(pointer, 0xCC, SgVariantExpression::pool_size * sizeof(SgVariantExpression));
  195158             : #endif
  195159           0 :         SgVariantExpression::pools.push_back( (unsigned char*)(pointer) );
  195160           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVariantExpression::pool_size * sizeof(SgVariantExpression), V_SgVariantExpression ) );
  195161             : 
  195162           0 :         if ( SgVariantExpression::next_node != NULL ) {
  195163           0 :           if ( blockIndex > 0 ) {
  195164           0 :             SgVariantExpression * blkptr = (SgVariantExpression*)(SgVariantExpression::pools[blockIndex-1]);
  195165           0 :             blkptr[ SgVariantExpression::pool_size - 1 ].set_freepointer(pointer);
  195166             :           }
  195167             :         } else {
  195168           0 :           SgVariantExpression::next_node = pointer;
  195169             :         }
  195170             : 
  195171           0 :         for (unsigned i = 0; i < SgVariantExpression::pool_size-1; ++i)
  195172             :            {
  195173           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  195174             :            }
  195175           0 :         pointer[ SgVariantExpression::pool_size -1 ].set_freepointer(NULL);
  195176             : 
  195177           0 :         blockIndex++;
  195178             :       }
  195179           2 :   }
  195180             : 
  195181             : //############################################################################
  195182             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  195183             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  195184             :  * not compressed. However, that stuff is not yet implemented! 
  195185             :  */
  195186             : unsigned long
  195187           0 : SgVariantExpression::getNumberOfLastValidPointer()
  195188             :    {
  195189           0 :       SgVariantExpression* testPointer = (SgVariantExpression*)(SgVariantExpression::pools.back());
  195190           0 :       unsigned long localIndex = SgVariantExpression::pool_size - 1;
  195191           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  195192             :          {
  195193           0 :            localIndex--;
  195194             :          }
  195195           0 :       return (localIndex + SgVariantExpression::pool_size * (SgVariantExpression::pools.size()-1));
  195196             :    }
  195197             : 
  195198             : //############################################################################
  195199             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  195200             :  * memory pool and initializes the data member in class SgVariantExpressionStroageClass
  195201             :  * from its counterpart of SgVariantExpression. The return value is just for checking, 
  195202             :  * that the whole StorageClassArray is initialized!
  195203             :  */
  195204             : unsigned long
  195205           0 : SgVariantExpression::initializeStorageClassArray( SgVariantExpressionStorageClass *storageArray )
  195206             :    {
  195207           0 :      unsigned long storageCounter = 0;
  195208           0 :      std::vector < unsigned char* > :: const_iterator block = SgVariantExpression::pools.begin();
  195209           0 :      SgVariantExpression* pointer = NULL;
  195210           0 :      while ( block != SgVariantExpression::pools.end() ) {
  195211           0 :           pointer = (SgVariantExpression*) (*block);
  195212           0 :           for ( unsigned i = 0; i < SgVariantExpression::pool_size; ++i ) {
  195213           0 :                if ( pointer->get_freepointer() != NULL ) {
  195214           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  195215           0 :                  storageArray++;
  195216           0 :                  storageCounter++;
  195217             :                }
  195218           0 :                pointer++;
  195219             :              }
  195220           0 :            block++;
  195221             :         }
  195222           0 :      return storageCounter;
  195223             :    }
  195224             : 
  195225             : /* #line 195226 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  195226             : 
  195227             : 
  195228             : 
  195229             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  195230             : 
  195231             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  195232             : 
  195233             : //############################################################################
  195234             : /* JH (02/02/2006) Constructor of the IR node SgSubscriptExpression that takes its 
  195235             :  * corresponding StorageClass as parameter
  195236             :  */
  195237           0 : SgSubscriptExpression :: SgSubscriptExpression ( const SgSubscriptExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  195238             :    {
  195239             : 
  195240             : 
  195241             : /* #line 195242 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  195242             : 
  195243           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  195244           0 :      p_lowerBound =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lowerBound) );
  195245           0 :      p_upperBound =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_upperBound) );
  195246           0 :      p_stride =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_stride) );
  195247             : 
  195248             : 
  195249             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  195250             : 
  195251             : 
  195252           0 :    }
  195253             : 
  195254             : //############################################################################
  195255             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  195256             :  * within the working AST. 
  195257             :  */
  195258           0 : SgSubscriptExpression * SgSubscriptExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  195259           0 :      SgSubscriptExpression* returnPointer = NULL;
  195260           0 :      if ( globalIndex != 0 )
  195261             :         {
  195262             : 
  195263             : #if FILE_IO_EXTRA_CHECK
  195264           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSubscriptExpression ) ) <= globalIndex ) ;
  195265           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSubscriptExpression + 1 ) ) );
  195266             : #endif
  195267           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSubscriptExpression )  
  195268           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSubscriptExpression );
  195269           0 :           unsigned long positionInPool = localIndex % SgSubscriptExpression::pool_size;
  195270           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSubscriptExpression::pool_size;
  195271             : 
  195272             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  195273             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  195274             : 
  195275           0 :           returnPointer = &( ( (SgSubscriptExpression*)(SgSubscriptExpression::pools[memoryBlock]) ) [positionInPool]) ;
  195276             : 
  195277           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  195278             :         }
  195279           0 :      return returnPointer ;
  195280             :    }
  195281             : 
  195282             : //############################################################################
  195283             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  195284             :   for the AST with the index astIndex
  195285             : */
  195286           0 : SgSubscriptExpression * SgSubscriptExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  195287           0 :      SgSubscriptExpression* returnPointer = NULL;
  195288           0 :      if ( globalIndex != 0 )
  195289             :         {
  195290             : 
  195291             : #if FILE_IO_EXTRA_CHECK
  195292           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSubscriptExpression ) ) <= globalIndex ) ;
  195293           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSubscriptExpression + 1 ) ) );
  195294             : #endif
  195295           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSubscriptExpression )
  195296           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSubscriptExpression );
  195297           0 :           unsigned long positionInPool = localIndex % SgSubscriptExpression::pool_size ;
  195298           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSubscriptExpression::pool_size ;
  195299             : 
  195300             : #if FILE_IO_EXTRA_CHECK
  195301             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  195302             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  195303             : #endif
  195304             : 
  195305           0 :           returnPointer = &( ( (SgSubscriptExpression*)(SgSubscriptExpression::pools[memoryBlock]) ) [positionInPool]) ;
  195306             : 
  195307             : #if FILE_IO_EXTRA_CHECK
  195308           0 :           assert ( returnPointer != NULL ) ;
  195309             : #endif
  195310             :         }
  195311           0 :      return returnPointer ;
  195312             :    }
  195313             : 
  195314             : //############################################################################
  195315             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  195316             :  * pool size! We set for every valid object in the memory pool the freepointer
  195317             :  * to the global index and increase the global index afterwards. For all the 
  195318             :  * invalid objects (means address ranges within the memory pool that were not
  195319             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  195320             :  * distinguish valid from invalid objects! 
  195321             :  */
  195322             : unsigned long
  195323           5 : SgSubscriptExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  195324             :    {
  195325           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  195326           5 :      SgSubscriptExpression* pointer = NULL;
  195327           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  195328           5 :      std::vector < unsigned char* > :: const_iterator block;
  195329           5 :      for ( block = SgSubscriptExpression::pools.begin(); block != SgSubscriptExpression::pools.end() ; ++block )
  195330             :         {
  195331           0 :           pointer = (SgSubscriptExpression*)(*block);
  195332           0 :           for (unsigned i = 0; i < SgSubscriptExpression::pool_size; ++i )
  195333             :              {
  195334             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  195335             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  195336             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  195337             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  195338             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  195339             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  195340             :             // properly; so this will have to be checked next.
  195341             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  195342             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  195343           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  195344             :                   {
  195345           0 :                     pointer[i].set_freepointer((SgSubscriptExpression*)(globalIndex));
  195346           0 :                     globalIndex++;
  195347             :                   }
  195348             :                else
  195349             :                   {
  195350           0 :                     pointer[i].set_freepointer(NULL);
  195351             :                   }
  195352             :               }
  195353             :         }
  195354           5 :      return globalIndex;
  195355             :    }
  195356             : 
  195357             : //############################################################################
  195358             : // JH (01/14/2006)
  195359             : void
  195360           5 : SgSubscriptExpression::resetValidFreepointers( )
  195361             :    {
  195362           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  195363           5 :      SgSubscriptExpression* pointer = NULL;
  195364           5 :      std::vector < unsigned char* > :: const_iterator block;
  195365           5 :      SgSubscriptExpression* pointerOfLinkedList = NULL;
  195366           5 :      for ( block = SgSubscriptExpression::pools.begin(); block != SgSubscriptExpression::pools.end() ; ++block )
  195367             :         {
  195368           0 :           pointer = (SgSubscriptExpression*)(*block);
  195369           0 :           for (unsigned i = 0; i < SgSubscriptExpression::pool_size; ++i )
  195370             :              {
  195371             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  195372             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  195373             :             // memory blocks!.
  195374           0 :                if ( pointer[i].get_freepointer() != NULL )
  195375             :                   {
  195376           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  195377             :                   }
  195378             :                else
  195379             :                   {
  195380           0 :                     if ( pointerOfLinkedList == NULL )
  195381             :                        {
  195382           0 :                          SgSubscriptExpression::next_node = &(pointer[i]);
  195383             :                        }
  195384             :                     else
  195385             :                        {
  195386             :                       // printf ("In SgSubscriptExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  195387           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  195388             :                        }
  195389             :                     pointerOfLinkedList = &(pointer[i]);
  195390             :                   }
  195391             :               }
  195392             :         }
  195393             : 
  195394           5 :      if ( pointerOfLinkedList != NULL )
  195395             :         {
  195396             :        // printf ("In SgSubscriptExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  195397           0 :           pointerOfLinkedList->set_freepointer(NULL);
  195398             :        // DQ (6/6/2010): Temporary debugging...
  195399             :        //   ROSE_ASSERT(false);
  195400             :         }
  195401             : 
  195402           5 :      return ;
  195403             :    }
  195404             : 
  195405             : //############################################################################
  195406             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  195407             :  * within the memory pool and resets the freepointers, in order to achieve a 
  195408             :  * linked list, that has no jumps and starts at the beginning! This function 
  195409             :  * does not extend the memory pool, since we do not delete any memory blocks,
  195410             :  * but delete the valid objects.  
  195411             :  */
  195412             : void
  195413           0 : SgSubscriptExpression::clearMemoryPool( )
  195414             :    {
  195415             :   // printf ("Inside of SgSubscriptExpression::clearMemoryPool() \n");
  195416             : 
  195417           0 :      SgSubscriptExpression* pointer = NULL, *tempPointer = NULL;
  195418           0 :      std::vector < unsigned char* > :: const_iterator block;
  195419           0 :      if ( SgSubscriptExpression::pools.empty() == false )
  195420             :         {
  195421           0 :           block = SgSubscriptExpression::pools.begin() ;
  195422           0 :           SgSubscriptExpression::next_node = (SgSubscriptExpression*) (*block);
  195423             : 
  195424           0 :           while ( block != SgSubscriptExpression::pools.end() )
  195425             :              {
  195426           0 :                pointer = (SgSubscriptExpression*) (*block);
  195427           0 :                if ( tempPointer != NULL )
  195428             :                   {
  195429           0 :                     tempPointer->set_freepointer(pointer);
  195430             :                   }
  195431           0 :                for (unsigned i = 0; i < SgSubscriptExpression::pool_size - 1; ++i)
  195432             :                   {
  195433           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  195434             :                   }
  195435           0 :                 pointer[SgSubscriptExpression::pool_size-1].set_freepointer(NULL);
  195436           0 :                 tempPointer = &(pointer[SgSubscriptExpression::pool_size-1]);
  195437           0 :                 ++block;
  195438             :              }
  195439             :         }
  195440           0 :    }
  195441             : 
  195442           5 : void SgSubscriptExpression::deleteMemoryPool() {
  195443           5 :   for (auto p: SgSubscriptExpression::pools) {
  195444           0 :     ROSE_FREE(p);
  195445             :   }
  195446           5 :   SgSubscriptExpression::next_node = nullptr;
  195447           5 :   SgSubscriptExpression::pools.clear();
  195448           5 : }
  195449             : 
  195450             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  195451             : //                 reading multiple binary files to for a single AST.
  195452             : /////////// new version ////////////////////////////////
  195453             : //############################################################################
  195454             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  195455             : void
  195456           2 : SgSubscriptExpression::extendMemoryPoolForFileIO( )
  195457             :   {
  195458           2 :     size_t blockIndex = SgSubscriptExpression::pools.size();
  195459           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSubscriptExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSubscriptExpression);
  195460             : 
  195461           2 :     while ( (blockIndex * SgSubscriptExpression::pool_size) < newPoolSize)
  195462             :       {
  195463             : #if ROSE_ALLOC_TRACE
  195464             :         if (blockIndex > 0) {
  195465             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSubscriptExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSubscriptExpression) = %" PRIuPTR " SgSubscriptExpression::pool_size = %d \n",
  195466             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSubscriptExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSubscriptExpression),SgSubscriptExpression::pool_size);
  195467             :         }
  195468             : #endif
  195469             : 
  195470           0 :         SgSubscriptExpression * pointer = (SgSubscriptExpression*) ROSE_MALLOC ( SgSubscriptExpression::pool_size * sizeof(SgSubscriptExpression) );
  195471           0 :         assert( pointer != NULL );
  195472             : #if ROSE_ALLOC_MEMSET == 1
  195473             :         memset(pointer, 0x00, SgSubscriptExpression::pool_size * sizeof(SgSubscriptExpression));
  195474             : #elif ROSE_ALLOC_MEMSET == 2
  195475             :         memset(pointer, 0xCC, SgSubscriptExpression::pool_size * sizeof(SgSubscriptExpression));
  195476             : #endif
  195477           0 :         SgSubscriptExpression::pools.push_back( (unsigned char*)(pointer) );
  195478           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSubscriptExpression::pool_size * sizeof(SgSubscriptExpression), V_SgSubscriptExpression ) );
  195479             : 
  195480           0 :         if ( SgSubscriptExpression::next_node != NULL ) {
  195481           0 :           if ( blockIndex > 0 ) {
  195482           0 :             SgSubscriptExpression * blkptr = (SgSubscriptExpression*)(SgSubscriptExpression::pools[blockIndex-1]);
  195483           0 :             blkptr[ SgSubscriptExpression::pool_size - 1 ].set_freepointer(pointer);
  195484             :           }
  195485             :         } else {
  195486           0 :           SgSubscriptExpression::next_node = pointer;
  195487             :         }
  195488             : 
  195489           0 :         for (unsigned i = 0; i < SgSubscriptExpression::pool_size-1; ++i)
  195490             :            {
  195491           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  195492             :            }
  195493           0 :         pointer[ SgSubscriptExpression::pool_size -1 ].set_freepointer(NULL);
  195494             : 
  195495           0 :         blockIndex++;
  195496             :       }
  195497           2 :   }
  195498             : 
  195499             : //############################################################################
  195500             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  195501             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  195502             :  * not compressed. However, that stuff is not yet implemented! 
  195503             :  */
  195504             : unsigned long
  195505           0 : SgSubscriptExpression::getNumberOfLastValidPointer()
  195506             :    {
  195507           0 :       SgSubscriptExpression* testPointer = (SgSubscriptExpression*)(SgSubscriptExpression::pools.back());
  195508           0 :       unsigned long localIndex = SgSubscriptExpression::pool_size - 1;
  195509           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  195510             :          {
  195511           0 :            localIndex--;
  195512             :          }
  195513           0 :       return (localIndex + SgSubscriptExpression::pool_size * (SgSubscriptExpression::pools.size()-1));
  195514             :    }
  195515             : 
  195516             : //############################################################################
  195517             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  195518             :  * memory pool and initializes the data member in class SgSubscriptExpressionStroageClass
  195519             :  * from its counterpart of SgSubscriptExpression. The return value is just for checking, 
  195520             :  * that the whole StorageClassArray is initialized!
  195521             :  */
  195522             : unsigned long
  195523           0 : SgSubscriptExpression::initializeStorageClassArray( SgSubscriptExpressionStorageClass *storageArray )
  195524             :    {
  195525           0 :      unsigned long storageCounter = 0;
  195526           0 :      std::vector < unsigned char* > :: const_iterator block = SgSubscriptExpression::pools.begin();
  195527           0 :      SgSubscriptExpression* pointer = NULL;
  195528           0 :      while ( block != SgSubscriptExpression::pools.end() ) {
  195529           0 :           pointer = (SgSubscriptExpression*) (*block);
  195530           0 :           for ( unsigned i = 0; i < SgSubscriptExpression::pool_size; ++i ) {
  195531           0 :                if ( pointer->get_freepointer() != NULL ) {
  195532           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  195533           0 :                  storageArray++;
  195534           0 :                  storageCounter++;
  195535             :                }
  195536           0 :                pointer++;
  195537             :              }
  195538           0 :            block++;
  195539             :         }
  195540           0 :      return storageCounter;
  195541             :    }
  195542             : 
  195543             : /* #line 195544 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  195544             : 
  195545             : 
  195546             : 
  195547             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  195548             : 
  195549             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  195550             : 
  195551             : //############################################################################
  195552             : /* JH (02/02/2006) Constructor of the IR node SgColonShapeExp that takes its 
  195553             :  * corresponding StorageClass as parameter
  195554             :  */
  195555           0 : SgColonShapeExp :: SgColonShapeExp ( const SgColonShapeExpStorageClass& storageSource )   : SgExpression (storageSource)
  195556             :    {
  195557             : 
  195558             : 
  195559             : /* #line 195560 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  195560             : 
  195561           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  195562             : 
  195563             : 
  195564             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  195565             : 
  195566             : 
  195567           0 :    }
  195568             : 
  195569             : //############################################################################
  195570             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  195571             :  * within the working AST. 
  195572             :  */
  195573           0 : SgColonShapeExp * SgColonShapeExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  195574           0 :      SgColonShapeExp* returnPointer = NULL;
  195575           0 :      if ( globalIndex != 0 )
  195576             :         {
  195577             : 
  195578             : #if FILE_IO_EXTRA_CHECK
  195579           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgColonShapeExp ) ) <= globalIndex ) ;
  195580           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgColonShapeExp + 1 ) ) );
  195581             : #endif
  195582           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgColonShapeExp )  
  195583           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgColonShapeExp );
  195584           0 :           unsigned long positionInPool = localIndex % SgColonShapeExp::pool_size;
  195585           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgColonShapeExp::pool_size;
  195586             : 
  195587             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  195588             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  195589             : 
  195590           0 :           returnPointer = &( ( (SgColonShapeExp*)(SgColonShapeExp::pools[memoryBlock]) ) [positionInPool]) ;
  195591             : 
  195592           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  195593             :         }
  195594           0 :      return returnPointer ;
  195595             :    }
  195596             : 
  195597             : //############################################################################
  195598             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  195599             :   for the AST with the index astIndex
  195600             : */
  195601           0 : SgColonShapeExp * SgColonShapeExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  195602           0 :      SgColonShapeExp* returnPointer = NULL;
  195603           0 :      if ( globalIndex != 0 )
  195604             :         {
  195605             : 
  195606             : #if FILE_IO_EXTRA_CHECK
  195607           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgColonShapeExp ) ) <= globalIndex ) ;
  195608           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgColonShapeExp + 1 ) ) );
  195609             : #endif
  195610           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgColonShapeExp )
  195611           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgColonShapeExp );
  195612           0 :           unsigned long positionInPool = localIndex % SgColonShapeExp::pool_size ;
  195613           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgColonShapeExp::pool_size ;
  195614             : 
  195615             : #if FILE_IO_EXTRA_CHECK
  195616             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  195617             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  195618             : #endif
  195619             : 
  195620           0 :           returnPointer = &( ( (SgColonShapeExp*)(SgColonShapeExp::pools[memoryBlock]) ) [positionInPool]) ;
  195621             : 
  195622             : #if FILE_IO_EXTRA_CHECK
  195623           0 :           assert ( returnPointer != NULL ) ;
  195624             : #endif
  195625             :         }
  195626           0 :      return returnPointer ;
  195627             :    }
  195628             : 
  195629             : //############################################################################
  195630             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  195631             :  * pool size! We set for every valid object in the memory pool the freepointer
  195632             :  * to the global index and increase the global index afterwards. For all the 
  195633             :  * invalid objects (means address ranges within the memory pool that were not
  195634             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  195635             :  * distinguish valid from invalid objects! 
  195636             :  */
  195637             : unsigned long
  195638           5 : SgColonShapeExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  195639             :    {
  195640           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  195641           5 :      SgColonShapeExp* pointer = NULL;
  195642           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  195643           5 :      std::vector < unsigned char* > :: const_iterator block;
  195644           5 :      for ( block = SgColonShapeExp::pools.begin(); block != SgColonShapeExp::pools.end() ; ++block )
  195645             :         {
  195646           0 :           pointer = (SgColonShapeExp*)(*block);
  195647           0 :           for (unsigned i = 0; i < SgColonShapeExp::pool_size; ++i )
  195648             :              {
  195649             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  195650             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  195651             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  195652             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  195653             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  195654             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  195655             :             // properly; so this will have to be checked next.
  195656             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  195657             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  195658           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  195659             :                   {
  195660           0 :                     pointer[i].set_freepointer((SgColonShapeExp*)(globalIndex));
  195661           0 :                     globalIndex++;
  195662             :                   }
  195663             :                else
  195664             :                   {
  195665           0 :                     pointer[i].set_freepointer(NULL);
  195666             :                   }
  195667             :               }
  195668             :         }
  195669           5 :      return globalIndex;
  195670             :    }
  195671             : 
  195672             : //############################################################################
  195673             : // JH (01/14/2006)
  195674             : void
  195675           5 : SgColonShapeExp::resetValidFreepointers( )
  195676             :    {
  195677           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  195678           5 :      SgColonShapeExp* pointer = NULL;
  195679           5 :      std::vector < unsigned char* > :: const_iterator block;
  195680           5 :      SgColonShapeExp* pointerOfLinkedList = NULL;
  195681           5 :      for ( block = SgColonShapeExp::pools.begin(); block != SgColonShapeExp::pools.end() ; ++block )
  195682             :         {
  195683           0 :           pointer = (SgColonShapeExp*)(*block);
  195684           0 :           for (unsigned i = 0; i < SgColonShapeExp::pool_size; ++i )
  195685             :              {
  195686             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  195687             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  195688             :             // memory blocks!.
  195689           0 :                if ( pointer[i].get_freepointer() != NULL )
  195690             :                   {
  195691           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  195692             :                   }
  195693             :                else
  195694             :                   {
  195695           0 :                     if ( pointerOfLinkedList == NULL )
  195696             :                        {
  195697           0 :                          SgColonShapeExp::next_node = &(pointer[i]);
  195698             :                        }
  195699             :                     else
  195700             :                        {
  195701             :                       // printf ("In SgColonShapeExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  195702           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  195703             :                        }
  195704             :                     pointerOfLinkedList = &(pointer[i]);
  195705             :                   }
  195706             :               }
  195707             :         }
  195708             : 
  195709           5 :      if ( pointerOfLinkedList != NULL )
  195710             :         {
  195711             :        // printf ("In SgColonShapeExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  195712           0 :           pointerOfLinkedList->set_freepointer(NULL);
  195713             :        // DQ (6/6/2010): Temporary debugging...
  195714             :        //   ROSE_ASSERT(false);
  195715             :         }
  195716             : 
  195717           5 :      return ;
  195718             :    }
  195719             : 
  195720             : //############################################################################
  195721             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  195722             :  * within the memory pool and resets the freepointers, in order to achieve a 
  195723             :  * linked list, that has no jumps and starts at the beginning! This function 
  195724             :  * does not extend the memory pool, since we do not delete any memory blocks,
  195725             :  * but delete the valid objects.  
  195726             :  */
  195727             : void
  195728           0 : SgColonShapeExp::clearMemoryPool( )
  195729             :    {
  195730             :   // printf ("Inside of SgColonShapeExp::clearMemoryPool() \n");
  195731             : 
  195732           0 :      SgColonShapeExp* pointer = NULL, *tempPointer = NULL;
  195733           0 :      std::vector < unsigned char* > :: const_iterator block;
  195734           0 :      if ( SgColonShapeExp::pools.empty() == false )
  195735             :         {
  195736           0 :           block = SgColonShapeExp::pools.begin() ;
  195737           0 :           SgColonShapeExp::next_node = (SgColonShapeExp*) (*block);
  195738             : 
  195739           0 :           while ( block != SgColonShapeExp::pools.end() )
  195740             :              {
  195741           0 :                pointer = (SgColonShapeExp*) (*block);
  195742           0 :                if ( tempPointer != NULL )
  195743             :                   {
  195744           0 :                     tempPointer->set_freepointer(pointer);
  195745             :                   }
  195746           0 :                for (unsigned i = 0; i < SgColonShapeExp::pool_size - 1; ++i)
  195747             :                   {
  195748           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  195749             :                   }
  195750           0 :                 pointer[SgColonShapeExp::pool_size-1].set_freepointer(NULL);
  195751           0 :                 tempPointer = &(pointer[SgColonShapeExp::pool_size-1]);
  195752           0 :                 ++block;
  195753             :              }
  195754             :         }
  195755           0 :    }
  195756             : 
  195757           5 : void SgColonShapeExp::deleteMemoryPool() {
  195758           5 :   for (auto p: SgColonShapeExp::pools) {
  195759           0 :     ROSE_FREE(p);
  195760             :   }
  195761           5 :   SgColonShapeExp::next_node = nullptr;
  195762           5 :   SgColonShapeExp::pools.clear();
  195763           5 : }
  195764             : 
  195765             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  195766             : //                 reading multiple binary files to for a single AST.
  195767             : /////////// new version ////////////////////////////////
  195768             : //############################################################################
  195769             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  195770             : void
  195771           2 : SgColonShapeExp::extendMemoryPoolForFileIO( )
  195772             :   {
  195773           2 :     size_t blockIndex = SgColonShapeExp::pools.size();
  195774           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgColonShapeExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgColonShapeExp);
  195775             : 
  195776           2 :     while ( (blockIndex * SgColonShapeExp::pool_size) < newPoolSize)
  195777             :       {
  195778             : #if ROSE_ALLOC_TRACE
  195779             :         if (blockIndex > 0) {
  195780             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgColonShapeExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgColonShapeExp) = %" PRIuPTR " SgColonShapeExp::pool_size = %d \n",
  195781             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgColonShapeExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgColonShapeExp),SgColonShapeExp::pool_size);
  195782             :         }
  195783             : #endif
  195784             : 
  195785           0 :         SgColonShapeExp * pointer = (SgColonShapeExp*) ROSE_MALLOC ( SgColonShapeExp::pool_size * sizeof(SgColonShapeExp) );
  195786           0 :         assert( pointer != NULL );
  195787             : #if ROSE_ALLOC_MEMSET == 1
  195788             :         memset(pointer, 0x00, SgColonShapeExp::pool_size * sizeof(SgColonShapeExp));
  195789             : #elif ROSE_ALLOC_MEMSET == 2
  195790             :         memset(pointer, 0xCC, SgColonShapeExp::pool_size * sizeof(SgColonShapeExp));
  195791             : #endif
  195792           0 :         SgColonShapeExp::pools.push_back( (unsigned char*)(pointer) );
  195793           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgColonShapeExp::pool_size * sizeof(SgColonShapeExp), V_SgColonShapeExp ) );
  195794             : 
  195795           0 :         if ( SgColonShapeExp::next_node != NULL ) {
  195796           0 :           if ( blockIndex > 0 ) {
  195797           0 :             SgColonShapeExp * blkptr = (SgColonShapeExp*)(SgColonShapeExp::pools[blockIndex-1]);
  195798           0 :             blkptr[ SgColonShapeExp::pool_size - 1 ].set_freepointer(pointer);
  195799             :           }
  195800             :         } else {
  195801           0 :           SgColonShapeExp::next_node = pointer;
  195802             :         }
  195803             : 
  195804           0 :         for (unsigned i = 0; i < SgColonShapeExp::pool_size-1; ++i)
  195805             :            {
  195806           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  195807             :            }
  195808           0 :         pointer[ SgColonShapeExp::pool_size -1 ].set_freepointer(NULL);
  195809             : 
  195810           0 :         blockIndex++;
  195811             :       }
  195812           2 :   }
  195813             : 
  195814             : //############################################################################
  195815             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  195816             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  195817             :  * not compressed. However, that stuff is not yet implemented! 
  195818             :  */
  195819             : unsigned long
  195820           0 : SgColonShapeExp::getNumberOfLastValidPointer()
  195821             :    {
  195822           0 :       SgColonShapeExp* testPointer = (SgColonShapeExp*)(SgColonShapeExp::pools.back());
  195823           0 :       unsigned long localIndex = SgColonShapeExp::pool_size - 1;
  195824           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  195825             :          {
  195826           0 :            localIndex--;
  195827             :          }
  195828           0 :       return (localIndex + SgColonShapeExp::pool_size * (SgColonShapeExp::pools.size()-1));
  195829             :    }
  195830             : 
  195831             : //############################################################################
  195832             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  195833             :  * memory pool and initializes the data member in class SgColonShapeExpStroageClass
  195834             :  * from its counterpart of SgColonShapeExp. The return value is just for checking, 
  195835             :  * that the whole StorageClassArray is initialized!
  195836             :  */
  195837             : unsigned long
  195838           0 : SgColonShapeExp::initializeStorageClassArray( SgColonShapeExpStorageClass *storageArray )
  195839             :    {
  195840           0 :      unsigned long storageCounter = 0;
  195841           0 :      std::vector < unsigned char* > :: const_iterator block = SgColonShapeExp::pools.begin();
  195842           0 :      SgColonShapeExp* pointer = NULL;
  195843           0 :      while ( block != SgColonShapeExp::pools.end() ) {
  195844           0 :           pointer = (SgColonShapeExp*) (*block);
  195845           0 :           for ( unsigned i = 0; i < SgColonShapeExp::pool_size; ++i ) {
  195846           0 :                if ( pointer->get_freepointer() != NULL ) {
  195847           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  195848           0 :                  storageArray++;
  195849           0 :                  storageCounter++;
  195850             :                }
  195851           0 :                pointer++;
  195852             :              }
  195853           0 :            block++;
  195854             :         }
  195855           0 :      return storageCounter;
  195856             :    }
  195857             : 
  195858             : /* #line 195859 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  195859             : 
  195860             : 
  195861             : 
  195862             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  195863             : 
  195864             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  195865             : 
  195866             : //############################################################################
  195867             : /* JH (02/02/2006) Constructor of the IR node SgAsteriskShapeExp that takes its 
  195868             :  * corresponding StorageClass as parameter
  195869             :  */
  195870           0 : SgAsteriskShapeExp :: SgAsteriskShapeExp ( const SgAsteriskShapeExpStorageClass& storageSource )   : SgExpression (storageSource)
  195871             :    {
  195872             : 
  195873             : 
  195874             : /* #line 195875 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  195875             : 
  195876           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  195877             : 
  195878             : 
  195879             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  195880             : 
  195881             : 
  195882           0 :    }
  195883             : 
  195884             : //############################################################################
  195885             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  195886             :  * within the working AST. 
  195887             :  */
  195888           0 : SgAsteriskShapeExp * SgAsteriskShapeExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  195889           0 :      SgAsteriskShapeExp* returnPointer = NULL;
  195890           0 :      if ( globalIndex != 0 )
  195891             :         {
  195892             : 
  195893             : #if FILE_IO_EXTRA_CHECK
  195894           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAsteriskShapeExp ) ) <= globalIndex ) ;
  195895           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAsteriskShapeExp + 1 ) ) );
  195896             : #endif
  195897           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAsteriskShapeExp )  
  195898           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAsteriskShapeExp );
  195899           0 :           unsigned long positionInPool = localIndex % SgAsteriskShapeExp::pool_size;
  195900           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAsteriskShapeExp::pool_size;
  195901             : 
  195902             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  195903             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  195904             : 
  195905           0 :           returnPointer = &( ( (SgAsteriskShapeExp*)(SgAsteriskShapeExp::pools[memoryBlock]) ) [positionInPool]) ;
  195906             : 
  195907           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  195908             :         }
  195909           0 :      return returnPointer ;
  195910             :    }
  195911             : 
  195912             : //############################################################################
  195913             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  195914             :   for the AST with the index astIndex
  195915             : */
  195916           0 : SgAsteriskShapeExp * SgAsteriskShapeExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  195917           0 :      SgAsteriskShapeExp* returnPointer = NULL;
  195918           0 :      if ( globalIndex != 0 )
  195919             :         {
  195920             : 
  195921             : #if FILE_IO_EXTRA_CHECK
  195922           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAsteriskShapeExp ) ) <= globalIndex ) ;
  195923           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAsteriskShapeExp + 1 ) ) );
  195924             : #endif
  195925           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAsteriskShapeExp )
  195926           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAsteriskShapeExp );
  195927           0 :           unsigned long positionInPool = localIndex % SgAsteriskShapeExp::pool_size ;
  195928           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAsteriskShapeExp::pool_size ;
  195929             : 
  195930             : #if FILE_IO_EXTRA_CHECK
  195931             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  195932             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  195933             : #endif
  195934             : 
  195935           0 :           returnPointer = &( ( (SgAsteriskShapeExp*)(SgAsteriskShapeExp::pools[memoryBlock]) ) [positionInPool]) ;
  195936             : 
  195937             : #if FILE_IO_EXTRA_CHECK
  195938           0 :           assert ( returnPointer != NULL ) ;
  195939             : #endif
  195940             :         }
  195941           0 :      return returnPointer ;
  195942             :    }
  195943             : 
  195944             : //############################################################################
  195945             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  195946             :  * pool size! We set for every valid object in the memory pool the freepointer
  195947             :  * to the global index and increase the global index afterwards. For all the 
  195948             :  * invalid objects (means address ranges within the memory pool that were not
  195949             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  195950             :  * distinguish valid from invalid objects! 
  195951             :  */
  195952             : unsigned long
  195953           5 : SgAsteriskShapeExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  195954             :    {
  195955           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  195956           5 :      SgAsteriskShapeExp* pointer = NULL;
  195957           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  195958           5 :      std::vector < unsigned char* > :: const_iterator block;
  195959           6 :      for ( block = SgAsteriskShapeExp::pools.begin(); block != SgAsteriskShapeExp::pools.end() ; ++block )
  195960             :         {
  195961           1 :           pointer = (SgAsteriskShapeExp*)(*block);
  195962        2001 :           for (unsigned i = 0; i < SgAsteriskShapeExp::pool_size; ++i )
  195963             :              {
  195964             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  195965             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  195966             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  195967             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  195968             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  195969             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  195970             :             // properly; so this will have to be checked next.
  195971             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  195972             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  195973        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  195974             :                   {
  195975           1 :                     pointer[i].set_freepointer((SgAsteriskShapeExp*)(globalIndex));
  195976           1 :                     globalIndex++;
  195977             :                   }
  195978             :                else
  195979             :                   {
  195980        1999 :                     pointer[i].set_freepointer(NULL);
  195981             :                   }
  195982             :               }
  195983             :         }
  195984           5 :      return globalIndex;
  195985             :    }
  195986             : 
  195987             : //############################################################################
  195988             : // JH (01/14/2006)
  195989             : void
  195990           5 : SgAsteriskShapeExp::resetValidFreepointers( )
  195991             :    {
  195992           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  195993           5 :      SgAsteriskShapeExp* pointer = NULL;
  195994           5 :      std::vector < unsigned char* > :: const_iterator block;
  195995           5 :      SgAsteriskShapeExp* pointerOfLinkedList = NULL;
  195996           6 :      for ( block = SgAsteriskShapeExp::pools.begin(); block != SgAsteriskShapeExp::pools.end() ; ++block )
  195997             :         {
  195998           1 :           pointer = (SgAsteriskShapeExp*)(*block);
  195999        2001 :           for (unsigned i = 0; i < SgAsteriskShapeExp::pool_size; ++i )
  196000             :              {
  196001             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  196002             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  196003             :             // memory blocks!.
  196004        2000 :                if ( pointer[i].get_freepointer() != NULL )
  196005             :                   {
  196006           1 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  196007             :                   }
  196008             :                else
  196009             :                   {
  196010        1999 :                     if ( pointerOfLinkedList == NULL )
  196011             :                        {
  196012           1 :                          SgAsteriskShapeExp::next_node = &(pointer[i]);
  196013             :                        }
  196014             :                     else
  196015             :                        {
  196016             :                       // printf ("In SgAsteriskShapeExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  196017        1998 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  196018             :                        }
  196019             :                     pointerOfLinkedList = &(pointer[i]);
  196020             :                   }
  196021             :               }
  196022             :         }
  196023             : 
  196024           5 :      if ( pointerOfLinkedList != NULL )
  196025             :         {
  196026             :        // printf ("In SgAsteriskShapeExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  196027           1 :           pointerOfLinkedList->set_freepointer(NULL);
  196028             :        // DQ (6/6/2010): Temporary debugging...
  196029             :        //   ROSE_ASSERT(false);
  196030             :         }
  196031             : 
  196032           5 :      return ;
  196033             :    }
  196034             : 
  196035             : //############################################################################
  196036             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  196037             :  * within the memory pool and resets the freepointers, in order to achieve a 
  196038             :  * linked list, that has no jumps and starts at the beginning! This function 
  196039             :  * does not extend the memory pool, since we do not delete any memory blocks,
  196040             :  * but delete the valid objects.  
  196041             :  */
  196042             : void
  196043           0 : SgAsteriskShapeExp::clearMemoryPool( )
  196044             :    {
  196045             :   // printf ("Inside of SgAsteriskShapeExp::clearMemoryPool() \n");
  196046             : 
  196047           0 :      SgAsteriskShapeExp* pointer = NULL, *tempPointer = NULL;
  196048           0 :      std::vector < unsigned char* > :: const_iterator block;
  196049           0 :      if ( SgAsteriskShapeExp::pools.empty() == false )
  196050             :         {
  196051           0 :           block = SgAsteriskShapeExp::pools.begin() ;
  196052           0 :           SgAsteriskShapeExp::next_node = (SgAsteriskShapeExp*) (*block);
  196053             : 
  196054           0 :           while ( block != SgAsteriskShapeExp::pools.end() )
  196055             :              {
  196056           0 :                pointer = (SgAsteriskShapeExp*) (*block);
  196057           0 :                if ( tempPointer != NULL )
  196058             :                   {
  196059           0 :                     tempPointer->set_freepointer(pointer);
  196060             :                   }
  196061           0 :                for (unsigned i = 0; i < SgAsteriskShapeExp::pool_size - 1; ++i)
  196062             :                   {
  196063           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  196064             :                   }
  196065           0 :                 pointer[SgAsteriskShapeExp::pool_size-1].set_freepointer(NULL);
  196066           0 :                 tempPointer = &(pointer[SgAsteriskShapeExp::pool_size-1]);
  196067           0 :                 ++block;
  196068             :              }
  196069             :         }
  196070           0 :    }
  196071             : 
  196072           5 : void SgAsteriskShapeExp::deleteMemoryPool() {
  196073           6 :   for (auto p: SgAsteriskShapeExp::pools) {
  196074           1 :     ROSE_FREE(p);
  196075             :   }
  196076           5 :   SgAsteriskShapeExp::next_node = nullptr;
  196077           5 :   SgAsteriskShapeExp::pools.clear();
  196078           5 : }
  196079             : 
  196080             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  196081             : //                 reading multiple binary files to for a single AST.
  196082             : /////////// new version ////////////////////////////////
  196083             : //############################################################################
  196084             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  196085             : void
  196086           2 : SgAsteriskShapeExp::extendMemoryPoolForFileIO( )
  196087             :   {
  196088           2 :     size_t blockIndex = SgAsteriskShapeExp::pools.size();
  196089           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAsteriskShapeExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsteriskShapeExp);
  196090             : 
  196091           2 :     while ( (blockIndex * SgAsteriskShapeExp::pool_size) < newPoolSize)
  196092             :       {
  196093             : #if ROSE_ALLOC_TRACE
  196094             :         if (blockIndex > 0) {
  196095             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAsteriskShapeExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsteriskShapeExp) = %" PRIuPTR " SgAsteriskShapeExp::pool_size = %d \n",
  196096             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAsteriskShapeExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsteriskShapeExp),SgAsteriskShapeExp::pool_size);
  196097             :         }
  196098             : #endif
  196099             : 
  196100           0 :         SgAsteriskShapeExp * pointer = (SgAsteriskShapeExp*) ROSE_MALLOC ( SgAsteriskShapeExp::pool_size * sizeof(SgAsteriskShapeExp) );
  196101           0 :         assert( pointer != NULL );
  196102             : #if ROSE_ALLOC_MEMSET == 1
  196103             :         memset(pointer, 0x00, SgAsteriskShapeExp::pool_size * sizeof(SgAsteriskShapeExp));
  196104             : #elif ROSE_ALLOC_MEMSET == 2
  196105             :         memset(pointer, 0xCC, SgAsteriskShapeExp::pool_size * sizeof(SgAsteriskShapeExp));
  196106             : #endif
  196107           0 :         SgAsteriskShapeExp::pools.push_back( (unsigned char*)(pointer) );
  196108           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAsteriskShapeExp::pool_size * sizeof(SgAsteriskShapeExp), V_SgAsteriskShapeExp ) );
  196109             : 
  196110           0 :         if ( SgAsteriskShapeExp::next_node != NULL ) {
  196111           0 :           if ( blockIndex > 0 ) {
  196112           0 :             SgAsteriskShapeExp * blkptr = (SgAsteriskShapeExp*)(SgAsteriskShapeExp::pools[blockIndex-1]);
  196113           0 :             blkptr[ SgAsteriskShapeExp::pool_size - 1 ].set_freepointer(pointer);
  196114             :           }
  196115             :         } else {
  196116           0 :           SgAsteriskShapeExp::next_node = pointer;
  196117             :         }
  196118             : 
  196119           0 :         for (unsigned i = 0; i < SgAsteriskShapeExp::pool_size-1; ++i)
  196120             :            {
  196121           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  196122             :            }
  196123           0 :         pointer[ SgAsteriskShapeExp::pool_size -1 ].set_freepointer(NULL);
  196124             : 
  196125           0 :         blockIndex++;
  196126             :       }
  196127           2 :   }
  196128             : 
  196129             : //############################################################################
  196130             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  196131             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  196132             :  * not compressed. However, that stuff is not yet implemented! 
  196133             :  */
  196134             : unsigned long
  196135           0 : SgAsteriskShapeExp::getNumberOfLastValidPointer()
  196136             :    {
  196137           0 :       SgAsteriskShapeExp* testPointer = (SgAsteriskShapeExp*)(SgAsteriskShapeExp::pools.back());
  196138           0 :       unsigned long localIndex = SgAsteriskShapeExp::pool_size - 1;
  196139           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  196140             :          {
  196141           0 :            localIndex--;
  196142             :          }
  196143           0 :       return (localIndex + SgAsteriskShapeExp::pool_size * (SgAsteriskShapeExp::pools.size()-1));
  196144             :    }
  196145             : 
  196146             : //############################################################################
  196147             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  196148             :  * memory pool and initializes the data member in class SgAsteriskShapeExpStroageClass
  196149             :  * from its counterpart of SgAsteriskShapeExp. The return value is just for checking, 
  196150             :  * that the whole StorageClassArray is initialized!
  196151             :  */
  196152             : unsigned long
  196153           1 : SgAsteriskShapeExp::initializeStorageClassArray( SgAsteriskShapeExpStorageClass *storageArray )
  196154             :    {
  196155           1 :      unsigned long storageCounter = 0;
  196156           1 :      std::vector < unsigned char* > :: const_iterator block = SgAsteriskShapeExp::pools.begin();
  196157           1 :      SgAsteriskShapeExp* pointer = NULL;
  196158           2 :      while ( block != SgAsteriskShapeExp::pools.end() ) {
  196159           1 :           pointer = (SgAsteriskShapeExp*) (*block);
  196160        2001 :           for ( unsigned i = 0; i < SgAsteriskShapeExp::pool_size; ++i ) {
  196161        2000 :                if ( pointer->get_freepointer() != NULL ) {
  196162           1 :                  storageArray->pickOutIRNodeData (pointer) ;
  196163           1 :                  storageArray++;
  196164           1 :                  storageCounter++;
  196165             :                }
  196166        2000 :                pointer++;
  196167             :              }
  196168           1 :            block++;
  196169             :         }
  196170           1 :      return storageCounter;
  196171             :    }
  196172             : 
  196173             : /* #line 196174 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  196174             : 
  196175             : 
  196176             : 
  196177             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  196178             : 
  196179             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  196180             : 
  196181             : //############################################################################
  196182             : /* JH (02/02/2006) Constructor of the IR node SgImpliedDo that takes its 
  196183             :  * corresponding StorageClass as parameter
  196184             :  */
  196185           0 : SgImpliedDo :: SgImpliedDo ( const SgImpliedDoStorageClass& storageSource )   : SgExpression (storageSource)
  196186             :    {
  196187             : 
  196188             : 
  196189             : /* #line 196190 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  196190             : 
  196191           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  196192           0 :      p_do_var_initialization =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_do_var_initialization) );
  196193           0 :      p_last_val =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_last_val) );
  196194           0 :      p_increment =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_increment) );
  196195           0 :      p_object_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_object_list) );
  196196           0 :      p_implied_do_scope =  (SgScopeStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_implied_do_scope) );
  196197             : 
  196198             : 
  196199             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  196200             : 
  196201             : 
  196202           0 :    }
  196203             : 
  196204             : //############################################################################
  196205             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  196206             :  * within the working AST. 
  196207             :  */
  196208           0 : SgImpliedDo * SgImpliedDo::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  196209           0 :      SgImpliedDo* returnPointer = NULL;
  196210           0 :      if ( globalIndex != 0 )
  196211             :         {
  196212             : 
  196213             : #if FILE_IO_EXTRA_CHECK
  196214           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgImpliedDo ) ) <= globalIndex ) ;
  196215           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImpliedDo + 1 ) ) );
  196216             : #endif
  196217           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgImpliedDo )  
  196218           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgImpliedDo );
  196219           0 :           unsigned long positionInPool = localIndex % SgImpliedDo::pool_size;
  196220           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImpliedDo::pool_size;
  196221             : 
  196222             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  196223             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  196224             : 
  196225           0 :           returnPointer = &( ( (SgImpliedDo*)(SgImpliedDo::pools[memoryBlock]) ) [positionInPool]) ;
  196226             : 
  196227           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  196228             :         }
  196229           0 :      return returnPointer ;
  196230             :    }
  196231             : 
  196232             : //############################################################################
  196233             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  196234             :   for the AST with the index astIndex
  196235             : */
  196236           0 : SgImpliedDo * SgImpliedDo::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  196237           0 :      SgImpliedDo* returnPointer = NULL;
  196238           0 :      if ( globalIndex != 0 )
  196239             :         {
  196240             : 
  196241             : #if FILE_IO_EXTRA_CHECK
  196242           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgImpliedDo ) ) <= globalIndex ) ;
  196243           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImpliedDo + 1 ) ) );
  196244             : #endif
  196245           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgImpliedDo )
  196246           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgImpliedDo );
  196247           0 :           unsigned long positionInPool = localIndex % SgImpliedDo::pool_size ;
  196248           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgImpliedDo::pool_size ;
  196249             : 
  196250             : #if FILE_IO_EXTRA_CHECK
  196251             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  196252             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  196253             : #endif
  196254             : 
  196255           0 :           returnPointer = &( ( (SgImpliedDo*)(SgImpliedDo::pools[memoryBlock]) ) [positionInPool]) ;
  196256             : 
  196257             : #if FILE_IO_EXTRA_CHECK
  196258           0 :           assert ( returnPointer != NULL ) ;
  196259             : #endif
  196260             :         }
  196261           0 :      return returnPointer ;
  196262             :    }
  196263             : 
  196264             : //############################################################################
  196265             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  196266             :  * pool size! We set for every valid object in the memory pool the freepointer
  196267             :  * to the global index and increase the global index afterwards. For all the 
  196268             :  * invalid objects (means address ranges within the memory pool that were not
  196269             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  196270             :  * distinguish valid from invalid objects! 
  196271             :  */
  196272             : unsigned long
  196273           5 : SgImpliedDo::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  196274             :    {
  196275           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  196276           5 :      SgImpliedDo* pointer = NULL;
  196277           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  196278           5 :      std::vector < unsigned char* > :: const_iterator block;
  196279           5 :      for ( block = SgImpliedDo::pools.begin(); block != SgImpliedDo::pools.end() ; ++block )
  196280             :         {
  196281           0 :           pointer = (SgImpliedDo*)(*block);
  196282           0 :           for (unsigned i = 0; i < SgImpliedDo::pool_size; ++i )
  196283             :              {
  196284             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  196285             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  196286             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  196287             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  196288             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  196289             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  196290             :             // properly; so this will have to be checked next.
  196291             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  196292             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  196293           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  196294             :                   {
  196295           0 :                     pointer[i].set_freepointer((SgImpliedDo*)(globalIndex));
  196296           0 :                     globalIndex++;
  196297             :                   }
  196298             :                else
  196299             :                   {
  196300           0 :                     pointer[i].set_freepointer(NULL);
  196301             :                   }
  196302             :               }
  196303             :         }
  196304           5 :      return globalIndex;
  196305             :    }
  196306             : 
  196307             : //############################################################################
  196308             : // JH (01/14/2006)
  196309             : void
  196310           5 : SgImpliedDo::resetValidFreepointers( )
  196311             :    {
  196312           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  196313           5 :      SgImpliedDo* pointer = NULL;
  196314           5 :      std::vector < unsigned char* > :: const_iterator block;
  196315           5 :      SgImpliedDo* pointerOfLinkedList = NULL;
  196316           5 :      for ( block = SgImpliedDo::pools.begin(); block != SgImpliedDo::pools.end() ; ++block )
  196317             :         {
  196318           0 :           pointer = (SgImpliedDo*)(*block);
  196319           0 :           for (unsigned i = 0; i < SgImpliedDo::pool_size; ++i )
  196320             :              {
  196321             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  196322             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  196323             :             // memory blocks!.
  196324           0 :                if ( pointer[i].get_freepointer() != NULL )
  196325             :                   {
  196326           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  196327             :                   }
  196328             :                else
  196329             :                   {
  196330           0 :                     if ( pointerOfLinkedList == NULL )
  196331             :                        {
  196332           0 :                          SgImpliedDo::next_node = &(pointer[i]);
  196333             :                        }
  196334             :                     else
  196335             :                        {
  196336             :                       // printf ("In SgImpliedDo::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  196337           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  196338             :                        }
  196339             :                     pointerOfLinkedList = &(pointer[i]);
  196340             :                   }
  196341             :               }
  196342             :         }
  196343             : 
  196344           5 :      if ( pointerOfLinkedList != NULL )
  196345             :         {
  196346             :        // printf ("In SgImpliedDo::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  196347           0 :           pointerOfLinkedList->set_freepointer(NULL);
  196348             :        // DQ (6/6/2010): Temporary debugging...
  196349             :        //   ROSE_ASSERT(false);
  196350             :         }
  196351             : 
  196352           5 :      return ;
  196353             :    }
  196354             : 
  196355             : //############################################################################
  196356             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  196357             :  * within the memory pool and resets the freepointers, in order to achieve a 
  196358             :  * linked list, that has no jumps and starts at the beginning! This function 
  196359             :  * does not extend the memory pool, since we do not delete any memory blocks,
  196360             :  * but delete the valid objects.  
  196361             :  */
  196362             : void
  196363           0 : SgImpliedDo::clearMemoryPool( )
  196364             :    {
  196365             :   // printf ("Inside of SgImpliedDo::clearMemoryPool() \n");
  196366             : 
  196367           0 :      SgImpliedDo* pointer = NULL, *tempPointer = NULL;
  196368           0 :      std::vector < unsigned char* > :: const_iterator block;
  196369           0 :      if ( SgImpliedDo::pools.empty() == false )
  196370             :         {
  196371           0 :           block = SgImpliedDo::pools.begin() ;
  196372           0 :           SgImpliedDo::next_node = (SgImpliedDo*) (*block);
  196373             : 
  196374           0 :           while ( block != SgImpliedDo::pools.end() )
  196375             :              {
  196376           0 :                pointer = (SgImpliedDo*) (*block);
  196377           0 :                if ( tempPointer != NULL )
  196378             :                   {
  196379           0 :                     tempPointer->set_freepointer(pointer);
  196380             :                   }
  196381           0 :                for (unsigned i = 0; i < SgImpliedDo::pool_size - 1; ++i)
  196382             :                   {
  196383           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  196384             :                   }
  196385           0 :                 pointer[SgImpliedDo::pool_size-1].set_freepointer(NULL);
  196386           0 :                 tempPointer = &(pointer[SgImpliedDo::pool_size-1]);
  196387           0 :                 ++block;
  196388             :              }
  196389             :         }
  196390           0 :    }
  196391             : 
  196392           5 : void SgImpliedDo::deleteMemoryPool() {
  196393           5 :   for (auto p: SgImpliedDo::pools) {
  196394           0 :     ROSE_FREE(p);
  196395             :   }
  196396           5 :   SgImpliedDo::next_node = nullptr;
  196397           5 :   SgImpliedDo::pools.clear();
  196398           5 : }
  196399             : 
  196400             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  196401             : //                 reading multiple binary files to for a single AST.
  196402             : /////////// new version ////////////////////////////////
  196403             : //############################################################################
  196404             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  196405             : void
  196406           2 : SgImpliedDo::extendMemoryPoolForFileIO( )
  196407             :   {
  196408           2 :     size_t blockIndex = SgImpliedDo::pools.size();
  196409           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgImpliedDo) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgImpliedDo);
  196410             : 
  196411           2 :     while ( (blockIndex * SgImpliedDo::pool_size) < newPoolSize)
  196412             :       {
  196413             : #if ROSE_ALLOC_TRACE
  196414             :         if (blockIndex > 0) {
  196415             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgImpliedDo) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgImpliedDo) = %" PRIuPTR " SgImpliedDo::pool_size = %d \n",
  196416             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgImpliedDo),AST_FILE_IO::getPoolSizeOfNewAst(V_SgImpliedDo),SgImpliedDo::pool_size);
  196417             :         }
  196418             : #endif
  196419             : 
  196420           0 :         SgImpliedDo * pointer = (SgImpliedDo*) ROSE_MALLOC ( SgImpliedDo::pool_size * sizeof(SgImpliedDo) );
  196421           0 :         assert( pointer != NULL );
  196422             : #if ROSE_ALLOC_MEMSET == 1
  196423             :         memset(pointer, 0x00, SgImpliedDo::pool_size * sizeof(SgImpliedDo));
  196424             : #elif ROSE_ALLOC_MEMSET == 2
  196425             :         memset(pointer, 0xCC, SgImpliedDo::pool_size * sizeof(SgImpliedDo));
  196426             : #endif
  196427           0 :         SgImpliedDo::pools.push_back( (unsigned char*)(pointer) );
  196428           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgImpliedDo::pool_size * sizeof(SgImpliedDo), V_SgImpliedDo ) );
  196429             : 
  196430           0 :         if ( SgImpliedDo::next_node != NULL ) {
  196431           0 :           if ( blockIndex > 0 ) {
  196432           0 :             SgImpliedDo * blkptr = (SgImpliedDo*)(SgImpliedDo::pools[blockIndex-1]);
  196433           0 :             blkptr[ SgImpliedDo::pool_size - 1 ].set_freepointer(pointer);
  196434             :           }
  196435             :         } else {
  196436           0 :           SgImpliedDo::next_node = pointer;
  196437             :         }
  196438             : 
  196439           0 :         for (unsigned i = 0; i < SgImpliedDo::pool_size-1; ++i)
  196440             :            {
  196441           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  196442             :            }
  196443           0 :         pointer[ SgImpliedDo::pool_size -1 ].set_freepointer(NULL);
  196444             : 
  196445           0 :         blockIndex++;
  196446             :       }
  196447           2 :   }
  196448             : 
  196449             : //############################################################################
  196450             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  196451             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  196452             :  * not compressed. However, that stuff is not yet implemented! 
  196453             :  */
  196454             : unsigned long
  196455           0 : SgImpliedDo::getNumberOfLastValidPointer()
  196456             :    {
  196457           0 :       SgImpliedDo* testPointer = (SgImpliedDo*)(SgImpliedDo::pools.back());
  196458           0 :       unsigned long localIndex = SgImpliedDo::pool_size - 1;
  196459           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  196460             :          {
  196461           0 :            localIndex--;
  196462             :          }
  196463           0 :       return (localIndex + SgImpliedDo::pool_size * (SgImpliedDo::pools.size()-1));
  196464             :    }
  196465             : 
  196466             : //############################################################################
  196467             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  196468             :  * memory pool and initializes the data member in class SgImpliedDoStroageClass
  196469             :  * from its counterpart of SgImpliedDo. The return value is just for checking, 
  196470             :  * that the whole StorageClassArray is initialized!
  196471             :  */
  196472             : unsigned long
  196473           0 : SgImpliedDo::initializeStorageClassArray( SgImpliedDoStorageClass *storageArray )
  196474             :    {
  196475           0 :      unsigned long storageCounter = 0;
  196476           0 :      std::vector < unsigned char* > :: const_iterator block = SgImpliedDo::pools.begin();
  196477           0 :      SgImpliedDo* pointer = NULL;
  196478           0 :      while ( block != SgImpliedDo::pools.end() ) {
  196479           0 :           pointer = (SgImpliedDo*) (*block);
  196480           0 :           for ( unsigned i = 0; i < SgImpliedDo::pool_size; ++i ) {
  196481           0 :                if ( pointer->get_freepointer() != NULL ) {
  196482           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  196483           0 :                  storageArray++;
  196484           0 :                  storageCounter++;
  196485             :                }
  196486           0 :                pointer++;
  196487             :              }
  196488           0 :            block++;
  196489             :         }
  196490           0 :      return storageCounter;
  196491             :    }
  196492             : 
  196493             : /* #line 196494 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  196494             : 
  196495             : 
  196496             : 
  196497             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  196498             : 
  196499             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  196500             : 
  196501             : //############################################################################
  196502             : /* JH (02/02/2006) Constructor of the IR node SgIOItemExpression that takes its 
  196503             :  * corresponding StorageClass as parameter
  196504             :  */
  196505           0 : SgIOItemExpression :: SgIOItemExpression ( const SgIOItemExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  196506             :    {
  196507             : 
  196508             : 
  196509             : /* #line 196510 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  196510             : 
  196511           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  196512           0 :      p_name = SgName ( storageSource.storageOf_name ) ;
  196513           0 :      p_io_item =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_io_item) );
  196514             : 
  196515             : 
  196516             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  196517             : 
  196518             : 
  196519           0 :    }
  196520             : 
  196521             : //############################################################################
  196522             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  196523             :  * within the working AST. 
  196524             :  */
  196525           0 : SgIOItemExpression * SgIOItemExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  196526           0 :      SgIOItemExpression* returnPointer = NULL;
  196527           0 :      if ( globalIndex != 0 )
  196528             :         {
  196529             : 
  196530             : #if FILE_IO_EXTRA_CHECK
  196531           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIOItemExpression ) ) <= globalIndex ) ;
  196532           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIOItemExpression + 1 ) ) );
  196533             : #endif
  196534           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIOItemExpression )  
  196535           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIOItemExpression );
  196536           0 :           unsigned long positionInPool = localIndex % SgIOItemExpression::pool_size;
  196537           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIOItemExpression::pool_size;
  196538             : 
  196539             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  196540             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  196541             : 
  196542           0 :           returnPointer = &( ( (SgIOItemExpression*)(SgIOItemExpression::pools[memoryBlock]) ) [positionInPool]) ;
  196543             : 
  196544           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  196545             :         }
  196546           0 :      return returnPointer ;
  196547             :    }
  196548             : 
  196549             : //############################################################################
  196550             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  196551             :   for the AST with the index astIndex
  196552             : */
  196553           0 : SgIOItemExpression * SgIOItemExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  196554           0 :      SgIOItemExpression* returnPointer = NULL;
  196555           0 :      if ( globalIndex != 0 )
  196556             :         {
  196557             : 
  196558             : #if FILE_IO_EXTRA_CHECK
  196559           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIOItemExpression ) ) <= globalIndex ) ;
  196560           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIOItemExpression + 1 ) ) );
  196561             : #endif
  196562           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIOItemExpression )
  196563           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIOItemExpression );
  196564           0 :           unsigned long positionInPool = localIndex % SgIOItemExpression::pool_size ;
  196565           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIOItemExpression::pool_size ;
  196566             : 
  196567             : #if FILE_IO_EXTRA_CHECK
  196568             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  196569             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  196570             : #endif
  196571             : 
  196572           0 :           returnPointer = &( ( (SgIOItemExpression*)(SgIOItemExpression::pools[memoryBlock]) ) [positionInPool]) ;
  196573             : 
  196574             : #if FILE_IO_EXTRA_CHECK
  196575           0 :           assert ( returnPointer != NULL ) ;
  196576             : #endif
  196577             :         }
  196578           0 :      return returnPointer ;
  196579             :    }
  196580             : 
  196581             : //############################################################################
  196582             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  196583             :  * pool size! We set for every valid object in the memory pool the freepointer
  196584             :  * to the global index and increase the global index afterwards. For all the 
  196585             :  * invalid objects (means address ranges within the memory pool that were not
  196586             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  196587             :  * distinguish valid from invalid objects! 
  196588             :  */
  196589             : unsigned long
  196590           5 : SgIOItemExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  196591             :    {
  196592           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  196593           5 :      SgIOItemExpression* pointer = NULL;
  196594           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  196595           5 :      std::vector < unsigned char* > :: const_iterator block;
  196596           5 :      for ( block = SgIOItemExpression::pools.begin(); block != SgIOItemExpression::pools.end() ; ++block )
  196597             :         {
  196598           0 :           pointer = (SgIOItemExpression*)(*block);
  196599           0 :           for (unsigned i = 0; i < SgIOItemExpression::pool_size; ++i )
  196600             :              {
  196601             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  196602             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  196603             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  196604             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  196605             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  196606             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  196607             :             // properly; so this will have to be checked next.
  196608             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  196609             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  196610           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  196611             :                   {
  196612           0 :                     pointer[i].set_freepointer((SgIOItemExpression*)(globalIndex));
  196613           0 :                     globalIndex++;
  196614             :                   }
  196615             :                else
  196616             :                   {
  196617           0 :                     pointer[i].set_freepointer(NULL);
  196618             :                   }
  196619             :               }
  196620             :         }
  196621           5 :      return globalIndex;
  196622             :    }
  196623             : 
  196624             : //############################################################################
  196625             : // JH (01/14/2006)
  196626             : void
  196627           5 : SgIOItemExpression::resetValidFreepointers( )
  196628             :    {
  196629           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  196630           5 :      SgIOItemExpression* pointer = NULL;
  196631           5 :      std::vector < unsigned char* > :: const_iterator block;
  196632           5 :      SgIOItemExpression* pointerOfLinkedList = NULL;
  196633           5 :      for ( block = SgIOItemExpression::pools.begin(); block != SgIOItemExpression::pools.end() ; ++block )
  196634             :         {
  196635           0 :           pointer = (SgIOItemExpression*)(*block);
  196636           0 :           for (unsigned i = 0; i < SgIOItemExpression::pool_size; ++i )
  196637             :              {
  196638             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  196639             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  196640             :             // memory blocks!.
  196641           0 :                if ( pointer[i].get_freepointer() != NULL )
  196642             :                   {
  196643           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  196644             :                   }
  196645             :                else
  196646             :                   {
  196647           0 :                     if ( pointerOfLinkedList == NULL )
  196648             :                        {
  196649           0 :                          SgIOItemExpression::next_node = &(pointer[i]);
  196650             :                        }
  196651             :                     else
  196652             :                        {
  196653             :                       // printf ("In SgIOItemExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  196654           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  196655             :                        }
  196656             :                     pointerOfLinkedList = &(pointer[i]);
  196657             :                   }
  196658             :               }
  196659             :         }
  196660             : 
  196661           5 :      if ( pointerOfLinkedList != NULL )
  196662             :         {
  196663             :        // printf ("In SgIOItemExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  196664           0 :           pointerOfLinkedList->set_freepointer(NULL);
  196665             :        // DQ (6/6/2010): Temporary debugging...
  196666             :        //   ROSE_ASSERT(false);
  196667             :         }
  196668             : 
  196669           5 :      return ;
  196670             :    }
  196671             : 
  196672             : //############################################################################
  196673             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  196674             :  * within the memory pool and resets the freepointers, in order to achieve a 
  196675             :  * linked list, that has no jumps and starts at the beginning! This function 
  196676             :  * does not extend the memory pool, since we do not delete any memory blocks,
  196677             :  * but delete the valid objects.  
  196678             :  */
  196679             : void
  196680           0 : SgIOItemExpression::clearMemoryPool( )
  196681             :    {
  196682             :   // printf ("Inside of SgIOItemExpression::clearMemoryPool() \n");
  196683             : 
  196684           0 :      SgIOItemExpression* pointer = NULL, *tempPointer = NULL;
  196685           0 :      std::vector < unsigned char* > :: const_iterator block;
  196686           0 :      if ( SgIOItemExpression::pools.empty() == false )
  196687             :         {
  196688           0 :           block = SgIOItemExpression::pools.begin() ;
  196689           0 :           SgIOItemExpression::next_node = (SgIOItemExpression*) (*block);
  196690             : 
  196691           0 :           while ( block != SgIOItemExpression::pools.end() )
  196692             :              {
  196693           0 :                pointer = (SgIOItemExpression*) (*block);
  196694           0 :                if ( tempPointer != NULL )
  196695             :                   {
  196696           0 :                     tempPointer->set_freepointer(pointer);
  196697             :                   }
  196698           0 :                for (unsigned i = 0; i < SgIOItemExpression::pool_size - 1; ++i)
  196699             :                   {
  196700           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  196701             :                   }
  196702           0 :                 pointer[SgIOItemExpression::pool_size-1].set_freepointer(NULL);
  196703           0 :                 tempPointer = &(pointer[SgIOItemExpression::pool_size-1]);
  196704           0 :                 ++block;
  196705             :              }
  196706             :         }
  196707           0 :    }
  196708             : 
  196709           5 : void SgIOItemExpression::deleteMemoryPool() {
  196710           5 :   for (auto p: SgIOItemExpression::pools) {
  196711           0 :     ROSE_FREE(p);
  196712             :   }
  196713           5 :   SgIOItemExpression::next_node = nullptr;
  196714           5 :   SgIOItemExpression::pools.clear();
  196715           5 : }
  196716             : 
  196717             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  196718             : //                 reading multiple binary files to for a single AST.
  196719             : /////////// new version ////////////////////////////////
  196720             : //############################################################################
  196721             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  196722             : void
  196723           2 : SgIOItemExpression::extendMemoryPoolForFileIO( )
  196724             :   {
  196725           2 :     size_t blockIndex = SgIOItemExpression::pools.size();
  196726           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIOItemExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIOItemExpression);
  196727             : 
  196728           2 :     while ( (blockIndex * SgIOItemExpression::pool_size) < newPoolSize)
  196729             :       {
  196730             : #if ROSE_ALLOC_TRACE
  196731             :         if (blockIndex > 0) {
  196732             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIOItemExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIOItemExpression) = %" PRIuPTR " SgIOItemExpression::pool_size = %d \n",
  196733             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIOItemExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIOItemExpression),SgIOItemExpression::pool_size);
  196734             :         }
  196735             : #endif
  196736             : 
  196737           0 :         SgIOItemExpression * pointer = (SgIOItemExpression*) ROSE_MALLOC ( SgIOItemExpression::pool_size * sizeof(SgIOItemExpression) );
  196738           0 :         assert( pointer != NULL );
  196739             : #if ROSE_ALLOC_MEMSET == 1
  196740             :         memset(pointer, 0x00, SgIOItemExpression::pool_size * sizeof(SgIOItemExpression));
  196741             : #elif ROSE_ALLOC_MEMSET == 2
  196742             :         memset(pointer, 0xCC, SgIOItemExpression::pool_size * sizeof(SgIOItemExpression));
  196743             : #endif
  196744           0 :         SgIOItemExpression::pools.push_back( (unsigned char*)(pointer) );
  196745           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIOItemExpression::pool_size * sizeof(SgIOItemExpression), V_SgIOItemExpression ) );
  196746             : 
  196747           0 :         if ( SgIOItemExpression::next_node != NULL ) {
  196748           0 :           if ( blockIndex > 0 ) {
  196749           0 :             SgIOItemExpression * blkptr = (SgIOItemExpression*)(SgIOItemExpression::pools[blockIndex-1]);
  196750           0 :             blkptr[ SgIOItemExpression::pool_size - 1 ].set_freepointer(pointer);
  196751             :           }
  196752             :         } else {
  196753           0 :           SgIOItemExpression::next_node = pointer;
  196754             :         }
  196755             : 
  196756           0 :         for (unsigned i = 0; i < SgIOItemExpression::pool_size-1; ++i)
  196757             :            {
  196758           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  196759             :            }
  196760           0 :         pointer[ SgIOItemExpression::pool_size -1 ].set_freepointer(NULL);
  196761             : 
  196762           0 :         blockIndex++;
  196763             :       }
  196764           2 :   }
  196765             : 
  196766             : //############################################################################
  196767             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  196768             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  196769             :  * not compressed. However, that stuff is not yet implemented! 
  196770             :  */
  196771             : unsigned long
  196772           0 : SgIOItemExpression::getNumberOfLastValidPointer()
  196773             :    {
  196774           0 :       SgIOItemExpression* testPointer = (SgIOItemExpression*)(SgIOItemExpression::pools.back());
  196775           0 :       unsigned long localIndex = SgIOItemExpression::pool_size - 1;
  196776           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  196777             :          {
  196778           0 :            localIndex--;
  196779             :          }
  196780           0 :       return (localIndex + SgIOItemExpression::pool_size * (SgIOItemExpression::pools.size()-1));
  196781             :    }
  196782             : 
  196783             : //############################################################################
  196784             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  196785             :  * memory pool and initializes the data member in class SgIOItemExpressionStroageClass
  196786             :  * from its counterpart of SgIOItemExpression. The return value is just for checking, 
  196787             :  * that the whole StorageClassArray is initialized!
  196788             :  */
  196789             : unsigned long
  196790           0 : SgIOItemExpression::initializeStorageClassArray( SgIOItemExpressionStorageClass *storageArray )
  196791             :    {
  196792           0 :      unsigned long storageCounter = 0;
  196793           0 :      std::vector < unsigned char* > :: const_iterator block = SgIOItemExpression::pools.begin();
  196794           0 :      SgIOItemExpression* pointer = NULL;
  196795           0 :      while ( block != SgIOItemExpression::pools.end() ) {
  196796           0 :           pointer = (SgIOItemExpression*) (*block);
  196797           0 :           for ( unsigned i = 0; i < SgIOItemExpression::pool_size; ++i ) {
  196798           0 :                if ( pointer->get_freepointer() != NULL ) {
  196799           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  196800           0 :                  storageArray++;
  196801           0 :                  storageCounter++;
  196802             :                }
  196803           0 :                pointer++;
  196804             :              }
  196805           0 :            block++;
  196806             :         }
  196807           0 :      return storageCounter;
  196808             :    }
  196809             : 
  196810             : /* #line 196811 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  196811             : 
  196812             : 
  196813             : 
  196814             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  196815             : 
  196816             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  196817             : 
  196818             : //############################################################################
  196819             : /* JH (02/02/2006) Constructor of the IR node SgStatementExpression that takes its 
  196820             :  * corresponding StorageClass as parameter
  196821             :  */
  196822           0 : SgStatementExpression :: SgStatementExpression ( const SgStatementExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  196823             :    {
  196824             : 
  196825             : 
  196826             : /* #line 196827 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  196827             : 
  196828           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  196829           0 :      p_statement =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_statement) );
  196830             : 
  196831             : 
  196832             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  196833             : 
  196834             : 
  196835           0 :    }
  196836             : 
  196837             : //############################################################################
  196838             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  196839             :  * within the working AST. 
  196840             :  */
  196841           0 : SgStatementExpression * SgStatementExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  196842           0 :      SgStatementExpression* returnPointer = NULL;
  196843           0 :      if ( globalIndex != 0 )
  196844             :         {
  196845             : 
  196846             : #if FILE_IO_EXTRA_CHECK
  196847           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStatementExpression ) ) <= globalIndex ) ;
  196848           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStatementExpression + 1 ) ) );
  196849             : #endif
  196850           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStatementExpression )  
  196851           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStatementExpression );
  196852           0 :           unsigned long positionInPool = localIndex % SgStatementExpression::pool_size;
  196853           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStatementExpression::pool_size;
  196854             : 
  196855             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  196856             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  196857             : 
  196858           0 :           returnPointer = &( ( (SgStatementExpression*)(SgStatementExpression::pools[memoryBlock]) ) [positionInPool]) ;
  196859             : 
  196860           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  196861             :         }
  196862           0 :      return returnPointer ;
  196863             :    }
  196864             : 
  196865             : //############################################################################
  196866             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  196867             :   for the AST with the index astIndex
  196868             : */
  196869           0 : SgStatementExpression * SgStatementExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  196870           0 :      SgStatementExpression* returnPointer = NULL;
  196871           0 :      if ( globalIndex != 0 )
  196872             :         {
  196873             : 
  196874             : #if FILE_IO_EXTRA_CHECK
  196875           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStatementExpression ) ) <= globalIndex ) ;
  196876           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStatementExpression + 1 ) ) );
  196877             : #endif
  196878           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStatementExpression )
  196879           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStatementExpression );
  196880           0 :           unsigned long positionInPool = localIndex % SgStatementExpression::pool_size ;
  196881           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStatementExpression::pool_size ;
  196882             : 
  196883             : #if FILE_IO_EXTRA_CHECK
  196884             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  196885             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  196886             : #endif
  196887             : 
  196888           0 :           returnPointer = &( ( (SgStatementExpression*)(SgStatementExpression::pools[memoryBlock]) ) [positionInPool]) ;
  196889             : 
  196890             : #if FILE_IO_EXTRA_CHECK
  196891           0 :           assert ( returnPointer != NULL ) ;
  196892             : #endif
  196893             :         }
  196894           0 :      return returnPointer ;
  196895             :    }
  196896             : 
  196897             : //############################################################################
  196898             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  196899             :  * pool size! We set for every valid object in the memory pool the freepointer
  196900             :  * to the global index and increase the global index afterwards. For all the 
  196901             :  * invalid objects (means address ranges within the memory pool that were not
  196902             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  196903             :  * distinguish valid from invalid objects! 
  196904             :  */
  196905             : unsigned long
  196906           5 : SgStatementExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  196907             :    {
  196908           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  196909           5 :      SgStatementExpression* pointer = NULL;
  196910           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  196911           5 :      std::vector < unsigned char* > :: const_iterator block;
  196912           5 :      for ( block = SgStatementExpression::pools.begin(); block != SgStatementExpression::pools.end() ; ++block )
  196913             :         {
  196914           0 :           pointer = (SgStatementExpression*)(*block);
  196915           0 :           for (unsigned i = 0; i < SgStatementExpression::pool_size; ++i )
  196916             :              {
  196917             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  196918             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  196919             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  196920             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  196921             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  196922             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  196923             :             // properly; so this will have to be checked next.
  196924             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  196925             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  196926           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  196927             :                   {
  196928           0 :                     pointer[i].set_freepointer((SgStatementExpression*)(globalIndex));
  196929           0 :                     globalIndex++;
  196930             :                   }
  196931             :                else
  196932             :                   {
  196933           0 :                     pointer[i].set_freepointer(NULL);
  196934             :                   }
  196935             :               }
  196936             :         }
  196937           5 :      return globalIndex;
  196938             :    }
  196939             : 
  196940             : //############################################################################
  196941             : // JH (01/14/2006)
  196942             : void
  196943           5 : SgStatementExpression::resetValidFreepointers( )
  196944             :    {
  196945           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  196946           5 :      SgStatementExpression* pointer = NULL;
  196947           5 :      std::vector < unsigned char* > :: const_iterator block;
  196948           5 :      SgStatementExpression* pointerOfLinkedList = NULL;
  196949           5 :      for ( block = SgStatementExpression::pools.begin(); block != SgStatementExpression::pools.end() ; ++block )
  196950             :         {
  196951           0 :           pointer = (SgStatementExpression*)(*block);
  196952           0 :           for (unsigned i = 0; i < SgStatementExpression::pool_size; ++i )
  196953             :              {
  196954             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  196955             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  196956             :             // memory blocks!.
  196957           0 :                if ( pointer[i].get_freepointer() != NULL )
  196958             :                   {
  196959           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  196960             :                   }
  196961             :                else
  196962             :                   {
  196963           0 :                     if ( pointerOfLinkedList == NULL )
  196964             :                        {
  196965           0 :                          SgStatementExpression::next_node = &(pointer[i]);
  196966             :                        }
  196967             :                     else
  196968             :                        {
  196969             :                       // printf ("In SgStatementExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  196970           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  196971             :                        }
  196972             :                     pointerOfLinkedList = &(pointer[i]);
  196973             :                   }
  196974             :               }
  196975             :         }
  196976             : 
  196977           5 :      if ( pointerOfLinkedList != NULL )
  196978             :         {
  196979             :        // printf ("In SgStatementExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  196980           0 :           pointerOfLinkedList->set_freepointer(NULL);
  196981             :        // DQ (6/6/2010): Temporary debugging...
  196982             :        //   ROSE_ASSERT(false);
  196983             :         }
  196984             : 
  196985           5 :      return ;
  196986             :    }
  196987             : 
  196988             : //############################################################################
  196989             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  196990             :  * within the memory pool and resets the freepointers, in order to achieve a 
  196991             :  * linked list, that has no jumps and starts at the beginning! This function 
  196992             :  * does not extend the memory pool, since we do not delete any memory blocks,
  196993             :  * but delete the valid objects.  
  196994             :  */
  196995             : void
  196996           0 : SgStatementExpression::clearMemoryPool( )
  196997             :    {
  196998             :   // printf ("Inside of SgStatementExpression::clearMemoryPool() \n");
  196999             : 
  197000           0 :      SgStatementExpression* pointer = NULL, *tempPointer = NULL;
  197001           0 :      std::vector < unsigned char* > :: const_iterator block;
  197002           0 :      if ( SgStatementExpression::pools.empty() == false )
  197003             :         {
  197004           0 :           block = SgStatementExpression::pools.begin() ;
  197005           0 :           SgStatementExpression::next_node = (SgStatementExpression*) (*block);
  197006             : 
  197007           0 :           while ( block != SgStatementExpression::pools.end() )
  197008             :              {
  197009           0 :                pointer = (SgStatementExpression*) (*block);
  197010           0 :                if ( tempPointer != NULL )
  197011             :                   {
  197012           0 :                     tempPointer->set_freepointer(pointer);
  197013             :                   }
  197014           0 :                for (unsigned i = 0; i < SgStatementExpression::pool_size - 1; ++i)
  197015             :                   {
  197016           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  197017             :                   }
  197018           0 :                 pointer[SgStatementExpression::pool_size-1].set_freepointer(NULL);
  197019           0 :                 tempPointer = &(pointer[SgStatementExpression::pool_size-1]);
  197020           0 :                 ++block;
  197021             :              }
  197022             :         }
  197023           0 :    }
  197024             : 
  197025           5 : void SgStatementExpression::deleteMemoryPool() {
  197026           5 :   for (auto p: SgStatementExpression::pools) {
  197027           0 :     ROSE_FREE(p);
  197028             :   }
  197029           5 :   SgStatementExpression::next_node = nullptr;
  197030           5 :   SgStatementExpression::pools.clear();
  197031           5 : }
  197032             : 
  197033             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  197034             : //                 reading multiple binary files to for a single AST.
  197035             : /////////// new version ////////////////////////////////
  197036             : //############################################################################
  197037             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  197038             : void
  197039           2 : SgStatementExpression::extendMemoryPoolForFileIO( )
  197040             :   {
  197041           2 :     size_t blockIndex = SgStatementExpression::pools.size();
  197042           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStatementExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatementExpression);
  197043             : 
  197044           2 :     while ( (blockIndex * SgStatementExpression::pool_size) < newPoolSize)
  197045             :       {
  197046             : #if ROSE_ALLOC_TRACE
  197047             :         if (blockIndex > 0) {
  197048             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStatementExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatementExpression) = %" PRIuPTR " SgStatementExpression::pool_size = %d \n",
  197049             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStatementExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStatementExpression),SgStatementExpression::pool_size);
  197050             :         }
  197051             : #endif
  197052             : 
  197053           0 :         SgStatementExpression * pointer = (SgStatementExpression*) ROSE_MALLOC ( SgStatementExpression::pool_size * sizeof(SgStatementExpression) );
  197054           0 :         assert( pointer != NULL );
  197055             : #if ROSE_ALLOC_MEMSET == 1
  197056             :         memset(pointer, 0x00, SgStatementExpression::pool_size * sizeof(SgStatementExpression));
  197057             : #elif ROSE_ALLOC_MEMSET == 2
  197058             :         memset(pointer, 0xCC, SgStatementExpression::pool_size * sizeof(SgStatementExpression));
  197059             : #endif
  197060           0 :         SgStatementExpression::pools.push_back( (unsigned char*)(pointer) );
  197061           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStatementExpression::pool_size * sizeof(SgStatementExpression), V_SgStatementExpression ) );
  197062             : 
  197063           0 :         if ( SgStatementExpression::next_node != NULL ) {
  197064           0 :           if ( blockIndex > 0 ) {
  197065           0 :             SgStatementExpression * blkptr = (SgStatementExpression*)(SgStatementExpression::pools[blockIndex-1]);
  197066           0 :             blkptr[ SgStatementExpression::pool_size - 1 ].set_freepointer(pointer);
  197067             :           }
  197068             :         } else {
  197069           0 :           SgStatementExpression::next_node = pointer;
  197070             :         }
  197071             : 
  197072           0 :         for (unsigned i = 0; i < SgStatementExpression::pool_size-1; ++i)
  197073             :            {
  197074           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  197075             :            }
  197076           0 :         pointer[ SgStatementExpression::pool_size -1 ].set_freepointer(NULL);
  197077             : 
  197078           0 :         blockIndex++;
  197079             :       }
  197080           2 :   }
  197081             : 
  197082             : //############################################################################
  197083             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  197084             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  197085             :  * not compressed. However, that stuff is not yet implemented! 
  197086             :  */
  197087             : unsigned long
  197088           0 : SgStatementExpression::getNumberOfLastValidPointer()
  197089             :    {
  197090           0 :       SgStatementExpression* testPointer = (SgStatementExpression*)(SgStatementExpression::pools.back());
  197091           0 :       unsigned long localIndex = SgStatementExpression::pool_size - 1;
  197092           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  197093             :          {
  197094           0 :            localIndex--;
  197095             :          }
  197096           0 :       return (localIndex + SgStatementExpression::pool_size * (SgStatementExpression::pools.size()-1));
  197097             :    }
  197098             : 
  197099             : //############################################################################
  197100             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  197101             :  * memory pool and initializes the data member in class SgStatementExpressionStroageClass
  197102             :  * from its counterpart of SgStatementExpression. The return value is just for checking, 
  197103             :  * that the whole StorageClassArray is initialized!
  197104             :  */
  197105             : unsigned long
  197106           0 : SgStatementExpression::initializeStorageClassArray( SgStatementExpressionStorageClass *storageArray )
  197107             :    {
  197108           0 :      unsigned long storageCounter = 0;
  197109           0 :      std::vector < unsigned char* > :: const_iterator block = SgStatementExpression::pools.begin();
  197110           0 :      SgStatementExpression* pointer = NULL;
  197111           0 :      while ( block != SgStatementExpression::pools.end() ) {
  197112           0 :           pointer = (SgStatementExpression*) (*block);
  197113           0 :           for ( unsigned i = 0; i < SgStatementExpression::pool_size; ++i ) {
  197114           0 :                if ( pointer->get_freepointer() != NULL ) {
  197115           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  197116           0 :                  storageArray++;
  197117           0 :                  storageCounter++;
  197118             :                }
  197119           0 :                pointer++;
  197120             :              }
  197121           0 :            block++;
  197122             :         }
  197123           0 :      return storageCounter;
  197124             :    }
  197125             : 
  197126             : /* #line 197127 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  197127             : 
  197128             : 
  197129             : 
  197130             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  197131             : 
  197132             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  197133             : 
  197134             : //############################################################################
  197135             : /* JH (02/02/2006) Constructor of the IR node SgAsmOp that takes its 
  197136             :  * corresponding StorageClass as parameter
  197137             :  */
  197138           0 : SgAsmOp :: SgAsmOp ( const SgAsmOpStorageClass& storageSource )   : SgExpression (storageSource)
  197139             :    {
  197140             : 
  197141             : 
  197142             : /* #line 197143 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  197143             : 
  197144           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  197145           0 :      p_constraint = storageSource.storageOf_constraint ;
  197146           0 :      p_modifiers = storageSource.storageOf_modifiers ;
  197147           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  197148           0 :      p_recordRawAsmOperandDescriptions = storageSource.storageOf_recordRawAsmOperandDescriptions ;
  197149           0 :      p_isOutputOperand = storageSource.storageOf_isOutputOperand ;
  197150           0 :      p_constraintString = storageSource.storageOf_constraintString.rebuildDataStoredInEasyStorageClass() ;
  197151           0 :      p_name = storageSource.storageOf_name.rebuildDataStoredInEasyStorageClass() ;
  197152             : 
  197153             : 
  197154             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  197155             : 
  197156             : 
  197157           0 :    }
  197158             : 
  197159             : //############################################################################
  197160             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  197161             :  * within the working AST. 
  197162             :  */
  197163           0 : SgAsmOp * SgAsmOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  197164           0 :      SgAsmOp* returnPointer = NULL;
  197165           0 :      if ( globalIndex != 0 )
  197166             :         {
  197167             : 
  197168             : #if FILE_IO_EXTRA_CHECK
  197169           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAsmOp ) ) <= globalIndex ) ;
  197170           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAsmOp + 1 ) ) );
  197171             : #endif
  197172           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAsmOp )  
  197173           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAsmOp );
  197174           0 :           unsigned long positionInPool = localIndex % SgAsmOp::pool_size;
  197175           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAsmOp::pool_size;
  197176             : 
  197177             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  197178             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  197179             : 
  197180           0 :           returnPointer = &( ( (SgAsmOp*)(SgAsmOp::pools[memoryBlock]) ) [positionInPool]) ;
  197181             : 
  197182           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  197183             :         }
  197184           0 :      return returnPointer ;
  197185             :    }
  197186             : 
  197187             : //############################################################################
  197188             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  197189             :   for the AST with the index astIndex
  197190             : */
  197191           0 : SgAsmOp * SgAsmOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  197192           0 :      SgAsmOp* returnPointer = NULL;
  197193           0 :      if ( globalIndex != 0 )
  197194             :         {
  197195             : 
  197196             : #if FILE_IO_EXTRA_CHECK
  197197           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAsmOp ) ) <= globalIndex ) ;
  197198           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAsmOp + 1 ) ) );
  197199             : #endif
  197200           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAsmOp )
  197201           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAsmOp );
  197202           0 :           unsigned long positionInPool = localIndex % SgAsmOp::pool_size ;
  197203           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAsmOp::pool_size ;
  197204             : 
  197205             : #if FILE_IO_EXTRA_CHECK
  197206             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  197207             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  197208             : #endif
  197209             : 
  197210           0 :           returnPointer = &( ( (SgAsmOp*)(SgAsmOp::pools[memoryBlock]) ) [positionInPool]) ;
  197211             : 
  197212             : #if FILE_IO_EXTRA_CHECK
  197213           0 :           assert ( returnPointer != NULL ) ;
  197214             : #endif
  197215             :         }
  197216           0 :      return returnPointer ;
  197217             :    }
  197218             : 
  197219             : //############################################################################
  197220             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  197221             :  * pool size! We set for every valid object in the memory pool the freepointer
  197222             :  * to the global index and increase the global index afterwards. For all the 
  197223             :  * invalid objects (means address ranges within the memory pool that were not
  197224             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  197225             :  * distinguish valid from invalid objects! 
  197226             :  */
  197227             : unsigned long
  197228           5 : SgAsmOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  197229             :    {
  197230           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  197231           5 :      SgAsmOp* pointer = NULL;
  197232           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  197233           5 :      std::vector < unsigned char* > :: const_iterator block;
  197234           5 :      for ( block = SgAsmOp::pools.begin(); block != SgAsmOp::pools.end() ; ++block )
  197235             :         {
  197236           0 :           pointer = (SgAsmOp*)(*block);
  197237           0 :           for (unsigned i = 0; i < SgAsmOp::pool_size; ++i )
  197238             :              {
  197239             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  197240             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  197241             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  197242             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  197243             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  197244             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  197245             :             // properly; so this will have to be checked next.
  197246             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  197247             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  197248           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  197249             :                   {
  197250           0 :                     pointer[i].set_freepointer((SgAsmOp*)(globalIndex));
  197251           0 :                     globalIndex++;
  197252             :                   }
  197253             :                else
  197254             :                   {
  197255           0 :                     pointer[i].set_freepointer(NULL);
  197256             :                   }
  197257             :               }
  197258             :         }
  197259           5 :      return globalIndex;
  197260             :    }
  197261             : 
  197262             : //############################################################################
  197263             : // JH (01/14/2006)
  197264             : void
  197265           5 : SgAsmOp::resetValidFreepointers( )
  197266             :    {
  197267           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  197268           5 :      SgAsmOp* pointer = NULL;
  197269           5 :      std::vector < unsigned char* > :: const_iterator block;
  197270           5 :      SgAsmOp* pointerOfLinkedList = NULL;
  197271           5 :      for ( block = SgAsmOp::pools.begin(); block != SgAsmOp::pools.end() ; ++block )
  197272             :         {
  197273           0 :           pointer = (SgAsmOp*)(*block);
  197274           0 :           for (unsigned i = 0; i < SgAsmOp::pool_size; ++i )
  197275             :              {
  197276             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  197277             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  197278             :             // memory blocks!.
  197279           0 :                if ( pointer[i].get_freepointer() != NULL )
  197280             :                   {
  197281           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  197282             :                   }
  197283             :                else
  197284             :                   {
  197285           0 :                     if ( pointerOfLinkedList == NULL )
  197286             :                        {
  197287           0 :                          SgAsmOp::next_node = &(pointer[i]);
  197288             :                        }
  197289             :                     else
  197290             :                        {
  197291             :                       // printf ("In SgAsmOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  197292           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  197293             :                        }
  197294             :                     pointerOfLinkedList = &(pointer[i]);
  197295             :                   }
  197296             :               }
  197297             :         }
  197298             : 
  197299           5 :      if ( pointerOfLinkedList != NULL )
  197300             :         {
  197301             :        // printf ("In SgAsmOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  197302           0 :           pointerOfLinkedList->set_freepointer(NULL);
  197303             :        // DQ (6/6/2010): Temporary debugging...
  197304             :        //   ROSE_ASSERT(false);
  197305             :         }
  197306             : 
  197307           5 :      return ;
  197308             :    }
  197309             : 
  197310             : //############################################################################
  197311             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  197312             :  * within the memory pool and resets the freepointers, in order to achieve a 
  197313             :  * linked list, that has no jumps and starts at the beginning! This function 
  197314             :  * does not extend the memory pool, since we do not delete any memory blocks,
  197315             :  * but delete the valid objects.  
  197316             :  */
  197317             : void
  197318           0 : SgAsmOp::clearMemoryPool( )
  197319             :    {
  197320             :   // printf ("Inside of SgAsmOp::clearMemoryPool() \n");
  197321             : 
  197322           0 :      SgAsmOp* pointer = NULL, *tempPointer = NULL;
  197323           0 :      std::vector < unsigned char* > :: const_iterator block;
  197324           0 :      if ( SgAsmOp::pools.empty() == false )
  197325             :         {
  197326           0 :           block = SgAsmOp::pools.begin() ;
  197327           0 :           SgAsmOp::next_node = (SgAsmOp*) (*block);
  197328             : 
  197329           0 :           while ( block != SgAsmOp::pools.end() )
  197330             :              {
  197331           0 :                pointer = (SgAsmOp*) (*block);
  197332           0 :                if ( tempPointer != NULL )
  197333             :                   {
  197334           0 :                     tempPointer->set_freepointer(pointer);
  197335             :                   }
  197336           0 :                for (unsigned i = 0; i < SgAsmOp::pool_size - 1; ++i)
  197337             :                   {
  197338           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  197339             :                   }
  197340           0 :                 pointer[SgAsmOp::pool_size-1].set_freepointer(NULL);
  197341           0 :                 tempPointer = &(pointer[SgAsmOp::pool_size-1]);
  197342           0 :                 ++block;
  197343             :              }
  197344             :         }
  197345           0 :    }
  197346             : 
  197347           5 : void SgAsmOp::deleteMemoryPool() {
  197348           5 :   for (auto p: SgAsmOp::pools) {
  197349           0 :     ROSE_FREE(p);
  197350             :   }
  197351           5 :   SgAsmOp::next_node = nullptr;
  197352           5 :   SgAsmOp::pools.clear();
  197353           5 : }
  197354             : 
  197355             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  197356             : //                 reading multiple binary files to for a single AST.
  197357             : /////////// new version ////////////////////////////////
  197358             : //############################################################################
  197359             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  197360             : void
  197361           2 : SgAsmOp::extendMemoryPoolForFileIO( )
  197362             :   {
  197363           2 :     size_t blockIndex = SgAsmOp::pools.size();
  197364           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAsmOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsmOp);
  197365             : 
  197366           2 :     while ( (blockIndex * SgAsmOp::pool_size) < newPoolSize)
  197367             :       {
  197368             : #if ROSE_ALLOC_TRACE
  197369             :         if (blockIndex > 0) {
  197370             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAsmOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsmOp) = %" PRIuPTR " SgAsmOp::pool_size = %d \n",
  197371             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAsmOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAsmOp),SgAsmOp::pool_size);
  197372             :         }
  197373             : #endif
  197374             : 
  197375           0 :         SgAsmOp * pointer = (SgAsmOp*) ROSE_MALLOC ( SgAsmOp::pool_size * sizeof(SgAsmOp) );
  197376           0 :         assert( pointer != NULL );
  197377             : #if ROSE_ALLOC_MEMSET == 1
  197378             :         memset(pointer, 0x00, SgAsmOp::pool_size * sizeof(SgAsmOp));
  197379             : #elif ROSE_ALLOC_MEMSET == 2
  197380             :         memset(pointer, 0xCC, SgAsmOp::pool_size * sizeof(SgAsmOp));
  197381             : #endif
  197382           0 :         SgAsmOp::pools.push_back( (unsigned char*)(pointer) );
  197383           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAsmOp::pool_size * sizeof(SgAsmOp), V_SgAsmOp ) );
  197384             : 
  197385           0 :         if ( SgAsmOp::next_node != NULL ) {
  197386           0 :           if ( blockIndex > 0 ) {
  197387           0 :             SgAsmOp * blkptr = (SgAsmOp*)(SgAsmOp::pools[blockIndex-1]);
  197388           0 :             blkptr[ SgAsmOp::pool_size - 1 ].set_freepointer(pointer);
  197389             :           }
  197390             :         } else {
  197391           0 :           SgAsmOp::next_node = pointer;
  197392             :         }
  197393             : 
  197394           0 :         for (unsigned i = 0; i < SgAsmOp::pool_size-1; ++i)
  197395             :            {
  197396           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  197397             :            }
  197398           0 :         pointer[ SgAsmOp::pool_size -1 ].set_freepointer(NULL);
  197399             : 
  197400           0 :         blockIndex++;
  197401             :       }
  197402           2 :   }
  197403             : 
  197404             : //############################################################################
  197405             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  197406             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  197407             :  * not compressed. However, that stuff is not yet implemented! 
  197408             :  */
  197409             : unsigned long
  197410           0 : SgAsmOp::getNumberOfLastValidPointer()
  197411             :    {
  197412           0 :       SgAsmOp* testPointer = (SgAsmOp*)(SgAsmOp::pools.back());
  197413           0 :       unsigned long localIndex = SgAsmOp::pool_size - 1;
  197414           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  197415             :          {
  197416           0 :            localIndex--;
  197417             :          }
  197418           0 :       return (localIndex + SgAsmOp::pool_size * (SgAsmOp::pools.size()-1));
  197419             :    }
  197420             : 
  197421             : //############################################################################
  197422             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  197423             :  * memory pool and initializes the data member in class SgAsmOpStroageClass
  197424             :  * from its counterpart of SgAsmOp. The return value is just for checking, 
  197425             :  * that the whole StorageClassArray is initialized!
  197426             :  */
  197427             : unsigned long
  197428           0 : SgAsmOp::initializeStorageClassArray( SgAsmOpStorageClass *storageArray )
  197429             :    {
  197430           0 :      unsigned long storageCounter = 0;
  197431           0 :      std::vector < unsigned char* > :: const_iterator block = SgAsmOp::pools.begin();
  197432           0 :      SgAsmOp* pointer = NULL;
  197433           0 :      while ( block != SgAsmOp::pools.end() ) {
  197434           0 :           pointer = (SgAsmOp*) (*block);
  197435           0 :           for ( unsigned i = 0; i < SgAsmOp::pool_size; ++i ) {
  197436           0 :                if ( pointer->get_freepointer() != NULL ) {
  197437           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  197438           0 :                  storageArray++;
  197439           0 :                  storageCounter++;
  197440             :                }
  197441           0 :                pointer++;
  197442             :              }
  197443           0 :            block++;
  197444             :         }
  197445           0 :      return storageCounter;
  197446             :    }
  197447             : 
  197448             : /* #line 197449 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  197449             : 
  197450             : 
  197451             : 
  197452             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  197453             : 
  197454             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  197455             : 
  197456             : //############################################################################
  197457             : /* JH (02/02/2006) Constructor of the IR node SgLabelRefExp that takes its 
  197458             :  * corresponding StorageClass as parameter
  197459             :  */
  197460           0 : SgLabelRefExp :: SgLabelRefExp ( const SgLabelRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  197461             :    {
  197462             : 
  197463             : 
  197464             : /* #line 197465 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  197465             : 
  197466           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  197467           0 :      p_symbol =  (SgLabelSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol) );
  197468             : 
  197469             : 
  197470             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  197471             : 
  197472             : 
  197473           0 :    }
  197474             : 
  197475             : //############################################################################
  197476             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  197477             :  * within the working AST. 
  197478             :  */
  197479           0 : SgLabelRefExp * SgLabelRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  197480           0 :      SgLabelRefExp* returnPointer = NULL;
  197481           0 :      if ( globalIndex != 0 )
  197482             :         {
  197483             : 
  197484             : #if FILE_IO_EXTRA_CHECK
  197485           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLabelRefExp ) ) <= globalIndex ) ;
  197486           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLabelRefExp + 1 ) ) );
  197487             : #endif
  197488           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLabelRefExp )  
  197489           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLabelRefExp );
  197490           0 :           unsigned long positionInPool = localIndex % SgLabelRefExp::pool_size;
  197491           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLabelRefExp::pool_size;
  197492             : 
  197493             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  197494             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  197495             : 
  197496           0 :           returnPointer = &( ( (SgLabelRefExp*)(SgLabelRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  197497             : 
  197498           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  197499             :         }
  197500           0 :      return returnPointer ;
  197501             :    }
  197502             : 
  197503             : //############################################################################
  197504             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  197505             :   for the AST with the index astIndex
  197506             : */
  197507           0 : SgLabelRefExp * SgLabelRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  197508           0 :      SgLabelRefExp* returnPointer = NULL;
  197509           0 :      if ( globalIndex != 0 )
  197510             :         {
  197511             : 
  197512             : #if FILE_IO_EXTRA_CHECK
  197513           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLabelRefExp ) ) <= globalIndex ) ;
  197514           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLabelRefExp + 1 ) ) );
  197515             : #endif
  197516           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLabelRefExp )
  197517           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLabelRefExp );
  197518           0 :           unsigned long positionInPool = localIndex % SgLabelRefExp::pool_size ;
  197519           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLabelRefExp::pool_size ;
  197520             : 
  197521             : #if FILE_IO_EXTRA_CHECK
  197522             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  197523             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  197524             : #endif
  197525             : 
  197526           0 :           returnPointer = &( ( (SgLabelRefExp*)(SgLabelRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  197527             : 
  197528             : #if FILE_IO_EXTRA_CHECK
  197529           0 :           assert ( returnPointer != NULL ) ;
  197530             : #endif
  197531             :         }
  197532           0 :      return returnPointer ;
  197533             :    }
  197534             : 
  197535             : //############################################################################
  197536             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  197537             :  * pool size! We set for every valid object in the memory pool the freepointer
  197538             :  * to the global index and increase the global index afterwards. For all the 
  197539             :  * invalid objects (means address ranges within the memory pool that were not
  197540             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  197541             :  * distinguish valid from invalid objects! 
  197542             :  */
  197543             : unsigned long
  197544           5 : SgLabelRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  197545             :    {
  197546           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  197547           5 :      SgLabelRefExp* pointer = NULL;
  197548           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  197549           5 :      std::vector < unsigned char* > :: const_iterator block;
  197550           5 :      for ( block = SgLabelRefExp::pools.begin(); block != SgLabelRefExp::pools.end() ; ++block )
  197551             :         {
  197552           0 :           pointer = (SgLabelRefExp*)(*block);
  197553           0 :           for (unsigned i = 0; i < SgLabelRefExp::pool_size; ++i )
  197554             :              {
  197555             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  197556             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  197557             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  197558             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  197559             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  197560             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  197561             :             // properly; so this will have to be checked next.
  197562             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  197563             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  197564           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  197565             :                   {
  197566           0 :                     pointer[i].set_freepointer((SgLabelRefExp*)(globalIndex));
  197567           0 :                     globalIndex++;
  197568             :                   }
  197569             :                else
  197570             :                   {
  197571           0 :                     pointer[i].set_freepointer(NULL);
  197572             :                   }
  197573             :               }
  197574             :         }
  197575           5 :      return globalIndex;
  197576             :    }
  197577             : 
  197578             : //############################################################################
  197579             : // JH (01/14/2006)
  197580             : void
  197581           5 : SgLabelRefExp::resetValidFreepointers( )
  197582             :    {
  197583           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  197584           5 :      SgLabelRefExp* pointer = NULL;
  197585           5 :      std::vector < unsigned char* > :: const_iterator block;
  197586           5 :      SgLabelRefExp* pointerOfLinkedList = NULL;
  197587           5 :      for ( block = SgLabelRefExp::pools.begin(); block != SgLabelRefExp::pools.end() ; ++block )
  197588             :         {
  197589           0 :           pointer = (SgLabelRefExp*)(*block);
  197590           0 :           for (unsigned i = 0; i < SgLabelRefExp::pool_size; ++i )
  197591             :              {
  197592             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  197593             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  197594             :             // memory blocks!.
  197595           0 :                if ( pointer[i].get_freepointer() != NULL )
  197596             :                   {
  197597           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  197598             :                   }
  197599             :                else
  197600             :                   {
  197601           0 :                     if ( pointerOfLinkedList == NULL )
  197602             :                        {
  197603           0 :                          SgLabelRefExp::next_node = &(pointer[i]);
  197604             :                        }
  197605             :                     else
  197606             :                        {
  197607             :                       // printf ("In SgLabelRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  197608           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  197609             :                        }
  197610             :                     pointerOfLinkedList = &(pointer[i]);
  197611             :                   }
  197612             :               }
  197613             :         }
  197614             : 
  197615           5 :      if ( pointerOfLinkedList != NULL )
  197616             :         {
  197617             :        // printf ("In SgLabelRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  197618           0 :           pointerOfLinkedList->set_freepointer(NULL);
  197619             :        // DQ (6/6/2010): Temporary debugging...
  197620             :        //   ROSE_ASSERT(false);
  197621             :         }
  197622             : 
  197623           5 :      return ;
  197624             :    }
  197625             : 
  197626             : //############################################################################
  197627             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  197628             :  * within the memory pool and resets the freepointers, in order to achieve a 
  197629             :  * linked list, that has no jumps and starts at the beginning! This function 
  197630             :  * does not extend the memory pool, since we do not delete any memory blocks,
  197631             :  * but delete the valid objects.  
  197632             :  */
  197633             : void
  197634           0 : SgLabelRefExp::clearMemoryPool( )
  197635             :    {
  197636             :   // printf ("Inside of SgLabelRefExp::clearMemoryPool() \n");
  197637             : 
  197638           0 :      SgLabelRefExp* pointer = NULL, *tempPointer = NULL;
  197639           0 :      std::vector < unsigned char* > :: const_iterator block;
  197640           0 :      if ( SgLabelRefExp::pools.empty() == false )
  197641             :         {
  197642           0 :           block = SgLabelRefExp::pools.begin() ;
  197643           0 :           SgLabelRefExp::next_node = (SgLabelRefExp*) (*block);
  197644             : 
  197645           0 :           while ( block != SgLabelRefExp::pools.end() )
  197646             :              {
  197647           0 :                pointer = (SgLabelRefExp*) (*block);
  197648           0 :                if ( tempPointer != NULL )
  197649             :                   {
  197650           0 :                     tempPointer->set_freepointer(pointer);
  197651             :                   }
  197652           0 :                for (unsigned i = 0; i < SgLabelRefExp::pool_size - 1; ++i)
  197653             :                   {
  197654           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  197655             :                   }
  197656           0 :                 pointer[SgLabelRefExp::pool_size-1].set_freepointer(NULL);
  197657           0 :                 tempPointer = &(pointer[SgLabelRefExp::pool_size-1]);
  197658           0 :                 ++block;
  197659             :              }
  197660             :         }
  197661           0 :    }
  197662             : 
  197663           5 : void SgLabelRefExp::deleteMemoryPool() {
  197664           5 :   for (auto p: SgLabelRefExp::pools) {
  197665           0 :     ROSE_FREE(p);
  197666             :   }
  197667           5 :   SgLabelRefExp::next_node = nullptr;
  197668           5 :   SgLabelRefExp::pools.clear();
  197669           5 : }
  197670             : 
  197671             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  197672             : //                 reading multiple binary files to for a single AST.
  197673             : /////////// new version ////////////////////////////////
  197674             : //############################################################################
  197675             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  197676             : void
  197677           2 : SgLabelRefExp::extendMemoryPoolForFileIO( )
  197678             :   {
  197679           2 :     size_t blockIndex = SgLabelRefExp::pools.size();
  197680           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelRefExp);
  197681             : 
  197682           2 :     while ( (blockIndex * SgLabelRefExp::pool_size) < newPoolSize)
  197683             :       {
  197684             : #if ROSE_ALLOC_TRACE
  197685             :         if (blockIndex > 0) {
  197686             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelRefExp) = %" PRIuPTR " SgLabelRefExp::pool_size = %d \n",
  197687             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelRefExp),SgLabelRefExp::pool_size);
  197688             :         }
  197689             : #endif
  197690             : 
  197691           0 :         SgLabelRefExp * pointer = (SgLabelRefExp*) ROSE_MALLOC ( SgLabelRefExp::pool_size * sizeof(SgLabelRefExp) );
  197692           0 :         assert( pointer != NULL );
  197693             : #if ROSE_ALLOC_MEMSET == 1
  197694             :         memset(pointer, 0x00, SgLabelRefExp::pool_size * sizeof(SgLabelRefExp));
  197695             : #elif ROSE_ALLOC_MEMSET == 2
  197696             :         memset(pointer, 0xCC, SgLabelRefExp::pool_size * sizeof(SgLabelRefExp));
  197697             : #endif
  197698           0 :         SgLabelRefExp::pools.push_back( (unsigned char*)(pointer) );
  197699           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLabelRefExp::pool_size * sizeof(SgLabelRefExp), V_SgLabelRefExp ) );
  197700             : 
  197701           0 :         if ( SgLabelRefExp::next_node != NULL ) {
  197702           0 :           if ( blockIndex > 0 ) {
  197703           0 :             SgLabelRefExp * blkptr = (SgLabelRefExp*)(SgLabelRefExp::pools[blockIndex-1]);
  197704           0 :             blkptr[ SgLabelRefExp::pool_size - 1 ].set_freepointer(pointer);
  197705             :           }
  197706             :         } else {
  197707           0 :           SgLabelRefExp::next_node = pointer;
  197708             :         }
  197709             : 
  197710           0 :         for (unsigned i = 0; i < SgLabelRefExp::pool_size-1; ++i)
  197711             :            {
  197712           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  197713             :            }
  197714           0 :         pointer[ SgLabelRefExp::pool_size -1 ].set_freepointer(NULL);
  197715             : 
  197716           0 :         blockIndex++;
  197717             :       }
  197718           2 :   }
  197719             : 
  197720             : //############################################################################
  197721             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  197722             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  197723             :  * not compressed. However, that stuff is not yet implemented! 
  197724             :  */
  197725             : unsigned long
  197726           0 : SgLabelRefExp::getNumberOfLastValidPointer()
  197727             :    {
  197728           0 :       SgLabelRefExp* testPointer = (SgLabelRefExp*)(SgLabelRefExp::pools.back());
  197729           0 :       unsigned long localIndex = SgLabelRefExp::pool_size - 1;
  197730           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  197731             :          {
  197732           0 :            localIndex--;
  197733             :          }
  197734           0 :       return (localIndex + SgLabelRefExp::pool_size * (SgLabelRefExp::pools.size()-1));
  197735             :    }
  197736             : 
  197737             : //############################################################################
  197738             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  197739             :  * memory pool and initializes the data member in class SgLabelRefExpStroageClass
  197740             :  * from its counterpart of SgLabelRefExp. The return value is just for checking, 
  197741             :  * that the whole StorageClassArray is initialized!
  197742             :  */
  197743             : unsigned long
  197744           0 : SgLabelRefExp::initializeStorageClassArray( SgLabelRefExpStorageClass *storageArray )
  197745             :    {
  197746           0 :      unsigned long storageCounter = 0;
  197747           0 :      std::vector < unsigned char* > :: const_iterator block = SgLabelRefExp::pools.begin();
  197748           0 :      SgLabelRefExp* pointer = NULL;
  197749           0 :      while ( block != SgLabelRefExp::pools.end() ) {
  197750           0 :           pointer = (SgLabelRefExp*) (*block);
  197751           0 :           for ( unsigned i = 0; i < SgLabelRefExp::pool_size; ++i ) {
  197752           0 :                if ( pointer->get_freepointer() != NULL ) {
  197753           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  197754           0 :                  storageArray++;
  197755           0 :                  storageCounter++;
  197756             :                }
  197757           0 :                pointer++;
  197758             :              }
  197759           0 :            block++;
  197760             :         }
  197761           0 :      return storageCounter;
  197762             :    }
  197763             : 
  197764             : /* #line 197765 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  197765             : 
  197766             : 
  197767             : 
  197768             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  197769             : 
  197770             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  197771             : 
  197772             : //############################################################################
  197773             : /* JH (02/02/2006) Constructor of the IR node SgActualArgumentExpression that takes its 
  197774             :  * corresponding StorageClass as parameter
  197775             :  */
  197776           0 : SgActualArgumentExpression :: SgActualArgumentExpression ( const SgActualArgumentExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  197777             :    {
  197778             : 
  197779             : 
  197780             : /* #line 197781 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  197781             : 
  197782           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  197783           0 :      p_argument_name = SgName ( storageSource.storageOf_argument_name ) ;
  197784           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  197785             : 
  197786             : 
  197787             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  197788             : 
  197789             : 
  197790           0 :    }
  197791             : 
  197792             : //############################################################################
  197793             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  197794             :  * within the working AST. 
  197795             :  */
  197796           0 : SgActualArgumentExpression * SgActualArgumentExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  197797           0 :      SgActualArgumentExpression* returnPointer = NULL;
  197798           0 :      if ( globalIndex != 0 )
  197799             :         {
  197800             : 
  197801             : #if FILE_IO_EXTRA_CHECK
  197802           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgActualArgumentExpression ) ) <= globalIndex ) ;
  197803           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgActualArgumentExpression + 1 ) ) );
  197804             : #endif
  197805           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgActualArgumentExpression )  
  197806           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgActualArgumentExpression );
  197807           0 :           unsigned long positionInPool = localIndex % SgActualArgumentExpression::pool_size;
  197808           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgActualArgumentExpression::pool_size;
  197809             : 
  197810             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  197811             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  197812             : 
  197813           0 :           returnPointer = &( ( (SgActualArgumentExpression*)(SgActualArgumentExpression::pools[memoryBlock]) ) [positionInPool]) ;
  197814             : 
  197815           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  197816             :         }
  197817           0 :      return returnPointer ;
  197818             :    }
  197819             : 
  197820             : //############################################################################
  197821             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  197822             :   for the AST with the index astIndex
  197823             : */
  197824           0 : SgActualArgumentExpression * SgActualArgumentExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  197825           0 :      SgActualArgumentExpression* returnPointer = NULL;
  197826           0 :      if ( globalIndex != 0 )
  197827             :         {
  197828             : 
  197829             : #if FILE_IO_EXTRA_CHECK
  197830           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgActualArgumentExpression ) ) <= globalIndex ) ;
  197831           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgActualArgumentExpression + 1 ) ) );
  197832             : #endif
  197833           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgActualArgumentExpression )
  197834           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgActualArgumentExpression );
  197835           0 :           unsigned long positionInPool = localIndex % SgActualArgumentExpression::pool_size ;
  197836           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgActualArgumentExpression::pool_size ;
  197837             : 
  197838             : #if FILE_IO_EXTRA_CHECK
  197839             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  197840             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  197841             : #endif
  197842             : 
  197843           0 :           returnPointer = &( ( (SgActualArgumentExpression*)(SgActualArgumentExpression::pools[memoryBlock]) ) [positionInPool]) ;
  197844             : 
  197845             : #if FILE_IO_EXTRA_CHECK
  197846           0 :           assert ( returnPointer != NULL ) ;
  197847             : #endif
  197848             :         }
  197849           0 :      return returnPointer ;
  197850             :    }
  197851             : 
  197852             : //############################################################################
  197853             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  197854             :  * pool size! We set for every valid object in the memory pool the freepointer
  197855             :  * to the global index and increase the global index afterwards. For all the 
  197856             :  * invalid objects (means address ranges within the memory pool that were not
  197857             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  197858             :  * distinguish valid from invalid objects! 
  197859             :  */
  197860             : unsigned long
  197861           5 : SgActualArgumentExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  197862             :    {
  197863           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  197864           5 :      SgActualArgumentExpression* pointer = NULL;
  197865           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  197866           5 :      std::vector < unsigned char* > :: const_iterator block;
  197867           5 :      for ( block = SgActualArgumentExpression::pools.begin(); block != SgActualArgumentExpression::pools.end() ; ++block )
  197868             :         {
  197869           0 :           pointer = (SgActualArgumentExpression*)(*block);
  197870           0 :           for (unsigned i = 0; i < SgActualArgumentExpression::pool_size; ++i )
  197871             :              {
  197872             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  197873             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  197874             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  197875             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  197876             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  197877             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  197878             :             // properly; so this will have to be checked next.
  197879             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  197880             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  197881           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  197882             :                   {
  197883           0 :                     pointer[i].set_freepointer((SgActualArgumentExpression*)(globalIndex));
  197884           0 :                     globalIndex++;
  197885             :                   }
  197886             :                else
  197887             :                   {
  197888           0 :                     pointer[i].set_freepointer(NULL);
  197889             :                   }
  197890             :               }
  197891             :         }
  197892           5 :      return globalIndex;
  197893             :    }
  197894             : 
  197895             : //############################################################################
  197896             : // JH (01/14/2006)
  197897             : void
  197898           5 : SgActualArgumentExpression::resetValidFreepointers( )
  197899             :    {
  197900           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  197901           5 :      SgActualArgumentExpression* pointer = NULL;
  197902           5 :      std::vector < unsigned char* > :: const_iterator block;
  197903           5 :      SgActualArgumentExpression* pointerOfLinkedList = NULL;
  197904           5 :      for ( block = SgActualArgumentExpression::pools.begin(); block != SgActualArgumentExpression::pools.end() ; ++block )
  197905             :         {
  197906           0 :           pointer = (SgActualArgumentExpression*)(*block);
  197907           0 :           for (unsigned i = 0; i < SgActualArgumentExpression::pool_size; ++i )
  197908             :              {
  197909             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  197910             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  197911             :             // memory blocks!.
  197912           0 :                if ( pointer[i].get_freepointer() != NULL )
  197913             :                   {
  197914           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  197915             :                   }
  197916             :                else
  197917             :                   {
  197918           0 :                     if ( pointerOfLinkedList == NULL )
  197919             :                        {
  197920           0 :                          SgActualArgumentExpression::next_node = &(pointer[i]);
  197921             :                        }
  197922             :                     else
  197923             :                        {
  197924             :                       // printf ("In SgActualArgumentExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  197925           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  197926             :                        }
  197927             :                     pointerOfLinkedList = &(pointer[i]);
  197928             :                   }
  197929             :               }
  197930             :         }
  197931             : 
  197932           5 :      if ( pointerOfLinkedList != NULL )
  197933             :         {
  197934             :        // printf ("In SgActualArgumentExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  197935           0 :           pointerOfLinkedList->set_freepointer(NULL);
  197936             :        // DQ (6/6/2010): Temporary debugging...
  197937             :        //   ROSE_ASSERT(false);
  197938             :         }
  197939             : 
  197940           5 :      return ;
  197941             :    }
  197942             : 
  197943             : //############################################################################
  197944             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  197945             :  * within the memory pool and resets the freepointers, in order to achieve a 
  197946             :  * linked list, that has no jumps and starts at the beginning! This function 
  197947             :  * does not extend the memory pool, since we do not delete any memory blocks,
  197948             :  * but delete the valid objects.  
  197949             :  */
  197950             : void
  197951           0 : SgActualArgumentExpression::clearMemoryPool( )
  197952             :    {
  197953             :   // printf ("Inside of SgActualArgumentExpression::clearMemoryPool() \n");
  197954             : 
  197955           0 :      SgActualArgumentExpression* pointer = NULL, *tempPointer = NULL;
  197956           0 :      std::vector < unsigned char* > :: const_iterator block;
  197957           0 :      if ( SgActualArgumentExpression::pools.empty() == false )
  197958             :         {
  197959           0 :           block = SgActualArgumentExpression::pools.begin() ;
  197960           0 :           SgActualArgumentExpression::next_node = (SgActualArgumentExpression*) (*block);
  197961             : 
  197962           0 :           while ( block != SgActualArgumentExpression::pools.end() )
  197963             :              {
  197964           0 :                pointer = (SgActualArgumentExpression*) (*block);
  197965           0 :                if ( tempPointer != NULL )
  197966             :                   {
  197967           0 :                     tempPointer->set_freepointer(pointer);
  197968             :                   }
  197969           0 :                for (unsigned i = 0; i < SgActualArgumentExpression::pool_size - 1; ++i)
  197970             :                   {
  197971           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  197972             :                   }
  197973           0 :                 pointer[SgActualArgumentExpression::pool_size-1].set_freepointer(NULL);
  197974           0 :                 tempPointer = &(pointer[SgActualArgumentExpression::pool_size-1]);
  197975           0 :                 ++block;
  197976             :              }
  197977             :         }
  197978           0 :    }
  197979             : 
  197980           5 : void SgActualArgumentExpression::deleteMemoryPool() {
  197981           5 :   for (auto p: SgActualArgumentExpression::pools) {
  197982           0 :     ROSE_FREE(p);
  197983             :   }
  197984           5 :   SgActualArgumentExpression::next_node = nullptr;
  197985           5 :   SgActualArgumentExpression::pools.clear();
  197986           5 : }
  197987             : 
  197988             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  197989             : //                 reading multiple binary files to for a single AST.
  197990             : /////////// new version ////////////////////////////////
  197991             : //############################################################################
  197992             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  197993             : void
  197994           2 : SgActualArgumentExpression::extendMemoryPoolForFileIO( )
  197995             :   {
  197996           2 :     size_t blockIndex = SgActualArgumentExpression::pools.size();
  197997           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgActualArgumentExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgActualArgumentExpression);
  197998             : 
  197999           2 :     while ( (blockIndex * SgActualArgumentExpression::pool_size) < newPoolSize)
  198000             :       {
  198001             : #if ROSE_ALLOC_TRACE
  198002             :         if (blockIndex > 0) {
  198003             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgActualArgumentExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgActualArgumentExpression) = %" PRIuPTR " SgActualArgumentExpression::pool_size = %d \n",
  198004             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgActualArgumentExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgActualArgumentExpression),SgActualArgumentExpression::pool_size);
  198005             :         }
  198006             : #endif
  198007             : 
  198008           0 :         SgActualArgumentExpression * pointer = (SgActualArgumentExpression*) ROSE_MALLOC ( SgActualArgumentExpression::pool_size * sizeof(SgActualArgumentExpression) );
  198009           0 :         assert( pointer != NULL );
  198010             : #if ROSE_ALLOC_MEMSET == 1
  198011             :         memset(pointer, 0x00, SgActualArgumentExpression::pool_size * sizeof(SgActualArgumentExpression));
  198012             : #elif ROSE_ALLOC_MEMSET == 2
  198013             :         memset(pointer, 0xCC, SgActualArgumentExpression::pool_size * sizeof(SgActualArgumentExpression));
  198014             : #endif
  198015           0 :         SgActualArgumentExpression::pools.push_back( (unsigned char*)(pointer) );
  198016           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgActualArgumentExpression::pool_size * sizeof(SgActualArgumentExpression), V_SgActualArgumentExpression ) );
  198017             : 
  198018           0 :         if ( SgActualArgumentExpression::next_node != NULL ) {
  198019           0 :           if ( blockIndex > 0 ) {
  198020           0 :             SgActualArgumentExpression * blkptr = (SgActualArgumentExpression*)(SgActualArgumentExpression::pools[blockIndex-1]);
  198021           0 :             blkptr[ SgActualArgumentExpression::pool_size - 1 ].set_freepointer(pointer);
  198022             :           }
  198023             :         } else {
  198024           0 :           SgActualArgumentExpression::next_node = pointer;
  198025             :         }
  198026             : 
  198027           0 :         for (unsigned i = 0; i < SgActualArgumentExpression::pool_size-1; ++i)
  198028             :            {
  198029           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  198030             :            }
  198031           0 :         pointer[ SgActualArgumentExpression::pool_size -1 ].set_freepointer(NULL);
  198032             : 
  198033           0 :         blockIndex++;
  198034             :       }
  198035           2 :   }
  198036             : 
  198037             : //############################################################################
  198038             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  198039             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  198040             :  * not compressed. However, that stuff is not yet implemented! 
  198041             :  */
  198042             : unsigned long
  198043           0 : SgActualArgumentExpression::getNumberOfLastValidPointer()
  198044             :    {
  198045           0 :       SgActualArgumentExpression* testPointer = (SgActualArgumentExpression*)(SgActualArgumentExpression::pools.back());
  198046           0 :       unsigned long localIndex = SgActualArgumentExpression::pool_size - 1;
  198047           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  198048             :          {
  198049           0 :            localIndex--;
  198050             :          }
  198051           0 :       return (localIndex + SgActualArgumentExpression::pool_size * (SgActualArgumentExpression::pools.size()-1));
  198052             :    }
  198053             : 
  198054             : //############################################################################
  198055             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  198056             :  * memory pool and initializes the data member in class SgActualArgumentExpressionStroageClass
  198057             :  * from its counterpart of SgActualArgumentExpression. The return value is just for checking, 
  198058             :  * that the whole StorageClassArray is initialized!
  198059             :  */
  198060             : unsigned long
  198061           0 : SgActualArgumentExpression::initializeStorageClassArray( SgActualArgumentExpressionStorageClass *storageArray )
  198062             :    {
  198063           0 :      unsigned long storageCounter = 0;
  198064           0 :      std::vector < unsigned char* > :: const_iterator block = SgActualArgumentExpression::pools.begin();
  198065           0 :      SgActualArgumentExpression* pointer = NULL;
  198066           0 :      while ( block != SgActualArgumentExpression::pools.end() ) {
  198067           0 :           pointer = (SgActualArgumentExpression*) (*block);
  198068           0 :           for ( unsigned i = 0; i < SgActualArgumentExpression::pool_size; ++i ) {
  198069           0 :                if ( pointer->get_freepointer() != NULL ) {
  198070           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  198071           0 :                  storageArray++;
  198072           0 :                  storageCounter++;
  198073             :                }
  198074           0 :                pointer++;
  198075             :              }
  198076           0 :            block++;
  198077             :         }
  198078           0 :      return storageCounter;
  198079             :    }
  198080             : 
  198081             : /* #line 198082 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  198082             : 
  198083             : 
  198084             : 
  198085             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  198086             : 
  198087             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  198088             : 
  198089             : //############################################################################
  198090             : /* JH (02/02/2006) Constructor of the IR node SgUnknownArrayOrFunctionReference that takes its 
  198091             :  * corresponding StorageClass as parameter
  198092             :  */
  198093           0 : SgUnknownArrayOrFunctionReference :: SgUnknownArrayOrFunctionReference ( const SgUnknownArrayOrFunctionReferenceStorageClass& storageSource )   : SgExpression (storageSource)
  198094             :    {
  198095             : 
  198096             : 
  198097             : /* #line 198098 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  198098             : 
  198099           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  198100           0 :      p_name = storageSource.storageOf_name.rebuildDataStoredInEasyStorageClass() ;
  198101           0 :      p_named_reference =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_named_reference) );
  198102           0 :      p_expression_list =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_list) );
  198103             : 
  198104             : 
  198105             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  198106             : 
  198107             : 
  198108           0 :    }
  198109             : 
  198110             : //############################################################################
  198111             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  198112             :  * within the working AST. 
  198113             :  */
  198114           0 : SgUnknownArrayOrFunctionReference * SgUnknownArrayOrFunctionReference::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  198115           0 :      SgUnknownArrayOrFunctionReference* returnPointer = NULL;
  198116           0 :      if ( globalIndex != 0 )
  198117             :         {
  198118             : 
  198119             : #if FILE_IO_EXTRA_CHECK
  198120           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgUnknownArrayOrFunctionReference ) ) <= globalIndex ) ;
  198121           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnknownArrayOrFunctionReference + 1 ) ) );
  198122             : #endif
  198123           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgUnknownArrayOrFunctionReference )  
  198124           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgUnknownArrayOrFunctionReference );
  198125           0 :           unsigned long positionInPool = localIndex % SgUnknownArrayOrFunctionReference::pool_size;
  198126           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnknownArrayOrFunctionReference::pool_size;
  198127             : 
  198128             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  198129             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  198130             : 
  198131           0 :           returnPointer = &( ( (SgUnknownArrayOrFunctionReference*)(SgUnknownArrayOrFunctionReference::pools[memoryBlock]) ) [positionInPool]) ;
  198132             : 
  198133           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  198134             :         }
  198135           0 :      return returnPointer ;
  198136             :    }
  198137             : 
  198138             : //############################################################################
  198139             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  198140             :   for the AST with the index astIndex
  198141             : */
  198142           0 : SgUnknownArrayOrFunctionReference * SgUnknownArrayOrFunctionReference::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  198143           0 :      SgUnknownArrayOrFunctionReference* returnPointer = NULL;
  198144           0 :      if ( globalIndex != 0 )
  198145             :         {
  198146             : 
  198147             : #if FILE_IO_EXTRA_CHECK
  198148           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgUnknownArrayOrFunctionReference ) ) <= globalIndex ) ;
  198149           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnknownArrayOrFunctionReference + 1 ) ) );
  198150             : #endif
  198151           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgUnknownArrayOrFunctionReference )
  198152           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgUnknownArrayOrFunctionReference );
  198153           0 :           unsigned long positionInPool = localIndex % SgUnknownArrayOrFunctionReference::pool_size ;
  198154           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgUnknownArrayOrFunctionReference::pool_size ;
  198155             : 
  198156             : #if FILE_IO_EXTRA_CHECK
  198157             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  198158             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  198159             : #endif
  198160             : 
  198161           0 :           returnPointer = &( ( (SgUnknownArrayOrFunctionReference*)(SgUnknownArrayOrFunctionReference::pools[memoryBlock]) ) [positionInPool]) ;
  198162             : 
  198163             : #if FILE_IO_EXTRA_CHECK
  198164           0 :           assert ( returnPointer != NULL ) ;
  198165             : #endif
  198166             :         }
  198167           0 :      return returnPointer ;
  198168             :    }
  198169             : 
  198170             : //############################################################################
  198171             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  198172             :  * pool size! We set for every valid object in the memory pool the freepointer
  198173             :  * to the global index and increase the global index afterwards. For all the 
  198174             :  * invalid objects (means address ranges within the memory pool that were not
  198175             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  198176             :  * distinguish valid from invalid objects! 
  198177             :  */
  198178             : unsigned long
  198179           5 : SgUnknownArrayOrFunctionReference::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  198180             :    {
  198181           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  198182           5 :      SgUnknownArrayOrFunctionReference* pointer = NULL;
  198183           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  198184           5 :      std::vector < unsigned char* > :: const_iterator block;
  198185           5 :      for ( block = SgUnknownArrayOrFunctionReference::pools.begin(); block != SgUnknownArrayOrFunctionReference::pools.end() ; ++block )
  198186             :         {
  198187           0 :           pointer = (SgUnknownArrayOrFunctionReference*)(*block);
  198188           0 :           for (unsigned i = 0; i < SgUnknownArrayOrFunctionReference::pool_size; ++i )
  198189             :              {
  198190             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  198191             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  198192             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  198193             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  198194             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  198195             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  198196             :             // properly; so this will have to be checked next.
  198197             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  198198             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  198199           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  198200             :                   {
  198201           0 :                     pointer[i].set_freepointer((SgUnknownArrayOrFunctionReference*)(globalIndex));
  198202           0 :                     globalIndex++;
  198203             :                   }
  198204             :                else
  198205             :                   {
  198206           0 :                     pointer[i].set_freepointer(NULL);
  198207             :                   }
  198208             :               }
  198209             :         }
  198210           5 :      return globalIndex;
  198211             :    }
  198212             : 
  198213             : //############################################################################
  198214             : // JH (01/14/2006)
  198215             : void
  198216           5 : SgUnknownArrayOrFunctionReference::resetValidFreepointers( )
  198217             :    {
  198218           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  198219           5 :      SgUnknownArrayOrFunctionReference* pointer = NULL;
  198220           5 :      std::vector < unsigned char* > :: const_iterator block;
  198221           5 :      SgUnknownArrayOrFunctionReference* pointerOfLinkedList = NULL;
  198222           5 :      for ( block = SgUnknownArrayOrFunctionReference::pools.begin(); block != SgUnknownArrayOrFunctionReference::pools.end() ; ++block )
  198223             :         {
  198224           0 :           pointer = (SgUnknownArrayOrFunctionReference*)(*block);
  198225           0 :           for (unsigned i = 0; i < SgUnknownArrayOrFunctionReference::pool_size; ++i )
  198226             :              {
  198227             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  198228             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  198229             :             // memory blocks!.
  198230           0 :                if ( pointer[i].get_freepointer() != NULL )
  198231             :                   {
  198232           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  198233             :                   }
  198234             :                else
  198235             :                   {
  198236           0 :                     if ( pointerOfLinkedList == NULL )
  198237             :                        {
  198238           0 :                          SgUnknownArrayOrFunctionReference::next_node = &(pointer[i]);
  198239             :                        }
  198240             :                     else
  198241             :                        {
  198242             :                       // printf ("In SgUnknownArrayOrFunctionReference::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  198243           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  198244             :                        }
  198245             :                     pointerOfLinkedList = &(pointer[i]);
  198246             :                   }
  198247             :               }
  198248             :         }
  198249             : 
  198250           5 :      if ( pointerOfLinkedList != NULL )
  198251             :         {
  198252             :        // printf ("In SgUnknownArrayOrFunctionReference::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  198253           0 :           pointerOfLinkedList->set_freepointer(NULL);
  198254             :        // DQ (6/6/2010): Temporary debugging...
  198255             :        //   ROSE_ASSERT(false);
  198256             :         }
  198257             : 
  198258           5 :      return ;
  198259             :    }
  198260             : 
  198261             : //############################################################################
  198262             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  198263             :  * within the memory pool and resets the freepointers, in order to achieve a 
  198264             :  * linked list, that has no jumps and starts at the beginning! This function 
  198265             :  * does not extend the memory pool, since we do not delete any memory blocks,
  198266             :  * but delete the valid objects.  
  198267             :  */
  198268             : void
  198269           0 : SgUnknownArrayOrFunctionReference::clearMemoryPool( )
  198270             :    {
  198271             :   // printf ("Inside of SgUnknownArrayOrFunctionReference::clearMemoryPool() \n");
  198272             : 
  198273           0 :      SgUnknownArrayOrFunctionReference* pointer = NULL, *tempPointer = NULL;
  198274           0 :      std::vector < unsigned char* > :: const_iterator block;
  198275           0 :      if ( SgUnknownArrayOrFunctionReference::pools.empty() == false )
  198276             :         {
  198277           0 :           block = SgUnknownArrayOrFunctionReference::pools.begin() ;
  198278           0 :           SgUnknownArrayOrFunctionReference::next_node = (SgUnknownArrayOrFunctionReference*) (*block);
  198279             : 
  198280           0 :           while ( block != SgUnknownArrayOrFunctionReference::pools.end() )
  198281             :              {
  198282           0 :                pointer = (SgUnknownArrayOrFunctionReference*) (*block);
  198283           0 :                if ( tempPointer != NULL )
  198284             :                   {
  198285           0 :                     tempPointer->set_freepointer(pointer);
  198286             :                   }
  198287           0 :                for (unsigned i = 0; i < SgUnknownArrayOrFunctionReference::pool_size - 1; ++i)
  198288             :                   {
  198289           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  198290             :                   }
  198291           0 :                 pointer[SgUnknownArrayOrFunctionReference::pool_size-1].set_freepointer(NULL);
  198292           0 :                 tempPointer = &(pointer[SgUnknownArrayOrFunctionReference::pool_size-1]);
  198293           0 :                 ++block;
  198294             :              }
  198295             :         }
  198296           0 :    }
  198297             : 
  198298           5 : void SgUnknownArrayOrFunctionReference::deleteMemoryPool() {
  198299           5 :   for (auto p: SgUnknownArrayOrFunctionReference::pools) {
  198300           0 :     ROSE_FREE(p);
  198301             :   }
  198302           5 :   SgUnknownArrayOrFunctionReference::next_node = nullptr;
  198303           5 :   SgUnknownArrayOrFunctionReference::pools.clear();
  198304           5 : }
  198305             : 
  198306             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  198307             : //                 reading multiple binary files to for a single AST.
  198308             : /////////// new version ////////////////////////////////
  198309             : //############################################################################
  198310             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  198311             : void
  198312           2 : SgUnknownArrayOrFunctionReference::extendMemoryPoolForFileIO( )
  198313             :   {
  198314           2 :     size_t blockIndex = SgUnknownArrayOrFunctionReference::pools.size();
  198315           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgUnknownArrayOrFunctionReference) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnknownArrayOrFunctionReference);
  198316             : 
  198317           2 :     while ( (blockIndex * SgUnknownArrayOrFunctionReference::pool_size) < newPoolSize)
  198318             :       {
  198319             : #if ROSE_ALLOC_TRACE
  198320             :         if (blockIndex > 0) {
  198321             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgUnknownArrayOrFunctionReference) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnknownArrayOrFunctionReference) = %" PRIuPTR " SgUnknownArrayOrFunctionReference::pool_size = %d \n",
  198322             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgUnknownArrayOrFunctionReference),AST_FILE_IO::getPoolSizeOfNewAst(V_SgUnknownArrayOrFunctionReference),SgUnknownArrayOrFunctionReference::pool_size);
  198323             :         }
  198324             : #endif
  198325             : 
  198326           0 :         SgUnknownArrayOrFunctionReference * pointer = (SgUnknownArrayOrFunctionReference*) ROSE_MALLOC ( SgUnknownArrayOrFunctionReference::pool_size * sizeof(SgUnknownArrayOrFunctionReference) );
  198327           0 :         assert( pointer != NULL );
  198328             : #if ROSE_ALLOC_MEMSET == 1
  198329             :         memset(pointer, 0x00, SgUnknownArrayOrFunctionReference::pool_size * sizeof(SgUnknownArrayOrFunctionReference));
  198330             : #elif ROSE_ALLOC_MEMSET == 2
  198331             :         memset(pointer, 0xCC, SgUnknownArrayOrFunctionReference::pool_size * sizeof(SgUnknownArrayOrFunctionReference));
  198332             : #endif
  198333           0 :         SgUnknownArrayOrFunctionReference::pools.push_back( (unsigned char*)(pointer) );
  198334           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgUnknownArrayOrFunctionReference::pool_size * sizeof(SgUnknownArrayOrFunctionReference), V_SgUnknownArrayOrFunctionReference ) );
  198335             : 
  198336           0 :         if ( SgUnknownArrayOrFunctionReference::next_node != NULL ) {
  198337           0 :           if ( blockIndex > 0 ) {
  198338           0 :             SgUnknownArrayOrFunctionReference * blkptr = (SgUnknownArrayOrFunctionReference*)(SgUnknownArrayOrFunctionReference::pools[blockIndex-1]);
  198339           0 :             blkptr[ SgUnknownArrayOrFunctionReference::pool_size - 1 ].set_freepointer(pointer);
  198340             :           }
  198341             :         } else {
  198342           0 :           SgUnknownArrayOrFunctionReference::next_node = pointer;
  198343             :         }
  198344             : 
  198345           0 :         for (unsigned i = 0; i < SgUnknownArrayOrFunctionReference::pool_size-1; ++i)
  198346             :            {
  198347           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  198348             :            }
  198349           0 :         pointer[ SgUnknownArrayOrFunctionReference::pool_size -1 ].set_freepointer(NULL);
  198350             : 
  198351           0 :         blockIndex++;
  198352             :       }
  198353           2 :   }
  198354             : 
  198355             : //############################################################################
  198356             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  198357             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  198358             :  * not compressed. However, that stuff is not yet implemented! 
  198359             :  */
  198360             : unsigned long
  198361           0 : SgUnknownArrayOrFunctionReference::getNumberOfLastValidPointer()
  198362             :    {
  198363           0 :       SgUnknownArrayOrFunctionReference* testPointer = (SgUnknownArrayOrFunctionReference*)(SgUnknownArrayOrFunctionReference::pools.back());
  198364           0 :       unsigned long localIndex = SgUnknownArrayOrFunctionReference::pool_size - 1;
  198365           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  198366             :          {
  198367           0 :            localIndex--;
  198368             :          }
  198369           0 :       return (localIndex + SgUnknownArrayOrFunctionReference::pool_size * (SgUnknownArrayOrFunctionReference::pools.size()-1));
  198370             :    }
  198371             : 
  198372             : //############################################################################
  198373             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  198374             :  * memory pool and initializes the data member in class SgUnknownArrayOrFunctionReferenceStroageClass
  198375             :  * from its counterpart of SgUnknownArrayOrFunctionReference. The return value is just for checking, 
  198376             :  * that the whole StorageClassArray is initialized!
  198377             :  */
  198378             : unsigned long
  198379           0 : SgUnknownArrayOrFunctionReference::initializeStorageClassArray( SgUnknownArrayOrFunctionReferenceStorageClass *storageArray )
  198380             :    {
  198381           0 :      unsigned long storageCounter = 0;
  198382           0 :      std::vector < unsigned char* > :: const_iterator block = SgUnknownArrayOrFunctionReference::pools.begin();
  198383           0 :      SgUnknownArrayOrFunctionReference* pointer = NULL;
  198384           0 :      while ( block != SgUnknownArrayOrFunctionReference::pools.end() ) {
  198385           0 :           pointer = (SgUnknownArrayOrFunctionReference*) (*block);
  198386           0 :           for ( unsigned i = 0; i < SgUnknownArrayOrFunctionReference::pool_size; ++i ) {
  198387           0 :                if ( pointer->get_freepointer() != NULL ) {
  198388           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  198389           0 :                  storageArray++;
  198390           0 :                  storageCounter++;
  198391             :                }
  198392           0 :                pointer++;
  198393             :              }
  198394           0 :            block++;
  198395             :         }
  198396           0 :      return storageCounter;
  198397             :    }
  198398             : 
  198399             : /* #line 198400 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  198400             : 
  198401             : 
  198402             : 
  198403             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  198404             : 
  198405             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  198406             : 
  198407             : //############################################################################
  198408             : /* JH (02/02/2006) Constructor of the IR node SgPseudoDestructorRefExp that takes its 
  198409             :  * corresponding StorageClass as parameter
  198410             :  */
  198411           0 : SgPseudoDestructorRefExp :: SgPseudoDestructorRefExp ( const SgPseudoDestructorRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  198412             :    {
  198413             : 
  198414             : 
  198415             : /* #line 198416 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  198416             : 
  198417           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  198418           0 :      p_object_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_object_type) );
  198419           0 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  198420           0 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  198421           0 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  198422           0 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  198423             : 
  198424             : 
  198425             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  198426             : 
  198427             : 
  198428           0 :    }
  198429             : 
  198430             : //############################################################################
  198431             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  198432             :  * within the working AST. 
  198433             :  */
  198434           0 : SgPseudoDestructorRefExp * SgPseudoDestructorRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  198435           0 :      SgPseudoDestructorRefExp* returnPointer = NULL;
  198436           0 :      if ( globalIndex != 0 )
  198437             :         {
  198438             : 
  198439             : #if FILE_IO_EXTRA_CHECK
  198440           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgPseudoDestructorRefExp ) ) <= globalIndex ) ;
  198441           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPseudoDestructorRefExp + 1 ) ) );
  198442             : #endif
  198443           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgPseudoDestructorRefExp )  
  198444           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgPseudoDestructorRefExp );
  198445           0 :           unsigned long positionInPool = localIndex % SgPseudoDestructorRefExp::pool_size;
  198446           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPseudoDestructorRefExp::pool_size;
  198447             : 
  198448             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  198449             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  198450             : 
  198451           0 :           returnPointer = &( ( (SgPseudoDestructorRefExp*)(SgPseudoDestructorRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  198452             : 
  198453           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  198454             :         }
  198455           0 :      return returnPointer ;
  198456             :    }
  198457             : 
  198458             : //############################################################################
  198459             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  198460             :   for the AST with the index astIndex
  198461             : */
  198462           0 : SgPseudoDestructorRefExp * SgPseudoDestructorRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  198463           0 :      SgPseudoDestructorRefExp* returnPointer = NULL;
  198464           0 :      if ( globalIndex != 0 )
  198465             :         {
  198466             : 
  198467             : #if FILE_IO_EXTRA_CHECK
  198468           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgPseudoDestructorRefExp ) ) <= globalIndex ) ;
  198469           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPseudoDestructorRefExp + 1 ) ) );
  198470             : #endif
  198471           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgPseudoDestructorRefExp )
  198472           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgPseudoDestructorRefExp );
  198473           0 :           unsigned long positionInPool = localIndex % SgPseudoDestructorRefExp::pool_size ;
  198474           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgPseudoDestructorRefExp::pool_size ;
  198475             : 
  198476             : #if FILE_IO_EXTRA_CHECK
  198477             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  198478             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  198479             : #endif
  198480             : 
  198481           0 :           returnPointer = &( ( (SgPseudoDestructorRefExp*)(SgPseudoDestructorRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  198482             : 
  198483             : #if FILE_IO_EXTRA_CHECK
  198484           0 :           assert ( returnPointer != NULL ) ;
  198485             : #endif
  198486             :         }
  198487           0 :      return returnPointer ;
  198488             :    }
  198489             : 
  198490             : //############################################################################
  198491             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  198492             :  * pool size! We set for every valid object in the memory pool the freepointer
  198493             :  * to the global index and increase the global index afterwards. For all the 
  198494             :  * invalid objects (means address ranges within the memory pool that were not
  198495             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  198496             :  * distinguish valid from invalid objects! 
  198497             :  */
  198498             : unsigned long
  198499           5 : SgPseudoDestructorRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  198500             :    {
  198501           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  198502           5 :      SgPseudoDestructorRefExp* pointer = NULL;
  198503           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  198504           5 :      std::vector < unsigned char* > :: const_iterator block;
  198505           5 :      for ( block = SgPseudoDestructorRefExp::pools.begin(); block != SgPseudoDestructorRefExp::pools.end() ; ++block )
  198506             :         {
  198507           0 :           pointer = (SgPseudoDestructorRefExp*)(*block);
  198508           0 :           for (unsigned i = 0; i < SgPseudoDestructorRefExp::pool_size; ++i )
  198509             :              {
  198510             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  198511             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  198512             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  198513             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  198514             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  198515             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  198516             :             // properly; so this will have to be checked next.
  198517             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  198518             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  198519           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  198520             :                   {
  198521           0 :                     pointer[i].set_freepointer((SgPseudoDestructorRefExp*)(globalIndex));
  198522           0 :                     globalIndex++;
  198523             :                   }
  198524             :                else
  198525             :                   {
  198526           0 :                     pointer[i].set_freepointer(NULL);
  198527             :                   }
  198528             :               }
  198529             :         }
  198530           5 :      return globalIndex;
  198531             :    }
  198532             : 
  198533             : //############################################################################
  198534             : // JH (01/14/2006)
  198535             : void
  198536           5 : SgPseudoDestructorRefExp::resetValidFreepointers( )
  198537             :    {
  198538           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  198539           5 :      SgPseudoDestructorRefExp* pointer = NULL;
  198540           5 :      std::vector < unsigned char* > :: const_iterator block;
  198541           5 :      SgPseudoDestructorRefExp* pointerOfLinkedList = NULL;
  198542           5 :      for ( block = SgPseudoDestructorRefExp::pools.begin(); block != SgPseudoDestructorRefExp::pools.end() ; ++block )
  198543             :         {
  198544           0 :           pointer = (SgPseudoDestructorRefExp*)(*block);
  198545           0 :           for (unsigned i = 0; i < SgPseudoDestructorRefExp::pool_size; ++i )
  198546             :              {
  198547             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  198548             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  198549             :             // memory blocks!.
  198550           0 :                if ( pointer[i].get_freepointer() != NULL )
  198551             :                   {
  198552           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  198553             :                   }
  198554             :                else
  198555             :                   {
  198556           0 :                     if ( pointerOfLinkedList == NULL )
  198557             :                        {
  198558           0 :                          SgPseudoDestructorRefExp::next_node = &(pointer[i]);
  198559             :                        }
  198560             :                     else
  198561             :                        {
  198562             :                       // printf ("In SgPseudoDestructorRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  198563           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  198564             :                        }
  198565             :                     pointerOfLinkedList = &(pointer[i]);
  198566             :                   }
  198567             :               }
  198568             :         }
  198569             : 
  198570           5 :      if ( pointerOfLinkedList != NULL )
  198571             :         {
  198572             :        // printf ("In SgPseudoDestructorRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  198573           0 :           pointerOfLinkedList->set_freepointer(NULL);
  198574             :        // DQ (6/6/2010): Temporary debugging...
  198575             :        //   ROSE_ASSERT(false);
  198576             :         }
  198577             : 
  198578           5 :      return ;
  198579             :    }
  198580             : 
  198581             : //############################################################################
  198582             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  198583             :  * within the memory pool and resets the freepointers, in order to achieve a 
  198584             :  * linked list, that has no jumps and starts at the beginning! This function 
  198585             :  * does not extend the memory pool, since we do not delete any memory blocks,
  198586             :  * but delete the valid objects.  
  198587             :  */
  198588             : void
  198589           0 : SgPseudoDestructorRefExp::clearMemoryPool( )
  198590             :    {
  198591             :   // printf ("Inside of SgPseudoDestructorRefExp::clearMemoryPool() \n");
  198592             : 
  198593           0 :      SgPseudoDestructorRefExp* pointer = NULL, *tempPointer = NULL;
  198594           0 :      std::vector < unsigned char* > :: const_iterator block;
  198595           0 :      if ( SgPseudoDestructorRefExp::pools.empty() == false )
  198596             :         {
  198597           0 :           block = SgPseudoDestructorRefExp::pools.begin() ;
  198598           0 :           SgPseudoDestructorRefExp::next_node = (SgPseudoDestructorRefExp*) (*block);
  198599             : 
  198600           0 :           while ( block != SgPseudoDestructorRefExp::pools.end() )
  198601             :              {
  198602           0 :                pointer = (SgPseudoDestructorRefExp*) (*block);
  198603           0 :                if ( tempPointer != NULL )
  198604             :                   {
  198605           0 :                     tempPointer->set_freepointer(pointer);
  198606             :                   }
  198607           0 :                for (unsigned i = 0; i < SgPseudoDestructorRefExp::pool_size - 1; ++i)
  198608             :                   {
  198609           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  198610             :                   }
  198611           0 :                 pointer[SgPseudoDestructorRefExp::pool_size-1].set_freepointer(NULL);
  198612           0 :                 tempPointer = &(pointer[SgPseudoDestructorRefExp::pool_size-1]);
  198613           0 :                 ++block;
  198614             :              }
  198615             :         }
  198616           0 :    }
  198617             : 
  198618           5 : void SgPseudoDestructorRefExp::deleteMemoryPool() {
  198619           5 :   for (auto p: SgPseudoDestructorRefExp::pools) {
  198620           0 :     ROSE_FREE(p);
  198621             :   }
  198622           5 :   SgPseudoDestructorRefExp::next_node = nullptr;
  198623           5 :   SgPseudoDestructorRefExp::pools.clear();
  198624           5 : }
  198625             : 
  198626             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  198627             : //                 reading multiple binary files to for a single AST.
  198628             : /////////// new version ////////////////////////////////
  198629             : //############################################################################
  198630             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  198631             : void
  198632           2 : SgPseudoDestructorRefExp::extendMemoryPoolForFileIO( )
  198633             :   {
  198634           2 :     size_t blockIndex = SgPseudoDestructorRefExp::pools.size();
  198635           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgPseudoDestructorRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgPseudoDestructorRefExp);
  198636             : 
  198637           2 :     while ( (blockIndex * SgPseudoDestructorRefExp::pool_size) < newPoolSize)
  198638             :       {
  198639             : #if ROSE_ALLOC_TRACE
  198640             :         if (blockIndex > 0) {
  198641             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgPseudoDestructorRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgPseudoDestructorRefExp) = %" PRIuPTR " SgPseudoDestructorRefExp::pool_size = %d \n",
  198642             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgPseudoDestructorRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgPseudoDestructorRefExp),SgPseudoDestructorRefExp::pool_size);
  198643             :         }
  198644             : #endif
  198645             : 
  198646           0 :         SgPseudoDestructorRefExp * pointer = (SgPseudoDestructorRefExp*) ROSE_MALLOC ( SgPseudoDestructorRefExp::pool_size * sizeof(SgPseudoDestructorRefExp) );
  198647           0 :         assert( pointer != NULL );
  198648             : #if ROSE_ALLOC_MEMSET == 1
  198649             :         memset(pointer, 0x00, SgPseudoDestructorRefExp::pool_size * sizeof(SgPseudoDestructorRefExp));
  198650             : #elif ROSE_ALLOC_MEMSET == 2
  198651             :         memset(pointer, 0xCC, SgPseudoDestructorRefExp::pool_size * sizeof(SgPseudoDestructorRefExp));
  198652             : #endif
  198653           0 :         SgPseudoDestructorRefExp::pools.push_back( (unsigned char*)(pointer) );
  198654           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgPseudoDestructorRefExp::pool_size * sizeof(SgPseudoDestructorRefExp), V_SgPseudoDestructorRefExp ) );
  198655             : 
  198656           0 :         if ( SgPseudoDestructorRefExp::next_node != NULL ) {
  198657           0 :           if ( blockIndex > 0 ) {
  198658           0 :             SgPseudoDestructorRefExp * blkptr = (SgPseudoDestructorRefExp*)(SgPseudoDestructorRefExp::pools[blockIndex-1]);
  198659           0 :             blkptr[ SgPseudoDestructorRefExp::pool_size - 1 ].set_freepointer(pointer);
  198660             :           }
  198661             :         } else {
  198662           0 :           SgPseudoDestructorRefExp::next_node = pointer;
  198663             :         }
  198664             : 
  198665           0 :         for (unsigned i = 0; i < SgPseudoDestructorRefExp::pool_size-1; ++i)
  198666             :            {
  198667           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  198668             :            }
  198669           0 :         pointer[ SgPseudoDestructorRefExp::pool_size -1 ].set_freepointer(NULL);
  198670             : 
  198671           0 :         blockIndex++;
  198672             :       }
  198673           2 :   }
  198674             : 
  198675             : //############################################################################
  198676             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  198677             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  198678             :  * not compressed. However, that stuff is not yet implemented! 
  198679             :  */
  198680             : unsigned long
  198681           0 : SgPseudoDestructorRefExp::getNumberOfLastValidPointer()
  198682             :    {
  198683           0 :       SgPseudoDestructorRefExp* testPointer = (SgPseudoDestructorRefExp*)(SgPseudoDestructorRefExp::pools.back());
  198684           0 :       unsigned long localIndex = SgPseudoDestructorRefExp::pool_size - 1;
  198685           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  198686             :          {
  198687           0 :            localIndex--;
  198688             :          }
  198689           0 :       return (localIndex + SgPseudoDestructorRefExp::pool_size * (SgPseudoDestructorRefExp::pools.size()-1));
  198690             :    }
  198691             : 
  198692             : //############################################################################
  198693             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  198694             :  * memory pool and initializes the data member in class SgPseudoDestructorRefExpStroageClass
  198695             :  * from its counterpart of SgPseudoDestructorRefExp. The return value is just for checking, 
  198696             :  * that the whole StorageClassArray is initialized!
  198697             :  */
  198698             : unsigned long
  198699           0 : SgPseudoDestructorRefExp::initializeStorageClassArray( SgPseudoDestructorRefExpStorageClass *storageArray )
  198700             :    {
  198701           0 :      unsigned long storageCounter = 0;
  198702           0 :      std::vector < unsigned char* > :: const_iterator block = SgPseudoDestructorRefExp::pools.begin();
  198703           0 :      SgPseudoDestructorRefExp* pointer = NULL;
  198704           0 :      while ( block != SgPseudoDestructorRefExp::pools.end() ) {
  198705           0 :           pointer = (SgPseudoDestructorRefExp*) (*block);
  198706           0 :           for ( unsigned i = 0; i < SgPseudoDestructorRefExp::pool_size; ++i ) {
  198707           0 :                if ( pointer->get_freepointer() != NULL ) {
  198708           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  198709           0 :                  storageArray++;
  198710           0 :                  storageCounter++;
  198711             :                }
  198712           0 :                pointer++;
  198713             :              }
  198714           0 :            block++;
  198715             :         }
  198716           0 :      return storageCounter;
  198717             :    }
  198718             : 
  198719             : /* #line 198720 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  198720             : 
  198721             : 
  198722             : 
  198723             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  198724             : 
  198725             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  198726             : 
  198727             : //############################################################################
  198728             : /* JH (02/02/2006) Constructor of the IR node SgCAFCoExpression that takes its 
  198729             :  * corresponding StorageClass as parameter
  198730             :  */
  198731           0 : SgCAFCoExpression :: SgCAFCoExpression ( const SgCAFCoExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  198732             :    {
  198733             : 
  198734             : 
  198735             : /* #line 198736 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  198736             : 
  198737           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  198738           0 :      p_teamId =  (SgVarRefExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_teamId) );
  198739           0 :      p_teamRank =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_teamRank) );
  198740           0 :      p_referData =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_referData) );
  198741             : 
  198742             : 
  198743             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  198744             : 
  198745             : 
  198746           0 :    }
  198747             : 
  198748             : //############################################################################
  198749             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  198750             :  * within the working AST. 
  198751             :  */
  198752           0 : SgCAFCoExpression * SgCAFCoExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  198753           0 :      SgCAFCoExpression* returnPointer = NULL;
  198754           0 :      if ( globalIndex != 0 )
  198755             :         {
  198756             : 
  198757             : #if FILE_IO_EXTRA_CHECK
  198758           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCAFCoExpression ) ) <= globalIndex ) ;
  198759           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCAFCoExpression + 1 ) ) );
  198760             : #endif
  198761           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCAFCoExpression )  
  198762           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCAFCoExpression );
  198763           0 :           unsigned long positionInPool = localIndex % SgCAFCoExpression::pool_size;
  198764           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCAFCoExpression::pool_size;
  198765             : 
  198766             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  198767             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  198768             : 
  198769           0 :           returnPointer = &( ( (SgCAFCoExpression*)(SgCAFCoExpression::pools[memoryBlock]) ) [positionInPool]) ;
  198770             : 
  198771           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  198772             :         }
  198773           0 :      return returnPointer ;
  198774             :    }
  198775             : 
  198776             : //############################################################################
  198777             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  198778             :   for the AST with the index astIndex
  198779             : */
  198780           0 : SgCAFCoExpression * SgCAFCoExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  198781           0 :      SgCAFCoExpression* returnPointer = NULL;
  198782           0 :      if ( globalIndex != 0 )
  198783             :         {
  198784             : 
  198785             : #if FILE_IO_EXTRA_CHECK
  198786           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCAFCoExpression ) ) <= globalIndex ) ;
  198787           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCAFCoExpression + 1 ) ) );
  198788             : #endif
  198789           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCAFCoExpression )
  198790           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCAFCoExpression );
  198791           0 :           unsigned long positionInPool = localIndex % SgCAFCoExpression::pool_size ;
  198792           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCAFCoExpression::pool_size ;
  198793             : 
  198794             : #if FILE_IO_EXTRA_CHECK
  198795             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  198796             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  198797             : #endif
  198798             : 
  198799           0 :           returnPointer = &( ( (SgCAFCoExpression*)(SgCAFCoExpression::pools[memoryBlock]) ) [positionInPool]) ;
  198800             : 
  198801             : #if FILE_IO_EXTRA_CHECK
  198802           0 :           assert ( returnPointer != NULL ) ;
  198803             : #endif
  198804             :         }
  198805           0 :      return returnPointer ;
  198806             :    }
  198807             : 
  198808             : //############################################################################
  198809             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  198810             :  * pool size! We set for every valid object in the memory pool the freepointer
  198811             :  * to the global index and increase the global index afterwards. For all the 
  198812             :  * invalid objects (means address ranges within the memory pool that were not
  198813             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  198814             :  * distinguish valid from invalid objects! 
  198815             :  */
  198816             : unsigned long
  198817           5 : SgCAFCoExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  198818             :    {
  198819           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  198820           5 :      SgCAFCoExpression* pointer = NULL;
  198821           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  198822           5 :      std::vector < unsigned char* > :: const_iterator block;
  198823           5 :      for ( block = SgCAFCoExpression::pools.begin(); block != SgCAFCoExpression::pools.end() ; ++block )
  198824             :         {
  198825           0 :           pointer = (SgCAFCoExpression*)(*block);
  198826           0 :           for (unsigned i = 0; i < SgCAFCoExpression::pool_size; ++i )
  198827             :              {
  198828             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  198829             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  198830             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  198831             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  198832             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  198833             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  198834             :             // properly; so this will have to be checked next.
  198835             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  198836             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  198837           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  198838             :                   {
  198839           0 :                     pointer[i].set_freepointer((SgCAFCoExpression*)(globalIndex));
  198840           0 :                     globalIndex++;
  198841             :                   }
  198842             :                else
  198843             :                   {
  198844           0 :                     pointer[i].set_freepointer(NULL);
  198845             :                   }
  198846             :               }
  198847             :         }
  198848           5 :      return globalIndex;
  198849             :    }
  198850             : 
  198851             : //############################################################################
  198852             : // JH (01/14/2006)
  198853             : void
  198854           5 : SgCAFCoExpression::resetValidFreepointers( )
  198855             :    {
  198856           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  198857           5 :      SgCAFCoExpression* pointer = NULL;
  198858           5 :      std::vector < unsigned char* > :: const_iterator block;
  198859           5 :      SgCAFCoExpression* pointerOfLinkedList = NULL;
  198860           5 :      for ( block = SgCAFCoExpression::pools.begin(); block != SgCAFCoExpression::pools.end() ; ++block )
  198861             :         {
  198862           0 :           pointer = (SgCAFCoExpression*)(*block);
  198863           0 :           for (unsigned i = 0; i < SgCAFCoExpression::pool_size; ++i )
  198864             :              {
  198865             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  198866             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  198867             :             // memory blocks!.
  198868           0 :                if ( pointer[i].get_freepointer() != NULL )
  198869             :                   {
  198870           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  198871             :                   }
  198872             :                else
  198873             :                   {
  198874           0 :                     if ( pointerOfLinkedList == NULL )
  198875             :                        {
  198876           0 :                          SgCAFCoExpression::next_node = &(pointer[i]);
  198877             :                        }
  198878             :                     else
  198879             :                        {
  198880             :                       // printf ("In SgCAFCoExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  198881           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  198882             :                        }
  198883             :                     pointerOfLinkedList = &(pointer[i]);
  198884             :                   }
  198885             :               }
  198886             :         }
  198887             : 
  198888           5 :      if ( pointerOfLinkedList != NULL )
  198889             :         {
  198890             :        // printf ("In SgCAFCoExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  198891           0 :           pointerOfLinkedList->set_freepointer(NULL);
  198892             :        // DQ (6/6/2010): Temporary debugging...
  198893             :        //   ROSE_ASSERT(false);
  198894             :         }
  198895             : 
  198896           5 :      return ;
  198897             :    }
  198898             : 
  198899             : //############################################################################
  198900             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  198901             :  * within the memory pool and resets the freepointers, in order to achieve a 
  198902             :  * linked list, that has no jumps and starts at the beginning! This function 
  198903             :  * does not extend the memory pool, since we do not delete any memory blocks,
  198904             :  * but delete the valid objects.  
  198905             :  */
  198906             : void
  198907           0 : SgCAFCoExpression::clearMemoryPool( )
  198908             :    {
  198909             :   // printf ("Inside of SgCAFCoExpression::clearMemoryPool() \n");
  198910             : 
  198911           0 :      SgCAFCoExpression* pointer = NULL, *tempPointer = NULL;
  198912           0 :      std::vector < unsigned char* > :: const_iterator block;
  198913           0 :      if ( SgCAFCoExpression::pools.empty() == false )
  198914             :         {
  198915           0 :           block = SgCAFCoExpression::pools.begin() ;
  198916           0 :           SgCAFCoExpression::next_node = (SgCAFCoExpression*) (*block);
  198917             : 
  198918           0 :           while ( block != SgCAFCoExpression::pools.end() )
  198919             :              {
  198920           0 :                pointer = (SgCAFCoExpression*) (*block);
  198921           0 :                if ( tempPointer != NULL )
  198922             :                   {
  198923           0 :                     tempPointer->set_freepointer(pointer);
  198924             :                   }
  198925           0 :                for (unsigned i = 0; i < SgCAFCoExpression::pool_size - 1; ++i)
  198926             :                   {
  198927           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  198928             :                   }
  198929           0 :                 pointer[SgCAFCoExpression::pool_size-1].set_freepointer(NULL);
  198930           0 :                 tempPointer = &(pointer[SgCAFCoExpression::pool_size-1]);
  198931           0 :                 ++block;
  198932             :              }
  198933             :         }
  198934           0 :    }
  198935             : 
  198936           5 : void SgCAFCoExpression::deleteMemoryPool() {
  198937           5 :   for (auto p: SgCAFCoExpression::pools) {
  198938           0 :     ROSE_FREE(p);
  198939             :   }
  198940           5 :   SgCAFCoExpression::next_node = nullptr;
  198941           5 :   SgCAFCoExpression::pools.clear();
  198942           5 : }
  198943             : 
  198944             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  198945             : //                 reading multiple binary files to for a single AST.
  198946             : /////////// new version ////////////////////////////////
  198947             : //############################################################################
  198948             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  198949             : void
  198950           2 : SgCAFCoExpression::extendMemoryPoolForFileIO( )
  198951             :   {
  198952           2 :     size_t blockIndex = SgCAFCoExpression::pools.size();
  198953           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCAFCoExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCAFCoExpression);
  198954             : 
  198955           2 :     while ( (blockIndex * SgCAFCoExpression::pool_size) < newPoolSize)
  198956             :       {
  198957             : #if ROSE_ALLOC_TRACE
  198958             :         if (blockIndex > 0) {
  198959             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCAFCoExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCAFCoExpression) = %" PRIuPTR " SgCAFCoExpression::pool_size = %d \n",
  198960             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCAFCoExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCAFCoExpression),SgCAFCoExpression::pool_size);
  198961             :         }
  198962             : #endif
  198963             : 
  198964           0 :         SgCAFCoExpression * pointer = (SgCAFCoExpression*) ROSE_MALLOC ( SgCAFCoExpression::pool_size * sizeof(SgCAFCoExpression) );
  198965           0 :         assert( pointer != NULL );
  198966             : #if ROSE_ALLOC_MEMSET == 1
  198967             :         memset(pointer, 0x00, SgCAFCoExpression::pool_size * sizeof(SgCAFCoExpression));
  198968             : #elif ROSE_ALLOC_MEMSET == 2
  198969             :         memset(pointer, 0xCC, SgCAFCoExpression::pool_size * sizeof(SgCAFCoExpression));
  198970             : #endif
  198971           0 :         SgCAFCoExpression::pools.push_back( (unsigned char*)(pointer) );
  198972           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCAFCoExpression::pool_size * sizeof(SgCAFCoExpression), V_SgCAFCoExpression ) );
  198973             : 
  198974           0 :         if ( SgCAFCoExpression::next_node != NULL ) {
  198975           0 :           if ( blockIndex > 0 ) {
  198976           0 :             SgCAFCoExpression * blkptr = (SgCAFCoExpression*)(SgCAFCoExpression::pools[blockIndex-1]);
  198977           0 :             blkptr[ SgCAFCoExpression::pool_size - 1 ].set_freepointer(pointer);
  198978             :           }
  198979             :         } else {
  198980           0 :           SgCAFCoExpression::next_node = pointer;
  198981             :         }
  198982             : 
  198983           0 :         for (unsigned i = 0; i < SgCAFCoExpression::pool_size-1; ++i)
  198984             :            {
  198985           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  198986             :            }
  198987           0 :         pointer[ SgCAFCoExpression::pool_size -1 ].set_freepointer(NULL);
  198988             : 
  198989           0 :         blockIndex++;
  198990             :       }
  198991           2 :   }
  198992             : 
  198993             : //############################################################################
  198994             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  198995             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  198996             :  * not compressed. However, that stuff is not yet implemented! 
  198997             :  */
  198998             : unsigned long
  198999           0 : SgCAFCoExpression::getNumberOfLastValidPointer()
  199000             :    {
  199001           0 :       SgCAFCoExpression* testPointer = (SgCAFCoExpression*)(SgCAFCoExpression::pools.back());
  199002           0 :       unsigned long localIndex = SgCAFCoExpression::pool_size - 1;
  199003           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  199004             :          {
  199005           0 :            localIndex--;
  199006             :          }
  199007           0 :       return (localIndex + SgCAFCoExpression::pool_size * (SgCAFCoExpression::pools.size()-1));
  199008             :    }
  199009             : 
  199010             : //############################################################################
  199011             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  199012             :  * memory pool and initializes the data member in class SgCAFCoExpressionStroageClass
  199013             :  * from its counterpart of SgCAFCoExpression. The return value is just for checking, 
  199014             :  * that the whole StorageClassArray is initialized!
  199015             :  */
  199016             : unsigned long
  199017           0 : SgCAFCoExpression::initializeStorageClassArray( SgCAFCoExpressionStorageClass *storageArray )
  199018             :    {
  199019           0 :      unsigned long storageCounter = 0;
  199020           0 :      std::vector < unsigned char* > :: const_iterator block = SgCAFCoExpression::pools.begin();
  199021           0 :      SgCAFCoExpression* pointer = NULL;
  199022           0 :      while ( block != SgCAFCoExpression::pools.end() ) {
  199023           0 :           pointer = (SgCAFCoExpression*) (*block);
  199024           0 :           for ( unsigned i = 0; i < SgCAFCoExpression::pool_size; ++i ) {
  199025           0 :                if ( pointer->get_freepointer() != NULL ) {
  199026           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  199027           0 :                  storageArray++;
  199028           0 :                  storageCounter++;
  199029             :                }
  199030           0 :                pointer++;
  199031             :              }
  199032           0 :            block++;
  199033             :         }
  199034           0 :      return storageCounter;
  199035             :    }
  199036             : 
  199037             : /* #line 199038 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  199038             : 
  199039             : 
  199040             : 
  199041             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  199042             : 
  199043             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  199044             : 
  199045             : //############################################################################
  199046             : /* JH (02/02/2006) Constructor of the IR node SgCudaKernelExecConfig that takes its 
  199047             :  * corresponding StorageClass as parameter
  199048             :  */
  199049           0 : SgCudaKernelExecConfig :: SgCudaKernelExecConfig ( const SgCudaKernelExecConfigStorageClass& storageSource )   : SgExpression (storageSource)
  199050             :    {
  199051             : 
  199052             : 
  199053             : /* #line 199054 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  199054             : 
  199055           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  199056           0 :      p_grid =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_grid) );
  199057           0 :      p_blocks =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_blocks) );
  199058           0 :      p_shared =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_shared) );
  199059           0 :      p_stream =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_stream) );
  199060             : 
  199061             : 
  199062             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  199063             : 
  199064             : 
  199065           0 :    }
  199066             : 
  199067             : //############################################################################
  199068             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  199069             :  * within the working AST. 
  199070             :  */
  199071           0 : SgCudaKernelExecConfig * SgCudaKernelExecConfig::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  199072           0 :      SgCudaKernelExecConfig* returnPointer = NULL;
  199073           0 :      if ( globalIndex != 0 )
  199074             :         {
  199075             : 
  199076             : #if FILE_IO_EXTRA_CHECK
  199077           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCudaKernelExecConfig ) ) <= globalIndex ) ;
  199078           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCudaKernelExecConfig + 1 ) ) );
  199079             : #endif
  199080           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCudaKernelExecConfig )  
  199081           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCudaKernelExecConfig );
  199082           0 :           unsigned long positionInPool = localIndex % SgCudaKernelExecConfig::pool_size;
  199083           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCudaKernelExecConfig::pool_size;
  199084             : 
  199085             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  199086             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  199087             : 
  199088           0 :           returnPointer = &( ( (SgCudaKernelExecConfig*)(SgCudaKernelExecConfig::pools[memoryBlock]) ) [positionInPool]) ;
  199089             : 
  199090           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  199091             :         }
  199092           0 :      return returnPointer ;
  199093             :    }
  199094             : 
  199095             : //############################################################################
  199096             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  199097             :   for the AST with the index astIndex
  199098             : */
  199099           0 : SgCudaKernelExecConfig * SgCudaKernelExecConfig::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  199100           0 :      SgCudaKernelExecConfig* returnPointer = NULL;
  199101           0 :      if ( globalIndex != 0 )
  199102             :         {
  199103             : 
  199104             : #if FILE_IO_EXTRA_CHECK
  199105           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCudaKernelExecConfig ) ) <= globalIndex ) ;
  199106           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCudaKernelExecConfig + 1 ) ) );
  199107             : #endif
  199108           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCudaKernelExecConfig )
  199109           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCudaKernelExecConfig );
  199110           0 :           unsigned long positionInPool = localIndex % SgCudaKernelExecConfig::pool_size ;
  199111           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCudaKernelExecConfig::pool_size ;
  199112             : 
  199113             : #if FILE_IO_EXTRA_CHECK
  199114             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  199115             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  199116             : #endif
  199117             : 
  199118           0 :           returnPointer = &( ( (SgCudaKernelExecConfig*)(SgCudaKernelExecConfig::pools[memoryBlock]) ) [positionInPool]) ;
  199119             : 
  199120             : #if FILE_IO_EXTRA_CHECK
  199121           0 :           assert ( returnPointer != NULL ) ;
  199122             : #endif
  199123             :         }
  199124           0 :      return returnPointer ;
  199125             :    }
  199126             : 
  199127             : //############################################################################
  199128             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  199129             :  * pool size! We set for every valid object in the memory pool the freepointer
  199130             :  * to the global index and increase the global index afterwards. For all the 
  199131             :  * invalid objects (means address ranges within the memory pool that were not
  199132             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  199133             :  * distinguish valid from invalid objects! 
  199134             :  */
  199135             : unsigned long
  199136           5 : SgCudaKernelExecConfig::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  199137             :    {
  199138           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  199139           5 :      SgCudaKernelExecConfig* pointer = NULL;
  199140           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  199141           5 :      std::vector < unsigned char* > :: const_iterator block;
  199142           5 :      for ( block = SgCudaKernelExecConfig::pools.begin(); block != SgCudaKernelExecConfig::pools.end() ; ++block )
  199143             :         {
  199144           0 :           pointer = (SgCudaKernelExecConfig*)(*block);
  199145           0 :           for (unsigned i = 0; i < SgCudaKernelExecConfig::pool_size; ++i )
  199146             :              {
  199147             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  199148             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  199149             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  199150             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  199151             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  199152             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  199153             :             // properly; so this will have to be checked next.
  199154             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  199155             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  199156           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  199157             :                   {
  199158           0 :                     pointer[i].set_freepointer((SgCudaKernelExecConfig*)(globalIndex));
  199159           0 :                     globalIndex++;
  199160             :                   }
  199161             :                else
  199162             :                   {
  199163           0 :                     pointer[i].set_freepointer(NULL);
  199164             :                   }
  199165             :               }
  199166             :         }
  199167           5 :      return globalIndex;
  199168             :    }
  199169             : 
  199170             : //############################################################################
  199171             : // JH (01/14/2006)
  199172             : void
  199173           5 : SgCudaKernelExecConfig::resetValidFreepointers( )
  199174             :    {
  199175           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  199176           5 :      SgCudaKernelExecConfig* pointer = NULL;
  199177           5 :      std::vector < unsigned char* > :: const_iterator block;
  199178           5 :      SgCudaKernelExecConfig* pointerOfLinkedList = NULL;
  199179           5 :      for ( block = SgCudaKernelExecConfig::pools.begin(); block != SgCudaKernelExecConfig::pools.end() ; ++block )
  199180             :         {
  199181           0 :           pointer = (SgCudaKernelExecConfig*)(*block);
  199182           0 :           for (unsigned i = 0; i < SgCudaKernelExecConfig::pool_size; ++i )
  199183             :              {
  199184             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  199185             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  199186             :             // memory blocks!.
  199187           0 :                if ( pointer[i].get_freepointer() != NULL )
  199188             :                   {
  199189           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  199190             :                   }
  199191             :                else
  199192             :                   {
  199193           0 :                     if ( pointerOfLinkedList == NULL )
  199194             :                        {
  199195           0 :                          SgCudaKernelExecConfig::next_node = &(pointer[i]);
  199196             :                        }
  199197             :                     else
  199198             :                        {
  199199             :                       // printf ("In SgCudaKernelExecConfig::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  199200           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  199201             :                        }
  199202             :                     pointerOfLinkedList = &(pointer[i]);
  199203             :                   }
  199204             :               }
  199205             :         }
  199206             : 
  199207           5 :      if ( pointerOfLinkedList != NULL )
  199208             :         {
  199209             :        // printf ("In SgCudaKernelExecConfig::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  199210           0 :           pointerOfLinkedList->set_freepointer(NULL);
  199211             :        // DQ (6/6/2010): Temporary debugging...
  199212             :        //   ROSE_ASSERT(false);
  199213             :         }
  199214             : 
  199215           5 :      return ;
  199216             :    }
  199217             : 
  199218             : //############################################################################
  199219             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  199220             :  * within the memory pool and resets the freepointers, in order to achieve a 
  199221             :  * linked list, that has no jumps and starts at the beginning! This function 
  199222             :  * does not extend the memory pool, since we do not delete any memory blocks,
  199223             :  * but delete the valid objects.  
  199224             :  */
  199225             : void
  199226           0 : SgCudaKernelExecConfig::clearMemoryPool( )
  199227             :    {
  199228             :   // printf ("Inside of SgCudaKernelExecConfig::clearMemoryPool() \n");
  199229             : 
  199230           0 :      SgCudaKernelExecConfig* pointer = NULL, *tempPointer = NULL;
  199231           0 :      std::vector < unsigned char* > :: const_iterator block;
  199232           0 :      if ( SgCudaKernelExecConfig::pools.empty() == false )
  199233             :         {
  199234           0 :           block = SgCudaKernelExecConfig::pools.begin() ;
  199235           0 :           SgCudaKernelExecConfig::next_node = (SgCudaKernelExecConfig*) (*block);
  199236             : 
  199237           0 :           while ( block != SgCudaKernelExecConfig::pools.end() )
  199238             :              {
  199239           0 :                pointer = (SgCudaKernelExecConfig*) (*block);
  199240           0 :                if ( tempPointer != NULL )
  199241             :                   {
  199242           0 :                     tempPointer->set_freepointer(pointer);
  199243             :                   }
  199244           0 :                for (unsigned i = 0; i < SgCudaKernelExecConfig::pool_size - 1; ++i)
  199245             :                   {
  199246           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  199247             :                   }
  199248           0 :                 pointer[SgCudaKernelExecConfig::pool_size-1].set_freepointer(NULL);
  199249           0 :                 tempPointer = &(pointer[SgCudaKernelExecConfig::pool_size-1]);
  199250           0 :                 ++block;
  199251             :              }
  199252             :         }
  199253           0 :    }
  199254             : 
  199255           5 : void SgCudaKernelExecConfig::deleteMemoryPool() {
  199256           5 :   for (auto p: SgCudaKernelExecConfig::pools) {
  199257           0 :     ROSE_FREE(p);
  199258             :   }
  199259           5 :   SgCudaKernelExecConfig::next_node = nullptr;
  199260           5 :   SgCudaKernelExecConfig::pools.clear();
  199261           5 : }
  199262             : 
  199263             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  199264             : //                 reading multiple binary files to for a single AST.
  199265             : /////////// new version ////////////////////////////////
  199266             : //############################################################################
  199267             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  199268             : void
  199269           2 : SgCudaKernelExecConfig::extendMemoryPoolForFileIO( )
  199270             :   {
  199271           2 :     size_t blockIndex = SgCudaKernelExecConfig::pools.size();
  199272           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCudaKernelExecConfig) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCudaKernelExecConfig);
  199273             : 
  199274           2 :     while ( (blockIndex * SgCudaKernelExecConfig::pool_size) < newPoolSize)
  199275             :       {
  199276             : #if ROSE_ALLOC_TRACE
  199277             :         if (blockIndex > 0) {
  199278             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCudaKernelExecConfig) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCudaKernelExecConfig) = %" PRIuPTR " SgCudaKernelExecConfig::pool_size = %d \n",
  199279             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCudaKernelExecConfig),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCudaKernelExecConfig),SgCudaKernelExecConfig::pool_size);
  199280             :         }
  199281             : #endif
  199282             : 
  199283           0 :         SgCudaKernelExecConfig * pointer = (SgCudaKernelExecConfig*) ROSE_MALLOC ( SgCudaKernelExecConfig::pool_size * sizeof(SgCudaKernelExecConfig) );
  199284           0 :         assert( pointer != NULL );
  199285             : #if ROSE_ALLOC_MEMSET == 1
  199286             :         memset(pointer, 0x00, SgCudaKernelExecConfig::pool_size * sizeof(SgCudaKernelExecConfig));
  199287             : #elif ROSE_ALLOC_MEMSET == 2
  199288             :         memset(pointer, 0xCC, SgCudaKernelExecConfig::pool_size * sizeof(SgCudaKernelExecConfig));
  199289             : #endif
  199290           0 :         SgCudaKernelExecConfig::pools.push_back( (unsigned char*)(pointer) );
  199291           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCudaKernelExecConfig::pool_size * sizeof(SgCudaKernelExecConfig), V_SgCudaKernelExecConfig ) );
  199292             : 
  199293           0 :         if ( SgCudaKernelExecConfig::next_node != NULL ) {
  199294           0 :           if ( blockIndex > 0 ) {
  199295           0 :             SgCudaKernelExecConfig * blkptr = (SgCudaKernelExecConfig*)(SgCudaKernelExecConfig::pools[blockIndex-1]);
  199296           0 :             blkptr[ SgCudaKernelExecConfig::pool_size - 1 ].set_freepointer(pointer);
  199297             :           }
  199298             :         } else {
  199299           0 :           SgCudaKernelExecConfig::next_node = pointer;
  199300             :         }
  199301             : 
  199302           0 :         for (unsigned i = 0; i < SgCudaKernelExecConfig::pool_size-1; ++i)
  199303             :            {
  199304           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  199305             :            }
  199306           0 :         pointer[ SgCudaKernelExecConfig::pool_size -1 ].set_freepointer(NULL);
  199307             : 
  199308           0 :         blockIndex++;
  199309             :       }
  199310           2 :   }
  199311             : 
  199312             : //############################################################################
  199313             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  199314             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  199315             :  * not compressed. However, that stuff is not yet implemented! 
  199316             :  */
  199317             : unsigned long
  199318           0 : SgCudaKernelExecConfig::getNumberOfLastValidPointer()
  199319             :    {
  199320           0 :       SgCudaKernelExecConfig* testPointer = (SgCudaKernelExecConfig*)(SgCudaKernelExecConfig::pools.back());
  199321           0 :       unsigned long localIndex = SgCudaKernelExecConfig::pool_size - 1;
  199322           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  199323             :          {
  199324           0 :            localIndex--;
  199325             :          }
  199326           0 :       return (localIndex + SgCudaKernelExecConfig::pool_size * (SgCudaKernelExecConfig::pools.size()-1));
  199327             :    }
  199328             : 
  199329             : //############################################################################
  199330             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  199331             :  * memory pool and initializes the data member in class SgCudaKernelExecConfigStroageClass
  199332             :  * from its counterpart of SgCudaKernelExecConfig. The return value is just for checking, 
  199333             :  * that the whole StorageClassArray is initialized!
  199334             :  */
  199335             : unsigned long
  199336           0 : SgCudaKernelExecConfig::initializeStorageClassArray( SgCudaKernelExecConfigStorageClass *storageArray )
  199337             :    {
  199338           0 :      unsigned long storageCounter = 0;
  199339           0 :      std::vector < unsigned char* > :: const_iterator block = SgCudaKernelExecConfig::pools.begin();
  199340           0 :      SgCudaKernelExecConfig* pointer = NULL;
  199341           0 :      while ( block != SgCudaKernelExecConfig::pools.end() ) {
  199342           0 :           pointer = (SgCudaKernelExecConfig*) (*block);
  199343           0 :           for ( unsigned i = 0; i < SgCudaKernelExecConfig::pool_size; ++i ) {
  199344           0 :                if ( pointer->get_freepointer() != NULL ) {
  199345           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  199346           0 :                  storageArray++;
  199347           0 :                  storageCounter++;
  199348             :                }
  199349           0 :                pointer++;
  199350             :              }
  199351           0 :            block++;
  199352             :         }
  199353           0 :      return storageCounter;
  199354             :    }
  199355             : 
  199356             : /* #line 199357 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  199357             : 
  199358             : 
  199359             : 
  199360             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  199361             : 
  199362             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  199363             : 
  199364             : //############################################################################
  199365             : /* JH (02/02/2006) Constructor of the IR node SgLambdaRefExp that takes its 
  199366             :  * corresponding StorageClass as parameter
  199367             :  */
  199368           0 : SgLambdaRefExp :: SgLambdaRefExp ( const SgLambdaRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  199369             :    {
  199370             : 
  199371             : 
  199372             : /* #line 199373 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  199373             : 
  199374           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  199375           0 :      p_functionDeclaration =  (SgFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_functionDeclaration) );
  199376             : 
  199377             : 
  199378             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  199379             : 
  199380             : 
  199381           0 :    }
  199382             : 
  199383             : //############################################################################
  199384             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  199385             :  * within the working AST. 
  199386             :  */
  199387           0 : SgLambdaRefExp * SgLambdaRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  199388           0 :      SgLambdaRefExp* returnPointer = NULL;
  199389           0 :      if ( globalIndex != 0 )
  199390             :         {
  199391             : 
  199392             : #if FILE_IO_EXTRA_CHECK
  199393           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLambdaRefExp ) ) <= globalIndex ) ;
  199394           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLambdaRefExp + 1 ) ) );
  199395             : #endif
  199396           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLambdaRefExp )  
  199397           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLambdaRefExp );
  199398           0 :           unsigned long positionInPool = localIndex % SgLambdaRefExp::pool_size;
  199399           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLambdaRefExp::pool_size;
  199400             : 
  199401             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  199402             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  199403             : 
  199404           0 :           returnPointer = &( ( (SgLambdaRefExp*)(SgLambdaRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  199405             : 
  199406           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  199407             :         }
  199408           0 :      return returnPointer ;
  199409             :    }
  199410             : 
  199411             : //############################################################################
  199412             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  199413             :   for the AST with the index astIndex
  199414             : */
  199415           0 : SgLambdaRefExp * SgLambdaRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  199416           0 :      SgLambdaRefExp* returnPointer = NULL;
  199417           0 :      if ( globalIndex != 0 )
  199418             :         {
  199419             : 
  199420             : #if FILE_IO_EXTRA_CHECK
  199421           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLambdaRefExp ) ) <= globalIndex ) ;
  199422           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLambdaRefExp + 1 ) ) );
  199423             : #endif
  199424           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLambdaRefExp )
  199425           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLambdaRefExp );
  199426           0 :           unsigned long positionInPool = localIndex % SgLambdaRefExp::pool_size ;
  199427           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLambdaRefExp::pool_size ;
  199428             : 
  199429             : #if FILE_IO_EXTRA_CHECK
  199430             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  199431             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  199432             : #endif
  199433             : 
  199434           0 :           returnPointer = &( ( (SgLambdaRefExp*)(SgLambdaRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  199435             : 
  199436             : #if FILE_IO_EXTRA_CHECK
  199437           0 :           assert ( returnPointer != NULL ) ;
  199438             : #endif
  199439             :         }
  199440           0 :      return returnPointer ;
  199441             :    }
  199442             : 
  199443             : //############################################################################
  199444             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  199445             :  * pool size! We set for every valid object in the memory pool the freepointer
  199446             :  * to the global index and increase the global index afterwards. For all the 
  199447             :  * invalid objects (means address ranges within the memory pool that were not
  199448             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  199449             :  * distinguish valid from invalid objects! 
  199450             :  */
  199451             : unsigned long
  199452           5 : SgLambdaRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  199453             :    {
  199454           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  199455           5 :      SgLambdaRefExp* pointer = NULL;
  199456           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  199457           5 :      std::vector < unsigned char* > :: const_iterator block;
  199458           5 :      for ( block = SgLambdaRefExp::pools.begin(); block != SgLambdaRefExp::pools.end() ; ++block )
  199459             :         {
  199460           0 :           pointer = (SgLambdaRefExp*)(*block);
  199461           0 :           for (unsigned i = 0; i < SgLambdaRefExp::pool_size; ++i )
  199462             :              {
  199463             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  199464             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  199465             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  199466             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  199467             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  199468             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  199469             :             // properly; so this will have to be checked next.
  199470             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  199471             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  199472           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  199473             :                   {
  199474           0 :                     pointer[i].set_freepointer((SgLambdaRefExp*)(globalIndex));
  199475           0 :                     globalIndex++;
  199476             :                   }
  199477             :                else
  199478             :                   {
  199479           0 :                     pointer[i].set_freepointer(NULL);
  199480             :                   }
  199481             :               }
  199482             :         }
  199483           5 :      return globalIndex;
  199484             :    }
  199485             : 
  199486             : //############################################################################
  199487             : // JH (01/14/2006)
  199488             : void
  199489           5 : SgLambdaRefExp::resetValidFreepointers( )
  199490             :    {
  199491           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  199492           5 :      SgLambdaRefExp* pointer = NULL;
  199493           5 :      std::vector < unsigned char* > :: const_iterator block;
  199494           5 :      SgLambdaRefExp* pointerOfLinkedList = NULL;
  199495           5 :      for ( block = SgLambdaRefExp::pools.begin(); block != SgLambdaRefExp::pools.end() ; ++block )
  199496             :         {
  199497           0 :           pointer = (SgLambdaRefExp*)(*block);
  199498           0 :           for (unsigned i = 0; i < SgLambdaRefExp::pool_size; ++i )
  199499             :              {
  199500             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  199501             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  199502             :             // memory blocks!.
  199503           0 :                if ( pointer[i].get_freepointer() != NULL )
  199504             :                   {
  199505           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  199506             :                   }
  199507             :                else
  199508             :                   {
  199509           0 :                     if ( pointerOfLinkedList == NULL )
  199510             :                        {
  199511           0 :                          SgLambdaRefExp::next_node = &(pointer[i]);
  199512             :                        }
  199513             :                     else
  199514             :                        {
  199515             :                       // printf ("In SgLambdaRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  199516           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  199517             :                        }
  199518             :                     pointerOfLinkedList = &(pointer[i]);
  199519             :                   }
  199520             :               }
  199521             :         }
  199522             : 
  199523           5 :      if ( pointerOfLinkedList != NULL )
  199524             :         {
  199525             :        // printf ("In SgLambdaRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  199526           0 :           pointerOfLinkedList->set_freepointer(NULL);
  199527             :        // DQ (6/6/2010): Temporary debugging...
  199528             :        //   ROSE_ASSERT(false);
  199529             :         }
  199530             : 
  199531           5 :      return ;
  199532             :    }
  199533             : 
  199534             : //############################################################################
  199535             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  199536             :  * within the memory pool and resets the freepointers, in order to achieve a 
  199537             :  * linked list, that has no jumps and starts at the beginning! This function 
  199538             :  * does not extend the memory pool, since we do not delete any memory blocks,
  199539             :  * but delete the valid objects.  
  199540             :  */
  199541             : void
  199542           0 : SgLambdaRefExp::clearMemoryPool( )
  199543             :    {
  199544             :   // printf ("Inside of SgLambdaRefExp::clearMemoryPool() \n");
  199545             : 
  199546           0 :      SgLambdaRefExp* pointer = NULL, *tempPointer = NULL;
  199547           0 :      std::vector < unsigned char* > :: const_iterator block;
  199548           0 :      if ( SgLambdaRefExp::pools.empty() == false )
  199549             :         {
  199550           0 :           block = SgLambdaRefExp::pools.begin() ;
  199551           0 :           SgLambdaRefExp::next_node = (SgLambdaRefExp*) (*block);
  199552             : 
  199553           0 :           while ( block != SgLambdaRefExp::pools.end() )
  199554             :              {
  199555           0 :                pointer = (SgLambdaRefExp*) (*block);
  199556           0 :                if ( tempPointer != NULL )
  199557             :                   {
  199558           0 :                     tempPointer->set_freepointer(pointer);
  199559             :                   }
  199560           0 :                for (unsigned i = 0; i < SgLambdaRefExp::pool_size - 1; ++i)
  199561             :                   {
  199562           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  199563             :                   }
  199564           0 :                 pointer[SgLambdaRefExp::pool_size-1].set_freepointer(NULL);
  199565           0 :                 tempPointer = &(pointer[SgLambdaRefExp::pool_size-1]);
  199566           0 :                 ++block;
  199567             :              }
  199568             :         }
  199569           0 :    }
  199570             : 
  199571           5 : void SgLambdaRefExp::deleteMemoryPool() {
  199572           5 :   for (auto p: SgLambdaRefExp::pools) {
  199573           0 :     ROSE_FREE(p);
  199574             :   }
  199575           5 :   SgLambdaRefExp::next_node = nullptr;
  199576           5 :   SgLambdaRefExp::pools.clear();
  199577           5 : }
  199578             : 
  199579             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  199580             : //                 reading multiple binary files to for a single AST.
  199581             : /////////// new version ////////////////////////////////
  199582             : //############################################################################
  199583             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  199584             : void
  199585           2 : SgLambdaRefExp::extendMemoryPoolForFileIO( )
  199586             :   {
  199587           2 :     size_t blockIndex = SgLambdaRefExp::pools.size();
  199588           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaRefExp);
  199589             : 
  199590           2 :     while ( (blockIndex * SgLambdaRefExp::pool_size) < newPoolSize)
  199591             :       {
  199592             : #if ROSE_ALLOC_TRACE
  199593             :         if (blockIndex > 0) {
  199594             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaRefExp) = %" PRIuPTR " SgLambdaRefExp::pool_size = %d \n",
  199595             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaRefExp),SgLambdaRefExp::pool_size);
  199596             :         }
  199597             : #endif
  199598             : 
  199599           0 :         SgLambdaRefExp * pointer = (SgLambdaRefExp*) ROSE_MALLOC ( SgLambdaRefExp::pool_size * sizeof(SgLambdaRefExp) );
  199600           0 :         assert( pointer != NULL );
  199601             : #if ROSE_ALLOC_MEMSET == 1
  199602             :         memset(pointer, 0x00, SgLambdaRefExp::pool_size * sizeof(SgLambdaRefExp));
  199603             : #elif ROSE_ALLOC_MEMSET == 2
  199604             :         memset(pointer, 0xCC, SgLambdaRefExp::pool_size * sizeof(SgLambdaRefExp));
  199605             : #endif
  199606           0 :         SgLambdaRefExp::pools.push_back( (unsigned char*)(pointer) );
  199607           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLambdaRefExp::pool_size * sizeof(SgLambdaRefExp), V_SgLambdaRefExp ) );
  199608             : 
  199609           0 :         if ( SgLambdaRefExp::next_node != NULL ) {
  199610           0 :           if ( blockIndex > 0 ) {
  199611           0 :             SgLambdaRefExp * blkptr = (SgLambdaRefExp*)(SgLambdaRefExp::pools[blockIndex-1]);
  199612           0 :             blkptr[ SgLambdaRefExp::pool_size - 1 ].set_freepointer(pointer);
  199613             :           }
  199614             :         } else {
  199615           0 :           SgLambdaRefExp::next_node = pointer;
  199616             :         }
  199617             : 
  199618           0 :         for (unsigned i = 0; i < SgLambdaRefExp::pool_size-1; ++i)
  199619             :            {
  199620           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  199621             :            }
  199622           0 :         pointer[ SgLambdaRefExp::pool_size -1 ].set_freepointer(NULL);
  199623             : 
  199624           0 :         blockIndex++;
  199625             :       }
  199626           2 :   }
  199627             : 
  199628             : //############################################################################
  199629             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  199630             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  199631             :  * not compressed. However, that stuff is not yet implemented! 
  199632             :  */
  199633             : unsigned long
  199634           0 : SgLambdaRefExp::getNumberOfLastValidPointer()
  199635             :    {
  199636           0 :       SgLambdaRefExp* testPointer = (SgLambdaRefExp*)(SgLambdaRefExp::pools.back());
  199637           0 :       unsigned long localIndex = SgLambdaRefExp::pool_size - 1;
  199638           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  199639             :          {
  199640           0 :            localIndex--;
  199641             :          }
  199642           0 :       return (localIndex + SgLambdaRefExp::pool_size * (SgLambdaRefExp::pools.size()-1));
  199643             :    }
  199644             : 
  199645             : //############################################################################
  199646             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  199647             :  * memory pool and initializes the data member in class SgLambdaRefExpStroageClass
  199648             :  * from its counterpart of SgLambdaRefExp. The return value is just for checking, 
  199649             :  * that the whole StorageClassArray is initialized!
  199650             :  */
  199651             : unsigned long
  199652           0 : SgLambdaRefExp::initializeStorageClassArray( SgLambdaRefExpStorageClass *storageArray )
  199653             :    {
  199654           0 :      unsigned long storageCounter = 0;
  199655           0 :      std::vector < unsigned char* > :: const_iterator block = SgLambdaRefExp::pools.begin();
  199656           0 :      SgLambdaRefExp* pointer = NULL;
  199657           0 :      while ( block != SgLambdaRefExp::pools.end() ) {
  199658           0 :           pointer = (SgLambdaRefExp*) (*block);
  199659           0 :           for ( unsigned i = 0; i < SgLambdaRefExp::pool_size; ++i ) {
  199660           0 :                if ( pointer->get_freepointer() != NULL ) {
  199661           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  199662           0 :                  storageArray++;
  199663           0 :                  storageCounter++;
  199664             :                }
  199665           0 :                pointer++;
  199666             :              }
  199667           0 :            block++;
  199668             :         }
  199669           0 :      return storageCounter;
  199670             :    }
  199671             : 
  199672             : /* #line 199673 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  199673             : 
  199674             : 
  199675             : 
  199676             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  199677             : 
  199678             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  199679             : 
  199680             : //############################################################################
  199681             : /* JH (02/02/2006) Constructor of the IR node SgDictionaryExp that takes its 
  199682             :  * corresponding StorageClass as parameter
  199683             :  */
  199684           0 : SgDictionaryExp :: SgDictionaryExp ( const SgDictionaryExpStorageClass& storageSource )   : SgExpression (storageSource)
  199685             :    {
  199686             : 
  199687             : 
  199688             : /* #line 199689 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  199689             : 
  199690           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  199691           0 :      p_key_datum_pairs = storageSource.storageOf_key_datum_pairs.rebuildDataStoredInEasyStorageClass() ;
  199692           0 :      SgKeyDatumPairPtrList::iterator i_key_datum_pairs = p_key_datum_pairs.begin() ; 
  199693           0 :      for ( ; i_key_datum_pairs != p_key_datum_pairs.end(); ++i_key_datum_pairs ) 
  199694             :         {
  199695           0 :           (*i_key_datum_pairs) = (SgKeyDatumPairPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_key_datum_pairs) ) );
  199696             :         }
  199697             : 
  199698             : 
  199699             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  199700             : 
  199701             : 
  199702           0 :    }
  199703             : 
  199704             : //############################################################################
  199705             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  199706             :  * within the working AST. 
  199707             :  */
  199708           0 : SgDictionaryExp * SgDictionaryExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  199709           0 :      SgDictionaryExp* returnPointer = NULL;
  199710           0 :      if ( globalIndex != 0 )
  199711             :         {
  199712             : 
  199713             : #if FILE_IO_EXTRA_CHECK
  199714           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDictionaryExp ) ) <= globalIndex ) ;
  199715           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDictionaryExp + 1 ) ) );
  199716             : #endif
  199717           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDictionaryExp )  
  199718           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDictionaryExp );
  199719           0 :           unsigned long positionInPool = localIndex % SgDictionaryExp::pool_size;
  199720           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDictionaryExp::pool_size;
  199721             : 
  199722             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  199723             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  199724             : 
  199725           0 :           returnPointer = &( ( (SgDictionaryExp*)(SgDictionaryExp::pools[memoryBlock]) ) [positionInPool]) ;
  199726             : 
  199727           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  199728             :         }
  199729           0 :      return returnPointer ;
  199730             :    }
  199731             : 
  199732             : //############################################################################
  199733             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  199734             :   for the AST with the index astIndex
  199735             : */
  199736           0 : SgDictionaryExp * SgDictionaryExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  199737           0 :      SgDictionaryExp* returnPointer = NULL;
  199738           0 :      if ( globalIndex != 0 )
  199739             :         {
  199740             : 
  199741             : #if FILE_IO_EXTRA_CHECK
  199742           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDictionaryExp ) ) <= globalIndex ) ;
  199743           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDictionaryExp + 1 ) ) );
  199744             : #endif
  199745           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDictionaryExp )
  199746           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDictionaryExp );
  199747           0 :           unsigned long positionInPool = localIndex % SgDictionaryExp::pool_size ;
  199748           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDictionaryExp::pool_size ;
  199749             : 
  199750             : #if FILE_IO_EXTRA_CHECK
  199751             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  199752             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  199753             : #endif
  199754             : 
  199755           0 :           returnPointer = &( ( (SgDictionaryExp*)(SgDictionaryExp::pools[memoryBlock]) ) [positionInPool]) ;
  199756             : 
  199757             : #if FILE_IO_EXTRA_CHECK
  199758           0 :           assert ( returnPointer != NULL ) ;
  199759             : #endif
  199760             :         }
  199761           0 :      return returnPointer ;
  199762             :    }
  199763             : 
  199764             : //############################################################################
  199765             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  199766             :  * pool size! We set for every valid object in the memory pool the freepointer
  199767             :  * to the global index and increase the global index afterwards. For all the 
  199768             :  * invalid objects (means address ranges within the memory pool that were not
  199769             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  199770             :  * distinguish valid from invalid objects! 
  199771             :  */
  199772             : unsigned long
  199773           5 : SgDictionaryExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  199774             :    {
  199775           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  199776           5 :      SgDictionaryExp* pointer = NULL;
  199777           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  199778           5 :      std::vector < unsigned char* > :: const_iterator block;
  199779           5 :      for ( block = SgDictionaryExp::pools.begin(); block != SgDictionaryExp::pools.end() ; ++block )
  199780             :         {
  199781           0 :           pointer = (SgDictionaryExp*)(*block);
  199782           0 :           for (unsigned i = 0; i < SgDictionaryExp::pool_size; ++i )
  199783             :              {
  199784             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  199785             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  199786             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  199787             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  199788             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  199789             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  199790             :             // properly; so this will have to be checked next.
  199791             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  199792             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  199793           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  199794             :                   {
  199795           0 :                     pointer[i].set_freepointer((SgDictionaryExp*)(globalIndex));
  199796           0 :                     globalIndex++;
  199797             :                   }
  199798             :                else
  199799             :                   {
  199800           0 :                     pointer[i].set_freepointer(NULL);
  199801             :                   }
  199802             :               }
  199803             :         }
  199804           5 :      return globalIndex;
  199805             :    }
  199806             : 
  199807             : //############################################################################
  199808             : // JH (01/14/2006)
  199809             : void
  199810           5 : SgDictionaryExp::resetValidFreepointers( )
  199811             :    {
  199812           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  199813           5 :      SgDictionaryExp* pointer = NULL;
  199814           5 :      std::vector < unsigned char* > :: const_iterator block;
  199815           5 :      SgDictionaryExp* pointerOfLinkedList = NULL;
  199816           5 :      for ( block = SgDictionaryExp::pools.begin(); block != SgDictionaryExp::pools.end() ; ++block )
  199817             :         {
  199818           0 :           pointer = (SgDictionaryExp*)(*block);
  199819           0 :           for (unsigned i = 0; i < SgDictionaryExp::pool_size; ++i )
  199820             :              {
  199821             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  199822             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  199823             :             // memory blocks!.
  199824           0 :                if ( pointer[i].get_freepointer() != NULL )
  199825             :                   {
  199826           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  199827             :                   }
  199828             :                else
  199829             :                   {
  199830           0 :                     if ( pointerOfLinkedList == NULL )
  199831             :                        {
  199832           0 :                          SgDictionaryExp::next_node = &(pointer[i]);
  199833             :                        }
  199834             :                     else
  199835             :                        {
  199836             :                       // printf ("In SgDictionaryExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  199837           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  199838             :                        }
  199839             :                     pointerOfLinkedList = &(pointer[i]);
  199840             :                   }
  199841             :               }
  199842             :         }
  199843             : 
  199844           5 :      if ( pointerOfLinkedList != NULL )
  199845             :         {
  199846             :        // printf ("In SgDictionaryExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  199847           0 :           pointerOfLinkedList->set_freepointer(NULL);
  199848             :        // DQ (6/6/2010): Temporary debugging...
  199849             :        //   ROSE_ASSERT(false);
  199850             :         }
  199851             : 
  199852           5 :      return ;
  199853             :    }
  199854             : 
  199855             : //############################################################################
  199856             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  199857             :  * within the memory pool and resets the freepointers, in order to achieve a 
  199858             :  * linked list, that has no jumps and starts at the beginning! This function 
  199859             :  * does not extend the memory pool, since we do not delete any memory blocks,
  199860             :  * but delete the valid objects.  
  199861             :  */
  199862             : void
  199863           0 : SgDictionaryExp::clearMemoryPool( )
  199864             :    {
  199865             :   // printf ("Inside of SgDictionaryExp::clearMemoryPool() \n");
  199866             : 
  199867           0 :      SgDictionaryExp* pointer = NULL, *tempPointer = NULL;
  199868           0 :      std::vector < unsigned char* > :: const_iterator block;
  199869           0 :      if ( SgDictionaryExp::pools.empty() == false )
  199870             :         {
  199871           0 :           block = SgDictionaryExp::pools.begin() ;
  199872           0 :           SgDictionaryExp::next_node = (SgDictionaryExp*) (*block);
  199873             : 
  199874           0 :           while ( block != SgDictionaryExp::pools.end() )
  199875             :              {
  199876           0 :                pointer = (SgDictionaryExp*) (*block);
  199877           0 :                if ( tempPointer != NULL )
  199878             :                   {
  199879           0 :                     tempPointer->set_freepointer(pointer);
  199880             :                   }
  199881           0 :                for (unsigned i = 0; i < SgDictionaryExp::pool_size - 1; ++i)
  199882             :                   {
  199883           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  199884             :                   }
  199885           0 :                 pointer[SgDictionaryExp::pool_size-1].set_freepointer(NULL);
  199886           0 :                 tempPointer = &(pointer[SgDictionaryExp::pool_size-1]);
  199887           0 :                 ++block;
  199888             :              }
  199889             :         }
  199890           0 :    }
  199891             : 
  199892           5 : void SgDictionaryExp::deleteMemoryPool() {
  199893           5 :   for (auto p: SgDictionaryExp::pools) {
  199894           0 :     ROSE_FREE(p);
  199895             :   }
  199896           5 :   SgDictionaryExp::next_node = nullptr;
  199897           5 :   SgDictionaryExp::pools.clear();
  199898           5 : }
  199899             : 
  199900             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  199901             : //                 reading multiple binary files to for a single AST.
  199902             : /////////// new version ////////////////////////////////
  199903             : //############################################################################
  199904             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  199905             : void
  199906           2 : SgDictionaryExp::extendMemoryPoolForFileIO( )
  199907             :   {
  199908           2 :     size_t blockIndex = SgDictionaryExp::pools.size();
  199909           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDictionaryExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDictionaryExp);
  199910             : 
  199911           2 :     while ( (blockIndex * SgDictionaryExp::pool_size) < newPoolSize)
  199912             :       {
  199913             : #if ROSE_ALLOC_TRACE
  199914             :         if (blockIndex > 0) {
  199915             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDictionaryExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDictionaryExp) = %" PRIuPTR " SgDictionaryExp::pool_size = %d \n",
  199916             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDictionaryExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDictionaryExp),SgDictionaryExp::pool_size);
  199917             :         }
  199918             : #endif
  199919             : 
  199920           0 :         SgDictionaryExp * pointer = (SgDictionaryExp*) ROSE_MALLOC ( SgDictionaryExp::pool_size * sizeof(SgDictionaryExp) );
  199921           0 :         assert( pointer != NULL );
  199922             : #if ROSE_ALLOC_MEMSET == 1
  199923             :         memset(pointer, 0x00, SgDictionaryExp::pool_size * sizeof(SgDictionaryExp));
  199924             : #elif ROSE_ALLOC_MEMSET == 2
  199925             :         memset(pointer, 0xCC, SgDictionaryExp::pool_size * sizeof(SgDictionaryExp));
  199926             : #endif
  199927           0 :         SgDictionaryExp::pools.push_back( (unsigned char*)(pointer) );
  199928           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDictionaryExp::pool_size * sizeof(SgDictionaryExp), V_SgDictionaryExp ) );
  199929             : 
  199930           0 :         if ( SgDictionaryExp::next_node != NULL ) {
  199931           0 :           if ( blockIndex > 0 ) {
  199932           0 :             SgDictionaryExp * blkptr = (SgDictionaryExp*)(SgDictionaryExp::pools[blockIndex-1]);
  199933           0 :             blkptr[ SgDictionaryExp::pool_size - 1 ].set_freepointer(pointer);
  199934             :           }
  199935             :         } else {
  199936           0 :           SgDictionaryExp::next_node = pointer;
  199937             :         }
  199938             : 
  199939           0 :         for (unsigned i = 0; i < SgDictionaryExp::pool_size-1; ++i)
  199940             :            {
  199941           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  199942             :            }
  199943           0 :         pointer[ SgDictionaryExp::pool_size -1 ].set_freepointer(NULL);
  199944             : 
  199945           0 :         blockIndex++;
  199946             :       }
  199947           2 :   }
  199948             : 
  199949             : //############################################################################
  199950             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  199951             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  199952             :  * not compressed. However, that stuff is not yet implemented! 
  199953             :  */
  199954             : unsigned long
  199955           0 : SgDictionaryExp::getNumberOfLastValidPointer()
  199956             :    {
  199957           0 :       SgDictionaryExp* testPointer = (SgDictionaryExp*)(SgDictionaryExp::pools.back());
  199958           0 :       unsigned long localIndex = SgDictionaryExp::pool_size - 1;
  199959           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  199960             :          {
  199961           0 :            localIndex--;
  199962             :          }
  199963           0 :       return (localIndex + SgDictionaryExp::pool_size * (SgDictionaryExp::pools.size()-1));
  199964             :    }
  199965             : 
  199966             : //############################################################################
  199967             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  199968             :  * memory pool and initializes the data member in class SgDictionaryExpStroageClass
  199969             :  * from its counterpart of SgDictionaryExp. The return value is just for checking, 
  199970             :  * that the whole StorageClassArray is initialized!
  199971             :  */
  199972             : unsigned long
  199973           0 : SgDictionaryExp::initializeStorageClassArray( SgDictionaryExpStorageClass *storageArray )
  199974             :    {
  199975           0 :      unsigned long storageCounter = 0;
  199976           0 :      std::vector < unsigned char* > :: const_iterator block = SgDictionaryExp::pools.begin();
  199977           0 :      SgDictionaryExp* pointer = NULL;
  199978           0 :      while ( block != SgDictionaryExp::pools.end() ) {
  199979           0 :           pointer = (SgDictionaryExp*) (*block);
  199980           0 :           for ( unsigned i = 0; i < SgDictionaryExp::pool_size; ++i ) {
  199981           0 :                if ( pointer->get_freepointer() != NULL ) {
  199982           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  199983           0 :                  storageArray++;
  199984           0 :                  storageCounter++;
  199985             :                }
  199986           0 :                pointer++;
  199987             :              }
  199988           0 :            block++;
  199989             :         }
  199990           0 :      return storageCounter;
  199991             :    }
  199992             : 
  199993             : /* #line 199994 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  199994             : 
  199995             : 
  199996             : 
  199997             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  199998             : 
  199999             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  200000             : 
  200001             : //############################################################################
  200002             : /* JH (02/02/2006) Constructor of the IR node SgKeyDatumPair that takes its 
  200003             :  * corresponding StorageClass as parameter
  200004             :  */
  200005           0 : SgKeyDatumPair :: SgKeyDatumPair ( const SgKeyDatumPairStorageClass& storageSource )   : SgExpression (storageSource)
  200006             :    {
  200007             : 
  200008             : 
  200009             : /* #line 200010 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  200010             : 
  200011           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  200012           0 :      p_key =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_key) );
  200013           0 :      p_datum =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_datum) );
  200014             : 
  200015             : 
  200016             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  200017             : 
  200018             : 
  200019           0 :    }
  200020             : 
  200021             : //############################################################################
  200022             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  200023             :  * within the working AST. 
  200024             :  */
  200025           0 : SgKeyDatumPair * SgKeyDatumPair::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  200026           0 :      SgKeyDatumPair* returnPointer = NULL;
  200027           0 :      if ( globalIndex != 0 )
  200028             :         {
  200029             : 
  200030             : #if FILE_IO_EXTRA_CHECK
  200031           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgKeyDatumPair ) ) <= globalIndex ) ;
  200032           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgKeyDatumPair + 1 ) ) );
  200033             : #endif
  200034           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgKeyDatumPair )  
  200035           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgKeyDatumPair );
  200036           0 :           unsigned long positionInPool = localIndex % SgKeyDatumPair::pool_size;
  200037           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgKeyDatumPair::pool_size;
  200038             : 
  200039             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  200040             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  200041             : 
  200042           0 :           returnPointer = &( ( (SgKeyDatumPair*)(SgKeyDatumPair::pools[memoryBlock]) ) [positionInPool]) ;
  200043             : 
  200044           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  200045             :         }
  200046           0 :      return returnPointer ;
  200047             :    }
  200048             : 
  200049             : //############################################################################
  200050             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  200051             :   for the AST with the index astIndex
  200052             : */
  200053           0 : SgKeyDatumPair * SgKeyDatumPair::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  200054           0 :      SgKeyDatumPair* returnPointer = NULL;
  200055           0 :      if ( globalIndex != 0 )
  200056             :         {
  200057             : 
  200058             : #if FILE_IO_EXTRA_CHECK
  200059           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgKeyDatumPair ) ) <= globalIndex ) ;
  200060           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgKeyDatumPair + 1 ) ) );
  200061             : #endif
  200062           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgKeyDatumPair )
  200063           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgKeyDatumPair );
  200064           0 :           unsigned long positionInPool = localIndex % SgKeyDatumPair::pool_size ;
  200065           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgKeyDatumPair::pool_size ;
  200066             : 
  200067             : #if FILE_IO_EXTRA_CHECK
  200068             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  200069             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  200070             : #endif
  200071             : 
  200072           0 :           returnPointer = &( ( (SgKeyDatumPair*)(SgKeyDatumPair::pools[memoryBlock]) ) [positionInPool]) ;
  200073             : 
  200074             : #if FILE_IO_EXTRA_CHECK
  200075           0 :           assert ( returnPointer != NULL ) ;
  200076             : #endif
  200077             :         }
  200078           0 :      return returnPointer ;
  200079             :    }
  200080             : 
  200081             : //############################################################################
  200082             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  200083             :  * pool size! We set for every valid object in the memory pool the freepointer
  200084             :  * to the global index and increase the global index afterwards. For all the 
  200085             :  * invalid objects (means address ranges within the memory pool that were not
  200086             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  200087             :  * distinguish valid from invalid objects! 
  200088             :  */
  200089             : unsigned long
  200090           5 : SgKeyDatumPair::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  200091             :    {
  200092           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  200093           5 :      SgKeyDatumPair* pointer = NULL;
  200094           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  200095           5 :      std::vector < unsigned char* > :: const_iterator block;
  200096           5 :      for ( block = SgKeyDatumPair::pools.begin(); block != SgKeyDatumPair::pools.end() ; ++block )
  200097             :         {
  200098           0 :           pointer = (SgKeyDatumPair*)(*block);
  200099           0 :           for (unsigned i = 0; i < SgKeyDatumPair::pool_size; ++i )
  200100             :              {
  200101             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  200102             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  200103             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  200104             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  200105             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  200106             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  200107             :             // properly; so this will have to be checked next.
  200108             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  200109             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  200110           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  200111             :                   {
  200112           0 :                     pointer[i].set_freepointer((SgKeyDatumPair*)(globalIndex));
  200113           0 :                     globalIndex++;
  200114             :                   }
  200115             :                else
  200116             :                   {
  200117           0 :                     pointer[i].set_freepointer(NULL);
  200118             :                   }
  200119             :               }
  200120             :         }
  200121           5 :      return globalIndex;
  200122             :    }
  200123             : 
  200124             : //############################################################################
  200125             : // JH (01/14/2006)
  200126             : void
  200127           5 : SgKeyDatumPair::resetValidFreepointers( )
  200128             :    {
  200129           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  200130           5 :      SgKeyDatumPair* pointer = NULL;
  200131           5 :      std::vector < unsigned char* > :: const_iterator block;
  200132           5 :      SgKeyDatumPair* pointerOfLinkedList = NULL;
  200133           5 :      for ( block = SgKeyDatumPair::pools.begin(); block != SgKeyDatumPair::pools.end() ; ++block )
  200134             :         {
  200135           0 :           pointer = (SgKeyDatumPair*)(*block);
  200136           0 :           for (unsigned i = 0; i < SgKeyDatumPair::pool_size; ++i )
  200137             :              {
  200138             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  200139             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  200140             :             // memory blocks!.
  200141           0 :                if ( pointer[i].get_freepointer() != NULL )
  200142             :                   {
  200143           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  200144             :                   }
  200145             :                else
  200146             :                   {
  200147           0 :                     if ( pointerOfLinkedList == NULL )
  200148             :                        {
  200149           0 :                          SgKeyDatumPair::next_node = &(pointer[i]);
  200150             :                        }
  200151             :                     else
  200152             :                        {
  200153             :                       // printf ("In SgKeyDatumPair::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  200154           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  200155             :                        }
  200156             :                     pointerOfLinkedList = &(pointer[i]);
  200157             :                   }
  200158             :               }
  200159             :         }
  200160             : 
  200161           5 :      if ( pointerOfLinkedList != NULL )
  200162             :         {
  200163             :        // printf ("In SgKeyDatumPair::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  200164           0 :           pointerOfLinkedList->set_freepointer(NULL);
  200165             :        // DQ (6/6/2010): Temporary debugging...
  200166             :        //   ROSE_ASSERT(false);
  200167             :         }
  200168             : 
  200169           5 :      return ;
  200170             :    }
  200171             : 
  200172             : //############################################################################
  200173             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  200174             :  * within the memory pool and resets the freepointers, in order to achieve a 
  200175             :  * linked list, that has no jumps and starts at the beginning! This function 
  200176             :  * does not extend the memory pool, since we do not delete any memory blocks,
  200177             :  * but delete the valid objects.  
  200178             :  */
  200179             : void
  200180           0 : SgKeyDatumPair::clearMemoryPool( )
  200181             :    {
  200182             :   // printf ("Inside of SgKeyDatumPair::clearMemoryPool() \n");
  200183             : 
  200184           0 :      SgKeyDatumPair* pointer = NULL, *tempPointer = NULL;
  200185           0 :      std::vector < unsigned char* > :: const_iterator block;
  200186           0 :      if ( SgKeyDatumPair::pools.empty() == false )
  200187             :         {
  200188           0 :           block = SgKeyDatumPair::pools.begin() ;
  200189           0 :           SgKeyDatumPair::next_node = (SgKeyDatumPair*) (*block);
  200190             : 
  200191           0 :           while ( block != SgKeyDatumPair::pools.end() )
  200192             :              {
  200193           0 :                pointer = (SgKeyDatumPair*) (*block);
  200194           0 :                if ( tempPointer != NULL )
  200195             :                   {
  200196           0 :                     tempPointer->set_freepointer(pointer);
  200197             :                   }
  200198           0 :                for (unsigned i = 0; i < SgKeyDatumPair::pool_size - 1; ++i)
  200199             :                   {
  200200           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  200201             :                   }
  200202           0 :                 pointer[SgKeyDatumPair::pool_size-1].set_freepointer(NULL);
  200203           0 :                 tempPointer = &(pointer[SgKeyDatumPair::pool_size-1]);
  200204           0 :                 ++block;
  200205             :              }
  200206             :         }
  200207           0 :    }
  200208             : 
  200209           5 : void SgKeyDatumPair::deleteMemoryPool() {
  200210           5 :   for (auto p: SgKeyDatumPair::pools) {
  200211           0 :     ROSE_FREE(p);
  200212             :   }
  200213           5 :   SgKeyDatumPair::next_node = nullptr;
  200214           5 :   SgKeyDatumPair::pools.clear();
  200215           5 : }
  200216             : 
  200217             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  200218             : //                 reading multiple binary files to for a single AST.
  200219             : /////////// new version ////////////////////////////////
  200220             : //############################################################################
  200221             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  200222             : void
  200223           2 : SgKeyDatumPair::extendMemoryPoolForFileIO( )
  200224             :   {
  200225           2 :     size_t blockIndex = SgKeyDatumPair::pools.size();
  200226           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgKeyDatumPair) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgKeyDatumPair);
  200227             : 
  200228           2 :     while ( (blockIndex * SgKeyDatumPair::pool_size) < newPoolSize)
  200229             :       {
  200230             : #if ROSE_ALLOC_TRACE
  200231             :         if (blockIndex > 0) {
  200232             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgKeyDatumPair) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgKeyDatumPair) = %" PRIuPTR " SgKeyDatumPair::pool_size = %d \n",
  200233             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgKeyDatumPair),AST_FILE_IO::getPoolSizeOfNewAst(V_SgKeyDatumPair),SgKeyDatumPair::pool_size);
  200234             :         }
  200235             : #endif
  200236             : 
  200237           0 :         SgKeyDatumPair * pointer = (SgKeyDatumPair*) ROSE_MALLOC ( SgKeyDatumPair::pool_size * sizeof(SgKeyDatumPair) );
  200238           0 :         assert( pointer != NULL );
  200239             : #if ROSE_ALLOC_MEMSET == 1
  200240             :         memset(pointer, 0x00, SgKeyDatumPair::pool_size * sizeof(SgKeyDatumPair));
  200241             : #elif ROSE_ALLOC_MEMSET == 2
  200242             :         memset(pointer, 0xCC, SgKeyDatumPair::pool_size * sizeof(SgKeyDatumPair));
  200243             : #endif
  200244           0 :         SgKeyDatumPair::pools.push_back( (unsigned char*)(pointer) );
  200245           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgKeyDatumPair::pool_size * sizeof(SgKeyDatumPair), V_SgKeyDatumPair ) );
  200246             : 
  200247           0 :         if ( SgKeyDatumPair::next_node != NULL ) {
  200248           0 :           if ( blockIndex > 0 ) {
  200249           0 :             SgKeyDatumPair * blkptr = (SgKeyDatumPair*)(SgKeyDatumPair::pools[blockIndex-1]);
  200250           0 :             blkptr[ SgKeyDatumPair::pool_size - 1 ].set_freepointer(pointer);
  200251             :           }
  200252             :         } else {
  200253           0 :           SgKeyDatumPair::next_node = pointer;
  200254             :         }
  200255             : 
  200256           0 :         for (unsigned i = 0; i < SgKeyDatumPair::pool_size-1; ++i)
  200257             :            {
  200258           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  200259             :            }
  200260           0 :         pointer[ SgKeyDatumPair::pool_size -1 ].set_freepointer(NULL);
  200261             : 
  200262           0 :         blockIndex++;
  200263             :       }
  200264           2 :   }
  200265             : 
  200266             : //############################################################################
  200267             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  200268             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  200269             :  * not compressed. However, that stuff is not yet implemented! 
  200270             :  */
  200271             : unsigned long
  200272           0 : SgKeyDatumPair::getNumberOfLastValidPointer()
  200273             :    {
  200274           0 :       SgKeyDatumPair* testPointer = (SgKeyDatumPair*)(SgKeyDatumPair::pools.back());
  200275           0 :       unsigned long localIndex = SgKeyDatumPair::pool_size - 1;
  200276           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  200277             :          {
  200278           0 :            localIndex--;
  200279             :          }
  200280           0 :       return (localIndex + SgKeyDatumPair::pool_size * (SgKeyDatumPair::pools.size()-1));
  200281             :    }
  200282             : 
  200283             : //############################################################################
  200284             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  200285             :  * memory pool and initializes the data member in class SgKeyDatumPairStroageClass
  200286             :  * from its counterpart of SgKeyDatumPair. The return value is just for checking, 
  200287             :  * that the whole StorageClassArray is initialized!
  200288             :  */
  200289             : unsigned long
  200290           0 : SgKeyDatumPair::initializeStorageClassArray( SgKeyDatumPairStorageClass *storageArray )
  200291             :    {
  200292           0 :      unsigned long storageCounter = 0;
  200293           0 :      std::vector < unsigned char* > :: const_iterator block = SgKeyDatumPair::pools.begin();
  200294           0 :      SgKeyDatumPair* pointer = NULL;
  200295           0 :      while ( block != SgKeyDatumPair::pools.end() ) {
  200296           0 :           pointer = (SgKeyDatumPair*) (*block);
  200297           0 :           for ( unsigned i = 0; i < SgKeyDatumPair::pool_size; ++i ) {
  200298           0 :                if ( pointer->get_freepointer() != NULL ) {
  200299           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  200300           0 :                  storageArray++;
  200301           0 :                  storageCounter++;
  200302             :                }
  200303           0 :                pointer++;
  200304             :              }
  200305           0 :            block++;
  200306             :         }
  200307           0 :      return storageCounter;
  200308             :    }
  200309             : 
  200310             : /* #line 200311 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  200311             : 
  200312             : 
  200313             : 
  200314             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  200315             : 
  200316             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  200317             : 
  200318             : //############################################################################
  200319             : /* JH (02/02/2006) Constructor of the IR node SgComprehension that takes its 
  200320             :  * corresponding StorageClass as parameter
  200321             :  */
  200322           0 : SgComprehension :: SgComprehension ( const SgComprehensionStorageClass& storageSource )   : SgExpression (storageSource)
  200323             :    {
  200324             : 
  200325             : 
  200326             : /* #line 200327 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  200327             : 
  200328           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  200329           0 :      p_target =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_target) );
  200330           0 :      p_iter =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_iter) );
  200331           0 :      p_filters =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_filters) );
  200332             : 
  200333             : 
  200334             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  200335             : 
  200336             : 
  200337           0 :    }
  200338             : 
  200339             : //############################################################################
  200340             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  200341             :  * within the working AST. 
  200342             :  */
  200343           0 : SgComprehension * SgComprehension::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  200344           0 :      SgComprehension* returnPointer = NULL;
  200345           0 :      if ( globalIndex != 0 )
  200346             :         {
  200347             : 
  200348             : #if FILE_IO_EXTRA_CHECK
  200349           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgComprehension ) ) <= globalIndex ) ;
  200350           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgComprehension + 1 ) ) );
  200351             : #endif
  200352           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgComprehension )  
  200353           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgComprehension );
  200354           0 :           unsigned long positionInPool = localIndex % SgComprehension::pool_size;
  200355           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgComprehension::pool_size;
  200356             : 
  200357             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  200358             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  200359             : 
  200360           0 :           returnPointer = &( ( (SgComprehension*)(SgComprehension::pools[memoryBlock]) ) [positionInPool]) ;
  200361             : 
  200362           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  200363             :         }
  200364           0 :      return returnPointer ;
  200365             :    }
  200366             : 
  200367             : //############################################################################
  200368             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  200369             :   for the AST with the index astIndex
  200370             : */
  200371           0 : SgComprehension * SgComprehension::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  200372           0 :      SgComprehension* returnPointer = NULL;
  200373           0 :      if ( globalIndex != 0 )
  200374             :         {
  200375             : 
  200376             : #if FILE_IO_EXTRA_CHECK
  200377           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgComprehension ) ) <= globalIndex ) ;
  200378           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgComprehension + 1 ) ) );
  200379             : #endif
  200380           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgComprehension )
  200381           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgComprehension );
  200382           0 :           unsigned long positionInPool = localIndex % SgComprehension::pool_size ;
  200383           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgComprehension::pool_size ;
  200384             : 
  200385             : #if FILE_IO_EXTRA_CHECK
  200386             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  200387             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  200388             : #endif
  200389             : 
  200390           0 :           returnPointer = &( ( (SgComprehension*)(SgComprehension::pools[memoryBlock]) ) [positionInPool]) ;
  200391             : 
  200392             : #if FILE_IO_EXTRA_CHECK
  200393           0 :           assert ( returnPointer != NULL ) ;
  200394             : #endif
  200395             :         }
  200396           0 :      return returnPointer ;
  200397             :    }
  200398             : 
  200399             : //############################################################################
  200400             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  200401             :  * pool size! We set for every valid object in the memory pool the freepointer
  200402             :  * to the global index and increase the global index afterwards. For all the 
  200403             :  * invalid objects (means address ranges within the memory pool that were not
  200404             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  200405             :  * distinguish valid from invalid objects! 
  200406             :  */
  200407             : unsigned long
  200408           5 : SgComprehension::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  200409             :    {
  200410           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  200411           5 :      SgComprehension* pointer = NULL;
  200412           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  200413           5 :      std::vector < unsigned char* > :: const_iterator block;
  200414           5 :      for ( block = SgComprehension::pools.begin(); block != SgComprehension::pools.end() ; ++block )
  200415             :         {
  200416           0 :           pointer = (SgComprehension*)(*block);
  200417           0 :           for (unsigned i = 0; i < SgComprehension::pool_size; ++i )
  200418             :              {
  200419             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  200420             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  200421             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  200422             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  200423             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  200424             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  200425             :             // properly; so this will have to be checked next.
  200426             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  200427             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  200428           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  200429             :                   {
  200430           0 :                     pointer[i].set_freepointer((SgComprehension*)(globalIndex));
  200431           0 :                     globalIndex++;
  200432             :                   }
  200433             :                else
  200434             :                   {
  200435           0 :                     pointer[i].set_freepointer(NULL);
  200436             :                   }
  200437             :               }
  200438             :         }
  200439           5 :      return globalIndex;
  200440             :    }
  200441             : 
  200442             : //############################################################################
  200443             : // JH (01/14/2006)
  200444             : void
  200445           5 : SgComprehension::resetValidFreepointers( )
  200446             :    {
  200447           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  200448           5 :      SgComprehension* pointer = NULL;
  200449           5 :      std::vector < unsigned char* > :: const_iterator block;
  200450           5 :      SgComprehension* pointerOfLinkedList = NULL;
  200451           5 :      for ( block = SgComprehension::pools.begin(); block != SgComprehension::pools.end() ; ++block )
  200452             :         {
  200453           0 :           pointer = (SgComprehension*)(*block);
  200454           0 :           for (unsigned i = 0; i < SgComprehension::pool_size; ++i )
  200455             :              {
  200456             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  200457             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  200458             :             // memory blocks!.
  200459           0 :                if ( pointer[i].get_freepointer() != NULL )
  200460             :                   {
  200461           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  200462             :                   }
  200463             :                else
  200464             :                   {
  200465           0 :                     if ( pointerOfLinkedList == NULL )
  200466             :                        {
  200467           0 :                          SgComprehension::next_node = &(pointer[i]);
  200468             :                        }
  200469             :                     else
  200470             :                        {
  200471             :                       // printf ("In SgComprehension::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  200472           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  200473             :                        }
  200474             :                     pointerOfLinkedList = &(pointer[i]);
  200475             :                   }
  200476             :               }
  200477             :         }
  200478             : 
  200479           5 :      if ( pointerOfLinkedList != NULL )
  200480             :         {
  200481             :        // printf ("In SgComprehension::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  200482           0 :           pointerOfLinkedList->set_freepointer(NULL);
  200483             :        // DQ (6/6/2010): Temporary debugging...
  200484             :        //   ROSE_ASSERT(false);
  200485             :         }
  200486             : 
  200487           5 :      return ;
  200488             :    }
  200489             : 
  200490             : //############################################################################
  200491             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  200492             :  * within the memory pool and resets the freepointers, in order to achieve a 
  200493             :  * linked list, that has no jumps and starts at the beginning! This function 
  200494             :  * does not extend the memory pool, since we do not delete any memory blocks,
  200495             :  * but delete the valid objects.  
  200496             :  */
  200497             : void
  200498           0 : SgComprehension::clearMemoryPool( )
  200499             :    {
  200500             :   // printf ("Inside of SgComprehension::clearMemoryPool() \n");
  200501             : 
  200502           0 :      SgComprehension* pointer = NULL, *tempPointer = NULL;
  200503           0 :      std::vector < unsigned char* > :: const_iterator block;
  200504           0 :      if ( SgComprehension::pools.empty() == false )
  200505             :         {
  200506           0 :           block = SgComprehension::pools.begin() ;
  200507           0 :           SgComprehension::next_node = (SgComprehension*) (*block);
  200508             : 
  200509           0 :           while ( block != SgComprehension::pools.end() )
  200510             :              {
  200511           0 :                pointer = (SgComprehension*) (*block);
  200512           0 :                if ( tempPointer != NULL )
  200513             :                   {
  200514           0 :                     tempPointer->set_freepointer(pointer);
  200515             :                   }
  200516           0 :                for (unsigned i = 0; i < SgComprehension::pool_size - 1; ++i)
  200517             :                   {
  200518           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  200519             :                   }
  200520           0 :                 pointer[SgComprehension::pool_size-1].set_freepointer(NULL);
  200521           0 :                 tempPointer = &(pointer[SgComprehension::pool_size-1]);
  200522           0 :                 ++block;
  200523             :              }
  200524             :         }
  200525           0 :    }
  200526             : 
  200527           5 : void SgComprehension::deleteMemoryPool() {
  200528           5 :   for (auto p: SgComprehension::pools) {
  200529           0 :     ROSE_FREE(p);
  200530             :   }
  200531           5 :   SgComprehension::next_node = nullptr;
  200532           5 :   SgComprehension::pools.clear();
  200533           5 : }
  200534             : 
  200535             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  200536             : //                 reading multiple binary files to for a single AST.
  200537             : /////////// new version ////////////////////////////////
  200538             : //############################################################################
  200539             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  200540             : void
  200541           2 : SgComprehension::extendMemoryPoolForFileIO( )
  200542             :   {
  200543           2 :     size_t blockIndex = SgComprehension::pools.size();
  200544           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgComprehension) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgComprehension);
  200545             : 
  200546           2 :     while ( (blockIndex * SgComprehension::pool_size) < newPoolSize)
  200547             :       {
  200548             : #if ROSE_ALLOC_TRACE
  200549             :         if (blockIndex > 0) {
  200550             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgComprehension) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgComprehension) = %" PRIuPTR " SgComprehension::pool_size = %d \n",
  200551             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgComprehension),AST_FILE_IO::getPoolSizeOfNewAst(V_SgComprehension),SgComprehension::pool_size);
  200552             :         }
  200553             : #endif
  200554             : 
  200555           0 :         SgComprehension * pointer = (SgComprehension*) ROSE_MALLOC ( SgComprehension::pool_size * sizeof(SgComprehension) );
  200556           0 :         assert( pointer != NULL );
  200557             : #if ROSE_ALLOC_MEMSET == 1
  200558             :         memset(pointer, 0x00, SgComprehension::pool_size * sizeof(SgComprehension));
  200559             : #elif ROSE_ALLOC_MEMSET == 2
  200560             :         memset(pointer, 0xCC, SgComprehension::pool_size * sizeof(SgComprehension));
  200561             : #endif
  200562           0 :         SgComprehension::pools.push_back( (unsigned char*)(pointer) );
  200563           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgComprehension::pool_size * sizeof(SgComprehension), V_SgComprehension ) );
  200564             : 
  200565           0 :         if ( SgComprehension::next_node != NULL ) {
  200566           0 :           if ( blockIndex > 0 ) {
  200567           0 :             SgComprehension * blkptr = (SgComprehension*)(SgComprehension::pools[blockIndex-1]);
  200568           0 :             blkptr[ SgComprehension::pool_size - 1 ].set_freepointer(pointer);
  200569             :           }
  200570             :         } else {
  200571           0 :           SgComprehension::next_node = pointer;
  200572             :         }
  200573             : 
  200574           0 :         for (unsigned i = 0; i < SgComprehension::pool_size-1; ++i)
  200575             :            {
  200576           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  200577             :            }
  200578           0 :         pointer[ SgComprehension::pool_size -1 ].set_freepointer(NULL);
  200579             : 
  200580           0 :         blockIndex++;
  200581             :       }
  200582           2 :   }
  200583             : 
  200584             : //############################################################################
  200585             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  200586             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  200587             :  * not compressed. However, that stuff is not yet implemented! 
  200588             :  */
  200589             : unsigned long
  200590           0 : SgComprehension::getNumberOfLastValidPointer()
  200591             :    {
  200592           0 :       SgComprehension* testPointer = (SgComprehension*)(SgComprehension::pools.back());
  200593           0 :       unsigned long localIndex = SgComprehension::pool_size - 1;
  200594           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  200595             :          {
  200596           0 :            localIndex--;
  200597             :          }
  200598           0 :       return (localIndex + SgComprehension::pool_size * (SgComprehension::pools.size()-1));
  200599             :    }
  200600             : 
  200601             : //############################################################################
  200602             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  200603             :  * memory pool and initializes the data member in class SgComprehensionStroageClass
  200604             :  * from its counterpart of SgComprehension. The return value is just for checking, 
  200605             :  * that the whole StorageClassArray is initialized!
  200606             :  */
  200607             : unsigned long
  200608           0 : SgComprehension::initializeStorageClassArray( SgComprehensionStorageClass *storageArray )
  200609             :    {
  200610           0 :      unsigned long storageCounter = 0;
  200611           0 :      std::vector < unsigned char* > :: const_iterator block = SgComprehension::pools.begin();
  200612           0 :      SgComprehension* pointer = NULL;
  200613           0 :      while ( block != SgComprehension::pools.end() ) {
  200614           0 :           pointer = (SgComprehension*) (*block);
  200615           0 :           for ( unsigned i = 0; i < SgComprehension::pool_size; ++i ) {
  200616           0 :                if ( pointer->get_freepointer() != NULL ) {
  200617           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  200618           0 :                  storageArray++;
  200619           0 :                  storageCounter++;
  200620             :                }
  200621           0 :                pointer++;
  200622             :              }
  200623           0 :            block++;
  200624             :         }
  200625           0 :      return storageCounter;
  200626             :    }
  200627             : 
  200628             : /* #line 200629 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  200629             : 
  200630             : 
  200631             : 
  200632             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  200633             : 
  200634             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  200635             : 
  200636             : //############################################################################
  200637             : /* JH (02/02/2006) Constructor of the IR node SgListComprehension that takes its 
  200638             :  * corresponding StorageClass as parameter
  200639             :  */
  200640           0 : SgListComprehension :: SgListComprehension ( const SgListComprehensionStorageClass& storageSource )   : SgExpression (storageSource)
  200641             :    {
  200642             : 
  200643             : 
  200644             : /* #line 200645 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  200645             : 
  200646           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  200647           0 :      p_element =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_element) );
  200648           0 :      p_generators =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_generators) );
  200649             : 
  200650             : 
  200651             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  200652             : 
  200653             : 
  200654           0 :    }
  200655             : 
  200656             : //############################################################################
  200657             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  200658             :  * within the working AST. 
  200659             :  */
  200660           0 : SgListComprehension * SgListComprehension::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  200661           0 :      SgListComprehension* returnPointer = NULL;
  200662           0 :      if ( globalIndex != 0 )
  200663             :         {
  200664             : 
  200665             : #if FILE_IO_EXTRA_CHECK
  200666           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgListComprehension ) ) <= globalIndex ) ;
  200667           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgListComprehension + 1 ) ) );
  200668             : #endif
  200669           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgListComprehension )  
  200670           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgListComprehension );
  200671           0 :           unsigned long positionInPool = localIndex % SgListComprehension::pool_size;
  200672           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgListComprehension::pool_size;
  200673             : 
  200674             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  200675             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  200676             : 
  200677           0 :           returnPointer = &( ( (SgListComprehension*)(SgListComprehension::pools[memoryBlock]) ) [positionInPool]) ;
  200678             : 
  200679           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  200680             :         }
  200681           0 :      return returnPointer ;
  200682             :    }
  200683             : 
  200684             : //############################################################################
  200685             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  200686             :   for the AST with the index astIndex
  200687             : */
  200688           0 : SgListComprehension * SgListComprehension::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  200689           0 :      SgListComprehension* returnPointer = NULL;
  200690           0 :      if ( globalIndex != 0 )
  200691             :         {
  200692             : 
  200693             : #if FILE_IO_EXTRA_CHECK
  200694           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgListComprehension ) ) <= globalIndex ) ;
  200695           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgListComprehension + 1 ) ) );
  200696             : #endif
  200697           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgListComprehension )
  200698           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgListComprehension );
  200699           0 :           unsigned long positionInPool = localIndex % SgListComprehension::pool_size ;
  200700           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgListComprehension::pool_size ;
  200701             : 
  200702             : #if FILE_IO_EXTRA_CHECK
  200703             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  200704             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  200705             : #endif
  200706             : 
  200707           0 :           returnPointer = &( ( (SgListComprehension*)(SgListComprehension::pools[memoryBlock]) ) [positionInPool]) ;
  200708             : 
  200709             : #if FILE_IO_EXTRA_CHECK
  200710           0 :           assert ( returnPointer != NULL ) ;
  200711             : #endif
  200712             :         }
  200713           0 :      return returnPointer ;
  200714             :    }
  200715             : 
  200716             : //############################################################################
  200717             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  200718             :  * pool size! We set for every valid object in the memory pool the freepointer
  200719             :  * to the global index and increase the global index afterwards. For all the 
  200720             :  * invalid objects (means address ranges within the memory pool that were not
  200721             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  200722             :  * distinguish valid from invalid objects! 
  200723             :  */
  200724             : unsigned long
  200725           5 : SgListComprehension::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  200726             :    {
  200727           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  200728           5 :      SgListComprehension* pointer = NULL;
  200729           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  200730           5 :      std::vector < unsigned char* > :: const_iterator block;
  200731           5 :      for ( block = SgListComprehension::pools.begin(); block != SgListComprehension::pools.end() ; ++block )
  200732             :         {
  200733           0 :           pointer = (SgListComprehension*)(*block);
  200734           0 :           for (unsigned i = 0; i < SgListComprehension::pool_size; ++i )
  200735             :              {
  200736             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  200737             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  200738             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  200739             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  200740             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  200741             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  200742             :             // properly; so this will have to be checked next.
  200743             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  200744             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  200745           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  200746             :                   {
  200747           0 :                     pointer[i].set_freepointer((SgListComprehension*)(globalIndex));
  200748           0 :                     globalIndex++;
  200749             :                   }
  200750             :                else
  200751             :                   {
  200752           0 :                     pointer[i].set_freepointer(NULL);
  200753             :                   }
  200754             :               }
  200755             :         }
  200756           5 :      return globalIndex;
  200757             :    }
  200758             : 
  200759             : //############################################################################
  200760             : // JH (01/14/2006)
  200761             : void
  200762           5 : SgListComprehension::resetValidFreepointers( )
  200763             :    {
  200764           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  200765           5 :      SgListComprehension* pointer = NULL;
  200766           5 :      std::vector < unsigned char* > :: const_iterator block;
  200767           5 :      SgListComprehension* pointerOfLinkedList = NULL;
  200768           5 :      for ( block = SgListComprehension::pools.begin(); block != SgListComprehension::pools.end() ; ++block )
  200769             :         {
  200770           0 :           pointer = (SgListComprehension*)(*block);
  200771           0 :           for (unsigned i = 0; i < SgListComprehension::pool_size; ++i )
  200772             :              {
  200773             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  200774             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  200775             :             // memory blocks!.
  200776           0 :                if ( pointer[i].get_freepointer() != NULL )
  200777             :                   {
  200778           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  200779             :                   }
  200780             :                else
  200781             :                   {
  200782           0 :                     if ( pointerOfLinkedList == NULL )
  200783             :                        {
  200784           0 :                          SgListComprehension::next_node = &(pointer[i]);
  200785             :                        }
  200786             :                     else
  200787             :                        {
  200788             :                       // printf ("In SgListComprehension::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  200789           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  200790             :                        }
  200791             :                     pointerOfLinkedList = &(pointer[i]);
  200792             :                   }
  200793             :               }
  200794             :         }
  200795             : 
  200796           5 :      if ( pointerOfLinkedList != NULL )
  200797             :         {
  200798             :        // printf ("In SgListComprehension::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  200799           0 :           pointerOfLinkedList->set_freepointer(NULL);
  200800             :        // DQ (6/6/2010): Temporary debugging...
  200801             :        //   ROSE_ASSERT(false);
  200802             :         }
  200803             : 
  200804           5 :      return ;
  200805             :    }
  200806             : 
  200807             : //############################################################################
  200808             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  200809             :  * within the memory pool and resets the freepointers, in order to achieve a 
  200810             :  * linked list, that has no jumps and starts at the beginning! This function 
  200811             :  * does not extend the memory pool, since we do not delete any memory blocks,
  200812             :  * but delete the valid objects.  
  200813             :  */
  200814             : void
  200815           0 : SgListComprehension::clearMemoryPool( )
  200816             :    {
  200817             :   // printf ("Inside of SgListComprehension::clearMemoryPool() \n");
  200818             : 
  200819           0 :      SgListComprehension* pointer = NULL, *tempPointer = NULL;
  200820           0 :      std::vector < unsigned char* > :: const_iterator block;
  200821           0 :      if ( SgListComprehension::pools.empty() == false )
  200822             :         {
  200823           0 :           block = SgListComprehension::pools.begin() ;
  200824           0 :           SgListComprehension::next_node = (SgListComprehension*) (*block);
  200825             : 
  200826           0 :           while ( block != SgListComprehension::pools.end() )
  200827             :              {
  200828           0 :                pointer = (SgListComprehension*) (*block);
  200829           0 :                if ( tempPointer != NULL )
  200830             :                   {
  200831           0 :                     tempPointer->set_freepointer(pointer);
  200832             :                   }
  200833           0 :                for (unsigned i = 0; i < SgListComprehension::pool_size - 1; ++i)
  200834             :                   {
  200835           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  200836             :                   }
  200837           0 :                 pointer[SgListComprehension::pool_size-1].set_freepointer(NULL);
  200838           0 :                 tempPointer = &(pointer[SgListComprehension::pool_size-1]);
  200839           0 :                 ++block;
  200840             :              }
  200841             :         }
  200842           0 :    }
  200843             : 
  200844           5 : void SgListComprehension::deleteMemoryPool() {
  200845           5 :   for (auto p: SgListComprehension::pools) {
  200846           0 :     ROSE_FREE(p);
  200847             :   }
  200848           5 :   SgListComprehension::next_node = nullptr;
  200849           5 :   SgListComprehension::pools.clear();
  200850           5 : }
  200851             : 
  200852             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  200853             : //                 reading multiple binary files to for a single AST.
  200854             : /////////// new version ////////////////////////////////
  200855             : //############################################################################
  200856             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  200857             : void
  200858           2 : SgListComprehension::extendMemoryPoolForFileIO( )
  200859             :   {
  200860           2 :     size_t blockIndex = SgListComprehension::pools.size();
  200861           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgListComprehension) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgListComprehension);
  200862             : 
  200863           2 :     while ( (blockIndex * SgListComprehension::pool_size) < newPoolSize)
  200864             :       {
  200865             : #if ROSE_ALLOC_TRACE
  200866             :         if (blockIndex > 0) {
  200867             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgListComprehension) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgListComprehension) = %" PRIuPTR " SgListComprehension::pool_size = %d \n",
  200868             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgListComprehension),AST_FILE_IO::getPoolSizeOfNewAst(V_SgListComprehension),SgListComprehension::pool_size);
  200869             :         }
  200870             : #endif
  200871             : 
  200872           0 :         SgListComprehension * pointer = (SgListComprehension*) ROSE_MALLOC ( SgListComprehension::pool_size * sizeof(SgListComprehension) );
  200873           0 :         assert( pointer != NULL );
  200874             : #if ROSE_ALLOC_MEMSET == 1
  200875             :         memset(pointer, 0x00, SgListComprehension::pool_size * sizeof(SgListComprehension));
  200876             : #elif ROSE_ALLOC_MEMSET == 2
  200877             :         memset(pointer, 0xCC, SgListComprehension::pool_size * sizeof(SgListComprehension));
  200878             : #endif
  200879           0 :         SgListComprehension::pools.push_back( (unsigned char*)(pointer) );
  200880           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgListComprehension::pool_size * sizeof(SgListComprehension), V_SgListComprehension ) );
  200881             : 
  200882           0 :         if ( SgListComprehension::next_node != NULL ) {
  200883           0 :           if ( blockIndex > 0 ) {
  200884           0 :             SgListComprehension * blkptr = (SgListComprehension*)(SgListComprehension::pools[blockIndex-1]);
  200885           0 :             blkptr[ SgListComprehension::pool_size - 1 ].set_freepointer(pointer);
  200886             :           }
  200887             :         } else {
  200888           0 :           SgListComprehension::next_node = pointer;
  200889             :         }
  200890             : 
  200891           0 :         for (unsigned i = 0; i < SgListComprehension::pool_size-1; ++i)
  200892             :            {
  200893           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  200894             :            }
  200895           0 :         pointer[ SgListComprehension::pool_size -1 ].set_freepointer(NULL);
  200896             : 
  200897           0 :         blockIndex++;
  200898             :       }
  200899           2 :   }
  200900             : 
  200901             : //############################################################################
  200902             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  200903             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  200904             :  * not compressed. However, that stuff is not yet implemented! 
  200905             :  */
  200906             : unsigned long
  200907           0 : SgListComprehension::getNumberOfLastValidPointer()
  200908             :    {
  200909           0 :       SgListComprehension* testPointer = (SgListComprehension*)(SgListComprehension::pools.back());
  200910           0 :       unsigned long localIndex = SgListComprehension::pool_size - 1;
  200911           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  200912             :          {
  200913           0 :            localIndex--;
  200914             :          }
  200915           0 :       return (localIndex + SgListComprehension::pool_size * (SgListComprehension::pools.size()-1));
  200916             :    }
  200917             : 
  200918             : //############################################################################
  200919             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  200920             :  * memory pool and initializes the data member in class SgListComprehensionStroageClass
  200921             :  * from its counterpart of SgListComprehension. The return value is just for checking, 
  200922             :  * that the whole StorageClassArray is initialized!
  200923             :  */
  200924             : unsigned long
  200925           0 : SgListComprehension::initializeStorageClassArray( SgListComprehensionStorageClass *storageArray )
  200926             :    {
  200927           0 :      unsigned long storageCounter = 0;
  200928           0 :      std::vector < unsigned char* > :: const_iterator block = SgListComprehension::pools.begin();
  200929           0 :      SgListComprehension* pointer = NULL;
  200930           0 :      while ( block != SgListComprehension::pools.end() ) {
  200931           0 :           pointer = (SgListComprehension*) (*block);
  200932           0 :           for ( unsigned i = 0; i < SgListComprehension::pool_size; ++i ) {
  200933           0 :                if ( pointer->get_freepointer() != NULL ) {
  200934           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  200935           0 :                  storageArray++;
  200936           0 :                  storageCounter++;
  200937             :                }
  200938           0 :                pointer++;
  200939             :              }
  200940           0 :            block++;
  200941             :         }
  200942           0 :      return storageCounter;
  200943             :    }
  200944             : 
  200945             : /* #line 200946 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  200946             : 
  200947             : 
  200948             : 
  200949             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  200950             : 
  200951             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  200952             : 
  200953             : //############################################################################
  200954             : /* JH (02/02/2006) Constructor of the IR node SgSetComprehension that takes its 
  200955             :  * corresponding StorageClass as parameter
  200956             :  */
  200957           0 : SgSetComprehension :: SgSetComprehension ( const SgSetComprehensionStorageClass& storageSource )   : SgExpression (storageSource)
  200958             :    {
  200959             : 
  200960             : 
  200961             : /* #line 200962 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  200962             : 
  200963           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  200964           0 :      p_element =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_element) );
  200965           0 :      p_generators =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_generators) );
  200966             : 
  200967             : 
  200968             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  200969             : 
  200970             : 
  200971           0 :    }
  200972             : 
  200973             : //############################################################################
  200974             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  200975             :  * within the working AST. 
  200976             :  */
  200977           0 : SgSetComprehension * SgSetComprehension::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  200978           0 :      SgSetComprehension* returnPointer = NULL;
  200979           0 :      if ( globalIndex != 0 )
  200980             :         {
  200981             : 
  200982             : #if FILE_IO_EXTRA_CHECK
  200983           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSetComprehension ) ) <= globalIndex ) ;
  200984           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSetComprehension + 1 ) ) );
  200985             : #endif
  200986           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSetComprehension )  
  200987           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSetComprehension );
  200988           0 :           unsigned long positionInPool = localIndex % SgSetComprehension::pool_size;
  200989           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSetComprehension::pool_size;
  200990             : 
  200991             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  200992             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  200993             : 
  200994           0 :           returnPointer = &( ( (SgSetComprehension*)(SgSetComprehension::pools[memoryBlock]) ) [positionInPool]) ;
  200995             : 
  200996           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  200997             :         }
  200998           0 :      return returnPointer ;
  200999             :    }
  201000             : 
  201001             : //############################################################################
  201002             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  201003             :   for the AST with the index astIndex
  201004             : */
  201005           0 : SgSetComprehension * SgSetComprehension::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  201006           0 :      SgSetComprehension* returnPointer = NULL;
  201007           0 :      if ( globalIndex != 0 )
  201008             :         {
  201009             : 
  201010             : #if FILE_IO_EXTRA_CHECK
  201011           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSetComprehension ) ) <= globalIndex ) ;
  201012           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSetComprehension + 1 ) ) );
  201013             : #endif
  201014           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSetComprehension )
  201015           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSetComprehension );
  201016           0 :           unsigned long positionInPool = localIndex % SgSetComprehension::pool_size ;
  201017           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSetComprehension::pool_size ;
  201018             : 
  201019             : #if FILE_IO_EXTRA_CHECK
  201020             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  201021             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  201022             : #endif
  201023             : 
  201024           0 :           returnPointer = &( ( (SgSetComprehension*)(SgSetComprehension::pools[memoryBlock]) ) [positionInPool]) ;
  201025             : 
  201026             : #if FILE_IO_EXTRA_CHECK
  201027           0 :           assert ( returnPointer != NULL ) ;
  201028             : #endif
  201029             :         }
  201030           0 :      return returnPointer ;
  201031             :    }
  201032             : 
  201033             : //############################################################################
  201034             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  201035             :  * pool size! We set for every valid object in the memory pool the freepointer
  201036             :  * to the global index and increase the global index afterwards. For all the 
  201037             :  * invalid objects (means address ranges within the memory pool that were not
  201038             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  201039             :  * distinguish valid from invalid objects! 
  201040             :  */
  201041             : unsigned long
  201042           5 : SgSetComprehension::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  201043             :    {
  201044           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  201045           5 :      SgSetComprehension* pointer = NULL;
  201046           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  201047           5 :      std::vector < unsigned char* > :: const_iterator block;
  201048           5 :      for ( block = SgSetComprehension::pools.begin(); block != SgSetComprehension::pools.end() ; ++block )
  201049             :         {
  201050           0 :           pointer = (SgSetComprehension*)(*block);
  201051           0 :           for (unsigned i = 0; i < SgSetComprehension::pool_size; ++i )
  201052             :              {
  201053             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  201054             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  201055             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  201056             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  201057             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  201058             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  201059             :             // properly; so this will have to be checked next.
  201060             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  201061             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  201062           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  201063             :                   {
  201064           0 :                     pointer[i].set_freepointer((SgSetComprehension*)(globalIndex));
  201065           0 :                     globalIndex++;
  201066             :                   }
  201067             :                else
  201068             :                   {
  201069           0 :                     pointer[i].set_freepointer(NULL);
  201070             :                   }
  201071             :               }
  201072             :         }
  201073           5 :      return globalIndex;
  201074             :    }
  201075             : 
  201076             : //############################################################################
  201077             : // JH (01/14/2006)
  201078             : void
  201079           5 : SgSetComprehension::resetValidFreepointers( )
  201080             :    {
  201081           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  201082           5 :      SgSetComprehension* pointer = NULL;
  201083           5 :      std::vector < unsigned char* > :: const_iterator block;
  201084           5 :      SgSetComprehension* pointerOfLinkedList = NULL;
  201085           5 :      for ( block = SgSetComprehension::pools.begin(); block != SgSetComprehension::pools.end() ; ++block )
  201086             :         {
  201087           0 :           pointer = (SgSetComprehension*)(*block);
  201088           0 :           for (unsigned i = 0; i < SgSetComprehension::pool_size; ++i )
  201089             :              {
  201090             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  201091             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  201092             :             // memory blocks!.
  201093           0 :                if ( pointer[i].get_freepointer() != NULL )
  201094             :                   {
  201095           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  201096             :                   }
  201097             :                else
  201098             :                   {
  201099           0 :                     if ( pointerOfLinkedList == NULL )
  201100             :                        {
  201101           0 :                          SgSetComprehension::next_node = &(pointer[i]);
  201102             :                        }
  201103             :                     else
  201104             :                        {
  201105             :                       // printf ("In SgSetComprehension::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  201106           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  201107             :                        }
  201108             :                     pointerOfLinkedList = &(pointer[i]);
  201109             :                   }
  201110             :               }
  201111             :         }
  201112             : 
  201113           5 :      if ( pointerOfLinkedList != NULL )
  201114             :         {
  201115             :        // printf ("In SgSetComprehension::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  201116           0 :           pointerOfLinkedList->set_freepointer(NULL);
  201117             :        // DQ (6/6/2010): Temporary debugging...
  201118             :        //   ROSE_ASSERT(false);
  201119             :         }
  201120             : 
  201121           5 :      return ;
  201122             :    }
  201123             : 
  201124             : //############################################################################
  201125             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  201126             :  * within the memory pool and resets the freepointers, in order to achieve a 
  201127             :  * linked list, that has no jumps and starts at the beginning! This function 
  201128             :  * does not extend the memory pool, since we do not delete any memory blocks,
  201129             :  * but delete the valid objects.  
  201130             :  */
  201131             : void
  201132           0 : SgSetComprehension::clearMemoryPool( )
  201133             :    {
  201134             :   // printf ("Inside of SgSetComprehension::clearMemoryPool() \n");
  201135             : 
  201136           0 :      SgSetComprehension* pointer = NULL, *tempPointer = NULL;
  201137           0 :      std::vector < unsigned char* > :: const_iterator block;
  201138           0 :      if ( SgSetComprehension::pools.empty() == false )
  201139             :         {
  201140           0 :           block = SgSetComprehension::pools.begin() ;
  201141           0 :           SgSetComprehension::next_node = (SgSetComprehension*) (*block);
  201142             : 
  201143           0 :           while ( block != SgSetComprehension::pools.end() )
  201144             :              {
  201145           0 :                pointer = (SgSetComprehension*) (*block);
  201146           0 :                if ( tempPointer != NULL )
  201147             :                   {
  201148           0 :                     tempPointer->set_freepointer(pointer);
  201149             :                   }
  201150           0 :                for (unsigned i = 0; i < SgSetComprehension::pool_size - 1; ++i)
  201151             :                   {
  201152           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  201153             :                   }
  201154           0 :                 pointer[SgSetComprehension::pool_size-1].set_freepointer(NULL);
  201155           0 :                 tempPointer = &(pointer[SgSetComprehension::pool_size-1]);
  201156           0 :                 ++block;
  201157             :              }
  201158             :         }
  201159           0 :    }
  201160             : 
  201161           5 : void SgSetComprehension::deleteMemoryPool() {
  201162           5 :   for (auto p: SgSetComprehension::pools) {
  201163           0 :     ROSE_FREE(p);
  201164             :   }
  201165           5 :   SgSetComprehension::next_node = nullptr;
  201166           5 :   SgSetComprehension::pools.clear();
  201167           5 : }
  201168             : 
  201169             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  201170             : //                 reading multiple binary files to for a single AST.
  201171             : /////////// new version ////////////////////////////////
  201172             : //############################################################################
  201173             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  201174             : void
  201175           2 : SgSetComprehension::extendMemoryPoolForFileIO( )
  201176             :   {
  201177           2 :     size_t blockIndex = SgSetComprehension::pools.size();
  201178           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSetComprehension) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSetComprehension);
  201179             : 
  201180           2 :     while ( (blockIndex * SgSetComprehension::pool_size) < newPoolSize)
  201181             :       {
  201182             : #if ROSE_ALLOC_TRACE
  201183             :         if (blockIndex > 0) {
  201184             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSetComprehension) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSetComprehension) = %" PRIuPTR " SgSetComprehension::pool_size = %d \n",
  201185             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSetComprehension),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSetComprehension),SgSetComprehension::pool_size);
  201186             :         }
  201187             : #endif
  201188             : 
  201189           0 :         SgSetComprehension * pointer = (SgSetComprehension*) ROSE_MALLOC ( SgSetComprehension::pool_size * sizeof(SgSetComprehension) );
  201190           0 :         assert( pointer != NULL );
  201191             : #if ROSE_ALLOC_MEMSET == 1
  201192             :         memset(pointer, 0x00, SgSetComprehension::pool_size * sizeof(SgSetComprehension));
  201193             : #elif ROSE_ALLOC_MEMSET == 2
  201194             :         memset(pointer, 0xCC, SgSetComprehension::pool_size * sizeof(SgSetComprehension));
  201195             : #endif
  201196           0 :         SgSetComprehension::pools.push_back( (unsigned char*)(pointer) );
  201197           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSetComprehension::pool_size * sizeof(SgSetComprehension), V_SgSetComprehension ) );
  201198             : 
  201199           0 :         if ( SgSetComprehension::next_node != NULL ) {
  201200           0 :           if ( blockIndex > 0 ) {
  201201           0 :             SgSetComprehension * blkptr = (SgSetComprehension*)(SgSetComprehension::pools[blockIndex-1]);
  201202           0 :             blkptr[ SgSetComprehension::pool_size - 1 ].set_freepointer(pointer);
  201203             :           }
  201204             :         } else {
  201205           0 :           SgSetComprehension::next_node = pointer;
  201206             :         }
  201207             : 
  201208           0 :         for (unsigned i = 0; i < SgSetComprehension::pool_size-1; ++i)
  201209             :            {
  201210           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  201211             :            }
  201212           0 :         pointer[ SgSetComprehension::pool_size -1 ].set_freepointer(NULL);
  201213             : 
  201214           0 :         blockIndex++;
  201215             :       }
  201216           2 :   }
  201217             : 
  201218             : //############################################################################
  201219             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  201220             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  201221             :  * not compressed. However, that stuff is not yet implemented! 
  201222             :  */
  201223             : unsigned long
  201224           0 : SgSetComprehension::getNumberOfLastValidPointer()
  201225             :    {
  201226           0 :       SgSetComprehension* testPointer = (SgSetComprehension*)(SgSetComprehension::pools.back());
  201227           0 :       unsigned long localIndex = SgSetComprehension::pool_size - 1;
  201228           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  201229             :          {
  201230           0 :            localIndex--;
  201231             :          }
  201232           0 :       return (localIndex + SgSetComprehension::pool_size * (SgSetComprehension::pools.size()-1));
  201233             :    }
  201234             : 
  201235             : //############################################################################
  201236             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  201237             :  * memory pool and initializes the data member in class SgSetComprehensionStroageClass
  201238             :  * from its counterpart of SgSetComprehension. The return value is just for checking, 
  201239             :  * that the whole StorageClassArray is initialized!
  201240             :  */
  201241             : unsigned long
  201242           0 : SgSetComprehension::initializeStorageClassArray( SgSetComprehensionStorageClass *storageArray )
  201243             :    {
  201244           0 :      unsigned long storageCounter = 0;
  201245           0 :      std::vector < unsigned char* > :: const_iterator block = SgSetComprehension::pools.begin();
  201246           0 :      SgSetComprehension* pointer = NULL;
  201247           0 :      while ( block != SgSetComprehension::pools.end() ) {
  201248           0 :           pointer = (SgSetComprehension*) (*block);
  201249           0 :           for ( unsigned i = 0; i < SgSetComprehension::pool_size; ++i ) {
  201250           0 :                if ( pointer->get_freepointer() != NULL ) {
  201251           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  201252           0 :                  storageArray++;
  201253           0 :                  storageCounter++;
  201254             :                }
  201255           0 :                pointer++;
  201256             :              }
  201257           0 :            block++;
  201258             :         }
  201259           0 :      return storageCounter;
  201260             :    }
  201261             : 
  201262             : /* #line 201263 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  201263             : 
  201264             : 
  201265             : 
  201266             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  201267             : 
  201268             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  201269             : 
  201270             : //############################################################################
  201271             : /* JH (02/02/2006) Constructor of the IR node SgDictionaryComprehension that takes its 
  201272             :  * corresponding StorageClass as parameter
  201273             :  */
  201274           0 : SgDictionaryComprehension :: SgDictionaryComprehension ( const SgDictionaryComprehensionStorageClass& storageSource )   : SgExpression (storageSource)
  201275             :    {
  201276             : 
  201277             : 
  201278             : /* #line 201279 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  201279             : 
  201280           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  201281           0 :      p_element =  (SgKeyDatumPair*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_element) );
  201282           0 :      p_generators =  (SgExprListExp*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_generators) );
  201283             : 
  201284             : 
  201285             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  201286             : 
  201287             : 
  201288           0 :    }
  201289             : 
  201290             : //############################################################################
  201291             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  201292             :  * within the working AST. 
  201293             :  */
  201294           0 : SgDictionaryComprehension * SgDictionaryComprehension::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  201295           0 :      SgDictionaryComprehension* returnPointer = NULL;
  201296           0 :      if ( globalIndex != 0 )
  201297             :         {
  201298             : 
  201299             : #if FILE_IO_EXTRA_CHECK
  201300           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDictionaryComprehension ) ) <= globalIndex ) ;
  201301           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDictionaryComprehension + 1 ) ) );
  201302             : #endif
  201303           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDictionaryComprehension )  
  201304           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDictionaryComprehension );
  201305           0 :           unsigned long positionInPool = localIndex % SgDictionaryComprehension::pool_size;
  201306           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDictionaryComprehension::pool_size;
  201307             : 
  201308             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  201309             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  201310             : 
  201311           0 :           returnPointer = &( ( (SgDictionaryComprehension*)(SgDictionaryComprehension::pools[memoryBlock]) ) [positionInPool]) ;
  201312             : 
  201313           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  201314             :         }
  201315           0 :      return returnPointer ;
  201316             :    }
  201317             : 
  201318             : //############################################################################
  201319             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  201320             :   for the AST with the index astIndex
  201321             : */
  201322           0 : SgDictionaryComprehension * SgDictionaryComprehension::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  201323           0 :      SgDictionaryComprehension* returnPointer = NULL;
  201324           0 :      if ( globalIndex != 0 )
  201325             :         {
  201326             : 
  201327             : #if FILE_IO_EXTRA_CHECK
  201328           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDictionaryComprehension ) ) <= globalIndex ) ;
  201329           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDictionaryComprehension + 1 ) ) );
  201330             : #endif
  201331           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDictionaryComprehension )
  201332           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDictionaryComprehension );
  201333           0 :           unsigned long positionInPool = localIndex % SgDictionaryComprehension::pool_size ;
  201334           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDictionaryComprehension::pool_size ;
  201335             : 
  201336             : #if FILE_IO_EXTRA_CHECK
  201337             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  201338             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  201339             : #endif
  201340             : 
  201341           0 :           returnPointer = &( ( (SgDictionaryComprehension*)(SgDictionaryComprehension::pools[memoryBlock]) ) [positionInPool]) ;
  201342             : 
  201343             : #if FILE_IO_EXTRA_CHECK
  201344           0 :           assert ( returnPointer != NULL ) ;
  201345             : #endif
  201346             :         }
  201347           0 :      return returnPointer ;
  201348             :    }
  201349             : 
  201350             : //############################################################################
  201351             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  201352             :  * pool size! We set for every valid object in the memory pool the freepointer
  201353             :  * to the global index and increase the global index afterwards. For all the 
  201354             :  * invalid objects (means address ranges within the memory pool that were not
  201355             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  201356             :  * distinguish valid from invalid objects! 
  201357             :  */
  201358             : unsigned long
  201359           5 : SgDictionaryComprehension::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  201360             :    {
  201361           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  201362           5 :      SgDictionaryComprehension* pointer = NULL;
  201363           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  201364           5 :      std::vector < unsigned char* > :: const_iterator block;
  201365           5 :      for ( block = SgDictionaryComprehension::pools.begin(); block != SgDictionaryComprehension::pools.end() ; ++block )
  201366             :         {
  201367           0 :           pointer = (SgDictionaryComprehension*)(*block);
  201368           0 :           for (unsigned i = 0; i < SgDictionaryComprehension::pool_size; ++i )
  201369             :              {
  201370             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  201371             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  201372             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  201373             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  201374             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  201375             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  201376             :             // properly; so this will have to be checked next.
  201377             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  201378             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  201379           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  201380             :                   {
  201381           0 :                     pointer[i].set_freepointer((SgDictionaryComprehension*)(globalIndex));
  201382           0 :                     globalIndex++;
  201383             :                   }
  201384             :                else
  201385             :                   {
  201386           0 :                     pointer[i].set_freepointer(NULL);
  201387             :                   }
  201388             :               }
  201389             :         }
  201390           5 :      return globalIndex;
  201391             :    }
  201392             : 
  201393             : //############################################################################
  201394             : // JH (01/14/2006)
  201395             : void
  201396           5 : SgDictionaryComprehension::resetValidFreepointers( )
  201397             :    {
  201398           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  201399           5 :      SgDictionaryComprehension* pointer = NULL;
  201400           5 :      std::vector < unsigned char* > :: const_iterator block;
  201401           5 :      SgDictionaryComprehension* pointerOfLinkedList = NULL;
  201402           5 :      for ( block = SgDictionaryComprehension::pools.begin(); block != SgDictionaryComprehension::pools.end() ; ++block )
  201403             :         {
  201404           0 :           pointer = (SgDictionaryComprehension*)(*block);
  201405           0 :           for (unsigned i = 0; i < SgDictionaryComprehension::pool_size; ++i )
  201406             :              {
  201407             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  201408             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  201409             :             // memory blocks!.
  201410           0 :                if ( pointer[i].get_freepointer() != NULL )
  201411             :                   {
  201412           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  201413             :                   }
  201414             :                else
  201415             :                   {
  201416           0 :                     if ( pointerOfLinkedList == NULL )
  201417             :                        {
  201418           0 :                          SgDictionaryComprehension::next_node = &(pointer[i]);
  201419             :                        }
  201420             :                     else
  201421             :                        {
  201422             :                       // printf ("In SgDictionaryComprehension::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  201423           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  201424             :                        }
  201425             :                     pointerOfLinkedList = &(pointer[i]);
  201426             :                   }
  201427             :               }
  201428             :         }
  201429             : 
  201430           5 :      if ( pointerOfLinkedList != NULL )
  201431             :         {
  201432             :        // printf ("In SgDictionaryComprehension::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  201433           0 :           pointerOfLinkedList->set_freepointer(NULL);
  201434             :        // DQ (6/6/2010): Temporary debugging...
  201435             :        //   ROSE_ASSERT(false);
  201436             :         }
  201437             : 
  201438           5 :      return ;
  201439             :    }
  201440             : 
  201441             : //############################################################################
  201442             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  201443             :  * within the memory pool and resets the freepointers, in order to achieve a 
  201444             :  * linked list, that has no jumps and starts at the beginning! This function 
  201445             :  * does not extend the memory pool, since we do not delete any memory blocks,
  201446             :  * but delete the valid objects.  
  201447             :  */
  201448             : void
  201449           0 : SgDictionaryComprehension::clearMemoryPool( )
  201450             :    {
  201451             :   // printf ("Inside of SgDictionaryComprehension::clearMemoryPool() \n");
  201452             : 
  201453           0 :      SgDictionaryComprehension* pointer = NULL, *tempPointer = NULL;
  201454           0 :      std::vector < unsigned char* > :: const_iterator block;
  201455           0 :      if ( SgDictionaryComprehension::pools.empty() == false )
  201456             :         {
  201457           0 :           block = SgDictionaryComprehension::pools.begin() ;
  201458           0 :           SgDictionaryComprehension::next_node = (SgDictionaryComprehension*) (*block);
  201459             : 
  201460           0 :           while ( block != SgDictionaryComprehension::pools.end() )
  201461             :              {
  201462           0 :                pointer = (SgDictionaryComprehension*) (*block);
  201463           0 :                if ( tempPointer != NULL )
  201464             :                   {
  201465           0 :                     tempPointer->set_freepointer(pointer);
  201466             :                   }
  201467           0 :                for (unsigned i = 0; i < SgDictionaryComprehension::pool_size - 1; ++i)
  201468             :                   {
  201469           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  201470             :                   }
  201471           0 :                 pointer[SgDictionaryComprehension::pool_size-1].set_freepointer(NULL);
  201472           0 :                 tempPointer = &(pointer[SgDictionaryComprehension::pool_size-1]);
  201473           0 :                 ++block;
  201474             :              }
  201475             :         }
  201476           0 :    }
  201477             : 
  201478           5 : void SgDictionaryComprehension::deleteMemoryPool() {
  201479           5 :   for (auto p: SgDictionaryComprehension::pools) {
  201480           0 :     ROSE_FREE(p);
  201481             :   }
  201482           5 :   SgDictionaryComprehension::next_node = nullptr;
  201483           5 :   SgDictionaryComprehension::pools.clear();
  201484           5 : }
  201485             : 
  201486             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  201487             : //                 reading multiple binary files to for a single AST.
  201488             : /////////// new version ////////////////////////////////
  201489             : //############################################################################
  201490             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  201491             : void
  201492           2 : SgDictionaryComprehension::extendMemoryPoolForFileIO( )
  201493             :   {
  201494           2 :     size_t blockIndex = SgDictionaryComprehension::pools.size();
  201495           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDictionaryComprehension) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDictionaryComprehension);
  201496             : 
  201497           2 :     while ( (blockIndex * SgDictionaryComprehension::pool_size) < newPoolSize)
  201498             :       {
  201499             : #if ROSE_ALLOC_TRACE
  201500             :         if (blockIndex > 0) {
  201501             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDictionaryComprehension) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDictionaryComprehension) = %" PRIuPTR " SgDictionaryComprehension::pool_size = %d \n",
  201502             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDictionaryComprehension),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDictionaryComprehension),SgDictionaryComprehension::pool_size);
  201503             :         }
  201504             : #endif
  201505             : 
  201506           0 :         SgDictionaryComprehension * pointer = (SgDictionaryComprehension*) ROSE_MALLOC ( SgDictionaryComprehension::pool_size * sizeof(SgDictionaryComprehension) );
  201507           0 :         assert( pointer != NULL );
  201508             : #if ROSE_ALLOC_MEMSET == 1
  201509             :         memset(pointer, 0x00, SgDictionaryComprehension::pool_size * sizeof(SgDictionaryComprehension));
  201510             : #elif ROSE_ALLOC_MEMSET == 2
  201511             :         memset(pointer, 0xCC, SgDictionaryComprehension::pool_size * sizeof(SgDictionaryComprehension));
  201512             : #endif
  201513           0 :         SgDictionaryComprehension::pools.push_back( (unsigned char*)(pointer) );
  201514           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDictionaryComprehension::pool_size * sizeof(SgDictionaryComprehension), V_SgDictionaryComprehension ) );
  201515             : 
  201516           0 :         if ( SgDictionaryComprehension::next_node != NULL ) {
  201517           0 :           if ( blockIndex > 0 ) {
  201518           0 :             SgDictionaryComprehension * blkptr = (SgDictionaryComprehension*)(SgDictionaryComprehension::pools[blockIndex-1]);
  201519           0 :             blkptr[ SgDictionaryComprehension::pool_size - 1 ].set_freepointer(pointer);
  201520             :           }
  201521             :         } else {
  201522           0 :           SgDictionaryComprehension::next_node = pointer;
  201523             :         }
  201524             : 
  201525           0 :         for (unsigned i = 0; i < SgDictionaryComprehension::pool_size-1; ++i)
  201526             :            {
  201527           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  201528             :            }
  201529           0 :         pointer[ SgDictionaryComprehension::pool_size -1 ].set_freepointer(NULL);
  201530             : 
  201531           0 :         blockIndex++;
  201532             :       }
  201533           2 :   }
  201534             : 
  201535             : //############################################################################
  201536             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  201537             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  201538             :  * not compressed. However, that stuff is not yet implemented! 
  201539             :  */
  201540             : unsigned long
  201541           0 : SgDictionaryComprehension::getNumberOfLastValidPointer()
  201542             :    {
  201543           0 :       SgDictionaryComprehension* testPointer = (SgDictionaryComprehension*)(SgDictionaryComprehension::pools.back());
  201544           0 :       unsigned long localIndex = SgDictionaryComprehension::pool_size - 1;
  201545           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  201546             :          {
  201547           0 :            localIndex--;
  201548             :          }
  201549           0 :       return (localIndex + SgDictionaryComprehension::pool_size * (SgDictionaryComprehension::pools.size()-1));
  201550             :    }
  201551             : 
  201552             : //############################################################################
  201553             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  201554             :  * memory pool and initializes the data member in class SgDictionaryComprehensionStroageClass
  201555             :  * from its counterpart of SgDictionaryComprehension. The return value is just for checking, 
  201556             :  * that the whole StorageClassArray is initialized!
  201557             :  */
  201558             : unsigned long
  201559           0 : SgDictionaryComprehension::initializeStorageClassArray( SgDictionaryComprehensionStorageClass *storageArray )
  201560             :    {
  201561           0 :      unsigned long storageCounter = 0;
  201562           0 :      std::vector < unsigned char* > :: const_iterator block = SgDictionaryComprehension::pools.begin();
  201563           0 :      SgDictionaryComprehension* pointer = NULL;
  201564           0 :      while ( block != SgDictionaryComprehension::pools.end() ) {
  201565           0 :           pointer = (SgDictionaryComprehension*) (*block);
  201566           0 :           for ( unsigned i = 0; i < SgDictionaryComprehension::pool_size; ++i ) {
  201567           0 :                if ( pointer->get_freepointer() != NULL ) {
  201568           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  201569           0 :                  storageArray++;
  201570           0 :                  storageCounter++;
  201571             :                }
  201572           0 :                pointer++;
  201573             :              }
  201574           0 :            block++;
  201575             :         }
  201576           0 :      return storageCounter;
  201577             :    }
  201578             : 
  201579             : /* #line 201580 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  201580             : 
  201581             : 
  201582             : 
  201583             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  201584             : 
  201585             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  201586             : 
  201587             : //############################################################################
  201588             : /* JH (02/02/2006) Constructor of the IR node SgNaryOp that takes its 
  201589             :  * corresponding StorageClass as parameter
  201590             :  */
  201591           0 : SgNaryOp :: SgNaryOp ( const SgNaryOpStorageClass& storageSource )   : SgExpression (storageSource)
  201592             :    {
  201593             : 
  201594             : 
  201595             : /* #line 201596 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  201596             : 
  201597           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  201598           0 :      p_operands = storageSource.storageOf_operands.rebuildDataStoredInEasyStorageClass() ;
  201599           0 :      SgExpressionPtrList::iterator i_operands = p_operands.begin() ; 
  201600           0 :      for ( ; i_operands != p_operands.end(); ++i_operands ) 
  201601             :         {
  201602           0 :           (*i_operands) = (SgExpressionPtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_operands) ) );
  201603             :         }
  201604           0 :      p_operators = storageSource.storageOf_operators.rebuildDataStoredInEasyStorageClass() ;
  201605             : 
  201606             : 
  201607             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  201608             : 
  201609             : 
  201610           0 :    }
  201611             : 
  201612             : //############################################################################
  201613             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  201614             :  * within the working AST. 
  201615             :  */
  201616           0 : SgNaryOp * SgNaryOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  201617           0 :      SgNaryOp* returnPointer = NULL;
  201618           0 :      if ( globalIndex != 0 )
  201619             :         {
  201620             : 
  201621             : #if FILE_IO_EXTRA_CHECK
  201622           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNaryOp ) ) <= globalIndex ) ;
  201623           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNaryOp + 1 ) ) );
  201624             : #endif
  201625           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNaryOp )  
  201626           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNaryOp );
  201627           0 :           unsigned long positionInPool = localIndex % SgNaryOp::pool_size;
  201628           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNaryOp::pool_size;
  201629             : 
  201630             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  201631             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  201632             : 
  201633           0 :           returnPointer = &( ( (SgNaryOp*)(SgNaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  201634             : 
  201635           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  201636             :         }
  201637           0 :      return returnPointer ;
  201638             :    }
  201639             : 
  201640             : //############################################################################
  201641             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  201642             :   for the AST with the index astIndex
  201643             : */
  201644           0 : SgNaryOp * SgNaryOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  201645           0 :      SgNaryOp* returnPointer = NULL;
  201646           0 :      if ( globalIndex != 0 )
  201647             :         {
  201648             : 
  201649             : #if FILE_IO_EXTRA_CHECK
  201650           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNaryOp ) ) <= globalIndex ) ;
  201651           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNaryOp + 1 ) ) );
  201652             : #endif
  201653           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNaryOp )
  201654           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNaryOp );
  201655           0 :           unsigned long positionInPool = localIndex % SgNaryOp::pool_size ;
  201656           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNaryOp::pool_size ;
  201657             : 
  201658             : #if FILE_IO_EXTRA_CHECK
  201659             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  201660             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  201661             : #endif
  201662             : 
  201663           0 :           returnPointer = &( ( (SgNaryOp*)(SgNaryOp::pools[memoryBlock]) ) [positionInPool]) ;
  201664             : 
  201665             : #if FILE_IO_EXTRA_CHECK
  201666           0 :           assert ( returnPointer != NULL ) ;
  201667             : #endif
  201668             :         }
  201669           0 :      return returnPointer ;
  201670             :    }
  201671             : 
  201672             : //############################################################################
  201673             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  201674             :  * pool size! We set for every valid object in the memory pool the freepointer
  201675             :  * to the global index and increase the global index afterwards. For all the 
  201676             :  * invalid objects (means address ranges within the memory pool that were not
  201677             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  201678             :  * distinguish valid from invalid objects! 
  201679             :  */
  201680             : unsigned long
  201681           5 : SgNaryOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  201682             :    {
  201683           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  201684           5 :      SgNaryOp* pointer = NULL;
  201685           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  201686           5 :      std::vector < unsigned char* > :: const_iterator block;
  201687           5 :      for ( block = SgNaryOp::pools.begin(); block != SgNaryOp::pools.end() ; ++block )
  201688             :         {
  201689           0 :           pointer = (SgNaryOp*)(*block);
  201690           0 :           for (unsigned i = 0; i < SgNaryOp::pool_size; ++i )
  201691             :              {
  201692             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  201693             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  201694             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  201695             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  201696             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  201697             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  201698             :             // properly; so this will have to be checked next.
  201699             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  201700             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  201701           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  201702             :                   {
  201703           0 :                     pointer[i].set_freepointer((SgNaryOp*)(globalIndex));
  201704           0 :                     globalIndex++;
  201705             :                   }
  201706             :                else
  201707             :                   {
  201708           0 :                     pointer[i].set_freepointer(NULL);
  201709             :                   }
  201710             :               }
  201711             :         }
  201712           5 :      return globalIndex;
  201713             :    }
  201714             : 
  201715             : //############################################################################
  201716             : // JH (01/14/2006)
  201717             : void
  201718           5 : SgNaryOp::resetValidFreepointers( )
  201719             :    {
  201720           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  201721           5 :      SgNaryOp* pointer = NULL;
  201722           5 :      std::vector < unsigned char* > :: const_iterator block;
  201723           5 :      SgNaryOp* pointerOfLinkedList = NULL;
  201724           5 :      for ( block = SgNaryOp::pools.begin(); block != SgNaryOp::pools.end() ; ++block )
  201725             :         {
  201726           0 :           pointer = (SgNaryOp*)(*block);
  201727           0 :           for (unsigned i = 0; i < SgNaryOp::pool_size; ++i )
  201728             :              {
  201729             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  201730             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  201731             :             // memory blocks!.
  201732           0 :                if ( pointer[i].get_freepointer() != NULL )
  201733             :                   {
  201734           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  201735             :                   }
  201736             :                else
  201737             :                   {
  201738           0 :                     if ( pointerOfLinkedList == NULL )
  201739             :                        {
  201740           0 :                          SgNaryOp::next_node = &(pointer[i]);
  201741             :                        }
  201742             :                     else
  201743             :                        {
  201744             :                       // printf ("In SgNaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  201745           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  201746             :                        }
  201747             :                     pointerOfLinkedList = &(pointer[i]);
  201748             :                   }
  201749             :               }
  201750             :         }
  201751             : 
  201752           5 :      if ( pointerOfLinkedList != NULL )
  201753             :         {
  201754             :        // printf ("In SgNaryOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  201755           0 :           pointerOfLinkedList->set_freepointer(NULL);
  201756             :        // DQ (6/6/2010): Temporary debugging...
  201757             :        //   ROSE_ASSERT(false);
  201758             :         }
  201759             : 
  201760           5 :      return ;
  201761             :    }
  201762             : 
  201763             : //############################################################################
  201764             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  201765             :  * within the memory pool and resets the freepointers, in order to achieve a 
  201766             :  * linked list, that has no jumps and starts at the beginning! This function 
  201767             :  * does not extend the memory pool, since we do not delete any memory blocks,
  201768             :  * but delete the valid objects.  
  201769             :  */
  201770             : void
  201771           0 : SgNaryOp::clearMemoryPool( )
  201772             :    {
  201773             :   // printf ("Inside of SgNaryOp::clearMemoryPool() \n");
  201774             : 
  201775           0 :      SgNaryOp* pointer = NULL, *tempPointer = NULL;
  201776           0 :      std::vector < unsigned char* > :: const_iterator block;
  201777           0 :      if ( SgNaryOp::pools.empty() == false )
  201778             :         {
  201779           0 :           block = SgNaryOp::pools.begin() ;
  201780           0 :           SgNaryOp::next_node = (SgNaryOp*) (*block);
  201781             : 
  201782           0 :           while ( block != SgNaryOp::pools.end() )
  201783             :              {
  201784           0 :                pointer = (SgNaryOp*) (*block);
  201785           0 :                if ( tempPointer != NULL )
  201786             :                   {
  201787           0 :                     tempPointer->set_freepointer(pointer);
  201788             :                   }
  201789           0 :                for (unsigned i = 0; i < SgNaryOp::pool_size - 1; ++i)
  201790             :                   {
  201791           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  201792             :                   }
  201793           0 :                 pointer[SgNaryOp::pool_size-1].set_freepointer(NULL);
  201794           0 :                 tempPointer = &(pointer[SgNaryOp::pool_size-1]);
  201795           0 :                 ++block;
  201796             :              }
  201797             :         }
  201798           0 :    }
  201799             : 
  201800           5 : void SgNaryOp::deleteMemoryPool() {
  201801           5 :   for (auto p: SgNaryOp::pools) {
  201802           0 :     ROSE_FREE(p);
  201803             :   }
  201804           5 :   SgNaryOp::next_node = nullptr;
  201805           5 :   SgNaryOp::pools.clear();
  201806           5 : }
  201807             : 
  201808             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  201809             : //                 reading multiple binary files to for a single AST.
  201810             : /////////// new version ////////////////////////////////
  201811             : //############################################################################
  201812             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  201813             : void
  201814           2 : SgNaryOp::extendMemoryPoolForFileIO( )
  201815             :   {
  201816           2 :     size_t blockIndex = SgNaryOp::pools.size();
  201817           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryOp);
  201818             : 
  201819           2 :     while ( (blockIndex * SgNaryOp::pool_size) < newPoolSize)
  201820             :       {
  201821             : #if ROSE_ALLOC_TRACE
  201822             :         if (blockIndex > 0) {
  201823             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryOp) = %" PRIuPTR " SgNaryOp::pool_size = %d \n",
  201824             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryOp),SgNaryOp::pool_size);
  201825             :         }
  201826             : #endif
  201827             : 
  201828           0 :         SgNaryOp * pointer = (SgNaryOp*) ROSE_MALLOC ( SgNaryOp::pool_size * sizeof(SgNaryOp) );
  201829           0 :         assert( pointer != NULL );
  201830             : #if ROSE_ALLOC_MEMSET == 1
  201831             :         memset(pointer, 0x00, SgNaryOp::pool_size * sizeof(SgNaryOp));
  201832             : #elif ROSE_ALLOC_MEMSET == 2
  201833             :         memset(pointer, 0xCC, SgNaryOp::pool_size * sizeof(SgNaryOp));
  201834             : #endif
  201835           0 :         SgNaryOp::pools.push_back( (unsigned char*)(pointer) );
  201836           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNaryOp::pool_size * sizeof(SgNaryOp), V_SgNaryOp ) );
  201837             : 
  201838           0 :         if ( SgNaryOp::next_node != NULL ) {
  201839           0 :           if ( blockIndex > 0 ) {
  201840           0 :             SgNaryOp * blkptr = (SgNaryOp*)(SgNaryOp::pools[blockIndex-1]);
  201841           0 :             blkptr[ SgNaryOp::pool_size - 1 ].set_freepointer(pointer);
  201842             :           }
  201843             :         } else {
  201844           0 :           SgNaryOp::next_node = pointer;
  201845             :         }
  201846             : 
  201847           0 :         for (unsigned i = 0; i < SgNaryOp::pool_size-1; ++i)
  201848             :            {
  201849           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  201850             :            }
  201851           0 :         pointer[ SgNaryOp::pool_size -1 ].set_freepointer(NULL);
  201852             : 
  201853           0 :         blockIndex++;
  201854             :       }
  201855           2 :   }
  201856             : 
  201857             : //############################################################################
  201858             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  201859             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  201860             :  * not compressed. However, that stuff is not yet implemented! 
  201861             :  */
  201862             : unsigned long
  201863           0 : SgNaryOp::getNumberOfLastValidPointer()
  201864             :    {
  201865           0 :       SgNaryOp* testPointer = (SgNaryOp*)(SgNaryOp::pools.back());
  201866           0 :       unsigned long localIndex = SgNaryOp::pool_size - 1;
  201867           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  201868             :          {
  201869           0 :            localIndex--;
  201870             :          }
  201871           0 :       return (localIndex + SgNaryOp::pool_size * (SgNaryOp::pools.size()-1));
  201872             :    }
  201873             : 
  201874             : //############################################################################
  201875             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  201876             :  * memory pool and initializes the data member in class SgNaryOpStroageClass
  201877             :  * from its counterpart of SgNaryOp. The return value is just for checking, 
  201878             :  * that the whole StorageClassArray is initialized!
  201879             :  */
  201880             : unsigned long
  201881           0 : SgNaryOp::initializeStorageClassArray( SgNaryOpStorageClass *storageArray )
  201882             :    {
  201883           0 :      unsigned long storageCounter = 0;
  201884           0 :      std::vector < unsigned char* > :: const_iterator block = SgNaryOp::pools.begin();
  201885           0 :      SgNaryOp* pointer = NULL;
  201886           0 :      while ( block != SgNaryOp::pools.end() ) {
  201887           0 :           pointer = (SgNaryOp*) (*block);
  201888           0 :           for ( unsigned i = 0; i < SgNaryOp::pool_size; ++i ) {
  201889           0 :                if ( pointer->get_freepointer() != NULL ) {
  201890           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  201891           0 :                  storageArray++;
  201892           0 :                  storageCounter++;
  201893             :                }
  201894           0 :                pointer++;
  201895             :              }
  201896           0 :            block++;
  201897             :         }
  201898           0 :      return storageCounter;
  201899             :    }
  201900             : 
  201901             : /* #line 201902 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  201902             : 
  201903             : 
  201904             : 
  201905             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  201906             : 
  201907             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  201908             : 
  201909             : //############################################################################
  201910             : /* JH (02/02/2006) Constructor of the IR node SgNaryBooleanOp that takes its 
  201911             :  * corresponding StorageClass as parameter
  201912             :  */
  201913           0 : SgNaryBooleanOp :: SgNaryBooleanOp ( const SgNaryBooleanOpStorageClass& storageSource )   : SgNaryOp (storageSource)
  201914             :    {
  201915             : 
  201916             : 
  201917             : /* #line 201918 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  201918             : 
  201919           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  201920             : 
  201921             : 
  201922             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  201923             : 
  201924             : 
  201925           0 :    }
  201926             : 
  201927             : //############################################################################
  201928             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  201929             :  * within the working AST. 
  201930             :  */
  201931           0 : SgNaryBooleanOp * SgNaryBooleanOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  201932           0 :      SgNaryBooleanOp* returnPointer = NULL;
  201933           0 :      if ( globalIndex != 0 )
  201934             :         {
  201935             : 
  201936             : #if FILE_IO_EXTRA_CHECK
  201937           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNaryBooleanOp ) ) <= globalIndex ) ;
  201938           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNaryBooleanOp + 1 ) ) );
  201939             : #endif
  201940           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNaryBooleanOp )  
  201941           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNaryBooleanOp );
  201942           0 :           unsigned long positionInPool = localIndex % SgNaryBooleanOp::pool_size;
  201943           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNaryBooleanOp::pool_size;
  201944             : 
  201945             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  201946             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  201947             : 
  201948           0 :           returnPointer = &( ( (SgNaryBooleanOp*)(SgNaryBooleanOp::pools[memoryBlock]) ) [positionInPool]) ;
  201949             : 
  201950           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  201951             :         }
  201952           0 :      return returnPointer ;
  201953             :    }
  201954             : 
  201955             : //############################################################################
  201956             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  201957             :   for the AST with the index astIndex
  201958             : */
  201959           0 : SgNaryBooleanOp * SgNaryBooleanOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  201960           0 :      SgNaryBooleanOp* returnPointer = NULL;
  201961           0 :      if ( globalIndex != 0 )
  201962             :         {
  201963             : 
  201964             : #if FILE_IO_EXTRA_CHECK
  201965           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNaryBooleanOp ) ) <= globalIndex ) ;
  201966           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNaryBooleanOp + 1 ) ) );
  201967             : #endif
  201968           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNaryBooleanOp )
  201969           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNaryBooleanOp );
  201970           0 :           unsigned long positionInPool = localIndex % SgNaryBooleanOp::pool_size ;
  201971           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNaryBooleanOp::pool_size ;
  201972             : 
  201973             : #if FILE_IO_EXTRA_CHECK
  201974             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  201975             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  201976             : #endif
  201977             : 
  201978           0 :           returnPointer = &( ( (SgNaryBooleanOp*)(SgNaryBooleanOp::pools[memoryBlock]) ) [positionInPool]) ;
  201979             : 
  201980             : #if FILE_IO_EXTRA_CHECK
  201981           0 :           assert ( returnPointer != NULL ) ;
  201982             : #endif
  201983             :         }
  201984           0 :      return returnPointer ;
  201985             :    }
  201986             : 
  201987             : //############################################################################
  201988             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  201989             :  * pool size! We set for every valid object in the memory pool the freepointer
  201990             :  * to the global index and increase the global index afterwards. For all the 
  201991             :  * invalid objects (means address ranges within the memory pool that were not
  201992             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  201993             :  * distinguish valid from invalid objects! 
  201994             :  */
  201995             : unsigned long
  201996           5 : SgNaryBooleanOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  201997             :    {
  201998           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  201999           5 :      SgNaryBooleanOp* pointer = NULL;
  202000           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  202001           5 :      std::vector < unsigned char* > :: const_iterator block;
  202002           5 :      for ( block = SgNaryBooleanOp::pools.begin(); block != SgNaryBooleanOp::pools.end() ; ++block )
  202003             :         {
  202004           0 :           pointer = (SgNaryBooleanOp*)(*block);
  202005           0 :           for (unsigned i = 0; i < SgNaryBooleanOp::pool_size; ++i )
  202006             :              {
  202007             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  202008             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  202009             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  202010             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  202011             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  202012             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  202013             :             // properly; so this will have to be checked next.
  202014             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  202015             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  202016           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  202017             :                   {
  202018           0 :                     pointer[i].set_freepointer((SgNaryBooleanOp*)(globalIndex));
  202019           0 :                     globalIndex++;
  202020             :                   }
  202021             :                else
  202022             :                   {
  202023           0 :                     pointer[i].set_freepointer(NULL);
  202024             :                   }
  202025             :               }
  202026             :         }
  202027           5 :      return globalIndex;
  202028             :    }
  202029             : 
  202030             : //############################################################################
  202031             : // JH (01/14/2006)
  202032             : void
  202033           5 : SgNaryBooleanOp::resetValidFreepointers( )
  202034             :    {
  202035           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  202036           5 :      SgNaryBooleanOp* pointer = NULL;
  202037           5 :      std::vector < unsigned char* > :: const_iterator block;
  202038           5 :      SgNaryBooleanOp* pointerOfLinkedList = NULL;
  202039           5 :      for ( block = SgNaryBooleanOp::pools.begin(); block != SgNaryBooleanOp::pools.end() ; ++block )
  202040             :         {
  202041           0 :           pointer = (SgNaryBooleanOp*)(*block);
  202042           0 :           for (unsigned i = 0; i < SgNaryBooleanOp::pool_size; ++i )
  202043             :              {
  202044             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  202045             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  202046             :             // memory blocks!.
  202047           0 :                if ( pointer[i].get_freepointer() != NULL )
  202048             :                   {
  202049           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  202050             :                   }
  202051             :                else
  202052             :                   {
  202053           0 :                     if ( pointerOfLinkedList == NULL )
  202054             :                        {
  202055           0 :                          SgNaryBooleanOp::next_node = &(pointer[i]);
  202056             :                        }
  202057             :                     else
  202058             :                        {
  202059             :                       // printf ("In SgNaryBooleanOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  202060           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  202061             :                        }
  202062             :                     pointerOfLinkedList = &(pointer[i]);
  202063             :                   }
  202064             :               }
  202065             :         }
  202066             : 
  202067           5 :      if ( pointerOfLinkedList != NULL )
  202068             :         {
  202069             :        // printf ("In SgNaryBooleanOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  202070           0 :           pointerOfLinkedList->set_freepointer(NULL);
  202071             :        // DQ (6/6/2010): Temporary debugging...
  202072             :        //   ROSE_ASSERT(false);
  202073             :         }
  202074             : 
  202075           5 :      return ;
  202076             :    }
  202077             : 
  202078             : //############################################################################
  202079             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  202080             :  * within the memory pool and resets the freepointers, in order to achieve a 
  202081             :  * linked list, that has no jumps and starts at the beginning! This function 
  202082             :  * does not extend the memory pool, since we do not delete any memory blocks,
  202083             :  * but delete the valid objects.  
  202084             :  */
  202085             : void
  202086           0 : SgNaryBooleanOp::clearMemoryPool( )
  202087             :    {
  202088             :   // printf ("Inside of SgNaryBooleanOp::clearMemoryPool() \n");
  202089             : 
  202090           0 :      SgNaryBooleanOp* pointer = NULL, *tempPointer = NULL;
  202091           0 :      std::vector < unsigned char* > :: const_iterator block;
  202092           0 :      if ( SgNaryBooleanOp::pools.empty() == false )
  202093             :         {
  202094           0 :           block = SgNaryBooleanOp::pools.begin() ;
  202095           0 :           SgNaryBooleanOp::next_node = (SgNaryBooleanOp*) (*block);
  202096             : 
  202097           0 :           while ( block != SgNaryBooleanOp::pools.end() )
  202098             :              {
  202099           0 :                pointer = (SgNaryBooleanOp*) (*block);
  202100           0 :                if ( tempPointer != NULL )
  202101             :                   {
  202102           0 :                     tempPointer->set_freepointer(pointer);
  202103             :                   }
  202104           0 :                for (unsigned i = 0; i < SgNaryBooleanOp::pool_size - 1; ++i)
  202105             :                   {
  202106           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  202107             :                   }
  202108           0 :                 pointer[SgNaryBooleanOp::pool_size-1].set_freepointer(NULL);
  202109           0 :                 tempPointer = &(pointer[SgNaryBooleanOp::pool_size-1]);
  202110           0 :                 ++block;
  202111             :              }
  202112             :         }
  202113           0 :    }
  202114             : 
  202115           5 : void SgNaryBooleanOp::deleteMemoryPool() {
  202116           5 :   for (auto p: SgNaryBooleanOp::pools) {
  202117           0 :     ROSE_FREE(p);
  202118             :   }
  202119           5 :   SgNaryBooleanOp::next_node = nullptr;
  202120           5 :   SgNaryBooleanOp::pools.clear();
  202121           5 : }
  202122             : 
  202123             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  202124             : //                 reading multiple binary files to for a single AST.
  202125             : /////////// new version ////////////////////////////////
  202126             : //############################################################################
  202127             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  202128             : void
  202129           2 : SgNaryBooleanOp::extendMemoryPoolForFileIO( )
  202130             :   {
  202131           2 :     size_t blockIndex = SgNaryBooleanOp::pools.size();
  202132           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryBooleanOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryBooleanOp);
  202133             : 
  202134           2 :     while ( (blockIndex * SgNaryBooleanOp::pool_size) < newPoolSize)
  202135             :       {
  202136             : #if ROSE_ALLOC_TRACE
  202137             :         if (blockIndex > 0) {
  202138             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryBooleanOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryBooleanOp) = %" PRIuPTR " SgNaryBooleanOp::pool_size = %d \n",
  202139             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryBooleanOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryBooleanOp),SgNaryBooleanOp::pool_size);
  202140             :         }
  202141             : #endif
  202142             : 
  202143           0 :         SgNaryBooleanOp * pointer = (SgNaryBooleanOp*) ROSE_MALLOC ( SgNaryBooleanOp::pool_size * sizeof(SgNaryBooleanOp) );
  202144           0 :         assert( pointer != NULL );
  202145             : #if ROSE_ALLOC_MEMSET == 1
  202146             :         memset(pointer, 0x00, SgNaryBooleanOp::pool_size * sizeof(SgNaryBooleanOp));
  202147             : #elif ROSE_ALLOC_MEMSET == 2
  202148             :         memset(pointer, 0xCC, SgNaryBooleanOp::pool_size * sizeof(SgNaryBooleanOp));
  202149             : #endif
  202150           0 :         SgNaryBooleanOp::pools.push_back( (unsigned char*)(pointer) );
  202151           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNaryBooleanOp::pool_size * sizeof(SgNaryBooleanOp), V_SgNaryBooleanOp ) );
  202152             : 
  202153           0 :         if ( SgNaryBooleanOp::next_node != NULL ) {
  202154           0 :           if ( blockIndex > 0 ) {
  202155           0 :             SgNaryBooleanOp * blkptr = (SgNaryBooleanOp*)(SgNaryBooleanOp::pools[blockIndex-1]);
  202156           0 :             blkptr[ SgNaryBooleanOp::pool_size - 1 ].set_freepointer(pointer);
  202157             :           }
  202158             :         } else {
  202159           0 :           SgNaryBooleanOp::next_node = pointer;
  202160             :         }
  202161             : 
  202162           0 :         for (unsigned i = 0; i < SgNaryBooleanOp::pool_size-1; ++i)
  202163             :            {
  202164           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  202165             :            }
  202166           0 :         pointer[ SgNaryBooleanOp::pool_size -1 ].set_freepointer(NULL);
  202167             : 
  202168           0 :         blockIndex++;
  202169             :       }
  202170           2 :   }
  202171             : 
  202172             : //############################################################################
  202173             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  202174             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  202175             :  * not compressed. However, that stuff is not yet implemented! 
  202176             :  */
  202177             : unsigned long
  202178           0 : SgNaryBooleanOp::getNumberOfLastValidPointer()
  202179             :    {
  202180           0 :       SgNaryBooleanOp* testPointer = (SgNaryBooleanOp*)(SgNaryBooleanOp::pools.back());
  202181           0 :       unsigned long localIndex = SgNaryBooleanOp::pool_size - 1;
  202182           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  202183             :          {
  202184           0 :            localIndex--;
  202185             :          }
  202186           0 :       return (localIndex + SgNaryBooleanOp::pool_size * (SgNaryBooleanOp::pools.size()-1));
  202187             :    }
  202188             : 
  202189             : //############################################################################
  202190             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  202191             :  * memory pool and initializes the data member in class SgNaryBooleanOpStroageClass
  202192             :  * from its counterpart of SgNaryBooleanOp. The return value is just for checking, 
  202193             :  * that the whole StorageClassArray is initialized!
  202194             :  */
  202195             : unsigned long
  202196           0 : SgNaryBooleanOp::initializeStorageClassArray( SgNaryBooleanOpStorageClass *storageArray )
  202197             :    {
  202198           0 :      unsigned long storageCounter = 0;
  202199           0 :      std::vector < unsigned char* > :: const_iterator block = SgNaryBooleanOp::pools.begin();
  202200           0 :      SgNaryBooleanOp* pointer = NULL;
  202201           0 :      while ( block != SgNaryBooleanOp::pools.end() ) {
  202202           0 :           pointer = (SgNaryBooleanOp*) (*block);
  202203           0 :           for ( unsigned i = 0; i < SgNaryBooleanOp::pool_size; ++i ) {
  202204           0 :                if ( pointer->get_freepointer() != NULL ) {
  202205           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  202206           0 :                  storageArray++;
  202207           0 :                  storageCounter++;
  202208             :                }
  202209           0 :                pointer++;
  202210             :              }
  202211           0 :            block++;
  202212             :         }
  202213           0 :      return storageCounter;
  202214             :    }
  202215             : 
  202216             : /* #line 202217 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  202217             : 
  202218             : 
  202219             : 
  202220             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  202221             : 
  202222             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  202223             : 
  202224             : //############################################################################
  202225             : /* JH (02/02/2006) Constructor of the IR node SgNaryComparisonOp that takes its 
  202226             :  * corresponding StorageClass as parameter
  202227             :  */
  202228           0 : SgNaryComparisonOp :: SgNaryComparisonOp ( const SgNaryComparisonOpStorageClass& storageSource )   : SgNaryOp (storageSource)
  202229             :    {
  202230             : 
  202231             : 
  202232             : /* #line 202233 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  202233             : 
  202234           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  202235             : 
  202236             : 
  202237             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  202238             : 
  202239             : 
  202240           0 :    }
  202241             : 
  202242             : //############################################################################
  202243             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  202244             :  * within the working AST. 
  202245             :  */
  202246           0 : SgNaryComparisonOp * SgNaryComparisonOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  202247           0 :      SgNaryComparisonOp* returnPointer = NULL;
  202248           0 :      if ( globalIndex != 0 )
  202249             :         {
  202250             : 
  202251             : #if FILE_IO_EXTRA_CHECK
  202252           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNaryComparisonOp ) ) <= globalIndex ) ;
  202253           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNaryComparisonOp + 1 ) ) );
  202254             : #endif
  202255           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNaryComparisonOp )  
  202256           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNaryComparisonOp );
  202257           0 :           unsigned long positionInPool = localIndex % SgNaryComparisonOp::pool_size;
  202258           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNaryComparisonOp::pool_size;
  202259             : 
  202260             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  202261             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  202262             : 
  202263           0 :           returnPointer = &( ( (SgNaryComparisonOp*)(SgNaryComparisonOp::pools[memoryBlock]) ) [positionInPool]) ;
  202264             : 
  202265           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  202266             :         }
  202267           0 :      return returnPointer ;
  202268             :    }
  202269             : 
  202270             : //############################################################################
  202271             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  202272             :   for the AST with the index astIndex
  202273             : */
  202274           0 : SgNaryComparisonOp * SgNaryComparisonOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  202275           0 :      SgNaryComparisonOp* returnPointer = NULL;
  202276           0 :      if ( globalIndex != 0 )
  202277             :         {
  202278             : 
  202279             : #if FILE_IO_EXTRA_CHECK
  202280           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNaryComparisonOp ) ) <= globalIndex ) ;
  202281           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNaryComparisonOp + 1 ) ) );
  202282             : #endif
  202283           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNaryComparisonOp )
  202284           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNaryComparisonOp );
  202285           0 :           unsigned long positionInPool = localIndex % SgNaryComparisonOp::pool_size ;
  202286           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNaryComparisonOp::pool_size ;
  202287             : 
  202288             : #if FILE_IO_EXTRA_CHECK
  202289             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  202290             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  202291             : #endif
  202292             : 
  202293           0 :           returnPointer = &( ( (SgNaryComparisonOp*)(SgNaryComparisonOp::pools[memoryBlock]) ) [positionInPool]) ;
  202294             : 
  202295             : #if FILE_IO_EXTRA_CHECK
  202296           0 :           assert ( returnPointer != NULL ) ;
  202297             : #endif
  202298             :         }
  202299           0 :      return returnPointer ;
  202300             :    }
  202301             : 
  202302             : //############################################################################
  202303             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  202304             :  * pool size! We set for every valid object in the memory pool the freepointer
  202305             :  * to the global index and increase the global index afterwards. For all the 
  202306             :  * invalid objects (means address ranges within the memory pool that were not
  202307             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  202308             :  * distinguish valid from invalid objects! 
  202309             :  */
  202310             : unsigned long
  202311           5 : SgNaryComparisonOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  202312             :    {
  202313           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  202314           5 :      SgNaryComparisonOp* pointer = NULL;
  202315           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  202316           5 :      std::vector < unsigned char* > :: const_iterator block;
  202317           5 :      for ( block = SgNaryComparisonOp::pools.begin(); block != SgNaryComparisonOp::pools.end() ; ++block )
  202318             :         {
  202319           0 :           pointer = (SgNaryComparisonOp*)(*block);
  202320           0 :           for (unsigned i = 0; i < SgNaryComparisonOp::pool_size; ++i )
  202321             :              {
  202322             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  202323             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  202324             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  202325             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  202326             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  202327             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  202328             :             // properly; so this will have to be checked next.
  202329             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  202330             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  202331           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  202332             :                   {
  202333           0 :                     pointer[i].set_freepointer((SgNaryComparisonOp*)(globalIndex));
  202334           0 :                     globalIndex++;
  202335             :                   }
  202336             :                else
  202337             :                   {
  202338           0 :                     pointer[i].set_freepointer(NULL);
  202339             :                   }
  202340             :               }
  202341             :         }
  202342           5 :      return globalIndex;
  202343             :    }
  202344             : 
  202345             : //############################################################################
  202346             : // JH (01/14/2006)
  202347             : void
  202348           5 : SgNaryComparisonOp::resetValidFreepointers( )
  202349             :    {
  202350           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  202351           5 :      SgNaryComparisonOp* pointer = NULL;
  202352           5 :      std::vector < unsigned char* > :: const_iterator block;
  202353           5 :      SgNaryComparisonOp* pointerOfLinkedList = NULL;
  202354           5 :      for ( block = SgNaryComparisonOp::pools.begin(); block != SgNaryComparisonOp::pools.end() ; ++block )
  202355             :         {
  202356           0 :           pointer = (SgNaryComparisonOp*)(*block);
  202357           0 :           for (unsigned i = 0; i < SgNaryComparisonOp::pool_size; ++i )
  202358             :              {
  202359             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  202360             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  202361             :             // memory blocks!.
  202362           0 :                if ( pointer[i].get_freepointer() != NULL )
  202363             :                   {
  202364           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  202365             :                   }
  202366             :                else
  202367             :                   {
  202368           0 :                     if ( pointerOfLinkedList == NULL )
  202369             :                        {
  202370           0 :                          SgNaryComparisonOp::next_node = &(pointer[i]);
  202371             :                        }
  202372             :                     else
  202373             :                        {
  202374             :                       // printf ("In SgNaryComparisonOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  202375           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  202376             :                        }
  202377             :                     pointerOfLinkedList = &(pointer[i]);
  202378             :                   }
  202379             :               }
  202380             :         }
  202381             : 
  202382           5 :      if ( pointerOfLinkedList != NULL )
  202383             :         {
  202384             :        // printf ("In SgNaryComparisonOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  202385           0 :           pointerOfLinkedList->set_freepointer(NULL);
  202386             :        // DQ (6/6/2010): Temporary debugging...
  202387             :        //   ROSE_ASSERT(false);
  202388             :         }
  202389             : 
  202390           5 :      return ;
  202391             :    }
  202392             : 
  202393             : //############################################################################
  202394             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  202395             :  * within the memory pool and resets the freepointers, in order to achieve a 
  202396             :  * linked list, that has no jumps and starts at the beginning! This function 
  202397             :  * does not extend the memory pool, since we do not delete any memory blocks,
  202398             :  * but delete the valid objects.  
  202399             :  */
  202400             : void
  202401           0 : SgNaryComparisonOp::clearMemoryPool( )
  202402             :    {
  202403             :   // printf ("Inside of SgNaryComparisonOp::clearMemoryPool() \n");
  202404             : 
  202405           0 :      SgNaryComparisonOp* pointer = NULL, *tempPointer = NULL;
  202406           0 :      std::vector < unsigned char* > :: const_iterator block;
  202407           0 :      if ( SgNaryComparisonOp::pools.empty() == false )
  202408             :         {
  202409           0 :           block = SgNaryComparisonOp::pools.begin() ;
  202410           0 :           SgNaryComparisonOp::next_node = (SgNaryComparisonOp*) (*block);
  202411             : 
  202412           0 :           while ( block != SgNaryComparisonOp::pools.end() )
  202413             :              {
  202414           0 :                pointer = (SgNaryComparisonOp*) (*block);
  202415           0 :                if ( tempPointer != NULL )
  202416             :                   {
  202417           0 :                     tempPointer->set_freepointer(pointer);
  202418             :                   }
  202419           0 :                for (unsigned i = 0; i < SgNaryComparisonOp::pool_size - 1; ++i)
  202420             :                   {
  202421           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  202422             :                   }
  202423           0 :                 pointer[SgNaryComparisonOp::pool_size-1].set_freepointer(NULL);
  202424           0 :                 tempPointer = &(pointer[SgNaryComparisonOp::pool_size-1]);
  202425           0 :                 ++block;
  202426             :              }
  202427             :         }
  202428           0 :    }
  202429             : 
  202430           5 : void SgNaryComparisonOp::deleteMemoryPool() {
  202431           5 :   for (auto p: SgNaryComparisonOp::pools) {
  202432           0 :     ROSE_FREE(p);
  202433             :   }
  202434           5 :   SgNaryComparisonOp::next_node = nullptr;
  202435           5 :   SgNaryComparisonOp::pools.clear();
  202436           5 : }
  202437             : 
  202438             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  202439             : //                 reading multiple binary files to for a single AST.
  202440             : /////////// new version ////////////////////////////////
  202441             : //############################################################################
  202442             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  202443             : void
  202444           2 : SgNaryComparisonOp::extendMemoryPoolForFileIO( )
  202445             :   {
  202446           2 :     size_t blockIndex = SgNaryComparisonOp::pools.size();
  202447           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryComparisonOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryComparisonOp);
  202448             : 
  202449           2 :     while ( (blockIndex * SgNaryComparisonOp::pool_size) < newPoolSize)
  202450             :       {
  202451             : #if ROSE_ALLOC_TRACE
  202452             :         if (blockIndex > 0) {
  202453             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryComparisonOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryComparisonOp) = %" PRIuPTR " SgNaryComparisonOp::pool_size = %d \n",
  202454             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNaryComparisonOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNaryComparisonOp),SgNaryComparisonOp::pool_size);
  202455             :         }
  202456             : #endif
  202457             : 
  202458           0 :         SgNaryComparisonOp * pointer = (SgNaryComparisonOp*) ROSE_MALLOC ( SgNaryComparisonOp::pool_size * sizeof(SgNaryComparisonOp) );
  202459           0 :         assert( pointer != NULL );
  202460             : #if ROSE_ALLOC_MEMSET == 1
  202461             :         memset(pointer, 0x00, SgNaryComparisonOp::pool_size * sizeof(SgNaryComparisonOp));
  202462             : #elif ROSE_ALLOC_MEMSET == 2
  202463             :         memset(pointer, 0xCC, SgNaryComparisonOp::pool_size * sizeof(SgNaryComparisonOp));
  202464             : #endif
  202465           0 :         SgNaryComparisonOp::pools.push_back( (unsigned char*)(pointer) );
  202466           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNaryComparisonOp::pool_size * sizeof(SgNaryComparisonOp), V_SgNaryComparisonOp ) );
  202467             : 
  202468           0 :         if ( SgNaryComparisonOp::next_node != NULL ) {
  202469           0 :           if ( blockIndex > 0 ) {
  202470           0 :             SgNaryComparisonOp * blkptr = (SgNaryComparisonOp*)(SgNaryComparisonOp::pools[blockIndex-1]);
  202471           0 :             blkptr[ SgNaryComparisonOp::pool_size - 1 ].set_freepointer(pointer);
  202472             :           }
  202473             :         } else {
  202474           0 :           SgNaryComparisonOp::next_node = pointer;
  202475             :         }
  202476             : 
  202477           0 :         for (unsigned i = 0; i < SgNaryComparisonOp::pool_size-1; ++i)
  202478             :            {
  202479           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  202480             :            }
  202481           0 :         pointer[ SgNaryComparisonOp::pool_size -1 ].set_freepointer(NULL);
  202482             : 
  202483           0 :         blockIndex++;
  202484             :       }
  202485           2 :   }
  202486             : 
  202487             : //############################################################################
  202488             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  202489             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  202490             :  * not compressed. However, that stuff is not yet implemented! 
  202491             :  */
  202492             : unsigned long
  202493           0 : SgNaryComparisonOp::getNumberOfLastValidPointer()
  202494             :    {
  202495           0 :       SgNaryComparisonOp* testPointer = (SgNaryComparisonOp*)(SgNaryComparisonOp::pools.back());
  202496           0 :       unsigned long localIndex = SgNaryComparisonOp::pool_size - 1;
  202497           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  202498             :          {
  202499           0 :            localIndex--;
  202500             :          }
  202501           0 :       return (localIndex + SgNaryComparisonOp::pool_size * (SgNaryComparisonOp::pools.size()-1));
  202502             :    }
  202503             : 
  202504             : //############################################################################
  202505             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  202506             :  * memory pool and initializes the data member in class SgNaryComparisonOpStroageClass
  202507             :  * from its counterpart of SgNaryComparisonOp. The return value is just for checking, 
  202508             :  * that the whole StorageClassArray is initialized!
  202509             :  */
  202510             : unsigned long
  202511           0 : SgNaryComparisonOp::initializeStorageClassArray( SgNaryComparisonOpStorageClass *storageArray )
  202512             :    {
  202513           0 :      unsigned long storageCounter = 0;
  202514           0 :      std::vector < unsigned char* > :: const_iterator block = SgNaryComparisonOp::pools.begin();
  202515           0 :      SgNaryComparisonOp* pointer = NULL;
  202516           0 :      while ( block != SgNaryComparisonOp::pools.end() ) {
  202517           0 :           pointer = (SgNaryComparisonOp*) (*block);
  202518           0 :           for ( unsigned i = 0; i < SgNaryComparisonOp::pool_size; ++i ) {
  202519           0 :                if ( pointer->get_freepointer() != NULL ) {
  202520           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  202521           0 :                  storageArray++;
  202522           0 :                  storageCounter++;
  202523             :                }
  202524           0 :                pointer++;
  202525             :              }
  202526           0 :            block++;
  202527             :         }
  202528           0 :      return storageCounter;
  202529             :    }
  202530             : 
  202531             : /* #line 202532 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  202532             : 
  202533             : 
  202534             : 
  202535             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  202536             : 
  202537             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  202538             : 
  202539             : //############################################################################
  202540             : /* JH (02/02/2006) Constructor of the IR node SgStringConversion that takes its 
  202541             :  * corresponding StorageClass as parameter
  202542             :  */
  202543           0 : SgStringConversion :: SgStringConversion ( const SgStringConversionStorageClass& storageSource )   : SgExpression (storageSource)
  202544             :    {
  202545             : 
  202546             : 
  202547             : /* #line 202548 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  202548             : 
  202549           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  202550           0 :      p_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression) );
  202551             : 
  202552             : 
  202553             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  202554             : 
  202555             : 
  202556           0 :    }
  202557             : 
  202558             : //############################################################################
  202559             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  202560             :  * within the working AST. 
  202561             :  */
  202562           0 : SgStringConversion * SgStringConversion::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  202563           0 :      SgStringConversion* returnPointer = NULL;
  202564           0 :      if ( globalIndex != 0 )
  202565             :         {
  202566             : 
  202567             : #if FILE_IO_EXTRA_CHECK
  202568           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgStringConversion ) ) <= globalIndex ) ;
  202569           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStringConversion + 1 ) ) );
  202570             : #endif
  202571           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgStringConversion )  
  202572           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgStringConversion );
  202573           0 :           unsigned long positionInPool = localIndex % SgStringConversion::pool_size;
  202574           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStringConversion::pool_size;
  202575             : 
  202576             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  202577             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  202578             : 
  202579           0 :           returnPointer = &( ( (SgStringConversion*)(SgStringConversion::pools[memoryBlock]) ) [positionInPool]) ;
  202580             : 
  202581           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  202582             :         }
  202583           0 :      return returnPointer ;
  202584             :    }
  202585             : 
  202586             : //############################################################################
  202587             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  202588             :   for the AST with the index astIndex
  202589             : */
  202590           0 : SgStringConversion * SgStringConversion::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  202591           0 :      SgStringConversion* returnPointer = NULL;
  202592           0 :      if ( globalIndex != 0 )
  202593             :         {
  202594             : 
  202595             : #if FILE_IO_EXTRA_CHECK
  202596           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgStringConversion ) ) <= globalIndex ) ;
  202597           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStringConversion + 1 ) ) );
  202598             : #endif
  202599           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgStringConversion )
  202600           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgStringConversion );
  202601           0 :           unsigned long positionInPool = localIndex % SgStringConversion::pool_size ;
  202602           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgStringConversion::pool_size ;
  202603             : 
  202604             : #if FILE_IO_EXTRA_CHECK
  202605             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  202606             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  202607             : #endif
  202608             : 
  202609           0 :           returnPointer = &( ( (SgStringConversion*)(SgStringConversion::pools[memoryBlock]) ) [positionInPool]) ;
  202610             : 
  202611             : #if FILE_IO_EXTRA_CHECK
  202612           0 :           assert ( returnPointer != NULL ) ;
  202613             : #endif
  202614             :         }
  202615           0 :      return returnPointer ;
  202616             :    }
  202617             : 
  202618             : //############################################################################
  202619             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  202620             :  * pool size! We set for every valid object in the memory pool the freepointer
  202621             :  * to the global index and increase the global index afterwards. For all the 
  202622             :  * invalid objects (means address ranges within the memory pool that were not
  202623             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  202624             :  * distinguish valid from invalid objects! 
  202625             :  */
  202626             : unsigned long
  202627           5 : SgStringConversion::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  202628             :    {
  202629           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  202630           5 :      SgStringConversion* pointer = NULL;
  202631           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  202632           5 :      std::vector < unsigned char* > :: const_iterator block;
  202633           5 :      for ( block = SgStringConversion::pools.begin(); block != SgStringConversion::pools.end() ; ++block )
  202634             :         {
  202635           0 :           pointer = (SgStringConversion*)(*block);
  202636           0 :           for (unsigned i = 0; i < SgStringConversion::pool_size; ++i )
  202637             :              {
  202638             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  202639             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  202640             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  202641             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  202642             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  202643             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  202644             :             // properly; so this will have to be checked next.
  202645             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  202646             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  202647           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  202648             :                   {
  202649           0 :                     pointer[i].set_freepointer((SgStringConversion*)(globalIndex));
  202650           0 :                     globalIndex++;
  202651             :                   }
  202652             :                else
  202653             :                   {
  202654           0 :                     pointer[i].set_freepointer(NULL);
  202655             :                   }
  202656             :               }
  202657             :         }
  202658           5 :      return globalIndex;
  202659             :    }
  202660             : 
  202661             : //############################################################################
  202662             : // JH (01/14/2006)
  202663             : void
  202664           5 : SgStringConversion::resetValidFreepointers( )
  202665             :    {
  202666           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  202667           5 :      SgStringConversion* pointer = NULL;
  202668           5 :      std::vector < unsigned char* > :: const_iterator block;
  202669           5 :      SgStringConversion* pointerOfLinkedList = NULL;
  202670           5 :      for ( block = SgStringConversion::pools.begin(); block != SgStringConversion::pools.end() ; ++block )
  202671             :         {
  202672           0 :           pointer = (SgStringConversion*)(*block);
  202673           0 :           for (unsigned i = 0; i < SgStringConversion::pool_size; ++i )
  202674             :              {
  202675             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  202676             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  202677             :             // memory blocks!.
  202678           0 :                if ( pointer[i].get_freepointer() != NULL )
  202679             :                   {
  202680           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  202681             :                   }
  202682             :                else
  202683             :                   {
  202684           0 :                     if ( pointerOfLinkedList == NULL )
  202685             :                        {
  202686           0 :                          SgStringConversion::next_node = &(pointer[i]);
  202687             :                        }
  202688             :                     else
  202689             :                        {
  202690             :                       // printf ("In SgStringConversion::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  202691           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  202692             :                        }
  202693             :                     pointerOfLinkedList = &(pointer[i]);
  202694             :                   }
  202695             :               }
  202696             :         }
  202697             : 
  202698           5 :      if ( pointerOfLinkedList != NULL )
  202699             :         {
  202700             :        // printf ("In SgStringConversion::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  202701           0 :           pointerOfLinkedList->set_freepointer(NULL);
  202702             :        // DQ (6/6/2010): Temporary debugging...
  202703             :        //   ROSE_ASSERT(false);
  202704             :         }
  202705             : 
  202706           5 :      return ;
  202707             :    }
  202708             : 
  202709             : //############################################################################
  202710             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  202711             :  * within the memory pool and resets the freepointers, in order to achieve a 
  202712             :  * linked list, that has no jumps and starts at the beginning! This function 
  202713             :  * does not extend the memory pool, since we do not delete any memory blocks,
  202714             :  * but delete the valid objects.  
  202715             :  */
  202716             : void
  202717           0 : SgStringConversion::clearMemoryPool( )
  202718             :    {
  202719             :   // printf ("Inside of SgStringConversion::clearMemoryPool() \n");
  202720             : 
  202721           0 :      SgStringConversion* pointer = NULL, *tempPointer = NULL;
  202722           0 :      std::vector < unsigned char* > :: const_iterator block;
  202723           0 :      if ( SgStringConversion::pools.empty() == false )
  202724             :         {
  202725           0 :           block = SgStringConversion::pools.begin() ;
  202726           0 :           SgStringConversion::next_node = (SgStringConversion*) (*block);
  202727             : 
  202728           0 :           while ( block != SgStringConversion::pools.end() )
  202729             :              {
  202730           0 :                pointer = (SgStringConversion*) (*block);
  202731           0 :                if ( tempPointer != NULL )
  202732             :                   {
  202733           0 :                     tempPointer->set_freepointer(pointer);
  202734             :                   }
  202735           0 :                for (unsigned i = 0; i < SgStringConversion::pool_size - 1; ++i)
  202736             :                   {
  202737           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  202738             :                   }
  202739           0 :                 pointer[SgStringConversion::pool_size-1].set_freepointer(NULL);
  202740           0 :                 tempPointer = &(pointer[SgStringConversion::pool_size-1]);
  202741           0 :                 ++block;
  202742             :              }
  202743             :         }
  202744           0 :    }
  202745             : 
  202746           5 : void SgStringConversion::deleteMemoryPool() {
  202747           5 :   for (auto p: SgStringConversion::pools) {
  202748           0 :     ROSE_FREE(p);
  202749             :   }
  202750           5 :   SgStringConversion::next_node = nullptr;
  202751           5 :   SgStringConversion::pools.clear();
  202752           5 : }
  202753             : 
  202754             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  202755             : //                 reading multiple binary files to for a single AST.
  202756             : /////////// new version ////////////////////////////////
  202757             : //############################################################################
  202758             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  202759             : void
  202760           2 : SgStringConversion::extendMemoryPoolForFileIO( )
  202761             :   {
  202762           2 :     size_t blockIndex = SgStringConversion::pools.size();
  202763           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgStringConversion) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringConversion);
  202764             : 
  202765           2 :     while ( (blockIndex * SgStringConversion::pool_size) < newPoolSize)
  202766             :       {
  202767             : #if ROSE_ALLOC_TRACE
  202768             :         if (blockIndex > 0) {
  202769             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgStringConversion) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringConversion) = %" PRIuPTR " SgStringConversion::pool_size = %d \n",
  202770             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgStringConversion),AST_FILE_IO::getPoolSizeOfNewAst(V_SgStringConversion),SgStringConversion::pool_size);
  202771             :         }
  202772             : #endif
  202773             : 
  202774           0 :         SgStringConversion * pointer = (SgStringConversion*) ROSE_MALLOC ( SgStringConversion::pool_size * sizeof(SgStringConversion) );
  202775           0 :         assert( pointer != NULL );
  202776             : #if ROSE_ALLOC_MEMSET == 1
  202777             :         memset(pointer, 0x00, SgStringConversion::pool_size * sizeof(SgStringConversion));
  202778             : #elif ROSE_ALLOC_MEMSET == 2
  202779             :         memset(pointer, 0xCC, SgStringConversion::pool_size * sizeof(SgStringConversion));
  202780             : #endif
  202781           0 :         SgStringConversion::pools.push_back( (unsigned char*)(pointer) );
  202782           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgStringConversion::pool_size * sizeof(SgStringConversion), V_SgStringConversion ) );
  202783             : 
  202784           0 :         if ( SgStringConversion::next_node != NULL ) {
  202785           0 :           if ( blockIndex > 0 ) {
  202786           0 :             SgStringConversion * blkptr = (SgStringConversion*)(SgStringConversion::pools[blockIndex-1]);
  202787           0 :             blkptr[ SgStringConversion::pool_size - 1 ].set_freepointer(pointer);
  202788             :           }
  202789             :         } else {
  202790           0 :           SgStringConversion::next_node = pointer;
  202791             :         }
  202792             : 
  202793           0 :         for (unsigned i = 0; i < SgStringConversion::pool_size-1; ++i)
  202794             :            {
  202795           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  202796             :            }
  202797           0 :         pointer[ SgStringConversion::pool_size -1 ].set_freepointer(NULL);
  202798             : 
  202799           0 :         blockIndex++;
  202800             :       }
  202801           2 :   }
  202802             : 
  202803             : //############################################################################
  202804             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  202805             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  202806             :  * not compressed. However, that stuff is not yet implemented! 
  202807             :  */
  202808             : unsigned long
  202809           0 : SgStringConversion::getNumberOfLastValidPointer()
  202810             :    {
  202811           0 :       SgStringConversion* testPointer = (SgStringConversion*)(SgStringConversion::pools.back());
  202812           0 :       unsigned long localIndex = SgStringConversion::pool_size - 1;
  202813           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  202814             :          {
  202815           0 :            localIndex--;
  202816             :          }
  202817           0 :       return (localIndex + SgStringConversion::pool_size * (SgStringConversion::pools.size()-1));
  202818             :    }
  202819             : 
  202820             : //############################################################################
  202821             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  202822             :  * memory pool and initializes the data member in class SgStringConversionStroageClass
  202823             :  * from its counterpart of SgStringConversion. The return value is just for checking, 
  202824             :  * that the whole StorageClassArray is initialized!
  202825             :  */
  202826             : unsigned long
  202827           0 : SgStringConversion::initializeStorageClassArray( SgStringConversionStorageClass *storageArray )
  202828             :    {
  202829           0 :      unsigned long storageCounter = 0;
  202830           0 :      std::vector < unsigned char* > :: const_iterator block = SgStringConversion::pools.begin();
  202831           0 :      SgStringConversion* pointer = NULL;
  202832           0 :      while ( block != SgStringConversion::pools.end() ) {
  202833           0 :           pointer = (SgStringConversion*) (*block);
  202834           0 :           for ( unsigned i = 0; i < SgStringConversion::pool_size; ++i ) {
  202835           0 :                if ( pointer->get_freepointer() != NULL ) {
  202836           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  202837           0 :                  storageArray++;
  202838           0 :                  storageCounter++;
  202839             :                }
  202840           0 :                pointer++;
  202841             :              }
  202842           0 :            block++;
  202843             :         }
  202844           0 :      return storageCounter;
  202845             :    }
  202846             : 
  202847             : /* #line 202848 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  202848             : 
  202849             : 
  202850             : 
  202851             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  202852             : 
  202853             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  202854             : 
  202855             : //############################################################################
  202856             : /* JH (02/02/2006) Constructor of the IR node SgYieldExpression that takes its 
  202857             :  * corresponding StorageClass as parameter
  202858             :  */
  202859           0 : SgYieldExpression :: SgYieldExpression ( const SgYieldExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  202860             :    {
  202861             : 
  202862             : 
  202863             : /* #line 202864 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  202864             : 
  202865           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  202866           0 :      p_value =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_value) );
  202867             : 
  202868             : 
  202869             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  202870             : 
  202871             : 
  202872           0 :    }
  202873             : 
  202874             : //############################################################################
  202875             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  202876             :  * within the working AST. 
  202877             :  */
  202878           0 : SgYieldExpression * SgYieldExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  202879           0 :      SgYieldExpression* returnPointer = NULL;
  202880           0 :      if ( globalIndex != 0 )
  202881             :         {
  202882             : 
  202883             : #if FILE_IO_EXTRA_CHECK
  202884           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgYieldExpression ) ) <= globalIndex ) ;
  202885           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgYieldExpression + 1 ) ) );
  202886             : #endif
  202887           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgYieldExpression )  
  202888           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgYieldExpression );
  202889           0 :           unsigned long positionInPool = localIndex % SgYieldExpression::pool_size;
  202890           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgYieldExpression::pool_size;
  202891             : 
  202892             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  202893             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  202894             : 
  202895           0 :           returnPointer = &( ( (SgYieldExpression*)(SgYieldExpression::pools[memoryBlock]) ) [positionInPool]) ;
  202896             : 
  202897           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  202898             :         }
  202899           0 :      return returnPointer ;
  202900             :    }
  202901             : 
  202902             : //############################################################################
  202903             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  202904             :   for the AST with the index astIndex
  202905             : */
  202906           0 : SgYieldExpression * SgYieldExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  202907           0 :      SgYieldExpression* returnPointer = NULL;
  202908           0 :      if ( globalIndex != 0 )
  202909             :         {
  202910             : 
  202911             : #if FILE_IO_EXTRA_CHECK
  202912           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgYieldExpression ) ) <= globalIndex ) ;
  202913           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgYieldExpression + 1 ) ) );
  202914             : #endif
  202915           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgYieldExpression )
  202916           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgYieldExpression );
  202917           0 :           unsigned long positionInPool = localIndex % SgYieldExpression::pool_size ;
  202918           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgYieldExpression::pool_size ;
  202919             : 
  202920             : #if FILE_IO_EXTRA_CHECK
  202921             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  202922             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  202923             : #endif
  202924             : 
  202925           0 :           returnPointer = &( ( (SgYieldExpression*)(SgYieldExpression::pools[memoryBlock]) ) [positionInPool]) ;
  202926             : 
  202927             : #if FILE_IO_EXTRA_CHECK
  202928           0 :           assert ( returnPointer != NULL ) ;
  202929             : #endif
  202930             :         }
  202931           0 :      return returnPointer ;
  202932             :    }
  202933             : 
  202934             : //############################################################################
  202935             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  202936             :  * pool size! We set for every valid object in the memory pool the freepointer
  202937             :  * to the global index and increase the global index afterwards. For all the 
  202938             :  * invalid objects (means address ranges within the memory pool that were not
  202939             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  202940             :  * distinguish valid from invalid objects! 
  202941             :  */
  202942             : unsigned long
  202943           5 : SgYieldExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  202944             :    {
  202945           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  202946           5 :      SgYieldExpression* pointer = NULL;
  202947           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  202948           5 :      std::vector < unsigned char* > :: const_iterator block;
  202949           5 :      for ( block = SgYieldExpression::pools.begin(); block != SgYieldExpression::pools.end() ; ++block )
  202950             :         {
  202951           0 :           pointer = (SgYieldExpression*)(*block);
  202952           0 :           for (unsigned i = 0; i < SgYieldExpression::pool_size; ++i )
  202953             :              {
  202954             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  202955             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  202956             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  202957             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  202958             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  202959             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  202960             :             // properly; so this will have to be checked next.
  202961             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  202962             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  202963           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  202964             :                   {
  202965           0 :                     pointer[i].set_freepointer((SgYieldExpression*)(globalIndex));
  202966           0 :                     globalIndex++;
  202967             :                   }
  202968             :                else
  202969             :                   {
  202970           0 :                     pointer[i].set_freepointer(NULL);
  202971             :                   }
  202972             :               }
  202973             :         }
  202974           5 :      return globalIndex;
  202975             :    }
  202976             : 
  202977             : //############################################################################
  202978             : // JH (01/14/2006)
  202979             : void
  202980           5 : SgYieldExpression::resetValidFreepointers( )
  202981             :    {
  202982           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  202983           5 :      SgYieldExpression* pointer = NULL;
  202984           5 :      std::vector < unsigned char* > :: const_iterator block;
  202985           5 :      SgYieldExpression* pointerOfLinkedList = NULL;
  202986           5 :      for ( block = SgYieldExpression::pools.begin(); block != SgYieldExpression::pools.end() ; ++block )
  202987             :         {
  202988           0 :           pointer = (SgYieldExpression*)(*block);
  202989           0 :           for (unsigned i = 0; i < SgYieldExpression::pool_size; ++i )
  202990             :              {
  202991             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  202992             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  202993             :             // memory blocks!.
  202994           0 :                if ( pointer[i].get_freepointer() != NULL )
  202995             :                   {
  202996           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  202997             :                   }
  202998             :                else
  202999             :                   {
  203000           0 :                     if ( pointerOfLinkedList == NULL )
  203001             :                        {
  203002           0 :                          SgYieldExpression::next_node = &(pointer[i]);
  203003             :                        }
  203004             :                     else
  203005             :                        {
  203006             :                       // printf ("In SgYieldExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  203007           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  203008             :                        }
  203009             :                     pointerOfLinkedList = &(pointer[i]);
  203010             :                   }
  203011             :               }
  203012             :         }
  203013             : 
  203014           5 :      if ( pointerOfLinkedList != NULL )
  203015             :         {
  203016             :        // printf ("In SgYieldExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  203017           0 :           pointerOfLinkedList->set_freepointer(NULL);
  203018             :        // DQ (6/6/2010): Temporary debugging...
  203019             :        //   ROSE_ASSERT(false);
  203020             :         }
  203021             : 
  203022           5 :      return ;
  203023             :    }
  203024             : 
  203025             : //############################################################################
  203026             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  203027             :  * within the memory pool and resets the freepointers, in order to achieve a 
  203028             :  * linked list, that has no jumps and starts at the beginning! This function 
  203029             :  * does not extend the memory pool, since we do not delete any memory blocks,
  203030             :  * but delete the valid objects.  
  203031             :  */
  203032             : void
  203033           0 : SgYieldExpression::clearMemoryPool( )
  203034             :    {
  203035             :   // printf ("Inside of SgYieldExpression::clearMemoryPool() \n");
  203036             : 
  203037           0 :      SgYieldExpression* pointer = NULL, *tempPointer = NULL;
  203038           0 :      std::vector < unsigned char* > :: const_iterator block;
  203039           0 :      if ( SgYieldExpression::pools.empty() == false )
  203040             :         {
  203041           0 :           block = SgYieldExpression::pools.begin() ;
  203042           0 :           SgYieldExpression::next_node = (SgYieldExpression*) (*block);
  203043             : 
  203044           0 :           while ( block != SgYieldExpression::pools.end() )
  203045             :              {
  203046           0 :                pointer = (SgYieldExpression*) (*block);
  203047           0 :                if ( tempPointer != NULL )
  203048             :                   {
  203049           0 :                     tempPointer->set_freepointer(pointer);
  203050             :                   }
  203051           0 :                for (unsigned i = 0; i < SgYieldExpression::pool_size - 1; ++i)
  203052             :                   {
  203053           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  203054             :                   }
  203055           0 :                 pointer[SgYieldExpression::pool_size-1].set_freepointer(NULL);
  203056           0 :                 tempPointer = &(pointer[SgYieldExpression::pool_size-1]);
  203057           0 :                 ++block;
  203058             :              }
  203059             :         }
  203060           0 :    }
  203061             : 
  203062           5 : void SgYieldExpression::deleteMemoryPool() {
  203063           5 :   for (auto p: SgYieldExpression::pools) {
  203064           0 :     ROSE_FREE(p);
  203065             :   }
  203066           5 :   SgYieldExpression::next_node = nullptr;
  203067           5 :   SgYieldExpression::pools.clear();
  203068           5 : }
  203069             : 
  203070             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  203071             : //                 reading multiple binary files to for a single AST.
  203072             : /////////// new version ////////////////////////////////
  203073             : //############################################################################
  203074             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  203075             : void
  203076           2 : SgYieldExpression::extendMemoryPoolForFileIO( )
  203077             :   {
  203078           2 :     size_t blockIndex = SgYieldExpression::pools.size();
  203079           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgYieldExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgYieldExpression);
  203080             : 
  203081           2 :     while ( (blockIndex * SgYieldExpression::pool_size) < newPoolSize)
  203082             :       {
  203083             : #if ROSE_ALLOC_TRACE
  203084             :         if (blockIndex > 0) {
  203085             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgYieldExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgYieldExpression) = %" PRIuPTR " SgYieldExpression::pool_size = %d \n",
  203086             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgYieldExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgYieldExpression),SgYieldExpression::pool_size);
  203087             :         }
  203088             : #endif
  203089             : 
  203090           0 :         SgYieldExpression * pointer = (SgYieldExpression*) ROSE_MALLOC ( SgYieldExpression::pool_size * sizeof(SgYieldExpression) );
  203091           0 :         assert( pointer != NULL );
  203092             : #if ROSE_ALLOC_MEMSET == 1
  203093             :         memset(pointer, 0x00, SgYieldExpression::pool_size * sizeof(SgYieldExpression));
  203094             : #elif ROSE_ALLOC_MEMSET == 2
  203095             :         memset(pointer, 0xCC, SgYieldExpression::pool_size * sizeof(SgYieldExpression));
  203096             : #endif
  203097           0 :         SgYieldExpression::pools.push_back( (unsigned char*)(pointer) );
  203098           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgYieldExpression::pool_size * sizeof(SgYieldExpression), V_SgYieldExpression ) );
  203099             : 
  203100           0 :         if ( SgYieldExpression::next_node != NULL ) {
  203101           0 :           if ( blockIndex > 0 ) {
  203102           0 :             SgYieldExpression * blkptr = (SgYieldExpression*)(SgYieldExpression::pools[blockIndex-1]);
  203103           0 :             blkptr[ SgYieldExpression::pool_size - 1 ].set_freepointer(pointer);
  203104             :           }
  203105             :         } else {
  203106           0 :           SgYieldExpression::next_node = pointer;
  203107             :         }
  203108             : 
  203109           0 :         for (unsigned i = 0; i < SgYieldExpression::pool_size-1; ++i)
  203110             :            {
  203111           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  203112             :            }
  203113           0 :         pointer[ SgYieldExpression::pool_size -1 ].set_freepointer(NULL);
  203114             : 
  203115           0 :         blockIndex++;
  203116             :       }
  203117           2 :   }
  203118             : 
  203119             : //############################################################################
  203120             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  203121             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  203122             :  * not compressed. However, that stuff is not yet implemented! 
  203123             :  */
  203124             : unsigned long
  203125           0 : SgYieldExpression::getNumberOfLastValidPointer()
  203126             :    {
  203127           0 :       SgYieldExpression* testPointer = (SgYieldExpression*)(SgYieldExpression::pools.back());
  203128           0 :       unsigned long localIndex = SgYieldExpression::pool_size - 1;
  203129           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  203130             :          {
  203131           0 :            localIndex--;
  203132             :          }
  203133           0 :       return (localIndex + SgYieldExpression::pool_size * (SgYieldExpression::pools.size()-1));
  203134             :    }
  203135             : 
  203136             : //############################################################################
  203137             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  203138             :  * memory pool and initializes the data member in class SgYieldExpressionStroageClass
  203139             :  * from its counterpart of SgYieldExpression. The return value is just for checking, 
  203140             :  * that the whole StorageClassArray is initialized!
  203141             :  */
  203142             : unsigned long
  203143           0 : SgYieldExpression::initializeStorageClassArray( SgYieldExpressionStorageClass *storageArray )
  203144             :    {
  203145           0 :      unsigned long storageCounter = 0;
  203146           0 :      std::vector < unsigned char* > :: const_iterator block = SgYieldExpression::pools.begin();
  203147           0 :      SgYieldExpression* pointer = NULL;
  203148           0 :      while ( block != SgYieldExpression::pools.end() ) {
  203149           0 :           pointer = (SgYieldExpression*) (*block);
  203150           0 :           for ( unsigned i = 0; i < SgYieldExpression::pool_size; ++i ) {
  203151           0 :                if ( pointer->get_freepointer() != NULL ) {
  203152           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  203153           0 :                  storageArray++;
  203154           0 :                  storageCounter++;
  203155             :                }
  203156           0 :                pointer++;
  203157             :              }
  203158           0 :            block++;
  203159             :         }
  203160           0 :      return storageCounter;
  203161             :    }
  203162             : 
  203163             : /* #line 203164 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  203164             : 
  203165             : 
  203166             : 
  203167             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  203168             : 
  203169             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  203170             : 
  203171             : //############################################################################
  203172             : /* JH (02/02/2006) Constructor of the IR node SgTemplateFunctionRefExp that takes its 
  203173             :  * corresponding StorageClass as parameter
  203174             :  */
  203175         225 : SgTemplateFunctionRefExp :: SgTemplateFunctionRefExp ( const SgTemplateFunctionRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  203176             :    {
  203177             : 
  203178             : 
  203179             : /* #line 203180 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  203180             : 
  203181         225 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  203182         225 :      p_symbol_i =  (SgTemplateFunctionSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol_i) );
  203183         225 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  203184         225 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  203185         225 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  203186             : 
  203187             : 
  203188             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  203189             : 
  203190             : 
  203191         225 :    }
  203192             : 
  203193             : //############################################################################
  203194             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  203195             :  * within the working AST. 
  203196             :  */
  203197         900 : SgTemplateFunctionRefExp * SgTemplateFunctionRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  203198         900 :      SgTemplateFunctionRefExp* returnPointer = NULL;
  203199         900 :      if ( globalIndex != 0 )
  203200             :         {
  203201             : 
  203202             : #if FILE_IO_EXTRA_CHECK
  203203         900 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateFunctionRefExp ) ) <= globalIndex ) ;
  203204         900 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateFunctionRefExp + 1 ) ) );
  203205             : #endif
  203206         900 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateFunctionRefExp )  
  203207         900 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateFunctionRefExp );
  203208         900 :           unsigned long positionInPool = localIndex % SgTemplateFunctionRefExp::pool_size;
  203209         900 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateFunctionRefExp::pool_size;
  203210             : 
  203211             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  203212             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  203213             : 
  203214         900 :           returnPointer = &( ( (SgTemplateFunctionRefExp*)(SgTemplateFunctionRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  203215             : 
  203216         900 :           ROSE_ASSERT( returnPointer != NULL ) ;
  203217             :         }
  203218         900 :      return returnPointer ;
  203219             :    }
  203220             : 
  203221             : //############################################################################
  203222             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  203223             :   for the AST with the index astIndex
  203224             : */
  203225           0 : SgTemplateFunctionRefExp * SgTemplateFunctionRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  203226           0 :      SgTemplateFunctionRefExp* returnPointer = NULL;
  203227           0 :      if ( globalIndex != 0 )
  203228             :         {
  203229             : 
  203230             : #if FILE_IO_EXTRA_CHECK
  203231           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateFunctionRefExp ) ) <= globalIndex ) ;
  203232           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateFunctionRefExp + 1 ) ) );
  203233             : #endif
  203234           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateFunctionRefExp )
  203235           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateFunctionRefExp );
  203236           0 :           unsigned long positionInPool = localIndex % SgTemplateFunctionRefExp::pool_size ;
  203237           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateFunctionRefExp::pool_size ;
  203238             : 
  203239             : #if FILE_IO_EXTRA_CHECK
  203240             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  203241             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  203242             : #endif
  203243             : 
  203244           0 :           returnPointer = &( ( (SgTemplateFunctionRefExp*)(SgTemplateFunctionRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  203245             : 
  203246             : #if FILE_IO_EXTRA_CHECK
  203247           0 :           assert ( returnPointer != NULL ) ;
  203248             : #endif
  203249             :         }
  203250           0 :      return returnPointer ;
  203251             :    }
  203252             : 
  203253             : //############################################################################
  203254             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  203255             :  * pool size! We set for every valid object in the memory pool the freepointer
  203256             :  * to the global index and increase the global index afterwards. For all the 
  203257             :  * invalid objects (means address ranges within the memory pool that were not
  203258             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  203259             :  * distinguish valid from invalid objects! 
  203260             :  */
  203261             : unsigned long
  203262           5 : SgTemplateFunctionRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  203263             :    {
  203264           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  203265           5 :      SgTemplateFunctionRefExp* pointer = NULL;
  203266           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  203267           5 :      std::vector < unsigned char* > :: const_iterator block;
  203268           6 :      for ( block = SgTemplateFunctionRefExp::pools.begin(); block != SgTemplateFunctionRefExp::pools.end() ; ++block )
  203269             :         {
  203270           1 :           pointer = (SgTemplateFunctionRefExp*)(*block);
  203271        2001 :           for (unsigned i = 0; i < SgTemplateFunctionRefExp::pool_size; ++i )
  203272             :              {
  203273             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  203274             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  203275             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  203276             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  203277             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  203278             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  203279             :             // properly; so this will have to be checked next.
  203280             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  203281             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  203282        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  203283             :                   {
  203284         225 :                     pointer[i].set_freepointer((SgTemplateFunctionRefExp*)(globalIndex));
  203285         225 :                     globalIndex++;
  203286             :                   }
  203287             :                else
  203288             :                   {
  203289        1775 :                     pointer[i].set_freepointer(NULL);
  203290             :                   }
  203291             :               }
  203292             :         }
  203293           5 :      return globalIndex;
  203294             :    }
  203295             : 
  203296             : //############################################################################
  203297             : // JH (01/14/2006)
  203298             : void
  203299           5 : SgTemplateFunctionRefExp::resetValidFreepointers( )
  203300             :    {
  203301           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  203302           5 :      SgTemplateFunctionRefExp* pointer = NULL;
  203303           5 :      std::vector < unsigned char* > :: const_iterator block;
  203304           5 :      SgTemplateFunctionRefExp* pointerOfLinkedList = NULL;
  203305           6 :      for ( block = SgTemplateFunctionRefExp::pools.begin(); block != SgTemplateFunctionRefExp::pools.end() ; ++block )
  203306             :         {
  203307           1 :           pointer = (SgTemplateFunctionRefExp*)(*block);
  203308        2001 :           for (unsigned i = 0; i < SgTemplateFunctionRefExp::pool_size; ++i )
  203309             :              {
  203310             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  203311             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  203312             :             // memory blocks!.
  203313        2000 :                if ( pointer[i].get_freepointer() != NULL )
  203314             :                   {
  203315         225 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  203316             :                   }
  203317             :                else
  203318             :                   {
  203319        1775 :                     if ( pointerOfLinkedList == NULL )
  203320             :                        {
  203321           1 :                          SgTemplateFunctionRefExp::next_node = &(pointer[i]);
  203322             :                        }
  203323             :                     else
  203324             :                        {
  203325             :                       // printf ("In SgTemplateFunctionRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  203326        1774 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  203327             :                        }
  203328             :                     pointerOfLinkedList = &(pointer[i]);
  203329             :                   }
  203330             :               }
  203331             :         }
  203332             : 
  203333           5 :      if ( pointerOfLinkedList != NULL )
  203334             :         {
  203335             :        // printf ("In SgTemplateFunctionRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  203336           1 :           pointerOfLinkedList->set_freepointer(NULL);
  203337             :        // DQ (6/6/2010): Temporary debugging...
  203338             :        //   ROSE_ASSERT(false);
  203339             :         }
  203340             : 
  203341           5 :      return ;
  203342             :    }
  203343             : 
  203344             : //############################################################################
  203345             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  203346             :  * within the memory pool and resets the freepointers, in order to achieve a 
  203347             :  * linked list, that has no jumps and starts at the beginning! This function 
  203348             :  * does not extend the memory pool, since we do not delete any memory blocks,
  203349             :  * but delete the valid objects.  
  203350             :  */
  203351             : void
  203352           0 : SgTemplateFunctionRefExp::clearMemoryPool( )
  203353             :    {
  203354             :   // printf ("Inside of SgTemplateFunctionRefExp::clearMemoryPool() \n");
  203355             : 
  203356           0 :      SgTemplateFunctionRefExp* pointer = NULL, *tempPointer = NULL;
  203357           0 :      std::vector < unsigned char* > :: const_iterator block;
  203358           0 :      if ( SgTemplateFunctionRefExp::pools.empty() == false )
  203359             :         {
  203360           0 :           block = SgTemplateFunctionRefExp::pools.begin() ;
  203361           0 :           SgTemplateFunctionRefExp::next_node = (SgTemplateFunctionRefExp*) (*block);
  203362             : 
  203363           0 :           while ( block != SgTemplateFunctionRefExp::pools.end() )
  203364             :              {
  203365           0 :                pointer = (SgTemplateFunctionRefExp*) (*block);
  203366           0 :                if ( tempPointer != NULL )
  203367             :                   {
  203368           0 :                     tempPointer->set_freepointer(pointer);
  203369             :                   }
  203370           0 :                for (unsigned i = 0; i < SgTemplateFunctionRefExp::pool_size - 1; ++i)
  203371             :                   {
  203372           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  203373             :                   }
  203374           0 :                 pointer[SgTemplateFunctionRefExp::pool_size-1].set_freepointer(NULL);
  203375           0 :                 tempPointer = &(pointer[SgTemplateFunctionRefExp::pool_size-1]);
  203376           0 :                 ++block;
  203377             :              }
  203378             :         }
  203379           0 :    }
  203380             : 
  203381           5 : void SgTemplateFunctionRefExp::deleteMemoryPool() {
  203382           7 :   for (auto p: SgTemplateFunctionRefExp::pools) {
  203383           2 :     ROSE_FREE(p);
  203384             :   }
  203385           5 :   SgTemplateFunctionRefExp::next_node = nullptr;
  203386           5 :   SgTemplateFunctionRefExp::pools.clear();
  203387           5 : }
  203388             : 
  203389             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  203390             : //                 reading multiple binary files to for a single AST.
  203391             : /////////// new version ////////////////////////////////
  203392             : //############################################################################
  203393             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  203394             : void
  203395           2 : SgTemplateFunctionRefExp::extendMemoryPoolForFileIO( )
  203396             :   {
  203397           2 :     size_t blockIndex = SgTemplateFunctionRefExp::pools.size();
  203398           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionRefExp);
  203399             : 
  203400           3 :     while ( (blockIndex * SgTemplateFunctionRefExp::pool_size) < newPoolSize)
  203401             :       {
  203402             : #if ROSE_ALLOC_TRACE
  203403             :         if (blockIndex > 0) {
  203404             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionRefExp) = %" PRIuPTR " SgTemplateFunctionRefExp::pool_size = %d \n",
  203405             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionRefExp),SgTemplateFunctionRefExp::pool_size);
  203406             :         }
  203407             : #endif
  203408             : 
  203409           1 :         SgTemplateFunctionRefExp * pointer = (SgTemplateFunctionRefExp*) ROSE_MALLOC ( SgTemplateFunctionRefExp::pool_size * sizeof(SgTemplateFunctionRefExp) );
  203410           1 :         assert( pointer != NULL );
  203411             : #if ROSE_ALLOC_MEMSET == 1
  203412             :         memset(pointer, 0x00, SgTemplateFunctionRefExp::pool_size * sizeof(SgTemplateFunctionRefExp));
  203413             : #elif ROSE_ALLOC_MEMSET == 2
  203414             :         memset(pointer, 0xCC, SgTemplateFunctionRefExp::pool_size * sizeof(SgTemplateFunctionRefExp));
  203415             : #endif
  203416           1 :         SgTemplateFunctionRefExp::pools.push_back( (unsigned char*)(pointer) );
  203417           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateFunctionRefExp::pool_size * sizeof(SgTemplateFunctionRefExp), V_SgTemplateFunctionRefExp ) );
  203418             : 
  203419           1 :         if ( SgTemplateFunctionRefExp::next_node != NULL ) {
  203420           0 :           if ( blockIndex > 0 ) {
  203421           0 :             SgTemplateFunctionRefExp * blkptr = (SgTemplateFunctionRefExp*)(SgTemplateFunctionRefExp::pools[blockIndex-1]);
  203422           0 :             blkptr[ SgTemplateFunctionRefExp::pool_size - 1 ].set_freepointer(pointer);
  203423             :           }
  203424             :         } else {
  203425           1 :           SgTemplateFunctionRefExp::next_node = pointer;
  203426             :         }
  203427             : 
  203428        2000 :         for (unsigned i = 0; i < SgTemplateFunctionRefExp::pool_size-1; ++i)
  203429             :            {
  203430        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  203431             :            }
  203432           1 :         pointer[ SgTemplateFunctionRefExp::pool_size -1 ].set_freepointer(NULL);
  203433             : 
  203434           1 :         blockIndex++;
  203435             :       }
  203436           2 :   }
  203437             : 
  203438             : //############################################################################
  203439             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  203440             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  203441             :  * not compressed. However, that stuff is not yet implemented! 
  203442             :  */
  203443             : unsigned long
  203444           0 : SgTemplateFunctionRefExp::getNumberOfLastValidPointer()
  203445             :    {
  203446           0 :       SgTemplateFunctionRefExp* testPointer = (SgTemplateFunctionRefExp*)(SgTemplateFunctionRefExp::pools.back());
  203447           0 :       unsigned long localIndex = SgTemplateFunctionRefExp::pool_size - 1;
  203448           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  203449             :          {
  203450           0 :            localIndex--;
  203451             :          }
  203452           0 :       return (localIndex + SgTemplateFunctionRefExp::pool_size * (SgTemplateFunctionRefExp::pools.size()-1));
  203453             :    }
  203454             : 
  203455             : //############################################################################
  203456             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  203457             :  * memory pool and initializes the data member in class SgTemplateFunctionRefExpStroageClass
  203458             :  * from its counterpart of SgTemplateFunctionRefExp. The return value is just for checking, 
  203459             :  * that the whole StorageClassArray is initialized!
  203460             :  */
  203461             : unsigned long
  203462           1 : SgTemplateFunctionRefExp::initializeStorageClassArray( SgTemplateFunctionRefExpStorageClass *storageArray )
  203463             :    {
  203464           1 :      unsigned long storageCounter = 0;
  203465           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateFunctionRefExp::pools.begin();
  203466           1 :      SgTemplateFunctionRefExp* pointer = NULL;
  203467           2 :      while ( block != SgTemplateFunctionRefExp::pools.end() ) {
  203468           1 :           pointer = (SgTemplateFunctionRefExp*) (*block);
  203469        2001 :           for ( unsigned i = 0; i < SgTemplateFunctionRefExp::pool_size; ++i ) {
  203470        2000 :                if ( pointer->get_freepointer() != NULL ) {
  203471         225 :                  storageArray->pickOutIRNodeData (pointer) ;
  203472         225 :                  storageArray++;
  203473         225 :                  storageCounter++;
  203474             :                }
  203475        2000 :                pointer++;
  203476             :              }
  203477           1 :            block++;
  203478             :         }
  203479           1 :      return storageCounter;
  203480             :    }
  203481             : 
  203482             : /* #line 203483 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  203483             : 
  203484             : 
  203485             : 
  203486             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  203487             : 
  203488             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  203489             : 
  203490             : //############################################################################
  203491             : /* JH (02/02/2006) Constructor of the IR node SgTemplateMemberFunctionRefExp that takes its 
  203492             :  * corresponding StorageClass as parameter
  203493             :  */
  203494         738 : SgTemplateMemberFunctionRefExp :: SgTemplateMemberFunctionRefExp ( const SgTemplateMemberFunctionRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  203495             :    {
  203496             : 
  203497             : 
  203498             : /* #line 203499 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  203499             : 
  203500         738 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  203501         738 :      p_symbol_i =  (SgTemplateMemberFunctionSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol_i) );
  203502         738 :      p_virtual_call = storageSource.storageOf_virtual_call ;
  203503         738 :      p_need_qualifier = storageSource.storageOf_need_qualifier ;
  203504         738 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  203505         738 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  203506         738 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  203507             : 
  203508             : 
  203509             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  203510             : 
  203511             : 
  203512         738 :    }
  203513             : 
  203514             : //############################################################################
  203515             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  203516             :  * within the working AST. 
  203517             :  */
  203518        2952 : SgTemplateMemberFunctionRefExp * SgTemplateMemberFunctionRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  203519        2952 :      SgTemplateMemberFunctionRefExp* returnPointer = NULL;
  203520        2952 :      if ( globalIndex != 0 )
  203521             :         {
  203522             : 
  203523             : #if FILE_IO_EXTRA_CHECK
  203524        2952 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateMemberFunctionRefExp ) ) <= globalIndex ) ;
  203525        2952 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateMemberFunctionRefExp + 1 ) ) );
  203526             : #endif
  203527        2952 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateMemberFunctionRefExp )  
  203528        2952 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateMemberFunctionRefExp );
  203529        2952 :           unsigned long positionInPool = localIndex % SgTemplateMemberFunctionRefExp::pool_size;
  203530        2952 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateMemberFunctionRefExp::pool_size;
  203531             : 
  203532             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  203533             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  203534             : 
  203535        2952 :           returnPointer = &( ( (SgTemplateMemberFunctionRefExp*)(SgTemplateMemberFunctionRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  203536             : 
  203537        2952 :           ROSE_ASSERT( returnPointer != NULL ) ;
  203538             :         }
  203539        2952 :      return returnPointer ;
  203540             :    }
  203541             : 
  203542             : //############################################################################
  203543             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  203544             :   for the AST with the index astIndex
  203545             : */
  203546           0 : SgTemplateMemberFunctionRefExp * SgTemplateMemberFunctionRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  203547           0 :      SgTemplateMemberFunctionRefExp* returnPointer = NULL;
  203548           0 :      if ( globalIndex != 0 )
  203549             :         {
  203550             : 
  203551             : #if FILE_IO_EXTRA_CHECK
  203552           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateMemberFunctionRefExp ) ) <= globalIndex ) ;
  203553           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateMemberFunctionRefExp + 1 ) ) );
  203554             : #endif
  203555           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateMemberFunctionRefExp )
  203556           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateMemberFunctionRefExp );
  203557           0 :           unsigned long positionInPool = localIndex % SgTemplateMemberFunctionRefExp::pool_size ;
  203558           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateMemberFunctionRefExp::pool_size ;
  203559             : 
  203560             : #if FILE_IO_EXTRA_CHECK
  203561             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  203562             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  203563             : #endif
  203564             : 
  203565           0 :           returnPointer = &( ( (SgTemplateMemberFunctionRefExp*)(SgTemplateMemberFunctionRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  203566             : 
  203567             : #if FILE_IO_EXTRA_CHECK
  203568           0 :           assert ( returnPointer != NULL ) ;
  203569             : #endif
  203570             :         }
  203571           0 :      return returnPointer ;
  203572             :    }
  203573             : 
  203574             : //############################################################################
  203575             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  203576             :  * pool size! We set for every valid object in the memory pool the freepointer
  203577             :  * to the global index and increase the global index afterwards. For all the 
  203578             :  * invalid objects (means address ranges within the memory pool that were not
  203579             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  203580             :  * distinguish valid from invalid objects! 
  203581             :  */
  203582             : unsigned long
  203583           5 : SgTemplateMemberFunctionRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  203584             :    {
  203585           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  203586           5 :      SgTemplateMemberFunctionRefExp* pointer = NULL;
  203587           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  203588           5 :      std::vector < unsigned char* > :: const_iterator block;
  203589           6 :      for ( block = SgTemplateMemberFunctionRefExp::pools.begin(); block != SgTemplateMemberFunctionRefExp::pools.end() ; ++block )
  203590             :         {
  203591           1 :           pointer = (SgTemplateMemberFunctionRefExp*)(*block);
  203592        2001 :           for (unsigned i = 0; i < SgTemplateMemberFunctionRefExp::pool_size; ++i )
  203593             :              {
  203594             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  203595             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  203596             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  203597             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  203598             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  203599             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  203600             :             // properly; so this will have to be checked next.
  203601             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  203602             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  203603        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  203604             :                   {
  203605         738 :                     pointer[i].set_freepointer((SgTemplateMemberFunctionRefExp*)(globalIndex));
  203606         738 :                     globalIndex++;
  203607             :                   }
  203608             :                else
  203609             :                   {
  203610        1262 :                     pointer[i].set_freepointer(NULL);
  203611             :                   }
  203612             :               }
  203613             :         }
  203614           5 :      return globalIndex;
  203615             :    }
  203616             : 
  203617             : //############################################################################
  203618             : // JH (01/14/2006)
  203619             : void
  203620           5 : SgTemplateMemberFunctionRefExp::resetValidFreepointers( )
  203621             :    {
  203622           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  203623           5 :      SgTemplateMemberFunctionRefExp* pointer = NULL;
  203624           5 :      std::vector < unsigned char* > :: const_iterator block;
  203625           5 :      SgTemplateMemberFunctionRefExp* pointerOfLinkedList = NULL;
  203626           6 :      for ( block = SgTemplateMemberFunctionRefExp::pools.begin(); block != SgTemplateMemberFunctionRefExp::pools.end() ; ++block )
  203627             :         {
  203628           1 :           pointer = (SgTemplateMemberFunctionRefExp*)(*block);
  203629        2001 :           for (unsigned i = 0; i < SgTemplateMemberFunctionRefExp::pool_size; ++i )
  203630             :              {
  203631             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  203632             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  203633             :             // memory blocks!.
  203634        2000 :                if ( pointer[i].get_freepointer() != NULL )
  203635             :                   {
  203636         738 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  203637             :                   }
  203638             :                else
  203639             :                   {
  203640        1262 :                     if ( pointerOfLinkedList == NULL )
  203641             :                        {
  203642           1 :                          SgTemplateMemberFunctionRefExp::next_node = &(pointer[i]);
  203643             :                        }
  203644             :                     else
  203645             :                        {
  203646             :                       // printf ("In SgTemplateMemberFunctionRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  203647        1261 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  203648             :                        }
  203649             :                     pointerOfLinkedList = &(pointer[i]);
  203650             :                   }
  203651             :               }
  203652             :         }
  203653             : 
  203654           5 :      if ( pointerOfLinkedList != NULL )
  203655             :         {
  203656             :        // printf ("In SgTemplateMemberFunctionRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  203657           1 :           pointerOfLinkedList->set_freepointer(NULL);
  203658             :        // DQ (6/6/2010): Temporary debugging...
  203659             :        //   ROSE_ASSERT(false);
  203660             :         }
  203661             : 
  203662           5 :      return ;
  203663             :    }
  203664             : 
  203665             : //############################################################################
  203666             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  203667             :  * within the memory pool and resets the freepointers, in order to achieve a 
  203668             :  * linked list, that has no jumps and starts at the beginning! This function 
  203669             :  * does not extend the memory pool, since we do not delete any memory blocks,
  203670             :  * but delete the valid objects.  
  203671             :  */
  203672             : void
  203673           0 : SgTemplateMemberFunctionRefExp::clearMemoryPool( )
  203674             :    {
  203675             :   // printf ("Inside of SgTemplateMemberFunctionRefExp::clearMemoryPool() \n");
  203676             : 
  203677           0 :      SgTemplateMemberFunctionRefExp* pointer = NULL, *tempPointer = NULL;
  203678           0 :      std::vector < unsigned char* > :: const_iterator block;
  203679           0 :      if ( SgTemplateMemberFunctionRefExp::pools.empty() == false )
  203680             :         {
  203681           0 :           block = SgTemplateMemberFunctionRefExp::pools.begin() ;
  203682           0 :           SgTemplateMemberFunctionRefExp::next_node = (SgTemplateMemberFunctionRefExp*) (*block);
  203683             : 
  203684           0 :           while ( block != SgTemplateMemberFunctionRefExp::pools.end() )
  203685             :              {
  203686           0 :                pointer = (SgTemplateMemberFunctionRefExp*) (*block);
  203687           0 :                if ( tempPointer != NULL )
  203688             :                   {
  203689           0 :                     tempPointer->set_freepointer(pointer);
  203690             :                   }
  203691           0 :                for (unsigned i = 0; i < SgTemplateMemberFunctionRefExp::pool_size - 1; ++i)
  203692             :                   {
  203693           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  203694             :                   }
  203695           0 :                 pointer[SgTemplateMemberFunctionRefExp::pool_size-1].set_freepointer(NULL);
  203696           0 :                 tempPointer = &(pointer[SgTemplateMemberFunctionRefExp::pool_size-1]);
  203697           0 :                 ++block;
  203698             :              }
  203699             :         }
  203700           0 :    }
  203701             : 
  203702           5 : void SgTemplateMemberFunctionRefExp::deleteMemoryPool() {
  203703           7 :   for (auto p: SgTemplateMemberFunctionRefExp::pools) {
  203704           2 :     ROSE_FREE(p);
  203705             :   }
  203706           5 :   SgTemplateMemberFunctionRefExp::next_node = nullptr;
  203707           5 :   SgTemplateMemberFunctionRefExp::pools.clear();
  203708           5 : }
  203709             : 
  203710             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  203711             : //                 reading multiple binary files to for a single AST.
  203712             : /////////// new version ////////////////////////////////
  203713             : //############################################################################
  203714             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  203715             : void
  203716           2 : SgTemplateMemberFunctionRefExp::extendMemoryPoolForFileIO( )
  203717             :   {
  203718           2 :     size_t blockIndex = SgTemplateMemberFunctionRefExp::pools.size();
  203719           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionRefExp);
  203720             : 
  203721           3 :     while ( (blockIndex * SgTemplateMemberFunctionRefExp::pool_size) < newPoolSize)
  203722             :       {
  203723             : #if ROSE_ALLOC_TRACE
  203724             :         if (blockIndex > 0) {
  203725             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionRefExp) = %" PRIuPTR " SgTemplateMemberFunctionRefExp::pool_size = %d \n",
  203726             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionRefExp),SgTemplateMemberFunctionRefExp::pool_size);
  203727             :         }
  203728             : #endif
  203729             : 
  203730           1 :         SgTemplateMemberFunctionRefExp * pointer = (SgTemplateMemberFunctionRefExp*) ROSE_MALLOC ( SgTemplateMemberFunctionRefExp::pool_size * sizeof(SgTemplateMemberFunctionRefExp) );
  203731           1 :         assert( pointer != NULL );
  203732             : #if ROSE_ALLOC_MEMSET == 1
  203733             :         memset(pointer, 0x00, SgTemplateMemberFunctionRefExp::pool_size * sizeof(SgTemplateMemberFunctionRefExp));
  203734             : #elif ROSE_ALLOC_MEMSET == 2
  203735             :         memset(pointer, 0xCC, SgTemplateMemberFunctionRefExp::pool_size * sizeof(SgTemplateMemberFunctionRefExp));
  203736             : #endif
  203737           1 :         SgTemplateMemberFunctionRefExp::pools.push_back( (unsigned char*)(pointer) );
  203738           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateMemberFunctionRefExp::pool_size * sizeof(SgTemplateMemberFunctionRefExp), V_SgTemplateMemberFunctionRefExp ) );
  203739             : 
  203740           1 :         if ( SgTemplateMemberFunctionRefExp::next_node != NULL ) {
  203741           0 :           if ( blockIndex > 0 ) {
  203742           0 :             SgTemplateMemberFunctionRefExp * blkptr = (SgTemplateMemberFunctionRefExp*)(SgTemplateMemberFunctionRefExp::pools[blockIndex-1]);
  203743           0 :             blkptr[ SgTemplateMemberFunctionRefExp::pool_size - 1 ].set_freepointer(pointer);
  203744             :           }
  203745             :         } else {
  203746           1 :           SgTemplateMemberFunctionRefExp::next_node = pointer;
  203747             :         }
  203748             : 
  203749        2000 :         for (unsigned i = 0; i < SgTemplateMemberFunctionRefExp::pool_size-1; ++i)
  203750             :            {
  203751        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  203752             :            }
  203753           1 :         pointer[ SgTemplateMemberFunctionRefExp::pool_size -1 ].set_freepointer(NULL);
  203754             : 
  203755           1 :         blockIndex++;
  203756             :       }
  203757           2 :   }
  203758             : 
  203759             : //############################################################################
  203760             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  203761             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  203762             :  * not compressed. However, that stuff is not yet implemented! 
  203763             :  */
  203764             : unsigned long
  203765           0 : SgTemplateMemberFunctionRefExp::getNumberOfLastValidPointer()
  203766             :    {
  203767           0 :       SgTemplateMemberFunctionRefExp* testPointer = (SgTemplateMemberFunctionRefExp*)(SgTemplateMemberFunctionRefExp::pools.back());
  203768           0 :       unsigned long localIndex = SgTemplateMemberFunctionRefExp::pool_size - 1;
  203769           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  203770             :          {
  203771           0 :            localIndex--;
  203772             :          }
  203773           0 :       return (localIndex + SgTemplateMemberFunctionRefExp::pool_size * (SgTemplateMemberFunctionRefExp::pools.size()-1));
  203774             :    }
  203775             : 
  203776             : //############################################################################
  203777             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  203778             :  * memory pool and initializes the data member in class SgTemplateMemberFunctionRefExpStroageClass
  203779             :  * from its counterpart of SgTemplateMemberFunctionRefExp. The return value is just for checking, 
  203780             :  * that the whole StorageClassArray is initialized!
  203781             :  */
  203782             : unsigned long
  203783           1 : SgTemplateMemberFunctionRefExp::initializeStorageClassArray( SgTemplateMemberFunctionRefExpStorageClass *storageArray )
  203784             :    {
  203785           1 :      unsigned long storageCounter = 0;
  203786           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateMemberFunctionRefExp::pools.begin();
  203787           1 :      SgTemplateMemberFunctionRefExp* pointer = NULL;
  203788           2 :      while ( block != SgTemplateMemberFunctionRefExp::pools.end() ) {
  203789           1 :           pointer = (SgTemplateMemberFunctionRefExp*) (*block);
  203790        2001 :           for ( unsigned i = 0; i < SgTemplateMemberFunctionRefExp::pool_size; ++i ) {
  203791        2000 :                if ( pointer->get_freepointer() != NULL ) {
  203792         738 :                  storageArray->pickOutIRNodeData (pointer) ;
  203793         738 :                  storageArray++;
  203794         738 :                  storageCounter++;
  203795             :                }
  203796        2000 :                pointer++;
  203797             :              }
  203798           1 :            block++;
  203799             :         }
  203800           1 :      return storageCounter;
  203801             :    }
  203802             : 
  203803             : /* #line 203804 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  203804             : 
  203805             : 
  203806             : 
  203807             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  203808             : 
  203809             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  203810             : 
  203811             : //############################################################################
  203812             : /* JH (02/02/2006) Constructor of the IR node SgAlignOfOp that takes its 
  203813             :  * corresponding StorageClass as parameter
  203814             :  */
  203815           5 : SgAlignOfOp :: SgAlignOfOp ( const SgAlignOfOpStorageClass& storageSource )   : SgExpression (storageSource)
  203816             :    {
  203817             : 
  203818             : 
  203819             : /* #line 203820 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  203820             : 
  203821           5 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  203822           5 :      p_operand_expr =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_expr) );
  203823           5 :      p_operand_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_type) );
  203824           5 :      p_expression_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_expression_type) );
  203825           5 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  203826           5 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  203827           5 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  203828           5 :      p_alignOfContainsBaseTypeDefiningDeclaration = storageSource.storageOf_alignOfContainsBaseTypeDefiningDeclaration ;
  203829             : 
  203830             : 
  203831             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  203832             : 
  203833             : 
  203834           5 :    }
  203835             : 
  203836             : //############################################################################
  203837             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  203838             :  * within the working AST. 
  203839             :  */
  203840          20 : SgAlignOfOp * SgAlignOfOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  203841          20 :      SgAlignOfOp* returnPointer = NULL;
  203842          20 :      if ( globalIndex != 0 )
  203843             :         {
  203844             : 
  203845             : #if FILE_IO_EXTRA_CHECK
  203846          20 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAlignOfOp ) ) <= globalIndex ) ;
  203847          20 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAlignOfOp + 1 ) ) );
  203848             : #endif
  203849          20 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAlignOfOp )  
  203850          20 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAlignOfOp );
  203851          20 :           unsigned long positionInPool = localIndex % SgAlignOfOp::pool_size;
  203852          20 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAlignOfOp::pool_size;
  203853             : 
  203854             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  203855             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  203856             : 
  203857          20 :           returnPointer = &( ( (SgAlignOfOp*)(SgAlignOfOp::pools[memoryBlock]) ) [positionInPool]) ;
  203858             : 
  203859          20 :           ROSE_ASSERT( returnPointer != NULL ) ;
  203860             :         }
  203861          20 :      return returnPointer ;
  203862             :    }
  203863             : 
  203864             : //############################################################################
  203865             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  203866             :   for the AST with the index astIndex
  203867             : */
  203868           0 : SgAlignOfOp * SgAlignOfOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  203869           0 :      SgAlignOfOp* returnPointer = NULL;
  203870           0 :      if ( globalIndex != 0 )
  203871             :         {
  203872             : 
  203873             : #if FILE_IO_EXTRA_CHECK
  203874           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAlignOfOp ) ) <= globalIndex ) ;
  203875           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAlignOfOp + 1 ) ) );
  203876             : #endif
  203877           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAlignOfOp )
  203878           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAlignOfOp );
  203879           0 :           unsigned long positionInPool = localIndex % SgAlignOfOp::pool_size ;
  203880           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAlignOfOp::pool_size ;
  203881             : 
  203882             : #if FILE_IO_EXTRA_CHECK
  203883             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  203884             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  203885             : #endif
  203886             : 
  203887           0 :           returnPointer = &( ( (SgAlignOfOp*)(SgAlignOfOp::pools[memoryBlock]) ) [positionInPool]) ;
  203888             : 
  203889             : #if FILE_IO_EXTRA_CHECK
  203890           0 :           assert ( returnPointer != NULL ) ;
  203891             : #endif
  203892             :         }
  203893           0 :      return returnPointer ;
  203894             :    }
  203895             : 
  203896             : //############################################################################
  203897             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  203898             :  * pool size! We set for every valid object in the memory pool the freepointer
  203899             :  * to the global index and increase the global index afterwards. For all the 
  203900             :  * invalid objects (means address ranges within the memory pool that were not
  203901             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  203902             :  * distinguish valid from invalid objects! 
  203903             :  */
  203904             : unsigned long
  203905           5 : SgAlignOfOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  203906             :    {
  203907           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  203908           5 :      SgAlignOfOp* pointer = NULL;
  203909           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  203910           5 :      std::vector < unsigned char* > :: const_iterator block;
  203911           6 :      for ( block = SgAlignOfOp::pools.begin(); block != SgAlignOfOp::pools.end() ; ++block )
  203912             :         {
  203913           1 :           pointer = (SgAlignOfOp*)(*block);
  203914        2001 :           for (unsigned i = 0; i < SgAlignOfOp::pool_size; ++i )
  203915             :              {
  203916             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  203917             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  203918             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  203919             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  203920             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  203921             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  203922             :             // properly; so this will have to be checked next.
  203923             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  203924             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  203925        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  203926             :                   {
  203927           5 :                     pointer[i].set_freepointer((SgAlignOfOp*)(globalIndex));
  203928           5 :                     globalIndex++;
  203929             :                   }
  203930             :                else
  203931             :                   {
  203932        1995 :                     pointer[i].set_freepointer(NULL);
  203933             :                   }
  203934             :               }
  203935             :         }
  203936           5 :      return globalIndex;
  203937             :    }
  203938             : 
  203939             : //############################################################################
  203940             : // JH (01/14/2006)
  203941             : void
  203942           5 : SgAlignOfOp::resetValidFreepointers( )
  203943             :    {
  203944           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  203945           5 :      SgAlignOfOp* pointer = NULL;
  203946           5 :      std::vector < unsigned char* > :: const_iterator block;
  203947           5 :      SgAlignOfOp* pointerOfLinkedList = NULL;
  203948           6 :      for ( block = SgAlignOfOp::pools.begin(); block != SgAlignOfOp::pools.end() ; ++block )
  203949             :         {
  203950           1 :           pointer = (SgAlignOfOp*)(*block);
  203951        2001 :           for (unsigned i = 0; i < SgAlignOfOp::pool_size; ++i )
  203952             :              {
  203953             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  203954             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  203955             :             // memory blocks!.
  203956        2000 :                if ( pointer[i].get_freepointer() != NULL )
  203957             :                   {
  203958           5 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  203959             :                   }
  203960             :                else
  203961             :                   {
  203962        1995 :                     if ( pointerOfLinkedList == NULL )
  203963             :                        {
  203964           1 :                          SgAlignOfOp::next_node = &(pointer[i]);
  203965             :                        }
  203966             :                     else
  203967             :                        {
  203968             :                       // printf ("In SgAlignOfOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  203969        1994 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  203970             :                        }
  203971             :                     pointerOfLinkedList = &(pointer[i]);
  203972             :                   }
  203973             :               }
  203974             :         }
  203975             : 
  203976           5 :      if ( pointerOfLinkedList != NULL )
  203977             :         {
  203978             :        // printf ("In SgAlignOfOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  203979           1 :           pointerOfLinkedList->set_freepointer(NULL);
  203980             :        // DQ (6/6/2010): Temporary debugging...
  203981             :        //   ROSE_ASSERT(false);
  203982             :         }
  203983             : 
  203984           5 :      return ;
  203985             :    }
  203986             : 
  203987             : //############################################################################
  203988             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  203989             :  * within the memory pool and resets the freepointers, in order to achieve a 
  203990             :  * linked list, that has no jumps and starts at the beginning! This function 
  203991             :  * does not extend the memory pool, since we do not delete any memory blocks,
  203992             :  * but delete the valid objects.  
  203993             :  */
  203994             : void
  203995           0 : SgAlignOfOp::clearMemoryPool( )
  203996             :    {
  203997             :   // printf ("Inside of SgAlignOfOp::clearMemoryPool() \n");
  203998             : 
  203999           0 :      SgAlignOfOp* pointer = NULL, *tempPointer = NULL;
  204000           0 :      std::vector < unsigned char* > :: const_iterator block;
  204001           0 :      if ( SgAlignOfOp::pools.empty() == false )
  204002             :         {
  204003           0 :           block = SgAlignOfOp::pools.begin() ;
  204004           0 :           SgAlignOfOp::next_node = (SgAlignOfOp*) (*block);
  204005             : 
  204006           0 :           while ( block != SgAlignOfOp::pools.end() )
  204007             :              {
  204008           0 :                pointer = (SgAlignOfOp*) (*block);
  204009           0 :                if ( tempPointer != NULL )
  204010             :                   {
  204011           0 :                     tempPointer->set_freepointer(pointer);
  204012             :                   }
  204013           0 :                for (unsigned i = 0; i < SgAlignOfOp::pool_size - 1; ++i)
  204014             :                   {
  204015           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  204016             :                   }
  204017           0 :                 pointer[SgAlignOfOp::pool_size-1].set_freepointer(NULL);
  204018           0 :                 tempPointer = &(pointer[SgAlignOfOp::pool_size-1]);
  204019           0 :                 ++block;
  204020             :              }
  204021             :         }
  204022           0 :    }
  204023             : 
  204024           5 : void SgAlignOfOp::deleteMemoryPool() {
  204025           7 :   for (auto p: SgAlignOfOp::pools) {
  204026           2 :     ROSE_FREE(p);
  204027             :   }
  204028           5 :   SgAlignOfOp::next_node = nullptr;
  204029           5 :   SgAlignOfOp::pools.clear();
  204030           5 : }
  204031             : 
  204032             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  204033             : //                 reading multiple binary files to for a single AST.
  204034             : /////////// new version ////////////////////////////////
  204035             : //############################################################################
  204036             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  204037             : void
  204038           2 : SgAlignOfOp::extendMemoryPoolForFileIO( )
  204039             :   {
  204040           2 :     size_t blockIndex = SgAlignOfOp::pools.size();
  204041           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAlignOfOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAlignOfOp);
  204042             : 
  204043           3 :     while ( (blockIndex * SgAlignOfOp::pool_size) < newPoolSize)
  204044             :       {
  204045             : #if ROSE_ALLOC_TRACE
  204046             :         if (blockIndex > 0) {
  204047             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAlignOfOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAlignOfOp) = %" PRIuPTR " SgAlignOfOp::pool_size = %d \n",
  204048             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAlignOfOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAlignOfOp),SgAlignOfOp::pool_size);
  204049             :         }
  204050             : #endif
  204051             : 
  204052           1 :         SgAlignOfOp * pointer = (SgAlignOfOp*) ROSE_MALLOC ( SgAlignOfOp::pool_size * sizeof(SgAlignOfOp) );
  204053           1 :         assert( pointer != NULL );
  204054             : #if ROSE_ALLOC_MEMSET == 1
  204055             :         memset(pointer, 0x00, SgAlignOfOp::pool_size * sizeof(SgAlignOfOp));
  204056             : #elif ROSE_ALLOC_MEMSET == 2
  204057             :         memset(pointer, 0xCC, SgAlignOfOp::pool_size * sizeof(SgAlignOfOp));
  204058             : #endif
  204059           1 :         SgAlignOfOp::pools.push_back( (unsigned char*)(pointer) );
  204060           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAlignOfOp::pool_size * sizeof(SgAlignOfOp), V_SgAlignOfOp ) );
  204061             : 
  204062           1 :         if ( SgAlignOfOp::next_node != NULL ) {
  204063           0 :           if ( blockIndex > 0 ) {
  204064           0 :             SgAlignOfOp * blkptr = (SgAlignOfOp*)(SgAlignOfOp::pools[blockIndex-1]);
  204065           0 :             blkptr[ SgAlignOfOp::pool_size - 1 ].set_freepointer(pointer);
  204066             :           }
  204067             :         } else {
  204068           1 :           SgAlignOfOp::next_node = pointer;
  204069             :         }
  204070             : 
  204071        2000 :         for (unsigned i = 0; i < SgAlignOfOp::pool_size-1; ++i)
  204072             :            {
  204073        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  204074             :            }
  204075           1 :         pointer[ SgAlignOfOp::pool_size -1 ].set_freepointer(NULL);
  204076             : 
  204077           1 :         blockIndex++;
  204078             :       }
  204079           2 :   }
  204080             : 
  204081             : //############################################################################
  204082             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  204083             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  204084             :  * not compressed. However, that stuff is not yet implemented! 
  204085             :  */
  204086             : unsigned long
  204087           0 : SgAlignOfOp::getNumberOfLastValidPointer()
  204088             :    {
  204089           0 :       SgAlignOfOp* testPointer = (SgAlignOfOp*)(SgAlignOfOp::pools.back());
  204090           0 :       unsigned long localIndex = SgAlignOfOp::pool_size - 1;
  204091           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  204092             :          {
  204093           0 :            localIndex--;
  204094             :          }
  204095           0 :       return (localIndex + SgAlignOfOp::pool_size * (SgAlignOfOp::pools.size()-1));
  204096             :    }
  204097             : 
  204098             : //############################################################################
  204099             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  204100             :  * memory pool and initializes the data member in class SgAlignOfOpStroageClass
  204101             :  * from its counterpart of SgAlignOfOp. The return value is just for checking, 
  204102             :  * that the whole StorageClassArray is initialized!
  204103             :  */
  204104             : unsigned long
  204105           1 : SgAlignOfOp::initializeStorageClassArray( SgAlignOfOpStorageClass *storageArray )
  204106             :    {
  204107           1 :      unsigned long storageCounter = 0;
  204108           1 :      std::vector < unsigned char* > :: const_iterator block = SgAlignOfOp::pools.begin();
  204109           1 :      SgAlignOfOp* pointer = NULL;
  204110           2 :      while ( block != SgAlignOfOp::pools.end() ) {
  204111           1 :           pointer = (SgAlignOfOp*) (*block);
  204112        2001 :           for ( unsigned i = 0; i < SgAlignOfOp::pool_size; ++i ) {
  204113        2000 :                if ( pointer->get_freepointer() != NULL ) {
  204114           5 :                  storageArray->pickOutIRNodeData (pointer) ;
  204115           5 :                  storageArray++;
  204116           5 :                  storageCounter++;
  204117             :                }
  204118        2000 :                pointer++;
  204119             :              }
  204120           1 :            block++;
  204121             :         }
  204122           1 :      return storageCounter;
  204123             :    }
  204124             : 
  204125             : /* #line 204126 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  204126             : 
  204127             : 
  204128             : 
  204129             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  204130             : 
  204131             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  204132             : 
  204133             : //############################################################################
  204134             : /* JH (02/02/2006) Constructor of the IR node SgRangeExp that takes its 
  204135             :  * corresponding StorageClass as parameter
  204136             :  */
  204137           0 : SgRangeExp :: SgRangeExp ( const SgRangeExpStorageClass& storageSource )   : SgExpression (storageSource)
  204138             :    {
  204139             : 
  204140             : 
  204141             : /* #line 204142 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  204142             : 
  204143           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  204144           0 :      p_start =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_start) );
  204145           0 :      p_end =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_end) );
  204146           0 :      p_stride =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_stride) );
  204147             : 
  204148             : 
  204149             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  204150             : 
  204151             : 
  204152           0 :    }
  204153             : 
  204154             : //############################################################################
  204155             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  204156             :  * within the working AST. 
  204157             :  */
  204158           0 : SgRangeExp * SgRangeExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  204159           0 :      SgRangeExp* returnPointer = NULL;
  204160           0 :      if ( globalIndex != 0 )
  204161             :         {
  204162             : 
  204163             : #if FILE_IO_EXTRA_CHECK
  204164           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRangeExp ) ) <= globalIndex ) ;
  204165           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRangeExp + 1 ) ) );
  204166             : #endif
  204167           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRangeExp )  
  204168           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRangeExp );
  204169           0 :           unsigned long positionInPool = localIndex % SgRangeExp::pool_size;
  204170           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRangeExp::pool_size;
  204171             : 
  204172             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  204173             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  204174             : 
  204175           0 :           returnPointer = &( ( (SgRangeExp*)(SgRangeExp::pools[memoryBlock]) ) [positionInPool]) ;
  204176             : 
  204177           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  204178             :         }
  204179           0 :      return returnPointer ;
  204180             :    }
  204181             : 
  204182             : //############################################################################
  204183             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  204184             :   for the AST with the index astIndex
  204185             : */
  204186           0 : SgRangeExp * SgRangeExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  204187           0 :      SgRangeExp* returnPointer = NULL;
  204188           0 :      if ( globalIndex != 0 )
  204189             :         {
  204190             : 
  204191             : #if FILE_IO_EXTRA_CHECK
  204192           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRangeExp ) ) <= globalIndex ) ;
  204193           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRangeExp + 1 ) ) );
  204194             : #endif
  204195           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRangeExp )
  204196           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRangeExp );
  204197           0 :           unsigned long positionInPool = localIndex % SgRangeExp::pool_size ;
  204198           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRangeExp::pool_size ;
  204199             : 
  204200             : #if FILE_IO_EXTRA_CHECK
  204201             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  204202             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  204203             : #endif
  204204             : 
  204205           0 :           returnPointer = &( ( (SgRangeExp*)(SgRangeExp::pools[memoryBlock]) ) [positionInPool]) ;
  204206             : 
  204207             : #if FILE_IO_EXTRA_CHECK
  204208           0 :           assert ( returnPointer != NULL ) ;
  204209             : #endif
  204210             :         }
  204211           0 :      return returnPointer ;
  204212             :    }
  204213             : 
  204214             : //############################################################################
  204215             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  204216             :  * pool size! We set for every valid object in the memory pool the freepointer
  204217             :  * to the global index and increase the global index afterwards. For all the 
  204218             :  * invalid objects (means address ranges within the memory pool that were not
  204219             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  204220             :  * distinguish valid from invalid objects! 
  204221             :  */
  204222             : unsigned long
  204223           5 : SgRangeExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  204224             :    {
  204225           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  204226           5 :      SgRangeExp* pointer = NULL;
  204227           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  204228           5 :      std::vector < unsigned char* > :: const_iterator block;
  204229           5 :      for ( block = SgRangeExp::pools.begin(); block != SgRangeExp::pools.end() ; ++block )
  204230             :         {
  204231           0 :           pointer = (SgRangeExp*)(*block);
  204232           0 :           for (unsigned i = 0; i < SgRangeExp::pool_size; ++i )
  204233             :              {
  204234             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  204235             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  204236             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  204237             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  204238             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  204239             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  204240             :             // properly; so this will have to be checked next.
  204241             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  204242             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  204243           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  204244             :                   {
  204245           0 :                     pointer[i].set_freepointer((SgRangeExp*)(globalIndex));
  204246           0 :                     globalIndex++;
  204247             :                   }
  204248             :                else
  204249             :                   {
  204250           0 :                     pointer[i].set_freepointer(NULL);
  204251             :                   }
  204252             :               }
  204253             :         }
  204254           5 :      return globalIndex;
  204255             :    }
  204256             : 
  204257             : //############################################################################
  204258             : // JH (01/14/2006)
  204259             : void
  204260           5 : SgRangeExp::resetValidFreepointers( )
  204261             :    {
  204262           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  204263           5 :      SgRangeExp* pointer = NULL;
  204264           5 :      std::vector < unsigned char* > :: const_iterator block;
  204265           5 :      SgRangeExp* pointerOfLinkedList = NULL;
  204266           5 :      for ( block = SgRangeExp::pools.begin(); block != SgRangeExp::pools.end() ; ++block )
  204267             :         {
  204268           0 :           pointer = (SgRangeExp*)(*block);
  204269           0 :           for (unsigned i = 0; i < SgRangeExp::pool_size; ++i )
  204270             :              {
  204271             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  204272             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  204273             :             // memory blocks!.
  204274           0 :                if ( pointer[i].get_freepointer() != NULL )
  204275             :                   {
  204276           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  204277             :                   }
  204278             :                else
  204279             :                   {
  204280           0 :                     if ( pointerOfLinkedList == NULL )
  204281             :                        {
  204282           0 :                          SgRangeExp::next_node = &(pointer[i]);
  204283             :                        }
  204284             :                     else
  204285             :                        {
  204286             :                       // printf ("In SgRangeExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  204287           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  204288             :                        }
  204289             :                     pointerOfLinkedList = &(pointer[i]);
  204290             :                   }
  204291             :               }
  204292             :         }
  204293             : 
  204294           5 :      if ( pointerOfLinkedList != NULL )
  204295             :         {
  204296             :        // printf ("In SgRangeExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  204297           0 :           pointerOfLinkedList->set_freepointer(NULL);
  204298             :        // DQ (6/6/2010): Temporary debugging...
  204299             :        //   ROSE_ASSERT(false);
  204300             :         }
  204301             : 
  204302           5 :      return ;
  204303             :    }
  204304             : 
  204305             : //############################################################################
  204306             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  204307             :  * within the memory pool and resets the freepointers, in order to achieve a 
  204308             :  * linked list, that has no jumps and starts at the beginning! This function 
  204309             :  * does not extend the memory pool, since we do not delete any memory blocks,
  204310             :  * but delete the valid objects.  
  204311             :  */
  204312             : void
  204313           0 : SgRangeExp::clearMemoryPool( )
  204314             :    {
  204315             :   // printf ("Inside of SgRangeExp::clearMemoryPool() \n");
  204316             : 
  204317           0 :      SgRangeExp* pointer = NULL, *tempPointer = NULL;
  204318           0 :      std::vector < unsigned char* > :: const_iterator block;
  204319           0 :      if ( SgRangeExp::pools.empty() == false )
  204320             :         {
  204321           0 :           block = SgRangeExp::pools.begin() ;
  204322           0 :           SgRangeExp::next_node = (SgRangeExp*) (*block);
  204323             : 
  204324           0 :           while ( block != SgRangeExp::pools.end() )
  204325             :              {
  204326           0 :                pointer = (SgRangeExp*) (*block);
  204327           0 :                if ( tempPointer != NULL )
  204328             :                   {
  204329           0 :                     tempPointer->set_freepointer(pointer);
  204330             :                   }
  204331           0 :                for (unsigned i = 0; i < SgRangeExp::pool_size - 1; ++i)
  204332             :                   {
  204333           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  204334             :                   }
  204335           0 :                 pointer[SgRangeExp::pool_size-1].set_freepointer(NULL);
  204336           0 :                 tempPointer = &(pointer[SgRangeExp::pool_size-1]);
  204337           0 :                 ++block;
  204338             :              }
  204339             :         }
  204340           0 :    }
  204341             : 
  204342           5 : void SgRangeExp::deleteMemoryPool() {
  204343           5 :   for (auto p: SgRangeExp::pools) {
  204344           0 :     ROSE_FREE(p);
  204345             :   }
  204346           5 :   SgRangeExp::next_node = nullptr;
  204347           5 :   SgRangeExp::pools.clear();
  204348           5 : }
  204349             : 
  204350             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  204351             : //                 reading multiple binary files to for a single AST.
  204352             : /////////// new version ////////////////////////////////
  204353             : //############################################################################
  204354             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  204355             : void
  204356           2 : SgRangeExp::extendMemoryPoolForFileIO( )
  204357             :   {
  204358           2 :     size_t blockIndex = SgRangeExp::pools.size();
  204359           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRangeExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRangeExp);
  204360             : 
  204361           2 :     while ( (blockIndex * SgRangeExp::pool_size) < newPoolSize)
  204362             :       {
  204363             : #if ROSE_ALLOC_TRACE
  204364             :         if (blockIndex > 0) {
  204365             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRangeExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRangeExp) = %" PRIuPTR " SgRangeExp::pool_size = %d \n",
  204366             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRangeExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRangeExp),SgRangeExp::pool_size);
  204367             :         }
  204368             : #endif
  204369             : 
  204370           0 :         SgRangeExp * pointer = (SgRangeExp*) ROSE_MALLOC ( SgRangeExp::pool_size * sizeof(SgRangeExp) );
  204371           0 :         assert( pointer != NULL );
  204372             : #if ROSE_ALLOC_MEMSET == 1
  204373             :         memset(pointer, 0x00, SgRangeExp::pool_size * sizeof(SgRangeExp));
  204374             : #elif ROSE_ALLOC_MEMSET == 2
  204375             :         memset(pointer, 0xCC, SgRangeExp::pool_size * sizeof(SgRangeExp));
  204376             : #endif
  204377           0 :         SgRangeExp::pools.push_back( (unsigned char*)(pointer) );
  204378           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRangeExp::pool_size * sizeof(SgRangeExp), V_SgRangeExp ) );
  204379             : 
  204380           0 :         if ( SgRangeExp::next_node != NULL ) {
  204381           0 :           if ( blockIndex > 0 ) {
  204382           0 :             SgRangeExp * blkptr = (SgRangeExp*)(SgRangeExp::pools[blockIndex-1]);
  204383           0 :             blkptr[ SgRangeExp::pool_size - 1 ].set_freepointer(pointer);
  204384             :           }
  204385             :         } else {
  204386           0 :           SgRangeExp::next_node = pointer;
  204387             :         }
  204388             : 
  204389           0 :         for (unsigned i = 0; i < SgRangeExp::pool_size-1; ++i)
  204390             :            {
  204391           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  204392             :            }
  204393           0 :         pointer[ SgRangeExp::pool_size -1 ].set_freepointer(NULL);
  204394             : 
  204395           0 :         blockIndex++;
  204396             :       }
  204397           2 :   }
  204398             : 
  204399             : //############################################################################
  204400             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  204401             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  204402             :  * not compressed. However, that stuff is not yet implemented! 
  204403             :  */
  204404             : unsigned long
  204405           0 : SgRangeExp::getNumberOfLastValidPointer()
  204406             :    {
  204407           0 :       SgRangeExp* testPointer = (SgRangeExp*)(SgRangeExp::pools.back());
  204408           0 :       unsigned long localIndex = SgRangeExp::pool_size - 1;
  204409           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  204410             :          {
  204411           0 :            localIndex--;
  204412             :          }
  204413           0 :       return (localIndex + SgRangeExp::pool_size * (SgRangeExp::pools.size()-1));
  204414             :    }
  204415             : 
  204416             : //############################################################################
  204417             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  204418             :  * memory pool and initializes the data member in class SgRangeExpStroageClass
  204419             :  * from its counterpart of SgRangeExp. The return value is just for checking, 
  204420             :  * that the whole StorageClassArray is initialized!
  204421             :  */
  204422             : unsigned long
  204423           0 : SgRangeExp::initializeStorageClassArray( SgRangeExpStorageClass *storageArray )
  204424             :    {
  204425           0 :      unsigned long storageCounter = 0;
  204426           0 :      std::vector < unsigned char* > :: const_iterator block = SgRangeExp::pools.begin();
  204427           0 :      SgRangeExp* pointer = NULL;
  204428           0 :      while ( block != SgRangeExp::pools.end() ) {
  204429           0 :           pointer = (SgRangeExp*) (*block);
  204430           0 :           for ( unsigned i = 0; i < SgRangeExp::pool_size; ++i ) {
  204431           0 :                if ( pointer->get_freepointer() != NULL ) {
  204432           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  204433           0 :                  storageArray++;
  204434           0 :                  storageCounter++;
  204435             :                }
  204436           0 :                pointer++;
  204437             :              }
  204438           0 :            block++;
  204439             :         }
  204440           0 :      return storageCounter;
  204441             :    }
  204442             : 
  204443             : /* #line 204444 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  204444             : 
  204445             : 
  204446             : 
  204447             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  204448             : 
  204449             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  204450             : 
  204451             : //############################################################################
  204452             : /* JH (02/02/2006) Constructor of the IR node SgMagicColonExp that takes its 
  204453             :  * corresponding StorageClass as parameter
  204454             :  */
  204455           0 : SgMagicColonExp :: SgMagicColonExp ( const SgMagicColonExpStorageClass& storageSource )   : SgExpression (storageSource)
  204456             :    {
  204457             : 
  204458             : 
  204459             : /* #line 204460 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  204460             : 
  204461           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  204462             : 
  204463             : 
  204464             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  204465             : 
  204466             : 
  204467           0 :    }
  204468             : 
  204469             : //############################################################################
  204470             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  204471             :  * within the working AST. 
  204472             :  */
  204473           0 : SgMagicColonExp * SgMagicColonExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  204474           0 :      SgMagicColonExp* returnPointer = NULL;
  204475           0 :      if ( globalIndex != 0 )
  204476             :         {
  204477             : 
  204478             : #if FILE_IO_EXTRA_CHECK
  204479           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMagicColonExp ) ) <= globalIndex ) ;
  204480           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMagicColonExp + 1 ) ) );
  204481             : #endif
  204482           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMagicColonExp )  
  204483           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMagicColonExp );
  204484           0 :           unsigned long positionInPool = localIndex % SgMagicColonExp::pool_size;
  204485           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMagicColonExp::pool_size;
  204486             : 
  204487             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  204488             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  204489             : 
  204490           0 :           returnPointer = &( ( (SgMagicColonExp*)(SgMagicColonExp::pools[memoryBlock]) ) [positionInPool]) ;
  204491             : 
  204492           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  204493             :         }
  204494           0 :      return returnPointer ;
  204495             :    }
  204496             : 
  204497             : //############################################################################
  204498             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  204499             :   for the AST with the index astIndex
  204500             : */
  204501           0 : SgMagicColonExp * SgMagicColonExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  204502           0 :      SgMagicColonExp* returnPointer = NULL;
  204503           0 :      if ( globalIndex != 0 )
  204504             :         {
  204505             : 
  204506             : #if FILE_IO_EXTRA_CHECK
  204507           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMagicColonExp ) ) <= globalIndex ) ;
  204508           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMagicColonExp + 1 ) ) );
  204509             : #endif
  204510           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMagicColonExp )
  204511           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMagicColonExp );
  204512           0 :           unsigned long positionInPool = localIndex % SgMagicColonExp::pool_size ;
  204513           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMagicColonExp::pool_size ;
  204514             : 
  204515             : #if FILE_IO_EXTRA_CHECK
  204516             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  204517             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  204518             : #endif
  204519             : 
  204520           0 :           returnPointer = &( ( (SgMagicColonExp*)(SgMagicColonExp::pools[memoryBlock]) ) [positionInPool]) ;
  204521             : 
  204522             : #if FILE_IO_EXTRA_CHECK
  204523           0 :           assert ( returnPointer != NULL ) ;
  204524             : #endif
  204525             :         }
  204526           0 :      return returnPointer ;
  204527             :    }
  204528             : 
  204529             : //############################################################################
  204530             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  204531             :  * pool size! We set for every valid object in the memory pool the freepointer
  204532             :  * to the global index and increase the global index afterwards. For all the 
  204533             :  * invalid objects (means address ranges within the memory pool that were not
  204534             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  204535             :  * distinguish valid from invalid objects! 
  204536             :  */
  204537             : unsigned long
  204538           5 : SgMagicColonExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  204539             :    {
  204540           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  204541           5 :      SgMagicColonExp* pointer = NULL;
  204542           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  204543           5 :      std::vector < unsigned char* > :: const_iterator block;
  204544           5 :      for ( block = SgMagicColonExp::pools.begin(); block != SgMagicColonExp::pools.end() ; ++block )
  204545             :         {
  204546           0 :           pointer = (SgMagicColonExp*)(*block);
  204547           0 :           for (unsigned i = 0; i < SgMagicColonExp::pool_size; ++i )
  204548             :              {
  204549             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  204550             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  204551             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  204552             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  204553             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  204554             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  204555             :             // properly; so this will have to be checked next.
  204556             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  204557             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  204558           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  204559             :                   {
  204560           0 :                     pointer[i].set_freepointer((SgMagicColonExp*)(globalIndex));
  204561           0 :                     globalIndex++;
  204562             :                   }
  204563             :                else
  204564             :                   {
  204565           0 :                     pointer[i].set_freepointer(NULL);
  204566             :                   }
  204567             :               }
  204568             :         }
  204569           5 :      return globalIndex;
  204570             :    }
  204571             : 
  204572             : //############################################################################
  204573             : // JH (01/14/2006)
  204574             : void
  204575           5 : SgMagicColonExp::resetValidFreepointers( )
  204576             :    {
  204577           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  204578           5 :      SgMagicColonExp* pointer = NULL;
  204579           5 :      std::vector < unsigned char* > :: const_iterator block;
  204580           5 :      SgMagicColonExp* pointerOfLinkedList = NULL;
  204581           5 :      for ( block = SgMagicColonExp::pools.begin(); block != SgMagicColonExp::pools.end() ; ++block )
  204582             :         {
  204583           0 :           pointer = (SgMagicColonExp*)(*block);
  204584           0 :           for (unsigned i = 0; i < SgMagicColonExp::pool_size; ++i )
  204585             :              {
  204586             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  204587             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  204588             :             // memory blocks!.
  204589           0 :                if ( pointer[i].get_freepointer() != NULL )
  204590             :                   {
  204591           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  204592             :                   }
  204593             :                else
  204594             :                   {
  204595           0 :                     if ( pointerOfLinkedList == NULL )
  204596             :                        {
  204597           0 :                          SgMagicColonExp::next_node = &(pointer[i]);
  204598             :                        }
  204599             :                     else
  204600             :                        {
  204601             :                       // printf ("In SgMagicColonExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  204602           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  204603             :                        }
  204604             :                     pointerOfLinkedList = &(pointer[i]);
  204605             :                   }
  204606             :               }
  204607             :         }
  204608             : 
  204609           5 :      if ( pointerOfLinkedList != NULL )
  204610             :         {
  204611             :        // printf ("In SgMagicColonExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  204612           0 :           pointerOfLinkedList->set_freepointer(NULL);
  204613             :        // DQ (6/6/2010): Temporary debugging...
  204614             :        //   ROSE_ASSERT(false);
  204615             :         }
  204616             : 
  204617           5 :      return ;
  204618             :    }
  204619             : 
  204620             : //############################################################################
  204621             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  204622             :  * within the memory pool and resets the freepointers, in order to achieve a 
  204623             :  * linked list, that has no jumps and starts at the beginning! This function 
  204624             :  * does not extend the memory pool, since we do not delete any memory blocks,
  204625             :  * but delete the valid objects.  
  204626             :  */
  204627             : void
  204628           0 : SgMagicColonExp::clearMemoryPool( )
  204629             :    {
  204630             :   // printf ("Inside of SgMagicColonExp::clearMemoryPool() \n");
  204631             : 
  204632           0 :      SgMagicColonExp* pointer = NULL, *tempPointer = NULL;
  204633           0 :      std::vector < unsigned char* > :: const_iterator block;
  204634           0 :      if ( SgMagicColonExp::pools.empty() == false )
  204635             :         {
  204636           0 :           block = SgMagicColonExp::pools.begin() ;
  204637           0 :           SgMagicColonExp::next_node = (SgMagicColonExp*) (*block);
  204638             : 
  204639           0 :           while ( block != SgMagicColonExp::pools.end() )
  204640             :              {
  204641           0 :                pointer = (SgMagicColonExp*) (*block);
  204642           0 :                if ( tempPointer != NULL )
  204643             :                   {
  204644           0 :                     tempPointer->set_freepointer(pointer);
  204645             :                   }
  204646           0 :                for (unsigned i = 0; i < SgMagicColonExp::pool_size - 1; ++i)
  204647             :                   {
  204648           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  204649             :                   }
  204650           0 :                 pointer[SgMagicColonExp::pool_size-1].set_freepointer(NULL);
  204651           0 :                 tempPointer = &(pointer[SgMagicColonExp::pool_size-1]);
  204652           0 :                 ++block;
  204653             :              }
  204654             :         }
  204655           0 :    }
  204656             : 
  204657           5 : void SgMagicColonExp::deleteMemoryPool() {
  204658           5 :   for (auto p: SgMagicColonExp::pools) {
  204659           0 :     ROSE_FREE(p);
  204660             :   }
  204661           5 :   SgMagicColonExp::next_node = nullptr;
  204662           5 :   SgMagicColonExp::pools.clear();
  204663           5 : }
  204664             : 
  204665             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  204666             : //                 reading multiple binary files to for a single AST.
  204667             : /////////// new version ////////////////////////////////
  204668             : //############################################################################
  204669             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  204670             : void
  204671           2 : SgMagicColonExp::extendMemoryPoolForFileIO( )
  204672             :   {
  204673           2 :     size_t blockIndex = SgMagicColonExp::pools.size();
  204674           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMagicColonExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMagicColonExp);
  204675             : 
  204676           2 :     while ( (blockIndex * SgMagicColonExp::pool_size) < newPoolSize)
  204677             :       {
  204678             : #if ROSE_ALLOC_TRACE
  204679             :         if (blockIndex > 0) {
  204680             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMagicColonExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMagicColonExp) = %" PRIuPTR " SgMagicColonExp::pool_size = %d \n",
  204681             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMagicColonExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMagicColonExp),SgMagicColonExp::pool_size);
  204682             :         }
  204683             : #endif
  204684             : 
  204685           0 :         SgMagicColonExp * pointer = (SgMagicColonExp*) ROSE_MALLOC ( SgMagicColonExp::pool_size * sizeof(SgMagicColonExp) );
  204686           0 :         assert( pointer != NULL );
  204687             : #if ROSE_ALLOC_MEMSET == 1
  204688             :         memset(pointer, 0x00, SgMagicColonExp::pool_size * sizeof(SgMagicColonExp));
  204689             : #elif ROSE_ALLOC_MEMSET == 2
  204690             :         memset(pointer, 0xCC, SgMagicColonExp::pool_size * sizeof(SgMagicColonExp));
  204691             : #endif
  204692           0 :         SgMagicColonExp::pools.push_back( (unsigned char*)(pointer) );
  204693           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMagicColonExp::pool_size * sizeof(SgMagicColonExp), V_SgMagicColonExp ) );
  204694             : 
  204695           0 :         if ( SgMagicColonExp::next_node != NULL ) {
  204696           0 :           if ( blockIndex > 0 ) {
  204697           0 :             SgMagicColonExp * blkptr = (SgMagicColonExp*)(SgMagicColonExp::pools[blockIndex-1]);
  204698           0 :             blkptr[ SgMagicColonExp::pool_size - 1 ].set_freepointer(pointer);
  204699             :           }
  204700             :         } else {
  204701           0 :           SgMagicColonExp::next_node = pointer;
  204702             :         }
  204703             : 
  204704           0 :         for (unsigned i = 0; i < SgMagicColonExp::pool_size-1; ++i)
  204705             :            {
  204706           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  204707             :            }
  204708           0 :         pointer[ SgMagicColonExp::pool_size -1 ].set_freepointer(NULL);
  204709             : 
  204710           0 :         blockIndex++;
  204711             :       }
  204712           2 :   }
  204713             : 
  204714             : //############################################################################
  204715             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  204716             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  204717             :  * not compressed. However, that stuff is not yet implemented! 
  204718             :  */
  204719             : unsigned long
  204720           0 : SgMagicColonExp::getNumberOfLastValidPointer()
  204721             :    {
  204722           0 :       SgMagicColonExp* testPointer = (SgMagicColonExp*)(SgMagicColonExp::pools.back());
  204723           0 :       unsigned long localIndex = SgMagicColonExp::pool_size - 1;
  204724           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  204725             :          {
  204726           0 :            localIndex--;
  204727             :          }
  204728           0 :       return (localIndex + SgMagicColonExp::pool_size * (SgMagicColonExp::pools.size()-1));
  204729             :    }
  204730             : 
  204731             : //############################################################################
  204732             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  204733             :  * memory pool and initializes the data member in class SgMagicColonExpStroageClass
  204734             :  * from its counterpart of SgMagicColonExp. The return value is just for checking, 
  204735             :  * that the whole StorageClassArray is initialized!
  204736             :  */
  204737             : unsigned long
  204738           0 : SgMagicColonExp::initializeStorageClassArray( SgMagicColonExpStorageClass *storageArray )
  204739             :    {
  204740           0 :      unsigned long storageCounter = 0;
  204741           0 :      std::vector < unsigned char* > :: const_iterator block = SgMagicColonExp::pools.begin();
  204742           0 :      SgMagicColonExp* pointer = NULL;
  204743           0 :      while ( block != SgMagicColonExp::pools.end() ) {
  204744           0 :           pointer = (SgMagicColonExp*) (*block);
  204745           0 :           for ( unsigned i = 0; i < SgMagicColonExp::pool_size; ++i ) {
  204746           0 :                if ( pointer->get_freepointer() != NULL ) {
  204747           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  204748           0 :                  storageArray++;
  204749           0 :                  storageCounter++;
  204750             :                }
  204751           0 :                pointer++;
  204752             :              }
  204753           0 :            block++;
  204754             :         }
  204755           0 :      return storageCounter;
  204756             :    }
  204757             : 
  204758             : /* #line 204759 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  204759             : 
  204760             : 
  204761             : 
  204762             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  204763             : 
  204764             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  204765             : 
  204766             : //############################################################################
  204767             : /* JH (02/02/2006) Constructor of the IR node SgTypeTraitBuiltinOperator that takes its 
  204768             :  * corresponding StorageClass as parameter
  204769             :  */
  204770          42 : SgTypeTraitBuiltinOperator :: SgTypeTraitBuiltinOperator ( const SgTypeTraitBuiltinOperatorStorageClass& storageSource )   : SgExpression (storageSource)
  204771             :    {
  204772             : 
  204773             : 
  204774             : /* #line 204775 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  204775             : 
  204776          42 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  204777          42 :      p_name = SgName ( storageSource.storageOf_name ) ;
  204778          42 :      p_args = storageSource.storageOf_args.rebuildDataStoredInEasyStorageClass() ;
  204779          42 :      SgNodePtrList::iterator i_args = p_args.begin() ; 
  204780          95 :      for ( ; i_args != p_args.end(); ++i_args ) 
  204781             :         {
  204782          53 :           (*i_args) = (SgNodePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_args) ) );
  204783             :         }
  204784             : 
  204785             : 
  204786             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  204787             : 
  204788             : 
  204789          42 :    }
  204790             : 
  204791             : //############################################################################
  204792             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  204793             :  * within the working AST. 
  204794             :  */
  204795         219 : SgTypeTraitBuiltinOperator * SgTypeTraitBuiltinOperator::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  204796         219 :      SgTypeTraitBuiltinOperator* returnPointer = NULL;
  204797         219 :      if ( globalIndex != 0 )
  204798             :         {
  204799             : 
  204800             : #if FILE_IO_EXTRA_CHECK
  204801         219 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeTraitBuiltinOperator ) ) <= globalIndex ) ;
  204802         219 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeTraitBuiltinOperator + 1 ) ) );
  204803             : #endif
  204804         219 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeTraitBuiltinOperator )  
  204805         219 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeTraitBuiltinOperator );
  204806         219 :           unsigned long positionInPool = localIndex % SgTypeTraitBuiltinOperator::pool_size;
  204807         219 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeTraitBuiltinOperator::pool_size;
  204808             : 
  204809             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  204810             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  204811             : 
  204812         219 :           returnPointer = &( ( (SgTypeTraitBuiltinOperator*)(SgTypeTraitBuiltinOperator::pools[memoryBlock]) ) [positionInPool]) ;
  204813             : 
  204814         219 :           ROSE_ASSERT( returnPointer != NULL ) ;
  204815             :         }
  204816         219 :      return returnPointer ;
  204817             :    }
  204818             : 
  204819             : //############################################################################
  204820             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  204821             :   for the AST with the index astIndex
  204822             : */
  204823           0 : SgTypeTraitBuiltinOperator * SgTypeTraitBuiltinOperator::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  204824           0 :      SgTypeTraitBuiltinOperator* returnPointer = NULL;
  204825           0 :      if ( globalIndex != 0 )
  204826             :         {
  204827             : 
  204828             : #if FILE_IO_EXTRA_CHECK
  204829           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeTraitBuiltinOperator ) ) <= globalIndex ) ;
  204830           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeTraitBuiltinOperator + 1 ) ) );
  204831             : #endif
  204832           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeTraitBuiltinOperator )
  204833           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeTraitBuiltinOperator );
  204834           0 :           unsigned long positionInPool = localIndex % SgTypeTraitBuiltinOperator::pool_size ;
  204835           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeTraitBuiltinOperator::pool_size ;
  204836             : 
  204837             : #if FILE_IO_EXTRA_CHECK
  204838             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  204839             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  204840             : #endif
  204841             : 
  204842           0 :           returnPointer = &( ( (SgTypeTraitBuiltinOperator*)(SgTypeTraitBuiltinOperator::pools[memoryBlock]) ) [positionInPool]) ;
  204843             : 
  204844             : #if FILE_IO_EXTRA_CHECK
  204845           0 :           assert ( returnPointer != NULL ) ;
  204846             : #endif
  204847             :         }
  204848           0 :      return returnPointer ;
  204849             :    }
  204850             : 
  204851             : //############################################################################
  204852             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  204853             :  * pool size! We set for every valid object in the memory pool the freepointer
  204854             :  * to the global index and increase the global index afterwards. For all the 
  204855             :  * invalid objects (means address ranges within the memory pool that were not
  204856             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  204857             :  * distinguish valid from invalid objects! 
  204858             :  */
  204859             : unsigned long
  204860           5 : SgTypeTraitBuiltinOperator::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  204861             :    {
  204862           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  204863           5 :      SgTypeTraitBuiltinOperator* pointer = NULL;
  204864           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  204865           5 :      std::vector < unsigned char* > :: const_iterator block;
  204866           6 :      for ( block = SgTypeTraitBuiltinOperator::pools.begin(); block != SgTypeTraitBuiltinOperator::pools.end() ; ++block )
  204867             :         {
  204868           1 :           pointer = (SgTypeTraitBuiltinOperator*)(*block);
  204869        2001 :           for (unsigned i = 0; i < SgTypeTraitBuiltinOperator::pool_size; ++i )
  204870             :              {
  204871             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  204872             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  204873             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  204874             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  204875             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  204876             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  204877             :             // properly; so this will have to be checked next.
  204878             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  204879             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  204880        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  204881             :                   {
  204882          42 :                     pointer[i].set_freepointer((SgTypeTraitBuiltinOperator*)(globalIndex));
  204883          42 :                     globalIndex++;
  204884             :                   }
  204885             :                else
  204886             :                   {
  204887        1958 :                     pointer[i].set_freepointer(NULL);
  204888             :                   }
  204889             :               }
  204890             :         }
  204891           5 :      return globalIndex;
  204892             :    }
  204893             : 
  204894             : //############################################################################
  204895             : // JH (01/14/2006)
  204896             : void
  204897           5 : SgTypeTraitBuiltinOperator::resetValidFreepointers( )
  204898             :    {
  204899           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  204900           5 :      SgTypeTraitBuiltinOperator* pointer = NULL;
  204901           5 :      std::vector < unsigned char* > :: const_iterator block;
  204902           5 :      SgTypeTraitBuiltinOperator* pointerOfLinkedList = NULL;
  204903           6 :      for ( block = SgTypeTraitBuiltinOperator::pools.begin(); block != SgTypeTraitBuiltinOperator::pools.end() ; ++block )
  204904             :         {
  204905           1 :           pointer = (SgTypeTraitBuiltinOperator*)(*block);
  204906        2001 :           for (unsigned i = 0; i < SgTypeTraitBuiltinOperator::pool_size; ++i )
  204907             :              {
  204908             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  204909             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  204910             :             // memory blocks!.
  204911        2000 :                if ( pointer[i].get_freepointer() != NULL )
  204912             :                   {
  204913          42 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  204914             :                   }
  204915             :                else
  204916             :                   {
  204917        1958 :                     if ( pointerOfLinkedList == NULL )
  204918             :                        {
  204919           1 :                          SgTypeTraitBuiltinOperator::next_node = &(pointer[i]);
  204920             :                        }
  204921             :                     else
  204922             :                        {
  204923             :                       // printf ("In SgTypeTraitBuiltinOperator::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  204924        1957 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  204925             :                        }
  204926             :                     pointerOfLinkedList = &(pointer[i]);
  204927             :                   }
  204928             :               }
  204929             :         }
  204930             : 
  204931           5 :      if ( pointerOfLinkedList != NULL )
  204932             :         {
  204933             :        // printf ("In SgTypeTraitBuiltinOperator::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  204934           1 :           pointerOfLinkedList->set_freepointer(NULL);
  204935             :        // DQ (6/6/2010): Temporary debugging...
  204936             :        //   ROSE_ASSERT(false);
  204937             :         }
  204938             : 
  204939           5 :      return ;
  204940             :    }
  204941             : 
  204942             : //############################################################################
  204943             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  204944             :  * within the memory pool and resets the freepointers, in order to achieve a 
  204945             :  * linked list, that has no jumps and starts at the beginning! This function 
  204946             :  * does not extend the memory pool, since we do not delete any memory blocks,
  204947             :  * but delete the valid objects.  
  204948             :  */
  204949             : void
  204950           0 : SgTypeTraitBuiltinOperator::clearMemoryPool( )
  204951             :    {
  204952             :   // printf ("Inside of SgTypeTraitBuiltinOperator::clearMemoryPool() \n");
  204953             : 
  204954           0 :      SgTypeTraitBuiltinOperator* pointer = NULL, *tempPointer = NULL;
  204955           0 :      std::vector < unsigned char* > :: const_iterator block;
  204956           0 :      if ( SgTypeTraitBuiltinOperator::pools.empty() == false )
  204957             :         {
  204958           0 :           block = SgTypeTraitBuiltinOperator::pools.begin() ;
  204959           0 :           SgTypeTraitBuiltinOperator::next_node = (SgTypeTraitBuiltinOperator*) (*block);
  204960             : 
  204961           0 :           while ( block != SgTypeTraitBuiltinOperator::pools.end() )
  204962             :              {
  204963           0 :                pointer = (SgTypeTraitBuiltinOperator*) (*block);
  204964           0 :                if ( tempPointer != NULL )
  204965             :                   {
  204966           0 :                     tempPointer->set_freepointer(pointer);
  204967             :                   }
  204968           0 :                for (unsigned i = 0; i < SgTypeTraitBuiltinOperator::pool_size - 1; ++i)
  204969             :                   {
  204970           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  204971             :                   }
  204972           0 :                 pointer[SgTypeTraitBuiltinOperator::pool_size-1].set_freepointer(NULL);
  204973           0 :                 tempPointer = &(pointer[SgTypeTraitBuiltinOperator::pool_size-1]);
  204974           0 :                 ++block;
  204975             :              }
  204976             :         }
  204977           0 :    }
  204978             : 
  204979           5 : void SgTypeTraitBuiltinOperator::deleteMemoryPool() {
  204980           7 :   for (auto p: SgTypeTraitBuiltinOperator::pools) {
  204981           2 :     ROSE_FREE(p);
  204982             :   }
  204983           5 :   SgTypeTraitBuiltinOperator::next_node = nullptr;
  204984           5 :   SgTypeTraitBuiltinOperator::pools.clear();
  204985           5 : }
  204986             : 
  204987             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  204988             : //                 reading multiple binary files to for a single AST.
  204989             : /////////// new version ////////////////////////////////
  204990             : //############################################################################
  204991             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  204992             : void
  204993           2 : SgTypeTraitBuiltinOperator::extendMemoryPoolForFileIO( )
  204994             :   {
  204995           2 :     size_t blockIndex = SgTypeTraitBuiltinOperator::pools.size();
  204996           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTraitBuiltinOperator) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTraitBuiltinOperator);
  204997             : 
  204998           3 :     while ( (blockIndex * SgTypeTraitBuiltinOperator::pool_size) < newPoolSize)
  204999             :       {
  205000             : #if ROSE_ALLOC_TRACE
  205001             :         if (blockIndex > 0) {
  205002             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTraitBuiltinOperator) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTraitBuiltinOperator) = %" PRIuPTR " SgTypeTraitBuiltinOperator::pool_size = %d \n",
  205003             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeTraitBuiltinOperator),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeTraitBuiltinOperator),SgTypeTraitBuiltinOperator::pool_size);
  205004             :         }
  205005             : #endif
  205006             : 
  205007           1 :         SgTypeTraitBuiltinOperator * pointer = (SgTypeTraitBuiltinOperator*) ROSE_MALLOC ( SgTypeTraitBuiltinOperator::pool_size * sizeof(SgTypeTraitBuiltinOperator) );
  205008           1 :         assert( pointer != NULL );
  205009             : #if ROSE_ALLOC_MEMSET == 1
  205010             :         memset(pointer, 0x00, SgTypeTraitBuiltinOperator::pool_size * sizeof(SgTypeTraitBuiltinOperator));
  205011             : #elif ROSE_ALLOC_MEMSET == 2
  205012             :         memset(pointer, 0xCC, SgTypeTraitBuiltinOperator::pool_size * sizeof(SgTypeTraitBuiltinOperator));
  205013             : #endif
  205014           1 :         SgTypeTraitBuiltinOperator::pools.push_back( (unsigned char*)(pointer) );
  205015           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeTraitBuiltinOperator::pool_size * sizeof(SgTypeTraitBuiltinOperator), V_SgTypeTraitBuiltinOperator ) );
  205016             : 
  205017           1 :         if ( SgTypeTraitBuiltinOperator::next_node != NULL ) {
  205018           0 :           if ( blockIndex > 0 ) {
  205019           0 :             SgTypeTraitBuiltinOperator * blkptr = (SgTypeTraitBuiltinOperator*)(SgTypeTraitBuiltinOperator::pools[blockIndex-1]);
  205020           0 :             blkptr[ SgTypeTraitBuiltinOperator::pool_size - 1 ].set_freepointer(pointer);
  205021             :           }
  205022             :         } else {
  205023           1 :           SgTypeTraitBuiltinOperator::next_node = pointer;
  205024             :         }
  205025             : 
  205026        2000 :         for (unsigned i = 0; i < SgTypeTraitBuiltinOperator::pool_size-1; ++i)
  205027             :            {
  205028        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  205029             :            }
  205030           1 :         pointer[ SgTypeTraitBuiltinOperator::pool_size -1 ].set_freepointer(NULL);
  205031             : 
  205032           1 :         blockIndex++;
  205033             :       }
  205034           2 :   }
  205035             : 
  205036             : //############################################################################
  205037             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  205038             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  205039             :  * not compressed. However, that stuff is not yet implemented! 
  205040             :  */
  205041             : unsigned long
  205042           0 : SgTypeTraitBuiltinOperator::getNumberOfLastValidPointer()
  205043             :    {
  205044           0 :       SgTypeTraitBuiltinOperator* testPointer = (SgTypeTraitBuiltinOperator*)(SgTypeTraitBuiltinOperator::pools.back());
  205045           0 :       unsigned long localIndex = SgTypeTraitBuiltinOperator::pool_size - 1;
  205046           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  205047             :          {
  205048           0 :            localIndex--;
  205049             :          }
  205050           0 :       return (localIndex + SgTypeTraitBuiltinOperator::pool_size * (SgTypeTraitBuiltinOperator::pools.size()-1));
  205051             :    }
  205052             : 
  205053             : //############################################################################
  205054             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  205055             :  * memory pool and initializes the data member in class SgTypeTraitBuiltinOperatorStroageClass
  205056             :  * from its counterpart of SgTypeTraitBuiltinOperator. The return value is just for checking, 
  205057             :  * that the whole StorageClassArray is initialized!
  205058             :  */
  205059             : unsigned long
  205060           1 : SgTypeTraitBuiltinOperator::initializeStorageClassArray( SgTypeTraitBuiltinOperatorStorageClass *storageArray )
  205061             :    {
  205062           1 :      unsigned long storageCounter = 0;
  205063           1 :      std::vector < unsigned char* > :: const_iterator block = SgTypeTraitBuiltinOperator::pools.begin();
  205064           1 :      SgTypeTraitBuiltinOperator* pointer = NULL;
  205065           2 :      while ( block != SgTypeTraitBuiltinOperator::pools.end() ) {
  205066           1 :           pointer = (SgTypeTraitBuiltinOperator*) (*block);
  205067        2001 :           for ( unsigned i = 0; i < SgTypeTraitBuiltinOperator::pool_size; ++i ) {
  205068        2000 :                if ( pointer->get_freepointer() != NULL ) {
  205069          42 :                  storageArray->pickOutIRNodeData (pointer) ;
  205070          42 :                  storageArray++;
  205071          42 :                  storageCounter++;
  205072             :                }
  205073        2000 :                pointer++;
  205074             :              }
  205075           1 :            block++;
  205076             :         }
  205077           1 :      return storageCounter;
  205078             :    }
  205079             : 
  205080             : /* #line 205081 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  205081             : 
  205082             : 
  205083             : 
  205084             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  205085             : 
  205086             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  205087             : 
  205088             : //############################################################################
  205089             : /* JH (02/02/2006) Constructor of the IR node SgCompoundLiteralExp that takes its 
  205090             :  * corresponding StorageClass as parameter
  205091             :  */
  205092           0 : SgCompoundLiteralExp :: SgCompoundLiteralExp ( const SgCompoundLiteralExpStorageClass& storageSource )   : SgExpression (storageSource)
  205093             :    {
  205094             : 
  205095             : 
  205096             : /* #line 205097 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  205097             : 
  205098           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  205099           0 :      p_symbol =  (SgVariableSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol) );
  205100             : 
  205101             : 
  205102             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  205103             : 
  205104             : 
  205105           0 :    }
  205106             : 
  205107             : //############################################################################
  205108             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  205109             :  * within the working AST. 
  205110             :  */
  205111           0 : SgCompoundLiteralExp * SgCompoundLiteralExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  205112           0 :      SgCompoundLiteralExp* returnPointer = NULL;
  205113           0 :      if ( globalIndex != 0 )
  205114             :         {
  205115             : 
  205116             : #if FILE_IO_EXTRA_CHECK
  205117           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCompoundLiteralExp ) ) <= globalIndex ) ;
  205118           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCompoundLiteralExp + 1 ) ) );
  205119             : #endif
  205120           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCompoundLiteralExp )  
  205121           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCompoundLiteralExp );
  205122           0 :           unsigned long positionInPool = localIndex % SgCompoundLiteralExp::pool_size;
  205123           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCompoundLiteralExp::pool_size;
  205124             : 
  205125             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  205126             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  205127             : 
  205128           0 :           returnPointer = &( ( (SgCompoundLiteralExp*)(SgCompoundLiteralExp::pools[memoryBlock]) ) [positionInPool]) ;
  205129             : 
  205130           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  205131             :         }
  205132           0 :      return returnPointer ;
  205133             :    }
  205134             : 
  205135             : //############################################################################
  205136             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  205137             :   for the AST with the index astIndex
  205138             : */
  205139           0 : SgCompoundLiteralExp * SgCompoundLiteralExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  205140           0 :      SgCompoundLiteralExp* returnPointer = NULL;
  205141           0 :      if ( globalIndex != 0 )
  205142             :         {
  205143             : 
  205144             : #if FILE_IO_EXTRA_CHECK
  205145           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCompoundLiteralExp ) ) <= globalIndex ) ;
  205146           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCompoundLiteralExp + 1 ) ) );
  205147             : #endif
  205148           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCompoundLiteralExp )
  205149           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCompoundLiteralExp );
  205150           0 :           unsigned long positionInPool = localIndex % SgCompoundLiteralExp::pool_size ;
  205151           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCompoundLiteralExp::pool_size ;
  205152             : 
  205153             : #if FILE_IO_EXTRA_CHECK
  205154             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  205155             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  205156             : #endif
  205157             : 
  205158           0 :           returnPointer = &( ( (SgCompoundLiteralExp*)(SgCompoundLiteralExp::pools[memoryBlock]) ) [positionInPool]) ;
  205159             : 
  205160             : #if FILE_IO_EXTRA_CHECK
  205161           0 :           assert ( returnPointer != NULL ) ;
  205162             : #endif
  205163             :         }
  205164           0 :      return returnPointer ;
  205165             :    }
  205166             : 
  205167             : //############################################################################
  205168             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  205169             :  * pool size! We set for every valid object in the memory pool the freepointer
  205170             :  * to the global index and increase the global index afterwards. For all the 
  205171             :  * invalid objects (means address ranges within the memory pool that were not
  205172             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  205173             :  * distinguish valid from invalid objects! 
  205174             :  */
  205175             : unsigned long
  205176           5 : SgCompoundLiteralExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  205177             :    {
  205178           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  205179           5 :      SgCompoundLiteralExp* pointer = NULL;
  205180           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  205181           5 :      std::vector < unsigned char* > :: const_iterator block;
  205182           5 :      for ( block = SgCompoundLiteralExp::pools.begin(); block != SgCompoundLiteralExp::pools.end() ; ++block )
  205183             :         {
  205184           0 :           pointer = (SgCompoundLiteralExp*)(*block);
  205185           0 :           for (unsigned i = 0; i < SgCompoundLiteralExp::pool_size; ++i )
  205186             :              {
  205187             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  205188             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  205189             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  205190             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  205191             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  205192             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  205193             :             // properly; so this will have to be checked next.
  205194             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  205195             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  205196           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  205197             :                   {
  205198           0 :                     pointer[i].set_freepointer((SgCompoundLiteralExp*)(globalIndex));
  205199           0 :                     globalIndex++;
  205200             :                   }
  205201             :                else
  205202             :                   {
  205203           0 :                     pointer[i].set_freepointer(NULL);
  205204             :                   }
  205205             :               }
  205206             :         }
  205207           5 :      return globalIndex;
  205208             :    }
  205209             : 
  205210             : //############################################################################
  205211             : // JH (01/14/2006)
  205212             : void
  205213           5 : SgCompoundLiteralExp::resetValidFreepointers( )
  205214             :    {
  205215           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  205216           5 :      SgCompoundLiteralExp* pointer = NULL;
  205217           5 :      std::vector < unsigned char* > :: const_iterator block;
  205218           5 :      SgCompoundLiteralExp* pointerOfLinkedList = NULL;
  205219           5 :      for ( block = SgCompoundLiteralExp::pools.begin(); block != SgCompoundLiteralExp::pools.end() ; ++block )
  205220             :         {
  205221           0 :           pointer = (SgCompoundLiteralExp*)(*block);
  205222           0 :           for (unsigned i = 0; i < SgCompoundLiteralExp::pool_size; ++i )
  205223             :              {
  205224             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  205225             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  205226             :             // memory blocks!.
  205227           0 :                if ( pointer[i].get_freepointer() != NULL )
  205228             :                   {
  205229           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  205230             :                   }
  205231             :                else
  205232             :                   {
  205233           0 :                     if ( pointerOfLinkedList == NULL )
  205234             :                        {
  205235           0 :                          SgCompoundLiteralExp::next_node = &(pointer[i]);
  205236             :                        }
  205237             :                     else
  205238             :                        {
  205239             :                       // printf ("In SgCompoundLiteralExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  205240           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  205241             :                        }
  205242             :                     pointerOfLinkedList = &(pointer[i]);
  205243             :                   }
  205244             :               }
  205245             :         }
  205246             : 
  205247           5 :      if ( pointerOfLinkedList != NULL )
  205248             :         {
  205249             :        // printf ("In SgCompoundLiteralExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  205250           0 :           pointerOfLinkedList->set_freepointer(NULL);
  205251             :        // DQ (6/6/2010): Temporary debugging...
  205252             :        //   ROSE_ASSERT(false);
  205253             :         }
  205254             : 
  205255           5 :      return ;
  205256             :    }
  205257             : 
  205258             : //############################################################################
  205259             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  205260             :  * within the memory pool and resets the freepointers, in order to achieve a 
  205261             :  * linked list, that has no jumps and starts at the beginning! This function 
  205262             :  * does not extend the memory pool, since we do not delete any memory blocks,
  205263             :  * but delete the valid objects.  
  205264             :  */
  205265             : void
  205266           0 : SgCompoundLiteralExp::clearMemoryPool( )
  205267             :    {
  205268             :   // printf ("Inside of SgCompoundLiteralExp::clearMemoryPool() \n");
  205269             : 
  205270           0 :      SgCompoundLiteralExp* pointer = NULL, *tempPointer = NULL;
  205271           0 :      std::vector < unsigned char* > :: const_iterator block;
  205272           0 :      if ( SgCompoundLiteralExp::pools.empty() == false )
  205273             :         {
  205274           0 :           block = SgCompoundLiteralExp::pools.begin() ;
  205275           0 :           SgCompoundLiteralExp::next_node = (SgCompoundLiteralExp*) (*block);
  205276             : 
  205277           0 :           while ( block != SgCompoundLiteralExp::pools.end() )
  205278             :              {
  205279           0 :                pointer = (SgCompoundLiteralExp*) (*block);
  205280           0 :                if ( tempPointer != NULL )
  205281             :                   {
  205282           0 :                     tempPointer->set_freepointer(pointer);
  205283             :                   }
  205284           0 :                for (unsigned i = 0; i < SgCompoundLiteralExp::pool_size - 1; ++i)
  205285             :                   {
  205286           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  205287             :                   }
  205288           0 :                 pointer[SgCompoundLiteralExp::pool_size-1].set_freepointer(NULL);
  205289           0 :                 tempPointer = &(pointer[SgCompoundLiteralExp::pool_size-1]);
  205290           0 :                 ++block;
  205291             :              }
  205292             :         }
  205293           0 :    }
  205294             : 
  205295           5 : void SgCompoundLiteralExp::deleteMemoryPool() {
  205296           5 :   for (auto p: SgCompoundLiteralExp::pools) {
  205297           0 :     ROSE_FREE(p);
  205298             :   }
  205299           5 :   SgCompoundLiteralExp::next_node = nullptr;
  205300           5 :   SgCompoundLiteralExp::pools.clear();
  205301           5 : }
  205302             : 
  205303             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  205304             : //                 reading multiple binary files to for a single AST.
  205305             : /////////// new version ////////////////////////////////
  205306             : //############################################################################
  205307             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  205308             : void
  205309           2 : SgCompoundLiteralExp::extendMemoryPoolForFileIO( )
  205310             :   {
  205311           2 :     size_t blockIndex = SgCompoundLiteralExp::pools.size();
  205312           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundLiteralExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundLiteralExp);
  205313             : 
  205314           2 :     while ( (blockIndex * SgCompoundLiteralExp::pool_size) < newPoolSize)
  205315             :       {
  205316             : #if ROSE_ALLOC_TRACE
  205317             :         if (blockIndex > 0) {
  205318             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundLiteralExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundLiteralExp) = %" PRIuPTR " SgCompoundLiteralExp::pool_size = %d \n",
  205319             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCompoundLiteralExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCompoundLiteralExp),SgCompoundLiteralExp::pool_size);
  205320             :         }
  205321             : #endif
  205322             : 
  205323           0 :         SgCompoundLiteralExp * pointer = (SgCompoundLiteralExp*) ROSE_MALLOC ( SgCompoundLiteralExp::pool_size * sizeof(SgCompoundLiteralExp) );
  205324           0 :         assert( pointer != NULL );
  205325             : #if ROSE_ALLOC_MEMSET == 1
  205326             :         memset(pointer, 0x00, SgCompoundLiteralExp::pool_size * sizeof(SgCompoundLiteralExp));
  205327             : #elif ROSE_ALLOC_MEMSET == 2
  205328             :         memset(pointer, 0xCC, SgCompoundLiteralExp::pool_size * sizeof(SgCompoundLiteralExp));
  205329             : #endif
  205330           0 :         SgCompoundLiteralExp::pools.push_back( (unsigned char*)(pointer) );
  205331           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCompoundLiteralExp::pool_size * sizeof(SgCompoundLiteralExp), V_SgCompoundLiteralExp ) );
  205332             : 
  205333           0 :         if ( SgCompoundLiteralExp::next_node != NULL ) {
  205334           0 :           if ( blockIndex > 0 ) {
  205335           0 :             SgCompoundLiteralExp * blkptr = (SgCompoundLiteralExp*)(SgCompoundLiteralExp::pools[blockIndex-1]);
  205336           0 :             blkptr[ SgCompoundLiteralExp::pool_size - 1 ].set_freepointer(pointer);
  205337             :           }
  205338             :         } else {
  205339           0 :           SgCompoundLiteralExp::next_node = pointer;
  205340             :         }
  205341             : 
  205342           0 :         for (unsigned i = 0; i < SgCompoundLiteralExp::pool_size-1; ++i)
  205343             :            {
  205344           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  205345             :            }
  205346           0 :         pointer[ SgCompoundLiteralExp::pool_size -1 ].set_freepointer(NULL);
  205347             : 
  205348           0 :         blockIndex++;
  205349             :       }
  205350           2 :   }
  205351             : 
  205352             : //############################################################################
  205353             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  205354             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  205355             :  * not compressed. However, that stuff is not yet implemented! 
  205356             :  */
  205357             : unsigned long
  205358           0 : SgCompoundLiteralExp::getNumberOfLastValidPointer()
  205359             :    {
  205360           0 :       SgCompoundLiteralExp* testPointer = (SgCompoundLiteralExp*)(SgCompoundLiteralExp::pools.back());
  205361           0 :       unsigned long localIndex = SgCompoundLiteralExp::pool_size - 1;
  205362           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  205363             :          {
  205364           0 :            localIndex--;
  205365             :          }
  205366           0 :       return (localIndex + SgCompoundLiteralExp::pool_size * (SgCompoundLiteralExp::pools.size()-1));
  205367             :    }
  205368             : 
  205369             : //############################################################################
  205370             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  205371             :  * memory pool and initializes the data member in class SgCompoundLiteralExpStroageClass
  205372             :  * from its counterpart of SgCompoundLiteralExp. The return value is just for checking, 
  205373             :  * that the whole StorageClassArray is initialized!
  205374             :  */
  205375             : unsigned long
  205376           0 : SgCompoundLiteralExp::initializeStorageClassArray( SgCompoundLiteralExpStorageClass *storageArray )
  205377             :    {
  205378           0 :      unsigned long storageCounter = 0;
  205379           0 :      std::vector < unsigned char* > :: const_iterator block = SgCompoundLiteralExp::pools.begin();
  205380           0 :      SgCompoundLiteralExp* pointer = NULL;
  205381           0 :      while ( block != SgCompoundLiteralExp::pools.end() ) {
  205382           0 :           pointer = (SgCompoundLiteralExp*) (*block);
  205383           0 :           for ( unsigned i = 0; i < SgCompoundLiteralExp::pool_size; ++i ) {
  205384           0 :                if ( pointer->get_freepointer() != NULL ) {
  205385           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  205386           0 :                  storageArray++;
  205387           0 :                  storageCounter++;
  205388             :                }
  205389           0 :                pointer++;
  205390             :              }
  205391           0 :            block++;
  205392             :         }
  205393           0 :      return storageCounter;
  205394             :    }
  205395             : 
  205396             : /* #line 205397 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  205397             : 
  205398             : 
  205399             : 
  205400             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  205401             : 
  205402             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  205403             : 
  205404             : //############################################################################
  205405             : /* JH (02/02/2006) Constructor of the IR node SgTypeExpression that takes its 
  205406             :  * corresponding StorageClass as parameter
  205407             :  */
  205408           0 : SgTypeExpression :: SgTypeExpression ( const SgTypeExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  205409             :    {
  205410             : 
  205411             : 
  205412             : /* #line 205413 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  205413             : 
  205414           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  205415           0 :      p_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
  205416             : 
  205417             : 
  205418             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  205419             : 
  205420             : 
  205421           0 :    }
  205422             : 
  205423             : //############################################################################
  205424             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  205425             :  * within the working AST. 
  205426             :  */
  205427           0 : SgTypeExpression * SgTypeExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  205428           0 :      SgTypeExpression* returnPointer = NULL;
  205429           0 :      if ( globalIndex != 0 )
  205430             :         {
  205431             : 
  205432             : #if FILE_IO_EXTRA_CHECK
  205433           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypeExpression ) ) <= globalIndex ) ;
  205434           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeExpression + 1 ) ) );
  205435             : #endif
  205436           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypeExpression )  
  205437           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypeExpression );
  205438           0 :           unsigned long positionInPool = localIndex % SgTypeExpression::pool_size;
  205439           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeExpression::pool_size;
  205440             : 
  205441             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  205442             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  205443             : 
  205444           0 :           returnPointer = &( ( (SgTypeExpression*)(SgTypeExpression::pools[memoryBlock]) ) [positionInPool]) ;
  205445             : 
  205446           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  205447             :         }
  205448           0 :      return returnPointer ;
  205449             :    }
  205450             : 
  205451             : //############################################################################
  205452             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  205453             :   for the AST with the index astIndex
  205454             : */
  205455           0 : SgTypeExpression * SgTypeExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  205456           0 :      SgTypeExpression* returnPointer = NULL;
  205457           0 :      if ( globalIndex != 0 )
  205458             :         {
  205459             : 
  205460             : #if FILE_IO_EXTRA_CHECK
  205461           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypeExpression ) ) <= globalIndex ) ;
  205462           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeExpression + 1 ) ) );
  205463             : #endif
  205464           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypeExpression )
  205465           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypeExpression );
  205466           0 :           unsigned long positionInPool = localIndex % SgTypeExpression::pool_size ;
  205467           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypeExpression::pool_size ;
  205468             : 
  205469             : #if FILE_IO_EXTRA_CHECK
  205470             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  205471             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  205472             : #endif
  205473             : 
  205474           0 :           returnPointer = &( ( (SgTypeExpression*)(SgTypeExpression::pools[memoryBlock]) ) [positionInPool]) ;
  205475             : 
  205476             : #if FILE_IO_EXTRA_CHECK
  205477           0 :           assert ( returnPointer != NULL ) ;
  205478             : #endif
  205479             :         }
  205480           0 :      return returnPointer ;
  205481             :    }
  205482             : 
  205483             : //############################################################################
  205484             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  205485             :  * pool size! We set for every valid object in the memory pool the freepointer
  205486             :  * to the global index and increase the global index afterwards. For all the 
  205487             :  * invalid objects (means address ranges within the memory pool that were not
  205488             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  205489             :  * distinguish valid from invalid objects! 
  205490             :  */
  205491             : unsigned long
  205492           5 : SgTypeExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  205493             :    {
  205494           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  205495           5 :      SgTypeExpression* pointer = NULL;
  205496           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  205497           5 :      std::vector < unsigned char* > :: const_iterator block;
  205498           5 :      for ( block = SgTypeExpression::pools.begin(); block != SgTypeExpression::pools.end() ; ++block )
  205499             :         {
  205500           0 :           pointer = (SgTypeExpression*)(*block);
  205501           0 :           for (unsigned i = 0; i < SgTypeExpression::pool_size; ++i )
  205502             :              {
  205503             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  205504             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  205505             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  205506             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  205507             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  205508             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  205509             :             // properly; so this will have to be checked next.
  205510             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  205511             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  205512           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  205513             :                   {
  205514           0 :                     pointer[i].set_freepointer((SgTypeExpression*)(globalIndex));
  205515           0 :                     globalIndex++;
  205516             :                   }
  205517             :                else
  205518             :                   {
  205519           0 :                     pointer[i].set_freepointer(NULL);
  205520             :                   }
  205521             :               }
  205522             :         }
  205523           5 :      return globalIndex;
  205524             :    }
  205525             : 
  205526             : //############################################################################
  205527             : // JH (01/14/2006)
  205528             : void
  205529           5 : SgTypeExpression::resetValidFreepointers( )
  205530             :    {
  205531           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  205532           5 :      SgTypeExpression* pointer = NULL;
  205533           5 :      std::vector < unsigned char* > :: const_iterator block;
  205534           5 :      SgTypeExpression* pointerOfLinkedList = NULL;
  205535           5 :      for ( block = SgTypeExpression::pools.begin(); block != SgTypeExpression::pools.end() ; ++block )
  205536             :         {
  205537           0 :           pointer = (SgTypeExpression*)(*block);
  205538           0 :           for (unsigned i = 0; i < SgTypeExpression::pool_size; ++i )
  205539             :              {
  205540             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  205541             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  205542             :             // memory blocks!.
  205543           0 :                if ( pointer[i].get_freepointer() != NULL )
  205544             :                   {
  205545           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  205546             :                   }
  205547             :                else
  205548             :                   {
  205549           0 :                     if ( pointerOfLinkedList == NULL )
  205550             :                        {
  205551           0 :                          SgTypeExpression::next_node = &(pointer[i]);
  205552             :                        }
  205553             :                     else
  205554             :                        {
  205555             :                       // printf ("In SgTypeExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  205556           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  205557             :                        }
  205558             :                     pointerOfLinkedList = &(pointer[i]);
  205559             :                   }
  205560             :               }
  205561             :         }
  205562             : 
  205563           5 :      if ( pointerOfLinkedList != NULL )
  205564             :         {
  205565             :        // printf ("In SgTypeExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  205566           0 :           pointerOfLinkedList->set_freepointer(NULL);
  205567             :        // DQ (6/6/2010): Temporary debugging...
  205568             :        //   ROSE_ASSERT(false);
  205569             :         }
  205570             : 
  205571           5 :      return ;
  205572             :    }
  205573             : 
  205574             : //############################################################################
  205575             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  205576             :  * within the memory pool and resets the freepointers, in order to achieve a 
  205577             :  * linked list, that has no jumps and starts at the beginning! This function 
  205578             :  * does not extend the memory pool, since we do not delete any memory blocks,
  205579             :  * but delete the valid objects.  
  205580             :  */
  205581             : void
  205582           0 : SgTypeExpression::clearMemoryPool( )
  205583             :    {
  205584             :   // printf ("Inside of SgTypeExpression::clearMemoryPool() \n");
  205585             : 
  205586           0 :      SgTypeExpression* pointer = NULL, *tempPointer = NULL;
  205587           0 :      std::vector < unsigned char* > :: const_iterator block;
  205588           0 :      if ( SgTypeExpression::pools.empty() == false )
  205589             :         {
  205590           0 :           block = SgTypeExpression::pools.begin() ;
  205591           0 :           SgTypeExpression::next_node = (SgTypeExpression*) (*block);
  205592             : 
  205593           0 :           while ( block != SgTypeExpression::pools.end() )
  205594             :              {
  205595           0 :                pointer = (SgTypeExpression*) (*block);
  205596           0 :                if ( tempPointer != NULL )
  205597             :                   {
  205598           0 :                     tempPointer->set_freepointer(pointer);
  205599             :                   }
  205600           0 :                for (unsigned i = 0; i < SgTypeExpression::pool_size - 1; ++i)
  205601             :                   {
  205602           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  205603             :                   }
  205604           0 :                 pointer[SgTypeExpression::pool_size-1].set_freepointer(NULL);
  205605           0 :                 tempPointer = &(pointer[SgTypeExpression::pool_size-1]);
  205606           0 :                 ++block;
  205607             :              }
  205608             :         }
  205609           0 :    }
  205610             : 
  205611           5 : void SgTypeExpression::deleteMemoryPool() {
  205612           5 :   for (auto p: SgTypeExpression::pools) {
  205613           0 :     ROSE_FREE(p);
  205614             :   }
  205615           5 :   SgTypeExpression::next_node = nullptr;
  205616           5 :   SgTypeExpression::pools.clear();
  205617           5 : }
  205618             : 
  205619             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  205620             : //                 reading multiple binary files to for a single AST.
  205621             : /////////// new version ////////////////////////////////
  205622             : //############################################################################
  205623             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  205624             : void
  205625           2 : SgTypeExpression::extendMemoryPoolForFileIO( )
  205626             :   {
  205627           2 :     size_t blockIndex = SgTypeExpression::pools.size();
  205628           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeExpression);
  205629             : 
  205630           2 :     while ( (blockIndex * SgTypeExpression::pool_size) < newPoolSize)
  205631             :       {
  205632             : #if ROSE_ALLOC_TRACE
  205633             :         if (blockIndex > 0) {
  205634             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeExpression) = %" PRIuPTR " SgTypeExpression::pool_size = %d \n",
  205635             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypeExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypeExpression),SgTypeExpression::pool_size);
  205636             :         }
  205637             : #endif
  205638             : 
  205639           0 :         SgTypeExpression * pointer = (SgTypeExpression*) ROSE_MALLOC ( SgTypeExpression::pool_size * sizeof(SgTypeExpression) );
  205640           0 :         assert( pointer != NULL );
  205641             : #if ROSE_ALLOC_MEMSET == 1
  205642             :         memset(pointer, 0x00, SgTypeExpression::pool_size * sizeof(SgTypeExpression));
  205643             : #elif ROSE_ALLOC_MEMSET == 2
  205644             :         memset(pointer, 0xCC, SgTypeExpression::pool_size * sizeof(SgTypeExpression));
  205645             : #endif
  205646           0 :         SgTypeExpression::pools.push_back( (unsigned char*)(pointer) );
  205647           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypeExpression::pool_size * sizeof(SgTypeExpression), V_SgTypeExpression ) );
  205648             : 
  205649           0 :         if ( SgTypeExpression::next_node != NULL ) {
  205650           0 :           if ( blockIndex > 0 ) {
  205651           0 :             SgTypeExpression * blkptr = (SgTypeExpression*)(SgTypeExpression::pools[blockIndex-1]);
  205652           0 :             blkptr[ SgTypeExpression::pool_size - 1 ].set_freepointer(pointer);
  205653             :           }
  205654             :         } else {
  205655           0 :           SgTypeExpression::next_node = pointer;
  205656             :         }
  205657             : 
  205658           0 :         for (unsigned i = 0; i < SgTypeExpression::pool_size-1; ++i)
  205659             :            {
  205660           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  205661             :            }
  205662           0 :         pointer[ SgTypeExpression::pool_size -1 ].set_freepointer(NULL);
  205663             : 
  205664           0 :         blockIndex++;
  205665             :       }
  205666           2 :   }
  205667             : 
  205668             : //############################################################################
  205669             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  205670             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  205671             :  * not compressed. However, that stuff is not yet implemented! 
  205672             :  */
  205673             : unsigned long
  205674           0 : SgTypeExpression::getNumberOfLastValidPointer()
  205675             :    {
  205676           0 :       SgTypeExpression* testPointer = (SgTypeExpression*)(SgTypeExpression::pools.back());
  205677           0 :       unsigned long localIndex = SgTypeExpression::pool_size - 1;
  205678           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  205679             :          {
  205680           0 :            localIndex--;
  205681             :          }
  205682           0 :       return (localIndex + SgTypeExpression::pool_size * (SgTypeExpression::pools.size()-1));
  205683             :    }
  205684             : 
  205685             : //############################################################################
  205686             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  205687             :  * memory pool and initializes the data member in class SgTypeExpressionStroageClass
  205688             :  * from its counterpart of SgTypeExpression. The return value is just for checking, 
  205689             :  * that the whole StorageClassArray is initialized!
  205690             :  */
  205691             : unsigned long
  205692           0 : SgTypeExpression::initializeStorageClassArray( SgTypeExpressionStorageClass *storageArray )
  205693             :    {
  205694           0 :      unsigned long storageCounter = 0;
  205695           0 :      std::vector < unsigned char* > :: const_iterator block = SgTypeExpression::pools.begin();
  205696           0 :      SgTypeExpression* pointer = NULL;
  205697           0 :      while ( block != SgTypeExpression::pools.end() ) {
  205698           0 :           pointer = (SgTypeExpression*) (*block);
  205699           0 :           for ( unsigned i = 0; i < SgTypeExpression::pool_size; ++i ) {
  205700           0 :                if ( pointer->get_freepointer() != NULL ) {
  205701           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  205702           0 :                  storageArray++;
  205703           0 :                  storageCounter++;
  205704             :                }
  205705           0 :                pointer++;
  205706             :              }
  205707           0 :            block++;
  205708             :         }
  205709           0 :      return storageCounter;
  205710             :    }
  205711             : 
  205712             : /* #line 205713 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  205713             : 
  205714             : 
  205715             : 
  205716             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  205717             : 
  205718             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  205719             : 
  205720             : //############################################################################
  205721             : /* JH (02/02/2006) Constructor of the IR node SgClassExp that takes its 
  205722             :  * corresponding StorageClass as parameter
  205723             :  */
  205724           0 : SgClassExp :: SgClassExp ( const SgClassExpStorageClass& storageSource )   : SgExpression (storageSource)
  205725             :    {
  205726             : 
  205727             : 
  205728             : /* #line 205729 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  205729             : 
  205730           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  205731           0 :      p_class_symbol =  (SgClassSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_class_symbol) );
  205732           0 :      p_pobj_class = storageSource.storageOf_pobj_class ;
  205733             : 
  205734             : 
  205735             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  205736             : 
  205737             : 
  205738           0 :    }
  205739             : 
  205740             : //############################################################################
  205741             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  205742             :  * within the working AST. 
  205743             :  */
  205744           0 : SgClassExp * SgClassExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  205745           0 :      SgClassExp* returnPointer = NULL;
  205746           0 :      if ( globalIndex != 0 )
  205747             :         {
  205748             : 
  205749             : #if FILE_IO_EXTRA_CHECK
  205750           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClassExp ) ) <= globalIndex ) ;
  205751           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassExp + 1 ) ) );
  205752             : #endif
  205753           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassExp )  
  205754           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClassExp );
  205755           0 :           unsigned long positionInPool = localIndex % SgClassExp::pool_size;
  205756           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassExp::pool_size;
  205757             : 
  205758             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  205759             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  205760             : 
  205761           0 :           returnPointer = &( ( (SgClassExp*)(SgClassExp::pools[memoryBlock]) ) [positionInPool]) ;
  205762             : 
  205763           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  205764             :         }
  205765           0 :      return returnPointer ;
  205766             :    }
  205767             : 
  205768             : //############################################################################
  205769             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  205770             :   for the AST with the index astIndex
  205771             : */
  205772           0 : SgClassExp * SgClassExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  205773           0 :      SgClassExp* returnPointer = NULL;
  205774           0 :      if ( globalIndex != 0 )
  205775             :         {
  205776             : 
  205777             : #if FILE_IO_EXTRA_CHECK
  205778           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClassExp ) ) <= globalIndex ) ;
  205779           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassExp + 1 ) ) );
  205780             : #endif
  205781           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassExp )
  205782           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClassExp );
  205783           0 :           unsigned long positionInPool = localIndex % SgClassExp::pool_size ;
  205784           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassExp::pool_size ;
  205785             : 
  205786             : #if FILE_IO_EXTRA_CHECK
  205787             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  205788             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  205789             : #endif
  205790             : 
  205791           0 :           returnPointer = &( ( (SgClassExp*)(SgClassExp::pools[memoryBlock]) ) [positionInPool]) ;
  205792             : 
  205793             : #if FILE_IO_EXTRA_CHECK
  205794           0 :           assert ( returnPointer != NULL ) ;
  205795             : #endif
  205796             :         }
  205797           0 :      return returnPointer ;
  205798             :    }
  205799             : 
  205800             : //############################################################################
  205801             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  205802             :  * pool size! We set for every valid object in the memory pool the freepointer
  205803             :  * to the global index and increase the global index afterwards. For all the 
  205804             :  * invalid objects (means address ranges within the memory pool that were not
  205805             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  205806             :  * distinguish valid from invalid objects! 
  205807             :  */
  205808             : unsigned long
  205809           5 : SgClassExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  205810             :    {
  205811           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  205812           5 :      SgClassExp* pointer = NULL;
  205813           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  205814           5 :      std::vector < unsigned char* > :: const_iterator block;
  205815           5 :      for ( block = SgClassExp::pools.begin(); block != SgClassExp::pools.end() ; ++block )
  205816             :         {
  205817           0 :           pointer = (SgClassExp*)(*block);
  205818           0 :           for (unsigned i = 0; i < SgClassExp::pool_size; ++i )
  205819             :              {
  205820             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  205821             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  205822             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  205823             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  205824             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  205825             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  205826             :             // properly; so this will have to be checked next.
  205827             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  205828             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  205829           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  205830             :                   {
  205831           0 :                     pointer[i].set_freepointer((SgClassExp*)(globalIndex));
  205832           0 :                     globalIndex++;
  205833             :                   }
  205834             :                else
  205835             :                   {
  205836           0 :                     pointer[i].set_freepointer(NULL);
  205837             :                   }
  205838             :               }
  205839             :         }
  205840           5 :      return globalIndex;
  205841             :    }
  205842             : 
  205843             : //############################################################################
  205844             : // JH (01/14/2006)
  205845             : void
  205846           5 : SgClassExp::resetValidFreepointers( )
  205847             :    {
  205848           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  205849           5 :      SgClassExp* pointer = NULL;
  205850           5 :      std::vector < unsigned char* > :: const_iterator block;
  205851           5 :      SgClassExp* pointerOfLinkedList = NULL;
  205852           5 :      for ( block = SgClassExp::pools.begin(); block != SgClassExp::pools.end() ; ++block )
  205853             :         {
  205854           0 :           pointer = (SgClassExp*)(*block);
  205855           0 :           for (unsigned i = 0; i < SgClassExp::pool_size; ++i )
  205856             :              {
  205857             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  205858             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  205859             :             // memory blocks!.
  205860           0 :                if ( pointer[i].get_freepointer() != NULL )
  205861             :                   {
  205862           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  205863             :                   }
  205864             :                else
  205865             :                   {
  205866           0 :                     if ( pointerOfLinkedList == NULL )
  205867             :                        {
  205868           0 :                          SgClassExp::next_node = &(pointer[i]);
  205869             :                        }
  205870             :                     else
  205871             :                        {
  205872             :                       // printf ("In SgClassExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  205873           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  205874             :                        }
  205875             :                     pointerOfLinkedList = &(pointer[i]);
  205876             :                   }
  205877             :               }
  205878             :         }
  205879             : 
  205880           5 :      if ( pointerOfLinkedList != NULL )
  205881             :         {
  205882             :        // printf ("In SgClassExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  205883           0 :           pointerOfLinkedList->set_freepointer(NULL);
  205884             :        // DQ (6/6/2010): Temporary debugging...
  205885             :        //   ROSE_ASSERT(false);
  205886             :         }
  205887             : 
  205888           5 :      return ;
  205889             :    }
  205890             : 
  205891             : //############################################################################
  205892             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  205893             :  * within the memory pool and resets the freepointers, in order to achieve a 
  205894             :  * linked list, that has no jumps and starts at the beginning! This function 
  205895             :  * does not extend the memory pool, since we do not delete any memory blocks,
  205896             :  * but delete the valid objects.  
  205897             :  */
  205898             : void
  205899           0 : SgClassExp::clearMemoryPool( )
  205900             :    {
  205901             :   // printf ("Inside of SgClassExp::clearMemoryPool() \n");
  205902             : 
  205903           0 :      SgClassExp* pointer = NULL, *tempPointer = NULL;
  205904           0 :      std::vector < unsigned char* > :: const_iterator block;
  205905           0 :      if ( SgClassExp::pools.empty() == false )
  205906             :         {
  205907           0 :           block = SgClassExp::pools.begin() ;
  205908           0 :           SgClassExp::next_node = (SgClassExp*) (*block);
  205909             : 
  205910           0 :           while ( block != SgClassExp::pools.end() )
  205911             :              {
  205912           0 :                pointer = (SgClassExp*) (*block);
  205913           0 :                if ( tempPointer != NULL )
  205914             :                   {
  205915           0 :                     tempPointer->set_freepointer(pointer);
  205916             :                   }
  205917           0 :                for (unsigned i = 0; i < SgClassExp::pool_size - 1; ++i)
  205918             :                   {
  205919           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  205920             :                   }
  205921           0 :                 pointer[SgClassExp::pool_size-1].set_freepointer(NULL);
  205922           0 :                 tempPointer = &(pointer[SgClassExp::pool_size-1]);
  205923           0 :                 ++block;
  205924             :              }
  205925             :         }
  205926           0 :    }
  205927             : 
  205928           5 : void SgClassExp::deleteMemoryPool() {
  205929           5 :   for (auto p: SgClassExp::pools) {
  205930           0 :     ROSE_FREE(p);
  205931             :   }
  205932           5 :   SgClassExp::next_node = nullptr;
  205933           5 :   SgClassExp::pools.clear();
  205934           5 : }
  205935             : 
  205936             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  205937             : //                 reading multiple binary files to for a single AST.
  205938             : /////////// new version ////////////////////////////////
  205939             : //############################################################################
  205940             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  205941             : void
  205942           2 : SgClassExp::extendMemoryPoolForFileIO( )
  205943             :   {
  205944           2 :     size_t blockIndex = SgClassExp::pools.size();
  205945           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClassExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassExp);
  205946             : 
  205947           2 :     while ( (blockIndex * SgClassExp::pool_size) < newPoolSize)
  205948             :       {
  205949             : #if ROSE_ALLOC_TRACE
  205950             :         if (blockIndex > 0) {
  205951             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClassExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassExp) = %" PRIuPTR " SgClassExp::pool_size = %d \n",
  205952             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClassExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassExp),SgClassExp::pool_size);
  205953             :         }
  205954             : #endif
  205955             : 
  205956           0 :         SgClassExp * pointer = (SgClassExp*) ROSE_MALLOC ( SgClassExp::pool_size * sizeof(SgClassExp) );
  205957           0 :         assert( pointer != NULL );
  205958             : #if ROSE_ALLOC_MEMSET == 1
  205959             :         memset(pointer, 0x00, SgClassExp::pool_size * sizeof(SgClassExp));
  205960             : #elif ROSE_ALLOC_MEMSET == 2
  205961             :         memset(pointer, 0xCC, SgClassExp::pool_size * sizeof(SgClassExp));
  205962             : #endif
  205963           0 :         SgClassExp::pools.push_back( (unsigned char*)(pointer) );
  205964           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClassExp::pool_size * sizeof(SgClassExp), V_SgClassExp ) );
  205965             : 
  205966           0 :         if ( SgClassExp::next_node != NULL ) {
  205967           0 :           if ( blockIndex > 0 ) {
  205968           0 :             SgClassExp * blkptr = (SgClassExp*)(SgClassExp::pools[blockIndex-1]);
  205969           0 :             blkptr[ SgClassExp::pool_size - 1 ].set_freepointer(pointer);
  205970             :           }
  205971             :         } else {
  205972           0 :           SgClassExp::next_node = pointer;
  205973             :         }
  205974             : 
  205975           0 :         for (unsigned i = 0; i < SgClassExp::pool_size-1; ++i)
  205976             :            {
  205977           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  205978             :            }
  205979           0 :         pointer[ SgClassExp::pool_size -1 ].set_freepointer(NULL);
  205980             : 
  205981           0 :         blockIndex++;
  205982             :       }
  205983           2 :   }
  205984             : 
  205985             : //############################################################################
  205986             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  205987             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  205988             :  * not compressed. However, that stuff is not yet implemented! 
  205989             :  */
  205990             : unsigned long
  205991           0 : SgClassExp::getNumberOfLastValidPointer()
  205992             :    {
  205993           0 :       SgClassExp* testPointer = (SgClassExp*)(SgClassExp::pools.back());
  205994           0 :       unsigned long localIndex = SgClassExp::pool_size - 1;
  205995           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  205996             :          {
  205997           0 :            localIndex--;
  205998             :          }
  205999           0 :       return (localIndex + SgClassExp::pool_size * (SgClassExp::pools.size()-1));
  206000             :    }
  206001             : 
  206002             : //############################################################################
  206003             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  206004             :  * memory pool and initializes the data member in class SgClassExpStroageClass
  206005             :  * from its counterpart of SgClassExp. The return value is just for checking, 
  206006             :  * that the whole StorageClassArray is initialized!
  206007             :  */
  206008             : unsigned long
  206009           0 : SgClassExp::initializeStorageClassArray( SgClassExpStorageClass *storageArray )
  206010             :    {
  206011           0 :      unsigned long storageCounter = 0;
  206012           0 :      std::vector < unsigned char* > :: const_iterator block = SgClassExp::pools.begin();
  206013           0 :      SgClassExp* pointer = NULL;
  206014           0 :      while ( block != SgClassExp::pools.end() ) {
  206015           0 :           pointer = (SgClassExp*) (*block);
  206016           0 :           for ( unsigned i = 0; i < SgClassExp::pool_size; ++i ) {
  206017           0 :                if ( pointer->get_freepointer() != NULL ) {
  206018           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  206019           0 :                  storageArray++;
  206020           0 :                  storageCounter++;
  206021             :                }
  206022           0 :                pointer++;
  206023             :              }
  206024           0 :            block++;
  206025             :         }
  206026           0 :      return storageCounter;
  206027             :    }
  206028             : 
  206029             : /* #line 206030 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  206030             : 
  206031             : 
  206032             : 
  206033             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  206034             : 
  206035             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  206036             : 
  206037             : //############################################################################
  206038             : /* JH (02/02/2006) Constructor of the IR node SgFunctionParameterRefExp that takes its 
  206039             :  * corresponding StorageClass as parameter
  206040             :  */
  206041          67 : SgFunctionParameterRefExp :: SgFunctionParameterRefExp ( const SgFunctionParameterRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  206042             :    {
  206043             : 
  206044             : 
  206045             : /* #line 206046 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  206046             : 
  206047          67 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  206048          67 :      p_parameter_number = storageSource.storageOf_parameter_number ;
  206049          67 :      p_parameter_levels_up = storageSource.storageOf_parameter_levels_up ;
  206050          67 :      p_parameter_expression =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parameter_expression) );
  206051          67 :      p_parameter_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_parameter_type) );
  206052             : 
  206053             : 
  206054             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  206055             : 
  206056             : 
  206057          67 :    }
  206058             : 
  206059             : //############################################################################
  206060             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  206061             :  * within the working AST. 
  206062             :  */
  206063         268 : SgFunctionParameterRefExp * SgFunctionParameterRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  206064         268 :      SgFunctionParameterRefExp* returnPointer = NULL;
  206065         268 :      if ( globalIndex != 0 )
  206066             :         {
  206067             : 
  206068             : #if FILE_IO_EXTRA_CHECK
  206069         268 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionParameterRefExp ) ) <= globalIndex ) ;
  206070         268 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionParameterRefExp + 1 ) ) );
  206071             : #endif
  206072         268 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionParameterRefExp )  
  206073         268 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionParameterRefExp );
  206074         268 :           unsigned long positionInPool = localIndex % SgFunctionParameterRefExp::pool_size;
  206075         268 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionParameterRefExp::pool_size;
  206076             : 
  206077             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  206078             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  206079             : 
  206080         268 :           returnPointer = &( ( (SgFunctionParameterRefExp*)(SgFunctionParameterRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  206081             : 
  206082         268 :           ROSE_ASSERT( returnPointer != NULL ) ;
  206083             :         }
  206084         268 :      return returnPointer ;
  206085             :    }
  206086             : 
  206087             : //############################################################################
  206088             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  206089             :   for the AST with the index astIndex
  206090             : */
  206091           0 : SgFunctionParameterRefExp * SgFunctionParameterRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  206092           0 :      SgFunctionParameterRefExp* returnPointer = NULL;
  206093           0 :      if ( globalIndex != 0 )
  206094             :         {
  206095             : 
  206096             : #if FILE_IO_EXTRA_CHECK
  206097           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionParameterRefExp ) ) <= globalIndex ) ;
  206098           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionParameterRefExp + 1 ) ) );
  206099             : #endif
  206100           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionParameterRefExp )
  206101           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionParameterRefExp );
  206102           0 :           unsigned long positionInPool = localIndex % SgFunctionParameterRefExp::pool_size ;
  206103           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionParameterRefExp::pool_size ;
  206104             : 
  206105             : #if FILE_IO_EXTRA_CHECK
  206106             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  206107             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  206108             : #endif
  206109             : 
  206110           0 :           returnPointer = &( ( (SgFunctionParameterRefExp*)(SgFunctionParameterRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  206111             : 
  206112             : #if FILE_IO_EXTRA_CHECK
  206113           0 :           assert ( returnPointer != NULL ) ;
  206114             : #endif
  206115             :         }
  206116           0 :      return returnPointer ;
  206117             :    }
  206118             : 
  206119             : //############################################################################
  206120             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  206121             :  * pool size! We set for every valid object in the memory pool the freepointer
  206122             :  * to the global index and increase the global index afterwards. For all the 
  206123             :  * invalid objects (means address ranges within the memory pool that were not
  206124             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  206125             :  * distinguish valid from invalid objects! 
  206126             :  */
  206127             : unsigned long
  206128           5 : SgFunctionParameterRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  206129             :    {
  206130           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  206131           5 :      SgFunctionParameterRefExp* pointer = NULL;
  206132           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  206133           5 :      std::vector < unsigned char* > :: const_iterator block;
  206134           6 :      for ( block = SgFunctionParameterRefExp::pools.begin(); block != SgFunctionParameterRefExp::pools.end() ; ++block )
  206135             :         {
  206136           1 :           pointer = (SgFunctionParameterRefExp*)(*block);
  206137        2001 :           for (unsigned i = 0; i < SgFunctionParameterRefExp::pool_size; ++i )
  206138             :              {
  206139             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  206140             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  206141             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  206142             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  206143             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  206144             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  206145             :             // properly; so this will have to be checked next.
  206146             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  206147             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  206148        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  206149             :                   {
  206150          67 :                     pointer[i].set_freepointer((SgFunctionParameterRefExp*)(globalIndex));
  206151          67 :                     globalIndex++;
  206152             :                   }
  206153             :                else
  206154             :                   {
  206155        1933 :                     pointer[i].set_freepointer(NULL);
  206156             :                   }
  206157             :               }
  206158             :         }
  206159           5 :      return globalIndex;
  206160             :    }
  206161             : 
  206162             : //############################################################################
  206163             : // JH (01/14/2006)
  206164             : void
  206165           5 : SgFunctionParameterRefExp::resetValidFreepointers( )
  206166             :    {
  206167           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  206168           5 :      SgFunctionParameterRefExp* pointer = NULL;
  206169           5 :      std::vector < unsigned char* > :: const_iterator block;
  206170           5 :      SgFunctionParameterRefExp* pointerOfLinkedList = NULL;
  206171           6 :      for ( block = SgFunctionParameterRefExp::pools.begin(); block != SgFunctionParameterRefExp::pools.end() ; ++block )
  206172             :         {
  206173           1 :           pointer = (SgFunctionParameterRefExp*)(*block);
  206174        2001 :           for (unsigned i = 0; i < SgFunctionParameterRefExp::pool_size; ++i )
  206175             :              {
  206176             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  206177             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  206178             :             // memory blocks!.
  206179        2000 :                if ( pointer[i].get_freepointer() != NULL )
  206180             :                   {
  206181          67 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  206182             :                   }
  206183             :                else
  206184             :                   {
  206185        1933 :                     if ( pointerOfLinkedList == NULL )
  206186             :                        {
  206187           1 :                          SgFunctionParameterRefExp::next_node = &(pointer[i]);
  206188             :                        }
  206189             :                     else
  206190             :                        {
  206191             :                       // printf ("In SgFunctionParameterRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  206192        1932 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  206193             :                        }
  206194             :                     pointerOfLinkedList = &(pointer[i]);
  206195             :                   }
  206196             :               }
  206197             :         }
  206198             : 
  206199           5 :      if ( pointerOfLinkedList != NULL )
  206200             :         {
  206201             :        // printf ("In SgFunctionParameterRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  206202           1 :           pointerOfLinkedList->set_freepointer(NULL);
  206203             :        // DQ (6/6/2010): Temporary debugging...
  206204             :        //   ROSE_ASSERT(false);
  206205             :         }
  206206             : 
  206207           5 :      return ;
  206208             :    }
  206209             : 
  206210             : //############################################################################
  206211             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  206212             :  * within the memory pool and resets the freepointers, in order to achieve a 
  206213             :  * linked list, that has no jumps and starts at the beginning! This function 
  206214             :  * does not extend the memory pool, since we do not delete any memory blocks,
  206215             :  * but delete the valid objects.  
  206216             :  */
  206217             : void
  206218           0 : SgFunctionParameterRefExp::clearMemoryPool( )
  206219             :    {
  206220             :   // printf ("Inside of SgFunctionParameterRefExp::clearMemoryPool() \n");
  206221             : 
  206222           0 :      SgFunctionParameterRefExp* pointer = NULL, *tempPointer = NULL;
  206223           0 :      std::vector < unsigned char* > :: const_iterator block;
  206224           0 :      if ( SgFunctionParameterRefExp::pools.empty() == false )
  206225             :         {
  206226           0 :           block = SgFunctionParameterRefExp::pools.begin() ;
  206227           0 :           SgFunctionParameterRefExp::next_node = (SgFunctionParameterRefExp*) (*block);
  206228             : 
  206229           0 :           while ( block != SgFunctionParameterRefExp::pools.end() )
  206230             :              {
  206231           0 :                pointer = (SgFunctionParameterRefExp*) (*block);
  206232           0 :                if ( tempPointer != NULL )
  206233             :                   {
  206234           0 :                     tempPointer->set_freepointer(pointer);
  206235             :                   }
  206236           0 :                for (unsigned i = 0; i < SgFunctionParameterRefExp::pool_size - 1; ++i)
  206237             :                   {
  206238           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  206239             :                   }
  206240           0 :                 pointer[SgFunctionParameterRefExp::pool_size-1].set_freepointer(NULL);
  206241           0 :                 tempPointer = &(pointer[SgFunctionParameterRefExp::pool_size-1]);
  206242           0 :                 ++block;
  206243             :              }
  206244             :         }
  206245           0 :    }
  206246             : 
  206247           5 : void SgFunctionParameterRefExp::deleteMemoryPool() {
  206248           7 :   for (auto p: SgFunctionParameterRefExp::pools) {
  206249           2 :     ROSE_FREE(p);
  206250             :   }
  206251           5 :   SgFunctionParameterRefExp::next_node = nullptr;
  206252           5 :   SgFunctionParameterRefExp::pools.clear();
  206253           5 : }
  206254             : 
  206255             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  206256             : //                 reading multiple binary files to for a single AST.
  206257             : /////////// new version ////////////////////////////////
  206258             : //############################################################################
  206259             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  206260             : void
  206261           2 : SgFunctionParameterRefExp::extendMemoryPoolForFileIO( )
  206262             :   {
  206263           2 :     size_t blockIndex = SgFunctionParameterRefExp::pools.size();
  206264           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterRefExp);
  206265             : 
  206266           3 :     while ( (blockIndex * SgFunctionParameterRefExp::pool_size) < newPoolSize)
  206267             :       {
  206268             : #if ROSE_ALLOC_TRACE
  206269             :         if (blockIndex > 0) {
  206270             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterRefExp) = %" PRIuPTR " SgFunctionParameterRefExp::pool_size = %d \n",
  206271             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionParameterRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionParameterRefExp),SgFunctionParameterRefExp::pool_size);
  206272             :         }
  206273             : #endif
  206274             : 
  206275           1 :         SgFunctionParameterRefExp * pointer = (SgFunctionParameterRefExp*) ROSE_MALLOC ( SgFunctionParameterRefExp::pool_size * sizeof(SgFunctionParameterRefExp) );
  206276           1 :         assert( pointer != NULL );
  206277             : #if ROSE_ALLOC_MEMSET == 1
  206278             :         memset(pointer, 0x00, SgFunctionParameterRefExp::pool_size * sizeof(SgFunctionParameterRefExp));
  206279             : #elif ROSE_ALLOC_MEMSET == 2
  206280             :         memset(pointer, 0xCC, SgFunctionParameterRefExp::pool_size * sizeof(SgFunctionParameterRefExp));
  206281             : #endif
  206282           1 :         SgFunctionParameterRefExp::pools.push_back( (unsigned char*)(pointer) );
  206283           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionParameterRefExp::pool_size * sizeof(SgFunctionParameterRefExp), V_SgFunctionParameterRefExp ) );
  206284             : 
  206285           1 :         if ( SgFunctionParameterRefExp::next_node != NULL ) {
  206286           0 :           if ( blockIndex > 0 ) {
  206287           0 :             SgFunctionParameterRefExp * blkptr = (SgFunctionParameterRefExp*)(SgFunctionParameterRefExp::pools[blockIndex-1]);
  206288           0 :             blkptr[ SgFunctionParameterRefExp::pool_size - 1 ].set_freepointer(pointer);
  206289             :           }
  206290             :         } else {
  206291           1 :           SgFunctionParameterRefExp::next_node = pointer;
  206292             :         }
  206293             : 
  206294        2000 :         for (unsigned i = 0; i < SgFunctionParameterRefExp::pool_size-1; ++i)
  206295             :            {
  206296        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  206297             :            }
  206298           1 :         pointer[ SgFunctionParameterRefExp::pool_size -1 ].set_freepointer(NULL);
  206299             : 
  206300           1 :         blockIndex++;
  206301             :       }
  206302           2 :   }
  206303             : 
  206304             : //############################################################################
  206305             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  206306             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  206307             :  * not compressed. However, that stuff is not yet implemented! 
  206308             :  */
  206309             : unsigned long
  206310           0 : SgFunctionParameterRefExp::getNumberOfLastValidPointer()
  206311             :    {
  206312           0 :       SgFunctionParameterRefExp* testPointer = (SgFunctionParameterRefExp*)(SgFunctionParameterRefExp::pools.back());
  206313           0 :       unsigned long localIndex = SgFunctionParameterRefExp::pool_size - 1;
  206314           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  206315             :          {
  206316           0 :            localIndex--;
  206317             :          }
  206318           0 :       return (localIndex + SgFunctionParameterRefExp::pool_size * (SgFunctionParameterRefExp::pools.size()-1));
  206319             :    }
  206320             : 
  206321             : //############################################################################
  206322             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  206323             :  * memory pool and initializes the data member in class SgFunctionParameterRefExpStroageClass
  206324             :  * from its counterpart of SgFunctionParameterRefExp. The return value is just for checking, 
  206325             :  * that the whole StorageClassArray is initialized!
  206326             :  */
  206327             : unsigned long
  206328           1 : SgFunctionParameterRefExp::initializeStorageClassArray( SgFunctionParameterRefExpStorageClass *storageArray )
  206329             :    {
  206330           1 :      unsigned long storageCounter = 0;
  206331           1 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionParameterRefExp::pools.begin();
  206332           1 :      SgFunctionParameterRefExp* pointer = NULL;
  206333           2 :      while ( block != SgFunctionParameterRefExp::pools.end() ) {
  206334           1 :           pointer = (SgFunctionParameterRefExp*) (*block);
  206335        2001 :           for ( unsigned i = 0; i < SgFunctionParameterRefExp::pool_size; ++i ) {
  206336        2000 :                if ( pointer->get_freepointer() != NULL ) {
  206337          67 :                  storageArray->pickOutIRNodeData (pointer) ;
  206338          67 :                  storageArray++;
  206339          67 :                  storageCounter++;
  206340             :                }
  206341        2000 :                pointer++;
  206342             :              }
  206343           1 :            block++;
  206344             :         }
  206345           1 :      return storageCounter;
  206346             :    }
  206347             : 
  206348             : /* #line 206349 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  206349             : 
  206350             : 
  206351             : 
  206352             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  206353             : 
  206354             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  206355             : 
  206356             : //############################################################################
  206357             : /* JH (02/02/2006) Constructor of the IR node SgLambdaExp that takes its 
  206358             :  * corresponding StorageClass as parameter
  206359             :  */
  206360           0 : SgLambdaExp :: SgLambdaExp ( const SgLambdaExpStorageClass& storageSource )   : SgExpression (storageSource)
  206361             :    {
  206362             : 
  206363             : 
  206364             : /* #line 206365 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  206365             : 
  206366           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  206367           0 :      p_lambda_capture_list =  (SgLambdaCaptureList*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lambda_capture_list) );
  206368           0 :      p_lambda_closure_class =  (SgClassDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lambda_closure_class) );
  206369           0 :      p_lambda_function =  (SgFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_lambda_function) );
  206370           0 :      p_is_mutable = storageSource.storageOf_is_mutable ;
  206371           0 :      p_capture_default = storageSource.storageOf_capture_default ;
  206372           0 :      p_default_is_by_reference = storageSource.storageOf_default_is_by_reference ;
  206373           0 :      p_explicit_return_type = storageSource.storageOf_explicit_return_type ;
  206374           0 :      p_has_parameter_decl = storageSource.storageOf_has_parameter_decl ;
  206375           0 :      p_is_device = storageSource.storageOf_is_device ;
  206376             : 
  206377             : 
  206378             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  206379             : 
  206380             : 
  206381           0 :    }
  206382             : 
  206383             : //############################################################################
  206384             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  206385             :  * within the working AST. 
  206386             :  */
  206387           0 : SgLambdaExp * SgLambdaExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  206388           0 :      SgLambdaExp* returnPointer = NULL;
  206389           0 :      if ( globalIndex != 0 )
  206390             :         {
  206391             : 
  206392             : #if FILE_IO_EXTRA_CHECK
  206393           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLambdaExp ) ) <= globalIndex ) ;
  206394           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLambdaExp + 1 ) ) );
  206395             : #endif
  206396           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLambdaExp )  
  206397           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLambdaExp );
  206398           0 :           unsigned long positionInPool = localIndex % SgLambdaExp::pool_size;
  206399           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLambdaExp::pool_size;
  206400             : 
  206401             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  206402             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  206403             : 
  206404           0 :           returnPointer = &( ( (SgLambdaExp*)(SgLambdaExp::pools[memoryBlock]) ) [positionInPool]) ;
  206405             : 
  206406           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  206407             :         }
  206408           0 :      return returnPointer ;
  206409             :    }
  206410             : 
  206411             : //############################################################################
  206412             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  206413             :   for the AST with the index astIndex
  206414             : */
  206415           0 : SgLambdaExp * SgLambdaExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  206416           0 :      SgLambdaExp* returnPointer = NULL;
  206417           0 :      if ( globalIndex != 0 )
  206418             :         {
  206419             : 
  206420             : #if FILE_IO_EXTRA_CHECK
  206421           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLambdaExp ) ) <= globalIndex ) ;
  206422           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLambdaExp + 1 ) ) );
  206423             : #endif
  206424           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLambdaExp )
  206425           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLambdaExp );
  206426           0 :           unsigned long positionInPool = localIndex % SgLambdaExp::pool_size ;
  206427           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLambdaExp::pool_size ;
  206428             : 
  206429             : #if FILE_IO_EXTRA_CHECK
  206430             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  206431             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  206432             : #endif
  206433             : 
  206434           0 :           returnPointer = &( ( (SgLambdaExp*)(SgLambdaExp::pools[memoryBlock]) ) [positionInPool]) ;
  206435             : 
  206436             : #if FILE_IO_EXTRA_CHECK
  206437           0 :           assert ( returnPointer != NULL ) ;
  206438             : #endif
  206439             :         }
  206440           0 :      return returnPointer ;
  206441             :    }
  206442             : 
  206443             : //############################################################################
  206444             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  206445             :  * pool size! We set for every valid object in the memory pool the freepointer
  206446             :  * to the global index and increase the global index afterwards. For all the 
  206447             :  * invalid objects (means address ranges within the memory pool that were not
  206448             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  206449             :  * distinguish valid from invalid objects! 
  206450             :  */
  206451             : unsigned long
  206452           5 : SgLambdaExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  206453             :    {
  206454           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  206455           5 :      SgLambdaExp* pointer = NULL;
  206456           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  206457           5 :      std::vector < unsigned char* > :: const_iterator block;
  206458           5 :      for ( block = SgLambdaExp::pools.begin(); block != SgLambdaExp::pools.end() ; ++block )
  206459             :         {
  206460           0 :           pointer = (SgLambdaExp*)(*block);
  206461           0 :           for (unsigned i = 0; i < SgLambdaExp::pool_size; ++i )
  206462             :              {
  206463             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  206464             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  206465             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  206466             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  206467             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  206468             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  206469             :             // properly; so this will have to be checked next.
  206470             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  206471             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  206472           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  206473             :                   {
  206474           0 :                     pointer[i].set_freepointer((SgLambdaExp*)(globalIndex));
  206475           0 :                     globalIndex++;
  206476             :                   }
  206477             :                else
  206478             :                   {
  206479           0 :                     pointer[i].set_freepointer(NULL);
  206480             :                   }
  206481             :               }
  206482             :         }
  206483           5 :      return globalIndex;
  206484             :    }
  206485             : 
  206486             : //############################################################################
  206487             : // JH (01/14/2006)
  206488             : void
  206489           5 : SgLambdaExp::resetValidFreepointers( )
  206490             :    {
  206491           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  206492           5 :      SgLambdaExp* pointer = NULL;
  206493           5 :      std::vector < unsigned char* > :: const_iterator block;
  206494           5 :      SgLambdaExp* pointerOfLinkedList = NULL;
  206495           5 :      for ( block = SgLambdaExp::pools.begin(); block != SgLambdaExp::pools.end() ; ++block )
  206496             :         {
  206497           0 :           pointer = (SgLambdaExp*)(*block);
  206498           0 :           for (unsigned i = 0; i < SgLambdaExp::pool_size; ++i )
  206499             :              {
  206500             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  206501             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  206502             :             // memory blocks!.
  206503           0 :                if ( pointer[i].get_freepointer() != NULL )
  206504             :                   {
  206505           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  206506             :                   }
  206507             :                else
  206508             :                   {
  206509           0 :                     if ( pointerOfLinkedList == NULL )
  206510             :                        {
  206511           0 :                          SgLambdaExp::next_node = &(pointer[i]);
  206512             :                        }
  206513             :                     else
  206514             :                        {
  206515             :                       // printf ("In SgLambdaExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  206516           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  206517             :                        }
  206518             :                     pointerOfLinkedList = &(pointer[i]);
  206519             :                   }
  206520             :               }
  206521             :         }
  206522             : 
  206523           5 :      if ( pointerOfLinkedList != NULL )
  206524             :         {
  206525             :        // printf ("In SgLambdaExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  206526           0 :           pointerOfLinkedList->set_freepointer(NULL);
  206527             :        // DQ (6/6/2010): Temporary debugging...
  206528             :        //   ROSE_ASSERT(false);
  206529             :         }
  206530             : 
  206531           5 :      return ;
  206532             :    }
  206533             : 
  206534             : //############################################################################
  206535             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  206536             :  * within the memory pool and resets the freepointers, in order to achieve a 
  206537             :  * linked list, that has no jumps and starts at the beginning! This function 
  206538             :  * does not extend the memory pool, since we do not delete any memory blocks,
  206539             :  * but delete the valid objects.  
  206540             :  */
  206541             : void
  206542           0 : SgLambdaExp::clearMemoryPool( )
  206543             :    {
  206544             :   // printf ("Inside of SgLambdaExp::clearMemoryPool() \n");
  206545             : 
  206546           0 :      SgLambdaExp* pointer = NULL, *tempPointer = NULL;
  206547           0 :      std::vector < unsigned char* > :: const_iterator block;
  206548           0 :      if ( SgLambdaExp::pools.empty() == false )
  206549             :         {
  206550           0 :           block = SgLambdaExp::pools.begin() ;
  206551           0 :           SgLambdaExp::next_node = (SgLambdaExp*) (*block);
  206552             : 
  206553           0 :           while ( block != SgLambdaExp::pools.end() )
  206554             :              {
  206555           0 :                pointer = (SgLambdaExp*) (*block);
  206556           0 :                if ( tempPointer != NULL )
  206557             :                   {
  206558           0 :                     tempPointer->set_freepointer(pointer);
  206559             :                   }
  206560           0 :                for (unsigned i = 0; i < SgLambdaExp::pool_size - 1; ++i)
  206561             :                   {
  206562           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  206563             :                   }
  206564           0 :                 pointer[SgLambdaExp::pool_size-1].set_freepointer(NULL);
  206565           0 :                 tempPointer = &(pointer[SgLambdaExp::pool_size-1]);
  206566           0 :                 ++block;
  206567             :              }
  206568             :         }
  206569           0 :    }
  206570             : 
  206571           5 : void SgLambdaExp::deleteMemoryPool() {
  206572           5 :   for (auto p: SgLambdaExp::pools) {
  206573           0 :     ROSE_FREE(p);
  206574             :   }
  206575           5 :   SgLambdaExp::next_node = nullptr;
  206576           5 :   SgLambdaExp::pools.clear();
  206577           5 : }
  206578             : 
  206579             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  206580             : //                 reading multiple binary files to for a single AST.
  206581             : /////////// new version ////////////////////////////////
  206582             : //############################################################################
  206583             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  206584             : void
  206585           2 : SgLambdaExp::extendMemoryPoolForFileIO( )
  206586             :   {
  206587           2 :     size_t blockIndex = SgLambdaExp::pools.size();
  206588           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaExp);
  206589             : 
  206590           2 :     while ( (blockIndex * SgLambdaExp::pool_size) < newPoolSize)
  206591             :       {
  206592             : #if ROSE_ALLOC_TRACE
  206593             :         if (blockIndex > 0) {
  206594             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaExp) = %" PRIuPTR " SgLambdaExp::pool_size = %d \n",
  206595             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLambdaExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLambdaExp),SgLambdaExp::pool_size);
  206596             :         }
  206597             : #endif
  206598             : 
  206599           0 :         SgLambdaExp * pointer = (SgLambdaExp*) ROSE_MALLOC ( SgLambdaExp::pool_size * sizeof(SgLambdaExp) );
  206600           0 :         assert( pointer != NULL );
  206601             : #if ROSE_ALLOC_MEMSET == 1
  206602             :         memset(pointer, 0x00, SgLambdaExp::pool_size * sizeof(SgLambdaExp));
  206603             : #elif ROSE_ALLOC_MEMSET == 2
  206604             :         memset(pointer, 0xCC, SgLambdaExp::pool_size * sizeof(SgLambdaExp));
  206605             : #endif
  206606           0 :         SgLambdaExp::pools.push_back( (unsigned char*)(pointer) );
  206607           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLambdaExp::pool_size * sizeof(SgLambdaExp), V_SgLambdaExp ) );
  206608             : 
  206609           0 :         if ( SgLambdaExp::next_node != NULL ) {
  206610           0 :           if ( blockIndex > 0 ) {
  206611           0 :             SgLambdaExp * blkptr = (SgLambdaExp*)(SgLambdaExp::pools[blockIndex-1]);
  206612           0 :             blkptr[ SgLambdaExp::pool_size - 1 ].set_freepointer(pointer);
  206613             :           }
  206614             :         } else {
  206615           0 :           SgLambdaExp::next_node = pointer;
  206616             :         }
  206617             : 
  206618           0 :         for (unsigned i = 0; i < SgLambdaExp::pool_size-1; ++i)
  206619             :            {
  206620           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  206621             :            }
  206622           0 :         pointer[ SgLambdaExp::pool_size -1 ].set_freepointer(NULL);
  206623             : 
  206624           0 :         blockIndex++;
  206625             :       }
  206626           2 :   }
  206627             : 
  206628             : //############################################################################
  206629             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  206630             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  206631             :  * not compressed. However, that stuff is not yet implemented! 
  206632             :  */
  206633             : unsigned long
  206634           0 : SgLambdaExp::getNumberOfLastValidPointer()
  206635             :    {
  206636           0 :       SgLambdaExp* testPointer = (SgLambdaExp*)(SgLambdaExp::pools.back());
  206637           0 :       unsigned long localIndex = SgLambdaExp::pool_size - 1;
  206638           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  206639             :          {
  206640           0 :            localIndex--;
  206641             :          }
  206642           0 :       return (localIndex + SgLambdaExp::pool_size * (SgLambdaExp::pools.size()-1));
  206643             :    }
  206644             : 
  206645             : //############################################################################
  206646             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  206647             :  * memory pool and initializes the data member in class SgLambdaExpStroageClass
  206648             :  * from its counterpart of SgLambdaExp. The return value is just for checking, 
  206649             :  * that the whole StorageClassArray is initialized!
  206650             :  */
  206651             : unsigned long
  206652           0 : SgLambdaExp::initializeStorageClassArray( SgLambdaExpStorageClass *storageArray )
  206653             :    {
  206654           0 :      unsigned long storageCounter = 0;
  206655           0 :      std::vector < unsigned char* > :: const_iterator block = SgLambdaExp::pools.begin();
  206656           0 :      SgLambdaExp* pointer = NULL;
  206657           0 :      while ( block != SgLambdaExp::pools.end() ) {
  206658           0 :           pointer = (SgLambdaExp*) (*block);
  206659           0 :           for ( unsigned i = 0; i < SgLambdaExp::pool_size; ++i ) {
  206660           0 :                if ( pointer->get_freepointer() != NULL ) {
  206661           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  206662           0 :                  storageArray++;
  206663           0 :                  storageCounter++;
  206664             :                }
  206665           0 :                pointer++;
  206666             :              }
  206667           0 :            block++;
  206668             :         }
  206669           0 :      return storageCounter;
  206670             :    }
  206671             : 
  206672             : /* #line 206673 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  206673             : 
  206674             : 
  206675             : 
  206676             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  206677             : 
  206678             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  206679             : 
  206680             : //############################################################################
  206681             : /* JH (02/02/2006) Constructor of the IR node SgNoexceptOp that takes its 
  206682             :  * corresponding StorageClass as parameter
  206683             :  */
  206684          18 : SgNoexceptOp :: SgNoexceptOp ( const SgNoexceptOpStorageClass& storageSource )   : SgExpression (storageSource)
  206685             :    {
  206686             : 
  206687             : 
  206688             : /* #line 206689 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  206689             : 
  206690          18 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  206691          18 :      p_operand_expr =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operand_expr) );
  206692             : 
  206693             : 
  206694             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  206695             : 
  206696             : 
  206697          18 :    }
  206698             : 
  206699             : //############################################################################
  206700             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  206701             :  * within the working AST. 
  206702             :  */
  206703          90 : SgNoexceptOp * SgNoexceptOp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  206704          90 :      SgNoexceptOp* returnPointer = NULL;
  206705          90 :      if ( globalIndex != 0 )
  206706             :         {
  206707             : 
  206708             : #if FILE_IO_EXTRA_CHECK
  206709          90 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNoexceptOp ) ) <= globalIndex ) ;
  206710          90 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNoexceptOp + 1 ) ) );
  206711             : #endif
  206712          90 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNoexceptOp )  
  206713          90 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNoexceptOp );
  206714          90 :           unsigned long positionInPool = localIndex % SgNoexceptOp::pool_size;
  206715          90 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNoexceptOp::pool_size;
  206716             : 
  206717             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  206718             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  206719             : 
  206720          90 :           returnPointer = &( ( (SgNoexceptOp*)(SgNoexceptOp::pools[memoryBlock]) ) [positionInPool]) ;
  206721             : 
  206722          90 :           ROSE_ASSERT( returnPointer != NULL ) ;
  206723             :         }
  206724          90 :      return returnPointer ;
  206725             :    }
  206726             : 
  206727             : //############################################################################
  206728             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  206729             :   for the AST with the index astIndex
  206730             : */
  206731           0 : SgNoexceptOp * SgNoexceptOp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  206732           0 :      SgNoexceptOp* returnPointer = NULL;
  206733           0 :      if ( globalIndex != 0 )
  206734             :         {
  206735             : 
  206736             : #if FILE_IO_EXTRA_CHECK
  206737           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNoexceptOp ) ) <= globalIndex ) ;
  206738           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNoexceptOp + 1 ) ) );
  206739             : #endif
  206740           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNoexceptOp )
  206741           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNoexceptOp );
  206742           0 :           unsigned long positionInPool = localIndex % SgNoexceptOp::pool_size ;
  206743           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNoexceptOp::pool_size ;
  206744             : 
  206745             : #if FILE_IO_EXTRA_CHECK
  206746             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  206747             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  206748             : #endif
  206749             : 
  206750           0 :           returnPointer = &( ( (SgNoexceptOp*)(SgNoexceptOp::pools[memoryBlock]) ) [positionInPool]) ;
  206751             : 
  206752             : #if FILE_IO_EXTRA_CHECK
  206753           0 :           assert ( returnPointer != NULL ) ;
  206754             : #endif
  206755             :         }
  206756           0 :      return returnPointer ;
  206757             :    }
  206758             : 
  206759             : //############################################################################
  206760             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  206761             :  * pool size! We set for every valid object in the memory pool the freepointer
  206762             :  * to the global index and increase the global index afterwards. For all the 
  206763             :  * invalid objects (means address ranges within the memory pool that were not
  206764             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  206765             :  * distinguish valid from invalid objects! 
  206766             :  */
  206767             : unsigned long
  206768           5 : SgNoexceptOp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  206769             :    {
  206770           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  206771           5 :      SgNoexceptOp* pointer = NULL;
  206772           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  206773           5 :      std::vector < unsigned char* > :: const_iterator block;
  206774           6 :      for ( block = SgNoexceptOp::pools.begin(); block != SgNoexceptOp::pools.end() ; ++block )
  206775             :         {
  206776           1 :           pointer = (SgNoexceptOp*)(*block);
  206777        2001 :           for (unsigned i = 0; i < SgNoexceptOp::pool_size; ++i )
  206778             :              {
  206779             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  206780             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  206781             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  206782             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  206783             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  206784             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  206785             :             // properly; so this will have to be checked next.
  206786             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  206787             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  206788        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  206789             :                   {
  206790          18 :                     pointer[i].set_freepointer((SgNoexceptOp*)(globalIndex));
  206791          18 :                     globalIndex++;
  206792             :                   }
  206793             :                else
  206794             :                   {
  206795        1982 :                     pointer[i].set_freepointer(NULL);
  206796             :                   }
  206797             :               }
  206798             :         }
  206799           5 :      return globalIndex;
  206800             :    }
  206801             : 
  206802             : //############################################################################
  206803             : // JH (01/14/2006)
  206804             : void
  206805           5 : SgNoexceptOp::resetValidFreepointers( )
  206806             :    {
  206807           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  206808           5 :      SgNoexceptOp* pointer = NULL;
  206809           5 :      std::vector < unsigned char* > :: const_iterator block;
  206810           5 :      SgNoexceptOp* pointerOfLinkedList = NULL;
  206811           6 :      for ( block = SgNoexceptOp::pools.begin(); block != SgNoexceptOp::pools.end() ; ++block )
  206812             :         {
  206813           1 :           pointer = (SgNoexceptOp*)(*block);
  206814        2001 :           for (unsigned i = 0; i < SgNoexceptOp::pool_size; ++i )
  206815             :              {
  206816             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  206817             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  206818             :             // memory blocks!.
  206819        2000 :                if ( pointer[i].get_freepointer() != NULL )
  206820             :                   {
  206821          18 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  206822             :                   }
  206823             :                else
  206824             :                   {
  206825        1982 :                     if ( pointerOfLinkedList == NULL )
  206826             :                        {
  206827           1 :                          SgNoexceptOp::next_node = &(pointer[i]);
  206828             :                        }
  206829             :                     else
  206830             :                        {
  206831             :                       // printf ("In SgNoexceptOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  206832        1981 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  206833             :                        }
  206834             :                     pointerOfLinkedList = &(pointer[i]);
  206835             :                   }
  206836             :               }
  206837             :         }
  206838             : 
  206839           5 :      if ( pointerOfLinkedList != NULL )
  206840             :         {
  206841             :        // printf ("In SgNoexceptOp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  206842           1 :           pointerOfLinkedList->set_freepointer(NULL);
  206843             :        // DQ (6/6/2010): Temporary debugging...
  206844             :        //   ROSE_ASSERT(false);
  206845             :         }
  206846             : 
  206847           5 :      return ;
  206848             :    }
  206849             : 
  206850             : //############################################################################
  206851             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  206852             :  * within the memory pool and resets the freepointers, in order to achieve a 
  206853             :  * linked list, that has no jumps and starts at the beginning! This function 
  206854             :  * does not extend the memory pool, since we do not delete any memory blocks,
  206855             :  * but delete the valid objects.  
  206856             :  */
  206857             : void
  206858           0 : SgNoexceptOp::clearMemoryPool( )
  206859             :    {
  206860             :   // printf ("Inside of SgNoexceptOp::clearMemoryPool() \n");
  206861             : 
  206862           0 :      SgNoexceptOp* pointer = NULL, *tempPointer = NULL;
  206863           0 :      std::vector < unsigned char* > :: const_iterator block;
  206864           0 :      if ( SgNoexceptOp::pools.empty() == false )
  206865             :         {
  206866           0 :           block = SgNoexceptOp::pools.begin() ;
  206867           0 :           SgNoexceptOp::next_node = (SgNoexceptOp*) (*block);
  206868             : 
  206869           0 :           while ( block != SgNoexceptOp::pools.end() )
  206870             :              {
  206871           0 :                pointer = (SgNoexceptOp*) (*block);
  206872           0 :                if ( tempPointer != NULL )
  206873             :                   {
  206874           0 :                     tempPointer->set_freepointer(pointer);
  206875             :                   }
  206876           0 :                for (unsigned i = 0; i < SgNoexceptOp::pool_size - 1; ++i)
  206877             :                   {
  206878           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  206879             :                   }
  206880           0 :                 pointer[SgNoexceptOp::pool_size-1].set_freepointer(NULL);
  206881           0 :                 tempPointer = &(pointer[SgNoexceptOp::pool_size-1]);
  206882           0 :                 ++block;
  206883             :              }
  206884             :         }
  206885           0 :    }
  206886             : 
  206887           5 : void SgNoexceptOp::deleteMemoryPool() {
  206888           7 :   for (auto p: SgNoexceptOp::pools) {
  206889           2 :     ROSE_FREE(p);
  206890             :   }
  206891           5 :   SgNoexceptOp::next_node = nullptr;
  206892           5 :   SgNoexceptOp::pools.clear();
  206893           5 : }
  206894             : 
  206895             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  206896             : //                 reading multiple binary files to for a single AST.
  206897             : /////////// new version ////////////////////////////////
  206898             : //############################################################################
  206899             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  206900             : void
  206901           2 : SgNoexceptOp::extendMemoryPoolForFileIO( )
  206902             :   {
  206903           2 :     size_t blockIndex = SgNoexceptOp::pools.size();
  206904           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNoexceptOp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNoexceptOp);
  206905             : 
  206906           3 :     while ( (blockIndex * SgNoexceptOp::pool_size) < newPoolSize)
  206907             :       {
  206908             : #if ROSE_ALLOC_TRACE
  206909             :         if (blockIndex > 0) {
  206910             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNoexceptOp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNoexceptOp) = %" PRIuPTR " SgNoexceptOp::pool_size = %d \n",
  206911             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNoexceptOp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNoexceptOp),SgNoexceptOp::pool_size);
  206912             :         }
  206913             : #endif
  206914             : 
  206915           1 :         SgNoexceptOp * pointer = (SgNoexceptOp*) ROSE_MALLOC ( SgNoexceptOp::pool_size * sizeof(SgNoexceptOp) );
  206916           1 :         assert( pointer != NULL );
  206917             : #if ROSE_ALLOC_MEMSET == 1
  206918             :         memset(pointer, 0x00, SgNoexceptOp::pool_size * sizeof(SgNoexceptOp));
  206919             : #elif ROSE_ALLOC_MEMSET == 2
  206920             :         memset(pointer, 0xCC, SgNoexceptOp::pool_size * sizeof(SgNoexceptOp));
  206921             : #endif
  206922           1 :         SgNoexceptOp::pools.push_back( (unsigned char*)(pointer) );
  206923           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNoexceptOp::pool_size * sizeof(SgNoexceptOp), V_SgNoexceptOp ) );
  206924             : 
  206925           1 :         if ( SgNoexceptOp::next_node != NULL ) {
  206926           0 :           if ( blockIndex > 0 ) {
  206927           0 :             SgNoexceptOp * blkptr = (SgNoexceptOp*)(SgNoexceptOp::pools[blockIndex-1]);
  206928           0 :             blkptr[ SgNoexceptOp::pool_size - 1 ].set_freepointer(pointer);
  206929             :           }
  206930             :         } else {
  206931           1 :           SgNoexceptOp::next_node = pointer;
  206932             :         }
  206933             : 
  206934        2000 :         for (unsigned i = 0; i < SgNoexceptOp::pool_size-1; ++i)
  206935             :            {
  206936        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  206937             :            }
  206938           1 :         pointer[ SgNoexceptOp::pool_size -1 ].set_freepointer(NULL);
  206939             : 
  206940           1 :         blockIndex++;
  206941             :       }
  206942           2 :   }
  206943             : 
  206944             : //############################################################################
  206945             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  206946             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  206947             :  * not compressed. However, that stuff is not yet implemented! 
  206948             :  */
  206949             : unsigned long
  206950           0 : SgNoexceptOp::getNumberOfLastValidPointer()
  206951             :    {
  206952           0 :       SgNoexceptOp* testPointer = (SgNoexceptOp*)(SgNoexceptOp::pools.back());
  206953           0 :       unsigned long localIndex = SgNoexceptOp::pool_size - 1;
  206954           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  206955             :          {
  206956           0 :            localIndex--;
  206957             :          }
  206958           0 :       return (localIndex + SgNoexceptOp::pool_size * (SgNoexceptOp::pools.size()-1));
  206959             :    }
  206960             : 
  206961             : //############################################################################
  206962             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  206963             :  * memory pool and initializes the data member in class SgNoexceptOpStroageClass
  206964             :  * from its counterpart of SgNoexceptOp. The return value is just for checking, 
  206965             :  * that the whole StorageClassArray is initialized!
  206966             :  */
  206967             : unsigned long
  206968           1 : SgNoexceptOp::initializeStorageClassArray( SgNoexceptOpStorageClass *storageArray )
  206969             :    {
  206970           1 :      unsigned long storageCounter = 0;
  206971           1 :      std::vector < unsigned char* > :: const_iterator block = SgNoexceptOp::pools.begin();
  206972           1 :      SgNoexceptOp* pointer = NULL;
  206973           2 :      while ( block != SgNoexceptOp::pools.end() ) {
  206974           1 :           pointer = (SgNoexceptOp*) (*block);
  206975        2001 :           for ( unsigned i = 0; i < SgNoexceptOp::pool_size; ++i ) {
  206976        2000 :                if ( pointer->get_freepointer() != NULL ) {
  206977          18 :                  storageArray->pickOutIRNodeData (pointer) ;
  206978          18 :                  storageArray++;
  206979          18 :                  storageCounter++;
  206980             :                }
  206981        2000 :                pointer++;
  206982             :              }
  206983           1 :            block++;
  206984             :         }
  206985           1 :      return storageCounter;
  206986             :    }
  206987             : 
  206988             : /* #line 206989 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  206989             : 
  206990             : 
  206991             : 
  206992             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  206993             : 
  206994             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  206995             : 
  206996             : //############################################################################
  206997             : /* JH (02/02/2006) Constructor of the IR node SgNonrealRefExp that takes its 
  206998             :  * corresponding StorageClass as parameter
  206999             :  */
  207000        1494 : SgNonrealRefExp :: SgNonrealRefExp ( const SgNonrealRefExpStorageClass& storageSource )   : SgExpression (storageSource)
  207001             :    {
  207002             : 
  207003             : 
  207004             : /* #line 207005 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  207005             : 
  207006        1494 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  207007        1494 :      p_symbol =  (SgNonrealSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_symbol) );
  207008        1494 :      p_name_qualification_length = storageSource.storageOf_name_qualification_length ;
  207009        1494 :      p_type_elaboration_required = storageSource.storageOf_type_elaboration_required ;
  207010        1494 :      p_global_qualification_required = storageSource.storageOf_global_qualification_required ;
  207011             : 
  207012             : 
  207013             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  207014             : 
  207015             : 
  207016        1494 :    }
  207017             : 
  207018             : //############################################################################
  207019             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  207020             :  * within the working AST. 
  207021             :  */
  207022        5976 : SgNonrealRefExp * SgNonrealRefExp::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  207023        5976 :      SgNonrealRefExp* returnPointer = NULL;
  207024        5976 :      if ( globalIndex != 0 )
  207025             :         {
  207026             : 
  207027             : #if FILE_IO_EXTRA_CHECK
  207028        5976 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNonrealRefExp ) ) <= globalIndex ) ;
  207029        5976 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealRefExp + 1 ) ) );
  207030             : #endif
  207031        5976 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealRefExp )  
  207032        5976 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNonrealRefExp );
  207033        5976 :           unsigned long positionInPool = localIndex % SgNonrealRefExp::pool_size;
  207034        5976 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealRefExp::pool_size;
  207035             : 
  207036             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  207037             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  207038             : 
  207039        5976 :           returnPointer = &( ( (SgNonrealRefExp*)(SgNonrealRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  207040             : 
  207041        5976 :           ROSE_ASSERT( returnPointer != NULL ) ;
  207042             :         }
  207043        5976 :      return returnPointer ;
  207044             :    }
  207045             : 
  207046             : //############################################################################
  207047             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  207048             :   for the AST with the index astIndex
  207049             : */
  207050           0 : SgNonrealRefExp * SgNonrealRefExp::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  207051           0 :      SgNonrealRefExp* returnPointer = NULL;
  207052           0 :      if ( globalIndex != 0 )
  207053             :         {
  207054             : 
  207055             : #if FILE_IO_EXTRA_CHECK
  207056           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNonrealRefExp ) ) <= globalIndex ) ;
  207057           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealRefExp + 1 ) ) );
  207058             : #endif
  207059           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealRefExp )
  207060           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNonrealRefExp );
  207061           0 :           unsigned long positionInPool = localIndex % SgNonrealRefExp::pool_size ;
  207062           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealRefExp::pool_size ;
  207063             : 
  207064             : #if FILE_IO_EXTRA_CHECK
  207065             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  207066             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  207067             : #endif
  207068             : 
  207069           0 :           returnPointer = &( ( (SgNonrealRefExp*)(SgNonrealRefExp::pools[memoryBlock]) ) [positionInPool]) ;
  207070             : 
  207071             : #if FILE_IO_EXTRA_CHECK
  207072           0 :           assert ( returnPointer != NULL ) ;
  207073             : #endif
  207074             :         }
  207075           0 :      return returnPointer ;
  207076             :    }
  207077             : 
  207078             : //############################################################################
  207079             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  207080             :  * pool size! We set for every valid object in the memory pool the freepointer
  207081             :  * to the global index and increase the global index afterwards. For all the 
  207082             :  * invalid objects (means address ranges within the memory pool that were not
  207083             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  207084             :  * distinguish valid from invalid objects! 
  207085             :  */
  207086             : unsigned long
  207087           5 : SgNonrealRefExp::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  207088             :    {
  207089           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  207090           5 :      SgNonrealRefExp* pointer = NULL;
  207091           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  207092           5 :      std::vector < unsigned char* > :: const_iterator block;
  207093           6 :      for ( block = SgNonrealRefExp::pools.begin(); block != SgNonrealRefExp::pools.end() ; ++block )
  207094             :         {
  207095           1 :           pointer = (SgNonrealRefExp*)(*block);
  207096        2001 :           for (unsigned i = 0; i < SgNonrealRefExp::pool_size; ++i )
  207097             :              {
  207098             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  207099             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  207100             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  207101             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  207102             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  207103             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  207104             :             // properly; so this will have to be checked next.
  207105             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  207106             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  207107        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  207108             :                   {
  207109        1494 :                     pointer[i].set_freepointer((SgNonrealRefExp*)(globalIndex));
  207110        1494 :                     globalIndex++;
  207111             :                   }
  207112             :                else
  207113             :                   {
  207114         506 :                     pointer[i].set_freepointer(NULL);
  207115             :                   }
  207116             :               }
  207117             :         }
  207118           5 :      return globalIndex;
  207119             :    }
  207120             : 
  207121             : //############################################################################
  207122             : // JH (01/14/2006)
  207123             : void
  207124           5 : SgNonrealRefExp::resetValidFreepointers( )
  207125             :    {
  207126           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  207127           5 :      SgNonrealRefExp* pointer = NULL;
  207128           5 :      std::vector < unsigned char* > :: const_iterator block;
  207129           5 :      SgNonrealRefExp* pointerOfLinkedList = NULL;
  207130           6 :      for ( block = SgNonrealRefExp::pools.begin(); block != SgNonrealRefExp::pools.end() ; ++block )
  207131             :         {
  207132           1 :           pointer = (SgNonrealRefExp*)(*block);
  207133        2001 :           for (unsigned i = 0; i < SgNonrealRefExp::pool_size; ++i )
  207134             :              {
  207135             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  207136             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  207137             :             // memory blocks!.
  207138        2000 :                if ( pointer[i].get_freepointer() != NULL )
  207139             :                   {
  207140        1494 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  207141             :                   }
  207142             :                else
  207143             :                   {
  207144         506 :                     if ( pointerOfLinkedList == NULL )
  207145             :                        {
  207146           1 :                          SgNonrealRefExp::next_node = &(pointer[i]);
  207147             :                        }
  207148             :                     else
  207149             :                        {
  207150             :                       // printf ("In SgNonrealRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  207151         505 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  207152             :                        }
  207153             :                     pointerOfLinkedList = &(pointer[i]);
  207154             :                   }
  207155             :               }
  207156             :         }
  207157             : 
  207158           5 :      if ( pointerOfLinkedList != NULL )
  207159             :         {
  207160             :        // printf ("In SgNonrealRefExp::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  207161           1 :           pointerOfLinkedList->set_freepointer(NULL);
  207162             :        // DQ (6/6/2010): Temporary debugging...
  207163             :        //   ROSE_ASSERT(false);
  207164             :         }
  207165             : 
  207166           5 :      return ;
  207167             :    }
  207168             : 
  207169             : //############################################################################
  207170             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  207171             :  * within the memory pool and resets the freepointers, in order to achieve a 
  207172             :  * linked list, that has no jumps and starts at the beginning! This function 
  207173             :  * does not extend the memory pool, since we do not delete any memory blocks,
  207174             :  * but delete the valid objects.  
  207175             :  */
  207176             : void
  207177           0 : SgNonrealRefExp::clearMemoryPool( )
  207178             :    {
  207179             :   // printf ("Inside of SgNonrealRefExp::clearMemoryPool() \n");
  207180             : 
  207181           0 :      SgNonrealRefExp* pointer = NULL, *tempPointer = NULL;
  207182           0 :      std::vector < unsigned char* > :: const_iterator block;
  207183           0 :      if ( SgNonrealRefExp::pools.empty() == false )
  207184             :         {
  207185           0 :           block = SgNonrealRefExp::pools.begin() ;
  207186           0 :           SgNonrealRefExp::next_node = (SgNonrealRefExp*) (*block);
  207187             : 
  207188           0 :           while ( block != SgNonrealRefExp::pools.end() )
  207189             :              {
  207190           0 :                pointer = (SgNonrealRefExp*) (*block);
  207191           0 :                if ( tempPointer != NULL )
  207192             :                   {
  207193           0 :                     tempPointer->set_freepointer(pointer);
  207194             :                   }
  207195           0 :                for (unsigned i = 0; i < SgNonrealRefExp::pool_size - 1; ++i)
  207196             :                   {
  207197           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  207198             :                   }
  207199           0 :                 pointer[SgNonrealRefExp::pool_size-1].set_freepointer(NULL);
  207200           0 :                 tempPointer = &(pointer[SgNonrealRefExp::pool_size-1]);
  207201           0 :                 ++block;
  207202             :              }
  207203             :         }
  207204           0 :    }
  207205             : 
  207206           5 : void SgNonrealRefExp::deleteMemoryPool() {
  207207           7 :   for (auto p: SgNonrealRefExp::pools) {
  207208           2 :     ROSE_FREE(p);
  207209             :   }
  207210           5 :   SgNonrealRefExp::next_node = nullptr;
  207211           5 :   SgNonrealRefExp::pools.clear();
  207212           5 : }
  207213             : 
  207214             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  207215             : //                 reading multiple binary files to for a single AST.
  207216             : /////////// new version ////////////////////////////////
  207217             : //############################################################################
  207218             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  207219             : void
  207220           2 : SgNonrealRefExp::extendMemoryPoolForFileIO( )
  207221             :   {
  207222           2 :     size_t blockIndex = SgNonrealRefExp::pools.size();
  207223           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealRefExp) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealRefExp);
  207224             : 
  207225           3 :     while ( (blockIndex * SgNonrealRefExp::pool_size) < newPoolSize)
  207226             :       {
  207227             : #if ROSE_ALLOC_TRACE
  207228             :         if (blockIndex > 0) {
  207229             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealRefExp) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealRefExp) = %" PRIuPTR " SgNonrealRefExp::pool_size = %d \n",
  207230             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealRefExp),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealRefExp),SgNonrealRefExp::pool_size);
  207231             :         }
  207232             : #endif
  207233             : 
  207234           1 :         SgNonrealRefExp * pointer = (SgNonrealRefExp*) ROSE_MALLOC ( SgNonrealRefExp::pool_size * sizeof(SgNonrealRefExp) );
  207235           1 :         assert( pointer != NULL );
  207236             : #if ROSE_ALLOC_MEMSET == 1
  207237             :         memset(pointer, 0x00, SgNonrealRefExp::pool_size * sizeof(SgNonrealRefExp));
  207238             : #elif ROSE_ALLOC_MEMSET == 2
  207239             :         memset(pointer, 0xCC, SgNonrealRefExp::pool_size * sizeof(SgNonrealRefExp));
  207240             : #endif
  207241           1 :         SgNonrealRefExp::pools.push_back( (unsigned char*)(pointer) );
  207242           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNonrealRefExp::pool_size * sizeof(SgNonrealRefExp), V_SgNonrealRefExp ) );
  207243             : 
  207244           1 :         if ( SgNonrealRefExp::next_node != NULL ) {
  207245           0 :           if ( blockIndex > 0 ) {
  207246           0 :             SgNonrealRefExp * blkptr = (SgNonrealRefExp*)(SgNonrealRefExp::pools[blockIndex-1]);
  207247           0 :             blkptr[ SgNonrealRefExp::pool_size - 1 ].set_freepointer(pointer);
  207248             :           }
  207249             :         } else {
  207250           1 :           SgNonrealRefExp::next_node = pointer;
  207251             :         }
  207252             : 
  207253        2000 :         for (unsigned i = 0; i < SgNonrealRefExp::pool_size-1; ++i)
  207254             :            {
  207255        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  207256             :            }
  207257           1 :         pointer[ SgNonrealRefExp::pool_size -1 ].set_freepointer(NULL);
  207258             : 
  207259           1 :         blockIndex++;
  207260             :       }
  207261           2 :   }
  207262             : 
  207263             : //############################################################################
  207264             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  207265             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  207266             :  * not compressed. However, that stuff is not yet implemented! 
  207267             :  */
  207268             : unsigned long
  207269           0 : SgNonrealRefExp::getNumberOfLastValidPointer()
  207270             :    {
  207271           0 :       SgNonrealRefExp* testPointer = (SgNonrealRefExp*)(SgNonrealRefExp::pools.back());
  207272           0 :       unsigned long localIndex = SgNonrealRefExp::pool_size - 1;
  207273           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  207274             :          {
  207275           0 :            localIndex--;
  207276             :          }
  207277           0 :       return (localIndex + SgNonrealRefExp::pool_size * (SgNonrealRefExp::pools.size()-1));
  207278             :    }
  207279             : 
  207280             : //############################################################################
  207281             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  207282             :  * memory pool and initializes the data member in class SgNonrealRefExpStroageClass
  207283             :  * from its counterpart of SgNonrealRefExp. The return value is just for checking, 
  207284             :  * that the whole StorageClassArray is initialized!
  207285             :  */
  207286             : unsigned long
  207287           1 : SgNonrealRefExp::initializeStorageClassArray( SgNonrealRefExpStorageClass *storageArray )
  207288             :    {
  207289           1 :      unsigned long storageCounter = 0;
  207290           1 :      std::vector < unsigned char* > :: const_iterator block = SgNonrealRefExp::pools.begin();
  207291           1 :      SgNonrealRefExp* pointer = NULL;
  207292           2 :      while ( block != SgNonrealRefExp::pools.end() ) {
  207293           1 :           pointer = (SgNonrealRefExp*) (*block);
  207294        2001 :           for ( unsigned i = 0; i < SgNonrealRefExp::pool_size; ++i ) {
  207295        2000 :                if ( pointer->get_freepointer() != NULL ) {
  207296        1494 :                  storageArray->pickOutIRNodeData (pointer) ;
  207297        1494 :                  storageArray++;
  207298        1494 :                  storageCounter++;
  207299             :                }
  207300        2000 :                pointer++;
  207301             :              }
  207302           1 :            block++;
  207303             :         }
  207304           1 :      return storageCounter;
  207305             :    }
  207306             : 
  207307             : /* #line 207308 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  207308             : 
  207309             : 
  207310             : 
  207311             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  207312             : 
  207313             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  207314             : 
  207315             : //############################################################################
  207316             : /* JH (02/02/2006) Constructor of the IR node SgFoldExpression that takes its 
  207317             :  * corresponding StorageClass as parameter
  207318             :  */
  207319           0 : SgFoldExpression :: SgFoldExpression ( const SgFoldExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  207320             :    {
  207321             : 
  207322             : 
  207323             : /* #line 207324 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  207324             : 
  207325           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  207326           0 :      p_operands =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_operands) );
  207327           0 :      p_operator_token = storageSource.storageOf_operator_token.rebuildDataStoredInEasyStorageClass() ;
  207328           0 :      p_is_left_associative = storageSource.storageOf_is_left_associative ;
  207329             : 
  207330             : 
  207331             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  207332             : 
  207333             : 
  207334           0 :    }
  207335             : 
  207336             : //############################################################################
  207337             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  207338             :  * within the working AST. 
  207339             :  */
  207340           0 : SgFoldExpression * SgFoldExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  207341           0 :      SgFoldExpression* returnPointer = NULL;
  207342           0 :      if ( globalIndex != 0 )
  207343             :         {
  207344             : 
  207345             : #if FILE_IO_EXTRA_CHECK
  207346           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFoldExpression ) ) <= globalIndex ) ;
  207347           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFoldExpression + 1 ) ) );
  207348             : #endif
  207349           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFoldExpression )  
  207350           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFoldExpression );
  207351           0 :           unsigned long positionInPool = localIndex % SgFoldExpression::pool_size;
  207352           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFoldExpression::pool_size;
  207353             : 
  207354             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  207355             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  207356             : 
  207357           0 :           returnPointer = &( ( (SgFoldExpression*)(SgFoldExpression::pools[memoryBlock]) ) [positionInPool]) ;
  207358             : 
  207359           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  207360             :         }
  207361           0 :      return returnPointer ;
  207362             :    }
  207363             : 
  207364             : //############################################################################
  207365             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  207366             :   for the AST with the index astIndex
  207367             : */
  207368           0 : SgFoldExpression * SgFoldExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  207369           0 :      SgFoldExpression* returnPointer = NULL;
  207370           0 :      if ( globalIndex != 0 )
  207371             :         {
  207372             : 
  207373             : #if FILE_IO_EXTRA_CHECK
  207374           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFoldExpression ) ) <= globalIndex ) ;
  207375           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFoldExpression + 1 ) ) );
  207376             : #endif
  207377           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFoldExpression )
  207378           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFoldExpression );
  207379           0 :           unsigned long positionInPool = localIndex % SgFoldExpression::pool_size ;
  207380           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFoldExpression::pool_size ;
  207381             : 
  207382             : #if FILE_IO_EXTRA_CHECK
  207383             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  207384             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  207385             : #endif
  207386             : 
  207387           0 :           returnPointer = &( ( (SgFoldExpression*)(SgFoldExpression::pools[memoryBlock]) ) [positionInPool]) ;
  207388             : 
  207389             : #if FILE_IO_EXTRA_CHECK
  207390           0 :           assert ( returnPointer != NULL ) ;
  207391             : #endif
  207392             :         }
  207393           0 :      return returnPointer ;
  207394             :    }
  207395             : 
  207396             : //############################################################################
  207397             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  207398             :  * pool size! We set for every valid object in the memory pool the freepointer
  207399             :  * to the global index and increase the global index afterwards. For all the 
  207400             :  * invalid objects (means address ranges within the memory pool that were not
  207401             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  207402             :  * distinguish valid from invalid objects! 
  207403             :  */
  207404             : unsigned long
  207405           5 : SgFoldExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  207406             :    {
  207407           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  207408           5 :      SgFoldExpression* pointer = NULL;
  207409           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  207410           5 :      std::vector < unsigned char* > :: const_iterator block;
  207411           5 :      for ( block = SgFoldExpression::pools.begin(); block != SgFoldExpression::pools.end() ; ++block )
  207412             :         {
  207413           0 :           pointer = (SgFoldExpression*)(*block);
  207414           0 :           for (unsigned i = 0; i < SgFoldExpression::pool_size; ++i )
  207415             :              {
  207416             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  207417             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  207418             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  207419             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  207420             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  207421             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  207422             :             // properly; so this will have to be checked next.
  207423             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  207424             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  207425           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  207426             :                   {
  207427           0 :                     pointer[i].set_freepointer((SgFoldExpression*)(globalIndex));
  207428           0 :                     globalIndex++;
  207429             :                   }
  207430             :                else
  207431             :                   {
  207432           0 :                     pointer[i].set_freepointer(NULL);
  207433             :                   }
  207434             :               }
  207435             :         }
  207436           5 :      return globalIndex;
  207437             :    }
  207438             : 
  207439             : //############################################################################
  207440             : // JH (01/14/2006)
  207441             : void
  207442           5 : SgFoldExpression::resetValidFreepointers( )
  207443             :    {
  207444           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  207445           5 :      SgFoldExpression* pointer = NULL;
  207446           5 :      std::vector < unsigned char* > :: const_iterator block;
  207447           5 :      SgFoldExpression* pointerOfLinkedList = NULL;
  207448           5 :      for ( block = SgFoldExpression::pools.begin(); block != SgFoldExpression::pools.end() ; ++block )
  207449             :         {
  207450           0 :           pointer = (SgFoldExpression*)(*block);
  207451           0 :           for (unsigned i = 0; i < SgFoldExpression::pool_size; ++i )
  207452             :              {
  207453             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  207454             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  207455             :             // memory blocks!.
  207456           0 :                if ( pointer[i].get_freepointer() != NULL )
  207457             :                   {
  207458           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  207459             :                   }
  207460             :                else
  207461             :                   {
  207462           0 :                     if ( pointerOfLinkedList == NULL )
  207463             :                        {
  207464           0 :                          SgFoldExpression::next_node = &(pointer[i]);
  207465             :                        }
  207466             :                     else
  207467             :                        {
  207468             :                       // printf ("In SgFoldExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  207469           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  207470             :                        }
  207471             :                     pointerOfLinkedList = &(pointer[i]);
  207472             :                   }
  207473             :               }
  207474             :         }
  207475             : 
  207476           5 :      if ( pointerOfLinkedList != NULL )
  207477             :         {
  207478             :        // printf ("In SgFoldExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  207479           0 :           pointerOfLinkedList->set_freepointer(NULL);
  207480             :        // DQ (6/6/2010): Temporary debugging...
  207481             :        //   ROSE_ASSERT(false);
  207482             :         }
  207483             : 
  207484           5 :      return ;
  207485             :    }
  207486             : 
  207487             : //############################################################################
  207488             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  207489             :  * within the memory pool and resets the freepointers, in order to achieve a 
  207490             :  * linked list, that has no jumps and starts at the beginning! This function 
  207491             :  * does not extend the memory pool, since we do not delete any memory blocks,
  207492             :  * but delete the valid objects.  
  207493             :  */
  207494             : void
  207495           0 : SgFoldExpression::clearMemoryPool( )
  207496             :    {
  207497             :   // printf ("Inside of SgFoldExpression::clearMemoryPool() \n");
  207498             : 
  207499           0 :      SgFoldExpression* pointer = NULL, *tempPointer = NULL;
  207500           0 :      std::vector < unsigned char* > :: const_iterator block;
  207501           0 :      if ( SgFoldExpression::pools.empty() == false )
  207502             :         {
  207503           0 :           block = SgFoldExpression::pools.begin() ;
  207504           0 :           SgFoldExpression::next_node = (SgFoldExpression*) (*block);
  207505             : 
  207506           0 :           while ( block != SgFoldExpression::pools.end() )
  207507             :              {
  207508           0 :                pointer = (SgFoldExpression*) (*block);
  207509           0 :                if ( tempPointer != NULL )
  207510             :                   {
  207511           0 :                     tempPointer->set_freepointer(pointer);
  207512             :                   }
  207513           0 :                for (unsigned i = 0; i < SgFoldExpression::pool_size - 1; ++i)
  207514             :                   {
  207515           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  207516             :                   }
  207517           0 :                 pointer[SgFoldExpression::pool_size-1].set_freepointer(NULL);
  207518           0 :                 tempPointer = &(pointer[SgFoldExpression::pool_size-1]);
  207519           0 :                 ++block;
  207520             :              }
  207521             :         }
  207522           0 :    }
  207523             : 
  207524           5 : void SgFoldExpression::deleteMemoryPool() {
  207525           5 :   for (auto p: SgFoldExpression::pools) {
  207526           0 :     ROSE_FREE(p);
  207527             :   }
  207528           5 :   SgFoldExpression::next_node = nullptr;
  207529           5 :   SgFoldExpression::pools.clear();
  207530           5 : }
  207531             : 
  207532             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  207533             : //                 reading multiple binary files to for a single AST.
  207534             : /////////// new version ////////////////////////////////
  207535             : //############################################################################
  207536             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  207537             : void
  207538           2 : SgFoldExpression::extendMemoryPoolForFileIO( )
  207539             :   {
  207540           2 :     size_t blockIndex = SgFoldExpression::pools.size();
  207541           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFoldExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFoldExpression);
  207542             : 
  207543           2 :     while ( (blockIndex * SgFoldExpression::pool_size) < newPoolSize)
  207544             :       {
  207545             : #if ROSE_ALLOC_TRACE
  207546             :         if (blockIndex > 0) {
  207547             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFoldExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFoldExpression) = %" PRIuPTR " SgFoldExpression::pool_size = %d \n",
  207548             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFoldExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFoldExpression),SgFoldExpression::pool_size);
  207549             :         }
  207550             : #endif
  207551             : 
  207552           0 :         SgFoldExpression * pointer = (SgFoldExpression*) ROSE_MALLOC ( SgFoldExpression::pool_size * sizeof(SgFoldExpression) );
  207553           0 :         assert( pointer != NULL );
  207554             : #if ROSE_ALLOC_MEMSET == 1
  207555             :         memset(pointer, 0x00, SgFoldExpression::pool_size * sizeof(SgFoldExpression));
  207556             : #elif ROSE_ALLOC_MEMSET == 2
  207557             :         memset(pointer, 0xCC, SgFoldExpression::pool_size * sizeof(SgFoldExpression));
  207558             : #endif
  207559           0 :         SgFoldExpression::pools.push_back( (unsigned char*)(pointer) );
  207560           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFoldExpression::pool_size * sizeof(SgFoldExpression), V_SgFoldExpression ) );
  207561             : 
  207562           0 :         if ( SgFoldExpression::next_node != NULL ) {
  207563           0 :           if ( blockIndex > 0 ) {
  207564           0 :             SgFoldExpression * blkptr = (SgFoldExpression*)(SgFoldExpression::pools[blockIndex-1]);
  207565           0 :             blkptr[ SgFoldExpression::pool_size - 1 ].set_freepointer(pointer);
  207566             :           }
  207567             :         } else {
  207568           0 :           SgFoldExpression::next_node = pointer;
  207569             :         }
  207570             : 
  207571           0 :         for (unsigned i = 0; i < SgFoldExpression::pool_size-1; ++i)
  207572             :            {
  207573           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  207574             :            }
  207575           0 :         pointer[ SgFoldExpression::pool_size -1 ].set_freepointer(NULL);
  207576             : 
  207577           0 :         blockIndex++;
  207578             :       }
  207579           2 :   }
  207580             : 
  207581             : //############################################################################
  207582             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  207583             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  207584             :  * not compressed. However, that stuff is not yet implemented! 
  207585             :  */
  207586             : unsigned long
  207587           0 : SgFoldExpression::getNumberOfLastValidPointer()
  207588             :    {
  207589           0 :       SgFoldExpression* testPointer = (SgFoldExpression*)(SgFoldExpression::pools.back());
  207590           0 :       unsigned long localIndex = SgFoldExpression::pool_size - 1;
  207591           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  207592             :          {
  207593           0 :            localIndex--;
  207594             :          }
  207595           0 :       return (localIndex + SgFoldExpression::pool_size * (SgFoldExpression::pools.size()-1));
  207596             :    }
  207597             : 
  207598             : //############################################################################
  207599             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  207600             :  * memory pool and initializes the data member in class SgFoldExpressionStroageClass
  207601             :  * from its counterpart of SgFoldExpression. The return value is just for checking, 
  207602             :  * that the whole StorageClassArray is initialized!
  207603             :  */
  207604             : unsigned long
  207605           0 : SgFoldExpression::initializeStorageClassArray( SgFoldExpressionStorageClass *storageArray )
  207606             :    {
  207607           0 :      unsigned long storageCounter = 0;
  207608           0 :      std::vector < unsigned char* > :: const_iterator block = SgFoldExpression::pools.begin();
  207609           0 :      SgFoldExpression* pointer = NULL;
  207610           0 :      while ( block != SgFoldExpression::pools.end() ) {
  207611           0 :           pointer = (SgFoldExpression*) (*block);
  207612           0 :           for ( unsigned i = 0; i < SgFoldExpression::pool_size; ++i ) {
  207613           0 :                if ( pointer->get_freepointer() != NULL ) {
  207614           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  207615           0 :                  storageArray++;
  207616           0 :                  storageCounter++;
  207617             :                }
  207618           0 :                pointer++;
  207619             :              }
  207620           0 :            block++;
  207621             :         }
  207622           0 :      return storageCounter;
  207623             :    }
  207624             : 
  207625             : /* #line 207626 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  207626             : 
  207627             : 
  207628             : 
  207629             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  207630             : 
  207631             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  207632             : 
  207633             : //############################################################################
  207634             : /* JH (02/02/2006) Constructor of the IR node SgAwaitExpression that takes its 
  207635             :  * corresponding StorageClass as parameter
  207636             :  */
  207637           0 : SgAwaitExpression :: SgAwaitExpression ( const SgAwaitExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  207638             :    {
  207639             : 
  207640             : 
  207641             : /* #line 207642 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  207642             : 
  207643           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  207644           0 :      p_value =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_value) );
  207645             : 
  207646             : 
  207647             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  207648             : 
  207649             : 
  207650           0 :    }
  207651             : 
  207652             : //############################################################################
  207653             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  207654             :  * within the working AST. 
  207655             :  */
  207656           0 : SgAwaitExpression * SgAwaitExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  207657           0 :      SgAwaitExpression* returnPointer = NULL;
  207658           0 :      if ( globalIndex != 0 )
  207659             :         {
  207660             : 
  207661             : #if FILE_IO_EXTRA_CHECK
  207662           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAwaitExpression ) ) <= globalIndex ) ;
  207663           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAwaitExpression + 1 ) ) );
  207664             : #endif
  207665           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAwaitExpression )  
  207666           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAwaitExpression );
  207667           0 :           unsigned long positionInPool = localIndex % SgAwaitExpression::pool_size;
  207668           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAwaitExpression::pool_size;
  207669             : 
  207670             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  207671             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  207672             : 
  207673           0 :           returnPointer = &( ( (SgAwaitExpression*)(SgAwaitExpression::pools[memoryBlock]) ) [positionInPool]) ;
  207674             : 
  207675           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  207676             :         }
  207677           0 :      return returnPointer ;
  207678             :    }
  207679             : 
  207680             : //############################################################################
  207681             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  207682             :   for the AST with the index astIndex
  207683             : */
  207684           0 : SgAwaitExpression * SgAwaitExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  207685           0 :      SgAwaitExpression* returnPointer = NULL;
  207686           0 :      if ( globalIndex != 0 )
  207687             :         {
  207688             : 
  207689             : #if FILE_IO_EXTRA_CHECK
  207690           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAwaitExpression ) ) <= globalIndex ) ;
  207691           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAwaitExpression + 1 ) ) );
  207692             : #endif
  207693           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAwaitExpression )
  207694           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAwaitExpression );
  207695           0 :           unsigned long positionInPool = localIndex % SgAwaitExpression::pool_size ;
  207696           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAwaitExpression::pool_size ;
  207697             : 
  207698             : #if FILE_IO_EXTRA_CHECK
  207699             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  207700             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  207701             : #endif
  207702             : 
  207703           0 :           returnPointer = &( ( (SgAwaitExpression*)(SgAwaitExpression::pools[memoryBlock]) ) [positionInPool]) ;
  207704             : 
  207705             : #if FILE_IO_EXTRA_CHECK
  207706           0 :           assert ( returnPointer != NULL ) ;
  207707             : #endif
  207708             :         }
  207709           0 :      return returnPointer ;
  207710             :    }
  207711             : 
  207712             : //############################################################################
  207713             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  207714             :  * pool size! We set for every valid object in the memory pool the freepointer
  207715             :  * to the global index and increase the global index afterwards. For all the 
  207716             :  * invalid objects (means address ranges within the memory pool that were not
  207717             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  207718             :  * distinguish valid from invalid objects! 
  207719             :  */
  207720             : unsigned long
  207721           5 : SgAwaitExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  207722             :    {
  207723           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  207724           5 :      SgAwaitExpression* pointer = NULL;
  207725           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  207726           5 :      std::vector < unsigned char* > :: const_iterator block;
  207727           5 :      for ( block = SgAwaitExpression::pools.begin(); block != SgAwaitExpression::pools.end() ; ++block )
  207728             :         {
  207729           0 :           pointer = (SgAwaitExpression*)(*block);
  207730           0 :           for (unsigned i = 0; i < SgAwaitExpression::pool_size; ++i )
  207731             :              {
  207732             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  207733             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  207734             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  207735             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  207736             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  207737             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  207738             :             // properly; so this will have to be checked next.
  207739             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  207740             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  207741           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  207742             :                   {
  207743           0 :                     pointer[i].set_freepointer((SgAwaitExpression*)(globalIndex));
  207744           0 :                     globalIndex++;
  207745             :                   }
  207746             :                else
  207747             :                   {
  207748           0 :                     pointer[i].set_freepointer(NULL);
  207749             :                   }
  207750             :               }
  207751             :         }
  207752           5 :      return globalIndex;
  207753             :    }
  207754             : 
  207755             : //############################################################################
  207756             : // JH (01/14/2006)
  207757             : void
  207758           5 : SgAwaitExpression::resetValidFreepointers( )
  207759             :    {
  207760           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  207761           5 :      SgAwaitExpression* pointer = NULL;
  207762           5 :      std::vector < unsigned char* > :: const_iterator block;
  207763           5 :      SgAwaitExpression* pointerOfLinkedList = NULL;
  207764           5 :      for ( block = SgAwaitExpression::pools.begin(); block != SgAwaitExpression::pools.end() ; ++block )
  207765             :         {
  207766           0 :           pointer = (SgAwaitExpression*)(*block);
  207767           0 :           for (unsigned i = 0; i < SgAwaitExpression::pool_size; ++i )
  207768             :              {
  207769             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  207770             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  207771             :             // memory blocks!.
  207772           0 :                if ( pointer[i].get_freepointer() != NULL )
  207773             :                   {
  207774           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  207775             :                   }
  207776             :                else
  207777             :                   {
  207778           0 :                     if ( pointerOfLinkedList == NULL )
  207779             :                        {
  207780           0 :                          SgAwaitExpression::next_node = &(pointer[i]);
  207781             :                        }
  207782             :                     else
  207783             :                        {
  207784             :                       // printf ("In SgAwaitExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  207785           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  207786             :                        }
  207787             :                     pointerOfLinkedList = &(pointer[i]);
  207788             :                   }
  207789             :               }
  207790             :         }
  207791             : 
  207792           5 :      if ( pointerOfLinkedList != NULL )
  207793             :         {
  207794             :        // printf ("In SgAwaitExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  207795           0 :           pointerOfLinkedList->set_freepointer(NULL);
  207796             :        // DQ (6/6/2010): Temporary debugging...
  207797             :        //   ROSE_ASSERT(false);
  207798             :         }
  207799             : 
  207800           5 :      return ;
  207801             :    }
  207802             : 
  207803             : //############################################################################
  207804             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  207805             :  * within the memory pool and resets the freepointers, in order to achieve a 
  207806             :  * linked list, that has no jumps and starts at the beginning! This function 
  207807             :  * does not extend the memory pool, since we do not delete any memory blocks,
  207808             :  * but delete the valid objects.  
  207809             :  */
  207810             : void
  207811           0 : SgAwaitExpression::clearMemoryPool( )
  207812             :    {
  207813             :   // printf ("Inside of SgAwaitExpression::clearMemoryPool() \n");
  207814             : 
  207815           0 :      SgAwaitExpression* pointer = NULL, *tempPointer = NULL;
  207816           0 :      std::vector < unsigned char* > :: const_iterator block;
  207817           0 :      if ( SgAwaitExpression::pools.empty() == false )
  207818             :         {
  207819           0 :           block = SgAwaitExpression::pools.begin() ;
  207820           0 :           SgAwaitExpression::next_node = (SgAwaitExpression*) (*block);
  207821             : 
  207822           0 :           while ( block != SgAwaitExpression::pools.end() )
  207823             :              {
  207824           0 :                pointer = (SgAwaitExpression*) (*block);
  207825           0 :                if ( tempPointer != NULL )
  207826             :                   {
  207827           0 :                     tempPointer->set_freepointer(pointer);
  207828             :                   }
  207829           0 :                for (unsigned i = 0; i < SgAwaitExpression::pool_size - 1; ++i)
  207830             :                   {
  207831           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  207832             :                   }
  207833           0 :                 pointer[SgAwaitExpression::pool_size-1].set_freepointer(NULL);
  207834           0 :                 tempPointer = &(pointer[SgAwaitExpression::pool_size-1]);
  207835           0 :                 ++block;
  207836             :              }
  207837             :         }
  207838           0 :    }
  207839             : 
  207840           5 : void SgAwaitExpression::deleteMemoryPool() {
  207841           5 :   for (auto p: SgAwaitExpression::pools) {
  207842           0 :     ROSE_FREE(p);
  207843             :   }
  207844           5 :   SgAwaitExpression::next_node = nullptr;
  207845           5 :   SgAwaitExpression::pools.clear();
  207846           5 : }
  207847             : 
  207848             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  207849             : //                 reading multiple binary files to for a single AST.
  207850             : /////////// new version ////////////////////////////////
  207851             : //############################################################################
  207852             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  207853             : void
  207854           2 : SgAwaitExpression::extendMemoryPoolForFileIO( )
  207855             :   {
  207856           2 :     size_t blockIndex = SgAwaitExpression::pools.size();
  207857           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAwaitExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAwaitExpression);
  207858             : 
  207859           2 :     while ( (blockIndex * SgAwaitExpression::pool_size) < newPoolSize)
  207860             :       {
  207861             : #if ROSE_ALLOC_TRACE
  207862             :         if (blockIndex > 0) {
  207863             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAwaitExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAwaitExpression) = %" PRIuPTR " SgAwaitExpression::pool_size = %d \n",
  207864             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAwaitExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAwaitExpression),SgAwaitExpression::pool_size);
  207865             :         }
  207866             : #endif
  207867             : 
  207868           0 :         SgAwaitExpression * pointer = (SgAwaitExpression*) ROSE_MALLOC ( SgAwaitExpression::pool_size * sizeof(SgAwaitExpression) );
  207869           0 :         assert( pointer != NULL );
  207870             : #if ROSE_ALLOC_MEMSET == 1
  207871             :         memset(pointer, 0x00, SgAwaitExpression::pool_size * sizeof(SgAwaitExpression));
  207872             : #elif ROSE_ALLOC_MEMSET == 2
  207873             :         memset(pointer, 0xCC, SgAwaitExpression::pool_size * sizeof(SgAwaitExpression));
  207874             : #endif
  207875           0 :         SgAwaitExpression::pools.push_back( (unsigned char*)(pointer) );
  207876           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAwaitExpression::pool_size * sizeof(SgAwaitExpression), V_SgAwaitExpression ) );
  207877             : 
  207878           0 :         if ( SgAwaitExpression::next_node != NULL ) {
  207879           0 :           if ( blockIndex > 0 ) {
  207880           0 :             SgAwaitExpression * blkptr = (SgAwaitExpression*)(SgAwaitExpression::pools[blockIndex-1]);
  207881           0 :             blkptr[ SgAwaitExpression::pool_size - 1 ].set_freepointer(pointer);
  207882             :           }
  207883             :         } else {
  207884           0 :           SgAwaitExpression::next_node = pointer;
  207885             :         }
  207886             : 
  207887           0 :         for (unsigned i = 0; i < SgAwaitExpression::pool_size-1; ++i)
  207888             :            {
  207889           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  207890             :            }
  207891           0 :         pointer[ SgAwaitExpression::pool_size -1 ].set_freepointer(NULL);
  207892             : 
  207893           0 :         blockIndex++;
  207894             :       }
  207895           2 :   }
  207896             : 
  207897             : //############################################################################
  207898             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  207899             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  207900             :  * not compressed. However, that stuff is not yet implemented! 
  207901             :  */
  207902             : unsigned long
  207903           0 : SgAwaitExpression::getNumberOfLastValidPointer()
  207904             :    {
  207905           0 :       SgAwaitExpression* testPointer = (SgAwaitExpression*)(SgAwaitExpression::pools.back());
  207906           0 :       unsigned long localIndex = SgAwaitExpression::pool_size - 1;
  207907           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  207908             :          {
  207909           0 :            localIndex--;
  207910             :          }
  207911           0 :       return (localIndex + SgAwaitExpression::pool_size * (SgAwaitExpression::pools.size()-1));
  207912             :    }
  207913             : 
  207914             : //############################################################################
  207915             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  207916             :  * memory pool and initializes the data member in class SgAwaitExpressionStroageClass
  207917             :  * from its counterpart of SgAwaitExpression. The return value is just for checking, 
  207918             :  * that the whole StorageClassArray is initialized!
  207919             :  */
  207920             : unsigned long
  207921           0 : SgAwaitExpression::initializeStorageClassArray( SgAwaitExpressionStorageClass *storageArray )
  207922             :    {
  207923           0 :      unsigned long storageCounter = 0;
  207924           0 :      std::vector < unsigned char* > :: const_iterator block = SgAwaitExpression::pools.begin();
  207925           0 :      SgAwaitExpression* pointer = NULL;
  207926           0 :      while ( block != SgAwaitExpression::pools.end() ) {
  207927           0 :           pointer = (SgAwaitExpression*) (*block);
  207928           0 :           for ( unsigned i = 0; i < SgAwaitExpression::pool_size; ++i ) {
  207929           0 :                if ( pointer->get_freepointer() != NULL ) {
  207930           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  207931           0 :                  storageArray++;
  207932           0 :                  storageCounter++;
  207933             :                }
  207934           0 :                pointer++;
  207935             :              }
  207936           0 :            block++;
  207937             :         }
  207938           0 :      return storageCounter;
  207939             :    }
  207940             : 
  207941             : /* #line 207942 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  207942             : 
  207943             : 
  207944             : 
  207945             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  207946             : 
  207947             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  207948             : 
  207949             : //############################################################################
  207950             : /* JH (02/02/2006) Constructor of the IR node SgChooseExpression that takes its 
  207951             :  * corresponding StorageClass as parameter
  207952             :  */
  207953           0 : SgChooseExpression :: SgChooseExpression ( const SgChooseExpressionStorageClass& storageSource )   : SgExpression (storageSource)
  207954             :    {
  207955             : 
  207956             : 
  207957             : /* #line 207958 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  207958             : 
  207959           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  207960           0 :      p_value =  (SgExpression*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_value) );
  207961             : 
  207962             : 
  207963             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  207964             : 
  207965             : 
  207966           0 :    }
  207967             : 
  207968             : //############################################################################
  207969             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  207970             :  * within the working AST. 
  207971             :  */
  207972           0 : SgChooseExpression * SgChooseExpression::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  207973           0 :      SgChooseExpression* returnPointer = NULL;
  207974           0 :      if ( globalIndex != 0 )
  207975             :         {
  207976             : 
  207977             : #if FILE_IO_EXTRA_CHECK
  207978           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgChooseExpression ) ) <= globalIndex ) ;
  207979           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgChooseExpression + 1 ) ) );
  207980             : #endif
  207981           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgChooseExpression )  
  207982           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgChooseExpression );
  207983           0 :           unsigned long positionInPool = localIndex % SgChooseExpression::pool_size;
  207984           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgChooseExpression::pool_size;
  207985             : 
  207986             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  207987             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  207988             : 
  207989           0 :           returnPointer = &( ( (SgChooseExpression*)(SgChooseExpression::pools[memoryBlock]) ) [positionInPool]) ;
  207990             : 
  207991           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  207992             :         }
  207993           0 :      return returnPointer ;
  207994             :    }
  207995             : 
  207996             : //############################################################################
  207997             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  207998             :   for the AST with the index astIndex
  207999             : */
  208000           0 : SgChooseExpression * SgChooseExpression::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  208001           0 :      SgChooseExpression* returnPointer = NULL;
  208002           0 :      if ( globalIndex != 0 )
  208003             :         {
  208004             : 
  208005             : #if FILE_IO_EXTRA_CHECK
  208006           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgChooseExpression ) ) <= globalIndex ) ;
  208007           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgChooseExpression + 1 ) ) );
  208008             : #endif
  208009           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgChooseExpression )
  208010           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgChooseExpression );
  208011           0 :           unsigned long positionInPool = localIndex % SgChooseExpression::pool_size ;
  208012           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgChooseExpression::pool_size ;
  208013             : 
  208014             : #if FILE_IO_EXTRA_CHECK
  208015             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  208016             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  208017             : #endif
  208018             : 
  208019           0 :           returnPointer = &( ( (SgChooseExpression*)(SgChooseExpression::pools[memoryBlock]) ) [positionInPool]) ;
  208020             : 
  208021             : #if FILE_IO_EXTRA_CHECK
  208022           0 :           assert ( returnPointer != NULL ) ;
  208023             : #endif
  208024             :         }
  208025           0 :      return returnPointer ;
  208026             :    }
  208027             : 
  208028             : //############################################################################
  208029             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  208030             :  * pool size! We set for every valid object in the memory pool the freepointer
  208031             :  * to the global index and increase the global index afterwards. For all the 
  208032             :  * invalid objects (means address ranges within the memory pool that were not
  208033             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  208034             :  * distinguish valid from invalid objects! 
  208035             :  */
  208036             : unsigned long
  208037           5 : SgChooseExpression::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  208038             :    {
  208039           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  208040           5 :      SgChooseExpression* pointer = NULL;
  208041           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  208042           5 :      std::vector < unsigned char* > :: const_iterator block;
  208043           5 :      for ( block = SgChooseExpression::pools.begin(); block != SgChooseExpression::pools.end() ; ++block )
  208044             :         {
  208045           0 :           pointer = (SgChooseExpression*)(*block);
  208046           0 :           for (unsigned i = 0; i < SgChooseExpression::pool_size; ++i )
  208047             :              {
  208048             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  208049             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  208050             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  208051             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  208052             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  208053             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  208054             :             // properly; so this will have to be checked next.
  208055             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  208056             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  208057           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  208058             :                   {
  208059           0 :                     pointer[i].set_freepointer((SgChooseExpression*)(globalIndex));
  208060           0 :                     globalIndex++;
  208061             :                   }
  208062             :                else
  208063             :                   {
  208064           0 :                     pointer[i].set_freepointer(NULL);
  208065             :                   }
  208066             :               }
  208067             :         }
  208068           5 :      return globalIndex;
  208069             :    }
  208070             : 
  208071             : //############################################################################
  208072             : // JH (01/14/2006)
  208073             : void
  208074           5 : SgChooseExpression::resetValidFreepointers( )
  208075             :    {
  208076           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  208077           5 :      SgChooseExpression* pointer = NULL;
  208078           5 :      std::vector < unsigned char* > :: const_iterator block;
  208079           5 :      SgChooseExpression* pointerOfLinkedList = NULL;
  208080           5 :      for ( block = SgChooseExpression::pools.begin(); block != SgChooseExpression::pools.end() ; ++block )
  208081             :         {
  208082           0 :           pointer = (SgChooseExpression*)(*block);
  208083           0 :           for (unsigned i = 0; i < SgChooseExpression::pool_size; ++i )
  208084             :              {
  208085             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  208086             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  208087             :             // memory blocks!.
  208088           0 :                if ( pointer[i].get_freepointer() != NULL )
  208089             :                   {
  208090           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  208091             :                   }
  208092             :                else
  208093             :                   {
  208094           0 :                     if ( pointerOfLinkedList == NULL )
  208095             :                        {
  208096           0 :                          SgChooseExpression::next_node = &(pointer[i]);
  208097             :                        }
  208098             :                     else
  208099             :                        {
  208100             :                       // printf ("In SgChooseExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  208101           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  208102             :                        }
  208103             :                     pointerOfLinkedList = &(pointer[i]);
  208104             :                   }
  208105             :               }
  208106             :         }
  208107             : 
  208108           5 :      if ( pointerOfLinkedList != NULL )
  208109             :         {
  208110             :        // printf ("In SgChooseExpression::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  208111           0 :           pointerOfLinkedList->set_freepointer(NULL);
  208112             :        // DQ (6/6/2010): Temporary debugging...
  208113             :        //   ROSE_ASSERT(false);
  208114             :         }
  208115             : 
  208116           5 :      return ;
  208117             :    }
  208118             : 
  208119             : //############################################################################
  208120             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  208121             :  * within the memory pool and resets the freepointers, in order to achieve a 
  208122             :  * linked list, that has no jumps and starts at the beginning! This function 
  208123             :  * does not extend the memory pool, since we do not delete any memory blocks,
  208124             :  * but delete the valid objects.  
  208125             :  */
  208126             : void
  208127           0 : SgChooseExpression::clearMemoryPool( )
  208128             :    {
  208129             :   // printf ("Inside of SgChooseExpression::clearMemoryPool() \n");
  208130             : 
  208131           0 :      SgChooseExpression* pointer = NULL, *tempPointer = NULL;
  208132           0 :      std::vector < unsigned char* > :: const_iterator block;
  208133           0 :      if ( SgChooseExpression::pools.empty() == false )
  208134             :         {
  208135           0 :           block = SgChooseExpression::pools.begin() ;
  208136           0 :           SgChooseExpression::next_node = (SgChooseExpression*) (*block);
  208137             : 
  208138           0 :           while ( block != SgChooseExpression::pools.end() )
  208139             :              {
  208140           0 :                pointer = (SgChooseExpression*) (*block);
  208141           0 :                if ( tempPointer != NULL )
  208142             :                   {
  208143           0 :                     tempPointer->set_freepointer(pointer);
  208144             :                   }
  208145           0 :                for (unsigned i = 0; i < SgChooseExpression::pool_size - 1; ++i)
  208146             :                   {
  208147           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  208148             :                   }
  208149           0 :                 pointer[SgChooseExpression::pool_size-1].set_freepointer(NULL);
  208150           0 :                 tempPointer = &(pointer[SgChooseExpression::pool_size-1]);
  208151           0 :                 ++block;
  208152             :              }
  208153             :         }
  208154           0 :    }
  208155             : 
  208156           5 : void SgChooseExpression::deleteMemoryPool() {
  208157           5 :   for (auto p: SgChooseExpression::pools) {
  208158           0 :     ROSE_FREE(p);
  208159             :   }
  208160           5 :   SgChooseExpression::next_node = nullptr;
  208161           5 :   SgChooseExpression::pools.clear();
  208162           5 : }
  208163             : 
  208164             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  208165             : //                 reading multiple binary files to for a single AST.
  208166             : /////////// new version ////////////////////////////////
  208167             : //############################################################################
  208168             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  208169             : void
  208170           2 : SgChooseExpression::extendMemoryPoolForFileIO( )
  208171             :   {
  208172           2 :     size_t blockIndex = SgChooseExpression::pools.size();
  208173           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgChooseExpression) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgChooseExpression);
  208174             : 
  208175           2 :     while ( (blockIndex * SgChooseExpression::pool_size) < newPoolSize)
  208176             :       {
  208177             : #if ROSE_ALLOC_TRACE
  208178             :         if (blockIndex > 0) {
  208179             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgChooseExpression) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgChooseExpression) = %" PRIuPTR " SgChooseExpression::pool_size = %d \n",
  208180             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgChooseExpression),AST_FILE_IO::getPoolSizeOfNewAst(V_SgChooseExpression),SgChooseExpression::pool_size);
  208181             :         }
  208182             : #endif
  208183             : 
  208184           0 :         SgChooseExpression * pointer = (SgChooseExpression*) ROSE_MALLOC ( SgChooseExpression::pool_size * sizeof(SgChooseExpression) );
  208185           0 :         assert( pointer != NULL );
  208186             : #if ROSE_ALLOC_MEMSET == 1
  208187             :         memset(pointer, 0x00, SgChooseExpression::pool_size * sizeof(SgChooseExpression));
  208188             : #elif ROSE_ALLOC_MEMSET == 2
  208189             :         memset(pointer, 0xCC, SgChooseExpression::pool_size * sizeof(SgChooseExpression));
  208190             : #endif
  208191           0 :         SgChooseExpression::pools.push_back( (unsigned char*)(pointer) );
  208192           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgChooseExpression::pool_size * sizeof(SgChooseExpression), V_SgChooseExpression ) );
  208193             : 
  208194           0 :         if ( SgChooseExpression::next_node != NULL ) {
  208195           0 :           if ( blockIndex > 0 ) {
  208196           0 :             SgChooseExpression * blkptr = (SgChooseExpression*)(SgChooseExpression::pools[blockIndex-1]);
  208197           0 :             blkptr[ SgChooseExpression::pool_size - 1 ].set_freepointer(pointer);
  208198             :           }
  208199             :         } else {
  208200           0 :           SgChooseExpression::next_node = pointer;
  208201             :         }
  208202             : 
  208203           0 :         for (unsigned i = 0; i < SgChooseExpression::pool_size-1; ++i)
  208204             :            {
  208205           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  208206             :            }
  208207           0 :         pointer[ SgChooseExpression::pool_size -1 ].set_freepointer(NULL);
  208208             : 
  208209           0 :         blockIndex++;
  208210             :       }
  208211           2 :   }
  208212             : 
  208213             : //############################################################################
  208214             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  208215             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  208216             :  * not compressed. However, that stuff is not yet implemented! 
  208217             :  */
  208218             : unsigned long
  208219           0 : SgChooseExpression::getNumberOfLastValidPointer()
  208220             :    {
  208221           0 :       SgChooseExpression* testPointer = (SgChooseExpression*)(SgChooseExpression::pools.back());
  208222           0 :       unsigned long localIndex = SgChooseExpression::pool_size - 1;
  208223           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  208224             :          {
  208225           0 :            localIndex--;
  208226             :          }
  208227           0 :       return (localIndex + SgChooseExpression::pool_size * (SgChooseExpression::pools.size()-1));
  208228             :    }
  208229             : 
  208230             : //############################################################################
  208231             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  208232             :  * memory pool and initializes the data member in class SgChooseExpressionStroageClass
  208233             :  * from its counterpart of SgChooseExpression. The return value is just for checking, 
  208234             :  * that the whole StorageClassArray is initialized!
  208235             :  */
  208236             : unsigned long
  208237           0 : SgChooseExpression::initializeStorageClassArray( SgChooseExpressionStorageClass *storageArray )
  208238             :    {
  208239           0 :      unsigned long storageCounter = 0;
  208240           0 :      std::vector < unsigned char* > :: const_iterator block = SgChooseExpression::pools.begin();
  208241           0 :      SgChooseExpression* pointer = NULL;
  208242           0 :      while ( block != SgChooseExpression::pools.end() ) {
  208243           0 :           pointer = (SgChooseExpression*) (*block);
  208244           0 :           for ( unsigned i = 0; i < SgChooseExpression::pool_size; ++i ) {
  208245           0 :                if ( pointer->get_freepointer() != NULL ) {
  208246           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  208247           0 :                  storageArray++;
  208248           0 :                  storageCounter++;
  208249             :                }
  208250           0 :                pointer++;
  208251             :              }
  208252           0 :            block++;
  208253             :         }
  208254           0 :      return storageCounter;
  208255             :    }
  208256             : 
  208257             : /* #line 208258 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  208258             : 
  208259             : 
  208260             : 
  208261             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  208262             : 
  208263             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  208264             : 
  208265             : //############################################################################
  208266             : /* JH (02/02/2006) Constructor of the IR node SgSymbol that takes its 
  208267             :  * corresponding StorageClass as parameter
  208268             :  */
  208269       45536 : SgSymbol :: SgSymbol ( const SgSymbolStorageClass& storageSource )   : SgNode (storageSource)
  208270             :    {
  208271             : 
  208272             : 
  208273             : /* #line 208274 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  208274             : 
  208275       45536 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  208276       45536 :      p_attributeMechanism = storageSource.storageOf_attributeMechanism.rebuildDataStoredInEasyStorageClass() ;
  208277             : 
  208278             : 
  208279             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  208280             : 
  208281             : 
  208282       45536 :    }
  208283             : 
  208284             : //############################################################################
  208285             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  208286             :  * within the working AST. 
  208287             :  */
  208288           0 : SgSymbol * SgSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  208289           0 :      SgSymbol* returnPointer = NULL;
  208290           0 :      if ( globalIndex != 0 )
  208291             :         {
  208292             : 
  208293             : #if FILE_IO_EXTRA_CHECK
  208294           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgSymbol ) ) <= globalIndex ) ;
  208295           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSymbol + 1 ) ) );
  208296             : #endif
  208297           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgSymbol )  
  208298           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgSymbol );
  208299           0 :           unsigned long positionInPool = localIndex % SgSymbol::pool_size;
  208300           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSymbol::pool_size;
  208301             : 
  208302             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  208303             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  208304             : 
  208305           0 :           returnPointer = &( ( (SgSymbol*)(SgSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  208306             : 
  208307           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  208308             :         }
  208309           0 :      return returnPointer ;
  208310             :    }
  208311             : 
  208312             : //############################################################################
  208313             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  208314             :   for the AST with the index astIndex
  208315             : */
  208316           0 : SgSymbol * SgSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  208317           0 :      SgSymbol* returnPointer = NULL;
  208318           0 :      if ( globalIndex != 0 )
  208319             :         {
  208320             : 
  208321             : #if FILE_IO_EXTRA_CHECK
  208322           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgSymbol ) ) <= globalIndex ) ;
  208323           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSymbol + 1 ) ) );
  208324             : #endif
  208325           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgSymbol )
  208326           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgSymbol );
  208327           0 :           unsigned long positionInPool = localIndex % SgSymbol::pool_size ;
  208328           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgSymbol::pool_size ;
  208329             : 
  208330             : #if FILE_IO_EXTRA_CHECK
  208331             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  208332             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  208333             : #endif
  208334             : 
  208335           0 :           returnPointer = &( ( (SgSymbol*)(SgSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  208336             : 
  208337             : #if FILE_IO_EXTRA_CHECK
  208338           0 :           assert ( returnPointer != NULL ) ;
  208339             : #endif
  208340             :         }
  208341           0 :      return returnPointer ;
  208342             :    }
  208343             : 
  208344             : //############################################################################
  208345             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  208346             :  * pool size! We set for every valid object in the memory pool the freepointer
  208347             :  * to the global index and increase the global index afterwards. For all the 
  208348             :  * invalid objects (means address ranges within the memory pool that were not
  208349             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  208350             :  * distinguish valid from invalid objects! 
  208351             :  */
  208352             : unsigned long
  208353           5 : SgSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  208354             :    {
  208355           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  208356           5 :      SgSymbol* pointer = NULL;
  208357           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  208358           5 :      std::vector < unsigned char* > :: const_iterator block;
  208359           5 :      for ( block = SgSymbol::pools.begin(); block != SgSymbol::pools.end() ; ++block )
  208360             :         {
  208361           0 :           pointer = (SgSymbol*)(*block);
  208362           0 :           for (unsigned i = 0; i < SgSymbol::pool_size; ++i )
  208363             :              {
  208364             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  208365             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  208366             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  208367             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  208368             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  208369             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  208370             :             // properly; so this will have to be checked next.
  208371             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  208372             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  208373           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  208374             :                   {
  208375           0 :                     pointer[i].set_freepointer((SgSymbol*)(globalIndex));
  208376           0 :                     globalIndex++;
  208377             :                   }
  208378             :                else
  208379             :                   {
  208380           0 :                     pointer[i].set_freepointer(NULL);
  208381             :                   }
  208382             :               }
  208383             :         }
  208384           5 :      return globalIndex;
  208385             :    }
  208386             : 
  208387             : //############################################################################
  208388             : // JH (01/14/2006)
  208389             : void
  208390           5 : SgSymbol::resetValidFreepointers( )
  208391             :    {
  208392           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  208393           5 :      SgSymbol* pointer = NULL;
  208394           5 :      std::vector < unsigned char* > :: const_iterator block;
  208395           5 :      SgSymbol* pointerOfLinkedList = NULL;
  208396           5 :      for ( block = SgSymbol::pools.begin(); block != SgSymbol::pools.end() ; ++block )
  208397             :         {
  208398           0 :           pointer = (SgSymbol*)(*block);
  208399           0 :           for (unsigned i = 0; i < SgSymbol::pool_size; ++i )
  208400             :              {
  208401             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  208402             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  208403             :             // memory blocks!.
  208404           0 :                if ( pointer[i].get_freepointer() != NULL )
  208405             :                   {
  208406           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  208407             :                   }
  208408             :                else
  208409             :                   {
  208410           0 :                     if ( pointerOfLinkedList == NULL )
  208411             :                        {
  208412           0 :                          SgSymbol::next_node = &(pointer[i]);
  208413             :                        }
  208414             :                     else
  208415             :                        {
  208416             :                       // printf ("In SgSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  208417           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  208418             :                        }
  208419             :                     pointerOfLinkedList = &(pointer[i]);
  208420             :                   }
  208421             :               }
  208422             :         }
  208423             : 
  208424           5 :      if ( pointerOfLinkedList != NULL )
  208425             :         {
  208426             :        // printf ("In SgSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  208427           0 :           pointerOfLinkedList->set_freepointer(NULL);
  208428             :        // DQ (6/6/2010): Temporary debugging...
  208429             :        //   ROSE_ASSERT(false);
  208430             :         }
  208431             : 
  208432           5 :      return ;
  208433             :    }
  208434             : 
  208435             : //############################################################################
  208436             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  208437             :  * within the memory pool and resets the freepointers, in order to achieve a 
  208438             :  * linked list, that has no jumps and starts at the beginning! This function 
  208439             :  * does not extend the memory pool, since we do not delete any memory blocks,
  208440             :  * but delete the valid objects.  
  208441             :  */
  208442             : void
  208443           0 : SgSymbol::clearMemoryPool( )
  208444             :    {
  208445             :   // printf ("Inside of SgSymbol::clearMemoryPool() \n");
  208446             : 
  208447           0 :      SgSymbol* pointer = NULL, *tempPointer = NULL;
  208448           0 :      std::vector < unsigned char* > :: const_iterator block;
  208449           0 :      if ( SgSymbol::pools.empty() == false )
  208450             :         {
  208451           0 :           block = SgSymbol::pools.begin() ;
  208452           0 :           SgSymbol::next_node = (SgSymbol*) (*block);
  208453             : 
  208454           0 :           while ( block != SgSymbol::pools.end() )
  208455             :              {
  208456           0 :                pointer = (SgSymbol*) (*block);
  208457           0 :                if ( tempPointer != NULL )
  208458             :                   {
  208459           0 :                     tempPointer->set_freepointer(pointer);
  208460             :                   }
  208461           0 :                for (unsigned i = 0; i < SgSymbol::pool_size - 1; ++i)
  208462             :                   {
  208463           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  208464             :                   }
  208465           0 :                 pointer[SgSymbol::pool_size-1].set_freepointer(NULL);
  208466           0 :                 tempPointer = &(pointer[SgSymbol::pool_size-1]);
  208467           0 :                 ++block;
  208468             :              }
  208469             :         }
  208470           0 :    }
  208471             : 
  208472           5 : void SgSymbol::deleteMemoryPool() {
  208473           5 :   for (auto p: SgSymbol::pools) {
  208474           0 :     ROSE_FREE(p);
  208475             :   }
  208476           5 :   SgSymbol::next_node = nullptr;
  208477           5 :   SgSymbol::pools.clear();
  208478           5 : }
  208479             : 
  208480             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  208481             : //                 reading multiple binary files to for a single AST.
  208482             : /////////// new version ////////////////////////////////
  208483             : //############################################################################
  208484             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  208485             : void
  208486           2 : SgSymbol::extendMemoryPoolForFileIO( )
  208487             :   {
  208488           2 :     size_t blockIndex = SgSymbol::pools.size();
  208489           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgSymbol);
  208490             : 
  208491           2 :     while ( (blockIndex * SgSymbol::pool_size) < newPoolSize)
  208492             :       {
  208493             : #if ROSE_ALLOC_TRACE
  208494             :         if (blockIndex > 0) {
  208495             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgSymbol) = %" PRIuPTR " SgSymbol::pool_size = %d \n",
  208496             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgSymbol),SgSymbol::pool_size);
  208497             :         }
  208498             : #endif
  208499             : 
  208500           0 :         SgSymbol * pointer = (SgSymbol*) ROSE_MALLOC ( SgSymbol::pool_size * sizeof(SgSymbol) );
  208501           0 :         assert( pointer != NULL );
  208502             : #if ROSE_ALLOC_MEMSET == 1
  208503             :         memset(pointer, 0x00, SgSymbol::pool_size * sizeof(SgSymbol));
  208504             : #elif ROSE_ALLOC_MEMSET == 2
  208505             :         memset(pointer, 0xCC, SgSymbol::pool_size * sizeof(SgSymbol));
  208506             : #endif
  208507           0 :         SgSymbol::pools.push_back( (unsigned char*)(pointer) );
  208508           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgSymbol::pool_size * sizeof(SgSymbol), V_SgSymbol ) );
  208509             : 
  208510           0 :         if ( SgSymbol::next_node != NULL ) {
  208511           0 :           if ( blockIndex > 0 ) {
  208512           0 :             SgSymbol * blkptr = (SgSymbol*)(SgSymbol::pools[blockIndex-1]);
  208513           0 :             blkptr[ SgSymbol::pool_size - 1 ].set_freepointer(pointer);
  208514             :           }
  208515             :         } else {
  208516           0 :           SgSymbol::next_node = pointer;
  208517             :         }
  208518             : 
  208519           0 :         for (unsigned i = 0; i < SgSymbol::pool_size-1; ++i)
  208520             :            {
  208521           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  208522             :            }
  208523           0 :         pointer[ SgSymbol::pool_size -1 ].set_freepointer(NULL);
  208524             : 
  208525           0 :         blockIndex++;
  208526             :       }
  208527           2 :   }
  208528             : 
  208529             : //############################################################################
  208530             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  208531             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  208532             :  * not compressed. However, that stuff is not yet implemented! 
  208533             :  */
  208534             : unsigned long
  208535           0 : SgSymbol::getNumberOfLastValidPointer()
  208536             :    {
  208537           0 :       SgSymbol* testPointer = (SgSymbol*)(SgSymbol::pools.back());
  208538           0 :       unsigned long localIndex = SgSymbol::pool_size - 1;
  208539           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  208540             :          {
  208541           0 :            localIndex--;
  208542             :          }
  208543           0 :       return (localIndex + SgSymbol::pool_size * (SgSymbol::pools.size()-1));
  208544             :    }
  208545             : 
  208546             : //############################################################################
  208547             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  208548             :  * memory pool and initializes the data member in class SgSymbolStroageClass
  208549             :  * from its counterpart of SgSymbol. The return value is just for checking, 
  208550             :  * that the whole StorageClassArray is initialized!
  208551             :  */
  208552             : unsigned long
  208553           0 : SgSymbol::initializeStorageClassArray( SgSymbolStorageClass *storageArray )
  208554             :    {
  208555           0 :      unsigned long storageCounter = 0;
  208556           0 :      std::vector < unsigned char* > :: const_iterator block = SgSymbol::pools.begin();
  208557           0 :      SgSymbol* pointer = NULL;
  208558           0 :      while ( block != SgSymbol::pools.end() ) {
  208559           0 :           pointer = (SgSymbol*) (*block);
  208560           0 :           for ( unsigned i = 0; i < SgSymbol::pool_size; ++i ) {
  208561           0 :                if ( pointer->get_freepointer() != NULL ) {
  208562           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  208563           0 :                  storageArray++;
  208564           0 :                  storageCounter++;
  208565             :                }
  208566           0 :                pointer++;
  208567             :              }
  208568           0 :            block++;
  208569             :         }
  208570           0 :      return storageCounter;
  208571             :    }
  208572             : 
  208573             : /* #line 208574 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  208574             : 
  208575             : 
  208576             : 
  208577             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  208578             : 
  208579             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  208580             : 
  208581             : //############################################################################
  208582             : /* JH (02/02/2006) Constructor of the IR node SgVariableSymbol that takes its 
  208583             :  * corresponding StorageClass as parameter
  208584             :  */
  208585        4312 : SgVariableSymbol :: SgVariableSymbol ( const SgVariableSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  208586             :    {
  208587             : 
  208588             : 
  208589             : /* #line 208590 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  208590             : 
  208591        4312 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  208592        4312 :      p_declaration =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  208593             : 
  208594             : 
  208595             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  208596             : 
  208597             : 
  208598        4312 :    }
  208599             : 
  208600             : //############################################################################
  208601             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  208602             :  * within the working AST. 
  208603             :  */
  208604       11268 : SgVariableSymbol * SgVariableSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  208605       11268 :      SgVariableSymbol* returnPointer = NULL;
  208606       11268 :      if ( globalIndex != 0 )
  208607             :         {
  208608             : 
  208609             : #if FILE_IO_EXTRA_CHECK
  208610       11268 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgVariableSymbol ) ) <= globalIndex ) ;
  208611       11268 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariableSymbol + 1 ) ) );
  208612             : #endif
  208613       11268 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgVariableSymbol )  
  208614       11268 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgVariableSymbol );
  208615       11268 :           unsigned long positionInPool = localIndex % SgVariableSymbol::pool_size;
  208616       11268 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariableSymbol::pool_size;
  208617             : 
  208618             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  208619             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  208620             : 
  208621       11268 :           returnPointer = &( ( (SgVariableSymbol*)(SgVariableSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  208622             : 
  208623       11268 :           ROSE_ASSERT( returnPointer != NULL ) ;
  208624             :         }
  208625       11268 :      return returnPointer ;
  208626             :    }
  208627             : 
  208628             : //############################################################################
  208629             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  208630             :   for the AST with the index astIndex
  208631             : */
  208632           0 : SgVariableSymbol * SgVariableSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  208633           0 :      SgVariableSymbol* returnPointer = NULL;
  208634           0 :      if ( globalIndex != 0 )
  208635             :         {
  208636             : 
  208637             : #if FILE_IO_EXTRA_CHECK
  208638           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgVariableSymbol ) ) <= globalIndex ) ;
  208639           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariableSymbol + 1 ) ) );
  208640             : #endif
  208641           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgVariableSymbol )
  208642           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgVariableSymbol );
  208643           0 :           unsigned long positionInPool = localIndex % SgVariableSymbol::pool_size ;
  208644           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgVariableSymbol::pool_size ;
  208645             : 
  208646             : #if FILE_IO_EXTRA_CHECK
  208647             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  208648             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  208649             : #endif
  208650             : 
  208651           0 :           returnPointer = &( ( (SgVariableSymbol*)(SgVariableSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  208652             : 
  208653             : #if FILE_IO_EXTRA_CHECK
  208654           0 :           assert ( returnPointer != NULL ) ;
  208655             : #endif
  208656             :         }
  208657           0 :      return returnPointer ;
  208658             :    }
  208659             : 
  208660             : //############################################################################
  208661             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  208662             :  * pool size! We set for every valid object in the memory pool the freepointer
  208663             :  * to the global index and increase the global index afterwards. For all the 
  208664             :  * invalid objects (means address ranges within the memory pool that were not
  208665             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  208666             :  * distinguish valid from invalid objects! 
  208667             :  */
  208668             : unsigned long
  208669           5 : SgVariableSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  208670             :    {
  208671           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  208672           5 :      SgVariableSymbol* pointer = NULL;
  208673           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  208674           5 :      std::vector < unsigned char* > :: const_iterator block;
  208675           9 :      for ( block = SgVariableSymbol::pools.begin(); block != SgVariableSymbol::pools.end() ; ++block )
  208676             :         {
  208677           4 :           pointer = (SgVariableSymbol*)(*block);
  208678        8004 :           for (unsigned i = 0; i < SgVariableSymbol::pool_size; ++i )
  208679             :              {
  208680             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  208681             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  208682             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  208683             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  208684             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  208685             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  208686             :             // properly; so this will have to be checked next.
  208687             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  208688             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  208689        8000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  208690             :                   {
  208691        4226 :                     pointer[i].set_freepointer((SgVariableSymbol*)(globalIndex));
  208692        4226 :                     globalIndex++;
  208693             :                   }
  208694             :                else
  208695             :                   {
  208696        3774 :                     pointer[i].set_freepointer(NULL);
  208697             :                   }
  208698             :               }
  208699             :         }
  208700           5 :      return globalIndex;
  208701             :    }
  208702             : 
  208703             : //############################################################################
  208704             : // JH (01/14/2006)
  208705             : void
  208706           5 : SgVariableSymbol::resetValidFreepointers( )
  208707             :    {
  208708           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  208709           5 :      SgVariableSymbol* pointer = NULL;
  208710           5 :      std::vector < unsigned char* > :: const_iterator block;
  208711           5 :      SgVariableSymbol* pointerOfLinkedList = NULL;
  208712           9 :      for ( block = SgVariableSymbol::pools.begin(); block != SgVariableSymbol::pools.end() ; ++block )
  208713             :         {
  208714           4 :           pointer = (SgVariableSymbol*)(*block);
  208715        8004 :           for (unsigned i = 0; i < SgVariableSymbol::pool_size; ++i )
  208716             :              {
  208717             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  208718             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  208719             :             // memory blocks!.
  208720        8000 :                if ( pointer[i].get_freepointer() != NULL )
  208721             :                   {
  208722        4226 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  208723             :                   }
  208724             :                else
  208725             :                   {
  208726        3774 :                     if ( pointerOfLinkedList == NULL )
  208727             :                        {
  208728           2 :                          SgVariableSymbol::next_node = &(pointer[i]);
  208729             :                        }
  208730             :                     else
  208731             :                        {
  208732             :                       // printf ("In SgVariableSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  208733        3772 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  208734             :                        }
  208735             :                     pointerOfLinkedList = &(pointer[i]);
  208736             :                   }
  208737             :               }
  208738             :         }
  208739             : 
  208740           5 :      if ( pointerOfLinkedList != NULL )
  208741             :         {
  208742             :        // printf ("In SgVariableSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  208743           2 :           pointerOfLinkedList->set_freepointer(NULL);
  208744             :        // DQ (6/6/2010): Temporary debugging...
  208745             :        //   ROSE_ASSERT(false);
  208746             :         }
  208747             : 
  208748           5 :      return ;
  208749             :    }
  208750             : 
  208751             : //############################################################################
  208752             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  208753             :  * within the memory pool and resets the freepointers, in order to achieve a 
  208754             :  * linked list, that has no jumps and starts at the beginning! This function 
  208755             :  * does not extend the memory pool, since we do not delete any memory blocks,
  208756             :  * but delete the valid objects.  
  208757             :  */
  208758             : void
  208759           0 : SgVariableSymbol::clearMemoryPool( )
  208760             :    {
  208761             :   // printf ("Inside of SgVariableSymbol::clearMemoryPool() \n");
  208762             : 
  208763           0 :      SgVariableSymbol* pointer = NULL, *tempPointer = NULL;
  208764           0 :      std::vector < unsigned char* > :: const_iterator block;
  208765           0 :      if ( SgVariableSymbol::pools.empty() == false )
  208766             :         {
  208767           0 :           block = SgVariableSymbol::pools.begin() ;
  208768           0 :           SgVariableSymbol::next_node = (SgVariableSymbol*) (*block);
  208769             : 
  208770           0 :           while ( block != SgVariableSymbol::pools.end() )
  208771             :              {
  208772           0 :                pointer = (SgVariableSymbol*) (*block);
  208773           0 :                if ( tempPointer != NULL )
  208774             :                   {
  208775           0 :                     tempPointer->set_freepointer(pointer);
  208776             :                   }
  208777           0 :                for (unsigned i = 0; i < SgVariableSymbol::pool_size - 1; ++i)
  208778             :                   {
  208779           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  208780             :                   }
  208781           0 :                 pointer[SgVariableSymbol::pool_size-1].set_freepointer(NULL);
  208782           0 :                 tempPointer = &(pointer[SgVariableSymbol::pool_size-1]);
  208783           0 :                 ++block;
  208784             :              }
  208785             :         }
  208786           0 :    }
  208787             : 
  208788           5 : void SgVariableSymbol::deleteMemoryPool() {
  208789          13 :   for (auto p: SgVariableSymbol::pools) {
  208790           8 :     ROSE_FREE(p);
  208791             :   }
  208792           5 :   SgVariableSymbol::next_node = nullptr;
  208793           5 :   SgVariableSymbol::pools.clear();
  208794           5 : }
  208795             : 
  208796             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  208797             : //                 reading multiple binary files to for a single AST.
  208798             : /////////// new version ////////////////////////////////
  208799             : //############################################################################
  208800             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  208801             : void
  208802           2 : SgVariableSymbol::extendMemoryPoolForFileIO( )
  208803             :   {
  208804           2 :     size_t blockIndex = SgVariableSymbol::pools.size();
  208805           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableSymbol);
  208806             : 
  208807           6 :     while ( (blockIndex * SgVariableSymbol::pool_size) < newPoolSize)
  208808             :       {
  208809             : #if ROSE_ALLOC_TRACE
  208810             :         if (blockIndex > 0) {
  208811             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableSymbol) = %" PRIuPTR " SgVariableSymbol::pool_size = %d \n",
  208812             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgVariableSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgVariableSymbol),SgVariableSymbol::pool_size);
  208813             :         }
  208814             : #endif
  208815             : 
  208816           4 :         SgVariableSymbol * pointer = (SgVariableSymbol*) ROSE_MALLOC ( SgVariableSymbol::pool_size * sizeof(SgVariableSymbol) );
  208817           4 :         assert( pointer != NULL );
  208818             : #if ROSE_ALLOC_MEMSET == 1
  208819             :         memset(pointer, 0x00, SgVariableSymbol::pool_size * sizeof(SgVariableSymbol));
  208820             : #elif ROSE_ALLOC_MEMSET == 2
  208821             :         memset(pointer, 0xCC, SgVariableSymbol::pool_size * sizeof(SgVariableSymbol));
  208822             : #endif
  208823           4 :         SgVariableSymbol::pools.push_back( (unsigned char*)(pointer) );
  208824           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgVariableSymbol::pool_size * sizeof(SgVariableSymbol), V_SgVariableSymbol ) );
  208825             : 
  208826           4 :         if ( SgVariableSymbol::next_node != NULL ) {
  208827           2 :           if ( blockIndex > 0 ) {
  208828           2 :             SgVariableSymbol * blkptr = (SgVariableSymbol*)(SgVariableSymbol::pools[blockIndex-1]);
  208829           2 :             blkptr[ SgVariableSymbol::pool_size - 1 ].set_freepointer(pointer);
  208830             :           }
  208831             :         } else {
  208832           2 :           SgVariableSymbol::next_node = pointer;
  208833             :         }
  208834             : 
  208835        8000 :         for (unsigned i = 0; i < SgVariableSymbol::pool_size-1; ++i)
  208836             :            {
  208837        7996 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  208838             :            }
  208839           4 :         pointer[ SgVariableSymbol::pool_size -1 ].set_freepointer(NULL);
  208840             : 
  208841           4 :         blockIndex++;
  208842             :       }
  208843           2 :   }
  208844             : 
  208845             : //############################################################################
  208846             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  208847             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  208848             :  * not compressed. However, that stuff is not yet implemented! 
  208849             :  */
  208850             : unsigned long
  208851           0 : SgVariableSymbol::getNumberOfLastValidPointer()
  208852             :    {
  208853           0 :       SgVariableSymbol* testPointer = (SgVariableSymbol*)(SgVariableSymbol::pools.back());
  208854           0 :       unsigned long localIndex = SgVariableSymbol::pool_size - 1;
  208855           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  208856             :          {
  208857           0 :            localIndex--;
  208858             :          }
  208859           0 :       return (localIndex + SgVariableSymbol::pool_size * (SgVariableSymbol::pools.size()-1));
  208860             :    }
  208861             : 
  208862             : //############################################################################
  208863             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  208864             :  * memory pool and initializes the data member in class SgVariableSymbolStroageClass
  208865             :  * from its counterpart of SgVariableSymbol. The return value is just for checking, 
  208866             :  * that the whole StorageClassArray is initialized!
  208867             :  */
  208868             : unsigned long
  208869           2 : SgVariableSymbol::initializeStorageClassArray( SgVariableSymbolStorageClass *storageArray )
  208870             :    {
  208871           2 :      unsigned long storageCounter = 0;
  208872           2 :      std::vector < unsigned char* > :: const_iterator block = SgVariableSymbol::pools.begin();
  208873           2 :      SgVariableSymbol* pointer = NULL;
  208874           6 :      while ( block != SgVariableSymbol::pools.end() ) {
  208875           4 :           pointer = (SgVariableSymbol*) (*block);
  208876        8004 :           for ( unsigned i = 0; i < SgVariableSymbol::pool_size; ++i ) {
  208877        8000 :                if ( pointer->get_freepointer() != NULL ) {
  208878        4226 :                  storageArray->pickOutIRNodeData (pointer) ;
  208879        4226 :                  storageArray++;
  208880        4226 :                  storageCounter++;
  208881             :                }
  208882        8000 :                pointer++;
  208883             :              }
  208884           4 :            block++;
  208885             :         }
  208886           2 :      return storageCounter;
  208887             :    }
  208888             : 
  208889             : /* #line 208890 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  208890             : 
  208891             : 
  208892             : 
  208893             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  208894             : 
  208895             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  208896             : 
  208897             : //############################################################################
  208898             : /* JH (02/02/2006) Constructor of the IR node SgTemplateVariableSymbol that takes its 
  208899             :  * corresponding StorageClass as parameter
  208900             :  */
  208901          86 : SgTemplateVariableSymbol :: SgTemplateVariableSymbol ( const SgTemplateVariableSymbolStorageClass& storageSource )   : SgVariableSymbol (storageSource)
  208902             :    {
  208903             : 
  208904             : 
  208905             : /* #line 208906 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  208906             : 
  208907          86 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  208908             : 
  208909             : 
  208910             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  208911             : 
  208912             : 
  208913          86 :    }
  208914             : 
  208915             : //############################################################################
  208916             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  208917             :  * within the working AST. 
  208918             :  */
  208919         533 : SgTemplateVariableSymbol * SgTemplateVariableSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  208920         533 :      SgTemplateVariableSymbol* returnPointer = NULL;
  208921         533 :      if ( globalIndex != 0 )
  208922             :         {
  208923             : 
  208924             : #if FILE_IO_EXTRA_CHECK
  208925         533 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateVariableSymbol ) ) <= globalIndex ) ;
  208926         533 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateVariableSymbol + 1 ) ) );
  208927             : #endif
  208928         533 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateVariableSymbol )  
  208929         533 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateVariableSymbol );
  208930         533 :           unsigned long positionInPool = localIndex % SgTemplateVariableSymbol::pool_size;
  208931         533 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateVariableSymbol::pool_size;
  208932             : 
  208933             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  208934             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  208935             : 
  208936         533 :           returnPointer = &( ( (SgTemplateVariableSymbol*)(SgTemplateVariableSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  208937             : 
  208938         533 :           ROSE_ASSERT( returnPointer != NULL ) ;
  208939             :         }
  208940         533 :      return returnPointer ;
  208941             :    }
  208942             : 
  208943             : //############################################################################
  208944             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  208945             :   for the AST with the index astIndex
  208946             : */
  208947           0 : SgTemplateVariableSymbol * SgTemplateVariableSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  208948           0 :      SgTemplateVariableSymbol* returnPointer = NULL;
  208949           0 :      if ( globalIndex != 0 )
  208950             :         {
  208951             : 
  208952             : #if FILE_IO_EXTRA_CHECK
  208953           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateVariableSymbol ) ) <= globalIndex ) ;
  208954           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateVariableSymbol + 1 ) ) );
  208955             : #endif
  208956           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateVariableSymbol )
  208957           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateVariableSymbol );
  208958           0 :           unsigned long positionInPool = localIndex % SgTemplateVariableSymbol::pool_size ;
  208959           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateVariableSymbol::pool_size ;
  208960             : 
  208961             : #if FILE_IO_EXTRA_CHECK
  208962             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  208963             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  208964             : #endif
  208965             : 
  208966           0 :           returnPointer = &( ( (SgTemplateVariableSymbol*)(SgTemplateVariableSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  208967             : 
  208968             : #if FILE_IO_EXTRA_CHECK
  208969           0 :           assert ( returnPointer != NULL ) ;
  208970             : #endif
  208971             :         }
  208972           0 :      return returnPointer ;
  208973             :    }
  208974             : 
  208975             : //############################################################################
  208976             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  208977             :  * pool size! We set for every valid object in the memory pool the freepointer
  208978             :  * to the global index and increase the global index afterwards. For all the 
  208979             :  * invalid objects (means address ranges within the memory pool that were not
  208980             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  208981             :  * distinguish valid from invalid objects! 
  208982             :  */
  208983             : unsigned long
  208984           5 : SgTemplateVariableSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  208985             :    {
  208986           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  208987           5 :      SgTemplateVariableSymbol* pointer = NULL;
  208988           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  208989           5 :      std::vector < unsigned char* > :: const_iterator block;
  208990           6 :      for ( block = SgTemplateVariableSymbol::pools.begin(); block != SgTemplateVariableSymbol::pools.end() ; ++block )
  208991             :         {
  208992           1 :           pointer = (SgTemplateVariableSymbol*)(*block);
  208993        2001 :           for (unsigned i = 0; i < SgTemplateVariableSymbol::pool_size; ++i )
  208994             :              {
  208995             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  208996             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  208997             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  208998             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  208999             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  209000             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  209001             :             // properly; so this will have to be checked next.
  209002             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  209003             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  209004        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  209005             :                   {
  209006          86 :                     pointer[i].set_freepointer((SgTemplateVariableSymbol*)(globalIndex));
  209007          86 :                     globalIndex++;
  209008             :                   }
  209009             :                else
  209010             :                   {
  209011        1914 :                     pointer[i].set_freepointer(NULL);
  209012             :                   }
  209013             :               }
  209014             :         }
  209015           5 :      return globalIndex;
  209016             :    }
  209017             : 
  209018             : //############################################################################
  209019             : // JH (01/14/2006)
  209020             : void
  209021           5 : SgTemplateVariableSymbol::resetValidFreepointers( )
  209022             :    {
  209023           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  209024           5 :      SgTemplateVariableSymbol* pointer = NULL;
  209025           5 :      std::vector < unsigned char* > :: const_iterator block;
  209026           5 :      SgTemplateVariableSymbol* pointerOfLinkedList = NULL;
  209027           6 :      for ( block = SgTemplateVariableSymbol::pools.begin(); block != SgTemplateVariableSymbol::pools.end() ; ++block )
  209028             :         {
  209029           1 :           pointer = (SgTemplateVariableSymbol*)(*block);
  209030        2001 :           for (unsigned i = 0; i < SgTemplateVariableSymbol::pool_size; ++i )
  209031             :              {
  209032             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  209033             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  209034             :             // memory blocks!.
  209035        2000 :                if ( pointer[i].get_freepointer() != NULL )
  209036             :                   {
  209037          86 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  209038             :                   }
  209039             :                else
  209040             :                   {
  209041        1914 :                     if ( pointerOfLinkedList == NULL )
  209042             :                        {
  209043           1 :                          SgTemplateVariableSymbol::next_node = &(pointer[i]);
  209044             :                        }
  209045             :                     else
  209046             :                        {
  209047             :                       // printf ("In SgTemplateVariableSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  209048        1913 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  209049             :                        }
  209050             :                     pointerOfLinkedList = &(pointer[i]);
  209051             :                   }
  209052             :               }
  209053             :         }
  209054             : 
  209055           5 :      if ( pointerOfLinkedList != NULL )
  209056             :         {
  209057             :        // printf ("In SgTemplateVariableSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  209058           1 :           pointerOfLinkedList->set_freepointer(NULL);
  209059             :        // DQ (6/6/2010): Temporary debugging...
  209060             :        //   ROSE_ASSERT(false);
  209061             :         }
  209062             : 
  209063           5 :      return ;
  209064             :    }
  209065             : 
  209066             : //############################################################################
  209067             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  209068             :  * within the memory pool and resets the freepointers, in order to achieve a 
  209069             :  * linked list, that has no jumps and starts at the beginning! This function 
  209070             :  * does not extend the memory pool, since we do not delete any memory blocks,
  209071             :  * but delete the valid objects.  
  209072             :  */
  209073             : void
  209074           0 : SgTemplateVariableSymbol::clearMemoryPool( )
  209075             :    {
  209076             :   // printf ("Inside of SgTemplateVariableSymbol::clearMemoryPool() \n");
  209077             : 
  209078           0 :      SgTemplateVariableSymbol* pointer = NULL, *tempPointer = NULL;
  209079           0 :      std::vector < unsigned char* > :: const_iterator block;
  209080           0 :      if ( SgTemplateVariableSymbol::pools.empty() == false )
  209081             :         {
  209082           0 :           block = SgTemplateVariableSymbol::pools.begin() ;
  209083           0 :           SgTemplateVariableSymbol::next_node = (SgTemplateVariableSymbol*) (*block);
  209084             : 
  209085           0 :           while ( block != SgTemplateVariableSymbol::pools.end() )
  209086             :              {
  209087           0 :                pointer = (SgTemplateVariableSymbol*) (*block);
  209088           0 :                if ( tempPointer != NULL )
  209089             :                   {
  209090           0 :                     tempPointer->set_freepointer(pointer);
  209091             :                   }
  209092           0 :                for (unsigned i = 0; i < SgTemplateVariableSymbol::pool_size - 1; ++i)
  209093             :                   {
  209094           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  209095             :                   }
  209096           0 :                 pointer[SgTemplateVariableSymbol::pool_size-1].set_freepointer(NULL);
  209097           0 :                 tempPointer = &(pointer[SgTemplateVariableSymbol::pool_size-1]);
  209098           0 :                 ++block;
  209099             :              }
  209100             :         }
  209101           0 :    }
  209102             : 
  209103           5 : void SgTemplateVariableSymbol::deleteMemoryPool() {
  209104           7 :   for (auto p: SgTemplateVariableSymbol::pools) {
  209105           2 :     ROSE_FREE(p);
  209106             :   }
  209107           5 :   SgTemplateVariableSymbol::next_node = nullptr;
  209108           5 :   SgTemplateVariableSymbol::pools.clear();
  209109           5 : }
  209110             : 
  209111             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  209112             : //                 reading multiple binary files to for a single AST.
  209113             : /////////// new version ////////////////////////////////
  209114             : //############################################################################
  209115             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  209116             : void
  209117           2 : SgTemplateVariableSymbol::extendMemoryPoolForFileIO( )
  209118             :   {
  209119           2 :     size_t blockIndex = SgTemplateVariableSymbol::pools.size();
  209120           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateVariableSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateVariableSymbol);
  209121             : 
  209122           3 :     while ( (blockIndex * SgTemplateVariableSymbol::pool_size) < newPoolSize)
  209123             :       {
  209124             : #if ROSE_ALLOC_TRACE
  209125             :         if (blockIndex > 0) {
  209126             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateVariableSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateVariableSymbol) = %" PRIuPTR " SgTemplateVariableSymbol::pool_size = %d \n",
  209127             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateVariableSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateVariableSymbol),SgTemplateVariableSymbol::pool_size);
  209128             :         }
  209129             : #endif
  209130             : 
  209131           1 :         SgTemplateVariableSymbol * pointer = (SgTemplateVariableSymbol*) ROSE_MALLOC ( SgTemplateVariableSymbol::pool_size * sizeof(SgTemplateVariableSymbol) );
  209132           1 :         assert( pointer != NULL );
  209133             : #if ROSE_ALLOC_MEMSET == 1
  209134             :         memset(pointer, 0x00, SgTemplateVariableSymbol::pool_size * sizeof(SgTemplateVariableSymbol));
  209135             : #elif ROSE_ALLOC_MEMSET == 2
  209136             :         memset(pointer, 0xCC, SgTemplateVariableSymbol::pool_size * sizeof(SgTemplateVariableSymbol));
  209137             : #endif
  209138           1 :         SgTemplateVariableSymbol::pools.push_back( (unsigned char*)(pointer) );
  209139           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateVariableSymbol::pool_size * sizeof(SgTemplateVariableSymbol), V_SgTemplateVariableSymbol ) );
  209140             : 
  209141           1 :         if ( SgTemplateVariableSymbol::next_node != NULL ) {
  209142           0 :           if ( blockIndex > 0 ) {
  209143           0 :             SgTemplateVariableSymbol * blkptr = (SgTemplateVariableSymbol*)(SgTemplateVariableSymbol::pools[blockIndex-1]);
  209144           0 :             blkptr[ SgTemplateVariableSymbol::pool_size - 1 ].set_freepointer(pointer);
  209145             :           }
  209146             :         } else {
  209147           1 :           SgTemplateVariableSymbol::next_node = pointer;
  209148             :         }
  209149             : 
  209150        2000 :         for (unsigned i = 0; i < SgTemplateVariableSymbol::pool_size-1; ++i)
  209151             :            {
  209152        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  209153             :            }
  209154           1 :         pointer[ SgTemplateVariableSymbol::pool_size -1 ].set_freepointer(NULL);
  209155             : 
  209156           1 :         blockIndex++;
  209157             :       }
  209158           2 :   }
  209159             : 
  209160             : //############################################################################
  209161             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  209162             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  209163             :  * not compressed. However, that stuff is not yet implemented! 
  209164             :  */
  209165             : unsigned long
  209166           0 : SgTemplateVariableSymbol::getNumberOfLastValidPointer()
  209167             :    {
  209168           0 :       SgTemplateVariableSymbol* testPointer = (SgTemplateVariableSymbol*)(SgTemplateVariableSymbol::pools.back());
  209169           0 :       unsigned long localIndex = SgTemplateVariableSymbol::pool_size - 1;
  209170           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  209171             :          {
  209172           0 :            localIndex--;
  209173             :          }
  209174           0 :       return (localIndex + SgTemplateVariableSymbol::pool_size * (SgTemplateVariableSymbol::pools.size()-1));
  209175             :    }
  209176             : 
  209177             : //############################################################################
  209178             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  209179             :  * memory pool and initializes the data member in class SgTemplateVariableSymbolStroageClass
  209180             :  * from its counterpart of SgTemplateVariableSymbol. The return value is just for checking, 
  209181             :  * that the whole StorageClassArray is initialized!
  209182             :  */
  209183             : unsigned long
  209184           1 : SgTemplateVariableSymbol::initializeStorageClassArray( SgTemplateVariableSymbolStorageClass *storageArray )
  209185             :    {
  209186           1 :      unsigned long storageCounter = 0;
  209187           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateVariableSymbol::pools.begin();
  209188           1 :      SgTemplateVariableSymbol* pointer = NULL;
  209189           2 :      while ( block != SgTemplateVariableSymbol::pools.end() ) {
  209190           1 :           pointer = (SgTemplateVariableSymbol*) (*block);
  209191        2001 :           for ( unsigned i = 0; i < SgTemplateVariableSymbol::pool_size; ++i ) {
  209192        2000 :                if ( pointer->get_freepointer() != NULL ) {
  209193          86 :                  storageArray->pickOutIRNodeData (pointer) ;
  209194          86 :                  storageArray++;
  209195          86 :                  storageCounter++;
  209196             :                }
  209197        2000 :                pointer++;
  209198             :              }
  209199           1 :            block++;
  209200             :         }
  209201           1 :      return storageCounter;
  209202             :    }
  209203             : 
  209204             : /* #line 209205 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  209205             : 
  209206             : 
  209207             : 
  209208             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  209209             : 
  209210             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  209211             : 
  209212             : //############################################################################
  209213             : /* JH (02/02/2006) Constructor of the IR node SgNonrealSymbol that takes its 
  209214             :  * corresponding StorageClass as parameter
  209215             :  */
  209216        5080 : SgNonrealSymbol :: SgNonrealSymbol ( const SgNonrealSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  209217             :    {
  209218             : 
  209219             : 
  209220             : /* #line 209221 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  209221             : 
  209222        5080 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  209223        5080 :      p_declaration =  (SgNonrealDecl*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  209224             : 
  209225             : 
  209226             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  209227             : 
  209228             : 
  209229        5080 :    }
  209230             : 
  209231             : //############################################################################
  209232             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  209233             :  * within the working AST. 
  209234             :  */
  209235        7171 : SgNonrealSymbol * SgNonrealSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  209236        7171 :      SgNonrealSymbol* returnPointer = NULL;
  209237        7171 :      if ( globalIndex != 0 )
  209238             :         {
  209239             : 
  209240             : #if FILE_IO_EXTRA_CHECK
  209241        7171 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNonrealSymbol ) ) <= globalIndex ) ;
  209242        7171 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealSymbol + 1 ) ) );
  209243             : #endif
  209244        7171 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNonrealSymbol )  
  209245        7171 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNonrealSymbol );
  209246        7171 :           unsigned long positionInPool = localIndex % SgNonrealSymbol::pool_size;
  209247        7171 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealSymbol::pool_size;
  209248             : 
  209249             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  209250             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  209251             : 
  209252        7171 :           returnPointer = &( ( (SgNonrealSymbol*)(SgNonrealSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  209253             : 
  209254        7171 :           ROSE_ASSERT( returnPointer != NULL ) ;
  209255             :         }
  209256        7171 :      return returnPointer ;
  209257             :    }
  209258             : 
  209259             : //############################################################################
  209260             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  209261             :   for the AST with the index astIndex
  209262             : */
  209263           0 : SgNonrealSymbol * SgNonrealSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  209264           0 :      SgNonrealSymbol* returnPointer = NULL;
  209265           0 :      if ( globalIndex != 0 )
  209266             :         {
  209267             : 
  209268             : #if FILE_IO_EXTRA_CHECK
  209269           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNonrealSymbol ) ) <= globalIndex ) ;
  209270           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealSymbol + 1 ) ) );
  209271             : #endif
  209272           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNonrealSymbol )
  209273           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNonrealSymbol );
  209274           0 :           unsigned long positionInPool = localIndex % SgNonrealSymbol::pool_size ;
  209275           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNonrealSymbol::pool_size ;
  209276             : 
  209277             : #if FILE_IO_EXTRA_CHECK
  209278             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  209279             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  209280             : #endif
  209281             : 
  209282           0 :           returnPointer = &( ( (SgNonrealSymbol*)(SgNonrealSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  209283             : 
  209284             : #if FILE_IO_EXTRA_CHECK
  209285           0 :           assert ( returnPointer != NULL ) ;
  209286             : #endif
  209287             :         }
  209288           0 :      return returnPointer ;
  209289             :    }
  209290             : 
  209291             : //############################################################################
  209292             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  209293             :  * pool size! We set for every valid object in the memory pool the freepointer
  209294             :  * to the global index and increase the global index afterwards. For all the 
  209295             :  * invalid objects (means address ranges within the memory pool that were not
  209296             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  209297             :  * distinguish valid from invalid objects! 
  209298             :  */
  209299             : unsigned long
  209300           5 : SgNonrealSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  209301             :    {
  209302           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  209303           5 :      SgNonrealSymbol* pointer = NULL;
  209304           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  209305           5 :      std::vector < unsigned char* > :: const_iterator block;
  209306           8 :      for ( block = SgNonrealSymbol::pools.begin(); block != SgNonrealSymbol::pools.end() ; ++block )
  209307             :         {
  209308           3 :           pointer = (SgNonrealSymbol*)(*block);
  209309        6003 :           for (unsigned i = 0; i < SgNonrealSymbol::pool_size; ++i )
  209310             :              {
  209311             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  209312             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  209313             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  209314             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  209315             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  209316             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  209317             :             // properly; so this will have to be checked next.
  209318             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  209319             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  209320        6000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  209321             :                   {
  209322        5080 :                     pointer[i].set_freepointer((SgNonrealSymbol*)(globalIndex));
  209323        5080 :                     globalIndex++;
  209324             :                   }
  209325             :                else
  209326             :                   {
  209327         920 :                     pointer[i].set_freepointer(NULL);
  209328             :                   }
  209329             :               }
  209330             :         }
  209331           5 :      return globalIndex;
  209332             :    }
  209333             : 
  209334             : //############################################################################
  209335             : // JH (01/14/2006)
  209336             : void
  209337           5 : SgNonrealSymbol::resetValidFreepointers( )
  209338             :    {
  209339           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  209340           5 :      SgNonrealSymbol* pointer = NULL;
  209341           5 :      std::vector < unsigned char* > :: const_iterator block;
  209342           5 :      SgNonrealSymbol* pointerOfLinkedList = NULL;
  209343           8 :      for ( block = SgNonrealSymbol::pools.begin(); block != SgNonrealSymbol::pools.end() ; ++block )
  209344             :         {
  209345           3 :           pointer = (SgNonrealSymbol*)(*block);
  209346        6003 :           for (unsigned i = 0; i < SgNonrealSymbol::pool_size; ++i )
  209347             :              {
  209348             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  209349             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  209350             :             // memory blocks!.
  209351        6000 :                if ( pointer[i].get_freepointer() != NULL )
  209352             :                   {
  209353        5080 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  209354             :                   }
  209355             :                else
  209356             :                   {
  209357         920 :                     if ( pointerOfLinkedList == NULL )
  209358             :                        {
  209359           1 :                          SgNonrealSymbol::next_node = &(pointer[i]);
  209360             :                        }
  209361             :                     else
  209362             :                        {
  209363             :                       // printf ("In SgNonrealSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  209364         919 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  209365             :                        }
  209366             :                     pointerOfLinkedList = &(pointer[i]);
  209367             :                   }
  209368             :               }
  209369             :         }
  209370             : 
  209371           5 :      if ( pointerOfLinkedList != NULL )
  209372             :         {
  209373             :        // printf ("In SgNonrealSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  209374           1 :           pointerOfLinkedList->set_freepointer(NULL);
  209375             :        // DQ (6/6/2010): Temporary debugging...
  209376             :        //   ROSE_ASSERT(false);
  209377             :         }
  209378             : 
  209379           5 :      return ;
  209380             :    }
  209381             : 
  209382             : //############################################################################
  209383             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  209384             :  * within the memory pool and resets the freepointers, in order to achieve a 
  209385             :  * linked list, that has no jumps and starts at the beginning! This function 
  209386             :  * does not extend the memory pool, since we do not delete any memory blocks,
  209387             :  * but delete the valid objects.  
  209388             :  */
  209389             : void
  209390           0 : SgNonrealSymbol::clearMemoryPool( )
  209391             :    {
  209392             :   // printf ("Inside of SgNonrealSymbol::clearMemoryPool() \n");
  209393             : 
  209394           0 :      SgNonrealSymbol* pointer = NULL, *tempPointer = NULL;
  209395           0 :      std::vector < unsigned char* > :: const_iterator block;
  209396           0 :      if ( SgNonrealSymbol::pools.empty() == false )
  209397             :         {
  209398           0 :           block = SgNonrealSymbol::pools.begin() ;
  209399           0 :           SgNonrealSymbol::next_node = (SgNonrealSymbol*) (*block);
  209400             : 
  209401           0 :           while ( block != SgNonrealSymbol::pools.end() )
  209402             :              {
  209403           0 :                pointer = (SgNonrealSymbol*) (*block);
  209404           0 :                if ( tempPointer != NULL )
  209405             :                   {
  209406           0 :                     tempPointer->set_freepointer(pointer);
  209407             :                   }
  209408           0 :                for (unsigned i = 0; i < SgNonrealSymbol::pool_size - 1; ++i)
  209409             :                   {
  209410           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  209411             :                   }
  209412           0 :                 pointer[SgNonrealSymbol::pool_size-1].set_freepointer(NULL);
  209413           0 :                 tempPointer = &(pointer[SgNonrealSymbol::pool_size-1]);
  209414           0 :                 ++block;
  209415             :              }
  209416             :         }
  209417           0 :    }
  209418             : 
  209419           5 : void SgNonrealSymbol::deleteMemoryPool() {
  209420          11 :   for (auto p: SgNonrealSymbol::pools) {
  209421           6 :     ROSE_FREE(p);
  209422             :   }
  209423           5 :   SgNonrealSymbol::next_node = nullptr;
  209424           5 :   SgNonrealSymbol::pools.clear();
  209425           5 : }
  209426             : 
  209427             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  209428             : //                 reading multiple binary files to for a single AST.
  209429             : /////////// new version ////////////////////////////////
  209430             : //############################################################################
  209431             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  209432             : void
  209433           2 : SgNonrealSymbol::extendMemoryPoolForFileIO( )
  209434             :   {
  209435           2 :     size_t blockIndex = SgNonrealSymbol::pools.size();
  209436           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealSymbol);
  209437             : 
  209438           5 :     while ( (blockIndex * SgNonrealSymbol::pool_size) < newPoolSize)
  209439             :       {
  209440             : #if ROSE_ALLOC_TRACE
  209441             :         if (blockIndex > 0) {
  209442             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealSymbol) = %" PRIuPTR " SgNonrealSymbol::pool_size = %d \n",
  209443             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNonrealSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNonrealSymbol),SgNonrealSymbol::pool_size);
  209444             :         }
  209445             : #endif
  209446             : 
  209447           3 :         SgNonrealSymbol * pointer = (SgNonrealSymbol*) ROSE_MALLOC ( SgNonrealSymbol::pool_size * sizeof(SgNonrealSymbol) );
  209448           3 :         assert( pointer != NULL );
  209449             : #if ROSE_ALLOC_MEMSET == 1
  209450             :         memset(pointer, 0x00, SgNonrealSymbol::pool_size * sizeof(SgNonrealSymbol));
  209451             : #elif ROSE_ALLOC_MEMSET == 2
  209452             :         memset(pointer, 0xCC, SgNonrealSymbol::pool_size * sizeof(SgNonrealSymbol));
  209453             : #endif
  209454           3 :         SgNonrealSymbol::pools.push_back( (unsigned char*)(pointer) );
  209455           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNonrealSymbol::pool_size * sizeof(SgNonrealSymbol), V_SgNonrealSymbol ) );
  209456             : 
  209457           3 :         if ( SgNonrealSymbol::next_node != NULL ) {
  209458           2 :           if ( blockIndex > 0 ) {
  209459           2 :             SgNonrealSymbol * blkptr = (SgNonrealSymbol*)(SgNonrealSymbol::pools[blockIndex-1]);
  209460           2 :             blkptr[ SgNonrealSymbol::pool_size - 1 ].set_freepointer(pointer);
  209461             :           }
  209462             :         } else {
  209463           1 :           SgNonrealSymbol::next_node = pointer;
  209464             :         }
  209465             : 
  209466        6000 :         for (unsigned i = 0; i < SgNonrealSymbol::pool_size-1; ++i)
  209467             :            {
  209468        5997 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  209469             :            }
  209470           3 :         pointer[ SgNonrealSymbol::pool_size -1 ].set_freepointer(NULL);
  209471             : 
  209472           3 :         blockIndex++;
  209473             :       }
  209474           2 :   }
  209475             : 
  209476             : //############################################################################
  209477             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  209478             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  209479             :  * not compressed. However, that stuff is not yet implemented! 
  209480             :  */
  209481             : unsigned long
  209482           0 : SgNonrealSymbol::getNumberOfLastValidPointer()
  209483             :    {
  209484           0 :       SgNonrealSymbol* testPointer = (SgNonrealSymbol*)(SgNonrealSymbol::pools.back());
  209485           0 :       unsigned long localIndex = SgNonrealSymbol::pool_size - 1;
  209486           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  209487             :          {
  209488           0 :            localIndex--;
  209489             :          }
  209490           0 :       return (localIndex + SgNonrealSymbol::pool_size * (SgNonrealSymbol::pools.size()-1));
  209491             :    }
  209492             : 
  209493             : //############################################################################
  209494             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  209495             :  * memory pool and initializes the data member in class SgNonrealSymbolStroageClass
  209496             :  * from its counterpart of SgNonrealSymbol. The return value is just for checking, 
  209497             :  * that the whole StorageClassArray is initialized!
  209498             :  */
  209499             : unsigned long
  209500           1 : SgNonrealSymbol::initializeStorageClassArray( SgNonrealSymbolStorageClass *storageArray )
  209501             :    {
  209502           1 :      unsigned long storageCounter = 0;
  209503           1 :      std::vector < unsigned char* > :: const_iterator block = SgNonrealSymbol::pools.begin();
  209504           1 :      SgNonrealSymbol* pointer = NULL;
  209505           4 :      while ( block != SgNonrealSymbol::pools.end() ) {
  209506           3 :           pointer = (SgNonrealSymbol*) (*block);
  209507        6003 :           for ( unsigned i = 0; i < SgNonrealSymbol::pool_size; ++i ) {
  209508        6000 :                if ( pointer->get_freepointer() != NULL ) {
  209509        5080 :                  storageArray->pickOutIRNodeData (pointer) ;
  209510        5080 :                  storageArray++;
  209511        5080 :                  storageCounter++;
  209512             :                }
  209513        6000 :                pointer++;
  209514             :              }
  209515           3 :            block++;
  209516             :         }
  209517           1 :      return storageCounter;
  209518             :    }
  209519             : 
  209520             : /* #line 209521 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  209521             : 
  209522             : 
  209523             : 
  209524             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  209525             : 
  209526             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  209527             : 
  209528             : //############################################################################
  209529             : /* JH (02/02/2006) Constructor of the IR node SgFunctionSymbol that takes its 
  209530             :  * corresponding StorageClass as parameter
  209531             :  */
  209532        9295 : SgFunctionSymbol :: SgFunctionSymbol ( const SgFunctionSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  209533             :    {
  209534             : 
  209535             : 
  209536             : /* #line 209537 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  209537             : 
  209538        9295 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  209539        9295 :      p_declaration =  (SgFunctionDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  209540             : 
  209541             : 
  209542             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  209543             : 
  209544             : 
  209545        9295 :    }
  209546             : 
  209547             : //############################################################################
  209548             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  209549             :  * within the working AST. 
  209550             :  */
  209551       12603 : SgFunctionSymbol * SgFunctionSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  209552       12603 :      SgFunctionSymbol* returnPointer = NULL;
  209553       12603 :      if ( globalIndex != 0 )
  209554             :         {
  209555             : 
  209556             : #if FILE_IO_EXTRA_CHECK
  209557       12603 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionSymbol ) ) <= globalIndex ) ;
  209558       12603 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionSymbol + 1 ) ) );
  209559             : #endif
  209560       12603 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionSymbol )  
  209561       12603 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionSymbol );
  209562       12603 :           unsigned long positionInPool = localIndex % SgFunctionSymbol::pool_size;
  209563       12603 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionSymbol::pool_size;
  209564             : 
  209565             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  209566             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  209567             : 
  209568       12603 :           returnPointer = &( ( (SgFunctionSymbol*)(SgFunctionSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  209569             : 
  209570       12603 :           ROSE_ASSERT( returnPointer != NULL ) ;
  209571             :         }
  209572       12603 :      return returnPointer ;
  209573             :    }
  209574             : 
  209575             : //############################################################################
  209576             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  209577             :   for the AST with the index astIndex
  209578             : */
  209579           0 : SgFunctionSymbol * SgFunctionSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  209580           0 :      SgFunctionSymbol* returnPointer = NULL;
  209581           0 :      if ( globalIndex != 0 )
  209582             :         {
  209583             : 
  209584             : #if FILE_IO_EXTRA_CHECK
  209585           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionSymbol ) ) <= globalIndex ) ;
  209586           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionSymbol + 1 ) ) );
  209587             : #endif
  209588           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionSymbol )
  209589           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionSymbol );
  209590           0 :           unsigned long positionInPool = localIndex % SgFunctionSymbol::pool_size ;
  209591           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionSymbol::pool_size ;
  209592             : 
  209593             : #if FILE_IO_EXTRA_CHECK
  209594             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  209595             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  209596             : #endif
  209597             : 
  209598           0 :           returnPointer = &( ( (SgFunctionSymbol*)(SgFunctionSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  209599             : 
  209600             : #if FILE_IO_EXTRA_CHECK
  209601           0 :           assert ( returnPointer != NULL ) ;
  209602             : #endif
  209603             :         }
  209604           0 :      return returnPointer ;
  209605             :    }
  209606             : 
  209607             : //############################################################################
  209608             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  209609             :  * pool size! We set for every valid object in the memory pool the freepointer
  209610             :  * to the global index and increase the global index afterwards. For all the 
  209611             :  * invalid objects (means address ranges within the memory pool that were not
  209612             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  209613             :  * distinguish valid from invalid objects! 
  209614             :  */
  209615             : unsigned long
  209616           5 : SgFunctionSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  209617             :    {
  209618           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  209619           5 :      SgFunctionSymbol* pointer = NULL;
  209620           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  209621           5 :      std::vector < unsigned char* > :: const_iterator block;
  209622          10 :      for ( block = SgFunctionSymbol::pools.begin(); block != SgFunctionSymbol::pools.end() ; ++block )
  209623             :         {
  209624           5 :           pointer = (SgFunctionSymbol*)(*block);
  209625       10005 :           for (unsigned i = 0; i < SgFunctionSymbol::pool_size; ++i )
  209626             :              {
  209627             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  209628             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  209629             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  209630             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  209631             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  209632             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  209633             :             // properly; so this will have to be checked next.
  209634             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  209635             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  209636       10000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  209637             :                   {
  209638        5956 :                     pointer[i].set_freepointer((SgFunctionSymbol*)(globalIndex));
  209639        5956 :                     globalIndex++;
  209640             :                   }
  209641             :                else
  209642             :                   {
  209643        4044 :                     pointer[i].set_freepointer(NULL);
  209644             :                   }
  209645             :               }
  209646             :         }
  209647           5 :      return globalIndex;
  209648             :    }
  209649             : 
  209650             : //############################################################################
  209651             : // JH (01/14/2006)
  209652             : void
  209653           5 : SgFunctionSymbol::resetValidFreepointers( )
  209654             :    {
  209655           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  209656           5 :      SgFunctionSymbol* pointer = NULL;
  209657           5 :      std::vector < unsigned char* > :: const_iterator block;
  209658           5 :      SgFunctionSymbol* pointerOfLinkedList = NULL;
  209659          10 :      for ( block = SgFunctionSymbol::pools.begin(); block != SgFunctionSymbol::pools.end() ; ++block )
  209660             :         {
  209661           5 :           pointer = (SgFunctionSymbol*)(*block);
  209662       10005 :           for (unsigned i = 0; i < SgFunctionSymbol::pool_size; ++i )
  209663             :              {
  209664             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  209665             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  209666             :             // memory blocks!.
  209667       10000 :                if ( pointer[i].get_freepointer() != NULL )
  209668             :                   {
  209669        5956 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  209670             :                   }
  209671             :                else
  209672             :                   {
  209673        4044 :                     if ( pointerOfLinkedList == NULL )
  209674             :                        {
  209675           3 :                          SgFunctionSymbol::next_node = &(pointer[i]);
  209676             :                        }
  209677             :                     else
  209678             :                        {
  209679             :                       // printf ("In SgFunctionSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  209680        4041 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  209681             :                        }
  209682             :                     pointerOfLinkedList = &(pointer[i]);
  209683             :                   }
  209684             :               }
  209685             :         }
  209686             : 
  209687           5 :      if ( pointerOfLinkedList != NULL )
  209688             :         {
  209689             :        // printf ("In SgFunctionSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  209690           3 :           pointerOfLinkedList->set_freepointer(NULL);
  209691             :        // DQ (6/6/2010): Temporary debugging...
  209692             :        //   ROSE_ASSERT(false);
  209693             :         }
  209694             : 
  209695           5 :      return ;
  209696             :    }
  209697             : 
  209698             : //############################################################################
  209699             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  209700             :  * within the memory pool and resets the freepointers, in order to achieve a 
  209701             :  * linked list, that has no jumps and starts at the beginning! This function 
  209702             :  * does not extend the memory pool, since we do not delete any memory blocks,
  209703             :  * but delete the valid objects.  
  209704             :  */
  209705             : void
  209706           0 : SgFunctionSymbol::clearMemoryPool( )
  209707             :    {
  209708             :   // printf ("Inside of SgFunctionSymbol::clearMemoryPool() \n");
  209709             : 
  209710           0 :      SgFunctionSymbol* pointer = NULL, *tempPointer = NULL;
  209711           0 :      std::vector < unsigned char* > :: const_iterator block;
  209712           0 :      if ( SgFunctionSymbol::pools.empty() == false )
  209713             :         {
  209714           0 :           block = SgFunctionSymbol::pools.begin() ;
  209715           0 :           SgFunctionSymbol::next_node = (SgFunctionSymbol*) (*block);
  209716             : 
  209717           0 :           while ( block != SgFunctionSymbol::pools.end() )
  209718             :              {
  209719           0 :                pointer = (SgFunctionSymbol*) (*block);
  209720           0 :                if ( tempPointer != NULL )
  209721             :                   {
  209722           0 :                     tempPointer->set_freepointer(pointer);
  209723             :                   }
  209724           0 :                for (unsigned i = 0; i < SgFunctionSymbol::pool_size - 1; ++i)
  209725             :                   {
  209726           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  209727             :                   }
  209728           0 :                 pointer[SgFunctionSymbol::pool_size-1].set_freepointer(NULL);
  209729           0 :                 tempPointer = &(pointer[SgFunctionSymbol::pool_size-1]);
  209730           0 :                 ++block;
  209731             :              }
  209732             :         }
  209733           0 :    }
  209734             : 
  209735           5 : void SgFunctionSymbol::deleteMemoryPool() {
  209736          14 :   for (auto p: SgFunctionSymbol::pools) {
  209737           9 :     ROSE_FREE(p);
  209738             :   }
  209739           5 :   SgFunctionSymbol::next_node = nullptr;
  209740           5 :   SgFunctionSymbol::pools.clear();
  209741           5 : }
  209742             : 
  209743             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  209744             : //                 reading multiple binary files to for a single AST.
  209745             : /////////// new version ////////////////////////////////
  209746             : //############################################################################
  209747             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  209748             : void
  209749           2 : SgFunctionSymbol::extendMemoryPoolForFileIO( )
  209750             :   {
  209751           2 :     size_t blockIndex = SgFunctionSymbol::pools.size();
  209752           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionSymbol);
  209753             : 
  209754           6 :     while ( (blockIndex * SgFunctionSymbol::pool_size) < newPoolSize)
  209755             :       {
  209756             : #if ROSE_ALLOC_TRACE
  209757             :         if (blockIndex > 0) {
  209758             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionSymbol) = %" PRIuPTR " SgFunctionSymbol::pool_size = %d \n",
  209759             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionSymbol),SgFunctionSymbol::pool_size);
  209760             :         }
  209761             : #endif
  209762             : 
  209763           4 :         SgFunctionSymbol * pointer = (SgFunctionSymbol*) ROSE_MALLOC ( SgFunctionSymbol::pool_size * sizeof(SgFunctionSymbol) );
  209764           4 :         assert( pointer != NULL );
  209765             : #if ROSE_ALLOC_MEMSET == 1
  209766             :         memset(pointer, 0x00, SgFunctionSymbol::pool_size * sizeof(SgFunctionSymbol));
  209767             : #elif ROSE_ALLOC_MEMSET == 2
  209768             :         memset(pointer, 0xCC, SgFunctionSymbol::pool_size * sizeof(SgFunctionSymbol));
  209769             : #endif
  209770           4 :         SgFunctionSymbol::pools.push_back( (unsigned char*)(pointer) );
  209771           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionSymbol::pool_size * sizeof(SgFunctionSymbol), V_SgFunctionSymbol ) );
  209772             : 
  209773           4 :         if ( SgFunctionSymbol::next_node != NULL ) {
  209774           2 :           if ( blockIndex > 0 ) {
  209775           2 :             SgFunctionSymbol * blkptr = (SgFunctionSymbol*)(SgFunctionSymbol::pools[blockIndex-1]);
  209776           2 :             blkptr[ SgFunctionSymbol::pool_size - 1 ].set_freepointer(pointer);
  209777             :           }
  209778             :         } else {
  209779           2 :           SgFunctionSymbol::next_node = pointer;
  209780             :         }
  209781             : 
  209782        8000 :         for (unsigned i = 0; i < SgFunctionSymbol::pool_size-1; ++i)
  209783             :            {
  209784        7996 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  209785             :            }
  209786           4 :         pointer[ SgFunctionSymbol::pool_size -1 ].set_freepointer(NULL);
  209787             : 
  209788           4 :         blockIndex++;
  209789             :       }
  209790           2 :   }
  209791             : 
  209792             : //############################################################################
  209793             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  209794             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  209795             :  * not compressed. However, that stuff is not yet implemented! 
  209796             :  */
  209797             : unsigned long
  209798           0 : SgFunctionSymbol::getNumberOfLastValidPointer()
  209799             :    {
  209800           0 :       SgFunctionSymbol* testPointer = (SgFunctionSymbol*)(SgFunctionSymbol::pools.back());
  209801           0 :       unsigned long localIndex = SgFunctionSymbol::pool_size - 1;
  209802           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  209803             :          {
  209804           0 :            localIndex--;
  209805             :          }
  209806           0 :       return (localIndex + SgFunctionSymbol::pool_size * (SgFunctionSymbol::pools.size()-1));
  209807             :    }
  209808             : 
  209809             : //############################################################################
  209810             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  209811             :  * memory pool and initializes the data member in class SgFunctionSymbolStroageClass
  209812             :  * from its counterpart of SgFunctionSymbol. The return value is just for checking, 
  209813             :  * that the whole StorageClassArray is initialized!
  209814             :  */
  209815             : unsigned long
  209816           3 : SgFunctionSymbol::initializeStorageClassArray( SgFunctionSymbolStorageClass *storageArray )
  209817             :    {
  209818           3 :      unsigned long storageCounter = 0;
  209819           3 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionSymbol::pools.begin();
  209820           3 :      SgFunctionSymbol* pointer = NULL;
  209821           8 :      while ( block != SgFunctionSymbol::pools.end() ) {
  209822           5 :           pointer = (SgFunctionSymbol*) (*block);
  209823       10005 :           for ( unsigned i = 0; i < SgFunctionSymbol::pool_size; ++i ) {
  209824       10000 :                if ( pointer->get_freepointer() != NULL ) {
  209825        5956 :                  storageArray->pickOutIRNodeData (pointer) ;
  209826        5956 :                  storageArray++;
  209827        5956 :                  storageCounter++;
  209828             :                }
  209829       10000 :                pointer++;
  209830             :              }
  209831           5 :            block++;
  209832             :         }
  209833           3 :      return storageCounter;
  209834             :    }
  209835             : 
  209836             : /* #line 209837 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  209837             : 
  209838             : 
  209839             : 
  209840             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  209841             : 
  209842             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  209843             : 
  209844             : //############################################################################
  209845             : /* JH (02/02/2006) Constructor of the IR node SgMemberFunctionSymbol that takes its 
  209846             :  * corresponding StorageClass as parameter
  209847             :  */
  209848        3000 : SgMemberFunctionSymbol :: SgMemberFunctionSymbol ( const SgMemberFunctionSymbolStorageClass& storageSource )   : SgFunctionSymbol (storageSource)
  209849             :    {
  209850             : 
  209851             : 
  209852             : /* #line 209853 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  209853             : 
  209854        3000 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  209855             : 
  209856             : 
  209857             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  209858             : 
  209859             : 
  209860        3000 :    }
  209861             : 
  209862             : //############################################################################
  209863             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  209864             :  * within the working AST. 
  209865             :  */
  209866        4475 : SgMemberFunctionSymbol * SgMemberFunctionSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  209867        4475 :      SgMemberFunctionSymbol* returnPointer = NULL;
  209868        4475 :      if ( globalIndex != 0 )
  209869             :         {
  209870             : 
  209871             : #if FILE_IO_EXTRA_CHECK
  209872        4475 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgMemberFunctionSymbol ) ) <= globalIndex ) ;
  209873        4475 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMemberFunctionSymbol + 1 ) ) );
  209874             : #endif
  209875        4475 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgMemberFunctionSymbol )  
  209876        4475 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgMemberFunctionSymbol );
  209877        4475 :           unsigned long positionInPool = localIndex % SgMemberFunctionSymbol::pool_size;
  209878        4475 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMemberFunctionSymbol::pool_size;
  209879             : 
  209880             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  209881             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  209882             : 
  209883        4475 :           returnPointer = &( ( (SgMemberFunctionSymbol*)(SgMemberFunctionSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  209884             : 
  209885        4475 :           ROSE_ASSERT( returnPointer != NULL ) ;
  209886             :         }
  209887        4475 :      return returnPointer ;
  209888             :    }
  209889             : 
  209890             : //############################################################################
  209891             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  209892             :   for the AST with the index astIndex
  209893             : */
  209894           0 : SgMemberFunctionSymbol * SgMemberFunctionSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  209895           0 :      SgMemberFunctionSymbol* returnPointer = NULL;
  209896           0 :      if ( globalIndex != 0 )
  209897             :         {
  209898             : 
  209899             : #if FILE_IO_EXTRA_CHECK
  209900           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgMemberFunctionSymbol ) ) <= globalIndex ) ;
  209901           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMemberFunctionSymbol + 1 ) ) );
  209902             : #endif
  209903           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgMemberFunctionSymbol )
  209904           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgMemberFunctionSymbol );
  209905           0 :           unsigned long positionInPool = localIndex % SgMemberFunctionSymbol::pool_size ;
  209906           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgMemberFunctionSymbol::pool_size ;
  209907             : 
  209908             : #if FILE_IO_EXTRA_CHECK
  209909             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  209910             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  209911             : #endif
  209912             : 
  209913           0 :           returnPointer = &( ( (SgMemberFunctionSymbol*)(SgMemberFunctionSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  209914             : 
  209915             : #if FILE_IO_EXTRA_CHECK
  209916           0 :           assert ( returnPointer != NULL ) ;
  209917             : #endif
  209918             :         }
  209919           0 :      return returnPointer ;
  209920             :    }
  209921             : 
  209922             : //############################################################################
  209923             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  209924             :  * pool size! We set for every valid object in the memory pool the freepointer
  209925             :  * to the global index and increase the global index afterwards. For all the 
  209926             :  * invalid objects (means address ranges within the memory pool that were not
  209927             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  209928             :  * distinguish valid from invalid objects! 
  209929             :  */
  209930             : unsigned long
  209931           5 : SgMemberFunctionSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  209932             :    {
  209933           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  209934           5 :      SgMemberFunctionSymbol* pointer = NULL;
  209935           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  209936           5 :      std::vector < unsigned char* > :: const_iterator block;
  209937           6 :      for ( block = SgMemberFunctionSymbol::pools.begin(); block != SgMemberFunctionSymbol::pools.end() ; ++block )
  209938             :         {
  209939           1 :           pointer = (SgMemberFunctionSymbol*)(*block);
  209940        2001 :           for (unsigned i = 0; i < SgMemberFunctionSymbol::pool_size; ++i )
  209941             :              {
  209942             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  209943             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  209944             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  209945             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  209946             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  209947             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  209948             :             // properly; so this will have to be checked next.
  209949             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  209950             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  209951        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  209952             :                   {
  209953        1953 :                     pointer[i].set_freepointer((SgMemberFunctionSymbol*)(globalIndex));
  209954        1953 :                     globalIndex++;
  209955             :                   }
  209956             :                else
  209957             :                   {
  209958          47 :                     pointer[i].set_freepointer(NULL);
  209959             :                   }
  209960             :               }
  209961             :         }
  209962           5 :      return globalIndex;
  209963             :    }
  209964             : 
  209965             : //############################################################################
  209966             : // JH (01/14/2006)
  209967             : void
  209968           5 : SgMemberFunctionSymbol::resetValidFreepointers( )
  209969             :    {
  209970           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  209971           5 :      SgMemberFunctionSymbol* pointer = NULL;
  209972           5 :      std::vector < unsigned char* > :: const_iterator block;
  209973           5 :      SgMemberFunctionSymbol* pointerOfLinkedList = NULL;
  209974           6 :      for ( block = SgMemberFunctionSymbol::pools.begin(); block != SgMemberFunctionSymbol::pools.end() ; ++block )
  209975             :         {
  209976           1 :           pointer = (SgMemberFunctionSymbol*)(*block);
  209977        2001 :           for (unsigned i = 0; i < SgMemberFunctionSymbol::pool_size; ++i )
  209978             :              {
  209979             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  209980             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  209981             :             // memory blocks!.
  209982        2000 :                if ( pointer[i].get_freepointer() != NULL )
  209983             :                   {
  209984        1953 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  209985             :                   }
  209986             :                else
  209987             :                   {
  209988          47 :                     if ( pointerOfLinkedList == NULL )
  209989             :                        {
  209990           1 :                          SgMemberFunctionSymbol::next_node = &(pointer[i]);
  209991             :                        }
  209992             :                     else
  209993             :                        {
  209994             :                       // printf ("In SgMemberFunctionSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  209995          46 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  209996             :                        }
  209997             :                     pointerOfLinkedList = &(pointer[i]);
  209998             :                   }
  209999             :               }
  210000             :         }
  210001             : 
  210002           5 :      if ( pointerOfLinkedList != NULL )
  210003             :         {
  210004             :        // printf ("In SgMemberFunctionSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  210005           1 :           pointerOfLinkedList->set_freepointer(NULL);
  210006             :        // DQ (6/6/2010): Temporary debugging...
  210007             :        //   ROSE_ASSERT(false);
  210008             :         }
  210009             : 
  210010           5 :      return ;
  210011             :    }
  210012             : 
  210013             : //############################################################################
  210014             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  210015             :  * within the memory pool and resets the freepointers, in order to achieve a 
  210016             :  * linked list, that has no jumps and starts at the beginning! This function 
  210017             :  * does not extend the memory pool, since we do not delete any memory blocks,
  210018             :  * but delete the valid objects.  
  210019             :  */
  210020             : void
  210021           0 : SgMemberFunctionSymbol::clearMemoryPool( )
  210022             :    {
  210023             :   // printf ("Inside of SgMemberFunctionSymbol::clearMemoryPool() \n");
  210024             : 
  210025           0 :      SgMemberFunctionSymbol* pointer = NULL, *tempPointer = NULL;
  210026           0 :      std::vector < unsigned char* > :: const_iterator block;
  210027           0 :      if ( SgMemberFunctionSymbol::pools.empty() == false )
  210028             :         {
  210029           0 :           block = SgMemberFunctionSymbol::pools.begin() ;
  210030           0 :           SgMemberFunctionSymbol::next_node = (SgMemberFunctionSymbol*) (*block);
  210031             : 
  210032           0 :           while ( block != SgMemberFunctionSymbol::pools.end() )
  210033             :              {
  210034           0 :                pointer = (SgMemberFunctionSymbol*) (*block);
  210035           0 :                if ( tempPointer != NULL )
  210036             :                   {
  210037           0 :                     tempPointer->set_freepointer(pointer);
  210038             :                   }
  210039           0 :                for (unsigned i = 0; i < SgMemberFunctionSymbol::pool_size - 1; ++i)
  210040             :                   {
  210041           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  210042             :                   }
  210043           0 :                 pointer[SgMemberFunctionSymbol::pool_size-1].set_freepointer(NULL);
  210044           0 :                 tempPointer = &(pointer[SgMemberFunctionSymbol::pool_size-1]);
  210045           0 :                 ++block;
  210046             :              }
  210047             :         }
  210048           0 :    }
  210049             : 
  210050           5 : void SgMemberFunctionSymbol::deleteMemoryPool() {
  210051           7 :   for (auto p: SgMemberFunctionSymbol::pools) {
  210052           2 :     ROSE_FREE(p);
  210053             :   }
  210054           5 :   SgMemberFunctionSymbol::next_node = nullptr;
  210055           5 :   SgMemberFunctionSymbol::pools.clear();
  210056           5 : }
  210057             : 
  210058             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  210059             : //                 reading multiple binary files to for a single AST.
  210060             : /////////// new version ////////////////////////////////
  210061             : //############################################################################
  210062             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  210063             : void
  210064           2 : SgMemberFunctionSymbol::extendMemoryPoolForFileIO( )
  210065             :   {
  210066           2 :     size_t blockIndex = SgMemberFunctionSymbol::pools.size();
  210067           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionSymbol);
  210068             : 
  210069           3 :     while ( (blockIndex * SgMemberFunctionSymbol::pool_size) < newPoolSize)
  210070             :       {
  210071             : #if ROSE_ALLOC_TRACE
  210072             :         if (blockIndex > 0) {
  210073             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionSymbol) = %" PRIuPTR " SgMemberFunctionSymbol::pool_size = %d \n",
  210074             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgMemberFunctionSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgMemberFunctionSymbol),SgMemberFunctionSymbol::pool_size);
  210075             :         }
  210076             : #endif
  210077             : 
  210078           1 :         SgMemberFunctionSymbol * pointer = (SgMemberFunctionSymbol*) ROSE_MALLOC ( SgMemberFunctionSymbol::pool_size * sizeof(SgMemberFunctionSymbol) );
  210079           1 :         assert( pointer != NULL );
  210080             : #if ROSE_ALLOC_MEMSET == 1
  210081             :         memset(pointer, 0x00, SgMemberFunctionSymbol::pool_size * sizeof(SgMemberFunctionSymbol));
  210082             : #elif ROSE_ALLOC_MEMSET == 2
  210083             :         memset(pointer, 0xCC, SgMemberFunctionSymbol::pool_size * sizeof(SgMemberFunctionSymbol));
  210084             : #endif
  210085           1 :         SgMemberFunctionSymbol::pools.push_back( (unsigned char*)(pointer) );
  210086           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgMemberFunctionSymbol::pool_size * sizeof(SgMemberFunctionSymbol), V_SgMemberFunctionSymbol ) );
  210087             : 
  210088           1 :         if ( SgMemberFunctionSymbol::next_node != NULL ) {
  210089           0 :           if ( blockIndex > 0 ) {
  210090           0 :             SgMemberFunctionSymbol * blkptr = (SgMemberFunctionSymbol*)(SgMemberFunctionSymbol::pools[blockIndex-1]);
  210091           0 :             blkptr[ SgMemberFunctionSymbol::pool_size - 1 ].set_freepointer(pointer);
  210092             :           }
  210093             :         } else {
  210094           1 :           SgMemberFunctionSymbol::next_node = pointer;
  210095             :         }
  210096             : 
  210097        2000 :         for (unsigned i = 0; i < SgMemberFunctionSymbol::pool_size-1; ++i)
  210098             :            {
  210099        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  210100             :            }
  210101           1 :         pointer[ SgMemberFunctionSymbol::pool_size -1 ].set_freepointer(NULL);
  210102             : 
  210103           1 :         blockIndex++;
  210104             :       }
  210105           2 :   }
  210106             : 
  210107             : //############################################################################
  210108             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  210109             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  210110             :  * not compressed. However, that stuff is not yet implemented! 
  210111             :  */
  210112             : unsigned long
  210113           0 : SgMemberFunctionSymbol::getNumberOfLastValidPointer()
  210114             :    {
  210115           0 :       SgMemberFunctionSymbol* testPointer = (SgMemberFunctionSymbol*)(SgMemberFunctionSymbol::pools.back());
  210116           0 :       unsigned long localIndex = SgMemberFunctionSymbol::pool_size - 1;
  210117           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  210118             :          {
  210119           0 :            localIndex--;
  210120             :          }
  210121           0 :       return (localIndex + SgMemberFunctionSymbol::pool_size * (SgMemberFunctionSymbol::pools.size()-1));
  210122             :    }
  210123             : 
  210124             : //############################################################################
  210125             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  210126             :  * memory pool and initializes the data member in class SgMemberFunctionSymbolStroageClass
  210127             :  * from its counterpart of SgMemberFunctionSymbol. The return value is just for checking, 
  210128             :  * that the whole StorageClassArray is initialized!
  210129             :  */
  210130             : unsigned long
  210131           1 : SgMemberFunctionSymbol::initializeStorageClassArray( SgMemberFunctionSymbolStorageClass *storageArray )
  210132             :    {
  210133           1 :      unsigned long storageCounter = 0;
  210134           1 :      std::vector < unsigned char* > :: const_iterator block = SgMemberFunctionSymbol::pools.begin();
  210135           1 :      SgMemberFunctionSymbol* pointer = NULL;
  210136           2 :      while ( block != SgMemberFunctionSymbol::pools.end() ) {
  210137           1 :           pointer = (SgMemberFunctionSymbol*) (*block);
  210138        2001 :           for ( unsigned i = 0; i < SgMemberFunctionSymbol::pool_size; ++i ) {
  210139        2000 :                if ( pointer->get_freepointer() != NULL ) {
  210140        1953 :                  storageArray->pickOutIRNodeData (pointer) ;
  210141        1953 :                  storageArray++;
  210142        1953 :                  storageCounter++;
  210143             :                }
  210144        2000 :                pointer++;
  210145             :              }
  210146           1 :            block++;
  210147             :         }
  210148           1 :      return storageCounter;
  210149             :    }
  210150             : 
  210151             : /* #line 210152 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  210152             : 
  210153             : 
  210154             : 
  210155             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  210156             : 
  210157             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  210158             : 
  210159             : //############################################################################
  210160             : /* JH (02/02/2006) Constructor of the IR node SgTemplateMemberFunctionSymbol that takes its 
  210161             :  * corresponding StorageClass as parameter
  210162             :  */
  210163        1047 : SgTemplateMemberFunctionSymbol :: SgTemplateMemberFunctionSymbol ( const SgTemplateMemberFunctionSymbolStorageClass& storageSource )   : SgMemberFunctionSymbol (storageSource)
  210164             :    {
  210165             : 
  210166             : 
  210167             : /* #line 210168 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  210168             : 
  210169        1047 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  210170             : 
  210171             : 
  210172             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  210173             : 
  210174             : 
  210175        1047 :    }
  210176             : 
  210177             : //############################################################################
  210178             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  210179             :  * within the working AST. 
  210180             :  */
  210181        2015 : SgTemplateMemberFunctionSymbol * SgTemplateMemberFunctionSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  210182        2015 :      SgTemplateMemberFunctionSymbol* returnPointer = NULL;
  210183        2015 :      if ( globalIndex != 0 )
  210184             :         {
  210185             : 
  210186             : #if FILE_IO_EXTRA_CHECK
  210187        2015 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateMemberFunctionSymbol ) ) <= globalIndex ) ;
  210188        2015 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateMemberFunctionSymbol + 1 ) ) );
  210189             : #endif
  210190        2015 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateMemberFunctionSymbol )  
  210191        2015 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateMemberFunctionSymbol );
  210192        2015 :           unsigned long positionInPool = localIndex % SgTemplateMemberFunctionSymbol::pool_size;
  210193        2015 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateMemberFunctionSymbol::pool_size;
  210194             : 
  210195             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  210196             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  210197             : 
  210198        2015 :           returnPointer = &( ( (SgTemplateMemberFunctionSymbol*)(SgTemplateMemberFunctionSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  210199             : 
  210200        2015 :           ROSE_ASSERT( returnPointer != NULL ) ;
  210201             :         }
  210202        2015 :      return returnPointer ;
  210203             :    }
  210204             : 
  210205             : //############################################################################
  210206             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  210207             :   for the AST with the index astIndex
  210208             : */
  210209           0 : SgTemplateMemberFunctionSymbol * SgTemplateMemberFunctionSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  210210           0 :      SgTemplateMemberFunctionSymbol* returnPointer = NULL;
  210211           0 :      if ( globalIndex != 0 )
  210212             :         {
  210213             : 
  210214             : #if FILE_IO_EXTRA_CHECK
  210215           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateMemberFunctionSymbol ) ) <= globalIndex ) ;
  210216           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateMemberFunctionSymbol + 1 ) ) );
  210217             : #endif
  210218           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateMemberFunctionSymbol )
  210219           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateMemberFunctionSymbol );
  210220           0 :           unsigned long positionInPool = localIndex % SgTemplateMemberFunctionSymbol::pool_size ;
  210221           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateMemberFunctionSymbol::pool_size ;
  210222             : 
  210223             : #if FILE_IO_EXTRA_CHECK
  210224             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  210225             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  210226             : #endif
  210227             : 
  210228           0 :           returnPointer = &( ( (SgTemplateMemberFunctionSymbol*)(SgTemplateMemberFunctionSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  210229             : 
  210230             : #if FILE_IO_EXTRA_CHECK
  210231           0 :           assert ( returnPointer != NULL ) ;
  210232             : #endif
  210233             :         }
  210234           0 :      return returnPointer ;
  210235             :    }
  210236             : 
  210237             : //############################################################################
  210238             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  210239             :  * pool size! We set for every valid object in the memory pool the freepointer
  210240             :  * to the global index and increase the global index afterwards. For all the 
  210241             :  * invalid objects (means address ranges within the memory pool that were not
  210242             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  210243             :  * distinguish valid from invalid objects! 
  210244             :  */
  210245             : unsigned long
  210246           5 : SgTemplateMemberFunctionSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  210247             :    {
  210248           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  210249           5 :      SgTemplateMemberFunctionSymbol* pointer = NULL;
  210250           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  210251           5 :      std::vector < unsigned char* > :: const_iterator block;
  210252           6 :      for ( block = SgTemplateMemberFunctionSymbol::pools.begin(); block != SgTemplateMemberFunctionSymbol::pools.end() ; ++block )
  210253             :         {
  210254           1 :           pointer = (SgTemplateMemberFunctionSymbol*)(*block);
  210255        2001 :           for (unsigned i = 0; i < SgTemplateMemberFunctionSymbol::pool_size; ++i )
  210256             :              {
  210257             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  210258             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  210259             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  210260             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  210261             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  210262             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  210263             :             // properly; so this will have to be checked next.
  210264             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  210265             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  210266        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  210267             :                   {
  210268        1047 :                     pointer[i].set_freepointer((SgTemplateMemberFunctionSymbol*)(globalIndex));
  210269        1047 :                     globalIndex++;
  210270             :                   }
  210271             :                else
  210272             :                   {
  210273         953 :                     pointer[i].set_freepointer(NULL);
  210274             :                   }
  210275             :               }
  210276             :         }
  210277           5 :      return globalIndex;
  210278             :    }
  210279             : 
  210280             : //############################################################################
  210281             : // JH (01/14/2006)
  210282             : void
  210283           5 : SgTemplateMemberFunctionSymbol::resetValidFreepointers( )
  210284             :    {
  210285           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  210286           5 :      SgTemplateMemberFunctionSymbol* pointer = NULL;
  210287           5 :      std::vector < unsigned char* > :: const_iterator block;
  210288           5 :      SgTemplateMemberFunctionSymbol* pointerOfLinkedList = NULL;
  210289           6 :      for ( block = SgTemplateMemberFunctionSymbol::pools.begin(); block != SgTemplateMemberFunctionSymbol::pools.end() ; ++block )
  210290             :         {
  210291           1 :           pointer = (SgTemplateMemberFunctionSymbol*)(*block);
  210292        2001 :           for (unsigned i = 0; i < SgTemplateMemberFunctionSymbol::pool_size; ++i )
  210293             :              {
  210294             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  210295             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  210296             :             // memory blocks!.
  210297        2000 :                if ( pointer[i].get_freepointer() != NULL )
  210298             :                   {
  210299        1047 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  210300             :                   }
  210301             :                else
  210302             :                   {
  210303         953 :                     if ( pointerOfLinkedList == NULL )
  210304             :                        {
  210305           1 :                          SgTemplateMemberFunctionSymbol::next_node = &(pointer[i]);
  210306             :                        }
  210307             :                     else
  210308             :                        {
  210309             :                       // printf ("In SgTemplateMemberFunctionSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  210310         952 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  210311             :                        }
  210312             :                     pointerOfLinkedList = &(pointer[i]);
  210313             :                   }
  210314             :               }
  210315             :         }
  210316             : 
  210317           5 :      if ( pointerOfLinkedList != NULL )
  210318             :         {
  210319             :        // printf ("In SgTemplateMemberFunctionSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  210320           1 :           pointerOfLinkedList->set_freepointer(NULL);
  210321             :        // DQ (6/6/2010): Temporary debugging...
  210322             :        //   ROSE_ASSERT(false);
  210323             :         }
  210324             : 
  210325           5 :      return ;
  210326             :    }
  210327             : 
  210328             : //############################################################################
  210329             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  210330             :  * within the memory pool and resets the freepointers, in order to achieve a 
  210331             :  * linked list, that has no jumps and starts at the beginning! This function 
  210332             :  * does not extend the memory pool, since we do not delete any memory blocks,
  210333             :  * but delete the valid objects.  
  210334             :  */
  210335             : void
  210336           0 : SgTemplateMemberFunctionSymbol::clearMemoryPool( )
  210337             :    {
  210338             :   // printf ("Inside of SgTemplateMemberFunctionSymbol::clearMemoryPool() \n");
  210339             : 
  210340           0 :      SgTemplateMemberFunctionSymbol* pointer = NULL, *tempPointer = NULL;
  210341           0 :      std::vector < unsigned char* > :: const_iterator block;
  210342           0 :      if ( SgTemplateMemberFunctionSymbol::pools.empty() == false )
  210343             :         {
  210344           0 :           block = SgTemplateMemberFunctionSymbol::pools.begin() ;
  210345           0 :           SgTemplateMemberFunctionSymbol::next_node = (SgTemplateMemberFunctionSymbol*) (*block);
  210346             : 
  210347           0 :           while ( block != SgTemplateMemberFunctionSymbol::pools.end() )
  210348             :              {
  210349           0 :                pointer = (SgTemplateMemberFunctionSymbol*) (*block);
  210350           0 :                if ( tempPointer != NULL )
  210351             :                   {
  210352           0 :                     tempPointer->set_freepointer(pointer);
  210353             :                   }
  210354           0 :                for (unsigned i = 0; i < SgTemplateMemberFunctionSymbol::pool_size - 1; ++i)
  210355             :                   {
  210356           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  210357             :                   }
  210358           0 :                 pointer[SgTemplateMemberFunctionSymbol::pool_size-1].set_freepointer(NULL);
  210359           0 :                 tempPointer = &(pointer[SgTemplateMemberFunctionSymbol::pool_size-1]);
  210360           0 :                 ++block;
  210361             :              }
  210362             :         }
  210363           0 :    }
  210364             : 
  210365           5 : void SgTemplateMemberFunctionSymbol::deleteMemoryPool() {
  210366           7 :   for (auto p: SgTemplateMemberFunctionSymbol::pools) {
  210367           2 :     ROSE_FREE(p);
  210368             :   }
  210369           5 :   SgTemplateMemberFunctionSymbol::next_node = nullptr;
  210370           5 :   SgTemplateMemberFunctionSymbol::pools.clear();
  210371           5 : }
  210372             : 
  210373             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  210374             : //                 reading multiple binary files to for a single AST.
  210375             : /////////// new version ////////////////////////////////
  210376             : //############################################################################
  210377             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  210378             : void
  210379           2 : SgTemplateMemberFunctionSymbol::extendMemoryPoolForFileIO( )
  210380             :   {
  210381           2 :     size_t blockIndex = SgTemplateMemberFunctionSymbol::pools.size();
  210382           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionSymbol);
  210383             : 
  210384           3 :     while ( (blockIndex * SgTemplateMemberFunctionSymbol::pool_size) < newPoolSize)
  210385             :       {
  210386             : #if ROSE_ALLOC_TRACE
  210387             :         if (blockIndex > 0) {
  210388             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionSymbol) = %" PRIuPTR " SgTemplateMemberFunctionSymbol::pool_size = %d \n",
  210389             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateMemberFunctionSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateMemberFunctionSymbol),SgTemplateMemberFunctionSymbol::pool_size);
  210390             :         }
  210391             : #endif
  210392             : 
  210393           1 :         SgTemplateMemberFunctionSymbol * pointer = (SgTemplateMemberFunctionSymbol*) ROSE_MALLOC ( SgTemplateMemberFunctionSymbol::pool_size * sizeof(SgTemplateMemberFunctionSymbol) );
  210394           1 :         assert( pointer != NULL );
  210395             : #if ROSE_ALLOC_MEMSET == 1
  210396             :         memset(pointer, 0x00, SgTemplateMemberFunctionSymbol::pool_size * sizeof(SgTemplateMemberFunctionSymbol));
  210397             : #elif ROSE_ALLOC_MEMSET == 2
  210398             :         memset(pointer, 0xCC, SgTemplateMemberFunctionSymbol::pool_size * sizeof(SgTemplateMemberFunctionSymbol));
  210399             : #endif
  210400           1 :         SgTemplateMemberFunctionSymbol::pools.push_back( (unsigned char*)(pointer) );
  210401           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateMemberFunctionSymbol::pool_size * sizeof(SgTemplateMemberFunctionSymbol), V_SgTemplateMemberFunctionSymbol ) );
  210402             : 
  210403           1 :         if ( SgTemplateMemberFunctionSymbol::next_node != NULL ) {
  210404           0 :           if ( blockIndex > 0 ) {
  210405           0 :             SgTemplateMemberFunctionSymbol * blkptr = (SgTemplateMemberFunctionSymbol*)(SgTemplateMemberFunctionSymbol::pools[blockIndex-1]);
  210406           0 :             blkptr[ SgTemplateMemberFunctionSymbol::pool_size - 1 ].set_freepointer(pointer);
  210407             :           }
  210408             :         } else {
  210409           1 :           SgTemplateMemberFunctionSymbol::next_node = pointer;
  210410             :         }
  210411             : 
  210412        2000 :         for (unsigned i = 0; i < SgTemplateMemberFunctionSymbol::pool_size-1; ++i)
  210413             :            {
  210414        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  210415             :            }
  210416           1 :         pointer[ SgTemplateMemberFunctionSymbol::pool_size -1 ].set_freepointer(NULL);
  210417             : 
  210418           1 :         blockIndex++;
  210419             :       }
  210420           2 :   }
  210421             : 
  210422             : //############################################################################
  210423             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  210424             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  210425             :  * not compressed. However, that stuff is not yet implemented! 
  210426             :  */
  210427             : unsigned long
  210428           0 : SgTemplateMemberFunctionSymbol::getNumberOfLastValidPointer()
  210429             :    {
  210430           0 :       SgTemplateMemberFunctionSymbol* testPointer = (SgTemplateMemberFunctionSymbol*)(SgTemplateMemberFunctionSymbol::pools.back());
  210431           0 :       unsigned long localIndex = SgTemplateMemberFunctionSymbol::pool_size - 1;
  210432           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  210433             :          {
  210434           0 :            localIndex--;
  210435             :          }
  210436           0 :       return (localIndex + SgTemplateMemberFunctionSymbol::pool_size * (SgTemplateMemberFunctionSymbol::pools.size()-1));
  210437             :    }
  210438             : 
  210439             : //############################################################################
  210440             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  210441             :  * memory pool and initializes the data member in class SgTemplateMemberFunctionSymbolStroageClass
  210442             :  * from its counterpart of SgTemplateMemberFunctionSymbol. The return value is just for checking, 
  210443             :  * that the whole StorageClassArray is initialized!
  210444             :  */
  210445             : unsigned long
  210446           1 : SgTemplateMemberFunctionSymbol::initializeStorageClassArray( SgTemplateMemberFunctionSymbolStorageClass *storageArray )
  210447             :    {
  210448           1 :      unsigned long storageCounter = 0;
  210449           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateMemberFunctionSymbol::pools.begin();
  210450           1 :      SgTemplateMemberFunctionSymbol* pointer = NULL;
  210451           2 :      while ( block != SgTemplateMemberFunctionSymbol::pools.end() ) {
  210452           1 :           pointer = (SgTemplateMemberFunctionSymbol*) (*block);
  210453        2001 :           for ( unsigned i = 0; i < SgTemplateMemberFunctionSymbol::pool_size; ++i ) {
  210454        2000 :                if ( pointer->get_freepointer() != NULL ) {
  210455        1047 :                  storageArray->pickOutIRNodeData (pointer) ;
  210456        1047 :                  storageArray++;
  210457        1047 :                  storageCounter++;
  210458             :                }
  210459        2000 :                pointer++;
  210460             :              }
  210461           1 :            block++;
  210462             :         }
  210463           1 :      return storageCounter;
  210464             :    }
  210465             : 
  210466             : /* #line 210467 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  210467             : 
  210468             : 
  210469             : 
  210470             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  210471             : 
  210472             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  210473             : 
  210474             : //############################################################################
  210475             : /* JH (02/02/2006) Constructor of the IR node SgTemplateFunctionSymbol that takes its 
  210476             :  * corresponding StorageClass as parameter
  210477             :  */
  210478         340 : SgTemplateFunctionSymbol :: SgTemplateFunctionSymbol ( const SgTemplateFunctionSymbolStorageClass& storageSource )   : SgFunctionSymbol (storageSource)
  210479             :    {
  210480             : 
  210481             : 
  210482             : /* #line 210483 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  210483             : 
  210484         340 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  210485             : 
  210486             : 
  210487             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  210488             : 
  210489             : 
  210490         340 :    }
  210491             : 
  210492             : //############################################################################
  210493             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  210494             :  * within the working AST. 
  210495             :  */
  210496         904 : SgTemplateFunctionSymbol * SgTemplateFunctionSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  210497         904 :      SgTemplateFunctionSymbol* returnPointer = NULL;
  210498         904 :      if ( globalIndex != 0 )
  210499             :         {
  210500             : 
  210501             : #if FILE_IO_EXTRA_CHECK
  210502         904 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateFunctionSymbol ) ) <= globalIndex ) ;
  210503         904 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateFunctionSymbol + 1 ) ) );
  210504             : #endif
  210505         904 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateFunctionSymbol )  
  210506         904 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateFunctionSymbol );
  210507         904 :           unsigned long positionInPool = localIndex % SgTemplateFunctionSymbol::pool_size;
  210508         904 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateFunctionSymbol::pool_size;
  210509             : 
  210510             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  210511             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  210512             : 
  210513         904 :           returnPointer = &( ( (SgTemplateFunctionSymbol*)(SgTemplateFunctionSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  210514             : 
  210515         904 :           ROSE_ASSERT( returnPointer != NULL ) ;
  210516             :         }
  210517         904 :      return returnPointer ;
  210518             :    }
  210519             : 
  210520             : //############################################################################
  210521             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  210522             :   for the AST with the index astIndex
  210523             : */
  210524           0 : SgTemplateFunctionSymbol * SgTemplateFunctionSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  210525           0 :      SgTemplateFunctionSymbol* returnPointer = NULL;
  210526           0 :      if ( globalIndex != 0 )
  210527             :         {
  210528             : 
  210529             : #if FILE_IO_EXTRA_CHECK
  210530           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateFunctionSymbol ) ) <= globalIndex ) ;
  210531           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateFunctionSymbol + 1 ) ) );
  210532             : #endif
  210533           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateFunctionSymbol )
  210534           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateFunctionSymbol );
  210535           0 :           unsigned long positionInPool = localIndex % SgTemplateFunctionSymbol::pool_size ;
  210536           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateFunctionSymbol::pool_size ;
  210537             : 
  210538             : #if FILE_IO_EXTRA_CHECK
  210539             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  210540             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  210541             : #endif
  210542             : 
  210543           0 :           returnPointer = &( ( (SgTemplateFunctionSymbol*)(SgTemplateFunctionSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  210544             : 
  210545             : #if FILE_IO_EXTRA_CHECK
  210546           0 :           assert ( returnPointer != NULL ) ;
  210547             : #endif
  210548             :         }
  210549           0 :      return returnPointer ;
  210550             :    }
  210551             : 
  210552             : //############################################################################
  210553             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  210554             :  * pool size! We set for every valid object in the memory pool the freepointer
  210555             :  * to the global index and increase the global index afterwards. For all the 
  210556             :  * invalid objects (means address ranges within the memory pool that were not
  210557             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  210558             :  * distinguish valid from invalid objects! 
  210559             :  */
  210560             : unsigned long
  210561           5 : SgTemplateFunctionSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  210562             :    {
  210563           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  210564           5 :      SgTemplateFunctionSymbol* pointer = NULL;
  210565           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  210566           5 :      std::vector < unsigned char* > :: const_iterator block;
  210567           6 :      for ( block = SgTemplateFunctionSymbol::pools.begin(); block != SgTemplateFunctionSymbol::pools.end() ; ++block )
  210568             :         {
  210569           1 :           pointer = (SgTemplateFunctionSymbol*)(*block);
  210570        2001 :           for (unsigned i = 0; i < SgTemplateFunctionSymbol::pool_size; ++i )
  210571             :              {
  210572             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  210573             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  210574             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  210575             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  210576             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  210577             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  210578             :             // properly; so this will have to be checked next.
  210579             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  210580             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  210581        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  210582             :                   {
  210583         340 :                     pointer[i].set_freepointer((SgTemplateFunctionSymbol*)(globalIndex));
  210584         340 :                     globalIndex++;
  210585             :                   }
  210586             :                else
  210587             :                   {
  210588        1660 :                     pointer[i].set_freepointer(NULL);
  210589             :                   }
  210590             :               }
  210591             :         }
  210592           5 :      return globalIndex;
  210593             :    }
  210594             : 
  210595             : //############################################################################
  210596             : // JH (01/14/2006)
  210597             : void
  210598           5 : SgTemplateFunctionSymbol::resetValidFreepointers( )
  210599             :    {
  210600           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  210601           5 :      SgTemplateFunctionSymbol* pointer = NULL;
  210602           5 :      std::vector < unsigned char* > :: const_iterator block;
  210603           5 :      SgTemplateFunctionSymbol* pointerOfLinkedList = NULL;
  210604           6 :      for ( block = SgTemplateFunctionSymbol::pools.begin(); block != SgTemplateFunctionSymbol::pools.end() ; ++block )
  210605             :         {
  210606           1 :           pointer = (SgTemplateFunctionSymbol*)(*block);
  210607        2001 :           for (unsigned i = 0; i < SgTemplateFunctionSymbol::pool_size; ++i )
  210608             :              {
  210609             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  210610             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  210611             :             // memory blocks!.
  210612        2000 :                if ( pointer[i].get_freepointer() != NULL )
  210613             :                   {
  210614         340 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  210615             :                   }
  210616             :                else
  210617             :                   {
  210618        1660 :                     if ( pointerOfLinkedList == NULL )
  210619             :                        {
  210620           1 :                          SgTemplateFunctionSymbol::next_node = &(pointer[i]);
  210621             :                        }
  210622             :                     else
  210623             :                        {
  210624             :                       // printf ("In SgTemplateFunctionSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  210625        1659 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  210626             :                        }
  210627             :                     pointerOfLinkedList = &(pointer[i]);
  210628             :                   }
  210629             :               }
  210630             :         }
  210631             : 
  210632           5 :      if ( pointerOfLinkedList != NULL )
  210633             :         {
  210634             :        // printf ("In SgTemplateFunctionSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  210635           1 :           pointerOfLinkedList->set_freepointer(NULL);
  210636             :        // DQ (6/6/2010): Temporary debugging...
  210637             :        //   ROSE_ASSERT(false);
  210638             :         }
  210639             : 
  210640           5 :      return ;
  210641             :    }
  210642             : 
  210643             : //############################################################################
  210644             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  210645             :  * within the memory pool and resets the freepointers, in order to achieve a 
  210646             :  * linked list, that has no jumps and starts at the beginning! This function 
  210647             :  * does not extend the memory pool, since we do not delete any memory blocks,
  210648             :  * but delete the valid objects.  
  210649             :  */
  210650             : void
  210651           0 : SgTemplateFunctionSymbol::clearMemoryPool( )
  210652             :    {
  210653             :   // printf ("Inside of SgTemplateFunctionSymbol::clearMemoryPool() \n");
  210654             : 
  210655           0 :      SgTemplateFunctionSymbol* pointer = NULL, *tempPointer = NULL;
  210656           0 :      std::vector < unsigned char* > :: const_iterator block;
  210657           0 :      if ( SgTemplateFunctionSymbol::pools.empty() == false )
  210658             :         {
  210659           0 :           block = SgTemplateFunctionSymbol::pools.begin() ;
  210660           0 :           SgTemplateFunctionSymbol::next_node = (SgTemplateFunctionSymbol*) (*block);
  210661             : 
  210662           0 :           while ( block != SgTemplateFunctionSymbol::pools.end() )
  210663             :              {
  210664           0 :                pointer = (SgTemplateFunctionSymbol*) (*block);
  210665           0 :                if ( tempPointer != NULL )
  210666             :                   {
  210667           0 :                     tempPointer->set_freepointer(pointer);
  210668             :                   }
  210669           0 :                for (unsigned i = 0; i < SgTemplateFunctionSymbol::pool_size - 1; ++i)
  210670             :                   {
  210671           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  210672             :                   }
  210673           0 :                 pointer[SgTemplateFunctionSymbol::pool_size-1].set_freepointer(NULL);
  210674           0 :                 tempPointer = &(pointer[SgTemplateFunctionSymbol::pool_size-1]);
  210675           0 :                 ++block;
  210676             :              }
  210677             :         }
  210678           0 :    }
  210679             : 
  210680           5 : void SgTemplateFunctionSymbol::deleteMemoryPool() {
  210681           7 :   for (auto p: SgTemplateFunctionSymbol::pools) {
  210682           2 :     ROSE_FREE(p);
  210683             :   }
  210684           5 :   SgTemplateFunctionSymbol::next_node = nullptr;
  210685           5 :   SgTemplateFunctionSymbol::pools.clear();
  210686           5 : }
  210687             : 
  210688             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  210689             : //                 reading multiple binary files to for a single AST.
  210690             : /////////// new version ////////////////////////////////
  210691             : //############################################################################
  210692             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  210693             : void
  210694           2 : SgTemplateFunctionSymbol::extendMemoryPoolForFileIO( )
  210695             :   {
  210696           2 :     size_t blockIndex = SgTemplateFunctionSymbol::pools.size();
  210697           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionSymbol);
  210698             : 
  210699           3 :     while ( (blockIndex * SgTemplateFunctionSymbol::pool_size) < newPoolSize)
  210700             :       {
  210701             : #if ROSE_ALLOC_TRACE
  210702             :         if (blockIndex > 0) {
  210703             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionSymbol) = %" PRIuPTR " SgTemplateFunctionSymbol::pool_size = %d \n",
  210704             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateFunctionSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateFunctionSymbol),SgTemplateFunctionSymbol::pool_size);
  210705             :         }
  210706             : #endif
  210707             : 
  210708           1 :         SgTemplateFunctionSymbol * pointer = (SgTemplateFunctionSymbol*) ROSE_MALLOC ( SgTemplateFunctionSymbol::pool_size * sizeof(SgTemplateFunctionSymbol) );
  210709           1 :         assert( pointer != NULL );
  210710             : #if ROSE_ALLOC_MEMSET == 1
  210711             :         memset(pointer, 0x00, SgTemplateFunctionSymbol::pool_size * sizeof(SgTemplateFunctionSymbol));
  210712             : #elif ROSE_ALLOC_MEMSET == 2
  210713             :         memset(pointer, 0xCC, SgTemplateFunctionSymbol::pool_size * sizeof(SgTemplateFunctionSymbol));
  210714             : #endif
  210715           1 :         SgTemplateFunctionSymbol::pools.push_back( (unsigned char*)(pointer) );
  210716           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateFunctionSymbol::pool_size * sizeof(SgTemplateFunctionSymbol), V_SgTemplateFunctionSymbol ) );
  210717             : 
  210718           1 :         if ( SgTemplateFunctionSymbol::next_node != NULL ) {
  210719           0 :           if ( blockIndex > 0 ) {
  210720           0 :             SgTemplateFunctionSymbol * blkptr = (SgTemplateFunctionSymbol*)(SgTemplateFunctionSymbol::pools[blockIndex-1]);
  210721           0 :             blkptr[ SgTemplateFunctionSymbol::pool_size - 1 ].set_freepointer(pointer);
  210722             :           }
  210723             :         } else {
  210724           1 :           SgTemplateFunctionSymbol::next_node = pointer;
  210725             :         }
  210726             : 
  210727        2000 :         for (unsigned i = 0; i < SgTemplateFunctionSymbol::pool_size-1; ++i)
  210728             :            {
  210729        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  210730             :            }
  210731           1 :         pointer[ SgTemplateFunctionSymbol::pool_size -1 ].set_freepointer(NULL);
  210732             : 
  210733           1 :         blockIndex++;
  210734             :       }
  210735           2 :   }
  210736             : 
  210737             : //############################################################################
  210738             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  210739             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  210740             :  * not compressed. However, that stuff is not yet implemented! 
  210741             :  */
  210742             : unsigned long
  210743           0 : SgTemplateFunctionSymbol::getNumberOfLastValidPointer()
  210744             :    {
  210745           0 :       SgTemplateFunctionSymbol* testPointer = (SgTemplateFunctionSymbol*)(SgTemplateFunctionSymbol::pools.back());
  210746           0 :       unsigned long localIndex = SgTemplateFunctionSymbol::pool_size - 1;
  210747           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  210748             :          {
  210749           0 :            localIndex--;
  210750             :          }
  210751           0 :       return (localIndex + SgTemplateFunctionSymbol::pool_size * (SgTemplateFunctionSymbol::pools.size()-1));
  210752             :    }
  210753             : 
  210754             : //############################################################################
  210755             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  210756             :  * memory pool and initializes the data member in class SgTemplateFunctionSymbolStroageClass
  210757             :  * from its counterpart of SgTemplateFunctionSymbol. The return value is just for checking, 
  210758             :  * that the whole StorageClassArray is initialized!
  210759             :  */
  210760             : unsigned long
  210761           1 : SgTemplateFunctionSymbol::initializeStorageClassArray( SgTemplateFunctionSymbolStorageClass *storageArray )
  210762             :    {
  210763           1 :      unsigned long storageCounter = 0;
  210764           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateFunctionSymbol::pools.begin();
  210765           1 :      SgTemplateFunctionSymbol* pointer = NULL;
  210766           2 :      while ( block != SgTemplateFunctionSymbol::pools.end() ) {
  210767           1 :           pointer = (SgTemplateFunctionSymbol*) (*block);
  210768        2001 :           for ( unsigned i = 0; i < SgTemplateFunctionSymbol::pool_size; ++i ) {
  210769        2000 :                if ( pointer->get_freepointer() != NULL ) {
  210770         340 :                  storageArray->pickOutIRNodeData (pointer) ;
  210771         340 :                  storageArray++;
  210772         340 :                  storageCounter++;
  210773             :                }
  210774        2000 :                pointer++;
  210775             :              }
  210776           1 :            block++;
  210777             :         }
  210778           1 :      return storageCounter;
  210779             :    }
  210780             : 
  210781             : /* #line 210782 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  210782             : 
  210783             : 
  210784             : 
  210785             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  210786             : 
  210787             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  210788             : 
  210789             : //############################################################################
  210790             : /* JH (02/02/2006) Constructor of the IR node SgRenameSymbol that takes its 
  210791             :  * corresponding StorageClass as parameter
  210792             :  */
  210793           0 : SgRenameSymbol :: SgRenameSymbol ( const SgRenameSymbolStorageClass& storageSource )   : SgFunctionSymbol (storageSource)
  210794             :    {
  210795             : 
  210796             : 
  210797             : /* #line 210798 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  210798             : 
  210799           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  210800           0 :      p_original_symbol =  (SgSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_original_symbol) );
  210801           0 :      p_new_name = SgName ( storageSource.storageOf_new_name ) ;
  210802             : 
  210803             : 
  210804             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  210805             : 
  210806             : 
  210807           0 :    }
  210808             : 
  210809             : //############################################################################
  210810             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  210811             :  * within the working AST. 
  210812             :  */
  210813           0 : SgRenameSymbol * SgRenameSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  210814           0 :      SgRenameSymbol* returnPointer = NULL;
  210815           0 :      if ( globalIndex != 0 )
  210816             :         {
  210817             : 
  210818             : #if FILE_IO_EXTRA_CHECK
  210819           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgRenameSymbol ) ) <= globalIndex ) ;
  210820           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRenameSymbol + 1 ) ) );
  210821             : #endif
  210822           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgRenameSymbol )  
  210823           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgRenameSymbol );
  210824           0 :           unsigned long positionInPool = localIndex % SgRenameSymbol::pool_size;
  210825           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRenameSymbol::pool_size;
  210826             : 
  210827             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  210828             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  210829             : 
  210830           0 :           returnPointer = &( ( (SgRenameSymbol*)(SgRenameSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  210831             : 
  210832           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  210833             :         }
  210834           0 :      return returnPointer ;
  210835             :    }
  210836             : 
  210837             : //############################################################################
  210838             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  210839             :   for the AST with the index astIndex
  210840             : */
  210841           0 : SgRenameSymbol * SgRenameSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  210842           0 :      SgRenameSymbol* returnPointer = NULL;
  210843           0 :      if ( globalIndex != 0 )
  210844             :         {
  210845             : 
  210846             : #if FILE_IO_EXTRA_CHECK
  210847           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgRenameSymbol ) ) <= globalIndex ) ;
  210848           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRenameSymbol + 1 ) ) );
  210849             : #endif
  210850           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgRenameSymbol )
  210851           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgRenameSymbol );
  210852           0 :           unsigned long positionInPool = localIndex % SgRenameSymbol::pool_size ;
  210853           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgRenameSymbol::pool_size ;
  210854             : 
  210855             : #if FILE_IO_EXTRA_CHECK
  210856             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  210857             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  210858             : #endif
  210859             : 
  210860           0 :           returnPointer = &( ( (SgRenameSymbol*)(SgRenameSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  210861             : 
  210862             : #if FILE_IO_EXTRA_CHECK
  210863           0 :           assert ( returnPointer != NULL ) ;
  210864             : #endif
  210865             :         }
  210866           0 :      return returnPointer ;
  210867             :    }
  210868             : 
  210869             : //############################################################################
  210870             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  210871             :  * pool size! We set for every valid object in the memory pool the freepointer
  210872             :  * to the global index and increase the global index afterwards. For all the 
  210873             :  * invalid objects (means address ranges within the memory pool that were not
  210874             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  210875             :  * distinguish valid from invalid objects! 
  210876             :  */
  210877             : unsigned long
  210878           5 : SgRenameSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  210879             :    {
  210880           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  210881           5 :      SgRenameSymbol* pointer = NULL;
  210882           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  210883           5 :      std::vector < unsigned char* > :: const_iterator block;
  210884           5 :      for ( block = SgRenameSymbol::pools.begin(); block != SgRenameSymbol::pools.end() ; ++block )
  210885             :         {
  210886           0 :           pointer = (SgRenameSymbol*)(*block);
  210887           0 :           for (unsigned i = 0; i < SgRenameSymbol::pool_size; ++i )
  210888             :              {
  210889             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  210890             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  210891             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  210892             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  210893             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  210894             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  210895             :             // properly; so this will have to be checked next.
  210896             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  210897             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  210898           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  210899             :                   {
  210900           0 :                     pointer[i].set_freepointer((SgRenameSymbol*)(globalIndex));
  210901           0 :                     globalIndex++;
  210902             :                   }
  210903             :                else
  210904             :                   {
  210905           0 :                     pointer[i].set_freepointer(NULL);
  210906             :                   }
  210907             :               }
  210908             :         }
  210909           5 :      return globalIndex;
  210910             :    }
  210911             : 
  210912             : //############################################################################
  210913             : // JH (01/14/2006)
  210914             : void
  210915           5 : SgRenameSymbol::resetValidFreepointers( )
  210916             :    {
  210917           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  210918           5 :      SgRenameSymbol* pointer = NULL;
  210919           5 :      std::vector < unsigned char* > :: const_iterator block;
  210920           5 :      SgRenameSymbol* pointerOfLinkedList = NULL;
  210921           5 :      for ( block = SgRenameSymbol::pools.begin(); block != SgRenameSymbol::pools.end() ; ++block )
  210922             :         {
  210923           0 :           pointer = (SgRenameSymbol*)(*block);
  210924           0 :           for (unsigned i = 0; i < SgRenameSymbol::pool_size; ++i )
  210925             :              {
  210926             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  210927             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  210928             :             // memory blocks!.
  210929           0 :                if ( pointer[i].get_freepointer() != NULL )
  210930             :                   {
  210931           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  210932             :                   }
  210933             :                else
  210934             :                   {
  210935           0 :                     if ( pointerOfLinkedList == NULL )
  210936             :                        {
  210937           0 :                          SgRenameSymbol::next_node = &(pointer[i]);
  210938             :                        }
  210939             :                     else
  210940             :                        {
  210941             :                       // printf ("In SgRenameSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  210942           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  210943             :                        }
  210944             :                     pointerOfLinkedList = &(pointer[i]);
  210945             :                   }
  210946             :               }
  210947             :         }
  210948             : 
  210949           5 :      if ( pointerOfLinkedList != NULL )
  210950             :         {
  210951             :        // printf ("In SgRenameSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  210952           0 :           pointerOfLinkedList->set_freepointer(NULL);
  210953             :        // DQ (6/6/2010): Temporary debugging...
  210954             :        //   ROSE_ASSERT(false);
  210955             :         }
  210956             : 
  210957           5 :      return ;
  210958             :    }
  210959             : 
  210960             : //############################################################################
  210961             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  210962             :  * within the memory pool and resets the freepointers, in order to achieve a 
  210963             :  * linked list, that has no jumps and starts at the beginning! This function 
  210964             :  * does not extend the memory pool, since we do not delete any memory blocks,
  210965             :  * but delete the valid objects.  
  210966             :  */
  210967             : void
  210968           0 : SgRenameSymbol::clearMemoryPool( )
  210969             :    {
  210970             :   // printf ("Inside of SgRenameSymbol::clearMemoryPool() \n");
  210971             : 
  210972           0 :      SgRenameSymbol* pointer = NULL, *tempPointer = NULL;
  210973           0 :      std::vector < unsigned char* > :: const_iterator block;
  210974           0 :      if ( SgRenameSymbol::pools.empty() == false )
  210975             :         {
  210976           0 :           block = SgRenameSymbol::pools.begin() ;
  210977           0 :           SgRenameSymbol::next_node = (SgRenameSymbol*) (*block);
  210978             : 
  210979           0 :           while ( block != SgRenameSymbol::pools.end() )
  210980             :              {
  210981           0 :                pointer = (SgRenameSymbol*) (*block);
  210982           0 :                if ( tempPointer != NULL )
  210983             :                   {
  210984           0 :                     tempPointer->set_freepointer(pointer);
  210985             :                   }
  210986           0 :                for (unsigned i = 0; i < SgRenameSymbol::pool_size - 1; ++i)
  210987             :                   {
  210988           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  210989             :                   }
  210990           0 :                 pointer[SgRenameSymbol::pool_size-1].set_freepointer(NULL);
  210991           0 :                 tempPointer = &(pointer[SgRenameSymbol::pool_size-1]);
  210992           0 :                 ++block;
  210993             :              }
  210994             :         }
  210995           0 :    }
  210996             : 
  210997           5 : void SgRenameSymbol::deleteMemoryPool() {
  210998           5 :   for (auto p: SgRenameSymbol::pools) {
  210999           0 :     ROSE_FREE(p);
  211000             :   }
  211001           5 :   SgRenameSymbol::next_node = nullptr;
  211002           5 :   SgRenameSymbol::pools.clear();
  211003           5 : }
  211004             : 
  211005             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  211006             : //                 reading multiple binary files to for a single AST.
  211007             : /////////// new version ////////////////////////////////
  211008             : //############################################################################
  211009             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  211010             : void
  211011           2 : SgRenameSymbol::extendMemoryPoolForFileIO( )
  211012             :   {
  211013           2 :     size_t blockIndex = SgRenameSymbol::pools.size();
  211014           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgRenameSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgRenameSymbol);
  211015             : 
  211016           2 :     while ( (blockIndex * SgRenameSymbol::pool_size) < newPoolSize)
  211017             :       {
  211018             : #if ROSE_ALLOC_TRACE
  211019             :         if (blockIndex > 0) {
  211020             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgRenameSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgRenameSymbol) = %" PRIuPTR " SgRenameSymbol::pool_size = %d \n",
  211021             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgRenameSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgRenameSymbol),SgRenameSymbol::pool_size);
  211022             :         }
  211023             : #endif
  211024             : 
  211025           0 :         SgRenameSymbol * pointer = (SgRenameSymbol*) ROSE_MALLOC ( SgRenameSymbol::pool_size * sizeof(SgRenameSymbol) );
  211026           0 :         assert( pointer != NULL );
  211027             : #if ROSE_ALLOC_MEMSET == 1
  211028             :         memset(pointer, 0x00, SgRenameSymbol::pool_size * sizeof(SgRenameSymbol));
  211029             : #elif ROSE_ALLOC_MEMSET == 2
  211030             :         memset(pointer, 0xCC, SgRenameSymbol::pool_size * sizeof(SgRenameSymbol));
  211031             : #endif
  211032           0 :         SgRenameSymbol::pools.push_back( (unsigned char*)(pointer) );
  211033           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgRenameSymbol::pool_size * sizeof(SgRenameSymbol), V_SgRenameSymbol ) );
  211034             : 
  211035           0 :         if ( SgRenameSymbol::next_node != NULL ) {
  211036           0 :           if ( blockIndex > 0 ) {
  211037           0 :             SgRenameSymbol * blkptr = (SgRenameSymbol*)(SgRenameSymbol::pools[blockIndex-1]);
  211038           0 :             blkptr[ SgRenameSymbol::pool_size - 1 ].set_freepointer(pointer);
  211039             :           }
  211040             :         } else {
  211041           0 :           SgRenameSymbol::next_node = pointer;
  211042             :         }
  211043             : 
  211044           0 :         for (unsigned i = 0; i < SgRenameSymbol::pool_size-1; ++i)
  211045             :            {
  211046           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  211047             :            }
  211048           0 :         pointer[ SgRenameSymbol::pool_size -1 ].set_freepointer(NULL);
  211049             : 
  211050           0 :         blockIndex++;
  211051             :       }
  211052           2 :   }
  211053             : 
  211054             : //############################################################################
  211055             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  211056             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  211057             :  * not compressed. However, that stuff is not yet implemented! 
  211058             :  */
  211059             : unsigned long
  211060           0 : SgRenameSymbol::getNumberOfLastValidPointer()
  211061             :    {
  211062           0 :       SgRenameSymbol* testPointer = (SgRenameSymbol*)(SgRenameSymbol::pools.back());
  211063           0 :       unsigned long localIndex = SgRenameSymbol::pool_size - 1;
  211064           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  211065             :          {
  211066           0 :            localIndex--;
  211067             :          }
  211068           0 :       return (localIndex + SgRenameSymbol::pool_size * (SgRenameSymbol::pools.size()-1));
  211069             :    }
  211070             : 
  211071             : //############################################################################
  211072             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  211073             :  * memory pool and initializes the data member in class SgRenameSymbolStroageClass
  211074             :  * from its counterpart of SgRenameSymbol. The return value is just for checking, 
  211075             :  * that the whole StorageClassArray is initialized!
  211076             :  */
  211077             : unsigned long
  211078           0 : SgRenameSymbol::initializeStorageClassArray( SgRenameSymbolStorageClass *storageArray )
  211079             :    {
  211080           0 :      unsigned long storageCounter = 0;
  211081           0 :      std::vector < unsigned char* > :: const_iterator block = SgRenameSymbol::pools.begin();
  211082           0 :      SgRenameSymbol* pointer = NULL;
  211083           0 :      while ( block != SgRenameSymbol::pools.end() ) {
  211084           0 :           pointer = (SgRenameSymbol*) (*block);
  211085           0 :           for ( unsigned i = 0; i < SgRenameSymbol::pool_size; ++i ) {
  211086           0 :                if ( pointer->get_freepointer() != NULL ) {
  211087           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  211088           0 :                  storageArray++;
  211089           0 :                  storageCounter++;
  211090             :                }
  211091           0 :                pointer++;
  211092             :              }
  211093           0 :            block++;
  211094             :         }
  211095           0 :      return storageCounter;
  211096             :    }
  211097             : 
  211098             : /* #line 211099 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  211099             : 
  211100             : 
  211101             : 
  211102             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  211103             : 
  211104             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  211105             : 
  211106             : //############################################################################
  211107             : /* JH (02/02/2006) Constructor of the IR node SgFunctionTypeSymbol that takes its 
  211108             :  * corresponding StorageClass as parameter
  211109             :  */
  211110        9181 : SgFunctionTypeSymbol :: SgFunctionTypeSymbol ( const SgFunctionTypeSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  211111             :    {
  211112             : 
  211113             : 
  211114             : /* #line 211115 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  211115             : 
  211116        9181 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  211117        9181 :      p_name = SgName ( storageSource.storageOf_name ) ;
  211118        9181 :      p_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
  211119             : 
  211120             : 
  211121             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  211122             : 
  211123             : 
  211124        9181 :    }
  211125             : 
  211126             : //############################################################################
  211127             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  211128             :  * within the working AST. 
  211129             :  */
  211130       13043 : SgFunctionTypeSymbol * SgFunctionTypeSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  211131       13043 :      SgFunctionTypeSymbol* returnPointer = NULL;
  211132       13043 :      if ( globalIndex != 0 )
  211133             :         {
  211134             : 
  211135             : #if FILE_IO_EXTRA_CHECK
  211136       13043 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgFunctionTypeSymbol ) ) <= globalIndex ) ;
  211137       13043 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionTypeSymbol + 1 ) ) );
  211138             : #endif
  211139       13043 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgFunctionTypeSymbol )  
  211140       13043 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgFunctionTypeSymbol );
  211141       13043 :           unsigned long positionInPool = localIndex % SgFunctionTypeSymbol::pool_size;
  211142       13043 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionTypeSymbol::pool_size;
  211143             : 
  211144             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  211145             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  211146             : 
  211147       13043 :           returnPointer = &( ( (SgFunctionTypeSymbol*)(SgFunctionTypeSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  211148             : 
  211149       13043 :           ROSE_ASSERT( returnPointer != NULL ) ;
  211150             :         }
  211151       13043 :      return returnPointer ;
  211152             :    }
  211153             : 
  211154             : //############################################################################
  211155             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  211156             :   for the AST with the index astIndex
  211157             : */
  211158           0 : SgFunctionTypeSymbol * SgFunctionTypeSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  211159           0 :      SgFunctionTypeSymbol* returnPointer = NULL;
  211160           0 :      if ( globalIndex != 0 )
  211161             :         {
  211162             : 
  211163             : #if FILE_IO_EXTRA_CHECK
  211164           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgFunctionTypeSymbol ) ) <= globalIndex ) ;
  211165           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionTypeSymbol + 1 ) ) );
  211166             : #endif
  211167           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgFunctionTypeSymbol )
  211168           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgFunctionTypeSymbol );
  211169           0 :           unsigned long positionInPool = localIndex % SgFunctionTypeSymbol::pool_size ;
  211170           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgFunctionTypeSymbol::pool_size ;
  211171             : 
  211172             : #if FILE_IO_EXTRA_CHECK
  211173             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  211174             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  211175             : #endif
  211176             : 
  211177           0 :           returnPointer = &( ( (SgFunctionTypeSymbol*)(SgFunctionTypeSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  211178             : 
  211179             : #if FILE_IO_EXTRA_CHECK
  211180           0 :           assert ( returnPointer != NULL ) ;
  211181             : #endif
  211182             :         }
  211183           0 :      return returnPointer ;
  211184             :    }
  211185             : 
  211186             : //############################################################################
  211187             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  211188             :  * pool size! We set for every valid object in the memory pool the freepointer
  211189             :  * to the global index and increase the global index afterwards. For all the 
  211190             :  * invalid objects (means address ranges within the memory pool that were not
  211191             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  211192             :  * distinguish valid from invalid objects! 
  211193             :  */
  211194             : unsigned long
  211195           5 : SgFunctionTypeSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  211196             :    {
  211197           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  211198           5 :      SgFunctionTypeSymbol* pointer = NULL;
  211199           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  211200           5 :      std::vector < unsigned char* > :: const_iterator block;
  211201          12 :      for ( block = SgFunctionTypeSymbol::pools.begin(); block != SgFunctionTypeSymbol::pools.end() ; ++block )
  211202             :         {
  211203           7 :           pointer = (SgFunctionTypeSymbol*)(*block);
  211204       14007 :           for (unsigned i = 0; i < SgFunctionTypeSymbol::pool_size; ++i )
  211205             :              {
  211206             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  211207             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  211208             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  211209             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  211210             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  211211             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  211212             :             // properly; so this will have to be checked next.
  211213             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  211214             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  211215       14000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  211216             :                   {
  211217        9183 :                     pointer[i].set_freepointer((SgFunctionTypeSymbol*)(globalIndex));
  211218        9183 :                     globalIndex++;
  211219             :                   }
  211220             :                else
  211221             :                   {
  211222        4817 :                     pointer[i].set_freepointer(NULL);
  211223             :                   }
  211224             :               }
  211225             :         }
  211226           5 :      return globalIndex;
  211227             :    }
  211228             : 
  211229             : //############################################################################
  211230             : // JH (01/14/2006)
  211231             : void
  211232           5 : SgFunctionTypeSymbol::resetValidFreepointers( )
  211233             :    {
  211234           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  211235           5 :      SgFunctionTypeSymbol* pointer = NULL;
  211236           5 :      std::vector < unsigned char* > :: const_iterator block;
  211237           5 :      SgFunctionTypeSymbol* pointerOfLinkedList = NULL;
  211238          12 :      for ( block = SgFunctionTypeSymbol::pools.begin(); block != SgFunctionTypeSymbol::pools.end() ; ++block )
  211239             :         {
  211240           7 :           pointer = (SgFunctionTypeSymbol*)(*block);
  211241       14007 :           for (unsigned i = 0; i < SgFunctionTypeSymbol::pool_size; ++i )
  211242             :              {
  211243             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  211244             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  211245             :             // memory blocks!.
  211246       14000 :                if ( pointer[i].get_freepointer() != NULL )
  211247             :                   {
  211248        9183 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  211249             :                   }
  211250             :                else
  211251             :                   {
  211252        4817 :                     if ( pointerOfLinkedList == NULL )
  211253             :                        {
  211254           3 :                          SgFunctionTypeSymbol::next_node = &(pointer[i]);
  211255             :                        }
  211256             :                     else
  211257             :                        {
  211258             :                       // printf ("In SgFunctionTypeSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  211259        4814 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  211260             :                        }
  211261             :                     pointerOfLinkedList = &(pointer[i]);
  211262             :                   }
  211263             :               }
  211264             :         }
  211265             : 
  211266           5 :      if ( pointerOfLinkedList != NULL )
  211267             :         {
  211268             :        // printf ("In SgFunctionTypeSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  211269           3 :           pointerOfLinkedList->set_freepointer(NULL);
  211270             :        // DQ (6/6/2010): Temporary debugging...
  211271             :        //   ROSE_ASSERT(false);
  211272             :         }
  211273             : 
  211274           5 :      return ;
  211275             :    }
  211276             : 
  211277             : //############################################################################
  211278             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  211279             :  * within the memory pool and resets the freepointers, in order to achieve a 
  211280             :  * linked list, that has no jumps and starts at the beginning! This function 
  211281             :  * does not extend the memory pool, since we do not delete any memory blocks,
  211282             :  * but delete the valid objects.  
  211283             :  */
  211284             : void
  211285           0 : SgFunctionTypeSymbol::clearMemoryPool( )
  211286             :    {
  211287             :   // printf ("Inside of SgFunctionTypeSymbol::clearMemoryPool() \n");
  211288             : 
  211289           0 :      SgFunctionTypeSymbol* pointer = NULL, *tempPointer = NULL;
  211290           0 :      std::vector < unsigned char* > :: const_iterator block;
  211291           0 :      if ( SgFunctionTypeSymbol::pools.empty() == false )
  211292             :         {
  211293           0 :           block = SgFunctionTypeSymbol::pools.begin() ;
  211294           0 :           SgFunctionTypeSymbol::next_node = (SgFunctionTypeSymbol*) (*block);
  211295             : 
  211296           0 :           while ( block != SgFunctionTypeSymbol::pools.end() )
  211297             :              {
  211298           0 :                pointer = (SgFunctionTypeSymbol*) (*block);
  211299           0 :                if ( tempPointer != NULL )
  211300             :                   {
  211301           0 :                     tempPointer->set_freepointer(pointer);
  211302             :                   }
  211303           0 :                for (unsigned i = 0; i < SgFunctionTypeSymbol::pool_size - 1; ++i)
  211304             :                   {
  211305           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  211306             :                   }
  211307           0 :                 pointer[SgFunctionTypeSymbol::pool_size-1].set_freepointer(NULL);
  211308           0 :                 tempPointer = &(pointer[SgFunctionTypeSymbol::pool_size-1]);
  211309           0 :                 ++block;
  211310             :              }
  211311             :         }
  211312           0 :    }
  211313             : 
  211314           5 : void SgFunctionTypeSymbol::deleteMemoryPool() {
  211315          18 :   for (auto p: SgFunctionTypeSymbol::pools) {
  211316          13 :     ROSE_FREE(p);
  211317             :   }
  211318           5 :   SgFunctionTypeSymbol::next_node = nullptr;
  211319           5 :   SgFunctionTypeSymbol::pools.clear();
  211320           5 : }
  211321             : 
  211322             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  211323             : //                 reading multiple binary files to for a single AST.
  211324             : /////////// new version ////////////////////////////////
  211325             : //############################################################################
  211326             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  211327             : void
  211328           2 : SgFunctionTypeSymbol::extendMemoryPoolForFileIO( )
  211329             :   {
  211330           2 :     size_t blockIndex = SgFunctionTypeSymbol::pools.size();
  211331           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionTypeSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionTypeSymbol);
  211332             : 
  211333           8 :     while ( (blockIndex * SgFunctionTypeSymbol::pool_size) < newPoolSize)
  211334             :       {
  211335             : #if ROSE_ALLOC_TRACE
  211336             :         if (blockIndex > 0) {
  211337             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionTypeSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionTypeSymbol) = %" PRIuPTR " SgFunctionTypeSymbol::pool_size = %d \n",
  211338             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgFunctionTypeSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgFunctionTypeSymbol),SgFunctionTypeSymbol::pool_size);
  211339             :         }
  211340             : #endif
  211341             : 
  211342           6 :         SgFunctionTypeSymbol * pointer = (SgFunctionTypeSymbol*) ROSE_MALLOC ( SgFunctionTypeSymbol::pool_size * sizeof(SgFunctionTypeSymbol) );
  211343           6 :         assert( pointer != NULL );
  211344             : #if ROSE_ALLOC_MEMSET == 1
  211345             :         memset(pointer, 0x00, SgFunctionTypeSymbol::pool_size * sizeof(SgFunctionTypeSymbol));
  211346             : #elif ROSE_ALLOC_MEMSET == 2
  211347             :         memset(pointer, 0xCC, SgFunctionTypeSymbol::pool_size * sizeof(SgFunctionTypeSymbol));
  211348             : #endif
  211349           6 :         SgFunctionTypeSymbol::pools.push_back( (unsigned char*)(pointer) );
  211350           6 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgFunctionTypeSymbol::pool_size * sizeof(SgFunctionTypeSymbol), V_SgFunctionTypeSymbol ) );
  211351             : 
  211352           6 :         if ( SgFunctionTypeSymbol::next_node != NULL ) {
  211353           4 :           if ( blockIndex > 0 ) {
  211354           4 :             SgFunctionTypeSymbol * blkptr = (SgFunctionTypeSymbol*)(SgFunctionTypeSymbol::pools[blockIndex-1]);
  211355           4 :             blkptr[ SgFunctionTypeSymbol::pool_size - 1 ].set_freepointer(pointer);
  211356             :           }
  211357             :         } else {
  211358           2 :           SgFunctionTypeSymbol::next_node = pointer;
  211359             :         }
  211360             : 
  211361       12000 :         for (unsigned i = 0; i < SgFunctionTypeSymbol::pool_size-1; ++i)
  211362             :            {
  211363       11994 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  211364             :            }
  211365           6 :         pointer[ SgFunctionTypeSymbol::pool_size -1 ].set_freepointer(NULL);
  211366             : 
  211367           6 :         blockIndex++;
  211368             :       }
  211369           2 :   }
  211370             : 
  211371             : //############################################################################
  211372             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  211373             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  211374             :  * not compressed. However, that stuff is not yet implemented! 
  211375             :  */
  211376             : unsigned long
  211377           0 : SgFunctionTypeSymbol::getNumberOfLastValidPointer()
  211378             :    {
  211379           0 :       SgFunctionTypeSymbol* testPointer = (SgFunctionTypeSymbol*)(SgFunctionTypeSymbol::pools.back());
  211380           0 :       unsigned long localIndex = SgFunctionTypeSymbol::pool_size - 1;
  211381           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  211382             :          {
  211383           0 :            localIndex--;
  211384             :          }
  211385           0 :       return (localIndex + SgFunctionTypeSymbol::pool_size * (SgFunctionTypeSymbol::pools.size()-1));
  211386             :    }
  211387             : 
  211388             : //############################################################################
  211389             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  211390             :  * memory pool and initializes the data member in class SgFunctionTypeSymbolStroageClass
  211391             :  * from its counterpart of SgFunctionTypeSymbol. The return value is just for checking, 
  211392             :  * that the whole StorageClassArray is initialized!
  211393             :  */
  211394             : unsigned long
  211395           3 : SgFunctionTypeSymbol::initializeStorageClassArray( SgFunctionTypeSymbolStorageClass *storageArray )
  211396             :    {
  211397           3 :      unsigned long storageCounter = 0;
  211398           3 :      std::vector < unsigned char* > :: const_iterator block = SgFunctionTypeSymbol::pools.begin();
  211399           3 :      SgFunctionTypeSymbol* pointer = NULL;
  211400          10 :      while ( block != SgFunctionTypeSymbol::pools.end() ) {
  211401           7 :           pointer = (SgFunctionTypeSymbol*) (*block);
  211402       14007 :           for ( unsigned i = 0; i < SgFunctionTypeSymbol::pool_size; ++i ) {
  211403       14000 :                if ( pointer->get_freepointer() != NULL ) {
  211404        9183 :                  storageArray->pickOutIRNodeData (pointer) ;
  211405        9183 :                  storageArray++;
  211406        9183 :                  storageCounter++;
  211407             :                }
  211408       14000 :                pointer++;
  211409             :              }
  211410           7 :            block++;
  211411             :         }
  211412           3 :      return storageCounter;
  211413             :    }
  211414             : 
  211415             : /* #line 211416 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  211416             : 
  211417             : 
  211418             : 
  211419             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  211420             : 
  211421             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  211422             : 
  211423             : //############################################################################
  211424             : /* JH (02/02/2006) Constructor of the IR node SgClassSymbol that takes its 
  211425             :  * corresponding StorageClass as parameter
  211426             :  */
  211427        1424 : SgClassSymbol :: SgClassSymbol ( const SgClassSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  211428             :    {
  211429             : 
  211430             : 
  211431             : /* #line 211432 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  211432             : 
  211433        1424 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  211434        1424 :      p_declaration =  (SgClassDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  211435             : 
  211436             : 
  211437             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  211438             : 
  211439             : 
  211440        1424 :    }
  211441             : 
  211442             : //############################################################################
  211443             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  211444             :  * within the working AST. 
  211445             :  */
  211446        4404 : SgClassSymbol * SgClassSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  211447        4404 :      SgClassSymbol* returnPointer = NULL;
  211448        4404 :      if ( globalIndex != 0 )
  211449             :         {
  211450             : 
  211451             : #if FILE_IO_EXTRA_CHECK
  211452        4404 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgClassSymbol ) ) <= globalIndex ) ;
  211453        4404 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassSymbol + 1 ) ) );
  211454             : #endif
  211455        4404 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgClassSymbol )  
  211456        4404 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgClassSymbol );
  211457        4404 :           unsigned long positionInPool = localIndex % SgClassSymbol::pool_size;
  211458        4404 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassSymbol::pool_size;
  211459             : 
  211460             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  211461             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  211462             : 
  211463        4404 :           returnPointer = &( ( (SgClassSymbol*)(SgClassSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  211464             : 
  211465        4404 :           ROSE_ASSERT( returnPointer != NULL ) ;
  211466             :         }
  211467        4404 :      return returnPointer ;
  211468             :    }
  211469             : 
  211470             : //############################################################################
  211471             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  211472             :   for the AST with the index astIndex
  211473             : */
  211474           0 : SgClassSymbol * SgClassSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  211475           0 :      SgClassSymbol* returnPointer = NULL;
  211476           0 :      if ( globalIndex != 0 )
  211477             :         {
  211478             : 
  211479             : #if FILE_IO_EXTRA_CHECK
  211480           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgClassSymbol ) ) <= globalIndex ) ;
  211481           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassSymbol + 1 ) ) );
  211482             : #endif
  211483           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgClassSymbol )
  211484           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgClassSymbol );
  211485           0 :           unsigned long positionInPool = localIndex % SgClassSymbol::pool_size ;
  211486           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgClassSymbol::pool_size ;
  211487             : 
  211488             : #if FILE_IO_EXTRA_CHECK
  211489             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  211490             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  211491             : #endif
  211492             : 
  211493           0 :           returnPointer = &( ( (SgClassSymbol*)(SgClassSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  211494             : 
  211495             : #if FILE_IO_EXTRA_CHECK
  211496           0 :           assert ( returnPointer != NULL ) ;
  211497             : #endif
  211498             :         }
  211499           0 :      return returnPointer ;
  211500             :    }
  211501             : 
  211502             : //############################################################################
  211503             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  211504             :  * pool size! We set for every valid object in the memory pool the freepointer
  211505             :  * to the global index and increase the global index afterwards. For all the 
  211506             :  * invalid objects (means address ranges within the memory pool that were not
  211507             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  211508             :  * distinguish valid from invalid objects! 
  211509             :  */
  211510             : unsigned long
  211511           5 : SgClassSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  211512             :    {
  211513           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  211514           5 :      SgClassSymbol* pointer = NULL;
  211515           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  211516           5 :      std::vector < unsigned char* > :: const_iterator block;
  211517           7 :      for ( block = SgClassSymbol::pools.begin(); block != SgClassSymbol::pools.end() ; ++block )
  211518             :         {
  211519           2 :           pointer = (SgClassSymbol*)(*block);
  211520        4002 :           for (unsigned i = 0; i < SgClassSymbol::pool_size; ++i )
  211521             :              {
  211522             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  211523             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  211524             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  211525             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  211526             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  211527             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  211528             :             // properly; so this will have to be checked next.
  211529             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  211530             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  211531        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  211532             :                   {
  211533         852 :                     pointer[i].set_freepointer((SgClassSymbol*)(globalIndex));
  211534         852 :                     globalIndex++;
  211535             :                   }
  211536             :                else
  211537             :                   {
  211538        3148 :                     pointer[i].set_freepointer(NULL);
  211539             :                   }
  211540             :               }
  211541             :         }
  211542           5 :      return globalIndex;
  211543             :    }
  211544             : 
  211545             : //############################################################################
  211546             : // JH (01/14/2006)
  211547             : void
  211548           5 : SgClassSymbol::resetValidFreepointers( )
  211549             :    {
  211550           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  211551           5 :      SgClassSymbol* pointer = NULL;
  211552           5 :      std::vector < unsigned char* > :: const_iterator block;
  211553           5 :      SgClassSymbol* pointerOfLinkedList = NULL;
  211554           7 :      for ( block = SgClassSymbol::pools.begin(); block != SgClassSymbol::pools.end() ; ++block )
  211555             :         {
  211556           2 :           pointer = (SgClassSymbol*)(*block);
  211557        4002 :           for (unsigned i = 0; i < SgClassSymbol::pool_size; ++i )
  211558             :              {
  211559             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  211560             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  211561             :             // memory blocks!.
  211562        4000 :                if ( pointer[i].get_freepointer() != NULL )
  211563             :                   {
  211564         852 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  211565             :                   }
  211566             :                else
  211567             :                   {
  211568        3148 :                     if ( pointerOfLinkedList == NULL )
  211569             :                        {
  211570           2 :                          SgClassSymbol::next_node = &(pointer[i]);
  211571             :                        }
  211572             :                     else
  211573             :                        {
  211574             :                       // printf ("In SgClassSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  211575        3146 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  211576             :                        }
  211577             :                     pointerOfLinkedList = &(pointer[i]);
  211578             :                   }
  211579             :               }
  211580             :         }
  211581             : 
  211582           5 :      if ( pointerOfLinkedList != NULL )
  211583             :         {
  211584             :        // printf ("In SgClassSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  211585           2 :           pointerOfLinkedList->set_freepointer(NULL);
  211586             :        // DQ (6/6/2010): Temporary debugging...
  211587             :        //   ROSE_ASSERT(false);
  211588             :         }
  211589             : 
  211590           5 :      return ;
  211591             :    }
  211592             : 
  211593             : //############################################################################
  211594             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  211595             :  * within the memory pool and resets the freepointers, in order to achieve a 
  211596             :  * linked list, that has no jumps and starts at the beginning! This function 
  211597             :  * does not extend the memory pool, since we do not delete any memory blocks,
  211598             :  * but delete the valid objects.  
  211599             :  */
  211600             : void
  211601           0 : SgClassSymbol::clearMemoryPool( )
  211602             :    {
  211603             :   // printf ("Inside of SgClassSymbol::clearMemoryPool() \n");
  211604             : 
  211605           0 :      SgClassSymbol* pointer = NULL, *tempPointer = NULL;
  211606           0 :      std::vector < unsigned char* > :: const_iterator block;
  211607           0 :      if ( SgClassSymbol::pools.empty() == false )
  211608             :         {
  211609           0 :           block = SgClassSymbol::pools.begin() ;
  211610           0 :           SgClassSymbol::next_node = (SgClassSymbol*) (*block);
  211611             : 
  211612           0 :           while ( block != SgClassSymbol::pools.end() )
  211613             :              {
  211614           0 :                pointer = (SgClassSymbol*) (*block);
  211615           0 :                if ( tempPointer != NULL )
  211616             :                   {
  211617           0 :                     tempPointer->set_freepointer(pointer);
  211618             :                   }
  211619           0 :                for (unsigned i = 0; i < SgClassSymbol::pool_size - 1; ++i)
  211620             :                   {
  211621           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  211622             :                   }
  211623           0 :                 pointer[SgClassSymbol::pool_size-1].set_freepointer(NULL);
  211624           0 :                 tempPointer = &(pointer[SgClassSymbol::pool_size-1]);
  211625           0 :                 ++block;
  211626             :              }
  211627             :         }
  211628           0 :    }
  211629             : 
  211630           5 : void SgClassSymbol::deleteMemoryPool() {
  211631           9 :   for (auto p: SgClassSymbol::pools) {
  211632           4 :     ROSE_FREE(p);
  211633             :   }
  211634           5 :   SgClassSymbol::next_node = nullptr;
  211635           5 :   SgClassSymbol::pools.clear();
  211636           5 : }
  211637             : 
  211638             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  211639             : //                 reading multiple binary files to for a single AST.
  211640             : /////////// new version ////////////////////////////////
  211641             : //############################################################################
  211642             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  211643             : void
  211644           2 : SgClassSymbol::extendMemoryPoolForFileIO( )
  211645             :   {
  211646           2 :     size_t blockIndex = SgClassSymbol::pools.size();
  211647           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgClassSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassSymbol);
  211648             : 
  211649           4 :     while ( (blockIndex * SgClassSymbol::pool_size) < newPoolSize)
  211650             :       {
  211651             : #if ROSE_ALLOC_TRACE
  211652             :         if (blockIndex > 0) {
  211653             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgClassSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassSymbol) = %" PRIuPTR " SgClassSymbol::pool_size = %d \n",
  211654             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgClassSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgClassSymbol),SgClassSymbol::pool_size);
  211655             :         }
  211656             : #endif
  211657             : 
  211658           2 :         SgClassSymbol * pointer = (SgClassSymbol*) ROSE_MALLOC ( SgClassSymbol::pool_size * sizeof(SgClassSymbol) );
  211659           2 :         assert( pointer != NULL );
  211660             : #if ROSE_ALLOC_MEMSET == 1
  211661             :         memset(pointer, 0x00, SgClassSymbol::pool_size * sizeof(SgClassSymbol));
  211662             : #elif ROSE_ALLOC_MEMSET == 2
  211663             :         memset(pointer, 0xCC, SgClassSymbol::pool_size * sizeof(SgClassSymbol));
  211664             : #endif
  211665           2 :         SgClassSymbol::pools.push_back( (unsigned char*)(pointer) );
  211666           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgClassSymbol::pool_size * sizeof(SgClassSymbol), V_SgClassSymbol ) );
  211667             : 
  211668           2 :         if ( SgClassSymbol::next_node != NULL ) {
  211669           0 :           if ( blockIndex > 0 ) {
  211670           0 :             SgClassSymbol * blkptr = (SgClassSymbol*)(SgClassSymbol::pools[blockIndex-1]);
  211671           0 :             blkptr[ SgClassSymbol::pool_size - 1 ].set_freepointer(pointer);
  211672             :           }
  211673             :         } else {
  211674           2 :           SgClassSymbol::next_node = pointer;
  211675             :         }
  211676             : 
  211677        4000 :         for (unsigned i = 0; i < SgClassSymbol::pool_size-1; ++i)
  211678             :            {
  211679        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  211680             :            }
  211681           2 :         pointer[ SgClassSymbol::pool_size -1 ].set_freepointer(NULL);
  211682             : 
  211683           2 :         blockIndex++;
  211684             :       }
  211685           2 :   }
  211686             : 
  211687             : //############################################################################
  211688             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  211689             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  211690             :  * not compressed. However, that stuff is not yet implemented! 
  211691             :  */
  211692             : unsigned long
  211693           0 : SgClassSymbol::getNumberOfLastValidPointer()
  211694             :    {
  211695           0 :       SgClassSymbol* testPointer = (SgClassSymbol*)(SgClassSymbol::pools.back());
  211696           0 :       unsigned long localIndex = SgClassSymbol::pool_size - 1;
  211697           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  211698             :          {
  211699           0 :            localIndex--;
  211700             :          }
  211701           0 :       return (localIndex + SgClassSymbol::pool_size * (SgClassSymbol::pools.size()-1));
  211702             :    }
  211703             : 
  211704             : //############################################################################
  211705             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  211706             :  * memory pool and initializes the data member in class SgClassSymbolStroageClass
  211707             :  * from its counterpart of SgClassSymbol. The return value is just for checking, 
  211708             :  * that the whole StorageClassArray is initialized!
  211709             :  */
  211710             : unsigned long
  211711           2 : SgClassSymbol::initializeStorageClassArray( SgClassSymbolStorageClass *storageArray )
  211712             :    {
  211713           2 :      unsigned long storageCounter = 0;
  211714           2 :      std::vector < unsigned char* > :: const_iterator block = SgClassSymbol::pools.begin();
  211715           2 :      SgClassSymbol* pointer = NULL;
  211716           4 :      while ( block != SgClassSymbol::pools.end() ) {
  211717           2 :           pointer = (SgClassSymbol*) (*block);
  211718        4002 :           for ( unsigned i = 0; i < SgClassSymbol::pool_size; ++i ) {
  211719        4000 :                if ( pointer->get_freepointer() != NULL ) {
  211720         852 :                  storageArray->pickOutIRNodeData (pointer) ;
  211721         852 :                  storageArray++;
  211722         852 :                  storageCounter++;
  211723             :                }
  211724        4000 :                pointer++;
  211725             :              }
  211726           2 :            block++;
  211727             :         }
  211728           2 :      return storageCounter;
  211729             :    }
  211730             : 
  211731             : /* #line 211732 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  211732             : 
  211733             : 
  211734             : 
  211735             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  211736             : 
  211737             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  211738             : 
  211739             : //############################################################################
  211740             : /* JH (02/02/2006) Constructor of the IR node SgTemplateClassSymbol that takes its 
  211741             :  * corresponding StorageClass as parameter
  211742             :  */
  211743         572 : SgTemplateClassSymbol :: SgTemplateClassSymbol ( const SgTemplateClassSymbolStorageClass& storageSource )   : SgClassSymbol (storageSource)
  211744             :    {
  211745             : 
  211746             : 
  211747             : /* #line 211748 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  211748             : 
  211749         572 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  211750             : 
  211751             : 
  211752             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  211753             : 
  211754             : 
  211755         572 :    }
  211756             : 
  211757             : //############################################################################
  211758             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  211759             :  * within the working AST. 
  211760             :  */
  211761        2762 : SgTemplateClassSymbol * SgTemplateClassSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  211762        2762 :      SgTemplateClassSymbol* returnPointer = NULL;
  211763        2762 :      if ( globalIndex != 0 )
  211764             :         {
  211765             : 
  211766             : #if FILE_IO_EXTRA_CHECK
  211767        2762 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateClassSymbol ) ) <= globalIndex ) ;
  211768        2762 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateClassSymbol + 1 ) ) );
  211769             : #endif
  211770        2762 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateClassSymbol )  
  211771        2762 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateClassSymbol );
  211772        2762 :           unsigned long positionInPool = localIndex % SgTemplateClassSymbol::pool_size;
  211773        2762 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateClassSymbol::pool_size;
  211774             : 
  211775             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  211776             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  211777             : 
  211778        2762 :           returnPointer = &( ( (SgTemplateClassSymbol*)(SgTemplateClassSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  211779             : 
  211780        2762 :           ROSE_ASSERT( returnPointer != NULL ) ;
  211781             :         }
  211782        2762 :      return returnPointer ;
  211783             :    }
  211784             : 
  211785             : //############################################################################
  211786             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  211787             :   for the AST with the index astIndex
  211788             : */
  211789           0 : SgTemplateClassSymbol * SgTemplateClassSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  211790           0 :      SgTemplateClassSymbol* returnPointer = NULL;
  211791           0 :      if ( globalIndex != 0 )
  211792             :         {
  211793             : 
  211794             : #if FILE_IO_EXTRA_CHECK
  211795           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateClassSymbol ) ) <= globalIndex ) ;
  211796           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateClassSymbol + 1 ) ) );
  211797             : #endif
  211798           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateClassSymbol )
  211799           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateClassSymbol );
  211800           0 :           unsigned long positionInPool = localIndex % SgTemplateClassSymbol::pool_size ;
  211801           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateClassSymbol::pool_size ;
  211802             : 
  211803             : #if FILE_IO_EXTRA_CHECK
  211804             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  211805             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  211806             : #endif
  211807             : 
  211808           0 :           returnPointer = &( ( (SgTemplateClassSymbol*)(SgTemplateClassSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  211809             : 
  211810             : #if FILE_IO_EXTRA_CHECK
  211811           0 :           assert ( returnPointer != NULL ) ;
  211812             : #endif
  211813             :         }
  211814           0 :      return returnPointer ;
  211815             :    }
  211816             : 
  211817             : //############################################################################
  211818             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  211819             :  * pool size! We set for every valid object in the memory pool the freepointer
  211820             :  * to the global index and increase the global index afterwards. For all the 
  211821             :  * invalid objects (means address ranges within the memory pool that were not
  211822             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  211823             :  * distinguish valid from invalid objects! 
  211824             :  */
  211825             : unsigned long
  211826           5 : SgTemplateClassSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  211827             :    {
  211828           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  211829           5 :      SgTemplateClassSymbol* pointer = NULL;
  211830           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  211831           5 :      std::vector < unsigned char* > :: const_iterator block;
  211832           6 :      for ( block = SgTemplateClassSymbol::pools.begin(); block != SgTemplateClassSymbol::pools.end() ; ++block )
  211833             :         {
  211834           1 :           pointer = (SgTemplateClassSymbol*)(*block);
  211835        2001 :           for (unsigned i = 0; i < SgTemplateClassSymbol::pool_size; ++i )
  211836             :              {
  211837             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  211838             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  211839             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  211840             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  211841             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  211842             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  211843             :             // properly; so this will have to be checked next.
  211844             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  211845             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  211846        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  211847             :                   {
  211848         572 :                     pointer[i].set_freepointer((SgTemplateClassSymbol*)(globalIndex));
  211849         572 :                     globalIndex++;
  211850             :                   }
  211851             :                else
  211852             :                   {
  211853        1428 :                     pointer[i].set_freepointer(NULL);
  211854             :                   }
  211855             :               }
  211856             :         }
  211857           5 :      return globalIndex;
  211858             :    }
  211859             : 
  211860             : //############################################################################
  211861             : // JH (01/14/2006)
  211862             : void
  211863           5 : SgTemplateClassSymbol::resetValidFreepointers( )
  211864             :    {
  211865           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  211866           5 :      SgTemplateClassSymbol* pointer = NULL;
  211867           5 :      std::vector < unsigned char* > :: const_iterator block;
  211868           5 :      SgTemplateClassSymbol* pointerOfLinkedList = NULL;
  211869           6 :      for ( block = SgTemplateClassSymbol::pools.begin(); block != SgTemplateClassSymbol::pools.end() ; ++block )
  211870             :         {
  211871           1 :           pointer = (SgTemplateClassSymbol*)(*block);
  211872        2001 :           for (unsigned i = 0; i < SgTemplateClassSymbol::pool_size; ++i )
  211873             :              {
  211874             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  211875             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  211876             :             // memory blocks!.
  211877        2000 :                if ( pointer[i].get_freepointer() != NULL )
  211878             :                   {
  211879         572 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  211880             :                   }
  211881             :                else
  211882             :                   {
  211883        1428 :                     if ( pointerOfLinkedList == NULL )
  211884             :                        {
  211885           1 :                          SgTemplateClassSymbol::next_node = &(pointer[i]);
  211886             :                        }
  211887             :                     else
  211888             :                        {
  211889             :                       // printf ("In SgTemplateClassSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  211890        1427 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  211891             :                        }
  211892             :                     pointerOfLinkedList = &(pointer[i]);
  211893             :                   }
  211894             :               }
  211895             :         }
  211896             : 
  211897           5 :      if ( pointerOfLinkedList != NULL )
  211898             :         {
  211899             :        // printf ("In SgTemplateClassSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  211900           1 :           pointerOfLinkedList->set_freepointer(NULL);
  211901             :        // DQ (6/6/2010): Temporary debugging...
  211902             :        //   ROSE_ASSERT(false);
  211903             :         }
  211904             : 
  211905           5 :      return ;
  211906             :    }
  211907             : 
  211908             : //############################################################################
  211909             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  211910             :  * within the memory pool and resets the freepointers, in order to achieve a 
  211911             :  * linked list, that has no jumps and starts at the beginning! This function 
  211912             :  * does not extend the memory pool, since we do not delete any memory blocks,
  211913             :  * but delete the valid objects.  
  211914             :  */
  211915             : void
  211916           0 : SgTemplateClassSymbol::clearMemoryPool( )
  211917             :    {
  211918             :   // printf ("Inside of SgTemplateClassSymbol::clearMemoryPool() \n");
  211919             : 
  211920           0 :      SgTemplateClassSymbol* pointer = NULL, *tempPointer = NULL;
  211921           0 :      std::vector < unsigned char* > :: const_iterator block;
  211922           0 :      if ( SgTemplateClassSymbol::pools.empty() == false )
  211923             :         {
  211924           0 :           block = SgTemplateClassSymbol::pools.begin() ;
  211925           0 :           SgTemplateClassSymbol::next_node = (SgTemplateClassSymbol*) (*block);
  211926             : 
  211927           0 :           while ( block != SgTemplateClassSymbol::pools.end() )
  211928             :              {
  211929           0 :                pointer = (SgTemplateClassSymbol*) (*block);
  211930           0 :                if ( tempPointer != NULL )
  211931             :                   {
  211932           0 :                     tempPointer->set_freepointer(pointer);
  211933             :                   }
  211934           0 :                for (unsigned i = 0; i < SgTemplateClassSymbol::pool_size - 1; ++i)
  211935             :                   {
  211936           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  211937             :                   }
  211938           0 :                 pointer[SgTemplateClassSymbol::pool_size-1].set_freepointer(NULL);
  211939           0 :                 tempPointer = &(pointer[SgTemplateClassSymbol::pool_size-1]);
  211940           0 :                 ++block;
  211941             :              }
  211942             :         }
  211943           0 :    }
  211944             : 
  211945           5 : void SgTemplateClassSymbol::deleteMemoryPool() {
  211946           7 :   for (auto p: SgTemplateClassSymbol::pools) {
  211947           2 :     ROSE_FREE(p);
  211948             :   }
  211949           5 :   SgTemplateClassSymbol::next_node = nullptr;
  211950           5 :   SgTemplateClassSymbol::pools.clear();
  211951           5 : }
  211952             : 
  211953             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  211954             : //                 reading multiple binary files to for a single AST.
  211955             : /////////// new version ////////////////////////////////
  211956             : //############################################################################
  211957             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  211958             : void
  211959           2 : SgTemplateClassSymbol::extendMemoryPoolForFileIO( )
  211960             :   {
  211961           2 :     size_t blockIndex = SgTemplateClassSymbol::pools.size();
  211962           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassSymbol);
  211963             : 
  211964           3 :     while ( (blockIndex * SgTemplateClassSymbol::pool_size) < newPoolSize)
  211965             :       {
  211966             : #if ROSE_ALLOC_TRACE
  211967             :         if (blockIndex > 0) {
  211968             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassSymbol) = %" PRIuPTR " SgTemplateClassSymbol::pool_size = %d \n",
  211969             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateClassSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateClassSymbol),SgTemplateClassSymbol::pool_size);
  211970             :         }
  211971             : #endif
  211972             : 
  211973           1 :         SgTemplateClassSymbol * pointer = (SgTemplateClassSymbol*) ROSE_MALLOC ( SgTemplateClassSymbol::pool_size * sizeof(SgTemplateClassSymbol) );
  211974           1 :         assert( pointer != NULL );
  211975             : #if ROSE_ALLOC_MEMSET == 1
  211976             :         memset(pointer, 0x00, SgTemplateClassSymbol::pool_size * sizeof(SgTemplateClassSymbol));
  211977             : #elif ROSE_ALLOC_MEMSET == 2
  211978             :         memset(pointer, 0xCC, SgTemplateClassSymbol::pool_size * sizeof(SgTemplateClassSymbol));
  211979             : #endif
  211980           1 :         SgTemplateClassSymbol::pools.push_back( (unsigned char*)(pointer) );
  211981           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateClassSymbol::pool_size * sizeof(SgTemplateClassSymbol), V_SgTemplateClassSymbol ) );
  211982             : 
  211983           1 :         if ( SgTemplateClassSymbol::next_node != NULL ) {
  211984           0 :           if ( blockIndex > 0 ) {
  211985           0 :             SgTemplateClassSymbol * blkptr = (SgTemplateClassSymbol*)(SgTemplateClassSymbol::pools[blockIndex-1]);
  211986           0 :             blkptr[ SgTemplateClassSymbol::pool_size - 1 ].set_freepointer(pointer);
  211987             :           }
  211988             :         } else {
  211989           1 :           SgTemplateClassSymbol::next_node = pointer;
  211990             :         }
  211991             : 
  211992        2000 :         for (unsigned i = 0; i < SgTemplateClassSymbol::pool_size-1; ++i)
  211993             :            {
  211994        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  211995             :            }
  211996           1 :         pointer[ SgTemplateClassSymbol::pool_size -1 ].set_freepointer(NULL);
  211997             : 
  211998           1 :         blockIndex++;
  211999             :       }
  212000           2 :   }
  212001             : 
  212002             : //############################################################################
  212003             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  212004             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  212005             :  * not compressed. However, that stuff is not yet implemented! 
  212006             :  */
  212007             : unsigned long
  212008           0 : SgTemplateClassSymbol::getNumberOfLastValidPointer()
  212009             :    {
  212010           0 :       SgTemplateClassSymbol* testPointer = (SgTemplateClassSymbol*)(SgTemplateClassSymbol::pools.back());
  212011           0 :       unsigned long localIndex = SgTemplateClassSymbol::pool_size - 1;
  212012           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  212013             :          {
  212014           0 :            localIndex--;
  212015             :          }
  212016           0 :       return (localIndex + SgTemplateClassSymbol::pool_size * (SgTemplateClassSymbol::pools.size()-1));
  212017             :    }
  212018             : 
  212019             : //############################################################################
  212020             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  212021             :  * memory pool and initializes the data member in class SgTemplateClassSymbolStroageClass
  212022             :  * from its counterpart of SgTemplateClassSymbol. The return value is just for checking, 
  212023             :  * that the whole StorageClassArray is initialized!
  212024             :  */
  212025             : unsigned long
  212026           1 : SgTemplateClassSymbol::initializeStorageClassArray( SgTemplateClassSymbolStorageClass *storageArray )
  212027             :    {
  212028           1 :      unsigned long storageCounter = 0;
  212029           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateClassSymbol::pools.begin();
  212030           1 :      SgTemplateClassSymbol* pointer = NULL;
  212031           2 :      while ( block != SgTemplateClassSymbol::pools.end() ) {
  212032           1 :           pointer = (SgTemplateClassSymbol*) (*block);
  212033        2001 :           for ( unsigned i = 0; i < SgTemplateClassSymbol::pool_size; ++i ) {
  212034        2000 :                if ( pointer->get_freepointer() != NULL ) {
  212035         572 :                  storageArray->pickOutIRNodeData (pointer) ;
  212036         572 :                  storageArray++;
  212037         572 :                  storageCounter++;
  212038             :                }
  212039        2000 :                pointer++;
  212040             :              }
  212041           1 :            block++;
  212042             :         }
  212043           1 :      return storageCounter;
  212044             :    }
  212045             : 
  212046             : /* #line 212047 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  212047             : 
  212048             : 
  212049             : 
  212050             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  212051             : 
  212052             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  212053             : 
  212054             : //############################################################################
  212055             : /* JH (02/02/2006) Constructor of the IR node SgTemplateSymbol that takes its 
  212056             :  * corresponding StorageClass as parameter
  212057             :  */
  212058           0 : SgTemplateSymbol :: SgTemplateSymbol ( const SgTemplateSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  212059             :    {
  212060             : 
  212061             : 
  212062             : /* #line 212063 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  212063             : 
  212064           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  212065           0 :      p_declaration =  (SgTemplateDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  212066             : 
  212067             : 
  212068             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  212069             : 
  212070             : 
  212071           0 :    }
  212072             : 
  212073             : //############################################################################
  212074             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  212075             :  * within the working AST. 
  212076             :  */
  212077           0 : SgTemplateSymbol * SgTemplateSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  212078           0 :      SgTemplateSymbol* returnPointer = NULL;
  212079           0 :      if ( globalIndex != 0 )
  212080             :         {
  212081             : 
  212082             : #if FILE_IO_EXTRA_CHECK
  212083           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateSymbol ) ) <= globalIndex ) ;
  212084           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateSymbol + 1 ) ) );
  212085             : #endif
  212086           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateSymbol )  
  212087           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateSymbol );
  212088           0 :           unsigned long positionInPool = localIndex % SgTemplateSymbol::pool_size;
  212089           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateSymbol::pool_size;
  212090             : 
  212091             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  212092             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  212093             : 
  212094           0 :           returnPointer = &( ( (SgTemplateSymbol*)(SgTemplateSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  212095             : 
  212096           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  212097             :         }
  212098           0 :      return returnPointer ;
  212099             :    }
  212100             : 
  212101             : //############################################################################
  212102             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  212103             :   for the AST with the index astIndex
  212104             : */
  212105           0 : SgTemplateSymbol * SgTemplateSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  212106           0 :      SgTemplateSymbol* returnPointer = NULL;
  212107           0 :      if ( globalIndex != 0 )
  212108             :         {
  212109             : 
  212110             : #if FILE_IO_EXTRA_CHECK
  212111           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateSymbol ) ) <= globalIndex ) ;
  212112           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateSymbol + 1 ) ) );
  212113             : #endif
  212114           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateSymbol )
  212115           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateSymbol );
  212116           0 :           unsigned long positionInPool = localIndex % SgTemplateSymbol::pool_size ;
  212117           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateSymbol::pool_size ;
  212118             : 
  212119             : #if FILE_IO_EXTRA_CHECK
  212120             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  212121             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  212122             : #endif
  212123             : 
  212124           0 :           returnPointer = &( ( (SgTemplateSymbol*)(SgTemplateSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  212125             : 
  212126             : #if FILE_IO_EXTRA_CHECK
  212127           0 :           assert ( returnPointer != NULL ) ;
  212128             : #endif
  212129             :         }
  212130           0 :      return returnPointer ;
  212131             :    }
  212132             : 
  212133             : //############################################################################
  212134             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  212135             :  * pool size! We set for every valid object in the memory pool the freepointer
  212136             :  * to the global index and increase the global index afterwards. For all the 
  212137             :  * invalid objects (means address ranges within the memory pool that were not
  212138             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  212139             :  * distinguish valid from invalid objects! 
  212140             :  */
  212141             : unsigned long
  212142           5 : SgTemplateSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  212143             :    {
  212144           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  212145           5 :      SgTemplateSymbol* pointer = NULL;
  212146           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  212147           5 :      std::vector < unsigned char* > :: const_iterator block;
  212148           5 :      for ( block = SgTemplateSymbol::pools.begin(); block != SgTemplateSymbol::pools.end() ; ++block )
  212149             :         {
  212150           0 :           pointer = (SgTemplateSymbol*)(*block);
  212151           0 :           for (unsigned i = 0; i < SgTemplateSymbol::pool_size; ++i )
  212152             :              {
  212153             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  212154             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  212155             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  212156             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  212157             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  212158             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  212159             :             // properly; so this will have to be checked next.
  212160             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  212161             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  212162           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  212163             :                   {
  212164           0 :                     pointer[i].set_freepointer((SgTemplateSymbol*)(globalIndex));
  212165           0 :                     globalIndex++;
  212166             :                   }
  212167             :                else
  212168             :                   {
  212169           0 :                     pointer[i].set_freepointer(NULL);
  212170             :                   }
  212171             :               }
  212172             :         }
  212173           5 :      return globalIndex;
  212174             :    }
  212175             : 
  212176             : //############################################################################
  212177             : // JH (01/14/2006)
  212178             : void
  212179           5 : SgTemplateSymbol::resetValidFreepointers( )
  212180             :    {
  212181           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  212182           5 :      SgTemplateSymbol* pointer = NULL;
  212183           5 :      std::vector < unsigned char* > :: const_iterator block;
  212184           5 :      SgTemplateSymbol* pointerOfLinkedList = NULL;
  212185           5 :      for ( block = SgTemplateSymbol::pools.begin(); block != SgTemplateSymbol::pools.end() ; ++block )
  212186             :         {
  212187           0 :           pointer = (SgTemplateSymbol*)(*block);
  212188           0 :           for (unsigned i = 0; i < SgTemplateSymbol::pool_size; ++i )
  212189             :              {
  212190             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  212191             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  212192             :             // memory blocks!.
  212193           0 :                if ( pointer[i].get_freepointer() != NULL )
  212194             :                   {
  212195           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  212196             :                   }
  212197             :                else
  212198             :                   {
  212199           0 :                     if ( pointerOfLinkedList == NULL )
  212200             :                        {
  212201           0 :                          SgTemplateSymbol::next_node = &(pointer[i]);
  212202             :                        }
  212203             :                     else
  212204             :                        {
  212205             :                       // printf ("In SgTemplateSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  212206           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  212207             :                        }
  212208             :                     pointerOfLinkedList = &(pointer[i]);
  212209             :                   }
  212210             :               }
  212211             :         }
  212212             : 
  212213           5 :      if ( pointerOfLinkedList != NULL )
  212214             :         {
  212215             :        // printf ("In SgTemplateSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  212216           0 :           pointerOfLinkedList->set_freepointer(NULL);
  212217             :        // DQ (6/6/2010): Temporary debugging...
  212218             :        //   ROSE_ASSERT(false);
  212219             :         }
  212220             : 
  212221           5 :      return ;
  212222             :    }
  212223             : 
  212224             : //############################################################################
  212225             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  212226             :  * within the memory pool and resets the freepointers, in order to achieve a 
  212227             :  * linked list, that has no jumps and starts at the beginning! This function 
  212228             :  * does not extend the memory pool, since we do not delete any memory blocks,
  212229             :  * but delete the valid objects.  
  212230             :  */
  212231             : void
  212232           0 : SgTemplateSymbol::clearMemoryPool( )
  212233             :    {
  212234             :   // printf ("Inside of SgTemplateSymbol::clearMemoryPool() \n");
  212235             : 
  212236           0 :      SgTemplateSymbol* pointer = NULL, *tempPointer = NULL;
  212237           0 :      std::vector < unsigned char* > :: const_iterator block;
  212238           0 :      if ( SgTemplateSymbol::pools.empty() == false )
  212239             :         {
  212240           0 :           block = SgTemplateSymbol::pools.begin() ;
  212241           0 :           SgTemplateSymbol::next_node = (SgTemplateSymbol*) (*block);
  212242             : 
  212243           0 :           while ( block != SgTemplateSymbol::pools.end() )
  212244             :              {
  212245           0 :                pointer = (SgTemplateSymbol*) (*block);
  212246           0 :                if ( tempPointer != NULL )
  212247             :                   {
  212248           0 :                     tempPointer->set_freepointer(pointer);
  212249             :                   }
  212250           0 :                for (unsigned i = 0; i < SgTemplateSymbol::pool_size - 1; ++i)
  212251             :                   {
  212252           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  212253             :                   }
  212254           0 :                 pointer[SgTemplateSymbol::pool_size-1].set_freepointer(NULL);
  212255           0 :                 tempPointer = &(pointer[SgTemplateSymbol::pool_size-1]);
  212256           0 :                 ++block;
  212257             :              }
  212258             :         }
  212259           0 :    }
  212260             : 
  212261           5 : void SgTemplateSymbol::deleteMemoryPool() {
  212262           5 :   for (auto p: SgTemplateSymbol::pools) {
  212263           0 :     ROSE_FREE(p);
  212264             :   }
  212265           5 :   SgTemplateSymbol::next_node = nullptr;
  212266           5 :   SgTemplateSymbol::pools.clear();
  212267           5 : }
  212268             : 
  212269             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  212270             : //                 reading multiple binary files to for a single AST.
  212271             : /////////// new version ////////////////////////////////
  212272             : //############################################################################
  212273             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  212274             : void
  212275           2 : SgTemplateSymbol::extendMemoryPoolForFileIO( )
  212276             :   {
  212277           2 :     size_t blockIndex = SgTemplateSymbol::pools.size();
  212278           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateSymbol);
  212279             : 
  212280           2 :     while ( (blockIndex * SgTemplateSymbol::pool_size) < newPoolSize)
  212281             :       {
  212282             : #if ROSE_ALLOC_TRACE
  212283             :         if (blockIndex > 0) {
  212284             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateSymbol) = %" PRIuPTR " SgTemplateSymbol::pool_size = %d \n",
  212285             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateSymbol),SgTemplateSymbol::pool_size);
  212286             :         }
  212287             : #endif
  212288             : 
  212289           0 :         SgTemplateSymbol * pointer = (SgTemplateSymbol*) ROSE_MALLOC ( SgTemplateSymbol::pool_size * sizeof(SgTemplateSymbol) );
  212290           0 :         assert( pointer != NULL );
  212291             : #if ROSE_ALLOC_MEMSET == 1
  212292             :         memset(pointer, 0x00, SgTemplateSymbol::pool_size * sizeof(SgTemplateSymbol));
  212293             : #elif ROSE_ALLOC_MEMSET == 2
  212294             :         memset(pointer, 0xCC, SgTemplateSymbol::pool_size * sizeof(SgTemplateSymbol));
  212295             : #endif
  212296           0 :         SgTemplateSymbol::pools.push_back( (unsigned char*)(pointer) );
  212297           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateSymbol::pool_size * sizeof(SgTemplateSymbol), V_SgTemplateSymbol ) );
  212298             : 
  212299           0 :         if ( SgTemplateSymbol::next_node != NULL ) {
  212300           0 :           if ( blockIndex > 0 ) {
  212301           0 :             SgTemplateSymbol * blkptr = (SgTemplateSymbol*)(SgTemplateSymbol::pools[blockIndex-1]);
  212302           0 :             blkptr[ SgTemplateSymbol::pool_size - 1 ].set_freepointer(pointer);
  212303             :           }
  212304             :         } else {
  212305           0 :           SgTemplateSymbol::next_node = pointer;
  212306             :         }
  212307             : 
  212308           0 :         for (unsigned i = 0; i < SgTemplateSymbol::pool_size-1; ++i)
  212309             :            {
  212310           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  212311             :            }
  212312           0 :         pointer[ SgTemplateSymbol::pool_size -1 ].set_freepointer(NULL);
  212313             : 
  212314           0 :         blockIndex++;
  212315             :       }
  212316           2 :   }
  212317             : 
  212318             : //############################################################################
  212319             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  212320             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  212321             :  * not compressed. However, that stuff is not yet implemented! 
  212322             :  */
  212323             : unsigned long
  212324           0 : SgTemplateSymbol::getNumberOfLastValidPointer()
  212325             :    {
  212326           0 :       SgTemplateSymbol* testPointer = (SgTemplateSymbol*)(SgTemplateSymbol::pools.back());
  212327           0 :       unsigned long localIndex = SgTemplateSymbol::pool_size - 1;
  212328           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  212329             :          {
  212330           0 :            localIndex--;
  212331             :          }
  212332           0 :       return (localIndex + SgTemplateSymbol::pool_size * (SgTemplateSymbol::pools.size()-1));
  212333             :    }
  212334             : 
  212335             : //############################################################################
  212336             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  212337             :  * memory pool and initializes the data member in class SgTemplateSymbolStroageClass
  212338             :  * from its counterpart of SgTemplateSymbol. The return value is just for checking, 
  212339             :  * that the whole StorageClassArray is initialized!
  212340             :  */
  212341             : unsigned long
  212342           0 : SgTemplateSymbol::initializeStorageClassArray( SgTemplateSymbolStorageClass *storageArray )
  212343             :    {
  212344           0 :      unsigned long storageCounter = 0;
  212345           0 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateSymbol::pools.begin();
  212346           0 :      SgTemplateSymbol* pointer = NULL;
  212347           0 :      while ( block != SgTemplateSymbol::pools.end() ) {
  212348           0 :           pointer = (SgTemplateSymbol*) (*block);
  212349           0 :           for ( unsigned i = 0; i < SgTemplateSymbol::pool_size; ++i ) {
  212350           0 :                if ( pointer->get_freepointer() != NULL ) {
  212351           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  212352           0 :                  storageArray++;
  212353           0 :                  storageCounter++;
  212354             :                }
  212355           0 :                pointer++;
  212356             :              }
  212357           0 :            block++;
  212358             :         }
  212359           0 :      return storageCounter;
  212360             :    }
  212361             : 
  212362             : /* #line 212363 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  212363             : 
  212364             : 
  212365             : 
  212366             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  212367             : 
  212368             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  212369             : 
  212370             : //############################################################################
  212371             : /* JH (02/02/2006) Constructor of the IR node SgEnumSymbol that takes its 
  212372             :  * corresponding StorageClass as parameter
  212373             :  */
  212374          88 : SgEnumSymbol :: SgEnumSymbol ( const SgEnumSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  212375             :    {
  212376             : 
  212377             : 
  212378             : /* #line 212379 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  212379             : 
  212380          88 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  212381          88 :      p_declaration =  (SgEnumDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  212382             : 
  212383             : 
  212384             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  212385             : 
  212386             : 
  212387          88 :    }
  212388             : 
  212389             : //############################################################################
  212390             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  212391             :  * within the working AST. 
  212392             :  */
  212393         130 : SgEnumSymbol * SgEnumSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  212394         130 :      SgEnumSymbol* returnPointer = NULL;
  212395         130 :      if ( globalIndex != 0 )
  212396             :         {
  212397             : 
  212398             : #if FILE_IO_EXTRA_CHECK
  212399         130 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEnumSymbol ) ) <= globalIndex ) ;
  212400         130 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumSymbol + 1 ) ) );
  212401             : #endif
  212402         130 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumSymbol )  
  212403         130 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEnumSymbol );
  212404         130 :           unsigned long positionInPool = localIndex % SgEnumSymbol::pool_size;
  212405         130 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumSymbol::pool_size;
  212406             : 
  212407             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  212408             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  212409             : 
  212410         130 :           returnPointer = &( ( (SgEnumSymbol*)(SgEnumSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  212411             : 
  212412         130 :           ROSE_ASSERT( returnPointer != NULL ) ;
  212413             :         }
  212414         130 :      return returnPointer ;
  212415             :    }
  212416             : 
  212417             : //############################################################################
  212418             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  212419             :   for the AST with the index astIndex
  212420             : */
  212421           0 : SgEnumSymbol * SgEnumSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  212422           0 :      SgEnumSymbol* returnPointer = NULL;
  212423           0 :      if ( globalIndex != 0 )
  212424             :         {
  212425             : 
  212426             : #if FILE_IO_EXTRA_CHECK
  212427           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEnumSymbol ) ) <= globalIndex ) ;
  212428           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumSymbol + 1 ) ) );
  212429             : #endif
  212430           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumSymbol )
  212431           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEnumSymbol );
  212432           0 :           unsigned long positionInPool = localIndex % SgEnumSymbol::pool_size ;
  212433           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumSymbol::pool_size ;
  212434             : 
  212435             : #if FILE_IO_EXTRA_CHECK
  212436             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  212437             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  212438             : #endif
  212439             : 
  212440           0 :           returnPointer = &( ( (SgEnumSymbol*)(SgEnumSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  212441             : 
  212442             : #if FILE_IO_EXTRA_CHECK
  212443           0 :           assert ( returnPointer != NULL ) ;
  212444             : #endif
  212445             :         }
  212446           0 :      return returnPointer ;
  212447             :    }
  212448             : 
  212449             : //############################################################################
  212450             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  212451             :  * pool size! We set for every valid object in the memory pool the freepointer
  212452             :  * to the global index and increase the global index afterwards. For all the 
  212453             :  * invalid objects (means address ranges within the memory pool that were not
  212454             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  212455             :  * distinguish valid from invalid objects! 
  212456             :  */
  212457             : unsigned long
  212458           5 : SgEnumSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  212459             :    {
  212460           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  212461           5 :      SgEnumSymbol* pointer = NULL;
  212462           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  212463           5 :      std::vector < unsigned char* > :: const_iterator block;
  212464           6 :      for ( block = SgEnumSymbol::pools.begin(); block != SgEnumSymbol::pools.end() ; ++block )
  212465             :         {
  212466           1 :           pointer = (SgEnumSymbol*)(*block);
  212467        2001 :           for (unsigned i = 0; i < SgEnumSymbol::pool_size; ++i )
  212468             :              {
  212469             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  212470             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  212471             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  212472             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  212473             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  212474             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  212475             :             // properly; so this will have to be checked next.
  212476             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  212477             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  212478        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  212479             :                   {
  212480          88 :                     pointer[i].set_freepointer((SgEnumSymbol*)(globalIndex));
  212481          88 :                     globalIndex++;
  212482             :                   }
  212483             :                else
  212484             :                   {
  212485        1912 :                     pointer[i].set_freepointer(NULL);
  212486             :                   }
  212487             :               }
  212488             :         }
  212489           5 :      return globalIndex;
  212490             :    }
  212491             : 
  212492             : //############################################################################
  212493             : // JH (01/14/2006)
  212494             : void
  212495           5 : SgEnumSymbol::resetValidFreepointers( )
  212496             :    {
  212497           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  212498           5 :      SgEnumSymbol* pointer = NULL;
  212499           5 :      std::vector < unsigned char* > :: const_iterator block;
  212500           5 :      SgEnumSymbol* pointerOfLinkedList = NULL;
  212501           6 :      for ( block = SgEnumSymbol::pools.begin(); block != SgEnumSymbol::pools.end() ; ++block )
  212502             :         {
  212503           1 :           pointer = (SgEnumSymbol*)(*block);
  212504        2001 :           for (unsigned i = 0; i < SgEnumSymbol::pool_size; ++i )
  212505             :              {
  212506             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  212507             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  212508             :             // memory blocks!.
  212509        2000 :                if ( pointer[i].get_freepointer() != NULL )
  212510             :                   {
  212511          88 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  212512             :                   }
  212513             :                else
  212514             :                   {
  212515        1912 :                     if ( pointerOfLinkedList == NULL )
  212516             :                        {
  212517           1 :                          SgEnumSymbol::next_node = &(pointer[i]);
  212518             :                        }
  212519             :                     else
  212520             :                        {
  212521             :                       // printf ("In SgEnumSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  212522        1911 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  212523             :                        }
  212524             :                     pointerOfLinkedList = &(pointer[i]);
  212525             :                   }
  212526             :               }
  212527             :         }
  212528             : 
  212529           5 :      if ( pointerOfLinkedList != NULL )
  212530             :         {
  212531             :        // printf ("In SgEnumSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  212532           1 :           pointerOfLinkedList->set_freepointer(NULL);
  212533             :        // DQ (6/6/2010): Temporary debugging...
  212534             :        //   ROSE_ASSERT(false);
  212535             :         }
  212536             : 
  212537           5 :      return ;
  212538             :    }
  212539             : 
  212540             : //############################################################################
  212541             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  212542             :  * within the memory pool and resets the freepointers, in order to achieve a 
  212543             :  * linked list, that has no jumps and starts at the beginning! This function 
  212544             :  * does not extend the memory pool, since we do not delete any memory blocks,
  212545             :  * but delete the valid objects.  
  212546             :  */
  212547             : void
  212548           0 : SgEnumSymbol::clearMemoryPool( )
  212549             :    {
  212550             :   // printf ("Inside of SgEnumSymbol::clearMemoryPool() \n");
  212551             : 
  212552           0 :      SgEnumSymbol* pointer = NULL, *tempPointer = NULL;
  212553           0 :      std::vector < unsigned char* > :: const_iterator block;
  212554           0 :      if ( SgEnumSymbol::pools.empty() == false )
  212555             :         {
  212556           0 :           block = SgEnumSymbol::pools.begin() ;
  212557           0 :           SgEnumSymbol::next_node = (SgEnumSymbol*) (*block);
  212558             : 
  212559           0 :           while ( block != SgEnumSymbol::pools.end() )
  212560             :              {
  212561           0 :                pointer = (SgEnumSymbol*) (*block);
  212562           0 :                if ( tempPointer != NULL )
  212563             :                   {
  212564           0 :                     tempPointer->set_freepointer(pointer);
  212565             :                   }
  212566           0 :                for (unsigned i = 0; i < SgEnumSymbol::pool_size - 1; ++i)
  212567             :                   {
  212568           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  212569             :                   }
  212570           0 :                 pointer[SgEnumSymbol::pool_size-1].set_freepointer(NULL);
  212571           0 :                 tempPointer = &(pointer[SgEnumSymbol::pool_size-1]);
  212572           0 :                 ++block;
  212573             :              }
  212574             :         }
  212575           0 :    }
  212576             : 
  212577           5 : void SgEnumSymbol::deleteMemoryPool() {
  212578           7 :   for (auto p: SgEnumSymbol::pools) {
  212579           2 :     ROSE_FREE(p);
  212580             :   }
  212581           5 :   SgEnumSymbol::next_node = nullptr;
  212582           5 :   SgEnumSymbol::pools.clear();
  212583           5 : }
  212584             : 
  212585             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  212586             : //                 reading multiple binary files to for a single AST.
  212587             : /////////// new version ////////////////////////////////
  212588             : //############################################################################
  212589             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  212590             : void
  212591           2 : SgEnumSymbol::extendMemoryPoolForFileIO( )
  212592             :   {
  212593           2 :     size_t blockIndex = SgEnumSymbol::pools.size();
  212594           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumSymbol);
  212595             : 
  212596           3 :     while ( (blockIndex * SgEnumSymbol::pool_size) < newPoolSize)
  212597             :       {
  212598             : #if ROSE_ALLOC_TRACE
  212599             :         if (blockIndex > 0) {
  212600             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumSymbol) = %" PRIuPTR " SgEnumSymbol::pool_size = %d \n",
  212601             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumSymbol),SgEnumSymbol::pool_size);
  212602             :         }
  212603             : #endif
  212604             : 
  212605           1 :         SgEnumSymbol * pointer = (SgEnumSymbol*) ROSE_MALLOC ( SgEnumSymbol::pool_size * sizeof(SgEnumSymbol) );
  212606           1 :         assert( pointer != NULL );
  212607             : #if ROSE_ALLOC_MEMSET == 1
  212608             :         memset(pointer, 0x00, SgEnumSymbol::pool_size * sizeof(SgEnumSymbol));
  212609             : #elif ROSE_ALLOC_MEMSET == 2
  212610             :         memset(pointer, 0xCC, SgEnumSymbol::pool_size * sizeof(SgEnumSymbol));
  212611             : #endif
  212612           1 :         SgEnumSymbol::pools.push_back( (unsigned char*)(pointer) );
  212613           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEnumSymbol::pool_size * sizeof(SgEnumSymbol), V_SgEnumSymbol ) );
  212614             : 
  212615           1 :         if ( SgEnumSymbol::next_node != NULL ) {
  212616           0 :           if ( blockIndex > 0 ) {
  212617           0 :             SgEnumSymbol * blkptr = (SgEnumSymbol*)(SgEnumSymbol::pools[blockIndex-1]);
  212618           0 :             blkptr[ SgEnumSymbol::pool_size - 1 ].set_freepointer(pointer);
  212619             :           }
  212620             :         } else {
  212621           1 :           SgEnumSymbol::next_node = pointer;
  212622             :         }
  212623             : 
  212624        2000 :         for (unsigned i = 0; i < SgEnumSymbol::pool_size-1; ++i)
  212625             :            {
  212626        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  212627             :            }
  212628           1 :         pointer[ SgEnumSymbol::pool_size -1 ].set_freepointer(NULL);
  212629             : 
  212630           1 :         blockIndex++;
  212631             :       }
  212632           2 :   }
  212633             : 
  212634             : //############################################################################
  212635             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  212636             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  212637             :  * not compressed. However, that stuff is not yet implemented! 
  212638             :  */
  212639             : unsigned long
  212640           0 : SgEnumSymbol::getNumberOfLastValidPointer()
  212641             :    {
  212642           0 :       SgEnumSymbol* testPointer = (SgEnumSymbol*)(SgEnumSymbol::pools.back());
  212643           0 :       unsigned long localIndex = SgEnumSymbol::pool_size - 1;
  212644           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  212645             :          {
  212646           0 :            localIndex--;
  212647             :          }
  212648           0 :       return (localIndex + SgEnumSymbol::pool_size * (SgEnumSymbol::pools.size()-1));
  212649             :    }
  212650             : 
  212651             : //############################################################################
  212652             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  212653             :  * memory pool and initializes the data member in class SgEnumSymbolStroageClass
  212654             :  * from its counterpart of SgEnumSymbol. The return value is just for checking, 
  212655             :  * that the whole StorageClassArray is initialized!
  212656             :  */
  212657             : unsigned long
  212658           1 : SgEnumSymbol::initializeStorageClassArray( SgEnumSymbolStorageClass *storageArray )
  212659             :    {
  212660           1 :      unsigned long storageCounter = 0;
  212661           1 :      std::vector < unsigned char* > :: const_iterator block = SgEnumSymbol::pools.begin();
  212662           1 :      SgEnumSymbol* pointer = NULL;
  212663           2 :      while ( block != SgEnumSymbol::pools.end() ) {
  212664           1 :           pointer = (SgEnumSymbol*) (*block);
  212665        2001 :           for ( unsigned i = 0; i < SgEnumSymbol::pool_size; ++i ) {
  212666        2000 :                if ( pointer->get_freepointer() != NULL ) {
  212667          88 :                  storageArray->pickOutIRNodeData (pointer) ;
  212668          88 :                  storageArray++;
  212669          88 :                  storageCounter++;
  212670             :                }
  212671        2000 :                pointer++;
  212672             :              }
  212673           1 :            block++;
  212674             :         }
  212675           1 :      return storageCounter;
  212676             :    }
  212677             : 
  212678             : /* #line 212679 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  212679             : 
  212680             : 
  212681             : 
  212682             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  212683             : 
  212684             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  212685             : 
  212686             : //############################################################################
  212687             : /* JH (02/02/2006) Constructor of the IR node SgEnumFieldSymbol that takes its 
  212688             :  * corresponding StorageClass as parameter
  212689             :  */
  212690         279 : SgEnumFieldSymbol :: SgEnumFieldSymbol ( const SgEnumFieldSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  212691             :    {
  212692             : 
  212693             : 
  212694             : /* #line 212695 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  212695             : 
  212696         279 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  212697         279 :      p_declaration =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  212698             : 
  212699             : 
  212700             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  212701             : 
  212702             : 
  212703         279 :    }
  212704             : 
  212705             : //############################################################################
  212706             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  212707             :  * within the working AST. 
  212708             :  */
  212709         432 : SgEnumFieldSymbol * SgEnumFieldSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  212710         432 :      SgEnumFieldSymbol* returnPointer = NULL;
  212711         432 :      if ( globalIndex != 0 )
  212712             :         {
  212713             : 
  212714             : #if FILE_IO_EXTRA_CHECK
  212715         432 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgEnumFieldSymbol ) ) <= globalIndex ) ;
  212716         432 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumFieldSymbol + 1 ) ) );
  212717             : #endif
  212718         432 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgEnumFieldSymbol )  
  212719         432 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgEnumFieldSymbol );
  212720         432 :           unsigned long positionInPool = localIndex % SgEnumFieldSymbol::pool_size;
  212721         432 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumFieldSymbol::pool_size;
  212722             : 
  212723             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  212724             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  212725             : 
  212726         432 :           returnPointer = &( ( (SgEnumFieldSymbol*)(SgEnumFieldSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  212727             : 
  212728         432 :           ROSE_ASSERT( returnPointer != NULL ) ;
  212729             :         }
  212730         432 :      return returnPointer ;
  212731             :    }
  212732             : 
  212733             : //############################################################################
  212734             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  212735             :   for the AST with the index astIndex
  212736             : */
  212737           0 : SgEnumFieldSymbol * SgEnumFieldSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  212738           0 :      SgEnumFieldSymbol* returnPointer = NULL;
  212739           0 :      if ( globalIndex != 0 )
  212740             :         {
  212741             : 
  212742             : #if FILE_IO_EXTRA_CHECK
  212743           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgEnumFieldSymbol ) ) <= globalIndex ) ;
  212744           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumFieldSymbol + 1 ) ) );
  212745             : #endif
  212746           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgEnumFieldSymbol )
  212747           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgEnumFieldSymbol );
  212748           0 :           unsigned long positionInPool = localIndex % SgEnumFieldSymbol::pool_size ;
  212749           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgEnumFieldSymbol::pool_size ;
  212750             : 
  212751             : #if FILE_IO_EXTRA_CHECK
  212752             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  212753             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  212754             : #endif
  212755             : 
  212756           0 :           returnPointer = &( ( (SgEnumFieldSymbol*)(SgEnumFieldSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  212757             : 
  212758             : #if FILE_IO_EXTRA_CHECK
  212759           0 :           assert ( returnPointer != NULL ) ;
  212760             : #endif
  212761             :         }
  212762           0 :      return returnPointer ;
  212763             :    }
  212764             : 
  212765             : //############################################################################
  212766             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  212767             :  * pool size! We set for every valid object in the memory pool the freepointer
  212768             :  * to the global index and increase the global index afterwards. For all the 
  212769             :  * invalid objects (means address ranges within the memory pool that were not
  212770             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  212771             :  * distinguish valid from invalid objects! 
  212772             :  */
  212773             : unsigned long
  212774           5 : SgEnumFieldSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  212775             :    {
  212776           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  212777           5 :      SgEnumFieldSymbol* pointer = NULL;
  212778           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  212779           5 :      std::vector < unsigned char* > :: const_iterator block;
  212780           6 :      for ( block = SgEnumFieldSymbol::pools.begin(); block != SgEnumFieldSymbol::pools.end() ; ++block )
  212781             :         {
  212782           1 :           pointer = (SgEnumFieldSymbol*)(*block);
  212783        2001 :           for (unsigned i = 0; i < SgEnumFieldSymbol::pool_size; ++i )
  212784             :              {
  212785             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  212786             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  212787             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  212788             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  212789             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  212790             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  212791             :             // properly; so this will have to be checked next.
  212792             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  212793             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  212794        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  212795             :                   {
  212796         279 :                     pointer[i].set_freepointer((SgEnumFieldSymbol*)(globalIndex));
  212797         279 :                     globalIndex++;
  212798             :                   }
  212799             :                else
  212800             :                   {
  212801        1721 :                     pointer[i].set_freepointer(NULL);
  212802             :                   }
  212803             :               }
  212804             :         }
  212805           5 :      return globalIndex;
  212806             :    }
  212807             : 
  212808             : //############################################################################
  212809             : // JH (01/14/2006)
  212810             : void
  212811           5 : SgEnumFieldSymbol::resetValidFreepointers( )
  212812             :    {
  212813           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  212814           5 :      SgEnumFieldSymbol* pointer = NULL;
  212815           5 :      std::vector < unsigned char* > :: const_iterator block;
  212816           5 :      SgEnumFieldSymbol* pointerOfLinkedList = NULL;
  212817           6 :      for ( block = SgEnumFieldSymbol::pools.begin(); block != SgEnumFieldSymbol::pools.end() ; ++block )
  212818             :         {
  212819           1 :           pointer = (SgEnumFieldSymbol*)(*block);
  212820        2001 :           for (unsigned i = 0; i < SgEnumFieldSymbol::pool_size; ++i )
  212821             :              {
  212822             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  212823             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  212824             :             // memory blocks!.
  212825        2000 :                if ( pointer[i].get_freepointer() != NULL )
  212826             :                   {
  212827         279 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  212828             :                   }
  212829             :                else
  212830             :                   {
  212831        1721 :                     if ( pointerOfLinkedList == NULL )
  212832             :                        {
  212833           1 :                          SgEnumFieldSymbol::next_node = &(pointer[i]);
  212834             :                        }
  212835             :                     else
  212836             :                        {
  212837             :                       // printf ("In SgEnumFieldSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  212838        1720 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  212839             :                        }
  212840             :                     pointerOfLinkedList = &(pointer[i]);
  212841             :                   }
  212842             :               }
  212843             :         }
  212844             : 
  212845           5 :      if ( pointerOfLinkedList != NULL )
  212846             :         {
  212847             :        // printf ("In SgEnumFieldSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  212848           1 :           pointerOfLinkedList->set_freepointer(NULL);
  212849             :        // DQ (6/6/2010): Temporary debugging...
  212850             :        //   ROSE_ASSERT(false);
  212851             :         }
  212852             : 
  212853           5 :      return ;
  212854             :    }
  212855             : 
  212856             : //############################################################################
  212857             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  212858             :  * within the memory pool and resets the freepointers, in order to achieve a 
  212859             :  * linked list, that has no jumps and starts at the beginning! This function 
  212860             :  * does not extend the memory pool, since we do not delete any memory blocks,
  212861             :  * but delete the valid objects.  
  212862             :  */
  212863             : void
  212864           0 : SgEnumFieldSymbol::clearMemoryPool( )
  212865             :    {
  212866             :   // printf ("Inside of SgEnumFieldSymbol::clearMemoryPool() \n");
  212867             : 
  212868           0 :      SgEnumFieldSymbol* pointer = NULL, *tempPointer = NULL;
  212869           0 :      std::vector < unsigned char* > :: const_iterator block;
  212870           0 :      if ( SgEnumFieldSymbol::pools.empty() == false )
  212871             :         {
  212872           0 :           block = SgEnumFieldSymbol::pools.begin() ;
  212873           0 :           SgEnumFieldSymbol::next_node = (SgEnumFieldSymbol*) (*block);
  212874             : 
  212875           0 :           while ( block != SgEnumFieldSymbol::pools.end() )
  212876             :              {
  212877           0 :                pointer = (SgEnumFieldSymbol*) (*block);
  212878           0 :                if ( tempPointer != NULL )
  212879             :                   {
  212880           0 :                     tempPointer->set_freepointer(pointer);
  212881             :                   }
  212882           0 :                for (unsigned i = 0; i < SgEnumFieldSymbol::pool_size - 1; ++i)
  212883             :                   {
  212884           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  212885             :                   }
  212886           0 :                 pointer[SgEnumFieldSymbol::pool_size-1].set_freepointer(NULL);
  212887           0 :                 tempPointer = &(pointer[SgEnumFieldSymbol::pool_size-1]);
  212888           0 :                 ++block;
  212889             :              }
  212890             :         }
  212891           0 :    }
  212892             : 
  212893           5 : void SgEnumFieldSymbol::deleteMemoryPool() {
  212894           7 :   for (auto p: SgEnumFieldSymbol::pools) {
  212895           2 :     ROSE_FREE(p);
  212896             :   }
  212897           5 :   SgEnumFieldSymbol::next_node = nullptr;
  212898           5 :   SgEnumFieldSymbol::pools.clear();
  212899           5 : }
  212900             : 
  212901             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  212902             : //                 reading multiple binary files to for a single AST.
  212903             : /////////// new version ////////////////////////////////
  212904             : //############################################################################
  212905             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  212906             : void
  212907           2 : SgEnumFieldSymbol::extendMemoryPoolForFileIO( )
  212908             :   {
  212909           2 :     size_t blockIndex = SgEnumFieldSymbol::pools.size();
  212910           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumFieldSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumFieldSymbol);
  212911             : 
  212912           3 :     while ( (blockIndex * SgEnumFieldSymbol::pool_size) < newPoolSize)
  212913             :       {
  212914             : #if ROSE_ALLOC_TRACE
  212915             :         if (blockIndex > 0) {
  212916             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumFieldSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumFieldSymbol) = %" PRIuPTR " SgEnumFieldSymbol::pool_size = %d \n",
  212917             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgEnumFieldSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgEnumFieldSymbol),SgEnumFieldSymbol::pool_size);
  212918             :         }
  212919             : #endif
  212920             : 
  212921           1 :         SgEnumFieldSymbol * pointer = (SgEnumFieldSymbol*) ROSE_MALLOC ( SgEnumFieldSymbol::pool_size * sizeof(SgEnumFieldSymbol) );
  212922           1 :         assert( pointer != NULL );
  212923             : #if ROSE_ALLOC_MEMSET == 1
  212924             :         memset(pointer, 0x00, SgEnumFieldSymbol::pool_size * sizeof(SgEnumFieldSymbol));
  212925             : #elif ROSE_ALLOC_MEMSET == 2
  212926             :         memset(pointer, 0xCC, SgEnumFieldSymbol::pool_size * sizeof(SgEnumFieldSymbol));
  212927             : #endif
  212928           1 :         SgEnumFieldSymbol::pools.push_back( (unsigned char*)(pointer) );
  212929           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgEnumFieldSymbol::pool_size * sizeof(SgEnumFieldSymbol), V_SgEnumFieldSymbol ) );
  212930             : 
  212931           1 :         if ( SgEnumFieldSymbol::next_node != NULL ) {
  212932           0 :           if ( blockIndex > 0 ) {
  212933           0 :             SgEnumFieldSymbol * blkptr = (SgEnumFieldSymbol*)(SgEnumFieldSymbol::pools[blockIndex-1]);
  212934           0 :             blkptr[ SgEnumFieldSymbol::pool_size - 1 ].set_freepointer(pointer);
  212935             :           }
  212936             :         } else {
  212937           1 :           SgEnumFieldSymbol::next_node = pointer;
  212938             :         }
  212939             : 
  212940        2000 :         for (unsigned i = 0; i < SgEnumFieldSymbol::pool_size-1; ++i)
  212941             :            {
  212942        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  212943             :            }
  212944           1 :         pointer[ SgEnumFieldSymbol::pool_size -1 ].set_freepointer(NULL);
  212945             : 
  212946           1 :         blockIndex++;
  212947             :       }
  212948           2 :   }
  212949             : 
  212950             : //############################################################################
  212951             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  212952             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  212953             :  * not compressed. However, that stuff is not yet implemented! 
  212954             :  */
  212955             : unsigned long
  212956           0 : SgEnumFieldSymbol::getNumberOfLastValidPointer()
  212957             :    {
  212958           0 :       SgEnumFieldSymbol* testPointer = (SgEnumFieldSymbol*)(SgEnumFieldSymbol::pools.back());
  212959           0 :       unsigned long localIndex = SgEnumFieldSymbol::pool_size - 1;
  212960           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  212961             :          {
  212962           0 :            localIndex--;
  212963             :          }
  212964           0 :       return (localIndex + SgEnumFieldSymbol::pool_size * (SgEnumFieldSymbol::pools.size()-1));
  212965             :    }
  212966             : 
  212967             : //############################################################################
  212968             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  212969             :  * memory pool and initializes the data member in class SgEnumFieldSymbolStroageClass
  212970             :  * from its counterpart of SgEnumFieldSymbol. The return value is just for checking, 
  212971             :  * that the whole StorageClassArray is initialized!
  212972             :  */
  212973             : unsigned long
  212974           1 : SgEnumFieldSymbol::initializeStorageClassArray( SgEnumFieldSymbolStorageClass *storageArray )
  212975             :    {
  212976           1 :      unsigned long storageCounter = 0;
  212977           1 :      std::vector < unsigned char* > :: const_iterator block = SgEnumFieldSymbol::pools.begin();
  212978           1 :      SgEnumFieldSymbol* pointer = NULL;
  212979           2 :      while ( block != SgEnumFieldSymbol::pools.end() ) {
  212980           1 :           pointer = (SgEnumFieldSymbol*) (*block);
  212981        2001 :           for ( unsigned i = 0; i < SgEnumFieldSymbol::pool_size; ++i ) {
  212982        2000 :                if ( pointer->get_freepointer() != NULL ) {
  212983         279 :                  storageArray->pickOutIRNodeData (pointer) ;
  212984         279 :                  storageArray++;
  212985         279 :                  storageCounter++;
  212986             :                }
  212987        2000 :                pointer++;
  212988             :              }
  212989           1 :            block++;
  212990             :         }
  212991           1 :      return storageCounter;
  212992             :    }
  212993             : 
  212994             : /* #line 212995 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  212995             : 
  212996             : 
  212997             : 
  212998             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  212999             : 
  213000             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  213001             : 
  213002             : //############################################################################
  213003             : /* JH (02/02/2006) Constructor of the IR node SgTypedefSymbol that takes its 
  213004             :  * corresponding StorageClass as parameter
  213005             :  */
  213006        1879 : SgTypedefSymbol :: SgTypedefSymbol ( const SgTypedefSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  213007             :    {
  213008             : 
  213009             : 
  213010             : /* #line 213011 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  213011             : 
  213012        1879 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  213013        1879 :      p_declaration =  (SgTypedefDeclaration*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  213014             : 
  213015             : 
  213016             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  213017             : 
  213018             : 
  213019        1879 :    }
  213020             : 
  213021             : //############################################################################
  213022             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  213023             :  * within the working AST. 
  213024             :  */
  213025        3135 : SgTypedefSymbol * SgTypedefSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  213026        3135 :      SgTypedefSymbol* returnPointer = NULL;
  213027        3135 :      if ( globalIndex != 0 )
  213028             :         {
  213029             : 
  213030             : #if FILE_IO_EXTRA_CHECK
  213031        3135 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTypedefSymbol ) ) <= globalIndex ) ;
  213032        3135 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypedefSymbol + 1 ) ) );
  213033             : #endif
  213034        3135 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTypedefSymbol )  
  213035        3135 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTypedefSymbol );
  213036        3135 :           unsigned long positionInPool = localIndex % SgTypedefSymbol::pool_size;
  213037        3135 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypedefSymbol::pool_size;
  213038             : 
  213039             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  213040             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  213041             : 
  213042        3135 :           returnPointer = &( ( (SgTypedefSymbol*)(SgTypedefSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  213043             : 
  213044        3135 :           ROSE_ASSERT( returnPointer != NULL ) ;
  213045             :         }
  213046        3135 :      return returnPointer ;
  213047             :    }
  213048             : 
  213049             : //############################################################################
  213050             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  213051             :   for the AST with the index astIndex
  213052             : */
  213053           0 : SgTypedefSymbol * SgTypedefSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  213054           0 :      SgTypedefSymbol* returnPointer = NULL;
  213055           0 :      if ( globalIndex != 0 )
  213056             :         {
  213057             : 
  213058             : #if FILE_IO_EXTRA_CHECK
  213059           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTypedefSymbol ) ) <= globalIndex ) ;
  213060           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypedefSymbol + 1 ) ) );
  213061             : #endif
  213062           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTypedefSymbol )
  213063           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTypedefSymbol );
  213064           0 :           unsigned long positionInPool = localIndex % SgTypedefSymbol::pool_size ;
  213065           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTypedefSymbol::pool_size ;
  213066             : 
  213067             : #if FILE_IO_EXTRA_CHECK
  213068             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  213069             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  213070             : #endif
  213071             : 
  213072           0 :           returnPointer = &( ( (SgTypedefSymbol*)(SgTypedefSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  213073             : 
  213074             : #if FILE_IO_EXTRA_CHECK
  213075           0 :           assert ( returnPointer != NULL ) ;
  213076             : #endif
  213077             :         }
  213078           0 :      return returnPointer ;
  213079             :    }
  213080             : 
  213081             : //############################################################################
  213082             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  213083             :  * pool size! We set for every valid object in the memory pool the freepointer
  213084             :  * to the global index and increase the global index afterwards. For all the 
  213085             :  * invalid objects (means address ranges within the memory pool that were not
  213086             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  213087             :  * distinguish valid from invalid objects! 
  213088             :  */
  213089             : unsigned long
  213090           5 : SgTypedefSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  213091             :    {
  213092           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  213093           5 :      SgTypedefSymbol* pointer = NULL;
  213094           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  213095           5 :      std::vector < unsigned char* > :: const_iterator block;
  213096           7 :      for ( block = SgTypedefSymbol::pools.begin(); block != SgTypedefSymbol::pools.end() ; ++block )
  213097             :         {
  213098           2 :           pointer = (SgTypedefSymbol*)(*block);
  213099        4002 :           for (unsigned i = 0; i < SgTypedefSymbol::pool_size; ++i )
  213100             :              {
  213101             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  213102             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  213103             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  213104             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  213105             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  213106             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  213107             :             // properly; so this will have to be checked next.
  213108             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  213109             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  213110        4000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  213111             :                   {
  213112        1719 :                     pointer[i].set_freepointer((SgTypedefSymbol*)(globalIndex));
  213113        1719 :                     globalIndex++;
  213114             :                   }
  213115             :                else
  213116             :                   {
  213117        2281 :                     pointer[i].set_freepointer(NULL);
  213118             :                   }
  213119             :               }
  213120             :         }
  213121           5 :      return globalIndex;
  213122             :    }
  213123             : 
  213124             : //############################################################################
  213125             : // JH (01/14/2006)
  213126             : void
  213127           5 : SgTypedefSymbol::resetValidFreepointers( )
  213128             :    {
  213129           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  213130           5 :      SgTypedefSymbol* pointer = NULL;
  213131           5 :      std::vector < unsigned char* > :: const_iterator block;
  213132           5 :      SgTypedefSymbol* pointerOfLinkedList = NULL;
  213133           7 :      for ( block = SgTypedefSymbol::pools.begin(); block != SgTypedefSymbol::pools.end() ; ++block )
  213134             :         {
  213135           2 :           pointer = (SgTypedefSymbol*)(*block);
  213136        4002 :           for (unsigned i = 0; i < SgTypedefSymbol::pool_size; ++i )
  213137             :              {
  213138             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  213139             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  213140             :             // memory blocks!.
  213141        4000 :                if ( pointer[i].get_freepointer() != NULL )
  213142             :                   {
  213143        1719 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  213144             :                   }
  213145             :                else
  213146             :                   {
  213147        2281 :                     if ( pointerOfLinkedList == NULL )
  213148             :                        {
  213149           2 :                          SgTypedefSymbol::next_node = &(pointer[i]);
  213150             :                        }
  213151             :                     else
  213152             :                        {
  213153             :                       // printf ("In SgTypedefSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  213154        2279 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  213155             :                        }
  213156             :                     pointerOfLinkedList = &(pointer[i]);
  213157             :                   }
  213158             :               }
  213159             :         }
  213160             : 
  213161           5 :      if ( pointerOfLinkedList != NULL )
  213162             :         {
  213163             :        // printf ("In SgTypedefSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  213164           2 :           pointerOfLinkedList->set_freepointer(NULL);
  213165             :        // DQ (6/6/2010): Temporary debugging...
  213166             :        //   ROSE_ASSERT(false);
  213167             :         }
  213168             : 
  213169           5 :      return ;
  213170             :    }
  213171             : 
  213172             : //############################################################################
  213173             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  213174             :  * within the memory pool and resets the freepointers, in order to achieve a 
  213175             :  * linked list, that has no jumps and starts at the beginning! This function 
  213176             :  * does not extend the memory pool, since we do not delete any memory blocks,
  213177             :  * but delete the valid objects.  
  213178             :  */
  213179             : void
  213180           0 : SgTypedefSymbol::clearMemoryPool( )
  213181             :    {
  213182             :   // printf ("Inside of SgTypedefSymbol::clearMemoryPool() \n");
  213183             : 
  213184           0 :      SgTypedefSymbol* pointer = NULL, *tempPointer = NULL;
  213185           0 :      std::vector < unsigned char* > :: const_iterator block;
  213186           0 :      if ( SgTypedefSymbol::pools.empty() == false )
  213187             :         {
  213188           0 :           block = SgTypedefSymbol::pools.begin() ;
  213189           0 :           SgTypedefSymbol::next_node = (SgTypedefSymbol*) (*block);
  213190             : 
  213191           0 :           while ( block != SgTypedefSymbol::pools.end() )
  213192             :              {
  213193           0 :                pointer = (SgTypedefSymbol*) (*block);
  213194           0 :                if ( tempPointer != NULL )
  213195             :                   {
  213196           0 :                     tempPointer->set_freepointer(pointer);
  213197             :                   }
  213198           0 :                for (unsigned i = 0; i < SgTypedefSymbol::pool_size - 1; ++i)
  213199             :                   {
  213200           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  213201             :                   }
  213202           0 :                 pointer[SgTypedefSymbol::pool_size-1].set_freepointer(NULL);
  213203           0 :                 tempPointer = &(pointer[SgTypedefSymbol::pool_size-1]);
  213204           0 :                 ++block;
  213205             :              }
  213206             :         }
  213207           0 :    }
  213208             : 
  213209           5 : void SgTypedefSymbol::deleteMemoryPool() {
  213210           9 :   for (auto p: SgTypedefSymbol::pools) {
  213211           4 :     ROSE_FREE(p);
  213212             :   }
  213213           5 :   SgTypedefSymbol::next_node = nullptr;
  213214           5 :   SgTypedefSymbol::pools.clear();
  213215           5 : }
  213216             : 
  213217             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  213218             : //                 reading multiple binary files to for a single AST.
  213219             : /////////// new version ////////////////////////////////
  213220             : //############################################################################
  213221             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  213222             : void
  213223           2 : SgTypedefSymbol::extendMemoryPoolForFileIO( )
  213224             :   {
  213225           2 :     size_t blockIndex = SgTypedefSymbol::pools.size();
  213226           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefSymbol);
  213227             : 
  213228           4 :     while ( (blockIndex * SgTypedefSymbol::pool_size) < newPoolSize)
  213229             :       {
  213230             : #if ROSE_ALLOC_TRACE
  213231             :         if (blockIndex > 0) {
  213232             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefSymbol) = %" PRIuPTR " SgTypedefSymbol::pool_size = %d \n",
  213233             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTypedefSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTypedefSymbol),SgTypedefSymbol::pool_size);
  213234             :         }
  213235             : #endif
  213236             : 
  213237           2 :         SgTypedefSymbol * pointer = (SgTypedefSymbol*) ROSE_MALLOC ( SgTypedefSymbol::pool_size * sizeof(SgTypedefSymbol) );
  213238           2 :         assert( pointer != NULL );
  213239             : #if ROSE_ALLOC_MEMSET == 1
  213240             :         memset(pointer, 0x00, SgTypedefSymbol::pool_size * sizeof(SgTypedefSymbol));
  213241             : #elif ROSE_ALLOC_MEMSET == 2
  213242             :         memset(pointer, 0xCC, SgTypedefSymbol::pool_size * sizeof(SgTypedefSymbol));
  213243             : #endif
  213244           2 :         SgTypedefSymbol::pools.push_back( (unsigned char*)(pointer) );
  213245           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTypedefSymbol::pool_size * sizeof(SgTypedefSymbol), V_SgTypedefSymbol ) );
  213246             : 
  213247           2 :         if ( SgTypedefSymbol::next_node != NULL ) {
  213248           0 :           if ( blockIndex > 0 ) {
  213249           0 :             SgTypedefSymbol * blkptr = (SgTypedefSymbol*)(SgTypedefSymbol::pools[blockIndex-1]);
  213250           0 :             blkptr[ SgTypedefSymbol::pool_size - 1 ].set_freepointer(pointer);
  213251             :           }
  213252             :         } else {
  213253           2 :           SgTypedefSymbol::next_node = pointer;
  213254             :         }
  213255             : 
  213256        4000 :         for (unsigned i = 0; i < SgTypedefSymbol::pool_size-1; ++i)
  213257             :            {
  213258        3998 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  213259             :            }
  213260           2 :         pointer[ SgTypedefSymbol::pool_size -1 ].set_freepointer(NULL);
  213261             : 
  213262           2 :         blockIndex++;
  213263             :       }
  213264           2 :   }
  213265             : 
  213266             : //############################################################################
  213267             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  213268             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  213269             :  * not compressed. However, that stuff is not yet implemented! 
  213270             :  */
  213271             : unsigned long
  213272           0 : SgTypedefSymbol::getNumberOfLastValidPointer()
  213273             :    {
  213274           0 :       SgTypedefSymbol* testPointer = (SgTypedefSymbol*)(SgTypedefSymbol::pools.back());
  213275           0 :       unsigned long localIndex = SgTypedefSymbol::pool_size - 1;
  213276           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  213277             :          {
  213278           0 :            localIndex--;
  213279             :          }
  213280           0 :       return (localIndex + SgTypedefSymbol::pool_size * (SgTypedefSymbol::pools.size()-1));
  213281             :    }
  213282             : 
  213283             : //############################################################################
  213284             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  213285             :  * memory pool and initializes the data member in class SgTypedefSymbolStroageClass
  213286             :  * from its counterpart of SgTypedefSymbol. The return value is just for checking, 
  213287             :  * that the whole StorageClassArray is initialized!
  213288             :  */
  213289             : unsigned long
  213290           2 : SgTypedefSymbol::initializeStorageClassArray( SgTypedefSymbolStorageClass *storageArray )
  213291             :    {
  213292           2 :      unsigned long storageCounter = 0;
  213293           2 :      std::vector < unsigned char* > :: const_iterator block = SgTypedefSymbol::pools.begin();
  213294           2 :      SgTypedefSymbol* pointer = NULL;
  213295           4 :      while ( block != SgTypedefSymbol::pools.end() ) {
  213296           2 :           pointer = (SgTypedefSymbol*) (*block);
  213297        4002 :           for ( unsigned i = 0; i < SgTypedefSymbol::pool_size; ++i ) {
  213298        4000 :                if ( pointer->get_freepointer() != NULL ) {
  213299        1719 :                  storageArray->pickOutIRNodeData (pointer) ;
  213300        1719 :                  storageArray++;
  213301        1719 :                  storageCounter++;
  213302             :                }
  213303        4000 :                pointer++;
  213304             :              }
  213305           2 :            block++;
  213306             :         }
  213307           2 :      return storageCounter;
  213308             :    }
  213309             : 
  213310             : /* #line 213311 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  213311             : 
  213312             : 
  213313             : 
  213314             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  213315             : 
  213316             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  213317             : 
  213318             : //############################################################################
  213319             : /* JH (02/02/2006) Constructor of the IR node SgTemplateTypedefSymbol that takes its 
  213320             :  * corresponding StorageClass as parameter
  213321             :  */
  213322         160 : SgTemplateTypedefSymbol :: SgTemplateTypedefSymbol ( const SgTemplateTypedefSymbolStorageClass& storageSource )   : SgTypedefSymbol (storageSource)
  213323             :    {
  213324             : 
  213325             : 
  213326             : /* #line 213327 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  213327             : 
  213328         160 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  213329             : 
  213330             : 
  213331             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  213332             : 
  213333             : 
  213334         160 :    }
  213335             : 
  213336             : //############################################################################
  213337             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  213338             :  * within the working AST. 
  213339             :  */
  213340         283 : SgTemplateTypedefSymbol * SgTemplateTypedefSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  213341         283 :      SgTemplateTypedefSymbol* returnPointer = NULL;
  213342         283 :      if ( globalIndex != 0 )
  213343             :         {
  213344             : 
  213345             : #if FILE_IO_EXTRA_CHECK
  213346         283 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgTemplateTypedefSymbol ) ) <= globalIndex ) ;
  213347         283 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateTypedefSymbol + 1 ) ) );
  213348             : #endif
  213349         283 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgTemplateTypedefSymbol )  
  213350         283 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgTemplateTypedefSymbol );
  213351         283 :           unsigned long positionInPool = localIndex % SgTemplateTypedefSymbol::pool_size;
  213352         283 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateTypedefSymbol::pool_size;
  213353             : 
  213354             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  213355             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  213356             : 
  213357         283 :           returnPointer = &( ( (SgTemplateTypedefSymbol*)(SgTemplateTypedefSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  213358             : 
  213359         283 :           ROSE_ASSERT( returnPointer != NULL ) ;
  213360             :         }
  213361         283 :      return returnPointer ;
  213362             :    }
  213363             : 
  213364             : //############################################################################
  213365             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  213366             :   for the AST with the index astIndex
  213367             : */
  213368           0 : SgTemplateTypedefSymbol * SgTemplateTypedefSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  213369           0 :      SgTemplateTypedefSymbol* returnPointer = NULL;
  213370           0 :      if ( globalIndex != 0 )
  213371             :         {
  213372             : 
  213373             : #if FILE_IO_EXTRA_CHECK
  213374           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgTemplateTypedefSymbol ) ) <= globalIndex ) ;
  213375           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateTypedefSymbol + 1 ) ) );
  213376             : #endif
  213377           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgTemplateTypedefSymbol )
  213378           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgTemplateTypedefSymbol );
  213379           0 :           unsigned long positionInPool = localIndex % SgTemplateTypedefSymbol::pool_size ;
  213380           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgTemplateTypedefSymbol::pool_size ;
  213381             : 
  213382             : #if FILE_IO_EXTRA_CHECK
  213383             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  213384             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  213385             : #endif
  213386             : 
  213387           0 :           returnPointer = &( ( (SgTemplateTypedefSymbol*)(SgTemplateTypedefSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  213388             : 
  213389             : #if FILE_IO_EXTRA_CHECK
  213390           0 :           assert ( returnPointer != NULL ) ;
  213391             : #endif
  213392             :         }
  213393           0 :      return returnPointer ;
  213394             :    }
  213395             : 
  213396             : //############################################################################
  213397             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  213398             :  * pool size! We set for every valid object in the memory pool the freepointer
  213399             :  * to the global index and increase the global index afterwards. For all the 
  213400             :  * invalid objects (means address ranges within the memory pool that were not
  213401             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  213402             :  * distinguish valid from invalid objects! 
  213403             :  */
  213404             : unsigned long
  213405           5 : SgTemplateTypedefSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  213406             :    {
  213407           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  213408           5 :      SgTemplateTypedefSymbol* pointer = NULL;
  213409           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  213410           5 :      std::vector < unsigned char* > :: const_iterator block;
  213411           6 :      for ( block = SgTemplateTypedefSymbol::pools.begin(); block != SgTemplateTypedefSymbol::pools.end() ; ++block )
  213412             :         {
  213413           1 :           pointer = (SgTemplateTypedefSymbol*)(*block);
  213414        2001 :           for (unsigned i = 0; i < SgTemplateTypedefSymbol::pool_size; ++i )
  213415             :              {
  213416             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  213417             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  213418             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  213419             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  213420             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  213421             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  213422             :             // properly; so this will have to be checked next.
  213423             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  213424             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  213425        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  213426             :                   {
  213427         160 :                     pointer[i].set_freepointer((SgTemplateTypedefSymbol*)(globalIndex));
  213428         160 :                     globalIndex++;
  213429             :                   }
  213430             :                else
  213431             :                   {
  213432        1840 :                     pointer[i].set_freepointer(NULL);
  213433             :                   }
  213434             :               }
  213435             :         }
  213436           5 :      return globalIndex;
  213437             :    }
  213438             : 
  213439             : //############################################################################
  213440             : // JH (01/14/2006)
  213441             : void
  213442           5 : SgTemplateTypedefSymbol::resetValidFreepointers( )
  213443             :    {
  213444           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  213445           5 :      SgTemplateTypedefSymbol* pointer = NULL;
  213446           5 :      std::vector < unsigned char* > :: const_iterator block;
  213447           5 :      SgTemplateTypedefSymbol* pointerOfLinkedList = NULL;
  213448           6 :      for ( block = SgTemplateTypedefSymbol::pools.begin(); block != SgTemplateTypedefSymbol::pools.end() ; ++block )
  213449             :         {
  213450           1 :           pointer = (SgTemplateTypedefSymbol*)(*block);
  213451        2001 :           for (unsigned i = 0; i < SgTemplateTypedefSymbol::pool_size; ++i )
  213452             :              {
  213453             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  213454             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  213455             :             // memory blocks!.
  213456        2000 :                if ( pointer[i].get_freepointer() != NULL )
  213457             :                   {
  213458         160 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  213459             :                   }
  213460             :                else
  213461             :                   {
  213462        1840 :                     if ( pointerOfLinkedList == NULL )
  213463             :                        {
  213464           1 :                          SgTemplateTypedefSymbol::next_node = &(pointer[i]);
  213465             :                        }
  213466             :                     else
  213467             :                        {
  213468             :                       // printf ("In SgTemplateTypedefSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  213469        1839 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  213470             :                        }
  213471             :                     pointerOfLinkedList = &(pointer[i]);
  213472             :                   }
  213473             :               }
  213474             :         }
  213475             : 
  213476           5 :      if ( pointerOfLinkedList != NULL )
  213477             :         {
  213478             :        // printf ("In SgTemplateTypedefSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  213479           1 :           pointerOfLinkedList->set_freepointer(NULL);
  213480             :        // DQ (6/6/2010): Temporary debugging...
  213481             :        //   ROSE_ASSERT(false);
  213482             :         }
  213483             : 
  213484           5 :      return ;
  213485             :    }
  213486             : 
  213487             : //############################################################################
  213488             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  213489             :  * within the memory pool and resets the freepointers, in order to achieve a 
  213490             :  * linked list, that has no jumps and starts at the beginning! This function 
  213491             :  * does not extend the memory pool, since we do not delete any memory blocks,
  213492             :  * but delete the valid objects.  
  213493             :  */
  213494             : void
  213495           0 : SgTemplateTypedefSymbol::clearMemoryPool( )
  213496             :    {
  213497             :   // printf ("Inside of SgTemplateTypedefSymbol::clearMemoryPool() \n");
  213498             : 
  213499           0 :      SgTemplateTypedefSymbol* pointer = NULL, *tempPointer = NULL;
  213500           0 :      std::vector < unsigned char* > :: const_iterator block;
  213501           0 :      if ( SgTemplateTypedefSymbol::pools.empty() == false )
  213502             :         {
  213503           0 :           block = SgTemplateTypedefSymbol::pools.begin() ;
  213504           0 :           SgTemplateTypedefSymbol::next_node = (SgTemplateTypedefSymbol*) (*block);
  213505             : 
  213506           0 :           while ( block != SgTemplateTypedefSymbol::pools.end() )
  213507             :              {
  213508           0 :                pointer = (SgTemplateTypedefSymbol*) (*block);
  213509           0 :                if ( tempPointer != NULL )
  213510             :                   {
  213511           0 :                     tempPointer->set_freepointer(pointer);
  213512             :                   }
  213513           0 :                for (unsigned i = 0; i < SgTemplateTypedefSymbol::pool_size - 1; ++i)
  213514             :                   {
  213515           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  213516             :                   }
  213517           0 :                 pointer[SgTemplateTypedefSymbol::pool_size-1].set_freepointer(NULL);
  213518           0 :                 tempPointer = &(pointer[SgTemplateTypedefSymbol::pool_size-1]);
  213519           0 :                 ++block;
  213520             :              }
  213521             :         }
  213522           0 :    }
  213523             : 
  213524           5 : void SgTemplateTypedefSymbol::deleteMemoryPool() {
  213525           7 :   for (auto p: SgTemplateTypedefSymbol::pools) {
  213526           2 :     ROSE_FREE(p);
  213527             :   }
  213528           5 :   SgTemplateTypedefSymbol::next_node = nullptr;
  213529           5 :   SgTemplateTypedefSymbol::pools.clear();
  213530           5 : }
  213531             : 
  213532             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  213533             : //                 reading multiple binary files to for a single AST.
  213534             : /////////// new version ////////////////////////////////
  213535             : //############################################################################
  213536             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  213537             : void
  213538           2 : SgTemplateTypedefSymbol::extendMemoryPoolForFileIO( )
  213539             :   {
  213540           2 :     size_t blockIndex = SgTemplateTypedefSymbol::pools.size();
  213541           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateTypedefSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateTypedefSymbol);
  213542             : 
  213543           3 :     while ( (blockIndex * SgTemplateTypedefSymbol::pool_size) < newPoolSize)
  213544             :       {
  213545             : #if ROSE_ALLOC_TRACE
  213546             :         if (blockIndex > 0) {
  213547             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateTypedefSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateTypedefSymbol) = %" PRIuPTR " SgTemplateTypedefSymbol::pool_size = %d \n",
  213548             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgTemplateTypedefSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgTemplateTypedefSymbol),SgTemplateTypedefSymbol::pool_size);
  213549             :         }
  213550             : #endif
  213551             : 
  213552           1 :         SgTemplateTypedefSymbol * pointer = (SgTemplateTypedefSymbol*) ROSE_MALLOC ( SgTemplateTypedefSymbol::pool_size * sizeof(SgTemplateTypedefSymbol) );
  213553           1 :         assert( pointer != NULL );
  213554             : #if ROSE_ALLOC_MEMSET == 1
  213555             :         memset(pointer, 0x00, SgTemplateTypedefSymbol::pool_size * sizeof(SgTemplateTypedefSymbol));
  213556             : #elif ROSE_ALLOC_MEMSET == 2
  213557             :         memset(pointer, 0xCC, SgTemplateTypedefSymbol::pool_size * sizeof(SgTemplateTypedefSymbol));
  213558             : #endif
  213559           1 :         SgTemplateTypedefSymbol::pools.push_back( (unsigned char*)(pointer) );
  213560           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgTemplateTypedefSymbol::pool_size * sizeof(SgTemplateTypedefSymbol), V_SgTemplateTypedefSymbol ) );
  213561             : 
  213562           1 :         if ( SgTemplateTypedefSymbol::next_node != NULL ) {
  213563           0 :           if ( blockIndex > 0 ) {
  213564           0 :             SgTemplateTypedefSymbol * blkptr = (SgTemplateTypedefSymbol*)(SgTemplateTypedefSymbol::pools[blockIndex-1]);
  213565           0 :             blkptr[ SgTemplateTypedefSymbol::pool_size - 1 ].set_freepointer(pointer);
  213566             :           }
  213567             :         } else {
  213568           1 :           SgTemplateTypedefSymbol::next_node = pointer;
  213569             :         }
  213570             : 
  213571        2000 :         for (unsigned i = 0; i < SgTemplateTypedefSymbol::pool_size-1; ++i)
  213572             :            {
  213573        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  213574             :            }
  213575           1 :         pointer[ SgTemplateTypedefSymbol::pool_size -1 ].set_freepointer(NULL);
  213576             : 
  213577           1 :         blockIndex++;
  213578             :       }
  213579           2 :   }
  213580             : 
  213581             : //############################################################################
  213582             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  213583             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  213584             :  * not compressed. However, that stuff is not yet implemented! 
  213585             :  */
  213586             : unsigned long
  213587           0 : SgTemplateTypedefSymbol::getNumberOfLastValidPointer()
  213588             :    {
  213589           0 :       SgTemplateTypedefSymbol* testPointer = (SgTemplateTypedefSymbol*)(SgTemplateTypedefSymbol::pools.back());
  213590           0 :       unsigned long localIndex = SgTemplateTypedefSymbol::pool_size - 1;
  213591           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  213592             :          {
  213593           0 :            localIndex--;
  213594             :          }
  213595           0 :       return (localIndex + SgTemplateTypedefSymbol::pool_size * (SgTemplateTypedefSymbol::pools.size()-1));
  213596             :    }
  213597             : 
  213598             : //############################################################################
  213599             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  213600             :  * memory pool and initializes the data member in class SgTemplateTypedefSymbolStroageClass
  213601             :  * from its counterpart of SgTemplateTypedefSymbol. The return value is just for checking, 
  213602             :  * that the whole StorageClassArray is initialized!
  213603             :  */
  213604             : unsigned long
  213605           1 : SgTemplateTypedefSymbol::initializeStorageClassArray( SgTemplateTypedefSymbolStorageClass *storageArray )
  213606             :    {
  213607           1 :      unsigned long storageCounter = 0;
  213608           1 :      std::vector < unsigned char* > :: const_iterator block = SgTemplateTypedefSymbol::pools.begin();
  213609           1 :      SgTemplateTypedefSymbol* pointer = NULL;
  213610           2 :      while ( block != SgTemplateTypedefSymbol::pools.end() ) {
  213611           1 :           pointer = (SgTemplateTypedefSymbol*) (*block);
  213612        2001 :           for ( unsigned i = 0; i < SgTemplateTypedefSymbol::pool_size; ++i ) {
  213613        2000 :                if ( pointer->get_freepointer() != NULL ) {
  213614         160 :                  storageArray->pickOutIRNodeData (pointer) ;
  213615         160 :                  storageArray++;
  213616         160 :                  storageCounter++;
  213617             :                }
  213618        2000 :                pointer++;
  213619             :              }
  213620           1 :            block++;
  213621             :         }
  213622           1 :      return storageCounter;
  213623             :    }
  213624             : 
  213625             : /* #line 213626 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  213626             : 
  213627             : 
  213628             : 
  213629             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  213630             : 
  213631             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  213632             : 
  213633             : //############################################################################
  213634             : /* JH (02/02/2006) Constructor of the IR node SgLabelSymbol that takes its 
  213635             :  * corresponding StorageClass as parameter
  213636             :  */
  213637           0 : SgLabelSymbol :: SgLabelSymbol ( const SgLabelSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  213638             :    {
  213639             : 
  213640             : 
  213641             : /* #line 213642 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  213642             : 
  213643           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  213644           0 :      p_declaration =  (SgLabelStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  213645           0 :      p_fortran_statement =  (SgStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_fortran_statement) );
  213646           0 :      p_fortran_alternate_return_parameter =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_fortran_alternate_return_parameter) );
  213647           0 :      p_numeric_label_value = storageSource.storageOf_numeric_label_value ;
  213648           0 :      p_label_type = storageSource.storageOf_label_type ;
  213649             : 
  213650             : 
  213651             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  213652             : 
  213653             : 
  213654           0 :    }
  213655             : 
  213656             : //############################################################################
  213657             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  213658             :  * within the working AST. 
  213659             :  */
  213660           0 : SgLabelSymbol * SgLabelSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  213661           0 :      SgLabelSymbol* returnPointer = NULL;
  213662           0 :      if ( globalIndex != 0 )
  213663             :         {
  213664             : 
  213665             : #if FILE_IO_EXTRA_CHECK
  213666           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgLabelSymbol ) ) <= globalIndex ) ;
  213667           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLabelSymbol + 1 ) ) );
  213668             : #endif
  213669           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgLabelSymbol )  
  213670           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgLabelSymbol );
  213671           0 :           unsigned long positionInPool = localIndex % SgLabelSymbol::pool_size;
  213672           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLabelSymbol::pool_size;
  213673             : 
  213674             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  213675             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  213676             : 
  213677           0 :           returnPointer = &( ( (SgLabelSymbol*)(SgLabelSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  213678             : 
  213679           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  213680             :         }
  213681           0 :      return returnPointer ;
  213682             :    }
  213683             : 
  213684             : //############################################################################
  213685             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  213686             :   for the AST with the index astIndex
  213687             : */
  213688           0 : SgLabelSymbol * SgLabelSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  213689           0 :      SgLabelSymbol* returnPointer = NULL;
  213690           0 :      if ( globalIndex != 0 )
  213691             :         {
  213692             : 
  213693             : #if FILE_IO_EXTRA_CHECK
  213694           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgLabelSymbol ) ) <= globalIndex ) ;
  213695           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLabelSymbol + 1 ) ) );
  213696             : #endif
  213697           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgLabelSymbol )
  213698           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgLabelSymbol );
  213699           0 :           unsigned long positionInPool = localIndex % SgLabelSymbol::pool_size ;
  213700           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgLabelSymbol::pool_size ;
  213701             : 
  213702             : #if FILE_IO_EXTRA_CHECK
  213703             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  213704             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  213705             : #endif
  213706             : 
  213707           0 :           returnPointer = &( ( (SgLabelSymbol*)(SgLabelSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  213708             : 
  213709             : #if FILE_IO_EXTRA_CHECK
  213710           0 :           assert ( returnPointer != NULL ) ;
  213711             : #endif
  213712             :         }
  213713           0 :      return returnPointer ;
  213714             :    }
  213715             : 
  213716             : //############################################################################
  213717             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  213718             :  * pool size! We set for every valid object in the memory pool the freepointer
  213719             :  * to the global index and increase the global index afterwards. For all the 
  213720             :  * invalid objects (means address ranges within the memory pool that were not
  213721             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  213722             :  * distinguish valid from invalid objects! 
  213723             :  */
  213724             : unsigned long
  213725           5 : SgLabelSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  213726             :    {
  213727           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  213728           5 :      SgLabelSymbol* pointer = NULL;
  213729           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  213730           5 :      std::vector < unsigned char* > :: const_iterator block;
  213731           5 :      for ( block = SgLabelSymbol::pools.begin(); block != SgLabelSymbol::pools.end() ; ++block )
  213732             :         {
  213733           0 :           pointer = (SgLabelSymbol*)(*block);
  213734           0 :           for (unsigned i = 0; i < SgLabelSymbol::pool_size; ++i )
  213735             :              {
  213736             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  213737             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  213738             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  213739             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  213740             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  213741             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  213742             :             // properly; so this will have to be checked next.
  213743             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  213744             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  213745           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  213746             :                   {
  213747           0 :                     pointer[i].set_freepointer((SgLabelSymbol*)(globalIndex));
  213748           0 :                     globalIndex++;
  213749             :                   }
  213750             :                else
  213751             :                   {
  213752           0 :                     pointer[i].set_freepointer(NULL);
  213753             :                   }
  213754             :               }
  213755             :         }
  213756           5 :      return globalIndex;
  213757             :    }
  213758             : 
  213759             : //############################################################################
  213760             : // JH (01/14/2006)
  213761             : void
  213762           5 : SgLabelSymbol::resetValidFreepointers( )
  213763             :    {
  213764           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  213765           5 :      SgLabelSymbol* pointer = NULL;
  213766           5 :      std::vector < unsigned char* > :: const_iterator block;
  213767           5 :      SgLabelSymbol* pointerOfLinkedList = NULL;
  213768           5 :      for ( block = SgLabelSymbol::pools.begin(); block != SgLabelSymbol::pools.end() ; ++block )
  213769             :         {
  213770           0 :           pointer = (SgLabelSymbol*)(*block);
  213771           0 :           for (unsigned i = 0; i < SgLabelSymbol::pool_size; ++i )
  213772             :              {
  213773             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  213774             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  213775             :             // memory blocks!.
  213776           0 :                if ( pointer[i].get_freepointer() != NULL )
  213777             :                   {
  213778           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  213779             :                   }
  213780             :                else
  213781             :                   {
  213782           0 :                     if ( pointerOfLinkedList == NULL )
  213783             :                        {
  213784           0 :                          SgLabelSymbol::next_node = &(pointer[i]);
  213785             :                        }
  213786             :                     else
  213787             :                        {
  213788             :                       // printf ("In SgLabelSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  213789           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  213790             :                        }
  213791             :                     pointerOfLinkedList = &(pointer[i]);
  213792             :                   }
  213793             :               }
  213794             :         }
  213795             : 
  213796           5 :      if ( pointerOfLinkedList != NULL )
  213797             :         {
  213798             :        // printf ("In SgLabelSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  213799           0 :           pointerOfLinkedList->set_freepointer(NULL);
  213800             :        // DQ (6/6/2010): Temporary debugging...
  213801             :        //   ROSE_ASSERT(false);
  213802             :         }
  213803             : 
  213804           5 :      return ;
  213805             :    }
  213806             : 
  213807             : //############################################################################
  213808             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  213809             :  * within the memory pool and resets the freepointers, in order to achieve a 
  213810             :  * linked list, that has no jumps and starts at the beginning! This function 
  213811             :  * does not extend the memory pool, since we do not delete any memory blocks,
  213812             :  * but delete the valid objects.  
  213813             :  */
  213814             : void
  213815           0 : SgLabelSymbol::clearMemoryPool( )
  213816             :    {
  213817             :   // printf ("Inside of SgLabelSymbol::clearMemoryPool() \n");
  213818             : 
  213819           0 :      SgLabelSymbol* pointer = NULL, *tempPointer = NULL;
  213820           0 :      std::vector < unsigned char* > :: const_iterator block;
  213821           0 :      if ( SgLabelSymbol::pools.empty() == false )
  213822             :         {
  213823           0 :           block = SgLabelSymbol::pools.begin() ;
  213824           0 :           SgLabelSymbol::next_node = (SgLabelSymbol*) (*block);
  213825             : 
  213826           0 :           while ( block != SgLabelSymbol::pools.end() )
  213827             :              {
  213828           0 :                pointer = (SgLabelSymbol*) (*block);
  213829           0 :                if ( tempPointer != NULL )
  213830             :                   {
  213831           0 :                     tempPointer->set_freepointer(pointer);
  213832             :                   }
  213833           0 :                for (unsigned i = 0; i < SgLabelSymbol::pool_size - 1; ++i)
  213834             :                   {
  213835           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  213836             :                   }
  213837           0 :                 pointer[SgLabelSymbol::pool_size-1].set_freepointer(NULL);
  213838           0 :                 tempPointer = &(pointer[SgLabelSymbol::pool_size-1]);
  213839           0 :                 ++block;
  213840             :              }
  213841             :         }
  213842           0 :    }
  213843             : 
  213844           5 : void SgLabelSymbol::deleteMemoryPool() {
  213845           5 :   for (auto p: SgLabelSymbol::pools) {
  213846           0 :     ROSE_FREE(p);
  213847             :   }
  213848           5 :   SgLabelSymbol::next_node = nullptr;
  213849           5 :   SgLabelSymbol::pools.clear();
  213850           5 : }
  213851             : 
  213852             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  213853             : //                 reading multiple binary files to for a single AST.
  213854             : /////////// new version ////////////////////////////////
  213855             : //############################################################################
  213856             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  213857             : void
  213858           2 : SgLabelSymbol::extendMemoryPoolForFileIO( )
  213859             :   {
  213860           2 :     size_t blockIndex = SgLabelSymbol::pools.size();
  213861           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelSymbol);
  213862             : 
  213863           2 :     while ( (blockIndex * SgLabelSymbol::pool_size) < newPoolSize)
  213864             :       {
  213865             : #if ROSE_ALLOC_TRACE
  213866             :         if (blockIndex > 0) {
  213867             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelSymbol) = %" PRIuPTR " SgLabelSymbol::pool_size = %d \n",
  213868             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgLabelSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgLabelSymbol),SgLabelSymbol::pool_size);
  213869             :         }
  213870             : #endif
  213871             : 
  213872           0 :         SgLabelSymbol * pointer = (SgLabelSymbol*) ROSE_MALLOC ( SgLabelSymbol::pool_size * sizeof(SgLabelSymbol) );
  213873           0 :         assert( pointer != NULL );
  213874             : #if ROSE_ALLOC_MEMSET == 1
  213875             :         memset(pointer, 0x00, SgLabelSymbol::pool_size * sizeof(SgLabelSymbol));
  213876             : #elif ROSE_ALLOC_MEMSET == 2
  213877             :         memset(pointer, 0xCC, SgLabelSymbol::pool_size * sizeof(SgLabelSymbol));
  213878             : #endif
  213879           0 :         SgLabelSymbol::pools.push_back( (unsigned char*)(pointer) );
  213880           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgLabelSymbol::pool_size * sizeof(SgLabelSymbol), V_SgLabelSymbol ) );
  213881             : 
  213882           0 :         if ( SgLabelSymbol::next_node != NULL ) {
  213883           0 :           if ( blockIndex > 0 ) {
  213884           0 :             SgLabelSymbol * blkptr = (SgLabelSymbol*)(SgLabelSymbol::pools[blockIndex-1]);
  213885           0 :             blkptr[ SgLabelSymbol::pool_size - 1 ].set_freepointer(pointer);
  213886             :           }
  213887             :         } else {
  213888           0 :           SgLabelSymbol::next_node = pointer;
  213889             :         }
  213890             : 
  213891           0 :         for (unsigned i = 0; i < SgLabelSymbol::pool_size-1; ++i)
  213892             :            {
  213893           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  213894             :            }
  213895           0 :         pointer[ SgLabelSymbol::pool_size -1 ].set_freepointer(NULL);
  213896             : 
  213897           0 :         blockIndex++;
  213898             :       }
  213899           2 :   }
  213900             : 
  213901             : //############################################################################
  213902             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  213903             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  213904             :  * not compressed. However, that stuff is not yet implemented! 
  213905             :  */
  213906             : unsigned long
  213907           0 : SgLabelSymbol::getNumberOfLastValidPointer()
  213908             :    {
  213909           0 :       SgLabelSymbol* testPointer = (SgLabelSymbol*)(SgLabelSymbol::pools.back());
  213910           0 :       unsigned long localIndex = SgLabelSymbol::pool_size - 1;
  213911           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  213912             :          {
  213913           0 :            localIndex--;
  213914             :          }
  213915           0 :       return (localIndex + SgLabelSymbol::pool_size * (SgLabelSymbol::pools.size()-1));
  213916             :    }
  213917             : 
  213918             : //############################################################################
  213919             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  213920             :  * memory pool and initializes the data member in class SgLabelSymbolStroageClass
  213921             :  * from its counterpart of SgLabelSymbol. The return value is just for checking, 
  213922             :  * that the whole StorageClassArray is initialized!
  213923             :  */
  213924             : unsigned long
  213925           0 : SgLabelSymbol::initializeStorageClassArray( SgLabelSymbolStorageClass *storageArray )
  213926             :    {
  213927           0 :      unsigned long storageCounter = 0;
  213928           0 :      std::vector < unsigned char* > :: const_iterator block = SgLabelSymbol::pools.begin();
  213929           0 :      SgLabelSymbol* pointer = NULL;
  213930           0 :      while ( block != SgLabelSymbol::pools.end() ) {
  213931           0 :           pointer = (SgLabelSymbol*) (*block);
  213932           0 :           for ( unsigned i = 0; i < SgLabelSymbol::pool_size; ++i ) {
  213933           0 :                if ( pointer->get_freepointer() != NULL ) {
  213934           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  213935           0 :                  storageArray++;
  213936           0 :                  storageCounter++;
  213937             :                }
  213938           0 :                pointer++;
  213939             :              }
  213940           0 :            block++;
  213941             :         }
  213942           0 :      return storageCounter;
  213943             :    }
  213944             : 
  213945             : /* #line 213946 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  213946             : 
  213947             : 
  213948             : 
  213949             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  213950             : 
  213951             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  213952             : 
  213953             : //############################################################################
  213954             : /* JH (02/02/2006) Constructor of the IR node SgDefaultSymbol that takes its 
  213955             :  * corresponding StorageClass as parameter
  213956             :  */
  213957           0 : SgDefaultSymbol :: SgDefaultSymbol ( const SgDefaultSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  213958             :    {
  213959             : 
  213960             : 
  213961             : /* #line 213962 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  213962             : 
  213963           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  213964           0 :      p_type =  (SgType*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_type) );
  213965             : 
  213966             : 
  213967             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  213968             : 
  213969             : 
  213970           0 :    }
  213971             : 
  213972             : //############################################################################
  213973             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  213974             :  * within the working AST. 
  213975             :  */
  213976           0 : SgDefaultSymbol * SgDefaultSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  213977           0 :      SgDefaultSymbol* returnPointer = NULL;
  213978           0 :      if ( globalIndex != 0 )
  213979             :         {
  213980             : 
  213981             : #if FILE_IO_EXTRA_CHECK
  213982           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgDefaultSymbol ) ) <= globalIndex ) ;
  213983           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDefaultSymbol + 1 ) ) );
  213984             : #endif
  213985           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgDefaultSymbol )  
  213986           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgDefaultSymbol );
  213987           0 :           unsigned long positionInPool = localIndex % SgDefaultSymbol::pool_size;
  213988           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDefaultSymbol::pool_size;
  213989             : 
  213990             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  213991             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  213992             : 
  213993           0 :           returnPointer = &( ( (SgDefaultSymbol*)(SgDefaultSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  213994             : 
  213995           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  213996             :         }
  213997           0 :      return returnPointer ;
  213998             :    }
  213999             : 
  214000             : //############################################################################
  214001             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  214002             :   for the AST with the index astIndex
  214003             : */
  214004           0 : SgDefaultSymbol * SgDefaultSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  214005           0 :      SgDefaultSymbol* returnPointer = NULL;
  214006           0 :      if ( globalIndex != 0 )
  214007             :         {
  214008             : 
  214009             : #if FILE_IO_EXTRA_CHECK
  214010           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgDefaultSymbol ) ) <= globalIndex ) ;
  214011           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDefaultSymbol + 1 ) ) );
  214012             : #endif
  214013           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgDefaultSymbol )
  214014           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgDefaultSymbol );
  214015           0 :           unsigned long positionInPool = localIndex % SgDefaultSymbol::pool_size ;
  214016           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgDefaultSymbol::pool_size ;
  214017             : 
  214018             : #if FILE_IO_EXTRA_CHECK
  214019             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  214020             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  214021             : #endif
  214022             : 
  214023           0 :           returnPointer = &( ( (SgDefaultSymbol*)(SgDefaultSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  214024             : 
  214025             : #if FILE_IO_EXTRA_CHECK
  214026           0 :           assert ( returnPointer != NULL ) ;
  214027             : #endif
  214028             :         }
  214029           0 :      return returnPointer ;
  214030             :    }
  214031             : 
  214032             : //############################################################################
  214033             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  214034             :  * pool size! We set for every valid object in the memory pool the freepointer
  214035             :  * to the global index and increase the global index afterwards. For all the 
  214036             :  * invalid objects (means address ranges within the memory pool that were not
  214037             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  214038             :  * distinguish valid from invalid objects! 
  214039             :  */
  214040             : unsigned long
  214041           5 : SgDefaultSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  214042             :    {
  214043           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  214044           5 :      SgDefaultSymbol* pointer = NULL;
  214045           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  214046           5 :      std::vector < unsigned char* > :: const_iterator block;
  214047           5 :      for ( block = SgDefaultSymbol::pools.begin(); block != SgDefaultSymbol::pools.end() ; ++block )
  214048             :         {
  214049           0 :           pointer = (SgDefaultSymbol*)(*block);
  214050           0 :           for (unsigned i = 0; i < SgDefaultSymbol::pool_size; ++i )
  214051             :              {
  214052             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  214053             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  214054             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  214055             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  214056             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  214057             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  214058             :             // properly; so this will have to be checked next.
  214059             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  214060             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  214061           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  214062             :                   {
  214063           0 :                     pointer[i].set_freepointer((SgDefaultSymbol*)(globalIndex));
  214064           0 :                     globalIndex++;
  214065             :                   }
  214066             :                else
  214067             :                   {
  214068           0 :                     pointer[i].set_freepointer(NULL);
  214069             :                   }
  214070             :               }
  214071             :         }
  214072           5 :      return globalIndex;
  214073             :    }
  214074             : 
  214075             : //############################################################################
  214076             : // JH (01/14/2006)
  214077             : void
  214078           5 : SgDefaultSymbol::resetValidFreepointers( )
  214079             :    {
  214080           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  214081           5 :      SgDefaultSymbol* pointer = NULL;
  214082           5 :      std::vector < unsigned char* > :: const_iterator block;
  214083           5 :      SgDefaultSymbol* pointerOfLinkedList = NULL;
  214084           5 :      for ( block = SgDefaultSymbol::pools.begin(); block != SgDefaultSymbol::pools.end() ; ++block )
  214085             :         {
  214086           0 :           pointer = (SgDefaultSymbol*)(*block);
  214087           0 :           for (unsigned i = 0; i < SgDefaultSymbol::pool_size; ++i )
  214088             :              {
  214089             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  214090             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  214091             :             // memory blocks!.
  214092           0 :                if ( pointer[i].get_freepointer() != NULL )
  214093             :                   {
  214094           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  214095             :                   }
  214096             :                else
  214097             :                   {
  214098           0 :                     if ( pointerOfLinkedList == NULL )
  214099             :                        {
  214100           0 :                          SgDefaultSymbol::next_node = &(pointer[i]);
  214101             :                        }
  214102             :                     else
  214103             :                        {
  214104             :                       // printf ("In SgDefaultSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  214105           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  214106             :                        }
  214107             :                     pointerOfLinkedList = &(pointer[i]);
  214108             :                   }
  214109             :               }
  214110             :         }
  214111             : 
  214112           5 :      if ( pointerOfLinkedList != NULL )
  214113             :         {
  214114             :        // printf ("In SgDefaultSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  214115           0 :           pointerOfLinkedList->set_freepointer(NULL);
  214116             :        // DQ (6/6/2010): Temporary debugging...
  214117             :        //   ROSE_ASSERT(false);
  214118             :         }
  214119             : 
  214120           5 :      return ;
  214121             :    }
  214122             : 
  214123             : //############################################################################
  214124             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  214125             :  * within the memory pool and resets the freepointers, in order to achieve a 
  214126             :  * linked list, that has no jumps and starts at the beginning! This function 
  214127             :  * does not extend the memory pool, since we do not delete any memory blocks,
  214128             :  * but delete the valid objects.  
  214129             :  */
  214130             : void
  214131           0 : SgDefaultSymbol::clearMemoryPool( )
  214132             :    {
  214133             :   // printf ("Inside of SgDefaultSymbol::clearMemoryPool() \n");
  214134             : 
  214135           0 :      SgDefaultSymbol* pointer = NULL, *tempPointer = NULL;
  214136           0 :      std::vector < unsigned char* > :: const_iterator block;
  214137           0 :      if ( SgDefaultSymbol::pools.empty() == false )
  214138             :         {
  214139           0 :           block = SgDefaultSymbol::pools.begin() ;
  214140           0 :           SgDefaultSymbol::next_node = (SgDefaultSymbol*) (*block);
  214141             : 
  214142           0 :           while ( block != SgDefaultSymbol::pools.end() )
  214143             :              {
  214144           0 :                pointer = (SgDefaultSymbol*) (*block);
  214145           0 :                if ( tempPointer != NULL )
  214146             :                   {
  214147           0 :                     tempPointer->set_freepointer(pointer);
  214148             :                   }
  214149           0 :                for (unsigned i = 0; i < SgDefaultSymbol::pool_size - 1; ++i)
  214150             :                   {
  214151           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  214152             :                   }
  214153           0 :                 pointer[SgDefaultSymbol::pool_size-1].set_freepointer(NULL);
  214154           0 :                 tempPointer = &(pointer[SgDefaultSymbol::pool_size-1]);
  214155           0 :                 ++block;
  214156             :              }
  214157             :         }
  214158           0 :    }
  214159             : 
  214160           5 : void SgDefaultSymbol::deleteMemoryPool() {
  214161           5 :   for (auto p: SgDefaultSymbol::pools) {
  214162           0 :     ROSE_FREE(p);
  214163             :   }
  214164           5 :   SgDefaultSymbol::next_node = nullptr;
  214165           5 :   SgDefaultSymbol::pools.clear();
  214166           5 : }
  214167             : 
  214168             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  214169             : //                 reading multiple binary files to for a single AST.
  214170             : /////////// new version ////////////////////////////////
  214171             : //############################################################################
  214172             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  214173             : void
  214174           2 : SgDefaultSymbol::extendMemoryPoolForFileIO( )
  214175             :   {
  214176           2 :     size_t blockIndex = SgDefaultSymbol::pools.size();
  214177           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgDefaultSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefaultSymbol);
  214178             : 
  214179           2 :     while ( (blockIndex * SgDefaultSymbol::pool_size) < newPoolSize)
  214180             :       {
  214181             : #if ROSE_ALLOC_TRACE
  214182             :         if (blockIndex > 0) {
  214183             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgDefaultSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefaultSymbol) = %" PRIuPTR " SgDefaultSymbol::pool_size = %d \n",
  214184             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgDefaultSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgDefaultSymbol),SgDefaultSymbol::pool_size);
  214185             :         }
  214186             : #endif
  214187             : 
  214188           0 :         SgDefaultSymbol * pointer = (SgDefaultSymbol*) ROSE_MALLOC ( SgDefaultSymbol::pool_size * sizeof(SgDefaultSymbol) );
  214189           0 :         assert( pointer != NULL );
  214190             : #if ROSE_ALLOC_MEMSET == 1
  214191             :         memset(pointer, 0x00, SgDefaultSymbol::pool_size * sizeof(SgDefaultSymbol));
  214192             : #elif ROSE_ALLOC_MEMSET == 2
  214193             :         memset(pointer, 0xCC, SgDefaultSymbol::pool_size * sizeof(SgDefaultSymbol));
  214194             : #endif
  214195           0 :         SgDefaultSymbol::pools.push_back( (unsigned char*)(pointer) );
  214196           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgDefaultSymbol::pool_size * sizeof(SgDefaultSymbol), V_SgDefaultSymbol ) );
  214197             : 
  214198           0 :         if ( SgDefaultSymbol::next_node != NULL ) {
  214199           0 :           if ( blockIndex > 0 ) {
  214200           0 :             SgDefaultSymbol * blkptr = (SgDefaultSymbol*)(SgDefaultSymbol::pools[blockIndex-1]);
  214201           0 :             blkptr[ SgDefaultSymbol::pool_size - 1 ].set_freepointer(pointer);
  214202             :           }
  214203             :         } else {
  214204           0 :           SgDefaultSymbol::next_node = pointer;
  214205             :         }
  214206             : 
  214207           0 :         for (unsigned i = 0; i < SgDefaultSymbol::pool_size-1; ++i)
  214208             :            {
  214209           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  214210             :            }
  214211           0 :         pointer[ SgDefaultSymbol::pool_size -1 ].set_freepointer(NULL);
  214212             : 
  214213           0 :         blockIndex++;
  214214             :       }
  214215           2 :   }
  214216             : 
  214217             : //############################################################################
  214218             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  214219             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  214220             :  * not compressed. However, that stuff is not yet implemented! 
  214221             :  */
  214222             : unsigned long
  214223           0 : SgDefaultSymbol::getNumberOfLastValidPointer()
  214224             :    {
  214225           0 :       SgDefaultSymbol* testPointer = (SgDefaultSymbol*)(SgDefaultSymbol::pools.back());
  214226           0 :       unsigned long localIndex = SgDefaultSymbol::pool_size - 1;
  214227           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  214228             :          {
  214229           0 :            localIndex--;
  214230             :          }
  214231           0 :       return (localIndex + SgDefaultSymbol::pool_size * (SgDefaultSymbol::pools.size()-1));
  214232             :    }
  214233             : 
  214234             : //############################################################################
  214235             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  214236             :  * memory pool and initializes the data member in class SgDefaultSymbolStroageClass
  214237             :  * from its counterpart of SgDefaultSymbol. The return value is just for checking, 
  214238             :  * that the whole StorageClassArray is initialized!
  214239             :  */
  214240             : unsigned long
  214241           0 : SgDefaultSymbol::initializeStorageClassArray( SgDefaultSymbolStorageClass *storageArray )
  214242             :    {
  214243           0 :      unsigned long storageCounter = 0;
  214244           0 :      std::vector < unsigned char* > :: const_iterator block = SgDefaultSymbol::pools.begin();
  214245           0 :      SgDefaultSymbol* pointer = NULL;
  214246           0 :      while ( block != SgDefaultSymbol::pools.end() ) {
  214247           0 :           pointer = (SgDefaultSymbol*) (*block);
  214248           0 :           for ( unsigned i = 0; i < SgDefaultSymbol::pool_size; ++i ) {
  214249           0 :                if ( pointer->get_freepointer() != NULL ) {
  214250           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  214251           0 :                  storageArray++;
  214252           0 :                  storageCounter++;
  214253             :                }
  214254           0 :                pointer++;
  214255             :              }
  214256           0 :            block++;
  214257             :         }
  214258           0 :      return storageCounter;
  214259             :    }
  214260             : 
  214261             : /* #line 214262 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  214262             : 
  214263             : 
  214264             : 
  214265             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  214266             : 
  214267             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  214268             : 
  214269             : //############################################################################
  214270             : /* JH (02/02/2006) Constructor of the IR node SgNamespaceSymbol that takes its 
  214271             :  * corresponding StorageClass as parameter
  214272             :  */
  214273          14 : SgNamespaceSymbol :: SgNamespaceSymbol ( const SgNamespaceSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  214274             :    {
  214275             : 
  214276             : 
  214277             : /* #line 214278 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  214278             : 
  214279          14 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  214280          14 :      p_name = SgName ( storageSource.storageOf_name ) ;
  214281          14 :      p_declaration =  (SgNamespaceDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  214282          14 :      p_aliasDeclaration =  (SgNamespaceAliasDeclarationStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_aliasDeclaration) );
  214283          14 :      p_isAlias = storageSource.storageOf_isAlias ;
  214284             : 
  214285             : 
  214286             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  214287             : 
  214288             : 
  214289          14 :    }
  214290             : 
  214291             : //############################################################################
  214292             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  214293             :  * within the working AST. 
  214294             :  */
  214295         326 : SgNamespaceSymbol * SgNamespaceSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  214296         326 :      SgNamespaceSymbol* returnPointer = NULL;
  214297         326 :      if ( globalIndex != 0 )
  214298             :         {
  214299             : 
  214300             : #if FILE_IO_EXTRA_CHECK
  214301         326 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgNamespaceSymbol ) ) <= globalIndex ) ;
  214302         326 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamespaceSymbol + 1 ) ) );
  214303             : #endif
  214304         326 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgNamespaceSymbol )  
  214305         326 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgNamespaceSymbol );
  214306         326 :           unsigned long positionInPool = localIndex % SgNamespaceSymbol::pool_size;
  214307         326 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamespaceSymbol::pool_size;
  214308             : 
  214309             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  214310             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  214311             : 
  214312         326 :           returnPointer = &( ( (SgNamespaceSymbol*)(SgNamespaceSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  214313             : 
  214314         326 :           ROSE_ASSERT( returnPointer != NULL ) ;
  214315             :         }
  214316         326 :      return returnPointer ;
  214317             :    }
  214318             : 
  214319             : //############################################################################
  214320             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  214321             :   for the AST with the index astIndex
  214322             : */
  214323           0 : SgNamespaceSymbol * SgNamespaceSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  214324           0 :      SgNamespaceSymbol* returnPointer = NULL;
  214325           0 :      if ( globalIndex != 0 )
  214326             :         {
  214327             : 
  214328             : #if FILE_IO_EXTRA_CHECK
  214329           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgNamespaceSymbol ) ) <= globalIndex ) ;
  214330           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamespaceSymbol + 1 ) ) );
  214331             : #endif
  214332           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgNamespaceSymbol )
  214333           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgNamespaceSymbol );
  214334           0 :           unsigned long positionInPool = localIndex % SgNamespaceSymbol::pool_size ;
  214335           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgNamespaceSymbol::pool_size ;
  214336             : 
  214337             : #if FILE_IO_EXTRA_CHECK
  214338             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  214339             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  214340             : #endif
  214341             : 
  214342           0 :           returnPointer = &( ( (SgNamespaceSymbol*)(SgNamespaceSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  214343             : 
  214344             : #if FILE_IO_EXTRA_CHECK
  214345           0 :           assert ( returnPointer != NULL ) ;
  214346             : #endif
  214347             :         }
  214348           0 :      return returnPointer ;
  214349             :    }
  214350             : 
  214351             : //############################################################################
  214352             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  214353             :  * pool size! We set for every valid object in the memory pool the freepointer
  214354             :  * to the global index and increase the global index afterwards. For all the 
  214355             :  * invalid objects (means address ranges within the memory pool that were not
  214356             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  214357             :  * distinguish valid from invalid objects! 
  214358             :  */
  214359             : unsigned long
  214360           5 : SgNamespaceSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  214361             :    {
  214362           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  214363           5 :      SgNamespaceSymbol* pointer = NULL;
  214364           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  214365           5 :      std::vector < unsigned char* > :: const_iterator block;
  214366           6 :      for ( block = SgNamespaceSymbol::pools.begin(); block != SgNamespaceSymbol::pools.end() ; ++block )
  214367             :         {
  214368           1 :           pointer = (SgNamespaceSymbol*)(*block);
  214369        2001 :           for (unsigned i = 0; i < SgNamespaceSymbol::pool_size; ++i )
  214370             :              {
  214371             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  214372             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  214373             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  214374             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  214375             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  214376             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  214377             :             // properly; so this will have to be checked next.
  214378             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  214379             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  214380        2000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  214381             :                   {
  214382          14 :                     pointer[i].set_freepointer((SgNamespaceSymbol*)(globalIndex));
  214383          14 :                     globalIndex++;
  214384             :                   }
  214385             :                else
  214386             :                   {
  214387        1986 :                     pointer[i].set_freepointer(NULL);
  214388             :                   }
  214389             :               }
  214390             :         }
  214391           5 :      return globalIndex;
  214392             :    }
  214393             : 
  214394             : //############################################################################
  214395             : // JH (01/14/2006)
  214396             : void
  214397           5 : SgNamespaceSymbol::resetValidFreepointers( )
  214398             :    {
  214399           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  214400           5 :      SgNamespaceSymbol* pointer = NULL;
  214401           5 :      std::vector < unsigned char* > :: const_iterator block;
  214402           5 :      SgNamespaceSymbol* pointerOfLinkedList = NULL;
  214403           6 :      for ( block = SgNamespaceSymbol::pools.begin(); block != SgNamespaceSymbol::pools.end() ; ++block )
  214404             :         {
  214405           1 :           pointer = (SgNamespaceSymbol*)(*block);
  214406        2001 :           for (unsigned i = 0; i < SgNamespaceSymbol::pool_size; ++i )
  214407             :              {
  214408             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  214409             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  214410             :             // memory blocks!.
  214411        2000 :                if ( pointer[i].get_freepointer() != NULL )
  214412             :                   {
  214413          14 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  214414             :                   }
  214415             :                else
  214416             :                   {
  214417        1986 :                     if ( pointerOfLinkedList == NULL )
  214418             :                        {
  214419           1 :                          SgNamespaceSymbol::next_node = &(pointer[i]);
  214420             :                        }
  214421             :                     else
  214422             :                        {
  214423             :                       // printf ("In SgNamespaceSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  214424        1985 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  214425             :                        }
  214426             :                     pointerOfLinkedList = &(pointer[i]);
  214427             :                   }
  214428             :               }
  214429             :         }
  214430             : 
  214431           5 :      if ( pointerOfLinkedList != NULL )
  214432             :         {
  214433             :        // printf ("In SgNamespaceSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  214434           1 :           pointerOfLinkedList->set_freepointer(NULL);
  214435             :        // DQ (6/6/2010): Temporary debugging...
  214436             :        //   ROSE_ASSERT(false);
  214437             :         }
  214438             : 
  214439           5 :      return ;
  214440             :    }
  214441             : 
  214442             : //############################################################################
  214443             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  214444             :  * within the memory pool and resets the freepointers, in order to achieve a 
  214445             :  * linked list, that has no jumps and starts at the beginning! This function 
  214446             :  * does not extend the memory pool, since we do not delete any memory blocks,
  214447             :  * but delete the valid objects.  
  214448             :  */
  214449             : void
  214450           0 : SgNamespaceSymbol::clearMemoryPool( )
  214451             :    {
  214452             :   // printf ("Inside of SgNamespaceSymbol::clearMemoryPool() \n");
  214453             : 
  214454           0 :      SgNamespaceSymbol* pointer = NULL, *tempPointer = NULL;
  214455           0 :      std::vector < unsigned char* > :: const_iterator block;
  214456           0 :      if ( SgNamespaceSymbol::pools.empty() == false )
  214457             :         {
  214458           0 :           block = SgNamespaceSymbol::pools.begin() ;
  214459           0 :           SgNamespaceSymbol::next_node = (SgNamespaceSymbol*) (*block);
  214460             : 
  214461           0 :           while ( block != SgNamespaceSymbol::pools.end() )
  214462             :              {
  214463           0 :                pointer = (SgNamespaceSymbol*) (*block);
  214464           0 :                if ( tempPointer != NULL )
  214465             :                   {
  214466           0 :                     tempPointer->set_freepointer(pointer);
  214467             :                   }
  214468           0 :                for (unsigned i = 0; i < SgNamespaceSymbol::pool_size - 1; ++i)
  214469             :                   {
  214470           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  214471             :                   }
  214472           0 :                 pointer[SgNamespaceSymbol::pool_size-1].set_freepointer(NULL);
  214473           0 :                 tempPointer = &(pointer[SgNamespaceSymbol::pool_size-1]);
  214474           0 :                 ++block;
  214475             :              }
  214476             :         }
  214477           0 :    }
  214478             : 
  214479           5 : void SgNamespaceSymbol::deleteMemoryPool() {
  214480           7 :   for (auto p: SgNamespaceSymbol::pools) {
  214481           2 :     ROSE_FREE(p);
  214482             :   }
  214483           5 :   SgNamespaceSymbol::next_node = nullptr;
  214484           5 :   SgNamespaceSymbol::pools.clear();
  214485           5 : }
  214486             : 
  214487             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  214488             : //                 reading multiple binary files to for a single AST.
  214489             : /////////// new version ////////////////////////////////
  214490             : //############################################################################
  214491             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  214492             : void
  214493           2 : SgNamespaceSymbol::extendMemoryPoolForFileIO( )
  214494             :   {
  214495           2 :     size_t blockIndex = SgNamespaceSymbol::pools.size();
  214496           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceSymbol);
  214497             : 
  214498           3 :     while ( (blockIndex * SgNamespaceSymbol::pool_size) < newPoolSize)
  214499             :       {
  214500             : #if ROSE_ALLOC_TRACE
  214501             :         if (blockIndex > 0) {
  214502             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceSymbol) = %" PRIuPTR " SgNamespaceSymbol::pool_size = %d \n",
  214503             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgNamespaceSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgNamespaceSymbol),SgNamespaceSymbol::pool_size);
  214504             :         }
  214505             : #endif
  214506             : 
  214507           1 :         SgNamespaceSymbol * pointer = (SgNamespaceSymbol*) ROSE_MALLOC ( SgNamespaceSymbol::pool_size * sizeof(SgNamespaceSymbol) );
  214508           1 :         assert( pointer != NULL );
  214509             : #if ROSE_ALLOC_MEMSET == 1
  214510             :         memset(pointer, 0x00, SgNamespaceSymbol::pool_size * sizeof(SgNamespaceSymbol));
  214511             : #elif ROSE_ALLOC_MEMSET == 2
  214512             :         memset(pointer, 0xCC, SgNamespaceSymbol::pool_size * sizeof(SgNamespaceSymbol));
  214513             : #endif
  214514           1 :         SgNamespaceSymbol::pools.push_back( (unsigned char*)(pointer) );
  214515           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgNamespaceSymbol::pool_size * sizeof(SgNamespaceSymbol), V_SgNamespaceSymbol ) );
  214516             : 
  214517           1 :         if ( SgNamespaceSymbol::next_node != NULL ) {
  214518           0 :           if ( blockIndex > 0 ) {
  214519           0 :             SgNamespaceSymbol * blkptr = (SgNamespaceSymbol*)(SgNamespaceSymbol::pools[blockIndex-1]);
  214520           0 :             blkptr[ SgNamespaceSymbol::pool_size - 1 ].set_freepointer(pointer);
  214521             :           }
  214522             :         } else {
  214523           1 :           SgNamespaceSymbol::next_node = pointer;
  214524             :         }
  214525             : 
  214526        2000 :         for (unsigned i = 0; i < SgNamespaceSymbol::pool_size-1; ++i)
  214527             :            {
  214528        1999 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  214529             :            }
  214530           1 :         pointer[ SgNamespaceSymbol::pool_size -1 ].set_freepointer(NULL);
  214531             : 
  214532           1 :         blockIndex++;
  214533             :       }
  214534           2 :   }
  214535             : 
  214536             : //############################################################################
  214537             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  214538             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  214539             :  * not compressed. However, that stuff is not yet implemented! 
  214540             :  */
  214541             : unsigned long
  214542           0 : SgNamespaceSymbol::getNumberOfLastValidPointer()
  214543             :    {
  214544           0 :       SgNamespaceSymbol* testPointer = (SgNamespaceSymbol*)(SgNamespaceSymbol::pools.back());
  214545           0 :       unsigned long localIndex = SgNamespaceSymbol::pool_size - 1;
  214546           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  214547             :          {
  214548           0 :            localIndex--;
  214549             :          }
  214550           0 :       return (localIndex + SgNamespaceSymbol::pool_size * (SgNamespaceSymbol::pools.size()-1));
  214551             :    }
  214552             : 
  214553             : //############################################################################
  214554             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  214555             :  * memory pool and initializes the data member in class SgNamespaceSymbolStroageClass
  214556             :  * from its counterpart of SgNamespaceSymbol. The return value is just for checking, 
  214557             :  * that the whole StorageClassArray is initialized!
  214558             :  */
  214559             : unsigned long
  214560           1 : SgNamespaceSymbol::initializeStorageClassArray( SgNamespaceSymbolStorageClass *storageArray )
  214561             :    {
  214562           1 :      unsigned long storageCounter = 0;
  214563           1 :      std::vector < unsigned char* > :: const_iterator block = SgNamespaceSymbol::pools.begin();
  214564           1 :      SgNamespaceSymbol* pointer = NULL;
  214565           2 :      while ( block != SgNamespaceSymbol::pools.end() ) {
  214566           1 :           pointer = (SgNamespaceSymbol*) (*block);
  214567        2001 :           for ( unsigned i = 0; i < SgNamespaceSymbol::pool_size; ++i ) {
  214568        2000 :                if ( pointer->get_freepointer() != NULL ) {
  214569          14 :                  storageArray->pickOutIRNodeData (pointer) ;
  214570          14 :                  storageArray++;
  214571          14 :                  storageCounter++;
  214572             :                }
  214573        2000 :                pointer++;
  214574             :              }
  214575           1 :            block++;
  214576             :         }
  214577           1 :      return storageCounter;
  214578             :    }
  214579             : 
  214580             : /* #line 214581 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  214581             : 
  214582             : 
  214583             : 
  214584             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  214585             : 
  214586             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  214587             : 
  214588             : //############################################################################
  214589             : /* JH (02/02/2006) Constructor of the IR node SgIntrinsicSymbol that takes its 
  214590             :  * corresponding StorageClass as parameter
  214591             :  */
  214592           0 : SgIntrinsicSymbol :: SgIntrinsicSymbol ( const SgIntrinsicSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  214593             :    {
  214594             : 
  214595             : 
  214596             : /* #line 214597 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  214597             : 
  214598           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  214599           0 :      p_declaration =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  214600             : 
  214601             : 
  214602             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  214603             : 
  214604             : 
  214605           0 :    }
  214606             : 
  214607             : //############################################################################
  214608             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  214609             :  * within the working AST. 
  214610             :  */
  214611           0 : SgIntrinsicSymbol * SgIntrinsicSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  214612           0 :      SgIntrinsicSymbol* returnPointer = NULL;
  214613           0 :      if ( globalIndex != 0 )
  214614             :         {
  214615             : 
  214616             : #if FILE_IO_EXTRA_CHECK
  214617           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgIntrinsicSymbol ) ) <= globalIndex ) ;
  214618           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntrinsicSymbol + 1 ) ) );
  214619             : #endif
  214620           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgIntrinsicSymbol )  
  214621           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgIntrinsicSymbol );
  214622           0 :           unsigned long positionInPool = localIndex % SgIntrinsicSymbol::pool_size;
  214623           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntrinsicSymbol::pool_size;
  214624             : 
  214625             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  214626             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  214627             : 
  214628           0 :           returnPointer = &( ( (SgIntrinsicSymbol*)(SgIntrinsicSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  214629             : 
  214630           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  214631             :         }
  214632           0 :      return returnPointer ;
  214633             :    }
  214634             : 
  214635             : //############################################################################
  214636             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  214637             :   for the AST with the index astIndex
  214638             : */
  214639           0 : SgIntrinsicSymbol * SgIntrinsicSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  214640           0 :      SgIntrinsicSymbol* returnPointer = NULL;
  214641           0 :      if ( globalIndex != 0 )
  214642             :         {
  214643             : 
  214644             : #if FILE_IO_EXTRA_CHECK
  214645           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgIntrinsicSymbol ) ) <= globalIndex ) ;
  214646           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntrinsicSymbol + 1 ) ) );
  214647             : #endif
  214648           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgIntrinsicSymbol )
  214649           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgIntrinsicSymbol );
  214650           0 :           unsigned long positionInPool = localIndex % SgIntrinsicSymbol::pool_size ;
  214651           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgIntrinsicSymbol::pool_size ;
  214652             : 
  214653             : #if FILE_IO_EXTRA_CHECK
  214654             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  214655             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  214656             : #endif
  214657             : 
  214658           0 :           returnPointer = &( ( (SgIntrinsicSymbol*)(SgIntrinsicSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  214659             : 
  214660             : #if FILE_IO_EXTRA_CHECK
  214661           0 :           assert ( returnPointer != NULL ) ;
  214662             : #endif
  214663             :         }
  214664           0 :      return returnPointer ;
  214665             :    }
  214666             : 
  214667             : //############################################################################
  214668             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  214669             :  * pool size! We set for every valid object in the memory pool the freepointer
  214670             :  * to the global index and increase the global index afterwards. For all the 
  214671             :  * invalid objects (means address ranges within the memory pool that were not
  214672             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  214673             :  * distinguish valid from invalid objects! 
  214674             :  */
  214675             : unsigned long
  214676           5 : SgIntrinsicSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  214677             :    {
  214678           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  214679           5 :      SgIntrinsicSymbol* pointer = NULL;
  214680           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  214681           5 :      std::vector < unsigned char* > :: const_iterator block;
  214682           5 :      for ( block = SgIntrinsicSymbol::pools.begin(); block != SgIntrinsicSymbol::pools.end() ; ++block )
  214683             :         {
  214684           0 :           pointer = (SgIntrinsicSymbol*)(*block);
  214685           0 :           for (unsigned i = 0; i < SgIntrinsicSymbol::pool_size; ++i )
  214686             :              {
  214687             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  214688             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  214689             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  214690             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  214691             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  214692             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  214693             :             // properly; so this will have to be checked next.
  214694             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  214695             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  214696           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  214697             :                   {
  214698           0 :                     pointer[i].set_freepointer((SgIntrinsicSymbol*)(globalIndex));
  214699           0 :                     globalIndex++;
  214700             :                   }
  214701             :                else
  214702             :                   {
  214703           0 :                     pointer[i].set_freepointer(NULL);
  214704             :                   }
  214705             :               }
  214706             :         }
  214707           5 :      return globalIndex;
  214708             :    }
  214709             : 
  214710             : //############################################################################
  214711             : // JH (01/14/2006)
  214712             : void
  214713           5 : SgIntrinsicSymbol::resetValidFreepointers( )
  214714             :    {
  214715           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  214716           5 :      SgIntrinsicSymbol* pointer = NULL;
  214717           5 :      std::vector < unsigned char* > :: const_iterator block;
  214718           5 :      SgIntrinsicSymbol* pointerOfLinkedList = NULL;
  214719           5 :      for ( block = SgIntrinsicSymbol::pools.begin(); block != SgIntrinsicSymbol::pools.end() ; ++block )
  214720             :         {
  214721           0 :           pointer = (SgIntrinsicSymbol*)(*block);
  214722           0 :           for (unsigned i = 0; i < SgIntrinsicSymbol::pool_size; ++i )
  214723             :              {
  214724             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  214725             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  214726             :             // memory blocks!.
  214727           0 :                if ( pointer[i].get_freepointer() != NULL )
  214728             :                   {
  214729           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  214730             :                   }
  214731             :                else
  214732             :                   {
  214733           0 :                     if ( pointerOfLinkedList == NULL )
  214734             :                        {
  214735           0 :                          SgIntrinsicSymbol::next_node = &(pointer[i]);
  214736             :                        }
  214737             :                     else
  214738             :                        {
  214739             :                       // printf ("In SgIntrinsicSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  214740           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  214741             :                        }
  214742             :                     pointerOfLinkedList = &(pointer[i]);
  214743             :                   }
  214744             :               }
  214745             :         }
  214746             : 
  214747           5 :      if ( pointerOfLinkedList != NULL )
  214748             :         {
  214749             :        // printf ("In SgIntrinsicSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  214750           0 :           pointerOfLinkedList->set_freepointer(NULL);
  214751             :        // DQ (6/6/2010): Temporary debugging...
  214752             :        //   ROSE_ASSERT(false);
  214753             :         }
  214754             : 
  214755           5 :      return ;
  214756             :    }
  214757             : 
  214758             : //############################################################################
  214759             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  214760             :  * within the memory pool and resets the freepointers, in order to achieve a 
  214761             :  * linked list, that has no jumps and starts at the beginning! This function 
  214762             :  * does not extend the memory pool, since we do not delete any memory blocks,
  214763             :  * but delete the valid objects.  
  214764             :  */
  214765             : void
  214766           0 : SgIntrinsicSymbol::clearMemoryPool( )
  214767             :    {
  214768             :   // printf ("Inside of SgIntrinsicSymbol::clearMemoryPool() \n");
  214769             : 
  214770           0 :      SgIntrinsicSymbol* pointer = NULL, *tempPointer = NULL;
  214771           0 :      std::vector < unsigned char* > :: const_iterator block;
  214772           0 :      if ( SgIntrinsicSymbol::pools.empty() == false )
  214773             :         {
  214774           0 :           block = SgIntrinsicSymbol::pools.begin() ;
  214775           0 :           SgIntrinsicSymbol::next_node = (SgIntrinsicSymbol*) (*block);
  214776             : 
  214777           0 :           while ( block != SgIntrinsicSymbol::pools.end() )
  214778             :              {
  214779           0 :                pointer = (SgIntrinsicSymbol*) (*block);
  214780           0 :                if ( tempPointer != NULL )
  214781             :                   {
  214782           0 :                     tempPointer->set_freepointer(pointer);
  214783             :                   }
  214784           0 :                for (unsigned i = 0; i < SgIntrinsicSymbol::pool_size - 1; ++i)
  214785             :                   {
  214786           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  214787             :                   }
  214788           0 :                 pointer[SgIntrinsicSymbol::pool_size-1].set_freepointer(NULL);
  214789           0 :                 tempPointer = &(pointer[SgIntrinsicSymbol::pool_size-1]);
  214790           0 :                 ++block;
  214791             :              }
  214792             :         }
  214793           0 :    }
  214794             : 
  214795           5 : void SgIntrinsicSymbol::deleteMemoryPool() {
  214796           5 :   for (auto p: SgIntrinsicSymbol::pools) {
  214797           0 :     ROSE_FREE(p);
  214798             :   }
  214799           5 :   SgIntrinsicSymbol::next_node = nullptr;
  214800           5 :   SgIntrinsicSymbol::pools.clear();
  214801           5 : }
  214802             : 
  214803             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  214804             : //                 reading multiple binary files to for a single AST.
  214805             : /////////// new version ////////////////////////////////
  214806             : //############################################################################
  214807             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  214808             : void
  214809           2 : SgIntrinsicSymbol::extendMemoryPoolForFileIO( )
  214810             :   {
  214811           2 :     size_t blockIndex = SgIntrinsicSymbol::pools.size();
  214812           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgIntrinsicSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntrinsicSymbol);
  214813             : 
  214814           2 :     while ( (blockIndex * SgIntrinsicSymbol::pool_size) < newPoolSize)
  214815             :       {
  214816             : #if ROSE_ALLOC_TRACE
  214817             :         if (blockIndex > 0) {
  214818             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgIntrinsicSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntrinsicSymbol) = %" PRIuPTR " SgIntrinsicSymbol::pool_size = %d \n",
  214819             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgIntrinsicSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgIntrinsicSymbol),SgIntrinsicSymbol::pool_size);
  214820             :         }
  214821             : #endif
  214822             : 
  214823           0 :         SgIntrinsicSymbol * pointer = (SgIntrinsicSymbol*) ROSE_MALLOC ( SgIntrinsicSymbol::pool_size * sizeof(SgIntrinsicSymbol) );
  214824           0 :         assert( pointer != NULL );
  214825             : #if ROSE_ALLOC_MEMSET == 1
  214826             :         memset(pointer, 0x00, SgIntrinsicSymbol::pool_size * sizeof(SgIntrinsicSymbol));
  214827             : #elif ROSE_ALLOC_MEMSET == 2
  214828             :         memset(pointer, 0xCC, SgIntrinsicSymbol::pool_size * sizeof(SgIntrinsicSymbol));
  214829             : #endif
  214830           0 :         SgIntrinsicSymbol::pools.push_back( (unsigned char*)(pointer) );
  214831           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgIntrinsicSymbol::pool_size * sizeof(SgIntrinsicSymbol), V_SgIntrinsicSymbol ) );
  214832             : 
  214833           0 :         if ( SgIntrinsicSymbol::next_node != NULL ) {
  214834           0 :           if ( blockIndex > 0 ) {
  214835           0 :             SgIntrinsicSymbol * blkptr = (SgIntrinsicSymbol*)(SgIntrinsicSymbol::pools[blockIndex-1]);
  214836           0 :             blkptr[ SgIntrinsicSymbol::pool_size - 1 ].set_freepointer(pointer);
  214837             :           }
  214838             :         } else {
  214839           0 :           SgIntrinsicSymbol::next_node = pointer;
  214840             :         }
  214841             : 
  214842           0 :         for (unsigned i = 0; i < SgIntrinsicSymbol::pool_size-1; ++i)
  214843             :            {
  214844           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  214845             :            }
  214846           0 :         pointer[ SgIntrinsicSymbol::pool_size -1 ].set_freepointer(NULL);
  214847             : 
  214848           0 :         blockIndex++;
  214849             :       }
  214850           2 :   }
  214851             : 
  214852             : //############################################################################
  214853             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  214854             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  214855             :  * not compressed. However, that stuff is not yet implemented! 
  214856             :  */
  214857             : unsigned long
  214858           0 : SgIntrinsicSymbol::getNumberOfLastValidPointer()
  214859             :    {
  214860           0 :       SgIntrinsicSymbol* testPointer = (SgIntrinsicSymbol*)(SgIntrinsicSymbol::pools.back());
  214861           0 :       unsigned long localIndex = SgIntrinsicSymbol::pool_size - 1;
  214862           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  214863             :          {
  214864           0 :            localIndex--;
  214865             :          }
  214866           0 :       return (localIndex + SgIntrinsicSymbol::pool_size * (SgIntrinsicSymbol::pools.size()-1));
  214867             :    }
  214868             : 
  214869             : //############################################################################
  214870             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  214871             :  * memory pool and initializes the data member in class SgIntrinsicSymbolStroageClass
  214872             :  * from its counterpart of SgIntrinsicSymbol. The return value is just for checking, 
  214873             :  * that the whole StorageClassArray is initialized!
  214874             :  */
  214875             : unsigned long
  214876           0 : SgIntrinsicSymbol::initializeStorageClassArray( SgIntrinsicSymbolStorageClass *storageArray )
  214877             :    {
  214878           0 :      unsigned long storageCounter = 0;
  214879           0 :      std::vector < unsigned char* > :: const_iterator block = SgIntrinsicSymbol::pools.begin();
  214880           0 :      SgIntrinsicSymbol* pointer = NULL;
  214881           0 :      while ( block != SgIntrinsicSymbol::pools.end() ) {
  214882           0 :           pointer = (SgIntrinsicSymbol*) (*block);
  214883           0 :           for ( unsigned i = 0; i < SgIntrinsicSymbol::pool_size; ++i ) {
  214884           0 :                if ( pointer->get_freepointer() != NULL ) {
  214885           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  214886           0 :                  storageArray++;
  214887           0 :                  storageCounter++;
  214888             :                }
  214889           0 :                pointer++;
  214890             :              }
  214891           0 :            block++;
  214892             :         }
  214893           0 :      return storageCounter;
  214894             :    }
  214895             : 
  214896             : /* #line 214897 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  214897             : 
  214898             : 
  214899             : 
  214900             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  214901             : 
  214902             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  214903             : 
  214904             : //############################################################################
  214905             : /* JH (02/02/2006) Constructor of the IR node SgModuleSymbol that takes its 
  214906             :  * corresponding StorageClass as parameter
  214907             :  */
  214908           0 : SgModuleSymbol :: SgModuleSymbol ( const SgModuleSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  214909             :    {
  214910             : 
  214911             : 
  214912             : /* #line 214913 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  214913             : 
  214914           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  214915           0 :      p_declaration =  (SgModuleStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  214916             : 
  214917             : 
  214918             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  214919             : 
  214920             : 
  214921           0 :    }
  214922             : 
  214923             : //############################################################################
  214924             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  214925             :  * within the working AST. 
  214926             :  */
  214927           0 : SgModuleSymbol * SgModuleSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  214928           0 :      SgModuleSymbol* returnPointer = NULL;
  214929           0 :      if ( globalIndex != 0 )
  214930             :         {
  214931             : 
  214932             : #if FILE_IO_EXTRA_CHECK
  214933           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgModuleSymbol ) ) <= globalIndex ) ;
  214934           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModuleSymbol + 1 ) ) );
  214935             : #endif
  214936           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgModuleSymbol )  
  214937           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgModuleSymbol );
  214938           0 :           unsigned long positionInPool = localIndex % SgModuleSymbol::pool_size;
  214939           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModuleSymbol::pool_size;
  214940             : 
  214941             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  214942             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  214943             : 
  214944           0 :           returnPointer = &( ( (SgModuleSymbol*)(SgModuleSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  214945             : 
  214946           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  214947             :         }
  214948           0 :      return returnPointer ;
  214949             :    }
  214950             : 
  214951             : //############################################################################
  214952             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  214953             :   for the AST with the index astIndex
  214954             : */
  214955           0 : SgModuleSymbol * SgModuleSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  214956           0 :      SgModuleSymbol* returnPointer = NULL;
  214957           0 :      if ( globalIndex != 0 )
  214958             :         {
  214959             : 
  214960             : #if FILE_IO_EXTRA_CHECK
  214961           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgModuleSymbol ) ) <= globalIndex ) ;
  214962           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModuleSymbol + 1 ) ) );
  214963             : #endif
  214964           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgModuleSymbol )
  214965           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgModuleSymbol );
  214966           0 :           unsigned long positionInPool = localIndex % SgModuleSymbol::pool_size ;
  214967           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgModuleSymbol::pool_size ;
  214968             : 
  214969             : #if FILE_IO_EXTRA_CHECK
  214970             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  214971             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  214972             : #endif
  214973             : 
  214974           0 :           returnPointer = &( ( (SgModuleSymbol*)(SgModuleSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  214975             : 
  214976             : #if FILE_IO_EXTRA_CHECK
  214977           0 :           assert ( returnPointer != NULL ) ;
  214978             : #endif
  214979             :         }
  214980           0 :      return returnPointer ;
  214981             :    }
  214982             : 
  214983             : //############################################################################
  214984             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  214985             :  * pool size! We set for every valid object in the memory pool the freepointer
  214986             :  * to the global index and increase the global index afterwards. For all the 
  214987             :  * invalid objects (means address ranges within the memory pool that were not
  214988             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  214989             :  * distinguish valid from invalid objects! 
  214990             :  */
  214991             : unsigned long
  214992           5 : SgModuleSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  214993             :    {
  214994           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  214995           5 :      SgModuleSymbol* pointer = NULL;
  214996           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  214997           5 :      std::vector < unsigned char* > :: const_iterator block;
  214998           5 :      for ( block = SgModuleSymbol::pools.begin(); block != SgModuleSymbol::pools.end() ; ++block )
  214999             :         {
  215000           0 :           pointer = (SgModuleSymbol*)(*block);
  215001           0 :           for (unsigned i = 0; i < SgModuleSymbol::pool_size; ++i )
  215002             :              {
  215003             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  215004             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  215005             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  215006             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  215007             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  215008             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  215009             :             // properly; so this will have to be checked next.
  215010             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  215011             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  215012           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  215013             :                   {
  215014           0 :                     pointer[i].set_freepointer((SgModuleSymbol*)(globalIndex));
  215015           0 :                     globalIndex++;
  215016             :                   }
  215017             :                else
  215018             :                   {
  215019           0 :                     pointer[i].set_freepointer(NULL);
  215020             :                   }
  215021             :               }
  215022             :         }
  215023           5 :      return globalIndex;
  215024             :    }
  215025             : 
  215026             : //############################################################################
  215027             : // JH (01/14/2006)
  215028             : void
  215029           5 : SgModuleSymbol::resetValidFreepointers( )
  215030             :    {
  215031           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  215032           5 :      SgModuleSymbol* pointer = NULL;
  215033           5 :      std::vector < unsigned char* > :: const_iterator block;
  215034           5 :      SgModuleSymbol* pointerOfLinkedList = NULL;
  215035           5 :      for ( block = SgModuleSymbol::pools.begin(); block != SgModuleSymbol::pools.end() ; ++block )
  215036             :         {
  215037           0 :           pointer = (SgModuleSymbol*)(*block);
  215038           0 :           for (unsigned i = 0; i < SgModuleSymbol::pool_size; ++i )
  215039             :              {
  215040             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  215041             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  215042             :             // memory blocks!.
  215043           0 :                if ( pointer[i].get_freepointer() != NULL )
  215044             :                   {
  215045           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  215046             :                   }
  215047             :                else
  215048             :                   {
  215049           0 :                     if ( pointerOfLinkedList == NULL )
  215050             :                        {
  215051           0 :                          SgModuleSymbol::next_node = &(pointer[i]);
  215052             :                        }
  215053             :                     else
  215054             :                        {
  215055             :                       // printf ("In SgModuleSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  215056           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  215057             :                        }
  215058             :                     pointerOfLinkedList = &(pointer[i]);
  215059             :                   }
  215060             :               }
  215061             :         }
  215062             : 
  215063           5 :      if ( pointerOfLinkedList != NULL )
  215064             :         {
  215065             :        // printf ("In SgModuleSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  215066           0 :           pointerOfLinkedList->set_freepointer(NULL);
  215067             :        // DQ (6/6/2010): Temporary debugging...
  215068             :        //   ROSE_ASSERT(false);
  215069             :         }
  215070             : 
  215071           5 :      return ;
  215072             :    }
  215073             : 
  215074             : //############################################################################
  215075             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  215076             :  * within the memory pool and resets the freepointers, in order to achieve a 
  215077             :  * linked list, that has no jumps and starts at the beginning! This function 
  215078             :  * does not extend the memory pool, since we do not delete any memory blocks,
  215079             :  * but delete the valid objects.  
  215080             :  */
  215081             : void
  215082           0 : SgModuleSymbol::clearMemoryPool( )
  215083             :    {
  215084             :   // printf ("Inside of SgModuleSymbol::clearMemoryPool() \n");
  215085             : 
  215086           0 :      SgModuleSymbol* pointer = NULL, *tempPointer = NULL;
  215087           0 :      std::vector < unsigned char* > :: const_iterator block;
  215088           0 :      if ( SgModuleSymbol::pools.empty() == false )
  215089             :         {
  215090           0 :           block = SgModuleSymbol::pools.begin() ;
  215091           0 :           SgModuleSymbol::next_node = (SgModuleSymbol*) (*block);
  215092             : 
  215093           0 :           while ( block != SgModuleSymbol::pools.end() )
  215094             :              {
  215095           0 :                pointer = (SgModuleSymbol*) (*block);
  215096           0 :                if ( tempPointer != NULL )
  215097             :                   {
  215098           0 :                     tempPointer->set_freepointer(pointer);
  215099             :                   }
  215100           0 :                for (unsigned i = 0; i < SgModuleSymbol::pool_size - 1; ++i)
  215101             :                   {
  215102           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  215103             :                   }
  215104           0 :                 pointer[SgModuleSymbol::pool_size-1].set_freepointer(NULL);
  215105           0 :                 tempPointer = &(pointer[SgModuleSymbol::pool_size-1]);
  215106           0 :                 ++block;
  215107             :              }
  215108             :         }
  215109           0 :    }
  215110             : 
  215111           5 : void SgModuleSymbol::deleteMemoryPool() {
  215112           5 :   for (auto p: SgModuleSymbol::pools) {
  215113           0 :     ROSE_FREE(p);
  215114             :   }
  215115           5 :   SgModuleSymbol::next_node = nullptr;
  215116           5 :   SgModuleSymbol::pools.clear();
  215117           5 : }
  215118             : 
  215119             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  215120             : //                 reading multiple binary files to for a single AST.
  215121             : /////////// new version ////////////////////////////////
  215122             : //############################################################################
  215123             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  215124             : void
  215125           2 : SgModuleSymbol::extendMemoryPoolForFileIO( )
  215126             :   {
  215127           2 :     size_t blockIndex = SgModuleSymbol::pools.size();
  215128           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgModuleSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgModuleSymbol);
  215129             : 
  215130           2 :     while ( (blockIndex * SgModuleSymbol::pool_size) < newPoolSize)
  215131             :       {
  215132             : #if ROSE_ALLOC_TRACE
  215133             :         if (blockIndex > 0) {
  215134             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgModuleSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgModuleSymbol) = %" PRIuPTR " SgModuleSymbol::pool_size = %d \n",
  215135             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgModuleSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgModuleSymbol),SgModuleSymbol::pool_size);
  215136             :         }
  215137             : #endif
  215138             : 
  215139           0 :         SgModuleSymbol * pointer = (SgModuleSymbol*) ROSE_MALLOC ( SgModuleSymbol::pool_size * sizeof(SgModuleSymbol) );
  215140           0 :         assert( pointer != NULL );
  215141             : #if ROSE_ALLOC_MEMSET == 1
  215142             :         memset(pointer, 0x00, SgModuleSymbol::pool_size * sizeof(SgModuleSymbol));
  215143             : #elif ROSE_ALLOC_MEMSET == 2
  215144             :         memset(pointer, 0xCC, SgModuleSymbol::pool_size * sizeof(SgModuleSymbol));
  215145             : #endif
  215146           0 :         SgModuleSymbol::pools.push_back( (unsigned char*)(pointer) );
  215147           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgModuleSymbol::pool_size * sizeof(SgModuleSymbol), V_SgModuleSymbol ) );
  215148             : 
  215149           0 :         if ( SgModuleSymbol::next_node != NULL ) {
  215150           0 :           if ( blockIndex > 0 ) {
  215151           0 :             SgModuleSymbol * blkptr = (SgModuleSymbol*)(SgModuleSymbol::pools[blockIndex-1]);
  215152           0 :             blkptr[ SgModuleSymbol::pool_size - 1 ].set_freepointer(pointer);
  215153             :           }
  215154             :         } else {
  215155           0 :           SgModuleSymbol::next_node = pointer;
  215156             :         }
  215157             : 
  215158           0 :         for (unsigned i = 0; i < SgModuleSymbol::pool_size-1; ++i)
  215159             :            {
  215160           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  215161             :            }
  215162           0 :         pointer[ SgModuleSymbol::pool_size -1 ].set_freepointer(NULL);
  215163             : 
  215164           0 :         blockIndex++;
  215165             :       }
  215166           2 :   }
  215167             : 
  215168             : //############################################################################
  215169             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  215170             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  215171             :  * not compressed. However, that stuff is not yet implemented! 
  215172             :  */
  215173             : unsigned long
  215174           0 : SgModuleSymbol::getNumberOfLastValidPointer()
  215175             :    {
  215176           0 :       SgModuleSymbol* testPointer = (SgModuleSymbol*)(SgModuleSymbol::pools.back());
  215177           0 :       unsigned long localIndex = SgModuleSymbol::pool_size - 1;
  215178           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  215179             :          {
  215180           0 :            localIndex--;
  215181             :          }
  215182           0 :       return (localIndex + SgModuleSymbol::pool_size * (SgModuleSymbol::pools.size()-1));
  215183             :    }
  215184             : 
  215185             : //############################################################################
  215186             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  215187             :  * memory pool and initializes the data member in class SgModuleSymbolStroageClass
  215188             :  * from its counterpart of SgModuleSymbol. The return value is just for checking, 
  215189             :  * that the whole StorageClassArray is initialized!
  215190             :  */
  215191             : unsigned long
  215192           0 : SgModuleSymbol::initializeStorageClassArray( SgModuleSymbolStorageClass *storageArray )
  215193             :    {
  215194           0 :      unsigned long storageCounter = 0;
  215195           0 :      std::vector < unsigned char* > :: const_iterator block = SgModuleSymbol::pools.begin();
  215196           0 :      SgModuleSymbol* pointer = NULL;
  215197           0 :      while ( block != SgModuleSymbol::pools.end() ) {
  215198           0 :           pointer = (SgModuleSymbol*) (*block);
  215199           0 :           for ( unsigned i = 0; i < SgModuleSymbol::pool_size; ++i ) {
  215200           0 :                if ( pointer->get_freepointer() != NULL ) {
  215201           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  215202           0 :                  storageArray++;
  215203           0 :                  storageCounter++;
  215204             :                }
  215205           0 :                pointer++;
  215206             :              }
  215207           0 :            block++;
  215208             :         }
  215209           0 :      return storageCounter;
  215210             :    }
  215211             : 
  215212             : /* #line 215213 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  215213             : 
  215214             : 
  215215             : 
  215216             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  215217             : 
  215218             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  215219             : 
  215220             : //############################################################################
  215221             : /* JH (02/02/2006) Constructor of the IR node SgInterfaceSymbol that takes its 
  215222             :  * corresponding StorageClass as parameter
  215223             :  */
  215224           0 : SgInterfaceSymbol :: SgInterfaceSymbol ( const SgInterfaceSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  215225             :    {
  215226             : 
  215227             : 
  215228             : /* #line 215229 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  215229             : 
  215230           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  215231           0 :      p_declaration =  (SgInterfaceStatement*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  215232             : 
  215233             : 
  215234             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  215235             : 
  215236             : 
  215237           0 :    }
  215238             : 
  215239             : //############################################################################
  215240             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  215241             :  * within the working AST. 
  215242             :  */
  215243           0 : SgInterfaceSymbol * SgInterfaceSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  215244           0 :      SgInterfaceSymbol* returnPointer = NULL;
  215245           0 :      if ( globalIndex != 0 )
  215246             :         {
  215247             : 
  215248             : #if FILE_IO_EXTRA_CHECK
  215249           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgInterfaceSymbol ) ) <= globalIndex ) ;
  215250           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInterfaceSymbol + 1 ) ) );
  215251             : #endif
  215252           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgInterfaceSymbol )  
  215253           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgInterfaceSymbol );
  215254           0 :           unsigned long positionInPool = localIndex % SgInterfaceSymbol::pool_size;
  215255           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInterfaceSymbol::pool_size;
  215256             : 
  215257             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  215258             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  215259             : 
  215260           0 :           returnPointer = &( ( (SgInterfaceSymbol*)(SgInterfaceSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  215261             : 
  215262           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  215263             :         }
  215264           0 :      return returnPointer ;
  215265             :    }
  215266             : 
  215267             : //############################################################################
  215268             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  215269             :   for the AST with the index astIndex
  215270             : */
  215271           0 : SgInterfaceSymbol * SgInterfaceSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  215272           0 :      SgInterfaceSymbol* returnPointer = NULL;
  215273           0 :      if ( globalIndex != 0 )
  215274             :         {
  215275             : 
  215276             : #if FILE_IO_EXTRA_CHECK
  215277           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgInterfaceSymbol ) ) <= globalIndex ) ;
  215278           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInterfaceSymbol + 1 ) ) );
  215279             : #endif
  215280           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgInterfaceSymbol )
  215281           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgInterfaceSymbol );
  215282           0 :           unsigned long positionInPool = localIndex % SgInterfaceSymbol::pool_size ;
  215283           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgInterfaceSymbol::pool_size ;
  215284             : 
  215285             : #if FILE_IO_EXTRA_CHECK
  215286             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  215287             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  215288             : #endif
  215289             : 
  215290           0 :           returnPointer = &( ( (SgInterfaceSymbol*)(SgInterfaceSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  215291             : 
  215292             : #if FILE_IO_EXTRA_CHECK
  215293           0 :           assert ( returnPointer != NULL ) ;
  215294             : #endif
  215295             :         }
  215296           0 :      return returnPointer ;
  215297             :    }
  215298             : 
  215299             : //############################################################################
  215300             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  215301             :  * pool size! We set for every valid object in the memory pool the freepointer
  215302             :  * to the global index and increase the global index afterwards. For all the 
  215303             :  * invalid objects (means address ranges within the memory pool that were not
  215304             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  215305             :  * distinguish valid from invalid objects! 
  215306             :  */
  215307             : unsigned long
  215308           5 : SgInterfaceSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  215309             :    {
  215310           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  215311           5 :      SgInterfaceSymbol* pointer = NULL;
  215312           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  215313           5 :      std::vector < unsigned char* > :: const_iterator block;
  215314           5 :      for ( block = SgInterfaceSymbol::pools.begin(); block != SgInterfaceSymbol::pools.end() ; ++block )
  215315             :         {
  215316           0 :           pointer = (SgInterfaceSymbol*)(*block);
  215317           0 :           for (unsigned i = 0; i < SgInterfaceSymbol::pool_size; ++i )
  215318             :              {
  215319             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  215320             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  215321             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  215322             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  215323             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  215324             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  215325             :             // properly; so this will have to be checked next.
  215326             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  215327             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  215328           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  215329             :                   {
  215330           0 :                     pointer[i].set_freepointer((SgInterfaceSymbol*)(globalIndex));
  215331           0 :                     globalIndex++;
  215332             :                   }
  215333             :                else
  215334             :                   {
  215335           0 :                     pointer[i].set_freepointer(NULL);
  215336             :                   }
  215337             :               }
  215338             :         }
  215339           5 :      return globalIndex;
  215340             :    }
  215341             : 
  215342             : //############################################################################
  215343             : // JH (01/14/2006)
  215344             : void
  215345           5 : SgInterfaceSymbol::resetValidFreepointers( )
  215346             :    {
  215347           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  215348           5 :      SgInterfaceSymbol* pointer = NULL;
  215349           5 :      std::vector < unsigned char* > :: const_iterator block;
  215350           5 :      SgInterfaceSymbol* pointerOfLinkedList = NULL;
  215351           5 :      for ( block = SgInterfaceSymbol::pools.begin(); block != SgInterfaceSymbol::pools.end() ; ++block )
  215352             :         {
  215353           0 :           pointer = (SgInterfaceSymbol*)(*block);
  215354           0 :           for (unsigned i = 0; i < SgInterfaceSymbol::pool_size; ++i )
  215355             :              {
  215356             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  215357             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  215358             :             // memory blocks!.
  215359           0 :                if ( pointer[i].get_freepointer() != NULL )
  215360             :                   {
  215361           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  215362             :                   }
  215363             :                else
  215364             :                   {
  215365           0 :                     if ( pointerOfLinkedList == NULL )
  215366             :                        {
  215367           0 :                          SgInterfaceSymbol::next_node = &(pointer[i]);
  215368             :                        }
  215369             :                     else
  215370             :                        {
  215371             :                       // printf ("In SgInterfaceSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  215372           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  215373             :                        }
  215374             :                     pointerOfLinkedList = &(pointer[i]);
  215375             :                   }
  215376             :               }
  215377             :         }
  215378             : 
  215379           5 :      if ( pointerOfLinkedList != NULL )
  215380             :         {
  215381             :        // printf ("In SgInterfaceSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  215382           0 :           pointerOfLinkedList->set_freepointer(NULL);
  215383             :        // DQ (6/6/2010): Temporary debugging...
  215384             :        //   ROSE_ASSERT(false);
  215385             :         }
  215386             : 
  215387           5 :      return ;
  215388             :    }
  215389             : 
  215390             : //############################################################################
  215391             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  215392             :  * within the memory pool and resets the freepointers, in order to achieve a 
  215393             :  * linked list, that has no jumps and starts at the beginning! This function 
  215394             :  * does not extend the memory pool, since we do not delete any memory blocks,
  215395             :  * but delete the valid objects.  
  215396             :  */
  215397             : void
  215398           0 : SgInterfaceSymbol::clearMemoryPool( )
  215399             :    {
  215400             :   // printf ("Inside of SgInterfaceSymbol::clearMemoryPool() \n");
  215401             : 
  215402           0 :      SgInterfaceSymbol* pointer = NULL, *tempPointer = NULL;
  215403           0 :      std::vector < unsigned char* > :: const_iterator block;
  215404           0 :      if ( SgInterfaceSymbol::pools.empty() == false )
  215405             :         {
  215406           0 :           block = SgInterfaceSymbol::pools.begin() ;
  215407           0 :           SgInterfaceSymbol::next_node = (SgInterfaceSymbol*) (*block);
  215408             : 
  215409           0 :           while ( block != SgInterfaceSymbol::pools.end() )
  215410             :              {
  215411           0 :                pointer = (SgInterfaceSymbol*) (*block);
  215412           0 :                if ( tempPointer != NULL )
  215413             :                   {
  215414           0 :                     tempPointer->set_freepointer(pointer);
  215415             :                   }
  215416           0 :                for (unsigned i = 0; i < SgInterfaceSymbol::pool_size - 1; ++i)
  215417             :                   {
  215418           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  215419             :                   }
  215420           0 :                 pointer[SgInterfaceSymbol::pool_size-1].set_freepointer(NULL);
  215421           0 :                 tempPointer = &(pointer[SgInterfaceSymbol::pool_size-1]);
  215422           0 :                 ++block;
  215423             :              }
  215424             :         }
  215425           0 :    }
  215426             : 
  215427           5 : void SgInterfaceSymbol::deleteMemoryPool() {
  215428           5 :   for (auto p: SgInterfaceSymbol::pools) {
  215429           0 :     ROSE_FREE(p);
  215430             :   }
  215431           5 :   SgInterfaceSymbol::next_node = nullptr;
  215432           5 :   SgInterfaceSymbol::pools.clear();
  215433           5 : }
  215434             : 
  215435             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  215436             : //                 reading multiple binary files to for a single AST.
  215437             : /////////// new version ////////////////////////////////
  215438             : //############################################################################
  215439             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  215440             : void
  215441           2 : SgInterfaceSymbol::extendMemoryPoolForFileIO( )
  215442             :   {
  215443           2 :     size_t blockIndex = SgInterfaceSymbol::pools.size();
  215444           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceSymbol);
  215445             : 
  215446           2 :     while ( (blockIndex * SgInterfaceSymbol::pool_size) < newPoolSize)
  215447             :       {
  215448             : #if ROSE_ALLOC_TRACE
  215449             :         if (blockIndex > 0) {
  215450             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceSymbol) = %" PRIuPTR " SgInterfaceSymbol::pool_size = %d \n",
  215451             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgInterfaceSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgInterfaceSymbol),SgInterfaceSymbol::pool_size);
  215452             :         }
  215453             : #endif
  215454             : 
  215455           0 :         SgInterfaceSymbol * pointer = (SgInterfaceSymbol*) ROSE_MALLOC ( SgInterfaceSymbol::pool_size * sizeof(SgInterfaceSymbol) );
  215456           0 :         assert( pointer != NULL );
  215457             : #if ROSE_ALLOC_MEMSET == 1
  215458             :         memset(pointer, 0x00, SgInterfaceSymbol::pool_size * sizeof(SgInterfaceSymbol));
  215459             : #elif ROSE_ALLOC_MEMSET == 2
  215460             :         memset(pointer, 0xCC, SgInterfaceSymbol::pool_size * sizeof(SgInterfaceSymbol));
  215461             : #endif
  215462           0 :         SgInterfaceSymbol::pools.push_back( (unsigned char*)(pointer) );
  215463           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgInterfaceSymbol::pool_size * sizeof(SgInterfaceSymbol), V_SgInterfaceSymbol ) );
  215464             : 
  215465           0 :         if ( SgInterfaceSymbol::next_node != NULL ) {
  215466           0 :           if ( blockIndex > 0 ) {
  215467           0 :             SgInterfaceSymbol * blkptr = (SgInterfaceSymbol*)(SgInterfaceSymbol::pools[blockIndex-1]);
  215468           0 :             blkptr[ SgInterfaceSymbol::pool_size - 1 ].set_freepointer(pointer);
  215469             :           }
  215470             :         } else {
  215471           0 :           SgInterfaceSymbol::next_node = pointer;
  215472             :         }
  215473             : 
  215474           0 :         for (unsigned i = 0; i < SgInterfaceSymbol::pool_size-1; ++i)
  215475             :            {
  215476           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  215477             :            }
  215478           0 :         pointer[ SgInterfaceSymbol::pool_size -1 ].set_freepointer(NULL);
  215479             : 
  215480           0 :         blockIndex++;
  215481             :       }
  215482           2 :   }
  215483             : 
  215484             : //############################################################################
  215485             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  215486             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  215487             :  * not compressed. However, that stuff is not yet implemented! 
  215488             :  */
  215489             : unsigned long
  215490           0 : SgInterfaceSymbol::getNumberOfLastValidPointer()
  215491             :    {
  215492           0 :       SgInterfaceSymbol* testPointer = (SgInterfaceSymbol*)(SgInterfaceSymbol::pools.back());
  215493           0 :       unsigned long localIndex = SgInterfaceSymbol::pool_size - 1;
  215494           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  215495             :          {
  215496           0 :            localIndex--;
  215497             :          }
  215498           0 :       return (localIndex + SgInterfaceSymbol::pool_size * (SgInterfaceSymbol::pools.size()-1));
  215499             :    }
  215500             : 
  215501             : //############################################################################
  215502             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  215503             :  * memory pool and initializes the data member in class SgInterfaceSymbolStroageClass
  215504             :  * from its counterpart of SgInterfaceSymbol. The return value is just for checking, 
  215505             :  * that the whole StorageClassArray is initialized!
  215506             :  */
  215507             : unsigned long
  215508           0 : SgInterfaceSymbol::initializeStorageClassArray( SgInterfaceSymbolStorageClass *storageArray )
  215509             :    {
  215510           0 :      unsigned long storageCounter = 0;
  215511           0 :      std::vector < unsigned char* > :: const_iterator block = SgInterfaceSymbol::pools.begin();
  215512           0 :      SgInterfaceSymbol* pointer = NULL;
  215513           0 :      while ( block != SgInterfaceSymbol::pools.end() ) {
  215514           0 :           pointer = (SgInterfaceSymbol*) (*block);
  215515           0 :           for ( unsigned i = 0; i < SgInterfaceSymbol::pool_size; ++i ) {
  215516           0 :                if ( pointer->get_freepointer() != NULL ) {
  215517           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  215518           0 :                  storageArray++;
  215519           0 :                  storageCounter++;
  215520             :                }
  215521           0 :                pointer++;
  215522             :              }
  215523           0 :            block++;
  215524             :         }
  215525           0 :      return storageCounter;
  215526             :    }
  215527             : 
  215528             : /* #line 215529 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  215529             : 
  215530             : 
  215531             : 
  215532             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  215533             : 
  215534             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  215535             : 
  215536             : //############################################################################
  215537             : /* JH (02/02/2006) Constructor of the IR node SgCommonSymbol that takes its 
  215538             :  * corresponding StorageClass as parameter
  215539             :  */
  215540           0 : SgCommonSymbol :: SgCommonSymbol ( const SgCommonSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  215541             :    {
  215542             : 
  215543             : 
  215544             : /* #line 215545 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  215545             : 
  215546           0 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  215547           0 :      p_declaration =  (SgInitializedName*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_declaration) );
  215548             : 
  215549             : 
  215550             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  215551             : 
  215552             : 
  215553           0 :    }
  215554             : 
  215555             : //############################################################################
  215556             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  215557             :  * within the working AST. 
  215558             :  */
  215559           0 : SgCommonSymbol * SgCommonSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  215560           0 :      SgCommonSymbol* returnPointer = NULL;
  215561           0 :      if ( globalIndex != 0 )
  215562             :         {
  215563             : 
  215564             : #if FILE_IO_EXTRA_CHECK
  215565           0 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgCommonSymbol ) ) <= globalIndex ) ;
  215566           0 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCommonSymbol + 1 ) ) );
  215567             : #endif
  215568           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgCommonSymbol )  
  215569           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgCommonSymbol );
  215570           0 :           unsigned long positionInPool = localIndex % SgCommonSymbol::pool_size;
  215571           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCommonSymbol::pool_size;
  215572             : 
  215573             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  215574             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  215575             : 
  215576           0 :           returnPointer = &( ( (SgCommonSymbol*)(SgCommonSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  215577             : 
  215578           0 :           ROSE_ASSERT( returnPointer != NULL ) ;
  215579             :         }
  215580           0 :      return returnPointer ;
  215581             :    }
  215582             : 
  215583             : //############################################################################
  215584             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  215585             :   for the AST with the index astIndex
  215586             : */
  215587           0 : SgCommonSymbol * SgCommonSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  215588           0 :      SgCommonSymbol* returnPointer = NULL;
  215589           0 :      if ( globalIndex != 0 )
  215590             :         {
  215591             : 
  215592             : #if FILE_IO_EXTRA_CHECK
  215593           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgCommonSymbol ) ) <= globalIndex ) ;
  215594           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCommonSymbol + 1 ) ) );
  215595             : #endif
  215596           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgCommonSymbol )
  215597           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgCommonSymbol );
  215598           0 :           unsigned long positionInPool = localIndex % SgCommonSymbol::pool_size ;
  215599           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgCommonSymbol::pool_size ;
  215600             : 
  215601             : #if FILE_IO_EXTRA_CHECK
  215602             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  215603             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  215604             : #endif
  215605             : 
  215606           0 :           returnPointer = &( ( (SgCommonSymbol*)(SgCommonSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  215607             : 
  215608             : #if FILE_IO_EXTRA_CHECK
  215609           0 :           assert ( returnPointer != NULL ) ;
  215610             : #endif
  215611             :         }
  215612           0 :      return returnPointer ;
  215613             :    }
  215614             : 
  215615             : //############################################################################
  215616             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  215617             :  * pool size! We set for every valid object in the memory pool the freepointer
  215618             :  * to the global index and increase the global index afterwards. For all the 
  215619             :  * invalid objects (means address ranges within the memory pool that were not
  215620             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  215621             :  * distinguish valid from invalid objects! 
  215622             :  */
  215623             : unsigned long
  215624           5 : SgCommonSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  215625             :    {
  215626           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  215627           5 :      SgCommonSymbol* pointer = NULL;
  215628           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  215629           5 :      std::vector < unsigned char* > :: const_iterator block;
  215630           5 :      for ( block = SgCommonSymbol::pools.begin(); block != SgCommonSymbol::pools.end() ; ++block )
  215631             :         {
  215632           0 :           pointer = (SgCommonSymbol*)(*block);
  215633           0 :           for (unsigned i = 0; i < SgCommonSymbol::pool_size; ++i )
  215634             :              {
  215635             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  215636             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  215637             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  215638             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  215639             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  215640             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  215641             :             // properly; so this will have to be checked next.
  215642             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  215643             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  215644           0 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  215645             :                   {
  215646           0 :                     pointer[i].set_freepointer((SgCommonSymbol*)(globalIndex));
  215647           0 :                     globalIndex++;
  215648             :                   }
  215649             :                else
  215650             :                   {
  215651           0 :                     pointer[i].set_freepointer(NULL);
  215652             :                   }
  215653             :               }
  215654             :         }
  215655           5 :      return globalIndex;
  215656             :    }
  215657             : 
  215658             : //############################################################################
  215659             : // JH (01/14/2006)
  215660             : void
  215661           5 : SgCommonSymbol::resetValidFreepointers( )
  215662             :    {
  215663           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  215664           5 :      SgCommonSymbol* pointer = NULL;
  215665           5 :      std::vector < unsigned char* > :: const_iterator block;
  215666           5 :      SgCommonSymbol* pointerOfLinkedList = NULL;
  215667           5 :      for ( block = SgCommonSymbol::pools.begin(); block != SgCommonSymbol::pools.end() ; ++block )
  215668             :         {
  215669           0 :           pointer = (SgCommonSymbol*)(*block);
  215670           0 :           for (unsigned i = 0; i < SgCommonSymbol::pool_size; ++i )
  215671             :              {
  215672             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  215673             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  215674             :             // memory blocks!.
  215675           0 :                if ( pointer[i].get_freepointer() != NULL )
  215676             :                   {
  215677           0 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  215678             :                   }
  215679             :                else
  215680             :                   {
  215681           0 :                     if ( pointerOfLinkedList == NULL )
  215682             :                        {
  215683           0 :                          SgCommonSymbol::next_node = &(pointer[i]);
  215684             :                        }
  215685             :                     else
  215686             :                        {
  215687             :                       // printf ("In SgCommonSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  215688           0 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  215689             :                        }
  215690             :                     pointerOfLinkedList = &(pointer[i]);
  215691             :                   }
  215692             :               }
  215693             :         }
  215694             : 
  215695           5 :      if ( pointerOfLinkedList != NULL )
  215696             :         {
  215697             :        // printf ("In SgCommonSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  215698           0 :           pointerOfLinkedList->set_freepointer(NULL);
  215699             :        // DQ (6/6/2010): Temporary debugging...
  215700             :        //   ROSE_ASSERT(false);
  215701             :         }
  215702             : 
  215703           5 :      return ;
  215704             :    }
  215705             : 
  215706             : //############################################################################
  215707             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  215708             :  * within the memory pool and resets the freepointers, in order to achieve a 
  215709             :  * linked list, that has no jumps and starts at the beginning! This function 
  215710             :  * does not extend the memory pool, since we do not delete any memory blocks,
  215711             :  * but delete the valid objects.  
  215712             :  */
  215713             : void
  215714           0 : SgCommonSymbol::clearMemoryPool( )
  215715             :    {
  215716             :   // printf ("Inside of SgCommonSymbol::clearMemoryPool() \n");
  215717             : 
  215718           0 :      SgCommonSymbol* pointer = NULL, *tempPointer = NULL;
  215719           0 :      std::vector < unsigned char* > :: const_iterator block;
  215720           0 :      if ( SgCommonSymbol::pools.empty() == false )
  215721             :         {
  215722           0 :           block = SgCommonSymbol::pools.begin() ;
  215723           0 :           SgCommonSymbol::next_node = (SgCommonSymbol*) (*block);
  215724             : 
  215725           0 :           while ( block != SgCommonSymbol::pools.end() )
  215726             :              {
  215727           0 :                pointer = (SgCommonSymbol*) (*block);
  215728           0 :                if ( tempPointer != NULL )
  215729             :                   {
  215730           0 :                     tempPointer->set_freepointer(pointer);
  215731             :                   }
  215732           0 :                for (unsigned i = 0; i < SgCommonSymbol::pool_size - 1; ++i)
  215733             :                   {
  215734           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  215735             :                   }
  215736           0 :                 pointer[SgCommonSymbol::pool_size-1].set_freepointer(NULL);
  215737           0 :                 tempPointer = &(pointer[SgCommonSymbol::pool_size-1]);
  215738           0 :                 ++block;
  215739             :              }
  215740             :         }
  215741           0 :    }
  215742             : 
  215743           5 : void SgCommonSymbol::deleteMemoryPool() {
  215744           5 :   for (auto p: SgCommonSymbol::pools) {
  215745           0 :     ROSE_FREE(p);
  215746             :   }
  215747           5 :   SgCommonSymbol::next_node = nullptr;
  215748           5 :   SgCommonSymbol::pools.clear();
  215749           5 : }
  215750             : 
  215751             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  215752             : //                 reading multiple binary files to for a single AST.
  215753             : /////////// new version ////////////////////////////////
  215754             : //############################################################################
  215755             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  215756             : void
  215757           2 : SgCommonSymbol::extendMemoryPoolForFileIO( )
  215758             :   {
  215759           2 :     size_t blockIndex = SgCommonSymbol::pools.size();
  215760           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonSymbol);
  215761             : 
  215762           2 :     while ( (blockIndex * SgCommonSymbol::pool_size) < newPoolSize)
  215763             :       {
  215764             : #if ROSE_ALLOC_TRACE
  215765             :         if (blockIndex > 0) {
  215766             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonSymbol) = %" PRIuPTR " SgCommonSymbol::pool_size = %d \n",
  215767             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgCommonSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgCommonSymbol),SgCommonSymbol::pool_size);
  215768             :         }
  215769             : #endif
  215770             : 
  215771           0 :         SgCommonSymbol * pointer = (SgCommonSymbol*) ROSE_MALLOC ( SgCommonSymbol::pool_size * sizeof(SgCommonSymbol) );
  215772           0 :         assert( pointer != NULL );
  215773             : #if ROSE_ALLOC_MEMSET == 1
  215774             :         memset(pointer, 0x00, SgCommonSymbol::pool_size * sizeof(SgCommonSymbol));
  215775             : #elif ROSE_ALLOC_MEMSET == 2
  215776             :         memset(pointer, 0xCC, SgCommonSymbol::pool_size * sizeof(SgCommonSymbol));
  215777             : #endif
  215778           0 :         SgCommonSymbol::pools.push_back( (unsigned char*)(pointer) );
  215779           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgCommonSymbol::pool_size * sizeof(SgCommonSymbol), V_SgCommonSymbol ) );
  215780             : 
  215781           0 :         if ( SgCommonSymbol::next_node != NULL ) {
  215782           0 :           if ( blockIndex > 0 ) {
  215783           0 :             SgCommonSymbol * blkptr = (SgCommonSymbol*)(SgCommonSymbol::pools[blockIndex-1]);
  215784           0 :             blkptr[ SgCommonSymbol::pool_size - 1 ].set_freepointer(pointer);
  215785             :           }
  215786             :         } else {
  215787           0 :           SgCommonSymbol::next_node = pointer;
  215788             :         }
  215789             : 
  215790           0 :         for (unsigned i = 0; i < SgCommonSymbol::pool_size-1; ++i)
  215791             :            {
  215792           0 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  215793             :            }
  215794           0 :         pointer[ SgCommonSymbol::pool_size -1 ].set_freepointer(NULL);
  215795             : 
  215796           0 :         blockIndex++;
  215797             :       }
  215798           2 :   }
  215799             : 
  215800             : //############################################################################
  215801             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  215802             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  215803             :  * not compressed. However, that stuff is not yet implemented! 
  215804             :  */
  215805             : unsigned long
  215806           0 : SgCommonSymbol::getNumberOfLastValidPointer()
  215807             :    {
  215808           0 :       SgCommonSymbol* testPointer = (SgCommonSymbol*)(SgCommonSymbol::pools.back());
  215809           0 :       unsigned long localIndex = SgCommonSymbol::pool_size - 1;
  215810           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  215811             :          {
  215812           0 :            localIndex--;
  215813             :          }
  215814           0 :       return (localIndex + SgCommonSymbol::pool_size * (SgCommonSymbol::pools.size()-1));
  215815             :    }
  215816             : 
  215817             : //############################################################################
  215818             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  215819             :  * memory pool and initializes the data member in class SgCommonSymbolStroageClass
  215820             :  * from its counterpart of SgCommonSymbol. The return value is just for checking, 
  215821             :  * that the whole StorageClassArray is initialized!
  215822             :  */
  215823             : unsigned long
  215824           0 : SgCommonSymbol::initializeStorageClassArray( SgCommonSymbolStorageClass *storageArray )
  215825             :    {
  215826           0 :      unsigned long storageCounter = 0;
  215827           0 :      std::vector < unsigned char* > :: const_iterator block = SgCommonSymbol::pools.begin();
  215828           0 :      SgCommonSymbol* pointer = NULL;
  215829           0 :      while ( block != SgCommonSymbol::pools.end() ) {
  215830           0 :           pointer = (SgCommonSymbol*) (*block);
  215831           0 :           for ( unsigned i = 0; i < SgCommonSymbol::pool_size; ++i ) {
  215832           0 :                if ( pointer->get_freepointer() != NULL ) {
  215833           0 :                  storageArray->pickOutIRNodeData (pointer) ;
  215834           0 :                  storageArray++;
  215835           0 :                  storageCounter++;
  215836             :                }
  215837           0 :                pointer++;
  215838             :              }
  215839           0 :            block++;
  215840             :         }
  215841           0 :      return storageCounter;
  215842             :    }
  215843             : 
  215844             : /* #line 215845 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  215845             : 
  215846             : 
  215847             : 
  215848             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  215849             : 
  215850             : /* JH (02/02/2006) ROSETTA generated code, do not change!! */
  215851             : 
  215852             : //############################################################################
  215853             : /* JH (02/02/2006) Constructor of the IR node SgAliasSymbol that takes its 
  215854             :  * corresponding StorageClass as parameter
  215855             :  */
  215856       13984 : SgAliasSymbol :: SgAliasSymbol ( const SgAliasSymbolStorageClass& storageSource )   : SgSymbol (storageSource)
  215857             :    {
  215858             : 
  215859             : 
  215860             : /* #line 215861 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  215861             : 
  215862       13984 :      assert ( p_freepointer == AST_FileIO::IS_VALID_POINTER() ) ; 
  215863       13984 :      p_alias =  (SgSymbol*)( AST_FILE_IO::getSgClassPointerFromGlobalIndex ( storageSource.storageOf_alias) );
  215864       13984 :      p_isRenamed = storageSource.storageOf_isRenamed ;
  215865       13984 :      p_new_name = SgName ( storageSource.storageOf_new_name ) ;
  215866       13984 :      p_causal_nodes = storageSource.storageOf_causal_nodes.rebuildDataStoredInEasyStorageClass() ;
  215867       13984 :      SgNodePtrList::iterator i_causal_nodes = p_causal_nodes.begin() ; 
  215868       19211 :      for ( ; i_causal_nodes != p_causal_nodes.end(); ++i_causal_nodes ) 
  215869             :         {
  215870        5227 :           (*i_causal_nodes) = (SgNodePtrList::value_type)(AST_FILE_IO::getSgClassPointerFromGlobalIndex ( (unsigned long)(*i_causal_nodes) ) );
  215871             :         }
  215872             : 
  215873             : 
  215874             : /* #line 11 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarSourceOfIRNodesAstFileIOSupport.macro" */
  215875             : 
  215876             : 
  215877       13984 :    }
  215878             : 
  215879             : //############################################################################
  215880             : /* JH (11/23/2005) : computing the pointer to the passed global index, specific 
  215881             :  * within the working AST. 
  215882             :  */
  215883       13198 : SgAliasSymbol * SgAliasSymbol::getPointerFromGlobalIndex ( unsigned long globalIndex ) {
  215884       13198 :      SgAliasSymbol* returnPointer = NULL;
  215885       13198 :      if ( globalIndex != 0 )
  215886             :         {
  215887             : 
  215888             : #if FILE_IO_EXTRA_CHECK
  215889       13198 :           ROSE_ASSERT( ( AST_FILE_IO::getAccumulatedPoolSizeOfNewAst( V_SgAliasSymbol ) ) <= globalIndex ) ;
  215890       13198 :           ROSE_ASSERT( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAliasSymbol + 1 ) ) );
  215891             : #endif
  215892       13198 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfNewAst ( V_SgAliasSymbol )  
  215893       13198 :                                                  + AST_FILE_IO::getSizeOfMemoryPool ( V_SgAliasSymbol );
  215894       13198 :           unsigned long positionInPool = localIndex % SgAliasSymbol::pool_size;
  215895       13198 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAliasSymbol::pool_size;
  215896             : 
  215897             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  215898             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  215899             : 
  215900       13198 :           returnPointer = &( ( (SgAliasSymbol*)(SgAliasSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  215901             : 
  215902       13198 :           ROSE_ASSERT( returnPointer != NULL ) ;
  215903             :         }
  215904       13198 :      return returnPointer ;
  215905             :    }
  215906             : 
  215907             : //############################################################################
  215908             : /*JH (11/23/2005) : computing the pointer to the passed global index, specific 
  215909             :   for the AST with the index astIndex
  215910             : */
  215911           0 : SgAliasSymbol * SgAliasSymbol::getPointerFromGlobalIndex ( AstSpecificDataManagingClass *astInPool, unsigned long globalIndex ) {
  215912           0 :      SgAliasSymbol* returnPointer = NULL;
  215913           0 :      if ( globalIndex != 0 )
  215914             :         {
  215915             : 
  215916             : #if FILE_IO_EXTRA_CHECK
  215917           0 :           assert ( ( AST_FILE_IO::getAccumulatedPoolSizeOfAst( astInPool, V_SgAliasSymbol ) ) <= globalIndex ) ;
  215918           0 :           assert ( globalIndex < (AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAliasSymbol + 1 ) ) );
  215919             : #endif
  215920           0 :           unsigned long localIndex = globalIndex - AST_FILE_IO::getAccumulatedPoolSizeOfAst ( astInPool, V_SgAliasSymbol )
  215921           0 :                                                  + AST_FILE_IO::getSizeOfMemoryPoolUpToAst ( astInPool, V_SgAliasSymbol );
  215922           0 :           unsigned long positionInPool = localIndex % SgAliasSymbol::pool_size ;
  215923           0 :           unsigned long memoryBlock = (localIndex - positionInPool) / SgAliasSymbol::pool_size ;
  215924             : 
  215925             : #if FILE_IO_EXTRA_CHECK
  215926             :           // assert ( 0 <= memoryBlock && memoryBlock < Memory_Block_List.size() ) ;
  215927             :           // assert ( 0 <= positionInPool && positionInPool < (unsigned long)(CLASS_ALLOCATION_POOL_SIZE) );
  215928             : #endif
  215929             : 
  215930           0 :           returnPointer = &( ( (SgAliasSymbol*)(SgAliasSymbol::pools[memoryBlock]) ) [positionInPool]) ;
  215931             : 
  215932             : #if FILE_IO_EXTRA_CHECK
  215933           0 :           assert ( returnPointer != NULL ) ;
  215934             : #endif
  215935             :         }
  215936           0 :      return returnPointer ;
  215937             :    }
  215938             : 
  215939             : //############################################################################
  215940             : /* JH (01/14/2006) Traverse memory pool, set global ids and return accumulated
  215941             :  * pool size! We set for every valid object in the memory pool the freepointer
  215942             :  * to the global index and increase the global index afterwards. For all the 
  215943             :  * invalid objects (means address ranges within the memory pool that were not
  215944             :  * returned by the new operator) the freepointer is set to NULL, in order to 
  215945             :  * distinguish valid from invalid objects! 
  215946             :  */
  215947             : unsigned long
  215948           5 : SgAliasSymbol::getNumberOfValidNodesAndSetGlobalIndexInFreepointer( unsigned long numberOfPreviousNodes )
  215949             :    {
  215950           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == false );
  215951           5 :      SgAliasSymbol* pointer = NULL;
  215952           5 :      unsigned long globalIndex = numberOfPreviousNodes ;
  215953           5 :      std::vector < unsigned char* > :: const_iterator block;
  215954          14 :      for ( block = SgAliasSymbol::pools.begin(); block != SgAliasSymbol::pools.end() ; ++block )
  215955             :         {
  215956           9 :           pointer = (SgAliasSymbol*)(*block);
  215957       18009 :           for (unsigned i = 0; i < SgAliasSymbol::pool_size; ++i )
  215958             :              {
  215959             :             // DQ (6/6/2010): In reading in multiple files, when the extendMemoryPoolForFileIO() function is called,
  215960             :             // we have entries with pointer[i].get_freepointer() set to NULL at the end of any newly allocated memory pool.
  215961             :             // These are rare and so are a problem that is difficult to reproduce except when the CLASSNAME::pool_size
  215962             :             // is set to 1 to test the pool extention at the price of performance.  In this case we want to reset the
  215963             :             // elements of the memory pool that have freepointer set to either AST_FileIO::IS_VALID_POINTER() or NULL.
  215964             :             // This should not be a problem if the AST resd reset the freepointer to AST_FileIO::IS_VALID_POINTER()
  215965             :             // properly; so this will have to be checked next.
  215966             :             // if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  215967             :             // if ( (pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER()) || (pointer[i].get_freepointer() == NULL) )
  215968       18000 :                if ( pointer[i].get_freepointer() == AST_FileIO::IS_VALID_POINTER() )
  215969             :                   {
  215970       13985 :                     pointer[i].set_freepointer((SgAliasSymbol*)(globalIndex));
  215971       13985 :                     globalIndex++;
  215972             :                   }
  215973             :                else
  215974             :                   {
  215975        4015 :                     pointer[i].set_freepointer(NULL);
  215976             :                   }
  215977             :               }
  215978             :         }
  215979           5 :      return globalIndex;
  215980             :    }
  215981             : 
  215982             : //############################################################################
  215983             : // JH (01/14/2006)
  215984             : void
  215985           5 : SgAliasSymbol::resetValidFreepointers( )
  215986             :    {
  215987           5 :      assert ( AST_FILE_IO::areFreepointersContainingGlobalIndices() == true );
  215988           5 :      SgAliasSymbol* pointer = NULL;
  215989           5 :      std::vector < unsigned char* > :: const_iterator block;
  215990           5 :      SgAliasSymbol* pointerOfLinkedList = NULL;
  215991          14 :      for ( block = SgAliasSymbol::pools.begin(); block != SgAliasSymbol::pools.end() ; ++block )
  215992             :         {
  215993           9 :           pointer = (SgAliasSymbol*)(*block);
  215994       18009 :           for (unsigned i = 0; i < SgAliasSymbol::pool_size; ++i )
  215995             :              {
  215996             :             // DQ (6/6/2010): This would seem to mark all of the rest of the entries in a memory block of the memory pool to be valid
  215997             :             // even when they are not really used as valid IR nodes.  Debug this case when we have everything working for size 1
  215998             :             // memory blocks!.
  215999       18000 :                if ( pointer[i].get_freepointer() != NULL )
  216000             :                   {
  216001       13985 :                     pointer[i].set_freepointer(AST_FileIO::IS_VALID_POINTER()) ;
  216002             :                   }
  216003             :                else
  216004             :                   {
  216005        4015 :                     if ( pointerOfLinkedList == NULL )
  216006             :                        {
  216007           3 :                          SgAliasSymbol::next_node = &(pointer[i]);
  216008             :                        }
  216009             :                     else
  216010             :                        {
  216011             :                       // printf ("In SgAliasSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointer[i].class_name().c_str(),pointer[i].get_freepointer(),&(pointer[i]));
  216012        4012 :                          pointerOfLinkedList->set_freepointer(&(pointer[i]));
  216013             :                        }
  216014             :                     pointerOfLinkedList = &(pointer[i]);
  216015             :                   }
  216016             :               }
  216017             :         }
  216018             : 
  216019           5 :      if ( pointerOfLinkedList != NULL )
  216020             :         {
  216021             :        // printf ("In SgAliasSymbol::resetValidFreepointers(): Resetting the freepointer of %p = %s from %p to %p \n",pointerOfLinkedList,pointerOfLinkedList->class_name().c_str(),pointerOfLinkedList->get_freepointer(),(void*)NULL);
  216022           3 :           pointerOfLinkedList->set_freepointer(NULL);
  216023             :        // DQ (6/6/2010): Temporary debugging...
  216024             :        //   ROSE_ASSERT(false);
  216025             :         }
  216026             : 
  216027           5 :      return ;
  216028             :    }
  216029             : 
  216030             : //############################################################################
  216031             : /* JH (01/14/2006) clearing the memory pool. This method deletes all objects 
  216032             :  * within the memory pool and resets the freepointers, in order to achieve a 
  216033             :  * linked list, that has no jumps and starts at the beginning! This function 
  216034             :  * does not extend the memory pool, since we do not delete any memory blocks,
  216035             :  * but delete the valid objects.  
  216036             :  */
  216037             : void
  216038           0 : SgAliasSymbol::clearMemoryPool( )
  216039             :    {
  216040             :   // printf ("Inside of SgAliasSymbol::clearMemoryPool() \n");
  216041             : 
  216042           0 :      SgAliasSymbol* pointer = NULL, *tempPointer = NULL;
  216043           0 :      std::vector < unsigned char* > :: const_iterator block;
  216044           0 :      if ( SgAliasSymbol::pools.empty() == false )
  216045             :         {
  216046           0 :           block = SgAliasSymbol::pools.begin() ;
  216047           0 :           SgAliasSymbol::next_node = (SgAliasSymbol*) (*block);
  216048             : 
  216049           0 :           while ( block != SgAliasSymbol::pools.end() )
  216050             :              {
  216051           0 :                pointer = (SgAliasSymbol*) (*block);
  216052           0 :                if ( tempPointer != NULL )
  216053             :                   {
  216054           0 :                     tempPointer->set_freepointer(pointer);
  216055             :                   }
  216056           0 :                for (unsigned i = 0; i < SgAliasSymbol::pool_size - 1; ++i)
  216057             :                   {
  216058           0 :                     pointer[i].set_freepointer(&(pointer[i+1]));
  216059             :                   }
  216060           0 :                 pointer[SgAliasSymbol::pool_size-1].set_freepointer(NULL);
  216061           0 :                 tempPointer = &(pointer[SgAliasSymbol::pool_size-1]);
  216062           0 :                 ++block;
  216063             :              }
  216064             :         }
  216065           0 :    }
  216066             : 
  216067           5 : void SgAliasSymbol::deleteMemoryPool() {
  216068          22 :   for (auto p: SgAliasSymbol::pools) {
  216069          17 :     ROSE_FREE(p);
  216070             :   }
  216071           5 :   SgAliasSymbol::next_node = nullptr;
  216072           5 :   SgAliasSymbol::pools.clear();
  216073           5 : }
  216074             : 
  216075             : // DQ (4/30/2006): New version of code added (from Jochen) to fix bug in
  216076             : //                 reading multiple binary files to for a single AST.
  216077             : /////////// new version ////////////////////////////////
  216078             : //############################################################################
  216079             : // JH (01/14/2006) Traversal for the MemoryPool, used for Ast file io
  216080             : void
  216081           2 : SgAliasSymbol::extendMemoryPoolForFileIO( )
  216082             :   {
  216083           2 :     size_t blockIndex = SgAliasSymbol::pools.size();
  216084           2 :     size_t newPoolSize = AST_FILE_IO::getSizeOfMemoryPool(V_SgAliasSymbol) + AST_FILE_IO::getPoolSizeOfNewAst(V_SgAliasSymbol);
  216085             : 
  216086          10 :     while ( (blockIndex * SgAliasSymbol::pool_size) < newPoolSize)
  216087             :       {
  216088             : #if ROSE_ALLOC_TRACE
  216089             :         if (blockIndex > 0) {
  216090             :           printf ("blockIndex = %lu newPoolSize = %" PRIuPTR " AST_FILE_IO::getSizeOfMemoryPool(V_SgAliasSymbol) = %" PRIuPTR " AST_FILE_IO::getPoolSizeOfNewAst(V_SgAliasSymbol) = %" PRIuPTR " SgAliasSymbol::pool_size = %d \n",
  216091             :            blockIndex,newPoolSize,AST_FILE_IO::getSizeOfMemoryPool(V_SgAliasSymbol),AST_FILE_IO::getPoolSizeOfNewAst(V_SgAliasSymbol),SgAliasSymbol::pool_size);
  216092             :         }
  216093             : #endif
  216094             : 
  216095           8 :         SgAliasSymbol * pointer = (SgAliasSymbol*) ROSE_MALLOC ( SgAliasSymbol::pool_size * sizeof(SgAliasSymbol) );
  216096           8 :         assert( pointer != NULL );
  216097             : #if ROSE_ALLOC_MEMSET == 1
  216098             :         memset(pointer, 0x00, SgAliasSymbol::pool_size * sizeof(SgAliasSymbol));
  216099             : #elif ROSE_ALLOC_MEMSET == 2
  216100             :         memset(pointer, 0xCC, SgAliasSymbol::pool_size * sizeof(SgAliasSymbol));
  216101             : #endif
  216102           8 :         SgAliasSymbol::pools.push_back( (unsigned char*)(pointer) );
  216103           8 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) pointer, SgAliasSymbol::pool_size * sizeof(SgAliasSymbol), V_SgAliasSymbol ) );
  216104             : 
  216105           8 :         if ( SgAliasSymbol::next_node != NULL ) {
  216106           6 :           if ( blockIndex > 0 ) {
  216107           6 :             SgAliasSymbol * blkptr = (SgAliasSymbol*)(SgAliasSymbol::pools[blockIndex-1]);
  216108           6 :             blkptr[ SgAliasSymbol::pool_size - 1 ].set_freepointer(pointer);
  216109             :           }
  216110             :         } else {
  216111           2 :           SgAliasSymbol::next_node = pointer;
  216112             :         }
  216113             : 
  216114       16000 :         for (unsigned i = 0; i < SgAliasSymbol::pool_size-1; ++i)
  216115             :            {
  216116       15992 :              pointer [ i ].set_freepointer(&(pointer[i+1]));
  216117             :            }
  216118           8 :         pointer[ SgAliasSymbol::pool_size -1 ].set_freepointer(NULL);
  216119             : 
  216120           8 :         blockIndex++;
  216121             :       }
  216122           2 :   }
  216123             : 
  216124             : //############################################################################
  216125             : /* JH (04/01/2006) Method that delivers the last valid object within a memory
  216126             :  * pool. This could be used, to read new ASTs even, if the memory pools are 
  216127             :  * not compressed. However, that stuff is not yet implemented! 
  216128             :  */
  216129             : unsigned long
  216130           0 : SgAliasSymbol::getNumberOfLastValidPointer()
  216131             :    {
  216132           0 :       SgAliasSymbol* testPointer = (SgAliasSymbol*)(SgAliasSymbol::pools.back());
  216133           0 :       unsigned long localIndex = SgAliasSymbol::pool_size - 1;
  216134           0 :       while (testPointer[localIndex].get_freepointer() !=  AST_FileIO::IS_VALID_POINTER() )
  216135             :          {
  216136           0 :            localIndex--;
  216137             :          }
  216138           0 :       return (localIndex + SgAliasSymbol::pool_size * (SgAliasSymbol::pools.size()-1));
  216139             :    }
  216140             : 
  216141             : //############################################################################
  216142             : /* JH (01/14/2006) function that steps through the valid IR nodes in the 
  216143             :  * memory pool and initializes the data member in class SgAliasSymbolStroageClass
  216144             :  * from its counterpart of SgAliasSymbol. The return value is just for checking, 
  216145             :  * that the whole StorageClassArray is initialized!
  216146             :  */
  216147             : unsigned long
  216148           3 : SgAliasSymbol::initializeStorageClassArray( SgAliasSymbolStorageClass *storageArray )
  216149             :    {
  216150           3 :      unsigned long storageCounter = 0;
  216151           3 :      std::vector < unsigned char* > :: const_iterator block = SgAliasSymbol::pools.begin();
  216152           3 :      SgAliasSymbol* pointer = NULL;
  216153          12 :      while ( block != SgAliasSymbol::pools.end() ) {
  216154           9 :           pointer = (SgAliasSymbol*) (*block);
  216155       18009 :           for ( unsigned i = 0; i < SgAliasSymbol::pool_size; ++i ) {
  216156       18000 :                if ( pointer->get_freepointer() != NULL ) {
  216157       13985 :                  storageArray->pickOutIRNodeData (pointer) ;
  216158       13985 :                  storageArray++;
  216159       13985 :                  storageCounter++;
  216160             :                }
  216161       18000 :                pointer++;
  216162             :              }
  216163           9 :            block++;
  216164             :         }
  216165           3 :      return storageCounter;
  216166             :    }
  216167             : 
  216168             : /* #line 216169 "../../../src/frontend/SageIII//astFileIO//SourcesOfIRNodesAstFileIOSupport.C" */
  216169             : 
  216170             : 

Generated by: LCOV version 1.14